/* Mapbox GL JS is Copyright © 2020 Mapbox and subject to the Mapbox Terms of Service ((https://www.mapbox.com/legal/tos/). */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.mapboxgl = factory()); })(this, (function () { 'use strict'; /* eslint-disable */ var shared, worker, mapboxgl; // define gets called three times: one for each chunk. we rely on the order // they're imported to know which is which function define(_, chunk) { if (!shared) { shared = chunk; } else if (!worker) { worker = chunk; } else { var workerBundleString = "self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; (" + shared + ")(sharedChunk); (" + worker + ")(sharedChunk); self.onerror = null;" var sharedChunk = {}; shared(sharedChunk); mapboxgl = chunk(sharedChunk); if (typeof window !== 'undefined' && window && window.URL && window.URL.createObjectURL) { mapboxgl.workerUrl = window.URL.createObjectURL(new Blob([workerBundleString], { type: 'text/javascript' })); } } } define(["exports"],(function(t){function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var r,n={},i={};function s(){if(r)return i;r=1,Object.defineProperty(i,"__esModule",{value:!0}),i.setMatrixArrayType=function(t){i.ARRAY_TYPE=e=t;},i.toRadian=function(t){return t*s},i.equals=function(e,r){return Math.abs(e-r)<=t*Math.max(1,Math.abs(e),Math.abs(r))},i.RANDOM=i.ARRAY_TYPE=i.EPSILON=void 0;var t=1e-6;i.EPSILON=t;var e="undefined"!=typeof Float32Array?Float32Array:Array;i.ARRAY_TYPE=e;var n=Math.random;i.RANDOM=n;var s=Math.PI/180;return Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),i}var a,o={};function l(){if(a)return o;function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}a=1,Object.defineProperty(o,"__esModule",{value:!0}),o.create=function(){var t=new e.ARRAY_TYPE(4);return e.ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t},o.clone=function(t){var r=new e.ARRAY_TYPE(4);return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r},o.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},o.identity=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t},o.fromValues=function(t,r,n,i){var s=new e.ARRAY_TYPE(4);return s[0]=t,s[1]=r,s[2]=n,s[3]=i,s},o.set=function(t,e,r,n,i){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t},o.transpose=function(t,e){if(t===e){var r=e[1];t[1]=e[2],t[2]=r;}else t[0]=e[0],t[1]=e[2],t[2]=e[1],t[3]=e[3];return t},o.invert=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=r*s-i*n;return a?(t[0]=s*(a=1/a),t[1]=-n*a,t[2]=-i*a,t[3]=r*a,t):null},o.adjoint=function(t,e){var r=e[0];return t[0]=e[3],t[1]=-e[1],t[2]=-e[2],t[3]=r,t},o.determinant=function(t){return t[0]*t[3]-t[2]*t[1]},o.multiply=n,o.rotate=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=Math.sin(r),l=Math.cos(r);return t[0]=n*l+s*o,t[1]=i*l+a*o,t[2]=n*-o+s*l,t[3]=i*-o+a*l,t},o.scale=function(t,e,r){var n=e[1],i=e[2],s=e[3],a=r[0],o=r[1];return t[0]=e[0]*a,t[1]=n*a,t[2]=i*o,t[3]=s*o,t},o.fromRotation=function(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=-r,t[3]=n,t},o.fromScaling=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t},o.str=function(t){return "mat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},o.frob=function(t){return Math.hypot(t[0],t[1],t[2],t[3])},o.LDU=function(t,e,r,n){return t[2]=n[2]/n[0],r[0]=n[0],r[1]=n[1],r[3]=n[3]-t[2]*r[1],[t,e,r]},o.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t},o.subtract=i,o.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]},o.equals=function(t,r){var n=t[0],i=t[1],s=t[2],a=t[3],o=r[0],l=r[1],u=r[2],c=r[3];return Math.abs(n-o)<=e.EPSILON*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(i-l)<=e.EPSILON*Math.max(1,Math.abs(i),Math.abs(l))&&Math.abs(s-u)<=e.EPSILON*Math.max(1,Math.abs(s),Math.abs(u))&&Math.abs(a-c)<=e.EPSILON*Math.max(1,Math.abs(a),Math.abs(c))},o.multiplyScalar=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t},o.multiplyScalarAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t},o.sub=o.mul=void 0;var e=function(e,n){if(e&&e.__esModule)return e;if(null===e||"object"!==t(e)&&"function"!=typeof e)return {default:e};var i=r(void 0);if(i&&i.has(e))return i.get(e);var s={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var l=a?Object.getOwnPropertyDescriptor(e,o):null;l&&(l.get||l.set)?Object.defineProperty(s,o,l):s[o]=e[o];}return s.default=e,i&&i.set(e,s),s}(s());function r(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return (r=function(t){return t?n:e})(t)}function n(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=r[0],l=r[1],u=r[2],c=r[3];return t[0]=n*o+s*l,t[1]=i*o+a*l,t[2]=n*u+s*c,t[3]=i*u+a*c,t}function i(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}return o.mul=n,o.sub=i,o}var u,c={};function h(){if(u)return c;function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}u=1,Object.defineProperty(c,"__esModule",{value:!0}),c.create=function(){var t=new e.ARRAY_TYPE(6);return e.ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0,t[4]=0,t[5]=0),t[0]=1,t[3]=1,t},c.clone=function(t){var r=new e.ARRAY_TYPE(6);return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[4]=t[4],r[5]=t[5],r},c.copy=function(t,e){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},c.identity=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t},c.fromValues=function(t,r,n,i,s,a){var o=new e.ARRAY_TYPE(6);return o[0]=t,o[1]=r,o[2]=n,o[3]=i,o[4]=s,o[5]=a,o},c.set=function(t,e,r,n,i,s,a){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t[4]=s,t[5]=a,t},c.invert=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=r*s-n*i;return l?(t[0]=s*(l=1/l),t[1]=-n*l,t[2]=-i*l,t[3]=r*l,t[4]=(i*o-s*a)*l,t[5]=(n*a-r*o)*l,t):null},c.determinant=function(t){return t[0]*t[3]-t[1]*t[2]},c.multiply=n,c.rotate=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=Math.sin(r),c=Math.cos(r);return t[0]=n*c+s*u,t[1]=i*c+a*u,t[2]=n*-u+s*c,t[3]=i*-u+a*c,t[4]=o,t[5]=l,t},c.scale=function(t,e,r){var n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=r[0],u=r[1];return t[0]=e[0]*l,t[1]=n*l,t[2]=i*u,t[3]=s*u,t[4]=a,t[5]=o,t},c.translate=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=r[0],c=r[1];return t[0]=n,t[1]=i,t[2]=s,t[3]=a,t[4]=n*u+s*c+o,t[5]=i*u+a*c+l,t},c.fromRotation=function(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=-r,t[3]=n,t[4]=0,t[5]=0,t},c.fromScaling=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t[4]=0,t[5]=0,t},c.fromTranslation=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=e[0],t[5]=e[1],t},c.str=function(t){return "mat2d("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+")"},c.frob=function(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],1)},c.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t},c.subtract=i,c.multiplyScalar=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t},c.multiplyScalarAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t[4]=e[4]+r[4]*n,t[5]=e[5]+r[5]*n,t},c.exactEquals=function(t,e){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]},c.equals=function(t,r){var n=t[0],i=t[1],s=t[2],a=t[3],o=t[4],l=t[5],u=r[0],c=r[1],h=r[2],p=r[3],f=r[4],d=r[5];return Math.abs(n-u)<=e.EPSILON*Math.max(1,Math.abs(n),Math.abs(u))&&Math.abs(i-c)<=e.EPSILON*Math.max(1,Math.abs(i),Math.abs(c))&&Math.abs(s-h)<=e.EPSILON*Math.max(1,Math.abs(s),Math.abs(h))&&Math.abs(a-p)<=e.EPSILON*Math.max(1,Math.abs(a),Math.abs(p))&&Math.abs(o-f)<=e.EPSILON*Math.max(1,Math.abs(o),Math.abs(f))&&Math.abs(l-d)<=e.EPSILON*Math.max(1,Math.abs(l),Math.abs(d))},c.sub=c.mul=void 0;var e=function(e,n){if(e&&e.__esModule)return e;if(null===e||"object"!==t(e)&&"function"!=typeof e)return {default:e};var i=r(void 0);if(i&&i.has(e))return i.get(e);var s={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var l=a?Object.getOwnPropertyDescriptor(e,o):null;l&&(l.get||l.set)?Object.defineProperty(s,o,l):s[o]=e[o];}return s.default=e,i&&i.set(e,s),s}(s());function r(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return (r=function(t){return t?n:e})(t)}function n(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=r[0],c=r[1],h=r[2],p=r[3],f=r[4],d=r[5];return t[0]=n*u+s*c,t[1]=i*u+a*c,t[2]=n*h+s*p,t[3]=i*h+a*p,t[4]=n*f+s*d+o,t[5]=i*f+a*d+l,t}function i(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t}return c.mul=n,c.sub=i,c}var p,f={};function d(){if(p)return f;function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}p=1,Object.defineProperty(f,"__esModule",{value:!0}),f.create=function(){var t=new e.ARRAY_TYPE(9);return e.ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t},f.fromMat4=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t},f.clone=function(t){var r=new e.ARRAY_TYPE(9);return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[4]=t[4],r[5]=t[5],r[6]=t[6],r[7]=t[7],r[8]=t[8],r},f.copy=function(t,e){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},f.fromValues=function(t,r,n,i,s,a,o,l,u){var c=new e.ARRAY_TYPE(9);return c[0]=t,c[1]=r,c[2]=n,c[3]=i,c[4]=s,c[5]=a,c[6]=o,c[7]=l,c[8]=u,c},f.set=function(t,e,r,n,i,s,a,o,l,u){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t[4]=s,t[5]=a,t[6]=o,t[7]=l,t[8]=u,t},f.identity=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},f.transpose=function(t,e){if(t===e){var r=e[1],n=e[2],i=e[5];t[1]=e[3],t[2]=e[6],t[3]=r,t[5]=e[7],t[6]=n,t[7]=i;}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t},f.invert=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],u=e[7],c=e[8],h=c*a-o*u,p=-c*s+o*l,f=u*s-a*l,d=r*h+n*p+i*f;return d?(t[0]=h*(d=1/d),t[1]=(-c*n+i*u)*d,t[2]=(o*n-i*a)*d,t[3]=p*d,t[4]=(c*r-i*l)*d,t[5]=(-o*r+i*s)*d,t[6]=f*d,t[7]=(-u*r+n*l)*d,t[8]=(a*r-n*s)*d,t):null},f.adjoint=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],u=e[7],c=e[8];return t[0]=a*c-o*u,t[1]=i*u-n*c,t[2]=n*o-i*a,t[3]=o*l-s*c,t[4]=r*c-i*l,t[5]=i*s-r*o,t[6]=s*u-a*l,t[7]=n*l-r*u,t[8]=r*a-n*s,t},f.determinant=function(t){var e=t[3],r=t[4],n=t[5],i=t[6],s=t[7],a=t[8];return t[0]*(a*r-n*s)+t[1]*(-a*e+n*i)+t[2]*(s*e-r*i)},f.multiply=n,f.translate=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=r[0],f=r[1];return t[0]=n,t[1]=i,t[2]=s,t[3]=a,t[4]=o,t[5]=l,t[6]=p*n+f*a+u,t[7]=p*i+f*o+c,t[8]=p*s+f*l+h,t},f.rotate=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=Math.sin(r),f=Math.cos(r);return t[0]=f*n+p*a,t[1]=f*i+p*o,t[2]=f*s+p*l,t[3]=f*a-p*n,t[4]=f*o-p*i,t[5]=f*l-p*s,t[6]=u,t[7]=c,t[8]=h,t},f.scale=function(t,e,r){var n=r[0],i=r[1];return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=i*e[3],t[4]=i*e[4],t[5]=i*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t},f.fromTranslation=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=e[0],t[7]=e[1],t[8]=1,t},f.fromRotation=function(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=0,t[3]=-r,t[4]=n,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},f.fromScaling=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=e[1],t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},f.fromMat2d=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=0,t[3]=e[2],t[4]=e[3],t[5]=0,t[6]=e[4],t[7]=e[5],t[8]=1,t},f.fromQuat=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=r+r,o=n+n,l=i+i,u=r*a,c=n*a,h=n*o,p=i*a,f=i*o,d=i*l,m=s*a,y=s*o,g=s*l;return t[0]=1-h-d,t[3]=c-g,t[6]=p+y,t[1]=c+g,t[4]=1-u-d,t[7]=f-m,t[2]=p-y,t[5]=f+m,t[8]=1-u-h,t},f.normalFromMat4=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],u=e[7],c=e[8],h=e[9],p=e[10],f=e[11],d=e[12],m=e[13],y=e[14],g=e[15],x=r*o-n*a,b=r*l-i*a,v=r*u-s*a,w=n*l-i*o,_=n*u-s*o,M=i*u-s*l,A=c*m-h*d,S=c*y-p*d,I=c*g-f*d,P=h*y-p*m,z=h*g-f*m,k=p*g-f*y,T=x*k-b*z+v*P+w*I-_*S+M*A;return T?(t[0]=(o*k-l*z+u*P)*(T=1/T),t[1]=(l*I-a*k-u*S)*T,t[2]=(a*z-o*I+u*A)*T,t[3]=(i*z-n*k-s*P)*T,t[4]=(r*k-i*I+s*S)*T,t[5]=(n*I-r*z-s*A)*T,t[6]=(m*M-y*_+g*w)*T,t[7]=(y*v-d*M-g*b)*T,t[8]=(d*_-m*v+g*x)*T,t):null},f.projection=function(t,e,r){return t[0]=2/e,t[1]=0,t[2]=0,t[3]=0,t[4]=-2/r,t[5]=0,t[6]=-1,t[7]=1,t[8]=1,t},f.str=function(t){return "mat3("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+")"},f.frob=function(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])},f.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t},f.subtract=i,f.multiplyScalar=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t},f.multiplyScalarAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t[4]=e[4]+r[4]*n,t[5]=e[5]+r[5]*n,t[6]=e[6]+r[6]*n,t[7]=e[7]+r[7]*n,t[8]=e[8]+r[8]*n,t},f.exactEquals=function(t,e){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]},f.equals=function(t,r){var n=t[0],i=t[1],s=t[2],a=t[3],o=t[4],l=t[5],u=t[6],c=t[7],h=t[8],p=r[0],f=r[1],d=r[2],m=r[3],y=r[4],g=r[5],x=r[6],b=r[7],v=r[8];return Math.abs(n-p)<=e.EPSILON*Math.max(1,Math.abs(n),Math.abs(p))&&Math.abs(i-f)<=e.EPSILON*Math.max(1,Math.abs(i),Math.abs(f))&&Math.abs(s-d)<=e.EPSILON*Math.max(1,Math.abs(s),Math.abs(d))&&Math.abs(a-m)<=e.EPSILON*Math.max(1,Math.abs(a),Math.abs(m))&&Math.abs(o-y)<=e.EPSILON*Math.max(1,Math.abs(o),Math.abs(y))&&Math.abs(l-g)<=e.EPSILON*Math.max(1,Math.abs(l),Math.abs(g))&&Math.abs(u-x)<=e.EPSILON*Math.max(1,Math.abs(u),Math.abs(x))&&Math.abs(c-b)<=e.EPSILON*Math.max(1,Math.abs(c),Math.abs(b))&&Math.abs(h-v)<=e.EPSILON*Math.max(1,Math.abs(h),Math.abs(v))},f.sub=f.mul=void 0;var e=function(e,n){if(e&&e.__esModule)return e;if(null===e||"object"!==t(e)&&"function"!=typeof e)return {default:e};var i=r(void 0);if(i&&i.has(e))return i.get(e);var s={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var l=a?Object.getOwnPropertyDescriptor(e,o):null;l&&(l.get||l.set)?Object.defineProperty(s,o,l):s[o]=e[o];}return s.default=e,i&&i.set(e,s),s}(s());function r(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return (r=function(t){return t?n:e})(t)}function n(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=r[0],f=r[1],d=r[2],m=r[3],y=r[4],g=r[5],x=r[6],b=r[7],v=r[8];return t[0]=p*n+f*a+d*u,t[1]=p*i+f*o+d*c,t[2]=p*s+f*l+d*h,t[3]=m*n+y*a+g*u,t[4]=m*i+y*o+g*c,t[5]=m*s+y*l+g*h,t[6]=x*n+b*a+v*u,t[7]=x*i+b*o+v*c,t[8]=x*s+b*l+v*h,t}function i(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t}return f.mul=n,f.sub=i,f}var m,y={};function g(){if(m)return y;function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}m=1,Object.defineProperty(y,"__esModule",{value:!0}),y.create=function(){var t=new e.ARRAY_TYPE(16);return e.ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},y.clone=function(t){var r=new e.ARRAY_TYPE(16);return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[4]=t[4],r[5]=t[5],r[6]=t[6],r[7]=t[7],r[8]=t[8],r[9]=t[9],r[10]=t[10],r[11]=t[11],r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15],r},y.copy=function(t,e){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},y.fromValues=function(t,r,n,i,s,a,o,l,u,c,h,p,f,d,m,y){var g=new e.ARRAY_TYPE(16);return g[0]=t,g[1]=r,g[2]=n,g[3]=i,g[4]=s,g[5]=a,g[6]=o,g[7]=l,g[8]=u,g[9]=c,g[10]=h,g[11]=p,g[12]=f,g[13]=d,g[14]=m,g[15]=y,g},y.set=function(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m,y){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t[4]=s,t[5]=a,t[6]=o,t[7]=l,t[8]=u,t[9]=c,t[10]=h,t[11]=p,t[12]=f,t[13]=d,t[14]=m,t[15]=y,t},y.identity=n,y.transpose=function(t,e){if(t===e){var r=e[1],n=e[2],i=e[3],s=e[6],a=e[7],o=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=s,t[11]=e[14],t[12]=i,t[13]=a,t[14]=o;}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t},y.invert=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],u=e[7],c=e[8],h=e[9],p=e[10],f=e[11],d=e[12],m=e[13],y=e[14],g=e[15],x=r*o-n*a,b=r*l-i*a,v=r*u-s*a,w=n*l-i*o,_=n*u-s*o,M=i*u-s*l,A=c*m-h*d,S=c*y-p*d,I=c*g-f*d,P=h*y-p*m,z=h*g-f*m,k=p*g-f*y,T=x*k-b*z+v*P+w*I-_*S+M*A;return T?(t[0]=(o*k-l*z+u*P)*(T=1/T),t[1]=(i*z-n*k-s*P)*T,t[2]=(m*M-y*_+g*w)*T,t[3]=(p*_-h*M-f*w)*T,t[4]=(l*I-a*k-u*S)*T,t[5]=(r*k-i*I+s*S)*T,t[6]=(y*v-d*M-g*b)*T,t[7]=(c*M-p*v+f*b)*T,t[8]=(a*z-o*I+u*A)*T,t[9]=(n*I-r*z-s*A)*T,t[10]=(d*_-m*v+g*x)*T,t[11]=(h*v-c*_-f*x)*T,t[12]=(o*S-a*P-l*A)*T,t[13]=(r*P-n*S+i*A)*T,t[14]=(m*b-d*w-y*x)*T,t[15]=(c*w-h*b+p*x)*T,t):null},y.adjoint=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],u=e[7],c=e[8],h=e[9],p=e[10],f=e[11],d=e[12],m=e[13],y=e[14],g=e[15];return t[0]=o*(p*g-f*y)-h*(l*g-u*y)+m*(l*f-u*p),t[1]=-(n*(p*g-f*y)-h*(i*g-s*y)+m*(i*f-s*p)),t[2]=n*(l*g-u*y)-o*(i*g-s*y)+m*(i*u-s*l),t[3]=-(n*(l*f-u*p)-o*(i*f-s*p)+h*(i*u-s*l)),t[4]=-(a*(p*g-f*y)-c*(l*g-u*y)+d*(l*f-u*p)),t[5]=r*(p*g-f*y)-c*(i*g-s*y)+d*(i*f-s*p),t[6]=-(r*(l*g-u*y)-a*(i*g-s*y)+d*(i*u-s*l)),t[7]=r*(l*f-u*p)-a*(i*f-s*p)+c*(i*u-s*l),t[8]=a*(h*g-f*m)-c*(o*g-u*m)+d*(o*f-u*h),t[9]=-(r*(h*g-f*m)-c*(n*g-s*m)+d*(n*f-s*h)),t[10]=r*(o*g-u*m)-a*(n*g-s*m)+d*(n*u-s*o),t[11]=-(r*(o*f-u*h)-a*(n*f-s*h)+c*(n*u-s*o)),t[12]=-(a*(h*y-p*m)-c*(o*y-l*m)+d*(o*p-l*h)),t[13]=r*(h*y-p*m)-c*(n*y-i*m)+d*(n*p-i*h),t[14]=-(r*(o*y-l*m)-a*(n*y-i*m)+d*(n*l-i*o)),t[15]=r*(o*p-l*h)-a*(n*p-i*h)+c*(n*l-i*o),t},y.determinant=function(t){var e=t[0],r=t[1],n=t[2],i=t[3],s=t[4],a=t[5],o=t[6],l=t[7],u=t[8],c=t[9],h=t[10],p=t[11],f=t[12],d=t[13],m=t[14],y=t[15];return (e*a-r*s)*(h*y-p*m)-(e*o-n*s)*(c*y-p*d)+(e*l-i*s)*(c*m-h*d)+(r*o-n*a)*(u*y-p*f)-(r*l-i*a)*(u*m-h*f)+(n*l-i*o)*(u*d-c*f)},y.multiply=i,y.translate=function(t,e,r){var n,i,s,a,o,l,u,c,h,p,f,d,m=r[0],y=r[1],g=r[2];return e===t?(t[12]=e[0]*m+e[4]*y+e[8]*g+e[12],t[13]=e[1]*m+e[5]*y+e[9]*g+e[13],t[14]=e[2]*m+e[6]*y+e[10]*g+e[14],t[15]=e[3]*m+e[7]*y+e[11]*g+e[15]):(i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],f=e[10],d=e[11],t[0]=n=e[0],t[1]=i,t[2]=s,t[3]=a,t[4]=o,t[5]=l,t[6]=u,t[7]=c,t[8]=h,t[9]=p,t[10]=f,t[11]=d,t[12]=n*m+o*y+h*g+e[12],t[13]=i*m+l*y+p*g+e[13],t[14]=s*m+u*y+f*g+e[14],t[15]=a*m+c*y+d*g+e[15]),t},y.scale=function(t,e,r){var n=r[0],i=r[1],s=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*s,t[9]=e[9]*s,t[10]=e[10]*s,t[11]=e[11]*s,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},y.rotate=function(t,r,n,i){var s,a,o,l,u,c,h,p,f,d,m,y,g,x,b,v,w,_,M,A,S,I,P,z,k=i[0],T=i[1],E=i[2],B=Math.hypot(k,T,E);return B0?(n[0]=2*(u*l+p*i+c*o-h*s)/f,n[1]=2*(c*l+p*s+h*i-u*o)/f,n[2]=2*(h*l+p*o+u*s-c*i)/f):(n[0]=2*(u*l+p*i+c*o-h*s),n[1]=2*(c*l+p*s+h*i-u*o),n[2]=2*(h*l+p*o+u*s-c*i)),a(t,r,n),t},y.getTranslation=function(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t},y.getScaling=o,y.getRotation=function(t,r){var n=new e.ARRAY_TYPE(3);o(n,r);var i=1/n[0],s=1/n[1],a=1/n[2],l=r[0]*i,u=r[1]*s,c=r[2]*a,h=r[4]*i,p=r[5]*s,f=r[6]*a,d=r[8]*i,m=r[9]*s,y=r[10]*a,g=l+p+y,x=0;return g>0?(x=2*Math.sqrt(g+1),t[3]=.25*x,t[0]=(f-m)/x,t[1]=(d-c)/x,t[2]=(u-h)/x):l>p&&l>y?(x=2*Math.sqrt(1+l-p-y),t[3]=(f-m)/x,t[0]=.25*x,t[1]=(u+h)/x,t[2]=(d+c)/x):p>y?(x=2*Math.sqrt(1+p-l-y),t[3]=(d-c)/x,t[0]=(u+h)/x,t[1]=.25*x,t[2]=(f+m)/x):(x=2*Math.sqrt(1+y-l-p),t[3]=(u-h)/x,t[0]=(d+c)/x,t[1]=(f+m)/x,t[2]=.25*x),t},y.fromRotationTranslationScale=function(t,e,r,n){var i=e[0],s=e[1],a=e[2],o=e[3],l=i+i,u=s+s,c=a+a,h=i*l,p=i*u,f=i*c,d=s*u,m=s*c,y=a*c,g=o*l,x=o*u,b=o*c,v=n[0],w=n[1],_=n[2];return t[0]=(1-(d+y))*v,t[1]=(p+b)*v,t[2]=(f-x)*v,t[3]=0,t[4]=(p-b)*w,t[5]=(1-(h+y))*w,t[6]=(m+g)*w,t[7]=0,t[8]=(f+x)*_,t[9]=(m-g)*_,t[10]=(1-(h+d))*_,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t},y.fromRotationTranslationScaleOrigin=function(t,e,r,n,i){var s=e[0],a=e[1],o=e[2],l=e[3],u=s+s,c=a+a,h=o+o,p=s*u,f=s*c,d=s*h,m=a*c,y=a*h,g=o*h,x=l*u,b=l*c,v=l*h,w=n[0],_=n[1],M=n[2],A=i[0],S=i[1],I=i[2],P=(1-(m+g))*w,z=(f+v)*w,k=(d-b)*w,T=(f-v)*_,E=(1-(p+g))*_,B=(y+x)*_,V=(d+b)*M,C=(y-x)*M,R=(1-(p+m))*M;return t[0]=P,t[1]=z,t[2]=k,t[3]=0,t[4]=T,t[5]=E,t[6]=B,t[7]=0,t[8]=V,t[9]=C,t[10]=R,t[11]=0,t[12]=r[0]+A-(P*A+T*S+V*I),t[13]=r[1]+S-(z*A+E*S+C*I),t[14]=r[2]+I-(k*A+B*S+R*I),t[15]=1,t},y.fromQuat=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=r+r,o=n+n,l=i+i,u=r*a,c=n*a,h=n*o,p=i*a,f=i*o,d=i*l,m=s*a,y=s*o,g=s*l;return t[0]=1-h-d,t[1]=c+g,t[2]=p-y,t[3]=0,t[4]=c-g,t[5]=1-u-d,t[6]=f+m,t[7]=0,t[8]=p+y,t[9]=f-m,t[10]=1-u-h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},y.frustum=function(t,e,r,n,i,s,a){var o=1/(r-e),l=1/(i-n),u=1/(s-a);return t[0]=2*s*o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=2*s*l,t[6]=0,t[7]=0,t[8]=(r+e)*o,t[9]=(i+n)*l,t[10]=(a+s)*u,t[11]=-1,t[12]=0,t[13]=0,t[14]=a*s*2*u,t[15]=0,t},y.perspectiveNO=l,y.perspectiveZO=function(t,e,r,n,i){var s,a=1/Math.tan(e/2);return t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(t[10]=i*(s=1/(n-i)),t[14]=i*n*s):(t[10]=-1,t[14]=-n),t},y.perspectiveFromFieldOfView=function(t,e,r,n){var i=Math.tan(e.upDegrees*Math.PI/180),s=Math.tan(e.downDegrees*Math.PI/180),a=Math.tan(e.leftDegrees*Math.PI/180),o=Math.tan(e.rightDegrees*Math.PI/180),l=2/(a+o),u=2/(i+s);return t[0]=l,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=u,t[6]=0,t[7]=0,t[8]=-(a-o)*l*.5,t[9]=(i-s)*u*.5,t[10]=n/(r-n),t[11]=-1,t[12]=0,t[13]=0,t[14]=n*r/(r-n),t[15]=0,t},y.orthoNO=u,y.orthoZO=function(t,e,r,n,i,s,a){var o=1/(e-r),l=1/(n-i),u=1/(s-a);return t[0]=-2*o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=u,t[11]=0,t[12]=(e+r)*o,t[13]=(i+n)*l,t[14]=s*u,t[15]=1,t},y.lookAt=function(t,r,i,s){var a,o,l,u,c,h,p,f,d,m,y=r[0],g=r[1],x=r[2],b=s[0],v=s[1],w=s[2],_=i[0],M=i[1],A=i[2];return Math.abs(y-_)0&&(c*=f=1/Math.sqrt(f),h*=f,p*=f);var d=l*p-u*h,m=u*c-o*p,y=o*h-l*c;return (f=d*d+m*m+y*y)>0&&(d*=f=1/Math.sqrt(f),m*=f,y*=f),t[0]=d,t[1]=m,t[2]=y,t[3]=0,t[4]=h*y-p*m,t[5]=p*d-c*y,t[6]=c*m-h*d,t[7]=0,t[8]=c,t[9]=h,t[10]=p,t[11]=0,t[12]=i,t[13]=s,t[14]=a,t[15]=1,t},y.str=function(t){return "mat4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+", "+t[9]+", "+t[10]+", "+t[11]+", "+t[12]+", "+t[13]+", "+t[14]+", "+t[15]+")"},y.frob=function(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])},y.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t[9]=e[9]+r[9],t[10]=e[10]+r[10],t[11]=e[11]+r[11],t[12]=e[12]+r[12],t[13]=e[13]+r[13],t[14]=e[14]+r[14],t[15]=e[15]+r[15],t},y.subtract=c,y.multiplyScalar=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12]*r,t[13]=e[13]*r,t[14]=e[14]*r,t[15]=e[15]*r,t},y.multiplyScalarAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t[4]=e[4]+r[4]*n,t[5]=e[5]+r[5]*n,t[6]=e[6]+r[6]*n,t[7]=e[7]+r[7]*n,t[8]=e[8]+r[8]*n,t[9]=e[9]+r[9]*n,t[10]=e[10]+r[10]*n,t[11]=e[11]+r[11]*n,t[12]=e[12]+r[12]*n,t[13]=e[13]+r[13]*n,t[14]=e[14]+r[14]*n,t[15]=e[15]+r[15]*n,t},y.exactEquals=function(t,e){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]},y.equals=function(t,r){var n=t[0],i=t[1],s=t[2],a=t[3],o=t[4],l=t[5],u=t[6],c=t[7],h=t[8],p=t[9],f=t[10],d=t[11],m=t[12],y=t[13],g=t[14],x=t[15],b=r[0],v=r[1],w=r[2],_=r[3],M=r[4],A=r[5],S=r[6],I=r[7],P=r[8],z=r[9],k=r[10],T=r[11],E=r[12],B=r[13],V=r[14],C=r[15];return Math.abs(n-b)<=e.EPSILON*Math.max(1,Math.abs(n),Math.abs(b))&&Math.abs(i-v)<=e.EPSILON*Math.max(1,Math.abs(i),Math.abs(v))&&Math.abs(s-w)<=e.EPSILON*Math.max(1,Math.abs(s),Math.abs(w))&&Math.abs(a-_)<=e.EPSILON*Math.max(1,Math.abs(a),Math.abs(_))&&Math.abs(o-M)<=e.EPSILON*Math.max(1,Math.abs(o),Math.abs(M))&&Math.abs(l-A)<=e.EPSILON*Math.max(1,Math.abs(l),Math.abs(A))&&Math.abs(u-S)<=e.EPSILON*Math.max(1,Math.abs(u),Math.abs(S))&&Math.abs(c-I)<=e.EPSILON*Math.max(1,Math.abs(c),Math.abs(I))&&Math.abs(h-P)<=e.EPSILON*Math.max(1,Math.abs(h),Math.abs(P))&&Math.abs(p-z)<=e.EPSILON*Math.max(1,Math.abs(p),Math.abs(z))&&Math.abs(f-k)<=e.EPSILON*Math.max(1,Math.abs(f),Math.abs(k))&&Math.abs(d-T)<=e.EPSILON*Math.max(1,Math.abs(d),Math.abs(T))&&Math.abs(m-E)<=e.EPSILON*Math.max(1,Math.abs(m),Math.abs(E))&&Math.abs(y-B)<=e.EPSILON*Math.max(1,Math.abs(y),Math.abs(B))&&Math.abs(g-V)<=e.EPSILON*Math.max(1,Math.abs(g),Math.abs(V))&&Math.abs(x-C)<=e.EPSILON*Math.max(1,Math.abs(x),Math.abs(C))},y.sub=y.mul=y.ortho=y.perspective=void 0;var e=function(e,n){if(e&&e.__esModule)return e;if(null===e||"object"!==t(e)&&"function"!=typeof e)return {default:e};var i=r(void 0);if(i&&i.has(e))return i.get(e);var s={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var l=a?Object.getOwnPropertyDescriptor(e,o):null;l&&(l.get||l.set)?Object.defineProperty(s,o,l):s[o]=e[o];}return s.default=e,i&&i.set(e,s),s}(s());function r(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return (r=function(t){return t?n:e})(t)}function n(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function i(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],f=e[10],d=e[11],m=e[12],y=e[13],g=e[14],x=e[15],b=r[0],v=r[1],w=r[2],_=r[3];return t[0]=b*n+v*o+w*h+_*m,t[1]=b*i+v*l+w*p+_*y,t[2]=b*s+v*u+w*f+_*g,t[3]=b*a+v*c+w*d+_*x,t[4]=(b=r[4])*n+(v=r[5])*o+(w=r[6])*h+(_=r[7])*m,t[5]=b*i+v*l+w*p+_*y,t[6]=b*s+v*u+w*f+_*g,t[7]=b*a+v*c+w*d+_*x,t[8]=(b=r[8])*n+(v=r[9])*o+(w=r[10])*h+(_=r[11])*m,t[9]=b*i+v*l+w*p+_*y,t[10]=b*s+v*u+w*f+_*g,t[11]=b*a+v*c+w*d+_*x,t[12]=(b=r[12])*n+(v=r[13])*o+(w=r[14])*h+(_=r[15])*m,t[13]=b*i+v*l+w*p+_*y,t[14]=b*s+v*u+w*f+_*g,t[15]=b*a+v*c+w*d+_*x,t}function a(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=n+n,l=i+i,u=s+s,c=n*o,h=n*l,p=n*u,f=i*l,d=i*u,m=s*u,y=a*o,g=a*l,x=a*u;return t[0]=1-(f+m),t[1]=h+x,t[2]=p-g,t[3]=0,t[4]=h-x,t[5]=1-(c+m),t[6]=d+y,t[7]=0,t[8]=p+g,t[9]=d-y,t[10]=1-(c+f),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function o(t,e){var r=e[4],n=e[5],i=e[6],s=e[8],a=e[9],o=e[10];return t[0]=Math.hypot(e[0],e[1],e[2]),t[1]=Math.hypot(r,n,i),t[2]=Math.hypot(s,a,o),t}function l(t,e,r,n,i){var s,a=1/Math.tan(e/2);return t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(t[10]=(i+n)*(s=1/(n-i)),t[14]=2*i*n*s):(t[10]=-1,t[14]=-2*n),t}function u(t,e,r,n,i,s,a){var o=1/(e-r),l=1/(n-i),u=1/(s-a);return t[0]=-2*o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*u,t[11]=0,t[12]=(e+r)*o,t[13]=(i+n)*l,t[14]=(a+s)*u,t[15]=1,t}function c(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t[9]=e[9]-r[9],t[10]=e[10]-r[10],t[11]=e[11]-r[11],t[12]=e[12]-r[12],t[13]=e[13]-r[13],t[14]=e[14]-r[14],t[15]=e[15]-r[15],t}return y.perspective=l,y.ortho=u,y.mul=i,y.sub=c,y}var x,b={},v={};function w(){if(x)return v;function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}x=1,Object.defineProperty(v,"__esModule",{value:!0}),v.create=n,v.clone=function(t){var r=new e.ARRAY_TYPE(3);return r[0]=t[0],r[1]=t[1],r[2]=t[2],r},v.length=i,v.fromValues=function(t,r,n){var i=new e.ARRAY_TYPE(3);return i[0]=t,i[1]=r,i[2]=n,i},v.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},v.set=function(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t},v.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t},v.subtract=a,v.multiply=o,v.divide=l,v.ceil=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t},v.floor=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t},v.min=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t},v.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t},v.round=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t},v.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t},v.scaleAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t},v.distance=u,v.squaredDistance=c,v.squaredLength=h,v.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t},v.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t},v.normalize=function(t,e){var r=e[0],n=e[1],i=e[2],s=r*r+n*n+i*i;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t},v.dot=p,v.cross=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=r[0],o=r[1],l=r[2];return t[0]=i*l-s*o,t[1]=s*a-n*l,t[2]=n*o-i*a,t},v.lerp=function(t,e,r,n){var i=e[0],s=e[1],a=e[2];return t[0]=i+n*(r[0]-i),t[1]=s+n*(r[1]-s),t[2]=a+n*(r[2]-a),t},v.hermite=function(t,e,r,n,i,s){var a=s*s,o=a*(2*s-3)+1,l=a*(s-2)+s,u=a*(s-1),c=a*(3-2*s);return t[0]=e[0]*o+r[0]*l+n[0]*u+i[0]*c,t[1]=e[1]*o+r[1]*l+n[1]*u+i[1]*c,t[2]=e[2]*o+r[2]*l+n[2]*u+i[2]*c,t},v.bezier=function(t,e,r,n,i,s){var a=1-s,o=a*a,l=s*s,u=o*a,c=3*s*o,h=3*l*a,p=l*s;return t[0]=e[0]*u+r[0]*c+n[0]*h+i[0]*p,t[1]=e[1]*u+r[1]*c+n[1]*h+i[1]*p,t[2]=e[2]*u+r[2]*c+n[2]*h+i[2]*p,t},v.random=function(t,r){r=r||1;var n=2*e.RANDOM()*Math.PI,i=2*e.RANDOM()-1,s=Math.sqrt(1-i*i)*r;return t[0]=Math.cos(n)*s,t[1]=Math.sin(n)*s,t[2]=i*r,t},v.transformMat4=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=r[3]*n+r[7]*i+r[11]*s+r[15];return t[0]=(r[0]*n+r[4]*i+r[8]*s+r[12])/(a=a||1),t[1]=(r[1]*n+r[5]*i+r[9]*s+r[13])/a,t[2]=(r[2]*n+r[6]*i+r[10]*s+r[14])/a,t},v.transformMat3=function(t,e,r){var n=e[0],i=e[1],s=e[2];return t[0]=n*r[0]+i*r[3]+s*r[6],t[1]=n*r[1]+i*r[4]+s*r[7],t[2]=n*r[2]+i*r[5]+s*r[8],t},v.transformQuat=function(t,e,r){var n=r[0],i=r[1],s=r[2],a=e[0],o=e[1],l=e[2],u=i*l-s*o,c=s*a-n*l,h=n*o-i*a,p=i*h-s*c,f=s*u-n*h,d=n*c-i*u,m=2*r[3];return c*=m,h*=m,f*=2,d*=2,t[0]=a+(u*=m)+(p*=2),t[1]=o+c+f,t[2]=l+h+d,t},v.rotateX=function(t,e,r,n){var i=[],s=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],s[0]=i[0],s[1]=i[1]*Math.cos(n)-i[2]*Math.sin(n),s[2]=i[1]*Math.sin(n)+i[2]*Math.cos(n),t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t},v.rotateY=function(t,e,r,n){var i=[],s=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],s[0]=i[2]*Math.sin(n)+i[0]*Math.cos(n),s[1]=i[1],s[2]=i[2]*Math.cos(n)-i[0]*Math.sin(n),t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t},v.rotateZ=function(t,e,r,n){var i=[],s=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],s[0]=i[0]*Math.cos(n)-i[1]*Math.sin(n),s[1]=i[0]*Math.sin(n)+i[1]*Math.cos(n),s[2]=i[2],t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t},v.angle=function(t,e){var r=t[0],n=t[1],i=t[2],s=e[0],a=e[1],o=e[2],l=Math.sqrt(r*r+n*n+i*i)*Math.sqrt(s*s+a*a+o*o),u=l&&p(t,e)/l;return Math.acos(Math.min(Math.max(u,-1),1))},v.zero=function(t){return t[0]=0,t[1]=0,t[2]=0,t},v.str=function(t){return "vec3("+t[0]+", "+t[1]+", "+t[2]+")"},v.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]},v.equals=function(t,r){var n=t[0],i=t[1],s=t[2],a=r[0],o=r[1],l=r[2];return Math.abs(n-a)<=e.EPSILON*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(i-o)<=e.EPSILON*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(s-l)<=e.EPSILON*Math.max(1,Math.abs(s),Math.abs(l))},v.forEach=v.sqrLen=v.len=v.sqrDist=v.dist=v.div=v.mul=v.sub=void 0;var e=function(e,n){if(e&&e.__esModule)return e;if(null===e||"object"!==t(e)&&"function"!=typeof e)return {default:e};var i=r(void 0);if(i&&i.has(e))return i.get(e);var s={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var l=a?Object.getOwnPropertyDescriptor(e,o):null;l&&(l.get||l.set)?Object.defineProperty(s,o,l):s[o]=e[o];}return s.default=e,i&&i.set(e,s),s}(s());function r(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return (r=function(t){return t?n:e})(t)}function n(){var t=new e.ARRAY_TYPE(3);return e.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function i(t){return Math.hypot(t[0],t[1],t[2])}function a(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function o(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function l(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function u(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2])}function c(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return r*r+n*n+i*i}function h(t){var e=t[0],r=t[1],n=t[2];return e*e+r*r+n*n}function p(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}v.sub=a,v.mul=o,v.div=l,v.dist=u,v.sqrDist=c,v.len=i,v.sqrLen=h;var f,d=(f=n(),function(t,e,r,n,i,s){var a,o;for(e||(e=3),r||(r=0),o=n?Math.min(n*e+r,t.length):t.length,a=r;a0&&(a=1/Math.sqrt(a)),t[0]=r*a,t[1]=n*a,t[2]=i*a,t[3]=s*a,t},A.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},A.cross=function(t,e,r,n){var i=r[0]*n[1]-r[1]*n[0],s=r[0]*n[2]-r[2]*n[0],a=r[0]*n[3]-r[3]*n[0],o=r[1]*n[2]-r[2]*n[1],l=r[1]*n[3]-r[3]*n[1],u=r[2]*n[3]-r[3]*n[2],c=e[0],h=e[1],p=e[2],f=e[3];return t[0]=h*u-p*l+f*o,t[1]=-c*u+p*a-f*s,t[2]=c*l-h*a+f*i,t[3]=-c*o+h*s-p*i,t},A.lerp=function(t,e,r,n){var i=e[0],s=e[1],a=e[2],o=e[3];return t[0]=i+n*(r[0]-i),t[1]=s+n*(r[1]-s),t[2]=a+n*(r[2]-a),t[3]=o+n*(r[3]-o),t},A.random=function(t,r){var n,i,s,a,o,l;r=r||1;do{o=(n=2*e.RANDOM()-1)*n+(i=2*e.RANDOM()-1)*i;}while(o>=1);do{l=(s=2*e.RANDOM()-1)*s+(a=2*e.RANDOM()-1)*a;}while(l>=1);var u=Math.sqrt((1-o)/l);return t[0]=r*n,t[1]=r*i,t[2]=r*s*u,t[3]=r*a*u,t},A.transformMat4=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*s+r[12]*a,t[1]=r[1]*n+r[5]*i+r[9]*s+r[13]*a,t[2]=r[2]*n+r[6]*i+r[10]*s+r[14]*a,t[3]=r[3]*n+r[7]*i+r[11]*s+r[15]*a,t},A.transformQuat=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=r[0],o=r[1],l=r[2],u=r[3],c=u*n+o*s-l*i,h=u*i+l*n-a*s,p=u*s+a*i-o*n,f=-a*n-o*i-l*s;return t[0]=c*u+f*-a+h*-l-p*-o,t[1]=h*u+f*-o+p*-a-c*-l,t[2]=p*u+f*-l+c*-o-h*-a,t[3]=e[3],t},A.zero=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t},A.str=function(t){return "vec4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},A.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]},A.equals=function(t,r){var n=t[0],i=t[1],s=t[2],a=t[3],o=r[0],l=r[1],u=r[2],c=r[3];return Math.abs(n-o)<=e.EPSILON*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(i-l)<=e.EPSILON*Math.max(1,Math.abs(i),Math.abs(l))&&Math.abs(s-u)<=e.EPSILON*Math.max(1,Math.abs(s),Math.abs(u))&&Math.abs(a-c)<=e.EPSILON*Math.max(1,Math.abs(a),Math.abs(c))},A.forEach=A.sqrLen=A.len=A.sqrDist=A.dist=A.div=A.mul=A.sub=void 0;var e=function(e,n){if(e&&e.__esModule)return e;if(null===e||"object"!==t(e)&&"function"!=typeof e)return {default:e};var i=r(void 0);if(i&&i.has(e))return i.get(e);var s={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var l=a?Object.getOwnPropertyDescriptor(e,o):null;l&&(l.get||l.set)?Object.defineProperty(s,o,l):s[o]=e[o];}return s.default=e,i&&i.set(e,s),s}(s());function r(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return (r=function(t){return t?n:e})(t)}function n(){var t=new e.ARRAY_TYPE(4);return e.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function i(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}function a(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t}function o(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t}function l(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2],e[3]-t[3])}function u(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2],s=e[3]-t[3];return r*r+n*n+i*i+s*s}function c(t){return Math.hypot(t[0],t[1],t[2],t[3])}function h(t){var e=t[0],r=t[1],n=t[2],i=t[3];return e*e+r*r+n*n+i*i}A.sub=i,A.mul=a,A.div=o,A.dist=l,A.sqrDist=u,A.len=c,A.sqrLen=h;var p,f=(p=n(),function(t,e,r,n,i,s){var a,o;for(e||(e=4),r||(r=0),o=n?Math.min(n*e+r,t.length):t.length,a=r;ae.EPSILON?(t[0]=r[0]/i,t[1]=r[1]/i,t[2]=r[2]/i):(t[0]=1,t[1]=0,t[2]=0),n},b.getAngle=function(t,e){var r=g(t,e);return Math.acos(2*r*r-1)},b.multiply=c,b.rotateX=function(t,e,r){r*=.5;var n=e[0],i=e[1],s=e[2],a=e[3],o=Math.sin(r),l=Math.cos(r);return t[0]=n*l+a*o,t[1]=i*l+s*o,t[2]=s*l-i*o,t[3]=a*l-n*o,t},b.rotateY=function(t,e,r){r*=.5;var n=e[0],i=e[1],s=e[2],a=e[3],o=Math.sin(r),l=Math.cos(r);return t[0]=n*l-s*o,t[1]=i*l+a*o,t[2]=s*l+n*o,t[3]=a*l-i*o,t},b.rotateZ=function(t,e,r){r*=.5;var n=e[0],i=e[1],s=e[2],a=e[3],o=Math.sin(r),l=Math.cos(r);return t[0]=n*l+i*o,t[1]=i*l-n*o,t[2]=s*l+a*o,t[3]=a*l-s*o,t},b.calculateW=function(t,e){var r=e[0],n=e[1],i=e[2];return t[0]=r,t[1]=n,t[2]=i,t[3]=Math.sqrt(Math.abs(1-r*r-n*n-i*i)),t},b.exp=h,b.ln=p,b.pow=function(t,e,r){return p(t,e),y(t,t,r),h(t,t),t},b.slerp=f,b.random=function(t){var r=e.RANDOM(),n=e.RANDOM(),i=e.RANDOM(),s=Math.sqrt(1-r),a=Math.sqrt(r);return t[0]=s*Math.sin(2*Math.PI*n),t[1]=s*Math.cos(2*Math.PI*n),t[2]=a*Math.sin(2*Math.PI*i),t[3]=a*Math.cos(2*Math.PI*i),t},b.invert=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=r*r+n*n+i*i+s*s,o=a?1/a:0;return t[0]=-r*o,t[1]=-n*o,t[2]=-i*o,t[3]=s*o,t},b.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},b.fromMat3=m,b.fromEuler=function(t,e,r,n){var i=.5*Math.PI/180;e*=i,r*=i,n*=i;var s=Math.sin(e),a=Math.cos(e),o=Math.sin(r),l=Math.cos(r),u=Math.sin(n),c=Math.cos(n);return t[0]=s*l*c-a*o*u,t[1]=a*o*c+s*l*u,t[2]=a*l*u-s*o*c,t[3]=a*l*c+s*o*u,t},b.str=function(t){return "quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},b.setAxes=b.sqlerp=b.rotationTo=b.equals=b.exactEquals=b.normalize=b.sqrLen=b.squaredLength=b.len=b.length=b.lerp=b.dot=b.scale=b.mul=b.add=b.set=b.copy=b.fromValues=b.clone=void 0;var e=o(s()),r=o(d()),n=o(w()),i=o(S());function a(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,r=new WeakMap;return (a=function(t){return t?r:e})(t)}function o(e,r){if(e&&e.__esModule)return e;if(null===e||"object"!==t(e)&&"function"!=typeof e)return {default:e};var n=a(r);if(n&&n.has(e))return n.get(e);var i={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var l=s?Object.getOwnPropertyDescriptor(e,o):null;l&&(l.get||l.set)?Object.defineProperty(i,o,l):i[o]=e[o];}return i.default=e,n&&n.set(e,i),i}function l(){var t=new e.ARRAY_TYPE(4);return e.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function u(t,e,r){r*=.5;var n=Math.sin(r);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(r),t}function c(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=r[0],l=r[1],u=r[2],c=r[3];return t[0]=n*c+a*o+i*u-s*l,t[1]=i*c+a*l+s*o-n*u,t[2]=s*c+a*u+n*l-i*o,t[3]=a*c-n*o-i*l-s*u,t}function h(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=Math.sqrt(r*r+n*n+i*i),o=Math.exp(s),l=a>0?o*Math.sin(a)/a:0;return t[0]=r*l,t[1]=n*l,t[2]=i*l,t[3]=o*Math.cos(a),t}function p(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=Math.sqrt(r*r+n*n+i*i),o=a>0?Math.atan2(a,s)/a:0;return t[0]=r*o,t[1]=n*o,t[2]=i*o,t[3]=.5*Math.log(r*r+n*n+i*i+s*s),t}function f(t,r,n,i){var s,a,o,l,u,c=r[0],h=r[1],p=r[2],f=r[3],d=n[0],m=n[1],y=n[2],g=n[3];return (a=c*d+h*m+p*y+f*g)<0&&(a=-a,d=-d,m=-m,y=-y,g=-g),1-a>e.EPSILON?(s=Math.acos(a),o=Math.sin(s),l=Math.sin((1-i)*s)/o,u=Math.sin(i*s)/o):(l=1-i,u=i),t[0]=l*c+u*d,t[1]=l*h+u*m,t[2]=l*p+u*y,t[3]=l*f+u*g,t}function m(t,e){var r,n=e[0]+e[4]+e[8];if(n>0)r=Math.sqrt(n+1),t[3]=.5*r,t[0]=(e[5]-e[7])*(r=.5/r),t[1]=(e[6]-e[2])*r,t[2]=(e[1]-e[3])*r;else {var i=0;e[4]>e[0]&&(i=1),e[8]>e[3*i+i]&&(i=2);var s=(i+1)%3,a=(i+2)%3;r=Math.sqrt(e[3*i+i]-e[3*s+s]-e[3*a+a]+1),t[i]=.5*r,t[3]=(e[3*s+a]-e[3*a+s])*(r=.5/r),t[s]=(e[3*s+i]+e[3*i+s])*r,t[a]=(e[3*a+i]+e[3*i+a])*r;}return t}b.clone=i.clone,b.fromValues=i.fromValues,b.copy=i.copy,b.set=i.set,b.add=i.add,b.mul=c;var y=i.scale;b.scale=y;var g=i.dot;b.dot=g,b.lerp=i.lerp;var x=i.length;b.length=x,b.len=x;var v=i.squaredLength;b.squaredLength=v,b.sqrLen=v;var _=i.normalize;b.normalize=_,b.exactEquals=i.exactEquals,b.equals=i.equals;var A,I,P,z=(A=n.create(),I=n.fromValues(1,0,0),P=n.fromValues(0,1,0),function(t,e,r){var i=n.dot(e,r);return i<-.999999?(n.cross(A,I,e),n.len(A)<1e-6&&n.cross(A,P,e),n.normalize(A,A),u(t,A,Math.PI),t):i>.999999?(t[0]=0,t[1]=0,t[2]=0,t[3]=1,t):(n.cross(A,e,r),t[0]=A[0],t[1]=A[1],t[2]=A[2],t[3]=1+i,_(t,t))});b.rotationTo=z;var k,T,E=(k=l(),T=l(),function(t,e,r,n,i,s){return f(k,e,i,s),f(T,r,n,s),f(t,k,T,2*s*(1-s)),t});b.sqlerp=E;var B,V=(B=r.create(),function(t,e,r,n){return B[0]=r[0],B[3]=r[1],B[6]=r[2],B[1]=n[0],B[4]=n[1],B[7]=n[2],B[2]=-e[0],B[5]=-e[1],B[8]=-e[2],_(t,m(t,B))});return b.setAxes=V,b}var P,z={};function k(){if(P)return z;function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}P=1,Object.defineProperty(z,"__esModule",{value:!0}),z.create=function(){var t=new e.ARRAY_TYPE(8);return e.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[4]=0,t[5]=0,t[6]=0,t[7]=0),t[3]=1,t},z.clone=function(t){var r=new e.ARRAY_TYPE(8);return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[4]=t[4],r[5]=t[5],r[6]=t[6],r[7]=t[7],r},z.fromValues=function(t,r,n,i,s,a,o,l){var u=new e.ARRAY_TYPE(8);return u[0]=t,u[1]=r,u[2]=n,u[3]=i,u[4]=s,u[5]=a,u[6]=o,u[7]=l,u},z.fromRotationTranslationValues=function(t,r,n,i,s,a,o){var l=new e.ARRAY_TYPE(8);l[0]=t,l[1]=r,l[2]=n,l[3]=i;var u=.5*s,c=.5*a,h=.5*o;return l[4]=u*i+c*n-h*r,l[5]=c*i+h*t-u*n,l[6]=h*i+u*r-c*t,l[7]=-u*t-c*r-h*n,l},z.fromRotationTranslation=o,z.fromTranslation=function(t,e){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t[4]=.5*e[0],t[5]=.5*e[1],t[6]=.5*e[2],t[7]=0,t},z.fromRotation=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=0,t[5]=0,t[6]=0,t[7]=0,t},z.fromMat4=function(t,i){var s=r.create();n.getRotation(s,i);var a=new e.ARRAY_TYPE(3);return n.getTranslation(a,i),o(t,s,a),t},z.copy=l,z.identity=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t[6]=0,t[7]=0,t},z.set=function(t,e,r,n,i,s,a,o,l){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t[4]=s,t[5]=a,t[6]=o,t[7]=l,t},z.getDual=function(t,e){return t[0]=e[4],t[1]=e[5],t[2]=e[6],t[3]=e[7],t},z.setDual=function(t,e){return t[4]=e[0],t[5]=e[1],t[6]=e[2],t[7]=e[3],t},z.getTranslation=function(t,e){var r=e[4],n=e[5],i=e[6],s=e[7],a=-e[0],o=-e[1],l=-e[2],u=e[3];return t[0]=2*(r*u+s*a+n*l-i*o),t[1]=2*(n*u+s*o+i*a-r*l),t[2]=2*(i*u+s*l+r*o-n*a),t},z.translate=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=.5*r[0],l=.5*r[1],u=.5*r[2],c=e[4],h=e[5],p=e[6],f=e[7];return t[0]=n,t[1]=i,t[2]=s,t[3]=a,t[4]=a*o+i*u-s*l+c,t[5]=a*l+s*o-n*u+h,t[6]=a*u+n*l-i*o+p,t[7]=-n*o-i*l-s*u+f,t},z.rotateX=function(t,e,n){var i=-e[0],s=-e[1],a=-e[2],o=e[3],l=e[4],u=e[5],c=e[6],h=e[7],p=l*o+h*i+u*a-c*s,f=u*o+h*s+c*i-l*a,d=c*o+h*a+l*s-u*i,m=h*o-l*i-u*s-c*a;return r.rotateX(t,e,n),t[4]=p*(o=t[3])+m*(i=t[0])+f*(a=t[2])-d*(s=t[1]),t[5]=f*o+m*s+d*i-p*a,t[6]=d*o+m*a+p*s-f*i,t[7]=m*o-p*i-f*s-d*a,t},z.rotateY=function(t,e,n){var i=-e[0],s=-e[1],a=-e[2],o=e[3],l=e[4],u=e[5],c=e[6],h=e[7],p=l*o+h*i+u*a-c*s,f=u*o+h*s+c*i-l*a,d=c*o+h*a+l*s-u*i,m=h*o-l*i-u*s-c*a;return r.rotateY(t,e,n),t[4]=p*(o=t[3])+m*(i=t[0])+f*(a=t[2])-d*(s=t[1]),t[5]=f*o+m*s+d*i-p*a,t[6]=d*o+m*a+p*s-f*i,t[7]=m*o-p*i-f*s-d*a,t},z.rotateZ=function(t,e,n){var i=-e[0],s=-e[1],a=-e[2],o=e[3],l=e[4],u=e[5],c=e[6],h=e[7],p=l*o+h*i+u*a-c*s,f=u*o+h*s+c*i-l*a,d=c*o+h*a+l*s-u*i,m=h*o-l*i-u*s-c*a;return r.rotateZ(t,e,n),t[4]=p*(o=t[3])+m*(i=t[0])+f*(a=t[2])-d*(s=t[1]),t[5]=f*o+m*s+d*i-p*a,t[6]=d*o+m*a+p*s-f*i,t[7]=m*o-p*i-f*s-d*a,t},z.rotateByQuatAppend=function(t,e,r){var n=r[0],i=r[1],s=r[2],a=r[3],o=e[0],l=e[1],u=e[2],c=e[3];return t[0]=o*a+c*n+l*s-u*i,t[1]=l*a+c*i+u*n-o*s,t[2]=u*a+c*s+o*i-l*n,t[3]=c*a-o*n-l*i-u*s,t[4]=(o=e[4])*a+(c=e[7])*n+(l=e[5])*s-(u=e[6])*i,t[5]=l*a+c*i+u*n-o*s,t[6]=u*a+c*s+o*i-l*n,t[7]=c*a-o*n-l*i-u*s,t},z.rotateByQuatPrepend=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=r[0],l=r[1],u=r[2],c=r[3];return t[0]=n*c+a*o+i*u-s*l,t[1]=i*c+a*l+s*o-n*u,t[2]=s*c+a*u+n*l-i*o,t[3]=a*c-n*o-i*l-s*u,t[4]=n*(c=r[7])+a*(o=r[4])+i*(u=r[6])-s*(l=r[5]),t[5]=i*c+a*l+s*o-n*u,t[6]=s*c+a*u+n*l-i*o,t[7]=a*c-n*o-i*l-s*u,t},z.rotateAroundAxis=function(t,r,n,i){if(Math.abs(i)0){r=Math.sqrt(r);var n=e[0]/r,i=e[1]/r,s=e[2]/r,a=e[3]/r,o=e[4],l=e[5],u=e[6],c=e[7],h=n*o+i*l+s*u+a*c;t[0]=n,t[1]=i,t[2]=s,t[3]=a,t[4]=(o-n*h)/r,t[5]=(l-i*h)/r,t[6]=(u-s*h)/r,t[7]=(c-a*h)/r;}return t},z.str=function(t){return "quat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+")"},z.exactEquals=function(t,e){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]},z.equals=function(t,r){var n=t[0],i=t[1],s=t[2],a=t[3],o=t[4],l=t[5],u=t[6],c=t[7],h=r[0],p=r[1],f=r[2],d=r[3],m=r[4],y=r[5],g=r[6],x=r[7];return Math.abs(n-h)<=e.EPSILON*Math.max(1,Math.abs(n),Math.abs(h))&&Math.abs(i-p)<=e.EPSILON*Math.max(1,Math.abs(i),Math.abs(p))&&Math.abs(s-f)<=e.EPSILON*Math.max(1,Math.abs(s),Math.abs(f))&&Math.abs(a-d)<=e.EPSILON*Math.max(1,Math.abs(a),Math.abs(d))&&Math.abs(o-m)<=e.EPSILON*Math.max(1,Math.abs(o),Math.abs(m))&&Math.abs(l-y)<=e.EPSILON*Math.max(1,Math.abs(l),Math.abs(y))&&Math.abs(u-g)<=e.EPSILON*Math.max(1,Math.abs(u),Math.abs(g))&&Math.abs(c-x)<=e.EPSILON*Math.max(1,Math.abs(c),Math.abs(x))},z.sqrLen=z.squaredLength=z.len=z.length=z.dot=z.mul=z.setReal=z.getReal=void 0;var e=a(s()),r=a(I()),n=a(g());function i(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,r=new WeakMap;return (i=function(t){return t?r:e})(t)}function a(e,r){if(e&&e.__esModule)return e;if(null===e||"object"!==t(e)&&"function"!=typeof e)return {default:e};var n=i(r);if(n&&n.has(e))return n.get(e);var s={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var l=a?Object.getOwnPropertyDescriptor(e,o):null;l&&(l.get||l.set)?Object.defineProperty(s,o,l):s[o]=e[o];}return s.default=e,n&&n.set(e,s),s}function o(t,e,r){var n=.5*r[0],i=.5*r[1],s=.5*r[2],a=e[0],o=e[1],l=e[2],u=e[3];return t[0]=a,t[1]=o,t[2]=l,t[3]=u,t[4]=n*u+i*l-s*o,t[5]=i*u+s*a-n*l,t[6]=s*u+n*o-i*a,t[7]=-n*a-i*o-s*l,t}function l(t,e){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}function u(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=r[4],l=r[5],u=r[6],c=r[7],h=e[4],p=e[5],f=e[6],d=e[7],m=r[0],y=r[1],g=r[2],x=r[3];return t[0]=n*x+a*m+i*g-s*y,t[1]=i*x+a*y+s*m-n*g,t[2]=s*x+a*g+n*y-i*m,t[3]=a*x-n*m-i*y-s*g,t[4]=n*c+a*o+i*u-s*l+h*x+d*m+p*g-f*y,t[5]=i*c+a*l+s*o-n*u+p*x+d*y+f*m-h*g,t[6]=s*c+a*u+n*l-i*o+f*x+d*g+h*y-p*m,t[7]=a*c-n*o-i*l-s*u+d*x-h*m-p*y-f*g,t}z.getReal=r.copy,z.setReal=r.copy,z.mul=u;var c=r.dot;z.dot=c;var h=r.length;z.length=h,z.len=h;var p=r.squaredLength;return z.squaredLength=p,z.sqrLen=p,z}var T,E,B={};function V(){if(T)return B;function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}T=1,Object.defineProperty(B,"__esModule",{value:!0}),B.create=n,B.clone=function(t){var r=new e.ARRAY_TYPE(2);return r[0]=t[0],r[1]=t[1],r},B.fromValues=function(t,r){var n=new e.ARRAY_TYPE(2);return n[0]=t,n[1]=r,n},B.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t},B.set=function(t,e,r){return t[0]=e,t[1]=r,t},B.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t},B.subtract=i,B.multiply=a,B.divide=o,B.ceil=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t},B.floor=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t},B.min=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t},B.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t},B.round=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t},B.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t},B.scaleAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t},B.distance=l,B.squaredDistance=u,B.length=c,B.squaredLength=h,B.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t},B.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t},B.normalize=function(t,e){var r=e[0],n=e[1],i=r*r+n*n;return i>0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i,t},B.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]},B.cross=function(t,e,r){var n=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=n,t},B.lerp=function(t,e,r,n){var i=e[0],s=e[1];return t[0]=i+n*(r[0]-i),t[1]=s+n*(r[1]-s),t},B.random=function(t,r){r=r||1;var n=2*e.RANDOM()*Math.PI;return t[0]=Math.cos(n)*r,t[1]=Math.sin(n)*r,t},B.transformMat2=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[2]*i,t[1]=r[1]*n+r[3]*i,t},B.transformMat2d=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[2]*i+r[4],t[1]=r[1]*n+r[3]*i+r[5],t},B.transformMat3=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[3]*i+r[6],t[1]=r[1]*n+r[4]*i+r[7],t},B.transformMat4=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[4]*i+r[12],t[1]=r[1]*n+r[5]*i+r[13],t},B.rotate=function(t,e,r,n){var i=e[0]-r[0],s=e[1]-r[1],a=Math.sin(n),o=Math.cos(n);return t[0]=i*o-s*a+r[0],t[1]=i*a+s*o+r[1],t},B.angle=function(t,e){var r=t[0],n=t[1],i=e[0],s=e[1],a=Math.sqrt(r*r+n*n)*Math.sqrt(i*i+s*s);return Math.acos(Math.min(Math.max(a&&(r*i+n*s)/a,-1),1))},B.zero=function(t){return t[0]=0,t[1]=0,t},B.str=function(t){return "vec2("+t[0]+", "+t[1]+")"},B.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]},B.equals=function(t,r){var n=t[0],i=t[1],s=r[0],a=r[1];return Math.abs(n-s)<=e.EPSILON*Math.max(1,Math.abs(n),Math.abs(s))&&Math.abs(i-a)<=e.EPSILON*Math.max(1,Math.abs(i),Math.abs(a))},B.forEach=B.sqrLen=B.sqrDist=B.dist=B.div=B.mul=B.sub=B.len=void 0;var e=function(e,n){if(e&&e.__esModule)return e;if(null===e||"object"!==t(e)&&"function"!=typeof e)return {default:e};var i=r(void 0);if(i&&i.has(e))return i.get(e);var s={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var l=a?Object.getOwnPropertyDescriptor(e,o):null;l&&(l.get||l.set)?Object.defineProperty(s,o,l):s[o]=e[o];}return s.default=e,i&&i.set(e,s),s}(s());function r(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return (r=function(t){return t?n:e})(t)}function n(){var t=new e.ARRAY_TYPE(2);return e.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0),t}function i(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}function a(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t}function o(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t}function l(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1])}function u(t,e){var r=e[0]-t[0],n=e[1]-t[1];return r*r+n*n}function c(t){return Math.hypot(t[0],t[1])}function h(t){var e=t[0],r=t[1];return e*e+r*r}B.len=c,B.sub=i,B.mul=a,B.div=o,B.dist=l,B.sqrDist=u,B.sqrLen=h;var p,f=(p=n(),function(t,e,r,n,i,s){var a,o;for(e||(e=2),r||(r=0),o=n?Math.min(n*e+r,t.length):t.length,a=r;a1)return 1;for(var r=t,n=0;n<8;n++){var i=this.sampleCurveX(r)-t;if(Math.abs(i)i?a=r:o=r,r=.5*(o-a)+a;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},R}(),j=e(U);function N(){if(F)return L;function t(t,e){this.x=t,this.y=e;}return F=1,L=t,t.prototype={clone:function(){return new t(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),n=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=n,this},_rotateAround:function(t,e){var r=Math.cos(t),n=Math.sin(t),i=e.y+n*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-n*(this.y-e.y),this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},t.convert=function(e){return e instanceof t?e:Array.isArray(e)?new t(e[0],e[1]):e},L}var q=e(N());function $(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return !1;for(let r=0;r=1)return 1;const e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}function K(t,e,r,n){const i=new j(t,e,r,n);return function(t){return i.solve(t)}}const J=K(.25,.1,.25,1);function Q(t,e,r){return Math.min(r,Math.max(e,t))}function tt(t,e,r){return (r=Q((r-t)/(e-t),0,1))*r*(3-2*r)}function et(t,e,r){const n=r-e,i=((t-e)%n+n)%n+e;return i===e?r:i}function rt(t,e,r){if(!t.length)return r(null,[]);let n=t.length;const i=new Array(t.length);let s=null;t.forEach(((t,a)=>{e(t,((t,e)=>{t&&(s=t),i[a]=e,0==--n&&r(s,i);}));}));}function nt(t,...e){for(const r of e)for(const e in r)t[e]=r[e];return t}let it=1;function st(){return it++}function at(t){return t<=1?1:Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function ot(t,e){t.forEach((t=>{e[t]&&(e[t]=e[t].bind(e));}));}function lt(t,e){return -1!==t.indexOf(e,t.length-e.length)}function ut(t,e,r){const n={};for(const r in t)n[r]=e.call(this,t[r],r,t);return n}function ct(t,e,r){const n={};for(const r in t)e.call(this,t[r],r,t)&&(n[r]=t[r]);return n}function ht(t){return Array.isArray(t)?t.map(ht):"object"==typeof t&&t?ut(t,ht):t}const pt={};function ft(t){pt[t]||("undefined"!=typeof console&&console.warn(t),pt[t]=!0);}function dt(t,e,r){return (r.y-t.y)*(e.x-t.x)>(e.y-t.y)*(r.x-t.x)}function mt(t){let e=0;for(let r,n,i=0,s=t.length,a=s-1;i@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,r,n,i)=>{const s=n||i;return e[r]=!s||s.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t;}return e}let bt,vt=null;function wt(t,e){return [t[4*e],t[4*e+1],t[4*e+2],t[4*e+3]]}function _t(t,e,r,n){for(;e>1;t[i]>1;t[i]<=n?e=i+1:r=i;}return e}function At(t){return t>0?1/(1.001-t):1+t}function St(t){return t>0?1-1/(1.001-t):-t}const It={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==bt){const t=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{bt=null!=process.env.API_URL_REGEX?new RegExp(process.env.API_URL_REGEX):t;}catch(e){bt=t;}}return bt},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(!It.API_URL)return null;try{const t=new URL(It.API_URL);return "api.mapbox.cn"===t.hostname?"https://events.mapbox.cn/events/v2":"api.mapbox.com"===t.hostname?"https://events.mapbox.com/events/v2":null}catch(t){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",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf",TILES3D_URL_PREFIX:"3dtiles/v1"};function Pt(t){return It.API_URL_REGEX.test(t)}function zt(t){return It.API_SPRITE_REGEX.test(t)}let kt,Tt,Et,Bt,Vt,Ct;function Rt(){return null==kt&&(kt=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof self.createImageBitmap),kt}const Dt={now:()=>void 0!==Bt?Bt:performance.now(),setNow(t){Bt=t;},restoreNow(){Bt=void 0;},frame(t){const e=requestAnimationFrame(t);return {cancel:()=>cancelAnimationFrame(e)}},getImageData(t,e=0){const{width:r,height:n}=t;Vt||(Vt=document.createElement("canvas"));const i=Vt.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return (r>Vt.width||n>Vt.height)&&(Vt.width=r,Vt.height=n),i.clearRect(-e,-e,r+2*e,n+2*e),i.drawImage(t,0,0,r,n),i.getImageData(-e,-e,r+2*e,n+2*e)},resolveURL:t=>(Tt||(Tt=document.createElement("a")),Tt.href=t,Tt.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return !!window.matchMedia&&(null==Et&&(Et=window.matchMedia("(prefers-reduced-motion: reduce)")),Et.matches)},hasCanvasFingerprintNoise(){if(void 0!==Ct)return Ct;if(!Rt())return Ct=!1,!1;const t=new OffscreenCanvas(85,1),e=t.getContext("2d",{willReadFrequently:!0});let r=0;for(let n=0;n0?`?${s}`:""}`}const Ot="mapbox-tiles";let Ut=500,jt=50;const Nt=["language","worldview","jobid"];let qt,$t;function Gt(){try{return caches}catch(t){}}function Xt(){const t=Gt();t&&null==qt&&(qt=t.open(Ot));}let Yt=1/0;const Zt={supported:!1,testSupport:function(t){!Kt&&Ht&&(Jt?te(t):Wt=t);}};let Wt,Ht,Kt=!1,Jt=!1;const Qt="undefined"!=typeof self?self:{};function te(t){const e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,Ht),t.isContextLost())return;Zt.supported=!0;}catch(t){}t.deleteTexture(e),Kt=!0;}Qt.document&&(Ht=Qt.document.createElement("img"),Ht.onload=function(){Wt&&te(Wt),Wt=null,Jt=!0;},Ht.onerror=function(){Kt=!0,Wt=null;},Ht.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const ee={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image",Model:"Model"};"function"==typeof Object.freeze&&Object.freeze(ee);class re extends Error{constructor(t,e,r){401===e&&Pt(r)&&(t+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(t),this.status=e,this.url=r;}toString(){return `${this.name}: ${this.message} (${this.status}): ${this.url}`}}const ne=gt()?()=>self.worker&&self.worker.referrer:()=>("blob:"===location.protocol?parent:self).location.href;const ie=function(t,e){if(!(/^file:/.test(r=t.url)||/^file:/.test(ne())&&!/^\w+:/.test(r))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return function(t,e){const r=new AbortController,n=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,referrer:ne(),referrerPolicy:t.referrerPolicy,signal:r.signal});let i=!1,s=!1;const a=(o=n.url).indexOf("sku=")>0&&Pt(o);var o;"json"===t.type&&n.headers.set("Accept","application/json");const l=(r,i,o)=>{if(s)return;if(r&&"SecurityError"!==r.message&&ft(r.toString()),i&&o)return u(i);const l=Date.now();fetch(n).then((r=>{if(r.ok){const t=a?r.clone():null;return u(r,t,l)}return e(new re(r.statusText,r.status,t.url))})).catch((r=>{"AbortError"!==r.name&&e(new Error(`${r.message} ${t.url}`));}));},u=(r,a,o)=>{("arrayBuffer"===t.type?r.arrayBuffer():"json"===t.type?r.json():r.text()).then((t=>{s||(a&&o&&function(t,e,r){if(Xt(),null==qt)return;const n=xt(e.headers.get("Cache-Control")||"");if(n["no-store"])return;const i={status:e.status,statusText:e.statusText,headers:new Headers};e.headers.forEach(((t,e)=>i.headers.set(e,t))),n["max-age"]&&i.headers.set("Expires",new Date(r+1e3*n["max-age"]).toUTCString());const s=i.headers.get("Expires");if(!s)return;if(new Date(s).getTime()-r<42e4)return;let a=Ft(t.url,{persistentParams:Nt});if(206===e.status){const e=t.headers.get("Range");if(!e)return;i.status=200,a=Lt(a,{range:e});}!function(t,e){if(void 0===$t)try{new Response(new ReadableStream),$t=!0;}catch(t){$t=!1;}$t?e(t.body):t.blob().then(e);}(e,(t=>{const r=new Response(200!==(n=e.status)&&404!==n&&[101,103,204,205,304].includes(n)?null:t,i);var n;Xt(),null!=qt&&qt.then((t=>t.put(a,r))).catch((t=>ft(t.message)));}));}(n,a,o),i=!0,e(null,t,r.headers.get("Cache-Control"),r.headers.get("Expires")));})).catch((t=>{s||e(new Error(t.message));}));};return a?function(t,e){if(Xt(),null==qt)return e(null);qt.then((r=>{let n=Ft(t.url,{persistentParams:Nt});const i=t.headers.get("Range");i&&(n=Lt(n,{range:i})),r.match(n).then((t=>{const i=function(t){if(!t)return !1;const e=new Date(t.headers.get("Expires")||0),r=xt(t.headers.get("Cache-Control")||"");return e>Date.now()&&!r["no-cache"]}(t);r.delete(n),i&&r.put(n,t.clone()),e(null,t,i);})).catch(e);})).catch(e);}(n,l):l(null,null),{cancel:()=>{s=!0,i||r.abort();}}}(t,e);if(gt()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e,void 0,!0)}var r;return function(t,e){const r=new XMLHttpRequest;r.open(t.method||"GET",t.url,!0),"arrayBuffer"===t.type&&(r.responseType="arraybuffer");for(const e in t.headers)r.setRequestHeader(e,t.headers[e]);return "json"===t.type&&(r.responseType="text",r.setRequestHeader("Accept","application/json")),r.withCredentials="include"===t.credentials,r.onerror=()=>{e(new Error(r.statusText));},r.onload=()=>{if((r.status>=200&&r.status<300||0===r.status)&&null!==r.response){let n=r.response;if("json"===t.type)try{n=JSON.parse(r.response);}catch(t){return e(t)}e(null,n,r.getResponseHeader("Cache-Control"),r.getResponseHeader("Expires"));}else e(new re(r.statusText,r.status,t.url));},r.send(t.body),{cancel:()=>r.abort()}}(t,e)},se=function(t,e){return ie(nt(t,{type:"arrayBuffer"}),e)};function ae(t){const e=document.createElement("a");return e.href=t,e.protocol===location.protocol&&e.host===location.host}const oe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let le,ue;le=[],ue=0;const ce=function(t,e){if(Zt.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),ue>=It.MAX_PARALLEL_IMAGE_REQUESTS){const r={requestParameters:t,callback:e,cancelled:!1,cancel(){this.cancelled=!0;}};return le.push(r),r}ue++;let r=!1;const n=()=>{if(!r)for(r=!0,ue--;le.length&&ue{n(),t?e(t):r&&(self.createImageBitmap?function(t,e){const r=new Blob([new Uint8Array(t)],{type:"image/png"});createImageBitmap(r).then((t=>{e(null,t);})).catch((t=>{e(new Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`));}));}(r,((t,r)=>e(t,r,i,s))):function(t,e){const r=new Image;r.onload=()=>{e(null,r),URL.revokeObjectURL(r.src),r.onload=null,requestAnimationFrame((()=>{r.src=oe;}));},r.onerror=()=>e(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(t)],{type:"image/png"});r.src=t.byteLength?URL.createObjectURL(n):oe;}(r,((t,r)=>e(t,r,i,s))));}));return {cancel:()=>{i.cancel(),n();}}};var he,pe,fe,de={exports:{}},me={exports:{}},ye={exports:{}},ge=function(){if(fe)return de.exports;fe=1;var t=(he||(he=1,me.exports=function(t,e){var r,n,i,s,a,o,l,u;for(n=t.length-(r=3&t.length),i=e,a=3432918353,o=461845907,u=0;u>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(s>>>16)&65535)<<16);switch(l=0,r){case 3:l^=(255&t.charCodeAt(u+2))<<16;case 2:l^=(255&t.charCodeAt(u+1))<<8;case 1:i^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(u)))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295;}return i^=t.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0}),me.exports),e=(pe||(pe=1,ye.exports=function(t,e){for(var r,n=t.length,i=e^n,s=0;n>=4;)r=1540483477*(65535&(r=255&t.charCodeAt(s)|(255&t.charCodeAt(++s))<<8|(255&t.charCodeAt(++s))<<16|(255&t.charCodeAt(++s))<<24))+((1540483477*(r>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),n-=4,++s;switch(n){case 3:i^=(255&t.charCodeAt(s+2))<<16;case 2:i^=(255&t.charCodeAt(s+1))<<8;case 1:i=1540483477*(65535&(i^=255&t.charCodeAt(s)))+((1540483477*(i>>>16)&65535)<<16);}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0}),ye.exports);return de.exports=t,de.exports.murmur3=t,de.exports.murmur2=e,de.exports}(),xe=e(ge);class be{constructor(t,...e){nt(this,e[0]||{}),this.type=t;}}class ve extends be{constructor(t,e={}){super("error",nt({error:t},e));}}function we(t,e,r){r[t]&&-1!==r[t].indexOf(e)||(r[t]=r[t]||[],r[t].push(e));}function _e(t,e,r){if(r&&r[t]){const n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1);}}class Me{on(t,e){return this._listeners=this._listeners||{},we(t,e,this._listeners),this}off(t,e){return _e(t,e,this._listeners),_e(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},we(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){const r="string"==typeof t?new be(t,e):t,n=r.type;if(this.listens(n)){r.target=this;const t=this._listeners&&this._listeners[n]?this._listeners[n].slice():[];for(const e of t)e.call(this,r);const e=this._oneTimeListeners&&this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];for(const t of e)_e(n,t,this._oneTimeListeners),t.call(this,r);const i=this._eventedParent;i&&(nt(r,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),i.fire(r));}else r instanceof ve&&console.error(r.error);return this}listens(t){return !!(this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t))}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}var Ae,Se={},Ie=function(){if(Ae)return Se;Ae=1;var t={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 e(t){return (t=Math.round(t))<0?0:t>255?255:t}function r(t){return e("%"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function n(t){return (e="%"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))<0?0:e>1?1:e;var e;}function i(t,e,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?t+(e-t)*r*6:2*r<1?e:3*r<2?t+(e-t)*(2/3-r)*6:t}try{Se.parseCSSColor=function(s){var a,o=s.replace(/ /g,"").toLowerCase();if(o in t)return t[o].slice();if("#"===o[0])return 4===o.length?(a=parseInt(o.substr(1),16))>=0&&a<=4095?[(3840&a)>>4|(3840&a)>>8,240&a|(240&a)>>4,15&a|(15&a)<<4,1]:null:7===o.length&&(a=parseInt(o.substr(1),16))>=0&&a<=16777215?[(16711680&a)>>16,(65280&a)>>8,255&a,1]:null;var l=o.indexOf("("),u=o.indexOf(")");if(-1!==l&&u+1===o.length){var c=o.substr(0,l),h=o.substr(l+1,u-(l+1)).split(","),p=1;switch(c){case"rgba":if(4!==h.length)return null;p=n(h.pop());case"rgb":return 3!==h.length?null:[r(h[0]),r(h[1]),r(h[2]),p];case"hsla":if(4!==h.length)return null;p=n(h.pop());case"hsl":if(3!==h.length)return null;var f=(parseFloat(h[0])%360+360)%360/360,d=n(h[1]),m=n(h[2]),y=m<=.5?m*(d+1):m+d-m*d,g=2*m-y;return [e(255*i(g,y,f+1/3)),e(255*i(g,y,f)),e(255*i(g,y,f-1/3)),p];default:return null}}return null};}catch(t){}return Se}();class Pe{constructor(t,e,r,n=1){this.r=t,this.g=e,this.b=r,this.a=n;}static parse(t){if(!t)return;if(t instanceof Pe)return t;if("string"!=typeof t)return;const e=Ie.parseCSSColor(t);return e?new Pe(e[0]/255*e[3],e[1]/255*e[3],e[2]/255*e[3],e[3]):void 0}toString(){const[t,e,r,n]=0===this.a?[0,0,0,0]:[255*this.r/this.a,255*this.g/this.a,255*this.b/this.a,this.a];return `rgba(${Math.round(t)},${Math.round(e)},${Math.round(r)},${n})`}toRenderColor(t){const{r:e,g:r,b:n,a:i}=this;return new ze(t,e,r,n,i)}}class ze{constructor(t,e,r,n,i){if(t){const s=t.image.height,a=s*s;e=0===i?0:e/i*(s-1),r=0===i?0:r/i*(s-1),n=0===i?0:n/i*(s-1);const o=Math.floor(e),l=Math.floor(r),u=Math.floor(n),c=Math.ceil(e),h=Math.ceil(r),p=Math.ceil(n),f=e-o,d=r-l,m=n-u,y=t.image.data,g=4*(o+l*a+u*s),x=4*(o+l*a+p*s),b=4*(o+h*a+u*s),v=4*(o+h*a+p*s),w=4*(c+l*a+u*s),_=4*(c+l*a+p*s),M=4*(c+h*a+u*s),A=4*(c+h*a+p*s);if(g<0||A>=y.length)throw new Error("out of range");this.r=ke(ke(ke(y[g],y[x],m),ke(y[b],y[v],m),d),ke(ke(y[w],y[_],m),ke(y[M],y[A],m),d),f)/255*i,this.g=ke(ke(ke(y[g+1],y[x+1],m),ke(y[b+1],y[v+1],m),d),ke(ke(y[w+1],y[_+1],m),ke(y[M+1],y[A+1],m),d),f)/255*i,this.b=ke(ke(ke(y[g+2],y[x+2],m),ke(y[b+2],y[v+2],m),d),ke(ke(y[w+2],y[_+2],m),ke(y[M+2],y[A+2],m),d),f)/255*i,this.a=i;}else this.r=e,this.g=r,this.b=n,this.a=i;}toArray(){const{r:t,g:e,b:r,a:n}=this;return 0===n?[0,0,0,0]:[255*t/n,255*e/n,255*r/n,n]}toArray01(){const{r:t,g:e,b:r,a:n}=this;return 0===n?[0,0,0,0]:[t/n,e/n,r/n,n]}toArray01Scaled(t){const{r:e,g:r,b:n,a:i}=this;return 0===i?[0,0,0]:[e/i*t,r/i*t,n/i*t]}toArray01PremultipliedAlpha(){const{r:t,g:e,b:r,a:n}=this;return [t,e,r,n]}toArray01Linear(){const{r:t,g:e,b:r,a:n}=this;return 0===n?[0,0,0,0]:[Math.pow(t/n,2.2),Math.pow(e/n,2.2),Math.pow(r/n,2.2),n]}}function ke(t,e,r){return t*(1-r)+e*r}function Te(t,e,r){return t.map(((t,n)=>ke(t,e[n],r)))}Pe.black=new Pe(0,0,0,1),Pe.white=new Pe(1,1,1,1),Pe.transparent=new Pe(0,0,0,0),Pe.red=new Pe(1,0,0,1),Pe.blue=new Pe(0,0,1,1);var Ee=Object.freeze({__proto__:null,array:Te,color:function(t,e,r){return new Pe(ke(t.r,e.r,r),ke(t.g,e.g,r),ke(t.b,e.b,r),ke(t.a,e.a,r))},number:ke});function Be(t,...e){for(const r of e)for(const e in r)t[e]=r[e];return t}class Ve extends Error{constructor(t,e){super(e),this.message=e,this.key=t;}}class Ce{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,r]of e)this.bindings[t]=r;}concat(t){return new Ce(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return !!this.bindings[t]||!!this.parent&&this.parent.has(t)}}const Re={kind:"null"},De={kind:"number"},Le={kind:"string"},Fe={kind:"boolean"},Oe={kind:"color"},Ue={kind:"object"},je={kind:"value"},Ne={kind:"collator"},qe={kind:"formatted"},$e={kind:"resolvedImage"};function Ge(t,e){return {kind:"array",itemType:t,N:e}}function Xe(t){if("array"===t.kind){const e=Xe(t.itemType);return "number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const Ye=[Re,De,Le,Fe,Oe,qe,Ue,Ge(je),$e];function Ze(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!Ze(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else {if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of Ye)if(!Ze(t,e))return null}return `Expected ${Xe(t)} but found ${Xe(e)} instead.`}function We(t,e){return e.some((e=>e.kind===t.kind))}function He(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}class Ke{constructor(t,e,r){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"});}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Je{constructor(t,e,r,n,i){this.text=t.normalize?t.normalize():t,this.image=e,this.scale=r,this.fontStack=n,this.textColor=i;}}class Qe{constructor(t){this.sections=t;}static fromString(t){return new Qe([new Je(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.namePrimary.length))}static factory(t){return t instanceof Qe?t:Qe.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}serialize(){const t=["format"];for(const e of this.sections){if(e.image){t.push(["image",e.image.namePrimary]);continue}t.push(e.text);const r={};e.fontStack&&(r["text-font"]=["literal",e.fontStack.split(",")]),e.scale&&(r["font-scale"]=e.scale),e.textColor&&(r["text-color"]=["rgba"].concat(e.textColor.toRenderColor(null).toArray())),t.push(r);}return t}}class tr{constructor(t){this.namePrimary=t.namePrimary,t.nameSecondary&&(this.nameSecondary=t.nameSecondary),this.available=t.available;}toString(){return this.nameSecondary?`[${this.namePrimary},${this.nameSecondary}]`:this.namePrimary}static fromString(t,e){return t?new tr({namePrimary:t,nameSecondary:e,available:!1}):null}serialize(){return this.nameSecondary?["image",this.namePrimary,this.nameSecondary]:["image",this.namePrimary]}}function er(t,e,r,n){return "number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof r&&r>=0&&r<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[t,e,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[t,e,r,n]:[t,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function rr(t){if(null===t)return !0;if("string"==typeof t)return !0;if("boolean"==typeof t)return !0;if("number"==typeof t)return !0;if(t instanceof Pe)return !0;if(t instanceof Ke)return !0;if(t instanceof Qe)return !0;if(t instanceof tr)return !0;if(Array.isArray(t)){for(const e of t)if(!rr(e))return !1;return !0}if("object"==typeof t){for(const e in t)if(!rr(t[e]))return !1;return !0}return !1}function nr(t){if(null===t)return Re;if("string"==typeof t)return Le;if("boolean"==typeof t)return Fe;if("number"==typeof t)return De;if(t instanceof Pe)return Oe;if(t instanceof Ke)return Ne;if(t instanceof Qe)return qe;if(t instanceof tr)return $e;if(Array.isArray(t)){const e=t.length;let r;for(const e of t){const t=nr(e);if(r){if(r===t)continue;r=je;break}r=t;}return Ge(r||je,e)}return Ue}function ir(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof Pe||t instanceof Qe||t instanceof tr?t.toString():JSON.stringify(t)}class sr{constructor(t,e){this.type=t,this.value=e;}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!rr(t[1]))return e.error("invalid value");const r=t[1];let n=nr(r);const i=e.expectedType;return "array"!==n.kind||0!==n.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(n=i),new sr(n,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return !0}serialize(){return "array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof Pe?["rgba"].concat(this.value.toRenderColor(null).toArray()):this.value instanceof Qe?this.value.serialize():this.value}}class ar{constructor(t){this.name="ExpressionEvaluationError",this.message=t;}toJSON(){return this.message}}const or={string:Le,number:De,boolean:Fe,object:Ue};class lr{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let r,n=1;const i=t[0];if("array"===i){let i,s;if(t.length>2){const r=t[1];if("string"!=typeof r||!(r in or)||"object"===r)return e.error('The item type argument of "array" must be one of string, number, boolean',1);i=or[r],n++;}else i=je;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);s=t[2],n++;}r=Ge(i,s);}else r=or[i];const s=[];for(;nt.outputDefined()))}serialize(){const t=this.type,e=[t.kind];if("array"===t.kind){const r=t.itemType;if("string"===r.kind||"number"===r.kind||"boolean"===r.kind){e.push(r.kind);const n=t.N;("number"==typeof n||this.args.length>1)&&e.push(n);}}return e.concat(this.args.map((t=>t.serialize())))}}class ur{constructor(t){this.type=qe,this.sections=t;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[1];if(!Array.isArray(r)&&"object"==typeof r)return e.error("First argument must be an image or text section.");const n=[];let i=!1;for(let r=1;r<=t.length-1;++r){const s=t[r];if(i&&"object"==typeof s&&!Array.isArray(s)){i=!1;let t=null;if(s["font-scale"]&&(t=e.parseObjectValue(s["font-scale"],r,"font-scale",De),!t))return null;let a=null;if(s["text-font"]&&(a=e.parseObjectValue(s["text-font"],r,"text-font",Ge(Le)),!a))return null;let o=null;if(s["text-color"]&&(o=e.parseObjectValue(s["text-color"],r,"text-color",Oe),!o))return null;const l=n[n.length-1];l.scale=t,l.font=a,l.textColor=o;}else {const s=e.parse(t[r],r,je);if(!s)return null;const a=s.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,n.push({content:s,scale:null,font:null,textColor:null});}}return new ur(n)}evaluate(t){return new Qe(this.sections.map((e=>{const r=e.content.evaluate(t);return nr(r)===$e?new Je("",r,null,null,null):new Je(ir(r),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor);}outputDefined(){return !1}serialize(){const t=["format"];for(const e of this.sections){t.push(e.content.serialize());const r={};e.scale&&(r["font-scale"]=e.scale.serialize()),e.font&&(r["text-font"]=e.font.serialize()),e.textColor&&(r["text-color"]=e.textColor.serialize()),t.push(r);}return t}}class cr{constructor(t,e){this.type=$e,this.inputPrimary=t,this.inputSecondary=e;}static parse(t,e){if(t.length<2)return e.error("Expected two or more arguments.");const r=e.parse(t[1],1,Le);if(!r)return e.error("No image name provided.");if(2===t.length)return new cr(r);const n=e.parse(t[2],1,Le);return n?new cr(r,n):e.error("Secondary image variant is not a string.")}evaluate(t){const e=tr.fromString(this.inputPrimary.evaluate(t),this.inputSecondary?this.inputSecondary.evaluate(t):void 0);return e&&t.availableImages&&(e.available=t.availableImages.indexOf(e.namePrimary)>-1,e.nameSecondary&&e.available&&t.availableImages&&(e.available=t.availableImages.indexOf(e.nameSecondary)>-1)),e}eachChild(t){t(this.inputPrimary),this.inputSecondary&&t(this.inputSecondary);}outputDefined(){return !1}serialize(){return this.inputSecondary?["image",this.inputPrimary.serialize(),this.inputSecondary.serialize()]:["image",this.inputPrimary.serialize()]}}function hr(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}const pr={"to-boolean":Fe,"to-color":Oe,"to-number":De,"to-string":Le};class fr{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[0],n=[];let i=Re;if("to-array"===r){if(!Array.isArray(t[1]))return null;const r=t[1].length;if(e.expectedType){if("array"!==e.expectedType.kind)return e.error(`Expected ${e.expectedType.kind} but found array.`);i=Ge(e.expectedType.itemType,r);}else {if(!(r>0&&rr(t[1][0])))return null;i=Ge(nr(t[1][0]),r);}for(let s=0;s4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:er(e[0],e[1],e[2],e[3]),!r))return new Pe(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new ar(r||`Could not parse color from value '${"string"==typeof e?e:String(JSON.stringify(e))}'`)}if("number"===this.type.kind){let e=null;for(const r of this.args){if(e=r.evaluate(t),null===e)return 0;const n=Number(e);if(!isNaN(n))return n}throw new ar(`Could not convert ${JSON.stringify(e)} to number.`)}return "formatted"===this.type.kind?Qe.fromString(ir(this.args[0].evaluate(t))):"resolvedImage"===this.type.kind?tr.fromString(ir(this.args[0].evaluate(t))):"array"===this.type.kind?this.args.map((e=>e.evaluate(t))):ir(this.args[0].evaluate(t))}eachChild(t){this.args.forEach(t);}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new ur([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new cr(this.args[0]).serialize();const t="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild((e=>{t.push(e.serialize());})),t}}const dr=["Unknown","Point","LineString","Polygon"];class mr{constructor(t,e){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=t,this.options=e;}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?dr[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(t){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const t=this.featureDistanceData.center,e=this.featureDistanceData.scale,{x:r,y:n}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(r*e-t[0])+this.featureDistanceData.bearing[1]*(n*e-t[1])}return 0}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=Pe.parse(t)),e}getConfig(t){return this.options?this.options.get(t):null}}class yr{constructor(t,e,r,n,i){this.name=t,this.type=e,this._evaluate=r,this.args=n,this._overloadIndex=i;}evaluate(t){if(!this._evaluate){const t=yr.definitions[this.name];this._evaluate=Array.isArray(t)?t[2]:t.overloads[this._overloadIndex][1];}return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t);}outputDefined(){return !1}serialize(){return [this.name].concat(this.args.map((t=>t.serialize())))}static parse(t,e){const r=t[0],n=yr.definitions[r];if(!n)return e.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);const i=Array.isArray(n)?n[0]:n.type,s=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,a=[];let o=null,l=-1;for(const[n,u]of s){if(Array.isArray(n)&&n.length!==t.length-1)continue;a.push(n),l++,o=new Ln(e.registry,e.path,null,e.scope,void 0,e._scope,e.options);const s=[];let c=!1;for(let e=1;et))).map(gr).join(" | "),n=[];for(let r=1;rr;){if(n-r>600){const s=n-r+1,a=e-r+1,o=Math.log(s),l=.5*Math.exp(2*o/3),u=.5*Math.sqrt(o*l*(s-l)/s)*(a-s/2<0?-1:1);br(t,e,Math.max(r,Math.floor(e-a*l/s+u)),Math.min(n,Math.floor(e+(s-a)*l/s+u)),i);}const s=t[e];let a=r,o=n;for(vr(t,r,e),i(t[n],s)>0&&vr(t,r,n);a0;)o--;}0===i(t[r],s)?vr(t,r,o):(o++,vr(t,o,n)),o<=e&&(r=o+1),e<=o&&(n=o-1);}}function vr(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function wr(t,e){return te?1:0}function _r(t){let e=0;for(let r,n,i=0,s=t.length,a=s-1;i=e[2]||t[1]<=e[1]||t[3]>=e[3])}function Sr(t,e,r){const n=t[0]-e[0],i=t[1]-e[1],s=t[0]-r[0],a=t[1]-r[1];return n*a-s*i==0&&n*s<=0&&i*a<=0}function Ir(t,e,r=!1){let n=!1;for(let o=0,l=e.length;o(i=t)[1]!=(a=c)[1]>i[1]&&i[0]<(a[0]-s[0])*(i[1]-s[1])/(a[1]-s[1])+s[0]&&(n=!n);}}var i,s,a;return n}function Pr(t,e,r,n){const i=n[0]-r[0],s=n[1]-r[1],a=(t[0]-r[0])*s-i*(t[1]-r[1]),o=(e[0]-r[0])*s-i*(e[1]-r[1]);return a>0&&o<0||a<0&&o>0}function zr(t,e,r,n){return 0!=(i=[n[0]-r[0],n[1]-r[1]])[0]*(s=[e[0]-t[0],e[1]-t[1]])[1]-i[1]*s[0]&&!(!Pr(t,e,r,n)||!Pr(r,n,t,e));var i,s;}const kr=8192;function Tr(t,e){const r=(180+t[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,i=Math.pow(2,e.z);return [Math.round(r*i*kr),Math.round(n*i*kr)]}function Er(t,e){for(let r=0;rr[2]){const e=.5*n;let i=t[0]-r[0]>e?-n:r[0]-t[0]>e?n:0;0===i&&(i=t[0]-r[2]>e?-n:r[2]-t[0]>e?n:0),t[0]+=i;}Mr(e,t);}function Fr(t,e,r,n){const i=Math.pow(2,n.z)*kr,s=[n.x*kr,n.y*kr],a=[];if(!t)return a;for(const n of t)for(const t of n){const n=[t.x+s[0],t.y+s[1]];Lr(n,e,r,i),a.push(n);}return a}function Or(t,e,r,n){const i=Math.pow(2,n.z)*kr,s=[n.x*kr,n.y*kr],a=[];if(!t)return a;for(const r of t){const t=[];for(const n of r){const r=[n.x+s[0],n.y+s[1]];Mr(e,r),t.push(r);}a.push(t);}if(e[2]-e[0]<=i/2){(o=e)[0]=o[1]=1/0,o[2]=o[3]=-1/0;for(const t of a)for(const n of t)Lr(n,e,r,i);}var o;return a}class Ur{constructor(t,e){this.type=Fe,this.geojson=t,this.geometries=e;}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(rr(t[1])){const e=t[1];if("FeatureCollection"===e.type)for(let t=0;te)return Yr(i,s,(e-(r-a))/a)}return t[t.length-1]}pointToSegmentDistance(t,e,r){let[n,i]=e,s=Zr(r[0]-n)*this.kx,a=(r[1]-i)*this.ky;if(0!==s||0!==a){const e=(Zr(t[0]-n)*this.kx*s+(t[1]-i)*this.ky*a)/(s*s+a*a);e>1?(n=r[0],i=r[1]):e>0&&(n+=s/this.kx*e,i+=a/this.ky*e);}return s=Zr(t[0]-n)*this.kx,a=(t[1]-i)*this.ky,Math.sqrt(s*s+a*a)}pointOnLine(t,e){let r=1/0,n=t[0][0],i=t[0][1],s=0,a=0;for(let o=0;o1?(l=t[o+1][0],u=t[o+1][1]):p>0&&(l+=c/this.kx*p,u+=h/this.ky*p)),c=Zr(e[0]-l)*this.kx,h=(e[1]-u)*this.ky;const f=c*c+h*h;fi.index||n.index===i.index&&n.t>i.t){const t=n;n=i,i=t;}const s=[n.point],a=n.index+1,o=i.index;!Xr(r[a],s[0])&&a<=o&&s.push(r[a]);for(let t=a+1;t<=o;t++)s.push(r[t]);return Xr(r[o],i.point)||s.push(i.point),s}lineSliceAlong(t,e,r){let n=0;const i=[];for(let s=0;st&&0===i.length&&i.push(Yr(a,o,(t-(n-l))/l)),n>=e)return i.push(Yr(a,o,(e-(n-l))/l)),i;n>t&&i.push(o);}return i}bufferPoint(t,e){const r=e/this.ky,n=e/this.kx;return [t[0]-n,t[1]-r,t[0]+n,t[1]+r]}bufferBBox(t,e){const r=e/this.ky,n=e/this.kx;return [t[0]-n,t[1]-r,t[2]+n,t[3]+r]}insideBBox(t,e){return Zr(t[0]-e[0])>=0&&Zr(t[0]-e[2])<=0&&t[1]>=e[1]&&t[1]<=e[3]}}function Xr(t,e){return t[0]===e[0]&&t[1]===e[1]}function Yr(t,e,r){const n=Zr(e[0]-t[0]);return [t[0]+n*r,t[1]+(e[1]-t[1])*r]}function Zr(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}class Wr{constructor(t=[],e=((t,e)=>te?1:0)){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t);}push(t){this.data.push(t),this._up(this.length++);}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return --this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:r}=this,n=e[t];for(;t>0;){const i=t-1>>1,s=e[i];if(r(n,s)>=0)break;e[t]=s,t=i;}e[t]=n;}_down(t){const{data:e,compare:r}=this,n=this.length>>1,i=e[t];for(;t=0)break;e[t]=e[n],t=n;}e[t]=i;}}var Hr=8192;function Kr(t,e){return e.dist-t.dist}const Jr=100,Qr=50;function tn(t){const e=[1/0,1/0,-1/0,-1/0];if(e.length!==t.length)return !1;for(let r=0;r=t[0]&&t[1]t[1])return [null,null];const r=en(t);if(e){if(2===r)return [t,null];const e=Math.floor(r/2);return [[t[0],t[0]+e],[t[0]+e,t[1]]]}{if(1===r)return [t,null];const e=Math.floor(r/2)-1;return [[t[0],t[0]+e],[t[0]+e+1,t[1]]]}}function sn(t,e){const r=[1/0,1/0,-1/0,-1/0];if(!rn(e,t.length))return r;for(let n=e[0];n<=e[1];++n)Mr(r,t[n]);return r}function an(t){const e=[1/0,1/0,-1/0,-1/0];for(let r=0;re[2]&&(n=t[0]-e[2]),t[1]>e[3]&&(i=t[1]-e[3]),t[3]=n)return n;if(Ar(i,s)){if(bn(t,e))return 0}else if(bn(e,t))return 0;let a=n;for(const n of t)for(let t=0,i=n.length,s=i-1;t=s)continue;const u=i.range1;if(en(u)<=o){if(!rn(u,t.length))return NaN;if(e){const e=xn(t,u,r,n);if(0===(s=Math.min(s,e)))return s}else for(let e=u[0];e<=u[1];++e){const i=gn(t[e],r,n);if(0===(s=Math.min(s,i)))return s}}else {const r=nn(u,e);if(null!==r[0]){const e=on(sn(t,r[0]),l,n);e=a)continue;const c=s.range1,h=s.range2;if(en(c)<=l&&en(h)<=u){if(!rn(c,t.length)||!rn(h,r.length))return NaN;if(e&&n?a=Math.min(a,mn(t,c,r,h,i)):e||n?e&&!n?a=Math.min(a,fn(r,h,t,c,i)):!e&&n&&(a=Math.min(a,fn(t,c,r,h,i))):a=Math.min(a,yn(t,c,r,h,i)),0===a)return a}else {const s=nn(c,e),l=nn(h,n);wn(o,a,i,t,r,s[0],l[0]),wn(o,a,i,t,r,s[0],l[1]),wn(o,a,i,t,r,s[1],l[0]),wn(o,a,i,t,r,s[1],l[1]);}}return a}function An(t,e,r,n,i=1/0){let s=i;const a=sn(t,[0,t.length-1]);for(const i of r)if(!(s!==1/0&&on(a,sn(i,[0,i.length-1]),n)>=s)&&(s=Math.min(s,Mn(t,e,i,!0,n,s)),0===s))return s;return s}function Sn(t,e,r,n,i=1/0){let s=i;const a=sn(t,[0,t.length-1]);for(const i of r){if(s!==1/0&&on(a,an(i),n)>=s)continue;const r=_n(t,e,i,n,s);if(isNaN(r))return r;if(0===(s=Math.min(s,r)))return s}return s}function In(t){return "Point"===t||"MultiPoint"===t||"LineString"===t||"MultiLineString"===t||"Polygon"===t||"MultiPolygon"===t}class Pn{constructor(t,e){this.type=De,this.geojson=t,this.geometries=e;}static parse(t,e){if(2!==t.length)return e.error(`'distance' expression requires either one argument, but found ' ${t.length-1} instead.`);if(rr(t[1])){const e=t[1];if("FeatureCollection"===e.type){for(let t=0;tr&&(t=r),t}class Tn{constructor(t,e,r){this.type=t,this.key=e,this.scope=r;}static parse(t,e){let r=e.expectedType;if(null==r&&(r=je),t.length<2||t.length>3)return e.error("Invalid number of arguments for 'config' expression.");const n=e.parse(t[1],1);if(!(n instanceof sr))return e.error("Key name of 'config' expression must be a string literal.");if(t.length>=3){const i=e.parse(t[2],2);return i instanceof sr?new Tn(r,ir(n.value),ir(i.value)):e.error("Scope of 'config' expression must be a string literal.")}return new Tn(r,ir(n.value))}evaluate(t){const e=[this.key,this.scope,t.scope].filter(Boolean).join(""),r=t.getConfig(e);if(!r)return null;const{type:n,value:i,values:s,minValue:a,maxValue:o,stepValue:l}=r,u=r.default.evaluate(t);let c=u;if(i){const e=t.scope;t.scope=(e||"").split("").slice(1).join(""),c=i.evaluate(t),t.scope=e;}return n&&(c=zn(n,c)),void 0===c||void 0===a&&void 0===o&&void 0===l||("number"==typeof c?c=kn(c,a,o,l):Array.isArray(c)&&(c=c.map((t=>"number"==typeof t?kn(t,a,o,l):t)))),void 0!==i&&void 0!==c&&s&&!s.includes(c)&&(c=u,n&&(c=zn(n,c))),(n&&n!==this.type||void 0!==c&&nr(c)!==this.type)&&(c=zn(this.type.kind,c)),c}eachChild(){}outputDefined(){return !1}serialize(){const t=["config",this.key];return this.scope&&t.concat(this.key),t}}function En(t){if(t instanceof yr){if("get"===t.name&&1===t.args.length)return !1;if("feature-state"===t.name)return !1;if("has"===t.name&&1===t.args.length)return !1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return !1;if(/^filter-/.test(t.name))return !1}if(t instanceof Ur)return !1;if(t instanceof Pn)return !1;let e=!0;return t.eachChild((t=>{e&&!En(t)&&(e=!1);})),e}function Bn(t){if(t instanceof yr&&"feature-state"===t.name)return !1;let e=!0;return t.eachChild((t=>{e&&!Bn(t)&&(e=!1);})),e}function Vn(t){if(t instanceof Tn)return new Set([t.key]);let e=new Set;return t.eachChild((t=>{e=new Set([...e,...Vn(t)]);})),e}function Cn(t,e){if(t instanceof yr&&e.indexOf(t.name)>=0)return !1;let r=!0;return t.eachChild((t=>{r&&!Cn(t,e)&&(r=!1);})),r}class Rn{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e;}static parse(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");const r=t[1];return e.scope.has(r)?new Rn(r,e.scope.get(r)):e.error(`Unknown variable "${r}". Make sure "${r}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return !1}serialize(){return ["var",this.name]}}class Dn{constructor(t,e=[],r,n=new Ce,i=[],s,a){this.registry=t,this.path=e,this.key=e.map((t=>"string"==typeof t?`['${t}']`:`[${t}]`)).join(""),this.scope=n,this.errors=i,this.expectedType=r,this._scope=s,this.options=a;}parse(t,e,r,n,i={}){return e||r?this.concat(e,null,r,n)._parse(t,i):this._parse(t,i)}parseObjectValue(t,e,r,n,i,s={}){return this.concat(e,r,n,i)._parse(t,s)}_parse(t,e){function r(t,e,r){return "assert"===r?new lr(e,[t]):"coerce"===r?new fr(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n="string"==typeof t[0]?this.registry[t[0]]:void 0;if(n){let i=n.parse(t,this);if(!i)return null;if(this.expectedType){const t=this.expectedType,n=i.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==n.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==n.kind&&"string"!==n.kind){if(this.checkSubtype(t,n))return null}else i=r(i,t,e.typeAnnotation||"coerce");else i=r(i,t,e.typeAnnotation||"assert");}if(!(i instanceof sr)&&"resolvedImage"!==i.type.kind&&Fn(i)){const t=new mr(this._scope,this.options);try{i=new sr(i.type,i.evaluate(t));}catch(t){return this.error(t.message),null}}return i}return fr.parse(["to-array",t],this)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,r,n){let i="number"==typeof t?this.path.concat(t):this.path;i="string"==typeof e?i.concat(e):i;const s=n?this.scope.concat(n):this.scope;return new Dn(this.registry,i,r||null,s,this.errors,this._scope,this.options)}error(t,...e){const r=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new Ve(r,t));}checkSubtype(t,e){const r=Ze(t,e);return r&&this.error(r),r}}var Ln=Dn;function Fn(t){if(t instanceof Rn)return Fn(t.boundExpression);if(t instanceof yr&&"error"===t.name)return !1;if(t instanceof xr)return !1;if(t instanceof Ur)return !1;if(t instanceof Pn)return !1;if(t instanceof Tn)return !1;const e=t instanceof fr||t instanceof lr;let r=!0;return t.eachChild((t=>{r=e?r&&Fn(t):r&&t instanceof sr;})),!!r&&En(t)&&Cn(t,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])}function On(t,e){const r=t.length-1;let n,i,s=0,a=r,o=0;for(;s<=a;)if(o=Math.floor((s+a)/2),n=t[o],i=t[o+1],n<=e){if(o===r||ee))throw new ar("Input is not a number.");a=o-1;}return 0}class Un{constructor(t,e,r){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of r)this.labels.push(t),this.outputs.push(e);}static parse(t,e){if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");const r=e.parse(t[1],1,De);if(!r)return null;const n=[];let i=null;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);for(let r=1;r=s)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',o);const u=e.parse(a,l,i);if(!u)return null;i=i||u.type,n.push([s,u]);}return new Un(i,r,n)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;return n>=e[i-1]?r[i-1].evaluate(t):r[On(e,n)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){const t=["step",this.input.serialize()];for(let e=0;e0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t}}const jn=.95047,Nn=1.08883,qn=4/29,$n=6/29,Gn=3*$n*$n,Xn=$n*$n*$n,Yn=Math.PI/180,Zn=180/Math.PI;function Wn(t){return t>Xn?Math.pow(t,1/3):t/Gn+qn}function Hn(t){return t>$n?t*t*t:Gn*(t-qn)}function Kn(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function Jn(t){return (t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Qn(t){const e=Jn(t.r),r=Jn(t.g),n=Jn(t.b),i=Wn((.4124564*e+.3575761*r+.1804375*n)/jn),s=Wn((.2126729*e+.7151522*r+.072175*n)/1);return {l:116*s-16,a:500*(i-s),b:200*(s-Wn((.0193339*e+.119192*r+.9503041*n)/Nn)),alpha:t.a}}function ti(t){let e=(t.l+16)/116,r=isNaN(t.a)?e:e+t.a/500,n=isNaN(t.b)?e:e-t.b/200;return e=1*Hn(e),r=jn*Hn(r),n=Nn*Hn(n),new Pe(Kn(3.2404542*r-1.5371385*e-.4985314*n),Kn(-.969266*r+1.8760108*e+.041556*n),Kn(.0556434*r-.2040259*e+1.0572252*n),t.alpha)}function ei(t,e,r){const n=e-t;return t+r*(n>180||n<-180?n-360*Math.round(n/360):n)}const ri={forward:Qn,reverse:ti,interpolate:function(t,e,r){return {l:ke(t.l,e.l,r),a:ke(t.a,e.a,r),b:ke(t.b,e.b,r),alpha:ke(t.alpha,e.alpha,r)}}},ni={forward:function(t){const{l:e,a:r,b:n}=Qn(t),i=Math.atan2(n,r)*Zn;return {h:i<0?i+360:i,c:Math.sqrt(r*r+n*n),l:e,alpha:t.a}},reverse:function(t){const e=t.h*Yn,r=t.c;return ti({l:t.l,a:Math.cos(e)*r,b:Math.sin(e)*r,alpha:t.alpha})},interpolate:function(t,e,r){return {h:ei(t.h,e.h,r),c:ke(t.c,e.c,r),l:ke(t.l,e.l,r),alpha:ke(t.alpha,e.alpha,r)}}};var ii=Object.freeze({__proto__:null,hcl:ni,lab:ri});class si{constructor(t,e,r,n,i){this.type=t,this.operator=e,this.interpolation=r,this.input=n,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e);}static interpolationFactor(t,e,r,n){let i=0;if("exponential"===t.name)i=ai(e,t.base,r,n);else if("linear"===t.name)i=ai(e,1,r,n);else if("cubic-bezier"===t.name){const s=t.controlPoints;i=new j(s[0],s[1],s[2],s[3]).solve(ai(e,1,r,n));}return i}static parse(t,e){let[r,n,i,...s]=t;if(!Array.isArray(n)||0===n.length)return e.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const t=n[1];if("number"!=typeof t)return e.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:t};}else {if("cubic-bezier"!==n[0])return e.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const t=n.slice(1);if(4!==t.length||t.some((t=>"number"!=typeof t||t<0||t>1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:t};}}if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(i=e.parse(i,2,De),!i)return null;const a=[];let o=null;"interpolate-hcl"===r||"interpolate-lab"===r?o=Oe:e.expectedType&&"value"!==e.expectedType.kind&&(o=e.expectedType);for(let t=0;t=r)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',i);const u=e.parse(n,l,o);if(!u)return null;o=o||u.type,a.push([r,u]);}return "number"===o.kind||"color"===o.kind||"array"===o.kind&&"number"===o.itemType.kind&&"number"==typeof o.N?new si(o,r,n,i,a):e.error(`Type ${Xe(o)} is not interpolatable.`)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;if(n>=e[i-1])return r[i-1].evaluate(t);const s=On(e,n),a=si.interpolationFactor(this.interpolation,n,e[s],e[s+1]),o=r[s].evaluate(t),l=r[s+1].evaluate(t);return "interpolate"===this.operator?Ee[this.type.kind.toLowerCase()](o,l,a):"interpolate-hcl"===this.operator?ni.reverse(ni.interpolate(ni.forward(o),ni.forward(l),a)):ri.reverse(ri.interpolate(ri.forward(o),ri.forward(l),a))}eachChild(t){t(this.input);for(const e of this.outputs)t(e);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){let t;t="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const e=[this.operator,t,this.input.serialize()];for(let t=0;tZe(n,t.type)));return new oi(s?je:r,i)}evaluate(t){let e,r=null,n=0;for(const i of this.args){if(n++,r=i.evaluate(t),r&&r instanceof tr&&!r.available&&(e||(e=r),r=null,n===this.args.length))return e;if(null!==r)break}return r}eachChild(t){this.args.forEach(t);}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=["coalesce"];return this.eachChild((e=>{t.push(e.serialize());})),t}}class li{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e;}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result);}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const r=[];for(let n=1;n=r.length)throw new ar(`Array index out of bounds: ${e} > ${r.length-1}.`);if(e!==Math.floor(e))throw new ar(`Array index must be an integer, but found ${e} instead.`);return r[e]}eachChild(t){t(this.index),t(this.input);}outputDefined(){return !1}serialize(){return ["at",this.index.serialize(),this.input.serialize()]}}class ci{constructor(t,e){this.type=Fe,this.needle=t,this.haystack=e;}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,je),n=e.parse(t[2],2,je);return r&&n?We(r.type,[Fe,Le,De,Re,je])?new ci(r,n):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Xe(r.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(null==r)return !1;if(!He(e,["boolean","string","number","null"]))throw new ar(`Expected first argument to be of type boolean, string, number or null, but found ${Xe(nr(e))} instead.`);if(!He(r,["string","array"]))throw new ar(`Expected second argument to be of type array or string, but found ${Xe(nr(r))} instead.`);return r.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack);}outputDefined(){return !0}serialize(){return ["in",this.needle.serialize(),this.haystack.serialize()]}}class hi{constructor(t,e,r){this.type=De,this.needle=t,this.haystack=e,this.fromIndex=r;}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,je),n=e.parse(t[2],2,je);if(!r||!n)return null;if(!We(r.type,[Fe,Le,De,Re,je]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Xe(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,De);return i?new hi(r,n,i):null}return new hi(r,n)}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!He(e,["boolean","string","number","null"]))throw new ar(`Expected first argument to be of type boolean, string, number or null, but found ${Xe(nr(e))} instead.`);if(!He(r,["string","array"]))throw new ar(`Expected second argument to be of type array or string, but found ${Xe(nr(r))} instead.`);if(this.fromIndex){const n=this.fromIndex.evaluate(t);return r.indexOf(e,n)}return r.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex);}outputDefined(){return !1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const t=this.fromIndex.serialize();return ["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return ["index-of",this.needle.serialize(),this.haystack.serialize()]}}class pi{constructor(t,e,r,n,i,s){this.inputType=t,this.type=e,this.input=r,this.cases=n,this.outputs=i,this.otherwise=s;}static parse(t,e){if(t.length<5)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return e.error("Expected an even number of arguments.");let r,n;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);const i={},s=[];for(let a=2;aNumber.MAX_SAFE_INTEGER)return u.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return u.error("Numeric branch labels must be integer values.");if(r){if(u.checkSubtype(r,nr(t)))return null}else r=nr(t);if(void 0!==i[String(t)])return u.error("Branch labels must be unique.");i[String(t)]=s.length;}const c=e.parse(l,a,n);if(!c)return null;n=n||c.type,s.push(c);}const a=e.parse(t[1],1,je);if(!a)return null;const o=e.parse(t[t.length-1],t.length-1,n);return o?"value"!==a.type.kind&&e.concat(1).checkSubtype(r,a.type)?null:new pi(r,n,a,i,s,o):null}evaluate(t){const e=this.input.evaluate(t);return (nr(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["match",this.input.serialize()],e=Object.keys(this.cases).sort(),r=[],n={};for(const t of e){const e=n[this.cases[t]];void 0===e?(n[this.cases[t]]=r.length,r.push([this.cases[t],[t]])):r[e][1].push(t);}const i=t=>"number"===this.inputType.kind?Number(t):t;for(const[e,n]of r)t.push(1===n.length?i(n[0]):n.map(i)),t.push(this.outputs[e].serialize());return t.push(this.otherwise.serialize()),t}}class fi{constructor(t,e,r){this.type=t,this.branches=e,this.otherwise=r;}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return e.error("Expected an odd number of arguments.");let r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);const n=[];for(let i=1;ie.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["case"];return this.eachChild((e=>{t.push(e.serialize());})),t}}class di{constructor(t,e,r,n){this.type=t,this.input=e,this.beginIndex=r,this.endIndex=n;}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,je),n=e.parse(t[2],2,De);if(!r||!n)return null;if(!We(r.type,[Ge(je),Le,je]))return e.error(`Expected first argument to be of type array or string, but found ${Xe(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,De);return i?new di(r.type,r,n,i):null}return new di(r.type,r,n)}evaluate(t){const e=this.input.evaluate(t),r=this.beginIndex.evaluate(t);if(!He(e,["string","array"]))throw new ar(`Expected first argument to be of type array or string, but found ${Xe(nr(e))} instead.`);if(this.endIndex){const n=this.endIndex.evaluate(t);return e.slice(r,n)}return e.slice(r)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex);}outputDefined(){return !1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const t=this.endIndex.serialize();return ["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return ["slice",this.input.serialize(),this.beginIndex.serialize()]}}function mi(t,e){return "=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function yi(t,e,r,n){return 0===n.compare(e,r)}function gi(t,e,r){const n="=="!==t&&"!="!==t;return class i{constructor(t,e,r){this.type=Fe,this.lhs=t,this.rhs=e,this.collator=r,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind;}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const r=t[0];let s=e.parse(t[1],1,je);if(!s)return null;if(!mi(r,s.type))return e.concat(1).error(`"${r}" comparisons are not supported for type '${Xe(s.type)}'.`);let a=e.parse(t[2],2,je);if(!a)return null;if(!mi(r,a.type))return e.concat(2).error(`"${r}" comparisons are not supported for type '${Xe(a.type)}'.`);if(s.type.kind!==a.type.kind&&"value"!==s.type.kind&&"value"!==a.type.kind)return e.error(`Cannot compare types '${Xe(s.type)}' and '${Xe(a.type)}'.`);n&&("value"===s.type.kind&&"value"!==a.type.kind?s=new lr(a.type,[s]):"value"!==s.type.kind&&"value"===a.type.kind&&(a=new lr(s.type,[a])));let o=null;if(4===t.length){if("string"!==s.type.kind&&"string"!==a.type.kind&&"value"!==s.type.kind&&"value"!==a.type.kind)return e.error("Cannot use collator to compare non-string types.");if(o=e.parse(t[3],3,Ne),!o)return null}return new i(s,a,o)}evaluate(i){const s=this.lhs.evaluate(i),a=this.rhs.evaluate(i);if(n&&this.hasUntypedArgument){const e=nr(s),r=nr(a);if(e.kind!==r.kind||"string"!==e.kind&&"number"!==e.kind)throw new ar(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${r.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const t=nr(s),r=nr(a);if("string"!==t.kind||"string"!==r.kind)return e(i,s,a)}return this.collator?r(i,s,a,this.collator.evaluate(i)):e(i,s,a)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator);}outputDefined(){return !0}serialize(){const e=[t];return this.eachChild((t=>{e.push(t.serialize());})),e}}}const xi=gi("==",(function(t,e,r){return e===r}),yi),bi=gi("!=",(function(t,e,r){return e!==r}),(function(t,e,r,n){return !yi(0,e,r,n)})),vi=gi("<",(function(t,e,r){return e",(function(t,e,r){return e>r}),(function(t,e,r,n){return n.compare(e,r)>0})),_i=gi("<=",(function(t,e,r){return e<=r}),(function(t,e,r,n){return n.compare(e,r)<=0})),Mi=gi(">=",(function(t,e,r){return e>=r}),(function(t,e,r,n){return n.compare(e,r)>=0}));class Ai{constructor(t,e,r,n,i,s){this.type=Le,this.number=t,this.locale=e,this.currency=r,this.unit=n,this.minFractionDigits=i,this.maxFractionDigits=s;}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const r=e.parse(t[1],1,De);if(!r)return null;const n=t[2];if("object"!=typeof n||Array.isArray(n))return e.error("NumberFormat options argument must be an object.");let i=null;if(n.locale&&(i=e.parseObjectValue(n.locale,2,"locale",Le),!i))return null;let s=null;if(n.currency&&(s=e.parseObjectValue(n.currency,2,"currency",Le),!s))return null;let a=null;if(n.unit&&(a=e.parseObjectValue(n.unit,2,"unit",Le),!a))return null;let o=null;if(n["min-fraction-digits"]&&(o=e.parseObjectValue(n["min-fraction-digits"],2,"min-fraction-digits",De),!o))return null;let l=null;return n["max-fraction-digits"]&&(l=e.parseObjectValue(n["max-fraction-digits"],2,"max-fraction-digits",De),!l)?null:new Ai(r,i,s,a,o,l)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(t):void 0,unit:this.unit?this.unit.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.unit&&t(this.unit),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits);}outputDefined(){return !1}serialize(){const t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.unit&&(t.unit=this.unit.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]}}class Si{constructor(t){this.type=De,this.input=t;}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const r=e.parse(t[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?e.error(`Expected argument of type string or array, but found ${Xe(r.type)} instead.`):new Si(r):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return e.length;if(Array.isArray(e))return e.length;throw new ar(`Expected value to be of type string or array, but found ${Xe(nr(e))} instead.`)}eachChild(t){t(this.input);}outputDefined(){return !1}serialize(){const t=["length"];return this.eachChild((e=>{t.push(e.serialize());})),t}}function Ii(t){return function(){t=1831565813+(t|=0)|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}const Pi={"==":xi,"!=":bi,">":wi,"<":vi,">=":Mi,"<=":_i,array:lr,at:ui,boolean:lr,case:fi,coalesce:oi,collator:xr,format:ur,image:cr,in:ci,"index-of":hi,interpolate:si,"interpolate-hcl":si,"interpolate-lab":si,length:Si,let:li,literal:sr,match:pi,number:lr,"number-format":Ai,object:lr,slice:di,step:Un,string:lr,"to-boolean":fr,"to-color":fr,"to-number":fr,"to-string":fr,var:Rn,within:Ur,distance:Pn,config:Tn};function zi(t,[e,r,n,i]){e=e.evaluate(t),r=r.evaluate(t),n=n.evaluate(t);const s=i?i.evaluate(t):1,a=er(e,r,n,s);if(a)throw new ar(a);return new Pe(e/255*s,r/255*s,n/255*s,s)}function ki(t,[e,r,n,i]){e=e.evaluate(t),r=r.evaluate(t),n=n.evaluate(t);const s=i?i.evaluate(t):1,a=function(t,e,r,n){return "number"==typeof t&&t>=0&&t<=360?"number"==typeof e&&e>=0&&e<=100&&"number"==typeof r&&r>=0&&r<=100?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid hsla value [${[t,e,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${("number"==typeof n?[t,e,r,n]:[t,e,r]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${("number"==typeof n?[t,e,r,n]:[t,e,r]).join(", ")}]: 'h' must be between 0 and 360.`}(e,r,n,s);if(a)throw new ar(a);const o=`hsla(${e}, ${r}%, ${n}%, ${s})`,l=Pe.parse(o);if(!l)throw new ar(`Failed to parse HSLA color: ${o}`);return l}function Ti(t,e){return t in e}function Ei(t,e){const r=e[t];return void 0===r?null:r}function Bi(t){return {type:t}}function Vi(t){return {result:"success",value:t}}function Ci(t){return {result:"error",value:t}}function Ri(t,e){return !!t&&!!t.parameters&&t.parameters.indexOf(e)>-1}function Di(t){return "data-driven"===t["property-type"]}function Li(t){return Ri(t.expression,"measure-light")}function Fi(t){return Ri(t.expression,"zoom")}function Oi(t){return !!t.expression&&t.expression.interpolated}function Ui(t){return "object"==typeof t&&null!==t&&!Array.isArray(t)}function ji(t){return t}function Ni(t,e){const r="color"===e.type,n=t.stops&&"object"==typeof t.stops[0][0],i=n||!(n||void 0!==t.property),s=t.type||(Oi(e)?"exponential":"interval");if(r&&((t=Be({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],Pe.parse(t[1])]))),t.default=Pe.parse(t.default?t.default:e.default)),t.colorSpace&&"rgb"!==t.colorSpace&&!ii[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let a,o,l;if("exponential"===s)a=Xi;else if("interval"===s)a=Gi;else if("categorical"===s){a=$i,o=Object.create(null);for(const e of t.stops)o[e[0]]=e[1];l=typeof t.stops[0][0];}else {if("identity"!==s)throw new Error(`Unknown function type "${s}"`);a=Yi;}if(n){const r={},n=[];for(let e=0;et[0])),evaluate:({zoom:r},n)=>Xi({stops:i,base:t.base},e,r).evaluate(r,n)}}if(i){const r="exponential"===s?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return {kind:"camera",interpolationType:r,interpolationFactor:si.interpolationFactor.bind(void 0,r),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:r})=>a(t,e,r,o,l)}}return {kind:"source",evaluate(r,n){const i=n&&n.properties?n.properties[t.property]:void 0;return void 0===i?qi(t.default,e.default):a(t,e,i,o,l)}}}function qi(t,e,r){return void 0!==t?t:void 0!==e?e:void 0!==r?r:void 0}function $i(t,e,r,n,i){return qi(typeof r===i?n[r]:void 0,t.default,e.default)}function Gi(t,e,r){if("number"!==hr(r))return qi(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[n-1][0])return t.stops[n-1][1];const i=On(t.stops.map((t=>t[0])),r);return t.stops[i][1]}function Xi(t,e,r){const n=void 0!==t.base?t.base:1;if("number"!==hr(r))return qi(t.default,e.default);const i=t.stops.length;if(1===i)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[i-1][0])return t.stops[i-1][1];const s=On(t.stops.map((t=>t[0])),r),a=function(t,e,r,n){const i=n-r,s=t-r;return 0===i?0:1===e?s/i:(Math.pow(e,s)-1)/(Math.pow(e,i)-1)}(r,n,t.stops[s][0],t.stops[s+1][0]),o=t.stops[s][1],l=t.stops[s+1][1];let u=Ee[e.type]||ji;if(t.colorSpace&&"rgb"!==t.colorSpace){const e=ii[t.colorSpace];u=(t,r)=>e.reverse(e.interpolate(e.forward(t),e.forward(r),a));}return "function"==typeof o.evaluate?{evaluate(...t){const e=o.evaluate.apply(void 0,t),r=l.evaluate.apply(void 0,t);if(void 0!==e&&void 0!==r)return u(e,r,a)}}:u(o,l,a)}function Yi(t,e,r){return "color"===e.type?r=Pe.parse(r):"formatted"===e.type?r=Qe.fromString(r.toString()):"resolvedImage"===e.type?r=tr.fromString(r.toString()):hr(r)===e.type||"enum"===e.type&&e.values[r]||(r=void 0),qi(r,t.default,e.default)}yr.register(Pi,{error:[{kind:"error"},[Le],(t,[e])=>{throw new ar(e.evaluate(t))}],typeof:[Le,[je],(t,[e])=>Xe(nr(e.evaluate(t)))],"to-rgba":[Ge(De,4),[Oe],(t,[e])=>e.evaluate(t).toRenderColor(null).toArray()],rgb:[Oe,[De,De,De],zi],rgba:[Oe,[De,De,De,De],zi],hsl:[Oe,[De,De,De],ki],hsla:[Oe,[De,De,De,De],ki],has:{type:Fe,overloads:[[[Le],(t,[e])=>Ti(e.evaluate(t),t.properties())],[[Le,Ue],(t,[e,r])=>Ti(e.evaluate(t),r.evaluate(t))]]},get:{type:je,overloads:[[[Le],(t,[e])=>Ei(e.evaluate(t),t.properties())],[[Le,Ue],(t,[e,r])=>Ei(e.evaluate(t),r.evaluate(t))]]},"feature-state":[je,[Le],(t,[e])=>Ei(e.evaluate(t),t.featureState||{})],properties:[Ue,[],t=>t.properties()],"geometry-type":[Le,[],t=>t.geometryType()],id:[je,[],t=>t.id()],zoom:[De,[],t=>t.globals.zoom],pitch:[De,[],t=>t.globals.pitch||0],"distance-from-center":[De,[],t=>t.distanceFromCenter()],"measure-light":[De,[Le],(t,[e])=>t.measureLight(e.evaluate(t))],"heatmap-density":[De,[],t=>t.globals.heatmapDensity||0],"line-progress":[De,[],t=>t.globals.lineProgress||0],"raster-value":[De,[],t=>t.globals.rasterValue||0],"raster-particle-speed":[De,[],t=>t.globals.rasterParticleSpeed||0],"sky-radial-progress":[De,[],t=>t.globals.skyRadialProgress||0],accumulated:[je,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[De,Bi(De),(t,e)=>{let r=0;for(const n of e)r+=n.evaluate(t);return r}],"*":[De,Bi(De),(t,e)=>{let r=1;for(const n of e)r*=n.evaluate(t);return r}],"-":{type:De,overloads:[[[De,De],(t,[e,r])=>e.evaluate(t)-r.evaluate(t)],[[De],(t,[e])=>-e.evaluate(t)]]},"/":[De,[De,De],(t,[e,r])=>e.evaluate(t)/r.evaluate(t)],"%":[De,[De,De],(t,[e,r])=>e.evaluate(t)%r.evaluate(t)],ln2:[De,[],()=>Math.LN2],pi:[De,[],()=>Math.PI],e:[De,[],()=>Math.E],"^":[De,[De,De],(t,[e,r])=>Math.pow(e.evaluate(t),r.evaluate(t))],sqrt:[De,[De],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[De,[De],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[De,[De],(t,[e])=>Math.log(e.evaluate(t))],log2:[De,[De],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[De,[De],(t,[e])=>Math.sin(e.evaluate(t))],cos:[De,[De],(t,[e])=>Math.cos(e.evaluate(t))],tan:[De,[De],(t,[e])=>Math.tan(e.evaluate(t))],asin:[De,[De],(t,[e])=>Math.asin(e.evaluate(t))],acos:[De,[De],(t,[e])=>Math.acos(e.evaluate(t))],atan:[De,[De],(t,[e])=>Math.atan(e.evaluate(t))],min:[De,Bi(De),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[De,Bi(De),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[De,[De],(t,[e])=>Math.abs(e.evaluate(t))],round:[De,[De],(t,[e])=>{const r=e.evaluate(t);return r<0?-Math.round(-r):Math.round(r)}],floor:[De,[De],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[De,[De],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[Fe,[Le,je],(t,[e,r])=>t.properties()[e.value]===r.value],"filter-id-==":[Fe,[je],(t,[e])=>t.id()===e.value],"filter-type-==":[Fe,[Le],(t,[e])=>t.geometryType()===e.value],"filter-<":[Fe,[Le,je],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n{const r=t.id(),n=e.value;return typeof r==typeof n&&r":[Fe,[Le,je],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>i}],"filter-id->":[Fe,[je],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>n}],"filter-<=":[Fe,[Le,je],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n<=i}],"filter-id-<=":[Fe,[je],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r<=n}],"filter->=":[Fe,[Le,je],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>=i}],"filter-id->=":[Fe,[je],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>=n}],"filter-has":[Fe,[je],(t,[e])=>e.value in t.properties()],"filter-has-id":[Fe,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[Fe,[Ge(Le)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[Fe,[Ge(je)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[Fe,[Le,Ge(je)],(t,[e,r])=>r.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[Fe,[Le,Ge(je)],(t,[e,r])=>function(t,e,r,n){for(;r<=n;){const i=r+n>>1;if(e[i]===t)return !0;e[i]>t?n=i-1:r=i+1;}return !1}(t.properties()[e.value],r.value,0,r.value.length-1)],all:{type:Fe,overloads:[[[Fe,Fe],(t,[e,r])=>e.evaluate(t)&&r.evaluate(t)],[Bi(Fe),(t,e)=>{for(const r of e)if(!r.evaluate(t))return !1;return !0}]]},any:{type:Fe,overloads:[[[Fe,Fe],(t,[e,r])=>e.evaluate(t)||r.evaluate(t)],[Bi(Fe),(t,e)=>{for(const r of e)if(r.evaluate(t))return !0;return !1}]]},"!":[Fe,[Fe],(t,[e])=>!e.evaluate(t)],"is-supported-script":[Fe,[Le],(t,[e])=>{const r=t.globals&&t.globals.isSupportedScript;return !r||r(e.evaluate(t))}],upcase:[Le,[Le],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[Le,[Le],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[Le,Bi(je),(t,e)=>e.map((e=>ir(e.evaluate(t)))).join("")],"resolved-locale":[Le,[Ne],(t,[e])=>e.evaluate(t).resolvedLocale()],random:[De,[De,De,je],(t,e)=>{const[r,n,i]=e.map((e=>e.evaluate(t)));if(r>n)return r;if(r===n)return r;let s;if("string"==typeof i)s=function(t){let e=0;if(0===t.length)return e;for(let r=0;rJSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${t.message}`)),this._defaultValue}}}function Wi(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in Pi}function Hi(t,e,r,n){const i=new Ln(Pi,[],e?function(t){const e={color:Oe,string:Le,number:De,enum:Le,boolean:Fe,formatted:qe,resolvedImage:$e};return "array"===t.type?Ge(e[t.value]||je,t.length):e[t.type]}(e):void 0,void 0,void 0,r,n),s=i.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return s?Vi(new Zi(s,e,r,n)):Ci(i.errors)}class Ki{constructor(t,e,r){this.kind=t,this._styleExpression=e,this.isLightConstant=r,this.isStateDependent="constant"!==t&&!Bn(e.expression),this.configDependencies=Vn(e.expression);}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,s)}evaluate(t,e,r,n,i,s){return this._styleExpression.evaluate(t,e,r,n,i,s)}}class Ji{constructor(t,e,r,n,i){this.kind=t,this.zoomStops=r,this._styleExpression=e,this.isStateDependent="camera"!==t&&!Bn(e.expression),this.isLightConstant=i,this.configDependencies=Vn(e.expression),this.interpolationType=n;}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,s)}evaluate(t,e,r,n,i,s){return this._styleExpression.evaluate(t,e,r,n,i,s)}interpolationFactor(t,e,r){return this.interpolationType?si.interpolationFactor(this.interpolationType,t,e,r):0}}function Qi(t,e,r,n){if("error"===(t=Hi(t,e,r,n)).result)return t;const i=t.value.expression,s=En(i);if(!s&&!Di(e))return Ci([new Ve("","data expressions not supported")]);const a=Cn(i,["zoom","pitch","distance-from-center"]);if(!a&&!Fi(e))return Ci([new Ve("","zoom expressions not supported")]);const o=Cn(i,["measure-light"]);if(!o&&!Li(e))return Ci([new Ve("","measure-light expression not supported")]);const l=e.expression&&e.expression.relaxZoomRestriction,u=es(i);return u||a||l?u instanceof Ve?Ci([u]):u instanceof si&&!Oi(e)?Ci([new Ve("",'"interpolate" expressions cannot be used with this property')]):Vi(u?new Ji(s?"camera":"composite",t.value,u.labels,u instanceof si?u.interpolation:void 0,o):new Ki(s?"constant":"source",t.value,o)):Ci([new Ve("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class ts{constructor(t,e){this._parameters=t,this._specification=e,Be(this,Ni(this._parameters,this._specification));}static deserialize(t){return new ts(t._parameters,t._specification)}static serialize(t){return {_parameters:t._parameters,_specification:t._specification}}}function es(t){let e=null;if(t instanceof li)e=es(t.result);else if(t instanceof oi){for(const r of t.args)if(e=es(r),e)break}else (t instanceof Un||t instanceof si)&&t.input instanceof yr&&"zoom"===t.input.name&&(e=t);return e instanceof Ve||t.eachChild((t=>{const r=es(t);r instanceof Ve?e=r:e&&r&&e!==r&&(e=new Ve("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'));})),e}var rs,ns,is=function(){if(ns)return rs;ns=1,rs=e;var t=3;function e(e,r,n){var i=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;var s=new Int32Array(this.arrayBuffer);e=s[0],this.d=(r=s[1])+2*(n=s[2]);for(var a=0;a=c[f+0]&&n>=c[f+1])?(a[p]=!0,s.push(u[p])):a[p]=!1;}}},e.prototype._forEachCell=function(t,e,r,n,i,s,a,o){for(var l=this._convertToCellCoord(t),u=this._convertToCellCoord(e),c=this._convertToCellCoord(r),h=this._convertToCellCoord(n),p=l;p<=c;p++)for(var f=u;f<=h;f++){var d=this.d*f+p;if((!o||o(this._convertFromCellCoord(p),this._convertFromCellCoord(f),this._convertFromCellCoord(p+1),this._convertFromCellCoord(f+1)))&&i.call(this,t,e,r,n,d,s,a,o))return}},e.prototype._convertFromCellCoord=function(t){return (t-this.padding)/this.scale},e.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},e.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var e=this.cells,r=t+this.cells.length+1+1,n=0,i=0;i=0||(i[r]=cs(t[r],e)));t instanceof Error&&(i.message=t.message);}if(i.$name)throw new Error("$name property is reserved for worker serialization logic.");return "Object"!==n&&(i.$name=n),i}throw new Error("can't serialize object of type "+typeof t)}function hs(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||ls(t)||us(t)||ArrayBuffer.isView(t)||t instanceof ImageData)return t;if(Array.isArray(t))return t.map(hs);if("object"==typeof t){const e=t.$name||"Object";if("Map"===e){const e=new Map;for(const r of Object.keys(t))"$name"!==r&&e.set(r,hs(t[r]));return e}if("Set"===e){const e=new Set;for(const r of Object.keys(t))"$name"!==r&&e.add(hs(t[r]));return e}const{klass:r}=as[e];if(!r)throw new Error(`can't deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(t);const n=Object.create(r.prototype);for(const e of Object.keys(t))"$name"!==e&&(n[e]=hs(t[e]));return n}throw new Error("can't deserialize object of type "+typeof t)}const ps={"Latin-1 Supplement":t=>t>=128&&t<=255,Arabic:t=>t>=1536&&t<=1791,"Arabic Supplement":t=>t>=1872&&t<=1919,"Arabic Extended-A":t=>t>=2208&&t<=2303,"Hangul Jamo":t=>t>=4352&&t<=4607,"Unified Canadian Aboriginal Syllabics":t=>t>=5120&&t<=5759,Khmer:t=>t>=6016&&t<=6143,"Unified Canadian Aboriginal Syllabics Extended":t=>t>=6320&&t<=6399,"General Punctuation":t=>t>=8192&&t<=8303,"Letterlike Symbols":t=>t>=8448&&t<=8527,"Number Forms":t=>t>=8528&&t<=8591,"Miscellaneous Technical":t=>t>=8960&&t<=9215,"Control Pictures":t=>t>=9216&&t<=9279,"Optical Character Recognition":t=>t>=9280&&t<=9311,"Enclosed Alphanumerics":t=>t>=9312&&t<=9471,"Geometric Shapes":t=>t>=9632&&t<=9727,"Miscellaneous Symbols":t=>t>=9728&&t<=9983,"Miscellaneous Symbols and Arrows":t=>t>=11008&&t<=11263,"CJK Radicals Supplement":t=>t>=11904&&t<=12031,"Kangxi Radicals":t=>t>=12032&&t<=12255,"Ideographic Description Characters":t=>t>=12272&&t<=12287,"CJK Symbols and Punctuation":t=>t>=12288&&t<=12351,Hiragana:t=>t>=12352&&t<=12447,Katakana:t=>t>=12448&&t<=12543,Bopomofo:t=>t>=12544&&t<=12591,"Hangul Compatibility Jamo":t=>t>=12592&&t<=12687,Kanbun:t=>t>=12688&&t<=12703,"Bopomofo Extended":t=>t>=12704&&t<=12735,"CJK Strokes":t=>t>=12736&&t<=12783,"Katakana Phonetic Extensions":t=>t>=12784&&t<=12799,"Enclosed CJK Letters and Months":t=>t>=12800&&t<=13055,"CJK Compatibility":t=>t>=13056&&t<=13311,"CJK Unified Ideographs Extension A":t=>t>=13312&&t<=19903,"Yijing Hexagram Symbols":t=>t>=19904&&t<=19967,"CJK Unified Ideographs":t=>t>=19968&&t<=40959,"Yi Syllables":t=>t>=40960&&t<=42127,"Yi Radicals":t=>t>=42128&&t<=42191,"Hangul Jamo Extended-A":t=>t>=43360&&t<=43391,"Hangul Syllables":t=>t>=44032&&t<=55215,"Hangul Jamo Extended-B":t=>t>=55216&&t<=55295,"Private Use Area":t=>t>=57344&&t<=63743,"CJK Compatibility Ideographs":t=>t>=63744&&t<=64255,"Arabic Presentation Forms-A":t=>t>=64336&&t<=65023,"Vertical Forms":t=>t>=65040&&t<=65055,"CJK Compatibility Forms":t=>t>=65072&&t<=65103,"Small Form Variants":t=>t>=65104&&t<=65135,"Arabic Presentation Forms-B":t=>t>=65136&&t<=65279,"Halfwidth and Fullwidth Forms":t=>t>=65280&&t<=65519,"CJK Unified Ideographs Extension B":t=>t>=131072&&t<=173791};function fs(t){for(const e of t)if(ys(e.charCodeAt(0)))return !0;return !1}function ds(t){for(const e of t)if(!ms(e.charCodeAt(0)))return !1;return !0}function ms(t){return !(ps.Arabic(t)||ps["Arabic Supplement"](t)||ps["Arabic Extended-A"](t)||ps["Arabic Presentation Forms-A"](t)||ps["Arabic Presentation Forms-B"](t))}function ys(t){return !(746!==t&&747!==t&&(t<4352||!(ps["Bopomofo Extended"](t)||ps.Bopomofo(t)||ps["CJK Compatibility Forms"](t)&&!(t>=65097&&t<=65103)||ps["CJK Compatibility Ideographs"](t)||ps["CJK Compatibility"](t)||ps["CJK Radicals Supplement"](t)||ps["CJK Strokes"](t)||!(!ps["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||ps["CJK Unified Ideographs Extension A"](t)||ps["CJK Unified Ideographs"](t)||ps["Enclosed CJK Letters and Months"](t)||ps["Hangul Compatibility Jamo"](t)||ps["Hangul Jamo Extended-A"](t)||ps["Hangul Jamo Extended-B"](t)||ps["Hangul Jamo"](t)||ps["Hangul Syllables"](t)||ps.Hiragana(t)||ps["Ideographic Description Characters"](t)||ps.Kanbun(t)||ps["Kangxi Radicals"](t)||ps["Katakana Phonetic Extensions"](t)||ps.Katakana(t)&&12540!==t||!(!ps["Halfwidth and Fullwidth Forms"](t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!ps["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||ps["Unified Canadian Aboriginal Syllabics"](t)||ps["Unified Canadian Aboriginal Syllabics Extended"](t)||ps["Vertical Forms"](t)||ps["Yijing Hexagram Symbols"](t)||ps["Yi Syllables"](t)||ps["Yi Radicals"](t))))}function gs(t){return !(ys(t)||function(t){return !!(ps["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||ps["General Punctuation"](t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||ps["Letterlike Symbols"](t)||ps["Number Forms"](t)||ps["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||ps["Control Pictures"](t)&&9251!==t||ps["Optical Character Recognition"](t)||ps["Enclosed Alphanumerics"](t)||ps["Geometric Shapes"](t)||ps["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||ps["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||ps["CJK Symbols and Punctuation"](t)||ps.Katakana(t)||ps["Private Use Area"](t)||ps["CJK Compatibility Forms"](t)||ps["Small Form Variants"](t)||ps["Halfwidth and Fullwidth Forms"](t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}function xs(t){return t>=1424&&t<=2303||ps["Arabic Presentation Forms-A"](t)||ps["Arabic Presentation Forms-B"](t)}function bs(t,e){return !(!e&&xs(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||ps.Khmer(t))}function vs(t){for(const e of t)if(xs(e.charCodeAt(0)))return !0;return !1}const ws="deferred",_s="loading",Ms="loaded";let As=null,Ss="unavailable",Is=null;const Ps=function(t){t&&"string"==typeof t&&t.indexOf("NetworkError")>-1&&(Ss="error"),As&&As(t);};function zs(){ks.fire(new be("pluginStateChange",{pluginStatus:Ss,pluginURL:Is}));}const ks=new Me,Ts=function(){return Ss},Es=function(){if(Ss!==ws||!Is)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Ss=_s,zs(),Is&&se({url:Is},(t=>{t?Ps(t):(Ss=Ms,zs());}));},Bs={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Ss===Ms||null!=Bs.applyArabicShaping,isLoading:()=>Ss===_s,setState(t){Ss=t.pluginStatus,Is=t.pluginURL;},isParsed:()=>null!=Bs.applyArabicShaping&&null!=Bs.processBidirectionalText&&null!=Bs.processStyledBidirectionalText,getPluginURL:()=>Is};class Vs{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.transition=e.transition,this.pitch=e.pitch,this.brightness=e.brightness):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0);}isSupportedScript(t){return function(t,e){for(const r of t)if(!bs(r.charCodeAt(0),e))return !1;return !0}(t,Bs.isLoaded())}}class Cs{constructor(t,e,r,n){this.property=t,this.value=e,this.expression=function(t,e,r,n){if(Ui(t))return new ts(t,e);if(Wi(t)||Array.isArray(t)&&t.length>0){const i=Qi(t,e,r,n);if("error"===i.result)throw new Error(i.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return i.value}{let r=t;return "string"==typeof t&&"color"===e.type&&(r=Pe.parse(t)),{kind:"constant",configDependencies:new Set,evaluate:()=>r}}}(void 0===e?t.specification.default:e,t.specification,r,n);}isDataDriven(){return "source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,r){return this.property.possiblyEvaluate(this,t,e,r)}}class Rs{constructor(t,e,r){this.property=t,this.value=new Cs(t,void 0,e,r);}transitioned(t,e){return new Ls(this.property,this.value,e,nt({},t.transition,this.transition),t.now)}untransitioned(){return new Ls(this.property,this.value,null,{},0)}}class Ds{constructor(t,e,r){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues),this._scope=e,this._options=r,this.configDependencies=new Set;}getValue(t){return ht(this._values[t].value.value)}setValue(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new Rs(this._values[t].property,this._scope,this._options)),this._values[t].value=new Cs(this._values[t].property,null===e?void 0:ht(e),this._scope,this._options),this._values[t].value.expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[t].value.expression.configDependencies]));}setTransitionOrValue(t,e){e&&(this._options=e);const r=this._properties.properties;if(t)for(const e in t){const n=t[e];if(lt(e,"-transition")){const t=e.slice(0,-11);r[t]&&this.setTransition(t,n);}else r.hasOwnProperty(e)&&this.setValue(e,n);}}getTransition(t){return ht(this._values[t].transition)}setTransition(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new Rs(this._values[t].property)),this._values[t].transition=ht(e)||void 0;}serialize(){const t={};for(const e of Object.keys(this._values)){const r=this.getValue(e);void 0!==r&&(t[e]=r);const n=this.getTransition(e);void 0!==n&&(t[`${e}-transition`]=n);}return t}transitioned(t,e){const r=new Fs(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].transitioned(t,e._values[n]);return r}untransitioned(){const t=new Fs(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class Ls{constructor(t,e,r,n,i){const s=n.delay||0,a=n.duration||0;i=i||0,this.property=t,this.value=e,this.begin=i+s,this.end=this.begin+a,t.specification.transition&&(n.delay||n.duration)&&(this.prior=r);}possiblyEvaluate(t,e,r){const n=t.now||0,i=this.value.possiblyEvaluate(t,e,r),s=this.prior;if(s){if(n>this.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;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":"*","required":false}},"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","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"high-color":{"type":"color","property-type":"data-constant","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"space-color":{"type":"color","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","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","property-type":"data-constant","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","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}}},"camera":{"camera-projection":{"type":"enum","values":{"perspective":1,"orthographic":1},"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"default":"perspective","property-type":"data-constant"}},"colorTheme":{"data":{"type":"string","property-type":"data-constant","expression":{}}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"property-type":"data-constant","expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","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","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-180,-90],"maximum":[180,90]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-90,-90],"maximum":[90,90]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","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_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"]},"property-type":"data-constant"},"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","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","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"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"fill-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","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"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","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"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"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-vertical-gradient":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-ambient-occlusion-intensity":{"property-type":"data-constant","type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"property-type":"data-constant","type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-wall-radius":{"property-type":"data-constant","type":"number","experimental":true,"default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-radius":{"property-type":"data-constant","type":"number","experimental":true,"default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-attenuation":{"property-type":"data-constant","type":"number","experimental":true,"default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-flood-light-color":{"property-type":"data-constant","type":"color","experimental":true,"default":"#ffffff","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-intensity":{"property-type":"data-constant","type":"number","experimental":true,"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","experimental":true,"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","experimental":true,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-attenuation":{"property-type":"data-constant","type":"number","experimental":true,"default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-vertical-scale":{"property-type":"data-constant","type":"number","experimental":true,"default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-rounded-roof":{"property-type":"data-constant","type":"boolean","default":true,"experimental":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{},"property-type":"data-constant"},"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,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-cast-shadows":{"type":"boolean","default":true,"property-type":"data-constant"}},"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","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"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"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-gradient":{"type":"color","expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"property-type":"constant"},"line-trim-fade-range":{"type":"array","value":"number","experimental":true,"length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"line-trim-color":{"type":"color","experimental":true,"default":"transparent","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"line-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"line-border-width":{"type":"number","private":true,"default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-border-color":{"type":"color","private":true,"default":"rgba(0, 0, 0, 0)","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,"property-type":"data-constant"}},"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","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"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"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","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"]},"property-type":"data-constant"}},"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"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"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","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)","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"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-image-cross-fade":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"transition":true},"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","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)","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"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-color-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{},"property-type":"data-constant"},"icon-color-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{},"property-type":"data-constant"},"icon-color-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{},"property-type":"data-constant"},"icon-color-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{},"property-type":"data-constant"},"symbol-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1},"default":"ground","experimental":true,"expression":{"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-color":{"type":"color","expression":{"interpolated":true,"parameters":["raster-value"]},"property-type":"color-ramp"},"raster-color-mix":{"type":"array","default":[0.2126,0.7152,0.0722,0],"length":4,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color-range":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":1,"nearest":1},"default":"linear","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"raster-array-band":{"type":"string","required":false,"experimental":true,"property-type":"data-constant"},"raster-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster-particle":{"raster-particle-array-band":{"type":"string","required":false,"property-type":"data-constant"},"raster-particle-count":{"type":"number","default":512,"minimum":1,"property-type":"data-constant"},"raster-particle-color":{"type":"color","expression":{"interpolated":true,"parameters":["raster-particle-speed"]},"property-type":"color-ramp"},"raster-particle-max-speed":{"type":"number","default":1,"minimum":1,"property-type":"data-constant"},"raster-particle-speed-factor":{"type":"number","default":0.2,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-particle-fade-opacity-factor":{"type":"number","default":0.98,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-particle-reset-rate-factor":{"type":"number","default":0.8,"minimum":0,"maximum":1,"property-type":"data-constant"},"raster-particle-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"hillshade-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_background":{"background-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":[]},"property-type":"data-constant"},"background-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":1,"atmosphere":1},"default":"atmosphere","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","default":10,"minimum":0,"maximum":100,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","value":"number","default":[0,0],"length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","default":90,"minimum":0,"maximum":180,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_model":{"model-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"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"]},"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","property-type":"data-constant"},"model-cast-shadows":{"type":"boolean","default":true,"property-type":"data-constant"},"model-receive-shadows":{"type":"boolean","default":true,"property-type":"data-constant"},"model-ambient-occlusion-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant","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":{},"property-type":"data-constant"},"model-front-cutoff":{"type":"array","private":true,"value":"number","property-type":"data-constant","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]}},"transition":{"duration":{"type":"number","default":300,"minimum":0},"delay":{"type":"number","default":0,"minimum":0}},"property-type":{"data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');function Ys(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function Zs(t){if(Array.isArray(t))return t.map(Zs);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){const e={};for(const r in t)e[r]=Zs(t[r]);return e}return Ys(t)}function Ws(t){if(!0===t||!1===t)return !0;if(!Array.isArray(t)||0===t.length)return !1;switch(t[0]){case"has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return !1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(const e of t.slice(1))if(!Ws(e)&&"boolean"!=typeof e)return !1;return !0;default:return !0}}function Hs(t,e="",r=null,n="fill"){if(null==t)return {filter:()=>!0,needGeometry:!1,needFeature:!1};Ws(t)||(t=na(t));const i=t;let s=!0;try{s=function(t){if(!Qs(t))return t;let e=Zs(t);return Js(e),e=Ks(e),e}(i);}catch(t){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(i,null,2)}\n `);}const a=Xs[`filter_${n}`],o=Hi(s,a,e,r);let l=null;if("error"===o.result)throw new Error(o.value.map((t=>`${t.key}: ${t.message}`)).join(", "));l=(t,e,r)=>o.value.evaluate(t,e,{},r);let u=null,c=null;if(s!==i){const t=Hi(i,a,e,r);if("error"===t.result)throw new Error(t.value.map((t=>`${t.key}: ${t.message}`)).join(", "));u=(e,r,n,i,s)=>t.value.evaluate(e,r,{},n,void 0,void 0,i,s),c=!En(t.value.expression);}return {filter:l,dynamicFilter:u||void 0,needGeometry:ra(s),needFeature:!!c}}function Ks(t){if(!Array.isArray(t))return t;const e=function(t){if(ta.has(t[0]))for(let e=1;eKs(t)))}function Js(t){let e=!1;const r=[];if("case"===t[0]){for(let n=1;n",">=","<","<=","to-boolean"]);function ea(t,e){return te?1:0}function ra(t){if(!Array.isArray(t))return !1;if("within"===t[0]||"distance"===t[0])return !0;for(let e=1;e"===e||"<="===e||">="===e?ia(t[1],t[2],e):"any"===e?(r=t.slice(1),["any"].concat(r.map(na))):"all"===e?["all"].concat(t.slice(1).map(na)):"none"===e?["all"].concat(t.slice(1).map(na).map(oa)):"in"===e?sa(t[1],t.slice(2)):"!in"===e?oa(sa(t[1],t.slice(2))):"has"===e?aa(t[1]):"!has"!==e||oa(aa(t[1]));var r;}function ia(t,e,r){switch(t){case"$type":return [`filter-type-${r}`,e];case"$id":return [`filter-id-${r}`,e];default:return [`filter-${r}`,t,e]}}function sa(t,e){if(0===e.length)return !1;switch(t){case"$type":return ["filter-type-in",["literal",e]];case"$id":return ["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(ea)]]:["filter-in-small",t,["literal",e]]}}function aa(t){switch(t){case"$type":return !0;case"$id":return ["filter-has-id"];default:return ["filter-has",t]}}function oa(t){return ["!",t]}const la="";function ua(t,e){return e?`${t}${la}${e}`:t}const ca="-transition",ha=new Set(["fill","line","background","hillshade","raster"]);class pa extends Me{constructor(t,e,r,n,i){if(super(),this.id=t.id,this.fqid=ua(this.id,r),this.type=t.type,this.scope=r,this.lut=n,this.options=i,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.configDependencies=new Set,"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&"sky"!==t.type&&"slot"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),t.slot&&(this.slot=t.slot),e.layout&&(this._unevaluatedLayout=new Os(e.layout,this.scope,i),this.configDependencies=new Set([...this.configDependencies,...this._unevaluatedLayout.configDependencies])),e.paint)){this._transitionablePaint=new Ds(e.paint,this.scope,i);for(const e in t.paint)this.setPaintProperty(e,t.paint[e]);for(const e in t.layout)this.setLayoutProperty(e,t.layout[e]);this.configDependencies=new Set([...this.configDependencies,...this._transitionablePaint.configDependencies]),this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new js(e.paint);}}onAdd(t){}onRemove(t){}isDraped(t){return !this.is3D()&&ha.has(this.type)}getLayoutProperty(t){return "visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e){if("custom"===this.type&&"visibility"===t)return void(this.visibility=e);const r=this._unevaluatedLayout;r._properties.properties[t]&&(r.setValue(t,e),this.configDependencies=new Set([...this.configDependencies,...r.configDependencies]),"visibility"===t&&this.possiblyEvaluateVisibility());}possiblyEvaluateVisibility(){this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0});}getPaintProperty(t){return lt(t,ca)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e){const r=this._transitionablePaint,n=r._properties.properties;if(lt(t,ca)){const i=t.slice(0,-11);return n[i]&&r.setTransition(i,e||void 0),!1}if(!n[t])return !1;const i=r._values[t],s=i.value.isDataDriven(),a=i.value;r.setValue(t,e),this.configDependencies=new Set([...this.configDependencies,...r.configDependencies]),this._handleSpecialPaintPropertyUpdate(t);const o=r._values[t].value,l=o.isDataDriven(),u=lt(t,"pattern")||"line-dasharray"===t;return l||s||u||this._handleOverridablePaintPropertyUpdate(t,a,o)}_handleSpecialPaintPropertyUpdate(t){}getProgramIds(){return null}getDefaultProgramParams(t,e,r){return null}_handleOverridablePaintPropertyUpdate(t,e,r){return !1}isHidden(t){return !!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint);}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e);}serialize(){return ct({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()},((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}is3D(){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(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof Us&&Di(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return !0}return !1}compileFilter(t){this._filterCompiled||(this._featureFilter=Hs(this.filter,this.scope,t),this._filterCompiled=!0);}invalidateCompiledFilter(){this._filterCompiled=!1;}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(t){this._stats&&("shadow"===t.renderPass?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0);}queryRadius(t){}queryIntersectsFeature(t,e,r,n,i,s,a,o,l){}queryIntersectsMatchingFeature(t,e,r,n){}}const fa={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class da{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8;}}class ma{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0);}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.add(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews());}clear(){this.length=0;}resize(t){this.reserve(t),this.length=t;}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e);}}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...t){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...t){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 ya(t,e=1){let r=0,n=0;return {members:t.map((t=>{const i=fa[t.type].BYTES_PER_ELEMENT,s=r=ga(r,Math.max(e,i)),a=t.components||1;return n=Math.max(n,i),r+=i*a,{name:t.name,type:t.type,components:a,offset:s}})),size:ga(r,Math.max(n,e)),alignment:e}}function ga(t,e){return Math.ceil(t/e)*e}class xa extends ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.int16[n+0]=e,this.int16[n+1]=r,t}}xa.prototype.bytesPerElement=4,os(xa,"StructArrayLayout2i4");class ba extends ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.int16[i+0]=e,this.int16[i+1]=r,this.int16[i+2]=n,t}}ba.prototype.bytesPerElement=6,os(ba,"StructArrayLayout3i6");class va extends ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const s=4*t;return this.int16[s+0]=e,this.int16[s+1]=r,this.int16[s+2]=n,this.int16[s+3]=i,t}}va.prototype.bytesPerElement=8,os(va,"StructArrayLayout4i8");class wa extends ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n,i)}emplace(t,e,r,n,i,s){const a=5*t;return this.int16[a+0]=e,this.int16[a+1]=r,this.int16[a+2]=n,this.int16[a+3]=i,this.int16[a+4]=s,t}}wa.prototype.bytesPerElement=10,os(wa,"StructArrayLayout5i10");class _a extends ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i,s,a)}emplace(t,e,r,n,i,s,a,o){const l=6*t,u=12*t,c=3*t;return this.int16[l+0]=e,this.int16[l+1]=r,this.uint8[u+4]=n,this.uint8[u+5]=i,this.uint8[u+6]=s,this.uint8[u+7]=a,this.float32[c+2]=o,t}}_a.prototype.bytesPerElement=12,os(_a,"StructArrayLayout2i4ub1f12");class Ma extends ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const s=4*t;return this.float32[s+0]=e,this.float32[s+1]=r,this.float32[s+2]=n,this.float32[s+3]=i,t}}Ma.prototype.bytesPerElement=16,os(Ma,"StructArrayLayout4f16");class Aa extends ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.float32[i+0]=e,this.float32[i+1]=r,this.float32[i+2]=n,t}}Aa.prototype.bytesPerElement=12,os(Aa,"StructArrayLayout3f12");class Sa extends ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n,i)}emplace(t,e,r,n,i,s){const a=6*t,o=3*t;return this.uint16[a+0]=e,this.uint16[a+1]=r,this.uint16[a+2]=n,this.uint16[a+3]=i,this.float32[o+2]=s,t}}Sa.prototype.bytesPerElement=12,os(Sa,"StructArrayLayout4ui1f12");class Ia extends ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const s=4*t;return this.uint16[s+0]=e,this.uint16[s+1]=r,this.uint16[s+2]=n,this.uint16[s+3]=i,t}}Ia.prototype.bytesPerElement=8,os(Ia,"StructArrayLayout4ui8");class Pa extends ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=n,this.int16[o+3]=i,this.int16[o+4]=s,this.int16[o+5]=a,t}}Pa.prototype.bytesPerElement=12,os(Pa,"StructArrayLayout6i12");class za extends ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,r,n,i,s,a,o,l,u,c,h)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p){const f=12*t;return this.int16[f+0]=e,this.int16[f+1]=r,this.int16[f+2]=n,this.int16[f+3]=i,this.uint16[f+4]=s,this.uint16[f+5]=a,this.uint16[f+6]=o,this.uint16[f+7]=l,this.int16[f+8]=u,this.int16[f+9]=c,this.int16[f+10]=h,this.int16[f+11]=p,t}}za.prototype.bytesPerElement=24,os(za,"StructArrayLayout4i4ui4i24");class ka extends ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=10*t,l=5*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=n,this.float32[l+2]=i,this.float32[l+3]=s,this.float32[l+4]=a,t}}ka.prototype.bytesPerElement=20,os(ka,"StructArrayLayout3i3f20");class Ta extends ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}Ta.prototype.bytesPerElement=4,os(Ta,"StructArrayLayout1ul4");class Ea extends ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.uint16[n+0]=e,this.uint16[n+1]=r,t}}Ea.prototype.bytesPerElement=4,os(Ea,"StructArrayLayout2ui4");class Ba extends ma{_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(t,e,r,n,i,s,a,o,l,u,c,h,p){const f=this.length;return this.resize(f+1),this.emplace(f,t,e,r,n,i,s,a,o,l,u,c,h,p)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p,f){const d=20*t,m=10*t;return this.int16[d+0]=e,this.int16[d+1]=r,this.int16[d+2]=n,this.int16[d+3]=i,this.int16[d+4]=s,this.float32[m+3]=a,this.float32[m+4]=o,this.float32[m+5]=l,this.float32[m+6]=u,this.int16[d+14]=c,this.uint32[m+8]=h,this.uint16[d+18]=p,this.uint16[d+19]=f,t}}Ba.prototype.bytesPerElement=40,os(Ba,"StructArrayLayout5i4f1i1ul2ui40");class Va extends ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i,s,a)}emplace(t,e,r,n,i,s,a,o){const l=8*t;return this.int16[l+0]=e,this.int16[l+1]=r,this.int16[l+2]=n,this.int16[l+4]=i,this.int16[l+5]=s,this.int16[l+6]=a,this.int16[l+7]=o,t}}Va.prototype.bytesPerElement=16,os(Va,"StructArrayLayout3i2i2i16");class Ca extends ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n,i)}emplace(t,e,r,n,i,s){const a=4*t,o=8*t;return this.float32[a+0]=e,this.float32[a+1]=r,this.float32[a+2]=n,this.int16[o+6]=i,this.int16[o+7]=s,t}}Ca.prototype.bytesPerElement=16,os(Ca,"StructArrayLayout2f1f2i16");class Ra extends ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=20*t,l=5*t;return this.uint8[o+0]=e,this.uint8[o+1]=r,this.float32[l+1]=n,this.float32[l+2]=i,this.float32[l+3]=s,this.float32[l+4]=a,t}}Ra.prototype.bytesPerElement=20,os(Ra,"StructArrayLayout2ub4f20");class Da extends ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.uint16[i+0]=e,this.uint16[i+1]=r,this.uint16[i+2]=n,t}}Da.prototype.bytesPerElement=6,os(Da,"StructArrayLayout3ui6");class La extends ma{_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(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m,y,g,x,b,v){const w=this.length;return this.resize(w+1),this.emplace(w,t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m,y,g,x,b,v)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m,y,g,x,b,v,w){const _=30*t,M=15*t,A=60*t;return this.int16[_+0]=e,this.int16[_+1]=r,this.int16[_+2]=n,this.float32[M+2]=i,this.float32[M+3]=s,this.uint16[_+8]=a,this.uint16[_+9]=o,this.uint32[M+5]=l,this.uint32[M+6]=u,this.uint32[M+7]=c,this.uint16[_+16]=h,this.uint16[_+17]=p,this.uint16[_+18]=f,this.float32[M+10]=d,this.float32[M+11]=m,this.uint8[A+48]=y,this.uint8[A+49]=g,this.uint8[A+50]=x,this.uint32[M+13]=b,this.int16[_+28]=v,this.uint8[A+58]=w,t}}La.prototype.bytesPerElement=60,os(La,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Fa extends ma{_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(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m,y,g,x,b,v,w,_,M,A,S,I,P,z,k,T,E){const B=this.length;return this.resize(B+1),this.emplace(B,t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m,y,g,x,b,v,w,_,M,A,S,I,P,z,k,T,E)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m,y,g,x,b,v,w,_,M,A,S,I,P,z,k,T,E,B){const V=20*t,C=40*t,R=80*t;return this.float32[V+0]=e,this.float32[V+1]=r,this.int16[C+4]=n,this.int16[C+5]=i,this.int16[C+6]=s,this.int16[C+7]=a,this.int16[C+8]=o,this.int16[C+9]=l,this.int16[C+10]=u,this.int16[C+11]=c,this.int16[C+12]=h,this.uint16[C+13]=p,this.uint16[C+14]=f,this.uint16[C+15]=d,this.uint16[C+16]=m,this.uint16[C+17]=y,this.uint16[C+18]=g,this.uint16[C+19]=x,this.uint16[C+20]=b,this.uint16[C+21]=v,this.uint16[C+22]=w,this.uint16[C+23]=_,this.uint16[C+24]=M,this.uint16[C+25]=A,this.uint16[C+26]=S,this.uint16[C+27]=I,this.uint32[V+14]=P,this.float32[V+15]=z,this.float32[V+16]=k,this.float32[V+17]=T,this.float32[V+18]=E,this.uint8[R+76]=B,t}}Fa.prototype.bytesPerElement=80,os(Fa,"StructArrayLayout2f9i15ui1ul4f1ub80");class Oa extends ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}Oa.prototype.bytesPerElement=4,os(Oa,"StructArrayLayout1f4");class Ua extends ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n,i)}emplace(t,e,r,n,i,s){const a=5*t;return this.float32[a+0]=e,this.float32[a+1]=r,this.float32[a+2]=n,this.float32[a+3]=i,this.float32[a+4]=s,t}}Ua.prototype.bytesPerElement=20,os(Ua,"StructArrayLayout5f20");class ja extends ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i,s,a)}emplace(t,e,r,n,i,s,a,o){const l=7*t;return this.float32[l+0]=e,this.float32[l+1]=r,this.float32[l+2]=n,this.float32[l+3]=i,this.float32[l+4]=s,this.float32[l+5]=a,this.float32[l+6]=o,t}}ja.prototype.bytesPerElement=28,os(ja,"StructArrayLayout7f28");class Na extends ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const s=6*t;return this.uint32[3*t+0]=e,this.uint16[s+2]=r,this.uint16[s+3]=n,this.uint16[s+4]=i,t}}Na.prototype.bytesPerElement=12,os(Na,"StructArrayLayout1ul3ui12");class qa extends ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}qa.prototype.bytesPerElement=2,os(qa,"StructArrayLayout1ui2");class $a extends ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.float32[n+0]=e,this.float32[n+1]=r,t}}$a.prototype.bytesPerElement=8,os($a,"StructArrayLayout2f8");class Ga extends ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m){const y=this.length;return this.resize(y+1),this.emplace(y,t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m,y){const g=16*t;return this.float32[g+0]=e,this.float32[g+1]=r,this.float32[g+2]=n,this.float32[g+3]=i,this.float32[g+4]=s,this.float32[g+5]=a,this.float32[g+6]=o,this.float32[g+7]=l,this.float32[g+8]=u,this.float32[g+9]=c,this.float32[g+10]=h,this.float32[g+11]=p,this.float32[g+12]=f,this.float32[g+13]=d,this.float32[g+14]=m,this.float32[g+15]=y,t}}Ga.prototype.bytesPerElement=64,os(Ga,"StructArrayLayout16f64");class Xa extends ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i,s,a)}emplace(t,e,r,n,i,s,a,o){const l=10*t,u=5*t;return this.uint16[l+0]=e,this.uint16[l+1]=r,this.uint16[l+2]=n,this.uint16[l+3]=i,this.float32[u+2]=s,this.float32[u+3]=a,this.float32[u+4]=o,t}}Xa.prototype.bytesPerElement=20,os(Xa,"StructArrayLayout4ui3f20");class Ya extends ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.int16[1*t+0]=e,t}}Ya.prototype.bytesPerElement=2,os(Ya,"StructArrayLayout1i2");class Za extends ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint8[1*t+0]=e,t}}Za.prototype.bytesPerElement=1,os(Za,"StructArrayLayout1ub1");class Wa extends da{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]}}Wa.prototype.size=40;class Ha extends Ba{get(t){return new Wa(this,t)}}os(Ha,"CollisionBoxArray");class Ka extends da{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(t){this._structArray.uint8[this._pos1+49]=t;}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(t){this._structArray.uint8[this._pos1+50]=t;}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(t){this._structArray.uint32[this._pos4+13]=t;}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(t){this._structArray.uint8[this._pos1+58]=t;}}Ka.prototype.size=60;class Ja extends La{get(t){return new Ka(this,t)}}os(Ja,"PlacedSymbolArray");class Qa extends da{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(t){this._structArray.uint32[this._pos4+14]=t;}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(t){this._structArray.float32[this._pos4+18]=t;}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}}Qa.prototype.size=80;class to extends Fa{get(t){return new Qa(this,t)}}os(to,"SymbolInstanceArray");class eo extends Oa{getoffsetX(t){return this.float32[1*t+0]}}os(eo,"GlyphOffsetArray");class ro extends xa{getx(t){return this.int16[2*t+0]}gety(t){return this.int16[2*t+1]}}os(ro,"SymbolLineVertexArray");class no extends da{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]}}no.prototype.size=12;class io extends Na{get(t){return new no(this,t)}}os(io,"FeatureIndexArray");class so extends Ea{geta_centroid_pos0(t){return this.uint16[2*t+0]}geta_centroid_pos1(t){return this.uint16[2*t+1]}}os(so,"FillExtrusionCentroidArray");class ao extends da{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]}}ao.prototype.size=6;class oo extends ba{get(t){return new ao(this,t)}}os(oo,"FillExtrusionWallArray");const lo=ya([{name:"a_pos",components:2,type:"Int16"}],4),uo=ya([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class co{constructor(t=[]){this.segments=t;}_prepareSegment(t,e,r,n){let i=this.segments[this.segments.length-1];return t>co.MAX_VERTEX_ARRAY_LENGTH&&ft(`Max vertices per segment is ${co.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!i||i.vertexLength+t>co.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==n)&&(i={vertexOffset:e,primitiveOffset:r,vertexLength:0,primitiveLength:0},void 0!==n&&(i.sortKey=n),this.segments.push(i)),i}prepareSegment(t,e,r,n){return this._prepareSegment(t,e.length,r.length,n)}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy();}static simpleSegment(t,e,r,n){return new co([{vertexOffset:t,primitiveOffset:e,vertexLength:r,primitiveLength:n,vaos:{},sortKey:0}])}}function ho(t,e){return 256*(t=Q(Math.floor(t),0,255))+Q(Math.floor(e),0,255)}co.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,os(co,"SegmentVector");const po=ya([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),fo=ya([{name:"a_dash",components:4,type:"Uint16"}]);class mo{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1;}add(t,e,r,n){this.ids.push(yo(t)),this.positions.push(e,r,n);}eachPosition(t,e){const r=yo(t);let n=0,i=this.ids.length-1;for(;n>1;this.ids[t]>=r?i=t:n=t+1;}for(;this.ids[n]===r;)e(this.positions[3*n],this.positions[3*n+1],this.positions[3*n+2]),n++;}static serialize(t,e){const r=new Float64Array(t.ids),n=new Uint32Array(t.positions);return go(r,n,0,r.length-1),e&&(e.add(r.buffer),e.add(n.buffer)),{ids:r,positions:n}}static deserialize(t){const e=new mo;let r;e.ids=t.ids,e.positions=t.positions;for(const t of e.ids)t!==r&&e.uniqueIds.push(t),r=t;return e.indexed=!0,e}}function yo(t){const e=+t;return !isNaN(e)&&Number.MIN_SAFE_INTEGER<=e&&e<=Number.MAX_SAFE_INTEGER?e:xe(String(t))}function go(t,e,r,n){for(;r>1];let s=r-1,a=n+1;for(;;){do{s++;}while(t[s]i);if(s>=a)break;xo(t,s,a),xo(e,3*s,3*a),xo(e,3*s+1,3*a+1),xo(e,3*s+2,3*a+2);}a-r`u_${t}`)),this.type=r,this.context=n;}setUniform(t,e,r,n,i){const s=n.constantOr(this.value);e.set(t,i,s instanceof Pe?s.toRenderColor(this.context.lut):s);}getBinding(t,e){return "color"===this.type?new So(t):new wo(t)}}class Vo{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.pattern=null,this.pixelRatio=1;}setConstantPatternPositions(t){this.pixelRatio=t.pixelRatio||1,this.pattern=t.tl.concat(t.br);}setUniform(t,e,r,n,i){const s="u_pattern"===i||"u_dash"===i?this.pattern:"u_pixel_ratio"===i?this.pixelRatio:null;s&&e.set(t,i,s);}getBinding(t,e){return "u_pattern"===e||"u_dash"===e?new Ao(t):new wo(t)}}class Co{constructor(t,e,r,n){this.expression=t,this.type=r,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?2:1,offset:0}))),this.paintVertexArray=new n;}populatePaintArray(t,e,r,n,i,s,a){const o=this.paintVertexArray.length,l=this.expression.evaluate(new Vs(0,{brightness:s}),e,{},i,n,a);this.paintVertexArray.resize(t),this._setPaintValue(o,t,l,this.context);}updatePaintArray(t,e,r,n,i,s,a){const o=this.expression.evaluate({zoom:0,brightness:a},r,n,void 0,i);this._setPaintValue(t,e,o,this.context);}_setPaintValue(t,e,r,n){if("color"===this.type){const i=Eo(r.toRenderColor(n.lut));for(let r=t;r`u_${t}_t`)),this.type=r,this.useIntegerZoom=n,this.context=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?4:2,offset:0}))),this.paintVertexArray=new s;}populatePaintArray(t,e,r,n,i,s,a){const o=this.expression.evaluate(new Vs(this.context.zoom,{brightness:s}),e,{},i,n,a),l=this.expression.evaluate(new Vs(this.context.zoom+1,{brightness:s}),e,{},i,n,a),u=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(u,t,o,l,this.context);}updatePaintArray(t,e,r,n,i,s,a){const o=this.expression.evaluate({zoom:this.context.zoom,brightness:a},r,n,void 0,i),l=this.expression.evaluate({zoom:this.context.zoom+1,brightness:a},r,n,void 0,i);this._setPaintValue(t,e,o,l,this.context);}_setPaintValue(t,e,r,n,i){if("color"===this.type){const n=Eo(r.toRenderColor(i.lut)),s=Eo(r.toRenderColor(i.lut));for(let r=t;r!0)){this.binders={},this._buffers=[],this.context=e;const n=[];for(const i in t.paint._values){const s=t.paint.get(i);if(!r(i))continue;if(!(s instanceof Us&&Di(s.property.specification)))continue;const a=Uo(i,t.type),o=s.value,l=s.property.specification.type,u=!!s.property.useIntegerZoom,c="line-dasharray"===i||i.endsWith("pattern"),h="line-dasharray"===i&&"constant"!==t.layout.get("line-cap").value.kind;if("constant"!==o.kind||h)if("source"===o.kind||h||c){const e=qo(i,l,"source");this.binders[i]=c?new Do(o,a,l,e,t.id):new Co(o,a,l,e),n.push(`/a_${i}`);}else {const t=qo(i,l,"composite");this.binders[i]=new Ro(o,a,l,u,e,t),n.push(`/z_${i}`);}else this.binders[i]=c?new Vo(o.value,a):new Bo(o.value,a,l,e),n.push(`/u_${i}`);}this.cacheKey=n.sort().join("");}getMaxValue(t){const e=this.binders[t];return e instanceof Co||e instanceof Ro?e.maxValue:0}populatePaintArrays(t,e,r,n,i,s,a){for(const o in this.binders){const l=this.binders[o];l.context=this.context,(l instanceof Co||l instanceof Ro||l instanceof Do)&&l.populatePaintArray(t,e,r,n,i,s,a);}}setConstantPatternPositions(t){for(const e in this.binders){const r=this.binders[e];r instanceof Vo&&r.setConstantPatternPositions(t);}}updatePaintArrays(t,e,r,n,i,s,a,o){let l=!1;const u=Object.keys(t),c=0!==u.length,h=c?u:e.uniqueIds;this.context.lut=i.lut;for(const u in this.binders){const p=this.binders[u];if(p.context=this.context,(p instanceof Co||p instanceof Ro||p instanceof Do)&&(!0===p.expression.isStateDependent||!1===p.expression.isLightConstant)){const f=i.paint.get(u);p.expression=f.value;for(const r of h){const i=t[r.toString()];e.eachPosition(r,((t,e,r)=>{const l=n.feature(t);p.updatePaintArray(e,r,l,i,s,a,o);}));}if(!c)for(const e of r.uniqueIds){const i=t[e.toString()];r.eachPosition(e,((t,e,r)=>{const l=n.feature(t);p.updatePaintArray(e,r,l,i,s,a,o);}));}l=!0;}}return l}defines(){const t=[];for(const e in this.binders){const r=this.binders[e];(r instanceof Bo||r instanceof Vo)&&t.push(...r.uniformNames.map((t=>`#define HAS_UNIFORM_${t}`)));}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const r=this.binders[e];if(r instanceof Co||r instanceof Ro||r instanceof Do)for(let e=0;e!0)){this.programConfigurations={};for(const n of t)this.programConfigurations[n.id]=new Lo(n,e,r);this.needsUpload=!1,this._featureMap=new mo,this._featureMapWithoutIds=new mo,this._bufferOffset=0,this._idlessCounter=0;}populatePaintArrays(t,e,r,n,i,s,a,o){for(const r in this.programConfigurations)this.programConfigurations[r].populatePaintArrays(t,e,n,i,s,a,o);void 0!==e.id?this._featureMap.add(e.id,r,this._bufferOffset,t):(this._featureMapWithoutIds.add(this._idlessCounter,r,this._bufferOffset,t),this._idlessCounter+=1),this._bufferOffset=t,this.needsUpload=!0;}updatePaintArrays(t,e,r,n,i,s){for(const a of r)this.needsUpload=this.programConfigurations[a.id].updatePaintArrays(t,this._featureMap,this._featureMapWithoutIds,e,a,n,i,s||0)||this.needsUpload;}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1;}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy();}}const Oo={"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"],"fill-pattern":["pattern","pixel_ratio"],"fill-extrusion-pattern":["pattern","pixel_ratio"],"line-dasharray":["dash"]};function Uo(t,e){return Oo[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}const jo={"line-pattern":{source:Sa,composite:Sa},"fill-pattern":{source:Sa,composite:Sa},"fill-extrusion-pattern":{source:Sa,composite:Sa},"line-dasharray":{source:Ia,composite:Ia}},No={color:{source:$a,composite:Ma},number:{source:Oa,composite:$a}};function qo(t,e,r){const n=jo[t];return n&&n[r]||No[e][r]}os(Bo,"ConstantBinder"),os(Vo,"PatternConstantBinder"),os(Co,"SourceExpressionBinder"),os(Do,"PatternCompositeBinder"),os(Ro,"CompositeExpressionBinder"),os(Lo,"ProgramConfiguration",{omit:["_buffers"]}),os(Fo,"ProgramConfigurationSet");const $o=Hr/Math.PI/2,Go=5,Xo=6,Yo=16383,Zo=64,Wo=[Zo,32,16],Ho=-$o,Ko=$o;function Jo(t,e,r,n=$o){return r=Y(r),[t*Math.sin(r)*n,-e*n,t*Math.cos(r)*n]}function Qo(t,e,r){return Jo(Math.cos(Y(t)),Math.sin(Y(t)),e,r)}const tl=6371008.8,el=2*Math.PI*tl;class rl{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new rl(et(this.lng,-180,180),this.lat)}toArray(){return [this.lng,this.lat]}toString(){return `LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,r=this.lat*e,n=t.lat*e,i=Math.sin(r)*Math.sin(n)+Math.cos(r)*Math.cos(n)*Math.cos((t.lng-this.lng)*e);return tl*Math.acos(Math.min(i,1))}toBounds(t=0){const e=360*t/40075017,r=e/Math.cos(Math.PI/180*this.lat);return new nl({lng:this.lng-r,lat:this.lat-e},{lng:this.lng+r,lat:this.lat+e})}toEcef(t){return Qo(this.lat,this.lng,$o+t*$o/tl)}static convert(t){if(t instanceof rl)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new rl(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new rl(Number("lng"in t?t.lng:t.lon),Number(t.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 nl{constructor(t,e){if(t)if(e)this.setSouthWest(t).setNorthEast(e);else if(4===t.length){const e=t;this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]);}else {const e=t;this.setSouthWest(e[0]).setNorthEast(e[1]);}}setNorthEast(t){return this._ne=t instanceof rl?new rl(t.lng,t.lat):rl.convert(t),this}setSouthWest(t){return this._sw=t instanceof rl?new rl(t.lng,t.lat):rl.convert(t),this}extend(t){const e=this._sw,r=this._ne;let n,i;if(t instanceof rl)n=t,i=t;else {if(!(t instanceof nl))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(nl.convert(t)):this.extend(rl.convert(t)):"object"==typeof t&&null!==t&&t.hasOwnProperty("lat")&&(t.hasOwnProperty("lon")||t.hasOwnProperty("lng"))?this.extend(rl.convert(t)):this;if(n=t._sw,i=t._ne,!n||!i)return this}return e||r?(e.lng=Math.min(n.lng,e.lng),e.lat=Math.min(n.lat,e.lat),r.lng=Math.max(i.lng,r.lng),r.lat=Math.max(i.lat,r.lat)):(this._sw=new rl(n.lng,n.lat),this._ne=new rl(i.lng,i.lat)),this}getCenter(){return new rl((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 rl(this.getWest(),this.getNorth())}getSouthEast(){return new rl(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return [this._sw.toArray(),this._ne.toArray()]}toString(){return `LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return !(this._sw&&this._ne)}contains(t){const{lng:e,lat:r}=rl.convert(t);let n=this._sw.lng<=e&&e<=this._ne.lng;return this._sw.lng>this._ne.lng&&(n=this._sw.lng>=e&&e>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&n}static convert(t){if(t)return t instanceof nl?t:new nl(t)}}const il=0,sl=25.5;function al(t){return el*Math.cos(t*Math.PI/180)}function ol(t){return (180+t)/360}function ll(t){return (180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function ul(t,e){return t/al(e)}function cl(t){return 360*t-180}function hl(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function pl(t,e){return t*al(hl(e))}const fl=85.051129;function dl(t){return Math.cos(Y(Q(t,-fl,fl)))}function ml(t,e){const r=Q(e,il,sl),n=Math.pow(2,r);return dl(t)*el/(512*n)}function yl(t){return 1/Math.cos(t*Math.PI/180)}function gl(t,e=0){const r=Math.exp(Math.PI*(1-(t.y+e/Hr)/(1<=l?(bl(t,e,r,u,c,s,h,o,l),bl(t,u,c,n,i,h,a,o,l)):t.push(a);}function vl(t,e,r){let n=t[0],i=n.x,s=n.y;e(n);const a=[n];for(let o=1;ot.x+1||nt.y+1)&&ft("Geometry exceeds allowed extent, reduce your vector tile buffer size"),t}function Il(t,e,r){const n=t.loadGeometry(),i=t.extent,s=Hr/i;if(e&&r&&r.projection.isReprojectedInTileSpace){const s=1<{const r=cl((e.x+t.x/i)/s),n=hl((e.y+t.y/i)/s),c=u.project(r,n);t.x=(c.x*a-o)*i,t.y=(c.y*a-l)*i;};for(let e=0;e=i||r.y<0||r.y>=i||(c(r),t.push(r));n[e]=t;}}for(const t of n)for(const e of t)Sl(e,s);return n}function Pl(t,e){return {type:t.type,id:t.id,properties:t.properties,geometry:e?Il(t):[]}}function zl(t,e,r,n,i){t.emplaceBack(2*e+(n+1)/2,2*r+(i+1)/2);}function kl(t,e,r){const n=16384;t.emplaceBack(e.x,e.y,e.z,r[0]*n,r[1]*n,r[2]*n);}class Tl{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new xa,this.indexArray=new Da,this.segments=new co,this.programConfigurations=new Fo(t.layers,{zoom:t.zoom,lut:t.lut}),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}updateFootprints(t,e){}populate(t,e,r,n){const i=this.layers[0],s=[];let a=null;"circle"===i.type&&(a=i.layout.get("circle-sort-key"));for(const{feature:e,id:i,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=Pl(e,t);if(!this.layers[0]._featureFilter.filter(new Vs(this.zoom),u,r))continue;const c=a?a.evaluate(u,{},r):void 0,h={id:i,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?u.geometry:Il(e,r,n),patterns:{},sortKey:c};s.push(h);}a&&s.sort(((t,e)=>t.sortKey-e.sortKey));let o=null;"globe"===n.projection.name&&(this.globeExtVertexArray=new Pa,o=n.projection);for(const n of s){const{geometry:i,index:s,sourceLayerIndex:a}=n,l=t[s].feature;this.addFeature(n,i,s,e.availableImages,r,o,e.brightness),e.featureIndex.insert(l,i,s,a,this.index);}}update(t,e,r,n,i){const s=0!==Object.keys(t).length;s&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,s?this.stateDependentLayers:this.layers,r,n,i);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,lo.members),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,uo.members))),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy());}addFeature(t,e,r,n,i,s,a){for(const r of e)for(const e of r){const r=e.x,n=e.y;if(r<0||r>=Hr||n<0||n>=Hr)continue;if(s){const t=s.projectTilePoint(r,n,i),e=s.upVector(i,r,n),a=this.globeExtVertexArray;kl(a,t,e),kl(a,t,e),kl(a,t,e),kl(a,t,e);}const a=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),o=a.vertexLength;zl(this.layoutVertexArray,r,n,-1,-1),zl(this.layoutVertexArray,r,n,1,-1),zl(this.layoutVertexArray,r,n,1,1),zl(this.layoutVertexArray,r,n,-1,1),this.indexArray.emplaceBack(o,o+1,o+2),this.indexArray.emplaceBack(o,o+2,o+3),a.vertexLength+=4,a.primitiveLength+=2;}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,{},n,i,a);}}function El(t,e){for(let r=0;r1){if(Rl(t,e))return !0;for(let n=0;n1?r:r.sub(e)._mult(i)._add(e))}function Ol(t,e){let r,n,i,s=!1;for(let a=0;ae.y!=i.y>e.y&&e.x<(i.x-n.x)*(e.y-n.y)/(i.y-n.y)+n.x&&(s=!s);}return s}function Ul(t,e){let r=!1;for(let n=0,i=t.length-1;ne.y!=a.y>e.y&&e.x<(a.x-s.x)*(e.y-s.y)/(a.y-s.y)+s.x&&(r=!r);}return r}function jl(t,e,r,n,i){for(const s of t)if(e<=s.x&&r<=s.y&&n>=s.x&&i>=s.y)return !0;const s=[new q(e,r),new q(e,i),new q(n,i),new q(n,r)];if(t.length>2)for(const e of s)if(Ul(t,e))return !0;for(let e=0;ei.x&&e.x>i.x||t.yi.y&&e.y>i.y)return !1;const s=dt(t,e,r[0]);return s!==dt(t,e,r[1])||s!==dt(t,e,r[2])||s!==dt(t,e,r[3])}function ql(t,e,r,n,i,s){let a=e.y-t.y,o=t.x-e.x;if(s=s||0){const t=a*a+o*o;if(0===t)return !0;const e=Math.sqrt(t);a/=e,o/=e;}return !((r.x-t.x)*a+(r.y-t.y)*o-s<0||(n.x-t.x)*a+(n.y-t.y)*o-s<0||(i.x-t.x)*a+(i.y-t.y)*o-s<0)}function $l(t,e,r,n,i,s,a){return !(ql(t,e,n,i,s,a)||ql(e,r,n,i,s,a)||ql(r,t,n,i,s,a)||ql(n,i,t,e,r,a)||ql(i,s,t,e,r,a)||ql(s,n,t,e,r,a))}function Gl(t,e,r){const n=e.paint.get(t).value;return "constant"===n.kind?n.value:r.programConfigurations.get(e.id).getMaxValue(t)}function Xl(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Yl(t,e,r,n,i){if(!e[0]&&!e[1])return t;const s=q.convert(e)._mult(i);"viewport"===r&&s._rotate(-n);const a=[];for(let e=0;e0;s--)n=1<this.canonical.z?new ru(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new ru(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e=!0){if(this.overscaledZ===t&&e)return this.key;if(t>this.canonical.z)return nu(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y);{const r=this.canonical.z-t;return nu(this.wrap*+e,t,t,this.canonical.x>>r,this.canonical.y>>r)}}isChildOf(t){if(t.wrap!==this.wrap)return !1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return [new ru(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,r=2*this.canonical.x,n=2*this.canonical.y;return [new ru(e,this.wrap,e,r,n),new ru(e,this.wrap,e,r+1,n),new ru(e,this.wrap,e,r,n+1),new ru(e,this.wrap,e,r+1,n+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.y{let e=t.canonical.x-1,r=t.wrap;return e<0&&(e=(1<{let e=t.canonical.x+1,r=t.wrap;return e===1<new ru(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,(0===t.canonical.y?1<new ru(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y===(1<=0;if(0===s)return 0;s!==e.length&&(r=!1);}return r?2:1}function fu(t,e){for(const r of t.projections){const n=hu(e,t.points[0],r.axis);if(r.projection[1]n[1])return 0}return 1}function du(t,e){let r=0;const n=[0,0,0,0];for(let i=0;i=0&&r++;return r}class mu{constructor(t,e){this.points=t||new Array(8).fill([0,0,0]),this.planes=e||new Array(6).fill([0,0,0,0]),this.bounds=yu.fromPoints(this.points),this.projections=[],this.frustumEdges=[O.vec3.sub([],this.points[2],this.points[3]),O.vec3.sub([],this.points[0],this.points[3]),O.vec3.sub([],this.points[4],this.points[0]),O.vec3.sub([],this.points[5],this.points[1]),O.vec3.sub([],this.points[6],this.points[2]),O.vec3.sub([],this.points[7],this.points[3])];for(const t of this.frustumEdges){const e=[0,-t[2],t[1]],r=[t[2],0,-t[0]];this.projections.push({axis:e,projection:hu(this.points,this.points[0],e)}),this.projections.push({axis:r,projection:hu(this.points,this.points[0],r)});}}static fromInvProjectionMatrix(t,e,r,n){const i=Math.pow(2,r),s=[[-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=>{const s=O.vec4.transformMat4([],r,t),a=1/s[3]/e*i;return O.vec4.mul(s,s,[a,a,n?1/s[3]:a,a])})),a=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((t=>{const e=O.vec3.sub([],s[t[0]],s[t[1]]),r=O.vec3.sub([],s[t[2]],s[t[1]]),n=O.vec3.normalize([],O.vec3.cross([],e,r)),i=-O.vec3.dot(n,s[t[1]]);return n.concat(i)})),o=[];for(let t=0;ta[1]||a[0]>s[1])return 0}return 1}containsPoint(t){for(const e of this.planes){const r=e[3];if(O.vec3.dot([e[0],e[1],e[2]],t)+r<0)return !1}return !0}}class yu{static fromPoints(t){const e=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0];for(const n of t)O.vec3.min(e,e,n),O.vec3.max(r,r,n);return new yu(e,r)}static fromTileIdAndHeight(t,e,r){const n=1<t.max[e]||t.min[e]>this.max[e])return !1;return !0}intersectsAabbXY(t){return !(this.min[0]>t.max[0]||t.min[0]>this.max[0]||this.min[1]>t.max[1]||t.min[1]>this.max[1])}encapsulate(t){for(let e=0;e<3;e++)this.min[e]=Math.min(this.min[e],t.min[e]),this.max[e]=Math.max(this.max[e],t.max[e]);}encapsulatePoint(t){for(let e=0;e<3;e++)this.min[e]=Math.min(this.min[e],t[e]),this.max[e]=Math.max(this.max[e],t[e]);}closestPoint(t){return [Math.max(Math.min(this.max[0],t[0]),this.min[0]),Math.max(Math.min(this.max[1],t[1]),this.min[1]),Math.max(Math.min(this.max[2],t[2]),this.min[2])]}}function gu(t){return t*$o/tl}os(yu,"Aabb");const xu=[new yu([Ho,Ho,Ho],[Ko,Ko,Ko]),new yu([Ho,Ho,Ho],[0,0,Ko]),new yu([0,Ho,Ho],[Ko,0,Ko]),new yu([Ho,0,Ho],[0,Ko,Ko]),new yu([0,0,Ho],[Ko,Ko,Ko])];function bu(t,e,r,n=!0){const i=O.vec3.scale([],t._camera.position,t.worldSize),s=[e,r,1,1];O.vec4.transformMat4(s,s,t.pixelMatrixInverse),O.vec4.scale(s,s,1/s[3]);const a=O.vec3.sub([],s,i),o=O.vec3.normalize([],a),l=t.globeMatrix,u=[l[12],l[13],l[14]],c=O.vec3.sub([],u,i),h=O.vec3.length(c),p=O.vec3.normalize([],c),f=t.worldSize/(2*Math.PI),d=O.vec3.dot(p,o),m=Math.asin(f/h);if(m1?null:function(t,e,r,n){const i=Math.sin(r);return t*(Math.sin((1-n)*r)/i)+e*(Math.sin(n*r)/i)}(t.a[e],t.b[e],t.angle,Q(r,0,1))+t.center[e]}function _u(t){if(t.z<=1)return xu[t.z+2*t.y+t.x];const e=Pu(Iu(t));return yu.fromPoints(e)}function Mu(t,e,r){return O.vec3.scale(t,t,1-r),O.vec3.scaleAndAdd(t,t,e,r)}function Au(t,e,r){for(const n of t)O.vec3.transformMat4(n,n,e),O.vec3.scale(n,n,r);}function Su(t,e,r,n){const i=e/t.worldSize,s=t.globeMatrix;if(r.z<=1){const t=_u(r).getCorners();return Au(t,s,i),yu.fromPoints(t)}const a=Iu(r,n),o=Pu(a,$o+gu(t._tileCoverLift));Au(o,s,i);const l=Number.MAX_VALUE,u=[-l,-l,-l],c=[l,l,l];if(a.contains(t.center)){for(const t of o)O.vec3.min(c,c,t),O.vec3.max(u,u,t);u[2]=0;const e=t.point,r=[e.x*i,e.y*i,0];return O.vec3.min(c,c,r),O.vec3.max(u,u,r),new yu(c,u)}if(t._tileCoverLift>0){for(const t of o)O.vec3.min(c,c,t),O.vec3.max(u,u,t);return new yu(c,u)}const h=[s[12]*i,s[13]*i,s[14]*i],p=a.getCenter(),f=Q(t.center.lat,-fl,fl),d=Q(p.lat,-fl,fl),m=ol(t.center.lng),y=ll(f);let g=m-ol(p.lng);const x=y-ll(d);g>.5?g-=1:g<-.5&&(g+=1);let b=0;if(Math.abs(g)>Math.abs(x))b=g>=0?1:3;else {b=x>=0?0:2;const t=[s[4]*i,s[5]*i,s[6]*i],e=-Math.sin(Y(x>=0?a.getSouth():a.getNorth()))*$o;O.vec3.scaleAndAdd(h,h,t,e);}const v=o[b],w=o[(b+1)%4],_=new vu(v,w,h),M=[wu(_,0)||v[0],wu(_,1)||v[1],wu(_,2)||v[2]],A=Du(t.zoom);if(A>0){const n=function({x:t,y:e,z:r},n,i,s,a){const o=1/(1<.5?p=-1:f<-.5&&(p=1),l=((l+p)*n-(s*=n))*i+s,u=((u+p)*n-s)*i+s,c=(c*n-(a*=n))*i+a,h=(h*n-a)*i+a,[[l,h,0],[u,h,0],[u,c,0],[l,c,0]]}(r,e,t._pixelsPerMercatorPixel,m,y);for(let t=0;tMath.PI/2*1.01}const Ou=Y(85),Uu=Math.cos(Ou),ju=Math.sin(Ou),Nu=O.mat4.create(),qu=t=>{const e=[];return "map"===t.paint.get("circle-pitch-alignment")&&e.push("PITCH_WITH_MAP"),"map"===t.paint.get("circle-pitch-scale")&&e.push("SCALE_WITH_MAP"),e};function $u(t,e,r,n,i,s,a,o,l){if(s&&t.queryGeometry.isAboveHorizon)return !1;s&&(l*=t.pixelToTileUnitsFactor);const u=t.tileID.canonical,c=r.projection.upVectorScale(u,r.center.lat,r.worldSize).metersToTile;for(const h of e)for(const e of h){const h=e.add(o),p=i&&r.elevation?r.elevation.exaggeration()*i.getElevationAt(h.x,h.y,!0):0,f=r.projection.projectTilePoint(h.x,h.y,u);if(p>0){const t=r.projection.upVector(u,h.x,h.y);f.x+=t[0]*c*p,f.y+=t[1]*c*p,f.z+=t[2]*c*p;}const d=s?h:Gu(f.x,f.y,f.z,n),m=s?t.tilespaceRays.map((t=>Zu(t,p))):t.queryGeometry.screenGeometry,y=O.vec4.transformMat4([],[f.x,f.y,f.z,1],n);if(!a&&s?l*=y[3]/r.cameraToCenterDistance:a&&!s&&(l*=r.cameraToCenterDistance/y[3]),s){const t=hl((e.y/Hr+u.y)/(1<t.width||i.height>t.height||r.x>t.width-i.width||r.y>t.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw new RangeError("out of range destination coordinates for image copy");const l=t.data,u=e.data,c=4===s&&o;for(let o=0;o{e[t.evaluationKey]=s;const a=t.expression.evaluate(e);a&&(i.data[r+n+0]=Math.floor(255*a.r/a.a),i.data[r+n+1]=Math.floor(255*a.g/a.a),i.data[r+n+2]=Math.floor(255*a.b/a.a),i.data[r+n+3]=Math.floor(255*a.a));};if(t.clips)for(let e=0,i=0;e80*r){o=1/0,l=1/0;let e=-1/0,n=-1/0;for(let s=r;se&&(e=r),i>n&&(n=i);}u=Math.max(e-o,n-l),u=0!==u?32767/u:0;}return pc(s,a,r,o,l,u,0),a}function cc(t,e,r,n,i){let s;if(i===function(t,e,r,n){let i=0;for(let s=e,a=r-n;s0)for(let i=e;i=e;i-=n)s=Ec(i/n|0,t[i],t[i+1],s);return s&&Sc(s,s.next)&&(Bc(s),s=s.next),s}function hc(t,e){if(!t)return t;e||(e=t);let r,n=t;do{if(r=!1,n.steiner||!Sc(n,n.next)&&0!==Ac(n.prev,n,n.next))n=n.next;else {if(Bc(n),n=e=n.prev,n===n.next)break;r=!0;}}while(r||n!==e);return e}function pc(t,e,r,n,i,s,a){if(!t)return;!a&&s&&function(t,e,r,n){let i=t;do{0===i.z&&(i.z=vc(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){let e,r=1;do{let n,i=t;t=null;let s=null;for(e=0;i;){e++;let a=i,o=0;for(let t=0;t0||l>0&&a;)0!==o&&(0===l||!a||i.z<=a.z)?(n=i,i=i.nextZ,o--):(n=a,a=a.nextZ,l--),s?s.nextZ=n:t=n,n.prevZ=s,s=n;i=a;}s.nextZ=null,r*=2;}while(e>1)}(i);}(t,n,i,s);let o=t;for(;t.prev!==t.next;){const l=t.prev,u=t.next;if(s?dc(t,n,i,s):fc(t))e.push(l.i,t.i,u.i),Bc(t),t=u.next,o=u.next;else if((t=u)===o){a?1===a?pc(t=mc(hc(t),e),e,r,n,i,s,2):2===a&&yc(t,e,r,n,i,s):pc(hc(t),e,r,n,i,s,1);break}}}function fc(t){const e=t.prev,r=t,n=t.next;if(Ac(e,r,n)>=0)return !1;const i=e.x,s=r.x,a=n.x,o=e.y,l=r.y,u=n.y,c=is?i>a?i:a:s>a?s:a,f=o>l?o>u?o:u:l>u?l:u;let d=n.next;for(;d!==e;){if(d.x>=c&&d.x<=p&&d.y>=h&&d.y<=f&&_c(i,o,s,l,a,u,d.x,d.y)&&Ac(d.prev,d,d.next)>=0)return !1;d=d.next;}return !0}function dc(t,e,r,n){const i=t.prev,s=t,a=t.next;if(Ac(i,s,a)>=0)return !1;const o=i.x,l=s.x,u=a.x,c=i.y,h=s.y,p=a.y,f=ol?o>u?o:u:l>u?l:u,y=c>h?c>p?c:p:h>p?h:p,g=vc(f,d,e,r,n),x=vc(m,y,e,r,n);let b=t.prevZ,v=t.nextZ;for(;b&&b.z>=g&&v&&v.z<=x;){if(b.x>=f&&b.x<=m&&b.y>=d&&b.y<=y&&b!==i&&b!==a&&_c(o,c,l,h,u,p,b.x,b.y)&&Ac(b.prev,b,b.next)>=0)return !1;if(b=b.prevZ,v.x>=f&&v.x<=m&&v.y>=d&&v.y<=y&&v!==i&&v!==a&&_c(o,c,l,h,u,p,v.x,v.y)&&Ac(v.prev,v,v.next)>=0)return !1;v=v.nextZ;}for(;b&&b.z>=g;){if(b.x>=f&&b.x<=m&&b.y>=d&&b.y<=y&&b!==i&&b!==a&&_c(o,c,l,h,u,p,b.x,b.y)&&Ac(b.prev,b,b.next)>=0)return !1;b=b.prevZ;}for(;v&&v.z<=x;){if(v.x>=f&&v.x<=m&&v.y>=d&&v.y<=y&&v!==i&&v!==a&&_c(o,c,l,h,u,p,v.x,v.y)&&Ac(v.prev,v,v.next)>=0)return !1;v=v.nextZ;}return !0}function mc(t,e){let r=t;do{const n=r.prev,i=r.next.next;!Sc(n,i)&&Ic(n,r,r.next,i)&&kc(n,i)&&kc(i,n)&&(e.push(n.i,r.i,i.i),Bc(r),Bc(r.next),r=t=i),r=r.next;}while(r!==t);return hc(r)}function yc(t,e,r,n,i,s){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.i!==t.i&&Mc(a,t)){let o=Tc(a,t);return a=hc(a,a.next),o=hc(o,o.next),pc(a,e,r,n,i,s,0),void pc(o,e,r,n,i,s,0)}t=t.next;}a=a.next;}while(a!==t)}function gc(t,e){return t.x-e.x}function xc(t,e){const r=function(t,e){let r=e;const n=t.x,i=t.y;let s,a=-1/0;do{if(i<=r.y&&i>=r.next.y&&r.next.y!==r.y){const t=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(t<=n&&t>a&&(a=t,s=r.x=r.x&&r.x>=l&&n!==r.x&&_c(is.x||r.x===s.x&&bc(s,r)))&&(s=r,c=e);}r=r.next;}while(r!==o);return s}(t,e);if(!r)return e;const n=Tc(r,t);return hc(n,n.next),hc(r,r.next)}function bc(t,e){return Ac(t.prev,t,e.prev)<0&&Ac(e.next,t,t.next)<0}function vc(t,e,r,n,i){return (t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function wc(t){let e=t,r=t;do{(e.x=(t-a)*(s-o)&&(t-a)*(n-o)>=(r-a)*(e-o)&&(r-a)*(s-o)>=(i-a)*(n-o)}function Mc(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&Ic(r,r.next,t,e))return !0;r=r.next;}while(r!==t);return !1}(t,e)&&(kc(t,e)&&kc(e,t)&&function(t,e){let r=t,n=!1;const i=(t.x+e.x)/2,s=(t.y+e.y)/2;do{r.y>s!=r.next.y>s&&r.next.y!==r.y&&i<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next;}while(r!==t);return n}(t,e)&&(Ac(t.prev,t,e.prev)||Ac(t,e.prev,e))||Sc(t,e)&&Ac(t.prev,t,t.next)>0&&Ac(e.prev,e,e.next)>0)}function Ac(t,e,r){return (e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function Sc(t,e){return t.x===e.x&&t.y===e.y}function Ic(t,e,r,n){const i=zc(Ac(t,e,r)),s=zc(Ac(t,e,n)),a=zc(Ac(r,n,t)),o=zc(Ac(r,n,e));return i!==s&&a!==o||!(0!==i||!Pc(t,r,e))||!(0!==s||!Pc(t,n,e))||!(0!==a||!Pc(r,t,n))||!(0!==o||!Pc(r,e,n))}function Pc(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function zc(t){return t>0?1:t<0?-1:0}function kc(t,e){return Ac(t.prev,t,t.next)<0?Ac(t,e,t.next)>=0&&Ac(t,t.prev,e)>=0:Ac(t,e,t.prev)<0||Ac(t,t.next,e)<0}function Tc(t,e){const r=Vc(t.i,t.x,t.y),n=Vc(e.i,e.x,e.y),i=t.next,s=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,s.next=n,n.prev=s,n}function Ec(t,e,r,n){const i=Vc(t,e,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Bc(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ);}function Vc(t,e,r){return {i:t,x:e,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Cc(t,e){const r=t.length;if(r<=1)return [t];const n=[];let i,s;for(let e=0;e1)for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new xa,this.indexArray=new Da,this.indexArray2=new Ea,this.programConfigurations=new Fo(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new co,this.segments2=new co,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.projection=t.projection;}updateFootprints(t,e){}populate(t,e,r,n){this.hasPattern=Dc("fill",this.layers,e);const i=this.layers[0].layout.get("fill-sort-key"),s=[];for(const{feature:a,id:o,index:l,sourceLayerIndex:u}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Pl(a,t);if(!this.layers[0]._featureFilter.filter(new Vs(this.zoom),c,r))continue;const h=i?i.evaluate(c,{},r,e.availableImages):void 0,p={id:o,properties:a.properties,type:a.type,sourceLayerIndex:u,index:l,geometry:t?c.geometry:Il(a,r,n),patterns:{},sortKey:h};s.push(p);}i&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of s){const{geometry:i,index:s,sourceLayerIndex:a}=n;if(this.hasPattern){const t=Lc("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t);}else this.addFeature(n,i,s,r,{},e.availableImages,e.brightness);e.featureIndex.insert(t[s].feature,i,s,a,this.index);}}update(t,e,r,n,i){const s=0!==Object.keys(t).length;s&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,s?this.stateDependentLayers:this.layers,r,n,i);}addFeatures(t,e,r,n,i,s){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,r,n,s);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,lc),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy());}addFeature(t,e,r,n,i,s=[],a){for(const t of Cc(e,500)){let e=0;for(const r of t)e+=r.length;const r=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),n=r.vertexLength,i=[],s=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&s.push(i.length/2);const r=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),n=r.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(n+e.length-1,n),i.push(e[0].x),i.push(e[0].y);for(let t=1;tt.cellIdx-e.cellIdx||t.triIdx-e.triIdx));let u=0;for(;uthis.max.x||this.min.x>t.x||t.y>this.max.y||this.min.y>t.y)return;const r=$c(t.x-this.min.x,this.xScale,this.cellsX),n=$c(t.y-this.min.y,this.yScale,this.cellsY),i=this.cells[n*this.cellsX+r];if(i){this._lazyInitLookup();for(let t=0;tthis.max.x||this.min.x>e.x)return;if(t.y>this.max.y||this.min.y>e.y)return;this._lazyInitLookup();const n=$c(t.x-this.min.x,this.xScale,this.cellsX),i=$c(e.x-this.min.x,this.xScale,this.cellsX),s=$c(t.y-this.min.y,this.yScale,this.cellsY),a=$c(e.y-this.min.y,this.yScale,this.cellsY);for(let t=s;t<=a;t++)for(let e=n;e<=i;e++){const n=this.cells[t*this.cellsX+e];if(n)for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.footprints=[];}updateFootprints(t,e){for(const r of this.footprints)e.push({footprint:r,id:t});}populate(t,e,r,n){const i=[];for(const{feature:e,id:s,index:a,sourceLayerIndex:o}of t){const t=this.layers[0]._featureFilter.needGeometry,l=Pl(e,t);if(!this.layers[0]._featureFilter.filter(new Vs(this.zoom),l,r))continue;const u={id:s,properties:e.properties,type:e.type,sourceLayerIndex:o,index:a,geometry:t?l.geometry:Il(e,r,n),patterns:{}};i.push(u);}for(const n of i){const{geometry:i,index:s,sourceLayerIndex:a}=n;this.addFeature(n,i,s,r,{},e.availableImages,e.brightness),e.featureIndex.insert(t[s].feature,i,s,a,this.index);}}isEmpty(){return 0===this.footprints.length}uploadPending(){return !1}upload(t){}update(t,e,r,n,i){}destroy(){}addFeature(t,e,r,n,i,s=[],a){for(const t of Cc(e,2)){const e=[],r=[],n=[],i=new q(1/0,1/0),s=new q(-1/0,-1/0);for(const a of t)if(0!==a.length){a!==t[0]&&n.push(r.length/2);for(let t=0;t>3;}if(s--,1===i||2===i)a+=e.readSVarint(),o+=e.readSVarint(),1===i&&(r&&l.push(r),r=[]),r.push(new t(a,o));else {if(7!==i)throw new Error("unknown command "+i);r&&r.push(r[0].clone());}}return r&&l.push(r),l},e.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,n=0,i=0,s=0,a=1/0,o=-1/0,l=1/0,u=-1/0;t.pos>3;}if(n--,1===r||2===r)(i+=t.readSVarint())o&&(o=i),(s+=t.readSVarint())u&&(u=s);else if(7!==r)throw new Error("unknown command "+r)}return [a,l,o,u]},e.prototype.toGeoJSON=function(t,r,i){var s,a,o=this.extent*Math.pow(2,i),l=this.extent*t,u=this.extent*r,c=this.loadGeometry(),h=e.types[this.type];function p(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null;}return e}(r));}return eh=e,e.prototype.feature=function(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var r=this._pbf.readVarint()+this._pbf.pos;return new t(this._pbf,r,this.extent,this._keys,this._values)},eh}function uh(){return sh||(sh=1,ah.VectorTile=function(){if(ih)return nh;ih=1;var t=lh();function e(e,r,n){if(3===e){var i=new t(n,n.readVarint()+n.pos);i.length&&(r[i.name]=i);}}return nh=function(t,r){this.layers=t.readFields(e,{},r);},nh}(),ah.VectorTileFeature=oh(),ah.VectorTileLayer=lh()),ah}var ch=uh();class hh extends q{constructor(t,e,r){super(t,e),this.z=r;}}class ph extends hh{constructor(t,e,r,n){super(t,e,r),this.w=n;}}function fh(t,e,r,n){const i=[],s=0===n?(t,e,r,n,i,s)=>{t.push(new q(s,r+(s-e)/(n-e)*(i-r)));}:(t,e,r,n,i,s)=>{t.push(new q(e+(s-r)/(i-r)*(n-e),s));};for(const a of t){const t=[];for(const i of a){if(i.length<=2)continue;const a=[];for(let t=0;te&&s(a,o,l,u,c,e):h>r?p=e&&s(a,o,l,u,c,e),p>r&&h<=r&&s(a,o,l,u,c,r);}let o=i[i.length-1];const l=0===n?o.x:o.y;l>=e&&l<=r&&a.push(o),a.length&&(o=a[a.length-1],a[0].x===o.x&&a[0].y===o.y||a.push(a[0]),t.push(a));}t.length&&i.push(t);}return i}function dh(t,e,r,n){const i="x"===r?"y":"x",s=(n-t[r])/(e[r]-t[r]);t[i]=t[i]+(e[i]-t[i])*s,t[r]=n,t.hasOwnProperty("z")&&(t.z=ke(t.z,e.z,s)),t.hasOwnProperty("w")&&(t.w=ke(t.w,e.w,s));}function mh(t,e,r,n){const i=r,s=n;for(const r of ["x","y"]){let n=t,a=e;n[r]>=a[r]&&(n=e,a=t),n[r]i&&dh(n,a,r,i),n[r]s&&dh(a,n,r,s);}}const yh=Number.MAX_SAFE_INTEGER;function gh(t,e,r,n){return t.ordere===t))}(n,t.clipScope)}function xh(t,e){return t.x-e.x||t.y-e.y}function bh(t,e){return 0===xh(t.min,e.min)&&0===xh(t.max,e.max)}function vh(t,e){return !(t.min.x>e.max.x||t.max.xe.max.y||t.max.ynew q((t.x+s.x*Hr)*o-a.x*Hr,(t.y+s.y*Hr)*o-a.y*Hr)));}return Ah(r,i,t.indices,0,t.indices.length,0,0)}function Ih(t,e,r,n){const i=Math.pow(2,n.z-r.z);return new q((t+r.x*Hr)*i-n.x*Hr,(e+r.y*Hr)*i-n.y*Hr)}function Ph(t,e){const r=[];e.grid.queryPoint(t,r);const n=e.indices,i=e.vertices;for(let e=0;e0&&(n.length>1&&r.push(n),n=[]);}return n.length>1&&r.push(n),r}const Th=ch.VectorTileFeature.types,Eh=["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"],Bh=["fill-extrusion-flood-light-ground-radius"],Vh=Math.pow(2,13),Ch=Math.pow(2,15)-1,Rh=new q(0,1),Dh=2147483648;function Lh(t,e,r,n,i,s,a,o){t.emplaceBack((e<<1)+a,(r<<1)+s,(Math.floor(n*Vh)<<1)+i,Math.round(o));}function Fh(t,e,r){t.emplaceBack(e.x*Hr,e.y*Hr,r?1:0);}function Oh(t,e,r,n,i,s){t.emplaceBack(e.x,e.y,(r.x<<1)+n,(r.y<<1)+i,s);}function Uh(t,e,r){const n=16384;t.emplaceBack(e.x,e.y,e.z,r[0]*n,r[1]*n,r[2]*n);}class jh{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0;}}class Nh{constructor(){this.centroidXY=new q(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 q(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new q(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0;}span(){return new q(this.max.x-this.min.x,this.max.y-this.min.y)}}class qh{constructor(){this.acc=new q(0,0),this.accCount=0,this.centroidDataIndex=0;}startRing(t,e){t.min.x===Number.MAX_VALUE&&(t.min.x=t.max.x=e.x,t.min.y=t.max.y=e.y);}appendEdge(t,e,r){this.accCount++,this.acc._add(e);let n=!!this.borders;e.xt.max.x&&(t.max.x=e.x,n=!0),e.yt.max.y&&(t.max.y=e.y,n=!0),((0===e.x||e.x===Hr)&&e.x===r.x)!=((0===e.y||e.y===Hr)&&e.y===r.y)&&this.processBorderOverlap(e,r),n&&this.checkBorderIntersection(e,r);}checkBorderIntersection(t,e){e.x<0!=t.x<0&&this.addBorderIntersection(0,ke(e.y,t.y,(0-e.x)/(t.x-e.x))),e.x>Hr!=t.x>Hr&&this.addBorderIntersection(1,ke(e.y,t.y,(Hr-e.x)/(t.x-e.x))),e.y<0!=t.y<0&&this.addBorderIntersection(2,ke(e.x,t.x,(0-e.y)/(t.y-e.y))),e.y>Hr!=t.y>Hr&&this.addBorderIntersection(3,ke(e.x,t.x,(Hr-e.y)/(t.y-e.y)));}addBorderIntersection(t,e){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 r=this.borders[t];er[1]&&(r[1]=e);}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const r=0===t.x?0:1;this.addBorderIntersection(r,e.y),this.addBorderIntersection(r,t.y);}else {const r=0===t.y?2:3;this.addBorderIntersection(r,e.x),this.addBorderIntersection(r,t.x);}}centroid(){return 0===this.accCount?new q(0,0):new q(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(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0):0}}function $h(t,e){const r=t.add(e)._unit(),n=Q(t.x*r.x+t.y*r.y,-1,1);var i,s,a;return a=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(a)))/4*Ch*((i=t).x*(s=e).y-i.y*s.x<0?-1:1)}const Gh=[t=>t.x<0,t=>t.x>Hr,t=>t.y<0,t=>t.y>Hr];function Xh(t,e,r,n){const i=[4];if(0===n)return i;r._mult(n);const s=t.sub(r),a=e.sub(r),o=[t,e,s,a];for(let t=0;t<4;t++)for(const e of o)if(Gh[t](e)){i.push(t);break}return i}class Yh{constructor(t){this.vertexArray=new wa,this.indexArray=new Da,this.programConfigurations=new Fo(t.layers,{zoom:t.zoom,lut:t.lut},(t=>Bh.includes(t))),this._segments=new co,this.hiddenByLandmarkVertexArray=new Za,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new co;}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(t,e,r,n=!1){const i=t.length;if(i>2){let s=Math.max(0,this._segments.get().length-1);const a=this._segments._prepareSegment(4*i,this.vertexArray.length,2*this._segmentToGroundQuads[s].length);let o;s!==this._segments.get().length-1&&(s++,this._segmentToGroundQuads[s]=[],this._segmentToRegionTriCounts[s]=[0,0,0,0,0]);{const e=t[0],r=t[1];o=$h(e.sub(t[i-1])._perp()._unit(),r.sub(e)._perp()._unit());}for(let l=0;lt.region-e.region));for(let r=0;rt+e),0);let s=0;for(let t=0;t<=4;t++){const e=i[t];if(0!==e){let r=this.regionSegments[t];r||(r=this.regionSegments[t]=new co);const i={vertexOffset:n.vertexOffset,primitiveOffset:n.primitiveOffset+s,vertexLength:n.vertexLength,primitiveLength:e};r.get().push(i);}s+=e;}for(let t=0;t0?this.hiddenByLandmarkVertexBuffer=t.createVertexBuffer(this.hiddenByLandmarkVertexArray,Hc.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._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let t=0;t<=4;t++){const e=this.regionSegments[t];e&&e.destroy();}}}}class Zh{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=t.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Da,this.footprintVertices=new xa,this.footprintSegments=[],this.layoutVertexArray=new va,this.centroidVertexArray=new so,this.wallVertexArray=new oo,this.indexArray=new Da,this.programConfigurations=new Fo(t.layers,{zoom:t.zoom,lut:t.lut},(t=>Eh.includes(t))),this.segments=new co,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.groundEffect=new Yh(t),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[];}updateFootprints(t,e){}populate(t,e,r,n){this.features=[],this.hasPattern=Dc("fill-extrusion",this.layers,e),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=gl(r),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:i,id:s,index:a,sourceLayerIndex:o}of t){const t=this.layers[0]._featureFilter.needGeometry,l=Pl(i,t);if(!this.layers[0]._featureFilter.filter(new Vs(this.zoom),l,r))continue;const u={id:s,sourceLayerIndex:o,index:a,geometry:t?l.geometry:Il(i,r,n),properties:i.properties,type:i.type,patterns:{}},c=this.layoutVertexArray.length,h="Polygon"===Th[u.type];if(this.hasPattern)this.features.push(Lc("fill-extrusion",this.layers,u,this.zoom,e));else if(this.wallMode)for(const t of u.geometry)for(const i of kh(t,h))this.addFeature(u,[i],a,r,{},e.availableImages,n,e.brightness);else this.addFeature(u,u.geometry,a,r,{},e.availableImages,n,e.brightness);e.featureIndex.insert(i,u.geometry,a,o,this.index,c);}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0;}addFeatures(t,e,r,n,i,s){for(const t of this.features){const a="Polygon"===Th[t.type],{geometry:o}=t;if(this.wallMode)for(const l of o)for(const o of kh(l,a))this.addFeature(t,[o],t.index,e,r,n,i,s);else this.addFeature(t,o,t.index,e,r,n,i,s);}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles();}update(t,e,r,n,i){const s=0!==Object.keys(t).length;if(s&&!this.stateDependentLayers.length)return;const a=s?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(t,e,a,r,n,i),this.groundEffect.update(t,e,a,r,n,i);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Jc),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.wallVertexBuffer=t.createVertexBuffer(this.wallVertexArray,Wc.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=t.createVertexBuffer(this.layoutVertexExtArray,Kc.members,!0)),this.groundEffect.upload(t)),this.groundEffect.uploadPaintProperties(t),this.programConfigurations.upload(t),this.uploaded=!0;}uploadCentroid(t){this.groundEffect.uploadHiddenByLandmark(t),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Zc.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(t,e,r,n,i,s,a,o){const l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,u=[new q(0,0),new q(Hr,Hr)],c=a.projection,h="globe"===c.name,p=this.wallMode||"Polygon"===Th[t.type],f=new qh;f.centroidDataIndex=this.centroidData.length;const d=new Nh,m=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},n)<=0,y=this.layers[0].paint.get("fill-extrusion-height").evaluate(t,{},n);let g;if(d.height=y,d.vertexArrayOffset=this.layoutVertexArray.length,d.groundVertexArrayOffset=this.groundEffect.vertexArray.length,h&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new Pa),this.wallMode){if(h)return void ft("Non zero fill-extrusion-line-width is not yet supported on globe.");if(1!==e.length)return;g=function(t){const e=t[0].x===t[t.length-1].x&&t[0].y===t[t.length-1].y,r=function(t){let e=0;const r=t.length;for(let n=0;n=0}(t);r||(t=t.reverse());const n={geometry:[],joinNormals:[],indices:[]},i=[],s=[],a=[];let o=t.length;if(o<(e?3:2))return n;for(;o>=2&&t[o-1].equals(t[o-2]);)o--;let l,u,c,h,p,f=0;for(;f0;let g="miter";const x=2;"miter"===g&&m>x&&(g="bevel"),"bevel"===g&&(m>100&&(g="flipbevel"),m{const o=new q(t.x,t.y),l=new q(t.x,t.y);o.x+=e.x*n,o.y+=e.y*n,l.x-=e.x*Math.max(r,1),l.y-=e.y*Math.max(r,1),a.push(e),i.push(o),s.push(l);};if("miter"===g)n._mult(m),b(l,n,0,0);else if("flipbevel"===g)n=p.mult(-1),b(l,n,0,0),b(l,n.mult(-1),0,0);else {const t=-Math.sqrt(m*m-1),e=y?t:0,r=y?0:t;u&&b(l,h,e,r),c&&b(l,p,e,r);}}n.geometry=[...i,...s.reverse(),i[0]],n.joinNormals=[...a,...a.reverse(),a[a.length-1]];const d=n.geometry.length-1;for(let t=0;tt<(e.length-1)/2||t===e.length-1,b=this.wallMode?[e]:Cc(e,500);for(let t=b.length-1;t>=0;t--){const e=b[t];(0===e.length||(v=e[0]).every((t=>t.x<=0))||v.every((t=>t.x>=Hr))||v.every((t=>t.y<=0))||v.every((t=>t.y>=Hr)))&&b.splice(t,1);}var v;let w;if(h)w=np(b,u,n);else {w=[];for(const t of b)w.push({polygon:t,bounds:u});}const _=p?this.edgeRadius:0,M=_>0&&this.zoom<17,A=(t,e)=>{if(0===t.length)return !1;const r=t[t.length-1];return e.x===r.x&&e.y===r.y};for(const{polygon:t,bounds:e}of w){let r=0,i=0;for(const e of t)p&&!e[0].equals(e[e.length-1])&&e.push(e[0]),i+=p?e.length-1:e.length;const s=this.segments.prepareSegment((p?5:4)*i,this.layoutVertexArray,this.indexArray);d.footprintSegIdx<0&&(d.footprintSegIdx=this.footprintSegments.length),d.polygonSegIdx<0&&(d.polygonSegIdx=this.polygonSegments.length);const a={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},o=new jh;if(o.vertexOffset=this.footprintVertices.length,o.indexOffset=3*this.footprintIndices.length,o.ringIndices=[],p){const i=[],a=[];r=s.vertexLength;for(let r=0;r4&&tp(a[a.length-2],a[0],a[1]),u=_?Hh(a[a.length-2],a[0],a[1],_):0;const y=[];let b,v,w;v=a[1].sub(a[0])._perp()._unit();let M=!0;for(let t=1,i=0;t0?1:0,k=l.dist(p);if(i+k>32768&&(i=0),_){w=S.sub(p)._perp()._unit();let t=Kh(l,p,S,Wh(v,w),_);isNaN(t)&&(t=0);const e=p.sub(l)._unit();l=l.add(e.mult(u))._round(),p=p.add(e.mult(-t))._round(),u=t,v=w,m&&this.zoom>=17&&(A(y,l)||y.push(l),A(y,p)||y.push(p));}const T=s.vertexLength,E=a.length>4&&tp(l,p,S);let B=ep(i,o,M);if(Lh(this.layoutVertexArray,l.x,l.y,P,z,0,0,B),Lh(this.layoutVertexArray,l.x,l.y,P,z,0,1,B),this.wallMode){const e=x(t-1,a),r=g.joinNormals[t-1];Fh(this.wallVertexArray,r,e),Fh(this.wallVertexArray,r,e);}if(i+=k,B=ep(i,E,!M),o=E,Lh(this.layoutVertexArray,p.x,p.y,P,z,0,0,B),Lh(this.layoutVertexArray,p.x,p.y,P,z,0,1,B),this.wallMode){const e=x(t,a),r=g.joinNormals[t];Fh(this.wallVertexArray,r,e),Fh(this.wallVertexArray,r,e);}if(s.vertexLength+=4,this.indexArray.emplaceBack(T+0,T+1,T+2),this.indexArray.emplaceBack(T+1,T+3,T+2),s.primitiveLength+=2,_){const n=r+(1===t?a.length-2:t-2),i=1===t?r:n+1;if(this.indexArray.emplaceBack(T+1,n,T+3),this.indexArray.emplaceBack(n,i,T+3),s.primitiveLength+=2,void 0===b&&(b=T),!Jh(S,a[t],e)){const e=t===a.length-1?b:s.vertexLength;this.indexArray.emplaceBack(T+2,T+3,e),this.indexArray.emplaceBack(T+3,e+1,e),this.indexArray.emplaceBack(T+3,i,e+1),s.primitiveLength+=3;}M=!M;}if(h){const t=this.layoutVertexExtArray,e=c.projectTilePoint(l.x,l.y,n),r=c.projectTilePoint(p.x,p.y,n),i=c.upVector(n,l.x,l.y),s=c.upVector(n,p.x,p.y);Uh(t,e,i),Uh(t,e,i),Uh(t,r,s),Uh(t,r,s);}}p&&(r+=a.length-1),m&&_&&this.zoom>=17&&(0!==y.length&&A(y,y[0])&&y.pop(),this.groundEffect.addData(y,e,l,_>0));}this.footprintSegments.push(o),a.triangleCount=this.indexArray.length-a.triangleArrayOffset,this.polygonSegments.push(a),++d.footprintSegLen,++d.polygonSegLen;}if(d.vertexCount=this.layoutVertexArray.length-d.vertexArrayOffset,d.groundVertexCount=this.groundEffect.vertexArray.length-d.groundVertexArrayOffset,0!==d.vertexCount){if(d.centroidXY=f.borders?Rh:this.encodeCentroid(f,d),this.centroidData.push(d),f.borders){this.featuresOnBorder.push(f);const t=this.featuresOnBorder.length-1;for(let e=0;ethis.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[r].borders[t][0]));}splitToSubtiles(){const t=[];for(let e=0;eHr),i=2*n+(+(r.min.x+r.max.x>Hr)^n);for(let n=0;nt.triangleSegmentIdx===e.triangleSegmentIdx?t.subtile-e.subtile:t.triangleSegmentIdx-e.triangleSegmentIdx));let r=0,n=0,i=0;for(const e of t){if(e.triangleSegmentIdx!==r)break;i++;}const s=t.length;for(;n!==t.length;){r=t[n].triangleSegmentIdx;let a=0,o=n,l=n;for(let e=o;e0&&this.triangleSubSegments.push({segment:c,min:s,max:u}),o=l;for(let e=o;e[t[0]*(1-r[0])+e[0]*r[0],t[1]*(1-r[1])+e[1]*r[1]],p=[],f=[];for(const t of this.triangleSubSegments){p[0]=t.min.x/Hr,p[1]=t.min.y/Hr,f[0]=t.max.x/Hr,f[1]=t.max.y/Hr;const e=h(u,c,p),a=h(u,c,f);if(0===new yu([e[0],e[1],i],[a[0],a[1],s]).intersectsPrecise(r)){l&&(n.segments.push(l),l=void 0);continue}const o=t.segment;l&&l.vertexOffset!==o.vertexOffset&&(n.segments.push(l),l=void 0),l?(l.vertexLength+=o.vertexLength,l.primitiveLength+=o.primitiveLength):l={vertexOffset:o.vertexOffset,primitiveLength:o.primitiveLength,vertexLength:o.vertexLength,primitiveOffset:o.primitiveOffset,sortKey:void 0,vaos:{}};}return l&&n.segments.push(l),n}encodeCentroid(t,e){const r=t.centroid(),n=e.span(),i=Math.min(7,Math.round(n.x*this.tileToMeter/10)),s=Math.min(7,Math.round(n.y*this.tileToMeter/10));return new q(Q(r.x,1,Hr-1)<<3|i,Q(r.y,1,Hr-1)<<3|s)}encodeBorderCentroid(t){if(!t.borders)return new q(0,0);const e=t.borders,r=Number.MAX_VALUE;if(e[0][0]!==r||e[1][0]!==r){const t=e[0][0]!==r?0:1;return new q(6|(e[0][0]!==r?0:65528),(e[t][0]+e[t][1])/2<<3|6)}{const t=e[2][0]!==r?2:3;return new q((e[t][0]+e[t][1])/2<<3|6,6|(e[2][0]!==r?0:65528))}}showCentroid(t){const e=this.centroidData[t.centroidDataIndex];e.flags&=Dh,e.centroidXY.x=0,e.centroidXY.y=0,this.writeCentroidToBuffer(e);}writeCentroidToBuffer(t){this.groundEffect.updateHiddenByLandmark(t);const e=t.vertexArrayOffset,r=t.vertexCount+t.vertexArrayOffset,n=t.flags&Dh?Rh:t.centroidXY,i=this.centroidVertexArray.geta_centroid_pos0(e);if(this.centroidVertexArray.geta_centroid_pos1(e)!==n.y||i!==n.x){for(let t=e;tr.max.x||r.min.x>e.max.x||e.min.y>r.max.y||r.min.y>e.max.y))for(let s=0;se!=l>e&&t<(this.footprintVertices.int16[2*(o+s.vertexOffset)+0]-r)*(e-a)/(l-a)+r&&(n=!n);}a=r;}}return n}getHeightAtTileCoord(t,e){let r=Number.NEGATIVE_INFINITY,n=!0;const i=4*(t+Hr)*Hr+(e+Hr);if(this.partLookup.hasOwnProperty(i)){const t=this.partLookup[i];return t?{height:t.height,hidden:!!(t.flags&Dh)}:void 0}for(const s of this.centroidData)t>s.max.x||s.min.x>t||e>s.max.y||s.min.y>e||this.footprintContainsPoint(t,e,s)&&s&&s.height>r&&(r=s.height,this.partLookup[i]=s,n=!!(s.flags&Dh));if(r!==Number.NEGATIVE_INFINITY)return {height:r,hidden:n};this.partLookup[i]=void 0;}}function Wh(t,e){const r=t.add(e)._unit();return t.x*r.x+t.y*r.y}function Hh(t,e,r,n){const i=e.sub(t)._perp()._unit(),s=r.sub(e)._perp()._unit();return Kh(t,e,r,Wh(i,s),n)}function Kh(t,e,r,n,i){const s=Math.sqrt(1-n*n);return Math.min(t.dist(e)/3,e.dist(r)/3,i*s/n)}function Jh(t,e,r){return t.xr[1].x&&e.x>r[1].x||t.yr[1].y&&e.y>r[1].y}function Qh(t,e){return t.xe[1].x||t.ye[1].y}function tp(t,e,r){if(t.x<0||t.x>=Hr||e.x<0||e.x>=Hr||r.x<0||r.x>=Hr)return !1;const n=r.sub(e),i=n.perp(),s=t.sub(e);return (n.x*s.x+n.y*s.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(s.x*s.x+s.y*s.y))>-.866&&i.x*s.x+i.y*s.y<0}function ep(t,e,r){const n=e?2|t:-3&t;return r?1|n:-2&n}function rp(){const t=Math.PI/32,e=Math.tan(t),r=tl;return r*Math.sqrt(1+2*e*e)-r}function np(t,e,r){const n=1<{for(const r of t)a.push({polygon:r,bounds:e});},l=Math.ceil(Math.log2(r)),u=Math.ceil(Math.log2(n)),c=l-u,h=[];for(let t=0;t0?0:1);for(let t=0;te+1?f.push({polygons:p,bounds:t,depth:e+1}):o(p,t);}if(d.length){const t=[new q(0===r?c:n.x,1===r?c:n.y),a];h.length>e+1?f.push({polygons:d,bounds:t,depth:e+1}):o(d,t);}}return a}(t,e,Math.ceil((s-i)/11.25),Math.ceil((a-o)/11.25),1,((t,e,i)=>{if(0===t)return .5*(e+i);{const t=hl((r.y+e/Hr)/n);return (ll(.5*(hl((r.y+i/Hr)/n)+t))*n-r.y)*Hr}}))}function ip(t,e,r,n,i,s){const a=Math.pow(2,n.z-i.z);for(let o=0;o1&&(a=t[++s]);const l=Math.abs(o-a.left),u=Math.abs(o-a.right),c=Math.min(l,u);let h;const p=e/r*(n+1);if(a.isDash){const t=n-Math.abs(p);h=Math.sqrt(c*c+t*t);}else h=n-Math.sqrt(c*c+p*p);this.image.data[i+o]=Math.max(0,Math.min(255,h+128));}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const r=t[e],n=t[e+1];r.zeroLength?t.splice(e,1):n&&n.isDash===r.isDash&&(n.left=r.left,t.splice(e,1));}const r=t[0],n=t[t.length-1];r.isDash===n.isDash&&(r.left=n.left-this.width,n.right=r.right+this.width);const i=this.width*this.nextRow;let s=0,a=t[s];for(let r=0;r1&&(a=t[++s]);const n=Math.abs(r-a.left),o=Math.abs(r-a.right),l=Math.min(n,o);this.image.data[i+r]=Math.max(0,Math.min(255,(a.isDash?l:-l)+e+128));}}addDash(t,e){const r=this.getKey(t,e);if(this.positions[r])return this.positions[r];const n="round"===e,i=n?7:0,s=2*i+1;if(this.nextRow+s>this.height)return ft("LineAtlas out of space"),null;0===t.length&&t.push(1);let a=0;for(let e=0;et.fqid)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.hasZOffset=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={};})),this.layoutVertexArray=new _a,this.layoutVertexArray2=new Ma,this.patternVertexArray=new Aa,this.indexArray=new Da,this.programConfigurations=new Fo(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new co,this.maxLineLength=0,this.zOffsetVertexArray=new Oa,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.tessellationStep=t.tessellationStep?t.tessellationStep:Hr/64;}updateFootprints(t,e){}populate(t,e,r,n){this.hasPattern=Dc("line",this.layers,e);const i=this.layers[0].layout.get("line-sort-key"),s=this.layers[0].layout.get("line-z-offset");this.hasZOffset=!s.isConstant()||!!s.constantOr(0);const a=[];for(const{feature:e,id:s,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=Pl(e,t);if(!this.layers[0]._featureFilter.filter(new Vs(this.zoom),u,r))continue;const c=i?i.evaluate(u,{},r):void 0,h={id:s,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?u.geometry:Il(e,r,n),patterns:{},sortKey:c};a.push(h);}i&&a.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:o,featureIndex:l}=e,u=this.addConstantDashes(o);for(const n of a){const{geometry:i,index:s,sourceLayerIndex:a}=n;if(u&&this.addFeatureDashes(n,o),this.hasPattern){const t=Lc("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t);}else this.addFeature(n,i,s,r,o.positions,e.availableImages,e.brightness);l.insert(t[s].feature,i,s,a,this.index);}}addConstantDashes(t){let e=!1;for(const r of this.layers){const n=r.paint.get("line-dasharray").value,i=r.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==i.kind)e=!0;else {const e=i.value,r=n.value;if(!r)continue;t.addDash(r,e);}}return e}addFeatureDashes(t,e){const r=this.zoom;for(const n of this.layers){const i=n.paint.get("line-dasharray").value,s=n.layout.get("line-cap").value;if("constant"===i.kind&&"constant"===s.kind)continue;let a,o;if("constant"===i.kind){if(a=i.value,!a)continue}else a=i.evaluate({zoom:r},t);o="constant"===s.kind?s.value:s.evaluate({zoom:r},t),e.addDash(a,o),t.patterns[n.id]=e.getKey(a,o);}}update(t,e,r,n,i){const s=0!==Object.keys(t).length;s&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,s?this.stateDependentLayers:this.layers,r,n,i);}addFeatures(t,e,r,n,i,s){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,r,n,s);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,dp)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=t.createVertexBuffer(this.patternVertexArray,yp)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,hp.members,!0)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,pp),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return {start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,r,n,i,s,a){const o=this.layers[0].layout,l=o.get("line-join").evaluate(t,{}),u=o.get("line-cap").evaluate(t,{}),c=o.get("line-miter-limit"),h=o.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const r of e)this.addLine(r,t,n,l,u,c,h);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,i,s,n,a);}addLine(t,e,r,n,i,s,a){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.currentVertex=void 0;const o={zoom:this.zoom,lineProgress:void 0},l=this.layers[0].layout,u="none"===n;if(this.patternJoinNone=this.hasPattern&&u,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[h-1].equals(t[h-2]);)h--;let p=0;for(;p0;if(z&&r>p){const t=m.dist(y);if(t>2*f){const e=m.sub(m.sub(y)._mult(f/t)._round());this.updateDistance(y,e),this.addCurrentVertex(e,x,0,0,d,v),y=e;}}if(w&&"round"===_&&(Is&&(_="bevel"),"bevel"===_&&(I>2&&(_="flipbevel"),I100)A=b.mult(-1);else {const t=I*x.add(b).mag()/x.sub(b).mag();A._perp()._mult(t*(k?-1:1));}this.addCurrentVertex(m,A,0,0,d,v),this.addCurrentVertex(m,A.mult(-1),0,0,d,v);}else if("bevel"===_||"fakeround"===_){const t=-Math.sqrt(I*I-1),e=k?t:0,r=k?0:t;if(y&&this.addCurrentVertex(m,x,e,r,d,v),"fakeround"===_){const t=Math.round(180*P/Math.PI/20);for(let e=1;e2*f){const e=m.add(g.sub(m)._mult(f/t)._round());this.updateDistance(m,e),this.addCurrentVertex(e,b,0,0,d,v),m=e;}}}}addVerticesTo(t,e,r,n,i,s,a,o,l,u){const c=(e.w-t.w)/this.tessellationStep|0;if(c>1){this.lineSoFar=t.w;const h=(e.x-t.x)/c,p=(e.y-t.y)/c,f=(e.z-t.z)/c,d=(e.w-t.w)/c;for(let e=1;e=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,u),o.primitiveLength++),s?this.e2=u:this.e1=u,null!=l&&this.zOffsetVertexArray.emplaceBack(l);}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance;}else this.lineSoFar=this.distance;}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance();}}function _p(t,e,r){return t.xr||t.yr}let Mp,Ap;function Sp(t,e,r){return e*(Hr/(t.tileSize*Math.pow(2,r-t.tileID.overscaledZ)))}function Ip(t,e){return 1/Sp(t,1,e.tileZoom)}function Pp(t,e,r,n){return t.translatePosMatrix(n||e.tileID.projMatrix,e,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}os(wp,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const zp=t=>{const e=[];kp(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const r=t.paint.get("line-trim-offset");0===r[0]&&0===r[1]||e.push("RENDER_LINE_TRIM_OFFSET"),0!==t.paint.get("line-border-width").constantOr(1)&&e.push("RENDER_LINE_BORDER");const n="none"===t.layout.get("line-join").constantOr("miter"),i=!!t.paint.get("line-pattern").constantOr(1);return n&&i&&e.push("LINE_JOIN_NONE"),e};function kp(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}let Tp;const Ep=()=>Tp||(Tp={layout:Mp||(Mp=new Gs({"line-cap":new qs(Xs.layout_line["line-cap"]),"line-join":new qs(Xs.layout_line["line-join"]),"line-miter-limit":new Ns(Xs.layout_line["line-miter-limit"]),"line-round-limit":new Ns(Xs.layout_line["line-round-limit"]),"line-sort-key":new qs(Xs.layout_line["line-sort-key"]),"line-z-offset":new qs(Xs.layout_line["line-z-offset"]),visibility:new Ns(Xs.layout_line.visibility)})),paint:Ap||(Ap=new Gs({"line-opacity":new qs(Xs.paint_line["line-opacity"]),"line-color":new qs(Xs.paint_line["line-color"]),"line-translate":new Ns(Xs.paint_line["line-translate"]),"line-translate-anchor":new Ns(Xs.paint_line["line-translate-anchor"]),"line-width":new qs(Xs.paint_line["line-width"]),"line-gap-width":new qs(Xs.paint_line["line-gap-width"]),"line-offset":new qs(Xs.paint_line["line-offset"]),"line-blur":new qs(Xs.paint_line["line-blur"]),"line-dasharray":new qs(Xs.paint_line["line-dasharray"]),"line-pattern":new qs(Xs.paint_line["line-pattern"]),"line-gradient":new $s(Xs.paint_line["line-gradient"]),"line-trim-offset":new Ns(Xs.paint_line["line-trim-offset"]),"line-trim-fade-range":new Ns(Xs.paint_line["line-trim-fade-range"]),"line-trim-color":new Ns(Xs.paint_line["line-trim-color"]),"line-emissive-strength":new Ns(Xs.paint_line["line-emissive-strength"]),"line-border-width":new qs(Xs.paint_line["line-border-width"]),"line-border-color":new qs(Xs.paint_line["line-border-color"]),"line-occlusion-opacity":new Ns(Xs.paint_line["line-occlusion-opacity"])}))},Tp);class Bp extends qs{possiblyEvaluate(t,e){return e=new Vs(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,r,n){return e=nt({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,r,n)}}let Vp;function Cp(t,e){return e>0?e+2*t:t}const Rp=ya([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Dp=ya([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Lp=ya([{name:"a_projected_pos",components:4,type:"Float32"}],4);ya([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Fp=ya([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),Op=ya([{name:"a_texb",components:2,type:"Uint16"}]),Up=ya([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),jp=ya([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);ya([{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 Np=ya([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),qp=ya([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);ya([{name:"triangle",components:3,type:"Uint16"}]),ya([{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"}]),ya([{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"}]),ya([{type:"Float32",name:"offsetX"}]),ya([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var $p=24;const Gp=128;function Xp(t,e){const{expression:r}=e;if("constant"===r.kind)return {kind:"constant",layoutSize:r.evaluate(new Vs(t+1))};if("source"===r.kind)return {kind:"source"};{const{zoomStops:e,interpolationType:n}=r;let i=0;for(;i{t.text=function(t,e,r){const n=e.layout.get("text-transform").evaluate(r,{});return "uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),Bs.applyArabicShaping&&(t=Bs.applyArabicShaping(t)),t}(t.text,e,r);})),t}const Kp={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Jp(t){return "︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function Qp(t){return "︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}var tf,ef,rf,nf={}; /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */function sf(){return tf||(tf=1,nf.read=function(t,e,r,n,i){var s,a,o=8*i-n-1,l=(1<>1,c=-7,h=r?i-1:0,p=r?-1:1,f=t[e+h];for(h+=p,s=f&(1<<-c)-1,f>>=-c,c+=o;c>0;s=256*s+t[e+h],h+=p,c-=8);for(a=s&(1<<-c)-1,s>>=-c,c+=n;c>0;a=256*a+t[e+h],h+=p,c-=8);if(0===s)s=1-u;else {if(s===l)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,n),s-=u;}return (f?-1:1)*a*Math.pow(2,s-n)},nf.write=function(t,e,r,n,i,s){var a,o,l,u=8*s-i-1,c=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:s-1,d=n?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-a))<1&&(a--,l*=2),(e+=a+h>=1?p/l:p*Math.pow(2,1-h))*l>=2&&(a++,l/=2),a+h>=c?(o=0,a=c):a+h>=1?(o=(e*l-1)*Math.pow(2,i),a+=h):(o=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;t[r+f]=255&o,f+=d,o/=256,i-=8);for(a=a<0;t[r+f]=255&a,f+=d,a/=256,u-=8);t[r+f-d]|=128*m;}),nf}function af(){if(rf)return ef;rf=1,ef=e;var t=sf();function e(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length;}e.Varint=0,e.Fixed64=1,e.Bytes=2,e.Fixed32=5;var r=4294967296,n=1/r,i="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function s(t){return t.type===e.Bytes?t.readVarint()+t.pos:t.pos+1}function a(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function o(t,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(n);for(var i=r.pos-1;i>=t;i--)r.buf[i+n]=r.buf[i];}function l(t,e){for(var r=0;r>>8,t[r+2]=e>>>16,t[r+3]=e>>>24;}function b(t,e){return (t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}return e.prototype={destroy:function(){this.buf=null;},readFields:function(t,e,r){for(r=r||this.length;this.pos>3,s=this.pos;this.type=7&n,t(i,e,this),this.pos===s&&this.skip(n);}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=g(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=b(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=g(this.buf,this.pos)+g(this.buf,this.pos+4)*r;return this.pos+=8,t},readSFixed64:function(){var t=g(this.buf,this.pos)+b(this.buf,this.pos+4)*r;return this.pos+=8,t},readFloat:function(){var e=t.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=t.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(t){var e,r,n=this.buf;return e=127&(r=n[this.pos++]),r<128?e:(e|=(127&(r=n[this.pos++]))<<7,r<128?e:(e|=(127&(r=n[this.pos++]))<<14,r<128?e:(e|=(127&(r=n[this.pos++]))<<21,r<128?e:function(t,e,r){var n,i,s=r.buf;if(n=(112&(i=s[r.pos++]))>>4,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<3,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<10,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<17,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<24,i<128)return a(t,n,e);if(n|=(1&(i=s[r.pos++]))<<31,i<128)return a(t,n,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=n[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&i?function(t,e,r){return i.decode(t.subarray(e,r))}(this.buf,e,t):function(t,e,r){for(var n="",i=e;i239?4:l>223?3:l>191?2:1;if(i+c>r)break;1===c?l<128&&(u=l):2===c?128==(192&(s=t[i+1]))&&(u=(31&l)<<6|63&s)<=127&&(u=null):3===c?(a=t[i+2],128==(192&(s=t[i+1]))&&128==(192&a)&&((u=(15&l)<<12|(63&s)<<6|63&a)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(a=t[i+2],o=t[i+3],128==(192&(s=t[i+1]))&&128==(192&a)&&128==(192&o)&&((u=(15&l)<<18|(63&s)<<12|(63&a)<<6|63&o)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,n+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),n+=String.fromCharCode(u),i+=c;}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,r){if(this.type!==e.Bytes)return t.push(this.readVarint(r));var n=s(this);for(t=t||[];this.pos127;);else if(r===e.Bytes)this.pos=this.readVarint()+this.pos;else if(r===e.Fixed32)this.pos+=4;else {if(r!==e.Fixed64)throw new Error("Unimplemented type: "+r);this.pos+=8;}},writeTag:function(t,e){this.writeVarint(t<<3|e);},realloc:function(t){for(var e=this.length||16;e268435455||t<0?function(t,e){var r,n;if(t>=0?(r=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(r=~(-t%4294967296))?r=r+1|0:(r=0,n=n+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,r){r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,r.buf[r.pos]=127&(t>>>=7);}(r,0,e),function(t,e){var r=(7&t)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))));}(n,e);}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))));},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t);},writeBoolean:function(t){this.writeVarint(Boolean(t));},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,r){for(var n,i,s=0;s55295&&n<57344){if(!i){n>56319||s+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):i=n;continue}if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,i=n;continue}n=i-55296<<10|n-56320|65536,i=null;}else i&&(t[r++]=239,t[r++]=191,t[r++]=189,i=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=63&n|128);}return r}(this.buf,t,this.pos);var r=this.pos-e;r>=128&&o(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r;},writeFloat:function(e){this.realloc(4),t.write(this.buf,e,this.pos,!0,23,4),this.pos+=4;},writeDouble:function(e){this.realloc(8),t.write(this.buf,e,this.pos,!0,52,8),this.pos+=8;},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&o(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n;},writeMessage:function(t,r,n){this.writeTag(t,e.Bytes),this.writeRawMessage(r,n);},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,l,e);},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,u,e);},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,p,e);},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,c,e);},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,h,e);},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,f,e);},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,d,e);},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,m,e);},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,y,e);},writeBytesField:function(t,r){this.writeTag(t,e.Bytes),this.writeBytes(r);},writeFixed32Field:function(t,r){this.writeTag(t,e.Fixed32),this.writeFixed32(r);},writeSFixed32Field:function(t,r){this.writeTag(t,e.Fixed32),this.writeSFixed32(r);},writeFixed64Field:function(t,r){this.writeTag(t,e.Fixed64),this.writeFixed64(r);},writeSFixed64Field:function(t,r){this.writeTag(t,e.Fixed64),this.writeSFixed64(r);},writeVarintField:function(t,r){this.writeTag(t,e.Varint),this.writeVarint(r);},writeSVarintField:function(t,r){this.writeTag(t,e.Varint),this.writeSVarint(r);},writeStringField:function(t,r){this.writeTag(t,e.Bytes),this.writeString(r);},writeFloatField:function(t,r){this.writeTag(t,e.Fixed32),this.writeFloat(r);},writeDoubleField:function(t,r){this.writeTag(t,e.Fixed64),this.writeDouble(r);},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e));}},ef}var of=e(af());const lf=3;function uf(t,e,r){e.glyphs=[],1===t&&r.readMessage(cf,e);}function cf(t,e,r){if(3===t){const{id:t,bitmap:n,width:i,height:s,left:a,top:o,advance:l}=r.readMessage(hf,{});e.glyphs.push({id:t,bitmap:new nc({width:i+2*lf,height:s+2*lf},n),metrics:{width:i,height:s,left:a,top:o,advance:l}});}else 4===t?e.ascender=r.readSVarint():5===t&&(e.descender=r.readSVarint());}function hf(t,e,r){1===t?e.id=r.readVarint():2===t?e.bitmap=r.readBytes():3===t?e.width=r.readVarint():4===t?e.height=r.readVarint():5===t?e.left=r.readSVarint():6===t?e.top=r.readSVarint():7===t&&(e.advance=r.readVarint());}const pf=lf,ff={horizontal:1,vertical:2,horizontalOnly:3};class df{constructor(){this.scale=1,this.fontStack="",this.imageName=null;}static forText(t,e){const r=new df;return r.scale=t||1,r.fontStack=e,r}static forImage(t){const e=new df;return e.imageName=t,e}}class mf{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null;}static fromFeature(t,e){const r=new mf;for(let n=0;n=0&&r>=t&&gf[this.text.charCodeAt(r)];r--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e);}substring(t,e){const r=new mf;return r.text=this.text.substring(t,e),r.sectionIndex=this.sectionIndex.slice(t,e),r.sections=this.sections,r}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(df.forText(t.scale,t.fontStack||e));const r=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function yf(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d){const m=mf.fromFeature(t,i);h===ff.vertical&&m.verticalizePunctuation(p);let y=[];const g=function(t,e,r,n,i,s){if(!t)return [];const a=[],o=function(t,e,r,n,i,s){let a=0;for(let r=0;r=0;let u=0;for(let r=0;r0&&s>w&&(w=s);}else {const t=r[o.fontStack];if(!t)continue;t[m]&&(A=t[m]);const n=e[o.fontStack];if(!n)continue;const s=n.glyphs[m];if(!s)continue;if(b=s.metrics,I=8203!==m?$p:0,y){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,r=(t+e)*g;_-r/2;){if(a--,a<0)return !1;o-=t[a].dist(s),s=t[a];}o+=t[a].dist(t[a+1]),a++;const l=[];let u=0;for(;on;)u-=l.shift().angleDelta;if(u>i)return !1;a++,o+=e.dist(r);}return !0}function Tf(t){let e=0;for(let r=0;ru){const c=(u-l)/s,h=ke(n.x,i.x,c),p=ke(n.y,i.y,c),f=new zf(h,p,0,i.angleTo(n),r);return !a||kf(t,f,o,a,e)?f:void 0}l+=s;}}function Cf(t,e,r,n,i,s,a,o,l){const u=Ef(n,s,a),c=Bf(n,i),h=c*a,p=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-h=0&&g=0&&x=0&&p+u<=c){const r=new zf(g,x,0,m,e);n&&!kf(t,r,s,n,i)||f.push(r);}}h+=d;}return o||f.length||a||(f=Rf(t,h/2,r,n,i,s,a,!0,l)),f}function Df(t,e,r,n,i){const s=[];for(let a=0;a=n&&u.x>=n||(a.x>=n?a=new q(n,a.y+(n-a.x)/(u.x-a.x)*(u.y-a.y))._round():u.x>=n&&(u=new q(n,a.y+(n-a.x)/(u.x-a.x)*(u.y-a.y))._round()),a.y>=i&&u.y>=i||(a.y>=i?a=new q(a.x+(i-a.y)/(u.y-a.y)*(u.x-a.x),i)._round():u.y>=i&&(u=new q(a.x+(i-a.y)/(u.y-a.y)*(u.x-a.x),i)._round()),l&&a.equals(l[l.length-1])||(l=[a],s.push(l)),l.push(u)))));}}return s}function Lf(t){let e=0,r=0;for(const n of t)e+=n.w*n.h,r=Math.max(r,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let i=0,s=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const r=n[t];if(!(e.w>r.w||e.h>r.h)){if(e.x=r.x,e.y=r.y,s=Math.max(s,e.y+e.h),i=Math.max(i,e.x+e.w),e.w===r.w&&e.h===r.h){const e=n.pop();t1?a-1:a,ic.copy(n.data,l,{x:0,y:0},{x:o,y:u},n.data,r),ic.copy(n.data,l,{x:0,y:h-a},{x:o,y:u-a},{width:c,height:a},r),ic.copy(n.data,l,{x:0,y:0},{x:o,y:u+h},{width:c,height:a},r),ic.copy(n.data,l,{x:c-a,y:0},{x:o-a,y:u},{width:a,height:h},r),ic.copy(n.data,l,{x:0,y:0},{x:o+c,y:u},{width:a,height:h},r),ic.copy(n.data,l,{x:c-a,y:h-a},{x:o-a,y:u-a},{width:a,height:a},r),ic.copy(n.data,l,{x:0,y:h-a},{x:o+c,y:u-a},{width:a,height:a},r),ic.copy(n.data,l,{x:0,y:0},{x:o+c,y:u+h},{width:a,height:a},r),ic.copy(n.data,l,{x:c-a,y:0},{x:o-a,y:u+h},{width:a,height:a},r);}this.image=l,this.iconPositions=n,this.patternPositions=i;}addImages(t,e,r,n){for(const i in t){const s=t[i],a={x:0,y:0,w:s.data.width+2*r,h:s.data.height+2*r};n.push(a),e[i]=new Of(a,s,r),s.hasRenderCallback&&this.haveRenderCallbacks.push(i);}}patchUpdatedImages(t,e,r){this.haveRenderCallbacks=this.haveRenderCallbacks.filter((e=>t.hasImage(e,r))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,r);for(const n in t.getUpdatedImages(r))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,r),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,r),e);}patchUpdatedImage(t,e,r){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,i]=t.tl;r.update(e.data,{position:{x:n,y:i}});}}os(Of,"ImagePosition"),os(Uf,"ImageAtlas");const jf=1e20;function Nf(t,e,r,n,i,s,a,o,l){for(let u=e;u-1);l++,s[l]=o,a[l]=u,a[l+1]=jf;}for(let o=0,l=0;o{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let s=n.glyphs[e];if(void 0!==s)return void r(null,{stack:t,id:e,glyph:s});if(s=this._tinySDF(n,t,e),s)return n.glyphs[e]=s,void r(null,{stack:t,id:e,glyph:s});const a=Math.floor(e/256);if(256*a>65535)return void r(new Error("glyphs > 65535 not supported"));if(n.ranges[a])return void r(null,{stack:t,id:e,glyph:s});let o=n.requests[a];o||(o=n.requests[a]=[],Xf.loadGlyphRange(t,a,i,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[a]=!0;}for(const r of o)r(t,e);delete n.requests[a];}))),o.push(((n,i)=>{n?r(n):i&&r(null,{stack:t,id:e,glyph:i.glyphs[e]||null});}));}),((t,e)=>{if(t)r(t);else if(e){const t={};for(const{stack:r,id:n,glyph:i}of e)void 0===t[r]&&(t[r]={}),void 0===t[r].glyphs&&(t[r].glyphs={}),t[r].glyphs[n]=i&&{id:i.id,bitmap:i.bitmap.clone(),metrics:i.metrics},t[r].ascender=this.entries[r].ascender,t[r].descender=this.entries[r].descender;r(null,t);}}));}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==Gf.none&&(this.localGlyphMode===Gf.all?!!this.localFontFamily:!!this.localFontFamily&&(ps["CJK Unified Ideographs"](t)||ps["Hangul Syllables"](t)||ps.Hiragana(t)||ps.Katakana(t)||ps["CJK Symbols and Punctuation"](t)||ps["CJK Unified Ideographs Extension A"](t)||ps["CJK Unified Ideographs Extension B"](t)))}_tinySDF(t,e,r){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(r))return;let i=t.tinySDF;if(!i){let r="400";/bold/i.test(e)?r="900":/medium/i.test(e)?r="500":/light/i.test(e)&&(r="200"),i=t.tinySDF=new Xf.TinySDF({fontFamily:n,fontWeight:r,fontSize:24*$f,buffer:3*$f,radius:8*$f}),i.fontWeight=r;}if(this.localGlyphs[i.fontWeight][r])return this.localGlyphs[i.fontWeight][r];const s=String.fromCodePoint(r),{data:a,width:o,height:l,glyphWidth:u,glyphHeight:c,glyphLeft:h,glyphTop:p,glyphAdvance:f}=i.draw(s);return this.localGlyphs[i.fontWeight][r]={id:r,bitmap:new nc({width:o,height:l},a),metrics:{width:u/$f,height:c/$f,left:h/$f,top:p/$f-27,advance:f/$f,localGlyph:!0}}}}Xf.loadGlyphRange=function(t,e,r,n,i){const s=256*e,a=s+255,o=n.transformRequest(n.normalizeGlyphsURL(r).replace("{fontstack}",t).replace("{range}",`${s}-${a}`),ee.Glyphs);se(o,((t,e)=>{if(t)i(t);else if(e){const t={},r=function(t){return new of(t).readFields(uf,{})}(e);for(const e of r.glyphs)t[e.id]=e;i(null,{glyphs:t,ascender:r.ascender,descender:r.descender});}}));},Xf.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:r=8,cutoff:n=.25,fontFamily:i="sans-serif",fontWeight:s="normal",fontStyle:a="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=r;const o=this.size=t+4*e,l=this._createCanvas(o),u=this.ctx=l.getContext("2d",{willReadFrequently:!0});u.font=`${a} ${s} ${t}px ${i}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(o*o),this.gridInner=new Float64Array(o*o),this.f=new Float64Array(o),this.z=new Float64Array(o+1),this.v=new Uint16Array(o);}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:r,actualBoundingBoxDescent:n,actualBoundingBoxLeft:i,actualBoundingBoxRight:s}=this.ctx.measureText(t),a=Math.ceil(r),o=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(s-i))),l=Math.min(this.size-this.buffer,a+Math.ceil(n)),u=o+2*this.buffer,c=l+2*this.buffer,h=Math.max(u*c,0),p=new Uint8ClampedArray(h),f={data:p,width:u,height:c,glyphWidth:o,glyphHeight:l,glyphTop:a,glyphLeft:0,glyphAdvance:e};if(0===o||0===l)return f;const{ctx:d,buffer:m,gridInner:y,gridOuter:g}=this;d.clearRect(m,m,o,l),d.fillText(t,m,m+a);const x=d.getImageData(m,m,o,l);g.fill(jf,0,h),y.fill(0,0,h);for(let t=0;t0?t*t:0,y[n]=t<0?t*t:0;}}Nf(g,0,0,u,c,u,this.f,this.v,this.z),Nf(y,m,m,o,l,u,this.f,this.v,this.z);for(let t=0;tt+e[1]-e[0],d=h.reduce(f,0),m=p.reduce(f,0),y=o-d,g=l-m;let x=0,b=d,v=0,w=m,_=0,M=y,A=0,S=g;if(s.content&&n){const t=s.content;x=Wf(h,0,t[0]),v=Wf(p,0,t[1]),b=Wf(h,t[0],t[2]),w=Wf(p,t[1],t[3]),_=t[0]-x,A=t[1]-v,M=t[2]-t[0]-b,S=t[3]-t[1]-w;}const I=(n,i,o,l)=>{const h=Kf(n.stretch-x,b,u,t.left),p=Jf(n.fixed-_,M,n.stretch,d),f=Kf(i.stretch-v,w,c,t.top),y=Jf(i.fixed-A,S,i.stretch,m),g=Kf(o.stretch-x,b,u,t.left),I=Jf(o.fixed-_,M,o.stretch,d),P=Kf(l.stretch-v,w,c,t.top),z=Jf(l.fixed-A,S,l.stretch,m),k=new q(h,f),T=new q(g,f),E=new q(g,P),B=new q(h,P),V=new q(p/a,y/a),C=new q(I/a,z/a),R=e*Math.PI/180;if(R){const t=Math.sin(R),e=Math.cos(R),r=[e,-t,t,e];k._matMult(r),T._matMult(r),B._matMult(r),E._matMult(r);}const D=n.stretch+n.fixed,L=o.stretch+o.fixed,F=i.stretch+i.fixed,O=l.stretch+l.fixed,U=t.imageSecondary;return {tl:k,tr:T,bl:B,br:E,texPrimary:{x:s.paddedRect.x+Yf+D,y:s.paddedRect.y+Yf+F,w:L-D,h:O-F},texSecondary:U?{x:U.paddedRect.x+Yf+D,y:U.paddedRect.y+Yf+F,w:L-D,h:O-F}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:V,pixelOffsetBR:C,minFontScaleX:M/a/u,minFontScaleY:S/a/c,isSDF:r}};if(n&&(s.stretchX||s.stretchY)){const t=Hf(h,y,d),e=Hf(p,g,m);for(let r=0;rs)&&(s=e.x),(!t||e.y>a)&&(a=e.y);}const l=Math.min(s-n,a-i);let u=l/2;const c=new Wr([],ed);if(0===l)return new q(n,i);for(let e=n;eh.d||!h.d)&&(h=n,r&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,p)),n.max-h.d<=e||(u=n.h/2,c.push(new rd(n.p.x-u,n.p.y-u,u,t)),c.push(new rd(n.p.x+u,n.p.y-u,u,t)),c.push(new rd(n.p.x-u,n.p.y+u,u,t)),c.push(new rd(n.p.x+u,n.p.y+u,u,t)),p+=4);}return r&&(console.log(`num probes: ${p}`),console.log(`best distance: ${h.d}`)),h.p}function ed(t,e){return e.max-t.max}class rd{constructor(t,e,r,n){this.p=new q(t,e),this.h=r,this.d=function(t,e){let r=!1,n=1/0;for(let i=0;it.y!=o.y>t.y&&t.x<(o.x-i.x)*(t.y-i.y)/(o.y-i.y)+i.x&&(r=!r),n=Math.min(n,Fl(t,i,o));}}return (r?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2;}}const nd=Number.POSITIVE_INFINITY,id=Math.sqrt(2);function sd(t,[e,r]){let n=0,i=0;if(r===nd){e<0&&(e=0);const r=e/id;switch(t){case"top-right":case"top-left":i=r-7;break;case"bottom-right":case"bottom-left":i=7-r;break;case"bottom":i=7-e;break;case"top":i=e-7;}switch(t){case"top-right":case"bottom-right":n=-r;break;case"top-left":case"bottom-left":n=r;break;case"left":n=e;break;case"right":n=-e;}}else {switch(e=Math.abs(e),r=Math.abs(r),t){case"top-right":case"top-left":case"top":i=r-7;break;case"bottom-right":case"bottom-left":case"bottom":i=7-r;}switch(t){case"top-right":case"bottom-right":case"right":n=-e;break;case"top-left":case"bottom-left":case"left":n=e;}}return [n,i]}function ad(t){switch(t){case"right":case"top-right":case"bottom-right":return "right";case"left":case"top-left":case"bottom-left":return "left"}return "center"}function od(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d){let m=s.textMaxSize.evaluate(e,{},h);void 0===m&&(m=a);const y=t.layers[0].layout,g=y.get("icon-offset").evaluate(e,{},h),x=hd(r.horizontal)||r.vertical,b="globe"===p.name,v=$p,w=a/v,_=t.tilePixelRatio*m/v,M=(E=t.overscaling,t.zoom>18&&E>2&&(E>>=1),Math.max(Hr/(512*E),1)*y.get("symbol-spacing")),A=y.get("text-padding")*t.tilePixelRatio,S=y.get("icon-padding")*t.tilePixelRatio,I=Y(y.get("text-max-angle")),P="map"===y.get("text-rotation-alignment")&&"point"!==y.get("symbol-placement"),z="map"===y.get("icon-rotation-alignment")&&"point"!==y.get("symbol-placement"),k=y.get("symbol-placement"),T=M/2;var E;const B=y.get("icon-text-fit").evaluate(e,{},h),V=y.get("icon-text-fit-padding").evaluate(e,{},h),C="none"!==B;let R;!1===t.hasAnyIconTextFit&&C&&(t.hasAnyIconTextFit=!0),n&&C&&(t.allowVerticalPlacement&&r.vertical&&(R=Pf(n,r.vertical,B,V,g,w)),x&&(n=Pf(n,x,B,V,g,w)));const D=(a,o,m)=>{if(o.x<0||o.x>=Hr||o.y<0||o.y>=Hr)return;let y=null;if(b){const{x:t,y:e,z:r}=p.projectTilePoint(o.x,o.y,m);y={anchor:new zf(t,e,r,0,void 0),up:p.upVector(m,o.x,o.y)};}!function(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m,y,g,x,b,v,w,_,M,A,S,I){const P=t.addToLineVertexArray(e,n);let z,k,T,E,B,V,C,R=0,D=0,L=0,F=0,O=-1,U=-1;const j={};let N=xe("");const q=r?r.anchor:e,$="none"!==l.layout.get("icon-text-fit").evaluate(v,{},A);let G=0,X=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[G,X]=l.layout.get("text-offset").evaluate(v,{},A).map((t=>t*$p)):(G=l.layout.get("text-radial-offset").evaluate(v,{},A)*$p,X=nd),t.allowVerticalPlacement&&i.vertical){const t=i.vertical;if(d)V=fd(t),o&&(C=fd(o));else {const r=l.layout.get("text-rotate").evaluate(v,{},A)+90;T=pd(u,q,e,c,h,p,t,f,r,m),o&&(E=pd(u,q,e,c,h,p,o,g,r));}}if(s){const n=l.layout.get("icon-rotate").evaluate(v,{},A),i=Zf(s,n,_,$),a=o?Zf(o,n,_,$):void 0;k=pd(u,q,e,c,h,p,s,g,n),R=4*i.length;const f=t.iconSizeData;let d=null;"source"===f.kind?(d=[Gp*l.layout.get("icon-size").evaluate(v,{},A)],d[0]>ud&&ft(`${t.layerIds[0]}: Value for "icon-size" is >= ${ld}. Reduce your "icon-size".`)):"composite"===f.kind&&(d=[Gp*w.compositeIconSizes[0].evaluate(v,{},A),Gp*w.compositeIconSizes[1].evaluate(v,{},A)],(d[0]>ud||d[1]>ud)&&ft(`${t.layerIds[0]}: Value for "icon-size" is >= ${ld}. Reduce your "icon-size".`)),t.addSymbols(t.icon,i,d,b,x,v,!1,r,e,P.lineStartIndex,P.lineLength,-1,M,A,S,I),O=t.icon.placedSymbolArray.length-1,a&&(D=4*a.length,t.addSymbols(t.icon,a,d,b,x,v,ff.vertical,r,e,P.lineStartIndex,P.lineLength,-1,M,A,S,I),U=t.icon.placedSymbolArray.length-1);}for(const n in i.horizontal){const s=i.horizontal[n];z||(N=xe(s.text),d?B=fd(s):z=pd(u,q,e,c,h,p,s,f,l.layout.get("text-rotate").evaluate(v,{},A),m));const o=1===s.positionedLines.length;if(L+=cd(t,r,e,s,a,l,d,v,m,P,i.vertical?ff.horizontal:ff.horizontalOnly,o?Object.keys(i.horizontal):[n],j,O,w,M,A,S),o)break}i.vertical&&(F+=cd(t,r,e,i.vertical,a,l,d,v,m,P,ff.vertical,["vertical"],j,U,w,M,A,S));let Y=-1;const Z=(t,e)=>t?Math.max(t,e):e;Y=Z(B,Y),Y=Z(V,Y),Y=Z(C,Y);const W=Y>-1?1:0;t.glyphOffsetArray.length>=65535&&ft("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==v.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,v.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,q.x,q.y,q.z,j.right>=0?j.right:-1,j.center>=0?j.center:-1,j.left>=0?j.left:-1,j.vertical>=0?j.vertical:-1,O,U,N,void 0!==z?z:t.collisionBoxArray.length,void 0!==z?z+1:t.collisionBoxArray.length,void 0!==T?T:t.collisionBoxArray.length,void 0!==T?T+1:t.collisionBoxArray.length,void 0!==k?k:t.collisionBoxArray.length,void 0!==k?k+1:t.collisionBoxArray.length,E||t.collisionBoxArray.length,E?E+1:t.collisionBoxArray.length,c,L,F,R,D,W,0,G,X,Y,0,$?1:0);}(t,o,y,a,r,n,i,R,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,A,P,l,0,S,z,g,e,s,u,c,h,f,d);};if("line"===k)for(const i of Df(e.geometry,0,0,Hr,Hr)){const e=Cf(i,M,I,r.vertical||x,n,v,_,t.overscaling,Hr);for(const r of e)x&&dd(t,x.text,T,r)||D(i,r,h);}else if("line-center"===k){for(const t of e.geometry)if(t.length>1){const e=Vf(t,I,r.vertical||x,n,v,_);e&&D(t,e,h);}}else if("Polygon"===e.type)for(const t of Cc(e.geometry,0)){const e=td(t,16);D(t[0],new zf(e.x,e.y,0,0,void 0),h);}else if("LineString"===e.type)for(const t of e.geometry)D(t,new zf(t[0].x,t[0].y,0,0,void 0),h);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)D([e],new zf(e.x,e.y,0,0,void 0),h);}const ld=255,ud=ld*Gp;function cd(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m,y,g){const x=function(t,e,r,n,i,s,a,o){const l=[];if(0===e.positionedLines.length)return l;const u=n.layout.get("text-rotate").evaluate(s,{})*Math.PI/180,c=function(t){const e=t[0],r=t[1],n=e*r;return n>0?[e,-r]:n<0?[-e,r]:0===e?[r,e]:[r,-e]}(r);let h=Math.abs(e.top-e.bottom);for(const t of e.positionedLines)h-=t.lineOffset;const p=e.positionedLines.length,f=h/p;let d=e.top-r[1];for(let t=0;tud&&ft(`${t.layerIds[0]}: Value for "text-size" is >= ${ld}. Reduce your "text-size".`)):"composite"===b.kind&&(v=[Gp*d.compositeTextSizes[0].evaluate(o,{},y),Gp*d.compositeTextSizes[1].evaluate(o,{},y)],(v[0]>ud||v[1]>ud)&&ft(`${t.layerIds[0]}: Value for "text-size" is >= ${ld}. Reduce your "text-size".`)),t.addSymbols(t.text,x,v,l,a,o,c,e,r,u.lineStartIndex,u.lineLength,f,m,y,g,!1);for(const e of h)p[e]=t.text.placedSymbolArray.length-1;return 4*x.length}function hd(t){for(const e in t)return t[e];return null}function pd(t,e,r,n,i,s,a,o,l,u){let c=a.top,h=a.bottom,p=a.left,f=a.right;const d=a.collisionPadding;if(d&&(p-=d[0],c-=d[1],f+=d[2],h+=d[3]),l){const t=new q(p,c),e=new q(f,c),r=new q(p,h),n=new q(f,h),i=Y(l);let s=new q(0,0);u&&(s=new q(u[0],u[1])),t._rotateAround(i,s),e._rotateAround(i,s),r._rotateAround(i,s),n._rotateAround(i,s),p=Math.min(t.x,e.x,r.x,n.x),f=Math.max(t.x,e.x,r.x,n.x),c=Math.min(t.y,e.y,r.y,n.y),h=Math.max(t.y,e.y,r.y,n.y);}return t.emplaceBack(e.x,e.y,e.z,r.x,r.y,p,c,f,h,o,n,i,s),t.length-1}function fd(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function dd(t,e,r,n){const i=t.compareText;if(e in i){const t=i[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])b&&(v(t,u,n,i,o,l),v(u,r,o,l,s,a));}v(h,p,n,s,i,s),v(p,f,i,s,i,a),v(f,d,i,a,n,a),v(d,h,n,a,n,s),m-=b,y-=b,g+=b,x+=b;const w=1/Math.max(g-m,x-y);return {scale:w,x:m*w,y:y*w,x2:g*w,y2:x*w,projection:e}}function gd(t,{x:e,y:r},n=0){return new q(((e-n)*t.scale-t.x)*Hr,(r*t.scale-t.y)*Hr)}const xd=O.mat4.identity(new Float32Array(16));class bd{constructor(t){this.spec=t,this.name=t.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(t,e){return {x:0,y:0,z:0}}unproject(t,e){return new rl(0,0)}projectTilePoint(t,e,r){return {x:t,y:e,z:0}}locationPoint(t,e,r=!0){return t._coordinatePoint(t.locationCoordinate(e),r)}pixelsPerMeter(t,e){return ul(1,t)*e}pixelSpaceConversion(t,e,r){return 1}farthestPixelDistance(t){return md(t,t.pixelsPerMeter)}pointCoordinate(t,e,r,n){const i=t.horizonLineFromTop(!1),s=new q(e,Math.max(i,r));return t.rayIntersectionCoordinate(t.pointRayIntersection(s,n))}pointCoordinate3D(t,e,r){const n=new q(e,r);if(t.elevation)return t.elevation.pointCoordinate(n);{const e=this.pointCoordinate(t,n.x,n.y,0);return [e.x,e.y,e.z]}}isPointAboveHorizon(t,e){if(t.elevation&&t.elevation.visibleDemTiles.length)return !this.pointCoordinate3D(t,e.x,e.y);const r=t.horizonLineFromTop();return e.y0?e<-zd+r&&(e=-zd+r):e>zd-r&&(e=zd-r);const s=i/Math.pow(kd(e),n);let a=s*Math.sin(n*t),o=i-s*Math.cos(n*t);return a=.5*(a/Math.PI+.5),o=.5*(o/Math.PI+.5),{x:a,y:this.southernCenter?o:1-o,z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,this.southernCenter&&(e=1-e),e=(2*(1-e)-.5)*Math.PI;const{n:r,f:n}=this,i=n-e,s=Math.sign(i),a=Math.sign(r)*Math.sqrt(t*t+i*i);let o=Math.atan2(t,Math.abs(i))*s;i*r<0&&(o-=Math.PI*Math.sign(t)*s);const l=Q(Z(o/r)+this.center[0],-180,180),u=Q(Z(2*Math.atan(Math.pow(n/a,1/r))-zd),-fl,fl);return new rl(l,this.southernCenter?-u:u)}}class Ed extends bd{constructor(t){super(t),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null;}project(t,e){return {x:ol(t),y:ll(e),z:0}}unproject(t,e){const r=cl(t),n=hl(e);return new rl(r,n)}}const Bd=Y(fl);class Vd extends bd{project(t,e){const r=(e=Y(e))*e,n=r*r;return {x:.5*((t=Y(t))*(.8707-.131979*r+n*(n*(.003971*r-.001529*n)-.013791))/Math.PI+.5),y:1-.5*(e*(1.007226+r*(.015085+n*(.028874*r-.044475-.005916*n)))/Math.PI+1),z:0}}unproject(t,e){t=(2*t-.5)*Math.PI;let r=e=(2*(1-e)-1)*Math.PI,n=25,i=0,s=r*r;do{s=r*r;const t=s*s;i=(r*(1.007226+s*(.015085+t*(.028874*s-.044475-.005916*t)))-e)/(1.007226+s*(.045255+t*(.259866*s-.311325-.005916*11*t))),r=Q(r-i,-Bd,Bd);}while(Math.abs(i)>1e-6&&--n>0);s=r*r;const a=Q(Z(t/(.8707+s*(s*(s*s*s*(.003971-.001529*s)-.013791)-.131979))),-180,180),o=Z(r);return new rl(a,o)}}const Cd=Y(fl);class Rd extends bd{project(t,e){e=Y(e),t=Y(t);const r=Math.cos(e),n=2/Math.PI,i=Math.acos(r*Math.cos(t/2)),s=Math.sin(i)/i,a=.5*(t*n+2*r*Math.sin(t/2)/s)||0,o=.5*(e+Math.sin(e)/s)||0;return {x:.5*(a/Math.PI+.5),y:1-.5*(o/Math.PI+1),z:0}}unproject(t,e){let r=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,i=25;const s=1e-6;let a=0,o=0;do{const i=Math.cos(n),s=Math.sin(n),l=2*s*i,u=s*s,c=i*i,h=Math.cos(r/2),p=Math.sin(r/2),f=2*h*p,d=p*p,m=1-c*h*h,y=m?1/m:0,g=m?Math.acos(i*h)*Math.sqrt(1/m):0,x=.5*(2*g*i*p+2*r/Math.PI)-t,b=.5*(g*s+n)-e,v=.5*y*(c*d+g*i*h*u)+1/Math.PI,w=y*(f*l/4-g*s*p),_=.125*y*(l*p-g*s*c*f),M=.5*y*(u*h+g*d*i)+.5,A=w*_-M*v;a=(b*w-x*M)/A,o=(x*_-b*v)/A,r=Q(r-a,-Math.PI,Math.PI),n=Q(n-o,-Cd,Cd);}while((Math.abs(a)>s||Math.abs(o)>s)&&--i>0);return new rl(Z(r),Z(n))}}class Dd extends bd{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Y(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0;}project(t,e){const{scale:r,cosPhi:n}=this;return {x:Y(t)*n*r+.5,y:-Math.sin(Y(e))/n*r+.5,z:0}}unproject(t,e){const{scale:r,cosPhi:n}=this,i=-(e-.5)/r,s=Q(Z((t-.5)/r)/n,-180,180),a=Math.asin(Q(i*n,-1,1)),o=Q(Z(a),-fl,fl);return new rl(s,o)}}class Ld extends Ed{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5];}projectTilePoint(t,e,r){const n=zu(t,e,r),i=Eu(_u(r));return O.vec3.transformMat4(n,n,i),{x:n[0],y:n[1],z:n[2]}}locationPoint(t,e){const r=Qo(e.lat,e.lng),n=O.vec3.normalize([],r),i=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(e),t._centerAltitude):t._centerAltitude,s=ul(1,0)*Hr*i;O.vec3.scaleAndAdd(r,r,n,s);const a=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(a,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(r,r,a),new q(r[0],r[1])}pixelsPerMeter(t,e){return ul(1,0)*e}pixelSpaceConversion(t,e,r){const n=ul(1,t)*e,i=ke(ul(1,45)*e,n,r);return this.pixelsPerMeter(t,e)/i}createTileMatrix(t,e,r){const n=Bu(_u(r.canonical));return O.mat4.multiply(new Float64Array(16),t.globeMatrix,n)}createInversionMatrix(t,e){const{center:r}=t,n=Eu(_u(e));return O.mat4.rotateY(n,n,Y(r.lng)),O.mat4.rotateX(n,n,Y(r.lat)),O.mat4.scale(n,n,[t._pixelsPerMercatorPixel,t._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(t,e,r,n){return bu(t,e,r,!0)||new xl(0,0)}pointCoordinate3D(t,e,r){const n=this.pointCoordinate(t,e,r,0);return [n.x,n.y,n.z]}isPointAboveHorizon(t,e){return !bu(t,e.x,e.y,!1)}farthestPixelDistance(t){const e=function(t,e){const r=t.cameraToCenterDistance,n=t._centerAltitude*e,i=t._camera,s=t._camera.forward(),a=O.vec3.add([],O.vec3.scale([],s,-r),[0,0,n]),o=t.worldSize/(2*Math.PI),l=[0,0,-o],u=t.width/t.height,c=Math.tan(t.fovAboveCenter),h=O.vec3.scale([],i.up(),c),p=O.vec3.scale([],i.right(),c*u),f=O.vec3.normalize([],O.vec3.add([],O.vec3.add([],s,h),p)),d=[];let m;if(new uu(a,f).closestPointOnSphere(l,o,d)){const e=O.vec3.add([],d,l),r=O.vec3.sub([],e,a);m=Math.cos(t.fovAboveCenter)*O.vec3.length(r);}else {const t=O.vec3.sub([],a,l),e=O.vec3.sub([],l,a);O.vec3.normalize(e,e);const r=O.vec3.length(t)-o;m=Math.sqrt(r*(r+2*o));const n=Math.acos(m/(o+r))-Math.acos(O.vec3.dot(s,e));m*=Math.cos(n);}return 1.01*m}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),r=Du(t.zoom);if(r>0){const n=md(t,ul(1,t.center.lat)*t.worldSize),i=t.worldSize/(2*Math.PI),s=Math.max(t.width,t.height)/t.worldSize*Math.PI;return ke(e,n+i*(1-Math.cos(s)),Math.pow(r,10))}return e}upVector(t,e,r){return zu(e,r,t,1)}upVectorScale(t){return {metersToTile:gu(ku(_u(t)))}}}function Fd(t){const e=t.parallels,r=!!e&&Math.abs(e[0]+e[1])<.01;switch(t.name){case"mercator":return new Ed(t);case"equirectangular":return new Pd(t);case"naturalEarth":return new Vd(t);case"equalEarth":return new Id(t);case"winkelTripel":return new Rd(t);case"albers":return r?new Dd(t):new vd(t);case"lambertConformalConic":return r?new Dd(t):new Td(t);case"globe":return new Ld(t)}throw new Error(`Invalid projection name: ${t.name}`)}const Od=ch.VectorTileFeature.types,Ud=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function jd(t,e,r,n,i,s,a,o,l,u,c,h,p){const f=o?Math.min(ud,Math.round(o[0])):0,d=o?Math.min(ud,Math.round(o[1])):0;t.emplaceBack(e,r,Math.round(32*n),Math.round(32*i),s,a,(f<<1)+(l?1:0),d,16*u,16*c,256*h,256*p);}function Nd(t,e,r){t.emplaceBack(e,r);}function qd(t,e,r,n,i,s,a){t.emplaceBack(e,r,n,i,s,a);}function $d(t,e,r,n,i){t.emplaceBack(e,r,n,i),t.emplaceBack(e,r,n,i),t.emplaceBack(e,r,n,i),t.emplaceBack(e,r,n,i);}function Gd(t){for(const e of t.sections)if(vs(e.text))return !0;return !1}class Xd{constructor(t){this.layoutVertexArray=new za,this.indexArray=new Da,this.programConfigurations=t,this.segments=new co,this.dynamicLayoutVertexArray=new Ma,this.opacityVertexArray=new Ta,this.placedSymbolArray=new Ja,this.iconTransitioningVertexArray=new Ea,this.globeExtVertexArray=new ka,this.zOffsetVertexArray=new Oa;}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length&&0===this.iconTransitioningVertexArray.length}upload(t,e,r,n,i){this.isEmpty()||(r&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Rp.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,e),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,Lp.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,Ud,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Op.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,Dp.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||i)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Fp.members,!0)),this.opacityVertexBuffer.itemSize=1),(r||n)&&this.programConfigurations.upload(t));}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());}}os(Xd,"SymbolBuffers");class Yd{constructor(t,e,r){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new r,this.segments=new co,this.collisionVertexArray=new Ra,this.collisionVertexArrayExt=new Ma;}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Up.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,jp.members,!0);}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy());}}os(Yd,"CollisionBuffers");class Zd{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.lut=t.lut,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=O.mat4.identity([]),this.placementViewportMatrix=O.mat4.identity([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Xp(this.zoom,e["text-size"]),this.iconSizeData=Xp(this.zoom,e["icon-size"]);const r=this.layers[0].layout,n=r.get("symbol-sort-key"),i=r.get("symbol-z-order");this.canOverlap=r.get("text-allow-overlap")||r.get("icon-allow-overlap")||r.get("text-ignore-placement")||r.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==i&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===i||"auto"===i&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=r.get("text-writing-mode").map((t=>ff[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID,this.projection=t.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=r.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0;}createArrays(){this.text=new Xd(new Fo(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("text")||t.startsWith("symbol")))),this.icon=new Xd(new Fo(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("icon")||t.startsWith("symbol")))),this.glyphOffsetArray=new eo,this.lineVertexArray=new ro,this.symbolInstances=new to;}calculateGlyphDependencies(t,e,r,n,i){for(let r=0;r0)&&("constant"!==o.value.kind||o.value.value.length>0),h="constant"!==u.value.kind||!!u.value.value||Object.keys(u.parameters).length>0,p=s.get("symbol-sort-key");if(this.features=[],!c&&!h)return;const f=e.iconDependencies,d=e.glyphDependencies,m=e.availableImages,y=new Vs(this.zoom);for(const{feature:e,id:l,index:u,sourceLayerIndex:g}of t){const t=i._featureFilter.needGeometry,x=Pl(e,t);if(!i._featureFilter.filter(y,x,r))continue;if(t||(x.geometry=Il(e,r,n)),a&&1!==e.type&&r.z<=5){const t=x.geometry,e=.98078528056,n=(t,n)=>{const i=zu(t.x,t.y,r,1),s=zu(n.x,n.y,r,1);return O.vec3.dot(i,s)=0;for(const r of b.sections)if(r.image)f[r.image.namePrimary]=!0;else {const n=fs(b.toString()),i=r.fontStack||t,s=d[i]=d[i]||{};this.calculateGlyphDependencies(r.text,s,e,this.allowVerticalPlacement,n);}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},r={},n=[];let i=0;function s(e){n.push(t[e]),i++;}function a(t,e,i){const s=r[t];return delete r[t],r[e]=s,n[s].geometry[0].pop(),n[s].geometry[0]=n[s].geometry[0].concat(i[0]),s}function o(t,r,i){const s=e[r];return delete e[r],e[t]=s,n[s].geometry[0].shift(),n[s].geometry[0]=i[0].concat(n[s].geometry[0]),s}function l(t,e,r){const n=r?e[0][e[0].length-1]:e[0][0];return `${t}:${n.x}:${n.y}`}for(let u=0;ut.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey));}update(t,e,r,n,i){const s=0!==Object.keys(t).length;if(s&&!this.stateDependentLayers.length)return;const a=s?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,a,r,n,i),this.icon.programConfigurations.updatePaintArrays(t,e,a,r,n,i);}updateZOffset(){const t=(t,e,n)=>{r+=e,r>t.length&&t.resize(r);for(let i=-e;i<0;i++)t.emplace(i+r,n);},e=(t,e,r)=>{n+=e,n>t.length&&t.resize(n);for(let i=-e;i<0;i++)t.emplace(i+n,r);};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let r=0,n=0;for(let r=0;r0;if((i>0||s>0)&&(t(this.text.zOffsetVertexArray,i,o),t(this.text.zOffsetVertexArray,s,o)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:r}=n;t>=0&&e(this.icon.zOffsetVertexArray,a,o),r>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,o);}}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(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0;}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy();}getProjection(){return this.projectionInstance||(this.projectionInstance=Fd(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();}addToLineVertexArray(t,e){const r=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:r}of e)this.lineVertexArray.emplaceBack(t,r);return {lineStartIndex:r,lineLength:this.lineVertexArray.length-r}}addSymbols(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m){const y=t.indexArray,g=t.layoutVertexArray,x=t.globeExtVertexArray,b=t.segments.prepareSegment(4*e.length,g,y,this.canOverlap?s.sortKey:void 0),v=this.glyphOffsetArray.length,w=b.vertexLength,_=this.allowVerticalPlacement&&a===ff.vertical?Math.PI/2:0,M=s.text&&s.text.sections;for(let n=0;n=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:n),s=Yp(this.textSizeData,t,i)/$p;return this.tilePixelRatio*s}getSymbolInstanceIconSize(t,e,r){const n=this.icon.placedSymbolArray.get(r),i=Yp(this.iconSizeData,t,n);return this.tilePixelRatio*i}_commitDebugCollisionVertexUpdate(t,e,r,n){t.emplaceBack(e,-r,-r,n),t.emplaceBack(e,r,-r,n),t.emplaceBack(e,r,r,n),t.emplaceBack(e,-r,r,n);}_updateTextDebugCollisionBoxes(t,e,r,n,i,s){for(let a=n;a0}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(t,e){const r=t.placedSymbolArray.get(e),n=r.vertexStartIndex+4*r.numGlyphs;for(let e=r.vertexStartIndex;en[t]-n[e]||i[e]-i[t])),s}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let t=0;tthis.symbolInstances.get(e).zOffset-this.symbolInstances.get(t).zOffset))}addToSortKeyRanges(t,e){const r=this.sortKeyRanges[this.sortKeyRanges.length-1];r&&r.sortKey===e?r.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1});}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);const{rightJustifiedTextSymbolIndex:r,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:i,verticalPlacedTextSymbolIndex:s,placedIconSymbolIndex:a,verticalPlacedIconSymbolIndex:o}=e;r>=0&&this.addIndicesForPlacedSymbol(this.text,r),n>=0&&n!==r&&this.addIndicesForPlacedSymbol(this.text,n),i>=0&&i!==n&&i!==r&&this.addIndicesForPlacedSymbol(this.text,i),s>=0&&this.addIndicesForPlacedSymbol(this.text,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a),o>=0&&this.addIndicesForPlacedSymbol(this.icon,o);}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray);}}}let Wd,Hd,Kd;os(Zd,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Zd.addDynamicAttributes=$d;class Jd{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Re,this.defaultValue=t;}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression);}outputDefined(){return !1}serialize(){return null}}os(Jd,"FormatSectionOverride",{omit:["defaultValue"]});const Qd=()=>Kd||(Kd={layout:Wd||(Wd=new Gs({"symbol-placement":new Ns(Xs.layout_symbol["symbol-placement"]),"symbol-spacing":new Ns(Xs.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ns(Xs.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new qs(Xs.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ns(Xs.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Ns(Xs.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new Ns(Xs.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Ns(Xs.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ns(Xs.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ns(Xs.layout_symbol["icon-rotation-alignment"]),"icon-size":new qs(Xs.layout_symbol["icon-size"]),"icon-text-fit":new qs(Xs.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new qs(Xs.layout_symbol["icon-text-fit-padding"]),"icon-image":new qs(Xs.layout_symbol["icon-image"]),"icon-rotate":new qs(Xs.layout_symbol["icon-rotate"]),"icon-padding":new Ns(Xs.layout_symbol["icon-padding"]),"icon-keep-upright":new Ns(Xs.layout_symbol["icon-keep-upright"]),"icon-offset":new qs(Xs.layout_symbol["icon-offset"]),"icon-anchor":new qs(Xs.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ns(Xs.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ns(Xs.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ns(Xs.layout_symbol["text-rotation-alignment"]),"text-field":new qs(Xs.layout_symbol["text-field"]),"text-font":new qs(Xs.layout_symbol["text-font"]),"text-size":new qs(Xs.layout_symbol["text-size"]),"text-max-width":new qs(Xs.layout_symbol["text-max-width"]),"text-line-height":new qs(Xs.layout_symbol["text-line-height"]),"text-letter-spacing":new qs(Xs.layout_symbol["text-letter-spacing"]),"text-justify":new qs(Xs.layout_symbol["text-justify"]),"text-radial-offset":new qs(Xs.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ns(Xs.layout_symbol["text-variable-anchor"]),"text-anchor":new qs(Xs.layout_symbol["text-anchor"]),"text-max-angle":new Ns(Xs.layout_symbol["text-max-angle"]),"text-writing-mode":new Ns(Xs.layout_symbol["text-writing-mode"]),"text-rotate":new qs(Xs.layout_symbol["text-rotate"]),"text-padding":new Ns(Xs.layout_symbol["text-padding"]),"text-keep-upright":new Ns(Xs.layout_symbol["text-keep-upright"]),"text-transform":new qs(Xs.layout_symbol["text-transform"]),"text-offset":new qs(Xs.layout_symbol["text-offset"]),"text-allow-overlap":new Ns(Xs.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Ns(Xs.layout_symbol["text-ignore-placement"]),"text-optional":new Ns(Xs.layout_symbol["text-optional"]),visibility:new Ns(Xs.layout_symbol.visibility)})),paint:Hd||(Hd=new Gs({"icon-opacity":new qs(Xs.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new qs(Xs.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new qs(Xs.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new qs(Xs.paint_symbol["text-emissive-strength"]),"icon-color":new qs(Xs.paint_symbol["icon-color"]),"icon-halo-color":new qs(Xs.paint_symbol["icon-halo-color"]),"icon-halo-width":new qs(Xs.paint_symbol["icon-halo-width"]),"icon-halo-blur":new qs(Xs.paint_symbol["icon-halo-blur"]),"icon-translate":new Ns(Xs.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ns(Xs.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new qs(Xs.paint_symbol["icon-image-cross-fade"]),"text-opacity":new qs(Xs.paint_symbol["text-opacity"]),"text-occlusion-opacity":new qs(Xs.paint_symbol["text-occlusion-opacity"]),"text-color":new qs(Xs.paint_symbol["text-color"],{runtimeType:Oe,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new qs(Xs.paint_symbol["text-halo-color"]),"text-halo-width":new qs(Xs.paint_symbol["text-halo-width"]),"text-halo-blur":new qs(Xs.paint_symbol["text-halo-blur"]),"text-translate":new Ns(Xs.paint_symbol["text-translate"]),"text-translate-anchor":new Ns(Xs.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Ns(Xs.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Ns(Xs.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Ns(Xs.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Ns(Xs.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new qs(Xs.paint_symbol["symbol-z-offset"]),"symbol-elevation-reference":new Ns(Xs.paint_symbol["symbol-elevation-reference"])}))},Kd);class tm extends pa{constructor(t,e,r,n){super(t,Qd(),e,r,n),this._colorAdjustmentMatrix=O.mat4.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==t.paint&&("icon-occlusion-opacity"in t.paint||"text-occlusion-opacity"in t.paint);}recalculate(t,e){super.recalculate(t,e),"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 r=this.layout.get("text-writing-mode");if(r){const t=[];for(const e of r)t.indexOf(e)<0&&t.push(e);this.layout._values["text-writing-mode"]=t;}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides();}getColorAdjustmentMatrix(t,e,r,n){return this._saturation===t&&this._contrast===e&&this._brightnessMin===r&&this._brightnessMax===n||(this._colorAdjustmentMatrix=function(t,e,r,n){t=St(t),e=At(e);const i=O.mat4.create(),s=t/3,a=1-2*s,o=[a,s,s,0,s,a,s,0,s,s,a,0,0,0,0,1],l=.5-.5*e,u=n-r;return O.mat4.multiply(i,[u,0,0,0,0,u,0,0,0,0,u,0,r,r,r,1],[e,0,0,0,0,e,0,0,0,0,e,0,l,l,l,1]),O.mat4.multiply(i,i,o),i}(t,e,r,n),this._saturation=t,this._contrast=e,this._brightnessMin=r,this._brightnessMax=n),this._colorAdjustmentMatrix}getValueAndResolveTokens(t,e,r,n){const i=this.layout.get(t).evaluate(e,{},r,n),s=this._unevaluatedLayout._values[t];return s.isDataDriven()||Wi(s.value)||!i?i:function(t,e){return e.replace(/{([^{}]+)}/g,((e,r)=>r in t?String(t[r]):""))}(e.properties,i)}createBucket(t){return new Zd(t)}queryRadius(){return 0}queryIntersectsFeature(){return !1}_setPaintOverrides(){for(const t of Qd().paint.overridableProperties){if(!tm.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),r=new Jd(e),n=new Zi(r,e.property.specification,this.scope,this.options);let i=null;i="constant"===e.value.kind||"source"===e.value.kind?new Ki("source",n):new Ji("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new Us(e.property,i,e.parameters);}}_handleOverridablePaintPropertyUpdate(t,e,r){return !(!this.layout||e.isDataDriven()||r.isDataDriven())&&tm.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const r=t.get("text-field"),n=Qd().paint.properties[e];let i=!1;const s=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(i=!0)};if("constant"===r.value.kind&&r.value.value instanceof Qe)s(r.value.value.sections);else if("source"===r.value.kind){const t=e=>{i||(e instanceof sr&&nr(e.value)===qe?s(e.value.sections):e instanceof ur?s(e.sections):e.eachChild(t));},e=r.value;e._styleExpression&&t(e._styleExpression.expression);}return i}getProgramIds(){return ["symbol"]}getDefaultProgramParams(t,e,r){return {config:new Lo(this,{zoom:e,lut:r}),overrideFog:!1}}}let em,rm,nm,im;var sm=ya([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function am(t){switch(t){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 om(t){switch(t){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 lm{constructor(t,e,r,n){this.context=t,this.format=r,this.useMipmap=n&&n.useMipmap,this.texture=t.gl.createTexture(),this.update(e,{premultiply:n&&n.premultiply});}update(t,e){const r=t&&t instanceof HTMLVideoElement&&0===t.width?t.videoWidth:t.width,n=t&&t instanceof HTMLVideoElement&&0===t.height?t.videoHeight:t.height,{context:i}=this,{gl:s}=i,{x:a,y:o}=e&&e.position?e.position:{x:0,y:0},l=Math.max(a+r,this.size?this.size[0]:0),u=Math.max(o+n,this.size?this.size[1]:0);!this.size||this.size[0]===l&&this.size[1]===u||(s.bindTexture(s.TEXTURE_2D,null),s.deleteTexture(this.texture),this.texture=s.createTexture(),this.size=null),s.bindTexture(s.TEXTURE_2D,this.texture),i.pixelStoreUnpackFlipY.set(!1),i.pixelStoreUnpack.set(1),i.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA8&&(!e||!1!==e.premultiply));const c=t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap;if(!this.size&&l>0&&u>0){const t=this.useMipmap?Math.floor(Math.log2(Math.max(l,u)))+1:1;s.texStorage2D(s.TEXTURE_2D,t,this.format,l,u),this.size=[l,u];}if(this.size)if(c)s.texSubImage2D(s.TEXTURE_2D,0,a,o,am(this.format),om(this.format),t);else {const e=t.data;e&&s.texSubImage2D(s.TEXTURE_2D,0,a,o,r,n,am(this.format),om(this.format),e);}this.useMipmap&&s.generateMipmap(s.TEXTURE_2D);}bind(t,e,r=!1){const{context:n}=this,{gl:i}=n;i.bindTexture(i.TEXTURE_2D,this.texture),t!==this.minFilter&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,this.useMipmap&&!r?t===i.NEAREST?i.NEAREST_MIPMAP_NEAREST:i.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,e),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,e),this.wrapS=e);}bindExtraParam(t,e,r,n){const{context:i}=this,{gl:s}=i;s.bindTexture(s.TEXTURE_2D,this.texture),e!==this.magFilter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,this.useMipmap?t===s.NEAREST?s.NEAREST_MIPMAP_NEAREST:s.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),r!==this.wrapS&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,r),this.wrapS=r),n!==this.wrapT&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,n),this.wrapT=n);}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null;}}class um{constructor(t,e){this.context=t,this.texture=e;}bind(t,e){const{context:r}=this,{gl:n}=r;n.bindTexture(n.TEXTURE_2D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrapS=e);}}function cm(t,e,r,n,i,s,a,o){const l=[t,e,1,r,n,1,i,s,1],u=[a,o,1],c=O.mat3.adjoint([],l),[h,p,f]=O.vec3.transformMat3(u,u,c);return O.mat3.multiply(l,l,[h,0,0,0,p,0,0,0,f])}function hm(t,e,r,n,i,s,a,o){const l=function(t,e,r,n,i,s,a,o){const l=cm(0,0,1,0,1,1,0,1),u=cm(t,e,r,n,i,s,a,o),c=O.mat3.adjoint([],l);return O.mat3.multiply(u,u,c)}(t,e,r,n,i,s,a,o);return [l[2]/l[8]/Hr,l[5]/l[8]/Hr]}function pm(t){return [t[0],Math.min(Math.max(t[1],-fl),fl)]}class fm extends Me{constructor(t,e,r,n){super(),this.id=t,this.dispatcher=r,this.coordinates=e.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=e,this._dirty=!1;}load(t,e){if(this._loaded=e||!1,this.fire(new be("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=ce(this.map._requestManager.transformRequest(this.url,ee.Image),((e,r)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new ve(e)):r&&(this.image=r instanceof HTMLImageElement?Dt.getImageData(r):r,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading());}));}loaded(){return this._loaded}updateImage(t){return t.url?(this._imageRequest&&t.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}setTexture(t){if(!(t.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new um(this.map.painter.context,t.handle),this.width=t.dimensions[0],this.height=t.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new be("data",{dataType:"source",sourceDataType:"metadata"})));}onAdd(t){this.map=t,this.load();}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof um||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy());}setCoordinates(t){if(this.coordinates=t,this._boundsArray=void 0,this._unsupportedCoords=!1,!t.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let e=t[0][1],r=t[0][1];for(const n of t)n[1]>r&&(r=n[1]),n[1]fl?this.onNorthPole=!0:n<-fl&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const e=t.map(xl.fromLngLat);this.tileID=function(t){let e=1/0,r=1/0,n=-1/0,i=-1/0;for(const s of t)e=Math.min(e,s.x),r=Math.min(r,s.y),n=Math.max(n,s.x),i=Math.max(i,s.y);const s=Math.max(n-e,i-r),a=Math.max(0,Math.floor(-Math.log(s)/Math.LN2)),o=Math.pow(2,a);let l=Math.floor((e+n)/2*o);return l>1&&(l-=1),new tu(a,l,Math.floor((r+i)/2*o))}(e),this.minzoom=this.maxzoom=this.tileID.z;}return this.fire(new be("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1;}_prepareData(t){for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture);}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const e=yd(new tu(0,0,0),this.map.transform.projection),r=[e.projection.project(this.coordinates[0][0],this.coordinates[0][1]),e.projection.project(this.coordinates[1][0],this.coordinates[1][1]),e.projection.project(this.coordinates[2][0],this.coordinates[2][1]),e.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,r=t[1].y-t[0].y,n=t[2].x-t[1].x,i=t[2].y-t[1].y,s=t[3].x-t[2].x,a=t[3].y-t[2].y,o=t[0].x-t[3].x,l=t[0].y-t[3].y,u=e*i-n*r,c=n*a-s*i,h=s*l-o*a,p=o*r-e*l;return u>0&&c>0&&h>0&&p>0||u<0&&c<0&&h<0&&p<0}(r))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const n=yd(this.tileID,this.map.transform.projection),[i,s,a,o]=this.coordinates.map((t=>{const e=n.projection.project(t[0],t[1]);return gd(n,e)._round()}));this.perspectiveTransform=hm(i.x,i.y,s.x,s.y,a.x,a.y,o.x,o.y);const l=this._boundsArray=new va;l.emplaceBack(i.x,i.y,0,0),l.emplaceBack(s.x,s.y,Hr,0),l.emplaceBack(o.x,o.y,0,Hr),l.emplaceBack(a.x,a.y,Hr,Hr),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=t.createVertexBuffer(l,sm.members),this.boundsSegments=co.simpleSegment(0,0,4,2);const u=[],c=[pm((h=this.coordinates)[0]),pm(h[1]),pm(h[2]),pm(h[3])];var h;const[p,f,d,m]=function(t){let e=t[0][0],r=e,n=t[0][1],i=n;for(let s=1;sr&&(r=t[s][0]),t[s][1]i&&(i=t[s][1]);return [e,n,r-e,i-n]}(c);{const n=new va,[i,s,a,o]=function(t){let e=t[0].x,r=e,n=t[0].y,i=n;for(let s=1;sr&&(r=t[s].x),t[s].yi&&(i=t[s].y);return [e,n,r-e,i-n]}(r),l=t=>[(t.x-i)/a,(t.y-s)/o],[c,h,y,g]=r.map(l),x=function(t,e,r,n,i,s,a,o){const l=cm(0,0,1,0,1,1,0,1),u=cm(t,e,r,n,i,s,a,o),c=O.mat3.adjoint([],u);return O.mat3.multiply(l,l,c)}(c[0],c[1],h[0],h[1],y[0],y[1],g[0],g[1]);this.elevatedGlobePerspectiveTransform=hm(c[0],c[1],h[0],h[1],y[0],y[1],g[0],g[1]);const b=(t,e)=>{u.push(t.lng);const r=Math.round((t.lng-p)/d*Hr),i=Math.round((t.lat-f)/m*Hr),s=l(e),a=O.vec3.transformMat3([],[s[0],s[1],1],x),o=Math.round(a[0]/a[2]*Hr),c=Math.round(a[1]/a[2]*Hr);n.emplaceBack(r,i,o,c);},v=r[3].x-r[0].x,w=r[3].y-r[0].y,_=r[2].x-r[1].x,M=r[2].y-r[1].y;for(let t=0;t<65;t++){const n=t/64,i=[r[0].x+n*v,r[0].y+n*w],s=[r[1].x+n*_,r[1].y+n*M],a=s[0]-i[0],o=s[1]-i[1];for(let t=0;t<65;t++){const r=t/64,n={x:i[0]+a*r,y:i[1]+o*r,z:0};b(e.projection.unproject(n.x,n.y),n);}}this.elevatedGlobeVertexBuffer=t.createVertexBuffer(n,sm.members);}{this.maxLongitudeTriangleSize=0;let e=[],r=new Da;const n=(t,n,i)=>{r.emplaceBack(t,n,i);const s=u[t],a=u[n],o=u[i],l=Math.min(Math.min(s,a),o),c=Math.max(Math.max(s,a),o)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),e.push(l+c/2);};for(let t=0;t<64;t++)for(let e=0;e<64;e++){const r=65*t+e,i=r+1,s=r+65,a=s+1;n(r,s,i),n(i,s,a);}[e,r]=function(t,e){const r=Array.from({length:t.length},((t,e)=>e));r.sort(((e,r)=>t[e]-t[r]));const n=[],i=new Da;for(let s=0;s{s.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:r,sortKey:void 0,vaos:{}});},o=.51*this.maxLongitudeTriangleSize;if(Math.abs(r[0]-n)<=o){const t=Mt(r,0,r.length,n+o);return t===r.length||a(t,_t(r,t+1,r.length,n+360-o)-t),s}n0){const r=function(t,e){const r=e.worldSize,n=ul(1,0)*r*ml(e.center.lat,e.zoom)/Vu(r),i=ul(1,e.center.lat)*r,s=O.mat4.identity([]);return O.mat4.rotateY(s,s,Y(e.center.lng)),O.mat4.rotateX(s,s,Y(e.center.lat)),O.mat4.translate(s,s,[0,0,$o]),O.mat4.scale(s,s,[n,n,n*i]),O.mat4.translate(s,s,[e.point.x-.5*r,e.point.y-.5*r,0]),O.mat4.multiply(s,s,t),O.mat4.multiply(s,e.globeMatrix,s)}(t,e);return function(t,e,r){const n=(t,e,r)=>{const n=O.vec3.length(t),i=O.vec3.length(e),s=Mu(t,e,r);return O.vec3.scale(s,s,1/O.vec3.length(s)*ke(n,i,r))},i=n([t[0],t[1],t[2]],[e[0],e[1],e[2]],r),s=n([t[4],t[5],t[6]],[e[4],e[5],e[6]],r),a=n([t[8],t[9],t[10]],[e[8],e[9],e[10]],r),o=Mu([t[12],t[13],t[14]],[e[12],e[13],e[14]],r);return [i[0],i[1],i[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],0,o[0],o[1],o[2],1]}(i,r,n)}return i}function Vm(t,e,r,n){const i=yu.projectAabbCorners(n,r);let s=Number.MAX_VALUE,a=-1;for(let t=0;tnew q(i[t][0],i[t][1]);let l;switch(a){case 0:case 6:l=[o(1),o(5),o(4),o(7),o(3),o(2),o(1)];break;case 1:case 7:l=[o(0),o(4),o(5),o(6),o(2),o(3),o(0)];break;case 3:case 5:l=[o(1),o(0),o(4),o(7),o(6),o(2),o(1)];break;default:l=[o(1),o(5),o(6),o(7),o(3),o(0),o(1)];}if(El(t,l))return s}const Cm=ya([{name:"a_pos_3f",components:3,type:"Float32"}]),Rm=ya([{name:"a_color_3f",components:3,type:"Float32"}]),Dm=ya([{name:"a_color_4f",components:4,type:"Float32"}]),Lm=ya([{name:"a_uv_2f",components:2,type:"Float32"}]),Fm=ya([{name:"a_normal_3f",components:3,type:"Float32"}]),Om=ya([{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"}]),Um=ya([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]),jm={None:0,Model:1,Symbol:2,FillExtrusion:4,All:7};class Nm{constructor(t,e,r,n){this.message=(t?`${t}: `:"")+r,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__);}}function qm(t,e){const r=-1===t.indexOf("://");try{return new URL(t,r&&e?"http://example.com":void 0),!0}catch(t){return !1}}class $m{constructor(t,e){this.feature=t,this.instancedDataOffset=e,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0];}}class Gm{constructor(){this.instancedDataArray=new Ga,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={};}}class Xm{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.projection=t.projection,this.index=t.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.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?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;}updateFootprints(t,e){}populate(t,e,r,n){this.tileToMeter=gl(r);const i=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:s,id:a,index:o,sourceLayerIndex:l}of t){const t=null!=a?a:s.properties&&s.properties.hasOwnProperty("id")?s.properties.id:void 0,u=Pl(s,i);if(!this.layers[0]._featureFilter.filter(new Vs(this.zoom),u,r))continue;const c={id:t,sourceLayerIndex:l,index:o,geometry:i?u.geometry:Il(s,r,n),properties:s.properties,type:s.type,patterns:{}},h=this.addFeature(c,c.geometry,u);h&&e.featureIndex.insert(s,c.geometry,o,l,this.index,this.instancesPerModel[h].instancedDataArray.length,Hr/32);}this.lookup=null;}update(t,e,r,n){for(const e in this.instancesPerModel){const r=this.instancesPerModel[e];for(const e in t)r.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(r.features[r.idToFeaturesIndex[e]],t[e],r,!0),this.uploaded=!1);}this.maxHeight=0;}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return !1;let t=!1;for(const e in this.instancesPerModel){const r=this.instancesPerModel[e];for(const e of r.features){const n=this.layers[0],i=e.feature,s=this.canonical,a=n.paint.get("model-rotation").evaluate(i,{},s),o=n.paint.get("model-scale").evaluate(i,{},s),l=n.paint.get("model-translation").evaluate(i,{},s);O.vec3.exactEquals(e.rotation,a)&&O.vec3.exactEquals(e.scale,o)&&O.vec3.exactEquals(e.translation,l)||(this.evaluate(e,e.featureStates,r,!0),t=!0);}}return t}updateReplacement(t,e,r,n){if(e.updateTime===this.replacementUpdateTime)return !1;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(wh(this.activeReplacements,i))return !1;this.activeReplacements=i;let s=!1;for(const e in this.instancesPerModel){const i=this.instancesPerModel[e],a=i.instancedDataArray;for(const e of i.features){const i=e.instancedDataOffset,o=e.instancedDataCount;for(let e=0;eHr;l=u?l-Hr:l;const c=Math.floor(l),h=a.float32[o+1];let p=!1;for(const e of this.activeReplacements)if(!gh(e,r,jm.Model,n)&&!(e.min.x>c||c>e.max.x||e.min.y>h||h>e.max.y)&&(p=Ph(Ih(c,h,t.canonical,e.footprintTileId.canonical),e.footprint),p))break;a.float32[o]=p?l+Hr:l,s=s||p!==u;}}}return s}isEmpty(){for(const t in this.instancesPerModel)if(0!==this.instancesPerModel[t].instancedDataArray.length)return !1;return !0}uploadPending(){return !this.uploaded}upload(t){if(!this.uploaded)for(const e in this.instancesPerModel){const r=this.instancesPerModel[e];r.instancedDataArray.length<0||0===r.instancedDataArray.length||(r.instancedDataBuffer?r.instancedDataBuffer.updateData(r.instancedDataArray):r.instancedDataBuffer=t.createVertexBuffer(r.instancedDataArray,Om.members,!0,void 0,this.instanceCount));}this.uploaded=!0;}destroy(){for(const t in this.instancesPerModel){const e=this.instancesPerModel[t];0!==e.instancedDataArray.length&&e.instancedDataBuffer&&e.instancedDataBuffer.destroy();}const t=this.layers[0].modelManager;if(t&&this.modelUris)for(const e of this.modelUris)t.removeModel(e,"");}addFeature(t,e,r){const n=this.layers[0],i=n.layout.get("model-id").evaluate(r,{},this.canonical);if(!i)return ft(`modelId is not evaluated for layer ${n.id} and it is not going to get rendered.`),i;qm(i,!1)&&(this.modelUris.includes(i)||this.modelUris.push(i)),this.instancesPerModel[i]||(this.instancesPerModel[i]=new Gm);const s=this.instancesPerModel[i],a=s.instancedDataArray,o=new $m(r,a.length);for(const t of e)for(const e of t){if(e.x<0||e.x>=Hr||e.y<0||e.y>=Hr)continue;const t=(this.lookupDim-1)/Hr,r=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[r])continue;this.lookup[r]=1;}this.instanceCount++;const n=a.length;a.resize(n+1),s.instancesEvaluatedElevation.push(0),a.float32[16*n]=e.x,a.float32[16*n+1]=e.y;}return o.instancedDataCount=s.instancedDataArray.length-o.instancedDataOffset,o.instancedDataCount>0&&(t.id&&(s.idToFeaturesIndex[t.id]=s.features.length),s.features.push(o),this.evaluate(o,{},s,!1)),i}getModelUris(){return this.modelUris}evaluate(t,e,r,n){const i=this.layers[0],s=t.feature,a=this.canonical,o=t.rotation=i.paint.get("model-rotation").evaluate(s,e,a),l=t.scale=i.paint.get("model-scale").evaluate(s,e,a),u=t.translation=i.paint.get("model-translation").evaluate(s,e,a),c=i.paint.get("model-color").evaluate(s,e,a);c.a=i.paint.get("model-color-mix-intensity").evaluate(s,e,a);const h=[];this.maxVerticalOffset10?this.tileToMeter:gl(a,f)),o[s+4]=u[0],o[s+5]=u[1],o[s+6]=u[2]+l,o[s+7]=h[0],o[s+8]=h[1],o[s+9]=h[2],o[s+10]=h[4],o[s+11]=h[5],o[s+12]=h[6],o[s+13]=h[8],o[s+14]=h[9],o[s+15]=h[10],r.instancesEvaluatedElevation[i]=u[2];}}}let Ym,Zm;os(Xm,"ModelBucket",{omit:["layers"]}),os(Gm,"PerModelAttributes"),os($m,"ModelFeature");const Wm=64,Hm={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Km(t,e,r,n,i,s,a,o,l,u=!1){const c=r.zoom,h=r.project(n),p=ml(n.lat,c),f=1/p;O.mat4.identity(t),O.mat4.translate(t,t,[h.x+a[0]*f,h.y+a[1]*f,a[2]]);let d=1,m=1;const y=r.worldSize;if(u){if("mercator"===r.projection.name){let t=0;r.elevation&&(t=r.elevation.getAtPointOrZero(new xl(h.x/y,h.y/y),0));const e=O.vec4.transformMat4([],[h.x,h.y,t,1],r.projMatrix)[3]/r.cameraToCenterDistance;d=e,m=e*ml(r.center.lat,c);}else if("globe"===r.projection.name){const e=Bm(t,r),i=O.mat4.multiply([],r.projMatrix,e),s=[0,0,0,1];O.vec4.transformMat4(s,s,i);const a=s[3]/r.cameraToCenterDistance,o=Du(c),l=r.projection.pixelsPerMeter(n.lat,y)*ml(n.lat,c),u=r.projection.pixelsPerMeter(r.center.lat,y)*ml(r.center.lat,c);d=a/ke(l,dl(r.center.lat),o),m=a*p/l,d*=u,m*=u;}}else d=f;O.mat4.scale(t,t,[d,d,m]);const g=[...t],x=e.orientation,b=[];if(Tm(b,[x[0]+i[0],x[1]+i[1],x[2]+i[2]],s),O.mat4.multiply(t,g,b),o&&r.elevation){let i=0;const s=[];if(l&&r.elevation){i=function(t,e,r,n,i){const s=e.elevation;if(!s)return 0;const a=yu.projectAabbCorners(r,n),o=ul(1,i.lat)*e.worldSize,l=function(t,e){const r=[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 i of n){const n=t[i.corners[0]],s=t[i.corners[1]],a=t[i.corners[2]],o=[s[0]-n[0],s[1]-n[1],e*(s[2]-n[2])],l=O.vec3.cross(o,o,[a[0]-n[0],a[1]-n[1],e*(a[2]-n[2])]);O.vec3.normalize(l,l),i.dotProductWithUp=O.vec3.dot(l,r);}return n.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),n[0].corners}(a,o),u=a[l[0]],c=a[l[1]],h=a[l[2]],p=a[l[3]],f=s.getAtPointOrZero(new xl(u[0]/e.worldSize,u[1]/e.worldSize),0),d=s.getAtPointOrZero(new xl(c[0]/e.worldSize,c[1]/e.worldSize),0),m=s.getAtPointOrZero(new xl(h[0]/e.worldSize,h[1]/e.worldSize),0),y=s.getAtPointOrZero(new xl(p[0]/e.worldSize,p[1]/e.worldSize),0),g=(f+y)/2,x=(d+m)/2;return g>x?d=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null);}function Qm(t,e,r){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,Cm.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,Fm.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,Lm.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?Rm:Dm).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,Um.members,!0)),t.segments=co.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&Jm(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&Jm(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&Jm(n.normalTexture,e),n.occlusionTexture&&Jm(n.occlusionTexture,e,r),n.emissionTexture&&Jm(n.emissionTexture,e);}function ty(t,e,r){if(t.meshes)for(const n of t.meshes)Qm(n,e,r);if(t.children)for(const n of t.children)ty(n,e,r);}function ey(t){if(t.meshes)for(const e of t.meshes)e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();if(t.children)for(const e of t.children)ey(e);}function ry(t){if(t.meshes)for(const r of t.meshes)r.vertexBuffer&&(r.vertexBuffer.destroy(),r.indexBuffer.destroy(),r.normalBuffer&&r.normalBuffer.destroy(),r.texcoordBuffer&&r.texcoordBuffer.destroy(),r.colorBuffer&&r.colorBuffer.destroy(),r.pbrBuffer&&r.pbrBuffer.destroy(),r.segments.destroy(),r.material&&((e=r.material).pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy()));var e;if(t.children)for(const e of t.children)ry(e);}class ny{constructor(t,e,r){this._demTile=t,this._dem=this._demTile.dem,this._scale=e,this._offset=r;}static create(t,e,r){const n=r||t.findDEMTileFor(e);if(!n||!n.dem)return;const i=n.dem,s=n.tileID,a=1<=t)continue;const h=iy[u],p=Math.abs(h);p>o&&(a=h,o=p,l=i,c=e);}if(o>.1){const s=1-(t+.5*Math.abs(l*c))/u;let o=e._dem.get(n,r)+a*s;const h=e._dem.get(n+l,r+c),p=e._dem.get(n-l,r-c,!0);(o-h)*(o-p)>0&&(o=(h+p)/2),iy[i]=e._dem.set(n,r,o),sy[i]=t;}}}}}a&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=Dt.now());}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)ey(e.node),ry(e.node);}isEmpty(){return !this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const r=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint));}}getHeightAtTileCoord(t,e){const r=this.getNodesInfo(),n=[],i=[0,0,0],s=O.mat4.identity([]);for(let a=0;au.max[0]||e>u.max[1])continue;if(!0===o.node.hidden)return {height:1/0,maxHeight:o.feature.properties.height,hidden:!1,verticalScale:o.evaluatedScale[2]};O.mat4.invert(s,o.node.matrix),i[0]=t,i[1]=e,O.vec3.transformMat4(i,i,s);const c=(i[0]-l.aabb.min[0])/(l.aabb.max[0]-l.aabb.min[0])*Wm|0,h=Math.min(63,(i[1]-l.aabb.min[1])/(l.aabb.max[1]-l.aabb.min[1])*Wm|0)*Wm+Math.min(63,c),p=l.heightmap[h];if(!(p<0&&o.node.footprint)){if(o.hiddenByReplacement)return;return {height:p,maxHeight:o.feature.properties.height,hidden:!1,verticalScale:o.evaluatedScale[2]}}if(o.node.footprint.grid.query(new q(t,e),new q(t,e),n),n.length>0)return {height:void 0,maxHeight:o.feature.properties.height,hidden:o.hiddenByReplacement,verticalScale:o.evaluatedScale[2]}}}}function hy(t,e){return !t.isLightConstant&&e}function py(t,e,r,n,i,s,a,o){let l=(61440&e|(61440&e)>>4)>>8,u=(3840&e|(3840&e)>>4)>>4,c=240&e|(240&e)>>4;r[3]>0&&(l=ke(l,255*r[0],r[3]),u=ke(u,255*r[1],r[3]),c=ke(c,255*r[2],r[3]));const h=l<<8|u,p=c<<8|Math.floor(255*n[3]),f=function(t){const e=Q(t,0,2);return Math.min(Math.round(.5*e*255),255)}(n[2])<<8|15*n[0]<<4|15*n[1],d=Q(i[0],0,1),m=Q(i[1],0,1),y=Q(i[2],0,1),g=Q(i[3],0,1);let x,b,v,w;if(d!==m&&a!==s&&m!==d){const t=a-s;b=1/(t*(m-d)),v=-(s+t*d)/(t*(m-d));const e=Q(i[4],-1,1);w=Math.pow(10,e),x=255*y<<8|255*g;}else x=65535,b=0,v=1,w=1;if(t.emplaceBack(h,p,f,x,b,v,w),o){const t=o.length;o.clear();for(let e=0;e>16&65535,o=s?e>>16&65535:65535&e,l=(15&o)<8?15&o:0,u=t.evaluatedRMEA[l],c=t.evaluatedColor[l],h=t.emissionHeightBasedParams[l];let p;if(a&&2===l&&n.lights&&(p=new Xa,p.resize(10*n.lights.length)),py(r.featureArray,i,c,u,h,r.aabb.min[2],r.aabb.max[2],p),p&&a){a=!1;const t=n.meshes[n.lightMeshIndex];t.featureArray=p,t.featureArray._trim();}}r.featureArray._trim(),i++;}}function dy(t,e,r,n){const i=1<t.polygon)).flat());const y=f?o:null,[g,x]=function(t,e,r,n,i,s,a,o,l,u,c){return "globe"===t.projection.name?function(t,e,r,n,i,s,a,o,l,u,c){const h=[],p=[],f=t.projection.upVectorScale(c,t.center.lat,t.worldSize).metersToTile,d=[0,0,0,1],m=[0,0,0,1],y=(t,e,r,n)=>{t[0]=e,t[1]=r,t[2]=n,t[3]=1;},g=rp();r>0&&(r+=g),n+=g;for(const g of e){const e=[],x=[];for(const h of g){const p=h.x+i.x,g=h.y+i.y,b=t.projection.projectTilePoint(p,g,c),v=t.projection.upVector(c,h.x,h.y);let w=r,_=n;if(a){const t=up(p,g,r,n,a,o,l,u);w+=t.base,_+=t.top;}0!==r?y(d,b.x+v[0]*f*w,b.y+v[1]*f*w,b.z+v[2]*f*w):y(d,b.x,b.y,b.z),y(m,b.x+v[0]*f*_,b.y+v[1]*f*_,b.z+v[2]*f*_),O.vec3.transformMat4(d,d,s),O.vec3.transformMat4(m,m,s),e.push(new hh(d[0],d[1],d[2])),x.push(new hh(m[0],m[1],m[2]));}h.push(e),p.push(x);}return [h,p]}(t,e,r,n,i,s,a,o,l,u,c):a?function(t,e,r,n,i,s,a,o,l){const u=[],c=[],h=[0,0,0,1];for(const p of t){const t=[],f=[];for(const u of p){const c=u.x+n.x,p=u.y+n.y,d=up(c,p,e,r,s,a,o,l);h[0]=c,h[1]=p,h[2]=d.base,h[3]=1,O.vec4.transformMat4(h,h,i),h[3]=Math.max(h[3],1e-5);const m=new hh(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=c,h[1]=p,h[2]=d.top,h[3]=1,O.vec4.transformMat4(h,h,i),h[3]=Math.max(h[3],1e-5);const y=new hh(h[0]/h[3],h[1]/h[3],h[2]/h[3]);t.push(m),f.push(y);}u.push(t),c.push(f);}return [u,c]}(e,r,n,i,s,a,o,l,u):function(t,e,r,n,i){const s=[],a=[],o=i[8]*e,l=i[9]*e,u=i[10]*e,c=i[11]*e,h=i[8]*r,p=i[9]*r,f=i[10]*r,d=i[11]*r;for(const e of t){const t=[],r=[];for(const s of e){const e=s.x+n.x,a=s.y+n.y,m=i[0]*e+i[4]*a+i[12],y=i[1]*e+i[5]*a+i[13],g=i[2]*e+i[6]*a+i[14],x=i[3]*e+i[7]*a+i[15],b=m+o,v=y+l,w=g+u,_=Math.max(x+c,1e-5),M=m+h,A=y+p,S=g+f,I=Math.max(x+d,1e-5);t.push(new hh(b/_,v/_,w/_)),r.push(new hh(M/I,A/I,S/I));}s.push(t),a.push(r);}return [s,a]}(e,r,n,i,s)}(s,n,h,c,u,a,y,p,d,s.center.lat,t.tileID.canonical),b=t.queryGeometry;return function(t,e,r){let n=1/0;Vl(r,e)&&(n=lp(r,e[0]));for(let i=0;i{if(Vp)return Vp;const t=Ep();return Vp=new Bp(t.paint.properties["line-width"].specification),Vp.useIntegerZoom=!0,Vp})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t);}createBucket(t){return new wp(t)}getProgramIds(){return [this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(t,e,r){const n=zp(this);return {config:new Lo(this,{zoom:e,lut:r}),defines:n,overrideFog:!1}}queryRadius(t){const e=t,r=Cp(Gl("line-width",this,e),Gl("line-gap-width",this,e)),n=Gl("line-offset",this,e);return r/2+Math.abs(n)+Xl(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,r,n,i,s){if(t.queryGeometry.isAboveHorizon)return !1;const a=Yl(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),s.angle,t.pixelToTileUnitsFactor),o=t.pixelToTileUnitsFactor/2*Cp(this.paint.get("line-width").evaluate(e,r),this.paint.get("line-gap-width").evaluate(e,r)),l=this.paint.get("line-offset").evaluate(e,r);return l&&(n=function(t,e){const r=[],n=new q(0,0);for(let i=0;i=3)for(let e=0;e{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 gy{constructor(){this.tasks={},this.taskQueue=[],ot(["process"],this),this.invoker=new yy(this.process),this.nextId=0;}add(t,e){const r=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:r}){return r=r||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-r:"maybePrepare"===t&&e?400-r:500:200-r:100-r}(e);if(0===n){try{t();}finally{}return null}return this.tasks[r]={fn:t,metadata:e,priority:n,id:r},this.taskQueue.push(r),this.invoker.trigger(),{cancel:()=>{delete this.tasks[r];}}}process(){try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn();}finally{}}pick(){let t=null,e=1/0;for(let r=0;r{r&&delete this.callbacks[a],this.target.postMessage({id:a,type:"",targetMapId:n,sourceMapId:this.mapId});}}}receive(t){const e=t.data,r=e.id;if(r&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[r];delete this.cancelCallbacks[r],t&&t.cancel();}else if(e.mustQueue||gt()){const t=this.callbacks[r],n=this.scheduler.add((()=>this.processTask(r,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[r]=n);}else this.processTask(r,e);}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const r=this.callbacks[t];delete this.callbacks[t],r&&(e.error?r(hs(e.error)):r(null,hs(e.data)));}else {const r=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?cs(e):null,data:cs(n,r)},r);}:t=>{},i=hs(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,i,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],i.source,i.scope)[t[1]](i,n);}else n(new Error(`Could not find function ${e.type}`));}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1);}}class by{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=st();const r=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0;}));}broadcast(t,e,r){rt(this.actors,((r,n)=>{r.send(t,e,n);}),r=r||function(){});}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove();})),this.actors=[],this.workerPool.release(this.id);}}by.Actor=xy;class vy{constructor(t){this.size=t,this.minimums=[],this.maximums=[],this.leaves=[];}getElevation(t,e){const r=this.toIdx(t,e);return {min:this.minimums[r],max:this.maximums[r]}}isLeaf(t,e){return this.leaves[this.toIdx(t,e)]}toIdx(t,e){return e*this.size+t}}function wy(t,e,r,n){let i=0,s=Number.MAX_VALUE;for(let a=0;a<3;a++)if(Math.abs(n[a])<1e-15){if(r[a]e[a])return null}else {const o=1/n[a];let l=(t[a]-r[a])*o,u=(e[a]-r[a])*o;if(l>u){const t=l;l=u,u=t;}if(l>i&&(i=l),us)return null}return i}function _y(t,e,r,n,i,s,a,o,l,u,c){const h=n-t,p=i-e,f=s-r,d=a-t,m=o-e,y=l-r,g=c[1]*y-c[2]*m,x=c[2]*d-c[0]*y,b=c[0]*m-c[1]*d,v=h*g+p*x+f*b;if(Math.abs(v)<1e-15)return null;const w=1/v,_=u[0]-t,M=u[1]-e,A=u[2]-r,S=(_*g+M*x+A*b)*w;if(S<0||S>1)return null;const I=M*f-A*p,P=A*h-_*f,z=_*p-M*h,k=(c[0]*I+c[1]*P+c[2]*z)*w;return k<0||S+k>1?null:(d*I+m*P+y*z)*w}function My(t,e,r){return (t-e)/(r-e)}function Ay(t,e,r,n,i,s,a,o,l){const u=1<{const s=n?1:0,a=(t+1)*r-s,o=e*r,l=(e+1)*r-s;i[0]=t*r,i[1]=o,i[2]=a,i[3]=l;};let a=new vy(n);const o=[];for(let e=0;e=1;n/=2){const t=r[r.length-1];a=new vy(n);for(let e=0;e0;){const{idx:o,t:f,nodex:d,nodey:m,depth:y}=p.pop();if(this.leaves[o]){Ay(d,m,y,t,e,r,n,c,h);const o=1<=t[2])return f}continue}let g=0;for(let p=0;p=l[u[r]]&&(u.splice(r,0,p),e=!0);e||(u[g]=p),g++;}}for(let t=0;t=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return (e+1)*this.stride+(t+1)}static pack(t,e){const r=[0,0,0,0],n=Ey.getUnpackVector(e);let i=Math.floor((t+n[3])/n[2]);return r[2]=i%256,i=Math.floor(i/256),r[1]=i%256,i=Math.floor(i/256),r[0]=i,r}getPixels(){return new sc({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,r){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,i=e*this.dim+this.dim,s=r*this.dim,a=r*this.dim+this.dim;switch(e){case-1:n=i-1;break;case 1:i=n+1;}switch(r){case-1:s=a-1;break;case 1:a=s+1;}const o=-e*this.dim,l=-r*this.dim;for(let e=s;e=1;n--){const i=1===n?1:0,s=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function qy(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&r)>>8|(240&n)<<4|61440&n,t[e+1]=15&r|(3840&r)>>4|(15&n)<<8|(3840&n)<<4;}return t;case"uint8":for(let e=0;e>6|(192&n)>>4|(192&i)>>2|192&s,t[e+1]=(48&r)>>4|(48&n)>>2|48&i|(48&s)<<2,t[e+2]=(12&r)>>2|12&n|(12&i)<<2|(12&s)<<4,t[e+3]=3&r|(3&n)<<2|(3&i)<<4|(3&s)<<6;}return t;default:throw new Error(`Invalid pixel format, "${e}"`)}}var $y=Uint8Array,Gy=Uint16Array,Xy=Int32Array,Yy=new $y([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]),Zy=new $y([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]),Wy=new $y([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Hy=function(t,e){for(var r=new Gy(31),n=0;n<31;++n)r[n]=e+=1<>1|(21845&rg)<<1;eg[rg]=((65280&(ng=(61680&(ng=(52428&ng)>>2|(13107&ng)<<2))>>4|(3855&ng)<<4))>>8|(255&ng)<<8)>>1;}var ig=function(t,e,r){for(var n=t.length,i=0,s=new Gy(e);i>l]=u;return a},sg=new $y(288);for(rg=0;rg<144;++rg)sg[rg]=8;for(rg=144;rg<256;++rg)sg[rg]=9;for(rg=256;rg<280;++rg)sg[rg]=7;for(rg=280;rg<288;++rg)sg[rg]=8;var ag=new $y(32);for(rg=0;rg<32;++rg)ag[rg]=5;var og=ig(sg,9),lg=ig(ag,5),ug=function(t){for(var e=t[0],r=1;re&&(e=t[r]);return e},cg=function(t,e,r){var n=e/8|0;return (t[n]|t[n+1]<<8)>>(7&e)&r},hg=function(t,e){var r=e/8|0;return (t[r]|t[r+1]<<8|t[r+2]<<16)>>(7&e)},pg=["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"],fg=function(t,e,r){var n=new Error(e||pg[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,fg),!r)throw n;return n},dg=new $y(0),mg="undefined"!=typeof TextDecoder&&new TextDecoder;try{mg.decode(dg,{stream:!0});}catch(t){}const yg={gzip_data:"gzip"};class gg extends Error{constructor(t){super(t),this.name="MRTError";}}const xg={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},bg={uint32:1,uint16:2,uint8:4},vg={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let wg;class _g{constructor(t=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t;}getLayer(t){const e=this.layers[t];if(!e)throw new gg(`Layer '${t}' not found`);return e}getHeaderLength(t){const e=new Uint8Array(t),r=new DataView(t);if(13!==e[0])throw new gg("File is not a valid MRT.");return r.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),r=this.getHeaderLength(t);if(e.length= ${r} but got buffer of length ${e.length}`);const n=function(t,e){return t.readFields(By,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new wg(e.subarray(0,r)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new gg(`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 t of n.layers)this.layers[t.name]=new Mg(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],r=this.getLayer(t.layerName);for(let n of t.blockIndices){const i=r.dataIndex[n],s=i.first_byte-t.firstByte,a=i.last_byte-t.firstByte;if(r._blocksInProgress.has(n))continue;const o={layerName:r.name,firstByte:s,lastByte:a,pixelFormat:r.pixelFormat,blockIndex:n,blockShape:[i.bands.length].concat(r.bandShape),buffer:r.buffer,codec:i.codec.codec,filters:i.filters.map((t=>t.filter))};r._blocksInProgress.add(n),e.push(o);}return new Ag(e,(()=>{e.forEach((t=>r._blocksInProgress.delete(t.blockIndex)));}),((t,n)=>{if(e.forEach((t=>r._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t);}));}))}}class Mg{constructor({version:t,name:e,units:r,tilesize:n,pixel_format:i,buffer:s,data_index:a},o){if(this.version=t,1!==this.version)throw new gg(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=r,this.tileSize=n,this.buffer=s,this.pixelFormat=xg[i],this.dataIndex=a,this.bandShape=[n+2*s,n+2*s,bg[this.pixelFormat]],this._decodedBlocks=new Uy(o?o.cacheSize:5),this._blocksInProgress=new Set;}get dimension(){return bg[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map((({bands:t})=>t)).flat()}processDecodedData(t){const e=t.blockIndex.toString();this._decodedBlocks.get(e)||this._decodedBlocks.put(e,t.data);}getBlockForBand(t){let e=0;switch(typeof t){case"string":for(const[r,n]of this.dataIndex.entries()){for(const[i,s]of n.bands.entries())if(s===t)return {bandIndex:e+i,blockIndex:r,blockBandIndex:i};e+=n.bands.length;}break;case"number":for(const[r,n]of this.dataIndex.entries()){if(t>=e&&tthis.cacheSize)throw new gg(`Number of blocks to decode (${i.size}) exceeds cache size (${this.cacheSize}).`);return {layerName:this.name,firstByte:e,lastByte:r,blockIndices:n}}hasBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:r}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new gg(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const i=this.dataIndex[e],s=this.bandShape.reduce(((t,e)=>t*e),1),a=r*s,o=n.subarray(a,a+s);return {data:o,bytes:new Uint8Array(o.buffer).subarray(o.byteOffset,o.byteOffset+o.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:0!==i.offset?i.offset:i.deprecated_offset,scale:0!==i.scale?i.scale:i.deprecated_scale}}}_g.setPbf=function(t){wg=t;};class Ag{constructor(t,e,r){this.tasks=t,this._onCancel=e,this._onComplete=r,this._finalized=!1;}cancel(){this._finalized||(this._onCancel(),this._finalized=!0);}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0);}}_g.performDecoding=function(t,e){const r=new Uint8Array(t);return Promise.all(e.tasks.map((t=>{const{layerName:e,firstByte:n,lastByte:i,pixelFormat:s,blockShape:a,blockIndex:o,filters:l,codec:u}=t,c=r.subarray(n,i+1),h=new Uint32Array(a[0]*a[1]*a[2]);let p;if("gzip_data"!==u)throw new gg(`Unhandled codec: ${u}`);return p=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((s=function(t){31==t[0]&&139==t[1]&&8==t[2]||fg(6,"invalid gzip data");var e=t[3],r=10;4&e&&(r+=2+(t[10]|t[11]<<8));for(var n=(e>>3&1)+(e>>4&1);n>0;n-=!t[r++]);return r+(2&e)}(i=t))+8>i.length&&fg(6,"invalid gzip data"),function(t,e,r,n){var i=t.length;if(!i||e.f&&!e.l)return r||new $y(0);var s=!r,a=s||2!=e.i,o=e.i;s&&(r=new $y(3*i));var l,u,c=function(t){var e=r.length;if(t>e){var n=new $y(Math.max(2*e,t));n.set(r),r=n;}},h=e.f||0,p=e.p||0,f=e.b||0,d=e.l,m=e.d,y=e.m,g=e.n,x=8*i;do{if(!d){h=cg(t,p,1);var b=cg(t,p+1,3);if(p+=3,!b){var v=t[(E=4+((p+7)/8|0))-4]|t[E-3]<<8,w=E+v;if(w>i){o&&fg(0);break}a&&c(f+v),r.set(t.subarray(E,w),f),e.b=f+=v,e.p=p=8*w,e.f=h;continue}if(1==b)d=og,m=lg,y=9,g=5;else if(2==b){var _=cg(t,p,31)+257,M=cg(t,p+10,15)+4,A=_+cg(t,p+5,31)+1;p+=14;for(var S=new $y(A),I=new $y(19),P=0;P>4)<16)S[P++]=E;else {var V=0,C=0;for(16==E?(C=3+cg(t,p,3),p+=2,V=S[P-1]):17==E?(C=3+cg(t,p,7),p+=3):18==E&&(C=11+cg(t,p,127),p+=7);C--;)S[P++]=V;}}var R=S.subarray(0,_),D=S.subarray(_);y=ug(R),g=ug(D),d=ig(R,y),m=ig(D,g);}else fg(1);if(p>x){o&&fg(0);break}}a&&c(f+131072);for(var L=(1<>4;if((p+=15&V)>x){o&&fg(0);break}if(V||fg(2),U<256)r[f++]=U;else {if(256==U){O=p,d=null;break}var j=U-254;U>264&&(j=cg(t,p,(1<<($=Yy[P=U-257]))-1)+Jy[P],p+=$);var N=m[hg(t,p)&F],q=N>>4;if(N||fg(3),p+=15&N,D=tg[q],q>3){var $=Zy[q];D+=hg(t,p)&(1<<$)-1,p+=$;}if(p>x){o&&fg(0);break}a&&c(f+131072);var G=f+j;if(fl.length)&&(u=l.length),new $y(l.subarray(0,u))):r.subarray(0,f)}(i.subarray(s,-8),{i:2},new $y(((r=i)[(n=r.length)-4]|r[n-3]<<8|r[n-2]<<16|r[n-1]<<24)>>>0))));var r,n,i,s;const a=yg[e];if(!a)throw new Error(`Unhandled codec: ${e}`);const o=new globalThis.DecompressionStream(a);return new Response(new Blob([t]).stream().pipeThrough(o)).arrayBuffer().then((t=>new Uint8Array(t)))}(c,u).then((t=>(function(t,e){t.readFields(Fy,e);}(new wg(t),h),new(0,vg[s])(h.buffer)))),p.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":jy(t,a);break;case"zigzag_filter":Ny(t);break;case"bitshuffle_filter":qy(t,s);break;default:throw new gg(`Unhandled filter "${l[e]}"`)}return {layerName:e,blockIndex:o,data:t}})).catch((t=>{throw t}))})))},os(Ag,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]});var Sg={workerUrl:"",workerClass:null,workerParams:void 0};const Ig="mapboxgl_preloaded_worker_pool";class Pg{constructor(){this.active={};}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate();})),this.workers=null);}isPreloaded(){return !!this.active[Ig]}numActive(){return Object.keys(this.active).length}}let zg;function kg(){return zg||(zg=new Pg),zg}Pg.workerCount=2;let Tg,Eg,Bg,Vg,Cg,Rg=null;function Dg(){return gt()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:Eg||It.DRACO_URL}function Lg(){if(gt()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(Vg)return Vg;const t=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]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return Vg=WebAssembly.validate(t)?It.MESHOPT_SIMD_URL:It.MESHOPT_URL,Vg}const Fg={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Og={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},Ug={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function jg(t,e,r){const n=r.json.bufferViews.length,i=r.buffers.length;e.bufferView=n,r.json.bufferViews[n]={buffer:i,byteLength:t.byteLength},r.buffers[i]=t;}const Ng="KHR_draco_mesh_compression";function qg(t,e){const r=t.extensions&&t.extensions[Ng];if(!r)return;const n=new Bg.Decoder,i=Hg(e,r.bufferView),s=new Bg.Mesh;if(!n.DecodeArrayToMesh(i,i.byteLength,s))throw new Error("Failed to decode Draco mesh");const a=e.json.accessors[t.indices],o=Fg[a.componentType],l=a.count*o.BYTES_PER_ELEMENT,u=Bg._malloc(l);o===Uint16Array?n.GetTrianglesUInt16Array(s,l,u):n.GetTrianglesUInt32Array(s,l,u),jg(Bg.memory.buffer.slice(u,u+l),a,e),Bg._free(u);for(const i of Object.keys(r.attributes)){const a=n.GetAttributeByUniqueId(s,r.attributes[i]),o=e.json.accessors[t.attributes[i]],l=Og[o.componentType],u=o.count*Ug[o.type]*Fg[o.componentType].BYTES_PER_ELEMENT,c=Bg._malloc(u);n.GetAttributeDataArrayForAllPoints(s,a,Bg[l],u,c),jg(Bg.memory.buffer.slice(c,c+u),o,e),Bg._free(c);}n.destroy(),s.destroy(),delete t.extensions[Ng];}const $g="EXT_meshopt_compression";function Gg(t,e){if(!t.extensions||!t.extensions[$g])return;const r=t.extensions[$g],n=new Uint8Array(e.buffers[r.buffer],r.byteOffset||0,r.byteLength||0),i=new Uint8Array(r.count*r.byteStride);Cg.decodeGltfBuffer(i,r.count,r.byteStride,n,r.mode,r.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=i.buffer,delete t.extensions[$g];}const Xg=1179937895,Yg=new TextDecoder("utf8");function Zg(t,e){return new URL(t,e).href}function Wg(t,e,r,n){return fetch(Zg(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[r]=t;}))}function Hg(t,e){const r=t.json.bufferViews[e];return new Uint8Array(t.buffers[r.buffer],r.byteOffset||0,r.byteLength)}function Kg(t,e,r,n){if(t.uri){const i=Zg(t.uri,n);return fetch(i).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[r]=t;}))}if(void 0!==t.bufferView){const n=Hg(e,t.bufferView),i=new Blob([n],{type:t.mimeType});return createImageBitmap(i).then((t=>{e.images[r]=t;}))}}function Jg(t,e=0,r){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===Xg){const r=new Uint32Array(t,e);let i=2;const s=(r[i++]>>2)-3,a=r[i++]>>2;if(i++,n.json=JSON.parse(Yg.decode(r.subarray(i,i+a))),i+=a,i{const t=[],e=o&&o.includes(Ng),i=o&&o.includes($g);if(e&&t.push(function(){if(!Bg)return null!=Tg?Tg:(Tg=function(t){let e,r=null;function n(){e=new Uint8Array(r.buffer);}function i(){throw new Error("Unexpected Draco error.")}const s={a:{a:i,d:function(t,r,n){return e.copyWithin(t,r,r+n)},c:function(t){const i=e.length,s=Math.max(t>>>0,Math.ceil(1.2*i)),a=Math.ceil((s-i)/65536);try{return r.grow(a),n(),!0}catch(t){return !1}},b:i}};return (WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,s):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,s)))).then((t=>{const{Rb:i,Qb:s,P:a,T:o,X:l,Ja:u,La:c,Qa:h,Va:p,Wa:f,eb:d,jb:m,f:y,e:g,yb:x,zb:b,Ab:v,Bb:w,Db:_,Gb:M}=t.instance.exports;r=g;const A=(()=>{let t=0,r=0,n=0,a=0;return o=>{n&&(i(a),i(t),r+=n,n=t=0),t||(r+=128,t=s(r));const l=o.length+7&-8;let u=t;l>=r&&(n=l,u=a=s(l));for(let t=0;t{Bg=t,Tg=void 0;})))}()),i&&t.push(function(){if(Cg)return;const t=function(t){let e;const r=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors();})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},i={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return {ready:r,supported:!0,decodeGltfBuffer(t,r,s,a,o,l){!function(t,e,r,n,i,s,a){const o=t.exports.sbrk,l=n+3&-4,u=o(l*i),c=o(s.length),h=new Uint8Array(t.exports.memory.buffer);h.set(s,c);const p=e(u,n,i,c,s.length);if(0===p&&a&&a(u,l,i),r.set(h.subarray(u,u+n*i)),o(u-o(0)),0!==p)throw new Error(`Malformed buffer data: ${p}`)}(e,e.exports[i[o]],t,r,s,a,e.exports[n[l]]);}}}(fetch(Lg()));return t.ready.then((()=>{Cg=t;}))}()),s)for(let e=0;e{if(e&&a)for(const{primitives:t}of a)for(const e of t)qg(e,n);if(i&&a&&l)for(const t of l)Gg(t,n);return n}))}))}function Qg(t,e){const r=t.json.bufferViews[e.bufferView],n=Fg[e.componentType];return new n(t.buffers[r.buffer],(e.byteOffset||0)+(r.byteOffset||0),e.count*(r.byteStride&&r.byteStride!==Ug[e.type]*n.BYTES_PER_ELEMENT?r.byteStride/n.BYTES_PER_ELEMENT:Ug[e.type]))}function tx(t,e,r,n){const i=Fg[e.componentType],s=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(i),a=t.json.bufferViews[e.bufferView],o=a.byteStride?a.byteStride/i.BYTES_PER_ELEMENT:Ug[e.type],l=r.float32,u=l.length/r.capacity;for(let t=0,r=0;t0){for(let i=0;i0){s.texcoordArray=new $a;const t=e.json.accessors[i.TEXCOORD_0];s.texcoordArray.resize(t.count);const r=Qg(e,t);tx(e,t,s.texcoordArray,r);}if(void 0!==i._FEATURE_ID_RGBA4444){const t=e.json.accessors[i._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(s.featureData=Qg(e,t));}void 0!==i._FEATURE_RGBA4444&&(s.featureData=new Uint32Array(Qg(e,e.json.accessors[i._FEATURE_RGBA4444]).buffer));const h=t.material;return s.material=function(t,e){const{emissiveFactor:r=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:i=.5,normalTexture:s,occlusionTexture:a,emissiveTexture:o,doubleSided:l}=t,{baseColorFactor:u=[1,1,1,1],metallicFactor:c=1,roughnessFactor:h=1,baseColorTexture:p,metallicRoughnessTexture:f}=t.pbrMetallicRoughness||{},d=a?e[a.index]:void 0;if(a&&a.extensions&&a.extensions.KHR_texture_transform&&d){const t=a.extensions.KHR_texture_transform;d.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]];}return {pbrMetallicRoughness:{baseColorFactor:new Pe(...u),metallicFactor:c,roughnessFactor:h,baseColorTexture:p?e[p.index]:void 0,metallicRoughnessTexture:f?e[f.index]:void 0},doubleSided:l,emissiveFactor:r,alphaMode:n,alphaCutoff:i,normalTexture:s?e[s.index]:void 0,occlusionTexture:d,emissionTexture:o?e[o.index]:void 0,defined:void 0===t.defined}}(void 0!==h?e.json.materials[h]:{defined:!1},r),s}function rx(t,e,r){const{matrix:n,rotation:i,translation:s,scale:a,mesh:o,extras:l,children:u}=t,c={};if(c.matrix=n||O.mat4.fromRotationTranslationScale([],i||[0,0,0,1],s||[0,0,0],a||[1,1,1]),void 0!==o){c.meshes=r[o];const t=c.anchor=[0,0];for(const e of c.meshes){const{min:r,max:n}=e.aabb;t[0]+=r[0]+n[0],t[1]+=r[1]+n[1];}t[0]=Math.floor(t[0]/c.meshes.length/2),t[1]=Math.floor(t[1]/c.meshes.length/2);}if(l&&(l.id&&(c.id=l.id),l.lights&&(c.lights=function(t){if(!t.length)return [];const e=function(t){const e=atob(t),r=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let i=0;for(let t=0;t0&&n.reverse();const s=uc(n.flatMap((t=>[t.x,t.y])),[]);return 0===s.length?null:{vertices:n,indices:s}}function sx(t,e){const r=[],n=[];let i=0;const s=[];for(const a of t){i=r.length;const t=a.vertexArray.float32,o=a.indexArray.uint16;for(let n=0;n0&&([n[t+1],n[t+2]]=[n[t+2],n[t+1]]);}return {vertices:r,indices:n}}function ax(t){const e=function(t,e){const r=[],n=WebGL2RenderingContext;if(t.json.textures)for(const i of t.json.textures){const s={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==i.sampler&&Object.assign(s,t.json.samplers[i.sampler]),r.push({image:e[i.source],sampler:s,uploaded:!1});}return r}(t,t.images),r=function(t,e){const r=[];for(const n of t.json.meshes){const i=[];for(const r of n.primitives)i.push(ex(r,t,e));r.push(i);}return r}(t,e),{scenes:n,scene:i,nodes:s}=t.json,a=n?n[i||0].nodes:s,o=[];for(const e of a)o.push(rx(s[e],t,r));return function(t,e,r){const n={},i=new Set;for(let s=0;s0){const e=Array.from(i.values()).sort(((t,e)=>t-e));for(let r=e.length-1;r>=0;r--)t.splice(e[r],1);}}(o,a,t.json.nodes),o}function ox(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,r=t.aabb.min[0]-1,n=t.aabb.min[1]-1,i=Wm/(t.aabb.max[0]-r+2),s=Wm/(t.aabb.max[1]-n+2);for(let a=0;at.heightmap[u*Wm+l]&&(t.heightmap[u*Wm+l]=o);}}function lx(t,e){const r={};r.indexArray=new Da,r.indexArray.reserve(4*t.length),r.vertexArray=new Aa,r.vertexArray.reserve(10*t.length),r.colorArray=new Ma,r.vertexArray.reserve(10*t.length);let n=0;for(const i of t){const t=Math.min(10,Math.max(4,1.3*i.height))*e,s=[-i.normal[1],i.normal[0],0],a=Math.min(.29,.1*i.width/i.depth),o=i.width-2*i.depth*e*(a+.01),l=O.vec3.scaleAndAdd([],i.pos,s,o/2),u=O.vec3.scaleAndAdd([],i.pos,s,-o/2),c=[l[0],l[1],l[2]+i.height],h=[u[0],u[1],u[2]+i.height],p=O.vec3.scaleAndAdd([],i.normal,s,a);O.vec3.scale(p,p,t);const f=O.vec3.scaleAndAdd([],i.normal,s,-a);O.vec3.scale(f,f,t),O.vec3.add(p,l,p),O.vec3.add(f,u,f),l[2]+=.1,u[2]+=.1,r.vertexArray.emplaceBack(p[0],p[1],p[2]),r.vertexArray.emplaceBack(f[0],f[1],f[2]),r.vertexArray.emplaceBack(l[0],l[1],l[2]),r.vertexArray.emplaceBack(u[0],u[1],u[2]),r.vertexArray.emplaceBack(c[0],c[1],c[2]),r.vertexArray.emplaceBack(h[0],h[1],h[2]),r.vertexArray.emplaceBack(l[0],l[1],l[2]),r.vertexArray.emplaceBack(u[0],u[1],u[2]),r.vertexArray.emplaceBack(p[0],p[1],p[2]),r.vertexArray.emplaceBack(f[0],f[1],f[2]);const d=o/t/2;r.colorArray.emplaceBack(-d-a,-1,d,.8),r.colorArray.emplaceBack(d+a,-1,d,.8),r.colorArray.emplaceBack(-d,0,d,1.3),r.colorArray.emplaceBack(d,0,d,1.3),r.colorArray.emplaceBack(d+a,-.8,d,.7),r.colorArray.emplaceBack(d+a,-.8,d,.7),r.colorArray.emplaceBack(0,0,d,1.3),r.colorArray.emplaceBack(0,0,d,1.3),r.colorArray.emplaceBack(d+a,-1.2,d,.8),r.colorArray.emplaceBack(d+a,-1.2,d,.8),r.indexArray.emplaceBack(6+n,4+n,8+n),r.indexArray.emplaceBack(7+n,9+n,5+n),r.indexArray.emplaceBack(0+n,1+n,2+n),r.indexArray.emplaceBack(1+n,3+n,2+n),n+=10;}const i={defined:!0,emissiveFactor:[0,0,0]},s={};return s.baseColorFactor=Pe.white,i.pbrMetallicRoughness=s,r.material=i,r.aabb=new yu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),r}class ux{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e=0&&n[3]>=0&&l.insert(o,n[0],n[1],n[2],n[3]);}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new ch.VectorTile(new of(this.rawTileData)).layers,this.sourceLayerCoder=new ux(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[];}return this.vtLayers}query(t,e,r,n){this.loadVTLayers();const i=t.params||{},s=Hs(i.filter),a=t.tileResult,o=t.transform,l=a.bufferedTilespaceBounds,u=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,r,n)=>jl(a.bufferedTilespaceGeometry,t,e,r,n)));u.sort(dx);let c=null;o.elevation&&u.length>0&&(c=ny.create(o.elevation,this.tileID));const h={};let p;for(let l=0;l(m||(m=Il(e,this.tileID.canonical,t.tileTransform)),r.queryIntersectsFeature(a,e,n,m,this.z,t.transform,t.pixelPosMatrix,c,i))));}return h}loadMatchingFeature(t,e,r,n,i,s,a,o,l){const{featureIndex:u,bucketIndex:c,sourceLayerIndex:h,layoutVertexArrayOffset:p}=e,f=this.bucketLayerIDs[c];if(n&&!function(t,e){for(let r=0;r=0)return !0;return !1}(n,f))return;const d=this.sourceLayerCoder.decode(h),m=this.vtLayers[d].feature(u);if(r.needGeometry){const t=Pl(m,!0);if(!r.filter(new Vs(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!r.filter(new Vs(this.tileID.overscaledZ),m))return;const y=this.getId(m,d);for(let e=0;e{const a=e instanceof js?e.get(s):null;return a&&a.evaluate?a.evaluate(r,n,i):a}))}function dx(t,e){return e-t}os(px,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const mx=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class yx{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,r]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const n=r>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const i=mx[15&r];if(!i)throw new Error("Unrecognized array type.");const[s]=new Uint16Array(t,2,1),[a]=new Uint32Array(t,4,1);return new yx(a,s,i,t)}constructor(t,e=64,r=Float64Array,n){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const i=mx.indexOf(this.ArrayType),s=2*t*this.ArrayType.BYTES_PER_ELEMENT,a=t*this.IndexArrayType.BYTES_PER_ELEMENT,o=(8-a%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${r}.`);n&&n instanceof ArrayBuffer?(this.data=n,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+a+o,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+s+a+o),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+a+o,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t);}add(t,e){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=e,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return gx(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,r,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:s,nodeSize:a}=this,o=[0,i.length-1,0],l=[];for(;o.length;){const u=o.pop()||0,c=o.pop()||0,h=o.pop()||0;if(c-h<=a){for(let a=h;a<=c;a++){const o=s[2*a],u=s[2*a+1];o>=t&&o<=r&&u>=e&&u<=n&&l.push(i[a]);}continue}const p=h+c>>1,f=s[2*p],d=s[2*p+1];f>=t&&f<=r&&d>=e&&d<=n&&l.push(i[p]),(0===u?t<=f:e<=d)&&(o.push(h),o.push(p-1),o.push(1-u)),(0===u?r>=f:n>=d)&&(o.push(p+1),o.push(c),o.push(1-u));}return l}within(t,e,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:i,nodeSize:s}=this,a=[0,n.length-1,0],o=[],l=r*r;for(;a.length;){const u=a.pop()||0,c=a.pop()||0,h=a.pop()||0;if(c-h<=s){for(let r=h;r<=c;r++)wx(i[2*r],i[2*r+1],t,e)<=l&&o.push(n[r]);continue}const p=h+c>>1,f=i[2*p],d=i[2*p+1];wx(f,d,t,e)<=l&&o.push(n[p]),(0===u?t-r<=f:e-r<=d)&&(a.push(h),a.push(p-1),a.push(1-u)),(0===u?t+r>=f:e+r>=d)&&(a.push(p+1),a.push(c),a.push(1-u));}return o}}function gx(t,e,r,n,i,s){if(i-n<=r)return;const a=n+i>>1;xx(t,e,a,n,i,s),gx(t,e,r,n,a-1,1-s),gx(t,e,r,a+1,i,1-s);}function xx(t,e,r,n,i,s){for(;i>n;){if(i-n>600){const a=i-n+1,o=r-n+1,l=Math.log(a),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(a-u)/a)*(o-a/2<0?-1:1);xx(t,e,r,Math.max(n,Math.floor(r-o*u/a+c)),Math.min(i,Math.floor(r+(a-o)*u/a+c)),s);}const a=e[2*r+s];let o=n,l=i;for(bx(t,e,n,r),e[2*i+s]>a&&bx(t,e,n,i);oa;)l--;}e[2*n+s]===a?bx(t,e,n,l):(l++,bx(t,e,l,i)),l<=r&&(n=l+1),r<=l&&(i=l-1);}}function bx(t,e,r,n){vx(t,r,n),vx(e,2*r,2*n),vx(e,2*r+1,2*n+1);}function vx(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function wx(t,e,r,n){const i=t-r,s=e-n;return i*i+s*s}t.$=Ds,t.A=class extends Nm{},t.B=hr,t.C=Be,t.D=Ys,t.E=Me,t.F=Oi,t.G=Di,t.H=Fi,t.I=Of,t.J=Wi,t.K=Zs,t.L=Qi,t.M=Hi,t.N=Bn,t.O=Cn,t.P=q,t.Q=En,t.R=ee,t.S=yr,t.T=lm,t.U=Ie,t.V=Nm,t.W=Ws,t.X=Ui,t.Y=Li,t.Z=function(t){const e=t.value;let r=[];if(!e)return r;const n=hr(e);return "string"!==n?(r=r.concat([new Nm(t.key,e,`string expected, "${n}" found`)]),r):(qm(e,!0)||(r=r.concat([new Nm(t.key,e,`invalid url "${e}"`)])),r)},t._=Xs,t.a=function(t){return It.API_CDN_URL_REGEX.test(t)},t.a$=qa,t.a0=Gs,t.a1=Ns,t.a2=class{constructor(t){this.specification=t;}possiblyEvaluate(t,e){return yt(t.expression.evaluate(e))}interpolate(t,e,r){return {x:ke(t.x,e.x,r),y:ke(t.y,e.y,r),z:ke(t.z,e.z,r),azimuthal:ke(t.azimuthal,e.azimuthal,r),polar:ke(t.polar,e.polar,r)}}},t.a3=Vs,t.a4=Ji,t.a5=xl,t.a6=O,t.a7=tt,t.a8=js,t.a9=Du,t.aA=ru,t.aB=mm,t.aC=wm,t.aD=fm,t.aE=function(t,e){const r=document.createElement("video");r.muted=!0,r.onloadstart=function(){e(null,r);};for(let e=0;e{}}},t.aF=um,t.aG=function(t){return fetch(t).then((t=>t.arrayBuffer())).then((e=>Jg(e,0,t)))},t.aH=ax,t.aI=class{constructor(t,e,r,n){this.id=t,this.position=null!=e?new rl(e[0],e[1]):new rl(0,0),this.orientation=null!=r?r:[0,0,0],this.nodes=n,this.uploaded=!1,this.aabb=new yu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[];}_applyTransformations(t,e){if(O.mat4.multiply(t.matrix,e,t.matrix),t.meshes)for(const e of t.meshes){const r=yu.applyTransformFast(e.aabb,t.matrix);this.aabb.encapsulate(r);}if(t.children)for(const e of t.children)this._applyTransformations(e,t.matrix);}computeBoundsAndApplyParent(){const t=O.mat4.identity([]);for(const e of this.nodes)this._applyTransformations(e,t);}computeModelMatrix(t,e,r,n,i,s,a=!1){Km(this.matrix,this,t.transform,this.position,e,r,n,i,s,a);}upload(t){if(!this.uploaded){for(const e of this.nodes)ty(e,t);for(const t of this.nodes)ey(t);this.uploaded=!0;}}destroy(){for(const t of this.nodes)ry(t);}},t.aJ=ot,t.aK=yd,t.aL=cl,t.aM=hl,t.aN=va,t.aO=Da,t.aP=st,t.aQ=Ha,t.aR=Zd,t.aS=function(){Bs.isLoading()||Bs.isLoaded()||"deferred"!==Ts()||Es();},t.aT=Hs,t.aU=Pl,t.aV=hx,t.aW=xt,t.aX=wp,t.aY=Fc,t.aZ=Il,t.a_=xa,t.aa=ke,t.ab=Hr,t.ac=Te,t.ad=class{constructor(t){this.specification=t;}possiblyEvaluate(t,e){return function([t,e]){const r=yt([1,t,e]);return {x:r.x,y:r.y,z:r.z}}(t.expression.evaluate(e))}interpolate(t,e,r){return {x:ke(t.x,e.x,r),y:ke(t.y,e.y,r),z:ke(t.z,e.z,r)}}},t.ae=function(t,e,r=0,n=!0){const i=new q(r,r),s=t.sub(i),a=e.add(i),o=[s,new q(a.x,s.y),a,new q(s.x,a.y)];return n&&o.push(s.clone()),o},t.af=function(t,e){const r=[];for(let n=0;n{n(t,r);}),e):n(t,r),()=>{}}return i.callbacks.push(n),i.cancel||(i.cancel=r(((r,n)=>{i.result=[r,n];for(const t of i.callbacks)this.scheduler?this.scheduler.add((()=>{t(r,n);}),e):t(r,n);setTimeout((()=>delete this.entries[t]),3e3);}))),()=>{i.result||(i.callbacks=i.callbacks.filter((t=>t!==n)),i.callbacks.length||(i.cancel(),delete this.entries[t]));}}},t.av=ua,t.aw=function(t,e,r){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=se(t.request,((t,n,i,s)=>{t?e(t):n&&e(null,{vectorTile:r?void 0:new ch.VectorTile(new of(n)),rawData:n,cacheControl:i,expires:s});}));return ()=>{n.cancel(),e();}}),e)},t.ax=function(t){Yt++,Yt>jt&&(t.getActor().send("enforceCacheSizeLimit",Ut),Yt=0);},t.ay=Rt,t.az=function(t){return t<=1?1:Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},t.b=function(t){return It.API_FONTS_REGEX.test(t)},t.b$=function(t){const{x:e,y:r}=t.point,{lng:n,lat:i}=t._center;return Ru(e,r,t.worldSize,n,i)},t.b0=lu,t.b1=co,t.b2=uc,t.b3=sm,t.b4=function(t,e){const r=Du(e.zoom);if(0===r)return _u(t);const n=Iu(t),i=Pu(n),s=ol(n.getWest())*e.worldSize,a=ol(n.getEast())*e.worldSize,o=ll(n.getNorth())*e.worldSize,l=ll(n.getSouth())*e.worldSize,u=[s,o,0],c=[a,o,0],h=[s,l,0],p=[a,l,0],f=O.mat4.invert([],e.globeMatrix);return O.vec3.transformMat4(u,u,f),O.vec3.transformMat4(c,c,f),O.vec3.transformMat4(h,h,f),O.vec3.transformMat4(p,p,f),i[0]=Mu(i[0],h,r),i[1]=Mu(i[1],p,r),i[2]=Mu(i[2],c,r),i[3]=Mu(i[3],u,r),yu.fromPoints(i)},t.b5=Eu,t.b6=zu,t.b7=Mu,t.b8=ba,t.b9=ou,t.bA=et,t.bB=Y,t.bC=wt,t.bD=ul,t.bE=function(t,e,r){t[4*e+0]=r[0],t[4*e+1]=r[1],t[4*e+2]=r[2],t[4*e+3]=r[3];},t.bF=Po,t.bG=_o,t.bH=Mo,t.bI=wo,t.bJ=vo,t.bK=rl,t.bL=Fd,t.bM=eu,t.bN=mu,t.bO=Sm,t.bP=tu,t.bQ=Su,t.bR=function(t,e,r,n,i,s,a,o,l){if("globe"===l.name)return Su(t,e,new tu(r,n,i),!1);const u=yd({z:r,x:n,y:i},l);return new yu([(s+u.x/u.scale)*e,e*(u.y/u.scale),a],[(s+u.x2/u.scale)*e,e*(u.y2/u.scale),o])},t.bS=function(t,e,r){let n=0;for(let r=0;r<2;++r){const i=0;t[r]>i&&(n+=(t[r]-i)*(t[r]-i)),e[r]0&&r[0]<=t.width&&r[1]>0&&r[1]<=t.height&&!Fu(t,new rl(t.center.lat,90)),n[0]>0&&n[0]<=t.width&&n[1]>0&&n[1]<=t.height&&!Fu(t,new rl(t.center.lat,-90))]},t.bW=function(t,e){const{scale:r}=t.tileTransform,n=r*Hr/(t.tileSize*Math.pow(2,e.zoom-t.tileID.overscaledZ+t.tileID.canonical.z));return O.mat2.scale(new Float32Array(4),e.inverseAdjustmentMatrix,[n,n])},t.bX=Im,t.bY=Am,t.bZ=function(t){const e=Am(t,!0);return O.mat2.invert([],[e[0],e[1],e[4],e[5]])},t.b_=cu,t.ba=_g,t.bb=of,t.bc=se,t.bd=function(t){const e=[];for(const r in t)e.push(t[r]);return e},t.be=function(t,e){const r=[];for(const n in t)n in e||r.push(n);return r},t.bf=rt,t.bg=["type","source","source-layer","minzoom","maxzoom","filter","layout"],t.bh=$,t.bi=function(t,e){const{x:r,y:n}=t.point,i=Ru(r,n,t.worldSize/t._pixelsPerMercatorPixel,0,0);return O.mat4.multiply(i,i,Bu(_u(e)))},t.bj=Zp,t.bk=ff,t.bl=Yp,t.bm=function(t,e,r,n,i){const s=5*e+2;t.float32[s+0]=r,t.float32[s+1]=n,t.float32[s+2]=i;},t.bn=$d,t.bo=Df,t.bp=El,t.bq=$p,t.br=gh,t.bs=jm,t.bt=Ih,t.bu=Ph,t.bv=ad,t.bw=sd,t.bx=Af,t.by=yx,t.bz=Pe,t.c=zt,t.c$=iu,t.c0=Z,t.c1=nu,t.c2=Go,t.c3=function(t){const e=Math.round((t+45+360)%360/90)%4;return W[e]},t.c4=45,t.c5=al,t.c6=Ao,t.c7=function(t,e,r){const n=Math.sqrt(t*t+e*e+r*r),i=n>0?Math.acos(r/n)*X:0;let s=0!==t||0!==e?Math.atan2(-e,-t)*X+90:0;return s<0&&(s+=360),[n,s,i]},t.c8=gl,t.c9=yu,t.cA=function(t){const e=fl-5;t=Q(t,-e,e)/e*90;const r=Math.pow(Math.abs(Math.sin(Y(t))),3);return Math.round(r*(Wo.length-1))},t.cB=function(t,e,r,n){const i=e.getNorth(),s=e.getSouth(),a=e.getWest(),o=e.getEast(),l=1<0){const t=180/n;O.mat3.multiply(f,f,[t/u+1,0,0,0,t/c+1,0,-.5*t/h,.5*t/p,1]);}return f[2]=l,f[5]=t.x,f[8]=t.y,f},t.cC=_u,t.cD=function(t,e,r){const n=O.mat4.identity(new Float64Array(16)),i=(e/(1<1)return !1;const r=e.getSource().maxzoom,n=1<1)return e;const i=n.getSource().maxzoom,s=1<{const s=this.getAtTileOffset(t,i.x,i.y),a=n.upVector(t.canonical,i.x,i.y),o=n.upVectorScale(t.canonical,e,r).metersToTile;return O.vec3.scale(a,a,s*o),a}}getForTilePoints(t,e,r,n){if(this.isUsingMockSource())return !1;const i=ny.create(this,t,n);return !!i&&(e.forEach((t=>{t[2]=this.exaggeration()*i.getElevationAt(t[0],t[1],r);})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const r=e.dem.tree,n=e.tileID,i=1<({u_camera_to_center_distance:new wo(t),u_extrude_scale:new To(t),u_device_pixel_ratio:new wo(t),u_matrix:new Po(t),u_inv_rot_matrix:new Po(t),u_merc_center:new _o(t),u_tile_id:new Mo(t),u_zoom_transition:new wo(t),u_up_dir:new Mo(t),u_emissive_strength:new wo(t)}),t.cO=t=>({u_matrix:new Po(t),u_pixels_to_tile_units:new To(t),u_device_pixel_ratio:new wo(t),u_units_to_pixels:new _o(t),u_dash_image:new vo(t),u_gradient_image:new vo(t),u_image_height:new wo(t),u_texsize:new _o(t),u_tile_units_to_pixels:new wo(t),u_alpha_discard_threshold:new wo(t),u_trim_offset:new _o(t),u_trim_fade_range:new _o(t),u_trim_color:new Ao(t),u_emissive_strength:new wo(t)}),t.cP=t=>({u_matrix:new Po(t),u_texsize:new _o(t),u_pixels_to_tile_units:new To(t),u_device_pixel_ratio:new wo(t),u_image:new vo(t),u_units_to_pixels:new _o(t),u_tile_units_to_pixels:new wo(t),u_alpha_discard_threshold:new wo(t),u_trim_offset:new _o(t)}),t.cQ=Ca,t.cR=qp,t.cS=Wp,t.cT=qu,t.cU=(t,e,r,n,i,s)=>{const a=t.transform,o="globe"===a.projection.name;let l;if("map"===s.paint.get("circle-pitch-alignment"))if(o){const t=Cu(a.zoom,e.canonical)*a._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t]);}else l=a.calculatePixelsToTileUnitsMatrix(r);else l=new Float32Array([a.pixelsToGLUnits[0],0,0,a.pixelsToGLUnits[1]]);const u={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(a.projection),u_matrix:t.translatePosMatrix(e.projMatrix,r,s.paint.get("circle-translate"),s.paint.get("circle-translate-anchor")),u_device_pixel_ratio:Dt.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Nu,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:s.paint.get("circle-emissive-strength")};if(o){u.u_inv_rot_matrix=n,u.u_merc_center=i,u.u_tile_id=[e.canonical.x,e.canonical.y,1<{const a=t.transform;return {u_matrix:Pp(t,e,r,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:a.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:i,u_image:0,u_tile_units_to_pixels:Ip(e,a),u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:s}},t.cX=(t,e,r,n,i,s,a)=>{const o=t.transform,l=o.calculatePixelsToTileUnitsMatrix(e);return {u_matrix:Pp(t,e,r,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:s,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:i,u_texsize:kp(r)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:Ip(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:a,u_trim_fade_range:r.paint.get("line-trim-fade-range"),u_trim_color:r.paint.get("line-trim-color").toRenderColor(r.lut).toArray01(),u_emissive_strength:r.paint.get("line-emissive-strength")}},t.cY=at,t.cZ=ac,t.c_=rp,t.ca=yt,t.cb=function(t){return [Math.pow(t[0],1/2.2),Math.pow(t[1],1/2.2),Math.pow(t[2],1/2.2)]},t.cc=function(t){return t({pluginStatus:Ss,pluginURL:Is}),ks.on("pluginStateChange",t),t},t.cd=by,t.ce=kg,t.cf=Xf,t.cg=Gf,t.ch=ne,t.ci=Ps,t.cj=Ft,t.ck=xe,t.cl=ht,t.cm=function(t){const e=t.indexOf(la);return e>=0?t.slice(0,e):t},t.cn=function(t){return t.indexOf(la)>=0},t.co=function(t){const e=t.indexOf(la);return e>=0?t.slice(e+1):""},t.cp=function(t){const e=[],r=t.id;return void 0===r&&e.push({message:`layers.${r}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${r}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${r}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cq=function(t,e,r,n){return "custom"===t.type?new _m(t,e):new my[t.type](t,e,r,n)},t.cr=ct,t.cs=ks,t.ct=ie,t.cu=So,t.cv=class extends bo{constructor(t){super(t),this.current=zo;}set(t,e,r){if(this.fetchUniformLocation(t,e))for(let t=0;t<9;t++)if(r[t]!==this.current[t]){this.current=r,this.gl.uniformMatrix3fv(this.location,!1,r);break}}},t.cw=H,t.cx=function(t,e,r){const n=Du(r.zoom),i=t.style.map._antialias,s=e.options.extStandardDerivativesForceOff||t.terrain&&t.terrain.exaggeration()>0;return 0===n&&!i&&!s},t.cy=function(t){const e=t.pixelsPerMeter,r=e/ul(1,t.center.lat),n=O.mat4.identity(new Float64Array(16));return O.mat4.translate(n,n,[t.point.x,t.point.y,0]),O.mat4.scale(n,n,[r,r,e]),Float32Array.from(n)},t.cz=Iu,t.d=function(t){return It.API_TILEJSON_REGEX.test(t)},t.d$=e,t.d0=Zh,t.d1=Dh,t.d2=450,t.d3=7,t.d4=dm,t.d5=ya,t.d6=Ya,t.d7=256,t.d8=Bu,t.d9=Aa,t.dA=Lu,t.dB=function(t){const e=[0,0,0],r=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(r,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(e,e,r),new q(e[0],e[1])},t.dC=function(t,e,r=!1){if(Ss===ws||Ss===_s||Ss===Ms)throw new Error("setRTLTextPlugin cannot be called multiple times.");Is=Dt.resolveURL(t),Ss=ws,As=e,zs(),r||Es();},t.dD=Ts,t.dE=function(){kg().acquire(Ig);},t.dF=function(){const t=zg;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(Ig),zg=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()"));},t.dG=Pg,t.dH=function(t){const e=Gt();if(!e)return;const r=e.delete(Ot);t&&r.catch(t).then((()=>t()));},t.dI=Sg,t.dJ=Dg,t.dK=function(t){Eg=Dt.resolveURL(t),Rg||(Rg=new by(kg(),new Me)),Rg.broadcast("setDracoUrl",Eg);},t.dL=Lg,t.dM=function(t){Vg=Dt.resolveURL(t),Rg||(Rg=new by(kg(),new Me)),Rg.broadcast("setMeshoptUrl",Vg);},t.dN=os,t.dO=nc,t.dP=$f,t.dQ=ux,t.dR=px,t.dS=gp,t.dT=ut,t.dU=Uf,t.dV=function(t,e,r,n,i,s,a,o,l,u,c){t.createArrays(),t.tilePixelRatio=Hr/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const h=t.layers[0].layout,p=t.layers[0]._unevaluatedLayout._values,f={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:r}=t.textSizeData;f.compositeTextSizes=[p["text-size"].possiblyEvaluate(new Vs(e),o),p["text-size"].possiblyEvaluate(new Vs(r),o)];}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:r}=t.iconSizeData;f.compositeIconSizes=[p["icon-size"].possiblyEvaluate(new Vs(e),o),p["icon-size"].possiblyEvaluate(new Vs(r),o)];}f.layoutTextSize=p["text-size"].possiblyEvaluate(new Vs(l+1),o),f.layoutIconSize=p["icon-size"].possiblyEvaluate(new Vs(l+1),o),f.textMaxSize=p["text-size"].possiblyEvaluate(new Vs(18),o);const d="map"===h.get("text-rotation-alignment")&&"point"!==h.get("symbol-placement"),m=h.get("text-size");let y=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){y=!0;break}for(const s of t.features){const l=h.get("text-font").evaluate(s,{},o).join(","),p=m.evaluate(s,{},o),g=f.layoutTextSize.evaluate(s,{},o),x=(f.layoutIconSize.evaluate(s,{},o),{horizontal:{},vertical:void 0}),b=s.text;let v,w=[0,0];if(b){const n=b.toString(),a=h.get("text-letter-spacing").evaluate(s,{},o)*$p,u=h.get("text-line-height").evaluate(s,{},o)*$p,c=ds(n)?a:0,f=h.get("text-anchor").evaluate(s,{},o),m=h.get("text-variable-anchor");if(!m){const t=h.get("text-radial-offset").evaluate(s,{},o);w=t?sd(f,[t*$p,nd]):h.get("text-offset").evaluate(s,{},o).map((t=>t*$p));}let y=d?"center":h.get("text-justify").evaluate(s,{},o);const v="point"===h.get("symbol-placement"),_=v?h.get("text-max-width").evaluate(s,{},o)*$p:1/0,M=s=>{t.allowVerticalPlacement&&fs(n)&&(x.vertical=yf(b,e,r,i,l,_,u,f,s,c,w,ff.vertical,!0,g,p));};if(!d&&m){const t="auto"===y?m.map((t=>ad(t))):[y];let n=!1;for(let s=0;s=0||!fs(n)){const t=yf(b,e,r,i,l,_,u,f,y,c,w,ff.horizontal,!1,g,p);t&&(x.horizontal[y]=t);}M(v?"left":y);}}let _=!1;if(s.icon&&s.icon.namePrimary){const e=n[s.icon.namePrimary];e&&(v=If(i[s.icon.namePrimary],s.icon.nameSecondary?i[s.icon.nameSecondary]:void 0,h.get("icon-offset").evaluate(s,{},o),h.get("icon-anchor").evaluate(s,{},o)),_=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&ft("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==h.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0));}const M=hd(x.horizontal)||x.vertical;t.iconsInText||(t.iconsInText=!!M&&M.iconsInText),(M||v)&&od(t,s,x,v,n,f,g,0,w,_,a,o,u,c,y);}s&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray);},t.dW=ch,t.dX=Ey,t.dY=N,t.dZ=uh,t.d_=af,t.da=Ua,t.db=ja,t.dc=function(t,e,r,n,i){return Q((t-e)/(r-e)*(i-n)+n,n,i)},t.dd=Ii,t.de=ml,t.df=class{constructor(t,e,r,n){this.context=t,this.format=n,this.size=r,this.texture=t.gl.createTexture();const[i,s,a]=this.size,{gl:o}=t;o.bindTexture(o.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1),o.texImage3D(o.TEXTURE_3D,0,this.format,i,s,a,0,am(this.format),om(this.format),e.data);}bind(t,e){const{context:r}=this,{gl:n}=r;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e);}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null;}},t.dg=Bm,t.dh=[1,1,1],t.di=ny,t.dj=Hm,t.dk=Ea,t.dl=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new q(1/0,1/0),max:new q(-1/0,-1/0)};}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[];}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const r=_h(new q(0,0),new q(Hr,Hr),t),n=[];if(e&&!vh(r,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!vh(r,e))continue;const i=Mh(e.min,e.max,t);n.push({min:i.min,max:i.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask,clipScope:e.clipScope});}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const r of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(r).buckets[t.layer];n&&n.updateFootprints(r.toUnwrapped(),e);}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask,getClipScope:()=>t.clipScope}))));}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const r=t.getOrder(),n=t.getClipMask(),i=t.getClipScope();for(const t of e){if(!t.footprint)continue;const e=_h(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:r,clipMask:n,clipScope:i});}this._sourceIds.push(t.getSourceId());}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||xh(t.min,e.min)||xh(t.max,e.max)||t.order-e.order||t.clipMask-e.clipMask||function(t,e){const r=(t,e)=>t+e;return t.length-e.length||t.reduce(r,"").localeCompare(e.reduce(r,""))}(t.clipScope,e.clipScope)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const r=this._activeRegions[e],n=this._prevRegions[e];t=r.priority!==n.priority||!bh(r,n)||r.order!==n.order||r.clipMask!==n.clipMask||!$(r.clipScope,n.clipScope),++e;}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==yh&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const r=e[t].priority;for(;t1){let e=0,r=t(e);for(;e!==r;){let n=e;const i=e;for(;n!==r;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement();}},t.dm=class{constructor(t){this._createGrid(t),this._createPoles(t);}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy();}_fillGridMeshWithLods(t,e){const r=new xa,n=new Da,i=[],s=t+1+2,a=e[0]+1,o=e[0]+1+(1+e.length),l=(t,e,r)=>{let n=t===s-1?t-2:0===t?t:t-1;return n+=r?24575:0,[n,e]};for(let t=0;t=t.byteLength)&&ft("Invalid b3dm header information.");}return Jg(t,e)},t.e1=function(t,e){const r=ax(t);for(const t of r){for(const e of t.meshes)ox(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(lx(t.lights,e)));}return r},t.e2=cy,t.e3=xy,t.e4=Bs,t.e5=function(t){Xt(),null!=qt&&qt.then((e=>{e.keys().then((r=>{for(let n=0;n"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join(""))},t.k=function(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number("0x"+e)))))},t.l=nt,t.m=Zt,t.n=function(t,e){return ie(nt(t,{type:"json"}),e)},t.o=ce,t.p=function(t,e){return ie(nt(t,{method:"POST"}),e)},t.q=Dt,t.r=ic,t.s=function(t){try{const e=self[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch(t){return !1}},t.t=ve,t.u=function(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()},t.v=function(t){return !!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)},t.w=ft,t.x=be,t.y=2,t.z=Lf;})); define(["./shared"],(function(e){function t(e){const t=e?e.url.toString():void 0;return t?performance.getEntriesByName(t):[]}function o(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 s of e)t+=`${o(s)},`;return `${t}]`}let t="{";for(const s of Object.keys(e).sort())t+=`${s}:${o(e[s])},`;return `${t}}`}function s(t){let s="";for(const i of e.bg)s+=`/${o(t[i])}`;return s}class i{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,o,i){this._options=i;for(const o of t)this._layerConfigs[o.id]=o,(this._layers[o.id]=e.cq(o,this.scope,null,this._options)).compileFilter(i),this.keyCache[o.id]&&delete this.keyCache[o.id];for(const e of o)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const n=function(e,t){const o={};for(let i=0;ithis._layers[e.id])),o=t[0];if("none"===o.visibility)continue;const s=o.source||"";let i=this.familiesBySource[s];i||(i=this.familiesBySource[s]={});const n=o.sourceLayer||"_geojsonTileLayer";let r=i[n];r||(r=i[n]=[]),r.push(t);}}}const n=1*e.dP;class r{constructor(t){const o={},s=[];for(const e in t){const i=t[e],r=o[e]={};for(const e in i.glyphs){const t=i.glyphs[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const o=t.metrics.localGlyph?n:1,a={x:0,y:0,w:t.bitmap.width+2*o,h:t.bitmap.height+2*o};s.push(a),r[e]=a;}}const{w:i,h:r}=e.z(s),a=new e.dO({width:i||1,height:r||1});for(const s in t){const i=t[s];for(const t in i.glyphs){const r=i.glyphs[+t];if(!r||0===r.bitmap.width||0===r.bitmap.height)continue;const l=o[s][t],c=r.metrics.localGlyph?n:1;e.dO.copy(r.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},r.bitmap);}}this.image=a,this.positions=o;}}e.dN(r,"GlyphAtlas");class a{constructor(t){this.tileID=new e.aA(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.collectResourceTiming,this.promoteId=t.promoteId,this.isSymbolTile=t.isSymbolTile,this.tileTransform=e.aK(t.tileID.canonical,t.projection),this.projection=t.projection,this.brightness=t.brightness,this.extraShadowCaster=!!t.extraShadowCaster,this.tessellationStep=t.tessellationStep;}parse(t,o,s,i,n){this.status="parsing",this.data=t,this.collisionBoxArray=new e.aQ;const a=new e.dQ(Object.keys(t.layers).sort()),c=new e.dR(this.tileID,this.promoteId);c.bucketLayerIDs=[];const h={},u=new e.dS(256,256),d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:s,brightness:this.brightness},f=o.familiesBySource[this.source];for(const o in f){const i=t.layers[o];if(!i)continue;let n=!1,r=!1,u=!1;for(const e of f[o])"symbol"===e[0].type?n=!0:r=!0,e[0].is3D()&&"model"!==e[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!n)continue;if(!1===this.isSymbolTile&&!r)continue;1===i.version&&e.w(`Vector tile source "${this.source}" layer "${o}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const p=a.encode(o),g=[];for(let e=0;e=t.maxzoom||"none"!==t.visibility&&(l(e,this.zoom,d.brightness,s),(h[t.id]=t.createBucket({index:c.bucketLayerIDs.length,layers:e,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:p,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(g,d,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(e.map((e=>e.id)))));}}let p,g,m,y;u.trim();const x={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},w=()=>{if(p)return this.status="done",n(p);if(this.extraShadowCaster)this.status="done",n(null,{buckets:e.bd(h).filter((e=>!e.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:d.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(g&&m&&y){const t=new r(g),o=new e.dU(m,y,this.lut);for(const i in h){const n=h[i];n instanceof e.aR?(l(n.layers,this.zoom,d.brightness,s),e.dV(n,g,t.positions,m,o.iconPositions,this.showCollisionBoxes,s,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):n.hasPattern&&(n instanceof e.aX||n instanceof e.aY||n instanceof e.d0)&&(l(n.layers,this.zoom,d.brightness,s),n.addFeatures(d,this.tileID.canonical,o.patternPositions,s,this.tileTransform,this.brightness));}this.status="done",n(null,{buckets:e.bd(h).filter((e=>!e.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:t.image,lineAtlas:u,imageAtlas:o,brightness:d.brightness});}};if(!this.extraShadowCaster){const t=e.dT(d.glyphDependencies,(e=>Object.keys(e).map(Number)));Object.keys(t).length?i.send("getGlyphs",{uid:this.uid,stacks:t,scope:this.scope},((e,t)=>{p||(p=e,g=t,w());}),void 0,!1,x):g={};const o=Object.keys(d.iconDependencies);o.length?i.send("getImages",{icons:o,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((e,t)=>{p||(p=e,m=t,w());}),void 0,!1,x):m={};const s=Object.keys(d.patternDependencies);s.length?i.send("getImages",{icons:s,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((e,t)=>{p||(p=e,y=t,w());}),void 0,!1,x):y={};}w();}}function l(t,o,s,i){const n=new e.a3(o,{brightness:s});for(const e of t)e.recalculate(n,i);}class c extends e.E{constructor(t,o,s,i,n,r){super(),this.actor=t,this.layerIndex=o,this.availableImages=s,this.loadVectorData=n||e.aw,this.loading={},this.loaded={},this.deduped=new e.au(t.scheduler),this.isSpriteLoaded=i,this.scheduler=t.scheduler,this.brightness=r;}loadTile(o,s){const i=o.uid,n=o&&o.request,r=n&&n.collectResourceTiming,l=this.loading[i]=new a(o);l.abort=this.loadVectorData(o,((a,c)=>{const h=!this.loading[i];if(delete this.loading[i],h||a||!c)return l.status="done",h||(this.loaded[i]=l),s(a);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new e.dW.VectorTile(new e.bb(u));const f=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((o,i)=>{if(o||!i)return s(o);const a={};if(r){const e=t(n);e.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(e)));}s(null,e.l({rawTileData:u.slice(0)},i,d,a));}));};this.isSpriteLoaded?f():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(f,{type:"parseTile",isSymbolTile:o.isSymbolTile,zoom:o.tileZoom}):f();})),this.loaded=this.loaded||{},this.loaded[i]=l;}));}reloadTile(t,o){const s=this.loaded,i=t.uid;if(s&&s[i]){const n=s[i];n.showCollisionBoxes=t.showCollisionBoxes,n.projection=t.projection,n.brightness=t.brightness,n.tileTransform=e.aK(t.tileID.canonical,t.projection),n.extraShadowCaster=t.extraShadowCaster,n.lut=t.lut;const r=(e,t)=>{const s=n.reloadCallback;s&&(delete n.reloadCallback,n.parse(n.vectorTile,this.layerIndex,this.availableImages,this.actor,s)),o(e,t);};"parsing"===n.status?n.reloadCallback=r:"done"===n.status&&(n.vectorTile?n.parse(n.vectorTile,this.layerIndex,this.availableImages,this.actor,r):r());}else o(null,void 0);}abortTile(e,t){const o=e.uid,s=this.loading[o];s&&(s.abort&&s.abort(),delete this.loading[o]),t();}removeTile(e,t){const o=this.loaded,s=e.uid;o&&o[s]&&delete o[s],t();}}class h{loadTile(t,o){const{uid:s,encoding:i,rawImageData:n,padding:r}=t,a=ImageBitmap&&n instanceof ImageBitmap?this.getImageData(n,r):n;o(null,new e.dX(s,a,i,r<1));}getImageData(e,t){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);const o=this.offscreenCanvasContext.getImageData(-t,-t,e.width+2*t,e.height+2*t);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),o}}e.ba.setPbf(e.bb);class u{decodeRasterArray({task:t,buffer:o},s){e.ba.performDecoding(o,t).then((e=>{s(null,e);}),(e=>{s(e);}));}}const d=e.dW.VectorTileFeature.prototype.toGeoJSON;class f{constructor(t){this._feature=t,this.extent=e.ab,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 o of this._feature.geometry)t.push([new e.P(o[0],o[1])]);return t}{const t=[];for(const o of this._feature.geometry){const s=[];for(const t of o)s.push(new e.P(t[0],t[1]));t.push(s);}return t}}toGeoJSON(e,t,o){return d.call(this,e,t,o)}}class p{constructor(t){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=e.ab,this.length=t.length,this._features=t;}feature(e){return new f(this._features[e])}}const g=64/4096,m=128;class y{constructor(){this.features=new Map;}clear(){this.features.clear();}load(e=[],t){for(const o of e){const e=o.id;if(null==e)continue;let s=this.features.get(e);s&&this.updateCache(s,t),o.geometry?(s=w(o),this.updateCache(s,t),this.features.set(e,s)):this.features.delete(e),this.updateCache(s,t);}}updateCache(e,t){for(const{canonical:o,uid:s}of Object.values(t)){const{z:i,x:n,y:r}=o;x(e,Math.pow(2,i),n,r)&&delete t[s];}}getTile(e,t,o){const s=Math.pow(2,e),i=[];for(const e of this.features.values())x(e,s,t,o)&&i.push(I(e,s,t,o));return {features:i}}getFeatures(){return [...this.features.values()]}}function x({minX:e,minY:t,maxX:o,maxY:s},i,n,r){return e<(n+1+g)/i&&t<(r+1+g)/i&&o>(n-g)/i&&s>(r-g)/i}function w(e){const{id:t,geometry:o,properties:s}=e;if(!o)return;if("GeometryCollection"===o.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:i,coordinates:n}=o,r={id:t,type:1,geometry:[],tags:s,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=r.geometry;if("Point"===i)b(n,a,r);else if("MultiPoint"===i)for(const e of n)b(e,a,r);else if("LineString"===i)r.type=2,S(n,a,r);else if("MultiLineString"===i)r.type=2,v(n,a,r);else if("Polygon"===i)r.type=3,v(n,a,r,!0);else {if("MultiPolygon"!==i)throw new Error("Input data is not a valid GeoJSON object.");r.type=3;for(const e of n)v(e,a,r,!0);}return r}function b([t,o],s,i){const n=e.am(t);let r=e.at(o);r=r<0?0:r>1?1:r,s.push(n,r),i.minX=Math.min(i.minX,n),i.minY=Math.min(i.minY,r),i.maxX=Math.max(i.maxX,n),i.maxY=Math.max(i.maxY,r);}function S(e,t,o,s=!1,i=!1){const n=[];for(const t of e)b(t,n,o);t.push(n),s&&function(e,t){let o=0;for(let t=0,s=e.length,i=s-2;t0===t)for(let t=0,o=e.length;t=a&&d>=a||(h>=a?(u+=Math.round(g*((a-h)/p)),h=a):d>=a&&(f=u+Math.round(g*((a-h)/p)),d=a),u>=a&&f>=a||(u>=a?(h+=Math.round(p*((a-u)/g)),u=a):f>=a&&(d=h+Math.round(p*((a-u)/g)),f=a),l&&h===l[l.length-1][0]&&u===l[l.length-1][1]||(l=[[h,u]],n.push(l)),l.push([d,f])))));}}var k,T,P,C={exports:{}},_=function(){if(P)return C.exports;P=1;var t=e.d_(),o=function(){if(T)return k;T=1;var t=e.dY(),o=e.dZ().VectorTileFeature;function s(e,t){this.options=t||{},this.features=e,this.length=e.length;}function i(e,t){this.id="number"==typeof e.id?e.id:void 0,this.type=e.type,this.rawGeometry=1===e.type?[e.geometry]:e.geometry,this.properties=e.tags,this.extent=t||4096;}return k=s,s.prototype.feature=function(e){return new i(this.features[e],this.options.extent)},i.prototype.loadGeometry=function(){var e=this.rawGeometry;this.geometry=[];for(var o=0;o>31}function c(e,t){for(var o=e.loadGeometry(),s=e.type,i=0,n=0,r=o.length,c=0;ce},j=Math.fround||(O=new Float32Array(1),e=>(O[0]=+e,O[0]));var O;const z=3,A=5,Z=6;class E{constructor(e){this.options=Object.assign(Object.create(D),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[];}load(e){const{log:t,minZoom:o,maxZoom:s}=this.options;t&&console.time("total time");const i=`prepare ${e.length} points`;t&&console.time(i),this.points=e;const n=[];for(let t=0;t=o;e--){const o=+Date.now();r=this.trees[e]=this._createTree(this._cluster(r,e)),t&&console.log("z%d: %d clusters in %dms",e,r.numItems,+Date.now()-o);}return t&&console.timeEnd("total time"),this}getClusters(e,t){let o=((e[0]+180)%360+360)%360-180;const s=Math.max(-90,Math.min(90,e[1]));let i=180===e[2]?180:((e[2]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)o=-180,i=180;else if(o>i){const e=this.getClusters([o,s,180,n],t),r=this.getClusters([-180,s,i,n],t);return e.concat(r)}const r=this.trees[this._limitZoom(t)],a=r.range(N(o),X(n),N(i),X(s)),l=r.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+A]>1?F(l,t,this.clusterProps):this.points[l[t+z]]);}return c}getChildren(e){const t=this._getOriginId(e),o=this._getOriginZoom(e),s="No cluster with the specified id.",i=this.trees[o];if(!i)throw new Error(s);const n=i.data;if(t*this.stride>=n.length)throw new Error(s);const r=this.options.radius/(this.options.extent*Math.pow(2,o-1)),a=i.within(n[t*this.stride],n[t*this.stride+1],r),l=[];for(const t of a){const o=t*this.stride;n[o+4]===e&&l.push(n[o+A]>1?F(n,o,this.clusterProps):this.points[n[o+z]]);}if(0===l.length)throw new Error(s);return l}getLeaves(e,t,o){const s=[];return this._appendLeaves(s,e,t=t||10,o=o||0,0),s}getTile(e,t,o){const s=this.trees[this._limitZoom(e)],i=Math.pow(2,e),{extent:n,radius:r}=this.options,a=r/n,l=(o-a)/i,c=(o+1+a)/i,h={features:[]};return this._addTileFeatures(s.range((t-a)/i,l,(t+1+a)/i,c),s.data,t,o,i,h),0===t&&this._addTileFeatures(s.range(1-a/i,l,1,c),s.data,i,o,i,h),t===i-1&&this._addTileFeatures(s.range(0,l,a/i,c),s.data,-1,o,i,h),h.features.length?h:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const o=this.getChildren(e);if(t++,1!==o.length)break;e=o[0].properties.cluster_id;}return t}_appendLeaves(e,t,o,s,i){const n=this.getChildren(t);for(const t of n){const n=t.properties;if(n&&n.cluster?i+n.point_count<=s?i+=n.point_count:i=this._appendLeaves(e,n.cluster_id,o,s,i):i1;let l,c,h;if(a)l=Y(t,e,this.clusterProps),c=t[e],h=t[e+1];else {const o=this.points[t[e+z]];l=o.properties;const[s,i]=o.geometry.coordinates;c=N(s),h=X(i);}const u={type:1,geometry:[[Math.round(this.options.extent*(c*i-o)),Math.round(this.options.extent*(h*i-s))]],tags:l};let d;d=a||this.options.generateId?t[e+z]:this.points[t[e+z]].id,void 0!==d&&(u.id=d),n.features.push(u);}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:o,extent:s,reduce:i,minPoints:n}=this.options,r=o/(s*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let o=0;ot&&(f+=a[o+A]);}if(f>d&&f>=n){let e,n=s*d,r=h*d,p=-1;const g=(o/c<<5)+(t+1)+this.points.length;for(const s of u){const l=s*c;if(a[l+2]<=t)continue;a[l+2]=t;const h=a[l+A];n+=a[l]*h,r+=a[l+1]*h,a[l+4]=g,i&&(e||(e=this._map(a,o,!0),p=this.clusterProps.length,this.clusterProps.push(e)),i(e,this._map(a,l)));}a[o+4]=g,l.push(n/f,r/f,1/0,g,-1,f),i&&l.push(p);}else {for(let e=0;e1)for(const e of u){const o=e*c;if(!(a[o+2]<=t)){a[o+2]=t;for(let e=0;e>5}_getOriginZoom(e){return (e-this.points.length)%32}_map(e,t,o){if(e[t+A]>1){const s=this.clusterProps[e[t+Z]];return o?Object.assign({},s):s}const s=this.points[e[t+z]].properties,i=this.options.map(s);return o&&i===s?Object.assign({},i):i}}function F(e,t,o){return {type:"Feature",id:e[t+z],properties:Y(e,t,o),geometry:{type:"Point",coordinates:[(s=e[t],360*(s-.5)),W(e[t+1])]}};var s;}function Y(e,t,o){const s=e[t+A],i=s>=1e4?`${Math.round(s/1e3)}k`:s>=1e3?Math.round(s/100)/10+"k":s,n=e[t+Z],r=-1===n?{}:Object.assign({},o[n]);return Object.assign(r,{cluster:!0,cluster_id:e[t+z],point_count:s,point_count_abbreviated:i})}function N(e){return e/360+.5}function X(e){const t=Math.sin(e*Math.PI/180),o=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return o<0?0:o>1?1:o}function W(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function G(e,t,o,s){let i=s;const n=t+(o-t>>1);let r,a=o-t;const l=e[t],c=e[t+1],h=e[o],u=e[o+1];for(let s=t+3;si)r=s,i=t;else if(t===i){const e=Math.abs(s-n);es&&(r-t>3&&G(e,t,r,s),e[r+2]=i,o-r>3&&G(e,r,o,s));}function B(e,t,o,s,i,n){let r=i-o,a=n-s;if(0!==r||0!==a){const l=((e-o)*r+(t-s)*a)/(r*r+a*a);l>1?(o=i,s=n):l>0&&(o+=r*l,s+=a*l);}return r=e-o,a=t-s,r*r+a*a}function J(e,t,o,s){const i={id:e??null,type:t,geometry:o,tags:s,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)R(i,o);else if("Polygon"===t)R(i,o[0]);else if("MultiLineString"===t)for(const e of o)R(i,e);else if("MultiPolygon"===t)for(const e of o)R(i,e[0]);return i}function R(e,t){for(let o=0;o0&&(r+=s?(i*l-a*n)/2:Math.sqrt(Math.pow(a-i,2)+Math.pow(l-n,2))),i=a,n=l;}const a=t.length-3;t[2]=1,G(t,0,a,o),t[a+2]=1,t.size=Math.abs(r),t.start=0,t.end=t.size;}function U(e,t,o,s){for(let i=0;i1?1:o}function H(e,t,o,s,i,n,r,a){if(s/=t,n>=(o/=t)&&r=s)return null;const l=[];for(const t of e){const e=t.geometry;let n=t.type;const r=0===i?t.minX:t.minY,c=0===i?t.maxX:t.maxY;if(r>=o&&c=s)continue;let h=[];if("Point"===n||"MultiPoint"===n)ee(e,h,o,s,i);else if("LineString"===n)te(e,h,o,s,i,!1,a.lineMetrics);else if("MultiLineString"===n)se(e,h,o,s,i,!1);else if("Polygon"===n)se(e,h,o,s,i,!0);else if("MultiPolygon"===n)for(const t of e){const e=[];se(t,e,o,s,i,!0),e.length&&h.push(e);}if(h.length){if(a.lineMetrics&&"LineString"===n){for(const e of h)l.push(J(t.id,n,e,t.tags));continue}"LineString"!==n&&"MultiLineString"!==n||(1===h.length?(n="LineString",h=h[0]):n="MultiLineString"),"Point"!==n&&"MultiPoint"!==n||(n=3===h.length?"Point":"MultiPoint"),l.push(J(t.id,n,h,t.tags));}}return l.length?l:null}function ee(e,t,o,s,i){for(let n=0;n=o&&r<=s&&ie(t,e[n],e[n+1],e[n+2]);}}function te(e,t,o,s,i,n,r){let a=oe(e);const l=0===i?ne:re;let c,h,u=e.start;for(let d=0;do&&(h=l(a,f,p,m,y,o),r&&(a.start=u+c*h)):x>s?w=o&&(h=l(a,f,p,m,y,o),b=!0),w>s&&x<=s&&(h=l(a,f,p,m,y,s),b=!0),!n&&b&&(r&&(a.end=u+c*h),t.push(a),a=oe(e)),r&&(u+=c);}let d=e.length-3;const f=e[d],p=e[d+1],g=0===i?f:p;g>=o&&g<=s&&ie(a,f,p,e[d+2]),d=a.length-3,n&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&ie(a,a[0],a[1],a[2]),a.length&&t.push(a);}function oe(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function se(e,t,o,s,i,n){for(const r of e)te(r,t,o,s,i,n,!1);}function ie(e,t,o,s){e.push(t,o,s);}function ne(e,t,o,s,i,n){const r=(n-t)/(s-t);return ie(e,n,o+(i-o)*r,1),r}function re(e,t,o,s,i,n){const r=(n-o)/(i-o);return ie(e,t+(s-t)*r,n,1),r}function ae(e,t){const o=[];for(let s=0;s0&&t.size<(i?r:s))return void(o.numPoints+=t.length/3);const a=[];for(let e=0;er)&&(o.numSimplified++,a.push(t[e],t[e+1])),o.numPoints++;i&&function(e,t){let o=0;for(let t=0,s=e.length,i=s-2;t0===t)for(let t=0,o=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 s=function(e,t){const o=[];if("FeatureCollection"===e.type)for(let s=0;s1&&console.time("creation"),d=this.tiles[u]=ue(e,t,o,s,l),this.tileCoords.push({z:t,x:o,y:s}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,o,s,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==i){if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else {if(t===l.maxZoom||t===i)continue;if(null!=i){const e=i-t;if(o!==n>>e||s!==r>>e)continue}}if(d.source=null,0===e.length)continue;c>1&&console.time("clipping");const f=.5*l.buffer/l.extent,p=.5-f,g=.5+f,m=1+f;let y=null,x=null,w=null,b=null,S=H(e,h,o-f,o+g,0,d.minX,d.maxX,l),v=H(e,h,o+p,o+m,0,d.minX,d.maxX,l);e=null,S&&(y=H(S,h,s-f,s+g,1,d.minY,d.maxY,l),x=H(S,h,s+p,s+m,1,d.minY,d.maxY,l),S=null),v&&(w=H(v,h,s-f,s+g,1,d.minY,d.maxY,l),b=H(v,h,s+p,s+m,1,d.minY,d.maxY,l),v=null),c>1&&console.timeEnd("clipping"),a.push(y||[],t+1,2*o,2*s),a.push(x||[],t+1,2*o,2*s+1),a.push(w||[],t+1,2*o+1,2*s),a.push(b||[],t+1,2*o+1,2*s+1);}}getTile(e,t,o){e=+e,t=+t,o=+o;const s=this.options,{extent:i,debug:n}=s;if(e<0||e>24)return null;const r=1<1&&console.log("drilling down to z%d-%d-%d",e,t,o);let l,c=e,h=t,u=o;for(;!l&&c>0;)c--,h>>=1,u>>=1,l=this.tiles[me(c,h,u)];return l&&l.source?(n>1&&(console.log("found parent tile z%d-%d-%d",c,h,u),console.time("drilling down")),this.splitTile(l.source,c,h,u,e,t,o),n>1&&console.timeEnd("drilling down"),this.tiles[a]?ce(this.tiles[a],i):null):null}}function me(e,t,o){return 32*((1<{if(r||!a)return s(r);if("object"!=typeof a)return s(new Error(`Input data given to '${o.source}' is not a valid GeoJSON object.`));{try{if(o.filter){const t=e.M(o.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)));}o.dynamic?("Feature"===a.type&&(a={type:"FeatureCollection",features:[a]}),o.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(a.features,this.loaded),o.cluster&&(a.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=o.cluster?new E(function({superclusterOptions:t,clusterProperties:o}){if(!o||!t)return t;const s={},i={},n={accumulated:null,zoom:0},r={properties:null},a=Object.keys(o);for(const t of a){const[n,r]=o[t],a=e.M(r),l=e.M("string"==typeof n?[n,["accumulated"],["get",t]]:n);s[t]=a.value,i[t]=l.value;}return t.map=e=>{r.properties=e;const t={};for(const e of a)t[e]=s[e].evaluate(n,r);return t},t.reduce=(e,t)=>{r.properties=t;for(const t of a)n.accumulated=e[t],e[t]=i[t].evaluate(n,r);},t}(o)).load(a.features):o.dynamic?this._dynamicIndex:function(e,t){return new ge(e,t)}(a,o.geojsonVtOptions);}catch(e){return s(e)}const r={};if(n){const e=t(i);e&&(r.resourceTiming={},r.resourceTiming[o.source]=JSON.parse(JSON.stringify(e)));}s(null,r);}}));}reloadTile(e,t){const o=this.loaded;return o&&o[e.uid]?e.partial?t(null,void 0):super.reloadTile(e,t):this.loadTile(e,t)}loadGeoJSON(t,o){if(t.request)e.n(t.request,o);else {if("string"!=typeof t.data)return o(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));try{return o(null,JSON.parse(t.data))}catch(e){return o(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`))}}}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 we{constructor(t,o){this.tileID=new e.aA(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=o;}parse(t,o,s,i){this.status="parsing";const n=new e.aA(s.tileID.overscaledZ,s.tileID.wrap,s.tileID.canonical.z,s.tileID.canonical.x,s.tileID.canonical.y),r={},a=o.familiesBySource[s.source],l=new e.dR(n,s.promoteId);return l.bucketLayerIDs=[],l.is3DTile=!0,e.e0(t).then((t=>{if(!t)return i(new Error("Could not parse tile"));const o=e.e1(t,1/e.c8(s.tileID.canonical)),c=t.json.extensionsUsed&&t.json.extensionsUsed.includes("MAPBOX_mesh_features")||t.json.asset.extras&&t.json.asset.extras.MAPBOX_mesh_features,h=t.json.extensionsUsed&&t.json.extensionsUsed.includes("EXT_meshopt_compression"),u=new e.a3(this.zoom,{brightness:this.brightness});for(const t in a)for(const s of a[t]){const t=s[0];l.bucketLayerIDs.push(s.map((e=>e.id))),t.recalculate(u,[]);const i=new e.e2(o,n,c,h,this.brightness,l);c||(i.needsUpload=!0),r[t.fqid]=i,i.evaluate(t);}this.status="done",i(null,{buckets:r,featureIndex:l});})).catch((e=>i(new Error(e.message))))}}class be{constructor(e,t,o,s,i,n){this.actor=e,this.layerIndex=t,this.brightness=n,this.loading={},this.loaded={};}loadTile(t,o){const s=t.uid,i=this.loading[s]=new we(t,this.brightness);e.bc(t.request,((e,n)=>{const r=!this.loading[s];return delete this.loading[s],r||e?(i.status="done",r||(this.loaded[s]=i),o(e)):n&&0!==n.byteLength?void i.parse(n,this.layerIndex,t,((e,t)=>{i.status="done",this.loaded=this.loaded||{},this.loaded[s]=i,e||!t?o(e):o(null,t);})):(i.status="done",this.loaded[s]=i,o())}));}reloadTile(e,t){const o=this.loaded,s=e.uid;if(o&&o[s]){const i=o[s];i.projection=e.projection,i.brightness=e.brightness;const n=(o,s)=>{i.reloadCallback&&(delete i.reloadCallback,this.loadTile(e,t)),t(o,s);};"parsing"===i.status?i.reloadCallback=n:"done"===i.status&&this.loadTile(e,t);}}abortTile(e,t){const o=e.uid;this.loading[o]&&delete this.loading[o],t();}removeTile(e,t){const o=this.loaded,s=e.uid;o&&o[s]&&delete o[s],t();}}class Se{constructor(t){this.self=t,this.actor=new e.e3(t,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=e.bL({name:"mercator"}),this.workerSourceTypes={vector:c,geojson:xe,"batched-model":be},this.workerSources={},this.demWorkerSources={},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.e4.isParsed())throw new Error("RTL text plugin already registered.");e.e4.applyArabicShaping=t.applyArabicShaping,e.e4.processBidirectionalText=t.processBidirectionalText,e.e4.processStyledBidirectionalText=t.processStyledBidirectionalText;};}clearCaches(e,t,o){delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e],delete this.rasterArrayWorkerSource,o();}checkIfReady(e,t,o){o();}setReferrer(e,t){this.referrer=t;}spriteLoaded(t,{scope:o,isLoaded:s}){if(this.isSpriteLoaded[t]||(this.isSpriteLoaded[t]={}),this.isSpriteLoaded[t][o]=s,this.workerSources[t]&&this.workerSources[t][o])for(const i in this.workerSources[t][o]){const n=this.workerSources[t][o][i];for(const t in n){const o=n[t];o instanceof c&&(o.isSpriteLoaded=s,o.fire(new e.x("isSpriteLoaded")));}}}setImages(e,{scope:t,images:o},s){if(this.availableImages[e]||(this.availableImages[e]={}),this.availableImages[e][t]=o,this.workerSources[e]&&this.workerSources[e][t]){for(const s in this.workerSources[e][t]){const i=this.workerSources[e][t][s];for(const e in i)i[e].availableImages=o;}s();}else s();}setProjection(t,o){this.projections[t]=e.bL(o);}setBrightness(e,t,o){this.brightness=t,o();}setLayers(e,t,o){this.getLayerIndex(e,t.scope).replace(t.layers,t.options),o();}updateLayers(e,t,o){this.getLayerIndex(e,t.scope).update(t.layers,t.removedIds,t.options),o();}loadTile(e,t,o){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).loadTile(t,o);}loadDEMTile(e,t,o){this.getDEMWorkerSource(e,t.source,t.scope).loadTile(t,o);}decodeRasterArray(e,t,o){this.getRasterArrayWorkerSource().decodeRasterArray(t,o);}reloadTile(e,t,o){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).reloadTile(t,o);}abortTile(e,t,o){this.getWorkerSource(e,t.type,t.source,t.scope).abortTile(t,o);}removeTile(e,t,o){this.getWorkerSource(e,t.type,t.source,t.scope).removeTile(t,o);}removeSource(e,t,o){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 s=this.workerSources[e][t.scope][t.type][t.source];delete this.workerSources[e][t.scope][t.type][t.source],void 0!==s.removeSource?s.removeSource(t,o):o();}loadWorkerSource(e,t,o){try{this.self.importScripts(t.url),o();}catch(e){o(e.toString());}}syncRTLPluginState(t,o,s){try{e.e4.setState(o);const t=e.e4.getPluginURL();if(e.e4.isLoaded()&&!e.e4.isParsed()&&null!=t){this.self.importScripts(t);const o=e.e4.isParsed();s(o?void 0:new Error(`RTL Text Plugin failed to import scripts from ${t}`),o);}}catch(e){s(e.toString());}}setDracoUrl(e,t){this.dracoUrl=t;}getAvailableImages(e,t){this.availableImages[e]||(this.availableImages[e]={});let o=this.availableImages[e][t];return o||(o=[]),o}getLayerIndex(e,t){this.layerIndexes[e]||(this.layerIndexes[e]={});let o=this.layerIndexes[e][t];return o||(o=this.layerIndexes[e][t]=new i,o.scope=t),o}getWorkerSource(e,t,o,s){return this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][s]||(this.workerSources[e][s]={}),this.workerSources[e][s][t]||(this.workerSources[e][s][t]={}),this.isSpriteLoaded[e]||(this.isSpriteLoaded[e]={}),this.workerSources[e][s][t][o]||(this.workerSources[e][s][t][o]=new this.workerSourceTypes[t]({send:(t,o,s,i,n,r)=>{this.actor.send(t,o,s,e,n,r);},scheduler:this.actor.scheduler},this.getLayerIndex(e,s),this.getAvailableImages(e,s),this.isSpriteLoaded[e][s],void 0,this.brightness)),this.workerSources[e][s][t][o]}getDEMWorkerSource(e,t,o){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][o]||(this.demWorkerSources[e][o]={}),this.demWorkerSources[e][o][t]||(this.demWorkerSources[e][o][t]=new h),this.demWorkerSources[e][o][t]}getRasterArrayWorkerSource(){return this.rasterArrayWorkerSource||(this.rasterArrayWorkerSource=new u),this.rasterArrayWorkerSource}enforceCacheSizeLimit(t,o){e.e5(o);}getWorkerPerformanceMetrics(e,t,o){o(void 0,void 0);}}return "undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new Se(self)),Se})); define(["./shared"],(function(e){var t="3.7.0";const i={create:"create",load:"load",fullLoad:"fullLoad"},o={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 s,a={},n=function(){if(s)return a;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"}),o=URL.createObjectURL(i);try{t=new Worker(o),e=!0;}catch(t){e=!1;}return t&&t.terminate(),URL.revokeObjectURL(o),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[o=t&&t.failIfMajorPerformanceCaveat]&&(i[o]=function(t){var i,o=function(t){var i=document.createElement("canvas"),o=Object.create(e.webGLContextAttributes);return o.failIfMajorPerformanceCaveat=t,i.getContext("webgl2",o)}(t);if(!o)return !1;try{i=o.createShader(o.VERTEX_SHADER);}catch(e){return !1}return !(!i||o.isContextLost())&&(o.shaderSource(i,"void main() {}"),o.compileShader(i),!0===o.getShaderParameter(i,o.COMPILE_STATUS))}(o)),i[o]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL2 support"):"insufficient Canvas/getImageData support":"insufficient worker support";var o;}s=1,a.supported=e,a.notSupportedReason=t;var i={};return e.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},a}();function l(e,t,i){const o=document.createElement(e);return null!=t&&(o.className=t),i&&i.appendChild(o),o}function c(e,t,i){const o=document.createElementNS("http://www.w3.org/2000/svg",e);for(const e of Object.keys(t))o.setAttributeNS(null,e,String(t[e]));return i&&i.appendChild(o),o}const h="undefined"!=typeof document?document.documentElement&&document.documentElement.style:null,u=h&&void 0!==h.userSelect?"userSelect":"WebkitUserSelect";let d;function _(){h&&u&&(d=h[u],h[u]="none");}function p(){h&&u&&(h[u]=d);}function m(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",m,!0);}function f(){window.addEventListener("click",m,!0),window.setTimeout((()=>{window.removeEventListener("click",m,!0);}),0);}function g(e,t){const i=e.getBoundingClientRect();return y(e,i,t)}function v(e,t){const i=e.getBoundingClientRect(),o=[];for(let r=0;r=0?0:e.button}function y(t,i,o){const r=t.offsetWidth===i.width?1:t.offsetWidth/i.width;return new e.P((o.clientX-i.left)*r,(o.clientY-i.top)*r)}const b="01",w="NO_ACCESS_TOKEN";class T{constructor(e,t,i){this._transformRequestFn=e,this._customAccessToken=t,this._silenceAuthErrors=!!i,this._createSkuToken();}_createSkuToken(){const e=function(){let e="";for(let t=0;t<10;t++)e+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return {token:["1",b,e].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=e.token,this._skuTokenExpiresAt=e.tokenExpiresAt;}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}normalizeStyleURL(i,o){if(!e.f(i))return i;const r=C(i);return r.params.push(`sdk=js-${t}`),r.path=`/styles/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||o)}normalizeGlyphsURL(t,i){if(!e.f(t))return t;const o=C(t);return o.path=`/fonts/v1${o.path}`,this._makeAPIURL(o,this._customAccessToken||i)}normalizeModelURL(t,i){if(!e.f(t))return t;const o=C(t);return o.path=`/models/v1${o.path}`,this._makeAPIURL(o,this._customAccessToken||i)}normalizeSourceURL(t,i,o,r){if(!e.f(t))return t;const s=C(t);return s.path=`/v4/${s.authority}.json`,s.params.push("secure"),o&&s.params.push(`language=${o}`),r&&s.params.push(`worldview=${r}`),this._makeAPIURL(s,this._customAccessToken||i)}normalizeSpriteURL(t,i,o,r){const s=C(t);return e.f(t)?(s.path=`/styles/v1${s.path}/sprite${i}${o}`,this._makeAPIURL(s,this._customAccessToken||r)):(s.path+=`${i}${o}`,S(s))}normalizeTileURL(t,i,o){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!e.f(t))return t;const r=C(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${i||o&&"raster"!==r.authority&&512===o?"@2x":""}${e.m.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 s=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&&s&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,s)}canonicalizeTileURL(t,i){const o=C(t);if(!o.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!o.path.match(/\.[\w]+$/))return t;let r="mapbox://";o.path.match(/^\/raster\/v1\//)?r+=`raster/${o.path.replace(`/${e.e.RASTER_URL_PREFIX}/`,"")}`:o.path.match(/^\/rasterarrays\/v1\//)?r+=`rasterarrays/${o.path.replace(`/${e.e.RASTERARRAYS_URL_PREFIX}/`,"")}`:r+=`tiles/${o.path.replace(`/${e.e.TILE_URL_VERSION}/`,"")}`;let s=o.params;return i&&(s=s.filter((e=>!e.match(/^access_token=/)))),s.length&&(r+=`?${s.join("&")}`),r}canonicalizeTileset(t,i){const o=!!i&&e.f(i),r=[];for(const i of t.tiles||[])e.h(i)?r.push(this.canonicalizeTileURL(i,o)):r.push(i);return r}_makeAPIURL(t,i){const o="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=C(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 S(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. ${o}`);if("s"===i[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${o}`)}return t.params=t.params.filter((e=>-1===e.indexOf("access_token"))),t.params.push(`access_token=${i||""}`),S(t)}}const E=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function C(e){const t=e.match(E);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 S(e){const t=e.params.length?`?${e.params.join("&")}`:"";return `${e.protocol}://${e.authority}${e.path}${t}`}const I="mapbox.eventData";function D(t){if(!t)return null;const i=t.split(".");if(!i||3!==i.length)return null;try{return JSON.parse(e.j(i[1]))}catch(e){return null}}class R{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null;}getStorageKey(t){const i=D(e.e.ACCESS_TOKEN);let o="";return o=i&&i.u?e.k(i.u):e.e.ACCESS_TOKEN||"",t?`${I}.${t}:${o}`:`${I}:${o}`}fetchEventData(){const t=e.s("localStorage"),i=this.getStorageKey(),o=this.getStorageKey("uuid");if(t)try{const e=localStorage.getItem(i);e&&(this.eventData=JSON.parse(e));const t=localStorage.getItem(o);t&&(this.anonId=t);}catch(t){e.w("Unable to read from LocalStorage");}}saveEventData(){const t=e.s("localStorage"),i=this.getStorageKey(),o=this.getStorageKey("uuid"),r=this.anonId;if(t&&r)try{localStorage.setItem(o,r),Object.keys(this.eventData).length>=1&&localStorage.setItem(i,JSON.stringify(this.eventData));}catch(t){e.w("Unable to write to LocalStorage");}}processRequests(e){}postEvent(t,i,o,r){if(!e.e.EVENTS_URL)return;const s=C(e.e.EVENTS_URL);s.params.push(`access_token=${r||e.e.ACCESS_TOKEN||""}`);const a={event:this.type,created:new Date(t).toISOString()},n=i?e.l(a,i):a,l={url:S(s),headers:{"Content-Type":"text/plain"},body:JSON.stringify([n])};this.pendingRequest=e.p(l,(e=>{this.pendingRequest=null,o(e),this.saveEventData(),this.processRequests(r);}));}queueRequest(e,t){this.queue.push(e),this.processRequests(t);}}const A=new class extends R{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.f(t)||e.h(t)))&&this.queueRequest(Date.now(),i);}processRequests(i){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const o=D(e.e.ACCESS_TOKEN),r=o?o.u:e.e.ACCESS_TOKEN;let s=r!==this.eventData.tokenU;e.v(this.anonId)||(this.anonId=e.u(),s=!0);const a=this.queue.shift();if(this.eventData.lastSuccess){const e=new Date(this.eventData.lastSuccess),t=new Date(a),i=(a-this.eventData.lastSuccess)/864e5;s=s||i>=1||i<-1||e.getDate()!==t.getDate();}else s=!0;s?this.postEvent(a,{sdkIdentifier:"mapbox-gl-js",sdkVersion:t,skuId:b,"enabled.telemetry":!1,userId:this.anonId},(e=>{e||(this.eventData.lastSuccess=a,this.eventData.tokenU=r);}),i):this.processRequests();}},L=A.postTurnstileEvent.bind(A),P=new class extends R{constructor(){super("map.load"),this.success={},this.skuToken="";}postMapLoadEvent(t,i,o,r){this.skuToken=i,this.errorCb=r,e.e.EVENTS_URL&&(o||e.e.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},o):this.errorCb(new Error(w)));}processRequests(i){if(this.pendingRequest||0===this.queue.length)return;const{id:o,timestamp:r}=this.queue.shift();o&&this.success[o]||(this.anonId||this.fetchEventData(),e.v(this.anonId)||(this.anonId=e.u()),this.postEvent(r,{sdkIdentifier:"mapbox-gl-js",sdkVersion:t,skuId:b,skuToken:this.skuToken,userId:this.anonId},(e=>{e?this.errorCb(e):o&&(this.success[o]=!0);}),i));}remove(){this.errorCb=null;}},M=P.postMapLoadEvent.bind(P),z=new class extends R{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:o,style:r,importedStyles:s}=i;if(!e.e.EVENTS_URL||!t&&!e.e.ACCESS_TOKEN)return;const a=this.getMapInstanceId(o),n={mapInstanceId:a,eventId:this.getEventId(a),style:r};s.length&&(n.importedStyles=s),this.queueRequest({timestamp:Date.now(),payload:n},t);}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,payload:i}=this.queue.shift();this.postEvent(t,i,(()=>{}),e);}},O=z.postStyleLoadEvent.bind(z),F=new class extends R{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(o){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:s,performanceData:a}=this.queue.shift(),n=function(o){const s=performance.getEntriesByType("resource"),a=performance.getEntriesByType("mark"),n=function(e){const t={};if(e)for(const i in e)if("other"!==i)for(const o of e[i]){const e=`${i}ResolveRangeMin`,r=`${i}ResolveRangeMax`,s=`${i}RequestCount`,a=`${i}RequestCachedCount`;t[e]=Math.min(t[e]||1/0,o.startTime),t[r]=Math.max(t[r]||-1/0,o.responseEnd);const n=e=>{void 0===t[e]&&(t[e]=0),++t[e];};void 0!==o.transferSize&&0===o.transferSize&&n(a),n(s);}return t}(function(e,t){const i={};if(e)for(const o of e){const e=t(o);void 0===i[e]&&(i[e]=[]),i[e].push(o);}return i}(s,r)),l=window.devicePixelRatio,c=navigator.connection||navigator.mozConnection||navigator.webkitConnection,h=c?c.effectiveType:void 0,u={counters:[],metadata:[],attributes:[]},d=(e,t,i)=>{null!=i&&e.push({name:t,value:i.toString()});};for(const e in n)d(u.counters,e,n[e]);if(o.interactionRange[0]!==1/0&&o.interactionRange[1]!==-1/0&&(d(u.counters,"interactionRangeMin",o.interactionRange[0]),d(u.counters,"interactionRangeMax",o.interactionRange[1])),a)for(const e of Object.keys(i)){const t=i[e],o=a.find((e=>e.name===t));o&&d(u.counters,t,o.startTime);}return d(u.counters,"visibilityHidden",o.visibilityHidden),d(u.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]}`}}}(s)),d(u.attributes,"terrainEnabled",o.terrainEnabled?"true":"false"),d(u.attributes,"fogEnabled",o.fogEnabled?"true":"false"),d(u.attributes,"projection",o.projection),d(u.attributes,"zoom",o.zoom),d(u.metadata,"devicePixelRatio",l),d(u.metadata,"connectionEffectiveType",h),d(u.metadata,"navigatorUserAgent",navigator.userAgent),d(u.metadata,"screenWidth",window.screen.width),d(u.metadata,"screenHeight",window.screen.height),d(u.metadata,"windowWidth",window.innerWidth),d(u.metadata,"windowHeight",window.innerHeight),d(u.metadata,"mapWidth",o.width/l),d(u.metadata,"mapHeight",o.height/l),d(u.metadata,"webglRenderer",o.renderer),d(u.metadata,"webglVendor",o.vendor),d(u.metadata,"sdkVersion",t),d(u.metadata,"sdkIdentifier","mapbox-gl-js"),u}(a);for(const e of n.metadata);for(const e of n.counters);for(const e of n.attributes);this.postEvent(s,n,(()=>{}),o);}},k=F.postPerformanceEvent.bind(F),B=new class extends R{constructor(){super("map.auth"),this.success={},this.skuToken="";}getSession(t,i,o,r){if(!e.e.API_URL||!e.e.SESSION_PATH)return;const s=C(e.e.API_URL+e.e.SESSION_PATH);s.params.push(`sku=${i||""}`),s.params.push(`access_token=${r||e.e.ACCESS_TOKEN||""}`);const a={url:S(s),headers:{"Content-Type":"text/plain"}};this.pendingRequest=e.g(a,(e=>{this.pendingRequest=null,o(e),this.saveEventData(),this.processRequests(r);}));}getSessionAPI(t,i,o,r){this.skuToken=i,this.errorCb=r,e.e.SESSION_PATH&&e.e.API_URL&&(o||e.e.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},o):this.errorCb(new Error(w)));}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;}},N=B.getSessionAPI.bind(B),U=new Set;function G(e,t){t?U.add(e):U.delete(e);}class j{constructor(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages=new Set;}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(){return Array.from(this._updatedImages.values())}updateImage(e){this._updatedImages.add(e),this.setDirty();}resetUpdatedImages(){this._updatedImages.clear();}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages.clear();}}function V(e){const{userImage:t}=e;return !!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class q extends e.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded={},this.requestors=[],this.patterns={},this.atlasImage={},this.atlasTexture={},this.dirty=!0;}createScope(t){this.images[t]={},this.loaded[t]=!1,this.updatedImages[t]={},this.patterns[t]={},this.callbackDispatchedThisFrame[t]={},this.atlasImage[t]=new e.r({width:1,height:1});}isLoaded(){for(const e in this.loaded)if(!this.loaded[e])return !1;return !0}setLoaded(e,t){if(this.loaded[t]!==e&&(this.loaded[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[t][e]}addImage(e,t,i){this._validate(e,i)&&(this.images[t][e]=i);}_validate(t,i){let o=!0;return this._validateStretch(i.stretchX,i.data&&i.data.width)||(this.fire(new e.t(new Error(`Image "${t}" has invalid "stretchX" value`))),o=!1),this._validateStretch(i.stretchY,i.data&&i.data.height)||(this.fire(new e.t(new Error(`Image "${t}" has invalid "stretchY" value`))),o=!1),this._validateContent(i.content,i)||(this.fire(new e.t(new Error(`Image "${t}" has invalid "content" value`))),o=!1),o}_validateStretch(e,t){if(!e)return !0;let i=0;for(const o of e){if(o[0]1?n-1:n,e.r.copy(h,a,{x:0,y:0},{x:l,y:c},{width:u,height:d},i),e.r.copy(h,a,{x:0,y:d-n},{x:l,y:c-n},{width:u,height:n},i),e.r.copy(h,a,{x:0,y:0},{x:l,y:c+d},{width:u,height:n},i),e.r.copy(h,a,{x:u-n,y:0},{x:l-n,y:c},{width:n,height:d},i),e.r.copy(h,a,{x:0,y:0},{x:l+u,y:c},{width:n,height:d},i),e.r.copy(h,a,{x:u-n,y:d-n},{x:l-n,y:c-n},{width:n,height:n},i),e.r.copy(h,a,{x:0,y:d-n},{x:l+u,y:c-n},{width:n,height:n},i),e.r.copy(h,a,{x:0,y:0},{x:l+u,y:c+d},{width:n,height:n},i),e.r.copy(h,a,{x:u-n,y:0},{x:l-n,y:c+d},{width:n,height:n},i);}this.dirty=!0;}beginFrame(){for(const e in this.images)this.callbackDispatchedThisFrame[e]={};}dispatchRenderCallbacks(e,t){for(const i of e){if(this.callbackDispatchedThisFrame[t][i])continue;this.callbackDispatchedThisFrame[t][i]=!0;const e=this.images[t][i];V(e)&&this.updateImage(i,t,e);}}}function Z(t){const i=t.key,o=t.value,r=t.valueSpec||{},s=t.objectElementValidators||{},a=t.style,n=t.styleSpec;let l=[];const c=e.B(o);if("object"!==c)return [new e.V(i,o,`object expected, ${c} found`)];for(const t in o){const c=t.split(".")[0];let h;s[c]?h=s[c]:r[c]?h=_e:s["*"]?h=s["*"]:r["*"]&&(h=_e),h?l=l.concat(h({key:(i?`${i}.`:i)+t,value:o[t],valueSpec:r[c]||r["*"],style:a,styleSpec:n,object:o,objectKey:t},o)):l.push(new e.A(i,o[t],`unknown property "${t}"`));}for(const t in r)s[t]||r[t].required&&void 0===r[t].default&&void 0===o[t]&&l.push(new e.V(i,o,`missing required property "${t}"`));return l}function H(t){const i=t.value,o=t.valueSpec,r=t.style,s=t.styleSpec,a=t.key,n=t.arrayElementValidator||_e;if("array"!==e.B(i))return [new e.V(a,i,`array expected, ${e.B(i)} found`)];if(o.length&&i.length!==o.length)return [new e.V(a,i,`array length ${o.length} expected, length ${i.length} found`)];if(o["min-length"]&&i.lengths)return [new e.V(i,o,`${o} is greater than the maximum value ${s}`)]}return []}function $(t){const i=t.valueSpec,o=e.D(t.value.type);let r,s,a,n={};const l="categorical"!==o&&void 0===t.value.property,c=!l,h="array"===e.B(t.value.stops)&&"array"===e.B(t.value.stops[0])&&"object"===e.B(t.value.stops[0][0]),u=Z({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(H({key:t.key,value:r,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:d})),"array"===e.B(r)&&0===r.length&&i.push(new e.V(t.key,r,"array must have at least one stop")),i},default:function(e){return _e({key:e.key,value:e.value,valueSpec:i,style:e.style,styleSpec:e.styleSpec})}}});return "identity"===o&&l&&u.push(new e.V(t.key,t.value,'missing required property "property"')),"identity"===o||t.value.stops||u.push(new e.V(t.key,t.value,'missing required property "stops"')),"exponential"===o&&t.valueSpec.expression&&!e.F(t.valueSpec)&&u.push(new e.V(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(c&&!e.G(t.valueSpec)?u.push(new e.V(t.key,t.value,"property functions not supported")):l&&!e.H(t.valueSpec)&&u.push(new e.V(t.key,t.value,"zoom functions not supported"))),"categorical"!==o&&!h||void 0!==t.value.property||u.push(new e.V(t.key,t.value,'"property" property is required')),u;function d(t){let o=[];const r=t.value,l=t.key;if("array"!==e.B(r))return [new e.V(l,r,`array expected, ${e.B(r)} found`)];if(2!==r.length)return [new e.V(l,r,`array length 2 expected, length ${r.length} found`)];if(h){if("object"!==e.B(r[0]))return [new e.V(l,r,`object expected, ${e.B(r[0])} found`)];if(void 0===r[0].zoom)return [new e.V(l,r,"object stop key must have zoom")];if(void 0===r[0].value)return [new e.V(l,r,"object stop key must have value")];const i=e.D(r[0].zoom);if("number"!=typeof i)return [new e.V(l,r[0].zoom,"stop zoom values must be numbers")];if(a&&a>i)return [new e.V(l,r[0].zoom,"stop zoom values must appear in ascending order")];i!==a&&(a=i,s=void 0,n={}),o=o.concat(Z({key:`${l}[0]`,value:r[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:W,value:_}}));}else o=o.concat(_({key:`${l}[0]`,value:r[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},r));return e.J(e.K(r[1]))?o.concat([new e.V(`${l}[1]`,r[1],"expressions are not allowed in function stops.")]):o.concat(_e({key:`${l}[1]`,value:r[1],valueSpec:i,style:t.style,styleSpec:t.styleSpec}))}function _(t,a){const l=e.B(t.value),c=e.D(t.value),h=null!==t.value?t.value:a;if(r){if(l!==r)return [new e.V(t.key,h,`${l} stop domain type must match previous stop domain type ${r}`)]}else r=l;if("number"!==l&&"string"!==l&&"boolean"!==l&&"number"!=typeof c&&"string"!=typeof c&&"boolean"!=typeof c)return [new e.V(t.key,h,"stop domain value must be a number, string, or boolean")];if("number"!==l&&"categorical"!==o){let r=`number expected, ${l} found`;return e.G(i)&&void 0===o&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new e.V(t.key,h,r)]}return "categorical"!==o||"number"!==l||"number"==typeof c&&isFinite(c)&&Math.floor(c)===c?"categorical"!==o&&"number"===l&&"number"==typeof c&&"number"==typeof s&&void 0!==s&&cnew e.V(`${t.key}${i.key}`,t.value,i.message)));const o=i.value.expression||i.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!o.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.N(o))return [new e.V(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext)return Y(o,t);if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!e.O(o,["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.Q(o))return [new e.V(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return []}function Y(t,i){const o=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(i.valueSpec&&i.valueSpec.expression)for(const e of i.valueSpec.expression.parameters)o.delete(e);if(0===o.size)return [];const r=[];return t instanceof e.S&&o.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(...Y(e,i));})),r)}function K(t){const i=t.key,o=t.value,r=t.valueSpec,s=[];return Array.isArray(r.values)?-1===r.values.indexOf(e.D(o))&&s.push(new e.V(i,o,`expected one of [${r.values.join(", ")}], ${JSON.stringify(o)} found`)):-1===Object.keys(r.values).indexOf(e.D(o))&&s.push(new e.V(i,o,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(o)} found`)),s}function J(t){return e.W(e.K(t.value))?X(e.C({},t,{expressionContext:"filter",valueSpec:t.styleSpec[`filter_${t.layerType||"fill"}`]})):Q(t)}function Q(t){const i=t.value,o=t.key;if("array"!==e.B(i))return [new e.V(o,i,`array expected, ${e.B(i)} found`)];const r=t.styleSpec;let s,a=[];if(i.length<1)return [new e.V(o,i,"filter array must have at least 1 element")];switch(a=a.concat(K({key:`${o}[0]`,value:i[0],valueSpec:r.filter_operator,style:t.style,styleSpec:t.styleSpec})),e.D(i[0])){case"<":case"<=":case">":case">=":i.length>=2&&"$type"===e.D(i[1])&&a.push(new e.V(o,i,`"$type" cannot be use with operator "${i[0]}"`));case"==":case"!=":3!==i.length&&a.push(new e.V(o,i,`filter array for operator "${i[0]}" must have 3 elements`));case"in":case"!in":i.length>=2&&(s=e.B(i[1]),"string"!==s&&a.push(new e.V(`${o}[1]`,i[1],`string expected, ${s} found`)));for(let n=2;n{t in o&&i.push(new e.V(r,o[t],`"${t}" is prohibited for ref layers`));})),s.layers.forEach((i=>{e.D(i.id)===l&&(t=i);})),t?t.ref?i.push(new e.V(r,o.ref,"ref cannot reference another ref layer")):n=e.D(t.type):"string"==typeof l&&i.push(new e.V(r,o.ref,`ref layer "${l}" not found`));}else if("background"!==n&&"sky"!==n&&"slot"!==n)if(o.source){const t=s.sources&&s.sources[o.source],a=t&&e.D(t.type);t?"vector"===a&&"raster"===n?i.push(new e.V(r,o.source,`layer "${o.id}" requires a raster source`)):"raster"===a&&"raster"!==n?i.push(new e.V(r,o.source,`layer "${o.id}" requires a vector source`)):"vector"!==a||o["source-layer"]?"raster-dem"===a&&"hillshade"!==n?i.push(new e.V(r,o.source,"raster-dem source can only be used with layer type 'hillshade'.")):"raster-array"!==a||["raster","raster-particle"].includes(n)?"line"!==n||!o.paint||!o.paint["line-gradient"]&&!o.paint["line-trim-offset"]||"geojson"===a&&t.lineMetrics?"raster-particle"===n&&"raster-array"!==a&&i.push(new e.V(r,o.source,`layer "${o.id}" requires a 'raster-array' source.`)):i.push(new e.V(r,o,`layer "${o.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):i.push(new e.V(r,o.source,"raster-array source can only be used with layer type 'raster'.")):i.push(new e.V(r,o,`layer "${o.id}" must specify a "source-layer"`)):i.push(new e.V(r,o.source,`source "${o.source}" not found`));}else i.push(new e.V(r,o,'missing required property "source"'));return i=i.concat(Z({key:r,value:o,valueSpec:a.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>_e({key:`${r}.type`,value:o.type,valueSpec:a.layer.type,style:t.style,styleSpec:t.styleSpec,object:o,objectKey:"type"}),filter:t=>J(e.C({layerType:n},t)),layout:t=>Z({layer:o,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>ie(e.C({layerType:n},t))}}),paint:t=>Z({layer:o,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>te(e.C({layerType:n,layer:o},t))}})}})),i}function re(t){const i=t.value,o=t.key,r=e.B(i);return "string"!==r?[new e.V(o,i,`string expected, ${r} found`)]:[]}const se={promoteId:function({key:t,value:i}){if("string"===e.B(i))return re({key:t,value:i});{const e=[];for(const o in i)e.push(...re({key:`${t}.${o}`,value:i[o]}));return e}}};function ae(t){const i=t.value,o=t.key,r=t.styleSpec,s=t.style;if(!i.type)return [new e.V(o,i,'"type" is required')];const a=e.D(i.type);let n=[];switch(["vector","raster","raster-dem","raster-array"].includes(a)&&(i.url||i.tiles||n.push(new e.A(o,i,'Either "url" or "tiles" is required.'))),a){case"vector":case"raster":case"raster-dem":case"raster-array":return n=n.concat(Z({key:o,value:i,valueSpec:r[`source_${a.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:se})),n;case"geojson":if(n=Z({key:o,value:i,valueSpec:r.source_geojson,style:s,styleSpec:r,objectElementValidators:se}),i.cluster)for(const e in i.clusterProperties){const[t,r]=i.clusterProperties[e],s="string"==typeof t?[t,["accumulated"],["get",e]]:t;n.push(...X({key:`${o}.${e}.map`,value:r,expressionContext:"cluster-map"})),n.push(...X({key:`${o}.${e}.reduce`,value:s,expressionContext:"cluster-reduce"}));}return n;case"video":return Z({key:o,value:i,valueSpec:r.source_video,style:s,styleSpec:r});case"image":return Z({key:o,value:i,valueSpec:r.source_image,style:s,styleSpec:r});case"canvas":return [new e.V(o,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return K({key:`${o}.type`,value:i.type,valueSpec:{values:ne(r)},style:s,styleSpec:r})}}function ne(e){return e.source.reduce(((t,i)=>{const o=e[i];return "enum"===o.type.type&&(t=t.concat(Object.keys(o.type.values))),t}),[])}function le(t){const i=t.value,o=t.styleSpec,r=o.light,s=t.style;let a=[];const n=e.B(i);if(void 0===i)return a;if("object"!==n)return a=a.concat([new e.V("light",i,`object expected, ${n} found`)]),a;for(const t in i){const n=t.match(/^(.*)-transition$/);a=a.concat(n&&r[n[1]]&&r[n[1]].transition?_e({key:t,value:i[t],valueSpec:o.transition,style:s,styleSpec:o}):r[t]?_e({key:t,value:i[t],valueSpec:r[t],style:s,styleSpec:o}):[new e.V(t,i[t],`unknown property "${t}"`)]);}return a}function ce(t){const i=t.value;let o=[];if(!i)return o;const r=e.B(i);if("object"!==r)return o=o.concat([new e.V("light-3d",i,`object expected, ${r} found`)]),o;const s=t.styleSpec,a=s["light-3d"],n=t.key,l=t.style,c=t.style.lights;for(const t of ["type","id"])if(!(t in i))return o=o.concat([new e.V("light-3d",i,`missing property ${t} on light`)]),o;if(i.type&&c)for(let r=0;r[],array:H,boolean:function(t){const i=t.value,o=t.key,r=e.B(i);return "boolean"!==r?[new e.V(o,i,`boolean expected, ${r} found`)]:[]},number:W,color:function(t){const i=t.key,o=t.value,r=e.B(o);return "string"!==r?[new e.V(i,o,`color expected, ${r} found`)]:null===e.U.parseCSSColor(o)?[new e.V(i,o,`color expected, "${o}" found`)]:[]},enum:K,filter:J,function:$,layer:oe,object:Z,source:ae,model:e.Z,light:le,"light-3d":ce,terrain:he,fog:ue,string:re,formatted:function(e){return 0===re(e).length?[]:X(e)},resolvedImage:function(e){return 0===re(e).length?[]:X(e)},projection:function(t){const i=t.value,o=t.styleSpec,r=o.projection,s=t.style;let a=[];const n=e.B(i);if("object"===n)for(const e in i)a=a.concat(_e({key:e,value:i[e],valueSpec:r[e],style:s,styleSpec:o}));else "string"!==n&&(a=a.concat([new e.V("projection",i,`object or string expected, ${n} found`)]));return a},import:function(t){const{value:i,styleSpec:o}=t,{data:r,...s}=i;Object.defineProperty(s,"__line__",{value:i.__line__,enumerable:!1});let a=Z(e.C({},t,{value:s,valueSpec:o.import}));return ""===e.D(s.id)&&a.push(new e.V(`${t.key}.id`,s,"import id can't be an empty string")),r&&(a=a.concat(me(r,o,{key:`${t.key}.data`}))),a}};function _e(t,i=!1){const o=t.value,r=t.valueSpec,s=t.styleSpec;if(r.expression&&e.X(e.D(o)))return $(t);if(r.expression&&e.J(e.K(o)))return X(t);if(r.type&&de[r.type]){const o=de[r.type](t);return !0===i&&o.length>0&&"array"===e.B(t.value)?X(t):o}return Z(e.C({},t,{valueSpec:r.type?s[r.type]:r}))}function pe(t){const i=t.value,o=t.key,r=re(t);return r.length||(-1===i.indexOf("{fontstack}")&&r.push(new e.V(o,i,'"glyphs" url must include a "{fontstack}" token')),-1===i.indexOf("{range}")&&r.push(new e.V(o,i,'"glyphs" url must include a "{range}" token'))),r}function me(t,i=e._,o={}){return _e({key:o.key||"",value:t,valueSpec:i.$root,styleSpec:i,style:t,objectElementValidators:{glyphs:pe,"*":()=>[]}})}function fe(t,i=e._){return Ie(me(t,i))}const ge=e=>Ie(ae(e)),ve=e=>Ie(le(e)),xe=e=>Ie(ce(e)),ye=e=>Ie(he(e)),be=e=>Ie(ue(e)),we=e=>Ie(oe(e)),Te=e=>Ie(J(e)),Ee=e=>Ie(te(e)),Ce=e=>Ie(ie(e)),Se=t=>Ie(e.Z(t));function Ie(e){return e.slice().sort(((e,t)=>e.line&&t.line?e.line-t.line:0))}function De(t,i){let o=!1;if(i&&i.length)for(const r of i)r instanceof e.A?e.w(r.message):(t.fire(new e.t(new Error(r.message))),o=!0);return o}let Re;class Ae extends e.E{constructor(t,i="flat"){super(),this._transitionable=new e.$(Re||(Re=new e.a0({anchor:new e.a1(e._.light.anchor),position:new e.a2(e._.light.position),color:new e.a1(e._.light.color),intensity:new e.a1(e._.light.intensity)}))),this.setLight(t,i),this._transitioning=this._transitionable.untransitioned();}getLight(){return this._transitionable.serialize()}setLight(e,t,i={}){this._validate(ve,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,o){return (!o||!1!==o.validate)&&De(this,t.call(fe,e.l({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e._})))}}const Le=new e.a0({source:new e.a1(e._.terrain.source),exaggeration:new e.a1(e._.terrain.exaggeration)});let Pe=class extends e.E{constructor(t,i,o,r){super(),this.scope=o,this._transitionable=new e.$(Le,o,r),this._transitionable.setTransitionOrValue(t,r),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=i;}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.a3(t)).get("exaggeration")}isZoomDependent(){const t=this._transitionable._values.exaggeration;return null!=t&&null!=t.value&&null!=t.value.expression&&t.value.expression instanceof e.a4}};const Me=45,ze=65,Oe=.05;function Fe(t,i,o,r){const s=e.a7(Me,ze,o),[a,n]=ke(t,r);let l=1-Math.min(1,Math.exp((i-a)/(n-a)*-6));return l*=l*l,l=Math.min(1,1.00747*l),l*s*t.alpha}function ke(e,t){const i=.5/Math.tan(.5*t);return [e.range[0]+i,e.range[1]+i]}function Be(t,i,o,r,s){const a=e.a6.vec3.transformMat4([],[i,o,r],s.mercatorFogMatrix);return Fe(t,e.a6.vec3.length(a),s.pitch,s._fov)}function Ne(t,i,o,r,s,a,n){const l=[[o,r,0],[s,r,0],[s,a,0],[o,a,0]];let c=Number.MAX_VALUE,h=-Number.MAX_VALUE;for(const t of l){const o=e.a6.vec3.transformMat4([],t,i),r=e.a6.vec3.length(o);c=Math.min(c,r),h=Math.max(h,r);}return [Fe(t,c,n.pitch,n._fov),Fe(t,h,n.pitch,n._fov)]}const Ue=new e.a0({range:new e.a1(e._.fog.range),color:new e.a1(e._.fog.color),"high-color":new e.a1(e._.fog["high-color"]),"space-color":new e.a1(e._.fog["space-color"]),"horizon-blend":new e.a1(e._.fog["horizon-blend"]),"star-intensity":new e.a1(e._.fog["star-intensity"]),"vertical-range":new e.a1(e._.fog["vertical-range"])});class Ge extends e.E{constructor(t,i,o,r){super(),this._transitionable=new e.$(Ue,o,new Map(r)),this.set(t,r),this._transitioning=this._transitionable.untransitioned(),this._transform=i,this.properties=new e.a8(Ue),this.scope=o;}get state(){const t=this._transform,i="globe"===t.projection.name,o=e.a9(t.zoom),r=this.properties.get("range"),s=[.5,3];return {range:i?[e.aa(s[0],r[0],o),e.aa(s[1],r[1],o)]:r,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(t,i,o={}){if(this._validate(be,t,o))return;const r=e.l({},t);for(const t of Object.keys(e._.fog))void 0===r[t]&&(r[t]=e._.fog[t].default);this._options=r,this._transitionable.setTransitionOrValue(this._options,i);}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.a7(Me,ze,t))*i.a}getOpacityAtLatLng(t,i){return this._transform.projection.supportsFog?function(t,i,o){const r=e.a5.fromLngLat(i),s=o.elevation?o.elevation.getAtPointOrZero(r):0;return Be(t,r.x,r.y,s,o)}(this.state,t,i):0}getOpacityForTile(t){if(!this._transform.projection.supportsFog)return [1,1];const i=this._transform.calculateFogTileMatrix(t.toUnwrapped());return Ne(this.state,i,0,0,e.ab,e.ab,this._transform)}getOpacityForBounds(e,t,i,o,r){return this._transform.projection.supportsFog?Ne(this.state,e,t,i,o,r,this._transform):[1,1]}getFovAdjustedRange(e){return this._transform.projection.supportsFog?ke(this.state,e):[0,1]}isVisibleOnFrustum(t){if(!this._transform.projection.supportsFog)return !1;const i=[4,5,6,7];for(const o of i){const i=t.points[o];let r;if(i[2]>=0)r=i;else {const s=t.points[o-4];r=e.ac(s,i,s[2]/(s[2]-i[2]));}if(Be(this.state,r[0],r[1],0,this._transform)>=Oe)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,o){return (!o||!1!==o.validate)&&De(this,t.call(fe,e.l({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e._})))}}class je extends e.E{constructor(t,i,o,r){super(),this.scope=o,this._options=t,this.properties=new e.a8(i),this._transitionable=new e.$(i,o,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")}}let Ve,qe;class Ze{constructor(e,t,i,o){this.screenBounds=e,this.cameraPoint=t,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,o);}static createFromScreenPoints(t,i){let o,r;if(t instanceof e.P||"number"==typeof t[0]){const s=e.P.convert(t);o=[s],r=i.isPointAboveHorizon(s);}else {const s=e.P.convert(t[0]),a=e.P.convert(t[1]);o=[s,a],r=e.ae(s,a).every((e=>i.isPointAboveHorizon(e)));}return new Ze(o,i.getCameraPoint(),r,i)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return e.ae(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const i=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],r=e.ae(i,o,0,!1);return this.cameraPoint.y>o.y&&(this.cameraPoint.x>i.x&&this.cameraPoint.x=o.x?r[2]=this.cameraPoint:this.cameraPoint.x<=i.x&&(r[3]=this.cameraPoint)),e.af(r,t)}bufferedCameraGeometryGlobe(t){const i=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],r=e.ae(i,o,t),s=this.cameraPoint.clone();switch(3*((s.y>i.y)+(s.y>o.y))+((s.x>i.x)+(s.x>o.x))){case 0:r[0]=s,r[4]=s.clone();break;case 1:r.splice(1,0,s);break;case 2:r[1]=s;break;case 3:r.splice(4,0,s);break;case 5:r.splice(2,0,s);break;case 6:r[3]=s;break;case 7:r.splice(3,0,s);break;case 8:r[2]=s;}return r}containsTile(t,i,o,r=0){const s=t.queryPadding/i._pixelsPerMercatorPixel+1,a=o?this._bufferedCameraMercator(s,i):this._bufferedScreenMercator(s,i);let n=t.tileID.wrap+(a.unwrapped?r:0);const l=a.polygon.map((i=>e.ag(t.tileTransform,i,n)));if(!e.ah(l,0,0,e.ab,e.ab))return;n=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?r:0);const c=this.screenGeometryMercator.polygon.map((i=>e.ai(t.tileTransform,i,n))),h=c.map((t=>new e.P(t[0],t[1]))),u=i.getFreeCameraOptions().position||new e.a5(0,0,0),d=e.ai(t.tileTransform,u,n),_=c.map((t=>{const i=e.a6.vec3.sub(t,t,d);return e.a6.vec3.normalize(i,i),new e.aj(d,i)})),p=e.ak(t,1,i.zoom)*i._pixelsPerMercatorPixel;return {queryGeometry:this,tilespaceGeometry:h,tilespaceRays:_,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(m=e.al(l),m.min.x=e.ap(m.min.x,0,e.ab),m.min.y=e.ap(m.min.y,0,e.ab),m.max.x=e.ap(m.max.x,0,e.ab),m.max.y=e.ap(m.max.y,0,e.ab),m),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:p};var m;}_bufferedScreenMercator(e,t){const i=$e(e);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let o;return o="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._screenRaycastCache[i]=o,o}}_bufferedCameraMercator(e,t){const i=$e(e);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let o;return o="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._cameraRaycastCache[i]=o,o}}_projectAndResample(t,i){const o=function(t,i){const o=e.a6.mat4.multiply([],i.pixelMatrix,i.globeMatrix),r=[0,-e.aq,0,1],s=[0,e.aq,0,1],a=[0,0,0,1];e.a6.vec4.transformMat4(r,r,o),e.a6.vec4.transformMat4(s,s,o),e.a6.vec4.transformMat4(a,a,o);const n=new e.P(r[0]/r[3],r[1]/r[3]),l=new e.P(s[0]/s[3],s[1]/s[3]),c=e.an(t,n)&&r[3]1?He(t.slice(0,d),i):[],m=dnew e.P(We(t.x),t.y))),m=m.map((t=>new e.P(We(t.x),t.y)));const f=[...p];0===f.length&&f.push(m[m.length-1]);const g=e.aa(f[f.length-1].y,(0===m.length?p[0]:m[0]).y,_);let v;return v=c?[new e.P(0,g),new e.P(0,0),new e.P(1,0),new e.P(1,g)]:[new e.P(1,g),new e.P(1,1),new e.P(0,1),new e.P(0,g)],f.push(...v),0===m.length?f.push(p[0]):f.push(...m),{polygon:f.map((t=>new e.a5(t.x,t.y))),unwrapped:!1}}(t,i);if(o)return o;const r=function(t,i){let o=!1,r=-1/0,s=0;for(let e=0;er&&(r=t[e].x,s=e);for(let e=0;e.5&&(r.x{e.x-=1;})),{polygon:t,unwrapped:o}}(He(t,i).map((t=>new e.P(We(t.x),t.y))),i);return {polygon:r.polygon.map((t=>new e.a5(t.x,t.y))),unwrapped:r.unwrapped}}}function He(t,i){return e.ao(t,(e=>{const t=i.pointCoordinate3D(e);e.x=t.x,e.y=t.y;}),1/256)}function We(e){return e<0?1+e%1:e%1}function $e(e){return 100*e|0}function Xe(t,i,o,r,s){const a=function(o,r){if(o)return s(o);if(r){if(t.url&&r.tiles&&t.tiles&&delete t.tiles,r.variants){if(!Array.isArray(r.variants))return s(new Error("variants must be an array"));for(const t of r.variants){if(null==t||"object"!=typeof t||t.constructor!==Object)return s(new Error("variant must be an object"));if(!Array.isArray(t.capabilities))return s(new Error("capabilities must be an array"));if(1===t.capabilities.length&&"meshopt"===t.capabilities[0]){r=e.l(r,t);break}}}const o=e.ar(e.l(r,t),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);r.vector_layers&&(o.vectorLayers=r.vector_layers,o.vectorLayerIds=o.vectorLayers.map((e=>e.id))),r.raster_layers&&(o.rasterLayers=r.raster_layers,o.rasterLayerIds=o.rasterLayers.map((e=>e.id))),o.tiles=i.canonicalizeTileset(o,t.url),s(null,o);}},n=function(e,t,i){if(!e)return null;if(!t&&!i)return e;i=i||e.worldview_default;const o=Object.values(e.language||{});if(0===o.length)return null;const r=Object.values(e.worldview||{});if(0===r.length)return null;const s=o.every((e=>e===t)),a=r.every((e=>e===i));return s&&a?e:t in(e.language_options||{})||i in(e.worldview_options||{})?null:e.language_options&&e.worldview_options?e:null}(t.data,o,r);return n?e.q.frame((()=>a(null,n))):t.url?e.n(i.transformRequest(i.normalizeSourceURL(t.url,null,o,r),e.R.Source),a):e.q.frame((()=>{const{data:e,...i}=t;a(null,i);}))}class Ye{constructor(t,i,o){this.bounds=e.as.convert(this.validateBounds(t)),this.minzoom=i||0,this.maxzoom=o||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(t){const i=Math.pow(2,t.z),o=Math.floor(e.am(this.bounds.getWest())*i),r=Math.floor(e.at(this.bounds.getNorth())*i),s=Math.ceil(e.am(this.bounds.getEast())*i),a=Math.ceil(e.at(this.bounds.getSouth())*i);return t.x>=o&&t.x=r&&t.y{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}`),o&&2!==o.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${o}`),this.fire(new e.t(r))):s&&(e.l(this,s),s.bounds&&(this.tileBounds=new Ye(s.bounds,this.minzoom,this.maxzoom)),L(s.tiles,this.map._requestManager._customAccessToken),this.fire(new e.x("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.x("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.av(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 e.l({},this._options)}loadTile(t,i){const o=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),r=this.map._requestManager.transformRequest(o,e.R.Tile),s=this.map.style?this.map.style.getLut(this.scope):null,a={request:r,data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,lut:s?{image:s.image.clone()}:null,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:e.q.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};if(a.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state)"loading"===t.state?t.reloadCallback=i:t.request=t.actor.send("reloadTile",a,n.bind(this));else if(t.actor=this._tileWorkers[o]=this._tileWorkers[o]||this.dispatcher.getActor(),this.dispatcher.ready)t.request=t.actor.send("loadTile",a,n.bind(this),void 0,!0);else {const i=e.aw.call({deduped:this._deduped},a,((e,i)=>{e||!i?n.call(this,e):(a.data={cacheControl:i.cacheControl,expires:i.expires,rawData:i.rawData.slice(0)},t.actor&&t.actor.send("loadTile",a,n.bind(this),void 0,!0));}),!0);t.request={cancel:i};}function n(o,r){return delete t.request,t.aborted?i(null):o&&404!==o.status?i(o):(r&&r.resourceTiming&&(t.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&r&&t.setExpiryData(r),t.loadVectorData(r,this.map.painter),e.ax(this.dispatcher),i(null),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 Je extends e.E{constructor(t,i,o,r){super(),this.id=t,this.dispatcher=o,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=e.l({type:"raster"},i),e.l(this,e.ar(i,["url","scheme","tileSize"]));}load(t){this._loaded=!1,this.fire(new e.x("dataloading",{dataType:"source"})),this._tileJSONRequest=Xe(this._options,this.map._requestManager,null,null,((i,o)=>{this._tileJSONRequest=null,this._loaded=!0,i?this.fire(new e.t(i)):o&&(e.l(this,o),o.bounds&&(this.tileBounds=new Ye(o.bounds,this.minzoom,this.maxzoom)),L(o.tiles),this.fire(new e.x("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.x("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.av(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 e.l({},this._options)}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,i){const o=e.q.devicePixelRatio>=2,r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),o,this.tileSize);t.request=e.o(this.map._requestManager.transformRequest(r,e.R.Tile),((o,r,s,a)=>(delete t.request,t.aborted?(t.state="unloaded",i(null)):o?(t.state="errored",i(o)):r?(this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:s,expires:a}),t.setTexture(r,this.map.painter),t.state="loaded",e.ax(this.dispatcher),void i(null)):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);}}class Qe extends Je{constructor(t,i,o,r){super(t,i,o,r),this.type="raster-array",this.maxzoom=22,this._options=e.l({type:"raster-array"},i);}triggerRepaint(e){const t=this.map.painter._terrain,i=this.map.style.getSourceCache(this.id);t&&t.enabled&&i&&t._clearRenderCacheForTile(i.id,e.tileID),this.map.triggerRepaint();}loadTile(t,i){const o=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),r=this.map._requestManager.transformRequest(o,e.R.Tile);t.requestParams=r,t.actor||(t.actor=this.dispatcher.getActor()),t.request=t.fetchHeader(void 0,((e,o,r,s)=>{if(delete t.request,t.aborted)return t.state="unloaded",i(null);if(e){if(20===e.code)return;return t.state="errored",i(e)}this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:r,expires:s}),t.state="empty",i(null);}));}unloadTile(t,i){const o=t.texture;o&&o instanceof e.T?(t.destroy(!0),this.map.painter.saveTileTexture(o)):(t.destroy(),t.flushQueues(),t._isHeaderLoaded=!1,delete t._mrt,delete t.textureDescriptor),t.fbo&&(t.fbo.destroy(),delete t.fbo),delete t.request,delete t.requestParams,delete t.neighboringTiles,t.state="unloaded";}prepareTile(t,i,o){t._isHeaderLoaded&&("empty"!==t.state&&(t.state="reloading"),t.fetchBand(i,o,((i,o)=>{if(i)return t.state="errored",this.fire(new e.t(i)),void this.triggerRepaint(t);o&&(t.setTexture(o,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,o=i&&i.bands&&i.bands;return o?o[0]:0}getTextureDescriptor(t,i,o){if(!t)return;const r=i.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!r)return;let s=null;i instanceof e.aB?s=i.paint.get("raster-array-band"):i instanceof e.aC&&(s=i.paint.get("raster-particle-array-band"));const a=s||this.getInitialBand(r);if(null!=a)if(t.textureDescriptor){if(!t.updateNeeded(r,a)||o)return Object.assign({},t.textureDescriptor,{texture:t.texture})}else this.prepareTile(t,r,a);}}const et={vector:Ke,raster:Je,"raster-dem":class extends Je{constructor(t,i,o,r){super(t,i,o,r),this.type="raster-dem",this.maxzoom=22,this._options=e.l({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox";}loadTile(t,i){const o=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function r(e,o){e&&(t.state="errored",i(e)),o&&(t.dem=o,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0,t.state="loaded",i(null));}t.request=e.o(this.map._requestManager.transformRequest(o,e.R.Tile),function(o,s,a,n){if(delete t.request,t.aborted)t.state="unloaded",i(null);else if(o)t.state="errored",i(o);else if(s){this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:a,expires:n});const i=ImageBitmap&&s instanceof ImageBitmap&&e.ay(),o=1-(s.width-e.az(s.width))/2;o<1||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID));const l=i?s:e.q.getImageData(s,o),c={uid:t.uid,coord:t.tileID,source:this.id,scope:this.scope,rawImageData:l,encoding:this.encoding,padding:o};t.actor&&"expired"!==t.state||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",c,r.bind(this),void 0,!0));}}.bind(this));}_getNeighboringTiles(t){const i=t.canonical,o=Math.pow(2,i.z),r=(i.x-1+o)%o,s=0===i.x?t.wrap-1:t.wrap,a=(i.x+1+o)%o,n=i.x+1===o?t.wrap+1:t.wrap,l={};return l[new e.aA(t.overscaledZ,s,i.z,r,i.y).key]={backfilled:!1},l[new e.aA(t.overscaledZ,n,i.z,a,i.y).key]={backfilled:!1},i.y>0&&(l[new e.aA(t.overscaledZ,s,i.z,r,i.y-1).key]={backfilled:!1},l[new e.aA(t.overscaledZ,t.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new e.aA(t.overscaledZ,n,i.z,a,i.y-1).key]={backfilled:!1}),i.y+1{if(this._loaded=!0,this._pendingLoad=null,i)this.fire(new e.t(i));else {const i={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&o&&o.resourceTiming&&o.resourceTiming[this.id]&&(i.resourceTiming=o.resourceTiming[this.id]),t&&(this._partialReload=!0),this.fire(new e.x("data",i)),this._partialReload=!1,this._metadataFired=!0;}this._coalesce&&(this._updateWorkerData(t),this._coalesce=!1);}));}loaded(){return this._loaded}loadTile(t,i){const o=t.actor?"reloadTile":"loadTile";t.actor=this.actor;const r=this.map.style?this.map.style.getLut(this.scope):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:r?{image:r.image.clone()}:null,scope:this.scope,pixelRatio:e.q.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,partial:s};t.request=this.actor.send(o,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"===o),i(null)))),void 0,"loadTile"===o);}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 e.l({},this._options,{type:this.type,data:this._data})}hasTransition(){return !1}},video:class extends e.aD{constructor(e,t,i,o){super(e,t,i,o),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.aE(this.urls,((t,i)=>{this._loaded=!0,t?this.fire(new e.t(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.t(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.aD,model:class extends e.E{constructor(e,t,i,o){super(),this.id=e,this.type="model",this.models=[],this._loaded=!1,this._options=t;}load(){const t=[];for(const i in this._options.models){const o=this._options.models[i],r=e.aG(this.map._requestManager.transformRequest(o.uri,e.R.Model).url).then((t=>{if(!t)return;const r=e.aH(t),s=new e.aI(i,o.position,o.orientation,r);s.computeBoundsAndApplyParent(),this.models.push(s);})).catch((t=>{this.fire(new e.t(new Error(`Could not load model ${i} from ${o.uri}: ${t.message}`)));}));t.push(r);}return Promise.allSettled(t).then((()=>{this._loaded=!0,this.fire(new e.x("data",{dataType:"source",sourceDataType:"metadata"}));})).catch((t=>{this.fire(new e.t(new Error(`Could not load models: ${t.message}`)));}))}onAdd(e){this.map=e,this.load();}hasTransition(){return !1}loaded(){return this._loaded}getModels(){return this.models}loadTile(e,t){}serialize(){return {type:"model"}}},"batched-model":class extends e.E{constructor(e,t,i,o){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(o);}onAdd(e){this.map=e,this.load();}load(t){this._loaded=!1,this.fire(new e.x("dataloading",{dataType:"source"}));const i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,o=this.map._worldview;this._tileJSONRequest=Xe(this._options,this.map._requestManager,i,o,((r,s)=>{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}`),o&&2!==o.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${o}`),this.fire(new e.t(r))):s&&(e.l(this,s),s.bounds&&(this.tileBounds=new Ye(s.bounds,this.minzoom,this.maxzoom)),L(s.tiles,this.map._requestManager._customAccessToken),this.fire(new e.x("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.x("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 o=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),r={request:this.map._requestManager.transformRequest(o,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};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,s.bind(this));}else t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",r,s.bind(this),void 0,!0);function s(e,o){return t.aborted?i(null):e&&404!==e.status?i(e):(o&&(o.resourceTiming&&(t.resourceTiming=o.resourceTiming),this.map._refreshExpiredTiles&&t.setExpiryData(o),t.buckets={...t.buckets,...o.buckets},o.featureIndex&&(t.latestFeatureIndex=o.featureIndex)),t.state="loaded",void i(null))}}serialize(){return e.l({},this._options)}},canvas:class extends e.aD{constructor(t,i,o,r){super(t,i,o,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.t(new e.V(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.t(new e.V(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new e.t(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.t(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.t(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.t(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.aF||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,o,r){super(),this.id=t,this.type="custom",this._dataType="raster",this._dispatcher=o,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.t(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new e.t(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new Ye(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),e.l(this,e.ar(i,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]));}serialize(){return e.ar(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new e.x("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.x("data",{dataType:"source",sourceDataType:"content"}));}loaded(){return this._loaded}onAdd(t){this.map=t,this._loaded=!1,this.fire(new e.x("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:o}=e.canonical;return this._implementation.hasTile({x:t,y:i,z:o})}return !this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e,t){const{x:i,y:o,z:r}=e.tileID.canonical,s=new AbortController;e.request=Promise.resolve(this._implementation.loadTile({x:i,y:o,z:r},{signal:s.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=>{20!==i.code&&(e.state="errored",t(i));})),e.request.cancel=()=>s.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:o}=t.tileID.canonical;this._implementation.unloadTile({x:e,y:i,z:o});}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.av(this.id,this.scope);this.map.style.clearSource(t);}_update(){this.fire(new e.x("data",{dataType:"source",sourceDataType:"content"}));}}},tt=function(t,i,o,r){const s=new et[i.type](t,i,o,r);if(s.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${s.id}`);return e.aJ(["load","abort","unload","serialize","prepare"],s),s};function it(t,i){const o=e.a6.mat4.identity([]);return e.a6.mat4.scale(o,o,[.5*t.width,.5*-t.height,1]),e.a6.mat4.translate(o,o,[1,-1,0]),e.a6.mat4.multiply(o,o,t.calculateProjMatrix(i.toUnwrapped())),Float32Array.from(o)}function ot(e,t,i,o,r,s,a,n=!1){const l=e.tilesIn(o,a,n);l.sort(st);const c=[];for(const o of l)c.push({wrappedTileID:o.tile.tileID.wrapped().key,queryResults:o.tile.queryRenderedFeatures(t,i,e._state,o,r,s,it(e.transform,o.tile.tileID),n)});const h=function(e){const t={},i={};for(const o of e){const e=o.queryResults,r=o.wrappedTileID,s=i[r]=i[r]||{};for(const i in e){const o=e[i],r=s[i]=s[i]||{},a=t[i]=t[i]||[];for(const e of o)r[e.featureIndex]||(r[e.featureIndex]=!0,a.push(e));}}return t}(c);for(const t in h)h[t].forEach((t=>{const i=t.feature,o=i.layer;o&&"background"!==o.type&&"sky"!==o.type&&"slot"!==o.type&&(i.source=o.source,o["source-layer"]&&(i.sourceLayer=o["source-layer"]),i.state=void 0!==i.id?e.getFeatureState(o["source-layer"],i.id):{});}));return h}function rt(e,t){const i=e.getRenderableIds().map((t=>e.getTileByID(t))),o=[],r={};for(let e=0;e>=1)>1;){const e=i+r>>1,l=o+s>>1;1&t?(r=i,s=o,i=a,o=n):(i=r,o=s,r=a,s=n),a=e,n=l;}const l=4*e;lt[l+0]=i,lt[l+1]=o,lt[l+2]=r,lt[l+3]=s;}const ct=new Uint16Array(2178),ht=new Uint8Array(1089),ut=new Uint16Array(1089);function dt(e){return 0===e?-.03125:32===e?.03125:0}const _t=(()=>({type:2,extent:e.ab,loadGeometry:()=>[[new e.P(0,0),new e.P(e.ab+1,0),new e.P(e.ab+1,e.ab+1),new e.P(0,e.ab+1),new e.P(0,0)]]}))();class pt{constructor(t,i,o,r,s){this.tileID=t,this.uid=e.aP(),this.uses=0,this.tileSize=i,this.tileZoom=o,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=s,r&&r.style&&(this._lastUpdatedBrightness=r.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",r&&r.transform&&(this.projection=r.transform.projection);}registerFadeDuration(t){const i=t+this.timeAdded;it.getLayer(e))).filter(Boolean);if(0!==e.length){o.layers=e,o.stateDependentLayerIds&&(o.stateDependentLayers=o.stateDependentLayerIds.map((t=>e.filter((e=>e.id===t))[0])));for(const t of e)i[t.fqid]=o;}}return i}(t.buckets,i.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const i=this.buckets[t];if(i instanceof e.aR){if(this.hasSymbolBuckets=!0,!o)break;i.justReloaded=!0;}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const i=this.buckets[t];if(i instanceof e.aR&&i.hasRTLText){this.hasRTLText=!0,e.aS();break}}this.queryPadding=0;for(const e in this.buckets){const t=this.buckets[e],o=i.style.getOwnLayer(e);if(!o)continue;const r=o.queryRadius(t);this.queryPadding=Math.max(this.queryPadding,r);}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas),this._lastUpdatedBrightness=t.brightness;}else this.collisionBoxArray=new e.aQ;}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded";}}getBucket(e){return this.buckets[e.fqid]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t);}const i=t.gl,o=this.imageAtlas;if(o&&!o.uploaded){const r=!!Object.keys(o.patternPositions).length;this.imageAtlasTexture=new e.T(t,o.image,i.RGBA8,{useMipmap:r}),this.imageAtlas.uploaded=!0;}this.glyphAtlasImage&&(this.glyphAtlasTexture=new e.T(t,this.glyphAtlasImage,i.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new e.T(t,this.lineAtlas.image,i.R8),this.lineAtlas.uploaded=!0);}prepare(e,t,i){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture,i),!t||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const o=t.style.getBrightness();(this._lastUpdatedBrightness||o)&&(this._lastUpdatedBrightness&&o&&Math.abs(this._lastUpdatedBrightness-o)<.001||(this._lastUpdatedBrightness=o,this.updateBuckets(t)));}queryRenderedFeatures(e,t,i,o,r,s,a,n){return this.latestFeatureIndex&&(this.latestFeatureIndex.rawTileData||this.latestFeatureIndex.is3DTile)?this.latestFeatureIndex.query({tileResult:o,pixelPosMatrix:a,transform:s,params:r,tileTransform:this.tileTransform},e,t,i):{}}querySourceFeatures(t,i){const o=this.latestFeatureIndex;if(!o||!o.rawTileData)return;const r=o.loadVTLayers(),s=i?i.sourceLayer:"",a=r._geojsonTileLayer||r[s];if(!a)return;const n=e.aT(i&&i.filter),{z:l,x:c,y:h}=this.tileID.canonical,u={z:l,x:c,y:h};for(let i=0;ie)t=!1;else if(i)if(this.expirationTime=0;e--){const t=4*e,i=lt[t+0],o=lt[t+1],r=lt[t+2],s=lt[t+3],a=i+r>>1,n=o+s>>1,l=a+n-o,c=n+i-a,h=o*nt+i,u=s*nt+r,d=n*nt+a,_=Math.hypot((ct[2*h+0]+ct[2*u+0])/2-ct[2*d+0],(ct[2*h+1]+ct[2*u+1])/2-ct[2*d+1])>=16;ht[d]=ht[d]||(_?1:0),e<1022&&(ht[d]=ht[d]||ht[(o+c>>1)*nt+(i+l>>1)]||ht[(s+c>>1)*nt+(r+l>>1)]);}const s=new e.aN,a=new e.aO;let n=0;function l(t,i){const o=i*nt+t;return 0===ut[o]&&(s.emplaceBack(ct[2*o+0],ct[2*o+1],t*e.ab/at,i*e.ab/at),ut[o]=++n),ut[o]-1}function c(e,t,i,o,r,s){const n=e+i>>1,h=t+o>>1;if(Math.abs(e-r)+Math.abs(t-s)>1&&ht[h*nt+n])c(r,s,e,t,n,h),c(i,o,r,s,n,h);else {const n=l(e,t),c=l(i,o),h=l(r,s);a.emplaceBack(n,c,h);}}return c(0,0,at,at,at,0),c(at,at,0,0,0,at),{vertices:s,indices:a}}(this.tileID.canonical,i);r=t.vertices,s=t.indices;}else {r=new e.aN,s=new e.aO;for(const{x:e,y:t}of o)r.emplaceBack(e,t,0,0);const t=e.b2(r.int16,void 0,4);for(let e=0;e0&&(l=e.a6.mat4.invert(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(t,r,i,a,l,n),this._makeGlobeTileDebugTextBuffer(t,r,i,a,l,n);}_globePoint(t,i,o,r,s,a,n){let l=e.b6(t,i,o);if(a){const s=1<.5?d=-1:u<-.5&&(d=1);let _=(t/e.ab+o.x)/s+d,p=(i/e.ab+o.y)/s;_=(_-c)*r._pixelsPerMercatorPixel+c,p=(p-h)*r._pixelsPerMercatorPixel+h;const m=[_*r.worldSize,p*r.worldSize,0];e.a6.vec3.transformMat4(m,m,a),l=e.b7(l,m,n);}return e.a6.vec3.transformMat4(l,l,s)}_makeGlobeTileDebugBorderBuffer(t,i,o,r,s,a){const n=new e.a_,l=new e.a$,c=new e.b8,h=(e,t,h,u,d)=>{const _=(h-e)/(d-1),p=(u-t)/(d-1),m=n.length;for(let h=0;hu*e+t;for(let e=0;e{if(e)i(e);else try{const e=o.getHeaderLength(r);if(e>t)return void(this.request=this.fetchHeader(e,i));o.parseHeader(r),this._isHeaderLoaded=!0;let n=0;for(const e of Object.values(o.layers))n=Math.max(n,e.dataIndex[e.dataIndex.length-1].last_byte);r.byteLength>=n&&(this.entireBuffer=r),i(null,this.entireBuffer||r,s,a);}catch(e){i(e);}})),this.request}fetchBand(t,i,o){const r=this._mrt;if(!this._isHeaderLoaded||!r)return void o(new Error("Tile header is not ready"));const s=this.actor;if(!s)return void o(new Error("Can't fetch tile band without an actor"));let a;const n=(e,r)=>{a.complete(e,r),e?o(e):(this.updateTextureDescriptor(t,i),o(null,this.textureDescriptor&&this.textureDescriptor.img));},l=(e,t)=>{if(e)return o(e);const i=s.send("decodeRasterArray",{buffer:t,task:a},n,void 0,!0);this._workQueue.push((()=>{i&&i.cancel(),a.cancel();}));},c=r.getLayer(t);if(!c)return void o(new Error(`Unknown sourceLayer "${t}"`));if(c.hasDataForBand(i))return this.updateTextureDescriptor(t,i),void o(null,this.textureDescriptor?this.textureDescriptor.img:null);const h=c.getDataRange([i]);if(a=r.createDecodingTask(h),!a||a.tasks.length)if(this.flushQueues(),this.entireBuffer)l(null,this.entireBuffer.slice(h.firstByte,h.lastByte+1));else {const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${h.firstByte}-${h.lastByte}`}}),i=e.bc(t,l);this._fetchQueue.push((()=>{i.cancel(),a.cancel();}));}else o(null);}updateNeeded(e,t){return (!this.textureDescriptor||this.textureDescriptor.band!==t||this.textureDescriptor.layer!==e)&&"errored"!==this.state}updateTextureDescriptor(t,i){if(!this._mrt)return;const o=this._mrt.getLayer(t);if(!o||!o.hasBand(i)||!o.hasDataForBand(i))return;const{bytes:r,tileSize:s,buffer:a,offset:n,scale:l}=o.getBandView(i),c=s+2*a,h={data:r,width:c,height:c},u=this.texture;u&&u instanceof e.T&&u.update(h,{premultiply:!1}),this.textureDescriptor={layer:t,band:i,img:h,buffer:a,offset:n,tileSize:s,format:o.pixelFormat,mix:[l,256*l,65536*l,16777216*l]};}}class ft{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 o=e.wrapped().key;void 0===this.data[o]&&(this.data[o]=[]);const r={value:t,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout((()=>{this.remove(e,r);}),i)),this.data[o].push(r),this.order.push(o),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,o=void 0===t?0:this.data[i].indexOf(t),r=this.data[i][o];return this.data[i].splice(o,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 o of this.data[i])e(o.value)||t.push(o);for(const e of t)this.remove(e.value.tileID,e);}}class gt{constructor(){this.state={},this.stateChanges={},this.deletedStates={};}updateState(t,i,o){const r=String(i);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][r]=this.stateChanges[t][r]||{},e.l(this.stateChanges[t][r],o),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==r&&(this.deletedStates[t][e]=null);}else if(this.deletedStates[t]&&null===this.deletedStates[t][r]){this.deletedStates[t][r]={};for(const e in this.state[t][r])o[e]||(this.deletedStates[t][r][e]=null);}else for(const e in o)this.deletedStates[t]&&this.deletedStates[t][r]&&null===this.deletedStates[t][r][e]&&delete this.deletedStates[t][r][e];}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const o=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&void 0!==t)null!==this.deletedStates[e][o]&&(this.deletedStates[e][o]=this.deletedStates[e][o]||{},this.deletedStates[e][o][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][o])for(i in this.deletedStates[e][o]={},this.stateChanges[e][o])this.deletedStates[e][o][i]=null;else this.deletedStates[e][o]=null;else this.deletedStates[e]=null;}getState(t,i){const o=this.state[t]||{},r=this.stateChanges[t]||{},s=this.deletedStates[t];if(null===s)return {};if(void 0!==i){const t=String(i),a=e.l({},o[t],r[t]);if(s){const e=s[i];if(null===e)return {};for(const t in e)delete a[t];}return a}const a=e.l({},o,r);if(s)for(const e in s)delete a[e];return a}initializeTileState(e,t){e.setFeatureState(this.state,t);}coalesceChanges(t,i){const o={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const i={};for(const o in this.stateChanges[t])this.state[t][o]||(this.state[t][o]={}),e.l(this.state[t][o],this.stateChanges[t][o]),i[o]=this.state[t][o];o[t]=i;}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const i={};if(null===this.deletedStates[t])for(const e in this.state[t])i[e]={},this.state[t][e]={};else for(const e in this.deletedStates[t]){if(null===this.deletedStates[t][e])this.state[t][e]={};else if(this.state[t][e])for(const i of Object.keys(this.deletedStates[t][e]))delete this.state[t][e][i];i[e]=this.state[t][e];}o[t]=o[t]||{},e.l(o[t],i);}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(o).length)for(const e in t)t[e].setFeatureState(o,i);}}class vt 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 ft(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 gt,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){const t=this._tiles[e];if("loaded"!==t.state&&"errored"!==t.state)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),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope);}}getIds(){return e.bd(this._tiles).map((e=>e.tileID)).sort(xt).map((e=>e.key))}getRenderableIds(t,i){const o=[];for(const e in this._tiles)this._isIdRenderable(+e,t,i)&&o.push(this._tiles[e]);return t?o.sort(((t,i)=>{const o=t.tileID,r=i.tileID,s=new e.P(o.canonical.x,o.canonical.y)._rotate(this.transform.angle),a=new e.P(r.canonical.x,r.canonical.y)._rotate(this.transform.angle);return o.overscaledZ-r.overscaledZ||a.y-s.y||a.x-s.x})).map((e=>e.tileID.key)):o.map((e=>e.tileID)).sort(xt).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,o,r){if(r)if(t.state="errored",404!==r.status)this._source.fire(new e.t(r,{tile:t}));else {if(this._source.fire(new e.x("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id,tile:t})),!(t.tileID.key in this._loadedParentTiles))return;if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const e=this.map.painter.terrain;this.update(this.transform,e.getScaledDemTileSize(),!0),e.resetTileLookupCache(this.id);}else this.update(this.transform);}else t.timeAdded=e.q.now(),"expired"===o&&(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),this._source.fire(new e.x("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}));}_backfillDEM(e){const t=this.getRenderableIds();for(let o=0;o1||(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,o),e.neighboringTiles&&e.neighboringTiles[s]&&(e.neighboringTiles[s].backfilled=!0)));}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,i,o){for(const r in this._tiles){let s=this._tiles[r];if(o[r]||!s.hasData()||s.tileID.overscaledZ<=t||s.tileID.overscaledZ>i)continue;let a=s.tileID;for(;s&&s.tileID.overscaledZ>t+1;){const e=s.tileID.scaledTo(s.tileID.overscaledZ-1);s=this._tiles[e.key],s&&s.hasData()&&(a=e);}let n=a;for(;n.overscaledZ>t;)if(n=n.scaledTo(n.overscaledZ-1),e[n.key]){o[a.key]=a;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),o=this._getLoadedTile(t);if(o)return o}}_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,o=Math.ceil(e.height/t)+1,r=Math.floor(i*o*5),s="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,a="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,s):s;this._cache.setMaxSize(a);}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 o=this._tiles[i];o.tileID=o.tileID.unwrapTo(o.tileID.wrap+t),e[o.tileID.key]=o;}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,o,r){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!o)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;if(this.used||this.usedForTerrain){if(this._source.tileID)a=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new e.aA(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:this._source.maxzoom,roundZoom:this._source.roundZoom&&!o,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:s}),this._source.minzoom<=1&&"globe"===t.projection.name&&(a.push(new e.aA(1,0,1,0,0)),a.push(new e.aA(1,0,1,1,0)),a.push(new e.aA(1,0,1,0,1)),a.push(new e.aA(1,0,1,1,1)));}else if(a=t.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!o,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&&this.castsShadows&&r&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!yt(this._source.type)){const e=t.coveringZoomLevel({tileSize:i||this._source.tileSize,roundZoom:this._source.roundZoom&&!o}),n=Math.min(e,this._source.maxzoom);if(s){const e=t.extendTileCover(a,n);for(const t of e)a.push(t);}else {const e=t.extendTileCover(a,n,r);for(const t of e)this._shadowCasterTiles[t.key]=!0,a.push(t);}}const n=this._updateRetainedTiles(a);if(yt(this._source.type)&&0!==a.length){const t={},i={},o=Object.keys(n);for(const r of o){const o=n[r],s=this._tiles[r];if(!s||s.fadeEndTime&&s.fadeEndTime<=e.q.now())continue;const a=this.findLoadedParent(o,Math.max(o.overscaledZ-vt.maxOverzooming,this._source.minzoom));a&&(this._addTile(a.tileID),t[a.tileID.key]=a.tileID),i[r]=o;}const r=a[a.length-1].overscaledZ;for(const e in this._tiles){const t=this._tiles[e];if(n[e]||!t.hasData())continue;let o=t.tileID;for(;o.overscaledZ>r;){o=o.scaledTo(o.overscaledZ-1);const r=this._tiles[o.key];if(r&&r.hasData()&&i[o.key]){n[e]=t.tileID;break}}}for(const e in t)n[e]||(this._coveredTiles[e]=!0,n[e]=t[e]);}for(const e in n)this._tiles[e].clearFadeHold();const l=e.be(this._tiles,n);for(const e of l){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={},o=e.reduce(((e,t)=>Math.min(e,t.overscaledZ)),1/0),r=e[0].overscaledZ,s=Math.max(r-vt.maxOverzooming,this._source.minzoom),a=Math.max(r+vt.maxUnderzooming,this._source.minzoom),n={};for(const i of e){const e=this._addTile(i);t[i.key]=i,e.hasData()||o=this._source.maxzoom){const e=o.children(this._source.maxzoom)[0],i=this.getTile(e);if(i&&i.hasData()){t[e.key]=e;continue}}else {const e=o.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 a=o.overscaledZ-1;a>=s;--a){const s=o.scaledTo(a);if(i[s.key])break;if(i[s.key]=!0,e=this.getTile(s),!e&&r&&(e=this._addTile(s)),e&&(t[s.key]=s,r=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,o=this._tiles[e].tileID;for(;o.overscaledZ>0;){if(o.key in this._loadedParentTiles){i=this._loadedParentTiles[o.key];break}t.push(o.key);const e=o.scaledTo(o.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;o=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 o=Boolean(i);if(!o){const e=this.map?this.map.painter:null,o=this._source.tileSize*t.overscaleFactor();i="raster-array"===this._source.type?new mt(t,o,this.transform.tileZoom,e,this._isRaster):new pt(t,o,this.transform.tileZoom,e,this._isRaster),this._loadTile(i,this._tileLoaded.bind(this,i,t.key,i.state));}return i?(i.uses++,this._tiles[t.key]=i,o||this._source.fire(new e.x("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i):null}_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,o){const r=[],s=this.transform;if(!s)return r;const a="globe"===s.projection.name,n=e.am(s.center.lng);for(const l in this._tiles){const c=this._tiles[l];if(o&&c.clearQueryDebugViz(),c.holdingForFade())continue;let h;if(a){const t=c.tileID.canonical;if(0===t.z){const i=[Math.abs(e.ap(n,...bt(t,-1))-n),Math.abs(e.ap(n,...bt(t,1))-n)];h=[0,2*i.indexOf(Math.min(...i))-1];}else {const i=[Math.abs(e.ap(n,...bt(t,-1))-n),Math.abs(e.ap(n,...bt(t,0))-n),Math.abs(e.ap(n,...bt(t,1))-n)];h=[i.indexOf(Math.min(...i))-1];}}else h=[0];for(const e of h){const o=t.containsTile(c,s,i,e);o&&r.push(o);}}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)),o="globe"===this.transform.projection.name;for(const e of i)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped()),e.expandedProjMatrix=o?this.transform.calculateProjMatrix(e.toUnwrapped(),!1,!0):e.projMatrix;return i}sortCoordinatesByDistance(e){const t=e.slice(),i=this.transform._camera.position,o=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(yt(this._source.type))for(const t in this._tiles){const i=this._tiles[t];if(void 0!==i.fadeEndTime&&i.fadeEndTime>=e.q.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 o=this._tiles[e];o&&o.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 o=new Map,r=Array.isArray(t)?t:[t],s=this.map.painter.terrain,a=this.usedForTerrain&&s?s.getScaledDemTileSize():this._source.tileSize;for(const e of r){const t=e.coveringTiles({tileSize:a,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)o.set(e.key,e);this.usedForTerrain&&e.updateElevation(!1);}const n=Array.from(o.values());e.bf(n,((e,t)=>{const i=new pt(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(e=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),t(e,i);}));}),i);}}function xt(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),o=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||o-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function yt(e){return "raster"===e||"image"===e||"video"===e||"custom"===e}function bt(e,t){const i=1<0:"model"===i.type&&(o=!i.isHidden(e)&&i.paint.get("model-opacity")>0),this.layersGotHidden=this.layersGotHidden||!o&&t.visible,t.visible=o;}}updateZOffset(e,t){this.currentBuildingBuckets=[];for(const e of this.layers){const i=e.layer,o=this.style.getLayerSourceCache(i);let r=1;"fill-extrusion"===i.type&&(r=e.visible?i.paint.get("fill-extrusion-vertical-scale"):0);let s=o?o.getTile(t):null;if(!s&&o&&t.canonical.z>o.getSource().minzoom){let e=t.scaledTo(Math.min(o.getSource().maxzoom,t.overscaledZ-1));for(;e.overscaledZ>=o.getSource().minzoom&&(s=o.getTile(e),!s&&0!==e.overscaledZ);)e=e.scaledTo(e.overscaledZ-1);}this.currentBuildingBuckets.push({bucket:s?s.getBucket(i):null,tileID:s?s.tileID:t,verticalScale:r});}e.hasAnyZOffset=!1;let i=!1;for(let o=0;o{e in i&&(o[e]=i[e]);})),o}function Et(e){e=e.slice();const t=Object.create(null);for(let i=0;i0?(r-a)/n:0;return this.points[s].mult(1-l).add(this.points[i].mult(l))}}class zt{constructor(e,t,i){const o=this.boxCells=[],r=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;ethis.width||o<0||t>this.height)return !r&&[];const a=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=o){if(r)return !0;for(let e=0;e0:a}_queryCircle(e,t,i,o,r){const s=e-i,a=e+i,n=t-i,l=t+i;if(a<0||s>this.width||l<0||n>this.height)return !o&&[];const c=[];return this._forEachCell(s,n,a,l,this._queryCellCircle,c,{hitTest:o,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},r),o?c.length>0:c}query(e,t,i,o,r){return this._query(e,t,i,o,!1,r)}hitTest(e,t,i,o,r){return this._query(e,t,i,o,!0,r)}hitTestCircle(e,t,i,o){return this._queryCircle(e,t,i,!0,o)}_queryCell(e,t,i,o,r,s,a,n){const l=a.seenUids,c=this.boxCells[r];if(null!==c){const r=this.bboxes;for(const h of c)if(!l.box[h]){l.box[h]=!0;const c=4*h;if(e<=r[c+2]&&t<=r[c+3]&&i>=r[c+0]&&o>=r[c+1]&&(!n||n(this.boxKeys[h]))){if(a.hitTest)return s.push(!0),!0;s.push({key:this.boxKeys[h],x1:r[c],y1:r[c+1],x2:r[c+2],y2:r[c+3]});}}}const h=this.circleCells[r];if(null!==h){const r=this.circles;for(const c of h)if(!l.circle[c]){l.circle[c]=!0;const h=3*c;if(this._circleAndRectCollide(r[h],r[h+1],r[h+2],e,t,i,o)&&(!n||n(this.circleKeys[c]))){if(a.hitTest)return s.push(!0),!0;{const e=r[h],t=r[h+1],i=r[h+2];s.push({key:this.circleKeys[c],x1:e-i,y1:t-i,x2:e+i,y2:t+i});}}}}}_queryCellCircle(e,t,i,o,r,s,a,n){const l=a.circle,c=a.seenUids,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;if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!n||n(this.boxKeys[t])))return s.push(!0),!0}}const u=this.circleCells[r];if(null!==u){const e=this.circles;for(const t of u)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)&&(!n||n(this.circleKeys[t])))return s.push(!0),!0}}}_forEachCell(e,t,i,o,r,s,a,n){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(o);for(let d=l;d<=h;d++)for(let l=c;l<=u;l++)if(r.call(this,e,t,i,o,this.xCellCount*l+d,s,a,n))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,o,r,s){const a=o-e,n=r-t,l=i+s;return l*l>a*a+n*n}_circleAndRectCollide(e,t,i,o,r,s,a){const n=(s-o)/2,l=Math.abs(e-(o+n));if(l>n+i)return !1;const c=(a-r)/2,h=Math.abs(t-(r+c));if(h>c+i)return !1;if(l<=n||h<=c)return !0;const u=l-n,d=h-c;return u*u+d*d<=i*i}}const Ot={unknown:0,flipRequired:1,flipNotRequired:2},Ft=Math.tan(85*Math.PI/180);function kt(t,i,o,r,s,a,n){const l=e.a6.mat4.create();if(o)if("globe"===a.name){const t=e.bi(s,i);e.a6.mat4.multiply(l,l,t);}else {const t=e.a6.mat2.invert([],n);l[0]=t[0],l[1]=t[1],l[4]=t[2],l[5]=t[3],r||e.a6.mat4.rotateZ(l,l,s.angle);}else e.a6.mat4.multiply(l,s.labelPlaneMatrix,t);return l}function Bt(e,t,i,o,r,s,a){const n=kt(e,t,i,o,r,s,a);return "globe"===s.name&&i||(n[2]=n[6]=n[10]=n[14]=0),n}function Nt(t,i,o,r,s,a,n){if(o){if("globe"===a.name){const l=kt(t,i,o,r,s,a,n);return e.a6.mat4.invert(l,l),e.a6.mat4.multiply(l,t,l),l}{const i=e.a6.mat4.clone(t),o=e.a6.mat4.identity([]);return o[0]=n[0],o[1]=n[1],o[4]=n[2],o[5]=n[3],e.a6.mat4.multiply(i,i,o),r||e.a6.mat4.rotateZ(i,i,-s.angle),i}}return s.glCoordMatrix}function Ut(t,i,o,r){const s=[t,i,o,1];o?e.a6.vec4.transformMat4(s,s,r):Kt(s,s,r);const a=s[3];return s[0]/=a,s[1]/=a,s[2]/=a,s}function Gt(e,t){return Math.min(.5+e/t*.5,1.5)}function jt(e,t){const i=e[0]/e[3],o=e[1]/e[3];return i>=-t[0]&&i<=t[0]&&o>=-t[1]&&o<=t[1]}function Vt(t,i,o,r,s,a,n,l,c,h){const u=o.transform,d=r?t.textSizeData:t.iconSizeData,_=e.bj(d,o.transform.zoom),p="globe"===u.projection.name,m=[256/o.width*2+1,256/o.height*2+1],f=r?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;f.clear();let g=null;p&&(g=r?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const v=t.lineVertexArray,x=r?t.text.placedSymbolArray:t.icon.placedSymbolArray,y=o.transform.width/o.transform.height;let b,w=!1;for(let r=0;rMath.abs(o)?{useVertical:!0}:t===e.bk.vertical?r>0?{needsFlipping:!0}:null:i!==Ot.unknown&&function(e,t){return 0===e||Math.abs(t/e)>Ft}(o,r)?i===Ot.flipRequired?{needsFlipping:!0}:null:o<0?{needsFlipping:!0}:null}function Ht(t,i,o,r,s,a,n,l,c,h,u,d,_,p,m,f,g,v,x){const y=i/24,b=t.lineOffsetX*y,w=t.lineOffsetY*y,{lineStartIndex:T,glyphStartIndex:E,numGlyphs:C,segment:S,writingMode:I,flipState:D}=t,R=T+t.lineLength,A=t=>{if(u){const[i,o,r]=t.up,s=h.length;e.bm(u,s+0,i,o,r),e.bm(u,s+1,i,o,r),e.bm(u,s+2,i,o,r),e.bm(u,s+3,i,o,r);}const[i,o,r]=t.point;e.bn(h,i,o,r,t.angle);};if(C>1){const e=qt(y,l,b,w,o,d,_,t,c,a,p,f,!1,g,v,x);if(!e)return {notEnoughRoom:!0};if(r&&!o){let[i,o,r]=e.first.point,[s,a,l]=e.last.point;[i,o]=Ut(i,o,r,n),[s,a]=Ut(s,a,l,n);const c=Zt(I,D,(s-i)*m,a-o);if(t.flipState=c&&c.needsFlipping?Ot.flipRequired:Ot.flipNotRequired,c)return c}A(e.first);for(let e=E+1;e0?a:$t(_,r,i,1,s,void 0,g,v.canonical),l=Zt(I,D,(n[0]-i[0])*m,n[1]-i[1]);if(t.flipState=l&&l.needsFlipping?Ot.flipRequired:Ot.flipNotRequired,l)return l}const i=Xt(y*l.getoffsetX(E),b,w,o,d,_,S,T,R,c,a,p,f,!1,!1,g,v,x);if(!i)return {notEnoughRoom:!0};A(i);}return {}}function Wt(e,t,i,o,r){const{x:s,y:a,z:n}=o.projectTilePoint(e.x,e.y,t);if(!r)return Ut(s,a,n,i);const[l,c,h]=r(e);return Ut(s+l,a+c,n+h,i)}function $t(t,i,o,r,s,a,n,l){const c=Wt(t.sub(i)._unit()._add(t),l,s,n,a);return e.a6.vec3.sub(c,o,c),e.a6.vec3.normalize(c,c),e.a6.vec3.scaleAndAdd(c,o,c,r)}function Xt(t,i,o,r,s,a,n,l,c,h,u,d,_,p,m,f,g,v){const x=r?t-i:t+i;let y=x>0?1:-1,b=0;r&&(y*=-1,b=Math.PI),y<0&&(b+=Math.PI);let w=l+n+(y>0?0:1)|0,T=s,E=s,C=0,S=0;const I=Math.abs(x),D=[],R=[];let A=a,L=A;const P=()=>$t(L,A,E,I-C+1,u,_,f,g.canonical);for(;C+S<=I;){if(w+=y,w=c)return null;if(E=T,L=A,D.push(E),p&&R.push(L),A=new e.P(h.getx(w),h.gety(w)),T=d[w],!T){const e=Wt(A,g.canonical,u,f,_);T=e[3]>0?d[w]=e:P();}C+=S,S=e.a6.vec3.distance(E,T);}m&&_&&(d[w]&&(T=P(),S=e.a6.vec3.distance(E,T)),d[w]=T);const M=(I-C)/S,z=A.sub(L)._mult(M)._add(L),O=e.a6.vec3.sub([],T,E),F=e.a6.vec3.scaleAndAdd([],E,O,M);let k=[0,0,1],B=O[0],N=O[1];if(v&&(k=f.upVector(g.canonical,z.x,z.y),0!==k[0]||0!==k[1]||1!==k[2])){const t=[k[2],0,-k[0]],i=e.a6.vec3.cross([],k,t);e.a6.vec3.normalize(t,t),e.a6.vec3.normalize(i,i),B=e.a6.vec3.dot(O,t),N=e.a6.vec3.dot(O,i);}if(o){const t=e.a6.vec3.cross([],k,O);e.a6.vec3.normalize(t,t),e.a6.vec3.scaleAndAdd(F,F,t,o*y);}const U=b+Math.atan2(N,B);return D.push(F),p&&R.push(z),{point:F,angle:U,path:D,tilePath:R,up:k}}function Yt(e,t){const i=t.length,o=i+4*e;t.resize(o),t.float32.fill(-1/0,4*i,4*o);}function Kt(e,t,i){const o=t[0],r=t[1];return e[0]=i[0]*o+i[4]*r+i[12],e[1]=i[1]*o+i[5]*r+i[13],e[3]=i[3]*o+i[7]*r+i[15],e}const Jt=100;class Qt{constructor(e,t,i=new zt(e.width+200,e.height+200,25),o=new zt(e.width+200,e.height+200,25)){this.transform=e,this.grid=i,this.ignoredGrid=o,this.pitchfactor=Math.cos(e._pitch)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+Jt,this.screenBottomBoundary=e.height+Jt,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.fogState=t;}placeCollisionBox(e,t,i,o,r,s,a,n){let l=i.projectedAnchorX,c=i.projectedAnchorY,h=i.projectedAnchorZ;const u=i.elevation,d=i.tileID,_=e.getProjection();if(u&&d){const[e,t,o]=_.upVector(d.canonical,i.tileAnchorX,i.tileAnchorY),r=_.upVectorScale(d.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;l+=e*u*r,c+=t*u*r,h+=o*u*r;}const p=this.projectAndGetPerspectiveRatio(a,l,c,h,i.tileID,"globe"===_.name||!!u||this.transform.pitch>0,_),m=s*p.perspectiveRatio,f=(i.x1*t+o.x-i.padding)*m+p.point.x,g=(i.y1*t+o.y-i.padding)*m+p.point.y,v=(i.x2*t+o.x+i.padding)*m+p.point.x,x=(i.y2*t+o.y+i.padding)*m+p.point.y,y=p.perspectiveRatio<=.55||p.occluded;return !this.isInsideGrid(f,g,v,x)||!r&&this.grid.hitTest(f,g,v,x,n)||y?{box:[],offscreen:!1,occluded:p.occluded}:{box:[f,g,v,x],offscreen:this.isOffscreen(f,g,v,x),occluded:!1}}placeCollisionCircles(t,i,o,r,s,a,n,l,c,h,u,d,_,p,m){const f=[],g=this.transform.elevation,v=t.getProjection(),x=g?g.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,v):null,y=new e.P(o.tileAnchorX,o.tileAnchorY);let{x:b,y:w,z:T}=v.projectTilePoint(y.x,y.y,m.canonical);if(x){const[e,t,i]=x(y);b+=e,w+=t,T+=i;}const E="globe"===v.name,C=this.projectAndGetPerspectiveRatio(n,b,w,T,m,E||!!g||this.transform.pitch>0,v),{perspectiveRatio:S}=C,I=(u?a/S:a*S)/e.bq,D=Ut(b,w,T,l),R=C.signedDistanceFromCamera>0?qt(I,s,o.lineOffsetX*I,o.lineOffsetY*I,!1,D,y,o,r,l,{},g&&!u?x:null,u&&!!g,v,m,u):null;let A=!1,L=!1,P=!0;if(R&&!C.occluded){const t=.5*_*S+p,o=new e.P(-100,-100),r=new e.P(this.screenRightBoundary,this.screenBottomBoundary),s=new Mt,{first:a,last:n}=R,l=a.path.length;let u=[];for(let e=l-1;e>=1;e--)u.push(a.path[e]);for(let e=1;e(x&&!E&&(i=x(oe[3]<=0))&&(u=[]));let g=[];if(u.length>0){let t=1/0,i=-1/0,s=1/0,a=-1/0;for(const e of u)t=Math.min(t,e[0]),s=Math.min(s,e[1]),i=Math.max(i,e[0]),a=Math.max(a,e[1]);i>=o.x&&t<=r.x&&a>=o.y&&s<=r.y&&(g=[u.map((t=>new e.P(t[0],t[1])))],(tr.x||sr.y)&&(g=e.bo(g,o.x,o.y,r.x,r.y)));}for(const e of g){s.reset(e,.25*t);let o=0;o=s.length<=.5*t?1:Math.ceil(s.paddedLength/m)+1;for(let e=0;e0){if(e.a6.vec4.transformMat4(l,l,t),this.fogState&&s&&"globe"!==n.name){const t=function(t,i,o,r,s,a){const n=a.calculateFogTileMatrix(s),l=[i,o,r];return e.a6.vec3.transformMat4(l,l,n),Fe(t,e.a6.vec3.length(l),a.pitch,a._fov)}(this.fogState,i,o,r,s.toUnwrapped(),this.transform);c=t>.9;}}else Kt(l,l,t);const h=l[3];return {point:new e.P((l[0]/h+1)/2*this.transform.width+Jt,(-l[1]/h+1)/2*this.transform.height+Jt),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(n)/h*.5,1.5),signedDistanceFromCamera:h,occluded:a&&l[2]>h||c}}isOffscreen(e,t,i,o){return i=this.screenRightBoundary||othis.screenBottomBoundary}isInsideGrid(e,t,i,o){return i>=0&&e=0&&te.collisionGroupID===t};}return this.collisionGroups[e]}}function ci(t,i,o,r,s){const{horizontalAlign:a,verticalAlign:n}=e.bx(t),l=-(a-.5)*i,c=-(n-.5)*o,h=e.bw(t,r);return new e.P(l+h[0]*s,c+h[1]*s)}function hi(t,i,o,r,s){const a=new e.P(t,i);return o&&a._rotate(r?s:-s),a}class ui{constructor(e,t,i,o,r,s){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new Qt(this.transform,r),this.buildingIndex=s,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new li(i),this.collisionCircleArrays={},this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={};}getBucketParts(t,i,o,r){const s=o.getBucket(i),a=o.latestFeatureIndex;if(!s||!a||i.fqid!==s.layerIds[0])return;const n=s.layers[0].layout,l=s.layers[0].paint,c=o.collisionBoxArray,h=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),u=o.tileSize/e.ab,d=o.tileID.toUnwrapped();this.transform.setProjection(s.projection);const _=(p=o.tileID,m=s.getProjection(),f=this.transform,m.name===this.projection?f.calculateProjMatrix(p.toUnwrapped()):ei(f,m,p));var p,m,f;const g="map"===n.get("text-pitch-alignment"),v="map"===n.get("text-rotation-alignment");i.compileFilter();const x=i.dynamicFilter(),y=i.dynamicFilterNeedsFeature(),b=this.transform.calculatePixelsToTileUnitsMatrix(o),w=Bt(_,o.tileID.canonical,g,v,this.transform,s.getProjection(),b);let T=null;if(g){const t=Nt(_,o.tileID.canonical,g,v,this.transform,s.getProjection(),b);T=e.a6.mat4.multiply([],this.transform.labelPlaneMatrix,t);}let E=null;x&&o.latestFeatureIndex&&(E={unwrappedTileID:d,dynamicFilter:x,dynamicFilterNeedsFeature:y}),this.retainedQueryData[s.bucketInstanceId]=new ni(s.bucketInstanceId,a,s.sourceLayerIndex,s.index,o.tileID);const C={bucket:s,layout:n,paint:l,posMatrix:_,textLabelPlaneMatrix:w,labelToScreenMatrix:T,clippingData:E,scale:h,textPixelRatio:u,holdingForFade:o.holdingForFade(),collisionBoxArray:c,partiallyEvaluatedTextSize:e.bj(s.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:e.bj(s.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(s.sourceID),latestFeatureIndex:o.latestFeatureIndex};if(r)for(const e of s.sortKeyRanges){const{sortKey:i,symbolInstanceStart:o,symbolInstanceEnd:r}=e;t.push({sortKey:i,symbolInstanceStart:o,symbolInstanceEnd:r,parameters:C});}else t.push({symbolInstanceStart:0,symbolInstanceEnd:s.symbolInstances.length,parameters:C});}attemptAnchorPlacement(e,t,i,o,r,s,a,n,l,c,h,u,d,_,p,m,f,g){const{textOffset0:v,textOffset1:x,crossTileID:y}=u,b=[v,x],w=ci(e,i,o,b,r),T=this.collisionIndex.placeCollisionBox(_,r,t,hi(w.x,w.y,s,a,this.transform.angle),h,n,l,c.predicate);if(m){const e=_.getSymbolInstanceIconSize(g,this.transform.zoom,u.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(_,e,m,hi(w.x,w.y,s,a,this.transform.angle),h,n,l,c.predicate).box.length)return}if(T.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[y]&&this.prevPlacement.placements[y]&&this.prevPlacement.placements[y].text&&(t=this.prevPlacement.variableOffsets[y].anchor),this.variableOffsets[y]={textOffset:b,width:i,height:o,anchor:e,textScale:r,prevAnchor:t},this.markUsedJustification(_,e,u,p),_.allowVerticalPlacement&&(this.markUsedOrientation(_,p,u),this.placedOrientations[y]=p),{shift:w,placedGlyphBoxes:T}}}placeLayerBucketPart(t,i,o,r){const{bucket:s,layout:a,paint:n,posMatrix:l,textLabelPlaneMatrix:c,labelToScreenMatrix:h,clippingData:u,textPixelRatio:d,holdingForFade:_,collisionBoxArray:p,partiallyEvaluatedTextSize:m,partiallyEvaluatedIconSize:f,collisionGroup:g,latestFeatureIndex:v}=t.parameters,x=a.get("text-optional"),y=a.get("icon-optional"),b=a.get("text-allow-overlap"),w=a.get("icon-allow-overlap"),T="map"===a.get("text-rotation-alignment"),E="map"===a.get("text-pitch-alignment"),C=a.get("symbol-z-elevate"),S=n.get("symbol-z-offset"),I="sea"===n.get("symbol-elevation-reference");this.transform.setProjection(s.projection);let D=b&&(w||!s.hasIconData()||y),R=w&&(b||!s.hasTextData()||x);const A=!S.isConstant();!s.collisionArrays&&p&&s.deserializeCollisionBoxes(p),o&&r&&s.updateCollisionDebugBuffers(this.transform.zoom,p);const L=(t,r,n)=>{const{crossTileID:p,numVerticalGlyphVertices:C}=t;let L=null;if(u&&u.dynamicFilterNeedsFeature||A){const e=this.retainedQueryData[s.bucketInstanceId];L=v.loadFeature({featureIndex:t.featureIndex,bucketIndex:e.bucketIndex,sourceLayerIndex:e.sourceLayerIndex,layoutVertexArrayOffset:0});}if(u&&!(0,u.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch},L,this.retainedQueryData[s.bucketInstanceId].tileID.canonical,new e.P(t.tileAnchorX,t.tileAnchorY),this.transform.calculateDistanceTileData(u.unwrappedTileID)))return this.placements[p]=new si(!1,!1,!1,!0),void i.add(p);const P=S.evaluate(L,{});if(i.has(p))return;if(_)return void(this.placements[p]=new si(!1,!1,!1));let M=!1,z=!1,O=!0,F=!1,k=!1,B=null,N={box:null,offscreen:null,occluded:null},U={box:null,offscreen:null,occluded:null},G=null,j=null,V=null,q=0,Z=0,H=0;n.textFeatureIndex?q=n.textFeatureIndex:t.useRuntimeCollisionCircles&&(q=t.featureIndex),n.verticalTextFeatureIndex&&(Z=n.verticalTextFeatureIndex);const W=e=>{e.tileID=this.retainedQueryData[s.bucketInstanceId].tileID;const i=this.transform.elevation;e.elevation=I?P:P+(i?i.getAtTileOffset(e.tileID,e.tileAnchorX,e.tileAnchorY):0),e.elevation+=t.zOffset;},$=n.textBox;if($){W($);const i=i=>{let o=e.bk.horizontal;if(s.allowVerticalPlacement&&!i&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[p];e&&(this.placedOrientations[p]=e,o=e,this.markUsedOrientation(s,o,t));}return o},o=(t,i)=>{if(s.allowVerticalPlacement&&C>0&&n.verticalTextBox){for(const o of s.writingModes)if(o===e.bk.vertical?(N=i(),U=N):N=t(),N&&N.box&&N.box.length)break}else N=t();};if(a.get("text-variable-anchor")){let c=a.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[p]){const e=this.prevPlacement.variableOffsets[p];c.indexOf(e.anchor)>0&&(c=c.filter((t=>t!==e.anchor)),c.unshift(e.anchor));}const h=(e,i,o)=>{const a=s.getSymbolInstanceTextSize(m,t,this.transform.zoom,r),n=(e.x2-e.x1)*a+2*e.padding,h=(e.y2-e.y1)*a+2*e.padding,u=t.hasIconTextFit&&!w?i:null;u&&W(u);let _={box:[],offscreen:!1,occluded:!1};const p=b?2*c.length:c.length;for(let i=0;i=c.length,t,r,s,o,u,m,f);if(p&&(_=p.placedGlyphBoxes,_&&_.box&&_.box.length)){M=!0,B=p.shift;break}}return _};o((()=>h($,n.iconBox,e.bk.horizontal)),(()=>{const t=n.verticalTextBox;return t&&W(t),s.allowVerticalPlacement&&!(N&&N.box&&N.box.length)&&C>0&&t?h(t,n.verticalIconBox,e.bk.vertical):{box:null,offscreen:null,occluded:null}})),N&&(M=N.box,O=N.offscreen,F=N.occluded);const u=i(!(!N||!N.box));if(!M&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[p];e&&(this.variableOffsets[p]=e,this.markUsedJustification(s,e.anchor,t,u));}}else {const a=(i,o)=>{const a=s.getSymbolInstanceTextSize(m,t,this.transform.zoom,r),n=this.collisionIndex.placeCollisionBox(s,a,i,new e.P(0,0),b,d,l,g.predicate);return n&&n.box&&n.box.length&&(this.markUsedOrientation(s,o,t),this.placedOrientations[p]=o),n};o((()=>a($,e.bk.horizontal)),(()=>{const t=n.verticalTextBox;return s.allowVerticalPlacement&&C>0&&t?(W(t),a(t,e.bk.vertical)):{box:null,offscreen:null,occluded:null}})),i(!!(N&&N.box&&N.box.length));}}if(G=N,M=G&&G.box&&G.box.length>0,O=G&&G.offscreen,F=G&&G.occluded,t.useRuntimeCollisionCircles){const i=s.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex),r=e.bl(s.textSizeData,m,i),n=a.get("text-padding");j=this.collisionIndex.placeCollisionCircles(s,b,i,s.lineVertexArray,s.glyphOffsetArray,r,l,c,h,o,E,g.predicate,t.collisionCircleDiameter*r/e.bq,n,this.retainedQueryData[s.bucketInstanceId].tileID),M=b||j.circles.length>0&&!j.collisionDetected,O=O&&j.offscreen,F=j.occluded;}if(n.iconFeatureIndex&&(H=n.iconFeatureIndex),n.iconBox){const i=i=>{W(i);const o=t.hasIconTextFit&&B?hi(B.x,B.y,T,E,this.transform.angle):new e.P(0,0),r=s.getSymbolInstanceIconSize(f,this.transform.zoom,t.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(s,r,i,o,w,d,l,g.predicate)};U&&U.box&&U.box.length&&n.verticalIconBox?(V=i(n.verticalIconBox),z=V.box.length>0):(V=i(n.iconBox),z=V.box.length>0),O=O&&V.offscreen,k=V.occluded;}const X=x||0===t.numHorizontalGlyphVertices&&0===C,Y=y||0===t.numIconVertices;if(X||Y?Y?X||(z=z&&M):M=z&&M:z=M=z&&M,M&&G&&G.box&&this.collisionIndex.insertCollisionBox(G.box,a.get("text-ignore-placement"),s.bucketInstanceId,U&&U.box&&Z?Z:q,g.ID),z&&V&&this.collisionIndex.insertCollisionBox(V.box,a.get("icon-ignore-placement"),s.bucketInstanceId,H,g.ID),j&&(M&&this.collisionIndex.insertCollisionCircles(j.circles,a.get("text-ignore-placement"),s.bucketInstanceId,q,g.ID),o)){const e=s.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new ai);for(let e=0;e=0;--e){const i=t[e];L(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(s).crossTileID=u>=0&&s!==u?0:c),a>=0&&(t.text.placedSymbolArray.get(a).crossTileID=u>=0&&a!==u?0:c),n>=0&&(t.text.placedSymbolArray.get(n).crossTileID=u>=0&&n!==u?0:c),l>=0&&(t.text.placedSymbolArray.get(l).crossTileID=u>=0&&l!==u?0:c);}markUsedOrientation(t,i,o){const r=i===e.bk.horizontal||i===e.bk.horizontalOnly?i:0,s=i===e.bk.vertical?i:0,{leftJustifiedTextSymbolIndex:a,centerJustifiedTextSymbolIndex:n,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:c}=o,h=t.text.placedSymbolArray;a>=0&&(h.get(a).placedOrientation=r),n>=0&&(h.get(n).placedOrientation=r),l>=0&&(h.get(l).placedOrientation=r),c>=0&&(h.get(c).placedOrientation=s);}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const o=t?t.symbolFadeChange(e):1,r=t?t.opacities:{},s=t?t.variableOffsets:{},a=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],s=r[e];s?(this.opacities[e]=new ri(s,o,t.text,t.icon,null,t.clipped),i=i||t.text!==s.text.placed||t.icon!==s.icon.placed):(this.opacities[e]=new ri(null,o,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 ri(t,o,!1,!1);r.isHidden()||(this.opacities[e]=r,i=i||t.text.placed||t.icon.placed);}}for(const e in s)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=s[e]);for(const e in a)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=a[e]);i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e);}updateLayerOpacities(e,t,i,o){const r=new Set;for(const s of t){const t=s.getBucket(e);t&&s.latestFeatureIndex&&e.fqid===t.layerIds[0]&&(this.updateBucketOpacities(t,r,s,s.collisionBoxArray,i,o,s.tileID,e.scope),t.layers[0].layout.get("symbol-z-elevate")&&this.buildingIndex&&(this.buildingIndex.updateZOffset(t,s.tileID),t.updateZOffset()));}}updateBucketOpacities(t,i,o,r,s,a,n,l){t.hasTextData()&&t.text.opacityVertexArray.clear(),t.hasIconData()&&t.icon.opacityVertexArray.clear(),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const c=t.layers[0].layout,h=t.layers[0].paint,u=!!t.layers[0].dynamicFilter(),d=new ri(null,0,!1,!1,!0),_=c.get("text-allow-overlap"),p=c.get("icon-allow-overlap"),m=c.get("text-variable-anchor"),f="map"===c.get("text-rotation-alignment"),g="map"===c.get("text-pitch-alignment"),v=h.get("symbol-z-offset"),x="sea"===h.get("symbol-elevation-reference"),y=!v.isConstant(),b=new ri(null,0,_&&(p||!t.hasIconData()||c.get("icon-optional")),p&&(_||!t.hasTextData()||c.get("text-optional")),!0);!t.collisionArrays&&r&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(r);const w=(e,t,i)=>{for(let o=0;o0||_>0,P=E>0,M=this.placedOrientations[p],z=M===e.bk.vertical,O=M===e.bk.horizontal||M===e.bk.horizontalOnly;!L&&!P||A.isHidden()||T++;let F=!1;if((L||P)&&a)for(const i of t.activeReplacements){if(e.br(i,s,e.bs.Symbol,l))continue;if(i.min.x>C||C>i.max.x||i.min.y>S||S>i.max.y)continue;const t=e.bt(C,S,n.canonical,i.footprintTileId.canonical);if(F=e.bu(t,i.footprint),F)break}if(L){const e=F?bi:yi(A.text);w(t.text,h,z?bi:e),w(t.text,_,O?bi:e);const i=A.text.isHidden(),{leftJustifiedTextSymbolIndex:o,centerJustifiedTextSymbolIndex:r,rightJustifiedTextSymbolIndex:s,verticalPlacedTextSymbolIndex:a}=c,n=t.text.placedSymbolArray,l=i||z?1:0;o>=0&&(n.get(o).hidden=l),r>=0&&(n.get(r).hidden=l),s>=0&&(n.get(s).hidden=l),a>=0&&(n.get(a).hidden=i||O?1:0);const u=this.variableOffsets[p];u&&this.markUsedJustification(t,u.anchor,c,M);const d=this.placedOrientations[p];d&&(this.markUsedJustification(t,"left",c,d),this.markUsedOrientation(t,d,c));}if(P){const e=F?bi:yi(A.icon),{placedIconSymbolIndex:i,verticalPlacedIconSymbolIndex:o}=c,r=t.icon.placedSymbolArray,s=A.icon.isHidden()?1:0;i>=0&&(w(t.icon,E,z?bi:e),r.get(i).hidden=s),o>=0&&(w(t.icon,c.numVerticalIconVertices,O?bi:e),r.get(o).hidden=s);}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const i=t.collisionArrays[r];if(i){let o=new e.P(0,0),r=!0;if(i.textBox||i.verticalTextBox){if(m){const e=this.variableOffsets[p];e?(o=ci(e.anchor,e.width,e.height,e.textOffset,e.textScale),f&&o._rotate(g?this.transform.angle:-this.transform.angle)):r=!1;}u&&(r=!A.clipped),i.textBox&&di(t.textCollisionBox.collisionVertexArray,A.text.placed,!r||z,D,x,o.x,o.y),i.verticalTextBox&&di(t.textCollisionBox.collisionVertexArray,A.text.placed,!r||O,D,x,o.x,o.y);}const s=r&&Boolean(!O&&i.verticalIconBox);i.iconBox&&di(t.iconCollisionBox.collisionVertexArray,A.icon.placed,s,D,x,c.hasIconTextFit?o.x:0,c.hasIconTextFit?o.y:0),i.verticalIconBox&&di(t.iconCollisionBox.collisionVertexArray,A.icon.placed,!s,D,x,c.hasIconTextFit?o.x:0,c.hasIconTextFit?o.y:0);}}}if(t.fullyClipped=0===T,t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=e.invProjMatrix,t.placementViewportMatrix=e.viewportMatrix,t.collisionCircleArray=e.circles,delete this.collisionCircleArrays[t.bucketInstanceId];}}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTimee}setStale(){this.stale=!0;}}function di(e,t,i,o,r,s,a){e.emplaceBack(t?1:0,i?1:0,s||0,a||0,o,r?1:0),e.emplaceBack(t?1:0,i?1:0,s||0,a||0,o,r?1:0),e.emplaceBack(t?1:0,i?1:0,s||0,a||0,o,r?1:0),e.emplaceBack(t?1:0,i?1:0,s||0,a||0,o,r?1:0);}const _i=Math.pow(2,25),pi=Math.pow(2,24),mi=Math.pow(2,17),fi=Math.pow(2,16),gi=Math.pow(2,9),vi=Math.pow(2,8),xi=Math.pow(2,1);function yi(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*_i+t*pi+i*mi+t*fi+i*gi+t*vi+i*xi+t}const bi=0;class wi{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,o,r){const s=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey)));this._currentPartIndex{const t=e.q.now()-s;return !this._forceFullPlacement&&t>2};for(;this._currentPlacementIndex>=0;){const s=i[t[this._currentPlacementIndex]],n=this.placement.collisionIndex.transform.zoom;if("symbol"===s.type&&(!s.minzoom||s.minzoom<=n)&&(!s.maxzoom||s.maxzoom>n)){const t=s,i=t.layout.get("symbol-z-elevate"),n=void 0!==t.layout.get("symbol-sort-key").constantOr(1),l=t.layout.get("symbol-z-order"),c="viewport-y"===l||"auto"===l&&!("viewport-y"!==l&&n),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"),u=c&&h,d=this._inProgressLayer=this._inProgressLayer||new wi(t),_=e.av(s.source,s.scope);if(d.continuePlacement(i||u?r[_]:o[_],this.placement,this._showCollisionBoxes,s,a))return;delete this._inProgressLayer;}this._currentPlacementIndex--;}this._done=!0;}commit(e){return this.placement.commit(e),this.placement}}const Ei=512/e.ab/2;class Ci{constructor(t,i,o){this.tileID=t,this.bucketInstanceId=o,this.index=new e.by(i.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const r=t.canonical.x*e.ab,s=t.canonical.y*e.ab;for(let e=0;ee.overscaledZ)for(const i in r){const s=r[i];s.tileID.isChildOf(e)&&s.findMatches(t.symbolInstances,e,o);}else {const s=r[e.scaledTo(Number(i)).key];s&&s.findMatches(t.symbolInstances,e,o);}}for(let e=0;e{t[e]=!0;}));for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e];}}const Ri=771;class Ai{constructor(e,t,i,o){this.blendFunction=e,this.blendColor=t,this.mask=i,this.blendEquation=o;}}Ai.Replace=[1,0,1,0],Ai.disabled=new Ai(Ai.Replace,e.bz.transparent,[!1,!1,!1,!1]),Ai.unblended=new Ai(Ai.Replace,e.bz.transparent,[!0,!0,!0,!0]),Ai.alphaBlended=new Ai([1,Ri,1,Ri],e.bz.transparent,[!0,!0,!0,!0]),Ai.alphaBlendedNonPremultiplied=new Ai([770,Ri,770,Ri],e.bz.transparent,[!0,!0,!0,!0]),Ai.multiply=new Ai([774,0,774,0],e.bz.transparent,[!0,!0,!0,!0]);class Li{constructor(e,t,i){this.func=e,this.mask=t,this.range=i;}}Li.ReadOnly=!1,Li.ReadWrite=!0,Li.disabled=new Li(519,Li.ReadOnly,[0,1]);const Pi=7680;class Mi{constructor(e,t,i,o,r,s){this.test=e,this.ref=t,this.mask=i,this.fail=o,this.depthFail=r,this.pass=s;}}Mi.disabled=new Mi({func:519,mask:0},0,0,Pi,Pi,Pi);const zi=1029,Oi=2305;class Fi{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i;}}function ki(t,i){const o=e.bC(t,3);e.a6.mat4.fromQuat(t,i),e.bE(t,3,o);}function Bi(t,i){const o=e.a6.quat.identity([]);return e.a6.quat.rotateZ(o,o,-i),e.a6.quat.rotateX(o,o,-t),o}function Ni(t,i){const o=[t[0],t[1],0],r=[i[0],i[1],0];if(e.a6.vec3.length(o)>=1e-15){const t=e.a6.vec3.normalize([],o);e.a6.vec3.scale(r,t,e.a6.vec3.dot(r,t)),i[0]=r[0],i[1]=r[1];}const s=e.a6.vec3.cross([],i,t);if(e.a6.vec3.len(s)<1e-15)return null;const a=Math.atan2(-s[1],s[0]);return Bi(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),a)}Fi.disabled=new Fi(!1,zi,Oi),Fi.backCCW=new Fi(!0,zi,Oi),Fi.backCW=new Fi(!0,zi,2304),Fi.frontCW=new Fi(!0,1028,2304),Fi.frontCCW=new Fi(!0,1028,Oi);class Ui{constructor(e,t){this.position=e,this.orientation=t;}get position(){return this._position}set position(t){if(t){const i=t instanceof e.a5?t:new e.a5(t[0],t[1],t[2]);this._renderWorldCopies&&(i.x=e.bA(i.x,0,1)),this._position=i;}else this._position=null;}lookAtPoint(t,i){if(this.orientation=null,!this.position)return;const o=this.position,r=this._elevation?this._elevation.getAtPointOrZero(e.a5.fromLngLat(t)):0,s=e.a5.fromLngLat(t,r),a=[s.x-o.x,s.y-o.y,s.z-o.z];i||(i=[0,0,1]),i[2]=Math.abs(i[2]),this.orientation=Ni(a,i);}setPitchBearing(t,i){this.orientation=Bi(e.bB(t),e.bB(-i));}}class Gi{constructor(t,i){this._transform=e.a6.mat4.identity([]),this.orientation=i,this.position=t;}get mercatorPosition(){const t=this.position;return new e.a5(t[0],t[1],t[2])}get position(){const t=e.bC(this._transform,3);return [t[0],t[1],t[2]]}set position(t){var i;t&&e.bE(this._transform,3,[(i=t)[0],i[1],i[2],1]);}get orientation(){return this._orientation}set orientation(t){this._orientation=t||e.a6.quat.identity([]),t&&ki(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=Bi(e,t),ki(this._transform,this._orientation);}forward(){const t=e.bC(this._transform,2);return [-t[0],-t[1],-t[2]]}up(){const t=e.bC(this._transform,1);return [-t[0],-t[1],-t[2]]}right(){const t=e.bC(this._transform,0);return [t[0],t[1],t[2]]}getCameraToWorld(t,i){const o=new Float64Array(16);return e.a6.mat4.invert(o,this.getWorldToCamera(t,i)),o}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(t,i,o){const r=this.position;e.a6.vec3.scale(r,r,-t);const s=new Float64Array(16);return e.a6.mat4.fromScaling(s,[o,o,o]),e.a6.mat4.translate(s,s,r),s[10]*=i,s}getWorldToCamera(t,i){const o=new Float64Array(16),r=new Float64Array(4),s=this.position;return e.a6.quat.conjugate(r,this._orientation),e.a6.vec3.scale(s,s,-t),e.a6.mat4.fromQuat(o,r),e.a6.mat4.translate(o,o,s),o[1]*=-1,o[5]*=-1,o[9]*=-1,o[13]*=-1,o[8]*=i,o[9]*=i,o[10]*=i,o[11]*=i,o}getCameraToClipPerspective(t,i,o,r){const s=new Float64Array(16);return e.a6.mat4.perspective(s,t,i,o,r),s}getCameraToClipOrthographic(t,i,o,r,s,a){const n=new Float64Array(16);return e.a6.mat4.ortho(n,t,i,o,r,s,a),n}getDistanceToElevation(t,i=!1){const o=0===t?0:e.bD(t,i?e.aM(this.position[1]):this.position[1]),r=this.forward();return (o-this.position[2])/r[2]}clone(){return new Gi([...this.position],[...this.orientation])}}const ji={BaseColor:5,MetallicRoughness:6,Normal:7,Occlusion:8,Emission:9,LUT:10,ShadowMap0:11};class Vi{constructor(e=0,t=0,i=0,o=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(o)||o<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=o;}interpolate(t,i,o){return null!=i.top&&null!=t.top&&(this.top=e.aa(t.top,i.top,o)),null!=i.bottom&&null!=t.bottom&&(this.bottom=e.aa(t.bottom,i.bottom,o)),null!=i.left&&null!=t.left&&(this.left=e.aa(t.left,i.left,o)),null!=i.right&&null!=t.right&&(this.right=e.aa(t.right,i.right,o)),this}getCenter(t,i){const o=e.ap((this.left+t-this.right)/2,0,t),r=e.ap((this.top+i-this.bottom)/2,0,i);return new e.P(o,r)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Vi(this.top,this.bottom,this.left,this.right)}toJSON(){return {top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const qi=(e,t,i)=>(1-i)*e+i*t,Zi=e=>e*e*e*e*e;class Hi{constructor(t,i,o,r,s,a,n){this.tileSize=512,this._renderWorldCopies=void 0===s||s,this._minZoom=t||0,this._maxZoom=i||22,this._minPitch=o??0,this._maxPitch=r??60,this.setProjection(a),this.setMaxBounds(n),this.width=0,this.height=0,this._center=new e.bK(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 Vi,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new Gi,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;}clone(){const e=new Hi(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());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}get isOrthographic(){return "globe"!==this.projection.name&&this._orthographicProjectionAtLowPitch&&this.pitch<15}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices());}get depthOcclusionForSymbolsAndCircles(){return "globe"!==this.projection.name&&!this.isOrthographic}updateElevation(e,t=!1){const i=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||i)&&this._updateCameraOnTerrain(),(e||i)&&this._constrainCamera(t),this._calcMatrices();}getProjection(){return e.ar(this.projection,["name","center","parallels"])}setProjection(t){this.projectionOptions=t||{name:"mercator"};const i=this.projection?this.getProjection():void 0;this.projection=e.bL(this.projectionOptions);const o=this.getProjection(),r=!e.bh(i,o);return r&&this._calcMatrices(),this.mercatorFromTransition=!1,r}setOrthographicProjectionAtLowPitch(e){return this._orthographicProjectionAtLowPitch!==e&&(this._orthographicProjectionAtLowPitch=e,this._calcMatrices(),!0)}setMercatorFromTransition(){const t=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=e.bL({name:"mercator"});const i=t!==this.projection.name;return i&&this._calcMatrices(),i}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e));}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e));}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e));}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e));}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e;}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get cameraWorldSize(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return e.bD(1,this.center.lat)*this.cameraWorldSizeForFog}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new e.P(this.width,this.height)}get bearing(){return e.bA(this.rotation,-180,180)}set bearing(e){this.rotation=e;}get rotation(){return -this.angle/Math.PI*180}set rotation(t){const i=-t*Math.PI/180;this.angle!==i&&(this._unmodified=!1,this.angle=i,this._calcMatrices(),this.rotationMatrix=e.a6.mat2.create(),e.a6.mat2.rotate(this.rotationMatrix,this.rotationMatrix,this.angle));}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const i=e.ap(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==i&&(this._unmodified=!1,this._pitch=i,this._calcMatrices());}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}get fovX(){return this._fov}get fovY(){const e=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/e)}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=e.bB(t),this._calcMatrices());}get averageElevation(){return this._averageElevation}set averageElevation(e){this._averageElevation=e,this._calcFogMatrices(),this._distanceTileDataCache={};}get zoom(){return this._zoom}set zoom(e){const t=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==t&&(this._unmodified=!1,this._setZoom(t),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices());}_setZoom(e){this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom;}get tileCoverLift(){return this._tileCoverLift}set tileCoverLift(e){this._tileCoverLift!==e&&(this._tileCoverLift=e);}_updateCameraOnTerrain(){const e=this.elevation?this.elevation.getAtPoint(this.locationCoordinate(this.center),Number.NEGATIVE_INFINITY):Number.NEGATIVE_INFINITY,t=this.elevation&&e===Number.NEGATIVE_INFINITY&&this.elevation.visibleDemTiles.length>0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||e===Number.NEGATIVE_INFINITY&&(!t||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const i=this._elevation;t||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&i.exaggeration()&&this._centerAltitudeValidForExaggeration!==i.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*i.exaggeration(),this._centerAltitudeValidForExaggeration=i.exaggeration()):(this._centerAltitude=e||0,this._centerAltitudeValidForExaggeration=i.exaggeration()),this._updateSeaLevelZoom();}_updateSeaLevelZoom(){void 0!==this._centerAltitudeValidForExaggeration&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize));}sampleAverageElevation(){if(!this._elevation)return 0;const t=this._elevation,i=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],o=this.horizonLineFromTop();let r=0,s=0;for(let a=0;a{const l=e.c1(i,t,o,s,a);n.has(l)||(r.push(new e.aA(t,i,o,s,a)),n.add(l));};for(let e=0;e0,p=n.y+10,f=r.wrap-(_?0:1),g=r.wrap+(d?0:1),v=_?n.x-1:u-1,x=d?n.x+1:0;if(s)o[0]<0?(l(c,g,n.z,x,n.y),o[1]<0&&p&&(l(c,h,n.z,n.x,n.y+1),l(c,g,n.z,x,n.y+1)),o[1]>0&&m&&(l(c,h,n.z,n.x,n.y-1),l(c,g,n.z,x,n.y-1))):o[0]>0?(l(c,f,n.z,v,n.y),o[1]<0&&p&&(l(c,h,n.z,n.x,n.y+1),l(c,f,n.z,v,n.y+1)),o[1]>0&&m&&(l(c,h,n.z,n.x,n.y-1),l(c,f,n.z,v,n.y-1))):o[1]<0&&p?l(c,h,n.z,n.x,n.y+1):m&&l(c,h,n.z,n.x,n.y-1);else {const e=r.visibleQuadrants;1&e&&(l(c,f,n.z,v,n.y),m&&(l(c,h,n.z,n.x,n.y-1),l(c,f,n.z,v,n.y-1))),2&e&&(l(c,g,n.z,x,n.y),m&&(l(c,h,n.z,n.x,n.y-1),l(c,g,n.z,x,n.y-1))),4&e&&(l(c,f,n.z,v,n.y),p&&(l(c,h,n.z,n.x,n.y+1),l(c,f,n.z,v,n.y+1))),8&e&&(l(c,g,n.z,x,n.y),p&&(l(c,h,n.z,n.x,n.y+1),l(c,g,n.z,x,n.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-o[0],i=e.canonical.y+.5-o[1];return t*t+i*it.maxzoom&&(i=t.maxzoom);const n=this.locationCoordinate(this.center),l=this.center.lat,c=1<{const i=1/4e4,o=new e.a5(t.x+i,t.y,t.z),r=new e.a5(t.x,t.y+i,t.z),s=t.toLngLat(),a=o.toLngLat(),n=r.toLngLat(),l=this.locationCoordinate(s),c=this.locationCoordinate(a),h=this.locationCoordinate(n),u=Math.hypot(c.x-l.x,c.y-l.y),d=Math.hypot(h.x-l.x,h.y-l.y);return Math.sqrt(u*d)*T/i},C=t=>{const i=b,o=w;return {aabb:e.bR(this,c,0,0,0,t,o,i,this.projection),zoom:0,x:0,y:0,minZ:o,maxZ:i,wrap:t,fullyVisible:!1}},S=[];let I=[];const D=i,R=t.reparseOverscaled?o:i,A=(f-this._centerAltitude)*m,L=e=>{if(!this._elevation||!e.tileID||!a)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=M(e),e.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude));},P=(e,t)=>{if(.707*t{if(t.zoom=.9)return !0}else if(s&&(n=t.aabb.distanceZ(g)*m),this.projection.isReprojectedInTileSpace&&o<=5){const i=Math.pow(2,t.zoom),o=E(new e.a5((t.x+.5)/i,(t.y+.5)/i));c=o>.85?1:o;}if(!a){const e=Math.sqrt(i*i+r*r+n*n);let o=(1<0;){const o=S.pop(),r=o.x,n=o.y;let l=o.fullyVisible;const d=()=>"globe"===this.projection.name&&(0===o.y||o.y===(1<>1),d={aabb:a?o.aabb.quadrant(t):e.bR(this,c,o.zoom+1,i,h,o.wrap,o.minZ,o.maxZ,this.projection),zoom:o.zoom+1,x:i,y:h,wrap:o.wrap,fullyVisible:l,tileID:void 0,shouldSplit:void 0,minZ:o.minZ,maxZ:o.maxZ};s&&!u&&(d.tileID=new e.aA(o.zoom+1===D?R:o.zoom+1,o.wrap,o.zoom+1,i,h),L(d)),S.push(d);}else {const s=o.zoom===D?R:o.zoom;if(t.minzoom&&t.minzoom>s)continue;let a=0;if(!l){let i=v?o.aabb.intersectsPrecise(_):o.aabb.intersectsPreciseFlat(_);if(0===i&&d()){const t=new e.bP(o.zoom,r,n);i=e.bQ(this,c,t,!0).intersectsPrecise(_);}if(0===i)continue;if(t.calculateQuadrantVisibility)if(_.containsPoint(o.aabb.center))a=15;else for(let e=0;e<4;e++)0!==o.aabb.quadrant(e).intersects(_)&&(a|=1<{const s=[0,0,0,1],a=[e.ab,e.ab,0,1],n=this.calculateFogTileMatrix(r.tileID.toUnwrapped());e.a6.vec4.transformMat4(s,s,n),e.a6.vec4.transformMat4(a,a,n);const l=e.a6.vec4.min([],s,a),c=e.a6.vec4.max([],s,a),h=e.bS(l,c);if(0===h)return !0;let u=!1;const d=this._elevation;if(d&&h>i&&0!==o){const i=this.calculateProjMatrix(r.tileID.toUnwrapped());let s;t.isTerrainDEM||(s=d.getMinMaxForTile(r.tileID)),s||(s={min:w,max:b});const a=e.c3(this.rotation),n=[a[0]*e.ab,a[1]*e.ab,s.max];e.a6.vec3.transformMat4(n,n,i),u=(1-n[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.log(e)/Math.LN2}project(t){const i=e.ap(t.lat,-e.bT,e.bT),o=this.projection.project(t.lng,i);return new e.P(o.x*this.worldSize,o.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.bD(1,this.center.lat)/this.worldSize}setLocationAtPoint(t,i){let o,r;const s=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;o=(i.x-s.x)/e,r=(i.y-s.y)/e;}else {const e=this.pointCoordinate(i),t=this.pointCoordinate(s);o=e.x-t.x,r=e.y-t.y;}const a=this.locationCoordinate(t);this.setLocation(new e.a5(a.x-o,a.y-r));}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap());}locationPoint(e){return this.projection.locationPoint(this,e)}locationPoint3D(e){return this.projection.locationPoint(this,e,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e){return this.coordinateLocation(this.pointCoordinate3D(e))}locationCoordinate(t,i){const o=i?e.bD(i,t.lat):void 0,r=this.projection.project(t.lng,t.lat);return new e.a5(r.x,r.y,o)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(t,i){const o=null!=i?i:this._centerAltitude,r=[t.x,t.y,0,1],s=[t.x,t.y,1,1];e.a6.vec4.transformMat4(r,r,this.pixelMatrixInverse),e.a6.vec4.transformMat4(s,s,this.pixelMatrixInverse);const a=s[3];e.a6.vec4.scale(r,r,1/r[3]),e.a6.vec4.scale(s,s,1/a);const n=r[2],l=s[2];return {p0:r,p1:s,t:n===l?0:(o-n)/(l-n)}}screenPointToMercatorRay(t){const i=[t.x,t.y,0,1],o=[t.x,t.y,1,1];return e.a6.vec4.transformMat4(i,i,this.pixelMatrixInverse),e.a6.vec4.transformMat4(o,o,this.pixelMatrixInverse),e.a6.vec4.scale(i,i,1/i[3]),e.a6.vec4.scale(o,o,1/o[3]),i[2]=e.bD(i[2],this._center.lat)*this.worldSize,o[2]=e.bD(o[2],this._center.lat)*this.worldSize,e.a6.vec4.scale(i,i,1/this.worldSize),e.a6.vec4.scale(o,o,1/this.worldSize),new e.aj([i[0],i[1],i[2]],e.a6.vec3.normalize([],e.a6.vec3.sub([],o,i)))}rayIntersectionCoordinate(t){const{p0:i,p1:o,t:r}=t,s=e.bD(i[2],this._center.lat),a=e.bD(o[2],this._center.lat);return new e.a5(e.aa(i[0],o[0],r)/this.worldSize,e.aa(i[1],o[1],r)/this.worldSize,e.aa(s,a,r))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(t){if(!this.elevation)return this.pointCoordinate(t);let i=this.projection.pointCoordinate3D(this,t.x,t.y);if(i)return new e.a5(i[0],i[1],i[2]);let o=0,r=this.horizonLineFromTop();if(t.y>r)return this.pointCoordinate(t);const s=.02*r,a=t.clone();for(let t=0;t<10&&r-o>s;t++){a.y=e.aa(o,r,.66);const t=this.projection.pointCoordinate3D(this,a.x,a.y);t?(r=a.y,i=t):o=a.y;}return i?new e.a5(i[0],i[1],i[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.bU)return !this.isPointAboveHorizon(t);const i=this.pointCoordinate(t);return i.y>=0&&i.y<=1}_coordinatePoint(t,i){const o=i&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,r=[t.x*this.worldSize,t.y*this.worldSize,o+t.toAltitude(),1];return e.a6.vec4.transformMat4(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,o=this.height-this._edgeInsets.bottom,r=this.width-this._edgeInsets.right,s=this.pointLocation3D(new e.P(i,t)),a=this.pointLocation3D(new e.P(r,t)),n=this.pointLocation3D(new e.P(r,o)),l=this.pointLocation3D(new e.P(i,o));let c=Math.min(s.lng,a.lng,n.lng,l.lng),h=Math.max(s.lng,a.lng,n.lng,l.lng),u=Math.min(s.lat,a.lat,n.lat,l.lat),d=Math.max(s.lat,a.lat,n.lat,l.lat);const _=Math.pow(2,-this.zoom)/16*270,p="globe"===this.projection.name?1:4,m=(t,i,o,r,s)=>{const a=(t+o)/2,n=(i+r)/2,l=new e.P(a,n),{lng:f,lat:g}=this.pointLocation3D(l),v=Math.max(0,c-f,u-g,f-h,g-d);c=Math.min(c,f),h=Math.max(h,f),u=Math.min(u,g),d=Math.max(d,g),(s_)&&(m(t,i,a,n,s+1),m(a,n,o,r,s+1));};if(m(i,t,r,t,1),m(r,t,r,o,1),m(r,o,i,o,1),m(i,o,i,t,1),"globe"===this.projection.name){const[t,i]=e.bV(this);t?(d=90,h=180,c=-180):i&&(u=-90,h=180,c=-180);}return new e.as(new e.bK(c,u),new e.bK(h,d))}_getBoundsRectangular(t,i){const{top:o,left:r}=this._edgeInsets,s=this.height-this._edgeInsets.bottom,a=this.width-this._edgeInsets.right,n=new e.P(r,o),l=new e.P(a,o),c=new e.P(a,s),h=new e.P(r,s);let u=this.pointCoordinate(n,t),d=this.pointCoordinate(l,t);const _=this.pointCoordinate(c,i),p=this.pointCoordinate(h,i),m=(e,t)=>(t.y-e.y)/(t.x-e.x);return u.y>1&&d.y>=0?u=new e.a5((1-p.y)/m(p,u)+p.x,1):u.y<0&&d.y<=1&&(u=new e.a5(-p.y/m(p,u)+p.x,0)),d.y>1&&u.y>=0?d=new e.a5((1-_.y)/m(_,d)+_.x,1):d.y<0&&u.y<=1&&(d=new e.a5(-_.y/m(_,d)+_.x,0)),(new e.as).extend(this.coordinateLocation(u)).extend(this.coordinateLocation(d)).extend(this.coordinateLocation(p)).extend(this.coordinateLocation(_))}_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.bT,this.maxLat=e.bT,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLngu&&(n=u-c),u-ht&&(a=t-l),t-e{for(let r=0;r<16;r++)e[r]=qi(t[r],i[r],o);})(n,n,l,Zi(this.pitch>=15?1:this.pitch/15));}else n=l;const c=e.a6.mat4.mul([],l,a);let h=e.a6.mat4.mul([],n,a);if(this.projection.isReprojectedInTileSpace){const t=this.locationCoordinate(this.center),i=e.a6.mat4.identity([]);e.a6.mat4.translate(i,i,[t.x*this.worldSize,t.y*this.worldSize,0]),e.a6.mat4.multiply(i,i,e.bY(this)),e.a6.mat4.translate(i,i,[-t.x*this.worldSize,-t.y*this.worldSize,0]),e.a6.mat4.multiply(h,h,i),e.a6.mat4.multiply(c,c,i),this.inverseAdjustmentMatrix=e.bZ(this);}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=e.a6.mat4.scale([],h,[this.worldSize,this.worldSize,this.worldSize/s,1]),this.projMatrix=h,this.invProjMatrix=e.a6.mat4.invert(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.a6.mat4.mul([],i,a);}else this.expandedFarZProjMatrix=this.projMatrix;const u=e.a6.mat4.invert([],n);this.frustumCorners=e.b_.fromInvProjectionMatrix(u,this.horizonLineFromTop(),this.height),this.cameraFrustum=e.bN.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!i);const d=new Float32Array(16);e.a6.mat4.identity(d),e.a6.mat4.scale(d,d,[1,-1,1]),e.a6.mat4.rotateX(d,d,this._pitch),e.a6.mat4.rotateZ(d,d,this.angle);const _=e.a6.mat4.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=e.a6.mat4.clone(_);const p=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;_[8]=2*-t.x/this.width,_[9]=2*(t.y+p)/this.height,this.skyboxMatrix=e.a6.mat4.multiply(d,_,d);const m=this.point,f=m.x,g=m.y,v=this.width%2/2,x=this.height%2/2,y=Math.cos(this.angle),b=Math.sin(this.angle),w=f-Math.round(f)+y*v+b*x,T=g-Math.round(g)+y*x+b*v,E=new Float64Array(h);if(e.a6.mat4.translate(E,E,[w>.5?w-1:w,T>.5?T-1:T,0]),this.alignedProjMatrix=E,h=e.a6.mat4.create(),e.a6.mat4.scale(h,h,[this.width/2,-this.height/2,1]),e.a6.mat4.translate(h,h,[1,-1,0]),this.labelPlaneMatrix=h,h=e.a6.mat4.create(),e.a6.mat4.scale(h,h,[1,-1,1]),e.a6.mat4.translate(h,h,[-1,-1,0]),e.a6.mat4.scale(h,h,[2/this.width,2/this.height,1]),this.glCoordMatrix=h,this.pixelMatrix=e.a6.mat4.multiply(new Float64Array(16),this.labelPlaneMatrix,c),this._calcFogMatrices(),this._distanceTileDataCache={},h=e.a6.mat4.invert(new Float64Array(16),this.pixelMatrix),!h)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=h,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=e.b$(this);const t=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=e.a6.vec3.transformMat4(t,t,a),this.globeRadius=this.worldSize/2/Math.PI-1;}else this.globeMatrix=h;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={};}_calcFogMatrices(){this._fogTileMatrixCache={};const t=this.cameraWorldSizeForFog,i=this.cameraPixelsPerMeter,o=this._camera.position,r=1/this.height/this._pixelsPerMercatorPixel,s=[t,t,i];e.a6.vec3.scale(s,s,r),e.a6.vec3.scale(o,o,-1),e.a6.vec3.multiply(o,o,s);const a=e.a6.mat4.create();e.a6.mat4.translate(a,a,o),e.a6.mat4.scale(a,a,s),this.mercatorFogMatrix=a,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,i,r);}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),o=this.point,r=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return [o.x/this.worldSize-i[0]*r,o.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),o=this._camera.position[2],r=t[2];let s=1;this.projection.wrap&&(this.center=this.center.wrap()),r>0&&(s=Math.min((i-o)/r,1)),this._camera.position=e.a6.vec3.scaleAndAdd([],this._camera.position,t,s),this._updateStateFromCamera();}_updateStateFromCamera(){const t=this._camera.position,i=this._camera.forward(),{pitch:o,bearing:r}=this._camera.getPitchBearing(),s=e.bD(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,a=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.bB(this._maxPitch)),n=Math.max((t[2]-s)/Math.cos(o),a),l=this._zoomFromMercatorZ(n);e.a6.vec3.scaleAndAdd(t,t,i,n),this._pitch=e.ap(o,e.bB(this.minPitch),e.bB(this.maxPitch)),this.angle=e.bA(r,-Math.PI,Math.PI),this._setZoom(e.ap(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new e.a5(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/(e*this.tileSize))}zoomFromMercatorZAdjusted(t){let i=0,o=e.bU,r=0,s=1/0;for(;o-i>1e-6&&o>i;){const e=i+.5*(o-i),a=this.tileSize*Math.pow(2,e),n=this.getCameraToCenterDistance(this.projection,e,a),l=this.scaleZoom(n/(t*this.tileSize)),c=Math.abs(e-l);cc||i.y>1)return !0}return !1}isHorizonVisible(){return this.pitch+e.c0(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.P(0,0),new e.P(this.width,this.height))}zoomDeltaToMovement(t,i){const o=e.a6.vec3.length(e.a6.vec3.sub([],this._camera.position,t)),r=this._zoomFromMercatorZ(o)+i;return o-this._mercatorZfromZoom(r)}getCameraPoint(){if("globe"===this.projection.name){const t=function([t,i,o],r){const s=[t,i,o,1];e.a6.vec4.transformMat4(s,s,r);const a=s[3]=Math.max(s[3],1e-6);return s[0]/=a,s[1]/=a,s[2]/=a,s}([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,o=this.worldSize){const r=e.bX(t,i,this.width,this.height,1024),s=t.pixelSpaceConversion(this.center.lat,o,r);let a=.5/Math.tan(.5*this._fov)*this.height*s;return this.isOrthographic&&(a=qi(1,a,Zi(this.pitch>=15?1:this.pitch/15))),a}getWorldToCameraMatrix(){const t=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return "globe"===this.projection.name&&e.a6.mat4.multiply(t,t,this.globeMatrix),t}getFrustum(t){return e.bN.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,"meters"===this.projection.zAxisUnit)}}const Wi=(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 o=t.transform,r=Math.max(Math.abs(o._zoom-(t.minCutoffZoom-1)),1),s=o.isLODDisabled(!1)?e.a7(60,45,o.pitch):e.a7(30,15,o.pitch),a=o._farZ-o._nearZ,n=i*o.height,l=((1-(c=s))*o.cameraToCenterDistance+c*(o._farZ+n))*r;var c;return {shouldRenderCutoff:s<1,uniformValues:{u_cutoff_params:[o._nearZ,o._farZ,(l-o._nearZ)/a,(l-n-o._nearZ)/a]}}},$i={cascadeCount:2,normalOffset:3,shadowMapResolution:2048};class Xi{constructor(e,t){this.aabb=e,this.lastCascade=t;}}class Yi{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 Xi(t,null);}clear(){this.receivers={};}get(e){return this.receivers[e.key]}computeRequiredCascades(t,i,o){const r=e.c9.fromPoints(t.points);let s=0;for(const t in this.receivers){const a=this.receivers[t];if(!a)continue;if(!r.intersectsAabb(a.aabb))continue;a.aabb.min=r.closestPoint(a.aabb.min),a.aabb.max=r.closestPoint(a.aabb.max);const n=a.aabb.getCorners();for(let t=0;t1||a[1]<-1||a[1]>1){r=!1;break}}if(a.lastCascade=t,s=Math.max(s,t),r)break}}return s+1}}class Ki{constructor(e){this.painter=e,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new Yi,this._depthMode=new Li(e.context.gl.LEQUAL,Li.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($i,["Shadows"],"cascadeCount",{min:1,max:2,step:1}),e.tp.registerParameter($i,["Shadows"],"normalOffset",{min:0,max:10,step:.05}),e.tp.registerParameter($i,["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 o=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=o.style.order.reduce(((e,i)=>{const r=o.style._mergedLayers[i];return e+(r.hasShadowPass()&&!r.isHidden(t.zoom)?1:0)}),0),this._enabled=this._shadowLayerCount>0,!this.enabled)return;const s=o.context,a=$i.shadowMapResolution,n=$i.shadowMapResolution;if(0===this._cascades.length||$i.shadowMapResolution!==this._cascades[0].texture.size[0]){this._cascades=[];for(let t=0;t<$i.cascadeCount;++t){const t=o._shadowMapDebug,i=s.gl,r=s.createFramebuffer(a,n,t,"texture"),l=new e.T(s,{width:a,height:n,data:null},i.DEPTH_COMPONENT16);if(r.depthAttachment.set(l.texture),t){const t=new e.T(s,{width:a,height:n,data:null},i.RGBA8);r.colorAttachment.set(t.texture);}this._cascades.push({framebuffer:r,texture:l,matrix:[],far:0,boundingSphereRadius:0,frustum:new e.bN,scale:0});}}this.shadowDirection=Qi(i);let l=0;if(t.elevation){const e=t.elevation,i=[1e4,-1e4];e.visibleDemTiles.filter((e=>e.dem)).forEach((e=>{const t=e.dem.tree;i[0]=Math.min(i[0],t.minimums[0]),i[1]=Math.max(i[1],t.maximums[0]);})),1e4!==i[0]&&(l=(i[1]-i[0])*e.exaggeration());}const c=1.5*t.cameraToCenterDistance,h=3*c,u=new Float64Array(16);for(let i=0;i=0)return {};const s=function(t,i,o){const r=o/(1<0&&(e.a6.vec3.add(s[1],s[1],[r[0]*a,0,0]),e.a6.vec3.add(s[2],s[2],[r[0]*a,0,0])),r[1]<0?(e.a6.vec3.add(s[0],s[0],[0,r[1]*a,0]),e.a6.vec3.add(s[1],s[1],[0,r[1]*a,0])):r[1]>0&&(e.a6.vec3.add(s[2],s[2],[0,r[1]*a,0]),e.a6.vec3.add(s[3],s[3],[0,r[1]*a,0]));const n={};return n.vertices=s,n.planes=[Ji(s[1],s[0],s[4]),Ji(s[2],s[1],s[5]),Ji(s[3],s[2],s[6]),Ji(s[0],s[3],s[7])],n}addShadowReceiver(t,i,o){this._receivers.add(t,e.c9.fromTileIdAndHeight(t,i,o));}getMaxCascadeForTile(e){const t=this._receivers.get(e);return t&&t.lastCascade?t.lastCascade:0}}function Ji(t,i,o){const r=e.a6.vec3.sub([],o,i),s=e.a6.vec3.sub([],t,i),a=e.a6.vec3.cross([],r,s),n=e.a6.vec3.length(a);return 0===n?[0,0,1,0]:(e.a6.vec3.scale(a,a,1/n),[a[0],a[1],a[2],-e.a6.vec3.dot(a,i)])}function Qi(t){const i=t.properties.get("direction"),o=e.c7(i.x,i.y,i.z);o[2]=e.ap(o[2],0,75);const r=e.ca([o[0],o[1],o[2]]);return e.a6.vec3.fromValues(r.x,r.y,r.z)}function eo(t,i,o){const r=i.properties.get("color"),s=i.properties.get("intensity"),a=i.properties.get("direction"),n=[a.x,a.y,a.z],l=o.properties.get("color"),c=o.properties.get("intensity"),h=Math.max(e.a6.vec3.dot([0,0,1],n),0),u=[0,0,0];e.a6.vec3.scale(u,l.toRenderColor(t.getLut(i.scope)).toArray01Linear().slice(0,3),c);const d=[0,0,0];return e.a6.vec3.scale(d,r.toRenderColor(t.getLut(o.scope)).toArray01Linear().slice(0,3),h*s),e.cb([u[0]>0?u[0]/(u[0]+d[0]):0,u[1]>0?u[1]/(u[1]+d[1]):0,u[2]>0?u[2]/(u[2]+d[2]):0])}function to(t,i,o,r,s,a){const n=t.zoom,l=t.scale,c=t.worldSize,h=1/c,u=t.aspect,d=Math.sqrt(1+u*u)*Math.tan(.5*t.fovX),_=d*d,p=r-o,m=r+o;let f,g;_>p/m?(f=r,g=r*d):(f=.5*m*(1+_),g=.5*Math.sqrt(p*p+2*(r*r+o*o)*_+m*m*_*_));const v=t.projection.pixelsPerMeter(t.center.lat,c),x=t._camera.getCameraToWorldMercator(),y=[0,0,-f*h];e.a6.vec3.transformMat4(y,y,x);let b=g*h;const w=t._edgeInsets;if(!(0===w.left&&0===w.top&&0===w.right&&0===w.bottom||w.left===w.right&&w.top===w.bottom)){const i=t._camera.getWorldToCamera(t.worldSize,"meters"===t.projection.zAxisUnit?v:1),s=t._camera.getCameraToClipPerspective(t._fov,t.width/t.height,o,r);s[8]=2*-t.centerOffset.x/t.width,s[9]=2*t.centerOffset.y/t.height;const a=new Float64Array(16);e.a6.mat4.mul(a,s,i);const h=new Float64Array(16);e.a6.mat4.invert(h,a);const u=e.bN.fromInvProjectionMatrix(h,c,n,!0);for(const i of u.points){const o=((T=i)[0]/=l,T[1]/=l,T[2]=e.bD(T[2],t._center.lat),T);b=Math.max(b,e.a6.vec3.len(e.a6.vec3.subtract([],y,o)));}}var T;b*=s/(s-1);const E=Math.acos(i[2]),C=Math.atan2(-i[0],-i[1]),S=new Gi;S.position=y,S.setPitchBearing(E,C);const I=S.getWorldToCamera(c,v),D=b*c,R=Math.min(t._mercatorZfromZoom(17)*c*-2,-2*D),A=S.getCameraToClipOrthographic(-D,D,-D,D,R,(D+a*v)/i[2]),L=new Float64Array(16);e.a6.mat4.multiply(L,A,I);const P=e.a6.vec3.fromValues(Math.floor(1e6*y[0])/1e6*c,Math.floor(1e6*y[1])/1e6*c,0),M=.5*s,z=[0,0,0];e.a6.vec3.transformMat4(z,P,L),e.a6.vec3.scale(z,z,M);const O=[Math.floor(z[0]),Math.floor(z[1]),Math.floor(z[2])],F=[0,0,0];e.a6.vec3.sub(F,z,O),e.a6.vec3.scale(F,F,-1/M);const k=new Float64Array(16);return e.a6.mat4.identity(k),e.a6.mat4.translate(k,k,F),e.a6.mat4.multiply(L,k,L),[L,D]}class io extends e.E{constructor(e){super(),this.requestManager=e,this.models={"":{}},this.numModelsLoading={};}loadModel(t,i){return e.aG(this.requestManager.transformRequest(i,e.R.Model).url).then((i=>{if(!i)return;const o=e.aH(i),r=new e.aI(t,void 0,void 0,o);return r.computeBoundsAndApplyParent(),r})).catch((o=>{if(o&&404===o.status)return null;this.fire(new e.t(new Error(`Could not load model ${t} from ${i}: ${o.message}`)));}))}load(t,i){this.models[i]||(this.models[i]={});const o=Object.keys(t);this.numModelsLoading[i]=(this.numModelsLoading[i]||0)+o.length;const r=[];for(const e of o)r.push(this.loadModel(e,t[e]));Promise.allSettled(r).then((t=>{for(let e=0;e{this.fire(new e.t(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){return !!this.getModel(e,t)}getModel(e,t){return this.models[t]||(this.models[t]={}),this.models[t][e]?this.models[t][e].model:void 0}addModel(e,t,i){this.models[i]||(this.models[i]={}),this.hasModel(e,i)&&this.models[i][e].numReferences++,this.load({[e]:this.requestManager.normalizeModelURL(t)},i);}addModels(e,t){this.models[t]||(this.models[t]={});const i={};for(const o in e)this.models[t][o]={},i[o]=this.requestManager.normalizeModelURL(e[o]);this.load(i,t);}addModelsFromBucket(e,t){this.models[t]||(this.models[t]={});const i={};for(const o of e)this.hasModel(o,t)?this.models[t][o].numReferences++:i[o]=this.requestManager.normalizeModelURL(o);this.load(i,t);}removeModel(e,t){if(this.models[t]&&this.models[t][e]&&(this.models[t][e].numReferences--,0===this.models[t][e].numReferences)){const i=this.models[t][e].model;delete this.models[t][e],i.destroy();}}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 oo=new e.a0({data:new e.a1(e._.colorTheme.data)}),ro=(e,t)=>De(e,t&&t.filter((e=>"source.canvas"!==e.identifier))),so=e.ar(Ct,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection","setCamera","addImport","removeImport","updateImport"]),ao=e.ar(Ct,["setCenter","setZoom","setBearing","setPitch"]),no={version:8,layers:[],sources:{}},lo={duration:300,delay:0};class co 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=e.l({},lo),this._buildingIndex=new wt(this),this.crossTileSymbolIndex=new Di,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._clipLayerPresent=!1,this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._changes=i.styleChanges||new j,this.dispatcher=i.dispatcher?i.dispatcher:new e.cd(e.ce(),this),i.imageManager?this.imageManager=i.imageManager:(this.imageManager=new q,this.imageManager.setEventedParent(this)),this.imageManager.createScope(this.scope),this.glyphManager=i.glyphManager?i.glyphManager:new e.cf(t._requestManager,i.localFontFamily?e.cg.all:i.localIdeographFontFamily?e.cg.ideographs:e.cg.none,i.localFontFamily||i.localIdeographFontFamily),i.modelManager?this.modelManager=i.modelManager:(this.modelManager=new io(t._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._precompileDone=!1,this._shouldPrecompile=!1,this._availableImages=[],this._order=[],this._markersNeedUpdate=!1,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null},this._styleColorThemeForScope={},this.options=i.configOptions?i.configOptions:new Map,this._configDependentLayers=i.configDependentLayers?i.configDependentLayers:new Set,this._config=i.config,this._initialConfig=i.initialConfig,this.dispatcher.broadcast("setReferrer",e.ch());const o=this;this._rtlTextPluginCallback=co.registerForPluginStateChange((t=>{o.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},((t,i)=>{if(e.ci(t),i&&i.every((e=>e)))for(const e in o._sourceCaches){const t=o._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.f(t))return t;const i=e.cj(t);if(!i.startsWith("http"))try{return new URL(i,location.href).toString()}catch(e){return i}return i}return `json://${e.ck(JSON.stringify(t))}`}_diffStyle(t,i,o){this.globalId=this._getGlobalId(t);const r=(e,t)=>{try{t(null,this.setState(e,o));}catch(e){t(e,!1);}};if("string"==typeof t){const o=this.map._requestManager.normalizeStyleURL(t),s=this.map._requestManager.transformRequest(o,e.R.Style);e.n(s,((t,o)=>{t?this.fire(new e.t(t)):o&&r(o,i);}));}else "object"==typeof t&&r(t,i);}loadURL(t,i={}){this.fire(new e.x("dataloading",{dataType:"style"}));const o="boolean"==typeof i.validate?i.validate:!e.f(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,o);const s=this.map._requestManager.transformRequest(t,e.R.Style);this._request=e.n(s,((i,r)=>{if(this._request=null,i)this.fire(new e.t(i));else if(r)return this.importsCache.set(t,r),this._load(r,o)}));}loadJSON(t,i={}){this.fire(new e.x("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(t),this._request=e.q.frame((()=>{this._request=null,this._load(t,!1!==i.validate);}));}loadEmpty(){this.fire(new e.x("dataloading",{dataType:"style"})),this._load(no,!1);}_loadImports(t,i,o){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),s=new Promise((e=>{t.once("style.import.load",e),t.once("error",e);})).then((()=>this.mergeAll()));if(r.push(s),this.resolvedImports.has(e.url)){t.loadEmpty();continue}const a=e.data||this.importsCache.get(e.url);a?(t.loadJSON(a,{validate:i}),this._isInternalStyle(a)&&(t.globalId=null)):e.url?t.loadURL(e.url,{validate:i}):t.loadEmpty();const n={style:t,id:e.id,config:e.config};if(o){const e=this.fragments.findIndex((({id:e})=>e===o));this.fragments=this.fragments.slice(0,e).concat(n).concat(this.fragments.slice(e));}else this.fragments.push(n);}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.av(t.id,this.scope):t.id;let o;const r=this._initialConfig&&this._initialConfig[i];(t.config||r)&&(o=e.l({},t.config,r));const s=new co(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:o,configOptions:this.options,configDependentLayers:this._configDependentLayers});return s.setEventedParent(this.map,{style:s}),s}_reloadImports(){this.mergeAll(),this._updateMapProjection(),this.updateConfigDependencies(),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){const o=t.schema;if(this._isInternalStyle(t)){const o=e.l({},no,{imports:[{id:"basemap",data:t,url:""}]});return void this._load(o,i)}if(this.updateConfig(this._config,o),i&&ro(this,fe(t)))return;this._loaded=!0,this.stylesheet=e.cl(t);const r=()=>{for(const e in t.sources)this.addSource(e,t.sources[e],{validate:!1,isInitialLoad:!0});t.sprite?this._loadSprite(t.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),this.glyphManager.setURL(t.glyphs,this.scope);const o=Et(this.stylesheet.layers);if(this._order=o.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 Ae(e.properties,e.id);}else this.setLights(this.stylesheet.lights);this.light||(this.light=new Ae(this.stylesheet.light)),this._layers={},this._serializedLayers={};for(const t of o){const i=e.cq(t,this.scope,this._styleColorTheme.lut,this.options);0!==i.configDependencies.size&&this._configDependentLayers.add(i.fqid),i.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=i,this._serializedLayers[i.id]=i.serialize();const o=this.getOwnLayerSourceCache(i),r=!!this.directionalLight&&this.directionalLight.shadowsEnabled();o&&i.canCastShadows()&&r&&(o.castsShadows=!0);}this.stylesheet.models&&this.modelManager.addModels(this.stylesheet.models,this.scope);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.transition&&this.setTransition(this.stylesheet.transition),this.fire(new e.x("data",{dataType:"style"}));const s=this.isRootStyle();t.imports?this._loadImports(t.imports,i).then((()=>{this._reloadImports(),this.fire(new e.x(s?"style.load":"style.import.load"));})):(this._reloadImports(),this.fire(new e.x(s?"style.load":"style.import.load")));},s=this.stylesheet["color-theme"];if(this._styleColorTheme.colorTheme=s,s){const t=this._evaluateColorThemeData(s);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}mergeAll(){let t,i,o,r,s,a,n,l;const c={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle((e=>{if(e.stylesheet){if(null!=e.light&&(t=e.light),e.stylesheet.lights)for(const t of e.stylesheet.lights)"ambient"===t.type&&null!=e.ambientLight&&(i=e.ambientLight),"directional"===t.type&&null!=e.directionalLight&&(o=e.directionalLight);r=this._prioritizeTerrain(r,e.terrain,e.stylesheet.terrain),e.stylesheet.fog&&null!=e.fog&&(s=e.fog),null!=e.stylesheet.camera&&(l=e.stylesheet.camera),null!=e.stylesheet.projection&&(a=e.stylesheet.projection),null!=e.stylesheet.transition&&(n=e.stylesheet.transition),c[e.scope]=e._styleColorTheme;}})),this.light=t,this.ambientLight=i,this.directionalLight=o,this.fog=s,this._styleColorThemeForScope=c,null===r?delete this.terrain:this.terrain=r,this.camera=l||{"camera-projection":"perspective"},this.projection=a||{name:"mercator"},this.transition=e.l({},lo,n),this.mergeSources(),this.mergeLayers();}forEachFragmentStyle(e){const t=i=>{for(const e of i.fragments)t(e.style);e(i);};t(this);}_prioritizeTerrain(e,t,i){const o=e&&0===e.drapeRenderMode;return null===i?t&&0===t.drapeRenderMode?t:o?e:null:null!=t&&(!e||o||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={},o={};this.forEachFragmentStyle((r=>{for(const i in r._sourceCaches){const o=e.av(i,r.scope);t[o]=r._sourceCaches[i];}for(const t in r._otherSourceCaches){const o=e.av(t,r.scope);i[o]=r._otherSourceCaches[t];}for(const t in r._symbolSourceCaches){const i=e.av(t,r.scope);o[i]=r._symbolSourceCaches[t];}})),this._mergedSourceCaches=t,this._mergedOtherSourceCaches=i,this._mergedSymbolSourceCaches=o;}mergeLayers(){const t={},i=[],o={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle((o=>{for(const r of o._order){const s=o._layers[r];if("slot"===s.type){const i=e.cm(r);if(t[i])continue;t[i]=[];}s.slot&&t[s.slot]?t[s.slot].push(s):i.push(s);}})),this._mergedOrder=[];const r=(i=[])=>{for(const s of i)if("slot"===s.type){const i=e.cm(s.id);t[i]&&r(t[i]),this._mergedSlots.push(i);}else {const t=e.av(s.id,s.scope);this._mergedOrder.push(t),o[t]=s,s.is3D()&&(this._has3DLayers=!0),"circle"===s.type&&(this._hasCircleLayers=!0),"symbol"===s.type&&(this._hasSymbolLayers=!0),"clip"===s.type&&(this._clipLayerPresent=!0);}};r(i),this._mergedOrder.sort(((e,t)=>{const i=o[e],r=o[t];return i.hasInitialOcclusionOpacityProperties?r.is3D()?1:0:i.is3D()&&r.hasInitialOcclusionOpacityProperties?-1:0})),this._mergedLayers=o,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged();}terrainSetForDrapingOnly(){return !!this.terrain&&0===this.terrain.drapeRenderMode}getCamera(){return this.stylesheet.camera}setCamera(t){return this.stylesheet.camera=e.l({},this.stylesheet.camera,t),this.camera=this.stylesheet.camera,this}_evaluateColorThemeData(t){return t.data?function(t,i,o){const r=e.l({},i);for(const t of Object.keys(e._.colorTheme))void 0===r[t]&&(r[t]=e._.colorTheme[t].default);const s=new e.$(oo,t,new Map(o));return s.setTransitionOrValue(r,o),s.untransitioned().possiblyEvaluate(new e.a3(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(((o,r)=>{const s="data:image/png;base64,";if(!t||0===t.length)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void o();let a=t;a.startsWith(s)||(a=s+a);const n="mapbox-reserved-lut",l=new Image;l.src=a,l.onerror=()=>{this._styleColorTheme.lutLoading=!1,r(new Error("Failed to load image data"));},l.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==i)return void o();this._styleColorTheme.lutLoading=!1;const{width:s,height:a,data:c}=e.q.getImageData(l);if(a>32)return void r(new Error("The height of the image must be less than or equal to 32 pixels."));if(s!==a*a)return void r(new Error("The width of the image must be equal to the height squared."));this.getImage(n)&&this.removeImage(n),this.addImage(n,{data:new e.r({width:s,height:a},c),pixelRatio:1,sdf:!1,version:0});const h=this.imageManager.getImage(n,this.scope);h?(this._styleColorTheme.lut={image:h.data,data:t},o()):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,o){let r,s,a;const n=e.q.devicePixelRatio>1?"@2x":"";let l=e.n(i.transformRequest(i.normalizeSpriteURL(t,n,".json"),e.R.SpriteJSON),((e,t)=>{l=null,a||(a=e,r=t,h());})),c=e.o(i.transformRequest(i.normalizeSpriteURL(t,n,".png"),e.R.SpriteImage),((e,t)=>{c=null,a||(a=e,s=t,h());}));function h(){if(a)o(a);else if(r&&s){const t=e.q.getImageData(s),i={};for(const o in r){const{width:s,height:a,x:n,y:l,sdf:c,pixelRatio:h,stretchX:u,stretchY:d,content:_}=r[o],p=new e.r({width:s,height:a});e.r.copy(t,p,{x:n,y:l},{x:0,y:0},{width:s,height:a},null),i[o]={data:p,pixelRatio:h,sdf:c,stretchX:u,stretchY:d,content:_};}o(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.t(t));else if(i)for(const e in i)this.imageManager.addImage(e,this.scope,i[e]);this.imageManager.setLoaded(!0,this.scope),this._availableImages=this.imageManager.listImages(this.scope),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages}),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new e.x("data",{dataType:"style"}));}));}_validateLayer(t){const i=this.getOwnSource(t.source);if(!i)return;const o=t.sourceLayer;o&&("geojson"===i.type||i.vectorLayerIds&&-1===i.vectorLayerIds.indexOf(o))&&this.fire(new e.t(new Error(`Source layer "${o}" 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.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()}hasTransitions(){if(this.hasLightTransitions())return !0;if(this.hasFogTransition())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}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.t(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.t(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 o=e.minzoom||0;o<(e.maxzoom||25.5);o++){const o=e.getProgramIds();if(o)for(const r of o){const o=e.getDefaultProgramParams(r,t.zoom,this._styleColorTheme.lut);o&&(i.style=this,this.fog&&(i._fogVisible=!0,o.overrideFog=!0,i.getOrCreateProgram(r,o)),i._fogVisible=!1,o.overrideFog=!1,i.getOrCreateProgram(r,o),(this.stylesheet.terrain||this.stylesheet.projection&&"globe"===this.stylesheet.projection.name)&&(o.overrideRtt=!0,i.getOrCreateProgram(r,o)));}}}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));const o=this._changes.isDirty();let r=!1;if(this._changes.isDirty()){const e=this._changes.getLayerUpdatesByScope();for(const t in e){const{updatedIds:i,removedIds:o}=e[t];(i||o)&&(this._updateWorkerLayers(t,i,o),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._changes.reset();}const s={};for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e];s[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();for(const t in s){const i=this._mergedSourceCaches[t];s[t]!==i.used&&i.getSource().fire(new e.x("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.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),o&&this.fire(new e.x("data",{dataType:"style"}));}_updateTilesForChangedImages(){const e=this._changes.getUpdatedImages();if(e.length){for(const t in this._sourceCaches)this._sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changes.resetUpdatedImages();}}_updateWorkerLayers(e,t,i){const o=this.getFragmentStyle(e);o&&this.dispatcher.broadcast("updateLayers",{layers:t?o._serializeLayers(t):[],scope:e,removedIds:i||[],options:o.options});}setState(t,i){if(this._checkLoaded(),ro(this,fe(t)))return !1;(t=e.cl(t)).layers=Et(t.layers);const o=function(t,i){if(!t)return [{command:Ct.setStyle,args:[i]}];let o=[];try{if(!e.bh(t.version,i.version))return [{command:Ct.setStyle,args:[i]}];if(e.bh(t.center,i.center)||o.push({command:Ct.setCenter,args:[i.center]}),e.bh(t.zoom,i.zoom)||o.push({command:Ct.setZoom,args:[i.zoom]}),e.bh(t.bearing,i.bearing)||o.push({command:Ct.setBearing,args:[i.bearing]}),e.bh(t.pitch,i.pitch)||o.push({command:Ct.setPitch,args:[i.pitch]}),e.bh(t.sprite,i.sprite)||o.push({command:Ct.setSprite,args:[i.sprite]}),e.bh(t.glyphs,i.glyphs)||o.push({command:Ct.setGlyphs,args:[i.glyphs]}),e.bh(t.imports,i.imports)||function(t=[],i=[],o){i=i||[];const r=(t=t||[]).map(Lt),s=i.map(Lt),a=t.reduce(Pt,{}),n=i.reduce(Pt,{}),l=r.slice();let c,h,u,d;for(c=0,h=0;c{e.source&&r[e.source]?o.push({command:Ct.removeLayer,args:[e.id]}):a.push(e);}));let n=t.terrain;n&&r[n.source]&&(o.push({command:Ct.setTerrain,args:[void 0]}),n=void 0),o=o.concat(s),e.bh(n,i.terrain)||o.push({command:Ct.setTerrain,args:[i.terrain]}),function(t,i,o){i=i||[];const r=(t=t||[]).map(Lt),s=i.map(Lt),a=t.reduce(Pt,{}),n=i.reduce(Pt,{}),l=r.slice(),c=Object.create(null);let h,u,d,_,p,m,f;for(h=0,u=0;h!(e.command in ao)));if(0===o.length)return !1;const r=o.filter((e=>!(e.command in so)));if(r.length>0)throw new Error(`Unimplemented: ${r.map((e=>e.command)).join(", ")}.`);const s=[];return o.forEach((e=>{s.push(this[e.command].apply(this,e.args));})),i&&Promise.all(s).then(i),this.stylesheet=t,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}addImage(t,i){return this.getImage(t)?this.fire(new e.t(new Error("An image with this name already exists."))):(this.imageManager.addImage(t,this.scope,i),this._afterImageUpdated(t),this)}updateImage(e,t){this.imageManager.updateImage(e,this.scope,t);}getImage(e){return this.imageManager.getImage(e,this.scope)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t,this.scope),this._afterImageUpdated(t),this):this.fire(new e.t(new Error("No image with this name exists.")))}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(this.scope),this._changes.updateImage(t),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages}),this.fire(new e.x("data",{dataType:"style"}));}listImages(){return this._checkLoaded(),this._availableImages.slice()}addModel(e,t,i={}){return this._checkLoaded(),this._validate(Se,`models.${e}`,t,null,i)||(this.modelManager.addModel(e,t,this.scope),this._changes.setDirty()),this}hasModel(e){return this.modelManager.hasModel(e,this.scope)}removeModel(t){return this.hasModel(t)?(this.modelManager.removeModel(t,this.scope),this):this.fire(new e.t(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.scope)}addSource(t,i,o={}){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(ge,`sources.${t}`,i,null,o))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const r=tt(t,i,this.dispatcher,this);r.scope=this.scope,r.setEventedParent(this,(()=>({isSourceLoaded:this._isSourceCacheLoaded(r.id),source:r.serialize(),sourceId:r.id})));const s=t=>{const i=(t?"symbol:":"other:")+r.id,o=e.av(i,this.scope),s=this._sourceCaches[i]=new vt(o,r,t);(t?this._symbolSourceCaches:this._otherSourceCaches)[r.id]=s,s.onAdd(this.map);};s(!1),"vector"!==i.type&&"geojson"!==i.type||s(!0),r.onAdd&&r.onAdd(this.map),o.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.t(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.t(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));const o=this.getOwnSourceCaches(t);for(const t of o){const i=e.cm(t.id);delete this._sourceCaches[i],this._changes.discardSourceCacheUpdate(t.id),t.fire(new e.x("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 o of t){if(this._validate(xe,"lights",o))return;switch(o.type){case"ambient":if(this.ambientLight){const e=this.ambientLight;e.set(o),e.updateTransitions(i);}else this.ambientLight=new je(o,Ve||(Ve=new e.a0({color:new e.a1(e._.properties_light_ambient.color),intensity:new e.a1(e._.properties_light_ambient.intensity)})),this.scope,this.options);break;case"directional":if(this.directionalLight){const e=this.directionalLight;e.set(o),e.updateTransitions(i);}else this.directionalLight=new je(o,qe||(qe=new e.a0({direction:new e.ad(e._.properties_light_directional.direction),color:new e.a1(e._.properties_light_directional.color),intensity:new e.a1(e._.properties_light_directional.intensity),"cast-shadows":new e.a1(e._.properties_light_directional["cast-shadows"]),"shadow-intensity":new e.a1(e._.properties_light_directional["shadow-intensity"])})),this.scope,this.options);}}const o=new e.a3(this.z||0,i);this.ambientLight&&this.ambientLight.recalculate(o),this.directionalLight&&this.directionalLight.recalculate(o),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness);}calculateLightsBrightness(){const t=this.directionalLight,i=this.ambientLight;if(!t||!i)return;const o=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").toRenderColor(null).toArray01(),s=t.properties.get("intensity"),a=t.properties.get("direction"),n=1-e.c7(a.x,a.y,a.z)[2]/90,l=o(r)*s*n,c=i.properties.get("color").toRenderColor(null).toArray01(),h=i.properties.get("intensity");return (l+o(c)*h)/2}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(!t)return this;if(e.cn(t)){const i=e.co(t),o=this.fragments.find((({id:e})=>e===i));if(!o)throw new Error(`Style import not found: ${t}`);const r=e.cm(t);return o.style.getFragmentStyle(r)}{const e=this.fragments.find((({id:e})=>e===t));if(!e)throw new Error(`Style import not found: ${t}`);return e.style}}getConfigProperty(t,i){const o=this.getFragmentStyle(t);if(!o)return null;const r=e.av(i,o.scope),s=o.options.get(r),a=s?s.value||s.default:null;return a?a.serialize():null}setConfigProperty(t,i,o){const r=this.getFragmentStyle(t);if(!r)return;const s=r.stylesheet.schema;if(!s||!s[i])return;const a=e.M(o);if("success"!==a.result)return void ro(this,a.value);const n=a.value.expression,l=e.av(i,r.scope),c=r.options.get(l);if(!c)return;let h;const{minValue:u,maxValue:d,stepValue:_,type:p,values:m}=s[i],f=e.M(s[i].default);"success"===f.result&&(h=f.value.expression),h?(this.options.set(l,{...c,value:n,default:h,minValue:u,maxValue:d,stepValue:_,type:p,values:m}),this.updateConfigDependencies(i)):this.fire(new e.t(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 o=i.stylesheet.schema;if(!o)return null;const r={};for(const t in o){const o=e.av(t,i.scope),s=i.options.get(o),a=s?s.value||s.default:null;r[t]=a?a.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 o in i){let r,s;const a=e.M(i[o].default);if("success"===a.result&&(r=a.value.expression),t&&void 0!==t[o]){const i=e.M(t[o]);"success"===i.result&&(s=i.value.expression);}const{minValue:n,maxValue:l,stepValue:c,type:h,values:u}=i[o];if(r){const t=e.av(o,this.scope);this.options.set(t,{default:r,value:s,minValue:n,maxValue:l,stepValue:c,type:h,values:u});}else this.fire(new e.t(new Error(`No schema defined for config option "${o}".`)));}else this.fire(new e.t(new Error("Attempting to set config for a style without schema.")));}updateConfigDependencies(e){for(const t of this._configDependentLayers){const i=this.getLayer(t);if(i){if(e&&!i.configDependencies.has(e))continue;i.possiblyEvaluateVisibility(),this._updateLayer(i);}}this.ambientLight&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.updateConfig(this.options),this.fog&&this.fog.updateConfig(this.options),this.forEachFragmentStyle((e=>{if(e._styleColorTheme.colorTheme){const t=e._evaluateColorThemeData(e._styleColorTheme.colorTheme);(!e._styleColorTheme.lut&&""!==t||e._styleColorTheme.lut&&t!==e._styleColorTheme.lut.data)&&e.setColorTheme(e._styleColorTheme.colorTheme);}})),this._changes.setDirty();}addLayer(t,i,o={}){this._checkLoaded();const r=t.id;if(this._layers[r])return void this.fire(new e.t(new Error(`Layer with id "${r}" already exists on this map`)));let s;if("custom"===t.type){if(ro(this,e.cp(t)))return;s=e.cq(t,this.scope,this._styleColorTheme.lut,this.options);}else {if("object"==typeof t.source&&(this.addSource(r,t.source),t=e.cl(t),t=e.l(t,{source:r})),this._validate(we,`layers.${r}`,t,{arrayIndex:-1},o))return;s=e.cq(t,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(s),s.setEventedParent(this,{layer:{id:r}}),this._serializedLayers[s.id]=s.serialize();}0!==s.configDependencies.size&&this._configDependentLayers.add(s.fqid);let a=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.t(new Error(`Layer with id "${i}" does not exist on this map.`)));s.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]=s;const n=this.getOwnLayerSourceCache(s),l=!!this.directionalLight&&this.directionalLight.shadowsEnabled();n&&s.canCastShadows()&&l&&(n.castsShadows=!0);const c=this._changes.getRemovedLayer(s);if(c&&s.source&&n&&"custom"!==s.type){this._changes.discardLayerRemoval(s);const t=e.av(s.source,s.scope);c.type!==s.type?this._changes.updateSourceCache(t,"clear"):(this._changes.updateSourceCache(t,"reload"),n.pause());}this._updateLayer(s),s.onAdd&&s.onAdd(this.map),s.scope=this.scope,this.mergeLayers();}moveLayer(t,i){this._checkLoaded();const o=this._checkLayer(t);if(!o)return;if(t===i)return;const r=this._order.indexOf(t);this._order.splice(r,1);let s=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.t(new Error(`Layer with id "${i}" does not exist on this map.`)));o.slot===this._layers[i].slot?s=t:e.w(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`);}this._order.splice(s,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],delete this._serializedLayers[e],this._changes.setDirty(),this._layerOrderChanged=!0,this._configDependentLayers.delete(t.fqid),this._changes.removeLayer(t);const o=this.getOwnLayerSourceCache(t);if(o&&o.castsShadows){let e=!1;for(const i in this._layers)if(this._layers[i].source===t.source&&this._layers[i].canCastShadows()){e=!0;break}o.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 o=this._checkLayer(e);o&&(o.minzoom===t&&o.maxzoom===i||(null!=t&&(o.minzoom=t),null!=i&&(o.maxzoom=i),this._updateLayer(o)));}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,o={}){this._checkLoaded();const r=this._checkLayer(t);if(r&&!e.bh(r.filter,i))return null==i?(r.filter=void 0,void this._updateLayer(r)):void(this._validate(Te,`layers.${r.id}.filter`,i,{layerType:r.type},o)||(r.filter=e.cl(i),this._updateLayer(r)))}getFilter(t){const i=this._checkLayer(t);if(i)return e.cl(i.filter)}setLayoutProperty(t,i,o,r={}){this._checkLoaded();const s=this._checkLayer(t);if(s&&!e.bh(s.getLayoutProperty(i),o)){if(null!=o&&(!r||!1!==r.validate)&&ro(s,Ce.call(fe,{key:`layers.${t}.layout.${i}`,layerType:s.type,objectKey:i,value:o,styleSpec:e._,style:{glyphs:!0,sprite:!0}})))return;s.setLayoutProperty(i,o),0!==s.configDependencies.size&&this._configDependentLayers.add(s.fqid),this._updateLayer(s);}}getLayoutProperty(e,t){const i=this._checkLayer(e);if(i)return i.getLayoutProperty(t)}setPaintProperty(t,i,o,r={}){this._checkLoaded();const s=this._checkLayer(t);if(!s)return;if(e.bh(s.getPaintProperty(i),o))return;if(null!=o&&(!r||!1!==r.validate)&&ro(s,Ee.call(fe,{key:`layers.${t}.paint.${i}`,layerType:s.type,objectKey:i,value:o,styleSpec:e._})))return;const a=s.setPaintProperty(i,o);0!==s.configDependencies.size&&this._configDependentLayers.add(s.fqid),a&&this._updateLayer(s),this._changes.updatePaintProperties(s);}getPaintProperty(e,t){const i=this._checkLayer(e);if(i)return i.getPaintProperty(t)}setFeatureState(t,i){this._checkLoaded();const o=t.source,r=t.sourceLayer,s=this._checkSource(o);if(!s)return;const a=s.type;if("geojson"===a&&r)return void this.fire(new e.t(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===a&&!r)return void this.fire(new e.t(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===t.id&&this.fire(new e.t(new Error("The feature id parameter must be provided.")));const n=this.getOwnSourceCaches(o);for(const e of n)e.setFeatureState(r,t.id,i);}removeFeatureState(t,i){this._checkLoaded();const o=t.source,r=this._checkSource(o);if(!r)return;const s=r.type,a="vector"===s?t.sourceLayer:void 0;if("vector"===s&&!a)return void this.fire(new e.t(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.t(new Error("A feature id is required to remove its specific state property.")));const n=this.getOwnSourceCaches(o);for(const e of n)e.removeFeatureState(a,t.id,i);}getFeatureState(t){this._checkLoaded();const i=t.source,o=t.sourceLayer,r=this._checkSource(i);if(r){if("vector"!==r.type||o)return void 0===t.id&&this.fire(new e.t(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(i)[0].getFeatureState(o,t.id);this.fire(new e.t(new Error("The sourceLayer parameter must be provided for vector source types.")));}}setTransition(t){return this.stylesheet.transition=e.l({},this.stylesheet.transition,t),this.transition=this.stylesheet.transition,this}getTransition(){return e.l({},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.cr({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,fragment:this.stylesheet.fragment,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,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))}_updateLayer(t){this._changes.updateLayer(t);const i=this.getLayerSourceCache(t),o=e.av(t.source,t.scope),r=this._changes.getUpdatedSourceCaches();t.source&&!r[o]&&i&&"raster"!==i.getSource().type&&(this._changes.updateSourceCache(o,"reload"),i.pause()),t.invalidateCompiledFilter();}_flattenAndSortRenderedFeatures(e){const t=e=>this._mergedLayers[e].is3D(),i=this.order,o={},r=[];for(let s=i.length-1;s>=0;s--){const a=i[s];if(t(a)){o[a]=s;for(const t of e){const e=t[a];if(e)for(const t of e)r.push(t);}}}r.sort(((e,t)=>t.intersectionZ-e.intersectionZ));const s=[];for(let a=i.length-1;a>=0;a--){const n=i[a];if(t(n))for(let e=r.length-1;e>=0;e--){const t=r[e].feature;if(t.layer&&o[t.layer.id]{const t=this.getLayer(e);return t&&t.is3D()})):this.has3DLayers(),l=Ze.createFromScreenPoints(t,o);for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e].getSource();if(!t||t.scope!==i.scope)continue;const c=this._mergedSourceCaches[e].getSource().id;i.layers&&!r[c]||s.push(ot(this._mergedSourceCaches[e],this._mergedLayers,a,l,i,o,n,!!this.map._showQueryGeometry));}return this.placement&&s.push(function(e,t,i,o,r,s,a){const n={},l=s.queryRenderedSymbols(o),c=[];for(const e of Object.keys(l).map(Number))c.push(a[e]);c.sort(st);for(const i of c){const o=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],t,i.bucketIndex,i.sourceLayerIndex,r.filter,r.layers,r.availableImages,e);for(const e in o){const t=n[e]=n[e]||[],r=o[e];r.sort(((e,t)=>{const o=i.featureSortOrder;if(o){const i=o.indexOf(e.featureIndex);return o.indexOf(t.featureIndex)-i}return t.featureIndex-e.featureIndex}));for(const e of r)t.push(e);}}for(const t in n)n[t].forEach((o=>{const r=o.feature,s=i(e[t]);if(!s)return;const a=s.getFeatureState(r.layer["source-layer"],r.id);r.source=r.layer.source,r.layer["source-layer"]&&(r.sourceLayer=r.layer["source-layer"]),r.state=a;}));return n}(this._mergedLayers,a,this.getLayerSourceCache.bind(this),l.screenGeometry,i,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(s)}querySourceFeatures(e,t){t&&t.filter&&this._validate(Te,"querySourceFeatures.filter",t.filter,null,t);const i=this.getOwnSourceCaches(e);let o=[];for(const e of i)o=o.concat(rt(e,t));return o}addSourceType(e,t,i){return co.getSourceType(e)?i(new Error(`A source type called "${e}" already exists.`)):(co.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,o={}){this._checkLoaded();const r=this.light.getLight();let s=!1;for(const i in t)if(!e.bh(t[i],r[i])){s=!0;break}if(!s)return;const a=this._getTransitionParameters();this.light.setLight(t,i,o),this.light.updateTransitions(a);}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.q.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 o=t;const r=null==t.source;if(1===i){if(this.disableElevatedTerrain)return;if("object"==typeof o.source){const t="terrain-dem-src";this.addSource(t,o.source),o=e.cl(o),o=e.l(o,{source:t});}const t=e.l({},o),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(ye,"terrain",t,i))return}if(!this.terrain||this.terrain.scope!==this.scope&&!r||this.terrain&&i!==this.terrain.drapeRenderMode){if(!o)return;this._createTerrain(o,i),this.fire(new e.x("data",{dataType:"style"}));}else {const i=this.terrain,r=i.get();for(const t of Object.keys(e._.terrain))!o.hasOwnProperty(t)&&e._.terrain[t].default&&(o[t]=e._.terrain[t].default);for(const o in t)if(!e.bh(t[o],r[o])){i.set(t,this.options),this.stylesheet.terrain=t;const o=this._getTransitionParameters({duration:0});i.updateTransitions(o),this.fire(new e.x("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0;}_createFog(e){const t=this.fog=new Ge(e,this.map.transform,this.scope,this.options);this.stylesheet.fog=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.bh(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;}setColorTheme(t){this._checkLoaded();const i=()=>{for(const e in this._layers)this._layers[e].lut=this._styleColorTheme.lut;for(const e in this._sourceCaches)this._sourceCaches[e].clearTiles();};if(this._styleColorTheme.colorTheme=t,!t)return this._styleColorTheme.lut=null,void i();const o=this._evaluateColorThemeData(t);this._loadColorTheme(o).then((()=>{this.fire(new e.x("colorthemeset")),i();})).catch((t=>{e.w(`Couldn't set color theme: ${t}`);}));}_getTransitionParameters(t){return {now:e.q.now(),transition:e.l(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 Pe(e,t,this.scope,this.options);1===t&&(this.stylesheet.terrain=e),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const o=this._getTransitionParameters({duration:0});i.updateTransitions(o);}_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,o,r,s={}){if(s&&!1===s.validate)return !1;const a=e.l({},this.serialize());return ro(this,t.call(fe,e.l({key:i,style:a,value:o,styleSpec:e._},r)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),e.cs.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.setEventedParent(null),delete this.fog,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.modelManager.setEventedParent(null),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();}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();}updateSources(e){let t;this.directionalLight&&(t=Qi(this.directionalLight));for(const i in this._mergedSourceCaches)this._mergedSourceCaches[i].update(e,void 0,void 0,t);}_generateCollisionBoxes(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload();}}_updatePlacement(t,i,o,r,s,a,n=!1){let l=!1,c=!1;const h={},u={};for(const t of this._mergedOrder){const o=this._mergedLayers[t];if("symbol"!==o.type)continue;const r=e.av(o.source,o.scope);let s=h[r];if(!s){const e=this.getLayerSourceCache(o);if(!e)continue;const t=e.getRenderableIds(!0).map((t=>e.getTileByID(t)));u[r]=t.slice(),s=h[r]=t.sort(((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)));}const a=this.crossTileSymbolIndex.addLayer(o,s,i.center.lng,i.projection);l=l||a;}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),n=n||this._layerOrderChanged||0===r,this._layerOrderChanged&&this.fire(new e.x("neworder")),(n||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.q.now(),i.zoom))&&(this.pauseablePlacement=new Ti(i,this._mergedOrder,n,o,r,s,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,h,u),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(e.q.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.t(new Error(`Import with id '${t.id}' already exists in the map's style.`)));if(!i)return o.push(t),this._loadImports([t],!0);const r=o.findIndex((({id:e})=>e===i));return -1===r&&this.fire(new e.t(new Error(`Import with id "${i}" does not exist on this map.`))),this.stylesheet.imports=o.slice(0,r).concat(t).concat(o.slice(r)),this._loadImports([t],!0,i)}updateImport(t,i){this._checkLoaded();const o=this.stylesheet.imports||[],r=this.getImportIndex(t);return -1===r?this:"string"==typeof i?(this.setImportUrl(t,i),this):(i.url&&i.url!==o[r].url&&this.setImportUrl(t,i.url),e.bh(i.config,o[r].config)||this.setImportConfig(t,i.config),e.bh(i.data,o[r].data)||this.setImportData(t,i.data),this)}moveImport(e,t){this._checkLoaded();let i=this.stylesheet.imports||[];const o=this.getImportIndex(e);if(-1===o)return this;const r=this.getImportIndex(t);if(-1===r)return this;const s=i[o],a=this.fragments[o];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(s).concat(i.slice(r)),this.fragments=this.fragments.slice(0,r).concat(a).concat(this.fragments.slice(r)),this.mergeLayers(),this}setImportUrl(e,t){this._checkLoaded();const i=this.stylesheet.imports||[],o=this.getImportIndex(e);if(-1===o)return this;i[o].url=t;const r=this.fragments[o];return r.style=this._createFragmentStyle(i[o]),r.style.on("style.import.load",(()=>this.mergeAll())),r.style.loadURL(t),this}setImportData(e,t){this._checkLoaded();const i=this.getImportIndex(e),o=this.stylesheet.imports||[];return -1===i?this:t?(this.fragments[i].style.setState(t),this._reloadImports(),this):(delete o[i].data,this.setImportUrl(e,o[i].url))}setImportConfig(e,t){this._checkLoaded();const i=this.getImportIndex(e),o=this.stylesheet.imports||[];if(-1===i)return this;t?o[i].config=t:delete o[i].config;const r=this.fragments[i],s=r.style.stylesheet&&r.style.stylesheet.schema;return r.config=t,r.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.t(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 o=e.av(t,i);return this._mergedOtherSourceCaches[o]}getLayerSourceCache(t){const i=e.av(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);}}getImages(e,t,i){this.imageManager.getImages(t.icons,t.scope,i),this._updateTilesForChangedImages();const o=e=>{e&&e.setDependencies(t.tileID.key,t.type,t.icons);};o(this._otherSourceCaches[t.source]),o(this._symbolSourceCaches[t.source]);}getGlyphs(e,t,i){this.glyphManager.getGlyphs(t.stacks,t.scope,i);}getResource(t,i,o){return e.ct(i,o)}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.t(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)return !1;const i="fill-extrusion"===e.type&&"building"===e.sourceLayer;if(e.is3D()){if(i||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);}}co.getSourceType=function(e){return et[e]},co.setSourceType=function(e,t){et[e]=t;},co.registerForPluginStateChange=e.cc;var ho="\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",uo="\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 vec2 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params;\n#endif\nvec4 applyCutout(vec4 color) {\n#ifdef INDICATOR_CUTOUT\nfloat holeMinOpacity=u_indicator_cutout_params.x;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);}vec3 applyLUT(highp sampler3D lut,vec3 col) {return applyLUT(lut,vec4(col,1.0)).rgb;}",_o="\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);}",po="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;}",mo="\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 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;int 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;highp 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",fo="#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",go="highp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}\n#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;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos,float opacity_limit) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,min(opacity,opacity_limit));}vec3 fog_apply(vec3 color,vec3 pos) {return fog_apply(color,pos,1.0);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec4 fog_apply_premultiplied(vec4 color,vec3 pos,float heightMeters) {float verticalProgress=(u_fog_vertical_limit.x > 0.0 || u_fog_vertical_limit.y > 0.0) ? smoothstep(u_fog_vertical_limit.x,u_fog_vertical_limit.y,heightMeters) : 0.0;float opacityLimit=1.0-smoothstep(0.9,1.0,fog_opacity(pos));return mix(fog_apply_premultiplied(color,pos),color,min(verticalProgress,opacityLimit));}vec3 fog_dither(vec3 color) {\n#ifdef FOG_DITHERING\nvec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);\n#else\nreturn color;\n#endif\n}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif",vo="#ifdef RASTER_ARRAY\nuniform 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",xo="#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;}",yo="#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",bo="#ifdef RENDER_SHADOWS\n#ifdef DEPTH_TEXTURE\nuniform highp sampler2D u_shadowmap_0;uniform highp sampler2D u_shadowmap_1;\n#else\nuniform sampler2D u_shadowmap_0;uniform sampler2D u_shadowmap_1;\n#endif\nuniform float u_shadow_intensity;uniform float u_shadow_map_resolution;uniform float u_shadow_texel_size;uniform highp vec3 u_shadow_normal_offset;uniform vec2 u_fade_range;uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_bias;highp float shadow_sample_1(highp vec2 uv,highp float compare) {highp float shadow_depth;\n#ifdef DEPTH_TEXTURE\nshadow_depth=texture(u_shadowmap_1,uv).r;\n#else\nshadow_depth=unpack_depth(texture(u_shadowmap_1,uv))*0.5+0.5;\n#endif\nreturn step(shadow_depth,compare);}highp float shadow_sample_0(highp vec2 uv,highp float compare) {highp float shadow_depth;\n#ifdef DEPTH_TEXTURE\nshadow_depth=texture(u_shadowmap_0,uv).r;\n#else\nshadow_depth=unpack_depth(texture(u_shadowmap_0,uv))*0.5+0.5;\n#endif\nreturn step(shadow_depth,compare);}float shadow_occlusion_1(highp vec4 pos,highp float bias) {highp vec2 uv=pos.xy;return shadow_sample_1(uv,pos.z-bias);}float shadow_occlusion_0(highp vec4 pos,highp float bias) {highp float compare0=pos.z-bias;\n#ifdef NATIVE\nhighp vec2 uv=pos.xy;highp vec4 samples=textureGather(u_shadowmap_0,uv,0);lowp vec4 stepSamples=step(samples,vec4(compare0));\n#else\nhighp vec2 uv00=pos.xy-vec2(0.5*u_shadow_texel_size);highp vec2 uv10=uv00+vec2(u_shadow_texel_size,0.0);highp vec2 uv01=uv00+vec2(0.0,u_shadow_texel_size);highp vec2 uv11=uv01+vec2(u_shadow_texel_size,0.0);lowp vec4 stepSamples=vec4(\nshadow_sample_0(uv01,compare0),shadow_sample_0(uv11,compare0),shadow_sample_0(uv10,compare0),shadow_sample_0(uv00,compare0)\n);\n#endif\nvec2 f=fract(pos.xy*u_shadow_map_resolution-vec2(0.5));lowp vec2 lerpx=mix(stepSamples.wx,stepSamples.zy,f.xx);return mix(lerpx.x,lerpx.y,f.y);}float shadow_occlusion(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,highp float bias) {\n#ifdef SHADOWS_SINGLE_CASCADE\nlight_view_pos0.xyz=light_view_pos0.xyz/light_view_pos0.w*0.5+0.5;return shadow_occlusion_0(light_view_pos0,bias);\n#else\nlight_view_pos0.xyz/=light_view_pos0.w;light_view_pos1.xyz/=light_view_pos1.w;vec4 uv=vec4(light_view_pos0.xy,light_view_pos1.xy);vec4 abs_bounds=abs(uv);if (abs_bounds.x < 1.0 && abs_bounds.y < 1.0) {light_view_pos0.xyz=light_view_pos0.xyz*0.5+0.5;return shadow_occlusion_0(light_view_pos0,bias);}if (abs_bounds.z >=1.0 || abs_bounds.w >=1.0) {return 0.0;}light_view_pos1.xyz=light_view_pos1.xyz*0.5+0.5;float occlusion1=shadow_occlusion_1(light_view_pos1,bias);return mix(occlusion1,0.0,smoothstep(u_fade_range.x,u_fade_range.y,view_depth));\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));}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 wo=[];Do(ho,wo),Do(_o,wo),Do(uo,wo);const To={"_prelude_fog.vertex.glsl":fo,"_prelude_terrain.vertex.glsl":mo,"_prelude_shadow.vertex.glsl":yo,"_prelude_fog.fragment.glsl":go,"_prelude_shadow.fragment.glsl":bo,"_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":vo,"_prelude_raster_particle.glsl":xo},Eo={};Ro("",mo),Ro(go,fo),Ro(bo,yo),Ro(vo,""),Ro(xo,"");const Co=Ro(uo,_o),So=ho;var Io={background:Ro('#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:Ro('#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}'),circle:Ro('#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 opacity_t=smoothstep((1.0-blur_positive)*antialiased_blur,blur_positive*antialiased_blur,extrude_length-1.0)-smoothstep(0.0,antialiasblur,extrude_length-1.0);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\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(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 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\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:Ro("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:Ro('#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(void) {\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:Ro("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:Ro("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;out 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));vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*(feature_elevation+terrain_elevation),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:Ro("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:Ro("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}'),fill:Ro('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nuniform float u_emissive_strength;void 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#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"\nin vec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_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;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillOutline:Ro('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin highp vec2 v_pos;uniform float u_emissive_strength;\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#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"\nin vec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;\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);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillOutlinePattern:Ro('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_emissive_strength;in highp vec2 v_pos;in highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\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 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*(alpha*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_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\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#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\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);v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillPattern:Ro('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;in highp vec2 v_pos;uniform float u_emissive_strength;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\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 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*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_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\nout highp vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\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\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;\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 FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillExtrusion:Ro('#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);\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"\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\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;\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() {\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 flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : 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);cutoff=cutoff_opacity(u_cutoff_params,ground.z);if (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);v_flat=vec4(linearProduct(color.rgb,vec3(calculate_NdotL(normal))),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:Ro("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}",'#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_width_scale;uniform float u_vertical_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#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() {\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 flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : 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:Ro('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\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\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#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#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 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);\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"\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\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 mediump vec4 pattern\n#pragma mapbox: define highp float pixel_ratio\n#pragma mapbox: define highp float line_width\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize mediump vec4 pattern\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 flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : 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);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:Ro('#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(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)).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:Ro("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:Ro("precision highp float;uniform 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:Ro('#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:Ro('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform lowp float u_device_pixel_ratio;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 vec4 v_uv;\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\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=(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;alpha*=linearstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/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 start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));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=out_color.a;}\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+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.rgb=mix(border_color.rgb*border_color.a*trim_alpha,out_color.rgb,smoothAlpha);}}\n#endif\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\nout_color*=(alpha*opacity);\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color);\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#define EXTRUDE_SCALE 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\nin float a_z_offset;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nin highp vec4 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;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec4 v_uv;\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#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 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=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*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);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);\n#ifdef ELEVATED_ROADS\ngl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset+0.01*step(0.01,a_z_offset),1.0)+projected_extrude;\n#else\n#ifdef ELEVATED\nvec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 halfCellProgress=normal.yx*32.0;float ele0=elevation(pos);float ele_line=max(ele0,max(elevation(pos+halfCellProgress),elevation(pos-halfCellProgress)));float ele1=elevation(pos+offsetTile);float ele2=elevation(pos-offsetTile);float ele_max=max(ele_line,0.5*(ele1+ele2));float ele=ele_max-ele0+ele1+a_z_offset ;gl_Position=u_matrix*vec4(pos+offsetTile,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)*0.1*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#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=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];\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=vec4(a_uv_x,a_split_index*texel_height-half_texel_height,a_clip_start,a_clip_end);\n#else\nv_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\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,(-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}'),linePattern:Ro('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform highp float u_device_pixel_ratio;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 sampler2D u_image;in 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 vec4 v_uv;\n#endif\n#ifdef LINE_JOIN_NONE\nin vec2 v_pattern_data;\n#endif\n#pragma mapbox: define mediump vec4 pattern\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#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;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=(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 RENDER_LINE_TRIM_OFFSET\nhighp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {color=vec4(0,0,0,0);}}\n#endif\n#ifdef LINE_JOIN_NONE\nfloat pattern_len=pattern_size/aspect;float segment_phase=pattern_len-mod(v_linesofar-v_pattern_data.x+pattern_len,pattern_len);float visible_start=segment_phase-step(pattern_len*0.5,segment_phase)*pattern_len;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_ground(color);\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);\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#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\nin float a_z_offset;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec4 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\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;out 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 vec4 v_uv;\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#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#pragma mapbox: initialize mediump float pixel_ratio\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=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);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);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);\n#ifdef ELEVATED_ROADS\ngl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset+0.01*step(0.01,a_z_offset),1.0)+projected_extrude;\n#else\n#ifdef ELEVATED\nvec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 halfCellProgress=normal.yx*32.0;float ele0=elevation(pos);float ele_line=max(ele0,max(elevation(pos+halfCellProgress),elevation(pos-halfCellProgress)));float ele1=elevation(pos+offsetTile);float ele2=elevation(pos-offsetTile);float ele_max=max(ele_line,0.5*(ele1+ele2));float ele=ele_max-ele0+ele1+a_z_offset ;gl_Position=u_matrix*vec4(pos+offsetTile,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)*0.1*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#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=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nfloat a_uv_x=a_packed[0];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];v_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;\n#ifdef LINE_JOIN_NONE\nv_width=floorwidth+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}'),raster:Ro('#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 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:Ro('#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),0.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:Ro("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:Ro("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:Ro('#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:Ro('#include "_prelude_lighting.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;\n#ifdef ICON_TRANSITION\nuniform float u_icon_transition;\n#endif\n#ifdef COLOR_ADJUSTMENT\nuniform mat4 u_color_adj_mat;\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#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*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/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 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#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\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\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_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#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);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 (!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 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\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\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+(u_elevation_from_sea ? z_offset : z_offset) : 0.0;\n#else\nz+=u_pitch_with_map ? (u_elevation_from_sea ? z_offset : z_offset) : 0.0;\n#endif\nfloat occlusion_fade=globe_occlusion_fade;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float out_fade_opacity=interpolated_fade_opacity*projection_transition_fade;\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\nfloat alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\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);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,hidden);\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\n#endif\nfloat 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}'),terrainRaster:Ro('#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;out float v_depth;\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:Ro("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:Ro('#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.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_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}',po),skyboxGradient:Ro('#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;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);glFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',po),skyboxCapture:Ro("\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:Ro('#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\nvec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);vec3 dir=normalize(ray_dir);vec3 closest_point=dot(u_globe_pos,dir)*dir;float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);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(raster.rgb*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:Ro('#include "_prelude_fog.fragment.glsl"\nuniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec4 u_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_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_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;\n#ifndef NATIVE\nc=dither(c,gl_FragCoord.xy+u_temporal_offset);\n#endif\nglFragColor=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:Ro('#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 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;highp 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=normalize(cross(fdx,fdy))*-1.0;\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);\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#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:Ro("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:Ro("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);}"),occlusion:Ro("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 Do(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 Ro(e,t){const i=/#include\s+"([^"]+)"/g,o=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g;let r=t.match(/(attribute(\S*)|(^\s*|;)in) (highp |mediump |lowp )?([\w]+) ([\w]+)/gm);r&&(r=r.map((e=>{const t=e.split(" ");return t[t.length-1]})),r=[...new Set(r)]);const s={},a=[],n=[];if(e=e.replace(i,((e,t)=>(n.push(t),""))),(t=t.replace(i,((e,t)=>(a.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 l=[...wo];Do(e,l),Do(t,l);for(const e of [...a,...n])To[e]||console.error(`Undefined include: ${e}`),Eo[e]||(Eo[e]=[],Do(To[e],Eo[e])),l=[...l,...Eo[e]];return {fragmentSource:e=e.replace(o,((e,t,i,o,r)=>(s[r]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nin ${i} ${o} ${r};\n#else\nuniform ${i} ${o} u_${r};\n#endif\n`:"initialize"===t?`\n#ifdef HAS_UNIFORM_u_${r}\n ${i} ${o} ${r} = u_${r};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${r}\n in ${i} ${o} ${r};\n#endif\n`:"initialize-attribute"===t?"":void 0))),vertexSource:t=t.replace(o,((e,t,i,o,r)=>{const a="float"===o?"vec2":o,n=r.match(/color/)?"color":a;return "define-attribute-vertex-shader-only"===t?`\n#ifdef HAS_ATTRIBUTE_a_${r}\nin ${i} ${o} a_${r};\n#endif\n`:s[r]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nuniform lowp float u_${r}_t;\nin ${i} ${a} a_${r};\nout ${i} ${o} ${r};\n#else\nuniform ${i} ${o} u_${r};\n#endif\n`:"initialize"===t?"vec4"===n?`\n#ifndef HAS_UNIFORM_u_${r}\n ${r} = a_${r};\n#else\n ${i} ${o} ${r} = u_${r};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${r}\n ${r} = unpack_mix_${n}(a_${r}, u_${r}_t);\n#else\n ${i} ${o} ${r} = u_${r};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${r}\n in ${i} ${o} a_${r};\n out ${i} ${o} ${r};\n#endif\n`:"initialize-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${r}\n ${r} = a_${r};\n#endif\n`:void 0:"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nuniform lowp float u_${r}_t;\nin ${i} ${a} a_${r};\n#else\nuniform ${i} ${o} u_${r};\n#endif\n`:"define-instanced"===t?"mat4"===n?`\n#ifdef INSTANCED_ARRAYS\nin vec4 a_${r}0;\nin vec4 a_${r}1;\nin vec4 a_${r}2;\nin vec4 a_${r}3;\n#else\nuniform ${i} ${o} u_${r};\n#endif\n`:`\n#ifdef INSTANCED_ARRAYS\nin ${i} ${a} a_${r};\n#else\nuniform ${i} ${o} u_${r};\n#endif\n`:"initialize-attribute-custom"===t?`\n#ifdef HAS_ATTRIBUTE_a_${r}\n ${i} ${o} ${r} = a_${r};\n#endif\n`:"vec4"===n?`\n#ifndef HAS_UNIFORM_u_${r}\n ${i} ${o} ${r} = a_${r};\n#else\n ${i} ${o} ${r} = u_${r};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${r}\n ${i} ${o} ${r} = unpack_mix_${n}(a_${r}, u_${r}_t);\n#else\n ${i} ${o} ${r} = u_${r};\n#endif\n`})),staticAttributes:r,usedDefines:l,vertexIncludes:a,fragmentIncludes:n}}class Ao{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null;}bind(e,t,i,o,r,s,a,n){this.context=e;let l=this.boundPaintVertexBuffers.length!==o.length;for(let e=0;!l&&e{const s=o.paint.get("hillshade-shadow-color"),a=o.paint.get("hillshade-highlight-color"),n=o.paint.get("hillshade-accent-color"),l=o.paint.get("hillshade-emissive-strength");let c=e.bB(o.paint.get("hillshade-illumination-direction"));if("viewport"===o.paint.get("hillshade-illumination-anchor"))c-=t.transform.angle;else if(t.style&&t.style.enable3dLights()&&t.style.directionalLight){const i=t.style.directionalLight.properties.get("direction"),o=e.c7(i.x,i.y,i.z);c=e.bB(o[1]);}const h=!t.options.moving;return {u_matrix:r||t.transform.calculateProjMatrix(i.tileID.toUnwrapped(),h),u_image:0,u_latrange:Lo(0,i.tileID),u_light:[o.paint.get("hillshade-exaggeration"),c],u_shadow:s.toRenderColor(o.lut),u_highlight:a.toRenderColor(o.lut),u_emissive_strength:l,u_accent:n.toRenderColor(o.lut)}})(t,o,r,t.terrain?i.projMatrix:null);t.uploadCommonUniforms(l,d,i.toUnwrapped());const{tileBoundsBuffer:p,tileBoundsIndexBuffer:m,tileBoundsSegments:f}=t.getTileBoundsBuffers(o);d.draw(t,c.TRIANGLES,s,a,n,Fi.disabled,_,r.id,p,m,f);}function Mo(t,i,o){if(!i.needsDEMTextureUpload)return;const r=t.context,s=r.gl;r.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||t.getTileTexture(o.stride);const a=o.getPixels();i.demTexture?i.demTexture.update(a,{premultiply:!1}):i.demTexture=new e.T(r,a,s.R32F,{premultiply:!1}),i.needsDEMTextureUpload=!1;}function zo(t,i,o){const r=t.context,s=r.gl;if(!i.dem)return;const a=i.dem;if(r.activeTexture.set(s.TEXTURE1),Mo(t,i,a),!i.demTexture)return;i.demTexture.bind(s.NEAREST,s.CLAMP_TO_EDGE);const n=a.dim;r.activeTexture.set(s.TEXTURE0);let l=i.hillshadeFBO;if(!l){const t=new e.T(r,{width:n,height:n,data:null},s.RGBA8);t.bind(s.LINEAR,s.CLAMP_TO_EDGE),l=i.hillshadeFBO=r.createFramebuffer(n,n,!0,"renderbuffer"),l.colorAttachment.set(t.texture);}r.bindFramebuffer.set(l.framebuffer),r.viewport.set([0,0,n,n]);const{tileBoundsBuffer:c,tileBoundsIndexBuffer:h,tileBoundsSegments:u}=t.getMercatorTileBoundsBuffers(),d=[];t.linearFloatFilteringSupported()&&d.push("TERRAIN_DEM_FLOAT_FORMAT"),t.getOrCreateProgram("hillshadePrepare",{defines:d}).draw(t,s.TRIANGLES,Li.disabled,Mi.disabled,Ai.unblended,Fi.disabled,((t,i)=>{const o=i.stride,r=e.a6.mat4.create();return e.a6.mat4.ortho(r,0,e.ab,-e.ab,0,0,1),e.a6.mat4.translate(r,r,[0,-e.ab,0]),{u_matrix:r,u_image:1,u_dimension:[o,o],u_zoom:t.overscaledZ}})(i.tileID,a),o.id,c,h,u),i.needsHillshadePrepare=!1;}class Oo{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 Fo extends Oo{getDefault(){return e.bz.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1);}}class ko extends Oo{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1);}}class Bo extends Oo{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1);}}class No extends Oo{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 Uo extends Oo{getDefault(){return !0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1);}}class Go extends Oo{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1);}}class jo extends Oo{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 Vo extends Oo{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 qo extends Oo{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1;}}class Zo extends Oo{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 Ho extends Oo{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 Wo extends Oo{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1);}}class $o extends Oo{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 Xo extends Oo{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 Yo extends Oo{getDefault(){return e.bz.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1);}}class Ko extends Oo{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 Jo extends Oo{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 Qo extends Oo{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1);}}class er extends Oo{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1);}}let tr=class extends Oo{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1);}};class ir extends Oo{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1);}}class or extends Oo{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 rr extends Oo{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 sr extends Oo{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 ar extends Oo{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 nr extends Oo{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 lr extends Oo{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1;}}class cr extends Oo{getDefault(){return null}set(e){this.gl&&(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1);}}class hr extends Oo{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 ur extends Oo{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 dr extends Oo{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 _r extends Oo{constructor(e,t){super(e),this.context=e,this.parent=t;}getDefault(){return null}}class pr extends _r{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 mr extends _r{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 fr extends _r{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 gr extends mr{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const vr=(e,t,i)=>({u_matrix:e,u_image0:0,u_skirt_height:t,u_ground_shadow_factor:i}),xr=(e,t,i,o,r,s,a,n,l,c,h,u,d,_,p,m)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(o),u_merc_matrix:i,u_zoom_transition:r,u_merc_center:s,u_image0:0,u_frustum_tl:a,u_frustum_tr:n,u_frustum_br:l,u_frustum_bl:c,u_globe_pos:h,u_globe_radius:u,u_viewport:d,u_grid_matrix:m?Float32Array.from(m):new Float32Array(9),u_skirt_height:_,u_far_z_cutoff:p});function yr(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const br=new class{constructor(){this.operations={};}newMorphing(e,t,i,o,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:o,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()}},wr={0:null,1:"TERRAIN_VERTEX_MORPHING"};function Tr(e,t,i){if(0===t)return 0;const o=t<1&&514===i?.25/t:1;return 6*Math.pow(1.5,22-e)*Math.max(t,1)*o}function Er(e,t){const i=1<({u_matrix:e});function Sr(t,i,o,r,s){if(s>0){const a=e.q.now(),n=(a-t.timeAdded)/s,l=i?(a-i.timeAdded)/s:-1,c=o.getSource(),h=r.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),u=!i||Math.abs(i.tileID.overscaledZ-h)>Math.abs(t.tileID.overscaledZ-h),d=u&&t.refreshedUponExpiration?1:e.ap(u?n:1-l,0,1);return t.refreshedUponExpiration&&n>=1&&(t.refreshedUponExpiration=!1),i?{opacity:1,mix:1-d}:{opacity:d,mix:0}}return {opacity:1,mix:0}}class Ir extends vt{constructor(t){const i={type:"raster-dem",maxzoom:t.transform.maxZoom},o=new e.cd(e.ce(),null),r=tt("mock-dem",i,o,t.style);super("mock-dem",r,!1),r.setEventedParent(this),this._sourceLoaded=!0;}_loadTile(e,t){e.state="loaded",t(null);}}class Dr extends vt{constructor(t){const i=tt("proxy",{type:"geojson",maxzoom:t.transform.maxZoom},new e.cd(e.ce(),null),t.style);super("proxy",i,!1),i.setEventedParent(this),this.map=this.getSource().map=t,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={};}update(e,t,i){if(e.freezeTileCoverage)return;this.transform=e;const o=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 pt(i,this._source.tileSize*i.overscaleFactor(),e.tileZoom);t.state="loaded",this._tiles[i.key]=t;}return t}),{});for(const e in this._tiles)e in o||(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 Rr extends e.aA{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 Ar extends e.cE{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[o,r,s]=function(t){const i=new e.a_,o=new e.aO,r=131;i.reserve(17161),o.reserve(33800);const s=e.ab/128,a=e.ab+s/2,n=a+s;for(let t=-s;ta||t<0||t>a?24575:0,s=e.ap(Math.round(o),0,e.ab),n=e.ap(Math.round(t),0,e.ab);i.emplaceBack(s+r,n);}const l=(e,t)=>{const i=t*r+e;o.emplaceBack(i+1,i,i+r),o.emplaceBack(i+r,i+r+1,i+1);};for(let e=1;e<129;e++)for(let t=1;t<129;t++)l(t,e);return [0,129].forEach((e=>{for(let t=0;t<130;t++)l(t,e),l(e,t);})),[i,o,32768]}(),a=t.context;this.gridBuffer=a.createVertexBuffer(o,e.b0.members),this.gridIndexBuffer=a.createIndexBuffer(r),this.gridSegments=e.b1.simpleSegment(0,0,o.length,r.length),this.gridNoSkirtSegments=e.b1.simpleSegment(0,0,o.length,s),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Dr(i.map),this.orthoMatrix=e.a6.mat4.create(),e.a6.mat4.ortho(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,e.ab,0,e.ab,0,1);const n=a.gl;this._overlapStencilMode=new Mi({func:n.GEQUAL,mask:255},0,255,n.KEEP,n.KEEP,n.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=i,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new Ir(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,o){if(t&&t.terrain){this._style!==t&&(this.style=t,this._evaluationZoom=void 0);const r=t.terrain.properties,s=0===t.terrain.drapeRenderMode,a=t.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=e.q.now();const n=t.terrain&&t.terrain.scope,l=r.get("source"),c=s?this._mockSourceCache:t.getSourceCache(l,n);if(!c)return void e.w(`Couldn't find terrain source "${l}".`);if(this.sourceCache=c,this._exaggeration=a?this.calculateExaggeration(i):r.get("exaggeration"),!i.projection.requiresDraping&&a&&0===this._exaggeration)return void this._disable();this.enabled=!0;const h=()=>{this.sourceCache.used&&e.w(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.\nThis leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const t=this.getScaledDemTileSize();this.sourceCache.update(i,t,!0),this.resetTileLookupCache(this.sourceCache.id);};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,h(),this._initializing=!0),h(),i.updateElevation(!0,o),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(i),this._emptyDEMTextureDirty=!0,this._previousZoom=i.zoom;}else this._disable();}calculateExaggeration(t){const i=this._previousCameraAltitude,o=t.getFreeCameraOptions().position.z/t.pixelsPerMeter*t.worldSize;this._previousCameraAltitude=o;const r=null!=i?o-i:Number.MAX_VALUE;if(Math.abs(r)<2)return this._exaggeration;const s=t.zoom,a=this._style.terrain;if(!this._previousUpdateTimestamp)return a.getExaggeration(s);let n=s-this._previousZoom;const l=this._previousUpdateTimestamp;let c=s;null!=this._evaluationZoom&&(c=this._evaluationZoom,Math.abs(s-c)>.5&&(n=.5*(s-c+n)),n*r<0&&(c+=n)),this._evaluationZoom=c;const h=a.getExaggeration(c),u=h===a.getExaggeration(Math.max(0,c-.1));if(u&&Math.abs(h-this._exaggeration)<.01)return h;let d=Math.min(.1,.00375*(this._updateTimestamp-l));return (u||h<.1||Math.abs(n)<1e-4)&&(d=Math.min(.2,4*d)),e.aa(this._exaggeration,h,d)}resetTileLookupCache(e){this._findCoveringTileCache[e]={};}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(e){e.coord&&"source"===e.dataType?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,o=this.painter.transform;this._initializing&&(this._initializing=0===o._centerAltitude&&-1===this.getAtPointOrZero(e.a5.fromLngLat(o.center),-1),this._emptyDEMTextureDirty=!this._initializing);const r=this.proxyCoords=i.getIds().map((e=>{const t=i.getTileByID(e).tileID;return t.projMatrix=o.calculateProjMatrix(t.toUnwrapped()),t}));!function(t,i){const o=i.transform.pointCoordinate(i.transform.getCameraPoint()),r=new e.P(o.x,o.y);t.sort(((t,i)=>{if(i.overscaledZ-t.overscaledZ)return i.overscaledZ-t.overscaledZ;const o=new e.P(t.canonical.x+(1<{this.proxyToSource[e.key]={};})),this.terrainTileForTile={};const a=this._style._mergedSourceCaches;for(const e in a){const i=a[e];if(!i.used)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,t[e],s),i.usedForTerrain)continue;const o=t[e];i.getSource().reparseOverscaled&&this._assignTerrainTiles(o);}this.proxiedCoords[i.id]=r.map((e=>new Rr(e,e.key,this.orthoMatrix))),this._assignTerrainTiles(r),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(s),this.renderingToTexture=!1;const n={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const i=t.tileID.key;i in n||(this._visibleDemTiles.push(t),n[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 o=this.terrainTileForTile[i],r=o.dem;!r||o.demTexture&&!o.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),Mo(this.painter,o,r));}}_prepareDemTileUniforms(e,t,i,o){if(!t||null==t.demTexture)return !1;const r=e.tileID.canonical,s=Math.pow(2,t.tileID.canonical.z-r.z),a=o||"";return i[`u_dem_tl${a}`]=[r.x*s%1,r.y*s%1],i[`u_dem_scale${a}`]=s,!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 o=i.dem.tree.minimums[0];return o>0&&e++,t+o}),0);return e?t/e:0}_updateEmptyDEMTexture(){const t=this.painter.context,i=t.gl;t.activeTexture.set(i.TEXTURE2);const o=this._getLoadedAreaMinimum(),r=new e.cF({width:1,height:1},new Float32Array([o]));this._emptyDEMTextureDirty=!1;let s=this._emptyDEMTexture;return s?s.update(r,{premultiply:!1}):s=this._emptyDEMTexture=new e.T(t,r,i.R32F,{premultiply:!1}),s}setupElevationDraw(t,i,o){const r=this.painter.context,s=r.gl,a={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};a.u_exaggeration=this.exaggeration();let n=null,l=null,c=1;if(o&&o.morphing&&this._useVertexMorphing){const e=o.morphing.srcDemTile,i=o.morphing.dstDemTile;c=o.morphing.phase,e&&i&&(this._prepareDemTileUniforms(t,e,a,"_prev")&&(l=e),this._prepareDemTileUniforms(t,i,a)&&(n=i));}const h=e=>e&&e.demTexture&&this.painter.linearFloatFilteringSupported()?s.LINEAR:s.NEAREST;let u=null;var d;if(this.enabled?l&&n?(u=n.demTexture,r.activeTexture.set(s.TEXTURE4),l.demTexture.bind(h(l),s.CLAMP_TO_EDGE),a.u_dem_lerp=c):(n=this.terrainTileForTile[t.tileID.key],u=this._prepareDemTileUniforms(t,n,a)?n.demTexture:this.emptyDEMTexture):u=this.emptyDEMTexture,r.activeTexture.set(s.TEXTURE2),u&&(a.u_dem_size=1===(d=u).size[0]?1:d.size[0]-2,u.bind(h(n),s.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(o&&o.useDepthForOcclusion,i,a),o&&o.useMeterToDem&&n){const t=(1<{if(c===i)return;const o=[wr[i],"PROJECTION_GLOBE_VIEW"];u&&o.push("CUSTOM_ANTIALIASING");const r=t.isTileAffectedByFog(e);l=t.getOrCreateProgram("globeRaster",{defines:o,overrideFog:r}),c=i;},_=t.colorModeForRenderPass(),p=new Li(n.LEQUAL,Li.ReadWrite,t.depthRangeFor3D);br.update(s);const m=e.cy(h),f=[e.am(h.center.lng),e.at(h.center.lat)],g=t.globeSharedBuffers,v=[h.width*e.q.devicePixelRatio,h.height*e.q.devicePixelRatio],x=Float32Array.from(h.globeMatrix),y={useDenormalizedUpVectorScale:!0};{const h=t.transform,u=Tr(h.zoom,i.exaggeration(),i.sourceCache._source.tileSize);c=-1;const b=n.TRIANGLES;for(const c of r){const r=o.getTile(c),w=Mi.disabled,T=i.prevTerrainTileForTile[c.key],E=i.terrainTileForTile[c.key];yr(T,E)&&br.newMorphing(c.key,T,E,s,250),a.activeTexture.set(n.TEXTURE0),r.texture&&r.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE);const C=br.getMorphValuesForProxy(c.key),S=C?1:0;C&&e.C(y,{morphing:{srcDemTile:C.from,dstDemTile:C.to,phase:e.cw(C.phase)}});const I=e.cz(c.canonical),D=e.cA(I.getCenter().lat),R=e.cB(c.canonical,I,D,h.worldSize/h._pixelsPerMercatorPixel),A=e.b5(e.cC(c.canonical)),L=xr(h.expandedFarZProjMatrix,x,m,A,e.a9(h.zoom),f,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,v,u,h._farZ,R);if(d(c,S),l&&(i.setupElevationDraw(r,l,y),t.uploadCommonUniforms(a,l,c.toUnwrapped()),g)){const[e,i,o]=g.getGridBuffers(D,0!==u);l.draw(t,b,p,w,_,Fi.backCCW,L,"globe_raster",e,i,o);}}}if(g&&(t.renderDefaultNorthPole||t.renderDefaultSouthPole)){const s=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];u&&s.push("CUSTOM_ANTIALIASING"),l=t.getOrCreateProgram("globeRaster",{defines:s});for(const s of r){const{x:r,y:c,z:u}=s.canonical,d=0===c,m=c===(1<e.draw(t,n.TRIANGLES,p,Mi.disabled,_,Fi.disabled,xr(h.expandedFarZProjMatrix,g,g,E,0,f,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,v,0,h._farZ),"globe_pole_raster",i,w,T);i.setupElevationDraw(c,l,y),t.uploadCommonUniforms(a,l,s.toUnwrapped()),d&&t.renderDefaultNorthPole&&C(l,x),m&&t.renderDefaultSouthPole&&(g=e.a6.mat4.scale(e.a6.mat4.create(),g,[1,-1,1]),C(l,b));}}}}(t,i,o,r,s);else {const a=t.context,n=a.gl;let l,c;const h=t.shadowRenderer,u=Wi(t,t.longestCutoffRange),d=e=>{if(c===e)return;const i=[];i.push(wr[e]),u.shouldRenderCutoff&&i.push("RENDER_CUTOFF"),l=t.getOrCreateProgram("terrainRaster",{defines:i}),c=e;},_=t.colorModeForRenderPass(),p=new Li(n.LEQUAL,Li.ReadWrite,t.depthRangeFor3D);br.update(s);const m=t.transform,f=Tr(m.zoom,i.exaggeration(),i.sourceCache._source.tileSize);let g=[0,0,0];if(h){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(g=eo(t.style,e,i));}{c=-1;const v=n.TRIANGLES,[x,y]=[i.gridIndexBuffer,i.gridSegments];for(const c of r){const r=o.getTile(c),b=Mi.disabled,w=i.prevTerrainTileForTile[c.key],T=i.terrainTileForTile[c.key];yr(w,T)&&br.newMorphing(c.key,w,T,s,250),a.activeTexture.set(n.TEXTURE0),r.texture&&r.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE);const E=br.getMorphValuesForProxy(c.key),C=E?1:0;let S;E&&(S={morphing:{srcDemTile:E.from,dstDemTile:E.to,phase:e.cw(E.phase)}});const I=vr(c.projMatrix,Er(c.canonical,m.renderWorldCopies)?f/10:f,g);if(d(C),!l)continue;i.setupElevationDraw(r,l,S);const D=c.toUnwrapped();h&&h.setupShadows(D,l),t.uploadCommonUniforms(a,l,D,null,u),l.draw(t,v,p,b,_,Fi.backCCW,I,"terrain_raster",i.gridBuffer,x,y);}}}}(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,o=this.painter.context,r=this.proxySourceCache,s=this.proxiedCoords[r.id],a=this._drapedRenderBatches.shift(),n=i.style.order,l=[];let c=0;for(const h of s){const s=r.getTileByID(h.proxyTileKey),u=r.proxyCachedFBO[h.key]?r.proxyCachedFBO[h.key][t]:void 0,d=void 0!==u?r.renderCache[u]:this.pool[c++],_=void 0!==u;if(s.texture=d.tex,_&&!d.dirty){l.push(s.tileID);continue}let p;o.bindFramebuffer.set(d.fb.framebuffer),this.renderedToTile=!1,d.dirty&&(o.clear({color:e.bz.transparent,stencil:0}),d.dirty=!1);for(let e=a.start;e<=a.end;++e){const t=i.style._mergedLayers[n[e]];if(t.isHidden(i.transform.zoom))continue;const r=i.style.getLayerSourceCache(t),s=r?this.proxyToSource[h.key][r.id]:[h];if(!s)continue;const a=s;o.viewport.set([0,0,d.fb.width,d.fb.height]),p!==(r?r.id:null)&&(this._setupStencil(d,s,t,r),p=r?r.id:null),i.renderLayer(i,r,t,a);}if(0===this._drapedRenderBatches.length)for(const e of this._pendingGroundEffectLayers){const t=i.style._mergedLayers[n[e]];if(t.isHidden(i.transform.zoom))continue;const r=i.style.getLayerSourceCache(t),s=r?this.proxyToSource[h.key][r.id]:[h];if(!s)continue;const a=s;o.viewport.set([0,0,d.fb.width,d.fb.height]),p!==(r?r.id:null)&&(this._setupStencil(d,s,t,r),p=r?r.id:null),i.renderLayer(i,r,t,a);}this.renderedToTile?(d.dirty=!0,l.push(s.tileID)):_||--c,5===c&&(c=0,this.renderToBackBuffer(l));}return this.renderToBackBuffer(l),this.renderingToTexture=!1,o.bindFramebuffer.set(null),o.viewport.set([0,0,i.width,i.height]),a.end+1}postRender(){}isLayerOrderingCorrect(e){const t=e.order.length;let i=-1,o=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 o=this._visibleDemTiles.filter((e=>e.dem)).map((o=>{const r=o.tileID,s=1<(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE)));for(const r of o){if(null==r.t)return null;const o=r.tile.dem.tree.raycast(r.minx,r.miny,r.maxx,r.maxy,e,t,i);if(null!=o)return o}return null}_createFBO(){const t=this.painter.context,i=t.gl,o=this.drapeBufferSize;t.activeTexture.set(i.TEXTURE0);const r=new e.T(t,{width:o[0],height:o[1],data:null},i.RGBA8);r.bind(i.LINEAR,i.CLAMP_TO_EDGE);const s=t.createFramebuffer(o[0],o[1],!0,null);return s.colorAttachment.set(r.texture),s.depthAttachment=new gr(t,s.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,o[0],o[1]),this._stencilRef=0,s.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):s.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&i.texParameterf(i.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.extTextureFilterAnisotropicMax),{fb:s,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 Ke){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=o;}_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 s=i[r];if(t.getTileByID(s.key),void 0!==t.proxyCachedFBO[s.key]){const i=e[s.key],r=this.proxyToSource[s.key];let a=0;for(const e in r){const t=r[e],s=i[e];if(!s||s.length!==t.length||t.some(((t,i)=>t!==s[i]||o[e]&&o[e].hasOwnProperty(t.key)))){a=-1;break}++a;}for(const e in t.proxyCachedFBO[s.key])t.renderCache[t.proxyCachedFBO[s.key][e]].dirty=a<0||a!==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 o of i){if(t.proxyCachedFBO[o.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[o.key]={},t.proxyCachedFBO[o.key][e.start]=i,t.renderCache[i].dirty=!0);}this._tilesDirty={};}_setupStencil(e,t,i,o){if(!o||!this._sourceTilesOverlap[o.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const r=this.painter.context,s=r.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let a;if(i.isTileClipped())a=t.length,this._overlapStencilMode.test={func:s.EQUAL,mask:255},this._overlapStencilType="Clip";else {if(!(t[0].overscaledZ>t[t.length-1].overscaledZ))return void(this._overlapStencilType=!1);a=1,this._overlapStencilMode.test={func:s.GREATER,mask:255},this._overlapStencilType="Mask";}this._stencilRef+a>255&&(r.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=a,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):Mi.disabled}_renderTileClippingMasks(e,t){const i=this.painter,o=this.painter.context,r=o.gl;i._tileClippingMaskIDs={},o.setColorMode(Ai.disabled),o.setDepthMode(Li.disabled);const s=i.getOrCreateProgram("clippingMask");for(const o of e){const e=i._tileClippingMaskIDs[o.key]=--t;s.draw(i,r.TRIANGLES,Li.disabled,new Mi({func:r.ALWAYS,mask:0},e,255,r.KEEP,r.KEEP,r.REPLACE),Ai.disabled,Fi.disabled,Cr(o.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 o=[t.x,t.y,1,1];e.a6.vec4.transformMat4(o,o,i.pixelMatrixInverse),e.a6.vec4.scale(o,o,1/o[3]),o[0]/=i.worldSize,o[1]/=i.worldSize;const r=i._camera.position,s=e.bD(1,i.center.lat),a=[r[0],r[1],r[2]/s,0],n=e.a6.vec3.subtract([],o.slice(0,3),a);e.a6.vec3.normalize(n,n);const l=this.raycast(a,n,this._exaggeration);return null!==l&&l?(e.a6.vec3.scaleAndAdd(a,a,n,l),a[3]=a[2],a[2]*=s,a):null}_setupProxiedCoordsForOrtho(t,i,o){if(t.getSource()instanceof e.aD)return this._setupProxiedCoordsForImageSource(t,i,o);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};const r=this.proxiedCoords[t.id]=[],s=this.proxyCoords;for(let e=0;et.overscaledZ-e.overscaledZ));}_setupProxiedCoordsForImageSource(t,i,o){if(!t.getSource().loaded())return;const r=this.proxiedCoords[t.id]=[],s=this.proxyCoords,a=t.getSource(),n=a.tileID;if(!n)return;const l=new e.P(n.x,n.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)}),h=(t,i)=>{const o=t.wrap+t.canonical.x/(1<a+c.max.x||r+sn+c.max.y};for(let e=0;ee.key===i.tileID.key));if(e)return e}if(i.tileID.key!==t.key){const o=t.canonical.z-i.tileID.canonical.z;let s,a,n;r=e.a6.mat4.create();const l=i.tileID.wrap-t.wrap<0?(s=e.ab>>o,a=s*((i.tileID.canonical.x<=r){const o=t.canonical.z-r;i.getSource().reparseOverscaled?(n=Math.max(t.canonical.z+2,i.transform.tileZoom),a=new e.aA(n,t.wrap,r,t.canonical.x>>o,t.canonical.y>>o)):0!==o&&(n=r,a=new e.aA(n,t.wrap,r,t.canonical.x>>o,t.canonical.y>>o));}a.key!==t.key&&(c.push(a.key),o=i.getTile(a));}const h=e=>{c.forEach((t=>{r[t]=e;})),c.length=0;};for(n-=1;n>=l&&(!o||!o.hasData());n--){o&&h(o.tileID.key);const e=a.calculateScaledKey(n);if(o=i.getTileByID(e),o&&o.hasData())break;const t=r[e];if(null===t)break;void 0===t?c.push(e):o=i.getTileByID(t);}return h(o?o.tileID.key:null),o&&o.hasData()?o: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 Lr(t,i,o){const r=function(t,i,o){const r=e.a6.vec3.dot(i,t),s=e.a6.vec3.dot(o,[.2126,.7152,.0722]),a=(e,t,i)=>(1-i)*e+i*t,n=a(1-.3*Math.min(s,1),1,Math.min(r+1,1));return a(.92,1,Math.asin(e.ap(i[2],-1,1))/Math.PI+.5)*n}(t,[0,0,1],i),s=[0,0,0];e.a6.vec3.scale(s,o.slice(0,3),r);const a=[0,0,0];e.a6.vec3.scale(a,i.slice(0,3),t[2]);const n=[0,0,0];return e.a6.vec3.add(n,s,a),e.cb(n)}const Pr=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],Mr=["stars","fillExtrusion","fillExtrusionGroundEffect","model","symbol"];class zr{static cacheKey(e,t,i,o){let r=`${t}${o?o.cacheKey:""}`;for(const t of i)e.usedDefines.includes(t)&&(r+=`/${t}`);return r}constructor(t,i,o,r,s,a){const n=t.gl;this.program=n.createProgram(),this.configuration=r,this.name=i,this.fixedDefines=[...a];const l=r?r.getBinderAttributes():[],c=(o.staticAttributes||[]).concat(l);let h=r?r.defines():[];h=h.concat(a.map((e=>`#define ${e}`)));const u="#version 300 es\n";let d=u+h.concat("precision mediump float;",So,Co.fragmentSource).join("\n");for(const e of o.fragmentIncludes)d+=`\n${To[e]}`;d+=`\n${o.fragmentSource}`;let _=u+h.concat("precision highp float;",So,Co.vertexSource).join("\n");for(const e of o.vertexIncludes)_+=`\n${To[e]}`;_+=`\n${o.vertexSource}`;const p=n.createShader(n.FRAGMENT_SHADER);if(n.isContextLost())return void(this.failedToCreate=!0);n.shaderSource(p,d),n.compileShader(p),n.attachShader(this.program,p);const m=n.createShader(n.VERTEX_SHADER);if(n.isContextLost())this.failedToCreate=!0;else {n.shaderSource(m,_),n.compileShader(m),n.attachShader(this.program,m),this.attributes={},this.numAttributes=c.length;for(let e=0;e({u_dem:new e.bJ(t),u_dem_prev:new e.bJ(t),u_dem_tl:new e.bG(t),u_dem_scale:new e.bI(t),u_dem_tl_prev:new e.bG(t),u_dem_scale_prev:new e.bI(t),u_dem_size:new e.bI(t),u_dem_lerp:new e.bI(t),u_exaggeration:new e.bI(t),u_depth:new e.bJ(t),u_depth_size_inv:new e.bG(t),u_depth_range_unpack:new e.bG(t),u_occluder_half_size:new e.bI(t),u_occlusion_depth_offset:new e.bI(t),u_meter_to_dem:new e.bI(t),u_label_plane_matrix_inv:new e.bF(t)}))(t)),a.includes("GLOBE")&&(this.globeUniforms=(t=>({u_tile_tl_up:new e.bH(t),u_tile_tr_up:new e.bH(t),u_tile_br_up:new e.bH(t),u_tile_bl_up:new e.bH(t),u_tile_up_scale:new e.bI(t)}))(t)),a.includes("FOG")&&(this.fogUniforms=(t=>({u_fog_matrix:new e.bF(t),u_fog_range:new e.bG(t),u_fog_color:new e.c6(t),u_fog_horizon_blend:new e.bI(t),u_fog_vertical_limit:new e.bG(t),u_fog_temporal_offset:new e.bI(t),u_frustum_tl:new e.bH(t),u_frustum_tr:new e.bH(t),u_frustum_br:new e.bH(t),u_frustum_bl:new e.bH(t),u_globe_pos:new e.bH(t),u_globe_radius:new e.bI(t),u_globe_transition:new e.bI(t),u_is_globe:new e.bJ(t),u_viewport:new e.bG(t)}))(t)),a.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(t=>({u_cutoff_params:new e.c6(t)}))(t)),a.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(t=>({u_lighting_ambient_color:new e.bH(t),u_lighting_directional_dir:new e.bH(t),u_lighting_directional_color:new e.bH(t),u_ground_radiance:new e.bH(t)}))(t)),a.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(t=>({u_light_matrix_0:new e.bF(t),u_light_matrix_1:new e.bF(t),u_fade_range:new e.bG(t),u_shadow_normal_offset:new e.bH(t),u_shadow_intensity:new e.bI(t),u_shadow_texel_size:new e.bI(t),u_shadow_map_resolution:new e.bI(t),u_shadow_direction:new e.bH(t),u_shadow_bias:new e.bH(t),u_shadowmap_0:new e.bJ(t),u_shadowmap_1:new e.bJ(t)}))(t));}}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,o,r,s,a,n,l,c,h){const u=t.options.wireframe;if(!1===u.terrain&&!1===u.layers2D&&!1===u.layers3D)return;const d=t.context;if(!(()=>!(!u.terrain||"terrainRaster"!==this.name&&"globeRaster"!==this.name)||!(!u.layers2D||t._terrain&&t._terrain.renderingToTexture||!Pr.includes(this.name))||!(!u.layers3D||!Mr.includes(this.name)))())return;const _=d.gl,p=t.wireframeDebugCache.getLinesFromTrianglesBuffer(t.frameCounter,s,d);if(!p)return;const m=[...this.fixedDefines];m.push("DEBUG_WIREFRAME");const f=t.getOrCreateProgram(this.name,{config:this.configuration,defines:m});d.program.set(f.program);const g=(e,t,i)=>{if(t[e]&&i[e])for(const o in t[e])i[e][o]&&i[e][o].set(i.program,o,t[e][o].current);};c&&c.setUniforms(f.program,d,f.binderUniforms,n,{zoom:l}),g("fixedUniforms",this,f),g("terrainUniforms",this,f),g("globeUniforms",this,f),g("fogUniforms",this,f),g("lightsUniforms",this,f),g("shadowUniforms",this,f),p.bind(),d.setColorMode(new Ai([_.ONE,_.ONE_MINUS_SRC_ALPHA,_.ZERO,_.ONE],e.bz.transparent,[!0,!0,!0,!1])),d.setDepthMode(new Li(i.func===_.LESS?_.LEQUAL:i.func,Li.ReadOnly,i.range)),d.setStencilMode(Mi.disabled);const v=3*a.primitiveLength*2,x=3*a.primitiveOffset*2*2;h&&h>1?_.drawElementsInstanced(_.LINES,v,_.UNSIGNED_SHORT,x,h):_.drawElements(_.LINES,v,_.UNSIGNED_SHORT,x),s.bind(),d.program.set(this.program),d.setDepthMode(i),d.setStencilMode(o),d.setColorMode(r);}draw(e,t,i,o,r,s,a,n,l,c,h,u,d,_,p,m){const f=e.context,g=f.gl;if(this.failedToCreate)return;f.program.set(this.program),f.setDepthMode(i),f.setStencilMode(o),f.setColorMode(r),f.setCullFace(s);for(const e of Object.keys(this.fixedUniforms))this.fixedUniforms[e].set(this.program,e,a[e]);_&&_.setUniforms(this.program,f,this.binderUniforms,u,{zoom:d});const v={[g.POINTS]:1,[g.LINES]:2,[g.TRIANGLES]:3,[g.LINE_STRIP]:1}[t],x=m&&m>0?1:void 0;for(const s of h.get()){const a=s.vaos||(s.vaos={});(a[n]||(a[n]=new Ao)).bind(f,this,l,_?_.getPaintVertexBuffers():[],c,s.vertexOffset,p||[],x),m&&m>1?g.drawElementsInstanced(t,s.primitiveLength*v,g.UNSIGNED_SHORT,s.primitiveOffset*v*2,m):c?g.drawElements(t,s.primitiveLength*v,g.UNSIGNED_SHORT,s.primitiveOffset*v*2):g.drawArrays(t,s.vertexOffset,s.vertexLength),t===g.TRIANGLES&&c&&this._drawDebugWireframe(e,i,o,r,c,s,u,d,_,m);}}}function Or(t,i){const o=Math.pow(2,i.tileID.overscaledZ),r=i.tileSize*Math.pow(2,t.transform.tileZoom)/o,s=r*(i.tileID.canonical.x+i.tileID.wrap*o),a=r*i.tileID.canonical.y;return {u_image:0,u_texsize:i.imageAtlasTexture?i.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/e.ak(i,1,t.transform.tileZoom),u_pixel_coord_upper:[s>>16,a>>16],u_pixel_coord_lower:[65535&s,65535&a]}}const Fr=e.a6.mat4.create(),kr=(t,i,o,r,s,a,n,l,c,h,u,d,_,p,m,f)=>{const g=i.style.light,v=g.properties.get("position"),x=[v.x,v.y,v.z],y=e.a6.mat3.create();"viewport"===g.properties.get("anchor")&&(e.a6.mat3.fromRotation(y,-i.transform.angle),e.a6.vec3.transformMat3(x,x,y));const b=g.properties.get("color"),w=i.transform,T={u_matrix:t,u_lightpos:x,u_lightintensity:g.properties.get("intensity"),u_lightcolor:[b.r,b.g,b.b],u_vertical_gradient:+o,u_opacity:r,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Fr,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:s,u_edge_radius:a,u_width_scale:n,u_flood_light_color:_,u_vertical_scale:p,u_flood_light_intensity:m,u_ground_shadow_factor:f};return "globe"===w.projection.name&&(T.u_tile_id=[l.canonical.x,l.canonical.y,1<({u_matrix:e,u_edge_radius:t,u_width_scale:i,u_vertical_scale:o}),Nr=(t,i,o,r,s,a,n,l,c,h,u,d,_,p,m)=>{const f=kr(t,i,o,r,s,a,n,l,h,u,d,_,p,m,1,[0,0,0]),g={u_height_factor:-Math.pow(2,l.overscaledZ)/c.tileSize/8};return e.l(f,Or(i,c),g)},Ur=(e,t)=>({u_matrix:e,u_emissive_strength:t}),Gr=(t,i,o,r)=>e.l(Ur(t,i),Or(o,r)),jr=(e,t,i)=>({u_matrix:e,u_world:i,u_emissive_strength:t}),Vr=(t,i,o,r,s)=>e.l(Gr(t,i,o,r),{u_world:s}),qr=(t,i,o,r)=>{const s=e.ab/o.tileSize;return {u_matrix:t,u_camera_to_center_distance:i.getCameraToCenterDistance(r),u_extrude_scale:[i.pixelsToGLUnits[0]/s,i.pixelsToGLUnits[1]/s]}},Zr=(e,t,i=1)=>({u_matrix:e,u_color:t.toRenderColor(null),u_overlay:0,u_overlay_scale:i}),Hr=e.a6.mat4.create(),Wr=(t,i,o,r,s,a,n)=>{const l=t.transform,c="globe"===l.projection.name,h=c?e.cI(l.zoom,i.canonical)*l._pixelsPerMercatorPixel:e.ak(o,1,a),u={u_matrix:i.projMatrix,u_extrude_scale:h,u_intensity:n,u_inv_rot_matrix:Hr,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(c){u.u_inv_rot_matrix=r,u.u_merc_center=s,u.u_tile_id=[i.canonical.x,i.canonical.y,1<({u_matrix:t,u_normalize_matrix:i,u_globe_matrix:o,u_merc_matrix:r,u_grid_matrix:s,u_tl_parent:a,u_scale_parent:h,u_fade_t:u.mix,u_opacity:u.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.cJ(d.paint.get("raster-saturation")),u_contrast_factor:e.cK(d.paint.get("raster-contrast")),u_spin_weights:Kr(d.paint.get("raster-hue-rotate")),u_perspective_transform:_,u_raster_elevation:p,u_zoom_transition:n,u_merc_center:l,u_cutoff_params:c,u_colorization_mix:$r(e.cL,f,v),u_colorization_offset:Xr(e.cL,g,v),u_color_ramp:m,u_texture_offset:[y/(x+2*y),x/(x+2*y)],u_texture_res:[x+2*y,x+2*y],u_emissive_strength:b});function Kr(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 Jr=.05,Qr=(e,t,i,o,r,s,a,n,l,c,h,u)=>({u_matrix:e,u_normalize_matrix:t,u_globe_matrix:i,u_merc_matrix:o,u_grid_matrix:r,u_tl_parent:s,u_scale_parent:c,u_fade_t:h.mix,u_opacity:h.opacity,u_image0:0,u_image1:1,u_raster_elevation:u,u_zoom_transition:a,u_merc_center:n,u_cutoff_params:l}),es=(e,t,i,o,r,s,a,n,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_tile_offset:i,u_velocity:o,u_color_ramp:s,u_velocity_res:r,u_max_speed:a,u_uv_offset:n,u_data_scale:[255*l[0],255*l[1]],u_data_offset:c,u_particle_pos_scale:1.1,u_particle_pos_offset:[Jr,Jr]}),ts=(e,t,i,o,r,s,a,n,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_velocity:i,u_velocity_res:o,u_max_speed:r,u_speed_factor:s,u_reset_rate:a,u_rand_seed:Math.random(),u_uv_offset:n,u_data_scale:[255*l[0],255*l[1]],u_data_offset:c,u_particle_pos_scale:1.1,u_particle_pos_offset:[Jr,Jr]}),is=e.a6.mat4.create(),os=(t,i,o,r,s,a,n,l,c,h,u,d,_,p,m,f,g,v,x,y,b)=>{const w=s.transform,T={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:w.getCameraToCenterDistance(x),u_rotate_symbol:+o,u_aspect_ratio:w.width/w.height,u_fade_change:s.options.fadeDuration?s.symbolFadeChange:1,u_matrix:a,u_label_plane_matrix:n,u_coord_matrix:l,u_is_text:+h,u_elevation_from_sea:c?1:0,u_pitch_with_map:+r,u_texsize:u,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:is,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:is,u_up_vector:[0,-1,0],u_color_adj_mat:y,u_icon_transition:b||0,u_gamma_scale:r?s.transform.getCameraToCenterDistance(x)*Math.cos(s.terrain?0:s.transform._pitch):1,u_device_pixel_ratio:e.q.devicePixelRatio,u_is_halo:+_};return "globe"===x.name&&(T.u_tile_id=[p.canonical.x,p.canonical.y,1<({u_matrix:e,u_emissive_strength:t,u_opacity:i,u_color:o}),ss=(t,i,o,r,s,a,n,l,c)=>e.l(function(t,i,o,r,s,a){const{width:n,height:l}=r.imageManager.getPixelSize(i),c=Math.pow(2,a.tileID.overscaledZ),h=a.tileSize*Math.pow(2,r.transform.tileZoom)/c,u=h*(a.tileID.canonical.x+a.tileID.wrap*c),d=h*a.tileID.canonical.y;return {u_image:0,u_pattern_tl:o.tl,u_pattern_br:o.br,u_texsize:[n,l],u_pattern_size:o.displaySize,u_pattern_units_to_pixels:s?[r.transform.width,-1*r.transform.height]:[1/e.ak(a,1,r.transform.tileZoom),1/e.ak(a,1,r.transform.tileZoom)],u_pixel_coord_upper:[u>>16,d>>16],u_pixel_coord_lower:[65535&u,65535&d]}}(0,a,n,r,l,c),{u_matrix:t,u_emissive_strength:i,u_opacity:o}),as=new Float32Array(e.a6.mat4.identity([])),ns=(t,i,o,r,s,a,n,l,c,h,u,d,_,p=[0,0,0],m)=>{const f=s.style.light,g=f.properties.get("position"),v=[-g.x,-g.y,g.z],x=e.a6.mat3.create();"viewport"===f.properties.get("anchor")&&(e.a6.mat3.fromRotation(x,-s.transform.angle),e.a6.vec3.transformMat3(v,v,x));const y="MASK"===u.alphaMode,b=f.properties.get("color").toRenderColor(null),w=_.paint.get("model-ambient-occlusion-intensity"),T=_.paint.get("model-color").constantOr(e.bz.white).toRenderColor(null),E=_.paint.get("model-color-mix-intensity").constantOr(0);return {u_matrix:t,u_lighting_matrix:i,u_normal_matrix:o,u_node_matrix:r||as,u_lightpos:v,u_lightintensity:f.properties.get("intensity"),u_lightcolor:[b.r,b.g,b.b],u_camera_pos:p,u_opacity:a,u_baseTextureIsAlpha:0,u_alphaMask:+y,u_alphaCutoff:u.alphaCutoff,u_baseColorFactor:[n.r,n.g,n.b,n.a],u_emissiveFactor:[l[0],l[1],l[2],1],u_metallicFactor:c,u_roughnessFactor:h,u_baseColorTexture:ji.BaseColor,u_metallicRoughnessTexture:ji.MetallicRoughness,u_normalTexture:ji.Normal,u_occlusionTexture:ji.Occlusion,u_emissionTexture:ji.Emission,u_lutTexture:ji.LUT,u_color_mix:[T.r,T.g,T.b,E],u_aoIntensity:w,u_emissive_strength:d,u_occlusionTextureTransform:m||[0,0,0,0]}},ls=(e,t=as,i=as)=>({u_matrix:e,u_instance:t,u_node_matrix:i}),cs={fillExtrusion:t=>({u_matrix:new e.bF(t),u_lightpos:new e.bH(t),u_lightintensity:new e.bI(t),u_lightcolor:new e.bH(t),u_vertical_gradient:new e.bI(t),u_opacity:new e.bI(t),u_edge_radius:new e.bI(t),u_width_scale:new e.bI(t),u_ao:new e.bG(t),u_tile_id:new e.bH(t),u_zoom_transition:new e.bI(t),u_inv_rot_matrix:new e.bF(t),u_merc_center:new e.bG(t),u_up_dir:new e.bH(t),u_height_lift:new e.bI(t),u_flood_light_color:new e.bH(t),u_vertical_scale:new e.bI(t),u_flood_light_intensity:new e.bI(t),u_ground_shadow_factor:new e.bH(t)}),fillExtrusionDepth:t=>({u_matrix:new e.bF(t),u_edge_radius:new e.bI(t),u_width_scale:new e.bI(t),u_vertical_scale:new e.bI(t)}),fillExtrusionPattern:t=>({u_matrix:new e.bF(t),u_lightpos:new e.bH(t),u_lightintensity:new e.bI(t),u_lightcolor:new e.bH(t),u_vertical_gradient:new e.bI(t),u_height_factor:new e.bI(t),u_edge_radius:new e.bI(t),u_width_scale:new e.bI(t),u_ao:new e.bG(t),u_tile_id:new e.bH(t),u_zoom_transition:new e.bI(t),u_inv_rot_matrix:new e.bF(t),u_merc_center:new e.bG(t),u_up_dir:new e.bH(t),u_height_lift:new e.bI(t),u_image:new e.bJ(t),u_texsize:new e.bG(t),u_pixel_coord_upper:new e.bG(t),u_pixel_coord_lower:new e.bG(t),u_tile_units_to_pixels:new e.bI(t),u_opacity:new e.bI(t)}),fillExtrusionGroundEffect:t=>({u_matrix:new e.bF(t),u_opacity:new e.bI(t),u_ao_pass:new e.bI(t),u_meter_to_tile:new e.bI(t),u_ao:new e.bG(t),u_flood_light_intensity:new e.bI(t),u_flood_light_color:new e.bH(t),u_attenuation:new e.bI(t),u_edge_radius:new e.bI(t),u_fb:new e.bJ(t),u_fb_size:new e.bI(t),u_dynamic_offset:new e.bI(t)}),fill:t=>({u_matrix:new e.bF(t),u_emissive_strength:new e.bI(t)}),fillPattern:t=>({u_matrix:new e.bF(t),u_emissive_strength:new e.bI(t),u_image:new e.bJ(t),u_texsize:new e.bG(t),u_pixel_coord_upper:new e.bG(t),u_pixel_coord_lower:new e.bG(t),u_tile_units_to_pixels:new e.bI(t)}),fillOutline:t=>({u_matrix:new e.bF(t),u_emissive_strength:new e.bI(t),u_world:new e.bG(t)}),fillOutlinePattern:t=>({u_matrix:new e.bF(t),u_emissive_strength:new e.bI(t),u_world:new e.bG(t),u_image:new e.bJ(t),u_texsize:new e.bG(t),u_pixel_coord_upper:new e.bG(t),u_pixel_coord_lower:new e.bG(t),u_tile_units_to_pixels:new e.bI(t)}),circle:e.cN,collisionBox:t=>({u_matrix:new e.bF(t),u_camera_to_center_distance:new e.bI(t),u_extrude_scale:new e.bG(t)}),collisionCircle:t=>({u_matrix:new e.bF(t),u_inv_matrix:new e.bF(t),u_camera_to_center_distance:new e.bI(t),u_viewport_size:new e.bG(t)}),debug:t=>({u_color:new e.cu(t),u_matrix:new e.bF(t),u_overlay:new e.bJ(t),u_overlay_scale:new e.bI(t)}),clippingMask:t=>({u_matrix:new e.bF(t)}),heatmap:t=>({u_extrude_scale:new e.bI(t),u_intensity:new e.bI(t),u_matrix:new e.bF(t),u_inv_rot_matrix:new e.bF(t),u_merc_center:new e.bG(t),u_tile_id:new e.bH(t),u_zoom_transition:new e.bI(t),u_up_dir:new e.bH(t)}),heatmapTexture:t=>({u_image:new e.bJ(t),u_color_ramp:new e.bJ(t),u_opacity:new e.bI(t)}),hillshade:t=>({u_matrix:new e.bF(t),u_image:new e.bJ(t),u_latrange:new e.bG(t),u_light:new e.bG(t),u_shadow:new e.cu(t),u_highlight:new e.cu(t),u_emissive_strength:new e.bI(t),u_accent:new e.cu(t)}),hillshadePrepare:t=>({u_matrix:new e.bF(t),u_image:new e.bJ(t),u_dimension:new e.bG(t),u_zoom:new e.bI(t)}),line:e.cO,linePattern:e.cP,raster:t=>({u_matrix:new e.bF(t),u_normalize_matrix:new e.bF(t),u_globe_matrix:new e.bF(t),u_merc_matrix:new e.bF(t),u_grid_matrix:new e.cv(t),u_tl_parent:new e.bG(t),u_scale_parent:new e.bI(t),u_fade_t:new e.bI(t),u_opacity:new e.bI(t),u_image0:new e.bJ(t),u_image1:new e.bJ(t),u_brightness_low:new e.bI(t),u_brightness_high:new e.bI(t),u_saturation_factor:new e.bI(t),u_contrast_factor:new e.bI(t),u_spin_weights:new e.bH(t),u_perspective_transform:new e.bG(t),u_raster_elevation:new e.bI(t),u_zoom_transition:new e.bI(t),u_merc_center:new e.bG(t),u_cutoff_params:new e.c6(t),u_colorization_mix:new e.c6(t),u_colorization_offset:new e.bI(t),u_color_ramp:new e.bJ(t),u_texture_offset:new e.bG(t),u_texture_res:new e.bG(t),u_emissive_strength:new e.bI(t)}),rasterParticle:t=>({u_matrix:new e.bF(t),u_normalize_matrix:new e.bF(t),u_globe_matrix:new e.bF(t),u_merc_matrix:new e.bF(t),u_grid_matrix:new e.cv(t),u_tl_parent:new e.bG(t),u_scale_parent:new e.bI(t),u_fade_t:new e.bI(t),u_opacity:new e.bI(t),u_image0:new e.bJ(t),u_image1:new e.bJ(t),u_raster_elevation:new e.bI(t),u_zoom_transition:new e.bI(t),u_merc_center:new e.bG(t),u_cutoff_params:new e.c6(t)}),rasterParticleTexture:t=>({u_texture:new e.bJ(t),u_opacity:new e.bI(t)}),rasterParticleDraw:t=>({u_particle_texture:new e.bJ(t),u_particle_texture_side_len:new e.bI(t),u_tile_offset:new e.bG(t),u_velocity:new e.bJ(t),u_color_ramp:new e.bJ(t),u_velocity_res:new e.bG(t),u_max_speed:new e.bI(t),u_uv_offset:new e.bG(t),u_data_scale:new e.bG(t),u_data_offset:new e.bI(t),u_particle_pos_scale:new e.bI(t),u_particle_pos_offset:new e.bG(t)}),rasterParticleUpdate:t=>({u_particle_texture:new e.bJ(t),u_particle_texture_side_len:new e.bI(t),u_velocity:new e.bJ(t),u_velocity_res:new e.bG(t),u_max_speed:new e.bI(t),u_speed_factor:new e.bI(t),u_reset_rate:new e.bI(t),u_rand_seed:new e.bI(t),u_uv_offset:new e.bG(t),u_data_scale:new e.bG(t),u_data_offset:new e.bI(t),u_particle_pos_scale:new e.bI(t),u_particle_pos_offset:new e.bG(t)}),symbol:t=>({u_is_size_zoom_constant:new e.bJ(t),u_is_size_feature_constant:new e.bJ(t),u_size_t:new e.bI(t),u_size:new e.bI(t),u_camera_to_center_distance:new e.bI(t),u_rotate_symbol:new e.bJ(t),u_aspect_ratio:new e.bI(t),u_fade_change:new e.bI(t),u_matrix:new e.bF(t),u_label_plane_matrix:new e.bF(t),u_coord_matrix:new e.bF(t),u_is_text:new e.bJ(t),u_elevation_from_sea:new e.bJ(t),u_pitch_with_map:new e.bJ(t),u_texsize:new e.bG(t),u_texsize_icon:new e.bG(t),u_texture:new e.bJ(t),u_texture_icon:new e.bJ(t),u_gamma_scale:new e.bI(t),u_device_pixel_ratio:new e.bI(t),u_tile_id:new e.bH(t),u_zoom_transition:new e.bI(t),u_inv_rot_matrix:new e.bF(t),u_merc_center:new e.bG(t),u_camera_forward:new e.bH(t),u_tile_matrix:new e.bF(t),u_up_vector:new e.bH(t),u_ecef_origin:new e.bH(t),u_is_halo:new e.bJ(t),u_icon_transition:new e.bI(t),u_color_adj_mat:new e.bF(t)}),background:t=>({u_matrix:new e.bF(t),u_emissive_strength:new e.bI(t),u_opacity:new e.bI(t),u_color:new e.cu(t)}),backgroundPattern:t=>({u_matrix:new e.bF(t),u_emissive_strength:new e.bI(t),u_opacity:new e.bI(t),u_image:new e.bJ(t),u_pattern_tl:new e.bG(t),u_pattern_br:new e.bG(t),u_texsize:new e.bG(t),u_pattern_size:new e.bG(t),u_pixel_coord_upper:new e.bG(t),u_pixel_coord_lower:new e.bG(t),u_pattern_units_to_pixels:new e.bG(t)}),terrainRaster:t=>({u_matrix:new e.bF(t),u_image0:new e.bJ(t),u_skirt_height:new e.bI(t),u_ground_shadow_factor:new e.bH(t)}),skybox:t=>({u_matrix:new e.bF(t),u_sun_direction:new e.bH(t),u_cubemap:new e.bJ(t),u_opacity:new e.bI(t),u_temporal_offset:new e.bI(t)}),skyboxGradient:t=>({u_matrix:new e.bF(t),u_color_ramp:new e.bJ(t),u_center_direction:new e.bH(t),u_radius:new e.bI(t),u_opacity:new e.bI(t),u_temporal_offset:new e.bI(t)}),skyboxCapture:t=>({u_matrix_3f:new e.cv(t),u_sun_direction:new e.bH(t),u_sun_intensity:new e.bI(t),u_color_tint_r:new e.c6(t),u_color_tint_m:new e.c6(t),u_luminance:new e.bI(t)}),globeRaster:t=>({u_proj_matrix:new e.bF(t),u_globe_matrix:new e.bF(t),u_normalize_matrix:new e.bF(t),u_merc_matrix:new e.bF(t),u_zoom_transition:new e.bI(t),u_merc_center:new e.bG(t),u_image0:new e.bJ(t),u_grid_matrix:new e.cv(t),u_skirt_height:new e.bI(t),u_far_z_cutoff:new e.bI(t),u_frustum_tl:new e.bH(t),u_frustum_tr:new e.bH(t),u_frustum_br:new e.bH(t),u_frustum_bl:new e.bH(t),u_globe_pos:new e.bH(t),u_globe_radius:new e.bI(t),u_viewport:new e.bG(t)}),globeAtmosphere:t=>({u_frustum_tl:new e.bH(t),u_frustum_tr:new e.bH(t),u_frustum_br:new e.bH(t),u_frustum_bl:new e.bH(t),u_horizon:new e.bI(t),u_transition:new e.bI(t),u_fadeout_range:new e.bI(t),u_color:new e.c6(t),u_high_color:new e.c6(t),u_space_color:new e.c6(t),u_temporal_offset:new e.bI(t),u_horizon_angle:new e.bI(t)}),model:t=>({u_matrix:new e.bF(t),u_lighting_matrix:new e.bF(t),u_normal_matrix:new e.bF(t),u_node_matrix:new e.bF(t),u_lightpos:new e.bH(t),u_lightintensity:new e.bI(t),u_lightcolor:new e.bH(t),u_camera_pos:new e.bH(t),u_opacity:new e.bI(t),u_baseColorFactor:new e.c6(t),u_emissiveFactor:new e.c6(t),u_metallicFactor:new e.bI(t),u_roughnessFactor:new e.bI(t),u_baseTextureIsAlpha:new e.bJ(t),u_alphaMask:new e.bJ(t),u_alphaCutoff:new e.bI(t),u_baseColorTexture:new e.bJ(t),u_metallicRoughnessTexture:new e.bJ(t),u_normalTexture:new e.bJ(t),u_occlusionTexture:new e.bJ(t),u_emissionTexture:new e.bJ(t),u_lutTexture:new e.bJ(t),u_color_mix:new e.c6(t),u_aoIntensity:new e.bI(t),u_emissive_strength:new e.bI(t),u_occlusionTextureTransform:new e.c6(t)}),modelDepth:t=>({u_matrix:new e.bF(t),u_instance:new e.bF(t),u_node_matrix:new e.bF(t)}),groundShadow:t=>({u_matrix:new e.bF(t),u_ground_shadow_factor:new e.bH(t)}),stars:t=>({u_matrix:new e.bF(t),u_up:new e.bH(t),u_right:new e.bH(t),u_intensity_multiplier:new e.bI(t)}),occlusion:t=>({u_matrix:new e.bF(t),u_anchorPos:new e.bH(t),u_screenSizePx:new e.bG(t),u_occluderSizePx:new e.bG(t),u_color:new e.c6(t)})};class hs{constructor(e,t,i,o){this.id=hs.uniqueIdxCounter,hs.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||o||t.destroy();}bind(){this.context.bindElementBuffer.set(this.buffer);}updateData(e){this.id=hs.uniqueIdxCounter,hs.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);}}hs.uniqueIdxCounter=0;const us={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class ds{constructor(e,t,i,o,r,s){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=o,this.instanceCount=s,this.context=e;const a=e.gl;this.buffer=a.createBuffer(),e.bindVertexBuffer.set(this.buffer),a.bufferData(a.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||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 _s{constructor(e,t,i,o,r){this.context=e,this.width=t,this.height=i;const s=this.framebuffer=e.gl.createFramebuffer();o&&(this.colorAttachment=new pr(e,s)),r&&(this.depthAttachmentType=r,this.depthAttachment="renderbuffer"===r?new mr(e,s):new fr(e,s));}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 ps{constructor(e,t){this.gl=e,this.clearColor=new Fo(this),this.clearDepth=new ko(this),this.clearStencil=new Bo(this),this.colorMask=new No(this),this.depthMask=new Uo(this),this.stencilMask=new Go(this),this.stencilFunc=new jo(this),this.stencilOp=new Vo(this),this.stencilTest=new qo(this),this.depthRange=new Zo(this),this.depthTest=new Ho(this),this.depthFunc=new Wo(this),this.blend=new $o(this),this.blendFunc=new Xo(this),this.blendColor=new Yo(this),this.blendEquation=new Ko(this),this.cullFace=new Jo(this),this.cullFaceSide=new Qo(this),this.frontFace=new er(this),this.program=new tr(this),this.activeTexture=new ir(this),this.viewport=new or(this),this.bindFramebuffer=new rr(this),this.bindRenderbuffer=new sr(this),this.bindTexture=new ar(this),this.bindVertexBuffer=new nr(this),this.bindElementBuffer=new lr(this),this.bindVertexArrayOES=new cr(this),this.pixelStoreUnpack=new hr(this),this.pixelStoreUnpackPremultiplyAlpha=new ur(this),this.pixelStoreUnpackFlipY=new dr(this),this.options=t?{...t}:{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=e.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=e.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=e.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.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 hs(this,e,t,i)}createVertexBuffer(e,t,i,o,r){return new ds(this,e,t,i,o,r)}createRenderbuffer(e,t,i){const o=this.gl,r=o.createRenderbuffer();return this.bindRenderbuffer.set(r),o.renderbufferStorage(o.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),r}createFramebuffer(e,t,i,o){return new _s(this,e,t,i,o)}clear({color:e,depth:t,stencil:i,colorMask:o}){const r=this.gl;let s=0;e&&(s|=r.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set(o||[!0,!0,!0,!0])),void 0!==t&&(s|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==i&&(s|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),r.clear(s);}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.bh(t.blendFunction,Ai.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 ms;function fs(t,i,o,r,s,a,n){const l=t.context,c=l.gl,h=t.transform,u=t.getOrCreateProgram("collisionBox"),d=[];let _=0,p=0;for(let l=0;l0){const t=e.a6.mat4.create(),i=x;e.a6.mat4.mul(t,g.placementInvProjMatrix,h.glCoordMatrix),e.a6.mat4.mul(t,t,g.placementViewportMatrix),d.push({circleArray:b,circleOffset:p,transform:i,invTransform:t,projection:g.getProjection()}),_+=b.length/4,p=_;}y&&(t.terrain&&t.terrain.setupElevationDraw(f,u),u.draw(t,c.LINES,Li.disabled,Mi.disabled,t.colorModeForRenderPass(),Fi.disabled,qr(x,h,f,g.getProjection()),o.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,null,h.zoom,null,[y.collisionVertexBuffer,y.collisionVertexBufferExt]));}if(!n||!d.length)return;const m=t.getOrCreateProgram("collisionCircle"),f=new e.cQ;f.resize(4*_),f._trim();let g=0;for(const e of d)for(let t=0;t=0&&(m[y.associatedIconIndex]={x:C,y:S,z:I,angle:P});}else Yt(T,_);}if(u){p.clear();const i=t.icon.placedSymbolArray;for(let t=0;t{S.depthOcclusionForSymbolsAndCircles&&(o.hasInitialOcclusionOpacityProperties||t.terrain)&&(e.push("DEPTH_D24"),e.push("DEPTH_OCCLUSION"));},G=()=>{const i=I&&"point"!==o.layout.get("symbol-placement"),n=[];U(n);const c=i||M,u=o.paint.get("icon-image-cross-fade").constantOr(0);t.terrainRenderModeElevated()&&R&&n.push("PITCH_WITH_MAP_TERRAIN"),d&&(n.push("PROJECTION_GLOBE_VIEW"),c&&n.push("PROJECTED_POS_ON_VIEWPORT")),u>0&&n.push("ICON_TRANSITION"),a.icon.zOffsetVertexBuffer&&n.push("Z_OFFSET"),0===v&&0===x&&0===y&&1===b||n.push("COLOR_ADJUSTMENT"),a.sdfIcons&&n.push("RENDER_SDF");const g=a.icon.programConfigurations.get(o.id),T=t.getOrCreateProgram("symbol",{config:g,defines:n}),E=r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],D=a.iconSizeData,A=e.bj(D,S.zoom),L=R||0!==S.pitch,P=kt(p,r.tileID.canonical,R,I,S,a.getProjection(),m),O=Nt(p,r.tileID.canonical,R,I,S,a.getProjection(),m),k=t.translatePosMatrix(O,r,l,h,!0),G=t.translatePosMatrix(p,r,l,h),j=c?gs:P,V=I&&!R&&!i;let q=B;!F&&!S.mercatorFromTransition||I||(q=vs(S));const Z=d?q:B,H=o.getColorAdjustmentMatrix(v,x,y,b),W=os(D.kind,A,V,R,t,G,j,k,w,!1,E,[0,0],!0,s,_,z,N,Z,a.getProjection(),H,u),$=r.imageAtlasTexture?r.imageAtlasTexture:null,X=1!==o.layout.get("icon-size").constantOr(0)||a.iconsNeedLinear,Y=a.sdfIcons||t.options.rotating||t.options.zooming||X||L?C.LINEAR:C.NEAREST,K=a.sdfIcons&&0!==o.paint.get("icon-halo-width").constantOr(1),J=t.terrain&&R&&i?e.a6.mat4.invert(e.a6.mat4.create(),P):gs;if(i&&a.icon){const e=S.elevation,i=e?e.getAtTileOffsetFunc(s,S.center.lat,S.worldSize,a.getProjection()):null,o=Bt(p,r.tileID.canonical,R,I,S,a.getProjection(),m);Vt(a,p,t,!1,o,O,R,f,i,s);}return {program:T,buffers:a.icon,uniformValues:W,atlasTexture:$,atlasTextureIcon:null,atlasInterpolation:Y,atlasInterpolationIcon:null,isSDF:a.sdfIcons,hasHalo:K,tile:r,labelPlaneMatrixInv:J}},j=()=>{const i=D&&"point"!==o.layout.get("symbol-placement"),n=[],l=i||O||M;t.terrainRenderModeElevated()&&A&&n.push("PITCH_WITH_MAP_TERRAIN"),d&&(n.push("PROJECTION_GLOBE_VIEW"),l&&n.push("PROJECTED_POS_ON_VIEWPORT")),a.text.zOffsetVertexBuffer&&n.push("Z_OFFSET"),a.iconsInText&&n.push("RENDER_TEXT_AND_SYMBOL"),n.push("RENDER_SDF"),U(n);const h=a.text.programConfigurations.get(o.id),f=t.getOrCreateProgram("symbol",{config:h,defines:n});let v,x=[0,0],y=null;const b=a.textSizeData;a.iconsInText&&(x=r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],y=r.imageAtlasTexture?r.imageAtlasTexture:null,v=A||0!==S.pitch||t.options.rotating||t.options.zooming||"composite"===b.kind||"camera"===b.kind?C.LINEAR:C.NEAREST);const E=r.glyphAtlasTexture?r.glyphAtlasTexture.size:[0,0],I=e.bj(b,S.zoom),R=kt(p,r.tileID.canonical,A,D,S,a.getProjection(),m),L=Nt(p,r.tileID.canonical,A,D,S,a.getProjection(),m),P=t.translatePosMatrix(L,r,c,u,!0),k=t.translatePosMatrix(p,r,c,u),G=l?gs:R,j=D&&!A&&!i;let V=B;!F&&!S.mercatorFromTransition||D||(V=vs(S));const q=os(b.kind,I,j,A,t,k,G,P,w,!0,E,x,!0,s,_,z,N,d?V:B,a.getProjection(),T),Z=r.glyphAtlasTexture?r.glyphAtlasTexture:null,H=C.LINEAR,W=0!==o.paint.get("text-halo-width").constantOr(1),$=t.terrain&&A&&i?e.a6.mat4.invert(e.a6.mat4.create(),R):gs;if(i&&a.text){const e=S.elevation,i=e?e.getAtTileOffsetFunc(s,S.center.lat,S.worldSize,a.getProjection()):null,o=Bt(p,r.tileID.canonical,A,D,S,a.getProjection(),m);Vt(a,p,t,!0,o,L,A,g,i,s);}return {program:f,buffers:a.text,uniformValues:q,atlasTexture:Z,atlasTextureIcon:y,atlasInterpolation:H,atlasInterpolationIcon:v,isSDF:!0,hasHalo:W,tile:r,labelPlaneMatrixInv:$}},V=a.icon.segments.get().length,q=a.text.segments.get().length,Z=V&&!n.onlyText?G():null,H=q&&!n.onlyIcons?j():null,W=o.paint.get("icon-opacity").constantOr(1),$=o.paint.get("text-opacity").constantOr(1);if(L&&a.canOverlap){P=!0;const t=W&&!n.onlyText?a.icon.segments.get():[],i=$&&!n.onlyIcons?a.text.segments.get():[];for(const i of t)k.push({segments:new e.b1([i]),sortKey:i.sortKey,state:Z});for(const t of i)k.push({segments:new e.b1([t]),sortKey:t.sortKey,state:H});}else n.onlyText||k.push({segments:W?a.icon.segments:new e.b1([]),sortKey:0,state:Z}),n.onlyIcons||k.push({segments:$?a.text.segments:new e.b1([]),sortKey:0,state:H});}P&&k.sort(((e,t)=>e.sortKey-t.sortKey));for(const e of k){const i=e.state;if(i)if(t.terrain?t.terrain.setupElevationDraw(i.tile,i.program,{useDepthForOcclusion:S.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:i.labelPlaneMatrixInv}):t.setupDepthForOcclusion(S.depthOcclusionForSymbolsAndCircles,i.program),E.activeTexture.set(C.TEXTURE0),i.atlasTexture&&i.atlasTexture.bind(i.atlasInterpolation,C.CLAMP_TO_EDGE,!0),i.atlasTextureIcon&&(E.activeTexture.set(C.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,C.CLAMP_TO_EDGE,!0)),t.uploadCommonLightUniforms(t.context,i.program),i.hasHalo){const r=i.uniformValues;r.u_is_halo=1,ws(i.buffers,e.segments,o,t,i.program,M,s,a,r,2),r.u_is_halo=0;}else {if(i.isSDF){const r=i.uniformValues;i.hasHalo&&(r.u_is_halo=1,ws(i.buffers,e.segments,o,t,i.program,M,s,a,r,1)),r.u_is_halo=0;}ws(i.buffers,e.segments,o,t,i.program,M,s,a,i.uniformValues,1);}}}function ws(e,t,i,o,r,s,a,n,l,c){const h=[e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.iconTransitioningVertexBuffer,e.globeExtVertexBuffer,e.zOffsetVertexBuffer];r.draw(o,o.context.gl.TRIANGLES,s,a,n,Fi.disabled,l,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,o.transform.zoom,e.programConfigurations.get(i.id),h,c);}function Ts(e,t,i,o,r,s,a){const n=e.context.gl,l=i.paint.get("fill-pattern"),c=i.is3D(),h=c?e.stencilModeFor3D():Mi.disabled,u=l&&l.constantOr(1);let d,_,p,m,f;a?(_=u&&!i.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",d=n.LINES):(_=u?"fillPattern":"fill",d=n.TRIANGLES);for(const g of o){const o=t.getTile(g);if(u&&!o.patternsLoaded())continue;const v=o.getBucket(i);if(!v)continue;e.prepareDrawTile();const x=v.programConfigurations.get(i.id),y=e.isTileAffectedByFog(g),b=e.getOrCreateProgram(_,{config:x,overrideFog:y});u&&(e.context.activeTexture.set(n.TEXTURE0),o.imageAtlasTexture&&o.imageAtlasTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE),x.updatePaintBuffers());const w=l.constantOr(null);if(w&&o.imageAtlas){const e=o.imageAtlas.patternPositions[w.toString()];e&&x.setConstantPatternPositions(e);}const T=e.translatePosMatrix(g.projMatrix,o,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor")),E=i.paint.get("fill-emissive-strength");if(a){m=v.indexBuffer2,f=v.segments2;const t=e.terrain&&e.terrain.renderingToTexture?e.terrain.drapeBufferSize:[n.drawingBufferWidth,n.drawingBufferHeight];p="fillOutlinePattern"===_&&u?Vr(T,E,e,o,t):jr(T,E,t);}else m=v.indexBuffer,f=v.segments,p=u?Gr(T,E,e,o):Ur(T,E);e.uploadCommonUniforms(e.context,b,g.toUnwrapped()),b.draw(e,d,r,c?h:e.stencilModeForClipping(g),s,Fi.disabled,p,i.id,v.layoutVertexBuffer,m,f,i.paint,e.transform.zoom,x,void 0);}}function Es(t,i,o,r,s,a,n,l){o.resetLayerRenderingStats(t);const c=t.context,h=c.gl,u=t.transform,d=o.paint.get("fill-extrusion-pattern"),_=d.constantOr(1),p=o.paint.get("fill-extrusion-opacity"),m=t.style.enable3dLights(),f=o.paint.get(m&&!_?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),g=[o.paint.get("fill-extrusion-ambient-occlusion-intensity"),f],v=o.layout.get("fill-extrusion-edge-radius"),x=v>0&&!o.paint.get("fill-extrusion-rounded-roof"),y=x?0:v,b="globe"===u.projection.name?e.c_():0,w="globe"===u.projection.name,T=w?e.a9(u.zoom):0,E=[e.am(u.center.lng),e.at(u.center.lat)],C=o.paint.get("fill-extrusion-flood-light-color").toRenderColor(o.lut).toArray01().slice(0,3),S=o.paint.get("fill-extrusion-flood-light-intensity"),I=o.paint.get("fill-extrusion-vertical-scale"),D=0!==o.paint.get("fill-extrusion-line-width").constantOr(1),R=Wi(t,o.paint.get("fill-extrusion-cutoff-fade-range")),A=[];let L;w&&A.push("PROJECTION_GLOBE_VIEW"),g[0]>0&&A.push("FAUX_AO"),x&&A.push("ZERO_ROOF_RADIUS"),l&&A.push("HAS_CENTROID"),S>0&&A.push("FLOOD_LIGHT"),R.shouldRenderCutoff&&A.push("RENDER_CUTOFF"),D&&A.push("RENDER_WALL_MODE");const P="shadow"===t.renderPass,M=t.shadowRenderer,z=P&&!!M;t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!0);let O=[0,0,0];if(M){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(O=eo(t.style,e,i)),L=A.concat(["SHADOWS_SINGLE_CASCADE"]);}const F=z?"fillExtrusionDepth":_?"fillExtrusionPattern":"fillExtrusion",k=o.getLayerRenderingStats();for(const e of r){const r=i.getTile(e),m=r.getBucket(o);if(!m||m.projection.name!==u.projection.name)continue;let f=!1;M&&(f=0===M.getMaxCascadeForTile(e.toUnwrapped()));const v=t.isTileAffectedByFog(e),x=m.programConfigurations.get(o.id),z=t.getOrCreateProgram(F,{config:x,defines:f?L:A,overrideFog:v});if(t.terrain&&t.terrain.setupElevationDraw(r,z,{useMeterToDem:!0}),!m.centroidVertexBuffer){const e=z.attributes.a_centroid_pos;void 0!==e&&h.vertexAttrib2f(e,0,0);}!P&&M&&M.setupShadows(r.tileID.toUnwrapped(),z,"vector-tile",r.tileID.overscaledZ),_&&(t.context.activeTexture.set(h.TEXTURE0),r.imageAtlasTexture&&r.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),x.updatePaintBuffers());const B=d.constantOr(null);if(B&&r.imageAtlas){const e=r.imageAtlas.patternPositions[B.toString()];e&&x.setConstantPatternPositions(e);}const N=o.paint.get("fill-extrusion-vertical-gradient"),U=1/m.tileToMeter;let G;if(P&&M){if(As(r.tileID,m,t))continue;const e=M.calculateShadowPassMatrixFromTile(r.tileID.toUnwrapped());G=Br(e,y,U,I);}else {const i=t.translatePosMatrix(e.expandedProjMatrix,r,o.paint.get("fill-extrusion-translate"),o.paint.get("fill-extrusion-translate-anchor")),s=u.projection.createInversionMatrix(u,e.canonical);G=_?Nr(i,t,N,p,g,y,U,e,r,b,T,E,s,C,I):kr(i,t,N,p,g,y,U,e,b,T,E,s,C,I,S,O);}t.uploadCommonUniforms(c,z,e.toUnwrapped(),null,R);let j=m.segments;if("mercator"===u.projection.name&&!P&&(j=m.getVisibleSegments(r.tileID,t.terrain,t.transform.getFrustum(0)),!j.get().length))continue;if(k)if(P)for(const e of j.get())k.numRenderedVerticesInShadowPass+=e.primitiveLength;else for(const e of j.get())k.numRenderedVerticesInTransparentPass+=e.primitiveLength;const V=[];(t.terrain||l)&&V.push(m.centroidVertexBuffer),w&&V.push(m.layoutVertexExtBuffer),D&&V.push(m.wallVertexBuffer),z.draw(t,c.gl.TRIANGLES,s,a,n,Fi.backCCW,G,o.id,m.layoutVertexBuffer,m.indexBuffer,j,o.paint,t.transform.zoom,x,V);}t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!1);}function Cs(t,i,o,r,s,a,n,l,c,h,u,d,_,p,m,f,g,v,x){const y=t.context,b=y.gl,w=t.transform,T=t.transform.zoom,E=[],C=Wi(t,o.paint.get("fill-extrusion-cutoff-fade-range"));"clear"===h?(E.push("CLEAR_SUBPASS"),x&&(E.push("CLEAR_FROM_TEXTURE"),y.activeTexture.set(b.TEXTURE0),x.bind(b.LINEAR,b.CLAMP_TO_EDGE))):"sdf"===h&&E.push("SDF_SUBPASS"),g&&E.push("HAS_CENTROID"),C.shouldRenderCutoff&&E.push("RENDER_CUTOFF");const S=o.layout.get("fill-extrusion-edge-radius"),I=(e,i,r,h,v)=>{const b=i.programConfigurations.get(o.id),w=t.isTileAffectedByFog(e),I=t.getOrCreateProgram("fillExtrusionGroundEffect",{config:b,defines:E,overrideFog:w}),D=((e,t,i,o,r,s,a,n,l,c,h)=>({u_matrix:t,u_opacity:i,u_ao_pass:o?1:0,u_meter_to_tile:r,u_ao:s,u_flood_light_intensity:a,u_flood_light_color:n,u_attenuation:l,u_edge_radius:c,u_fb:0,u_fb_size:h,u_dynamic_offset:1}))(0,h,u,c,v,[d,_*v],p,m,f,T>=17?0:S*v,x?x.size[0]:0),R=[];g&&R.push(i.hiddenByLandmarkVertexBuffer),t.uploadCommonUniforms(y,I,e.toUnwrapped(),null,C),I.draw(t,y.gl.TRIANGLES,s,a,n,l,D,o.id,i.vertexBuffer,i.indexBuffer,r,o.paint,T,b,R);};for(const s of r){const r=i.getTile(s),a=r.getBucket(o);if(!a||a.projection.name!==w.projection.name||!a.groundEffect||a.groundEffect&&!a.groundEffect.hasData())continue;const n=a.groundEffect,l=1/a.tileToMeter;{const e=t.translatePosMatrix(s.projMatrix,r,o.paint.get("fill-extrusion-translate"),o.paint.get("fill-extrusion-translate-anchor")),i=n.getDefaultSegment();I(s,n,i,e,l);}if(v)for(let a=0;a<4;a++){const n=e.c$[a](s),c=i.getTile(n);if(!c)continue;const h=c.getBucket(o);if(!h||h.projection.name!==w.projection.name||!h.groundEffect||h.groundEffect&&!h.groundEffect.hasData())continue;const u=h.groundEffect;let d,_;0===a?(d=[-e.ab,0,0],_=1):1===a?(d=[e.ab,0,0],_=0):2===a?(d=[0,-e.ab,0],_=3):(d=[0,e.ab,0],_=2);const p=u.regionSegments[_];if(!p)continue;const m=new Float32Array(16);e.a6.mat4.translate(m,s.projMatrix,d),I(s,u,p,t.translatePosMatrix(m,r,o.paint.get("fill-extrusion-translate"),o.paint.get("fill-extrusion-translate-anchor")),l);}}}function Ss(t,i,o,r,s,a,n){0===r.centroidVertexArray.length&&r.createCentroidsBuffer();const l=a?a.findDEMTileFor(o):null;if(!(l&&l.dem||n))return;const c=t=>new e.P(Math.ceil((t+e.d2)*e.d3),0),h=e=>{const t=i.getSource().minzoom,o=e=>{const t=i.getTileByID(e);if(t&&t.hasData())return t.getBucket(s)},r=[0,-1,1];for(const i of r){if(e.overscaledZ+i(u[0]=Math.min(t.min.y,i.min.y),u[1]=Math.max(t.max.y,i.max.y),u[2]=e.ab-i.min.x>t.max.x?i.min.x-e.ab:t.max.x,u),_=(t,i)=>(u[0]=Math.min(t.min.x,i.min.x),u[1]=Math.max(t.max.x,i.max.x),u[2]=e.ab-i.min.y>t.max.y?i.min.y-e.ab:t.max.y,u),p=[(e,t)=>d(e,t),(e,t)=>d(t,e),(e,t)=>_(e,t),(e,t)=>_(t,e)],m=(t,i,r,s,n,c,h)=>{if(!a)return 0;const u=[[c?r:t,c?t:r,0],[c?r:i,c?i:r,0]],d=h<0?e.ab+h:h,_=[c?d:(t+i)/2,c?(t+i)/2:d,0];return 0===r&&h<0||0!==r&&h>0?a.getForTilePoints(n,[_],!0,s):u.push(_),a.getForTilePoints(o,u,!0,l),Math.max(u[0][2],u[1][2],_[2])/a.exaggeration()};for(let t=0;t<4;t++){const i=r.borderFeatureIndices[t];if(0===i.length)continue;const s=e.c$[t](o),l=h(s);if(!(l&&l instanceof e.d0))continue;if(r.borderDoneWithNeighborZ[t]===l.canonical.z)continue;0===l.centroidVertexArray.length&&l.createCentroidsBuffer();const u=a?a.findDEMTileFor(s):null;if(!(u&&u.dem||n))continue;const d=(t<2?1:5)-t,_=l.borderDoneWithNeighborZ[d]!==r.canonical.z,v=l.borderFeatureIndices[d];let x=0;if(r.canonical.z!==l.canonical.z){for(const e of i)r.showCentroid(r.featuresOnBorder[e]);if(_)for(const e of v)l.showCentroid(l.featuresOnBorder[e]);r.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[d]=r.canonical.z;}for(const o of i){const i=r.featuresOnBorder[o],a=r.centroidData[i.centroidDataIndex],h=i.borders[t];let _;for(;xh[0]+3||e[0]>h[0]-3)break;l.showCentroid(_),x++;}if(_&&xh[1]-3)&&(y++,++x!==v.length);)_=l.featuresOnBorder[v[x]];_=l.featuresOnBorder[v[o]];let b=!1;if(y>=1){const e=_.borders[d];Math.abs(h[0]-e[0])<3&&Math.abs(h[1]-e[1])<3&&(y=1,b=!0,x=o+1);}else if(0===y){r.showCentroid(i);continue}const w=l.centroidData[_.centroidDataIndex];n&&b&&(((f=a).flags|(g=w).flags)&e.d1?(f.flags|=e.d1,g.flags|=e.d1):(f.flags&=~e.d1,g.flags&=~e.d1));const T=i.intersectsCount()>1||_.intersectsCount()>1;if(y>1)x=o,a.centroidXY=w.centroidXY=new e.P(0,0);else if(u&&u.dem&&!T){const i=p[t](a,w),o=t%2?e.ab-1:0,r=m(i[0],Math.min(e.ab-1,i[1]),o,u,s,t<2,i[2]);a.centroidXY=w.centroidXY=c(r);}else T?a.centroidXY=w.centroidXY=new e.P(0,0):(a.centroidXY=r.encodeBorderCentroid(i),w.centroidXY=l.encodeBorderCentroid(_));r.writeCentroidToBuffer(a),l.writeCentroidToBuffer(w);}else r.showCentroid(i);}r.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[d]=r.canonical.z;}var f,g;(r.needsCentroidUpdate||!r.centroidVertexBuffer&&0!==r.centroidVertexArray.length)&&r.uploadCentroid(t);}const Is=[1,0,0],Ds=[0,1,0],Rs=[0,0,1];function As(t,i,o){const r=o.transform,s=o.shadowRenderer;if(!s)return !0;const a=t.toUnwrapped(),n=r.tileSize*s._cascades[o.currentShadowCascade].scale;let l=i.maxHeight;if(r.elevation){const e=r.elevation.getMinMaxForTile(t);e&&(l+=e.max);}const c=[...s.shadowDirection];c[2]=-c[2];const h=s.computeSimplifiedTileShadowVolume(a,l,n,c);if(!h)return !1;const u=[Is,Ds,Rs,c,[c[0],0,c[2]],[0,c[1],c[2]]],d="globe"===r.projection.name,_=r.scaleZoom(n),p=e.bN.fromInvProjectionMatrix(r.invProjMatrix,r.worldSize,_,!d),m=s.getCurrentCascadeFrustum();return 0===p.intersectsPrecise(h.vertices,h.planes,u)||0===m.intersectsPrecise(h.vertices,h.planes,u)}function Ls(t){return [t[0]*e.d4,t[1]*e.d4,t[2]*e.d4,0]}function Ps(t,i,o,r,s,a,n,l,c){const h=r.getSource(),u=o.globeSharedBuffers;if(!u)return;let d,_,p;if(i&&(d=r.getTile(i)),h instanceof e.aD?(_=h.texture,p=e.cD(0,0,o.transform)):d&&i&&(_=d.texture,p=e.cD(i.canonical.z,i.canonical.x,o.transform)),!_||!p)return;t||(p=e.a6.mat4.scale(e.a6.mat4.create(),p,[1,-1,1]));const m=o.context,f=m.gl,g="nearest"===s.paint.get("raster-resampling")?f.NEAREST:f.LINEAR,v=o.colorModeForDrapableLayerRenderPass(a),x=n.defines;x.push("GLOBE_POLES");const y=new Li(f.LEQUAL,Li.ReadWrite,o.depthRangeFor3D),b=Float32Array.from(o.transform.expandedFarZProjMatrix),w=Float32Array.from(e.b5(e.cC(new e.bP(0,0,0))));o.terrain&&o.terrain.prepareDrawTile(),m.activeTexture.set(f.TEXTURE0),_.bind(g,f.CLAMP_TO_EDGE),m.activeTexture.set(f.TEXTURE1),_.bind(g,f.CLAMP_TO_EDGE),_.useMipmap&&m.extTextureFilterAnisotropic&&o.transform.pitch>20&&f.texParameterf(f.TEXTURE_2D,m.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,m.extTextureFilterAnisotropicMax);const[T,E,C,S]=i?u.getPoleBuffers(i.canonical.z,!1):u.getPoleBuffers(0,!0),I=s.paint.get("raster-elevation");let D;t?(D=T,o.renderDefaultNorthPole=0!==I):(D=E,o.renderDefaultSouthPole=0!==I);const R=Ls(n.mix),A=((e,t,i,o,r,s,a,n,l,c,h,u,d)=>Yr(e,t,i,new Float32Array(16),new Float32Array(9),[0,0],o,[0,0],[0,0,0,0],1,{opacity:1,mix:0},s,[0,0]||[0,0],n,2,c,h,u,1,0,d))(b,w,p,e.a9(o.transform.zoom),0,s,0,I,0,R,n.offset,n.range,a),L=o.getOrCreateProgram("raster",{defines:x});o.uploadCommonUniforms(m,L,null),L.draw(o,f.TRIANGLES,y,c,v,l,A,s.id,D,C,S);}function Ms(e){const t=e._nearZ,i=e.projection.farthestPixelDistance(e),o=i-t,r=.2*e.height,s=t+r;return [t,i,(s-r-t)/o,(s-t)/o]}function zs(e,t,i,o){if(e)return t instanceof Qe&&e instanceof mt?t.getTextureDescriptor(e,i,!0):{texture:e.texture,mix:Ls(o.mix),offset:o.offset,buffer:0,tileSize:1}}var Os=e.d5([{name:"a_index",type:"Int16",components:1}]);class Fs{constructor(t,i,o,r){const s={width:o[0],height:o[1],data:null},a=t.gl;this.targetColorTexture=new e.T(t,s,a.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new e.T(t,s,a.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 o=this.context.gl,r=i.width*i.height;this.particleTexture0=new e.T(this.context,i,o.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new e.T(this.context,i,o.RGBA8,{premultiply:!1,useMipmap:!1});const s=new e.d6;s.reserve(r);for(let e=0;e0){const t=e.b4(o.canonical,c),i=e.d8(t);_=e.a6.mat4.multiply(new Float32Array(16),c.globeMatrix,i),e.a6.mat4.multiply(_,c.projMatrix,_);}const p=e.a6.mat4.create();p[12]+=2*s/(e.q.devicePixelRatio*c.width),p[13]+=2*a/(e.q.devicePixelRatio*c.height),e.a6.mat4.multiply(_,p,_);const m=t.getOrCreateProgram("debug",{defines:d}),f=i.getTileByID(o.key);t.terrain&&t.terrain.setupElevationDraw(f,m);const g=Li.disabled,v=Mi.disabled,x=t.colorModeForRenderPass(),y="$debug";l.activeTexture.set(h.TEXTURE0),t.emptyTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),u?f._makeGlobeTileDebugBuffers(t.context,c):f._makeDebugTileBoundsBuffers(t.context,c.projection);const b=f._tileDebugBuffer||t.debugBuffer,w=f._tileDebugIndexBuffer||t.debugIndexBuffer,T=f._tileDebugSegments||t.debugSegments;if(m.draw(t,h.LINE_STRIP,g,v,x,Fi.disabled,Zr(_,r),y,b,w,T,null,null,null,[f._globeTileDebugBorderBuffer]),n){const e=f.latestRawTileData,i=Math.floor((e&&e.byteLength||0)/1024);let r=o.canonical.toString();o.overscaledZ!==o.canonical.z&&(r+=` => ${o.overscaledZ}`),r+=` ${f.state}`,r+=` ${i}kb`,function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,o=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(o.LINEAR,o.CLAMP_TO_EDGE);}(t,r);}const E=i.getTile(o).tileSize,C=512/Math.min(E,512)*(o.overscaledZ/c.zoom)*.5,S=f._tileDebugTextBuffer||t.debugBuffer,I=f._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,D=f._tileDebugTextSegments||t.debugSegments;m.draw(t,h.TRIANGLES,g,v,Ai.alphaBlended,Fi.disabled,Zr(_,e.bz.transparent,C),y,S,I,D,null,null,null,[f._globeTileDebugTextBuffer]);}function Zs(e,t,i,o){Ws(e,0,t+i/2,e.transform.width,i,o);}function Hs(e,t,i,o){Ws(e,t-i/2,0,i,e.transform.height,o);}function Ws(t,i,o,r,s,a){const n=t.context,l=n.gl;l.enable(l.SCISSOR_TEST),l.scissor(i*e.q.devicePixelRatio,o*e.q.devicePixelRatio,r*e.q.devicePixelRatio,s*e.q.devicePixelRatio),n.clear({color:a}),l.disable(l.SCISSOR_TEST);}const $s=e.d5([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Xs}=$s;function Ys(e,t,i,o){e.emplaceBack(t,i,o);}class Ks{constructor(t){this.vertexArray=new e.d9,this.indices=new e.aO,Ys(this.vertexArray,-1,-1,1),Ys(this.vertexArray,1,-1,1),Ys(this.vertexArray,-1,1,1),Ys(this.vertexArray,1,1,1),Ys(this.vertexArray,-1,-1,-1),Ys(this.vertexArray,1,-1,-1),Ys(this.vertexArray,-1,1,-1),Ys(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,Xs),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=e.b1.simpleSegment(0,0,36,12);}}function Js(t,i,o,r,s,a){const n=t.context.gl,l=i.paint.get("sky-atmosphere-color"),c=i.paint.get("sky-atmosphere-halo-color"),h=i.paint.get("sky-atmosphere-sun-intensity"),u=((e,t,i,o,r)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:i,u_color_tint_r:[o.r,o.g,o.b,o.a],u_color_tint_m:[r.r,r.g,r.b,r.a],u_luminance:5e-5}))(e.a6.mat3.fromMat4(e.a6.mat3.create(),r),s,h,l,c);n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+a,i.skyboxTexture,0),o.draw(t,n.TRIANGLES,Li.disabled,Mi.disabled,Ai.unblended,Fi.frontCW,u,"skyboxCapture",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment);}const Qs=e.d5([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class ea{constructor(t){const i=new e.da;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 o=new e.aO;o.emplaceBack(0,1,2),o.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(i,Qs.members),this.indexBuffer=t.createIndexBuffer(o),this.segments=e.b1.simpleSegment(0,0,4,2);}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy();}}const ta=e.d5([{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 ia{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200;}}class oa{constructor(t){this.colorModeAlphaBlendedWriteRGB=new Ai([1,Ri,1,Ri],e.bz.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new Ai([1,0,1,0],e.bz.transparent,[!1,!1,!1,!0]),this.params=new ia,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 ea(i);const t=this.params.sizeRange,o=this.params.intensityRange,r=function(t){const i=e.dd(30),o=[];for(let r=0;r{const i="globe"===s.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];e&&i.push("ALPHA_PASS");const l=t.getOrCreateProgram("globeAtmosphere",{defines:i}),d=((e,t,i,o,r,s,a,n,l,c,h,u)=>({u_frustum_tl:e,u_frustum_tr:t,u_frustum_br:i,u_frustum_bl:o,u_horizon:r,u_transition:s,u_fadeout_range:a,u_color:n,u_high_color:l,u_space_color:c,u_temporal_offset:h,u_horizon_angle:u}))(s.frustumCorners.TL,s.frustumCorners.TR,s.frustumCorners.BR,s.frustumCorners.BL,s.frustumCorners.horizon,n,_,c,h,u,m,v);t.uploadCommonUniforms(o,l);const p=this.atmosphereBuffer;p&&l.draw(t,r.TRIANGLES,a,Mi.disabled,e?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,Fi.backCW,d,e?"atmosphere_glow_alpha":"atmosphere_glow",p.vertexBuffer,p.indexBuffer,p.segments);};x(!1),x(!0);}drawStars(t,i){const o=e.ap(i.properties.get("star-intensity"),0,1);if(0===o)return;const r=t.context,s=r.gl,a=t.transform,n=t.getOrCreateProgram("stars"),l=e.a6.quat.identity([]);e.a6.quat.rotateX(l,l,-a._pitch),e.a6.quat.rotateZ(l,l,-a.angle),e.a6.quat.rotateX(l,l,e.bB(a._center.lat)),e.a6.quat.rotateY(l,l,-e.bB(a._center.lng));const c=e.a6.mat4.fromQuat(new Float32Array(16),l),h=e.a6.mat4.multiply([],a.starsProjMatrix,c),u=e.a6.mat3.fromMat4([],c),d=e.a6.mat3.invert([],u),_=[0,1,0];e.a6.vec3.transformMat3(_,_,d),e.a6.vec3.scale(_,_,this.params.sizeMultiplier);const p=[1,0,0];e.a6.vec3.transformMat3(p,p,d),e.a6.vec3.scale(p,p,this.params.sizeMultiplier);const m=(f=_,g=p,v=o,{u_matrix:Float32Array.from(h),u_up:f,u_right:g,u_intensity_multiplier:v});var f,g,v;t.uploadCommonUniforms(r,n),this.starsVx&&this.starsIdx&&n.draw(t,s.TRIANGLES,Li.disabled,Mi.disabled,this.colorModeAlphaBlendedWriteRGB,Fi.disabled,m,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments);}}function ra(t,i){const o=[...t],r=i.cameraWorldSizeForFog/i.worldSize,s=e.a6.mat4.identity([]);return e.a6.mat4.scale(s,s,[r,r,1]),e.a6.mat4.multiply(o,s,o),e.a6.mat4.multiply(o,i.worldToFogMatrix,o),o}function sa(t,i,o,r,s){const a=o.material,n=r.context,{baseColorTexture:l,metallicRoughnessTexture:c}=a.pbrMetallicRoughness,{normalTexture:h,occlusionTexture:u,emissionTexture:d}=a;function _(e,i,o){if(e&&(t.push(i),n.activeTexture.set(n.gl.TEXTURE0+o),e.gfxTexture)){const{minFilter:t,magFilter:i,wrapS:o,wrapT:r}=e.sampler;e.gfxTexture.bindExtraParam(t,i,o,r);}}_(l,"HAS_TEXTURE_u_baseColorTexture",ji.BaseColor),_(c,"HAS_TEXTURE_u_metallicRoughnessTexture",ji.MetallicRoughness),_(h,"HAS_TEXTURE_u_normalTexture",ji.Normal),_(u,"HAS_TEXTURE_u_occlusionTexture",ji.Occlusion),_(d,"HAS_TEXTURE_u_emissionTexture",ji.Emission),s&&(s.texture||(s.texture=new e.df(r.context,s.image,[s.image.height,s.image.height,s.image.height],n.gl.RGBA8)),n.activeTexture.set(n.gl.TEXTURE0+ji.LUT),s.texture&&s.texture.bind(n.gl.LINEAR,n.gl.CLAMP_TO_EDGE),t.push("APPLY_LUT_ON_GPU")),o.texcoordBuffer&&(t.push("HAS_ATTRIBUTE_a_uv_2f"),i.push(o.texcoordBuffer)),o.colorBuffer&&(t.push(12===o.colorBuffer.itemSize?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),i.push(o.colorBuffer)),o.normalBuffer&&(t.push("HAS_ATTRIBUTE_a_normal_3f"),i.push(o.normalBuffer)),o.pbrBuffer&&(t.push("HAS_ATTRIBUTE_a_pbr"),t.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),i.push(o.pbrBuffer)),"OPAQUE"!==a.alphaMode&&"MASK"!==a.alphaMode||t.push("UNPREMULT_TEXTURE_IN_SHADER"),a.defined||t.push("DIFFUSE_SHADED"),t.push("USE_STANDARD_DERIVATIVES");}function aa(t,i,o,r,s,a){const n=o.paint.get("model-opacity"),l=i.context,c=new Li(i.context.gl.LEQUAL,Li.ReadWrite,i.depthRangeFor3D),h=i.transform,u=t.mesh,d=u.material,_=d.pbrMetallicRoughness,p=i.style.fog;let m;m="pixels"===i.transform.projection.zAxisUnit?[...t.nodeModelMatrix]:e.a6.mat4.multiply([],r.zScaleMatrix,t.nodeModelMatrix),e.a6.mat4.multiply(m,r.negCameraPosMatrix,m);const f=e.a6.mat4.invert([],m);e.a6.mat4.transpose(f,f);const g=o.paint.get("model-emissive-strength").constantOr(0),v=ns(new Float32Array(t.worldViewProjection),new Float32Array(m),new Float32Array(f),null,i,n,_.baseColorFactor.toRenderColor(null),d.emissiveFactor,_.metallicFactor,_.roughnessFactor,d,g,o),x={defines:[]},y=[];sa(x.defines,y,u,i,o.lut);const b=i.shadowRenderer;b&&(b.useNormalOffset=!1);let w=null;if(p){const e=ra(t.nodeModelMatrix,i.transform);if(w=new Float32Array(e),"globe"!==h.projection.name){const t=u.aabb.min,i=u.aabb.max,[o,r]=p.getOpacityForBounds(e,t[0],t[1],i[0],i[1]);x.overrideFog=o>=Oe||r>=Oe;}}const T=Wi(i,o.paint.get("model-cutoff-fade-range"));T.shouldRenderCutoff&&x.defines.push("RENDER_CUTOFF");const E=i.getOrCreateProgram("model",x);i.uploadCommonUniforms(l,E,null,w,T),"shadow"!==i.renderPass&&b&&b.setupShadowsFromMatrix(t.nodeModelMatrix,E),E.draw(i,l.gl.TRIANGLES,c,s,a,u.material.doubleSided?Fi.disabled:Fi.backCCW,v,o.id,u.vertexBuffer,u.indexBuffer,u.segments,o.paint,i.transform.zoom,void 0,y);}function na(t,i,o,r,s,a,n){let l;l="globe"===t.projection.name?e.dg(o,t):[...o],e.a6.mat4.multiply(l,l,i.matrix);const c=e.a6.mat4.multiply([],r,l);if(i.meshes)for(const t of i.meshes){if("BLEND"!==t.material.alphaMode){n.push({mesh:t,depth:0,modelIndex:s,worldViewProjection:c,nodeModelMatrix:l});continue}const i=e.a6.vec3.transformMat4([],t.centroid,c);i[2]>0&&a.push({mesh:t,depth:i[2],modelIndex:s,worldViewProjection:c,nodeModelMatrix:l});}if(i.children)for(const e of i.children)na(t,e,o,r,s,a,n);}function la(e,t,i,o){const r=i.shadowRenderer;if(!r)return;const s=r.getShadowPassDepthMode(),a=r.getShadowPassColorMode(),n=r.calculateShadowPassMatrixFromMatrix(t),l=ls(n);i.getOrCreateProgram("modelDepth",{defines:i._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(i,i.context.gl.TRIANGLES,s,Mi.disabled,a,Fi.backCCW,l,o.id,e.vertexBuffer,e.indexBuffer,e.segments,o.paint,i.transform.zoom,void 0,void 0);}function ca(t,i,o){const r=i.updateZoomBasedPaintProperties(),s=function(t,i,o){let r,s,a,n=t.terrain?t.terrain.exaggeration():0;if(t.terrain&&n>0){const i=t.terrain,s=i.findDEMTileFor(o);s&&s.dem?r=e.di.create(i,o,s):n=0;}if(0===n&&(i.terrainElevationMin=0,i.terrainElevationMax=0),n===i.validForExaggeration&&(0===n||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;eh&&(h=e.max);}const u=e.ap(r.x,a,n)-r.x,d=e.ap(r.y,l,c)-r.y,_=e.bD(h,i.center.lat)-r.z;return i._zoomFromMercatorZ(Math.sqrt(u*u+d*d+_*_))}function da(e,t,i,o,r,s,a){const n=e.context,l="shadow"===e.renderPass,c=e.shadowRenderer,h=l&&c?c.getShadowPassDepthMode():new Li(n.gl.LEQUAL,Li.ReadWrite,e.depthRangeFor3D),u=e.isTileAffectedByFog(s);if(i.meshes)for(const d of i.meshes){const _=["MODEL_POSITION_ON_GPU"],p=[];let m,f,g;o.instancedDataArray.length>20&&_.push("INSTANCED_ARRAYS");const v=Wi(e,t.paint.get("model-cutoff-fade-range"));if(v.shouldRenderCutoff&&_.push("RENDER_CUTOFF"),l&&c)m=e.getOrCreateProgram("modelDepth",{defines:_}),f=ls(a.shadowTileMatrix,a.shadowTileMatrix,Float32Array.from(i.matrix)),g=c.getShadowPassColorMode();else {sa(_,p,d,e,t.lut),m=e.getOrCreateProgram("model",{defines:_,overrideFog:u});const o=d.material,l=o.pbrMetallicRoughness,h=t.paint.get("model-opacity"),x=t.paint.get("model-emissive-strength").constantOr(0);f=ns(s.expandedProjMatrix,Float32Array.from(i.matrix),new Float32Array(16),null,e,h,l.baseColorFactor.toRenderColor(null),o.emissiveFactor,l.metallicFactor,l.roughnessFactor,o,x,t,r),c&&(a.shadowUniformsInitialized?m.setShadowUniformValues(n,c.getShadowUniformValues()):(c.setupShadows(s.toUnwrapped(),m,"model-tile",s.overscaledZ),a.shadowUniformsInitialized=!0)),g=v.shouldRenderCutoff||h<1||"OPAQUE"!==o.alphaMode?Ai.alphaBlended:Ai.unblended;}e.uploadCommonUniforms(n,m,s.toUnwrapped(),null,v);const x=d.material.doubleSided?Fi.disabled:Fi.backCCW;if(o.instancedDataArray.length>20)p.push(o.instancedDataBuffer),m.draw(e,n.gl.TRIANGLES,h,Mi.disabled,g,x,f,t.id,d.vertexBuffer,d.indexBuffer,d.segments,t.paint,e.transform.zoom,void 0,p,o.instancedDataArray.length);else {const i=l?"u_instance":"u_normal_matrix";for(let r=0;rc[1]?n:c,a[0]=o.max[0],n=e.a6.vec4.transformMat4(e.a6.vec4.create(),a,s),l=n[1]c[1]?n:c,a[1]=o.min[1],n=e.a6.vec4.transformMat4(e.a6.vec4.create(),a,s),l=n[1]c[1]?n:c;const h=e.ap(r[0],0,1),u=100*i.pixelsPerMeter*e.ap(r[1],0,1),d=e.ap(r[2],0,1),_=e.a6.vec4.lerp(e.a6.vec4.create(),l,c,h),p=Math.tan(.5*i.fovX),m=-_[2]*p;if(0===u)return _[1]<-Math.abs(m)?d:1;const f=(-Math.abs(m)-_[1])/u,g=(e,t,i)=>(1-i)*e+i*t,v=e.ap(g(1,d,f),d,1);return g(1,v,e.ap((i.pitch-20)/20,0,1))}class ga{}class va{constructor(){this._storage=new Map;}getLinesFromTrianglesBuffer(t,i,o){{const e=this._storage.get(i.id);if(e)return e.lastUsedFrameIdx=t,e.buf}const r=o.gl,s=r.getBufferParameter(r.ELEMENT_ARRAY_BUFFER,r.BUFFER_SIZE),a=new ArrayBuffer(s),n=new Int16Array(a);r.getBufferSubData(r.ELEMENT_ARRAY_BUFFER,0,new Int16Array(a));const l=new e.dk;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 xa{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 ya={symbol:function(t,i,o,r,s){if("translucent"!==t.renderPass)return;const a=Mi.disabled,n=t.colorModeForRenderPass();o.layout.get("text-variable-anchor")&&function(t,i,o,r,s,a,n){const l=i.transform,c="map"===s,h="map"===a;for(const i of t){const t=r.getTile(i),s=t.getBucket(o);if(!s||!s.text||!s.text.segments.get().length)continue;const a=e.bj(s.textSizeData,l.zoom),u=ii(i,s.getProjection(),l),d=l.calculatePixelsToTileUnitsMatrix(t),_=kt(u,t.tileID.canonical,h,c,l,s.getProjection(),d),p=s.hasIconTextFit()&&s.hasIconData();if(a){const o=Math.pow(2,l.zoom-t.tileID.overscaledZ);ys(s,c,h,n,e.cS,l,_,i,o,a,p);}}}(r,t,o,i,o.layout.get("text-rotation-alignment"),o.layout.get("text-pitch-alignment"),s);const l=0!==o.paint.get("icon-opacity").constantOr(1),c=0!==o.paint.get("text-opacity").constantOr(1);void 0!==o.layout.get("symbol-sort-key").constantOr(1)&&(l||c)?bs(t,i,o,r,a,n):(l&&bs(t,i,o,r,a,n,{onlyIcons:!0}),c&&bs(t,i,o,r,a,n,{onlyText:!0})),i.map.showCollisionBoxes&&(fs(t,i,o,r,o.paint.get("text-translate"),o.paint.get("text-translate-anchor"),!0),fs(t,i,o,r,o.paint.get("icon-translate"),o.paint.get("icon-translate-anchor"),!1));},circle:function(t,i,o,r){if("translucent"!==t.renderPass)return;const s=o.paint.get("circle-opacity"),a=o.paint.get("circle-stroke-width"),n=o.paint.get("circle-stroke-opacity"),l=void 0!==o.layout.get("circle-sort-key").constantOr(1),c=o.paint.get("circle-emissive-strength");if(0===s.constantOr(1)&&(0===a.constantOr(1)||0===n.constantOr(1)))return;const h=t.context,u=h.gl,d=t.transform,_=t.depthModeForSublayer(0,Li.ReadOnly),p=Mi.disabled,m=t.colorModeForDrapableLayerRenderPass(c),f="globe"===d.projection.name,g=[e.am(d.center.lng),e.at(d.center.lat)],v=[];for(let s=0;se.sortKey-t.sortKey));const x={useDepthForOcclusion:d.depthOcclusionForSymbolsAndCircles};for(const e of v){const{programConfiguration:i,program:r,layoutVertexBuffer:s,globeExtVertexBuffer:a,indexBuffer:n,uniformValues:l,tile:c}=e.state,f=e.segments;t.terrain&&t.terrain.setupElevationDraw(c,r,x),t.uploadCommonUniforms(h,r,c.tileID.toUnwrapped()),r.draw(t,u.TRIANGLES,_,p,m,Fi.disabled,l,o.id,s,n,f,o.paint,d.zoom,i,[a]);}},heatmap:function(t,i,o,r){if(0!==o.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const s=t.context,a=s.gl,n=Mi.disabled,l=new Ai([a.ONE,a.ONE,a.ONE,a.ONE],e.bz.transparent,[!0,!0,!0,!0]);!function(e,t,i,o){const r=e.gl,s=t.width*o,a=t.height*o;e.activeTexture.set(r.TEXTURE1),e.viewport.set([0,0,s,a]);let n=i.heatmapFbo;if(!n||n&&(n.width!==s||n.height!==a)){n&&n.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),n=i.heatmapFbo=e.createFramebuffer(s,a,!0,null),function(e,t,i,o,r,s){const a=e.gl;a.texImage2D(a.TEXTURE_2D,0,e.extRenderToTextureHalfFloat?a.RGBA16F:a.RGBA,r,s,0,a.RGBA,e.extRenderToTextureHalfFloat?a.HALF_FLOAT:a.UNSIGNED_BYTE,null),o.colorAttachment.set(i);}(e,0,t,n,s,a);}else r.bindTexture(r.TEXTURE_2D,n.colorAttachment.get()),e.bindFramebuffer.set(n.framebuffer);}(s,t,o,"globe"===t.transform.projection.name?.5:.25),s.clear({color:e.bz.transparent});const c=t.transform,h="globe"===c.projection.name,u=h?["PROJECTION_GLOBE_VIEW"]:[],d=h?Fi.frontCCW:Fi.disabled,_=[e.am(c.center.lng),e.at(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,o));},line:function(t,i,o,r){if("translucent"!==t.renderPass)return;const s=o.paint.get("line-opacity"),a=o.paint.get("line-width");if(0===s.constantOr(1)||0===a.constantOr(1))return;const n=o.paint.get("line-emissive-strength"),l=o.paint.get("line-occlusion-opacity"),c=t.context,h=c.gl,u=o.layout.get("line-z-offset"),d=!u.isConstant()||!!u.constantOr(0),_=d?new Li(t.depthOcclusion?h.GREATER:h.LEQUAL,Li.ReadOnly,t.depthRangeFor3D):t.depthModeForSublayer(0,Li.ReadOnly),p=t.colorModeForDrapableLayerRenderPass(n),m=t.terrain&&t.terrain.renderingToTexture,f=m?1:e.q.devicePixelRatio,g=o.paint.get("line-dasharray"),v=g.constantOr(1),x=o.layout.get("line-cap"),y=g.constantOr(null),b=x.constantOr(null),w=o.paint.get("line-pattern"),T=w.constantOr(1),E=w.constantOr(null),C=o.paint.get("line-opacity").constantOr(1);let S=!T&&1!==C||t.depthOcclusion&&l>0&&l<1;const I=o.paint.get("line-gradient"),D=T?"linePattern":"line",R=e.cV(o);let A;if(m&&t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(S=!1),0!==l&&t.depthOcclusion){const t=o.paint._values["line-opacity"];t&&t.value&&"constant"===t.value.kind?A=t.value:e.w(`Occlusion opacity for layer ${o.id} is supported only when line-opacity isn't data-driven.`);}if(d&&(t.forceTerrainMode=!0),!d&&0!==l&&t.terrain&&!m)return void e.w(`Occlusion opacity for layer ${o.id} is supported on terrain only if the layer has non-zero line-z-offset.`);const L=S&&d?t.stencilModeFor3D():Mi.disabled;for(const s of r){const r=i.getTile(s);if(T&&!r.patternsLoaded())continue;const a=r.getBucket(o);if(!a)continue;t.prepareDrawTile();const n=a.programConfigurations.get(o.id),u=t.isTileAffectedByFog(s),g=t.getOrCreateProgram(D,{config:n,defines:d?[...R,"ELEVATED"]:R,overrideFog:u});if(E&&r.imageAtlas){const e=r.imageAtlas.patternPositions[E.toString()];e&&n.setConstantPatternPositions(e);}if(!T&&y&&b&&r.lineAtlas){const e=r.lineAtlas.getDash(y,b);e&&n.setConstantPatternPositions(e);}let[x,w]=o.paint.get("line-trim-offset");if("round"===b||"square"===b){const e=1;x!==w&&(0===x&&(x-=e),1===w&&(w+=e));}const P=m?s.projMatrix:null,M=T?e.cW(t,r,o,P,f,[x,w]):e.cX(t,r,o,P,a.lineClipsArray.length,f,[x,w]);if(I){const r=a.gradients[o.id];let n=r.texture;if(o.gradientVersion!==r.version){let l=256;if(o.stepInterpolant){const o=i.getSource().maxzoom,r=s.canonical.z===o?Math.ceil(1<{null!=A&&(A.value=C*l),g.draw(t,h.TRIANGLES,_,e,p,Fi.disabled,M,o.id,a.layoutVertexBuffer,a.indexBuffer,a.segments,o.paint,t.transform.zoom,n,[a.layoutVertexBuffer2,a.patternVertexBuffer,a.zOffsetVertexBuffer]),null!=A&&(A.value=C);};if(S&&!d){const e=t.stencilModeForClipping(s).ref;0===e&&m&&c.clear({stencil:0});const i={func:h.EQUAL,mask:255};M.u_alpha_discard_threshold=.8,z(new Mi(i,e,255,h.KEEP,h.KEEP,h.INVERT)),M.u_alpha_discard_threshold=0,z(new Mi(i,e,255,h.KEEP,h.KEEP,h.KEEP));}else S&&d&&(M.u_alpha_discard_threshold=.001),z(d?L:t.stencilModeForClipping(s));}S&&(t.resetStencilClippingMasks(),m&&c.clear({stencil:0})),0===l||t.depthOcclusion||m||t.layersWithOcclusionOpacity.push(t.currentLayer),d&&(t.forceTerrainMode=!1);},fill:function(t,i,o,r){const s=o.paint.get("fill-color"),a=o.paint.get("fill-opacity"),n=o.is3D(),l=new Li(t.context.gl.LEQUAL,Li.ReadWrite,t.depthRangeFor3D);if(0===a.constantOr(1))return;const c=o.paint.get("fill-emissive-strength"),h=t.colorModeForDrapableLayerRenderPass(c),u=o.paint.get("fill-pattern"),d=t.opaquePassEnabledForLayer()&&!u.constantOr(1)&&1===s.constantOr(e.bz.transparent).a&&1===a.constantOr(0)?"opaque":"translucent";if(t.renderPass===d){const e=n?l:t.depthModeForSublayer(1,"opaque"===t.renderPass?Li.ReadWrite:Li.ReadOnly);Ts(t,i,o,r,e,h,!1);}if(!n&&"translucent"===t.renderPass&&o.paint.get("fill-antialias")){const e=n?l:t.depthModeForSublayer(o.getPaintProperty("fill-outline-color")?2:0,Li.ReadOnly);Ts(t,i,o,r,e,h,!0);}},"fill-extrusion":function(t,i,o,r){const s=o.paint.get("fill-extrusion-opacity"),a=t.context,n=a.gl,l=t.terrain,c=l&&l.renderingToTexture;if(0===s)return;const h=t.conflationActive&&t.style.isLayerClipped(o,i.getSource()),u=t.style.order.indexOf(o.fqid);if(h&&function(e,t,i,o,r){for(const s of o){const o=t.getTile(s).getBucket(i);o&&(o.updateReplacement(s,e.replacementSource,r),o.uploadCentroid(e.context));}}(t,i,o,r,u),l||h)for(const e of r){const r=i.getTile(e).getBucket(o);r&&Ss(t.context,i,e,r,o,l,h);}if("shadow"===t.renderPass&&t.shadowRenderer){const a=t.shadowRenderer;if(l&&s<.65&&o._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof e.a4)return;const n=a.getShadowPassDepthMode(),c=a.getShadowPassColorMode();Es(t,i,o,r,n,Mi.disabled,c,h);}else if("translucent"===t.renderPass){const u=!o.paint.get("fill-extrusion-pattern").constantOr(1),d=o.paint.get("fill-extrusion-color").constantOr(e.bz.white);if(!c&&0!==d.a){const e=new Li(t.context.gl.LEQUAL,Li.ReadWrite,t.depthRangeFor3D);1===s&&u?Es(t,i,o,r,e,Mi.disabled,Ai.unblended,h):(Es(t,i,o,r,e,Mi.disabled,Ai.disabled,h),Es(t,i,o,r,e,t.stencilModeFor3D(),t.colorModeForRenderPass(),h),t.resetStencilClippingMasks());}if(t.style.enable3dLights()&&u&&(!l&&"globe"!==t.transform.projection.name||c)){const s=o.paint.get("fill-extrusion-opacity"),u=o.paint.get("fill-extrusion-ambient-occlusion-intensity"),d=o.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),_=o.paint.get("fill-extrusion-flood-light-intensity"),p=o.paint.get("fill-extrusion-flood-light-color").toRenderColor(o.lut).toArray01().slice(0,3),m=u>0&&d>0,f=_>0,g=(e,t,i)=>(1-i)*e+i*t,v=a=>{const l=t.depthModeForSublayer(1,Li.ReadOnly,n.LEQUAL,!0),c=o.paint.get(a?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),m=g(.1,3,c),f=t._showOverdrawInspector;if(!f){const c=new Mi({func:n.ALWAYS,mask:255},255,255,n.KEEP,n.KEEP,n.REPLACE),f=new Ai([n.ONE,n.ONE,n.ONE,n.ONE],e.bz.transparent,[!1,!1,!1,!0],n.MIN);Cs(t,i,o,r,l,c,f,Fi.disabled,a,"sdf",s,u,d,_,p,m,h,!1);}{const c=f?Mi.disabled:new Mi({func:n.EQUAL,mask:255},255,255,n.KEEP,n.DECR,n.DECR),g=f?t.colorModeForRenderPass():new Ai([n.ONE_MINUS_DST_ALPHA,n.DST_ALPHA,n.ONE,n.ONE],e.bz.transparent,[!0,!0,!0,!0]);Cs(t,i,o,r,l,c,g,Fi.disabled,a,"color",s,u,d,_,p,m,h,!1);}};if(c){const c=(a,l,c)=>{const m=t.depthModeForSublayer(1,Li.ReadOnly,n.LEQUAL,!1),f=o.paint.get(a?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),v=g(.1,3,f);{const c=new Ai([n.ONE,n.ONE,n.ONE,n.ONE],e.bz.transparent,[!1,!1,!1,!0]);Cs(t,i,o,r,m,Mi.disabled,c,Fi.disabled,a,"clear",s,u,d,_,p,v,h,l);}{const c=new Mi({func:n.ALWAYS,mask:255},255,255,n.KEEP,n.KEEP,n.REPLACE),f=new Ai([n.ONE,n.ONE,n.ONE,n.ONE],e.bz.transparent,[!1,!1,!1,!0],n.MIN);Cs(t,i,o,r,m,c,f,Fi.disabled,a,"sdf",s,u,d,_,p,v,h,l);}{const c=a?n.ZERO:n.ONE_MINUS_DST_ALPHA,f=new Mi({func:n.EQUAL,mask:255},255,255,n.KEEP,n.DECR,n.DECR),g=new Ai([c,n.DST_ALPHA,n.ONE_MINUS_DST_ALPHA,n.ZERO],e.bz.transparent,[!0,!0,!0,!0]);Cs(t,i,o,r,m,f,g,Fi.disabled,a,"color",s,u,d,_,p,v,h,l);}{const f=new Ai([n.ONE,n.ONE,n.ONE,a?n.ZERO:n.ONE],e.bz.transparent,[!1,!1,!1,!0],a?n.FUNC_ADD:n.MAX);Cs(t,i,o,r,m,Mi.disabled,f,Fi.disabled,a,"clear",s,u,d,_,p,v,h,l,c);}};if(m||f){let i;if(t.prepareDrawTile(),l){const t=l.drapeBufferSize[0],o=l.drapeBufferSize[1];i=l.framebufferCopyTexture,i&&(!i||i.size[0]===t&&i.size[1]===o)||(i&&i.destroy(),i=l.framebufferCopyTexture=new e.T(a,new e.r({width:t,height:o}),n.RGBA8)),i.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.copyTexImage2D(n.TEXTURE_2D,0,n.RGBA,0,0,t,o,0);}m&&c(!0,!1,i),f&&c(!1,!0,i);}}else m&&v(!0),f&&v(!1),(m||f)&&t.resetStencilClippingMasks();}}},hillshade:function(e,t,i,o){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;if(e.style.disableElevatedTerrain)return;const r=e.context,s=e.terrain&&e.terrain.renderingToTexture,[a,n]="translucent"!==e.renderPass||s?[{},o]:e.stencilConfigForOverlap(o);for(const o of n){const r=t.getTile(o);if(r.needsHillshadePrepare&&"offscreen"===e.renderPass)zo(e,r,i);else if("translucent"===e.renderPass){const t=e.depthModeForSublayer(0,Li.ReadOnly),n=i.paint.get("hillshade-emissive-strength"),l=e.colorModeForDrapableLayerRenderPass(n),c=s&&e.terrain?e.terrain.stencilModeForRTTOverlap(o):a[o.overscaledZ];Po(e,o,r,i,t,c,l);}}r.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks();},raster:function(t,i,o,r,s,a){if("translucent"!==t.renderPass)return;if(0===o.paint.get("raster-opacity"))return;const n="globe"===t.transform.projection.name,l=0!==o.paint.get("raster-elevation"),c=l&&n;if(t.renderElevatedRasterBackface&&!c)return;const h=t.context,u=h.gl,d=i.getSource(),_=function(t,i,o,r){const s=i.paint.get("raster-color"),a="raster-array"===t.type,n=[],l=i.paint.get("raster-resampling"),c=i.paint.get("raster-color-mix");let h=i.paint.get("raster-color-range");const u=[c[0],c[1],c[2],0],d=c[3];let _="nearest"===l?r.NEAREST:r.LINEAR;if(a&&(n.push("RASTER_ARRAY"),s||n.push("RASTER_COLOR"),"linear"===l&&n.push("RASTER_ARRAY_LINEAR"),_=r.NEAREST,!h&&t.rasterLayers)){const e=t.rasterLayers.find((({id:e})=>e===i.sourceLayer));e&&e.fields&&e.fields.range&&(h=e.fields.range);}if(h=h||[0,1],s){n.push("RASTER_COLOR"),o.activeTexture.set(r.TEXTURE2),i.updateColorRamp(h);let t=i.colorRampTexture;t||(t=i.colorRampTexture=new e.T(o,i.colorRamp,r.RGBA8)),t.bind(r.LINEAR,r.CLAMP_TO_EDGE);}return {mix:u,range:h,offset:d,defines:n,resampling:_}}(d,o,h,u);if(d instanceof e.aD&&!r.length&&!n)return;const p=o.paint.get("raster-emissive-strength"),m=t.colorModeForDrapableLayerRenderPass(p),f=t.terrain&&t.terrain.renderingToTexture,g=!t.options.moving,v="nearest"===o.paint.get("raster-resampling")?u.NEAREST:u.LINEAR;if(d instanceof e.aD&&!r.length&&(d.onNorthPole||d.onSouthPole)){const e=l?t.stencilModeFor3D():Mi.disabled;return void Ps(!!d.onNorthPole,null,t,i,o,p,_,Fi.disabled,e)}if(!r.length)return;const[x,y]=d instanceof e.aD||f?[{},r]:t.stencilConfigForOverlap(r),b=y[y.length-1].overscaledZ;c&&_.defines.push("PROJECTION_GLOBE_VIEW"),l&&_.defines.push("RENDER_CUTOFF");const w=(r,s,y)=>{for(const w of r){const r=w.toUnwrapped(),T=i.getTile(w);if(f&&(!T||!T.hasData()))continue;h.activeTexture.set(u.TEXTURE0);const E=zs(T,d,o,_);if(!E||!E.texture)continue;const{texture:C,mix:S,offset:I,tileSize:D,buffer:R}=E;let A,L;f?(A=Li.disabled,L=w.projMatrix):l?(A=new Li(u.LEQUAL,Li.ReadWrite,t.depthRangeFor3D),L=n?Float32Array.from(t.transform.expandedFarZProjMatrix):t.transform.calculateProjMatrix(r,g)):(A=t.depthModeForSublayer(w.overscaledZ-b,1===o.paint.get("raster-opacity")?Li.ReadWrite:Li.ReadOnly,u.LESS),L=t.transform.calculateProjMatrix(r,g));const P=t.terrain&&f?t.terrain.stencilModeForRTTOverlap(w):x[w.overscaledZ],M=a?0:o.paint.get("raster-fade-duration");T.registerFadeDuration(M);const z=i.findLoadedParent(w,0),O=Sr(T,z,i,t.transform,M);let F,k;t.terrain&&t.terrain.prepareDrawTile(),h.activeTexture.set(u.TEXTURE0),C.bind(v,u.CLAMP_TO_EDGE),h.activeTexture.set(u.TEXTURE1),z?(z.texture&&z.texture.bind(v,u.CLAMP_TO_EDGE),F=Math.pow(2,z.tileID.overscaledZ-T.tileID.overscaledZ),k=[T.tileID.canonical.x*F%1,T.tileID.canonical.y*F%1]):C.bind(v,u.CLAMP_TO_EDGE),C.useMipmap&&h.extTextureFilterAnisotropic&&t.transform.pitch>20&&u.texParameterf(u.TEXTURE_2D,h.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,h.extTextureFilterAnisotropicMax);const B=t.transform;let N;const U=l?Ms(B):[0,0,0,0];let G,j,V,q,Z,H=0;if(c&&d instanceof e.aD&&d.coordinates.length>3)G=Float32Array.from(e.b5(e.cC(new e.bP(0,0,0)))),j=Float32Array.from(B.globeMatrix),V=Float32Array.from(e.cy(B)),q=[e.am(B.center.lng),e.at(B.center.lat)],N=d.elevatedGlobePerspectiveTransform,Z=d.elevatedGlobeGridMatrix||new Float32Array(9);else if(c){const t=e.cz(w.canonical);H=e.cA(t.getCenter().lat),G=Float32Array.from(e.b5(e.cC(w.canonical))),j=Float32Array.from(B.globeMatrix),V=Float32Array.from(e.cy(B)),q=[e.am(B.center.lng),e.at(B.center.lat)],N=[0,0],Z=Float32Array.from(e.cB(w.canonical,t,H,B.worldSize/B._pixelsPerMercatorPixel));}else N=d instanceof e.aD?d.perspectiveTransform:[0,0],G=new Float32Array(16),j=new Float32Array(9),V=new Float32Array(16),q=[0,0],Z=new Float32Array(9);const W=Yr(L,G,j,V,Z,k||[0,0],e.a9(t.transform.zoom),q,U,F||1,O,o,N,l?o.paint.get("raster-elevation"):0,2,S,I,_.range,D,R,p),$=t.isTileAffectedByFog(w),X=t.getOrCreateProgram("raster",{defines:_.defines,overrideFog:$});if(t.uploadCommonUniforms(h,X,r),d instanceof e.aD){const i=d.elevatedGlobeVertexBuffer,r=d.elevatedGlobeIndexBuffer;if(f||!n)d.boundsBuffer&&d.boundsSegments&&X.draw(t,u.TRIANGLES,A,Mi.disabled,m,Fi.disabled,W,o.id,d.boundsBuffer,t.quadTriangleIndexBuffer,d.boundsSegments);else if(i&&r){const a=B.zoom<=e.c2?d.elevatedGlobeSegments:d.getSegmentsForLongitude(B.center.lng);a&&X.draw(t,u.TRIANGLES,A,Mi.disabled,m,s,W,o.id,i,r,a);}}else if(c){A=new Li(u.LEQUAL,Li.ReadOnly,t.depthRangeFor3D);const e=t.globeSharedBuffers;if(e){const[i,r,a]=e.getGridBuffers(H,!1);X.draw(t,u.TRIANGLES,A,y||P,t.colorModeForRenderPass(),s,W,o.id,i,r,a);}}else {const{tileBoundsBuffer:e,tileBoundsIndexBuffer:i,tileBoundsSegments:r}=t.getTileBoundsBuffers(T);X.draw(t,u.TRIANGLES,A,P,m,Fi.disabled,W,o.id,e,i,r);}}if(!(d instanceof e.aD)&&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.c$[t](r)));p.push(r);const m=r.canonical.x,f=r.canonical.y;for(const e of p){const s=i.getTile(l?e.wrapped():e);if(!s)continue;const n=s.rasterParticleState;if(!n)continue;const h=e.canonical.x+(1<e.tileID))),_&&(c.activeTexture.set(h.TEXTURE0),t.imageManager.bind(t.context,o.scope)),l){const i=t.getOrCreateProgram(x,{overrideFog:!1,overrideRtt:!0}),r=new Float32Array(e.a6.mat4.identity([])),c=new e.aA(0,0,0,0,0),u=_?ss(r,n,a,t,0,o.scope,p,l,{tileID:c,tileSize:d}):rs(r,n,a,s.toRenderColor(o.lut));i.draw(t,h.TRIANGLES,g,f,v,Fi.disabled,u,o.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments);}else for(const e of b){const m=t.isTileAffectedByFog(e),b=t.getOrCreateProgram(x,{overrideFog:m}),w=e.toUnwrapped(),T=r?e.projMatrix:t.transform.calculateProjMatrix(w);t.prepareDrawTile();const E=i?i.getTile(e):y?y[e.key]:new pt(e,d,u.zoom,t),C=_?ss(T,n,a,t,0,o.scope,p,l,{tileID:e,tileSize:d}):rs(T,n,a,s.toRenderColor(o.lut));t.uploadCommonUniforms(c,b,w);const{tileBoundsBuffer:S,tileBoundsIndexBuffer:I,tileBoundsSegments:D}=t.getTileBoundsBuffers(E);b.draw(t,h.TRIANGLES,g,f,v,Fi.disabled,C,o.id,S,I,D);}},sky:function(t,i,o){const r=t._atmosphere?e.a9(t.transform.zoom):1,s=o.paint.get("sky-opacity")*r;if(0===s)return;const a=t.context,n=o.paint.get("sky-type"),l=new Li(a.gl.LEQUAL,Li.ReadOnly,[0,1]),c=t.frameCounter/1e3%1;"atmosphere"===n?"offscreen"===t.renderPass?o.needsSkyboxCapture(t)&&(function(t,i,o,r){const s=t.context,a=s.gl;let n=i.skyboxFbo;if(!n){n=i.skyboxFbo=s.createFramebuffer(32,32,!0,null),i.skyboxGeometry=new Ks(s),i.skyboxTexture=s.gl.createTexture(),a.bindTexture(a.TEXTURE_CUBE_MAP,i.skyboxTexture),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MAG_FILTER,a.LINEAR);for(let e=0;e<6;++e)a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,a.RGBA,32,32,0,a.RGBA,a.UNSIGNED_BYTE,null);}s.bindFramebuffer.set(n.framebuffer),s.viewport.set([0,0,32,32]);const l=i.getCenter(t,!0),c=t.getOrCreateProgram("skyboxCapture"),h=new Float64Array(16);e.a6.mat4.identity(h),e.a6.mat4.rotateY(h,h,.5*-Math.PI),Js(t,i,c,h,l,0),e.a6.mat4.identity(h),e.a6.mat4.rotateY(h,h,.5*Math.PI),Js(t,i,c,h,l,1),e.a6.mat4.identity(h),e.a6.mat4.rotateX(h,h,.5*-Math.PI),Js(t,i,c,h,l,2),e.a6.mat4.identity(h),e.a6.mat4.rotateX(h,h,.5*Math.PI),Js(t,i,c,h,l,3),e.a6.mat4.identity(h),Js(t,i,c,h,l,4),e.a6.mat4.identity(h),e.a6.mat4.rotateY(h,h,Math.PI),Js(t,i,c,h,l,5),s.viewport.set([0,0,t.width,t.height]);}(t,o),o.markSkyboxValid(t)):"sky"===t.renderPass&&function(e,t,i,o,r){const s=e.context,a=s.gl,n=e.transform,l=e.getOrCreateProgram("skybox");s.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_CUBE_MAP,t.skyboxTexture);const c=((e,t,i,o,r)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:o,u_temporal_offset:r}))(n.skyboxMatrix,t.getCenter(e,!1),0,o,r);e.uploadCommonUniforms(s,l),l.draw(e,a.TRIANGLES,i,Mi.disabled,e.colorModeForRenderPass(),Fi.backCW,c,"skybox",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment);}(t,o,l,s,c):"gradient"===n&&"sky"===t.renderPass&&function(t,i,o,r,s){const a=t.context,n=a.gl,l=t.transform,c=t.getOrCreateProgram("skyboxGradient");i.skyboxGeometry||(i.skyboxGeometry=new Ks(a)),a.activeTexture.set(n.TEXTURE0);let h=i.colorRampTexture;h||(h=i.colorRampTexture=new e.T(a,i.colorRamp,n.RGBA8)),h.bind(n.LINEAR,n.CLAMP_TO_EDGE);const u=((t,i,o,r,s)=>({u_matrix:t,u_color_ramp:0,u_center_direction:i,u_radius:e.bB(o),u_opacity:r,u_temporal_offset:s}))(l.skyboxMatrix,i.getCenter(t,!1),i.paint.get("sky-gradient-radius"),r,s);t.uploadCommonUniforms(a,c),c.draw(t,n.TRIANGLES,o,Mi.disabled,t.colorModeForRenderPass(),Fi.backCW,u,"skyboxGradient",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment);}(t,o,l,s,c);},debug:function(t,i,o,r,s,a){for(let n=0;n{n&&(n.useNormalOffset=!0,l||(n.enabled=!0));},h=i.getSource();if("light-beam"===t.renderPass&&"batched-model"!==h.type)return;if("vector"===h.type||"geojson"===h.type)return function(t,i,o,r,s){const a=t.transform;if("mercator"!==a.projection.name)return void e.w(`Drawing 3D models for ${a.projection.name} projection is not yet implemented`);const n=a.getFreeCameraOptions().position;if(!t.modelManager)return;const l=t.modelManager;o.modelManager=l;const c=t.shadowRenderer;if(!o._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const h=o._unevaluatedLayout._values["model-id"],u={...o.layout.get("model-id").parameters},d=t.style.order.indexOf(o.fqid);for(const _ of r){const r=i.getTile(_).getBucket(o);if(!r||r.projection.name!==a.projection.name)continue;const p=r.getModelUris();p&&!r.modelsRequested&&(l.addModelsFromBucket(p,s),r.modelsRequested=!0);const m=ua(_,a);u.zoom=m;const f=h.possiblyEvaluate(u);if(ca(t,r,_),ha.shadowUniformsInitialized=!1,ha.useSingleShadowCascade=!!c&&0===c.getMaxCascadeForTile(_.toUnwrapped()),"shadow"===t.renderPass&&c){if(1===t.currentShadowCascade&&r.isInsideFirstShadowMapFrustum)continue;const i=a.calculatePosMatrix(_.toUnwrapped(),a.worldSize);if(ha.tileMatrix.set(i),ha.shadowTileMatrix=Float32Array.from(c.calculateShadowPassMatrixFromMatrix(i)),ha.aabb.min.fill(0),ha.aabb.max[0]=ha.aabb.max[1]=e.ab,ha.aabb.max[2]=0,pa(r,ha,t,o.scope))continue}const g=1<<_.canonical.z,v=[((n.x-_.wrap)*g-_.canonical.x)*e.ab,(n.y*g-_.canonical.y)*e.ab,n.z*g*e.ab];t.conflationActive&&Object.keys(r.instancesPerModel).length>0&&t.style.isLayerClipped(o,i.getSource())&&r.updateReplacement(_,t.replacementSource,d,s)&&(r.uploaded=!1,r.upload(t.context));for(let e in r.instancesPerModel){const i=r.instancesPerModel[e];i.features.length>0&&(e=f.evaluate(i.features[0].feature,{}));const a=l.getModel(e,s);if(a&&a.uploaded)for(const e of a.nodes)da(t,o,e,i,v,_,ha);}}}(t,i,o,r,"vector"===h.type?o.scope:""),void c();if(!h.loaded())return;if("batched-model"===h.type)return function(t,i,o,r){o.resetLayerRenderingStats(t);const s=t.context,a=t.transform,n=t.style.fog,l=t.shadowRenderer;if("mercator"!==a.projection.name)return void e.w(`Drawing 3D landmark models for ${a.projection.name} projection is not yet implemented`);const c=t.transform.getFreeCameraOptions().position,h=e.a6.vec3.scale([],[c.x,c.y,c.z],t.transform.worldSize),u=e.a6.vec3.negate([],h),d=e.a6.mat4.identity([]),_=e.de(a.center.lat,a.zoom),p=e.a6.mat4.fromScaling([],[1,1,1/_]);e.a6.mat4.translate(d,d,u);const m=o.paint.get("model-opacity"),f=new Li(s.gl.LEQUAL,Li.ReadWrite,t.depthRangeFor3D),g=new Li(s.gl.LEQUAL,Li.ReadOnly,t.depthRangeFor3D),v=new e.c9([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),x="shadow"===t.renderPass,y=x&&l?l.getCurrentCascadeFrustum():a.getFrustum(a.scaleZoom(a.worldSize)),b=o.paint.get("model-front-cutoff"),w=b[2]<1,T=Wi(t,o.paint.get("model-cutoff-fade-range")),E=o.getLayerRenderingStats();((function(e,t,i,o){const r=e.terrain?e.terrain.exaggeration():0,s=e.transform.zoom;for(const a of o){const o=t.getTile(a).getBucket(i);o&&(e.conflationActive&&o.updateReplacement(a,e.replacementSource),o.evaluateScale(e,i),e.terrain&&r>0&&o.elevationUpdate(e.terrain,r,a,i.source),o.needsReEvaluation(e,s,i)&&o.evaluate(i));}}))(t,i,o,r),function(){let c,u,C;w?(c=r.length-1,u=-1,C=-1):(c=0,u=r.length,C=1);const S=new Float64Array(16),I=e.a6.vec3.create(),D=new e.P(0,0);for(let R=c;R!==u;R+=C){const c=r[R],u=i.getTile(c).getBucket(o);if(!u||!u.uploaded)continue;let C=!1;l&&(C=0===l.getMaxCascadeForTile(c.toUnwrapped()));const A=a.calculatePosMatrix(c.toUnwrapped(),a.worldSize),L=u.modelTraits;!x&&w&&(e.a6.mat4.invert(S,A),e.a6.vec3.transformMat4(I,h,S),D.x=I[0],D.y=I[1]);const P=[];for(const i of u.getNodesInfo()){if(i.hiddenByReplacement)continue;if(!i.node.meshes)continue;const o=i.node;let r=0;t.terrain&&o.elevation&&(r=o.elevation*t.terrain.exaggeration());const s=(()=>{const t=i.aabb;return v.min=[...t.min],v.max=[...t.max],v.min[2]+=r,v.max[2]+=r,e.a6.vec3.transformMat4(v.min,v.min,A),e.a6.vec3.transformMat4(v.max,v.max,A),v})(),n=i.evaluatedScale;if(n[0]<=1&&n[1]<=1&&n[2]<=1&&0===s.intersects(y))continue;if(!x&&w){const t=1/6;i.cameraCollisionOpacity=h[0]>s.min[0]&&h[0]s.min[1]&&h[1]!w||1===e.opacity&&1===t.opacity?e.deptht.depth?-1:1));for(const i of P){const r=i.nodeInfo,c=r.node;let h=e.a6.mat4.multiply([],p,i.tileModelMatrix);e.a6.mat4.multiply(h,d,h);const u=e.a6.mat4.invert([],h);e.a6.mat4.transpose(u,u),e.a6.mat4.scale(u,u,_a),h=e.a6.mat4.multiply(h,h,c.matrix);const _="light-beam"===t.renderPass,m=L&e.dj.HasMapboxMeshFeatures,v=m?0:r.evaluatedRMEA[0][2];for(let e=0;e=Oe||r>=Oe;}}const S=d.material;let I;S.occlusionTexture&&S.occlusionTexture.offsetScale&&(I=S.occlusionTexture.offsetScale,b.defines.push("OCCLUSION_TEXTURE_TRANSFORM")),!x&&l&&(l.useNormalOffset=!!d.normalBuffer);const D=t.getOrCreateProgram("model",b);!x&&l&&l.setupShadowsFromMatrix(i.tileModelMatrix,D,l.useNormalOffset),t.uploadCommonUniforms(s,D,null,T);const R=S.pbrMetallicRoughness;R.metallicFactor=.9,R.roughnessFactor=.5;const A=ns(new Float32Array(y),new Float32Array(h),new Float32Array(u),new Float32Array(c.matrix),t,i.opacity,R.baseColorFactor.toRenderColor(null),S.emissiveFactor,R.metallicFactor,R.roughnessFactor,S,v,o,[0,0,0],I);!p&&(r.hasTranslucentParts||i.opacity<1)&&D.draw(t,s.gl.TRIANGLES,f,Mi.disabled,Ai.disabled,Fi.backCCW,A,o.id,d.vertexBuffer,d.indexBuffer,d.segments,o.paint,t.transform.zoom,void 0,w),D.draw(t,s.gl.TRIANGLES,p?g:f,Mi.disabled,p||i.opacity<1||r.hasTranslucentParts?Ai.alphaBlended:Ai.unblended,Fi.backCCW,A,o.id,d.vertexBuffer,d.indexBuffer,d.segments,o.paint,t.transform.zoom,void 0,w);}}}}();}(t,i,o,r),void c();if("model"!==h.type)return;const u=h.getModels(),d=[],_=t.transform.getFreeCameraOptions().position,p=e.a6.vec3.scale([],[_.x,_.y,_.z],t.transform.worldSize);e.a6.vec3.negate(p,p);const m=[],f=[];let g=0;for(const i of u){const r=o.paint.get("model-rotation").constantOr(null),s=o.paint.get("model-scale").constantOr(null),a=o.paint.get("model-translation").constantOr(null);i.computeModelMatrix(t,r,s,a,!0,!0,!1);const n=e.a6.mat4.identity([]),l=e.de(i.position.lat,t.transform.zoom),c=e.a6.mat4.fromScaling([],[1,1,1/l]);e.a6.mat4.translate(n,n,p),d.push({zScaleMatrix:c,negCameraPosMatrix:n});for(const e of i.nodes)na(t.transform,e,i.matrix,t.transform.expandedFarZProjMatrix,g,m,f);g++;}if(m.sort(((e,t)=>t.depth-e.depth)),"shadow"!==t.renderPass){if(1===s)for(const e of f)aa(e,t,o,d[e.modelIndex],Mi.disabled,t.colorModeForRenderPass());else {for(const e of f)aa(e,t,o,d[e.modelIndex],Mi.disabled,Ai.disabled);for(const e of f)aa(e,t,o,d[e.modelIndex],t.stencilModeFor3D(),t.colorModeForRenderPass());t.resetStencilClippingMasks();}for(const e of m)aa(e,t,o,d[e.modelIndex],Mi.disabled,t.colorModeForRenderPass());c();}else {for(const e of f)la(e.mesh,e.nodeModelMatrix,t,o);for(const e of m)la(e.mesh,e.nodeModelMatrix,t,o);c();}}},ba={model:function(e,t,i){const o=t.getSource();if(!o.loaded())return;if("vector"===o.type||"geojson"===o.type)return void(i.modelManager&&i.modelManager.upload(i,"vector"===o.type?e.scope:""));if("batched-model"===o.type)return;if("model"!==o.type)return;const r=o.getModels();for(const e of r)e.upload(i.context);},raster:function(e,t,i){const o=t.getSource();if(!(o instanceof Qe&&o.loaded()))return;const r=e.sourceLayer||o.rasterLayerIds&&o.rasterLayerIds[0];if(!r)return;const s=e.paint.get("raster-array-band")||o.getInitialBand(r);if(null==s)return;const a=t.getIds().map((e=>t.getTileByID(e)));for(const e of a)e.updateNeeded(r,s)&&o.prepareTile(e,r,s);},"raster-particle":function(e,t,i){const o=t.getSource();if(!(o instanceof Qe&&o.loaded()))return;const r=e.sourceLayer||o.rasterLayerIds&&o.rasterLayerIds[0];if(!r)return;const s=e.paint.get("raster-particle-array-band")||o.getInitialBand(r);if(null==s)return;const a=t.getIds().map((e=>t.getTileByID(e)));for(const e of a)e.updateNeeded(r,s)&&o.prepareTile(e,r,s);}};class wa{constructor(t,i,o,r){this.context=new ps(t,i),this.transform=o,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.tp=r,this._timeStamp=e.q.now(),this._averageFPS=0,this._fpsHistory=[],this._dt=0,this._debugParams={showTerrainProxyTiles:!1,fpsWindow:30,continousRedraw:!1,enabledLayers:{}};const s=["fill","line","symbol","circle","heatmap","fill-extrusion","raster","raster-particle","hillshade","model","background","sky"];for(const e of s)this._debugParams.enabledLayers[e]=!0;r.registerParameter(this._debugParams,["Terrain"],"showTerrainProxyTiles",{},(()=>{this.style.map.triggerRepaint();})),r.registerParameter(this._debugParams,["FPS"],"fpsWindow",{min:1,max:100,step:1}),r.registerBinding(this._debugParams,["FPS"],"continousRedraw",{readonly:!0,label:"continuous redraw"}),r.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"value"}),r.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"graph",view:"graph",min:0,max:200});for(const e of s)r.registerParameter(this._debugParams.enabledLayers,["Debug","Layers"],e);this.occlusionParams=new xa(r),this.setup(),this.numSublayers=vt.maxUnderzooming+vt.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.dl,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new Ki(this),this._wireframeDebugCache=new va,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const a=new e.r({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new e.T(this.context,a,t.RGBA8),this._clippingActiveLastFrame=!1;}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 Ar(this,e));const o=this._terrain;this.transform.elevation=i?o:null,o.update(e,this.transform,t),this.transform.elevation&&!o.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,o]=t.getFovAdjustedRange(this.transform._fov);if(i>o)return void(this.transform.fogCullDistSq=null);const r=i+.78*(o-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 Ar(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.q.devicePixelRatio,this.height=i*e.q.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.a_;i.emplaceBack(0,0),i.emplaceBack(e.ab,0),i.emplaceBack(0,e.ab),i.emplaceBack(e.ab,e.ab),this.tileExtentBuffer=t.createVertexBuffer(i,e.b0.members),this.tileExtentSegments=e.b1.simpleSegment(0,0,4,2);const o=new e.a_;o.emplaceBack(0,0),o.emplaceBack(e.ab,0),o.emplaceBack(0,e.ab),o.emplaceBack(e.ab,e.ab),this.debugBuffer=t.createVertexBuffer(o,e.b0.members),this.debugSegments=e.b1.simpleSegment(0,0,4,5);const r=new e.a_;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(-1,1),r.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(r,e.b0.members),this.viewportSegments=e.b1.simpleSegment(0,0,4,2);const s=new e.aN;s.emplaceBack(0,0,0,0),s.emplaceBack(e.ab,0,e.ab,0),s.emplaceBack(0,e.ab,0,e.ab),s.emplaceBack(e.ab,e.ab,e.ab,e.ab),this.mercatorBoundsBuffer=t.createVertexBuffer(s,e.b3.members),this.mercatorBoundsSegments=e.b1.simpleSegment(0,0,4,2);const a=new e.aO;a.emplaceBack(0,1,2),a.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(a);const n=new e.a$;for(const e of [0,1,3,2,0])n.emplaceBack(e);this.debugIndexBuffer=t.createIndexBuffer(n),this.emptyTexture=new e.T(t,new e.r({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA8),this.identityMat=e.a6.mat4.create();const l=this.context.gl;this.stencilClearMode=new Mi({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,Li.disabled,this.stencilClearMode,Ai.disabled,Fi.disabled,Cr(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 o=this.context,r=o.gl;this.nextStencilID+i.length>256&&this.clearStencil(),o.setColorMode(Ai.disabled),o.setDepthMode(Li.disabled);const s=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const e of i){const i=t.getTile(e),o=this._tileClippingMaskIDs[e.key]=this.nextStencilID++,{tileBoundsBuffer:a,tileBoundsIndexBuffer:n,tileBoundsSegments:l}=this.getTileBoundsBuffers(i);s.draw(this,r.TRIANGLES,Li.disabled,new Mi({func:r.ALWAYS,mask:0},o,255,r.KEEP,r.KEEP,r.REPLACE),Ai.disabled,Fi.disabled,Cr(e.projMatrix),"$clipping",a,n,l);}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new Mi({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 Mi({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)),o=i[i.length-1].overscaledZ,r=i[0].overscaledZ-o+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 Ai([i.ONE,i.ONE_MINUS_SRC_ALPHA,i.CONSTANT_ALPHA,i.ONE_MINUS_SRC_ALPHA],new e.bz(0,0,0,void 0===t?0:t),[!0,!0,!0,!0]):this.colorModeForRenderPass()}depthModeForSublayer(e,t,i,o=!1){if(this.depthOcclusion)return new Li(this.context.gl.GREATER,Li.ReadOnly,this.depthRangeFor3D);if(!this.opaquePassEnabledForLayer()&&!o)return Li.disabled;const r=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new Li(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 o=e.q.now();this._dt=o-this._timeStamp,this._timeStamp=o,this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=t.map.repaint,this.style=t,this.options=i;const r=this.style._mergedLayers,s=this.style.order.filter((e=>{const t=r[e];return !(t.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[t.type]}));let a=!1,n=!1;for(const e of s){const t=r[e];"circle"===t.type&&(a=!0),"symbol"===t.type&&(t.hasInitialOcclusionOpacityProperties?n=!0:a=!0);}const l=s.map((e=>r[e])),c=this.style._mergedSourceCaches;this.imageManager=t.imageManager,this.modelManager=t.modelManager,this.symbolFadeChange=t.placement.symbolFadeChange(e.q.now()),this.imageManager.beginFrame();let h=0,u=!1;for(const e in c){const t=c[e];t.used&&(t.prepare(this.context),t.getSource().usedInConflation&&++h);}let d=!1;for(const e of l)e.isHidden(this.transform.zoom)||("clip"===e.type&&(d=!0),this.prepareLayer(e));const _={},p={},m={},f={},g={};for(const e in c){const t=c[e];_[e]=t.getVisibleCoordinates(),p[e]=_[e].slice().reverse(),m[e]=t.getVisibleCoordinates(!0).reverse(),f[e]=t.getShadowCasterCoordinates(),g[e]=t.sortCoordinatesByDistance(_[e]);}const v=e=>{const t=this.style.getLayerSourceCache(e);return t&&t.used?t.getSource():null};if(h||d||this._clippingActiveLastFrame){const t=[],i=[];let o=0;for(const e of l)this.isSourceForClippingOrConflation(e,v(e))&&(t.push(e),i.push(o)),o++;if(t&&(d||t.length>1)||this._clippingActiveLastFrame){d=!1;const o=[];for(let r=0;r0){const e=v(t);e&&(this.minCutoffZoom=Math.max(e.minzoom,this.minCutoffZoom)),t.minzoom&&(this.minCutoffZoom=Math.max(t.minzoom,this.minCutoffZoom));}t.is3D()&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=e),this._lastOcclusionLayer=e);}const x=this.style&&this.style.fog;x?(this._fogVisible=0!==x.getOpacity(this.transform.pitch),this._fogVisible&&"globe"!==this.transform.projection.name&&(this._fogVisible=x.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(m),this.opaquePassCutoff=0);const y=this._shadowRenderer;if(y){y.updateShadowParameters(this.transform,this.style.directionalLight);for(const e in c)for(const t of _[e]){let e={min:0,max:0};this.terrain&&(e=this.terrain.getMinMaxForTile(t)||e),y.addShadowReceiver(t.toUnwrapped(),e.min,e.max);}}if("globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new e.dm(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new oa(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),!U.has(this.context.gl))return;this.renderPass="offscreen";for(const e of l){const i=t.getLayerSourceCache(e);if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;const o=i?p[i.id]:void 0;("custom"===e.type||"raster"===e.type||"raster-particle"===e.type||e.isSky()||o&&o.length)&&this.renderLayer(this,i,e,o);}this.depthRangeFor3D=[0,1-(l.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,f)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const b="globe"===this.transform.projection.name||this.transform.isHorizonVisible(),w=(()=>{if(i.showOverdrawInspector)return e.bz.black;const t=this.style.fog;if(t&&this.transform.projection.supportsFog){const i=this.style.getLut(t.scope);if(!b){const o=t.properties.get("color").toRenderColor(i).toArray01();return new e.bz(...o)}if(b){const o=t.properties.get("space-color").toRenderColor(i).toArray01();return new e.bz(...o)}}return e.bz.transparent})();if(this.context.clear({color:w,depth:1}),this.clearStencil(),this._showOverdrawInspector=i.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&b&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=s.length-1;this.currentLayer>=0;this.currentLayer--){const e=l[this.currentLayer],i=t.getLayerSourceCache(e);if(e.isSky())continue;const o=i?(e.is3D()?g:p)[i.id]:void 0;this._renderTileClippingMasks(e,i,o),this.renderLayer(this,i,e,o);}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&b&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||e.a9(this.transform.zoom)>0)&&("globe"===this.transform.projection.name||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer0&&e.hasShadowPass()&&0==--E&&(y.drawGroundShadows(),this.firstLightBeamLayer<=this.currentLayer)){const e=this.currentLayer;for(this.renderPass="light-beam",this.currentLayer=this.firstLightBeamLayer;this.currentLayer<=e;this.currentLayer++){const e=l[this.currentLayer];if(!e.hasLightBeamPass())continue;const i=t.getLayerSourceCache(e);this.renderLayer(this,i,e,i?p[i.id]:void 0);}this.currentLayer=e,this.renderPass="translucent";}if(this.currentLayer>=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){const e=this.currentLayer;this.depthOcclusion=!0;for(const e of this.layersWithOcclusionOpacity){this.currentLayer=e;const i=l[this.currentLayer],o=t.getLayerSourceCache(i),r=o?p[o.id]:void 0;i.is3D()||this.terrain||this._renderTileClippingMasks(i,o,o?_[o.id]:void 0),this.renderLayer(this,o,i,r);}this.depthOcclusion=!1,this.currentLayer=e,this.renderPass="translucent",this.layersWithOcclusionOpacity=[];}++this.currentLayer;}}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let i=null;l.forEach((e=>{const o=t.getLayerSourceCache(e);o&&!e.isHidden(this.transform.zoom)&&o.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 o=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")):o||r.push("LIGHTING_3D_MODE")),"shadow"===this.renderPass?this._shadowMapDebug||r.push("DEPTH_TEXTURE"):this.shadowRenderer&&(this.shadowRenderer.useNormalOffset?r.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"):r.push("RENDER_SHADOWS","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||o||void 0!==t&&!t||r.push("FOG","FOG_DITHERING"),o&&r.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&r.push("OVERDRAW_INSPECTOR"),r}getOrCreateProgram(e,t){this.cache=this.cache||{};const i=t&&t.defines||[],o=t&&t.config,r=this.currentGlobalDefines(e,t&&t.overrideFog,t&&t.overrideRtt).concat(i),s=zr.cacheKey(Io[e],e,r,o);return this.cache[s]||(this.cache[s]=new zr(this.context,e,Io[e],o,cs[e],r)),this.cache[s]}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 o=this.style.directionalLight,r=this.style.ambientLight;if(o&&r){const s=((t,i,o)=>{const r=t.properties.get("direction"),s=t.properties.get("color").toRenderColor(o.getLut(t.scope)).toArray01(),a=t.properties.get("intensity"),n=i.properties.get("color").toRenderColor(o.getLut(i.scope)).toArray01(),l=i.properties.get("intensity"),c=[r.x,r.y,r.z],h=e.cH(n,l),u=e.cH(s,a);return {u_lighting_ambient_color:h,u_lighting_directional_dir:c,u_lighting_directional_color:u,u_ground_radiance:Lr(c,u,h)}})(o,r,this.style);i.setLightsUniformValues(t,s);}}}uploadCommonUniforms(t,i,o,r,s){if(this.uploadCommonLightUniforms(t,i),this.terrain&&this.terrain.renderingToTexture)return;const a=this.style.fog;if(a){const s=a.getOpacity(this.transform.pitch),n=((t,i,o,r,s,a,n,l,c,h,u,d)=>{const _=t.transform,p=i.properties.get("color").toRenderColor(t.style.getLut(i.scope)).toArray01();p[3]=r;const m=t.frameCounter/1e3%1,[f,g]=i.properties.get("vertical-range");return {u_fog_matrix:o?_.calculateFogTileMatrix(o):d||t.identityMat,u_fog_range:i.getFovAdjustedRange(_._fov),u_fog_color:p,u_fog_horizon_blend:i.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(f,g),g],u_fog_temporal_offset:m,u_frustum_tl:s,u_frustum_tr:a,u_frustum_br:n,u_frustum_bl:l,u_globe_pos:c,u_globe_radius:h,u_viewport:u,u_globe_transition:e.a9(_.zoom),u_is_globe:+("globe"===_.projection.name)}})(this,a,o,s,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.q.devicePixelRatio,this.transform.height*e.q.devicePixelRatio],r);i.setFogUniformValues(t,n);}s&&i.setCutoffUniformValues(t,s.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 o of i)t[o.key]=e[o.key]||new pt(o,512,this.transform.tileZoom,this);return t}clearBackgroundTiles(){this._backgroundTiles={};}isSourceForClippingOrConflation(e,t){return !(!e.is3D()||"clip"!==e.type&&(e.minzoom&&e.minzoom>this.transform.zoom||(this.style._clipLayerPresent||"building"!==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]>=Oe||t[1]>=Oe}setupDepthForOcclusion(e,t,i){const o=this.context,r=o.gl,s=!!i;var a;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}),o.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/((a=this.depthRangeFor3D)[1]-a[0]),-1-2*a[0]/(a[1]-a[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),o.activeTexture.set(r.TEXTURE0),s||t.setTerrainUniformValues(o,i);}}function Ta(e,t){let i=!1,o=null;const r=()=>{o=null,i&&(e(),o=setTimeout(r,t),i=!1);};return ()=>(i=!0,o||r(),o)}class Ea{constructor(t){this._hashName=t&&encodeURIComponent(t),e.aJ(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Ta(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=Ca(e);if(this._hashName){const e=this._hashName;let i=!1;const o=location.hash.slice(1).split("&").map((o=>{const r=o.split("=")[0];return r===e?(i=!0,`${r}=${t}`):o})).filter((e=>e));return i||o.push(`${e}=${t}`),`#${o.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(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 Ca(e,t){const i=e.getCenter(),o=Math.round(100*e.getZoom())/100,r=Math.ceil((o*Math.LN2+Math.log(512/360/.5))/Math.LN10),s=Math.pow(10,r),a=Math.round(i.lng*s)/s,n=Math.round(i.lat*s)/s,l=e.getBearing(),c=e.getPitch();let h=t?`/${a}/${n}/${o}`:`${o}/${n}/${a}`;return (l||c)&&(h+="/"+Math.round(10*l)/10),c&&(h+=`/${Math.round(c)}`),h}const Sa={linearity:.3,easing:e.dp(0,0,.3,1)},Ia=e.l({deceleration:2500,maxSpeed:1400},Sa),Da=e.l({deceleration:20,maxSpeed:1400},Sa),Ra=e.l({deceleration:1e3,maxSpeed:360},Sa),Aa=e.l({deceleration:1e3,maxSpeed:90},Sa);class La{constructor(e){this._map=e,this.clear();}clear(){this._inertiaBuffer=[];}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:e.q.now(),settings:t});}_drainInertiaBuffer(){const t=this._inertiaBuffer,i=e.q.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 o=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(i.pan.mag()){const s=Ma(i.pan.mag(),o,e.l({},Ia,t||{}));r.offset=i.pan.mult(s.amount/i.pan.mag()),r.center=this._map.transform.center,Pa(r,s);}if(i.zoom){const e=Ma(i.zoom,o,Da);r.zoom=this._map.transform.zoom+e.amount,Pa(r,e);}if(i.bearing){const t=Ma(i.bearing,o,Ra);r.bearing=this._map.transform.bearing+e.ap(t.amount,-179,179),Pa(r,t);}if(i.pitch){const e=Ma(i.pitch,o,Aa);r.pitch=this._map.transform.pitch+e.amount,Pa(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 Pa(e,t){(!e.duration||e.durationi.unproject(e))),n=s.reduce(((e,t,i,o)=>e.add(t.div(o.length))),new e.P(0,0));super(t,{points:s,point:n,lngLats:a,lngLat:i.unproject(n),originalEvent:o}),this._defaultPrevented=!1;}}class Fa extends e.x{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(e,t){super("wheel",{originalEvent:t}),this._defaultPrevented=!1;}}class ka{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance;}reset(){this._mousedownPos=void 0;}wheel(e){return this._firePreventable(new Fa(this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new za(e.type,this._map,e))}mouseup(e){this._map.fire(new za(e.type,this._map,e));}preclick(t){const i=e.l({},t);i.type="preclick",this._map.fire(new za(i.type,this._map,i));}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new za(e.type,this._map,e)));}dblclick(e){return this._firePreventable(new za(e.type,this._map,e))}mouseover(e){this._map.fire(new za(e.type,this._map,e));}mouseout(e){this._map.fire(new za(e.type,this._map,e));}touchstart(e){return this._firePreventable(new Oa(e.type,this._map,e))}touchmove(e){this._map.fire(new Oa(e.type,this._map,e));}touchend(e){this._map.fire(new Oa(e.type,this._map,e));}touchcancel(e){this._map.fire(new Oa(e.type,this._map,e));}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return {}}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class Ba{constructor(e){this._map=e;}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0;}mousemove(e){this._map.fire(new za(e.type,this._map,e));}mousedown(){this._delayContextMenu=!0;}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new za("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent);}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new za(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault();}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class Na{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&&(_(),this._startPos=this._lastPos=t,this._active=!0);}mousemoveWindow(e,t){if(!this._active)return;const i=t,o=this._startPos,r=this._lastPos;if(!o||!r||r.equals(i)||!this._box&&i.dist(o){this._box&&(this._box.style.transform=`translate(${s}px,${n}px)`,this._box.style.width=a-s+"px",this._box.style.height=c-n+"px");}));}mouseupWindow(t,i){if(!this._active)return;const o=this._startPos,r=i;if(o&&0===t.button){if(this.reset(),f(),o.x!==r.x||o.y!==r.y)return this._map.fire(new e.x("boxzoomend",{originalEvent:t})),{cameraAnimation:e=>e.fitScreenCoordinates(o,r,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",t);}}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e));}blur(){this.reset();}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),p(),delete this._startPos,delete this._lastPos;}_fireEvent(t,i){return this._map.fire(new e.x(t,{originalEvent:i}))}}function Ua(e,t){const i={};for(let o=0;othis.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),o.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=Ua(o,i)));}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const o=Ua(i,t);for(const e in this.touches){const t=o[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 Ga(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 o=this.singleTap.touchend(e,t,i);if(o){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(o)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=o,this.count===this.numTaps)return this.reset(),o}}}class Va{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 o=this._zoomIn.touchend(e,t,i),r=this._zoomOut.touchend(e,t,i);return o?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(o)},{originalEvent:e})}):r?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()-1,around:t.unproject(r)},{originalEvent:e})}):void 0}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}const qa={0:1,2:2};class Za{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=x(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=qa[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=Ua(o,i),s=new e.P(0,0),a=new e.P(0,0);let n=0;for(const e in r){const t=r[e],i=this._touches[e];i&&(s._add(t),a._add(t.sub(i)),n++,r[e]=t);}if(this._touches=r,n{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role");}),500);}}class Ya{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 o=this._firstTwoTouches;if(!o)return;e.preventDefault();const[r,s]=o,a=Ka(i,t,r),n=Ka(i,t,s);if(!a||!n)return;const l=this._aroundCenter?null:a.add(n).div(2);return this._move([a,n],l,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;const[o,r]=this._firstTwoTouches,s=Ka(i,t,o),a=Ka(i,t,r);s&&a||(this._active&&f(),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 Ka(e,t,i){for(let o=0;oMath.abs(e.x)}class rn extends Ya{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,on(e[0].sub(e[1]))&&(this._valid=!1);}_move(t,i,o){const r=this._lastPoints;if(!r)return;const s=t[0].sub(r[0]),a=t[1].sub(r[1]);return this._map._cooperativeGestures&&!e.dq()&&o.touches.length<3||(this._valid=this.gestureBeginsVertically(s,a,o.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(s.y+a.y)/2*-.5})}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const o=e.mag()>=2,r=t.mag()>=2;if(!o&&!r)return;if(!o||!r)return null==this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const s=e.y>0==t.y>0;return on(e)&&on(t)&&s}}const sn={panStep:100,bearingStep:15,pitchStep:10};class an{constructor(){const e=sn;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,o=0,r=0,s=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?o=1:(e.preventDefault(),s=-1);break;case 40:e.shiftKey?o=-1:(e.preventDefault(),s=1);break;default:return}return this._rotationDisabled&&(i=0,o=0),{cameraAnimation:a=>{const n=a.getZoom();a.easeTo({duration:300,easeId:"keyboardHandler",easing:nn,zoom:t?Math.round(n)+t*(e.shiftKey?2:1):n,bearing:a.getBearing()+i*this._bearingStep,pitch:a.getPitch()+o*this._pitchStep,offset:[-r*this._panStep,-s*this._panStep],center:a.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 nn(e){return e*(2-e)}const ln=4.000244140625,cn=1/450;class hn{constructor(t,i){this._map=t,this._el=t.getCanvasContainer(),this._handler=i,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=cn,e.aJ(["_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.dq()))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 o=e.q.now(),r=o-(this._lastWheelEventTime||0);this._lastWheelEventTime=o,0!==i&&i%ln==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=g(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)>ln?this._wheelZoomRate:this._defaultZoomRate;let o=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==o&&(o=1/o);const r=i(),s=Math.pow(2,r),a="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):s;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(a*o))),"wheel"===this._type&&(this._startZoom=r,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0;}const o="number"==typeof this._targetZoom?this._targetZoom:i(),r=this._startZoom,s=this._easing;let a,n=!1;if("wheel"===this._type&&r&&s){const t=Math.min((e.q.now()-this._lastWheelEventTime)/200,1),i=s(t);a=e.aa(r,o,i),t<1?this._frameId||(this._frameId=!0):n=!0;}else a=o,n=!0;this._active=!0,n&&(this._active=!1,this._finishTimeout=window.setTimeout((()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout;}),200));let l=a-i();return l*this._lastDelta<0&&(l=0),{noInertia:!0,needsRenderFrame:!n,zoomDelta:l,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let i=e.dr;if(this._prevEase){const t=this._prevEase,o=(e.q.now()-t.start)/t.duration,r=t.easing(o+.01)-t.easing(o),s=.27/Math.sqrt(r*r+1e-4)*.01,a=Math.sqrt(.0729-s*s);i=e.dp(s,a,.25,1);}return this._prevEase={start:e.q.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 un{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 dn{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 _n{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 o=t[0],r=o.y-this._swipePoint.y;return this._swipePoint=o,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 pn{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 mn{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 fn{constructor(e,t,i,o){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=o,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 gn=e=>e.zoom||e.drag||e.pitch||e.rotate;class vn extends e.x{}class xn{constructor(){this.constants=[1,1,.01],this.radius=0;}setup(t,i){const o=e.a6.vec3.sub([],i,t);this.radius=e.a6.vec3.length(o[2]<0?e.a6.vec3.div([],o,this.constants):[o[0],o[1],0]);}projectRay(t){e.a6.vec3.div(t,t,this.constants),e.a6.vec3.normalize(t,t),e.a6.vec3.mul(t,t,this.constants);const i=e.a6.vec3.scale([],t,this.radius);if(i[2]>0){const t=e.a6.vec3.scale([],[0,0,1],e.a6.vec3.dot(i,[0,0,1])),o=e.a6.vec3.scale([],e.a6.vec3.normalize([],[i[0],i[1],0]),this.radius),r=e.a6.vec3.add([],i,e.a6.vec3.scale([],e.a6.vec3.sub([],e.a6.vec3.add([],o,t),i),2));i[0]=r[0],i[1]=r[1];}return i}}function yn(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class bn{constructor(t,i){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new La(t),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new xn,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),e.aJ(["handleEvent","handleWindowEvent"],this);const o=this._el;this._listeners=[[o,"touchstart",{passive:!0}],[o,"touchmove",{passive:!1}],[o,"touchend",void 0],[o,"touchcancel",void 0],[o,"mousedown",void 0],[o,"mousemove",void 0],[o,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[o,"mouseover",void 0],[o,"mouseout",void 0],[o,"dblclick",void 0],[o,"click",void 0],[o,"keydown",{capture:!1}],[o,"keyup",void 0],[o,"wheel",{passive:!1}],[o,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,i]of this._listeners){const o=e===document?this.handleWindowEvent:this.handleEvent;e.addEventListener(t,o,i);}}destroy(){for(const[e,t,i]of this._listeners){const o=e===document?this.handleWindowEvent:this.handleEvent;e.removeEventListener(t,o,i);}}_addDefaultHandlers(e){const t=this._map,i=t.getCanvasContainer();this._add("mapEvent",new ka(t,e));const o=t.boxZoom=new Na(t,e);this._add("boxZoom",o);const r=new Va,s=new dn;t.doubleClickZoom=new un(s,r),this._add("tapZoom",r),this._add("clickZoom",s);const a=new _n;this._add("tapDragZoom",a);const n=t.touchPitch=new rn(t);this._add("touchPitch",n);const l=new Wa(e),c=new $a(e);t.dragRotate=new mn(e,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const h=new Ha(e),u=new Xa(t,e);t.dragPan=new pn(i,h,u),this._add("mousePan",h),this._add("touchPan",u,["touchZoom","touchRotate"]);const d=new tn,_=new Qa;t.touchZoomRotate=new fn(i,_,d,a),this._add("touchRotate",d,["touchPan","touchZoom"]),this._add("touchZoom",_,["touchPan","touchRotate"]),this._add("blockableMapEvent",new Ba(t));const p=t.scrollZoom=new hn(t,this);this._add("scrollZoom",p,["mousePan"]);const m=t.keyboard=new an;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 !!gn(this._eventsInProgress)||this.isZooming()}_isDragging(){return !!this._eventsInProgress.drag}_blockedByActive(e,t,i){for(const o in e)if(o!==i&&(!t||t.indexOf(o)<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,o=i?void 0:e,r={needsRenderFrame:!1},s={},a={},n=e.touches?this._getMapTouches(e.touches):void 0,l=n?v(this._el,n):i?void 0:g(this._el,e);for(const{handlerName:i,handler:c,allowed:h}of this._handlers){if(!c.isEnabled())continue;let u;this._blockedByActive(a,h,i)?c.reset():c[t||e.type]&&(u=c[t||e.type](e,l,n),this.mergeHandlerResult(r,s,u,i,o),u&&u.needsRenderFrame&&this._triggerRenderFrame()),(u||c.isActive())&&(a[i]=c);}const c={};for(const e in this._previousActiveHandlers)a[e]||(c[e]=o);this._previousActiveHandlers=a,(Object.keys(c).length||yn(r))&&(this._changes.push([r,s,c]),this._triggerRenderFrame()),(Object.keys(a).length||yn(r))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:h}=r;h&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],h(this._map));}mergeHandlerResult(t,i,o,r,s){if(!o)return;e.l(t,o);const a={handlerName:r,originalEvent:o.originalEvent||s};void 0!==o.zoomDelta&&(i.zoom=a),void 0!==o.panDelta&&(i.drag=a),void 0!==o.pitchDelta&&(i.pitch=a),void 0!==o.bearingDelta&&(i.rotate=a);}_applyChanges(){const t={},i={},o={};for(const[r,s,a]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),e.l(i,s),e.l(o,a);this._updateMapTransform(t,i,o),this._changes=[];}_updateMapTransform(t,i,o){const r=this._map,s=r.transform,a=e=>[e.x,e.y,e.z];if((e=>{const t=this._eventsInProgress.drag;return t&&!this._handlersById[t.handlerName].isActive()})()&&!yn(t)){const e=s.zoom;s.cameraElevationReference="sea",null!=this._originalZoom&&s._orthographicProjectionAtLowPitch&&"globe"!==s.projection.name&&0===s.pitch?(s.cameraElevationReference="ground",s.zoom=this._originalZoom):(s.recenterOnTerrain(),s.cameraElevationReference="ground"),e!==s.zoom&&this._map._update(!0);}if(s._isCameraConstrained&&r._stop(!0),!yn(t))return void this._fireEvents(i,o,!0);let{panDelta:n,zoomDelta:l,bearingDelta:c,pitchDelta:h,around:u,aroundCoord:d,pinchAround:_}=t;s._isCameraConstrained&&(l>0&&(l=0),s._isCameraConstrained=!1),void 0!==_&&(u=_),(l||(e=>i[e]&&!this._eventsInProgress[e])("drag"))&&u&&(this._dragOrigin=a(s.pointCoordinate3D(u)),this._originalZoom=s.zoom,this._trackingEllipsoid.setup(s._camera.position,this._dragOrigin)),s.cameraElevationReference="sea",r._stop(!0),u=u||r.transform.centerPoint,c&&(s.bearing+=c),h&&(s.pitch+=h),s._updateCameraState();const p=[0,0,0];if(n)if("mercator"===s.projection.name){const e=this._trackingEllipsoid.projectRay(s.screenPointToMercatorRay(u).dir),t=this._trackingEllipsoid.projectRay(s.screenPointToMercatorRay(u.sub(n)).dir);p[0]=t[0]-e[0],p[1]=t[1]-e[1];}else {const t=s.pointCoordinate(u);if("globe"===s.projection.name){n=n.rotate(-s.angle);const i=s._pixelsPerMercatorPixel/s.worldSize;p[0]=-n.x*e.ds(e.aM(t.y))*i,p[1]=-n.y*e.ds(s.center.lat)*i;}else {const e=s.pointCoordinate(u.sub(n));t&&e&&(p[0]=e.x-t.x,p[1]=e.y-t.y);}}const m=s.zoom,f=[0,0,0];if(l){const t=a(d||s.pointCoordinate3D(u)),i={dir:e.a6.vec3.normalize([],e.a6.vec3.sub([],t,s._camera.position))};if(i.dir[2]<0){const o=s.zoomDeltaToMovement(t,l);e.a6.vec3.scale(f,i.dir,o);}}const g=e.a6.vec3.add(p,p,f);s._translateCameraConstrained(g),l&&Math.abs(s.zoom-m)>1e-4&&s.recenterOnTerrain(),s.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(i,o,!0);}_fireEvents(t,i,o){const r=gn(this._eventsInProgress),s=gn(t),a={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(a[`${e}start`]=i),this._eventsInProgress[e]=t[e];}!r&&s&&this._fireEvent("movestart",s.originalEvent);for(const e in a)this._fireEvent(e,a[e]);s&&this._fireEvent("move",s.originalEvent);for(const e in t){const{originalEvent:i}=t[e];this._fireEvent(e,i);}const n={};let l;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:o}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=i[t]||o,n[`${e}end`]=l);}for(const e in n)this._fireEvent(e,n[e]);const c=gn(this._eventsInProgress);if(o&&(r||s)&&!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 vn("renderFrame",{timeStamp:e})),this._applyChanges();}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame());}}const wn="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Tn 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.aJ(["_renderFrameCallback"],this);}getCenter(){return new e.bK(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(t,i,o){return t=e.P.convert(t).mult(-1),this.panTo(this.transform.center,e.l({offset:t},i),o)}panTo(t,i,o){return this.easeTo(e.l({center:t},i),o)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(t,i,o){return this.easeTo(e.l({zoom:t},i),o)}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(t,i,o){return this.easeTo(e.l({bearing:t},i),o)}resetNorth(t,i){return this.rotateTo(0,e.l({duration:1e3},t),i),this}resetNorthPitch(t,i){return this.easeTo(e.l({bearing:0,pitch:0,duration:1e3},t),i),this}snapToNorth(e,t){return Math.abs(this.getBearing())e.aspect?i/(2*Math.tan(.5*e.fovX)*e.aspect):o/(2*Math.tan(.5*e.fovY)*e.aspect)}_cameraForBoundsOnGlobe(t,i,o,r,s,a){const n=t.clone(),l=this._extendCameraOptions(a);n.bearing=r,n.pitch=s;const c=e.bK.convert(i),h=e.bK.convert(o),u=.5*(c.lat+h.lat),d=.5*(c.lng+h.lng),_=e.dt(u,d),p=e.a6.vec3.normalize([],_),m=e.a6.vec3.normalize([],e.a6.vec3.cross([],p,[0,1,0])),f=e.a6.vec3.cross([],m,p),g=[m[0],m[1],m[2],0,f[0],f[1],f[2],0,p[0],p[1],p[2],0,0,0,0,1],v=[_,e.dt(c.lat,c.lng),e.dt(h.lat,c.lng),e.dt(h.lat,h.lng),e.dt(c.lat,h.lng),e.dt(u,c.lng),e.dt(u,h.lng),e.dt(c.lat,d),e.dt(h.lat,d)];let x=e.c9.fromPoints(v.map((t=>[e.a6.vec3.dot(m,t),e.a6.vec3.dot(f,t),e.a6.vec3.dot(p,t)])));const y=e.a6.vec3.transformMat4([],x.center,g);0===e.a6.vec3.squaredLength(y)&&e.a6.vec3.set(y,0,0,1),e.a6.vec3.normalize(y,y),e.a6.vec3.scale(y,y,e.aq),n.center=e.du(y);const b=n.getWorldToCameraMatrix(),w=e.a6.mat4.invert(new Float64Array(16),b);x=e.c9.applyTransform(x,e.a6.mat4.multiply([],b,g));const T=this._extendAABB(x,n,l,r);if(!T)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");x=T,e.a6.vec3.transformMat4(y,y,b);const E=.5*(x.max[2]-x.min[2]),C=this._minimumAABBFrustumDistance(n,x),S=e.a6.vec3.scale([],[0,0,1],E),I=e.a6.vec3.add(S,y,S),D=C+(0===n.pitch?0:e.a6.vec3.distance(y,I)),R=n.globeCenterInViewSpace,A=e.a6.vec3.sub([],y,[R[0],R[1],R[2]]);e.a6.vec3.normalize(A,A),e.a6.vec3.scale(A,A,D);const L=e.a6.vec3.add([],y,A);e.a6.vec3.transformMat4(L,L,w);const P=e.dw/e.aq,M=e.a6.vec3.length(L),z=e.bD(Math.max(M*P-e.dw,Number.EPSILON),0),O=Math.min(n.zoomFromMercatorZAdjusted(z),l.maxZoom);return O>.5*(e.c2+e.bU)?(n.setProjection({name:"mercator"}),n.zoom=O,this._cameraForBounds(n,i,o,r,s,a)):{center:n.center,zoom:O,bearing:r,pitch:s}}_extendAABB(t,i,o,r){const s=.5*((o.padding.left||0)+(o.padding.right||0)),a=.5*((o.padding.top||0)+(o.padding.bottom||0)),n=a,l=s,c=s,h=a,u=i.width-(l+c),d=i.height-(n+h),_=e.a6.vec3.sub([],t.max,t.min),p=Math.min(u/_[0],d/_[1]),m=Math.min(i.scaleZoom(i.scale*p),o.maxZoom);if(isNaN(m))return null;const f=i.scale/i.zoomScale(m),g=new e.c9([t.min[0]-l*f,t.min[1]-h*f,t.min[2]],[t.max[0]+c*f,t.max[1]+n*f,t.max[2]]),v=("number"==typeof o.offset.x&&"number"==typeof o.offset.y?new e.P(o.offset.x,o.offset.y):e.P.convert(o.offset)).rotate(-e.bB(r));return g.center[0]-=v.x*f,g.center[1]+=v.y*f,g}queryTerrainElevation(t,i){const o=this.transform.elevation;return o?(i=e.l({},{exaggerated:!0},i),o.getAtPoint(e.a5.fromLngLat(t),null,i.exaggerated)):null}_cameraForBounds(t,i,o,r,s,a){if("globe"===t.projection.name)return this._cameraForBoundsOnGlobe(t,i,o,r,s,a);const n=t.clone(),l=this._extendCameraOptions(a);n.bearing=r,n.pitch=s;const c=e.bK.convert(i),h=e.bK.convert(o),u=new e.bK(c.lng,h.lat),d=new e.bK(h.lng,c.lat),_=n.project(c),p=n.project(h),m=this.queryTerrainElevation(c),f=this.queryTerrainElevation(h),g=this.queryTerrainElevation(u),v=this.queryTerrainElevation(d),x=[[_.x,_.y,Math.min(m||0,f||0,g||0,v||0)],[p.x,p.y,Math.max(m||0,f||0,g||0,v||0)]];let y=e.c9.fromPoints(x);const b=n.getWorldToCameraMatrix(),w=e.a6.mat4.invert(new Float64Array(16),b);y=e.c9.applyTransform(y,b);const T=this._extendAABB(y,n,l,r);if(!T)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");y=T;const E=.5*e.a6.vec3.sub([],y.max,y.min)[2],C=this._minimumAABBFrustumDistance(n,y),S=[0,0,1,0];e.a6.vec4.transformMat4(S,S,b),e.a6.vec4.normalize(S,S);const I=e.a6.vec3.scale([],S,C+E),D=e.a6.vec3.add([],y.center,I);e.a6.vec3.transformMat4(y.center,y.center,w),e.a6.vec3.transformMat4(D,D,w);const R=n.unproject(new e.P(y.center[0],y.center[1])),A=e.dv(n.projection,R),L=Math.pow(2,A),P=Math.min(n._zoomFromMercatorZ(D[2]*n.pixelsPerMeter*L/n.worldSize),l.maxZoom);return n.mercatorFromTransition&&P<.5*(e.c2+e.bU)?(n.setProjection({name:"globe"}),n.zoom=P,this._cameraForBounds(n,i,o,r,s,a)):{center:R,zoom:P,bearing:r,pitch:s}}fitBounds(e,t,i){const o=this.cameraForBounds(e,t);return this._fitInternal(o,t,i)}fitScreenCoordinates(t,i,o,r,s){const a=e.P.convert(t),n=e.P.convert(i),l=new e.P(Math.min(a.x,n.x),Math.min(a.y,n.y)),c=new e.P(Math.max(a.x,n.x),Math.max(a.y,n.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(a,n))return this;const h=this.transform.pointLocation3D(l),u=this.transform.pointLocation3D(c),d=this.transform.pointLocation3D(new e.P(l.x,c.y)),_=this.transform.pointLocation3D(new e.P(c.x,l.y)),p=[Math.min(h.lng,u.lng,d.lng,_.lng),Math.min(h.lat,u.lat,d.lat,_.lat)],m=[Math.max(h.lng,u.lng,d.lng,_.lng),Math.max(h.lat,u.lat,d.lat,_.lat)],f=r&&r.pitch?r.pitch:this.getPitch(),g=this._cameraForBounds(this.transform,p,m,o,f,r);return this._fitInternal(g,r,s)}_fitInternal(t,i,o){return t?(i=e.l(t,i)).linear?this.easeTo(i,o):this.flyTo(i,o):this}jumpTo(t,i){this.stop();const o=t.preloadOnly?this.transform.clone():this.transform;let r=!1,s=!1,a=!1;"zoom"in t&&o.zoom!==+t.zoom&&(r=!0,o.zoom=+t.zoom),void 0!==t.center&&(o.center=e.bK.convert(t.center)),"bearing"in t&&o.bearing!==+t.bearing&&(s=!0,o.bearing=+t.bearing),"pitch"in t&&o.pitch!==+t.pitch&&(a=!0,o.pitch=+t.pitch);const n="number"==typeof t.padding?this._extendPadding(t.padding):t.padding;if(null!=t.padding&&!o.isPaddingEqual(n))if(!1===t.retainPadding){const e=o.clone();e.padding=n,o.setLocationAtPoint(o.center,e.centerPoint);}else o.padding=n;return t.preloadOnly?(this._preloadTiles(o),this):(this.fire(new e.x("movestart",i)).fire(new e.x("move",i)),r&&this.fire(new e.x("zoomstart",i)).fire(new e.x("zoom",i)).fire(new e.x("zoomend",i)),s&&this.fire(new e.x("rotatestart",i)).fire(new e.x("rotate",i)).fire(new e.x("rotateend",i)),a&&this.fire(new e.x("pitchstart",i)).fire(new e.x("pitch",i)).fire(new e.x("pitchend",i)),this.fire(new e.x("moveend",i)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||e.w(wn),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,i){const o=this.transform;if(!o.projection.supportsFreeCamera)return e.w(wn),this;this.stop();const r=o.zoom,s=o.pitch,a=o.bearing;o.setFreeCameraOptions(t);const n=r!==o.zoom,l=s!==o.pitch,c=a!==o.bearing;return this.fire(new e.x("movestart",i)).fire(new e.x("move",i)),n&&this.fire(new e.x("zoomstart",i)).fire(new e.x("zoom",i)).fire(new e.x("zoomend",i)),c&&this.fire(new e.x("rotatestart",i)).fire(new e.x("rotate",i)).fire(new e.x("rotateend",i)),l&&this.fire(new e.x("pitchstart",i)).fire(new e.x("pitch",i)).fire(new e.x("pitchend",i)),this.fire(new e.x("moveend",i)),this}easeTo(t,i){this._stop(!1,t.easeId),(!1===(t=e.l({offset:[0,0],duration:500,easing:e.dr},t)).animate||this._prefersReducedMotion(t))&&(t.duration=0);const o=this.transform,r=this.getZoom(),s=this.getBearing(),a=this.getPitch(),n=this.getPadding(),l="zoom"in t?+t.zoom:r,c="bearing"in t?this._normalizeBearing(t.bearing,s):s,h="pitch"in t?+t.pitch:a,u=this._extendPadding(t.padding),d=e.P.convert(t.offset);let _,p,m;if("globe"===o.projection.name){const i=e.a5.fromLngLat(o.center),r=d.rotate(-o.angle);i.x+=r.x/o.worldSize,i.y+=r.y/o.worldSize;const s=i.toLngLat(),a=e.bK.convert(t.center||s);this._normalizeCenter(a),_=o.centerPoint.add(r),p=new e.P(i.x,i.y).mult(o.worldSize),m=new e.P(e.am(a.lng),e.at(a.lat)).mult(o.worldSize).sub(p);}else {_=o.centerPoint.add(d);const i=o.pointLocation(_),r=e.bK.convert(t.center||i);this._normalizeCenter(r),p=o.project(i),m=o.project(r).sub(p);}const f=o.zoomScale(l-r);let g,v;t.around&&(g=e.bK.convert(t.around),v=o.locationPoint(g));const x=this._zooming||l!==r,y=this._rotating||s!==c,b=this._pitching||h!==a,w=!o.isPaddingEqual(u),T=!1===t.retainPadding?o.clone():o,E=o=>E=>{if(x&&(o.zoom=e.aa(r,l,E)),y&&(o.bearing=e.aa(s,c,E)),b&&(o.pitch=e.aa(a,h,E)),w&&(T.interpolatePadding(n,u,E),_=T.centerPoint.add(d)),g)o.setLocationAtPoint(g,v);else {const e=o.zoomScale(o.zoom-r),t=l>r?Math.min(2,f):Math.max(.5,f),i=Math.pow(t,1-E),s=o.unproject(p.add(m.mult(E*i)).mult(e));o.setLocationAtPoint(o.renderWorldCopies?s.wrap():s,_);}return t.preloadOnly||this._fireMoveEvents(i),o};if(t.preloadOnly){const e=this._emulate(E,t.duration,o);return this._preloadTiles(e),this}const C={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=x,this._rotating=y,this._pitching=b,this._padding=w,this._easeId=t.easeId,this._prepareEase(i,t.noMoveStart,C),this._ease(E(o),(e=>{"sea"===o.cameraElevationReference&&o.recenterOnTerrain(),this._afterEase(i,e);}),t),this}_prepareEase(t,i,o={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&0===this.transform.pitch&&"globe"!==this.transform.projection.name&&(this.transform.cameraElevationReference="ground"),i||o.moving||this.fire(new e.x("movestart",t)),this._zooming&&!o.zooming&&this.fire(new e.x("zoomstart",t)),this._rotating&&!o.rotating&&this.fire(new e.x("rotatestart",t)),this._pitching&&!o.pitching&&this.fire(new e.x("pitchstart",t));}_fireMoveEvents(t){this.fire(new e.x("move",t)),this._zooming&&this.fire(new e.x("zoom",t)),this._rotating&&this.fire(new e.x("rotate",t)),this._pitching&&this.fire(new e.x("pitch",t));}_afterEase(t,i){if(this._easeId&&i&&this._easeId===i)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const o=this._zooming,r=this._rotating,s=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,o&&this.fire(new e.x("zoomend",t)),r&&this.fire(new e.x("rotateend",t)),s&&this.fire(new e.x("pitchend",t)),this.fire(new e.x("moveend",t));}flyTo(t,i){if(this._prefersReducedMotion(t)){const o=e.ar(t,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(o,i)}this.stop(),t=e.l({offset:[0,0],speed:1.2,curve:1.42,easing:e.dr},t);const o=this.transform,r=this.getZoom(),s=this.getBearing(),a=this.getPitch(),n=this.getPadding(),l="zoom"in t?e.ap(+t.zoom,o.minZoom,o.maxZoom):r,c="bearing"in t?this._normalizeBearing(t.bearing,s):s,h="pitch"in t?+t.pitch:a,u=this._extendPadding(t.padding),d=o.zoomScale(l-r),_=e.P.convert(t.offset);let p=o.centerPoint.add(_);const m=o.pointLocation(p),f=e.bK.convert(t.center||m);this._normalizeCenter(f);const g=o.project(m),v=o.project(f).sub(g);let x=t.curve;const y=Math.max(o.width,o.height),b=y/d,w=v.mag();if("minZoom"in t){const i=e.ap(Math.min(t.minZoom,r,l),o.minZoom,o.maxZoom),s=y/o.zoomScale(i-r);x=Math.sqrt(s/w*2);}const T=x*x;function E(e){const t=(b*b-y*y+(e?-1:1)*T*T*w*w)/(2*(e?b:y)*T*w);return Math.log(Math.sqrt(t*t+1)-t)}function C(e){return (Math.exp(e)-Math.exp(-e))/2}function S(e){return (Math.exp(e)+Math.exp(-e))/2}const I=E(0);let D=function(e){return S(I)/S(I+x*e)},R=function(e){return y*((S(I)*(C(t=I+x*e)/S(t))-C(I))/T)/w;var t;},A=(E(1)-I)/x;if(Math.abs(w)<1e-6||!isFinite(A)){if(Math.abs(y-b)<1e-6)return this.easeTo(t,i);const e=bt.maxDuration&&(t.duration=0);const L=s!==c,P=h!==a,M=!o.isPaddingEqual(u),z=!1===t.retainPadding?o.clone():o,O=o=>d=>{const m=d*A,x=1/D(m);o.zoom=1===d?l:r+o.scaleZoom(x),L&&(o.bearing=e.aa(s,c,d)),P&&(o.pitch=e.aa(a,h,d)),M&&(z.interpolatePadding(n,u,d),p=z.centerPoint.add(_));const y=1===d?f:o.unproject(g.add(v.mult(R(m))).mult(x));return o.setLocationAtPoint(o.renderWorldCopies?y.wrap():y,p),o._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(i),o};if(t.preloadOnly){const e=this._emulate(O,t.duration,o);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=L,this._pitching=P,this._padding=M,this._prepareEase(i,!1),this._ease(O(o),(()=>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,o){!1===o.animate||0===o.duration?(t(1),i()):(this._easeStart=e.q.now(),this._easeOptions=o,this._onEaseFrame=t,this._onEaseEnd=i,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback));}_renderFrameCallback(){const t=Math.min((e.q.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.bA(t,-180,180);const o=Math.abs(t-i);return Math.abs(t-360-i)180?-360:i<-180?360:0;}_prefersReducedMotion(t){return this._respectPrefersReducedMotion&&e.q.prefersReducedMotion&&!(t&&t.essential)}_emulate(e,t,i){const o=Math.ceil(15*t/1e3),r=[],s=e(i.clone());for(let e=0;e<=o;e++){const t=s(e/o);r.push(t.clone());}return r}_preloadTiles(e,t){}}class En{constructor(t={}){this.options=t,e.aJ(["_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 o=l("span","mapboxgl-ctrl-icon",this._compactButton);return o.setAttribute("aria-hidden","true"),o.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 o=i.reduce(((e,t,o)=>(t.value&&(e+=`${t.key}=${t.value}${oe.length-t.length)),e=e.filter(((t,i)=>{for(let o=i+1;o=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 Cn{constructor(){e.aJ(["_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 Sn{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1;}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(const t of i)if(t.id===e)return void(t.cancelled=!0)}run(e=0){const t=this._currentlyRunning=this._queue;this._queue=[];for(const i of t)if(!i.cancelled&&(i.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1;}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[];}}class In{constructor(e){this.jumpTo(e);}getValue(t){if(t<=this._startTime)return this._start;if(t>=this._endTime)return this._end;const i=e.cw((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 Dn={"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 Rn{registerParameter(){}registerButton(){}registerBinding(){}refreshUI(){}}class An{constructor(e){this.map=e,this.interactionsByType=new Map,this.typeById=new Map,this.filters=new Map,this.handleType=this.handleType.bind(this);}add(t,i){if(this.typeById.has(t))throw new Error(`Interaction id "${t}" already exists.`);const{type:o,filter:r}=i;if(r){const i=e.M(r,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===i.result)throw new Error(i.value.map((e=>`${e.key}: ${e.message}`)).join(", "));this.filters.set(t,i.value);}const s=this.interactionsByType.get(o)||new Map;0===s.size&&(this.map.on(o,this.handleType),this.interactionsByType.set(o,s)),s.set(t,i),this.typeById.set(t,o);}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),0===i.size&&this.map.off(t,this.handleType));}handleType(e){const t=e.features||this.map.queryRenderedFeatures(e.point);if(!t)return;const i=this.interactionsByType.get(e.type),o={zoom:0};for(const[e,r]of i){const i=this.filters.get(e),{handler:s,layers:a}=r;for(const n of t)if((!a||a.includes(n.layer.id))&&(!i||i.evaluate(o,n))&&!1!==s({id:e,feature:n,interaction:r}))break}}}const Ln={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},Pn={showCompass:!0,showZoom:!0,visualizePitch:!1};class Mn{constructor(t,i,o=!1){this._clickTolerance=10,this.element=i,this.mouseRotate=new Wa({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,o&&(this.mousePitch=new $a({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),e.aJ(["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),_();}move(e,t){const i=this.map,o=this.mouseRotate.mousemoveWindow(e,t),r=o&&o.bearingDelta;if(r&&i.setBearing(i.getBearing()+r),this.mousePitch){const o=this.mousePitch.mousemoveWindow(e,t),r=o&&o.pitchDelta;r&&i.setPitch(i.getPitch()+r);}}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart,{passive:!1}),e.removeEventListener("touchmove",this.touchmove),e.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp();}offTemp(){p(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup);}mousedown(t){this.down(e.l({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),g(this.element,t)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup);}mousemove(e){this.move(e,g(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=v(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=v(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)o.width||i.y>o.height;o.locationPoint(r).distSqr(i)180;){const e=o.locationPoint(t);if(e.x>=0&&e.y>=0&&e.x<=o.width&&e.y<=o.height)break;t.lng>o.center.lng?t.lng-=360:t.lng+=360;}return t}const On={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%)"};class Fn extends e.E{constructor(t,i){if(super(),(t instanceof HTMLElement||i)&&(t=e.l({element:t},i)),e.aJ(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&t.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),this._occludedOpacity=t&&t.occludedOpacity||.2,t&&t.element)this._element=t.element,this._offset=e.P.convert(t&&t.offset||[0,0]);else {this._defaultMarker=!0,this._element=l("div");const i=41,o=27,r=c("svg",{display:"block",height:i*this._scale+"px",width:o*this._scale+"px",viewBox:`0 0 ${o} ${i}`},this._element),s=c("radialGradient",{id:"shadowGradient"},c("defs",{},r));c("stop",{offset:"10%","stop-opacity":.4},s),c("stop",{offset:"100%","stop-opacity":.05},s),c("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},r),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"},r),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"},r),c("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},r),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 o=this._element.classList;for(const e in On)o.remove(`mapboxgl-marker-anchor-${e}`);o.add(`mapboxgl-marker-anchor-${this._anchor}`);const r=t&&t.className?t.className.trim().split(/\s+/):[];o.add(...r),this._popup=null;}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.bK.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}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,o=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":[o,-1*(t-i+o)],"bottom-right":[-o,-1*(t-i+o)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset;}this._popup=e,e._marker=this,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),o=e.getFreeCameraOptions();if(!o.position)return !1;const r=o.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 o=t.unproject(i);let r;t._showingGlobe()&&e.dz(t.transform,this._lngLat)?r=0:(r=1-t._queryFogOpacity(o),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 ${On[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${t.x}px,${t.y}px)\n `;}_calculateXYTransform(){const t=this._pos,i=this._map,o=this.getPitchAlignment();if(!i||!t||"map"!==o)return "";if(!i._showingGlobe()){const e=i.getPitch();return e?`rotateX(${e}deg)`:""}const r=e.c0(e.dA(i.transform,this._lngLat)),s=t.sub(e.dB(i.transform)),a=Math.abs(s.x)+Math.abs(s.y);if(0===a)return "";const n=r/a;return `rotateX(${-s.y*n}deg) rotateY(${s.x*n}deg)`}_calculateZTransform(){const t=this._pos,i=this._map;if(!i||!t)return "";let o=0;const r=this.getRotationAlignment();if("map"===r)if(i._showingGlobe()){const t=i.project(new e.bK(this._lngLat.lng,this._lngLat.lat+.001)),r=i.project(new e.bK(this._lngLat.lng,this._lngLat.lat-.001)).sub(t);o=e.c0(Math.atan2(r.y,r.x))-90;}else o=-i.getBearing();else if("horizon"===r){const r=e.a7(4,6,i.getZoom()),s=e.dB(i.transform);s.y+=r*i.transform.height;const a=t.sub(s),n=e.c0(Math.atan2(a.y,a.x));o=(n>90?n-270:n+90)*(1-r);}return o+=this._rotation,o?`rotateZ(${o}deg)`:""}_update(e){cancelAnimationFrame(this._updateFrameId);const t=this._map;t&&(t.transform.renderWorldCopies&&(this._lngLat=zn(this._lngLat,this._pos,t.transform)),this._pos=t.project(this._lngLat),!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 o=this._pointerdownPos,r=this._positionDelta;if(o&&r){if(!this._isDragging){const e=this._clickTolerance||i._clickTolerance;if(t.point.dist(o)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.dx(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 Hi(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),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 Sn,this._domRenderTaskQueue=new Sn,this._controls=[],this._markers=[],this._popups=[],this._mapId=e.aP(),this._locale=e.l({},Dn,t.locale),this._clickTolerance=t.clickTolerance,this._cooperativeGestures=t.cooperativeGestures,this._performanceMetricsCollection=t.performanceMetricsCollection,this._tessellationStep=t.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._precompilePrograms=t.precompilePrograms,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new In(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._requestManager=new T(t.transformRequest,t.accessToken,t.testMode),this._silenceAuthErrors=!!t.testMode,this._contextCreateOptions=t.contextCreateOptions?{...t.contextCreateOptions}:{},"string"==typeof t.container){const e=document.getElementById(t.container);if(!e)throw new Error(`Container '${t.container.toString()}' not found.`);this._container=e;}else {if(!(t.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container;}if(this._container.childNodes.length>0&&e.w("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),t.maxBounds&&this.setMaxBounds(t.maxBounds),e.aJ(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._tp||(this._tp=new Rn),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._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 bn(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 Ea("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 i=t.bounds;i&&(this.resize(),this.fitBounds(i,e.l({},t.fitBoundsOptions,{duration:0})));}this.resize(),t.attributionControl&&this.addControl(new En({customAttribution:t.customAttribution})),this._logoControl=new Cn,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent();})),this.on("data",(t=>{this._update("style"===t.dataType),this.fire(new e.x(`${t.dataType}data`,t));})),this.on("dataloading",(t=>{this.fire(new e.x(`${t.dataType}dataloading`,t));})),this._interactions=new An(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.t(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const o=t.onAdd(this);this._controls.push(t);const r=this._controlPositions[i];return -1!==i.indexOf("bottom")?r.insertBefore(o,r.firstChild):r.appendChild(o),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.t(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.x("movestart",t)).fire(new e.x("move",t)),this.fire(new e.x("resize",t)),i&&this.fire(new e.x("moveend",t)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(t){return this.transform.setMaxBounds(e.as.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.x("zoomstart")).fire(new e.x("zoom")).fire(new e.x("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.x("pitchstart")).fire(new e.x("pitch")).fire(new e.x("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}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.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 o;"globe"===i&&t.zoom>=e.bU?(t.setMercatorFromTransition(),o=!0):"mercator"===i&&t.zoom=e.bU?this.transform.setMercatorFromTransition():this.transform.setProjection(t),this.style.applyProjectionUpdate(),i&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(t){return this.transform.locationPoint3D(e.bK.convert(t))}unproject(t){return this.transform.pointLocation3D(e.P.convert(t))}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){if("mouseenter"===e||"mouseover"===e){let o=!1;const r=r=>{const s=t.filter((e=>this.getLayer(e))),a=s.length?this.queryRenderedFeatures(r.point,{layers:s}):[];a.length?o||(o=!0,i.call(this,new za(e,this,r.originalEvent,{features:a}))):o=!1;},s=()=>{o=!1;};return {layers:new Set(t),listener:i,delegates:{mousemove:r,mouseout:s}}}if("mouseleave"===e||"mouseout"===e){let o=!1;const r=r=>{const s=t.filter((e=>this.getLayer(e)));(s.length?this.queryRenderedFeatures(r.point,{layers:s}):[]).length?o=!0:o&&(o=!1,i.call(this,new za(e,this,r.originalEvent)));},s=t=>{o&&(o=!1,i.call(this,new za(e,this,t.originalEvent)));};return {layers:new Set(t),listener:i,delegates:{mousemove:r,mouseout:s}}}{const o=e=>{const o=t.filter((e=>this.getLayer(e))),r=o.length?this.queryRenderedFeatures(e.point,{layers:o}):[];r.length&&(e.features=r,i.call(this,e),delete e.features);};return {layers:new Set(t),listener:i,delegates:{[e]:o}}}}on(e,t,i){if("function"==typeof t||void 0===i)return super.on(e,t);if(Array.isArray(t)||(t=[t]),t)for(const e of t)if(!this._isValidId(e))return this;const o=this._createDelegatedListener(e,t,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(o);for(const e in o.delegates)this.on(e,o.delegates[e]);return this}once(e,t,i){if("function"==typeof t||void 0===i)return super.once(e,t);if(Array.isArray(t)||(t=[t]),t)for(const e of t)if(!this._isValidId(e))return this;const o=this._createDelegatedListener(e,t,i);for(const e in o.delegates)this.once(e,o.delegates[e]);return this}off(e,t,i){if("function"==typeof t||void 0===i)return super.off(e,t);const o=new Set(Array.isArray(t)?t:[t]);for(const e of o)if(!this._isValidId(e))return this;const r=(e,t)=>{if(e.size!==t.size)return !1;for(const i of e)if(!t.has(i))return !1;return !0},s=this._delegatedListeners?this._delegatedListeners[e]:void 0;return s&&(e=>{for(let t=0;t{o?(e.w(`Unable to perform style diff: ${String(o.message||o.error||o)}. Rebuilding the style from scratch.`),this._updateStyle(t,i)):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(t,i){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),t){const o=e.l({},i);i&&i.config&&(o.initialConfig=i.config,delete o.config),this.style=new co(this,o).load(t),this.style.setEventedParent(this,{style:this.style});}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new co(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.t(new Error("IDs can't be empty."))),!1):!e.cn(t)||(this.fire(new e.t(new Error(`IDs can't contain special symbols: "${t}".`))),!1)}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:o=1,sdf:r=!1,stretchX:s,stretchY:a,content:n}={}){if(this._lazyInitEmptyStyle(),i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap){const{width:l,height:c,data:h}=e.q.getImageData(i);this.style.addImage(t,{data:new e.r({width:l,height:c},h),pixelRatio:o,stretchX:s,stretchY:a,content:n,sdf:r,version:0});}else if(void 0===i.width||void 0===i.height)this.fire(new e.t(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:l,height:c}=i,h=i;this.style.addImage(t,{data:new e.r({width:l,height:c},new Uint8Array(h.data)),pixelRatio:o,stretchX:s,stretchY:a,content:n,sdf:r,version:0,userImage:h}),h.onAdd&&h.onAdd(this,t);}}updateImage(t,i){this._lazyInitEmptyStyle();const o=this.style.getImage(t);if(!o)return void this.fire(new e.t(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||ImageBitmap&&i instanceof ImageBitmap?e.q.getImageData(i):i,{width:s,height:a,data:n}=r;if(void 0===s||void 0===a)return void this.fire(new e.t(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!==o.data.width||a!==o.data.height)return void this.fire(new e.t(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 (${o.data.width}, ${o.data.height})`)));const l=!(i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap);o.data.replace(n,l),this.style.updateImage(t,o);}hasImage(t){return t?!!this.style&&!!this.style.getImage(t):(this.fire(new e.t(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e);}loadImage(t,i){e.o(this._requestManager.transformRequest(t,e.R.Image),((t,o)=>{i(t,o instanceof HTMLImageElement?e.q.getImageData(o):o);}));}listImages(){return this.style.listImages()}addModel(e,t){this._lazyInitEmptyStyle(),this.style.addModel(e,t);}hasModel(t){return t?this.style.hasModel(t):(this.fire(new e.t(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(e,t){return this.style.addImport(e,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,o={}){return this._isValidId(e)?(this.style.setPaintProperty(e,t,i,o),this._update(!0)):this}getPaintProperty(e,t){return this._isValidId(e)?this.style.getPaintProperty(e,t):null}setLayoutProperty(e,t,i,o={}){return this._isValidId(e)?(this.style.setLayoutProperty(e,t,i,o),this._update(!0)):this}getLayoutProperty(e,t){return this._isValidId(e)?this.style.getLayoutProperty(e,t):null}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)}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}setColorTheme(e){return this._lazyInitEmptyStyle(),this.style.setColorTheme(e),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.bK.convert(t),this.transform):0}setFeatureState(e,t){return this._isValidId(e.source)?(this.style.setFeatureState(e,t),this._update()):this}removeFeatureState(e,t){return this._isValidId(e.source)?(this.style.removeFeatureState(e,t),this._update()):this}getFeatureState(e){return this._isValidId(e.source)?this.style.getFeatureState(e):null}_updateContainerDimensions(){if(!this._container)return;const e=this._container.getBoundingClientRect().width||400,t=this._container.getBoundingClientRect().height||300;let i,o,r,s=this._container;for(;s&&(!o||!r);){const e=window.getComputedStyle(s).transform;e&&"none"!==e&&(i=e.match(/matrix.*\((.+)\)/)[1].split(", "),i[0]&&"0"!==i[0]&&"1"!==i[0]&&(o=i[0]),i[3]&&"0"!==i[3]&&"1"!==i[3]&&(r=i[3])),s=s.parentElement;}this._containerWidth=o?Math.abs(e/o):e,this._containerHeight=r?Math.abs(t/r):t;}_detectMissingCSS(){"rgb(250, 128, 114)"!==window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&e.w("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.");}_setupContainer(){const e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=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),o=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach((e=>{o[e]=l("div",`mapboxgl-ctrl-${e}`,i);})),this._container.addEventListener("scroll",this._onMapScroll,!1);}_resizeCanvas(t,i){const o=e.q.devicePixelRatio||1;this._canvas.width=o*Math.ceil(t),this._canvas.height=o*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=e.l({},n.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 wa(i,this._contextCreateOptions,this.transform,this._tp),this.on("data",(e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0);})),e.m.testSupport(i)):this.fire(new e.t(new Error("Failed to initialize WebGL")));}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new e.x("webglcontextlost",{originalEvent:t}));}_contextRestored(t){this._setupPainter(),this.resize(),this._update(),this.fire(new e.x("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.x("renderstart")),++this._frameId;const s=this.painter.context.extTimerQuery,a=e.q.now(),n=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(r=n.createQuery(),n.beginQuery(s.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,o=e.q.now(),r=new e.a3(t,{now:o,fadeDuration:l,pitch:i,transition:this.style.transition});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(a),this.style.updateSources(this.transform),this._forceMarkerAndPopupUpdate()):c=this._updateAverageElevation(a);const h=this.style&&this.style._updatePlacement(this.painter,this.painter.transform,this.showCollisionBoxes,l,this._crossSourceCollisions,this.painter.replacementSource);if(h&&(this._placementDirty=h.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.x("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,o.mark(i.load),this.fire(new e.x("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),r){const t=e.q.now()-a;n.endQuery(s.TIME_ELAPSED_EXT),setTimeout((()=>{const i=n.getQueryParameter(r,n.QUERY_RESULT)/1e6;n.deleteQuery(r),this.fire(new e.x("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.x("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.x("gpu-timing-deferred-render",{gpuTime:i}));}),50);}const u=this._sourcesDirty||this._styleDirty||this._placementDirty||c;if(u||this._repaint)this.triggerRepaint();else {const t=this.idle();if(t&&(c=this._updateAverageElevation(a,!0)),c)this.triggerRepaint();else if(this._triggerFrame(!1),t&&(this.fire(new e.x("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new e.x("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1;}}!this._loaded||this._fullyLoaded||u||(this._fullyLoaded=!0,o.mark(i.fullLoad),this._performanceMetricsCollection&&k(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 o=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(o||(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 s=Math.abs(t-r);if(s>1){if(this._isInitialLoad||o)return this._averageElevation.jumpTo(r),i(r);this._averageElevation.easeTo(r,e,300);}else if(s>1e-4)return this._averageElevation.jumpTo(r),i(r)}return !!this._averageElevation.isEasing(e)&&i(this._averageElevation.getValue(e))}_authenticate(){N(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(t=>{if(t&&(t.message===w||401===t.status)){const t=this.painter.context.gl;G(t,!1),this._logoControl instanceof Cn&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new e.t(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/")));}})),M(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(()=>{}));}_postStyleLoadEvent(){this.style.globalId&&O(this._requestManager._customAccessToken,{map:this,skuToken:this._requestManager._skuToken,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()});}_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,o=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,o),this._canvasPixelComparison(r(e),t.canvasCopies.map(r),t.timeStamps)}_canvasPixelComparison(e,t,i){let o=i[1]-i[0];const r=e.length/4;for(let s=0;s{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.bf(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.dy(t,i);}get version(){return t}},NavigationControl:class{constructor(t={}){this.options=e.l({},Pn,t),this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(e.aJ(["_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.aJ(["_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(),o=t===e.getMinZoom();this._zoomInButton.disabled=i,this._zoomOutButton.disabled=o,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",o.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 Mn(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=e.l({geolocation:i},kn,t),e.aJ(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Ta(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.x("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.x("geolocate",t)),this._finish();}}_updateCamera(t){const i=new e.bK(t.coords.longitude,t.coords.latitude),o=t.coords.accuracy,r=this._map.getBearing(),s=e.l({bearing:r},this.options.fitBoundsOptions);this._map.fitBounds(i.toBounds(o),s,{geolocateSource:!0});}_updateMarker(t){if(t){const i=new e.bK(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.bD(1,t._center.lat)*t.worldSize,o=Math.ceil(2*this._accuracy*i);this._circleElement.style.width=`${o}px`,this._circleElement.style.height=`${o}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.x("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 Fn({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=l("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Fn({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.x("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.x("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.x("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.x("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:En,ScaleControl:class{constructor(t={}){this.options=e.l({},Bn,t),this._isNumberFormatSupported=function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"short",unit:"meter"}),!0}catch(e){return !1}}(),e.aJ(["_update","_setScale","setUnit"],this);}getDefaultPosition(){return "bottom-left"}_update(){const e=this.options.maxWidth||100,t=this._map,i=t._containerHeight/2,o=t._containerWidth/2-e/2,r=t.unproject([o,i]),s=t.unproject([o+e,i]),a=r.distanceTo(s);if("imperial"===this.options.unit){const t=3.2808*a;t>5280?this._setScale(e,t/5280,"mile"):this._setScale(e,t,"foot");}else "nautical"===this.options.unit?this._setScale(e,a/1852,"nautical-mile"):a>=1e3?this._setScale(e,a/1e3,"kilometer"):this._setScale(e,a,"meter");}_setScale(e,t,i){this._map._requestDomTask((()=>{const o=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=o/t;this._container.innerHTML=this._isNumberFormatSupported&&"nautical-mile"!==i?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:i}).format(o):`${o} ${Nn[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.aJ(["_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();}},Popup:class extends e.E{constructor(t){super(),this.options=e.l(Object.create(Un),t),e.aJ(["_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.x("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.x("close")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=e.bK.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}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 o;for(i.innerHTML=e;o=i.firstChild,o;)t.appendChild(o);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.setAttribute("aria-hidden","true"),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,o=this._pos;if(!t||!i||!o)return "bottom";const r=i.offsetWidth,s=i.offsetHeight,a=o.xt.transform.width-r/2;if(o.y+et.transform.height-s){if(a)return "bottom-left";if(n)return "bottom-right"}return a?"left":n?"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,o=this._content;if(!i||!this._lngLat&&!this._trackPointer||!o)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(o)),this.options.maxWidth&&r.style.maxWidth!==this.options.maxWidth&&(r.style.maxWidth=this.options.maxWidth),i.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=zn(this._lngLat,this._pos,i.transform)),!this._trackPointer||t){const o=this._pos=this._trackPointer&&t instanceof e.P?t:i.project(this._lngLat),r=jn(this.options.offset),s=this._anchor=this._getAnchor(r.y),a=jn(this.options.offset,s),n=o.add(a).round();i._requestDomTask((()=>{this._container&&s&&(this._container.style.transform=`${On[s]} translate(${n.x}px,${n.y}px)`);}));}if(!this._marker&&i._showingGlobe()){const t=e.dz(i.transform,this._lngLat)?0:1;this._setOpacity(t);}this._updateClassList();}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(Gn);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:Fn,Style:co,LngLat:e.bK,LngLatBounds:e.as,Point:e.P,MercatorCoordinate:e.a5,FreeCameraOptions:Ui,Evented:e.E,config:e.e,prewarm:e.dE,clearPrewarmedResources:e.dF,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.dG.workerCount},set workerCount(t){e.dG.workerCount=t;},get maxParallelImageRequests(){return e.e.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){e.e.MAX_PARALLEL_IMAGE_REQUESTS=t;},clearStorage(t){e.dH(t);},get workerUrl(){return e.dI.workerUrl},set workerUrl(t){e.dI.workerUrl=t;},get workerClass(){return e.dI.workerClass},set workerClass(t){e.dI.workerClass=t;},get workerParams(){return e.dI.workerParams},set workerParams(t){e.dI.workerParams=t;},get dracoUrl(){return e.dJ()},set dracoUrl(t){e.dK(t);},get meshoptUrl(){return e.dL()},set meshoptUrl(t){e.dM(t);},setNow:e.q.setNow,restoreNow:e.q.restoreNow}})); // // Our custom intro provides a specialized "define()" function, called by the // AMD modules below, that sets up the worker blob URL and then executes the // main module, storing its exported value as 'mapboxgl' var mapboxgl$1 = mapboxgl; return mapboxgl$1; })); //# sourceMappingURL=mapbox-gl.js.map