territories-dashboard-lib 0.1.30__py3-none-any.whl → 0.1.31__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of territories-dashboard-lib might be problematic. Click here for more details.

Files changed (15) hide show
  1. territories_dashboard_lib/indicators_lib/migrations/0003_indicator_short_title.py +18 -0
  2. territories_dashboard_lib/indicators_lib/models.py +2 -0
  3. territories_dashboard_lib/website_lib/serializers.py +2 -0
  4. territories_dashboard_lib/website_lib/static/territories_dashboard_lib/website/react/indicatorMap.bundle.js +1 -1
  5. territories_dashboard_lib/website_lib/static/territories_dashboard_lib/website/react/sankeyGraph.bundle.js +1 -1
  6. territories_dashboard_lib/website_lib/static/territories_dashboard_lib/website/react/vendors.bundle.js +2 -0
  7. territories_dashboard_lib/website_lib/templates/territories_dashboard_lib/website/layout/base.css +1 -0
  8. territories_dashboard_lib/website_lib/templates/territories_dashboard_lib/website/pages/indicators/details/map.css +40 -2
  9. territories_dashboard_lib/website_lib/templates/territories_dashboard_lib/website/pages/indicators/details/page.html +9 -0
  10. {territories_dashboard_lib-0.1.30.dist-info → territories_dashboard_lib-0.1.31.dist-info}/METADATA +1 -1
  11. {territories_dashboard_lib-0.1.30.dist-info → territories_dashboard_lib-0.1.31.dist-info}/RECORD +14 -13
  12. territories_dashboard_lib/website_lib/static/territories_dashboard_lib/website/react/vendors-node_modules_mapbox-gl_dist_mapbox-gl_js.bundle.js +0 -2
  13. {territories_dashboard_lib-0.1.30.dist-info → territories_dashboard_lib-0.1.31.dist-info}/WHEEL +0 -0
  14. {territories_dashboard_lib-0.1.30.dist-info → territories_dashboard_lib-0.1.31.dist-info}/licenses/licence.md +0 -0
  15. {territories_dashboard_lib-0.1.30.dist-info → territories_dashboard_lib-0.1.31.dist-info}/top_level.txt +0 -0
@@ -1,2 +0,0 @@
1
- /*! For license information please see vendors-node_modules_mapbox-gl_dist_mapbox-gl_js.bundle.js.LICENSE.txt */
2
- (self.webpackChunkreact_components=self.webpackChunkreact_components||[]).push([["vendors-node_modules_mapbox-gl_dist_mapbox-gl_js"],{"./node_modules/mapbox-gl/dist/mapbox-gl.js":function(e){e.exports=function(){"use strict";var e,t,i;function r(r,n){if(e)if(t){var o="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+e+")(sharedChunk); ("+t+")(sharedChunk); self.onerror = null;",s={};e(s),i=n(s),"undefined"!=typeof window&&window&&window.URL&&window.URL.createObjectURL&&(i.workerUrl=window.URL.createObjectURL(new Blob([o],{type:"text/javascript"})))}else t=n;else e=n}return r(0,(function(e){function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var i,r={},n={};function o(){if(i)return n;i=1,Object.defineProperty(n,"__esModule",{value:!0}),n.setMatrixArrayType=function(e){n.ARRAY_TYPE=t=e},n.toRadian=function(e){return e*o},n.equals=function(t,i){return Math.abs(t-i)<=e*Math.max(1,Math.abs(t),Math.abs(i))},n.RANDOM=n.ARRAY_TYPE=n.EPSILON=void 0;var e=1e-6;n.EPSILON=e;var t="undefined"!=typeof Float32Array?Float32Array:Array;n.ARRAY_TYPE=t;var r=Math.random;n.RANDOM=r;var o=Math.PI/180;return Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)}),n}var s,a={};function l(){if(s)return a;function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}s=1,Object.defineProperty(a,"__esModule",{value:!0}),a.create=function(){var e=new t.ARRAY_TYPE(4);return t.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e},a.clone=function(e){var i=new t.ARRAY_TYPE(4);return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i},a.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},a.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e},a.fromValues=function(e,i,r,n){var o=new t.ARRAY_TYPE(4);return o[0]=e,o[1]=i,o[2]=r,o[3]=n,o},a.set=function(e,t,i,r,n){return e[0]=t,e[1]=i,e[2]=r,e[3]=n,e},a.transpose=function(e,t){if(e===t){var i=t[1];e[1]=t[2],e[2]=i}else e[0]=t[0],e[1]=t[2],e[2]=t[1],e[3]=t[3];return e},a.invert=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=i*o-n*r;return s?(e[0]=o*(s=1/s),e[1]=-r*s,e[2]=-n*s,e[3]=i*s,e):null},a.adjoint=function(e,t){var i=t[0];return e[0]=t[3],e[1]=-t[1],e[2]=-t[2],e[3]=i,e},a.determinant=function(e){return e[0]*e[3]-e[2]*e[1]},a.multiply=r,a.rotate=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=r*l+o*a,e[1]=n*l+s*a,e[2]=r*-a+o*l,e[3]=n*-a+s*l,e},a.scale=function(e,t,i){var r=t[1],n=t[2],o=t[3],s=i[0],a=i[1];return e[0]=t[0]*s,e[1]=r*s,e[2]=n*a,e[3]=o*a,e},a.fromRotation=function(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=i,e[2]=-i,e[3]=r,e},a.fromScaling=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e},a.str=function(e){return"mat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},a.frob=function(e){return Math.hypot(e[0],e[1],e[2],e[3])},a.LDU=function(e,t,i,r){return e[2]=r[2]/r[0],i[0]=r[0],i[1]=r[1],i[3]=r[3]-e[2]*i[1],[e,t,i]},a.add=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e[3]=t[3]+i[3],e},a.subtract=n,a.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},a.equals=function(e,i){var r=e[0],n=e[1],o=e[2],s=e[3],a=i[0],l=i[1],c=i[2],h=i[3];return Math.abs(r-a)<=t.EPSILON*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(n-l)<=t.EPSILON*Math.max(1,Math.abs(n),Math.abs(l))&&Math.abs(o-c)<=t.EPSILON*Math.max(1,Math.abs(o),Math.abs(c))&&Math.abs(s-h)<=t.EPSILON*Math.max(1,Math.abs(s),Math.abs(h))},a.multiplyScalar=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e},a.multiplyScalarAndAdd=function(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e[3]=t[3]+i[3]*r,e},a.sub=a.mul=void 0;var t=function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var r=i(void 0);if(r&&r.has(t))return r.get(t);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if("default"!==s&&Object.prototype.hasOwnProperty.call(t,s)){var a=o?Object.getOwnPropertyDescriptor(t,s):null;a&&(a.get||a.set)?Object.defineProperty(n,s,a):n[s]=t[s]}return n.default=t,r&&r.set(t,n),n}(o());function i(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(i=function(e){return e?r:t})(e)}function r(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=i[0],l=i[1],c=i[2],h=i[3];return e[0]=r*a+o*l,e[1]=n*a+s*l,e[2]=r*c+o*h,e[3]=n*c+s*h,e}function n(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e[3]=t[3]-i[3],e}return a.mul=r,a.sub=n,a}var c,h={};function u(){if(c)return h;function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}c=1,Object.defineProperty(h,"__esModule",{value:!0}),h.create=function(){var e=new t.ARRAY_TYPE(6);return t.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0,e[4]=0,e[5]=0),e[0]=1,e[3]=1,e},h.clone=function(e){var i=new t.ARRAY_TYPE(6);return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=e[4],i[5]=e[5],i},h.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e},h.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e},h.fromValues=function(e,i,r,n,o,s){var a=new t.ARRAY_TYPE(6);return a[0]=e,a[1]=i,a[2]=r,a[3]=n,a[4]=o,a[5]=s,a},h.set=function(e,t,i,r,n,o,s){return e[0]=t,e[1]=i,e[2]=r,e[3]=n,e[4]=o,e[5]=s,e},h.invert=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=i*o-r*n;return l?(e[0]=o*(l=1/l),e[1]=-r*l,e[2]=-n*l,e[3]=i*l,e[4]=(n*a-o*s)*l,e[5]=(r*s-i*a)*l,e):null},h.determinant=function(e){return e[0]*e[3]-e[1]*e[2]},h.multiply=r,h.rotate=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=Math.sin(i),h=Math.cos(i);return e[0]=r*h+o*c,e[1]=n*h+s*c,e[2]=r*-c+o*h,e[3]=n*-c+s*h,e[4]=a,e[5]=l,e},h.scale=function(e,t,i){var r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=i[0],c=i[1];return e[0]=t[0]*l,e[1]=r*l,e[2]=n*c,e[3]=o*c,e[4]=s,e[5]=a,e},h.translate=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=i[0],h=i[1];return e[0]=r,e[1]=n,e[2]=o,e[3]=s,e[4]=r*c+o*h+a,e[5]=n*c+s*h+l,e},h.fromRotation=function(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=i,e[2]=-i,e[3]=r,e[4]=0,e[5]=0,e},h.fromScaling=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e[4]=0,e[5]=0,e},h.fromTranslation=function(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=t[0],e[5]=t[1],e},h.str=function(e){return"mat2d("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+")"},h.frob=function(e){return Math.hypot(e[0],e[1],e[2],e[3],e[4],e[5],1)},h.add=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e[3]=t[3]+i[3],e[4]=t[4]+i[4],e[5]=t[5]+i[5],e},h.subtract=n,h.multiplyScalar=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*i,e[5]=t[5]*i,e},h.multiplyScalarAndAdd=function(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e[3]=t[3]+i[3]*r,e[4]=t[4]+i[4]*r,e[5]=t[5]+i[5]*r,e},h.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]},h.equals=function(e,i){var r=e[0],n=e[1],o=e[2],s=e[3],a=e[4],l=e[5],c=i[0],h=i[1],u=i[2],d=i[3],p=i[4],f=i[5];return Math.abs(r-c)<=t.EPSILON*Math.max(1,Math.abs(r),Math.abs(c))&&Math.abs(n-h)<=t.EPSILON*Math.max(1,Math.abs(n),Math.abs(h))&&Math.abs(o-u)<=t.EPSILON*Math.max(1,Math.abs(o),Math.abs(u))&&Math.abs(s-d)<=t.EPSILON*Math.max(1,Math.abs(s),Math.abs(d))&&Math.abs(a-p)<=t.EPSILON*Math.max(1,Math.abs(a),Math.abs(p))&&Math.abs(l-f)<=t.EPSILON*Math.max(1,Math.abs(l),Math.abs(f))},h.sub=h.mul=void 0;var t=function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var r=i(void 0);if(r&&r.has(t))return r.get(t);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if("default"!==s&&Object.prototype.hasOwnProperty.call(t,s)){var a=o?Object.getOwnPropertyDescriptor(t,s):null;a&&(a.get||a.set)?Object.defineProperty(n,s,a):n[s]=t[s]}return n.default=t,r&&r.set(t,n),n}(o());function i(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(i=function(e){return e?r:t})(e)}function r(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=i[0],h=i[1],u=i[2],d=i[3],p=i[4],f=i[5];return e[0]=r*c+o*h,e[1]=n*c+s*h,e[2]=r*u+o*d,e[3]=n*u+s*d,e[4]=r*p+o*f+a,e[5]=n*p+s*f+l,e}function n(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e[3]=t[3]-i[3],e[4]=t[4]-i[4],e[5]=t[5]-i[5],e}return h.mul=r,h.sub=n,h}var d,p={};function f(){if(d)return p;function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}d=1,Object.defineProperty(p,"__esModule",{value:!0}),p.create=function(){var e=new t.ARRAY_TYPE(9);return t.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e},p.fromMat4=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e},p.clone=function(e){var i=new t.ARRAY_TYPE(9);return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7],i[8]=e[8],i},p.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},p.fromValues=function(e,i,r,n,o,s,a,l,c){var h=new t.ARRAY_TYPE(9);return h[0]=e,h[1]=i,h[2]=r,h[3]=n,h[4]=o,h[5]=s,h[6]=a,h[7]=l,h[8]=c,h},p.set=function(e,t,i,r,n,o,s,a,l,c){return e[0]=t,e[1]=i,e[2]=r,e[3]=n,e[4]=o,e[5]=s,e[6]=a,e[7]=l,e[8]=c,e},p.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},p.transpose=function(e,t){if(e===t){var i=t[1],r=t[2],n=t[5];e[1]=t[3],e[2]=t[6],e[3]=i,e[5]=t[7],e[6]=r,e[7]=n}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8];return e},p.invert=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=h*s-a*c,d=-h*o+a*l,p=c*o-s*l,f=i*u+r*d+n*p;return f?(e[0]=u*(f=1/f),e[1]=(-h*r+n*c)*f,e[2]=(a*r-n*s)*f,e[3]=d*f,e[4]=(h*i-n*l)*f,e[5]=(-a*i+n*o)*f,e[6]=p*f,e[7]=(-c*i+r*l)*f,e[8]=(s*i-r*o)*f,e):null},p.adjoint=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],h=t[8];return e[0]=s*h-a*c,e[1]=n*c-r*h,e[2]=r*a-n*s,e[3]=a*l-o*h,e[4]=i*h-n*l,e[5]=n*o-i*a,e[6]=o*c-s*l,e[7]=r*l-i*c,e[8]=i*s-r*o,e},p.determinant=function(e){var t=e[3],i=e[4],r=e[5],n=e[6],o=e[7],s=e[8];return e[0]*(s*i-r*o)+e[1]*(-s*t+r*n)+e[2]*(o*t-i*n)},p.multiply=r,p.translate=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=t[8],d=i[0],p=i[1];return e[0]=r,e[1]=n,e[2]=o,e[3]=s,e[4]=a,e[5]=l,e[6]=d*r+p*s+c,e[7]=d*n+p*a+h,e[8]=d*o+p*l+u,e},p.rotate=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=t[8],d=Math.sin(i),p=Math.cos(i);return e[0]=p*r+d*s,e[1]=p*n+d*a,e[2]=p*o+d*l,e[3]=p*s-d*r,e[4]=p*a-d*n,e[5]=p*l-d*o,e[6]=c,e[7]=h,e[8]=u,e},p.scale=function(e,t,i){var r=i[0],n=i[1];return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=n*t[3],e[4]=n*t[4],e[5]=n*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},p.fromTranslation=function(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=t[0],e[7]=t[1],e[8]=1,e},p.fromRotation=function(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=i,e[2]=0,e[3]=-i,e[4]=r,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},p.fromScaling=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=t[1],e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},p.fromMat2d=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=0,e[3]=t[2],e[4]=t[3],e[5]=0,e[6]=t[4],e[7]=t[5],e[8]=1,e},p.fromQuat=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=i+i,a=r+r,l=n+n,c=i*s,h=r*s,u=r*a,d=n*s,p=n*a,f=n*l,m=o*s,_=o*a,g=o*l;return e[0]=1-u-f,e[3]=h-g,e[6]=d+_,e[1]=h+g,e[4]=1-c-f,e[7]=p-m,e[2]=d-_,e[5]=p+m,e[8]=1-c-u,e},p.normalFromMat4=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],p=t[11],f=t[12],m=t[13],_=t[14],g=t[15],y=i*a-r*s,x=i*l-n*s,v=i*c-o*s,b=r*l-n*a,w=r*c-o*a,T=n*c-o*l,S=h*m-u*f,M=h*_-d*f,E=h*g-p*f,A=u*_-d*m,I=u*g-p*m,C=d*g-p*_,P=y*C-x*I+v*A+b*E-w*M+T*S;return P?(e[0]=(a*C-l*I+c*A)*(P=1/P),e[1]=(l*E-s*C-c*M)*P,e[2]=(s*I-a*E+c*S)*P,e[3]=(n*I-r*C-o*A)*P,e[4]=(i*C-n*E+o*M)*P,e[5]=(r*E-i*I-o*S)*P,e[6]=(m*T-_*w+g*b)*P,e[7]=(_*v-f*T-g*x)*P,e[8]=(f*w-m*v+g*y)*P,e):null},p.projection=function(e,t,i){return e[0]=2/t,e[1]=0,e[2]=0,e[3]=0,e[4]=-2/i,e[5]=0,e[6]=-1,e[7]=1,e[8]=1,e},p.str=function(e){return"mat3("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+")"},p.frob=function(e){return Math.hypot(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},p.add=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e[3]=t[3]+i[3],e[4]=t[4]+i[4],e[5]=t[5]+i[5],e[6]=t[6]+i[6],e[7]=t[7]+i[7],e[8]=t[8]+i[8],e},p.subtract=n,p.multiplyScalar=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*i,e},p.multiplyScalarAndAdd=function(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e[3]=t[3]+i[3]*r,e[4]=t[4]+i[4]*r,e[5]=t[5]+i[5]*r,e[6]=t[6]+i[6]*r,e[7]=t[7]+i[7]*r,e[8]=t[8]+i[8]*r,e},p.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]},p.equals=function(e,i){var r=e[0],n=e[1],o=e[2],s=e[3],a=e[4],l=e[5],c=e[6],h=e[7],u=e[8],d=i[0],p=i[1],f=i[2],m=i[3],_=i[4],g=i[5],y=i[6],x=i[7],v=i[8];return Math.abs(r-d)<=t.EPSILON*Math.max(1,Math.abs(r),Math.abs(d))&&Math.abs(n-p)<=t.EPSILON*Math.max(1,Math.abs(n),Math.abs(p))&&Math.abs(o-f)<=t.EPSILON*Math.max(1,Math.abs(o),Math.abs(f))&&Math.abs(s-m)<=t.EPSILON*Math.max(1,Math.abs(s),Math.abs(m))&&Math.abs(a-_)<=t.EPSILON*Math.max(1,Math.abs(a),Math.abs(_))&&Math.abs(l-g)<=t.EPSILON*Math.max(1,Math.abs(l),Math.abs(g))&&Math.abs(c-y)<=t.EPSILON*Math.max(1,Math.abs(c),Math.abs(y))&&Math.abs(h-x)<=t.EPSILON*Math.max(1,Math.abs(h),Math.abs(x))&&Math.abs(u-v)<=t.EPSILON*Math.max(1,Math.abs(u),Math.abs(v))},p.sub=p.mul=void 0;var t=function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var r=i(void 0);if(r&&r.has(t))return r.get(t);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if("default"!==s&&Object.prototype.hasOwnProperty.call(t,s)){var a=o?Object.getOwnPropertyDescriptor(t,s):null;a&&(a.get||a.set)?Object.defineProperty(n,s,a):n[s]=t[s]}return n.default=t,r&&r.set(t,n),n}(o());function i(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(i=function(e){return e?r:t})(e)}function r(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=t[8],d=i[0],p=i[1],f=i[2],m=i[3],_=i[4],g=i[5],y=i[6],x=i[7],v=i[8];return e[0]=d*r+p*s+f*c,e[1]=d*n+p*a+f*h,e[2]=d*o+p*l+f*u,e[3]=m*r+_*s+g*c,e[4]=m*n+_*a+g*h,e[5]=m*o+_*l+g*u,e[6]=y*r+x*s+v*c,e[7]=y*n+x*a+v*h,e[8]=y*o+x*l+v*u,e}function n(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e[3]=t[3]-i[3],e[4]=t[4]-i[4],e[5]=t[5]-i[5],e[6]=t[6]-i[6],e[7]=t[7]-i[7],e[8]=t[8]-i[8],e}return p.mul=r,p.sub=n,p}var m,_={};function g(){if(m)return _;function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}m=1,Object.defineProperty(_,"__esModule",{value:!0}),_.create=function(){var e=new t.ARRAY_TYPE(16);return t.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e},_.clone=function(e){var i=new t.ARRAY_TYPE(16);return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7],i[8]=e[8],i[9]=e[9],i[10]=e[10],i[11]=e[11],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15],i},_.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},_.fromValues=function(e,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_){var g=new t.ARRAY_TYPE(16);return g[0]=e,g[1]=i,g[2]=r,g[3]=n,g[4]=o,g[5]=s,g[6]=a,g[7]=l,g[8]=c,g[9]=h,g[10]=u,g[11]=d,g[12]=p,g[13]=f,g[14]=m,g[15]=_,g},_.set=function(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_){return e[0]=t,e[1]=i,e[2]=r,e[3]=n,e[4]=o,e[5]=s,e[6]=a,e[7]=l,e[8]=c,e[9]=h,e[10]=u,e[11]=d,e[12]=p,e[13]=f,e[14]=m,e[15]=_,e},_.identity=r,_.transpose=function(e,t){if(e===t){var i=t[1],r=t[2],n=t[3],o=t[6],s=t[7],a=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=i,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=o,e[11]=t[14],e[12]=n,e[13]=s,e[14]=a}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e},_.invert=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],p=t[11],f=t[12],m=t[13],_=t[14],g=t[15],y=i*a-r*s,x=i*l-n*s,v=i*c-o*s,b=r*l-n*a,w=r*c-o*a,T=n*c-o*l,S=h*m-u*f,M=h*_-d*f,E=h*g-p*f,A=u*_-d*m,I=u*g-p*m,C=d*g-p*_,P=y*C-x*I+v*A+b*E-w*M+T*S;return P?(e[0]=(a*C-l*I+c*A)*(P=1/P),e[1]=(n*I-r*C-o*A)*P,e[2]=(m*T-_*w+g*b)*P,e[3]=(d*w-u*T-p*b)*P,e[4]=(l*E-s*C-c*M)*P,e[5]=(i*C-n*E+o*M)*P,e[6]=(_*v-f*T-g*x)*P,e[7]=(h*T-d*v+p*x)*P,e[8]=(s*I-a*E+c*S)*P,e[9]=(r*E-i*I-o*S)*P,e[10]=(f*w-m*v+g*y)*P,e[11]=(u*v-h*w-p*y)*P,e[12]=(a*M-s*A-l*S)*P,e[13]=(i*A-r*M+n*S)*P,e[14]=(m*x-f*b-_*y)*P,e[15]=(h*b-u*x+d*y)*P,e):null},_.adjoint=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],p=t[11],f=t[12],m=t[13],_=t[14],g=t[15];return e[0]=a*(d*g-p*_)-u*(l*g-c*_)+m*(l*p-c*d),e[1]=-(r*(d*g-p*_)-u*(n*g-o*_)+m*(n*p-o*d)),e[2]=r*(l*g-c*_)-a*(n*g-o*_)+m*(n*c-o*l),e[3]=-(r*(l*p-c*d)-a*(n*p-o*d)+u*(n*c-o*l)),e[4]=-(s*(d*g-p*_)-h*(l*g-c*_)+f*(l*p-c*d)),e[5]=i*(d*g-p*_)-h*(n*g-o*_)+f*(n*p-o*d),e[6]=-(i*(l*g-c*_)-s*(n*g-o*_)+f*(n*c-o*l)),e[7]=i*(l*p-c*d)-s*(n*p-o*d)+h*(n*c-o*l),e[8]=s*(u*g-p*m)-h*(a*g-c*m)+f*(a*p-c*u),e[9]=-(i*(u*g-p*m)-h*(r*g-o*m)+f*(r*p-o*u)),e[10]=i*(a*g-c*m)-s*(r*g-o*m)+f*(r*c-o*a),e[11]=-(i*(a*p-c*u)-s*(r*p-o*u)+h*(r*c-o*a)),e[12]=-(s*(u*_-d*m)-h*(a*_-l*m)+f*(a*d-l*u)),e[13]=i*(u*_-d*m)-h*(r*_-n*m)+f*(r*d-n*u),e[14]=-(i*(a*_-l*m)-s*(r*_-n*m)+f*(r*l-n*a)),e[15]=i*(a*d-l*u)-s*(r*d-n*u)+h*(r*l-n*a),e},_.determinant=function(e){var t=e[0],i=e[1],r=e[2],n=e[3],o=e[4],s=e[5],a=e[6],l=e[7],c=e[8],h=e[9],u=e[10],d=e[11],p=e[12],f=e[13],m=e[14],_=e[15];return(t*s-i*o)*(u*_-d*m)-(t*a-r*o)*(h*_-d*f)+(t*l-n*o)*(h*m-u*f)+(i*a-r*s)*(c*_-d*p)-(i*l-n*s)*(c*m-u*p)+(r*l-n*a)*(c*f-h*p)},_.multiply=n,_.translate=function(e,t,i){var r,n,o,s,a,l,c,h,u,d,p,f,m=i[0],_=i[1],g=i[2];return t===e?(e[12]=t[0]*m+t[4]*_+t[8]*g+t[12],e[13]=t[1]*m+t[5]*_+t[9]*g+t[13],e[14]=t[2]*m+t[6]*_+t[10]*g+t[14],e[15]=t[3]*m+t[7]*_+t[11]*g+t[15]):(n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=t[8],d=t[9],p=t[10],f=t[11],e[0]=r=t[0],e[1]=n,e[2]=o,e[3]=s,e[4]=a,e[5]=l,e[6]=c,e[7]=h,e[8]=u,e[9]=d,e[10]=p,e[11]=f,e[12]=r*m+a*_+u*g+t[12],e[13]=n*m+l*_+d*g+t[13],e[14]=o*m+c*_+p*g+t[14],e[15]=s*m+h*_+f*g+t[15]),e},_.scale=function(e,t,i){var r=i[0],n=i[1],o=i[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},_.rotate=function(e,i,r,n){var o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,S,M,E,A,I,C=n[0],P=n[1],z=n[2],D=Math.hypot(C,P,z);return D<t.EPSILON?null:(C*=D=1/D,P*=D,z*=D,o=Math.sin(r),s=Math.cos(r),c=i[1],h=i[2],u=i[3],p=i[5],f=i[6],m=i[7],g=i[9],y=i[10],x=i[11],v=C*C*(a=1-s)+s,T=C*P*a-z*o,S=P*P*a+s,M=z*P*a+C*o,E=C*z*a+P*o,A=P*z*a-C*o,I=z*z*a+s,e[0]=(l=i[0])*v+(d=i[4])*(b=P*C*a+z*o)+(_=i[8])*(w=z*C*a-P*o),e[1]=c*v+p*b+g*w,e[2]=h*v+f*b+y*w,e[3]=u*v+m*b+x*w,e[4]=l*T+d*S+_*M,e[5]=c*T+p*S+g*M,e[6]=h*T+f*S+y*M,e[7]=u*T+m*S+x*M,e[8]=l*E+d*A+_*I,e[9]=c*E+p*A+g*I,e[10]=h*E+f*A+y*I,e[11]=u*E+m*A+x*I,i!==e&&(e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15]),e)},_.rotateX=function(e,t,i){var r=Math.sin(i),n=Math.cos(i),o=t[4],s=t[5],a=t[6],l=t[7],c=t[8],h=t[9],u=t[10],d=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=o*n+c*r,e[5]=s*n+h*r,e[6]=a*n+u*r,e[7]=l*n+d*r,e[8]=c*n-o*r,e[9]=h*n-s*r,e[10]=u*n-a*r,e[11]=d*n-l*r,e},_.rotateY=function(e,t,i){var r=Math.sin(i),n=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[8],h=t[9],u=t[10],d=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*n-c*r,e[1]=s*n-h*r,e[2]=a*n-u*r,e[3]=l*n-d*r,e[8]=o*r+c*n,e[9]=s*r+h*n,e[10]=a*r+u*n,e[11]=l*r+d*n,e},_.rotateZ=function(e,t,i){var r=Math.sin(i),n=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[4],h=t[5],u=t[6],d=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*n+c*r,e[1]=s*n+h*r,e[2]=a*n+u*r,e[3]=l*n+d*r,e[4]=c*n-o*r,e[5]=h*n-s*r,e[6]=u*n-a*r,e[7]=d*n-l*r,e},_.fromTranslation=function(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e},_.fromScaling=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},_.fromRotation=function(e,i,r){var n,o,s,a=r[0],l=r[1],c=r[2],h=Math.hypot(a,l,c);return h<t.EPSILON?null:(a*=h=1/h,l*=h,c*=h,n=Math.sin(i),o=Math.cos(i),e[0]=a*a*(s=1-o)+o,e[1]=l*a*s+c*n,e[2]=c*a*s-l*n,e[3]=0,e[4]=a*l*s-c*n,e[5]=l*l*s+o,e[6]=c*l*s+a*n,e[7]=0,e[8]=a*c*s+l*n,e[9]=l*c*s-a*n,e[10]=c*c*s+o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)},_.fromXRotation=function(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=r,e[6]=i,e[7]=0,e[8]=0,e[9]=-i,e[10]=r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},_.fromYRotation=function(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=0,e[2]=-i,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=i,e[9]=0,e[10]=r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},_.fromZRotation=function(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=i,e[2]=0,e[3]=0,e[4]=-i,e[5]=r,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},_.fromRotationTranslation=s,_.fromQuat2=function(e,i){var r=new t.ARRAY_TYPE(3),n=-i[0],o=-i[1],a=-i[2],l=i[3],c=i[4],h=i[5],u=i[6],d=i[7],p=n*n+o*o+a*a+l*l;return p>0?(r[0]=2*(c*l+d*n+h*a-u*o)/p,r[1]=2*(h*l+d*o+u*n-c*a)/p,r[2]=2*(u*l+d*a+c*o-h*n)/p):(r[0]=2*(c*l+d*n+h*a-u*o),r[1]=2*(h*l+d*o+u*n-c*a),r[2]=2*(u*l+d*a+c*o-h*n)),s(e,i,r),e},_.getTranslation=function(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e},_.getScaling=a,_.getRotation=function(e,i){var r=new t.ARRAY_TYPE(3);a(r,i);var n=1/r[0],o=1/r[1],s=1/r[2],l=i[0]*n,c=i[1]*o,h=i[2]*s,u=i[4]*n,d=i[5]*o,p=i[6]*s,f=i[8]*n,m=i[9]*o,_=i[10]*s,g=l+d+_,y=0;return g>0?(y=2*Math.sqrt(g+1),e[3]=.25*y,e[0]=(p-m)/y,e[1]=(f-h)/y,e[2]=(c-u)/y):l>d&&l>_?(y=2*Math.sqrt(1+l-d-_),e[3]=(p-m)/y,e[0]=.25*y,e[1]=(c+u)/y,e[2]=(f+h)/y):d>_?(y=2*Math.sqrt(1+d-l-_),e[3]=(f-h)/y,e[0]=(c+u)/y,e[1]=.25*y,e[2]=(p+m)/y):(y=2*Math.sqrt(1+_-l-d),e[3]=(c-u)/y,e[0]=(f+h)/y,e[1]=(p+m)/y,e[2]=.25*y),e},_.fromRotationTranslationScale=function(e,t,i,r){var n=t[0],o=t[1],s=t[2],a=t[3],l=n+n,c=o+o,h=s+s,u=n*l,d=n*c,p=n*h,f=o*c,m=o*h,_=s*h,g=a*l,y=a*c,x=a*h,v=r[0],b=r[1],w=r[2];return e[0]=(1-(f+_))*v,e[1]=(d+x)*v,e[2]=(p-y)*v,e[3]=0,e[4]=(d-x)*b,e[5]=(1-(u+_))*b,e[6]=(m+g)*b,e[7]=0,e[8]=(p+y)*w,e[9]=(m-g)*w,e[10]=(1-(u+f))*w,e[11]=0,e[12]=i[0],e[13]=i[1],e[14]=i[2],e[15]=1,e},_.fromRotationTranslationScaleOrigin=function(e,t,i,r,n){var o=t[0],s=t[1],a=t[2],l=t[3],c=o+o,h=s+s,u=a+a,d=o*c,p=o*h,f=o*u,m=s*h,_=s*u,g=a*u,y=l*c,x=l*h,v=l*u,b=r[0],w=r[1],T=r[2],S=n[0],M=n[1],E=n[2],A=(1-(m+g))*b,I=(p+v)*b,C=(f-x)*b,P=(p-v)*w,z=(1-(d+g))*w,D=(_+y)*w,R=(f+x)*T,L=(_-y)*T,O=(1-(d+m))*T;return e[0]=A,e[1]=I,e[2]=C,e[3]=0,e[4]=P,e[5]=z,e[6]=D,e[7]=0,e[8]=R,e[9]=L,e[10]=O,e[11]=0,e[12]=i[0]+S-(A*S+P*M+R*E),e[13]=i[1]+M-(I*S+z*M+L*E),e[14]=i[2]+E-(C*S+D*M+O*E),e[15]=1,e},_.fromQuat=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=i+i,a=r+r,l=n+n,c=i*s,h=r*s,u=r*a,d=n*s,p=n*a,f=n*l,m=o*s,_=o*a,g=o*l;return e[0]=1-u-f,e[1]=h+g,e[2]=d-_,e[3]=0,e[4]=h-g,e[5]=1-c-f,e[6]=p+m,e[7]=0,e[8]=d+_,e[9]=p-m,e[10]=1-c-u,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},_.frustum=function(e,t,i,r,n,o,s){var a=1/(i-t),l=1/(n-r),c=1/(o-s);return e[0]=2*o*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*o*l,e[6]=0,e[7]=0,e[8]=(i+t)*a,e[9]=(n+r)*l,e[10]=(s+o)*c,e[11]=-1,e[12]=0,e[13]=0,e[14]=s*o*2*c,e[15]=0,e},_.perspectiveNO=l,_.perspectiveZO=function(e,t,i,r,n){var o,s=1/Math.tan(t/2);return e[0]=s/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=n&&n!==1/0?(e[10]=n*(o=1/(r-n)),e[14]=n*r*o):(e[10]=-1,e[14]=-r),e},_.perspectiveFromFieldOfView=function(e,t,i,r){var n=Math.tan(t.upDegrees*Math.PI/180),o=Math.tan(t.downDegrees*Math.PI/180),s=Math.tan(t.leftDegrees*Math.PI/180),a=Math.tan(t.rightDegrees*Math.PI/180),l=2/(s+a),c=2/(n+o);return e[0]=l,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=c,e[6]=0,e[7]=0,e[8]=-(s-a)*l*.5,e[9]=(n-o)*c*.5,e[10]=r/(i-r),e[11]=-1,e[12]=0,e[13]=0,e[14]=r*i/(i-r),e[15]=0,e},_.orthoNO=c,_.orthoZO=function(e,t,i,r,n,o,s){var a=1/(t-i),l=1/(r-n),c=1/(o-s);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=c,e[11]=0,e[12]=(t+i)*a,e[13]=(n+r)*l,e[14]=o*c,e[15]=1,e},_.lookAt=function(e,i,n,o){var s,a,l,c,h,u,d,p,f,m,_=i[0],g=i[1],y=i[2],x=o[0],v=o[1],b=o[2],w=n[0],T=n[1],S=n[2];return Math.abs(_-w)<t.EPSILON&&Math.abs(g-T)<t.EPSILON&&Math.abs(y-S)<t.EPSILON?r(e):(d=_-w,p=g-T,f=y-S,s=v*(f*=m=1/Math.hypot(d,p,f))-b*(p*=m),a=b*(d*=m)-x*f,l=x*p-v*d,(m=Math.hypot(s,a,l))?(s*=m=1/m,a*=m,l*=m):(s=0,a=0,l=0),c=p*l-f*a,h=f*s-d*l,u=d*a-p*s,(m=Math.hypot(c,h,u))?(c*=m=1/m,h*=m,u*=m):(c=0,h=0,u=0),e[0]=s,e[1]=c,e[2]=d,e[3]=0,e[4]=a,e[5]=h,e[6]=p,e[7]=0,e[8]=l,e[9]=u,e[10]=f,e[11]=0,e[12]=-(s*_+a*g+l*y),e[13]=-(c*_+h*g+u*y),e[14]=-(d*_+p*g+f*y),e[15]=1,e)},_.targetTo=function(e,t,i,r){var n=t[0],o=t[1],s=t[2],a=r[0],l=r[1],c=r[2],h=n-i[0],u=o-i[1],d=s-i[2],p=h*h+u*u+d*d;p>0&&(h*=p=1/Math.sqrt(p),u*=p,d*=p);var f=l*d-c*u,m=c*h-a*d,_=a*u-l*h;return(p=f*f+m*m+_*_)>0&&(f*=p=1/Math.sqrt(p),m*=p,_*=p),e[0]=f,e[1]=m,e[2]=_,e[3]=0,e[4]=u*_-d*m,e[5]=d*f-h*_,e[6]=h*m-u*f,e[7]=0,e[8]=h,e[9]=u,e[10]=d,e[11]=0,e[12]=n,e[13]=o,e[14]=s,e[15]=1,e},_.str=function(e){return"mat4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+", "+e[9]+", "+e[10]+", "+e[11]+", "+e[12]+", "+e[13]+", "+e[14]+", "+e[15]+")"},_.frob=function(e){return Math.hypot(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])},_.add=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e[3]=t[3]+i[3],e[4]=t[4]+i[4],e[5]=t[5]+i[5],e[6]=t[6]+i[6],e[7]=t[7]+i[7],e[8]=t[8]+i[8],e[9]=t[9]+i[9],e[10]=t[10]+i[10],e[11]=t[11]+i[11],e[12]=t[12]+i[12],e[13]=t[13]+i[13],e[14]=t[14]+i[14],e[15]=t[15]+i[15],e},_.subtract=h,_.multiplyScalar=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*i,e[9]=t[9]*i,e[10]=t[10]*i,e[11]=t[11]*i,e[12]=t[12]*i,e[13]=t[13]*i,e[14]=t[14]*i,e[15]=t[15]*i,e},_.multiplyScalarAndAdd=function(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e[3]=t[3]+i[3]*r,e[4]=t[4]+i[4]*r,e[5]=t[5]+i[5]*r,e[6]=t[6]+i[6]*r,e[7]=t[7]+i[7]*r,e[8]=t[8]+i[8]*r,e[9]=t[9]+i[9]*r,e[10]=t[10]+i[10]*r,e[11]=t[11]+i[11]*r,e[12]=t[12]+i[12]*r,e[13]=t[13]+i[13]*r,e[14]=t[14]+i[14]*r,e[15]=t[15]+i[15]*r,e},_.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]},_.equals=function(e,i){var r=e[0],n=e[1],o=e[2],s=e[3],a=e[4],l=e[5],c=e[6],h=e[7],u=e[8],d=e[9],p=e[10],f=e[11],m=e[12],_=e[13],g=e[14],y=e[15],x=i[0],v=i[1],b=i[2],w=i[3],T=i[4],S=i[5],M=i[6],E=i[7],A=i[8],I=i[9],C=i[10],P=i[11],z=i[12],D=i[13],R=i[14],L=i[15];return Math.abs(r-x)<=t.EPSILON*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(n-v)<=t.EPSILON*Math.max(1,Math.abs(n),Math.abs(v))&&Math.abs(o-b)<=t.EPSILON*Math.max(1,Math.abs(o),Math.abs(b))&&Math.abs(s-w)<=t.EPSILON*Math.max(1,Math.abs(s),Math.abs(w))&&Math.abs(a-T)<=t.EPSILON*Math.max(1,Math.abs(a),Math.abs(T))&&Math.abs(l-S)<=t.EPSILON*Math.max(1,Math.abs(l),Math.abs(S))&&Math.abs(c-M)<=t.EPSILON*Math.max(1,Math.abs(c),Math.abs(M))&&Math.abs(h-E)<=t.EPSILON*Math.max(1,Math.abs(h),Math.abs(E))&&Math.abs(u-A)<=t.EPSILON*Math.max(1,Math.abs(u),Math.abs(A))&&Math.abs(d-I)<=t.EPSILON*Math.max(1,Math.abs(d),Math.abs(I))&&Math.abs(p-C)<=t.EPSILON*Math.max(1,Math.abs(p),Math.abs(C))&&Math.abs(f-P)<=t.EPSILON*Math.max(1,Math.abs(f),Math.abs(P))&&Math.abs(m-z)<=t.EPSILON*Math.max(1,Math.abs(m),Math.abs(z))&&Math.abs(_-D)<=t.EPSILON*Math.max(1,Math.abs(_),Math.abs(D))&&Math.abs(g-R)<=t.EPSILON*Math.max(1,Math.abs(g),Math.abs(R))&&Math.abs(y-L)<=t.EPSILON*Math.max(1,Math.abs(y),Math.abs(L))},_.sub=_.mul=_.ortho=_.perspective=void 0;var t=function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var r=i(void 0);if(r&&r.has(t))return r.get(t);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if("default"!==s&&Object.prototype.hasOwnProperty.call(t,s)){var a=o?Object.getOwnPropertyDescriptor(t,s):null;a&&(a.get||a.set)?Object.defineProperty(n,s,a):n[s]=t[s]}return n.default=t,r&&r.set(t,n),n}(o());function i(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(i=function(e){return e?r:t})(e)}function r(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function n(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=t[8],d=t[9],p=t[10],f=t[11],m=t[12],_=t[13],g=t[14],y=t[15],x=i[0],v=i[1],b=i[2],w=i[3];return e[0]=x*r+v*a+b*u+w*m,e[1]=x*n+v*l+b*d+w*_,e[2]=x*o+v*c+b*p+w*g,e[3]=x*s+v*h+b*f+w*y,e[4]=(x=i[4])*r+(v=i[5])*a+(b=i[6])*u+(w=i[7])*m,e[5]=x*n+v*l+b*d+w*_,e[6]=x*o+v*c+b*p+w*g,e[7]=x*s+v*h+b*f+w*y,e[8]=(x=i[8])*r+(v=i[9])*a+(b=i[10])*u+(w=i[11])*m,e[9]=x*n+v*l+b*d+w*_,e[10]=x*o+v*c+b*p+w*g,e[11]=x*s+v*h+b*f+w*y,e[12]=(x=i[12])*r+(v=i[13])*a+(b=i[14])*u+(w=i[15])*m,e[13]=x*n+v*l+b*d+w*_,e[14]=x*o+v*c+b*p+w*g,e[15]=x*s+v*h+b*f+w*y,e}function s(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=r+r,l=n+n,c=o+o,h=r*a,u=r*l,d=r*c,p=n*l,f=n*c,m=o*c,_=s*a,g=s*l,y=s*c;return e[0]=1-(p+m),e[1]=u+y,e[2]=d-g,e[3]=0,e[4]=u-y,e[5]=1-(h+m),e[6]=f+_,e[7]=0,e[8]=d+g,e[9]=f-_,e[10]=1-(h+p),e[11]=0,e[12]=i[0],e[13]=i[1],e[14]=i[2],e[15]=1,e}function a(e,t){var i=t[4],r=t[5],n=t[6],o=t[8],s=t[9],a=t[10];return e[0]=Math.hypot(t[0],t[1],t[2]),e[1]=Math.hypot(i,r,n),e[2]=Math.hypot(o,s,a),e}function l(e,t,i,r,n){var o,s=1/Math.tan(t/2);return e[0]=s/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=n&&n!==1/0?(e[10]=(n+r)*(o=1/(r-n)),e[14]=2*n*r*o):(e[10]=-1,e[14]=-2*r),e}function c(e,t,i,r,n,o,s){var a=1/(t-i),l=1/(r-n),c=1/(o-s);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*c,e[11]=0,e[12]=(t+i)*a,e[13]=(n+r)*l,e[14]=(s+o)*c,e[15]=1,e}function h(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e[3]=t[3]-i[3],e[4]=t[4]-i[4],e[5]=t[5]-i[5],e[6]=t[6]-i[6],e[7]=t[7]-i[7],e[8]=t[8]-i[8],e[9]=t[9]-i[9],e[10]=t[10]-i[10],e[11]=t[11]-i[11],e[12]=t[12]-i[12],e[13]=t[13]-i[13],e[14]=t[14]-i[14],e[15]=t[15]-i[15],e}return _.perspective=l,_.ortho=c,_.mul=n,_.sub=h,_}var y,x={},v={};function b(){if(y)return v;function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}y=1,Object.defineProperty(v,"__esModule",{value:!0}),v.create=r,v.clone=function(e){var i=new t.ARRAY_TYPE(3);return i[0]=e[0],i[1]=e[1],i[2]=e[2],i},v.length=n,v.fromValues=function(e,i,r){var n=new t.ARRAY_TYPE(3);return n[0]=e,n[1]=i,n[2]=r,n},v.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},v.set=function(e,t,i,r){return e[0]=t,e[1]=i,e[2]=r,e},v.add=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e},v.subtract=s,v.multiply=a,v.divide=l,v.ceil=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e},v.floor=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e},v.min=function(e,t,i){return e[0]=Math.min(t[0],i[0]),e[1]=Math.min(t[1],i[1]),e[2]=Math.min(t[2],i[2]),e},v.max=function(e,t,i){return e[0]=Math.max(t[0],i[0]),e[1]=Math.max(t[1],i[1]),e[2]=Math.max(t[2],i[2]),e},v.round=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e[2]=Math.round(t[2]),e},v.scale=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e},v.scaleAndAdd=function(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e},v.distance=c,v.squaredDistance=h,v.squaredLength=u,v.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e},v.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e},v.normalize=function(e,t){var i=t[0],r=t[1],n=t[2],o=i*i+r*r+n*n;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e},v.dot=d,v.cross=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=i[0],a=i[1],l=i[2];return e[0]=n*l-o*a,e[1]=o*s-r*l,e[2]=r*a-n*s,e},v.lerp=function(e,t,i,r){var n=t[0],o=t[1],s=t[2];return e[0]=n+r*(i[0]-n),e[1]=o+r*(i[1]-o),e[2]=s+r*(i[2]-s),e},v.hermite=function(e,t,i,r,n,o){var s=o*o,a=s*(2*o-3)+1,l=s*(o-2)+o,c=s*(o-1),h=s*(3-2*o);return e[0]=t[0]*a+i[0]*l+r[0]*c+n[0]*h,e[1]=t[1]*a+i[1]*l+r[1]*c+n[1]*h,e[2]=t[2]*a+i[2]*l+r[2]*c+n[2]*h,e},v.bezier=function(e,t,i,r,n,o){var s=1-o,a=s*s,l=o*o,c=a*s,h=3*o*a,u=3*l*s,d=l*o;return e[0]=t[0]*c+i[0]*h+r[0]*u+n[0]*d,e[1]=t[1]*c+i[1]*h+r[1]*u+n[1]*d,e[2]=t[2]*c+i[2]*h+r[2]*u+n[2]*d,e},v.random=function(e,i){i=i||1;var r=2*t.RANDOM()*Math.PI,n=2*t.RANDOM()-1,o=Math.sqrt(1-n*n)*i;return e[0]=Math.cos(r)*o,e[1]=Math.sin(r)*o,e[2]=n*i,e},v.transformMat4=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=i[3]*r+i[7]*n+i[11]*o+i[15];return e[0]=(i[0]*r+i[4]*n+i[8]*o+i[12])/(s=s||1),e[1]=(i[1]*r+i[5]*n+i[9]*o+i[13])/s,e[2]=(i[2]*r+i[6]*n+i[10]*o+i[14])/s,e},v.transformMat3=function(e,t,i){var r=t[0],n=t[1],o=t[2];return e[0]=r*i[0]+n*i[3]+o*i[6],e[1]=r*i[1]+n*i[4]+o*i[7],e[2]=r*i[2]+n*i[5]+o*i[8],e},v.transformQuat=function(e,t,i){var r=i[0],n=i[1],o=i[2],s=t[0],a=t[1],l=t[2],c=n*l-o*a,h=o*s-r*l,u=r*a-n*s,d=n*u-o*h,p=o*c-r*u,f=r*h-n*c,m=2*i[3];return h*=m,u*=m,p*=2,f*=2,e[0]=s+(c*=m)+(d*=2),e[1]=a+h+p,e[2]=l+u+f,e},v.rotateX=function(e,t,i,r){var n=[],o=[];return n[0]=t[0]-i[0],n[1]=t[1]-i[1],n[2]=t[2]-i[2],o[0]=n[0],o[1]=n[1]*Math.cos(r)-n[2]*Math.sin(r),o[2]=n[1]*Math.sin(r)+n[2]*Math.cos(r),e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},v.rotateY=function(e,t,i,r){var n=[],o=[];return n[0]=t[0]-i[0],n[1]=t[1]-i[1],n[2]=t[2]-i[2],o[0]=n[2]*Math.sin(r)+n[0]*Math.cos(r),o[1]=n[1],o[2]=n[2]*Math.cos(r)-n[0]*Math.sin(r),e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},v.rotateZ=function(e,t,i,r){var n=[],o=[];return n[0]=t[0]-i[0],n[1]=t[1]-i[1],n[2]=t[2]-i[2],o[0]=n[0]*Math.cos(r)-n[1]*Math.sin(r),o[1]=n[0]*Math.sin(r)+n[1]*Math.cos(r),o[2]=n[2],e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},v.angle=function(e,t){var i=e[0],r=e[1],n=e[2],o=t[0],s=t[1],a=t[2],l=Math.sqrt(i*i+r*r+n*n)*Math.sqrt(o*o+s*s+a*a),c=l&&d(e,t)/l;return Math.acos(Math.min(Math.max(c,-1),1))},v.zero=function(e){return e[0]=0,e[1]=0,e[2]=0,e},v.str=function(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"},v.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]},v.equals=function(e,i){var r=e[0],n=e[1],o=e[2],s=i[0],a=i[1],l=i[2];return Math.abs(r-s)<=t.EPSILON*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(n-a)<=t.EPSILON*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(o-l)<=t.EPSILON*Math.max(1,Math.abs(o),Math.abs(l))},v.forEach=v.sqrLen=v.len=v.sqrDist=v.dist=v.div=v.mul=v.sub=void 0;var t=function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var r=i(void 0);if(r&&r.has(t))return r.get(t);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if("default"!==s&&Object.prototype.hasOwnProperty.call(t,s)){var a=o?Object.getOwnPropertyDescriptor(t,s):null;a&&(a.get||a.set)?Object.defineProperty(n,s,a):n[s]=t[s]}return n.default=t,r&&r.set(t,n),n}(o());function i(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(i=function(e){return e?r:t})(e)}function r(){var e=new t.ARRAY_TYPE(3);return t.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function n(e){return Math.hypot(e[0],e[1],e[2])}function s(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e}function a(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e}function l(e,t,i){return e[0]=t[0]/i[0],e[1]=t[1]/i[1],e[2]=t[2]/i[2],e}function c(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2])}function h(e,t){var i=t[0]-e[0],r=t[1]-e[1],n=t[2]-e[2];return i*i+r*r+n*n}function u(e){var t=e[0],i=e[1],r=e[2];return t*t+i*i+r*r}function d(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}v.sub=s,v.mul=a,v.div=l,v.dist=c,v.sqrDist=h,v.len=n,v.sqrLen=u;var p,f=(p=r(),function(e,t,i,r,n,o){var s,a;for(t||(t=3),i||(i=0),a=r?Math.min(r*t+i,e.length):e.length,s=i;s<a;s+=t)p[0]=e[s],p[1]=e[s+1],p[2]=e[s+2],n(p,p,o),e[s]=p[0],e[s+1]=p[1],e[s+2]=p[2];return e});return v.forEach=f,v}var w,T,S={};function M(){if(w)return S;function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}w=1,Object.defineProperty(S,"__esModule",{value:!0}),S.create=r,S.clone=function(e){var i=new t.ARRAY_TYPE(4);return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i},S.fromValues=function(e,i,r,n){var o=new t.ARRAY_TYPE(4);return o[0]=e,o[1]=i,o[2]=r,o[3]=n,o},S.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},S.set=function(e,t,i,r,n){return e[0]=t,e[1]=i,e[2]=r,e[3]=n,e},S.add=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e[3]=t[3]+i[3],e},S.subtract=n,S.multiply=s,S.divide=a,S.ceil=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e[3]=Math.ceil(t[3]),e},S.floor=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e[3]=Math.floor(t[3]),e},S.min=function(e,t,i){return e[0]=Math.min(t[0],i[0]),e[1]=Math.min(t[1],i[1]),e[2]=Math.min(t[2],i[2]),e[3]=Math.min(t[3],i[3]),e},S.max=function(e,t,i){return e[0]=Math.max(t[0],i[0]),e[1]=Math.max(t[1],i[1]),e[2]=Math.max(t[2],i[2]),e[3]=Math.max(t[3],i[3]),e},S.round=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e[2]=Math.round(t[2]),e[3]=Math.round(t[3]),e},S.scale=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e},S.scaleAndAdd=function(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e[3]=t[3]+i[3]*r,e},S.distance=l,S.squaredDistance=c,S.length=h,S.squaredLength=u,S.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e},S.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e[3]=1/t[3],e},S.normalize=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=i*i+r*r+n*n+o*o;return s>0&&(s=1/Math.sqrt(s)),e[0]=i*s,e[1]=r*s,e[2]=n*s,e[3]=o*s,e},S.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},S.cross=function(e,t,i,r){var n=i[0]*r[1]-i[1]*r[0],o=i[0]*r[2]-i[2]*r[0],s=i[0]*r[3]-i[3]*r[0],a=i[1]*r[2]-i[2]*r[1],l=i[1]*r[3]-i[3]*r[1],c=i[2]*r[3]-i[3]*r[2],h=t[0],u=t[1],d=t[2],p=t[3];return e[0]=u*c-d*l+p*a,e[1]=-h*c+d*s-p*o,e[2]=h*l-u*s+p*n,e[3]=-h*a+u*o-d*n,e},S.lerp=function(e,t,i,r){var n=t[0],o=t[1],s=t[2],a=t[3];return e[0]=n+r*(i[0]-n),e[1]=o+r*(i[1]-o),e[2]=s+r*(i[2]-s),e[3]=a+r*(i[3]-a),e},S.random=function(e,i){var r,n,o,s,a,l;i=i||1;do{a=(r=2*t.RANDOM()-1)*r+(n=2*t.RANDOM()-1)*n}while(a>=1);do{l=(o=2*t.RANDOM()-1)*o+(s=2*t.RANDOM()-1)*s}while(l>=1);var c=Math.sqrt((1-a)/l);return e[0]=i*r,e[1]=i*n,e[2]=i*o*c,e[3]=i*s*c,e},S.transformMat4=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3];return e[0]=i[0]*r+i[4]*n+i[8]*o+i[12]*s,e[1]=i[1]*r+i[5]*n+i[9]*o+i[13]*s,e[2]=i[2]*r+i[6]*n+i[10]*o+i[14]*s,e[3]=i[3]*r+i[7]*n+i[11]*o+i[15]*s,e},S.transformQuat=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=i[0],a=i[1],l=i[2],c=i[3],h=c*r+a*o-l*n,u=c*n+l*r-s*o,d=c*o+s*n-a*r,p=-s*r-a*n-l*o;return e[0]=h*c+p*-s+u*-l-d*-a,e[1]=u*c+p*-a+d*-s-h*-l,e[2]=d*c+p*-l+h*-a-u*-s,e[3]=t[3],e},S.zero=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e},S.str=function(e){return"vec4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},S.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},S.equals=function(e,i){var r=e[0],n=e[1],o=e[2],s=e[3],a=i[0],l=i[1],c=i[2],h=i[3];return Math.abs(r-a)<=t.EPSILON*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(n-l)<=t.EPSILON*Math.max(1,Math.abs(n),Math.abs(l))&&Math.abs(o-c)<=t.EPSILON*Math.max(1,Math.abs(o),Math.abs(c))&&Math.abs(s-h)<=t.EPSILON*Math.max(1,Math.abs(s),Math.abs(h))},S.forEach=S.sqrLen=S.len=S.sqrDist=S.dist=S.div=S.mul=S.sub=void 0;var t=function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var r=i(void 0);if(r&&r.has(t))return r.get(t);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if("default"!==s&&Object.prototype.hasOwnProperty.call(t,s)){var a=o?Object.getOwnPropertyDescriptor(t,s):null;a&&(a.get||a.set)?Object.defineProperty(n,s,a):n[s]=t[s]}return n.default=t,r&&r.set(t,n),n}(o());function i(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(i=function(e){return e?r:t})(e)}function r(){var e=new t.ARRAY_TYPE(4);return t.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function n(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e[3]=t[3]-i[3],e}function s(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e[3]=t[3]*i[3],e}function a(e,t,i){return e[0]=t[0]/i[0],e[1]=t[1]/i[1],e[2]=t[2]/i[2],e[3]=t[3]/i[3],e}function l(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2],t[3]-e[3])}function c(e,t){var i=t[0]-e[0],r=t[1]-e[1],n=t[2]-e[2],o=t[3]-e[3];return i*i+r*r+n*n+o*o}function h(e){return Math.hypot(e[0],e[1],e[2],e[3])}function u(e){var t=e[0],i=e[1],r=e[2],n=e[3];return t*t+i*i+r*r+n*n}S.sub=n,S.mul=s,S.div=a,S.dist=l,S.sqrDist=c,S.len=h,S.sqrLen=u;var d,p=(d=r(),function(e,t,i,r,n,o){var s,a;for(t||(t=4),i||(i=0),a=r?Math.min(r*t+i,e.length):e.length,s=i;s<a;s+=t)d[0]=e[s],d[1]=e[s+1],d[2]=e[s+2],d[3]=e[s+3],n(d,d,o),e[s]=d[0],e[s+1]=d[1],e[s+2]=d[2],e[s+3]=d[3];return e});return S.forEach=p,S}function E(){if(T)return x;function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}T=1,Object.defineProperty(x,"__esModule",{value:!0}),x.create=l,x.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},x.setAxisAngle=c,x.getAxisAngle=function(e,i){var r=2*Math.acos(i[3]),n=Math.sin(r/2);return n>t.EPSILON?(e[0]=i[0]/n,e[1]=i[1]/n,e[2]=i[2]/n):(e[0]=1,e[1]=0,e[2]=0),r},x.getAngle=function(e,t){var i=g(e,t);return Math.acos(2*i*i-1)},x.multiply=h,x.rotateX=function(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=r*l+s*a,e[1]=n*l+o*a,e[2]=o*l-n*a,e[3]=s*l-r*a,e},x.rotateY=function(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=r*l-o*a,e[1]=n*l+s*a,e[2]=o*l+r*a,e[3]=s*l-n*a,e},x.rotateZ=function(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=r*l+n*a,e[1]=n*l-r*a,e[2]=o*l+s*a,e[3]=s*l-o*a,e},x.calculateW=function(e,t){var i=t[0],r=t[1],n=t[2];return e[0]=i,e[1]=r,e[2]=n,e[3]=Math.sqrt(Math.abs(1-i*i-r*r-n*n)),e},x.exp=u,x.ln=d,x.pow=function(e,t,i){return d(e,t),_(e,e,i),u(e,e),e},x.slerp=p,x.random=function(e){var i=t.RANDOM(),r=t.RANDOM(),n=t.RANDOM(),o=Math.sqrt(1-i),s=Math.sqrt(i);return e[0]=o*Math.sin(2*Math.PI*r),e[1]=o*Math.cos(2*Math.PI*r),e[2]=s*Math.sin(2*Math.PI*n),e[3]=s*Math.cos(2*Math.PI*n),e},x.invert=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=i*i+r*r+n*n+o*o,a=s?1/s:0;return e[0]=-i*a,e[1]=-r*a,e[2]=-n*a,e[3]=o*a,e},x.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},x.fromMat3=m,x.fromEuler=function(e,t,i,r){var n=.5*Math.PI/180;t*=n,i*=n,r*=n;var o=Math.sin(t),s=Math.cos(t),a=Math.sin(i),l=Math.cos(i),c=Math.sin(r),h=Math.cos(r);return e[0]=o*l*h-s*a*c,e[1]=s*a*h+o*l*c,e[2]=s*l*c-o*a*h,e[3]=s*l*h+o*a*c,e},x.str=function(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},x.setAxes=x.sqlerp=x.rotationTo=x.equals=x.exactEquals=x.normalize=x.sqrLen=x.squaredLength=x.len=x.length=x.lerp=x.dot=x.scale=x.mul=x.add=x.set=x.copy=x.fromValues=x.clone=void 0;var t=a(o()),i=a(f()),r=a(b()),n=a(M());function s(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(s=function(e){return e?i:t})(e)}function a(t,i){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var r=s(i);if(r&&r.has(t))return r.get(t);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if("default"!==a&&Object.prototype.hasOwnProperty.call(t,a)){var l=o?Object.getOwnPropertyDescriptor(t,a):null;l&&(l.get||l.set)?Object.defineProperty(n,a,l):n[a]=t[a]}return n.default=t,r&&r.set(t,n),n}function l(){var e=new t.ARRAY_TYPE(4);return t.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function c(e,t,i){i*=.5;var r=Math.sin(i);return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=Math.cos(i),e}function h(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=i[0],l=i[1],c=i[2],h=i[3];return e[0]=r*h+s*a+n*c-o*l,e[1]=n*h+s*l+o*a-r*c,e[2]=o*h+s*c+r*l-n*a,e[3]=s*h-r*a-n*l-o*c,e}function u(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=Math.sqrt(i*i+r*r+n*n),a=Math.exp(o),l=s>0?a*Math.sin(s)/s:0;return e[0]=i*l,e[1]=r*l,e[2]=n*l,e[3]=a*Math.cos(s),e}function d(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=Math.sqrt(i*i+r*r+n*n),a=s>0?Math.atan2(s,o)/s:0;return e[0]=i*a,e[1]=r*a,e[2]=n*a,e[3]=.5*Math.log(i*i+r*r+n*n+o*o),e}function p(e,i,r,n){var o,s,a,l,c,h=i[0],u=i[1],d=i[2],p=i[3],f=r[0],m=r[1],_=r[2],g=r[3];return(s=h*f+u*m+d*_+p*g)<0&&(s=-s,f=-f,m=-m,_=-_,g=-g),1-s>t.EPSILON?(o=Math.acos(s),a=Math.sin(o),l=Math.sin((1-n)*o)/a,c=Math.sin(n*o)/a):(l=1-n,c=n),e[0]=l*h+c*f,e[1]=l*u+c*m,e[2]=l*d+c*_,e[3]=l*p+c*g,e}function m(e,t){var i,r=t[0]+t[4]+t[8];if(r>0)i=Math.sqrt(r+1),e[3]=.5*i,e[0]=(t[5]-t[7])*(i=.5/i),e[1]=(t[6]-t[2])*i,e[2]=(t[1]-t[3])*i;else{var n=0;t[4]>t[0]&&(n=1),t[8]>t[3*n+n]&&(n=2);var o=(n+1)%3,s=(n+2)%3;i=Math.sqrt(t[3*n+n]-t[3*o+o]-t[3*s+s]+1),e[n]=.5*i,e[3]=(t[3*o+s]-t[3*s+o])*(i=.5/i),e[o]=(t[3*o+n]+t[3*n+o])*i,e[s]=(t[3*s+n]+t[3*n+s])*i}return e}x.clone=n.clone,x.fromValues=n.fromValues,x.copy=n.copy,x.set=n.set,x.add=n.add,x.mul=h;var _=n.scale;x.scale=_;var g=n.dot;x.dot=g,x.lerp=n.lerp;var y=n.length;x.length=y,x.len=y;var v=n.squaredLength;x.squaredLength=v,x.sqrLen=v;var w=n.normalize;x.normalize=w,x.exactEquals=n.exactEquals,x.equals=n.equals;var S,E,A,I=(S=r.create(),E=r.fromValues(1,0,0),A=r.fromValues(0,1,0),function(e,t,i){var n=r.dot(t,i);return n<-.999999?(r.cross(S,E,t),r.len(S)<1e-6&&r.cross(S,A,t),r.normalize(S,S),c(e,S,Math.PI),e):n>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(r.cross(S,t,i),e[0]=S[0],e[1]=S[1],e[2]=S[2],e[3]=1+n,w(e,e))});x.rotationTo=I;var C,P,z=(C=l(),P=l(),function(e,t,i,r,n,o){return p(C,t,n,o),p(P,i,r,o),p(e,C,P,2*o*(1-o)),e});x.sqlerp=z;var D,R=(D=i.create(),function(e,t,i,r){return D[0]=i[0],D[3]=i[1],D[6]=i[2],D[1]=r[0],D[4]=r[1],D[7]=r[2],D[2]=-t[0],D[5]=-t[1],D[8]=-t[2],w(e,m(e,D))});return x.setAxes=R,x}var A,I={};var C,P,z={};function D(){if(C)return z;function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}C=1,Object.defineProperty(z,"__esModule",{value:!0}),z.create=r,z.clone=function(e){var i=new t.ARRAY_TYPE(2);return i[0]=e[0],i[1]=e[1],i},z.fromValues=function(e,i){var r=new t.ARRAY_TYPE(2);return r[0]=e,r[1]=i,r},z.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e},z.set=function(e,t,i){return e[0]=t,e[1]=i,e},z.add=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e},z.subtract=n,z.multiply=s,z.divide=a,z.ceil=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e},z.floor=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e},z.min=function(e,t,i){return e[0]=Math.min(t[0],i[0]),e[1]=Math.min(t[1],i[1]),e},z.max=function(e,t,i){return e[0]=Math.max(t[0],i[0]),e[1]=Math.max(t[1],i[1]),e},z.round=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e},z.scale=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e},z.scaleAndAdd=function(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e},z.distance=l,z.squaredDistance=c,z.length=h,z.squaredLength=u,z.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},z.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e},z.normalize=function(e,t){var i=t[0],r=t[1],n=i*i+r*r;return n>0&&(n=1/Math.sqrt(n)),e[0]=t[0]*n,e[1]=t[1]*n,e},z.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},z.cross=function(e,t,i){var r=t[0]*i[1]-t[1]*i[0];return e[0]=e[1]=0,e[2]=r,e},z.lerp=function(e,t,i,r){var n=t[0],o=t[1];return e[0]=n+r*(i[0]-n),e[1]=o+r*(i[1]-o),e},z.random=function(e,i){i=i||1;var r=2*t.RANDOM()*Math.PI;return e[0]=Math.cos(r)*i,e[1]=Math.sin(r)*i,e},z.transformMat2=function(e,t,i){var r=t[0],n=t[1];return e[0]=i[0]*r+i[2]*n,e[1]=i[1]*r+i[3]*n,e},z.transformMat2d=function(e,t,i){var r=t[0],n=t[1];return e[0]=i[0]*r+i[2]*n+i[4],e[1]=i[1]*r+i[3]*n+i[5],e},z.transformMat3=function(e,t,i){var r=t[0],n=t[1];return e[0]=i[0]*r+i[3]*n+i[6],e[1]=i[1]*r+i[4]*n+i[7],e},z.transformMat4=function(e,t,i){var r=t[0],n=t[1];return e[0]=i[0]*r+i[4]*n+i[12],e[1]=i[1]*r+i[5]*n+i[13],e},z.rotate=function(e,t,i,r){var n=t[0]-i[0],o=t[1]-i[1],s=Math.sin(r),a=Math.cos(r);return e[0]=n*a-o*s+i[0],e[1]=n*s+o*a+i[1],e},z.angle=function(e,t){var i=e[0],r=e[1],n=t[0],o=t[1],s=Math.sqrt(i*i+r*r)*Math.sqrt(n*n+o*o);return Math.acos(Math.min(Math.max(s&&(i*n+r*o)/s,-1),1))},z.zero=function(e){return e[0]=0,e[1]=0,e},z.str=function(e){return"vec2("+e[0]+", "+e[1]+")"},z.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]},z.equals=function(e,i){var r=e[0],n=e[1],o=i[0],s=i[1];return Math.abs(r-o)<=t.EPSILON*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(n-s)<=t.EPSILON*Math.max(1,Math.abs(n),Math.abs(s))},z.forEach=z.sqrLen=z.sqrDist=z.dist=z.div=z.mul=z.sub=z.len=void 0;var t=function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var r=i(void 0);if(r&&r.has(t))return r.get(t);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if("default"!==s&&Object.prototype.hasOwnProperty.call(t,s)){var a=o?Object.getOwnPropertyDescriptor(t,s):null;a&&(a.get||a.set)?Object.defineProperty(n,s,a):n[s]=t[s]}return n.default=t,r&&r.set(t,n),n}(o());function i(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(i=function(e){return e?r:t})(e)}function r(){var e=new t.ARRAY_TYPE(2);return t.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0),e}function n(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e}function s(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e}function a(e,t,i){return e[0]=t[0]/i[0],e[1]=t[1]/i[1],e}function l(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1])}function c(e,t){var i=t[0]-e[0],r=t[1]-e[1];return i*i+r*r}function h(e){return Math.hypot(e[0],e[1])}function u(e){var t=e[0],i=e[1];return t*t+i*i}z.len=h,z.sub=n,z.mul=s,z.div=a,z.dist=l,z.sqrDist=c,z.sqrLen=u;var d,p=(d=r(),function(e,t,i,r,n,o){var s,a;for(t||(t=2),i||(i=0),a=r?Math.min(r*t+i,e.length):e.length,s=i;s<a;s+=t)d[0]=e[s],d[1]=e[s+1],n(d,d,o),e[s]=d[0],e[s+1]=d[1];return e});return z.forEach=p,z}var R,L,O,k,F=function(){if(P)return r;function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}P=1,Object.defineProperty(r,"__esModule",{value:!0}),r.vec4=r.vec3=r.vec2=r.quat2=r.quat=r.mat4=r.mat3=r.mat2d=r.mat2=r.glMatrix=void 0;var t=y(o());r.glMatrix=t;var i=y(l());r.mat2=i;var n=y(u());r.mat2d=n;var s=y(f());r.mat3=s;var a=y(g());r.mat4=a;var c=y(E());r.quat=c;var h=y(function(){if(A)return I;function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}A=1,Object.defineProperty(I,"__esModule",{value:!0}),I.create=function(){var e=new t.ARRAY_TYPE(8);return t.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[4]=0,e[5]=0,e[6]=0,e[7]=0),e[3]=1,e},I.clone=function(e){var i=new t.ARRAY_TYPE(8);return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7],i},I.fromValues=function(e,i,r,n,o,s,a,l){var c=new t.ARRAY_TYPE(8);return c[0]=e,c[1]=i,c[2]=r,c[3]=n,c[4]=o,c[5]=s,c[6]=a,c[7]=l,c},I.fromRotationTranslationValues=function(e,i,r,n,o,s,a){var l=new t.ARRAY_TYPE(8);l[0]=e,l[1]=i,l[2]=r,l[3]=n;var c=.5*o,h=.5*s,u=.5*a;return l[4]=c*n+h*r-u*i,l[5]=h*n+u*e-c*r,l[6]=u*n+c*i-h*e,l[7]=-c*e-h*i-u*r,l},I.fromRotationTranslation=a,I.fromTranslation=function(e,t){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=.5*t[0],e[5]=.5*t[1],e[6]=.5*t[2],e[7]=0,e},I.fromRotation=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=0,e[5]=0,e[6]=0,e[7]=0,e},I.fromMat4=function(e,n){var o=i.create();r.getRotation(o,n);var s=new t.ARRAY_TYPE(3);return r.getTranslation(s,n),a(e,o,s),e},I.copy=l,I.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e[6]=0,e[7]=0,e},I.set=function(e,t,i,r,n,o,s,a,l){return e[0]=t,e[1]=i,e[2]=r,e[3]=n,e[4]=o,e[5]=s,e[6]=a,e[7]=l,e},I.getDual=function(e,t){return e[0]=t[4],e[1]=t[5],e[2]=t[6],e[3]=t[7],e},I.setDual=function(e,t){return e[4]=t[0],e[5]=t[1],e[6]=t[2],e[7]=t[3],e},I.getTranslation=function(e,t){var i=t[4],r=t[5],n=t[6],o=t[7],s=-t[0],a=-t[1],l=-t[2],c=t[3];return e[0]=2*(i*c+o*s+r*l-n*a),e[1]=2*(r*c+o*a+n*s-i*l),e[2]=2*(n*c+o*l+i*a-r*s),e},I.translate=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=.5*i[0],l=.5*i[1],c=.5*i[2],h=t[4],u=t[5],d=t[6],p=t[7];return e[0]=r,e[1]=n,e[2]=o,e[3]=s,e[4]=s*a+n*c-o*l+h,e[5]=s*l+o*a-r*c+u,e[6]=s*c+r*l-n*a+d,e[7]=-r*a-n*l-o*c+p,e},I.rotateX=function(e,t,r){var n=-t[0],o=-t[1],s=-t[2],a=t[3],l=t[4],c=t[5],h=t[6],u=t[7],d=l*a+u*n+c*s-h*o,p=c*a+u*o+h*n-l*s,f=h*a+u*s+l*o-c*n,m=u*a-l*n-c*o-h*s;return i.rotateX(e,t,r),e[4]=d*(a=e[3])+m*(n=e[0])+p*(s=e[2])-f*(o=e[1]),e[5]=p*a+m*o+f*n-d*s,e[6]=f*a+m*s+d*o-p*n,e[7]=m*a-d*n-p*o-f*s,e},I.rotateY=function(e,t,r){var n=-t[0],o=-t[1],s=-t[2],a=t[3],l=t[4],c=t[5],h=t[6],u=t[7],d=l*a+u*n+c*s-h*o,p=c*a+u*o+h*n-l*s,f=h*a+u*s+l*o-c*n,m=u*a-l*n-c*o-h*s;return i.rotateY(e,t,r),e[4]=d*(a=e[3])+m*(n=e[0])+p*(s=e[2])-f*(o=e[1]),e[5]=p*a+m*o+f*n-d*s,e[6]=f*a+m*s+d*o-p*n,e[7]=m*a-d*n-p*o-f*s,e},I.rotateZ=function(e,t,r){var n=-t[0],o=-t[1],s=-t[2],a=t[3],l=t[4],c=t[5],h=t[6],u=t[7],d=l*a+u*n+c*s-h*o,p=c*a+u*o+h*n-l*s,f=h*a+u*s+l*o-c*n,m=u*a-l*n-c*o-h*s;return i.rotateZ(e,t,r),e[4]=d*(a=e[3])+m*(n=e[0])+p*(s=e[2])-f*(o=e[1]),e[5]=p*a+m*o+f*n-d*s,e[6]=f*a+m*s+d*o-p*n,e[7]=m*a-d*n-p*o-f*s,e},I.rotateByQuatAppend=function(e,t,i){var r=i[0],n=i[1],o=i[2],s=i[3],a=t[0],l=t[1],c=t[2],h=t[3];return e[0]=a*s+h*r+l*o-c*n,e[1]=l*s+h*n+c*r-a*o,e[2]=c*s+h*o+a*n-l*r,e[3]=h*s-a*r-l*n-c*o,e[4]=(a=t[4])*s+(h=t[7])*r+(l=t[5])*o-(c=t[6])*n,e[5]=l*s+h*n+c*r-a*o,e[6]=c*s+h*o+a*n-l*r,e[7]=h*s-a*r-l*n-c*o,e},I.rotateByQuatPrepend=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=i[0],l=i[1],c=i[2],h=i[3];return e[0]=r*h+s*a+n*c-o*l,e[1]=n*h+s*l+o*a-r*c,e[2]=o*h+s*c+r*l-n*a,e[3]=s*h-r*a-n*l-o*c,e[4]=r*(h=i[7])+s*(a=i[4])+n*(c=i[6])-o*(l=i[5]),e[5]=n*h+s*l+o*a-r*c,e[6]=o*h+s*c+r*l-n*a,e[7]=s*h-r*a-n*l-o*c,e},I.rotateAroundAxis=function(e,i,r,n){if(Math.abs(n)<t.EPSILON)return l(e,i);var o=Math.hypot(r[0],r[1],r[2]);n*=.5;var s=Math.sin(n),a=s*r[0]/o,c=s*r[1]/o,h=s*r[2]/o,u=Math.cos(n),d=i[0],p=i[1],f=i[2],m=i[3];e[0]=d*u+m*a+p*h-f*c,e[1]=p*u+m*c+f*a-d*h,e[2]=f*u+m*h+d*c-p*a,e[3]=m*u-d*a-p*c-f*h;var _=i[4],g=i[5],y=i[6],x=i[7];return e[4]=_*u+x*a+g*h-y*c,e[5]=g*u+x*c+y*a-_*h,e[6]=y*u+x*h+_*c-g*a,e[7]=x*u-_*a-g*c-y*h,e},I.add=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e[3]=t[3]+i[3],e[4]=t[4]+i[4],e[5]=t[5]+i[5],e[6]=t[6]+i[6],e[7]=t[7]+i[7],e},I.multiply=c,I.scale=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e},I.lerp=function(e,t,i,r){var n=1-r;return h(t,i)<0&&(r=-r),e[0]=t[0]*n+i[0]*r,e[1]=t[1]*n+i[1]*r,e[2]=t[2]*n+i[2]*r,e[3]=t[3]*n+i[3]*r,e[4]=t[4]*n+i[4]*r,e[5]=t[5]*n+i[5]*r,e[6]=t[6]*n+i[6]*r,e[7]=t[7]*n+i[7]*r,e},I.invert=function(e,t){var i=d(t);return e[0]=-t[0]/i,e[1]=-t[1]/i,e[2]=-t[2]/i,e[3]=t[3]/i,e[4]=-t[4]/i,e[5]=-t[5]/i,e[6]=-t[6]/i,e[7]=t[7]/i,e},I.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e[4]=-t[4],e[5]=-t[5],e[6]=-t[6],e[7]=t[7],e},I.normalize=function(e,t){var i=d(t);if(i>0){i=Math.sqrt(i);var r=t[0]/i,n=t[1]/i,o=t[2]/i,s=t[3]/i,a=t[4],l=t[5],c=t[6],h=t[7],u=r*a+n*l+o*c+s*h;e[0]=r,e[1]=n,e[2]=o,e[3]=s,e[4]=(a-r*u)/i,e[5]=(l-n*u)/i,e[6]=(c-o*u)/i,e[7]=(h-s*u)/i}return e},I.str=function(e){return"quat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+")"},I.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]},I.equals=function(e,i){var r=e[0],n=e[1],o=e[2],s=e[3],a=e[4],l=e[5],c=e[6],h=e[7],u=i[0],d=i[1],p=i[2],f=i[3],m=i[4],_=i[5],g=i[6],y=i[7];return Math.abs(r-u)<=t.EPSILON*Math.max(1,Math.abs(r),Math.abs(u))&&Math.abs(n-d)<=t.EPSILON*Math.max(1,Math.abs(n),Math.abs(d))&&Math.abs(o-p)<=t.EPSILON*Math.max(1,Math.abs(o),Math.abs(p))&&Math.abs(s-f)<=t.EPSILON*Math.max(1,Math.abs(s),Math.abs(f))&&Math.abs(a-m)<=t.EPSILON*Math.max(1,Math.abs(a),Math.abs(m))&&Math.abs(l-_)<=t.EPSILON*Math.max(1,Math.abs(l),Math.abs(_))&&Math.abs(c-g)<=t.EPSILON*Math.max(1,Math.abs(c),Math.abs(g))&&Math.abs(h-y)<=t.EPSILON*Math.max(1,Math.abs(h),Math.abs(y))},I.sqrLen=I.squaredLength=I.len=I.length=I.dot=I.mul=I.setReal=I.getReal=void 0;var t=s(o()),i=s(E()),r=s(g());function n(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(n=function(e){return e?i:t})(e)}function s(t,i){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var r=n(i);if(r&&r.has(t))return r.get(t);var o={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if("default"!==a&&Object.prototype.hasOwnProperty.call(t,a)){var l=s?Object.getOwnPropertyDescriptor(t,a):null;l&&(l.get||l.set)?Object.defineProperty(o,a,l):o[a]=t[a]}return o.default=t,r&&r.set(t,o),o}function a(e,t,i){var r=.5*i[0],n=.5*i[1],o=.5*i[2],s=t[0],a=t[1],l=t[2],c=t[3];return e[0]=s,e[1]=a,e[2]=l,e[3]=c,e[4]=r*c+n*l-o*a,e[5]=n*c+o*s-r*l,e[6]=o*c+r*a-n*s,e[7]=-r*s-n*a-o*l,e}function l(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e}function c(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=i[4],l=i[5],c=i[6],h=i[7],u=t[4],d=t[5],p=t[6],f=t[7],m=i[0],_=i[1],g=i[2],y=i[3];return e[0]=r*y+s*m+n*g-o*_,e[1]=n*y+s*_+o*m-r*g,e[2]=o*y+s*g+r*_-n*m,e[3]=s*y-r*m-n*_-o*g,e[4]=r*h+s*a+n*c-o*l+u*y+f*m+d*g-p*_,e[5]=n*h+s*l+o*a-r*c+d*y+f*_+p*m-u*g,e[6]=o*h+s*c+r*l-n*a+p*y+f*g+u*_-d*m,e[7]=s*h-r*a-n*l-o*c+f*y-u*m-d*_-p*g,e}I.getReal=i.copy,I.setReal=i.copy,I.mul=c;var h=i.dot;I.dot=h;var u=i.length;I.length=u,I.len=u;var d=i.squaredLength;return I.squaredLength=d,I.sqrLen=d,I}());r.quat2=h;var d=y(D());r.vec2=d;var p=y(b());r.vec3=p;var m=y(M());function _(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(_=function(e){return e?i:t})(e)}function y(t,i){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var r=_(i);if(r&&r.has(t))return r.get(t);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if("default"!==s&&Object.prototype.hasOwnProperty.call(t,s)){var a=o?Object.getOwnPropertyDescriptor(t,s):null;a&&(a.get||a.set)?Object.defineProperty(n,s,a):n[s]=t[s]}return n.default=t,r&&r.set(t,n),n}return r.vec4=m,r}(),B=function(){if(L)return R;function e(e,t,i,r){this.cx=3*e,this.bx=3*(i-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(r-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=i,this.p2y=r}return L=1,R=e,e.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,t){if(void 0===t&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var i=e,r=0;r<8;r++){var n=this.sampleCurveX(i)-e;if(Math.abs(n)<t)return i;var o=this.sampleCurveDerivativeX(i);if(Math.abs(o)<1e-6)break;i-=n/o}var s=0,a=1;for(i=e,r=0;r<20&&(n=this.sampleCurveX(i),!(Math.abs(n-e)<t));r++)e>n?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},R}(),N=t(B);function V(){if(k)return O;function e(e,t){this.x=e,this.y=t}return k=1,O=e,e.prototype={clone:function(){return new e(this.x,this.y)},add:function(e){return this.clone()._add(e)},sub:function(e){return this.clone()._sub(e)},multByPoint:function(e){return this.clone()._multByPoint(e)},divByPoint:function(e){return this.clone()._divByPoint(e)},mult:function(e){return this.clone()._mult(e)},div:function(e){return this.clone()._div(e)},rotate:function(e){return this.clone()._rotate(e)},rotateAround:function(e,t){return this.clone()._rotateAround(e,t)},matMult:function(e){return this.clone()._matMult(e)},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(e){return this.x===e.x&&this.y===e.y},dist:function(e){return Math.sqrt(this.distSqr(e))},distSqr:function(e){var t=e.x-this.x,i=e.y-this.y;return t*t+i*i},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith:function(e){return this.angleWithSep(e.x,e.y)},angleWithSep:function(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult:function(e){var t=e[2]*this.x+e[3]*this.y;return this.x=e[0]*this.x+e[1]*this.y,this.y=t,this},_add:function(e){return this.x+=e.x,this.y+=e.y,this},_sub:function(e){return this.x-=e.x,this.y-=e.y,this},_mult:function(e){return this.x*=e,this.y*=e,this},_div:function(e){return this.x/=e,this.y/=e,this},_multByPoint:function(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint:function(e){return this.x/=e.x,this.y/=e.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var e=this.y;return this.y=this.x,this.x=-e,this},_rotate:function(e){var t=Math.cos(e),i=Math.sin(e),r=i*this.x+t*this.y;return this.x=t*this.x-i*this.y,this.y=r,this},_rotateAround:function(e,t){var i=Math.cos(e),r=Math.sin(e),n=t.y+r*(this.x-t.x)+i*(this.y-t.y);return this.x=t.x+i*(this.x-t.x)-r*(this.y-t.y),this.y=n,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},e.convert=function(t){return t instanceof e?t:Array.isArray(t)?new e(t[0],t[1]):t},O}var U=t(V());function j(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!j(e[i],t[i]))return!1;return!0}if("object"==typeof e&&null!==e&&null!==t){if("object"!=typeof t)return!1;if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const i in e)if(!j(e[i],t[i]))return!1;return!0}return e===t}const G=Math.PI/180,q=180/Math.PI;function Z(e){return e*G}function $(e){return e*q}const H=[[0,0],[1,0],[1,1],[0,1]];function W(e){if(e<=0)return 0;if(e>=1)return 1;const t=e*e,i=t*e;return 4*(e<.5?i:3*(e-t)+i-.75)}function X(e,t,i,r){const n=new N(e,t,i,r);return function(e){return n.solve(e)}}const Y=X(.25,.1,.25,1);function K(e,t,i){return Math.min(i,Math.max(t,e))}function J(e,t,i){return(i=K((i-e)/(t-e),0,1))*i*(3-2*i)}function Q(e,t,i){const r=i-t,n=((e-t)%r+r)%r+t;return n===t?i:n}function ee(e,t,i){if(!e.length)return i(null,[]);let r=e.length;const n=new Array(e.length);let o=null;e.forEach(((e,s)=>{t(e,((e,t)=>{e&&(o=e),n[s]=t,0==--r&&i(o,n)}))}))}function te(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}let ie=1;function re(){return ie++}function ne(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function oe(e,t){e.forEach((e=>{t[e]&&(t[e]=t[e].bind(t))}))}function se(e,t){return-1!==e.indexOf(t,e.length-t.length)}function ae(e,t,i){const r={};for(const i in e)r[i]=t.call(this,e[i],i,e);return r}function le(e,t,i){const r={};for(const i in e)t.call(this,e[i],i,e)&&(r[i]=e[i]);return r}function ce(e){return Array.isArray(e)?e.map(ce):"object"==typeof e&&e?ae(e,ce):e}const he={};function ue(e){he[e]||("undefined"!=typeof console&&console.warn(e),he[e]=!0)}function de(e,t,i){return(i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function pe(e){let t=0;for(let i,r,n=0,o=e.length,s=o-1;n<o;s=n++)i=e[n],r=e[s],t+=(r.x-i.x)*(i.y+r.y);return t}function fe([e,t,i]){const r=Z(t+90),n=Z(i);return{x:e*Math.cos(r)*Math.sin(n),y:e*Math.sin(r)*Math.sin(n),z:e*Math.cos(n),azimuthal:t,polar:i}}function me(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}function _e(e){const t={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((e,i,r,n)=>{const o=r||n;return t[i]=!o||o.toLowerCase(),""})),t["max-age"]){const e=parseInt(t["max-age"],10);isNaN(e)?delete t["max-age"]:t["max-age"]=e}return t}let ge=null;function ye(e,t){return[e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}function xe(e,t,i,r){for(;t<i;){const n=t+i>>1;e[n]<r?t=n+1:i=n}return t}function ve(e,t,i,r){for(;t<i;){const n=t+i>>1;e[n]<=r?t=n+1:i=n}return t}function be(e){return e>0?1/(1.001-e):1+e}function we(e){return e>0?1-1/(1.001-e):-e}const Te={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i},get API_TILEJSON_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i},get API_SPRITE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i},get API_FONTS_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i},get API_STYLE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i},get API_CDN_URL_REGEX(){return/^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i},get EVENTS_URL(){if(!Te.API_URL)return null;try{const e=new URL(Te.API_URL);return"api.mapbox.cn"===e.hostname?"https://events.mapbox.cn/events/v2":"api.mapbox.com"===e.hostname?"https://events.mapbox.com/events/v2":null}catch(e){return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",RASTERARRAYS_URL_PREFIX:"rasterarrays/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,DEFAULT_STYLE:"mapbox://styles/mapbox/standard",MAX_PARALLEL_IMAGE_REQUESTS:16,DRACO_URL:"https://api.mapbox.com/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",MESHOPT_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_base_v0.20.wasm",MESHOPT_SIMD_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_simd_v0.20.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf",TILES3D_URL_PREFIX:"3dtiles/v1"};function Se(e){return Te.API_URL_REGEX.test(e)}function Me(e){return Te.API_SPRITE_REGEX.test(e)}let Ee,Ae,Ie,Ce,Pe,ze;function De(){return null==Ee&&(Ee=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof self.createImageBitmap),Ee}const Re={now:()=>void 0!==Ce?Ce:performance.now(),setNow(e){Ce=e},restoreNow(){Ce=void 0},frame(e){const t=requestAnimationFrame(e);return{cancel:()=>cancelAnimationFrame(t)}},getImageData(e,t=0){const{width:i,height:r}=e;Pe||(Pe=document.createElement("canvas"));const n=Pe.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("failed to create canvas 2d context");return(i>Pe.width||r>Pe.height)&&(Pe.width=i,Pe.height=r),n.clearRect(-t,-t,i+2*t,r+2*t),n.drawImage(e,0,0,i,r),n.getImageData(-t,-t,i+2*t,r+2*t)},resolveURL:e=>(Ae||(Ae=document.createElement("a")),Ae.href=e,Ae.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(null==Ie&&(Ie=window.matchMedia("(prefers-reduced-motion: reduce)")),Ie.matches)},hasCanvasFingerprintNoise(){if(void 0!==ze)return ze;if(!De())return ze=!1,!1;const e=new OffscreenCanvas(85,1),t=e.getContext("2d",{willReadFrequently:!0});let i=0;for(let r=0;r<e.width;++r)t.fillStyle=`rgba(${i++},${i++},${i++}, 255)`,t.fillRect(r,0,1,1);const r=t.getImageData(0,0,e.width,e.height);i=0;for(let e=0;e<r.data.length;++e)if(e%4!=3&&i++!==r.data[e])return ze=!0,!0;return ze=!1,!1}};function Le(e,t){const i=e.indexOf("?");if(i<0)return`${e}?${new URLSearchParams(t).toString()}`;const r=new URLSearchParams(e.slice(i));for(const e in t)r.set(e,t[e]);return`${e.slice(0,i)}?${r.toString()}`}function Oe(e,t={persistentParams:[]}){const i=e.indexOf("?");if(i<0)return e;const r=new URLSearchParams,n=new URLSearchParams(e.slice(i));for(const e of t.persistentParams){const t=n.get(e);t&&r.set(e,t)}const o=r.toString();return`${e.slice(0,i)}${o.length>0?`?${o}`:""}`}const ke="mapbox-tiles";let Fe=500,Be=50;const Ne=["language","worldview","jobid"];let Ve,Ue;function je(){try{return caches}catch(e){}}function Ge(){const e=je();e&&null==Ve&&(Ve=e.open(ke))}let qe=1/0;const Ze={supported:!1,testSupport:function(e){!We&&He&&(Xe?Ke(e):$e=e)}};let $e,He,We=!1,Xe=!1;const Ye="undefined"!=typeof self?self:{};function Ke(e){const t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t);try{if(e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,He),e.isContextLost())return;Ze.supported=!0}catch(e){}e.deleteTexture(t),We=!0}Ye.document&&(He=Ye.document.createElement("img"),He.onload=function(){$e&&Ke($e),$e=null,Xe=!0},He.onerror=function(){We=!0,$e=null},He.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Je={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Iconset:"Iconset",Image:"Image",Model:"Model"};"function"==typeof Object.freeze&&Object.freeze(Je);class Qe extends Error{constructor(e,t,i){401===t&&Se(i)&&(e+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(e),this.status=t,this.url=i}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const et=me()?()=>self.worker&&self.worker.referrer:()=>("blob:"===location.protocol?parent:self).location.href,tt=function(e,t){if(!(/^file:/.test(i=e.url)||/^file:/.test(et())&&!/^\w+:/.test(i))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return function(e,t){const i=new AbortController,r=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,referrer:et(),referrerPolicy:e.referrerPolicy,signal:i.signal});let n=!1,o=!1;const s=(a=r.url).indexOf("sku=")>0&&Se(a);var a;"json"===e.type&&r.headers.set("Accept","application/json");const l=(i,n,a)=>{if(o)return;if(i&&"SecurityError"!==i.message&&ue(i.toString()),n&&a)return c(n);const l=Date.now();fetch(r).then((i=>{if(i.ok){const e=s?i.clone():null;return c(i,e,l)}return t(new Qe(i.statusText,i.status,e.url))})).catch((i=>{"AbortError"!==i.name&&t(new Error(`${i.message} ${e.url}`))}))},c=(i,s,a)=>{("arrayBuffer"===e.type?i.arrayBuffer():"json"===e.type?i.json():i.text()).then((e=>{o||(s&&a&&function(e,t,i){if(Ge(),null==Ve)return;const r=_e(t.headers.get("Cache-Control")||"");if(r["no-store"])return;const n={status:t.status,statusText:t.statusText,headers:new Headers};t.headers.forEach(((e,t)=>n.headers.set(t,e))),r["max-age"]&&n.headers.set("Expires",new Date(i+1e3*r["max-age"]).toUTCString());const o=n.headers.get("Expires");if(!o)return;if(new Date(o).getTime()-i<42e4)return;let s=Oe(e.url,{persistentParams:Ne});if(206===t.status){const t=e.headers.get("Range");if(!t)return;n.status=200,s=Le(s,{range:t})}!function(e,t){if(void 0===Ue)try{new Response(new ReadableStream),Ue=!0}catch(e){Ue=!1}Ue?t(e.body):e.blob().then(t)}(t,(e=>{const i=new Response(200!==(r=t.status)&&404!==r&&[101,103,204,205,304].includes(r)?null:e,n);var r;Ge(),null!=Ve&&Ve.then((e=>e.put(s,i))).catch((e=>ue(e.message)))}))}(r,s,a),n=!0,t(null,e,i.headers.get("Cache-Control"),i.headers.get("Expires")))})).catch((e=>{o||t(new Error(e.message))}))};return s?function(e,t){if(Ge(),null==Ve)return t(null);Ve.then((i=>{let r=Oe(e.url,{persistentParams:Ne});const n=e.headers.get("Range");n&&(r=Le(r,{range:n})),i.match(r).then((e=>{const n=function(e){if(!e)return!1;const t=new Date(e.headers.get("Expires")||0),i=_e(e.headers.get("Cache-Control")||"");return t>Date.now()&&!i["no-cache"]}(e);i.delete(r),n&&i.put(r,e.clone()),t(null,e,n)})).catch(t)})).catch(t)}(r,l):l(null,null),{cancel:()=>{o=!0,n||i.abort()}}}(e,t);if(me()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",e,t,void 0,!0)}var i;return function(e,t){const i=new XMLHttpRequest;i.open(e.method||"GET",e.url,!0),"arrayBuffer"===e.type&&(i.responseType="arraybuffer");for(const t in e.headers)i.setRequestHeader(t,e.headers[t]);return"json"===e.type&&(i.responseType="text",i.setRequestHeader("Accept","application/json")),i.withCredentials="include"===e.credentials,i.onerror=()=>{t(new Error(i.statusText))},i.onload=()=>{if((i.status>=200&&i.status<300||0===i.status)&&null!==i.response){let r=i.response;if("json"===e.type)try{r=JSON.parse(i.response)}catch(e){return t(e)}t(null,r,i.getResponseHeader("Cache-Control"),i.getResponseHeader("Expires"))}else t(new Qe(i.statusText,i.status,e.url))},i.send(e.body),{cancel:()=>i.abort()}}(e,t)},it=function(e,t){return tt(te(e,{type:"arrayBuffer"}),t)};function rt(e){const t=document.createElement("a");return t.href=e,t.protocol===location.protocol&&t.host===location.host}const nt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let ot,st;ot=[],st=0;const at=function(e,t){if(Ze.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),st>=Te.MAX_PARALLEL_IMAGE_REQUESTS){const i={requestParameters:e,callback:t,cancelled:!1,cancel(){this.cancelled=!0}};return ot.push(i),i}st++;let i=!1;const r=()=>{if(!i)for(i=!0,st--;ot.length&&st<Te.MAX_PARALLEL_IMAGE_REQUESTS;){const e=ot.shift(),{requestParameters:t,callback:i,cancelled:r}=e;r||(e.cancel=at(t,i).cancel)}},n=it(e,((e,i,n,o)=>{r(),e?t(e):i&&(self.createImageBitmap?function(e,t){const i=new Blob([new Uint8Array(e)],{type:"image/png"});createImageBitmap(i).then((e=>{t(null,e)})).catch((e=>{t(new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))}))}(i,((e,i)=>t(e,i,n,o))):function(e,t){const i=new Image;i.onload=()=>{t(null,i),URL.revokeObjectURL(i.src),i.onload=null,requestAnimationFrame((()=>{i.src=nt}))},i.onerror=()=>t(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const r=new Blob([new Uint8Array(e)],{type:"image/png"});i.src=e.byteLength?URL.createObjectURL(r):nt}(i,((e,i)=>t(e,i,n,o))))}));return{cancel:()=>{n.cancel(),r()}}};var lt,ct,ht,ut={exports:{}},dt={exports:{}},pt={exports:{}},ft=function(){if(ht)return ut.exports;ht=1;var e=(lt||(lt=1,dt.exports=function(e,t){var i,r,n,o,s,a,l,c;for(r=e.length-(i=3&e.length),n=t,s=3432918353,a=461845907,c=0;c<r;)l=255&e.charCodeAt(c)|(255&e.charCodeAt(++c))<<8|(255&e.charCodeAt(++c))<<16|(255&e.charCodeAt(++c))<<24,++c,n=27492+(65535&(o=5*(65535&(n=(n^=l=(65535&(l=(l=(65535&l)*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&e.charCodeAt(c+2))<<16;case 2:l^=(255&e.charCodeAt(c+1))<<8;case 1:n^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(c)))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295}return n^=e.length,n=2246822507*(65535&(n^=n>>>16))+((2246822507*(n>>>16)&65535)<<16)&4294967295,n=3266489909*(65535&(n^=n>>>13))+((3266489909*(n>>>16)&65535)<<16)&4294967295,(n^=n>>>16)>>>0}),dt.exports),t=(ct||(ct=1,pt.exports=function(e,t){for(var i,r=e.length,n=t^r,o=0;r>=4;)i=1540483477*(65535&(i=255&e.charCodeAt(o)|(255&e.charCodeAt(++o))<<8|(255&e.charCodeAt(++o))<<16|(255&e.charCodeAt(++o))<<24))+((1540483477*(i>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),r-=4,++o;switch(r){case 3:n^=(255&e.charCodeAt(o+2))<<16;case 2:n^=(255&e.charCodeAt(o+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(o)))+((1540483477*(n>>>16)&65535)<<16)}return n=1540483477*(65535&(n^=n>>>13))+((1540483477*(n>>>16)&65535)<<16),(n^=n>>>15)>>>0}),pt.exports);return ut.exports=e,ut.exports.murmur3=e,ut.exports.murmur2=t,ut.exports}(),mt=t(ft);class _t{constructor(e,...t){te(this,t[0]||{}),this.type=e}}class gt extends _t{constructor(e,t={}){super("error",te({error:e},t))}}function yt(e,t,i){i[e]&&-1!==i[e].indexOf(t)||(i[e]=i[e]||[],i[e].push(t))}function xt(e,t,i){if(i&&i[e]){const r=i[e].indexOf(t);-1!==r&&i[e].splice(r,1)}}class vt{on(e,t){return this._listeners=this._listeners||{},yt(e,t,this._listeners),this}off(e,t){return xt(e,t,this._listeners),xt(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},yt(e,t,this._oneTimeListeners),this):new Promise((t=>this.once(e,t)))}fire(e,t){const i="string"==typeof e?new _t(e,t):e,r=i.type;if(this.listens(r)){i.target=this;const e=this._listeners&&this._listeners[r]?this._listeners[r].slice():[];for(const t of e)t.call(this,i);const t=this._oneTimeListeners&&this._oneTimeListeners[r]?this._oneTimeListeners[r].slice():[];for(const e of t)xt(r,e,this._oneTimeListeners),e.call(this,i);const n=this._eventedParent;n&&(te(i,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),n.fire(i))}else i instanceof gt&&console.error(i.error);return this}listens(e){return!!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}}var bt,wt={},Tt=function(){if(bt)return wt;bt=1;var e={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function t(e){return(e=Math.round(e))<0?0:e>255?255:e}function i(e){return t("%"===e[e.length-1]?parseFloat(e)/100*255:parseInt(e))}function r(e){return(t="%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))<0?0:t>1?1:t;var t}function n(e,t,i){return i<0?i+=1:i>1&&(i-=1),6*i<1?e+(t-e)*i*6:2*i<1?t:3*i<2?e+(t-e)*(2/3-i)*6:e}try{wt.parseCSSColor=function(o){var s,a=o.replace(/ /g,"").toLowerCase();if(a in e)return e[a].slice();if("#"===a[0])return 4===a.length?(s=parseInt(a.substr(1),16))>=0&&s<=4095?[(3840&s)>>4|(3840&s)>>8,240&s|(240&s)>>4,15&s|(15&s)<<4,1]:null:7===a.length&&(s=parseInt(a.substr(1),16))>=0&&s<=16777215?[(16711680&s)>>16,(65280&s)>>8,255&s,1]:null;var l=a.indexOf("("),c=a.indexOf(")");if(-1!==l&&c+1===a.length){var h=a.substr(0,l),u=a.substr(l+1,c-(l+1)).split(","),d=1;switch(h){case"rgba":if(4!==u.length)return null;d=r(u.pop());case"rgb":return 3!==u.length?null:[i(u[0]),i(u[1]),i(u[2]),d];case"hsla":if(4!==u.length)return null;d=r(u.pop());case"hsl":if(3!==u.length)return null;var p=(parseFloat(u[0])%360+360)%360/360,f=r(u[1]),m=r(u[2]),_=m<=.5?m*(f+1):m+f-m*f,g=2*m-_;return[t(255*n(g,_,p+1/3)),t(255*n(g,_,p)),t(255*n(g,_,p-1/3)),d];default:return null}}return null}}catch(e){}return wt}();class St{constructor(e,t,i,r=1){this.r=e,this.g=t,this.b=i,this.a=r}static parse(e){if(!e)return;if(e instanceof St)return e;if("string"!=typeof e)return;const t=Tt.parseCSSColor(e);return t?new St(t[0]/255*t[3],t[1]/255*t[3],t[2]/255*t[3],t[3]):void 0}toStringPremultipliedAlpha(){const[e,t,i,r]=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(e)},${Math.round(t)},${Math.round(i)},${r})`}toString(){const[e,t,i,r]=[this.r,this.g,this.b,this.a];return`rgba(${Math.round(255*e)},${Math.round(255*t)},${Math.round(255*i)},${r})`}toRenderColor(e){const{r:t,g:i,b:r,a:n}=this;return new Mt(e,t,i,r,n)}clone(){return new St(this.r,this.g,this.b,this.a)}}class Mt{constructor(e,t,i,r,n){if(e){const o=e.image.height,s=o*o;t=0===n?0:t/n*(o-1),i=0===n?0:i/n*(o-1),r=0===n?0:r/n*(o-1);const a=Math.floor(t),l=Math.floor(i),c=Math.floor(r),h=Math.ceil(t),u=Math.ceil(i),d=Math.ceil(r),p=t-a,f=i-l,m=r-c,_=e.image.data,g=4*(a+l*s+c*o),y=4*(a+l*s+d*o),x=4*(a+u*s+c*o),v=4*(a+u*s+d*o),b=4*(h+l*s+c*o),w=4*(h+l*s+d*o),T=4*(h+u*s+c*o),S=4*(h+u*s+d*o);if(g<0||S>=_.length)throw new Error("out of range");this.r=Et(Et(Et(_[g],_[y],m),Et(_[x],_[v],m),f),Et(Et(_[b],_[w],m),Et(_[T],_[S],m),f),p)/255*n,this.g=Et(Et(Et(_[g+1],_[y+1],m),Et(_[x+1],_[v+1],m),f),Et(Et(_[b+1],_[w+1],m),Et(_[T+1],_[S+1],m),f),p)/255*n,this.b=Et(Et(Et(_[g+2],_[y+2],m),Et(_[x+2],_[v+2],m),f),Et(Et(_[b+2],_[w+2],m),Et(_[T+2],_[S+2],m),f),p)/255*n,this.a=n}else this.r=t,this.g=i,this.b=r,this.a=n}toArray(){const{r:e,g:t,b:i,a:r}=this;return 0===r?[0,0,0,0]:[255*e/r,255*t/r,255*i/r,r]}toHslaArray(){if(0===this.a)return[0,0,0,0];const{r:e,g:t,b:i,a:r}=this,n=Math.min(Math.max(e/r,0),1),o=Math.min(Math.max(t/r,0),1),s=Math.min(Math.max(i/r,0),1),a=Math.min(n,o,s),l=Math.max(n,o,s),c=(a+l)/2;if(a===l)return[0,0,100*c,r];const h=l-a,u=c>.5?h/(2-l-a):h/(l+a);let d=0;return l===n?d=(o-s)/h+(o<s?6:0):l===o?d=(s-n)/h+2:l===s&&(d=(n-o)/h+4),d*=60,[Math.min(Math.max(d,0),360),Math.min(Math.max(100*u,0),100),Math.min(Math.max(100*c,0),100),r]}toArray01(){const{r:e,g:t,b:i,a:r}=this;return 0===r?[0,0,0,0]:[e/r,t/r,i/r,r]}toArray01Scaled(e){const{r:t,g:i,b:r,a:n}=this;return 0===n?[0,0,0]:[t/n*e,i/n*e,r/n*e]}toArray01PremultipliedAlpha(){const{r:e,g:t,b:i,a:r}=this;return[e,t,i,r]}toArray01Linear(){const{r:e,g:t,b:i,a:r}=this;return 0===r?[0,0,0,0]:[Math.pow(e/r,2.2),Math.pow(t/r,2.2),Math.pow(i/r,2.2),r]}}function Et(e,t,i){return e*(1-i)+t*i}function At(e,t,i){return e.map(((e,r)=>Et(e,t[r],i)))}St.black=new St(0,0,0,1),St.white=new St(1,1,1,1),St.transparent=new St(0,0,0,0),St.red=new St(1,0,0,1),St.blue=new St(0,0,1,1);var It=Object.freeze({__proto__:null,array:At,color:function(e,t,i){return new St(Et(e.r,t.r,i),Et(e.g,t.g,i),Et(e.b,t.b,i),Et(e.a,t.a,i))},number:Et});function Ct(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}class Pt extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}class zt{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[e,i]of t)this.bindings[e]=i}concat(e){return new zt(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}const Dt={kind:"null"},Rt={kind:"number"},Lt={kind:"string"},Ot={kind:"boolean"},kt={kind:"color"},Ft={kind:"object"},Bt={kind:"value"},Nt={kind:"collator"},Vt={kind:"formatted"},Ut={kind:"resolvedImage"};function jt(e,t){return{kind:"array",itemType:e,N:t}}function Gt(e){if("array"===e.kind){const t=Gt(e.itemType);return"number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const qt=[Dt,Rt,Lt,Ot,kt,Vt,Ft,jt(Bt),Ut];function Zt(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!Zt(e.itemType,t.itemType))&&("number"!=typeof e.N||e.N===t.N))return null}else{if(e.kind===t.kind)return null;if("value"===e.kind)for(const e of qt)if(!Zt(e,t))return null}return`Expected ${Gt(e)} but found ${Gt(t)} instead.`}function $t(e,t){return t.some((t=>t.kind===e.kind))}function Ht(e,t){return t.some((t=>"null"===t?null===e:"array"===t?Array.isArray(e):"object"===t?e&&!Array.isArray(e)&&"object"==typeof e:t===typeof e))}class Wt{constructor(e,t,i){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Xt{constructor(e,t,i,r,n){this.text=e.normalize?e.normalize():e,this.image=t,this.scale=i,this.fontStack=r,this.textColor=n}}class Yt{constructor(e){this.sections=e}static fromString(e){return new Yt([new Xt(e,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((e=>0!==e.text.length||e.image&&e.image.namePrimary))}static factory(e){return e instanceof Yt?e:Yt.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map((e=>e.text)).join("")}serialize(){const e=["format"];for(const t of this.sections){if(t.image){e.push(["image",t.image.namePrimary]);continue}e.push(t.text);const i={};t.fontStack&&(i["text-font"]=["literal",t.fontStack.split(",")]),t.scale&&(i["font-scale"]=t.scale),t.textColor&&(i["text-color"]=["rgba"].concat(t.textColor.toRenderColor(null).toArray())),e.push(i)}return e}}class Kt{constructor(e,t){if(this.id=e,this.options=t||{params:{}},this.options.transform){const{a:e,b:t,c:i,d:r,e:n,f:o}=this.options.transform;this.options.transform=new DOMMatrix([e,t,i,r,n,o])}else this.options.transform=new DOMMatrix([1,0,0,1,0,0])}static deserializeFromString(e){const t=JSON.parse(e),{a:i,b:r,c:n,d:o,e:s,f:a}=t.options.transform;return new DOMMatrix([i,r,n,o,s,a]),new Kt(t.id,t.options)}scaleSelf(e){return this.options.transform=this.options.transform.scale(e),this}serialize(){const e={id:this.id};this.options&&(e.options=this.options);const{a:t,b:i,c:r,d:n,e:o,f:s}=this.options.transform;return e.options.transform={a:t,b:i,c:r,d:n,e:o,f:s},JSON.stringify(e)}}class Jt{constructor(e){this.namePrimary=e.namePrimary,e.nameSecondary&&(this.nameSecondary=e.nameSecondary),e.optionsPrimary&&(this.optionsPrimary=e.optionsPrimary),e.optionsSecondary&&(this.optionsSecondary=e.optionsSecondary),this.available=e.available}toString(){return this.namePrimary&&this.nameSecondary?`[${this.namePrimary},${this.nameSecondary}]`:this.namePrimary}getPrimary(){return new Kt(this.namePrimary,{params:this.optionsPrimary&&this.optionsPrimary.params||{}})}getSerializedPrimary(){return this.getPrimary().serialize()}getSecondary(){return this.nameSecondary?new Kt(this.nameSecondary,{params:this.optionsSecondary&&this.optionsSecondary.params||{}}):null}static from(e){return"string"==typeof e?Jt.build(e):e}static build(e,t,i,r){return e?new Jt({namePrimary:e,nameSecondary:t,optionsPrimary:i,optionsSecondary:r,available:!1}):null}}function Qt(e,t,i,r){return"number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[e,t,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[e,t,i,r]:[e,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function ei(e){if(null===e)return!0;if("string"==typeof e)return!0;if("boolean"==typeof e)return!0;if("number"==typeof e)return!0;if(e instanceof St)return!0;if(e instanceof Wt)return!0;if(e instanceof Yt)return!0;if(e instanceof Jt)return!0;if(Array.isArray(e)){for(const t of e)if(!ei(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!ei(e[t]))return!1;return!0}return!1}function ti(e){if(null===e)return Dt;if("string"==typeof e)return Lt;if("boolean"==typeof e)return Ot;if("number"==typeof e)return Rt;if(e instanceof St)return kt;if(e instanceof Wt)return Nt;if(e instanceof Yt)return Vt;if(e instanceof Jt)return Ut;if(Array.isArray(e)){const t=e.length;let i;for(const t of e){const e=ti(t);if(i){if(i===e)continue;i=Bt;break}i=e}return jt(i||Bt,t)}return Ft}function ii(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof St?e.toStringPremultipliedAlpha():e instanceof Yt||e instanceof Jt?e.toString():JSON.stringify(e)}class ri{constructor(e,t){this.type=e,this.value=t}static parse(e,t){if(2!==e.length)return t.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!ei(e[1]))return t.error("invalid value");const i=e[1];let r=ti(i);const n=t.expectedType;return"array"!==r.kind||0!==r.N||!n||"array"!==n.kind||"number"==typeof n.N&&0!==n.N||(r=n),new ri(r,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof St?["rgba"].concat(this.value.toRenderColor(null).toArray()):this.value instanceof Yt?this.value.serialize():this.value}}class ni{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}const oi={string:Lt,number:Rt,boolean:Ot,object:Ft};class si{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let i,r=1;const n=e[0];if("array"===n){let n,o;if(e.length>2){const i=e[1];if("string"!=typeof i||!(i in oi)||"object"===i)return t.error('The item type argument of "array" must be one of string, number, boolean',1);n=oi[i],r++}else n=Bt;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return t.error('The length argument to "array" must be a positive integer literal',2);o=e[2],r++}i=jt(n,o)}else i=oi[n];const o=[];for(;r<e.length;r++){const i=t.parse(e[r],r,Bt);if(!i)return null;o.push(i)}return new si(i,o)}evaluate(e){for(let t=0;t<this.args.length;t++){const i=this.args[t].evaluate(e);if(!Zt(this.type,ti(i)))return i;if(t===this.args.length-1)throw new ni(`The expression ${JSON.stringify(this.args[t].serialize())} evaluated to ${Gt(ti(i))} but was expected to be of type ${Gt(this.type)}.`)}return null}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}serialize(){const e=this.type,t=[e.kind];if("array"===e.kind){const i=e.itemType;if("string"===i.kind||"number"===i.kind||"boolean"===i.kind){t.push(i.kind);const r=e.N;("number"==typeof r||this.args.length>1)&&t.push(r)}}return t.concat(this.args.map((e=>e.serialize())))}}class ai{constructor(e){this.type=Vt,this.sections=e}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[1];if(!Array.isArray(i)&&"object"==typeof i)return t.error("First argument must be an image or text section.");const r=[];let n=!1;for(let i=1;i<=e.length-1;++i){const o=e[i];if(n&&"object"==typeof o&&!Array.isArray(o)){n=!1;let e=null;if(o["font-scale"]&&(e=t.parseObjectValue(o["font-scale"],i,"font-scale",Rt),!e))return null;let s=null;if(o["text-font"]&&(s=t.parseObjectValue(o["text-font"],i,"text-font",jt(Lt)),!s))return null;let a=null;if(o["text-color"]&&(a=t.parseObjectValue(o["text-color"],i,"text-color",kt),!a))return null;const l=r[r.length-1];l.scale=e,l.font=s,l.textColor=a}else{const o=t.parse(e[i],i,Bt);if(!o)return null;const s=o.type.kind;if("string"!==s&&"value"!==s&&"null"!==s&&"resolvedImage"!==s)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");n=!0,r.push({content:o,scale:null,font:null,textColor:null})}}return new ai(r)}evaluate(e){return new Yt(this.sections.map((t=>{const i=t.content.evaluate(e);return ti(i)===Ut?new Xt("",i,null,null,null):new Xt(ii(i),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null)})))}eachChild(e){for(const t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor)}outputDefined(){return!1}serialize(){const e=["format"];for(const t of this.sections){e.push(t.content.serialize());const i={};t.scale&&(i["font-scale"]=t.scale.serialize()),t.font&&(i["text-font"]=t.font.serialize()),t.textColor&&(i["text-color"]=t.textColor.serialize()),e.push(i)}return e}}class li{constructor(e,t,i,r){this._imageWarnHistory={},this.type=Ut,this.inputPrimary=e,this.inputSecondary=t,this.inputPrimaryParams=i,this.inputSecondaryParams=r}static parse(e,t){if(e.length<2)return t.error("Expected two or more arguments.");let i=1;const r=[];function n(){if(i<e.length){const n=t.parse(e[i],i++,Lt);return n?(r.push({image:n,options:void 0}),!0):(t.error(r.length?"Secondary image variant is not a string.":"No image name provided."),!1)}return!0}function o(){if(i<e.length){if(null===(n=e[i])||"object"!=typeof n||Array.isArray(n))return!0;const o=e[i].params,s=t.concat(i);if(!o)return i++,!0;if("object"!=typeof o||o.constructor!==Object)return s.error('Image options "params" should be an object'),!1;const a={},l=s.concat(void 0,"params");for(const e in o){if(!e)return l.error("Image parameter name should be non-empty"),!1;const t=l.concat(void 0,e).parse(o[e],void 0,kt,void 0,{typeAnnotation:"coerce"});if(!t)return!1;a[e]=t}return r[r.length-1].options=a,i++,!0}var n;return!0}for(let e=0;e<2;e++)if(!n()||!o())return;return new li(r[0].image,r[1]?r[1].image:void 0,r[0].options,r[1]?r[1].options:void 0)}evaluateParams(e,t){const i={};if(t){for(const r in t)if(t[r])try{const n=t[r].evaluate(e),o=`Ignoring image parameter "${r}" with semi-transparent color ${n.toString()}`;if(1!==n.a){this._imageWarnHistory[o]||(console.warn(o),this._imageWarnHistory[o]=!0);continue}i[r]=n}catch(e){continue}if(0!==Object.keys(i).length)return{params:i}}}evaluate(e){const t=Jt.build(this.inputPrimary.evaluate(e),this.inputSecondary?this.inputSecondary.evaluate(e):void 0,this.inputPrimaryParams?this.evaluateParams(e,this.inputPrimaryParams):void 0,this.inputSecondaryParams?this.evaluateParams(e,this.inputSecondaryParams):void 0);return t&&e.availableImages&&(t.available=e.availableImages.indexOf(t.namePrimary)>-1,t.nameSecondary&&t.available&&e.availableImages&&(t.available=e.availableImages.indexOf(t.nameSecondary)>-1)),t}eachChild(e){if(e(this.inputPrimary),this.inputPrimaryParams)for(const t in this.inputPrimaryParams)this.inputPrimaryParams[t]&&e(this.inputPrimaryParams[t]);if(this.inputSecondary&&(e(this.inputSecondary),this.inputSecondaryParams))for(const t in this.inputSecondaryParams)this.inputSecondaryParams[t]&&e(this.inputSecondaryParams[t])}outputDefined(){return!1}serializeParams(e){const t={};if(e){for(const i in e)e[i]&&(t[i]=e[i].serialize());return{params:t}}}serialize(){const e=["image",this.inputPrimary.serialize()];return this.inputPrimaryParams&&e.push(this.serializeParams(this.inputPrimaryParams)),this.inputSecondary&&(e.push(this.inputSecondary.serialize()),this.inputSecondaryParams&&e.push(this.serializeParams(this.inputSecondaryParams))),e}}function ci(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}const hi={"to-boolean":Ot,"to-color":kt,"to-number":Rt,"to-string":Lt};class ui{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[0],r=[];let n=Dt;if("to-array"===i){if(!Array.isArray(e[1]))return null;const i=e[1].length;if(t.expectedType){if("array"!==t.expectedType.kind)return t.error(`Expected ${t.expectedType.kind} but found array.`);n=jt(t.expectedType.itemType,i)}else{if(!(i>0&&ei(e[1][0])))return null;n=jt(ti(e[1][0]),i)}for(let o=0;o<i;o++){const i=e[1][o];let s;if("array"===ci(i))s=t.parse(i,void 0,n.itemType);else{const e=ci(i);if(e!==n.itemType.kind)return t.error(`Expected ${n.itemType.kind} but found ${e}.`);s=t.registry.literal.parse(["literal",void 0===i?null:i],t)}if(!s)return null;r.push(s)}}else{if(("to-boolean"===i||"to-string"===i)&&2!==e.length)return t.error("Expected one argument.");n=hi[i];for(let i=1;i<e.length;i++){const n=t.parse(e[i],i,Bt);if(!n)return null;r.push(n)}}return new ui(n,r)}evaluate(e){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(e));if("color"===this.type.kind){let t,i;for(const r of this.args){if(t=r.evaluate(e),i=null,t instanceof St)return t;if("string"==typeof t){const i=e.parseColor(t);if(i)return i}else if(Array.isArray(t)&&(i=t.length<3||t.length>4?`Invalid rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:Qt(t[0],t[1],t[2],t[3]),!i))return new St(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new ni(i||`Could not parse color from value '${"string"==typeof t?t:String(JSON.stringify(t))}'`)}if("number"===this.type.kind){let t=null;for(const i of this.args){if(t=i.evaluate(e),null===t)return 0;const r=Number(t);if(!isNaN(r))return r}throw new ni(`Could not convert ${JSON.stringify(t)} to number.`)}return"formatted"===this.type.kind?Yt.fromString(ii(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?Jt.build(ii(this.args[0].evaluate(e))):"array"===this.type.kind?this.args.map((t=>t.evaluate(e))):ii(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new ai([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new li(this.args[0]).serialize();const e="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild((t=>{e.push(t.serialize())})),e}}const di=["Unknown","Point","LineString","Polygon"];class pi{constructor(e,t){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.scope=e,this.options=t}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?di[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}measureLight(e){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const e=this.featureDistanceData.center,t=this.featureDistanceData.scale,{x:i,y:r}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(i*t-e[0])+this.featureDistanceData.bearing[1]*(r*t-e[1])}return 0}parseColor(e){let t=this._parseColorCache[e];return t||(t=this._parseColorCache[e]=St.parse(e)),t}getConfig(e){return this.options?this.options.get(e):null}}class fi{constructor(e,t,i,r,n){this.name=e,this.type=t,this._evaluate=i,this.args=r,this._overloadIndex=n}evaluate(e){if(!this._evaluate){const e=fi.definitions[this.name];this._evaluate=Array.isArray(e)?e[2]:e.overloads[this._overloadIndex][1]}return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map((e=>e.serialize())))}static parse(e,t){const i=e[0],r=fi.definitions[i];if(!r)return t.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const n=Array.isArray(r)?r[0]:r.type,o=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,s=[];let a=null,l=-1;for(const[r,c]of o){if(Array.isArray(r)&&r.length!==e.length-1)continue;s.push(r),l++,a=new Dr(t.registry,t.path,null,t.scope,void 0,t._scope,t.options);const o=[];let h=!1;for(let t=1;t<e.length;t++){const i=e[t],n=Array.isArray(r)?r[t-1]:r.type,s=a.parse(i,1+o.length,n);if(!s){h=!0;break}o.push(s)}if(!h)if(Array.isArray(r)&&r.length!==o.length)a.error(`Expected ${r.length} arguments, but found ${o.length} instead.`);else{for(let e=0;e<o.length;e++){const t=Array.isArray(r)?r[e]:r.type,i=o[e];a.concat(e+1).checkSubtype(t,i.type)}if(0===a.errors.length)return new fi(i,n,c,o,l)}}if(1===s.length)t.errors.push(...a.errors);else{const i=(s.length?s:o.map((([e])=>e))).map(mi).join(" | "),r=[];for(let i=1;i<e.length;i++){const n=t.parse(e[i],1+r.length);if(!n)return null;r.push(Gt(n.type))}t.error(`Expected arguments of type ${i}, but found (${r.join(", ")}) instead.`)}return null}static register(e,t){fi.definitions=t;for(const i in t)e[i]=fi}}function mi(e){return Array.isArray(e)?`(${e.map(Gt).join(", ")})`:`(${Gt(e.type)}...)`}class _i{constructor(e,t,i){this.type=Nt,this.locale=i,this.caseSensitive=e,this.diacriticSensitive=t}static parse(e,t){if(2!==e.length)return t.error("Expected one argument.");const i=e[1];if("object"!=typeof i||Array.isArray(i))return t.error("Collator options argument must be an object.");const r=void 0===i["case-sensitive"]?t.parse(!1,1,Ot):t.parseObjectValue(i["case-sensitive"],1,"case-sensitive",Ot);if(!r)return null;const n=void 0===i["diacritic-sensitive"]?t.parse(!1,1,Ot):t.parseObjectValue(i["diacritic-sensitive"],1,"diacritic-sensitive",Ot);if(!n)return null;let o=null;return i.locale&&(o=t.parseObjectValue(i.locale,1,"locale",Lt),!o)?null:new _i(r,n,o)}evaluate(e){return new Wt(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}serialize(){const e={};return e["case-sensitive"]=this.caseSensitive.serialize(),e["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(e.locale=this.locale.serialize()),["collator",e]}}function gi(e,t,i=0,r=e.length-1,n=xi){for(;r>i;){if(r-i>600){const o=r-i+1,s=t-i+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);gi(e,t,Math.max(i,Math.floor(t-s*l/o+c)),Math.min(r,Math.floor(t+(o-s)*l/o+c)),n)}const o=e[t];let s=i,a=r;for(yi(e,i,t),n(e[r],o)>0&&yi(e,i,r);s<a;){for(yi(e,s,a),s++,a--;n(e[s],o)<0;)s++;for(;n(e[a],o)>0;)a--}0===n(e[i],o)?yi(e,i,a):(a++,yi(e,a,r)),a<=t&&(i=a+1),t<=a&&(r=a-1)}}function yi(e,t,i){const r=e[t];e[t]=e[i],e[i]=r}function xi(e,t){return e<t?-1:e>t?1:0}function vi(e){let t=0;for(let i,r,n=0,o=e.length,s=o-1;n<o;s=n++)i=e[n],r=e[s],t+=(r.x-i.x)*(i.y+r.y);return t}function bi(e,t){e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.max(e[2],t[0]),e[3]=Math.max(e[3],t[1])}function wi(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function Ti(e,t,i){const r=e[0]-t[0],n=e[1]-t[1],o=e[0]-i[0],s=e[1]-i[1];return r*s-o*n==0&&r*o<=0&&n*s<=0}function Si(e,t,i=!1){let r=!1;for(let a=0,l=t.length;a<l;a++){const l=t[a];for(let t=0,a=l.length,c=a-1;t<a;c=t++){const a=l[c],h=l[t];if(Ti(e,a,h))return i;(o=a)[1]>(n=e)[1]!=(s=h)[1]>n[1]&&n[0]<(s[0]-o[0])*(n[1]-o[1])/(s[1]-o[1])+o[0]&&(r=!r)}}var n,o,s;return r}function Mi(e,t,i,r){const n=r[0]-i[0],o=r[1]-i[1],s=(e[0]-i[0])*o-n*(e[1]-i[1]),a=(t[0]-i[0])*o-n*(t[1]-i[1]);return s>0&&a<0||s<0&&a>0}function Ei(e,t,i,r){return 0!=(n=[r[0]-i[0],r[1]-i[1]])[0]*(o=[t[0]-e[0],t[1]-e[1]])[1]-n[1]*o[0]&&!(!Mi(e,t,i,r)||!Mi(i,r,e,t));var n,o}const Ai=8192;function Ii(e,t){const i=(180+e[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,n=Math.pow(2,t.z);return[Math.round(i*n*Ai),Math.round(r*n*Ai)]}function Ci(e,t){for(let i=0;i<t.length;i++)if(Si(e,t[i]))return!0;return!1}function Pi(e,t,i){for(const r of i)for(let i=0,n=r.length,o=n-1;i<n;o=i++)if(Ei(e,t,r[o],r[i]))return!0;return!1}function zi(e,t){for(let i=0;i<e.length;++i)if(!Si(e[i],t))return!1;for(let i=0;i<e.length-1;++i)if(Pi(e[i],e[i+1],t))return!1;return!0}function Di(e,t){for(let i=0;i<t.length;i++)if(zi(e,t[i]))return!0;return!1}function Ri(e,t,i){const r=[];for(let n=0;n<e.length;n++){const o=[];for(let r=0;r<e[n].length;r++){const s=Ii(e[n][r],i);bi(t,s),o.push(s)}r.push(o)}return r}function Li(e,t,i){const r=[];for(let n=0;n<e.length;n++){const o=Ri(e[n],t,i);r.push(o)}return r}function Oi(e,t,i,r){if(e[0]<i[0]||e[0]>i[2]){const t=.5*r;let n=e[0]-i[0]>t?-r:i[0]-e[0]>t?r:0;0===n&&(n=e[0]-i[2]>t?-r:i[2]-e[0]>t?r:0),e[0]+=n}bi(t,e)}function ki(e,t,i,r){const n=Math.pow(2,r.z)*Ai,o=[r.x*Ai,r.y*Ai],s=[];if(!e)return s;for(const r of e)for(const e of r){const r=[e.x+o[0],e.y+o[1]];Oi(r,t,i,n),s.push(r)}return s}function Fi(e,t,i,r){const n=Math.pow(2,r.z)*Ai,o=[r.x*Ai,r.y*Ai],s=[];if(!e)return s;for(const i of e){const e=[];for(const r of i){const i=[r.x+o[0],r.y+o[1]];bi(t,i),e.push(i)}s.push(e)}if(t[2]-t[0]<=n/2){(a=t)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const e of s)for(const r of e)Oi(r,t,i,n)}var a;return s}class Bi{constructor(e,t){this.type=Ot,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(ei(e[1])){const t=e[1];if("FeatureCollection"===t.type)for(let e=0;e<t.features.length;++e){const i=t.features[e].geometry.type;if("Polygon"===i||"MultiPolygon"===i)return new Bi(t,t.features[e].geometry)}else if("Feature"===t.type){const e=t.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new Bi(t,t.geometry)}else if("Polygon"===t.type||"MultiPolygon"===t.type)return new Bi(t,t)}return t.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,t){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=e.canonicalID();if(!n)return!1;if("Polygon"===t.type){const o=Ri(t.coordinates,r,n),s=ki(e.geometry(),i,r,n);if(!wi(i,r))return!1;for(const e of s)if(!Si(e,o))return!1}if("MultiPolygon"===t.type){const o=Li(t.coordinates,r,n),s=ki(e.geometry(),i,r,n);if(!wi(i,r))return!1;for(const e of s)if(!Ci(e,o))return!1}return!0}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=e.canonicalID();if(!n)return!1;if("Polygon"===t.type){const o=Ri(t.coordinates,r,n),s=Fi(e.geometry(),i,r,n);if(!wi(i,r))return!1;for(const e of s)if(!zi(e,o))return!1}if("MultiPolygon"===t.type){const o=Li(t.coordinates,r,n),s=Fi(e.geometry(),i,r,n);if(!wi(i,r))return!1;for(const e of s)if(!Di(e,o))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}const Ni={kilometers:1,miles:1e3/1609.344,nauticalmiles:1e3/1852,meters:1e3,metres:1e3,yards:1e3/.9144,feet:1e3/.3048,inches:1e3/.0254},Vi=1/298.257223563,Ui=Vi*(2-Vi),ji=Math.PI/180;class Gi{static fromTile(e,t,i){const r=Math.PI*(1-2*(e+.5)/Math.pow(2,t)),n=Math.atan(.5*(Math.exp(r)-Math.exp(-r)))/ji;return new Gi(n,i)}static get units(){return Ni}constructor(e,t){if(void 0===e)throw new Error("No latitude given.");if(t&&!Ni[t])throw new Error(`Unknown unit ${t}. Use one of: ${Object.keys(Ni).join(", ")}`);const i=6378.137*ji*(t?Ni[t]:1),r=Math.cos(e*ji),n=1/(1-Ui*(1-r*r)),o=Math.sqrt(n);this.kx=i*o*r,this.ky=i*o*n*(1-Ui)}distance(e,t){const i=$i(e[0]-t[0])*this.kx,r=(e[1]-t[1])*this.ky;return Math.sqrt(i*i+r*r)}bearing(e,t){const i=$i(t[0]-e[0])*this.kx;return Math.atan2(i,(t[1]-e[1])*this.ky)/ji}destination(e,t,i){const r=i*ji;return this.offset(e,Math.sin(r)*t,Math.cos(r)*t)}offset(e,t,i){return[e[0]+t/this.kx,e[1]+i/this.ky]}lineDistance(e){let t=0;for(let i=0;i<e.length-1;i++)t+=this.distance(e[i],e[i+1]);return t}area(e){let t=0;for(let i=0;i<e.length;i++){const r=e[i];for(let e=0,n=r.length,o=n-1;e<n;o=e++)t+=$i(r[e][0]-r[o][0])*(r[e][1]+r[o][1])*(i?-1:1)}return Math.abs(t)/2*this.kx*this.ky}along(e,t){let i=0;if(t<=0)return e[0];for(let r=0;r<e.length-1;r++){const n=e[r],o=e[r+1],s=this.distance(n,o);if(i+=s,i>t)return Zi(n,o,(t-(i-s))/s)}return e[e.length-1]}pointToSegmentDistance(e,t,i){let[r,n]=t,o=$i(i[0]-r)*this.kx,s=(i[1]-n)*this.ky;if(0!==o||0!==s){const t=($i(e[0]-r)*this.kx*o+(e[1]-n)*this.ky*s)/(o*o+s*s);t>1?(r=i[0],n=i[1]):t>0&&(r+=o/this.kx*t,n+=s/this.ky*t)}return o=$i(e[0]-r)*this.kx,s=(e[1]-n)*this.ky,Math.sqrt(o*o+s*s)}pointOnLine(e,t){let i=1/0,r=e[0][0],n=e[0][1],o=0,s=0;for(let a=0;a<e.length-1;a++){let l=e[a][0],c=e[a][1],h=$i(e[a+1][0]-l)*this.kx,u=(e[a+1][1]-c)*this.ky,d=0;0===h&&0===u||(d=($i(t[0]-l)*this.kx*h+(t[1]-c)*this.ky*u)/(h*h+u*u),d>1?(l=e[a+1][0],c=e[a+1][1]):d>0&&(l+=h/this.kx*d,c+=u/this.ky*d)),h=$i(t[0]-l)*this.kx,u=(t[1]-c)*this.ky;const p=h*h+u*u;p<i&&(i=p,r=l,n=c,o=a,s=d)}return{point:[r,n],index:o,t:Math.max(0,Math.min(1,s))}}lineSlice(e,t,i){let r=this.pointOnLine(i,e),n=this.pointOnLine(i,t);if(r.index>n.index||r.index===n.index&&r.t>n.t){const e=r;r=n,n=e}const o=[r.point],s=r.index+1,a=n.index;!qi(i[s],o[0])&&s<=a&&o.push(i[s]);for(let e=s+1;e<=a;e++)o.push(i[e]);return qi(i[a],n.point)||o.push(n.point),o}lineSliceAlong(e,t,i){let r=0;const n=[];for(let o=0;o<i.length-1;o++){const s=i[o],a=i[o+1],l=this.distance(s,a);if(r+=l,r>e&&0===n.length&&n.push(Zi(s,a,(e-(r-l))/l)),r>=t)return n.push(Zi(s,a,(t-(r-l))/l)),n;r>e&&n.push(a)}return n}bufferPoint(e,t){const i=t/this.ky,r=t/this.kx;return[e[0]-r,e[1]-i,e[0]+r,e[1]+i]}bufferBBox(e,t){const i=t/this.ky,r=t/this.kx;return[e[0]-r,e[1]-i,e[2]+r,e[3]+i]}insideBBox(e,t){return $i(e[0]-t[0])>=0&&$i(e[0]-t[2])<=0&&e[1]>=t[1]&&e[1]<=t[3]}}function qi(e,t){return e[0]===t[0]&&e[1]===t[1]}function Zi(e,t,i){const r=$i(t[0]-e[0]);return[e[0]+r*i,e[1]+(t[1]-e[1])*i]}function $i(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}class Hi{constructor(e=[],t=(e,t)=>e<t?-1:e>t?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:i}=this,r=t[e];for(;e>0;){const n=e-1>>1,o=t[n];if(i(r,o)>=0)break;t[e]=o,e=n}t[e]=r}_down(e){const{data:t,compare:i}=this,r=this.length>>1,n=t[e];for(;e<r;){let r=1+(e<<1);const o=r+1;if(o<this.length&&i(t[o],t[r])<0&&(r=o),i(t[r],n)>=0)break;t[e]=t[r],e=r}t[e]=n}}var Wi=8192;function Xi(e,t){return t.dist-e.dist}function Yi(e){const t=[1/0,1/0,-1/0,-1/0];if(t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!==e[i])return!1;return!0}function Ki(e){return e[1]-e[0]+1}function Ji(e,t){const i=e[1]>=e[0]&&e[1]<t;return i||console.warn("Distance Expression: Index is out of range"),i}function Qi(e,t){if(e[0]>e[1])return[null,null];const i=Ki(e);if(t){if(2===i)return[e,null];const t=Math.floor(i/2);return[[e[0],e[0]+t],[e[0]+t,e[1]]]}{if(1===i)return[e,null];const t=Math.floor(i/2)-1;return[[e[0],e[0]+t],[e[0]+t+1,e[1]]]}}function er(e,t){const i=[1/0,1/0,-1/0,-1/0];if(!Ji(t,e.length))return i;for(let r=t[0];r<=t[1];++r)bi(i,e[r]);return i}function tr(e){const t=[1/0,1/0,-1/0,-1/0];for(let i=0;i<e.length;++i)for(let r=0;r<e[i].length;++r)bi(t,e[i][r]);return t}function ir(e,t,i){if(Yi(e)||Yi(t))return NaN;let r=0,n=0;return e[2]<t[0]&&(r=t[0]-e[2]),e[0]>t[2]&&(r=e[0]-t[2]),e[1]>t[3]&&(n=e[1]-t[3]),e[3]<t[1]&&(n=t[1]-e[3]),i.distance([0,0],[r,n])}function rr(e){return 360*e-180}function nr(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function or(e,t){const i=Math.pow(2,t.z),r=(e.y/Wi+t.y)/i;return[rr((e.x/Wi+t.x)/i),nr(r)]}function sr(e,t){const i=[];for(let r=0;r<e.length;++r)i.push(or(e[r],t));return i}function ar(e,t,i){const r=i.pointOnLine(t,e).point;return i.distance(e,r)}function lr(e,t,i,r,n){const o=i.slice(r[0],r[1]+1);let s=1/0;for(let i=t[0];i<=t[1];++i)if(0===(s=Math.min(s,ar(e[i],o,n))))return 0;return s}function cr(e,t,i,r,n){const o=Math.min(n.pointToSegmentDistance(e,i,r),n.pointToSegmentDistance(t,i,r)),s=Math.min(n.pointToSegmentDistance(i,e,t),n.pointToSegmentDistance(r,e,t));return Math.min(o,s)}function hr(e,t,i,r,n){if(!Ji(t,e.length)||!Ji(r,i.length))return NaN;let o=1/0;for(let s=t[0];s<t[1];++s)for(let t=r[0];t<r[1];++t){if(Ei(e[s],e[s+1],i[t],i[t+1]))return 0;o=Math.min(o,cr(e[s],e[s+1],i[t],i[t+1],n))}return o}function ur(e,t,i,r,n){if(!Ji(t,e.length)||!Ji(r,i.length))return NaN;let o=1/0;for(let s=t[0];s<=t[1];++s)for(let t=r[0];t<=r[1];++t)if(0===(o=Math.min(o,n.distance(e[s],i[t]))))return o;return o}function dr(e,t,i){if(Si(e,t,!0))return 0;let r=1/0;for(const n of t){const t=n.length;if(t<2)return console.warn("Distance Expression: Invalid polygon!"),NaN;if(n[0]!==n[t-1]&&0===(r=Math.min(r,i.pointToSegmentDistance(e,n[t-1],n[0]))))return r;if(0===(r=Math.min(r,ar(e,n,i))))return r}return r}function pr(e,t,i,r){if(!Ji(t,e.length))return NaN;for(let r=t[0];r<=t[1];++r)if(Si(e[r],i,!0))return 0;let n=1/0;for(let o=t[0];o<t[1];++o)for(const t of i)for(let i=0,s=t.length,a=s-1;i<s;a=i++){if(Ei(e[o],e[o+1],t[a],t[i]))return 0;n=Math.min(n,cr(e[o],e[o+1],t[a],t[i],r))}return n}function fr(e,t){for(const i of e)for(let e=0;e<=i.length-1;++e)if(Si(i[e],t,!0))return!0;return!1}function mr(e,t,i,r=1/0){const n=tr(e),o=tr(t);if(r!==1/0&&ir(n,o,i)>=r)return r;if(wi(n,o)){if(fr(e,t))return 0}else if(fr(t,e))return 0;let s=r;for(const r of e)for(let e=0,n=r.length,o=n-1;e<n;o=e++)for(const n of t)for(let t=0,a=n.length,l=a-1;t<a;l=t++){if(Ei(r[o],r[e],n[l],n[t]))return 0;s=Math.min(s,cr(r[o],r[e],n[l],n[t],i))}return s}function _r(e,t,i,r,n,o,s){if(null===o||null===s)return;const a=ir(er(r,o),er(n,s),i);a<t&&e.push({dist:a,range1:o,range2:s})}function gr(e,t,i,r,n=1/0){let o=Math.min(r.distance(e[0],i[0][0]),n);if(0===o)return o;const s=new Hi([{dist:0,range1:[0,e.length-1],range2:[0,0]}],Xi),a=t?50:100,l=tr(i);for(;s.length;){const n=s.pop();if(n.dist>=o)continue;const c=n.range1;if(Ki(c)<=a){if(!Ji(c,e.length))return NaN;if(t){const t=pr(e,c,i,r);if(0===(o=Math.min(o,t)))return o}else for(let t=c[0];t<=c[1];++t){const n=dr(e[t],i,r);if(0===(o=Math.min(o,n)))return o}}else{const i=Qi(c,t);if(null!==i[0]){const t=ir(er(e,i[0]),l,r);t<o&&s.push({dist:t,range1:i[0],range2:[0,0]})}if(null!==i[1]){const t=ir(er(e,i[1]),l,r);t<o&&s.push({dist:t,range1:i[1],range2:[0,0]})}}}return o}function yr(e,t,i,r,n,o=1/0){let s=Math.min(o,n.distance(e[0],i[0]));if(0===s)return s;const a=new Hi([{dist:0,range1:[0,e.length-1],range2:[0,i.length-1]}],Xi),l=t?50:100,c=r?50:100;for(;a.length;){const o=a.pop();if(o.dist>=s)continue;const h=o.range1,u=o.range2;if(Ki(h)<=l&&Ki(u)<=c){if(!Ji(h,e.length)||!Ji(u,i.length))return NaN;if(t&&r?s=Math.min(s,hr(e,h,i,u,n)):t||r?t&&!r?s=Math.min(s,lr(i,u,e,h,n)):!t&&r&&(s=Math.min(s,lr(e,h,i,u,n))):s=Math.min(s,ur(e,h,i,u,n)),0===s)return s}else{const o=Qi(h,t),l=Qi(u,r);_r(a,s,n,e,i,o[0],l[0]),_r(a,s,n,e,i,o[0],l[1]),_r(a,s,n,e,i,o[1],l[0]),_r(a,s,n,e,i,o[1],l[1])}}return s}function xr(e,t,i,r,n=1/0){let o=n;const s=er(e,[0,e.length-1]);for(const n of i)if(!(o!==1/0&&ir(s,er(n,[0,n.length-1]),r)>=o)&&(o=Math.min(o,yr(e,t,n,!0,r,o)),0===o))return o;return o}function vr(e,t,i,r,n=1/0){let o=n;const s=er(e,[0,e.length-1]);for(const n of i){if(o!==1/0&&ir(s,tr(n),r)>=o)continue;const i=gr(e,t,n,r,o);if(isNaN(i))return i;if(0===(o=Math.min(o,i)))return o}return o}function br(e){return"Point"===e||"MultiPoint"===e||"LineString"===e||"MultiLineString"===e||"Polygon"===e||"MultiPolygon"===e}class wr{constructor(e,t){this.type=Rt,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'distance' expression requires either one argument, but found ' ${e.length-1} instead.`);if(ei(e[1])){const t=e[1];if("FeatureCollection"===t.type){for(let e=0;e<t.features.length;++e)if(br(t.features[e].geometry.type))return new wr(t,t.features[e].geometry)}else if("Feature"===t.type){if(br(t.geometry.type))return new wr(t,t.geometry)}else if(br(t.type))return new wr(t,t)}return t.error("'distance' expression needs to be an array with format ['Distance', GeoJSONObj].")}evaluate(e){const t=e.geometry(),i=e.canonicalID();if(null!=t&&null!=i){if("Point"===e.geometryType())return function(e,t,i){const r=[];for(const i of e)for(const e of i)r.push(or(e,t));const n=new Gi(r[0][1],"meters");return"Point"===i.type||"MultiPoint"===i.type||"LineString"===i.type?yr(r,!1,"Point"===i.type?[i.coordinates]:i.coordinates,"LineString"===i.type,n):"MultiLineString"===i.type?xr(r,!1,i.coordinates,n):"Polygon"===i.type||"MultiPolygon"===i.type?vr(r,!1,"Polygon"===i.type?[i.coordinates]:i.coordinates,n):null}(t,i,this.geometries);if("LineString"===e.geometryType())return function(e,t,i){const r=[];for(const i of e){const e=[];for(const r of i)e.push(or(r,t));r.push(e)}const n=new Gi(r[0][0][1],"meters");if("Point"===i.type||"MultiPoint"===i.type||"LineString"===i.type)return xr("Point"===i.type?[i.coordinates]:i.coordinates,"LineString"===i.type,r,n);if("MultiLineString"===i.type){let e=1/0;for(let t=0;t<i.coordinates.length;t++){const o=xr(i.coordinates[t],!0,r,n,e);if(isNaN(o))return o;if(0===(e=Math.min(e,o)))return e}return e}if("Polygon"===i.type||"MultiPolygon"===i.type){let e=1/0;for(let t=0;t<r.length;t++){const o=vr(r[t],!0,"Polygon"===i.type?[i.coordinates]:i.coordinates,n,e);if(isNaN(o))return o;if(0===(e=Math.min(e,o)))return e}return e}return null}(t,i,this.geometries);if("Polygon"===e.geometryType())return function(e,t,i){const r=[];for(const i of function(e){const t=e.length;if(t<=1)return[e];const i=[];let r,n;for(let o=0;o<t;o++){const t=vi(e[o]);0!==t&&(e[o].area=Math.abs(t),void 0===n&&(n=t<0),n===t<0?(r&&i.push(r),r=[e[o]]):r.push(e[o]))}return r&&i.push(r),i}(e)){const e=[];for(let r=0;r<i.length;++r)e.push(sr(i[r],t));r.push(e)}const n=new Gi(r[0][0][0][1],"meters");if("Point"===i.type||"MultiPoint"===i.type||"LineString"===i.type)return vr("Point"===i.type?[i.coordinates]:i.coordinates,"LineString"===i.type,r,n);if("MultiLineString"===i.type){let e=1/0;for(let t=0;t<i.coordinates.length;t++){const o=vr(i.coordinates[t],!0,r,n,e);if(isNaN(o))return o;if(0===(e=Math.min(e,o)))return e}return e}return"Polygon"===i.type||"MultiPolygon"===i.type?function(e,t,i){let r=1/0;for(const n of e)for(const e of t){const t=mr(n,e,i,r);if(isNaN(t))return t;if(0===(r=Math.min(r,t)))return r}return r}("Polygon"===i.type?[i.coordinates]:i.coordinates,r,n):null}(t,i,this.geometries);console.warn("Distance Expression: currently only evaluates valid Point/LineString/Polygon geometries.")}else console.warn("Distance Expression: requirs valid feature and canonical information.");return null}eachChild(){}outputDefined(){return!0}serialize(){return["distance",this.geojson]}}function Tr(e,t){switch(e){case"string":return ii(t);case"number":return+t;case"boolean":return!!t;case"color":return St.parse(t);case"formatted":return Yt.fromString(ii(t));case"resolvedImage":return Jt.build(ii(t))}return t}function Sr(e,t,i,r){return void 0!==r&&(e=r*Math.round(e/r)),void 0!==t&&e<t&&(e=t),void 0!==i&&e>i&&(e=i),e}class Mr{constructor(e,t,i){this.type=e,this.key=t,this.scope=i}static parse(e,t){let i=t.expectedType;if(null==i&&(i=Bt),e.length<2||e.length>3)return t.error("Invalid number of arguments for 'config' expression.");const r=t.parse(e[1],1);if(!(r instanceof ri))return t.error("Key name of 'config' expression must be a string literal.");if(e.length>=3){const n=t.parse(e[2],2);return n instanceof ri?new Mr(i,ii(r.value),ii(n.value)):t.error("Scope of 'config' expression must be a string literal.")}return new Mr(i,ii(r.value))}evaluate(e){const t=[this.key,this.scope,e.scope].filter(Boolean).join(""),i=e.getConfig(t);if(!i)return null;const{type:r,value:n,values:o,minValue:s,maxValue:a,stepValue:l}=i,c=i.default.evaluate(e);let h=c;if(n){const t=e.scope;e.scope=(t||"").split("").slice(1).join(""),h=n.evaluate(e),e.scope=t}return r&&(h=Tr(r,h)),void 0===h||void 0===s&&void 0===a&&void 0===l||("number"==typeof h?h=Sr(h,s,a,l):Array.isArray(h)&&(h=h.map((e=>"number"==typeof e?Sr(e,s,a,l):e)))),void 0!==n&&void 0!==h&&o&&!o.includes(h)&&(h=c,r&&(h=Tr(r,h))),(r&&r!==this.type||void 0!==h&&ti(h)!==this.type)&&(h=Tr(this.type.kind,h)),h}eachChild(){}outputDefined(){return!1}serialize(){const e=["config",this.key];return this.scope&&e.concat(this.key),e}}function Er(e){if(e instanceof fi){if("get"===e.name&&1===e.args.length)return!1;if("feature-state"===e.name)return!1;if("has"===e.name&&1===e.args.length)return!1;if("properties"===e.name||"geometry-type"===e.name||"id"===e.name)return!1;if(/^filter-/.test(e.name))return!1}if(e instanceof Bi)return!1;if(e instanceof wr)return!1;let t=!0;return e.eachChild((e=>{t&&!Er(e)&&(t=!1)})),t}function Ar(e){if(e instanceof fi&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild((e=>{t&&!Ar(e)&&(t=!1)})),t}function Ir(e){if(e instanceof Mr)return new Set([e.key]);let t=new Set;return e.eachChild((e=>{t=new Set([...t,...Ir(e)])})),t}function Cr(e,t){if(e instanceof fi&&t.indexOf(e.name)>=0)return!1;let i=!0;return e.eachChild((e=>{i&&!Cr(e,t)&&(i=!1)})),i}class Pr{constructor(e,t){this.type=t.type,this.name=e,this.boundExpression=t}static parse(e,t){if(2!==e.length||"string"!=typeof e[1])return t.error("'var' expression requires exactly one string literal argument.");const i=e[1];return t.scope.has(i)?new Pr(i,t.scope.get(i)):t.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class zr{constructor(e,t=[],i,r=new zt,n=[],o,s){this.registry=e,this.path=t,this.key=t.map((e=>"string"==typeof e?`['${e}']`:`[${e}]`)).join(""),this.scope=r,this.errors=n,this.expectedType=i,this._scope=o,this.options=s}parse(e,t,i,r,n={}){return t||i?this.concat(t,null,i,r)._parse(e,n):this._parse(e,n)}parseObjectValue(e,t,i,r,n,o={}){return this.concat(t,i,r,n)._parse(e,o)}_parse(e,t){function i(e,t,i){return"assert"===i?new si(t,[e]):"coerce"===i?new ui(t,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const r="string"==typeof e[0]?this.registry[e[0]]:void 0;if(r){let n=r.parse(e,this);if(!n)return null;if(this.expectedType){const e=this.expectedType,r=n.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==r.kind)if("color"!==e.kind&&"formatted"!==e.kind&&"resolvedImage"!==e.kind||"value"!==r.kind&&"string"!==r.kind){if(this.checkSubtype(e,r))return null}else n=i(n,e,t.typeAnnotation||"coerce");else n=i(n,e,t.typeAnnotation||"assert")}if(!(n instanceof ri)&&"resolvedImage"!==n.type.kind&&Rr(n)){const t=new pi(this._scope,this.options);try{n=new ri(n.type,n.evaluate(t))}catch(e){return this.error(e.message),null}}return n}return ui.parse(["to-array",e],this)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,t,i,r){let n="number"==typeof e?this.path.concat(e):this.path;n="string"==typeof t?n.concat(t):n;const o=r?this.scope.concat(r):this.scope;return new zr(this.registry,n,i||null,o,this.errors,this._scope,this.options)}error(e,...t){const i=`${this.key}${t.map((e=>`[${e}]`)).join("")}`;this.errors.push(new Pt(i,e))}checkSubtype(e,t){const i=Zt(e,t);return i&&this.error(i),i}}var Dr=zr;function Rr(e){if(e instanceof Pr)return Rr(e.boundExpression);if(e instanceof fi&&"error"===e.name)return!1;if(e instanceof _i)return!1;if(e instanceof Bi)return!1;if(e instanceof wr)return!1;if(e instanceof Mr)return!1;const t=e instanceof ui||e instanceof si;let i=!0;return e.eachChild((e=>{i=t?i&&Rr(e):i&&e instanceof ri})),!!i&&Er(e)&&Cr(e,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])}function Lr(e,t){const i=e.length-1;let r,n,o=0,s=i,a=0;for(;o<=s;)if(a=Math.floor((o+s)/2),r=e[a],n=e[a+1],r<=t){if(a===i||t<n)return a;o=a+1}else{if(!(r>t))throw new ni("Input is not a number.");s=a-1}return 0}class Or{constructor(e,t,i){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[e,t]of i)this.labels.push(e),this.outputs.push(t)}static parse(e,t){if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");const i=t.parse(e[1],1,Rt);if(!i)return null;const r=[];let n=null;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);for(let i=1;i<e.length;i+=2){const o=1===i?-1/0:e[i],s=e[i+1],a=i,l=i+1;if("number"!=typeof o)return t.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',a);if(r.length&&r[r.length-1][0]>=o)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=t.parse(s,l,n);if(!c)return null;n=n||c.type,r.push([o,c])}return new Or(n,i,r)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);const n=t.length;return r>=t[n-1]?i[n-1].evaluate(e):i[Lr(t,r)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}serialize(){const e=["step",this.input.serialize()];for(let t=0;t<this.labels.length;t++)t>0&&e.push(this.labels[t]),e.push(this.outputs[t].serialize());return e}}const kr=.95047,Fr=1.08883,Br=4/29,Nr=6/29,Vr=3*Nr*Nr,Ur=Nr*Nr*Nr,jr=Math.PI/180,Gr=180/Math.PI;function qr(e){return e>Ur?Math.pow(e,1/3):e/Vr+Br}function Zr(e){return e>Nr?e*e*e:Vr*(e-Br)}function $r(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function Hr(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Wr(e){const t=Hr(e.r),i=Hr(e.g),r=Hr(e.b),n=qr((.4124564*t+.3575761*i+.1804375*r)/kr),o=qr((.2126729*t+.7151522*i+.072175*r)/1);return{l:116*o-16,a:500*(n-o),b:200*(o-qr((.0193339*t+.119192*i+.9503041*r)/Fr)),alpha:e.a}}function Xr(e){let t=(e.l+16)/116,i=isNaN(e.a)?t:t+e.a/500,r=isNaN(e.b)?t:t-e.b/200;return t=1*Zr(t),i=kr*Zr(i),r=Fr*Zr(r),new St($r(3.2404542*i-1.5371385*t-.4985314*r),$r(-.969266*i+1.8760108*t+.041556*r),$r(.0556434*i-.2040259*t+1.0572252*r),e.alpha)}function Yr(e,t,i){const r=t-e;return e+i*(r>180||r<-180?r-360*Math.round(r/360):r)}const Kr={forward:Wr,reverse:Xr,interpolate:function(e,t,i){return{l:Et(e.l,t.l,i),a:Et(e.a,t.a,i),b:Et(e.b,t.b,i),alpha:Et(e.alpha,t.alpha,i)}}},Jr={forward:function(e){const{l:t,a:i,b:r}=Wr(e),n=Math.atan2(r,i)*Gr;return{h:n<0?n+360:n,c:Math.sqrt(i*i+r*r),l:t,alpha:e.a}},reverse:function(e){const t=e.h*jr,i=e.c;return Xr({l:e.l,a:Math.cos(t)*i,b:Math.sin(t)*i,alpha:e.alpha})},interpolate:function(e,t,i){return{h:Yr(e.h,t.h,i),c:Et(e.c,t.c,i),l:Et(e.l,t.l,i),alpha:Et(e.alpha,t.alpha,i)}}};var Qr=Object.freeze({__proto__:null,hcl:Jr,lab:Kr});class en{constructor(e,t,i,r,n,o){this.type=e,this.operator=t,this.interpolation=i,this.input=r,this.dynamicStops=n,this.labels=[],this.outputs=[];for(const[e,t]of o)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,i,r){let n=0;if("exponential"===e.name)n=tn(t,e.base,i,r);else if("linear"===e.name)n=tn(t,1,i,r);else if("cubic-bezier"===e.name){const o=e.controlPoints;n=new N(o[0],o[1],o[2],o[3]).solve(tn(t,1,i,r))}return n}static parse(e,t){let[i,r,n,...o]=e;if(!Array.isArray(r)||0===r.length)return t.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const e=r[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:e}}else{if("cubic-bezier"!==r[0])return t.error(`Unknown interpolation type ${String(r[0])}`,1,0);{const e=r.slice(1);if(4!==e.length||e.some((e=>"number"!=typeof e||e<0||e>1)))return t.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<3)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length-1>3&&(e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(n=t.parse(n,2,Rt),!n)return null;const s=[];let a=null;if("interpolate-hcl"===i||"interpolate-lab"===i?a=kt:t.expectedType&&"value"!==t.expectedType.kind&&(a=t.expectedType),e.length-1==3){const e=t.parse(o[0],3,Bt);return e?new en(a,i,r,n,e,s):null}for(let e=0;e<o.length;e+=2){const i=o[e],r=o[e+1],n=e+3,l=e+4;if("number"!=typeof i)return t.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',n);if(s.length&&s[s.length-1][0]>=i)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',n);const c=t.parse(r,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return"number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new en(a,i,r,n,null,s):t.error(`Type ${Gt(a)} is not interpolatable.`)}evaluate(e){let t=this.labels,i=this.outputs;if(this.dynamicStops){const r=this.dynamicStops.evaluate(e);if(r.length%2!=0)throw new ni("Expected an even number of arguments.");t=[],i=[];for(let e=0;e<r.length;e+=2){const n=r[e],o=new ri(Rt,r[e+1]);if("number"!=typeof n)throw new ni('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.');if(t.length&&t[t.length-1]>=n)throw new ni('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.');t.push(n),i.push(o)}if(0===t.length)throw new ni("Expected at least one input/output pair.")}if(1===t.length)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);const n=t.length;if(r>=t[n-1])return i[n-1].evaluate(e);const o=Lr(t,r),s=en.interpolationFactor(this.interpolation,r,t[o],t[o+1]),a=i[o].evaluate(e),l=i[o+1].evaluate(e);return"interpolate"===this.operator?It[this.type.kind.toLowerCase()](a,l,s):"interpolate-hcl"===this.operator?Jr.reverse(Jr.interpolate(Jr.forward(a),Jr.forward(l),s)):Kr.reverse(Kr.interpolate(Kr.forward(a),Kr.forward(l),s))}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}serialize(){let e;e="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const t=[this.operator,e,this.input.serialize()];if(this.dynamicStops)t.push(this.dynamicStops.serialize());else for(let e=0;e<this.labels.length;e++)t.push(this.labels[e],this.outputs[e].serialize());return t}}function tn(e,t,i,r){const n=r-i,o=e-i;return 0===n?0:1===t?o/n:(Math.pow(t,o)-1)/(Math.pow(t,n)-1)}class rn{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expectected at least one argument.");let i=null;const r=t.expectedType;r&&"value"!==r.kind&&(i=r);const n=[];for(const r of e.slice(1)){const e=t.parse(r,1+n.length,i,void 0,{typeAnnotation:"omit"});if(!e)return null;i=i||e.type,n.push(e)}const o=r&&n.some((e=>Zt(r,e.type)));return new rn(o?Bt:i,n)}evaluate(e){let t,i=null,r=0;for(const n of this.args){if(r++,i=n.evaluate(e),i&&i instanceof Jt&&!i.available&&(t||(t=i),i=null,r===this.args.length))return t;if(null!==i)break}return i}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}serialize(){const e=["coalesce"];return this.eachChild((t=>{e.push(t.serialize())})),e}}class nn{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const t of this.bindings)e(t[1]);e(this.result)}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const i=[];for(let r=1;r<e.length-1;r+=2){const n=e[r];if("string"!=typeof n)return t.error(`Expected string, but found ${typeof n} instead.`,r);if(/[^a-zA-Z0-9_]/.test(n))return t.error("Variable names must contain only alphanumeric characters or '_'.",r);const o=t.parse(e[r+1],r+1);if(!o)return null;i.push([n,o])}const r=t.parse(e[e.length-1],e.length-1,t.expectedType,i);return r?new nn(i,r):null}outputDefined(){return this.result.outputDefined()}serialize(){const e=["let"];for(const[t,i]of this.bindings)e.push(t,i.serialize());return e.push(this.result.serialize()),e}}class on{constructor(e,t,i){this.type=e,this.index=t,this.input=i}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Rt),r=t.parse(e[2],2,jt(t.expectedType||Bt));return i&&r?new on(r.type.itemType,i,r):null}evaluate(e){const t=this.index.evaluate(e),i=this.input.evaluate(e);if(t<0)throw new ni(`Array index out of bounds: ${t} < 0.`);if(t>i.length-1)throw new ni(`Array index out of bounds: ${t} > ${i.length-1}.`);if(t===Math.floor(t))return i[t];const r=Math.floor(t),n=Math.ceil(t),o=i[r],s=i[n];if("number"!=typeof o||"number"!=typeof s)throw new ni(`Cannot interpolate between non-number values at index ${t}.`);const a=t-r;return o*(1-a)+s*a}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class sn{constructor(e,t){this.type=Ot,this.needle=e,this.haystack=t}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Bt),r=t.parse(e[2],2,Bt);return i&&r?$t(i.type,[Ot,Lt,Rt,Dt,Bt])?new sn(i,r):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Gt(i.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(null==i)return!1;if(!Ht(t,["boolean","string","number","null"]))throw new ni(`Expected first argument to be of type boolean, string, number or null, but found ${Gt(ti(t))} instead.`);if(!Ht(i,["string","array"]))throw new ni(`Expected second argument to be of type array or string, but found ${Gt(ti(i))} instead.`);return i.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class an{constructor(e,t,i){this.type=Rt,this.needle=e,this.haystack=t,this.fromIndex=i}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Bt),r=t.parse(e[2],2,Bt);if(!i||!r)return null;if(!$t(i.type,[Ot,Lt,Rt,Dt,Bt]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Gt(i.type)} instead`);if(4===e.length){const n=t.parse(e[3],3,Rt);return n?new an(i,r,n):null}return new an(i,r)}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!Ht(t,["boolean","string","number","null"]))throw new ni(`Expected first argument to be of type boolean, string, number or null, but found ${Gt(ti(t))} instead.`);if(!Ht(i,["string","array"]))throw new ni(`Expected second argument to be of type array or string, but found ${Gt(ti(i))} instead.`);if(this.fromIndex){const r=this.fromIndex.evaluate(e);return i.indexOf(t,r)}return i.indexOf(t)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const e=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class ln{constructor(e,t,i,r,n,o){this.inputType=e,this.type=t,this.input=i,this.cases=r,this.outputs=n,this.otherwise=o}static parse(e,t){if(e.length<5)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return t.error("Expected an even number of arguments.");let i,r;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);const n={},o=[];for(let s=2;s<e.length-1;s+=2){let a=e[s];const l=e[s+1];Array.isArray(a)||(a=[a]);const c=t.concat(s);if(0===a.length)return c.error("Expected at least one branch label.");for(const e of a){if("number"!=typeof e&&"string"!=typeof e)return c.error("Branch labels must be numbers or strings.");if("number"==typeof e&&Math.abs(e)>Number.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,ti(e)))return null}else i=ti(e);if(void 0!==n[String(e)])return c.error("Branch labels must be unique.");n[String(e)]=o.length}const h=t.parse(l,s,r);if(!h)return null;r=r||h.type,o.push(h)}const s=t.parse(e[1],1,Bt);if(!s)return null;const a=t.parse(e[e.length-1],e.length-1,r);return a?"value"!==s.type.kind&&t.concat(1).checkSubtype(i,s.type)?null:new ln(i,r,s,n,o,a):null}evaluate(e){const t=this.input.evaluate(e);return(ti(t)===this.inputType&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const e=["match",this.input.serialize()],t=Object.keys(this.cases).sort(),i=[],r={};for(const e of t){const t=r[this.cases[e]];void 0===t?(r[this.cases[e]]=i.length,i.push([this.cases[e],[e]])):i[t][1].push(e)}const n=e=>"number"===this.inputType.kind?Number(e):e;for(const[t,r]of i)e.push(1===r.length?n(r[0]):r.map(n)),e.push(this.outputs[t].serialize());return e.push(this.otherwise.serialize()),e}}class cn{constructor(e,t,i){this.type=e,this.branches=t,this.otherwise=i}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return t.error("Expected an odd number of arguments.");let i;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);const r=[];for(let n=1;n<e.length-1;n+=2){const o=t.parse(e[n],n,Ot);if(!o)return null;const s=t.parse(e[n+1],n+1,i);if(!s)return null;r.push([o,s]),i=i||s.type}const n=t.parse(e[e.length-1],e.length-1,i);return n?new cn(i,r,n):null}evaluate(e){for(const[t,i]of this.branches)if(t.evaluate(e))return i.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[t,i]of this.branches)e(t),e(i);e(this.otherwise)}outputDefined(){return this.branches.every((([e,t])=>t.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild((t=>{e.push(t.serialize())})),e}}class hn{constructor(e,t,i,r){this.type=e,this.input=t,this.beginIndex=i,this.endIndex=r}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Bt),r=t.parse(e[2],2,Rt);if(!i||!r)return null;if(!$t(i.type,[jt(Bt),Lt,Bt]))return t.error(`Expected first argument to be of type array or string, but found ${Gt(i.type)} instead`);if(4===e.length){const n=t.parse(e[3],3,Rt);return n?new hn(i.type,i,r,n):null}return new hn(i.type,i,r)}evaluate(e){const t=this.input.evaluate(e),i=this.beginIndex.evaluate(e);if(!Ht(t,["string","array"]))throw new ni(`Expected first argument to be of type array or string, but found ${Gt(ti(t))} instead.`);if(this.endIndex){const r=this.endIndex.evaluate(e);return t.slice(i,r)}return t.slice(i)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const e=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}function un(e,t){return"=="===e||"!="===e?"boolean"===t.kind||"string"===t.kind||"number"===t.kind||"null"===t.kind||"value"===t.kind:"string"===t.kind||"number"===t.kind||"value"===t.kind}function dn(e,t,i,r){return 0===r.compare(t,i)}function pn(e,t,i){const r="=="!==e&&"!="!==e;return class n{constructor(e,t,i){this.type=Ot,this.lhs=e,this.rhs=t,this.collator=i,this.hasUntypedArgument="value"===e.type.kind||"value"===t.type.kind}static parse(e,t){if(3!==e.length&&4!==e.length)return t.error("Expected two or three arguments.");const i=e[0];let o=t.parse(e[1],1,Bt);if(!o)return null;if(!un(i,o.type))return t.concat(1).error(`"${i}" comparisons are not supported for type '${Gt(o.type)}'.`);let s=t.parse(e[2],2,Bt);if(!s)return null;if(!un(i,s.type))return t.concat(2).error(`"${i}" comparisons are not supported for type '${Gt(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error(`Cannot compare types '${Gt(o.type)}' and '${Gt(s.type)}'.`);r&&("value"===o.type.kind&&"value"!==s.type.kind?o=new si(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new si(o.type,[s])));let a=null;if(4===e.length){if("string"!==o.type.kind&&"string"!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error("Cannot use collator to compare non-string types.");if(a=t.parse(e[3],3,Nt),!a)return null}return new n(o,s,a)}evaluate(n){const o=this.lhs.evaluate(n),s=this.rhs.evaluate(n);if(r&&this.hasUntypedArgument){const t=ti(o),i=ti(s);if(t.kind!==i.kind||"string"!==t.kind&&"number"!==t.kind)throw new ni(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${i.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const e=ti(o),i=ti(s);if("string"!==e.kind||"string"!==i.kind)return t(n,o,s)}return this.collator?i(n,o,s,this.collator.evaluate(n)):t(n,o,s)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}serialize(){const t=[e];return this.eachChild((e=>{t.push(e.serialize())})),t}}}const fn=pn("==",(function(e,t,i){return t===i}),dn),mn=pn("!=",(function(e,t,i){return t!==i}),(function(e,t,i,r){return!dn(0,t,i,r)})),_n=pn("<",(function(e,t,i){return t<i}),(function(e,t,i,r){return r.compare(t,i)<0})),gn=pn(">",(function(e,t,i){return t>i}),(function(e,t,i,r){return r.compare(t,i)>0})),yn=pn("<=",(function(e,t,i){return t<=i}),(function(e,t,i,r){return r.compare(t,i)<=0})),xn=pn(">=",(function(e,t,i){return t>=i}),(function(e,t,i,r){return r.compare(t,i)>=0}));class vn{constructor(e,t,i,r,n,o){this.type=Lt,this.number=e,this.locale=t,this.currency=i,this.unit=r,this.minFractionDigits=n,this.maxFractionDigits=o}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,Rt);if(!i)return null;const r=e[2];if("object"!=typeof r||Array.isArray(r))return t.error("NumberFormat options argument must be an object.");let n=null;if(r.locale&&(n=t.parseObjectValue(r.locale,2,"locale",Lt),!n))return null;let o=null;if(r.currency&&(o=t.parseObjectValue(r.currency,2,"currency",Lt),!o))return null;let s=null;if(r.unit&&(s=t.parseObjectValue(r.unit,2,"unit",Lt),!s))return null;let a=null;if(r["min-fraction-digits"]&&(a=t.parseObjectValue(r["min-fraction-digits"],2,"min-fraction-digits",Rt),!a))return null;let l=null;return r["max-fraction-digits"]&&(l=t.parseObjectValue(r["max-fraction-digits"],2,"max-fraction-digits",Rt),!l)?null:new vn(i,n,o,s,a,l)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.unit&&(e.unit=this.unit.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}class bn{constructor(e){this.type=Rt,this.input=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=t.parse(e[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?t.error(`Expected argument of type string or array, but found ${Gt(i.type)} instead.`):new bn(i):null}evaluate(e){const t=this.input.evaluate(e);if("string"==typeof t)return t.length;if(Array.isArray(t))return t.length;throw new ni(`Expected value to be of type string or array, but found ${Gt(ti(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild((t=>{e.push(t.serialize())})),e}}function wn(e){return function(){e=1831565813+(e|=0)|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}const Tn={"==":fn,"!=":mn,">":gn,"<":_n,">=":xn,"<=":yn,array:si,at:on,boolean:si,case:cn,coalesce:rn,collator:_i,format:ai,image:li,in:sn,"index-of":an,interpolate:en,"interpolate-hcl":en,"interpolate-lab":en,length:bn,let:nn,literal:ri,match:ln,number:si,"number-format":vn,object:si,slice:hn,step:Or,string:si,"to-boolean":ui,"to-color":ui,"to-number":ui,"to-string":ui,var:Pr,within:Bi,distance:wr,config:Mr};function Sn(e,[t,i,r,n]){t=t.evaluate(e),i=i.evaluate(e),r=r.evaluate(e);const o=n?n.evaluate(e):1,s=Qt(t,i,r,o);if(s)throw new ni(s);return new St(t/255*o,i/255*o,r/255*o,o)}function Mn(e,[t,i,r,n]){t=t.evaluate(e),i=i.evaluate(e),r=r.evaluate(e);const o=n?n.evaluate(e):1,s=function(e,t,i,r){return"number"==typeof e&&e>=0&&e<=360?"number"==typeof t&&t>=0&&t<=100&&"number"==typeof i&&i>=0&&i<=100?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid hsla value [${[e,t,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${("number"==typeof r?[e,t,i,r]:[e,t,i]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${("number"==typeof r?[e,t,i,r]:[e,t,i]).join(", ")}]: 'h' must be between 0 and 360.`}(t,i,r,o);if(s)throw new ni(s);const a=`hsla(${t}, ${i}%, ${r}%, ${o})`,l=St.parse(a);if(!l)throw new ni(`Failed to parse HSLA color: ${a}`);return l}function En(e,t){return e in t}function An(e,t){const i=t[e];return void 0===i?null:i}function In(e){return{type:e}}function Cn(e){return{result:"success",value:e}}function Pn(e){return{result:"error",value:e}}function zn(e,t){return!!e&&!!e.parameters&&e.parameters.indexOf(t)>-1}function Dn(e){return"data-driven"===e["property-type"]}function Rn(e){return zn(e.expression,"measure-light")}function Ln(e){return zn(e.expression,"zoom")}function On(e){return!!e.expression&&e.expression.interpolated}function kn(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Fn(e){return e}function Bn(e,t){const i="color"===t.type,r=e.stops&&"object"==typeof e.stops[0][0],n=r||!(r||void 0!==e.property),o=e.type||(On(t)?"exponential":"interval");if(i&&((e=Ct({},e)).stops&&(e.stops=e.stops.map((e=>[e[0],St.parse(e[1])]))),e.default=St.parse(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==e.colorSpace&&!Qr[e.colorSpace])throw new Error(`Unknown color space: ${e.colorSpace}`);let s,a,l;if("exponential"===o)s=jn;else if("interval"===o)s=Un;else if("categorical"===o){s=Vn,a=Object.create(null);for(const t of e.stops)a[t[0]]=t[1];l=typeof e.stops[0][0]}else{if("identity"!==o)throw new Error(`Unknown function type "${o}"`);s=Gn}if(r){const i={},r=[];for(let t=0;t<e.stops.length;t++){const n=e.stops[t],o=n[0].zoom;void 0===i[o]&&(i[o]={zoom:o,type:e.type,property:e.property,default:e.default,stops:[]},r.push(o)),i[o].stops.push([n[0].value,n[1]])}const n=[];for(const e of r)n.push([i[e].zoom,Bn(i[e],t)]);const o={name:"linear"};return{kind:"composite",interpolationType:o,interpolationFactor:en.interpolationFactor.bind(void 0,o),zoomStops:n.map((e=>e[0])),evaluate:({zoom:i},r)=>jn({stops:n,base:e.base},t,i).evaluate(i,r)}}if(n){const i="exponential"===o?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:en.interpolationFactor.bind(void 0,i),zoomStops:e.stops.map((e=>e[0])),evaluate:({zoom:i})=>s(e,t,i,a,l)}}return{kind:"source",evaluate(i,r){const n=r&&r.properties?r.properties[e.property]:void 0;return void 0===n?Nn(e.default,t.default):s(e,t,n,a,l)}}}function Nn(e,t,i){return void 0!==e?e:void 0!==t?t:void 0!==i?i:void 0}function Vn(e,t,i,r,n){return Nn(typeof i===n?r[i]:void 0,e.default,t.default)}function Un(e,t,i){if("number"!==ci(i))return Nn(e.default,t.default);const r=e.stops.length;if(1===r)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[r-1][0])return e.stops[r-1][1];const n=Lr(e.stops.map((e=>e[0])),i);return e.stops[n][1]}function jn(e,t,i){const r=void 0!==e.base?e.base:1;if("number"!==ci(i))return Nn(e.default,t.default);const n=e.stops.length;if(1===n)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[n-1][0])return e.stops[n-1][1];const o=Lr(e.stops.map((e=>e[0])),i),s=function(e,t,i,r){const n=r-i,o=e-i;return 0===n?0:1===t?o/n:(Math.pow(t,o)-1)/(Math.pow(t,n)-1)}(i,r,e.stops[o][0],e.stops[o+1][0]),a=e.stops[o][1],l=e.stops[o+1][1];let c=It[t.type]||Fn;if(e.colorSpace&&"rgb"!==e.colorSpace){const t=Qr[e.colorSpace];c=(e,i)=>t.reverse(t.interpolate(t.forward(e),t.forward(i),s))}return"function"==typeof a.evaluate?{evaluate(...e){const t=a.evaluate.apply(void 0,e),i=l.evaluate.apply(void 0,e);if(void 0!==t&&void 0!==i)return c(t,i,s)}}:c(a,l,s)}function Gn(e,t,i){return"color"===t.type?i=St.parse(i):"formatted"===t.type?i=Yt.fromString(i.toString()):"resolvedImage"===t.type?i=Jt.build(i.toString()):ci(i)===t.type||"enum"===t.type&&t.values[i]||(i=void 0),Nn(i,e.default,t.default)}fi.register(Tn,{error:[{kind:"error"},[Lt],(e,[t])=>{throw new ni(t.evaluate(e))}],typeof:[Lt,[Bt],(e,[t])=>Gt(ti(t.evaluate(e)))],"to-rgba":[jt(Rt,4),[kt],(e,[t])=>t.evaluate(e).toRenderColor(null).toArray()],"to-hsla":[jt(Rt,4),[kt],(e,[t])=>t.evaluate(e).toRenderColor(null).toHslaArray()],rgb:[kt,[Rt,Rt,Rt],Sn],rgba:[kt,[Rt,Rt,Rt,Rt],Sn],hsl:[kt,[Rt,Rt,Rt],Mn],hsla:[kt,[Rt,Rt,Rt,Rt],Mn],has:{type:Ot,overloads:[[[Lt],(e,[t])=>En(t.evaluate(e),e.properties())],[[Lt,Ft],(e,[t,i])=>En(t.evaluate(e),i.evaluate(e))]]},get:{type:Bt,overloads:[[[Lt],(e,[t])=>An(t.evaluate(e),e.properties())],[[Lt,Ft],(e,[t,i])=>An(t.evaluate(e),i.evaluate(e))]]},"feature-state":[Bt,[Lt],(e,[t])=>An(t.evaluate(e),e.featureState||{})],properties:[Ft,[],e=>e.properties()],"geometry-type":[Lt,[],e=>e.geometryType()],id:[Bt,[],e=>e.id()],zoom:[Rt,[],e=>e.globals.zoom],pitch:[Rt,[],e=>e.globals.pitch||0],"distance-from-center":[Rt,[],e=>e.distanceFromCenter()],"measure-light":[Rt,[Lt],(e,[t])=>e.measureLight(t.evaluate(e))],"heatmap-density":[Rt,[],e=>e.globals.heatmapDensity||0],"line-progress":[Rt,[],e=>e.globals.lineProgress||0],"raster-value":[Rt,[],e=>e.globals.rasterValue||0],"raster-particle-speed":[Rt,[],e=>e.globals.rasterParticleSpeed||0],"sky-radial-progress":[Rt,[],e=>e.globals.skyRadialProgress||0],accumulated:[Bt,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[Rt,In(Rt),(e,t)=>{let i=0;for(const r of t)i+=r.evaluate(e);return i}],"*":[Rt,In(Rt),(e,t)=>{let i=1;for(const r of t)i*=r.evaluate(e);return i}],"-":{type:Rt,overloads:[[[Rt,Rt],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[Rt],(e,[t])=>-t.evaluate(e)]]},"/":[Rt,[Rt,Rt],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[Rt,[Rt,Rt],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[Rt,[],()=>Math.LN2],pi:[Rt,[],()=>Math.PI],e:[Rt,[],()=>Math.E],"^":[Rt,[Rt,Rt],(e,[t,i])=>Math.pow(t.evaluate(e),i.evaluate(e))],sqrt:[Rt,[Rt],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[Rt,[Rt],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[Rt,[Rt],(e,[t])=>Math.log(t.evaluate(e))],log2:[Rt,[Rt],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[Rt,[Rt],(e,[t])=>Math.sin(t.evaluate(e))],cos:[Rt,[Rt],(e,[t])=>Math.cos(t.evaluate(e))],tan:[Rt,[Rt],(e,[t])=>Math.tan(t.evaluate(e))],asin:[Rt,[Rt],(e,[t])=>Math.asin(t.evaluate(e))],acos:[Rt,[Rt],(e,[t])=>Math.acos(t.evaluate(e))],atan:[Rt,[Rt],(e,[t])=>Math.atan(t.evaluate(e))],min:[Rt,In(Rt),(e,t)=>Math.min(...t.map((t=>t.evaluate(e))))],max:[Rt,In(Rt),(e,t)=>Math.max(...t.map((t=>t.evaluate(e))))],abs:[Rt,[Rt],(e,[t])=>Math.abs(t.evaluate(e))],round:[Rt,[Rt],(e,[t])=>{const i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[Rt,[Rt],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[Rt,[Rt],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[Ot,[Lt,Bt],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[Ot,[Bt],(e,[t])=>e.id()===t.value],"filter-type-==":[Ot,[Lt],(e,[t])=>e.geometryType()===t.value],"filter-<":[Ot,[Lt,Bt],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r<n}],"filter-id-<":[Ot,[Bt],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i<r}],"filter->":[Ot,[Lt,Bt],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r>n}],"filter-id->":[Ot,[Bt],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i>r}],"filter-<=":[Ot,[Lt,Bt],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r<=n}],"filter-id-<=":[Ot,[Bt],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i<=r}],"filter->=":[Ot,[Lt,Bt],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r>=n}],"filter-id->=":[Ot,[Bt],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i>=r}],"filter-has":[Ot,[Bt],(e,[t])=>t.value in e.properties()],"filter-has-id":[Ot,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[Ot,[jt(Lt)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[Ot,[jt(Bt)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[Ot,[Lt,jt(Bt)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[Ot,[Lt,jt(Bt)],(e,[t,i])=>function(e,t,i,r){for(;i<=r;){const n=i+r>>1;if(t[n]===e)return!0;t[n]>e?r=n-1:i=n+1}return!1}(e.properties()[t.value],i.value,0,i.value.length-1)],all:{type:Ot,overloads:[[[Ot,Ot],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[In(Ot),(e,t)=>{for(const i of t)if(!i.evaluate(e))return!1;return!0}]]},any:{type:Ot,overloads:[[[Ot,Ot],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[In(Ot),(e,t)=>{for(const i of t)if(i.evaluate(e))return!0;return!1}]]},"!":[Ot,[Ot],(e,[t])=>!t.evaluate(e)],"is-supported-script":[Ot,[Lt],(e,[t])=>{const i=e.globals&&e.globals.isSupportedScript;return!i||i(t.evaluate(e))}],upcase:[Lt,[Lt],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[Lt,[Lt],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[Lt,In(Bt),(e,t)=>t.map((t=>ii(t.evaluate(e)))).join("")],"resolved-locale":[Lt,[Nt],(e,[t])=>t.evaluate(e).resolvedLocale()],random:[Rt,[Rt,Rt,Bt],(e,t)=>{const[i,r,n]=t.map((t=>t.evaluate(e)));if(i>r)return i;if(i===r)return i;let o;if("string"==typeof n)o=function(e){let t=0;if(0===e.length)return t;for(let i=0;i<e.length;i++)t=(t<<5)-t+e.charCodeAt(i),t|=0;return t}(n);else{if("number"!=typeof n)throw new ni(`Invalid seed input: ${n}`);o=n}return i+wn(o)()*(r-i)}]});class qn{constructor(e,t,i,r){this.expression=e,this._warningHistory={},this._evaluator=new pi(i,r),this._defaultValue=t?function(e){return"color"===e.type&&(kn(e.default)||Array.isArray(e.default))?new St(0,0,0,0):"color"===e.type?St.parse(e.default)||null:void 0===e.default?null:e.default}(t):null,this._enumValues=t&&"enum"===t.type?t.values:null,this.configDependencies=Ir(e)}evaluateWithoutErrorHandling(e,t,i,r,n,o,s,a){return this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=i,this._evaluator.canonical=r||null,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=a||null,this.expression.evaluate(this._evaluator)}evaluate(e,t,i,r,n,o,s,a){this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r||null,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o||null,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=a||null;try{const e=this.expression.evaluate(this._evaluator);if(null==e||"number"==typeof e&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new ni(`Expected value to be one of ${Object.keys(this._enumValues).map((e=>JSON.stringify(e))).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,"undefined"!=typeof console&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${e.message}`)),this._defaultValue}}}function Zn(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in Tn}function $n(e,t,i,r){const n=new Dr(Tn,[],t?function(e){const t={color:kt,string:Lt,number:Rt,enum:Lt,boolean:Ot,formatted:Vt,resolvedImage:Ut};return"array"===e.type?jt(t[e.value]||Bt,e.length):t[e.type]}(t):void 0,void 0,void 0,i,r),o=n.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return o?Cn(new qn(o,t,i,r)):Pn(n.errors)}class Hn{constructor(e,t,i,r){this.kind=e,this._styleExpression=t,this.isLightConstant=i,this.isLineProgressConstant=r,this.isStateDependent="constant"!==e&&!Ar(t.expression),this.configDependencies=Ir(t.expression)}evaluateWithoutErrorHandling(e,t,i,r,n,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,n,o)}evaluate(e,t,i,r,n,o){return this._styleExpression.evaluate(e,t,i,r,n,o)}}class Wn{constructor(e,t,i,r,n,o){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent="camera"!==e&&!Ar(t.expression),this.isLightConstant=n,this.isLineProgressConstant=o,this.configDependencies=Ir(t.expression),this.interpolationType=r}evaluateWithoutErrorHandling(e,t,i,r,n,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,n,o)}evaluate(e,t,i,r,n,o){return this._styleExpression.evaluate(e,t,i,r,n,o)}interpolationFactor(e,t,i){return this.interpolationType?en.interpolationFactor(this.interpolationType,e,t,i):0}}function Xn(e,t,i,r){if("error"===(e=$n(e,t,i,r)).result)return e;const n=e.value.expression,o=Er(n);if(!o&&!Dn(t))return Pn([new Pt("","data expressions not supported")]);const s=Cr(n,["zoom","pitch","distance-from-center"]);if(!s&&!Ln(t))return Pn([new Pt("","zoom expressions not supported")]);const a=Cr(n,["measure-light"]);if(!a&&!Rn(t))return Pn([new Pt("","measure-light expression not supported")]);const l=Cr(n,["line-progress"]);if(!l&&!function(e){return zn(e.expression,"line-progress")}(t))return Pn([new Pt("","line-progress expression not supported")]);const c=t.expression&&t.expression.relaxZoomRestriction,h=Kn(n);return h||s||c?h instanceof Pt?Pn([h]):h instanceof en&&!On(t)?Pn([new Pt("",'"interpolate" expressions cannot be used with this property')]):Cn(h?new Wn(o&&l?"camera":"composite",e.value,h.labels,h instanceof en?h.interpolation:void 0,a,l):new Hn(o&&l?"constant":"source",e.value,a,l)):Pn([new Pt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class Yn{constructor(e,t){this._parameters=e,this._specification=t,Ct(this,Bn(this._parameters,this._specification))}static deserialize(e){return new Yn(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function Kn(e){let t=null;if(e instanceof nn)t=Kn(e.result);else if(e instanceof rn){for(const i of e.args)if(t=Kn(i),t)break}else(e instanceof Or||e instanceof en)&&e.input instanceof fi&&"zoom"===e.input.name&&(t=e);return t instanceof Pt||e.eachChild((e=>{const i=Kn(e);i instanceof Pt?t=i:t&&i&&t!==i&&(t=new Pt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),t}var Jn,Qn,eo=function(){if(Qn)return Jn;Qn=1,Jn=t;var e=3;function t(t,i,r){var n=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var o=new Int32Array(this.arrayBuffer);t=o[0],this.d=(i=o[1])+2*(r=o[2]);for(var s=0;s<this.d*this.d;s++){var a=o[e+s],l=o[e+s+1];n.push(a===l?null:o.subarray(a,l))}var c=o[e+n.length+1];this.keys=o.subarray(o[e+n.length],c),this.bboxes=o.subarray(c),this.insert=this._insertReadonly}else{this.d=i+2*r;for(var h=0;h<this.d*this.d;h++)n.push([]);this.keys=[],this.bboxes=[]}this.n=i,this.extent=t,this.padding=r,this.scale=i/t,this.uid=0;var u=r/i*t;this.min=-u,this.max=t+u}return t.prototype.insert=function(e,t,i,r,n){this._forEachCell(t,i,r,n,this._insertCell,this.uid++),this.keys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)},t.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},t.prototype._insertCell=function(e,t,i,r,n,o){this.cells[n].push(o)},t.prototype.query=function(e,t,i,r,n){var o=this.min,s=this.max;if(e<=o&&t<=o&&s<=i&&s<=r&&!n)return Array.prototype.slice.call(this.keys);var a=[];return this._forEachCell(e,t,i,r,this._queryCell,a,{},n),a},t.prototype._queryCell=function(e,t,i,r,n,o,s,a){var l=this.cells[n];if(null!==l)for(var c=this.keys,h=this.bboxes,u=0;u<l.length;u++){var d=l[u];if(void 0===s[d]){var p=4*d;(a?a(h[p+0],h[p+1],h[p+2],h[p+3]):e<=h[p+2]&&t<=h[p+3]&&i>=h[p+0]&&r>=h[p+1])?(s[d]=!0,o.push(c[d])):s[d]=!1}}},t.prototype._forEachCell=function(e,t,i,r,n,o,s,a){for(var l=this._convertToCellCoord(e),c=this._convertToCellCoord(t),h=this._convertToCellCoord(i),u=this._convertToCellCoord(r),d=l;d<=h;d++)for(var p=c;p<=u;p++){var f=this.d*p+d;if((!a||a(this._convertFromCellCoord(d),this._convertFromCellCoord(p),this._convertFromCellCoord(d+1),this._convertFromCellCoord(p+1)))&&n.call(this,e,t,i,r,f,o,s,a))return}},t.prototype._convertFromCellCoord=function(e){return(e-this.padding)/this.scale},t.prototype._convertToCellCoord=function(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))},t.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,i=e+this.cells.length+1+1,r=0,n=0;n<this.cells.length;n++)r+=this.cells[n].length;var o=new Int32Array(i+r+this.keys.length+this.bboxes.length);o[0]=this.extent,o[1]=this.n,o[2]=this.padding;for(var s=i,a=0;a<t.length;a++){var l=t[a];o[e+a]=s,o.set(l,s),s+=l.length}return o[e+t.length]=s,o.set(this.keys,s),o[e+t.length+1]=s+=this.keys.length,o.set(this.bboxes,s),s+=this.bboxes.length,o.buffer},Jn}(),to=t(eo);const io={};function ro(e,t,i={}){Object.defineProperty(e,"_classRegistryKey",{value:t,writable:!1}),io[t]={klass:e,omit:i.omit||[]}}ro(Object,"Object"),to.serialize=function(e,t){const i=e.toArrayBuffer();return t&&t.add(i),{buffer:i}},to.deserialize=function(e){return new to(e.buffer)},Object.defineProperty(to,"name",{value:"Grid"}),ro(to,"Grid"),"undefined"!=typeof DOMMatrix&&ro(DOMMatrix,"DOMMatrix"),ro(St,"Color"),ro(Error,"Error"),ro(Yt,"Formatted"),ro(Xt,"FormattedSection"),ro(Qe,"AJAXError"),ro(Jt,"ResolvedImage"),ro(Yn,"StylePropertyFunction"),ro(qn,"StyleExpression",{omit:["_evaluator"]}),ro(Kt,"ImageIdWithOptions"),ro(Wn,"ZoomDependentExpression"),ro(Hn,"ZoomConstantExpression"),ro(fi,"CompoundExpression",{omit:["_evaluate"]});for(const e in Tn)io[Tn[e]._classRegistryKey]||ro(Tn[e],`Expression${e}`);function no(e){return e&&"undefined"!=typeof ArrayBuffer&&(e instanceof ArrayBuffer||e.constructor&&"ArrayBuffer"===e.constructor.name)}function oo(e){return self.ImageBitmap&&e instanceof ImageBitmap}function so(e,t){if(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp)return e;if(no(e)||oo(e))return t&&t.add(e),e;if(ArrayBuffer.isView(e))return t&&t.add(e.buffer),e;if(e instanceof ImageData)return t&&t.add(e.data.buffer),e;if(Array.isArray(e)){const i=[];for(const r of e)i.push(so(r,t));return i}if(e instanceof Map){const t={$name:"Map"};for(const[i,r]of e.entries())t[i]=so(r);return t}if(e instanceof Set){const t={$name:"Set"};let i=0;for(const r of e.values())t[++i]=so(r);return t}if("object"==typeof e){const i=e.constructor,r=i._classRegistryKey;if(!r)throw new Error(`Can't serialize object of unregistered class "${r}".`);const n=i.serialize?i.serialize(e,t):{};if(!i.serialize){for(const i in e)e.hasOwnProperty(i)&&(io[r].omit.indexOf(i)>=0||(n[i]=so(e[i],t)));e instanceof Error&&(n.message=e.message)}if(n.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==r&&(n.$name=r),n}throw new Error("can't serialize object of type "+typeof e)}function ao(e){if(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp||no(e)||oo(e)||ArrayBuffer.isView(e)||e instanceof ImageData)return e;if(Array.isArray(e))return e.map(ao);if("object"==typeof e){const t=e.$name||"Object";if("Map"===t){const t=new Map;for(const i of Object.keys(e))"$name"!==i&&t.set(i,ao(e[i]));return t}if("Set"===t){const t=new Set;for(const i of Object.keys(e))"$name"!==i&&t.add(ao(e[i]));return t}const{klass:i}=io[t];if(!i)throw new Error(`Can't deserialize unregistered class "${t}".`);if(i.deserialize)return i.deserialize(e);const r=Object.create(i.prototype);for(const t of Object.keys(e))"$name"!==t&&(r[t]=ao(e[t]));return r}throw new Error("can't deserialize object of type "+typeof e)}const lo=e=>e>=128&&e<=255,co=e=>e>=1536&&e<=1791,ho=e=>e>=1872&&e<=1919,uo=e=>e>=2208&&e<=2303,po=e=>e>=4352&&e<=4607,fo=e=>e>=5120&&e<=5759,mo=e=>e>=6016&&e<=6143,_o=e=>e>=6320&&e<=6399,go=e=>e>=8192&&e<=8303,yo=e=>e>=8448&&e<=8527,xo=e=>e>=8528&&e<=8591,vo=e=>e>=8960&&e<=9215,bo=e=>e>=9216&&e<=9279,wo=e=>e>=9280&&e<=9311,To=e=>e>=9312&&e<=9471,So=e=>e>=9632&&e<=9727,Mo=e=>e>=9728&&e<=9983,Eo=e=>e>=11008&&e<=11263,Ao=e=>e>=11904&&e<=12031,Io=e=>e>=12032&&e<=12255,Co=e=>e>=12272&&e<=12287,Po=e=>e>=12288&&e<=12351,zo=e=>e>=12352&&e<=12447,Do=e=>e>=12448&&e<=12543,Ro=e=>e>=12544&&e<=12591,Lo=e=>e>=12592&&e<=12687,Oo=e=>e>=12688&&e<=12703,ko=e=>e>=12704&&e<=12735,Fo=e=>e>=12736&&e<=12783,Bo=e=>e>=12784&&e<=12799,No=e=>e>=12800&&e<=13055,Vo=e=>e>=13056&&e<=13311,Uo=e=>e>=13312&&e<=19903,jo=e=>e>=19904&&e<=19967,Go=e=>e>=19968&&e<=40959,qo=e=>e>=40960&&e<=42127,Zo=e=>e>=42128&&e<=42191,$o=e=>e>=43360&&e<=43391,Ho=e=>e>=44032&&e<=55215,Wo=e=>e>=55216&&e<=55295,Xo=e=>e>=57344&&e<=63743,Yo=e=>e>=63744&&e<=64255,Ko=e=>e>=64336&&e<=65023,Jo=e=>e>=65040&&e<=65055,Qo=e=>e>=65072&&e<=65103,es=e=>e>=65104&&e<=65135,ts=e=>e>=65136&&e<=65279,is=e=>e>=65280&&e<=65519,rs=e=>e>=66736&&e<=66815,ns=e=>e>=131072&&e<=173791;function os(e){for(const t of e)if(ls(t.charCodeAt(0)))return!0;return!1}function ss(e){for(const t of e)if(!as(t.charCodeAt(0)))return!1;return!0}function as(e){return!(co(e)||ho(e)||uo(e)||Ko(e)||ts(e))}function ls(e){return!(746!==e&&747!==e&&(e<4352||!(ko(e)||Ro(e)||Qo(e)&&!(e>=65097&&e<=65103)||Yo(e)||Vo(e)||Ao(e)||Fo(e)||!(!Po(e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||Uo(e)||Go(e)||No(e)||Lo(e)||$o(e)||Wo(e)||po(e)||Ho(e)||zo(e)||Co(e)||Oo(e)||Io(e)||Bo(e)||Do(e)&&12540!==e||!(!is(e)||65288===e||65289===e||65293===e||e>=65306&&e<=65310||65339===e||65341===e||65343===e||e>=65371&&e<=65503||65507===e||e>=65512&&e<=65519)||!(!es(e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||fo(e)||_o(e)||Jo(e)||jo(e)||qo(e)||Zo(e))))}function cs(e){return!(ls(e)||function(e){return!!(lo(e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||go(e)&&(8214===e||8224===e||8225===e||8240===e||8241===e||8251===e||8252===e||8258===e||8263===e||8264===e||8265===e||8273===e)||yo(e)||xo(e)||vo(e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||9003===e||e>=9085&&e<=9114||e>=9150&&e<=9165||9167===e||e>=9169&&e<=9179||e>=9186&&e<=9215)||bo(e)&&9251!==e||wo(e)||To(e)||So(e)||Mo(e)&&!(e>=9754&&e<=9759)||Eo(e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||Po(e)||Do(e)||Xo(e)||Qo(e)||es(e)||is(e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e)}(e))}function hs(e){return e>=1424&&e<=2303||Ko(e)||ts(e)}function us(e,t){return!(!t&&hs(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||mo(e))}function ds(e){for(const t of e)if(hs(t.charCodeAt(0)))return!0;return!1}const ps="deferred",fs="loading",ms="loaded";let _s=null,gs="unavailable",ys=null;const xs=function(e){e&&"string"==typeof e&&e.indexOf("NetworkError")>-1&&(gs="error"),_s&&_s(e)};function vs(){bs.fire(new _t("pluginStateChange",{pluginStatus:gs,pluginURL:ys}))}const bs=new vt,ws=function(){return gs},Ts=function(){if(gs!==ps||!ys)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");gs=fs,vs(),ys&&it({url:ys},(e=>{e?xs(e):(gs=ms,vs())}))},Ss={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>gs===ms||null!=Ss.applyArabicShaping,isLoading:()=>gs===fs,setState(e){gs=e.pluginStatus,ys=e.pluginURL},isParsed:()=>null!=Ss.applyArabicShaping&&null!=Ss.processBidirectionalText&&null!=Ss.processStyledBidirectionalText,getPluginURL:()=>ys};class Ms{constructor(e,t){this.zoom=e,t?(this.now=t.now,this.fadeDuration=t.fadeDuration,this.transition=t.transition,this.pitch=t.pitch,this.brightness=t.brightness):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(e){return function(e,t){for(const i of e)if(!us(i.charCodeAt(0),t))return!1;return!0}(e,Ss.isLoaded())}}class Es{constructor(e,t,i,r){this.property=e,this.value=t,this.expression=function(e,t,i,r){if(kn(e))return new Yn(e,t);if(Zn(e)||Array.isArray(e)&&e.length>0){const n=Xn(e,t,i,r);if("error"===n.result)throw new Error(n.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return n.value}{let i=e;return"string"==typeof e&&"color"===t.type&&(i=St.parse(e)),{kind:"constant",configDependencies:new Set,evaluate:()=>i}}}(void 0===t?e.specification.default:t,e.specification,i,r)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(e,t,i){return this.property.possiblyEvaluate(this,e,t,i)}}class As{constructor(e,t,i){this.property=e,this.value=new Es(e,void 0,t,i)}transitioned(e,t){return new Cs(this.property,this.value,t,te({},e.transition,this.transition),e.now)}untransitioned(){return new Cs(this.property,this.value,null,{},0)}}class Is{constructor(e,t,i){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._scope=t,this._options=i,this.configDependencies=new Set}getValue(e){return ce(this._values[e].value.value)}setValue(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new As(this._values[e].property,this._scope,this._options)),this._values[e].value=new Es(this._values[e].property,null===t?void 0:ce(t),this._scope,this._options),this._values[e].value.expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[e].value.expression.configDependencies]))}setTransitionOrValue(e,t){t&&(this._options=t);const i=this._properties.properties;if(e)for(const t in e){const r=e[t];if(se(t,"-transition")){const e=t.slice(0,-11);i[e]&&this.setTransition(e,r)}else i.hasOwnProperty(t)&&this.setValue(t,r)}}getTransition(e){return ce(this._values[e].transition)}setTransition(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new As(this._values[e].property)),this._values[e].transition=ce(t)||void 0}serialize(){const e={};for(const t of Object.keys(this._values)){const i=this.getValue(t);void 0!==i&&(e[t]=i);const r=this.getTransition(t);void 0!==r&&(e[`${t}-transition`]=r)}return e}transitioned(e,t){const i=new Ps(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(e,t._values[r]);return i}untransitioned(){const e=new Ps(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class Cs{constructor(e,t,i,r,n){const o=r.delay||0,s=r.duration||0;n=n||0,this.property=e,this.value=t,this.begin=n+o,this.end=this.begin+s,e.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(e,t,i){const r=e.now||0,n=this.value.possiblyEvaluate(e,t,i),o=this.prior;if(o){if(r>this.end)return this.prior=null,n;if(this.value.isDataDriven())return this.prior=null,n;if(r<this.begin)return o.possiblyEvaluate(e,t,i);{const s=(r-this.begin)/(this.end-this.begin);return this.property.interpolate(o.possiblyEvaluate(e,t,i),n,W(s))}}return n}}class Ps{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,t,i){const r=new Rs(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(e,t,i);return r}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class zs{constructor(e,t,i){this._properties=e,this._values=Object.create(e.defaultPropertyValues),this._scope=t,this._options=i,this.configDependencies=new Set}getValue(e){return ce(this._values[e].value)}setValue(e,t){this._values[e]=new Es(this._values[e].property,null===t?void 0:ce(t),this._scope,this._options),this._values[e].expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[e].expression.configDependencies]))}serialize(){const e={};for(const t of Object.keys(this._values)){const i=this.getValue(t);void 0!==i&&(e[t]=i)}return e}possiblyEvaluate(e,t,i){const r=new Rs(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(e,t,i);return r}}class Ds{constructor(e,t,i){this.property=e,this.value=t,this.parameters=i}isConstant(){return"constant"===this.value.kind}constantOr(e){return"constant"===this.value.kind?this.value.value:e}evaluate(e,t,i,r){return this.property.evaluate(this.value,this.parameters,e,t,i,r)}}class Rs{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class Ls{constructor(e){this.specification=e}possiblyEvaluate(e,t){return e.expression.evaluate(t)}interpolate(e,t,i){const r=It[this.specification.type];return r?r(e,t,i):e}}class Os{constructor(e,t){this.specification=e,this.overrides=t}possiblyEvaluate(e,t,i,r){return new Ds(this,"constant"===e.expression.kind||"camera"===e.expression.kind?{kind:"constant",value:e.expression.evaluate(t,null,{},i,r)}:e.expression,t)}interpolate(e,t,i){if("constant"!==e.value.kind||"constant"!==t.value.kind)return e;if(void 0===e.value.value||void 0===t.value.value)return new Ds(this,{kind:"constant",value:void 0},e.parameters);const r=It[this.specification.type];return r?new Ds(this,{kind:"constant",value:r(e.value.value,t.value.value,i)},e.parameters):e}evaluate(e,t,i,r,n,o){return"constant"===e.kind?e.value:e.evaluate(t,i,r,n,o)}}class ks{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,r){return!!e.expression.evaluate(t,null,{},i,r)}interpolate(){return!1}}class Fs{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];const t=new Ms(0,{});for(const i in e){const r=e[i];r.specification.overridable&&this.overridableProperties.push(i);const n=this.defaultPropertyValues[i]=new Es(r,void 0),o=this.defaultTransitionablePropertyValues[i]=new As(r);this.defaultTransitioningPropertyValues[i]=o.untransitioned(),this.defaultPossiblyEvaluatedValues[i]=n.possiblyEvaluate(t)}}}ro(Os,"DataDrivenProperty"),ro(Ls,"DataConstantProperty"),ro(ks,"ColorRampProperty");var Bs=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"fragment":{"type":"boolean"},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360},"pitch":{"type":"number","default":0},"light":{"type":"light"},"lights":{"required":false,"type":"array","value":"light-3d"},"terrain":{"type":"terrain","optional":true},"fog":{"type":"fog"},"snow":{"type":"snow","experimental":true},"rain":{"type":"rain","experimental":true},"camera":{"type":"camera"},"color-theme":{"type":"colorTheme"},"indoor":{"type":"indoor","experimental":true},"imports":{"type":"array","value":"import"},"schema":{"type":"schema"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string","default":"mapbox://fonts/mapbox/{fontstack}/{range}.pbf"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"type":"array","value":"layer"},"models":{"type":"models"},"featuresets":{"experimental":true,"type":"featuresets"}},"featuresets":{"experimental":true,"*":{"type":"featureset"}},"featureset":{"experimental":true,"metadata":{"type":"*"},"selectors":{"type":"array","value":"selector"}},"selector":{"experimental":true,"layer":{"type":"string","required":true},"properties":{"type":"selectorProperty","required":false},"featureNamespace":{"type":"string","required":false}},"selectorProperty":{"experimental":true,"*":{"type":"*"}},"model":{"type":"string","required":true},"import":{"id":{"type":"string","required":true},"url":{"type":"string","required":true},"config":{"type":"config"},"data":{"type":"$root"},"color-theme":{"type":"colorTheme","optional":true}},"config":{"*":{"type":"*"}},"schema":{"*":{"type":"option"}},"option":{"default":{"type":"*","property-type":"data-constant","expression":{},"required":true},"type":{"type":"enum","values":{"string":1,"number":1,"boolean":1,"color":1}},"array":{"type":"boolean"},"minValue":{"type":"number"},"maxValue":{"type":"number"},"stepValue":{"type":"number"},"values":{"type":"array","value":"*"},"metadata":{"type":"*"}},"models":{"*":{"type":"model"}},"light-3d":{"id":{"type":"string","required":true},"properties":{"type":"properties"},"type":{"type":"enum","values":{"ambient":{},"directional":{},"flat":{}}}},"properties":["properties_light_directional","properties_light_ambient","properties_light_flat"],"properties_light_directional":{"direction":{"type":"array","default":[210,30],"minimum":[0,0],"maximum":[360,90],"length":2,"value":"number","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},"cast-shadows":{"type":"boolean","default":false,"property-type":"data-constant"},"shadow-quality":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1,"expression":{"parameters":["zoom"]},"experimental":true},"shadow-intensity":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"properties_light_ambient":{"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}},"properties_light_flat":{"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}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_raster_array","source_geojson","source_video","source_image","source_model"],"source_vector":{"type":{"required":true,"type":"enum","values":{"vector":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"scheme":{"type":"enum","values":{"xyz":1,"tms":1},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"type":"enum","values":{"raster":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"scheme":{"type":"enum","values":{"xyz":1,"tms":1},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":1,"mapbox":1},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_array":{"experimental":true,"type":{"required":true,"type":"enum","values":{"raster-array":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"attribution":{"type":"string"},"rasterLayers":{"type":"*"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":1}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"minzoom":{"type":"number","default":0},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"},"dynamic":{"type":"boolean","default":false}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":1}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":1}},"url":{"required":false,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_model":{"type":{"required":true,"type":"enum","values":{"model":1,"batched-model":1}},"maxzoom":{"type":"number","default":18},"minzoom":{"type":"number","default":0},"tiles":{"type":"array","value":"string"}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"raster-particle":{"experimental":true},"hillshade":{},"model":{"experimental":true},"background":{},"sky":{},"slot":{},"clip":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"slot":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"}},"layout":["layout_clip","layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_raster-particle","layout_hillshade","layout_background","layout_sky","layout_model"],"layout_background":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_model":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"},"model-id":{"type":"string","default":"","property-type":"data-driven","expression":{"parameters":["zoom","feature"]}}},"layout_clip":{"clip-layer-types":{"type":"array","value":"enum","values":{"model":1,"symbol":1},"default":[],"expression":{},"property-type":"data-constant"},"clip-layer-scope":{"type":"array","value":"string","default":[],"expression":{},"property-type":"data-constant"}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"},"fill-elevation-reference":{"type":"enum","values":{"none":1,"hd-road-base":1,"hd-road-markup":1},"default":"none","experimental":true,"private":true,"expression":{},"property-type":"data-constant"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"},"fill-extrusion-edge-radius":{"type":"number","experimental":true,"default":0,"minimum":0,"maximum":1,"expression":{},"property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":1,"round":1,"square":1},"default":"butt","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":1,"round":1,"miter":1,"none":1},"default":"miter","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-z-offset":{"type":"number","experimental":true,"default":0,"expression":{"parameters":["zoom","feature","line-progress"]},"property-type":"data-driven"},"line-elevation-reference":{"type":"enum","values":{"none":1,"sea":1,"ground":1,"hd-road-markup":1},"default":"none","experimental":true,"expression":{},"property-type":"data-constant"},"line-cross-slope":{"type":"number","experimental":true,"expression":{},"property-type":"constant"},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"},"line-width-unit":{"type":"enum","values":{"pixels":1,"meters":1},"default":"pixels","experimental":true,"private":true,"expression":{"parameters":["zoom"]},"property-type":"data-constant"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":1,"line":1,"line-center":1},"default":"point","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":1,"viewport-y":1,"source":1},"default":"auto","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"symbol-z-elevate":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"symbol-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1,"hd-road-markup":1},"default":"ground","experimental":true,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-size":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-size-scale-range":{"type":"array","value":"number","length":2,"default":[0.8,2],"minimum":0.1,"maximum":10,"experimental":true,"private":true,"expression":{},"property-type":"data-constant"},"icon-text-fit":{"type":"enum","values":{"none":1,"width":1,"height":1,"both":1},"default":"none","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size-scale-range":{"type":"array","value":"number","length":2,"default":[0.8,2],"minimum":0.1,"maximum":10,"experimental":true,"private":true,"expression":{},"property-type":"data-constant"},"text-max-width":{"type":"number","default":10,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":1,"left":1,"center":1,"right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","default":0,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":1,"vertical":1},"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":1,"uppercase":1,"lowercase":1},"default":"none","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","length":2,"default":[0,0],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_raster-particle":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_hillshade":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_raster":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_raster-particle":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_clip":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_model":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":1,"!=":1,">":1,">=":1,"<":1,"<=":1,"in":1,"!in":1,"all":1,"any":1,"none":1,"has":1,"!has":1}},"geometry_type":{"type":"enum","values":{"Point":1,"LineString":1,"Polygon":1}},"function":{"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}}},"snow":{"density":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],11,0,13,0.85],"minimum":0,"maximum":1,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"opacity":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],11,0,13,0.3],"minimum":0,"maximum":1,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette-color":{"type":"color","property-type":"data-constant","default":"#ffffff","experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"center-thinning":{"type":"number","property-type":"data-constant","default":0.4,"minimum":0,"maximum":1,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,50],"minimum":0,"maximum":360,"length":2,"value":"number","property-type":"data-constant","transition":true,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"flake-size":{"type":"number","property-type":"data-constant","default":0.71,"minimum":0,"maximum":5,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true}},"rain":{"density":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],11,0,13,0.5],"minimum":0,"maximum":1,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","property-type":"data-constant","default":["interpolate",["linear"],["measure-light","brightness"],0,"#03113d",0.3,"#a8adbc"],"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"opacity":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["measure-light","brightness"],0,0.88,1,0.7],"minimum":0,"maximum":1,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],11,0,13,1],"minimum":0,"maximum":1,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette-color":{"type":"color","property-type":"data-constant","default":["interpolate",["linear"],["measure-light","brightness"],0,"#001736",0.3,"#464646"],"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"center-thinning":{"type":"number","property-type":"data-constant","default":0.57,"minimum":0,"maximum":1,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,80],"minimum":0,"maximum":360,"length":2,"value":"number","property-type":"data-constant","transition":true,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"droplet-size":{"type":"array","default":[2.6,18.2],"minimum":0,"maximum":50,"length":2,"value":"number","property-type":"data-constant","transition":true,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"distortion-strength":{"type":"number","property-type":"data-constant","default":0.7,"minimum":0,"maximum":1,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true}},"camera":{"camera-projection":{"type":"enum","values":{"perspective":1,"orthographic":1},"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"default":"perspective","property-type":"data-constant"}},"colorTheme":{"data":{"type":"string","property-type":"data-constant","expression":{}}},"indoor":{"floorplanFeaturesetId":{"type":"string","experimental":true,"property-type":"data-constant","expression":{}},"buildingFeaturesetId":{"type":"string","experimental":true,"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-height-alignment":{"type":"enum","experimental":true,"values":{"terrain":1,"flat":1},"default":"flat","property-type":"data-constant"},"fill-extrusion-base-alignment":{"type":"enum","experimental":true,"values":{"terrain":1,"flat":1},"default":"terrain","property-type":"data-constant"},"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","line-progress"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-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"}},"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":[]},"experimental":true,"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":["feature","feature-state","zoom"]},"property-type":"data-driven"},"model-rotation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-scale":{"type":"array","value":"number","length":3,"default":[1,1,1],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-translation":{"type":"array","value":"number","length":3,"default":[0,0,0],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-color":{"type":"color","default":"#ffffff","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light","zoom"]},"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 Ns(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function Vs(e){if(Array.isArray(e))return e.map(Vs);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const t={};for(const i in e)t[i]=Vs(e[i]);return t}return Ns(e)}function Us(e){if(!0===e||!1===e)return!0;if(!Array.isArray(e)||0===e.length)return!1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(const t of e.slice(1))if(!Us(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}function js(e,t="",i=null,r="fill"){if(null==e)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Us(e)||(e=Xs(e));const n=e;let o=!0;try{o=function(e){if(!Zs(e))return e;let t=Vs(e);return qs(t),t=Gs(t),t}(n)}catch(e){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(n,null,2)}\n `)}let s=null,a=null;if("background"!==r&&"sky"!==r&&"slot"!==r){a=Bs[`filter_${r}`];const e=$n(o,a,t,i);if("error"===e.result)throw new Error(e.value.map((e=>`${e.key}: ${e.message}`)).join(", "));s=(t,i,r)=>e.value.evaluate(t,i,{},r)}let l=null,c=null;if(o!==n){const e=$n(n,a,t,i);if("error"===e.result)throw new Error(e.value.map((e=>`${e.key}: ${e.message}`)).join(", "));l=(t,i,r,n,o)=>e.value.evaluate(t,i,{},r,void 0,void 0,n,o),c=!Er(e.value.expression)}return{filter:s,dynamicFilter:l||void 0,needGeometry:Ws(o),needFeature:!!c}}function Gs(e){if(!Array.isArray(e))return e;const t=function(e){if($s.has(e[0]))for(let t=1;t<e.length;t++)if(Zs(e[t]))return!0;return e}(e);return!0===t?t:t.map((e=>Gs(e)))}function qs(e){let t=!1;const i=[];if("case"===e[0]){for(let r=1;r<e.length-1;r+=2)t=t||Zs(e[r]),i.push(e[r+1]);i.push(e[e.length-1])}else if("match"===e[0]){t=t||Zs(e[1]);for(let t=2;t<e.length-1;t+=2)i.push(e[t+1]);i.push(e[e.length-1])}else if("step"===e[0]){t=t||Zs(e[1]);for(let t=1;t<e.length-1;t+=2)i.push(e[t+1])}t&&(e.length=0,e.push("any",...i));for(let t=1;t<e.length;t++)qs(e[t])}function Zs(e){if(!Array.isArray(e))return!1;if("pitch"===(t=e[0])||"distance-from-center"===t)return!0;var t;for(let t=1;t<e.length;t++)if(Zs(e[t]))return!0;return!1}const $s=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function Hs(e,t){return e<t?-1:e>t?1:0}function Ws(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(let t=1;t<e.length;t++)if(Ws(e[t]))return!0;return!1}function Xs(e){if(!e)return!0;const t=e[0];return e.length<=1?"any"!==t:"=="===t?Ys(e[1],e[2],"=="):"!="===t?Qs(Ys(e[1],e[2],"==")):"<"===t||">"===t||"<="===t||">="===t?Ys(e[1],e[2],t):"any"===t?(i=e.slice(1),["any"].concat(i.map(Xs))):"all"===t?["all"].concat(e.slice(1).map(Xs)):"none"===t?["all"].concat(e.slice(1).map(Xs).map(Qs)):"in"===t?Ks(e[1],e.slice(2)):"!in"===t?Qs(Ks(e[1],e.slice(2))):"has"===t?Js(e[1]):"!has"!==t||Qs(Js(e[1]));var i}function Ys(e,t,i){switch(e){case"$type":return[`filter-type-${i}`,t];case"$id":return[`filter-id-${i}`,t];default:return[`filter-${i}`,e,t]}}function Ks(e,t){if(0===t.length)return!1;switch(e){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some((e=>typeof e!=typeof t[0]))?["filter-in-large",e,["literal",t.sort(Hs)]]:["filter-in-small",e,["literal",t]]}}function Js(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function Qs(e){return["!",e]}const ea="";function ta(e,t){return t?`${e}${ea}${t}`:e}const ia="-transition",ra=new Set(["fill","line","background","hillshade","raster"]);class na extends vt{constructor(e,t,i,r,n){if(super(),this.id=e.id,this.fqid=ta(this.id,i),this.type=e.type,this.scope=i,this.lut=r,this.options=n,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.configDependencies=new Set,"custom"!==e.type){if(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type&&"background"!==e.type&&"sky"!==e.type&&"slot"!==e.type){this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter;const t=$n(this.filter,Bs[`filter_${e.type}`]);"error"!==t.result&&(this.configDependencies=new Set([...this.configDependencies,...t.value.configDependencies]))}if(e.slot&&(this.slot=e.slot),t.layout&&(this._unevaluatedLayout=new zs(t.layout,this.scope,n),this.configDependencies=new Set([...this.configDependencies,...this._unevaluatedLayout.configDependencies])),t.paint){this._transitionablePaint=new Is(t.paint,this.scope,n);for(const t in e.paint)this.setPaintProperty(t,e.paint[t]);for(const t in e.layout)this.setLayoutProperty(t,e.layout[t]);this.configDependencies=new Set([...this.configDependencies,...this._transitionablePaint.configDependencies]),this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Rs(t.paint)}}}onAdd(e){}onRemove(e){}isDraped(e){return!this.is3D()&&ra.has(this.type)}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,t){if("custom"===this.type&&"visibility"===e)return void(this.visibility=t);const i=this._unevaluatedLayout;i._properties.properties[e]&&(i.setValue(e,t),this.configDependencies=new Set([...this.configDependencies,...i.configDependencies]),"visibility"===e&&this.possiblyEvaluateVisibility())}possiblyEvaluateVisibility(){this._unevaluatedLayout._values.visibility&&(this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0}))}getPaintProperty(e){return se(e,ia)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,t){const i=this._transitionablePaint,r=i._properties.properties;if(se(e,ia)){const n=e.slice(0,-11);return r[n]&&i.setTransition(n,t||void 0),!1}if(!r[e])return!1;const n=i._values[e],o=n.value.isDataDriven(),s=n.value;i.setValue(e,t),this.configDependencies=new Set([...this.configDependencies,...i.configDependencies]),this._handleSpecialPaintPropertyUpdate(e);const a=i._values[e].value,l=a.isDataDriven(),c=se(e,"pattern")||"line-dasharray"===e;return l||o||c||this._handleOverridablePaintPropertyUpdate(e,s,a)}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getDefaultProgramParams(e,t,i){return null}_handleOverridablePaintPropertyUpdate(e,t,i){return!1}isHidden(e){return!!(this.minzoom&&e<this.minzoom)||!!(this.maxzoom&&e>=this.maxzoom)||"none"===this.visibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,t){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){return le({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()},((e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).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 e in this.paint._values){const t=this.paint.get(e);if(t instanceof Ds&&Dn(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}compileFilter(e){this._filterCompiled||(this._featureFilter=js(this.filter,this.scope,e),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(e){this._stats&&("shadow"===e.renderPass?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}queryRadius(e){}queryIntersectsFeature(e,t,i,r,n,o,s,a,l){}}const oa={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class sa{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class aa{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,t){return e._trim(),t&&(e.isTransferred=!0,t.add(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const t=Object.create(this.prototype);return t.arrayBuffer=e.arrayBuffer,t.length=e.length,t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement,t._refreshViews(),t}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...e){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...e){throw new Error("StructArray#emplaceBack() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function la(e,t=1){let i=0,r=0;return{members:e.map((e=>{const n=oa[e.type].BYTES_PER_ELEMENT,o=i=ca(i,Math.max(t,n)),s=e.components||1;return r=Math.max(r,n),i+=n*s,{name:e.name,type:e.type,components:s,offset:o}})),size:ca(i,Math.max(r,t)),alignment:t}}function ca(e,t){return Math.ceil(e/t)*t}class ha extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.int16[r+0]=t,this.int16[r+1]=i,e}}ha.prototype.bytesPerElement=4,ro(ha,"StructArrayLayout2i4");class ua extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.int16[n+0]=t,this.int16[n+1]=i,this.int16[n+2]=r,e}}ua.prototype.bytesPerElement=6,ro(ua,"StructArrayLayout3i6");class da extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.int16[o+0]=t,this.int16[o+1]=i,this.int16[o+2]=r,this.int16[o+3]=n,e}}da.prototype.bytesPerElement=8,ro(da,"StructArrayLayout4i8");class pa extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=5*e;return this.int16[s+0]=t,this.int16[s+1]=i,this.int16[s+2]=r,this.int16[s+3]=n,this.int16[s+4]=o,e}}pa.prototype.bytesPerElement=10,ro(pa,"StructArrayLayout5i10");class fa extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=6*e,c=12*e,h=3*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.uint8[c+4]=r,this.uint8[c+5]=n,this.uint8[c+6]=o,this.uint8[c+7]=s,this.float32[h+2]=a,e}}fa.prototype.bytesPerElement=12,ro(fa,"StructArrayLayout2i4ub1f12");class ma extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.float32[o+0]=t,this.float32[o+1]=i,this.float32[o+2]=r,this.float32[o+3]=n,e}}ma.prototype.bytesPerElement=16,ro(ma,"StructArrayLayout4f16");class _a extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.float32[n+0]=t,this.float32[n+1]=i,this.float32[n+2]=r,e}}_a.prototype.bytesPerElement=12,ro(_a,"StructArrayLayout3f12");class ga extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=6*e,a=3*e;return this.uint16[s+0]=t,this.uint16[s+1]=i,this.uint16[s+2]=r,this.uint16[s+3]=n,this.float32[a+2]=o,e}}ga.prototype.bytesPerElement=12,ro(ga,"StructArrayLayout4ui1f12");class ya extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.uint16[o+0]=t,this.uint16[o+1]=i,this.uint16[o+2]=r,this.uint16[o+3]=n,e}}ya.prototype.bytesPerElement=8,ro(ya,"StructArrayLayout4ui8");class xa extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,s){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=r,this.int16[a+3]=n,this.int16[a+4]=o,this.int16[a+5]=s,e}}xa.prototype.bytesPerElement=12,ro(xa,"StructArrayLayout6i12");class va extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,h,u){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,i,r,n,o,s,a,l,c,h,u)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,d){const p=12*e;return this.int16[p+0]=t,this.int16[p+1]=i,this.int16[p+2]=r,this.int16[p+3]=n,this.uint16[p+4]=o,this.uint16[p+5]=s,this.uint16[p+6]=a,this.uint16[p+7]=l,this.int16[p+8]=c,this.int16[p+9]=h,this.int16[p+10]=u,this.int16[p+11]=d,e}}va.prototype.bytesPerElement=24,ro(va,"StructArrayLayout4i4ui4i24");class ba extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,s){const a=10*e,l=5*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=r,this.float32[l+2]=n,this.float32[l+3]=o,this.float32[l+4]=s,e}}ba.prototype.bytesPerElement=20,ro(ba,"StructArrayLayout3i3f20");class wa extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint32[1*e+0]=t,e}}wa.prototype.bytesPerElement=4,ro(wa,"StructArrayLayout1ul4");class Ta extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.uint16[r+0]=t,this.uint16[r+1]=i,e}}Ta.prototype.bytesPerElement=4,ro(Ta,"StructArrayLayout2ui4");class Sa extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,h,u,d){const p=this.length;return this.resize(p+1),this.emplace(p,e,t,i,r,n,o,s,a,l,c,h,u,d)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,d,p){const f=20*e,m=10*e;return this.int16[f+0]=t,this.int16[f+1]=i,this.int16[f+2]=r,this.int16[f+3]=n,this.int16[f+4]=o,this.float32[m+3]=s,this.float32[m+4]=a,this.float32[m+5]=l,this.float32[m+6]=c,this.int16[f+14]=h,this.uint32[m+8]=u,this.uint16[f+18]=d,this.uint16[f+19]=p,e}}Sa.prototype.bytesPerElement=40,ro(Sa,"StructArrayLayout5i4f1i1ul2ui40");class Ma extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=8*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.int16[l+2]=r,this.int16[l+4]=n,this.int16[l+5]=o,this.int16[l+6]=s,this.int16[l+7]=a,e}}Ma.prototype.bytesPerElement=16,ro(Ma,"StructArrayLayout3i2i2i16");class Ea extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=4*e,a=8*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=r,this.int16[a+6]=n,this.int16[a+7]=o,e}}Ea.prototype.bytesPerElement=16,ro(Ea,"StructArrayLayout2f1f2i16");class Aa extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,s){const a=20*e,l=5*e;return this.uint8[a+0]=t,this.uint8[a+1]=i,this.float32[l+1]=r,this.float32[l+2]=n,this.float32[l+3]=o,this.float32[l+4]=s,e}}Aa.prototype.bytesPerElement=20,ro(Aa,"StructArrayLayout2ub4f20");class Ia extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.uint16[n+0]=t,this.uint16[n+1]=i,this.uint16[n+2]=r,e}}Ia.prototype.bytesPerElement=6,ro(Ia,"StructArrayLayout3ui6");class Ca extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v){const b=this.length;return this.resize(b+1),this.emplace(b,e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b){const w=30*e,T=15*e,S=60*e;return this.int16[w+0]=t,this.int16[w+1]=i,this.int16[w+2]=r,this.float32[T+2]=n,this.float32[T+3]=o,this.uint16[w+8]=s,this.uint16[w+9]=a,this.uint32[T+5]=l,this.uint32[T+6]=c,this.uint32[T+7]=h,this.uint16[w+16]=u,this.uint16[w+17]=d,this.uint16[w+18]=p,this.float32[T+10]=f,this.float32[T+11]=m,this.uint8[S+48]=_,this.uint8[S+49]=g,this.uint8[S+50]=y,this.uint32[T+13]=x,this.int16[w+28]=v,this.uint8[S+58]=b,e}}Ca.prototype.bytesPerElement=60,ro(Ca,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Pa extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,S,M,E,A,I,C,P,z){const D=this.length;return this.resize(D+1),this.emplace(D,e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,S,M,E,A,I,C,P,z)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,S,M,E,A,I,C,P,z,D){const R=20*e,L=40*e,O=80*e;return this.float32[R+0]=t,this.float32[R+1]=i,this.int16[L+4]=r,this.int16[L+5]=n,this.int16[L+6]=o,this.int16[L+7]=s,this.int16[L+8]=a,this.int16[L+9]=l,this.int16[L+10]=c,this.int16[L+11]=h,this.int16[L+12]=u,this.uint16[L+13]=d,this.uint16[L+14]=p,this.uint16[L+15]=f,this.uint16[L+16]=m,this.uint16[L+17]=_,this.uint16[L+18]=g,this.uint16[L+19]=y,this.uint16[L+20]=x,this.uint16[L+21]=v,this.uint16[L+22]=b,this.uint16[L+23]=w,this.uint16[L+24]=T,this.uint16[L+25]=S,this.uint16[L+26]=M,this.uint16[L+27]=E,this.uint32[R+14]=A,this.float32[R+15]=I,this.float32[R+16]=C,this.float32[R+17]=P,this.float32[R+18]=z,this.uint8[O+76]=D,e}}Pa.prototype.bytesPerElement=80,ro(Pa,"StructArrayLayout2f9i15ui1ul4f1ub80");class za extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.float32[1*e+0]=t,e}}za.prototype.bytesPerElement=4,ro(za,"StructArrayLayout1f4");class Da extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=5*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=r,this.float32[s+3]=n,this.float32[s+4]=o,e}}Da.prototype.bytesPerElement=20,ro(Da,"StructArrayLayout5f20");class Ra extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=7*e;return this.float32[l+0]=t,this.float32[l+1]=i,this.float32[l+2]=r,this.float32[l+3]=n,this.float32[l+4]=o,this.float32[l+5]=s,this.float32[l+6]=a,e}}Ra.prototype.bytesPerElement=28,ro(Ra,"StructArrayLayout7f28");class La extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,h){const u=this.length;return this.resize(u+1),this.emplace(u,e,t,i,r,n,o,s,a,l,c,h)}emplace(e,t,i,r,n,o,s,a,l,c,h,u){const d=11*e;return this.float32[d+0]=t,this.float32[d+1]=i,this.float32[d+2]=r,this.float32[d+3]=n,this.float32[d+4]=o,this.float32[d+5]=s,this.float32[d+6]=a,this.float32[d+7]=l,this.float32[d+8]=c,this.float32[d+9]=h,this.float32[d+10]=u,e}}La.prototype.bytesPerElement=44,ro(La,"StructArrayLayout11f44");class Oa extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,t,i,r,n,o,s,a,l)}emplace(e,t,i,r,n,o,s,a,l,c){const h=9*e;return this.float32[h+0]=t,this.float32[h+1]=i,this.float32[h+2]=r,this.float32[h+3]=n,this.float32[h+4]=o,this.float32[h+5]=s,this.float32[h+6]=a,this.float32[h+7]=l,this.float32[h+8]=c,e}}Oa.prototype.bytesPerElement=36,ro(Oa,"StructArrayLayout9f36");class ka extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.float32[r+0]=t,this.float32[r+1]=i,e}}ka.prototype.bytesPerElement=8,ro(ka,"StructArrayLayout2f8");class Fa extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=6*e;return this.uint32[3*e+0]=t,this.uint16[o+2]=i,this.uint16[o+3]=r,this.uint16[o+4]=n,e}}Fa.prototype.bytesPerElement=12,ro(Fa,"StructArrayLayout1ul3ui12");class Ba extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint16[1*e+0]=t,e}}Ba.prototype.bytesPerElement=2,ro(Ba,"StructArrayLayout1ui2");class Na extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=this.length;return this.resize(_+1),this.emplace(_,e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_){const g=16*e;return this.float32[g+0]=t,this.float32[g+1]=i,this.float32[g+2]=r,this.float32[g+3]=n,this.float32[g+4]=o,this.float32[g+5]=s,this.float32[g+6]=a,this.float32[g+7]=l,this.float32[g+8]=c,this.float32[g+9]=h,this.float32[g+10]=u,this.float32[g+11]=d,this.float32[g+12]=p,this.float32[g+13]=f,this.float32[g+14]=m,this.float32[g+15]=_,e}}Na.prototype.bytesPerElement=64,ro(Na,"StructArrayLayout16f64");class Va extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=10*e,c=5*e;return this.uint16[l+0]=t,this.uint16[l+1]=i,this.uint16[l+2]=r,this.uint16[l+3]=n,this.float32[c+2]=o,this.float32[c+3]=s,this.float32[c+4]=a,e}}Va.prototype.bytesPerElement=20,ro(Va,"StructArrayLayout4ui3f20");class Ua extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.int16[1*e+0]=t,e}}Ua.prototype.bytesPerElement=2,ro(Ua,"StructArrayLayout1i2");class ja extends aa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint8[1*e+0]=t,e}}ja.prototype.bytesPerElement=1,ro(ja,"StructArrayLayout1ub1");class Ga extends sa{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]}}Ga.prototype.size=40;class qa extends Sa{get(e){return new Ga(this,e)}}ro(qa,"CollisionBoxArray");class Za extends sa{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(e){this._structArray.uint8[this._pos1+49]=e}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(e){this._structArray.uint8[this._pos1+50]=e}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(e){this._structArray.uint32[this._pos4+13]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(e){this._structArray.uint8[this._pos1+58]=e}}Za.prototype.size=60;class $a extends Ca{get(e){return new Za(this,e)}}ro($a,"PlacedSymbolArray");class Ha extends sa{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(e){this._structArray.uint32[this._pos4+14]=e}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(e){this._structArray.float32[this._pos4+18]=e}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}}Ha.prototype.size=80;class Wa extends Pa{get(e){return new Ha(this,e)}}ro(Wa,"SymbolInstanceArray");class Xa extends za{getoffsetX(e){return this.float32[1*e+0]}}ro(Xa,"GlyphOffsetArray");class Ya extends ha{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}ro(Ya,"SymbolLineVertexArray");class Ka extends sa{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]}}Ka.prototype.size=12;class Ja extends Fa{get(e){return new Ka(this,e)}}ro(Ja,"FeatureIndexArray");class Qa extends Ta{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}ro(Qa,"FillExtrusionCentroidArray");class el extends sa{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]}}el.prototype.size=6;class tl extends ua{get(e){return new el(this,e)}}ro(tl,"FillExtrusionWallArray");const il=la([{name:"a_pos",components:2,type:"Int16"}],4),rl=la([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class nl{constructor(e=[]){this.segments=e}_prepareSegment(e,t,i,r){let n=this.segments[this.segments.length-1];return e>nl.MAX_VERTEX_ARRAY_LENGTH&&ue(`Max vertices per segment is ${nl.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!n||n.vertexLength+e>nl.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==r)&&(n={vertexOffset:t,primitiveOffset:i,vertexLength:0,primitiveLength:0},void 0!==r&&(n.sortKey=r),this.segments.push(n)),n}prepareSegment(e,t,i,r){return this._prepareSegment(e,t.length,i.length,r)}get(){return this.segments}destroy(){for(const e of this.segments)for(const t in e.vaos)e.vaos[t].destroy()}static simpleSegment(e,t,i,r){return new nl([{vertexOffset:e,primitiveOffset:t,vertexLength:i,primitiveLength:r,vaos:{},sortKey:0}])}}function ol(e,t){return 256*(e=K(Math.floor(e),0,255))+K(Math.floor(t),0,255)}nl.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ro(nl,"SegmentVector");const sl=la([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),al=la([{name:"a_dash",components:4,type:"Uint16"}]);class ll{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(e,t,i,r){this.ids.push(cl(e)),this.positions.push(t,i,r)}eachPosition(e,t){const i=cl(e);let r=0,n=this.ids.length-1;for(;r<n;){const e=r+n>>1;this.ids[e]>=i?n=e:r=e+1}for(;this.ids[r]===i;)t(this.positions[3*r],this.positions[3*r+1],this.positions[3*r+2]),r++}static serialize(e,t){const i=new Float64Array(e.ids),r=new Uint32Array(e.positions);return hl(i,r,0,i.length-1),t&&(t.add(i.buffer),t.add(r.buffer)),{ids:i,positions:r}}static deserialize(e){const t=new ll;let i;t.ids=e.ids,t.positions=e.positions;for(const e of t.ids)e!==i&&t.uniqueIds.push(e),i=e;return t.indexed=!0,t}}function cl(e){const t=+e;return!isNaN(t)&&Number.MIN_SAFE_INTEGER<=t&&t<=Number.MAX_SAFE_INTEGER?t:mt(String(e))}function hl(e,t,i,r){for(;i<r;){const n=e[i+r>>1];let o=i-1,s=r+1;for(;;){do{o++}while(e[o]<n);do{s--}while(e[s]>n);if(o>=s)break;ul(e,o,s),ul(t,3*o,3*s),ul(t,3*o+1,3*s+1),ul(t,3*o+2,3*s+2)}s-i<r-s?(hl(e,t,i,s),i=s+1):(hl(e,t,s+1,r),r=s)}}function ul(e,t,i){const r=e[t];e[t]=e[i],e[i]=r}ro(ll,"FeaturePositionMap");class dl{constructor(e){this.gl=e.gl,this.initialized=!1}fetchUniformLocation(e,t){return this.location||this.initialized||(this.location=this.gl.getUniformLocation(e,t),this.initialized=!0),!!this.location}set(e,t,i){throw new Error("Uniform#set() must be implemented by each concrete Uniform")}}class pl extends dl{constructor(e){super(e),this.current=0}set(e,t,i){this.fetchUniformLocation(e,t)&&this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}}class fl extends dl{constructor(e){super(e),this.current=0}set(e,t,i){this.fetchUniformLocation(e,t)&&this.current!==i&&(this.current=i,this.gl.uniform1f(this.location,i))}}class ml extends dl{constructor(e){super(e),this.current=[0,0]}set(e,t,i){this.fetchUniformLocation(e,t)&&(i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1])))}}class _l extends dl{constructor(e){super(e),this.current=[0,0,0]}set(e,t,i){this.fetchUniformLocation(e,t)&&(i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2])))}}class gl extends dl{constructor(e){super(e),this.current=[0,0,0,0]}set(e,t,i){this.fetchUniformLocation(e,t)&&(i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]&&i[3]===this.current[3]||(this.current=i,this.gl.uniform4f(this.location,i[0],i[1],i[2],i[3])))}}class yl extends dl{constructor(e){super(e),this.current=St.transparent.toRenderColor(null)}set(e,t,i){this.fetchUniformLocation(e,t)&&(i.r===this.current.r&&i.g===this.current.g&&i.b===this.current.b&&i.a===this.current.a||(this.current=i,this.gl.uniform4f(this.location,i.r,i.g,i.b,i.a)))}}const xl=new Float32Array(16);class vl extends dl{constructor(e){super(e),this.current=xl}set(e,t,i){if(this.fetchUniformLocation(e,t)){if(i[12]!==this.current[12]||i[0]!==this.current[0])return this.current=i,void this.gl.uniformMatrix4fv(this.location,!1,i);for(let e=1;e<16;e++)if(i[e]!==this.current[e]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}}}const bl=new Float32Array(9),wl=new Float32Array(4);class Tl extends dl{constructor(e){super(e),this.current=wl}set(e,t,i){if(this.fetchUniformLocation(e,t))for(let e=0;e<4;e++)if(i[e]!==this.current[e]){this.current=i,this.gl.uniformMatrix2fv(this.location,!1,i);break}}}function Sl(e){return[ol(255*e.r,255*e.g),ol(255*e.b,255*e.a)]}class Ml{constructor(e,t,i,r){this.value=e,this.uniformNames=t.map((e=>`u_${e}`)),this.type=i,this.context=r}setUniform(e,t,i,r,n){const o=r.constantOr(this.value);t.set(e,n,o instanceof St?o.toRenderColor(this.ignoreLut?null:this.context.lut):o)}getBinding(e,t){return"color"===this.type?new yl(e):new fl(e)}}class El{constructor(e,t){this.uniformNames=t.map((e=>`u_${e}`)),this.pattern=null,this.pixelRatio=1}setConstantPatternPositions(e){this.pixelRatio=e.pixelRatio||1,this.pattern=e.tl.concat(e.br)}setUniform(e,t,i,r,n){const o="u_pattern"===n||"u_dash"===n?this.pattern:"u_pixel_ratio"===n?this.pixelRatio:null;o&&t.set(e,n,o)}getBinding(e,t){return"u_pattern"===t||"u_dash"===t?new gl(e):new fl(e)}}class Al{constructor(e,t,i,r){this.expression=e,this.type=i,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new r}populatePaintArray(e,t,i,r,n,o,s){const a=this.paintVertexArray.length,l=this.expression.evaluate(new Ms(0,{brightness:o}),t,{},n,r,s);this.paintVertexArray.resize(e),this._setPaintValue(a,e,l,this.context)}updatePaintArray(e,t,i,r,n,o,s){const a=this.expression.evaluate({zoom:0,brightness:s},i,r,void 0,n);this._setPaintValue(e,t,a,this.context)}_setPaintValue(e,t,i,r){if("color"===this.type){const n=Sl(i.toRenderColor(this.ignoreLut?null:r.lut));for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,n[0],n[1])}else{for(let r=e;r<t;r++)this.paintVertexArray.emplace(r,i);this.maxValue=Math.max(this.maxValue,Math.abs(i))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent||!this.expression.isLightConstant))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class Il{constructor(e,t,i,r,n,o){this.expression=e,this.uniformNames=t.map((e=>`u_${e}_t`)),this.type=i,this.useIntegerZoom=r,this.context=n,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new o}populatePaintArray(e,t,i,r,n,o,s){const a=this.expression.evaluate(new Ms(this.context.zoom,{brightness:o}),t,{},n,r,s),l=this.expression.evaluate(new Ms(this.context.zoom+1,{brightness:o}),t,{},n,r,s),c=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(c,e,a,l,this.context)}updatePaintArray(e,t,i,r,n,o,s){const a=this.expression.evaluate({zoom:this.context.zoom,brightness:s},i,r,void 0,n),l=this.expression.evaluate({zoom:this.context.zoom+1,brightness:s},i,r,void 0,n);this._setPaintValue(e,t,a,l,this.context)}_setPaintValue(e,t,i,r,n){if("color"===this.type){const r=Sl(i.toRenderColor(this.ignoreLut?null:n.lut)),o=Sl(i.toRenderColor(this.ignoreLut?null:n.lut));for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,r[0],r[1],o[0],o[1])}else{for(let n=e;n<t;n++)this.paintVertexArray.emplace(n,i,r);this.maxValue=Math.max(this.maxValue,Math.abs(i),Math.abs(r))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent||!this.expression.isLightConstant))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,t,i,r,n){const o=this.useIntegerZoom?Math.floor(i.zoom):i.zoom,s=K(this.expression.interpolationFactor(o,this.context.zoom,this.context.zoom+1),0,1);t.set(e,n,s)}getBinding(e,t){return new fl(e)}}class Cl{constructor(e,t,i,r,n){this.expression=e,this.layerId=n,this.paintVertexAttributes=("array"===i?al:sl).members;for(let e=0;e<t.length;++e);this.paintVertexArray=new r}populatePaintArray(e,t,i,r){const n=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValues(n,e,t.patterns&&t.patterns[this.layerId],i)}updatePaintArray(e,t,i,r,n,o,s){this._setPaintValues(e,t,i.patterns&&i.patterns[this.layerId],o)}_setPaintValues(e,t,i,r){if(!r||!i)return;const n=r[i];if(!n)return;const{tl:o,br:s,pixelRatio:a}=n;for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,o[0],o[1],s[0],s[1],a)}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent||!this.expression.isLightConstant))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class Pl{constructor(e,t,i=()=>!0){this.binders={},this._buffers=[],this.context=t;const r=[];for(const n in e.paint._values){const o=e.paint.get(n),s=e.paint.get(`${n}-use-theme`);if(n.endsWith("-use-theme"))continue;if(!i(n))continue;if(!(o instanceof Ds&&Dn(o.property.specification)))continue;const a=Rl(n,e.type),l=o.value,c=o.property.specification.type,h=!!o.property.useIntegerZoom,u="line-dasharray"===n||n.endsWith("pattern"),d="line-dasharray"===n&&"constant"!==e.layout.get("line-cap").value.kind;if("constant"!==l.kind||d)if("source"===l.kind||d||u){const t=kl(n,c,"source");this.binders[n]=u?new Cl(l,a,c,t,e.id):new Al(l,a,c,t),r.push(`/a_${n}`)}else{const e=kl(n,c,"composite");this.binders[n]=new Il(l,a,c,h,t,e),r.push(`/z_${n}`)}else this.binders[n]=u?new El(l.value,a):new Ml(l.value,a,c,t),r.push(`/u_${n}`);s&&(this.binders[n].ignoreLut="none"===s.constantOr("default"),this.binders[n].checkUseTheme=!0)}this.cacheKey=r.sort().join("")}getMaxValue(e){const t=this.binders[e];return t instanceof Al||t instanceof Il?t.maxValue:0}populatePaintArrays(e,t,i,r,n,o,s){for(const a in this.binders){const l=this.binders[a];l.context=this.context,(l instanceof Al||l instanceof Il||l instanceof Cl)&&l.populatePaintArray(e,t,i,r,n,o,s)}}setConstantPatternPositions(e){for(const t in this.binders){const i=this.binders[t];i instanceof El&&i.setConstantPatternPositions(e)}}updatePaintArrays(e,t,i,r,n,o,s,a,l){let c=!1;const h=Object.keys(e),u=0!==h.length&&!a,d=u?h:t.uniqueIds;this.context.lut=n.lut;for(const a in this.binders){const h=this.binders[a];if(h.context=this.context,(h instanceof Al||h instanceof Il||h instanceof Cl)&&(!0===h.expression.isStateDependent||!1===h.expression.isLightConstant)){const p=n.paint.get(a);h.expression=p.value;for(const i of d){const n=e[i.toString()];t.eachPosition(i,((e,t,i)=>{const a=r.feature(e);h.updatePaintArray(t,i,a,n,o,s,l)}))}if(!u)for(const t of i.uniqueIds){const n=e[t.toString()];i.eachPosition(t,((e,t,i)=>{const a=r.feature(e);h.updatePaintArray(t,i,a,n,o,s,l)}))}c=!0}}return c}defines(){const e=[];for(const t in this.binders){const i=this.binders[t];(i instanceof Ml||i instanceof El)&&e.push(...i.uniformNames.map((e=>`#define HAS_UNIFORM_${e}`)))}return e}getBinderAttributes(){const e=[];for(const t in this.binders){const i=this.binders[t];if(i instanceof Al||i instanceof Il||i instanceof Cl)for(let t=0;t<i.paintVertexAttributes.length;t++)e.push(i.paintVertexAttributes[t].name)}return e}getBinderUniforms(){const e=[];for(const t in this.binders){const i=this.binders[t];if(i instanceof Ml||i instanceof El||i instanceof Il)for(const t of i.uniformNames)e.push(t)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e){const t=[];for(const i in this.binders){const r=this.binders[i];if(r instanceof Ml||r instanceof El||r instanceof Il)for(const n of r.uniformNames)t.push({name:n,property:i,binding:r.getBinding(e,n)})}return t}setUniforms(e,t,i,r,n){for(const{name:t,property:o,binding:s}of i){if(this.binders[o].checkUseTheme&&this.binders[o]instanceof Ml){const e=r.get(`${o}-use-theme`);e.isConstant()&&(this.binders[o].ignoreLut="none"===e.constantOr("default"))}this.binders[o].setUniform(e,s,n,r.get(o),t)}}updatePaintBuffers(){this._buffers=[];for(const e in this.binders){const t=this.binders[e];(t instanceof Al||t instanceof Il||t instanceof Cl)&&t.paintVertexBuffer&&this._buffers.push(t.paintVertexBuffer)}}upload(e){for(const t in this.binders){const i=this.binders[t];(i instanceof Al||i instanceof Il||i instanceof Cl)&&i.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const t=this.binders[e];(t instanceof Al||t instanceof Il||t instanceof Cl)&&t.destroy()}}}class zl{constructor(e,t,i=()=>!0){this.programConfigurations={};for(const r of e)this.programConfigurations[r.id]=new Pl(r,t,i);this.needsUpload=!1,this._featureMap=new ll,this._featureMapWithoutIds=new ll,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(e,t,i,r,n,o,s,a){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(e,t,r,n,o,s,a);void 0!==t.id?this._featureMap.add(t.id,i,this._bufferOffset,e):(this._featureMapWithoutIds.add(this._idlessCounter,i,this._bufferOffset,e),this._idlessCounter+=1),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,i,r,n,o,s){for(const a of i)this.needsUpload=this.programConfigurations[a.id].updatePaintArrays(e,this._featureMap,this._featureMapWithoutIds,t,a,r,n,o,s||0)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}const Dl={"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 Rl(e,t){return Dl[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}const Ll={"line-pattern":{source:ga,composite:ga},"fill-pattern":{source:ga,composite:ga},"fill-extrusion-pattern":{source:ga,composite:ga},"line-dasharray":{source:ya,composite:ya}},Ol={color:{source:ka,composite:ma},number:{source:za,composite:ka}};function kl(e,t,i){const r=Ll[e];return r&&r[i]||Ol[t][i]}ro(Ml,"ConstantBinder"),ro(El,"PatternConstantBinder"),ro(Al,"SourceExpressionBinder"),ro(Cl,"PatternCompositeBinder"),ro(Il,"CompositeExpressionBinder"),ro(Pl,"ProgramConfiguration",{omit:["_buffers"]}),ro(zl,"ProgramConfigurationSet");const Fl=Wi/Math.PI/2,Bl=64,Nl=[Bl,32,16],Vl=-Fl,Ul=Fl;function jl(e,t,i,r=Fl){return i=Z(i),[e*Math.sin(i)*r,-t*r,e*Math.cos(i)*r]}function Gl(e,t,i){return jl(Math.cos(Z(e)),Math.sin(Z(e)),t,i)}const ql=6371008.8,Zl=2*Math.PI*ql;class $l{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new $l(Q(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const t=Math.PI/180,i=this.lat*t,r=e.lat*t,n=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((e.lng-this.lng)*t);return ql*Math.acos(Math.min(n,1))}toBounds(e=0){const t=360*e/40075017,i=t/Math.cos(Math.PI/180*this.lat);return new Hl({lng:this.lng-i,lat:this.lat-t},{lng:this.lng+i,lat:this.lat+t})}toEcef(e){return Gl(this.lat,this.lng,Fl+e*Fl/ql)}static convert(e){if(e instanceof $l)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new $l(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new $l(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}class Hl{constructor(e,t){if(e)if(t)this.setSouthWest(e).setNorthEast(t);else if(4===e.length){const t=e;this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]])}else{const t=e;this.setSouthWest(t[0]).setNorthEast(t[1])}}setNorthEast(e){return this._ne=e instanceof $l?new $l(e.lng,e.lat):$l.convert(e),this}setSouthWest(e){return this._sw=e instanceof $l?new $l(e.lng,e.lat):$l.convert(e),this}extend(e){const t=this._sw,i=this._ne;let r,n;if(e instanceof $l)r=e,n=e;else{if(!(e instanceof Hl))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(Hl.convert(e)):this.extend($l.convert(e)):"object"==typeof e&&null!==e&&e.hasOwnProperty("lat")&&(e.hasOwnProperty("lon")||e.hasOwnProperty("lng"))?this.extend($l.convert(e)):this;if(r=e._sw,n=e._ne,!r||!n)return this}return t||i?(t.lng=Math.min(r.lng,t.lng),t.lat=Math.min(r.lat,t.lat),i.lng=Math.max(n.lng,i.lng),i.lat=Math.max(n.lat,i.lat)):(this._sw=new $l(r.lng,r.lat),this._ne=new $l(n.lng,n.lat)),this}getCenter(){return new $l((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 $l(this.getWest(),this.getNorth())}getSouthEast(){return new $l(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(e){const{lng:t,lat:i}=$l.convert(e);let r=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=t&&t>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&r}static convert(e){if(e)return e instanceof Hl?e:new Hl(e)}}function Wl(e){return Zl*Math.cos(e*Math.PI/180)}function Xl(e){return(180+e)/360}function Yl(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Kl(e,t){return e/Wl(t)}function Jl(e){return 360*e-180}function Ql(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function ec(e,t){return e*Wl(Ql(t))}const tc=85.051129;function ic(e){return Math.cos(Z(K(e,-tc,tc)))}function rc(e,t){const i=K(t,0,25.5),r=Math.pow(2,i);return ic(e)*Zl/(512*r)}function nc(e){return 1/Math.cos(e*Math.PI/180)}function oc(e,t=0){const i=Math.exp(Math.PI*(1-(e.y+t/Wi)/(1<<e.z)*2));return 80150034*i/(i*i+1)/Wi/(1<<e.z)}class sc{constructor(e,t,i=0){this.x=+e,this.y=+t,this.z=+i}static fromLngLat(e,t=0){const i=$l.convert(e);return new sc(Xl(i.lng),Yl(i.lat),Kl(t,i.lat))}toLngLat(){return new $l(Jl(this.x),Ql(this.y))}toAltitude(){return ec(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Zl*nc(Ql(this.y))}}function ac(e,t,i,r,n,o,s,a,l){const c=(t+r)/2,h=(i+n)/2,u=new U(c,h);a(u),function(e,t,i,r,n,o){const s=i-n,a=r-o;return Math.abs((r-t)*s-(i-e)*a)/Math.hypot(s,a)}(u.x,u.y,o.x,o.y,s.x,s.y)>=l?(ac(e,t,i,c,h,o,u,a,l),ac(e,c,h,r,n,u,s,a,l)):e.push(s)}function lc(e,t,i){let r=e[0],n=r.x,o=r.y;t(r);const s=[r];for(let a=1;a<e.length;a++){const l=e[a],{x:c,y:h}=l;t(l),ac(s,n,o,c,h,r,l,t,i),n=c,o=h,r=l}return s}function cc(e,t,i,r){if(r(t,i)){const n=t.add(i)._mult(.5);cc(e,t,n,r),cc(e,n,i,r)}else e.push(i)}function hc(e,t){let i=e[0];const r=[i];for(let n=1;n<e.length;n++){const o=e[n];cc(r,i,o,t),i=o}return r}const uc=Math.pow(2,14)-1,dc=-uc-1;function pc(e,t){const i=Math.round(e.x*t),r=Math.round(e.y*t);return e.x=K(i,dc,uc),e.y=K(r,dc,uc),(i<e.x||i>e.x+1||r<e.y||r>e.y+1)&&ue("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function fc(e,t,i){const r=e.loadGeometry(),n=e.extent,o=Wi/n;if(t&&i&&i.projection.isReprojectedInTileSpace){const o=1<<t.z,{scale:s,x:a,y:l,projection:c}=i,h=e=>{const i=Jl((t.x+e.x/n)/o),r=Ql((t.y+e.y/n)/o),h=c.project(i,r);e.x=(h.x*s-a)*n,e.y=(h.y*s-l)*n};for(let t=0;t<r.length;t++)if(1!==e.type)r[t]=lc(r[t],h,1);else{const e=[];for(const i of r[t])i.x<0||i.x>=n||i.y<0||i.y>=n||(h(i),e.push(i));r[t]=e}}for(const e of r)for(const t of e)pc(t,o);return r}function mc(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?fc(e):[]}}function _c(e,t,i,r,n){e.emplaceBack(2*t+(r+1)/2,2*i+(n+1)/2)}function gc(e,t,i){const r=16384;e.emplaceBack(t.x,t.y,t.z,i[0]*r,i[1]*r,i[2]*r)}class yc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.fqid)),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new ha,this.indexArray=new Ia,this.segments=new nl,this.programConfigurations=new zl(e.layers,{zoom:e.zoom,lut:e.lut}),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}updateFootprints(e,t){}populate(e,t,i,r){const n=this.layers[0],o=[];let s=null;"circle"===n.type&&(s=n.layout.get("circle-sort-key"));for(const{feature:t,id:n,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=mc(t,e);if(!this.layers[0]._featureFilter.filter(new Ms(this.zoom),c,i))continue;const h=s?s.evaluate(c,{},i):void 0,u={id:n,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:fc(t,i,r),patterns:{},sortKey:h};o.push(u)}s&&o.sort(((e,t)=>e.sortKey-t.sortKey));let a=null;"globe"===r.projection.name&&(this.globeExtVertexArray=new xa,a=r.projection);for(const r of o){const{geometry:n,index:o,sourceLayerIndex:s}=r,l=e[o].feature;this.addFeature(r,n,o,t.availableImages,i,a,t.brightness),t.featureIndex.insert(l,n,o,s,this.index)}}update(e,t,i,r,n,o,s){this.programConfigurations.updatePaintArrays(e,t,n,i,r,o,s)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,il.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,rl.members))),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(e,t,i,r,n,o,s){for(const i of t)for(const t of i){const i=t.x,r=t.y;if(i<0||i>=Wi||r<0||r>=Wi)continue;if(o){const e=o.projectTilePoint(i,r,n),t=o.upVector(n,i,r),s=this.globeExtVertexArray;gc(s,e,t),gc(s,e,t),gc(s,e,t),gc(s,e,t)}const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),a=s.vertexLength;_c(this.layoutVertexArray,i,r,-1,-1),_c(this.layoutVertexArray,i,r,1,-1),_c(this.layoutVertexArray,i,r,1,1),_c(this.layoutVertexArray,i,r,-1,1),this.indexArray.emplaceBack(a,a+1,a+2),this.indexArray.emplaceBack(a,a+2,a+3),s.vertexLength+=4,s.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{},r,n,s)}}function xc(e,t){for(let i=0;i<e.length;i++)if(Ic(t,e[i]))return!0;for(let i=0;i<t.length;i++)if(Ic(e,t[i]))return!0;return!!Tc(e,t)}function vc(e,t,i){return!!Ic(e,t)||!!Mc(t,e,i)}function bc(e,t){if(1===e.length)return Ac(t,e[0]);for(let i=0;i<t.length;i++){const r=t[i];for(let t=0;t<r.length;t++)if(Ic(e,r[t]))return!0}for(let i=0;i<e.length;i++)if(Ac(t,e[i]))return!0;for(let i=0;i<t.length;i++)if(Tc(e,t[i]))return!0;return!1}function wc(e,t,i){if(e.length>1){if(Tc(e,t))return!0;for(let r=0;r<t.length;r++)if(Mc(t[r],e,i))return!0}for(let r=0;r<e.length;r++)if(Mc(e[r],t,i))return!0;return!1}function Tc(e,t){if(0===e.length||0===t.length)return!1;for(let i=0;i<e.length-1;i++){const r=e[i],n=e[i+1];for(let e=0;e<t.length-1;e++)if(Sc(r,n,t[e],t[e+1]))return!0}return!1}function Sc(e,t,i,r){return de(e,i,r)!==de(t,i,r)&&de(e,t,i)!==de(e,t,r)}function Mc(e,t,i){const r=i*i;if(1===t.length)return e.distSqr(t[0])<r;for(let i=1;i<t.length;i++)if(Ec(e,t[i-1],t[i])<r)return!0;return!1}function Ec(e,t,i){const r=t.distSqr(i);if(0===r)return e.distSqr(t);const n=((e.x-t.x)*(i.x-t.x)+(e.y-t.y)*(i.y-t.y))/r;return e.distSqr(n<0?t:n>1?i:i.sub(t)._mult(n)._add(t))}function Ac(e,t){let i,r,n,o=!1;for(let s=0;s<e.length;s++){i=e[s];for(let e=0,s=i.length-1;e<i.length;s=e++)r=i[e],n=i[s],r.y>t.y!=n.y>t.y&&t.x<(n.x-r.x)*(t.y-r.y)/(n.y-r.y)+r.x&&(o=!o)}return o}function Ic(e,t){let i=!1;for(let r=0,n=e.length-1;r<e.length;n=r++){const o=e[r],s=e[n];o.y>t.y!=s.y>t.y&&t.x<(s.x-o.x)*(t.y-o.y)/(s.y-o.y)+o.x&&(i=!i)}return i}function Cc(e,t,i,r,n){for(const o of e)if(t<=o.x&&i<=o.y&&r>=o.x&&n>=o.y)return!0;const o=[new U(t,i),new U(t,n),new U(r,n),new U(r,i)];if(e.length>2)for(const t of o)if(Ic(e,t))return!0;for(let t=0;t<e.length-1;t++)if(Pc(e[t],e[t+1],o))return!0;return!1}function Pc(e,t,i){const r=i[0],n=i[2];if(e.x<r.x&&t.x<r.x||e.x>n.x&&t.x>n.x||e.y<r.y&&t.y<r.y||e.y>n.y&&t.y>n.y)return!1;const o=de(e,t,i[0]);return o!==de(e,t,i[1])||o!==de(e,t,i[2])||o!==de(e,t,i[3])}function zc(e,t,i,r,n,o){let s=t.y-e.y,a=e.x-t.x;if(o=o||0){const e=s*s+a*a;if(0===e)return!0;const t=Math.sqrt(e);s/=t,a/=t}return!((i.x-e.x)*s+(i.y-e.y)*a-o<0||(r.x-e.x)*s+(r.y-e.y)*a-o<0||(n.x-e.x)*s+(n.y-e.y)*a-o<0)}function Dc(e,t,i,r,n,o,s){return!(zc(e,t,r,n,o,s)||zc(t,i,r,n,o,s)||zc(i,e,r,n,o,s)||zc(r,n,e,t,i,s)||zc(n,o,e,t,i,s)||zc(o,r,e,t,i,s))}function Rc(e,t,i){const r=t.paint.get(e).value;return"constant"===r.kind?r.value:i.programConfigurations.get(t.id).getMaxValue(e)}function Lc(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function Oc(e,t,i,r,n){if(!t[0]&&!t[1])return e;const o=U.convert(t)._mult(n);"viewport"===i&&o._rotate(-r);const s=[];for(let t=0;t<e.length;t++)s.push(e[t].sub(o));return s}function kc(e,t,i,r){const n=U.convert(e)._mult(r);return"viewport"===t&&n._rotate(-i),n}let Fc,Bc;ro(yc,"CircleBucket",{omit:["layers"]});var Nc,Vc={exports:{}},Uc=(Nc||(Nc=1,function(e,t){!function(e){function t(e,t,r){var n=i(256*e,256*(t=Math.pow(2,r)-t-1),r),o=i(256*(e+1),256*(t+1),r);return n[0]+","+n[1]+","+o[0]+","+o[1]}function i(e,t,i){var r=2*Math.PI*6378137/256/Math.pow(2,i);return[e*r-2*Math.PI*6378137/2,t*r-2*Math.PI*6378137/2]}e.getURL=function(e,i,r,n,o,s){return s=s||{},e+"?"+["bbox="+t(r,n,o),"format="+(s.format||"image/png"),"service="+(s.service||"WMS"),"version="+(s.version||"1.1.1"),"request="+(s.request||"GetMap"),"srs="+(s.srs||"EPSG:3857"),"width="+(s.width||256),"height="+(s.height||256),"layers="+i].join("&")},e.getTileBBox=t,e.getMercCoords=i,Object.defineProperty(e,"__esModule",{value:!0})}(t)}(0,Vc.exports)),Vc.exports);class jc{constructor(e,t,i){this.z=e,this.x=t,this.y=i,this.key=Zc(0,e,e,t,i)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t){const i=Uc.getTileBBox(this.x,this.y,this.z),r=function(e,t,i){let r,n="";for(let o=e;o>0;o--)r=1<<o-1,n+=(t&r?1:0)+(i&r?2:0);return n}(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace("{prefix}",(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String("tms"===t?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",r).replace("{bbox-epsg-3857}",i)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Gc{constructor(e,t){this.wrap=e,this.canonical=t,this.key=Zc(e,t.z,t.z,t.x,t.y)}}class qc{constructor(e,t,i,r,n){this.overscaledZ=e,this.wrap=t,this.canonical=new jc(i,+r,+n),this.key=0===t&&e===i?this.canonical.key:Zc(t,e,i,r,n)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){const t=this.canonical.z-e;return e>this.canonical.z?new qc(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new qc(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}calculateScaledKey(e,t=!0){if(this.overscaledZ===e&&t)return this.key;if(e>this.canonical.z)return Zc(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-e;return Zc(this.wrap*+t,e,e,this.canonical.x>>i,this.canonical.y>>i)}}isChildOf(e){if(e.wrap!==this.wrap)return!1;const t=this.canonical.z-e.canonical.z;return 0===e.overscaledZ||e.overscaledZ<this.overscaledZ&&e.canonical.z<this.canonical.z&&e.canonical.x===this.canonical.x>>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new qc(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,i=2*this.canonical.x,r=2*this.canonical.y;return[new qc(t,this.wrap,t,i,r),new qc(t,this.wrap,t,i+1,r),new qc(t,this.wrap,t,i,r+1),new qc(t,this.wrap,t,i+1,r+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new qc(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new qc(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new Gc(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function Zc(e,t,i,r,n){const o=1<<Math.min(i,22);let s=o*(n%o)+r%o;return e&&i<22&&(s+=o*o*((e<0?-2*e-1:2*e)%(1<<2*(22-i)))),16*(32*s+i)+(t-i)}const $c=[e=>{let t=e.canonical.x-1,i=e.wrap;return t<0&&(t=(1<<e.canonical.z)-1,i--),new qc(e.overscaledZ,i,e.canonical.z,t,e.canonical.y)},e=>{let t=e.canonical.x+1,i=e.wrap;return t===1<<e.canonical.z&&(t=0,i++),new qc(e.overscaledZ,i,e.canonical.z,t,e.canonical.y)},e=>new qc(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,(0===e.canonical.y?1<<e.canonical.z:e.canonical.y)-1),e=>new qc(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y===(1<<e.canonical.z)-1?0:e.canonical.y+1)];ro(jc,"CanonicalTileID"),ro(qc,"OverscaledTileID",{omit:["projMatrix","expandedProjMatrix"]});const Hc=la([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:Wc}=Hc,Xc=la([{name:"a_pos_3",components:3,type:"Int16"}]);var Yc=la([{name:"a_pos",type:"Int16",components:2}]);class Kc{constructor(e,t){this.pos=e,this.dir=t}intersectsPlane(e,t,i){const r=F.vec3.dot(t,this.dir);if(Math.abs(r)<1e-6)return!1;const n=((e[0]-this.pos[0])*t[0]+(e[1]-this.pos[1])*t[1]+(e[2]-this.pos[2])*t[2])/r;return i[0]=this.pos[0]+this.dir[0]*n,i[1]=this.pos[1]+this.dir[1]*n,i[2]=this.pos[2]+this.dir[2]*n,!0}closestPointOnSphere(e,t,i){if(F.vec3.equals(this.pos,e)||0===t)return i[0]=i[1]=i[2]=0,!1;const[r,n,o]=this.dir,s=this.pos[0]-e[0],a=this.pos[1]-e[1],l=this.pos[2]-e[2],c=r*r+n*n+o*o,h=2*(s*r+a*n+l*o),u=h*h-4*c*(s*s+a*a+l*l-t*t);if(u<0){const e=Math.max(-h/2,0),c=s+r*e,u=a+n*e,d=l+o*e,p=Math.hypot(c,u,d);return i[0]=c*t/p,i[1]=u*t/p,i[2]=d*t/p,!1}{const e=(-h-Math.sqrt(u))/(2*c);if(e<0){const e=Math.hypot(s,a,l);return i[0]=s*t/e,i[1]=a*t/e,i[2]=l*t/e,!1}return i[0]=s+r*e,i[1]=a+n*e,i[2]=l+o*e,!0}}}class Jc{constructor(e,t,i,r,n){this.TL=e,this.TR=t,this.BR=i,this.BL=r,this.horizon=n}static fromInvProjectionMatrix(e,t,i){const r=[-1,1,1],n=[1,1,1],o=[1,-1,1],s=[-1,-1,1],a=F.vec3.transformMat4(r,r,e),l=F.vec3.transformMat4(n,n,e),c=F.vec3.transformMat4(o,o,e),h=F.vec3.transformMat4(s,s,e);return new Jc(a,l,c,h,t/i)}}function Qc(e,t,i){let r=1/0,n=-1/0;const o=[];for(const s of e){F.vec3.sub(o,s,t);const e=F.vec3.dot(o,i);r=Math.min(r,e),n=Math.max(n,e)}return[r,n]}function eh(e,t){let i=!0;for(let r=0;r<e.planes.length;r++){const n=e.planes[r];let o=0;for(let e=0;e<t.length;e++)o+=F.vec3.dot(n,t[e])+n[3]>=0;if(0===o)return 0;o!==t.length&&(i=!1)}return i?2:1}function th(e,t){for(const i of e.projections){const r=Qc(t,e.points[0],i.axis);if(i.projection[1]<r[0]||i.projection[0]>r[1])return 0}return 1}function ih(e,t){let i=0;const r=[0,0,0,0];for(let n=0;n<e.length;n++)r[0]=e[n][0],r[1]=e[n][1],r[2]=e[n][2],r[3]=1,F.vec4.dot(r,t)>=0&&i++;return i}class rh{constructor(e,t){this.points=e||new Array(8).fill([0,0,0]),this.planes=t||new Array(6).fill([0,0,0,0]),this.bounds=nh.fromPoints(this.points),this.projections=[],this.frustumEdges=[F.vec3.sub([],this.points[2],this.points[3]),F.vec3.sub([],this.points[0],this.points[3]),F.vec3.sub([],this.points[4],this.points[0]),F.vec3.sub([],this.points[5],this.points[1]),F.vec3.sub([],this.points[6],this.points[2]),F.vec3.sub([],this.points[7],this.points[3])];for(const e of this.frustumEdges){const t=[0,-e[2],e[1]],i=[e[2],0,-e[0]];this.projections.push({axis:t,projection:Qc(this.points,this.points[0],t)}),this.projections.push({axis:i,projection:Qc(this.points,this.points[0],i)})}}static fromInvProjectionMatrix(e,t,i,r){const n=Math.pow(2,i),o=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((i=>{const o=F.vec4.transformMat4([],i,e),s=1/o[3]/t*n;return F.vec4.mul(o,o,[s,s,r?1/o[3]:s,s])})),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((e=>{const t=F.vec3.sub([],o[e[0]],o[e[1]]),i=F.vec3.sub([],o[e[2]],o[e[1]]),r=F.vec3.normalize([],F.vec3.cross([],t,i)),n=-F.vec3.dot(r,o[e[1]]);return r.concat(n)})),a=[];for(let e=0;e<o.length;e++)a.push([o[e][0],o[e][1],o[e][2]]);return new rh(a,s)}intersectsPrecise(e,t,i){for(let i=0;i<t.length;i++)if(!ih(e,t[i]))return 0;for(let t=0;t<this.planes.length;t++)if(!ih(e,this.planes[t]))return 0;for(const t of i)for(const i of this.frustumEdges){const r=F.vec3.cross([],t,i),n=F.vec3.length(r);if(0===n)continue;F.vec3.scale(r,r,1/n);const o=Qc(this.points,this.points[0],r),s=Qc(e,this.points[0],r);if(o[0]>s[1]||s[0]>o[1])return 0}return 1}containsPoint(e){for(const t of this.planes){const i=t[3];if(F.vec3.dot([t[0],t[1],t[2]],e)+i<0)return!1}return!0}}class nh{static fromPoints(e){const t=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0];for(const r of e)F.vec3.min(t,t,r),F.vec3.max(i,i,r);return new nh(t,i)}static fromTileIdAndHeight(e,t,i){const r=1<<e.canonical.z,n=e.canonical.x,o=e.canonical.y;return new nh([n/r,o/r,t],[(n+1)/r,(o+1)/r,i])}static applyTransform(e,t){const i=e.getCorners();for(let e=0;e<i.length;++e)F.vec3.transformMat4(i[e],i[e],t);return nh.fromPoints(i)}static applyTransformFast(e,t){const i=[t[12],t[13],t[14]],r=[...i];for(let n=0;n<3;n++)for(let o=0;o<3;o++){const s=t[4*o+n],a=s*e.min[o],l=s*e.max[o];i[n]+=Math.min(a,l),r[n]+=Math.max(a,l)}return new nh(i,r)}static projectAabbCorners(e,t){const i=e.getCorners();for(let e=0;e<i.length;++e)F.vec3.transformMat4(i[e],i[e],t);return i}constructor(e,t){this.min=e,this.max=t,this.center=F.vec3.scale([],F.vec3.add([],this.min,this.max),.5)}quadrant(e){const t=[e%2==0,e<2],i=F.vec3.clone(this.min),r=F.vec3.clone(this.max);for(let e=0;e<t.length;e++)i[e]=t[e]?this.min[e]:this.center[e],r[e]=t[e]?this.center[e]:this.max[e];return r[2]=this.max[2],new nh(i,r)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}distanceZ(e){return Math.max(Math.min(this.max[2],e[2]),this.min[2])-e[2]}getCorners(){const e=this.min,t=this.max;return[[e[0],e[1],e[2]],[t[0],e[1],e[2]],[t[0],t[1],e[2]],[e[0],t[1],e[2]],[e[0],e[1],t[2]],[t[0],e[1],t[2]],[t[0],t[1],t[2]],[e[0],t[1],t[2]]]}intersects(e){return this.intersectsAabb(e.bounds)?eh(e,this.getCorners()):0}intersectsFlat(e){return this.intersectsAabb(e.bounds)?eh(e,[[this.min[0],this.min[1],0],[this.max[0],this.min[1],0],[this.max[0],this.max[1],0],[this.min[0],this.max[1],0]]):0}intersectsPrecise(e,t){return t||this.intersects(e)?th(e,this.getCorners()):0}intersectsPreciseFlat(e,t){return t||this.intersectsFlat(e)?th(e,[[this.min[0],this.min[1],0],[this.max[0],this.min[1],0],[this.max[0],this.max[1],0],[this.min[0],this.max[1],0]]):0}intersectsAabb(e){for(let t=0;t<3;++t)if(this.min[t]>e.max[t]||e.min[t]>this.max[t])return!1;return!0}intersectsAabbXY(e){return!(this.min[0]>e.max[0]||e.min[0]>this.max[0]||this.min[1]>e.max[1]||e.min[1]>this.max[1])}encapsulate(e){for(let t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e.min[t]),this.max[t]=Math.max(this.max[t],e.max[t])}encapsulatePoint(e){for(let t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e[t]),this.max[t]=Math.max(this.max[t],e[t])}closestPoint(e){return[Math.max(Math.min(this.max[0],e[0]),this.min[0]),Math.max(Math.min(this.max[1],e[1]),this.min[1]),Math.max(Math.min(this.max[2],e[2]),this.min[2])]}}function oh(e){return e*Fl/ql}ro(nh,"Aabb");const sh=[new nh([Vl,Vl,Vl],[Ul,Ul,Ul]),new nh([Vl,Vl,Vl],[0,0,Ul]),new nh([0,Vl,Vl],[Ul,0,Ul]),new nh([Vl,0,Vl],[0,Ul,Ul]),new nh([0,0,Vl],[Ul,Ul,Ul])];function ah(e,t,i,r=!0){const n=F.vec3.scale([],e._camera.position,e.worldSize),o=[t,i,1,1];F.vec4.transformMat4(o,o,e.pixelMatrixInverse),F.vec4.scale(o,o,1/o[3]);const s=F.vec3.sub([],o,n),a=F.vec3.normalize([],s),l=e.globeMatrix,c=[l[12],l[13],l[14]],h=F.vec3.sub([],c,n),u=F.vec3.length(h),d=F.vec3.normalize([],h),p=e.worldSize/(2*Math.PI),f=F.vec3.dot(d,a),m=Math.asin(p/u);if(m<Math.acos(f)){if(!r)return null;const e=[],t=[];F.vec3.scale(e,a,u/f),F.vec3.normalize(t,F.vec3.sub(t,e,h)),F.vec3.normalize(a,F.vec3.add(a,h,F.vec3.scale(a,t,Math.tan(m)*u)))}const _=[];new Kc(n,a).closestPointOnSphere(c,p,_);const g=F.vec3.normalize([],ye(l,0)),y=F.vec3.normalize([],ye(l,1)),x=F.vec3.normalize([],ye(l,2)),v=F.vec3.dot(g,_),b=F.vec3.dot(y,_),w=F.vec3.dot(x,_),T=$(Math.asin(-b/p));let S=$(Math.atan2(v,w));S=e.center.lng+function(e,t){const i=(t-e+180)%360-180;return i<-180?i+360:i}(e.center.lng,S);const M=Xl(S),E=K(Yl(T),0,1);return new sc(M,E)}class lh{constructor(e,t,i){this.a=F.vec3.sub([],e,i),this.b=F.vec3.sub([],t,i),this.center=i;const r=F.vec3.normalize([],this.a),n=F.vec3.normalize([],this.b);this.angle=Math.acos(F.vec3.dot(r,n))}}function ch(e,t){if(0===e.angle)return null;let i;return i=0===e.a[t]?1/e.angle*.5*Math.PI:1/e.angle*Math.atan(e.b[t]/e.a[t]/Math.sin(e.angle)-1/Math.tan(e.angle)),i<0||i>1?null:function(e,t,i,r){const n=Math.sin(i);return e*(Math.sin((1-r)*i)/n)+t*(Math.sin(r*i)/n)}(e.a[t],e.b[t],e.angle,K(i,0,1))+e.center[t]}function hh(e){if(e.z<=1)return sh[e.z+2*e.y+e.x];const t=mh(fh(e));return nh.fromPoints(t)}function uh(e,t,i){return F.vec3.scale(e,e,1-i),F.vec3.scaleAndAdd(e,e,t,i)}function dh(e,t,i){for(const r of e)F.vec3.transformMat4(r,r,t),F.vec3.scale(r,r,i)}function ph(e,t,i,r){const n=t/e.worldSize,o=e.globeMatrix;if(i.z<=1){const e=hh(i).getCorners();return dh(e,o,n),nh.fromPoints(e)}const s=fh(i,r),a=mh(s,Fl+oh(e._tileCoverLift));dh(a,o,n);const l=Number.MAX_VALUE,c=[-l,-l,-l],h=[l,l,l];if(s.contains(e.center)){for(const e of a)F.vec3.min(h,h,e),F.vec3.max(c,c,e);c[2]=0;const t=e.point,i=[t.x*n,t.y*n,0];return F.vec3.min(h,h,i),F.vec3.max(c,c,i),new nh(h,c)}if(e._tileCoverLift>0){for(const e of a)F.vec3.min(h,h,e),F.vec3.max(c,c,e);return new nh(h,c)}const u=[o[12]*n,o[13]*n,o[14]*n],d=s.getCenter(),p=K(e.center.lat,-tc,tc),f=K(d.lat,-tc,tc),m=Xl(e.center.lng),_=Yl(p);let g=m-Xl(d.lng);const y=_-Yl(f);g>.5?g-=1:g<-.5&&(g+=1);let x=0;if(Math.abs(g)>Math.abs(y))x=g>=0?1:3;else{x=y>=0?0:2;const e=[o[4]*n,o[5]*n,o[6]*n],t=-Math.sin(Z(y>=0?s.getSouth():s.getNorth()))*Fl;F.vec3.scaleAndAdd(u,u,e,t)}const v=a[x],b=a[(x+1)%4],w=new lh(v,b,u),T=[ch(w,0)||v[0],ch(w,1)||v[1],ch(w,2)||v[2]],S=Sh(e.zoom);if(S>0){const r=function({x:e,y:t,z:i},r,n,o,s){const a=1/(1<<i);let l=e*a,c=l+a,h=t*a,u=h+a,d=0;const p=(l+c)/2-o;return p>.5?d=-1:p<-.5&&(d=1),l=((l+d)*r-(o*=r))*n+o,c=((c+d)*r-o)*n+o,h=(h*r-(s*=r))*n+s,u=(u*r-s)*n+s,[[l,u,0],[c,u,0],[c,h,0],[l,h,0]]}(i,t,e._pixelsPerMercatorPixel,m,_);for(let e=0;e<a.length;e++)uh(a[e],r[e],S);const n=F.vec3.add([],r[x],r[(x+1)%4]);F.vec3.scale(n,n,.5),uh(T,n,S)}for(const e of a)F.vec3.min(h,h,e),F.vec3.max(c,c,e);return h[2]=Math.min(v[2],b[2]),F.vec3.min(h,h,T),F.vec3.max(c,c,T),new nh(h,c)}function fh({x:e,y:t,z:i},r=!1){const n=1/(1<<i),o=new $l(Jl(e*n),t===(1<<i)-1&&r?-90:Ql((t+1)*n)),s=new $l(Jl((e+1)*n),0===t&&r?90:Ql(t*n));return new Hl(o,s)}function mh(e,t=Fl){const i=Z(e.getNorth()),r=Z(e.getSouth()),n=Math.cos(i),o=Math.cos(r),s=Math.sin(i),a=Math.sin(r),l=e.getWest(),c=e.getEast();return[jl(o,a,l,t),jl(o,a,c,t),jl(n,s,c,t),jl(n,s,l,t)]}function _h(e,t,i,r){const n=1<<i.z,o=(e/Wi+i.x)/n;return Gl(Ql((t/Wi+i.y)/n),Jl(o),r)}function gh({min:e,max:t}){return 16383/Math.max(t[0]-e[0],t[1]-e[1],t[2]-e[2])}const yh=new Float64Array(16);function xh(e){const t=gh(e),i=F.mat4.fromScaling(yh,[t,t,t]);return F.mat4.translate(i,i,F.vec3.negate([],e.min))}function vh(e){const t=F.mat4.fromTranslation(yh,e.min),i=1/gh(e);return F.mat4.scale(t,t,[i,i,i])}function bh(e){const t=Wi/(2*Math.PI);return e/(2*Math.PI)/t}function wh(e,t){return Wi/(512*Math.pow(2,e))*gh(hh(t))}function Th(e,t,i,r,n){const o=bh(i),s=[e,t,-i/(2*Math.PI)],a=F.mat4.identity(new Float64Array(16));return F.mat4.translate(a,a,s),F.mat4.scale(a,a,[o,o,o]),F.mat4.rotateX(a,a,Z(-n)),F.mat4.rotateY(a,a,Z(-r)),a}function Sh(e){return J(5,6,e)}function Mh(e,t){const i=Gl(t.lat,t.lng),r=function(e){const t=Gl(e._center.lat,e._center.lng),i=F.vec3.fromValues(0,1,0);let r=F.vec3.cross([],i,t);const n=F.mat4.fromRotation([],-e.angle,t);r=F.vec3.transformMat4(r,r,n),F.mat4.fromRotation(n,-e._pitch,r);const o=F.vec3.normalize([],t);return F.vec3.scale(o,o,oh(e.cameraToCenterDistance/e.pixelsPerMeter)),F.vec3.transformMat4(o,o,n),F.vec3.add([],t,o)}(e),n=F.vec3.subtract([],r,i);return F.vec3.angle(n,i)}function Eh(e,t){return Mh(e,t)>Math.PI/2*1.01}const Ah=Z(85),Ih=Math.cos(Ah),Ch=Math.sin(Ah),Ph=F.mat4.create(),zh=e=>{const t=[];return"map"===e.paint.get("circle-pitch-alignment")&&t.push("PITCH_WITH_MAP"),"map"===e.paint.get("circle-pitch-scale")&&t.push("SCALE_WITH_MAP"),t};function Dh(e,t,i,r,n,o,s,a,l){if(o&&e.queryGeometry.isAboveHorizon)return!1;o&&(l*=e.pixelToTileUnitsFactor);const c=e.tileID.canonical,h=i.projection.upVectorScale(c,i.center.lat,i.worldSize).metersToTile;for(const u of t)for(const t of u){const u=t.add(a),d=n&&i.elevation?i.elevation.exaggeration()*n.getElevationAt(u.x,u.y,!0):0,p=i.projection.projectTilePoint(u.x,u.y,c);if(d>0){const e=i.projection.upVector(c,u.x,u.y);p.x+=e[0]*h*d,p.y+=e[1]*h*d,p.z+=e[2]*h*d}const f=o?u:Rh(p.x,p.y,p.z,r),m=o?e.tilespaceRays.map((e=>kh(e,d))):e.queryGeometry.screenGeometry,_=F.vec4.transformMat4([],[p.x,p.y,p.z,1],r);if(!s&&o?l*=_[3]/i.cameraToCenterDistance:s&&!o&&(l*=i.cameraToCenterDistance/_[3]),o){const e=Ql((t.y/Wi+c.y)/(1<<c.z));l/=i.projection.pixelsPerMeter(e,1)/Kl(1,e)}if(vc(m,f,l))return!0}return!1}function Rh(e,t,i,r){const n=F.vec4.transformMat4([],[e,t,i,1],r);return new U(n[0]/n[3],n[1]/n[3])}const Lh=F.vec3.fromValues(0,0,0),Oh=F.vec3.fromValues(0,0,1);function kh(e,t){const i=F.vec3.create();return Lh[2]=t,e.intersectsPlane(Lh,Oh,i),new U(i[0],i[1])}class Fh extends yc{}let Bh,Nh,Vh,Uh;function jh(e,{width:t,height:i},r,n){if(n){if(n instanceof Uint8ClampedArray)n=new Uint8Array(n.buffer);else if(n.length!==t*i*r)throw new RangeError("mismatched image size")}else n=new Uint8Array(t*i*r);return e.width=t,e.height=i,e.data=n,e}function Gh(e,t,i){const{width:r,height:n}=t;r===e.width&&n===e.height||(qh(e,t,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,r),height:Math.min(e.height,n)},i,null),e.width=r,e.height=n,e.data=t.data)}function qh(e,t,i,r,n,o,s,a){if(0===n.width||0===n.height)return t;if(n.width>e.width||n.height>e.height||i.x>e.width-n.width||i.y>e.height-n.height)throw new RangeError("out of range source coordinates for image copy");if(n.width>t.width||n.height>t.height||r.x>t.width-n.width||r.y>t.height-n.height)throw new RangeError("out of range destination coordinates for image copy");const l=e.data,c=t.data,h=4===o&&a;for(let a=0;a<n.height;a++){const u=((i.y+a)*e.width+i.x)*o,d=((r.y+a)*t.width+r.x)*o;if(h)for(let e=0;e<n.width;e++){const t=u+e*o+3,i=d+e*o;c[i+0]=255,c[i+1]=255,c[i+2]=255,c[i+3]=l[t]}else if(s)for(let e=0;e<n.width;e++){const t=u+e*o,i=d+e*o,r=l[t+3],n=new St(l[t+0]/255*r,l[t+1]/255*r,l[t+2]/255*r,r).toRenderColor(s).toArray();c[i+0]=n[0],c[i+1]=n[1],c[i+2]=n[2],c[i+3]=n[3]}else for(let e=0;e<n.width*o;e++)c[d+e]=l[u+e]}return t}ro(Fh,"HeatmapBucket",{omit:["layers"]});class Zh{constructor(e,t){jh(this,e,1,t)}resize(e){Gh(this,new Zh(e),1)}clone(){return new Zh({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,i,r,n){qh(e,t,i,r,n,1,null)}}class $h{constructor(e,t){jh(this,e,4,t)}resize(e){Gh(this,new $h(e),4)}replace(e,t){t?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new $h({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,i,r,n,o,s){qh(e,t,i,r,n,4,o,s)}}class Hh{constructor(e,t){this.width=e.width,this.height=e.height,this.data=t instanceof Uint8Array?new Float32Array(t.buffer):t}}function Wh(e){const t={},i=e.resolution||256,r=e.clips?e.clips.length:1,n=e.image||new $h({width:i,height:r}),o=(i,r,o)=>{t[e.evaluationKey]=o;const s=e.expression.evaluate(t);s&&(n.data[i+r+0]=Math.floor(255*s.r/s.a),n.data[i+r+1]=Math.floor(255*s.g/s.a),n.data[i+r+2]=Math.floor(255*s.b/s.a),n.data[i+r+3]=Math.floor(255*s.a))};if(e.clips)for(let t=0,n=0;t<r;++t,n+=4*i)for(let r=0,s=0;r<i;r++,s+=4){const a=r/(i-1),{start:l,end:c}=e.clips[t];o(n,s,l*(1-a)+c*a)}else for(let e=0,t=0;e<i;e++,t+=4)o(0,t,e/(i-1));return n}ro(Zh,"AlphaImage"),ro($h,"RGBAImage");const Xh=la([{name:"a_pos",components:2,type:"Int16"}],4),{members:Yh}=Xh;function Kh(e,t,i=2){const r=t&&t.length,n=r?t[0]*i:e.length;let o=Jh(e,0,n,i,!0);const s=[];if(!o||o.next===o.prev)return s;let a,l,c;if(r&&(o=function(e,t,i,r){const n=[];for(let i=0,o=t.length;i<o;i++){const s=Jh(e,t[i]*r,i<o-1?t[i+1]*r:e.length,r,!1);s===s.next&&(s.steiner=!0),n.push(cu(s))}n.sort(ou);for(let e=0;e<n.length;e++)i=su(n[e],i);return i}(e,t,o,i)),e.length>80*i){a=1/0,l=1/0;let t=-1/0,r=-1/0;for(let o=i;o<n;o+=i){const i=e[o],n=e[o+1];i<a&&(a=i),n<l&&(l=n),i>t&&(t=i),n>r&&(r=n)}c=Math.max(t-a,r-l),c=0!==c?32767/c:0}return eu(o,s,i,a,l,c,0),s}function Jh(e,t,i,r,n){let o;if(n===function(e,t,i,r){let n=0;for(let o=t,s=i-r;o<i;o+=r)n+=(e[s]-e[o])*(e[o+1]+e[s+1]),s=o;return n}(e,t,i,r)>0)for(let n=t;n<i;n+=r)o=xu(n/r|0,e[n],e[n+1],o);else for(let n=i-r;n>=t;n-=r)o=xu(n/r|0,e[n],e[n+1],o);return o&&pu(o,o.next)&&(vu(o),o=o.next),o}function Qh(e,t){if(!e)return e;t||(t=e);let i,r=e;do{if(i=!1,r.steiner||!pu(r,r.next)&&0!==du(r.prev,r,r.next))r=r.next;else{if(vu(r),r=t=r.prev,r===r.next)break;i=!0}}while(i||r!==t);return t}function eu(e,t,i,r,n,o,s){if(!e)return;!s&&o&&function(e,t,i,r){let n=e;do{0===n.z&&(n.z=lu(n.x,n.y,t,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==e);n.prevZ.nextZ=null,n.prevZ=null,function(e){let t,i=1;do{let r,n=e;e=null;let o=null;for(t=0;n;){t++;let s=n,a=0;for(let e=0;e<i&&(a++,s=s.nextZ,s);e++);let l=i;for(;a>0||l>0&&s;)0!==a&&(0===l||!s||n.z<=s.z)?(r=n,n=n.nextZ,a--):(r=s,s=s.nextZ,l--),o?o.nextZ=r:e=r,r.prevZ=o,o=r;n=s}o.nextZ=null,i*=2}while(t>1)}(n)}(e,r,n,o);let a=e;for(;e.prev!==e.next;){const l=e.prev,c=e.next;if(o?iu(e,r,n,o):tu(e))t.push(l.i,e.i,c.i),vu(e),e=c.next,a=c.next;else if((e=c)===a){s?1===s?eu(e=ru(Qh(e),t),t,i,r,n,o,2):2===s&&nu(e,t,i,r,n,o):eu(Qh(e),t,i,r,n,o,1);break}}}function tu(e){const t=e.prev,i=e,r=e.next;if(du(t,i,r)>=0)return!1;const n=t.x,o=i.x,s=r.x,a=t.y,l=i.y,c=r.y,h=n<o?n<s?n:s:o<s?o:s,u=a<l?a<c?a:c:l<c?l:c,d=n>o?n>s?n:s:o>s?o:s,p=a>l?a>c?a:c:l>c?l:c;let f=r.next;for(;f!==t;){if(f.x>=h&&f.x<=d&&f.y>=u&&f.y<=p&&hu(n,a,o,l,s,c,f.x,f.y)&&du(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function iu(e,t,i,r){const n=e.prev,o=e,s=e.next;if(du(n,o,s)>=0)return!1;const a=n.x,l=o.x,c=s.x,h=n.y,u=o.y,d=s.y,p=a<l?a<c?a:c:l<c?l:c,f=h<u?h<d?h:d:u<d?u:d,m=a>l?a>c?a:c:l>c?l:c,_=h>u?h>d?h:d:u>d?u:d,g=lu(p,f,t,i,r),y=lu(m,_,t,i,r);let x=e.prevZ,v=e.nextZ;for(;x&&x.z>=g&&v&&v.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=_&&x!==n&&x!==s&&hu(a,h,l,u,c,d,x.x,x.y)&&du(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,v.x>=p&&v.x<=m&&v.y>=f&&v.y<=_&&v!==n&&v!==s&&hu(a,h,l,u,c,d,v.x,v.y)&&du(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;x&&x.z>=g;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=_&&x!==n&&x!==s&&hu(a,h,l,u,c,d,x.x,x.y)&&du(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;v&&v.z<=y;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=_&&v!==n&&v!==s&&hu(a,h,l,u,c,d,v.x,v.y)&&du(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function ru(e,t){let i=e;do{const r=i.prev,n=i.next.next;!pu(r,n)&&fu(r,i,i.next,n)&&gu(r,n)&&gu(n,r)&&(t.push(r.i,i.i,n.i),vu(i),vu(i.next),i=e=n),i=i.next}while(i!==e);return Qh(i)}function nu(e,t,i,r,n,o){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&uu(s,e)){let a=yu(s,e);return s=Qh(s,s.next),a=Qh(a,a.next),eu(s,t,i,r,n,o,0),void eu(a,t,i,r,n,o,0)}e=e.next}s=s.next}while(s!==e)}function ou(e,t){return e.x-t.x}function su(e,t){const i=function(e,t){let i=t;const r=e.x,n=e.y;let o,s=-1/0;do{if(n<=i.y&&n>=i.next.y&&i.next.y!==i.y){const e=i.x+(n-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=r&&e>s&&(s=e,o=i.x<i.next.x?i:i.next,e===r))return o}i=i.next}while(i!==t);if(!o)return null;const a=o,l=o.x,c=o.y;let h=1/0;i=o;do{if(r>=i.x&&i.x>=l&&r!==i.x&&hu(n<c?r:s,n,l,c,n<c?s:r,n,i.x,i.y)){const t=Math.abs(n-i.y)/(r-i.x);gu(i,e)&&(t<h||t===h&&(i.x>o.x||i.x===o.x&&au(o,i)))&&(o=i,h=t)}i=i.next}while(i!==a);return o}(e,t);if(!i)return t;const r=yu(i,e);return Qh(r,r.next),Qh(i,i.next)}function au(e,t){return du(e.prev,e,t.prev)<0&&du(t.next,e,e.next)<0}function lu(e,t,i,r,n){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function cu(e){let t=e,i=e;do{(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next}while(t!==e);return i}function hu(e,t,i,r,n,o,s,a){return(n-s)*(t-a)>=(e-s)*(o-a)&&(e-s)*(r-a)>=(i-s)*(t-a)&&(i-s)*(o-a)>=(n-s)*(r-a)}function uu(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&fu(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(gu(e,t)&&gu(t,e)&&function(e,t){let i=e,r=!1;const n=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&n<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==e);return r}(e,t)&&(du(e.prev,e,t.prev)||du(e,t.prev,t))||pu(e,t)&&du(e.prev,e,e.next)>0&&du(t.prev,t,t.next)>0)}function du(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function pu(e,t){return e.x===t.x&&e.y===t.y}function fu(e,t,i,r){const n=_u(du(e,t,i)),o=_u(du(e,t,r)),s=_u(du(i,r,e)),a=_u(du(i,r,t));return n!==o&&s!==a||!(0!==n||!mu(e,i,t))||!(0!==o||!mu(e,r,t))||!(0!==s||!mu(i,e,r))||!(0!==a||!mu(i,t,r))}function mu(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function _u(e){return e>0?1:e<0?-1:0}function gu(e,t){return du(e.prev,e,e.next)<0?du(e,t,e.next)>=0&&du(e,e.prev,t)>=0:du(e,t,e.prev)<0||du(e,e.next,t)<0}function yu(e,t){const i=bu(e.i,e.x,e.y),r=bu(t.i,t.x,t.y),n=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=n,n.prev=i,r.next=i,i.prev=r,o.next=r,r.prev=o,r}function xu(e,t,i,r){const n=bu(e,t,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function vu(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function bu(e,t,i){return{i:e,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function wu(e,t){const i=e.length;if(i<=1)return[e];const r=[];let n,o;for(let t=0;t<i;t++){const i=pe(e[t]);0!==i&&(e[t].area=Math.abs(i),void 0===o&&(o=i<0),o===i<0?(n&&r.push(n),n=[e[t]]):n.push(e[t]))}if(n&&r.push(n),t>1)for(let e=0;e<r.length;e++)r[e].length<=t||(gi(r[e],t,1,r[e].length-1,Tu),r[e]=r[e].slice(0,t));return r}function Tu(e,t){return t.area-e.area}function Su(e,t){if(!e)return null;const i="string"==typeof e?e:e.getPrimary().id;t[i]||(t[i]=[]);const r=Jt.from(e).getPrimary();return t[i].push(r),r.serialize()}function Mu(e,t,i){const r=i.patternDependencies;let n=!1;for(const i of t){const t=i.paint.get(`${e}-pattern`);t.isConstant()||(n=!0),Su(t.constantOr(null),r)&&(n=!0)}return n}function Eu(e,t,i,r,n){const o=n.patternDependencies;for(const s of t){const t=s.paint.get(`${e}-pattern`).value;if("constant"!==t.kind){let e=t.evaluate({zoom:r},i,{},n.availableImages);e=e&&e.name?e.name:e;const a=Su(e,o);a&&(i.patterns[s.id]=a)}}return i}class Au{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.fqid)),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new ha,this.indexArray=new Ia,this.indexArray2=new Ta,this.programConfigurations=new zl(e.layers,{zoom:e.zoom,lut:e.lut}),this.segments=new nl,this.segments2=new nl,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.projection=e.projection}updateFootprints(e,t){}populate(e,t,i,r){this.hasPattern=Mu("fill",this.layers,t);const n=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,h=mc(s,e);if(!this.layers[0]._featureFilter.filter(new Ms(this.zoom),h,i))continue;const u=n?n.evaluate(h,{},i,t.availableImages):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:e?h.geometry:fc(s,i,r),patterns:{},sortKey:u};o.push(d)}n&&o.sort(((e,t)=>e.sortKey-t.sortKey));for(const r of o){const{geometry:n,index:o,sourceLayerIndex:s}=r;if(this.hasPattern){const e=Eu("fill",this.layers,r,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(r,n,o,i,{},t.availableImages,t.brightness);t.featureIndex.insert(e[o].feature,n,o,s,this.index)}}update(e,t,i,r,n,o,s){this.programConfigurations.updatePaintArrays(e,t,n,i,r,o,s)}addFeatures(e,t,i,r,n,o){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,i,r,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Yh),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,t,i,r,n,o=[],s){for(const e of wu(t,500)){let t=0;for(const i of e)t+=i.length;const i=this.segments.prepareSegment(t,this.layoutVertexArray,this.indexArray),r=i.vertexLength,n=[],o=[];for(const t of e){if(0===t.length)continue;t!==e[0]&&o.push(n.length/2);const i=this.segments2.prepareSegment(t.length,this.layoutVertexArray,this.indexArray2),r=i.vertexLength;this.layoutVertexArray.emplaceBack(t[0].x,t[0].y),this.indexArray2.emplaceBack(r+t.length-1,r),n.push(t[0].x),n.push(t[0].y);for(let e=1;e<t.length;e++)this.layoutVertexArray.emplaceBack(t[e].x,t[e].y),this.indexArray2.emplaceBack(r+e-1,r+e),n.push(t[e].x),n.push(t[e].y);i.vertexLength+=t.length,i.primitiveLength+=t.length}const s=Kh(n,o);for(let e=0;e<s.length;e+=3)this.indexArray.emplaceBack(r+s[e],r+s[e+1],r+s[e+2]);i.vertexLength+=t,i.primitiveLength+=s.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,n,o,r,s)}}let Iu,Cu,Pu,zu;ro(Au,"FillBucket",{omit:["layers","patternFeatures"]});class Du{constructor(e,t,i,r){if(this.triangleCount=t.length/3,this.min=new U(0,0),this.max=new U(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],0===this.triangleCount||0===e.length)return;const[n,o]=[e[0].clone(),e[0].clone()];for(let t=1;t<e.length;++t){const i=e[t];n.x=Math.min(n.x,i.x),n.y=Math.min(n.y,i.y),o.x=Math.max(o.x,i.x),o.y=Math.max(o.y,i.y)}if(r){const e=Math.ceil(Math.max(o.x-n.x,o.y-n.y)/r);i=Math.max(i,e)}if(0===i)return;this.min=n,this.max=o;const s=this.max.sub(this.min);s.x=Math.max(s.x,1),s.y=Math.max(s.y,1);const a=Math.max(s.x,s.y)/i;this.cellsX=Math.max(1,Math.ceil(s.x/a)),this.cellsY=Math.max(1,Math.ceil(s.y/a)),this.xScale=1/a,this.yScale=1/a;const l=[];for(let i=0;i<this.triangleCount;i++){const r=e[t[3*i+0]].sub(this.min),n=e[t[3*i+1]].sub(this.min),o=e[t[3*i+2]].sub(this.min),s=Ru(Math.floor(Math.min(r.x,n.x,o.x)),this.xScale,this.cellsX),c=Ru(Math.floor(Math.max(r.x,n.x,o.x)),this.xScale,this.cellsX),h=Ru(Math.floor(Math.min(r.y,n.y,o.y)),this.yScale,this.cellsY),u=Ru(Math.floor(Math.max(r.y,n.y,o.y)),this.yScale,this.cellsY),d=new U(0,0),p=new U(0,0),f=new U(0,0),m=new U(0,0);for(let e=h;e<=u;++e){d.y=p.y=e*a,f.y=m.y=(e+1)*a;for(let t=s;t<=c;++t)d.x=f.x=t*a,p.x=m.x=(t+1)*a,(Dc(r,n,o,d,p,m)||Dc(r,n,o,d,m,f))&&l.push({cellIdx:e*this.cellsX+t,triIdx:i})}}if(0===l.length)return;l.sort(((e,t)=>e.cellIdx-t.cellIdx||e.triIdx-t.triIdx));let c=0;for(;c<l.length;){const e=l[c].cellIdx,t={start:this.payload.length,len:0};for(;c<l.length&&l[c].cellIdx===e;)++t.len,this.payload.push(l[c++].triIdx);this.cells[e]=t}}_lazyInitLookup(){this.lookup||(this.lookup=new Uint8Array(Math.ceil(this.triangleCount/8))),this.lookup.fill(0)}queryPoint(e,t){if(0===this.triangleCount||0===this.cells.length)return;if(e.x>this.max.x||this.min.x>e.x||e.y>this.max.y||this.min.y>e.y)return;const i=Ru(e.x-this.min.x,this.xScale,this.cellsX),r=Ru(e.y-this.min.y,this.yScale,this.cellsY),n=this.cells[r*this.cellsX+i];if(n){this._lazyInitLookup();for(let e=0;e<n.len;e++){const i=this.payload[n.start+e],r=Math.floor(i/8),o=1<<i%8;if(!(this.lookup[r]&o)&&(this.lookup[r]|=o,t.push(i),t.length===this.triangleCount))return}}}query(e,t,i){if(0===this.triangleCount||0===this.cells.length)return;if(e.x>this.max.x||this.min.x>t.x)return;if(e.y>this.max.y||this.min.y>t.y)return;this._lazyInitLookup();const r=Ru(e.x-this.min.x,this.xScale,this.cellsX),n=Ru(t.x-this.min.x,this.xScale,this.cellsX),o=Ru(e.y-this.min.y,this.yScale,this.cellsY),s=Ru(t.y-this.min.y,this.yScale,this.cellsY);for(let e=o;e<=s;e++)for(let t=r;t<=n;t++){const r=this.cells[e*this.cellsX+t];if(r)for(let e=0;e<r.len;e++){const t=this.payload[r.start+e],n=Math.floor(t/8),o=1<<t%8;if(!(this.lookup[n]&o)&&(this.lookup[n]|=o,i.push(t),i.length===this.triangleCount))return}}}}function Ru(e,t,i){return Math.max(0,Math.min(i-1,Math.floor(e*t)))}ro(Du,"TriangleGridIndex");class Lu{constructor(e){this.zoom=e.zoom,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.fqid)),this.index=e.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.footprints=[]}updateFootprints(e,t){for(const i of this.footprints)t.push({footprint:i,id:e})}populate(e,t,i,r){const n=[];for(const{feature:t,id:o,index:s,sourceLayerIndex:a}of e){const e=this.layers[0]._featureFilter.needGeometry,l=mc(t,e);if(!this.layers[0]._featureFilter.filter(new Ms(this.zoom),l,i))continue;const c={id:o,properties:t.properties,type:t.type,sourceLayerIndex:a,index:s,geometry:e?l.geometry:fc(t,i,r),patterns:{}};n.push(c)}for(const r of n){const{geometry:n,index:o,sourceLayerIndex:s}=r;this.addFeature(r,n,o,i,{},t.availableImages,t.brightness),t.featureIndex.insert(e[o].feature,n,o,s,this.index)}}isEmpty(){return 0===this.footprints.length}uploadPending(){return!1}upload(e){}update(e,t,i,r,n,o,s){}destroy(){}addFeature(e,t,i,r,n,o=[],s){for(const e of wu(t,2)){const t=[],i=[],r=[],n=new U(1/0,1/0),o=new U(-1/0,-1/0);for(const s of e)if(0!==s.length){s!==e[0]&&r.push(i.length/2);for(let e=0;e<s.length;e++)i.push(s[e].x),i.push(s[e].y),t.push(s[e]),n.x=Math.min(n.x,s[e].x),n.y=Math.min(n.y,s[e].y),o.x=Math.max(o.x,s[e].x),o.y=Math.max(o.y,s[e].y)}const s=Kh(i,r),a=new Du(t,s,8,256);this.footprints.push({vertices:t,indices:s,grid:a,min:n,max:o})}}}ro(Lu,"ClipBucket",{omit:["layers"]});const Ou=la([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),ku=la([{name:"a_pos_end",components:4,type:"Int16"},{name:"a_angular_offset_factor",components:1,type:"Int16"}]),Fu=la([{name:"a_centroid_pos",components:2,type:"Uint16"}]),Bu=la([{name:"a_join_normal_inside",components:3,type:"Int16"}]),Nu=la([{name:"a_hidden_by_landmark",components:1,type:"Uint8"}]),Vu=la([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:Uu}=Ou;var ju,Gu,qu,Zu,$u,Hu,Wu,Xu={};function Yu(){if(Gu)return ju;Gu=1;var e=V();function t(e,t,r,n,o){this.properties={},this.extent=r,this.type=0,this._pbf=e,this._geometry=-1,this._keys=n,this._values=o,e.readFields(i,this,t)}function i(e,t,i){1==e?t.id=i.readVarint():2==e?function(e,t){for(var i=e.readVarint()+e.pos;e.pos<i;){var r=t._keys[e.readVarint()],n=t._values[e.readVarint()];t.properties[r]=n}}(i,t):3==e?t.type=i.readVarint():4==e&&(t._geometry=i.pos)}function r(e){for(var t,i,r=0,n=0,o=e.length,s=o-1;n<o;s=n++)r+=((i=e[s]).x-(t=e[n]).x)*(t.y+i.y);return r}return ju=t,t.types=["Unknown","Point","LineString","Polygon"],t.prototype.loadGeometry=function(){var t=this._pbf;t.pos=this._geometry;for(var i,r=t.readVarint()+t.pos,n=1,o=0,s=0,a=0,l=[];t.pos<r;){if(o<=0){var c=t.readVarint();n=7&c,o=c>>3}if(o--,1===n||2===n)s+=t.readSVarint(),a+=t.readSVarint(),1===n&&(i&&l.push(i),i=[]),i.push(new e(s,a));else{if(7!==n)throw new Error("unknown command "+n);i&&i.push(i[0].clone())}}return i&&l.push(i),l},t.prototype.bbox=function(){var e=this._pbf;e.pos=this._geometry;for(var t=e.readVarint()+e.pos,i=1,r=0,n=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;e.pos<t;){if(r<=0){var h=e.readVarint();i=7&h,r=h>>3}if(r--,1===i||2===i)(n+=e.readSVarint())<s&&(s=n),n>a&&(a=n),(o+=e.readSVarint())<l&&(l=o),o>c&&(c=o);else if(7!==i)throw new Error("unknown command "+i)}return[s,l,a,c]},t.prototype.toGeoJSON=function(e,i,n){var o,s,a=this.extent*Math.pow(2,n),l=this.extent*e,c=this.extent*i,h=this.loadGeometry(),u=t.types[this.type];function d(e){for(var t=0;t<e.length;t++){var i=e[t];e[t]=[360*(i.x+l)/a-180,360/Math.PI*Math.atan(Math.exp((180-360*(i.y+c)/a)*Math.PI/180))-90]}}switch(this.type){case 1:var p=[];for(o=0;o<h.length;o++)p[o]=h[o][0];d(h=p);break;case 2:for(o=0;o<h.length;o++)d(h[o]);break;case 3:for(h=function(e){var t=e.length;if(t<=1)return[e];for(var i,n,o=[],s=0;s<t;s++){var a=r(e[s]);0!==a&&(void 0===n&&(n=a<0),n===a<0?(i&&o.push(i),i=[e[s]]):i.push(e[s]))}return i&&o.push(i),o}(h),o=0;o<h.length;o++)for(s=0;s<h[o].length;s++)d(h[o][s])}1===h.length?h=h[0]:u="Multi"+u;var f={type:"Feature",geometry:{type:u,coordinates:h},properties:this.properties};return"id"in this&&(f.id=this.id),f},ju}function Ku(){if(Zu)return qu;Zu=1;var e=Yu();function t(e,t){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(i,this,t),this.length=this._features.length}function i(e,t,i){15===e?t.version=i.readVarint():1===e?t.name=i.readString():5===e?t.extent=i.readVarint():2===e?t._features.push(i.pos):3===e?t._keys.push(i.readString()):4===e&&t._values.push(function(e){for(var t=null,i=e.readVarint()+e.pos;e.pos<i;){var r=e.readVarint()>>3;t=1===r?e.readString():2===r?e.readFloat():3===r?e.readDouble():4===r?e.readVarint64():5===r?e.readVarint():6===r?e.readSVarint():7===r?e.readBoolean():null}return t}(i))}return qu=t,t.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var i=this._pbf.readVarint()+this._pbf.pos;return new e(this._pbf,i,this.extent,this._keys,this._values)},qu}function Ju(){return Wu||(Wu=1,Xu.VectorTile=function(){if(Hu)return $u;Hu=1;var e=Ku();function t(t,i,r){if(3===t){var n=new e(r,r.readVarint()+r.pos);n.length&&(i[n.name]=n)}}return $u=function(e,i){this.layers=e.readFields(t,{},i)},$u}(),Xu.VectorTileFeature=Yu(),Xu.VectorTileLayer=Ku()),Xu}var Qu=Ju();class ed extends U{constructor(e,t,i){super(e,t),this.z=i}}class td extends ed{constructor(e,t,i,r){super(e,t,i),this.w=r}}function id(e,t,i,r){const n=[],o=0===r?(e,t,i,r,n,o)=>{e.push(new U(o,i+(o-t)/(r-t)*(n-i)))}:(e,t,i,r,n,o)=>{e.push(new U(t+(o-i)/(n-i)*(r-t),o))};for(const s of e){const e=[];for(const n of s){if(n.length<=2)continue;const s=[];for(let e=0;e<n.length-1;e++){const a=n[e].x,l=n[e].y,c=n[e+1].x,h=n[e+1].y,u=0===r?a:l,d=0===r?c:h;u<t?d>t&&o(s,a,l,c,h,t):u>i?d<i&&o(s,a,l,c,h,i):s.push(n[e]),d<t&&u>=t&&o(s,a,l,c,h,t),d>i&&u<=i&&o(s,a,l,c,h,i)}let a=n[n.length-1];const l=0===r?a.x:a.y;l>=t&&l<=i&&s.push(a),s.length&&(a=s[s.length-1],s[0].x===a.x&&s[0].y===a.y||s.push(s[0]),e.push(s))}e.length&&n.push(e)}return n}function rd(e,t,i,r){const n="x"===i?"y":"x",o=(r-e[i])/(t[i]-e[i]);e[n]=e[n]+(t[n]-e[n])*o,e[i]=r,e.hasOwnProperty("z")&&(e.z=Et(e.z,t.z,o)),e.hasOwnProperty("w")&&(e.w=Et(e.w,t.w,o))}function nd(e,t,i,r){const n=i,o=r;for(const i of["x","y"]){let r=e,s=t;r[i]>=s[i]&&(r=t,s=e),r[i]<n&&s[i]>n&&rd(r,s,i,n),r[i]<o&&s[i]>o&&rd(s,r,i,o)}}const od=Number.MAX_SAFE_INTEGER;function sd(e,t,i,r){return e.order<t||e.order===od||!(e.clipMask&i)||function(e,t){return 0!==t.length&&void 0===t.find((t=>t===e))}(r,e.clipScope)}function ad(e,t){return e.x-t.x||e.y-t.y}function ld(e,t){return 0===ad(e.min,t.min)&&0===ad(e.max,t.max)}function cd(e,t){return!(e.min.x>t.max.x||e.max.x<t.min.x||e.min.y>t.max.y||e.max.y<t.min.y)}function hd(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i].sourceId!==t[i].sourceId||!ld(e[i],t[i])||e[i].order!==t[i].order||e[i].clipMask!==t[i].clipMask||!j(e[i].clipScope,t[i].clipScope))return!1;return!0}function ud(e,t,i){const r=1/Wi,n=1/(1<<i.canonical.z),o=(t.x*r+i.canonical.x)*n+i.wrap,s=(t.y*r+i.canonical.y)*n;return{min:new U((e.x*r+i.canonical.x)*n+i.wrap,(e.y*r+i.canonical.y)*n),max:new U(o,s)}}function dd(e,t,i){const r=1<<i.canonical.z,n=((t.x-i.wrap)*r-i.canonical.x)*Wi,o=(t.y*r-i.canonical.y)*Wi;return{min:new U(((e.x-i.wrap)*r-i.canonical.x)*Wi,(e.y*r-i.canonical.y)*Wi),max:new U(n,o)}}function pd(e,t,i,r,n,o,s){const a=e.indices,l=e.vertices,c=[];for(let h=r;h<r+n;h+=3){const r=t[i[h+0]+o],n=t[i[h+1]+o],u=t[i[h+2]+o],d=Math.min(r.x,n.x,u.x),p=Math.max(r.x,n.x,u.x),f=Math.min(r.y,n.y,u.y),m=Math.max(r.y,n.y,u.y);c.length=0,e.grid.query(new U(d,f),new U(p,m),c);for(let e=0;e<c.length;e++){const t=c[e];if(Dc(l[a[3*t+0]],l[a[3*t+1]],l[a[3*t+2]],r,n,u,s))return!0}}return!1}function fd(e,t,i,r){if(!e||!i)return!1;let n=e.vertices;if(!t.canonical.equals(r.canonical)||t.wrap!==r.wrap){if(i.vertices.length<e.vertices.length)return fd(i,r,e,t);const o=t.canonical,s=r.canonical,a=Math.pow(2,s.z-o.z);n=e.vertices.map((e=>new U((e.x+o.x*Wi)*a-s.x*Wi,(e.y+o.y*Wi)*a-s.y*Wi)))}return pd(i,n,e.indices,0,e.indices.length,0,0)}function md(e,t,i,r){const n=Math.pow(2,r.z-i.z);return new U((e+i.x*Wi)*n-r.x*Wi,(t+i.y*Wi)*n-r.y*Wi)}function _d(e,t){const i=[];t.grid.queryPoint(e,i);const r=t.indices,n=t.vertices;for(let t=0;t<i.length;t++){const o=i[t];if(Ic([n[r[3*o+0]],n[r[3*o+1]],n[r[3*o+2]]],e))return!0}return!1}const gd=[new U(0,0),new U(Wi,0),new U(Wi,Wi),new U(0,Wi)];function yd(e,t){const i=[];let r=[];if(!t||e.length<2)return[e];if(2===e.length)return Pc(e[0],e[1],gd)?[e]:[];for(let t=0;t<e.length+2;t++){const n=e[t%e.length],o=e[(t+1)%e.length],s=Pc(0===t?e[e.length-1]:e[(t-1)%e.length],n,gd),a=Pc(n,o,gd),l=s||a;l&&r.push(n),l&&a||r.length>0&&(r.length>1&&i.push(r),r=[])}return r.length>1&&i.push(r),i}const xd=Qu.VectorTileFeature.types,vd=["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"],bd=["fill-extrusion-flood-light-ground-radius"],wd=Math.pow(2,13),Td=Math.pow(2,15)-1,Sd=new U(0,1),Md=2147483648;function Ed(e,t,i,r,n,o,s,a){e.emplaceBack((t<<1)+s,(i<<1)+o,(Math.floor(r*wd)<<1)+n,Math.round(a))}function Ad(e,t,i){e.emplaceBack(t.x*Wi,t.y*Wi,i?1:0)}function Id(e,t,i,r,n,o){e.emplaceBack(t.x,t.y,(i.x<<1)+r,(i.y<<1)+n,o)}function Cd(e,t,i){const r=16384;e.emplaceBack(t.x,t.y,t.z,i[0]*r,i[1]*r,i[2]*r)}class Pd{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class zd{constructor(){this.centroidXY=new U(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 U(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new U(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0}span(){return new U(this.max.x-this.min.x,this.max.y-this.min.y)}}class Dd{constructor(){this.acc=new U(0,0),this.accCount=0,this.centroidDataIndex=0}startRing(e,t){e.min.x===Number.MAX_VALUE&&(e.min.x=e.max.x=t.x,e.min.y=e.max.y=t.y)}appendEdge(e,t,i){this.accCount++,this.acc._add(t);let r=!!this.borders;t.x<e.min.x?(e.min.x=t.x,r=!0):t.x>e.max.x&&(e.max.x=t.x,r=!0),t.y<e.min.y?(e.min.y=t.y,r=!0):t.y>e.max.y&&(e.max.y=t.y,r=!0),((0===t.x||t.x===Wi)&&t.x===i.x)!=((0===t.y||t.y===Wi)&&t.y===i.y)&&this.processBorderOverlap(t,i),r&&this.checkBorderIntersection(t,i)}checkBorderIntersection(e,t){t.x<0!=e.x<0&&this.addBorderIntersection(0,Et(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>Wi!=e.x>Wi&&this.addBorderIntersection(1,Et(t.y,e.y,(Wi-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,Et(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>Wi!=e.y>Wi&&this.addBorderIntersection(3,Et(t.x,e.x,(Wi-t.y)/(e.y-t.y)))}addBorderIntersection(e,t){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[e];t<i[0]&&(i[0]=t),t>i[1]&&(i[1]=t)}processBorderOverlap(e,t){if(e.x===t.x){if(e.y===t.y)return;const i=0===e.x?0:1;this.addBorderIntersection(i,t.y),this.addBorderIntersection(i,e.y)}else{const i=0===e.y?2:3;this.addBorderIntersection(i,t.x),this.addBorderIntersection(i,e.x)}}centroid(){return 0===this.accCount?new U(0,0):new U(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce(((e,t)=>e+ +(t[0]!==Number.MAX_VALUE)),0):0}}function Rd(e,t){const i=e.add(t)._unit(),r=K(e.x*i.x+e.y*i.y,-1,1);var n,o,s;return s=Math.acos(r),Math.min(4,Math.max(-4,Math.tan(s)))/4*Td*((n=e).x*(o=t).y-n.y*o.x<0?-1:1)}const Ld=[e=>e.x<0,e=>e.x>Wi,e=>e.y<0,e=>e.y>Wi];function Od(e,t,i,r){const n=[4];if(0===r)return n;i._mult(r);const o=e.sub(i),s=t.sub(i),a=[e,t,o,s];for(let e=0;e<4;e++)for(const t of a)if(Ld[e](t)){n.push(e);break}return n}class kd{constructor(e){this.vertexArray=new pa,this.indexArray=new Ia,this.programConfigurations=new zl(e.layers,{zoom:e.zoom,lut:e.lut},(e=>bd.includes(e))),this._segments=new nl,this.hiddenByLandmarkVertexArray=new ja,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new nl}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(e,t,i,r=!1){const n=e.length;if(n>2){let o=Math.max(0,this._segments.get().length-1);const s=this._segments._prepareSegment(4*n,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);let a;o!==this._segments.get().length-1&&(o++,this._segmentToGroundQuads[o]=[],this._segmentToRegionTriCounts[o]=[0,0,0,0,0]);{const t=e[0],i=e[1];a=Rd(t.sub(e[n-1])._perp()._unit(),i.sub(t)._perp()._unit())}for(let l=0;l<n;l++){const c=l===n-1?0:l+1,h=e[l],u=e[c],d=e[c===n-1?0:c+1],p=u.sub(h)._perp()._unit(),f=Rd(p,d.sub(u)._perp()._unit()),m=a,_=f;if(Ud(h,u,t)||r&&jd(h,t)&&jd(u,t)){a=f;continue}const g=s.vertexLength;Id(this.vertexArray,h,u,1,1,m),Id(this.vertexArray,h,u,1,0,m),Id(this.vertexArray,h,u,0,1,_),Id(this.vertexArray,h,u,0,0,_),s.vertexLength+=4;const y=Od(h,u,p,i);for(const e of y)this._segmentToGroundQuads[o].push({id:g,region:e}),this._segmentToRegionTriCounts[o][e]+=2,s.primitiveLength+=2;a=f}}}prepareBorderSegments(){if(!this.hasData())return;const e=this._segments.get(),t=e.length;for(let e=0;e<t;e++)this._segmentToGroundQuads[e].sort(((e,t)=>e.region-t.region));for(let i=0;i<t;i++){const t=this._segmentToGroundQuads[i],r=e[i],n=this._segmentToRegionTriCounts[i];n.reduce(((e,t)=>e+t),0);let o=0;for(let e=0;e<=4;e++){const t=n[e];if(0!==t){let i=this.regionSegments[e];i||(i=this.regionSegments[e]=new nl);const n={vertexOffset:r.vertexOffset,primitiveOffset:r.primitiveOffset+o,vertexLength:r.vertexLength,primitiveLength:t};i.get().push(n)}o+=t}for(let e=0;e<t.length;e++){const i=t[e].id;this.indexArray.emplaceBack(i,i+1,i+3),this.indexArray.emplaceBack(i,i+3,i+2)}}this._segmentToGroundQuads=null,this._segmentToRegionTriCounts=null,this._segments.destroy(),this._segments=null}addPaintPropertiesData(e,t,i,r,n,o){this.hasData()&&this.programConfigurations.populatePaintArrays(this.vertexArray.length,e,t,i,r,n,o)}upload(e){this.hasData()&&(this.vertexBuffer=e.createVertexBuffer(this.vertexArray,ku.members),this.indexBuffer=e.createIndexBuffer(this.indexArray))}uploadPaintProperties(e){this.hasData()&&this.programConfigurations.upload(e)}update(e,t,i,r,n,o,s){this.hasData()&&this.programConfigurations.updatePaintArrays(e,t,i,r,n,o,s)}updateHiddenByLandmark(e){if(!this.hasData())return;const t=e.groundVertexCount+e.groundVertexArrayOffset;if(0===e.groundVertexCount)return;const i=e.flags&Md?1:0;for(let r=e.groundVertexArrayOffset;r<t;++r)this.hiddenByLandmarkVertexArray.emplace(r,i);this._needsHiddenByLandmarkUpdate=!0}uploadHiddenByLandmark(e){this.hasData()&&this._needsHiddenByLandmarkUpdate&&(!this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexArray.length>0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,Nu.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 e=0;e<=4;e++){const t=this.regionSegments[e];t&&t.destroy()}}}}class Fd{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.fqid)),this.index=e.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=e.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Ia,this.footprintVertices=new ha,this.footprintSegments=[],this.layoutVertexArray=new da,this.centroidVertexArray=new Qa,this.wallVertexArray=new tl,this.indexArray=new Ia,this.programConfigurations=new zl(e.layers,{zoom:e.zoom,lut:e.lut},(e=>vd.includes(e))),this.segments=new nl,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.groundEffect=new kd(e),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[]}updateFootprints(e,t){}populate(e,t,i,r){this.features=[],this.hasPattern=Mu("fill-extrusion",this.layers,t),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.selfDEMTileTimestamp=Number.MAX_VALUE,this.borderDEMTileTimestamp=[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE],this.tileToMeter=oc(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=0!==this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1);for(const{feature:n,id:o,index:s,sourceLayerIndex:a}of e){const e=this.layers[0]._featureFilter.needGeometry,l=mc(n,e);if(!this.layers[0]._featureFilter.filter(new Ms(this.zoom),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:e?l.geometry:fc(n,i,r),properties:n.properties,type:n.type,patterns:{}},h=this.layoutVertexArray.length,u="Polygon"===xd[c.type];if(this.hasPattern)this.features.push(Eu("fill-extrusion",this.layers,c,this.zoom,t));else if(this.wallMode)for(const e of c.geometry)for(const n of yd(e,u))this.addFeature(c,[n],s,i,{},t.availableImages,r,t.brightness);else this.addFeature(c,c.geometry,s,i,{},t.availableImages,r,t.brightness);t.featureIndex.insert(n,c.geometry,s,a,this.index,h)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(e,t,i,r,n,o){for(const e of this.features){const s="Polygon"===xd[e.type],{geometry:a}=e;if(this.wallMode)for(const l of a)for(const a of yd(l,s))this.addFeature(e,[a],e.index,t,i,r,n,o);else this.addFeature(e,a,e.index,t,i,r,n,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(e,t,i,r,n,o,s){this.programConfigurations.updatePaintArrays(e,t,n,i,r,o,s),this.groundEffect.update(e,t,n,i,r,o,s)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Uu),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.wallVertexBuffer=e.createVertexBuffer(this.wallVertexArray,Bu.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,Vu.members,!0)),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0}uploadCentroid(e){this.groundEffect.uploadHiddenByLandmark(e),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Fu.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,t,i,r,n,o,s,a){const l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(e,{})/this.tileToMeter,c=[new U(0,0),new U(Wi,Wi)],h=s.projection,u="globe"===h.name,d=this.wallMode||"Polygon"===xd[e.type],p=new Dd;p.centroidDataIndex=this.centroidData.length;const f=new zd,m=this.layers[0].paint.get("fill-extrusion-base").evaluate(e,{},r)<=0,_=this.layers[0].paint.get("fill-extrusion-height").evaluate(e,{},r);let g;if(f.height=_,f.vertexArrayOffset=this.layoutVertexArray.length,f.groundVertexArrayOffset=this.groundEffect.vertexArray.length,u&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new xa),this.wallMode){if(u)return void ue("Non zero fill-extrusion-line-width is not yet supported on globe.");if(1!==t.length)return;g=function(e){const t=e[0].x===e[e.length-1].x&&e[0].y===e[e.length-1].y,i=function(e){let t=0;const i=e.length;for(let r=0;r<i;r++)t+=(e[(r+1)%i].x-e[r].x)*(e[(r+1)%i].y+e[r].y);return t>=0}(e);i||(e=e.reverse());const r={geometry:[],joinNormals:[],indices:[]},n=[],o=[],s=[];let a=e.length;for(;a>=2&&e[a-1].equals(e[a-2]);)a--;if(a<(t?3:2))return r;let l,c,h,u,d,p=0;for(;p<a-1&&e[p].equals(e[p+1]);)p++;t&&(l=e[a-2],d=e[p].sub(l)._unit()._perp());for(let i=p;i<a;i++){if(h=i===a-1?t?e[p+1]:void 0:e[i+1],h&&e[i].equals(h))continue;d&&(u=d),l&&(c=l),l=e[i],d=h?h.sub(l)._unit()._perp():u,u=u||d;let r=u.add(d);0===r.x&&0===r.y||r._unit();const f=r.x*d.x+r.y*d.y,m=0!==f?1/f:1/0,_=u.x*d.y-u.y*d.x>0;let g="miter";const y=2;"miter"===g&&m>y&&(g="bevel"),"bevel"===g&&(m>100&&(g="flipbevel"),m<y&&(g="miter"));const x=(e,t,i,r)=>{const a=new U(e.x,e.y),l=new U(e.x,e.y);a.x+=t.x*r,a.y+=t.y*r,l.x-=t.x*Math.max(i,1),l.y-=t.y*Math.max(i,1),s.push(t),n.push(a),o.push(l)};if("miter"===g)r._mult(m),x(l,r,0,0);else if("flipbevel"===g)r=d.mult(-1),x(l,r,0,0),x(l,r.mult(-1),0,0);else{const e=-Math.sqrt(m*m-1),t=_?e:0,i=_?0:e;c&&x(l,u,t,i),h&&x(l,d,t,i)}}r.geometry=[...n,...o.reverse(),n[0]],r.joinNormals=[...s,...s.reverse(),s[s.length-1]];const f=r.geometry.length-1;for(let e=0;e<f/2;e++)if(e+1<f/2){let t=e,i=e+1,n=f-1-e,o=f-2-e;t=0===t?f-1:t-1,i=0===i?f-1:i-1,n=0===n?f-1:n-1,o=0===o?f-1:o-1,r.indices.push(n),r.indices.push(i),r.indices.push(t),r.indices.push(n),r.indices.push(o),r.indices.push(i)}return r}(t[0]),t=[g.geometry]}const y=(e,t)=>e<(t.length-1)/2||e===t.length-1,x=this.wallMode?[t]:wu(t,500);for(let e=x.length-1;e>=0;e--){const t=x[e];(0===t.length||(v=t[0]).every((e=>e.x<=0))||v.every((e=>e.x>=Wi))||v.every((e=>e.y<=0))||v.every((e=>e.y>=Wi)))&&x.splice(e,1)}var v;let b;if(u)b=$d(x,c,r);else{b=[];for(const e of x)b.push({polygon:e,bounds:c})}const w=d?this.edgeRadius:0,T=w>0&&this.zoom<17,S=(e,t)=>{if(0===e.length)return!1;const i=e[e.length-1];return t.x===i.x&&t.y===i.y};for(const{polygon:e,bounds:t}of b){let i=0,n=0;for(const t of e)d&&!t[0].equals(t[t.length-1])&&t.push(t[0]),n+=d?t.length-1:t.length;const o=this.segments.prepareSegment((d?5:4)*n,this.layoutVertexArray,this.indexArray);f.footprintSegIdx<0&&(f.footprintSegIdx=this.footprintSegments.length),f.polygonSegIdx<0&&(f.polygonSegIdx=this.polygonSegments.length);const s={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},a=new Pd;if(a.vertexOffset=this.footprintVertices.length,a.indexOffset=3*this.footprintIndices.length,a.ringIndices=[],d){const n=[],s=[];i=o.vertexLength;for(let i=0;i<e.length;i++){const c=e[i];c.length&&0!==i&&s.push(n.length/2);const d=[];let p,f;p=c[1].sub(c[0])._perp()._unit(),a.ringIndices.push(c.length-1);for(let e=1;e<c.length;e++){const t=c[e],i=c[e===c.length-1?1:e+1],s=t.clone();if(w){f=i.sub(t)._perp()._unit();const e=p.add(f)._unit(),r=w*Math.min(4,1/(p.x*e.x+p.y*e.y));s.x+=r*e.x,s.y+=r*e.y,s.x=Math.round(s.x),s.y=Math.round(s.y),p=f}if(!m||0!==w&&!T||S(d,s)||d.push(s),Ed(this.layoutVertexArray,s.x,s.y,0,0,1,1,0),this.wallMode){const t=y(e,c);Ad(this.wallVertexArray,g.joinNormals[e],!t)}o.vertexLength++,this.footprintVertices.emplaceBack(t.x,t.y),n.push(t.x,t.y),u&&Cd(this.layoutVertexExtArray,h.projectTilePoint(s.x,s.y,r),h.upVector(r,s.x,s.y))}m&&(0===w||T)&&(0!==d.length&&S(d,d[0])&&d.pop(),this.groundEffect.addData(d,t,l))}const c=this.wallMode?g.indices:Kh(n,s);for(let e=0;e<c.length;e+=3)this.footprintIndices.emplaceBack(a.vertexOffset+c[e+0],a.vertexOffset+c[e+1],a.vertexOffset+c[e+2]),this.indexArray.emplaceBack(i+c[e],i+c[e+2],i+c[e+1]),o.primitiveLength++;a.indexCount+=c.length,a.vertexCount+=this.footprintVertices.length-a.vertexOffset}for(let n=0;n<e.length;n++){const s=e[n];p.startRing(f,s[0]);let a=s.length>4&&Gd(s[s.length-2],s[0],s[1]),c=w?Nd(s[s.length-2],s[0],s[1],w):0;const _=[];let x,v,b;v=s[1].sub(s[0])._perp()._unit();let T=!0;for(let e=1,n=0;e<s.length;e++){let l=s[e-1],d=s[e];const M=s[e===s.length-1?1:e+1];if(p.appendEdge(f,d,l),Ud(d,l,t)){w&&(v=M.sub(d)._perp()._unit(),T=!T);continue}const E=d.sub(l)._perp(),A=E.x/(Math.abs(E.x)+Math.abs(E.y)),I=E.y>0?1:0,C=l.dist(d);if(n+C>32768&&(n=0),w){b=M.sub(d)._perp()._unit();let e=Vd(l,d,M,Bd(v,b),w);isNaN(e)&&(e=0);const t=d.sub(l)._unit();l=l.add(t.mult(c))._round(),d=d.add(t.mult(-e))._round(),c=e,v=b,m&&this.zoom>=17&&(S(_,l)||_.push(l),S(_,d)||_.push(d))}const P=o.vertexLength,z=s.length>4&&Gd(l,d,M);let D=qd(n,a,T);if(Ed(this.layoutVertexArray,l.x,l.y,A,I,0,0,D),Ed(this.layoutVertexArray,l.x,l.y,A,I,0,1,D),this.wallMode){const t=y(e-1,s),i=g.joinNormals[e-1];Ad(this.wallVertexArray,i,t),Ad(this.wallVertexArray,i,t)}if(n+=C,D=qd(n,z,!T),a=z,Ed(this.layoutVertexArray,d.x,d.y,A,I,0,0,D),Ed(this.layoutVertexArray,d.x,d.y,A,I,0,1,D),this.wallMode){const t=y(e,s),i=g.joinNormals[e];Ad(this.wallVertexArray,i,t),Ad(this.wallVertexArray,i,t)}if(o.vertexLength+=4,this.indexArray.emplaceBack(P+0,P+1,P+2),this.indexArray.emplaceBack(P+1,P+3,P+2),o.primitiveLength+=2,w){const r=i+(1===e?s.length-2:e-2),n=1===e?i:r+1;if(this.indexArray.emplaceBack(P+1,r,P+3),this.indexArray.emplaceBack(r,n,P+3),o.primitiveLength+=2,void 0===x&&(x=P),!Ud(M,s[e],t)){const t=e===s.length-1?x:o.vertexLength;this.indexArray.emplaceBack(P+2,P+3,t),this.indexArray.emplaceBack(P+3,t+1,t),this.indexArray.emplaceBack(P+3,n,t+1),o.primitiveLength+=3}T=!T}if(u){const e=this.layoutVertexExtArray,t=h.projectTilePoint(l.x,l.y,r),i=h.projectTilePoint(d.x,d.y,r),n=h.upVector(r,l.x,l.y),o=h.upVector(r,d.x,d.y);Cd(e,t,n),Cd(e,t,n),Cd(e,i,o),Cd(e,i,o)}}d&&(i+=s.length-1),m&&w&&this.zoom>=17&&(0!==_.length&&S(_,_[0])&&_.pop(),this.groundEffect.addData(_,t,l,w>0))}this.footprintSegments.push(a),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++f.footprintSegLen,++f.polygonSegLen}if(f.vertexCount=this.layoutVertexArray.length-f.vertexArrayOffset,f.groundVertexCount=this.groundEffect.vertexArray.length-f.groundVertexArrayOffset,0!==f.vertexCount){if(f.centroidXY=p.borders?Sd:this.encodeCentroid(p,f),this.centroidData.push(f),p.borders){this.featuresOnBorder.push(p);const e=this.featuresOnBorder.length-1;for(let t=0;t<p.borders.length;t++)p.borders[t][0]!==Number.MAX_VALUE&&this.borderFeatureIndices[t].push(e)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,n,o,r,a),this.groundEffect.addPaintPropertiesData(e,i,n,o,r,a),this.maxHeight=Math.max(this.maxHeight,_)}}sortBorders(){for(let e=0;e<this.borderFeatureIndices.length;e++)this.borderFeatureIndices[e].sort(((t,i)=>this.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[i].borders[e][0]))}splitToSubtiles(){const e=[];for(let t=0;t<this.centroidData.length;t++){const i=this.centroidData[t],r=+(i.min.y+i.max.y>Wi),n=2*r+(+(i.min.x+i.max.x>Wi)^r);for(let r=0;r<i.polygonSegLen;r++){const o=i.polygonSegIdx+r;e.push({centroidIdx:t,subtile:n,polygonSegmentIdx:o,triangleSegmentIdx:this.polygonSegments[o].triangleSegIdx})}}const t=new Ia;e.sort(((e,t)=>e.triangleSegmentIdx===t.triangleSegmentIdx?e.subtile-t.subtile:e.triangleSegmentIdx-t.triangleSegmentIdx));let i=0,r=0,n=0;for(const t of e){if(t.triangleSegmentIdx!==i)break;n++}const o=e.length;for(;r!==e.length;){i=e[r].triangleSegmentIdx;let s=0,a=r,l=r;for(let t=a;t<n&&e[t].subtile===s;t++)l++;for(;a!==n;){const r=e[a];s=r.subtile;const o=this.centroidData[r.centroidIdx].min.clone(),c=this.centroidData[r.centroidIdx].max.clone(),h={vertexOffset:this.segments.segments[i].vertexOffset,primitiveOffset:t.length,vertexLength:this.segments.segments[i].vertexLength,primitiveLength:0,sortKey:void 0,vaos:{}};for(let i=a;i<l;i++){const r=e[i],n=this.polygonSegments[r.polygonSegmentIdx],s=this.centroidData[r.centroidIdx].min,a=this.centroidData[r.centroidIdx].max,l=this.indexArray.uint16;for(let e=n.triangleArrayOffset;e<n.triangleArrayOffset+n.triangleCount;e++)t.emplaceBack(l[3*e],l[3*e+1],l[3*e+2]);h.primitiveLength+=n.triangleCount,o.x=Math.min(o.x,s.x),o.y=Math.min(o.y,s.y),c.x=Math.max(c.x,a.x),c.y=Math.max(c.y,a.y)}h.primitiveLength>0&&this.triangleSubSegments.push({segment:h,min:o,max:c}),a=l;for(let t=a;t<n&&e[t].subtile===e[a].subtile;t++)l++}r=n;for(let t=r;t<o&&e[t].triangleSegmentIdx===e[r].triangleSegmentIdx;t++)n++}t._trim(),this.indexArray=t}getVisibleSegments(e,t,i){const r=new nl;if(this.wallMode){for(const e of this.triangleSubSegments)r.segments.push(e.segment);return r}let n=0,o=0;const s=1<<e.canonical.z;if(t){const i=t.getMinMaxForTile(e);i&&(n=i.min,o=i.max)}o+=this.maxHeight;const a=e.toUnwrapped();let l;const c=[a.canonical.x/s+a.wrap,a.canonical.y/s],h=[(a.canonical.x+1)/s+a.wrap,(a.canonical.y+1)/s],u=(e,t,i)=>[e[0]*(1-i[0])+t[0]*i[0],e[1]*(1-i[1])+t[1]*i[1]],d=[],p=[];for(const e of this.triangleSubSegments){d[0]=e.min.x/Wi,d[1]=e.min.y/Wi,p[0]=e.max.x/Wi,p[1]=e.max.y/Wi;const t=u(c,h,d),s=u(c,h,p);if(0===new nh([t[0],t[1],n],[s[0],s[1],o]).intersectsPrecise(i)){l&&(r.segments.push(l),l=void 0);continue}const a=e.segment;l&&l.vertexOffset!==a.vertexOffset&&(r.segments.push(l),l=void 0),l?(l.vertexLength+=a.vertexLength,l.primitiveLength+=a.primitiveLength):l={vertexOffset:a.vertexOffset,primitiveLength:a.primitiveLength,vertexLength:a.vertexLength,primitiveOffset:a.primitiveOffset,sortKey:void 0,vaos:{}}}return l&&r.segments.push(l),r}encodeCentroid(e,t){const i=e.centroid(),r=t.span(),n=Math.min(7,Math.round(r.x*this.tileToMeter/10)),o=Math.min(7,Math.round(r.y*this.tileToMeter/10));return new U(K(i.x,1,8191)<<3|n,K(i.y,1,8191)<<3|o)}encodeBorderCentroid(e){if(!e.borders)return new U(0,0);const t=e.borders,i=Number.MAX_VALUE;if(t[0][0]!==i||t[1][0]!==i){const e=t[0][0]!==i?0:1;return new U(6|(t[0][0]!==i?0:65528),(t[e][0]+t[e][1])/2<<3|6)}{const e=t[2][0]!==i?2:3;return new U((t[e][0]+t[e][1])/2<<3|6,6|(t[2][0]!==i?0:65528))}}showCentroid(e){const t=this.centroidData[e.centroidDataIndex];t.flags&=Md,t.centroidXY.x=0,t.centroidXY.y=0,this.writeCentroidToBuffer(t)}writeCentroidToBuffer(e){this.groundEffect.updateHiddenByLandmark(e);const t=e.vertexArrayOffset,i=e.vertexCount+e.vertexArrayOffset,r=e.flags&Md?Sd:e.centroidXY,n=this.centroidVertexArray.geta_centroid_pos0(t);if(this.centroidVertexArray.geta_centroid_pos1(t)!==r.y||n!==r.x){for(let e=t;e<i;++e)this.centroidVertexArray.emplace(e,r.x,r.y);this.needsCentroidUpdate=!0}}createCentroidsBuffer(){this.centroidVertexArray.resize(this.layoutVertexArray.length),this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const e of this.centroidData)this.writeCentroidToBuffer(e)}updateReplacement(e,t,i){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const r=t.getReplacementRegionsForTile(e.toUnwrapped());if(hd(this.activeReplacements,r))return;if(this.activeReplacements=r,0===this.centroidVertexArray.length)this.createCentroidsBuffer();else for(const e of this.centroidData)e.flags&=2147483647;const n=[];for(const t of this.activeReplacements){if(t.order<i)continue;const r=Math.max(1,Math.pow(2,t.footprintTileId.canonical.z-e.canonical.z));for(const i of this.centroidData)if(!(i.flags&Md||t.min.x>i.max.x||i.min.x>t.max.x||t.min.y>i.max.y||i.min.y>t.max.y))for(let o=0;o<i.footprintSegLen;o++){const s=this.footprintSegments[i.footprintSegIdx+o];if(n.length=0,Hd(this.footprintVertices,s.vertexOffset,s.vertexCount,t.footprintTileId.canonical,e.canonical,n),pd(t.footprint,n,this.footprintIndices.uint16,s.indexOffset,s.indexCount,-s.vertexOffset,-r)){i.flags|=Md;break}}}for(const e of this.centroidData)this.writeCentroidToBuffer(e);this.borderDoneWithNeighborZ=[-1,-1,-1,-1]}footprintContainsPoint(e,t,i){let r=!1;for(let n=0;n<i.footprintSegLen;n++){const o=this.footprintSegments[i.footprintSegIdx+n];let s=0;for(const i of o.ringIndices){for(let n=s,a=i+s-1;n<i+s;a=n++){const i=this.footprintVertices.int16[2*(n+o.vertexOffset)+0],s=this.footprintVertices.int16[2*(n+o.vertexOffset)+1],l=this.footprintVertices.int16[2*(a+o.vertexOffset)+1];s>t!=l>t&&e<(this.footprintVertices.int16[2*(a+o.vertexOffset)+0]-i)*(t-s)/(l-s)+i&&(r=!r)}s=i}}return r}getHeightAtTileCoord(e,t){let i=Number.NEGATIVE_INFINITY,r=!0;const n=4*(e+Wi)*Wi+(t+Wi);if(this.partLookup.hasOwnProperty(n)){const e=this.partLookup[n];return e?{height:e.height,hidden:!!(e.flags&Md)}:void 0}for(const o of this.centroidData)e>o.max.x||o.min.x>e||t>o.max.y||o.min.y>t||this.footprintContainsPoint(e,t,o)&&o&&o.height>i&&(i=o.height,this.partLookup[n]=o,r=!!(o.flags&Md));if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:r};this.partLookup[n]=void 0}}function Bd(e,t){const i=e.add(t)._unit();return e.x*i.x+e.y*i.y}function Nd(e,t,i,r){const n=t.sub(e)._perp()._unit(),o=i.sub(t)._perp()._unit();return Vd(e,t,i,Bd(n,o),r)}function Vd(e,t,i,r,n){const o=Math.sqrt(1-r*r);return Math.min(e.dist(t)/3,t.dist(i)/3,n*o/r)}function Ud(e,t,i){return e.x<i[0].x&&t.x<i[0].x||e.x>i[1].x&&t.x>i[1].x||e.y<i[0].y&&t.y<i[0].y||e.y>i[1].y&&t.y>i[1].y}function jd(e,t){return e.x<t[0].x||e.x>t[1].x||e.y<t[0].y||e.y>t[1].y}function Gd(e,t,i){if(e.x<0||e.x>=Wi||t.x<0||t.x>=Wi||i.x<0||i.x>=Wi)return!1;const r=i.sub(t),n=r.perp(),o=e.sub(t);return(r.x*o.x+r.y*o.y)/Math.sqrt((r.x*r.x+r.y*r.y)*(o.x*o.x+o.y*o.y))>-.866&&n.x*o.x+n.y*o.y<0}function qd(e,t,i){const r=t?2|e:-3&e;return i?1|r:-2&r}function Zd(){const e=Math.PI/32,t=Math.tan(e),i=ql;return i*Math.sqrt(1+2*t*t)-i}function $d(e,t,i){const r=1<<i.z,n=Jl(i.x/r),o=Jl((i.x+1)/r),s=Ql(i.y/r),a=Ql((i.y+1)/r);return function(e,t,i,r,n=0,o){const s=[];if(!e.length||!i||!r)return s;const a=(e,t)=>{for(const i of e)s.push({polygon:i,bounds:t})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(r)),h=l-c,u=[];for(let e=0;e<Math.abs(h);e++)u.push(h>0?0:1);for(let e=0;e<Math.min(l,c);e++)u.push(0),u.push(1);let d=e;if(d=id(d,t[0].y-n,t[1].y+n,1),d=id(d,t[0].x-n,t[1].x+n,0),!d.length)return s;const p=[];for(u.length?p.push({polygons:d,bounds:t,depth:0}):a(d,t);p.length;){const e=p.pop(),t=e.depth,i=u[t],r=e.bounds[0],s=e.bounds[1],l=0===i?r.x:r.y,c=0===i?s.x:s.y,h=o?o(i,l,c):.5*(l+c),d=id(e.polygons,l-n,h+n,i),f=id(e.polygons,h-n,c+n,i);if(d.length){const e=[r,new U(0===i?h:s.x,1===i?h:s.y)];u.length>t+1?p.push({polygons:d,bounds:e,depth:t+1}):a(d,e)}if(f.length){const e=[new U(0===i?h:r.x,1===i?h:r.y),s];u.length>t+1?p.push({polygons:f,bounds:e,depth:t+1}):a(f,e)}}return s}(e,t,Math.ceil((o-n)/11.25),Math.ceil((s-a)/11.25),1,((e,t,n)=>{if(0===e)return.5*(t+n);{const e=Ql((i.y+t/Wi)/r);return(Yl(.5*(Ql((i.y+n/Wi)/r)+e))*r-i.y)*Wi}}))}function Hd(e,t,i,r,n,o){const s=Math.pow(2,r.z-n.z);for(let a=0;a<i;a++){let i=e.int16[2*(a+t)+0],l=e.int16[2*(a+t)+1];i=(i+n.x*Wi)*s-r.x*Wi,l=(l+n.y*Wi)*s-r.y*Wi,o.push(new U(i,l))}}let Wd,Xd;function Yd(e,t){return e.x*t.x+e.y*t.y}function Kd(e,t){if(1===e.length){let i=0;const r=t[i++];let n;for(;!n||r.equals(n);)if(n=t[i++],!n)return 1/0;for(;i<t.length;i++){const o=t[i],s=e[0],a=n.sub(r),l=o.sub(r),c=s.sub(r),h=Yd(a,a),u=Yd(a,l),d=Yd(l,l),p=Yd(c,a),f=Yd(c,l),m=h*d-u*u,_=(d*p-u*f)/m,g=(h*f-u*p)/m,y=r.z*(1-_-g)+n.z*_+o.z*g;if(isFinite(y))return y}return 1/0}{let e=1/0;for(const i of t)e=Math.min(e,i.z);return e}}function Jd(e,t,i,r,n,o,s,a){const l=s*n.getElevationAt(e,t,!0,!0),c=0!==o[0],h=c?0===o[1]?s*(o[0]/7-450):s*function(e,t,i){const r=Math.floor(t[0]/8),n=Math.floor(t[1]/8),o=10*(t[0]-8*r),s=10*(t[1]-8*n),a=e.getElevationAt(r,n,!0,!0),l=e.getMeterToDEM(i),c=Math.floor(.5*(o*l-1)),h=Math.floor(.5*(s*l-1)),u=e.tileCoordToPixel(r,n),d=2*c+1,p=2*h+1,f=function(e,t,i,r,n){return[e.getElevationAtPixel(t,i,!0),e.getElevationAtPixel(t+n,i,!0),e.getElevationAtPixel(t,i+n,!0),e.getElevationAtPixel(t+r,i+n,!0)]}(e,u.x-c,u.y-h,d,p),m=Math.abs(f[0]-f[1]),_=Math.abs(f[2]-f[3]),g=Math.abs(f[0]-f[2])+Math.abs(f[1]-f[3]),y=Math.min(.25,.5*l*(m+_)/d),x=Math.min(.25,.5*l*g/p);return a+Math.max(y*o,x*s)}(n,o,a):l;return{base:l+(0===i?-1:i),top:c?Math.max(h+r,l+i+2):l+r}}ro(Fd,"FillExtrusionBucket",{omit:["layers","features"]}),ro(zd,"PartData"),ro(Pd,"FootprintSegment"),ro(Dd,"BorderCentroidData"),ro(kd,"GroundEffect");const Qd=la([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),ep=la([{name:"a_z_offset_width",components:2,type:"Float32"}],4),{members:tp}=Qd,ip=la([{name:"a_packed",components:4,type:"Float32"}]),{members:rp}=ip,np=la([{name:"a_pattern_data",components:3,type:"Float32"}]),{members:op}=np;class sp{constructor(e,t){this.width=e,this.height=t,this.nextRow=0,this.image=new Zh({width:e,height:t}),this.positions={},this.uploaded=!1}getDash(e,t){const i=this.getKey(e,t);return this.positions[i]}trim(){const e=this.width,t=this.height=ne(this.nextRow);this.image.resize({width:e,height:t})}getKey(e,t){return e.join(",")+t}getDashRanges(e,t,i){const r=[];let n=e.length%2==1?-e[e.length-1]*i:0,o=e[0]*i,s=!0;r.push({left:n,right:o,isDash:s,zeroLength:0===e[0]});let a=e[0];for(let t=1;t<e.length;t++){s=!s;const l=e[t];n=a*i,a+=l,o=a*i,r.push({left:n,right:o,isDash:s,zeroLength:0===l})}return r}addRoundDash(e,t,i){const r=t/2;for(let t=-i;t<=i;t++){const n=this.width*(this.nextRow+i+t);let o=0,s=e[o];for(let a=0;a<this.width;a++){a/s.right>1&&(s=e[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),h=Math.min(l,c);let u;const d=t/i*(r+1);if(s.isDash){const e=r-Math.abs(d);u=Math.sqrt(h*h+e*e)}else u=r-Math.sqrt(h*h+d*d);this.image.data[n+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(e,t){for(let t=e.length-1;t>=0;--t){const i=e[t],r=e[t+1];i.zeroLength?e.splice(t,1):r&&r.isDash===i.isDash&&(r.left=i.left,e.splice(t,1))}const i=e[0],r=e[e.length-1];i.isDash===r.isDash&&(i.left=r.left-this.width,r.right=i.right+this.width);const n=this.width*this.nextRow;let o=0,s=e[o];for(let i=0;i<this.width;i++){i/s.right>1&&(s=e[++o]);const r=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(r,a);this.image.data[n+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+t+128))}}addDash(e,t){const i=this.getKey(e,t);if(this.positions[i])return this.positions[i];const r="round"===t,n=r?7:0,o=2*n+1;if(this.nextRow+o>this.height)return ue("LineAtlas out of space"),null;0===e.length&&e.push(1);let s=0;for(let t=0;t<e.length;t++)e[t]<0&&(ue("Negative value is found in line dasharray, replacing values with 0"),e[t]=0),s+=e[t];if(0!==s){const i=this.width/s,o=this.getDashRanges(e,this.width,i);r?this.addRoundDash(o,i,n):this.addRegularDash(o,"square"===t?.5*i:0)}const a=this.nextRow+n;this.nextRow+=o;const l={tl:[a,n],br:[s,0]};return this.positions[i]=l,l}}ro(sp,"LineAtlas");const ap=Qu.VectorTileFeature.types,lp=Math.cos(Math.PI/180*37.5),cp=Math.cos(Math.PI/180*5);class hp{constructor(e){this.evaluationGlobals={zoom:0,lineProgress:void 0},this.zoom=e.zoom,this.evaluationGlobals.zoom=this.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.fqid)),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.hasZOffset=!1,this.hasCrossSlope=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((e=>{this.gradients[e.id]={}})),this.layoutVertexArray=new fa,this.layoutVertexArray2=new ma,this.patternVertexArray=new _a,this.indexArray=new Ia,this.programConfigurations=new zl(e.layers,{zoom:e.zoom,lut:e.lut}),this.segments=new nl,this.maxLineLength=0,this.zOffsetVertexArray=new ka,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.tessellationStep=e.tessellationStep?e.tessellationStep:128}updateFootprints(e,t){}populate(e,t,i,r){this.hasPattern=Mu("line",this.layers,t);const n=this.layers[0].layout.get("line-sort-key");this.tileToMeter=oc(i),this.hasZOffset=!this.layers[0].isDraped();const o=this.layers[0].layout.get("line-elevation-reference");this.hasZOffset&&"none"===o&&ue(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`);const s=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope=this.hasZOffset&&void 0!==s;const a=[];for(const{feature:t,id:o,index:s,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=mc(t,e);if(!this.layers[0]._featureFilter.filter(new Ms(this.zoom),c,i))continue;const h=n?n.evaluate(c,{},i):void 0,u={id:o,properties:t.properties,type:t.type,sourceLayerIndex:l,index:s,geometry:e?c.geometry:fc(t,i,r),patterns:{},sortKey:h};a.push(u)}n&&a.sort(((e,t)=>e.sortKey-t.sortKey));const{lineAtlas:l,featureIndex:c}=t,h=this.addConstantDashes(l);for(const r of a){const{geometry:n,index:o,sourceLayerIndex:s}=r;if(h&&this.addFeatureDashes(r,l),this.hasPattern){const e=Eu("line",this.layers,r,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(r,n,o,i,l.positions,t.availableImages,t.brightness);c.insert(e[o].feature,n,o,s,this.index)}}addConstantDashes(e){let t=!1;for(const i of this.layers){const r=i.paint.get("line-dasharray").value,n=i.layout.get("line-cap").value;if("constant"!==r.kind||"constant"!==n.kind)t=!0;else{const t=n.value,i=r.value;if(!i)continue;e.addDash(i,t)}}return t}addFeatureDashes(e,t){const i=this.zoom;for(const r of this.layers){const n=r.paint.get("line-dasharray").value,o=r.layout.get("line-cap").value;if("constant"===n.kind&&"constant"===o.kind)continue;let s,a;if("constant"===n.kind){if(s=n.value,!s)continue}else s=n.evaluate({zoom:i},e);a="constant"===o.kind?o.value:o.evaluate({zoom:i},e),t.addDash(s,a),e.patterns[r.id]=t.getKey(s,a)}}update(e,t,i,r,n,o,s){this.programConfigurations.updatePaintArrays(e,t,n,i,r,o,s)}addFeatures(e,t,i,r,n,o){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,i,r,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,rp)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=e.createVertexBuffer(this.patternVertexArray,op)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,ep.members,!0)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,tp),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&e.properties.hasOwnProperty("mapbox_clip_start")&&e.properties.hasOwnProperty("mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,t,i,r,n,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(e,{}),c=a.get("line-cap").evaluate(e,{}),h=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(e),this.lineFeature=e,this.zOffsetValue=a.get("line-z-offset").value;const d=this.layers[0].paint.get("line-width").value;"constant"!==d.kind&&!1===d.isLineProgressConstant&&(this.variableWidthValue=d);for(const i of t)this.addLine(i,e,r,l,c,h,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,n,o,r,s)}addLine(e,t,i,r,n,o,s){this.distance=0,this.prevDistance=0,this.scaledDistance=0,this.totalDistance=0,this.totalFeatureLength=0,this.lineSoFar=0,this.currentVertex=void 0;const a="none"===r;if(this.patternJoinNone=this.hasPattern&&a,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t<e.length-1;t++)this.totalDistance+=e[t].dist(e[t+1]);this.totalFeatureLength=this.totalDistance/(this.lineClips.end-this.lineClips.start),this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const l="Polygon"===ap[t.type];let c=e.length;for(;c>=2&&e[c-1].equals(e[c-2]);)c--;let h=0;for(;h<c-1&&e[h].equals(e[h+1]);)h++;if(c<(l?3:2))return;"bevel"===r&&(o=1.05);const u=this.segments.prepareSegment(10*c,this.layoutVertexArray,this.indexArray);let d,p,f,m,_,g;this.e1=this.e2=-1,l&&(d=e[c-2],_=e[h].sub(d)._unit()._perp());for(let t=h;t<c;t++){if(f=t===c-1?l?e[h+1]:void 0:e[t+1],f&&e[t].equals(f))continue;_&&(m=_),d&&(p=d),d=e[t],g=this.evaluateLineProgressFeatures(p?p.dist(d):0),_=f?f.sub(d)._unit()._perp():m,m=m||_;const i=p&&f;let y=i?r:l||a?"butt":n;const x=m.x*_.x+m.y*_.y;if(a){const e=function(e){if(e.patternJoinNone){const t=e.segmentPoints.length/2,i=e.lineSoFar-e.segmentStart;for(let r=0;r<t;++r){const t=e.segmentPoints[2*r+1],n=Math.round(e.segmentPoints[2*r])+.5+.25*t;e.patternVertexArray.emplaceBack(n,i,e.segmentStart),e.patternVertexArray.emplaceBack(n,i,e.segmentStart)}e.segmentPoints.length=0}e.e1=e.e2=-1};if(i&&x<cp){this.updateDistance(p,d),this.addCurrentVertex(d,m,1,1,u,g),e(this),this.addCurrentVertex(d,_,-1,-1,u,g);continue}if(p){if(!f){this.updateDistance(p,d),this.addCurrentVertex(d,m,1,1,u,g),e(this);continue}y="miter"}}let v=m.add(_);0===v.x&&0===v.y||v._unit();const b=v.x*_.x+v.y*_.y,w=0!==b?1/b:1/0,T=2*Math.sqrt(2-2*b),S=b<lp&&p&&f,M=m.x*_.y-m.y*_.x>0,E=this.overscaling<=16?15*Wi/(512*this.overscaling):0;if(i&&"round"===y)if(w<s)y="miter";else if(w<=2){const e=up(d,-10,8202);y=this.hasZOffset&&(e||this.hasCrossSlope)?"miter":"fakeround"}if("miter"===y&&w>o&&(y="bevel"),"bevel"===y&&(w>2&&(y="flipbevel"),w<o&&(y="miter")),p&&!("miter"===y&&S)&&this.updateDistance(p,d),"miter"===y)if(S){const e=d.dist(p);if(e>2*E){const t=d.sub(d.sub(p)._mult(E/e)._round());this.updateDistance(p,t),this.addCurrentVertex(t,m,0,0,u,g),p=t}this.updateDistance(p,d),v._mult(w),this.addCurrentVertex(d,v,0,0,u,g);const t=d.dist(f);if(t>2*E){const e=d.add(f.sub(d)._mult(E/t)._round());this.updateDistance(d,e),this.addCurrentVertex(e,_,0,0,u,g),d=e}}else v._mult(w),this.addCurrentVertex(d,v,0,0,u,g);else if("flipbevel"===y){if(w>100)v=_.mult(-1);else{const e=w*m.add(_).mag()/m.sub(_).mag();v._perp()._mult(e*(M?-1:1))}this.addCurrentVertex(d,v,0,0,u,g),this.addCurrentVertex(d,v.mult(-1),0,0,u,g)}else if("bevel"===y||"fakeround"===y){null!=g&&p&&this.addCurrentVertex(d,m,-1,-1,u,g);const e=d.dist(p)<=2*E&&"bevel"!==y,t=v.mult(M?1:-1);t._mult(w);const i=_.mult(M?-1:1),r=m.mult(M?-1:1),n=this.evaluateLineProgressFeatures(this.distance);if(null==g&&(this.addHalfVertex(d,t.x,t.y,!1,!M,0,u,n),e||this.addHalfVertex(d,t.x+2*r.x,t.y+2*r.y,!1,M,0,u,n)),"fakeround"===y){const e=Math.round(180*T/Math.PI/20);this.addHalfVertex(d,r.x,r.y,!1,M,0,u,n);for(let t=0;t<e;t++){let o=t/e;if(.5!==o){const e=o-.5;o+=o*e*(o-1)*((1.0904+x*(x*(3.55645-1.43519*x)-3.2452))*e*e+(.848013+x*(.215638*x-1.06021)))}const s=i.sub(r)._mult(o)._add(r)._unit();this.addHalfVertex(d,s.x,s.y,!1,M,0,u,n)}this.addHalfVertex(d,i.x,i.y,!1,M,0,u,n)}e||null!=g||this.addHalfVertex(d,t.x+2*i.x,t.y+2*i.y,!1,M,0,u,n),null!=g&&f&&this.addCurrentVertex(d,_,1,1,u,g)}else"butt"===y?this.addCurrentVertex(d,v,0,0,u,g):"square"===y?(p||this.addCurrentVertex(d,v,-1,-1,u,g),this.addCurrentVertex(d,v,0,0,u,g),p&&this.addCurrentVertex(d,v,1,1,u,g)):"round"===y&&(p&&(this.addCurrentVertex(d,m,0,0,u,g),this.addCurrentVertex(d,m,1,1,u,g,!0)),f&&(this.addCurrentVertex(d,_,-1,-1,u,g,!0),this.addCurrentVertex(d,_,0,0,u,g)))}}addVerticesTo(e,t,i,r,n,o,s,a,l,c){const h=(t.w-e.w)/this.tessellationStep|0;let u=0;const d=this.scaledDistance;if(h>1){this.lineSoFar=e.w;const d=(t.x-e.x)/h,p=(t.y-e.y)/h,f=(t.z-e.z)/h,m=(t.w-e.w)/h;for(let t=1;t<h;++t){e.x+=d,e.y+=p,e.z+=f,this.lineSoFar+=m,u+=m;const t=this.evaluateLineProgressFeatures(this.prevDistance+u);this.scaledDistance=(this.prevDistance+u)/this.totalDistance,this.addHalfVertex(e,i,r,c,!1,s,l,t),this.addHalfVertex(e,n,o,c,!0,-a,l,t)}}this.lineSoFar=t.w,this.scaledDistance=d;const p=this.evaluateLineProgressFeatures(this.distance);this.addHalfVertex(t,i,r,c,!1,s,l,p),this.addHalfVertex(t,n,o,c,!0,-a,l,p)}evaluateLineProgressFeatures(e){if(!this.variableWidthValue&&!this.hasZOffset)return null;this.evaluationGlobals.lineProgress=0,this.lineClips?this.evaluationGlobals.lineProgress=Math.min(1,(this.totalFeatureLength*this.lineClips.start+e)/this.totalFeatureLength):ue(`line-progress evaluation for ${this.layerIds[0]} requires enabling 'lineMetrics' for the source.`);let t=0;return this.variableWidthValue&&"constant"!==this.variableWidthValue.kind&&(t=this.variableWidthValue.evaluate(this.evaluationGlobals,this.lineFeature)||0),this.hasZOffset?"constant"===this.zOffsetValue.kind?{zOffset:this.zOffsetValue.value,variableWidth:t}:{zOffset:this.zOffsetValue.evaluate(this.evaluationGlobals,this.lineFeature)||0,variableWidth:t}:{zOffset:0,variableWidth:t}}addCurrentVertex(e,t,i,r,n,o,s=!1){const a=t.x+t.y*i,l=t.y-t.x*i,c=t.y*r-t.x,h=-t.y-t.x*r;if(null!=o){const t=this.hasZOffset,u=-10,d=8202,p=o.zOffset,f=new td(e.x,e.y,p,this.lineSoFar),m=!!t&&up(e,u,d),_=this.lineSoFar,g=this.distance;if(this.currentVertex)if(m){const t=this.currentVertexIsOutside,o=this.currentVertex,m=new td(e.x,e.y,p,this.lineSoFar);if(nd(o,m,u,d),!up(m,u,d)){if(t){this.e1=this.e2=-1,this.distance-=o.dist(f),this.lineSoFar=o.w;const e=this.evaluateLineProgressFeatures(o.w-this.totalFeatureLength*(this.lineClips?this.lineClips.start:0));this.addHalfVertex(o,a,l,s,!1,i,n,e),this.addHalfVertex(o,c,h,s,!0,-r,n,e),this.prevDistance=this.distance}this.distance=this.prevDistance+o.dist(m),this.scaledDistance=this.distance/this.totalDistance,this.addVerticesTo(o,m,a,l,c,h,i,r,n,s),this.distance=g,this.scaledDistance=this.distance/this.totalDistance}}else{const e=this.currentVertex;if(this.currentVertexIsOutside){nd(e,f,u,d),this.e1=this.e2=-1,this.distance-=e.dist(f),this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=e.w;const t=this.evaluateLineProgressFeatures(e.w-this.totalFeatureLength*(this.lineClips?this.lineClips.start:0));this.addHalfVertex(e,a,l,s,!1,i,n,t),this.addHalfVertex(e,c,h,s,!0,-r,n,t),this.prevDistance=this.distance,this.distance=g,this.scaledDistance=this.distance/this.totalDistance}this.addVerticesTo(e,f,a,l,c,h,i,r,n,s)}else m||(this.addHalfVertex(e,a,l,s,!1,i,n,o),this.addHalfVertex(e,c,h,s,!0,-r,n,o));this.currentVertex=f,this.currentVertexIsOutside=m,this.lineSoFar=_}else this.addHalfVertex(e,a,l,s,!1,i,n,o),this.addHalfVertex(e,c,h,s,!0,-r,n,o)}addHalfVertex({x:e,y:t},i,r,n,o,s,a,l){this.patternJoinNone&&(0===this.segmentPoints.length&&(this.segmentStart=this.lineSoFar,this.segmentStartf32=Math.fround(this.lineSoFar)),o||this.segmentPoints.push(this.lineSoFar-this.segmentStart,s)),this.layoutVertexArray.emplaceBack((e<<1)+(n?1:0),(t<<1)+(o?1:0),Math.round(63*i)+128,Math.round(63*r)+128,1+(0===s?0:s<0?-1:1),0,this.lineSoFar-this.segmentStartf32),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const c=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l.zOffset,l.variableWidth)}updateScaledDistance(){this.lineClips?(this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=this.totalFeatureLength*this.lineClips.start+this.distance):this.lineSoFar=this.distance}updateDistance(e,t){this.prevDistance=this.distance,this.distance+=e.dist(t),this.updateScaledDistance()}}function up(e,t,i){return e.x<t||e.x>i||e.y<t||e.y>i}let dp,pp;function fp(e,t,i){return t*(Wi/(e.tileSize*Math.pow(2,i-e.tileID.overscaledZ)))}ro(hp,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const mp=(e,t,i)=>(1-i)*e+i*t;function _p(e,t){return 1/fp(e,1,t.tileZoom)}function gp(e,t,i,r){return e.translatePosMatrix(r||t.tileID.projMatrix,t,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const yp=e=>{const t=[];xp(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT");const i=e.paint.get("line-trim-offset");0===i[0]&&0===i[1]||t.push("RENDER_LINE_TRIM_OFFSET"),0!==e.paint.get("line-border-width").constantOr(1)&&t.push("RENDER_LINE_BORDER");const r="none"===e.layout.get("line-join").constantOr("miter"),n=!!e.paint.get("line-pattern").constantOr(1);return r&&n&&t.push("LINE_JOIN_NONE"),t};function xp(e){const t=e.paint.get("line-dasharray").value;return t.value||"constant"!==t.kind}let vp;const bp=()=>vp||(vp={layout:dp||(dp=new Fs({"line-cap":new Os(Bs.layout_line["line-cap"]),"line-join":new Os(Bs.layout_line["line-join"]),"line-miter-limit":new Ls(Bs.layout_line["line-miter-limit"]),"line-round-limit":new Ls(Bs.layout_line["line-round-limit"]),"line-sort-key":new Os(Bs.layout_line["line-sort-key"]),"line-z-offset":new Os(Bs.layout_line["line-z-offset"]),"line-elevation-reference":new Ls(Bs.layout_line["line-elevation-reference"]),"line-cross-slope":new Ls(Bs.layout_line["line-cross-slope"]),visibility:new Ls(Bs.layout_line.visibility),"line-width-unit":new Ls(Bs.layout_line["line-width-unit"])})),paint:pp||(pp=new Fs({"line-opacity":new Os(Bs.paint_line["line-opacity"]),"line-color":new Os(Bs.paint_line["line-color"]),"line-translate":new Ls(Bs.paint_line["line-translate"]),"line-translate-anchor":new Ls(Bs.paint_line["line-translate-anchor"]),"line-width":new Os(Bs.paint_line["line-width"]),"line-gap-width":new Os(Bs.paint_line["line-gap-width"]),"line-offset":new Os(Bs.paint_line["line-offset"]),"line-blur":new Os(Bs.paint_line["line-blur"]),"line-dasharray":new Os(Bs.paint_line["line-dasharray"]),"line-pattern":new Os(Bs.paint_line["line-pattern"]),"line-gradient":new ks(Bs.paint_line["line-gradient"]),"line-trim-offset":new Ls(Bs.paint_line["line-trim-offset"]),"line-trim-fade-range":new Ls(Bs.paint_line["line-trim-fade-range"]),"line-trim-color":new Ls(Bs.paint_line["line-trim-color"]),"line-emissive-strength":new Ls(Bs.paint_line["line-emissive-strength"]),"line-border-width":new Os(Bs.paint_line["line-border-width"]),"line-border-color":new Os(Bs.paint_line["line-border-color"]),"line-occlusion-opacity":new Ls(Bs.paint_line["line-occlusion-opacity"]),"line-color-use-theme":new Os({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new Os({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new Os({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new Os({type:"string",default:"default","property-type":"data-driven"})}))},vp);class wp extends Os{possiblyEvaluate(e,t){return t=new Ms(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,i,r){return t=te({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,r)}}let Tp;function Sp(e,t){return t>0?t+2*e:e}const Mp=la([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Ep=la([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Ap=la([{name:"a_projected_pos",components:4,type:"Float32"}],4);la([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Ip=la([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),Cp=la([{name:"a_texb",components:2,type:"Uint16"}]),Pp=la([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),zp=la([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);la([{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 Dp=la([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Rp=la([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);la([{name:"triangle",components:3,type:"Uint16"}]),la([{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"}]),la([{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"}]),la([{type:"Float32",name:"offsetX"}]),la([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var Lp=24;const Op=128;function kp(e,t,i,r,n){if("camera"===e.kind)return e.maxSize;if("composite"===e.kind){const r=t.possiblyEvaluate(new Ms(e.maxZoom),i).evaluate(n,{},i),o=t.possiblyEvaluate(new Ms(e.minZoom),i).evaluate(n,{},i);return Math.max(r,o)}return t.possiblyEvaluate(new Ms(r)).evaluate(n,{},i)}function Fp(e,t){const{expression:i}=t;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Ms(e+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:t,interpolationType:r}=i;let n=0;for(;n<t.length&&t[n]<=e;)n++;n=Math.max(0,n-1);let o=n;for(;o<t.length&&t[o]<e+1;)o++;o=Math.min(t.length-1,o);const s=t[n],a=t[o];return"composite"===i.kind?{kind:"composite",minZoom:s,maxZoom:a,interpolationType:r}:{kind:"camera",minZoom:s,maxZoom:a,minSize:i.evaluate(new Ms(s)),maxSize:i.evaluate(new Ms(a)),interpolationType:r}}}function Bp(e,{uSize:t,uSizeT:i},{lowerSize:r,upperSize:n}){return"source"===e.kind?r/Op:"composite"===e.kind?Et(r/Op,n/Op,i):t}function Np(e,t,i=1){let r=0,n=0;if("constant"===e.kind)n=e.layoutSize*i;else if("source"!==e.kind){const{interpolationType:o,minZoom:s,maxZoom:a}=e,l=o?K(en.interpolationFactor(o,t,s,a),0,1):0;"camera"===e.kind?n=Et(e.minSize,e.maxSize,l)*i:r=l*i}return{uSizeT:r,uSize:n}}var Vp=Object.freeze({__proto__:null,SIZE_PACK_FACTOR:Op,evaluateSizeForFeature:Bp,evaluateSizeForZoom:Np,getRasterizedIconSize:kp,getSizeData:Fp});function Up(e,t,i){return e.sections.forEach((e=>{e.text=function(e,t,i){const r=t.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?e=e.toLocaleUpperCase():"lowercase"===r&&(e=e.toLocaleLowerCase()),Ss.applyArabicShaping&&(e=Ss.applyArabicShaping(e)),e}(e.text,t,i)})),e}const jp={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Gp(e){return"︶"===e||"﹈"===e||"︸"===e||"﹄"===e||"﹂"===e||"︾"===e||"︼"===e||"︺"===e||"︘"===e||"﹀"===e||"︐"===e||"︓"===e||"︔"===e||"`"===e||" ̄"===e||"︑"===e||"︒"===e}function qp(e){return"︵"===e||"﹇"===e||"︷"===e||"﹃"===e||"﹁"===e||"︽"===e||"︻"===e||"︹"===e||"︗"===e||"︿"===e}var Zp,$p,Hp,Wp={};function Xp(){if(Hp)return $p;Hp=1,$p=t;var e=(Zp||(Zp=1,Wp.read=function(e,t,i,r,n){var o,s,a=8*n-r-1,l=(1<<a)-1,c=l>>1,h=-7,u=i?n-1:0,d=i?-1:1,p=e[t+u];for(u+=d,o=p&(1<<-h)-1,p>>=-h,h+=a;h>0;o=256*o+e[t+u],u+=d,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=r;h>0;s=256*s+e[t+u],u+=d,h-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),o-=c}return(p?-1:1)*s*Math.pow(2,o-r)},Wp.write=function(e,t,i,r,n,o){var s,a,l,c=8*o-n-1,h=(1<<c)-1,u=h>>1,d=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,f=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),(t+=s+u>=1?d/l:d*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=h?(a=0,s=h):s+u>=1?(a=(t*l-1)*Math.pow(2,n),s+=u):(a=t*Math.pow(2,u-1)*Math.pow(2,n),s=0));n>=8;e[i+p]=255&a,p+=f,a/=256,n-=8);for(s=s<<n|a,c+=n;c>0;e[i+p]=255&s,p+=f,s/=256,c-=8);e[i+p-f]|=128*m}),Wp);function t(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}t.Varint=0,t.Fixed64=1,t.Bytes=2,t.Fixed32=5;var i=4294967296,r=1/i,n="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function o(e){return e.type===t.Bytes?e.readVarint()+e.pos:e.pos+1}function s(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function a(e,t,i){var r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(r);for(var n=i.pos-1;n>=e;n--)i.buf[n+r]=i.buf[n]}function l(e,t){for(var i=0;i<e.length;i++)t.writeVarint(e[i])}function c(e,t){for(var i=0;i<e.length;i++)t.writeSVarint(e[i])}function h(e,t){for(var i=0;i<e.length;i++)t.writeFloat(e[i])}function u(e,t){for(var i=0;i<e.length;i++)t.writeDouble(e[i])}function d(e,t){for(var i=0;i<e.length;i++)t.writeBoolean(e[i])}function p(e,t){for(var i=0;i<e.length;i++)t.writeFixed32(e[i])}function f(e,t){for(var i=0;i<e.length;i++)t.writeSFixed32(e[i])}function m(e,t){for(var i=0;i<e.length;i++)t.writeFixed64(e[i])}function _(e,t){for(var i=0;i<e.length;i++)t.writeSFixed64(e[i])}function g(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+16777216*e[t+3]}function y(e,t,i){e[i]=t,e[i+1]=t>>>8,e[i+2]=t>>>16,e[i+3]=t>>>24}function x(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}return t.prototype={destroy:function(){this.buf=null},readFields:function(e,t,i){for(i=i||this.length;this.pos<i;){var r=this.readVarint(),n=r>>3,o=this.pos;this.type=7&r,e(n,t,this),this.pos===o&&this.skip(r)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=g(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=x(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=g(this.buf,this.pos)+g(this.buf,this.pos+4)*i;return this.pos+=8,e},readSFixed64:function(){var e=g(this.buf,this.pos)+x(this.buf,this.pos+4)*i;return this.pos+=8,e},readFloat:function(){var t=e.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=e.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(e){var t,i,r=this.buf;return t=127&(i=r[this.pos++]),i<128?t:(t|=(127&(i=r[this.pos++]))<<7,i<128?t:(t|=(127&(i=r[this.pos++]))<<14,i<128?t:(t|=(127&(i=r[this.pos++]))<<21,i<128?t:function(e,t,i){var r,n,o=i.buf;if(r=(112&(n=o[i.pos++]))>>4,n<128)return s(e,r,t);if(r|=(127&(n=o[i.pos++]))<<3,n<128)return s(e,r,t);if(r|=(127&(n=o[i.pos++]))<<10,n<128)return s(e,r,t);if(r|=(127&(n=o[i.pos++]))<<17,n<128)return s(e,r,t);if(r|=(127&(n=o[i.pos++]))<<24,n<128)return s(e,r,t);if(r|=(1&(n=o[i.pos++]))<<31,n<128)return s(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(i=r[this.pos]))<<28,e,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2==1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&n?function(e,t,i){return n.decode(e.subarray(t,i))}(this.buf,t,e):function(e,t,i){for(var r="",n=t;n<i;){var o,s,a,l=e[n],c=null,h=l>239?4:l>223?3:l>191?2:1;if(n+h>i)break;1===h?l<128&&(c=l):2===h?128==(192&(o=e[n+1]))&&(c=(31&l)<<6|63&o)<=127&&(c=null):3===h?(s=e[n+2],128==(192&(o=e[n+1]))&&128==(192&s)&&((c=(15&l)<<12|(63&o)<<6|63&s)<=2047||c>=55296&&c<=57343)&&(c=null)):4===h&&(s=e[n+2],a=e[n+3],128==(192&(o=e[n+1]))&&128==(192&s)&&128==(192&a)&&((c=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&a)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,h=1):c>65535&&(c-=65536,r+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),r+=String.fromCharCode(c),n+=h}return r}(this.buf,t,e)},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,i){if(this.type!==t.Bytes)return e.push(this.readVarint(i));var r=o(this);for(e=e||[];this.pos<r;)e.push(this.readVarint(i));return e},readPackedSVarint:function(e){if(this.type!==t.Bytes)return e.push(this.readSVarint());var i=o(this);for(e=e||[];this.pos<i;)e.push(this.readSVarint());return e},readPackedBoolean:function(e){if(this.type!==t.Bytes)return e.push(this.readBoolean());var i=o(this);for(e=e||[];this.pos<i;)e.push(this.readBoolean());return e},readPackedFloat:function(e){if(this.type!==t.Bytes)return e.push(this.readFloat());var i=o(this);for(e=e||[];this.pos<i;)e.push(this.readFloat());return e},readPackedDouble:function(e){if(this.type!==t.Bytes)return e.push(this.readDouble());var i=o(this);for(e=e||[];this.pos<i;)e.push(this.readDouble());return e},readPackedFixed32:function(e){if(this.type!==t.Bytes)return e.push(this.readFixed32());var i=o(this);for(e=e||[];this.pos<i;)e.push(this.readFixed32());return e},readPackedSFixed32:function(e){if(this.type!==t.Bytes)return e.push(this.readSFixed32());var i=o(this);for(e=e||[];this.pos<i;)e.push(this.readSFixed32());return e},readPackedFixed64:function(e){if(this.type!==t.Bytes)return e.push(this.readFixed64());var i=o(this);for(e=e||[];this.pos<i;)e.push(this.readFixed64());return e},readPackedSFixed64:function(e){if(this.type!==t.Bytes)return e.push(this.readSFixed64());var i=o(this);for(e=e||[];this.pos<i;)e.push(this.readSFixed64());return e},skip:function(e){var i=7&e;if(i===t.Varint)for(;this.buf[this.pos++]>127;);else if(i===t.Bytes)this.pos=this.readVarint()+this.pos;else if(i===t.Fixed32)this.pos+=4;else{if(i!==t.Fixed64)throw new Error("Unimplemented type: "+i);this.pos+=8}},writeTag:function(e,t){this.writeVarint(e<<3|t)},realloc:function(e){for(var t=this.length||16;t<this.pos+e;)t*=2;if(t!==this.length){var i=new Uint8Array(t);i.set(this.buf),this.buf=i,this.length=t}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(e){this.realloc(4),y(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),y(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),y(this.buf,-1&e,this.pos),y(this.buf,Math.floor(e*r),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),y(this.buf,-1&e,this.pos),y(this.buf,Math.floor(e*r),this.pos+4),this.pos+=8},writeVarint:function(e){(e=+e||0)>268435455||e<0?function(e,t){var i,r;if(e>=0?(i=e%4294967296|0,r=e/4294967296|0):(r=~(-e/4294967296),4294967295^(i=~(-e%4294967296))?i=i+1|0:(i=0,r=r+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,i){i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,i.buf[i.pos]=127&(e>>>=7)}(i,0,t),function(e,t){var i=(7&e)<<4;t.buf[t.pos++]|=i|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))))}(r,t)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))},writeSVarint:function(e){this.writeVarint(e<0?2*-e-1:2*e)},writeBoolean:function(e){this.writeVarint(Boolean(e))},writeString:function(e){e=String(e),this.realloc(4*e.length),this.pos++;var t=this.pos;this.pos=function(e,t,i){for(var r,n,o=0;o<t.length;o++){if((r=t.charCodeAt(o))>55295&&r<57344){if(!n){r>56319||o+1===t.length?(e[i++]=239,e[i++]=191,e[i++]=189):n=r;continue}if(r<56320){e[i++]=239,e[i++]=191,e[i++]=189,n=r;continue}r=n-55296<<10|r-56320|65536,n=null}else n&&(e[i++]=239,e[i++]=191,e[i++]=189,n=null);r<128?e[i++]=r:(r<2048?e[i++]=r>>6|192:(r<65536?e[i++]=r>>12|224:(e[i++]=r>>18|240,e[i++]=r>>12&63|128),e[i++]=r>>6&63|128),e[i++]=63&r|128)}return i}(this.buf,e,this.pos);var i=this.pos-t;i>=128&&a(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),e.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),e.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var i=0;i<t;i++)this.buf[this.pos++]=e[i]},writeRawMessage:function(e,t){this.pos++;var i=this.pos;e(t,this);var r=this.pos-i;r>=128&&a(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r},writeMessage:function(e,i,r){this.writeTag(e,t.Bytes),this.writeRawMessage(i,r)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,l,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,c,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,d,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,h,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,u,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,p,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,f,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,m,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,_,t)},writeBytesField:function(e,i){this.writeTag(e,t.Bytes),this.writeBytes(i)},writeFixed32Field:function(e,i){this.writeTag(e,t.Fixed32),this.writeFixed32(i)},writeSFixed32Field:function(e,i){this.writeTag(e,t.Fixed32),this.writeSFixed32(i)},writeFixed64Field:function(e,i){this.writeTag(e,t.Fixed64),this.writeFixed64(i)},writeSFixed64Field:function(e,i){this.writeTag(e,t.Fixed64),this.writeSFixed64(i)},writeVarintField:function(e,i){this.writeTag(e,t.Varint),this.writeVarint(i)},writeSVarintField:function(e,i){this.writeTag(e,t.Varint),this.writeSVarint(i)},writeStringField:function(e,i){this.writeTag(e,t.Bytes),this.writeString(i)},writeFloatField:function(e,i){this.writeTag(e,t.Fixed32),this.writeFloat(i)},writeDoubleField:function(e,i){this.writeTag(e,t.Fixed64),this.writeDouble(i)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}},$p}var Yp=t(Xp());function Kp(e,t,i){t.glyphs=[],1===e&&i.readMessage(Jp,t)}function Jp(e,t,i){if(3===e){const{id:e,bitmap:r,width:n,height:o,left:s,top:a,advance:l}=i.readMessage(Qp,{});t.glyphs.push({id:e,bitmap:new Zh({width:n+6,height:o+6},r),metrics:{width:n,height:o,left:s,top:a,advance:l}})}else 4===e?t.ascender=i.readSVarint():5===e&&(t.descender=i.readSVarint())}function Qp(e,t,i){1===e?t.id=i.readVarint():2===e?t.bitmap=i.readBytes():3===e?t.width=i.readVarint():4===e?t.height=i.readVarint():5===e?t.left=i.readSVarint():6===e?t.top=i.readSVarint():7===e&&(t.advance=i.readVarint())}const ef={horizontal:1,vertical:2,horizontalOnly:3};class tf{constructor(){this.scale=1,this.fontStack="",this.image=null}static forText(e,t){const i=new tf;return i.scale=e||1,i.fontStack=t,i}static forImage(e){const t=new tf;return t.image=e,t}}class rf{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,t){const i=new rf;for(let r=0;r<e.sections.length;r++){const n=e.sections[r];n.image?i.addImageSection(n):i.addTextSection(n,t)}return i}length(){return this.text.length}getSection(e){return this.sections[this.sectionIndex[e]]}getSections(){return this.sections}getSectionIndex(e){return this.sectionIndex[e]}getCodePoint(e){return this.text.codePointAt(e)}verticalizePunctuation(e){this.text=function(e,t){let i="";for(let r=0;r<e.length;r++){const n=e.charCodeAt(r+1)||null,o=e.charCodeAt(r-1)||null;i+=!t&&(n&&cs(n)&&!jp[e[r+1]]||o&&cs(o)&&!jp[e[r-1]])||!jp[e[r]]?e[r]:jp[e[r]]}return i}(this.text,e)}trim(){let e=0;for(let t=0;t<this.text.length&&of[this.text.charCodeAt(t)];t++)e++;let t=this.text.length;for(let i=this.text.length-1;i>=0&&i>=e&&of[this.text.charCodeAt(i)];i--)t--;this.text=this.text.substring(e,t),this.sectionIndex=this.sectionIndex.slice(e,t)}substring(e,t){const i=new rf;return i.text=this.text.substring(e,t),i.sectionIndex=this.sectionIndex.slice(e,t),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((e,t)=>Math.max(e,this.sections[t].scale)),0)}addTextSection(e,t){this.text+=e.text,this.sections.push(tf.forText(e.scale,e.fontStack||t));const i=this.sections.length-1;for(let t=0;t<e.text.length;++t)this.sectionIndex.push(i)}addImageSection(e){const t=e.image&&e.image.namePrimary?e.image.getPrimary():null;if(!t)return void ue("Can't add FormattedSection with an empty image.");const i=this.getNextImageSectionCharCode();i?(this.text+=String.fromCodePoint(i),this.sections.push(tf.forImage(t)),this.sectionIndex.push(this.sections.length-1)):ue("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function nf(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f){const m=rf.fromFeature(e,n);u===ef.vertical&&m.verticalizePunctuation(d);let _=[];const g=function(e,t,i,r,n,o){if(!e)return[];const s=[],a=function(e,t,i,r,n,o){let s=0;for(let i=0;i<e.length();i++){const a=e.getSection(i);s+=af(e.getCodePoint(i),a,r,n,t,o)}return s/Math.max(1,Math.ceil(s/i))}(e,t,i,r,n,o),l=e.text.indexOf("​")>=0;let c=0;for(let i=0;i<e.length();i++){const u=e.getSection(i),d=e.getCodePoint(i);if(of[d]||(c+=af(d,u,r,n,t,o)),i<e.length()-1){const t=!((h=d)<11904||!(ko(h)||Ro(h)||Qo(h)||Yo(h)||Vo(h)||Ao(h)||Fo(h)||Po(h)||Uo(h)||Go(h)||No(h)||is(h)||zo(h)||Co(h)||Io(h)||Bo(h)||Do(h)||Jo(h)||Zo(h)||qo(h)));(sf[d]||t||u.image)&&s.push(hf(i+1,c,a,s,cf(d,e.getCodePoint(i+1),t&&l),!1))}}var h;return uf(hf(e.length(),c,a,s,0,!0))}(m,c,o,t,r,p),{processBidirectionalText:y,processStyledBidirectionalText:x}=Ss;if(y&&1===m.sections.length){const e=y(m.toString(),g);for(const t of e){const e=new rf;e.text=t,e.sections=m.sections;for(let i=0;i<t.length;i++)e.sectionIndex.push(0);_.push(e)}}else if(x){const e=x(m.text,m.sectionIndex,g);for(const t of e){const e=new rf;e.text=t[0],e.sectionIndex=t[1],e.sections=m.sections,_.push(e)}}else _=function(e,t){const i=[],r=e.text;let n=0;for(const r of t)i.push(e.substring(n,r)),n=r;return n<r.length&&i.push(e.substring(n,r.length)),i}(m,g);const v=[],b={positionedLines:v,text:m.toString(),top:h[1],bottom:h[1],left:h[0],right:h[0],writingMode:u,iconsInText:!1,verticalizable:!1,hasBaseline:!1};return function(e,t,i,r,n,o,s,a,l,c,h,u){let d=0,p=0,f=0;const m="right"===a?1:"left"===a?0:.5;let _=!1;for(const e of n){const i=e.getSections();for(const e of i){if(e.image)continue;const i=t[e.fontStack];if(i&&(_=void 0!==i.ascender&&void 0!==i.descender,!_))break}if(!_)break}let g=0;for(const s of n){s.trim();const n=s.getMaxScale(),a=(n-1)*Lp,x={positionedGlyphs:[],lineOffset:0};e.positionedLines[g]=x;const v=x.positionedGlyphs;let b=0;if(!s.length()){p+=o,++g;continue}let w=0,T=0;for(let o=0;o<s.length();o++){const a=s.getSection(o),f=s.getSectionIndex(o),m=s.getCodePoint(o);let g=a.scale,x=null,S=null,M=null,E=Lp,A=0;const I=!(l===ef.horizontal||!h&&!ls(m)||h&&(of[m]||(y=m,co(y)||ho(y)||uo(y)||Ko(y)||ts(y))));if(a.image){const t=r[a.image.serialize()];if(!t)continue;M=a.image.id,e.iconsInText=e.iconsInText||!0,S=t.paddedRect;const i=t.displaySize;g=g*Lp/u,x={width:i[0],height:i[1],left:0,top:-3,advance:I?i[1]:i[0],localGlyph:!1},A=_?-x.height*g:n*Lp-17-i[1]*g,E=x.advance;const o=(I?i[0]:i[1])*g-Lp*n;o>0&&o>b&&(b=o)}else{const e=i[a.fontStack];if(!e)continue;e[m]&&(S=e[m]);const r=t[a.fontStack];if(!r)continue;const o=r.glyphs[m];if(!o)continue;if(x=o.metrics,E=8203!==m?Lp:0,_){const e=void 0!==r.ascender?Math.abs(r.ascender):0,t=void 0!==r.descender?Math.abs(r.descender):0,i=(e+t)*g;w<i&&(w=i,T=(e-t)/2*g),A=-e*g}else A=(n-g)*Lp-17}I?(e.verticalizable=!0,v.push({glyph:m,imageName:M,x:d,y:p+A,vertical:I,scale:g,localGlyph:x.localGlyph,fontStack:a.fontStack,sectionIndex:f,metrics:x,rect:S}),d+=E*g+c):(v.push({glyph:m,imageName:M,x:d,y:p+A,vertical:I,scale:g,localGlyph:x.localGlyph,fontStack:a.fontStack,sectionIndex:f,metrics:x,rect:S}),d+=x.advance*g+c)}0!==v.length&&(f=Math.max(d-c,f),_?pf(v,m,b,T,o*n/2):pf(v,m,b,0,o/2)),d=0;const S=o*n+b;x.lineOffset=Math.max(b,a),p+=S,++g}var y;const x=p,{horizontalAlign:v,verticalAlign:b}=df(s);(function(e,t,i,r,n,o){const s=(t-i)*n,a=-o*r;for(const t of e)for(const e of t.positionedGlyphs)e.x+=s,e.y+=a})(e.positionedLines,m,v,b,f,x),e.top+=-b*x,e.bottom=e.top+x,e.left+=-v*f,e.right=e.left+f,e.hasBaseline=_}(b,t,i,r,_,s,a,l,u,c,d,f),!function(e){for(const t of e)if(0!==t.positionedGlyphs.length)return!1;return!0}(v)&&b}const of={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},sf={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function af(e,t,i,r,n,o){if(t.image){const e=r[t.image.serialize()];return e?e.displaySize[0]*t.scale*Lp/o+n:0}{const r=i[t.fontStack],o=r&&r.glyphs[e];return o?o.metrics.advance*t.scale+n:0}}function lf(e,t,i,r){const n=Math.pow(e-t,2);return r?e<t?n/2:2*n:n+Math.abs(i)*i}function cf(e,t,i){let r=0;return 10===e&&(r-=1e4),i&&(r+=150),40!==e&&65288!==e||(r+=50),41!==t&&65289!==t||(r+=50),r}function hf(e,t,i,r,n,o){let s=null,a=lf(t,i,n,o);for(const e of r){const r=lf(t-e.x,i,n,o)+e.badness;r<=a&&(s=e,a=r)}return{index:e,x:t,priorBreak:s,badness:a}}function uf(e){return e?uf(e.priorBreak).concat(e.index):[]}function df(e){let t=.5,i=.5;switch(e){case"right":case"top-right":case"bottom-right":t=1;break;case"left":case"top-left":case"bottom-left":t=0}switch(e){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:t,verticalAlign:i}}function pf(e,t,i,r,n){if(!(t||i||r||n))return;const o=e.length-1,s=e[o],a=(s.x+s.metrics.advance*s.scale)*t;for(let t=0;t<=o;t++)e[t].x-=a,e[t].y+=i+r+n}function ff(e,t,i,r){const{horizontalAlign:n,verticalAlign:o}=df(r),s=i[0]-e.displaySize[0]*n,a=i[1]-e.displaySize[1]*o;return{imagePrimary:e,imageSecondary:t,top:a,bottom:a+e.displaySize[1],left:s,right:s+e.displaySize[0]}}function mf(e,t,i,r,n,o){const s=e.imagePrimary;let a;if(s.content){const e=s.content,t=s.pixelRatio||1;a=[e[0]/t,e[1]/t,s.displaySize[0]-e[2]/t,s.displaySize[1]-e[3]/t]}const l=t.left*o,c=t.right*o;let h,u,d,p;"width"===i||"both"===i?(p=n[0]+l-r[3],u=n[0]+c+r[1]):(p=n[0]+(l+c-s.displaySize[0])/2,u=p+s.displaySize[0]);const f=t.top*o,m=t.bottom*o;return"height"===i||"both"===i?(h=n[1]+f-r[0],d=n[1]+m+r[2]):(h=n[1]+(f+m-s.displaySize[1])/2,d=h+s.displaySize[1]),{imagePrimary:s,imageSecondary:void 0,top:h,right:u,bottom:d,left:p,collisionPadding:a}}class _f extends U{constructor(e,t,i,r,n){super(e,t),this.angle=r,this.z=i,void 0!==n&&(this.segment=n)}clone(){return new _f(this.x,this.y,this.z,this.angle,this.segment)}}function gf(e,t,i,r,n){if(void 0===t.segment)return!0;let o=t,s=t.segment+1,a=0;for(;a>-i/2;){if(s--,s<0)return!1;a-=e[s].dist(o),o=e[s]}a+=e[s].dist(e[s+1]),s++;const l=[];let c=0;for(;a<i/2;){const t=e[s],i=e[s+1];if(!i)return!1;let o=e[s-1].angleTo(t)-t.angleTo(i);for(o=Math.abs((o+3*Math.PI)%(2*Math.PI)-Math.PI),l.push({distance:a,angleDelta:o}),c+=o;a-l[0].distance>r;)c-=l.shift().angleDelta;if(c>n)return!1;s++,a+=t.dist(i)}return!0}function yf(e){let t=0;for(let i=0;i<e.length-1;i++)t+=e[i].dist(e[i+1]);return t}function xf(e,t,i){return e?.6*t*i:0}function vf(e,t){return Math.max(e?e.right-e.left:0,t?t.right-t.left:0)}function bf(e,t,i,r,n,o){const s=xf(i,n,o),a=vf(i,r)*o;let l=0;const c=yf(e)/2;for(let i=0;i<e.length-1;i++){const r=e[i],n=e[i+1],o=r.dist(n);if(l+o>c){const h=(c-l)/o,u=Et(r.x,n.x,h),d=Et(r.y,n.y,h),p=new _f(u,d,0,n.angleTo(r),i);return!s||gf(e,p,a,s,t)?p:void 0}l+=o}}function wf(e,t,i,r,n,o,s,a,l){const c=xf(r,o,s),h=vf(r,n),u=h*s,d=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-u<t/4&&(t=u+t/4),Tf(e,d?t/2*a%t:(h/2+2*o)*s*a%t,t,c,i,u,d,!1,l)}function Tf(e,t,i,r,n,o,s,a,l){const c=o/2,h=yf(e);let u=0,d=t-i,p=[];for(let t=0;t<e.length-1;t++){const s=e[t],a=e[t+1],f=s.dist(a),m=a.angleTo(s);for(;d+i<u+f;){d+=i;const _=(d-u)/f,g=Et(s.x,a.x,_),y=Et(s.y,a.y,_);if(g>=0&&g<l&&y>=0&&y<l&&d-c>=0&&d+c<=h){const i=new _f(g,y,0,m,t);r&&!gf(e,i,o,r,n)||p.push(i)}}u+=f}return a||p.length||s||(p=Tf(e,u/2,i,r,n,o,s,!0,l)),p}function Sf(e,t,i,r,n){const o=[];for(let s=0;s<e.length;s++){const a=e[s];let l;for(let e=0;e<a.length-1;e++){let s=a[e],c=a[e+1];s.x<t&&c.x<t||(s.x<t?s=new U(t,s.y+(t-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x<t&&(c=new U(t,s.y+(t-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y<i&&c.y<i||(s.y<i?s=new U(s.x+(i-s.y)/(c.y-s.y)*(c.x-s.x),i)._round():c.y<i&&(c=new U(s.x+(i-s.y)/(c.y-s.y)*(c.x-s.x),i)._round()),s.x>=r&&c.x>=r||(s.x>=r?s=new U(r,s.y+(r-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=r&&(c=new U(r,s.y+(r-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=n&&c.y>=n||(s.y>=n?s=new U(s.x+(n-s.y)/(c.y-s.y)*(c.x-s.x),n)._round():c.y>=n&&(c=new U(s.x+(n-s.y)/(c.y-s.y)*(c.x-s.x),n)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function Mf(e){let t=0,i=0;for(const r of e)t+=r.w*r.h,i=Math.max(i,r.w);e.sort(((e,t)=>t.h-e.h));const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}];let n=0,o=0;for(const t of e)for(let e=r.length-1;e>=0;e--){const i=r[e];if(!(t.w>i.w||t.h>i.h)){if(t.x=i.x,t.y=i.y,o=Math.max(o,t.y+t.h),n=Math.max(n,t.x+t.w),t.w===i.w&&t.h===i.h){const t=r.pop();e<r.length&&(r[e]=t)}else t.h===i.h?(i.x+=t.w,i.w-=t.w):t.w===i.w?(i.y+=t.h,i.h-=t.h):(r.push({x:i.x+t.w,y:i.y,w:i.w-t.w,h:t.h}),i.y+=t.h,i.h-=t.h);break}}return{w:n,h:o,fill:t/(n*o)||0}}ro(_f,"Anchor");class Ef{constructor(e,{pixelRatio:t,version:i,stretchX:r,stretchY:n,content:o},s){this.paddedRect=e,this.pixelRatio=t,this.stretchX=r,this.stretchY=n,this.content=o,this.version=i,this.padding=s}get tl(){return[this.paddedRect.x+this.padding,this.paddedRect.y+this.padding]}get br(){return[this.paddedRect.x+this.paddedRect.w-this.padding,this.paddedRect.y+this.paddedRect.h-this.padding]}get displaySize(){return[(this.paddedRect.w-2*this.padding)/this.pixelRatio,(this.paddedRect.h-2*this.padding)/this.pixelRatio]}}class Af{constructor(e,t,i){const r={},n={};this.haveRenderCallbacks=[];const o=[];this.addImages(e,r,1,o),this.addImages(t,n,2,o);const{w:s,h:a}=Mf(o),l=new $h({width:s||1,height:a||1});for(const t in e){const n=e[t],o=r[t].paddedRect;$h.copy(n.data,l,{x:0,y:0},{x:o.x+1,y:o.y+1},n.data,i,n.sdf)}for(const e in t){const r=t[e],o=n[e].paddedRect;let s=n[e].padding;const a=o.x+s,c=o.y+s,h=r.data.width,u=r.data.height;s=s>1?s-1:s,$h.copy(r.data,l,{x:0,y:0},{x:a,y:c},r.data,i),$h.copy(r.data,l,{x:0,y:u-s},{x:a,y:c-s},{width:h,height:s},i),$h.copy(r.data,l,{x:0,y:0},{x:a,y:c+u},{width:h,height:s},i),$h.copy(r.data,l,{x:h-s,y:0},{x:a-s,y:c},{width:s,height:u},i),$h.copy(r.data,l,{x:0,y:0},{x:a+h,y:c},{width:s,height:u},i),$h.copy(r.data,l,{x:h-s,y:u-s},{x:a-s,y:c-s},{width:s,height:s},i),$h.copy(r.data,l,{x:0,y:u-s},{x:a+h,y:c-s},{width:s,height:s},i),$h.copy(r.data,l,{x:0,y:0},{x:a+h,y:c+u},{width:s,height:s},i),$h.copy(r.data,l,{x:h-s,y:0},{x:a-s,y:c+u},{width:s,height:s},i)}this.image=l,this.iconPositions=r,this.patternPositions=n}addImages(e,t,i,r){for(const n in e){const o=e[n],s={x:0,y:0,w:o.data.width+2*i,h:o.data.height+2*i};r.push(s),t[n]=new Ef(s,o,i),o.hasRenderCallback&&this.haveRenderCallbacks.push(n)}}patchUpdatedImages(e,t,i){this.haveRenderCallbacks=this.haveRenderCallbacks.filter((t=>e.hasImage(t,i))),e.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const r in e.getUpdatedImages(i)){const n=Jt.build(r).getSerializedPrimary();this.patchUpdatedImage(this.iconPositions[n],e.getImage(r,i),t),this.patchUpdatedImage(this.patternPositions[n],e.getImage(r,i),t)}}patchUpdatedImage(e,t,i){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[r,n]=e.tl;i.update(t.data,{position:{x:r,y:n}})}}ro(Ef,"ImagePosition"),ro(Af,"ImageAtlas");const If=1e20;function Cf(e,t,i,r,n,o,s,a,l){for(let c=t;c<t+r;c++)Pf(e,i*o+c,o,n,s,a,l);for(let c=i;c<i+n;c++)Pf(e,c*o+t,1,r,s,a,l)}function Pf(e,t,i,r,n,o,s){o[0]=0,s[0]=-If,s[1]=If,n[0]=e[t];for(let a=1,l=0,c=0;a<r;a++){n[a]=e[t+a*i];const r=a*a;do{const e=o[l];c=(n[a]-n[e]+r-e*e)/(a-e)/2}while(c<=s[l]&&--l>-1);l++,o[l]=a,s[l]=c,s[l+1]=If}for(let a=0,l=0;a<r;a++){for(;s[l+1]<a;)l++;const r=o[l],c=a-r;e[t+a*i]=n[r]+c*c}}const zf={none:0,ideographs:1,all:2};class Df{constructor(e,t,i){this.requestManager=e,this.localGlyphMode=t,this.localFontFamily=i,this.urls={},this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}}}setURL(e,t){this.urls[t]=e}getGlyphs(e,t,i){const r=[],n=this.urls[t]||Te.GLYPHS_URL;for(const t in e)for(const i of e[t])r.push({stack:t,id:i});ee(r,(({stack:e,id:t},i)=>{let r=this.entries[e];r||(r=this.entries[e]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let o=r.glyphs[t];if(void 0!==o)return void i(null,{stack:e,id:t,glyph:o});if(o=this._tinySDF(r,e,t),o)return r.glyphs[t]=o,void i(null,{stack:e,id:t,glyph:o});const s=Math.floor(t/256);if(256*s>65535)return ue("glyphs > 65535 not supported"),void i(null,{stack:e,id:t,glyph:o});if(r.ranges[s])return void i(null,{stack:e,id:t,glyph:o});let a=r.requests[s];a||(a=r.requests[s]=[],Df.loadGlyphRange(e,s,n,this.requestManager,((e,t)=>{if(t){r.ascender=t.ascender,r.descender=t.descender;for(const e in t.glyphs)this._doesCharSupportLocalGlyph(+e)||(r.glyphs[+e]=t.glyphs[+e]);r.ranges[s]=!0}for(const i of a)i(e,t);delete r.requests[s]}))),a.push(((r,n)=>{r?i(r):n&&i(null,{stack:e,id:t,glyph:n.glyphs[t]||null})}))}),((e,t)=>{if(e)i(e);else if(t){const e={};for(const{stack:i,id:r,glyph:n}of t)void 0===e[i]&&(e[i]={}),void 0===e[i].glyphs&&(e[i].glyphs={}),e[i].glyphs[r]=n&&{id:n.id,bitmap:n.bitmap.clone(),metrics:n.metrics},e[i].ascender=this.entries[i].ascender,e[i].descender=this.entries[i].descender;i(null,e)}}))}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==zf.none&&(this.localGlyphMode===zf.all?!!this.localFontFamily:!!this.localFontFamily&&(Go(e)||Ho(e)||zo(e)||Do(e)||Po(e)||Uo(e)||ns(e)||rs(e)))}_tinySDF(e,t,i){const r=this.localFontFamily;if(!r||!this._doesCharSupportLocalGlyph(i))return;let n=e.tinySDF;if(!n){let i="400";/bold/i.test(t)?i="900":/medium/i.test(t)?i="500":/light/i.test(t)&&(i="200"),n=e.tinySDF=new Df.TinySDF({fontFamily:r,fontWeight:i,fontSize:48,buffer:6,radius:16}),n.fontWeight=i}if(this.localGlyphs[n.fontWeight][i])return this.localGlyphs[n.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:h,glyphLeft:u,glyphTop:d,glyphAdvance:p}=n.draw(o);return this.localGlyphs[n.fontWeight][i]={id:i,bitmap:new Zh({width:a,height:l},s),metrics:{width:c/2,height:h/2,left:u/2,top:d/2-27,advance:p/2,localGlyph:!0}}}}Df.loadGlyphRange=function(e,t,i,r,n){const o=256*t,s=o+255,a=r.transformRequest(r.normalizeGlyphsURL(i).replace("{fontstack}",e).replace("{range}",`${o}-${s}`),Je.Glyphs);it(a,((e,t)=>{if(e)n(e);else if(t){const e={},i=function(e){return new Yp(e).readFields(Kp,{})}(t);for(const t of i.glyphs)e[t.id]=t;n(null,{glyphs:e,ascender:i.ascender,descender:i.descender})}}))},Df.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:r=.25,fontFamily:n="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=t,this.cutoff=r,this.radius=i;const a=this.size=e+4*t,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${e}px ${n}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:n,actualBoundingBoxRight:o}=this.ctx.measureText(e),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-n))),l=Math.min(this.size-this.buffer,s+Math.ceil(r)),c=a+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),d=new Uint8ClampedArray(u),p={data:d,width:c,height:h,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:t};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(e,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(If,0,u),_.fill(0,0,u);for(let e=0;e<l;e++)for(let t=0;t<a;t++){const i=y.data[4*(e*a+t)+3]/255;if(0===i)continue;const r=(e+m)*c+t+m;if(1===i)g[r]=0,_[r]=If;else{const e=.5-i;g[r]=e>0?e*e:0,_[r]=e<0?e*e:0}}Cf(g,0,0,c,h,c,this.f,this.v,this.z),Cf(_,m,m,a,l,c,this.f,this.v,this.z);for(let e=0;e<u;e++){const t=Math.sqrt(g[e])-Math.sqrt(_[e]);d[e]=Math.round(255-255*(t/this.radius+this.cutoff))}return p}};function Rf(e,t){return e+t[1]-t[0]}function Lf(e,t,i,r,n=1){const o=[],s=e.imagePrimary,a=s.pixelRatio,l=s.paddedRect.w-2,c=s.paddedRect.h-2,h=(e.right-e.left)*n,u=(e.bottom-e.top)*n,d=s.stretchX||[[0,l]],p=s.stretchY||[[0,c]],f=d.reduce(Rf,0),m=p.reduce(Rf,0),_=l-f,g=c-m;let y=0,x=f,v=0,b=m,w=0,T=_,S=0,M=g;if(s.content&&r){const e=s.content;y=Of(d,0,e[0]),v=Of(p,0,e[1]),x=Of(d,e[0],e[2]),b=Of(p,e[1],e[3]),w=e[0]-y,S=e[1]-v,T=e[2]-e[0]-x,M=e[3]-e[1]-b}const E=(r,o,l,c)=>{const d=Ff(r.stretch-y,x,h,e.left*n),p=Bf(r.fixed-w,T,r.stretch,f),_=Ff(o.stretch-v,b,u,e.top*n),g=Bf(o.fixed-S,M,o.stretch,m),E=Ff(l.stretch-y,x,h,e.left*n),A=Bf(l.fixed-w,T,l.stretch,f),I=Ff(c.stretch-v,b,u,e.top*n),C=Bf(c.fixed-S,M,c.stretch,m),P=new U(d,_),z=new U(E,_),D=new U(E,I),R=new U(d,I),L=new U(p/a,g/a),O=new U(A/a,C/a),k=t*Math.PI/180;if(k){const e=Math.sin(k),t=Math.cos(k),i=[t,-e,e,t];P._matMult(i),z._matMult(i),R._matMult(i),D._matMult(i)}const F=r.stretch+r.fixed,B=l.stretch+l.fixed,N=o.stretch+o.fixed,V=c.stretch+c.fixed,j=e.imageSecondary;return{tl:P,tr:z,bl:R,br:D,texPrimary:{x:s.paddedRect.x+1+F,y:s.paddedRect.y+1+N,w:B-F,h:V-N},texSecondary:j?{x:j.paddedRect.x+1+F,y:j.paddedRect.y+1+N,w:B-F,h:V-N}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:L,pixelOffsetBR:O,minFontScaleX:T/a/h,minFontScaleY:M/a/u,isSDF:i}};if(r&&(s.stretchX||s.stretchY)){const e=kf(d,_,f),t=kf(p,g,m);for(let i=0;i<e.length-1;i++){const r=e[i],n=e[i+1];for(let e=0;e<t.length-1;e++)o.push(E(r,t[e],n,t[e+1]))}}else o.push(E({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:l+1},{fixed:0,stretch:c+1}));return o}function Of(e,t,i){let r=0;for(const n of e)r+=Math.max(t,Math.min(i,n[1]))-Math.max(t,Math.min(i,n[0]));return r}function kf(e,t,i){const r=[{fixed:-1,stretch:0}];for(const[t,i]of e){const e=r[r.length-1];r.push({fixed:t-e.stretch,stretch:e.stretch}),r.push({fixed:t-e.stretch,stretch:e.stretch+(i-t)})}return r.push({fixed:t+1,stretch:i}),r}function Ff(e,t,i,r){return e/t*i+r}function Bf(e,t,i,r){return e-t*i/r}function Nf(e,t,i,r){const n=t+e.positionedLines[r].lineOffset;return 0===r?i+n/2:i+(n+(t+e.positionedLines[r-1].lineOffset))/2}function Vf(e,t=1,i=!1){let r=1/0,n=1/0,o=-1/0,s=-1/0;const a=e[0];for(let e=0;e<a.length;e++){const t=a[e];(!e||t.x<r)&&(r=t.x),(!e||t.y<n)&&(n=t.y),(!e||t.x>o)&&(o=t.x),(!e||t.y>s)&&(s=t.y)}const l=Math.min(o-r,s-n);let c=l/2;const h=new Hi([],Uf);if(0===l)return new U(r,n);for(let t=r;t<o;t+=l)for(let i=n;i<s;i+=l)h.push(new jf(t+c,i+c,c,e));let u=function(e){let t=0,i=0,r=0;const n=e[0];for(let e=0,o=n.length,s=o-1;e<o;s=e++){const o=n[e],a=n[s],l=o.x*a.y-a.x*o.y;i+=(o.x+a.x)*l,r+=(o.y+a.y)*l,t+=3*l}return new jf(i/t,r/t,0,e)}(e),d=h.length;for(;h.length;){const r=h.pop();(r.d>u.d||!u.d)&&(u=r,i&&console.log("found best %d after %d probes",Math.round(1e4*r.d)/1e4,d)),r.max-u.d<=t||(c=r.h/2,h.push(new jf(r.p.x-c,r.p.y-c,c,e)),h.push(new jf(r.p.x+c,r.p.y-c,c,e)),h.push(new jf(r.p.x-c,r.p.y+c,c,e)),h.push(new jf(r.p.x+c,r.p.y+c,c,e)),d+=4)}return i&&(console.log(`num probes: ${d}`),console.log(`best distance: ${u.d}`)),u.p}function Uf(e,t){return t.max-e.max}class jf{constructor(e,t,i,r){this.p=new U(e,t),this.h=i,this.d=function(e,t){let i=!1,r=1/0;for(let n=0;n<t.length;n++){const o=t[n];for(let t=0,n=o.length,s=n-1;t<n;s=t++){const n=o[t],a=o[s];n.y>e.y!=a.y>e.y&&e.x<(a.x-n.x)*(e.y-n.y)/(a.y-n.y)+n.x&&(i=!i),r=Math.min(r,Ec(e,n,a))}}return(i?1:-1)*Math.sqrt(r)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}}const Gf=Number.POSITIVE_INFINITY,qf=Math.sqrt(2);function Zf(e,[t,i]){let r=0,n=0;if(i===Gf){t<0&&(t=0);const i=t/qf;switch(e){case"top-right":case"top-left":n=i-7;break;case"bottom-right":case"bottom-left":n=7-i;break;case"bottom":n=7-t;break;case"top":n=t-7}switch(e){case"top-right":case"bottom-right":r=-i;break;case"top-left":case"bottom-left":r=i;break;case"left":r=t;break;case"right":r=-t}}else{switch(t=Math.abs(t),i=Math.abs(i),e){case"top-right":case"top-left":case"top":n=i-7;break;case"bottom-right":case"bottom-left":case"bottom":n=7-i}switch(e){case"top-right":case"bottom-right":case"right":r=-t;break;case"top-left":case"bottom-left":case"left":r=t}}return[r,n]}function $f(e){switch(e){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Hf(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m){let _=o.textMaxSize.evaluate(t,{},d);void 0===_?_=s*o.textScaleFactor:_*=o.textScaleFactor;const g=e.layers[0].layout,y=g.get("icon-offset").evaluate(t,{},d),x=Kf(i.horizontal)||i.vertical,v="globe"===p.name,b=s*o.textScaleFactor/24,w=e.tilePixelRatio*_/24,T=(z=e.overscaling,e.zoom>18&&z>2&&(z>>=1),Math.max(Wi/(512*z),1)*g.get("symbol-spacing")),S=g.get("text-padding")*e.tilePixelRatio,M=g.get("icon-padding")*e.tilePixelRatio,E=Z(g.get("text-max-angle")),A="map"===g.get("text-rotation-alignment")&&"point"!==g.get("symbol-placement"),I="map"===g.get("icon-rotation-alignment")&&"point"!==g.get("symbol-placement"),C=g.get("symbol-placement"),P=T/2;var z;const D=g.get("icon-text-fit").evaluate(t,{},d),R=g.get("icon-text-fit-padding").evaluate(t,{},d),L="none"!==D;let O;!1===e.hasAnyIconTextFit&&L&&(e.hasAnyIconTextFit=!0),r&&L&&(e.allowVerticalPlacement&&i.vertical&&(O=mf(r,i.vertical,D,R,y,b)),x&&(r=mf(r,x,D,R,y,b)));const k=(s,a,_)=>{if(a.x<0||a.x>=Wi||a.y<0||a.y>=Wi)return;let g=null;if(v){const{x:e,y:t,z:i}=p.projectTilePoint(a.x,a.y,_);g={anchor:new _f(e,t,i,0,void 0),up:p.upVector(_,a.x,a.y)}}!function(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,S,M,E,A){const I=e.addToLineVertexArray(t,r);let C,P,z,D,R,L,O,k=0,F=0,B=0,N=0,V=-1,U=-1;const j={};let G=mt("");const q=i?i.anchor:t,Z="none"!==l.layout.get("icon-text-fit").evaluate(v,{},M);let $=0,H=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[$,H]=l.layout.get("text-offset").evaluate(v,{},M).map((e=>e*Lp)):($=l.layout.get("text-radial-offset").evaluate(v,{},M)*Lp,H=Gf),e.allowVerticalPlacement&&n.vertical){const e=n.vertical;if(f)L=Qf(e),a&&(O=Qf(a));else{const i=l.layout.get("text-rotate").evaluate(v,{},M)+90;z=Jf(c,q,t,h,u,d,e,p,i,m),a&&(D=Jf(c,q,t,h,u,d,a,g,i))}}if(o){const r=e.iconSizeData,n=T?kp(e.iconSizeData,e.layers[0]._unevaluatedLayout._values["icon-size"],M,e.zoom,v):1,s=l.layout.get("icon-rotate").evaluate(v,{},M),p=Lf(o,s,w,Z,T?1/n:b.iconScaleFactor),f=a?Lf(a,s,w,Z,b.iconScaleFactor):void 0;P=Jf(c,q,t,h,u,d,o,g,s,null,T?b.iconScaleFactor*n:1),k=4*p.length;let m=null;"source"===r.kind?(m=[Op*l.layout.get("icon-size").evaluate(v,{},M)*b.iconScaleFactor],m[0]>Xf&&ue(`${e.layerIds[0]}: Value for "icon-size" is >= ${Wf}. Reduce your "icon-size".`)):"composite"===r.kind&&(m=[Op*b.compositeIconSizes[0].evaluate(v,{},M)*b.iconScaleFactor,Op*b.compositeIconSizes[1].evaluate(v,{},M)*b.iconScaleFactor],(m[0]>Xf||m[1]>Xf)&&ue(`${e.layerIds[0]}: Value for "icon-size" is >= ${Wf}. Reduce your "icon-size".`)),e.addSymbols(e.icon,p,m,x,y,v,!1,i,t,I.lineStartIndex,I.lineLength,-1,S,M,E,A),V=e.icon.placedSymbolArray.length-1,f&&(F=4*f.length,e.addSymbols(e.icon,f,m,x,y,v,ef.vertical,i,t,I.lineStartIndex,I.lineLength,-1,S,M,E,A),U=e.icon.placedSymbolArray.length-1)}for(const r in n.horizontal){const o=n.horizontal[r];C||(G=mt(o.text),f?R=Qf(o):C=Jf(c,q,t,h,u,d,o,p,l.layout.get("text-rotate").evaluate(v,{},M),m));const a=1===o.positionedLines.length;if(B+=Yf(e,i,t,o,s,l,f,v,m,I,n.vertical?ef.horizontal:ef.horizontalOnly,a?Object.keys(n.horizontal):[r],j,V,b,S,M,E),a)break}n.vertical&&(N+=Yf(e,i,t,n.vertical,s,l,f,v,m,I,ef.vertical,["vertical"],j,U,b,S,M,E));let W=-1;const X=(e,t)=>e?Math.max(e,t):t;W=X(R,W),W=X(L,W),W=X(O,W);const Y=W>-1?1:0;e.glyphOffsetArray.length>=65535&&ue("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==v.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,v.sortKey),e.symbolInstances.emplaceBack(t.x,t.y,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,V,U,G,void 0!==C?C:e.collisionBoxArray.length,void 0!==C?C+1:e.collisionBoxArray.length,void 0!==z?z:e.collisionBoxArray.length,void 0!==z?z+1:e.collisionBoxArray.length,void 0!==P?P:e.collisionBoxArray.length,void 0!==P?P+1:e.collisionBoxArray.length,D||e.collisionBoxArray.length,D?D+1:e.collisionBoxArray.length,h,B,N,k,F,Y,0,$,H,W,0,Z?1:0)}(e,a,g,s,i,r,n,O,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,S,A,l,0,M,I,y,t,o,c,h,u,d,f,m)};if("line"===C)for(const n of Sf(t.geometry,0,0,Wi,Wi)){const t=wf(n,T,E,i.vertical||x,r,24,w,e.overscaling,Wi);for(const i of t)x&&em(e,x.text,P,i)||k(n,i,d)}else if("line-center"===C){for(const e of t.geometry)if(e.length>1){const t=bf(e,E,i.vertical||x,r,24,w);t&&k(e,t,d)}}else if("Polygon"===t.type)for(const e of wu(t.geometry,0)){const t=Vf(e,16);k(e[0],new _f(t.x,t.y,0,0,void 0),d)}else if("LineString"===t.type)for(const e of t.geometry)k(e,new _f(e[0].x,e[0].y,0,0,void 0),d);else if("Point"===t.type)for(const e of t.geometry)for(const t of e)k([t],new _f(t.x,t.y,0,0,void 0),d)}const Wf=255,Xf=Wf*Op;function Yf(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=function(e,t,i,r,n,o,s,a){const l=[];if(0===t.positionedLines.length)return l;const c=r.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,h=function(e){const t=e[0],i=e[1],r=t*i;return r>0?[t,-i]:r<0?[-t,i]:0===t?[i,t]:[i,-t]}(i);let u=Math.abs(t.top-t.bottom);for(const e of t.positionedLines)u-=e.lineOffset;const d=t.positionedLines.length,p=u/d;let f=t.top-i[1];for(let e=0;e<d;++e){const r=t.positionedLines[e];f=Nf(t,p,f,e);for(const e of r.positionedGlyphs){if(!e.rect)continue;const r=e.rect||{};let o=4,u=!0,d=1,p=0;if(e.imageName){const t=s[Jt.build(e.imageName).getSerializedPrimary()];if(!t)continue;if(t.sdf){ue("SDF images are not supported in formatted text and will be ignored.");continue}u=!1,d=t.pixelRatio,o=1/d}const m=(n||a)&&e.vertical,_=e.metrics.advance*e.scale/2,g=e.metrics,y=e.rect;if(null===y)continue;a&&t.verticalizable&&(p=e.imageName?_-e.metrics.width*e.scale/2:0);const x=n?[e.x+_,e.y]:[0,0];let v=[0,0],b=[0,0],w=!1;n||(m?(b=[e.x+_+h[0],e.y+h[1]-p],w=!0):v=[e.x+_+i[0],e.y+i[1]-p]);const T=y.w*e.scale/(d*(e.localGlyph?2:1)),S=y.h*e.scale/(d*(e.localGlyph?2:1));let M,E,A,I;if(m){const t=e.y-f,i=new U(-_,_-t),r=-Math.PI/2,n=new U(...b);M=new U(-_+v[0],v[1]),M._rotateAround(r,i)._add(n),M.x+=-t+_,M.y-=(g.left-o)*e.scale;const s=e.imageName?g.advance*e.scale:Lp*e.scale,a=String.fromCodePoint(e.glyph);Gp(a)?M.x+=(1-o)*e.scale:qp(a)?M.x+=s-g.height*e.scale+(-o-1)*e.scale:M.x+=e.imageName||g.width+2*o===y.w&&g.height+2*o===y.h?(s-S)/2:(s-(g.height+2*o)*e.scale)/2,E=new U(M.x,M.y-T),A=new U(M.x+S,M.y),I=new U(M.x+S,M.y-T)}else{const t=(g.left-o)*e.scale-_+v[0],i=(-g.top-o)*e.scale+v[1],r=t+T,n=i+S;M=new U(t,i),E=new U(r,i),A=new U(t,n),I=new U(r,n)}if(c){let e;e=n?new U(0,0):w?new U(h[0],h[1]):new U(i[0],i[1]),M._rotateAround(c,e),E._rotateAround(c,e),A._rotateAround(c,e),I._rotateAround(c,e)}const C=new U(0,0),P=new U(0,0);l.push({tl:M,tr:E,bl:A,br:I,texPrimary:r,texSecondary:void 0,writingMode:t.writingMode,glyphOffset:x,sectionIndex:e.sectionIndex,isSDF:u,pixelOffsetTL:C,pixelOffsetBR:P,minFontScaleX:0,minFontScaleY:0})}}return l}(0,r,l,o,s,a,n,e.allowVerticalPlacement),x=e.textSizeData;let v=null;"source"===x.kind?(v=[Op*o.layout.get("text-size").evaluate(a,{},_)*f.textScaleFactor],v[0]>Xf&&ue(`${e.layerIds[0]}: Value for "text-size" is >= ${Wf}. Reduce your "text-size".`)):"composite"===x.kind&&(v=[Op*f.compositeTextSizes[0].evaluate(a,{},_)*f.textScaleFactor,Op*f.compositeTextSizes[1].evaluate(a,{},_)*f.textScaleFactor],(v[0]>Xf||v[1]>Xf)&&ue(`${e.layerIds[0]}: Value for "text-size" is >= ${Wf}. Reduce your "text-size".`)),e.addSymbols(e.text,y,v,l,s,a,h,t,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const t of u)d[t]=e.text.placedSymbolArray.length-1;return 4*y.length}function Kf(e){for(const t in e)return e[t];return null}function Jf(e,t,i,r,n,o,s,a,l,c,h=1){let u=s.top/h,d=s.bottom/h,p=s.left/h,f=s.right/h;const m=s.collisionPadding;if(m&&(p-=m[0],u-=m[1],f+=m[2],d+=m[3]),l){const e=new U(p,u),t=new U(f,u),i=new U(p,d),r=new U(f,d),n=Z(l);let o=new U(0,0);c&&(o=new U(c[0],c[1])),e._rotateAround(n,o),t._rotateAround(n,o),i._rotateAround(n,o),r._rotateAround(n,o),p=Math.min(e.x,t.x,i.x,r.x),f=Math.max(e.x,t.x,i.x,r.x),u=Math.min(e.y,t.y,i.y,r.y),d=Math.max(e.y,t.y,i.y,r.y)}return e.emplaceBack(t.x,t.y,t.z,i.x,i.y,p,u,f,d,a,r,n,o),e.length-1}function Qf(e){e.collisionPadding&&(e.top-=e.collisionPadding[1],e.bottom+=e.collisionPadding[3]);const t=e.bottom-e.top;return t>0?Math.max(10,t):null}function em(e,t,i,r){const n=e.compareText;if(t in n){const e=n[t];for(let t=e.length-1;t>=0;t--)if(r.dist(e[t])<i)return!0}else n[t]=[];return n[t].push(r),!1}function tm(e,t){const i=e.fovAboveCenter,r=e.elevation?e.elevation.getMinElevationBelowMSL()*t:0,n=(e._camera.position[2]*e.worldSize-r)/Math.cos(e._pitch),o=Math.sin(i)*n/Math.sin(Math.max(Math.PI/2-e._pitch-i,.01));let s=Math.sin(e._pitch)*o+n;const a=n*(1/e._horizonShift);return e.elevation&&0!==e.elevation.exaggeration()||(s*=1+Math.max(e.zoom-17,0)),Math.min(1.01*s,a)}function im(e,t){if(!t.isReprojectedInTileSpace)return{scale:1<<e.z,x:e.x,y:e.y,x2:e.x+1,y2:e.y+1,projection:t};const i=Math.pow(2,-e.z),r=e.x*i,n=(e.x+1)*i,o=e.y*i,s=(e.y+1)*i,a=Jl(r),l=Jl(n),c=Ql(o),h=Ql(s),u=t.project(a,c),d=t.project(l,c),p=t.project(l,h),f=t.project(a,h);let m=Math.min(u.x,d.x,p.x,f.x),_=Math.min(u.y,d.y,p.y,f.y),g=Math.max(u.x,d.x,p.x,f.x),y=Math.max(u.y,d.y,p.y,f.y);const x=i/16;function v(e,i,r,n,o,s){const a=(r+o)/2,l=(n+s)/2,c=t.project(Jl(a),Ql(l)),h=Math.max(0,m-c.x,_-c.y,c.x-g,c.y-y);m=Math.min(m,c.x),g=Math.max(g,c.x),_=Math.min(_,c.y),y=Math.max(y,c.y),h>x&&(v(e,c,r,n,a,l),v(c,i,a,l,o,s))}v(u,d,r,o,n,o),v(d,p,n,o,n,s),v(p,f,n,s,r,s),v(f,u,r,s,r,o),m-=x,_-=x,g+=x,y+=x;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:t}}function rm(e,{x:t,y:i},r=0){return new U(((t-r)*e.scale-e.x)*Wi,(i*e.scale-e.y)*Wi)}const nm=F.mat4.identity(new Float32Array(16));class om{constructor(e){this.spec=e,this.name=e.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(e,t){return{x:0,y:0,z:0}}unproject(e,t){return new $l(0,0)}projectTilePoint(e,t,i){return{x:e,y:t,z:0}}locationPoint(e,t,i=!0){return e._coordinatePoint(e.locationCoordinate(t),i)}pixelsPerMeter(e,t){return Kl(1,e)*t}pixelSpaceConversion(e,t,i){return 1}farthestPixelDistance(e){return tm(e,e.pixelsPerMeter)}pointCoordinate(e,t,i,r){const n=e.horizonLineFromTop(!1),o=new U(t,Math.max(n,i));return e.rayIntersectionCoordinate(e.pointRayIntersection(o,r))}pointCoordinate3D(e,t,i){const r=new U(t,i);if(e.elevation)return e.elevation.pointCoordinate(r);{const t=this.pointCoordinate(e,r.x,r.y,0);return[t.x,t.y,t.z]}}isPointAboveHorizon(e,t){if(e.elevation&&e.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(e,t.x,t.y);const i=e.horizonLineFromTop();return t.y<i}createInversionMatrix(e,t){return nm}createTileMatrix(e,t,i){let r,n,o;const s=i.canonical,a=F.mat4.identity(new Float64Array(16));if(this.isReprojectedInTileSpace){const l=im(s,this);r=1,n=l.x+i.wrap*l.scale,o=l.y,F.mat4.scale(a,a,[r/l.scale,r/l.scale,e.pixelsPerMeter/t])}else r=t/e.zoomScale(s.z),n=(s.x+Math.pow(2,s.z)*i.wrap)*r,o=s.y*r;return F.mat4.translate(a,a,[n,o,0]),F.mat4.scale(a,a,[r/Wi,r/Wi,1]),a}upVector(e,t,i){return[0,0,1]}upVectorScale(e,t,i){return{metersToTile:1}}}class sm extends om{constructor(e){super(e),this.range=[4,7],this.center=e.center||[-96,37.5];const[t,i]=this.parallels=e.parallels||[29.5,45.5],r=Math.sin(Z(t));this.n=(r+Math.sin(Z(i)))/2,this.c=1+r*(2*this.n-r),this.r0=Math.sqrt(this.c)/this.n}project(e,t){const{n:i,c:r,r0:n}=this,o=Z(e-this.center[0]),s=Z(t),a=Math.sqrt(r-2*i*Math.sin(s))/i;return{x:a*Math.sin(o*i),y:a*Math.cos(o*i)-n,z:0}}unproject(e,t){const{n:i,c:r,r0:n}=this,o=n+t;let s=Math.atan2(e,Math.abs(o))*Math.sign(o);o*i<0&&(s-=Math.PI*Math.sign(e)*Math.sign(o));const a=Z(this.center[0])*i;s=Q(s,-Math.PI-a,Math.PI-a);const l=K($(s/i)+this.center[0],-180,180),c=Math.asin(K((r-(e*e+o*o)*i*i)/(2*i),-1,1)),h=K($(c),-tc,tc);return new $l(l,h)}}const am=1.340264,lm=-.081106,cm=893e-6,hm=.003796,um=Math.sqrt(3)/2;class dm extends om{project(e,t){t=t/180*Math.PI,e=e/180*Math.PI;const i=Math.asin(um*Math.sin(t)),r=i*i,n=r*r*r;return{x:.5*(e*Math.cos(i)/(um*(am+3*lm*r+n*(7*cm+9*hm*r)))/Math.PI+.5),y:1-.5*(i*(am+lm*r+n*(cm+hm*r))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let i=t=(2*(1-t)-1)*Math.PI,r=i*i,n=r*r*r;for(let e,o,s,a=0;a<12&&(o=i*(am+lm*r+n*(cm+hm*r))-t,s=am+3*lm*r+n*(7*cm+9*hm*r),e=o/s,i=K(i-e,-Math.PI/3,Math.PI/3),r=i*i,n=r*r*r,!(Math.abs(e)<1e-12));++a);const o=um*e*(am+3*lm*r+n*(7*cm+9*hm*r))/Math.cos(i),s=Math.asin(Math.sin(i)/um),a=K(180*o/Math.PI,-180,180),l=K(180*s/Math.PI,-tc,tc);return new $l(a,l)}}class pm extends om{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0}project(e,t){return{x:.5+e/360,y:.5-t/360,z:0}}unproject(e,t){const i=360*(e-.5),r=K(360*(.5-t),-tc,tc);return new $l(i,r)}}const fm=Math.PI/2;function mm(e){return Math.tan((fm+e)/2)}class _m extends om{constructor(e){super(e),this.center=e.center||[0,30];const[t,i]=this.parallels=e.parallels||[30,30];let r=Z(t),n=Z(i);this.southernCenter=r+n<0,this.southernCenter&&(r=-r,n=-n);const o=Math.cos(r),s=mm(r);this.n=r===n?Math.sin(r):Math.log(o/Math.cos(n))/Math.log(mm(n)/s),this.f=o*Math.pow(mm(r),this.n)/this.n}project(e,t){t=Z(t),this.southernCenter&&(t=-t),e=Z(e-this.center[0]);const i=1e-6,{n:r,f:n}=this;n>0?t<-fm+i&&(t=-fm+i):t>fm-i&&(t=fm-i);const o=n/Math.pow(mm(t),r);let s=o*Math.sin(r*e),a=n-o*Math.cos(r*e);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,z:0}}unproject(e,t){e=(2*e-.5)*Math.PI,this.southernCenter&&(t=1-t),t=(2*(1-t)-.5)*Math.PI;const{n:i,f:r}=this,n=r-t,o=Math.sign(n),s=Math.sign(i)*Math.sqrt(e*e+n*n);let a=Math.atan2(e,Math.abs(n))*o;n*i<0&&(a-=Math.PI*Math.sign(e)*o);const l=K($(a/i)+this.center[0],-180,180),c=K($(2*Math.atan(Math.pow(r/s,1/i))-fm),-tc,tc);return new $l(l,this.southernCenter?-c:c)}}class gm extends om{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(e,t){return{x:Xl(e),y:Yl(t),z:0}}unproject(e,t){const i=Jl(e),r=Ql(t);return new $l(i,r)}}const ym=Z(tc);class xm extends om{project(e,t){const i=(t=Z(t))*t,r=i*i;return{x:.5*((e=Z(e))*(.8707-.131979*i+r*(r*(.003971*i-.001529*r)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+i*(.015085+r*(.028874*i-.044475-.005916*r)))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let i=t=(2*(1-t)-1)*Math.PI,r=25,n=0,o=i*i;do{o=i*i;const e=o*o;n=(i*(1.007226+o*(.015085+e*(.028874*o-.044475-.005916*e)))-t)/(1.007226+o*(.045255+e*(.259866*o-.311325-.005916*11*e))),i=K(i-n,-ym,ym)}while(Math.abs(n)>1e-6&&--r>0);o=i*i;const s=K($(e/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=$(i);return new $l(s,a)}}const vm=Z(tc);class bm extends om{project(e,t){t=Z(t),e=Z(e);const i=Math.cos(t),r=2/Math.PI,n=Math.acos(i*Math.cos(e/2)),o=Math.sin(n)/n,s=.5*(e*r+2*i*Math.sin(e/2)/o)||0,a=.5*(t+Math.sin(t)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(e,t){let i=e=(2*e-.5)*Math.PI,r=t=(2*(1-t)-1)*Math.PI,n=25;const o=1e-6;let s=0,a=0;do{const n=Math.cos(r),o=Math.sin(r),l=2*o*n,c=o*o,h=n*n,u=Math.cos(i/2),d=Math.sin(i/2),p=2*u*d,f=d*d,m=1-h*u*u,_=m?1/m:0,g=m?Math.acos(n*u)*Math.sqrt(1/m):0,y=.5*(2*g*n*d+2*i/Math.PI)-e,x=.5*(g*o+r)-t,v=.5*_*(h*f+g*n*u*c)+1/Math.PI,b=_*(p*l/4-g*o*d),w=.125*_*(l*d-g*o*h*p),T=.5*_*(c*u+g*f*n)+.5,S=b*w-T*v;s=(x*b-y*T)/S,a=(y*w-x*v)/S,i=K(i-s,-Math.PI,Math.PI),r=K(r-a,-vm,vm)}while((Math.abs(s)>o||Math.abs(a)>o)&&--n>0);return new $l($(i),$(r))}}class wm extends om{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Z(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(e,t){const{scale:i,cosPhi:r}=this;return{x:Z(e)*r*i+.5,y:-Math.sin(Z(t))/r*i+.5,z:0}}unproject(e,t){const{scale:i,cosPhi:r}=this,n=-(t-.5)/i,o=K($((e-.5)/i)/r,-180,180),s=Math.asin(K(n*r,-1,1)),a=K($(s),-tc,tc);return new $l(o,a)}}class Tm extends gm{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,t,i){const r=_h(e,t,i),n=xh(hh(i));return F.vec3.transformMat4(r,r,n),{x:r[0],y:r[1],z:r[2]}}locationPoint(e,t){const i=Gl(t.lat,t.lng),r=F.vec3.normalize([],i),n=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude,o=Kl(1,0)*Wi*n;F.vec3.scaleAndAdd(i,i,r,o);const s=F.mat4.identity(new Float64Array(16));return F.mat4.multiply(s,e.pixelMatrix,e.globeMatrix),F.vec3.transformMat4(i,i,s),new U(i[0],i[1])}pixelsPerMeter(e,t){return Kl(1,0)*t}pixelSpaceConversion(e,t,i){const r=Kl(1,e)*t,n=Et(Kl(1,45)*t,r,i);return this.pixelsPerMeter(e,t)/n}createTileMatrix(e,t,i){const r=vh(hh(i.canonical));return F.mat4.multiply(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,t){const{center:i}=e,r=xh(hh(t));return F.mat4.rotateY(r,r,Z(i.lng)),F.mat4.rotateX(r,r,Z(i.lat)),F.mat4.scale(r,r,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(r)}pointCoordinate(e,t,i,r){return ah(e,t,i,!0)||new sc(0,0)}pointCoordinate3D(e,t,i){const r=this.pointCoordinate(e,t,i,0);return[r.x,r.y,r.z]}isPointAboveHorizon(e,t){return!ah(e,t.x,t.y,!1)}farthestPixelDistance(e){const t=function(e,t){const i=e.cameraToCenterDistance,r=e._centerAltitude*t,n=e._camera,o=e._camera.forward(),s=F.vec3.add([],F.vec3.scale([],o,-i),[0,0,r]),a=e.worldSize/(2*Math.PI),l=[0,0,-a],c=e.width/e.height,h=Math.tan(e.fovAboveCenter),u=F.vec3.scale([],n.up(),h),d=F.vec3.scale([],n.right(),h*c),p=F.vec3.normalize([],F.vec3.add([],F.vec3.add([],o,u),d)),f=[];let m;if(new Kc(s,p).closestPointOnSphere(l,a,f)){const t=F.vec3.add([],f,l),i=F.vec3.sub([],t,s);m=Math.cos(e.fovAboveCenter)*F.vec3.length(i)}else{const e=F.vec3.sub([],s,l),t=F.vec3.sub([],l,s);F.vec3.normalize(t,t);const i=F.vec3.length(e)-a;m=Math.sqrt(i*(i+2*a));const r=Math.acos(m/(a+i))-Math.acos(F.vec3.dot(o,t));m*=Math.cos(r)}return 1.01*m}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),i=Sh(e.zoom);if(i>0){const r=tm(e,Kl(1,e.center.lat)*e.worldSize),n=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Et(t,r+n*(1-Math.cos(o)),Math.pow(i,10))}return t}upVector(e,t,i){return _h(t,i,e,1)}upVectorScale(e){return{metersToTile:oh(gh(hh(e)))}}}function Sm(e){const t=e.parallels,i=!!t&&Math.abs(t[0]+t[1])<.01;switch(e.name){case"mercator":return new gm(e);case"equirectangular":return new pm(e);case"naturalEarth":return new xm(e);case"equalEarth":return new dm(e);case"winkelTripel":return new bm(e);case"albers":return i?new wm(e):new sm(e);case"lambertConformalConic":return i?new wm(e):new _m(e);case"globe":return new Tm(e)}throw new Error(`Invalid projection name: ${e.name}`)}const Mm=Qu.VectorTileFeature.types,Em=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Am(e,t,i,r,n,o,s,a,l,c,h,u,d){const p=a?Math.min(Xf,Math.round(a[0])):0,f=a?Math.min(Xf,Math.round(a[1])):0;e.emplaceBack(t,i,Math.round(32*r),Math.round(32*n),o,s,(p<<1)+(l?1:0),f,16*c,16*h,256*u,256*d)}function Im(e,t,i){e.emplaceBack(t,i)}function Cm(e,t,i,r,n,o,s){e.emplaceBack(t,i,r,n,o,s)}function Pm(e,t,i,r,n){e.emplaceBack(t,i,r,n),e.emplaceBack(t,i,r,n),e.emplaceBack(t,i,r,n),e.emplaceBack(t,i,r,n)}function zm(e){for(const t of e.sections)if(ds(t.text))return!0;return!1}class Dm{constructor(e){this.layoutVertexArray=new va,this.indexArray=new Ia,this.programConfigurations=e,this.segments=new nl,this.dynamicLayoutVertexArray=new ma,this.opacityVertexArray=new wa,this.placedSymbolArray=new $a,this.iconTransitioningVertexArray=new Ta,this.globeExtVertexArray=new ba,this.zOffsetVertexArray=new za}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length&&0===this.iconTransitioningVertexArray.length}upload(e,t,i,r,n){this.isEmpty()||(i&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Mp.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,Ap.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,Em,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,Cp.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Ep.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||n)&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,Ip.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||r)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy())}}ro(Dm,"SymbolBuffers");class Rm{constructor(e,t,i){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new i,this.segments=new nl,this.collisionVertexArray=new Aa,this.collisionVertexArrayExt=new ma}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,Pp.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,zp.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}ro(Rm,"CollisionBuffers");class Lm{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.lut=e.lut,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.fqid)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=F.mat4.identity([]),this.placementViewportMatrix=F.mat4.identity([]);const t=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Fp(this.zoom,t["text-size"]),this.iconSizeData=Fp(this.zoom,t["icon-size"]);const i=this.layers[0].layout,r=i.get("symbol-sort-key"),n=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==n&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===n||"auto"===n&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((e=>ef[e])),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=i.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Dm(new zl(this.layers,{zoom:this.zoom,lut:this.lut},(e=>e.startsWith("text")||e.startsWith("symbol")))),this.icon=new Dm(new zl(this.layers,{zoom:this.zoom,lut:this.lut},(e=>e.startsWith("icon")||e.startsWith("symbol")))),this.glyphOffsetArray=new Xa,this.lineVertexArray=new Ya,this.symbolInstances=new Wa}calculateGlyphDependencies(e,t,i,r,n){for(const i of e){const e=i.codePointAt(0);if(void 0===e)break;if(t[e]=!0,r&&n&&e<=65535){const e=jp[i];e&&(t[e.charCodeAt(0)]=!0)}}}updateFootprints(e,t){}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=t.updateTime;const i=t.getReplacementRegionsForTile(e.toUnwrapped(),!0);return!hd(this.activeReplacements,i)&&(this.activeReplacements=i,!0)}populate(e,t,i,r){const n=this.layers[0],o=n.layout,s="globe"===this.projection.name,a=o.get("text-font"),l=o.get("text-field"),c=o.get("icon-image"),[h,u]=o.get("icon-size-scale-range"),d=K(t.scaleFactor||1,h,u),p=("constant"!==l.value.kind||l.value.value instanceof Yt&&!l.value.value.isEmpty()||l.value.value.toString().length>0)&&("constant"!==a.value.kind||a.value.value.length>0),f="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,m=o.get("symbol-sort-key");if(this.features=[],!p&&!f)return;const _=t.iconDependencies,g=t.glyphDependencies,y=t.availableImages,x=new Ms(this.zoom);for(const{feature:t,id:l,index:c,sourceLayerIndex:h}of e){const e=n._featureFilter.needGeometry,u=mc(t,e);if(!n._featureFilter.filter(x,u,i))continue;if(e||(u.geometry=fc(t,i,r)),s&&1!==t.type&&i.z<=5){const e=u.geometry,t=.98078528056,r=(e,r)=>{const n=_h(e.x,e.y,i,1),o=_h(r.x,r.y,i,1);return F.vec3.dot(n,o)<t};for(let t=0;t<e.length;t++)e[t]=hc(e[t],r)}let v,b;if(p){const e=n.getValueAndResolveTokens("text-field",u,i,y),t=Yt.factory(e);zm(t)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===ws()||this.hasRTLText&&Ss.isParsed())&&(v=Up(t,n,u))}if(f){const e=n.getValueAndResolveTokens("icon-image",u,i,y);b=e instanceof Jt?e:Jt.build(e)}if(!v&&!b)continue;const w=this.sortFeaturesByKey?m.evaluate(u,{},i):void 0,T={id:l,text:v,icon:b,index:c,sourceLayerIndex:h,geometry:u.geometry,properties:t.properties,type:Mm[t.type],sortKey:w};if(this.features.push(T),b){const e=kp(this.iconSizeData,this.layers[0]._unevaluatedLayout._values["icon-size"],i,this.zoom,T)*d*this.pixelRatio,t=b.getPrimary().scaleSelf(e);if(_[t.id]=_[t.id]||[],_[t.id].push(t),b.nameSecondary){const t=b.getSecondary().scaleSelf(e);_[t.id]=_[t.id]||[],_[t.id].push(t)}}if(v){const e=a.evaluate(u,{},i).join(","),t="map"===o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(ef.vertical)>=0;for(const i of v.sections)if(i.image){const e=i.image.getPrimary().scaleSelf(this.pixelRatio);_[e.id]=_[e.id]||[],_[e.id].push(e)}else{const r=os(v.toString()),n=i.fontStack||e,o=g[n]=g[n]||{};this.calculateGlyphDependencies(i.text,o,t,this.allowVerticalPlacement,r)}}}"line"===o.get("symbol-placement")&&(this.features=function(e){const t={},i={},r=[];let n=0;function o(t){r.push(e[t]),n++}function s(e,t,n){const o=i[e];return delete i[e],i[t]=o,r[o].geometry[0].pop(),r[o].geometry[0]=r[o].geometry[0].concat(n[0]),o}function a(e,i,n){const o=t[i];return delete t[i],t[e]=o,r[o].geometry[0].shift(),r[o].geometry[0]=n[0].concat(r[o].geometry[0]),o}function l(e,t,i){const r=i?t[0][t[0].length-1]:t[0][0];return`${e}:${r.x}:${r.y}`}for(let c=0;c<e.length;c++){const h=e[c],u=h.geometry,d=h.text?h.text.toString():null;if(!d){o(c);continue}const p=l(d,u),f=l(d,u,!0);if(p in i&&f in t&&i[p]!==t[f]){const e=a(p,f,u),n=s(p,f,r[e].geometry);delete t[p],delete i[f],i[l(d,r[n].geometry,!0)]=n,r[e].geometry=null}else p in i?s(p,f,u):f in t?a(p,f,u):(o(c),t[p]=n-1,i[f]=n-1)}return r.filter((e=>e.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((e,t)=>e.sortKey-t.sortKey))}update(e,t,i,r,n,o,s){this.text.programConfigurations.updatePaintArrays(e,t,n,i,r,o,s),this.icon.programConfigurations.updatePaintArrays(e,t,n,i,r,o,s)}updateZOffset(){const e=(e,t,r)=>{i+=t,i>e.length&&e.resize(i);for(let n=-t;n<0;n++)e.emplace(n+i,r)},t=(e,t,i)=>{r+=t,r>e.length&&e.resize(r);for(let n=-t;n<0;n++)e.emplace(n+r,i)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let i=0,r=0;for(let i=0;i<this.symbolInstances.length;i++){const r=this.symbolInstances.get(i),{numHorizontalGlyphVertices:n,numVerticalGlyphVertices:o,numIconVertices:s}=r,a=r.zOffset,l=s>0;if((n>0||o>0)&&(e(this.text.zOffsetVertexArray,n,a),e(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:e,verticalPlacedIconSymbolIndex:i}=r;e>=0&&t(this.icon.zOffsetVertexArray,s,a),i>=0&&t(this.icon.zOffsetVertexArray,r.numVerticalIconVertices,a)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(e,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=Sm(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){const i=this.lineVertexArray.length;if(void 0!==e.segment)for(const{x:e,y:i}of t)this.lineVertexArray.emplaceBack(e,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=e.indexArray,g=e.layoutVertexArray,y=e.globeExtVertexArray,x=e.segments.prepareSegment(4*t.length,g,_,this.canOverlap?o.sortKey:void 0),v=this.glyphOffsetArray.length,b=x.vertexLength,w=this.allowVerticalPlacement&&s===ef.vertical?Math.PI/2:0,T=o.text&&o.text.sections;for(let r=0;r<t.length;r++){const{tl:n,tr:s,bl:c,br:h,texPrimary:u,texSecondary:v,pixelOffsetTL:b,pixelOffsetBR:S,minFontScaleX:M,minFontScaleY:E,glyphOffset:A,isSDF:I,sectionIndex:C}=t[r],P=x.vertexLength,z=A[1];if(Am(g,l.x,l.y,n.x,z+n.y,u.x,u.y,i,I,b.x,b.y,M,E),Am(g,l.x,l.y,s.x,z+s.y,u.x+u.w,u.y,i,I,S.x,b.y,M,E),Am(g,l.x,l.y,c.x,z+c.y,u.x,u.y+u.h,i,I,b.x,S.y,M,E),Am(g,l.x,l.y,h.x,z+h.y,u.x+u.w,u.y+u.h,i,I,S.x,S.y,M,E),a){const{x:t,y:i,z:r}=a.anchor,[n,o,s]=a.up;Cm(y,t,i,r,n,o,s),Cm(y,t,i,r,n,o,s),Cm(y,t,i,r,n,o,s),Cm(y,t,i,r,n,o,s),Pm(e.dynamicLayoutVertexArray,t,i,r,w)}else Pm(e.dynamicLayoutVertexArray,l.x,l.y,l.z,w);if(m){const t=v||u;Im(e.iconTransitioningVertexArray,t.x,t.y),Im(e.iconTransitioningVertexArray,t.x+t.w,t.y),Im(e.iconTransitioningVertexArray,t.x,t.y+t.h),Im(e.iconTransitioningVertexArray,t.x+t.w,t.y+t.h)}_.emplaceBack(P,P+1,P+2),_.emplaceBack(P+1,P+2,P+3),x.vertexLength+=4,x.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(A[0]),r!==t.length-1&&C===t[r+1].sectionIndex||e.programConfigurations.populatePaintArrays(g.length,o,o.index,{},d,p,f,T&&T[C])}const S=a?a.anchor:l;e.placedSymbolArray.emplaceBack(S.x,S.y,S.z,l.x,l.y,v,this.glyphOffsetArray.length-v,b,c,h,l.segment,i?i[0]:0,i?i[1]:0,r[0],r[1],s,0,!1,0,u,0)}_commitLayoutVertex(e,t,i,r,n,o,s){e.emplaceBack(t,i,r,n,o,Math.round(s.x),Math.round(s.y))}_addCollisionDebugVertices(e,t,i,r,n,o,s){const a=i.segments.prepareSegment(4,i.layoutVertexArray,i.indexArray),l=a.vertexLength,c=s.tileAnchorX,h=s.tileAnchorY;for(let e=0;e<4;e++)i.collisionVertexArray.emplaceBack(0,0,0,0,0,0);this._commitDebugCollisionVertexUpdate(i.collisionVertexArrayExt,t,e.padding,s.zOffset),this._commitLayoutVertex(i.layoutVertexArray,r,n,o,c,h,new U(e.x1,e.y1)),this._commitLayoutVertex(i.layoutVertexArray,r,n,o,c,h,new U(e.x2,e.y1)),this._commitLayoutVertex(i.layoutVertexArray,r,n,o,c,h,new U(e.x2,e.y2)),this._commitLayoutVertex(i.layoutVertexArray,r,n,o,c,h,new U(e.x1,e.y2)),a.vertexLength+=4;const u=i.indexArray;u.emplaceBack(l,l+1),u.emplaceBack(l+1,l+2),u.emplaceBack(l+2,l+3),u.emplaceBack(l+3,l),a.primitiveLength+=4}_addTextDebugCollisionBoxes(e,t,i,r,n,o){for(let s=r;s<n;s++){const r=i.get(s),n=this.getSymbolInstanceTextSize(e,o,t,s);this._addCollisionDebugVertices(r,n,this.textCollisionBox,r.projectedAnchorX,r.projectedAnchorY,r.projectedAnchorZ,o)}}_addIconDebugCollisionBoxes(e,t,i,r,n,o){for(let s=r;s<n;s++){const r=i.get(s),n=this.getSymbolInstanceIconSize(e,t,o.placedIconSymbolIndex);this._addCollisionDebugVertices(r,n,this.iconCollisionBox,r.projectedAnchorX,r.projectedAnchorY,r.projectedAnchorZ,o)}}generateCollisionDebugBuffers(e,t,i){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Rm(Ma,Dp.members,Ta),this.iconCollisionBox=new Rm(Ma,Dp.members,Ta);const r=Np(this.iconSizeData,e),n=Np(this.textSizeData,e,i);for(let i=0;i<this.symbolInstances.length;i++){const o=this.symbolInstances.get(i);this._addTextDebugCollisionBoxes(n,e,t,o.textBoxStartIndex,o.textBoxEndIndex,o),this._addTextDebugCollisionBoxes(n,e,t,o.verticalTextBoxStartIndex,o.verticalTextBoxEndIndex,o),this._addIconDebugCollisionBoxes(r,e,t,o.iconBoxStartIndex,o.iconBoxEndIndex,o),this._addIconDebugCollisionBoxes(r,e,t,o.verticalIconBoxStartIndex,o.verticalIconBoxEndIndex,o)}}getSymbolInstanceTextSize(e,t,i,r){const n=this.text.placedSymbolArray.get(t.rightJustifiedTextSymbolIndex>=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:r),o=Bp(this.textSizeData,e,n)/Lp;return this.tilePixelRatio*o}getSymbolInstanceIconSize(e,t,i){const r=this.icon.placedSymbolArray.get(i),n=Bp(this.iconSizeData,e,r);return this.tilePixelRatio*n}_commitDebugCollisionVertexUpdate(e,t,i,r){e.emplaceBack(t,-i,-i,r),e.emplaceBack(t,i,-i,r),e.emplaceBack(t,i,i,r),e.emplaceBack(t,-i,i,r)}_updateTextDebugCollisionBoxes(e,t,i,r,n,o,s){for(let s=r;s<n;s++){const r=i.get(s),n=this.getSymbolInstanceTextSize(e,o,t,s);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,n,r.padding,o.zOffset)}}_updateIconDebugCollisionBoxes(e,t,i,r,n,o,s){for(let s=r;s<n;s++){const r=i.get(s),n=this.getSymbolInstanceIconSize(e,t,o.placedIconSymbolIndex);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,n,r.padding,o.zOffset)}}updateCollisionDebugBuffers(e,t,i,r){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const n=Np(this.iconSizeData,e,r),o=Np(this.textSizeData,e,i);for(let s=0;s<this.symbolInstances.length;s++){const a=this.symbolInstances.get(s);this._updateTextDebugCollisionBoxes(o,e,t,a.textBoxStartIndex,a.textBoxEndIndex,a,i),this._updateTextDebugCollisionBoxes(o,e,t,a.verticalTextBoxStartIndex,a.verticalTextBoxEndIndex,a,i),this._updateIconDebugCollisionBoxes(n,e,t,a.iconBoxStartIndex,a.iconBoxEndIndex,a,r),this._updateIconDebugCollisionBoxes(n,e,t,a.verticalIconBoxStartIndex,a.verticalIconBoxEndIndex,a,r)}this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexBufferExt&&this.textCollisionBox.collisionVertexBufferExt.updateData(this.textCollisionBox.collisionVertexArrayExt),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexBufferExt&&this.iconCollisionBox.collisionVertexBufferExt.updateData(this.iconCollisionBox.collisionVertexArrayExt)}_deserializeCollisionBoxesForSymbol(e,t,i,r,n,o,s,a,l){const c={};if(t<i){const{x1:i,y1:r,x2:n,y2:o,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:h,tileAnchorX:u,tileAnchorY:d,featureIndex:p}=e.get(t);c.textBox={x1:i,y1:r,x2:n,y2:o,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:h,tileAnchorX:u,tileAnchorY:d},c.textFeatureIndex=p}if(r<n){const{x1:t,y1:i,x2:n,y2:o,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:h,tileAnchorX:u,tileAnchorY:d,featureIndex:p}=e.get(r);c.verticalTextBox={x1:t,y1:i,x2:n,y2:o,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:h,tileAnchorX:u,tileAnchorY:d},c.verticalTextFeatureIndex=p}if(o<s){const{x1:t,y1:i,x2:r,y2:n,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:h,tileAnchorX:u,tileAnchorY:d,featureIndex:p}=e.get(o);c.iconBox={x1:t,y1:i,x2:r,y2:n,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:h,tileAnchorX:u,tileAnchorY:d},c.iconFeatureIndex=p}if(a<l){const{x1:t,y1:i,x2:r,y2:n,padding:o,projectedAnchorX:s,projectedAnchorY:l,projectedAnchorZ:h,tileAnchorX:u,tileAnchorY:d,featureIndex:p}=e.get(a);c.verticalIconBox={x1:t,y1:i,x2:r,y2:n,padding:o,projectedAnchorX:s,projectedAnchorY:l,projectedAnchorZ:h,tileAnchorX:u,tileAnchorY:d},c.verticalIconFeatureIndex=p}return c}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let t=0;t<this.symbolInstances.length;t++){const i=this.symbolInstances.get(t);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,i.textBoxStartIndex,i.textBoxEndIndex,i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i.iconBoxStartIndex,i.iconBoxEndIndex,i.verticalIconBoxStartIndex,i.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(e,t){const i=e.placedSymbolArray.get(t),r=i.vertexStartIndex+4*i.numGlyphs;for(let t=i.vertexStartIndex;t<r;t+=4)e.indexArray.emplaceBack(t,t+1,t+2),e.indexArray.emplaceBack(t+1,t+2,t+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;const t=Math.sin(e),i=Math.cos(e),r=[],n=[],o=[];for(let e=0;e<this.symbolInstances.length;++e){o.push(e);const s=this.symbolInstances.get(e);r.push(0|Math.round(t*s.tileAnchorX+i*s.tileAnchorY)),n.push(s.featureIndex)}return o.sort(((e,t)=>r[e]-r[t]||n[t]-n[e])),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let e=0;e<this.symbolInstances.length;++e)this.symbolInstanceIndexesSortedZOffset.push(e)}return this.zOffsetSortDirty=!1,this.symbolInstanceIndexesSortedZOffset.sort(((e,t)=>this.symbolInstances.get(t).zOffset-this.symbolInstances.get(e).zOffset))}addToSortKeyRanges(e,t){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===t?i.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex);const{rightJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:r,leftJustifiedTextSymbolIndex:n,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=t;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),r>=0&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),n>=0&&n!==r&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Om,km,Fm;ro(Lm,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Lm.addDynamicAttributes=Pm;class Bm{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:Dt,this.defaultValue=e}evaluate(e){if(e.formattedSection){const t=this.defaultValue.property.overrides;if(t&&t.hasOverride(e.formattedSection))return t.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ro(Bm,"FormatSectionOverride",{omit:["defaultValue"]});const Nm=()=>Fm||(Fm={layout:Om||(Om=new Fs({"symbol-placement":new Ls(Bs.layout_symbol["symbol-placement"]),"symbol-spacing":new Ls(Bs.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ls(Bs.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Os(Bs.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ls(Bs.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Ls(Bs.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new Ls(Bs.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new Ls(Bs.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Ls(Bs.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ls(Bs.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ls(Bs.layout_symbol["icon-rotation-alignment"]),"icon-size":new Os(Bs.layout_symbol["icon-size"]),"icon-size-scale-range":new Ls(Bs.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new Os(Bs.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Os(Bs.layout_symbol["icon-text-fit-padding"]),"icon-image":new Os(Bs.layout_symbol["icon-image"]),"icon-rotate":new Os(Bs.layout_symbol["icon-rotate"]),"icon-padding":new Ls(Bs.layout_symbol["icon-padding"]),"icon-keep-upright":new Ls(Bs.layout_symbol["icon-keep-upright"]),"icon-offset":new Os(Bs.layout_symbol["icon-offset"]),"icon-anchor":new Os(Bs.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ls(Bs.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ls(Bs.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ls(Bs.layout_symbol["text-rotation-alignment"]),"text-field":new Os(Bs.layout_symbol["text-field"]),"text-font":new Os(Bs.layout_symbol["text-font"]),"text-size":new Os(Bs.layout_symbol["text-size"]),"text-size-scale-range":new Ls(Bs.layout_symbol["text-size-scale-range"]),"text-max-width":new Os(Bs.layout_symbol["text-max-width"]),"text-line-height":new Os(Bs.layout_symbol["text-line-height"]),"text-letter-spacing":new Os(Bs.layout_symbol["text-letter-spacing"]),"text-justify":new Os(Bs.layout_symbol["text-justify"]),"text-radial-offset":new Os(Bs.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ls(Bs.layout_symbol["text-variable-anchor"]),"text-anchor":new Os(Bs.layout_symbol["text-anchor"]),"text-max-angle":new Ls(Bs.layout_symbol["text-max-angle"]),"text-writing-mode":new Ls(Bs.layout_symbol["text-writing-mode"]),"text-rotate":new Os(Bs.layout_symbol["text-rotate"]),"text-padding":new Ls(Bs.layout_symbol["text-padding"]),"text-keep-upright":new Ls(Bs.layout_symbol["text-keep-upright"]),"text-transform":new Os(Bs.layout_symbol["text-transform"]),"text-offset":new Os(Bs.layout_symbol["text-offset"]),"text-allow-overlap":new Ls(Bs.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Ls(Bs.layout_symbol["text-ignore-placement"]),"text-optional":new Ls(Bs.layout_symbol["text-optional"]),visibility:new Ls(Bs.layout_symbol.visibility)})),paint:km||(km=new Fs({"icon-opacity":new Os(Bs.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new Os(Bs.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new Os(Bs.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new Os(Bs.paint_symbol["text-emissive-strength"]),"icon-color":new Os(Bs.paint_symbol["icon-color"]),"icon-halo-color":new Os(Bs.paint_symbol["icon-halo-color"]),"icon-halo-width":new Os(Bs.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Os(Bs.paint_symbol["icon-halo-blur"]),"icon-translate":new Ls(Bs.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ls(Bs.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new Os(Bs.paint_symbol["icon-image-cross-fade"]),"text-opacity":new Os(Bs.paint_symbol["text-opacity"]),"text-occlusion-opacity":new Os(Bs.paint_symbol["text-occlusion-opacity"]),"text-color":new Os(Bs.paint_symbol["text-color"],{runtimeType:kt,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new Os(Bs.paint_symbol["text-halo-color"]),"text-halo-width":new Os(Bs.paint_symbol["text-halo-width"]),"text-halo-blur":new Os(Bs.paint_symbol["text-halo-blur"]),"text-translate":new Ls(Bs.paint_symbol["text-translate"]),"text-translate-anchor":new Ls(Bs.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Ls(Bs.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Ls(Bs.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Ls(Bs.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Ls(Bs.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new Os(Bs.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new Os({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new Os({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new Os({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new Os({type:"string",default:"default","property-type":"data-driven"})}))},Fm);class Vm extends na{constructor(e,t,i,r){super(e,Nm(),t,i,r),this._colorAdjustmentMatrix=F.mat4.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint)}recalculate(e,t){super.recalculate(e,t),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const e=[];for(const t of i)e.indexOf(t)<0&&e.push(t);this.layout._values["text-writing-mode"]=e}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getColorAdjustmentMatrix(e,t,i,r){return this._saturation===e&&this._contrast===t&&this._brightnessMin===i&&this._brightnessMax===r||(this._colorAdjustmentMatrix=function(e,t,i,r){e=we(e),t=be(t);const n=F.mat4.create(),o=e/3,s=1-2*o,a=[s,o,o,0,o,s,o,0,o,o,s,0,0,0,0,1],l=.5-.5*t,c=r-i;return F.mat4.multiply(n,[c,0,0,0,0,c,0,0,0,0,c,0,i,i,i,1],[t,0,0,0,0,t,0,0,0,0,t,0,l,l,l,1]),F.mat4.multiply(n,n,a),n}(e,t,i,r),this._saturation=e,this._contrast=t,this._brightnessMin=i,this._brightnessMax=r),this._colorAdjustmentMatrix}getValueAndResolveTokens(e,t,i,r){const n=this.layout.get(e).evaluate(t,{},i,r),o=this._unevaluatedLayout._values[e];return o.isDataDriven()||Zn(o.value)||!n?n:function(e,t){return t.replace(/{([^{}]+)}/g,((t,i)=>i in e?String(e[i]):""))}(t.properties,n)}createBucket(e){return new Lm(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of Nm().paint.overridableProperties){if(!Vm.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),i=new Bm(t),r=new qn(i,t.property.specification,this.scope,this.options);let n=null;n="constant"===t.value.kind||"source"===t.value.kind?new Hn("source",r):new Wn("composite",r,t.value.zoomStops,t.value._interpolationType),this.paint._values[e]=new Ds(t.property,n,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,i){return!(!this.layout||t.isDataDriven()||i.isDataDriven())&&Vm.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const i=e.get("text-field"),r=Nm().paint.properties[t];let n=!1;const o=e=>{for(const t of e)if(r.overrides&&r.overrides.hasOverride(t))return void(n=!0)};if("constant"===i.value.kind&&i.value.value instanceof Yt)o(i.value.value.sections);else if("source"===i.value.kind){const e=t=>{n||(t instanceof ri&&ti(t.value)===Vt?o(t.value.sections):t instanceof ai?o(t.sections):t.eachChild(e))},t=i.value;t._styleExpression&&e(t._styleExpression.expression)}return n}getProgramIds(){return["symbol"]}getDefaultProgramParams(e,t,i){return{config:new Pl(this,{zoom:t,lut:i}),overrideFog:!1}}}let Um,jm,Gm,qm;var Zm=la([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function $m(e){switch(e){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function Hm(e){switch(e){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}class Wm{constructor(e,t,i,r){this.context=e,this.format=i,this.useMipmap=r&&r.useMipmap,this.texture=e.gl.createTexture(),this.update(t,{premultiply:r&&r.premultiply})}update(e,t){const i=e&&e instanceof HTMLVideoElement&&0===e.width?e.videoWidth:e.width,r=e&&e instanceof HTMLVideoElement&&0===e.height?e.videoHeight:e.height,{context:n}=this,{gl:o}=n,{x:s,y:a}=t&&t.position?t.position:{x:0,y:0},l=Math.max(s+i,this.size?this.size[0]:0),c=Math.max(a+r,this.size?this.size[1]:0);!this.size||this.size[0]===l&&this.size[1]===c||(o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(this.texture),this.texture=o.createTexture(),this.size=null),o.bindTexture(o.TEXTURE_2D,this.texture),n.pixelStoreUnpackFlipY.set(!1),n.pixelStoreUnpack.set(1),n.pixelStoreUnpackPremultiplyAlpha.set(this.format===o.RGBA8&&(!t||!1!==t.premultiply));const h=e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||ImageBitmap&&e instanceof ImageBitmap;if(!this.size&&l>0&&c>0){const e=this.useMipmap?Math.floor(Math.log2(Math.max(l,c)))+1:1;o.texStorage2D(o.TEXTURE_2D,e,this.format,l,c),this.size=[l,c]}if(this.size)if(h)o.texSubImage2D(o.TEXTURE_2D,0,s,a,$m(this.format),Hm(this.format),e);else{const t=e.data;t&&o.texSubImage2D(o.TEXTURE_2D,0,s,a,i,r,$m(this.format),Hm(this.format),t)}this.useMipmap&&o.generateMipmap(o.TEXTURE_2D)}bind(e,t,i=!1){const{context:r}=this,{gl:n}=r;n.bindTexture(n.TEXTURE_2D,this.texture),e!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,this.useMipmap&&!i?e===n.NEAREST?n.NEAREST_MIPMAP_NEAREST:n.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),t!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,t),this.wrapS=t)}bindExtraParam(e,t,i,r){const{context:n}=this,{gl:o}=n;o.bindTexture(o.TEXTURE_2D,this.texture),t!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,t),this.magFilter=t),e!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?e===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),r!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,r),this.wrapT=r)}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class Xm{constructor(e,t){this.context=e,this.texture=t}bind(e,t){const{context:i}=this,{gl:r}=i;r.bindTexture(r.TEXTURE_2D,this.texture),e!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,t),this.wrapS=t)}}function Ym(e,t,i,r,n,o,s,a){const l=[e,t,1,i,r,1,n,o,1],c=[s,a,1],h=F.mat3.adjoint([],l),[u,d,p]=F.vec3.transformMat3(c,c,h);return F.mat3.multiply(l,l,[u,0,0,0,d,0,0,0,p])}function Km(e,t,i,r,n,o,s,a){const l=function(e,t,i,r,n,o,s,a){const l=Ym(0,0,1,0,1,1,0,1),c=Ym(e,t,i,r,n,o,s,a),h=F.mat3.adjoint([],l);return F.mat3.multiply(c,c,h)}(e,t,i,r,n,o,s,a);return[l[2]/l[8]/Wi,l[5]/l[8]/Wi]}function Jm(e){return[e[0],Math.min(Math.max(e[1],-tc),tc)]}class Qm extends vt{constructor(e,t,i,r){super(),this.id=e,this.dispatcher=i,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(r),this.options=t,this._dirty=!1}load(e,t){if(this._loaded=t||!1,this.fire(new _t("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return e&&(this.coordinates=e),this._loaded=!0,void this._finishLoading();this._imageRequest=at(this.map._requestManager.transformRequest(this.url,Je.Image),((t,i)=>{this._imageRequest=null,this._loaded=!0,t?this.fire(new gt(t)):i&&(this.image=i instanceof HTMLImageElement?Re.getImageData(i):i,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,e&&(this.coordinates=e),this._finishLoading())}))}loaded(){return this._loaded}updateImage(e){return e.url?(this._imageRequest&&e.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=e.url,this.load(e.coordinates,this._loaded),this):this}setTexture(e){if(!(e.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Xm(this.map.painter.context,e.handle),this.width=e.dimensions[0],this.height=e.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new _t("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(e){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Xm||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(e){if(this.coordinates=e,this._boundsArray=void 0,this._unsupportedCoords=!1,!e.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let t=e[0][1],i=e[0][1];for(const r of e)r[1]>i&&(i=r[1]),r[1]<t&&(t=r[1]);const r=(i+t)/2;if(r>tc?this.onNorthPole=!0:r<-tc&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const t=e.map(sc.fromLngLat);this.tileID=function(e){let t=1/0,i=1/0,r=-1/0,n=-1/0;for(const o of e)t=Math.min(t,o.x),i=Math.min(i,o.y),r=Math.max(r,o.x),n=Math.max(n,o.y);const o=Math.max(r-t,n-i),s=Math.max(0,Math.floor(-Math.log(o)/Math.LN2)),a=Math.pow(2,s);let l=Math.floor((t+r)/2*a);return l>1&&(l-=1),new jc(s,l,Math.floor((i+n)/2*a))}(t),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new _t("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(e){for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const t=im(new jc(0,0,0),this.map.transform.projection),i=[t.projection.project(this.coordinates[0][0],this.coordinates[0][1]),t.projection.project(this.coordinates[1][0],this.coordinates[1][1]),t.projection.project(this.coordinates[2][0],this.coordinates[2][1]),t.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(e){const t=e[1].x-e[0].x,i=e[1].y-e[0].y,r=e[2].x-e[1].x,n=e[2].y-e[1].y,o=e[3].x-e[2].x,s=e[3].y-e[2].y,a=e[0].x-e[3].x,l=e[0].y-e[3].y,c=t*n-r*i,h=r*s-o*n,u=o*l-a*s,d=a*i-t*l;return c>0&&h>0&&u>0&&d>0||c<0&&h<0&&u<0&&d<0}(i))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const r=im(this.tileID,this.map.transform.projection),[n,o,s,a]=this.coordinates.map((e=>{const t=r.projection.project(e[0],e[1]);return rm(r,t)._round()}));this.perspectiveTransform=Km(n.x,n.y,o.x,o.y,s.x,s.y,a.x,a.y);const l=this._boundsArray=new da;l.emplaceBack(n.x,n.y,0,0),l.emplaceBack(o.x,o.y,Wi,0),l.emplaceBack(a.x,a.y,0,Wi),l.emplaceBack(s.x,s.y,Wi,Wi),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(l,Zm.members),this.boundsSegments=nl.simpleSegment(0,0,4,2);const c=[],h=[Jm((u=this.coordinates)[0]),Jm(u[1]),Jm(u[2]),Jm(u[3])];var u;const[d,p,f,m]=function(e){let t=e[0][0],i=t,r=e[0][1],n=r;for(let o=1;o<e.length;o++)e[o][0]<t?t=e[o][0]:e[o][0]>i&&(i=e[o][0]),e[o][1]<r?r=e[o][1]:e[o][1]>n&&(n=e[o][1]);return[t,r,i-t,n-r]}(h);{const r=new da,[n,o,s,a]=function(e){let t=e[0].x,i=t,r=e[0].y,n=r;for(let o=1;o<e.length;o++)e[o].x<t?t=e[o].x:e[o].x>i&&(i=e[o].x),e[o].y<r?r=e[o].y:e[o].y>n&&(n=e[o].y);return[t,r,i-t,n-r]}(i),l=e=>[(e.x-n)/s,(e.y-o)/a],[h,u,_,g]=i.map(l),y=function(e,t,i,r,n,o,s,a){const l=Ym(0,0,1,0,1,1,0,1),c=Ym(e,t,i,r,n,o,s,a),h=F.mat3.adjoint([],c);return F.mat3.multiply(l,l,h)}(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);this.elevatedGlobePerspectiveTransform=Km(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);const x=(e,t)=>{c.push(e.lng);const i=Math.round((e.lng-d)/f*Wi),n=Math.round((e.lat-p)/m*Wi),o=l(t),s=F.vec3.transformMat3([],[o[0],o[1],1],y),a=Math.round(s[0]/s[2]*Wi),h=Math.round(s[1]/s[2]*Wi);r.emplaceBack(i,n,a,h)},v=i[3].x-i[0].x,b=i[3].y-i[0].y,w=i[2].x-i[1].x,T=i[2].y-i[1].y;for(let e=0;e<65;e++){const r=e/64,n=[i[0].x+r*v,i[0].y+r*b],o=[i[1].x+r*w,i[1].y+r*T],s=o[0]-n[0],a=o[1]-n[1];for(let e=0;e<65;e++){const i=e/64,r={x:n[0]+s*i,y:n[1]+a*i,z:0};x(t.projection.unproject(r.x,r.y),r)}}this.elevatedGlobeVertexBuffer=e.createVertexBuffer(r,Zm.members)}{this.maxLongitudeTriangleSize=0;let t=[],i=new Ia;const r=(e,r,n)=>{i.emplaceBack(e,r,n);const o=c[e],s=c[r],a=c[n],l=Math.min(Math.min(o,s),a),h=Math.max(Math.max(o,s),a)-l;h>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=h),t.push(l+h/2)};for(let e=0;e<64;e++)for(let t=0;t<64;t++){const i=65*e+t,n=i+1,o=i+65,s=o+1;r(i,o,n),r(n,o,s)}[t,i]=function(e,t){const i=Array.from({length:e.length},((e,t)=>t));i.sort(((t,i)=>e[t]-e[i]));const r=[],n=new Ia;for(let o=0;o<i.length;o++){const s=i[o];r.push(e[s]);const a=3*s,l=a+1;n.emplaceBack(t.uint16[a],t.uint16[l],t.uint16[l+1])}return[r,n]}(t,i),this.elevatedGlobeTrianglesCenterLongitudes=t,this.elevatedGlobeIndexBuffer=e.createIndexBuffer(i)}this.elevatedGlobeSegments=nl.simpleSegment(0,0,4225,8192),this.elevatedGlobeGridMatrix=new Float32Array([0,f/Wi,0,m/Wi,0,0,p,d,0])}prepare(){const e=0!==Object.keys(this.tiles).length;if(this.tileID&&!e)return;const t=this.map.painter.context,i=t.gl;!this._dirty||this.texture instanceof Xm||(this.texture?this.texture.update(this.image):(this.texture=new Wm(t,this.image,i.RGBA8),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE)),this._dirty=!1),e&&this._prepareData(t)}loadTile(e,t){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={},t(null)):(e.state="errored",t(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}getSegmentsForLongitude(e){const t=this.elevatedGlobeSegments;if(!this.elevatedGlobeTrianglesCenterLongitudes||!t)return null;const i=this.elevatedGlobeTrianglesCenterLongitudes;let r=(n=e+180)+360*Math.round((i[0]-n)/360);var n;const o=new nl,s=(e,i)=>{o.segments.push({vertexOffset:0,primitiveOffset:e,vertexLength:t.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-r)<=a){const e=ve(i,0,i.length,r+a);return e===i.length||s(e,xe(i,e+1,i.length,r+360-a)-e),o}r<i[0]&&(r+=360);const l=xe(i,0,i.length,r-a);if(l===i.length)return s(0,i.length),o;s(0,l-0);const c=ve(i,l+1,i.length,r+a);return c!==i.length&&s(c,i.length-c),o}}const e_=(Math.pow(256,2)-1)/16907520;class t_ extends na{constructor(e,t,i,r){super(e,{layout:Gm||(Gm=new Fs({visibility:new Ls(Bs.layout_raster.visibility)})),paint:qm||(qm=new Fs({"raster-opacity":new Ls(Bs.paint_raster["raster-opacity"]),"raster-color":new ks(Bs.paint_raster["raster-color"]),"raster-color-mix":new Ls(Bs.paint_raster["raster-color-mix"]),"raster-color-range":new Ls(Bs.paint_raster["raster-color-range"]),"raster-hue-rotate":new Ls(Bs.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Ls(Bs.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Ls(Bs.paint_raster["raster-brightness-max"]),"raster-saturation":new Ls(Bs.paint_raster["raster-saturation"]),"raster-contrast":new Ls(Bs.paint_raster["raster-contrast"]),"raster-resampling":new Ls(Bs.paint_raster["raster-resampling"]),"raster-fade-duration":new Ls(Bs.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new Ls(Bs.paint_raster["raster-emissive-strength"]),"raster-array-band":new Ls(Bs.paint_raster["raster-array-band"]),"raster-elevation":new Ls(Bs.paint_raster["raster-elevation"]),"raster-color-use-theme":new Os({type:"string",default:"default","property-type":"data-driven"})}))},t,i,r),this.updateColorRamp(),this._curRampRange=[NaN,NaN]}getProgramIds(){return["raster"]}hasColorMap(){return!!this._transitionablePaint._values["raster-color"].value.value}tileCoverLift(){return this.paint.get("raster-elevation")}isDraped(e){return!(e&&e._source instanceof Qm&&(e._source.onNorthPole||e._source.onSouthPole))&&0===this.paint.get("raster-elevation")}_handleSpecialPaintPropertyUpdate(e){"raster-color"!==e&&"raster-color-range"!==e||(this._curRampRange=[NaN,NaN],this.updateColorRamp())}updateColorRamp(e){if(!this.hasColorMap())return;if(!this._curRampRange)return;const t=this._transitionablePaint._values["raster-color"].value.expression,[i,r]=e||this._transitionablePaint._values["raster-color-range"].value.expression.evaluate({zoom:0})||[NaN,NaN];isNaN(i)&&isNaN(r)||i===this._curRampRange[0]&&r===this._curRampRange[1]||(this.colorRamp=Wh({expression:t,evaluationKey:"rasterValue",image:this.colorRamp,clips:[{start:i,end:r}],resolution:256}),this.colorRampTexture=null,this._curRampRange=[i,r])}}let i_,r_,n_,o_,s_;class a_ extends na{constructor(e,t,i,r){super(e,{layout:i_||(i_=new Fs({visibility:new Ls(Bs["layout_raster-particle"].visibility)})),paint:r_||(r_=new Fs({"raster-particle-array-band":new Ls(Bs["paint_raster-particle"]["raster-particle-array-band"]),"raster-particle-count":new Ls(Bs["paint_raster-particle"]["raster-particle-count"]),"raster-particle-color":new ks(Bs["paint_raster-particle"]["raster-particle-color"]),"raster-particle-max-speed":new Ls(Bs["paint_raster-particle"]["raster-particle-max-speed"]),"raster-particle-speed-factor":new Ls(Bs["paint_raster-particle"]["raster-particle-speed-factor"]),"raster-particle-fade-opacity-factor":new Ls(Bs["paint_raster-particle"]["raster-particle-fade-opacity-factor"]),"raster-particle-reset-rate-factor":new Ls(Bs["paint_raster-particle"]["raster-particle-reset-rate-factor"]),"raster-particle-elevation":new Ls(Bs["paint_raster-particle"]["raster-particle-elevation"]),"raster-particle-color-use-theme":new Os({type:"string",default:"default","property-type":"data-driven"})}))},t,i,r),this._updateColorRamp(),this.lastInvalidatedAt=Re.now()}onRemove(e){this.colorRampTexture&&this.colorRampTexture.destroy(),this.tileFramebuffer&&this.tileFramebuffer.destroy(),this.particleFramebuffer&&this.particleFramebuffer.destroy()}hasColorMap(){return!!this._transitionablePaint._values["raster-particle-color"].value.value}getProgramIds(){return["rasterParticle"]}hasOffscreenPass(){return"none"!==this.visibility}isDraped(e){return!1}_handleSpecialPaintPropertyUpdate(e){"raster-particle-color"!==e&&"raster-particle-max-speed"!==e||(this._updateColorRamp(),this._invalidateAnimationState()),"raster-particle-count"===e&&this._invalidateAnimationState()}_updateColorRamp(){if(!this.hasColorMap())return;const e=this._transitionablePaint._values["raster-particle-color"].value.expression,t=this._transitionablePaint._values["raster-particle-max-speed"].value.expression.evaluate({zoom:0});this.colorRamp=Wh({expression:e,evaluationKey:"rasterParticleSpeed",image:this.colorRamp,clips:[{start:0,end:t}],resolution:256}),this.colorRampTexture=null}_invalidateAnimationState(){this.lastInvalidatedAt=Re.now()}tileCoverLift(){return this.paint.get("raster-particle-elevation")}}class l_ extends na{constructor(e,t){super(e,{},t,null),this.implementation=e,e.slot&&(this.slot=e.slot)}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}isDraped(e){return void 0!==this.implementation.renderToTile}shouldRedrape(){return!!this.implementation.shouldRerenderTiles&&this.implementation.shouldRerenderTiles()}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(e){this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)}onRemove(e){this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)}}function c_(e,t,i){const r=[0,0,1],n=F.quat.identity([]);return F.quat.rotateY(n,n,i?-Z(e)+Math.PI:Z(e)),F.quat.rotateX(n,n,-Z(t)),F.vec3.transformQuat(r,r,n),F.vec3.normalize(r,r)}function h_(e,t){const i=d_(e.projection,e.zoom,e.width,e.height),r=function(e,t,i,r,n){const o=new $l(i.lng-180*p_,i.lat),s=new $l(i.lng+180*p_,i.lat),a=e.project(o.lng,o.lat),l=e.project(s.lng,s.lat),c=-Math.atan2(l.y-a.y,l.x-a.x),h=sc.fromLngLat(i);h.y=K(h.y,-1+p_,1-p_);const u=h.toLngLat(),d=e.project(u.lng,u.lat),p=sc.fromLngLat(u);p.x+=p_;const f=p.toLngLat(),m=e.project(f.lng,f.lat),_=m_(m.x-d.x,m.y-d.y,c),g=sc.fromLngLat(u);g.y+=p_;const y=g.toLngLat(),x=e.project(y.lng,y.lat),v=m_(x.x-d.x,x.y-d.y,c),b=Math.abs(_.x)/Math.abs(v.y),w=F.mat4.identity([]);F.mat4.rotateZ(w,w,-c*(1-(n?0:r)));const T=F.mat4.identity([]);return F.mat4.scale(T,T,[1,1-(1-b)*r,1]),T[4]=-v.x/v.y*r,F.mat4.rotateZ(T,T,c),F.mat4.multiply(T,w,T),T}(e.projection,0,e.center,i,t),n=u_(e);return F.mat4.scale(r,r,[n,n,1]),r}function u_(e){const t=e.projection,i=d_(e.projection,e.zoom,e.width,e.height),r=f_(t,e.center),n=f_(t,$l.convert(t.center));return Math.pow(2,r*i+(1-i)*n)}function d_(e,t,i,r,n=1/0){const o=e.range;if(!o)return 0;const s=Math.min(n,Math.max(i,r)),a=Math.log(s/1024)/Math.LN2;return J(o[0]+a,o[1]+a,t)}const p_=1/4e4;function f_(e,t){const i=K(t.lat,-tc,tc),r=new $l(t.lng-180*p_,i),n=new $l(t.lng+180*p_,i),o=e.project(r.lng,i),s=e.project(n.lng,i),a=sc.fromLngLat(r),l=sc.fromLngLat(n),c=s.x-o.x,h=s.y-o.y,u=l.x-a.x,d=l.y-a.y,p=Math.sqrt((u*u+d*d)/(c*c+h*h));return Math.log(p)/Math.LN2}function m_(e,t,i){const r=Math.cos(i),n=Math.sin(i);return{x:e*r-t*n,y:e*n+t*r}}function __(e,t,i){F.mat4.identity(e),F.mat4.rotateZ(e,e,Z(t[2])),F.mat4.rotateX(e,e,Z(t[0])),F.mat4.rotateY(e,e,Z(t[1])),F.mat4.scale(e,e,i),F.mat4.multiply(e,e,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function g_(e,t,i,r,n,o,s,a){const l=[i[0]-t[0],i[1]-t[1],0],c=[r[0]-t[0],r[1]-t[1],0];if(F.vec3.length(l)<1e-12||F.vec3.length(c)<1e-12)return F.quat.identity(e);const h=F.vec3.cross([],l,c);F.vec3.normalize(h,h),F.vec3.subtract(c,r,t),l[2]=(o-n)*a,c[2]=(s-n)*a;const u=l;return F.vec3.cross(u,l,c),F.vec3.normalize(u,u),F.quat.rotationTo(e,h,u)}function y_(e,t,i=!1){const r=Sh(t.zoom),n=function(e,t,i){const r=t.worldSize,n=[e[12],e[13],e[14]],o=Ql(n[1]/r),s=Jl(n[0]/r),a=F.mat4.identity([]),l=Kl(1,o)*r,c=Kl(1,0)*r*rc(o,t.zoom),h=1/bh(r);let u=c*h;if(i){const e=d_(t.projection,t.zoom,t.width,t.height,1024);u=h*t.projection.pixelSpaceConversion(t.center.lat,r,e)}const d=Gl(o,s);F.vec3.add(d,d,F.vec3.scale([],F.vec3.normalize([],d),l*u*n[2]));const p=function(e){const t=[e[0],e[1],e[2]];let i=[0,1,0];const r=F.vec3.cross([],i,t);return F.vec3.cross(i,t,r),0===F.vec3.squaredLength(i)&&(i=[0,1,0],F.vec3.cross(r,t,i)),F.vec3.normalize(r,r),F.vec3.normalize(i,i),F.vec3.normalize(t,t),[r[0],r[1],r[2],0,i[0],i[1],i[2],0,t[0],t[1],t[2],0,e[0],e[1],e[2],1]}(d);F.mat4.scale(a,a,[u,u,u*l]),F.mat4.translate(a,a,[-n[0],-n[1],-n[2]]);const f=F.mat4.multiply([],t.globeMatrix,p);return F.mat4.multiply(f,f,a),F.mat4.multiply(f,f,e),f}(e,t,i);if(r>0){const i=function(e,t){const i=t.worldSize,r=Kl(1,0)*i*rc(t.center.lat,t.zoom)/bh(i),n=Kl(1,t.center.lat)*i,o=F.mat4.identity([]);return F.mat4.rotateY(o,o,Z(t.center.lng)),F.mat4.rotateX(o,o,Z(t.center.lat)),F.mat4.translate(o,o,[0,0,Fl]),F.mat4.scale(o,o,[r,r,r*n]),F.mat4.translate(o,o,[t.point.x-.5*i,t.point.y-.5*i,0]),F.mat4.multiply(o,o,e),F.mat4.multiply(o,t.globeMatrix,o)}(e,t);return function(e,t,i){const r=(e,t,i)=>{const r=F.vec3.length(e),n=F.vec3.length(t),o=uh(e,t,i);return F.vec3.scale(o,o,1/F.vec3.length(o)*Et(r,n,i))},n=r([e[0],e[1],e[2]],[t[0],t[1],t[2]],i),o=r([e[4],e[5],e[6]],[t[4],t[5],t[6]],i),s=r([e[8],e[9],e[10]],[t[8],t[9],t[10]],i),a=uh([e[12],e[13],e[14]],[t[12],t[13],t[14]],i);return[n[0],n[1],n[2],0,o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],1]}(n,i,r)}return n}function x_(e,t,i,r){const n=nh.projectAabbCorners(r,i);let o=Number.MAX_VALUE,s=-1;for(let e=0;e<n.length;++e){const i=n[e];i[0]=(.5*i[0]+.5)*t.width,i[1]=(.5-.5*i[1])*t.height,i[2]<o&&(s=e,o=i[2])}const a=e=>new U(n[e][0],n[e][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(xc(e,l))return o}const v_=la([{name:"a_pos_3f",components:3,type:"Float32"}]),b_=la([{name:"a_color_3f",components:3,type:"Float32"}]),w_=la([{name:"a_color_4f",components:4,type:"Float32"}]),T_=la([{name:"a_uv_2f",components:2,type:"Float32"}]),S_=la([{name:"a_normal_3f",components:3,type:"Float32"}]),M_=la([{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"}]),E_=la([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]),A_={None:0,Model:1,Symbol:2,FillExtrusion:4,All:7};class I_{constructor(e,t,i,r){this.message=(e?`${e}: `:"")+i,r&&(this.identifier=r),null!=t&&t.__line__&&(this.line=t.__line__)}}function C_(e,t){const i=-1===e.indexOf("://");try{return new URL(e,i&&t?"http://example.com":void 0),!0}catch(e){return!1}}class P_{constructor(e,t){this.feature=e,this.instancedDataOffset=t,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class z_{constructor(){this.instancedDataArray=new Na,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class D_{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.fqid)),this.projection=e.projection,this.index=e.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?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(e,t){}populate(e,t,i,r){this.tileToMeter=oc(i);const n=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of e){const e=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=mc(o,n);if(!this.layers[0]._featureFilter.filter(new Ms(this.zoom),c,i))continue;const h={id:e,sourceLayerIndex:l,index:a,geometry:n?c.geometry:fc(o,i,r),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(h,h.geometry,c);u&&t.featureIndex.insert(o,h.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,256)}this.lookup=null}update(e,t,i,r){for(const t in this.instancesPerModel){const i=this.instancesPerModel[t];for(const t in e)i.idToFeaturesIndex.hasOwnProperty(t)&&(this.evaluate(i.features[i.idToFeaturesIndex[t]],e[t],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(const t in this.instancesPerModel){const i=this.instancesPerModel[t];for(const t of i.features){const r=this.layers[0],n=t.feature,o=this.canonical,s=r.paint.get("model-rotation").evaluate(n,{},o),a=r.paint.get("model-scale").evaluate(n,{},o),l=r.paint.get("model-translation").evaluate(n,{},o);F.vec3.exactEquals(t.rotation,s)&&F.vec3.exactEquals(t.scale,a)&&F.vec3.exactEquals(t.translation,l)||(this.evaluate(t,t.featureStates,i,!0),e=!0)}}return e}updateReplacement(e,t,i,r){if(t.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=t.updateTime;const n=t.getReplacementRegionsForTile(e.toUnwrapped(),!0);if(hd(this.activeReplacements,n))return!1;this.activeReplacements=n;let o=!1;for(const t in this.instancesPerModel){const n=this.instancesPerModel[t],s=n.instancedDataArray;for(const t of n.features){const n=t.instancedDataOffset,a=t.instancedDataCount;for(let t=0;t<a;t++){const a=16*(t+n);let l=s.float32[a+0];const c=l>Wi;l=c?l-Wi:l;const h=Math.floor(l),u=s.float32[a+1];let d=!1;for(const t of this.activeReplacements)if(!sd(t,i,A_.Model,r)&&!(t.min.x>h||h>t.max.x||t.min.y>u||u>t.max.y)&&(d=_d(md(h,u,e.canonical,t.footprintTileId.canonical),t.footprint),d))break;s.float32[a]=d?l+Wi:l,o=o||d!==c}}}return o}isEmpty(){for(const e in this.instancesPerModel)if(0!==this.instancesPerModel[e].instancedDataArray.length)return!1;return!0}uploadPending(){return!this.uploaded}upload(e){if(!this.uploaded)for(const t in this.instancesPerModel){const i=this.instancesPerModel[t];i.instancedDataArray.length<0||0===i.instancedDataArray.length||(i.instancedDataBuffer?i.instancedDataBuffer.updateData(i.instancedDataArray):i.instancedDataBuffer=e.createVertexBuffer(i.instancedDataArray,M_.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(){for(const e in this.instancesPerModel){const t=this.instancesPerModel[e];0!==t.instancedDataArray.length&&t.instancedDataBuffer&&t.instancedDataBuffer.destroy()}const e=this.layers[0].modelManager;if(e&&this.modelUris)for(const t of this.modelUris)e.removeModel(t,"")}addFeature(e,t,i){const r=this.layers[0],n=r.layout.get("model-id").evaluate(i,{},this.canonical);if(!n)return ue(`modelId is not evaluated for layer ${r.id} and it is not going to get rendered.`),n;C_(n,!1)&&(this.modelUris.includes(n)||this.modelUris.push(n)),this.instancesPerModel[n]||(this.instancesPerModel[n]=new z_);const o=this.instancesPerModel[n],s=o.instancedDataArray,a=new P_(i,s.length);for(const e of t)for(const t of e){if(t.x<0||t.x>=Wi||t.y<0||t.y>=Wi)continue;const e=(this.lookupDim-1)/Wi,i=this.lookupDim*(t.y*e|0)+t.x*e|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const r=s.length;s.resize(r+1),o.instancesEvaluatedElevation.push(0),s.float32[16*r]=t.x,s.float32[16*r+1]=t.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(e.id&&(o.idToFeaturesIndex[e.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),n}getModelUris(){return this.modelUris}evaluate(e,t,i,r){const n=this.layers[0],o=e.feature,s=this.canonical,a=e.rotation=n.paint.get("model-rotation").evaluate(o,t,s),l=e.scale=n.paint.get("model-scale").evaluate(o,t,s),c=e.translation=n.paint.get("model-translation").evaluate(o,t,s),h=n.paint.get("model-color").evaluate(o,t,s);h.a=n.paint.get("model-color-mix-intensity").evaluate(o,t,s);const u=[];this.maxVerticalOffset<c[2]&&(this.maxVerticalOffset=c[2]),this.maxScale=Math.max(Math.max(this.maxScale,l[0]),Math.max(l[1],l[2])),__(u,a,l);const d=Math.round(100*h.a)+h.b/1.05;for(let t=0;t<e.instancedDataCount;++t){const n=e.instancedDataOffset+t,o=16*n,a=i.instancedDataArray.float32;let l=0;r&&(l=a[o+6]-i.instancesEvaluatedElevation[n]);const p=0|a[o+1];a[o]=(0|a[o])+h.r/1.05,a[o+1]=p+h.g/1.05,a[o+2]=d,a[o+3]=1/(s.z>10?this.tileToMeter:oc(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[n]=c[2]}}}let R_,L_;ro(D_,"ModelBucket",{omit:["layers"]}),ro(z_,"PerModelAttributes"),ro(P_,"ModelFeature");const O_=64,k_={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function F_(e,t,i,r,n,o,s,a,l,c=!1){const h=i.zoom,u=i.project(r),d=rc(r.lat,h),p=1/d;F.mat4.identity(e),F.mat4.translate(e,e,[u.x+s[0]*p,u.y+s[1]*p,s[2]]);let f=1,m=1;const _=i.worldSize;if(c){if("mercator"===i.projection.name){let e=0;i.elevation&&(e=i.elevation.getAtPointOrZero(new sc(u.x/_,u.y/_),0));const t=F.vec4.transformMat4([],[u.x,u.y,e,1],i.projMatrix)[3]/i.cameraToCenterDistance;f=t,m=t*rc(i.center.lat,h)}else if("globe"===i.projection.name){const t=y_(e,i),n=F.mat4.multiply([],i.projMatrix,t),o=[0,0,0,1];F.vec4.transformMat4(o,o,n);const s=o[3]/i.cameraToCenterDistance,a=Sh(h),l=i.projection.pixelsPerMeter(r.lat,_)*rc(r.lat,h),c=i.projection.pixelsPerMeter(i.center.lat,_)*rc(i.center.lat,h);f=s/Et(l,ic(i.center.lat),a),m=s*d/l,f*=c,m*=c}}else f=p;F.mat4.scale(e,e,[f,f,m]);const g=[...e],y=t.orientation,x=[];if(__(x,[y[0]+n[0],y[1]+n[1],y[2]+n[2]],o),F.mat4.multiply(e,g,x),a&&i.elevation){let n=0;const o=[];if(l&&i.elevation){n=function(e,t,i,r,n){const o=t.elevation;if(!o)return 0;const s=nh.projectAabbCorners(i,r),a=Kl(1,n.lat)*t.worldSize,l=function(e,t){const i=[0,0,1],r=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const n of r){const r=e[n.corners[0]],o=e[n.corners[1]],s=e[n.corners[2]],a=[o[0]-r[0],o[1]-r[1],t*(o[2]-r[2])],l=F.vec3.cross(a,a,[s[0]-r[0],s[1]-r[1],t*(s[2]-r[2])]);F.vec3.normalize(l,l),n.dotProductWithUp=F.vec3.dot(l,i)}return r.sort(((e,t)=>e.dotProductWithUp-t.dotProductWithUp)),r[0].corners}(s,a),c=s[l[0]],h=s[l[1]],u=s[l[2]],d=s[l[3]],p=o.getAtPointOrZero(new sc(c[0]/t.worldSize,c[1]/t.worldSize),0),f=o.getAtPointOrZero(new sc(h[0]/t.worldSize,h[1]/t.worldSize),0),m=o.getAtPointOrZero(new sc(u[0]/t.worldSize,u[1]/t.worldSize),0),_=o.getAtPointOrZero(new sc(d[0]/t.worldSize,d[1]/t.worldSize),0),g=(p+_)/2,y=(f+m)/2;return g>y?f<m?g_(e,h,d,c,f,_,p,a):g_(e,u,c,d,m,p,_,a):p<_?g_(e,c,h,u,p,f,m,a):g_(e,d,u,h,_,m,f,a),Math.max(g,y)}(o,i,t.aabb,e,r);const s=F.mat4.fromQuat([],o),a=F.mat4.multiply([],s,x);F.mat4.multiply(e,g,a)}else n=i.elevation.getAtPointOrZero(new sc(u.x/_,u.y/_),0);0!==n&&(e[14]+=n)}}function B_(e,t,i=!1){e.uploaded||(e.gfxTexture=new Wm(t,e.image,i?t.gl.R8:t.gl.RGBA8,{useMipmap:e.sampler.minFilter>=t.gl.NEAREST_MIPMAP_NEAREST}),e.uploaded=!0,e.image=null)}function N_(e,t,i){e.indexBuffer=t.createIndexBuffer(e.indexArray,!1,!0),e.vertexBuffer=t.createVertexBuffer(e.vertexArray,v_.members,!1,!0),e.normalArray&&(e.normalBuffer=t.createVertexBuffer(e.normalArray,S_.members,!1,!0)),e.texcoordArray&&(e.texcoordBuffer=t.createVertexBuffer(e.texcoordArray,T_.members,!1,!0)),e.colorArray&&(e.colorBuffer=t.createVertexBuffer(e.colorArray,(12===e.colorArray.bytesPerElement?b_:w_).members,!1,!0)),e.featureArray&&(e.pbrBuffer=t.createVertexBuffer(e.featureArray,E_.members,!0)),e.segments=nl.simpleSegment(0,0,e.vertexArray.length,e.indexArray.length);const r=e.material;r.pbrMetallicRoughness.baseColorTexture&&B_(r.pbrMetallicRoughness.baseColorTexture,t),r.pbrMetallicRoughness.metallicRoughnessTexture&&B_(r.pbrMetallicRoughness.metallicRoughnessTexture,t),r.normalTexture&&B_(r.normalTexture,t),r.occlusionTexture&&B_(r.occlusionTexture,t,i),r.emissionTexture&&B_(r.emissionTexture,t)}function V_(e,t,i){if(e.meshes)for(const r of e.meshes)N_(r,t,i);if(e.children)for(const r of e.children)V_(r,t,i)}function U_(e){if(e.meshes)for(const t of e.meshes)t.indexArray.destroy(),t.vertexArray.destroy(),t.colorArray&&t.colorArray.destroy(),t.normalArray&&t.normalArray.destroy(),t.texcoordArray&&t.texcoordArray.destroy(),t.featureArray&&t.featureArray.destroy();if(e.children)for(const t of e.children)U_(t)}function j_(e){if(e.meshes)for(const i of e.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((t=i.material).pbrMetallicRoughness.baseColorTexture&&t.pbrMetallicRoughness.baseColorTexture.gfxTexture&&t.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),t.pbrMetallicRoughness.metallicRoughnessTexture&&t.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&t.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),t.normalTexture&&t.normalTexture.gfxTexture&&t.normalTexture.gfxTexture.destroy(),t.emissionTexture&&t.emissionTexture.gfxTexture&&t.emissionTexture.gfxTexture.destroy(),t.occlusionTexture&&t.occlusionTexture.gfxTexture&&t.occlusionTexture.gfxTexture.destroy()));var t;if(e.children)for(const t of e.children)j_(t)}class G_{constructor(e,t,i){this._demTile=e,this._dem=this._demTile.dem,this._scale=t,this._offset=i}static create(e,t,i){const r=i||e.findDEMTileFor(t);if(!r||!r.dem)return;const n=r.dem,o=r.tileID,s=1<<t.canonical.z-o.canonical.z;return new G_(r,n.dim/Wi/s,[(t.canonical.x/s-o.canonical.x)*n.dim,(t.canonical.y/s-o.canonical.y)*n.dim])}tileCoordToPixel(e,t){const i=t*this._scale+this._offset[1],r=Math.floor(e*this._scale+this._offset[0]),n=Math.floor(i);return new U(r,n)}getElevationAt(e,t,i,r){const n=e*this._scale+this._offset[0],o=t*this._scale+this._offset[1],s=Math.floor(n),a=Math.floor(o),l=this._dem;return r=!!r,i?Et(Et(l.get(s,a,r),l.get(s,a+1,r),o-a),Et(l.get(s+1,a,r),l.get(s+1,a+1,r),o-a),n-s):l.get(s,a,r)}getElevationAtPixel(e,t,i){return this._dem.get(e,t,!!i)}getMeterToDEM(e){return(1<<this._demTile.tileID.canonical.z)*Kl(1,e)*this._dem.stride}}const q_=new Float32Array(262144),Z_=new Uint8Array(262144);function $_(e){let t=0;if(e.meshes)for(const i of e.meshes)t=Math.max(t,i.aabb.max[2]);if(e.children)for(const i of e.children)t=Math.max(t,$_(i));return t}function H_(e,t,i){if(e.meshes)for(const r of e.meshes){if(r.aabb.min[0]===1/0)continue;const n=nh.applyTransform(r.aabb,e.matrix);i.insert(t,n.min[0],n.min[1],n.max[0],n.max[1])}if(e.children)for(const r of e.children)H_(r,t,i)}const W_=["","wall","door","roof","window","lamp","logo"];class X_{constructor(e){this.node=e,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.cameraCollisionOpacity=1,this.feature={type:"Point",id:e.id,geometry:[],properties:{height:$_(e)}},this.aabb=this._getLocalBounds(),this.state=null}_getLocalBounds(){if(!this.node.meshes)return new nh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let e=0;const t=new nh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const i of this.node.meshes)this.node.lightMeshIndex!==e&&(i.transformedAabb=nh.applyTransformFast(i.aabb,this.node.matrix),t.encapsulate(i.transformedAabb)),e++;this.aabb=t}return this.aabb}}class Y_{constructor(e,t,i,r,n,o,s){this.id=i,this.layers=e,this.layerIds=this.layers.map((e=>e.fqid)),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.modelTraits|=k_.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,r&&(this.modelTraits|=k_.HasMapboxMeshFeatures),n&&(this.modelTraits|=k_.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=o,this.dirty=!0,this.needsUpload=!1,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new X_(e)),H_(e,s.featureIndexArray.length,s.grid),s.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,s.bucketLayerIDs.length-1,0);this.states={}}updateFootprints(e,t){for(const i of this.getNodesInfo()){const r=i.node;r.footprint&&t.push({footprint:r.footprint,id:e})}}update(e){const t=0!==Object.keys(e).length;if(t&&!this.stateDependentLayers.length)return;const i=t?this.stateDependentLayers:this.layers;if(!j(e,this.states))for(const t of i)this.evaluate(t,e);this.states=structuredClone(e)}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(e){if(!this.needsUpload)return;const t=this.getNodesInfo();for(const i of t){const t=i.node;this.uploaded?this.updatePbrBuffer(t):V_(t,e,!0)}for(const e of t)U_(e.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(e){let t=!1;if(!e.meshes)return t;for(const i of e.meshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),t=!0);return t}needsReEvaluation(e,t,i){const r=e.transform.projectionOptions,n=e.style.getBrightness(),o=this.brightness!==n;if(!this.uploaded||this.dirty||r.name!==this.projection.name||K_(i.paint.get("model-color").value,o)||K_(i.paint.get("model-color-mix-intensity").value,o)||K_(i.paint.get("model-roughness").value,o)||K_(i.paint.get("model-emissive-strength").value,o)||K_(i.paint.get("model-height-based-emissive-strength-multiplier").value,o)){this.projection=r,this.brightness=n;const e=this.getNodesInfo();for(const t of e)t.state=null;return!0}return!1}evaluateScale(e,t){if(e.transform.zoom===this.zoom)return;this.zoom=e.transform.zoom;const i=this.getNodesInfo(),r=this.id.canonical;for(const e of i){const i=e.feature;e.evaluatedScale=t.paint.get("model-scale").evaluate(i,{},r)}}evaluate(e,t){const i=this.getNodesInfo();for(const r of i){if(!r.node.meshes)continue;const i=r.feature,n=t&&t[i.id];if(j(n,r.state))continue;r.state=structuredClone(n);const o=r.node.meshes&&r.node.meshes[0].featureData,s=r.evaluatedColor[2],a=r.evaluatedRMEA[2],l=this.id.canonical;if(r.hasTranslucentParts=!1,o){for(let t=0;t<W_.length;t++){const o=W_[t];o.length&&(i.properties.part=o);const s=e.paint.get("model-color").evaluate(i,n,l).toRenderColor(null),a=e.paint.get("model-color-mix-intensity").evaluate(i,n,l);r.evaluatedColor[t]=[s.r,s.g,s.b,a],r.evaluatedRMEA[t][0]=e.paint.get("model-roughness").evaluate(i,n,l),r.evaluatedRMEA[t][2]=e.paint.get("model-emissive-strength").evaluate(i,n,l),r.evaluatedRMEA[t][3]=s.a,r.emissionHeightBasedParams[t]=e.paint.get("model-height-based-emissive-strength-multiplier").evaluate(i,n,l),!r.hasTranslucentParts&&s.a<1&&(r.hasTranslucentParts=!0)}delete i.properties.part,Q_(r,s!==r.evaluatedColor[2]||a!==r.evaluatedRMEA[2],this.modelTraits)}else r.evaluatedRMEA[0][2]=e.paint.get("model-emissive-strength").evaluate(i,n,l);r.evaluatedScale=e.paint.get("model-scale").evaluate(i,n,l),this.updatePbrBuffer(r.node)||(this.needsUpload=!0)}this.dirty=!1}elevationUpdate(e,t,i,r){const n=e.findDEMTileFor(i);if(n&&(n.tileID.canonical!==this.terrainTile||t!==this.terrainExaggeration)){if(n.dem&&n.tileID.overscaledZ!==this.elevationReadFromZ){this.elevationReadFromZ=n.tileID.overscaledZ;const t=G_.create(e,i,n);if(!t)return;this.modelTraits&k_.HasMapboxMeshFeatures&&this.updateDEM(e,t,i,r);for(const e of this.getNodesInfo()){const i=e.node;if(!i.footprint||!i.footprint.vertices||!i.footprint.vertices.length)continue;const r=i.footprint.vertices;let n=t.getElevationAt(r[0].x,r[0].y,!0,!0);for(let e=1;e<r.length;e++)n=Math.min(n,t.getElevationAt(r[e].x,r[e].y,!0,!0));i.elevation=n}}this.terrainTile=n.tileID.canonical,this.terrainExaggeration=t}}updateDEM(e,t,i,r){let n=t._dem._modifiedForSources[r];if(void 0===n&&(t._dem._modifiedForSources[r]=[],n=t._dem._modifiedForSources[r]),n.includes(i.canonical))return;const o=t._dem.dim;n.push(i.canonical);let s=!1;for(const e of this.getNodesInfo()){const i=e.node;if(!i.footprint||!i.footprint.grid)continue;const r=i.footprint.grid,n=t.tileCoordToPixel(r.min.x,r.min.y),a=t.tileCoordToPixel(r.max.x,r.max.y),l=Math.min(Math.min(o-a.y,n.x),Math.min(n.y,o-a.x));if(l<0)continue;const c=K(l,2,5);let h=Math.max(0,n.x-c),u=Math.max(0,n.y-c),d=Math.min(a.x+c,o-1),p=Math.min(a.y+c,o-1);for(let e=u;e<=p;++e)for(let t=h;t<=d;++t)Z_[e*o+t]=255;let f=0,m=0;for(let e=0;e<r.cellsY;++e)for(let i=0;i<r.cellsX;++i){if(!r.cells[e*r.cellsX+i])continue;const n=t.tileCoordToPixel(r.min.x+i/r.xScale,r.min.y+e/r.yScale),s=t.tileCoordToPixel(r.min.x+(i+1)/r.xScale,r.min.y+(e+1)/r.yScale);for(let e=n.y;e<=Math.min(s.y+1,o-1);++e)for(let i=n.x;i<=Math.min(s.x+1,o-1);++i)255===Z_[e*o+i]&&(Z_[e*o+i]=0,f+=t.getElevationAtPixel(i,e),m++)}const _=f/m;h=Math.max(1,n.x-c),u=Math.max(1,n.y-c),d=Math.min(a.x+c,o-2),p=Math.min(a.y+c,o-2),s=!0;for(let e=u;e<=p;++e)for(let i=h;i<=d;++i)0===Z_[e*o+i]&&(q_[e*o+i]=t._dem.set(i,e,_));for(let e=1;e<c;++e){h=Math.max(1,n.x-e),u=Math.max(1,n.y-e),d=Math.min(a.x+e,o-2),p=Math.min(a.y+e,o-2);for(let i=u;i<=p;++i)for(let r=h;r<=d;++r){const n=i*o+r;if(255===Z_[n]){let s=0,a=0,l=-1,h=-1;for(let t=-1;t<=1;++t)for(let n=-1;n<=1;++n){const c=(i+t)*o+r+n;if(Z_[c]>=e)continue;const u=q_[c],d=Math.abs(u);d>a&&(s=u,a=d,l=n,h=t)}if(a>.1){const o=1-(e+.5*Math.abs(l*h))/c;let a=t._dem.get(r,i)+s*o;const u=t._dem.get(r+l,i+h),d=t._dem.get(r-l,i-h,!0);(a-u)*(a-d)>0&&(a=(u+d)/2),q_[n]=t._dem.set(r,i,a),Z_[n]=e}}}}}s&&(t._demTile.needsDEMTextureUpload=!0,t._dem._timestamp=Re.now())}getNodesInfo(){return this.nodesInfo}destroy(){const e=this.getNodesInfo();for(const t of e)U_(t.node),j_(t.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const i=t.getReplacementRegionsForTile(e.toUnwrapped()),r=this.getNodesInfo();for(let e=0;e<this.nodesInfo.length;e++){const t=r[e].node;r[e].hiddenByReplacement=!!t.footprint&&!i.find((e=>e.footprint===t.footprint))}}getHeightAtTileCoord(e,t){const i=this.getNodesInfo(),r=[],n=[0,0,0],o=F.mat4.identity([]);for(let s=0;s<this.nodesInfo.length;s++){const a=i[s],l=a.node.meshes[0],c=l.transformedAabb;if(e<c.min[0]||t<c.min[1]||e>c.max[0]||t>c.max[1])continue;if(!0===a.node.hidden)return{height:1/0,maxHeight:a.feature.properties.height,hidden:!1,verticalScale:a.evaluatedScale[2]};F.mat4.invert(o,a.node.matrix),n[0]=e,n[1]=t,F.vec3.transformMat4(n,n,o);const h=(n[0]-l.aabb.min[0])/(l.aabb.max[0]-l.aabb.min[0])*O_|0,u=Math.min(63,(n[1]-l.aabb.min[1])/(l.aabb.max[1]-l.aabb.min[1])*O_|0)*O_+Math.min(63,h),d=l.heightmap[u];if(!(d<0&&a.node.footprint)){if(a.hiddenByReplacement)return;return{height:d,maxHeight:a.feature.properties.height,hidden:!1,verticalScale:a.evaluatedScale[2]}}if(a.node.footprint.grid.query(new U(e,t),new U(e,t),r),r.length>0)return{height:void 0,maxHeight:a.feature.properties.height,hidden:a.hiddenByReplacement,verticalScale:a.evaluatedScale[2]}}}}function K_(e,t){return!e.isLightConstant&&t}function J_(e,t,i,r,n,o,s,a){let l=(61440&t|(61440&t)>>4)>>8,c=(3840&t|(3840&t)>>4)>>4,h=240&t|(240&t)>>4;i[3]>0&&(l=Et(l,255*i[0],i[3]),c=Et(c,255*i[1],i[3]),h=Et(h,255*i[2],i[3]));const u=l<<8|c,d=h<<8|Math.floor(255*r[3]),p=function(e){const t=K(e,0,2);return Math.min(Math.round(.5*t*255),255)}(r[2])<<8|15*r[0]<<4|15*r[1],f=K(n[0],0,1),m=K(n[1],0,1),_=K(n[2],0,1),g=K(n[3],0,1);let y,x,v,b;if(f!==m&&s!==o&&m!==f){const e=s-o;x=1/(e*(m-f)),v=-(o+e*f)/(e*(m-f));const t=K(n[4],-1,1);b=Math.pow(10,t),y=255*_<<8|255*g}else y=65535,x=0,v=1,b=1;if(e.emplaceBack(u,d,p,y,x,v,b),a){const e=a.length;a.clear();for(let t=0;t<e;t++)a.emplaceBack(u,d,p,y,x,v,b)}}function Q_(e,t,i){const r=e.node;let n=0;const o=i&k_.HasMeshoptCompression;for(const i of r.meshes){if(r.lights&&r.lightMeshIndex===n)continue;if(!i.featureData)continue;i.featureArray=new Va,i.featureArray.reserve(i.featureData.length);let s=t;for(const t of i.featureData){const n=o?65535&t:t>>16&65535,a=o?t>>16&65535:65535&t,l=(15&a)<8?15&a:0,c=e.evaluatedRMEA[l],h=e.evaluatedColor[l],u=e.emissionHeightBasedParams[l];let d;if(s&&2===l&&r.lights&&(d=new Va,d.resize(10*r.lights.length)),J_(i.featureArray,n,h,c,u,i.aabb.min[2],i.aabb.max[2],d),d&&s){s=!1;const e=r.meshes[r.lightMeshIndex];e.featureArray=d,e.featureArray._trim()}}i.featureArray._trim(),n++}}function eg(e,t,i,r){const n=1<<e.z;t.lat=Ql((r/Wi+e.y)/n),t.lng=Jl((i/Wi+e.x)/n)}ro(Y_,"Tiled3dModelBucket",{omit:["layers"]}),ro(X_,"Tiled3dModelFeature");const tg={circle:class extends na{constructor(e,t,i,r){super(e,{layout:Fc||(Fc=new Fs({"circle-sort-key":new Os(Bs.layout_circle["circle-sort-key"]),visibility:new Ls(Bs.layout_circle.visibility)})),paint:Bc||(Bc=new Fs({"circle-radius":new Os(Bs.paint_circle["circle-radius"]),"circle-color":new Os(Bs.paint_circle["circle-color"]),"circle-blur":new Os(Bs.paint_circle["circle-blur"]),"circle-opacity":new Os(Bs.paint_circle["circle-opacity"]),"circle-translate":new Ls(Bs.paint_circle["circle-translate"]),"circle-translate-anchor":new Ls(Bs.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new Ls(Bs.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new Ls(Bs.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Os(Bs.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Os(Bs.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Os(Bs.paint_circle["circle-stroke-opacity"]),"circle-emissive-strength":new Ls(Bs.paint_circle["circle-emissive-strength"]),"circle-color-use-theme":new Os({type:"string",default:"default","property-type":"data-driven"}),"circle-stroke-color-use-theme":new Os({type:"string",default:"default","property-type":"data-driven"})}))},t,i,r)}createBucket(e){return new yc(e)}queryRadius(e){const t=e;return Rc("circle-radius",this,t)+Rc("circle-stroke-width",this,t)+Lc(this.paint.get("circle-translate"))}queryIntersectsFeature(e,t,i,r,n,o,s,a){const l=kc(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),c=this.paint.get("circle-radius").evaluate(t,i)+this.paint.get("circle-stroke-width").evaluate(t,i);return Dh(e,r,o,s,a,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),l,c)}getProgramIds(){return["circle"]}getDefaultProgramParams(e,t,i){const r=zh(this);return{config:new Pl(this,{zoom:t,lut:i}),defines:r,overrideFog:!1}}},heatmap:class extends na{createBucket(e){return new Fh(e)}constructor(e,t,i,r){super(e,{layout:Bh||(Bh=new Fs({visibility:new Ls(Bs.layout_heatmap.visibility)})),paint:Nh||(Nh=new Fs({"heatmap-radius":new Os(Bs.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Os(Bs.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Ls(Bs.paint_heatmap["heatmap-intensity"]),"heatmap-color":new ks(Bs.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Ls(Bs.paint_heatmap["heatmap-opacity"]),"heatmap-color-use-theme":new Os({type:"string",default:"default","property-type":"data-driven"})}))},t,i,r),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){"heatmap-color"===e&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Wh({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(e){return Rc("heatmap-radius",this,e)}queryIntersectsFeature(e,t,i,r,n,o,s,a){const l=this.paint.get("heatmap-radius").evaluate(t,i);return Dh(e,r,o,s,a,!0,!0,new U(0,0),l)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getDefaultProgramParams(e,t,i){return"heatmap"===e?{config:new Pl(this,{zoom:t,lut:i}),overrideFog:!1}:{}}},hillshade:class extends na{constructor(e,t,i,r){super(e,{layout:Vh||(Vh=new Fs({visibility:new Ls(Bs.layout_hillshade.visibility)})),paint:Uh||(Uh=new Fs({"hillshade-illumination-direction":new Ls(Bs.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new Ls(Bs.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new Ls(Bs.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new Ls(Bs.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new Ls(Bs.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new Ls(Bs.paint_hillshade["hillshade-accent-color"]),"hillshade-emissive-strength":new Ls(Bs.paint_hillshade["hillshade-emissive-strength"]),"hillshade-shadow-color-use-theme":new Os({type:"string",default:"default","property-type":"data-driven"}),"hillshade-highlight-color-use-theme":new Os({type:"string",default:"default","property-type":"data-driven"}),"hillshade-accent-color-use-theme":new Os({type:"string",default:"default","property-type":"data-driven"})}))},t,i,r)}shouldRedrape(){return this.hasOffscreenPass()&&"viewport"===this.paint.get("hillshade-illumination-anchor")}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}getDefaultProgramParams(e,t,i){return{overrideFog:!1}}},fill:class extends na{constructor(e,t,i,r){super(e,{layout:Iu||(Iu=new Fs({"fill-sort-key":new Os(Bs.layout_fill["fill-sort-key"]),visibility:new Ls(Bs.layout_fill.visibility),"fill-elevation-reference":new Ls(Bs.layout_fill["fill-elevation-reference"])})),paint:Cu||(Cu=new Fs({"fill-antialias":new Ls(Bs.paint_fill["fill-antialias"]),"fill-opacity":new Os(Bs.paint_fill["fill-opacity"]),"fill-color":new Os(Bs.paint_fill["fill-color"]),"fill-outline-color":new Os(Bs.paint_fill["fill-outline-color"]),"fill-translate":new Ls(Bs.paint_fill["fill-translate"]),"fill-translate-anchor":new Ls(Bs.paint_fill["fill-translate-anchor"]),"fill-pattern":new Os(Bs.paint_fill["fill-pattern"]),"fill-emissive-strength":new Ls(Bs.paint_fill["fill-emissive-strength"]),"fill-z-offset":new Os(Bs.paint_fill["fill-z-offset"]),"fill-color-use-theme":new Os({type:"string",default:"default","property-type":"data-driven"}),"fill-outline-color-use-theme":new Os({type:"string",default:"default","property-type":"data-driven"})}))},t,i,r)}getProgramIds(){const e=this.paint.get("fill-pattern"),t=e&&e.constantOr(1),i=[t?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&i.push(t&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),i}getDefaultProgramParams(e,t,i){return{config:new Pl(this,{zoom:t,lut:i}),overrideFog:!1}}recalculate(e,t){super.recalculate(e,t);const i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new Au(e)}queryRadius(){return Lc(this.paint.get("fill-translate"))}queryIntersectsFeature(e,t,i,r,n,o){return!e.queryGeometry.isAboveHorizon&&bc(Oc(e.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),r)}isTileClipped(){return!0}is3D(){return 0!==this.paint.get("fill-z-offset").constantOr(1)}},"fill-extrusion":class extends na{constructor(e,t,i,r){super(e,{layout:Wd||(Wd=new Fs({visibility:new Ls(Bs["layout_fill-extrusion"].visibility),"fill-extrusion-edge-radius":new Ls(Bs["layout_fill-extrusion"]["fill-extrusion-edge-radius"])})),paint:Xd||(Xd=new Fs({"fill-extrusion-opacity":new Ls(Bs["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Os(Bs["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Ls(Bs["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Ls(Bs["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Os(Bs["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Os(Bs["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Os(Bs["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-height-alignment":new Ls(Bs["paint_fill-extrusion"]["fill-extrusion-height-alignment"]),"fill-extrusion-base-alignment":new Ls(Bs["paint_fill-extrusion"]["fill-extrusion-base-alignment"]),"fill-extrusion-vertical-gradient":new Ls(Bs["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new Ls(Bs["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new Ls(Bs["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"]),"fill-extrusion-ambient-occlusion-wall-radius":new Ls(Bs["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-wall-radius"]),"fill-extrusion-ambient-occlusion-ground-radius":new Ls(Bs["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-radius"]),"fill-extrusion-ambient-occlusion-ground-attenuation":new Ls(Bs["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-attenuation"]),"fill-extrusion-flood-light-color":new Ls(Bs["paint_fill-extrusion"]["fill-extrusion-flood-light-color"]),"fill-extrusion-flood-light-intensity":new Ls(Bs["paint_fill-extrusion"]["fill-extrusion-flood-light-intensity"]),"fill-extrusion-flood-light-wall-radius":new Os(Bs["paint_fill-extrusion"]["fill-extrusion-flood-light-wall-radius"]),"fill-extrusion-flood-light-ground-radius":new Os(Bs["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-radius"]),"fill-extrusion-flood-light-ground-attenuation":new Ls(Bs["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-attenuation"]),"fill-extrusion-vertical-scale":new Ls(Bs["paint_fill-extrusion"]["fill-extrusion-vertical-scale"]),"fill-extrusion-rounded-roof":new Ls(Bs["paint_fill-extrusion"]["fill-extrusion-rounded-roof"]),"fill-extrusion-cutoff-fade-range":new Ls(Bs["paint_fill-extrusion"]["fill-extrusion-cutoff-fade-range"]),"fill-extrusion-emissive-strength":new Os(Bs["paint_fill-extrusion"]["fill-extrusion-emissive-strength"]),"fill-extrusion-line-width":new Os(Bs["paint_fill-extrusion"]["fill-extrusion-line-width"]),"fill-extrusion-cast-shadows":new Ls(Bs["paint_fill-extrusion"]["fill-extrusion-cast-shadows"]),"fill-extrusion-color-use-theme":new Os({type:"string",default:"default","property-type":"data-driven"}),"fill-extrusion-flood-light-color-use-theme":new Os({type:"string",default:"default","property-type":"data-driven"})}))},t,i,r),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(e){return new Fd(e)}queryRadius(){return Lc(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}hasShadowPass(){return this.paint.get("fill-extrusion-cast-shadows")}cutoffRange(){return this.paint.get("fill-extrusion-cutoff-fade-range")}canCastShadows(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}queryIntersectsFeature(e,t,i,r,n,o,s,a,l){const c=kc(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),h=this.paint.get("fill-extrusion-height").evaluate(t,i),u=this.paint.get("fill-extrusion-base").evaluate(t,i),d=[0,0],p=a&&o.elevation,f=o.elevation?o.elevation.exaggeration():1,m=e.tile.getBucket(this);if(p&&m instanceof Fd){const e=m.centroidVertexArray,t=l+1;t<e.length&&(d[0]=e.geta_centroid_pos0(t),d[1]=e.geta_centroid_pos1(t))}if(0===d[0]&&1===d[1])return!1;"globe"===o.projection.name&&(r=$d([r],[new U(0,0),new U(Wi,Wi)],e.tileID.canonical).map((e=>e.polygon)).flat());const _=p?a:null,[g,y]=function(e,t,i,r,n,o,s,a,l,c,h){return"globe"===e.projection.name?function(e,t,i,r,n,o,s,a,l,c,h){const u=[],d=[],p=e.projection.upVectorScale(h,e.center.lat,e.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],_=(e,t,i,r)=>{e[0]=t,e[1]=i,e[2]=r,e[3]=1},g=Zd();i>0&&(i+=g),r+=g;for(const g of t){const t=[],y=[];for(const u of g){const d=u.x+n.x,g=u.y+n.y,x=e.projection.projectTilePoint(d,g,h),v=e.projection.upVector(h,u.x,u.y);let b=i,w=r;if(s){const e=Jd(d,g,i,r,s,a,l,c);b+=e.base,w+=e.top}0!==i?_(f,x.x+v[0]*p*b,x.y+v[1]*p*b,x.z+v[2]*p*b):_(f,x.x,x.y,x.z),_(m,x.x+v[0]*p*w,x.y+v[1]*p*w,x.z+v[2]*p*w),F.vec3.transformMat4(f,f,o),F.vec3.transformMat4(m,m,o),t.push(new ed(f[0],f[1],f[2])),y.push(new ed(m[0],m[1],m[2]))}u.push(t),d.push(y)}return[u,d]}(e,t,i,r,n,o,s,a,l,c,h):s?function(e,t,i,r,n,o,s,a,l){const c=[],h=[],u=[0,0,0,1];for(const d of e){const e=[],p=[];for(const c of d){const h=c.x+r.x,d=c.y+r.y,f=Jd(h,d,t,i,o,s,a,l);u[0]=h,u[1]=d,u[2]=f.base,u[3]=1,F.vec4.transformMat4(u,u,n),u[3]=Math.max(u[3],1e-5);const m=new ed(u[0]/u[3],u[1]/u[3],u[2]/u[3]);u[0]=h,u[1]=d,u[2]=f.top,u[3]=1,F.vec4.transformMat4(u,u,n),u[3]=Math.max(u[3],1e-5);const _=new ed(u[0]/u[3],u[1]/u[3],u[2]/u[3]);e.push(m),p.push(_)}c.push(e),h.push(p)}return[c,h]}(t,i,r,n,o,s,a,l,c):function(e,t,i,r,n){const o=[],s=[],a=n[8]*t,l=n[9]*t,c=n[10]*t,h=n[11]*t,u=n[8]*i,d=n[9]*i,p=n[10]*i,f=n[11]*i;for(const t of e){const e=[],i=[];for(const o of t){const t=o.x+r.x,s=o.y+r.y,m=n[0]*t+n[4]*s+n[12],_=n[1]*t+n[5]*s+n[13],g=n[2]*t+n[6]*s+n[14],y=n[3]*t+n[7]*s+n[15],x=m+a,v=_+l,b=g+c,w=Math.max(y+h,1e-5),T=m+u,S=_+d,M=g+p,E=Math.max(y+f,1e-5);e.push(new ed(x/w,v/w,b/w)),i.push(new ed(T/E,S/E,M/E))}o.push(e),s.push(i)}return[o,s]}(t,i,r,n,o)}(o,r,u,h,c,s,_,d,f,o.center.lat,e.tileID.canonical),x=e.queryGeometry;return function(e,t,i){let r=1/0;bc(i,t)&&(r=Kd(i,t[0]));for(let n=0;n<t.length;n++){const o=t[n],s=e[n];for(let e=0;e<o.length-1;e++){const t=o[e],n=[t,o[e+1],s[e+1],s[e],t];xc(i,n)&&(r=Math.min(r,Kd(i,n)))}}return r!==1/0&&r}(g,y,x.isPointQuery()?x.screenBounds:x.screenGeometry)}},line:class extends na{constructor(e,t,i,r){const n=bp();super(e,n,t,i,r),n.layout&&(this.layout=new Rs(n.layout)),this.gradientVersion=0}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof Or,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}widthExpression(){return this._transitionablePaint._values["line-width"].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values["line-floorwidth"]=(()=>{if(Tp)return Tp;const e=bp();return Tp=new wp(e.paint.properties["line-width"].specification),Tp.useIntegerZoom=!0,Tp})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new hp(e)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(e,t,i){const r=yp(this);return{config:new Pl(this,{zoom:t,lut:i}),defines:r,overrideFog:!1}}queryRadius(e){const t=e,i=Sp(Rc("line-width",this,t),Rc("line-gap-width",this,t)),r=Rc("line-offset",this,t);return i/2+Math.abs(r)+Lc(this.paint.get("line-translate"))}queryIntersectsFeature(e,t,i,r,n,o){if(e.queryGeometry.isAboveHorizon)return!1;const s=Oc(e.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),a=e.pixelToTileUnitsFactor/2*Sp(this.paint.get("line-width").evaluate(t,i),this.paint.get("line-gap-width").evaluate(t,i)),l=this.paint.get("line-offset").evaluate(t,i);return l&&(r=function(e,t){const i=[],r=new U(0,0);for(let n=0;n<e.length;n++){const o=e[n],s=[];for(let e=0;e<o.length;e++){const i=o[e],n=o[e+1],a=0===e?r:i.sub(o[e-1])._unit()._perp(),l=e===o.length-1?r:n.sub(i)._unit()._perp(),c=a._add(l)._unit();c._mult(1/(c.x*l.x+c.y*l.y)),s.push(c._mult(t)._add(i))}i.push(s)}return i}(r,l*e.pixelToTileUnitsFactor)),function(e,t,i){for(let r=0;r<t.length;r++){const n=t[r];if(e.length>=3)for(let t=0;t<n.length;t++)if(Ic(e,n[t]))return!0;if(wc(e,n,i))return!0}return!1}(s,r,a)}isTileClipped(){return!0}isDraped(e){const t=this.layout.get("line-z-offset"),i=t.isConstant()&&!t.constantOr(0),r=this.layout.get("line-elevation-reference");return!("sea"===r||"ground"===r)&&(i||"none"!==r)}},symbol:Vm,background:class extends na{constructor(e,t,i,r){super(e,{layout:Um||(Um=new Fs({visibility:new Ls(Bs.layout_background.visibility)})),paint:jm||(jm=new Fs({"background-pitch-alignment":new Ls(Bs.paint_background["background-pitch-alignment"]),"background-color":new Ls(Bs.paint_background["background-color"]),"background-pattern":new Ls(Bs.paint_background["background-pattern"]),"background-opacity":new Ls(Bs.paint_background["background-opacity"]),"background-emissive-strength":new Ls(Bs.paint_background["background-emissive-strength"]),"background-color-use-theme":new Os({type:"string",default:"default","property-type":"data-driven"})}))},t,i,r)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}getDefaultProgramParams(e,t,i){return{overrideFog:!1}}is3D(){return"viewport"===this.paint.get("background-pitch-alignment")}},raster:t_,"raster-particle":a_,sky:class extends na{constructor(e,t,i,r){super(e,{layout:n_||(n_=new Fs({visibility:new Ls(Bs.layout_sky.visibility)})),paint:o_||(o_=new Fs({"sky-type":new Ls(Bs.paint_sky["sky-type"]),"sky-atmosphere-sun":new Ls(Bs.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new Ls(Bs.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new Ls(Bs.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new Ls(Bs.paint_sky["sky-gradient-radius"]),"sky-gradient":new ks(Bs.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new Ls(Bs.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new Ls(Bs.paint_sky["sky-atmosphere-color"]),"sky-opacity":new Ls(Bs.paint_sky["sky-opacity"]),"sky-gradient-use-theme":new Os({type:"string",default:"default","property-type":"data-driven"}),"sky-atmosphere-halo-color-use-theme":new Os({type:"string",default:"default","property-type":"data-driven"}),"sky-atmosphere-color-use-theme":new Os({type:"string",default:"default","property-type":"data-driven"})}))},t,i,r),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){"sky-gradient"===e?this._updateColorRamp():"sky-atmosphere-sun"!==e&&"sky-atmosphere-halo-color"!==e&&"sky-atmosphere-color"!==e&&"sky-atmosphere-sun-intensity"!==e||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=Wh({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(e){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){const t=e.style.light.properties.get("position");return this._lightPosition.azimuthal!==t.azimuthal||this._lightPosition.polar!==t.polar}return!1}getCenter(e,t){if("atmosphere"===this.paint.get("sky-type")){const i=this.paint.get("sky-atmosphere-sun"),r=!i,n=e.style.light,o=n.properties.get("position");return r&&"viewport"===n.properties.get("anchor")&&ue("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),r?c_(o.azimuthal,90-o.polar,t):c_(i[0],90-i[1],t)}const i=this.paint.get("sky-gradient-center");return c_(i[0],90-i[1],t)}isSky(){return!0}markSkyboxValid(e){this._skyboxInvalidated=!1,this._lightPosition=e.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){const e=this.paint.get("sky-type");return"atmosphere"===e?["skyboxCapture","skybox"]:"gradient"===e?["skyboxGradient"]:null}},slot:class extends na{constructor(e,t,i,r){super(e,{paint:s_||(s_=new Fs({}))},t,null)}},model:class extends na{constructor(e,t,i,r){super(e,{layout:R_||(R_=new Fs({visibility:new Ls(Bs.layout_model.visibility),"model-id":new Os(Bs.layout_model["model-id"])})),paint:L_||(L_=new Fs({"model-opacity":new Os(Bs.paint_model["model-opacity"]),"model-rotation":new Os(Bs.paint_model["model-rotation"]),"model-scale":new Os(Bs.paint_model["model-scale"]),"model-translation":new Os(Bs.paint_model["model-translation"]),"model-color":new Os(Bs.paint_model["model-color"]),"model-color-mix-intensity":new Os(Bs.paint_model["model-color-mix-intensity"]),"model-type":new Ls(Bs.paint_model["model-type"]),"model-cast-shadows":new Ls(Bs.paint_model["model-cast-shadows"]),"model-receive-shadows":new Ls(Bs.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new Ls(Bs.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new Os(Bs.paint_model["model-emissive-strength"]),"model-roughness":new Os(Bs.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new Os(Bs.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new Ls(Bs.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new Ls(Bs.paint_model["model-front-cutoff"]),"model-color-use-theme":new Os({type:"string",default:"default","property-type":"data-driven"})}))},t,i,r),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(e){return new D_(e)}getProgramIds(){return["model"]}is3D(){return!0}hasShadowPass(){return!0}canCastShadows(){return!0}hasLightBeamPass(){return!0}cutoffRange(){return this.paint.get("model-cutoff-fade-range")}queryRadius(e){return e instanceof Y_?8191:0}queryIntersectsFeature(e,t,i,r,n,o){if(!this.modelManager)return!1;const s=this.modelManager,a=e.tile.getBucket(this);if(!(a&&a instanceof D_))return!1;for(const i in a.instancesPerModel){const r=a.instancesPerModel[i],n=void 0!==t.id?t.id:t.properties&&t.properties.hasOwnProperty("id")?t.properties.id:void 0;if(r.idToFeaturesIndex.hasOwnProperty(n)){const t=r.features[r.idToFeaturesIndex[n]],l=s.getModel(i,this.scope);if(!l)return!1;let c=F.mat4.create();const h=new $l(0,0),u=a.canonical;let d=Number.MAX_VALUE;for(let i=0;i<t.instancedDataCount;++i){const n=16*(t.instancedDataOffset+i),s=r.instancedDataArray.float32,a=[s[n+4],s[n+5],s[n+6]];eg(u,h,s[n],0|s[n+1]),F_(c,l,o,h,t.rotation,t.scale,a,!1,!1,!1),"globe"===o.projection.name&&(c=y_(c,o));const p=F.mat4.multiply([],o.projMatrix,c),f=e.queryGeometry,m=x_(f.isPointQuery()?f.screenBounds:f.screenGeometry,o,p,l.aabb);null!=m&&(d=Math.min(m,d))}return d!==Number.MAX_VALUE&&d}}return!1}_handleOverridablePaintPropertyUpdate(e,t,i){return!(!this.layout||t.isDataDriven()||i.isDataDriven()||"model-color"!==e&&"model-color-mix-intensity"!==e&&"model-rotation"!==e&&"model-scale"!==e&&"model-translation"!==e&&"model-emissive-strength"!==e)}_isPropertyZoomDependent(e){const t=this._transitionablePaint._values[e];return null!=t&&null!=t.value&&null!=t.value.expression&&t.value.expression instanceof Wn}isZoomDependent(){return this._isPropertyZoomDependent("model-scale")||this._isPropertyZoomDependent("model-rotation")||this._isPropertyZoomDependent("model-translation")}},clip:class extends na{constructor(e,t,i,r){super(e,{layout:Pu||(Pu=new Fs({"clip-layer-types":new Ls(Bs.layout_clip["clip-layer-types"]),"clip-layer-scope":new Ls(Bs.layout_clip["clip-layer-scope"])})),paint:zu||(zu=new Fs({}))},t,i,r)}recalculate(e,t){super.recalculate(e,t)}createBucket(e){return new Lu(e)}isTileClipped(){return!0}is3D(){return!0}}};class ig{constructor(e){this._callback=e,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){this._channel=void 0,this._callback=()=>{}}}class rg{constructor(){this.tasks={},this.taskQueue=[],oe(["process"],this),this.invoker=new ig(this.process),this.nextId=0}add(e,t){const i=this.nextId++,r=function({type:e,isSymbolTile:t,zoom:i}){return i=i||0,"message"===e?0:"maybePrepare"!==e||t?"parseTile"!==e||t?"parseTile"===e&&t?300-i:"maybePrepare"===e&&t?400-i:500:200-i:100-i}(t);if(0===r){try{e()}finally{}return null}return this.tasks[i]={fn:e,metadata:t,priority:r,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){try{if(this.taskQueue=this.taskQueue.filter((e=>!!this.tasks[e])),!this.taskQueue.length)return;const e=this.pick();if(null===e)return;const t=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!t)return;t.fn()}finally{}}pick(){let e=null,t=1/0;for(let i=0;i<this.taskQueue.length;i++){const r=this.tasks[this.taskQueue[i]];r.priority<t&&(t=r.priority,e=i)}if(null===e)return null;const i=this.taskQueue[e];return this.taskQueue.splice(e,1),i}remove(){this.invoker.remove()}}class ng{constructor(e,t,i){this.target=e,this.parent=t,this.mapId=i,this.callbacks={},this.cancelCallbacks={},oe(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.scheduler=new rg}send(e,t,i,r,n=!1,o){const s=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(i.metadata=o,this.callbacks[s]=i);const a=new Set;return this.target.postMessage({id:s,type:e,hasCallback:!!i,targetMapId:r,mustQueue:n,sourceMapId:this.mapId,data:so(t,a)},a),{cancel:()=>{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"<cancel>",targetMapId:r,sourceMapId:this.mapId})}}}receive(e){const t=e.data,i=t.id;if(i&&(!t.targetMapId||this.mapId===t.targetMapId))if("<cancel>"===t.type){const e=this.cancelCallbacks[i];delete this.cancelCallbacks[i],e&&e.cancel()}else if(t.mustQueue||me()){const e=this.callbacks[i],r=this.scheduler.add((()=>this.processTask(i,t)),e&&e.metadata||{type:"message"});r&&(this.cancelCallbacks[i]=r)}else this.processTask(i,t)}processTask(e,t){if(delete this.cancelCallbacks[e],"<response>"===t.type){const i=this.callbacks[e];delete this.callbacks[e],i&&(t.error?i(ao(t.error)):i(null,ao(t.data)))}else{const i=new Set,r=t.hasCallback?(t,r)=>{this.target.postMessage({id:e,type:"<response>",sourceMapId:this.mapId,error:t?so(t):null,data:so(r,i)},i)}:()=>{},n=ao(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,n,r);else if(this.parent.getWorkerSource){const e=t.type.split(".");this.parent.getWorkerSource(t.sourceMapId,e[0],n.source,n.scope)[e[1]](n,r)}else r(new Error(`Could not find function ${t.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}var og={workerUrl:"",workerClass:null,workerParams:void 0};const sg="mapboxgl_preloaded_worker_pool";class ag{constructor(){this.active={}}acquire(e,t=ag.workerCount){if(!this.workers)for(this.workers=[];this.workers.length<t;)this.workers.push(null!=og.workerClass?new og.workerClass:new self.Worker(og.workerUrl,og.workerParams));return this.active[e]=!0,this.workers.slice()}release(e){delete this.active[e],this.workers&&0===this.numActive()&&(this.workers.forEach((e=>{e.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[sg]}numActive(){return Object.keys(this.active).length}}ag.workerCount=2;class lg{constructor(e,t,i="Worker",r=ag.workerCount){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=re();const n=this.workerPool.acquire(this.id,r);for(let e=0;e<n.length;e++){const r=new lg.Actor(n[e],t,this.id);r.name=`${i} ${e}`,this.actors.push(r)}this.ready=!1,this.broadcast("checkIfReady",null,(()=>{this.ready=!0}))}broadcast(e,t,i){ee(this.actors,((i,r)=>{i.send(e,t,r)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((e=>{e.remove()})),this.actors=[],this.workerPool.release(this.id)}}let cg,hg;function ug(){return cg||(cg=new ag),cg}lg.Actor=ng;const dg=new St(0,0,0);var pg=(e=>(e[e.PATH_RULE_UNSPECIFIED=0]="PATH_RULE_UNSPECIFIED",e[e.PATH_RULE_NON_ZERO=1]="PATH_RULE_NON_ZERO",e[e.PATH_RULE_EVEN_ODD=2]="PATH_RULE_EVEN_ODD",e))(pg||{}),fg=(e=>(e[e.LINE_CAP_UNSPECIFIED=0]="LINE_CAP_UNSPECIFIED",e[e.LINE_CAP_BUTT=1]="LINE_CAP_BUTT",e[e.LINE_CAP_ROUND=2]="LINE_CAP_ROUND",e[e.LINE_CAP_SQUARE=3]="LINE_CAP_SQUARE",e))(fg||{}),mg=(e=>(e[e.LINE_JOIN_UNSPECIFIED=0]="LINE_JOIN_UNSPECIFIED",e[e.LINE_JOIN_MITER=1]="LINE_JOIN_MITER",e[e.LINE_JOIN_MITER_CLIP=2]="LINE_JOIN_MITER_CLIP",e[e.LINE_JOIN_ROUND=3]="LINE_JOIN_ROUND",e[e.LINE_JOIN_BEVEL=4]="LINE_JOIN_BEVEL",e))(mg||{}),_g=(e=>(e[e.PAINT_ORDER_UNSPECIFIED=0]="PAINT_ORDER_UNSPECIFIED",e[e.PAINT_ORDER_FILL_AND_STROKE=1]="PAINT_ORDER_FILL_AND_STROKE",e[e.PAINT_ORDER_STROKE_AND_FILL=2]="PAINT_ORDER_STROKE_AND_FILL",e))(_g||{}),gg=(e=>(e[e.PATH_COMMAND_UNSPECIFIED=0]="PATH_COMMAND_UNSPECIFIED",e[e.PATH_COMMAND_MOVE=1]="PATH_COMMAND_MOVE",e[e.PATH_COMMAND_LINE=2]="PATH_COMMAND_LINE",e[e.PATH_COMMAND_QUAD=3]="PATH_COMMAND_QUAD",e[e.PATH_COMMAND_CUBIC=4]="PATH_COMMAND_CUBIC",e[e.PATH_COMMAND_CLOSE=5]="PATH_COMMAND_CLOSE",e))(gg||{}),yg=(e=>(e[e.MASK_TYPE_UNSPECIFIED=0]="MASK_TYPE_UNSPECIFIED",e[e.MASK_TYPE_LUMINANCE=1]="MASK_TYPE_LUMINANCE",e[e.MASK_TYPE_ALPHA=2]="MASK_TYPE_ALPHA",e))(yg||{});function xg(e,t,i){1===e&&t.icons.push(function(e,t){return function(e){if(e.usvg_tree.height||(e.usvg_tree.height=e.usvg_tree.width),!e.metadata)return e;const{metadata:t}=e;if(t.content_area){const{content_area:i}=t;null==i.top&&(i.top=i.left),null==i.width&&(i.width=e.usvg_tree.width),null==i.height&&(i.height=i.width)}return t.stretch_x&&t.stretch_x.length&&vg(t,"x"),t.stretch_y&&t.stretch_y.length&&vg(t,"y"),e}(e.readFields(bg,{name:void 0},t))}(i,i.readVarint()+i.pos))}function vg(e,t){const i=[],r=e[`stretch_${t}`];let n=null;for(let e=0;e<r.length;e++)null===n?n=0===i.length?r[0]:i[i.length-1][1]+r[e]:(i.push([n,n+r[e]]),n=null);e[`stretch_${t}_areas`]=i}function bg(e,t,i){1===e?t.name=i.readString():2===e?t.metadata=function(e,t){return e.readFields(wg,{stretch_x:null,stretch_y:null,stretch_x_areas:null,stretch_y_areas:null,variables:[]},t)}(i,i.readVarint()+i.pos):3===e&&(t.usvg_tree=function(e,t){return e.readFields(Mg,{width:20,children:[],linear_gradients:[],radial_gradients:[],clip_paths:[],masks:[]},t)}(i,i.readVarint()+i.pos),t.data="usvg_tree")}function wg(e,t,i){1===e?t.stretch_x=i.readPackedVarint():2===e?t.stretch_y=i.readPackedVarint():3===e?t.content_area=function(e,t){return e.readFields(Tg,{left:0},t)}(i,i.readVarint()+i.pos):4===e&&t.variables.push(function(e,t){return e.readFields(Sg,{name:void 0},t)}(i,i.readVarint()+i.pos))}function Tg(e,t,i){1===e?t.left=i.readVarint():2===e?t.width=i.readVarint():3===e?t.top=i.readVarint():4===e&&(t.height=i.readVarint())}function Sg(e,t,i){1===e?t.name=i.readString():2===e&&(t.rgb_color=Rg(i.readVarint()),t.value="rgb_color")}function Mg(e,t,i){1===e?t.width=t.height=i.readVarint():2===e?t.height=i.readVarint():3===e?t.children.push(Eg(i,i.readVarint()+i.pos)):4===e?t.linear_gradients.push(function(e,t){return e.readFields(Og,{spread_method:1,stops:[],x1:0,y1:0,x2:1,y2:0},t)}(i,i.readVarint()+i.pos)):5===e?t.radial_gradients.push(function(e,t){return e.readFields(Bg,{spread_method:1,stops:[],cx:.5,cy:.5,r:.5,fx:.5,fy:.5,fr:0},t)}(i,i.readVarint()+i.pos)):7===e?t.clip_paths.push(function(e,t){return e.readFields(Ng,{children:[]},t)}(i,i.readVarint()+i.pos)):8===e&&t.masks.push(function(e,t){const i=e.readFields(Vg,{left:0,width:20,mask_type:1,children:[]},t);return null==i.height&&(i.height=i.width),null==i.top&&(i.top=i.left),i}(i,i.readVarint()+i.pos))}function Eg(e,t){return e.readFields(Ag,{},t)}function Ag(e,t,i){1===e?(t.group=function(e,t){return e.readFields(Ig,{opacity:255,children:[]},t)}(i,i.readVarint()+i.pos),t.node="group"):2===e&&(t.path=function(e,t){return e.readFields(zg,{paint_order:1,commands:[],step:1,diffs:[],rule:1},t)}(i,i.readVarint()+i.pos),t.node="path")}function Ig(e,t,i){1===e?t.transform=Cg(i,i.readVarint()+i.pos):2===e?t.opacity=i.readVarint():5===e?t.clip_path_idx=i.readVarint():6===e?t.mask_idx=i.readVarint():7===e&&t.children.push(Eg(i,i.readVarint()+i.pos))}function Cg(e,t){return e.readFields(Pg,{sx:1,ky:0,kx:0,sy:1,tx:0,ty:0},t)}function Pg(e,t,i){1===e?t.sx=i.readFloat():2===e?t.ky=i.readFloat():3===e?t.kx=i.readFloat():4===e?t.sy=i.readFloat():5===e?t.tx=i.readFloat():6===e&&(t.ty=i.readFloat())}function zg(e,t,i){1===e?t.fill=function(e,t){return e.readFields(Dg,{rgb_color:dg,paint:"rgb_color",opacity:255},t)}(i,i.readVarint()+i.pos):2===e?t.stroke=function(e,t){return e.readFields(Lg,{rgb_color:dg,paint:"rgb_color",dasharray:[],dashoffset:0,miterlimit:4,opacity:255,width:1,linecap:1,linejoin:1},t)}(i,i.readVarint()+i.pos):3===e?t.paint_order=i.readVarint():5===e?i.readPackedVarint(t.commands):6===e?t.step=i.readFloat():7===e?i.readPackedSVarint(t.diffs):8===e&&(t.rule=i.readVarint())}function Dg(e,t,i){1===e?(t.rgb_color=Rg(i.readVarint()),t.paint="rgb_color"):2===e?(t.linear_gradient_idx=i.readVarint(),t.paint="linear_gradient_idx"):3===e?(t.radial_gradient_idx=i.readVarint(),t.paint="radial_gradient_idx"):5===e&&(t.opacity=i.readVarint())}function Rg(e){return new St((e>>16&255)/255,(e>>8&255)/255,(255&e)/255,1)}function Lg(e,t,i){1===e?(t.rgb_color=Rg(i.readVarint()),t.paint="rgb_color"):2===e?(t.linear_gradient_idx=i.readVarint(),t.paint="linear_gradient_idx"):3===e?(t.radial_gradient_idx=i.readVarint(),t.paint="radial_gradient_idx"):5===e?i.readPackedFloat(t.dasharray):6===e?t.dashoffset=i.readFloat():7===e?t.miterlimit=i.readFloat():8===e?t.opacity=i.readVarint():9===e?t.width=i.readFloat():10===e?t.linecap=i.readVarint():11===e&&(t.linejoin=i.readVarint())}function Og(e,t,i){1===e?t.transform=Cg(i,i.readVarint()+i.pos):2===e?t.spread_method=i.readVarint():3===e?t.stops.push(kg(i,i.readVarint()+i.pos)):4===e?t.x1=i.readFloat():5===e?t.y1=i.readFloat():6===e?t.x2=i.readFloat():7===e&&(t.y2=i.readFloat())}function kg(e,t){return e.readFields(Fg,{offset:0,opacity:255,rgb_color:dg},t)}function Fg(e,t,i){1===e?t.offset=i.readFloat():2===e?t.opacity=i.readVarint():3===e&&(t.rgb_color=Rg(i.readVarint()))}function Bg(e,t,i){1===e?t.transform=Cg(i,i.readVarint()+i.pos):2===e?t.spread_method=i.readVarint():3===e?t.stops.push(kg(i,i.readVarint()+i.pos)):4===e?t.cx=i.readFloat():5===e?t.cy=i.readFloat():6===e?t.r=i.readFloat():7===e?t.fx=i.readFloat():8===e?t.fy=i.readFloat():9===e&&(t.fr=i.readFloat())}function Ng(e,t,i){1===e?t.transform=Cg(i,i.readVarint()+i.pos):2===e?t.clip_path_idx=i.readVarint():3===e&&t.children.push(Eg(i,i.readVarint()+i.pos))}function Vg(e,t,i){1===e?t.left=t.top=i.readFloat():2===e?t.width=t.height=i.readFloat():3===e?t.top=i.readFloat():4===e?t.height=i.readFloat():5===e?t.mask_type=i.readVarint():6===e?t.mask_idx=i.readVarint():7===e&&t.children.push(Eg(i,i.readVarint()+i.pos))}class Ug{static calculate(e,t){const i=new Map,r=new Map;if(0===Object.keys(e).length)return i;t.forEach((e=>{r.set(e.name,e.rgb_color||new St(0,0,0))}));for(const[t,n]of Object.entries(e))r.has(t)?i.set(r.get(t).toStringPremultipliedAlpha(),n):console.warn(`Ignoring unknown image variable "${t}"`);return i}}function jg(e,t=255,i){const r=t/255,n=e.toStringPremultipliedAlpha(),o=i.has(n)?i.get(n).clone():e.clone();return o.a=r,o.toString()}function Gg(e,t){if(!De()){const i=document.createElement("canvas");return i.width=e,i.height=t,i}return new OffscreenCanvas(e,t)}function qg(e,t){const i=Ug.calculate(t.params,e.metadata?e.metadata.variables:[]),r=e.usvg_tree,n=r.width,o=r.height,s=t.transform?t.transform:new DOMMatrix,a=Math.max(1,Math.round(n*s.a)),l=Math.max(1,Math.round(o*s.d)),c=new DOMMatrix([a/n,0,0,l/o,0,0]),h=Gg(a,l).getContext("2d");return Zg(h,c,r,r,i),h.getImageData(0,0,a,l)}function Zg(e,t,i,r,n){for(const o of r.children)$g(e,t,i,o,n)}function $g(e,t,i,r,n){r.group?(e.save(),function(e,t,i,r,n){const o=null!=r.mask_idx?i.masks[r.mask_idx]:null,s=null!=r.clip_path_idx?i.clip_paths[r.clip_path_idx]:null;if(r.transform&&(t=Qg(r.transform).preMultiplySelf(t)),!function(e,t,i){return 255!==e.opacity||t||i}(r,null!=s,null!=o))return void Zg(e,t,i,r,n);const a=Gg(e.canvas.width,e.canvas.height),l=a.getContext("2d");s&&Kg(l,t,i,s),Zg(l,t,i,r,n),o&&Jg(l,t,i,o,n),e.globalAlpha=r.opacity/255,e.drawImage(a,0,0)}(e,t,i,r.group,n),e.restore()):r.path&&(e.save(),function(e,t,i,r,n){const o=ey(r);e.setTransform(t),r.paint_order===_g.PAINT_ORDER_FILL_AND_STROKE?(Hg(e,i,r,o,n),Wg(e,i,r,o,n)):(Wg(e,i,r,o,n),Hg(e,i,r,o,n))}(e,t,i,r.path,n),e.restore())}function Hg(e,t,i,r,n){const o=i.fill;if(!o)return;const s=o.opacity/255;switch(o.paint){case"rgb_color":e.fillStyle=jg(o.rgb_color,o.opacity,n);break;case"linear_gradient_idx":e.fillStyle=Xg(e,t.linear_gradients[o.linear_gradient_idx],s,n);break;case"radial_gradient_idx":e.fillStyle=Yg(e,t.radial_gradients[o.radial_gradient_idx],s,n)}let a;switch(i.rule){case pg.PATH_RULE_NON_ZERO:a="nonzero";break;case pg.PATH_RULE_EVEN_ODD:a="evenodd"}e.fill(r,a)}function Wg(e,t,i,r,n){const o=i.stroke;if(!o)return;e.lineWidth=o.width,e.miterLimit=o.miterlimit,e.setLineDash(o.dasharray),e.lineDashOffset=o.dashoffset;const s=o.opacity/255;switch(o.paint){case"rgb_color":e.strokeStyle=jg(o.rgb_color,o.opacity,n);break;case"linear_gradient_idx":e.strokeStyle=Xg(e,t.linear_gradients[o.linear_gradient_idx],s,n);break;case"radial_gradient_idx":e.strokeStyle=Yg(e,t.radial_gradients[o.radial_gradient_idx],s,n)}switch(o.linejoin){case mg.LINE_JOIN_MITER_CLIP:case mg.LINE_JOIN_MITER:e.lineJoin="miter";break;case mg.LINE_JOIN_ROUND:e.lineJoin="round";break;case mg.LINE_JOIN_BEVEL:e.lineJoin="bevel"}switch(o.linecap){case fg.LINE_CAP_BUTT:e.lineCap="butt";break;case fg.LINE_CAP_ROUND:e.lineCap="round";break;case fg.LINE_CAP_SQUARE:e.lineCap="square"}e.stroke(r)}function Xg(e,t,i,r){if(1===t.stops.length){const e=t.stops[0];return jg(e.rgb_color,e.opacity*i,r)}const n=Qg(t.transform),{x1:o,y1:s,x2:a,y2:l}=t,c=n.transformPoint(new DOMPoint(o,s)),h=n.transformPoint(new DOMPoint(a,l)),u=e.createLinearGradient(c.x,c.y,h.x,h.y);for(const e of t.stops)u.addColorStop(e.offset,jg(e.rgb_color,e.opacity*i,r));return u}function Yg(e,t,i,r){if(1===t.stops.length){const e=t.stops[0];return jg(e.rgb_color,e.opacity*i,r)}const n=Qg(t.transform),{fx:o,fy:s,cx:a,cy:l}=t,c=n.transformPoint(new DOMPoint(o,s)),h=n.transformPoint(new DOMPoint(a,l)),u=e.createRadialGradient(c.x,c.y,0,h.x,h.y,t.r*((n.a+n.d)/2));for(const e of t.stops)u.addColorStop(e.offset,jg(e.rgb_color,e.opacity*i,r));return u}function Kg(e,t,i,r){const n=Qg(r.transform).preMultiplySelf(t),o=null!=r.clip_path_idx?i.clip_paths[r.clip_path_idx]:null;o&&Kg(e,n,i,o);const s=new Path2D;let a;function l(e,t){if(e.path){const i=e.path;s.addPath(ey(i),t),i.rule===pg.PATH_RULE_EVEN_ODD&&(a="evenodd")}else if(e.group){const i=e.group.transform?Qg(e.group.transform).preMultiplySelf(t):t;for(const t of e.group.children)l(t,i)}}for(const e of r.children)l(e,n);e.clip(s,a)}function Jg(e,t,i,r,n){if(0===r.children.length)return;const o=null!=r.mask_idx?i.masks[r.mask_idx]:null;o&&Jg(e,t,i,o,n);const s=e.canvas.width,a=e.canvas.height,l=Gg(s,a),c=l.getContext("2d"),h=r.width,u=r.height,d=r.left,p=r.top,f=new Path2D,m=new Path2D;m.rect(d,p,h,u),f.addPath(m,t),c.clip(f);for(const e of r.children)$g(c,t,i,e,n);const _=c.getImageData(0,0,s,a),g=_.data;if(r.mask_type===yg.MASK_TYPE_LUMINANCE)for(let e=0;e<g.length;e+=4)g[e+3]=g[e+3]/255*(.2126*g[e]+.7152*g[e+1]+.0722*g[e+2]);c.putImageData(_,0,0),e.globalCompositeOperation="destination-in",e.drawImage(l,0,0)}function Qg(e){return e?new DOMMatrix([e.sx,e.ky,e.kx,e.sy,e.tx,e.ty]):new DOMMatrix}function ey(e){const t=new Path2D,i=e.step;let r=e.diffs[0]*i,n=e.diffs[1]*i;t.moveTo(r,n);for(let o=0,s=2;o<e.commands.length;o++)switch(e.commands[o]){case gg.PATH_COMMAND_MOVE:r+=e.diffs[s++]*i,n+=e.diffs[s++]*i,t.moveTo(r,n);break;case gg.PATH_COMMAND_LINE:r+=e.diffs[s++]*i,n+=e.diffs[s++]*i,t.lineTo(r,n);break;case gg.PATH_COMMAND_QUAD:{const o=r+e.diffs[s++]*i,a=n+e.diffs[s++]*i;r=o+e.diffs[s++]*i,n=a+e.diffs[s++]*i,t.quadraticCurveTo(o,a,r,n);break}case gg.PATH_COMMAND_CUBIC:{const o=r+e.diffs[s++]*i,a=n+e.diffs[s++]*i,l=o+e.diffs[s++]*i,c=a+e.diffs[s++]*i;r=l+e.diffs[s++]*i,n=c+e.diffs[s++]*i,t.bezierCurveTo(o,a,l,c,r,n);break}case gg.PATH_COMMAND_CLOSE:t.closePath()}return t}class ty{constructor(e){this.capacity=e,this.cache=new Map}get(e){if(!this.cache.has(e))return;const t=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,t),t}put(e,t){this.cache.has(e)?this.cache.delete(e):this.cache.size===this.capacity&&this.cache.delete(this.cache.keys().next().value),this.cache.set(e,t)}delete(e){this.cache.delete(e)}}class iy{constructor(){this.cacheMap=new Map,this.cacheDependenciesMap=new Map}static _getImage(e){return new $h(e,e.data)}getFromCache(e,t,i){return this.cacheMap.has(i)||this.cacheMap.set(i,new ty(150)),this.cacheMap.get(i).get(ta(e.serialize(),t))}setInCache(e,t,i,r){this.cacheDependenciesMap.has(r)||this.cacheDependenciesMap.set(r,new Map),this.cacheMap.has(r)||this.cacheMap.set(r,new ty(150));const n=this.cacheDependenciesMap.get(r);n.get(ta(e.id,i))||n.set(ta(e.id,i),new Set);const o=this.cacheMap.get(r),s=e.serialize();n.get(ta(e.id,i)).add(s),o.put(ta(e.serialize(),i),t)}removeImagesFromCacheByIds(e,t,i=""){if(!this.cacheMap.has(i)||!this.cacheDependenciesMap.has(i))return;const r=this.cacheMap.get(i),n=this.cacheDependenciesMap.get(i);for(const i of e)if(n.has(ta(i,t))){for(const e of n.get(ta(i,t)))r.delete(e);n.delete(ta(i,t))}}rasterize(e,t,i,r,n=qg){const o=this.getFromCache(e,i,r);if(o)return o.clone();const s=n(t.icon,e.options),a=iy._getImage(s);return this.setInCache(e,a,i,r),a.clone()}}class ry{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(e,t){const i=this.toIdx(e,t);return{min:this.minimums[i],max:this.maximums[i]}}isLeaf(e,t){return this.leaves[this.toIdx(e,t)]}toIdx(e,t){return t*this.size+e}}function ny(e,t,i,r){let n=0,o=Number.MAX_VALUE;for(let s=0;s<3;s++)if(Math.abs(r[s])<1e-15){if(i[s]<e[s]||i[s]>t[s])return null}else{const a=1/r[s];let l=(e[s]-i[s])*a,c=(t[s]-i[s])*a;if(l>c){const e=l;l=c,c=e}if(l>n&&(n=l),c<o&&(o=c),n>o)return null}return n}function oy(e,t,i,r,n,o,s,a,l,c,h){const u=r-e,d=n-t,p=o-i,f=s-e,m=a-t,_=l-i,g=h[1]*_-h[2]*m,y=h[2]*f-h[0]*_,x=h[0]*m-h[1]*f,v=u*g+d*y+p*x;if(Math.abs(v)<1e-15)return null;const b=1/v,w=c[0]-e,T=c[1]-t,S=c[2]-i,M=(w*g+T*y+S*x)*b;if(M<0||M>1)return null;const E=T*p-S*d,A=S*u-w*p,I=w*d-T*u,C=(h[0]*E+h[1]*A+h[2]*I)*b;return C<0||M+C>1?null:(f*E+m*A+_*I)*b}function sy(e,t,i){return(e-t)/(i-t)}function ay(e,t,i,r,n,o,s,a,l){const c=1<<i,h=o-r,u=s-n,d=(e+1)/c*h+r,p=(t+0)/c*u+n,f=(t+1)/c*u+n;a[0]=(e+0)/c*h+r,a[1]=p,l[0]=d,l[1]=f}class ly{constructor(e){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=e,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1]],!this.dem)return;const t=function(e){const t=Math.ceil(Math.log2(e.dim/8)),i=[];let r=Math.ceil(Math.pow(2,t));const n=1/r,o=(e,t,i,r,n)=>{const o=r?1:0,s=(e+1)*i-o,a=t*i,l=(t+1)*i-o;n[0]=e*i,n[1]=a,n[2]=s,n[3]=l};let s=new ry(r);const a=[];for(let t=0;t<r*r;t++){o(t%r,Math.floor(t/r),n,!1,a);const i=hy(a[0],a[1],e),l=hy(a[2],a[1],e),c=hy(a[2],a[3],e),h=hy(a[0],a[3],e);s.minimums.push(Math.min(i,l,c,h)),s.maximums.push(Math.max(i,l,c,h)),s.leaves.push(1)}for(i.push(s),r/=2;r>=1;r/=2){const e=i[i.length-1];s=new ry(r);for(let t=0;t<r*r;t++){o(t%r,Math.floor(t/r),2,!0,a);const i=e.getElevation(a[0],a[1]),n=e.getElevation(a[2],a[1]),l=e.getElevation(a[2],a[3]),c=e.getElevation(a[0],a[3]),h=e.isLeaf(a[0],a[1]),u=e.isLeaf(a[2],a[1]),d=e.isLeaf(a[2],a[3]),p=e.isLeaf(a[0],a[3]),f=Math.min(i.min,n.min,l.min,c.min),m=Math.max(i.max,n.max,l.max,c.max),_=h&&u&&d&&p;s.maximums.push(m),s.minimums.push(f),s.leaves.push(m-f<=5&&_?1:0)}i.push(s)}return i}(this.dem),i=t.length-1,r=t[i];this._addNode(r.minimums[0],r.maximums[0],r.leaves[0]),this._construct(t,0,0,i,0)}raycastRoot(e,t,i,r,n,o,s=1){return ny([e,t,-100],[i,r,this.maximums[0]*s],n,o)}raycast(e,t,i,r,n,o,s=1){if(!this.nodeCount)return null;const a=this.raycastRoot(e,t,i,r,n,o,s);if(null==a)return null;const l=[],c=[],h=[],u=[],d=[{idx:0,t:a,nodex:0,nodey:0,depth:0}];for(;d.length>0;){const{idx:a,t:p,nodex:f,nodey:m,depth:_}=d.pop();if(this.leaves[a]){ay(f,m,_,e,t,i,r,h,u);const a=1<<_,l=(f+0)/a,c=(f+1)/a,d=(m+0)/a,g=(m+1)/a,y=hy(l,d,this.dem)*s,x=hy(c,d,this.dem)*s,v=hy(c,g,this.dem)*s,b=hy(l,g,this.dem)*s,w=oy(h[0],h[1],y,u[0],h[1],x,u[0],u[1],v,n,o),T=oy(u[0],u[1],v,h[0],u[1],b,h[0],h[1],y,n,o),S=Math.min(null!==w?w:Number.MAX_VALUE,null!==T?T:Number.MAX_VALUE);if(S!==Number.MAX_VALUE)return S;{const e=F.vec3.scaleAndAdd([],n,o,p);if(cy(y,x,b,v,sy(e[0],h[0],u[0]),sy(e[1],h[1],u[1]))>=e[2])return p}continue}let g=0;for(let d=0;d<this._siblingOffset.length;d++){ay((f<<1)+this._siblingOffset[d][0],(m<<1)+this._siblingOffset[d][1],_+1,e,t,i,r,h,u),h[2]=-100,u[2]=this.maximums[this.childOffsets[a]+d]*s;const p=ny(h,u,n,o);if(null!=p){const e=p;l[d]=e;let t=!1;for(let i=0;i<g&&!t;i++)e>=l[c[i]]&&(c.splice(i,0,d),t=!0);t||(c[g]=d),g++}}for(let e=0;e<g;e++){const t=c[e];d.push({idx:this.childOffsets[a]+t,t:l[t],nodex:(f<<1)+this._siblingOffset[t][0],nodey:(m<<1)+this._siblingOffset[t][1],depth:_+1})}}return null}_addNode(e,t,i){return this.minimums.push(e),this.maximums.push(t),this.leaves.push(i),this.childOffsets.push(0),this.nodeCount++}_construct(e,t,i,r,n){if(1===e[r].isLeaf(t,i))return;this.childOffsets[n]||(this.childOffsets[n]=this.nodeCount);const o=r-1,s=e[o];let a=0,l=0;for(let e=0;e<this._siblingOffset.length;e++){const r=2*t+this._siblingOffset[e][0],n=2*i+this._siblingOffset[e][1],o=s.getElevation(r,n),c=s.isLeaf(r,n),h=this._addNode(o.min,o.max,c);c&&(a|=1<<e),l||(l=h)}for(let r=0;r<this._siblingOffset.length;r++)a&1<<r||this._construct(e,2*t+this._siblingOffset[r][0],2*i+this._siblingOffset[r][1],o,l+r)}}function cy(e,t,i,r,n,o){return Et(Et(e,i,o),Et(t,r,o),n)}function hy(e,t,i){const r=i.dim,n=K(e*r-.5,0,r-1),o=K(t*r-.5,0,r-1),s=Math.floor(n),a=Math.floor(o),l=Math.min(s+1,r-1),c=Math.min(a+1,r-1);return cy(i.get(s,a),i.get(l,a),i.get(s,c),i.get(l,c),n-s,o-a)}const uy={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};function dy(e,t,i){return(256*e*256+256*t+i)/10-1e4}function py(e,t,i){return 256*e+t+i/256-32768}class fy{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(e,t,i,r=!1){if(this.uid=e,t.height!==t.width)throw new RangeError("DEM tiles must be square");if(i&&"mapbox"!==i&&"terrarium"!==i)return void ue(`"${i}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=t.height;const n=this.dim=t.height-2,o=new Uint32Array(t.data.buffer);if(this.pixels=new Uint8Array(t.data.buffer),this.floatView=new Float32Array(t.data.buffer),this.borderReady=r,this._modifiedForSources={},!r){for(let e=0;e<n;e++)o[this._idx(-1,e)]=o[this._idx(0,e)],o[this._idx(n,e)]=o[this._idx(n-1,e)],o[this._idx(e,-1)]=o[this._idx(e,0)],o[this._idx(e,n)]=o[this._idx(e,n-1)];o[this._idx(-1,-1)]=o[this._idx(0,0)],o[this._idx(n,-1)]=o[this._idx(n-1,0)],o[this._idx(-1,n)]=o[this._idx(0,n-1)],o[this._idx(n,n)]=o[this._idx(n-1,n-1)]}const s="terrarium"===i?py:dy;for(let e=0;e<o.length;++e){const t=4*e;this.floatView[e]=s(this.pixels[t],this.pixels[t+1],this.pixels[t+2])}this._timestamp=Re.now()}_buildQuadTree(){this._tree=new ly(this)}get(e,t,i=!1){i&&(e=K(e,-1,this.dim),t=K(t,-1,this.dim));const r=this._idx(e,t);return this.floatView[r]}set(e,t,i){const r=this._idx(e,t),n=this.floatView[r];return this.floatView[r]=i,i-n}static getUnpackVector(e){return uy[e]}_idx(e,t){if(e<-1||e>=this.dim+1||t<-1||t>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(t+1)*this.stride+(e+1)}static pack(e,t){const i=[0,0,0,0],r=fy.getUnpackVector(t);let n=Math.floor((e+r[3])/r[2]);return i[2]=n%256,n=Math.floor(n/256),i[1]=n%256,n=Math.floor(n/256),i[0]=n,i}getPixels(){return new Hh({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,t,i){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let r=t*this.dim,n=t*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(t){case-1:r=n-1;break;case 1:n=r+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-t*this.dim,l=-i*this.dim;for(let t=o;t<s;t++)for(let i=r;i<n;i++){const r=4*this._idx(i,t),n=4*this._idx(i+a,t+l);this.pixels[r+0]=e.pixels[n+0],this.pixels[r+1]=e.pixels[n+1],this.pixels[r+2]=e.pixels[n+2],this.pixels[r+3]=e.pixels[n+3]}}onDeserialize(){this._tree&&(this._tree.dem=this)}}function my(e,t,i){1===e?t.headerLength=i.readFixed32():2===e?t.x=i.readVarint():3===e?t.y=i.readVarint():4===e?t.z=i.readVarint():5===e&&t.layers.push(function(e,t){return e.readFields(vy,{version:0,name:"",units:"",tileSize:0,buffer:0,pixelFormat:0,dataIndex:[]},t)}(i,i.readVarint()+i.pos))}function _y(e,t,i){1===e?(t.delta_filter=function(e,t){return e.readFields(gy,{blockSize:0},t)}(i,i.readVarint()+i.pos),t.filter="delta_filter"):2===e?(i.readVarint(),t.filter="zigzag_filter"):3===e?(i.readVarint(),t.filter="bitshuffle_filter"):4===e&&(i.readVarint(),t.filter="byteshuffle_filter")}function gy(e,t,i){1===e&&(t.blockSize=i.readVarint())}function yy(e,t,i){1===e?(i.readVarint(),t.codec="gzip_data"):2===e?(i.readVarint(),t.codec="jpeg_image"):3===e?(i.readVarint(),t.codec="webp_image"):4===e&&(i.readVarint(),t.codec="png_image")}function xy(e,t,i){let r=0,n=0;1===e?t.firstByte=i.readFixed64():2===e?t.lastByte=i.readFixed64():3===e?t.filters.push(function(e,t){return e.readFields(_y,{},t)}(i,i.readVarint()+i.pos)):4===e?t.codec=function(e,t){return e.readFields(yy,{},t)}(i,i.readVarint()+i.pos):5===e?n=i.readFloat():6===e?r=i.readFloat():7===e?t.bands.push(i.readString()):8===e?t.offset=i.readDouble():9===e&&(t.scale=i.readDouble()),0===t.offset&&(t.offset=n),0===t.scale&&(t.scale=r)}function vy(e,t,i){1===e?t.version=i.readVarint():2===e?t.name=i.readString():3===e?t.units=i.readString():4===e?t.tileSize=i.readVarint():5===e?t.buffer=i.readVarint():6===e?t.pixelFormat=i.readVarint():7===e&&t.dataIndex.push(function(e,t){return e.readFields(xy,{firstByte:0,lastByte:0,filters:[],codec:null,offset:0,scale:0,bands:[]},t)}(i,i.readVarint()+i.pos))}function by(e,t,i){if(2===e)!function(e,t,i){e.readFields(wy,i,t)}(i,i.readVarint()+i.pos,t);else if(3===e)throw new Error("Not implemented")}function wy(e,t,i){if(1===e){let e=0;const r=i.readVarint()+i.pos;for(;i.pos<r;)t[e++]=i.readVarint()}}function Ty(e,t){if(4!==t.length)throw new Error(`Expected data of dimension 4 but got ${t.length}.`);let i=t[3];for(let r=2;r>=1;r--){const n=1===r?1:0,o=2===r?1:0;for(let r=0;r<t[0];r++){const s=t[1]*r;for(let r=n;r<t[1];r++){const n=t[2]*(r+s);for(let r=o;r<t[2];r++){const o=t[3]*(r+n);for(let r=0;r<t[3];r++){const t=o+r;e[t]+=e[t-i]}}}}i*=t[r]}return e}function Sy(e){for(let t=0,i=e.length;t<i;t++)e[t]=e[t]>>>1^-(1&e[t]);return e}function My(e,t){switch(t){case"uint32":return e;case"uint16":for(let t=0;t<e.length;t+=2){const i=e[t],r=e[t+1];e[t]=(240&i)>>4|(61440&i)>>8|(240&r)<<4|61440&r,e[t+1]=15&i|(3840&i)>>4|(15&r)<<8|(3840&r)<<4}return e;case"uint8":for(let t=0;t<e.length;t+=4){const i=e[t],r=e[t+1],n=e[t+2],o=e[t+3];e[t+0]=(192&i)>>6|(192&r)>>4|(192&n)>>2|192&o,e[t+1]=(48&i)>>4|(48&r)>>2|48&n|(48&o)<<2,e[t+2]=(12&i)>>2|12&r|(12&n)<<2|(12&o)<<4,e[t+3]=3&i|(3&r)<<2|(3&n)<<4|(3&o)<<6}return e;default:throw new Error(`Invalid pixel format, "${t}"`)}}ro(fy,"DEMData"),ro(ly,"DemMinMaxQuadTree",{omit:["dem"]});var Ey=Uint8Array,Ay=Uint16Array,Iy=Int32Array,Cy=new Ey([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]),Py=new Ey([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]),zy=new Ey([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Dy=function(e,t){for(var i=new Ay(31),r=0;r<31;++r)i[r]=t+=1<<e[r-1];var n=new Iy(i[30]);for(r=1;r<30;++r)for(var o=i[r];o<i[r+1];++o)n[o]=o-i[r]<<5|r;return{b:i,r:n}},Ry=Dy(Cy,2),Ly=Ry.b,Oy=Ry.r;Ly[28]=258,Oy[258]=28;for(var ky=Dy(Py,0).b,Fy=new Ay(32768),By=0;By<32768;++By){var Ny=(43690&By)>>1|(21845&By)<<1;Fy[By]=((65280&(Ny=(61680&(Ny=(52428&Ny)>>2|(13107&Ny)<<2))>>4|(3855&Ny)<<4))>>8|(255&Ny)<<8)>>1}var Vy=function(e,t,i){for(var r=e.length,n=0,o=new Ay(t);n<r;++n)e[n]&&++o[e[n]-1];var s,a=new Ay(t);for(n=1;n<t;++n)a[n]=a[n-1]+o[n-1]<<1;s=new Ay(1<<t);var l=15-t;for(n=0;n<r;++n)if(e[n])for(var c=n<<4|e[n],h=t-e[n],u=a[e[n]-1]++<<h,d=u|(1<<h)-1;u<=d;++u)s[Fy[u]>>l]=c;return s},Uy=new Ey(288);for(By=0;By<144;++By)Uy[By]=8;for(By=144;By<256;++By)Uy[By]=9;for(By=256;By<280;++By)Uy[By]=7;for(By=280;By<288;++By)Uy[By]=8;var jy=new Ey(32);for(By=0;By<32;++By)jy[By]=5;var Gy=Vy(Uy,9),qy=Vy(jy,5),Zy=function(e){for(var t=e[0],i=1;i<e.length;++i)e[i]>t&&(t=e[i]);return t},$y=function(e,t,i){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&i},Hy=function(e,t){var i=t/8|0;return(e[i]|e[i+1]<<8|e[i+2]<<16)>>(7&t)},Wy=["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"],Xy=function(e,t,i){var r=new Error(t||Wy[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Xy),!i)throw r;return r},Yy=new Ey(0),Ky="undefined"!=typeof TextDecoder&&new TextDecoder;try{Ky.decode(Yy,{stream:!0})}catch(e){}const Jy={gzip_data:"gzip"};class Qy extends Error{constructor(e){super(e),this.name="MRTError"}}const ex={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},tx={uint32:1,uint16:2,uint8:4},ix={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let rx;class nx{constructor(e=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=e}getLayer(e){const t=this.layers[e];if(!t)throw new Qy(`Layer '${e}' not found`);return t}getHeaderLength(e){const t=new Uint8Array(e),i=new DataView(e);if(13!==t[0])throw new Qy("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(e){const t=new Uint8Array(e),i=this.getHeaderLength(e);if(t.length<i)throw new Qy(`Expected header with length >= ${i} but got buffer of length ${t.length}`);const r=function(e){return e.readFields(my,{headerLength:0,x:0,y:0,z:0,layers:[]},void 0)}(new rx(t.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==r.x||this.y!==r.y||this.z!==r.z))throw new Qy(`Invalid attempt to parse header ${r.z}/${r.x}/${r.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=r.x,this.y=r.y,this.z=r.z;for(const e of r.layers)this.layers[e.name]=new ox(e,{cacheSize:this._cacheSize});return this}createDecodingTask(e){const t=[],i=this.getLayer(e.layerName);for(let r of e.blockIndices){const n=i.dataIndex[r],o=n.firstByte-e.firstByte,s=n.lastByte-e.firstByte;if(i._blocksInProgress.has(r))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:r,blockShape:[n.bands.length].concat(i.bandShape),buffer:i.buffer,codec:n.codec.codec,filters:n.filters.map((e=>e.filter))};i._blocksInProgress.add(r),t.push(a)}return new sx(t,(()=>{t.forEach((e=>i._blocksInProgress.delete(e.blockIndex)))}),((e,r)=>{if(t.forEach((e=>i._blocksInProgress.delete(e.blockIndex))),e)throw e;r.forEach((e=>{this.getLayer(e.layerName).processDecodedData(e)}))}))}}class ox{constructor({version:e,name:t,units:i,tileSize:r,pixelFormat:n,buffer:o,dataIndex:s},a){if(this.version=e,1!==this.version)throw new Qy(`Cannot parse raster layer encoded with MRT version ${e}`);this.name=t,this.units=i,this.tileSize=r,this.buffer=o,this.pixelFormat=ex[n],this.dataIndex=s,this.bandShape=[r+2*o,r+2*o,tx[this.pixelFormat]],this._decodedBlocks=new ty(a?a.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return tx[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map((({bands:e})=>e)).flat()}processDecodedData(e){const t=e.blockIndex.toString();this._decodedBlocks.get(t)||this._decodedBlocks.put(t,e.data)}getBlockForBand(e){let t=0;switch(typeof e){case"string":for(const[i,r]of this.dataIndex.entries()){for(const[n,o]of r.bands.entries())if(o===e)return{bandIndex:t+n,blockIndex:i,blockBandIndex:n};t+=r.bands.length}break;case"number":for(const[i,r]of this.dataIndex.entries()){if(e>=t&&e<t+r.bands.length)return{bandIndex:e,blockIndex:i,blockBandIndex:e-t};t+=r.bands.length}break;default:throw new Qy(`Invalid band \`${JSON.stringify(e)}\`. Expected string or integer.`)}throw new Qy(`Band not found: ${JSON.stringify(e)}`)}getDataRange(e){let t=1/0,i=-1/0;const r=[],n=new Set;for(const o of e){const{blockIndex:e}=this.getBlockForBand(o);if(e<0)throw new Qy(`Invalid band: ${JSON.stringify(o)}`);const s=this.dataIndex[e];r.includes(e)||r.push(e),n.add(e),t=Math.min(t,s.firstByte),i=Math.max(i,s.lastByte)}if(n.size>this.cacheSize)throw new Qy(`Number of blocks to decode (${n.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:t,lastByte:i,blockIndices:r}}hasBand(e){const{blockIndex:t}=this.getBlockForBand(e);return t>=0}hasDataForBand(e){const{blockIndex:t}=this.getBlockForBand(e);return t>=0&&!!this._decodedBlocks.get(t.toString())}getBandView(e){const{blockIndex:t,blockBandIndex:i}=this.getBlockForBand(e),r=this._decodedBlocks.get(t.toString());if(!r)throw new Qy(`Data for band ${JSON.stringify(e)} of layer "${this.name}" not decoded.`);const n=this.dataIndex[t],o=this.bandShape.reduce(((e,t)=>e*t),1),s=i*o,a=r.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:n.offset,scale:n.scale}}}nx.setPbf=function(e){rx=e};class sx{constructor(e,t,i){this.tasks=e,this._onCancel=t,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(e,t){this._finalized||(this._onComplete(e,t),this._finalized=!0)}}nx.performDecoding=function(e,t){const i=new Uint8Array(e);return Promise.all(t.tasks.map((e=>{const{layerName:t,firstByte:r,lastByte:n,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=e,h=i.subarray(r,n+1),u=new Uint32Array(s[0]*s[1]*s[2]);let d;if("gzip_data"!==c)throw new Qy(`Unhandled codec: ${c}`);return d=function(e,t){if(!globalThis.DecompressionStream&&"gzip_data"===t)return Promise.resolve(((o=function(e){31==e[0]&&139==e[1]&&8==e[2]||Xy(6,"invalid gzip data");var t=e[3],i=10;4&t&&(i+=2+(e[10]|e[11]<<8));for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!e[i++]);return i+(2&t)}(n=e))+8>n.length&&Xy(6,"invalid gzip data"),function(e,t,i){var r=e.length;if(!r||t.f&&!t.l)return i||new Ey(0);var n=!i,o=n||2!=t.i,s=t.i;n&&(i=new Ey(3*r));var a,l,c=function(e){var t=i.length;if(e>t){var r=new Ey(Math.max(2*t,e));r.set(i),i=r}},h=t.f||0,u=t.p||0,d=t.b||0,p=t.l,f=t.d,m=t.m,_=t.n,g=8*r;do{if(!p){h=$y(e,u,1);var y=$y(e,u+1,3);if(u+=3,!y){var x=e[(P=4+((u+7)/8|0))-4]|e[P-3]<<8,v=P+x;if(v>r){s&&Xy(0);break}o&&c(d+x),i.set(e.subarray(P,v),d),t.b=d+=x,t.p=u=8*v,t.f=h;continue}if(1==y)p=Gy,f=qy,m=9,_=5;else if(2==y){var b=$y(e,u,31)+257,w=$y(e,u+10,15)+4,T=b+$y(e,u+5,31)+1;u+=14;for(var S=new Ey(T),M=new Ey(19),E=0;E<w;++E)M[zy[E]]=$y(e,u+3*E,7);u+=3*w;var A=Zy(M),I=(1<<A)-1,C=Vy(M,A);for(E=0;E<T;){var P,z=C[$y(e,u,I)];if(u+=15&z,(P=z>>4)<16)S[E++]=P;else{var D=0,R=0;for(16==P?(R=3+$y(e,u,3),u+=2,D=S[E-1]):17==P?(R=3+$y(e,u,7),u+=3):18==P&&(R=11+$y(e,u,127),u+=7);R--;)S[E++]=D}}var L=S.subarray(0,b),O=S.subarray(b);m=Zy(L),_=Zy(O),p=Vy(L,m),f=Vy(O,_)}else Xy(1);if(u>g){s&&Xy(0);break}}o&&c(d+131072);for(var k=(1<<m)-1,F=(1<<_)-1,B=u;;B=u){var N=(D=p[Hy(e,u)&k])>>4;if((u+=15&D)>g){s&&Xy(0);break}if(D||Xy(2),N<256)i[d++]=N;else{if(256==N){B=u,p=null;break}var V=N-254;N>264&&(V=$y(e,u,(1<<(G=Cy[E=N-257]))-1)+Ly[E],u+=G);var U=f[Hy(e,u)&F],j=U>>4;if(U||Xy(3),u+=15&U,O=ky[j],j>3){var G=Py[j];O+=Hy(e,u)&(1<<G)-1,u+=G}if(u>g){s&&Xy(0);break}o&&c(d+131072);var q=d+V;if(d<O){var Z=0-O,$=Math.min(O,q);for(Z+d<0&&Xy(3);d<$;++d)i[d]=(void 0)[Z+d]}for(;d<q;++d)i[d]=i[d-O]}}t.l=p,t.p=B,t.b=d,t.f=h,p&&(h=1,t.m=m,t.d=f,t.n=_)}while(!h);return d!=i.length&&n?(a=i,(null==(l=d)||l>a.length)&&(l=a.length),new Ey(a.subarray(0,l))):i.subarray(0,d)}(n.subarray(o,-8),{i:2},new Ey(((i=n)[(r=i.length)-4]|i[r-3]<<8|i[r-2]<<16|i[r-1]<<24)>>>0))));var i,r,n,o;const s=Jy[t];if(!s)throw new Error(`Unhandled codec: ${t}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([e]).stream().pipeThrough(a)).arrayBuffer().then((e=>new Uint8Array(e)))}(h,c).then((e=>(function(e,t){e.readFields(by,t)}(new rx(e),u),new(0,ix[o])(u.buffer)))),d.then((e=>{for(let t=l.length-1;t>=0;t--)switch(l[t]){case"delta_filter":Ty(e,s);break;case"zigzag_filter":Sy(e);break;case"bitshuffle_filter":My(e,o);break;default:throw new Qy(`Unhandled filter "${l[t]}"`)}return{layerName:t,blockIndex:a,data:e}})).catch((e=>{throw e}))})))},ro(sx,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]});let ax,lx,cx,hx,ux,dx=null;function px(){return me()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:lx||Te.DRACO_URL}function fx(){if(me()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(hx)return hx;const e=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return hx=WebAssembly.validate(e)?Te.MESHOPT_SIMD_URL:Te.MESHOPT_URL,hx}const mx={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},_x={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},gx={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function yx(e,t,i){const r=i.json.bufferViews.length,n=i.buffers.length;t.bufferView=r,i.json.bufferViews[r]={buffer:n,byteLength:e.byteLength},i.buffers[n]=e}const xx="KHR_draco_mesh_compression";function vx(e,t){const i=e.extensions&&e.extensions[xx];if(!i)return;const r=new cx.Decoder,n=Ax(t,i.bufferView),o=new cx.Mesh;if(!r.DecodeArrayToMesh(n,n.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=t.json.accessors[e.indices],a=mx[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=cx._malloc(l);a===Uint16Array?r.GetTrianglesUInt16Array(o,l,c):r.GetTrianglesUInt32Array(o,l,c),yx(cx.memory.buffer.slice(c,c+l),s,t),cx._free(c);for(const n of Object.keys(i.attributes)){const s=r.GetAttributeByUniqueId(o,i.attributes[n]),a=t.json.accessors[e.attributes[n]],l=_x[a.componentType],c=a.count*gx[a.type]*mx[a.componentType].BYTES_PER_ELEMENT,h=cx._malloc(c);r.GetAttributeDataArrayForAllPoints(o,s,cx[l],c,h),yx(cx.memory.buffer.slice(h,h+c),a,t),cx._free(h)}r.destroy(),o.destroy(),delete e.extensions[xx]}const bx="EXT_meshopt_compression";function wx(e,t){if(!e.extensions||!e.extensions[bx])return;const i=e.extensions[bx],r=new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),n=new Uint8Array(i.count*i.byteStride);ux.decodeGltfBuffer(n,i.count,i.byteStride,r,i.mode,i.filter),e.buffer=t.buffers.length,e.byteOffset=0,t.buffers[e.buffer]=n.buffer,delete e.extensions[bx]}const Tx=1179937895,Sx=new TextDecoder("utf8");function Mx(e,t){return new URL(e,t).href}function Ex(e,t,i,r){return fetch(Mx(e.uri,r)).then((e=>e.arrayBuffer())).then((e=>{t.buffers[i]=e}))}function Ax(e,t){const i=e.json.bufferViews[t];return new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function Ix(e,t,i,r){if(e.uri){const n=Mx(e.uri,r);return fetch(n).then((e=>e.blob())).then((e=>createImageBitmap(e))).then((e=>{t.images[i]=e}))}if(void 0!==e.bufferView){const r=Ax(t,e.bufferView),n=new Blob([r],{type:e.mimeType});return createImageBitmap(n).then((e=>{t.images[i]=e}))}}function Cx(e,t=0,i){const r={json:null,images:[],buffers:[]};if(new Uint32Array(e,t,1)[0]===Tx){const i=new Uint32Array(e,t);let n=2;const o=(i[n++]>>2)-3,s=i[n++]>>2;if(n++,r.json=JSON.parse(Sx.decode(i.subarray(n,n+s))),n+=s,n<o){const o=i[n++];n++;const s=t+(n<<2);r.buffers[0]=e.slice(s,s+o)}}else r.json=JSON.parse(Sx.decode(new Uint8Array(e,t)));const{buffers:n,images:o,meshes:s,extensionsUsed:a,bufferViews:l}=r.json;let c=Promise.resolve();if(n){const e=[];for(let t=0;t<n.length;t++){const o=n[t];o.uri?e.push(Ex(o,r,t,i)):r.buffers[t]||(r.buffers[t]=null)}c=Promise.all(e)}return c.then((()=>{const e=[],t=a&&a.includes(xx),n=a&&a.includes(bx);if(t&&e.push(function(){if(!cx)return null!=ax?ax:(ax=function(e){let t,i=null;function r(){t=new Uint8Array(i.buffer)}function n(){throw new Error("Unexpected Draco error.")}const o={a:{a:n,d:function(e,i,r){return t.copyWithin(e,i,i+r)},c:function(e){const n=t.length,o=Math.max(e>>>0,Math.ceil(1.2*n)),s=Math.ceil((o-n)/65536);try{return i.grow(s),r(),!0}catch(e){return!1}},b:n}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,o):e.then((e=>e.arrayBuffer())).then((e=>WebAssembly.instantiate(e,o)))).then((e=>{const{Rb:n,Qb:o,P:s,T:a,X:l,Ja:c,La:h,Qa:u,Va:d,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:x,Ab:v,Bb:b,Db:w,Gb:T}=e.instance.exports;i=g;const S=(()=>{let e=0,i=0,r=0,s=0;return a=>{r&&(n(s),n(e),i+=r,r=e=0),e||(i+=128,e=o(i));const l=a.length+7&-8;let c=e;l>=i&&(r=l,c=s=o(l));for(let e=0;e<a.length;e++)t[c+e]=a[e];return c}})();return r(),_(),{memory:g,_free:n,_malloc:o,Mesh:class{constructor(){this.ptr=s()}destroy(){a(this.ptr)}},Decoder:class{constructor(){this.ptr=c()}destroy(){m(this.ptr)}DecodeArrayToMesh(e,t,i){const r=S(e),n=h(this.ptr,r,t,i.ptr);return!!l(n)}GetAttributeByUniqueId(e,t){return{ptr:u(this.ptr,e.ptr,t)}}GetTrianglesUInt16Array(e,t,i){d(this.ptr,e.ptr,t,i)}GetTrianglesUInt32Array(e,t,i){p(this.ptr,e.ptr,t,i)}GetAttributeDataArrayForAllPoints(e,t,i,r,n){f(this.ptr,e.ptr,t.ptr,i,r,n)}},DT_INT8:y(),DT_UINT8:x(),DT_INT16:v(),DT_UINT16:b(),DT_UINT32:w(),DT_FLOAT32:T()}}))}(fetch(px())),ax.then((e=>{cx=e,ax=void 0})))}()),n&&e.push(function(){if(ux)return;const e=function(e){let t;const i=WebAssembly.instantiateStreaming(e,{}).then((e=>{t=e.instance,t.exports.__wasm_call_ctors()})),r={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},n={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(e,i,o,s,a,l){!function(e,t,i,r,n,o,s){const a=e.exports.sbrk,l=r+3&-4,c=a(l*n),h=a(o.length),u=new Uint8Array(e.exports.memory.buffer);u.set(o,h);const d=t(c,r,n,h,o.length);if(0===d&&s&&s(c,l,n),i.set(u.subarray(c,c+r*n)),a(c-a(0)),0!==d)throw new Error(`Malformed buffer data: ${d}`)}(t,t.exports[n[a]],e,i,o,s,t.exports[r[l]])}}}(fetch(fx()));return e.ready.then((()=>{ux=e}))}()),o)for(let t=0;t<o.length;t++)e.push(Ix(o[t],r,t,i));return(e.length?Promise.all(e):Promise.resolve()).then((()=>{if(t&&s)for(const{primitives:e}of s)for(const t of e)vx(t,r);if(n&&s&&l)for(const e of l)wx(e,r);return r}))}))}function Px(e,t){const i=e.json.bufferViews[t.bufferView],r=mx[t.componentType];return new r(e.buffers[i.buffer],(t.byteOffset||0)+(i.byteOffset||0),t.count*(i.byteStride&&i.byteStride!==gx[t.type]*r.BYTES_PER_ELEMENT?i.byteStride/r.BYTES_PER_ELEMENT:gx[t.type]))}function zx(e,t,i,r){const n=mx[t.componentType],o=function(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(n),s=e.json.bufferViews[t.bufferView],a=s.byteStride?s.byteStride/n.BYTES_PER_ELEMENT:gx[t.type],l=i.float32,c=l.length/i.capacity;for(let e=0,i=0;e<t.count*a;e+=a,i+=c)for(let t=0;t<c;t++)l[i+t]=r[e+t]*o;i._trim()}function Dx(e,t,i){const r=e.indices,n=e.attributes,o={};o.indexArray=new Ia;const s=t.json.accessors[r],a=s.count/3;o.indexArray.reserve(a);const l=Px(t,s);for(let e=0;e<a;e++)o.indexArray.emplaceBack(l[3*e],l[3*e+1],l[3*e+2]);o.indexArray._trim(),o.vertexArray=new _a;const c=t.json.accessors[n.POSITION];o.vertexArray.reserve(c.count);const h=Px(t,c);for(let e=0;e<c.count;e++)o.vertexArray.emplaceBack(h[3*e],h[3*e+1],h[3*e+2]);if(o.vertexArray._trim(),o.aabb=new nh(c.min,c.max),o.centroid=function(e,t){const i=[0,0,0],r=e.length;if(r>0){for(let n=0;n<r;n++){const r=3*e[n];i[0]+=t[r],i[1]+=t[r+1],i[2]+=t[r+2]}i[0]/=r,i[1]/=r,i[2]/=r}return i}(l,h),void 0!==n.COLOR_0){const e=t.json.accessors[n.COLOR_0],i=gx[e.type],r=Px(t,e);o.colorArray=3===i?new _a:new ma,o.colorArray.resize(e.count),zx(t,e,o.colorArray,r)}if(void 0!==n.NORMAL){o.normalArray=new _a;const e=t.json.accessors[n.NORMAL];o.normalArray.resize(e.count);const i=Px(t,e);zx(t,e,o.normalArray,i)}if(void 0!==n.TEXCOORD_0&&i.length>0){o.texcoordArray=new ka;const e=t.json.accessors[n.TEXCOORD_0];o.texcoordArray.resize(e.count);const i=Px(t,e);zx(t,e,o.texcoordArray,i)}if(void 0!==n._FEATURE_ID_RGBA4444){const e=t.json.accessors[n._FEATURE_ID_RGBA4444];t.json.extensionsUsed&&t.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=Px(t,e))}void 0!==n._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(Px(t,t.json.accessors[n._FEATURE_RGBA4444]).buffer));const u=e.material;return o.material=function(e,t){const{emissiveFactor:i=[0,0,0],alphaMode:r="OPAQUE",alphaCutoff:n=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=e,{baseColorFactor:c=[1,1,1,1],metallicFactor:h=1,roughnessFactor:u=1,baseColorTexture:d,metallicRoughnessTexture:p}=e.pbrMetallicRoughness||{},f=s?t[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const e=s.extensions.KHR_texture_transform;f.offsetScale=[e.offset[0],e.offset[1],e.scale[0],e.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new St(...c),metallicFactor:h,roughnessFactor:u,baseColorTexture:d?t[d.index]:void 0,metallicRoughnessTexture:p?t[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:r,alphaCutoff:n,normalTexture:o?t[o.index]:void 0,occlusionTexture:f,emissionTexture:a?t[a.index]:void 0,defined:void 0===e.defined}}(void 0!==u?t.json.materials[u]:{defined:!1},i),o}function Rx(e,t,i){const{matrix:r,rotation:n,translation:o,scale:s,mesh:a,extras:l,children:c}=e,h={};if(h.matrix=r||F.mat4.fromRotationTranslationScale([],n||[0,0,0,1],o||[0,0,0],s||[1,1,1]),void 0!==a){h.meshes=i[a];const e=h.anchor=[0,0];for(const t of h.meshes){const{min:i,max:r}=t.aabb;e[0]+=i[0]+r[0],e[1]+=i[1]+r[1]}e[0]=Math.floor(e[0]/h.meshes.length/2),e[1]=Math.floor(e[1]/h.meshes.length/2)}if(l&&(l.id&&(h.id=l.id),l.lights&&(h.lights=function(e){if(!e.length)return[];const t=function(e){const t=atob(e),i=new Uint8Array(t.length);for(let e=0;e<t.length;e++)i[e]=t.codePointAt(e);return i}(e),i=[],r=t.length/24,n=new Uint16Array(t.buffer),o=new Float32Array(t.buffer);for(let e=0;e<r;e++){const t=n[2*e*6]/30,r=n[2*e*6+1]/30,s=n[2*e*6+10]/100,a=o[6*e+1],l=o[6*e+2],c=o[6*e+3],h=o[6*e+4],u=c-a,d=h-l,p=Math.hypot(u,d);i.push({pos:[a+.5*u,l+.5*d,r],normal:[d/p,-u/p,0],width:p,height:t,depth:s,points:[a,l,c,h]})}return i}(l.lights))),c){const e=[];for(const r of c)e.push(Rx(t.json.nodes[r],t,i));h.children=e}return h}function Lx(e){if(0===e.vertices.length||0===e.indices.length)return null;const t=new Du(e.vertices,e.indices,8,256),[i,r]=[t.min.clone(),t.max.clone()];return{vertices:e.vertices,indices:e.indices,grid:t,min:i,max:r}}function Ox(e){if(!e.extras||!e.extras.ground)return null;const t=e.extras.ground;if(!t||!Array.isArray(t)||0===t.length)return null;const i=t[0];if(!i||!Array.isArray(i)||0===i.length)return null;const r=[];for(const e of i){if(!Array.isArray(e)||2!==e.length)continue;const t=e[0],i=e[1];"number"==typeof t&&"number"==typeof i&&r.push(new U(t,i))}if(r.length<3)return null;r.length>1&&r[r.length-1].equals(r[0])&&r.pop();let n=0;for(let e=0;e<r.length;e++){const t=r[e],i=r[(e+1)%r.length],o=r[(e+2)%r.length];n+=(t.x-i.x)*(o.y-i.y)-(o.x-i.x)*(t.y-i.y)}n>0&&r.reverse();const o=Kh(r.flatMap((e=>[e.x,e.y])),[]);return 0===o.length?null:{vertices:r,indices:o}}function kx(e,t){const i=[],r=[];let n=0;const o=[];for(const s of e){n=i.length;const e=s.vertexArray.float32,a=s.indexArray.uint16;for(let r=0;r<s.vertexArray.length;r++)o[0]=e[3*r+0],o[1]=e[3*r+1],o[2]=e[3*r+2],F.vec3.transformMat4(o,o,t),i.push(new U(o[0],o[1]));for(let e=0;e<3*s.indexArray.length;e++)r.push(a[e]+n)}if(r.length%3!=0)return null;for(let e=0;e<r.length;e+=3){const t=i[r[e+0]],n=i[r[e+1]],o=i[r[e+2]];(t.x-n.x)*(o.y-n.y)-(o.x-n.x)*(t.y-n.y)>0&&([r[e+1],r[e+2]]=[r[e+2],r[e+1]])}return{vertices:i,indices:r}}function Fx(e){const t=function(e,t){const i=[],r=WebGL2RenderingContext;if(e.json.textures)for(const n of e.json.textures){const o={magFilter:r.LINEAR,minFilter:r.NEAREST,wrapS:r.REPEAT,wrapT:r.REPEAT};void 0!==n.sampler&&Object.assign(o,e.json.samplers[n.sampler]),i.push({image:t[n.source],sampler:o,uploaded:!1})}return i}(e,e.images),i=function(e,t){const i=[];for(const r of e.json.meshes){const n=[];for(const i of r.primitives)n.push(Dx(i,e,t));i.push(n)}return i}(e,t),{scenes:r,scene:n,nodes:o}=e.json,s=r?r[n||0].nodes:o,a=[];for(const t of s)a.push(Rx(o[t],e,i));return function(e,t,i){const r={},n=new Set;for(let o=0;o<e.length;o++){const e=i[t[o]];if(!e.extras)continue;const s=e.extras["mapbox:footprint:version"],a=e.extras["mapbox:footprint:id"];(s||a)&&n.add(o),"1.0.0"===s&&a&&(r[a]=o)}for(let o=0;o<e.length;o++){if(n.has(o))continue;const s=e[o],a=i[t[o]];if(!a.extras)continue;let l=null;s.id in r&&(l=kx(e[r[s.id]].meshes,s.matrix)),l||(l=Ox(a)),l&&(s.footprint=Lx(l))}if(n.size>0){const t=Array.from(n.values()).sort(((e,t)=>e-t));for(let i=t.length-1;i>=0;i--)e.splice(t[i],1)}}(a,s,e.json.nodes),a}function Bx(e){e.heightmap=new Float32Array(4096),e.heightmap.fill(-1);const t=e.vertexArray.float32,i=e.aabb.min[0]-1,r=e.aabb.min[1]-1,n=O_/(e.aabb.max[0]-i+2),o=O_/(e.aabb.max[1]-r+2);for(let s=0;s<t.length;s+=3){const a=t[s+2],l=(t[s+0]-i)*n|0,c=(t[s+1]-r)*o|0;a>e.heightmap[c*O_+l]&&(e.heightmap[c*O_+l]=a)}}function Nx(e,t){const i={};i.indexArray=new Ia,i.indexArray.reserve(4*e.length),i.vertexArray=new _a,i.vertexArray.reserve(10*e.length),i.colorArray=new ma,i.vertexArray.reserve(10*e.length);let r=0;for(const n of e){const e=Math.min(10,Math.max(4,1.3*n.height))*t,o=[-n.normal[1],n.normal[0],0],s=Math.min(.29,.1*n.width/n.depth),a=n.width-2*n.depth*t*(s+.01),l=F.vec3.scaleAndAdd([],n.pos,o,a/2),c=F.vec3.scaleAndAdd([],n.pos,o,-a/2),h=[l[0],l[1],l[2]+n.height],u=[c[0],c[1],c[2]+n.height],d=F.vec3.scaleAndAdd([],n.normal,o,s);F.vec3.scale(d,d,e);const p=F.vec3.scaleAndAdd([],n.normal,o,-s);F.vec3.scale(p,p,e),F.vec3.add(d,l,d),F.vec3.add(p,c,p),l[2]+=.1,c[2]+=.1,i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(h[0],h[1],h[2]),i.vertexArray.emplaceBack(u[0],u[1],u[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]);const f=a/e/2;i.colorArray.emplaceBack(-f-s,-1,f,.8),i.colorArray.emplaceBack(f+s,-1,f,.8),i.colorArray.emplaceBack(-f,0,f,1.3),i.colorArray.emplaceBack(f,0,f,1.3),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.indexArray.emplaceBack(6+r,4+r,8+r),i.indexArray.emplaceBack(7+r,9+r,5+r),i.indexArray.emplaceBack(0+r,1+r,2+r),i.indexArray.emplaceBack(1+r,3+r,2+r),r+=10}const n={defined:!0,emissiveFactor:[0,0,0]},o={};return o.baseColorFactor=St.white,n.pbrMetallicRoughness=o,i.material=n,i.aabb=new nh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}class Vx{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t<e.length;t++){const i=e[t];this._stringToNumber[i]=t,this._numberToString[t]=i}}encode(e){return this._stringToNumber[e]}decode(e){return this._numberToString[e]}}const Ux=["id","tile","layer","source","sourceLayer","state"];class jx{constructor(e,t,i,r,n){this.type="Feature",this._vectorTileFeature=e,this._z=t,this._x=i,this._y=r,this.properties=e.properties,this.id=n}clone(){const e=new jx(this._vectorTileFeature,this._z,this._x,this._y,this.id);return this.state&&(e.state={...this.state}),this.layer&&(e.layer={...this.layer}),this.source&&(e.source=this.source),this.sourceLayer&&(e.sourceLayer=this.sourceLayer),e}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const t of Ux)void 0!==this[t]&&(e[t]=this[t]);return e}}class Gx{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new to(Wi,16,0),this.featureIndexArray=new Ja,this.promoteId=t,this.is3DTile=!1,this.serializedLayersCache=new Map}insert(e,t,i,r,n,o=0,s=0){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,n,o);const l=this.grid;for(let e=0;e<t.length;e++){const i=t[e],r=[1/0,1/0,-1/0,-1/0];for(let e=0;e<i.length;e++){const t=i[e];r[0]=Math.min(r[0],t.x),r[1]=Math.min(r[1],t.y),r[2]=Math.max(r[2],t.x),r[3]=Math.max(r[3],t.y)}0!==s&&(r[0]-=s,r[1]-=s,r[2]+=s,r[3]+=s),r[0]<Wi&&r[1]<Wi&&r[2]>=0&&r[3]>=0&&l.insert(a,r[0],r[1],r[2],r[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Qu.VectorTile(new Yp(this.rawTileData)).layers,this.sourceLayerCoder=new Vx(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[]}return this.vtLayers}query(e,t){const{tilespaceGeometry:i,transform:r,tileTransform:n,pixelPosMatrix:o,availableImages:s}=t;this.loadVTLayers(),this.serializedLayersCache.clear();const a=i.bufferedTilespaceBounds,l=this.grid.query(a.min.x,a.min.y,a.max.x,a.max.y,((e,t,r,n)=>Cc(i.bufferedTilespaceGeometry,e,t,r,n)));l.sort(Zx);let c=null;r.elevation&&l.length>0&&(c=G_.create(r.elevation,this.tileID));const h={};let u;for(let t=0;t<l.length;t++){const a=l[t];if(a===u)continue;u=a;const d=this.featureIndexArray.get(a);let p=null;this.is3DTile?this.loadMatchingModelFeature(h,d,e,i,r):this.loadMatchingFeature(h,d,e,s,((e,t,s,a=0)=>(p||(p=fc(e,this.tileID.canonical,n)),t.queryIntersectsFeature(i,e,s,p,this.z,r,o,c,a))))}return h}loadMatchingFeature(e,t,i,r,n){const{featureIndex:o,bucketIndex:s,sourceLayerIndex:a,layoutVertexArrayOffset:l}=t,c=this.bucketLayerIDs[s],h=i.layers,u=Object.keys(h);if(u.length&&!function(e,t){for(let i=0;i<e.length;i++)if(t.indexOf(e[i])>=0)return!0;return!1}(u,c))return;const d=i.sourceCache,p=this.sourceLayerCoder.decode(a),f=this.vtLayers[p].feature(o),m=this.getId(f,p);for(let t=0;t<c.length;t++){const i=c[t];if(!h[i])continue;const{styleLayer:s,targets:a}=h[i];let u={};void 0!==m&&(u=d.getFeatureState(s.sourceLayer,m));const p=!n||n(f,s,u,l);if(!p)continue;const _=new jx(f,this.z,this.x,this.y,m);_.tile=this.tileID.canonical,_.state=u;let g=this.serializedLayersCache.get(i);g||(g=s.serialize(),g.id=i,this.serializedLayersCache.set(i,g)),_.source=g.source,_.sourceLayer=g["source-layer"],_.layer=te({},g),_.layer.paint=qx(g.paint,s.paint,f,u,r),_.layer.layout=qx(g.layout,s.layout,f,u,r);let y=!1;for(const e of a){this.updateFeatureProperties(_,e);const{filter:t}=e;if(t)if(f.properties=_.properties,t.needGeometry){const e=mc(f,!0);if(!t.filter(new Ms(this.tileID.overscaledZ),e,this.tileID.canonical))continue}else if(!t.filter(new Ms(this.tileID.overscaledZ),f))continue;y=!0,e.targetId&&this.addFeatureVariant(_,e)}y&&this.appendToResult(e,i,o,_,p)}}loadMatchingModelFeature(e,t,i,r,n){const o=this.bucketLayerIDs[0][0],s=i.layers;if(!s[o])return;const{styleLayer:a,targets:l}=s[o];if("model"!==a.type)return;const c=r.tile,h=t.featureIndex,u=c.getBucket(a);if(!(u&&u instanceof Y_))return;const d=function(e,t,i,r){const n=e.getNodesInfo()[t];if(n.hiddenByReplacement||!n.node.meshes)return;let o=Number.MAX_VALUE;const s=n.node,a=i.tile,l=r.calculatePosMatrix(a.tileID.toUnwrapped(),r.worldSize),c=n.evaluatedScale;let h=0;r.elevation&&s.elevation&&(h=s.elevation*r.elevation.exaggeration()),F.mat4.translate(l,l,[(s.anchor?s.anchor[0]:0)*(c[0]-1),(s.anchor?s.anchor[1]:0)*(c[1]-1),h]),F.mat4.scale(l,l,c);const u=i.queryGeometry,d=u.isPointQuery()?u.screenBounds:u.screenGeometry,p=function(e){const t=F.mat4.multiply([],l,e.matrix);F.mat4.multiply(t,r.expandedFarZProjMatrix,t);for(let i=0;i<e.meshes.length;++i){const n=e.meshes[i];if(i===e.lightMeshIndex)continue;const s=x_(d,r,t,n.aabb);null!=s&&(o=Math.min(s,o))}if(e.children)for(const t of e.children)p(t)};if(p(s),o===Number.MAX_VALUE)return;const f=new $l(0,0);return eg(a.tileID.canonical,f,n.node.anchor[0],n.node.anchor[1]),{intersectionZ:o,position:f,feature:n.feature}}(u,h,r,n);if(!d)return;const{z:p,x:f,y:m}=c.tileID.canonical,{feature:_,intersectionZ:g,position:y}=d;let x={};void 0!==_.id&&(x=i.sourceCache.getFeatureState(a.sourceLayer,_.id));const v=new jx({},p,f,m,_.id);v.tile=this.tileID.canonical,v.state=x,v.properties=_.properties,v.geometry={type:"Point",coordinates:[y.lng,y.lat]};let b=this.serializedLayersCache.get(o);b||(b=a.serialize(),b.id=o,this.serializedLayersCache.set(o,b)),v.source=b.source,v.sourceLayer=b["source-layer"],v.layer=te({},b);let w=!1;for(const e of l){this.updateFeatureProperties(v,e);const{filter:t}=e;if(t)if(_.properties=v.properties,t.needGeometry){if(!t.filter(new Ms(this.tileID.overscaledZ),_,this.tileID.canonical))continue}else if(!t.filter(new Ms(this.tileID.overscaledZ),_))continue;w=!0,e.targetId&&this.addFeatureVariant(v,e)}w&&this.appendToResult(e,o,h,v,g)}updateFeatureProperties(e,t,i){if(t.properties){const r={};for(const n in t.properties){const o=t.properties[n].evaluate({zoom:this.z},e._vectorTileFeature,e.state,e.tile,i);null!=o&&(r[n]=o)}e.properties=r}}addFeatureVariant(e,t,i){const r={target:t.target,namespace:t.namespace};t.properties&&(r.properties=e.properties),e.variants=e.variants||{},e.variants[t.targetId]=e.variants[t.targetId]||[],e.variants[t.targetId].push(r)}appendToResult(e,t,i,r,n){let o=e[t];void 0===o&&(o=e[t]=[]),o.push({featureIndex:i,feature:r,intersectionZ:n})}lookupSymbolFeatures(e,t,i,r,n){const o={};this.loadVTLayers();for(const s of e)this.loadMatchingFeature(o,{bucketIndex:t,sourceLayerIndex:i,featureIndex:s,layoutVertexArrayOffset:0},r,n);return o}loadFeature(e){const{featureIndex:t,sourceLayerIndex:i}=e;this.loadVTLayers();const r=this.sourceLayerCoder.decode(i),n=this.vtFeatures[r];if(n[t])return n[t];const o=this.vtLayers[r].feature(t);return n[t]=o,o}hasLayer(e){for(const t of this.bucketLayerIDs)for(const i of t)if(e===i)return!0;return!1}getId(e,t){let i=e.id;if(this.promoteId){const r="string"==typeof this.promoteId?this.promoteId:this.promoteId[t];null!=r&&(i=e.properties[r]),"boolean"==typeof i&&(i=Number(i))}return i}}function qx(e,t,i,r,n){return ae(e,((e,o)=>{const s=t instanceof Rs?t.get(o):null;return s&&s.evaluate?s.evaluate(i,r,n):s}))}function Zx(e,t){return t-e}ro(Gx,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const $x=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Hx{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[t,i]=new Uint8Array(e,0,2);if(219!==t)throw new Error("Data does not appear to be in a KDBush format.");const r=i>>4;if(1!==r)throw new Error(`Got v${r} data when expected v1.`);const n=$x[15&i];if(!n)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(e,2,1),[s]=new Uint32Array(e,4,1);return new Hx(s,o,n,e)}constructor(e,t=64,i=Float64Array,r){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=i,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const n=$x.indexOf(this.ArrayType),o=2*e*this.ArrayType.BYTES_PER_ELEMENT,s=e*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-s%8)%8;if(n<0)throw new Error(`Unexpected typed array class: ${i}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+s+a,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+o+s+a),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+s+a,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+n]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){const i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=e,this.coords[this._pos++]=t,i}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return Wx(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,i,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:o,nodeSize:s}=this,a=[0,n.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,h=a.pop()||0,u=a.pop()||0;if(h-u<=s){for(let s=u;s<=h;s++){const a=o[2*s],c=o[2*s+1];a>=e&&a<=i&&c>=t&&c<=r&&l.push(n[s])}continue}const d=u+h>>1,p=o[2*d],f=o[2*d+1];p>=e&&p<=i&&f>=t&&f<=r&&l.push(n[d]),(0===c?e<=p:t<=f)&&(a.push(u),a.push(d-1),a.push(1-c)),(0===c?i>=p:r>=f)&&(a.push(d+1),a.push(h),a.push(1-c))}return l}within(e,t,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:n,nodeSize:o}=this,s=[0,r.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,h=s.pop()||0,u=s.pop()||0;if(h-u<=o){for(let i=u;i<=h;i++)Jx(n[2*i],n[2*i+1],e,t)<=l&&a.push(r[i]);continue}const d=u+h>>1,p=n[2*d],f=n[2*d+1];Jx(p,f,e,t)<=l&&a.push(r[d]),(0===c?e-i<=p:t-i<=f)&&(s.push(u),s.push(d-1),s.push(1-c)),(0===c?e+i>=p:t+i>=f)&&(s.push(d+1),s.push(h),s.push(1-c))}return a}}function Wx(e,t,i,r,n,o){if(n-r<=i)return;const s=r+n>>1;Xx(e,t,s,r,n,o),Wx(e,t,i,r,s-1,1-o),Wx(e,t,i,s+1,n,1-o)}function Xx(e,t,i,r,n,o){for(;n>r;){if(n-r>600){const s=n-r+1,a=i-r+1,l=Math.log(s),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2<0?-1:1);Xx(e,t,i,Math.max(r,Math.floor(i-a*c/s+h)),Math.min(n,Math.floor(i+(s-a)*c/s+h)),o)}const s=t[2*i+o];let a=r,l=n;for(Yx(e,t,r,i),t[2*n+o]>s&&Yx(e,t,r,n);a<l;){for(Yx(e,t,a,l),a++,l--;t[2*a+o]<s;)a++;for(;t[2*l+o]>s;)l--}t[2*r+o]===s?Yx(e,t,r,l):(l++,Yx(e,t,l,n)),l<=i&&(r=l+1),i<=l&&(n=l-1)}}function Yx(e,t,i,r){Kx(e,i,r),Kx(t,2*i,2*r),Kx(t,2*i+1,2*r+1)}function Kx(e,t,i){const r=e[t];e[t]=e[i],e[i]=r}function Jx(e,t,i,r){const n=e-i,o=t-r;return n*n+o*o}e.$=Us,e.A=Jt,e.B=2,e.C=Mf,e.D=lg,e.E=vt,e.F=Ef,e.G=class extends I_{},e.H=ci,e.I=iy,e.J=Ct,e.K=Ns,e.L=On,e.M=Dn,e.N=Ln,e.O=Zn,e.P=U,e.Q=Vs,e.R=Je,e.S=Xn,e.T=Wm,e.U=$n,e.V=I_,e.W=Ar,e.X=Cr,e.Y=Er,e.Z=fi,e._=Tt,e.a=function(e){return Te.API_CDN_URL_REGEX.test(e)},e.a$=jx,e.a0=kn,e.a1=Rn,e.a2=function(e){const t=e.value;let i=[];if(!t)return i;const r=ci(t);return"string"!==r?(i=i.concat([new I_(e.key,t,`string expected, "${r}" found`)]),i):(C_(t,!0)||(i=i.concat([new I_(e.key,t,`invalid url "${t}"`)])),i)},e.a3=Bs,e.a4=Is,e.a5=Fs,e.a6=Ls,e.a7=class{constructor(e){this.specification=e}possiblyEvaluate(e,t){return fe(e.expression.evaluate(t))}interpolate(e,t,i){return{x:Et(e.x,t.x,i),y:Et(e.y,t.y,i),z:Et(e.z,t.z,i),azimuthal:Et(e.azimuthal,t.azimuthal,i),polar:Et(e.polar,t.polar,i)}}},e.a8=Ms,e.a9=Wn,e.aA=Yl,e.aB=class{constructor(e){this.entries={},this.scheduler=e}request(e,t,i,r){const n=this.entries[e]=this.entries[e]||{callbacks:[]};if(n.result){const[e,i]=n.result;return this.scheduler?this.scheduler.add((()=>{r(e,i)}),t):r(e,i),()=>{}}return n.callbacks.push(r),n.cancel||(n.cancel=i(((i,r)=>{n.result=[i,r];for(const e of n.callbacks)this.scheduler?this.scheduler.add((()=>{e(i,r)}),t):e(i,r);setTimeout((()=>delete this.entries[e]),3e3)}))),()=>{n.result||(n.callbacks=n.callbacks.filter((e=>e!==r)),n.callbacks.length||(n.cancel(),delete this.entries[e]))}}},e.aC=ta,e.aD=function(e,t,i){const r=JSON.stringify(e.request);return e.data&&(this.deduped.entries[r]={result:[null,e.data]}),this.deduped.request(r,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom},(t=>{const r=it(e.request,((e,r,n,o)=>{e?t(e):r&&t(null,{vectorTile:i?void 0:new Qu.VectorTile(new Yp(r)),rawData:r,cacheControl:n,expires:o})}));return()=>{r.cancel(),t()}}),t)},e.aE=function(e){qe++,qe>Be&&(e.getActor().send("enforceCacheSizeLimit",Fe),qe=0)},e.aF=function(e){return e<=1?1:Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},e.aG=qc,e.aH=t_,e.aI=a_,e.aJ=Qm,e.aK=function(e,t){const i=document.createElement("video");i.muted=!0,i.onloadstart=function(){t(null,i)};for(let t=0;t<e.length;t++){const r=document.createElement("source");rt(e[t])||(i.crossOrigin="Anonymous"),r.src=e[t],i.appendChild(r)}return{cancel:()=>{}}},e.aL=Xm,e.aM=function(e){return fetch(e).then((e=>e.arrayBuffer())).then((t=>Cx(t,0,e)))},e.aN=Fx,e.aO=class{constructor(e,t,i,r){this.id=e,this.position=null!=t?new $l(t[0],t[1]):new $l(0,0),this.orientation=null!=i?i:[0,0,0],this.nodes=r,this.uploaded=!1,this.aabb=new nh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(e,t){if(F.mat4.multiply(e.matrix,t,e.matrix),e.meshes)for(const t of e.meshes){const i=nh.applyTransformFast(t.aabb,e.matrix);this.aabb.encapsulate(i)}if(e.children)for(const t of e.children)this._applyTransformations(t,e.matrix)}computeBoundsAndApplyParent(){const e=F.mat4.identity([]);for(const t of this.nodes)this._applyTransformations(t,e)}computeModelMatrix(e,t,i,r,n,o,s=!1){F_(this.matrix,this,e.transform,this.position,t,i,r,n,o,s)}upload(e){if(!this.uploaded){for(const t of this.nodes)V_(t,e);for(const e of this.nodes)U_(e);this.uploaded=!0}}destroy(){for(const e of this.nodes)j_(e)}},e.aP=oe,e.aQ=im,e.aR=Jl,e.aS=Ql,e.aT=da,e.aU=Ia,e.aV=re,e.aW=qa,e.aX=Lm,e.aY=function(){Ss.isLoading()||Ss.isLoaded()||"deferred"!==ws()||Ts()},e.aZ=js,e.a_=mc,e.aa=sc,e.ab=F,e.ac=J,e.ad=Rs,e.ae=Sh,e.af=Et,e.ag=Wi,e.ah=At,e.ai=Z,e.aj=St,e.ak=class{constructor(e){this.specification=e}possiblyEvaluate(e,t){return function([e,t]){const i=fe([1,e,t]);return{x:i.x,y:i.y,z:i.z}}(e.expression.evaluate(t))}interpolate(e,t,i){return{x:Et(e.x,t.x,i),y:Et(e.y,t.y,i),z:Et(e.z,t.z,i)}}},e.al=function(e,t,i=0,r=!0){const n=new U(i,i),o=e.sub(n),s=t.add(n),a=[o,new U(s.x,o.y),s,new U(o.x,s.y)];return r&&a.push(o.clone()),a},e.am=function(e,t){const i=[];for(let r=0;r<e.length;r++){const n=Q(r-1,-1,e.length-1),o=Q(r+1,-1,e.length-1),s=e[r],a=e[o],l=e[n].sub(s).unit(),c=a.sub(s).unit(),h=c.angleWithSep(l.x,l.y),u=l.add(c).unit().mult(-1*t/Math.sin(h/2));i.push(s.add(u))}return i},e.an=rm,e.ao=Cc,e.ap=function(e,t,i=0){return F.vec3.fromValues(((t.x-i)*e.scale-e.x)*Wi,(t.y*e.scale-e.y)*Wi,ec(t.z,t.y))},e.aq=Kc,e.ar=fp,e.as=function(e){let t=1/0,i=1/0,r=-1/0,n=-1/0;for(const o of e)t=Math.min(t,o.x),i=Math.min(i,o.y),r=Math.max(r,o.x),n=Math.max(n,o.y);return{min:new U(t,i),max:new U(r,n)}},e.at=Xl,e.au=Ic,e.av=lc,e.aw=K,e.ax=Fl,e.ay=function(e,t){const i={};for(let r=0;r<t.length;r++){const n=t[r];n in e&&(i[n]=e[n])}return i},e.az=Hl,e.b=function(e){return Te.API_FONTS_REGEX.test(e)},e.b$=d_,e.b0=_e,e.b1=hp,e.b2=Au,e.b3=fc,e.b4=ha,e.b5=Ba,e.b6=Yc,e.b7=nl,e.b8=Kh,e.b9=Zm,e.bA=_d,e.bB=$f,e.bC=Zf,e.bD=df,e.bE=Hx,e.bF=Q,e.bG=ye,e.bH=Kl,e.bI=function(e,t,i){e[4*t+0]=i[0],e[4*t+1]=i[1],e[4*t+2]=i[2],e[4*t+3]=i[3]},e.bJ=vl,e.bK=ml,e.bL=_l,e.bM=fl,e.bN=pl,e.bO=$l,e.bP=Sm,e.bQ=Gc,e.bR=rh,e.bS=u_,e.bT=jc,e.bU=ph,e.bV=function(e,t,i,r,n,o,s,a,l){if("globe"===l.name)return ph(e,t,new jc(i,r,n),!1);const c=im({z:i,x:r,y:n},l);return new nh([(o+c.x/c.scale)*t,t*(c.y/c.scale),s],[(o+c.x2/c.scale)*t,t*(c.y2/c.scale),a])},e.bW=function(e,t,i){let r=0;for(let i=0;i<2;++i){const n=0;e[i]>n&&(r+=(e[i]-n)*(e[i]-n)),t[i]<n&&(r+=(n-t[i])*(n-t[i]))}return r},e.bX=tc,e.bY=6,e.bZ=function(e){const t=F.mat4.identity(new Float64Array(16));F.mat4.multiply(t,e.pixelMatrix,e.globeMatrix);const i=[0,Vl,0],r=[0,Ul,0];return F.vec3.transformMat4(i,i,t),F.vec3.transformMat4(r,r,t),[i[0]>0&&i[0]<=e.width&&i[1]>0&&i[1]<=e.height&&!Eh(e,new $l(e.center.lat,90)),r[0]>0&&r[0]<=e.width&&r[1]>0&&r[1]<=e.height&&!Eh(e,new $l(e.center.lat,-90))]},e.b_=function(e,t){const{scale:i}=e.tileTransform,r=i*Wi/(e.tileSize*Math.pow(2,t.zoom-e.tileID.overscaledZ+e.tileID.canonical.z));return F.mat2.scale(new Float32Array(4),t.inverseAdjustmentMatrix,[r,r])},e.ba=function(e,t){const i=Sh(t.zoom);if(0===i)return hh(e);const r=fh(e),n=mh(r),o=Xl(r.getWest())*t.worldSize,s=Xl(r.getEast())*t.worldSize,a=Yl(r.getNorth())*t.worldSize,l=Yl(r.getSouth())*t.worldSize,c=[o,a,0],h=[s,a,0],u=[o,l,0],d=[s,l,0],p=F.mat4.invert([],t.globeMatrix);return F.vec3.transformMat4(c,c,p),F.vec3.transformMat4(h,h,p),F.vec3.transformMat4(u,u,p),F.vec3.transformMat4(d,d,p),n[0]=uh(n[0],u,i),n[1]=uh(n[1],d,i),n[2]=uh(n[2],h,i),n[3]=uh(n[3],c,i),nh.fromPoints(n)},e.bb=xh,e.bc=_h,e.bd=uh,e.be=ua,e.bf=Xc,e.bg=nx,e.bh=Yp,e.bi=it,e.bj=function(e){const t=[];for(const i in e)t.push(e[i]);return t},e.bk=function(e,t){const i=[];for(const r in e)r in t||i.push(r);return i},e.bl=ee,e.bm=["type","source","source-layer","minzoom","maxzoom","filter","layout"],e.bn=j,e.bo=function(e,t){const{x:i,y:r}=e.point,n=Th(i,r,e.worldSize/e._pixelsPerMercatorPixel,0,0);return F.mat4.multiply(n,n,vh(hh(t)))},e.bp=Np,e.bq=ef,e.br=Bp,e.bs=function(e,t,i,r,n){const o=5*t+2;e.float32[o+0]=i,e.float32[o+1]=r,e.float32[o+2]=n},e.bt=Pm,e.bu=Sf,e.bv=xc,e.bw=Lp,e.bx=sd,e.by=A_,e.bz=md,e.c=Me,e.c$=(e,t,i,r,n,o,s,a)=>{const l=e.transform,c=l.pitch<15?mp(.07,.7,K((14-l.zoom)/5,0,1)):.07,h="none"===i.paint.get("line-trim-color-use-theme").constantOr("default");return{u_matrix:gp(e,t,i,r),u_texsize:t.imageAtlasTexture?t.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:l.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:n,u_width_scale:o,u_floor_width_scale:s,u_image:0,u_tile_units_to_pixels:_p(t,l),u_units_to_pixels:[1/l.pixelsToGLUnits[0],1/l.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:a,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(h?null:i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength"),u_zbias_factor:c,u_tile_to_meter:oc(t.tileID.canonical,0)}},e.c0=h_,e.c1=function(e){const t=h_(e,!0);return F.mat2.invert([],[t[0],t[1],t[4],t[5]])},e.c2=Jc,e.c3=function(e){const{x:t,y:i}=e.point,{lng:r,lat:n}=e._center;return Th(t,i,e.worldSize,r,n)},e.c4=$,e.c5=Zc,e.c6=5,e.c7=function(e){const t=Math.round((e+45+360)%360/90)%4;return H[t]},e.c8=45,e.c9=Wl,e.cA=class extends dl{constructor(e){super(e),this.current=bl}set(e,t,i){if(this.fetchUniformLocation(e,t))for(let e=0;e<9;e++)if(i[e]!==this.current[e]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}},e.cB=W,e.cC=function(e,t,i){const r=Sh(i.zoom),n=e.style.map._antialias,o=t.options.extStandardDerivativesForceOff||e.terrain&&e.terrain.exaggeration()>0;return 0===r&&!n&&!o},e.cD=function(e){const t=e.pixelsPerMeter,i=t/Kl(1,e.center.lat),r=F.mat4.identity(new Float64Array(16));return F.mat4.translate(r,r,[e.point.x,e.point.y,0]),F.mat4.scale(r,r,[i,i,t]),Float32Array.from(r)},e.cE=fh,e.cF=function(e){const t=tc-5;e=K(e,-t,t)/t*90;const i=Math.pow(Math.abs(Math.sin(Z(e))),3);return Math.round(i*(Nl.length-1))},e.cG=function(e,t,i,r){const n=t.getNorth(),o=t.getSouth(),s=t.getWest(),a=t.getEast(),l=1<<e.z,c=a-s,h=n-o,u=c/Bl,d=-h/Nl[i],p=[0,u,0,d,0,0,n,s,0];if(e.z>0){const e=180/r;F.mat3.multiply(p,p,[e/c+1,0,0,0,e/h+1,0,-.5*e/u,.5*e/d,1])}return p[2]=l,p[5]=e.x,p[8]=e.y,p},e.cH=hh,e.cI=function(e,t,i){const r=F.mat4.identity(new Float64Array(16)),n=(t/(1<<e)-.5)*Math.PI*2;return F.mat4.rotateY(r,i.globeMatrix,n),Float32Array.from(r)},e.cJ=class{isDataAvailableAtPoint(e){const t=this._source();if(this.isUsingMockSource()||!t||e.y<0||e.y>1)return!1;const i=t.getSource().maxzoom,r=1<<i,n=Math.floor(e.x),o=Math.floor((e.x-n)*r),s=Math.floor(e.y*r),a=this.findDEMTileFor(new qc(i,n,i,o,s));return!(!a||!a.dem)}getAtPointOrZero(e,t=0){return this.getAtPoint(e,t)||0}getAtPoint(e,t,i=!0){if(this.isUsingMockSource())return null;null==t&&(t=null);const r=this._source();if(!r)return t;if(e.y<0||e.y>1)return t;const n=r.getSource().maxzoom,o=1<<n,s=Math.floor(e.x),a=e.x-s,l=new qc(n,s,n,Math.floor(a*o),Math.floor(e.y*o)),c=this.findDEMTileFor(l);if(!c||!c.dem)return t;const h=c.dem,u=1<<c.tileID.canonical.z,d=(a*u-c.tileID.canonical.x)*h.dim,p=(e.y*u-c.tileID.canonical.y)*h.dim,f=Math.floor(d),m=Math.floor(p);return(i?this.exaggeration():1)*Et(Et(h.get(f,m),h.get(f,m+1),p-m),Et(h.get(f+1,m),h.get(f+1,m+1),p-m),d-f)}getAtTileOffset(e,t,i){const r=1<<e.canonical.z;return this.getAtPointOrZero(new sc(e.wrap+(e.canonical.x+t/Wi)/r,(e.canonical.y+i/Wi)/r))}getAtTileOffsetFunc(e,t,i,r){return n=>{const o=this.getAtTileOffset(e,n.x,n.y),s=r.upVector(e.canonical,n.x,n.y),a=r.upVectorScale(e.canonical,t,i).metersToTile;return F.vec3.scale(s,s,o*a),s}}getForTilePoints(e,t,i,r){if(this.isUsingMockSource())return!1;const n=G_.create(this,e,r);return!!n&&(t.forEach((e=>{e[2]=this.exaggeration()*n.getElevationAt(e[0],e[1],i)})),!0)}getMinMaxForTile(e){if(this.isUsingMockSource())return null;const t=this.findDEMTileFor(e);if(!t||!t.dem)return null;const i=t.dem.tree,r=t.tileID,n=1<<e.canonical.z-r.canonical.z;let o=e.canonical.x/n-r.canonical.x,s=e.canonical.y/n-r.canonical.y,a=0;for(let t=0;t<e.canonical.z-r.canonical.z&&!i.leaves[a];t++){o*=2,s*=2;const e=2*Math.floor(s)+Math.floor(o);a=i.childOffsets[a]+e,o%=1,s%=1}return{min:this.exaggeration()*i.minimums[a],max:this.exaggeration()*i.maximums[a]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(e,t,i){throw new Error("Pure virtual method called.")}pointCoordinate(e){throw new Error("Pure virtual method called.")}_source(){throw new Error("Pure virtual method called.")}isUsingMockSource(){throw new Error("Pure virtual method called.")}exaggeration(){throw new Error("Pure virtual method called.")}findDEMTileFor(e){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}getMinMaxForVisibleTiles(){const e=this.visibleDemTiles;if(0===e.length)return null;let t=!1,i=Number.MAX_VALUE,r=Number.MIN_VALUE;for(const n of e){const e=this.getMinMaxForTile(n.tileID);e&&(i=Math.min(i,e.min),r=Math.max(r,e.max),t=!0)}return t?{min:i,max:r}:null}},e.cK=Hh,e.cL=oh,e.cM=function(e,t){return[Math.pow(e[0],2.2)*t,Math.pow(e[1],2.2)*t,Math.pow(e[2],2.2)*t]},e.cN=wh,e.cO=we,e.cP=be,e.cQ=256,e.cR=function(e,t){const i=[0,0,0],r=xh(hh(t.canonical));return F.vec3.transformMat4(i,i,r),F.vec3.transformMat4(i,i,e),i},e.cS=e=>({u_camera_to_center_distance:new fl(e),u_extrude_scale:new Tl(e),u_device_pixel_ratio:new fl(e),u_matrix:new vl(e),u_inv_rot_matrix:new vl(e),u_merc_center:new ml(e),u_tile_id:new _l(e),u_zoom_transition:new fl(e),u_up_dir:new _l(e),u_emissive_strength:new fl(e)}),e.cT=e=>({u_matrix:new vl(e),u_pixels_to_tile_units:new Tl(e),u_device_pixel_ratio:new fl(e),u_width_scale:new fl(e),u_floor_width_scale:new fl(e),u_units_to_pixels:new ml(e),u_dash_image:new pl(e),u_gradient_image:new pl(e),u_image_height:new fl(e),u_texsize:new ml(e),u_tile_units_to_pixels:new fl(e),u_alpha_discard_threshold:new fl(e),u_trim_offset:new ml(e),u_trim_fade_range:new ml(e),u_trim_color:new gl(e),u_emissive_strength:new fl(e),u_zbias_factor:new fl(e),u_tile_to_meter:new fl(e)}),e.cU=e=>({u_matrix:new vl(e),u_texsize:new ml(e),u_pixels_to_tile_units:new Tl(e),u_device_pixel_ratio:new fl(e),u_width_scale:new fl(e),u_floor_width_scale:new fl(e),u_image:new pl(e),u_units_to_pixels:new ml(e),u_tile_units_to_pixels:new fl(e),u_alpha_discard_threshold:new fl(e),u_trim_offset:new ml(e),u_trim_fade_range:new ml(e),u_trim_color:new gl(e),u_emissive_strength:new fl(e),u_zbias_factor:new fl(e),u_tile_to_meter:new fl(e)}),e.cV=Ea,e.cW=Rp,e.cX=Vp,e.cY=zh,e.cZ=(e,t,i,r,n,o)=>{const s=e.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const e=wh(s.zoom,t.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([e,0,0,e])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:e.transform.getCameraToCenterDistance(s.projection),u_matrix:e.translatePosMatrix(t.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:Re.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Ph,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=r,c.u_merc_center=n,c.u_tile_id=[t.canonical.x,t.canonical.y,1<<t.canonical.z],c.u_zoom_transition=Sh(s.zoom);const e=n[0]*Wi,i=n[1]*Wi;c.u_up_dir=s.projection.upVector(new jc(0,0,0),e,i)}return c},e.c_=yp,e.ca=gl,e.cb=function(e,t,i){const r=Math.sqrt(e*e+t*t+i*i),n=r>0?Math.acos(i/r)*q:0;let o=0!==e||0!==t?Math.atan2(-t,-e)*q+90:0;return o<0&&(o+=360),[r,o,n]},e.cc=oc,e.cd=nh,e.ce=fe,e.cf=function(e){return[Math.pow(e[0],1/2.2),Math.pow(e[1],1/2.2),Math.pow(e[2],1/2.2)]},e.cg=function(e,t){return e.readFields(xg,{icons:[]},t)},e.ch=function(e){return e({pluginStatus:gs,pluginURL:ys}),bs.on("pluginStateChange",e),e},e.ci=ug,e.cj=Df,e.ck=zf,e.cl=et,e.cm=xs,e.cn=Oe,e.co=mt,e.cp=ce,e.cq=function(e){const t=e.indexOf(ea);return t>=0?e.slice(0,t):e},e.cr=function(e){return e.indexOf(ea)>=0},e.cs=function(e){const t=e.indexOf(ea);return t>=0?e.slice(t+1):""},e.ct=function(e){const t=[],i=e.id;return void 0===i&&t.push({message:`layers.${i}: missing required property "id"`}),void 0===e.render&&t.push({message:`layers.${i}: missing required method "render"`}),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),t},e.cu=function(e,t,i,r){return"custom"===e.type?new l_(e,t):new tg[e.type](e,t,i,r)},e.cv=le,e.cw=class extends jx{constructor(e,t){super(e._vectorTileFeature,e._z,e._x,e._y,e.id),e.state&&(this.state={...e.state}),this.target=t.target,this.namespace=t.namespace,t.properties&&(this.properties=t.properties),this.target&&("featuresetId"in this.target&&!this.target.importId||"layerId"in this.target)&&(this.source=e.source,this.sourceLayer=e.sourceLayer,this.layer=e.layer)}toJSON(){const e=super.toJSON();return e.target=this.target,e.namespace=this.namespace,e}},e.cx=bs,e.cy=tt,e.cz=yl,e.d=function(e){return Te.API_TILEJSON_REGEX.test(e)},e.d$=ae,e.d0=(e,t,i,r,n,o,s,a,l)=>{const c=e.transform,h=c.calculatePixelsToTileUnitsMatrix(t),u="none"===i.paint.get("line-trim-color-use-theme").constantOr("default"),d=c.pitch<15?mp(.07,.7,K((14-c.zoom)/5,0,1)):.07;return{u_matrix:gp(e,t,i,r),u_pixels_to_tile_units:h,u_device_pixel_ratio:o,u_width_scale:s,u_floor_width_scale:a,u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:n,u_texsize:xp(i)&&t.lineAtlasTexture?t.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:_p(t,e.transform),u_alpha_discard_threshold:0,u_trim_offset:l,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(u?null:i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength"),u_zbias_factor:d,u_tile_to_meter:oc(t.tileID.canonical,0)}},e.d1=ne,e.d2=Wh,e.d3=Zd,e.d4=$c,e.d5=Fd,e.d6=Md,e.d7=450,e.d8=7,e.d9=e_,e.dA=Y,e.dB=nc,e.dC=Gl,e.dD=function([e,t,i]){const r=Math.hypot(e,t,i),n=Math.atan2(e,i),o=.5*Math.PI-Math.acos(-t/r);return new $l($(n),$(o))},e.dE=f_,e.dF=function(e){const t=e.navigator?e.navigator.userAgent:null;return!!function(e){if(null==ge){const t=e.navigator?e.navigator.userAgent:null;ge=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return ge}(e)&&t&&(t.match("Version/15.4")||t.match("Version/15.5")||t.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},e.dG=function(e,t){Fe=e,Be=t},e.dH=Eh,e.dI=Mh,e.dJ=function(e){const t=[0,0,0],i=F.mat4.identity(new Float64Array(16));return F.mat4.multiply(i,e.pixelMatrix,e.globeMatrix),F.vec3.transformMat4(t,t,i),new U(t[0],t[1])},e.dK=function(e,t,i=!1){if(gs===ps||gs===fs||gs===ms)throw new Error("setRTLTextPlugin cannot be called multiple times.");ys=Re.resolveURL(e),gs=ps,_s=t,vs(),i||Ts()},e.dL=ws,e.dM=function(){ug().acquire(sg)},e.dN=function(){const e=cg;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(sg),cg=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},e.dO=ag,e.dP=function(e){const t=je();if(!t)return;const i=t.delete(ke);e&&i.catch(e).then((()=>e()))},e.dQ=og,e.dR=px,e.dS=function(e){lx=Re.resolveURL(e),dx||(dx=new lg(ug(),new vt)),dx.broadcast("setDracoUrl",lx)},e.dT=fx,e.dU=function(e){hx=Re.resolveURL(e),dx||(dx=new lg(ug(),new vt)),dx.broadcast("setMeshoptUrl",hx)},e.dV=ro,e.dW=Zh,e.dX=2,e.dY=Vx,e.dZ=Gx,e.d_=sp,e.da=la,e.db=Ua,e.dc=256,e.dd=vh,e.de=_a,e.df=Da,e.dg=Ra,e.dh=function(e,t,i,r,n){return K((e-t)/(i-t)*(n-r)+r,r,n)},e.di=wn,e.dj=rc,e.dk=class{constructor(e,t,i,r){this.context=e,this.format=r,this.size=i,this.texture=e.gl.createTexture();const[n,o,s]=this.size,{gl:a}=e;a.bindTexture(a.TEXTURE_3D,this.texture),e.pixelStoreUnpackFlipY.set(!1),e.pixelStoreUnpack.set(1),e.pixelStoreUnpackPremultiplyAlpha.set(!1),a.texImage3D(a.TEXTURE_3D,0,this.format,n,o,s,0,$m(this.format),Hm(this.format),t.data)}bind(e,t){const{context:i}=this,{gl:r}=i;r.bindTexture(r.TEXTURE_3D,this.texture),e!==this.minFilter&&(r.texParameteri(r.TEXTURE_3D,r.TEXTURE_MAG_FILTER,e),r.texParameteri(r.TEXTURE_3D,r.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(r.texParameteri(r.TEXTURE_3D,r.TEXTURE_WRAP_S,t),r.texParameteri(r.TEXTURE_3D,r.TEXTURE_WRAP_T,t),this.wrapS=t)}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}},e.dl=y_,e.dm=[1,1,1],e.dn=G_,e.dp=k_,e.dq=Ta,e.dr=ka,e.ds=ql,e.dt=Oa,e.du=La,e.dv=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new U(1/0,1/0),max:new U(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(e,t=!1){const i=ud(new U(0,0),new U(Wi,Wi),e),r=[];if(t&&!cd(i,this._globalClipBounds))return r;for(const t of this._activeRegions){if(t.hiddenByOverlap)continue;if(!cd(i,t))continue;const n=dd(t.min,t.max,e);r.push({min:n.min,max:n.max,sourceId:this._sourceIds[t.priority],footprint:t.footprint,footprintTileId:t.tileId,order:t.order,clipMask:t.clipMask,clipScope:t.clipScope})}return r}setSources(e){this._setSources(e.map((e=>({getSourceId:()=>e.cache.id,getFootprints:()=>{const t=[];for(const i of e.cache.getVisibleCoordinates()){const r=e.cache.getTile(i).buckets[e.layer];r&&r.updateFootprints(i.toUnwrapped(),t)}return t},getOrder:()=>e.order,getClipMask:()=>e.clipMask,getClipScope:()=>e.clipScope}))))}_addSource(e){const t=e.getFootprints();if(0===t.length)return;const i=e.getOrder(),r=e.getClipMask(),n=e.getClipScope();for(const e of t){if(!e.footprint)continue;const t=ud(e.footprint.min,e.footprint.max,e.id);this._activeRegions.push({min:t.min,max:t.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:e.id,footprint:e.footprint,order:i,clipMask:r,clipScope:n})}this._sourceIds.push(e.getSourceId())}_computeReplacement(){this._activeRegions.sort(((e,t)=>e.priority-t.priority||ad(e.min,t.min)||ad(e.max,t.max)||e.order-t.order||e.clipMask-t.clipMask||function(e,t){const i=(e,t)=>e+t;return e.length-t.length||e.reduce(i,"").localeCompare(t.reduce(i,""))}(e.clipScope,t.clipScope)));let e=this._activeRegions.length!==this._prevRegions.length;if(!e){let t=0;for(;!e&&t!==this._activeRegions.length;){const i=this._activeRegions[t],r=this._prevRegions[t];e=i.priority!==r.priority||!ld(i,r)||i.order!==r.order||i.clipMask!==r.clipMask||!j(i.clipScope,r.clipScope),++t}}if(e){++this._updateTime;for(const e of this._activeRegions)e.order!==od&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,e.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,e.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,e.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,e.max.y));const e=e=>{const t=this._activeRegions;if(e>=t.length)return e;const i=t[e].priority;for(;e<t.length&&t[e].priority===i;)++e;return e};if(this._sourceIds.length>1){let t=0,i=e(t);for(;t!==i;){let r=t;const n=t;for(;r!==i;){const e=this._activeRegions[r];e.hiddenByOverlap=!1;for(let t=0;t<n;t++){const i=this._activeRegions[t];if(!i.hiddenByOverlap&&e.order===od&&cd(e,i)&&(e.hiddenByOverlap=fd(e.footprint,e.tileId,i.footprint,i.tileId),e.hiddenByOverlap))break}++r}t=i,i=e(t)}}}}_setSources(e){[this._prevRegions,this._activeRegions]=[this._activeRegions,[]],this._sourceIds=[];for(let t=e.length-1;t>=0;t--)this._addSource(e[t]);this._computeReplacement()}},e.dw=class{constructor(e){this._createGrid(e),this._createPoles(e)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const e of this._poleSegments)e.destroy();for(const e of this._gridSegments)e.withSkirts.destroy(),e.withoutSkirts.destroy()}_fillGridMeshWithLods(e,t){const i=new ha,r=new Ia,n=[],o=e+1+2,s=t[0]+1,a=t[0]+1+(1+t.length),l=(e,t,i)=>{let r=e===o-1?e-2:0===e?e:e-1;return r+=i?24575:0,[r,t]};for(let e=0;e<o;++e)i.emplaceBack(...l(e,0,!0));for(let e=0;e<s;++e)for(let t=0;t<o;++t)i.emplaceBack(...l(t,e,(0===t||t===o-1)&&!0));for(let e=0;e<t.length;++e){const r=t[e];for(let e=0;e<o;++e)i.emplaceBack(...l(e,r,!0))}for(let e=0;e<t.length;++e){const s=r.length,l=t[e]+1+2,c=new Ia;for(let i=0;i<l-1;i++){const n=i===l-2,s=n?o*(a-t.length+e-i):o;for(let e=0;e<o-1;e++){const t=i*o+e;0===i||n||0===e||e===o-2?(c.emplaceBack(t+1,t,t+s),c.emplaceBack(t+s,t+s+1,t+1)):(r.emplaceBack(t+1,t,t+s),r.emplaceBack(t+s,t+s+1,t+1))}}const h=nl.simpleSegment(0,s,i.length,r.length-s);for(let e=0;e<c.uint16.length;e+=3)r.emplaceBack(c.uint16[e],c.uint16[e+1],c.uint16[e+2]);const u=nl.simpleSegment(0,s,i.length,r.length-s);n.push({withoutSkirts:h,withSkirts:u})}return{vertices:i,indices:r,segments:n}}_createGrid(e){const t=this._fillGridMeshWithLods(Bl,Nl);this._gridSegments=t.segments,this._gridBuffer=e.createVertexBuffer(t.vertices,Yc.members),this._gridIndexBuffer=e.createIndexBuffer(t.indices,!0)}_createPoles(e){const t=new Ia;for(let e=0;e<=Bl;e++)t.emplaceBack(0,e+1,e+2);this._poleIndexBuffer=e.createIndexBuffer(t,!0);const i=new Da,r=new Da,n=new Da,o=new Da;this._poleSegments=[];for(let e=0,t=0;e<5;e++){const s=360/(1<<e);i.emplaceBack(0,-Fl,0,.5,0),r.emplaceBack(0,-Fl,0,.5,1),n.emplaceBack(0,-Fl,0,.5,.5),o.emplaceBack(0,-Fl,0,.5,.5);for(let e=0;e<=Bl;e++){let t=e/Bl,a=0;const l=Et(0,s,t),[c,h,u]=jl(Ih,Ch,l,Fl);i.emplaceBack(c,h,u,t,a),r.emplaceBack(c,h,u,t,1-a);const d=Z(l);t=.5+.5*Math.sin(d),a=.5+.5*Math.cos(d),n.emplaceBack(c,h,u,t,a),o.emplaceBack(c,h,u,t,1-a)}this._poleSegments.push(nl.simpleSegment(t,0,66,64)),t+=66}this._poleNorthVertexBuffer=e.createVertexBuffer(i,Wc,!1),this._poleSouthVertexBuffer=e.createVertexBuffer(r,Wc,!1),this._texturedPoleNorthVertexBuffer=e.createVertexBuffer(n,Wc,!1),this._texturedPoleSouthVertexBuffer=e.createVertexBuffer(o,Wc,!1)}getGridBuffers(e,t){return[this._gridBuffer,this._gridIndexBuffer,t?this._gridSegments[e].withSkirts:this._gridSegments[e].withoutSkirts]}getPoleBuffers(e,t){return[t?this._texturedPoleNorthVertexBuffer:this._poleNorthVertexBuffer,t?this._texturedPoleSouthVertexBuffer:this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[e]]}},e.dx=od,e.dy=X,e.dz=function(){return!!document.fullscreenElement||!!document.webkitFullscreenElement},e.e=Te,e.e0=Kt,e.e1=Af,e.e2=function(e,t,i,r,n,o,s,a,l,c,h=1,u,d){e.createArrays(),e.tilePixelRatio=Wi/(512*e.overscaling),e.compareText={},e.iconsNeedLinear=!1;const p=e.layers[0].layout,f=e.layers[0]._unevaluatedLayout._values,m={};m.scaleFactor=h,m.textSizeScaleRange=p.get("text-size-scale-range"),m.iconSizeScaleRange=p.get("icon-size-scale-range");const[_,g]=m.textSizeScaleRange,[y,x]=m.iconSizeScaleRange;if(m.textScaleFactor=K(m.scaleFactor,_,g),m.iconScaleFactor=K(m.scaleFactor,y,x),"composite"===e.textSizeData.kind){const{minZoom:t,maxZoom:i}=e.textSizeData;m.compositeTextSizes=[f["text-size"].possiblyEvaluate(new Ms(t),a),f["text-size"].possiblyEvaluate(new Ms(i),a)]}if("composite"===e.iconSizeData.kind){const{minZoom:t,maxZoom:i}=e.iconSizeData;m.compositeIconSizes=[f["icon-size"].possiblyEvaluate(new Ms(t),a),f["icon-size"].possiblyEvaluate(new Ms(i),a)]}m.layoutTextSize=f["text-size"].possiblyEvaluate(new Ms(l+1),a),m.layoutIconSize=f["icon-size"].possiblyEvaluate(new Ms(l+1),a),m.textMaxSize=f["text-size"].possiblyEvaluate(new Ms(18),a);const v="map"===p.get("text-rotation-alignment")&&"point"!==p.get("symbol-placement"),b=p.get("text-size");let w=!1;for(const t of e.features)if(t.icon&&t.icon.nameSecondary){w=!0;break}for(const o of e.features){const l=p.get("text-font").evaluate(o,{},a).join(","),h=b.evaluate(o,{},a)*m.textScaleFactor,_=m.layoutTextSize.evaluate(o,{},a)*m.textScaleFactor,g=(m.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),y=o.text;let x,T=[0,0];if(y){const r=y.toString(),s=p.get("text-letter-spacing").evaluate(o,{},a)*Lp,c=p.get("text-line-height").evaluate(o,{},a)*Lp,u=ss(r)?s:0,d=p.get("text-anchor").evaluate(o,{},a),f=p.get("text-variable-anchor");if(!f){const e=p.get("text-radial-offset").evaluate(o,{},a);T=e?Zf(d,[e*Lp,Gf]):p.get("text-offset").evaluate(o,{},a).map((e=>e*Lp))}let m=v?"center":p.get("text-justify").evaluate(o,{},a);const x="point"===p.get("symbol-placement"),b=x?p.get("text-max-width").evaluate(o,{},a)*Lp:1/0,w=o=>{e.allowVerticalPlacement&&os(r)&&(g.vertical=nf(y,t,i,n,l,b,c,d,o,u,T,ef.vertical,!0,_,h))};if(!v&&f){const e="auto"===m?f.map((e=>$f(e))):[m];let r=!1;for(let o=0;o<e.length;o++){const s=e[o];if(!g.horizontal[s])if(r)g.horizontal[s]=g.horizontal[0];else{const e=nf(y,t,i,n,l,b,c,"center",s,u,T,ef.horizontal,!1,_,h);e&&(g.horizontal[s]=e,r=1===e.positionedLines.length)}}w("left")}else{if("auto"===m&&(m=$f(d)),x||p.get("text-writing-mode").indexOf("horizontal")>=0||!os(r)){const e=nf(y,t,i,n,l,b,c,d,m,u,T,ef.horizontal,!1,_,h);e&&(g.horizontal[m]=e)}w(x?"left":m)}}let S=!1,M=!1;if(o.icon&&o.icon.namePrimary){const t=kp(e.iconSizeData,f["icon-size"],a,e.zoom,o)*m.iconScaleFactor*u,i=o.icon.getPrimary().scaleSelf(t).serialize(),s=r[i];s&&(x=ff(n[i],o.icon.nameSecondary?n[o.icon.getSecondary().scaleSelf(t).serialize()]:void 0,p.get("icon-offset").evaluate(o,{},a),p.get("icon-anchor").evaluate(o,{},a)),S=s.sdf,M=s.usvg,void 0===e.sdfIcons?e.sdfIcons=s.sdf:e.sdfIcons!==s.sdf&&ue("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(s.pixelRatio!==e.pixelRatio||0!==p.get("icon-rotate").constantOr(1))&&(e.iconsNeedLinear=!0))}const E=Kf(g.horizontal)||g.vertical;e.iconsInText||(e.iconsInText=!!E&&E.iconsInText),(E||x)&&Hf(e,o,g,x,r,m,_,0,T,S,M,s,a,c,d,w)}o&&e.generateCollisionDebugBuffers(l,e.collisionBoxArray,m.textScaleFactor)},e.e3=Qu,e.e4=fy,e.e5=V,e.e6=Ju,e.e7=Xp,e.e8=t,e.e9=function(e){let t=0;if(new Uint32Array(e,0,1)[0]!==Tx){const i=new Uint32Array(e,0,7),[,,r,n,o,s]=i;t=i.byteLength+n+o+s+o,(r!==e.byteLength||t>=e.byteLength)&&ue("Invalid b3dm header information.")}return Cx(e,t)},e.ea=function(e,t){const i=Fx(e);for(const e of i){for(const t of e.meshes)Bx(t);e.lights&&(e.lightMeshIndex=e.meshes.length,e.meshes.push(Nx(e.lights,t)))}return i},e.eb=Y_,e.ec=ng,e.ed=Ss,e.ee=function(e){Ge(),null!=Ve&&Ve.then((t=>{t.keys().then((i=>{for(let r=0;r<i.length-e;r++)t.delete(i[r])}))}))},e.f=function(e){return 0===e.indexOf("mapbox:")},e.g=function(e,t){return tt(te(e,{method:"GET"}),t)},e.h=Se,e.i=function(e){return Te.API_STYLE_REGEX.test(e)&&!Me(e)},e.j=function(e){return decodeURIComponent(atob(e).split("").map((e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2))).join(""))},e.k=function(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(Number("0x"+t)))))},e.l=te,e.m=Ze,e.n=function(e,t){return tt(te(e,{type:"json"}),t)},e.o=at,e.p=function(e,t){return tt(te(e,{method:"POST"}),t)},e.q=Re,e.r=$h,e.s=function(e){try{const t=self[e];return t.setItem("_mapbox_test_",1),t.removeItem("_mapbox_test_"),!0}catch(e){return!1}},e.t=De,e.u=function(){return function e(t){return t?(t^Math.random()*(16>>t/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,e)}()},e.v=function(e){return!!e&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)},e.w=ue,e.x=function(){return hg||(hg=new ag),hg},e.y=gt,e.z=_t})),r(0,(function(e){function t(e){const t=e?e.url.toString():void 0;return t?performance.getEntriesByName(t):[]}function i(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return JSON.stringify(e);if(Array.isArray(e)){let t="[";for(const r of e)t+=`${i(r)},`;return`${t}]`}let t="{";for(const r of Object.keys(e).sort())t+=`${r}:${i(e[r])},`;return`${t}}`}function r(t){let r="";for(const n of e.bm)r+=`/${i(t[n])}`;return r}class n{constructor(e){this.keyCache={},this._layers={},this._layerConfigs={},e&&this.replace(e)}replace(e,t){this._layerConfigs={},this._layers={},this.update(e,[],t)}update(t,n,o){this._options=o;for(const i of t)this._layerConfigs[i.id]=i,(this._layers[i.id]=e.cu(i,this.scope,null,this._options)).compileFilter(o),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const e of n)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const s=function(e,t){const n={};for(let o=0;o<e.length;o++){const s=e[o];let a=t&&t[s.id];!a&&(a=r(s),"line"===s.type&&s.paint)&&function e(t){return"string"==typeof t&&"line-progress"===t||(Array.isArray(t)?t.some(e):!(!t||"object"!=typeof t)&&Object.values(t).some(e))}(s.paint["line-width"])&&(a+=`/${i(s.paint["line-width"])}`),t&&(t[s.id]=a);let l=n[a];l||(l=n[a]=[]),l.push(s)}const o=[];for(const e in n)o.push(n[e]);return o}(e.bj(this._layerConfigs),this.keyCache);for(const e of s){const t=e.map((e=>this._layers[e.id])),i=t[0];if("none"===i.visibility)continue;const r=i.source||"";let n=this.familiesBySource[r];n||(n=this.familiesBySource[r]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=n[o];s||(s=n[o]=[]),s.push(t)}}}const o=1*e.dX;class s{constructor(t){const i={},r=[];for(const e in t){const n=t[e],s=i[e]={};for(const e in n.glyphs){const t=n.glyphs[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const i=t.metrics.localGlyph?o:1,a={x:0,y:0,w:t.bitmap.width+2*i,h:t.bitmap.height+2*i};r.push(a),s[e]=a}}const{w:n,h:s}=e.C(r),a=new e.dW({width:n||1,height:s||1});for(const r in t){const n=t[r];for(const t in n.glyphs){const s=n.glyphs[+t];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[r][t],c=s.metrics.localGlyph?o:1;e.dW.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}e.dV(s,"GlyphAtlas");class a{constructor(t){this.tileID=new e.aG(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.lut=t.lut,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.scope=t.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.request&&t.request.collectResourceTiming,this.promoteId=t.promoteId,this.isSymbolTile=t.isSymbolTile,this.tileTransform=e.aQ(t.tileID.canonical,t.projection),this.projection=t.projection,this.worldview=t.worldview,this.localizableLayerIds=t.localizableLayerIds,this.brightness=t.brightness,this.extraShadowCaster=!!t.extraShadowCaster,this.tessellationStep=t.tessellationStep,this.scaleFactor=t.scaleFactor}parse(t,i,r,n,o){this.status="parsing",this.data=t,this.collisionBoxArray=new e.aW;const a=new e.dY(Object.keys(t.layers).sort()),c=new e.dZ(this.tileID,this.promoteId);c.bucketLayerIDs=[];const h={},u=new e.d_(256,256),d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:r,brightness:this.brightness,scaleFactor:this.scaleFactor},p=i.familiesBySource[this.source];for(const i in p){const n=t.layers[i];if(!n)continue;let o=!1,s=!1,u=!1;for(const e of p[i])"symbol"===e[0].type?o=!0:s=!0,e[0].is3D()&&"model"!==e[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===n.version&&e.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let e=0,t=0;e<n.length;e++){const r=n.feature(e),o=c.getId(r,i);if(this.localizableLayerIds&&this.localizableLayerIds.has(i)){const e=r.properties?r.properties.worldview:null;if(this.worldview&&"string"==typeof e)if("all"===e)r.properties.$localized=!0;else{if(!e.split(",").includes(this.worldview))continue;r.properties.$localized=!0,r.properties.worldview=this.worldview}}m.push({feature:r,id:o,index:t,sourceLayerIndex:f}),t++}for(const t of p[i]){const i=t[0];(!this.extraShadowCaster||i.is3D()&&"model"!==i.type)&&(void 0!==this.isSymbolTile&&"symbol"===i.type!==this.isSymbolTile||i.minzoom&&this.zoom<Math.floor(i.minzoom)||i.maxzoom&&this.zoom>=i.maxzoom||"none"!==i.visibility&&(l(t,this.zoom,d.brightness,r),(h[i.id]=i.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,d,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>e.aC(t.id,t.scope))))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},x=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:e.bj(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(m&&_&&g){const t=new s(m),i=new e.e1(_,g,this.lut);for(const n in h){const o=h[n];o instanceof e.aX?(l(o.layers,this.zoom,d.brightness,r),e.e2(o,m,t.positions,_,i.iconPositions,this.showCollisionBoxes,r,this.tileID.canonical,this.tileZoom,this.projection,this.scaleFactor,this.pixelRatio,this.brightness)):o.hasPattern&&(o instanceof e.b1||o instanceof e.b2||o instanceof e.d5)&&(l(o.layers,this.zoom,d.brightness,r),o.addFeatures(d,this.tileID.canonical,i.patternPositions,r,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:e.bj(h).filter((e=>!e.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:t.image,lineAtlas:u,imageAtlas:i,brightness:d.brightness})}};if(!this.extraShadowCaster){const t=e.d$(d.glyphDependencies,(e=>Object.keys(e).map(Number)));Object.keys(t).length?n.send("getGlyphs",{uid:this.uid,stacks:t,scope:this.scope},((e,t)=>{f||(f=e,m=t,x())}),void 0,!1,y):m={};const i=Object.keys(d.iconDependencies);i.length?n.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((e,t)=>{if(f)return;f=e;const i={};Object.values(t).some((e=>e.usvg))?this.rasterize(n,i,t,d.iconDependencies,(()=>{_=i,x()})):(this.fillImageMap(i,d.iconDependencies,t),_=i,x())}),void 0,!1,y):_={};const r=Object.keys(d.patternDependencies);r.length?n.send("getImages",{icons:r,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((e,t)=>{if(!f){f=e;const i={};Object.values(t).some((e=>e.usvg))?this.rasterize(n,i,t,d.patternDependencies,(()=>{g=i,x()})):(this.fillImageMap(i,d.patternDependencies,t),g=i,x())}}),void 0,!1,y):g={}}x()}fillImageMap(e,t,i){for(const r in i){const n=t[r]||[];for(const t of n)i[t.id].usvg||(e[t.serialize()]=i[t.id])}}getImageTaskQueue(e,t,i){const r={};for(const n in t){const o=i[n]||[];for(const i of o){const n=i.serialize();t[i.id].usvg?r[n]||(r[n]=i):e[n]=t[i.id]}}return r}rasterize(t,i,r,n,o){const s=this.getImageTaskQueue(i,r,n);this.rasterizeTask=t.send("rasterizeImages",{scope:this.scope,imageTasks:s},((t,n)=>{if(!t)for(const t in n){const{id:o}=e.e0.deserializeFromString(t);i[t]={...r[o],data:n[t]}}o()}))}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel()}}function l(t,i,r,n){const o=new e.a8(i,{brightness:r});for(const e of t)e.recalculate(o,n)}class c extends e.E{constructor(t,i,r,n,o,s){super(),this.actor=t,this.layerIndex=i,this.availableImages=r,this.loadVectorData=o||e.aD,this.loading={},this.loaded={},this.deduped=new e.aB(t.scheduler),this.isSpriteLoaded=n,this.scheduler=t.scheduler,this.brightness=s}loadTile(i,r){const n=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[n]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const h=!this.loading[n];if(delete this.loading[n],l.cancelRasterize(),h||a||!c)return l.status="done",h||(this.loaded[n]=l),r(a);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new e.e3.VectorTile(new e.bh(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,n)=>{if(i||!n)return r(i);const a={};if(s){const e=t(o);e.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(e)))}r(null,e.l({rawTileData:u.slice(0)},n,d,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[n]=l}))}reloadTile(t,i){const r=this.loaded,n=t.uid;if(r&&r[n]){const o=r[n];o.scaleFactor=t.scaleFactor,o.showCollisionBoxes=t.showCollisionBoxes,o.projection=t.projection,o.brightness=t.brightness,o.tileTransform=e.aQ(t.tileID.canonical,t.projection),o.extraShadowCaster=t.extraShadowCaster,o.lut=t.lut;const s=(e,t)=>{const r=o.reloadCallback;r&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,r)),i(e,t)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(e,t){const i=e.uid,r=this.loading[i];r&&(r.abort&&r.abort(),delete this.loading[i]),t()}removeTile(e,t){const i=this.loaded,r=e.uid;i&&i[r]&&delete i[r],t()}}class h{loadTile(t,i){const{uid:r,encoding:n,rawImageData:o,padding:s}=t,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new e.e4(r,a,n,s<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 i=this.offscreenCanvasContext.getImageData(-t,-t,e.width+2*t,e.height+2*t);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),i}}e.bg.setPbf(e.bh);class u{decodeRasterArray({task:t,buffer:i},r){e.bg.performDecoding(i,t).then((e=>{r(null,e)}),(e=>{r(e)}))}}const d=e.e3.VectorTileFeature.prototype.toGeoJSON;class p{constructor(t){this._feature=t,this.extent=e.ag,this.type=t.type,this.properties=t.tags,"id"in t&&!isNaN(t.id)&&(this.id=parseInt(t.id,10))}loadGeometry(){if(1===this._feature.type){const t=[];for(const i of this._feature.geometry)t.push([new e.P(i[0],i[1])]);return t}{const t=[];for(const i of this._feature.geometry){const r=[];for(const t of i)r.push(new e.P(t[0],t[1]));t.push(r)}return t}}toGeoJSON(e,t,i){return d.call(this,e,t,i)}}class f{constructor(t){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=e.ag,this.length=t.length,this._features=t}feature(e){return new p(this._features[e])}}const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(e=[],t){for(const i of e){const e=i.id;if(null==e)continue;let r=this.features.get(e);r&&this.updateCache(r,t),i.geometry?(r=y(i),this.updateCache(r,t),this.features.set(e,r)):this.features.delete(e),this.updateCache(r,t)}}updateCache(e,t){for(const{canonical:i,uid:r}of Object.values(t)){const{z:n,x:o,y:s}=i;g(e,Math.pow(2,n),o,s)&&delete t[r]}}getTile(e,t,i){const r=Math.pow(2,e),n=[];for(const e of this.features.values())g(e,r,t,i)&&n.push(w(e,r,t,i));return{features:n}}getFeatures(){return[...this.features.values()]}}function g({minX:e,minY:t,maxX:i,maxY:r},n,o,s){return e<(o+1+m)/n&&t<(s+1+m)/n&&i>(o-m)/n&&r>(s-m)/n}function y(e){const{id:t,geometry:i,properties:r}=e;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:n,coordinates:o}=i,s={id:t,type:1,geometry:[],tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===n)x(o,a,s);else if("MultiPoint"===n)for(const e of o)x(e,a,s);else if("LineString"===n)s.type=2,v(o,a,s);else if("MultiLineString"===n)s.type=2,b(o,a,s);else if("Polygon"===n)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==n)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const e of o)b(e,a,s,!0)}return s}function x([t,i],r,n){const o=e.at(t);let s=e.aA(i);s=s<0?0:s>1?1:s,r.push(o,s),n.minX=Math.min(n.minX,o),n.minY=Math.min(n.minY,s),n.maxX=Math.max(n.maxX,o),n.maxY=Math.max(n.maxY,s)}function v(e,t,i,r=!1,n=!1){const o=[];for(const t of e)x(t,o,i);t.push(o),r&&function(e,t){let i=0;for(let t=0,r=e.length,n=r-2;t<r;n=t,t+=2)i+=(e[t]-e[n])*(e[t+1]+e[n+1]);if(i>0===t)for(let t=0,i=e.length;t<i/2;t+=2){const r=e[t],n=e[t+1];e[t]=e[i-2-t],e[t+1]=e[i-1-t],e[i-2-t]=r,e[i-1-t]=n}}(o,n)}function b(e,t,i,r=!1){for(let n=0;n<e.length;n++)v(e[n],t,i,r,0===n)}function w(t,i,r,n){const{id:o,type:s,geometry:a,tags:l}=t,c=[];if(1===s)!function(t,i,r,n,o){for(let s=0;s<t.length;s+=2){const a=Math.round(e.ag*(t[s+0]*i-r)),l=Math.round(e.ag*(t[s+1]*i-n));o.push([a,l])}}(a,i,r,n,c);else for(const e of a)T(e,i,r,n,c);return{id:o,type:s,geometry:c,tags:l}}function T(t,i,r,n,o){const s=-128,a=e.ag+128;let l;for(let c=0;c<t.length-2;c+=2){let h=Math.round(e.ag*(t[c+0]*i-r)),u=Math.round(e.ag*(t[c+1]*i-n)),d=Math.round(e.ag*(t[c+2]*i-r)),p=Math.round(e.ag*(t[c+3]*i-n));const f=d-h,m=p-u;h<s&&d<s||(h<s?(u+=Math.round(m*((s-h)/f)),h=s):d<s&&(p=u+Math.round(m*((s-h)/f)),d=s),u<s&&p<s||(u<s?(h+=Math.round(f*((s-u)/m)),u=s):p<s&&(d=h+Math.round(f*((s-u)/m)),p=s),h>=a&&d>=a||(h>=a?(u+=Math.round(m*((a-h)/f)),h=a):d>=a&&(p=u+Math.round(m*((a-h)/f)),d=a),u>=a&&p>=a||(u>=a?(h+=Math.round(f*((a-u)/m)),u=a):p>=a&&(d=h+Math.round(f*((a-u)/m)),p=a),l&&h===l[l.length-1][0]&&u===l[l.length-1][1]||(l=[[h,u]],o.push(l)),l.push([d,p])))))}}var S,M,E,A={exports:{}},I=function(){if(E)return A.exports;E=1;var t=e.e7(),i=function(){if(M)return S;M=1;var t=e.e5(),i=e.e6().VectorTileFeature;function r(e,t){this.options=t||{},this.features=e,this.length=e.length}function n(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 S=r,r.prototype.feature=function(e){return new n(this.features[e],this.options.extent)},n.prototype.loadGeometry=function(){var e=this.rawGeometry;this.geometry=[];for(var i=0;i<e.length;i++){for(var r=e[i],n=[],o=0;o<r.length;o++)n.push(new t(r[o][0],r[o][1]));this.geometry.push(n)}return this.geometry},n.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var e=this.geometry,t=1/0,i=-1/0,r=1/0,n=-1/0,o=0;o<e.length;o++)for(var s=e[o],a=0;a<s.length;a++){var l=s[a];t=Math.min(t,l.x),i=Math.max(i,l.x),r=Math.min(r,l.y),n=Math.max(n,l.y)}return[t,r,i,n]},n.prototype.toGeoJSON=i.prototype.toGeoJSON,S}();function r(e){var i=new t;return function(e,t){for(var i in e.layers)t.writeMessage(3,n,e.layers[i])}(e,i),i.finish()}function n(e,t){var i;t.writeVarintField(15,e.version||1),t.writeStringField(1,e.name||""),t.writeVarintField(5,e.extent||4096);var r={keys:[],values:[],keycache:{},valuecache:{}};for(i=0;i<e.length;i++)r.feature=e.feature(i),t.writeMessage(2,o,r);var n=r.keys;for(i=0;i<n.length;i++)t.writeStringField(3,n[i]);var s=r.values;for(i=0;i<s.length;i++)t.writeMessage(4,h,s[i])}function o(e,t){var i=e.feature;void 0!==i.id&&t.writeVarintField(1,i.id),t.writeMessage(2,s,e),t.writeVarintField(3,i.type),t.writeMessage(4,c,i)}function s(e,t){var i=e.feature,r=e.keys,n=e.values,o=e.keycache,s=e.valuecache;for(var a in i.properties){var l=i.properties[a],c=o[a];if(null!==l){void 0===c&&(r.push(a),o[a]=c=r.length-1),t.writeVarint(c);var h=typeof l;"string"!==h&&"boolean"!==h&&"number"!==h&&(l=JSON.stringify(l));var u=h+":"+l,d=s[u];void 0===d&&(n.push(l),s[u]=d=n.length-1),t.writeVarint(d)}}}function a(e,t){return(t<<3)+(7&e)}function l(e){return e<<1^e>>31}function c(e,t){for(var i=e.loadGeometry(),r=e.type,n=0,o=0,s=i.length,c=0;c<s;c++){var h=i[c],u=1;1===r&&(u=h.length),t.writeVarint(a(1,u));for(var d=3===r?h.length-1:h.length,p=0;p<d;p++){1===p&&1!==r&&t.writeVarint(a(2,d-1));var f=h[p].x-n,m=h[p].y-o;t.writeVarint(l(f)),t.writeVarint(l(m)),n+=f,o+=m}3===r&&t.writeVarint(a(7,1))}}function h(e,t){var i=typeof e;"string"===i?t.writeStringField(1,e):"boolean"===i?t.writeBooleanField(7,e):"number"===i&&(e%1!=0?t.writeDoubleField(3,e):e<0?t.writeSVarintField(6,e):t.writeVarintField(5,e))}return A.exports=r,A.exports.fromVectorTileJs=r,A.exports.fromGeojsonVt=function(e,t){t=t||{};var n={};for(var o in e)n[o]=new i(e[o].features,t),n[o].name=o,n[o].version=t.version,n[o].extent=t.extent;return r({layers:n})},A.exports.GeoJSONWrapper=i,A.exports}(),C=e.e8(I);const P={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e},z=Math.fround||(D=new Float32Array(1),e=>(D[0]=+e,D[0]));var D;class R{constructor(e){this.options=Object.assign(Object.create(P),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:t,minZoom:i,maxZoom:r}=this.options;t&&console.time("total time");const n=`prepare ${e.length} points`;t&&console.time(n),this.points=e;const o=[];for(let t=0;t<e.length;t++){const i=e[t];if(!i.geometry)continue;const[r,n]=i.geometry.coordinates,s=z(k(r)),a=z(F(n));o.push(s,a,1/0,t,-1,1),this.options.reduce&&o.push(0)}let s=this.trees[r+1]=this._createTree(o);t&&console.timeEnd(n);for(let e=r;e>=i;e--){const i=+Date.now();s=this.trees[e]=this._createTree(this._cluster(s,e)),t&&console.log("z%d: %d clusters in %dms",e,s.numItems,+Date.now()-i)}return t&&console.timeEnd("total time"),this}getClusters(e,t){let i=((e[0]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,e[1]));let n=180===e[2]?180:((e[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)i=-180,n=180;else if(i>n){const e=this.getClusters([i,r,180,o],t),s=this.getClusters([-180,r,n,o],t);return e.concat(s)}const s=this.trees[this._limitZoom(t)],a=s.range(k(i),F(o),k(n),F(r)),l=s.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+5]>1?L(l,t,this.clusterProps):this.points[l[t+3]])}return c}getChildren(e){const t=this._getOriginId(e),i=this._getOriginZoom(e),r="No cluster with the specified id.",n=this.trees[i];if(!n)throw new Error(r);const o=n.data;if(t*this.stride>=o.length)throw new Error(r);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=n.within(o[t*this.stride],o[t*this.stride+1],s),l=[];for(const t of a){const i=t*this.stride;o[i+4]===e&&l.push(o[i+5]>1?L(o,i,this.clusterProps):this.points[o[i+3]])}if(0===l.length)throw new Error(r);return l}getLeaves(e,t,i){const r=[];return this._appendLeaves(r,e,t=t||10,i=i||0,0),r}getTile(e,t,i){const r=this.trees[this._limitZoom(e)],n=Math.pow(2,e),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/n,c=(i+1+a)/n,h={features:[]};return this._addTileFeatures(r.range((t-a)/n,l,(t+1+a)/n,c),r.data,t,i,n,h),0===t&&this._addTileFeatures(r.range(1-a/n,l,1,c),r.data,n,i,n,h),t===n-1&&this._addTileFeatures(r.range(0,l,a/n,c),r.data,-1,i,n,h),h.features.length?h:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const i=this.getChildren(e);if(t++,1!==i.length)break;e=i[0].properties.cluster_id}return t}_appendLeaves(e,t,i,r,n){const o=this.getChildren(t);for(const t of o){const o=t.properties;if(o&&o.cluster?n+o.point_count<=r?n+=o.point_count:n=this._appendLeaves(e,o.cluster_id,i,r,n):n<r?n++:e.push(t),e.length===i)break}return n}_createTree(t){const i=new e.bE(t.length/this.stride|0,this.options.nodeSize,Float32Array);for(let e=0;e<t.length;e+=this.stride)i.add(t[e],t[e+1]);return i.finish(),i.data=t,i}_addTileFeatures(e,t,i,r,n,o){for(const s of e){const e=s*this.stride,a=t[e+5]>1;let l,c,h;if(a)l=O(t,e,this.clusterProps),c=t[e],h=t[e+1];else{const i=this.points[t[e+3]];l=i.properties;const[r,n]=i.geometry.coordinates;c=k(r),h=F(n)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*n-i)),Math.round(this.options.extent*(h*n-r))]],tags:l};let d;d=a||this.options.generateId?t[e+3]:this.points[t[e+3]].id,void 0!==d&&(u.id=d),o.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:i,extent:r,reduce:n,minPoints:o}=this.options,s=i/(r*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let i=0;i<a.length;i+=c){if(a[i+2]<=t)continue;a[i+2]=t;const r=a[i],h=a[i+1],u=e.within(a[i],a[i+1],s),d=a[i+5];let p=d;for(const e of u){const i=e*c;a[i+2]>t&&(p+=a[i+5])}if(p>d&&p>=o){let e,o=r*d,s=h*d,f=-1;const m=(i/c<<5)+(t+1)+this.points.length;for(const r of u){const l=r*c;if(a[l+2]<=t)continue;a[l+2]=t;const h=a[l+5];o+=a[l]*h,s+=a[l+1]*h,a[l+4]=m,n&&(e||(e=this._map(a,i,!0),f=this.clusterProps.length,this.clusterProps.push(e)),n(e,this._map(a,l)))}a[i+4]=m,l.push(o/p,s/p,1/0,m,-1,p),n&&l.push(f)}else{for(let e=0;e<c;e++)l.push(a[i+e]);if(p>1)for(const e of u){const i=e*c;if(!(a[i+2]<=t)){a[i+2]=t;for(let e=0;e<c;e++)l.push(a[i+e])}}}}return l}_getOriginId(e){return e-this.points.length>>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t,i){if(e[t+5]>1){const r=this.clusterProps[e[t+6]];return i?Object.assign({},r):r}const r=this.points[e[t+3]].properties,n=this.options.map(r);return i&&n===r?Object.assign({},n):n}}function L(e,t,i){return{type:"Feature",id:e[t+3],properties:O(e,t,i),geometry:{type:"Point",coordinates:[(r=e[t],360*(r-.5)),B(e[t+1])]}};var r}function O(e,t,i){const r=e[t+5],n=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r,o=e[t+6],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:e[t+3],point_count:r,point_count_abbreviated:n})}function k(e){return e/360+.5}function F(e){const t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}function B(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function N(e,t,i,r){let n=r;const o=t+(i-t>>1);let s,a=i-t;const l=e[t],c=e[t+1],h=e[i],u=e[i+1];for(let r=t+3;r<i;r+=3){const t=V(e[r],e[r+1],l,c,h,u);if(t>n)s=r,n=t;else if(t===n){const e=Math.abs(r-o);e<a&&(s=r,a=e)}}n>r&&(s-t>3&&N(e,t,s,r),e[s+2]=n,i-s>3&&N(e,s,i,r))}function V(e,t,i,r,n,o){let s=n-i,a=o-r;if(0!==s||0!==a){const l=((e-i)*s+(t-r)*a)/(s*s+a*a);l>1?(i=n,r=o):l>0&&(i+=s*l,r+=a*l)}return s=e-i,a=t-r,s*s+a*a}function U(e,t,i,r){const n={id:e??null,type:t,geometry:i,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)j(n,i);else if("Polygon"===t)j(n,i[0]);else if("MultiLineString"===t)for(const e of i)j(n,e);else if("MultiPolygon"===t)for(const e of i)j(n,e[0]);return n}function j(e,t){for(let i=0;i<t.length;i+=3)e.minX=Math.min(e.minX,t[i]),e.minY=Math.min(e.minY,t[i+1]),e.maxX=Math.max(e.maxX,t[i]),e.maxY=Math.max(e.maxY,t[i+1])}function G(e,t,i,r){if(!t.geometry)return;const n=t.geometry.coordinates;if(n&&0===n.length)return;const o=t.geometry.type,s=Math.pow(i.tolerance/((1<<i.maxZoom)*i.extent),2);let a=[],l=t.id;if(i.promoteId?l=t.properties[i.promoteId]:i.generateId&&(l=r||0),"Point"===o)q(n,a);else if("MultiPoint"===o)for(const e of n)q(e,a);else if("LineString"===o)Z(n,a,s,!1);else if("MultiLineString"===o){if(i.lineMetrics){for(const i of n)a=[],Z(i,a,s,!1),e.push(U(l,"LineString",a,t.properties));return}$(n,a,s,!1)}else if("Polygon"===o)$(n,a,s,!0);else{if("MultiPolygon"!==o){if("GeometryCollection"===o){for(const n of t.geometry.geometries)G(e,{id:l,geometry:n,properties:t.properties},i,r);return}throw new Error("Input data is not a valid GeoJSON object.")}for(const e of n){const t=[];$(e,t,s,!0),a.push(t)}}e.push(U(l,o,a,t.properties))}function q(e,t){t.push(H(e[0]),W(e[1]),0)}function Z(e,t,i,r){let n,o,s=0;for(let i=0;i<e.length;i++){const a=H(e[i][0]),l=W(e[i][1]);t.push(a,l,0),i>0&&(s+=r?(n*l-a*o)/2:Math.sqrt(Math.pow(a-n,2)+Math.pow(l-o,2))),n=a,o=l}const a=t.length-3;t[2]=1,N(t,0,a,i),t[a+2]=1,t.size=Math.abs(s),t.start=0,t.end=t.size}function $(e,t,i,r){for(let n=0;n<e.length;n++){const o=[];Z(e[n],o,i,r),t.push(o)}}function H(e){return e/360+.5}function W(e){const t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}function X(e,t,i,r,n,o,s,a){if(r/=t,o>=(i/=t)&&s<r)return e;if(s<i||o>=r)return null;const l=[];for(const t of e){const e=t.geometry;let o=t.type;const s=0===n?t.minX:t.minY,c=0===n?t.maxX:t.maxY;if(s>=i&&c<r){l.push(t);continue}if(c<i||s>=r)continue;let h=[];if("Point"===o||"MultiPoint"===o)Y(e,h,i,r,n);else if("LineString"===o)K(e,h,i,r,n,!1,a.lineMetrics);else if("MultiLineString"===o)Q(e,h,i,r,n,!1);else if("Polygon"===o)Q(e,h,i,r,n,!0);else if("MultiPolygon"===o)for(const t of e){const e=[];Q(t,e,i,r,n,!0),e.length&&h.push(e)}if(h.length){if(a.lineMetrics&&"LineString"===o){for(const e of h)l.push(U(t.id,o,e,t.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===h.length?(o="LineString",h=h[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===h.length?"Point":"MultiPoint"),l.push(U(t.id,o,h,t.tags))}}return l.length?l:null}function Y(e,t,i,r,n){for(let o=0;o<e.length;o+=3){const s=e[o+n];s>=i&&s<=r&&ee(t,e[o],e[o+1],e[o+2])}}function K(e,t,i,r,n,o,s){let a=J(e);const l=0===n?te:ie;let c,h,u=e.start;for(let d=0;d<e.length-3;d+=3){const p=e[d],f=e[d+1],m=e[d+2],_=e[d+3],g=e[d+4],y=0===n?p:f,x=0===n?_:g;let v=!1;s&&(c=Math.sqrt(Math.pow(p-_,2)+Math.pow(f-g,2))),y<i?x>i&&(h=l(a,p,f,_,g,i),s&&(a.start=u+c*h)):y>r?x<r&&(h=l(a,p,f,_,g,r),s&&(a.start=u+c*h)):ee(a,p,f,m),x<i&&y>=i&&(h=l(a,p,f,_,g,i),v=!0),x>r&&y<=r&&(h=l(a,p,f,_,g,r),v=!0),!o&&v&&(s&&(a.end=u+c*h),t.push(a),a=J(e)),s&&(u+=c)}let d=e.length-3;const p=e[d],f=e[d+1],m=0===n?p:f;m>=i&&m<=r&&ee(a,p,f,e[d+2]),d=a.length-3,o&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&ee(a,a[0],a[1],a[2]),a.length&&t.push(a)}function J(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function Q(e,t,i,r,n,o){for(const s of e)K(s,t,i,r,n,o,!1)}function ee(e,t,i,r){e.push(t,i,r)}function te(e,t,i,r,n,o){const s=(o-t)/(r-t);return ee(e,o,i+(n-i)*s,1),s}function ie(e,t,i,r,n,o){const s=(o-i)/(n-i);return ee(e,t+(r-t)*s,o,1),s}function re(e,t){const i=[];for(let r=0;r<e.length;r++){const n=e[r],o=n.type;let s;if("Point"===o||"MultiPoint"===o||"LineString"===o)s=ne(n.geometry,t);else if("MultiLineString"===o||"Polygon"===o){s=[];for(const e of n.geometry)s.push(ne(e,t))}else if("MultiPolygon"===o){s=[];for(const e of n.geometry){const i=[];for(const r of e)i.push(ne(r,t));s.push(i)}}i.push(U(n.id,o,s,n.tags))}return i}function ne(e,t){const i=[];i.size=e.size,void 0!==e.start&&(i.start=e.start,i.end=e.end);for(let r=0;r<e.length;r+=3)i.push(e[r]+t,e[r+1],e[r+2]);return i}function oe(e,t){if(e.transformed)return e;const i=1<<e.z,r=e.x,n=e.y;for(const o of e.features){const e=o.geometry,s=o.type;if(o.geometry=[],1===s)for(let s=0;s<e.length;s+=2)o.geometry.push(se(e[s],e[s+1],t,i,r,n));else for(let s=0;s<e.length;s++){const a=[];for(let o=0;o<e[s].length;o+=2)a.push(se(e[s][o],e[s][o+1],t,i,r,n));o.geometry.push(a)}}return e.transformed=!0,e}function se(e,t,i,r,n,o){return[Math.round(i*(e*r-n)),Math.round(i*(t*r-o))]}function ae(e,t,i,r,n){const o=t===n.maxZoom?0:n.tolerance/((1<<t)*n.extent),s={features:[],numPoints:0,numSimplified:0,numFeatures:e.length,source:null,x:i,y:r,z:t,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const t of e)le(s,t,o,n);return s}function le(e,t,i,r){const n=t.geometry,o=t.type,s=[];if(e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),"Point"===o||"MultiPoint"===o)for(let t=0;t<n.length;t+=3)s.push(n[t],n[t+1]),e.numPoints++,e.numSimplified++;else if("LineString"===o)ce(s,n,e,i,!1,!1);else if("MultiLineString"===o||"Polygon"===o)for(let t=0;t<n.length;t++)ce(s,n[t],e,i,"Polygon"===o,0===t);else if("MultiPolygon"===o)for(let t=0;t<n.length;t++){const r=n[t];for(let t=0;t<r.length;t++)ce(s,r[t],e,i,!0,0===t)}if(s.length){let i=t.tags||null;if("LineString"===o&&r.lineMetrics){i={};for(const e in t.tags)i[e]=t.tags[e];i.mapbox_clip_start=n.start/n.size,i.mapbox_clip_end=n.end/n.size}const a={geometry:s,type:"Polygon"===o||"MultiPolygon"===o?3:"LineString"===o||"MultiLineString"===o?2:1,tags:i};null!==t.id&&(a.id=t.id),e.features.push(a)}}function ce(e,t,i,r,n,o){const s=r*r;if(r>0&&t.size<(n?s:r))return void(i.numPoints+=t.length/3);const a=[];for(let e=0;e<t.length;e+=3)(0===r||t[e+2]>s)&&(i.numSimplified++,a.push(t[e],t[e+1])),i.numPoints++;n&&function(e,t){let i=0;for(let t=0,r=e.length,n=r-2;t<r;n=t,t+=2)i+=(e[t]-e[n])*(e[t+1]+e[n+1]);if(i>0===t)for(let t=0,i=e.length;t<i/2;t+=2){const r=e[t],n=e[t+1];e[t]=e[i-2-t],e[t+1]=e[i-1-t],e[i-2-t]=r,e[i-1-t]=n}}(a,o),e.push(a)}const he={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0};class ue{constructor(e,t){const i=(t=this.options=function(e,t){for(const i in t)e[i]=t[i];return e}(Object.create(he),t)).debug;if(i&&console.time("preprocess data"),t.maxZoom<0||t.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");let r=function(e,t){const i=[];if("FeatureCollection"===e.type)for(let r=0;r<e.features.length;r++)G(i,e.features[r],t,r);else G(i,"Feature"===e.type?e:{geometry:e},t);return i}(e,t);this.tiles={},this.tileCoords=[],i&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",t.indexMaxZoom,t.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),r=function(e,t){const i=t.buffer/t.extent;let r=e;const n=X(e,1,-1-i,i,0,-1,2,t),o=X(e,1,1-i,2+i,0,-1,2,t);return(n||o)&&(r=X(e,1,-i,1+i,0,-1,2,t)||[],n&&(r=re(n,1).concat(r)),o&&(r=r.concat(re(o,-1)))),r}(r,t),r.length&&this.splitTile(r,0,0,0),i&&(r.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}splitTile(e,t,i,r,n,o,s){const a=[e,t,i,r],l=this.options,c=l.debug;for(;a.length;){r=a.pop(),i=a.pop(),t=a.pop(),e=a.pop();const h=1<<t,u=de(t,i,r);let d=this.tiles[u];if(!d&&(c>1&&console.time("creation"),d=this.tiles[u]=ae(e,t,i,r,l),this.tileCoords.push({z:t,x:i,y:r}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,i,r,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));const e=`z${t}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}if(d.source=e,null==n){if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else{if(t===l.maxZoom||t===n)continue;if(null!=n){const e=n-t;if(i!==o>>e||r!==s>>e)continue}}if(d.source=null,0===e.length)continue;c>1&&console.time("clipping");const p=.5*l.buffer/l.extent,f=.5-p,m=.5+p,_=1+p;let g=null,y=null,x=null,v=null,b=X(e,h,i-p,i+m,0,d.minX,d.maxX,l),w=X(e,h,i+f,i+_,0,d.minX,d.maxX,l);e=null,b&&(g=X(b,h,r-p,r+m,1,d.minY,d.maxY,l),y=X(b,h,r+f,r+_,1,d.minY,d.maxY,l),b=null),w&&(x=X(w,h,r-p,r+m,1,d.minY,d.maxY,l),v=X(w,h,r+f,r+_,1,d.minY,d.maxY,l),w=null),c>1&&console.timeEnd("clipping"),a.push(g||[],t+1,2*i,2*r),a.push(y||[],t+1,2*i,2*r+1),a.push(x||[],t+1,2*i+1,2*r),a.push(v||[],t+1,2*i+1,2*r+1)}}getTile(e,t,i){e=+e,t=+t,i=+i;const r=this.options,{extent:n,debug:o}=r;if(e<0||e>24)return null;const s=1<<e,a=de(e,t=t+s&s-1,i);if(this.tiles[a])return oe(this.tiles[a],n);o>1&&console.log("drilling down to z%d-%d-%d",e,t,i);let l,c=e,h=t,u=i;for(;!l&&c>0;)c--,h>>=1,u>>=1,l=this.tiles[de(c,h,u)];return l&&l.source?(o>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,i),o>1&&console.timeEnd("drilling down"),this.tiles[a]?oe(this.tiles[a],n):null):null}}function de(e,t,i){return 32*((1<<e)*i+t)+e}function pe(e,t){const i=e.tileID.canonical;if(!this._geoJSONIndex)return void t(null,null);const r=this._geoJSONIndex.getTile(i.z,i.x,i.y);if(!r)return void t(null,null);const n=new f(r.features);let o=C(n);0===o.byteOffset&&o.byteLength===o.buffer.byteLength||(o=new Uint8Array(o)),t(null,{vectorTile:n,rawData:o.buffer})}class fe extends c{constructor(e,t,i,r,n,o){super(e,t,i,r,pe,o),n&&(this.loadGeoJSON=n),this._dynamicIndex=new _}loadData(i,r){const n=i&&i.request,o=n&&n.collectResourceTiming;this.loadGeoJSON(i,((s,a)=>{if(s||!a)return r(s);if("object"!=typeof a)return r(new Error(`Input data given to '${i.source}' is not a valid GeoJSON object.`));{try{if(i.filter){const t=e.U(i.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===t.result)throw new Error(t.value.map((e=>`${e.key}: ${e.message}`)).join(", "));a.features=a.features.filter((e=>t.value.evaluate({zoom:0},e)))}i.dynamic?("Feature"===a.type&&(a={type:"FeatureCollection",features:[a]}),i.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(a.features,this.loaded),i.cluster&&(a.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=i.cluster?new R(function({superclusterOptions:t,clusterProperties:i}){if(!i||!t)return t;const r={},n={},o={accumulated:null,zoom:0},s={properties:null},a=Object.keys(i);for(const t of a){const[o,s]=i[t],a=e.U(s),l=e.U("string"==typeof o?[o,["accumulated"],["get",t]]:o);r[t]=a.value,n[t]=l.value}return t.map=e=>{s.properties=e;const t={};for(const e of a)t[e]=r[e].evaluate(o,s);return t},t.reduce=(e,t)=>{s.properties=t;for(const t of a)o.accumulated=e[t],e[t]=n[t].evaluate(o,s)},t}(i)).load(a.features):i.dynamic?this._dynamicIndex:function(e,t){return new ue(e,t)}(a,i.geojsonVtOptions)}catch(e){return r(e)}const s={};if(o){const e=t(n);e&&(s.resourceTiming={},s.resourceTiming[i.source]=JSON.parse(JSON.stringify(e)))}r(null,s)}}))}reloadTile(e,t){const i=this.loaded;return i&&i[e.uid]?e.partial?t(null,void 0):super.reloadTile(e,t):this.loadTile(e,t)}loadGeoJSON(t,i){if(t.request)e.n(t.request,i);else{if("string"!=typeof t.data)return i(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));try{return i(null,JSON.parse(t.data))}catch(e){return i(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`))}}}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 me{constructor(t,i){this.tileID=new e.aG(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=t.projection,this.brightness=i}parse(t,i,r,n){this.status="parsing";const o=new e.aG(r.tileID.overscaledZ,r.tileID.wrap,r.tileID.canonical.z,r.tileID.canonical.x,r.tileID.canonical.y),s=[],a=i.familiesBySource[r.source],l=new e.dZ(o,r.promoteId);return l.bucketLayerIDs=[],l.is3DTile=!0,e.e9(t).then((t=>{if(!t)return n(new Error("Could not parse tile"));const i=e.ea(t,1/e.cc(r.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.a8(this.zoom,{brightness:this.brightness});for(const t in a)for(const r of a[t]){const t=r[0];l.bucketLayerIDs.push(r.map((t=>e.aC(t.id,t.scope)))),t.recalculate(u,[]);const n=new e.eb(r,i,o,c,h,this.brightness,l);c||(n.needsUpload=!0),s.push(n),n.evaluate(t)}this.status="done",n(null,{buckets:s,featureIndex:l,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null})})).catch((e=>n(new Error(e.message))))}}class _e{constructor(e,t,i,r,n,o){this.actor=e,this.layerIndex=t,this.availableImages=i,this.brightness=o,this.loading={},this.loaded={}}loadTile(t,i){const r=t.uid,n=this.loading[r]=new me(t,this.brightness);e.bi(t.request,((e,o)=>{const s=!this.loading[r];return delete this.loading[r],s||e?(n.status="done",s||(this.loaded[r]=n),i(e)):o&&0!==o.byteLength?void n.parse(o,this.layerIndex,t,((e,t)=>{n.status="done",this.loaded=this.loaded||{},this.loaded[r]=n,e||!t?i(e):i(null,t)})):(n.status="done",this.loaded[r]=n,i())}))}reloadTile(e,t){const i=this.loaded,r=e.uid;if(i&&i[r]){const n=i[r];n.projection=e.projection,n.brightness=e.brightness;const o=(i,r)=>{n.reloadCallback&&(delete n.reloadCallback,this.loadTile(e,t)),t(i,r)};"parsing"===n.status?n.reloadCallback=o:"done"===n.status&&this.loadTile(e,t)}}abortTile(e,t){const i=e.uid;this.loading[i]&&delete this.loading[i],t()}removeTile(e,t){const i=this.loaded,r=e.uid;i&&i[r]&&delete i[r],t()}}class ge{constructor(t){this.self=t,this.actor=new e.ec(t,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.imageRasterizer=new e.I,this.projections={},this.defaultProjection=e.bP({name:"mercator"}),this.workerSourceTypes={vector:c,geojson:fe,"batched-model":_e},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.ed.isParsed())throw new Error("RTL text plugin already registered.");e.ed.applyArabicShaping=t.applyArabicShaping,e.ed.processBidirectionalText=t.processBidirectionalText,e.ed.processStyledBidirectionalText=t.processStyledBidirectionalText}}clearCaches(e,t,i){delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e],delete this.rasterArrayWorkerSource,i()}checkIfReady(e,t,i){i()}setReferrer(e,t){this.referrer=t}spriteLoaded(t,{scope:i,isLoaded:r}){if(this.isSpriteLoaded[t]||(this.isSpriteLoaded[t]={}),this.isSpriteLoaded[t][i]=r,this.workerSources[t]&&this.workerSources[t][i])for(const n in this.workerSources[t][i]){const o=this.workerSources[t][i][n];for(const t in o){const i=o[t];i instanceof c&&(i.isSpriteLoaded=r,i.fire(new e.z("isSpriteLoaded")))}}}setImages(e,{scope:t,images:i},r){if(this.availableImages[e]||(this.availableImages[e]={}),this.availableImages[e][t]=i,this.workerSources[e]&&this.workerSources[e][t]){for(const r in this.workerSources[e][t]){const n=this.workerSources[e][t][r];for(const e in n)n[e].availableImages=i}r()}else r()}setProjection(t,i){this.projections[t]=e.bP(i)}setBrightness(e,t,i){this.brightness=t,i()}setLayers(e,t,i){this.getLayerIndex(e,t.scope).replace(t.layers,t.options),i()}updateLayers(e,t,i){this.getLayerIndex(e,t.scope).update(t.layers,t.removedIds,t.options),i()}loadTile(e,t,i){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).loadTile(t,i)}loadDEMTile(e,t,i){this.getDEMWorkerSource(e,t.source,t.scope).loadTile(t,i)}decodeRasterArray(e,t,i){this.getRasterArrayWorkerSource().decodeRasterArray(t,i)}reloadTile(e,t,i){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).reloadTile(t,i)}abortTile(e,t,i){this.getWorkerSource(e,t.type,t.source,t.scope).abortTile(t,i)}removeTile(e,t,i){this.getWorkerSource(e,t.type,t.source,t.scope).removeTile(t,i)}removeSource(e,t,i){if(!(this.workerSources[e]&&this.workerSources[e][t.scope]&&this.workerSources[e][t.scope][t.type]&&this.workerSources[e][t.scope][t.type][t.source]))return;const r=this.workerSources[e][t.scope][t.type][t.source];delete this.workerSources[e][t.scope][t.type][t.source],void 0!==r.removeSource?r.removeSource(t,i):i()}loadWorkerSource(e,t,i){try{this.self.importScripts(t.url),i()}catch(e){i(e.toString())}}syncRTLPluginState(t,i,r){try{e.ed.setState(i);const t=e.ed.getPluginURL();if(e.ed.isLoaded()&&!e.ed.isParsed()&&null!=t){this.self.importScripts(t);const i=e.ed.isParsed();r(i?void 0:new Error(`RTL Text Plugin failed to import scripts from ${t}`),i)}}catch(e){r(e.toString())}}setDracoUrl(e,t){this.dracoUrl=t}getAvailableImages(e,t){this.availableImages[e]||(this.availableImages[e]={});let i=this.availableImages[e][t];return i||(i=[]),i}getLayerIndex(e,t){this.layerIndexes[e]||(this.layerIndexes[e]={});let i=this.layerIndexes[e][t];return i||(i=this.layerIndexes[e][t]=new n,i.scope=t),i}getWorkerSource(e,t,i,r){return this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][r]||(this.workerSources[e][r]={}),this.workerSources[e][r][t]||(this.workerSources[e][r][t]={}),this.isSpriteLoaded[e]||(this.isSpriteLoaded[e]={}),this.workerSources[e][r][t][i]||(this.workerSources[e][r][t][i]=new this.workerSourceTypes[t]({send:(t,i,r,n,o,s)=>{this.actor.send(t,i,r,e,o,s)},scheduler:this.actor.scheduler},this.getLayerIndex(e,r),this.getAvailableImages(e,r),this.isSpriteLoaded[e][r],void 0,this.brightness)),this.workerSources[e][r][t][i]}rasterizeImages(e,t,i){const{imageTasks:r,scope:n}=t,o={};for(const t in r){const{image:i,imageIdWithOptions:s}=r[t];o[t]=this.imageRasterizer.rasterize(s,i,n,e)}i(void 0,o)}removeRasterizedImages(e,t,i){const{imageIds:r,scope:n}=t;this.imageRasterizer.removeImagesFromCacheByIds(r,n,e),i()}getDEMWorkerSource(e,t,i){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][i]||(this.demWorkerSources[e][i]={}),this.demWorkerSources[e][i][t]||(this.demWorkerSources[e][i][t]=new h),this.demWorkerSources[e][i][t]}getRasterArrayWorkerSource(){return this.rasterArrayWorkerSource||(this.rasterArrayWorkerSource=new u),this.rasterArrayWorkerSource}enforceCacheSizeLimit(t,i){e.ee(i)}getWorkerPerformanceMetrics(e,t,i){i(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new ge(self)),ge})),r(0,(function(e){var t="3.9.1";const i={create:"create",load:"load",fullLoad:"fullLoad"},r={mark(e){performance.mark(e)},measure(e,t,i){performance.measure(e,t,i)}};function n(t){const i=t.name.split("?")[0];return e.a(i)&&i.includes("mapbox-gl.js")?"javascript":e.a(i)&&i.includes("mapbox-gl.css")?"css":e.b(i)?"fontRange":e.c(i)?"sprite":e.i(i)?"style":e.d(i)?"tilejson":"other"}var o,s={},a=function(){if(o)return s;function e(e){return!t(e)}function t(t){return"undefined"==typeof window||"undefined"==typeof document?"not a browser":function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var e,t,i=new Blob([""],{type:"text/javascript"}),r=URL.createObjectURL(i);try{t=new Worker(r),e=!0}catch(t){e=!1}return t&&t.terminate(),URL.revokeObjectURL(r),e}()?function(){var e=document.createElement("canvas");e.width=e.height=1;var t=e.getContext("2d");if(!t)return!1;var i=t.getImageData(0,0,1,1);return i&&i.width===e.width}()?(void 0===i[r=t&&t.failIfMajorPerformanceCaveat]&&(i[r]=function(t){var i,r=function(t){var i=document.createElement("canvas"),r=Object.create(e.webGLContextAttributes);return r.failIfMajorPerformanceCaveat=t,i.getContext("webgl2",r)}(t);if(!r)return!1;try{i=r.createShader(r.VERTEX_SHADER)}catch(e){return!1}return!(!i||r.isContextLost())&&(r.shaderSource(i,"void main() {}"),r.compileShader(i),!0===r.getShaderParameter(i,r.COMPILE_STATUS))}(r)),i[r]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL2 support"):"insufficient Canvas/getImageData support":"insufficient worker support";var r}o=1,s.supported=e,s.notSupportedReason=t;var i={};return e.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},s}();function l(e,t,i){const r=document.createElement(e);return null!=t&&(r.className=t),i&&i.appendChild(r),r}function c(e,t,i){const r=document.createElementNS("http://www.w3.org/2000/svg",e);for(const e of Object.keys(t))r.setAttributeNS(null,e,String(t[e]));return i&&i.appendChild(r),r}const h="undefined"!=typeof document?document.documentElement&&document.documentElement.style:null,u=h&&void 0!==h.userSelect?"userSelect":"WebkitUserSelect";let d;function p(){h&&u&&(d=h[u],h[u]="none")}function f(){h&&u&&(h[u]=d)}function m(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",m,!0)}function _(){window.addEventListener("click",m,!0),window.setTimeout((()=>{window.removeEventListener("click",m,!0)}),0)}function g(e,t){const i=e.getBoundingClientRect();return v(e,i,t)}function y(e,t){const i=e.getBoundingClientRect(),r=[];for(let n=0;n<t.length;n++)r.push(v(e,i,t[n]));return r}function x(e){return void 0!==window.InstallTrigger&&2===e.button&&e.ctrlKey&&window.navigator.platform.toUpperCase().indexOf("MAC")>=0?0:e.button}function v(t,i,r){const n=t.offsetWidth===i.width?1:t.offsetWidth/i.width;return new e.P((r.clientX-i.left)*n,(r.clientY-i.top)*n)}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,r){if(!e.f(i))return i;const n=M(i);return n.params.push(`sdk=js-${t}`),n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeGlyphsURL(t,i){if(!e.f(t))return t;const r=M(t);return r.path=`/fonts/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||i)}normalizeModelURL(t,i){if(!e.f(t))return t;const r=M(t);return r.path=`/models/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||i)}normalizeSourceURL(t,i,r,n){if(!e.f(t))return t;const o=M(t);return o.path=`/v4/${o.authority}.json`,o.params.push("secure"),r&&o.params.push(`language=${r}`),n&&o.params.push(`worldview=${n}`),this._makeAPIURL(o,this._customAccessToken||i)}normalizeIconsetURL(t,i){const r=M(t);return e.f(t)?(r.path=`/styles/v1${r.path}/iconset.pbf`,this._makeAPIURL(r,this._customAccessToken||i)):E(r)}normalizeSpriteURL(t,i,r,n){const o=M(t);return e.f(t)?(o.path=`/styles/v1${o.path}/sprite${i}${r}`,this._makeAPIURL(o,this._customAccessToken||n)):(o.path+=`${i}${r}`,E(o))}normalizeTileURL(t,i,r){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!e.f(t))return t;const n=M(t);n.path=n.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${i||r&&"raster"!==n.authority&&512===r?"@2x":""}${e.m.supported?".webp":"$1"}`),"raster"===n.authority?n.path=`/${e.e.RASTER_URL_PREFIX}${n.path}`:"rasterarrays"===n.authority?n.path=`/${e.e.RASTERARRAYS_URL_PREFIX}${n.path}`:"3dtiles"===n.authority?n.path=`/${e.e.TILES3D_URL_PREFIX}${n.path}`:(n.path=n.path.replace(/^.+\/v4\//,"/"),n.path=`/${e.e.TILE_URL_VERSION}${n.path}`);const o=this._customAccessToken||function(e){for(const t of e){const e=t.match(/^access_token=(.*)$/);if(e)return e[1]}return null}(n.params)||e.e.ACCESS_TOKEN;return e.e.REQUIRE_ACCESS_TOKEN&&o&&this._skuToken&&n.params.push(`sku=${this._skuToken}`),this._makeAPIURL(n,o)}canonicalizeTileURL(t,i){const r=M(t);if(!r.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!r.path.match(/\.[\w]+$/))return t;let n="mapbox://";r.path.match(/^\/raster\/v1\//)?n+=`raster/${r.path.replace(`/${e.e.RASTER_URL_PREFIX}/`,"")}`:r.path.match(/^\/rasterarrays\/v1\//)?n+=`rasterarrays/${r.path.replace(`/${e.e.RASTERARRAYS_URL_PREFIX}/`,"")}`:n+=`tiles/${r.path.replace(`/${e.e.TILE_URL_VERSION}/`,"")}`;let o=r.params;return i&&(o=o.filter((e=>!e.match(/^access_token=/)))),o.length&&(n+=`?${o.join("&")}`),n}canonicalizeTileset(t,i){const r=!!i&&e.f(i),n=[];for(const i of t.tiles||[])e.h(i)?n.push(this.canonicalizeTileURL(i,r)):n.push(i);return n}_makeAPIURL(t,i){const r="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",n=M(e.e.API_URL);if(t.protocol=n.protocol,t.authority=n.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==n.path&&(t.path=`${n.path}${t.path}`),!e.e.REQUIRE_ACCESS_TOKEN)return E(t);if(i=i||e.e.ACCESS_TOKEN,!this._silenceAuthErrors){if(!i)throw new Error(`An API access token is required to use Mapbox GL. ${r}`);if("s"===i[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${r}`)}return t.params=t.params.filter((e=>-1===e.indexOf("access_token"))),t.params.push(`access_token=${i||""}`),E(t)}}const S=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function M(e){const t=e.match(S);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 E(e){const t=e.params.length?`?${e.params.join("&")}`:"";return`${e.protocol}://${e.authority}${e.path}${t}`}const A="mapbox.eventData";function I(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 C{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(t){const i=I(e.e.ACCESS_TOKEN);let r="";return r=i&&i.u?e.k(i.u):e.e.ACCESS_TOKEN||"",t?`${A}.${t}:${r}`:`${A}:${r}`}fetchEventData(){const t=e.s("localStorage"),i=this.getStorageKey(),r=this.getStorageKey("uuid");if(t)try{const e=localStorage.getItem(i);e&&(this.eventData=JSON.parse(e));const t=localStorage.getItem(r);t&&(this.anonId=t)}catch(t){e.w("Unable to read from LocalStorage")}}saveEventData(){const t=e.s("localStorage"),i=this.getStorageKey(),r=this.getStorageKey("uuid"),n=this.anonId;if(t&&n)try{localStorage.setItem(r,n),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,r,n){if(!e.e.EVENTS_URL)return;const o=M(e.e.EVENTS_URL);o.params.push(`access_token=${n||e.e.ACCESS_TOKEN||""}`);const s={event:this.type,created:new Date(t).toISOString()},a=i?e.l(s,i):s,l={url:E(o),headers:{"Content-Type":"text/plain"},body:JSON.stringify([a])};this.pendingRequest=e.p(l,(e=>{this.pendingRequest=null,r(e),this.saveEventData(),this.processRequests(n)}))}queueRequest(e,t){this.queue.push(e),this.processRequests(t)}}const P=new class extends C{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 r=I(e.e.ACCESS_TOKEN),n=r?r.u:e.e.ACCESS_TOKEN;let o=n!==this.eventData.tokenU;e.v(this.anonId)||(this.anonId=e.u(),o=!0);const s=this.queue.shift();if(this.eventData.lastSuccess){const e=new Date(this.eventData.lastSuccess),t=new Date(s),i=(s-this.eventData.lastSuccess)/864e5;o=o||i>=1||i<-1||e.getDate()!==t.getDate()}else o=!0;o?this.postEvent(s,{sdkIdentifier:"mapbox-gl-js",sdkVersion:t,skuId:b,"enabled.telemetry":!1,userId:this.anonId},(e=>{e||(this.eventData.lastSuccess=s,this.eventData.tokenU=n)}),i):this.processRequests()}},z=P.postTurnstileEvent.bind(P),D=new class extends C{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(t,i,r,n){this.skuToken=i,this.errorCb=n,e.e.EVENTS_URL&&(r||e.e.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},r):this.errorCb(new Error(w)))}processRequests(i){if(this.pendingRequest||0===this.queue.length)return;const{id:r,timestamp:n}=this.queue.shift();r&&this.success[r]||(this.anonId||this.fetchEventData(),e.v(this.anonId)||(this.anonId=e.u()),this.postEvent(n,{sdkIdentifier:"mapbox-gl-js",sdkVersion:t,skuId:b,skuToken:this.skuToken,userId:this.anonId},(e=>{e?this.errorCb(e):r&&(this.success[r]=!0)}),i))}remove(){this.errorCb=null}},R=D.postMapLoadEvent.bind(D),L=new class extends C{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(t){let i=this.mapInstanceIdMap.get(t);return i||(i=e.u(),this.mapInstanceIdMap.set(t,i)),i}getEventId(e){const t=this.eventIdPerMapInstanceMap.get(e)||0;return this.eventIdPerMapInstanceMap.set(e,t+1),t}postStyleLoadEvent(t,i){const{map:r,style:n,importedStyles:o}=i;if(!e.e.EVENTS_URL||!t&&!e.e.ACCESS_TOKEN)return;const s=this.getMapInstanceId(r),a={mapInstanceId:s,eventId:this.getEventId(s),style:n};o.length&&(a.importedStyles=o),this.queueRequest({timestamp:Date.now(),payload:a},t)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,payload:i}=this.queue.shift();this.postEvent(t,i,(()=>{}),e)}},O=L.postStyleLoadEvent.bind(L),k=new class extends C{constructor(){super("gljs.performance")}postPerformanceEvent(t,i){e.e.EVENTS_URL&&(t||e.e.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:i},t)}processRequests(r){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:o,performanceData:s}=this.queue.shift(),a=function(r){const o=performance.getEntriesByType("resource"),s=performance.getEntriesByType("mark"),a=function(e){const t={};if(e)for(const i in e)if("other"!==i)for(const r of e[i]){const e=`${i}ResolveRangeMin`,n=`${i}ResolveRangeMax`,o=`${i}RequestCount`,s=`${i}RequestCachedCount`;t[e]=Math.min(t[e]||1/0,r.startTime),t[n]=Math.max(t[n]||-1/0,r.responseEnd);const a=e=>{void 0===t[e]&&(t[e]=0),++t[e]};void 0!==r.transferSize&&0===r.transferSize&&a(s),a(o)}return t}(function(e,t){const i={};if(e)for(const r of e){const e=t(r);void 0===i[e]&&(i[e]=[]),i[e].push(r)}return i}(o,n)),l=window.devicePixelRatio,c=navigator.connection||navigator.mozConnection||navigator.webkitConnection,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 a)d(u.counters,e,a[e]);if(r.interactionRange[0]!==1/0&&r.interactionRange[1]!==-1/0&&(d(u.counters,"interactionRangeMin",r.interactionRange[0]),d(u.counters,"interactionRangeMax",r.interactionRange[1])),s)for(const e of Object.keys(i)){const t=i[e],r=s.find((e=>e.name===t));r&&d(u.counters,t,r.startTime)}return d(u.counters,"visibilityHidden",r.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]}`}}}(o)),d(u.attributes,"terrainEnabled",r.terrainEnabled?"true":"false"),d(u.attributes,"fogEnabled",r.fogEnabled?"true":"false"),d(u.attributes,"projection",r.projection),d(u.attributes,"zoom",r.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",r.width/l),d(u.metadata,"mapHeight",r.height/l),d(u.metadata,"webglRenderer",r.renderer),d(u.metadata,"webglVendor",r.vendor),d(u.metadata,"sdkVersion",t),d(u.metadata,"sdkIdentifier","mapbox-gl-js"),u}(s);for(const e of a.metadata);for(const e of a.counters);for(const e of a.attributes);this.postEvent(o,a,(()=>{}),r)}},F=k.postPerformanceEvent.bind(k),B=new class extends C{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(t,i,r,n){if(!e.e.API_URL||!e.e.SESSION_PATH)return;const o=M(e.e.API_URL+e.e.SESSION_PATH);o.params.push(`sku=${i||""}`),o.params.push(`access_token=${n||e.e.ACCESS_TOKEN||""}`);const s={url:E(o),headers:{"Content-Type":"text/plain"}};this.pendingRequest=e.g(s,(e=>{this.pendingRequest=null,r(e),this.saveEventData(),this.processRequests(n)}))}getSessionAPI(t,i,r,n){this.skuToken=i,this.errorCb=n,e.e.SESSION_PATH&&e.e.API_URL&&(r||e.e.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},r):this.errorCb(new Error(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),V=new Set;function U(e,t){t?V.add(e):V.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 G(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(t){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded={},this.requestors=[],this.patterns={},this.atlasImage={},this.atlasTexture={},this.dirty=!0,this.spriteFormat=t,"raster"!==t&&e.t()&&(this.imageRasterizerDispatcher=new e.D(e.x(),this,"Image Rasterizer Worker",1))}get imageRasterizer(){return this._imageRasterizer||(this._imageRasterizer=new e.I),this._imageRasterizer}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 r=!0;return this._validateStretch(i.stretchX,i.data&&i.data.width)||(this.fire(new e.y(new Error(`Image "${t}" has invalid "stretchX" value`))),r=!1),this._validateStretch(i.stretchY,i.data&&i.data.height)||(this.fire(new e.y(new Error(`Image "${t}" has invalid "stretchY" value`))),r=!1),this._validateContent(i.content,i)||(this.fire(new e.y(new Error(`Image "${t}" has invalid "content" value`))),r=!1),r}_validateStretch(e,t){if(!e)return!0;let i=0;for(const r of e){if(r[0]<i||r[1]<r[0]||t<r[1])return!1;i=r[1]}return!0}_validateContent(e,t){if(!e)return!0;if(4!==e.length)return!1;if(!t.usvg){if(e[0]<0||t.data.width<e[0])return!1;if(e[1]<0||t.data.height<e[1])return!1;if(e[2]<0||t.data.width<e[2])return!1;if(e[3]<0||t.data.height<e[3])return!1}return!(e[2]<e[0]||e[3]<e[1])}updateImage(e,t,i){i.version=this.images[t][e].version+1,this.images[t][e]=i,this.updatedImages[t][e]=!0,this.removeFromImageRasterizerCache(e,t)}removeFromImageRasterizerCache(t,i){"raster"!==this.spriteFormat&&(e.t()?this.imageRasterizerDispatcher.getActor().send("removeRasterizedImages",{imageIds:[t],scope:i}):this.imageRasterizer.removeImagesFromCacheByIds([t],i))}removeImage(e,t){const i=this.images[t][e];delete this.images[t][e],delete this.patterns[t][e],this.removeFromImageRasterizerCache(e,t),i.userImage&&i.userImage.onRemove&&i.userImage.onRemove()}listImages(e){return Object.keys(this.images[e])}getImages(e,t,i){let r=!0;const n=!!this.loaded[t];if(!n)for(const i of e)this.images[t][i]||(r=!1);n||r?this._notify(e,t,i):this.requestors.push({ids:e,scope:t,callback:i})}rasterizeImages({scope:t,imageTasks:i},r){const n={};for(const e in i){const r=i[e],o=this.getImage(r.id,t);o&&(n[e]={image:o,imageIdWithOptions:r})}e.t()?this.imageRasterizerDispatcher.getActor().send("rasterizeImages",{imageTasks:n,scope:t},r):this.rasterizeImagesInMainThread({imageTasks:n,scope:t},r)}rasterizeImagesInMainThread(e,t){const{imageTasks:i,scope:r}=e,n={};for(const e in i){const{image:t,imageIdWithOptions:o}=i[e];n[e]=this.imageRasterizer.rasterize(o,t,r,"")}t(void 0,n)}getUpdatedImages(e){return this.updatedImages[e]}_notify(t,i,r){const n={};for(const r of t){this.images[i][r]||this.fire(new e.z("styleimagemissing",{id:r}));const t=this.images[i][r];t?n[r]={data:t.usvg?null:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,usvg:t.usvg,version:t.version,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,hasRenderCallback:Boolean(t.userImage&&t.userImage.render)}:e.w(`Image "${r}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}r(null,n)}getPixelSize(e){const{width:t,height:i}=this.atlasImage[e];return{width:t,height:i}}getPattern(t,i,r){const n=this.patterns[i][t],o=this.getImage(t,i);if(!o)return null;if(n&&n.position.version===o.version)return n.position;if(n)n.position.version=o.version;else{o.usvg&&!o.data&&(o.data=this.imageRasterizer.rasterize(e.A.from(t).getPrimary(),o,i,""));const r={w:o.data.width+2*e.B,h:o.data.height+2*e.B,x:0,y:0},n=new e.F(r,o,e.B);this.patterns[i][t]={bin:r,position:n}}return this._updatePatternAtlas(i,r),this.patterns[i][t].position}bind(t,i){const r=t.gl;let n=this.atlasTexture[i];n?this.dirty&&(n.update(this.atlasImage[i]),this.dirty=!1):(n=new e.T(t,this.atlasImage[i],r.RGBA8),this.atlasTexture[i]=n),n.bind(r.LINEAR,r.CLAMP_TO_EDGE)}_updatePatternAtlas(t,i){const r=[];for(const e in this.patterns[t])r.push(this.patterns[t][e].bin);const{w:n,h:o}=e.C(r),s=this.atlasImage[t];s.resize({width:n||1,height:o||1});for(const r in this.patterns[t]){const{bin:n,position:o}=this.patterns[t][r];let a=o.padding;const l=n.x+a,c=n.y+a,h=this.images[t][r].data,u=h.width,d=h.height;a=a>1?a-1:a,e.r.copy(h,s,{x:0,y:0},{x:l,y:c},{width:u,height:d},i),e.r.copy(h,s,{x:0,y:d-a},{x:l,y:c-a},{width:u,height:a},i),e.r.copy(h,s,{x:0,y:0},{x:l,y:c+d},{width:u,height:a},i),e.r.copy(h,s,{x:u-a,y:0},{x:l-a,y:c},{width:a,height:d},i),e.r.copy(h,s,{x:0,y:0},{x:l+u,y:c},{width:a,height:d},i),e.r.copy(h,s,{x:u-a,y:d-a},{x:l-a,y:c-a},{width:a,height:a},i),e.r.copy(h,s,{x:0,y:d-a},{x:l+u,y:c-a},{width:a,height:a},i),e.r.copy(h,s,{x:0,y:0},{x:l+u,y:c+d},{width:a,height:a},i),e.r.copy(h,s,{x:u-a,y:0},{x:l-a,y:c+d},{width:a,height:a},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];G(e)&&this.updateImage(i,t,e)}}}function Z(t){const i=t.key,r=t.value,n=t.valueSpec||{},o=t.objectElementValidators||{},s=t.style,a=t.styleSpec;let l=[];const c=e.H(r);if("object"!==c)return[new e.V(i,r,`object expected, ${c} found`)];for(const t in r){const c=t.split(".")[0];let h;o[c]?h=o[c]:n[c]?h=pe:o["*"]?h=o["*"]:n["*"]&&(h=pe),h?l=l.concat(h({key:(i?`${i}.`:i)+t,value:r[t],valueSpec:n[c]||n["*"],style:s,styleSpec:a,object:r,objectKey:t},r)):l.push(new e.G(i,r[t],`unknown property "${t}"`))}for(const t in n)o[t]||n[t].required&&void 0===n[t].default&&void 0===r[t]&&l.push(new e.V(i,r,`missing required property "${t}"`));return l}function $(t){const i=t.value,r=t.valueSpec,n=t.style,o=t.styleSpec,s=t.key,a=t.arrayElementValidator||pe;if("array"!==e.H(i))return[new e.V(s,i,`array expected, ${e.H(i)} found`)];if(r.length&&i.length!==r.length)return[new e.V(s,i,`array length ${r.length} expected, length ${i.length} found`)];if(r["min-length"]&&i.length<r["min-length"])return[new e.V(s,i,`array length at least ${r["min-length"]} expected, length ${i.length} found`)];let l={type:r.value,values:r.values,minimum:r.minimum,maximum:r.maximum,function:void 0};o.$version<7&&(l.function=r.function),"object"===e.H(r.value)&&(l=r.value);let c=[];for(let e=0;e<i.length;e++)c=c.concat(a({array:i,arrayIndex:e,value:i[e],valueSpec:l,style:n,styleSpec:o,key:`${s}[${e}]`},!0));return c}function H(t){const i=t.key,r=t.value,n=t.valueSpec;let o=e.H(r);if("number"===o&&r!=r&&(o="NaN"),"number"!==o)return[new e.V(i,r,`number expected, ${o} found`)];if("minimum"in n){let o=n.minimum;if("array"===e.H(n.minimum)&&(o=n.minimum[t.arrayIndex]),r<o)return[new e.V(i,r,`${r} is less than the minimum value ${o}`)]}if("maximum"in n){let o=n.maximum;if("array"===e.H(n.maximum)&&(o=n.maximum[t.arrayIndex]),r>o)return[new e.V(i,r,`${r} is greater than the maximum value ${o}`)]}return[]}function W(t){const i=t.valueSpec,r=e.K(t.value.type);let n,o,s,a={};const l="categorical"!==r&&void 0===t.value.property,c=!l,h="array"===e.H(t.value.stops)&&"array"===e.H(t.value.stops[0])&&"object"===e.H(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"===r)return[new e.V(t.key,t.value,'identity function may not have a "stops" property')];let i=[];const n=t.value;return i=i.concat($({key:t.key,value:n,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:d})),"array"===e.H(n)&&0===n.length&&i.push(new e.V(t.key,n,"array must have at least one stop")),i},default:function(e){return pe({key:e.key,value:e.value,valueSpec:i,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===r&&l&&u.push(new e.V(t.key,t.value,'missing required property "property"')),"identity"===r||t.value.stops||u.push(new e.V(t.key,t.value,'missing required property "stops"')),"exponential"===r&&t.valueSpec.expression&&!e.L(t.valueSpec)&&u.push(new e.V(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(c&&!e.M(t.valueSpec)?u.push(new e.V(t.key,t.value,"property functions not supported")):l&&!e.N(t.valueSpec)&&u.push(new e.V(t.key,t.value,"zoom functions not supported"))),"categorical"!==r&&!h||void 0!==t.value.property||u.push(new e.V(t.key,t.value,'"property" property is required')),u;function d(t){let r=[];const n=t.value,l=t.key;if("array"!==e.H(n))return[new e.V(l,n,`array expected, ${e.H(n)} found`)];if(2!==n.length)return[new e.V(l,n,`array length 2 expected, length ${n.length} found`)];if(h){if("object"!==e.H(n[0]))return[new e.V(l,n,`object expected, ${e.H(n[0])} found`)];if(void 0===n[0].zoom)return[new e.V(l,n,"object stop key must have zoom")];if(void 0===n[0].value)return[new e.V(l,n,"object stop key must have value")];const i=e.K(n[0].zoom);if("number"!=typeof i)return[new e.V(l,n[0].zoom,"stop zoom values must be numbers")];if(s&&s>i)return[new e.V(l,n[0].zoom,"stop zoom values must appear in ascending order")];i!==s&&(s=i,o=void 0,a={}),r=r.concat(Z({key:`${l}[0]`,value:n[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:H,value:p}}))}else r=r.concat(p({key:`${l}[0]`,value:n[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},n));return e.O(e.Q(n[1]))?r.concat([new e.V(`${l}[1]`,n[1],"expressions are not allowed in function stops.")]):r.concat(pe({key:`${l}[1]`,value:n[1],valueSpec:i,style:t.style,styleSpec:t.styleSpec}))}function p(t,s){const l=e.H(t.value),c=e.K(t.value),h=null!==t.value?t.value:s;if(n){if(l!==n)return[new e.V(t.key,h,`${l} stop domain type must match previous stop domain type ${n}`)]}else n=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"!==r){let n=`number expected, ${l} found`;return e.M(i)&&void 0===r&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new e.V(t.key,h,n)]}return"categorical"!==r||"number"!==l||"number"==typeof c&&isFinite(c)&&Math.floor(c)===c?"categorical"!==r&&"number"===l&&"number"==typeof c&&"number"==typeof o&&void 0!==o&&c<o?[new e.V(t.key,h,"stop domain values must appear in ascending order")]:(o=c,"categorical"===r&&c in a?[new e.V(t.key,h,"stop domain values must be unique")]:(a[c]=!0,[])):[new e.V(t.key,h,`integer expected, found ${String(c)}`)]}}function X(t){const i=("property"===t.expressionContext?e.S:e.U)(e.Q(t.value),t.valueSpec);if("error"===i.result)return i.value.map((i=>new e.V(`${t.key}${i.key}`,t.value,i.message)));const r=i.value.expression||i.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!r.outputDefined())return[new e.V(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!e.W(r))return[new e.V(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext)return Y(r,t);if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!e.X(r,["zoom","feature-state"]))return[new e.V(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!e.Y(r))return[new e.V(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Y(t,i){const r=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(i.valueSpec&&i.valueSpec.expression)for(const e of i.valueSpec.expression.parameters)r.delete(e);if(0===r.size)return[];const n=[];return t instanceof e.Z&&r.has(t.name)?[new e.V(i.key,i.value,`["${t.name}"] expression is not supported in a filter for a ${i.object.type} layer with id: ${i.object.id}`)]:(t.eachChild((e=>{n.push(...Y(e,i))})),n)}function K(t){const i=t.key,r=t.value,n=t.valueSpec,o=[];return Array.isArray(n.values)?-1===n.values.indexOf(e.K(r))&&o.push(new e.V(i,r,`expected one of [${n.values.join(", ")}], ${JSON.stringify(r)} found`)):-1===Object.keys(n.values).indexOf(e.K(r))&&o.push(new e.V(i,r,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(r)} found`)),o}function J(t){return e.$(e.Q(t.value))?X(e.J({},t,{expressionContext:"filter",valueSpec:t.styleSpec[`filter_${t.layerType||"fill"}`]})):Q(t)}function Q(t){const i=t.value,r=t.key;if("array"!==e.H(i))return[new e.V(r,i,`array expected, ${e.H(i)} found`)];const n=t.styleSpec;let o,s=[];if(i.length<1)return[new e.V(r,i,"filter array must have at least 1 element")];switch(s=s.concat(K({key:`${r}[0]`,value:i[0],valueSpec:n.filter_operator,style:t.style,styleSpec:t.styleSpec})),e.K(i[0])){case"<":case"<=":case">":case">=":i.length>=2&&"$type"===e.K(i[1])&&s.push(new e.V(r,i,`"$type" cannot be use with operator "${i[0]}"`));case"==":case"!=":3!==i.length&&s.push(new e.V(r,i,`filter array for operator "${i[0]}" must have 3 elements`));case"in":case"!in":i.length>=2&&(o=e.H(i[1]),"string"!==o&&s.push(new e.V(`${r}[1]`,i[1],`string expected, ${o} found`)));for(let a=2;a<i.length;a++)o=e.H(i[a]),"$type"===e.K(i[1])?s=s.concat(K({key:`${r}[${a}]`,value:i[a],valueSpec:n.geometry_type,style:t.style,styleSpec:t.styleSpec})):"string"!==o&&"number"!==o&&"boolean"!==o&&s.push(new e.V(`${r}[${a}]`,i[a],`string, number, or boolean expected, ${o} found`));break;case"any":case"all":case"none":for(let e=1;e<i.length;e++)s=s.concat(Q({key:`${r}[${e}]`,value:i[e],style:t.style,styleSpec:t.styleSpec}));break;case"has":case"!has":o=e.H(i[1]),2!==i.length?s.push(new e.V(r,i,`filter array for "${i[0]}" operator must have 2 elements`)):"string"!==o&&s.push(new e.V(`${r}[1]`,i[1],`string expected, ${o} found`))}return s}function ee(t,i){const r=t.key,n=t.style,o=t.layer,s=t.styleSpec,a=t.value,l=t.objectKey,c=s[`${i}_${t.layerType}`];if(!c)return[];const h=l.match(/^(.*)-use-theme$/);if("paint"===i&&h&&c[h[1]])return pe({key:r,value:a,valueSpec:{type:"string"},style:n,styleSpec:s});const u=l.match(/^(.*)-transition$/);if("paint"===i&&u&&c[u[1]]&&c[u[1]].transition)return pe({key:r,value:a,valueSpec:s.transition,style:n,styleSpec:s});const d=t.valueSpec||c[l];if(!d)return[new e.G(r,a,`unknown property "${l}"`)];let p;if("string"===e.H(a)&&e.M(d)&&!d.tokens&&(p=/^{([^}]+)}$/.exec(a))){const t=`\`{ "type": "identity", "property": ${p?JSON.stringify(p[1]):'"_"'} }\``;return[new e.V(r,a,`"${l}" does not support interpolation syntax\nUse an identity property function instead: ${t}.`)]}const f=[];if("symbol"===t.layerType)"text-field"!==l||!n||n.glyphs||n.imports||f.push(new e.V(r,a,'use of "text-field" requires a style "glyphs" property')),"text-font"===l&&e.a0(e.Q(a))&&"identity"===e.K(a.type)&&f.push(new e.V(r,a,'"text-font" does not support identity functions'));else if("model"===t.layerType&&"paint"===i&&o&&o.layout&&o.layout.hasOwnProperty("model-id")&&e.M(d)&&(e.a1(d)||e.N(d))){const t=e.S(e.Q(a),d),i=t.value.expression||t.value._styleExpression.expression;i&&!e.X(i,["measure-light"])&&("model-emissive-strength"===l&&e.Y(i)&&e.W(i)||f.push(new e.V(r,a,`${l} does not support measure-light expressions when the model layer source is vector tile or GeoJSON.`)))}return f.concat(pe({key:t.key,value:a,valueSpec:d,style:n,styleSpec:s,expressionContext:"property",propertyType:i,propertyKey:l}))}function te(e){return ee(e,"paint")}function ie(e){return ee(e,"layout")}function re(t){let i=[];const r=t.value,n=t.key,o=t.style,s=t.styleSpec;r.type||r.ref||i.push(new e.V(n,r,'either "type" or "ref" is required'));let a=e.K(r.type);const l=e.K(r.ref);if(r.id){const s=e.K(r.id);for(let a=0;a<t.arrayIndex;a++){const t=o.layers[a];e.K(t.id)===s&&i.push(new e.V(n,r.id,`duplicate layer id "${r.id}", previously used at line ${t.id.__line__}`))}}if("ref"in r){let t;["type","source","source-layer","filter","layout"].forEach((t=>{t in r&&i.push(new e.V(n,r[t],`"${t}" is prohibited for ref layers`))})),o.layers.forEach((i=>{e.K(i.id)===l&&(t=i)})),t?t.ref?i.push(new e.V(n,r.ref,"ref cannot reference another ref layer")):a=e.K(t.type):"string"==typeof l&&i.push(new e.V(n,r.ref,`ref layer "${l}" not found`))}else if("background"!==a&&"sky"!==a&&"slot"!==a)if(r.source){const t=o.sources&&o.sources[r.source],s=t&&e.K(t.type);t?"vector"===s&&"raster"===a?i.push(new e.V(n,r.source,`layer "${r.id}" requires a raster source`)):"raster"===s&&"raster"!==a?i.push(new e.V(n,r.source,`layer "${r.id}" requires a vector source`)):"vector"!==s||r["source-layer"]?"raster-dem"===s&&"hillshade"!==a?i.push(new e.V(n,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):"raster-array"!==s||["raster","raster-particle"].includes(a)?"line"!==a||!r.paint||!r.paint["line-gradient"]&&!r.paint["line-trim-offset"]||"geojson"===s&&t.lineMetrics?"raster-particle"===a&&"raster-array"!==s&&i.push(new e.V(n,r.source,`layer "${r.id}" requires a 'raster-array' source.`)):i.push(new e.V(n,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):i.push(new e.V(n,r.source,"raster-array source can only be used with layer type 'raster'.")):i.push(new e.V(n,r,`layer "${r.id}" must specify a "source-layer"`)):i.push(new e.V(n,r.source,`source "${r.source}" not found`))}else i.push(new e.V(n,r,'missing required property "source"'));return i=i.concat(Z({key:n,value:r,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>pe({key:`${n}.type`,value:r.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,object:r,objectKey:"type"}),filter:t=>J(e.J({layerType:a},t)),layout:t=>Z({layer:r,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>ie(e.J({layerType:a},t))}}),paint:t=>Z({layer:r,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>te(e.J({layerType:a,layer:r},t))}})}})),i}function ne(t){const i=t.value,r=t.key,n=e.H(i);return"string"!==n?[new e.V(r,i,`string expected, ${n} found`)]:[]}const oe={promoteId:function({key:t,value:i}){if("string"===e.H(i))return ne({key:t,value:i});{const e=[];for(const r in i)e.push(...ne({key:`${t}.${r}`,value:i[r]}));return e}}};function se(t){const i=t.value,r=t.key,n=t.styleSpec,o=t.style;if(!i.type)return[new e.V(r,i,'"type" is required')];const s=e.K(i.type);let a=[];switch(["vector","raster","raster-dem","raster-array"].includes(s)&&(i.url||i.tiles||a.push(new e.G(r,i,'Either "url" or "tiles" is required.'))),s){case"vector":case"raster":case"raster-dem":case"raster-array":return a=a.concat(Z({key:r,value:i,valueSpec:n[`source_${s.replace("-","_")}`],style:t.style,styleSpec:n,objectElementValidators:oe})),a;case"geojson":if(a=Z({key:r,value:i,valueSpec:n.source_geojson,style:o,styleSpec:n,objectElementValidators:oe}),i.cluster)for(const e in i.clusterProperties){const[t,n]=i.clusterProperties[e],o="string"==typeof t?[t,["accumulated"],["get",e]]:t;a.push(...X({key:`${r}.${e}.map`,value:n,expressionContext:"cluster-map"})),a.push(...X({key:`${r}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return a;case"video":return Z({key:r,value:i,valueSpec:n.source_video,style:o,styleSpec:n});case"image":return Z({key:r,value:i,valueSpec:n.source_image,style:o,styleSpec:n});case"canvas":return[new e.V(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return K({key:`${r}.type`,value:i.type,valueSpec:{values:ae(n)},style:o,styleSpec:n})}}function ae(e){return e.source.reduce(((t,i)=>{const r=e[i];return"enum"===r.type.type&&(t=t.concat(Object.keys(r.type.values))),t}),[])}function le(t){const i=t.value,r=t.styleSpec,n=r.light,o=t.style;let s=[];const a=e.H(i);if(void 0===i)return s;if("object"!==a)return s=s.concat([new e.V("light",i,`object expected, ${a} found`)]),s;for(const t in i){const a=t.match(/^(.*)-transition$/),l=t.match(/^(.*)-use-theme$/);s=s.concat(l&&n[l[1]]?pe({key:t,value:i[t],valueSpec:{type:"string"},style:o,styleSpec:r}):a&&n[a[1]]&&n[a[1]].transition?pe({key:t,value:i[t],valueSpec:r.transition,style:o,styleSpec:r}):n[t]?pe({key:t,value:i[t],valueSpec:n[t],style:o,styleSpec:r}):[new e.V(t,i[t],`unknown property "${t}"`)])}return s}function ce(t){const i=t.value;let r=[];if(!i)return r;const n=e.H(i);if("object"!==n)return r=r.concat([new e.V("light-3d",i,`object expected, ${n} found`)]),r;const o=t.styleSpec,s=o["light-3d"],a=t.key,l=t.style,c=t.style.lights;for(const t of["type","id"])if(!(t in i))return r=r.concat([new e.V("light-3d",i,`missing property ${t} on light`)]),r;if(i.type&&c)for(let n=0;n<t.arrayIndex;n++){const t=e.K(i.type),o=c[n];e.K(o.type)===t&&r.push(new e.V(a,i.id,`duplicate light type "${i.type}", previously defined at line ${o.id.__line__}`))}const h=`properties_light_${i.type}`;if(!(h in o))return r=r.concat([new e.V("light-3d",i,`Invalid light type ${i.type}`)]),r;const u=o[h];for(const n in i)if("properties"===n){const s=i[n],a=e.H(s);if("object"!==a)return r=r.concat([new e.V("properties",s,`object expected, ${a} found`)]),r;for(const i in s)r=r.concat(u[i]?pe({key:i,value:s[i],valueSpec:u[i],style:l,styleSpec:o}):[new e.G(t.key,s[i],`unknown property "${i}"`)])}else{const t=n.match(/^(.*)-transition$/),a=n.match(/^(.*)-use-theme$/);r=r.concat(a&&s[a[1]]?pe({key:n,value:i[n],valueSpec:{type:"string"},style:l,styleSpec:o}):t&&s[t[1]]&&s[t[1]].transition?pe({key:n,value:i[n],valueSpec:o.transition,style:l,styleSpec:o}):s[n]?pe({key:n,value:i[n],valueSpec:s[n],style:l,styleSpec:o}):[new e.G(n,i[n],`unknown property "${n}"`)])}return r}function he(t){const i=t.value,r=t.key,n=t.style,o=t.styleSpec,s=o.terrain;let a=[];const l=e.H(i);if(void 0===i)return a;if("null"===l)return a;if("object"!==l)return a=a.concat([new e.V("terrain",i,`object expected, ${l} found`)]),a;for(const t in i){const r=t.match(/^(.*)-transition$/),l=t.match(/^(.*)-use-theme$/);a=a.concat(l&&s[l[1]]?pe({key:t,value:i[t],valueSpec:{type:"string"},style:n,styleSpec:o}):r&&s[r[1]]&&s[r[1]].transition?pe({key:t,value:i[t],valueSpec:o.transition,style:n,styleSpec:o}):s[t]?pe({key:t,value:i[t],valueSpec:s[t],style:n,styleSpec:o}):[new e.G(t,i[t],`unknown property "${t}"`)])}if(i.source){const t=n.sources&&n.sources[i.source],o=t&&e.K(t.type);t?"raster-dem"!==o&&a.push(new e.V(r,i.source,`terrain cannot be used with a source of type ${String(o)}, it only be used with a "raster-dem" source type`)):a.push(new e.V(r,i.source,`source "${i.source}" not found`))}else a.push(new e.V(r,i,'terrain is missing required property "source"'));return a}function ue(t){const i=t.value,r=t.style,n=t.styleSpec,o=n.fog;let s=[];const a=e.H(i);if(void 0===i)return s;if("object"!==a)return s=s.concat([new e.V("fog",i,`object expected, ${a} found`)]),s;for(const t in i){const a=t.match(/^(.*)-transition$/),l=t.match(/^(.*)-use-theme$/);s=s.concat(l&&o[l[1]]?pe({key:t,value:i[t],valueSpec:{type:"string"},style:r,styleSpec:n}):a&&o[a[1]]&&o[a[1]].transition?pe({key:t,value:i[t],valueSpec:n.transition,style:r,styleSpec:n}):o[t]?pe({key:t,value:i[t],valueSpec:o[t],style:r,styleSpec:n}):[new e.G(t,i[t],`unknown property "${t}"`)])}return s}const de={"*":()=>[],array:$,boolean:function(t){const i=t.value,r=t.key,n=e.H(i);return"boolean"!==n?[new e.V(r,i,`boolean expected, ${n} found`)]:[]},number:H,color:function(t){const i=t.key,r=t.value,n=e.H(r);return"string"!==n?[new e.V(i,r,`color expected, ${n} found`)]:null===e._.parseCSSColor(r)?[new e.V(i,r,`color expected, "${r}" found`)]:[]},enum:K,filter:J,function:W,layer:re,object:Z,source:se,model:e.a2,light:le,"light-3d":ce,terrain:he,fog:ue,string:ne,formatted:function(e){return 0===ne(e).length?[]:X(e)},resolvedImage:function(e){return 0===ne(e).length?[]:X(e)},projection:function(t){const i=t.value,r=t.styleSpec,n=r.projection,o=t.style;let s=[];const a=e.H(i);if("object"===a)for(const e in i)s=s.concat(pe({key:e,value:i[e],valueSpec:n[e],style:o,styleSpec:r}));else"string"!==a&&(s=s.concat([new e.V("projection",i,`object or string expected, ${a} found`)]));return s},import:function(t){const{value:i,styleSpec:r}=t,{data:n,...o}=i;Object.defineProperty(o,"__line__",{value:i.__line__,enumerable:!1});let s=Z(e.J({},t,{value:o,valueSpec:r.import}));return""===e.K(o.id)&&s.push(new e.V(`${t.key}.id`,o,"import id can't be an empty string")),n&&(s=s.concat(me(n,r,{key:`${t.key}.data`}))),s}};function pe(t,i=!1){const r=t.value,n=t.valueSpec,o=t.styleSpec;if(n.expression&&e.a0(e.K(r)))return W(t);if(n.expression&&e.O(e.Q(r)))return X(t);if(n.type&&de[n.type]){const r=de[n.type](t);return!0===i&&r.length>0&&"array"===e.H(t.value)?X(t):r}return Z(e.J({},t,{valueSpec:n.type?o[n.type]:n}))}function fe(t){const i=t.value,r=t.key,n=ne(t);return n.length||(-1===i.indexOf("{fontstack}")&&n.push(new e.V(r,i,'"glyphs" url must include a "{fontstack}" token')),-1===i.indexOf("{range}")&&n.push(new e.V(r,i,'"glyphs" url must include a "{range}" token'))),n}function me(t,i=e.a3,r={}){return pe({key:r.key||"",value:t,valueSpec:i.$root,styleSpec:i,style:t,objectElementValidators:{glyphs:fe,"*":()=>[]}})}function _e(t,i=e.a3){return Ce(me(t,i))}const ge=e=>Ce(se(e)),ye=e=>Ce(le(e)),xe=e=>Ce(ce(e)),ve=e=>Ce(he(e)),be=e=>Ce(ue(e)),we=t=>Ce(function(t){const i=t.value,r=t.style,n=t.styleSpec,o=n.snow;let s=[];const a=e.H(i);if(void 0===i)return s;if("object"!==a)return s=s.concat([new e.V("snow",i,`object expected, ${a} found`)]),s;for(const t in i){const a=t.match(/^(.*)-transition$/);s=s.concat(a&&o[a[1]]&&o[a[1]].transition?pe({key:t,value:i[t],valueSpec:n.transition,style:r,styleSpec:n}):o[t]?pe({key:t,value:i[t],valueSpec:o[t],style:r,styleSpec:n}):[new e.G(t,i[t],`unknown property "${t}"`)])}return s}(t)),Te=t=>Ce(function(t){const i=t.value,r=t.style,n=t.styleSpec,o=n.rain;let s=[];const a=e.H(i);if(void 0===i)return s;if("object"!==a)return s=s.concat([new e.V("rain",i,`object expected, ${a} found`)]),s;for(const t in i){const a=t.match(/^(.*)-transition$/);s=s.concat(a&&o[a[1]]&&o[a[1]].transition?pe({key:t,value:i[t],valueSpec:n.transition,style:r,styleSpec:n}):o[t]?pe({key:t,value:i[t],valueSpec:o[t],style:r,styleSpec:n}):[new e.G(t,i[t],`unknown property "${t}"`)])}return s}(t)),Se=e=>Ce(re(e)),Me=e=>Ce(J(e)),Ee=e=>Ce(te(e)),Ae=e=>Ce(ie(e)),Ie=t=>Ce(e.a2(t));function Ce(e){return e.slice().sort(((e,t)=>e.line&&t.line?e.line-t.line:0))}function Pe(t,i){let r=!1;if(i&&i.length)for(const n of i)n instanceof e.G?e.w(n.message):(t.fire(new e.y(new Error(n.message))),r=!0);return r}let ze;class De extends e.E{constructor(t,i="flat"){super(),this._transitionable=new e.a4(ze||(ze=new e.a5({anchor:new e.a6(e.a3.light.anchor),position:new e.a7(e.a3.light.position),color:new e.a6(e.a3.light.color),intensity:new e.a6(e.a3.light.intensity)}))),this.setLight(t,i),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,t,i={}){this._validate(ye,e,i)||(this._transitionable.setTransitionOrValue(e),this.id=t)}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(t,i,r){return(!r||!1!==r.validate)&&Pe(this,t.call(_e,e.l({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a3})))}}let Re=class extends e.E{constructor(t,i,r,n){super(),this.scope=r,this._transitionable=new e.a4(new e.a5({source:new e.a6(e.a3.terrain.source),exaggeration:new e.a6(e.a3.terrain.exaggeration)}),r,n),this._transitionable.setTransitionOrValue(t,n),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.a8(t)).get("exaggeration")}getAttenuationRange(){if(!this.isZoomDependent())return null;const t=this._transitionable._values.exaggeration;if(!t)return null;const i=t.value.expression;if(!i)return null;let r=-1,n=-1,o=1;for(const t of i.zoomStops)o=i.evaluate(new e.a8(t)),o>.01?(r=t,n=-1):n=t;return o<.01&&r>0&&n>r?[r,n]:null}isZoomDependent(){const t=this._transitionable._values.exaggeration;return null!=t&&null!=t.value&&null!=t.value.expression&&t.value.expression instanceof e.a9}};const Le=.05;function Oe(t,i,r,n){const o=e.ac(45,65,r),[s,a]=ke(t,n);let l=1-Math.min(1,Math.exp((i-s)/(a-s)*-6));return l*=l*l,l=Math.min(1,1.00747*l),l*o*t.alpha}function ke(e,t){const i=.5/Math.tan(.5*t);return[e.range[0]+i,e.range[1]+i]}function Fe(t,i,r,n,o){const s=e.ab.vec3.transformMat4([],[i,r,n],o.mercatorFogMatrix);return Oe(t,e.ab.vec3.length(s),o.pitch,o._fov)}function Be(t,i,r,n,o,s,a){const l=[[r,n,0],[o,n,0],[o,s,0],[r,s,0]];let c=Number.MAX_VALUE,h=-Number.MAX_VALUE;for(const t of l){const r=e.ab.vec3.transformMat4([],t,i),n=e.ab.vec3.length(r);c=Math.min(c,n),h=Math.max(h,n)}return[Oe(t,c,a.pitch,a._fov),Oe(t,h,a.pitch,a._fov)]}class Ne extends e.E{constructor(t,i,r,n){super();const o=new e.a5({range:new e.a6(e.a3.fog.range),color:new e.a6(e.a3.fog.color),"color-use-theme":new e.a6({type:"string","property-type":"data-constant",default:"default"}),"high-color":new e.a6(e.a3.fog["high-color"]),"high-color-use-theme":new e.a6({type:"string","property-type":"data-constant",default:"default"}),"space-color":new e.a6(e.a3.fog["space-color"]),"space-color-use-theme":new e.a6({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new e.a6(e.a3.fog["horizon-blend"]),"star-intensity":new e.a6(e.a3.fog["star-intensity"]),"vertical-range":new e.a6(e.a3.fog["vertical-range"])});this._transitionable=new e.a4(o,r,new Map(n)),this.set(t,n),this._transitioning=this._transitionable.untransitioned(),this._transform=i,this.properties=new e.ad(o),this.scope=r}get state(){const t=this._transform,i="globe"===t.projection.name,r=e.ae(t.zoom),n=this.properties.get("range"),o=[.5,3];return{range:i?[e.af(o[0],n[0],r),e.af(o[1],n[1],r)]:n,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(t,i,r={}){if(this._validate(be,t,r))return;const n=e.l({},t);for(const t of Object.keys(e.a3.fog))void 0===n[t]&&(n[t]=e.a3.fog[t].default);this._options=n,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.ac(45,65,t))*i.a}getOpacityAtLatLng(t,i){return this._transform.projection.supportsFog?function(t,i,r){const n=e.aa.fromLngLat(i),o=r.elevation?r.elevation.getAtPointOrZero(n):0;return Fe(t,n.x,n.y,o,r)}(this.state,t,i):0}getOpacityForTile(t){if(!this._transform.projection.supportsFog)return[1,1];const i=this._transform.calculateFogTileMatrix(t.toUnwrapped());return Be(this.state,i,0,0,e.ag,e.ag,this._transform)}getOpacityForBounds(e,t,i,r,n){return this._transform.projection.supportsFog?Be(this.state,e,t,i,r,n,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 r of i){const i=t.points[r];let n;if(i[2]>=0)n=i;else{const o=t.points[r-4];n=e.ah(o,i,o[2]/(o[2]-i[2]))}if(Fe(this.state,n[0],n[1],0,this._transform)>=Le)return!0}return!1}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,new Map(e))}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(t,i,r){return(!r||!1!==r.validate)&&Pe(this,t.call(_e,e.l({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a3})))}}let Ve,Ue,je,Ge,qe=class extends e.E{constructor(t,i,r,n){super();const o=Ve||(Ve=new e.a5({density:new e.a6(e.a3.snow.density),intensity:new e.a6(e.a3.snow.intensity),color:new e.a6(e.a3.snow.color),opacity:new e.a6(e.a3.snow.opacity),vignette:new e.a6(e.a3.snow.vignette),"vignette-color":new e.a6(e.a3.snow["vignette-color"]),"center-thinning":new e.a6(e.a3.snow["center-thinning"]),direction:new e.a6(e.a3.snow.direction),"flake-size":new e.a6(e.a3.snow["flake-size"])}));this._transitionable=new e.a4(o,r,new Map(n)),this.set(t,n),this._transitioning=this._transitionable.untransitioned(),this.properties=new e.ad(o),this.scope=r}get state(){const t=this.properties.get("opacity"),i=this.properties.get("color"),r=this.properties.get("direction"),n=e.ai(r[0]),o=-Math.max(e.ai(r[1]),.01),s=[Math.cos(n)*Math.cos(o),Math.sin(n)*Math.cos(o),Math.sin(o)],a=this.properties.get("vignette"),l=this.properties.get("vignette-color");return l.a=a,{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new e.aj(i.r,i.g,i.b,i.a*t),direction:s,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:l}}get(){return this._transitionable.serialize()}set(t,i,r={}){if(this._validate(we,t,r))return;const n=e.l({},t);for(const t of Object.keys(e.a3.snow))void 0===n[t]&&(n[t]=e.a3.snow[t].default);this._options=n,this._transitionable.setTransitionOrValue(this._options,i)}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,new Map(e))}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(t,i,r){return(!r||!1!==r.validate)&&Pe(this,t.call(_e,e.l({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a3})))}},Ze=class extends e.E{constructor(t,i,r,n){super();const o=Ue||(Ue=new e.a5({density:new e.a6(e.a3.rain.density),intensity:new e.a6(e.a3.rain.intensity),color:new e.a6(e.a3.rain.color),opacity:new e.a6(e.a3.rain.opacity),vignette:new e.a6(e.a3.rain.vignette),"vignette-color":new e.a6(e.a3.rain["vignette-color"]),"center-thinning":new e.a6(e.a3.rain["center-thinning"]),direction:new e.a6(e.a3.rain.direction),"droplet-size":new e.a6(e.a3.rain["droplet-size"]),"distortion-strength":new e.a6(e.a3.rain["distortion-strength"])}));this._transitionable=new e.a4(o,r,new Map(n)),this.set(t,n),this._transitioning=this._transitionable.untransitioned(),this.properties=new e.ad(o),this.scope=r}get state(){const t=this.properties.get("opacity"),i=this.properties.get("color"),r=this.properties.get("direction"),n=e.ai(r[0]),o=-Math.max(e.ai(r[1]),.01),s=[Math.cos(n)*Math.cos(o),Math.sin(n)*Math.cos(o),Math.sin(o)],a=this.properties.get("vignette-color");return a.a=this.properties.get("vignette"),{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new e.aj(i.r,i.g,i.b,i.a*t),direction:s,centerThinning:this.properties.get("center-thinning"),dropletSize:this.properties.get("droplet-size"),distortionStrength:this.properties.get("distortion-strength"),vignetteColor:a}}get(){return this._transitionable.serialize()}set(t,i,r={}){if(this._validate(Te,t,r))return;const n=e.l({},t);for(const t of Object.keys(e.a3.rain))void 0===n[t]&&(n[t]=e.a3.rain[t].default);this._options=n,this._transitionable.setTransitionOrValue(this._options,i)}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,new Map(e))}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(t,i,r){return(!r||!1!==r.validate)&&Pe(this,t.call(_e,e.l({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a3})))}};class $e extends e.E{constructor(t,i,r,n){super(),this.scope=r,this._options=t,this.properties=new e.ad(i),this._transitionable=new e.a4(i,r,new Map(n)),this._transitionable.setTransitionOrValue(t.properties),this._transitioning=this._transitionable.untransitioned()}updateConfig(e){this._transitionable.setTransitionOrValue(this._options.properties,new Map(e))}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(e,t){this._options=e,this._transitionable.setTransitionOrValue(e.properties,t)}shadowsEnabled(){return!!this.properties&&!0===this.properties.get("cast-shadows")}}class He{constructor(e,t,i,r){this.screenBounds=e,this.cameraPoint=t,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,r)}static createFromScreenPoints(t,i){let r,n;if(t instanceof e.P||"number"==typeof t[0]){const o=e.P.convert(t);r=[o],n=i.isPointAboveHorizon(o)}else{const o=e.P.convert(t[0]),s=e.P.convert(t[1]);r=[o,s],n=e.al(o,s).every((e=>i.isPointAboveHorizon(e)))}return new He(r,i.getCameraPoint(),n,i)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return e.al(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const i=this.screenBounds[0],r=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],n=e.al(i,r,0,!1);return this.cameraPoint.y>r.y&&(this.cameraPoint.x>i.x&&this.cameraPoint.x<r.x?n.splice(3,0,this.cameraPoint):this.cameraPoint.x>=r.x?n[2]=this.cameraPoint:this.cameraPoint.x<=i.x&&(n[3]=this.cameraPoint)),e.am(n,t)}bufferedCameraGeometryGlobe(t){const i=this.screenBounds[0],r=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],n=e.al(i,r,t),o=this.cameraPoint.clone();switch(3*((o.y>i.y)+(o.y>r.y))+((o.x>i.x)+(o.x>r.x))){case 0:n[0]=o,n[4]=o.clone();break;case 1:n.splice(1,0,o);break;case 2:n[1]=o;break;case 3:n.splice(4,0,o);break;case 5:n.splice(2,0,o);break;case 6:n[3]=o;break;case 7:n.splice(3,0,o);break;case 8:n[2]=o}return n}containsTile(t,i,r,n=0){const o=t.queryPadding/i._pixelsPerMercatorPixel+1,s=r?this._bufferedCameraMercator(o,i):this._bufferedScreenMercator(o,i);let a=t.tileID.wrap+(s.unwrapped?n:0);const l=s.polygon.map((i=>e.an(t.tileTransform,i,a)));if(!e.ao(l,0,0,e.ag,e.ag))return;a=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?n:0);const c=this.screenGeometryMercator.polygon.map((i=>e.ap(t.tileTransform,i,a))),h=c.map((t=>new e.P(t[0],t[1]))),u=i.getFreeCameraOptions().position||new e.aa(0,0,0),d=e.ap(t.tileTransform,u,a),p=c.map((t=>{const i=e.ab.vec3.sub(t,t,d);return e.ab.vec3.normalize(i,i),new e.aq(d,i)})),f=e.ar(t,1,i.zoom)*i._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:h,tilespaceRays:p,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(m=e.as(l),m.min.x=e.aw(m.min.x,0,e.ag),m.min.y=e.aw(m.min.y,0,e.ag),m.max.x=e.aw(m.max.x,0,e.ag),m.max.y=e.aw(m.max.y,0,e.ag),m),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:f};var m}_bufferedScreenMercator(e,t){const i=Ye(e);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let r;return r="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._screenRaycastCache[i]=r,r}}_bufferedCameraMercator(e,t){const i=Ye(e);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let r;return r="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._cameraRaycastCache[i]=r,r}}_projectAndResample(t,i){const r=function(t,i){const r=e.ab.mat4.multiply([],i.pixelMatrix,i.globeMatrix),n=[0,-e.ax,0,1],o=[0,e.ax,0,1],s=[0,0,0,1];e.ab.vec4.transformMat4(n,n,r),e.ab.vec4.transformMat4(o,o,r),e.ab.vec4.transformMat4(s,s,r);const a=new e.P(n[0]/n[3],n[1]/n[3]),l=new e.P(o[0]/o[3],o[1]/o[3]),c=e.au(t,a)&&n[3]<s[3],h=e.au(t,l)&&o[3]<s[3];if(!c&&!h)return null;const u=function(e,t,i){for(let r=1;r<e.length;r++){const n=Xe(t.pointCoordinate3D(e[r-1]).x),o=Xe(t.pointCoordinate3D(e[r]).x);if(i<0){if(n<o)return{idx:r,t:-n/(o-1-n)}}else if(o<n)return{idx:r,t:(1-n)/(o+1-n)}}return null}(t,i,c?-1:1);if(!u)return null;const{idx:d,t:p}=u;let f=d>1?We(t.slice(0,d),i):[],m=d<t.length?We(t.slice(d),i):[];f=f.map((t=>new e.P(Xe(t.x),t.y))),m=m.map((t=>new e.P(Xe(t.x),t.y)));const _=[...f];0===_.length&&_.push(m[m.length-1]);const g=e.af(_[_.length-1].y,(0===m.length?f[0]:m[0]).y,p);let y;return y=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)],_.push(...y),0===m.length?_.push(f[0]):_.push(...m),{polygon:_.map((t=>new e.aa(t.x,t.y))),unwrapped:!1}}(t,i);if(r)return r;const n=function(t,i){let r=!1,n=-1/0,o=0;for(let e=0;e<t.length-1;e++)t[e].x>n&&(n=t[e].x,o=e);for(let e=0;e<t.length-1;e++){const i=(o+e)%(t.length-1),n=t[i],s=t[i+1];Math.abs(n.x-s.x)>.5&&(n.x<s.x?(n.x+=1,0===i&&(t[t.length-1].x+=1)):(s.x+=1,i+1===t.length-1&&(t[0].x+=1)),r=!0)}const s=e.at(i.center.lng);return r&&s<Math.abs(s-1)&&t.forEach((e=>{e.x-=1})),{polygon:t,unwrapped:r}}(We(t,i).map((t=>new e.P(Xe(t.x),t.y))),i);return{polygon:n.polygon.map((t=>new e.aa(t.x,t.y))),unwrapped:n.unwrapped}}}function We(t,i){return e.av(t,(e=>{const t=i.pointCoordinate3D(e);e.x=t.x,e.y=t.y}),1/256)}function Xe(e){return e<0?1+e%1:e%1}function Ye(e){return 100*e|0}function Ke(t,i,r,n,o){const s=function(r,n){if(r)return o(r);if(n){if(t.url&&n.tiles&&t.tiles&&delete t.tiles,n.variants){if(!Array.isArray(n.variants))return o(new Error("variants must be an array"));for(const t of n.variants){if(null==t||"object"!=typeof t||t.constructor!==Object)return o(new Error("variant must be an object"));if(!Array.isArray(t.capabilities))return o(new Error("capabilities must be an array"));if(1===t.capabilities.length&&"meshopt"===t.capabilities[0]){n=e.l(n,t);break}}}const r=e.ay(e.l({},n,t),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);r.tiles=i.canonicalizeTileset(r,t.url),o(null,r)}},a=function(e,t,i){if(!e)return null;if(!t&&!i)return e;i=i||e.worldview_default;const r=Object.values(e.language||{});if(0===r.length)return null;const n=Object.values(e.worldview||{});if(0===n.length)return null;const o=r.every((e=>e===t)),s=n.every((e=>e===i));return o&&s?e:t in(e.language_options||{})||i in(e.worldview_options||{})?null:e.language_options&&e.worldview_options?e:null}(t.data,r,n);return a?e.q.frame((()=>s(null,a))):t.url?e.n(i.transformRequest(i.normalizeSourceURL(t.url,null,r,n),e.R.Source),s):e.q.frame((()=>{const{data:e,...i}=t;s(null,i)}))}class Je{constructor(t,i,r){this.bounds=e.az.convert(this.validateBounds(t)),this.minzoom=i||0,this.maxzoom=r||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),r=Math.floor(e.at(this.bounds.getWest())*i),n=Math.floor(e.aA(this.bounds.getNorth())*i),o=Math.ceil(e.at(this.bounds.getEast())*i),s=Math.ceil(e.aA(this.bounds.getSouth())*i);return t.x>=r&&t.x<o&&t.y>=n&&t.y<s}}class Qe extends e.E{constructor(t,i,r,n){if(super(),this.id=t,this.dispatcher=r,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,e.l(this,e.ay(i,["url","scheme","tileSize","promoteId"])),this._options=e.l({type:"vector"},i),this._collectResourceTiming=!!i.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(n),this._tileWorkers={},this._deduped=new e.aB}load(t){this._loaded=!1,this.fire(new e.z("dataloading",{dataType:"source"}));const i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,r=this.map.getWorldview();this._tileJSONRequest=Ke(this._options,this.map._requestManager,i,r,((n,o)=>{if(this._tileJSONRequest=null,this._loaded=!0,n)i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${i}`),r&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${r}`),this.fire(new e.y(n));else if(o){if(e.l(this,o),this.hasWorldviews=!!o.worldview_options,o.worldview_default&&(this.worldviewDefault=o.worldview_default),o.vector_layers){this.vectorLayers=o.vector_layers,this.vectorLayerIds=[],this.localizableLayerIds=new Set;for(const e of o.vector_layers)this.vectorLayerIds.push(e.id),o.worldview&&o.worldview[e.source]&&this.localizableLayerIds.add(e.id)}o.bounds&&(this.tileBounds=new Je(o.bounds,this.minzoom,this.maxzoom)),z(o.tiles,this.map._requestManager._customAccessToken),this.fire(new e.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))}t&&t(n)}))}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const t=e.aC(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 r=t.tileID.canonical.url(this.tiles,this.scheme),n=this.map._requestManager.normalizeTileURL(r),o=this.map._requestManager.transformRequest(n,e.R.Tile),s=this.map.style?this.map.style.getLut(this.scope):null,a=s?{image:s.image.clone()}:null,l={request:o,data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,lut:a,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:e.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,scaleFactor:this.map.getScaleFactor()};if(this.hasWorldviews&&e.f(r)&&(l.worldview=this.map.getWorldview()||this.worldviewDefault,l.localizableLayerIds=this.localizableLayerIds),l.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state)"loading"===t.state?t.reloadCallback=i:t.request=t.actor.send("reloadTile",l,c.bind(this));else if(t.actor=this._tileWorkers[n]=this._tileWorkers[n]||this.dispatcher.getActor(),this.dispatcher.ready)t.request=t.actor.send("loadTile",l,c.bind(this),void 0,!0);else{const i=e.aD.call({deduped:this._deduped},l,((e,i)=>{e||!i?c.call(this,e):(l.data={cacheControl:i.cacheControl,expires:i.expires,rawData:i.rawData.slice(0)},t.actor&&t.actor.send("loadTile",l,c.bind(this),void 0,!0))}),!0);t.request={cancel:i}}function c(r,n){return delete t.request,t.aborted?i(null):r&&404!==r.status?i(r):(n&&n.resourceTiming&&(t.resourceTiming=n.resourceTiming),this.map._refreshExpiredTiles&&n&&t.setExpiryData(n),t.loadVectorData(n,this.map.painter),e.aE(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 et extends e.E{constructor(t,i,r,n){super(),this.id=t,this.dispatcher=r,this.setEventedParent(n),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=e.l({type:"raster"},i),e.l(this,e.ay(i,["url","scheme","tileSize"]))}load(t){this._loaded=!1,this.fire(new e.z("dataloading",{dataType:"source"})),this._tileJSONRequest=Ke(this._options,this.map._requestManager,null,null,((i,r)=>{this._tileJSONRequest=null,this._loaded=!0,i?this.fire(new e.y(i)):r&&(e.l(this,r),r.raster_layers&&(this.rasterLayers=r.raster_layers,this.rasterLayerIds=this.rasterLayers.map((e=>e.id))),r.bounds&&(this.tileBounds=new Je(r.bounds,this.minzoom,this.maxzoom)),z(r.tiles),this.fire(new e.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))),t&&t(i)}))}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const t=e.aC(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 r=e.q.devicePixelRatio>=2,n=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),r,this.tileSize);t.request=e.o(this.map._requestManager.transformRequest(n,e.R.Tile),((r,n,o,s)=>(delete t.request,t.aborted?(t.state="unloaded",i(null)):r?(t.state="errored",i(r)):n?(this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:o,expires:s}),t.setTexture(n,this.map.painter),t.state="loaded",e.aE(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 tt extends et{constructor(t,i,r,n){super(t,i,r,n),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 r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),n=this.map._requestManager.transformRequest(r,e.R.Tile);t.requestParams=n,t.actor||(t.actor=this.dispatcher.getActor()),t.request=t.fetchHeader(void 0,((e,r,n,o)=>{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:n,expires:o}),t.state="empty",i(null)}))}unloadTile(t,i){const r=t.texture;r&&r instanceof e.T?(t.destroy(!0),this.map.painter.saveTileTexture(r)):(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,r){t._isHeaderLoaded&&("empty"!==t.state&&(t.state="reloading"),t.fetchBand(i,r,((i,r)=>{if(i)return t.state="errored",this.fire(new e.y(i)),void this.triggerRepaint(t);r&&(t.setTexture(r,this.map.painter),t.state="loaded",this.triggerRepaint(t))})))}getInitialBand(e){if(!this.rasterLayers)return 0;const t=this.rasterLayers.find((({id:t})=>t===e)),i=t&&t.fields,r=i&&i.bands&&i.bands;return r?r[0]:0}getTextureDescriptor(t,i,r){if(!t)return;const n=i.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!n)return;let o=null;i instanceof e.aH?o=i.paint.get("raster-array-band"):i instanceof e.aI&&(o=i.paint.get("raster-particle-array-band"));const s=o||this.getInitialBand(n);if(null!=s)if(t.textureDescriptor){if(!t.updateNeeded(n,s)||r)return Object.assign({},t.textureDescriptor,{texture:t.texture})}else this.prepareTile(t,n,s)}}const it={vector:Qe,raster:et,"raster-dem":class extends et{constructor(t,i,r,n){super(t,i,r,n),this.type="raster-dem",this.maxzoom=22,this._options=e.l({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox"}loadTile(t,i){const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function n(e,r){e&&(t.state="errored",i(e)),r&&(t.dem=r,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0,t.state="loaded",i(null))}t.request=e.o(this.map._requestManager.transformRequest(r,e.R.Tile),function(r,o,s,a){if(delete t.request,t.aborted)t.state="unloaded",i(null);else if(r)t.state="errored",i(r);else if(o){this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:s,expires:a});const i=ImageBitmap&&o instanceof ImageBitmap&&e.t(),r=1-(o.width-e.aF(o.width))/2;r<1||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID));const l=i?o:e.q.getImageData(o,r),c={uid:t.uid,coord:t.tileID,source:this.id,scope:this.scope,rawImageData:l,encoding:this.encoding,padding:r};t.actor&&"expired"!==t.state||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",c,n.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(t){const i=t.canonical,r=Math.pow(2,i.z),n=(i.x-1+r)%r,o=0===i.x?t.wrap-1:t.wrap,s=(i.x+1+r)%r,a=i.x+1===r?t.wrap+1:t.wrap,l={};return l[new e.aG(t.overscaledZ,o,i.z,n,i.y).key]={backfilled:!1},l[new e.aG(t.overscaledZ,a,i.z,s,i.y).key]={backfilled:!1},i.y>0&&(l[new e.aG(t.overscaledZ,o,i.z,n,i.y-1).key]={backfilled:!1},l[new e.aG(t.overscaledZ,t.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new e.aG(t.overscaledZ,a,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1<r&&(l[new e.aG(t.overscaledZ,o,i.z,n,i.y+1).key]={backfilled:!1},l[new e.aG(t.overscaledZ,t.wrap,i.z,i.x,i.y+1).key]={backfilled:!1},l[new e.aG(t.overscaledZ,a,i.z,s,i.y+1).key]={backfilled:!1}),l}},"raster-array":tt,geojson:class extends e.E{constructor(t,i,r,n){super(),this.id=t,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=r.getActor(),this.setEventedParent(n),this._data=i.data,this._options=e.l({},i),this._collectResourceTiming=i.collectResourceTiming,void 0!==i.maxzoom&&(this.maxzoom=i.maxzoom),void 0!==i.minzoom&&(this.minzoom=i.minzoom),i.type&&(this.type=i.type),i.attribution&&(this.attribution=i.attribution),this.promoteId=i.promoteId;const o=e.ag/this.tileSize;this.workerOptions=e.l({source:this.id,scope:this.scope,cluster:i.cluster||!1,geojsonVtOptions:{buffer:(void 0!==i.buffer?i.buffer:128)*o,tolerance:(void 0!==i.tolerance?i.tolerance:.375)*o,extent:e.ag,maxZoom:this.maxzoom,lineMetrics:i.lineMetrics||!1,generateId:i.generateId||!1},superclusterOptions:{maxZoom:void 0!==i.clusterMaxZoom?i.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,i.clusterMinPoints||2),extent:e.ag,radius:(void 0!==i.clusterRadius?i.clusterRadius:50)*o,log:!1,generateId:i.generateId||!1},clusterProperties:i.clusterProperties,filter:i.filter,dynamic:i.dynamic},i.workerOptions)}onAdd(e){this.map=e,this.setData(this._data)}setData(e){return this._data=e,this._updateWorkerData(),this}updateData(t){if(!this._options.dynamic)return this.fire(new e.y(new Error("Can't call updateData on a GeoJSON source with dynamic set to false.")));if("string"!=typeof t&&("Feature"===t.type&&(t={type:"FeatureCollection",features:[t]}),"FeatureCollection"!==t.type))return this.fire(new e.y(new Error("Data to update should be a feature or a feature collection.")));if(this._coalesce&&"string"!=typeof t&&"string"!=typeof this._data&&"FeatureCollection"===this._data.type){const e=new Map;for(const t of this._data.features)e.set(t.id,t);for(const i of t.features)e.set(i.id,i);this._data.features=[...e.values()]}else this._data=t;return this._updateWorkerData(!0),this}getClusterExpansionZoom(e,t){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:e,source:this.id,scope:this.scope},t),this}getClusterChildren(e,t){return this.actor.send("geojson.getClusterChildren",{clusterId:e,source:this.id,scope:this.scope},t),this}getClusterLeaves(e,t,i,r){return this.actor.send("geojson.getClusterLeaves",{source:this.id,scope:this.scope,clusterId:e,limit:t,offset:i},r),this}_updateWorkerData(t=!1){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new e.z("dataloading",{dataType:"source"})),this._loaded=!1;const i=e.l({append:t},this.workerOptions);i.scope=this.scope;const r=this._data;"string"==typeof r?(i.request=this.map._requestManager.transformRequest(e.q.resolveURL(r),e.R.Source),i.request.collectResourceTiming=this._collectResourceTiming):i.data=JSON.stringify(r),this._pendingLoad=this.actor.send(`${this.type}.loadData`,i,((i,r)=>{if(this._loaded=!0,this._pendingLoad=null,i)this.fire(new e.y(i));else{const i={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&r&&r.resourceTiming&&r.resourceTiming[this.id]&&(i.resourceTiming=r.resourceTiming[this.id]),t&&(this._partialReload=!0),this.fire(new e.z("data",i)),this._partialReload=!1,this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(t),this._coalesce=!1)}))}loaded(){return this._loaded}loadTile(t,i){const r=t.actor?"reloadTile":"loadTile";t.actor=this.actor;const n=this.map.style?this.map.style.getLut(this.scope):null,o=n?{image:n.image.clone()}:null,s=this._partialReload,a={type:this.type,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,lut:o,scope:this.scope,pixelRatio:e.q.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,scaleFactor:this.map.getScaleFactor(),partial:s};t.request=this.actor.send(r,a,((e,n)=>s&&!n?(t.state="loaded",i(null)):(delete t.request,t.destroy(),t.aborted?i(null):e?i(e):(t.loadVectorData(n,this.map.painter,"reloadTile"===r),i(null)))),void 0,"loadTile"===r)}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0}unloadTile(e,t){this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy()}onRemove(e){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return e.l({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends e.aJ{constructor(e,t,i,r){super(e,t,i,r),this.roundZoom=!0,this.type="video",this.options=t}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const i of t.urls)this.urls.push(this.map._requestManager.transformRequest(i,e.R.Source).url);e.aK(this.urls,((t,i)=>{this._loaded=!0,t?this.fire(new e.y(t)):i&&(this.video=i,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading())}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const i=this.video.seekable;t<i.start(0)||t>i.end(0)?this.fire(new e.y(new e.V(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const t=this.map.painter.context,i=t.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new e.T(t,this.video,i.RGBA8),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:e.aJ,model:class extends e.E{constructor(e,t,i,r){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 r=this._options.models[i],n=e.aM(this.map._requestManager.transformRequest(r.uri,e.R.Model).url).then((t=>{if(!t)return;const n=e.aN(t),o=new e.aO(i,r.position,r.orientation,n);o.computeBoundsAndApplyParent(),this.models.push(o)})).catch((t=>{this.fire(new e.y(new Error(`Could not load model ${i} from ${r.uri}: ${t.message}`)))}));t.push(n)}return Promise.allSettled(t).then((()=>{this._loaded=!0,this.fire(new e.z("data",{dataType:"source",sourceDataType:"metadata"}))})).catch((t=>{this.fire(new e.y(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,r){super(),this.type="batched-model",this.id=e,this.tileSize=512,this._options=t,this.tiles=this._options.tiles,this.maxzoom=t.maxzoom||19,this.minzoom=t.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=i,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(r)}onAdd(e){this.map=e,this.load()}load(t){this._loaded=!1,this.fire(new e.z("dataloading",{dataType:"source"}));const i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,r=this.map.getWorldview();this._tileJSONRequest=Ke(this._options,this.map._requestManager,i,r,((n,o)=>{this._tileJSONRequest=null,this._loaded=!0,n?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${i}`),r&&2!==r.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${r}`),this.fire(new e.y(n))):o&&(e.l(this,o),o.bounds&&(this.tileBounds=new Je(o.bounds,this.minzoom,this.maxzoom)),z(o.tiles,this.map._requestManager._customAccessToken),this.fire(new e.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))),t&&t(n)}))}hasTransition(){return!1}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loaded(){return this._loaded}loadTile(t,i){const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),n={request:this.map._requestManager.transformRequest(r,e.R.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,isSymbolTile:t.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,lut:null,maxZoom:null,promoteId:null,pixelRatio:null,scaleFactor:null};if(t.actor&&"expired"!==t.state)if("loading"===t.state)t.reloadCallback=i;else{if(t.buckets){const e=Object.values(t.buckets);for(const t of e)t.dirty=!0;return void(t.state="loaded")}t.request=t.actor.send("reloadTile",n,o.bind(this))}else t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",n,o.bind(this),void 0,!0);function o(e,r){return t.aborted?i(null):e&&404!==e.status?i(e):(this.map._refreshExpiredTiles&&r&&t.setExpiryData(r),t.loadModelData(r,this.map.painter),t.state="loaded",void i(null))}}serialize(){return e.l({},this._options)}},canvas:class extends e.aJ{constructor(t,i,r,n){super(t,i,r,n),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new e.y(new e.V(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.y(new e.V(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new e.y(new e.V(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new e.y(new e.V(`sources.${t}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new e.y(new e.V(`sources.${t}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.y(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(e){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context;this.texture?!t&&!this._playing||this.texture instanceof e.aL||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new e.T(i,this.canvas,i.gl.RGBA8,{premultiply:!0}),this._prepareData(i)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}},custom:class extends e.E{constructor(t,i,r,n){super(),this.id=t,this.type="custom",this._dataType="raster",this._dispatcher=r,this._implementation=i,this.setEventedParent(n),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new e.y(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new e.y(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new Je(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.ay(i,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return e.ay(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new e.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(t){this.map=t,this._loaded=!1,this.fire(new e.z("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(t),this.load()}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e)}hasTile(e){if(this._implementation.hasTile){const{x:t,y:i,z:r}=e.canonical;return this._implementation.hasTile({x:t,y:i,z:r})}return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e,t){const{x:i,y:r,z:n}=e.tileID.canonical,o=new AbortController;e.request=Promise.resolve(this._implementation.loadTile({x:i,y:r,z:n},{signal:o.signal})).then(function(i){return delete e.request,e.aborted?(e.state="unloaded",t(null)):void 0===i?(e.state="errored",t(null)):null===i?(this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",t(null)):function(e){return e instanceof ImageData||e instanceof HTMLCanvasElement||e instanceof ImageBitmap||e instanceof HTMLImageElement}(i)?(this.loadTileData(e,i),e.state="loaded",void t(null)):(e.state="errored",t(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch((i=>{20!==i.code&&(e.state="errored",t(i))})),e.request.cancel=()=>o.abort()}loadTileData(e,t){e.setTexture(t,this.map.painter)}unloadTile(t,i){if(t.texture&&t.texture instanceof e.T?(t.destroy(!0),t.texture&&t.texture instanceof e.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),this._implementation.unloadTile){const{x:e,y:i,z:r}=t.tileID.canonical;this._implementation.unloadTile({x:e,y:i,z:r})}i&&i()}abortTile(e,t){e.request&&e.request.cancel&&(e.request.cancel(),delete e.request),t&&t()}hasTransition(){return!1}_coveringTiles(){return this.map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map((e=>({x:e.canonical.x,y:e.canonical.y,z:e.canonical.z})))}_clearTiles(){const t=e.aC(this.id,this.scope);this.map.style.clearSource(t)}_update(){this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))}}},rt=function(t,i,r,n){const o=new it[i.type](t,i,r,n);if(o.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${o.id}`);return e.aP(["load","abort","unload","serialize","prepare"],o),o};function nt(e,t,i,r,n=!1){const o=t.sourceCache.transform,s=t.sourceCache.tilesIn(e,t.has3DLayers,n);s.sort(at);const a=[];for(const e of s){const s=e.tile.queryRenderedFeatures(t,e,i,r,o,n);Object.keys(s).length&&a.push({wrappedTileID:e.tile.tileID.wrapped().key,queryResults:s})}return 0===a.length?{}:function(e){const t={},i={};for(const r of e){const e=r.queryResults,n=r.wrappedTileID,o=i[n]=i[n]||{};for(const i in e){const r=e[i],n=o[i]=o[i]||{},s=t[i]=t[i]||[];for(const e of r)n[e.featureIndex]||(n[e.featureIndex]=!0,s.push(e))}}return t}(a)}function ot(e,t,i,r,n){const o={},s=r.queryRenderedSymbols(e),a=[];for(const e of Object.keys(s).map(Number))a.push(n[e]);a.sort(at);for(const e of a){const r=e.featureIndex.lookupSymbolFeatures(s[e.bucketInstanceId],e.bucketIndex,e.sourceLayerIndex,t,i);for(const t in r){const i=o[t]=o[t]||[],n=r[t];n.sort(((t,i)=>{const r=e.featureSortOrder;if(r){const e=r.indexOf(t.featureIndex);return r.indexOf(i.featureIndex)-e}return i.featureIndex-t.featureIndex}));for(const e of n)i.push(e)}}return o}function st(e,t){const i=e.getRenderableIds().map((t=>e.getTileByID(t))),r=[],n={};for(let e=0;e<i.length;e++){const o=i[e],s=o.tileID.canonical.key;n[s]||(n[s]=!0,o.querySourceFeatures(r,t))}return r}function at(e,t){const i=e.tileID,r=t.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}function lt(e,t){const i={};if(!t)return i;for(const r of e){const e=r.layerIds.map((e=>t.getLayer(e))).filter(Boolean);if(0!==e.length){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((t=>e.filter((e=>e.id===t))[0])));for(const t of e)i[t.fqid]=r}}return i}const ct=32,ht=33,ut=new Uint16Array(8184);for(let e=0;e<2046;e++){let t=e+2,i=0,r=0,n=0,o=0,s=0,a=0;for(1&t?n=o=s=ct:i=r=a=ct;(t>>=1)>1;){const e=i+n>>1,l=r+o>>1;1&t?(n=i,o=r,i=s,r=a):(i=n,r=o,n=s,o=a),s=e,a=l}const l=4*e;ut[l+0]=i,ut[l+1]=r,ut[l+2]=n,ut[l+3]=o}const dt=new Uint16Array(2178),pt=new Uint8Array(1089),ft=new Uint16Array(1089);function mt(e){return 0===e?-.03125:32===e?.03125:0}const _t={type:2,extent:e.ag,loadGeometry:()=>[[new e.P(0,0),new e.P(e.ag+1,0),new e.P(e.ag+1,e.ag+1),new e.P(0,e.ag+1),new e.P(0,0)]]};class gt{constructor(t,i,r,n,o){this.tileID=t,this.uid=e.aV(),this.uses=0,this.tileSize=i,this.tileZoom=r,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=o,n&&n.style&&(this._lastUpdatedBrightness=n.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",n&&n.transform&&(this.projection=n.transform.projection)}registerFadeDuration(t){const i=t+this.timeAdded;i<e.q.now()||this.fadeEndTime&&i<this.fadeEndTime||(this.fadeEndTime=i)}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}get tileTransform(){return this._tileTransform||(this._tileTransform=e.aQ(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(t,i,r){if(this.unloadVectorData(),this.state="loaded",t){t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,this.latestFeatureIndex.rawTileData=t.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=t.collisionBoxArray,this.buckets=lt(t.buckets,i.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const i=this.buckets[t];if(i instanceof e.aX){if(this.hasSymbolBuckets=!0,!r)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.aX&&i.hasRTLText){this.hasRTLText=!0,e.aY();break}}this.queryPadding=0;for(const e in this.buckets){const t=this.buckets[e],r=i.style.getOwnLayer(e);if(!r)continue;const n=r.queryRadius(t);this.queryPadding=Math.max(this.queryPadding,n)}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.aW}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"}}loadModelData(e,t,i){e&&(e.resourceTiming&&(this.resourceTiming=e.resourceTiming),this.buckets={...this.buckets,...lt(e.buckets,t.style)},e.featureIndex&&(this.latestFeatureIndex=e.featureIndex))}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,r=this.imageAtlas;if(r&&!r.uploaded){const n=!!Object.keys(r.patternPositions).length;this.imageAtlasTexture=new e.T(t,r.image,i.RGBA8,{useMipmap:n}),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 r=t.style.getBrightness();(this._lastUpdatedBrightness||r)&&(this._lastUpdatedBrightness&&r&&Math.abs(this._lastUpdatedBrightness-r)<.001||(this.updateBuckets(t,this._lastUpdatedBrightness!==r),this._lastUpdatedBrightness=r))}queryRenderedFeatures(t,i,r,n,o,s){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData&&!this.latestFeatureIndex.is3DTile)return{};const a=function(t,i){const r=e.ab.mat4.fromScaling([],[.5*t.width,.5*-t.height,1]);return e.ab.mat4.translate(r,r,[1,-1,0]),e.ab.mat4.multiply(r,r,t.calculateProjMatrix(i.toUnwrapped())),Float32Array.from(r)}(o,this.tileID);return this.latestFeatureIndex.query(t,{tilespaceGeometry:i,pixelPosMatrix:a,transform:n,availableImages:r,tileTransform:this.tileTransform})}querySourceFeatures(t,i){const r=this.latestFeatureIndex;if(!r||!r.rawTileData)return;const n=r.loadVTLayers(),o=i?i.sourceLayer:"",s=n._geojsonTileLayer||n[o];if(!s)return;const a=e.aZ(i&&i.filter),{z:l,x:c,y:h}=this.tileID.canonical,u={z:l,x:c,y:h};for(let i=0;i<s.length;i++){const n=s.feature(i);if(a.needGeometry){const t=e.a_(n,!0);if(!a.filter(new e.a8(this.tileID.overscaledZ),t,this.tileID.canonical))continue}else if(!a.filter(new e.a8(this.tileID.overscaledZ),n))continue;const d=r.getId(n,o),p=new e.a$(n,l,c,h,d);p.tile=u,t.push(p)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return!!this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){const i=this.expirationTime;if(t.cacheControl){const i=e.b0(t.cacheControl);i["max-age"]&&(this.expirationTime=Date.now()+1e3*i["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const e=Date.now();let t=!1;if(this.expirationTime>e)t=!1;else if(i)if(this.expirationTime<i)t=!0;else{const r=this.expirationTime-i;r?this.expirationTime=e+Math.max(r,3e4):t=!0}else t=!0;t?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-(new Date).getTime(),Math.pow(2,31)-1)}refreshFeatureState(e){this.latestFeatureIndex&&(this.latestFeatureIndex.rawTileData||this.latestFeatureIndex.is3DTile)&&e&&this.updateBuckets(e)}updateBuckets(t,i){if(!this.latestFeatureIndex)return;const r=this.latestFeatureIndex.loadVTLayers(),n=t.style.listImages(),o=t.style.getBrightness();for(const s in this.buckets){if(!t.style.hasLayer(s))continue;const a=this.buckets[s],l=a.layers[0],c=l.sourceLayer||"_geojsonTileLayer",h=r[c],u=t.style.getSourceCache(l.source,l.scope);let d={};u&&(d=u._state.getState(c,void 0));const p=this.imageAtlas&&this.imageAtlas.patternPositions||{},f=Object.keys(d).length>0&&!i;(f&&0!==a.stateDependentLayers.length||i)&&a.update(d,h,n,p,f?a.stateDependentLayers:a.layers,i,o),(a instanceof e.b1||a instanceof e.b2)&&t._terrain&&t._terrain.enabled&&u&&a.programConfigurations.needsUpload&&t._terrain._clearRenderCacheForTile(u.id,this.tileID);const m=t&&t.style&&t.style.getOwnLayer(s);m&&(this.queryPadding=Math.max(this.queryPadding,m.queryRadius(a)))}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<e.q.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(t){this.symbolFadeHoldUntil=e.q.now()+t}setTexture(t,i){const r=i.context,n=r.gl;this.texture=this.texture||i.getTileTexture(t.width),this.texture&&this.texture instanceof e.T?this.texture.update(t):(this.texture=new e.T(r,t,n.RGBA8,{useMipmap:!0}),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE))}setDependencies(e,t){const i={};for(const e of t)i[e]=!0;this.dependencies[e]=i}hasDependency(e,t){for(const i of e){const e=this.dependencies[i];if(e)for(const i of t)if(e[i])return!0}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(t,i){if(!i||"mercator"===i.name||this._tileDebugBuffer)return;const r=e.b3(_t,this.tileID.canonical,this.tileTransform)[0],n=new e.b4,o=new e.b5;for(let e=0;e<r.length;e++){const{x:t,y:i}=r[e];n.emplaceBack(t,i),o.emplaceBack(e)}o.emplaceBack(0),this._tileDebugIndexBuffer=t.createIndexBuffer(o),this._tileDebugBuffer=t.createVertexBuffer(n,e.b6.members),this._tileDebugSegments=e.b7.simpleSegment(0,0,n.length,o.length)}_makeTileBoundsBuffers(t,i){if(this._tileBoundsBuffer||!i||"mercator"===i.name)return;const r=e.b3(_t,this.tileID.canonical,this.tileTransform)[0];let n,o;if(this.isRaster){const t=function(t,i){const r=e.aQ(t,i),n=Math.pow(2,t.z);for(let o=0;o<ht;o++)for(let s=0;s<ht;s++){const a=e.aR((t.x+(s+mt(s))/ct)/n),l=e.aS((t.y+(o+mt(o))/ct)/n),c=i.project(a,l),h=o*ht+s;dt[2*h+0]=Math.round((c.x*r.scale-r.x)*e.ag),dt[2*h+1]=Math.round((c.y*r.scale-r.y)*e.ag)}pt.fill(0),ft.fill(0);for(let e=2045;e>=0;e--){const t=4*e,i=ut[t+0],r=ut[t+1],n=ut[t+2],o=ut[t+3],s=i+n>>1,a=r+o>>1,l=s+a-r,c=a+i-s,h=r*ht+i,u=o*ht+n,d=a*ht+s,p=Math.hypot((dt[2*h+0]+dt[2*u+0])/2-dt[2*d+0],(dt[2*h+1]+dt[2*u+1])/2-dt[2*d+1])>=16;pt[d]=pt[d]||(p?1:0),e<1022&&(pt[d]=pt[d]||pt[(r+c>>1)*ht+(i+l>>1)]||pt[(o+c>>1)*ht+(n+l>>1)])}const o=new e.aT,s=new e.aU;let a=0;function l(t,i){const r=i*ht+t;return 0===ft[r]&&(o.emplaceBack(dt[2*r+0],dt[2*r+1],t*e.ag/ct,i*e.ag/ct),ft[r]=++a),ft[r]-1}function c(e,t,i,r,n,o){const a=e+i>>1,h=t+r>>1;if(Math.abs(e-n)+Math.abs(t-o)>1&&pt[h*ht+a])c(n,o,e,t,a,h),c(i,r,n,o,a,h);else{const a=l(e,t),c=l(i,r),h=l(n,o);s.emplaceBack(a,c,h)}}return c(0,0,ct,ct,ct,0),c(ct,ct,0,0,0,ct),{vertices:o,indices:s}}(this.tileID.canonical,i);n=t.vertices,o=t.indices}else{n=new e.aT,o=new e.aU;for(const{x:e,y:t}of r)n.emplaceBack(e,t,0,0);const t=e.b8(n.int16,void 0,4);for(let e=0;e<t.length;e+=3)o.emplaceBack(t[e],t[e+1],t[e+2])}this._tileBoundsBuffer=t.createVertexBuffer(n,e.b9.members),this._tileBoundsIndexBuffer=t.createIndexBuffer(o),this._tileBoundsSegments=e.b7.simpleSegment(0,0,n.length,o.length)}_makeGlobeTileDebugBuffers(t,i){const r=i.projection;if(!r||"globe"!==r.name||i.freezeTileCoverage)return;const n=this.tileID.canonical,o=e.ba(n,i),s=e.bb(o),a=e.ae(i.zoom);let l;a>0&&(l=e.ab.mat4.invert(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(t,n,i,s,l,a),this._makeGlobeTileDebugTextBuffer(t,n,i,s,l,a)}_globePoint(t,i,r,n,o,s,a){let l=e.bc(t,i,r);if(s){const o=1<<r.z,c=e.at(n.center.lng),h=e.aA(n.center.lat),u=(r.x+.5)/o-c;let d=0;u>.5?d=-1:u<-.5&&(d=1);let p=(t/e.ag+r.x)/o+d,f=(i/e.ag+r.y)/o;p=(p-c)*n._pixelsPerMercatorPixel+c,f=(f-h)*n._pixelsPerMercatorPixel+h;const m=[p*n.worldSize,f*n.worldSize,0];e.ab.vec3.transformMat4(m,m,s),l=e.bd(l,m,a)}return e.ab.vec3.transformMat4(l,l,o)}_makeGlobeTileDebugBorderBuffer(t,i,r,n,o,s){const a=new e.b4,l=new e.b5,c=new e.be,h=(e,t,h,u,d)=>{const p=(h-e)/(d-1),f=(u-t)/(d-1),m=a.length;for(let h=0;h<d;h++){const u=e+h*p,d=t+h*f;a.emplaceBack(u,d);const _=this._globePoint(u,d,i,r,n,o,s);c.emplaceBack(_[0],_[1],_[2]),l.emplaceBack(m+h)}},u=e.ag;h(0,0,u,0,16),h(u,0,u,u,16),h(u,u,0,u,16),h(0,u,0,0,16),this._tileDebugIndexBuffer=t.createIndexBuffer(l),this._tileDebugBuffer=t.createVertexBuffer(a,e.b6.members),this._globeTileDebugBorderBuffer=t.createVertexBuffer(c,e.bf.members),this._tileDebugSegments=e.b7.simpleSegment(0,0,a.length,l.length)}_makeGlobeTileDebugTextBuffer(t,i,r,n,o,s){const a=e.ag/4,l=new e.b4,c=new e.aU,h=new e.be,u=25;c.reserve(32),l.reserve(u),h.reserve(u);const d=(e,t)=>u*e+t;for(let e=0;e<u;e++){const t=e*a;for(let e=0;e<u;e++){const c=e*a;l.emplaceBack(c,t);const u=this._globePoint(c,t,i,r,n,o,s);h.emplaceBack(u[0],u[1],u[2])}}for(let e=0;e<4;e++)for(let t=0;t<4;t++){const i=d(e,t),r=d(e,t+1),n=d(e+1,t),o=d(e+1,t+1);c.emplaceBack(i,r,n),c.emplaceBack(n,r,o)}this._tileDebugTextIndexBuffer=t.createIndexBuffer(c),this._tileDebugTextBuffer=t.createVertexBuffer(l,e.b6.members),this._globeTileDebugTextBuffer=t.createVertexBuffer(h,e.bf.members),this._tileDebugTextSegments=e.b7.simpleSegment(0,0,u,32)}destroy(t=!1){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(),delete this.imageAtlasTexture),this.glyphAtlasTexture&&(this.glyphAtlasTexture.destroy(),delete this.glyphAtlasTexture),this.lineAtlasTexture&&(this.lineAtlasTexture.destroy(),delete this.lineAtlasTexture),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),!t&&this.texture&&this.texture instanceof e.T&&(this.texture.destroy(),delete this.texture),this.hillshadeFBO&&(this.hillshadeFBO.destroy(),delete this.hillshadeFBO),this.dem&&delete this.dem,this.neighboringTiles&&delete this.neighboringTiles,this.demTexture&&(this.demTexture.destroy(),delete this.demTexture),this.rasterParticleState&&(this.rasterParticleState.destroy(),delete this.rasterParticleState),this.latestFeatureIndex=null,this.state="unloaded"}}e.bg.setPbf(e.bh);class yt extends gt{constructor(e,t,i,r,n){super(e,t,i,r,n),this._workQueue=[],this._fetchQueue=[],this._isHeaderLoaded=!1}setTexture(t,i){const r=i.context,n=r.gl;this.texture=this.texture||i.getTileTexture(t.width),this.texture&&this.texture instanceof e.T?this.texture.update(t,{premultiply:!1}):this.texture=new e.T(r,t,n.RGBA8,{premultiply:!1})}flushQueues(){for(;this._workQueue.length;)this._workQueue.pop()();for(;this._fetchQueue.length;)this._fetchQueue.pop()()}fetchHeader(t=16384,i){const r=this._mrt=new e.bg(30),n=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(t-1)}});return this.entireBuffer=null,this.request=e.bi(n,((e,n,o,s)=>{if(e)i(e);else try{const e=r.getHeaderLength(n);if(e>t)return void(this.request=this.fetchHeader(e,i));r.parseHeader(n),this._isHeaderLoaded=!0;let a=0;for(const e of Object.values(r.layers))a=Math.max(a,e.dataIndex[e.dataIndex.length-1].last_byte);n.byteLength>=a&&(this.entireBuffer=n),i(null,this.entireBuffer||n,o,s)}catch(e){i(e)}})),this.request}fetchBand(t,i,r){const n=this._mrt;if(!this._isHeaderLoaded||!n)return void r(new Error("Tile header is not ready"));const o=this.actor;if(!o)return void r(new Error("Can't fetch tile band without an actor"));let s;const a=(e,n)=>{s.complete(e,n),e?r(e):(this.updateTextureDescriptor(t,i),r(null,this.textureDescriptor&&this.textureDescriptor.img))},l=(e,t)=>{if(e)return r(e);const i=o.send("decodeRasterArray",{buffer:t,task:s},a,void 0,!0);this._workQueue.push((()=>{i&&i.cancel(),s.cancel()}))},c=n.getLayer(t);if(!c)return void r(new Error(`Unknown sourceLayer "${t}"`));if(c.hasDataForBand(i))return this.updateTextureDescriptor(t,i),void r(null,this.textureDescriptor?this.textureDescriptor.img:null);const h=c.getDataRange([i]);if(s=n.createDecodingTask(h),!s||s.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.bi(t,l);this._fetchQueue.push((()=>{i.cancel(),s.cancel()}))}else r(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 r=this._mrt.getLayer(t);if(!r||!r.hasBand(i)||!r.hasDataForBand(i))return;const{bytes:n,tileSize:o,buffer:s,offset:a,scale:l}=r.getBandView(i),c=o+2*s,h={data:n,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:s,offset:a,tileSize:o,format:r.pixelFormat,mix:[l,256*l,65536*l,16777216*l]}}}class xt{constructor(e,t){this.max=e,this.onRemove=t,this.reset()}reset(){for(const e in this.data)for(const t of this.data[e])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}add(e,t,i){const r=e.wrapped().key;void 0===this.data[r]&&(this.data[r]=[]);const n={value:t,timeout:void 0};if(void 0!==i&&(n.timeout=setTimeout((()=>{this.remove(e,n)}),i)),this.data[r].push(n),this.order.push(r),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const i=e.wrapped().key,r=void 0===t?0:this.data[i].indexOf(t),n=this.data[i][r];return this.data[i].splice(r,1),n.timeout&&clearTimeout(n.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(n.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){const t=[];for(const i in this.data)for(const r of this.data[i])e(r.value)||t.push(r);for(const e of t)this.remove(e.value.tileID,e)}}class vt{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,i,r){const n=String(i);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][n]=this.stateChanges[t][n]||{},e.l(this.stateChanges[t][n],r),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==n&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][n]){this.deletedStates[t][n]={};for(const e in this.state[t][n])r[e]||(this.deletedStates[t][n][e]=null)}else for(const e in r)this.deletedStates[t]&&this.deletedStates[t][n]&&null===this.deletedStates[t][n][e]&&delete this.deletedStates[t][n][e]}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const r=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&void 0!==t)null!==this.deletedStates[e][r]&&(this.deletedStates[e][r]=this.deletedStates[e][r]||{},this.deletedStates[e][r][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][r])for(i in this.deletedStates[e][r]={},this.stateChanges[e][r])this.deletedStates[e][r][i]=null;else this.deletedStates[e][r]=null;else this.deletedStates[e]=null}getState(t,i){const r=this.state[t]||{},n=this.stateChanges[t]||{},o=this.deletedStates[t];if(null===o)return{};if(void 0!==i){const t=String(i),s=e.l({},r[t],n[t]);if(o){const e=o[i];if(null===e)return{};for(const t in e)delete s[t]}return s}const s=e.l({},r,n);if(o)for(const e in o)delete s[e];return s}initializeTileState(e,t){e.refreshFeatureState(t)}coalesceChanges(t,i){const r={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const i={};for(const r in this.stateChanges[t])this.state[t][r]||(this.state[t][r]={}),e.l(this.state[t][r],this.stateChanges[t][r]),i[r]=this.state[t][r];r[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]}r[t]=r[t]||{},e.l(r[t],i)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(r).length)for(const e in t)t[e].refreshFeatureState(i)}}class bt 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 xt(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 vt,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.bj(this._tiles).map((e=>e.tileID)).sort(wt).map((e=>e.key))}getRenderableIds(t,i){const r=[];for(const e in this._tiles)this._isIdRenderable(+e,t,i)&&r.push(this._tiles[e]);return t?r.sort(((t,i)=>{const r=t.tileID,n=i.tileID,o=new e.P(r.canonical.x,r.canonical.y)._rotate(this.transform.angle),s=new e.P(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return r.overscaledZ-n.overscaledZ||s.y-o.y||s.x-o.x})).map((e=>e.tileID.key)):r.map((e=>e.tileID)).sort(wt).map((e=>e.key))}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return!!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t,i){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())&&(i||!this._shadowCasterTiles[e])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const e in this._tiles)"errored"!==this._tiles[e].state&&this._reloadTile(+e,"reloading")}}_reloadTile(e,t){const i=this._tiles[e];i&&("loading"!==i.state&&(i.state=t),this._loadTile(i,this._tileLoaded.bind(this,i,e,t)))}_tileLoaded(t,i,r,n){if(n)if(t.state="errored",404!==n.status)this._source.fire(new e.y(n,{tile:t}));else{if(this._source.fire(new e.z("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id,tile:t})),!(t.tileID.key in this._loadedParentTiles))return;if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const e=this.map.painter.terrain;this.update(this.transform,e.getScaledDemTileSize(),!0),e.resetTileLookupCache(this.id)}else this.update(this.transform)}else t.timeAdded=e.q.now(),"expired"===r&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(i,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new e.z("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(e){const t=this.getRenderableIds();for(let r=0;r<t.length;r++){const n=t[r];if(e.neighboringTiles&&e.neighboringTiles[n]){const t=this.getTileByID(n);i(e,t),i(t,e)}}function i(e,t){if(!e.dem||e.dem.borderReady)return;e.needsHillshadePrepare=!0,e.needsDEMTextureUpload=!0;let i=t.tileID.canonical.x-e.tileID.canonical.x;const r=t.tileID.canonical.y-e.tileID.canonical.y,n=Math.pow(2,e.tileID.canonical.z),o=t.tileID.key;0===i&&0===r||Math.abs(r)>1||(Math.abs(i)>1&&(1===Math.abs(i+n)?i+=n:1===Math.abs(i-n)&&(i-=n)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,r),e.neighboringTiles&&e.neighboringTiles[o]&&(e.neighboringTiles[o].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,i,r){for(const n in this._tiles){let o=this._tiles[n];if(r[n]||!o.hasData()||o.tileID.overscaledZ<=t||o.tileID.overscaledZ>i)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>t+1;){const e=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[e.key],o&&o.hasData()&&(s=e)}let a=s;for(;a.overscaledZ>t;)if(a=a.scaledTo(a.overscaledZ-1),e[a.key]){r[s.key]=s;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const i=this._loadedParentTiles[e.key];return i&&i.tileID.overscaledZ>=t?i:null}for(let i=e.overscaledZ-1;i>=t;i--){const t=e.scaledTo(i),r=this._getLoadedTile(t);if(r)return r}}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,t){t=t||this._source.tileSize;const i=Math.ceil(e.width/t)+1,r=Math.ceil(e.height/t)+1,n=Math.floor(i*r*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,n):n,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),e[r.tileID.key]=r}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(+e,this._tiles[e])}}update(t,i,r,n){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!r)return;this.updateCacheSize(t,i),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};const o="batched-model"===this._source.type;let s,a=this._source.maxzoom;const l=this.map&&this.map.painter?this.map.painter._terrain:null;if(l&&l.sourceCache===this&&l.attenuationRange()){const e=l.attenuationRange()[0],t=Math.floor(e)-Math.log2(l.getDemUpscale());a>t&&(a=t)}if(this.used||this.usedForTerrain){if(this._source.tileID)s=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new e.aG(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)));else if(0!==this.tileCoverLift){const n=t.clone();n.tileCoverLift=this.tileCoverLift,s=n.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:a,roundZoom:this._source.roundZoom&&!r,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:o}),this._source.minzoom<=1&&"globe"===t.projection.name&&(s.push(new e.aG(1,0,1,0,0)),s.push(new e.aG(1,0,1,1,0)),s.push(new e.aG(1,0,1,0,1)),s.push(new e.aG(1,0,1,1,1)))}else if(s=t.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:a,roundZoom:this._source.roundZoom&&!r,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:o}),this._source.hasTile){const e=this._source.hasTile.bind(this._source);s=s.filter((t=>e(t)))}}else s=[];if(s.length>0&&this.castsShadows&&n&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Tt(this._source.type)){const e=t.coveringZoomLevel({tileSize:i||this._source.tileSize,roundZoom:this._source.roundZoom&&!r}),a=Math.min(e,this._source.maxzoom);if(o){const e=t.extendTileCover(s,a);for(const t of e)s.push(t)}else{const e=t.extendTileCover(s,a,n);for(const t of e)this._shadowCasterTiles[t.key]=!0,s.push(t)}}const c=this._updateRetainedTiles(s);if(Tt(this._source.type)&&0!==s.length){const t={},i={},r=Object.keys(c);for(const n of r){const r=c[n],o=this._tiles[n];if(!o||o.fadeEndTime&&o.fadeEndTime<=e.q.now())continue;const s=this.findLoadedParent(r,Math.max(r.overscaledZ-bt.maxOverzooming,this._source.minzoom));s&&(this._addTile(s.tileID),t[s.tileID.key]=s.tileID),i[n]=r}const n=s[s.length-1].overscaledZ;for(const e in this._tiles){const t=this._tiles[e];if(c[e]||!t.hasData())continue;let r=t.tileID;for(;r.overscaledZ>n;){r=r.scaledTo(r.overscaledZ-1);const n=this._tiles[r.key];if(n&&n.hasData()&&i[r.key]){c[e]=t.tileID;break}}}for(const e in t)c[e]||(this._coveredTiles[e]=!0,c[e]=t[e])}for(const e in c)this._tiles[e].clearFadeHold();const h=e.bk(this._tiles,c);for(const e of h){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(+e)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e)}_updateRetainedTiles(e){const t={};if(0===e.length)return t;const i={},r=e.reduce(((e,t)=>Math.min(e,t.overscaledZ)),1/0),n=e[0].overscaledZ,o=Math.max(n-bt.maxOverzooming,this._source.minzoom),s=Math.max(n+bt.maxUnderzooming,this._source.minzoom),a={};for(const i of e){const e=this._addTile(i);t[i.key]=i,e.hasData()||r<this._source.maxzoom&&(a[i.key]=i)}this._retainLoadedChildren(a,r,s,t);for(const r of e){let e=this._tiles[r.key];if(e.hasData())continue;if(r.canonical.z>=this._source.maxzoom){const e=r.children(this._source.maxzoom)[0],i=this.getTile(e);if(i&&i.hasData()){t[e.key]=e;continue}}else{const e=r.children(this._source.maxzoom);if(t[e[0].key]&&t[e[1].key]&&t[e[2].key]&&t[e[3].key])continue}let n=e.wasRequested();for(let s=r.overscaledZ-1;s>=o;--s){const o=r.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,e=this.getTile(o),!e&&n&&(e=this._addTile(o)),e&&(t[o.key]=o,n=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,r=this._tiles[e].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}t.push(r.key);const e=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;r=e}for(const e of t)this._loadedParentTiles[e]=i}}_addTile(t){let i=this._tiles[t.key];if(i)return!0!==i.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),i;i=this._cache.getAndRemove(t),i&&(this._setTileReloadTimer(t.key,i),i.tileID=t,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,i)));const r=Boolean(i);if(!r){const e=this.map?this.map.painter:null,r=this._source.tileSize*t.overscaleFactor();i="raster-array"===this._source.type?new yt(t,r,this.transform.tileZoom,e,this._isRaster):new gt(t,r,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,r||this._source.fire(new e.z("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,r){const n=[],o=this.transform;if(!o)return n;const s="globe"===o.projection.name,a=e.at(o.center.lng);for(const l in this._tiles){const c=this._tiles[l];if(r&&c.clearQueryDebugViz(),c.holdingForFade())continue;let h;if(s){const t=c.tileID.canonical;if(0===t.z){const i=[Math.abs(e.aw(a,...St(t,-1))-a),Math.abs(e.aw(a,...St(t,1))-a)];h=[0,2*i.indexOf(Math.min(...i))-1]}else{const i=[Math.abs(e.aw(a,...St(t,-1))-a),Math.abs(e.aw(a,...St(t,0))-a),Math.abs(e.aw(a,...St(t,1))-a)];h=[i.indexOf(Math.min(...i))-1]}}else h=[0];for(const e of h){const r=t.containsTile(c,o,i,e);r&&n.push(r)}}return n}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(e){return this._getRenderableCoordinates(e)}_getRenderableCoordinates(e,t){const i=this.getRenderableIds(e,t).map((e=>this._tiles[e].tileID)),r="globe"===this.transform.projection.name;for(const e of i)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped()),e.expandedProjMatrix=r?this.transform.calculateProjMatrix(e.toUnwrapped(),!1,!0):e.projMatrix;return i}sortCoordinatesByDistance(e){const t=e.slice(),i=this.transform._camera.position,r=this.transform._camera.forward(),n={};for(const e of t){const t=1/(1<<e.canonical.z);n[e.key]=((e.canonical.x+.5)*t+e.wrap-i[0])*r[0]+((e.canonical.y+.5)*t-i[1])*r[1]-i[2]*r[2]}return t.sort(((e,t)=>n[e.key]-n[t.key])),t}hasTransition(){if(this._source.hasTransition())return!0;if(Tt(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 r=this._tiles[e];r&&r.setDependencies(t,i)}reloadTilesForDependencies(e,t){for(const i in this._tiles)this._tiles[i].hasDependency(e,t)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(e,t)))}_preloadTiles(t,i){if(!this._sourceLoaded){const e=()=>{this._sourceLoaded&&(this._source.off("data",e),this._preloadTiles(t,i))};return void this._source.on("data",e)}const r=new Map,n=Array.isArray(t)?t:[t],o=this.map.painter.terrain,s=this.usedForTerrain&&o?o.getScaledDemTileSize():this._source.tileSize;for(const e of n){const t=e.coveringTiles({tileSize:s,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const e of t)r.set(e.key,e);this.usedForTerrain&&e.updateElevation(!1)}const a=Array.from(r.values());e.bl(a,((e,t)=>{const i=new gt(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 wt(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),r=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function Tt(e){return"raster"===e||"image"===e||"video"===e||"custom"===e}function St(e,t){const i=1<<e.z;return[e.x/i+t,(e.x+1)/i+t]}bt.maxOverzooming=10,bt.maxUnderzooming=3;class Mt{constructor(e){this.style=e,this.layersGotHidden=!1,this.layers=[]}processLayersChanged(){this.layers=[];const e=!1,t=!1;for(const i in this.style._mergedLayers){const r=this.style._mergedLayers[i];if("fill-extrusion"===r.type)this.layers.push({layer:r,visible:e,visibilityChanged:t});else if("model"===r.type){const i=this.style.getLayerSource(r);i&&"batched-model"===i.type&&this.layers.push({layer:r,visible:e,visibilityChanged:t})}}}onNewFrame(e){this.layersGotHidden=!1;for(const t of this.layers){const i=t.layer;let r=!1;"fill-extrusion"===i.type?r=!i.isHidden(e)&&i.paint.get("fill-extrusion-opacity")>0:"model"===i.type&&(r=!i.isHidden(e)&&i.paint.get("model-opacity").constantOr(1)>0),this.layersGotHidden=this.layersGotHidden||!r&&t.visible,t.visible=r}}updateZOffset(e,t){this.currentBuildingBuckets=[];for(const e of this.layers){const i=e.layer,r=this.style.getLayerSourceCache(i);let n=1;"fill-extrusion"===i.type&&(n=e.visible?i.paint.get("fill-extrusion-vertical-scale"):0);let o=r?r.getTile(t):null;if(!o&&r&&t.canonical.z>r.getSource().minzoom){let e=t.scaledTo(Math.min(r.getSource().maxzoom,t.overscaledZ-1));for(;e.overscaledZ>=r.getSource().minzoom&&(o=r.getTile(e),!o&&0!==e.overscaledZ);)e=e.scaledTo(e.overscaledZ-1)}this.currentBuildingBuckets.push({bucket:o?o.getBucket(i):null,tileID:o?o.tileID:t,verticalScale:n})}e.hasAnyZOffset=!1;let i=!1;for(let r=0;r<e.symbolInstances.length;r++){const n=e.symbolInstances.get(r),o=n.zOffset,s=this._getHeightAtTileOffset(t,n.tileAnchorX,n.tileAnchorY);n.zOffset=s!==Number.NEGATIVE_INFINITY?s:o,i||o===n.zOffset||(i=!0),e.hasAnyZOffset||0===n.zOffset||(e.hasAnyZOffset=!0)}i&&(e.zOffsetBuffersNeedUpload=!0,e.zOffsetSortDirty=!0)}_mapCoordToOverlappingTile(t,i,r,n){let o=i,s=r;if(t.canonical.z!==n.canonical.z){const a=n.canonical,l=1/(1<<t.canonical.z-a.z);o=(i+t.canonical.x*e.ag)*l-a.x*e.ag|0,s=(r+t.canonical.y*e.ag)*l-a.y*e.ag|0}return{tileX:o,tileY:s}}_getHeightAtTileOffset(e,t,i){let r,n;for(let o=0;o<this.layers.length;++o){if("fill-extrusion"!==this.layers[o].layer.type)continue;const{bucket:s,tileID:a,verticalScale:l}=this.currentBuildingBuckets[o];if(!s)continue;const{tileX:c,tileY:h}=this._mapCoordToOverlappingTile(e,t,i,a),u=s.getHeightAtTileCoord(c,h);u&&void 0!==u.height&&(u.hidden?r=u.height:n=Math.max(u.height*l,n||0))}if(void 0!==n)return n;for(let n=0;n<this.layers.length;++n){const o=this.layers[n];if("model"!==o.layer.type||!o.visible)continue;const{bucket:s,tileID:a}=this.currentBuildingBuckets[n];if(!s)continue;const{tileX:l,tileY:c}=this._mapCoordToOverlappingTile(e,t,i,a),h=s.getHeightAtTileCoord(l,c);if(h&&!h.hidden)return void 0===h.height&&void 0!==r?Math.min(h.maxHeight,r)*h.verticalScale:h.height?h.height*h.verticalScale:Number.NEGATIVE_INFINITY}return this.layersGotHidden?0:Number.NEGATIVE_INFINITY}}function Et(t,i){const r={};for(const e in t)"ref"!==e&&(r[e]=t[e]);return e.bm.forEach((e=>{e in i&&(r[e]=i[e])})),r}function At(e){e=e.slice();const t=Object.create(null);for(let i=0;i<e.length;i++)t[e[i].id]=e[i];for(let i=0;i<e.length;i++)"ref"in e[i]&&(e[i]=Et(e[i],t[e[i].ref]));return e}const It={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setSlot:"setSlot",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setSnow:"setSnow",setRain:"setRain",setCamera:"setCamera",setLights:"setLights",setProjection:"setProjection",addImport:"addImport",removeImport:"removeImport",updateImport:"updateImport"};function Ct(e,t,i){i.push({command:It.addSource,args:[e,t[e]]})}function Pt(e,t,i){t.push({command:It.removeSource,args:[e]}),i[e]=!0}function zt(e,t,i,r){Pt(e,i,r),Ct(e,t,i)}function Dt(t,i,r){let n;for(n in t[r])if(t[r].hasOwnProperty(n)&&"data"!==n&&!e.bn(t[r][n],i[r][n]))return!1;for(n in i[r])if(i[r].hasOwnProperty(n)&&"data"!==n&&!e.bn(t[r][n],i[r][n]))return!1;return!0}function Rt(t,i,r,n,o,s){let a;for(a in i=i||{},t=t||{})t.hasOwnProperty(a)&&(e.bn(t[a],i[a])||r.push({command:s,args:[n,a,i[a],o]}));for(a in i)i.hasOwnProperty(a)&&!t.hasOwnProperty(a)&&(e.bn(t[a],i[a])||r.push({command:s,args:[n,a,i[a],o]}))}function Lt(e){return e.id}function Ot(e,t){return e[t.id]=t,e}class kt{constructor(e,t){this.reset(e,t)}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e<this.points.length;e++)this._distances[e]=this._distances[e-1]+this.points[e].dist(this.points[e-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(t||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(t){if(1===this.points.length)return this.points[0];t=e.aw(t,0,1);let i=1,r=this._distances[i];const n=t*this.paddedLength+this.padding;for(;r<n&&i<this._distances.length;)r=this._distances[++i];const o=i-1,s=this._distances[o],a=r-s,l=a>0?(n-s)/a:0;return this.points[o].mult(1-l).add(this.points[i].mult(l))}}class Ft{constructor(e,t,i){const r=this.boxCells=[],n=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;e<this.xCellCount*this.yCellCount;e++)r.push([]),n.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=e,this.height=t,this.xScale=this.xCellCount/e,this.yScale=this.yCellCount/t,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,t,i,r,n){this._forEachCell(t,i,r,n,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)}insertCircle(e,t,i,r){this._forEachCell(t-r,i-r,t+r,i+r,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(t),this.circles.push(i),this.circles.push(r)}_insertBoxCell(e,t,i,r,n,o){this.boxCells[n].push(o)}_insertCircleCell(e,t,i,r,n,o){this.circleCells[n].push(o)}_query(e,t,i,r,n,o){if(i<0||e>this.width||r<0||t>this.height)return!n&&[];const s=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=r){if(n)return!0;for(let e=0;e<this.boxKeys.length;e++)s.push({key:this.boxKeys[e],x1:this.bboxes[4*e],y1:this.bboxes[4*e+1],x2:this.bboxes[4*e+2],y2:this.bboxes[4*e+3]});for(let e=0;e<this.circleKeys.length;e++){const t=this.circles[3*e],i=this.circles[3*e+1],r=this.circles[3*e+2];s.push({key:this.circleKeys[e],x1:t-r,y1:i-r,x2:t+r,y2:i+r})}return o?s.filter(o):s}return this._forEachCell(e,t,i,r,this._queryCell,s,{hitTest:n,seenUids:{box:{},circle:{}}},o),n?s.length>0:s}_queryCircle(e,t,i,r,n){const o=e-i,s=e+i,a=t-i,l=t+i;if(s<0||o>this.width||l<0||a>this.height)return!r&&[];const c=[];return this._forEachCell(o,a,s,l,this._queryCellCircle,c,{hitTest:r,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},n),r?c.length>0:c}query(e,t,i,r,n){return this._query(e,t,i,r,!1,n)}hitTest(e,t,i,r,n){return this._query(e,t,i,r,!0,n)}hitTestCircle(e,t,i,r){return this._queryCircle(e,t,i,!0,r)}_queryCell(e,t,i,r,n,o,s,a){const l=s.seenUids,c=this.boxCells[n];if(null!==c){const n=this.bboxes;for(const h of c)if(!l.box[h]){l.box[h]=!0;const c=4*h;if(e<=n[c+2]&&t<=n[c+3]&&i>=n[c+0]&&r>=n[c+1]&&(!a||a(this.boxKeys[h]))){if(s.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[h],x1:n[c],y1:n[c+1],x2:n[c+2],y2:n[c+3]})}}}const h=this.circleCells[n];if(null!==h){const n=this.circles;for(const c of h)if(!l.circle[c]){l.circle[c]=!0;const h=3*c;if(this._circleAndRectCollide(n[h],n[h+1],n[h+2],e,t,i,r)&&(!a||a(this.circleKeys[c]))){if(s.hitTest)return o.push(!0),!0;{const e=n[h],t=n[h+1],i=n[h+2];o.push({key:this.circleKeys[c],x1:e-i,y1:t-i,x2:e+i,y2:t+i})}}}}}_queryCellCircle(e,t,i,r,n,o,s,a){const l=s.circle,c=s.seenUids,h=this.boxCells[n];if(null!==h){const e=this.bboxes;for(const t of h)if(!c.box[t]){c.box[t]=!0;const i=4*t;if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!a||a(this.boxKeys[t])))return o.push(!0),!0}}const u=this.circleCells[n];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)&&(!a||a(this.circleKeys[t])))return o.push(!0),!0}}}_forEachCell(e,t,i,r,n,o,s,a){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r);for(let d=l;d<=h;d++)for(let l=c;l<=u;l++)if(n.call(this,e,t,i,r,this.xCellCount*l+d,o,s,a))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,i,r,n,o){const s=r-e,a=n-t,l=i+o;return l*l>s*s+a*a}_circleAndRectCollide(e,t,i,r,n,o,s){const a=(o-r)/2,l=Math.abs(e-(r+a));if(l>a+i)return!1;const c=(s-n)/2,h=Math.abs(t-(n+c));if(h>c+i)return!1;if(l<=a||h<=c)return!0;const u=l-a,d=h-c;return u*u+d*d<=i*i}}const Bt=0,Nt=1,Vt=2,Ut=Math.tan(85*Math.PI/180);function jt(t,i,r,n,o,s,a){const l=e.ab.mat4.create();if(r)if("globe"===s.name){const t=e.bo(o,i);e.ab.mat4.multiply(l,l,t)}else{const t=e.ab.mat2.invert([],a);l[0]=t[0],l[1]=t[1],l[4]=t[2],l[5]=t[3],n||e.ab.mat4.rotateZ(l,l,o.angle)}else e.ab.mat4.multiply(l,o.labelPlaneMatrix,t);return l}function Gt(e,t,i,r,n,o,s){const a=jt(e,t,i,r,n,o,s);return"globe"===o.name&&i||(a[2]=a[6]=a[10]=a[14]=0),a}function qt(t,i,r,n,o,s,a){if(r){if("globe"===s.name){const l=jt(t,i,r,n,o,s,a);return e.ab.mat4.invert(l,l),e.ab.mat4.multiply(l,t,l),l}{const i=e.ab.mat4.clone(t),r=e.ab.mat4.identity([]);return r[0]=a[0],r[1]=a[1],r[4]=a[2],r[5]=a[3],e.ab.mat4.multiply(i,i,r),n||e.ab.mat4.rotateZ(i,i,-o.angle),i}}return o.glCoordMatrix}function Zt(t,i,r,n){const o=[t,i,r,1];r?e.ab.vec4.transformMat4(o,o,n):ii(o,o,n);const s=o[3];return o[0]/=s,o[1]/=s,o[2]/=s,o}function $t(e,t){return Math.min(.5+e/t*.5,1.5)}function Ht(e,t){const i=e[0]/e[3],r=e[1]/e[3];return i>=-t[0]&&i<=t[0]&&r>=-t[1]&&r<=t[1]}function Wt(t,i,r,n,o,s,a,l,c,h){const u=r.transform,d=n?t.textSizeData:t.iconSizeData,p=e.bp(d,r.transform.zoom),f="globe"===u.projection.name,m=[256/r.width*2+1,256/r.height*2+1],_=n?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;_.clear();let g=null;f&&(g=n?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const y=t.lineVertexArray,x=n?t.text.placedSymbolArray:t.icon.placedSymbolArray,v=r.transform.width/r.transform.height;let b,w=!1;for(let n=0;n<x.length;n++){const f=x.get(n),{numGlyphs:T,writingMode:S}=f;if(S!==e.bq.vertical||w||b===e.bq.horizontal||(w=!0),b=S,(f.hidden||S===e.bq.vertical)&&!w){ti(T,_);continue}w=!1;const M=new e.P(f.tileAnchorX,f.tileAnchorY);let{x:E,y:A,z:I}=u.projection.projectTilePoint(M.x,M.y,h.canonical);if(c){const[e,t,i]=c(M);E+=e,A+=t,I+=i}const C=[E,A,I,1];if(e.ab.vec4.transformMat4(C,C,i),!Ht(C,m)){ti(T,_);continue}const P=C[3],z=$t(r.transform.getCameraToCenterDistance(u.projection),P),D=e.br(d,p,f),R=a?D/z:D*z,L=Zt(E,A,I,o);if(L[3]<=0){ti(T,_);continue}let O={};const k=a?null:c,F=Kt(f,R,!1,l,i,o,s,t.glyphOffsetArray,y,_,g,L,M,O,v,k,u.projection,h,a);w=F.useVertical,k&&F.needsFlipping&&(O={}),(F.notEnoughRoom||w||F.needsFlipping&&Kt(f,R,!0,l,i,o,s,t.glyphOffsetArray,y,_,g,L,M,O,v,k,u.projection,h,a).notEnoughRoom)&&ti(T,_)}n?(t.text.dynamicLayoutVertexBuffer.updateData(_),g&&t.text.globeExtVertexBuffer&&t.text.globeExtVertexBuffer.updateData(g)):(t.icon.dynamicLayoutVertexBuffer.updateData(_),g&&t.icon.globeExtVertexBuffer&&t.icon.globeExtVertexBuffer.updateData(g))}function Xt(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m){const{lineStartIndex:_,glyphStartIndex:g,segment:y}=a,x=g+a.numGlyphs,v=_+a.lineLength,b=t.getoffsetX(g),w=t.getoffsetX(x-1),T=ei(e*b,i,r,n,o,s,y,_,v,l,c,h,u,d,!0,p,f,m);if(!T)return null;const S=ei(e*w,i,r,n,o,s,y,_,v,l,c,h,u,d,!0,p,f,m);return S?{first:T,last:S}:null}function Yt(t,i,r,n){return t===e.bq.horizontal&&Math.abs(n)>Math.abs(r)?{useVertical:!0}:t===e.bq.vertical?n>0?{needsFlipping:!0}:null:i!==Bt&&function(e,t){return 0===e||Math.abs(t/e)>Ut}(r,n)?i===Nt?{needsFlipping:!0}:null:r<0?{needsFlipping:!0}:null}function Kt(t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){const v=i/24,b=t.lineOffsetX*v,w=t.lineOffsetY*v,{lineStartIndex:T,glyphStartIndex:S,numGlyphs:M,segment:E,writingMode:A,flipState:I}=t,C=T+t.lineLength,P=t=>{if(u){const[i,r,n]=t.up,o=h.length;e.bs(u,o+0,i,r,n),e.bs(u,o+1,i,r,n),e.bs(u,o+2,i,r,n),e.bs(u,o+3,i,r,n)}const[i,r,n]=t.point;e.bt(h,i,r,n,t.angle)};if(M>1){const e=Xt(v,l,b,w,r,d,p,t,c,s,f,_,!1,g,y,x);if(!e)return{notEnoughRoom:!0};if(n&&!r){let[i,r,n]=e.first.point,[o,s,l]=e.last.point;[i,r]=Zt(i,r,n,a),[o,s]=Zt(o,s,l,a);const c=Yt(A,I,(o-i)*m,s-r);if(t.flipState=c&&c.needsFlipping?Nt:Vt,c)return c}P(e.first);for(let e=S+1;e<S+M-1;e++){const t=ei(v*l.getoffsetX(e),b,w,r,d,p,E,T,C,c,s,f,_,!1,!1,g,y,x);if(!t)return h.length-=4*(e-S),{notEnoughRoom:!0};P(t)}P(e.last)}else{if(n&&!r){const i=Zt(p.x,p.y,0,o),r=T+E+1,n=new e.P(c.getx(r),c.gety(r)),s=Zt(n.x,n.y,0,o),a=s[3]>0?s:Qt(p,n,i,1,o,void 0,g,y.canonical),l=Yt(A,I,(a[0]-i[0])*m,a[1]-i[1]);if(t.flipState=l&&l.needsFlipping?Nt:Vt,l)return l}const i=ei(v*l.getoffsetX(S),b,w,r,d,p,E,T,C,c,s,f,_,!1,!1,g,y,x);if(!i)return{notEnoughRoom:!0};P(i)}return{}}function Jt(e,t,i,r,n){const{x:o,y:s,z:a}=r.projectTilePoint(e.x,e.y,t);if(!n)return Zt(o,s,a,i);const[l,c,h]=n(e);return Zt(o+l,s+c,a+h,i)}function Qt(t,i,r,n,o,s,a,l){const c=Jt(t.sub(i)._unit()._add(t),l,o,a,s);return e.ab.vec3.sub(c,r,c),e.ab.vec3.normalize(c,c),e.ab.vec3.scaleAndAdd(c,r,c,n)}function ei(t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y){const x=n?t-i:t+i;let v=x>0?1:-1,b=0;n&&(v*=-1,b=Math.PI),v<0&&(b+=Math.PI);let w=l+a+(v>0?0:1)|0,T=o,S=o,M=0,E=0;const A=Math.abs(x),I=[],C=[];let P=s,z=P;const D=()=>Qt(z,P,S,A-M+1,u,p,_,g.canonical);for(;M+E<=A;){if(w+=v,w<l||w>=c)return null;if(S=T,z=P,I.push(S),f&&C.push(z),P=new e.P(h.getx(w),h.gety(w)),T=d[w],!T){const e=Jt(P,g.canonical,u,_,p);T=e[3]>0?d[w]=e:D()}M+=E,E=e.ab.vec3.distance(S,T)}m&&p&&(d[w]&&(T=D(),E=e.ab.vec3.distance(S,T)),d[w]=T);const R=(A-M)/E,L=P.sub(z)._mult(R)._add(z),O=e.ab.vec3.sub([],T,S),k=e.ab.vec3.scaleAndAdd([],S,O,R);let F=[0,0,1],B=O[0],N=O[1];if(y&&(F=_.upVector(g.canonical,L.x,L.y),0!==F[0]||0!==F[1]||1!==F[2])){const t=[F[2],0,-F[0]],i=e.ab.vec3.cross([],F,t);e.ab.vec3.normalize(t,t),e.ab.vec3.normalize(i,i),B=e.ab.vec3.dot(O,t),N=e.ab.vec3.dot(O,i)}if(r){const t=e.ab.vec3.cross([],F,O);e.ab.vec3.normalize(t,t),e.ab.vec3.scaleAndAdd(k,k,t,r*v)}const V=b+Math.atan2(N,B);return I.push(k),f&&C.push(L),{point:k,angle:V,path:I,tilePath:C,up:F}}function ti(e,t){const i=t.length,r=i+4*e;t.resize(r),t.float32.fill(-1/0,4*i,4*r)}function ii(e,t,i){const r=t[0],n=t[1];return e[0]=i[0]*r+i[4]*n+i[12],e[1]=i[1]*r+i[5]*n+i[13],e[3]=i[3]*r+i[7]*n+i[15],e}const ri=100;class ni{constructor(e,t,i=new Ft(e.width+200,e.height+200,25),r=new Ft(e.width+200,e.height+200,25)){this.transform=e,this.grid=i,this.ignoredGrid=r,this.pitchfactor=Math.cos(e._pitch)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+ri,this.screenBottomBoundary=e.height+ri,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.fogState=t}placeCollisionBox(e,t,i,r,n,o,s,a){let l=i.projectedAnchorX,c=i.projectedAnchorY,h=i.projectedAnchorZ;const u=i.elevation,d=i.tileID,p=e.getProjection();if(u&&d){const[e,t,r]=p.upVector(d.canonical,i.tileAnchorX,i.tileAnchorY),n=p.upVectorScale(d.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;l+=e*u*n,c+=t*u*n,h+=r*u*n}const f=this.projectAndGetPerspectiveRatio(s,l,c,h,i.tileID,"globe"===p.name||!!u||this.transform.pitch>0,p),m=o*f.perspectiveRatio,_=(i.x1*t+r.x-i.padding)*m+f.point.x,g=(i.y1*t+r.y-i.padding)*m+f.point.y,y=(i.x2*t+r.x+i.padding)*m+f.point.x,x=(i.y2*t+r.y+i.padding)*m+f.point.y,v=f.perspectiveRatio<=.55||f.occluded;return!this.isInsideGrid(_,g,y,x)||!n&&this.grid.hitTest(_,g,y,x,a)||v?{box:[],offscreen:!1,occluded:f.occluded}:{box:[_,g,y,x],offscreen:this.isOffscreen(_,g,y,x),occluded:!1}}placeCollisionCircles(t,i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=[],g=this.transform.elevation,y=t.getProjection(),x=g?g.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,y):null,v=new e.P(r.tileAnchorX,r.tileAnchorY);let{x:b,y:w,z:T}=y.projectTilePoint(v.x,v.y,m.canonical);if(x){const[e,t,i]=x(v);b+=e,w+=t,T+=i}const S="globe"===y.name,M=this.projectAndGetPerspectiveRatio(a,b,w,T,m,S||!!g||this.transform.pitch>0,y),{perspectiveRatio:E}=M,A=(u?s/E:s*E)/e.bw,I=Zt(b,w,T,l),C=M.signedDistanceFromCamera>0?Xt(A,o,r.lineOffsetX*A,r.lineOffsetY*A,!1,I,v,r,n,l,{},g&&!u?x:null,u&&!!g,y,m,u):null;let P=!1,z=!1,D=!0;if(C&&!M.occluded){const t=.5*p*E+f,r=new e.P(-100,-100),n=new e.P(this.screenRightBoundary,this.screenBottomBoundary),o=new kt,{first:s,last:a}=C,l=s.path.length;let u=[];for(let e=l-1;e>=1;e--)u.push(s.path[e]);for(let e=1;e<a.path.length;e++)u.push(a.path[e]);const m=2.5*t;c&&(u=u.map((([e,t,i],r)=>(x&&!S&&(i=x(r<l-1?s.tilePath[l-1-r]:a.tilePath[r-l+2])[2]),Zt(e,t,i,c)))),u.some((e=>e[3]<=0))&&(u=[]));let g=[];if(u.length>0){let t=1/0,i=-1/0,o=1/0,s=-1/0;for(const e of u)t=Math.min(t,e[0]),o=Math.min(o,e[1]),i=Math.max(i,e[0]),s=Math.max(s,e[1]);i>=r.x&&t<=n.x&&s>=r.y&&o<=n.y&&(g=[u.map((t=>new e.P(t[0],t[1])))],(t<r.x||i>n.x||o<r.y||s>n.y)&&(g=e.bu(g,r.x,r.y,n.x,n.y)))}for(const e of g){o.reset(e,.25*t);let r=0;r=o.length<=.5*t?1:Math.ceil(o.paddedLength/m)+1;for(let e=0;e<r;e++){const n=e/Math.max(r-1,1),s=o.lerp(n),a=s.x+ri,l=s.y+ri;_.push(a,l,t,0);const c=a-t,u=l-t,p=a+t,f=l+t;if(D=D&&this.isOffscreen(c,u,p,f),z=z||this.isInsideGrid(c,u,p,f),!i&&this.grid.hitTestCircle(a,l,t,d)&&(P=!0,!h))return{circles:[],offscreen:!1,collisionDetected:P,occluded:!1}}}}return{circles:!h&&P||!z?[]:_,offscreen:D,collisionDetected:P,occluded:M.occluded}}queryRenderedSymbols(t){if(0===t.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const i=[];let r=1/0,n=1/0,o=-1/0,s=-1/0;for(const a of t){const t=new e.P(a.x+ri,a.y+ri);r=Math.min(r,t.x),n=Math.min(n,t.y),o=Math.max(o,t.x),s=Math.max(s,t.y),i.push(t)}const a=this.grid.query(r,n,o,s).concat(this.ignoredGrid.query(r,n,o,s)),l={},c={};for(const t of a){const r=t.key;if(void 0===l[r.bucketInstanceId]&&(l[r.bucketInstanceId]={}),l[r.bucketInstanceId][r.featureIndex])continue;const n=[new e.P(t.x1,t.y1),new e.P(t.x2,t.y1),new e.P(t.x2,t.y2),new e.P(t.x1,t.y2)];e.bv(i,n)&&(l[r.bucketInstanceId][r.featureIndex]=!0,void 0===c[r.bucketInstanceId]&&(c[r.bucketInstanceId]=[]),c[r.bucketInstanceId].push(r.featureIndex))}return c}insertCollisionBox(e,t,i,r,n){(t?this.ignoredGrid:this.grid).insert({bucketInstanceId:i,featureIndex:r,collisionGroupID:n},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,i,r,n){const o=t?this.ignoredGrid:this.grid,s={bucketInstanceId:i,featureIndex:r,collisionGroupID:n};for(let t=0;t<e.length;t+=4)o.insertCircle(s,e[t],e[t+1],e[t+2])}projectAndGetPerspectiveRatio(t,i,r,n,o,s,a){const l=[i,r,n,1];let c=!1;if(n||this.transform.pitch>0){if(e.ab.vec4.transformMat4(l,l,t),this.fogState&&o&&"globe"!==a.name){const t=function(t,i,r,n,o,s){const a=s.calculateFogTileMatrix(o),l=[i,r,n];return e.ab.vec3.transformMat4(l,l,a),Oe(t,e.ab.vec3.length(l),s.pitch,s._fov)}(this.fogState,i,r,n,o.toUnwrapped(),this.transform);c=t>.9}}else ii(l,l,t);const h=l[3];return{point:new e.P((l[0]/h+1)/2*this.transform.width+ri,(-l[1]/h+1)/2*this.transform.height+ri),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(a)/h*.5,1.5),signedDistanceFromCamera:h,occluded:s&&l[2]>h||c}}isOffscreen(e,t,i,r){return i<ri||e>=this.screenRightBoundary||r<ri||t>this.screenBottomBoundary}isInsideGrid(e,t,i,r){return i>=0&&e<this.gridRightBoundary&&r>=0&&t<this.gridBottomBoundary}getViewportMatrix(){const t=e.ab.mat4.identity([]);return e.ab.mat4.translate(t,t,[-100,-100,0]),t}}function oi(t,i,r){const n=i.createTileMatrix(t,t.worldSize,r.toUnwrapped());return e.ab.mat4.multiply(new Float32Array(16),t.projMatrix,n)}function si(e,t,i){if(t.projection.name===i.projection.name)return e.projMatrix;const r=i.clone();return r.setProjection(t.projection),oi(r,t.getProjection(),e)}function ai(e,t,i){return t.name===i.projection.name?e.projMatrix:oi(i,t,e)}class li{constructor(e,t,i,r){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):r&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}}class ci{constructor(e,t,i,r,n,o=!1){this.text=new li(e?e.text:null,t,i,n),this.icon=new li(e?e.icon:null,t,r,n),this.clipped=o}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class hi{constructor(e,t,i,r=!1){this.text=e,this.icon=t,this.skipFade=i,this.clipped=r}}class ui{constructor(){this.invProjMatrix=e.ab.mat4.create(),this.viewportMatrix=e.ab.mat4.create(),this.circles=[]}}class di{constructor(e,t,i,r,n){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=n}}class pi{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){const t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:e=>e.collisionGroupID===t}}return this.collisionGroups[e]}}function fi(t,i,r,n,o){const{horizontalAlign:s,verticalAlign:a}=e.bD(t),l=-(s-.5)*i,c=-(a-.5)*r,h=e.bC(t,n);return new e.P(l+h[0]*o,c+h[1]*o)}function mi(t,i,r,n,o){const s=new e.P(t,i);return r&&s._rotate(n?o:-o),s}class _i{constructor(e,t,i,r,n,o){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new ni(this.transform,n),this.buildingIndex=o,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new pi(i),this.collisionCircleArrays={},this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,i,r,n,o=1){const s=r.getBucket(i),a=r.latestFeatureIndex;if(!s||!a||i.fqid!==s.layerIds[0])return;const l=s.layers[0].layout,c=s.layers[0].paint,h=r.collisionBoxArray,u=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),d=r.tileSize/e.ag,p=r.tileID.toUnwrapped();this.transform.setProjection(s.projection);const f=(m=r.tileID,_=s.getProjection(),g=this.transform,_.name===this.projection?g.calculateProjMatrix(m.toUnwrapped()):oi(g,_,m));var m,_,g;const y="map"===l.get("text-pitch-alignment"),x="map"===l.get("text-rotation-alignment");i.compileFilter(i.options);const v=i.dynamicFilter(),b=i.dynamicFilterNeedsFeature(),w=this.transform.calculatePixelsToTileUnitsMatrix(r),T=Gt(f,r.tileID.canonical,y,x,this.transform,s.getProjection(),w);let S=null;if(y){const t=qt(f,r.tileID.canonical,y,x,this.transform,s.getProjection(),w);S=e.ab.mat4.multiply([],this.transform.labelPlaneMatrix,t)}let M=null;v&&r.latestFeatureIndex&&(M={unwrappedTileID:p,dynamicFilter:v,dynamicFilterNeedsFeature:b}),this.retainedQueryData[s.bucketInstanceId]=new di(s.bucketInstanceId,a,s.sourceLayerIndex,s.index,r.tileID);const[E,A]=s.layers[0].layout.get("text-size-scale-range"),I=e.aw(o,E,A),[C,P]=l.get("icon-size-scale-range"),z=e.aw(o,C,P),D={bucket:s,layout:l,paint:c,posMatrix:f,textLabelPlaneMatrix:T,labelToScreenMatrix:S,clippingData:M,scale:u,textPixelRatio:d,holdingForFade:r.holdingForFade(),collisionBoxArray:h,partiallyEvaluatedTextSize:e.bp(s.textSizeData,this.transform.zoom,I),partiallyEvaluatedIconSize:e.bp(s.iconSizeData,this.transform.zoom,z),collisionGroup:this.collisionGroups.get(s.sourceID),latestFeatureIndex:r.latestFeatureIndex};if(n)for(const e of s.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n}=e;t.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n,parameters:D})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:s.symbolInstances.length,parameters:D})}attemptAnchorPlacement(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const{textOffset0:y,textOffset1:x,crossTileID:v}=u,b=[y,x],w=fi(e,i,r,b,n),T=this.collisionIndex.placeCollisionBox(p,n,t,mi(w.x,w.y,o,s,this.transform.angle),h,a,l,c.predicate);if(m){const e=p.getSymbolInstanceIconSize(g,this.transform.zoom,u.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(p,e,m,mi(w.x,w.y,o,s,this.transform.angle),h,a,l,c.predicate).box.length)return}if(T.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[v]&&this.prevPlacement.placements[v]&&this.prevPlacement.placements[v].text&&(t=this.prevPlacement.variableOffsets[v].anchor),this.variableOffsets[v]={textOffset:b,width:i,height:r,anchor:e,textScale:n,prevAnchor:t},this.markUsedJustification(p,e,u,f),p.allowVerticalPlacement&&(this.markUsedOrientation(p,f,u),this.placedOrientations[v]=f),{shift:w,placedGlyphBoxes:T}}}placeLayerBucketPart(t,i,r,n,o=1){const{bucket:s,layout:a,paint:l,posMatrix:c,textLabelPlaneMatrix:h,labelToScreenMatrix:u,clippingData:d,textPixelRatio:p,holdingForFade:f,collisionBoxArray:m,partiallyEvaluatedTextSize:_,partiallyEvaluatedIconSize:g,collisionGroup:y,latestFeatureIndex:x}=t.parameters,v=a.get("text-optional"),b=a.get("icon-optional"),w=a.get("text-allow-overlap"),T=a.get("icon-allow-overlap"),S="map"===a.get("text-rotation-alignment"),M="map"===a.get("text-pitch-alignment"),E=a.get("symbol-z-elevate"),A=l.get("symbol-z-offset"),I="sea"===a.get("symbol-elevation-reference"),[C,P]=a.get("text-size-scale-range"),[z,D]=a.get("icon-size-scale-range"),R=e.aw(o,C,P),L=e.aw(o,z,D);this.transform.setProjection(s.projection);let O=w&&(T||!s.hasIconData()||b),k=T&&(w||!s.hasTextData()||v);const F=!A.isConstant();!s.collisionArrays&&m&&s.deserializeCollisionBoxes(m),r&&n&&s.updateCollisionDebugBuffers(this.transform.zoom,m,R,L);const B=(t,n,l)=>{const{crossTileID:m,numVerticalGlyphVertices:E}=t;let C=null;if(d&&d.dynamicFilterNeedsFeature||F){const e=this.retainedQueryData[s.bucketInstanceId];C=x.loadFeature({featureIndex:t.featureIndex,bucketIndex:e.bucketIndex,sourceLayerIndex:e.sourceLayerIndex,layoutVertexArrayOffset:0})}if(d&&!(0,d.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch},C,this.retainedQueryData[s.bucketInstanceId].tileID.canonical,new e.P(t.tileAnchorX,t.tileAnchorY),this.transform.calculateDistanceTileData(d.unwrappedTileID)))return this.placements[m]=new hi(!1,!1,!1,!0),void i.add(m);const P=A.evaluate(C,{});if(i.has(m))return;if(f)return void(this.placements[m]=new hi(!1,!1,!1));let z=!1,D=!1,R=!0,L=!1,B=!1,N=null,V={box:null,offscreen:null,occluded:null},U={box:null,offscreen:null,occluded:null},j=null,G=null,q=null,Z=0,$=0,H=0;l.textFeatureIndex?Z=l.textFeatureIndex:t.useRuntimeCollisionCircles&&(Z=t.featureIndex),l.verticalTextFeatureIndex&&($=l.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},X=l.textBox;if(X){W(X);const i=i=>{let r=e.bq.horizontal;if(s.allowVerticalPlacement&&!i&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[m];e&&(this.placedOrientations[m]=e,r=e,this.markUsedOrientation(s,r,t))}return r},r=(t,i)=>{if(s.allowVerticalPlacement&&E>0&&l.verticalTextBox){for(const r of s.writingModes)if(r===e.bq.vertical?(V=i(),U=V):V=t(),V&&V.box&&V.box.length)break}else V=t()};if(a.get("text-variable-anchor")){let o=a.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[m]){const e=this.prevPlacement.variableOffsets[m];o.indexOf(e.anchor)>0&&(o=o.filter((t=>t!==e.anchor)),o.unshift(e.anchor))}const h=(e,i,r)=>{const a=s.getSymbolInstanceTextSize(_,t,this.transform.zoom,n),l=(e.x2-e.x1)*a+2*e.padding,h=(e.y2-e.y1)*a+2*e.padding,u=t.hasIconTextFit&&!T?i:null;u&&W(u);let d={box:[],offscreen:!1,occluded:!1};const f=w?2*o.length:o.length;for(let i=0;i<f;++i){const f=this.attemptAnchorPlacement(o[i%o.length],e,l,h,a,S,M,p,c,y,i>=o.length,t,n,s,r,u,_,g);if(f&&(d=f.placedGlyphBoxes,d&&d.box&&d.box.length)){z=!0,N=f.shift;break}}return d};r((()=>h(X,l.iconBox,e.bq.horizontal)),(()=>{const t=l.verticalTextBox;return t&&W(t),s.allowVerticalPlacement&&!(V&&V.box&&V.box.length)&&E>0&&t?h(t,l.verticalIconBox,e.bq.vertical):{box:null,offscreen:null,occluded:null}})),V&&(z=V.box,R=V.offscreen,L=V.occluded);const u=i(!(!V||!V.box));if(!z&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[m];e&&(this.variableOffsets[m]=e,this.markUsedJustification(s,e.anchor,t,u))}}else{const a=(i,r)=>{const a=s.getSymbolInstanceTextSize(_,t,this.transform.zoom,n,o),l=this.collisionIndex.placeCollisionBox(s,a,i,new e.P(0,0),w,p,c,y.predicate);return l&&l.box&&l.box.length&&(this.markUsedOrientation(s,r,t),this.placedOrientations[m]=r),l};r((()=>a(X,e.bq.horizontal)),(()=>{const t=l.verticalTextBox;return s.allowVerticalPlacement&&E>0&&t?(W(t),a(t,e.bq.vertical)):{box:null,offscreen:null,occluded:null}})),i(!!(V&&V.box&&V.box.length))}}if(j=V,z=j&&j.box&&j.box.length>0,R=j&&j.offscreen,L=j&&j.occluded,t.useRuntimeCollisionCircles){const i=s.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex),n=e.br(s.textSizeData,_,i),o=a.get("text-padding");G=this.collisionIndex.placeCollisionCircles(s,w,i,s.lineVertexArray,s.glyphOffsetArray,n,c,h,u,r,M,y.predicate,t.collisionCircleDiameter*n/e.bw,o,this.retainedQueryData[s.bucketInstanceId].tileID),z=w||G.circles.length>0&&!G.collisionDetected,R=R&&G.offscreen,L=G.occluded}if(l.iconFeatureIndex&&(H=l.iconFeatureIndex),l.iconBox){const i=i=>{W(i);const r=t.hasIconTextFit&&N?mi(N.x,N.y,S,M,this.transform.angle):new e.P(0,0),n=s.getSymbolInstanceIconSize(g,this.transform.zoom,t.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(s,n,i,r,T,p,c,y.predicate)};U&&U.box&&U.box.length&&l.verticalIconBox?(q=i(l.verticalIconBox),D=q.box.length>0):(q=i(l.iconBox),D=q.box.length>0),R=R&&q.offscreen,B=q.occluded}const Y=v||0===t.numHorizontalGlyphVertices&&0===E,K=b||0===t.numIconVertices;if(Y||K?K?Y||(D=D&&z):z=D&&z:D=z=D&&z,z&&j&&j.box&&this.collisionIndex.insertCollisionBox(j.box,a.get("text-ignore-placement"),s.bucketInstanceId,U&&U.box&&$?$:Z,y.ID),D&&q&&this.collisionIndex.insertCollisionBox(q.box,a.get("icon-ignore-placement"),s.bucketInstanceId,H,y.ID),G&&(z&&this.collisionIndex.insertCollisionCircles(G.circles,a.get("text-ignore-placement"),s.bucketInstanceId,Z,y.ID),r)){const e=s.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new ui);for(let e=0;e<G.circles.length;e+=4)t.circles.push(G.circles[e+0]),t.circles.push(G.circles[e+1]),t.circles.push(G.circles[e+2]),t.circles.push(G.collisionDetected?1:0)}const J="globe"!==s.projection.name;O=O&&(J||!L),k=k&&(J||!B),this.placements[m]=new hi(z||O,D||k,R||s.justReloaded),i.add(m)};if(E&&this.buildingIndex&&(this.buildingIndex.updateZOffset(s,this.retainedQueryData[s.bucketInstanceId].tileID),s.updateZOffset()),s.sortFeaturesByY){const t=s.getSortedSymbolIndexes(this.transform.angle);for(let e=t.length-1;e>=0;--e){const i=t[e];B(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<e.length;++t){const i=e[t];B(s.symbolInstances.get(i),i,s.collisionArrays[i])}}else for(let e=t.symbolInstanceStart;e<t.symbolInstanceEnd;e++)B(s.symbolInstances.get(e),e,s.collisionArrays[e]);if(r&&s.bucketInstanceId in this.collisionCircleArrays){const t=this.collisionCircleArrays[s.bucketInstanceId];e.ab.mat4.invert(t.invProjMatrix,c),t.viewportMatrix=this.collisionIndex.getViewportMatrix()}s.justReloaded=!1}markUsedJustification(t,i,r,n){const{leftJustifiedTextSymbolIndex:o,centerJustifiedTextSymbolIndex:s,rightJustifiedTextSymbolIndex:a,verticalPlacedTextSymbolIndex:l,crossTileID:c}=r,h=e.bB(i),u=n===e.bq.vertical?l:"left"===h?o:"center"===h?s:"right"===h?a:-1;o>=0&&(t.text.placedSymbolArray.get(o).crossTileID=u>=0&&o!==u?0:c),s>=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),l>=0&&(t.text.placedSymbolArray.get(l).crossTileID=u>=0&&l!==u?0:c)}markUsedOrientation(t,i,r){const n=i===e.bq.horizontal||i===e.bq.horizontalOnly?i:0,o=i===e.bq.vertical?i:0,{leftJustifiedTextSymbolIndex:s,centerJustifiedTextSymbolIndex:a,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:c}=r,h=t.text.placedSymbolArray;s>=0&&(h.get(s).placedOrientation=n),a>=0&&(h.get(a).placedOrientation=n),l>=0&&(h.get(l).placedOrientation=n),c>=0&&(h.get(c).placedOrientation=o)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const r=t?t.symbolFadeChange(e):1,n=t?t.opacities:{},o=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=n[e];o?(this.opacities[e]=new ci(o,r,t.text,t.icon,null,t.clipped),i=i||t.text!==o.text.placed||t.icon!==o.icon.placed):(this.opacities[e]=new ci(null,r,t.text,t.icon,t.skipFade,t.clipped),i=i||t.text||t.icon)}for(const e in n){const t=n[e];if(!this.opacities[e]){const n=new ci(t,r,!1,!1);n.isHidden()||(this.opacities[e]=n,i=i||t.text.placed||t.icon.placed)}}for(const e in o)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=o[e]);for(const e in s)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=s[e]);i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t,i,r){const n=new Set;for(const o of t){const t=o.getBucket(e);t&&o.latestFeatureIndex&&e.fqid===t.layerIds[0]&&(this.updateBucketOpacities(t,n,o,o.collisionBoxArray,i,r,o.tileID,e.scope),t.layers[0].layout.get("symbol-z-elevate")&&this.buildingIndex&&(this.buildingIndex.updateZOffset(t,o.tileID),t.updateZOffset()))}}updateBucketOpacities(t,i,r,n,o,s,a,l){t.hasTextData()&&t.text.opacityVertexArray.clear(),t.hasIconData()&&t.icon.opacityVertexArray.clear(),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const c=t.layers[0].layout,h=t.layers[0].paint,u=!!t.layers[0].dynamicFilter(),d=new ci(null,0,!1,!1,!0),p=c.get("text-allow-overlap"),f=c.get("icon-allow-overlap"),m=c.get("text-variable-anchor"),_="map"===c.get("text-rotation-alignment"),g="map"===c.get("text-pitch-alignment"),y=h.get("symbol-z-offset"),x="sea"===c.get("symbol-elevation-reference"),v=!y.isConstant(),b=new ci(null,0,p&&(f||!t.hasIconData()||c.get("icon-optional")),f&&(p||!t.hasTextData()||c.get("text-optional")),!0);!t.collisionArrays&&n&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(n);const w=(e,t,i)=>{for(let r=0;r<t/4;r++)e.opacityVertexArray.emplaceBack(i)};let T=0;s&&t.updateReplacement(a,s);for(let n=0;n<t.symbolInstances.length;n++){const c=t.symbolInstances.get(n),{numHorizontalGlyphVertices:h,numVerticalGlyphVertices:p,crossTileID:f,numIconVertices:S,tileAnchorX:M,tileAnchorY:E}=c;let A=null;const I=this.retainedQueryData[t.bucketInstanceId];v&&c&&I&&(A=r.latestFeatureIndex.loadFeature({featureIndex:c.featureIndex,bucketIndex:I.bucketIndex,sourceLayerIndex:I.sourceLayerIndex,layoutVertexArrayOffset:0}));const C=y.evaluate(A,{}),P=i.has(f);let z=this.opacities[f];P?z=d:z||(z=b,this.opacities[f]=z),i.add(f);const D=h>0||p>0,R=S>0,L=this.placedOrientations[f],O=L===e.bq.vertical,k=L===e.bq.horizontal||L===e.bq.horizontalOnly;!D&&!R||z.isHidden()||T++;let F=!1;if((D||R)&&s)for(const i of t.activeReplacements){if(e.bx(i,o,e.by.Symbol,l))continue;if(i.min.x>M||M>i.max.x||i.min.y>E||E>i.max.y)continue;const t=e.bz(M,E,a.canonical,i.footprintTileId.canonical);if(F=e.bA(t,i.footprint),F)break}if(D){const e=F?Ei:Mi(z.text);w(t.text,h,O?Ei:e),w(t.text,p,k?Ei:e);const i=z.text.isHidden(),{leftJustifiedTextSymbolIndex:r,centerJustifiedTextSymbolIndex:n,rightJustifiedTextSymbolIndex:o,verticalPlacedTextSymbolIndex:s}=c,a=t.text.placedSymbolArray,l=i||O?1:0;r>=0&&(a.get(r).hidden=l),n>=0&&(a.get(n).hidden=l),o>=0&&(a.get(o).hidden=l),s>=0&&(a.get(s).hidden=i||k?1:0);const u=this.variableOffsets[f];u&&this.markUsedJustification(t,u.anchor,c,L);const d=this.placedOrientations[f];d&&(this.markUsedJustification(t,"left",c,d),this.markUsedOrientation(t,d,c))}if(R){const e=F?Ei:Mi(z.icon),{placedIconSymbolIndex:i,verticalPlacedIconSymbolIndex:r}=c,n=t.icon.placedSymbolArray,o=z.icon.isHidden()?1:0;i>=0&&(w(t.icon,S,O?Ei:e),n.get(i).hidden=o),r>=0&&(w(t.icon,c.numVerticalIconVertices,k?Ei:e),n.get(r).hidden=o)}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const i=t.collisionArrays[n];if(i){let r=new e.P(0,0),n=!0;if(i.textBox||i.verticalTextBox){if(m){const e=this.variableOffsets[f];e?(r=fi(e.anchor,e.width,e.height,e.textOffset,e.textScale),_&&r._rotate(g?this.transform.angle:-this.transform.angle)):n=!1}u&&(n=!z.clipped),i.textBox&&gi(t.textCollisionBox.collisionVertexArray,z.text.placed,!n||O,C,x,r.x,r.y),i.verticalTextBox&&gi(t.textCollisionBox.collisionVertexArray,z.text.placed,!n||k,C,x,r.x,r.y)}const o=n&&Boolean(!k&&i.verticalIconBox);i.iconBox&&gi(t.iconCollisionBox.collisionVertexArray,z.icon.placed,o,C,x,c.hasIconTextFit?r.x:0,c.hasIconTextFit?r.y:0),i.verticalIconBox&&gi(t.iconCollisionBox.collisionVertexArray,z.icon.placed,!o,C,x,c.hasIconTextFit?r.x:0,c.hasIconTextFit?r.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.lastPlacementChangeTime<this.fadeDuration}stillRecent(e,t){const i=this.zoomAtLastRecencyCheck===t?1-this.zoomAdjustment(t):1;return this.zoomAtLastRecencyCheck=t,this.commitTime+this.fadeDuration*i>e}setStale(){this.stale=!0}}function gi(e,t,i,r,n,o,s){e.emplaceBack(t?1:0,i?1:0,o||0,s||0,r,n?1:0),e.emplaceBack(t?1:0,i?1:0,o||0,s||0,r,n?1:0),e.emplaceBack(t?1:0,i?1:0,o||0,s||0,r,n?1:0),e.emplaceBack(t?1:0,i?1:0,o||0,s||0,r,n?1:0)}const yi=Math.pow(2,25),xi=Math.pow(2,24),vi=Math.pow(2,17),bi=Math.pow(2,16),wi=Math.pow(2,9),Ti=Math.pow(2,8),Si=Math.pow(2,1);function Mi(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*yi+t*xi+i*vi+t*bi+i*wi+t*Ti+i*Si+t}const Ei=0;class Ai{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&void 0!==e.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(e,t,i,r,n,o){const s=this._bucketParts;for(;this._currentTileIndex<e.length;)if(t.getBucketParts(s,r,e[this._currentTileIndex],this._sortAcrossTiles,o),this._currentTileIndex++,n())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,s.sort(((e,t)=>e.sortKey-t.sortKey)));this._currentPartIndex<s.length;){const e=s[this._currentPartIndex];if(t.placeLayerBucketPart(e,this._seenCrossTileIDs,i,0===e.symbolInstanceStart,o),this._currentPartIndex++,n())return!0}return!1}}class Ii{constructor(e,t,i,r,n,o,s,a,l){this.placement=new _i(e,n,o,s,a,l),this._currentPlacementIndex=t.length-1,this._forceFullPlacement=i,this._showCollisionBoxes=r,this._done=!1}isDone(){return this._done}continuePlacement(t,i,r,n,o){const s=e.q.now(),a=()=>{const t=e.q.now()-s;return!this._forceFullPlacement&&t>2};for(;this._currentPlacementIndex>=0;){const s=i[t[this._currentPlacementIndex]],l=this.placement.collisionIndex.transform.zoom;if("symbol"===s.type&&(!s.minzoom||s.minzoom<=l)&&(!s.maxzoom||s.maxzoom>l)){const t=s,i=t.layout.get("symbol-z-elevate"),l=void 0!==t.layout.get("symbol-sort-key").constantOr(1),c=t.layout.get("symbol-z-order"),h="viewport-y"===c||"auto"===c&&!("viewport-y"!==c&&l),u=t.layout.get("text-allow-overlap")||t.layout.get("icon-allow-overlap")||t.layout.get("text-ignore-placement")||t.layout.get("icon-ignore-placement"),d=h&&u,p=this._inProgressLayer=this._inProgressLayer||new Ai(t),f=e.aC(s.source,s.scope);if(p.continuePlacement(i||d?n[f]:r[f],this.placement,this._showCollisionBoxes,s,a,o))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const Ci=512/e.ag/2;class Pi{constructor(t,i,r){this.tileID=t,this.bucketInstanceId=r,this.index=new e.bE(i.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const n=t.canonical.x*e.ag,o=t.canonical.y*e.ag;for(let e=0;e<i.length;e++){const{key:t,crossTileID:r,tileAnchorX:s,tileAnchorY:a}=i.get(e),l=Math.floor((n+s)*Ci),c=Math.floor((o+a)*Ci);this.index.add(l,c),this.keys.push(t),this.crossTileIDs.push(r)}this.index.finish()}findMatches(t,i,r){const n=this.tileID.canonical.z<i.canonical.z?1:Math.pow(2,this.tileID.canonical.z-i.canonical.z),o=Ci/Math.pow(2,i.canonical.z-this.tileID.canonical.z),s=i.canonical.x*e.ag,a=i.canonical.y*e.ag;for(let e=0;e<t.length;e++){const i=t.get(e);if(i.crossTileID)continue;const{key:l,tileAnchorX:c,tileAnchorY:h}=i,u=Math.floor((s+c)*o),d=Math.floor((a+h)*o),p=this.index.range(u-n,d-n,u+n,d+n);for(const e of p){const t=this.crossTileIDs[e];if(this.keys[e]===l&&!r.has(t)){r.add(t),i.crossTileID=t;break}}}}}class zi{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Di{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){const t=Math.round((e-this.lng)/360);if(0!==t)for(const e in this.indexes){const i=this.indexes[e],r={};for(const e in i){const n=i[e];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+t),r[n.tileID.key]=n}this.indexes[e]=r}this.lng=e}addBucket(e,t,i){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===t.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let e=0;e<t.symbolInstances.length;e++)t.symbolInstances.get(e).crossTileID=0;this.usedCrossTileIDs[e.overscaledZ]||(this.usedCrossTileIDs[e.overscaledZ]=new Set);const r=this.usedCrossTileIDs[e.overscaledZ];for(const i in this.indexes){const n=this.indexes[i];if(Number(i)>e.overscaledZ)for(const i in n){const o=n[i];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,r)}else{const o=n[e.scaledTo(Number(i)).key];o&&o.findMatches(t.symbolInstances,e,r)}}for(let e=0;e<t.symbolInstances.length;e++){const n=t.symbolInstances.get(e);n.crossTileID||(n.crossTileID=i.generate(),r.add(n.crossTileID))}return void 0===this.indexes[e.overscaledZ]&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new Pi(e,t.symbolInstances,t.bucketInstanceId),!0}removeBucketCrossTileIDs(e,t){for(const i of t.crossTileIDs)this.usedCrossTileIDs[e].delete(i)}removeStaleBuckets(e){let t=!1;for(const i in this.indexes){const r=this.indexes[i];for(const n in r)e[r[n].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,r[n]),delete r[n],t=!0)}return t}}class Ri{constructor(){this.layerIndexes={},this.crossTileIDs=new zi,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,t,i,r){let n=this.layerIndexes[e.fqid];void 0===n&&(n=this.layerIndexes[e.fqid]=new Di);let o=!1;const s={};"globe"!==r.name&&n.handleWrapJump(i);for(const i of t){const t=i.getBucket(e);t&&e.fqid===t.layerIds[0]&&(t.bucketInstanceId||(t.bucketInstanceId=++this.maxBucketInstanceId),n.addBucket(i.tileID,t,this.crossTileIDs)&&(o=!0),s[t.bucketInstanceId]=!0)}return n.removeStaleBuckets(s)&&(o=!0),o}pruneUnusedLayers(e){const t={};e.forEach((e=>{t[e]=!0}));for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}const Li=771;class Oi{constructor(e,t,i,r){this.blendFunction=e,this.blendColor=t,this.mask=i,this.blendEquation=r}}Oi.Replace=[1,0,1,0],Oi.disabled=new Oi(Oi.Replace,e.aj.transparent,[!1,!1,!1,!1]),Oi.unblended=new Oi(Oi.Replace,e.aj.transparent,[!0,!0,!0,!0]),Oi.alphaBlended=new Oi([1,Li,1,Li],e.aj.transparent,[!0,!0,!0,!0]),Oi.alphaBlendedNonPremultiplied=new Oi([770,Li,770,Li],e.aj.transparent,[!0,!0,!0,!0]),Oi.multiply=new Oi([774,0,774,0],e.aj.transparent,[!0,!0,!0,!0]);class ki{constructor(e,t,i){this.func=e,this.mask=t,this.range=i}}ki.ReadOnly=!1,ki.ReadWrite=!0,ki.disabled=new ki(519,ki.ReadOnly,[0,1]);const Fi=7680;class Bi{constructor(e,t,i,r,n,o){this.test=e,this.ref=t,this.mask=i,this.fail=r,this.depthFail=n,this.pass=o}}Bi.disabled=new Bi({func:519,mask:0},0,0,Fi,Fi,Fi);const Ni=1029,Vi=2305;class Ui{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}}function ji(t,i){const r=e.bG(t,3);e.ab.mat4.fromQuat(t,i),e.bI(t,3,r)}function Gi(t,i){const r=e.ab.quat.identity([]);return e.ab.quat.rotateZ(r,r,-i),e.ab.quat.rotateX(r,r,-t),r}function qi(t,i){const r=[t[0],t[1],0],n=[i[0],i[1],0];if(e.ab.vec3.length(r)>=1e-15){const t=e.ab.vec3.normalize([],r);e.ab.vec3.scale(n,t,e.ab.vec3.dot(n,t)),i[0]=n[0],i[1]=n[1]}const o=e.ab.vec3.cross([],i,t);if(e.ab.vec3.len(o)<1e-15)return null;const s=Math.atan2(-o[1],o[0]);return Gi(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),s)}Ui.disabled=new Ui(!1,Ni,Vi),Ui.backCCW=new Ui(!0,Ni,Vi),Ui.backCW=new Ui(!0,Ni,2304),Ui.frontCW=new Ui(!0,1028,2304),Ui.frontCCW=new Ui(!0,1028,Vi);class Zi{constructor(e,t){this.position=e,this.orientation=t}get position(){return this._position}set position(t){if(t){const i=t instanceof e.aa?t:new e.aa(t[0],t[1],t[2]);this._renderWorldCopies&&(i.x=e.bF(i.x,0,1)),this._position=i}else this._position=null}lookAtPoint(t,i){if(this.orientation=null,!this.position)return;const r=this.position,n=this._elevation?this._elevation.getAtPointOrZero(e.aa.fromLngLat(t)):0,o=e.aa.fromLngLat(t,n),s=[o.x-r.x,o.y-r.y,o.z-r.z];i||(i=[0,0,1]),i[2]=Math.abs(i[2]),this.orientation=qi(s,i)}setPitchBearing(t,i){this.orientation=Gi(e.ai(t),e.ai(-i))}}class $i{constructor(t,i){this._transform=e.ab.mat4.identity([]),this.orientation=i,this.position=t}get mercatorPosition(){const t=this.position;return new e.aa(t[0],t[1],t[2])}get position(){const t=e.bG(this._transform,3);return[t[0],t[1],t[2]]}set position(t){var i;t&&e.bI(this._transform,3,[(i=t)[0],i[1],i[2],1])}get orientation(){return this._orientation}set orientation(t){this._orientation=t||e.ab.quat.identity([]),t&&ji(this._transform,this._orientation)}getPitchBearing(){const e=this.forward(),t=this.right();return{bearing:Math.atan2(-t[1],t[0]),pitch:Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2])}}setPitchBearing(e,t){this._orientation=Gi(e,t),ji(this._transform,this._orientation)}forward(){const t=e.bG(this._transform,2);return[-t[0],-t[1],-t[2]]}up(){const t=e.bG(this._transform,1);return[-t[0],-t[1],-t[2]]}right(){const t=e.bG(this._transform,0);return[t[0],t[1],t[2]]}getCameraToWorld(t,i){const r=new Float64Array(16);return e.ab.mat4.invert(r,this.getWorldToCamera(t,i)),r}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(t,i,r){const n=this.position;e.ab.vec3.scale(n,n,-t);const o=new Float64Array(16);return e.ab.mat4.fromScaling(o,[r,r,r]),e.ab.mat4.translate(o,o,n),o[10]*=i,o}getWorldToCamera(t,i){const r=new Float64Array(16),n=new Float64Array(4),o=this.position;return e.ab.quat.conjugate(n,this._orientation),e.ab.vec3.scale(o,o,-t),e.ab.mat4.fromQuat(r,n),e.ab.mat4.translate(r,r,o),r[1]*=-1,r[5]*=-1,r[9]*=-1,r[13]*=-1,r[8]*=i,r[9]*=i,r[10]*=i,r[11]*=i,r}getCameraToClipPerspective(t,i,r,n){const o=new Float64Array(16);return e.ab.mat4.perspective(o,t,i,r,n),o}getCameraToClipOrthographic(t,i,r,n,o,s){const a=new Float64Array(16);return e.ab.mat4.ortho(a,t,i,r,n,o,s),a}getDistanceToElevation(t,i=!1){const r=0===t?0:e.bH(t,i?e.aS(this.position[1]):this.position[1]),n=this.forward();return(r-this.position[2])/n[2]}clone(){return new $i([...this.position],[...this.orientation])}}const Hi=5,Wi=6,Xi=7,Yi=8,Ki=9,Ji=10,Qi=11;class er{constructor(e=0,t=0,i=0,r=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=i,this.right=r}interpolate(t,i,r){return null!=i.top&&null!=t.top&&(this.top=e.af(t.top,i.top,r)),null!=i.bottom&&null!=t.bottom&&(this.bottom=e.af(t.bottom,i.bottom,r)),null!=i.left&&null!=t.left&&(this.left=e.af(t.left,i.left,r)),null!=i.right&&null!=t.right&&(this.right=e.af(t.right,i.right,r)),this}getCenter(t,i){const r=e.aw((this.left+t-this.right)/2,0,t),n=e.aw((this.top+i-this.bottom)/2,0,i);return new e.P(r,n)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new er(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const tr=(e,t,i)=>(1-i)*e+i*t,ir=e=>e*e*e*e*e;class rr{constructor(t,i,r,n,o,s,a){this.tileSize=512,this._renderWorldCopies=void 0===o||o,this._minZoom=t||0,this._maxZoom=i||22,this._minPitch=r??0,this._maxPitch=n??60,this.setProjection(s),this.setMaxBounds(a),this.width=0,this.height=0,this._center=new e.bO(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 er,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new $i,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 rr(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.ay(this.projection,["name","center","parallels"])}setProjection(t){this.projectionOptions=t||{name:"mercator"};const i=this.projection?this.getProjection():void 0;this.projection=e.bP(this.projectionOptions);const r=this.getProjection(),n=!e.bn(i,r);return n&&this._calcMatrices(),this.mercatorFromTransition=!1,n}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.bP({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.bH(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.bF(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.ab.mat2.create(),e.ab.mat2.rotate(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const i=e.aw(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.ai(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]],r=this.horizonLineFromTop();let n=0,o=0;for(let s=0;s<i.length;s++){const a=new e.P(i[s][0]*this.width,r+i[s][1]*(this.height-r)),l=t.pointCoordinate(a);if(!l)continue;const c=1/Math.hypot(l[0]-this._camera.position[0],l[1]-this._camera.position[1]);n+=l[3]*c,o+=c}return 0===o?NaN:n/o}get center(){return this._center}set center(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._terrainEnabled()&&("ground"===this.cameraElevationReference?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(null==this._seaLevelZoom||!this._elevation)return;const e=this._seaLevelZoom,t=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),i=this.pixelsPerMeter/this.worldSize*t,r=this._mercatorZfromZoom(e),n=this._mercatorZfromZoom(this._maxZoom),o=Math.max(r-i,n);this._setZoom(this._zoomFromMercatorZ(o))}get padding(){return this._edgeInsets.toJSON()}set padding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}computeZoomRelativeTo(t){const i=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,t.toAltitude()));let r;r=t.z<this._camera.position[2]?[i.x,i.y,i.z]:[t.x,t.y,t.z];const n=e.ab.vec3.length(e.ab.vec3.sub([],this._camera.position,r));return e.aw(this._zoomFromMercatorZ(n),this._minZoom,this._maxZoom)}setFreeCameraOptions(t){if(!this.height)return;if(!t.position&&!t.orientation)return;this._updateCameraState();let i=!1;if(t.orientation&&!e.ab.quat.exactEquals(t.orientation,this._camera.orientation)&&(i=this._setCameraOrientation(t.orientation)),t.position){const r=[t.position.x,t.position.y,t.position.z];e.ab.vec3.exactEquals(r,this._camera.position)||(this._setCameraPosition(r),i=!0)}i&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();const t=this._camera.position,i=new Zi;return i.position=new e.aa(t[0],t[1],t[2]),i.orientation=this._camera.orientation,i._elevation=this.elevation,i._renderWorldCopies=this.renderWorldCopies,i}_setCameraOrientation(t){if(!e.ab.quat.length(t))return!1;e.ab.quat.normalize(t,t);const i=e.ab.vec3.transformQuat([],[0,0,-1],t),r=e.ab.vec3.transformQuat([],[0,-1,0],t);if(r[2]<0)return!1;const n=qi(i,r);return!!n&&(this._camera.orientation=n,!0)}_setCameraPosition(t){const i=this.zoomScale(this.minZoom)*this.tileSize,r=this.zoomScale(this.maxZoom)*this.tileSize,n=this.cameraToCenterDistance;t[2]=e.aw(t[2],n/r,n/i),this._camera.position=t}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this._constrain(),this._calcMatrices()}coveringZoomLevel(e){const t=(e.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/e.tileSize));return Math.max(0,t)}getVisibleUnwrappedCoordinates(t){const i=[new e.bQ(0,t)];if(this.renderWorldCopies){const r=this.pointCoordinate(new e.P(0,0)),n=this.pointCoordinate(new e.P(this.width,0)),o=this.pointCoordinate(new e.P(this.width,this.height)),s=this.pointCoordinate(new e.P(0,this.height)),a=Math.floor(Math.min(r.x,n.x,o.x,s.x)),l=Math.floor(Math.max(r.x,n.x,o.x,s.x)),c=1;for(let r=a-c;r<=l+c;r++)0!==r&&i.push(new e.bQ(r,t))}return i}isLODDisabled(e){return(!e||this.pitch<=60)&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace}extendTileCover(t,i,r){let n=[];const o=void 0!==r,s=!o;if(s&&this.zoom<i)return n;if(o&&0===r[0]&&0===r[1])return n;const a=new Set,l=(t,i,r,o,s)=>{const l=e.c5(i,t,r,o,s);a.has(l)||(n.push(new e.aG(t,i,r,o,s)),a.add(l))};for(let e=0;e<t.length;e++){const n=t[e];if(s&&n.canonical.z!==i)continue;const a=n.canonical,c=n.overscaledZ,h=n.wrap,u=1<<a.z,d=a.x+1<u,p=a.x>0,f=a.y+1<u,m=a.y>0,_=n.wrap-(p?0:1),g=n.wrap+(d?0:1),y=p?a.x-1:u-1,x=d?a.x+1:0;if(o)r[0]<0?(l(c,g,a.z,x,a.y),r[1]<0&&f&&(l(c,h,a.z,a.x,a.y+1),l(c,g,a.z,x,a.y+1)),r[1]>0&&m&&(l(c,h,a.z,a.x,a.y-1),l(c,g,a.z,x,a.y-1))):r[0]>0?(l(c,_,a.z,y,a.y),r[1]<0&&f&&(l(c,h,a.z,a.x,a.y+1),l(c,_,a.z,y,a.y+1)),r[1]>0&&m&&(l(c,h,a.z,a.x,a.y-1),l(c,_,a.z,y,a.y-1))):r[1]<0&&f?l(c,h,a.z,a.x,a.y+1):m&&l(c,h,a.z,a.x,a.y-1);else{const e=n.visibleQuadrants;1&e&&(l(c,_,a.z,y,a.y),m&&(l(c,h,a.z,a.x,a.y-1),l(c,_,a.z,y,a.y-1))),2&e&&(l(c,g,a.z,x,a.y),m&&(l(c,h,a.z,a.x,a.y-1),l(c,g,a.z,x,a.y-1))),4&e&&(l(c,_,a.z,y,a.y),f&&(l(c,h,a.z,a.x,a.y+1),l(c,_,a.z,y,a.y+1))),8&e&&(l(c,g,a.z,x,a.y),f&&(l(c,h,a.z,a.x,a.y+1),l(c,g,a.z,x,a.y+1)))}}const c=[];for(const e of n)n.some((t=>e.isChildOf(t)))||c.push(e);if(n=c.filter((e=>!t.some((t=>!!(e.overscaledZ<i&&t.isChildOf(e))||e.equals(t)||e.isChildOf(t))))),s){const e=1<<i,t="globe"===this.projection.name?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),r=[e*t.x,e*t.y],o=4,s=o*o;n=n.filter((e=>{const t=e.canonical.x+.5-r[0],i=e.canonical.y+.5-r[1];return t*t+i*i<s}))}return n}coveringTiles(t){let i=this.coveringZoomLevel(t);const r=i,n=this.elevation&&this.elevation.exaggeration(),o=n&&!t.isTerrainDEM,s="mercator"===this.projection.name;if(void 0!==t.minzoom&&i<t.minzoom)return[];void 0!==t.maxzoom&&i>t.maxzoom&&(i=t.maxzoom);const a=this.locationCoordinate(this.center),l=this.center.lat,c=1<<i,h=[c*a.x,c*a.y,0],u="globe"===this.projection.name,d=!u,p=e.bR.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,i,d),f=u?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),m=c*e.bH(1,this.center.lat),_=this._camera.position[2]/e.bH(1,this.center.lat),g=[c*f.x,c*f.y,_*(d?1:m)],y=u||n,x=this.cameraToCenterDistance/t.tileSize*(t.roundZoom?1:.502),v=this.isLODDisabled(!0)?i:0;let b;if(this._elevation&&t.isTerrainDEM)b=1e4*this._elevation.exaggeration();else if(this._elevation){const e=this._elevation.getMinMaxForVisibleTiles();b=e?e.max:this._centerAltitude}else b=this._centerAltitude;const w=t.isTerrainDEM?-b:this._elevation?this._elevation.getMinElevationBelowMSL():0,T=this.projection.isReprojectedInTileSpace?e.bS(this):1,S=t=>{const i=1/4e4,r=new e.aa(t.x+i,t.y,t.z),n=new e.aa(t.x,t.y+i,t.z),o=t.toLngLat(),s=r.toLngLat(),a=n.toLngLat(),l=this.locationCoordinate(o),c=this.locationCoordinate(s),h=this.locationCoordinate(a),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},M=t=>{const i=b,r=w;return{aabb:e.bV(this,c,0,0,0,t,r,i,this.projection),zoom:0,x:0,y:0,minZ:r,maxZ:i,wrap:t,fullyVisible:!1}},E=[];let A=[];const I=i,C=t.reparseOverscaled?r:i,P=(_-this._centerAltitude)*m,z=e=>{if(!this._elevation||!e.tileID||!s)return;const t=this._elevation.getMinMaxForTile(e.tileID),i=e.aabb;t?(i.min[2]=t.min,i.max[2]=t.max,i.center[2]=(i.min[2]+i.max[2])/2):(e.shouldSplit=R(e),e.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude))},D=(e,t)=>{if(.707*t<e)return 1;const i=t/e;return i/(1.4144271570014144+(Math.pow(1.1,i-1.4144271570014144+1)-1)/(1.1-1)-1)},R=t=>{if(t.zoom<v)return!0;if(t.zoom===I)return!1;if(null!=t.shouldSplit)return t.shouldSplit;const i=t.aabb.distanceX(g),n=t.aabb.distanceY(g);let a=P,c=1;if(u){a=t.aabb.distanceZ(g);const i=Math.pow(2,t.zoom),r=e.aS((t.y+1)/i),n=e.aS(t.y/i),o=Math.min(Math.max(l,r),n),s=e.c9(o)/e.c9(l);if(c=o===l?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,s/this._mercatorScaleRatio),this.zoom<=e.c6&&t.zoom===I-1&&s>=.9)return!0}else if(o&&(a=t.aabb.distanceZ(g)*m),this.projection.isReprojectedInTileSpace&&r<=5){const i=Math.pow(2,t.zoom),r=S(new e.aa((t.x+.5)/i,(t.y+.5)/i));c=r>.85?1:r}if(!s){const e=Math.sqrt(i*i+n*n+a*a);let r=(1<<I-t.zoom)*x*c;return r*=D(Math.max(a,P),e),e<r}let d=Number.MAX_VALUE,p=0;const f=t.aabb.getCorners(),_=[];for(const t of f){e.ab.vec3.sub(_,t,g),u||(o?_[2]*=m:_[2]=P);const i=e.ab.vec3.dot(_,this._camera.forward());i<d&&(d=i,p=Math.abs(_[2]))}let y=(1<<I-t.zoom)*x*c;if(y*=D(Math.max(p,P),d),d<y)return!0;const b=t.aabb.closestPoint(h);return b[0]===h[0]&&b[1]===h[1]};if(this.renderWorldCopies)for(let e=1;e<=3;e++)E.push(M(-e)),E.push(M(e));for(E.push(M(0));E.length>0;){const r=E.pop(),n=r.x,a=r.y;let l=r.fullyVisible;const d=()=>"globe"===this.projection.name&&(0===r.y||r.y===(1<<r.zoom)-1);if(!l){let t=y?r.aabb.intersects(p):r.aabb.intersectsFlat(p);if(0===t&&d()){const i=new e.bT(r.zoom,n,a);t=e.bU(this,c,i,!0).intersects(p)}if(0===t)continue;l=2===t}if(r.zoom!==I&&R(r))for(let t=0;t<4;t++){const i=(n<<1)+t%2,h=(a<<1)+(t>>1),d={aabb:s?r.aabb.quadrant(t):e.bV(this,c,r.zoom+1,i,h,r.wrap,r.minZ,r.maxZ,this.projection),zoom:r.zoom+1,x:i,y:h,wrap:r.wrap,fullyVisible:l,tileID:void 0,shouldSplit:void 0,minZ:r.minZ,maxZ:r.maxZ};o&&!u&&(d.tileID=new e.aG(r.zoom+1===I?C:r.zoom+1,r.wrap,r.zoom+1,i,h),z(d)),E.push(d)}else{const o=r.zoom===I?C:r.zoom;if(t.minzoom&&t.minzoom>o)continue;let s=0;if(!l){let i=y?r.aabb.intersectsPrecise(p):r.aabb.intersectsPreciseFlat(p);if(0===i&&d()){const t=new e.bT(r.zoom,n,a);i=e.bU(this,c,t,!0).intersectsPrecise(p)}if(0===i)continue;if(t.calculateQuadrantVisibility)if(p.containsPoint(r.aabb.center))s=15;else for(let e=0;e<4;e++)0!==r.aabb.quadrant(e).intersects(p)&&(s|=1<<e)}const u=h[0]-(.5+n+(r.wrap<<r.zoom))*(1<<i-r.zoom),f=h[1]-.5-a,m=r.tileID?r.tileID:new e.aG(o,r.wrap,r.zoom,n,a);t.calculateQuadrantVisibility&&(m.visibleQuadrants=s),A.push({tileID:m,distanceSq:u*u+f*f})}}if(this.fogCullDistSq){const i=this.fogCullDistSq,r=this.horizonLineFromTop();A=A.filter((n=>{const o=[0,0,0,1],s=[e.ag,e.ag,0,1],a=this.calculateFogTileMatrix(n.tileID.toUnwrapped());e.ab.vec4.transformMat4(o,o,a),e.ab.vec4.transformMat4(s,s,a);const l=e.ab.vec4.min([],o,s),c=e.ab.vec4.max([],o,s),h=e.bW(l,c);if(0===h)return!0;let u=!1;const d=this._elevation;if(d&&h>i&&0!==r){const i=this.calculateProjMatrix(n.tileID.toUnwrapped());let o;t.isTerrainDEM||(o=d.getMinMaxForTile(n.tileID)),o||(o={min:w,max:b});const s=e.c7(this.rotation),a=[s[0]*e.ag,s[1]*e.ag,o.max];e.ab.vec3.transformMat4(a,a,i),u=(1-a[1])*this.height*.5<r}return h<i||u}))}return A.sort(((e,t)=>e.distanceSq-t.distanceSq)).map((e=>e.tileID))}resize(e,t){this.width=e,this.height=t,this.pixelsToGLUnits=[2/e,-2/t],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log(e)/Math.LN2}project(t){const i=e.aw(t.lat,-e.bX,e.bX),r=this.projection.project(t.lng,i);return new e.P(r.x*this.worldSize,r.y*this.worldSize)}unproject(e){return this.projection.unproject(e.x/this.worldSize,e.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/e.bH(1,this.center.lat)/this.worldSize}setLocationAtPoint(t,i){let r,n;const o=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;r=(i.x-o.x)/e,n=(i.y-o.y)/e}else{const e=this.pointCoordinate(i),t=this.pointCoordinate(o);r=e.x-t.x,n=e.y-t.y}const s=this.locationCoordinate(t);this.setLocation(new e.aa(s.x-r,s.y-n))}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 r=i?e.bH(i,t.lat):void 0,n=this.projection.project(t.lng,t.lat);return new e.aa(n.x,n.y,r)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(t,i){const r=null!=i?i:this._centerAltitude,n=[t.x,t.y,0,1],o=[t.x,t.y,1,1];e.ab.vec4.transformMat4(n,n,this.pixelMatrixInverse),e.ab.vec4.transformMat4(o,o,this.pixelMatrixInverse);const s=o[3];e.ab.vec4.scale(n,n,1/n[3]),e.ab.vec4.scale(o,o,1/s);const a=n[2],l=o[2];return{p0:n,p1:o,t:a===l?0:(r-a)/(l-a)}}screenPointToMercatorRay(t){const i=[t.x,t.y,0,1],r=[t.x,t.y,1,1];return e.ab.vec4.transformMat4(i,i,this.pixelMatrixInverse),e.ab.vec4.transformMat4(r,r,this.pixelMatrixInverse),e.ab.vec4.scale(i,i,1/i[3]),e.ab.vec4.scale(r,r,1/r[3]),i[2]=e.bH(i[2],this._center.lat)*this.worldSize,r[2]=e.bH(r[2],this._center.lat)*this.worldSize,e.ab.vec4.scale(i,i,1/this.worldSize),e.ab.vec4.scale(r,r,1/this.worldSize),new e.aq([i[0],i[1],i[2]],e.ab.vec3.normalize([],e.ab.vec3.sub([],r,i)))}rayIntersectionCoordinate(t){const{p0:i,p1:r,t:n}=t,o=e.bH(i[2],this._center.lat),s=e.bH(r[2],this._center.lat);return new e.aa(e.af(i[0],r[0],n)/this.worldSize,e.af(i[1],r[1],n)/this.worldSize,e.af(o,s,n))}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.aa(i[0],i[1],i[2]);let r=0,n=this.horizonLineFromTop();if(t.y>n)return this.pointCoordinate(t);const o=.02*n,s=t.clone();for(let t=0;t<10&&n-r>o;t++){s.y=e.af(r,n,.66);const t=this.projection.pointCoordinate3D(this,s.x,s.y);t?(n=s.y,i=t):r=s.y}return i?new e.aa(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.bY)return!this.isPointAboveHorizon(t);const i=this.pointCoordinate(t);return i.y>=0&&i.y<=1}_coordinatePoint(t,i){const r=i&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,n=[t.x*this.worldSize,t.y*this.worldSize,r+t.toAltitude(),1];return e.ab.vec4.transformMat4(n,n,this.pixelMatrix),n[3]>0?new e.P(n[0]/n[3],n[1]/n[3]):new e.P(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:t,left:i}=this._edgeInsets,r=this.height-this._edgeInsets.bottom,n=this.width-this._edgeInsets.right,o=this.pointLocation3D(new e.P(i,t)),s=this.pointLocation3D(new e.P(n,t)),a=this.pointLocation3D(new e.P(n,r)),l=this.pointLocation3D(new e.P(i,r));let c=Math.min(o.lng,s.lng,a.lng,l.lng),h=Math.max(o.lng,s.lng,a.lng,l.lng),u=Math.min(o.lat,s.lat,a.lat,l.lat),d=Math.max(o.lat,s.lat,a.lat,l.lat);const p=Math.pow(2,-this.zoom)/16*270,f="globe"===this.projection.name?1:4,m=(t,i,r,n,o)=>{const s=(t+r)/2,a=(i+n)/2,l=new e.P(s,a),{lng:_,lat:g}=this.pointLocation3D(l),y=Math.max(0,c-_,u-g,_-h,g-d);c=Math.min(c,_),h=Math.max(h,_),u=Math.min(u,g),d=Math.max(d,g),(o<f||y>p)&&(m(t,i,s,a,o+1),m(s,a,r,n,o+1))};if(m(i,t,n,t,1),m(n,t,n,r,1),m(n,r,i,r,1),m(i,r,i,t,1),"globe"===this.projection.name){const[t,i]=e.bZ(this);t?(d=90,h=180,c=-180):i&&(u=-90,h=180,c=-180)}return new e.az(new e.bO(c,u),new e.bO(h,d))}_getBoundsRectangular(t,i){const{top:r,left:n}=this._edgeInsets,o=this.height-this._edgeInsets.bottom,s=this.width-this._edgeInsets.right,a=new e.P(n,r),l=new e.P(s,r),c=new e.P(s,o),h=new e.P(n,o);let u=this.pointCoordinate(a,t),d=this.pointCoordinate(l,t);const p=this.pointCoordinate(c,i),f=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.aa((1-f.y)/m(f,u)+f.x,1):u.y<0&&d.y<=1&&(u=new e.aa(-f.y/m(f,u)+f.x,0)),d.y>1&&u.y>=0?d=new e.aa((1-p.y)/m(p,d)+p.x,1):d.y<0&&u.y<=1&&(d=new e.aa(-p.y/m(p,d)+p.x,0)),(new e.az).extend(this.coordinateLocation(u)).extend(this.coordinateLocation(d)).extend(this.coordinateLocation(f)).extend(this.coordinateLocation(p))}_getBoundsRectangularTerrain(){const e=this.elevation;if(!e.visibleDemTiles.length||e.isUsingMockSource())return this._getBoundsRectangular(0,0);const t=e.visibleDemTiles.reduce(((e,t)=>{if(t.dem){const i=t.dem.tree;e.min=Math.min(e.min,i.minimums[0]),e.max=Math.max(e.max,i.maximums[0])}return e}),{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(t.min*e.exaggeration(),t.max*e.exaggeration())}getBounds(){return"mercator"===this.projection.name||"equirectangular"===this.projection.name?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(e=!0){const t=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,i=this.height/2-t*(1-this._horizonShift);return e?Math.max(0,i):i}getMaxBounds(){return this.maxBounds}setMaxBounds(t){this.maxBounds=t,this.minLat=-e.bX,this.maxLat=e.bX,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=e.at(this.minLng)*this.tileSize,this.worldMaxX=e.at(this.maxLng)*this.tileSize,this.worldMinY=e.aA(this.maxLat)*this.tileSize,this.worldMaxY=e.aA(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(e,t){return this.projection.createTileMatrix(this,t,e)}calculateDistanceTileData(t){const i=t.key,r=this._distanceTileDataCache;if(r[i])return r[i];const n=t.canonical,o=1/this.height,s=this.cameraWorldSize,a=s/this.zoomScale(n.z),l=(n.x+Math.pow(2,n.z)*t.wrap)*a,c=n.y*a,h=this.point;h.x*=s/this.worldSize,h.y*=s/this.worldSize;const u=this.angle,d=Math.sin(-u),p=-Math.cos(-u);return r[i]={bearing:[d,p],center:[(h.x-l)*o,(h.y-c)*o],scale:a/e.ag*o},r[i]}calculateFogTileMatrix(t){const i=t.key,r=this._fogTileMatrixCache;if(r[i])return r[i];const n=this.projection.createTileMatrix(this,this.cameraWorldSizeForFog,t);return e.ab.mat4.multiply(n,this.worldToFogMatrix,n),r[i]=new Float32Array(n),r[i]}calculateProjMatrix(t,i=!1,r=!1){const n=t.key;let o;if(o=r?this._expandedProjMatrixCache:i?this._alignedProjMatrixCache:this._projMatrixCache,o[n])return o[n];const s=this.calculatePosMatrix(t,this.worldSize);let a;return a=this.projection.isReprojectedInTileSpace?this.mercatorMatrix:r?this.expandedFarZProjMatrix:i?this.alignedProjMatrix:this.projMatrix,e.ab.mat4.multiply(s,a,s),o[n]=new Float32Array(s),o[n]}calculatePixelsToTileUnitsMatrix(t){const i=t.tileID.key,r=this._pixelsToTileUnitsCache;if(r[i])return r[i];const n=e.b_(t,this);return r[i]=n,r[i]}customLayerMatrix(){return this.mercatorMatrix.slice()}globeToMercatorMatrix(){if("globe"===this.projection.name){const t=1/this.worldSize,i=e.ab.mat4.fromScaling([],[t,t,t]);return e.ab.mat4.multiply(i,i,this.globeMatrix),i}}recenterOnTerrain(){if(!this._elevation||"globe"===this.projection.name)return;const t=this._elevation;this._updateCameraState();const i=e.bH(1,this._center.lat)*this.worldSize,r=this._computeCameraPosition(i),n=this._camera.forward(),o=e.bH(1,this._center.lat);r[2]/=o,n[2]/=o,e.ab.vec3.normalize(n,n);const s=t.raycast(r,n,t.exaggeration());if(s){const t=e.ab.vec3.scaleAndAdd([],r,n,s),i=new e.aa(t[0],t[1],e.bH(t[2],e.aS(t[1]))),a=(i.z+e.ab.vec3.length([i.x-r[0],i.y-r[1],i.z-r[2]*o]))*this._pixelsPerMercatorPixel;this._seaLevelZoom=this._zoomFromMercatorZ(a),this._centerAltitude=i.toAltitude(),this._center=this.coordinateLocation(i),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCamera(t=!1){if(!this._elevation)return;const i=this._elevation,r=e.bH(1,this._center.lat)*this.worldSize,n=this._computeCameraPosition(r),o=i.getAtPointOrZero(new e.aa(...n)),s=this.pixelsPerMeter/this.worldSize*o,a=this._minimumHeightOverTerrain(),l=n[2]-s;if(l<=a)if(l<0||t){const t=this.locationCoordinate(this._center,this._centerAltitude),i=[n[0],n[1],t.z-n[2]],r=e.ab.vec3.length(i);i[2]-=(a-l)/this._pixelsPerMercatorPixel;const o=e.ab.vec3.length(i);if(0===o)return;e.ab.vec3.scale(i,i,r/o*this._pixelsPerMercatorPixel),this._camera.position=[n[0],n[1],t.z*this._pixelsPerMercatorPixel-i[2]],this._updateStateFromCamera()}else this._isCameraConstrained=!0}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const t="globe"===this.projection.name||this.mercatorFromTransition;if(this.projection.isReprojectedInTileSpace||t){const i=this.center;return i.lat=e.aw(i.lat,this.minLat,this.maxLat),(this.maxBounds||!this.renderWorldCopies&&!t)&&(i.lng=e.aw(i.lng,this.minLng,this.maxLng)),this.center=i,void(this._constraining=!1)}const i=this._unmodified,{x:r,y:n}=this.point;let o=0,s=r,a=n;const l=this.width/2,c=this.height/2,h=this.worldMinY*this.scale,u=this.worldMaxY*this.scale;if(n-c<h&&(a=h+c),n+c>u&&(a=u-c),u-h<this.height&&(o=Math.max(o,this.height/(u-h)),a=(u+h)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const e=this.worldMinX*this.scale,t=this.worldMaxX*this.scale,i=this.worldSize/2-(e+t)/2;s=(r+i+this.worldSize)%this.worldSize-i,s-l<e&&(s=e+l),s+l>t&&(s=t-l),t-e<this.width&&(o=Math.max(o,this.width/(t-e)),s=(t+e)/2)}s===r&&a===n||(this.center=this.unproject(new e.P(s,a))),o&&(this.zoom+=this.scaleZoom(o)),this._constrainCamera(),this._unmodified=i,this._constraining=!1}_minZoomForBounds(){let e=Math.max(0,this.scaleZoom(this.height/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(e=Math.max(e,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),e}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const t=this.centerOffset,i="globe"===this.projection.name,r=this.pixelsPerMeter;"globe"===this.projection.name&&(this._mercatorScaleRatio=e.bH(1,this.center.lat)/e.bH(1,e.c8));const n=e.b$(this.projection,this.zoom,this.width,this.height,1024);this._pixelsPerMercatorPixel=this.projection.pixelSpaceConversion(this.center.lat,this.worldSize,n),this.cameraToCenterDistance=.5/Math.tan(.5*this._fov)*this.height*this._pixelsPerMercatorPixel,this._updateCameraState(),this._farZ=this.projection.farthestPixelDistance(this),this._nearZ=this.height/50;const o="meters"===this.projection.zAxisUnit?r:1,s=this._camera.getWorldToCamera(this.worldSize,o);let a;const l=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);if(l[8]=2*-t.x/this.width,l[9]=2*t.y/this.height,this.isOrthographic){let e=.5*this.height/Math.tan(this._fov/2)*1*Math.tan(.5*this._fov),i=e*this.aspect,r=-i,n=-e;i-=t.x,r-=t.x,e+=t.y,n+=t.y,a=this._camera.getCameraToClipOrthographic(r,i,n,e,this._nearZ,this._farZ),((e,t,i,r)=>{for(let n=0;n<16;n++)e[n]=tr(t[n],i[n],r)})(a,a,l,ir(this.pitch>=15?1:this.pitch/15))}else a=l;const c=e.ab.mat4.mul([],l,s);let h=e.ab.mat4.mul([],a,s);if(this.projection.isReprojectedInTileSpace){const t=this.locationCoordinate(this.center),i=e.ab.mat4.identity([]);e.ab.mat4.translate(i,i,[t.x*this.worldSize,t.y*this.worldSize,0]),e.ab.mat4.multiply(i,i,e.c0(this)),e.ab.mat4.translate(i,i,[-t.x*this.worldSize,-t.y*this.worldSize,0]),e.ab.mat4.multiply(h,h,i),e.ab.mat4.multiply(c,c,i),this.inverseAdjustmentMatrix=e.c1(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=e.ab.mat4.scale([],h,[this.worldSize,this.worldSize,this.worldSize/o,1]),this.projMatrix=h,this.invProjMatrix=e.ab.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.ab.mat4.mul([],i,s)}else this.expandedFarZProjMatrix=this.projMatrix;const u=e.ab.mat4.invert([],a);this.frustumCorners=e.c2.fromInvProjectionMatrix(u,this.horizonLineFromTop(),this.height),this.cameraFrustum=e.bR.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!i);const d=new Float32Array(16);e.ab.mat4.identity(d),e.ab.mat4.scale(d,d,[1,-1,1]),e.ab.mat4.rotateX(d,d,this._pitch),e.ab.mat4.rotateZ(d,d,this.angle);const p=e.ab.mat4.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=e.ab.mat4.clone(p);const f=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;p[8]=2*-t.x/this.width,p[9]=2*(t.y+f)/this.height,this.skyboxMatrix=e.ab.mat4.multiply(d,p,d);const m=this.point,_=m.x,g=m.y,y=this.width%2/2,x=this.height%2/2,v=Math.cos(this.angle),b=Math.sin(this.angle),w=_-Math.round(_)+v*y+b*x,T=g-Math.round(g)+v*x+b*y,S=new Float64Array(h);if(e.ab.mat4.translate(S,S,[w>.5?w-1:w,T>.5?T-1:T,0]),this.alignedProjMatrix=S,h=e.ab.mat4.create(),e.ab.mat4.scale(h,h,[this.width/2,-this.height/2,1]),e.ab.mat4.translate(h,h,[1,-1,0]),this.labelPlaneMatrix=h,h=e.ab.mat4.create(),e.ab.mat4.scale(h,h,[1,-1,1]),e.ab.mat4.translate(h,h,[-1,-1,0]),e.ab.mat4.scale(h,h,[2/this.width,2/this.height,1]),this.glCoordMatrix=h,this.pixelMatrix=e.ab.mat4.multiply(new Float64Array(16),this.labelPlaneMatrix,c),this._calcFogMatrices(),this._distanceTileDataCache={},h=e.ab.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.c3(this);const t=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=e.ab.vec3.transformMat4(t,t,s),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,r=this._camera.position,n=1/this.height/this._pixelsPerMercatorPixel,o=[t,t,i];e.ab.vec3.scale(o,o,n),e.ab.vec3.scale(r,r,-1),e.ab.vec3.multiply(r,r,o);const s=e.ab.mat4.create();e.ab.mat4.translate(s,s,r),e.ab.mat4.scale(s,s,o),this.mercatorFogMatrix=s,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,i,n)}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),r=this.point,n=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return[r.x/this.worldSize-i[0]*n,r.y/this.worldSize-i[1]*n,e/this.worldSize*this._centerAltitude-i[2]*n]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(t){const i=this._maxCameraBoundsDistance()*Math.cos(this._pitch),r=this._camera.position[2],n=t[2];let o=1;this.projection.wrap&&(this.center=this.center.wrap()),n>0&&(o=Math.min((i-r)/n,1)),this._camera.position=e.ab.vec3.scaleAndAdd([],this._camera.position,t,o),this._updateStateFromCamera()}_updateStateFromCamera(){const t=this._camera.position,i=this._camera.forward(),{pitch:r,bearing:n}=this._camera.getPitchBearing(),o=e.bH(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,s=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.ai(this._maxPitch)),a=Math.max((t[2]-o)/Math.cos(r),s),l=this._zoomFromMercatorZ(a);e.ab.vec3.scaleAndAdd(t,t,i,a),this._pitch=e.aw(r,e.ai(this.minPitch),e.ai(this.maxPitch)),this.angle=e.bF(n,-Math.PI,Math.PI),this._setZoom(e.aw(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new e.aa(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,r=e.bY,n=0,o=1/0;for(;r-i>1e-6&&r>i;){const e=i+.5*(r-i),s=this.tileSize*Math.pow(2,e),a=this.getCameraToCenterDistance(this.projection,e,s),l=this.scaleZoom(a/(t*this.tileSize)),c=Math.abs(e-l);c<o&&(o=c,n=e),e<l?i=e:r=e}return n}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(e.w("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(t,i){const r=Math.min(t.x,i.x),n=Math.max(t.x,i.x),o=Math.min(t.y,i.y),s=Math.max(t.y,i.y);if(o<this.horizonLineFromTop(!1))return!0;if("mercator"!==this.projection.name)return!1;const a=[new e.P(r,o),new e.P(n,s),new e.P(r,s),new e.P(n,o)],l=this.renderWorldCopies?-3:0,c=this.renderWorldCopies?4:1;for(const e of a){const t=this.pointRayIntersection(e);if(t.t<0)return!0;const i=this.rayIntersectionCoordinate(t);if(i.x<l||i.y<0||i.x>c||i.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+e.c4(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.P(0,0),new e.P(this.width,this.height))}zoomDeltaToMovement(t,i){const r=e.ab.vec3.length(e.ab.vec3.sub([],this._camera.position,t)),n=this._zoomFromMercatorZ(r)+i;return r-this._mercatorZfromZoom(n)}getCameraPoint(){if("globe"===this.projection.name){const t=function([t,i,r],n){const o=[t,i,r,1];e.ab.vec4.transformMat4(o,o,n);const s=o[3]=Math.max(o[3],1e-6);return o[0]/=s,o[1]/=s,o[2]/=s,o}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new e.P(t[0],t[1])}{const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.P(0,t))}}getCameraToCenterDistance(t,i=this.zoom,r=this.worldSize){const n=e.b$(t,i,this.width,this.height,1024),o=t.pixelSpaceConversion(this.center.lat,r,n);let s=.5/Math.tan(.5*this._fov)*this.height*o;return this.isOrthographic&&(s=tr(1,s,ir(this.pitch>=15?1:this.pitch/15))),s}getWorldToCameraMatrix(){const t=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return"globe"===this.projection.name&&e.ab.mat4.multiply(t,t,this.globeMatrix),t}getFrustum(t){return e.bR.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,"meters"===this.projection.zAxisUnit)}}const nr=(t,i)=>{if(i>0&&t.terrain&&e.w("Cutoff is currently disabled on terrain"),i<=0||t.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const r=t.transform,n=Math.max(Math.abs(r._zoom-(t.minCutoffZoom-1)),1),o=r.isLODDisabled(!1)?e.ac(60,45,r.pitch):e.ac(30,15,r.pitch),s=r._farZ-r._nearZ,a=i*r.height,l=((1-(c=o))*r.cameraToCenterDistance+c*(r._farZ+a))*n;var c;return{shouldRenderCutoff:o<1,uniformValues:{u_cutoff_params:[r._nearZ,r._farZ,(l-r._nearZ)/s,(l-a-r._nearZ)/s]}}},or={cascadeCount:2,normalOffset:3,shadowMapResolution:2048};class sr{constructor(e,t){this.aabb=e,this.lastCascade=t}}class ar{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 sr(t,null)}clear(){this.receivers={}}get(e){return this.receivers[e.key]}computeRequiredCascades(t,i,r){const n=e.cd.fromPoints(t.points);let o=0;for(const t in this.receivers){const s=this.receivers[t];if(!s)continue;if(!n.intersectsAabb(s.aabb))continue;s.aabb.min=n.closestPoint(s.aabb.min),s.aabb.max=n.closestPoint(s.aabb.max);const a=s.aabb.getCorners();for(let t=0;t<r.length;t++){let n=!0;for(const o of a){const s=[o[0]*i,o[1]*i,o[2]];if(e.ab.vec3.transformMat4(s,s,r[t].matrix),s[0]<-1||s[0]>1||s[1]<-1||s[1]>1){n=!1;break}}if(s.lastCascade=t,o=Math.max(o,t),n)break}}return o+1}}class lr{constructor(e){this.painter=e,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new ar,this._depthMode=new ki(e.context.gl.LEQUAL,ki.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(or,["Shadows"],"cascadeCount",{min:1,max:2,step:1}),e.tp.registerParameter(or,["Shadows"],"normalOffset",{min:0,max:10,step:.05}),e.tp.registerParameter(or,["Shadows"],"shadowMapResolution",{min:32,max:2048,step:32}),e.tp.registerBinding(this,["Shadows"],"_numCascadesToRender",{readonly:!0,label:"numCascadesToRender"})}destroy(){for(const e of this._cascades)e.texture.destroy(),e.framebuffer.destroy();this._cascades=[]}updateShadowParameters(t,i){const r=this.painter;if(this._enabled=!1,this._shadowLayerCount=0,this._receivers.clear(),!i||!i.properties)return;const n=i.properties.get("shadow-intensity");if(!i.shadowsEnabled()||n<=0)return;if(this._shadowLayerCount=r.style.order.reduce(((e,i)=>{const n=r.style._mergedLayers[i];return e+(n.hasShadowPass()&&!n.isHidden(t.zoom)?1:0)}),0),this._enabled=this._shadowLayerCount>0,!this.enabled)return;const o=r.context,s=or.shadowMapResolution,a=or.shadowMapResolution;if(0===this._cascades.length||or.shadowMapResolution!==this._cascades[0].texture.size[0]){this._cascades=[];for(let t=0;t<or.cascadeCount;++t){const t=r._shadowMapDebug,i=o.gl,n=o.createFramebuffer(s,a,t,"texture"),l=new e.T(o,{width:s,height:a,data:null},i.DEPTH_COMPONENT16);if(n.depthAttachment.set(l.texture),t){const t=new e.T(o,{width:s,height:a,data:null},i.RGBA8);n.colorAttachment.set(t.texture)}this._cascades.push({framebuffer:n,texture:l,matrix:[],far:0,boundingSphereRadius:0,frustum:new e.bR,scale:0})}}this.shadowDirection=hr(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<this._cascades.length;++i){const r=this._cascades[i];let n=t.height/50,o=1;1===or.cascadeCount?o=h:0===i?o=c:(n=c,o=h);const[s,a]=dr(t,this.shadowDirection,n,o,or.shadowMapResolution,l);r.scale=t.scale,r.matrix=s,r.boundingSphereRadius=a,e.ab.mat4.invert(u,r.matrix),r.frustum=e.bR.fromInvProjectionMatrix(u,1,0,!0),r.far=o}const d=this._cascades.length-1;this._uniformValues.u_fade_range=[.75*this._cascades[d].far,this._cascades[d].far],this._uniformValues.u_shadow_intensity=n,this._uniformValues.u_shadow_direction=[this.shadowDirection[0],this.shadowDirection[1],this.shadowDirection[2]],this._uniformValues.u_shadow_texel_size=1/or.shadowMapResolution,this._uniformValues.u_shadow_map_resolution=or.shadowMapResolution,this._uniformValues.u_shadowmap_0=Qi,this._uniformValues.u_shadowmap_1=Qi+1,this._groundShadowTiles=r.transform.coveringTiles({tileSize:512,renderWorldCopies:!0});const p=r.transform.elevation;for(const e of this._groundShadowTiles){let t={min:0,max:0};if(p){const i=p.getMinMaxForTile(e);i&&(t=i)}this.addShadowReceiver(e.toUnwrapped(),t.min,t.max)}}get enabled(){return this._enabled&&!this._forceDisable}set enabled(e){this._enabled=e}drawShadowPass(t,i){if(!this.enabled)return;const r=this.painter,n=r.context;this._numCascadesToRender=this._receivers.computeRequiredCascades(r.transform.getFrustum(0),r.transform.worldSize,this._cascades),n.viewport.set([0,0,or.shadowMapResolution,or.shadowMapResolution]);for(let o=0;o<this._numCascadesToRender;++o){r.currentShadowCascade=o,n.bindFramebuffer.set(this._cascades[o].framebuffer.framebuffer),n.clear({color:e.aj.white,depth:1});for(const e of t.order){const n=t._mergedLayers[e];if(!n.hasShadowPass()||n.isHidden(r.transform.zoom))continue;const o=t.getLayerSourceCache(n),s=o?i[o.id]:void 0;("model"===n.type||s&&s.length)&&r.renderLayer(r,o,n,s)}}r.currentShadowCascade=0}drawGroundShadows(){if(!this.enabled)return;const e=this.painter,t=e.style,i=e.context,r=t.directionalLight,n=t.ambientLight;if(!r||!n)return;const o=[],s=nr(e,e.longestCutoffRange);s.shouldRenderCutoff&&o.push("RENDER_CUTOFF"),o.push("RENDER_SHADOWS","DEPTH_TEXTURE"),this.useNormalOffset&&o.push("NORMAL_OFFSET");const a=ur(t,r,n),l=new ki(i.gl.LEQUAL,ki.ReadOnly,e.depthRangeFor3D);for(const t of this._groundShadowTiles){const r=t.toUnwrapped(),n=e.isTileAffectedByFog(t),c=e.getOrCreateProgram("groundShadow",{defines:o,overrideFog:n});this.setupShadows(r,c),e.uploadCommonUniforms(i,c,r,null,s);const h={u_matrix:e.transform.calculateProjMatrix(r),u_ground_shadow_factor:a};c.draw(e,i.gl.TRIANGLES,l,Bi.disabled,Oi.multiply,Ui.disabled,h,"ground_shadow",e.tileExtentBuffer,e.quadTriangleIndexBuffer,e.tileExtentSegments,{},e.transform.zoom,null,null)}}getShadowPassColorMode(){return this.painter._shadowMapDebug?Oi.unblended:Oi.disabled}getShadowPassDepthMode(){return this._depthMode}getShadowCastingLayerCount(){return this._shadowLayerCount}calculateShadowPassMatrixFromTile(t){const i=this.painter.transform,r=i.calculatePosMatrix(t,i.worldSize);return e.ab.mat4.multiply(r,this._cascades[this.painter.currentShadowCascade].matrix,r),Float32Array.from(r)}calculateShadowPassMatrixFromMatrix(t){return e.ab.mat4.multiply(t,this._cascades[this.painter.currentShadowCascade].matrix,t),Float32Array.from(t)}setupShadows(t,i,r,n=0){if(!this.enabled)return;const o=this.painter.transform,s=this.painter.context,a=s.gl,l=this._uniformValues,c=new Float64Array(16),h=o.calculatePosMatrix(t,o.worldSize);for(let t=0;t<this._cascades.length;t++)e.ab.mat4.multiply(c,this._cascades[t].matrix,h),l[0===t?"u_light_matrix_0":"u_light_matrix_1"]=Float32Array.from(c),s.activeTexture.set(a.TEXTURE0+Qi+t),this._cascades[t].texture.bind(a.NEAREST,a.CLAMP_TO_EDGE);if(this.useNormalOffset=!!r,this.useNormalOffset){const i=e.cc(t.canonical),s=2/o.tileSize*e.ag/or.shadowMapResolution,a=s*this._cascades[0].boundingSphereRadius,c=s*this._cascades[this._cascades.length-1].boundingSphereRadius,h=("vector-tile"===r?1:3)/Math.pow(2,n-t.canonical.z-(1-o.zoom+Math.floor(o.zoom)));l.u_shadow_normal_offset=[i,a*h,c*h],l.u_shadow_bias=[6e-5,.0012,.012]}else l.u_shadow_bias=[36e-5,.0012,.012];i.setShadowUniformValues(s,l)}setupShadowsFromMatrix(t,i,r=!1){if(!this.enabled)return;const n=this.painter.context,o=n.gl,s=this._uniformValues,a=new Float64Array(16);for(let i=0;i<or.cascadeCount;i++)e.ab.mat4.multiply(a,this._cascades[i].matrix,t),s[0===i?"u_light_matrix_0":"u_light_matrix_1"]=Float32Array.from(a),n.activeTexture.set(o.TEXTURE0+Qi+i),this._cascades[i].texture.bind(o.NEAREST,o.CLAMP_TO_EDGE);if(this.useNormalOffset=r,r){const e=or.normalOffset;s.u_shadow_normal_offset=[1,e,e],s.u_shadow_bias=[6e-5,.0012,.012]}else s.u_shadow_bias=[36e-5,.0012,.012];i.setShadowUniformValues(n,s)}getShadowUniformValues(){return this._uniformValues}getCurrentCascadeFrustum(){return this._cascades[this.painter.currentShadowCascade].frustum}computeSimplifiedTileShadowVolume(t,i,r,n){if(n[2]>=0)return{};const o=function(t,i,r){const n=r/(1<<t.canonical.z);return new e.cd([t.canonical.x*n+t.wrap*r,t.canonical.y*n+t.wrap*r,0],[(t.canonical.x+1)*n+t.wrap*r,(t.canonical.y+1)*n+t.wrap*r,i])}(t,i,r).getCorners(),s=i/-n[2];n[0]<0?(e.ab.vec3.add(o[0],o[0],[n[0]*s,0,0]),e.ab.vec3.add(o[3],o[3],[n[0]*s,0,0])):n[0]>0&&(e.ab.vec3.add(o[1],o[1],[n[0]*s,0,0]),e.ab.vec3.add(o[2],o[2],[n[0]*s,0,0])),n[1]<0?(e.ab.vec3.add(o[0],o[0],[0,n[1]*s,0]),e.ab.vec3.add(o[1],o[1],[0,n[1]*s,0])):n[1]>0&&(e.ab.vec3.add(o[2],o[2],[0,n[1]*s,0]),e.ab.vec3.add(o[3],o[3],[0,n[1]*s,0]));const a={};return a.vertices=o,a.planes=[cr(o[1],o[0],o[4]),cr(o[2],o[1],o[5]),cr(o[3],o[2],o[6]),cr(o[0],o[3],o[7])],a}addShadowReceiver(t,i,r){this._receivers.add(t,e.cd.fromTileIdAndHeight(t,i,r))}getMaxCascadeForTile(e){const t=this._receivers.get(e);return t&&t.lastCascade?t.lastCascade:0}}function cr(t,i,r){const n=e.ab.vec3.sub([],r,i),o=e.ab.vec3.sub([],t,i),s=e.ab.vec3.cross([],n,o),a=e.ab.vec3.length(s);return 0===a?[0,0,1,0]:(e.ab.vec3.scale(s,s,1/a),[s[0],s[1],s[2],-e.ab.vec3.dot(s,i)])}function hr(t){const i=t.properties.get("direction"),r=e.cb(i.x,i.y,i.z);r[2]=e.aw(r[2],0,75);const n=e.ce([r[0],r[1],r[2]]);return e.ab.vec3.fromValues(n.x,n.y,n.z)}function ur(t,i,r){const n="none"===i.properties.get("color-use-theme"),o=i.properties.get("color"),s=i.properties.get("intensity"),a=i.properties.get("direction"),l=[a.x,a.y,a.z],c="none"===r.properties.get("color-use-theme"),h=r.properties.get("color"),u=r.properties.get("intensity"),d=Math.max(e.ab.vec3.dot([0,0,1],l),0),p=[0,0,0];e.ab.vec3.scale(p,h.toRenderColor(c?null:t.getLut(i.scope)).toArray01Linear().slice(0,3),u);const f=[0,0,0];return e.ab.vec3.scale(f,o.toRenderColor(n?null:t.getLut(r.scope)).toArray01Linear().slice(0,3),d*s),e.cf([p[0]>0?p[0]/(p[0]+f[0]):0,p[1]>0?p[1]/(p[1]+f[1]):0,p[2]>0?p[2]/(p[2]+f[2]):0])}function dr(t,i,r,n,o,s){const a=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),p=d*d,f=n-r,m=n+r;let _,g;p>f/m?(_=n,g=n*d):(_=.5*m*(1+p),g=.5*Math.sqrt(f*f+2*(n*n+r*r)*p+m*m*p*p));const y=t.projection.pixelsPerMeter(t.center.lat,c),x=t._camera.getCameraToWorldMercator(),v=[0,0,-_*h];e.ab.vec3.transformMat4(v,v,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?y:1),o=t._camera.getCameraToClipPerspective(t._fov,t.width/t.height,r,n);o[8]=2*-t.centerOffset.x/t.width,o[9]=2*t.centerOffset.y/t.height;const s=new Float64Array(16);e.ab.mat4.mul(s,o,i);const h=new Float64Array(16);e.ab.mat4.invert(h,s);const u=e.bR.fromInvProjectionMatrix(h,c,a,!0);for(const i of u.points){const r=((T=i)[0]/=l,T[1]/=l,T[2]=e.bH(T[2],t._center.lat),T);b=Math.max(b,e.ab.vec3.len(e.ab.vec3.subtract([],v,r)))}}var T;b*=o/(o-1);const S=Math.acos(i[2]),M=Math.atan2(-i[0],-i[1]),E=new $i;E.position=v,E.setPitchBearing(S,M);const A=E.getWorldToCamera(c,y),I=b*c,C=Math.min(t._mercatorZfromZoom(17)*c*-2,-2*I),P=E.getCameraToClipOrthographic(-I,I,-I,I,C,(I+s*y)/i[2]),z=new Float64Array(16);e.ab.mat4.multiply(z,P,A);const D=e.ab.vec3.fromValues(Math.floor(1e6*v[0])/1e6*c,Math.floor(1e6*v[1])/1e6*c,0),R=.5*o,L=[0,0,0];e.ab.vec3.transformMat4(L,D,z),e.ab.vec3.scale(L,L,R);const O=[Math.floor(L[0]),Math.floor(L[1]),Math.floor(L[2])],k=[0,0,0];e.ab.vec3.sub(k,L,O),e.ab.vec3.scale(k,k,-1/R);const F=new Float64Array(16);return e.ab.mat4.identity(F),e.ab.mat4.translate(F,F,k),e.ab.mat4.multiply(z,F,z),[z,I]}class pr extends e.E{constructor(e){super(),this.requestManager=e,this.models={"":{}},this.numModelsLoading={}}loadModel(t,i){return e.aM(this.requestManager.transformRequest(i,e.R.Model).url).then((i=>{if(!i)return;const r=e.aN(i),n=new e.aO(t,void 0,void 0,r);return n.computeBoundsAndApplyParent(),n})).catch((r=>{if(r&&404===r.status)return null;this.fire(new e.y(new Error(`Could not load model ${t} from ${i}: ${r.message}`)))}))}load(t,i){this.models[i]||(this.models[i]={});const r=Object.keys(t);this.numModelsLoading[i]=(this.numModelsLoading[i]||0)+r.length;const n=[];for(const e of r)n.push(this.loadModel(e,t[e]));Promise.allSettled(n).then((t=>{for(let e=0;e<t.length;e++){const{status:n,value:o}=t[e];"fulfilled"===n&&o&&(this.models[i][r[e]]={model:o,numReferences:1})}this.numModelsLoading[i]-=r.length,this.fire(new e.z("data",{dataType:"style"}))})).catch((t=>{this.fire(new e.y(new Error(`Could not load models: ${t.message}`)))}))}isLoaded(){for(const e in this.numModelsLoading)if(this.numModelsLoading[e]>0)return!1;return!0}hasModel(e,t){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 r in e)this.models[t][r]={},i[r]=this.requestManager.normalizeModelURL(e[r]);this.load(i,t)}addModelsFromBucket(e,t){this.models[t]||(this.models[t]={});const i={};for(const r of e)this.hasModel(r,t)?this.models[t][r].numReferences++:i[r]=this.requestManager.normalizeModelURL(r);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 fr=new e.a5({data:new e.a6(e.a3.colorTheme.data)}),mr={"mbx-indoor-active-floorplans":{default:["literal",[]]},"mbx-indoor-underground":{default:["literal",!1]},"mbx-indoor-loaded-levels":{default:["literal",[]]},"mbx-indoor-level-height":{default:["literal",{}]},"mbx-indoor-level-base":{default:["literal",{}]},"mbx-indoor-level-selected":{default:["literal",{}]},"mbx-indoor-level-overlapped":{default:["literal",{}]}};function _r(e){return e=e||{},Object.assign(e,mr)}class gr extends e.E{constructor(t){super(),this.mergeFloors=!0,this._scope=void 0,this._queryFeatureSetId=void 0,this._buildingEntryFeatureSetId=void 0,this._selectedFloorplan=void 0,this._indoorData=void 0,this._selectedLevel=void 0,this._floorplanStates={},e.aP(["_onLoad","_onMove","_checkFloorplanVisible"],this),this._map=t,this._checkFloorplanVisible(!0),this._map.on("load",this._onLoad),this._map.on("move",this._onMove)}destroy(){this._map.indoor.off("load",this._onLoad),this._map.indoor.off("move",this._onMove),this._map=void 0}_onLoad(){this._map.style.forEachFragmentStyle((t=>{t.stylesheet.indoor&&(this._queryFeatureSetId?this.fire(new e.y(new Error("Multiple indoor map styles detected, simultaneous usage is not allowed currently."))):(this._queryFeatureSetId=t.stylesheet.indoor.floorplanFeaturesetId,this._buildingEntryFeatureSetId=t.stylesheet.indoor.buildingFeaturesetId,this._scope=t.scope))})),this._queryFeatureSetId&&this._buildingEntryFeatureSetId&&this._map.addInteraction("mbx-indoor-buildingclick",{type:"click",target:{featuresetId:this._buildingEntryFeatureSetId,importId:this._scope},handler:e=>(e.feature&&e.feature.properties.floorplan&&this.selectFloorplan(e.feature.properties.floorplan),!0)}),this._checkFloorplanVisible(!0)}_onMove(){this._checkFloorplanVisible(!1)}_checkFloorplanVisible(t){if(!this._queryFeatureSetId)return;if(!this._map.isStyleLoaded())return;if(this._map.transform.zoom<13)return;this._indoorData&&!function(e,t){const[i,r]=e,{center:n,radius:o}=t,[s,a]=n,l=Math.abs(i-s);return Math.sqrt((l>180?360-l:l)**2+(r-a)**2)<=o}([this._map.getCenter().lng,this._map.getCenter().lat],this._indoorData.circumCircle)&&(this._indoorData=void 0,this._selectedFloorplan=void 0,this._map.setConfigProperty(this._scope,"mbx-indoor-underground",!1),this._map.setConfigProperty(this._scope,"mbx-indoor-active-floorplans",["literal",[]]),this.fire(new e.z("floorplangone")));const i={target:{featuresetId:this._queryFeatureSetId,importId:this._scope}},r=new e.P(this._map.transform.width/2,this._map.transform.height/2),n=[new e.P(0,0),new e.P(this._map.transform.width,this._map.transform.height)],o=this._map.queryRenderedFeatures(t?n:r,i);o.length>0&&(this._selectedFloorplan&&o[0].properties.id===this._selectedFloorplan.properties.id||(this._selectedFloorplan=o[0],this._floorplanSelected(!1)))}_floorplanSelected(t){this._indoorData=JSON.parse(this._selectedFloorplan.properties["indoor-data"]),this._indoorData.id=this._selectedFloorplan.properties.id,this._indoorData.circumCircle=function(e){const[[t,i],[r,n]]=e,o=(r-t+360)%360,s=o>180?360-o:o;return{center:[(t+s/2+360)%360,(i+n)/2],radius:Math.sqrt(s**2+(n-i)**2)/2}}(this._indoorData.extent),this._floorplanStates[this._indoorData.id]||(this._floorplanStates[this._indoorData.id]={});const i=this._floorplanStates[this._indoorData.id].selectedBuilding,r=this._floorplanStates[this._indoorData.id].selectedLevel;let n;if(this._map.setConfigProperty(this._scope,"mbx-indoor-active-floorplans",this._indoorData.floorplanIDs),this._selectedLevel)for(const e of this._indoorData.levels)e.id===this._selectedLevel.id&&(n=e.id);if(this.fire(new e.z("floorplanselected",{buildings:this._indoorData.buildings,levels:this._indoorData.levels,selectedLevelId:n})),i){const e=this._indoorData.buildings.find((e=>e.id===i));this._buildingSelected(e,!1)}else this._indoorData.buildings.length>0&&this._buildingSelected(this._indoorData.buildings[0],!1);if(r){const e=this._indoorData.levels.find((e=>e.id===r));this._updateLevels(e,t)}else t&&this._indoorData["default-levels"].length>0&&this.selectLevel(this._indoorData["default-levels"][0])}_buildingSelected(t,i){i&&t&&t.extent&&this._map.fitBounds(t.extent,{pitch:this._map.getPitch(),bearing:this._map.getBearing()}),this._floorplanStates[this._indoorData.id].selectedBuilding=t?t.id:void 0;const r=this._indoorData.levels.filter((e=>t.levels.includes(e.id)));this.fire(new e.z("buildingselected",{buildingId:t.id,levels:r}))}_levelSelected(t){if("overview"===t)this._updateLevels(void 0,!0);else{const e=this._indoorData.levels.find((e=>e.id===t));this._updateLevels(e,!0)}this.fire(new e.z("levelselected",{levelId:"overview"===t?void 0:t}))}_updateLevels(e,t){if(!e)return this._map.setConfigProperty(this._scope,"mbx-indoor-loaded-levels",["literal",[]]),this._map.setConfigProperty(this._scope,"mbx-indoor-underground",!1),this._floorplanStates[this._indoorData.id].selectedLevel=void 0,void(t&&this._indoorData.extent&&this._map.fitBounds(this._indoorData.extent,{pitch:this._map.getPitch(),bearing:this._map.getBearing()}));function i(e){const t=e.indexOf("/floor/");if(-1===t)return e;const i=t+7,r=e.indexOf("/",i);return-1===r?e.slice(i):e.slice(i,r)}this._selectedLevel=e,this._floorplanStates[this._indoorData.id].selectedLevel=e?e.id:void 0;const r=[],n={},o={},s={},a={};for(const t of this._indoorData.levels)if(r.push(t.id),n[t.id]=t.height,o[t.id]=t.base,e){if(this.mergeFloors){const r=i(e.id),n=i(t.id);s[t.id]=n===r?"true":"false"}else s[t.id]=t.id===e.id?"true":"false";a[t.id]=t.base<e.base?"true":"false"}else a[t.id]=!0;if(this._map.setConfigProperty(this._scope,"mbx-indoor-loaded-levels",["literal",r]),this._map.setConfigProperty(this._scope,"mbx-indoor-level-height",["literal",n]),this._map.setConfigProperty(this._scope,"mbx-indoor-level-base",["literal",o]),this._map.setConfigProperty(this._scope,"mbx-indoor-level-selected",["literal",s]),this._map.setConfigProperty(this._scope,"mbx-indoor-level-overlapped",["literal",a]),e&&(this._map.setConfigProperty(this._scope,"mbx-indoor-underground",!!e.isUnderground),t&&e.extent)){const t=this._map.cameraForBounds(e.extent,{pitch:this._map.getPitch(),bearing:this._map.getBearing()}),i=this._map.getZoom(),r=t.zoom?Math.abs(i-t.zoom):0;this._map.fitBounds(e.extent,r>=1?{pitch:this._map.getPitch(),bearing:this._map.getBearing()}:{pitch:this._map.getPitch(),bearing:this._map.getBearing(),zoom:i})}}selectFloorplan(t){const i={target:{featuresetId:this._queryFeatureSetId,importId:this._scope}},r=[new e.P(0,0),new e.P(this._map.transform.width,this._map.transform.height)],n=this._map.queryRenderedFeatures(r,i);if(n.length>0)for(const e of n)if(JSON.parse(e.properties["indoor-data"]).floorplanIDs.includes(t)){this._selectedFloorplan=e,this._floorplanSelected(!0);break}}selectBuilding(e){const t=this._indoorData.buildings.find((t=>t.id===e));this._buildingSelected(t,!0)}selectLevel(e){this._levelSelected(e)}}function yr(e){if(!e.metadata||!e.metadata.content_area)return;const{left:t,top:i,width:r,height:n}=e.metadata.content_area;return[t,i,t+r,i+n]}const xr=(e,t)=>Pe(e,t&&t.filter((e=>"source.canvas"!==e.identifier))),vr=e.ay(It,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setSnow","setRain","setProjection","setCamera","addImport","removeImport","updateImport"]),br=e.ay(It,["setCenter","setZoom","setBearing","setPitch"]),wr=new Set(["background","sky","slot","custom"]),Tr={version:8,layers:[],sources:{}},Sr={duration:300,delay:0};class Mr 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({},Sr),this._buildingIndex=new Mt(this),this.crossTileSymbolIndex=new Ri,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.D(e.ci(),this),i.imageManager?this.imageManager=i.imageManager:(this.imageManager=new q(this.map._spriteFormat),this.imageManager.setEventedParent(this)),this.imageManager.createScope(this.scope),this.glyphManager=i.glyphManager?i.glyphManager:new e.cj(t._requestManager,i.localFontFamily?e.ck.all:i.localIdeographFontFamily?e.ck.ideographs:e.ck.none,i.localFontFamily||i.localIdeographFontFamily),i.modelManager?this.modelManager=i.modelManager:(this.modelManager=new pr(t._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._precompileDone=!1,this._shouldPrecompile=!1,this._availableImages=[],this._order=[],this._markersNeedUpdate=!1,this.options=i.configOptions?i.configOptions:new Map,this._configDependentLayers=i.configDependentLayers?i.configDependentLayers:new Set,this._config=i.config,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null,colorThemeOverride:i.colorThemeOverride},this._styleColorThemeForScope={},this._initialConfig=i.initialConfig,this.dispatcher.broadcast("setReferrer",e.cl());const r=this;this._rtlTextPluginCallback=Mr.registerForPluginStateChange((t=>{r.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},((t,i)=>{if(e.cm(t),i&&i.every((e=>e)))for(const e in r._sourceCaches){const t=r._sourceCaches[e],i=t.getSource().type;"vector"!==i&&"geojson"!==i||t.reload()}}))})),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.getOwnSource(e.sourceId);if(t&&t.vectorLayerIds)for(const e in this._layers){const i=this._layers[e];i.source===t.id&&this._validateLayer(i)}}))}load(e){return e?("string"==typeof e?this.loadURL(e):this.loadJSON(e),this):this}_getGlobalId(t){if(!t)return null;if("string"==typeof t){if(e.f(t))return t;const i=e.cn(t);if(!i.startsWith("http"))try{return new URL(i,location.href).toString()}catch(e){return i}return i}return`json://${e.co(JSON.stringify(t))}`}_diffStyle(t,i,r){this.globalId=this._getGlobalId(t);const n=(e,t)=>{try{t(null,this.setState(e,r))}catch(e){t(e,!1)}};if("string"==typeof t){const r=this.map._requestManager.normalizeStyleURL(t),o=this.map._requestManager.transformRequest(r,e.R.Style);e.n(o,((t,r)=>{t?this.fire(new e.y(t)):r&&n(r,i)}))}else"object"==typeof t&&n(t,i)}loadURL(t,i={}){this.fire(new e.z("dataloading",{dataType:"style"}));const r="boolean"==typeof i.validate?i.validate:!e.f(t);this.globalId=this._getGlobalId(t),t=this.map._requestManager.normalizeStyleURL(t,i.accessToken),this.resolvedImports.add(t);const n=this.importsCache.get(t);if(n)return this._load(n,r);const o=this.map._requestManager.transformRequest(t,e.R.Style);this._request=e.n(o,((i,n)=>{if(this._request=null,i)this.fire(new e.y(i));else if(n)return this.importsCache.set(t,n),this._load(n,r)}))}loadJSON(t,i={}){this.fire(new e.z("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(t),this._request=e.q.frame((()=>{this._request=null,this._load(t,!1!==i.validate)}))}loadEmpty(){this.fire(new e.z("dataloading",{dataType:"style"})),this._load(Tr,!1)}_loadImports(t,i,r){if(this.importDepth>=4)return e.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const n=[];for(const e of t){const t=this._createFragmentStyle(e),o=new Promise((e=>{t.once("style.import.load",e),t.once("error",e)})).then((()=>this.mergeAll()));if(n.push(o),this.resolvedImports.has(e.url)){t.loadEmpty();continue}const s=e.data||this.importsCache.get(e.url);s?(t.loadJSON(s,{validate:i}),this._isInternalStyle(s)&&(t.globalId=null)):e.url?t.loadURL(e.url,{validate:i}):t.loadEmpty();const a={style:t,id:e.id,config:e.config};if(r){const e=this.fragments.findIndex((({id:e})=>e===r));this.fragments=this.fragments.slice(0,e).concat(a).concat(this.fragments.slice(e))}else this.fragments.push(a)}return Promise.allSettled(n)}getImportGlobalIds(e=this,t=new Set){for(const i of e.fragments)i.style.globalId&&t.add(i.style.globalId),this.getImportGlobalIds(i.style,t);return[...t.values()]}_createFragmentStyle(t){const i=this.scope?e.aC(t.id,this.scope):t.id;let r;const n=this._initialConfig&&this._initialConfig[i];(t.config||n)&&(r=e.l({},t.config,n));const o=new Mr(this.map,{scope:i,styleChanges:this._changes,importDepth:this.importDepth+1,importsCache:this.importsCache,resolvedImports:new Set(this.resolvedImports),dispatcher:this.dispatcher,imageManager:this.imageManager,glyphManager:this.glyphManager,modelManager:this.modelManager,config:r,configOptions:this.options,colorThemeOverride:t["color-theme"],configDependentLayers:this._configDependentLayers});return o.setEventedParent(this.map,{style:o}),o}_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 r=t.indoor?_r(t.schema):t.schema;if(this._isInternalStyle(t)){const r=e.l({},Tr,{imports:[{id:"basemap",data:t,url:""}]});return void this._load(r,i)}if(this.updateConfig(this._config,r),i&&xr(this,_e(t)))return;this._loaded=!0,this.stylesheet=e.cp(t);const n=()=>{for(const e in t.sources)this.addSource(e,t.sources[e],{validate:!1,isInitialLoad:!0});t.sprite?this._loadIconset(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 r=At(this.stylesheet.layers);if(this._order=r.map((e=>e.id)),this.stylesheet.light&&e.w("The `light` root property is deprecated, prefer using `lights` with `flat` light type instead."),this.stylesheet.lights)if(1===this.stylesheet.lights.length&&"flat"===this.stylesheet.lights[0].type){const e=this.stylesheet.lights[0];this.light=new De(e.properties,e.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new De(this.stylesheet.light)),this._layers={};for(const t of r){const i=e.cu(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;const r=this.getOwnLayerSourceCache(i),n=!!this.directionalLight&&this.directionalLight.shadowsEnabled();r&&i.canCastShadows()&&n&&(r.castsShadows=!0)}this.stylesheet.featuresets&&this.setFeaturesetSelectors(this.stylesheet.featuresets),this.stylesheet.models&&this.modelManager.addModels(this.stylesheet.models,this.scope);const n=this.stylesheet.terrain;n&&(this.checkCanvasFingerprintNoise(),this.disableElevatedTerrain||this.terrainSetForDrapingOnly()||this._createTerrain(n,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.snow&&this._createSnow(this.stylesheet.snow),this.stylesheet.rain&&this._createRain(this.stylesheet.rain),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new e.z("data",{dataType:"style"}));const o=this.isRootStyle();t.imports?this._loadImports(t.imports,i).then((()=>{this._reloadImports(),this.fire(new e.z(o?"style.load":"style.import.load"))})):(this._reloadImports(),this.fire(new e.z(o?"style.load":"style.import.load")))};this._styleColorTheme.colorTheme=this.stylesheet["color-theme"];const o=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(o){const t=this._evaluateColorThemeData(o);this._loadColorTheme(t).then((()=>{n()})).catch((t=>{e.w(`Couldn't load color theme from the stylesheet: ${t}`),n()}))}else this._styleColorTheme.lut=null,n()}isRootStyle(){return 0===this.importDepth}mergeAll(){let t,i,r,n,o,s,a,l,c,h;const u={};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&&(r=e.directionalLight);n=this._prioritizeTerrain(n,e.terrain,e.stylesheet.terrain),e.stylesheet.fog&&null!=e.fog&&(o=e.fog),e.stylesheet.snow&&null!=e.snow&&(s=e.snow),e.stylesheet.rain&&null!=e.rain&&(a=e.rain),null!=e.stylesheet.camera&&(h=e.stylesheet.camera),null!=e.stylesheet.projection&&(l=e.stylesheet.projection),null!=e.stylesheet.transition&&(c=e.stylesheet.transition),u[e.scope]=e._styleColorTheme}})),this.light=t,this.ambientLight=i,this.directionalLight=r,this.fog=o,this.snow=s,this.rain=a,this._styleColorThemeForScope=u,null===n?delete this.terrain:this.terrain=n,this.camera=h||{"camera-projection":"perspective"},this.projection=l||{name:"mercator"},this.transition=e.l({},Sr,c),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 r=e&&0===e.drapeRenderMode;return null===i?t&&0===t.drapeRenderMode?t:r?e:null:null!=t&&(!e||r||t&&1===t.drapeRenderMode)?t:e}mergeTerrain(){let e;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle((t=>{e=this._prioritizeTerrain(e,t.terrain,t.stylesheet.terrain)})),null===e?delete this.terrain:this.terrain=e}mergeProjection(){let e;this.forEachFragmentStyle((t=>{null!=t.stylesheet.projection&&(e=t.stylesheet.projection)})),this.projection=e||{name:"mercator"}}mergeSources(){const t={},i={},r={};this.forEachFragmentStyle((n=>{for(const i in n._sourceCaches){const r=e.aC(i,n.scope);t[r]=n._sourceCaches[i]}for(const t in n._otherSourceCaches){const r=e.aC(t,n.scope);i[r]=n._otherSourceCaches[t]}for(const t in n._symbolSourceCaches){const i=e.aC(t,n.scope);r[i]=n._symbolSourceCaches[t]}})),this._mergedSourceCaches=t,this._mergedOtherSourceCaches=i,this._mergedSymbolSourceCaches=r}mergeLayers(){const t={},i=[],r={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle((r=>{for(const n of r._order){const o=r._layers[n];if("slot"===o.type){const i=e.cq(n);if(t[i])continue;t[i]=[]}o.slot&&t[o.slot]?t[o.slot].push(o):i.push(o)}})),this._mergedOrder=[];const n=(i=[])=>{for(const o of i)if("slot"===o.type){const i=e.cq(o.id);t[i]&&n(t[i]),this._mergedSlots.push(i)}else{const t=e.aC(o.id,o.scope);this._mergedOrder.push(t),r[t]=o,o.is3D()&&(this._has3DLayers=!0),"circle"===o.type&&(this._hasCircleLayers=!0),"symbol"===o.type&&(this._hasSymbolLayers=!0),"clip"===o.type&&(this._clipLayerPresent=!0)}};n(i),this._mergedOrder.sort(((e,t)=>{const i=r[e],n=r[t];return i.hasInitialOcclusionOpacityProperties?n.is3D()?1:0:i.is3D()&&n.hasInitialOcclusionOpacityProperties?-1:0})),this._mergedLayers=r,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,r){const n=e.l({},i);for(const t of Object.keys(e.a3.colorTheme))void 0===n[t]&&(n[t]=e.a3.colorTheme[t].default);const o=new e.a4(fr,t,new Map(r));return o.setTransitionOrValue(n,r),o.untransitioned().possiblyEvaluate(new e.a8(0))}(this.scope,t,this.options).get("data"):null}_loadColorTheme(t){this._styleColorTheme.lutLoading=!0,this._styleColorTheme.lutLoadingCorrelationID+=1;const i=this._styleColorTheme.lutLoadingCorrelationID;return new Promise(((r,n)=>{const o="data:image/png;base64,";if(!t||0===t.length)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void r();let s=t;s.startsWith(o)||(s=o+s);const a="mapbox-reserved-lut",l=new Image;l.src=s,l.onerror=()=>{this._styleColorTheme.lutLoading=!1,n(new Error("Failed to load image data"))},l.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==i)return void r();this._styleColorTheme.lutLoading=!1;const{width:o,height:s,data:c}=e.q.getImageData(l);if(s>32)return void n(new Error("The height of the image must be less than or equal to 32 pixels."));if(o!==s*s)return void n(new Error("The width of the image must be equal to the height squared."));this.getImage(a)&&this.removeImage(a),this.addImage(a,{data:new e.r({width:o,height:s},c),pixelRatio:1,sdf:!1,usvg:!1,version:0});const h=this.imageManager.getImage(a,this.scope);h?(this._styleColorTheme.lut={image:h.data,data:t},r()):n(new Error("Missing LUT image."))}}))}getLut(e){const t=this._styleColorThemeForScope[e];return t?t.lut:null}setProjection(e){e?this.stylesheet.projection=e:delete this.stylesheet.projection,this.mergeProjection(),this._updateMapProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?(this.getTerrain()||this.stylesheet.terrain)&&!this.disableElevatedTerrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null,0))}_updateMapProjection(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection))}_loadSprite(t){this._spriteRequest=function(t,i,r){let n,o,s;const a=e.q.devicePixelRatio>1?"@2x":"";let l=e.n(i.transformRequest(i.normalizeSpriteURL(t,a,".json"),e.R.SpriteJSON),((e,t)=>{l=null,s||(s=e,n=t,h())})),c=e.o(i.transformRequest(i.normalizeSpriteURL(t,a,".png"),e.R.SpriteImage),((e,t)=>{c=null,s||(s=e,o=t,h())}));function h(){if(s)r(s);else if(n&&o){const t=e.q.getImageData(o),i={};for(const r in n){const{width:o,height:s,x:a,y:l,sdf:c,pixelRatio:h,stretchX:u,stretchY:d,content:p}=n[r],f=new e.r({width:o,height:s});e.r.copy(t,f,{x:a,y:l},{x:0,y:0},{width:o,height:s},null),i[r]={data:f,pixelRatio:h,sdf:c,stretchX:u,stretchY:d,content:p,usvg:!1}}r(null,i)}}return{cancel(){l&&(l.cancel(),l=null),c&&(c.cancel(),c=null)}}}(t,this.map._requestManager,((t,i)=>{if(this._spriteRequest=null,t)this.fire(new e.y(t));else if(i)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.z("data",{dataType:"style"}))}))}_loadIconset(t){if(!e.f(t)&&"icon_set"!==this.map._spriteFormat||"raster"===this.map._spriteFormat)return void this._loadSprite(t);const i="auto"===this.map._spriteFormat;var r,n;this._spriteRequest=(n=(r,n)=>{if(this._spriteRequest=null,r)i?this._loadSprite(t):this.fire(new e.y(r));else if(n)for(const e in n)this.imageManager.addImage(e,this.scope,n[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.z("data",{dataType:"style"}))},e.bi((r=this.map._requestManager).transformRequest(r.normalizeIconsetURL(t),e.R.Iconset),((t,i)=>{if(t)return void n(t);const r={},o=e.cg(new e.bh(i));for(const t of o.icons){const i={version:1,pixelRatio:e.q.devicePixelRatio,content:yr(t),stretchX:t.metadata?t.metadata.stretch_x_areas:void 0,stretchY:t.metadata?t.metadata.stretch_y_areas:void 0,sdf:!1,usvg:!0,icon:t};r[t.name]=i}n(null,r)})))}_validateLayer(t){const i=this.getOwnSource(t.source);if(!i)return;const r=t.sourceLayer;r&&("geojson"===i.type||i.vectorLayerIds&&-1===i.vectorLayerIds.indexOf(r))&&this.fire(new e.y(new Error(`Source layer "${r}" does not exist on source "${i.id}" as specified by style layer "${t.id}"`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._changes.getUpdatedSourceCaches()).length)return!1;for(const e in this._sourceCaches)if(!this._sourceCaches[e].loaded())return!1;if(!this.imageManager.isLoaded())return!1;if(!this.modelManager.isLoaded())return!1;if(this._styleColorTheme.lutLoading)return!1;for(const{style:e}of this.fragments)if(!e.loaded())return!1;return!0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map(((e,t)=>{const i=this.fragments[t];return i&&i.style&&(e.data=i.style.serialize()),e}))}_serializeSources(){const e={};for(const t in this._sourceCaches){const i=this._sourceCaches[t].getSource();e[i.id]||(e[i.id]=i.serialize())}return e}_serializeLayers(e){const t=[];for(const i of e){const e=this._layers[i];e&&"custom"!==e.type&&t.push(e.serialize())}return t}hasLightTransitions(){return!(!this.light||!this.light.hasTransition())||!(!this.ambientLight||!this.ambientLight.hasTransition())||!(!this.directionalLight||!this.directionalLight.hasTransition())}hasFogTransition(){return!!this.fog&&this.fog.hasTransition()}hasSnowTransition(){return!!this.snow&&this.snow.hasTransition()}hasRainTransition(){return!!this.rain&&this.rain.hasTransition()}hasTransitions(){if(this.hasLightTransitions())return!0;if(this.hasFogTransition())return!0;if(this.hasSnowTransition())return!0;if(this.hasRainTransition())return!0;for(const e in this._sourceCaches)if(this._sourceCaches[e].hasTransition())return!0;for(const e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}_getOrder(e){return e?this.order:this._mergedOrder}isLayerDraped(e){return!!this.terrain&&e.isDraped(this.getLayerSourceCache(e))}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}_checkLayer(t){const i=this.getOwnLayer(t);if(i)return i;this.fire(new e.y(new Error(`The layer '${t}' does not exist in the map's style.`)))}_checkSource(t){const i=this.getOwnSource(t);if(i)return i;this.fire(new e.y(new Error(`The source '${t}' does not exist in the map's style.`)))}precompilePrograms(e,t){const i=this.map.painter;if(i)for(let r=e.minzoom||0;r<(e.maxzoom||25.5);r++){const r=e.getProgramIds();if(r)for(const n of r){const r=e.getDefaultProgramParams(n,t.zoom,this._styleColorTheme.lut);r&&(i.style=this,this.fog&&(i._fogVisible=!0,r.overrideFog=!0,i.getOrCreateProgram(n,r)),i._fogVisible=!1,r.overrideFog=!1,i.getOrCreateProgram(n,r),(this.stylesheet.terrain||this.stylesheet.projection&&"globe"===this.stylesheet.projection.name)&&(r.overrideRtt=!0,i.getOrCreateProgram(n,r)))}}}update(t){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(t),this.directionalLight&&this.directionalLight.recalculate(t);const i=this.calculateLightsBrightness();t.brightness=i||0,i!==this._brightness&&(this._brightness=i,this.dispatcher.broadcast("setBrightness",i));const r=this._changes.isDirty();let n=!1;if(this._changes.isDirty()){const e=this._changes.getLayerUpdatesByScope();for(const t in e){const{updatedIds:i,removedIds:r}=e[t];(i||r)&&(this._updateWorkerLayers(t,i,r),n=!0)}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(t),this.light&&this.light.updateTransitions(t),this.ambientLight&&this.ambientLight.updateTransitions(t),this.directionalLight&&this.directionalLight.updateTransitions(t),this.fog&&this.fog.updateTransitions(t),this.snow&&this.snow.updateTransitions(t),this.rain&&this.rain.updateTransitions(t),this._changes.reset()}const o={};for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e];o[e]=t.used,t.used=!1,t.tileCoverLift=0}for(const e of this._mergedOrder){const i=this._mergedLayers[e];if(i.recalculate(t,this._availableImages),!i.isHidden(t.zoom)){const e=this.getLayerSourceCache(i);e&&(e.used=!0,e.tileCoverLift=Math.max(e.tileCoverLift,i.tileCoverLift()))}!this._precompileDone&&this._shouldPrecompile&&("requestIdleCallback"in window?requestIdleCallback((()=>{this.precompilePrograms(i,t)})):this.precompilePrograms(i,t))}this._shouldPrecompile&&(this._precompileDone=!0),this.terrain&&n&&this.mergeLayers();for(const t in o){const i=this._mergedSourceCaches[t];o[t]!==i.used&&i.getSource().fire(new e.z("data",{sourceDataType:"visibility",dataType:"source",sourceId:i.getSource().id}))}this.light&&this.light.recalculate(t),this.terrain&&this.terrain.recalculate(t),this.fog&&this.fog.recalculate(t),this.snow&&this.snow.recalculate(t),this.rain&&this.rain.recalculate(t),this.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),r&&this.fire(new e.z("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 r=this.getFragmentStyle(e);r&&this.dispatcher.broadcast("updateLayers",{layers:t?r._serializeLayers(t):[],scope:e,removedIds:i||[],options:r.options})}setState(t,i){if(this._checkLoaded(),xr(this,_e(t)))return!1;(t=e.cp(t)).layers=At(t.layers);const r=function(t,i){if(!t)return[{command:It.setStyle,args:[i]}];let r=[];try{if(!e.bn(t.version,i.version))return[{command:It.setStyle,args:[i]}];if(e.bn(t.center,i.center)||r.push({command:It.setCenter,args:[i.center]}),e.bn(t.zoom,i.zoom)||r.push({command:It.setZoom,args:[i.zoom]}),e.bn(t.bearing,i.bearing)||r.push({command:It.setBearing,args:[i.bearing]}),e.bn(t.pitch,i.pitch)||r.push({command:It.setPitch,args:[i.pitch]}),e.bn(t.sprite,i.sprite)||r.push({command:It.setSprite,args:[i.sprite]}),e.bn(t.glyphs,i.glyphs)||r.push({command:It.setGlyphs,args:[i.glyphs]}),e.bn(t.imports,i.imports)||function(t=[],i=[],r){i=i||[];const n=(t=t||[]).map(Lt),o=i.map(Lt),s=t.reduce(Ot,{}),a=i.reduce(Ot,{}),l=n.slice();let c,h,u,d;for(c=0,h=0;c<n.length;c++)u=n[c],a.hasOwnProperty(u)?h++:(r.push({command:It.removeImport,args:[u]}),l.splice(l.indexOf(u,h),1));for(c=0,h=0;c<o.length;c++)u=o[o.length-1-c],l[l.length-1-c]!==u&&(s.hasOwnProperty(u)?(r.push({command:It.removeImport,args:[u]}),l.splice(l.lastIndexOf(u,l.length-h),1)):h++,d=l[l.length-c],r.push({command:It.addImport,args:[a[u],d]}),l.splice(l.length-c,0,u));for(const t of i){const i=s[t.id];i&&!e.bn(i,t)&&r.push({command:It.updateImport,args:[t.id,t]})}}(t.imports,i.imports,r),e.bn(t.transition,i.transition)||r.push({command:It.setTransition,args:[i.transition]}),e.bn(t.light,i.light)||r.push({command:It.setLight,args:[i.light]}),e.bn(t.fog,i.fog)||r.push({command:It.setFog,args:[i.fog]}),e.bn(t.snow,i.snow)||r.push({command:It.setSnow,args:[i.snow]}),e.bn(t.rain,i.rain)||r.push({command:It.setRain,args:[i.rain]}),e.bn(t.projection,i.projection)||r.push({command:It.setProjection,args:[i.projection]}),e.bn(t.lights,i.lights)||r.push({command:It.setLights,args:[i.lights]}),e.bn(t.camera,i.camera)||r.push({command:It.setCamera,args:[i.camera]}),!e.bn(t["color-theme"],i["color-theme"]))return[{command:It.setStyle,args:[i]}];const n={},o=[];!function(t,i,r,n){let o;for(o in i=i||{},t=t||{})t.hasOwnProperty(o)&&(i.hasOwnProperty(o)||Pt(o,r,n));for(o in i){if(!i.hasOwnProperty(o))continue;const s=i[o];t.hasOwnProperty(o)?e.bn(t[o],s)||("geojson"===t[o].type&&"geojson"===s.type&&Dt(t,i,o)?r.push({command:It.setGeoJSONSourceData,args:[o,s.data]}):zt(o,i,r,n)):Ct(o,i,r)}}(t.sources,i.sources,o,n);const s=[];t.layers&&t.layers.forEach((e=>{e.source&&n[e.source]?r.push({command:It.removeLayer,args:[e.id]}):s.push(e)}));let a=t.terrain;a&&n[a.source]&&(r.push({command:It.setTerrain,args:[void 0]}),a=void 0),r=r.concat(o),e.bn(a,i.terrain)||r.push({command:It.setTerrain,args:[i.terrain]}),function(t,i,r){i=i||[];const n=(t=t||[]).map(Lt),o=i.map(Lt),s=t.reduce(Ot,{}),a=i.reduce(Ot,{}),l=n.slice(),c=Object.create(null);let h,u,d,p,f,m,_;for(h=0,u=0;h<n.length;h++)d=n[h],a.hasOwnProperty(d)?u++:(r.push({command:It.removeLayer,args:[d]}),l.splice(l.indexOf(d,u),1));for(h=0,u=0;h<o.length;h++)d=o[o.length-1-h],l[l.length-1-h]!==d&&(s.hasOwnProperty(d)?(r.push({command:It.removeLayer,args:[d]}),l.splice(l.lastIndexOf(d,l.length-u),1)):u++,m=l[l.length-h],r.push({command:It.addLayer,args:[a[d],m]}),l.splice(l.length-h,0,d),c[d]=!0);for(h=0;h<o.length;h++)if(d=o[h],p=s[d],f=a[d],!c[d]&&!e.bn(p,f))if(e.bn(p.source,f.source)&&e.bn(p["source-layer"],f["source-layer"])&&e.bn(p.type,f.type)){for(_ in Rt(p.layout,f.layout,r,d,null,It.setLayoutProperty),Rt(p.paint,f.paint,r,d,null,It.setPaintProperty),e.bn(p.slot,f.slot)||r.push({command:It.setSlot,args:[d,f.slot]}),e.bn(p.filter,f.filter)||r.push({command:It.setFilter,args:[d,f.filter]}),e.bn(p.minzoom,f.minzoom)&&e.bn(p.maxzoom,f.maxzoom)||r.push({command:It.setLayerZoomRange,args:[d,f.minzoom,f.maxzoom]}),p)p.hasOwnProperty(_)&&"layout"!==_&&"paint"!==_&&"filter"!==_&&"metadata"!==_&&"minzoom"!==_&&"maxzoom"!==_&&"slot"!==_&&(0===_.indexOf("paint.")?Rt(p[_],f[_],r,d,_.slice(6),It.setPaintProperty):e.bn(p[_],f[_])||r.push({command:It.setLayerProperty,args:[d,_,f[_]]}));for(_ in f)f.hasOwnProperty(_)&&!p.hasOwnProperty(_)&&"layout"!==_&&"paint"!==_&&"filter"!==_&&"metadata"!==_&&"minzoom"!==_&&"maxzoom"!==_&&"slot"!==_&&(0===_.indexOf("paint.")?Rt(p[_],f[_],r,d,_.slice(6),It.setPaintProperty):e.bn(p[_],f[_])||r.push({command:It.setLayerProperty,args:[d,_,f[_]]}))}else r.push({command:It.removeLayer,args:[d]}),m=l[l.lastIndexOf(d)+1],r.push({command:It.addLayer,args:[f,m]})}(s,i.layers,r)}catch(e){console.warn("Unable to compute style diff:",e),r=[{command:It.setStyle,args:[i]}]}return r}(this.serialize(),t).filter((e=>!(e.command in br)));if(0===r.length)return!1;const n=r.filter((e=>!(e.command in vr)));if(n.length>0)throw new Error(`Unimplemented: ${n.map((e=>e.command)).join(", ")}.`);const o=[];return r.forEach((e=>{o.push(this[e.command].apply(this,e.args))})),i&&Promise.all(o).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.y(new Error("An image with this name already exists."))):(this.imageManager.addImage(t,this.scope,i),this._afterImageUpdated(t),this)}updateImage(e,t,i=!1){this.imageManager.updateImage(e,this.scope,t),i&&this._afterImageUpdated(e)}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.y(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.z("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addModel(e,t,i={}){return this._checkLoaded(),this._validate(Ie,`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.y(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.scope)}addSource(t,i,r={}){if(this._checkLoaded(),void 0!==this.getOwnSource(t))throw new Error(`There is already a source with ID "${t}".`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(ge,`sources.${t}`,i,null,r))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const n=rt(t,i,this.dispatcher,this);n.scope=this.scope,n.setEventedParent(this,(()=>({isSourceLoaded:this._isSourceCacheLoaded(n.id),source:n.serialize(),sourceId:n.id})));const o=t=>{const i=(t?"symbol:":"other:")+n.id,r=e.aC(i,this.scope),o=this._sourceCaches[i]=new bt(r,n,t);(t?this._symbolSourceCaches:this._otherSourceCaches)[n.id]=o,o.onAdd(this.map)};o(!1),"vector"!==i.type&&"geojson"!==i.type||o(!0),n.onAdd&&n.onAdd(this.map),r.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}removeSource(t){this._checkLoaded();const i=this.getOwnSource(t);if(!i)throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===t)return this.fire(new e.y(new Error(`Source "${t}" cannot be removed while layer "${i}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===t)return this.fire(new e.y(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));const r=this.getOwnSourceCaches(t);for(const t of r){const i=e.cq(t.id);delete this._sourceCaches[i],this._changes.discardSourceCacheUpdate(t.id),t.fire(new e.z("data",{sourceDataType:"metadata",dataType:"source",sourceId:t.getSource().id})),t.setEventedParent(null),t.clearTiles()}return delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],this.mergeSources(),i.setEventedParent(null),i.onRemove&&i.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(e,t){this._checkLoaded(),this.getOwnSource(e).setData(t),this._changes.setDirty()}getOwnSource(e){const t=this.getOwnSourceCache(e);return t&&t.getSource()}getOwnSources(){const e=[];for(const t in this._otherSourceCaches){const i=this.getOwnSourceCache(t);i&&e.push(i.getSource())}return e}areTilesLoaded(){const e=this._mergedSourceCaches;for(const t in e){const i=e[t]._tiles;for(const e in i){const t=i[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}}return!0}setLights(t){if(this._checkLoaded(),!t)return delete this.ambientLight,void delete this.directionalLight;const i=this._getTransitionParameters();for(const r of t){if(this._validate(xe,"lights",r))return;switch(r.type){case"ambient":if(this.ambientLight){const e=this.ambientLight;e.set(r),e.updateTransitions(i)}else this.ambientLight=new $e(r,je||(je=new e.a5({color:new e.a6(e.a3.properties_light_ambient.color),"color-use-theme":new e.a6({type:"string",default:"default","property-type":"data-constant"}),intensity:new e.a6(e.a3.properties_light_ambient.intensity)})),this.scope,this.options);break;case"directional":if(this.directionalLight){const e=this.directionalLight;e.set(r),e.updateTransitions(i)}else this.directionalLight=new $e(r,Ge||(Ge=new e.a5({direction:new e.ak(e.a3.properties_light_directional.direction),color:new e.a6(e.a3.properties_light_directional.color),"color-use-theme":new e.a6({type:"string",default:"default","property-type":"data-constant"}),intensity:new e.a6(e.a3.properties_light_directional.intensity),"cast-shadows":new e.a6(e.a3.properties_light_directional["cast-shadows"]),"shadow-quality":new e.a6(e.a3.properties_light_directional["shadow-quality"]),"shadow-intensity":new e.a6(e.a3.properties_light_directional["shadow-intensity"])})),this.scope,this.options)}}const r=new e.a8(this.z||0,i);this.ambientLight&&this.ambientLight.recalculate(r),this.directionalLight&&this.directionalLight.recalculate(r),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}calculateLightsBrightness(){const t=this.directionalLight,i=this.ambientLight;if(!t||!i)return;const r=e=>.2126*(e[0]<=.03928?e[0]/12.92:Math.pow((e[0]+.055)/1.055,2.4))+.7152*(e[1]<=.03928?e[1]/12.92:Math.pow((e[1]+.055)/1.055,2.4))+.0722*(e[2]<=.03928?e[2]/12.92:Math.pow((e[2]+.055)/1.055,2.4)),n=t.properties.get("color").toRenderColor(null).toArray01(),o=t.properties.get("intensity"),s=t.properties.get("direction"),a=1-e.cb(s.x,s.y,s.z)[2]/90,l=r(n)*o*a,c=i.properties.get("color").toRenderColor(null).toArray01(),h=i.properties.get("intensity"),u=r(c)*h;return Number(((l+u)/2).toFixed(6))}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;const e=[];return this.directionalLight&&e.push(this.directionalLight.get()),this.ambientLight&&e.push(this.ambientLight.get()),e}enable3dLights(){return!!this.ambientLight&&!!this.directionalLight}getFragmentStyle(t){if(!t)return this;if(e.cr(t)){const i=e.cs(t),r=this.fragments.find((({id:e})=>e===i));if(!r)throw new Error(`Style import '${t}' not found`);const n=e.cq(t);return r.style.getFragmentStyle(n)}{const e=this.fragments.find((({id:e})=>e===t));if(!e)throw new Error(`Style import '${t}' not found`);return e.style}}setFeaturesetSelectors(t){if(!t)return;const i={},r=(e,t="")=>`${e}::${t}`;this.featuresetSelectors={};for(const n in t){const o=this.featuresetSelectors[n]=[];for(const s of t[n].selectors){if(s.featureNamespace){const t=this.getOwnLayer(s.layer);if(!t){e.w(`Layer is undefined for selector: ${s.layer}`);continue}const o=r(t.source,t.sourceLayer);if(o in i&&i[o]!==s.featureNamespace){e.w(`"featureNamespace ${s.featureNamespace} of featureset ${n}'s selector is not associated to the same source, skip this selector`);continue}i[o]=s.featureNamespace}let t;if(s.properties)for(const i in s.properties){const r=e.U(s.properties[i]);"success"===r.result&&(t=t||{},t[i]=r.value)}o.push({layerId:s.layer,namespace:s.featureNamespace,properties:t})}}}getFeaturesetDescriptors(e){const t=this.getFragmentStyle(e);if(!t||!t.stylesheet.featuresets)return[];const i=[];for(const e in t.stylesheet.featuresets)i.push({featuresetId:e,importId:t.scope?t.scope:void 0});return i}getFeaturesetLayers(t,i){const r=this.getFragmentStyle(i),n=r.stylesheet.featuresets;if(!n||!n[t])return this.fire(new e.y(new Error(`The featureset '${t}' does not exist in the map's style and cannot be queried.`))),[];const o=[];for(const e of n[t].selectors){const t=r.getOwnLayer(e.layer);t&&o.push(t)}return o}getConfigProperty(t,i){const r=this.getFragmentStyle(t);if(!r)return null;const n=e.aC(i,r.scope),o=r.options.get(n),s=o?o.value||o.default:null;return s?s.serialize():null}setConfigProperty(t,i,r){const n=this.getFragmentStyle(t);if(!n)return;const o=n.stylesheet.indoor?_r(n.stylesheet.schema):n.stylesheet.schema;if(!o||!o[i])return;const s=e.U(r);if("success"!==s.result)return void xr(this,s.value);const a=s.value.expression,l=e.aC(i,n.scope),c=n.options.get(l);if(!c)return;let h;const{minValue:u,maxValue:d,stepValue:p,type:f,values:m}=o[i],_=e.U(o[i].default);"success"===_.result&&(h=_.value.expression),h?(this.options.set(l,{...c,value:a,default:h,minValue:u,maxValue:d,stepValue:p,type:f,values:m}),this.updateConfigDependencies(i)):this.fire(new e.y(new Error(`No schema defined for the config option "${i}" in the "${t}" fragment.`)))}getConfig(t){const i=this.getFragmentStyle(t);if(!i)return null;const r=i.stylesheet.schema;if(!r)return null;const n={};for(const t in r){const r=e.aC(t,i.scope),o=i.options.get(r),s=o?o.value||o.default:null;n[t]=s?s.serialize():null}return n}setConfig(e,t){const i=this.getFragmentStyle(e);i&&(i.updateConfig(t,i.stylesheet.schema),this.updateConfigDependencies())}getSchema(e){const t=this.getFragmentStyle(e);return t?t.stylesheet.schema:null}setSchema(e,t){const i=this.getFragmentStyle(e);i&&(i.stylesheet.schema=t,i.updateConfig(i._config,t),this.updateConfigDependencies())}updateConfig(t,i){if(this._config=t,t||i)if(i)for(const r in i){let n,o;const s=e.U(i[r].default);if("success"===s.result&&(n=s.value.expression),t&&void 0!==t[r]){const i=e.U(t[r]);"success"===i.result&&(o=i.value.expression)}const{minValue:a,maxValue:l,stepValue:c,type:h,values:u}=i[r];if(n){const t=e.aC(r,this.scope);this.options.set(t,{default:n,value:o,minValue:a,maxValue:l,stepValue:c,type:h,values:u})}else this.fire(new e.y(new Error(`No schema defined for config option "${r}".`)))}else this.fire(new e.y(new Error("Attempting to set config for a style without schema.")))}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.snow&&this.snow.updateConfig(this.options),this.rain&&this.rain.updateConfig(this.options),this.forEachFragmentStyle((e=>{const t=e._styleColorTheme.colorThemeOverride?e._styleColorTheme.colorThemeOverride:e._styleColorTheme.colorTheme;if(t){const i=e._evaluateColorThemeData(t);(!e._styleColorTheme.lut&&""!==i||e._styleColorTheme.lut&&i!==e._styleColorTheme.lut.data)&&e.setColorTheme(t)}})),this._changes.setDirty()}addLayer(t,i,r={}){this._checkLoaded();const n=t.id;if(this._layers[n])return void this.fire(new e.y(new Error(`Layer with id "${n}" already exists on this map`)));let o;if("custom"===t.type){if(xr(this,e.ct(t)))return;o=e.cu(t,this.scope,this._styleColorTheme.lut,this.options)}else{if("object"==typeof t.source&&(this.addSource(n,t.source),t=e.cp(t),t=e.l(t,{source:n})),this._validate(Se,`layers.${n}`,t,{arrayIndex:-1},r))return;o=e.cu(t,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(o),o.setEventedParent(this,{layer:{id:n}})}0!==o.configDependencies.size&&this._configDependentLayers.add(o.fqid);let s=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.y(new Error(`Layer with id "${i}" does not exist on this map.`)));o.slot===this._layers[i].slot?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,n),this._layerOrderChanged=!0,this._layers[n]=o;const a=this.getOwnLayerSourceCache(o),l=!!this.directionalLight&&this.directionalLight.shadowsEnabled();a&&o.canCastShadows()&&l&&(a.castsShadows=!0);const c=this._changes.getRemovedLayer(o);if(c&&o.source&&a&&"custom"!==o.type){this._changes.discardLayerRemoval(o);const t=e.aC(o.source,o.scope);c.type!==o.type?this._changes.updateSourceCache(t,"clear"):(this._changes.updateSourceCache(t,"reload"),a.pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map),o.scope=this.scope,this.mergeLayers()}moveLayer(t,i){this._checkLoaded();const r=this._checkLayer(t);if(!r)return;if(t===i)return;const n=this._order.indexOf(t);this._order.splice(n,1);let o=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.y(new Error(`Layer with id "${i}" does not exist on this map.`)));r.slot===this._layers[i].slot?o=t:e.w(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(o,0,t),this._changes.setDirty(),this._layerOrderChanged=!0,this.mergeLayers()}removeLayer(e){this._checkLoaded();const t=this._checkLayer(e);if(!t)return;t.setEventedParent(null);const i=this._order.indexOf(e);this._order.splice(i,1),delete this._layers[e],this._changes.setDirty(),this._layerOrderChanged=!0,this._configDependentLayers.delete(t.fqid),this._changes.removeLayer(t);const r=this.getOwnLayerSourceCache(t);if(r&&r.castsShadows){let e=!1;for(const i in this._layers)if(this._layers[i].source===t.source&&this._layers[i].canCastShadows()){e=!0;break}r.castsShadows=e}t.onRemove&&t.onRemove(this.map),this.mergeLayers()}getOwnLayer(e){return this._layers[e]}hasLayer(e){return e in this._mergedLayers}hasLayerType(e){for(const t in this._layers)if(this._layers[t].type===e)return!0;return!1}setLayerZoomRange(e,t,i){this._checkLoaded();const r=this._checkLayer(e);r&&(r.minzoom===t&&r.maxzoom===i||(null!=t&&(r.minzoom=t),null!=i&&(r.maxzoom=i),this._updateLayer(r)))}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(e,t){this._checkLoaded();const i=this._checkLayer(e);i&&i.slot!==t&&(i.slot=t,this._updateLayer(i))}setFilter(t,i,r={}){this._checkLoaded();const n=this._checkLayer(t);if(n&&!e.bn(n.filter,i))return null==i?(n.filter=void 0,void this._updateLayer(n)):void(this._validate(Me,`layers.${n.id}.filter`,i,{layerType:n.type},r)||(n.filter=e.cp(i),this._updateLayer(n)))}getFilter(t){const i=this._checkLayer(t);if(i)return e.cp(i.filter)}setLayoutProperty(t,i,r,n={}){this._checkLoaded();const o=this._checkLayer(t);if(o&&!e.bn(o.getLayoutProperty(i),r)){if(null!=r&&(!n||!1!==n.validate)&&xr(o,Ae.call(_e,{key:`layers.${t}.layout.${i}`,layerType:o.type,objectKey:i,value:r,styleSpec:e.a3,style:{glyphs:!0,sprite:!0}})))return;o.setLayoutProperty(i,r),0!==o.configDependencies.size&&this._configDependentLayers.add(o.fqid),this._updateLayer(o)}}getLayoutProperty(e,t){const i=this._checkLayer(e);if(i)return i.getLayoutProperty(t)}setPaintProperty(t,i,r,n={}){this._checkLoaded();const o=this._checkLayer(t);if(!o)return;if(e.bn(o.getPaintProperty(i),r))return;if(null!=r&&(!n||!1!==n.validate)&&xr(o,Ee.call(_e,{key:`layers.${t}.paint.${i}`,layerType:o.type,objectKey:i,value:r,styleSpec:e.a3})))return;const s=o.setPaintProperty(i,r);0!==o.configDependencies.size&&this._configDependentLayers.add(o.fqid),s&&this._updateLayer(o),this._changes.updatePaintProperties(o)}getPaintProperty(e,t){const i=this._checkLayer(e);if(i)return i.getPaintProperty(t)}setFeatureState(t,i){if(this._checkLoaded(),"target"in t){if("featuresetId"in t.target){const{featuresetId:e,importId:r}=t.target,n=this.getFragmentStyle(r),o=n.getFeaturesetLayers(e);for(const{source:e,sourceLayer:r}of o)n.setFeatureState({id:t.id,source:e,sourceLayer:r},i)}else if("layerId"in t.target){const{layerId:e}=t.target,r=this.getLayer(e);this.setFeatureState({id:t.id,source:r.source,sourceLayer:r.sourceLayer},i)}return}const r=t.source,n=t.sourceLayer,o=this._checkSource(r);if(!o)return;const s=o.type;if("geojson"===s&&n)return void this.fire(new e.y(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===s&&!n)return void this.fire(new e.y(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===t.id&&this.fire(new e.y(new Error("The feature id parameter must be provided.")));const a=this.getOwnSourceCaches(r);for(const e of a)e.setFeatureState(n,t.id,i)}removeFeatureState(t,i){if(this._checkLoaded(),"target"in t){if("featuresetId"in t.target){const{featuresetId:e,importId:r}=t.target,n=this.getFragmentStyle(r),o=n.getFeaturesetLayers(e);for(const{source:e,sourceLayer:r}of o)n.removeFeatureState({id:t.id,source:e,sourceLayer:r},i)}else if("layerId"in t.target){const{layerId:e}=t.target,r=this.getLayer(e);this.removeFeatureState({id:t.id,source:r.source,sourceLayer:r.sourceLayer},i)}return}const r=t.source,n=this._checkSource(r);if(!n)return;const o=n.type,s="vector"===o?t.sourceLayer:void 0;if("vector"===o&&!s)return void this.fire(new e.y(new Error("The sourceLayer parameter must be provided for vector source types.")));if(i&&"string"!=typeof t.id&&"number"!=typeof t.id)return void this.fire(new e.y(new Error("A feature id is required to remove its specific state property.")));const a=this.getOwnSourceCaches(r);for(const e of a)e.removeFeatureState(s,t.id,i)}getFeatureState(t){if(this._checkLoaded(),"target"in t){let i;if("featuresetId"in t.target){const{featuresetId:r,importId:n}=t.target,o=this.getFragmentStyle(n),s=o.getFeaturesetLayers(r);for(const{source:r,sourceLayer:n}of s){const s=o.getFeatureState({id:t.id,source:r,sourceLayer:n});if(s&&!i)i=s;else if(!e.bn(i,s))return void this.fire(new e.y(new Error("The same feature id exists in multiple sources in the featureset, but their feature states are not consistent through the sources.")))}}else if("layerId"in t.target){const{layerId:e}=t.target,r=this.getLayer(e);i=this.getFeatureState({id:t.id,source:r.source,sourceLayer:r.sourceLayer})}return i}const i=t.source,r=t.sourceLayer,n=this._checkSource(i);if(n){if("vector"!==n.type||r)return void 0===t.id&&this.fire(new e.y(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(i)[0].getFeatureState(r,t.id);this.fire(new e.y(new Error("The sourceLayer parameter must be provided for vector source types.")))}}setTransition(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.cv({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,snow:this.stylesheet.snow,rain:this.stylesheet.rain,center:this.stylesheet.center,"color-theme":this.stylesheet["color-theme"],zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:this._serializeSources(),layers:this._serializeLayers(this._order)},(e=>void 0!==e))}_updateFilteredLayers(e){for(const t of Object.values(this._mergedLayers))e(t)&&this._updateLayer(t)}_updateLayer(t){this._changes.updateLayer(t);const i=this.getLayerSourceCache(t),r=e.aC(t.source,t.scope),n=this._changes.getUpdatedSourceCaches();t.source&&!n[r]&&i&&"raster"!==i.getSource().type&&(this._changes.updateSourceCache(r,"reload"),i.pause()),t.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(e){const t=e=>this._mergedLayers[e].is3D(),i=this.order,r={},n=[];for(let o=i.length-1;o>=0;o--){const s=i[o];if(t(s)){r[s]=o;for(const t of e){const e=t[s];if(e)for(const t of e)n.push(t)}}}n.sort(((e,t)=>t.intersectionZ-e.intersectionZ));const o=[];for(let s=i.length-1;s>=0;s--){const a=i[s];if(t(a))for(let e=n.length-1;e>=0;e--){const t=n[e].feature;if(t.layer&&r[t.layer.id]<s)break;o.push(t),n.pop()}else for(const t of e){const e=t[a];if(e)for(const t of e)o.push(t.feature)}}return o}queryRenderedFeatures(t,i,r){let n;i&&!Array.isArray(i)&&i.filter&&(this._validate(Me,"queryRenderedFeatures.filter",i.filter,null,i),n=e.aZ(i.filter));const o={},s=e=>{if(wr.has(e.type))return;const t=this.getOwnLayerSourceCache(e),i=o[t.id]=o[t.id]||{sourceCache:t,layers:{},has3DLayers:!1};e.is3D()&&(i.has3DLayers=!0),i.layers[e.fqid]=i.layers[e.fqid]||{styleLayer:e,targets:[]},i.layers[e.fqid].targets.push({filter:n})};if(i&&i.layers){if(!Array.isArray(i.layers))return this.fire(new e.y(new Error("parameters.layers must be an Array."))),[];for(const t of i.layers){const i=this._layers[t];if(!i)return this.fire(new e.y(new Error(`The layer '${t}' does not exist in the map's style and cannot be queried for features.`))),[];s(i)}}else for(const e in this._layers)s(this._layers[e]);const a=this._queryRenderedFeatures(t,o,r),l=this._flattenAndSortRenderedFeatures(a),c=[];for(const t of l)e.cs(t.layer.id)===this.scope&&c.push(t);return c}queryRenderedFeatureset(t,i,r){let n;i&&!Array.isArray(i)&&i.filter&&(this._validate(Me,"queryRenderedFeatures.filter",i.filter,null,i),n=e.aZ(i.filter));const o="mock",s=[];if(i&&i.target)s.push({...i,targetId:o,filter:n});else{const e=this.getFeaturesetDescriptors();for(const t of e)s.push({targetId:o,filter:n,target:t});for(const{style:e}of this.fragments){const t=e.getFeaturesetDescriptors();for(const e of t)s.push({targetId:o,filter:n,target:e})}}const a=this.queryRenderedTargets(t,s,r),l=[];for(const t of a)for(const i of t.variants[o])l.push(new e.cw(t,i));return l}queryRenderedTargets(t,i,r){const n={},o=(e,t,i,r)=>{const o=n[t.id]=n[t.id]||{sourceCache:t,layers:{},has3DLayers:!1};o.layers[e.fqid]=o.layers[e.fqid]||{styleLayer:e,targets:[]},e.is3D()&&(o.has3DLayers=!0),o.layers[e.fqid].targets.push(r?{...i,namespace:r.namespace,properties:r.properties}:i)};for(const t of i)if("featuresetId"in t.target){const{featuresetId:i,importId:r}=t.target,n=this.getFragmentStyle(r),s=n.featuresetSelectors[i];if(!s){this.fire(new e.y(new Error(`The featureset '${i}' does not exist in the map's style and cannot be queried for features.`)));continue}for(const e of s){const i=n.getOwnLayer(e.layerId);i&&!wr.has(i.type)&&o(i,n.getOwnLayerSourceCache(i),t,e)}}else if("layerId"in t.target){const{layerId:e}=t.target,i=this.getLayer(e);if(!i||wr.has(i.type))continue;o(i,this.getLayerSourceCache(i),t)}const s=this._queryRenderedFeatures(t,n,r);return this._flattenAndSortRenderedFeatures(s)}_queryRenderedFeatures(e,t,i){const r=[],n=!!this.map._showQueryGeometry,o=He.createFromScreenPoints(e,i);for(const e in t){const s=nt(o,t[e],this._availableImages,i,n);Object.keys(s).length&&r.push(s)}if(this.placement)for(const e in t){if(!t[e].sourceCache._onlySymbols)continue;const i=ot(o.screenGeometry,t[e],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData);Object.keys(i).length&&r.push(i)}return r}querySourceFeatures(e,t){const i=t&&t.filter;i&&this._validate(Me,"querySourceFeatures.filter",i,null,t);let r=[];const n=this.getOwnSourceCaches(e);for(const e of n)r=r.concat(st(e,t));return r}addSourceType(e,t,i){return Mr.getSourceType(e)?i(new Error(`A source type called "${e}" already exists.`)):(Mr.setSourceType(e,t),t.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:e,url:t.workerSourceURL},i):i(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(t,i,r={}){this._checkLoaded();const n=this.light.getLight();let o=!1;for(const i in t)if(!e.bn(t[i],n[i])){o=!0;break}if(!o)return;const s=this._getTransitionParameters();this.light.setLight(t,i,r),this.light.updateTransitions(s)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}checkCanvasFingerprintNoise(){void 0===this.disableElevatedTerrain&&(this.disableElevatedTerrain=e.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 r=t;const n=null==t.source;if(1===i){if(this.disableElevatedTerrain)return;if("object"==typeof r.source){const t="terrain-dem-src";this.addSource(t,r.source),r=e.cp(r),r=e.l(r,{source:t})}const t=e.l({},r),i={};if(this.terrain&&n){t.source=this.terrain.get().source;const e=this.terrain?this.getFragmentStyle(this.terrain.scope):null;e&&(i.style=e.serialize())}if(this._validate(ve,"terrain",t,i))return}if(!this.terrain||this.terrain.scope!==this.scope&&!n||this.terrain&&i!==this.terrain.drapeRenderMode){if(!r)return;this._createTerrain(r,i),this.fire(new e.z("data",{dataType:"style"}))}else{const i=this.terrain,n=i.get();for(const t of Object.keys(e.a3.terrain))!r.hasOwnProperty(t)&&e.a3.terrain[t].default&&(r[t]=e.a3.terrain[t].default);for(const r in t)if(!e.bn(t[r],n[r])){i.set(t,this.options),this.stylesheet.terrain=t;const r=this._getTransitionParameters({duration:0});i.updateTransitions(r),this.fire(new e.z("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(e){const t=this.fog=new Ne(e,this.map.transform,this.scope,this.options);this.stylesheet.fog=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i)}_createSnow(e){const t=this.snow=new qe(e,this.map.transform,this.scope,this.options);this.stylesheet.snow=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i)}_createRain(e){const t=this.rain=new Ze(e,this.map.transform,this.scope,this.options);this.stylesheet.rain=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask((()=>{for(const e of this.map._markers)e._evaluateOpacity()}))}getFog(){return this.fog?this.fog.get():null}setFog(t){if(this._checkLoaded(),!t)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const i=this.fog;if(!e.bn(i.get(),t)){i.set(t,this.options),this.stylesheet.fog=i.get();const e=this._getTransitionParameters({duration:0});i.updateTransitions(e)}}else this._createFog(t);this._markersNeedUpdate=!0}getSnow(){return this.snow?this.snow.get():null}setSnow(t){if(this._checkLoaded(),!t)return delete this.snow,void delete this.stylesheet.snow;if(this.snow){const i=this.snow;if(!e.bn(i.get(),t)){i.set(t,this.options),this.stylesheet.snow=i.get();const e=this._getTransitionParameters({duration:0});i.updateTransitions(e)}}else this._createSnow(t);this._markersNeedUpdate=!0}getRain(){return this.rain?this.rain.get():null}setRain(t){if(this._checkLoaded(),!t)return delete this.rain,void delete this.stylesheet.rain;if(this.rain){const i=this.rain;if(!e.bn(i.get(),t)){i.set(t,this.options),this.stylesheet.rain=i.get();const e=this._getTransitionParameters({duration:0});i.updateTransitions(e)}}else this._createRain(t);this._markersNeedUpdate=!0}_reloadColorTheme(){const t=()=>{for(const e in this._layers)this._layers[e].lut=this._styleColorTheme.lut;for(const e in this._sourceCaches)this._sourceCaches[e].clearTiles()},i=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(!i)return this._styleColorTheme.lut=null,void t();const r=this._evaluateColorThemeData(i);this._loadColorTheme(r).then((()=>{this.fire(new e.z("colorthemeset")),t()})).catch((t=>{e.w(`Couldn't set color theme: ${t}`)}))}setColorTheme(t){this._checkLoaded(),this._styleColorTheme.colorThemeOverride&&e.w("Note: setColorTheme is called on a style with a color-theme override, the passed color-theme won't be visible."),this._styleColorTheme.colorTheme=t,this._reloadColorTheme()}setImportColorTheme(e,t){const i=this.getFragmentStyle(e);i&&(i._styleColorTheme.colorThemeOverride=t,i._reloadColorTheme())}_getTransitionParameters(t){return{now:e.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 Re(e,t,this.scope,this.options);1===t&&(this.stylesheet.terrain=e),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const r=this._getTransitionParameters({duration:0});i.updateTransitions(r)}_force3DLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"fill-extrusion"===t.type&&this._updateLayer(t)}}_forceSymbolLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"symbol"===t.type&&this._updateLayer(t)}}_validate(t,i,r,n,o={}){if(o&&!1===o.validate)return!1;const s=e.l({},this.serialize());return xr(this,t.call(_e,e.l({key:i,style:s,value:r,styleSpec:e.a3},n)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),e.cx.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.snow,delete this.rain,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=hr(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,r,n,o,s,a=!1){let l=!1,c=!1;const h={},u={};for(const t of this._mergedOrder){const r=this._mergedLayers[t];if("symbol"!==r.type)continue;const n=e.aC(r.source,r.scope);let o=h[n];if(!o){const e=this.getLayerSourceCache(r);if(!e)continue;const t=e.getRenderableIds(!0).map((t=>e.getTileByID(t)));u[n]=t.slice(),o=h[n]=t.sort(((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)))}const s=this.crossTileSymbolIndex.addLayer(r,o,i.center.lng,i.projection);l=l||s}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),a=a||this._layerOrderChanged||0===n,this._layerOrderChanged&&this.fire(new e.z("neworder")),(a||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.q.now(),i.zoom))&&(this.pauseablePlacement=new Ii(i,this._mergedOrder,a,r,n,o,this.placement,this.fog&&i.projection.supportsFog?this.fog.state:null,this._buildingIndex),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,h,u,this.map.painter.scaleFactor),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;t<this._mergedOrder.length;t++){const i=this._mergedLayers[this._mergedOrder[t]];if("symbol"!==i.type)continue;const r=this.isLayerClipped(i);this.placement.updateLayerOpacities(i,h[e.aC(i.source,i.scope)],t,r?s:null)}}return{needsRerender:!this.pauseablePlacement.isDone()||this.placement.hasTransitions(e.q.now())}}_releaseSymbolFadeTiles(){for(const e in this._sourceCaches)this._sourceCaches[e].releaseSymbolFadeTiles()}addImport(t,i){this._checkLoaded();const r=this.stylesheet.imports=this.stylesheet.imports||[];if(-1!==r.findIndex((({id:e})=>e===t.id)))return void this.fire(new e.y(new Error(`Import with id '${t.id}' already exists in the map's style.`)));if(!i)return r.push(t),this._loadImports([t],!0);const n=r.findIndex((({id:e})=>e===i));return-1===n&&this.fire(new e.y(new Error(`Import with id "${i}" does not exist on this map.`))),this.stylesheet.imports=r.slice(0,n).concat(t).concat(r.slice(n)),this._loadImports([t],!0,i)}updateImport(t,i){this._checkLoaded();const r=this.stylesheet.imports||[],n=this.getImportIndex(t);return-1===n?this:"string"==typeof i?(this.setImportUrl(t,i),this):(i.url&&i.url!==r[n].url&&this.setImportUrl(t,i.url),e.bn(i.config,r[n].config)||this.setImportConfig(t,i.config),e.bn(i.data,r[n].data)||this.setImportData(t,i.data),this)}moveImport(e,t){this._checkLoaded();let i=this.stylesheet.imports||[];const r=this.getImportIndex(e);if(-1===r)return this;const n=this.getImportIndex(t);if(-1===n)return this;const o=i[r],s=this.fragments[r];return i=i.filter((({id:t})=>t!==e)),this.fragments=this.fragments.filter((({id:t})=>t!==e)),this.stylesheet.imports=i.slice(0,n).concat(o).concat(i.slice(n)),this.fragments=this.fragments.slice(0,n).concat(s).concat(this.fragments.slice(n)),this.mergeLayers(),this}setImportUrl(e,t){this._checkLoaded();const i=this.stylesheet.imports||[],r=this.getImportIndex(e);if(-1===r)return this;i[r].url=t;const n=this.fragments[r];return n.style=this._createFragmentStyle(i[r]),n.style.on("style.import.load",(()=>this.mergeAll())),n.style.loadURL(t),this}setImportData(e,t){this._checkLoaded();const i=this.getImportIndex(e),r=this.stylesheet.imports||[];return-1===i?this:t?(this.fragments[i].style.setState(t),this._reloadImports(),this):(delete r[i].data,this.setImportUrl(e,r[i].url))}setImportConfig(e,t){this._checkLoaded();const i=this.getImportIndex(e),r=this.stylesheet.imports||[];if(-1===i)return this;t?r[i].config=t:delete r[i].config;const n=this.fragments[i],o=n.style.stylesheet&&n.style.stylesheet.schema;return n.config=t,n.style.updateConfig(t,o),this.updateConfigDependencies(),this}removeImport(e){this._checkLoaded();const t=this.stylesheet.imports||[],i=this.getImportIndex(e);-1!==i&&(t.splice(i,1),this.fragments[i].style._remove(),this.fragments.splice(i,1),this._reloadImports())}getImportIndex(t){const i=(this.stylesheet.imports||[]).findIndex((e=>e.id===t));return-1===i&&this.fire(new e.y(new Error(`Import '${t}' does not exist in the map's style and cannot be updated.`))),i}getLayer(e){return this._mergedLayers[e]}getSources(){const e=[];for(const t in this._mergedOtherSourceCaches){const i=this._mergedOtherSourceCaches[t];i&&e.push(i.getSource())}return e}getSource(e,t){const i=this.getSourceCache(e,t);return i&&i.getSource()}getLayerSource(e){const t=this.getLayerSourceCache(e);return t&&t.getSource()}getSourceCache(t,i){const r=e.aC(t,i);return this._mergedOtherSourceCaches[r]}getLayerSourceCache(t){const i=e.aC(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 r=e=>{e&&e.setDependencies(t.tileID.key,t.type,t.icons)};r(this._otherSourceCaches[t.source]),r(this._symbolSourceCaches[t.source])}rasterizeImages(e,t,i){this.imageManager.rasterizeImages(t,i)}getGlyphs(e,t,i){this.glyphManager.getGlyphs(t.stacks,t.scope,i)}getResource(t,i,r){return e.cy(i,r)}getOwnSourceCache(e){return this._otherSourceCaches[e]}getOwnLayerSourceCache(e){return"symbol"===e.type?this._symbolSourceCaches[e.source]:this._otherSourceCaches[e.source]}getOwnSourceCaches(e){const t=[];return this._otherSourceCaches[e]&&t.push(this._otherSourceCaches[e]),this._symbolSourceCaches[e]&&t.push(this._symbolSourceCaches[e]),t}_isSourceCacheLoaded(t){const i=this.getOwnSourceCaches(t);return 0===i.length?(this.fire(new e.y(new Error(`There is no source with ID '${t}'`))),!1):i.every((e=>e.loaded()))}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}isLayerClipped(e,t){if(!this._clipLayerPresent&&"fill-extrusion"!==e.type)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)}}Mr.getSourceType=function(e){return it[e]},Mr.setSourceType=function(e,t){it[e]=t},Mr.registerForPluginStateChange=e.ch;var Er="\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",Ar="\nout vec4 glFragColor;highp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\n#ifdef INDICATOR_CUTOUT\nuniform vec3 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params;\n#endif\nvec4 applyCutout(vec4 color,float height) {\n#ifdef INDICATOR_CUTOUT\nfloat verticalFadeRange=u_indicator_cutout_centers.z*0.25;float holeMinOpacity=mix(1.0,u_indicator_cutout_params.x,smoothstep(u_indicator_cutout_centers.z,u_indicator_cutout_centers.z+verticalFadeRange,height));float holeRadius=max(u_indicator_cutout_params.y,0.0);float holeAspectRatio=u_indicator_cutout_params.z;float fadeStart=u_indicator_cutout_params.w;float distA=distance(vec2(gl_FragCoord.x,gl_FragCoord.y*holeAspectRatio),vec2(u_indicator_cutout_centers[0],u_indicator_cutout_centers[1]*holeAspectRatio));return color*min(smoothstep(fadeStart,holeRadius,distA)+holeMinOpacity,1.0);\n#else\nreturn color;\n#endif\n}\n#ifdef DEBUG_WIREFRAME\n#define HANDLE_WIREFRAME_DEBUG \\\nglFragColor=vec4(0.7,0.0,0.0,0.7); \\\ngl_FragDepth=gl_FragCoord.z-0.0001;\n#else\n#define HANDLE_WIREFRAME_DEBUG\n#endif\n#ifdef RENDER_CUTOFF\nuniform highp vec4 u_cutoff_params;in float v_cutoff_opacity;\n#endif\nvec4 textureLodCustom(sampler2D image,highp vec2 pos,highp vec2 lod_coord) {highp vec2 size=vec2(textureSize(image,0));highp vec2 dx=dFdx(lod_coord.xy*size);highp vec2 dy=dFdy(lod_coord.xy*size);highp float delta_max_sqr=max(dot(dx,dx),dot(dy,dy));highp float lod=0.5*log2(delta_max_sqr);return textureLod(image,pos,lod);}vec4 applyLUT(highp sampler3D lut,vec4 col) {vec3 size=vec3(textureSize(lut,0));vec3 uvw=(col.rbg*float(size-1.0)+0.5)/size;return vec4(texture(lut,uvw).rgb,col.a);}vec3 applyLUT(highp sampler3D lut,vec3 col) {return applyLUT(lut,vec4(col,1.0)).rgb;}",Ir="\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);}",Cr="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;}",Pr="\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",zr="#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;out vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}\n#endif",Dr="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",Rr="#ifdef RASTER_ARRAY\nuniform highp sampler2D u_image0;uniform sampler2D u_image1;const vec4 NODATA=vec4(1);ivec4 _raTexLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}vec2 _raTexLinearMix(highp vec2 fxy,highp vec4 colorMix,highp float colorOffset,highp vec4 t00,highp vec4 t10,highp vec4 t01,highp vec4 t11) {vec2 c00=t00==NODATA ? vec2(0) : vec2(colorOffset+dot(t00,colorMix),1);vec2 c10=t10==NODATA ? vec2(0) : vec2(colorOffset+dot(t10,colorMix),1);vec2 c01=t01==NODATA ? vec2(0) : vec2(colorOffset+dot(t01,colorMix),1);vec2 c11=t11==NODATA ? vec2(0) : vec2(colorOffset+dot(t11,colorMix),1);return mix(mix(c01,c11,fxy.x),mix(c00,c10,fxy.x),fxy.y);}vec2 raTexture2D_image0_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image0,c.yz,0),texelFetch(u_image0,c.xz,0),texelFetch(u_image0,c.yw,0),texelFetch(u_image0,c.xw,0)\n);}vec2 raTexture2D_image1_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image1,c.yz,0),texelFetch(u_image1,c.xz,0),texelFetch(u_image1,c.yw,0),texelFetch(u_image1,c.xw,0)\n);}vec2 raTexture2D_image0_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image0,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}vec2 raTexture2D_image1_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image1,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}\n#endif",Lr="#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;}",Or="#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",kr="#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 TEXTURE_GATHER\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.w;vec2 abs_bounds=abs(light_view_pos0.xy);if (abs_bounds.x >=1.0 || abs_bounds.y >=1.0) {return 0.0;}light_view_pos0.xyz=light_view_pos0.xyz*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));}highp vec2 compute_receiver_plane_depth_bias(highp vec3 pos_dx,highp vec3 pos_dy)\n{highp vec2 biasUV=vec2(\npos_dy.y*pos_dx.z-pos_dx.y*pos_dy.z,pos_dx.x*pos_dy.z-pos_dy.x*pos_dx.z);biasUV*=1.0/((pos_dx.x*pos_dy.y)-(pos_dx.y*pos_dy.x));return biasUV;}float shadowed_light_factor_plane_bias(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {highp vec3 light_view_pos0_xyz=light_view_pos0.xyz/light_view_pos0.w*0.5+0.5;highp vec3 light_view_pos0_ddx=dFdx(light_view_pos0_xyz);highp vec3 light_view_pos0_ddy=dFdy(light_view_pos0_xyz);highp vec2 plane_depth_bias=compute_receiver_plane_depth_bias(light_view_pos0_ddx,light_view_pos0_ddy);highp float bias=dot(vec2(u_shadow_texel_size,u_shadow_texel_size),plane_depth_bias)+0.0001;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadowed_light_factor(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadow_occlusion(float ndotl,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=calculate_shadow_bias(ndotl);return shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);}\n#endif";const Fr=[];Gr(Er,Fr),Gr(Ir,Fr),Gr(Ar,Fr);const Br={"_prelude_fog.vertex.glsl":zr,"_prelude_terrain.vertex.glsl":Pr,"_prelude_shadow.vertex.glsl":Or,"_prelude_fog.fragment.glsl":Dr,"_prelude_shadow.fragment.glsl":kr,"_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":Rr,"_prelude_raster_particle.glsl":Lr},Nr={};qr("",Pr),qr(Dr,zr),qr(kr,Or),qr(Rr,""),qr(Lr,"");const Vr=qr(Ar,Ir),Ur=Er;var jr={background:qr('#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:qr('#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:qr('#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:qr("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:qr('#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:qr("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:qr("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:qr("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:qr("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:qr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nuniform float u_emissive_strength;\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#endif\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec4 out_color=color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nout_color*=opacity;\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,v_z_offset);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin vec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#endif\nuniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp float z_offset\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=z_offset;\n#endif\n}'),fillOutline:qr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nin highp vec2 v_pos;uniform float u_emissive_strength;\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin vec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\nuniform mat4 u_matrix;uniform vec2 u_world;out highp vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp float z_offset\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillOutlinePattern:qr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_emissive_strength;\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\nin highp vec2 v_pos;in highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\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#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\nout highp vec2 v_pos;out highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#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 RENDER_SHADOWS\nvec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillPattern:qr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;in highp vec2 v_pos;uniform float u_emissive_strength;\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#pragma mapbox: define 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#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\nout highp vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#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 RENDER_SHADOWS\nvec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillExtrusion:qr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec4 v_color;in vec4 v_flat;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;\n#endif\nuniform lowp float u_opacity;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec2 v_ao;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nin vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nin highp vec3 v_normal;\n#endif\nuniform vec3 u_flood_light_color;uniform highp float u_vertical_scale;uniform float u_flood_light_intensity;uniform vec3 u_ground_shadow_factor;\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nin float v_flood_radius;in float v_has_floodlight;\n#endif\nin float v_height;\n#pragma mapbox: define highp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp float emissive_strength\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nvec3 normal=normalize(v_normal);\n#endif\nfloat z;vec4 color=v_color;\n#ifdef ZERO_ROOF_RADIUS\nz=float(normal.z > 0.00001);\n#ifdef LIGHTING_3D_MODE\nnormal=mix(normal,vec3(0.0,0.0,1.0),z);\n#else\ncolor=mix(v_color,v_roof_color,z);\n#endif\n#endif\nfloat h=max(0.0,v_height);float ao_shade=1.0;\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h_floors=h/(u_ao[1]*u_vertical_scale);float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);ao_shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;\n#ifdef ZERO_ROOF_RADIUS\nconcave*=(1.0-z);\n#endif\nfloat x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);ao_shade*=mix(1.0,x_shade*x_shade*x_shade,concave);\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\ncolor.rgb*=mix(ao_shade,1.0,v_has_floodlight);\n#else\ncolor.rgb*=ao_shade;\n#endif\n#else\ncolor.rgb*=ao_shade;\n#endif\n#endif\n#ifdef LIGHTING_3D_MODE\nfloat flood_radiance=0.0;\n#ifdef FLOOD_LIGHT\nflood_radiance=(1.0-min(h/v_flood_radius,1.0))*u_flood_light_intensity*v_has_floodlight;\n#endif\n#ifdef RENDER_SHADOWS\n#ifdef FLOOD_LIGHT\nfloat ndotl_unclamped=dot(normal,u_shadow_direction);float ndotl=max(0.0,ndotl_unclamped);float occlusion=ndotl_unclamped < 0.0 ? 1.0 : shadow_occlusion(ndotl,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 litColor=apply_lighting(color.rgb,normal,(1.0-u_shadow_intensity*occlusion)*ndotl);vec3 floodLitColor=compute_flood_lighting(u_flood_light_color*u_opacity,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=mix(litColor,floodLitColor,flood_radiance);\n#else\nfloat shadowed_lighting_factor;\n#ifdef RENDER_CUTOFF\nshadowed_lighting_factor=shadowed_light_factor_normal_opacity(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;}\n#else\nshadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);\n#endif\ncolor.rgb=apply_lighting(color.rgb,normal,shadowed_lighting_factor);\n#endif\n#else\ncolor.rgb=apply_lighting(color.rgb,normal);\n#ifdef FLOOD_LIGHT\ncolor.rgb=mix(color.rgb,u_flood_light_color*u_opacity,flood_radiance);\n#endif\n#endif\ncolor.rgb=mix(color.rgb,v_flat.rgb,emissive_strength);color*=u_opacity;\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,h));\n#endif\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color,h);\n#endif\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\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\n#endif\nuniform highp float u_vertical_scale;out vec4 v_color;out vec4 v_flat;\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nout vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nout highp vec3 v_normal;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec2 v_ao;\n#endif\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nout float v_flood_radius;out float v_has_floodlight;\n#endif\nout float v_height;vec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define highp float flood_light_wall_radius\n#pragma mapbox: define highp float line_width\n#pragma mapbox: define highp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize highp float flood_light_wall_radius\n#pragma mapbox: initialize highp float line_width\n#pragma mapbox: initialize highp float emissive_strength\nbase*=u_vertical_scale;height*=u_vertical_scale;vec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nv_normal=normal;\n#endif\nbase=max(0.0,base);float attr_height=height;height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=0.0;float c_ele=0.0;vec3 pos;\n#ifdef TERRAIN\nbool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);c_ele=is_flat_height || is_flat_base ? (centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_base;pos=vec3(pos_nx.xy,h);\n#else\nh=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat cutoff=1.0;vec3 scaled_pos=pos;\n#ifdef RENDER_CUTOFF\nvec3 centroid_random=vec3(centroid_pos.xy,centroid_pos.x+centroid_pos.y+1.0);vec3 ground_pos=centroid_pos.x==0.0 ? pos.xyz : (centroid_random/8.0);vec4 ground=u_matrix*vec4(ground_pos.xy,ele,1.0);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);float ndotl=calculate_NdotL(normal);v_flat.rgb=sRGBToLinear(color.rgb);v_flat.rgb=v_flat.rgb*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);v_flat=vec4(linearTosRGB(v_flat.rgb),1.0);\n#else\nv_color=vec4(0.0,0.0,0.0,1.0);v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nfloat roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color=vec4(0.0,0.0,0.0,1.0);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_roof_color*=u_opacity;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),fillExtrusionDepth:qr("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;\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\n#endif\nin vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef RENDER_WALL_MODE\nin vec3 a_join_normal_inside;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp float line_width\n#pragma mapbox: define highp vec4 color\nout highp float v_depth;void main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp float line_width\n#pragma mapbox: initialize highp vec4 color\nbase*=u_vertical_scale;height*=u_vertical_scale;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nvec3 pos;\n#ifdef TERRAIN\nbool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;float ele=elevation(pos_nx.xy);float c_ele=is_flat_height || is_flat_base ? (centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);float h=t > 0.0 ? max(h_base,h_height) : h_base;pos=vec3(pos_nx.xy,h);\n#else\npos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\n#ifdef RENDER_WALL_MODE\nvec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);pos.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;pos.xy-=a_join_normal_inside.z*wall_offset*0.5;\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.0));gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);v_depth=gl_Position.z/gl_Position.w;}'),fillExtrusionPattern:qr('#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,height);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_lighting.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_width_scale;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef RENDER_WALL_MODE\nin vec3 a_join_normal_inside;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\n#endif\nout highp vec2 v_pos;out vec4 v_lighting;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nout vec3 v_normal;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump vec4 pattern\n#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 highp vec4 color\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 is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);c_ele=is_flat_height || is_flat_base ? (centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_base;p=vec3(pos_nx.xy,h);\n#else\np=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\n#ifdef RENDER_WALL_MODE\nvec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);p.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;p.xy-=a_join_normal_inside.z*wall_offset*0.5;\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.0));gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0\n? pos_nx.xy\n: vec2(edgedistance,z*u_height_factor);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0;\n#ifdef LIGHTING_3D_MODE\nNdotL=calculate_NdotL(normal);\n#else\nNdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);\n#endif\nif (normal.y !=0.0) {float r=0.84;\n#ifndef LIGHTING_3D_MODE\nr=mix(0.7,0.98,1.0-u_lightintensity);\n#endif\nNdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\nv_normal=normal;\n#else\nv_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#endif \n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}'),groundShadow:qr('#include "_prelude_shadow.fragment.glsl"\nprecision highp float;uniform vec3 u_ground_shadow_factor;in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\nvoid main() {float light=shadowed_light_factor_plane_bias(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 shadow=mix(u_ground_shadow_factor,vec3(1.0),light);\n#ifdef RENDER_CUTOFF\nshadow=mix(vec3(1.0),shadow,cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w));\n#endif\n#ifdef FOG\nshadow=mix(shadow,vec3(1.0),v_fog_opacity);\n#endif\n#ifdef INDICATOR_CUTOUT\nshadow=mix(shadow,vec3(1.0),1.0-applyCutout(vec4(1.0),0.0).r);\n#endif\nglFragColor=vec4(shadow,1.0);}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;in vec2 a_pos;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;\n#ifdef FOG\nout float v_fog_opacity;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0.0,1.0);v_pos_light_view_0=u_light_matrix_0*vec4(a_pos,0.0,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(a_pos,0.0,1.0);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);v_fog_opacity=fog(v_fog_pos);\n#endif\n}'),fillExtrusionGroundEffect:qr("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:qr("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:qr('#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:qr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform lowp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_floor_width_scale;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform lowp vec4 u_trim_color;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec4 v_uv;\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;in vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\nfloat luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}uniform float u_emissive_strength;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\nfloat linearstep(float edge0,float edge1,float x) {return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\nfloat dist=length(v_normal)*v_width2.s;float blur2=(u_width_scale*blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist=texture(u_dash_image,v_tex).r;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;float scaled_floorwidth=(floorwidth*u_floor_width_scale);alpha*=linearstep(0.5-sdfgamma/scaled_floorwidth,0.5+sdfgamma/scaled_floorwidth,sdfdist);\n#endif\nhighp vec4 out_color;\n#ifdef RENDER_LINE_GRADIENT\nout_color=texture(u_gradient_image,v_uv.xy);\n#else\nout_color=color;\n#endif\nfloat trim_alpha=1.0;\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float 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=1.0-transition_factor;}\n#endif\nif (u_alpha_discard_threshold !=0.0) {if (alpha < u_alpha_discard_threshold) {discard;}}\n#ifdef RENDER_LINE_BORDER\nfloat edgeBlur=((border_width*u_width_scale)+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);if (border_color.a==0.0) {float Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}} else {out_color=mix(border_color*trim_alpha,out_color,smoothAlpha);}}\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#ifdef ELEVATED_ROADS\nout_color.rgb*=mix(v_road_z_offset > 0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#else\nout_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nout_color*=(alpha*opacity);\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,v_z_offset);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define EXTRUDE_SCALE 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS) || defined(VARIABLE_LINE_WIDTH)\nin vec2 a_z_offset_width;\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;uniform float u_width_scale;uniform highp float u_floor_width_scale;\n#ifdef ELEVATED\nuniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) {\n#ifdef ELEVATION_REFERENCE_SEA\nreturn 0.0;\n#else\nreturn elevation(apos);\n#endif\n}\n#endif\nout vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec4 v_uv;\n#ifdef ELEVATED_ROADS\nout highp float v_road_z_offset;\n#endif\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform float u_tile_units_to_pixels;out vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\nfloat a_z_offset;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\na_z_offset=a_z_offset_width.x;\n#endif\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth;\n#ifdef VARIABLE_LINE_WIDTH\nhalfwidth=(u_width_scale*a_z_offset_width.y)/2.0;\n#else\nhalfwidth=(u_width_scale*width)/2.0;\n#endif\noffset=-1.0*offset*u_width_scale;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy;\n#ifdef ELEVATED_ROADS\nv_road_z_offset=a_z_offset;gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset+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 offset_pos=pos+offsetTile;float ele=0.0;\n#ifdef CROSS_SLOPE_VERTICAL\nfloat top=a_pos_normal.y-2.0*floor(a_pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+a_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0);\n#else\n#ifdef CROSS_SLOPE_HORIZONTAL\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+a_z_offset;\n#else\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+a_z_offset;\n#endif\n#endif\ngl_Position=u_matrix*vec4(offset_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden);\n#else\ngl_Position=mix(u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude,AWAY,hidden);\n#endif\n#endif\n#ifdef ELEVATED_ROADS\n#ifdef RENDER_SHADOWS\nvec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos;\n#ifdef NORMAL_OFFSET\nvec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#endif\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude_xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur));\n#else\nv_gamma_scale=1.0;\n#endif\n#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*u_floor_width_scale),(-normal.y*height+dash.x+0.5)/u_texsize.y);\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=a_z_offset;\n#endif\n}'),linePattern:qr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform highp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_alpha_discard_threshold;uniform highp vec2 u_texsize;uniform highp float u_tile_units_to_pixels;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform lowp vec4 u_trim_color;uniform sampler2D u_image;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 ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef LINE_JOIN_NONE\nin vec2 v_pattern_data;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\nuniform float u_emissive_strength;\n#pragma mapbox: define mediump vec4 pattern\n#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;highp float pattern_size=display_size.x/u_tile_units_to_pixels;float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(u_width_scale*blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);highp float pattern_x=v_linesofar/pattern_size*aspect;highp float x=mod(pattern_x,1.0);highp float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;highp vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));highp vec2 lod_pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(pattern_x,y));vec4 color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef 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);color=mix(color,color.a*u_trim_color,transition_factor);}\n#endif\n#ifdef LINE_JOIN_NONE\nhighp float pattern_len=pattern_size/aspect;highp float segment_phase=pattern_len-mod(v_linesofar-v_pattern_data.x+pattern_len,pattern_len);highp float visible_start=segment_phase-step(pattern_len*0.5,segment_phase)*pattern_len;highp float visible_end=floor((v_pattern_data.y-segment_phase)/pattern_len)*pattern_len+segment_phase;visible_end+=step(pattern_len*0.5,v_pattern_data.y-visible_end)*pattern_len;if (v_pattern_data.x < visible_start || v_pattern_data.x >=visible_end) {color=vec4(0.0);}\n#endif\n#ifdef LIGHTING_3D_MODE\ncolor=apply_lighting_with_emission_ground(color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#ifdef ELEVATED_ROADS\ncolor.rgb*=mix(v_road_z_offset > 0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#else\ncolor.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=(alpha*opacity);if (u_alpha_discard_threshold !=0.0) {if (color.a < u_alpha_discard_threshold) {discard;}}\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color,v_z_offset);\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\nin vec2 a_z_offset_width;\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\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#endif\nuniform mat4 u_matrix;uniform float u_tile_units_to_pixels;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform float u_device_pixel_ratio;uniform float u_width_scale;uniform float u_floor_width_scale;\n#ifdef ELEVATED\nuniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) {\n#ifdef ELEVATION_REFERENCE_SEA\nreturn 0.0;\n#else\nreturn elevation(apos);\n#endif\n}\n#endif\nout vec2 v_normal;out vec2 v_width2;out highp float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nout highp vec4 v_uv;\n#endif\n#ifdef ELEVATED_ROADS\nout highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\n#pragma mapbox: define mediump float blur\n#pragma mapbox: define mediump float opacity\n#pragma mapbox: define mediump float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define mediump float floorwidth\n#pragma mapbox: define mediump vec4 pattern\n#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 a_z_offset;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\na_z_offset=a_z_offset_width.x;\n#endif\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=(u_width_scale*width)/2.0;offset=-1.0*offset*u_width_scale;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);vec2 dist=outset*a_extrude*scale;float u=0.5*a_direction;float t=1.0-abs(u);vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy;\n#ifdef ELEVATED_ROADS\nv_road_z_offset=a_z_offset;gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset+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 offset_pos=pos+offsetTile;float ele=0.0;\n#ifdef CROSS_SLOPE_VERTICAL\nfloat top=a_pos_normal.y-2.0*floor(a_pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+a_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0);\n#else\n#ifdef CROSS_SLOPE_HORIZONTAL\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+a_z_offset;\n#else\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+a_z_offset;\n#endif\n#endif\ngl_Position=u_matrix*vec4(offset_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden);\n#else\ngl_Position=mix(u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude,AWAY,hidden);\n#endif\n#endif\n#ifdef ELEVATED_ROADS\n#ifdef RENDER_SHADOWS\nvec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos;\n#ifdef NORMAL_OFFSET\nvec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#endif\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude_xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur));\n#else\nv_gamma_scale=1.0;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\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*u_floor_width_scale);\n#ifdef LINE_JOIN_NONE\nv_width=(floorwidth*u_floor_width_scale)+ANTIALIASING;mediump float pixels_to_tile_units=1.0/u_tile_units_to_pixels;mediump float pixel_ratio_inverse=1.0/pixel_ratio;mediump float aspect=v_width/((pattern.w-pattern.y)*pixel_ratio_inverse);highp float subt_multiple=(pattern.z-pattern.x)*pixel_ratio_inverse*pixels_to_tile_units*aspect*32.0;highp float subt=floor(a_pattern_data.z/subt_multiple)*subt_multiple;float offset_sign=(fract(a_pattern_data.x)-0.5)*4.0;float line_progress_offset=offset_sign*v_width*0.5*pixels_to_tile_units;v_linesofar=(a_pattern_data.z-subt)+a_linesofar+line_progress_offset;v_pattern_data=vec2(a_pattern_data.x+line_progress_offset,a_pattern_data.y);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=a_z_offset;\n#endif\n}'),raster:qr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_raster_array.glsl"\nuniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;uniform highp float u_zoom_transition;in vec2 v_pos0;in vec2 v_pos1;in float v_depth;\n#ifdef PROJECTION_GLOBE_VIEW\nin float v_split_fade;\n#endif\nuniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;uniform float u_emissive_strength;\n#ifndef RASTER_ARRAY\nuniform highp sampler2D u_image0;uniform sampler2D u_image1;\n#endif\n#ifdef RASTER_COLOR\nuniform sampler2D u_color_ramp;uniform highp vec4 u_colorization_mix;uniform highp float u_colorization_offset;uniform vec2 u_texture_res;\n#endif\nvoid main() {vec4 color0,color1,color;vec2 value;\n#ifdef RASTER_COLOR\n#ifdef RASTER_ARRAY\n#ifdef RASTER_ARRAY_LINEAR\nvalue=mix(\nraTexture2D_image0_linear(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_linear(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t\n);\n#else\nvalue=mix(\nraTexture2D_image0_nearest(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_nearest(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t\n);\n#endif\nif (value.y > 0.0) value.x/=value.y;\n#else\ncolor=mix(texture(u_image0,v_pos0),texture(u_image1,v_pos1),u_fade_t);value=vec2(u_colorization_offset+dot(color.rgb,u_colorization_mix.rgb),color.a);\n#endif\ncolor=texture(u_color_ramp,vec2(value.x,0.5));if (color.a > 0.0) color.rgb/=color.a;color.a*=value.y;\n#else\ncolor0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);\n#endif\ncolor.a*=u_opacity;\n#ifdef GLOBE_POLES\ncolor.a*=1.0-smoothstep(0.0,0.05,u_zoom_transition);\n#endif\nvec3 rgb=color.rgb;rgb=vec3(\ndot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),u_emissive_strength).rgb;\n#endif\n#ifdef FOG\nhighp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit));\n#endif\nglFragColor=vec4(out_color*color.a,color.a);\n#ifdef PROJECTION_GLOBE_VIEW\nglFragColor*=mix(1.0,1.0-smoothstep(0.0,0.05,u_zoom_transition),smoothstep(0.8,0.9,v_split_fade));\n#endif\n#ifdef RENDER_CUTOFF\nglFragColor=glFragColor*cutoff_opacity(u_cutoff_params,v_depth);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;uniform vec2 u_texture_offset;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center;\n#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin vec2 a_pos;in vec2 a_texture_pos;\n#endif\nout vec2 v_pos0;out vec2 v_pos1;out float v_depth;\n#ifdef PROJECTION_GLOBE_VIEW\nout float v_split_fade;\n#endif\nvoid main() {vec2 uv;\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos ,1.0);uv=a_uv;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz);\n#endif\n#else\nfloat w=1.0+dot(a_texture_pos,u_perspective_transform);uv=a_texture_pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]); \nv_split_fade=0.0;if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,u_raster_elevation,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;float opposite_merc_center=mod(u_merc_center.x+0.5,1.0);float dist_from_poles=(abs(mercatorY-0.5)*2.0);float range=0.1;v_split_fade=abs(opposite_merc_center-mercatorX);v_split_fade=clamp(1.0-v_split_fade,0.0,1.0);v_split_fade=max(smoothstep(1.0-range,1.0,dist_from_poles),max(smoothstep(1.0-range,1.0,v_split_fade),smoothstep(1.0-range,1.0,1.0-v_split_fade)));}float tiles=u_grid_matrix[0][2];if (tiles > 0.0) {float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvY=mercatorY*tiles-idy;float uvX=mercatorX*tiles-idx;uv=vec2(uvX,uvY);}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition)*w,w);gl_Position=u_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n#else\ngl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation*w,w);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n#endif\n#endif\nv_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;v_pos0=u_texture_offset.x+u_texture_offset.y*v_pos0;v_pos1=u_texture_offset.x+u_texture_offset.y*v_pos1;\n#ifdef RENDER_CUTOFF\nv_depth=gl_Position.z;\n#endif\n}'),rasterParticle:qr('#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:qr("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:qr("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:qr('#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:qr('#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;uniform lowp float u_scale_factor;\n#ifdef ICON_TRANSITION\nuniform float u_icon_transition;\n#endif\n#ifdef COLOR_ADJUSTMENT\nuniform mat4 u_color_adj_mat;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#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*u_scale_factor*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width*u_scale_factor/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,v_tex_a).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);out_color*=alpha;\n#else\n#ifdef ICON_TRANSITION\nvec4 a=texture(u_texture,v_tex_a)*(1.0-u_icon_transition);vec4 b=texture(u_texture,v_tex_b)*u_icon_transition;out_color=(a+b);\n#else\nout_color=texture(u_texture,v_tex_a);\n#endif\n#ifdef 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\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,v_z_offset);\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\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\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#ifdef INDICATOR_CUTOUT\nv_z_offset=e;\n#endif\n}'),terrainRaster:qr('#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:qr("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:qr('#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}',Cr),skyboxGradient:qr('#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}',Cr),skyboxCapture:qr("\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:qr('#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:qr('#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:qr('#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,v_position_height.w);\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:qr("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:qr("in highp vec2 v_uv;in mediump float v_intensity;float shapeCircle(in vec2 uv)\n{float beginFade=0.6;float lengthFromCenter=length(v_uv);return 1.0-clamp((lengthFromCenter-beginFade)/(1.0-beginFade),0.0,1.0);}void main() {float alpha=shapeCircle(v_uv);vec3 color=vec3(1.0,1.0,1.0);alpha*=v_intensity;glFragColor=vec4(color*alpha,alpha);HANDLE_WIREFRAME_DEBUG;}","\nin vec3 a_pos_3f;in vec2 a_uv;in float a_size_scale;in float a_fade_opacity;uniform mat4 u_matrix;uniform vec3 u_up;uniform vec3 u_right;uniform float u_intensity_multiplier;out highp vec2 v_uv;out mediump float v_intensity;void main() {v_uv=a_uv;v_intensity=a_fade_opacity*u_intensity_multiplier;vec3 pos=a_pos_3f;pos+=a_uv.x*u_right*a_size_scale;pos+=a_uv.y*u_up*a_size_scale;gl_Position=u_matrix*vec4(pos,1.0);}"),snowParticle:qr("in highp vec2 uv;in highp float alphaMultiplier;uniform vec4 u_particleColor;uniform vec2 u_simpleShapeParameters;void main() {float t=clamp((length(uv)-u_simpleShapeParameters.x)/(1.0-u_simpleShapeParameters.x),0.0,1.0);float alpha=1.0-pow(t,pow(10.0,u_simpleShapeParameters.y));alpha*=alphaMultiplier;alpha*=u_particleColor.a;vec3 color=u_particleColor.rgb*alpha;glFragColor=vec4(color,alpha) ;HANDLE_WIREFRAME_DEBUG;}","\nin highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_snowParticleData;in highp vec4 a_snowParticleDataHorizontalOscillation;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform vec2 u_screenSize;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; \nuniform float u_velocity;uniform vec3 u_direction;uniform float u_horizontalOscillationRadius; \nuniform float u_horizontalOscillationRate; \nuniform float u_billboardSize;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;out highp vec2 uv;out highp float alphaMultiplier;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos.xyz*=halfBoxSize;pos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_snowParticleData.z;float coneAngleHeadingRad=a_snowParticleData.w*radians(360.0);vec3 localZ=normalize(u_direction);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 direction;direction.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.z=cos(coneAnglePichRad);direction=normalize(direction);vec3 simPosLocal=vec3(0,0,0);float velocityScale=(1.0+3.0*a_snowParticleData.y)*u_velocity;simPosLocal+=direction*velocityScale*u_time;float horizontalOscillationRadius=u_horizontalOscillationRadius*a_snowParticleDataHorizontalOscillation.x;float horizontalOscillationAngle=u_horizontalOscillationRate*u_time*(-1.0+2.0*a_snowParticleDataHorizontalOscillation.y);simPosLocal.xy+=horizontalOscillationRadius*vec2(cos(horizontalOscillationAngle),sin(horizontalOscillationAngle));vec3 simPos=localX*simPosLocal.x+\nlocalY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);float clipZ=-u_cam_pos.z+pos.z;vec4 posView=u_modelview*vec4(pos,1.0);float size=u_billboardSize;alphaMultiplier=1.0;vec4 posScreen=u_projection*posView;posScreen/=posScreen.w;posScreen.xy=vec2(0.5)+posScreen.xy*0.5;posScreen.xy*=u_screenSize;vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=u_screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-posScreen.xy)/(0.5*u_screenSize));screenDist+=a_snowParticleData.x*u_thinningParticleOffset;float scaleFactorMode=0.0;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);if (a_snowParticleData.x < u_thinningAffectedRatio) {scaleFactorMode=1.0-thinningFadeRatio;alphaMultiplier=thinningFadeRatio;}}vec4 posScreen1=u_projection*vec4(posView.x-size,posView.yzw);posScreen1/=posScreen1.w;vec4 posScreen2=u_projection*vec4(posView.x+size,posView.yzw);posScreen2/=posScreen2.w;posScreen1.xy=vec2(0.5)+posScreen1.xy*0.5;posScreen1.xy*=u_screenSize;posScreen2.xy=vec2(0.5)+posScreen2.xy*0.5;posScreen2.xy*=u_screenSize;float screenLength=length(posScreen1.xy-posScreen2.xy);float screenEpsilon=3.0;float scaleFactor=1.0;if (screenLength < screenEpsilon) {scaleFactor=screenEpsilon/max(screenLength,0.01);scaleFactor=mix(scaleFactor,1.0,scaleFactorMode);}float screenEpsilon2=15.0;if (screenLength > screenEpsilon2) {scaleFactor=screenEpsilon2/max(screenLength,0.01);}size*=scaleFactor;vec2 right=size*vec2(1,0);vec2 up=size*vec2(0,1);posView.xy+=right*a_uv.x;posView.xy+=up*a_uv.y;uv=a_uv;gl_Position=u_projection*posView;}"),rainParticle:qr("in highp vec2 uv;in highp float particleRandomValue;uniform sampler2D u_texScreen;uniform float u_distortionStrength;uniform vec4 u_color;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;uniform float u_shapeDirectionalPower;uniform float u_mode;void main() {vec2 st=uv*0.5+vec2(0.5);vec2 uvm=uv;uvm.y=-1.0+2.0*pow(st.y,u_shapeDirectionalPower);float shape=clamp(1.0-length(uvm),0.0,1.0);float alpha=abs(shape)*u_color.a;vec2 screenSize=vec2(textureSize(u_texScreen,0));vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-gl_FragCoord.xy)/(0.5*screenSize));screenDist+=(0.5+0.5*particleRandomValue)*u_thinningParticleOffset;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;float thinningAlpha=1.0;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);thinningAlpha*=thinningFadeRatio;}vec2 offsetXY=normalize(uvm)*abs(shape);vec2 stScreen=(gl_FragCoord.xy+offsetXY*u_distortionStrength*thinningAlpha)/screenSize;vec3 colorScreen=texture(u_texScreen,stScreen).rgb;alpha*=thinningAlpha;glFragColor=mix(vec4(colorScreen,1.0),vec4(u_color.rgb*alpha,alpha),u_mode);HANDLE_WIREFRAME_DEBUG;}","\nin highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_rainParticleData;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; \nuniform float u_velocity; \nuniform vec2 u_rainDropletSize;uniform vec3 u_rainDirection;out highp vec2 uv;out highp float particleRandomValue;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos*=halfBoxSize; \npos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_rainParticleData.z;float coneAngleHeadingRad=a_rainParticleData.w*radians(360.0);vec3 localZ=normalize(u_rainDirection);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 directionLocal;directionLocal.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.z=cos(coneAnglePichRad);directionLocal=normalize(directionLocal);vec3 directionWorld=localX*directionLocal.x+localY*directionLocal.y+localZ*directionLocal.z;float velocityScale=(1.0+3.0*a_rainParticleData.y)*u_velocity;vec3 simPosLocal=vec3(0,0,0);simPosLocal+=directionLocal*velocityScale*u_time;vec3 simPos=localX*simPosLocal.x+\nlocalY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);vec4 posView=u_modelview*vec4(pos,1.0);vec3 directionView=normalize((u_modelview*vec4(directionWorld,0.0)).xyz);vec3 side=cross(directionView,normalize(posView.xyz));posView.xyz+=side*a_uv.x*u_rainDropletSize.x;posView.xyz+=directionView*a_uv.y*u_rainDropletSize.y;uv=a_uv;particleRandomValue=a_rainParticleData.x;gl_Position=u_projection*posView;}"),vignette:qr("uniform vec3 u_vignetteShape;uniform vec4 u_vignetteColor;in vec2 st;void main() {float screenDist=length(st);float alpha=clamp((screenDist-u_vignetteShape.x)/u_vignetteShape.y,0.0,1.0);alpha=pow(alpha,u_vignetteShape.z)*u_vignetteColor.a;vec3 color=u_vignetteColor.rgb;glFragColor=vec4(color*alpha,alpha) ;}","in vec2 a_pos_2f;out vec2 st;void main() {st=a_pos_2f;gl_Position=vec4(a_pos_2f,0,1);}"),occlusion:qr("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 Gr(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 qr(e,t){const i=/#include\s+"([^"]+)"/g,r=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g;let n=t.match(/(attribute(\S*)|(^\s*|;)in) (highp |mediump |lowp )?([\w]+) ([\w]+)/gm);n&&(n=n.map((e=>{const t=e.split(" ");return t[t.length-1]})),n=[...new Set(n)]);const o={},s=[],a=[];if(e=e.replace(i,((e,t)=>(a.push(t),""))),(t=t.replace(i,((e,t)=>(s.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=[...Fr];Gr(e,l),Gr(t,l);for(const e of[...s,...a])Br[e]||console.error(`Undefined include: ${e}`),Nr[e]||(Nr[e]=[],Gr(Br[e],Nr[e])),l=[...l,...Nr[e]];return{fragmentSource:e=e.replace(r,((e,t,i,r,n)=>(o[n]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nin ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"initialize"===t?`\n#ifdef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = u_${n};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n in ${i} ${r} ${n};\n#endif\n`:"initialize-attribute"===t?"":void 0))),vertexSource:t=t.replace(r,((e,t,i,r,n)=>{const s="float"===r?"vec2":r,a=n.match(/color/)?"color":s;return"define-attribute-vertex-shader-only"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\nin ${i} ${r} a_${n};\n#endif\n`:o[n]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nin ${i} ${s} a_${n};\nout ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"initialize"===t?"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = unpack_mix_${a}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n in ${i} ${r} a_${n};\n out ${i} ${r} ${n};\n#endif\n`:"initialize-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n ${n} = a_${n};\n#endif\n`:void 0:"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nin ${i} ${s} a_${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"define-instanced"===t?"mat4"===a?`\n#ifdef INSTANCED_ARRAYS\nin vec4 a_${n}0;\nin vec4 a_${n}1;\nin vec4 a_${n}2;\nin vec4 a_${n}3;\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:`\n#ifdef INSTANCED_ARRAYS\nin ${i} ${s} a_${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"initialize-attribute-custom"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n ${i} ${r} ${n} = a_${n};\n#endif\n`:"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = unpack_mix_${a}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`})),staticAttributes:n,usedDefines:l,vertexIncludes:s,fragmentIncludes:a}}class Zr{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(e,t,i,r,n,o,s,a){this.context=e;let l=this.boundPaintVertexBuffers.length!==r.length;for(let e=0;!l&&e<r.length;e++)this.boundPaintVertexBuffers[e]!==r[e]&&(l=!0);let c=this.boundDynamicVertexBuffers.length!==s.length;for(let e=0;!c&&e<s.length;e++)this.boundDynamicVertexBuffers[e]!==s[e]&&(c=!0);if(!this.vao||this.boundProgram!==t||this.boundLayoutVertexBuffer!==i||l||c||this.boundIndexBuffer!==n||this.boundVertexOffset!==o)this.freshBind(t,i,r,n,o,s,a);else{e.bindVertexArrayOES.set(this.vao);for(const i of s)i&&(i.bind(),a&&i.instanceCount&&i.setVertexAttribDivisor(e.gl,t,a));n&&n.dynamicDraw&&n.bind()}}freshBind(e,t,i,r,n,o,s){const a=e.numAttributes,l=this.context,c=l.gl;this.vao&&this.destroy(),this.vao=l.gl.createVertexArray(),l.bindVertexArrayOES.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=t,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=r,this.boundVertexOffset=n,this.boundDynamicVertexBuffers=o,t.enableAttributes(c,e),t.bind(),t.setVertexAttribPointers(c,e,n);for(const t of i)t.enableAttributes(c,e),t.bind(),t.setVertexAttribPointers(c,e,n);for(const t of o)t&&(t.enableAttributes(c,e),t.bind(),t.setVertexAttribPointers(c,e,n),s&&t.instanceCount&&t.setVertexAttribDivisor(c,e,s));r&&r.bind(),l.currentNumAttributes=a}destroy(){this.vao&&(this.context.gl.deleteVertexArray(this.vao),this.vao=null)}}function $r(t,i){const r=Math.pow(2,i.canonical.z),n=i.canonical.y;return[new e.aa(0,n/r).toLngLat().lat,new e.aa(0,(n+1)/r).toLngLat().lat]}function Hr(t,i,r,n,o,s,a){const l=t.context,c=l.gl,h=r.hillshadeFBO;if(!h)return;t.prepareDrawTile();const u=t.isTileAffectedByFog(i),d=t.getOrCreateProgram("hillshade",{overrideFog:u});l.activeTexture.set(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,h.colorAttachment.get());const p=((t,i,r,n)=>{const o=r.paint.get("hillshade-shadow-color"),s="none"===r.paint.get("hillshade-shadow-color-use-theme").constantOr("default"),a=r.paint.get("hillshade-highlight-color"),l="none"===r.paint.get("hillshade-highlight-color-use-theme").constantOr("default"),c=r.paint.get("hillshade-accent-color"),h="none"===r.paint.get("hillshade-accent-color-use-theme").constantOr("default"),u=r.paint.get("hillshade-emissive-strength");let d=e.ai(r.paint.get("hillshade-illumination-direction"));if("viewport"===r.paint.get("hillshade-illumination-anchor"))d-=t.transform.angle;else if(t.style&&t.style.enable3dLights()&&t.style.directionalLight){const i=t.style.directionalLight.properties.get("direction"),r=e.cb(i.x,i.y,i.z);d=e.ai(r[1])}const p=!t.options.moving;return{u_matrix:n||t.transform.calculateProjMatrix(i.tileID.toUnwrapped(),p),u_image:0,u_latrange:$r(0,i.tileID),u_light:[r.paint.get("hillshade-exaggeration"),d],u_shadow:o.toRenderColor(s?null:r.lut),u_highlight:a.toRenderColor(l?null:r.lut),u_emissive_strength:u,u_accent:c.toRenderColor(h?null:r.lut)}})(t,r,n,t.terrain?i.projMatrix:null);t.uploadCommonUniforms(l,d,i.toUnwrapped());const{tileBoundsBuffer:f,tileBoundsIndexBuffer:m,tileBoundsSegments:_}=t.getTileBoundsBuffers(r);d.draw(t,c.TRIANGLES,o,s,a,Ui.disabled,p,n.id,f,m,_)}function Wr(t,i,r){if(!i.needsDEMTextureUpload)return;const n=t.context,o=n.gl;n.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||t.getTileTexture(r.stride);const s=r.getPixels();i.demTexture?i.demTexture.update(s,{premultiply:!1}):i.demTexture=new e.T(n,s,o.R32F,{premultiply:!1}),i.needsDEMTextureUpload=!1}function Xr(t,i,r){const n=t.context,o=n.gl;if(!i.dem)return;const s=i.dem;if(n.activeTexture.set(o.TEXTURE1),Wr(t,i,s),!i.demTexture)return;i.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE);const a=s.dim;n.activeTexture.set(o.TEXTURE0);let l=i.hillshadeFBO;if(!l){const t=new e.T(n,{width:a,height:a,data:null},o.RGBA8);t.bind(o.LINEAR,o.CLAMP_TO_EDGE),l=i.hillshadeFBO=n.createFramebuffer(a,a,!0,"renderbuffer"),l.colorAttachment.set(t.texture)}n.bindFramebuffer.set(l.framebuffer),n.viewport.set([0,0,a,a]);const{tileBoundsBuffer:c,tileBoundsIndexBuffer:h,tileBoundsSegments:u}=t.getMercatorTileBoundsBuffers(),d=[];t.linearFloatFilteringSupported()&&d.push("TERRAIN_DEM_FLOAT_FORMAT"),t.getOrCreateProgram("hillshadePrepare",{defines:d}).draw(t,o.TRIANGLES,ki.disabled,Bi.disabled,Oi.unblended,Ui.disabled,((t,i)=>{const r=i.stride,n=e.ab.mat4.create();return e.ab.mat4.ortho(n,0,e.ag,-e.ag,0,0,1),e.ab.mat4.translate(n,n,[0,-e.ag,0]),{u_matrix:n,u_image:1,u_dimension:[r,r],u_zoom:t.overscaledZ}})(i.tileID,s),r.id,c,h,u),i.needsHillshadePrepare=!1}class Yr{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 Kr extends Yr{getDefault(){return e.aj.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 Jr extends Yr{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class Qr extends Yr{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class en extends Yr{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 tn extends Yr{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class rn extends Yr{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class nn extends Yr{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 on extends Yr{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 sn extends Yr{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 an extends Yr{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 ln extends Yr{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 cn extends Yr{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class hn extends Yr{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 un extends Yr{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 dn extends Yr{getDefault(){return e.aj.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 pn extends Yr{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 fn extends Yr{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 mn extends Yr{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class _n extends Yr{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}let gn=class extends Yr{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}};class yn extends Yr{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class xn extends Yr{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 vn extends Yr{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 bn extends Yr{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 wn extends Yr{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 Tn extends Yr{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class Sn extends Yr{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class Mn extends Yr{getDefault(){return null}set(e){this.gl&&(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1)}}class En extends Yr{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 An extends Yr{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 In extends Yr{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 Cn extends Yr{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}}class Pn extends Cn{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 zn extends Cn{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,this.attachment(),t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class Dn extends Cn{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 Rn extends zn{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const Ln=(e,t,i)=>({u_matrix:e,u_image0:0,u_skirt_height:t,u_ground_shadow_factor:i}),On=(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(r),u_merc_matrix:i,u_zoom_transition:n,u_merc_center:o,u_image0:0,u_frustum_tl:s,u_frustum_tr:a,u_frustum_br:l,u_frustum_bl:c,u_globe_pos:h,u_globe_radius:u,u_viewport:d,u_grid_matrix:m?Float32Array.from(m):new Float32Array(9),u_skirt_height:p,u_far_z_cutoff:f});function kn(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const Fn=new class{constructor(){this.operations={}}newMorphing(e,t,i,r,n){if(e in this.operations){const t=this.operations[e];t.to.tileID.key!==i.tileID.key&&(t.queued=i)}else this.operations[e]={startTime:r,phase:0,duration:n,from:t,to:i,queued:null}}getMorphValuesForProxy(e){if(!(e in this.operations))return null;const t=this.operations[e];return{from:t.from,to:t.to,phase:t.phase}}update(e){for(const t in this.operations){const i=this.operations[t];for(i.phase=(e-i.startTime)/i.duration;i.phase>=1||!this._validOp(i);)if(!this._nextOp(i,e)){delete this.operations[t];break}}}_nextOp(e,t){return!!e.queued&&(e.from=e.to,e.to=e.queued,e.queued=null,e.phase=0,e.startTime=t,!0)}_validOp(e){return e.from.hasData()&&e.to.hasData()}},Bn={0:null,1:"TERRAIN_VERTEX_MORPHING"};function Nn(e,t,i){if(0===t)return 0;const r=t<1&&514===i?.25/t:1;return 6*Math.pow(1.5,22-e)*Math.max(t,1)*r}function Vn(e,t){const i=1<<e.z;return!t&&(0===e.x||e.x===i-1)||0===e.y||e.y===i-1}const Un=e=>({u_matrix:e});function jn(t,i,r,n,o){if(o>0){const s=e.q.now(),a=(s-t.timeAdded)/o,l=i?(s-i.timeAdded)/o:-1,c=r.getSource(),h=n.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.aw(u?a:1-l,0,1);return t.refreshedUponExpiration&&a>=1&&(t.refreshedUponExpiration=!1),i?{opacity:1,mix:1-d}:{opacity:d,mix:0}}return{opacity:1,mix:0}}class Gn extends bt{constructor(t){const i={type:"raster-dem",maxzoom:t.transform.maxZoom},r=new e.D(e.ci(),null),n=rt("mock-dem",i,r,t.style);super("mock-dem",n,!1),n.setEventedParent(this),this._sourceLoaded=!0}_loadTile(e,t){e.state="loaded",t(null)}}class qn extends bt{constructor(t){const i=rt("proxy",{type:"geojson",maxzoom:t.transform.maxZoom},new e.D(e.ci(),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 r=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce(((t,i)=>{if(t[i.key]="",!this._tiles[i.key]){const t=new gt(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 r||(this.freeFBO(e),this._tiles[e].unloadVectorData(),delete this._tiles[e])}freeFBO(e){const t=this.proxyCachedFBO[e];if(void 0!==t){const i=Object.values(t);this.renderCachePool.push(...i),delete this.proxyCachedFBO[e]}}deallocRenderCache(){this.renderCache.forEach((e=>e.fb.destroy())),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class Zn extends e.aG{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 $n extends e.cJ{constructor(t,i){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},t.tp.registerParameter(this._debugParams,["Terrain"],"sortTilesHiZFirst",{},(()=>{this._style.map.triggerRepaint()})),t.tp.registerParameter(this._debugParams,["Terrain"],"disableRenderCache",{},(()=>{this._style.map.triggerRepaint()})),t.tp.registerButton(["Terrain"],"Invalidate Render Cache",(()=>{this.invalidateRenderCache=!0,this._style.map.triggerRepaint()})),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[r,n,o]=function(){const t=new e.b4,i=new e.aU,r=131;t.reserve(17161),i.reserve(33800);const n=e.ag/128,o=e.ag+n/2,s=o+n;for(let i=-n;i<s;i+=n)for(let r=-n;r<s;r+=n){const n=r<0||r>o||i<0||i>o?24575:0,s=e.aw(Math.round(r),0,e.ag),a=e.aw(Math.round(i),0,e.ag);t.emplaceBack(s+n,a)}const a=(e,t)=>{const n=t*r+e;i.emplaceBack(n+1,n,n+r),i.emplaceBack(n+r,n+r+1,n+1)};for(let e=1;e<129;e++)for(let t=1;t<129;t++)a(t,e);return[0,129].forEach((e=>{for(let t=0;t<130;t++)a(t,e),a(e,t)})),[t,i,32768]}(),s=t.context;this.gridBuffer=s.createVertexBuffer(r,e.b6.members),this.gridIndexBuffer=s.createIndexBuffer(n),this.gridSegments=e.b7.simpleSegment(0,0,r.length,n.length),this.gridNoSkirtSegments=e.b7.simpleSegment(0,0,r.length,o),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new qn(i.map),this.orthoMatrix=e.ab.mat4.create(),e.ab.mat4.ortho(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,e.ag,0,e.ag,0,1);const a=s.gl;this._overlapStencilMode=new Bi({func:a.GEQUAL,mask:255},0,255,a.KEEP,a.KEEP,a.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=i,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new Gn(i.map),this._pendingGroundEffectLayers=[]}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),this._style=e,this._style.map.on("moveend",(()=>{this._clearLineLayersFromRenderCache()}))}update(t,i,r){if(t&&t.terrain){this._style!==t&&(this.style=t,this._evaluationZoom=void 0);const n=t.terrain.properties,o=0===t.terrain.drapeRenderMode,s=t.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=e.q.now();const a=t.terrain&&t.terrain.scope,l=n.get("source"),c=o?this._mockSourceCache:t.getSourceCache(l,a);if(!c)return void e.w(`Couldn't find terrain source "${l}".`);if(this.sourceCache=c,this._attenuationRange=t.terrain.getAttenuationRange(),this._exaggeration=s?this.calculateExaggeration(i):n.get("exaggeration"),!i.projection.requiresDraping&&s&&0===this._exaggeration)return void this._disable();this.enabled=!0;const 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,r),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(i),this._emptyDEMTextureDirty=!0,this._previousZoom=i.zoom}else this._disable()}calculateExaggeration(t){if(this._attenuationRange&&t.zoom>=Math.ceil(this._attenuationRange[1]))return this._style.terrain.getExaggeration(t.zoom);const i=this._previousCameraAltitude,r=t.getFreeCameraOptions().position.z/t.pixelsPerMeter*t.worldSize;this._previousCameraAltitude=r;const n=null!=i?r-i:Number.MAX_VALUE;if(Math.abs(n)<2)return this._exaggeration;const o=t.zoom,s=this._style.terrain;if(!this._previousUpdateTimestamp)return s.getExaggeration(o);let a=o-this._previousZoom;const l=this._previousUpdateTimestamp;let c=o;null!=this._evaluationZoom&&(c=this._evaluationZoom,Math.abs(o-c)>.5&&(a=.5*(o-c+a)),a*n<0&&(c+=a)),this._evaluationZoom=c;const h=s.getExaggeration(c),u=h===s.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(a)<1e-4)&&(d=Math.min(.2,4*d)),e.af(this._exaggeration,h,d)}resetTileLookupCache(e){this._findCoveringTileCache[e]={}}attenuationRange(){return this._attenuationRange}getDemUpscale(){return this.proxySourceCache.getSource().tileSize/128}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(e){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,r=this.painter.transform;this._initializing&&(this._initializing=0===r._centerAltitude&&-1===this.getAtPointOrZero(e.aa.fromLngLat(r.center),-1),this._emptyDEMTextureDirty=!this._initializing);const n=this.proxyCoords=i.getIds().map((e=>{const t=i.getTileByID(e).tileID;return t.projMatrix=r.calculateProjMatrix(t.toUnwrapped()),t}));!function(t,i){const r=i.transform.pointCoordinate(i.transform.getCameraPoint()),n=new e.P(r.x,r.y);t.sort(((t,i)=>{if(i.overscaledZ-t.overscaledZ)return i.overscaledZ-t.overscaledZ;const r=new e.P(t.canonical.x+(1<<t.canonical.z)*t.wrap,t.canonical.y),o=new e.P(i.canonical.x+(1<<i.canonical.z)*i.wrap,i.canonical.y),s=n.mult(1<<t.canonical.z);return s.x-=.5,s.y-=.5,s.distSqr(r)-s.distSqr(o)}))}(n,this.painter);const o=this.proxyToSource||{};this.proxyToSource={},n.forEach((e=>{this.proxyToSource[e.key]={}})),this.terrainTileForTile={};const s=this._style._mergedSourceCaches;for(const e in s){const i=s[e];if(!i.used)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,t[e],o),i.usedForTerrain)continue;const r=t[e];i.getSource().reparseOverscaled&&this._assignTerrainTiles(r)}this.proxiedCoords[i.id]=n.map((e=>new Zn(e,e.key,this.orthoMatrix))),this._assignTerrainTiles(n),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(o),this.renderingToTexture=!1;const a={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const i=t.tileID.key;i in a||(this._visibleDemTiles.push(t),a[i]=i)}}_assignTerrainTiles(e){this._initializing||e.forEach((e=>{if(this.terrainTileForTile[e.key])return;const t=this._findTileCoveringTileID(e,this.sourceCache);t&&(this.terrainTileForTile[e.key]=t)}))}_prepareDEMTextures(){const e=this.painter.context,t=e.gl;for(const i in this.terrainTileForTile){const r=this.terrainTileForTile[i],n=r.dem;!n||r.demTexture&&!r.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),Wr(this.painter,r,n))}}_prepareDemTileUniforms(e,t,i,r){if(!t||null==t.demTexture)return!1;const n=e.tileID.canonical,o=Math.pow(2,t.tileID.canonical.z-n.z),s=r||"";return i[`u_dem_tl${s}`]=[n.x*o%1,n.y*o%1],i[`u_dem_scale${s}`]=o,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}_getLoadedAreaMinimum(){if(!this.enabled)return 0;let e=0;const t=this._visibleDemTiles.reduce(((t,i)=>{if(!i.dem)return t;const r=i.dem.tree.minimums[0];return r>0&&e++,t+r}),0);return e?t/e:0}_updateEmptyDEMTexture(){const t=this.painter.context,i=t.gl;t.activeTexture.set(i.TEXTURE2);const r=this._getLoadedAreaMinimum(),n=new e.cK({width:1,height:1},new Float32Array([r]));this._emptyDEMTextureDirty=!1;let o=this._emptyDEMTexture;return o?o.update(n,{premultiply:!1}):o=this._emptyDEMTexture=new e.T(t,n,i.R32F,{premultiply:!1}),o}setupElevationDraw(t,i,r){const n=this.painter.context,o=n.gl,s={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0};s.u_exaggeration=this.exaggeration();let a=null,l=null,c=1;if(r&&r.morphing&&this._useVertexMorphing){const e=r.morphing.srcDemTile,i=r.morphing.dstDemTile;c=r.morphing.phase,e&&i&&(this._prepareDemTileUniforms(t,e,s,"_prev")&&(l=e),this._prepareDemTileUniforms(t,i,s)&&(a=i))}const h=e=>e&&e.demTexture&&this.painter.linearFloatFilteringSupported()?o.LINEAR:o.NEAREST;let u=null;var d;if(this.enabled?l&&a?(u=a.demTexture,n.activeTexture.set(o.TEXTURE4),l.demTexture.bind(h(l),o.CLAMP_TO_EDGE),s.u_dem_lerp=c):(a=this.terrainTileForTile[t.tileID.key],u=this._prepareDemTileUniforms(t,a,s)?a.demTexture:this.emptyDEMTexture):u=this.emptyDEMTexture,n.activeTexture.set(o.TEXTURE2),u&&(s.u_dem_size=1===(d=u).size[0]?1:d.size[0]-2,u.bind(h(a),o.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(r&&r.useDepthForOcclusion,i,s),r&&r.useMeterToDem&&a){const t=(1<<a.tileID.canonical.z)*e.bH(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;s.u_meter_to_dem=t}if(r&&r.labelPlaneMatrixInv&&(s.u_label_plane_matrix_inv=r.labelPlaneMatrixInv),i.setTerrainUniformValues(n,s),"globe"===this.painter.transform.projection.name){const e=this.globeUniformValues(this.painter.transform,t.tileID.canonical,r&&r.useDenormalizedUpVectorScale);i.setGlobeUniformValues(n,e)}}globeUniformValues(t,i,r){const n=t.projection;return{u_tile_tl_up:n.upVector(i,0,0),u_tile_tr_up:n.upVector(i,e.ag,0),u_tile_br_up:n.upVector(i,e.ag,e.ag),u_tile_bl_up:n.upVector(i,0,e.ag),u_tile_up_scale:r?e.cL(1):n.upVectorScale(i,t.center.lat,t.worldSize).metersToTile}}renderToBackBuffer(t){const i=this.painter,r=this.painter.context;0!==t.length&&(r.bindFramebuffer.set(null),r.viewport.set([0,0,i.width,i.height]),i.gpuTimingDeferredRenderStart(),this.renderingToTexture=!1,function(t,i,r,n,o){if("globe"===t.transform.projection.name)!function(t,i,r,n,o){const s=t.context,a=s.gl;let l,c;const h=t.transform,u=e.cC(t,s,h),d=(e,i)=>{if(c===i)return;const r=[Bn[i],"PROJECTION_GLOBE_VIEW"];u&&r.push("CUSTOM_ANTIALIASING");const n=t.isTileAffectedByFog(e);l=t.getOrCreateProgram("globeRaster",{defines:r,overrideFog:n}),c=i},p=t.colorModeForRenderPass(),f=new ki(a.LEQUAL,ki.ReadWrite,t.depthRangeFor3D);Fn.update(o);const m=e.cD(h),_=[e.at(h.center.lng),e.aA(h.center.lat)],g=t.globeSharedBuffers,y=[h.width*e.q.devicePixelRatio,h.height*e.q.devicePixelRatio],x=Float32Array.from(h.globeMatrix),v={useDenormalizedUpVectorScale:!0};{const h=t.transform,u=Nn(h.zoom,i.exaggeration(),i.sourceCache._source.tileSize);c=-1;const b=a.TRIANGLES;for(const c of n){const n=r.getTile(c),w=Bi.disabled,T=i.prevTerrainTileForTile[c.key],S=i.terrainTileForTile[c.key];kn(T,S)&&Fn.newMorphing(c.key,T,S,o,250),s.activeTexture.set(a.TEXTURE0),n.texture&&n.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const M=Fn.getMorphValuesForProxy(c.key),E=M?1:0;M&&e.J(v,{morphing:{srcDemTile:M.from,dstDemTile:M.to,phase:e.cB(M.phase)}});const A=e.cE(c.canonical),I=e.cF(A.getCenter().lat),C=e.cG(c.canonical,A,I,h.worldSize/h._pixelsPerMercatorPixel),P=e.bb(e.cH(c.canonical)),z=On(h.expandedFarZProjMatrix,x,m,P,e.ae(h.zoom),_,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,y,u,h._farZ,C);if(d(c,E),l&&(i.setupElevationDraw(n,l,v),t.uploadCommonUniforms(s,l,c.toUnwrapped()),g)){const[e,i,r]=g.getGridBuffers(I,0!==u);l.draw(t,b,f,w,p,Ui.backCCW,z,"globe_raster",e,i,r)}}}if(g&&(t.renderDefaultNorthPole||t.renderDefaultSouthPole)){const o=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];u&&o.push("CUSTOM_ANTIALIASING"),l=t.getOrCreateProgram("globeRaster",{defines:o});for(const o of n){const{x:n,y:c,z:u}=o.canonical,d=0===c,m=c===(1<<u)-1,[x,b,w,T]=g.getPoleBuffers(u,!1);if(T&&(d||m)){const c=r.getTile(o);s.activeTexture.set(a.TEXTURE0),c.texture&&c.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);let g=e.cI(u,n,h);const S=e.bb(e.cH(o.canonical)),M=(e,i)=>e.draw(t,a.TRIANGLES,f,Bi.disabled,p,Ui.disabled,On(h.expandedFarZProjMatrix,g,g,S,0,_,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,y,0,h._farZ),"globe_pole_raster",i,w,T);i.setupElevationDraw(c,l,v),t.uploadCommonUniforms(s,l,o.toUnwrapped()),d&&t.renderDefaultNorthPole&&M(l,x),m&&t.renderDefaultSouthPole&&(g=e.ab.mat4.scale(e.ab.mat4.create(),g,[1,-1,1]),M(l,b))}}}}(t,i,r,n,o);else{const s=t.context,a=s.gl;let l,c;const h=t.shadowRenderer,u=nr(t,t.longestCutoffRange),d=e=>{if(c===e)return;const i=[];i.push(Bn[e]),u.shouldRenderCutoff&&i.push("RENDER_CUTOFF"),h&&(i.push("RENDER_SHADOWS","DEPTH_TEXTURE"),h.useNormalOffset&&i.push("NORMAL_OFFSET")),l=t.getOrCreateProgram("terrainRaster",{defines:i}),c=e},p=t.colorModeForRenderPass(),f=new ki(a.LEQUAL,ki.ReadWrite,t.depthRangeFor3D);Fn.update(o);const m=t.transform,_=Nn(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=ur(t.style,e,i))}{c=-1;const y=a.TRIANGLES,[x,v]=[i.gridIndexBuffer,i.gridSegments];for(const c of n){const n=r.getTile(c),b=Bi.disabled,w=i.prevTerrainTileForTile[c.key],T=i.terrainTileForTile[c.key];kn(w,T)&&Fn.newMorphing(c.key,w,T,o,250),s.activeTexture.set(a.TEXTURE0),n.texture&&n.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const S=Fn.getMorphValuesForProxy(c.key),M=S?1:0;let E;S&&(E={morphing:{srcDemTile:S.from,dstDemTile:S.to,phase:e.cB(S.phase)}});const A=Ln(c.projMatrix,Vn(c.canonical,m.renderWorldCopies)?_/10:_,g);if(d(M),!l)continue;i.setupElevationDraw(n,l,E);const I=c.toUnwrapped();h&&h.setupShadows(I,l),t.uploadCommonUniforms(s,l,I,null,u),l.draw(t,y,f,b,p,Ui.backCCW,A,"terrain_raster",i.gridBuffer,x,v)}}}}(i,this,this.proxySourceCache,t,this._updateTimestamp),this.renderingToTexture=!0,i.gpuTimingDeferredRenderEnd(),t.splice(0,t.length))}renderBatch(t){if(0===this._drapedRenderBatches.length)return t+1;this.renderingToTexture=!0;const i=this.painter,r=this.painter.context,n=this.proxySourceCache,o=this.proxiedCoords[n.id],s=this._drapedRenderBatches.shift(),a=i.style.order,l=[];let c=0;for(const h of o){const o=n.getTileByID(h.proxyTileKey),u=n.proxyCachedFBO[h.key]?n.proxyCachedFBO[h.key][t]:void 0,d=void 0!==u?n.renderCache[u]:this.pool[c++],p=void 0!==u;if(o.texture=d.tex,p&&!d.dirty){l.push(o.tileID);continue}let f;r.bindFramebuffer.set(d.fb.framebuffer),this.renderedToTile=!1,d.dirty&&(r.clear({color:e.aj.transparent,stencil:0}),d.dirty=!1);for(let e=s.start;e<=s.end;++e){const t=i.style._mergedLayers[a[e]];if(t.isHidden(i.transform.zoom))continue;const n=i.style.getLayerSourceCache(t),o=n?this.proxyToSource[h.key][n.id]:[h];if(!o)continue;const s=o;r.viewport.set([0,0,d.fb.width,d.fb.height]),f!==(n?n.id:null)&&(this._setupStencil(d,o,t,n),f=n?n.id:null),i.renderLayer(i,n,t,s)}if(0===this._drapedRenderBatches.length)for(const e of this._pendingGroundEffectLayers){const t=i.style._mergedLayers[a[e]];if(t.isHidden(i.transform.zoom))continue;const n=i.style.getLayerSourceCache(t),o=n?this.proxyToSource[h.key][n.id]:[h];if(!o)continue;const s=o;r.viewport.set([0,0,d.fb.width,d.fb.height]),f!==(n?n.id:null)&&(this._setupStencil(d,o,t,n),f=n?n.id:null),i.renderLayer(i,n,t,s)}this.renderedToTile?(d.dirty=!0,l.push(o.tileID)):p||--c,5===c&&(c=0,this.renderToBackBuffer(l))}return this.renderToBackBuffer(l),this.renderingToTexture=!1,r.bindFramebuffer.set(null),r.viewport.set([0,0,i.width,i.height]),s.end+1}postRender(){}isLayerOrderingCorrect(e){const t=e.order.length;let i=-1,r=t;for(let n=0;n<t;++n)this._style.isLayerDraped(e._mergedLayers[e.order[n]])?i=Math.max(i,n):r=Math.min(r,n);return r>i}getMinElevationBelowMSL(){let e=0;return this._visibleDemTiles.filter((e=>e.dem)).forEach((t=>{e=Math.min(e,t.dem.tree.minimums[0])})),0===e?e:(e-30)*this._exaggeration}raycast(e,t,i){if(!this._visibleDemTiles)return null;const r=this._visibleDemTiles.filter((e=>e.dem)).map((r=>{const n=r.tileID,o=1<<n.overscaledZ,{x:s,y:a}=n.canonical,l=s/o,c=(s+1)/o,h=a/o,u=(a+1)/o;return{minx:l,miny:h,maxx:c,maxy:u,t:r.dem.tree.raycastRoot(l,h,c,u,e,t,i),tile:r}}));r.sort(((e,t)=>(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE)));for(const n of r){if(null==n.t)return null;const r=n.tile.dem.tree.raycast(n.minx,n.miny,n.maxx,n.maxy,e,t,i);if(null!=r)return r}return null}_createFBO(){const t=this.painter.context,i=t.gl,r=this.drapeBufferSize;t.activeTexture.set(i.TEXTURE0);const n=new e.T(t,{width:r[0],height:r[1],data:null},i.RGBA8);n.bind(i.LINEAR,i.CLAMP_TO_EDGE);const o=t.createFramebuffer(r[0],r[1],!0,null);return o.colorAttachment.set(n.texture),o.depthAttachment=new Rn(t,o.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,r[0],r[1]),this._stencilRef=0,o.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):o.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&i.texParameterf(i.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.extTextureFilterAnisotropicMax),{fb:o,tex:n,dirty:!1}}_initFBOPool(){for(;this.pool.length<Math.min(5,this.proxyCoords.length);)this.pool.push(this._createFBO())}_shouldDisableRenderCache(){if(this._debugParams.disableRenderCache)return!0;if(this._style.hasLightTransitions())return!0;for(const e in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[e].hasTransition())return!0;return this._style.order.some((e=>{const t=this._style._mergedLayers[e],i=t.isHidden(this.painter.transform.zoom);return"hillshade"===t.type||"custom"===t.type?!i&&t.shouldRedrape():!i&&t.hasTransition()}))}_clearLineLayersFromRenderCache(){let t=!1;for(const e of this._style.getSources())if(e instanceof Qe){t=!0;break}if(!t)return;const i={};for(let t=0;t<this._style.order.length;++t){const r=this._style._mergedLayers[this._style.order[t]],n=this._style.getLayerSourceCache(r);if(n&&!i[n.id]&&!r.isHidden(this.painter.transform.zoom)&&"line"===r.type&&r.widthExpression()instanceof e.a9){i[n.id]=!0;for(const e of this.proxyCoords){const t=this.proxyToSource[e.key][n.id];if(t)for(const e of t)this._clearRenderCacheForTile(n.id,e)}}}}_clearRasterLayersFromRenderCache(){let e=!1;for(const t in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[t]._source instanceof et){e=!0;break}if(!e)return;const t={};for(let e=0;e<this._style.order.length;++e){const i=this._style._mergedLayers[this._style.order[e]],r=this._style.getLayerSourceCache(i);if(!r||t[r.id])continue;if(i.isHidden(this.painter.transform.zoom)||"raster"!==i.type)continue;const n=i.paint.get("raster-fade-duration");for(const e of this.proxyCoords){const t=this.proxyToSource[e.key][r.id];if(t)for(const e of t){const t=jn(r.getTile(e),r.findLoadedParent(e,0),r,this.painter.transform,n);(1!==t.opacity||0!==t.mix)&&this._clearRenderCacheForTile(r.id,e)}}}}_setupDrapedRenderBatches(){this._style.updateDrapeFirstLayers();const t=this._style.order,i=t.length;if(0===i)return;const r=[];this._pendingGroundEffectLayers=[];let n,o=0,s=this._style._mergedLayers[t[o]];for(;!this._style.isLayerDraped(s)&&s.isHidden(this.painter.transform.zoom)&&++o<i;)s=this._style._mergedLayers[t[o]];for(;o<i;++o){const e=this._style._mergedLayers[t[o]];e.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(e)?void 0===n&&(n=o):("fill-extrusion"===e.type&&this._pendingGroundEffectLayers.push(o),void 0!==n&&(r.push({start:n,end:o-1}),n=void 0)))}if(void 0!==n&&r.push({start:n,end:o-1}),0!==r.length){const t=r[r.length-1];this._pendingGroundEffectLayers.every((e=>e>t.end))||e.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=r}_setupRenderCache(e){const t=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,t.renderCache.length>t.renderCachePool.length){const e=Object.values(t.proxyCachedFBO);t.proxyCachedFBO={};for(let i=0;i<e.length;++i){const r=Object.values(e[i]);t.renderCachePool.push(...r)}}return}this._clearRasterLayersFromRenderCache();const i=this.proxyCoords,r=this._tilesDirty;for(let n=i.length-1;n>=0;n--){const o=i[n];if(t.getTileByID(o.key),void 0!==t.proxyCachedFBO[o.key]){const i=e[o.key],n=this.proxyToSource[o.key];let s=0;for(const e in n){const t=n[e],o=i[e];if(!o||o.length!==t.length||t.some(((t,i)=>t!==o[i]||r[e]&&r[e].hasOwnProperty(t.key)))){s=-1;break}++s}for(const e in t.proxyCachedFBO[o.key])t.renderCache[t.proxyCachedFBO[o.key][e]].dirty=s<0||s!==Object.values(i).length}}const n=[...this._drapedRenderBatches];n.sort(((e,t)=>t.end-t.start-(e.end-e.start)));for(const e of n)for(const r of i){if(t.proxyCachedFBO[r.key])continue;let i=t.renderCachePool.pop();void 0===i&&t.renderCache.length<50&&(i=t.renderCache.length,t.renderCache.push(this._createFBO())),void 0!==i&&(t.proxyCachedFBO[r.key]={},t.proxyCachedFBO[r.key][e.start]=i,t.renderCache[i].dirty=!0)}this._tilesDirty={}}_setupStencil(e,t,i,r){if(!r||!this._sourceTilesOverlap[r.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const n=this.painter.context,o=n.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let s;if(i.isTileClipped())s=t.length,this._overlapStencilMode.test={func:o.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(t[0].overscaledZ>t[t.length-1].overscaledZ))return void(this._overlapStencilType=!1);s=1,this._overlapStencilMode.test={func:o.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+s>255&&(n.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=s,this._overlapStencilMode.ref=this._stencilRef,i.isTileClipped()&&this._renderTileClippingMasks(t,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(e){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[e.key]),this._overlapStencilMode):Bi.disabled}_renderTileClippingMasks(e,t){const i=this.painter,r=this.painter.context,n=r.gl;i._tileClippingMaskIDs={},r.setColorMode(Oi.disabled),r.setDepthMode(ki.disabled);const o=i.getOrCreateProgram("clippingMask");for(const r of e){const e=i._tileClippingMaskIDs[r.key]=--t;o.draw(i,n.TRIANGLES,ki.disabled,new Bi({func:n.ALWAYS,mask:0},e,255,n.KEEP,n.KEEP,n.REPLACE),Oi.disabled,Ui.disabled,Un(r.projMatrix),"$clipping",i.tileExtentBuffer,i.quadTriangleIndexBuffer,i.tileExtentSegments)}}pointCoordinate(t){const i=this.painter.transform;if(t.x<0||t.x>i.width||t.y<0||t.y>i.height)return null;const r=[t.x,t.y,1,1];e.ab.vec4.transformMat4(r,r,i.pixelMatrixInverse),e.ab.vec4.scale(r,r,1/r[3]),r[0]/=i.worldSize,r[1]/=i.worldSize;const n=i._camera.position,o=e.bH(1,i.center.lat),s=[n[0],n[1],n[2]/o,0],a=e.ab.vec3.subtract([],r.slice(0,3),s);e.ab.vec3.normalize(a,a);const l=this.raycast(s,a,this._exaggeration);return null!==l&&l?(e.ab.vec3.scaleAndAdd(s,s,a,l),s[3]=s[2],s[2]*=o,s):null}_setupProxiedCoordsForOrtho(t,i,r){if(t.getSource()instanceof e.aJ)return this._setupProxiedCoordsForImageSource(t,i,r);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};const n=this.proxiedCoords[t.id]=[],o=this.proxyCoords;for(let e=0;e<o.length;e++){const i=o[e],s=this._findTileCoveringTileID(i,t);if(s){const e=this._createProxiedId(i,s,r[i.key]&&r[i.key][t.id]);n.push(e),this.proxyToSource[i.key][t.id]=[e]}}let s=!1;const a=new Set;for(let e=0;e<i.length;e++){const o=t.getTile(i[e]);if(!o||!o.hasData())continue;const l=this._findTileCoveringTileID(o.tileID,this.proxySourceCache);if(l&&l.tileID.canonical.z!==o.tileID.canonical.z){const e=this.proxyToSource[l.tileID.key][t.id],i=this._createProxiedId(l.tileID,o,r[l.tileID.key]&&r[l.tileID.key][t.id]);e?e.splice(e.length-1,0,i):this.proxyToSource[l.tileID.key][t.id]=[i];const c=this.proxyToSource[l.tileID.key][t.id];a.has(c)||a.add(c),n.push(i),s=!0}}if(this._sourceTilesOverlap[t.id]=s,s&&this._debugParams.sortTilesHiZFirst)for(const e of a)e.sort(((e,t)=>t.overscaledZ-e.overscaledZ))}_setupProxiedCoordsForImageSource(t,i,r){if(!t.getSource().loaded())return;const n=this.proxiedCoords[t.id]=[],o=this.proxyCoords,s=t.getSource(),a=s.tileID;if(!a)return;const l=new e.P(a.x,a.y)._div(1<<a.z),c=s.coordinates.map(e.aa.fromLngLat).reduce(((e,t)=>(e.min.x=Math.min(e.min.x,t.x-l.x),e.min.y=Math.min(e.min.y,t.y-l.y),e.max.x=Math.max(e.max.x,t.x-l.x),e.max.y=Math.max(e.max.y,t.y-l.y),e)),{min:new e.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new e.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),h=(t,i)=>{const r=t.wrap+t.canonical.x/(1<<t.canonical.z),n=t.canonical.y/(1<<t.canonical.z),o=e.ag/(1<<t.canonical.z),s=i.wrap+i.canonical.x/(1<<i.canonical.z),a=i.canonical.y/(1<<i.canonical.z);return r+o<s+c.min.x||r>s+c.max.x||n+o<a+c.min.y||n>a+c.max.y};for(let e=0;e<o.length;e++){const s=o[e];for(let e=0;e<i.length;e++){const o=t.getTile(i[e]);if(!o||!o.hasData())continue;if(h(s,o.tileID))continue;const a=this._createProxiedId(s,o,r[s.key]&&r[s.key][t.id]),l=this.proxyToSource[s.key][t.id];l?l.push(a):this.proxyToSource[s.key][t.id]=[a],n.push(a)}}}_createProxiedId(t,i,r){let n=this.orthoMatrix;if(r){const e=r.find((e=>e.key===i.tileID.key));if(e)return e}if(i.tileID.key!==t.key){const r=t.canonical.z-i.tileID.canonical.z;let o,s,a;n=e.ab.mat4.create();const l=i.tileID.wrap-t.wrap<<t.overscaledZ;r>0?(o=e.ag>>r,s=o*((i.tileID.canonical.x<<r)-t.canonical.x+l),a=o*((i.tileID.canonical.y<<r)-t.canonical.y)):(o=e.ag<<-r,s=e.ag*(i.tileID.canonical.x-(t.canonical.x+l<<-r)),a=e.ag*(i.tileID.canonical.y-(t.canonical.y<<-r))),e.ab.mat4.ortho(n,0,o,0,o,0,1),e.ab.mat4.translate(n,n,[s,a,0])}return new Zn(i.tileID,t.key,n)}_findTileCoveringTileID(t,i){let r=i.getTile(t);if(r&&r.hasData())return r;const n=this._findCoveringTileCache[i.id],o=n[t.key];if(r=o?i.getTileByID(o):null,r&&r.hasData()||null===o)return r;let s=r?r.tileID:t,a=s.overscaledZ;const l=i.getSource().minzoom,c=[];if(!o){const n=i.getSource().maxzoom;if(t.canonical.z>=n){const r=t.canonical.z-n;i.getSource().reparseOverscaled?(a=Math.max(t.canonical.z+2,i.transform.tileZoom),s=new e.aG(a,t.wrap,n,t.canonical.x>>r,t.canonical.y>>r)):0!==r&&(a=n,s=new e.aG(a,t.wrap,n,t.canonical.x>>r,t.canonical.y>>r))}s.key!==t.key&&(c.push(s.key),r=i.getTile(s))}const h=e=>{c.forEach((t=>{n[t]=e})),c.length=0};for(a-=1;a>=l&&(!r||!r.hasData());a--){r&&h(r.tileID.key);const e=s.calculateScaledKey(a);if(r=i.getTileByID(e),r&&r.hasData())break;const t=n[e];if(null===t)break;void 0===t?c.push(e):r=i.getTileByID(t)}return h(r?r.tileID.key:null),r&&r.hasData()?r:null}findDEMTileFor(e){return this.enabled?this._findTileCoveringTileID(e,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(e,t){let i=this._tilesDirty[e];i||(i=this._tilesDirty[e]={}),i[t.key]=!0}}function Hn(t,i,r){const n=function(t,i,r){const n=e.ab.vec3.dot(i,t),o=e.ab.vec3.dot(r,[.2126,.7152,.0722]),s=(e,t,i)=>(1-i)*e+i*t,a=s(1-.3*Math.min(o,1),1,Math.min(n+1,1));return s(.92,1,Math.asin(e.aw(i[2],-1,1))/Math.PI+.5)*a}(t,[0,0,1],i),o=[0,0,0];e.ab.vec3.scale(o,r.slice(0,3),n);const s=[0,0,0];e.ab.vec3.scale(s,i.slice(0,3),t[2]);const a=[0,0,0];return e.ab.vec3.add(a,o,s),e.cf(a)}const Wn=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],Xn=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","model","symbol"];class Yn{static cacheKey(e,t,i,r){let n=`${t}${r?r.cacheKey:""}`;for(const t of i)e.usedDefines.includes(t)&&(n+=`/${t}`);return n}constructor(t,i,r,n,o,s){const a=t.gl;this.program=a.createProgram(),this.configuration=n,this.name=i,this.fixedDefines=[...s];const l=n?n.getBinderAttributes():[],c=(r.staticAttributes||[]).concat(l);let h=n?n.defines():[];h=h.concat(s.map((e=>`#define ${e}`)));const u="#version 300 es\n";let d=u+h.concat("precision mediump float;",Ur,Vr.fragmentSource).join("\n");for(const e of r.fragmentIncludes)d+=`\n${Br[e]}`;d+=`\n${r.fragmentSource}`;let p=u+h.concat("precision highp float;",Ur,Vr.vertexSource).join("\n");for(const e of r.vertexIncludes)p+=`\n${Br[e]}`;this.forceManualRenderingForInstanceIDShaders=t.forceManualRenderingForInstanceIDShaders&&-1!==r.vertexSource.indexOf("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&(p+="\nuniform int u_instanceID;\n"),p+=`\n${r.vertexSource}`,this.forceManualRenderingForInstanceIDShaders&&(p=p.replaceAll("gl_InstanceID","u_instanceID"));const f=a.createShader(a.FRAGMENT_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(f,d),a.compileShader(f),a.attachShader(this.program,f);const m=a.createShader(a.VERTEX_SHADER);if(a.isContextLost())this.failedToCreate=!0;else{a.shaderSource(m,p),a.compileShader(m),a.attachShader(this.program,m),this.attributes={},this.numAttributes=c.length;for(let e=0;e<this.numAttributes;e++)if(c[e]){const t=c[e].startsWith("a_")?c[e]:`a_${c[e]}`;a.bindAttribLocation(this.program,e,t),this.attributes[t]=e}a.linkProgram(this.program),a.deleteShader(m),a.deleteShader(f),this.fixedUniforms=o(t),this.binderUniforms=n?n.getUniforms(t):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(t=>({u_instanceID:new e.bN(t)}))(t)),(s.includes("TERRAIN")||-1!==i.indexOf("symbol")||-1!==i.indexOf("circle"))&&(this.terrainUniforms=(t=>({u_dem:new e.bN(t),u_dem_prev:new e.bN(t),u_dem_tl:new e.bK(t),u_dem_scale:new e.bM(t),u_dem_tl_prev:new e.bK(t),u_dem_scale_prev:new e.bM(t),u_dem_size:new e.bM(t),u_dem_lerp:new e.bM(t),u_exaggeration:new e.bM(t),u_depth:new e.bN(t),u_depth_size_inv:new e.bK(t),u_depth_range_unpack:new e.bK(t),u_occluder_half_size:new e.bM(t),u_occlusion_depth_offset:new e.bM(t),u_meter_to_dem:new e.bM(t),u_label_plane_matrix_inv:new e.bJ(t)}))(t)),s.includes("GLOBE")&&(this.globeUniforms=(t=>({u_tile_tl_up:new e.bL(t),u_tile_tr_up:new e.bL(t),u_tile_br_up:new e.bL(t),u_tile_bl_up:new e.bL(t),u_tile_up_scale:new e.bM(t)}))(t)),s.includes("FOG")&&(this.fogUniforms=(t=>({u_fog_matrix:new e.bJ(t),u_fog_range:new e.bK(t),u_fog_color:new e.ca(t),u_fog_horizon_blend:new e.bM(t),u_fog_vertical_limit:new e.bK(t),u_fog_temporal_offset:new e.bM(t),u_frustum_tl:new e.bL(t),u_frustum_tr:new e.bL(t),u_frustum_br:new e.bL(t),u_frustum_bl:new e.bL(t),u_globe_pos:new e.bL(t),u_globe_radius:new e.bM(t),u_globe_transition:new e.bM(t),u_is_globe:new e.bN(t),u_viewport:new e.bK(t)}))(t)),s.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(t=>({u_cutoff_params:new e.ca(t)}))(t)),s.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(t=>({u_lighting_ambient_color:new e.bL(t),u_lighting_directional_dir:new e.bL(t),u_lighting_directional_color:new e.bL(t),u_ground_radiance:new e.bL(t)}))(t)),s.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(t=>({u_light_matrix_0:new e.bJ(t),u_light_matrix_1:new e.bJ(t),u_fade_range:new e.bK(t),u_shadow_normal_offset:new e.bL(t),u_shadow_intensity:new e.bM(t),u_shadow_texel_size:new e.bM(t),u_shadow_map_resolution:new e.bM(t),u_shadow_direction:new e.bL(t),u_shadow_bias:new e.bL(t),u_shadowmap_0:new e.bN(t),u_shadowmap_1:new e.bN(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,r,n,o,s,a,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||!Wn.includes(this.name))||!(!u.layers3D||!Xn.includes(this.name)))())return;const p=d.gl,f=t.wireframeDebugCache.getLinesFromTrianglesBuffer(t.frameCounter,o,d);if(!f)return;const m=[...this.fixedDefines];m.push("DEBUG_WIREFRAME");const _=t.getOrCreateProgram(this.name,{config:this.configuration,defines:m});d.program.set(_.program);const g=(e,t,i)=>{if(t[e]&&i[e])for(const r in t[e])i[e][r]&&i[e][r].set(i.program,r,t[e][r].current)};c&&c.setUniforms(_.program,d,_.binderUniforms,a,{zoom:l}),g("fixedUniforms",this,_),g("terrainUniforms",this,_),g("globeUniforms",this,_),g("fogUniforms",this,_),g("lightsUniforms",this,_),g("shadowUniforms",this,_),f.bind(),d.setColorMode(new Oi([p.ONE,p.ONE_MINUS_SRC_ALPHA,p.ZERO,p.ONE],e.aj.transparent,[!0,!0,!0,!1])),d.setDepthMode(new ki(i.func===p.LESS?p.LEQUAL:i.func,ki.ReadOnly,i.range)),d.setStencilMode(Bi.disabled);const y=3*s.primitiveLength*2,x=3*s.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const e=h||1;for(let t=0;t<e;++t)_.instancingUniforms.u_instanceID.set(this.program,"u_instanceID",t),p.drawElements(p.LINES,y,p.UNSIGNED_SHORT,x)}else h&&h>1?p.drawElementsInstanced(p.LINES,y,p.UNSIGNED_SHORT,x,h):p.drawElements(p.LINES,y,p.UNSIGNED_SHORT,x);o.bind(),d.program.set(this.program),d.setDepthMode(i),d.setStencilMode(r),d.setColorMode(n)}checkUniforms(e,t,i){if(this.fixedDefines.includes(t))for(const r of Object.keys(i))if(!i[r].initialized)throw new Error(`Program '${this.name}', from draw '${e}': uniform ${r} not set but required by ${t} being defined`)}draw(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=e.context,g=_.gl;if(this.failedToCreate)return;_.program.set(this.program),_.setDepthMode(i),_.setStencilMode(r),_.setColorMode(n),_.setCullFace(o);for(const e of Object.keys(this.fixedUniforms))this.fixedUniforms[e].set(this.program,e,s[e]);p&&p.setUniforms(this.program,_,this.binderUniforms,u,{zoom:d});const y={[g.POINTS]:1,[g.LINES]:2,[g.TRIANGLES]:3,[g.LINE_STRIP]:1}[t];this.checkUniforms(a,"RENDER_SHADOWS",this.shadowUniforms);const x=m&&m>0?1:void 0;for(const o of h.get()){const s=o.vaos||(o.vaos={});if((s[a]||(s[a]=new Zr)).bind(_,this,l,p?p.getPaintVertexBuffers():[],c,o.vertexOffset,f||[],x),this.forceManualRenderingForInstanceIDShaders){const e=m||1;for(let i=0;i<e;++i)this.instancingUniforms.u_instanceID.set(this.program,"u_instanceID",i),c?g.drawElements(t,o.primitiveLength*y,g.UNSIGNED_SHORT,o.primitiveOffset*y*2):g.drawArrays(t,o.vertexOffset,o.vertexLength)}else m&&m>1?g.drawElementsInstanced(t,o.primitiveLength*y,g.UNSIGNED_SHORT,o.primitiveOffset*y*2,m):c?g.drawElements(t,o.primitiveLength*y,g.UNSIGNED_SHORT,o.primitiveOffset*y*2):g.drawArrays(t,o.vertexOffset,o.vertexLength);t===g.TRIANGLES&&c&&this._drawDebugWireframe(e,i,r,n,c,o,u,d,p,m)}}}function Kn(t,i){const r=Math.pow(2,i.tileID.overscaledZ),n=i.tileSize*Math.pow(2,t.transform.tileZoom)/r,o=n*(i.tileID.canonical.x+i.tileID.wrap*r),s=n*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture?i.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/e.ar(i,1,t.transform.tileZoom),u_pixel_coord_upper:[o>>16,s>>16],u_pixel_coord_lower:[65535&o,65535&s]}}const Jn={terrain:0,flat:1},Qn=e.ab.mat4.create(),eo=(t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y)=>{const x=i.style.light,v=x.properties.get("position"),b=[v.x,v.y,v.z],w=e.ab.mat3.create();"viewport"===x.properties.get("anchor")&&(e.ab.mat3.fromRotation(w,-i.transform.angle),e.ab.vec3.transformMat3(b,b,w));const T=x.properties.get("color"),S=i.transform,M={u_matrix:t,u_lightpos:b,u_lightintensity:x.properties.get("intensity"),u_lightcolor:[T.r,T.g,T.b],u_vertical_gradient:+r,u_opacity:n,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Qn,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:Jn[h],u_base_type:Jn[u],u_ao:o,u_edge_radius:s,u_width_scale:a,u_flood_light_color:m,u_vertical_scale:_,u_flood_light_intensity:g,u_ground_shadow_factor:y};return"globe"===S.projection.name&&(M.u_tile_id=[l.canonical.x,l.canonical.y,1<<l.canonical.z],M.u_zoom_transition=d,M.u_inv_rot_matrix=f,M.u_merc_center=p,M.u_up_dir=S.projection.upVector(new e.bT(0,0,0),p[0]*e.ag,p[1]*e.ag),M.u_height_lift=c),M},to=(e,t,i,r,n,o)=>({u_matrix:e,u_edge_radius:t,u_width_scale:i,u_vertical_scale:r,u_height_type:Jn[n],u_base_type:Jn[o]}),io=(t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g)=>{const y=eo(t,i,r,n,o,s,a,l,h,u,d,p,f,m,_,g,1,[0,0,0]),x={u_height_factor:-Math.pow(2,l.overscaledZ)/c.tileSize/8};return e.l(y,Kn(i,c),x)},ro=(e,t)=>({u_matrix:e,u_emissive_strength:t}),no=(t,i,r,n)=>e.l(ro(t,i),Kn(r,n)),oo=(e,t,i)=>({u_matrix:e,u_world:i,u_emissive_strength:t}),so=(t,i,r,n,o)=>e.l(no(t,i,r,n),{u_world:o}),ao=(t,i,r,n)=>{const o=e.ag/r.tileSize;return{u_matrix:t,u_camera_to_center_distance:i.getCameraToCenterDistance(n),u_extrude_scale:[i.pixelsToGLUnits[0]/o,i.pixelsToGLUnits[1]/o]}},lo=(e,t,i=1)=>({u_matrix:e,u_color:t.toRenderColor(null),u_overlay:0,u_overlay_scale:i}),co=e.ab.mat4.create(),ho=(t,i,r,n,o,s,a)=>{const l=t.transform,c="globe"===l.projection.name,h=c?e.cN(l.zoom,i.canonical)*l._pixelsPerMercatorPixel:e.ar(r,1,s),u={u_matrix:i.projMatrix,u_extrude_scale:h,u_intensity:a,u_inv_rot_matrix:co,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=n,u.u_merc_center=o,u.u_tile_id=[i.canonical.x,i.canonical.y,1<<i.canonical.z],u.u_zoom_transition=e.ae(l.zoom);const t=o[0]*e.ag,r=o[1]*e.ag;u.u_up_dir=l.projection.upVector(new e.bT(0,0,0),t,r)}return u};function uo(e,[t,i,r,n],[o,s]){if(o===s)return[0,0,0,0];const a=255*(e-1)/(e*(s-o));return[t*a,i*a,r*a,n*a]}function po(e,t,[i,r]){return i===r?0:.5/e+(t-i)*(e-1)/(e*(r-i))}const fo=(t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b)=>({u_matrix:t,u_normalize_matrix:i,u_globe_matrix:r,u_merc_matrix:n,u_grid_matrix:o,u_tl_parent:s,u_scale_parent: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.cO(d.paint.get("raster-saturation")),u_contrast_factor:e.cP(d.paint.get("raster-contrast")),u_spin_weights:mo(d.paint.get("raster-hue-rotate")),u_perspective_transform:p,u_raster_elevation:f,u_zoom_transition:a,u_merc_center:l,u_cutoff_params:c,u_colorization_mix:uo(e.cQ,_,y),u_colorization_offset:po(e.cQ,g,y),u_color_ramp:m,u_texture_offset:[v/(x+2*v),x/(x+2*v)],u_texture_res:[x+2*v,x+2*v],u_emissive_strength:b});function mo(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 _o=.05,go=(e,t,i,r,n,o,s,a,l,c,h,u)=>({u_matrix:e,u_normalize_matrix:t,u_globe_matrix:i,u_merc_matrix:r,u_grid_matrix:n,u_tl_parent:o,u_scale_parent:c,u_fade_t:h.mix,u_opacity:h.opacity,u_image0:0,u_image1:1,u_raster_elevation:u,u_zoom_transition:s,u_merc_center:a,u_cutoff_params:l}),yo=(e,t,i,r,n,o,s,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_tile_offset:i,u_velocity:r,u_color_ramp:o,u_velocity_res:n,u_max_speed:s,u_uv_offset:a,u_data_scale:[255*l[0],255*l[1]],u_data_offset:c,u_particle_pos_scale:1.1,u_particle_pos_offset:[_o,_o]}),xo=(e,t,i,r,n,o,s,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_velocity:i,u_velocity_res:r,u_max_speed:n,u_speed_factor:o,u_reset_rate:s,u_rand_seed:Math.random(),u_uv_offset:a,u_data_scale:[255*l[0],255*l[1]],u_data_offset:c,u_particle_pos_scale:1.1,u_particle_pos_offset:[_o,_o]}),vo=e.ab.mat4.create(),bo=(t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w)=>{const T=o.transform,S={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:T.getCameraToCenterDistance(x),u_rotate_symbol:+r,u_aspect_ratio:T.width/T.height,u_fade_change:o.options.fadeDuration?o.symbolFadeChange:1,u_matrix:s,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+h,u_elevation_from_sea:c?1:0,u_pitch_with_map:+n,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:vo,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:vo,u_up_vector:[0,-1,0],u_color_adj_mat:v,u_icon_transition:b||0,u_gamma_scale:n?o.transform.getCameraToCenterDistance(x)*Math.cos(o.terrain?0:o.transform._pitch):1,u_device_pixel_ratio:e.q.devicePixelRatio,u_is_halo:+p,u_scale_factor:w||1};return"globe"===x.name&&(S.u_tile_id=[f.canonical.x,f.canonical.y,1<<f.canonical.z],S.u_zoom_transition=m,S.u_inv_rot_matrix=g,S.u_merc_center=_,S.u_camera_forward=T._camera.forward(),S.u_ecef_origin=e.cR(T.globeMatrix,f.toUnwrapped()),S.u_tile_matrix=Float32Array.from(T.globeMatrix),S.u_up_vector=y),S},wo=(e,t,i,r)=>({u_matrix:e,u_emissive_strength:t,u_opacity:i,u_color:r}),To=(t,i,r,n,o,s,a,l,c)=>e.l(function(t,i,r,n,o,s){const{width:a,height:l}=n.imageManager.getPixelSize(i),c=Math.pow(2,s.tileID.overscaledZ),h=s.tileSize*Math.pow(2,n.transform.tileZoom)/c,u=h*(s.tileID.canonical.x+s.tileID.wrap*c),d=h*s.tileID.canonical.y;return{u_image:0,u_pattern_tl:r.tl,u_pattern_br:r.br,u_texsize:[a,l],u_pattern_size:r.displaySize,u_pattern_units_to_pixels:o?[n.transform.width,-1*n.transform.height]:[1/e.ar(s,1,n.transform.tileZoom),1/e.ar(s,1,n.transform.tileZoom)],u_pixel_coord_upper:[u>>16,d>>16],u_pixel_coord_lower:[65535&u,65535&d]}}(0,s,a,n,l,c),{u_matrix:t,u_emissive_strength:i,u_opacity:r}),So=new Float32Array(e.ab.mat4.identity([])),Mo=(t,i,r,n,o,s,a,l,c,h,u,d,p,f=[0,0,0],m)=>{const _=o.style.light,g=_.properties.get("position"),y=[-g.x,-g.y,g.z],x=e.ab.mat3.create();"viewport"===_.properties.get("anchor")&&(e.ab.mat3.fromRotation(x,-o.transform.angle),e.ab.vec3.transformMat3(y,y,x));const v="MASK"===u.alphaMode,b=_.properties.get("color").toRenderColor(null),w=p.paint.get("model-ambient-occlusion-intensity"),T=p.paint.get("model-color").constantOr(e.aj.white).toRenderColor(null),S=p.paint.get("model-color-mix-intensity").constantOr(0);return{u_matrix:t,u_lighting_matrix:i,u_normal_matrix:r,u_node_matrix:n||So,u_lightpos:y,u_lightintensity:_.properties.get("intensity"),u_lightcolor:[b.r,b.g,b.b],u_camera_pos:f,u_opacity:s,u_baseTextureIsAlpha:0,u_alphaMask:+v,u_alphaCutoff:u.alphaCutoff,u_baseColorFactor:[a.r,a.g,a.b,a.a],u_emissiveFactor:[l[0],l[1],l[2],1],u_metallicFactor:c,u_roughnessFactor:h,u_baseColorTexture:Hi,u_metallicRoughnessTexture:Wi,u_normalTexture:Xi,u_occlusionTexture:Yi,u_emissionTexture:Ki,u_lutTexture:Ji,u_color_mix:[T.r,T.g,T.b,S],u_aoIntensity:w,u_emissive_strength:d,u_occlusionTextureTransform:m||[0,0,0,0]}},Eo=(e,t=So,i=So)=>({u_matrix:e,u_instance:t,u_node_matrix:i}),Ao={fillExtrusion:t=>({u_matrix:new e.bJ(t),u_lightpos:new e.bL(t),u_lightintensity:new e.bM(t),u_lightcolor:new e.bL(t),u_vertical_gradient:new e.bM(t),u_opacity:new e.bM(t),u_edge_radius:new e.bM(t),u_width_scale:new e.bM(t),u_ao:new e.bK(t),u_height_type:new e.bN(t),u_base_type:new e.bN(t),u_tile_id:new e.bL(t),u_zoom_transition:new e.bM(t),u_inv_rot_matrix:new e.bJ(t),u_merc_center:new e.bK(t),u_up_dir:new e.bL(t),u_height_lift:new e.bM(t),u_flood_light_color:new e.bL(t),u_vertical_scale:new e.bM(t),u_flood_light_intensity:new e.bM(t),u_ground_shadow_factor:new e.bL(t)}),fillExtrusionDepth:t=>({u_matrix:new e.bJ(t),u_edge_radius:new e.bM(t),u_width_scale:new e.bM(t),u_vertical_scale:new e.bM(t),u_height_type:new e.bN(t),u_base_type:new e.bN(t)}),fillExtrusionPattern:t=>({u_matrix:new e.bJ(t),u_lightpos:new e.bL(t),u_lightintensity:new e.bM(t),u_lightcolor:new e.bL(t),u_vertical_gradient:new e.bM(t),u_height_factor:new e.bM(t),u_edge_radius:new e.bM(t),u_width_scale:new e.bM(t),u_ao:new e.bK(t),u_height_type:new e.bN(t),u_base_type:new e.bN(t),u_tile_id:new e.bL(t),u_zoom_transition:new e.bM(t),u_inv_rot_matrix:new e.bJ(t),u_merc_center:new e.bK(t),u_up_dir:new e.bL(t),u_height_lift:new e.bM(t),u_image:new e.bN(t),u_texsize:new e.bK(t),u_pixel_coord_upper:new e.bK(t),u_pixel_coord_lower:new e.bK(t),u_tile_units_to_pixels:new e.bM(t),u_opacity:new e.bM(t)}),fillExtrusionGroundEffect:t=>({u_matrix:new e.bJ(t),u_opacity:new e.bM(t),u_ao_pass:new e.bM(t),u_meter_to_tile:new e.bM(t),u_ao:new e.bK(t),u_flood_light_intensity:new e.bM(t),u_flood_light_color:new e.bL(t),u_attenuation:new e.bM(t),u_edge_radius:new e.bM(t),u_fb:new e.bN(t),u_fb_size:new e.bM(t),u_dynamic_offset:new e.bM(t)}),fill:t=>({u_matrix:new e.bJ(t),u_emissive_strength:new e.bM(t)}),fillPattern:t=>({u_matrix:new e.bJ(t),u_emissive_strength:new e.bM(t),u_image:new e.bN(t),u_texsize:new e.bK(t),u_pixel_coord_upper:new e.bK(t),u_pixel_coord_lower:new e.bK(t),u_tile_units_to_pixels:new e.bM(t)}),fillOutline:t=>({u_matrix:new e.bJ(t),u_emissive_strength:new e.bM(t),u_world:new e.bK(t)}),fillOutlinePattern:t=>({u_matrix:new e.bJ(t),u_emissive_strength:new e.bM(t),u_world:new e.bK(t),u_image:new e.bN(t),u_texsize:new e.bK(t),u_pixel_coord_upper:new e.bK(t),u_pixel_coord_lower:new e.bK(t),u_tile_units_to_pixels:new e.bM(t)}),circle:e.cS,collisionBox:t=>({u_matrix:new e.bJ(t),u_camera_to_center_distance:new e.bM(t),u_extrude_scale:new e.bK(t)}),collisionCircle:t=>({u_matrix:new e.bJ(t),u_inv_matrix:new e.bJ(t),u_camera_to_center_distance:new e.bM(t),u_viewport_size:new e.bK(t)}),debug:t=>({u_color:new e.cz(t),u_matrix:new e.bJ(t),u_overlay:new e.bN(t),u_overlay_scale:new e.bM(t)}),clippingMask:t=>({u_matrix:new e.bJ(t)}),heatmap:t=>({u_extrude_scale:new e.bM(t),u_intensity:new e.bM(t),u_matrix:new e.bJ(t),u_inv_rot_matrix:new e.bJ(t),u_merc_center:new e.bK(t),u_tile_id:new e.bL(t),u_zoom_transition:new e.bM(t),u_up_dir:new e.bL(t)}),heatmapTexture:t=>({u_image:new e.bN(t),u_color_ramp:new e.bN(t),u_opacity:new e.bM(t)}),hillshade:t=>({u_matrix:new e.bJ(t),u_image:new e.bN(t),u_latrange:new e.bK(t),u_light:new e.bK(t),u_shadow:new e.cz(t),u_highlight:new e.cz(t),u_emissive_strength:new e.bM(t),u_accent:new e.cz(t)}),hillshadePrepare:t=>({u_matrix:new e.bJ(t),u_image:new e.bN(t),u_dimension:new e.bK(t),u_zoom:new e.bM(t)}),line:e.cT,linePattern:e.cU,raster:t=>({u_matrix:new e.bJ(t),u_normalize_matrix:new e.bJ(t),u_globe_matrix:new e.bJ(t),u_merc_matrix:new e.bJ(t),u_grid_matrix:new e.cA(t),u_tl_parent:new e.bK(t),u_scale_parent:new e.bM(t),u_fade_t:new e.bM(t),u_opacity:new e.bM(t),u_image0:new e.bN(t),u_image1:new e.bN(t),u_brightness_low:new e.bM(t),u_brightness_high:new e.bM(t),u_saturation_factor:new e.bM(t),u_contrast_factor:new e.bM(t),u_spin_weights:new e.bL(t),u_perspective_transform:new e.bK(t),u_raster_elevation:new e.bM(t),u_zoom_transition:new e.bM(t),u_merc_center:new e.bK(t),u_cutoff_params:new e.ca(t),u_colorization_mix:new e.ca(t),u_colorization_offset:new e.bM(t),u_color_ramp:new e.bN(t),u_texture_offset:new e.bK(t),u_texture_res:new e.bK(t),u_emissive_strength:new e.bM(t)}),rasterParticle:t=>({u_matrix:new e.bJ(t),u_normalize_matrix:new e.bJ(t),u_globe_matrix:new e.bJ(t),u_merc_matrix:new e.bJ(t),u_grid_matrix:new e.cA(t),u_tl_parent:new e.bK(t),u_scale_parent:new e.bM(t),u_fade_t:new e.bM(t),u_opacity:new e.bM(t),u_image0:new e.bN(t),u_image1:new e.bN(t),u_raster_elevation:new e.bM(t),u_zoom_transition:new e.bM(t),u_merc_center:new e.bK(t),u_cutoff_params:new e.ca(t)}),rasterParticleTexture:t=>({u_texture:new e.bN(t),u_opacity:new e.bM(t)}),rasterParticleDraw:t=>({u_particle_texture:new e.bN(t),u_particle_texture_side_len:new e.bM(t),u_tile_offset:new e.bK(t),u_velocity:new e.bN(t),u_color_ramp:new e.bN(t),u_velocity_res:new e.bK(t),u_max_speed:new e.bM(t),u_uv_offset:new e.bK(t),u_data_scale:new e.bK(t),u_data_offset:new e.bM(t),u_particle_pos_scale:new e.bM(t),u_particle_pos_offset:new e.bK(t)}),rasterParticleUpdate:t=>({u_particle_texture:new e.bN(t),u_particle_texture_side_len:new e.bM(t),u_velocity:new e.bN(t),u_velocity_res:new e.bK(t),u_max_speed:new e.bM(t),u_speed_factor:new e.bM(t),u_reset_rate:new e.bM(t),u_rand_seed:new e.bM(t),u_uv_offset:new e.bK(t),u_data_scale:new e.bK(t),u_data_offset:new e.bM(t),u_particle_pos_scale:new e.bM(t),u_particle_pos_offset:new e.bK(t)}),symbol:t=>({u_is_size_zoom_constant:new e.bN(t),u_is_size_feature_constant:new e.bN(t),u_size_t:new e.bM(t),u_size:new e.bM(t),u_camera_to_center_distance:new e.bM(t),u_rotate_symbol:new e.bN(t),u_aspect_ratio:new e.bM(t),u_fade_change:new e.bM(t),u_matrix:new e.bJ(t),u_label_plane_matrix:new e.bJ(t),u_coord_matrix:new e.bJ(t),u_is_text:new e.bN(t),u_elevation_from_sea:new e.bN(t),u_pitch_with_map:new e.bN(t),u_texsize:new e.bK(t),u_texsize_icon:new e.bK(t),u_texture:new e.bN(t),u_texture_icon:new e.bN(t),u_gamma_scale:new e.bM(t),u_device_pixel_ratio:new e.bM(t),u_tile_id:new e.bL(t),u_zoom_transition:new e.bM(t),u_inv_rot_matrix:new e.bJ(t),u_merc_center:new e.bK(t),u_camera_forward:new e.bL(t),u_tile_matrix:new e.bJ(t),u_up_vector:new e.bL(t),u_ecef_origin:new e.bL(t),u_is_halo:new e.bN(t),u_icon_transition:new e.bM(t),u_color_adj_mat:new e.bJ(t),u_scale_factor:new e.bM(t)}),background:t=>({u_matrix:new e.bJ(t),u_emissive_strength:new e.bM(t),u_opacity:new e.bM(t),u_color:new e.cz(t)}),backgroundPattern:t=>({u_matrix:new e.bJ(t),u_emissive_strength:new e.bM(t),u_opacity:new e.bM(t),u_image:new e.bN(t),u_pattern_tl:new e.bK(t),u_pattern_br:new e.bK(t),u_texsize:new e.bK(t),u_pattern_size:new e.bK(t),u_pixel_coord_upper:new e.bK(t),u_pixel_coord_lower:new e.bK(t),u_pattern_units_to_pixels:new e.bK(t)}),terrainRaster:t=>({u_matrix:new e.bJ(t),u_image0:new e.bN(t),u_skirt_height:new e.bM(t),u_ground_shadow_factor:new e.bL(t)}),skybox:t=>({u_matrix:new e.bJ(t),u_sun_direction:new e.bL(t),u_cubemap:new e.bN(t),u_opacity:new e.bM(t),u_temporal_offset:new e.bM(t)}),skyboxGradient:t=>({u_matrix:new e.bJ(t),u_color_ramp:new e.bN(t),u_center_direction:new e.bL(t),u_radius:new e.bM(t),u_opacity:new e.bM(t),u_temporal_offset:new e.bM(t)}),skyboxCapture:t=>({u_matrix_3f:new e.cA(t),u_sun_direction:new e.bL(t),u_sun_intensity:new e.bM(t),u_color_tint_r:new e.ca(t),u_color_tint_m:new e.ca(t),u_luminance:new e.bM(t)}),globeRaster:t=>({u_proj_matrix:new e.bJ(t),u_globe_matrix:new e.bJ(t),u_normalize_matrix:new e.bJ(t),u_merc_matrix:new e.bJ(t),u_zoom_transition:new e.bM(t),u_merc_center:new e.bK(t),u_image0:new e.bN(t),u_grid_matrix:new e.cA(t),u_skirt_height:new e.bM(t),u_far_z_cutoff:new e.bM(t),u_frustum_tl:new e.bL(t),u_frustum_tr:new e.bL(t),u_frustum_br:new e.bL(t),u_frustum_bl:new e.bL(t),u_globe_pos:new e.bL(t),u_globe_radius:new e.bM(t),u_viewport:new e.bK(t)}),globeAtmosphere:t=>({u_frustum_tl:new e.bL(t),u_frustum_tr:new e.bL(t),u_frustum_br:new e.bL(t),u_frustum_bl:new e.bL(t),u_horizon:new e.bM(t),u_transition:new e.bM(t),u_fadeout_range:new e.bM(t),u_color:new e.ca(t),u_high_color:new e.ca(t),u_space_color:new e.ca(t),u_temporal_offset:new e.bM(t),u_horizon_angle:new e.bM(t)}),model:t=>({u_matrix:new e.bJ(t),u_lighting_matrix:new e.bJ(t),u_normal_matrix:new e.bJ(t),u_node_matrix:new e.bJ(t),u_lightpos:new e.bL(t),u_lightintensity:new e.bM(t),u_lightcolor:new e.bL(t),u_camera_pos:new e.bL(t),u_opacity:new e.bM(t),u_baseColorFactor:new e.ca(t),u_emissiveFactor:new e.ca(t),u_metallicFactor:new e.bM(t),u_roughnessFactor:new e.bM(t),u_baseTextureIsAlpha:new e.bN(t),u_alphaMask:new e.bN(t),u_alphaCutoff:new e.bM(t),u_baseColorTexture:new e.bN(t),u_metallicRoughnessTexture:new e.bN(t),u_normalTexture:new e.bN(t),u_occlusionTexture:new e.bN(t),u_emissionTexture:new e.bN(t),u_lutTexture:new e.bN(t),u_color_mix:new e.ca(t),u_aoIntensity:new e.bM(t),u_emissive_strength:new e.bM(t),u_occlusionTextureTransform:new e.ca(t)}),modelDepth:t=>({u_matrix:new e.bJ(t),u_instance:new e.bJ(t),u_node_matrix:new e.bJ(t)}),groundShadow:t=>({u_matrix:new e.bJ(t),u_ground_shadow_factor:new e.bL(t)}),stars:t=>({u_matrix:new e.bJ(t),u_up:new e.bL(t),u_right:new e.bL(t),u_intensity_multiplier:new e.bM(t)}),snowParticle:t=>({u_modelview:new e.bJ(t),u_projection:new e.bJ(t),u_time:new e.bM(t),u_cam_pos:new e.bL(t),u_velocityConeAperture:new e.bM(t),u_velocity:new e.bM(t),u_horizontalOscillationRadius:new e.bM(t),u_horizontalOscillationRate:new e.bM(t),u_boxSize:new e.bM(t),u_billboardSize:new e.bM(t),u_simpleShapeParameters:new e.bK(t),u_screenSize:new e.bK(t),u_thinningCenterPos:new e.bK(t),u_thinningShape:new e.bL(t),u_thinningAffectedRatio:new e.bM(t),u_thinningParticleOffset:new e.bM(t),u_particleColor:new e.ca(t),u_direction:new e.bL(t)}),rainParticle:t=>({u_modelview:new e.bJ(t),u_projection:new e.bJ(t),u_time:new e.bM(t),u_cam_pos:new e.bL(t),u_texScreen:new e.bN(t),u_velocityConeAperture:new e.bM(t),u_velocity:new e.bM(t),u_boxSize:new e.bM(t),u_rainDropletSize:new e.bK(t),u_distortionStrength:new e.bM(t),u_rainDirection:new e.bL(t),u_color:new e.ca(t),u_screenSize:new e.bK(t),u_thinningCenterPos:new e.bK(t),u_thinningShape:new e.bL(t),u_thinningAffectedRatio:new e.bM(t),u_thinningParticleOffset:new e.bM(t),u_shapeDirectionalPower:new e.bM(t),u_shapeNormalPower:new e.bM(t),u_mode:new e.bM(t)}),vignette:t=>({u_vignetteShape:new e.bL(t),u_vignetteColor:new e.ca(t)}),occlusion:t=>({u_matrix:new e.bJ(t),u_anchorPos:new e.bL(t),u_screenSizePx:new e.bK(t),u_occluderSizePx:new e.bK(t),u_color:new e.ca(t)})};class Io{constructor(e,t,i,r){this.id=Io.uniqueIdxCounter,Io.uniqueIdxCounter++,this.context=e;const n=e.gl;this.buffer=n.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||r||t.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){this.id=Io.uniqueIdxCounter,Io.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)}}Io.uniqueIdxCounter=0;const Co={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Po{constructor(e,t,i,r,n,o){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.instanceCount=o,this.context=e;const s=e.gl;this.buffer=s.createBuffer(),e.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||n||t.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,t){for(let i=0;i<this.attributes.length;i++){const r=t.attributes[this.attributes[i].name];void 0!==r&&e.enableVertexAttribArray(r)}}setVertexAttribPointers(e,t,i){for(let r=0;r<this.attributes.length;r++){const n=this.attributes[r],o=t.attributes[n.name];void 0!==o&&e.vertexAttribPointer(o,n.components,e[Co[n.type]],!1,this.itemSize,n.offset+this.itemSize*(i||0))}}setVertexAttribDivisor(e,t,i){for(let r=0;r<this.attributes.length;r++){const n=t.attributes[this.attributes[r].name];void 0!==n&&this.instanceCount&&this.instanceCount>0&&e.vertexAttribDivisor(n,i)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class zo{constructor(e,t,i,r,n){this.context=e,this.width=t,this.height=i;const o=this.framebuffer=e.gl.createFramebuffer();r&&(this.colorAttachment=new Pn(e,o)),n&&(this.depthAttachmentType=n,this.depthAttachment="renderbuffer"===n?new zn(e,o):new Dn(e,o))}destroy(){const e=this.context.gl;if(this.colorAttachment){const t=this.colorAttachment.get();t&&e.deleteTexture(t)}if(this.depthAttachment&&this.depthAttachmentType)if("renderbuffer"===this.depthAttachmentType){const t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t)}else{const t=this.depthAttachment.get();t&&e.deleteTexture(t)}e.deleteFramebuffer(this.framebuffer)}}class Do{constructor(e,t){this.gl=e,this.clearColor=new Kr(this),this.clearDepth=new Jr(this),this.clearStencil=new Qr(this),this.colorMask=new en(this),this.depthMask=new tn(this),this.stencilMask=new rn(this),this.stencilFunc=new nn(this),this.stencilOp=new on(this),this.stencilTest=new sn(this),this.depthRange=new an(this),this.depthTest=new ln(this),this.depthFunc=new cn(this),this.blend=new hn(this),this.blendFunc=new un(this),this.blendColor=new dn(this),this.blendEquation=new pn(this),this.cullFace=new fn(this),this.cullFaceSide=new mn(this),this.frontFace=new _n(this),this.program=new gn(this),this.activeTexture=new yn(this),this.viewport=new xn(this),this.bindFramebuffer=new vn(this),this.bindRenderbuffer=new bn(this),this.bindTexture=new wn(this),this.bindVertexBuffer=new Tn(this),this.bindElementBuffer=new Sn(this),this.bindVertexArrayOES=new Mn(this),this.pixelStoreUnpack=new En(this),this.pixelStoreUnpackPremultiplyAlpha=new An(this),this.pixelStoreUnpackFlipY=new In(this),this.options=t?{...t}:{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=e.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=e.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=e.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.forceManualRenderingForInstanceIDShaders=t&&!!t.forceManualRenderingForInstanceIDShaders||this.renderer&&-1!==this.renderer.indexOf("PowerVR"),this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=e.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=e.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=e.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.maxPointSize=e.getParameter(e.ALIASED_POINT_SIZE_RANGE)[1]}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArrayOES.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(e,t,i){return new Io(this,e,t,i)}createVertexBuffer(e,t,i,r,n){return new Po(this,e,t,i,r,n)}createRenderbuffer(e,t,i){const r=this.gl,n=r.createRenderbuffer();return this.bindRenderbuffer.set(n),r.renderbufferStorage(r.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),n}createFramebuffer(e,t,i,r){return new zo(this,e,t,i,r)}clear({color:e,depth:t,stencil:i,colorMask:r}){const n=this.gl;let o=0;e&&(o|=n.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set(r||[!0,!0,!0,!0])),void 0!==t&&(o|=n.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==i&&(o|=n.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),n.clear(o)}setCullFace(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1)}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1)}setColorMode(t){e.bn(t.blendFunction,Oi.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 Ro;function Lo(t,i,r,n,o,s,a){const l=t.context,c=l.gl,h=t.transform,u=t.getOrCreateProgram("collisionBox"),d=[];let p=0,f=0;for(let l=0;l<n.length;l++){const m=n[l],_=i.getTile(m),g=_.getBucket(r);if(!g)continue;const y=si(m,g,h);let x=y;0===o[0]&&0===o[1]||(x=t.translatePosMatrix(y,_,o,s));const v=a?g.textCollisionBox:g.iconCollisionBox,b=g.collisionCircleArray;if(b.length>0){const t=e.ab.mat4.create(),i=x;e.ab.mat4.mul(t,g.placementInvProjMatrix,h.glCoordMatrix),e.ab.mat4.mul(t,t,g.placementViewportMatrix),d.push({circleArray:b,circleOffset:f,transform:i,invTransform:t,projection:g.getProjection()}),p+=b.length/4,f=p}v&&(t.terrain&&t.terrain.setupElevationDraw(_,u),u.draw(t,c.LINES,ki.disabled,Bi.disabled,t.colorModeForRenderPass(),Ui.disabled,ao(x,h,_,g.getProjection()),r.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,null,h.zoom,null,[v.collisionVertexBuffer,v.collisionVertexBufferExt]))}if(!a||!d.length)return;const m=t.getOrCreateProgram("collisionCircle"),_=new e.cV;_.resize(4*p),_._trim();let g=0;for(const e of d)for(let t=0;t<e.circleArray.length/4;t++){const i=4*t,r=e.circleArray[i+0],n=e.circleArray[i+1],o=e.circleArray[i+2],s=e.circleArray[i+3];_.emplace(g++,r,n,o,s,0),_.emplace(g++,r,n,o,s,1),_.emplace(g++,r,n,o,s,2),_.emplace(g++,r,n,o,s,3)}(!Ro||Ro.length<2*p)&&(Ro=function(t){const i=2*t,r=new e.aU;r.resize(i),r._trim();for(let e=0;e<i;e++){const t=6*e;r.uint16[t+0]=4*e+0,r.uint16[t+1]=4*e+1,r.uint16[t+2]=4*e+2,r.uint16[t+3]=4*e+2,r.uint16[t+4]=4*e+3,r.uint16[t+5]=4*e+0}return r}(p));const y=l.createIndexBuffer(Ro,!0),x=l.createVertexBuffer(_,e.cW.members,!0);for(const i of d){const n={u_matrix:i.transform,u_inv_matrix:i.invTransform,u_camera_to_center_distance:(v=h).getCameraToCenterDistance(i.projection),u_viewport_size:[v.width,v.height]};m.draw(t,c.TRIANGLES,ki.disabled,Bi.disabled,t.colorModeForRenderPass(),Ui.disabled,n,r.id,x,y,e.b7.simpleSegment(0,2*i.circleOffset,i.circleArray.length,i.circleArray.length/2),null,h.zoom)}var v;x.destroy(),y.destroy()}const Oo=e.ab.mat4.create();function ko(t){const i=t._camera.getWorldToCamera(t.worldSize,1),r=e.ab.mat4.multiply([],i,t.globeMatrix);e.ab.mat4.invert(r,r);const n=[0,0,0],o=[0,1,0,0];return e.ab.vec4.transformMat4(o,o,r),n[0]=o[0],n[1]=o[1],n[2]=o[2],e.ab.vec3.normalize(n,n),n}function Fo({width:t,height:i,anchor:r,textOffset:n,textScale:o},s){const{horizontalAlign:a,verticalAlign:l}=e.bD(r),c=-(a-.5)*t,h=-(l-.5)*i,u=e.bC(r,n);return new e.P((c/o+u[0])*s,(h/o+u[1])*s)}function Bo(t,i,r,n,o,s,a,l,c,h,u){const d=t.text.placedSymbolArray,p=t.text.dynamicLayoutVertexArray,f=t.icon.dynamicLayoutVertexArray,m={},_=t.getProjection(),g=ai(l,_,s),y=s.elevation,x=_.upVectorScale(l.canonical,s.center.lat,s.worldSize).metersToTile;p.clear();for(let f=0;f<d.length;f++){const v=d.get(f),{tileAnchorX:b,tileAnchorY:w,numGlyphs:T}=v,S=v.hidden||!v.crossTileID||t.allowVerticalPlacement&&!v.placedOrientation?null:n[v.crossTileID];if(S){let n=0,d=0,f=0;if(y){const e=y?y.getAtTileOffset(l,b,w):0,[t,i,r]=_.upVector(l.canonical,b,w);n=e*t*x,d=e*i*x,f=e*r*x}let[M,E,A,I]=Zt(v.projectedAnchorX+n,v.projectedAnchorY+d,v.projectedAnchorZ+f,r?g:a);const C=$t(s.getCameraToCenterDistance(_),I);let P=o.evaluateSizeForFeature(t.textSizeData,h,v)*C/e.bw;r&&(P*=t.tilePixelRatio/c);const z=Fo(S,P);r?(({x:M,y:E,z:A}=_.projectTilePoint(b+z.x,w+z.y,l.canonical)),[M,E,A]=Zt(M+n,E+d,A+f,a)):(i&&z._rotate(-s.angle),M+=z.x,E+=z.y,A=0);const D=t.allowVerticalPlacement&&v.placedOrientation===e.bq.vertical?Math.PI/2:0;for(let t=0;t<T;t++)e.bt(p,M,E,A,D);u&&v.associatedIconIndex>=0&&(m[v.associatedIconIndex]={x:M,y:E,z:A,angle:D})}else ti(T,p)}if(u){f.clear();const i=t.icon.placedSymbolArray;for(let t=0;t<i.length;t++){const r=i.get(t),{numGlyphs:n}=r,o=m[t];if(r.hidden||!o)ti(n,f);else{const{x:t,y:i,z:r,angle:s}=o;for(let o=0;o<n;o++)e.bt(f,t,i,r,s)}}t.icon.dynamicLayoutVertexBuffer.updateData(f)}t.text.dynamicLayoutVertexBuffer.updateData(p)}function No(t,i,r,n,o,s,a={}){const l=r.paint.get("icon-translate"),c=r.paint.get("text-translate"),h=r.paint.get("icon-translate-anchor"),u=r.paint.get("text-translate-anchor"),d=r.layout.get("icon-rotation-alignment"),p=r.layout.get("text-rotation-alignment"),f=r.layout.get("icon-pitch-alignment"),m=r.layout.get("text-pitch-alignment"),_=r.layout.get("icon-keep-upright"),g=r.layout.get("text-keep-upright"),y=r.paint.get("icon-color-saturation"),x=r.paint.get("icon-color-contrast"),v=r.paint.get("icon-color-brightness-min"),b=r.paint.get("icon-color-brightness-max"),w="sea"===r.layout.get("symbol-elevation-reference"),T=t.context,S=T.gl,M=t.transform,E="map"===d,A="map"===p,I="map"===f,C="map"===m,P=void 0!==r.layout.get("symbol-sort-key").constantOr(1);let z=!1;const D=t.depthModeForSublayer(0,ki.ReadOnly),R=[e.at(M.center.lng),e.aA(M.center.lat)],L=r.layout.get("text-variable-anchor"),O="globe"===M.projection.name,k=[],F=[0,-1,0];for(const o of n){const n=i.getTile(o),s=n.getBucket(r);if(!s)continue;if("mercator"===s.projection.name&&O)continue;if(s.fullyClipped)continue;const d="globe"===s.projection.name,p=d?e.ae(M.zoom):0,f=ai(o,s.getProjection(),M),m=M.calculatePixelsToTileUnitsMatrix(n),T=L&&s.hasTextData(),D=s.hasIconTextFit()&&T&&s.hasIconData(),B=s.getProjection().createInversionMatrix(M,o.canonical),N=e=>{M.depthOcclusionForSymbolsAndCircles&&(r.hasInitialOcclusionOpacityProperties||t.terrain)&&(e.push("DEPTH_D24"),e.push("DEPTH_OCCLUSION"))},V=()=>{const i=E&&"point"!==r.layout.get("symbol-placement"),a=[];N(a);const c=i||D,u=r.paint.get("icon-image-cross-fade").constantOr(0);t.terrainRenderModeElevated()&&I&&a.push("PITCH_WITH_MAP_TERRAIN"),d&&(a.push("PROJECTION_GLOBE_VIEW"),c&&a.push("PROJECTED_POS_ON_VIEWPORT")),u>0&&a.push("ICON_TRANSITION"),s.icon.zOffsetVertexBuffer&&a.push("Z_OFFSET"),0===y&&0===x&&0===v&&1===b||a.push("COLOR_ADJUSTMENT"),s.sdfIcons&&a.push("RENDER_SDF");const g=s.icon.programConfigurations.get(r.id),T=t.getOrCreateProgram("symbol",{config:g,defines:a}),A=n.imageAtlasTexture?n.imageAtlasTexture.size:[0,0],C=s.iconSizeData,P=e.bp(C,M.zoom),z=I||0!==M.pitch,L=jt(f,n.tileID.canonical,I,E,M,s.getProjection(),m),k=qt(f,n.tileID.canonical,I,E,M,s.getProjection(),m),V=t.translatePosMatrix(k,n,l,h,!0),U=t.translatePosMatrix(f,n,l,h),j=c?Oo:L,G=E&&!I&&!i;let q=F;!O&&!M.mercatorFromTransition||E||(q=ko(M));const Z=d?q:F,$=r.getColorAdjustmentMatrix(y,x,v,b),H=bo(C.kind,P,G,I,t,U,j,V,w,!1,A,[0,0],!0,o,p,R,B,Z,s.getProjection(),$,u),W=n.imageAtlasTexture?n.imageAtlasTexture:null,X=1!==r.layout.get("icon-size").constantOr(0)||s.iconsNeedLinear,Y=s.sdfIcons||t.options.rotating||t.options.zooming||X||z?S.LINEAR:S.NEAREST,K=s.sdfIcons&&0!==r.paint.get("icon-halo-width").constantOr(1),J=t.terrain&&I&&i?e.ab.mat4.invert(e.ab.mat4.create(),L):Oo;if(i&&s.icon){const e=M.elevation,i=e?e.getAtTileOffsetFunc(o,M.center.lat,M.worldSize,s.getProjection()):null,r=Gt(f,n.tileID.canonical,I,E,M,s.getProjection(),m);Wt(s,f,t,!1,r,k,I,_,i,o)}return{program:T,buffers:s.icon,uniformValues:H,atlasTexture:W,atlasTextureIcon:null,atlasInterpolation:Y,atlasInterpolationIcon:null,isSDF:s.sdfIcons,hasHalo:K,tile:n,labelPlaneMatrixInv:J}},U=()=>{const i=A&&"point"!==r.layout.get("symbol-placement"),a=[],l=i||L||D;t.terrainRenderModeElevated()&&C&&a.push("PITCH_WITH_MAP_TERRAIN"),d&&(a.push("PROJECTION_GLOBE_VIEW"),l&&a.push("PROJECTED_POS_ON_VIEWPORT")),s.text.zOffsetVertexBuffer&&a.push("Z_OFFSET"),s.iconsInText&&a.push("RENDER_TEXT_AND_SYMBOL"),a.push("RENDER_SDF"),N(a);const h=s.text.programConfigurations.get(r.id),_=t.getOrCreateProgram("symbol",{config:h,defines:a});let y,x=[0,0],v=null;const b=s.textSizeData;s.iconsInText&&(x=n.imageAtlasTexture?n.imageAtlasTexture.size:[0,0],v=n.imageAtlasTexture?n.imageAtlasTexture:null,y=C||0!==M.pitch||t.options.rotating||t.options.zooming||"composite"===b.kind||"camera"===b.kind?S.LINEAR:S.NEAREST);const T=n.glyphAtlasTexture?n.glyphAtlasTexture.size:[0,0],E=r.layout.get("text-size-scale-range"),I=e.aw(t.scaleFactor,E[0],E[1]),P=e.bp(b,M.zoom,I),z=jt(f,n.tileID.canonical,C,A,M,s.getProjection(),m),k=qt(f,n.tileID.canonical,C,A,M,s.getProjection(),m),V=t.translatePosMatrix(k,n,c,u,!0),U=t.translatePosMatrix(f,n,c,u),j=l?Oo:z,G=A&&!C&&!i;let q=F;!O&&!M.mercatorFromTransition||A||(q=ko(M));const Z=bo(b.kind,P,G,C,t,U,j,V,w,!0,T,x,!0,o,p,R,B,d?q:F,s.getProjection(),null,null,I),$=n.glyphAtlasTexture?n.glyphAtlasTexture:null,H=S.LINEAR,W=0!==r.paint.get("text-halo-width").constantOr(1),X=t.terrain&&C&&i?e.ab.mat4.invert(e.ab.mat4.create(),z):Oo;if(i&&s.text){const e=M.elevation,i=e?e.getAtTileOffsetFunc(o,M.center.lat,M.worldSize,s.getProjection()):null,r=Gt(f,n.tileID.canonical,C,A,M,s.getProjection(),m);Wt(s,f,t,!0,r,k,C,g,i,o)}return{program:_,buffers:s.text,uniformValues:Z,atlasTexture:$,atlasTextureIcon:v,atlasInterpolation:H,atlasInterpolationIcon:y,isSDF:!0,hasHalo:W,tile:n,labelPlaneMatrixInv:X}},j=s.icon.segments.get().length,G=s.text.segments.get().length,q=j&&!a.onlyText?V():null,Z=G&&!a.onlyIcons?U():null,$=r.paint.get("icon-opacity").constantOr(1),H=r.paint.get("text-opacity").constantOr(1);if(P&&s.canOverlap){z=!0;const t=$&&!a.onlyText?s.icon.segments.get():[],i=H&&!a.onlyIcons?s.text.segments.get():[];for(const i of t)k.push({segments:new e.b7([i]),sortKey:i.sortKey,state:q});for(const t of i)k.push({segments:new e.b7([t]),sortKey:t.sortKey,state:Z})}else a.onlyText||k.push({segments:$?s.icon.segments:new e.b7([]),sortKey:0,state:q}),a.onlyIcons||k.push({segments:H?s.text.segments:new e.b7([]),sortKey:0,state:Z})}z&&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:M.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:i.labelPlaneMatrixInv}):t.setupDepthForOcclusion(M.depthOcclusionForSymbolsAndCircles,i.program),T.activeTexture.set(S.TEXTURE0),i.atlasTexture&&i.atlasTexture.bind(i.atlasInterpolation,S.CLAMP_TO_EDGE,!0),i.atlasTextureIcon&&(T.activeTexture.set(S.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,S.CLAMP_TO_EDGE,!0)),t.uploadCommonLightUniforms(t.context,i.program),i.hasHalo){const n=i.uniformValues;n.u_is_halo=1,Vo(i.buffers,e.segments,r,t,i.program,D,o,s,n,2),n.u_is_halo=0}else{if(i.isSDF){const n=i.uniformValues;i.hasHalo&&(n.u_is_halo=1,Vo(i.buffers,e.segments,r,t,i.program,D,o,s,n,1)),n.u_is_halo=0}Vo(i.buffers,e.segments,r,t,i.program,D,o,s,i.uniformValues,1)}}}function Vo(e,t,i,r,n,o,s,a,l,c){const h=[e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.iconTransitioningVertexBuffer,e.globeExtVertexBuffer,e.zOffsetVertexBuffer];n.draw(r,r.context.gl.TRIANGLES,o,s,a,Ui.disabled,l,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,r.transform.zoom,e.programConfigurations.get(i.id),h,c)}function Uo(t,i,r,n,o,s,a){const l=t.context.gl,c=r.paint.get("fill-pattern"),h=r.is3D(),u=h?t.stencilModeFor3D():Bi.disabled,d=c&&c.constantOr(1);let p,f,m,_,g;a?(f=d&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",p=l.LINES):(f=d?"fillPattern":"fill",p=l.TRIANGLES);for(const y of n){const n=i.getTile(y);if(d&&!n.patternsLoaded())continue;const x=n.getBucket(r);if(!x)continue;t.prepareDrawTile();const v=x.programConfigurations.get(r.id),b=t.isTileAffectedByFog(y),w=t.getOrCreateProgram(f,{config:v,overrideFog:b});d&&(t.context.activeTexture.set(l.TEXTURE0),n.imageAtlasTexture&&n.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),v.updatePaintBuffers());const T=c.constantOr(null);if(T&&n.imageAtlas){const t=n.imageAtlas,i=e.A.from(T),r=t.patternPositions[i.getSerializedPrimary()];r&&v.setConstantPatternPositions(r)}const S=t.translatePosMatrix(y.projMatrix,n,r.paint.get("fill-translate"),r.paint.get("fill-translate-anchor")),M=r.paint.get("fill-emissive-strength");if(a){_=x.indexBuffer2,g=x.segments2;const e=t.terrain&&t.terrain.renderingToTexture?t.terrain.drapeBufferSize:[l.drawingBufferWidth,l.drawingBufferHeight];m="fillOutlinePattern"===f&&d?so(S,M,t,n,e):oo(S,M,e)}else _=x.indexBuffer,g=x.segments,m=d?no(S,M,t,n):ro(S,M);t.uploadCommonUniforms(t.context,w,y.toUnwrapped()),w.draw(t,p,o,h?u:t.stencilModeForClipping(y),s,Ui.disabled,m,r.id,x.layoutVertexBuffer,_,g,r.paint,t.transform.zoom,v,void 0)}}function jo(t,i,r,n,o,s,a,l){r.resetLayerRenderingStats(t);const c=t.context,h=c.gl,u=t.transform,d=r.paint.get("fill-extrusion-pattern"),p=d.constantOr(1),f=r.paint.get("fill-extrusion-opacity"),m=t.style.enable3dLights(),_=r.paint.get(m&&!p?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),g=[r.paint.get("fill-extrusion-ambient-occlusion-intensity"),_],y=r.layout.get("fill-extrusion-edge-radius"),x=y>0&&!r.paint.get("fill-extrusion-rounded-roof"),v=x?0:y,b="globe"===u.projection.name?e.d3():0,w="globe"===u.projection.name,T=w?e.ae(u.zoom):0,S=[e.at(u.center.lng),e.aA(u.center.lat)],M="none"===r.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default"),E=r.paint.get("fill-extrusion-flood-light-color").toRenderColor(M?null:r.lut).toArray01().slice(0,3),A=r.paint.get("fill-extrusion-flood-light-intensity"),I=r.paint.get("fill-extrusion-vertical-scale"),C=0!==r.paint.get("fill-extrusion-line-width").constantOr(1),P=r.paint.get("fill-extrusion-height-alignment"),z=r.paint.get("fill-extrusion-base-alignment"),D=nr(t,r.paint.get("fill-extrusion-cutoff-fade-range")),R=[];let L;w&&R.push("PROJECTION_GLOBE_VIEW"),g[0]>0&&R.push("FAUX_AO"),x&&R.push("ZERO_ROOF_RADIUS"),l&&R.push("HAS_CENTROID"),A>0&&R.push("FLOOD_LIGHT"),D.shouldRenderCutoff&&R.push("RENDER_CUTOFF"),C&&R.push("RENDER_WALL_MODE");const O="shadow"===t.renderPass,k=t.shadowRenderer,F=O&&!!k;t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!0);let B=[0,0,0];if(k){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(B=ur(t.style,e,i)),O||(R.push("RENDER_SHADOWS","DEPTH_TEXTURE"),k.useNormalOffset&&R.push("NORMAL_OFFSET")),L=R.concat(["SHADOWS_SINGLE_CASCADE"])}const N=F?"fillExtrusionDepth":p?"fillExtrusionPattern":"fillExtrusion",V=r.getLayerRenderingStats();for(const m of n){const n=i.getTile(m),_=n.getBucket(r);if(!_||_.projection.name!==u.projection.name)continue;let y=!1;k&&(y=0===k.getMaxCascadeForTile(m.toUnwrapped()));const x=t.isTileAffectedByFog(m),M=_.programConfigurations.get(r.id),F=t.getOrCreateProgram(N,{config:M,defines:y?L:R,overrideFog:x});if(t.terrain&&t.terrain.setupElevationDraw(n,F,{useMeterToDem:!0}),!_.centroidVertexBuffer){const e=F.attributes.a_centroid_pos;void 0!==e&&h.vertexAttrib2f(e,0,0)}!O&&k&&k.setupShadows(n.tileID.toUnwrapped(),F,"vector-tile",n.tileID.overscaledZ),p&&(t.context.activeTexture.set(h.TEXTURE0),n.imageAtlasTexture&&n.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),M.updatePaintBuffers());const U=d.constantOr(null);if(U&&n.imageAtlas){const t=n.imageAtlas,i=e.A.from(U),r=t.patternPositions[i.getSerializedPrimary()];r&&M.setConstantPatternPositions(r)}const j=r.paint.get("fill-extrusion-vertical-gradient"),G=1/_.tileToMeter;let q;if(O&&k){if(Wo(n.tileID,_,t))continue;const e=k.calculateShadowPassMatrixFromTile(n.tileID.toUnwrapped());q=to(e,v,G,I,P,z)}else{const e=t.translatePosMatrix(m.expandedProjMatrix,n,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),i=u.projection.createInversionMatrix(u,m.canonical);q=p?io(e,t,j,f,g,v,G,m,n,b,P,z,T,S,i,E,I):eo(e,t,j,f,g,v,G,m,b,P,z,T,S,i,E,I,A,B)}t.uploadCommonUniforms(c,F,m.toUnwrapped(),null,D);let Z=_.segments;if("mercator"===u.projection.name&&!O&&(Z=_.getVisibleSegments(n.tileID,t.terrain,t.transform.getFrustum(0)),!Z.get().length))continue;if(V)if(O)for(const e of Z.get())V.numRenderedVerticesInShadowPass+=e.primitiveLength;else for(const e of Z.get())V.numRenderedVerticesInTransparentPass+=e.primitiveLength;const $=[];(t.terrain||l)&&$.push(_.centroidVertexBuffer),w&&$.push(_.layoutVertexExtBuffer),C&&$.push(_.wallVertexBuffer),F.draw(t,c.gl.TRIANGLES,o,s,a,Ui.backCCW,q,r.id,_.layoutVertexBuffer,_.indexBuffer,Z,r.paint,t.transform.zoom,M,$)}t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!1)}function Go(t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){const v=t.context,b=v.gl,w=t.transform,T=t.transform.zoom,S=[],M=nr(t,r.paint.get("fill-extrusion-cutoff-fade-range"));"clear"===h?(S.push("CLEAR_SUBPASS"),x&&(S.push("CLEAR_FROM_TEXTURE"),v.activeTexture.set(b.TEXTURE0),x.bind(b.LINEAR,b.CLAMP_TO_EDGE))):"sdf"===h&&S.push("SDF_SUBPASS"),g&&S.push("HAS_CENTROID"),M.shouldRenderCutoff&&S.push("RENDER_CUTOFF");const E=r.layout.get("fill-extrusion-edge-radius"),A=(e,i,n,h,y)=>{const b=i.programConfigurations.get(r.id),w=t.isTileAffectedByFog(e),A=t.getOrCreateProgram("fillExtrusionGroundEffect",{config:b,defines:S,overrideFog:w}),I=((e,t,i,r,n,o,s,a,l,c,h)=>({u_matrix:t,u_opacity:i,u_ao_pass:r?1:0,u_meter_to_tile:n,u_ao:o,u_flood_light_intensity:s,u_flood_light_color:a,u_attenuation:l,u_edge_radius:c,u_fb:0,u_fb_size:h,u_dynamic_offset:1}))(0,h,u,c,y,[d,p*y],f,m,_,T>=17?0:E*y,x?x.size[0]:0),C=[];g&&C.push(i.hiddenByLandmarkVertexBuffer),t.uploadCommonUniforms(v,A,e.toUnwrapped(),null,M),A.draw(t,v.gl.TRIANGLES,o,s,a,l,I,r.id,i.vertexBuffer,i.indexBuffer,n,r.paint,T,b,C)};for(const o of n){const n=i.getTile(o),s=n.getBucket(r);if(!s||s.projection.name!==w.projection.name||!s.groundEffect||s.groundEffect&&!s.groundEffect.hasData())continue;const a=s.groundEffect,l=1/s.tileToMeter;{const e=t.translatePosMatrix(o.projMatrix,n,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),i=a.getDefaultSegment();A(o,a,i,e,l)}if(y)for(let s=0;s<4;s++){const a=e.d4[s](o),c=i.getTile(a);if(!c)continue;const h=c.getBucket(r);if(!h||h.projection.name!==w.projection.name||!h.groundEffect||h.groundEffect&&!h.groundEffect.hasData())continue;const u=h.groundEffect;let d,p;0===s?(d=[-e.ag,0,0],p=1):1===s?(d=[e.ag,0,0],p=0):2===s?(d=[0,-e.ag,0],p=3):(d=[0,e.ag,0],p=2);const f=u.regionSegments[p];if(!f)continue;const m=new Float32Array(16);e.ab.mat4.translate(m,o.projMatrix,d),A(o,u,f,t.translatePosMatrix(m,n,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),l)}}}function qo(t,i,r,n,o,s,a){0===n.centroidVertexArray.length&&n.createCentroidsBuffer();const l=s?s.findDEMTileFor(r):null;if(!(l&&l.dem||a))return;s&&l&&l.dem&&n.selfDEMTileTimestamp!==l.dem._timestamp&&(n.borderDoneWithNeighborZ=[-1,-1,-1,-1],n.selfDEMTileTimestamp=l.dem._timestamp);const c=t=>new e.P(Math.ceil((t+e.d7)*e.d8),0),h=e=>{const t=i.getSource().minzoom,r=e=>{const t=i.getTileByID(e);if(t&&t.hasData())return t.getBucket(o)},n=[0,-1,1];for(const i of n){if(e.overscaledZ+i<t)continue;const n=r(e.calculateScaledKey(e.overscaledZ+i));if(n)return n}},u=[0,0,0],d=(t,i)=>(u[0]=Math.min(t.min.y,i.min.y),u[1]=Math.max(t.max.y,i.max.y),u[2]=e.ag-i.min.x>t.max.x?i.min.x-e.ag:t.max.x,u),p=(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.ag-i.min.y>t.max.y?i.min.y-e.ag:t.max.y,u),f=[(e,t)=>d(e,t),(e,t)=>d(t,e),(e,t)=>p(e,t),(e,t)=>p(t,e)],m=(t,i,n,o,a,c,h)=>{if(!s)return 0;const u=[[c?n:t,c?t:n,0],[c?n:i,c?i:n,0]],d=h<0?e.ag+h:h,p=[c?d:(t+i)/2,c?(t+i)/2:d,0];return 0===n&&h<0||0!==n&&h>0?s.getForTilePoints(a,[p],!0,o):u.push(p),s.getForTilePoints(r,u,!0,l),Math.max(u[0][2],u[1][2],p[2])/s.exaggeration()};for(let t=0;t<4;t++){const i=n.borderFeatureIndices[t];if(0===i.length)continue;const o=e.d4[t](r),l=h(o);if(!(l&&l instanceof e.d5))continue;const u=s?s.findDEMTileFor(o):null;if(!(u&&u.dem||a))continue;if(s&&u&&u.dem&&n.borderDEMTileTimestamp[t]!==u.dem._timestamp&&(n.borderDoneWithNeighborZ[t]=-1,n.borderDEMTileTimestamp[t]=u.dem._timestamp),n.borderDoneWithNeighborZ[t]===l.canonical.z)continue;0===l.centroidVertexArray.length&&l.createCentroidsBuffer();const d=(t<2?1:5)-t,p=l.borderDoneWithNeighborZ[d]!==n.canonical.z,y=l.borderFeatureIndices[d];let x=0;if(n.canonical.z!==l.canonical.z){for(const e of i)n.showCentroid(n.featuresOnBorder[e]);if(p)for(const e of y)l.showCentroid(l.featuresOnBorder[e]);n.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[d]=n.canonical.z}for(const r of i){const i=n.featuresOnBorder[r],s=n.centroidData[i.centroidDataIndex],h=i.borders[t];let p;for(;x<y.length;){p=l.featuresOnBorder[y[x]];const e=p.borders[d];if(e[1]>h[0]+3||e[0]>h[0]-3)break;l.showCentroid(p),x++}if(p&&x<y.length){const r=x;let v=0;for(;!(p.borders[d][0]>h[1]-3)&&(v++,++x!==y.length);)p=l.featuresOnBorder[y[x]];p=l.featuresOnBorder[y[r]];let b=!1;if(v>=1){const e=p.borders[d];Math.abs(h[0]-e[0])<3&&Math.abs(h[1]-e[1])<3&&(v=1,b=!0,x=r+1)}else if(0===v){n.showCentroid(i);continue}const w=l.centroidData[p.centroidDataIndex];a&&b&&(((_=s).flags|(g=w).flags)&e.d6?(_.flags|=e.d6,g.flags|=e.d6):(_.flags&=~e.d6,g.flags&=~e.d6));const T=i.intersectsCount()>1||p.intersectsCount()>1;if(v>1)x=r,s.centroidXY=w.centroidXY=new e.P(0,0);else if(u&&u.dem&&!T){const i=f[t](s,w),r=t%2?e.ag-1:0,n=m(i[0],Math.min(e.ag-1,i[1]),r,u,o,t<2,i[2]);s.centroidXY=w.centroidXY=c(n)}else T?s.centroidXY=w.centroidXY=new e.P(0,0):(s.centroidXY=n.encodeBorderCentroid(i),w.centroidXY=l.encodeBorderCentroid(p));n.writeCentroidToBuffer(s),l.writeCentroidToBuffer(w)}else n.showCentroid(i)}n.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[d]=n.canonical.z}var _,g;(n.needsCentroidUpdate||!n.centroidVertexBuffer&&0!==n.centroidVertexArray.length)&&n.uploadCentroid(t)}const Zo=[1,0,0],$o=[0,1,0],Ho=[0,0,1];function Wo(t,i,r){const n=r.transform,o=r.shadowRenderer;if(!o)return!0;const s=t.toUnwrapped(),a=n.tileSize*o._cascades[r.currentShadowCascade].scale;let l=i.maxHeight;if(n.elevation){const e=n.elevation.getMinMaxForTile(t);e&&(l+=e.max)}const c=[...o.shadowDirection];c[2]=-c[2];const h=o.computeSimplifiedTileShadowVolume(s,l,a,c);if(!h)return!1;const u=[Zo,$o,Ho,c,[c[0],0,c[2]],[0,c[1],c[2]]],d="globe"===n.projection.name,p=n.scaleZoom(a),f=e.bR.fromInvProjectionMatrix(n.invProjMatrix,n.worldSize,p,!d),m=o.getCurrentCascadeFrustum();return 0===f.intersectsPrecise(h.vertices,h.planes,u)||0===m.intersectsPrecise(h.vertices,h.planes,u)}function Xo(t){return[t[0]*e.d9,t[1]*e.d9,t[2]*e.d9,0]}function Yo(t,i,r,n,o,s,a,l,c){const h=n.getSource(),u=r.globeSharedBuffers;if(!u)return;let d,p,f;if(i&&(d=n.getTile(i)),h instanceof e.aJ?(p=h.texture,f=e.cI(0,0,r.transform)):d&&i&&(p=d.texture,f=e.cI(i.canonical.z,i.canonical.x,r.transform)),!p||!f)return;t||(f=e.ab.mat4.scale(e.ab.mat4.create(),f,[1,-1,1]));const m=r.context,_=m.gl,g="nearest"===o.paint.get("raster-resampling")?_.NEAREST:_.LINEAR,y=r.colorModeForDrapableLayerRenderPass(s),x=a.defines;x.push("GLOBE_POLES");const v=new ki(_.LEQUAL,ki.ReadWrite,r.depthRangeFor3D),b=Float32Array.from(r.transform.expandedFarZProjMatrix),w=Float32Array.from(e.bb(e.cH(new e.bT(0,0,0))));r.terrain&&r.terrain.prepareDrawTile(),m.activeTexture.set(_.TEXTURE0),p.bind(g,_.CLAMP_TO_EDGE),m.activeTexture.set(_.TEXTURE1),p.bind(g,_.CLAMP_TO_EDGE),p.useMipmap&&m.extTextureFilterAnisotropic&&r.transform.pitch>20&&_.texParameterf(_.TEXTURE_2D,m.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,m.extTextureFilterAnisotropicMax);const[T,S,M,E]=i?u.getPoleBuffers(i.canonical.z,!1):u.getPoleBuffers(0,!0),A=o.paint.get("raster-elevation");let I;t?(I=T,r.renderDefaultNorthPole=0!==A):(I=S,r.renderDefaultSouthPole=0!==A);const C=Xo(a.mix),P=((e,t,i,r,n,o,s,a,l,c,h,u,d)=>fo(e,t,i,new Float32Array(16),new Float32Array(9),[0,0],r,[0,0],[0,0,0,0],1,{opacity:1,mix:0},o,[0,0]||0,a,2,c,h,u,1,0,d))(b,w,f,e.ae(r.transform.zoom),0,o,0,A,0,C,a.offset,a.range,s),z=r.getOrCreateProgram("raster",{defines:x});r.uploadCommonUniforms(m,z,null),z.draw(r,_.TRIANGLES,v,c,y,l,P,o.id,I,M,E)}function Ko(e){const t=e._nearZ,i=e.projection.farthestPixelDistance(e),r=i-t,n=.2*e.height,o=t+n;return[t,i,(o-n-t)/r,(o-t)/r]}function Jo(e,t,i,r){if(e)return t instanceof tt&&e instanceof yt?t.getTextureDescriptor(e,i,!0):{texture:e.texture,mix:Xo(r.mix),offset:r.offset,buffer:0,tileSize:1}}var Qo=e.da([{name:"a_index",type:"Int16",components:1}]);class es{constructor(t,i,r,n){const o={width:r[0],height:r[1],data:null},s=t.gl;this.targetColorTexture=new e.T(t,o,s.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new e.T(t,o,s.RGBA8,{useMipmap:!1}),this.context=t,this.updateParticleTexture(i,n),this.lastInvalidatedAt=0}updateParticleTexture(t,i){if(this.particleTextureDimension===i.width)return;(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());const r=this.context.gl,n=i.width*i.height;this.particleTexture0=new e.T(this.context,i,r.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new e.T(this.context,i,r.RGBA8,{premultiply:!1,useMipmap:!1});const o=new e.db;o.reserve(n);for(let e=0;e<n;e++)o.emplaceBack(e);this.particleIndexBuffer=this.context.createVertexBuffer(o,Qo.members,!0),this.particleSegment=e.b7.simpleSegment(0,0,this.particleIndexBuffer.length,0),this.particleTextureDimension=i.width}update(t){return!(this.lastInvalidatedAt<t&&(this.lastInvalidatedAt=e.q.now(),1))}destroy(){this.targetColorTexture.destroy(),this.backgroundColorTexture.destroy(),this.particleIndexBuffer.destroy(),this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleSegment.destroy()}}function ts(t,i,r){if(!t)return null;const n=i.getTextureDescriptor(t,r,!0);if(!n)return null;let{texture:o,mix:s,offset:a,tileSize:l,buffer:c,format:h}=n;if(!o||!h)return null;let u=!1;return"uint32"===h&&(u=!0,s[3]=0,s=uo(e.dc,s,[0,r.paint.get("raster-particle-max-speed")]),a=po(e.dc,a,[0,r.paint.get("raster-particle-max-speed")])),{texture:o,textureOffset:[c/(l+2*c),l/(l+2*c)],tileSize:l,scalarData:u,scale:s,offset:a,defines:["RASTER_ARRAY",{uint8:"DATA_FORMAT_UINT8",uint16:"DATA_FORMAT_UINT16",uint32:"DATA_FORMAT_UINT32"}[h]]}}function is(e){const t=e._nearZ,i=e.projection.farthestPixelDistance(e),r=i-t,n=.2*e.height,o=t+n;return[t,i,(o-n-t)/r,(o-t)/r]}const rs=new e.aj(1,0,0,1),ns=new e.aj(0,1,0,1),os=new e.aj(0,0,1,1),ss=new e.aj(1,0,1,1),as=new e.aj(0,1,1,1);function ls(t,i,r,n,o,s,a){const l=t.context,c=t.transform,h=l.gl,u="globe"===c.projection.name,d=u?["PROJECTION_GLOBE_VIEW"]:[];let p=e.ab.mat4.clone(r.projMatrix);if(u&&e.ae(c.zoom)>0){const t=e.ba(r.canonical,c),i=e.dd(t);p=e.ab.mat4.multiply(new Float32Array(16),c.globeMatrix,i),e.ab.mat4.multiply(p,c.projMatrix,p)}const f=e.ab.mat4.create();f[12]+=2*o/(e.q.devicePixelRatio*c.width),f[13]+=2*s/(e.q.devicePixelRatio*c.height),e.ab.mat4.multiply(p,f,p);const m=t.getOrCreateProgram("debug",{defines:d}),_=i.getTileByID(r.key);t.terrain&&t.terrain.setupElevationDraw(_,m);const g=ki.disabled,y=Bi.disabled,x=t.colorModeForRenderPass(),v="$debug";l.activeTexture.set(h.TEXTURE0),t.emptyTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),u?_._makeGlobeTileDebugBuffers(t.context,c):_._makeDebugTileBoundsBuffers(t.context,c.projection);const b=_._tileDebugBuffer||t.debugBuffer,w=_._tileDebugIndexBuffer||t.debugIndexBuffer,T=_._tileDebugSegments||t.debugSegments;if(m.draw(t,h.LINE_STRIP,g,y,x,Ui.disabled,lo(p,n),v,b,w,T,null,null,null,[_._globeTileDebugBorderBuffer]),a){const e=_.latestRawTileData,i=Math.floor((e&&e.byteLength||0)/1024);let n=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(n+=` => ${r.overscaledZ}`),n+=` ${_.state}`,n+=` ${i}kb`,function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,r=e.context.gl,n=e.debugOverlayCanvas.getContext("2d");n.clearRect(0,0,i.width,i.height),n.shadowColor="white",n.shadowBlur=2,n.lineWidth=1.5,n.strokeStyle="white",n.textBaseline="top",n.font="bold 36px Open Sans, sans-serif",n.fillText(t,5,5),n.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(t,n)}const S=i.getTile(r).tileSize,M=512/Math.min(S,512)*(r.overscaledZ/c.zoom)*.5,E=_._tileDebugTextBuffer||t.debugBuffer,A=_._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,I=_._tileDebugTextSegments||t.debugSegments;m.draw(t,h.TRIANGLES,g,y,Oi.alphaBlended,Ui.disabled,lo(p,e.aj.transparent,M),v,E,A,I,null,null,null,[_._globeTileDebugTextBuffer])}function cs(e,t,i,r){us(e,0,t+i/2,e.transform.width,i,r)}function hs(e,t,i,r){us(e,t-i/2,0,i,e.transform.height,r)}function us(t,i,r,n,o,s){const a=t.context,l=a.gl;l.enable(l.SCISSOR_TEST),l.scissor(i*e.q.devicePixelRatio,r*e.q.devicePixelRatio,n*e.q.devicePixelRatio,o*e.q.devicePixelRatio),a.clear({color:s}),l.disable(l.SCISSOR_TEST)}const ds=e.da([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:ps}=ds;function fs(e,t,i,r){e.emplaceBack(t,i,r)}class ms{constructor(t){this.vertexArray=new e.de,this.indices=new e.aU,fs(this.vertexArray,-1,-1,1),fs(this.vertexArray,1,-1,1),fs(this.vertexArray,-1,1,1),fs(this.vertexArray,1,1,1),fs(this.vertexArray,-1,-1,-1),fs(this.vertexArray,1,-1,-1),fs(this.vertexArray,-1,1,-1),fs(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,ps),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=e.b7.simpleSegment(0,0,36,12)}}function _s(t,i,r,n,o,s){const a=t.context.gl,l=i.paint.get("sky-atmosphere-color"),c=i.paint.get("sky-atmosphere-halo-color"),h=i.paint.get("sky-atmosphere-sun-intensity"),u=((e,t,i,r,n)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:i,u_color_tint_r:[r.r,r.g,r.b,r.a],u_color_tint_m:[n.r,n.g,n.b,n.a],u_luminance:5e-5}))(e.ab.mat3.fromMat4(e.ab.mat3.create(),n),o,h,l,c);a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+s,i.skyboxTexture,0),r.draw(t,a.TRIANGLES,ki.disabled,Bi.disabled,Oi.unblended,Ui.frontCW,u,"skyboxCapture",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}const gs=e.da([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class ys{constructor(t){const i=new e.df;i.emplaceBack(-1,1,1,0,0),i.emplaceBack(1,1,1,1,0),i.emplaceBack(1,-1,1,1,1),i.emplaceBack(-1,-1,1,0,1);const r=new e.aU;r.emplaceBack(0,1,2),r.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(i,gs.members),this.indexBuffer=t.createIndexBuffer(r),this.segments=e.b7.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const xs=e.da([{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 vs{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class bs{constructor(t){this.colorModeAlphaBlendedWriteRGB=new Oi([1,Li,1,Li],e.aj.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new Oi([1,0,1,0],e.aj.transparent,[!1,!1,!1,!0]),this.params=new vs,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 ys(i);const t=this.params.sizeRange,r=this.params.intensityRange,n=function(t){const i=e.di(30),r=[];for(let n=0;n<t;++n){const t=2*Math.PI*i(),n=Math.acos(1-2*i())-.5*Math.PI;r.push(e.ab.vec3.fromValues(Math.cos(n)*Math.cos(t),Math.cos(n)*Math.sin(t),Math.sin(n)))}return r}(this.params.starsCount),o=e.di(300),s=new e.dg,a=new e.aU;let l=0;for(let i=0;i<n.length;++i){const c=e.ab.vec3.scale([],n[i],200),h=Math.max(0,1+.01*t*(1*o()-.5)),u=Math.max(0,1+.01*r*(1*o()-.5));s.emplaceBack(c[0],c[1],c[2],-1,-1,h,u),s.emplaceBack(c[0],c[1],c[2],1,-1,h,u),s.emplaceBack(c[0],c[1],c[2],1,1,h,u),s.emplaceBack(c[0],c[1],c[2],-1,1,h,u),a.emplaceBack(l+0,l+1,l+2),a.emplaceBack(l+0,l+2,l+3),l+=4}this.starsVx=i.createVertexBuffer(s,xs.members),this.starsIdx=i.createIndexBuffer(a),this.starsSegments=e.b7.simpleSegment(0,0,s.length,a.length)}}destroy(){this.atmosphereBuffer&&this.atmosphereBuffer.destroy(),this.starsVx&&this.starsVx.destroy(),this.starsIdx&&this.starsIdx.destroy()}drawAtmosphereGlow(t,i){const r=t.context,n=r.gl,o=t.transform,s=new ki(n.LEQUAL,ki.ReadOnly,[0,1]),a=e.ae(o.zoom),l=t.style.getLut(i.scope),c="none"===i.properties.get("color-use-theme"),h=i.properties.get("color").toRenderColor(c?null:l).toArray01(),u="none"===i.properties.get("high-color-use-theme"),d=i.properties.get("high-color").toRenderColor(u?null:l).toArray01(),p="none"===i.properties.get("space-color-use-theme"),f=i.properties.get("space-color").toRenderColor(p?null:l).toArray01PremultipliedAlpha(),m=5e-4,_=e.dh(i.properties.get("horizon-blend"),0,1,m,.25),g=e.cC(t,r,o)&&_===m?o.worldSize/(2*Math.PI*1.025)-1:o.globeRadius,y=t.frameCounter/1e3%1,x=e.ab.vec3.length(o.globeCenterInViewSpace),v=Math.sqrt(Math.pow(x,2)-Math.pow(g,2)),b=Math.acos(v/x),w=e=>{const i="globe"===o.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];e&&i.push("ALPHA_PASS");const l=t.getOrCreateProgram("globeAtmosphere",{defines:i}),c=((e,t,i,r,n,o,s,a,l,c,h,u)=>({u_frustum_tl:e,u_frustum_tr:t,u_frustum_br:i,u_frustum_bl:r,u_horizon:n,u_transition:o,u_fadeout_range:s,u_color:a,u_high_color:l,u_space_color:c,u_temporal_offset:h,u_horizon_angle:u}))(o.frustumCorners.TL,o.frustumCorners.TR,o.frustumCorners.BR,o.frustumCorners.BL,o.frustumCorners.horizon,a,_,h,d,f,y,b);t.uploadCommonUniforms(r,l);const u=this.atmosphereBuffer;u&&l.draw(t,n.TRIANGLES,s,Bi.disabled,e?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,Ui.backCW,c,e?"atmosphere_glow_alpha":"atmosphere_glow",u.vertexBuffer,u.indexBuffer,u.segments)};w(!1),w(!0)}drawStars(t,i){const r=e.aw(i.properties.get("star-intensity"),0,1);if(0===r)return;const n=t.context,o=n.gl,s=t.transform,a=t.getOrCreateProgram("stars"),l=e.ab.quat.identity([]);e.ab.quat.rotateX(l,l,-s._pitch),e.ab.quat.rotateZ(l,l,-s.angle),e.ab.quat.rotateX(l,l,e.ai(s._center.lat)),e.ab.quat.rotateY(l,l,-e.ai(s._center.lng));const c=e.ab.mat4.fromQuat(new Float32Array(16),l),h=e.ab.mat4.multiply([],s.starsProjMatrix,c),u=e.ab.mat3.fromMat4([],c),d=e.ab.mat3.invert([],u),p=[0,1,0];e.ab.vec3.transformMat3(p,p,d),e.ab.vec3.scale(p,p,this.params.sizeMultiplier);const f=[1,0,0];e.ab.vec3.transformMat3(f,f,d),e.ab.vec3.scale(f,f,this.params.sizeMultiplier);const m=(_=p,g=f,y=r,{u_matrix:Float32Array.from(h),u_up:_,u_right:g,u_intensity_multiplier:y});var _,g,y;t.uploadCommonUniforms(n,a),this.starsVx&&this.starsIdx&&a.draw(t,o.TRIANGLES,ki.disabled,Bi.disabled,this.colorModeAlphaBlendedWriteRGB,Ui.disabled,m,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}function ws(t,i){const r=[...t],n=i.cameraWorldSizeForFog/i.worldSize,o=e.ab.mat4.identity([]);return e.ab.mat4.scale(o,o,[n,n,1]),e.ab.mat4.multiply(r,o,r),e.ab.mat4.multiply(r,i.worldToFogMatrix,r),r}function Ts(t,i,r,n,o){const s=r.material,a=n.context,{baseColorTexture:l,metallicRoughnessTexture:c}=s.pbrMetallicRoughness,{normalTexture:h,occlusionTexture:u,emissionTexture:d}=s;function p(e,i,r){if(e&&(t.push(i),a.activeTexture.set(a.gl.TEXTURE0+r),e.gfxTexture)){const{minFilter:t,magFilter:i,wrapS:r,wrapT:n}=e.sampler;e.gfxTexture.bindExtraParam(t,i,r,n)}}p(l,"HAS_TEXTURE_u_baseColorTexture",Hi),p(c,"HAS_TEXTURE_u_metallicRoughnessTexture",Wi),p(h,"HAS_TEXTURE_u_normalTexture",Xi),p(u,"HAS_TEXTURE_u_occlusionTexture",Yi),p(d,"HAS_TEXTURE_u_emissionTexture",Ki),o&&(o.texture||(o.texture=new e.dk(n.context,o.image,[o.image.height,o.image.height,o.image.height],a.gl.RGBA8)),a.activeTexture.set(a.gl.TEXTURE0+Ji),o.texture&&o.texture.bind(a.gl.LINEAR,a.gl.CLAMP_TO_EDGE),t.push("APPLY_LUT_ON_GPU")),r.texcoordBuffer&&(t.push("HAS_ATTRIBUTE_a_uv_2f"),i.push(r.texcoordBuffer)),r.colorBuffer&&(t.push(12===r.colorBuffer.itemSize?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),i.push(r.colorBuffer)),r.normalBuffer&&(t.push("HAS_ATTRIBUTE_a_normal_3f"),i.push(r.normalBuffer)),r.pbrBuffer&&(t.push("HAS_ATTRIBUTE_a_pbr"),t.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),i.push(r.pbrBuffer)),"OPAQUE"!==s.alphaMode&&"MASK"!==s.alphaMode||t.push("UNPREMULT_TEXTURE_IN_SHADER"),s.defined||t.push("DIFFUSE_SHADED"),t.push("USE_STANDARD_DERIVATIVES");const f=n.shadowRenderer;f&&(t.push("RENDER_SHADOWS","DEPTH_TEXTURE"),f.useNormalOffset&&t.push("NORMAL_OFFSET"))}function Ss(t,i,r,n,o,s){const a=r.paint.get("model-opacity").constantOr(1),l=i.context,c=new ki(i.context.gl.LEQUAL,ki.ReadWrite,i.depthRangeFor3D),h=i.transform,u=t.mesh,d=u.material,p=d.pbrMetallicRoughness,f=i.style.fog;let m;m="pixels"===i.transform.projection.zAxisUnit?[...t.nodeModelMatrix]:e.ab.mat4.multiply([],n.zScaleMatrix,t.nodeModelMatrix),e.ab.mat4.multiply(m,n.negCameraPosMatrix,m);const _=e.ab.mat4.invert([],m);e.ab.mat4.transpose(_,_);const g="none"===r.paint.get("model-color-use-theme").constantOr("default"),y=r.paint.get("model-emissive-strength").constantOr(0),x=Mo(new Float32Array(t.worldViewProjection),new Float32Array(m),new Float32Array(_),null,i,a,p.baseColorFactor.toRenderColor(null),d.emissiveFactor,p.metallicFactor,p.roughnessFactor,d,y,r),v={defines:[]},b=[],w=i.shadowRenderer;w&&(w.useNormalOffset=!1),Ts(v.defines,b,u,i,g?null:r.lut);let T=null;if(f){const e=ws(t.nodeModelMatrix,i.transform);if(T=new Float32Array(e),"globe"!==h.projection.name){const t=u.aabb.min,i=u.aabb.max,[r,n]=f.getOpacityForBounds(e,t[0],t[1],i[0],i[1]);v.overrideFog=r>=Le||n>=Le}}const S=nr(i,r.paint.get("model-cutoff-fade-range"));S.shouldRenderCutoff&&v.defines.push("RENDER_CUTOFF");const M=i.getOrCreateProgram("model",v);i.uploadCommonUniforms(l,M,null,T,S),"shadow"!==i.renderPass&&w&&w.setupShadowsFromMatrix(t.nodeModelMatrix,M),M.draw(i,l.gl.TRIANGLES,c,o,s,u.material.doubleSided?Ui.disabled:Ui.backCCW,x,r.id,u.vertexBuffer,u.indexBuffer,u.segments,r.paint,i.transform.zoom,void 0,b)}function Ms(t,i,r,n,o,s,a){let l;l="globe"===t.projection.name?e.dl(r,t):[...r],e.ab.mat4.multiply(l,l,i.matrix);const c=e.ab.mat4.multiply([],n,l);if(i.meshes)for(const t of i.meshes){if("BLEND"!==t.material.alphaMode){a.push({mesh:t,depth:0,modelIndex:o,worldViewProjection:c,nodeModelMatrix:l});continue}const i=e.ab.vec3.transformMat4([],t.centroid,c);i[2]>0&&s.push({mesh:t,depth:i[2],modelIndex:o,worldViewProjection:c,nodeModelMatrix:l})}if(i.children)for(const e of i.children)Ms(t,e,r,n,o,s,a)}function Es(e,t,i,r){const n=i.shadowRenderer;if(!n)return;const o=n.getShadowPassDepthMode(),s=n.getShadowPassColorMode(),a=n.calculateShadowPassMatrixFromMatrix(t),l=Eo(a);i.getOrCreateProgram("modelDepth",{defines:i._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(i,i.context.gl.TRIANGLES,o,Bi.disabled,s,Ui.backCCW,l,r.id,e.vertexBuffer,e.indexBuffer,e.segments,r.paint,i.transform.zoom,void 0,void 0)}function As(t,i,r){const n=i.updateZoomBasedPaintProperties(),o=function(t,i,r){let n,o,s,a=t.terrain?t.terrain.exaggeration():0;if(t.terrain&&a>0){const i=t.terrain,o=i.findDEMTileFor(r);o&&o.dem?n=e.dn.create(i,r,o):a=0}if(0===a&&(i.terrainElevationMin=0,i.terrainElevationMax=0),a===i.validForExaggeration&&(0===a||n&&n._demTile&&n._demTile.tileID===i.validForDEMTile.id&&n._dem._timestamp===i.validForDEMTile.timestamp))return!1;for(const e in i.instancesPerModel){const t=i.instancesPerModel[e];for(let e=0;e<t.instancedDataArray.length;++e){const r=(n?a*n.getElevationAt(0|t.instancedDataArray.float32[16*e],0|t.instancedDataArray.float32[16*e+1],!0,!0):0)+t.instancesEvaluatedElevation[e];t.instancedDataArray.float32[16*e+6]=r,o=o?Math.min(i.terrainElevationMin,r):r,s=s?Math.max(i.terrainElevationMax,r):r}}return i.terrainElevationMin=o||0,i.terrainElevationMax=s||0,i.validForExaggeration=a,i.validForDEMTile=n&&n._demTile?{id:n._demTile.tileID,timestamp:n._dem._timestamp}:{id:void 0,timestamp:0},!0}(t,i,r);(n||o)&&(i.uploaded=!1,i.upload(t.context))}const Is={shadowUniformsInitialized:!1,useSingleShadowCascade:!1,tileMatrix:new Float64Array(16),shadowTileMatrix:new Float32Array(16),aabb:new e.cd([0,0,0],[e.ag,e.ag,0])};function Cs(t,i){const r=1<<t.canonical.z,n=i.getFreeCameraOptions().position,o=i.elevation,s=t.canonical.x/r,a=(t.canonical.x+1)/r,l=t.canonical.y/r,c=(t.canonical.y+1)/r;let h=i._centerAltitude;if(o){const e=o.getMinMaxForTile(t);e&&e.max>h&&(h=e.max)}const u=e.aw(n.x,s,a)-n.x,d=e.aw(n.y,l,c)-n.y,p=e.bH(h,i.center.lat)-n.z;return i._zoomFromMercatorZ(Math.sqrt(u*u+d*d+p*p))}function Ps(e,t,i,r,n,o,s){const a=e.context,l="shadow"===e.renderPass,c=e.shadowRenderer,h=l&&c?c.getShadowPassDepthMode():new ki(a.gl.LEQUAL,ki.ReadWrite,e.depthRangeFor3D),u=e.isTileAffectedByFog(o);if(i.meshes)for(const d of i.meshes){const p=["MODEL_POSITION_ON_GPU"],f=[];let m,_,g;r.instancedDataArray.length>20&&p.push("INSTANCED_ARRAYS");const y=nr(e,t.paint.get("model-cutoff-fade-range"));if(y.shouldRenderCutoff&&p.push("RENDER_CUTOFF"),l&&c)m=e.getOrCreateProgram("modelDepth",{defines:p}),_=Eo(s.shadowTileMatrix,s.shadowTileMatrix,Float32Array.from(i.matrix)),g=c.getShadowPassColorMode();else{Ts(p,f,d,e,"none"===t.paint.get("model-color-use-theme").constantOr("default")?null:t.lut),m=e.getOrCreateProgram("model",{defines:p,overrideFog:u});const r=d.material,l=r.pbrMetallicRoughness,h=t.paint.get("model-opacity").constantOr(1),x=t.paint.get("model-emissive-strength").constantOr(0);_=Mo(o.expandedProjMatrix,Float32Array.from(i.matrix),new Float32Array(16),null,e,h,l.baseColorFactor.toRenderColor(null),r.emissiveFactor,l.metallicFactor,l.roughnessFactor,r,x,t,n),c&&(s.shadowUniformsInitialized?m.setShadowUniformValues(a,c.getShadowUniformValues()):(c.setupShadows(o.toUnwrapped(),m,"model-tile",o.overscaledZ),s.shadowUniformsInitialized=!0)),g=y.shouldRenderCutoff||h<1||"OPAQUE"!==r.alphaMode?Oi.alphaBlended:Oi.unblended}e.uploadCommonUniforms(a,m,o.toUnwrapped(),null,y);const x=d.material.doubleSided?Ui.disabled:Ui.backCCW;if(r.instancedDataArray.length>20)f.push(r.instancedDataBuffer),m.draw(e,a.gl.TRIANGLES,h,Bi.disabled,g,x,_,t.id,d.vertexBuffer,d.indexBuffer,d.segments,t.paint,e.transform.zoom,void 0,f,r.instancedDataArray.length);else{const i=l?"u_instance":"u_normal_matrix";for(let n=0;n<r.instancedDataArray.length;++n)_[i]=new Float32Array(r.instancedDataArray.arrayBuffer,64*n,16),m.draw(e,a.gl.TRIANGLES,h,Bi.disabled,g,x,_,t.id,d.vertexBuffer,d.indexBuffer,d.segments,t.paint,e.transform.zoom,void 0,f)}}if(i.children)for(const a of i.children)Ps(e,t,a,r,n,o,s)}const zs=[1,-1,1];function Ds(t,i,r,n){if(!r.modelManager)return!0;const o=r.modelManager;if(!r.shadowRenderer)return!0;const s=r.shadowRenderer,a=i.aabb;let l=!0,c=t.maxHeight;if(0===c){let e=0;for(const i in t.instancesPerModel){const t=o.getModel(i,n);t?e=Math.max(e,Math.max(Math.max(t.aabb.max[0],t.aabb.max[1]),t.aabb.max[2])):l=!1}c=t.maxScale*e*1.41+t.maxVerticalOffset,l&&(t.maxHeight=c)}a.max[2]=c,a.min[2]+=t.terrainElevationMin,a.max[2]+=t.terrainElevationMax,e.ab.vec3.transformMat4(a.min,a.min,i.tileMatrix),e.ab.vec3.transformMat4(a.max,a.max,i.tileMatrix);const h=a.intersects(s.getCurrentCascadeFrustum());return 0===r.currentShadowCascade&&(t.isInsideFirstShadowMapFrustum=2===h),0===h}function Rs(t,i){const r=t.uniformValues.u_cutoff_params[0],n=t.uniformValues.u_cutoff_params[1],o=t.uniformValues.u_cutoff_params[2],s=t.uniformValues.u_cutoff_params[3];return n===r||s===o?1:e.aw(((i-r)/(n-r)-o)/(s-o),0,1)}function Ls(t,i,r,n){if(i.pitch<20)return 1;const o=i.getWorldToCameraMatrix();e.ab.mat4.multiply(o,o,t);const s=e.ab.vec4.fromValues(r.min[0],r.min[1],r.min[2],1);let a=e.ab.vec4.transformMat4(e.ab.vec4.create(),s,o),l=a,c=a;s[1]=r.max[1],a=e.ab.vec4.transformMat4(e.ab.vec4.create(),s,o),l=a[1]<l[1]?a:l,c=a[1]>c[1]?a:c,s[0]=r.max[0],a=e.ab.vec4.transformMat4(e.ab.vec4.create(),s,o),l=a[1]<l[1]?a:l,c=a[1]>c[1]?a:c,s[1]=r.min[1],a=e.ab.vec4.transformMat4(e.ab.vec4.create(),s,o),l=a[1]<l[1]?a:l,c=a[1]>c[1]?a:c;const h=e.aw(n[0],0,1),u=100*i.pixelsPerMeter*e.aw(n[1],0,1),d=e.aw(n[2],0,1),p=e.ab.vec4.lerp(e.ab.vec4.create(),l,c,h),f=Math.tan(.5*i.fovX),m=-p[2]*f;if(0===u)return p[1]<-Math.abs(m)?d:1;const _=(-Math.abs(m)-p[1])/u,g=(e,t,i)=>(1-i)*e+i*t,y=e.aw(g(1,d,_),d,1);return g(1,y,e.aw((i.pitch-20)/20,0,1))}class Os{}class ks{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(t,i,r){{const e=this._storage.get(i.id);if(e)return e.lastUsedFrameIdx=t,e.buf}const n=r.gl,o=n.getBufferParameter(n.ELEMENT_ARRAY_BUFFER,n.BUFFER_SIZE),s=new ArrayBuffer(o),a=new Int16Array(s);n.getBufferSubData(n.ELEMENT_ARRAY_BUFFER,0,new Int16Array(s));const l=new e.dq;for(let e=0;e<o/2;e+=3){const t=a[e],i=a[e+1],r=a[e+2];l.emplaceBack(t,i),l.emplaceBack(i,r),l.emplaceBack(r,t)}const c=r.bindVertexArrayOES.current,h=new Os;return h.buf=new Io(r,l),h.lastUsedFrameIdx=t,this._storage.set(i.id,h),r.bindVertexArrayOES.set(c),h.buf}update(e){for(const[t,i]of this._storage)e-i.lastUsedFrameIdx>30&&(i.buf.destroy(),this._storage.delete(t))}destroy(){for(const[e,t]of this._storage)t.buf.destroy(),this._storage.delete(e)}}class Fs{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 Bs=e.da([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_rainParticleData",components:4}]);class Ns{registerParameter(){}registerButton(){}registerBinding(){}refreshUI(){}}class Vs{constructor(e,t){this.revealStart=11,this.revealRange=2,e.registerParameter(this,[...t,"Reveal"],"revealStart",{min:0,max:17,step:.05}),e.registerParameter(this,[...t,"Reveal"],"revealRange",{min:.1,max:5.1,step:.05})}}const Us=e.da([{type:"Float32",name:"a_pos_2f",components:2}]);class js{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(t,i){const r=t.getOrCreateProgram("vignette");if(!this.vignetteVx||!this.vignetteIdx){const i=new e.dr,r=new e.aU;i.emplaceBack(-1,-1),i.emplaceBack(1,-1),i.emplaceBack(1,1),i.emplaceBack(-1,1),r.emplaceBack(0,1,2),r.emplaceBack(0,2,3),this.vignetteVx=t.context.createVertexBuffer(i,Us.members),this.vignetteIdx=t.context.createIndexBuffer(r)}const n=e.b7.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){t.uploadCommonUniforms(t.context,r);const e={u_vignetteShape:(o={vignetteShape:[i.start,i.range,Math.pow(10,i.fadePower)],vignetteColor:[i.color.r,i.color.g,i.color.b,i.color.a*i.strength]}).vignetteShape,u_vignetteColor:o.vignetteColor};r.draw(t,t.context.gl.TRIANGLES,ki.disabled,Bi.disabled,Oi.alphaBlended,Ui.disabled,e,"vignette",this.vignetteVx,this.vignetteIdx,n,{})}var o}}class Gs{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(t,i){const r=t.getFreeCameraOptions().position,n=r.toAltitude(),o=r.toLngLat(),s=e.ai(o.lng),a=e.ai(o.lat),l=t.pixelsPerMeter/i,c=s*e.ds,h=e.ds*Math.log(Math.tan(Math.PI/4+a/2));if(void 0===this._offsetXPrev)this._offsetXPrev=0,this._offsetYPrev=0,this._elevationPrev=0,this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0;else{const e=-this._offsetYPrev+h,t=-this._elevationPrev+n;this._accumulatedOffsetX+=(-this._offsetXPrev+c)*l,this._accumulatedOffsetY+=e*l,this._accumulatedElevation+=t*l,this._offsetXPrev=c,this._offsetYPrev=h,this._elevationPrev=n}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function qs(e,t){return[-(e[0]-Math.floor(e[0]/t)*t),-(e[1]-Math.floor(e[1]/t)*t),-(e[2]-Math.floor(e[2]/t)*t)]}function Zs(t){const i=e.di(1323123451230),r=[];for(let n=0;n<t;++n){const t=2*i()-1,n=2*i()-1,o=2*i()-1;r.push(e.ab.vec3.fromValues(t,n,o))}return r}function $s(t,i,r,n,o){const s=e.aw((o-r)/(n-r),0,1);return(1-s)*t+s*i}class Hs{constructor(e){this._movement=new Gs,this._accumulatedTimeFromStart=0,this._prevTime=Date.now()/1e3,this._vignette=new js,this._ppmScaleFactor=e}destroy(){this.particlesVx&&this.particlesVx.destroy(),this.particlesIdx&&this.particlesIdx.destroy(),this._vignette&&this._vignette.destroy()}updateOnRender(t,i){const r=t.transform;this._movement.update(r,this._ppmScaleFactor);const n=r.starsProjMatrix,o=e.ab.quat.identity([]);e.ab.quat.rotateX(o,o,e.ai(90)-r._pitch),e.ab.quat.rotateZ(o,o,-r.angle);const s=e.ab.mat4.fromQuat(new Float32Array(16),o),a=e.ab.mat4.fromValues(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1),l=e.ab.mat4.transpose([],a),c=e.ab.mat4.multiply([],l,s),h=Date.now()/1e3;return this._accumulatedTimeFromStart+=(h-this._prevTime)*i,this._prevTime=h,{projectionMatrix:n,modelviewMatrix:c}}}class Ws extends Hs{constructor(e){super(4.25),this._params={overrideStyleParameters:!1,intensity:.5,timeFactor:1,velocityConeAperture:0,velocity:300,boxSize:2500,dropletSizeX:1,dropletSizeYScale:10,distortionStrength:70,screenThinning:{intensity:.57,start:.46,range:1.17,fadePower:.17,affectedRatio:1,particleOffset:-.2},color:{r:.66,g:.68,b:.74,a:.7},direction:{x:-50,y:-35},shapeDirPower:2,shapeNormalPower:1},this._revealParams=new Vs(e.tp,["Precipitation","Rain"]),this._vignetteParams={strength:1,start:.7,range:1,fadePower:.4,color:{r:.27,g:.27,b:.27,a:1}},this.particlesCount=16e3}update(t){const i=t.context;if(!this.particlesVx){const t=Zs(this.particlesCount),r=new e.dt,n=new e.aU;let o=0;const s=e.di(1323123451230);for(let e=0;e<t.length;++e){const i=t[e],a=[2*s()-1,s(),s(),s()];r.emplaceBack(i[0],i[1],i[2],-1,-1,...a),r.emplaceBack(i[0],i[1],i[2],1,-1,...a),r.emplaceBack(i[0],i[1],i[2],1,1,...a),r.emplaceBack(i[0],i[1],i[2],-1,1,...a),n.emplaceBack(o+0,o+1,o+2),n.emplaceBack(o+0,o+2,o+3),o+=4}this.particlesVx=i.createVertexBuffer(r,Bs.members),this.particlesIdx=i.createIndexBuffer(n)}}draw(t){if(!this._params.overrideStyleParameters&&!t.style.rain)return;const i=this._params.overrideStyleParameters?this._revealParams:{revealStart:0,revealRange:.01},r=t.transform.zoom;if(i.revealStart>r)return;const n=$s(0,1,i.revealStart,i.revealStart+i.revealRange,r);if(!this.particlesVx||!this.particlesIdx)return;const o=structuredClone(this._params);let s=[-o.direction.x,o.direction.y,-100];e.ab.vec3.normalize(s,s);const a=structuredClone(this._vignetteParams);a.strength*=n,o.overrideStyleParameters||(o.intensity=t.style.rain.state.density,o.timeFactor=t.style.rain.state.intensity,o.color=structuredClone(t.style.rain.state.color),s=structuredClone(t.style.rain.state.direction),o.screenThinning.intensity=t.style.rain.state.centerThinning,o.dropletSizeX=t.style.rain.state.dropletSize[0],o.dropletSizeYScale=t.style.rain.state.dropletSize[1]/t.style.rain.state.dropletSize[0],o.distortionStrength=100*t.style.rain.state.distortionStrength,a.strength=1,a.color=structuredClone(t.style.rain.state.vignetteColor));const l=this.updateOnRender(t,o.timeFactor),c=t.context,h=c.gl,u=t.transform;this.screenTexture&&this.screenTexture.size[0]===t.width&&this.screenTexture.size[1]===t.height||(this.screenTexture=new e.T(c,{width:t.width,height:t.height,data:null},h.RGBA8)),o.distortionStrength>0&&(c.activeTexture.set(h.TEXTURE0),this.screenTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),h.copyTexSubImage2D(h.TEXTURE_2D,0,0,0,0,0,t.width,t.height));const d=t.getOrCreateProgram("rainParticle");t.uploadCommonUniforms(c,d),c.activeTexture.set(h.TEXTURE0),this.screenTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE);const p=[o.color.r,o.color.g,o.color.b,o.color.a],f=(i,r)=>{const a=qs(this._movement.getPosition(),i),c=o.dropletSizeX,f=o.dropletSizeX*o.dropletSizeYScale,m=t.width/2,_=t.height/2,g=$s(0,o.screenThinning.start,0,1,o.screenThinning.intensity),y=$s(.001,o.screenThinning.range,0,1,o.screenThinning.intensity),x=$s(0,o.screenThinning.particleOffset,0,1,o.screenThinning.intensity),v=(b={modelview:l.modelviewMatrix,projection:l.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:a,velocityConeAperture:o.velocityConeAperture,velocity:o.velocity,boxSize:i,rainDropletSize:[c,f],distortionStrength:o.distortionStrength,rainDirection:s,color:p,screenSize:[u.width,u.height],thinningCenterPos:[m,_],thinningShape:[g,y,Math.pow(10,o.screenThinning.fadePower)],thinningAffectedRatio:o.screenThinning.affectedRatio,thinningParticleOffset:x,shapeDirectionalPower:o.shapeDirPower,shapeNormalPower:o.shapeNormalPower,mode:r?0:1},{u_modelview:Float32Array.from(b.modelview),u_projection:Float32Array.from(b.projection),u_time:b.time,u_cam_pos:b.camPos,u_texScreen:0,u_velocityConeAperture:b.velocityConeAperture,u_velocity:b.velocity,u_boxSize:b.boxSize,u_rainDropletSize:b.rainDropletSize,u_distortionStrength:b.distortionStrength,u_rainDirection:b.rainDirection,u_color:b.color,u_screenSize:b.screenSize,u_thinningCenterPos:b.thinningCenterPos,u_thinningShape:b.thinningShape,u_thinningAffectedRatio:b.thinningAffectedRatio,u_thinningParticleOffset:b.thinningParticleOffset,u_shapeDirectionalPower:b.shapeDirectionalPower,u_shapeNormalPower:b.shapeNormalPower,u_mode:b.mode});var b;const w=Math.round(n*o.intensity*this.particlesCount),T=e.b7.simpleSegment(0,0,4*w,2*w);d.draw(t,h.TRIANGLES,ki.disabled,Bi.disabled,Oi.alphaBlended,Ui.disabled,v,"rain_particles",this.particlesVx,this.particlesIdx,T,{})};o.distortionStrength>0&&f(o.boxSize,!0),f(o.boxSize,!1),this._vignette.draw(t,a)}}const Xs=e.da([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_snowParticleData",components:4},{type:"Float32",name:"a_snowParticleDataHorizontalOscillation",components:2}]);class Ys extends Hs{constructor(e){super(2.25),this._params={overrideStyleParameters:!1,intensity:.85,timeFactor:.75,velocityConeAperture:70,velocity:40,horizontalOscillationRadius:4,horizontalOscillationRate:1.5,boxSize:2e3,billboardSize:2,shapeFadeStart:.27,shapeFadePower:.21,screenThinning:{intensity:.4,start:.15,range:1.4,fadePower:.24,affectedRatio:1,particleOffset:-.2},color:{r:1,g:1,b:1,a:1},direction:{x:-50,y:-35}},this._revealParams=new Vs(e.tp,["Precipitation","Snow"]),this._vignetteParams={strength:.3,start:.78,range:.46,fadePower:.2,color:{r:1,g:1,b:1,a:1}},this.particlesCount=16e3}update(t){const i=t.context;if(!this.particlesVx){const t=Zs(this.particlesCount),r=new e.du,n=new e.aU;let o=0;const s=e.di(1323123451230);for(let e=0;e<t.length;++e){const i=t[e],a=s(),l=s(),c=s(),h=[e/t.length,a,l,c],u=[s(),s()];r.emplaceBack(i[0],i[1],i[2],-1,-1,...h,...u),r.emplaceBack(i[0],i[1],i[2],1,-1,...h,...u),r.emplaceBack(i[0],i[1],i[2],1,1,...h,...u),r.emplaceBack(i[0],i[1],i[2],-1,1,...h,...u),n.emplaceBack(o+0,o+1,o+2),n.emplaceBack(o+0,o+2,o+3),o+=4}this.particlesVx=i.createVertexBuffer(r,Xs.members),this.particlesIdx=i.createIndexBuffer(n)}}draw(t){if(!this._params.overrideStyleParameters&&!t.style.snow)return;const i=structuredClone(this._params);let r=[-i.direction.x,i.direction.y,-100];e.ab.vec3.normalize(r,r);const n=structuredClone(this._vignetteParams),o=i.overrideStyleParameters?this._revealParams:{revealStart:0,revealRange:.01},s=t.transform.zoom;if(o.revealStart>s)return;const a=$s(0,1,o.revealStart,o.revealStart+o.revealRange,s);n.strength*=a,i.overrideStyleParameters||(i.intensity=t.style.snow.state.density,i.timeFactor=t.style.snow.state.intensity,i.color=structuredClone(t.style.snow.state.color),r=structuredClone(t.style.snow.state.direction),i.screenThinning.intensity=t.style.snow.state.centerThinning,i.billboardSize=2.79*t.style.snow.state.flakeSize,n.strength=1,n.color=structuredClone(t.style.snow.state.vignetteColor));const l=this.updateOnRender(t,i.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const c=t.context,h=c.gl,u=t.transform,d=t.getOrCreateProgram("snowParticle");t.uploadCommonUniforms(c,d),((i,n,o)=>{const s=qs(this._movement.getPosition(),i),c=u.width/2,p=u.height/2,f=$s(0,o.screenThinning.start,0,1,o.screenThinning.intensity),m=$s(.001,o.screenThinning.range,0,1,o.screenThinning.intensity),_=$s(0,o.screenThinning.particleOffset,0,1,o.screenThinning.intensity),g=(y={modelview:l.modelviewMatrix,projection:l.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:s,velocityConeAperture:o.velocityConeAperture,velocity:o.velocity,horizontalOscillationRadius:o.horizontalOscillationRadius,horizontalOscillationRate:o.horizontalOscillationRate,boxSize:i,billboardSize:1*o.billboardSize,simpleShapeParameters:[o.shapeFadeStart,o.shapeFadePower],screenSize:[u.width,u.height],thinningCenterPos:[c,p],thinningShape:[f,m,Math.pow(10,o.screenThinning.fadePower)],thinningAffectedRatio:o.screenThinning.affectedRatio,thinningParticleOffset:_,color:[o.color.r,o.color.g,o.color.b,o.color.a],direction:r},{u_modelview:Float32Array.from(y.modelview),u_projection:Float32Array.from(y.projection),u_time:y.time,u_cam_pos:y.camPos,u_velocityConeAperture:y.velocityConeAperture,u_velocity:y.velocity,u_horizontalOscillationRadius:y.horizontalOscillationRadius,u_horizontalOscillationRate:y.horizontalOscillationRate,u_boxSize:y.boxSize,u_billboardSize:y.billboardSize,u_simpleShapeParameters:y.simpleShapeParameters,u_screenSize:y.screenSize,u_thinningCenterPos:y.thinningCenterPos,u_thinningShape:y.thinningShape,u_thinningAffectedRatio:y.thinningAffectedRatio,u_thinningParticleOffset:y.thinningParticleOffset,u_particleColor:y.color,u_direction:y.direction});var y;const x=Math.round(a*o.intensity*this.particlesCount),v=e.b7.simpleSegment(0,0,4*x,2*x);this.particlesVx&&this.particlesIdx&&d.draw(t,h.TRIANGLES,ki.disabled,Bi.disabled,Oi.alphaBlended,Ui.disabled,g,"snow_particles",this.particlesVx,this.particlesIdx,v,{})})(i.boxSize,0,i),this._vignette.draw(t,n)}}const Ks={symbol:function(t,i,r,n,o){if("translucent"!==t.renderPass)return;const s=Bi.disabled,a=t.colorModeForRenderPass(),l=r.layout.get("text-variable-anchor"),c=r.layout.get("text-size-scale-range"),h=e.aw(t.scaleFactor,c[0],c[1]);l&&function(t,i,r,n,o,s,a,l){const c=i.transform,h="map"===o,u="map"===s;for(const i of t){const t=n.getTile(i),o=t.getBucket(r);if(!o||!o.text||!o.text.segments.get().length)continue;const s=e.bp(o.textSizeData,c.zoom,l),d=ai(i,o.getProjection(),c),p=c.calculatePixelsToTileUnitsMatrix(t),f=jt(d,t.tileID.canonical,u,h,c,o.getProjection(),p),m=o.hasIconTextFit()&&o.hasIconData();if(s){const r=Math.pow(2,c.zoom-t.tileID.overscaledZ);Bo(o,h,u,a,e.cX,c,f,i,r,s,m)}}}(n,t,r,i,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),o,h);const u=0!==r.paint.get("icon-opacity").constantOr(1),d=0!==r.paint.get("text-opacity").constantOr(1);void 0!==r.layout.get("symbol-sort-key").constantOr(1)&&(u||d)?No(t,i,r,n,s,a):(u&&No(t,i,r,n,s,a,{onlyIcons:!0}),d&&No(t,i,r,n,s,a,{onlyText:!0})),i.map.showCollisionBoxes&&(Lo(t,i,r,n,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),!0),Lo(t,i,r,n,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),!1))},circle:function(t,i,r,n){if("translucent"!==t.renderPass)return;const o=r.paint.get("circle-opacity"),s=r.paint.get("circle-stroke-width"),a=r.paint.get("circle-stroke-opacity"),l=void 0!==r.layout.get("circle-sort-key").constantOr(1),c=r.paint.get("circle-emissive-strength");if(0===o.constantOr(1)&&(0===s.constantOr(1)||0===a.constantOr(1)))return;const h=t.context,u=h.gl,d=t.transform,p=t.depthModeForSublayer(0,ki.ReadOnly),f=Bi.disabled,m=t.colorModeForDrapableLayerRenderPass(c),_="globe"===d.projection.name,g=[e.at(d.center.lng),e.aA(d.center.lat)],y=[];for(let o=0;o<n.length;o++){const s=n[o],a=i.getTile(s),c=a.getBucket(r);if(!c||c.projection.name!==d.projection.name)continue;const h=c.programConfigurations.get(r.id),u=e.cY(r),p=t.isTileAffectedByFog(s);_&&u.push("PROJECTION_GLOBE_VIEW"),u.push("DEPTH_D24"),t.terrain&&d.depthOcclusionForSymbolsAndCircles&&u.push("DEPTH_OCCLUSION");const f=t.getOrCreateProgram("circle",{config:h,defines:u,overrideFog:p}),m=c.layoutVertexBuffer,x=c.globeExtVertexBuffer,v=c.indexBuffer,b=d.projection.createInversionMatrix(d,s.canonical),w={programConfiguration:h,program:f,layoutVertexBuffer:m,globeExtVertexBuffer:x,indexBuffer:v,uniformValues:e.cZ(t,s,a,b,g,r),tile:a};if(l){const t=c.segments.get();for(const i of t)y.push({segments:new e.b7([i]),sortKey:i.sortKey,state:w})}else y.push({segments:c.segments,sortKey:0,state:w})}l&&y.sort(((e,t)=>e.sortKey-t.sortKey));const x={useDepthForOcclusion:d.depthOcclusionForSymbolsAndCircles};for(const e of y){const{programConfiguration:i,program:n,layoutVertexBuffer:o,globeExtVertexBuffer:s,indexBuffer:a,uniformValues:l,tile:c}=e.state,_=e.segments;t.terrain&&t.terrain.setupElevationDraw(c,n,x),t.uploadCommonUniforms(h,n,c.tileID.toUnwrapped()),n.draw(t,u.TRIANGLES,p,f,m,Ui.disabled,l,r.id,o,a,_,r.paint,d.zoom,i,[s])}},heatmap:function(t,i,r,n){if(0!==r.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const o=t.context,s=o.gl,a=Bi.disabled,l=new Oi([s.ONE,s.ONE,s.ONE,s.ONE],e.aj.transparent,[!0,!0,!0,!0]);!function(e,t,i,r){const n=e.gl,o=t.width*r,s=t.height*r;e.activeTexture.set(n.TEXTURE1),e.viewport.set([0,0,o,s]);let a=i.heatmapFbo;if(!a||a&&(a.width!==o||a.height!==s)){a&&a.destroy();const t=n.createTexture();n.bindTexture(n.TEXTURE_2D,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),a=i.heatmapFbo=e.createFramebuffer(o,s,!0,null),function(e,t,i,r,n,o){const s=e.gl;s.texImage2D(s.TEXTURE_2D,0,e.extRenderToTextureHalfFloat?s.RGBA16F:s.RGBA,n,o,0,s.RGBA,e.extRenderToTextureHalfFloat?s.HALF_FLOAT:s.UNSIGNED_BYTE,null),r.colorAttachment.set(i)}(e,0,t,a,o,s)}else n.bindTexture(n.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer)}(o,t,r,"globe"===t.transform.projection.name?.5:.25),o.clear({color:e.aj.transparent});const c=t.transform,h="globe"===c.projection.name,u=h?["PROJECTION_GLOBE_VIEW"]:[],d=h?Ui.frontCCW:Ui.disabled,p=[e.at(c.center.lng),e.aA(c.center.lat)];for(let e=0;e<n.length;e++){const f=n[e];if(i.hasRenderableParent(f))continue;const m=i.getTile(f),_=m.getBucket(r);if(!_||_.projection.name!==c.projection.name)continue;const g=t.isTileAffectedByFog(f),y=_.programConfigurations.get(r.id),x=t.getOrCreateProgram("heatmap",{config:y,defines:u,overrideFog:g}),{zoom:v}=t.transform;t.terrain&&t.terrain.setupElevationDraw(m,x),t.uploadCommonUniforms(o,x,f.toUnwrapped());const b=c.projection.createInversionMatrix(c,f.canonical);x.draw(t,s.TRIANGLES,ki.disabled,a,l,d,ho(t,f,m,b,p,v,r.paint.get("heatmap-intensity")),r.id,_.layoutVertexBuffer,_.indexBuffer,_.segments,r.paint,t.transform.zoom,y,h?[_.globeExtVertexBuffer]:null)}o.viewport.set([0,0,t.width,t.height])}else"translucent"===t.renderPass&&(t.context.setColorMode(t.colorModeForRenderPass()),function(t,i){const r=t.context,n=r.gl,o=i.heatmapFbo;if(!o)return;r.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,o.colorAttachment.get()),r.activeTexture.set(n.TEXTURE1);let s=i.colorRampTexture;s||(s=i.colorRampTexture=new e.T(r,i.colorRamp,n.RGBA8)),s.bind(n.LINEAR,n.CLAMP_TO_EDGE),t.getOrCreateProgram("heatmapTexture").draw(t,n.TRIANGLES,ki.disabled,Bi.disabled,t.colorModeForRenderPass(),Ui.disabled,((e,t)=>({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,i),i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,i.paint,t.transform.zoom)}(t,r))},line:function(t,i,r,n){if("translucent"!==t.renderPass)return;const o=r.paint.get("line-opacity"),s=r.paint.get("line-width");if(0===o.constantOr(1)||0===s.constantOr(1))return;const a=r.paint.get("line-emissive-strength"),l=r.paint.get("line-occlusion-opacity"),c=r.layout.get("line-elevation-reference"),h="meters"===r.layout.get("line-width-unit"),u="sea"===c,d=t.context,p=d.gl,f=!r.isDraped();if(f&&"globe"===t.transform.projection.name)return;const m=r.layout.get("line-cross-slope"),_=void 0!==m,g=m<1,y=f?new ki(t.depthOcclusion?p.GREATER:p.LEQUAL,ki.ReadOnly,t.depthRangeFor3D):t.depthModeForSublayer(0,ki.ReadOnly),x=t.colorModeForDrapableLayerRenderPass(a),v=t.terrain&&t.terrain.renderingToTexture,b=v?1:e.q.devicePixelRatio,w=r.paint.get("line-dasharray"),T=w.constantOr(1),S=r.layout.get("line-cap"),M=w.constantOr(null),E=S.constantOr(null),A=r.paint.get("line-pattern"),I=A.constantOr(1),C=A.constantOr(null),P=r.paint.get("line-opacity").constantOr(1);let z=!I&&1!==P||t.depthOcclusion&&l>0&&l<1;const D=r.paint.get("line-gradient"),R=I?"linePattern":"line",L=e.c_(r);let O;if(v&&t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(z=!1),0!==l&&t.depthOcclusion){const t=r.paint._values["line-opacity"];t&&t.value&&"constant"===t.value.kind?O=t.value:e.w(`Occlusion opacity for layer ${r.id} is supported only when line-opacity isn't data-driven.`)}if(f&&(t.forceTerrainMode=!0),!f&&0!==l&&t.terrain&&!v)return void e.w(`Occlusion opacity for layer ${r.id} is supported on terrain only if the layer has line-z-offset enabled.`);const k=z&&f?t.stencilModeFor3D():Bi.disabled;f&&(L.push("ELEVATED"),_&&L.push(g?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),u&&L.push("ELEVATION_REFERENCE_SEA")),"constant"!==s.value.kind&&!1===s.value.isLineProgressConstant&&L.push("VARIABLE_LINE_WIDTH");for(const o of n){const n=i.getTile(o);if(I&&!n.patternsLoaded())continue;const s=n.getBucket(r);if(!s)continue;t.prepareDrawTile();const a=s.programConfigurations.get(r.id),c=t.isTileAffectedByFog(o),m=t.getOrCreateProgram(R,{config:a,defines:L,overrideFog:c,overrideRtt:!f&&void 0});if(C&&n.imageAtlas){const t=e.A.from(C),i=n.imageAtlas.patternPositions[t.getSerializedPrimary()];i&&a.setConstantPatternPositions(i)}if(!I&&M&&E&&n.lineAtlas){const e=n.lineAtlas.getDash(M,E);e&&a.setConstantPatternPositions(e)}let[_,g]=r.paint.get("line-trim-offset");if("round"===E||"square"===E){const e=1;_!==g&&(0===_&&(_-=e),1===g&&(g+=e))}const w=v?o.projMatrix:null,S=h?1/s.tileToMeter/e.ar(n,1,t.transform.zoom):1,A=h?1/s.tileToMeter/e.ar(n,1,Math.floor(t.transform.zoom)):1,F=I?e.c$(t,n,r,w,b,S,A,[_,g]):e.d0(t,n,r,w,s.lineClipsArray.length,b,S,A,[_,g]);if(D){const n=s.gradients[r.id];let a=n.texture;if(r.gradientVersion!==n.version){let l=256;if(r.stepInterpolant){const r=i.getSource().maxzoom,n=o.canonical.z===r?Math.ceil(1<<t.transform.maxZoom-o.canonical.z):1;l=e.aw(e.d1(s.maxLineLength/e.ag*1024*n),256,d.maxTextureSize)}n.gradient=e.d2({expression:r.gradientExpression(),evaluationKey:"lineProgress",resolution:l,image:n.gradient||void 0,clips:s.lineClipsArray}),n.texture?n.texture.update(n.gradient):n.texture=new e.T(d,n.gradient,p.RGBA8),n.version=r.gradientVersion,a=n.texture}d.activeTexture.set(p.TEXTURE1),a.bind(r.stepInterpolant?p.NEAREST:p.LINEAR,p.CLAMP_TO_EDGE)}T&&(d.activeTexture.set(p.TEXTURE0),n.lineAtlasTexture&&n.lineAtlasTexture.bind(p.LINEAR,p.REPEAT),a.updatePaintBuffers()),I&&(d.activeTexture.set(p.TEXTURE0),n.imageAtlasTexture&&n.imageAtlasTexture.bind(p.LINEAR,p.CLAMP_TO_EDGE),a.updatePaintBuffers()),f&&!u&&t.terrain.setupElevationDraw(n,m),t.uploadCommonUniforms(d,m,o.toUnwrapped());const B=e=>{null!=O&&(O.value=P*l),m.draw(t,p.TRIANGLES,y,e,x,Ui.disabled,F,r.id,s.layoutVertexBuffer,s.indexBuffer,s.segments,r.paint,t.transform.zoom,a,[s.layoutVertexBuffer2,s.patternVertexBuffer,s.zOffsetVertexBuffer]),null!=O&&(O.value=P)};if(z&&!f){const e=t.stencilModeForClipping(o).ref;0===e&&v&&d.clear({stencil:0});const i={func:p.EQUAL,mask:255};F.u_alpha_discard_threshold=.8,B(new Bi(i,e,255,p.KEEP,p.KEEP,p.INVERT)),F.u_alpha_discard_threshold=0,B(new Bi(i,e,255,p.KEEP,p.KEEP,p.KEEP))}else z&&f&&(F.u_alpha_discard_threshold=.001),B(f?k:t.stencilModeForClipping(o))}f&&(t.forceTerrainMode=!1),z&&(t.resetStencilClippingMasks(),v&&d.clear({stencil:0})),0===l||t.depthOcclusion||v||t.layersWithOcclusionOpacity.push(t.currentLayer)},fill:function(t,i,r,n){const o=r.paint.get("fill-color"),s=r.paint.get("fill-opacity"),a=r.is3D(),l=new ki(t.context.gl.LEQUAL,ki.ReadWrite,t.depthRangeFor3D);if(0===s.constantOr(1))return;const c=r.paint.get("fill-emissive-strength"),h=t.colorModeForDrapableLayerRenderPass(c),u=r.paint.get("fill-pattern"),d=t.opaquePassEnabledForLayer()&&!u.constantOr(1)&&1===o.constantOr(e.aj.transparent).a&&1===s.constantOr(0)?"opaque":"translucent";if(t.renderPass===d){const e=a?l:t.depthModeForSublayer(1,"opaque"===t.renderPass?ki.ReadWrite:ki.ReadOnly);Uo(t,i,r,n,e,h,!1)}if(!a&&"translucent"===t.renderPass&&r.paint.get("fill-antialias")){const e=a?l:t.depthModeForSublayer(r.getPaintProperty("fill-outline-color")?2:0,ki.ReadOnly);Uo(t,i,r,n,e,h,!0)}},"fill-extrusion":function(t,i,r,n){const o=r.paint.get("fill-extrusion-opacity"),s=t.context,a=s.gl,l=t.terrain,c=l&&l.renderingToTexture;if(0===o)return;const h=t.conflationActive&&t.style.isLayerClipped(r,i.getSource()),u=t.style.order.indexOf(r.fqid);if(h&&function(e,t,i,r,n){for(const o of r){const r=t.getTile(o).getBucket(i);r&&(r.updateReplacement(o,e.replacementSource,n),r.uploadCentroid(e.context))}}(t,i,r,n,u),l||h)for(const e of n){const n=i.getTile(e).getBucket(r);n&&qo(t.context,i,e,n,r,l,h)}if("shadow"===t.renderPass&&t.shadowRenderer){const s=t.shadowRenderer;if(l&&o<.65&&r._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof e.a9)return;const a=s.getShadowPassDepthMode(),c=s.getShadowPassColorMode();jo(t,i,r,n,a,Bi.disabled,c,h)}else if("translucent"===t.renderPass){const u=!r.paint.get("fill-extrusion-pattern").constantOr(1),d=r.paint.get("fill-extrusion-color").constantOr(e.aj.white);if(!c&&0!==d.a){const e=new ki(t.context.gl.LEQUAL,ki.ReadWrite,t.depthRangeFor3D);1===o&&u?jo(t,i,r,n,e,Bi.disabled,Oi.unblended,h):(jo(t,i,r,n,e,Bi.disabled,Oi.disabled,h),jo(t,i,r,n,e,t.stencilModeFor3D(),t.colorModeForRenderPass(),h),t.resetStencilClippingMasks())}if(t.style.enable3dLights()&&u&&(!l&&"globe"!==t.transform.projection.name||c)){const o=r.paint.get("fill-extrusion-opacity"),u=r.paint.get("fill-extrusion-ambient-occlusion-intensity"),d=r.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),p=r.paint.get("fill-extrusion-flood-light-intensity"),f="none"===r.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default"),m=r.paint.get("fill-extrusion-flood-light-color").toRenderColor(f?null:r.lut).toArray01().slice(0,3),_=u>0&&d>0,g=p>0,y=(e,t,i)=>(1-i)*e+i*t,x=s=>{const l=t.depthModeForSublayer(1,ki.ReadOnly,a.LEQUAL,!0),c=r.paint.get(s?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),f=y(.1,3,c),_=t._showOverdrawInspector;if(!_){const c=new Bi({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),_=new Oi([a.ONE,a.ONE,a.ONE,a.ONE],e.aj.transparent,[!1,!1,!1,!0],a.MIN);Go(t,i,r,n,l,c,_,Ui.disabled,s,"sdf",o,u,d,p,m,f,h,!1)}{const c=_?Bi.disabled:new Bi({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),g=_?t.colorModeForRenderPass():new Oi([a.ONE_MINUS_DST_ALPHA,a.DST_ALPHA,a.ONE,a.ONE],e.aj.transparent,[!0,!0,!0,!0]);Go(t,i,r,n,l,c,g,Ui.disabled,s,"color",o,u,d,p,m,f,h,!1)}};if(c){const c=(s,l,c)=>{const f=t.depthModeForSublayer(1,ki.ReadOnly,a.LEQUAL,!1),_=r.paint.get(s?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),g=y(.1,3,_);{const c=new Oi([a.ONE,a.ONE,a.ONE,a.ONE],e.aj.transparent,[!1,!1,!1,!0]);Go(t,i,r,n,f,Bi.disabled,c,Ui.disabled,s,"clear",o,u,d,p,m,g,h,l)}{const c=new Bi({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),_=new Oi([a.ONE,a.ONE,a.ONE,a.ONE],e.aj.transparent,[!1,!1,!1,!0],a.MIN);Go(t,i,r,n,f,c,_,Ui.disabled,s,"sdf",o,u,d,p,m,g,h,l)}{const c=s?a.ZERO:a.ONE_MINUS_DST_ALPHA,_=new Bi({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),y=new Oi([c,a.DST_ALPHA,a.ONE_MINUS_DST_ALPHA,a.ZERO],e.aj.transparent,[!0,!0,!0,!0]);Go(t,i,r,n,f,_,y,Ui.disabled,s,"color",o,u,d,p,m,g,h,l)}{const _=new Oi([a.ONE,a.ONE,a.ONE,s?a.ZERO:a.ONE],e.aj.transparent,[!1,!1,!1,!0],s?a.FUNC_ADD:a.MAX);Go(t,i,r,n,f,Bi.disabled,_,Ui.disabled,s,"clear",o,u,d,p,m,g,h,l,c)}};if(_||g){let i;if(t.prepareDrawTile(),l){const t=l.drapeBufferSize[0],r=l.drapeBufferSize[1];i=l.framebufferCopyTexture,i&&(!i||i.size[0]===t&&i.size[1]===r)||(i&&i.destroy(),i=l.framebufferCopyTexture=new e.T(s,new e.r({width:t,height:r}),a.RGBA8)),i.bind(a.LINEAR,a.CLAMP_TO_EDGE),a.copyTexSubImage2D(a.TEXTURE_2D,0,0,0,0,0,t,r)}_&&c(!0,!1,i),g&&c(!1,!0,i)}}else _&&x(!0),g&&x(!1),(_||g)&&t.resetStencilClippingMasks()}}},hillshade:function(e,t,i,r){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;if(e.style.disableElevatedTerrain)return;const n=e.context,o=e.terrain&&e.terrain.renderingToTexture,[s,a]="translucent"!==e.renderPass||o?[{},r]:e.stencilConfigForOverlap(r);for(const r of a){const n=t.getTile(r);if(n.needsHillshadePrepare&&"offscreen"===e.renderPass)Xr(e,n,i);else if("translucent"===e.renderPass){const t=e.depthModeForSublayer(0,ki.ReadOnly),a=i.paint.get("hillshade-emissive-strength"),l=e.colorModeForDrapableLayerRenderPass(a),c=o&&e.terrain?e.terrain.stencilModeForRTTOverlap(r):s[r.overscaledZ];Hr(e,r,n,i,t,c,l)}}n.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks()},raster:function(t,i,r,n,o,s){if("translucent"!==t.renderPass)return;if(0===r.paint.get("raster-opacity"))return;const a="globe"===t.transform.projection.name,l=0!==r.paint.get("raster-elevation"),c=l&&a;if(t.renderElevatedRasterBackface&&!c)return;const h=t.context,u=h.gl,d=i.getSource(),p=function(t,i,r,n){const o=i.paint.get("raster-color"),s="raster-array"===t.type,a=[],l=i.paint.get("raster-resampling"),c=i.paint.get("raster-color-mix");let h=i.paint.get("raster-color-range");const u=[c[0],c[1],c[2],0],d=c[3];let p="nearest"===l?n.NEAREST:n.LINEAR;if(s&&(a.push("RASTER_ARRAY"),o||a.push("RASTER_COLOR"),"linear"===l&&a.push("RASTER_ARRAY_LINEAR"),p=n.NEAREST,!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],o){a.push("RASTER_COLOR"),r.activeTexture.set(n.TEXTURE2),i.updateColorRamp(h);let t=i.colorRampTexture;t||(t=i.colorRampTexture=new e.T(r,i.colorRamp,n.RGBA8)),t.bind(n.LINEAR,n.CLAMP_TO_EDGE)}return{mix:u,range:h,offset:d,defines:a,resampling:p}}(d,r,h,u);if(d instanceof e.aJ&&!n.length&&!a)return;const f=r.paint.get("raster-emissive-strength"),m=t.colorModeForDrapableLayerRenderPass(f),_=t.terrain&&t.terrain.renderingToTexture,g=!t.options.moving,y="nearest"===r.paint.get("raster-resampling")?u.NEAREST:u.LINEAR;if(d instanceof e.aJ&&!n.length&&(d.onNorthPole||d.onSouthPole)){const e=l?t.stencilModeFor3D():Bi.disabled;return void Yo(!!d.onNorthPole,null,t,i,r,f,p,Ui.disabled,e)}if(!n.length)return;const[x,v]=d instanceof e.aJ||_?[{},n]:t.stencilConfigForOverlap(n),b=v[v.length-1].overscaledZ;c&&p.defines.push("PROJECTION_GLOBE_VIEW"),l&&p.defines.push("RENDER_CUTOFF");const w=(n,o,v)=>{for(const w of n){const n=w.toUnwrapped(),T=i.getTile(w);if(_&&(!T||!T.hasData()))continue;h.activeTexture.set(u.TEXTURE0);const S=Jo(T,d,r,p);if(!S||!S.texture)continue;const{texture:M,mix:E,offset:A,tileSize:I,buffer:C}=S;let P,z;_?(P=ki.disabled,z=w.projMatrix):l?(P=new ki(u.LEQUAL,ki.ReadWrite,t.depthRangeFor3D),z=a?Float32Array.from(t.transform.expandedFarZProjMatrix):t.transform.calculateProjMatrix(n,g)):(P=t.depthModeForSublayer(w.overscaledZ-b,1===r.paint.get("raster-opacity")?ki.ReadWrite:ki.ReadOnly,u.LESS),z=t.transform.calculateProjMatrix(n,g));const D=t.terrain&&_?t.terrain.stencilModeForRTTOverlap(w):x[w.overscaledZ],R=s?0:r.paint.get("raster-fade-duration");T.registerFadeDuration(R);const L=i.findLoadedParent(w,0),O=jn(T,L,i,t.transform,R);let k,F;t.terrain&&t.terrain.prepareDrawTile(),h.activeTexture.set(u.TEXTURE0),M.bind(y,u.CLAMP_TO_EDGE),h.activeTexture.set(u.TEXTURE1),L?(L.texture&&L.texture.bind(y,u.CLAMP_TO_EDGE),k=Math.pow(2,L.tileID.overscaledZ-T.tileID.overscaledZ),F=[T.tileID.canonical.x*k%1,T.tileID.canonical.y*k%1]):M.bind(y,u.CLAMP_TO_EDGE),M.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 V=l?Ko(B):[0,0,0,0];let U,j,G,q,Z,$=0;if(c&&d instanceof e.aJ&&d.coordinates.length>3)U=Float32Array.from(e.bb(e.cH(new e.bT(0,0,0)))),j=Float32Array.from(B.globeMatrix),G=Float32Array.from(e.cD(B)),q=[e.at(B.center.lng),e.aA(B.center.lat)],N=d.elevatedGlobePerspectiveTransform,Z=d.elevatedGlobeGridMatrix||new Float32Array(9);else if(c){const t=e.cE(w.canonical);$=e.cF(t.getCenter().lat),U=Float32Array.from(e.bb(e.cH(w.canonical))),j=Float32Array.from(B.globeMatrix),G=Float32Array.from(e.cD(B)),q=[e.at(B.center.lng),e.aA(B.center.lat)],N=[0,0],Z=Float32Array.from(e.cG(w.canonical,t,$,B.worldSize/B._pixelsPerMercatorPixel))}else N=d instanceof e.aJ?d.perspectiveTransform:[0,0],U=new Float32Array(16),j=new Float32Array(9),G=new Float32Array(16),q=[0,0],Z=new Float32Array(9);const H=fo(z,U,j,G,Z,F||[0,0],e.ae(t.transform.zoom),q,V,k||1,O,r,N,l?r.paint.get("raster-elevation"):0,2,E,A,p.range,I,C,f),W=t.isTileAffectedByFog(w),X=t.getOrCreateProgram("raster",{defines:p.defines,overrideFog:W});if(t.uploadCommonUniforms(h,X,n),d instanceof e.aJ){const i=d.elevatedGlobeVertexBuffer,n=d.elevatedGlobeIndexBuffer;if(_||!a)d.boundsBuffer&&d.boundsSegments&&X.draw(t,u.TRIANGLES,P,Bi.disabled,m,Ui.disabled,H,r.id,d.boundsBuffer,t.quadTriangleIndexBuffer,d.boundsSegments);else if(i&&n){const s=B.zoom<=e.c6?d.elevatedGlobeSegments:d.getSegmentsForLongitude(B.center.lng);s&&X.draw(t,u.TRIANGLES,P,Bi.disabled,m,o,H,r.id,i,n,s)}}else if(c){P=new ki(u.LEQUAL,ki.ReadOnly,t.depthRangeFor3D);const e=t.globeSharedBuffers;if(e){const[i,n,s]=e.getGridBuffers($,!1);X.draw(t,u.TRIANGLES,P,v||D,t.colorModeForRenderPass(),o,H,r.id,i,n,s)}}else{const{tileBoundsBuffer:e,tileBoundsIndexBuffer:i,tileBoundsSegments:n}=t.getTileBoundsBuffers(T);X.draw(t,u.TRIANGLES,P,D,m,Ui.disabled,H,r.id,e,i,n)}}if(!(d instanceof e.aJ)&&c)for(const e of n){const n=e.canonical.y===(1<<e.canonical.z)-1;0===e.canonical.y&&Yo(!0,e,t,i,r,f,p,o,v||Bi.disabled),n&&Yo(!1,e,t,i,r,f,p,o===Ui.frontCW?Ui.backCW:Ui.frontCW,v||Bi.disabled)}};c?w(v,t.renderElevatedRasterBackface?Ui.backCW:Ui.frontCW,t.stencilModeFor3D()):w(v,Ui.disabled,void 0),t.resetStencilClippingMasks()},"raster-particle":function(t,i,r,n,o,s){"offscreen"===t.renderPass&&function(t,i,r,n){if(!n.length)return;const o=t.context,s=o.gl,a=i.getSource();if(!(a instanceof tt))return;const l=Math.ceil(Math.sqrt(r.paint.get("raster-particle-count")));let c=r.particlePositionRGBAImage;if(!c||c.width!==l){const t=function(e){const t=e*e,i=new Uint8Array(4*t),r=function(e){return e|=0,e=Math.imul(2747636419^e,2654435769),e=Math.imul(e^e>>>16,2654435769),((e=Math.imul(e^e>>>16,2654435769))>>>0)/4294967296},n=1/1.1;for(let e=0;e<t;e++){const t=n*(r(2*e+0)+_o),o=n*(r(2*e+1)+_o),s=255*t%1,a=255*o%1,l=s,c=o-a/255,h=a;i[4*e+0]=255*(t-s/255),i[4*e+1]=255*l,i[4*e+2]=255*c,i[4*e+3]=255*h}return i}(l);c=r.particlePositionRGBAImage=new e.r({width:l,height:l},t)}let h=r.particleFramebuffer;h?h.width!==l&&(h.destroy(),h=r.particleFramebuffer=o.createFramebuffer(l,l,!0,null)):h=r.particleFramebuffer=o.createFramebuffer(l,l,!0,null);const u=[];for(const e of n){const t=i.getTile(e);if(!(t instanceof yt))continue;const n=ts(t,a,r);if(!n)continue;const s=[t.tileSize,t.tileSize];let h=r.tileFramebuffer;h||(h=r.tileFramebuffer=o.createFramebuffer(s[0],s[1],!0,null));let d=t.rasterParticleState;d||(d=t.rasterParticleState=new es(o,e,s,c));const p=d.update(r.lastInvalidatedAt);d.particleTextureDimension!==l&&d.updateParticleTexture(e,c);const f=d.targetColorTexture;d.targetColorTexture=d.backgroundColorTexture,d.backgroundColorTexture=f;const m=d.particleTexture0;d.particleTexture0=d.particleTexture1,d.particleTexture1=m,u.push([e,n,d,p])}if(0===u.length)return;const d=e.q.now(),p=r.previousDrawTimestamp?.001*(d-r.previousDrawTimestamp):.0167;if(r.previousDrawTimestamp=d,r.hasColorMap()){o.activeTexture.set(s.TEXTURE0+2);let t=r.colorRampTexture;t||(t=r.colorRampTexture=new e.T(o,r.colorRamp,s.RGBA8)),t.bind(s.LINEAR,s.CLAMP_TO_EDGE)}o.bindFramebuffer.set(r.tileFramebuffer.framebuffer),function(t,i,r){const n=t.context,o=n.gl,s=i.tileFramebuffer;n.activeTexture.set(o.TEXTURE0);const a={u_texture:0,u_opacity:1.05*(c=i.paint.get("raster-particle-fade-opacity-factor"))/(c+.05)},l=t.getOrCreateProgram("rasterParticleTexture",{defines:[],overrideFog:!1});var c;for(const c of r){const[,,r,h]=c;s.colorAttachment.set(r.targetColorTexture.texture),n.viewport.set([0,0,s.width,s.height]),n.clear({color:e.aj.transparent}),h&&(r.backgroundColorTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),l.draw(t,o.TRIANGLES,ki.disabled,Bi.disabled,Oi.alphaBlended,Ui.disabled,a,i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments))}}(t,r,u),function(t,i,r,n){const o=t.context,s=o.gl,a=r.tileFramebuffer,l="globe"===t.transform.projection.name,c=r.paint.get("raster-particle-max-speed");for(const h of n){const[n,u,d]=h;o.activeTexture.set(s.TEXTURE0+0),u.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE),a.colorAttachment.set(d.targetColorTexture.texture);const p=t.getOrCreateProgram("rasterParticleDraw",{defines:u.defines,overrideFog:!1});o.activeTexture.set(s.TEXTURE0+1);const f=u.scalarData?[]:[0,1,2,3].map((t=>e.d4[t](n)));f.push(n);const m=n.canonical.x,_=n.canonical.y;for(const e of f){const o=i.getTile(l?e.wrapped():e);if(!o)continue;const a=o.rasterParticleState;if(!a)continue;const h=e.canonical.x+(1<<e.canonical.z)*(e.wrap-n.wrap),d=e.canonical.y;a.particleTexture0.bind(s.NEAREST,s.CLAMP_TO_EDGE);const f=yo(1,a.particleTexture0.size[0],[h-m,d-_],0,u.texture.size,2,c,u.textureOffset,u.scale,u.offset);p.draw(t,s.POINTS,ki.disabled,Bi.disabled,Oi.alphaBlended,Ui.disabled,f,r.id,a.particleIndexBuffer,void 0,a.particleSegment)}}}(t,i,r,u),o.bindFramebuffer.set(r.particleFramebuffer.framebuffer),function(t,i,r,n){const o=t.context,s=o.gl,a=i.paint.get("raster-particle-max-speed"),l=n*i.paint.get("raster-particle-speed-factor")*.15,c=function(e){return Math.pow(e,6)}(.01+1*i.paint.get("raster-particle-reset-rate-factor")),h=i.particleFramebuffer;o.viewport.set([0,0,h.width,h.height]);for(const n of r){const[,r,u]=n;o.activeTexture.set(s.TEXTURE0+0),r.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE),o.activeTexture.set(s.TEXTURE0+1);const d=u.particleTexture0;d.bind(s.NEAREST,s.CLAMP_TO_EDGE);const p=xo(1,d.size[0],0,r.texture.size,a,l,c,r.textureOffset,r.scale,r.offset);h.colorAttachment.set(u.particleTexture1.texture),o.clear({color:e.aj.transparent}),t.getOrCreateProgram("rasterParticleUpdate",{defines:r.defines}).draw(t,s.TRIANGLES,ki.disabled,Bi.disabled,Oi.unblended,Ui.disabled,p,i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments)}}(t,r,u,p)}(t,i,r,n),"translucent"===t.renderPass&&(function(t,i,r,n){const o=t.context,s=o.gl,a=i.getSource().tileSize,l=5*(1-e.ac(e.bY,e.bY+1,t.transform.zoom))*a+r.paint.get("raster-particle-elevation"),c=!t.options.moving,h="globe"===t.transform.projection.name;if(!n.length)return;const[u,d]=t.stencilConfigForOverlap(n),p=[];h&&p.push("PROJECTION_GLOBE_VIEW");const f=t.stencilModeFor3D();for(const n of d){const a=n.toUnwrapped(),d=i.getTile(n);if(!d.rasterParticleState)continue;const m=d.rasterParticleState,_=100;d.registerFadeDuration(_);const g=i.findLoadedParent(n,0),y=jn(d,g,i,t.transform,_);let x,v;t.terrain&&t.terrain.prepareDrawTile(),o.activeTexture.set(s.TEXTURE0),m.targetColorTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE),o.activeTexture.set(s.TEXTURE1),g&&g.rasterParticleState?(g.rasterParticleState.targetColorTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE),x=Math.pow(2,g.tileID.overscaledZ-d.tileID.overscaledZ),v=[d.tileID.canonical.x*x%1,d.tileID.canonical.y*x%1]):m.targetColorTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE);const b=h?Float32Array.from(t.transform.expandedFarZProjMatrix):t.transform.calculateProjMatrix(a,c),w=t.transform,T=is(w),S=e.cE(n.canonical),M=e.cF(S.getCenter().lat);let E,A,I,C,P;h?(E=Float32Array.from(e.bb(e.cH(n.canonical))),A=Float32Array.from(w.globeMatrix),I=Float32Array.from(e.cD(w)),C=[e.at(w.center.lng),e.aA(w.center.lat)],P=Float32Array.from(e.cG(n.canonical,S,M,w.worldSize/w._pixelsPerMercatorPixel))):(E=new Float32Array(16),A=new Float32Array(9),I=new Float32Array(16),C=[0,0],P=new Float32Array(9));const z=go(b,E,A,I,P,v||[0,0],e.ae(t.transform.zoom),C,T,x||1,y,l),D=t.isTileAffectedByFog(n),R=t.getOrCreateProgram("rasterParticle",{defines:p,overrideFog:D});if(t.uploadCommonUniforms(o,R,a),h){const e=new ki(s.LEQUAL,ki.ReadOnly,t.depthRangeFor3D),i=0,n=t.globeSharedBuffers;if(n){const[o,a,l]=n.getGridBuffers(M,0!==i);R.draw(t,s.TRIANGLES,e,f,Oi.alphaBlended,t.renderElevatedRasterBackface?Ui.frontCCW:Ui.backCCW,z,r.id,o,a,l)}}else{const e=t.depthModeForSublayer(0,ki.ReadOnly),i=u[n.overscaledZ],{tileBoundsBuffer:o,tileBoundsIndexBuffer:a,tileBoundsSegments:l}=t.getTileBoundsBuffers(d);R.draw(t,s.TRIANGLES,e,i,Oi.alphaBlended,Ui.disabled,z,r.id,o,a,l)}}t.resetStencilClippingMasks()}(t,i,r,n),t.style.map.triggerRepaint())},background:function(t,i,r,n){const o=r.paint.get("background-color"),s="none"===r.paint.get("background-color-use-theme").constantOr("default"),a=r.paint.get("background-opacity"),l=r.paint.get("background-emissive-strength"),c="viewport"===r.paint.get("background-pitch-alignment");if(0===a)return;const h=t.context,u=h.gl,d=t.transform,p=d.tileSize,f=r.paint.get("background-pattern");let m;if(void 0!==f){if(null===f)return;if(m=t.imageManager.getPattern(f.toString(),r.scope,t.style.getLut(r.scope)),!m)return}const _=!f&&1===o.a&&1===a&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass!==_)return;const g=Bi.disabled,y=t.depthModeForSublayer(0,"opaque"===_?ki.ReadWrite:ki.ReadOnly),x=t.colorModeForDrapableLayerRenderPass(l),v=f?"backgroundPattern":"background";let b,w=n;if(w||(b=t.getBackgroundTiles(),w=Object.values(b).map((e=>e.tileID))),f&&(h.activeTexture.set(u.TEXTURE0),t.imageManager.bind(t.context,r.scope)),c){const i=t.getOrCreateProgram(v,{overrideFog:!1,overrideRtt:!0}),n=new Float32Array(e.ab.mat4.identity([])),h=new e.aG(0,0,0,0,0),d=f?To(n,l,a,t,0,r.scope,m,c,{tileID:h,tileSize:p}):wo(n,l,a,o.toRenderColor(s?null:r.lut));i.draw(t,u.TRIANGLES,y,g,x,Ui.disabled,d,r.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments)}else for(const e of w){const _=t.isTileAffectedByFog(e),w=t.getOrCreateProgram(v,{overrideFog:_}),T=e.toUnwrapped(),S=n?e.projMatrix:t.transform.calculateProjMatrix(T);t.prepareDrawTile();const M=i?i.getTile(e):b?b[e.key]:new gt(e,p,d.zoom,t),E=f?To(S,l,a,t,0,r.scope,m,c,{tileID:e,tileSize:p}):wo(S,l,a,o.toRenderColor(s?null:r.lut));t.uploadCommonUniforms(h,w,T);const{tileBoundsBuffer:A,tileBoundsIndexBuffer:I,tileBoundsSegments:C}=t.getTileBoundsBuffers(M);w.draw(t,u.TRIANGLES,y,g,x,Ui.disabled,E,r.id,A,I,C)}},sky:function(t,i,r){const n=t._atmosphere?e.ae(t.transform.zoom):1,o=r.paint.get("sky-opacity")*n;if(0===o)return;const s=t.context,a=r.paint.get("sky-type"),l=new ki(s.gl.LEQUAL,ki.ReadOnly,[0,1]),c=t.frameCounter/1e3%1;"atmosphere"===a?"offscreen"===t.renderPass?r.needsSkyboxCapture(t)&&(function(t,i){const r=t.context,n=r.gl;let o=i.skyboxFbo;if(!o){o=i.skyboxFbo=r.createFramebuffer(32,32,!0,null),i.skyboxGeometry=new ms(r),i.skyboxTexture=r.gl.createTexture(),n.bindTexture(n.TEXTURE_CUBE_MAP,i.skyboxTexture),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MAG_FILTER,n.LINEAR);for(let e=0;e<6;++e)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,n.RGBA,32,32,0,n.RGBA,n.UNSIGNED_BYTE,null)}r.bindFramebuffer.set(o.framebuffer),r.viewport.set([0,0,32,32]);const s=i.getCenter(t,!0),a=t.getOrCreateProgram("skyboxCapture"),l=new Float64Array(16);e.ab.mat4.identity(l),e.ab.mat4.rotateY(l,l,.5*-Math.PI),_s(t,i,a,l,s,0),e.ab.mat4.identity(l),e.ab.mat4.rotateY(l,l,.5*Math.PI),_s(t,i,a,l,s,1),e.ab.mat4.identity(l),e.ab.mat4.rotateX(l,l,.5*-Math.PI),_s(t,i,a,l,s,2),e.ab.mat4.identity(l),e.ab.mat4.rotateX(l,l,.5*Math.PI),_s(t,i,a,l,s,3),e.ab.mat4.identity(l),_s(t,i,a,l,s,4),e.ab.mat4.identity(l),e.ab.mat4.rotateY(l,l,Math.PI),_s(t,i,a,l,s,5),r.viewport.set([0,0,t.width,t.height])}(t,r),r.markSkyboxValid(t)):"sky"===t.renderPass&&function(e,t,i,r,n){const o=e.context,s=o.gl,a=e.transform,l=e.getOrCreateProgram("skybox");o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_CUBE_MAP,t.skyboxTexture);const c=((e,t,i,r,n)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:r,u_temporal_offset:n}))(a.skyboxMatrix,t.getCenter(e,!1),0,r,n);e.uploadCommonUniforms(o,l),l.draw(e,s.TRIANGLES,i,Bi.disabled,e.colorModeForRenderPass(),Ui.backCW,c,"skybox",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}(t,r,l,o,c):"gradient"===a&&"sky"===t.renderPass&&function(t,i,r,n,o){const s=t.context,a=s.gl,l=t.transform,c=t.getOrCreateProgram("skyboxGradient");i.skyboxGeometry||(i.skyboxGeometry=new ms(s)),s.activeTexture.set(a.TEXTURE0);let h=i.colorRampTexture;h||(h=i.colorRampTexture=new e.T(s,i.colorRamp,a.RGBA8)),h.bind(a.LINEAR,a.CLAMP_TO_EDGE);const u=((t,i,r,n,o)=>({u_matrix:t,u_color_ramp:0,u_center_direction:i,u_radius:e.ai(r),u_opacity:n,u_temporal_offset:o}))(l.skyboxMatrix,i.getCenter(t,!1),i.paint.get("sky-gradient-radius"),n,o);t.uploadCommonUniforms(s,c),c.draw(t,a.TRIANGLES,r,Bi.disabled,t.colorModeForRenderPass(),Ui.backCW,u,"skyboxGradient",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}(t,r,l,o,c)},debug:function(t,i,r,n,o,s){for(let a=0;a<r.length;a++)if(o){const o=1,l=.8,c=new e.aj(n.r*l,n.g*l,n.b*l,1);ls(t,i,r[a],n,-o,-o,s),ls(t,i,r[a],n,-o,o,s),ls(t,i,r[a],n,o,o,s),ls(t,i,r[a],n,o,-o,s),ls(t,i,r[a],c,0,0,s)}else ls(t,i,r[a],n,0,0,s)},custom:function(t,i,r,n){const o=t.context,s=r.implementation;if(!t.transform.projection.unsupportedLayers||!t.transform.projection.unsupportedLayers.includes("custom")||t.terrain&&(t.terrain.renderingToTexture||"offscreen"===t.renderPass)&&r.isDraped(i)){if("offscreen"===t.renderPass){const i=s.prerender;if(i){if(t.setCustomLayerDefaults(),o.setColorMode(t.colorModeForRenderPass()),"globe"===t.transform.projection.name){const r=t.transform.pointMerc;i.call(s,o.gl,t.transform.customLayerMatrix(),t.transform.getProjection(),t.transform.globeToMercatorMatrix(),e.ae(t.transform.zoom),[r.x,r.y],t.transform.pixelsPerMeterRatio)}else i.call(s,o.gl,t.transform.customLayerMatrix());o.setDirty(),t.setBaseState()}}else if("translucent"===t.renderPass){if(t.terrain&&t.terrain.renderingToTexture){const i=s.renderToTile;if(i){const r=n[0].canonical,a=new e.aa(r.x+n[0].wrap*(1<<r.z),r.y,r.z);o.setDepthMode(ki.disabled),o.setStencilMode(Bi.disabled),o.setColorMode(t.colorModeForRenderPass()),t.setCustomLayerDefaults(),i.call(s,o.gl,a),o.setDirty(),t.setBaseState()}return}t.setCustomLayerDefaults(),o.setColorMode(t.colorModeForRenderPass()),o.setStencilMode(Bi.disabled);const i="3d"===s.renderingMode?new ki(t.context.gl.LEQUAL,ki.ReadWrite,t.depthRangeFor3D):t.depthModeForSublayer(0,ki.ReadOnly);if(o.setDepthMode(i),"globe"===t.transform.projection.name){const i=t.transform.pointMerc;s.render(o.gl,t.transform.customLayerMatrix(),t.transform.getProjection(),t.transform.globeToMercatorMatrix(),e.ae(t.transform.zoom),[i.x,i.y],t.transform.pixelsPerMeterRatio)}else s.render(o.gl,t.transform.customLayerMatrix());o.setDirty(),t.setBaseState(),o.bindFramebuffer.set(null)}}else e.w("Custom layers are not yet supported with this projection. Use mercator or globe to enable usage of custom layers.")},model:function(t,i,r,n){if("opaque"===t.renderPass)return;const o=r.paint.get("model-opacity").constantOr(1);if(0===o)return;const s=r.paint.get("model-cast-shadows");if("shadow"===t.renderPass){if(!s)return;if(t.terrain&&o<.65&&r._transitionablePaint._values["model-opacity"].value.expression instanceof e.a9)return}const a=t.shadowRenderer,l=r.paint.get("model-receive-shadows");a&&(a.useNormalOffset=!0,l||(a.enabled=!1));const c=()=>{a&&(a.useNormalOffset=!0,l||(a.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,r,n,o){const s=t.transform;if("mercator"!==s.projection.name)return void e.w(`Drawing 3D models for ${s.projection.name} projection is not yet implemented`);const a=s.getFreeCameraOptions().position;if(!t.modelManager)return;const l=t.modelManager;r.modelManager=l;const c=t.shadowRenderer;if(!r._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const h=r._unevaluatedLayout._values["model-id"],u={...r.layout.get("model-id").parameters},d=t.style.order.indexOf(r.fqid);for(const p of n){const n=i.getTile(p).getBucket(r);if(!n||n.projection.name!==s.projection.name)continue;const f=n.getModelUris();f&&!n.modelsRequested&&(l.addModelsFromBucket(f,o),n.modelsRequested=!0);const m=Cs(p,s);u.zoom=m;const _=h.possiblyEvaluate(u);if(As(t,n,p),Is.shadowUniformsInitialized=!1,Is.useSingleShadowCascade=!!c&&0===c.getMaxCascadeForTile(p.toUnwrapped()),"shadow"===t.renderPass&&c){if(1===t.currentShadowCascade&&n.isInsideFirstShadowMapFrustum)continue;const i=s.calculatePosMatrix(p.toUnwrapped(),s.worldSize);if(Is.tileMatrix.set(i),Is.shadowTileMatrix=Float32Array.from(c.calculateShadowPassMatrixFromMatrix(i)),Is.aabb.min.fill(0),Is.aabb.max[0]=Is.aabb.max[1]=e.ag,Is.aabb.max[2]=0,Ds(n,Is,t,r.scope))continue}const g=1<<p.canonical.z,y=[((a.x-p.wrap)*g-p.canonical.x)*e.ag,(a.y*g-p.canonical.y)*e.ag,a.z*g*e.ag];t.conflationActive&&Object.keys(n.instancesPerModel).length>0&&t.style.isLayerClipped(r,i.getSource())&&n.updateReplacement(p,t.replacementSource,d,o)&&(n.uploaded=!1,n.upload(t.context));for(let e in n.instancesPerModel){const i=n.instancesPerModel[e];i.features.length>0&&(e=_.evaluate(i.features[0].feature,{}));const s=l.getModel(e,o);if(s&&s.uploaded)for(const e of s.nodes)Ps(t,r,e,i,y,p,Is)}}}(t,i,r,n,"vector"===h.type?r.scope:""),void c();if(!h.loaded())return;if("batched-model"===h.type)return function(t,i,r,n){r.resetLayerRenderingStats(t);const o=t.context,s=t.transform,a=t.style.fog,l=t.shadowRenderer;if("mercator"!==s.projection.name)return void e.w(`Drawing 3D landmark models for ${s.projection.name} projection is not yet implemented`);const c=t.transform.getFreeCameraOptions().position,h=e.ab.vec3.scale([],[c.x,c.y,c.z],t.transform.worldSize),u=e.ab.vec3.negate([],h),d=e.ab.mat4.identity([]),p=e.dj(s.center.lat,s.zoom),f=e.ab.mat4.fromScaling([],[1,1,1/p]);e.ab.mat4.translate(d,d,u);const m=r.paint.get("model-opacity").constantOr(1),_=new ki(o.gl.LEQUAL,ki.ReadWrite,t.depthRangeFor3D),g=new ki(o.gl.LEQUAL,ki.ReadOnly,t.depthRangeFor3D),y=new e.cd([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),x="shadow"===t.renderPass,v=x&&l?l.getCurrentCascadeFrustum():s.getFrustum(s.scaleZoom(s.worldSize)),b=r.paint.get("model-front-cutoff"),w=b[2]<1,T=nr(t,r.paint.get("model-cutoff-fade-range")),S=r.getLayerRenderingStats();(function(e,t,i,r){const n=e.terrain?e.terrain.exaggeration():0,o=e.transform.zoom;for(const s of r){const r=t.getTile(s).getBucket(i);r&&(e.conflationActive&&r.updateReplacement(s,e.replacementSource),r.evaluateScale(e,i),e.terrain&&n>0&&r.elevationUpdate(e.terrain,n,s,i.source),r.needsReEvaluation(e,o,i)&&r.evaluate(i))}})(t,i,r,n),function(){let c,u,M;w?(c=n.length-1,u=-1,M=-1):(c=0,u=n.length,M=1);const E=new Float64Array(16),A=e.ab.vec3.create(),I=new e.P(0,0);for(let C=c;C!==u;C+=M){const c=n[C],u=i.getTile(c).getBucket(r);if(!u||!u.uploaded)continue;let M=!1;l&&(M=0===l.getMaxCascadeForTile(c.toUnwrapped()));const P=s.calculatePosMatrix(c.toUnwrapped(),s.worldSize),z=u.modelTraits;!x&&w&&(e.ab.mat4.invert(E,P),e.ab.vec3.transformMat4(A,h,E),I.x=A[0],I.y=A[1]);const D=[];for(const i of u.getNodesInfo()){if(i.hiddenByReplacement)continue;if(!i.node.meshes)continue;const r=i.node;let n=0;t.terrain&&r.elevation&&(n=r.elevation*t.terrain.exaggeration());const o=(()=>{const t=i.aabb;return y.min=[...t.min],y.max=[...t.max],y.min[2]+=n,y.max[2]+=n,e.ab.vec3.transformMat4(y.min,y.min,P),e.ab.vec3.transformMat4(y.max,y.max,P),y})(),a=i.evaluatedScale;if(a[0]<=1&&a[1]<=1&&a[2]<=1&&0===o.intersects(v))continue;if(!x&&w){const t=1/6;i.cameraCollisionOpacity=h[0]>o.min[0]&&h[0]<o.max[0]&&h[1]>o.min[1]&&h[1]<o.max[1]&&h[2]*p<o.max[2]&&r.footprint&&e.bA(I,r.footprint)?Math.max(i.cameraCollisionOpacity-t,0):Math.min(1,i.cameraCollisionOpacity+t)}const l=[...P],c=r.anchor?r.anchor[0]:0,u=r.anchor?r.anchor[1]:0;e.ab.mat4.translate(l,l,[c*(a[0]-1),u*(a[1]-1),n]),e.ab.vec3.exactEquals(a,e.dm)||e.ab.mat4.scale(l,l,a);const d=e.ab.mat4.multiply([],l,r.matrix),f=e.ab.mat4.multiply([],s.expandedFarZProjMatrix,d),_=e.ab.mat4.multiply([],s.expandedFarZProjMatrix,l),g=e.ab.vec4.transformMat4([],[c,u,n,1],f)[2];r.hidden=!1;let S=m;x||(w&&(S*=i.cameraCollisionOpacity,S*=Ls(l,s,i.aabb,b)),S*=Rs(T,g)),0!==S?D.push({nodeInfo:i,depth:g,opacity:S,wvpForNode:f,wvpForTile:_,nodeModelMatrix:d,tileModelMatrix:l}):r.hidden=!0}x||D.sort(((e,t)=>!w||1===e.opacity&&1===t.opacity?e.depth<t.depth?-1:1:1===e.opacity?-1:1===t.opacity?1:e.depth>t.depth?-1:1));for(const i of D){const n=i.nodeInfo,c=n.node;let h=e.ab.mat4.multiply([],f,i.tileModelMatrix);e.ab.mat4.multiply(h,d,h);const u=e.ab.mat4.invert([],h);e.ab.mat4.transpose(u,u),e.ab.mat4.scale(u,u,zs),h=e.ab.mat4.multiply(h,h,c.matrix);const p="light-beam"===t.renderPass,m="none"===r.paint.get("model-color-use-theme").constantOr("default"),y=z&e.dp.HasMapboxMeshFeatures,v=y?0:n.evaluatedRMEA[0][2];for(let e=0;e<c.meshes.length;++e){const d=c.meshes[e],f=e===c.lightMeshIndex;let b=i.wvpForNode;if(f){if(!p&&!t.terrain&&t.shadowRenderer){t.currentLayer<t.firstLightBeamLayer&&(t.firstLightBeamLayer=t.currentLayer);continue}b=i.wvpForTile}else if(p)continue;const w={defines:[]},T=[];if(!x&&l&&(l.useNormalOffset=!!d.normalBuffer),Ts(w.defines,T,d,t,m?null:r.lut),y||w.defines.push("DIFFUSE_SHADED"),M&&w.defines.push("SHADOWS_SINGLE_CASCADE"),S&&(x?S.numRenderedVerticesInShadowPass+=d.vertexArray.length:S.numRenderedVerticesInTransparentPass+=d.vertexArray.length),x){Es(d,i.nodeModelMatrix,t,r);continue}let E=null;if(a){const e=ws(i.nodeModelMatrix,t.transform);if(E=new Float32Array(e),"globe"!==s.projection.name){const t=d.aabb.min,i=d.aabb.max,[r,n]=a.getOpacityForBounds(e,t[0],t[1],i[0],i[1]);w.overrideFog=r>=Le||n>=Le}}const A=d.material;let I;A.occlusionTexture&&A.occlusionTexture.offsetScale&&(I=A.occlusionTexture.offsetScale,w.defines.push("OCCLUSION_TEXTURE_TRANSFORM"));const C=t.getOrCreateProgram("model",w);!x&&l&&l.setupShadowsFromMatrix(i.tileModelMatrix,C,l.useNormalOffset),t.uploadCommonUniforms(o,C,null,E);const P=A.pbrMetallicRoughness;P.metallicFactor=.9,P.roughnessFactor=.5;const z=Mo(new Float32Array(b),new Float32Array(h),new Float32Array(u),new Float32Array(c.matrix),t,i.opacity,P.baseColorFactor.toRenderColor(null),A.emissiveFactor,P.metallicFactor,P.roughnessFactor,A,v,r,[0,0,0],I);!f&&(n.hasTranslucentParts||i.opacity<1)&&C.draw(t,o.gl.TRIANGLES,_,Bi.disabled,Oi.disabled,Ui.backCCW,z,r.id,d.vertexBuffer,d.indexBuffer,d.segments,r.paint,t.transform.zoom,void 0,T),C.draw(t,o.gl.TRIANGLES,f?g:_,Bi.disabled,f||i.opacity<1||n.hasTranslucentParts?Oi.alphaBlended:Oi.unblended,Ui.backCCW,z,r.id,d.vertexBuffer,d.indexBuffer,d.segments,r.paint,t.transform.zoom,void 0,T)}}}}()}(t,i,r,n),void c();if("model"!==h.type)return;const u=h.getModels(),d=[],p=t.transform.getFreeCameraOptions().position,f=e.ab.vec3.scale([],[p.x,p.y,p.z],t.transform.worldSize);e.ab.vec3.negate(f,f);const m=[],_=[];let g=0;for(const i of u){const n=r.paint.get("model-rotation").constantOr(null),o=r.paint.get("model-scale").constantOr(null),s=r.paint.get("model-translation").constantOr(null);i.computeModelMatrix(t,n,o,s,!0,!0,!1);const a=e.ab.mat4.identity([]),l=e.dj(i.position.lat,t.transform.zoom),c=e.ab.mat4.fromScaling([],[1,1,1/l]);e.ab.mat4.translate(a,a,f),d.push({zScaleMatrix:c,negCameraPosMatrix:a});for(const e of i.nodes)Ms(t.transform,e,i.matrix,t.transform.expandedFarZProjMatrix,g,m,_);g++}if(m.sort(((e,t)=>t.depth-e.depth)),"shadow"!==t.renderPass){if(1===o)for(const e of _)Ss(e,t,r,d[e.modelIndex],Bi.disabled,t.colorModeForRenderPass());else{for(const e of _)Ss(e,t,r,d[e.modelIndex],Bi.disabled,Oi.disabled);for(const e of _)Ss(e,t,r,d[e.modelIndex],t.stencilModeFor3D(),t.colorModeForRenderPass());t.resetStencilClippingMasks()}for(const e of m)Ss(e,t,r,d[e.modelIndex],Bi.disabled,t.colorModeForRenderPass());c()}else{for(const e of _)Es(e.mesh,e.nodeModelMatrix,t,r);for(const e of m)Es(e.mesh,e.nodeModelMatrix,t,r);c()}}},Js={model:function(e,t,i){const r=t.getSource();if(!r.loaded())return;if("vector"===r.type||"geojson"===r.type)return void(i.modelManager&&i.modelManager.upload(i,"vector"===r.type?e.scope:""));if("batched-model"===r.type)return;if("model"!==r.type)return;const n=r.getModels();for(const e of n)e.upload(i.context)},raster:function(e,t,i){const r=t.getSource();if(!(r instanceof tt&&r.loaded()))return;const n=e.sourceLayer||r.rasterLayerIds&&r.rasterLayerIds[0];if(!n)return;const o=e.paint.get("raster-array-band")||r.getInitialBand(n);if(null==o)return;const s=t.getIds().map((e=>t.getTileByID(e)));for(const e of s)e.updateNeeded(n,o)&&r.prepareTile(e,n,o)},"raster-particle":function(e,t,i){const r=t.getSource();if(!(r instanceof tt&&r.loaded()))return;const n=e.sourceLayer||r.rasterLayerIds&&r.rasterLayerIds[0];if(!n)return;const o=e.paint.get("raster-particle-array-band")||r.getInitialBand(n);if(null==o)return;const s=t.getIds().map((e=>t.getTileByID(e)));for(const e of s)e.updateNeeded(n,o)&&r.prepareTile(e,n,o)}};class Qs{constructor(t,i,r,n,o){this.context=new Do(t,i),this.transform=r,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.tp=o,this._timeStamp=e.q.now(),this._averageFPS=0,this._fpsHistory=[],this._dt=0,this._debugParams={forceEnablePrecipitation:!1,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;o.registerParameter(this._debugParams,["Terrain"],"showTerrainProxyTiles",{},(()=>{this.style.map.triggerRepaint()})),o.registerParameter(this._debugParams,["Precipitation"],"forceEnablePrecipitation"),o.registerParameter(this._debugParams,["FPS"],"fpsWindow",{min:1,max:100,step:1}),o.registerBinding(this._debugParams,["FPS"],"continousRedraw",{readonly:!0,label:"continuous redraw"}),o.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"value"}),o.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"graph",view:"graph",min:0,max:200});for(const e of s)o.registerParameter(this._debugParams.enabledLayers,["Debug","Layers"],e);this.occlusionParams=new Fs(o),this.setup(),this.numSublayers=bt.maxUnderzooming+bt.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.dv,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new lr(this),this._wireframeDebugCache=new ks,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,this.scaleFactor=n}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 $n(this,e));const r=this._terrain;this.transform.elevation=i?r:null,r.update(e,this.transform,t),this.transform.elevation&&!r.enabled&&(this.transform.elevation=null)}_updateFog(e){const t=e.fog;if(!t||"globe"===this.transform.projection.name||t.getOpacity(this.transform.pitch)<1||t.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[i,r]=t.getFovAdjustedRange(this.transform._fov);if(i>r)return void(this.transform.fogCullDistSq=null);const n=i+.78*(r-i);this.transform.fogCullDistSq=n*n}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled||this._forceTerrainMode?this._terrain:null}get forceTerrainMode(){return this._forceTerrainMode}set forceTerrainMode(e){e&&!this._terrain&&(this._terrain=new $n(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.b4;i.emplaceBack(0,0),i.emplaceBack(e.ag,0),i.emplaceBack(0,e.ag),i.emplaceBack(e.ag,e.ag),this.tileExtentBuffer=t.createVertexBuffer(i,e.b6.members),this.tileExtentSegments=e.b7.simpleSegment(0,0,4,2);const r=new e.b4;r.emplaceBack(0,0),r.emplaceBack(e.ag,0),r.emplaceBack(0,e.ag),r.emplaceBack(e.ag,e.ag),this.debugBuffer=t.createVertexBuffer(r,e.b6.members),this.debugSegments=e.b7.simpleSegment(0,0,4,5);const n=new e.b4;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(-1,1),n.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(n,e.b6.members),this.viewportSegments=e.b7.simpleSegment(0,0,4,2);const o=new e.aT;o.emplaceBack(0,0,0,0),o.emplaceBack(e.ag,0,e.ag,0),o.emplaceBack(0,e.ag,0,e.ag),o.emplaceBack(e.ag,e.ag,e.ag,e.ag),this.mercatorBoundsBuffer=t.createVertexBuffer(o,e.b9.members),this.mercatorBoundsSegments=e.b7.simpleSegment(0,0,4,2);const s=new e.aU;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(s);const a=new e.b5;for(const e of[0,1,3,2,0])a.emplaceBack(e);this.debugIndexBuffer=t.createIndexBuffer(a),this.emptyTexture=new e.T(t,new e.r({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA8),this.identityMat=e.ab.mat4.create();const l=this.context.gl;this.stencilClearMode=new Bi({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,ki.disabled,this.stencilClearMode,Oi.disabled,Ui.disabled,Un(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(e,t,i){if(!t||this.currentStencilSource===t.id||!e.isTileClipped()||!i||0===i.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of i)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=t.id;const r=this.context,n=r.gl;this.nextStencilID+i.length>256&&this.clearStencil(),r.setColorMode(Oi.disabled),r.setDepthMode(ki.disabled);const o=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const e of i){const i=t.getTile(e),r=this._tileClippingMaskIDs[e.key]=this.nextStencilID++,{tileBoundsBuffer:s,tileBoundsIndexBuffer:a,tileBoundsSegments:l}=this.getTileBoundsBuffers(i);o.draw(this,n.TRIANGLES,ki.disabled,new Bi({func:n.ALWAYS,mask:0},r,255,n.KEEP,n.KEEP,n.REPLACE),Oi.disabled,Ui.disabled,Un(e.projMatrix),"$clipping",s,a,l)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new Bi({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 Bi({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}stencilConfigForOverlap(e){const t=this.context.gl,i=e.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),r=i[i.length-1].overscaledZ,n=i[0].overscaledZ-r+1;if(n>1){this.currentStencilSource=void 0,this.nextStencilID+n>256&&this.clearStencil();const e={};for(let i=0;i<n;i++)e[i+r]=new Bi({func:t.GEQUAL,mask:255},i+this.nextStencilID,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID+=n,[e,i]}return[{[r]:Bi.disabled},i]}colorModeForRenderPass(){const t=this.context.gl;if(this._showOverdrawInspector){const i=1/8;return new Oi([t.CONSTANT_COLOR,t.ONE,t.CONSTANT_COLOR,t.ONE],new e.aj(i,i,i,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?Oi.unblended:Oi.alphaBlended}colorModeForDrapableLayerRenderPass(t){const i=this.context.gl;return(()=>this.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture)()&&"translucent"===this.renderPass?new Oi([i.ONE,i.ONE_MINUS_SRC_ALPHA,i.CONSTANT_ALPHA,i.ONE_MINUS_SRC_ALPHA],new e.aj(0,0,0,void 0===t?0:t),[!0,!0,!0,!0]):this.colorModeForRenderPass()}depthModeForSublayer(e,t,i,r=!1){if(this.depthOcclusion)return new ki(this.context.gl.GREATER,ki.ReadOnly,this.depthRangeFor3D);if(!this.opaquePassEnabledForLayer()&&!r)return ki.disabled;const n=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new ki(i||this.context.gl.LEQUAL,t,[n,n])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}blitDepth(){const t=this.context.gl,i=Math.ceil(this.width),r=Math.ceil(this.height),n=this.context.bindFramebuffer.get(),o=t.getParameter(t.TEXTURE_BINDING_2D);this.depthFBO&&this.depthFBO.width===i&&this.depthFBO.height===r||(this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),0!==i&&0!==r&&(this.depthFBO=new zo(this.context,i,r,!1,"texture"),this.depthTexture=new e.T(this.context,{width:i,height:r,data:null},t.DEPTH24_STENCIL8),this.depthFBO.depthAttachment.set(this.depthTexture.texture))),this.context.bindFramebuffer.set(n),t.bindTexture(t.TEXTURE_2D,o),this.depthFBO&&(t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,this.depthFBO.framebuffer),t.blitFramebuffer(0,0,i,r,0,0,i,r,t.DEPTH_BUFFER_BIT,t.NEAREST),t.bindFramebuffer(t.FRAMEBUFFER,this.context.bindFramebuffer.current))}updateAverageFPS(){this._fpsHistory.push(0===this._dt?0:1e3/this._dt),this._fpsHistory.length>this._debugParams.fpsWindow&&this._fpsHistory.splice(0,this._fpsHistory.length-this._debugParams.fpsWindow),this._averageFPS=Math.round(this._fpsHistory.reduce(((e,t)=>e+t/this._fpsHistory.length),0))}render(t,i){const r=e.q.now();this._dt=r-this._timeStamp,this._timeStamp=r,this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=t.map.repaint,this.style=t,this.options=i;const n=this.style._mergedLayers,o=this.style._getOrder(!(!this.terrain||!this.terrain.enabled)).filter((e=>{const t=n[e];return!(t.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[t.type]}));let s=!1,a=!1;for(const e of o){const t=n[e];"circle"===t.type&&(s=!0),"symbol"===t.type&&(t.hasInitialOcclusionOpacityProperties?a=!0:s=!0)}const l=o.map((e=>n[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={},f={},m={},_={},g={};for(const e in c){const t=c[e];p[e]=t.getVisibleCoordinates(),f[e]=p[e].slice().reverse(),m[e]=t.getVisibleCoordinates(!0).reverse(),_[e]=t.getShadowCasterCoordinates(),g[e]=t.sortCoordinatesByDistance(p[e])}const y=e=>{const t=this.style.getLayerSourceCache(e);return t&&t.used?t.getSource():null};if(h||d||this._clippingActiveLastFrame){const t=[],i=[];let r=0;for(const e of l)this.isSourceForClippingOrConflation(e,y(e))&&(t.push(e),i.push(r)),r++;if(t&&(d||t.length>1)||this._clippingActiveLastFrame){d=!1;const r=[];for(let n=0;n<t.length;n++){const o=t[n],s=i[n],a=this.style.getLayerSourceCache(o);if(!a||!a.used||!a.getSource().usedInConflation&&"clip"!==o.type)continue;let l=e.dx,c=e.by.None;const h=[];let u=!0;if("clip"===o.type){l=s;for(const t of o.layout.get("clip-layer-types"))c|="model"===t?e.by.Model:"symbol"===t?e.by.Symbol:e.by.FillExtrusion;for(const e of o.layout.get("clip-layer-scope"))h.push(e);o.isHidden(this.transform.zoom)?u=!1:d=!0}u&&r.push({layer:o.fqid,cache:a,order:l,clipMask:c,clipScope:h})}this.replacementSource.setSources(r),u=!0}}this._clippingActiveLastFrame=d,u||this.replacementSource.clear(),this.conflationActive=u,this.minCutoffZoom=0,this.longestCutoffRange=0,this.opaquePassCutoff=1/0,this._lastOcclusionLayer=-1,this.layersWithOcclusionOpacity=[];for(let e=0;e<l.length;e++){const t=l[e],i=t.cutoffRange();if(this.longestCutoffRange=Math.max(i,this.longestCutoffRange),i>0){const e=y(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 v=this._shadowRenderer;if(v){v.updateShadowParameters(this.transform,this.style.directionalLight);for(const e in c)for(const t of p[e]){let e={min:0,max:0};this.terrain&&(e=this.terrain.getMinMaxForTile(t)||e),v.addShadowReceiver(t.toUnwrapped(),e.min,e.max)}}"globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new e.dw(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new bs(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);const b=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.snow),w=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.rain);if(b&&!this._snow&&(this._snow=new Ys(this)),!b&&this._snow&&(this._snow.destroy(),delete this._snow),w&&!this._rain&&(this._rain=new Ws(this)),!w&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),!V.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 r=i?f[i.id]:void 0;("custom"===e.type||"raster"===e.type||"raster-particle"===e.type||e.isSky()||r&&r.length)&&this.renderLayer(this,i,e,r)}this.depthRangeFor3D=[0,1-(l.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,_)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const T="globe"===this.transform.projection.name||this.transform.isHorizonVisible(),S=(()=>{if(i.showOverdrawInspector)return e.aj.black;const t=this.style.fog;if(t&&this.transform.projection.supportsFog){const i=this.style.getLut(t.scope);if(!T){const r="none"===t.properties.get("color-use-theme"),n=t.properties.get("color").toRenderColor(r?null:i).toArray01();return new e.aj(...n)}if(T){const r="none"===t.properties.get("space-color-use-theme"),n=t.properties.get("space-color").toRenderColor(r?null:i).toArray01();return new e.aj(...n)}}return e.aj.transparent})();if(this.context.clear({color:S,depth:1}),this.clearStencil(),this._showOverdrawInspector=i.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&T&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=o.length-1;this.currentLayer>=0;this.currentLayer--){const e=l[this.currentLayer],i=t.getLayerSourceCache(e);if(e.isSky())continue;const r=i?(e.is3D()?g:f)[i.id]:void 0;this._renderTileClippingMasks(e,i,r),this.renderLayer(this,i,e,r)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&T&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||e.ae(this.transform.zoom)>0)&&("globe"===this.transform.projection.name||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer<o.length;this.currentLayer++){const e=l[this.currentLayer],i=t.getLayerSourceCache(e);e.isSky()&&this.renderLayer(this,i,e,i?f[i.id]:void 0)}function M(e,t){let i;return t&&(i=("symbol"===e.type?m:e.is3D()?g:f)[t.id]),i}if(this.renderPass="translucent","globe"===this.transform.projection.name){for(this.renderElevatedRasterBackface=!0,this.currentLayer=0;this.currentLayer<o.length;){const e=l[this.currentLayer];if("raster"===e.type||"raster-particle"===e.type){const i=t.getLayerSourceCache(e);this.renderLayer(this,i,e,M(e,i))}++this.currentLayer}this.renderElevatedRasterBackface=!1}this.currentLayer=0,this.firstLightBeamLayer=Number.MAX_SAFE_INTEGER;let E=0;v&&(E=v.getShadowCastingLayerCount());let A=!1,I=-1;for(let e=0;e<o.length;++e){const t=l[e];t.isHidden(this.transform.zoom)||t.is3D()&&(I=e)}for(a&&-1===I&&(s=!0);this.currentLayer<o.length;){const e=l[this.currentLayer],i=t.getLayerSourceCache(e);if(e.isSky())++this.currentLayer;else if(this.terrain&&this.style.isLayerDraped(e)){if(e.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=this.terrain.renderBatch(this.currentLayer),this._lastOcclusionLayer=Math.max(this.currentLayer,this._lastOcclusionLayer)}else{if(s&&!A&&this.terrain&&!this.transform.isOrthographic&&(A=!0,this.blitDepth()),a&&-1!==I&&this.currentLayer===I+1&&!this.transform.isOrthographic&&this.blitDepth(),e.is3D()||this.terrain||this._renderTileClippingMasks(e,i,i?p[i.id]:void 0),this.renderLayer(this,i,e,M(e,i)),!this.terrain&&v&&E>0&&e.hasShadowPass()&&0==--E&&(v.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?f[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],r=t.getLayerSourceCache(i),n=r?f[r.id]:void 0;i.is3D()||this.terrain||this._renderTileClippingMasks(i,r,r?p[r.id]:void 0),this.renderLayer(this,r,i,n)}this.depthOcclusion=!1,this.currentLayer=e,this.renderPass="translucent",this.layersWithOcclusionOpacity=[]}++this.currentLayer}}if(this.terrain&&this.terrain.postRender(),this._snow&&this._snow.draw(this),this._rain&&this._rain.draw(this),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let i=null;l.forEach((e=>{const r=t.getLayerSourceCache(e);r&&!e.isHidden(this.transform.zoom)&&r.getVisibleCoordinates().length&&(!i||i.getSource().maxzoom<r.getSource().maxzoom)&&(i=r)})),i&&this.options.showTileBoundaries&&Ks.debug(this,i,i.getVisibleCoordinates(),e.aj.red,!1,this.options.showParseStatus)}this.terrain&&this._debugParams.showTerrainProxyTiles&&Ks.debug(this,this.terrain.proxySourceCache,this.terrain.proxyCoords,new e.aj(1,.8,.1,1),!0,this.options.showParseStatus),this.options.showPadding&&function(e){const t=e.transform.padding;cs(e,e.transform.height-(t.top||0),3,rs),cs(e,t.bottom||0,3,ns),hs(e,t.left||0,3,os),hs(e,e.transform.width-(t.right||0),3,ss);const i=e.transform.centerPoint;!function(e,t,i,r){us(e,t-1,i-10,2,20,r),us(e,t-10,i-1,20,2,r)}(e,i.x,e.transform.height-i.y,as)}(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(performance.now()),this.saveCanvasCopy()),u||(this.conflationActive=!1)}prepareLayer(e){this.gpuTimingStart(e);const{unsupportedLayers:t}=this.transform.projection,i=!t||!t.includes(e.type);if(Js[e.type]&&(i||this.terrain&&"custom"===e.type)){const t=this.style.getLayerSourceCache(e);Js[e.type](e,t,this)}this.gpuTimingEnd()}renderLayer(e,t,i,r){i.isHidden(this.transform.zoom)||("background"===i.type||"sky"===i.type||"custom"===i.type||"model"===i.type||"raster"===i.type||"raster-particle"===i.type||r&&r.length)&&(this.id=i.id,this.gpuTimingStart(i),e.transform.projection.unsupportedLayers&&e.transform.projection.unsupportedLayers.includes(i.type)&&(!e.terrain||"custom"!==i.type)||"clip"===i.type||Ks[i.type](e,t,i,r,this.style.placement.variableOffsets,this.options.isInitialLoad),this.gpuTimingEnd())}gpuTimingStart(e){if(!this.options.gpuTiming)return;const t=this.context.extTimerQuery,i=this.context.gl;let r=this.gpuTimers[e.id];r||(r=this.gpuTimers[e.id]={calls:0,cpuTime:0,query:i.createQuery()}),r.calls++,i.beginQuery(t.TIME_ELAPSED_EXT,r.query)}gpuTimingDeferredRenderStart(){if(this.options.gpuTimingDeferredRender){const e=this.context.extTimerQuery,t=this.context.gl,i=t.createQuery();this.deferredRenderGpuTimeQueries.push(i),t.beginQuery(e.TIME_ELAPSED_EXT,i)}}gpuTimingDeferredRenderEnd(){this.options.gpuTimingDeferredRender&&this.context.gl.endQuery(this.context.extTimerQuery.TIME_ELAPSED_EXT)}gpuTimingEnd(){this.options.gpuTiming&&this.context.gl.endQuery(this.context.extTimerQuery.TIME_ELAPSED_EXT)}collectGpuTimers(){const e=this.gpuTimers;return this.gpuTimers={},e}collectDeferredRenderGpuQueries(){const e=this.deferredRenderGpuTimeQueries;return this.deferredRenderGpuTimeQueries=[],e}queryGpuTimers(e){const t={};for(const i in e){const r=e[i],n=this.context.extTimerQuery,o=n.getQueryParameter(r.query,this.context.gl.QUERY_RESULT)/1e6;n.deleteQueryEXT(r.query),t[i]=o}return t}queryGpuTimeDeferredRender(e){if(!this.options.gpuTimingDeferredRender)return 0;const t=this.context.gl;let i=0;for(const r of e)i+=t.getQueryParameter(r,t.QUERY_RESULT)/1e6,t.deleteQuery(r);return i}translatePosMatrix(t,i,r,n,o){if(!r[0]&&!r[1])return t;const s=o?"map"===n?this.transform.angle:0:"viewport"===n?-this.transform.angle:0;if(s){const e=Math.sin(s),t=Math.cos(s);r=[r[0]*t-r[1]*e,r[0]*e+r[1]*t]}const a=[o?r[0]:e.ar(i,r[0],this.transform.zoom),o?r[1]:e.ar(i,r[1],this.transform.zoom),0],l=new Float32Array(16);return e.ab.mat4.translate(l,t,a),l}saveTileTexture(e){const t=e.size[0],i=this._tileTextures[t];i?i.push(e):this._tileTextures[t]=[e]}getTileTexture(e){const t=this._tileTextures[e];return t&&t.length>0?t.pop():null}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}linearFloatFilteringSupported(){return null!=this.context.extTextureFloatLinear}currentGlobalDefines(e,t,i){const r=void 0===i?this.terrain&&this.terrain.renderingToTexture:i,n=[];return this.style&&this.style.enable3dLights()&&("globeRaster"===e||"terrainRaster"===e?(n.push("LIGHTING_3D_MODE"),n.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):r||n.push("LIGHTING_3D_MODE")),"shadow"===this.renderPass&&(this._shadowMapDebug||n.push("DEPTH_TEXTURE")),this.terrainRenderModeElevated()&&(n.push("TERRAIN"),this.linearFloatFilteringSupported()&&n.push("TERRAIN_DEM_FLOAT_FORMAT")),"globe"===this.transform.projection.name&&n.push("GLOBE"),!this._fogVisible||r||void 0!==t&&!t||n.push("FOG","FOG_DITHERING"),r&&n.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&n.push("OVERDRAW_INSPECTOR"),n}getOrCreateProgram(e,t){this.cache=this.cache||{};const i=t&&t.defines||[],r=t&&t.config,n=this.currentGlobalDefines(e,t&&t.overrideFog,t&&t.overrideRtt).concat(i),o=Yn.cacheKey(jr[e],e,n,r);return this.cache[o]||(this.cache[o]=new Yn(this.context,e,jr[e],r,Ao[e],n)),this.cache[o]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new e.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA8))}destroy(){this._terrain&&this._terrain.destroy(),this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this._wireframeDebugCache.destroy(),this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),this.emptyDepthTexture&&this.emptyDepthTexture.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}uploadCommonLightUniforms(t,i){if(this.style.enable3dLights()){const r=this.style.directionalLight,n=this.style.ambientLight;if(r&&n){const o=((t,i,r)=>{const n=t.properties.get("direction"),o="none"===t.properties.get("color-use-theme"),s=t.properties.get("color").toRenderColor(o?null:r.getLut(t.scope)).toArray01(),a=t.properties.get("intensity"),l="none"===i.properties.get("color-use-theme"),c=i.properties.get("color").toRenderColor(l?null:r.getLut(i.scope)).toArray01(),h=i.properties.get("intensity"),u=[n.x,n.y,n.z],d=e.cM(c,h),p=e.cM(s,a);return{u_lighting_ambient_color:d,u_lighting_directional_dir:u,u_lighting_directional_color:p,u_ground_radiance:Hn(u,p,d)}})(r,n,this.style);i.setLightsUniformValues(t,o)}}}uploadCommonUniforms(t,i,r,n,o){if(this.uploadCommonLightUniforms(t,i),this.terrain&&this.terrain.renderingToTexture)return;const s=this.style.fog;if(s){const o=s.getOpacity(this.transform.pitch),a=((t,i,r,n,o,s,a,l,c,h,u,d)=>{const p=t.transform,f="none"===i.properties.get("color-use-theme"),m=i.properties.get("color").toRenderColor(f?null:t.style.getLut(i.scope)).toArray01();m[3]=n;const _=t.frameCounter/1e3%1,[g,y]=i.properties.get("vertical-range");return{u_fog_matrix:r?p.calculateFogTileMatrix(r):d||t.identityMat,u_fog_range:i.getFovAdjustedRange(p._fov),u_fog_color:m,u_fog_horizon_blend:i.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(g,y),y],u_fog_temporal_offset:_,u_frustum_tl:o,u_frustum_tr:s,u_frustum_br:a,u_frustum_bl:l,u_globe_pos:c,u_globe_radius:h,u_viewport:u,u_globe_transition:e.ae(p.zoom),u_is_globe:+("globe"===p.projection.name)}})(this,s,r,o,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*e.q.devicePixelRatio,this.transform.height*e.q.devicePixelRatio],n);i.setFogUniformValues(t,a)}o&&i.setCutoffUniformValues(t,o.uniformValues)}setTileLoadedFlag(e){this.tileLoaded=e}saveCanvasCopy(){const e=this.canvasCopy();e&&(this.frameCopies.push(e),this.tileLoaded=!1)}canvasCopy(){const e=this.context.gl,t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,0,0,e.drawingBufferWidth,e.drawingBufferHeight,0),t}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const e=this.style&&this.style.fog;return!!e&&0!==e.getOpacity(this.transform.pitch)}getBackgroundTiles(){const e=this._backgroundTiles,t=this._backgroundTiles={},i=this.transform.coveringTiles({tileSize:512});for(const r of i)t[r.key]=e[r.key]||new gt(r,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]>=Le||t[1]>=Le}setupDepthForOcclusion(e,t,i){const r=this.context,n=r.gl,o=!!i;var s;i||(i={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0}),r.activeTexture.set(n.TEXTURE3),e&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE),i.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],i.u_depth_range_unpack=[2/((s=this.depthRangeFor3D)[1]-s[0]),-1-2*s[0]/(s[1]-s[0])],i.u_occluder_half_size=.5*this.occlusionParams.occluderSize,i.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE),r.activeTexture.set(n.TEXTURE0),o||t.setTerrainUniformValues(r,i)}}function ea(e,t){let i=!1,r=null;const n=()=>{r=null,i&&(e(),r=setTimeout(n,t),i=!1)};return()=>(i=!0,r||n(),r)}class ta{constructor(t){this._hashName=t&&encodeURIComponent(t),e.aP(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=ea(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=ia(e);if(this._hashName){const e=this._hashName;let i=!1;const r=location.hash.slice(1).split("&").map((r=>{const n=r.split("=")[0];return n===e?(i=!0,`${n}=${t}`):r})).filter((e=>e));return i||r.push(`${e}=${t}`),`#${r.join("&")}`}return`#${t}`}_getCurrentHash(){const e=location.hash.replace("#","");if(this._hashName){let t;return e.split("&").map((e=>e.split("="))).forEach((e=>{e[0]===this._hashName&&(t=e)})),(t&&t[1]||"").split("/")}return e.split("/")}_onHashChange(){const e=this._map;if(!e)return!1;const t=this._getCurrentHash();if(t.length>=3&&!t.some((e=>isNaN(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 ia(e,t){const i=e.getCenter(),r=Math.round(100*e.getZoom())/100,n=Math.ceil((r*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,n),s=Math.round(i.lng*o)/o,a=Math.round(i.lat*o)/o,l=e.getBearing(),c=e.getPitch();let h=t?`/${s}/${a}/${r}`:`${r}/${a}/${s}`;return(l||c)&&(h+="/"+Math.round(10*l)/10),c&&(h+=`/${Math.round(c)}`),h}const ra={linearity:.3,easing:e.dy(0,0,.3,1)},na=e.l({deceleration:2500,maxSpeed:1400},ra),oa=e.l({deceleration:20,maxSpeed:1400},ra),sa=e.l({deceleration:1e3,maxSpeed:360},ra),aa=e.l({deceleration:1e3,maxSpeed:90},ra);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 r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,n={};if(i.pan.mag()){const o=ha(i.pan.mag(),r,e.l({},na,t||{}));n.offset=i.pan.mult(o.amount/i.pan.mag()),n.center=this._map.transform.center,ca(n,o)}if(i.zoom){const e=ha(i.zoom,r,oa);n.zoom=this._map.transform.zoom+e.amount,ca(n,e)}if(i.bearing){const t=ha(i.bearing,r,sa);n.bearing=this._map.transform.bearing+e.aw(t.amount,-179,179),ca(n,t)}if(i.pitch){const e=ha(i.pitch,r,aa);n.pitch=this._map.transform.pitch+e.amount,ca(n,e)}if(n.zoom||n.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;n.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),n.noMoveStart=!0,n}}function ca(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing)}function ha(t,i,r){const{maxSpeed:n,linearity:o,deceleration:s}=r,a=e.aw(t*o/(i/1e3),-n,n),l=Math.abs(a)/(s*o);return{easing:r.easing,duration:1e3*l,amount:a*(l/2)}}class ua extends e.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,i,r,n={}){const o=g(i.getCanvasContainer(),r),s=i.unproject(o);super(t,e.l({point:o,lngLat:s,originalEvent:r},n)),this._defaultPrevented=!1,this.target=i}}class da extends e.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,i,r){const n="touchend"===t?r.changedTouches:r.touches,o=y(i.getCanvasContainer(),n),s=o.map((e=>i.unproject(e))),a=o.reduce(((e,t,i,r)=>e.add(t.div(r.length))),new e.P(0,0));super(t,{points:o,point:a,lngLats:s,lngLat:i.unproject(a),originalEvent:r}),this._defaultPrevented=!1}}class pa extends e.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t){super("wheel",{originalEvent:t}),this._defaultPrevented=!1}}class fa{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){this._mousedownPos=void 0}wheel(e){return this._firePreventable(new pa(this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new ua(e.type,this._map,e))}mouseup(e){this._map.fire(new ua(e.type,this._map,e))}preclick(t){const i=e.l({},t);i.type="preclick",this._map.fire(new ua(i.type,this._map,i))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new ua(e.type,this._map,e)))}dblclick(e){return this._firePreventable(new ua(e.type,this._map,e))}mouseover(e){this._map.fire(new ua(e.type,this._map,e))}mouseout(e){this._map.fire(new ua(e.type,this._map,e))}touchstart(e){return this._firePreventable(new da(e.type,this._map,e))}touchmove(e){this._map.fire(new da(e.type,this._map,e))}touchend(e){this._map.fire(new da(e.type,this._map,e))}touchcancel(e){this._map.fire(new da(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ma{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(e){this._map.fire(new ua(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ua("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new ua(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class _a{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(p(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const i=t,r=this._startPos,n=this._lastPos;if(!r||!n||n.equals(i)||!this._box&&i.dist(r)<this._clickTolerance)return;this._lastPos=i,this._box||(this._box=l("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",e));const o=Math.min(r.x,i.x),s=Math.max(r.x,i.x),a=Math.min(r.y,i.y),c=Math.max(r.y,i.y);this._map._requestDomTask((()=>{this._box&&(this._box.style.transform=`translate(${o}px,${a}px)`,this._box.style.width=s-o+"px",this._box.style.height=c-a+"px")}))}mouseupWindow(t,i){if(!this._active)return;const r=this._startPos,n=i;if(r&&0===t.button){if(this.reset(),_(),r.x!==n.x||r.y!==n.y)return this._map.fire(new e.z("boxzoomend",{originalEvent:t})),{cameraAnimation:e=>e.fitScreenCoordinates(r,n,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",t)}}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),f(),delete this._startPos,delete this._lastPos}_fireEvent(t,i){return this._map.fire(new e.z(t,{originalEvent:i}))}}function ga(e,t){const i={};for(let r=0;r<e.length;r++)i[e[r].identifier]=t[r];return i}class ya{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1}touchstart(t,i,r){(this.centroid||r.length>this.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),r.length===this.numTouches&&(this.centroid=function(t){const i=new e.P(0,0);for(const e of t)i._add(e);return i.div(t.length)}(i),this.touches=ga(r,i)))}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const r=ga(i,t);for(const e in this.touches){const t=r[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0)}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class xa{constructor(e){this.singleTap=new ya(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(e,t,i){this.singleTap.touchstart(e,t,i)}touchmove(e,t,i){this.singleTap.touchmove(e,t,i)}touchend(e,t,i){const r=this.singleTap.touchend(e,t,i);if(r){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class va{constructor(){this._zoomIn=new xa({numTouches:1,numTaps:2}),this._zoomOut=new xa({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i)}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i)}touchend(e,t,i){const r=this._zoomIn.touchend(e,t,i),n=this._zoomOut.touchend(e,t,i);return r?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(r)},{originalEvent:e})}):n?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()-1,around:t.unproject(n)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const ba={0:1,2:2};class wa{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=ba[t];return void 0===e.buttons||(e.buttons&i)!==i}(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(i)<this._clickTolerance))return this._moved=!0,this._lastPoint=t,this._move(i,t)}mouseupWindow(e){this._lastPoint&&x(e)===this._eventButton&&(this._moved&&_(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ta extends wa{mousedown(e,t){super.mousedown(e,t),this._lastPoint&&(this._active=!0)}_correctButton(e,t){return 0===t&&!e.ctrlKey}_move(e,t){return{around:t,panDelta:t.sub(e)}}}class Sa extends wa{_correctButton(e,t){return 0===t&&e.ctrlKey||2===t}_move(e,t){const i=.8*(t.x-e.x);if(i)return this._active=!0,{bearingDelta:i}}contextmenu(e){e.preventDefault()}}class Ma extends wa{_correctButton(e,t){return 0===t&&e.ctrlKey||2===t}_move(e,t){const i=-.5*(t.y-e.y);if(i)return this._active=!0,{pitchDelta:i}}contextmenu(e){e.preventDefault()}}class Ea{constructor(t,i){this._map=t,this._el=t.getCanvasContainer(),this._minTouches=1,this._clickTolerance=i.clickTolerance||1,this.reset(),e.aP(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new e.P(0,0)}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(t,i,r){if(this._active&&!(r.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(1===r.length&&!e.dz())return void this._showTouchPanBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return t.cancelable&&t.preventDefault(),this._calculateTransform(t,i,r)}}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&i.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,i,r){r.length>0&&(this._active=!0);const n=ga(r,i),o=new e.P(0,0),s=new e.P(0,0);let a=0;for(const e in n){const t=n[e],i=this._touches[e];i&&(o._add(t),s._add(t.sub(i)),a++,n[e]=t)}if(this._touches=n,a<this._minTouches||!s.mag())return;const l=s.div(a);return this._sum._add(l),this._sum.mag()<this._clickTolerance?void 0:{around:o.div(a),panDelta:l}}enable(){this._enabled=!0,this._map._cooperativeGestures&&(this._addTouchPanBlocker(),this._el.classList.add("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page"))}disable(){this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove(),this._el.classList.remove("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page")),this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}_addTouchPanBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=l("div","mapboxgl-touch-pan-blocker",this._map._container),this._alertContainer.textContent=this._map._getUIString("TouchPanBlocker.Message"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showTouchPanBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=window.setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")}),500)}}class Aa{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(e){}_move(e,t,i){return{}}touchstart(e,t,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,i){const r=this._firstTwoTouches;if(!r)return;e.preventDefault();const[n,o]=r,s=Ia(i,t,n),a=Ia(i,t,o);if(!s||!a)return;const l=this._aroundCenter?null:s.add(a).div(2);return this._move([s,a],l,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;const[r,n]=this._firstTwoTouches,o=Ia(i,t,r),s=Ia(i,t,n);o&&s||(this._active&&_(),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 Ia(e,t,i){for(let r=0;r<e.length;r++)if(e[r].identifier===i)return t[r]}function Ca(e,t){return Math.log(e/t)/Math.LN2}class Pa extends Aa{reset(){super.reset(),this._distance=0,this._startDistance=0}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,t){const i=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(Math.abs(Ca(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Ca(this._distance,i),pinchAround:t}}}function za(e,t){return 180*e.angleWith(t)/Math.PI}class Da extends Aa{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1])}_move(e,t){const i=this._vector;if(this._vector=e[0].sub(e[1]),i&&(this._active||!this._isBelowThreshold(this._vector)))return this._active=!0,{bearingDelta:za(this._vector,i),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());const t=25/(Math.PI*this._minDiameter)*360,i=this._startVector;if(!i)return!1;const r=za(e,i);return Math.abs(r)<t}}function Ra(e){return Math.abs(e.y)>Math.abs(e.x)}class La extends Aa{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,Ra(e[0].sub(e[1]))&&(this._valid=!1)}_move(t,i,r){const n=this._lastPoints;if(!n)return;const o=t[0].sub(n[0]),s=t[1].sub(n[1]);return this._map._cooperativeGestures&&!e.dz()&&r.touches.length<3||(this._valid=this.gestureBeginsVertically(o,s,r.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(o.y+s.y)/2*-.5})}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const r=e.mag()>=2,n=t.mag()>=2;if(!r&&!n)return;if(!r||!n)return null==this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return Ra(e)&&Ra(t)&&o}}const Oa={panStep:100,bearingStep:15,pitchStep:10};class ka{constructor(){const e=Oa;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,r=0,n=0,o=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?i=-1:(e.preventDefault(),n=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),n=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:s=>{const a=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:Fa,zoom:t?Math.round(a)+t*(e.shiftKey?2:1):a,bearing:s.getBearing()+i*this._bearingStep,pitch:s.getPitch()+r*this._pitchStep,offset:[-n*this._panStep,-o*this._panStep],center:s.getCenter()},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Fa(e){return e*(2-e)}const Ba=4.000244140625,Na=1/450;class Va{constructor(t,i){this._map=t,this._el=t.getCanvasContainer(),this._handler=i,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=Na,e.aP(["_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.dz()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let i=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const r=e.q.now(),n=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==i&&i%Ba==0?this._type="wheel":0!==i&&Math.abs(i)<4?this._type="trackpad":n>400?(this._type=null,this._lastValue=i,this._timeout=window.setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(n*i)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,i+=this._lastValue)),t.shiftKey&&i&&(i/=4),this._type&&(this._lastWheelEvent=t,this._delta-=i,this._active||this._start(t)),t.preventDefault()}_onTimeout(e){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const t=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)>Ba?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==r&&(r=1/r);const n=i(),o=Math.pow(2,n),s="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(s*r))),"wheel"===this._type&&(this._startZoom=n,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const r="number"==typeof this._targetZoom?this._targetZoom:i(),n=this._startZoom,o=this._easing;let s,a=!1;if("wheel"===this._type&&n&&o){const t=Math.min((e.q.now()-this._lastWheelEventTime)/200,1),i=o(t);s=e.af(n,r,i),t<1?this._frameId||(this._frameId=!0):a=!0}else s=r,a=!0;this._active=!0,a&&(this._active=!1,this._finishTimeout=window.setTimeout((()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200));let l=s-i();return l*this._lastDelta<0&&(l=0),{noInertia:!0,needsRenderFrame:!a,zoomDelta:l,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let i=e.dA;if(this._prevEase){const t=this._prevEase,r=(e.q.now()-t.start)/t.duration,n=t.easing(r+.01)-t.easing(r),o=.27/Math.sqrt(n*n+1e-4)*.01,s=Math.sqrt(.0729-o*o);i=e.dy(o,s,.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 Ua{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 ja{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 Ga{constructor(){this._tap=new xa({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(e,t,i){this._swipePoint||(this._tapTime&&e.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?i.length>0&&(this._swipePoint=t[0],this._swipeTouch=i[0].identifier):this._tap.touchstart(e,t,i))}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=t[0],n=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:n/128}}}else this._tap.touchmove(e,t,i)}touchend(e,t,i){this._tapTime?this._swipePoint&&0===i.length&&this.reset():this._tap.touchend(e,t,i)&&(this._tapTime=e.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class qa{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 Za{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 $a{constructor(e,t,i,r){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const Ha=e=>e.zoom||e.drag||e.pitch||e.rotate;class Wa extends e.z{}class Xa{constructor(){this.constants=[1,1,.01],this.radius=0}setup(t,i){const r=e.ab.vec3.sub([],i,t);this.radius=e.ab.vec3.length(r[2]<0?e.ab.vec3.div([],r,this.constants):[r[0],r[1],0])}projectRay(t){e.ab.vec3.div(t,t,this.constants),e.ab.vec3.normalize(t,t),e.ab.vec3.mul(t,t,this.constants);const i=e.ab.vec3.scale([],t,this.radius);if(i[2]>0){const t=e.ab.vec3.scale([],[0,0,1],e.ab.vec3.dot(i,[0,0,1])),r=e.ab.vec3.scale([],e.ab.vec3.normalize([],[i[0],i[1],0]),this.radius),n=e.ab.vec3.add([],i,e.ab.vec3.scale([],e.ab.vec3.sub([],e.ab.vec3.add([],r,t),i),2));i[0]=n[0],i[1]=n[1]}return i}}function Ya(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class Ka{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 Xa,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),e.aP(["handleEvent","handleWindowEvent"],this);const r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,i]of this._listeners){const r=e===document?this.handleWindowEvent:this.handleEvent;e.addEventListener(t,r,i)}}destroy(){for(const[e,t,i]of this._listeners){const r=e===document?this.handleWindowEvent:this.handleEvent;e.removeEventListener(t,r,i)}}_addDefaultHandlers(e){const t=this._map,i=t.getCanvasContainer();this._add("mapEvent",new fa(t,e));const r=t.boxZoom=new _a(t,e);this._add("boxZoom",r);const n=new va,o=new ja;t.doubleClickZoom=new Ua(o,n),this._add("tapZoom",n),this._add("clickZoom",o);const s=new Ga;this._add("tapDragZoom",s);const a=t.touchPitch=new La(t);this._add("touchPitch",a);const l=new Sa(e),c=new Ma(e);t.dragRotate=new Za(e,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const h=new Ta(e),u=new Ea(t,e);t.dragPan=new qa(i,h,u),this._add("mousePan",h),this._add("touchPan",u,["touchZoom","touchRotate"]);const d=new Da,p=new Pa;t.touchZoomRotate=new $a(i,p,d,s),this._add("touchRotate",d,["touchPan","touchZoom"]),this._add("touchZoom",p,["touchPan","touchRotate"]),this._add("blockableMapEvent",new ma(t));const f=t.scrollZoom=new Va(t,this);this._add("scrollZoom",f,["mousePan"]);const m=t.keyboard=new ka;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!!Ha(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(e,t,i){for(const r in e)if(r!==i&&(!t||t.indexOf(r)<0))return!0;return!1}handleWindowEvent(e){this.handleEvent(e,`${e.type}Window`)}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}handleEvent(e,t){this._updatingCamera=!0;const i="renderFrame"===e.type,r=i?void 0:e,n={needsRenderFrame:!1},o={},s={},a=e.touches?this._getMapTouches(e.touches):void 0,l=a?y(this._el,a):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(s,h,i)?c.reset():c[t||e.type]&&(u=c[t||e.type](e,l,a),this.mergeHandlerResult(n,o,u,i,r),u&&u.needsRenderFrame&&this._triggerRenderFrame()),(u||c.isActive())&&(s[i]=c)}const c={};for(const e in this._previousActiveHandlers)s[e]||(c[e]=r);this._previousActiveHandlers=s,(Object.keys(c).length||Ya(n))&&(this._changes.push([n,o,c]),this._triggerRenderFrame()),(Object.keys(s).length||Ya(n))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:h}=n;h&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],h(this._map))}mergeHandlerResult(t,i,r,n,o){if(!r)return;e.l(t,r);const s={handlerName:n,originalEvent:r.originalEvent||o};void 0!==r.zoomDelta&&(i.zoom=s),void 0!==r.panDelta&&(i.drag=s),void 0!==r.pitchDelta&&(i.pitch=s),void 0!==r.bearingDelta&&(i.rotate=s)}_applyChanges(){const t={},i={},r={};for(const[n,o,s]of this._changes)n.panDelta&&(t.panDelta=(t.panDelta||new e.P(0,0))._add(n.panDelta)),n.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+n.zoomDelta),n.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+n.bearingDelta),n.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+n.pitchDelta),void 0!==n.around&&(t.around=n.around),void 0!==n.aroundCoord&&(t.aroundCoord=n.aroundCoord),void 0!==n.pinchAround&&(t.pinchAround=n.pinchAround),n.noInertia&&(t.noInertia=n.noInertia),e.l(i,o),e.l(r,s);this._updateMapTransform(t,i,r),this._changes=[]}_updateMapTransform(t,i,r){const n=this._map,o=n.transform,s=e=>[e.x,e.y,e.z];if((()=>{const e=this._eventsInProgress.drag;return e&&!this._handlersById[e.handlerName].isActive()})()&&!Ya(t)){const e=o.zoom;o.cameraElevationReference="sea",null!=this._originalZoom&&o._orthographicProjectionAtLowPitch&&"globe"!==o.projection.name&&0===o.pitch?(o.cameraElevationReference="ground",o.zoom=this._originalZoom):(o.recenterOnTerrain(),o.cameraElevationReference="ground"),e!==o.zoom&&this._map._update(!0)}if(o._isCameraConstrained&&n._stop(!0),!Ya(t))return void this._fireEvents(i,r,!0);let{panDelta:a,zoomDelta:l,bearingDelta:c,pitchDelta:h,around:u,aroundCoord:d,pinchAround:p}=t;o._isCameraConstrained&&(l>0&&(l=0),o._isCameraConstrained=!1),void 0!==p&&(u=p),(l||(e=>i[e]&&!this._eventsInProgress[e])("drag"))&&u&&(this._dragOrigin=s(o.pointCoordinate3D(u)),this._originalZoom=o.zoom,this._trackingEllipsoid.setup(o._camera.position,this._dragOrigin)),o.cameraElevationReference="sea",n._stop(!0),u=u||n.transform.centerPoint,c&&(o.bearing+=c),h&&(o.pitch+=h),o._updateCameraState();const f=[0,0,0];if(a)if("mercator"===o.projection.name){const e=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(u).dir),t=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(u.sub(a)).dir);f[0]=t[0]-e[0],f[1]=t[1]-e[1]}else{const t=o.pointCoordinate(u);if("globe"===o.projection.name){a=a.rotate(-o.angle);const i=o._pixelsPerMercatorPixel/o.worldSize;f[0]=-a.x*e.dB(e.aS(t.y))*i,f[1]=-a.y*e.dB(o.center.lat)*i}else{const e=o.pointCoordinate(u.sub(a));t&&e&&(f[0]=e.x-t.x,f[1]=e.y-t.y)}}const m=o.zoom,_=[0,0,0];if(l){const t=s(d||o.pointCoordinate3D(u)),i={dir:e.ab.vec3.normalize([],e.ab.vec3.sub([],t,o._camera.position))};if(i.dir[2]<0){const r=o.zoomDeltaToMovement(t,l);e.ab.vec3.scale(_,i.dir,r)}}const g=e.ab.vec3.add(f,f,_);o._translateCameraConstrained(g),l&&Math.abs(o.zoom-m)>1e-4&&o.recenterOnTerrain(),o.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(i,r,!0)}_fireEvents(t,i,r){const n=Ha(this._eventsInProgress),o=Ha(t),s={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(s[`${e}start`]=i),this._eventsInProgress[e]=t[e]}!n&&o&&this._fireEvent("movestart",o.originalEvent);for(const e in s)this._fireEvent(e,s[e]);o&&this._fireEvent("move",o.originalEvent);for(const e in t){const{originalEvent:i}=t[e];this._fireEvent(e,i)}const a={};let l;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:r}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=i[t]||r,a[`${e}end`]=l)}for(const e in a)this._fireEvent(e,a[e]);const c=Ha(this._eventsInProgress);if(r&&(n||o)&&!c){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap<e&&e<this._bearingSnap;t?(i(t.bearing||this._map.getBearing())&&(t.bearing=0),this._map.easeTo(t,{originalEvent:l})):(this._map.fire(new e.z("moveend",{originalEvent:l})),i(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(t,i){this._map.fire(new e.z(t,i?{originalEvent:i}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((e=>{this._frameId=void 0,this.handleEvent(new Wa("renderFrame",{timeStamp:e})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const Ja="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Qa 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.aP(["_renderFrameCallback"],this)}getCenter(){return new e.bO(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(t,i,r){return t=e.P.convert(t).mult(-1),this.panTo(this.transform.center,e.l({offset:t},i),r)}panTo(t,i,r){return this.easeTo(e.l({center:t},i),r)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(t,i,r){return this.easeTo(e.l({zoom:t},i),r)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}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,r){return this.easeTo(e.l({bearing:t},i),r)}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())<this._bearingSnap?this.resetNorth(e,t):this}getPitch(){return this.transform.pitch}setPitch(e,t){return this.jumpTo({pitch:e},t),this}cameraForBounds(t,i){t=e.az.convert(t);const r=i&&i.bearing||0,n=i&&i.pitch||0,o=t.getNorthWest(),s=t.getSouthEast();return this._cameraForBounds(this.transform,o,s,r,n,i)}_extendPadding(t){const i={top:0,right:0,bottom:0,left:0};return null==t?e.l({},i,this.transform.padding):"number"==typeof t?{top:t,bottom:t,right:t,left:t}:e.l({},i,t)}_extendCameraOptions(t){return(t=e.l({offset:[0,0],maxZoom:this.transform.maxZoom},t)).padding=this._extendPadding(t.padding),t}_minimumAABBFrustumDistance(e,t){const i=t.max[0]-t.min[0],r=t.max[1]-t.min[1];return i/r>e.aspect?i/(2*Math.tan(.5*e.fovX)*e.aspect):r/(2*Math.tan(.5*e.fovY)*e.aspect)}_cameraForBoundsOnGlobe(t,i,r,n,o,s){const a=t.clone(),l=this._extendCameraOptions(s);a.bearing=n,a.pitch=o;const c=e.bO.convert(i),h=e.bO.convert(r),u=.5*(c.lat+h.lat),d=.5*(c.lng+h.lng),p=e.dC(u,d),f=e.ab.vec3.normalize([],p),m=e.ab.vec3.normalize([],e.ab.vec3.cross([],f,[0,1,0])),_=e.ab.vec3.cross([],m,f),g=[m[0],m[1],m[2],0,_[0],_[1],_[2],0,f[0],f[1],f[2],0,0,0,0,1],y=[p,e.dC(c.lat,c.lng),e.dC(h.lat,c.lng),e.dC(h.lat,h.lng),e.dC(c.lat,h.lng),e.dC(u,c.lng),e.dC(u,h.lng),e.dC(c.lat,d),e.dC(h.lat,d)];let x=e.cd.fromPoints(y.map((t=>[e.ab.vec3.dot(m,t),e.ab.vec3.dot(_,t),e.ab.vec3.dot(f,t)])));const v=e.ab.vec3.transformMat4([],x.center,g);0===e.ab.vec3.squaredLength(v)&&e.ab.vec3.set(v,0,0,1),e.ab.vec3.normalize(v,v),e.ab.vec3.scale(v,v,e.ax),a.center=e.dD(v);const b=a.getWorldToCameraMatrix(),w=e.ab.mat4.invert(new Float64Array(16),b);x=e.cd.applyTransform(x,e.ab.mat4.multiply([],b,g));const T=this._extendAABB(x,a,l,n);if(!T)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");x=T,e.ab.vec3.transformMat4(v,v,b);const S=.5*(x.max[2]-x.min[2]),M=this._minimumAABBFrustumDistance(a,x),E=e.ab.vec3.scale([],[0,0,1],S),A=e.ab.vec3.add(E,v,E),I=M+(0===a.pitch?0:e.ab.vec3.distance(v,A)),C=a.globeCenterInViewSpace,P=e.ab.vec3.sub([],v,[C[0],C[1],C[2]]);e.ab.vec3.normalize(P,P),e.ab.vec3.scale(P,P,I);const z=e.ab.vec3.add([],v,P);e.ab.vec3.transformMat4(z,z,w);const D=e.ds/e.ax,R=e.ab.vec3.length(z),L=e.bH(Math.max(R*D-e.ds,Number.EPSILON),0),O=Math.min(a.zoomFromMercatorZAdjusted(L),l.maxZoom);return O>.5*(e.c6+e.bY)?(a.setProjection({name:"mercator"}),a.zoom=O,this._cameraForBounds(a,i,r,n,o,s)):{center:a.center,zoom:O,bearing:n,pitch:o}}_extendAABB(t,i,r,n){const o=.5*((r.padding.left||0)+(r.padding.right||0)),s=.5*((r.padding.top||0)+(r.padding.bottom||0)),a=s,l=o,c=o,h=s,u=i.width-(l+c),d=i.height-(a+h),p=e.ab.vec3.sub([],t.max,t.min),f=Math.min(u/p[0],d/p[1]),m=Math.min(i.scaleZoom(i.scale*f),r.maxZoom);if(isNaN(m))return null;const _=i.scale/i.zoomScale(m),g=new e.cd([t.min[0]-l*_,t.min[1]-h*_,t.min[2]],[t.max[0]+c*_,t.max[1]+a*_,t.max[2]]),y=("number"==typeof r.offset.x&&"number"==typeof r.offset.y?new e.P(r.offset.x,r.offset.y):e.P.convert(r.offset)).rotate(-e.ai(n));return g.center[0]-=y.x*_,g.center[1]+=y.y*_,g}queryTerrainElevation(t,i){const r=this.transform.elevation;return r?(i=e.l({},{exaggerated:!0},i),r.getAtPoint(e.aa.fromLngLat(t),null,i.exaggerated)):null}_cameraForBounds(t,i,r,n,o,s){if("globe"===t.projection.name)return this._cameraForBoundsOnGlobe(t,i,r,n,o,s);const a=t.clone(),l=this._extendCameraOptions(s);a.bearing=n,a.pitch=o;const c=e.bO.convert(i),h=e.bO.convert(r),u=new e.bO(c.lng,h.lat),d=new e.bO(h.lng,c.lat),p=a.project(c),f=a.project(h),m=this.queryTerrainElevation(c),_=this.queryTerrainElevation(h),g=this.queryTerrainElevation(u),y=this.queryTerrainElevation(d),x=[[p.x,p.y,Math.min(m||0,_||0,g||0,y||0)],[f.x,f.y,Math.max(m||0,_||0,g||0,y||0)]];let v=e.cd.fromPoints(x);const b=a.getWorldToCameraMatrix(),w=e.ab.mat4.invert(new Float64Array(16),b);v=e.cd.applyTransform(v,b);const T=this._extendAABB(v,a,l,n);if(!T)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");v=T;const S=.5*e.ab.vec3.sub([],v.max,v.min)[2],M=this._minimumAABBFrustumDistance(a,v),E=[0,0,1,0];e.ab.vec4.transformMat4(E,E,b),e.ab.vec4.normalize(E,E);const A=e.ab.vec3.scale([],E,M+S),I=e.ab.vec3.add([],v.center,A);e.ab.vec3.transformMat4(v.center,v.center,w),e.ab.vec3.transformMat4(I,I,w);const C=a.unproject(new e.P(v.center[0],v.center[1])),P=e.dE(a.projection,C),z=Math.pow(2,P),D=Math.min(a._zoomFromMercatorZ(I[2]*a.pixelsPerMeter*z/a.worldSize),l.maxZoom);return a.mercatorFromTransition&&D<.5*(e.c6+e.bY)?(a.setProjection({name:"globe"}),a.zoom=D,this._cameraForBounds(a,i,r,n,o,s)):{center:C,zoom:D,bearing:n,pitch:o}}fitBounds(e,t,i){const r=this.cameraForBounds(e,t);return this._fitInternal(r,t,i)}fitScreenCoordinates(t,i,r,n,o){const s=e.P.convert(t),a=e.P.convert(i),l=new e.P(Math.min(s.x,a.x),Math.min(s.y,a.y)),c=new e.P(Math.max(s.x,a.x),Math.max(s.y,a.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(s,a))return this;const h=this.transform.pointLocation3D(l),u=this.transform.pointLocation3D(c),d=this.transform.pointLocation3D(new e.P(l.x,c.y)),p=this.transform.pointLocation3D(new e.P(c.x,l.y)),f=[Math.min(h.lng,u.lng,d.lng,p.lng),Math.min(h.lat,u.lat,d.lat,p.lat)],m=[Math.max(h.lng,u.lng,d.lng,p.lng),Math.max(h.lat,u.lat,d.lat,p.lat)],_=n&&n.pitch?n.pitch:this.getPitch(),g=this._cameraForBounds(this.transform,f,m,r,_,n);return this._fitInternal(g,n,o)}_fitInternal(t,i,r){return t?(i=e.l(t,i)).linear?this.easeTo(i,r):this.flyTo(i,r):this}jumpTo(t,i){this.stop();const r=t.preloadOnly?this.transform.clone():this.transform;let n=!1,o=!1,s=!1;"zoom"in t&&r.zoom!==+t.zoom&&(n=!0,r.zoom=+t.zoom),void 0!==t.center&&(r.center=e.bO.convert(t.center)),"bearing"in t&&r.bearing!==+t.bearing&&(o=!0,r.bearing=+t.bearing),"pitch"in t&&r.pitch!==+t.pitch&&(s=!0,r.pitch=+t.pitch);const a="number"==typeof t.padding?this._extendPadding(t.padding):t.padding;if(null!=t.padding&&!r.isPaddingEqual(a))if(!1===t.retainPadding){const e=r.clone();e.padding=a,r.setLocationAtPoint(r.center,e.centerPoint)}else r.padding=a;return t.preloadOnly?(this._preloadTiles(r),this):(this.fire(new e.z("movestart",i)).fire(new e.z("move",i)),n&&this.fire(new e.z("zoomstart",i)).fire(new e.z("zoom",i)).fire(new e.z("zoomend",i)),o&&this.fire(new e.z("rotatestart",i)).fire(new e.z("rotate",i)).fire(new e.z("rotateend",i)),s&&this.fire(new e.z("pitchstart",i)).fire(new e.z("pitch",i)).fire(new e.z("pitchend",i)),this.fire(new e.z("moveend",i)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||e.w(Ja),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,i){const r=this.transform;if(!r.projection.supportsFreeCamera)return e.w(Ja),this;this.stop();const n=r.zoom,o=r.pitch,s=r.bearing;r.setFreeCameraOptions(t);const a=n!==r.zoom,l=o!==r.pitch,c=s!==r.bearing;return this.fire(new e.z("movestart",i)).fire(new e.z("move",i)),a&&this.fire(new e.z("zoomstart",i)).fire(new e.z("zoom",i)).fire(new e.z("zoomend",i)),c&&this.fire(new e.z("rotatestart",i)).fire(new e.z("rotate",i)).fire(new e.z("rotateend",i)),l&&this.fire(new e.z("pitchstart",i)).fire(new e.z("pitch",i)).fire(new e.z("pitchend",i)),this.fire(new e.z("moveend",i)),this}easeTo(t,i){this._stop(!1,t.easeId),(!1===(t=e.l({offset:[0,0],duration:500,easing:e.dA},t)).animate||this._prefersReducedMotion(t))&&(t.duration=0);const r=this.transform,n=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?+t.zoom:n,c="bearing"in t?this._normalizeBearing(t.bearing,o):o,h="pitch"in t?+t.pitch:s,u=this._extendPadding(t.padding),d=e.P.convert(t.offset);let p,f,m;if("globe"===r.projection.name){const i=e.aa.fromLngLat(r.center),n=d.rotate(-r.angle);i.x+=n.x/r.worldSize,i.y+=n.y/r.worldSize;const o=i.toLngLat(),s=e.bO.convert(t.center||o);this._normalizeCenter(s),p=r.centerPoint.add(n),f=new e.P(i.x,i.y).mult(r.worldSize),m=new e.P(e.at(s.lng),e.aA(s.lat)).mult(r.worldSize).sub(f)}else{p=r.centerPoint.add(d);const i=r.pointLocation(p),n=e.bO.convert(t.center||i);this._normalizeCenter(n),f=r.project(i),m=r.project(n).sub(f)}const _=r.zoomScale(l-n);let g,y;t.around&&(g=e.bO.convert(t.around),y=r.locationPoint(g));const x=this._zooming||l!==n,v=this._rotating||o!==c,b=this._pitching||h!==s,w=!r.isPaddingEqual(u),T=!1===t.retainPadding?r.clone():r,S=r=>S=>{if(x&&(r.zoom=e.af(n,l,S)),v&&(r.bearing=e.af(o,c,S)),b&&(r.pitch=e.af(s,h,S)),w&&(T.interpolatePadding(a,u,S),p=T.centerPoint.add(d)),g)r.setLocationAtPoint(g,y);else{const e=r.zoomScale(r.zoom-n),t=l>n?Math.min(2,_):Math.max(.5,_),i=Math.pow(t,1-S),o=r.unproject(f.add(m.mult(S*i)).mult(e));r.setLocationAtPoint(r.renderWorldCopies?o.wrap():o,p)}return t.preloadOnly||this._fireMoveEvents(i),r};if(t.preloadOnly){const e=this._emulate(S,t.duration,r);return this._preloadTiles(e),this}const M={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=x,this._rotating=v,this._pitching=b,this._padding=w,this._easeId=t.easeId,this._prepareEase(i,t.noMoveStart,M),this._ease(S(r),(e=>{"sea"===r.cameraElevationReference&&r.recenterOnTerrain(),this._afterEase(i,e)}),t),this}_prepareEase(t,i,r={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&0===this.transform.pitch&&"globe"!==this.transform.projection.name&&(this.transform.cameraElevationReference="ground"),i||r.moving||this.fire(new e.z("movestart",t)),this._zooming&&!r.zooming&&this.fire(new e.z("zoomstart",t)),this._rotating&&!r.rotating&&this.fire(new e.z("rotatestart",t)),this._pitching&&!r.pitching&&this.fire(new e.z("pitchstart",t))}_fireMoveEvents(t){this.fire(new e.z("move",t)),this._zooming&&this.fire(new e.z("zoom",t)),this._rotating&&this.fire(new e.z("rotate",t)),this._pitching&&this.fire(new e.z("pitch",t))}_afterEase(t,i){if(this._easeId&&i&&this._easeId===i)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const r=this._zooming,n=this._rotating,o=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,r&&this.fire(new e.z("zoomend",t)),n&&this.fire(new e.z("rotateend",t)),o&&this.fire(new e.z("pitchend",t)),this.fire(new e.z("moveend",t))}flyTo(t,i){if(this._prefersReducedMotion(t)){const r=e.ay(t,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(r,i)}this.stop(),t=e.l({offset:[0,0],speed:1.2,curve:1.42,easing:e.dA},t);const r=this.transform,n=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?e.aw(+t.zoom,r.minZoom,r.maxZoom):n,c="bearing"in t?this._normalizeBearing(t.bearing,o):o,h="pitch"in t?+t.pitch:s,u=this._extendPadding(t.padding),d=r.zoomScale(l-n),p=e.P.convert(t.offset);let f=r.centerPoint.add(p);const m=r.pointLocation(f),_=e.bO.convert(t.center||m);this._normalizeCenter(_);const g=r.project(m),y=r.project(_).sub(g);let x=t.curve;const v=Math.max(r.width,r.height),b=v/d,w=y.mag();if("minZoom"in t){const i=e.aw(Math.min(t.minZoom,n,l),r.minZoom,r.maxZoom),o=v/r.zoomScale(i-n);x=Math.sqrt(o/w*2)}const T=x*x;function S(e){const t=(b*b-v*v+(e?-1:1)*T*T*w*w)/(2*(e?b:v)*T*w);return Math.log(Math.sqrt(t*t+1)-t)}function M(e){return(Math.exp(e)-Math.exp(-e))/2}function E(e){return(Math.exp(e)+Math.exp(-e))/2}const A=S(0);let I=function(e){return E(A)/E(A+x*e)},C=function(e){return v*((E(A)*(M(t=A+x*e)/E(t))-M(A))/T)/w;var t},P=(S(1)-A)/x;if(Math.abs(w)<1e-6||!isFinite(P)){if(Math.abs(v-b)<1e-6)return this.easeTo(t,i);const e=b<v?-1:1;P=Math.abs(Math.log(b/v))/x,C=function(){return 0},I=function(t){return Math.exp(e*x*t)}}t.duration="duration"in t?+t.duration:1e3*P/("screenSpeed"in t?+t.screenSpeed/x:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0);const z=o!==c,D=h!==s,R=!r.isPaddingEqual(u),L=!1===t.retainPadding?r.clone():r,O=r=>d=>{const m=d*P,x=1/I(m);r.zoom=1===d?l:n+r.scaleZoom(x),z&&(r.bearing=e.af(o,c,d)),D&&(r.pitch=e.af(s,h,d)),R&&(L.interpolatePadding(a,u,d),f=L.centerPoint.add(p));const v=1===d?_:r.unproject(g.add(y.mult(C(m))).mult(x));return r.setLocationAtPoint(r.renderWorldCopies?v.wrap():v,f),r._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(i),r};if(t.preloadOnly){const e=this._emulate(O,t.duration,r);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=z,this._pitching=D,this._padding=R,this._prepareEase(i,!1),this._ease(O(r),(()=>this._afterEase(i)),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(e){}_cancelRenderFrame(e){}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const e=this._onEaseEnd;this._onEaseEnd=void 0,e.call(this,t)}if(!e){const e=this.handlers;e&&e.stop(!1)}return this}_ease(t,i,r){!1===r.animate||0===r.duration?(t(1),i()):(this._easeStart=e.q.now(),this._easeOptions=r,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.bF(t,-180,180);const r=Math.abs(t-i);return Math.abs(t-360-i)<r&&(t-=360),Math.abs(t+360-i)<r&&(t+=360),t}_normalizeCenter(e){const t=this.transform;if(t.maxBounds)return;if("globe"!==t.projection.name&&!t.renderWorldCopies)return;const i=e.lng-t.center.lng;e.lng+=i>180?-360:i<-180?360:0}_prefersReducedMotion(t){return this._respectPrefersReducedMotion&&e.q.prefersReducedMotion&&!(t&&t.essential)}_emulate(e,t,i){const r=Math.ceil(15*t/1e3),n=[],o=e(i.clone());for(let e=0;e<=r;e++){const t=o(e/r);n.push(t.clone())}return n}_preloadTiles(e,t){}}class el{constructor(t={}){this.options=t,e.aP(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(e){const t=this.options&&this.options.compact,i=e._getUIString("AttributionControl.ToggleAttribution");this._map=e,this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=l("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",i);const r=l("span","mapboxgl-ctrl-icon",this._compactButton);return r.setAttribute("aria-hidden","true"),r.setAttribute("title",i),this._innerContainer=l("div","mapboxgl-ctrl-attrib-inner",this._container),t&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===t&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let t=this._editLink;t||(t=this._editLink=this._container.querySelector(".mapbox-improve-map"));const i=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||e.e.ACCESS_TOKEN}];if(t){const r=i.reduce(((e,t,r)=>(t.value&&(e+=`${t.key}=${t.value}${r<i.length-1?"&":""}`),e)),"?");t.href=`${e.e.FEEDBACK_URL}/${r}#${ia(this._map,!0)}`,t.rel="noopener nofollow"}}_updateData(e){!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType||(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let e=[];if(this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}const t=this._map.style._mergedSourceCaches;for(const i in t){const r=t[i];if(r.used){const t=r.getSource();t.attribution&&e.indexOf(t.attribution)<0&&e.push(t.attribution)}}e.sort(((e,t)=>e.length-t.length)),e=e.filter(((t,i)=>{for(let r=i+1;r<e.length;r++)if(e[r].indexOf(t)>=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 tl{constructor(){e.aP(["_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 il{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 rl{constructor(e){this.jumpTo(e)}getValue(t){if(t<=this._startTime)return this._start;if(t>=this._endTime)return this._end;const i=e.cB((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-i)+this._end*i}isEasing(e){return e>=this._startTime&&e<=this._endTime}jumpTo(e){this._startTime=-1/0,this._endTime=-1/0,this._start=e,this._end=e}easeTo(e,t,i){this._start=this.getValue(t),this._end=e,this._startTime=t,this._endTime=t+i}}const nl={"AttributionControl.ToggleAttribution":"Toggle attribution","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox homepage","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},ol=["mouseenter","mouseover","mouseleave","mouseout"];class sl extends e.z{constructor(e,t,i,r){const{point:n,lngLat:o,originalEvent:s,target:a}=e;super(e.type,{point:n,lngLat:o,originalEvent:s,target:a}),this.preventDefault=()=>{e.preventDefault()},this.id=t,this.interaction=i,this.feature=r}}class al{constructor(e){this.map=e,this.interactionsByType=new Map,this.typeById=new Map,this.filters=new Map,this.delegatedHandlers=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:r,filter:n}=i;n&&this.filters.set(t,e.aZ(n));const o=this.interactionsByType.get(r)||new Map;if(0===o.size){if(ol.includes(r)){const{mousemove:e,mouseout:r}=this._createDelegatedHandlers(t,i);this.map.on("mousemove",e),this.map.on("mouseout",r),this.delegatedHandlers.set(t,{mousemove:e,mouseout:r})}else this.map.on(r,this.handleType);this.interactionsByType.set(r,o)}o.set(t,i),this.typeById.set(t,r)}get(e){const t=this.typeById.get(e);if(!t)return;const i=this.interactionsByType.get(t);return i?i.get(e):void 0}remove(e){const t=this.typeById.get(e);if(!t)return;this.typeById.delete(e),this.filters.delete(e);const i=this.interactionsByType.get(t);if(i){if(i.delete(e),this.delegatedHandlers.has(e)){const{mousemove:t,mouseout:i}=this.delegatedHandlers.get(e);this.map.off("mousemove",t),this.map.off("mouseout",i),this.delegatedHandlers.delete(e)}0===i.size&&this.map.off(t,this.handleType)}}queryTargets(e,t){const i=[];for(const[e,r]of t)r.target&&i.push({targetId:e,target:r.target,filter:this.filters.get(e)});return this.map.style.queryRenderedTargets(e,i,this.map.transform)}handleType(t,i){const r=this.interactionsByType.get(t.type),n=Array.from(r).reverse();i=i||this.queryTargets(t.point,n);let o=!1;for(const r of i){for(const[i,s]of n){if(!s.target)continue;const n=r.variants?r.variants[i]:null;if(n){for(const a of n){const n=new e.cw(r,a);if(!1!==s.handler(new sl(t,i,s,n))){o=!0;break}}if(o)break}}if(o)break}if(!o)for(const[e,i]of n){const{handler:r,target:n}=i;if(!n&&!1!==r(new sl(t,e,i,null)))break}}_createDelegatedHandlers(e,t){switch(t.type){case"mouseenter":case"mouseover":{let i=!1,r=new Set;return{mousemove:n=>{const o=this.queryTargets(n.point,[[e,t]]),s=new Set;if(!o.length)return i=!1,void r.clear();const a=[];for(const e of o)r.has(e.id)||(s.add(e.id),a.push(e));i&&!a.length||(i=!0,r=s,n.type=t.type,this.handleType(n,a))},mouseout:()=>{i=!1,r.clear()}}}case"mouseleave":case"mouseout":{let i=[];return{mousemove:r=>{const n=this.queryTargets(r.point,[[e,t]]);if(!n.length)return r.type=t.type,this.handleType(r,i),void(i=n);const o=[],s=new Set(n.map((e=>e.id)));for(const e of i)s.has(e.id)||o.push(e);o.length&&(r.type=t.type,this.handleType(r,o)),i=n},mouseout:e=>{i.length&&(e.type=t.type,this.handleType(e,i),i=[])}}}}}}function ll(t,i){if(Array.isArray(t)&&Array.isArray(i)){const e=new Set(t),r=new Set(i);return e.size===r.size&&t.every((e=>r.has(e)))}return e.bn(t,i)}const cl={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,performanceMetricsCollection:!0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,antialias:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0,collectResourceTiming:!1,testMode:!1,precompilePrograms:!0,scaleFactor:1,spriteFormat:"auto"},hl={showCompass:!0,showZoom:!0,visualizePitch:!1};class ul{constructor(t,i,r=!1){this._clickTolerance=10,this.element=i,this.mouseRotate=new Sa({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,r&&(this.mousePitch=new Ma({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),e.aP(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),i.addEventListener("mousedown",this.mousedown),i.addEventListener("touchstart",this.touchstart,{passive:!1}),i.addEventListener("touchmove",this.touchmove),i.addEventListener("touchend",this.touchend),i.addEventListener("touchcancel",this.reset)}down(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),p()}move(e,t){const i=this.map,r=this.mouseRotate.mousemoveWindow(e,t),n=r&&r.bearingDelta;if(n&&i.setBearing(i.getBearing()+n),this.mousePitch){const r=this.mousePitch.mousemoveWindow(e,t),n=r&&r.pitchDelta;n&&i.setPitch(i.getPitch()+n)}}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart,{passive:!1}),e.removeEventListener("touchmove",this.touchmove),e.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){f(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(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=y(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=y(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)<this._clickTolerance&&this.element.click(),this.reset()}reset(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()}}function dl(t,i,r){if(t=new e.bO(t.lng,t.lat),i){const n=new e.bO(t.lng-360,t.lat),o=new e.bO(t.lng+360,t.lat),s=360*Math.ceil(Math.abs(t.lng-r.center.lng)/360),a=r.locationPoint(t).distSqr(i),l=i.x<0||i.y<0||i.x>r.width||i.y>r.height;r.locationPoint(n).distSqr(i)<a&&(l||Math.abs(n.lng-r.center.lng)<s)?t=n:r.locationPoint(o).distSqr(i)<a&&(l||Math.abs(o.lng-r.center.lng)<s)&&(t=o)}for(;Math.abs(t.lng-r.center.lng)>180;){const e=r.locationPoint(t);if(e.x>=0&&e.y>=0&&e.x<=r.width&&e.y<=r.height)break;t.lng>r.center.lng?t.lng-=360:t.lng+=360}return t}const pl={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 fl extends e.E{constructor(t,i){if(super(),(t instanceof HTMLElement||i)&&(t=e.l({element:t},i)),e.aP(["_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,r=27,n=c("svg",{display:"block",height:i*this._scale+"px",width:r*this._scale+"px",viewBox:`0 0 ${r} ${i}`},this._element),o=c("radialGradient",{id:"shadowGradient"},c("defs",{},n));c("stop",{offset:"10%","stop-opacity":.4},o),c("stop",{offset:"100%","stop-opacity":.05},o),c("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},n),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"},n),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"},n),c("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},n),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 r=this._element.classList;for(const e in pl)r.remove(`mapboxgl-marker-anchor-${e}`);r.add(`mapboxgl-marker-anchor-${this._anchor}`);const n=t&&t.className?t.className.trim().split(/\s+/):[];r.add(...n),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.bO.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,r=Math.sqrt(Math.pow(i,2)/2);e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[r,-1*(t-i+r)],"bottom-right":[-r,-1*(t-i+r)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset}this._popup=e,e._marker=this,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),r=e.getFreeCameraOptions();if(!r.position)return!1;const n=r.position.toLngLat();return n.distanceTo(i)<.9*n.distanceTo(this._lngLat)}_evaluateOpacity(){const t=this._map;if(!t)return;const i=this._pos;if(!i||i.x<0||i.x>t.transform.width||i.y<0||i.y>t.transform.height)return void this._clearFadeTimer();const r=t.unproject(i);let n;t._showingGlobe()&&e.dH(t.transform,this._lngLat)?n=0:(n=1-t._queryFogOpacity(r),t.transform._terrainEnabled()&&t.getTerrain()&&this._behindTerrain()&&(n*=this._occludedOpacity)),this._element.style.opacity=`${n}`,this._element.style.pointerEvents=n>0?"auto":"none",this._popup&&this._popup._setOpacity(n),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const e=this._pos;if(!e||!this._map)return;const t=this._offset.mult(this._scale);this._element.style.transform=`\n translate(${e.x}px,${e.y}px)\n ${pl[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${t.x}px,${t.y}px)\n `}_calculateXYTransform(){const t=this._pos,i=this._map,r=this.getPitchAlignment();if(!i||!t||"map"!==r)return"";if(!i._showingGlobe()){const e=i.getPitch();return e?`rotateX(${e}deg)`:""}const n=e.c4(e.dI(i.transform,this._lngLat)),o=t.sub(e.dJ(i.transform)),s=Math.abs(o.x)+Math.abs(o.y);if(0===s)return"";const a=n/s;return`rotateX(${-o.y*a}deg) rotateY(${o.x*a}deg)`}_calculateZTransform(){const t=this._pos,i=this._map;if(!i||!t)return"";let r=0;const n=this.getRotationAlignment();if("map"===n)if(i._showingGlobe()){const t=i.project(new e.bO(this._lngLat.lng,this._lngLat.lat+.001)),n=i.project(new e.bO(this._lngLat.lng,this._lngLat.lat-.001)).sub(t);r=e.c4(Math.atan2(n.y,n.x))-90}else r=-i.getBearing();else if("horizon"===n){const n=e.ac(4,6,i.getZoom()),o=e.dJ(i.transform);o.y+=n*i.transform.height;const s=t.sub(o),a=e.c4(Math.atan2(s.y,s.x));r=(a>90?a-270:a+90)*(1-n)}return r+=this._rotation,r?`rotateZ(${r}deg)`:""}_update(e){cancelAnimationFrame(this._updateFrameId);const t=this._map;t&&(t.transform.renderWorldCopies&&(this._lngLat=dl(this._lngLat,this._pos,t.transform)),this._pos=t.project(this._lngLat),!0===e?this._updateFrameId=requestAnimationFrame((()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())})):this._pos=this._pos.round(),t._requestDomTask((()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(t._showingGlobe()||t.getTerrain()||t.getFog())&&!this._fadeTimer&&(this._fadeTimer=window.setTimeout(this._evaluateOpacity.bind(this),60)))})))}getOffset(){return this._offset}setOffset(t){return this._offset=e.P.convert(t),this._update(),this}addClassName(e){return this._element.classList.add(e),this}removeClassName(e){return this._element.classList.remove(e),this}toggleClassName(e){return this._element.classList.toggle(e)}_onMove(t){const i=this._map;if(!i)return;const r=this._pointerdownPos,n=this._positionDelta;if(r&&n){if(!this._isDragging){const e=this._clickTolerance||i._clickTolerance;if(t.point.dist(r)<e)return;this._isDragging=!0}this._pos=t.point.sub(n),this._lngLat=i.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new e.z("dragstart"))),this.fire(new e.z("drag"))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const t=this._map;t&&(t.off("mousemove",this._onMove),t.off("touchmove",this._onMove)),"active"===this._state&&this.fire(new e.z("dragend")),this._state="inactive"}_addDragHandler(e){const t=this._map,i=this._pos;t&&i&&this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(i),this._pointerdownPos=e.point,this._state="pending",t.on("mousemove",this._onMove),t.on("touchmove",this._onMove),t.once("mouseup",this._onUp),t.once("touchend",this._onUp))}setDraggable(e){this._draggable=!!e;const t=this._map;return t&&(e?(t.on("mousedown",this._addDragHandler),t.on("touchstart",this._addDragHandler)):(t.off("mousedown",this._addDragHandler),t.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return"auto"===this._rotationAlignment||"horizon"===this._rotationAlignment&&this._map&&!this._map._showingGlobe()?"viewport":this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e||"auto",this._update(),this}getPitchAlignment(){return"auto"===this._pitchAlignment?this.getRotationAlignment():this._pitchAlignment}setOccludedOpacity(e){return this._occludedOpacity=e||.2,this._update(),this}getOccludedOpacity(){return this._occludedOpacity}}const ml={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1},_l={maxWidth:100,unit:"metric"},gl={kilometer:"km",meter:"m",mile:"mi",foot:"ft","nautical-mile":"nm"},yl={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},xl=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function vl(t=new e.P(0,0),i="bottom"){if("number"==typeof t){const r=Math.round(Math.sqrt(.5*Math.pow(t,2)));switch(i){case"top":return new e.P(0,t);case"top-left":return new e.P(r,r);case"top-right":return new e.P(-r,r);case"bottom":return new e.P(0,-t);case"bottom-left":return new e.P(r,-r);case"bottom-right":return new e.P(-r,-r);case"left":return new e.P(t,0);case"right":return new e.P(-t,0)}return new e.P(0,0)}return t instanceof e.P||Array.isArray(t)?e.P.convert(t):e.P.convert(t[i]||[0,0])}const bl={version:t,supported:a.supported,setRTLTextPlugin:e.dK,getRTLTextPluginStatus:e.dL,Map:class extends Qa{constructor(t){r.mark(i.create);const n=t;if(null!=(t=e.l({},cl,t)).minZoom&&null!=t.maxZoom&&t.minZoom>t.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(t.antialias&&e.dF(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 rr(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 il,this._domRenderTaskQueue=new il,this._controls=[],this._markers=[],this._popups=[],this._mapId=e.aV(),this._locale=e.l({},nl,t.locale),this._clickTolerance=t.clickTolerance,this._cooperativeGestures=t.cooperativeGestures,this._performanceMetricsCollection=t.performanceMetricsCollection,this._tessellationStep=t.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._precompilePrograms=t.precompilePrograms,this._scaleFactorChanged=!1,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new rl(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=t.scaleFactor,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),this._spriteFormat=t.spriteFormat,e.aP(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._tp||(this._tp=new Ns),this._tp.registerParameter(this,["Debug"],"showOverdrawInspector"),this._tp.registerParameter(this,["Debug"],"showTileBoundaries"),this._tp.registerParameter(this,["Debug"],"showParseStatus"),this._tp.registerParameter(this,["Debug"],"repaint"),this._tp.registerParameter(this,["Debug"],"showTileAABBs"),this._tp.registerParameter(this,["Debug"],"showPadding"),this._tp.registerParameter(this,["Debug"],"showCollisionBoxes",{noSave:!0}),this._tp.registerParameter(this.transform,["Debug"],"freezeTileCoverage",{noSave:!0},(()=>{this._update()})),this._tp.registerParameter(this,["Debug","Wireframe"],"showTerrainWireframe"),this._tp.registerParameter(this,["Debug","Wireframe"],"showLayers2DWireframe"),this._tp.registerParameter(this,["Debug","Wireframe"],"showLayers3DWireframe"),this._tp.registerParameter(this,["Scaling"],"_scaleFactor",{min:.1,max:10,step:.1},(()=>{this.setScaleFactor(this._scaleFactor)})),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");if(this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this._fullscreenchangeEvent="onfullscreenchange"in document?"fullscreenchange":"webkitfullscreenchange",window.addEventListener("online",this._onWindowOnline,!1),window.addEventListener("resize",this._onWindowResize,!1),window.addEventListener("orientationchange",this._onWindowResize,!1),window.addEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.addEventListener("visibilitychange",this._onVisibilityChange,!1),this.handlers=new Ka(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),this.indoor=new gr(this),t.hash&&(this._hash=new ta("string"==typeof t.hash&&t.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){null==n.center&&null==n.zoom||(this.transform._unmodified=!1),this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch});const i=t.bounds;i&&(this.resize(),this.fitBounds(i,e.l({},t.fitBoundsOptions,{duration:0})))}this.resize(),t.attributionControl&&this.addControl(new el({customAttribution:t.customAttribution})),this._logoControl=new tl,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.z(`${t.dataType}data`,t))})),this.on("dataloading",(t=>{this.fire(new e.z(`${t.dataType}dataloading`,t))})),this._interactions=new al(this)}_getMapId(){return this._mapId}addControl(t,i){if(void 0===i&&(i=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.y(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const r=t.onAdd(this);this._controls.push(t);const n=this._controlPositions[i];return-1!==i.indexOf("bottom")?n.insertBefore(r,n.firstChild):n.appendChild(r),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.y(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(t);return i>-1&&this._controls.splice(i,1),t.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(t){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const i=!this._moving;return i&&this.fire(new e.z("movestart",t)).fire(new e.z("move",t)),this.fire(new e.z("resize",t)),i&&this.fire(new e.z("moveend",t)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(t){return this.transform.setMaxBounds(e.az.convert(t)),this._update()}setMinZoom(t){if((t=t??-2)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()<t?this.setZoom(t):this.fire(new e.z("zoomstart")).fire(new e.z("zoom")).fire(new e.z("zoomend")),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(t){if((t=t??22)>=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new e.z("zoomstart")).fire(new e.z("zoom")).fire(new e.z("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=t??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()<t?this.setPitch(t):this.fire(new e.z("pitchstart")).fire(new e.z("pitch")).fire(new e.z("pitchend")),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(t){if((t=t??85)>85)throw new Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t?this.setPitch(t):this.fire(new e.z("pitchstart")).fire(new e.z("pitch")).fire(new e.z("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getScaleFactor(){return this._scaleFactor}setScaleFactor(e){return this._scaleFactor=e,this.painter.scaleFactor=e,this._tp.refreshUI(),this._scaleFactorChanged=!0,this.style._updateFilteredLayers((e=>"symbol"===e.type)),this._update(!0),this}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.renderWorldCopies=e,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(e){return"auto"===e?navigator.language:Array.isArray(e)?0===e.length?void 0:e.map((e=>"auto"===e?navigator.language:e)):e}setLanguage(e){const t=this._parseLanguage(e);if(!this.style||t===this._language)return this;this._language=t,this.style.reloadSources();for(const e of this._controls)e._setLanguage&&e._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(e){return this.style&&e!==this._worldview?(this._worldview=e,this.style.reloadSources(),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return"globe"===this.transform.projection.name}setProjection(e){return this._lazyInitEmptyStyle(),e?"string"==typeof e&&(e={name:e}):e=null,this._useExplicitProjection=!!e,this._prioritizeAndUpdateProjection(e,this.style.projection)}_updateProjectionTransition(){if("globe"!==this.getProjection().name)return;const t=this.transform,i=t.projection.name;let r;"globe"===i&&t.zoom>=e.bY?(t.setMercatorFromTransition(),r=!0):"mercator"===i&&t.zoom<e.bY&&(t.setProjection({name:"globe"}),r=!0),r&&(this.style.applyProjectionUpdate(),this.style._forceSymbolLayerUpdate())}_prioritizeAndUpdateProjection(e,t){return this._updateProjection(e||t||{name:"mercator"})}_updateProjection(t){let i;return i="globe"===t.name&&this.transform.zoom>=e.bY?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.bO.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){const r=e=>{let i=[];if(Array.isArray(t)){const r=t.filter((e=>this.getLayer(e)));i=r.length?this.queryRenderedFeatures(e,{layers:r}):[]}else i=this.queryRenderedFeatures(e,{target:t});return i};if("mouseenter"===e||"mouseover"===e){let n=!1;const o=t=>{const o=r(t.point);o.length?n||(n=!0,i.call(this,new ua(e,this,t.originalEvent,{features:o}))):n=!1};return{listener:i,targets:t,delegates:{mousemove:o,mouseout:()=>{n=!1}}}}if("mouseleave"===e||"mouseout"===e){let n=!1;const o=t=>{r(t.point).length?n=!0:n&&(n=!1,i.call(this,new ua(e,this,t.originalEvent)))},s=t=>{n&&(n=!1,i.call(this,new ua(e,this,t.originalEvent)))};return{listener:i,targets:t,delegates:{mousemove:o,mouseout:s}}}{const n=e=>{const t=r(e.point);t.length&&(e.features=t,i.call(this,e),delete e.features)};return{listener:i,targets:t,delegates:{[e]:n}}}}on(e,t,i){if("function"==typeof t||void 0===i)return super.on(e,t);if("string"==typeof t&&(t=[t]),!this._areTargetsValid(t))return this;const r=this._createDelegatedListener(e,t,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(r);for(const e in r.delegates)this.on(e,r.delegates[e]);return this}once(e,t,i){if("function"==typeof t||void 0===i)return super.once(e,t);if("string"==typeof t&&(t=[t]),!this._areTargetsValid(t))return this;const r=this._createDelegatedListener(e,t,i);for(const e in r.delegates)this.once(e,r.delegates[e]);return this}off(e,t,i){if("function"==typeof t||void 0===i)return super.off(e,t);if("string"==typeof t&&(t=[t]),!this._areTargetsValid(t))return this;const r=this._delegatedListeners?this._delegatedListeners[e]:void 0;return r&&(e=>{for(let r=0;r<e.length;r++){const n=e[r];if(n.listener===i&&ll(n.targets,t)){for(const e in n.delegates)this.off(e,n.delegates[e]);return e.splice(r,1),this}}})(r),this}queryRenderedFeatures(t,i){if(!this.style)return[];if(void 0===t||t instanceof e.P||Array.isArray(t)||void 0!==i||(i=t,t=void 0),t=t||[[0,0],[this.transform.width,this.transform.height]],!i){const e=this.style.queryRenderedFeatures(t,void 0,this.transform),i=this.style.queryRenderedFeatureset(t,void 0,this.transform);return e.concat(i)}let r=!0;if(i.target&&(r=this._isTargetValid(i.target),r&&!i.layers))return this.style.queryRenderedFeatureset(t,i,this.transform);let n=!0;if(i.layers&&Array.isArray(i.layers)){for(const e of i.layers)if(!this._isValidId(e)){n=!1;break}if(n&&!i.target)return this.style.queryRenderedFeatures(t,i,this.transform)}let o=[];return n&&(o=o.concat(this.style.queryRenderedFeatures(t,i,this.transform))),r&&(o=o.concat(this.style.queryRenderedFeatureset(t,i,this.transform))),o}querySourceFeatures(e,t){return!e||"string"==typeof e&&!this._isValidId(e)?[]:this.style.querySourceFeatures(e,t)}isPointOnSurface(t){const{name:i}=this.transform.projection;return"globe"!==i&&"mercator"!==i&&e.w(`${i} projection does not support isPointOnSurface, this API may behave unexpectedly.`),this.transform.isPointOnSurface(e.P.convert(t))}addInteraction(e,t){return this._interactions.add(e,t),this}removeInteraction(e){return this._interactions.remove(e),this}setStyle(t,i){return i=e.l({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily},i),this.style&&t&&!1!==i.diff&&i.localFontFamily===this._localFontFamily&&i.localIdeographFontFamily===this._localIdeographFontFamily&&!i.config?(this.style._diffStyle(t,((r,n)=>{r?(e.w(`Unable to perform style diff: ${String(r.message||r.error||r)}. Rebuilding the style from scratch.`),this._updateStyle(t,i)):n&&this._update(!0)}),(()=>{this._postStyleLoadEvent()})),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._localFontFamily=i.localFontFamily,this._updateStyle(t,i))}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(t,i){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),t){const r=e.l({},i);i&&i.config&&(r.initialConfig=i.config,delete r.config),this.style=new Mr(this,r).load(t),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Mr(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(e.w("There is no style added to the map."),!1)}_isValidId(t){return null==t?(this.fire(new e.y(new Error("IDs can't be empty."))),!1):!e.cr(t)||(this.fire(new e.y(new Error(`IDs can't contain special symbols: "${t}".`))),!1)}_isTargetValid(e){return"featuresetId"in e?this._isValidId("importId"in e?e.importId:e.featuresetId):"layerId"in e&&this._isValidId(e.layerId)}_areTargetsValid(e){if(Array.isArray(e)){for(const t of e)if(!this._isValidId(t))return!1;return!0}return this._isTargetValid(e)}addSource(e,t){return this._isValidId(e)?(this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)):this}isSourceLoaded(e){return!!this._isValidId(e)&&!!this.style&&this.style._isSourceCacheLoaded(e)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(e,t,i){this._lazyInitEmptyStyle(),this.style.addSourceType(e,t,i)}removeSource(e){return this._isValidId(e)?(this.style.removeSource(e),this._updateTerrain(),this._update(!0)):this}getSource(e){return this._isValidId(e)?this.style.getOwnSource(e):null}addImage(t,i,{pixelRatio:r=1,sdf:n=!1,stretchX:o,stretchY:s,content:a}={}){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:r,stretchX:o,stretchY:s,content:a,sdf:n,version:0,usvg:!1})}else if(void 0===i.width||void 0===i.height)this.fire(new e.y(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else{const{width:l,height:c}=i,h=i;this.style.addImage(t,{data:new e.r({width:l,height:c},new Uint8Array(h.data)),pixelRatio:r,stretchX:o,stretchY:s,content:a,sdf:n,usvg:!1,version:0,userImage:h}),h.onAdd&&h.onAdd(this,t)}}updateImage(t,i){this._lazyInitEmptyStyle();const r=this.style.getImage(t);if(!r)return void this.fire(new e.y(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const n=i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap?e.q.getImageData(i):i,{width:o,height:s,data:a}=n;if(void 0===o||void 0===s)return void this.fire(new e.y(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(o!==(r.usvg?r.icon.usvg_tree.width:r.data.width)||s!==(r.usvg?r.icon.usvg_tree.height:r.data.height))return void this.fire(new e.y(new Error(`The width and height of the updated image (${o}, ${s})\n must be that same as the previous version of the image\n (${r.data.width}, ${r.data.height})`)));const l=!(i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap);let c=!1;r.usvg?(r.data=new e.r({width:o,height:s},new Uint8Array(a)),r.usvg=!1,r.icon=void 0,c=!0):r.data.replace(a,l),this.style.updateImage(t,r,c)}hasImage(t){return t?!!this.style&&!!this.style.getImage(t):(this.fire(new e.y(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,r)=>{i(t,r instanceof HTMLImageElement?e.q.getImageData(r):r)}))}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.y(new Error("Missing required model id"))),!1)}removeModel(e){this.style.removeModel(e)}listModels(){return this.style.listModels()}addLayer(e,t){return this._isValidId(e.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)):this}getSlot(e){const t=this.getLayer(e);return t&&t.slot||null}setSlot(e,t){return this.style.setSlot(e,t),this.style.mergeLayers(),this._update(!0)}addImport(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,r={}){return this._isValidId(e)?(this.style.setPaintProperty(e,t,i,r),this._update(!0)):this}getPaintProperty(e,t){return this._isValidId(e)?this.style.getPaintProperty(e,t):null}setLayoutProperty(e,t,i,r={}){return this._isValidId(e)?(this.style.setLayoutProperty(e,t,i,r),this._update(!0)):this}getLayoutProperty(e,t){return this._isValidId(e)?this.style.getLayoutProperty(e,t):null}getSchema(e){return this.style.getSchema(e)}setSchema(e,t){return this.style.setSchema(e,t),this._update(!0)}getConfig(e){return this.style.getConfig(e)}setConfig(e,t){return this.style.setConfig(e,t),this._update(!0)}getConfigProperty(e,t){return this.style.getConfigProperty(e,t)}setConfigProperty(e,t,i){return this.style.setConfigProperty(e,t,i),this._update(!0)}getFeaturesetDescriptors(e){return this.style.getFeaturesetDescriptors(e)}setLights(e){if(this._lazyInitEmptyStyle(),e&&1===e.length&&"flat"===e[0].type){const t=e[0];t.properties?this.style.setFlatLight(t.properties,t.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(e),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const e=this.style.getLights()||[];return 0===e.length&&e.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),e}setLight(e,t={}){return console.log("The `map.setLight` function is deprecated, prefer using `map.setLights` with `flat` light type instead."),this.setLights([{id:"flat",type:"flat",properties:e}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(e){return this._lazyInitEmptyStyle(),!e&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(e),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(e){return this._lazyInitEmptyStyle(),this.style.setFog(e),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setSnow(e){return this._lazyInitEmptyStyle(),this.style.setSnow(e),this._update(!0)}getSnow(){return this.style?this.style.getSnow():null}setRain(e){return this._lazyInitEmptyStyle(),this.style.setRain(e),this._update(!0)}getRain(){return this.style?this.style.getRain():null}setColorTheme(e){return this._lazyInitEmptyStyle(),this.style.setColorTheme(e),this._update(!0)}setImportColorTheme(e,t){return this._lazyInitEmptyStyle(),this.style.setImportColorTheme(e,t),this._update(!0)}setCamera(e){return this.style.setCamera(e),this._triggerCameraUpdate(e)}_triggerCameraUpdate(e){return this._update(this.transform.setOrthographicProjectionAtLowPitch("orthographic"===e["camera-projection"]))}getCamera(){return this.style.camera}_queryFogOpacity(t){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(e.bO.convert(t),this.transform):0}setFeatureState(e,t){return e.source&&!this._isValidId(e.source)?this:(this.style.setFeatureState(e,t),this._update())}removeFeatureState(e,t){return e.source&&!this._isValidId(e.source)?this:(this.style.removeFeatureState(e,t),this._update())}getFeatureState(e){return e.source&&!this._isValidId(e.source)?null:this.style.getFeatureState(e)}_updateContainerDimensions(){if(!this._container)return;const e=this._container.getBoundingClientRect().width||400,t=this._container.getBoundingClientRect().height||300;let i,r,n,o=this._container;for(;o&&(!r||!n);){const e=window.getComputedStyle(o).transform;e&&"none"!==e&&(i=e.match(/matrix.*\((.+)\)/)[1].split(", "),i[0]&&"0"!==i[0]&&"1"!==i[0]&&(r=i[0]),i[3]&&"0"!==i[3]&&"1"!==i[3]&&(n=i[3])),o=o.parentElement}this._containerWidth=r?Math.abs(e/r):e,this._containerHeight=n?Math.abs(t/n):t}_detectMissingCSS(){"rgb(250, 128, 114)"!==window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&e.w("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){const e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=l("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=l("div","mapboxgl-canvas-container",e);this._canvas=l("canvas","mapboxgl-canvas",t),this._interactive&&(t.classList.add("mapboxgl-interactive"),this._canvas.setAttribute("tabindex","0")),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const i=this._controlContainer=l("div","mapboxgl-control-container",e),r=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach((e=>{r[e]=l("div",`mapboxgl-ctrl-${e}`,i)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,i){const r=e.q.devicePixelRatio||1;this._canvas.width=r*Math.ceil(t),this._canvas.height=r*Math.ceil(i),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${i}px`}_addMarker(e){this._markers.push(e)}_removeMarker(e){const t=this._markers.indexOf(e);-1!==t&&this._markers.splice(t,1)}_addPopup(e){this._popups.push(e)}_removePopup(e){const t=this._popups.indexOf(e);-1!==t&&this._popups.splice(t,1)}_setupPainter(){const t=e.l({},a.supported.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),i=this._canvas.getContext("webgl2",t);i?(U(i,!0),this.painter=new Qs(i,this._contextCreateOptions,this.transform,this._scaleFactor,this._tp),this.on("data",(e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0)})),e.m.testSupport(i)):this.fire(new e.y(new Error("Failed to initialize WebGL")))}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new e.z("webglcontextlost",{originalEvent:t}))}_contextRestored(t){this._setupPainter(),this.resize(),this._update(),this.fire(new e.z("webglcontextrestored",{originalEvent:t}))}_onMapScroll(e){if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}idle(){return!this.isMoving()&&this.loaded()}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}frameReady(){return this.loaded()&&!this._placementDirty}_update(e){return this.style?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_requestDomTask(e){!this.loaded()||this.loaded()&&!this.isMoving()?e():this._domRenderTaskQueue.add(e)}_render(t){let n;this.fire(new e.z("renderstart")),++this._frameId;const o=this.painter.context.extTimerQuery,s=e.q.now(),a=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(n=a.createQuery(),a.beginQuery(o.TIME_ELAPSED_EXT,n)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],performance.now())),this._renderTaskQueue.run(t),this._domRenderTaskQueue.run(t),this._removed)return;this._updateProjectionTransition();const l=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,i=this.transform.pitch,r=e.q.now(),n=new e.a8(t,{now:r,fadeDuration:l,pitch:i,transition:this.style.transition});this.style.update(n)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let c=!1;this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),c=this._updateAverageElevation(s),this.style.updateSources(this.transform),this._forceMarkerAndPopupUpdate()):c=this._updateAverageElevation(s);const h=this.style&&this.style._updatePlacement(this.painter,this.painter.transform,this.showCollisionBoxes,l,this._crossSourceCollisions,this.painter.replacementSource,this._scaleFactorChanged);if(this._scaleFactorChanged&&(this._scaleFactorChanged=!1),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.z("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,r.mark(i.load),this.fire(new e.z("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&(this.style.snow||this.style.rain)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),n){const t=e.q.now()-s;a.endQuery(o.TIME_ELAPSED_EXT),setTimeout((()=>{const i=a.getQueryParameter(n,a.QUERY_RESULT)/1e6;a.deleteQuery(n),this.fire(new e.z("gpu-timing-frame",{cpuTime:t,gpuTime:i}))}),50)}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout((()=>{const i=this.painter.queryGpuTimers(t);this.fire(new e.z("gpu-timing-layer",{layerTimes:i}))}),50)}if(this.listens("gpu-timing-deferred-render")){const t=this.painter.collectDeferredRenderGpuQueries();setTimeout((()=>{const i=this.painter.queryGpuTimeDeferredRender(t);this.fire(new e.z("gpu-timing-deferred-render",{gpuTime:i}))}),50)}const u=this._sourcesDirty||this._styleDirty||this._placementDirty||c;if(u||this._repaint)this.triggerRepaint();else{const t=this.idle();if(t&&(c=this._updateAverageElevation(s,!0)),c)this.triggerRepaint();else if(this._triggerFrame(!1),t&&(this.fire(new e.z("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new e.z("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||u||(this._fullyLoaded=!0,r.mark(i.fullLoad),this._performanceMetricsCollection&&F(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate())}_forceMarkerAndPopupUpdate(e){for(const t of this._markers)e&&!this.getRenderWorldCopies()&&(t._lngLat=t._lngLat.wrap()),t._update();for(const t of this._popups)!e||this.getRenderWorldCopies()||t._trackPointer||(t._lngLat=t._lngLat.wrap()),t._update()}_updateAverageElevation(e,t=!1){const i=e=>(this.transform.averageElevation=e,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&i(0);const r=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(r||(t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let n=this.transform.sampleAverageElevation();null!=this.transform.elevation&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(n)?n=0:this._averageElevationLastSampledAt=e;const o=Math.abs(t-n);if(o>1){if(this._isInitialLoad||r)return this._averageElevation.jumpTo(n),i(n);this._averageElevation.easeTo(n,e,300)}else if(o>1e-4)return this._averageElevation.jumpTo(n),i(n)}return!!this._averageElevation.isEasing(e)&&i(this._averageElevation.getValue(e))}_authenticate(){N(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(t=>{if(t&&(t.message===w||401===t.status)){const t=this.painter.context.gl;U(t,!1),this._logoControl instanceof tl&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new e.y(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}})),R(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,r=i.createFramebuffer();function n(e){i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0);const t=new Uint8Array(i.drawingBufferWidth*i.drawingBufferHeight*4);return i.readPixels(0,0,i.drawingBufferWidth,i.drawingBufferHeight,i.RGBA,i.UNSIGNED_BYTE,t),t}return i.bindFramebuffer(i.FRAMEBUFFER,r),this._canvasPixelComparison(n(e),t.canvasCopies.map(n),t.timeStamps)}_canvasPixelComparison(e,t,i){let r=i[1]-i[0];const n=e.length/4;for(let o=0;o<t.length;o++){const s=t[o];let a=0;for(let t=0;t<s.length;t+=4)s[t]===e[t]&&s[t+1]===e[t+1]&&s[t+2]===e[t+2]&&s[t+3]===e[t+3]&&(a+=1);r+=(i[o+2]-i[o+1])*(1-a/n)}return r}remove(){this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this._domRenderTaskQueue.clear(),this.style&&this.style.destroy(),this.indoor.destroy(),this.painter.destroy(),this.handlers&&this.handlers.destroy(),this.handlers=void 0,this.setStyle(null),window.removeEventListener("resize",this._onWindowResize,!1),window.removeEventListener("orientationchange",this._onWindowResize,!1),window.removeEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.removeEventListener("online",this._onWindowOnline,!1),window.removeEventListener("visibilitychange",this._onVisibilityChange,!1);const t=this.painter.context.gl.getExtension("WEBGL_lose_context");t&&t.loseContext(),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvasContainer.remove(),this._controlContainer.remove(),this._missingCSSCanary.remove(),this._canvas=void 0,this._canvasContainer=void 0,this._controlContainer=void 0,this._missingCSSCanary=void 0,this._container.classList.remove("mapboxgl-map"),this._container.removeEventListener("scroll",this._onMapScroll,!1),V.delete(this.painter.context.gl),B.remove(),D.remove(),this._removed=!0,this.fire(new e.z("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(t){this._renderNextFrame=this._renderNextFrame||t,this.style&&!this._frame&&(this._frame=e.q.frame((e=>{const t=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,t&&this._render(e)})))}_preloadTiles(t){const i=this.style?this.style.getSourceCaches():[];return e.bl(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.dG(t,i)}get version(){return t}},NavigationControl:class{constructor(t={}){this.options=e.l({},hl,t),this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(e.aP(["_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.aP(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",(e=>{const t=this._map;t&&(this.options.visualizePitch?t.resetNorthPitch({},{originalEvent:e}):t.resetNorth({},{originalEvent:e}))})),this._compassIcon=l("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const e=this._map;if(!e)return;const t=e.getZoom(),i=t===e.getMaxZoom(),r=t===e.getMinZoom();this._zoomInButton.disabled=i,this._zoomOutButton.disabled=r,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",r.toString())}_rotateCompassArrow(){const e=this._map;if(!e)return;const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(e.transform.pitch*(Math.PI/180)),.5)}) rotateX(${e.transform.pitch}deg) rotateZ(${e.transform.angle*(180/Math.PI)}deg)`:`rotate(${e.transform.angle*(180/Math.PI)}deg)`;e._requestDomTask((()=>{this._compassIcon&&(this._compassIcon.style.transform=t)}))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),e.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&e.on("pitch",this._rotateCompassArrow),e.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new ul(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},ml,t),e.aP(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=ea(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.longitude<t.getWest()||i.longitude>t.getEast()||i.latitude<t.getSouth()||i.latitude>t.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(t){if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.z("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(t),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(t),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new e.z("geolocate",t)),this._finish()}}_updateCamera(t){const i=new e.bO(t.coords.longitude,t.coords.latitude),r=t.coords.accuracy,n=this._map.getBearing(),o=e.l({bearing:n},this.options.fitBoundsOptions);this._map.fitBounds(i.toBounds(r),o,{geolocateSource:!0})}_updateMarker(t){if(t){const i=new e.bO(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.bH(1,t._center.lat)*t.worldSize,r=Math.ceil(2*this._accuracy*i);this._circleElement.style.width=`${r}px`,this._circleElement.style.height=`${r}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._userLocationDotMarker.addClassName("mapboxgl-user-location-show-heading")):(this._userLocationDotMarker.removeClassName("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(t){if(this._map){if(this.options.trackUserLocation)if(1===t.code){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===t.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new e.z("error",t)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(t){if(void 0!==this._map){if(this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this._geolocateButton=l("button","mapboxgl-ctrl-geolocate",this._container),l("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===t){e.w("Geolocation support is not available so the GeolocateControl will be disabled.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=l("div","mapboxgl-user-location"),this._dotElement.appendChild(l("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(l("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new fl({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=l("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new fl({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new e.z("trackuserlocationend")))}))}}_onDeviceOrientation(e){this._userLocationDotMarker&&(e.webkitCompassHeading?this._heading=e.webkitCompassHeading:!0===e.absolute&&(this._heading=-1*e.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return e.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new e.z("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new e.z("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new e.z("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(e={maximumAge:6e5,timeout:0},this._noTimeout=!0):(e=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,e),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=window.setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const e=()=>{"ondeviceorientationabsolute"in window?window.addEventListener("deviceorientationabsolute",this._onDeviceOrientation):window.addEventListener("deviceorientation",this._onDeviceOrientation)};"undefined"!=typeof DeviceMotionEvent&&"function"==typeof DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((t=>{"granted"===t&&e()})).catch(console.error):e()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),window.removeEventListener("deviceorientation",this._onDeviceOrientation),window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:el,ScaleControl:class{constructor(t={}){this.options=e.l({},_l,t),this._isNumberFormatSupported=function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"short",unit:"meter"}),!0}catch(e){return!1}}(),e.aP(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const e=this.options.maxWidth||100,t=this._map,i=t._containerHeight/2,r=t._containerWidth/2-e/2,n=t.unproject([r,i]),o=t.unproject([r+e,i]),s=n.distanceTo(o);if("imperial"===this.options.unit){const t=3.2808*s;t>5280?this._setScale(e,t/5280,"mile"):this._setScale(e,t,"foot")}else"nautical"===this.options.unit?this._setScale(e,s/1852,"nautical-mile"):s>=1e3?this._setScale(e,s/1e3,"kilometer"):this._setScale(e,s,"meter")}_setScale(e,t,i){this._map._requestDomTask((()=>{const r=function(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(i),t*i}(t),n=r/t;this._container.innerHTML=this._isNumberFormatSupported&&"nautical-mile"!==i?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:i}).format(r):`${r}&nbsp;${gl[i]}`,this._container.style.width=e*n+"px"}))}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-scale",e.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(e){this._language=e,this._update()}setUnit(e){this.options.unit=e,this._update()}},FullscreenControl:class{constructor(t={}){this._fullscreen=!1,t&&t.container&&(t.container instanceof HTMLElement?this._container=t.container:e.w("Full screen control 'container' must be a DOM element.")),e.aP(["_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(yl),t),e.aP(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(t&&t.className?t.className.trim().split(/\s+/):[])}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&t.on("preclick",this._onClose),this.options.closeOnMove&&t.on("move",this._onClose),t.on("remove",this.remove),this._update(),t._addPopup(this),this._focusFirstElement(),this._trackPointer?(t.on("mousemove",this._onMouseEvent),t.on("mouseup",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")):t.on("move",this._update),this.fire(new e.z("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const t=this._map;return t&&(t.off("move",this._update),t.off("move",this._onClose),t.off("preclick",this._onClose),t.off("click",this._onClose),t.off("remove",this.remove),t.off("mousemove",this._onMouseEvent),t.off("mouseup",this._onMouseEvent),t.off("drag",this._onMouseEvent),t._canvasContainer&&t._canvasContainer.classList.remove("mapboxgl-track-pointer"),t._removePopup(this),this._map=void 0),this.fire(new e.z("close")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=e.bO.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 r;for(i.innerHTML=e;r=i.firstChild,r;)t.appendChild(r);return this.setDOMContent(t)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){let t=this._content;if(t)for(;t.hasChildNodes();)t.firstChild&&t.removeChild(t.firstChild);else t=this._content=l("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=l("button","mapboxgl-popup-close-button",t);e.type="button",e.setAttribute("aria-label","Close popup"),e.setAttribute("aria-hidden","true"),e.innerHTML="&#215;",e.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(e){return this._classList.add(e),this._updateClassList(),this}removeClassName(e){return this._classList.delete(e),this._updateClassList(),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){let t;return this._classList.delete(e)?t=!1:(this._classList.add(e),t=!0),this._updateClassList(),t}_onMouseEvent(e){this._update(e.point)}_getAnchor(e){if(this.options.anchor)return this.options.anchor;const t=this._map,i=this._container,r=this._pos;if(!t||!i||!r)return"bottom";const n=i.offsetWidth,o=i.offsetHeight,s=r.x<n/2,a=r.x>t.transform.width-n/2;if(r.y+e<o)return s?"top-left":a?"top-right":"top";if(r.y>t.transform.height-o){if(s)return"bottom-left";if(a)return"bottom-right"}return s?"left":a?"right":"bottom"}_updateClassList(){const e=this._container;if(!e)return;const t=[...this._classList];t.push("mapboxgl-popup"),this._anchor&&t.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&t.push("mapboxgl-popup-track-pointer"),e.className=t.join(" ")}_update(t){const i=this._map,r=this._content;if(!i||!this._lngLat&&!this._trackPointer||!r)return;let n=this._container;if(n||(n=this._container=l("div","mapboxgl-popup",i.getContainer()),this._tip=l("div","mapboxgl-popup-tip",n),n.appendChild(r)),this.options.maxWidth&&n.style.maxWidth!==this.options.maxWidth&&(n.style.maxWidth=this.options.maxWidth),i.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=dl(this._lngLat,this._pos,i.transform)),!this._trackPointer||t){const r=this._pos=this._trackPointer&&t instanceof e.P?t:i.project(this._lngLat),n=vl(this.options.offset),o=this._anchor=this._getAnchor(n.y),s=vl(this.options.offset,o),a=r.add(s).round();i._requestDomTask((()=>{this._container&&o&&(this._container.style.transform=`${pl[o]} translate(${a.x}px,${a.y}px)`)}))}if(!this._marker&&i._showingGlobe()){const t=e.dH(i.transform,this._lngLat)?0:1;this._setOpacity(t)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(xl);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:fl,Style:Mr,LngLat:e.bO,LngLatBounds:e.az,Point:e.P,MercatorCoordinate:e.aa,FreeCameraOptions:Zi,Evented:e.E,config:e.e,prewarm:e.dM,clearPrewarmedResources:e.dN,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.dO.workerCount},set workerCount(t){e.dO.workerCount=t},get maxParallelImageRequests(){return e.e.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){e.e.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(t){e.dP(t)},get workerUrl(){return e.dQ.workerUrl},set workerUrl(t){e.dQ.workerUrl=t},get workerClass(){return e.dQ.workerClass},set workerClass(t){e.dQ.workerClass=t},get workerParams(){return e.dQ.workerParams},set workerParams(t){e.dQ.workerParams=t},get dracoUrl(){return e.dR()},set dracoUrl(t){e.dS(t)},get meshoptUrl(){return e.dT()},set meshoptUrl(t){e.dU(t)},setNow:e.q.setNow,restoreNow:e.q.restoreNow};return bl})),i}()}}]);