@mapcreator/sdk 0.0.0-opacity.0

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.
Files changed (70) hide show
  1. package/README.md +29 -0
  2. package/dist/HighlightManager.d.ts +23 -0
  3. package/dist/MCMap.d.ts +26 -0
  4. package/dist/PopupManager.d.ts +44 -0
  5. package/dist/Registry.d.ts +23 -0
  6. package/dist/Video.d.ts +42 -0
  7. package/dist/adornments/categoricalLegend.d.ts +2 -0
  8. package/dist/adornments/connectedLegend.d.ts +3 -0
  9. package/dist/adornments/copyright.d.ts +3 -0
  10. package/dist/adornments/customAdornment.d.ts +2 -0
  11. package/dist/adornments/heading.d.ts +2 -0
  12. package/dist/adornments/insetMap.d.ts +3 -0
  13. package/dist/adornments/manualLegend.d.ts +2 -0
  14. package/dist/adornments/northArrow.d.ts +3 -0
  15. package/dist/adornments/scalebar.d.ts +3 -0
  16. package/dist/constants/index.d.ts +18 -0
  17. package/dist/controls/controls.d.ts +7 -0
  18. package/dist/controls/fullscreenControls.d.ts +2 -0
  19. package/dist/controls/geocoderControl.d.ts +33 -0
  20. package/dist/controls/geolocationControls.d.ts +2 -0
  21. package/dist/controls/refreshMapControls.d.ts +3 -0
  22. package/dist/controls/webControls.d.ts +4 -0
  23. package/dist/controls/zoomControls.d.ts +3 -0
  24. package/dist/favicon-32x32.png +0 -0
  25. package/dist/i18n.d.ts +56 -0
  26. package/dist/index.d.ts +4 -0
  27. package/dist/initMap.d.ts +9 -0
  28. package/dist/locales/da_DK/strings.json.d.ts +10 -0
  29. package/dist/locales/de_DE/strings.json.d.ts +10 -0
  30. package/dist/locales/en_GB/strings.json.d.ts +10 -0
  31. package/dist/locales/es_ES/strings.json.d.ts +10 -0
  32. package/dist/locales/fr_FR/strings.json.d.ts +10 -0
  33. package/dist/locales/it_IT/strings.json.d.ts +10 -0
  34. package/dist/locales/nl_NL/strings.json.d.ts +10 -0
  35. package/dist/mapcreator-sdk.css +2 -0
  36. package/dist/mapcreator-sdk.js +40511 -0
  37. package/dist/mapcreator-sdk.umd.cjs +1178 -0
  38. package/dist/models/area.d.ts +5 -0
  39. package/dist/models/circle.d.ts +7 -0
  40. package/dist/models/dot.d.ts +3 -0
  41. package/dist/models/line.d.ts +6 -0
  42. package/dist/models/marker.d.ts +7 -0
  43. package/dist/models/polygon.d.ts +5 -0
  44. package/dist/renderAdornments.d.ts +4 -0
  45. package/dist/report.html +4950 -0
  46. package/dist/types/geometry.d.ts +10 -0
  47. package/dist/types/index.d.ts +28 -0
  48. package/dist/types/jobObject.d.ts +515 -0
  49. package/dist/types/mapstyle.d.ts +62 -0
  50. package/dist/types/video.d.ts +13 -0
  51. package/dist/utils/browser.d.ts +2 -0
  52. package/dist/utils/choropleth.d.ts +12 -0
  53. package/dist/utils/fullscreen.d.ts +4 -0
  54. package/dist/utils/geolocation.d.ts +6 -0
  55. package/dist/utils/graphhopper.d.ts +6 -0
  56. package/dist/utils/helpers.d.ts +30 -0
  57. package/dist/utils/language.d.ts +19 -0
  58. package/dist/utils/lineSlicer.d.ts +9 -0
  59. package/dist/utils/models.d.ts +16 -0
  60. package/dist/utils/overlays.d.ts +4 -0
  61. package/dist/utils/scalebar.d.ts +2 -0
  62. package/dist/utils/svgHelpers.d.ts +91 -0
  63. package/dist/utils/template.d.ts +5 -0
  64. package/dist/utils/video/animations.d.ts +4 -0
  65. package/dist/utils/video/cameraCurve.d.ts +39 -0
  66. package/dist/utils/video/easings.d.ts +31 -0
  67. package/dist/utils/video/index.d.ts +11 -0
  68. package/dist/utils/video/monotonicCurve.d.ts +23 -0
  69. package/dist/utils/youtube.d.ts +4 -0
  70. package/package.json +78 -0
@@ -0,0 +1,1178 @@
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.MC={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),c=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==a&&n(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},l=(e,r,i)=>(i=e==null?{}:t(a(e)),c(r||!e||!e.__esModule?n(i,`default`,{value:e,enumerable:!0}):i,e)),u=s(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self,n.maplibregl=r())})(e,(function(){"use strict";var e={},t={};function n(n,r,i){if(t[n]=i,n===`index`){var a=`var sharedModule = {}; (`+t.shared+`)(sharedModule); (`+t.worker+`)(sharedModule);`,o={};return t.shared(o),t.index(e,o),typeof window<`u`&&e.setWorkerUrl(window.URL.createObjectURL(new Blob([a],{type:`text/javascript`}))),e}}return n(`shared`,[`exports`],(function(e){function t(e,t,n,r){return new(n||=Promise)((function(i,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((r=r.apply(e,t||[])).next())}))}function n(e,t){this.x=e,this.y=t}function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var i,a;n.prototype={clone(){return new n(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){let t=e.x-this.x,n=e.y-this.y;return t*t+n*n},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){let t=e[2]*this.x+e[3]*this.y;return this.x=e[0]*this.x+e[1]*this.y,this.y=t,this},_add(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){let e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){let t=Math.cos(e),n=Math.sin(e),r=n*this.x+t*this.y;return this.x=t*this.x-n*this.y,this.y=r,this},_rotateAround(e,t){let n=Math.cos(e),r=Math.sin(e),i=t.y+r*(this.x-t.x)+n*(this.y-t.y);return this.x=t.x+n*(this.x-t.x)-r*(this.y-t.y),this.y=i,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:n},n.convert=function(e){if(e instanceof n)return e;if(Array.isArray(e))return new n(+e[0],+e[1]);if(e.x!==void 0&&e.y!==void 0)return new n(+e.x,+e.y);throw Error(`Expected [x, y] or {x, y} point format`)};var o=r(function(){if(a)return i;function e(e,t,n,r){this.cx=3*e,this.bx=3*(n-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=n,this.p2y=r}return a=1,i=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(t===void 0&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var n=e,r=0;r<8;r++){var i=this.sampleCurveX(n)-e;if(Math.abs(i)<t)return n;var a=this.sampleCurveDerivativeX(n);if(Math.abs(a)<1e-6)break;n-=i/a}var o=0,s=1;for(n=e,r=0;r<20&&(i=this.sampleCurveX(n),!(Math.abs(i-e)<t));r++)e>i?o=n:s=n,n=.5*(s-o)+o;return n},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},i}());let s,c;function l(){return s??=typeof OffscreenCanvas<`u`&&new OffscreenCanvas(1,1).getContext(`2d`)&&typeof createImageBitmap==`function`,s}function u(){if(c==null&&(c=!1,l())){let e=new OffscreenCanvas(5,5).getContext(`2d`,{willReadFrequently:!0});if(e){for(let t=0;t<25;t++){let n=4*t;e.fillStyle=`rgb(${n},${n+1},${n+2})`,e.fillRect(t%5,Math.floor(t/5),1,1)}let t=e.getImageData(0,0,5,5).data;for(let e=0;e<100;e++)if(e%4!=3&&t[e]!==e){c=!0;break}}}return c||!1}var d=1e-6,f=typeof Float32Array<`u`?Float32Array:Array;function p(){var e=new f(9);return f!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function m(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 h(){var e=new f(3);return f!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function g(e){var t=e[0],n=e[1],r=e[2];return Math.sqrt(t*t+n*n+r*r)}function _(e,t,n){var r=new f(3);return r[0]=e,r[1]=t,r[2]=n,r}function v(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e}function y(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e}function b(e,t,n){var r=t[0],i=t[1],a=t[2],o=n[0],s=n[1],c=n[2];return e[0]=i*c-a*s,e[1]=a*o-r*c,e[2]=r*s-i*o,e}var x,S=g;function C(e,t,n){var r=t[0],i=t[1],a=t[2],o=t[3];return e[0]=n[0]*r+n[4]*i+n[8]*a+n[12]*o,e[1]=n[1]*r+n[5]*i+n[9]*a+n[13]*o,e[2]=n[2]*r+n[6]*i+n[10]*a+n[14]*o,e[3]=n[3]*r+n[7]*i+n[11]*a+n[15]*o,e}function w(){var e=new f(4);return f!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function T(e,t,n,r){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:`zyx`,a=Math.PI/360;t*=a,r*=a,n*=a;var o=Math.sin(t),s=Math.cos(t),c=Math.sin(n),l=Math.cos(n),u=Math.sin(r),d=Math.cos(r);switch(i){case`xyz`:e[0]=o*l*d+s*c*u,e[1]=s*c*d-o*l*u,e[2]=s*l*u+o*c*d,e[3]=s*l*d-o*c*u;break;case`xzy`:e[0]=o*l*d-s*c*u,e[1]=s*c*d-o*l*u,e[2]=s*l*u+o*c*d,e[3]=s*l*d+o*c*u;break;case`yxz`:e[0]=o*l*d+s*c*u,e[1]=s*c*d-o*l*u,e[2]=s*l*u-o*c*d,e[3]=s*l*d+o*c*u;break;case`yzx`:e[0]=o*l*d+s*c*u,e[1]=s*c*d+o*l*u,e[2]=s*l*u-o*c*d,e[3]=s*l*d-o*c*u;break;case`zxy`:e[0]=o*l*d-s*c*u,e[1]=s*c*d+o*l*u,e[2]=s*l*u+o*c*d,e[3]=s*l*d-o*c*u;break;case`zyx`:e[0]=o*l*d-s*c*u,e[1]=s*c*d+o*l*u,e[2]=s*l*u-o*c*d,e[3]=s*l*d+o*c*u;break;default:throw Error(`Unknown angle order `+i)}return e}function E(){var e=new f(2);return f!=Float32Array&&(e[0]=0,e[1]=0),e}function D(e,t){var n=new f(2);return n[0]=e,n[1]=t,n}h(),x=new f(4),f!=Float32Array&&(x[0]=0,x[1]=0,x[2]=0,x[3]=0),h(),_(1,0,0),_(0,1,0),w(),w(),p(),E();let O=8192;function k(e,t,n,r){return t*(O/(e.tileSize*2**(n-e.tileID.overscaledZ)))*2**r}function A(e,t){return(e%t+t)%t}function j(e,t,n){return e*(1-n)+t*n}function M(e){if(e<=0)return 0;if(e>=1)return 1;let t=e*e,n=t*e;return 4*(e<.5?n:3*(e-t)+n-.75)}function N(e,t,n,r){let i=new o(e,t,n,r);return e=>i.solve(e)}let P=N(.25,.1,.25,1);function ee(e,t,n){return Math.min(n,Math.max(t,e))}function te(e,t,n){let r=n-t,i=((e-t)%r+r)%r+t;return i===t?n:i}function F(e,...t){for(let n of t)for(let t in n)e[t]=n[t];return e}let ne=1;function re(e,t,n){let r={};for(let n in e)r[n]=t.call(this,e[n],n,e);return r}function ie(e,t,n){let r={};for(let n in e)t.call(this,e[n],n,e)&&(r[n]=e[n]);return r}function ae(e){return Array.isArray(e)?e.map(ae):typeof e==`object`&&e?re(e,ae):e}let oe={};function se(e){oe[e]||(typeof console<`u`&&console.warn(e),oe[e]=!0)}function ce(e,t,n){return(n.y-e.y)*(t.x-e.x)>(t.y-e.y)*(n.x-e.x)}function le(e){return typeof WorkerGlobalScope<`u`&&e!==void 0&&e instanceof WorkerGlobalScope}let ue=null;function de(e){return typeof ImageBitmap<`u`&&e instanceof ImageBitmap}let fe=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=`;function pe(e,n,r,i,a){return t(this,void 0,void 0,(function*(){if(typeof VideoFrame>`u`)throw Error(`VideoFrame not supported`);let t=new VideoFrame(e,{timestamp:0});try{let o=t?.format;if(!o||!o.startsWith(`BGR`)&&!o.startsWith(`RGB`))throw Error(`Unrecognized format ${o}`);let s=o.startsWith(`BGR`),c=new Uint8ClampedArray(i*a*4);if(yield t.copyTo(c,function(e,t,n,r,i){let a=4*Math.max(-t,0),o=(Math.max(0,n)-n)*r*4+a,s=4*r,c=Math.max(0,t),l=Math.max(0,n);return{rect:{x:c,y:l,width:Math.min(e.width,t+r)-c,height:Math.min(e.height,n+i)-l},layout:[{offset:o,stride:s}]}}(e,n,r,i,a)),s)for(let e=0;e<c.length;e+=4){let t=c[e];c[e]=c[e+2],c[e+2]=t}return c}finally{t.close()}}))}let me,he;function ge(e,t,n,r){return e.addEventListener(t,n,r),{unsubscribe:()=>{e.removeEventListener(t,n,r)}}}function _e(e){return e*Math.PI/180}function ve(e){return e/Math.PI*180}let ye={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},be={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},xe=`AbortError`;function Se(){return Error(xe)}let Ce={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:``};function we(e){return Ce.REGISTERED_PROTOCOLS[e.substring(0,e.indexOf(`://`))]}let Te=`global-dispatcher`;class Ee extends Error{constructor(e,t,n,r){super(`AJAXError: ${t} (${e}): ${n}`),this.status=e,this.statusText=t,this.url=n,this.body=r}}let De=()=>le(self)?self.worker&&self.worker.referrer:(window.location.protocol===`blob:`?window.parent:window).location.href,Oe=function(e,n){if(/:\/\//.test(e.url)&&!/^https?:|^file:/.test(e.url)){let t=we(e.url);if(t)return t(e,n);if(le(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:`GR`,data:e,targetMapId:Te},n)}if(!(/^file:/.test(r=e.url)||/^file:/.test(De())&&!/^\w+:/.test(r))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,`signal`))return function(e,n){return t(this,void 0,void 0,(function*(){let t=new Request(e.url,{method:e.method||`GET`,body:e.body,credentials:e.credentials,headers:e.headers,cache:e.cache,referrer:De(),signal:n.signal}),r,i;e.type!==`json`||t.headers.has(`Accept`)||t.headers.set(`Accept`,`application/json`);try{r=yield fetch(t)}catch(t){throw new Ee(0,t.message,e.url,new Blob)}if(!r.ok){let t=yield r.blob();throw new Ee(r.status,r.statusText,e.url,t)}i=e.type===`arrayBuffer`||e.type===`image`?r.arrayBuffer():e.type===`json`?r.json():r.text();let a=yield i;if(n.signal.aborted)throw Se();return{data:a,cacheControl:r.headers.get(`Cache-Control`),expires:r.headers.get(`Expires`)}}))}(e,n);if(le(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:`GR`,data:e,mustQueue:!0,targetMapId:Te},n)}var r;return function(e,t){return new Promise(((n,r)=>{var i;let a=new XMLHttpRequest;a.open(e.method||`GET`,e.url,!0),e.type!==`arrayBuffer`&&e.type!==`image`||(a.responseType=`arraybuffer`);for(let t in e.headers)a.setRequestHeader(t,e.headers[t]);e.type===`json`&&(a.responseType=`text`,(i=e.headers)!=null&&i.Accept||a.setRequestHeader(`Accept`,`application/json`)),a.withCredentials=e.credentials===`include`,a.onerror=()=>{r(Error(a.statusText))},a.onload=()=>{if(!t.signal.aborted)if((a.status>=200&&a.status<300||a.status===0)&&a.response!==null){let t=a.response;if(e.type===`json`)try{t=JSON.parse(a.response)}catch(e){r(e);return}n({data:t,cacheControl:a.getResponseHeader(`Cache-Control`),expires:a.getResponseHeader(`Expires`)})}else{let t=new Blob([a.response],{type:a.getResponseHeader(`Content-Type`)});r(new Ee(a.status,a.statusText,e.url,t))}},t.signal.addEventListener(`abort`,(()=>{a.abort(),r(Se())})),a.send(e.body)}))}(e,n)};function ke(e){if(!e||e.indexOf(`://`)<=0||e.indexOf(`data:image/`)===0||e.indexOf(`blob:`)===0)return!0;let t=new URL(e),n=window.location;return t.protocol===n.protocol&&t.host===n.host}function Ae(e,t,n){n[e]&&n[e].indexOf(t)!==-1||(n[e]=n[e]||[],n[e].push(t))}function je(e,t,n){if(n&&n[e]){let r=n[e].indexOf(t);r!==-1&&n[e].splice(r,1)}}class Me{constructor(e,t={}){F(this,t),this.type=e}}class Ne extends Me{constructor(e,t={}){super(`error`,F({error:e},t))}}class Pe{on(e,t){return this._listeners=this._listeners||{},Ae(e,t,this._listeners),{unsubscribe:()=>{this.off(e,t)}}}off(e,t){return je(e,t,this._listeners),je(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},Ae(e,t,this._oneTimeListeners),this):new Promise((t=>this.once(e,t)))}fire(e,t){typeof e==`string`&&(e=new Me(e,t||{}));let n=e.type;if(this.listens(n)){e.target=this;let t=this._listeners&&this._listeners[n]?this._listeners[n].slice():[];for(let n of t)n.call(this,e);let r=this._oneTimeListeners&&this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];for(let t of r)je(n,t,this._oneTimeListeners),t.call(this,e);let i=this._eventedParent;i&&(F(e,typeof this._eventedParentData==`function`?this._eventedParentData():this._eventedParentData),i.fire(e))}else e instanceof Ne&&console.error(e.error);return this}listens(e){return this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e)}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}}var I={$version:8,$root:{version:{required:!0,type:`enum`,values:[8]},name:{type:`string`},metadata:{type:`*`},center:{type:`array`,value:`number`},centerAltitude:{type:`number`},zoom:{type:`number`},bearing:{type:`number`,default:0,period:360,units:`degrees`},pitch:{type:`number`,default:0,units:`degrees`},roll:{type:`number`,default:0,units:`degrees`},state:{type:`state`,default:{}},light:{type:`light`},sky:{type:`sky`},projection:{type:`projection`},terrain:{type:`terrain`},sources:{required:!0,type:`sources`},sprite:{type:`sprite`},glyphs:{type:`string`},transition:{type:`transition`},layers:{required:!0,type:`array`,value:`layer`}},sources:{"*":{type:`source`}},source:[`source_vector`,`source_raster`,`source_raster_dem`,`source_geojson`,`source_video`,`source_image`],source_vector:{type:{required:!0,type:`enum`,values:{vector:{}}},url:{type:`string`},tiles:{type:`array`,value:`string`},bounds:{type:`array`,value:`number`,length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:`enum`,values:{xyz:{},tms:{}},default:`xyz`},minzoom:{type:`number`,default:0},maxzoom:{type:`number`,default:22},attribution:{type:`string`},promoteId:{type:`promoteId`},volatile:{type:`boolean`,default:!1},"*":{type:`*`}},source_raster:{type:{required:!0,type:`enum`,values:{raster:{}}},url:{type:`string`},tiles:{type:`array`,value:`string`},bounds:{type:`array`,value:`number`,length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:`number`,default:0},maxzoom:{type:`number`,default:22},tileSize:{type:`number`,default:512,units:`pixels`},scheme:{type:`enum`,values:{xyz:{},tms:{}},default:`xyz`},attribution:{type:`string`},volatile:{type:`boolean`,default:!1},"*":{type:`*`}},source_raster_dem:{type:{required:!0,type:`enum`,values:{"raster-dem":{}}},url:{type:`string`},tiles:{type:`array`,value:`string`},bounds:{type:`array`,value:`number`,length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:`number`,default:0},maxzoom:{type:`number`,default:22},tileSize:{type:`number`,default:512,units:`pixels`},attribution:{type:`string`},encoding:{type:`enum`,values:{terrarium:{},mapbox:{},custom:{}},default:`mapbox`},redFactor:{type:`number`,default:1},blueFactor:{type:`number`,default:1},greenFactor:{type:`number`,default:1},baseShift:{type:`number`,default:0},volatile:{type:`boolean`,default:!1},"*":{type:`*`}},source_geojson:{type:{required:!0,type:`enum`,values:{geojson:{}}},data:{required:!0,type:`*`},maxzoom:{type:`number`,default:18},attribution:{type:`string`},buffer:{type:`number`,default:128,maximum:512,minimum:0},filter:{type:`*`},tolerance:{type:`number`,default:.375},cluster:{type:`boolean`,default:!1},clusterRadius:{type:`number`,default:50,minimum:0},clusterMaxZoom:{type:`number`},clusterMinPoints:{type:`number`},clusterProperties:{type:`*`},lineMetrics:{type:`boolean`,default:!1},generateId:{type:`boolean`,default:!1},promoteId:{type:`promoteId`}},source_video:{type:{required:!0,type:`enum`,values:{video:{}}},urls:{required:!0,type:`array`,value:`string`},coordinates:{required:!0,type:`array`,length:4,value:{type:`array`,length:2,value:`number`}}},source_image:{type:{required:!0,type:`enum`,values:{image:{}}},url:{required:!0,type:`string`},coordinates:{required:!0,type:`array`,length:4,value:{type:`array`,length:2,value:`number`}}},layer:{id:{type:`string`,required:!0},type:{type:`enum`,values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},metadata:{type:`*`},source:{type:`string`},"source-layer":{type:`string`},minzoom:{type:`number`,minimum:0,maximum:24},maxzoom:{type:`number`,minimum:0,maximum:24},filter:{type:`filter`},layout:{type:`layout`},paint:{type:`paint`}},layout:[`layout_fill`,`layout_line`,`layout_circle`,`layout_heatmap`,`layout_fill-extrusion`,`layout_symbol`,`layout_raster`,`layout_hillshade`,`layout_color-relief`,`layout_background`],layout_background:{visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,"property-type":`constant`}},layout_fill:{"fill-sort-key":{type:`number`,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,"property-type":`constant`}},layout_circle:{"circle-sort-key":{type:`number`,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,"property-type":`constant`}},layout_heatmap:{visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,"property-type":`constant`}},"layout_fill-extrusion":{visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,"property-type":`constant`}},layout_line:{"line-cap":{type:`enum`,values:{butt:{},round:{},square:{}},default:`butt`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"line-join":{type:`enum`,values:{bevel:{},round:{},miter:{}},default:`miter`,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"line-miter-limit":{type:`number`,default:2,requires:[{"line-join":`miter`}],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"line-round-limit":{type:`number`,default:1.05,requires:[{"line-join":`round`}],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"line-sort-key":{type:`number`,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,"property-type":`constant`}},layout_symbol:{"symbol-placement":{type:`enum`,values:{point:{},line:{},"line-center":{}},default:`point`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"symbol-spacing":{type:`number`,default:250,minimum:1,units:`pixels`,requires:[{"symbol-placement":`line`}],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"symbol-avoid-edges":{type:`boolean`,default:!1,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"symbol-sort-key":{type:`number`,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"symbol-z-order":{type:`enum`,values:{auto:{},"viewport-y":{},source:{}},default:`auto`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"icon-allow-overlap":{type:`boolean`,default:!1,requires:[`icon-image`,{"!":`icon-overlap`}],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"icon-overlap":{type:`enum`,values:{never:{},always:{},cooperative:{}},requires:[`icon-image`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"icon-ignore-placement":{type:`boolean`,default:!1,requires:[`icon-image`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"icon-optional":{type:`boolean`,default:!1,requires:[`icon-image`,`text-field`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"icon-rotation-alignment":{type:`enum`,values:{map:{},viewport:{},auto:{}},default:`auto`,requires:[`icon-image`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"icon-size":{type:`number`,default:1,minimum:0,units:`factor of the original icon size`,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"icon-text-fit":{type:`enum`,values:{none:{},width:{},height:{},both:{}},default:`none`,requires:[`icon-image`,`text-field`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"icon-text-fit-padding":{type:`array`,value:`number`,length:4,default:[0,0,0,0],units:`pixels`,requires:[`icon-image`,`text-field`,{"icon-text-fit":[`both`,`width`,`height`]}],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"icon-image":{type:`resolvedImage`,tokens:!0,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"icon-rotate":{type:`number`,default:0,period:360,units:`degrees`,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"icon-padding":{type:`padding`,default:[2],units:`pixels`,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"icon-keep-upright":{type:`boolean`,default:!1,requires:[`icon-image`,{"icon-rotation-alignment":`map`},{"symbol-placement":[`line`,`line-center`]}],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"icon-offset":{type:`array`,value:`number`,length:2,default:[0,0],requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"icon-anchor":{type:`enum`,values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:`center`,requires:[`icon-image`],expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"icon-pitch-alignment":{type:`enum`,values:{map:{},viewport:{},auto:{}},default:`auto`,requires:[`icon-image`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-pitch-alignment":{type:`enum`,values:{map:{},viewport:{},auto:{}},default:`auto`,requires:[`text-field`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-rotation-alignment":{type:`enum`,values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:`auto`,requires:[`text-field`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-field":{type:`formatted`,default:``,tokens:!0,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-font":{type:`array`,value:`string`,default:[`Open Sans Regular`,`Arial Unicode MS Regular`],requires:[`text-field`],expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-size":{type:`number`,default:16,minimum:0,units:`pixels`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-max-width":{type:`number`,default:10,minimum:0,units:`ems`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-line-height":{type:`number`,default:1.2,units:`ems`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"text-letter-spacing":{type:`number`,default:0,units:`ems`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-justify":{type:`enum`,values:{auto:{},left:{},center:{},right:{}},default:`center`,requires:[`text-field`],expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-radial-offset":{type:`number`,units:`ems`,default:0,requires:[`text-field`],"property-type":`data-driven`,expression:{interpolated:!0,parameters:[`zoom`,`feature`]}},"text-variable-anchor":{type:`array`,value:`enum`,values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:[`text-field`,{"symbol-placement":[`point`]}],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-variable-anchor-offset":{type:`variableAnchorOffsetCollection`,requires:[`text-field`,{"symbol-placement":[`point`]}],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-anchor":{type:`enum`,values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:`center`,requires:[`text-field`,{"!":`text-variable-anchor`}],expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-max-angle":{type:`number`,default:45,units:`degrees`,requires:[`text-field`,{"symbol-placement":[`line`,`line-center`]}],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"text-writing-mode":{type:`array`,value:`enum`,values:{horizontal:{},vertical:{}},requires:[`text-field`,{"symbol-placement":[`point`]}],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-rotate":{type:`number`,default:0,period:360,units:`degrees`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-padding":{type:`number`,default:2,minimum:0,units:`pixels`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"text-keep-upright":{type:`boolean`,default:!0,requires:[`text-field`,{"text-rotation-alignment":`map`},{"symbol-placement":[`line`,`line-center`]}],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-transform":{type:`enum`,values:{none:{},uppercase:{},lowercase:{}},default:`none`,requires:[`text-field`],expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-offset":{type:`array`,value:`number`,units:`ems`,length:2,default:[0,0],requires:[`text-field`,{"!":`text-radial-offset`}],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-allow-overlap":{type:`boolean`,default:!1,requires:[`text-field`,{"!":`text-overlap`}],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-overlap":{type:`enum`,values:{never:{},always:{},cooperative:{}},requires:[`text-field`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-ignore-placement":{type:`boolean`,default:!1,requires:[`text-field`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-optional":{type:`boolean`,default:!1,requires:[`text-field`,`icon-image`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,"property-type":`constant`}},layout_raster:{visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,"property-type":`constant`}},layout_hillshade:{visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,"property-type":`constant`}},"layout_color-relief":{visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,"property-type":`constant`}},filter:{type:`array`,value:`*`},filter_operator:{type:`enum`,values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:`enum`,values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:`expression`},stops:{type:`array`,value:`function_stop`},base:{type:`number`,default:1,minimum:0},property:{type:`string`,default:`$zoom`},type:{type:`enum`,values:{identity:{},exponential:{},interval:{},categorical:{}},default:`exponential`},colorSpace:{type:`enum`,values:{rgb:{},lab:{},hcl:{}},default:`rgb`},default:{type:`*`,required:!1}},function_stop:{type:`array`,minimum:0,maximum:24,value:[`number`,`color`],length:2},expression:{type:`array`,value:`*`,minimum:1},light:{anchor:{type:`enum`,default:`viewport`,values:{map:{},viewport:{}},"property-type":`data-constant`,transition:!1,expression:{interpolated:!1,parameters:[`zoom`]}},position:{type:`array`,default:[1.15,210,30],length:3,value:`number`,"property-type":`data-constant`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]}},color:{type:`color`,"property-type":`data-constant`,default:`#ffffff`,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0},intensity:{type:`number`,"property-type":`data-constant`,default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0}},sky:{"sky-color":{type:`color`,"property-type":`data-constant`,default:`#88C6FC`,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0},"horizon-color":{type:`color`,"property-type":`data-constant`,default:`#ffffff`,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0},"fog-color":{type:`color`,"property-type":`data-constant`,default:`#ffffff`,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0},"fog-ground-blend":{type:`number`,"property-type":`data-constant`,default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0},"horizon-fog-blend":{type:`number`,"property-type":`data-constant`,default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0},"sky-horizon-blend":{type:`number`,"property-type":`data-constant`,default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0},"atmosphere-blend":{type:`number`,"property-type":`data-constant`,default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0}},terrain:{source:{type:`string`,required:!0},exaggeration:{type:`number`,minimum:0,default:1}},projection:{type:{type:`projectionDefinition`,default:`mercator`,"property-type":`data-constant`,transition:!1,expression:{interpolated:!0,parameters:[`zoom`]}}},paint:[`paint_fill`,`paint_line`,`paint_circle`,`paint_heatmap`,`paint_fill-extrusion`,`paint_symbol`,`paint_raster`,`paint_hillshade`,`paint_color-relief`,`paint_background`],paint_fill:{"fill-antialias":{type:`boolean`,default:!0,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"fill-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-color":{type:`color`,default:`#000000`,transition:!0,requires:[{"!":`fill-pattern`}],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-outline-color":{type:`color`,transition:!0,requires:[{"!":`fill-pattern`},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-translate":{type:`array`,value:`number`,length:2,default:[0,0],transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"fill-translate-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`map`,requires:[`fill-translate`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"fill-pattern":{type:`resolvedImage`,transition:!0,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`cross-faded-data-driven`}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"fill-extrusion-color":{type:`color`,default:`#000000`,transition:!0,requires:[{"!":`fill-extrusion-pattern`}],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-extrusion-translate":{type:`array`,value:`number`,length:2,default:[0,0],transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"fill-extrusion-translate-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`map`,requires:[`fill-extrusion-translate`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"fill-extrusion-pattern":{type:`resolvedImage`,transition:!0,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`cross-faded-data-driven`},"fill-extrusion-height":{type:`number`,default:0,minimum:0,units:`meters`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-extrusion-base":{type:`number`,default:0,minimum:0,units:`meters`,transition:!0,requires:[`fill-extrusion-height`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-extrusion-vertical-gradient":{type:`boolean`,default:!0,transition:!1,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`}},paint_line:{"line-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"line-color":{type:`color`,default:`#000000`,transition:!0,requires:[{"!":`line-pattern`}],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"line-translate":{type:`array`,value:`number`,length:2,default:[0,0],transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"line-translate-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`map`,requires:[`line-translate`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"line-width":{type:`number`,default:1,minimum:0,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"line-gap-width":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"line-offset":{type:`number`,default:0,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"line-blur":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"line-dasharray":{type:`array`,value:`number`,minimum:0,transition:!0,units:`line widths`,requires:[{"!":`line-pattern`}],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`cross-faded`},"line-pattern":{type:`resolvedImage`,transition:!0,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`cross-faded-data-driven`},"line-gradient":{type:`color`,transition:!1,requires:[{"!":`line-dasharray`},{"!":`line-pattern`},{source:`geojson`,has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:[`line-progress`]},"property-type":`color-ramp`}},paint_circle:{"circle-radius":{type:`number`,default:5,minimum:0,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"circle-color":{type:`color`,default:`#000000`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"circle-blur":{type:`number`,default:0,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"circle-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"circle-translate":{type:`array`,value:`number`,length:2,default:[0,0],transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"circle-translate-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`map`,requires:[`circle-translate`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"circle-pitch-scale":{type:`enum`,values:{map:{},viewport:{}},default:`map`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"circle-pitch-alignment":{type:`enum`,values:{map:{},viewport:{}},default:`viewport`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"circle-stroke-width":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"circle-stroke-color":{type:`color`,default:`#000000`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"circle-stroke-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`}},paint_heatmap:{"heatmap-radius":{type:`number`,default:30,minimum:1,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"heatmap-weight":{type:`number`,default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"heatmap-intensity":{type:`number`,default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"heatmap-color":{type:`color`,default:[`interpolate`,[`linear`],[`heatmap-density`],0,`rgba(0, 0, 255, 0)`,.1,`royalblue`,.3,`cyan`,.5,`lime`,.7,`yellow`,1,`red`],transition:!1,expression:{interpolated:!0,parameters:[`heatmap-density`]},"property-type":`color-ramp`},"heatmap-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`}},paint_symbol:{"icon-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"icon-color":{type:`color`,default:`#000000`,transition:!0,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"icon-halo-color":{type:`color`,default:`rgba(0, 0, 0, 0)`,transition:!0,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"icon-halo-width":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"icon-halo-blur":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"icon-translate":{type:`array`,value:`number`,length:2,default:[0,0],transition:!0,units:`pixels`,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"icon-translate-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`map`,requires:[`icon-image`,`icon-translate`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"text-color":{type:`color`,default:`#000000`,transition:!0,overridable:!0,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"text-halo-color":{type:`color`,default:`rgba(0, 0, 0, 0)`,transition:!0,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"text-halo-width":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"text-halo-blur":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"text-translate":{type:`array`,value:`number`,length:2,default:[0,0],transition:!0,units:`pixels`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"text-translate-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`map`,requires:[`text-field`,`text-translate`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`}},paint_raster:{"raster-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"raster-hue-rotate":{type:`number`,default:0,period:360,transition:!0,units:`degrees`,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"raster-brightness-min":{type:`number`,default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"raster-brightness-max":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"raster-saturation":{type:`number`,default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"raster-contrast":{type:`number`,default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"raster-resampling":{type:`enum`,values:{linear:{},nearest:{}},default:`linear`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"raster-fade-duration":{type:`number`,default:300,minimum:0,transition:!1,units:`milliseconds`,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`}},paint_hillshade:{"hillshade-illumination-direction":{type:`numberArray`,default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"hillshade-illumination-altitude":{type:`numberArray`,default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"hillshade-illumination-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`viewport`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"hillshade-exaggeration":{type:`number`,default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"hillshade-shadow-color":{type:`colorArray`,default:`#000000`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"hillshade-highlight-color":{type:`colorArray`,default:`#FFFFFF`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"hillshade-accent-color":{type:`color`,default:`#000000`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"hillshade-method":{type:`enum`,values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:`standard`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`}},"paint_color-relief":{"color-relief-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"color-relief-color":{type:`color`,transition:!1,expression:{interpolated:!0,parameters:[`elevation`]},"property-type":`color-ramp`}},paint_background:{"background-color":{type:`color`,default:`#000000`,transition:!0,requires:[{"!":`background-pattern`}],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"background-pattern":{type:`resolvedImage`,transition:!0,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`cross-faded`},"background-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`}},transition:{duration:{type:`number`,default:300,minimum:0,units:`milliseconds`},delay:{type:`number`,default:0,minimum:0,units:`milliseconds`}},"property-type":{"data-driven":{type:`property-type`},"cross-faded":{type:`property-type`},"cross-faded-data-driven":{type:`property-type`},"color-ramp":{type:`property-type`},"data-constant":{type:`property-type`},constant:{type:`property-type`}},promoteId:{"*":{type:`string`}}};let Fe=[`type`,`source`,`source-layer`,`minzoom`,`maxzoom`,`filter`,`layout`];function Ie(e,t){let n={};for(let t in e)t!==`ref`&&(n[t]=e[t]);return Fe.forEach((e=>{e in t&&(n[e]=t[e])})),n}function Le(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Le(e[n],t[n]))return!1;return!0}if(typeof e==`object`&&e&&t!==null){if(typeof t!=`object`||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(!Le(e[n],t[n]))return!1;return!0}return e===t}function Re(e,t){e.push(t)}function ze(e,t,n){Re(n,{command:`addSource`,args:[e,t[e]]})}function Be(e,t,n){Re(t,{command:`removeSource`,args:[e]}),n[e]=!0}function Ve(e,t,n,r){Be(e,n,r),ze(e,t,n)}function He(e,t,n){let r;for(r in e[n])if(Object.prototype.hasOwnProperty.call(e[n],r)&&r!==`data`&&!Le(e[n][r],t[n][r]))return!1;for(r in t[n])if(Object.prototype.hasOwnProperty.call(t[n],r)&&r!==`data`&&!Le(e[n][r],t[n][r]))return!1;return!0}function Ue(e,t,n,r,i,a){e||={},t||={};for(let o in e)Object.prototype.hasOwnProperty.call(e,o)&&(Le(e[o],t[o])||n.push({command:a,args:[r,o,t[o],i]}));for(let o in t)Object.prototype.hasOwnProperty.call(t,o)&&!Object.prototype.hasOwnProperty.call(e,o)&&(Le(e[o],t[o])||n.push({command:a,args:[r,o,t[o],i]}))}function We(e){return e.id}function Ge(e,t){return e[t.id]=t,e}class L{constructor(e,t,n,r){this.message=(e?`${e}: `:``)+n,r&&(this.identifier=r),t!=null&&t.__line__&&(this.line=t.__line__)}}function Ke(e,...t){for(let n of t)for(let t in n)e[t]=n[t];return e}class qe extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}class Je{constructor(e,t=[]){this.parent=e,this.bindings={};for(let[e,n]of t)this.bindings[e]=n}concat(e){return new Je(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}let Ye={kind:`null`},R={kind:`number`},z={kind:`string`},B={kind:`boolean`},Xe={kind:`color`},Ze={kind:`projectionDefinition`},Qe={kind:`object`},V={kind:`value`},$e={kind:`collator`},et={kind:`formatted`},tt={kind:`padding`},nt={kind:`colorArray`},rt={kind:`numberArray`},it={kind:`resolvedImage`},at={kind:`variableAnchorOffsetCollection`};function ot(e,t){return{kind:`array`,itemType:e,N:t}}function st(e){if(e.kind===`array`){let t=st(e.itemType);return typeof e.N==`number`?`array<${t}, ${e.N}>`:e.itemType.kind===`value`?`array`:`array<${t}>`}return e.kind}let ct=[Ye,R,z,B,Xe,Ze,et,Qe,ot(V),tt,rt,nt,it,at];function lt(e,t){if(t.kind===`error`)return null;if(e.kind===`array`){if(t.kind===`array`&&(t.N===0&&t.itemType.kind===`value`||!lt(e.itemType,t.itemType))&&(typeof e.N!=`number`||e.N===t.N))return null}else{if(e.kind===t.kind)return null;if(e.kind===`value`){for(let e of ct)if(!lt(e,t))return null}}return`Expected ${st(e)} but found ${st(t)} instead.`}function ut(e,t){return t.some((t=>t.kind===e.kind))}function dt(e,t){return t.some((t=>t===`null`?e===null:t===`array`?Array.isArray(e):t===`object`?e&&!Array.isArray(e)&&typeof e==`object`:t===typeof e))}function ft(e,t){return e.kind===`array`&&t.kind===`array`?e.itemType.kind===t.itemType.kind&&typeof e.N==`number`:e.kind===t.kind}let pt=.96422,mt=.82521,ht=4/29,gt=6/29,_t=3*gt*gt;gt*gt*gt;let vt=Math.PI/180,yt=180/Math.PI;function bt(e){return(e%=360)<0&&(e+=360),e}function xt([e,t,n,r]){let i,a,o=Ct((.2225045*(e=St(e))+.7168786*(t=St(t))+.0606169*(n=St(n)))/1);e===t&&t===n?i=a=o:(i=Ct((.4360747*e+.3850649*t+.1430804*n)/pt),a=Ct((.0139322*e+.0971045*t+.7141733*n)/mt));let s=116*o-16;return[s<0?0:s,500*(i-o),200*(o-a),r]}function St(e){return e<=.04045?e/12.92:((e+.055)/1.055)**2.4}function Ct(e){return e>.008856451679035631?e**(1/3):e/_t+ht}function wt([e,t,n,r]){let i=(e+16)/116,a=isNaN(t)?i:i+t/500,o=isNaN(n)?i:i-n/200;return i=1*Et(i),a=pt*Et(a),o=mt*Et(o),[Tt(3.1338561*a-1.6168667*i-.4906146*o),Tt(-.9787684*a+1.9161415*i+.033454*o),Tt(.0719453*a-.2289914*i+1.4052427*o),r]}function Tt(e){return(e=e<=.00304?12.92*e:1.055*e**(1/2.4)-.055)<0?0:e>1?1:e}function Et(e){return e>gt?e*e*e:_t*(e-ht)}let Dt=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};function Ot(e,t){return Dt(e,t)?e[t]:void 0}function kt(e){return parseInt(e.padEnd(2,e),16)/255}function At(e,t){return jt(t?e/100:e,0,1)}function jt(e,t,n){return Math.min(Math.max(t,e),n)}function H(e){return!e.some(Number.isNaN)}let Mt={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function Nt(e,t,n){return e+n*(t-e)}function Pt(e,t,n){return e.map(((e,r)=>Nt(e,t[r],n)))}class U{constructor(e,t,n,r=1,i=!0){this.r=e,this.g=t,this.b=n,this.a=r,i||(this.r*=r,this.g*=r,this.b*=r,r||this.overwriteGetter(`rgb`,[e,t,n,r]))}static parse(e){if(e instanceof U)return e;if(typeof e!=`string`)return;let t=function(e){if((e=e.toLowerCase().trim())===`transparent`)return[0,0,0,0];let t=Ot(Mt,e);if(t){let[e,n,r]=t;return[e/255,n/255,r/255,1]}if(e.startsWith(`#`)&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e)){let t=e.length<6?1:2,n=1;return[kt(e.slice(n,n+=t)),kt(e.slice(n,n+=t)),kt(e.slice(n,n+=t)),kt(e.slice(n,n+t)||`ff`)]}if(e.startsWith(`rgb`)){let t=e.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(t){let[e,n,r,i,a,o,s,c,l,u,d,f]=t,p=[i||` `,s||` `,u].join(``);if(p===` `||p===` /`||p===`,,`||p===`,,,`){let e=[r,o,l].join(``),t=e===`%%%`?100:e===``?255:0;if(t){let e=[jt(+n/t,0,1),jt(+a/t,0,1),jt(+c/t,0,1),d?At(+d,f):1];if(H(e))return e}}return}}let n=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(n){let[e,t,r,i,a,o,s,c,l]=n,u=[r||` `,a||` `,s].join(``);if(u===` `||u===` /`||u===`,,`||u===`,,,`){let e=[+t,jt(+i,0,100),jt(+o,0,100),c?At(+c,l):1];if(H(e))return function([e,t,n,r]){function i(r){let i=(r+e/30)%12,a=t*Math.min(n,1-n);return n-a*Math.max(-1,Math.min(i-3,9-i,1))}return e=bt(e),t/=100,n/=100,[i(0),i(8),i(4),r]}(e)}}}(e);return t?new U(...t,!1):void 0}get rgb(){let{r:e,g:t,b:n,a:r}=this,i=r||1/0;return this.overwriteGetter(`rgb`,[e/i,t/i,n/i,r])}get hcl(){return this.overwriteGetter(`hcl`,function(e){let[t,n,r,i]=xt(e),a=Math.sqrt(n*n+r*r);return[Math.round(1e4*a)?bt(Math.atan2(r,n)*yt):NaN,a,t,i]}(this.rgb))}get lab(){return this.overwriteGetter(`lab`,xt(this.rgb))}overwriteGetter(e,t){return Object.defineProperty(this,e,{value:t}),t}toString(){let[e,t,n,r]=this.rgb;return`rgba(${[e,t,n].map((e=>Math.round(255*e))).join(`,`)},${r})`}static interpolate(e,t,n,r=`rgb`){switch(r){case`rgb`:{let[r,i,a,o]=Pt(e.rgb,t.rgb,n);return new U(r,i,a,o,!1)}case`hcl`:{let[r,i,a,o]=e.hcl,[s,c,l,u]=t.hcl,d,f;if(isNaN(r)||isNaN(s))isNaN(r)?isNaN(s)?d=NaN:(d=s,a!==1&&a!==0||(f=c)):(d=r,l!==1&&l!==0||(f=i));else{let e=s-r;s>r&&e>180?e-=360:s<r&&r-s>180&&(e+=360),d=r+n*e}let[p,m,h,g]=function([e,t,n,r]){return e=isNaN(e)?0:e*vt,wt([n,Math.cos(e)*t,Math.sin(e)*t,r])}([d,f??Nt(i,c,n),Nt(a,l,n),Nt(o,u,n)]);return new U(p,m,h,g,!1)}case`lab`:{let[r,i,a,o]=wt(Pt(e.lab,t.lab,n));return new U(r,i,a,o,!1)}}}}U.black=new U(0,0,0,1),U.white=new U(1,1,1,1),U.transparent=new U(0,0,0,0),U.red=new U(1,0,0,1);class Ft{constructor(e,t,n){this.sensitivity=e?t?`variant`:`case`:t?`accent`:`base`,this.locale=n,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}}let It=[`bottom`,`center`,`top`];class Lt{constructor(e,t,n,r,i,a){this.text=e,this.image=t,this.scale=n,this.fontStack=r,this.textColor=i,this.verticalAlign=a}}class Rt{constructor(e){this.sections=e}static fromString(e){return new Rt([new Lt(e,null,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some((e=>e.text.length!==0||e.image&&e.image.name.length!==0))}static factory(e){return e instanceof Rt?e:Rt.fromString(e)}toString(){return this.sections.length===0?``:this.sections.map((e=>e.text)).join(``)}}class zt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof zt)return e;if(typeof e==`number`)return new zt([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(let t of e)if(typeof t!=`number`)return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new zt(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,n){return new zt(Pt(e.values,t.values,n))}}class Bt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Bt)return e;if(typeof e==`number`)return new Bt([e]);if(Array.isArray(e)){for(let t of e)if(typeof t!=`number`)return;return new Bt(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,n){return new Bt(Pt(e.values,t.values,n))}}class Vt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Vt)return e;if(typeof e==`string`){let t=U.parse(e);return t?new Vt([t]):void 0}if(!Array.isArray(e))return;let t=[];for(let n of e){if(typeof n!=`string`)return;let e=U.parse(n);if(!e)return;t.push(e)}return new Vt(t)}toString(){return JSON.stringify(this.values)}static interpolate(e,t,n,r=`rgb`){let i=[];if(e.values.length!=t.values.length)throw Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${t.values.length}), cannot interpolate.`);for(let a=0;a<e.values.length;a++)i.push(U.interpolate(e.values[a],t.values[a],n,r));return new Vt(i)}}class Ht extends Error{constructor(e){super(e),this.name=`RuntimeError`}toJSON(){return this.message}}let Ut=new Set([`center`,`left`,`right`,`top`,`bottom`,`top-left`,`top-right`,`bottom-left`,`bottom-right`]);class Wt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Wt)return e;if(Array.isArray(e)&&!(e.length<1)&&e.length%2==0){for(let t=0;t<e.length;t+=2){let n=e[t],r=e[t+1];if(typeof n!=`string`||!Ut.has(n)||!Array.isArray(r)||r.length!==2||typeof r[0]!=`number`||typeof r[1]!=`number`)return}return new Wt(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,n){let r=e.values,i=t.values;if(r.length!==i.length)throw new Ht(`Cannot interpolate values of different length. from: ${e.toString()}, to: ${t.toString()}`);let a=[];for(let e=0;e<r.length;e+=2){if(r[e]!==i[e])throw new Ht(`Cannot interpolate values containing mismatched anchors. from[${e}]: ${r[e]}, to[${e}]: ${i[e]}`);a.push(r[e]);let[t,o]=r[e+1],[s,c]=i[e+1];a.push([Nt(t,s,n),Nt(o,c,n)])}return new Wt(a)}}class Gt{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new Gt({name:e,available:!1}):null}}class Kt{constructor(e,t,n){this.from=e,this.to=t,this.transition=n}static interpolate(e,t,n){return new Kt(e,t,n)}static parse(e){return e instanceof Kt?e:Array.isArray(e)&&e.length===3&&typeof e[0]==`string`&&typeof e[1]==`string`&&typeof e[2]==`number`?new Kt(e[0],e[1],e[2]):typeof e==`object`&&typeof e.from==`string`&&typeof e.to==`string`&&typeof e.transition==`number`?new Kt(e.from,e.to,e.transition):typeof e==`string`?new Kt(e,e,1):void 0}}function qt(e,t,n,r){return typeof e==`number`&&e>=0&&e<=255&&typeof t==`number`&&t>=0&&t<=255&&typeof n==`number`&&n>=0&&n<=255?r===void 0||typeof r==`number`&&r>=0&&r<=1?null:`Invalid rgba value [${[e,t,n,r].join(`, `)}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof r==`number`?[e,t,n,r]:[e,t,n]).join(`, `)}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Jt(e){if(e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`||e instanceof Kt||e instanceof U||e instanceof Ft||e instanceof Rt||e instanceof zt||e instanceof Bt||e instanceof Vt||e instanceof Wt||e instanceof Gt)return!0;if(Array.isArray(e)){for(let t of e)if(!Jt(t))return!1;return!0}if(typeof e==`object`){for(let t in e)if(!Jt(e[t]))return!1;return!0}return!1}function Yt(e){if(e===null)return Ye;if(typeof e==`string`)return z;if(typeof e==`boolean`)return B;if(typeof e==`number`)return R;if(e instanceof U)return Xe;if(e instanceof Kt)return Ze;if(e instanceof Ft)return $e;if(e instanceof Rt)return et;if(e instanceof zt)return tt;if(e instanceof Bt)return rt;if(e instanceof Vt)return nt;if(e instanceof Wt)return at;if(e instanceof Gt)return it;if(Array.isArray(e)){let t=e.length,n;for(let t of e){let e=Yt(t);if(n){if(n===e)continue;n=V;break}n=e}return ot(n||V,t)}return Qe}function W(e){let t=typeof e;return e===null?``:t===`string`||t===`number`||t===`boolean`?String(e):e instanceof U||e instanceof Kt||e instanceof Rt||e instanceof zt||e instanceof Bt||e instanceof Vt||e instanceof Wt||e instanceof Gt?e.toString():JSON.stringify(e)}class G{constructor(e,t){this.type=e,this.value=t}static parse(e,t){if(e.length!==2)return t.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Jt(e[1]))return t.error(`invalid value`);let n=e[1],r=Yt(n),i=t.expectedType;return r.kind!==`array`||r.N!==0||!i||i.kind!==`array`||typeof i.N==`number`&&i.N!==0||(r=i),new G(r,n)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}let Xt={string:z,number:R,boolean:B,object:Qe};class K{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 n,r=1,i=e[0];if(i===`array`){let i,a;if(e.length>2){let n=e[1];if(typeof n!=`string`||!(n in Xt)||n===`object`)return t.error(`The item type argument of "array" must be one of string, number, boolean`,1);i=Xt[n],r++}else i=V;if(e.length>3){if(e[2]!==null&&(typeof e[2]!=`number`||e[2]<0||e[2]!==Math.floor(e[2])))return t.error(`The length argument to "array" must be a positive integer literal`,2);a=e[2],r++}n=ot(i,a)}else{if(!Xt[i])throw Error(`Types doesn't contain name = ${i}`);n=Xt[i]}let a=[];for(;r<e.length;r++){let n=t.parse(e[r],r,V);if(!n)return null;a.push(n)}return new K(n,a)}evaluate(e){for(let t=0;t<this.args.length;t++){let n=this.args[t].evaluate(e);if(!lt(this.type,Yt(n)))return n;if(t===this.args.length-1)throw new Ht(`Expected value to be of type ${st(this.type)}, but found ${st(Yt(n))} instead.`)}throw Error()}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}let Zt={"to-boolean":B,"to-color":Xe,"to-number":R,"to-string":z};class Qt{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error(`Expected at least one argument.`);let n=e[0];if(!Zt[n])throw Error(`Can't parse ${n} as it is not part of the known types`);if((n===`to-boolean`||n===`to-string`)&&e.length!==2)return t.error(`Expected one argument.`);let r=Zt[n],i=[];for(let n=1;n<e.length;n++){let r=t.parse(e[n],n,V);if(!r)return null;i.push(r)}return new Qt(r,i)}evaluate(e){switch(this.type.kind){case`boolean`:return!!this.args[0].evaluate(e);case`color`:{let t,n;for(let r of this.args){if(t=r.evaluate(e),n=null,t instanceof U)return t;if(typeof t==`string`){let n=e.parseColor(t);if(n)return n}else if(Array.isArray(t)&&(n=t.length<3||t.length>4?`Invalid rgba value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:qt(t[0],t[1],t[2],t[3]),!n))return new U(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new Ht(n||`Could not parse color from value '${typeof t==`string`?t:JSON.stringify(t)}'`)}case`padding`:{let t;for(let n of this.args){t=n.evaluate(e);let r=zt.parse(t);if(r)return r}throw new Ht(`Could not parse padding from value '${typeof t==`string`?t:JSON.stringify(t)}'`)}case`numberArray`:{let t;for(let n of this.args){t=n.evaluate(e);let r=Bt.parse(t);if(r)return r}throw new Ht(`Could not parse numberArray from value '${typeof t==`string`?t:JSON.stringify(t)}'`)}case`colorArray`:{let t;for(let n of this.args){t=n.evaluate(e);let r=Vt.parse(t);if(r)return r}throw new Ht(`Could not parse colorArray from value '${typeof t==`string`?t:JSON.stringify(t)}'`)}case`variableAnchorOffsetCollection`:{let t;for(let n of this.args){t=n.evaluate(e);let r=Wt.parse(t);if(r)return r}throw new Ht(`Could not parse variableAnchorOffsetCollection from value '${typeof t==`string`?t:JSON.stringify(t)}'`)}case`number`:{let t=null;for(let n of this.args){if(t=n.evaluate(e),t===null)return 0;let r=Number(t);if(!isNaN(r))return r}throw new Ht(`Could not convert ${JSON.stringify(t)} to number.`)}case`formatted`:return Rt.fromString(W(this.args[0].evaluate(e)));case`resolvedImage`:return Gt.fromString(W(this.args[0].evaluate(e)));case`projectionDefinition`:return this.args[0].evaluate(e);default:return W(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}let $t=[`Unknown`,`Point`,`LineString`,`Polygon`];class en{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&`id`in this.feature?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type==`number`?$t[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&`geometry`in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(e){let t=this._parseColorCache.get(e);return t||(t=U.parse(e),this._parseColorCache.set(e,t)),t}}class tn{constructor(e,t,n=[],r,i=new Je,a=[]){this.registry=e,this.path=n,this.key=n.map((e=>`[${e}]`)).join(``),this.scope=i,this.errors=a,this.expectedType=r,this._isConstant=t}parse(e,t,n,r,i={}){return t?this.concat(t,n,r)._parse(e,i):this._parse(e,i)}_parse(e,t){function n(e,t,n){return n===`assert`?new K(t,[e]):n===`coerce`?new Qt(t,[e]):e}if(e!==null&&typeof e!=`string`&&typeof e!=`boolean`&&typeof e!=`number`||(e=[`literal`,e]),Array.isArray(e)){if(e.length===0)return this.error(`Expected an array with at least one element. If you wanted a literal array, use ["literal", []].`);let r=e[0];if(typeof r!=`string`)return this.error(`Expression name must be a string, but found ${typeof r} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;let i=this.registry[r];if(i){let r=i.parse(e,this);if(!r)return null;if(this.expectedType){let e=this.expectedType,i=r.type;if(e.kind!==`string`&&e.kind!==`number`&&e.kind!==`boolean`&&e.kind!==`object`&&e.kind!==`array`||i.kind!==`value`){if(e.kind===`projectionDefinition`&&[`string`,`array`].includes(i.kind)||[`color`,`formatted`,`resolvedImage`].includes(e.kind)&&[`value`,`string`].includes(i.kind)||[`padding`,`numberArray`].includes(e.kind)&&[`value`,`number`,`array`].includes(i.kind)||e.kind===`colorArray`&&[`value`,`string`,`array`].includes(i.kind)||e.kind===`variableAnchorOffsetCollection`&&[`value`,`array`].includes(i.kind))r=n(r,e,t.typeAnnotation||`coerce`);else if(this.checkSubtype(e,i))return null}else r=n(r,e,t.typeAnnotation||`assert`)}if(!(r instanceof G)&&r.type.kind!==`resolvedImage`&&this._isConstant(r)){let e=new en;try{r=new G(r.type,r.evaluate(e))}catch(e){return this.error(e.message),null}}return r}return this.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(e===void 0?`'undefined' value invalid. Use null instead.`:typeof e==`object`?`Bare objects invalid. Use ["literal", {...}] instead.`:`Expected an array, but found ${typeof e} instead.`)}concat(e,t,n){let r=typeof e==`number`?this.path.concat(e):this.path,i=n?this.scope.concat(n):this.scope;return new tn(this.registry,this._isConstant,r,t||null,i,this.errors)}error(e,...t){let n=`${this.key}${t.map((e=>`[${e}]`)).join(``)}`;this.errors.push(new qe(n,e))}checkSubtype(e,t){let n=lt(e,t);return n&&this.error(n),n}}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(let 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.`);let n=[];for(let r=1;r<e.length-1;r+=2){let i=e[r];if(typeof i!=`string`)return t.error(`Expected string, but found ${typeof i} instead.`,r);if(/[^a-zA-Z0-9_]/.test(i))return t.error(`Variable names must contain only alphanumeric characters or '_'.`,r);let a=t.parse(e[r+1],r+1);if(!a)return null;n.push([i,a])}let r=t.parse(e[e.length-1],e.length-1,t.expectedType,n);return r?new nn(n,r):null}outputDefined(){return this.result.outputDefined()}}class rn{constructor(e,t){this.type=t.type,this.name=e,this.boundExpression=t}static parse(e,t){if(e.length!==2||typeof e[1]!=`string`)return t.error(`'var' expression requires exactly one string literal argument.`);let n=e[1];return t.scope.has(n)?new rn(n,t.scope.get(n)):t.error(`Unknown variable "${n}". Make sure "${n}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}}class an{constructor(e,t,n){this.type=e,this.index=t,this.input=n}static parse(e,t){if(e.length!==3)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);let n=t.parse(e[1],1,R),r=t.parse(e[2],2,ot(t.expectedType||V));return n&&r?new an(r.type.itemType,n,r):null}evaluate(e){let t=this.index.evaluate(e),n=this.input.evaluate(e);if(t<0)throw new Ht(`Array index out of bounds: ${t} < 0.`);if(t>=n.length)throw new Ht(`Array index out of bounds: ${t} > ${n.length-1}.`);if(t!==Math.floor(t))throw new Ht(`Array index must be an integer, but found ${t} instead.`);return n[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class on{constructor(e,t){this.type=B,this.needle=e,this.haystack=t}static parse(e,t){if(e.length!==3)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);let n=t.parse(e[1],1,V),r=t.parse(e[2],2,V);return n&&r?ut(n.type,[B,z,R,Ye,V])?new on(n,r):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${st(n.type)} instead`):null}evaluate(e){let t=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(!n)return!1;if(!dt(t,[`boolean`,`string`,`number`,`null`]))throw new Ht(`Expected first argument to be of type boolean, string, number or null, but found ${st(Yt(t))} instead.`);if(!dt(n,[`string`,`array`]))throw new Ht(`Expected second argument to be of type array or string, but found ${st(Yt(n))} instead.`);return n.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class sn{constructor(e,t,n){this.type=R,this.needle=e,this.haystack=t,this.fromIndex=n}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);let n=t.parse(e[1],1,V),r=t.parse(e[2],2,V);if(!n||!r)return null;if(!ut(n.type,[B,z,R,Ye,V]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${st(n.type)} instead`);if(e.length===4){let i=t.parse(e[3],3,R);return i?new sn(n,r,i):null}return new sn(n,r)}evaluate(e){let t=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(!dt(t,[`boolean`,`string`,`number`,`null`]))throw new Ht(`Expected first argument to be of type boolean, string, number or null, but found ${st(Yt(t))} instead.`);let r;if(this.fromIndex&&(r=this.fromIndex.evaluate(e)),dt(n,[`string`])){let e=n.indexOf(t,r);return e===-1?-1:[...n.slice(0,e)].length}if(dt(n,[`array`]))return n.indexOf(t,r);throw new Ht(`Expected second argument to be of type array or string, but found ${st(Yt(n))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class cn{constructor(e,t,n,r,i,a){this.inputType=e,this.type=t,this.input=n,this.cases=r,this.outputs=i,this.otherwise=a}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 n,r;t.expectedType&&t.expectedType.kind!==`value`&&(r=t.expectedType);let i={},a=[];for(let o=2;o<e.length-1;o+=2){let s=e[o],c=e[o+1];Array.isArray(s)||(s=[s]);let l=t.concat(o);if(s.length===0)return l.error(`Expected at least one branch label.`);for(let e of s){if(typeof e!=`number`&&typeof e!=`string`)return l.error(`Branch labels must be numbers or strings.`);if(typeof e==`number`&&Math.abs(e)>2**53-1)return l.error(`Branch labels must be integers no larger than ${2**53-1}.`);if(typeof e==`number`&&Math.floor(e)!==e)return l.error(`Numeric branch labels must be integer values.`);if(n){if(l.checkSubtype(n,Yt(e)))return null}else n=Yt(e);if(i[String(e)]!==void 0)return l.error(`Branch labels must be unique.`);i[String(e)]=a.length}let u=t.parse(c,o,r);if(!u)return null;r||=u.type,a.push(u)}let o=t.parse(e[1],1,V);if(!o)return null;let s=t.parse(e[e.length-1],e.length-1,r);return s?o.type.kind!==`value`&&t.concat(1).checkSubtype(n,o.type)?null:new cn(n,r,o,i,a,s):null}evaluate(e){let t=this.input.evaluate(e);return(Yt(t)===this.inputType&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))&&this.otherwise.outputDefined()}}class ln{constructor(e,t,n){this.type=e,this.branches=t,this.otherwise=n}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 n;t.expectedType&&t.expectedType.kind!==`value`&&(n=t.expectedType);let r=[];for(let i=1;i<e.length-1;i+=2){let a=t.parse(e[i],i,B);if(!a)return null;let o=t.parse(e[i+1],i+1,n);if(!o)return null;r.push([a,o]),n||=o.type}let i=t.parse(e[e.length-1],e.length-1,n);if(!i)return null;if(!n)throw Error(`Can't infer output type`);return new ln(n,r,i)}evaluate(e){for(let[t,n]of this.branches)if(t.evaluate(e))return n.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(let[t,n]of this.branches)e(t),e(n);e(this.otherwise)}outputDefined(){return this.branches.every((([e,t])=>t.outputDefined()))&&this.otherwise.outputDefined()}}class un{constructor(e,t,n,r){this.type=e,this.input=t,this.beginIndex=n,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.`);let n=t.parse(e[1],1,V),r=t.parse(e[2],2,R);if(!n||!r)return null;if(!ut(n.type,[ot(V),z,V]))return t.error(`Expected first argument to be of type array or string, but found ${st(n.type)} instead`);if(e.length===4){let i=t.parse(e[3],3,R);return i?new un(n.type,n,r,i):null}return new un(n.type,n,r)}evaluate(e){let t=this.input.evaluate(e),n=this.beginIndex.evaluate(e),r;if(this.endIndex&&(r=this.endIndex.evaluate(e)),dt(t,[`string`]))return[...t].slice(n,r).join(``);if(dt(t,[`array`]))return t.slice(n,r);throw new Ht(`Expected first argument to be of type array or string, but found ${st(Yt(t))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function dn(e,t){let n=e.length-1,r,i,a=0,o=n,s=0;for(;a<=o;)if(s=Math.floor((a+o)/2),r=e[s],i=e[s+1],r<=t){if(s===n||t<i)return s;a=s+1}else{if(!(r>t))throw new Ht(`Input is not a number.`);o=s-1}return 0}class fn{constructor(e,t,n){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(let[e,t]of n)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.`);let n=t.parse(e[1],1,R);if(!n)return null;let r=[],i=null;t.expectedType&&t.expectedType.kind!==`value`&&(i=t.expectedType);for(let n=1;n<e.length;n+=2){let a=n===1?-1/0:e[n],o=e[n+1],s=n,c=n+1;if(typeof a!=`number`)return t.error(`Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.`,s);if(r.length&&r[r.length-1][0]>=a)return t.error(`Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.`,s);let l=t.parse(o,c,i);if(!l)return null;i||=l.type,r.push([a,l])}return new fn(i,n,r)}evaluate(e){let t=this.labels,n=this.outputs;if(t.length===1)return n[0].evaluate(e);let r=this.input.evaluate(e);if(r<=t[0])return n[0].evaluate(e);let i=t.length;return r>=t[i-1]?n[i-1].evaluate(e):n[dn(t,r)].evaluate(e)}eachChild(e){e(this.input);for(let t of this.outputs)e(t)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function pn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var mn,hn,gn=pn(function(){if(hn)return mn;function e(e,t,n,r){this.cx=3*e,this.bx=3*(n-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=n,this.p2y=r}return hn=1,mn=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(t===void 0&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var n=e,r=0;r<8;r++){var i=this.sampleCurveX(n)-e;if(Math.abs(i)<t)return n;var a=this.sampleCurveDerivativeX(n);if(Math.abs(a)<1e-6)break;n-=i/a}var o=0,s=1;for(n=e,r=0;r<20&&(i=this.sampleCurveX(n),!(Math.abs(i-e)<t));r++)e>i?o=n:s=n,n=.5*(s-o)+o;return n},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},mn}());class _n{constructor(e,t,n,r,i){this.type=e,this.operator=t,this.interpolation=n,this.input=r,this.labels=[],this.outputs=[];for(let[e,t]of i)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,n,r){let i=0;if(e.name===`exponential`)i=vn(t,e.base,n,r);else if(e.name===`linear`)i=vn(t,1,n,r);else if(e.name===`cubic-bezier`){let a=e.controlPoints;i=new gn(a[0],a[1],a[2],a[3]).solve(vn(t,1,n,r))}return i}static parse(e,t){let[n,r,i,...a]=e;if(!Array.isArray(r)||r.length===0)return t.error(`Expected an interpolation type expression.`,1);if(r[0]===`linear`)r={name:`linear`};else if(r[0]===`exponential`){let e=r[1];if(typeof e!=`number`)return t.error(`Exponential interpolation requires a numeric base.`,1,1);r={name:`exponential`,base:e}}else{if(r[0]!==`cubic-bezier`)return t.error(`Unknown interpolation type ${String(r[0])}`,1,0);{let e=r.slice(1);if(e.length!==4||e.some((e=>typeof e!=`number`||e<0||e>1)))return t.error(`Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.`,1);r={name:`cubic-bezier`,controlPoints:e}}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error(`Expected an even number of arguments.`);if(i=t.parse(i,2,R),!i)return null;let o=[],s=null;n!==`interpolate-hcl`&&n!==`interpolate-lab`||t.expectedType==nt?t.expectedType&&t.expectedType.kind!==`value`&&(s=t.expectedType):s=Xe;for(let e=0;e<a.length;e+=2){let n=a[e],r=a[e+1],i=e+3,c=e+4;if(typeof n!=`number`)return t.error(`Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.`,i);if(o.length&&o[o.length-1][0]>=n)return t.error(`Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.`,i);let l=t.parse(r,c,s);if(!l)return null;s||=l.type,o.push([n,l])}return ft(s,R)||ft(s,Ze)||ft(s,Xe)||ft(s,tt)||ft(s,rt)||ft(s,nt)||ft(s,at)||ft(s,ot(R))?new _n(s,n,r,i,o):t.error(`Type ${st(s)} is not interpolatable.`)}evaluate(e){let t=this.labels,n=this.outputs;if(t.length===1)return n[0].evaluate(e);let r=this.input.evaluate(e);if(r<=t[0])return n[0].evaluate(e);let i=t.length;if(r>=t[i-1])return n[i-1].evaluate(e);let a=dn(t,r),o=_n.interpolationFactor(this.interpolation,r,t[a],t[a+1]),s=n[a].evaluate(e),c=n[a+1].evaluate(e);switch(this.operator){case`interpolate`:switch(this.type.kind){case`number`:return Nt(s,c,o);case`color`:return U.interpolate(s,c,o);case`padding`:return zt.interpolate(s,c,o);case`colorArray`:return Vt.interpolate(s,c,o);case`numberArray`:return Bt.interpolate(s,c,o);case`variableAnchorOffsetCollection`:return Wt.interpolate(s,c,o);case`array`:return Pt(s,c,o);case`projectionDefinition`:return Kt.interpolate(s,c,o)}case`interpolate-hcl`:switch(this.type.kind){case`color`:return U.interpolate(s,c,o,`hcl`);case`colorArray`:return Vt.interpolate(s,c,o,`hcl`)}case`interpolate-lab`:switch(this.type.kind){case`color`:return U.interpolate(s,c,o,`lab`);case`colorArray`:return Vt.interpolate(s,c,o,`lab`)}}}eachChild(e){e(this.input);for(let t of this.outputs)e(t)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function vn(e,t,n,r){let i=r-n,a=e-n;return i===0?0:t===1?a/i:(t**+a-1)/(t**+i-1)}let yn={color:U.interpolate,number:Nt,padding:zt.interpolate,numberArray:Bt.interpolate,colorArray:Vt.interpolate,variableAnchorOffsetCollection:Wt.interpolate,array:Pt};class bn{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 n=null,r=t.expectedType;r&&r.kind!==`value`&&(n=r);let i=[];for(let r of e.slice(1)){let e=t.parse(r,1+i.length,n,void 0,{typeAnnotation:`omit`});if(!e)return null;n||=e.type,i.push(e)}if(!n)throw Error(`No output type`);return new bn(r&&i.some((e=>lt(r,e.type)))?V:n,i)}evaluate(e){let t,n=null,r=0;for(let i of this.args)if(r++,n=i.evaluate(e),n&&n instanceof Gt&&!n.available&&(t||=n.name,n=null,r===this.args.length&&(n=t)),n!==null)break;return n}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}function xn(e,t){return e===`==`||e===`!=`?t.kind===`boolean`||t.kind===`string`||t.kind===`number`||t.kind===`null`||t.kind===`value`:t.kind===`string`||t.kind===`number`||t.kind===`value`}function Sn(e,t,n,r){return r.compare(t,n)===0}function Cn(e,t,n){let r=e!==`==`&&e!==`!=`;return class i{constructor(e,t,n){this.type=B,this.lhs=e,this.rhs=t,this.collator=n,this.hasUntypedArgument=e.type.kind===`value`||t.type.kind===`value`}static parse(e,t){if(e.length!==3&&e.length!==4)return t.error(`Expected two or three arguments.`);let n=e[0],a=t.parse(e[1],1,V);if(!a)return null;if(!xn(n,a.type))return t.concat(1).error(`"${n}" comparisons are not supported for type '${st(a.type)}'.`);let o=t.parse(e[2],2,V);if(!o)return null;if(!xn(n,o.type))return t.concat(2).error(`"${n}" comparisons are not supported for type '${st(o.type)}'.`);if(a.type.kind!==o.type.kind&&a.type.kind!==`value`&&o.type.kind!==`value`)return t.error(`Cannot compare types '${st(a.type)}' and '${st(o.type)}'.`);r&&(a.type.kind===`value`&&o.type.kind!==`value`?a=new K(o.type,[a]):a.type.kind!==`value`&&o.type.kind===`value`&&(o=new K(a.type,[o])));let s=null;if(e.length===4){if(a.type.kind!==`string`&&o.type.kind!==`string`&&a.type.kind!==`value`&&o.type.kind!==`value`)return t.error(`Cannot use collator to compare non-string types.`);if(s=t.parse(e[3],3,$e),!s)return null}return new i(a,o,s)}evaluate(i){let a=this.lhs.evaluate(i),o=this.rhs.evaluate(i);if(r&&this.hasUntypedArgument){let t=Yt(a),n=Yt(o);if(t.kind!==n.kind||t.kind!==`string`&&t.kind!==`number`)throw new Ht(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${n.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){let e=Yt(a),n=Yt(o);if(e.kind!==`string`||n.kind!==`string`)return t(i,a,o)}return this.collator?n(i,a,o,this.collator.evaluate(i)):t(i,a,o)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}let wn=Cn(`==`,(function(e,t,n){return t===n}),Sn),Tn=Cn(`!=`,(function(e,t,n){return t!==n}),(function(e,t,n,r){return!Sn(0,t,n,r)})),En=Cn(`<`,(function(e,t,n){return t<n}),(function(e,t,n,r){return r.compare(t,n)<0})),Dn=Cn(`>`,(function(e,t,n){return t>n}),(function(e,t,n,r){return r.compare(t,n)>0})),On=Cn(`<=`,(function(e,t,n){return t<=n}),(function(e,t,n,r){return r.compare(t,n)<=0})),kn=Cn(`>=`,(function(e,t,n){return t>=n}),(function(e,t,n,r){return r.compare(t,n)>=0}));class An{constructor(e,t,n){this.type=$e,this.locale=n,this.caseSensitive=e,this.diacriticSensitive=t}static parse(e,t){if(e.length!==2)return t.error(`Expected one argument.`);let n=e[1];if(typeof n!=`object`||Array.isArray(n))return t.error(`Collator options argument must be an object.`);let r=t.parse(n[`case-sensitive`]!==void 0&&n[`case-sensitive`],1,B);if(!r)return null;let i=t.parse(n[`diacritic-sensitive`]!==void 0&&n[`diacritic-sensitive`],1,B);if(!i)return null;let a=null;return n.locale&&(a=t.parse(n.locale,1,z),!a)?null:new An(r,i,a)}evaluate(e){return new Ft(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}}class jn{constructor(e,t,n,r,i){this.type=z,this.number=e,this.locale=t,this.currency=n,this.minFractionDigits=r,this.maxFractionDigits=i}static parse(e,t){if(e.length!==3)return t.error(`Expected two arguments.`);let n=t.parse(e[1],1,R);if(!n)return null;let r=e[2];if(typeof r!=`object`||Array.isArray(r))return t.error(`NumberFormat options argument must be an object.`);let i=null;if(r.locale&&(i=t.parse(r.locale,1,z),!i))return null;let a=null;if(r.currency&&(a=t.parse(r.currency,1,z),!a))return null;let o=null;if(r[`min-fraction-digits`]&&(o=t.parse(r[`min-fraction-digits`],1,R),!o))return null;let s=null;return r[`max-fraction-digits`]&&(s=t.parse(r[`max-fraction-digits`],1,R),!s)?null:new jn(n,i,a,o,s)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?`currency`:`decimal`,currency:this.currency?this.currency.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class Mn{constructor(e){this.type=et,this.sections=e}static parse(e,t){if(e.length<2)return t.error(`Expected at least one argument.`);let n=e[1];if(!Array.isArray(n)&&typeof n==`object`)return t.error(`First argument must be an image or text section.`);let r=[],i=!1;for(let n=1;n<=e.length-1;++n){let a=e[n];if(i&&typeof a==`object`&&!Array.isArray(a)){i=!1;let e=null;if(a[`font-scale`]&&(e=t.parse(a[`font-scale`],1,R),!e))return null;let n=null;if(a[`text-font`]&&(n=t.parse(a[`text-font`],1,ot(z)),!n))return null;let o=null;if(a[`text-color`]&&(o=t.parse(a[`text-color`],1,Xe),!o))return null;let s=null;if(a[`vertical-align`]){if(typeof a[`vertical-align`]==`string`&&!It.includes(a[`vertical-align`]))return t.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${a[`vertical-align`]}' instead.`);if(s=t.parse(a[`vertical-align`],1,z),!s)return null}let c=r[r.length-1];c.scale=e,c.font=n,c.textColor=o,c.verticalAlign=s}else{let a=t.parse(e[n],1,V);if(!a)return null;let o=a.type.kind;if(o!==`string`&&o!==`value`&&o!==`null`&&o!==`resolvedImage`)return t.error(`Formatted text type must be 'string', 'value', 'image' or 'null'.`);i=!0,r.push({content:a,scale:null,font:null,textColor:null,verticalAlign:null})}}return new Mn(r)}evaluate(e){return new Rt(this.sections.map((t=>{let n=t.content.evaluate(e);return Yt(n)===it?new Lt(``,n,null,null,null,t.verticalAlign?t.verticalAlign.evaluate(e):null):new Lt(W(n),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(`,`):null,t.textColor?t.textColor.evaluate(e):null,t.verticalAlign?t.verticalAlign.evaluate(e):null)})))}eachChild(e){for(let t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor),t.verticalAlign&&e(t.verticalAlign)}outputDefined(){return!1}}class Nn{constructor(e){this.type=it,this.input=e}static parse(e,t){if(e.length!==2)return t.error(`Expected two arguments.`);let n=t.parse(e[1],1,z);return n?new Nn(n):t.error(`No image name provided.`)}evaluate(e){let t=this.input.evaluate(e),n=Gt.fromString(t);return n&&e.availableImages&&(n.available=e.availableImages.indexOf(t)>-1),n}eachChild(e){e(this.input)}outputDefined(){return!1}}class Pn{constructor(e){this.type=R,this.input=e}static parse(e,t){if(e.length!==2)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);let n=t.parse(e[1],1);return n?n.type.kind!==`array`&&n.type.kind!==`string`&&n.type.kind!==`value`?t.error(`Expected argument of type string or array, but found ${st(n.type)} instead.`):new Pn(n):null}evaluate(e){let t=this.input.evaluate(e);if(typeof t==`string`)return[...t].length;if(Array.isArray(t))return t.length;throw new Ht(`Expected value to be of type string or array, but found ${st(Yt(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}let Fn=8192;function In(e,t){let n=(180+e[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,i=2**t.z;return[Math.round(n*i*Fn),Math.round(r*i*Fn)]}function Ln(e,t){let n=2**t.z;return[(i=(e[0]/Fn+t.x)/n,360*i-180),(r=(e[1]/Fn+t.y)/n,360/Math.PI*Math.atan(Math.exp((180-360*r)*Math.PI/180))-90)];var r,i}function Rn(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 zn(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function Bn(e,t,n){let r=e[0]-t[0],i=e[1]-t[1],a=e[0]-n[0],o=e[1]-n[1];return r*o-a*i==0&&r*a<=0&&i*o<=0}function Vn(e,t,n,r){return(i=[r[0]-n[0],r[1]-n[1]])[0]*(a=[t[0]-e[0],t[1]-e[1]])[1]-i[1]*a[0]!=0&&!(!qn(e,t,n,r)||!qn(n,r,e,t));var i,a}function Hn(e,t,n){for(let r of n)for(let n=0;n<r.length-1;++n)if(Vn(e,t,r[n],r[n+1]))return!0;return!1}function Un(e,t,n=!1){let r=!1;for(let s of t)for(let t=0;t<s.length-1;t++){if(Bn(e,s[t],s[t+1]))return n;(a=s[t])[1]>(i=e)[1]!=(o=s[t+1])[1]>i[1]&&i[0]<(o[0]-a[0])*(i[1]-a[1])/(o[1]-a[1])+a[0]&&(r=!r)}var i,a,o;return r}function Wn(e,t){for(let n of t)if(Un(e,n))return!0;return!1}function Gn(e,t){for(let n of e)if(!Un(n,t))return!1;for(let n=0;n<e.length-1;++n)if(Hn(e[n],e[n+1],t))return!1;return!0}function Kn(e,t){for(let n of t)if(Gn(e,n))return!0;return!1}function qn(e,t,n,r){let i=r[0]-n[0],a=r[1]-n[1],o=(e[0]-n[0])*a-i*(e[1]-n[1]),s=(t[0]-n[0])*a-i*(t[1]-n[1]);return o>0&&s<0||o<0&&s>0}function Jn(e,t,n){let r=[];for(let i=0;i<e.length;i++){let a=[];for(let r=0;r<e[i].length;r++){let o=In(e[i][r],n);Rn(t,o),a.push(o)}r.push(a)}return r}function Yn(e,t,n){let r=[];for(let i=0;i<e.length;i++){let a=Jn(e[i],t,n);r.push(a)}return r}function Xn(e,t,n,r){if(e[0]<n[0]||e[0]>n[2]){let t=.5*r,i=e[0]-n[0]>t?-r:n[0]-e[0]>t?r:0;i===0&&(i=e[0]-n[2]>t?-r:n[2]-e[0]>t?r:0),e[0]+=i}Rn(t,e)}function Zn(e,t,n,r){let i=2**r.z*Fn,a=[r.x*Fn,r.y*Fn],o=[];for(let r of e)for(let e of r){let r=[e.x+a[0],e.y+a[1]];Xn(r,t,n,i),o.push(r)}return o}function Qn(e,t,n,r){let i=2**r.z*Fn,a=[r.x*Fn,r.y*Fn],o=[];for(let n of e){let e=[];for(let r of n){let n=[r.x+a[0],r.y+a[1]];Rn(t,n),e.push(n)}o.push(e)}if(t[2]-t[0]<=i/2){(s=t)[0]=s[1]=1/0,s[2]=s[3]=-1/0;for(let e of o)for(let r of e)Xn(r,t,n,i)}var s;return o}class $n{constructor(e,t){this.type=B,this.geojson=e,this.geometries=t}static parse(e,t){if(e.length!==2)return t.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Jt(e[1])){let t=e[1];if(t.type===`FeatureCollection`){let e=[];for(let n of t.features){let{type:t,coordinates:r}=n.geometry;t===`Polygon`&&e.push(r),t===`MultiPolygon`&&e.push(...r)}if(e.length)return new $n(t,{type:`MultiPolygon`,coordinates:e})}else if(t.type===`Feature`){let e=t.geometry.type;if(e===`Polygon`||e===`MultiPolygon`)return new $n(t,t.geometry)}else if(t.type===`Polygon`||t.type===`MultiPolygon`)return new $n(t,t)}return t.error(`'within' expression requires valid geojson object that contains polygon geometry type.`)}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()===`Point`)return function(e,t){let n=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],i=e.canonicalID();if(t.type===`Polygon`){let a=Jn(t.coordinates,r,i),o=Zn(e.geometry(),n,r,i);if(!zn(n,r))return!1;for(let e of o)if(!Un(e,a))return!1}if(t.type===`MultiPolygon`){let a=Yn(t.coordinates,r,i),o=Zn(e.geometry(),n,r,i);if(!zn(n,r))return!1;for(let e of o)if(!Wn(e,a))return!1}return!0}(e,this.geometries);if(e.geometryType()===`LineString`)return function(e,t){let n=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],i=e.canonicalID();if(t.type===`Polygon`){let a=Jn(t.coordinates,r,i),o=Qn(e.geometry(),n,r,i);if(!zn(n,r))return!1;for(let e of o)if(!Gn(e,a))return!1}if(t.type===`MultiPolygon`){let a=Yn(t.coordinates,r,i),o=Qn(e.geometry(),n,r,i);if(!zn(n,r))return!1;for(let e of o)if(!Kn(e,a))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let er=class{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(this.length===0)return;let 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){let{data:t,compare:n}=this,r=t[e];for(;e>0;){let i=e-1>>1,a=t[i];if(n(r,a)>=0)break;t[e]=a,e=i}t[e]=r}_down(e){let{data:t,compare:n}=this,r=this.length>>1,i=t[e];for(;e<r;){let r=1+(e<<1),a=r+1;if(a<this.length&&n(t[a],t[r])<0&&(r=a),n(t[r],i)>=0)break;t[e]=t[r],e=r}t[e]=i}};function tr(e,t,n=0,r=e.length-1,i=rr){for(;r>n;){if(r-n>600){let a=r-n+1,o=t-n+1,s=Math.log(a),c=.5*Math.exp(2*s/3),l=.5*Math.sqrt(s*c*(a-c)/a)*(o-a/2<0?-1:1);tr(e,t,Math.max(n,Math.floor(t-o*c/a+l)),Math.min(r,Math.floor(t+(a-o)*c/a+l)),i)}let a=e[t],o=n,s=r;for(nr(e,n,t),i(e[r],a)>0&&nr(e,n,r);o<s;){for(nr(e,o,s),o++,s--;i(e[o],a)<0;)o++;for(;i(e[s],a)>0;)s--}i(e[n],a)===0?nr(e,n,s):(s++,nr(e,s,r)),s<=t&&(n=s+1),t<=s&&(r=s-1)}}function nr(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function rr(e,t){return e<t?-1:e>t?1:0}function ir(e,t){if(e.length<=1)return[e];let n=[],r,i;for(let t of e){let e=or(t);e!==0&&(t.area=Math.abs(e),i===void 0&&(i=e<0),i===e<0?(r&&n.push(r),r=[t]):r.push(t))}if(r&&n.push(r),t>1)for(let e=0;e<n.length;e++)n[e].length<=t||(tr(n[e],t,1,n[e].length-1,ar),n[e]=n[e].slice(0,t));return n}function ar(e,t){return t.area-e.area}function or(e){let t=0;for(let n,r,i=0,a=e.length,o=a-1;i<a;o=i++)n=e[i],r=e[o],t+=(r.x-n.x)*(n.y+r.y);return t}let sr=1/298.257223563,cr=sr*(2-sr),lr=Math.PI/180;class ur{constructor(e){let t=6378.137*lr*1e3,n=Math.cos(e*lr),r=1/(1-cr*(1-n*n)),i=Math.sqrt(r);this.kx=t*i*n,this.ky=t*i*r*(1-cr)}distance(e,t){let n=this.wrap(e[0]-t[0])*this.kx,r=(e[1]-t[1])*this.ky;return Math.sqrt(n*n+r*r)}pointOnLine(e,t){let n,r,i,a,o=1/0;for(let s=0;s<e.length-1;s++){let c=e[s][0],l=e[s][1],u=this.wrap(e[s+1][0]-c)*this.kx,d=(e[s+1][1]-l)*this.ky,f=0;u===0&&d===0||(f=(this.wrap(t[0]-c)*this.kx*u+(t[1]-l)*this.ky*d)/(u*u+d*d),f>1?(c=e[s+1][0],l=e[s+1][1]):f>0&&(c+=u/this.kx*f,l+=d/this.ky*f)),u=this.wrap(t[0]-c)*this.kx,d=(t[1]-l)*this.ky;let p=u*u+d*d;p<o&&(o=p,n=c,r=l,i=s,a=f)}return{point:[n,r],index:i,t:Math.max(0,Math.min(1,a))}}wrap(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}}function dr(e,t){return t[0]-e[0]}function fr(e){return e[1]-e[0]+1}function pr(e,t){return e[1]>=e[0]&&e[1]<t}function mr(e,t){if(e[0]>e[1])return[null,null];let n=fr(e);if(t){if(n===2)return[e,null];let t=Math.floor(n/2);return[[e[0],e[0]+t],[e[0]+t,e[1]]]}if(n===1)return[e,null];let r=Math.floor(n/2)-1;return[[e[0],e[0]+r],[e[0]+r+1,e[1]]]}function hr(e,t){if(!pr(t,e.length))return[1/0,1/0,-1/0,-1/0];let n=[1/0,1/0,-1/0,-1/0];for(let r=t[0];r<=t[1];++r)Rn(n,e[r]);return n}function gr(e){let t=[1/0,1/0,-1/0,-1/0];for(let n of e)for(let e of n)Rn(t,e);return t}function _r(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function vr(e,t,n){if(!_r(e)||!_r(t))return NaN;let r=0,i=0;return e[2]<t[0]&&(r=t[0]-e[2]),e[0]>t[2]&&(r=e[0]-t[2]),e[1]>t[3]&&(i=e[1]-t[3]),e[3]<t[1]&&(i=t[1]-e[3]),n.distance([0,0],[r,i])}function yr(e,t,n){let r=n.pointOnLine(t,e);return n.distance(e,r.point)}function br(e,t,n,r,i){let a=Math.min(yr(e,[n,r],i),yr(t,[n,r],i)),o=Math.min(yr(n,[e,t],i),yr(r,[e,t],i));return Math.min(a,o)}function xr(e,t,n,r,i){if(!pr(t,e.length)||!pr(r,n.length))return 1/0;let a=1/0;for(let o=t[0];o<t[1];++o){let t=e[o],s=e[o+1];for(let e=r[0];e<r[1];++e){let r=n[e],o=n[e+1];if(Vn(t,s,r,o))return 0;a=Math.min(a,br(t,s,r,o,i))}}return a}function Sr(e,t,n,r,i){if(!pr(t,e.length)||!pr(r,n.length))return NaN;let a=1/0;for(let o=t[0];o<=t[1];++o)for(let t=r[0];t<=r[1];++t)if(a=Math.min(a,i.distance(e[o],n[t])),a===0)return a;return a}function Cr(e,t,n){if(Un(e,t,!0))return 0;let r=1/0;for(let i of t){let t=i[0],a=i[i.length-1];if(t!==a&&(r=Math.min(r,yr(e,[a,t],n)),r===0))return r;let o=n.pointOnLine(i,e);if(r=Math.min(r,n.distance(e,o.point)),r===0)return r}return r}function wr(e,t,n,r){if(!pr(t,e.length))return NaN;for(let r=t[0];r<=t[1];++r)if(Un(e[r],n,!0))return 0;let i=1/0;for(let a=t[0];a<t[1];++a){let t=e[a],o=e[a+1];for(let e of n)for(let n=0,a=e.length,s=a-1;n<a;s=n++){let a=e[s],c=e[n];if(Vn(t,o,a,c))return 0;i=Math.min(i,br(t,o,a,c,r))}}return i}function Tr(e,t){for(let n of e)for(let e of n)if(Un(e,t,!0))return!0;return!1}function Er(e,t,n,r=1/0){let i=gr(e),a=gr(t);if(r!==1/0&&vr(i,a,n)>=r)return r;if(zn(i,a)){if(Tr(e,t))return 0}else if(Tr(t,e))return 0;let o=1/0;for(let r of e)for(let e=0,i=r.length,a=i-1;e<i;a=e++){let i=r[a],s=r[e];for(let e of t)for(let t=0,r=e.length,a=r-1;t<r;a=t++){let r=e[a],c=e[t];if(Vn(i,s,r,c))return 0;o=Math.min(o,br(i,s,r,c,n))}}return o}function Dr(e,t,n,r,i,a){if(!a)return;let o=vr(hr(r,a),i,n);o<t&&e.push([o,a,[0,0]])}function Or(e,t,n,r,i,a,o){if(!a||!o)return;let s=vr(hr(r,a),hr(i,o),n);s<t&&e.push([s,a,o])}function kr(e,t,n,r,i=1/0){let a=Math.min(r.distance(e[0],n[0][0]),i);if(a===0)return a;let o=new er([[0,[0,e.length-1],[0,0]]],dr),s=gr(n);for(;o.length>0;){let i=o.pop();if(i[0]>=a)continue;let c=i[1],l=t?50:100;if(fr(c)<=l){if(!pr(c,e.length))return NaN;if(t){let t=wr(e,c,n,r);if(isNaN(t)||t===0)return t;a=Math.min(a,t)}else for(let t=c[0];t<=c[1];++t){let i=Cr(e[t],n,r);if(a=Math.min(a,i),a===0)return 0}}else{let n=mr(c,t);Dr(o,a,r,e,s,n[0]),Dr(o,a,r,e,s,n[1])}}return a}function q(e,t,n,r,i,a=1/0){let o=Math.min(a,i.distance(e[0],n[0]));if(o===0)return o;let s=new er([[0,[0,e.length-1],[0,n.length-1]]],dr);for(;s.length>0;){let a=s.pop();if(a[0]>=o)continue;let c=a[1],l=a[2],u=t?50:100,d=r?50:100;if(fr(c)<=u&&fr(l)<=d){if(!pr(c,e.length)&&pr(l,n.length))return NaN;let a;if(t&&r)a=xr(e,c,n,l,i),o=Math.min(o,a);else if(t&&!r){let t=e.slice(c[0],c[1]+1);for(let e=l[0];e<=l[1];++e)if(a=yr(n[e],t,i),o=Math.min(o,a),o===0)return o}else if(!t&&r){let t=n.slice(l[0],l[1]+1);for(let n=c[0];n<=c[1];++n)if(a=yr(e[n],t,i),o=Math.min(o,a),o===0)return o}else a=Sr(e,c,n,l,i),o=Math.min(o,a)}else{let a=mr(c,t),u=mr(l,r);Or(s,o,i,e,n,a[0],u[0]),Or(s,o,i,e,n,a[0],u[1]),Or(s,o,i,e,n,a[1],u[0]),Or(s,o,i,e,n,a[1],u[1])}}return o}function Ar(e){return e.type===`MultiPolygon`?e.coordinates.map((e=>({type:`Polygon`,coordinates:e}))):e.type===`MultiLineString`?e.coordinates.map((e=>({type:`LineString`,coordinates:e}))):e.type===`MultiPoint`?e.coordinates.map((e=>({type:`Point`,coordinates:e}))):[e]}class jr{constructor(e,t){this.type=R,this.geojson=e,this.geometries=t}static parse(e,t){if(e.length!==2)return t.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Jt(e[1])){let t=e[1];if(t.type===`FeatureCollection`)return new jr(t,t.features.map((e=>Ar(e.geometry))).flat());if(t.type===`Feature`)return new jr(t,Ar(t.geometry));if(`type`in t&&`coordinates`in t)return new jr(t,Ar(t))}return t.error(`'distance' expression requires valid geojson object that contains polygon geometry type.`)}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()===`Point`)return function(e,t){let n=e.geometry(),r=n.flat().map((t=>Ln([t.x,t.y],e.canonical)));if(n.length===0)return NaN;let i=new ur(r[0][1]),a=1/0;for(let e of t){switch(e.type){case`Point`:a=Math.min(a,q(r,!1,[e.coordinates],!1,i,a));break;case`LineString`:a=Math.min(a,q(r,!1,e.coordinates,!0,i,a));break;case`Polygon`:a=Math.min(a,kr(r,!1,e.coordinates,i,a))}if(a===0)return a}return a}(e,this.geometries);if(e.geometryType()===`LineString`)return function(e,t){let n=e.geometry(),r=n.flat().map((t=>Ln([t.x,t.y],e.canonical)));if(n.length===0)return NaN;let i=new ur(r[0][1]),a=1/0;for(let e of t){switch(e.type){case`Point`:a=Math.min(a,q(r,!0,[e.coordinates],!1,i,a));break;case`LineString`:a=Math.min(a,q(r,!0,e.coordinates,!0,i,a));break;case`Polygon`:a=Math.min(a,kr(r,!0,e.coordinates,i,a))}if(a===0)return a}return a}(e,this.geometries);if(e.geometryType()===`Polygon`)return function(e,t){let n=e.geometry();if(n.length===0||n[0].length===0)return NaN;let r=ir(n,0).map((t=>t.map((t=>t.map((t=>Ln([t.x,t.y],e.canonical))))))),i=new ur(r[0][0][0][1]),a=1/0;for(let e of t)for(let t of r){switch(e.type){case`Point`:a=Math.min(a,kr([e.coordinates],!1,t,i,a));break;case`LineString`:a=Math.min(a,kr(e.coordinates,!0,t,i,a));break;case`Polygon`:a=Math.min(a,Er(t,e.coordinates,i,a))}if(a===0)return a}return a}(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class Mr{constructor(e){this.type=V,this.key=e}static parse(e,t){if(e.length!==2)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);let n=e[1];return n==null?t.error(`Global state property must be defined.`):typeof n==`string`?new Mr(n):t.error(`Global state property must be string, but found ${typeof e[1]} instead.`)}evaluate(e){let t=e.globals?.globalState;return t&&Object.keys(t).length!==0?Ot(t,this.key):null}eachChild(){}outputDefined(){return!1}}let Nr={"==":wn,"!=":Tn,">":Dn,"<":En,">=":kn,"<=":On,array:K,at:an,boolean:K,case:ln,coalesce:bn,collator:An,format:Mn,image:Nn,in:on,"index-of":sn,interpolate:_n,"interpolate-hcl":_n,"interpolate-lab":_n,length:Pn,let:nn,literal:G,match:cn,number:K,"number-format":jn,object:K,slice:un,step:fn,string:K,"to-boolean":Qt,"to-color":Qt,"to-number":Qt,"to-string":Qt,var:rn,within:$n,distance:jr,"global-state":Mr};class Pr{constructor(e,t,n,r){this.name=e,this.type=t,this._evaluate=n,this.args=r}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,t){let n=e[0],r=Pr.definitions[n];if(!r)return t.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0);let i=Array.isArray(r)?r[0]:r.type,a=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,o=a.filter((([t])=>!Array.isArray(t)||t.length===e.length-1)),s=null;for(let[r,a]of o){s=new tn(t.registry,zr,t.path,null,t.scope);let o=[],c=!1;for(let t=1;t<e.length;t++){let n=e[t],i=Array.isArray(r)?r[t-1]:r.type,a=s.parse(n,1+o.length,i);if(!a){c=!0;break}o.push(a)}if(!c)if(Array.isArray(r)&&r.length!==o.length)s.error(`Expected ${r.length} arguments, but found ${o.length} instead.`);else{for(let e=0;e<o.length;e++){let t=Array.isArray(r)?r[e]:r.type,n=o[e];s.concat(e+1).checkSubtype(t,n.type)}if(s.errors.length===0)return new Pr(n,i,a,o)}}if(o.length===1)t.errors.push(...s.errors);else{let n=(o.length?o:a).map((([e])=>{return t=e,Array.isArray(t)?`(${t.map(st).join(`, `)})`:`(${st(t.type)}...)`;var t})).join(` | `),r=[];for(let n=1;n<e.length;n++){let i=t.parse(e[n],1+r.length);if(!i)return null;r.push(st(i.type))}t.error(`Expected arguments of type ${n}, but found (${r.join(`, `)}) instead.`)}return null}static register(e,t){Pr.definitions=t;for(let n in t)e[n]=Pr}}function Fr(e,[t,n,r,i]){t=t.evaluate(e),n=n.evaluate(e),r=r.evaluate(e);let a=i?i.evaluate(e):1,o=qt(t,n,r,a);if(o)throw new Ht(o);return new U(t/255,n/255,r/255,a,!1)}function Ir(e,t){return e in t}function Lr(e,t){let n=t[e];return n===void 0?null:n}function Rr(e){return{type:e}}function zr(e){if(e instanceof rn)return zr(e.boundExpression);if(e instanceof Pr&&e.name===`error`||e instanceof An||e instanceof $n||e instanceof jr||e instanceof Mr)return!1;let t=e instanceof Qt||e instanceof K,n=!0;return e.eachChild((e=>{n=t?n&&zr(e):n&&e instanceof G})),!!n&&Br(e)&&Hr(e,[`zoom`,`heatmap-density`,`elevation`,`line-progress`,`accumulated`,`is-supported-script`])}function Br(e){if(e instanceof Pr&&(e.name===`get`&&e.args.length===1||e.name===`feature-state`||e.name===`has`&&e.args.length===1||e.name===`properties`||e.name===`geometry-type`||e.name===`id`||/^filter-/.test(e.name))||e instanceof $n||e instanceof jr)return!1;let t=!0;return e.eachChild((e=>{t&&!Br(e)&&(t=!1)})),t}function Vr(e){if(e instanceof Pr&&e.name===`feature-state`)return!1;let t=!0;return e.eachChild((e=>{t&&!Vr(e)&&(t=!1)})),t}function Hr(e,t){if(e instanceof Pr&&t.indexOf(e.name)>=0)return!1;let n=!0;return e.eachChild((e=>{n&&!Hr(e,t)&&(n=!1)})),n}function Ur(e){return{result:`success`,value:e}}function Wr(e){return{result:`error`,value:e}}function Gr(e){return e[`property-type`]===`data-driven`||e[`property-type`]===`cross-faded-data-driven`}function Kr(e){return!!e.expression&&e.expression.parameters.indexOf(`zoom`)>-1}function qr(e){return!!e.expression&&e.expression.interpolated}function J(e){return e instanceof Number?`number`:e instanceof String?`string`:e instanceof Boolean?`boolean`:Array.isArray(e)?`array`:e===null?`null`:typeof e}function Jr(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Yt(e)===Qe}function Yr(e){return e}function Xr(e,t){let n=e.stops&&typeof e.stops[0][0]==`object`,r=n||!(n||e.property!==void 0),i=e.type||(qr(t)?`exponential`:`interval`),a=function(e){switch(e.type){case`color`:return U.parse;case`padding`:return zt.parse;case`numberArray`:return Bt.parse;case`colorArray`:return Vt.parse;default:return null}}(t);if(a&&((e=Ke({},e)).stops&&(e.stops=e.stops.map((e=>[e[0],a(e[1])]))),e.default=a(e.default?e.default:t.default)),e.colorSpace&&(o=e.colorSpace)!==`rgb`&&o!==`hcl`&&o!==`lab`)throw Error(`Unknown color space: "${e.colorSpace}"`);var o;let s=function(e){switch(e){case`exponential`:return ei;case`interval`:return $r;case`categorical`:return Qr;case`identity`:return ti;default:throw Error(`Unknown function type "${e}"`)}}(i),c,l;if(i===`categorical`){c=Object.create(null);for(let t of e.stops)c[t[0]]=t[1];l=typeof e.stops[0][0]}if(n){let n={},r=[];for(let t=0;t<e.stops.length;t++){let i=e.stops[t],a=i[0].zoom;n[a]===void 0&&(n[a]={zoom:a,type:e.type,property:e.property,default:e.default,stops:[]},r.push(a)),n[a].stops.push([i[0].value,i[1]])}let i=[];for(let e of r)i.push([n[e].zoom,Xr(n[e],t)]);let a={name:`linear`};return{kind:`composite`,interpolationType:a,interpolationFactor:_n.interpolationFactor.bind(void 0,a),zoomStops:i.map((e=>e[0])),evaluate:({zoom:n},r)=>ei({stops:i,base:e.base},t,n).evaluate(n,r)}}if(r){let n=i===`exponential`?{name:`exponential`,base:e.base===void 0?1:e.base}:null;return{kind:`camera`,interpolationType:n,interpolationFactor:_n.interpolationFactor.bind(void 0,n),zoomStops:e.stops.map((e=>e[0])),evaluate:({zoom:n})=>s(e,t,n,c,l)}}return{kind:`source`,evaluate(n,r){let i=r&&r.properties?r.properties[e.property]:void 0;return i===void 0?Zr(e.default,t.default):s(e,t,i,c,l)}}}function Zr(e,t,n){return e===void 0?t===void 0?n===void 0?void 0:n:t:e}function Qr(e,t,n,r,i){return Zr(typeof n===i?r[n]:void 0,e.default,t.default)}function $r(e,t,n){if(J(n)!==`number`)return Zr(e.default,t.default);let r=e.stops.length;if(r===1||n<=e.stops[0][0])return e.stops[0][1];if(n>=e.stops[r-1][0])return e.stops[r-1][1];let i=dn(e.stops.map((e=>e[0])),n);return e.stops[i][1]}function ei(e,t,n){let r=e.base===void 0?1:e.base;if(J(n)!==`number`)return Zr(e.default,t.default);let i=e.stops.length;if(i===1||n<=e.stops[0][0])return e.stops[0][1];if(n>=e.stops[i-1][0])return e.stops[i-1][1];let a=dn(e.stops.map((e=>e[0])),n),o=function(e,t,n,r){let i=r-n,a=e-n;return i===0?0:t===1?a/i:(t**+a-1)/(t**+i-1)}(n,r,e.stops[a][0],e.stops[a+1][0]),s=e.stops[a][1],c=e.stops[a+1][1],l=yn[t.type]||Yr;return typeof s.evaluate==`function`?{evaluate(...t){let n=s.evaluate.apply(void 0,t),r=c.evaluate.apply(void 0,t);if(n!==void 0&&r!==void 0)return l(n,r,o,e.colorSpace)}}:l(s,c,o,e.colorSpace)}function ti(e,t,n){switch(t.type){case`color`:n=U.parse(n);break;case`formatted`:n=Rt.fromString(n.toString());break;case`resolvedImage`:n=Gt.fromString(n.toString());break;case`padding`:n=zt.parse(n);break;case`colorArray`:n=Vt.parse(n);break;case`numberArray`:n=Bt.parse(n);break;default:J(n)===t.type||t.type===`enum`&&t.values[n]||(n=void 0)}return Zr(n,e.default,t.default)}Pr.register(Nr,{error:[{kind:`error`},[z],(e,[t])=>{throw new Ht(t.evaluate(e))}],typeof:[z,[V],(e,[t])=>st(Yt(t.evaluate(e)))],"to-rgba":[ot(R,4),[Xe],(e,[t])=>{let[n,r,i,a]=t.evaluate(e).rgb;return[255*n,255*r,255*i,a]}],rgb:[Xe,[R,R,R],Fr],rgba:[Xe,[R,R,R,R],Fr],has:{type:B,overloads:[[[z],(e,[t])=>Ir(t.evaluate(e),e.properties())],[[z,Qe],(e,[t,n])=>Ir(t.evaluate(e),n.evaluate(e))]]},get:{type:V,overloads:[[[z],(e,[t])=>Lr(t.evaluate(e),e.properties())],[[z,Qe],(e,[t,n])=>Lr(t.evaluate(e),n.evaluate(e))]]},"feature-state":[V,[z],(e,[t])=>Lr(t.evaluate(e),e.featureState||{})],properties:[Qe,[],e=>e.properties()],"geometry-type":[z,[],e=>e.geometryType()],id:[V,[],e=>e.id()],zoom:[R,[],e=>e.globals.zoom],"heatmap-density":[R,[],e=>e.globals.heatmapDensity||0],elevation:[R,[],e=>e.globals.elevation||0],"line-progress":[R,[],e=>e.globals.lineProgress||0],accumulated:[V,[],e=>e.globals.accumulated===void 0?null:e.globals.accumulated],"+":[R,Rr(R),(e,t)=>{let n=0;for(let r of t)n+=r.evaluate(e);return n}],"*":[R,Rr(R),(e,t)=>{let n=1;for(let r of t)n*=r.evaluate(e);return n}],"-":{type:R,overloads:[[[R,R],(e,[t,n])=>t.evaluate(e)-n.evaluate(e)],[[R],(e,[t])=>-t.evaluate(e)]]},"/":[R,[R,R],(e,[t,n])=>t.evaluate(e)/n.evaluate(e)],"%":[R,[R,R],(e,[t,n])=>t.evaluate(e)%n.evaluate(e)],ln2:[R,[],()=>Math.LN2],pi:[R,[],()=>Math.PI],e:[R,[],()=>Math.E],"^":[R,[R,R],(e,[t,n])=>t.evaluate(e)**+n.evaluate(e)],sqrt:[R,[R],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[R,[R],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[R,[R],(e,[t])=>Math.log(t.evaluate(e))],log2:[R,[R],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[R,[R],(e,[t])=>Math.sin(t.evaluate(e))],cos:[R,[R],(e,[t])=>Math.cos(t.evaluate(e))],tan:[R,[R],(e,[t])=>Math.tan(t.evaluate(e))],asin:[R,[R],(e,[t])=>Math.asin(t.evaluate(e))],acos:[R,[R],(e,[t])=>Math.acos(t.evaluate(e))],atan:[R,[R],(e,[t])=>Math.atan(t.evaluate(e))],min:[R,Rr(R),(e,t)=>Math.min(...t.map((t=>t.evaluate(e))))],max:[R,Rr(R),(e,t)=>Math.max(...t.map((t=>t.evaluate(e))))],abs:[R,[R],(e,[t])=>Math.abs(t.evaluate(e))],round:[R,[R],(e,[t])=>{let n=t.evaluate(e);return n<0?-Math.round(-n):Math.round(n)}],floor:[R,[R],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[R,[R],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[B,[z,V],(e,[t,n])=>e.properties()[t.value]===n.value],"filter-id-==":[B,[V],(e,[t])=>e.id()===t.value],"filter-type-==":[B,[z],(e,[t])=>e.geometryType()===t.value],"filter-<":[B,[z,V],(e,[t,n])=>{let r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r<i}],"filter-id-<":[B,[V],(e,[t])=>{let n=e.id(),r=t.value;return typeof n==typeof r&&n<r}],"filter->":[B,[z,V],(e,[t,n])=>{let r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r>i}],"filter-id->":[B,[V],(e,[t])=>{let n=e.id(),r=t.value;return typeof n==typeof r&&n>r}],"filter-<=":[B,[z,V],(e,[t,n])=>{let r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r<=i}],"filter-id-<=":[B,[V],(e,[t])=>{let n=e.id(),r=t.value;return typeof n==typeof r&&n<=r}],"filter->=":[B,[z,V],(e,[t,n])=>{let r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r>=i}],"filter-id->=":[B,[V],(e,[t])=>{let n=e.id(),r=t.value;return typeof n==typeof r&&n>=r}],"filter-has":[B,[V],(e,[t])=>t.value in e.properties()],"filter-has-id":[B,[],e=>e.id()!==null&&e.id()!==void 0],"filter-type-in":[B,[ot(z)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[B,[ot(V)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[B,[z,ot(V)],(e,[t,n])=>n.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[B,[z,ot(V)],(e,[t,n])=>function(e,t,n,r){for(;n<=r;){let i=n+r>>1;if(t[i]===e)return!0;t[i]>e?r=i-1:n=i+1}return!1}(e.properties()[t.value],n.value,0,n.value.length-1)],all:{type:B,overloads:[[[B,B],(e,[t,n])=>t.evaluate(e)&&n.evaluate(e)],[Rr(B),(e,t)=>{for(let n of t)if(!n.evaluate(e))return!1;return!0}]]},any:{type:B,overloads:[[[B,B],(e,[t,n])=>t.evaluate(e)||n.evaluate(e)],[Rr(B),(e,t)=>{for(let n of t)if(n.evaluate(e))return!0;return!1}]]},"!":[B,[B],(e,[t])=>!t.evaluate(e)],"is-supported-script":[B,[z],(e,[t])=>{let n=e.globals&&e.globals.isSupportedScript;return!n||n(t.evaluate(e))}],upcase:[z,[z],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[z,[z],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[z,Rr(V),(e,t)=>t.map((t=>W(t.evaluate(e)))).join(``)],"resolved-locale":[z,[$e],(e,[t])=>t.evaluate(e).resolvedLocale()]});class ni{constructor(e,t){this.expression=e,this._warningHistory={},this._evaluator=new en,this._defaultValue=t?function(e){if(e.type===`color`&&Jr(e.default))return new U(0,0,0,0);switch(e.type){case`color`:return U.parse(e.default)||null;case`padding`:return zt.parse(e.default)||null;case`numberArray`:return Bt.parse(e.default)||null;case`colorArray`:return Vt.parse(e.default)||null;case`variableAnchorOffsetCollection`:return Wt.parse(e.default)||null;case`projectionDefinition`:return Kt.parse(e.default)||null;default:return e.default===void 0?null:e.default}}(t):null,this._enumValues=t&&t.type===`enum`?t.values:null}evaluateWithoutErrorHandling(e,t,n,r,i,a){return this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=n,this._evaluator.canonical=r,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=a,this.expression.evaluate(this._evaluator)}evaluate(e,t,n,r,i,a){this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=n||null,this._evaluator.canonical=r,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=a||null;try{let e=this.expression.evaluate(this._evaluator);if(e==null||typeof e==`number`&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new Ht(`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,typeof console<`u`&&console.warn(e.message)),this._defaultValue}}}function ri(e){return Array.isArray(e)&&e.length>0&&typeof e[0]==`string`&&e[0]in Nr}function ii(e,t){let n=new tn(Nr,zr,[],t?function(e){let t={color:Xe,string:z,number:R,enum:z,boolean:B,formatted:et,padding:tt,numberArray:rt,colorArray:nt,projectionDefinition:Ze,resolvedImage:it,variableAnchorOffsetCollection:at};return e.type===`array`?ot(t[e.value]||V,e.length):t[e.type]}(t):void 0),r=n.parse(e,void 0,void 0,void 0,t&&t.type===`string`?{typeAnnotation:`coerce`}:void 0);return r?Ur(new ni(r,t)):Wr(n.errors)}class ai{constructor(e,t){this.kind=e,this._styleExpression=t,this.isStateDependent=e!==`constant`&&!Vr(t.expression),this.globalStateRefs=ui(t.expression)}evaluateWithoutErrorHandling(e,t,n,r,i,a){return this._styleExpression.evaluateWithoutErrorHandling(e,t,n,r,i,a)}evaluate(e,t,n,r,i,a){return this._styleExpression.evaluate(e,t,n,r,i,a)}}class oi{constructor(e,t,n,r){this.kind=e,this.zoomStops=n,this._styleExpression=t,this.isStateDependent=e!==`camera`&&!Vr(t.expression),this.globalStateRefs=ui(t.expression),this.interpolationType=r}evaluateWithoutErrorHandling(e,t,n,r,i,a){return this._styleExpression.evaluateWithoutErrorHandling(e,t,n,r,i,a)}evaluate(e,t,n,r,i,a){return this._styleExpression.evaluate(e,t,n,r,i,a)}interpolationFactor(e,t,n){return this.interpolationType?_n.interpolationFactor(this.interpolationType,e,t,n):0}}function si(e,t){let n=ii(e,t);if(n.result===`error`)return n;let r=n.value.expression,i=Br(r);if(!i&&!Gr(t))return Wr([new qe(``,`data expressions not supported`)]);let a=Hr(r,[`zoom`]);if(!a&&!Kr(t))return Wr([new qe(``,`zoom expressions not supported`)]);let o=li(r);return o||a?o instanceof qe?Wr([o]):o instanceof _n&&!qr(t)?Wr([new qe(``,`"interpolate" expressions cannot be used with this property`)]):Ur(o?new oi(i?`camera`:`composite`,n.value,o.labels,o instanceof _n?o.interpolation:void 0):new ai(i?`constant`:`source`,n.value)):Wr([new qe(``,`"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.`)])}class ci{constructor(e,t){this._parameters=e,this._specification=t,Ke(this,Xr(this._parameters,this._specification))}static deserialize(e){return new ci(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function li(e){let t=null;if(e instanceof nn)t=li(e.result);else if(e instanceof bn){for(let n of e.args)if(t=li(n),t)break}else (e instanceof fn||e instanceof _n)&&e.input instanceof Pr&&e.input.name===`zoom`&&(t=e);return t instanceof qe||e.eachChild((e=>{let n=li(e);n instanceof qe?t=n:!t&&n?t=new qe(``,`"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.`):t&&n&&t!==n&&(t=new qe(``,`Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.`))})),t}function ui(e,t=new Set){return e instanceof Mr&&t.add(e.key),e.eachChild((e=>{ui(e,t)})),t}function di(e){if(!0===e||!1===e)return!0;if(!Array.isArray(e)||e.length===0)return!1;switch(e[0]){case`has`:return e.length>=2&&e[1]!==`$id`&&e[1]!==`$type`;case`in`:return e.length>=3&&(typeof e[1]!=`string`||Array.isArray(e[2]));case`!in`:case`!has`:case`none`:return!1;case`==`:case`!=`:case`>`:case`>=`:case`<`:case`<=`:return e.length!==3||Array.isArray(e[1])||Array.isArray(e[2]);case`any`:case`all`:for(let t of e.slice(1))if(!di(t)&&typeof t!=`boolean`)return!1;return!0;default:return!0}}let fi={type:`boolean`,default:!1,transition:!1,"property-type":`data-driven`,expression:{interpolated:!1,parameters:[`zoom`,`feature`]}};function pi(e){if(e==null)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};di(e)||(e=gi(e));let t=ii(e,fi);if(t.result===`error`)throw Error(t.value.map((e=>`${e.key}: ${e.message}`)).join(`, `));return{filter:(e,n,r)=>t.value.evaluate(e,n,{},r),needGeometry:hi(e),getGlobalStateRefs:()=>ui(t.value.expression)}}function mi(e,t){return e<t?-1:e>t?1:0}function hi(e){if(!Array.isArray(e))return!1;if(e[0]===`within`||e[0]===`distance`)return!0;for(let t=1;t<e.length;t++)if(hi(e[t]))return!0;return!1}function gi(e){if(!e)return!0;let t=e[0];return e.length<=1?t!==`any`:t===`==`?_i(e[1],e[2],`==`):t===`!=`?bi(_i(e[1],e[2],`==`)):t===`<`||t===`>`||t===`<=`||t===`>=`?_i(e[1],e[2],t):t===`any`?(n=e.slice(1),[`any`].concat(n.map(gi))):t===`all`?[`all`].concat(e.slice(1).map(gi)):t===`none`?[`all`].concat(e.slice(1).map(gi).map(bi)):t===`in`?vi(e[1],e.slice(2)):t===`!in`?bi(vi(e[1],e.slice(2))):t===`has`?yi(e[1]):t!==`!has`||bi(yi(e[1]));var n}function _i(e,t,n){switch(e){case`$type`:return[`filter-type-${n}`,t];case`$id`:return[`filter-id-${n}`,t];default:return[`filter-${n}`,e,t]}}function vi(e,t){if(t.length===0)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(mi)]]:[`filter-in-small`,e,[`literal`,t]]}}function yi(e){switch(e){case`$type`:return!0;case`$id`:return[`filter-has-id`];default:return[`filter-has`,e]}}function bi(e){return[`!`,e]}function xi(e){let t=typeof e;if(t===`number`||t===`boolean`||t===`string`||e==null)return JSON.stringify(e);if(Array.isArray(e)){let t=`[`;for(let n of e)t+=`${xi(n)},`;return`${t}]`}let n=Object.keys(e).sort(),r=`{`;for(let t=0;t<n.length;t++)r+=`${JSON.stringify(n[t])}:${xi(e[n[t]])},`;return`${r}}`}function Si(e){let t=``;for(let n of Fe)t+=`/${xi(e[n])}`;return t}function Ci(e){let t=e.value;return t?[new L(e.key,t,`constants have been deprecated as of v8`)]:[]}function wi(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function Ti(e){if(Array.isArray(e))return e.map(Ti);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){let t={};for(let n in e)t[n]=Ti(e[n]);return t}return wi(e)}function Ei(e){let t=e.key,n=e.value,r=e.valueSpec||{},i=e.objectElementValidators||{},a=e.style,o=e.styleSpec,s=e.validateSpec,c=[],l=J(n);if(l!==`object`)return[new L(t,n,`object expected, ${l} found`)];for(let e in n){let l=e.split(`.`)[0],u=Ot(r,l)||r[`*`],d;if(Ot(i,l))d=i[l];else if(Ot(r,l))d=s;else if(i[`*`])d=i[`*`];else{if(!r[`*`]){c.push(new L(t,n[e],`unknown property "${e}"`));continue}d=s}c=c.concat(d({key:(t&&`${t}.`)+e,value:n[e],valueSpec:u,style:a,styleSpec:o,object:n,objectKey:e,validateSpec:s},n))}for(let e in r)i[e]||r[e].required&&r[e].default===void 0&&n[e]===void 0&&c.push(new L(t,n,`missing required property "${e}"`));return c}function Di(e){let t=e.value,n=e.valueSpec,r=e.style,i=e.styleSpec,a=e.key,o=e.arrayElementValidator||e.validateSpec;if(J(t)!==`array`)return[new L(a,t,`array expected, ${J(t)} found`)];if(n.length&&t.length!==n.length)return[new L(a,t,`array length ${n.length} expected, length ${t.length} found`)];if(n[`min-length`]&&t.length<n[`min-length`])return[new L(a,t,`array length at least ${n[`min-length`]} expected, length ${t.length} found`)];let s={type:n.value,values:n.values};i.$version<7&&(s.function=n.function),J(n.value)===`object`&&(s=n.value);let c=[];for(let n=0;n<t.length;n++)c=c.concat(o({array:t,arrayIndex:n,value:t[n],valueSpec:s,validateSpec:e.validateSpec,style:r,styleSpec:i,key:`${a}[${n}]`}));return c}function Oi(e){let t=e.key,n=e.value,r=e.valueSpec,i=J(n);return i===`number`&&n!=n&&(i=`NaN`),i===`number`?`minimum`in r&&n<r.minimum?[new L(t,n,`${n} is less than the minimum value ${r.minimum}`)]:`maximum`in r&&n>r.maximum?[new L(t,n,`${n} is greater than the maximum value ${r.maximum}`)]:[]:[new L(t,n,`number expected, ${i} found`)]}function ki(e){let t=e.valueSpec,n=wi(e.value.type),r,i,a,o={},s=n!==`categorical`&&e.value.property===void 0,c=!s,l=J(e.value.stops)===`array`&&J(e.value.stops[0])===`array`&&J(e.value.stops[0][0])===`object`,u=Ei({key:e.key,value:e.value,valueSpec:e.styleSpec.function,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if(n===`identity`)return[new L(e.key,e.value,`identity function may not have a "stops" property`)];let t=[],r=e.value;return t=t.concat(Di({key:e.key,value:r,valueSpec:e.valueSpec,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:d})),J(r)===`array`&&r.length===0&&t.push(new L(e.key,r,`array must have at least one stop`)),t},default:function(e){return e.validateSpec({key:e.key,value:e.value,valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec})}}});return n===`identity`&&s&&u.push(new L(e.key,e.value,`missing required property "property"`)),n===`identity`||e.value.stops||u.push(new L(e.key,e.value,`missing required property "stops"`)),n===`exponential`&&e.valueSpec.expression&&!qr(e.valueSpec)&&u.push(new L(e.key,e.value,`exponential functions not supported`)),e.styleSpec.$version>=8&&(c&&!Gr(e.valueSpec)?u.push(new L(e.key,e.value,`property functions not supported`)):s&&!Kr(e.valueSpec)&&u.push(new L(e.key,e.value,`zoom functions not supported`))),n!==`categorical`&&!l||e.value.property!==void 0||u.push(new L(e.key,e.value,`"property" property is required`)),u;function d(e){let n=[],r=e.value,s=e.key;if(J(r)!==`array`)return[new L(s,r,`array expected, ${J(r)} found`)];if(r.length!==2)return[new L(s,r,`array length 2 expected, length ${r.length} found`)];if(l){if(J(r[0])!==`object`)return[new L(s,r,`object expected, ${J(r[0])} found`)];if(r[0].zoom===void 0)return[new L(s,r,`object stop key must have zoom`)];if(r[0].value===void 0)return[new L(s,r,`object stop key must have value`)];if(a&&a>wi(r[0].zoom))return[new L(s,r[0].zoom,`stop zoom values must appear in ascending order`)];wi(r[0].zoom)!==a&&(a=wi(r[0].zoom),i=void 0,o={}),n=n.concat(Ei({key:`${s}[0]`,value:r[0],valueSpec:{zoom:{}},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:Oi,value:f}}))}else n=n.concat(f({key:`${s}[0]`,value:r[0],validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec},r));return ri(Ti(r[1]))?n.concat([new L(`${s}[1]`,r[1],`expressions are not allowed in function stops.`)]):n.concat(e.validateSpec({key:`${s}[1]`,value:r[1],valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec}))}function f(e,a){let s=J(e.value),c=wi(e.value),l=e.value===null?a:e.value;if(r){if(s!==r)return[new L(e.key,l,`${s} stop domain type must match previous stop domain type ${r}`)]}else r=s;if(s!==`number`&&s!==`string`&&s!==`boolean`)return[new L(e.key,l,`stop domain value must be a number, string, or boolean`)];if(s!==`number`&&n!==`categorical`){let r=`number expected, ${s} found`;return Gr(t)&&n===void 0&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new L(e.key,l,r)]}return n!==`categorical`||s!==`number`||isFinite(c)&&Math.floor(c)===c?n!==`categorical`&&s===`number`&&i!==void 0&&c<i?[new L(e.key,l,`stop domain values must appear in ascending order`)]:(i=c,n===`categorical`&&c in o?[new L(e.key,l,`stop domain values must be unique`)]:(o[c]=!0,[])):[new L(e.key,l,`integer expected, found ${c}`)]}}function Ai(e){let t=(e.expressionContext===`property`?si:ii)(Ti(e.value),e.valueSpec);if(t.result===`error`)return t.value.map((t=>new L(`${e.key}${t.key}`,e.value,t.message)));let n=t.value.expression||t.value._styleExpression.expression;if(e.expressionContext===`property`&&e.propertyKey===`text-font`&&!n.outputDefined())return[new L(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if(e.expressionContext===`property`&&e.propertyType===`layout`&&!Vr(n))return[new L(e.key,e.value,`"feature-state" data expressions are not supported with layout properties.`)];if(e.expressionContext===`filter`&&!Vr(n))return[new L(e.key,e.value,`"feature-state" data expressions are not supported with filters.`)];if(e.expressionContext&&e.expressionContext.indexOf(`cluster`)===0){if(!Hr(n,[`zoom`,`feature-state`]))return[new L(e.key,e.value,`"zoom" and "feature-state" expressions are not supported with cluster properties.`)];if(e.expressionContext===`cluster-initial`&&!Br(n))return[new L(e.key,e.value,`Feature data expressions are not supported with initial expression part of cluster properties.`)]}return[]}function ji(e){let t=e.key,n=e.value,r=J(n);return r===`string`?U.parse(String(n))?[]:[new L(t,n,`color expected, "${n}" found`)]:[new L(t,n,`color expected, ${r} found`)]}function Mi(e){let t=e.key,n=e.value,r=e.valueSpec,i=[];return Array.isArray(r.values)?r.values.indexOf(wi(n))===-1&&i.push(new L(t,n,`expected one of [${r.values.join(`, `)}], ${JSON.stringify(n)} found`)):Object.keys(r.values).indexOf(wi(n))===-1&&i.push(new L(t,n,`expected one of [${Object.keys(r.values).join(`, `)}], ${JSON.stringify(n)} found`)),i}function Ni(e){return di(Ti(e.value))?Ai(Ke({},e,{expressionContext:`filter`,valueSpec:{value:`boolean`}})):Pi(e)}function Pi(e){let t=e.value,n=e.key;if(J(t)!==`array`)return[new L(n,t,`array expected, ${J(t)} found`)];let r=e.styleSpec,i,a=[];if(t.length<1)return[new L(n,t,`filter array must have at least 1 element`)];switch(a=a.concat(Mi({key:`${n}[0]`,value:t[0],valueSpec:r.filter_operator,style:e.style,styleSpec:e.styleSpec})),wi(t[0])){case`<`:case`<=`:case`>`:case`>=`:t.length>=2&&wi(t[1])===`$type`&&a.push(new L(n,t,`"$type" cannot be use with operator "${t[0]}"`));case`==`:case`!=`:t.length!==3&&a.push(new L(n,t,`filter array for operator "${t[0]}" must have 3 elements`));case`in`:case`!in`:t.length>=2&&(i=J(t[1]),i!==`string`&&a.push(new L(`${n}[1]`,t[1],`string expected, ${i} found`)));for(let o=2;o<t.length;o++)i=J(t[o]),wi(t[1])===`$type`?a=a.concat(Mi({key:`${n}[${o}]`,value:t[o],valueSpec:r.geometry_type,style:e.style,styleSpec:e.styleSpec})):i!==`string`&&i!==`number`&&i!==`boolean`&&a.push(new L(`${n}[${o}]`,t[o],`string, number, or boolean expected, ${i} found`));break;case`any`:case`all`:case`none`:for(let r=1;r<t.length;r++)a=a.concat(Pi({key:`${n}[${r}]`,value:t[r],style:e.style,styleSpec:e.styleSpec}));break;case`has`:case`!has`:i=J(t[1]),t.length===2?i!==`string`&&a.push(new L(`${n}[1]`,t[1],`string expected, ${i} found`)):a.push(new L(n,t,`filter array for "${t[0]}" operator must have 2 elements`))}return a}function Fi(e,t){let n=e.key,r=e.validateSpec,i=e.style,a=e.styleSpec,o=e.value,s=e.objectKey,c=a[`${t}_${e.layerType}`];if(!c)return[];let l=s.match(/^(.*)-transition$/);if(t===`paint`&&l&&c[l[1]]&&c[l[1]].transition)return r({key:n,value:o,valueSpec:a.transition,style:i,styleSpec:a});let u=e.valueSpec||c[s];if(!u)return[new L(n,o,`unknown property "${s}"`)];let d;if(J(o)===`string`&&Gr(u)&&!u.tokens&&(d=/^{([^}]+)}$/.exec(o)))return[new L(n,o,`"${s}" does not support interpolation syntax\nUse an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(d[1])} }\`.`)];let f=[];return e.layerType===`symbol`&&(s===`text-field`&&i&&!i.glyphs&&f.push(new L(n,o,`use of "text-field" requires a style "glyphs" property`)),s===`text-font`&&Jr(Ti(o))&&wi(o.type)===`identity`&&f.push(new L(n,o,`"text-font" does not support identity functions`))),f.concat(r({key:e.key,value:o,valueSpec:u,style:i,styleSpec:a,expressionContext:`property`,propertyType:t,propertyKey:s}))}function Ii(e){return Fi(e,`paint`)}function Li(e){return Fi(e,`layout`)}function Ri(e){let t=[],n=e.value,r=e.key,i=e.style,a=e.styleSpec;if(J(n)!==`object`)return[new L(r,n,`object expected, ${J(n)} found`)];n.type||n.ref||t.push(new L(r,n,`either "type" or "ref" is required`));let o=wi(n.type),s=wi(n.ref);if(n.id){let a=wi(n.id);for(let o=0;o<e.arrayIndex;o++){let e=i.layers[o];wi(e.id)===a&&t.push(new L(r,n.id,`duplicate layer id "${n.id}", previously used at line ${e.id.__line__}`))}}if(`ref`in n){let e;[`type`,`source`,`source-layer`,`filter`,`layout`].forEach((e=>{e in n&&t.push(new L(r,n[e],`"${e}" is prohibited for ref layers`))})),i.layers.forEach((t=>{wi(t.id)===s&&(e=t)})),e?e.ref?t.push(new L(r,n.ref,`ref cannot reference another ref layer`)):o=wi(e.type):t.push(new L(r,n.ref,`ref layer "${s}" not found`))}else if(o!==`background`)if(n.source){let e=i.sources&&i.sources[n.source],a=e&&wi(e.type);e?a===`vector`&&o===`raster`?t.push(new L(r,n.source,`layer "${n.id}" requires a raster source`)):a!==`raster-dem`&&o===`hillshade`||a!==`raster-dem`&&o===`color-relief`?t.push(new L(r,n.source,`layer "${n.id}" requires a raster-dem source`)):a===`raster`&&o!==`raster`?t.push(new L(r,n.source,`layer "${n.id}" requires a vector source`)):a!==`vector`||n[`source-layer`]?a===`raster-dem`&&o!==`hillshade`&&o!==`color-relief`?t.push(new L(r,n.source,`raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.`)):o!==`line`||!n.paint||!n.paint[`line-gradient`]||a===`geojson`&&e.lineMetrics||t.push(new L(r,n,`layer "${n.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new L(r,n,`layer "${n.id}" must specify a "source-layer"`)):t.push(new L(r,n.source,`source "${n.source}" not found`))}else t.push(new L(r,n,`missing required property "source"`));return t=t.concat(Ei({key:r,value:n,valueSpec:a.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":()=>[],type:()=>e.validateSpec({key:`${r}.type`,value:n.type,valueSpec:a.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:n,objectKey:`type`}),filter:Ni,layout:e=>Ei({layer:n,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>Li(Ke({layerType:o},e))}}),paint:e=>Ei({layer:n,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>Ii(Ke({layerType:o},e))}})}})),t}function zi(e){let t=e.value,n=e.key,r=J(t);return r===`string`?[]:[new L(n,t,`string expected, ${r} found`)]}let Bi={promoteId:function({key:e,value:t}){if(J(t)===`string`)return zi({key:e,value:t});{let n=[];for(let r in t)n.push(...zi({key:`${e}.${r}`,value:t[r]}));return n}}};function Vi(e){let t=e.value,n=e.key,r=e.styleSpec,i=e.style,a=e.validateSpec;if(!t.type)return[new L(n,t,`"type" is required`)];let o=wi(t.type),s;switch(o){case`vector`:case`raster`:return s=Ei({key:n,value:t,valueSpec:r[`source_${o.replace(`-`,`_`)}`],style:e.style,styleSpec:r,objectElementValidators:Bi,validateSpec:a}),s;case`raster-dem`:return s=function(e){let t=e.sourceName??``,n=e.value,r=e.styleSpec,i=r.source_raster_dem,a=e.style,o=[],s=J(n);if(n===void 0)return o;if(s!==`object`)return o.push(new L(`source_raster_dem`,n,`object expected, ${s} found`)),o;let c=wi(n.encoding)===`custom`,l=[`redFactor`,`greenFactor`,`blueFactor`,`baseShift`],u=e.value.encoding?`"${e.value.encoding}"`:`Default`;for(let s in n)!c&&l.includes(s)?o.push(new L(s,n[s],`In "${t}": "${s}" is only valid when "encoding" is set to "custom". ${u} encoding found`)):i[s]?o=o.concat(e.validateSpec({key:s,value:n[s],valueSpec:i[s],validateSpec:e.validateSpec,style:a,styleSpec:r})):o.push(new L(s,n[s],`unknown property "${s}"`));return o}({sourceName:n,value:t,style:e.style,styleSpec:r,validateSpec:a}),s;case`geojson`:if(s=Ei({key:n,value:t,valueSpec:r.source_geojson,style:i,styleSpec:r,validateSpec:a,objectElementValidators:Bi}),t.cluster)for(let e in t.clusterProperties){let[r,i]=t.clusterProperties[e],a=typeof r==`string`?[r,[`accumulated`],[`get`,e]]:r;s.push(...Ai({key:`${n}.${e}.map`,value:i,expressionContext:`cluster-map`})),s.push(...Ai({key:`${n}.${e}.reduce`,value:a,expressionContext:`cluster-reduce`}))}return s;case`video`:return Ei({key:n,value:t,valueSpec:r.source_video,style:i,validateSpec:a,styleSpec:r});case`image`:return Ei({key:n,value:t,valueSpec:r.source_image,style:i,validateSpec:a,styleSpec:r});case`canvas`:return[new L(n,null,`Please use runtime APIs to add canvas sources, rather than including them in stylesheets.`,`source.canvas`)];default:return Mi({key:`${n}.type`,value:t.type,valueSpec:{values:[`vector`,`raster`,`raster-dem`,`geojson`,`video`,`image`]}})}}function Hi(e){let t=e.value,n=e.styleSpec,r=n.light,i=e.style,a=[],o=J(t);if(t===void 0)return a;if(o!==`object`)return a=a.concat([new L(`light`,t,`object expected, ${o} found`)]),a;for(let o in t){let s=o.match(/^(.*)-transition$/);a=a.concat(s&&r[s[1]]&&r[s[1]].transition?e.validateSpec({key:o,value:t[o],valueSpec:n.transition,validateSpec:e.validateSpec,style:i,styleSpec:n}):r[o]?e.validateSpec({key:o,value:t[o],valueSpec:r[o],validateSpec:e.validateSpec,style:i,styleSpec:n}):[new L(o,t[o],`unknown property "${o}"`)])}return a}function Ui(e){let t=e.value,n=e.styleSpec,r=n.sky,i=e.style,a=J(t);if(t===void 0)return[];if(a!==`object`)return[new L(`sky`,t,`object expected, ${a} found`)];let o=[];for(let a in t)o=o.concat(r[a]?e.validateSpec({key:a,value:t[a],valueSpec:r[a],style:i,styleSpec:n}):[new L(a,t[a],`unknown property "${a}"`)]);return o}function Wi(e){let t=e.value,n=e.styleSpec,r=n.terrain,i=e.style,a=[],o=J(t);if(t===void 0)return a;if(o!==`object`)return a=a.concat([new L(`terrain`,t,`object expected, ${o} found`)]),a;for(let o in t)a=a.concat(r[o]?e.validateSpec({key:o,value:t[o],valueSpec:r[o],validateSpec:e.validateSpec,style:i,styleSpec:n}):[new L(o,t[o],`unknown property "${o}"`)]);return a}function Gi(e){let t=[],n=e.value,r=e.key;if(Array.isArray(n)){let i=[],a=[];for(let o in n)n[o].id&&i.includes(n[o].id)&&t.push(new L(r,n,`all the sprites' ids must be unique, but ${n[o].id} is duplicated`)),i.push(n[o].id),n[o].url&&a.includes(n[o].url)&&t.push(new L(r,n,`all the sprites' URLs must be unique, but ${n[o].url} is duplicated`)),a.push(n[o].url),t=t.concat(Ei({key:`${r}[${o}]`,value:n[o],valueSpec:{id:{type:`string`,required:!0},url:{type:`string`,required:!0}},validateSpec:e.validateSpec}));return t}return zi({key:r,value:n})}function Ki(e){return t=e.value,t&&t.constructor===Object?[]:[new L(e.key,e.value,`object expected, ${J(e.value)} found`)];var t}let qi={"*":()=>[],array:Di,boolean:function(e){let t=e.value,n=e.key,r=J(t);return r===`boolean`?[]:[new L(n,t,`boolean expected, ${r} found`)]},number:Oi,color:ji,constants:Ci,enum:Mi,filter:Ni,function:ki,layer:Ri,object:Ei,source:Vi,light:Hi,sky:Ui,terrain:Wi,projection:function(e){let t=e.value,n=e.styleSpec,r=n.projection,i=e.style,a=J(t);if(t===void 0)return[];if(a!==`object`)return[new L(`projection`,t,`object expected, ${a} found`)];let o=[];for(let a in t)o=o.concat(r[a]?e.validateSpec({key:a,value:t[a],valueSpec:r[a],style:i,styleSpec:n}):[new L(a,t[a],`unknown property "${a}"`)]);return o},projectionDefinition:function(e){let t=e.key,n=e.value;n=n instanceof String?n.valueOf():n;let r=J(n);return r!==`array`||function(e){return Array.isArray(e)&&e.length===3&&typeof e[0]==`string`&&typeof e[1]==`string`&&typeof e[2]==`number`}(n)||function(e){return!![`interpolate`,`step`,`literal`].includes(e[0])}(n)?[`array`,`string`].includes(r)?[]:[new L(t,n,`projection expected, invalid type "${r}" found`)]:[new L(t,n,`projection expected, invalid array ${JSON.stringify(n)} found`)]},string:zi,formatted:function(e){return zi(e).length===0?[]:Ai(e)},resolvedImage:function(e){return zi(e).length===0?[]:Ai(e)},padding:function(e){let t=e.key,n=e.value;if(J(n)===`array`){if(n.length<1||n.length>4)return[new L(t,n,`padding requires 1 to 4 values; ${n.length} values found`)];let r={type:`number`},i=[];for(let a=0;a<n.length;a++)i=i.concat(e.validateSpec({key:`${t}[${a}]`,value:n[a],validateSpec:e.validateSpec,valueSpec:r}));return i}return Oi({key:t,value:n,valueSpec:{}})},numberArray:function(e){let t=e.key,n=e.value;if(J(n)===`array`){let r={type:`number`};if(n.length<1)return[new L(t,n,`array length at least 1 expected, length 0 found`)];let i=[];for(let a=0;a<n.length;a++)i=i.concat(e.validateSpec({key:`${t}[${a}]`,value:n[a],validateSpec:e.validateSpec,valueSpec:r}));return i}return Oi({key:t,value:n,valueSpec:{}})},colorArray:function(e){let t=e.key,n=e.value;if(J(n)===`array`){if(n.length<1)return[new L(t,n,`array length at least 1 expected, length 0 found`)];let e=[];for(let r=0;r<n.length;r++)e=e.concat(ji({key:`${t}[${r}]`,value:n[r]}));return e}return ji({key:t,value:n})},variableAnchorOffsetCollection:function(e){let t=e.key,n=e.value,r=J(n),i=e.styleSpec;if(r!==`array`||n.length<1||n.length%2!=0)return[new L(t,n,`variableAnchorOffsetCollection requires a non-empty array of even length`)];let a=[];for(let r=0;r<n.length;r+=2)a=a.concat(Mi({key:`${t}[${r}]`,value:n[r],valueSpec:i.layout_symbol[`text-anchor`]})),a=a.concat(Di({key:`${t}[${r+1}]`,value:n[r+1],valueSpec:{length:2,value:`number`},validateSpec:e.validateSpec,style:e.style,styleSpec:i}));return a},sprite:Gi,state:Ki};function Ji(e){let t=e.value,n=e.valueSpec,r=e.styleSpec;return e.validateSpec=Ji,n.expression&&Jr(wi(t))?ki(e):n.expression&&ri(Ti(t))?Ai(e):n.type&&qi[n.type]?qi[n.type](e):Ei(Ke({},e,{valueSpec:n.type?r[n.type]:n}))}function Yi(e){let t=e.value,n=e.key,r=zi(e);return r.length||(t.indexOf(`{fontstack}`)===-1&&r.push(new L(n,t,`"glyphs" url must include a "{fontstack}" token`)),t.indexOf(`{range}`)===-1&&r.push(new L(n,t,`"glyphs" url must include a "{range}" token`))),r}function Xi(e,t=I){let n=[];return n=n.concat(Ji({key:``,value:e,valueSpec:t.$root,styleSpec:t,style:e,validateSpec:Ji,objectElementValidators:{glyphs:Yi,"*":()=>[]}})),e.constants&&(n=n.concat(Ci({key:`constants`,value:e.constants}))),Qi(n)}function Zi(e){return function(t){return e({...t,validateSpec:Ji})}}function Qi(e){return[].concat(e).sort(((e,t)=>e.line-t.line))}function $i(e){return function(...t){return Qi(e.apply(this,t))}}Xi.source=$i(Zi(Vi)),Xi.sprite=$i(Zi(Gi)),Xi.glyphs=$i(Zi(Yi)),Xi.light=$i(Zi(Hi)),Xi.sky=$i(Zi(Ui)),Xi.terrain=$i(Zi(Wi)),Xi.state=$i(Zi(Ki)),Xi.layer=$i(Zi(Ri)),Xi.filter=$i(Zi(Ni)),Xi.paintProperty=$i(Zi(Ii)),Xi.layoutProperty=$i(Zi(Li));let ea=Xi,ta=ea.light,na=ea.sky,ra=ea.paintProperty,ia=ea.layoutProperty;function aa(e,t){let n=!1;if(t&&t.length)for(let r of t)e.fire(new Ne(Error(r.message))),n=!0;return n}class oa{constructor(e,t,n){let r=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;let i=new Int32Array(this.arrayBuffer);e=i[0],this.d=(t=i[1])+2*(n=i[2]);for(let e=0;e<this.d*this.d;e++){let t=i[3+e],n=i[3+e+1];r.push(t===n?null:i.subarray(t,n))}let a=i[3+r.length+1];this.keys=i.subarray(i[3+r.length],a),this.bboxes=i.subarray(a),this.insert=this._insertReadonly}else{this.d=t+2*n;for(let e=0;e<this.d*this.d;e++)r.push([]);this.keys=[],this.bboxes=[]}this.n=t,this.extent=e,this.padding=n,this.scale=t/e,this.uid=0;let i=n/t*e;this.min=-i,this.max=e+i}insert(e,t,n,r,i){this._forEachCell(t,n,r,i,this._insertCell,this.uid++,void 0,void 0),this.keys.push(e),this.bboxes.push(t),this.bboxes.push(n),this.bboxes.push(r),this.bboxes.push(i)}_insertReadonly(){throw Error(`Cannot insert into a GridIndex created from an ArrayBuffer.`)}_insertCell(e,t,n,r,i,a){this.cells[i].push(a)}query(e,t,n,r,i,a){let o=this.min,s=this.max;if(a||e<=o&&t<=o&&s<=n&&s<=r&&!i)return Array.prototype.slice.call(this.keys);{let a=[];return this._forEachCell(e,t,n,r,this._queryCell,a,{},i),a}}_queryCell(e,t,n,r,i,a,o,s){let c=this.cells[i];if(c!==null){let i=this.keys,l=this.bboxes;for(let u=0;u<c.length;u++){let d=c[u];if(o[d]===void 0){let c=4*d;(s?s(l[c+0],l[c+1],l[c+2],l[c+3]):e<=l[c+2]&&t<=l[c+3]&&n>=l[c+0]&&r>=l[c+1])?(o[d]=!0,a.push(i[d])):o[d]=!1}}}}_forEachCell(e,t,n,r,i,a,o,s){let c=this._convertToCellCoord(e),l=this._convertToCellCoord(t),u=this._convertToCellCoord(n),d=this._convertToCellCoord(r);for(let f=c;f<=u;f++)for(let c=l;c<=d;c++){let l=this.d*c+f;if((!s||s(this._convertFromCellCoord(f),this._convertFromCellCoord(c),this._convertFromCellCoord(f+1),this._convertFromCellCoord(c+1)))&&i.call(this,e,t,n,r,l,a,o,s))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;let e=this.cells,t=3+this.cells.length+1+1,n=0;for(let e=0;e<this.cells.length;e++)n+=this.cells[e].length;let r=new Int32Array(t+n+this.keys.length+this.bboxes.length);r[0]=this.extent,r[1]=this.n,r[2]=this.padding;let i=t;for(let t=0;t<e.length;t++){let n=e[t];r[3+t]=i,r.set(n,i),i+=n.length}return r[3+e.length]=i,r.set(this.keys,i),i+=this.keys.length,r[3+e.length+1]=i,r.set(this.bboxes,i),i+=this.bboxes.length,r.buffer}static serialize(e,t){let n=e.toArrayBuffer();return t&&t.push(n),{buffer:n}}static deserialize(e){return new oa(e.buffer)}}let sa={};function Y(e,t,n={}){if(sa[e])throw Error(`${e} is already registered.`);Object.defineProperty(t,`_classRegistryKey`,{value:e,writeable:!1}),sa[e]={klass:t,omit:n.omit||[],shallow:n.shallow||[]}}Y(`Object`,Object),Y(`Set`,Set),Y(`TransferableGridIndex`,oa),Y(`Color`,U),Y(`Error`,Error),Y(`AJAXError`,Ee),Y(`ResolvedImage`,Gt),Y(`StylePropertyFunction`,ci),Y(`StyleExpression`,ni,{omit:[`_evaluator`]}),Y(`ZoomDependentExpression`,oi),Y(`ZoomConstantExpression`,ai),Y(`CompoundExpression`,Pr,{omit:[`_evaluate`]});for(let e in Nr)Nr[e]._classRegistryKey||Y(`Expression_${e}`,Nr[e]);function ca(e){return e&&typeof ArrayBuffer<`u`&&(e instanceof ArrayBuffer||e.constructor&&e.constructor.name===`ArrayBuffer`)}function la(e){return e.$name||e.constructor._classRegistryKey}function ua(e){return!function(e){if(typeof e!=`object`||!e)return!1;let t=la(e);return!(!t||t===`Object`)}(e)&&(e==null||typeof e==`boolean`||typeof e==`number`||typeof e==`string`||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp||e instanceof Blob||e instanceof Error||ca(e)||de(e)||ArrayBuffer.isView(e)||e instanceof ImageData)}function da(e,t){if(ua(e))return(ca(e)||de(e))&&t&&t.push(e),ArrayBuffer.isView(e)&&t&&t.push(e.buffer),e instanceof ImageData&&t&&t.push(e.data.buffer),e;if(Array.isArray(e)){let n=[];for(let r of e)n.push(da(r,t));return n}if(typeof e!=`object`)throw Error(`can't serialize object of type `+typeof e);let n=la(e);if(!n)throw Error(`can't serialize object of unregistered class ${e.constructor.name}`);if(!sa[n])throw Error(`${n} is not registered.`);let{klass:r}=sa[n],i=r.serialize?r.serialize(e,t):{};if(r.serialize){if(t&&i===t[t.length-1])throw Error(`statically serialized object won't survive transfer of $name property`)}else{for(let r in e){if(!e.hasOwnProperty(r)||sa[n].omit.indexOf(r)>=0)continue;let a=e[r];i[r]=sa[n].shallow.indexOf(r)>=0?a:da(a,t)}e instanceof Error&&(i.message=e.message)}if(i.$name)throw Error(`$name property is reserved for worker serialization logic.`);return n!==`Object`&&(i.$name=n),i}function fa(e){if(ua(e))return e;if(Array.isArray(e))return e.map(fa);if(typeof e!=`object`)throw Error(`can't deserialize object of type `+typeof e);let t=la(e)||`Object`;if(!sa[t])throw Error(`can't deserialize unregistered class ${t}`);let{klass:n}=sa[t];if(!n)throw Error(`can't deserialize unregistered class ${t}`);if(n.deserialize)return n.deserialize(e);let r=Object.create(n.prototype);for(let n of Object.keys(e)){if(n===`$name`)continue;let i=e[n];r[n]=sa[t].shallow.indexOf(n)>=0?i:fa(i)}return r}class X{constructor(){this.first=!0}update(e,t){let n=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=n,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=n,!0):(this.lastFloorZoom>n?(this.lastIntegerZoom=n+1,this.lastIntegerZoomTime=t):this.lastFloorZoom<n&&(this.lastIntegerZoom=n,this.lastIntegerZoomTime=t),e!==this.lastZoom&&(this.lastZoom=e,this.lastFloorZoom=n,!0))}}let Z={"Latin-1 Supplement":e=>e>=128&&e<=255,"Hangul Jamo":e=>e>=4352&&e<=4607,Khmer:e=>e>=6016&&e<=6143,"General Punctuation":e=>e>=8192&&e<=8303,"Letterlike Symbols":e=>e>=8448&&e<=8527,"Number Forms":e=>e>=8528&&e<=8591,"Miscellaneous Technical":e=>e>=8960&&e<=9215,"Control Pictures":e=>e>=9216&&e<=9279,"Optical Character Recognition":e=>e>=9280&&e<=9311,"Enclosed Alphanumerics":e=>e>=9312&&e<=9471,"Geometric Shapes":e=>e>=9632&&e<=9727,"Miscellaneous Symbols":e=>e>=9728&&e<=9983,"Miscellaneous Symbols and Arrows":e=>e>=11008&&e<=11263,"Ideographic Description Characters":e=>e>=12272&&e<=12287,"CJK Symbols and Punctuation":e=>e>=12288&&e<=12351,Hiragana:e=>e>=12352&&e<=12447,Katakana:e=>e>=12448&&e<=12543,Kanbun:e=>e>=12688&&e<=12703,"CJK Strokes":e=>e>=12736&&e<=12783,"Enclosed CJK Letters and Months":e=>e>=12800&&e<=13055,"CJK Compatibility":e=>e>=13056&&e<=13311,"Yijing Hexagram Symbols":e=>e>=19904&&e<=19967,"CJK Unified Ideographs":e=>e>=19968&&e<=40959,"Hangul Syllables":e=>e>=44032&&e<=55215,"Private Use Area":e=>e>=57344&&e<=63743,"Vertical Forms":e=>e>=65040&&e<=65055,"CJK Compatibility Forms":e=>e>=65072&&e<=65103,"Small Form Variants":e=>e>=65104&&e<=65135,"Halfwidth and Fullwidth Forms":e=>e>=65280&&e<=65519};function pa(e){for(let t of e)if(ya(t.charCodeAt(0)))return!0;return!1}function ma(e){for(let t of e)if(!_a(t.charCodeAt(0)))return!1;return!0}function ha(e){let t=e.map((e=>{try{return RegExp(`\\p{sc=${e}}`,`u`).source}catch{return null}})).filter((e=>e));return new RegExp(t.join(`|`),`u`)}let ga=ha([`Arab`,`Dupl`,`Mong`,`Ougr`,`Syrc`]);function _a(e){return!ga.test(String.fromCodePoint(e))}let va=ha([`Bopo`,`Hani`,`Hira`,`Kana`,`Kits`,`Nshu`,`Tang`,`Yiii`]);function ya(e){return!(e!==746&&e!==747&&(e<4352||!(Z[`CJK Compatibility Forms`](e)&&!(e>=65097&&e<=65103)||Z[`CJK Compatibility`](e)||Z[`CJK Strokes`](e)||!(!Z[`CJK Symbols and Punctuation`](e)||e>=12296&&e<=12305||e>=12308&&e<=12319||e===12336)||Z[`Enclosed CJK Letters and Months`](e)||Z[`Ideographic Description Characters`](e)||Z.Kanbun(e)||Z.Katakana(e)&&e!==12540||!(!Z[`Halfwidth and Fullwidth Forms`](e)||e===65288||e===65289||e===65293||e>=65306&&e<=65310||e===65339||e===65341||e===65343||e>=65371&&e<=65503||e===65507||e>=65512&&e<=65519)||!(!Z[`Small Form Variants`](e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||Z[`Vertical Forms`](e)||Z[`Yijing Hexagram Symbols`](e)||/\p{sc=Cans}/u.test(String.fromCodePoint(e))||/\p{sc=Hang}/u.test(String.fromCodePoint(e))||va.test(String.fromCodePoint(e)))))}function ba(e){return!(ya(e)||function(e){return!!(Z[`Latin-1 Supplement`](e)&&(e===167||e===169||e===174||e===177||e===188||e===189||e===190||e===215||e===247)||Z[`General Punctuation`](e)&&(e===8214||e===8224||e===8225||e===8240||e===8241||e===8251||e===8252||e===8258||e===8263||e===8264||e===8265||e===8273)||Z[`Letterlike Symbols`](e)||Z[`Number Forms`](e)||Z[`Miscellaneous Technical`](e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||e===9003||e>=9085&&e<=9114||e>=9150&&e<=9165||e===9167||e>=9169&&e<=9179||e>=9186&&e<=9215)||Z[`Control Pictures`](e)&&e!==9251||Z[`Optical Character Recognition`](e)||Z[`Enclosed Alphanumerics`](e)||Z[`Geometric Shapes`](e)||Z[`Miscellaneous Symbols`](e)&&!(e>=9754&&e<=9759)||Z[`Miscellaneous Symbols and Arrows`](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||Z[`CJK Symbols and Punctuation`](e)||Z.Katakana(e)||Z[`Private Use Area`](e)||Z[`CJK Compatibility Forms`](e)||Z[`Small Form Variants`](e)||Z[`Halfwidth and Fullwidth Forms`](e)||e===8734||e===8756||e===8757||e>=9984&&e<=10087||e>=10102&&e<=10131||e===65532||e===65533)}(e))}let xa=ha(`Adlm.Arab.Armi.Avst.Chrs.Cprt.Egyp.Elym.Gara.Hatr.Hebr.Hung.Khar.Lydi.Mand.Mani.Mend.Merc.Mero.Narb.Nbat.Nkoo.Orkh.Palm.Phli.Phlp.Phnx.Prti.Rohg.Samr.Sarb.Sogo.Syrc.Thaa.Todr.Yezi`.split(`.`));function Sa(e){return xa.test(String.fromCodePoint(e))}function Ca(e,t){return!(!t&&Sa(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||Z.Khmer(e))}function wa(e){for(let t of e)if(Sa(t.charCodeAt(0)))return!0;return!1}let Ta=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus=`unavailable`,this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(e){this.pluginStatus=e.pluginStatus,this.pluginURL=e.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(e){if(Ta.isParsed())throw Error(`RTL text plugin already registered.`);this.applyArabicShaping=e.applyArabicShaping,this.processBidirectionalText=e.processBidirectionalText,this.processStyledBidirectionalText=e.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return this.applyArabicShaping!=null&&this.processBidirectionalText!=null&&this.processStyledBidirectionalText!=null}getRTLTextPluginStatus(){return this.pluginStatus}syncState(e,n){return t(this,void 0,void 0,(function*(){if(this.isParsed())return this.getState();if(e.pluginStatus!==`loading`)return this.setState(e),e;let t=e.pluginURL,r=new Promise((e=>{this.loadScriptResolve=e}));n(t);let i=new Promise((e=>setTimeout((()=>e()),this.TIMEOUT)));if(yield Promise.race([r,i]),this.isParsed()){let e={pluginStatus:`loaded`,pluginURL:t};return this.setState(e),e}throw this.setState({pluginStatus:`error`,pluginURL:``}),Error(`RTL Text Plugin failed to import scripts from ${t}`)}))}};class Ea{constructor(e,t){this.zoom=e,t?(this.now=t.now||0,this.fadeDuration=t.fadeDuration||0,this.zoomHistory=t.zoomHistory||new X,this.transition=t.transition||{},this.globalState=t.globalState||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new X,this.transition={},this.globalState={})}isSupportedScript(e){return function(e,t){for(let n of e)if(!Ca(n.charCodeAt(0),t))return!1;return!0}(e,Ta.getRTLTextPluginStatus()===`loaded`)}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){let e=this.zoom,t=e-Math.floor(e),n=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:t+(1-t)*n}:{fromScale:.5,toScale:1,t:1-(1-n)*t}}}class Da{constructor(e,t){this.property=e,this.value=t,this.expression=function(e,t){if(Jr(e))return new ci(e,t);if(ri(e)){let n=si(e,t);if(n.result===`error`)throw Error(n.value.map((e=>`${e.key}: ${e.message}`)).join(`, `));return n.value}{let n=e;return t.type===`color`&&typeof e==`string`?n=U.parse(e):t.type!==`padding`||typeof e!=`number`&&!Array.isArray(e)?t.type!==`numberArray`||typeof e!=`number`&&!Array.isArray(e)?t.type!==`colorArray`||typeof e!=`string`&&!Array.isArray(e)?t.type===`variableAnchorOffsetCollection`&&Array.isArray(e)?n=Wt.parse(e):t.type===`projectionDefinition`&&typeof e==`string`&&(n=Kt.parse(e)):n=Vt.parse(e):n=Bt.parse(e):n=zt.parse(e),{globalStateRefs:new Set,kind:`constant`,evaluate:()=>n}}}(t===void 0?e.specification.default:t,e.specification)}isDataDriven(){return this.expression.kind===`source`||this.expression.kind===`composite`}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(e,t,n){return this.property.possiblyEvaluate(this,e,t,n)}}class Oa{constructor(e){this.property=e,this.value=new Da(e,void 0)}transitioned(e,t){return new Aa(this.property,this.value,t,F({},e.transition,this.transition),e.now)}untransitioned(){return new Aa(this.property,this.value,null,{},0)}}class ka{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return ae(this._values[e].value.value)}setValue(e,t){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Oa(this._values[e].property)),this._values[e].value=new Da(this._values[e].property,t===null?void 0:ae(t))}getTransition(e){return ae(this._values[e].transition)}setTransition(e,t){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Oa(this._values[e].property)),this._values[e].transition=ae(t)||void 0}serialize(){let e={};for(let t of Object.keys(this._values)){let n=this.getValue(t);n!==void 0&&(e[t]=n);let r=this.getTransition(t);r!==void 0&&(e[`${t}-transition`]=r)}return e}transitioned(e,t){let n=new ja(this._properties);for(let r of Object.keys(this._values))n._values[r]=this._values[r].transitioned(e,t._values[r]);return n}untransitioned(){let e=new ja(this._properties);for(let t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class Aa{constructor(e,t,n,r,i){this.property=e,this.value=t,this.begin=i+r.delay||0,this.end=this.begin+r.duration||0,e.specification.transition&&(r.delay||r.duration)&&(this.prior=n)}possiblyEvaluate(e,t,n){let r=e.now||0,i=this.value.possiblyEvaluate(e,t,n),a=this.prior;if(a){if(r>this.end||this.value.isDataDriven())return this.prior=null,i;if(r<this.begin)return a.possiblyEvaluate(e,t,n);{let o=(r-this.begin)/(this.end-this.begin);return this.property.interpolate(a.possiblyEvaluate(e,t,n),i,M(o))}}return i}}class ja{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,t,n){let r=new Pa(this._properties);for(let i of Object.keys(this._values))r._values[i]=this._values[i].possiblyEvaluate(e,t,n);return r}hasTransition(){for(let e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class Ma{constructor(e){this._properties=e,this._values=Object.create(e.defaultPropertyValues)}hasValue(e){return this._values[e].value!==void 0}getValue(e){return ae(this._values[e].value)}setValue(e,t){this._values[e]=new Da(this._values[e].property,t===null?void 0:ae(t))}serialize(){let e={};for(let t of Object.keys(this._values)){let n=this.getValue(t);n!==void 0&&(e[t]=n)}return e}possiblyEvaluate(e,t,n){let r=new Pa(this._properties);for(let i of Object.keys(this._values)){let a=i===`text-letter-spacing`?F({},e,{zoom:Math.floor(e.zoom)}):e;r._values[i]=this._values[i].possiblyEvaluate(a,t,n)}return r}}class Na{constructor(e,t,n){this.property=e,this.value=t,this.parameters=n}isConstant(){return this.value.kind===`constant`}constantOr(e){return this.value.kind===`constant`?this.value.value:e}evaluate(e,t,n,r){return this.property.evaluate(this.value,this.parameters,e,t,n,r)}}class Pa{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class Q{constructor(e){this.specification=e}possiblyEvaluate(e,t){if(e.isDataDriven())throw Error(`Value should not be data driven`);return e.expression.evaluate(t)}interpolate(e,t,n){let r=yn[this.specification.type];return r?r(e,t,n):e}}class ${constructor(e,t){this.specification=e,this.overrides=t}possiblyEvaluate(e,t,n,r){return new Na(this,e.expression.kind===`constant`||e.expression.kind===`camera`?{kind:`constant`,value:e.expression.evaluate(t,null,{},n,r)}:e.expression,t)}interpolate(e,t,n){if(e.value.kind!==`constant`||t.value.kind!==`constant`)return e;if(e.value.value===void 0||t.value.value===void 0)return new Na(this,{kind:`constant`,value:void 0},e.parameters);let r=yn[this.specification.type];if(r){let i=r(e.value.value,t.value.value,n);return new Na(this,{kind:`constant`,value:i},e.parameters)}return e}evaluate(e,t,n,r,i,a){return e.kind===`constant`?e.value:e.evaluate(t,n,r,i,a)}}class Fa extends ${possiblyEvaluate(e,t,n,r){if(e.value===void 0)return new Na(this,{kind:`constant`,value:void 0},t);if(e.expression.kind===`constant`){let i=e.expression.evaluate(t,null,{},n,r),a=e.property.specification.type===`resolvedImage`&&typeof i!=`string`?i.name:i,o=this._calculate(a,a,a,t);return new Na(this,{kind:`constant`,value:o},t)}if(e.expression.kind===`camera`){let n=this._calculate(e.expression.evaluate({zoom:t.zoom-1}),e.expression.evaluate({zoom:t.zoom}),e.expression.evaluate({zoom:t.zoom+1}),t);return new Na(this,{kind:`constant`,value:n},t)}return new Na(this,e.expression,t)}evaluate(e,t,n,r,i,a){if(e.kind===`source`){let o=e.evaluate(t,n,r,i,a);return this._calculate(o,o,o,t)}return e.kind===`composite`?this._calculate(e.evaluate({zoom:Math.floor(t.zoom)-1},n,r),e.evaluate({zoom:Math.floor(t.zoom)},n,r),e.evaluate({zoom:Math.floor(t.zoom)+1},n,r),t):e.value}_calculate(e,t,n,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:n,to:t}}interpolate(e){return e}}class Ia{constructor(e){this.specification=e}possiblyEvaluate(e,t,n,r){if(e.value!==void 0){if(e.expression.kind===`constant`){let i=e.expression.evaluate(t,null,{},n,r);return this._calculate(i,i,i,t)}return this._calculate(e.expression.evaluate(new Ea(Math.floor(t.zoom-1),t)),e.expression.evaluate(new Ea(Math.floor(t.zoom),t)),e.expression.evaluate(new Ea(Math.floor(t.zoom+1),t)),t)}}_calculate(e,t,n,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:n,to:t}}interpolate(e){return e}}class La{constructor(e){this.specification=e}possiblyEvaluate(e,t,n,r){return!!e.expression.evaluate(t,null,{},n,r)}interpolate(){return!1}}class Ra{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(let t in e){let n=e[t];n.specification.overridable&&this.overridableProperties.push(t);let r=this.defaultPropertyValues[t]=new Da(n,void 0),i=this.defaultTransitionablePropertyValues[t]=new Oa(n);this.defaultTransitioningPropertyValues[t]=i.untransitioned(),this.defaultPossiblyEvaluatedValues[t]=r.possiblyEvaluate({})}}}Y(`DataDrivenProperty`,$),Y(`DataConstantProperty`,Q),Y(`CrossFadedDataDrivenProperty`,Fa),Y(`CrossFadedProperty`,Ia),Y(`ColorRampProperty`,La);let za=`-transition`;class Ba extends Pe{constructor(e,t){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},e.type!==`custom`&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type!==`background`&&(this.source=e.source,this.sourceLayer=e[`source-layer`],this.filter=e.filter,this._featureFilter=pi(e.filter)),t.layout&&(this._unevaluatedLayout=new Ma(t.layout)),t.paint)){this._transitionablePaint=new ka(t.paint);for(let t in e.paint)this.setPaintProperty(t,e.paint[t],{validate:!1});for(let t in e.layout)this.setLayoutProperty(t,e.layout[t],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Pa(t.paint)}}setFilter(e){this.filter=e,this._featureFilter=pi(e)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return e===`visibility`?this.visibility:this._unevaluatedLayout.getValue(e)}getLayoutAffectingGlobalStateRefs(){let e=new Set;if(this._unevaluatedLayout)for(let t in this._unevaluatedLayout._values){let n=this._unevaluatedLayout._values[t];for(let t of n.getGlobalStateRefs())e.add(t)}for(let t of this._featureFilter.getGlobalStateRefs())e.add(t);return e}getPaintAffectingGlobalStateRefs(){let e=new globalThis.Map;if(this._transitionablePaint)for(let t in this._transitionablePaint._values){let n=this._transitionablePaint._values[t].value;for(let r of n.getGlobalStateRefs()){let i=e.get(r)??[];i.push({name:t,value:n.value}),e.set(r,i)}}return e}setLayoutProperty(e,t,n={}){t!=null&&this._validate(ia,`layers.${this.id}.layout.${e}`,e,t,n)||(e===`visibility`?this.visibility=t:this._unevaluatedLayout.setValue(e,t))}getPaintProperty(e){return e.endsWith(za)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,t,n={}){if(t!=null&&this._validate(ra,`layers.${this.id}.paint.${e}`,e,t,n))return!1;if(e.endsWith(za))return this._transitionablePaint.setTransition(e.slice(0,-11),t||void 0),!1;{let n=this._transitionablePaint._values[e],r=n.property.specification[`property-type`]===`cross-faded-data-driven`,i=n.value.isDataDriven(),a=n.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);let o=this._transitionablePaint._values[e].value;return o.isDataDriven()||i||r||this._handleOverridablePaintPropertyUpdate(e,a,o)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,t,n){return!1}isHidden(e){return!!(this.minzoom&&e<this.minzoom)||!!(this.maxzoom&&e>=this.maxzoom)||this.visibility===`none`}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,t){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){let e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),ie(e,((e,t)=>!(e===void 0||t===`layout`&&!Object.keys(e).length||t===`paint`&&!Object.keys(e).length)))}_validate(e,t,n,r,i={}){return(!i||!1!==i.validate)&&aa(this,e.call(ea,{key:t,layerType:this.type,objectKey:n,value:r,styleSpec:I,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(let e in this.paint._values){let t=this.paint.get(e);if(t instanceof Na&&Gr(t.property.specification)&&(t.value.kind===`source`||t.value.kind===`composite`)&&t.value.isStateDependent)return!0}return!1}}let Va={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Ha{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Ua{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,t){return e._trim(),t&&(e.isTransferred=!0,t.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){let 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);let t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}_refreshViews(){throw Error(`_refreshViews() must be implemented by each concrete StructArray layout`)}}function Wa(e,t=1){let n=0,r=0;return{members:e.map((e=>{let i=Va[e.type].BYTES_PER_ELEMENT,a=n=Ga(n,Math.max(t,i)),o=e.components||1;return r=Math.max(r,i),n+=i*o,{name:e.name,type:e.type,components:o,offset:a}})),size:Ga(n,Math.max(r,t)),alignment:t}}function Ga(e,t){return Math.ceil(e/t)*t}class Ka extends Ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){let n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){let r=2*e;return this.int16[r+0]=t,this.int16[r+1]=n,e}}Ka.prototype.bytesPerElement=4,Y(`StructArrayLayout2i4`,Ka);class qa extends Ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){let i=3*e;return this.int16[i+0]=t,this.int16[i+1]=n,this.int16[i+2]=r,e}}qa.prototype.bytesPerElement=6,Y(`StructArrayLayout3i6`,qa);class Ja extends Ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r){let i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){let a=4*e;return this.int16[a+0]=t,this.int16[a+1]=n,this.int16[a+2]=r,this.int16[a+3]=i,e}}Ja.prototype.bytesPerElement=8,Y(`StructArrayLayout4i8`,Ja);class Ya extends Ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i,a)}emplace(e,t,n,r,i,a,o){let s=6*e;return this.int16[s+0]=t,this.int16[s+1]=n,this.int16[s+2]=r,this.int16[s+3]=i,this.int16[s+4]=a,this.int16[s+5]=o,e}}Ya.prototype.bytesPerElement=12,Y(`StructArrayLayout2i4i12`,Ya);class Xa extends Ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i,a)}emplace(e,t,n,r,i,a,o){let s=4*e,c=8*e;return this.int16[s+0]=t,this.int16[s+1]=n,this.uint8[c+4]=r,this.uint8[c+5]=i,this.uint8[c+6]=a,this.uint8[c+7]=o,e}}Xa.prototype.bytesPerElement=8,Y(`StructArrayLayout2i4ub8`,Xa);class Za extends Ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){let n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){let r=2*e;return this.float32[r+0]=t,this.float32[r+1]=n,e}}Za.prototype.bytesPerElement=8,Y(`StructArrayLayout2f8`,Za);class Qa extends Ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a,o,s,c,l){let u=this.length;return this.resize(u+1),this.emplace(u,e,t,n,r,i,a,o,s,c,l)}emplace(e,t,n,r,i,a,o,s,c,l,u){let d=10*e;return this.uint16[d+0]=t,this.uint16[d+1]=n,this.uint16[d+2]=r,this.uint16[d+3]=i,this.uint16[d+4]=a,this.uint16[d+5]=o,this.uint16[d+6]=s,this.uint16[d+7]=c,this.uint16[d+8]=l,this.uint16[d+9]=u,e}}Qa.prototype.bytesPerElement=20,Y(`StructArrayLayout10ui20`,Qa);class $a extends Ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a,o,s,c,l,u,d){let f=this.length;return this.resize(f+1),this.emplace(f,e,t,n,r,i,a,o,s,c,l,u,d)}emplace(e,t,n,r,i,a,o,s,c,l,u,d,f){let p=12*e;return this.int16[p+0]=t,this.int16[p+1]=n,this.int16[p+2]=r,this.int16[p+3]=i,this.uint16[p+4]=a,this.uint16[p+5]=o,this.uint16[p+6]=s,this.uint16[p+7]=c,this.int16[p+8]=l,this.int16[p+9]=u,this.int16[p+10]=d,this.int16[p+11]=f,e}}$a.prototype.bytesPerElement=24,Y(`StructArrayLayout4i4ui4i24`,$a);class eo extends Ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){let i=3*e;return this.float32[i+0]=t,this.float32[i+1]=n,this.float32[i+2]=r,e}}eo.prototype.bytesPerElement=12,Y(`StructArrayLayout3f12`,eo);class to extends Ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){let t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint32[1*e+0]=t,e}}to.prototype.bytesPerElement=4,Y(`StructArrayLayout1ul4`,to);class no extends Ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a,o,s,c){let l=this.length;return this.resize(l+1),this.emplace(l,e,t,n,r,i,a,o,s,c)}emplace(e,t,n,r,i,a,o,s,c,l){let u=10*e,d=5*e;return this.int16[u+0]=t,this.int16[u+1]=n,this.int16[u+2]=r,this.int16[u+3]=i,this.int16[u+4]=a,this.int16[u+5]=o,this.uint32[d+3]=s,this.uint16[u+8]=c,this.uint16[u+9]=l,e}}no.prototype.bytesPerElement=20,Y(`StructArrayLayout6i1ul2ui20`,no);class ro extends Ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i,a)}emplace(e,t,n,r,i,a,o){let s=6*e;return this.int16[s+0]=t,this.int16[s+1]=n,this.int16[s+2]=r,this.int16[s+3]=i,this.int16[s+4]=a,this.int16[s+5]=o,e}}ro.prototype.bytesPerElement=12,Y(`StructArrayLayout2i2i2i12`,ro);class io extends Ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i){let a=this.length;return this.resize(a+1),this.emplace(a,e,t,n,r,i)}emplace(e,t,n,r,i,a){let o=4*e,s=8*e;return this.float32[o+0]=t,this.float32[o+1]=n,this.float32[o+2]=r,this.int16[s+6]=i,this.int16[s+7]=a,e}}io.prototype.bytesPerElement=16,Y(`StructArrayLayout2f1f2i16`,io);class ao extends Ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i,a)}emplace(e,t,n,r,i,a,o){let s=16*e,c=4*e,l=8*e;return this.uint8[s+0]=t,this.uint8[s+1]=n,this.float32[c+1]=r,this.float32[c+2]=i,this.int16[l+6]=a,this.int16[l+7]=o,e}}ao.prototype.bytesPerElement=16,Y(`StructArrayLayout2ub2f2i16`,ao);class oo extends Ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){let i=3*e;return this.uint16[i+0]=t,this.uint16[i+1]=n,this.uint16[i+2]=r,e}}oo.prototype.bytesPerElement=6,Y(`StructArrayLayout3ui6`,oo);class so extends Ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){let _=this.length;return this.resize(_+1),this.emplace(_,e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}emplace(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_){let v=26*e,y=13*e,b=52*e;return this.int16[v+0]=t,this.int16[v+1]=n,this.uint32[y+1]=r,this.uint32[y+2]=i,this.uint32[y+3]=a,this.uint32[y+4]=o,this.uint32[y+5]=s,this.uint16[v+12]=c,this.uint16[v+13]=l,this.uint16[v+14]=u,this.float32[y+8]=d,this.float32[y+9]=f,this.uint8[b+40]=p,this.uint8[b+41]=m,this.uint8[b+42]=h,this.uint32[y+11]=g,this.int16[v+24]=_,e}}so.prototype.bytesPerElement=52,Y(`StructArrayLayout2i5ul3ui2f3ub1ul1i52`,so);class co extends Ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O){let k=this.length;return this.resize(k+1),this.emplace(k,e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O)}emplace(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k){let A=34*e,j=17*e;return this.int16[A+0]=t,this.int16[A+1]=n,this.int16[A+2]=r,this.int16[A+3]=i,this.int16[A+4]=a,this.int16[A+5]=o,this.int16[A+6]=s,this.int16[A+7]=c,this.uint16[A+8]=l,this.uint16[A+9]=u,this.uint16[A+10]=d,this.uint16[A+11]=f,this.uint16[A+12]=p,this.uint16[A+13]=m,this.uint16[A+14]=h,this.uint16[A+15]=g,this.uint16[A+16]=_,this.uint16[A+17]=v,this.uint16[A+18]=y,this.uint16[A+19]=b,this.uint16[A+20]=x,this.uint16[A+21]=S,this.uint16[A+22]=C,this.uint32[j+12]=w,this.float32[j+13]=T,this.float32[j+14]=E,this.uint16[A+30]=D,this.uint16[A+31]=O,this.float32[j+16]=k,e}}co.prototype.bytesPerElement=68,Y(`StructArrayLayout8i15ui1ul2f2ui1f68`,co);class lo extends Ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){let t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.float32[1*e+0]=t,e}}lo.prototype.bytesPerElement=4,Y(`StructArrayLayout1f4`,lo);class uo extends Ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){let i=3*e;return this.uint16[6*e+0]=t,this.float32[i+1]=n,this.float32[i+2]=r,e}}uo.prototype.bytesPerElement=12,Y(`StructArrayLayout1ui2f12`,uo);class fo extends Ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){let i=4*e;return this.uint32[2*e+0]=t,this.uint16[i+2]=n,this.uint16[i+3]=r,e}}fo.prototype.bytesPerElement=8,Y(`StructArrayLayout1ul2ui8`,fo);class po extends Ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){let n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){let r=2*e;return this.uint16[r+0]=t,this.uint16[r+1]=n,e}}po.prototype.bytesPerElement=4,Y(`StructArrayLayout2ui4`,po);class mo extends Ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){let t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint16[1*e+0]=t,e}}mo.prototype.bytesPerElement=2,Y(`StructArrayLayout1ui2`,mo);class ho extends Ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r){let i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){let a=4*e;return this.float32[a+0]=t,this.float32[a+1]=n,this.float32[a+2]=r,this.float32[a+3]=i,e}}ho.prototype.bytesPerElement=16,Y(`StructArrayLayout4f16`,ho);class go extends Ha{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new n(this.anchorPointX,this.anchorPointY)}}go.prototype.size=20;class _o extends no{get(e){return new go(this,e)}}Y(`CollisionBoxArray`,_o);class vo extends Ha{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint32[this._pos4+1]}get numGlyphs(){return this._structArray.uint32[this._pos4+2]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineStartIndex(){return this._structArray.uint32[this._pos4+4]}get lineLength(){return this._structArray.uint32[this._pos4+5]}get segment(){return this._structArray.uint16[this._pos2+12]}get lowerSize(){return this._structArray.uint16[this._pos2+13]}get upperSize(){return this._structArray.uint16[this._pos2+14]}get lineOffsetX(){return this._structArray.float32[this._pos4+8]}get lineOffsetY(){return this._structArray.float32[this._pos4+9]}get writingMode(){return this._structArray.uint8[this._pos1+40]}get placedOrientation(){return this._structArray.uint8[this._pos1+41]}set placedOrientation(e){this._structArray.uint8[this._pos1+41]=e}get hidden(){return this._structArray.uint8[this._pos1+42]}set hidden(e){this._structArray.uint8[this._pos1+42]=e}get crossTileID(){return this._structArray.uint32[this._pos4+11]}set crossTileID(e){this._structArray.uint32[this._pos4+11]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+24]}}vo.prototype.size=52;class yo extends so{get(e){return new vo(this,e)}}Y(`PlacedSymbolArray`,yo);class bo extends Ha{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}get angle(){return this._structArray.float32[this._pos4+16]}set angle(e){this._structArray.float32[this._pos4+16]=e}}bo.prototype.size=68;class xo extends co{get(e){return new bo(this,e)}}Y(`SymbolInstanceArray`,xo);class So extends lo{getoffsetX(e){return this.float32[1*e+0]}}Y(`GlyphOffsetArray`,So);class Co extends qa{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}Y(`SymbolLineVertexArray`,Co);class wo extends Ha{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}wo.prototype.size=12;class To extends uo{get(e){return new wo(this,e)}}Y(`TextAnchorOffsetArray`,To);class Eo extends Ha{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]}}Eo.prototype.size=8;class Do extends fo{get(e){return new Eo(this,e)}}Y(`FeatureIndexArray`,Do);class Oo extends Ka{}class ko extends Ka{}class Ao extends Ka{}class jo extends Ya{}class Mo extends Xa{}class No extends Za{}class Po extends Qa{}class Fo extends $a{}class Io extends eo{}class Lo extends to{}class Ro extends ro{}class zo extends ao{}class Bo extends oo{}class Vo extends po{}let{members:Ho}=Wa([{name:`a_pos`,components:2,type:`Int16`}],4);class Uo{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(e,t,n,r){let i=this.segments[this.segments.length-1];return e>Uo.MAX_VERTEX_ARRAY_LENGTH&&se(`Max vertices per segment is ${Uo.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${Uo.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!i||i.vertexLength+e>Uo.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==r?this.createNewSegment(t,n,r):i}createNewSegment(e,t,n){let r={vertexOffset:e.length,primitiveOffset:t.length,vertexLength:0,primitiveLength:0,vaos:{}};return n!==void 0&&(r.sortKey=n),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(r),r}getOrCreateLatestSegment(e,t,n){return this.prepareSegment(0,e,t,n)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(let e of this.segments)for(let t in e.vaos)e.vaos[t].destroy()}static simpleSegment(e,t,n,r){return new Uo([{vertexOffset:e,primitiveOffset:t,vertexLength:n,primitiveLength:r,vaos:{},sortKey:0}])}}function Wo(e,t){return 256*(e=ee(Math.floor(e),0,255))+ee(Math.floor(t),0,255)}Uo.MAX_VERTEX_ARRAY_LENGTH=2**16-1,Y(`SegmentVector`,Uo);let Go=Wa([{name:`a_pattern_from`,components:4,type:`Uint16`},{name:`a_pattern_to`,components:4,type:`Uint16`},{name:`a_pixel_ratio_from`,components:1,type:`Uint16`},{name:`a_pixel_ratio_to`,components:1,type:`Uint16`}]);var Ko,qo,Jo,Yo={exports:{}},Xo={exports:{}},Zo={exports:{}},Qo=r(function(){if(Jo)return Yo.exports;Jo=1;var e=(Ko||(Ko=1,Xo.exports=function(e,t){var n,r,i,a,o,s,c,l;for(r=e.length-(n=3&e.length),i=t,o=3432918353,s=461845907,l=0;l<r;)c=255&e.charCodeAt(l)|(255&e.charCodeAt(++l))<<8|(255&e.charCodeAt(++l))<<16|(255&e.charCodeAt(++l))<<24,++l,i=27492+(65535&(a=5*(65535&(i=(i^=c=(65535&(c=(c=(65535&c)*o+(((c>>>16)*o&65535)<<16)&4294967295)<<15|c>>>17))*s+(((c>>>16)*s&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(a>>>16)&65535)<<16);switch(c=0,n){case 3:c^=(255&e.charCodeAt(l+2))<<16;case 2:c^=(255&e.charCodeAt(l+1))<<8;case 1:i^=c=(65535&(c=(c=(65535&(c^=255&e.charCodeAt(l)))*o+(((c>>>16)*o&65535)<<16)&4294967295)<<15|c>>>17))*s+(((c>>>16)*s&65535)<<16)&4294967295}return i^=e.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0}),Xo.exports),t=(qo||(qo=1,Zo.exports=function(e,t){for(var n,r=e.length,i=t^r,a=0;r>=4;)n=1540483477*(65535&(n=255&e.charCodeAt(a)|(255&e.charCodeAt(++a))<<8|(255&e.charCodeAt(++a))<<16|(255&e.charCodeAt(++a))<<24))+((1540483477*(n>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),r-=4,++a;switch(r){case 3:i^=(255&e.charCodeAt(a+2))<<16;case 2:i^=(255&e.charCodeAt(a+1))<<8;case 1:i=1540483477*(65535&(i^=255&e.charCodeAt(a)))+((1540483477*(i>>>16)&65535)<<16)}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0}),Zo.exports);return Yo.exports=e,Yo.exports.murmur3=e,Yo.exports.murmur2=t,Yo.exports}());class $o{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,n,r){this.ids.push(es(e)),this.positions.push(t,n,r)}getPositions(e){if(!this.indexed)throw Error(`Trying to get index, but feature positions are not indexed`);let t=es(e),n=0,r=this.ids.length-1;for(;n<r;){let e=n+r>>1;this.ids[e]>=t?r=e:n=e+1}let i=[];for(;this.ids[n]===t;)i.push({index:this.positions[3*n],start:this.positions[3*n+1],end:this.positions[3*n+2]}),n++;return i}static serialize(e,t){let n=new Float64Array(e.ids),r=new Uint32Array(e.positions);return ts(n,r,0,n.length-1),t&&t.push(n.buffer,r.buffer),{ids:n,positions:r}}static deserialize(e){let t=new $o;return t.ids=e.ids,t.positions=e.positions,t.indexed=!0,t}}function es(e){let t=+e;return!isNaN(t)&&t<=2**53-1?t:Qo(String(e))}function ts(e,t,n,r){for(;n<r;){let i=e[n+r>>1],a=n-1,o=r+1;for(;;){do a++;while(e[a]<i);do o--;while(e[o]>i);if(a>=o)break;ns(e,a,o),ns(t,3*a,3*o),ns(t,3*a+1,3*o+1),ns(t,3*a+2,3*o+2)}o-n<r-o?(ts(e,t,n,o),n=o+1):(ts(e,t,o+1,r),r=o)}}function ns(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}Y(`FeaturePositionMap`,$o);class rs{constructor(e,t){this.gl=e.gl,this.location=t}}class is extends rs{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1f(this.location,e))}}class as extends rs{constructor(e,t){super(e,t),this.current=[0,0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]&&e[3]===this.current[3]||(this.current=e,this.gl.uniform4f(this.location,e[0],e[1],e[2],e[3]))}}class os extends rs{constructor(e,t){super(e,t),this.current=U.transparent}set(e){e.r===this.current.r&&e.g===this.current.g&&e.b===this.current.b&&e.a===this.current.a||(this.current=e,this.gl.uniform4f(this.location,e.r,e.g,e.b,e.a))}}let ss=new Float32Array(16);function cs(e){return[Wo(255*e.r,255*e.g),Wo(255*e.b,255*e.a)]}class ls{constructor(e,t,n){this.value=e,this.uniformNames=t.map((e=>`u_${e}`)),this.type=n}setUniform(e,t,n){e.set(n.constantOr(this.value))}getBinding(e,t,n){return this.type===`color`?new os(e,t):new is(e,t)}}class us{constructor(e,t){this.uniformNames=t.map((e=>`u_${e}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,t){this.pixelRatioFrom=t.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=t.tlbr,this.patternTo=e.tlbr}setUniform(e,t,n,r){let i=r===`u_pattern_to`?this.patternTo:r===`u_pattern_from`?this.patternFrom:r===`u_pixel_ratio_to`?this.pixelRatioTo:r===`u_pixel_ratio_from`?this.pixelRatioFrom:null;i&&e.set(i)}getBinding(e,t,n){return n.substr(0,9)===`u_pattern`?new as(e,t):new is(e,t)}}class ds{constructor(e,t,n,r){this.expression=e,this.type=n,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:`a_${e}`,type:`Float32`,components:n===`color`?2:1,offset:0}))),this.paintVertexArray=new r}populatePaintArray(e,t,n){let r=this.paintVertexArray.length,i=this.expression.evaluate(new Ea(0,n),t,{},n.canonical,[],n.formattedSection);this.paintVertexArray.resize(e),this._setPaintValue(r,e,i)}updatePaintArray(e,t,n,r,i){let a=this.expression.evaluate(new Ea(0,i),n,r);this._setPaintValue(e,t,a)}_setPaintValue(e,t,n){if(this.type===`color`){let r=cs(n);for(let n=e;n<t;n++)this.paintVertexArray.emplace(n,r[0],r[1])}else{for(let r=e;r<t;r++)this.paintVertexArray.emplace(r,n);this.maxValue=Math.max(this.maxValue,Math.abs(n))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class fs{constructor(e,t,n,r,i,a){this.expression=e,this.uniformNames=t.map((e=>`u_${e}_t`)),this.type=n,this.useIntegerZoom=r,this.zoom=i,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:`a_${e}`,type:`Float32`,components:n===`color`?4:2,offset:0}))),this.paintVertexArray=new a}populatePaintArray(e,t,n){let r=this.expression.evaluate(new Ea(this.zoom,n),t,{},n.canonical,[],n.formattedSection),i=this.expression.evaluate(new Ea(this.zoom+1,n),t,{},n.canonical,[],n.formattedSection),a=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(a,e,r,i)}updatePaintArray(e,t,n,r,i){let a=this.expression.evaluate(new Ea(this.zoom,i),n,r),o=this.expression.evaluate(new Ea(this.zoom+1,i),n,r);this._setPaintValue(e,t,a,o)}_setPaintValue(e,t,n,r){if(this.type===`color`){let i=cs(n),a=cs(r);for(let n=e;n<t;n++)this.paintVertexArray.emplace(n,i[0],i[1],a[0],a[1])}else{for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,n,r);this.maxValue=Math.max(this.maxValue,Math.abs(n),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))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,t){let n=this.useIntegerZoom?Math.floor(t.zoom):t.zoom,r=ee(this.expression.interpolationFactor(n,this.zoom,this.zoom+1),0,1);e.set(r)}getBinding(e,t,n){return new is(e,t)}}class ps{constructor(e,t,n,r,i,a){this.expression=e,this.type=t,this.useIntegerZoom=n,this.zoom=r,this.layerId=a,this.zoomInPaintVertexArray=new i,this.zoomOutPaintVertexArray=new i}populatePaintArray(e,t,n){let r=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(e),this.zoomOutPaintVertexArray.resize(e),this._setPaintValues(r,e,t.patterns&&t.patterns[this.layerId],n.imagePositions)}updatePaintArray(e,t,n,r,i){this._setPaintValues(e,t,n.patterns&&n.patterns[this.layerId],i.imagePositions)}_setPaintValues(e,t,n,r){if(!r||!n)return;let{min:i,mid:a,max:o}=n,s=r[i],c=r[a],l=r[o];if(s&&c&&l)for(let n=e;n<t;n++)this.zoomInPaintVertexArray.emplace(n,c.tl[0],c.tl[1],c.br[0],c.br[1],s.tl[0],s.tl[1],s.br[0],s.br[1],c.pixelRatio,s.pixelRatio),this.zoomOutPaintVertexArray.emplace(n,c.tl[0],c.tl[1],c.br[0],c.br[1],l.tl[0],l.tl[1],l.br[0],l.br[1],c.pixelRatio,l.pixelRatio)}upload(e){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=e.createVertexBuffer(this.zoomInPaintVertexArray,Go.members,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=e.createVertexBuffer(this.zoomOutPaintVertexArray,Go.members,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class ms{constructor(e,t,n){this.binders={},this._buffers=[];let r=[];for(let i in e.paint._values){if(!n(i))continue;let a=e.paint.get(i);if(!(a instanceof Na&&Gr(a.property.specification)))continue;let o=gs(i,e.type),s=a.value,c=a.property.specification.type,l=a.property.useIntegerZoom,u=a.property.specification[`property-type`],d=u===`cross-faded`||u===`cross-faded-data-driven`;if(s.kind===`constant`)this.binders[i]=d?new us(s.value,o):new ls(s.value,o,c),r.push(`/u_${i}`);else if(s.kind===`source`||d){let n=_s(i,c,`source`);this.binders[i]=d?new ps(s,c,l,t,n,e.id):new ds(s,o,c,n),r.push(`/a_${i}`)}else{let e=_s(i,c,`composite`);this.binders[i]=new fs(s,o,c,l,t,e),r.push(`/z_${i}`)}}this.cacheKey=r.sort().join(``)}getMaxValue(e){let t=this.binders[e];return t instanceof ds||t instanceof fs?t.maxValue:0}populatePaintArrays(e,t,n){for(let r in this.binders){let i=this.binders[r];(i instanceof ds||i instanceof fs||i instanceof ps)&&i.populatePaintArray(e,t,n)}}setConstantPatternPositions(e,t){for(let n in this.binders){let r=this.binders[n];r instanceof us&&r.setConstantPatternPositions(e,t)}}updatePaintArrays(e,t,n,r,i){let a=!1;for(let o in e){let s=t.getPositions(o);for(let t of s){let s=n.feature(t.index);for(let n in this.binders){let c=this.binders[n];(c instanceof ds||c instanceof fs||c instanceof ps)&&!0===c.expression.isStateDependent&&(c.expression=r.paint.get(n).value,c.updatePaintArray(t.start,t.end,s,e[o],i),a=!0)}}}return a}defines(){let e=[];for(let t in this.binders){let n=this.binders[t];(n instanceof ls||n instanceof us)&&e.push(...n.uniformNames.map((e=>`#define HAS_UNIFORM_${e}`)))}return e}getBinderAttributes(){let e=[];for(let t in this.binders){let n=this.binders[t];if(n instanceof ds||n instanceof fs)for(let t=0;t<n.paintVertexAttributes.length;t++)e.push(n.paintVertexAttributes[t].name);else if(n instanceof ps)for(let t=0;t<Go.members.length;t++)e.push(Go.members[t].name)}return e}getBinderUniforms(){let e=[];for(let t in this.binders){let n=this.binders[t];if(n instanceof ls||n instanceof us||n instanceof fs)for(let t of n.uniformNames)e.push(t)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,t){let n=[];for(let r in this.binders){let i=this.binders[r];if(i instanceof ls||i instanceof us||i instanceof fs){for(let a of i.uniformNames)if(t[a]){let o=i.getBinding(e,t[a],a);n.push({name:a,property:r,binding:o})}}}return n}setUniforms(e,t,n,r){for(let{name:e,property:i,binding:a}of t)this.binders[i].setUniform(a,r,n.get(i),e)}updatePaintBuffers(e){this._buffers=[];for(let t in this.binders){let n=this.binders[t];if(e&&n instanceof ps){let t=e.fromScale===2?n.zoomInPaintVertexBuffer:n.zoomOutPaintVertexBuffer;t&&this._buffers.push(t)}else (n instanceof ds||n instanceof fs)&&n.paintVertexBuffer&&this._buffers.push(n.paintVertexBuffer)}}upload(e){for(let t in this.binders){let n=this.binders[t];(n instanceof ds||n instanceof fs||n instanceof ps)&&n.upload(e)}this.updatePaintBuffers()}destroy(){for(let e in this.binders){let t=this.binders[e];(t instanceof ds||t instanceof fs||t instanceof ps)&&t.destroy()}}}class hs{constructor(e,t,n=()=>!0){this.programConfigurations={};for(let r of e)this.programConfigurations[r.id]=new ms(r,t,n);this.needsUpload=!1,this._featureMap=new $o,this._bufferOffset=0}populatePaintArrays(e,t,n,r){for(let n in this.programConfigurations)this.programConfigurations[n].populatePaintArrays(e,t,r);t.id!==void 0&&this._featureMap.add(t.id,n,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,n,r){for(let i of n)this.needsUpload=this.programConfigurations[i.id].updatePaintArrays(e,this._featureMap,t,i,r)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(let t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1}}destroy(){for(let e in this.programConfigurations)this.programConfigurations[e].destroy()}}function gs(e,t){return{"text-opacity":[`opacity`],"icon-opacity":[`opacity`],"text-color":[`fill_color`],"icon-color":[`fill_color`],"text-halo-color":[`halo_color`],"icon-halo-color":[`halo_color`],"text-halo-blur":[`halo_blur`],"icon-halo-blur":[`halo_blur`],"text-halo-width":[`halo_width`],"icon-halo-width":[`halo_width`],"line-gap-width":[`gapwidth`],"line-pattern":[`pattern_to`,`pattern_from`,`pixel_ratio_to`,`pixel_ratio_from`],"fill-pattern":[`pattern_to`,`pattern_from`,`pixel_ratio_to`,`pixel_ratio_from`],"fill-extrusion-pattern":[`pattern_to`,`pattern_from`,`pixel_ratio_to`,`pixel_ratio_from`]}[e]||[e.replace(`${t}-`,``).replace(/-/g,`_`)]}function _s(e,t,n){let r={color:{source:Za,composite:ho},number:{source:lo,composite:Za}},i=function(e){return{"line-pattern":{source:Po,composite:Po},"fill-pattern":{source:Po,composite:Po},"fill-extrusion-pattern":{source:Po,composite:Po}}[e]}(e);return i&&i[n]||r[t][n]}Y(`ConstantBinder`,ls),Y(`CrossFadedConstantBinder`,us),Y(`SourceExpressionBinder`,ds),Y(`CrossFadedCompositeBinder`,ps),Y(`CompositeExpressionBinder`,fs),Y(`ProgramConfiguration`,ms,{omit:[`_buffers`]}),Y(`ProgramConfigurationSet`,hs);let vs=2**14-1,ys=-vs-1;function bs(e){let t=O/e.extent,n=e.loadGeometry();for(let e=0;e<n.length;e++){let r=n[e];for(let e=0;e<r.length;e++){let n=r[e],i=Math.round(n.x*t),a=Math.round(n.y*t);n.x=ee(i,ys,vs),n.y=ee(a,ys,vs),(i<n.x||i>n.x+1||a<n.y||a>n.y+1)&&se(`Geometry exceeds allowed extent, reduce your vector tile buffer size`)}}return n}function xs(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?bs(e):[]}}let Ss=-32768;function Cs(e,t,n,r,i){e.emplaceBack(Ss+8*t+r,Ss+8*n+i)}class ws{constructor(e){this.zoom=e.zoom,this.globalState=e.globalState,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasPattern=!1,this.layoutVertexArray=new ko,this.indexArray=new Bo,this.segments=new Uo,this.programConfigurations=new hs(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,n){let r=this.layers[0],i=[],a=null,o=!1,s=r.type===`heatmap`;if(r.type===`circle`){let e=r;a=e.layout.get(`circle-sort-key`),o=!a.isConstant(),s||=e.paint.get(`circle-pitch-alignment`)===`map`}let c=s?t.subdivisionGranularity.circle:1;for(let{feature:t,id:r,index:s,sourceLayerIndex:c}of e){let e=this.layers[0]._featureFilter.needGeometry,l=xs(t,e);if(!this.layers[0]._featureFilter.filter(new Ea(this.zoom,{globalState:this.globalState}),l,n))continue;let u=o?a.evaluate(l,{},n):void 0,d={id:r,properties:t.properties,type:t.type,sourceLayerIndex:c,index:s,geometry:e?l.geometry:bs(t),patterns:{},sortKey:u};i.push(d)}o&&i.sort(((e,t)=>e.sortKey-t.sortKey));for(let r of i){let{geometry:i,index:a,sourceLayerIndex:o}=r,s=e[a].feature;this.addFeature(r,i,a,n,c),t.featureIndex.insert(s,i,a,o,this.index)}}update(e,t,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:n,globalState:this.globalState})}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Ho),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,t,n,r,i=1){let a;switch(i){case 1:a=[0,7];break;case 3:a=[0,2,5,7];break;case 5:a=[0,1,3,4,6,7];break;case 7:a=[0,1,2,3,4,5,6,7];break;default:throw Error(`Invalid circle bucket granularity: ${i}; valid values are 1, 3, 5, 7.`)}let o=a.length;for(let n of t)for(let t of n){let n=t.x,r=t.y;if(n<0||n>=O||r<0||r>=O)continue;let i=this.segments.prepareSegment(o*o,this.layoutVertexArray,this.indexArray,e.sortKey),s=i.vertexLength;for(let e=0;e<o;e++)for(let t=0;t<o;t++)Cs(this.layoutVertexArray,n,r,a[t],a[e]);for(let e=0;e<o-1;e++)for(let t=0;t<o-1;t++){let n=s+e*o+t,r=s+(e+1)*o+t;this.indexArray.emplaceBack(n,r+1,n+1),this.indexArray.emplaceBack(n,r,r+1)}i.vertexLength+=o*o,i.primitiveLength+=(o-1)*(o-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,{imagePositions:{},canonical:r,globalState:this.globalState})}}function Ts(e,t){for(let n=0;n<e.length;n++)if(Ps(t,e[n]))return!0;for(let n=0;n<t.length;n++)if(Ps(e,t[n]))return!0;return!!ks(e,t)}function Es(e,t,n){return!!Ps(e,t)||!!js(t,e,n)}function Ds(e,t){if(e.length===1)return Ns(t,e[0]);for(let n=0;n<t.length;n++){let r=t[n];for(let t=0;t<r.length;t++)if(Ps(e,r[t]))return!0}for(let n=0;n<e.length;n++)if(Ns(t,e[n]))return!0;for(let n=0;n<t.length;n++)if(ks(e,t[n]))return!0;return!1}function Os(e,t,n){if(e.length>1){if(ks(e,t))return!0;for(let r=0;r<t.length;r++)if(js(t[r],e,n))return!0}for(let r=0;r<e.length;r++)if(js(e[r],t,n))return!0;return!1}function ks(e,t){if(e.length===0||t.length===0)return!1;for(let n=0;n<e.length-1;n++){let r=e[n],i=e[n+1];for(let e=0;e<t.length-1;e++)if(As(r,i,t[e],t[e+1]))return!0}return!1}function As(e,t,n,r){return ce(e,n,r)!==ce(t,n,r)&&ce(e,t,n)!==ce(e,t,r)}function js(e,t,n){let r=n*n;if(t.length===1)return e.distSqr(t[0])<r;for(let n=1;n<t.length;n++)if(Ms(e,t[n-1],t[n])<r)return!0;return!1}function Ms(e,t,n){let r=t.distSqr(n);if(r===0)return e.distSqr(t);let i=((e.x-t.x)*(n.x-t.x)+(e.y-t.y)*(n.y-t.y))/r;return e.distSqr(i<0?t:i>1?n:n.sub(t)._mult(i)._add(t))}function Ns(e,t){let n,r,i,a=!1;for(let o=0;o<e.length;o++){n=e[o];for(let e=0,o=n.length-1;e<n.length;o=e++)r=n[e],i=n[o],r.y>t.y!=i.y>t.y&&t.x<(i.x-r.x)*(t.y-r.y)/(i.y-r.y)+r.x&&(a=!a)}return a}function Ps(e,t){let n=!1;for(let r=0,i=e.length-1;r<e.length;i=r++){let a=e[r],o=e[i];a.y>t.y!=o.y>t.y&&t.x<(o.x-a.x)*(t.y-a.y)/(o.y-a.y)+a.x&&(n=!n)}return n}function Fs(e,t,n){let r=n[0],i=n[2];if(e.x<r.x&&t.x<r.x||e.x>i.x&&t.x>i.x||e.y<r.y&&t.y<r.y||e.y>i.y&&t.y>i.y)return!1;let a=ce(e,t,n[0]);return a!==ce(e,t,n[1])||a!==ce(e,t,n[2])||a!==ce(e,t,n[3])}function Is(e,t,n){let r=t.paint.get(e).value;return r.kind===`constant`?r.value:n.programConfigurations.get(t.id).getMaxValue(e)}function Ls(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function Rs(e,t,r,i,a){if(!t[0]&&!t[1])return e;let o=n.convert(t)._mult(a);r===`viewport`&&o._rotate(-i);let s=[];for(let t=0;t<e.length;t++)s.push(e[t].sub(o));return s}let zs,Bs;Y(`CircleBucket`,ws,{omit:[`layers`]});var Vs={get paint(){return Bs||=new Ra({"circle-radius":new $(I.paint_circle[`circle-radius`]),"circle-color":new $(I.paint_circle[`circle-color`]),"circle-blur":new $(I.paint_circle[`circle-blur`]),"circle-opacity":new $(I.paint_circle[`circle-opacity`]),"circle-translate":new Q(I.paint_circle[`circle-translate`]),"circle-translate-anchor":new Q(I.paint_circle[`circle-translate-anchor`]),"circle-pitch-scale":new Q(I.paint_circle[`circle-pitch-scale`]),"circle-pitch-alignment":new Q(I.paint_circle[`circle-pitch-alignment`]),"circle-stroke-width":new $(I.paint_circle[`circle-stroke-width`]),"circle-stroke-color":new $(I.paint_circle[`circle-stroke-color`]),"circle-stroke-opacity":new $(I.paint_circle[`circle-stroke-opacity`])})},get layout(){return zs||=new Ra({"circle-sort-key":new $(I.layout_circle[`circle-sort-key`])})}};class Hs extends Ba{constructor(e){super(e,Vs)}createBucket(e){return new ws(e)}queryRadius(e){let t=e;return Is(`circle-radius`,this,t)+Is(`circle-stroke-width`,this,t)+Ls(this.paint.get(`circle-translate`))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:n,geometry:r,transform:i,pixelsToTileUnits:a,unwrappedTileID:o,getElevation:s}){let c=Rs(e,this.paint.get(`circle-translate`),this.paint.get(`circle-translate-anchor`),-i.bearingInRadians,a),l=this.paint.get(`circle-radius`).evaluate(t,n)+this.paint.get(`circle-stroke-width`).evaluate(t,n),u=this.paint.get(`circle-pitch-alignment`)===`map`,d=u?c:function(e,t,n,r){return e.map((e=>Us(e,t,n,r)))}(c,i,o,s),f=u?l*a:l;for(let e of r)for(let t of e){let e=u?t:Us(t,i,o,s),n=f,r=i.projectTileCoordinates(t.x,t.y,o,s).signedDistanceFromCamera;if(this.paint.get(`circle-pitch-scale`)===`viewport`&&this.paint.get(`circle-pitch-alignment`)===`map`?n*=r/i.cameraToCenterDistance:this.paint.get(`circle-pitch-scale`)===`map`&&this.paint.get(`circle-pitch-alignment`)===`viewport`&&(n*=i.cameraToCenterDistance/r),Es(d,e,n))return!0}return!1}}function Us(e,t,r,i){let a=t.projectTileCoordinates(e.x,e.y,r,i).point;return new n((.5*a.x+.5)*t.width,(.5*-a.y+.5)*t.height)}class Ws extends ws{}let Gs;Y(`HeatmapBucket`,Ws,{omit:[`layers`]});var Ks={get paint(){return Gs||=new Ra({"heatmap-radius":new $(I.paint_heatmap[`heatmap-radius`]),"heatmap-weight":new $(I.paint_heatmap[`heatmap-weight`]),"heatmap-intensity":new Q(I.paint_heatmap[`heatmap-intensity`]),"heatmap-color":new La(I.paint_heatmap[`heatmap-color`]),"heatmap-opacity":new Q(I.paint_heatmap[`heatmap-opacity`])})}};function qs(e,{width:t,height:n},r,i){if(i){if(i instanceof Uint8ClampedArray)i=new Uint8Array(i.buffer);else if(i.length!==t*n*r)throw RangeError(`mismatched image size. expected: ${i.length} but got: ${t*n*r}`)}else i=new Uint8Array(t*n*r);return e.width=t,e.height=n,e.data=i,e}function Js(e,{width:t,height:n},r){if(t===e.width&&n===e.height)return;let i=qs({},{width:t,height:n},r);Ys(e,i,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,t),height:Math.min(e.height,n)},r),e.width=t,e.height=n,e.data=i.data}function Ys(e,t,n,r,i,a){if(i.width===0||i.height===0)return t;if(i.width>e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw RangeError(`out of range source coordinates for image copy`);if(i.width>t.width||i.height>t.height||r.x>t.width-i.width||r.y>t.height-i.height)throw RangeError(`out of range destination coordinates for image copy`);let o=e.data,s=t.data;if(o===s)throw Error(`srcData equals dstData, so image is already copied`);for(let c=0;c<i.height;c++){let l=((n.y+c)*e.width+n.x)*a,u=((r.y+c)*t.width+r.x)*a;for(let e=0;e<i.width*a;e++)s[u+e]=o[l+e]}return t}class Xs{constructor(e,t){qs(this,e,1,t)}resize(e){Js(this,e,1)}clone(){return new Xs({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,n,r,i){Ys(e,t,n,r,i,1)}}class Zs{constructor(e,t){qs(this,e,4,t)}resize(e){Js(this,e,4)}replace(e,t){t?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new Zs({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,n,r,i){Ys(e,t,n,r,i,4)}setPixel(e,t,n){let r=4*(e*this.width+t);this.data[r+0]=Math.round(255*n.r/n.a),this.data[r+1]=Math.round(255*n.g/n.a),this.data[r+2]=Math.round(255*n.b/n.a),this.data[r+3]=Math.round(255*n.a)}}function Qs(e){let t={},n=e.resolution||256,r=e.clips?e.clips.length:1,i=e.image||new Zs({width:n,height:r});if(Math.log(n)/Math.LN2%1!=0)throw Error(`width is not a power of 2 - ${n}`);let a=(r,a,o)=>{t[e.evaluationKey]=o;let s=e.expression.evaluate(t);i.setPixel(r/4/n,a/4,s)};if(e.clips)for(let t=0,i=0;t<r;++t,i+=4*n)for(let r=0,o=0;r<n;r++,o+=4){let s=r/(n-1),{start:c,end:l}=e.clips[t];a(i,o,c*(1-s)+l*s)}else for(let e=0,t=0;e<n;e++,t+=4)a(0,t,e/(n-1));return i}Y(`AlphaImage`,Xs),Y(`RGBAImage`,Zs);let $s=`big-fb`;class ec extends Ba{createBucket(e){return new Ws(e)}constructor(e){super(e,Ks),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){e===`heatmap-color`&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Qs({expression:this._transitionablePaint._values[`heatmap-color`].value.expression,evaluationKey:`heatmapDensity`,image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has($s)&&this.heatmapFbos.delete($s)}queryRadius(){return 0}queryIntersectsFeature(){return!1}hasOffscreenPass(){return this.paint.get(`heatmap-opacity`)!==0&&this.visibility!==`none`}}let tc;var nc={get paint(){return tc||=new Ra({"hillshade-illumination-direction":new Q(I.paint_hillshade[`hillshade-illumination-direction`]),"hillshade-illumination-altitude":new Q(I.paint_hillshade[`hillshade-illumination-altitude`]),"hillshade-illumination-anchor":new Q(I.paint_hillshade[`hillshade-illumination-anchor`]),"hillshade-exaggeration":new Q(I.paint_hillshade[`hillshade-exaggeration`]),"hillshade-shadow-color":new Q(I.paint_hillshade[`hillshade-shadow-color`]),"hillshade-highlight-color":new Q(I.paint_hillshade[`hillshade-highlight-color`]),"hillshade-accent-color":new Q(I.paint_hillshade[`hillshade-accent-color`]),"hillshade-method":new Q(I.paint_hillshade[`hillshade-method`])})}};class rc extends Ba{constructor(e){super(e,nc),this.recalculate({zoom:0,zoomHistory:{}},void 0)}getIlluminationProperties(){let e=this.paint.get(`hillshade-illumination-direction`).values,t=this.paint.get(`hillshade-illumination-altitude`).values,n=this.paint.get(`hillshade-highlight-color`).values,r=this.paint.get(`hillshade-shadow-color`).values,i=Math.max(e.length,t.length,n.length,r.length);e=e.concat(Array(i-e.length).fill(e.at(-1))),t=t.concat(Array(i-t.length).fill(t.at(-1))),n=n.concat(Array(i-n.length).fill(n.at(-1))),r=r.concat(Array(i-r.length).fill(r.at(-1)));let a=t.map(_e);return{directionRadians:e.map(_e),altitudeRadians:a,shadowColor:r,highlightColor:n}}hasOffscreenPass(){return this.paint.get(`hillshade-exaggeration`)!==0&&this.visibility!==`none`}}let ic;var ac={get paint(){return ic||=new Ra({"color-relief-opacity":new Q(I[`paint_color-relief`][`color-relief-opacity`]),"color-relief-color":new La(I[`paint_color-relief`][`color-relief-color`])})}};class oc{constructor(e,t,n,r){this.context=e,this.format=n,this.texture=e.gl.createTexture(),this.update(t,r)}update(e,t,n){let{width:r,height:i}=e,a=!(this.size&&this.size[0]===r&&this.size[1]===i||n),{context:o}=this,{gl:s}=o;if(this.useMipmap=!!(t&&t.useMipmap),s.bindTexture(s.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1),o.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA&&(!t||!1!==t.premultiply)),a)this.size=[r,i],e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||de(e)?s.texImage2D(s.TEXTURE_2D,0,this.format,this.format,s.UNSIGNED_BYTE,e):s.texImage2D(s.TEXTURE_2D,0,this.format,r,i,0,this.format,s.UNSIGNED_BYTE,e.data);else{let{x:t,y:a}=n||{x:0,y:0};e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||de(e)?s.texSubImage2D(s.TEXTURE_2D,0,t,a,s.RGBA,s.UNSIGNED_BYTE,e):s.texSubImage2D(s.TEXTURE_2D,0,t,a,r,i,s.RGBA,s.UNSIGNED_BYTE,e.data)}this.useMipmap&&this.isSizePowerOfTwo()&&s.generateMipmap(s.TEXTURE_2D),o.pixelStoreUnpackFlipY.setDefault(),o.pixelStoreUnpack.setDefault(),o.pixelStoreUnpackPremultiplyAlpha.setDefault()}bind(e,t,n){let{context:r}=this,{gl:i}=r;i.bindTexture(i.TEXTURE_2D,this.texture),n!==i.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(n=i.LINEAR),e!==this.filter&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,e),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,n||e),this.filter=e),t!==this.wrap&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,t),this.wrap=t)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){let{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class sc{constructor(e,t,n,r=1,i=1,a=1,o=0){if(this.uid=e,t.height!==t.width)throw RangeError(`DEM tiles must be square`);if(n&&![`mapbox`,`terrarium`,`custom`].includes(n))return void se(`"${n}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=t.height;let s=this.dim=t.height-2;switch(this.data=new Uint32Array(t.data.buffer),n){case`terrarium`:this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case`custom`:this.redFactor=r,this.greenFactor=i,this.blueFactor=a,this.baseShift=o;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let e=0;e<s;e++)this.data[this._idx(-1,e)]=this.data[this._idx(0,e)],this.data[this._idx(s,e)]=this.data[this._idx(s-1,e)],this.data[this._idx(e,-1)]=this.data[this._idx(e,0)],this.data[this._idx(e,s)]=this.data[this._idx(e,s-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(s,-1)]=this.data[this._idx(s-1,0)],this.data[this._idx(-1,s)]=this.data[this._idx(0,s-1)],this.data[this._idx(s,s)]=this.data[this._idx(s-1,s-1)],this.min=2**53-1,this.max=-(2**53-1);for(let e=0;e<s;e++)for(let t=0;t<s;t++){let n=this.get(e,t);n>this.max&&(this.max=n),n<this.min&&(this.min=n)}}get(e,t){let n=new Uint8Array(this.data.buffer),r=4*this._idx(e,t);return this.unpack(n[r],n[r+1],n[r+2])}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(e,t){if(e<-1||e>=this.dim+1||t<-1||t>=this.dim+1)throw RangeError(`out of range source coordinates for DEM data`);return(t+1)*this.stride+(e+1)}unpack(e,t,n){return e*this.redFactor+t*this.greenFactor+n*this.blueFactor-this.baseShift}pack(e){return cc(e,this.getUnpackVector())}getPixels(){return new Zs({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,t,n){if(this.dim!==e.dim)throw Error(`dem dimension mismatch`);let r=t*this.dim,i=t*this.dim+this.dim,a=n*this.dim,o=n*this.dim+this.dim;switch(t){case-1:r=i-1;break;case 1:i=r+1}switch(n){case-1:a=o-1;break;case 1:o=a+1}let s=-t*this.dim,c=-n*this.dim;for(let t=a;t<o;t++)for(let n=r;n<i;n++)this.data[this._idx(n,t)]=e.data[this._idx(n+s,t+c)]}}function cc(e,t){let n=t[0],r=t[1],i=t[2],a=t[3],o=Math.min(n,r,i),s=Math.round((e+a)/o);return{r:Math.floor(s*o/n)%256,g:Math.floor(s*o/r)%256,b:Math.floor(s*o/i)%256}}Y(`DEMData`,sc);class lc extends Ba{constructor(e){super(e,ac)}_createColorRamp(e){let t={elevationStops:[],colorStops:[]},n=this._transitionablePaint._values[`color-relief-color`].value.expression;if(n instanceof ai&&n._styleExpression.expression instanceof _n){this.colorRampExpression=n;let e=n._styleExpression.expression;t.elevationStops=e.labels,t.colorStops=[];for(let n of t.elevationStops)t.colorStops.push(e.evaluate({globals:{elevation:n}}))}if(t.elevationStops.length<1&&(t.elevationStops=[0],t.colorStops=[U.transparent]),t.elevationStops.length<2&&(t.elevationStops.push(t.elevationStops[0]+1),t.colorStops.push(t.colorStops[0])),t.elevationStops.length<=e)return t;let r={elevationStops:[],colorStops:[]},i=(t.elevationStops.length-1)/(e-1);for(let e=0;e<t.elevationStops.length-.5;e+=i)r.elevationStops.push(t.elevationStops[Math.round(e)]),r.colorStops.push(t.colorStops[Math.round(e)]);return se(`Too many colors in specification of ${this.id} color-relief layer, may not render properly.`),r}_colorRampChanged(){return this.colorRampExpression!=this._transitionablePaint._values[`color-relief-color`].value.expression}getColorRampTextures(e,t,n){if(this.colorRampTextures&&!this._colorRampChanged())return this.colorRampTextures;let r=this._createColorRamp(t),i=new Zs({width:r.colorStops.length,height:1}),a=new Zs({width:r.colorStops.length,height:1});for(let e=0;e<r.elevationStops.length;e++){let t=cc(r.elevationStops[e],n);a.setPixel(0,e,new U(t.r/255,t.g/255,t.b/255,1)),i.setPixel(0,e,r.colorStops[e])}return this.colorRampTextures={elevationTexture:new oc(e,a,e.gl.RGBA),colorTexture:new oc(e,i,e.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return this.visibility!==`none`&&!!this.colorRampTextures}}let{members:uc}=Wa([{name:`a_pos`,components:2,type:`Int16`}],4);function dc(e,t,n){let r=n.patternDependencies,i=!1;for(let n of t){let t=n.paint.get(`${e}-pattern`);t.isConstant()||(i=!0);let a=t.constantOr(null);a&&(i=!0,r[a.to]=!0,r[a.from]=!0)}return i}function fc(e,t,n,r,i){let a=i.patternDependencies;for(let o of t){let t=o.paint.get(`${e}-pattern`).value;if(t.kind!==`constant`){let e=t.evaluate({zoom:r-1},n,{},i.availableImages),s=t.evaluate({zoom:r},n,{},i.availableImages),c=t.evaluate({zoom:r+1},n,{},i.availableImages);e=e&&e.name?e.name:e,s=s&&s.name?s.name:s,c=c&&c.name?c.name:c,a[e]=!0,a[s]=!0,a[c]=!0,n.patterns[o.id]={min:e,mid:s,max:c}}}return n}function pc(e,t,n,r,i){let a;if(i===function(e,t,n,r){let i=0;for(let a=t,o=n-r;a<n;a+=r)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}(e,t,n,r)>0)for(let i=t;i<n;i+=r)a=Fc(i/r|0,e[i],e[i+1],a);else for(let i=n-r;i>=t;i-=r)a=Fc(i/r|0,e[i],e[i+1],a);return a&&kc(a,a.next)&&(Ic(a),a=a.next),a}function mc(e,t){if(!e)return e;t||=e;let n,r=e;do if(n=!1,r.steiner||!kc(r,r.next)&&Oc(r.prev,r,r.next)!==0)r=r.next;else{if(Ic(r),r=t=r.prev,r===r.next)break;n=!0}while(n||r!==t);return t}function hc(e,t,n,r,i,a,o){if(!e)return;!o&&a&&function(e,t,n,r){let i=e;do i.z===0&&(i.z=Cc(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){let t,n=1;do{let r,i=e;e=null;let a=null;for(t=0;i;){t++;let o=i,s=0;for(let e=0;e<n&&(s++,o=o.nextZ,o);e++);let c=n;for(;s>0||c>0&&o;)s!==0&&(c===0||!o||i.z<=o.z)?(r=i,i=i.nextZ,s--):(r=o,o=o.nextZ,c--),a?a.nextZ=r:e=r,r.prevZ=a,a=r;i=o}a.nextZ=null,n*=2}while(t>1)}(i)}(e,r,i,a);let s=e;for(;e.prev!==e.next;){let c=e.prev,l=e.next;if(a?_c(e,r,i,a):gc(e))t.push(c.i,e.i,l.i),Ic(e),e=l.next,s=l.next;else if((e=l)===s){o?o===1?hc(e=vc(mc(e),t),t,n,r,i,a,2):o===2&&yc(e,t,n,r,i,a):hc(mc(e),t,n,r,i,a,1);break}}}function gc(e){let t=e.prev,n=e,r=e.next;if(Oc(t,n,r)>=0)return!1;let i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=Math.min(i,a,o),d=Math.min(s,c,l),f=Math.max(i,a,o),p=Math.max(s,c,l),m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&Ec(i,s,a,c,o,l,m.x,m.y)&&Oc(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function _c(e,t,n,r){let i=e.prev,a=e,o=e.next;if(Oc(i,a,o)>=0)return!1;let s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=Math.min(s,c,l),m=Math.min(u,d,f),h=Math.max(s,c,l),g=Math.max(u,d,f),_=Cc(p,m,t,n,r),v=Cc(h,g,t,n,r),y=e.prevZ,b=e.nextZ;for(;y&&y.z>=_&&b&&b.z<=v;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&Ec(s,u,c,d,l,f,y.x,y.y)&&Oc(y.prev,y,y.next)>=0||(y=y.prevZ,b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&Ec(s,u,c,d,l,f,b.x,b.y)&&Oc(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&Ec(s,u,c,d,l,f,y.x,y.y)&&Oc(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=v;){if(b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&Ec(s,u,c,d,l,f,b.x,b.y)&&Oc(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function vc(e,t){let n=e;do{let r=n.prev,i=n.next.next;!kc(r,i)&&Ac(r,n,n.next,i)&&Nc(r,i)&&Nc(i,r)&&(t.push(r.i,n.i,i.i),Ic(n),Ic(n.next),n=e=i),n=n.next}while(n!==e);return mc(n)}function yc(e,t,n,r,i,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&Dc(o,e)){let s=Pc(o,e);o=mc(o,o.next),s=mc(s,s.next),hc(o,t,n,r,i,a,0),hc(s,t,n,r,i,a,0);return}e=e.next}o=o.next}while(o!==e)}function bc(e,t){let n=e.x-t.x;return n===0&&(n=e.y-t.y,n===0)&&(n=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)),n}function xc(e,t){let n=function(e,t){let n=t,r=e.x,i=e.y,a,o=-1/0;if(kc(e,n))return n;do{if(kc(e,n.next))return n.next;if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){let e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>o&&(o=e,a=n.x<n.next.x?n:n.next,e===r))return a}n=n.next}while(n!==t);if(!a)return null;let s=a,c=a.x,l=a.y,u=1/0;n=a;do{if(r>=n.x&&n.x>=c&&r!==n.x&&Tc(i<l?r:o,i,c,l,i<l?o:r,i,n.x,n.y)){let t=Math.abs(i-n.y)/(r-n.x);Nc(n,e)&&(t<u||t===u&&(n.x>a.x||n.x===a.x&&Sc(a,n)))&&(a=n,u=t)}n=n.next}while(n!==s);return a}(e,t);if(!n)return t;let r=Pc(n,e);return mc(r,r.next),mc(n,n.next)}function Sc(e,t){return Oc(e.prev,e,t.prev)<0&&Oc(t.next,e,e.next)<0}function Cc(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function wc(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function Tc(e,t,n,r,i,a,o,s){return(i-o)*(t-s)>=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function Ec(e,t,n,r,i,a,o,s){return!(e===o&&t===s)&&Tc(e,t,n,r,i,a,o,s)}function Dc(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&Ac(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(Nc(e,t)&&Nc(t,e)&&function(e,t){let n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}(e,t)&&(Oc(e.prev,e,t.prev)||Oc(e,t.prev,t))||kc(e,t)&&Oc(e.prev,e,e.next)>0&&Oc(t.prev,t,t.next)>0)}function Oc(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function kc(e,t){return e.x===t.x&&e.y===t.y}function Ac(e,t,n,r){let i=Mc(Oc(e,t,n)),a=Mc(Oc(e,t,r)),o=Mc(Oc(n,r,e)),s=Mc(Oc(n,r,t));return i!==a&&o!==s||!(i!==0||!jc(e,n,t))||!(a!==0||!jc(e,r,t))||!(o!==0||!jc(n,e,r))||!(s!==0||!jc(n,t,r))}function jc(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function Mc(e){return e>0?1:e<0?-1:0}function Nc(e,t){return Oc(e.prev,e,e.next)<0?Oc(e,t,e.next)>=0&&Oc(e,e.prev,t)>=0:Oc(e,t,e.prev)<0||Oc(e,e.next,t)<0}function Pc(e,t){let n=Lc(e.i,e.x,e.y),r=Lc(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function Fc(e,t,n,r){let i=Lc(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Ic(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 Lc(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class Rc{constructor(e,t){if(t>e)throw Error(`Min granularity must not be greater than base granularity.`);this._baseZoomGranularity=e,this._minGranularity=t}getGranularityForZoomLevel(e){return Math.max(Math.floor(this._baseZoomGranularity/(1<<e)),this._minGranularity,1)}}class zc{constructor(e){this.fill=e.fill,this.line=e.line,this.tile=e.tile,this.stencil=e.stencil,this.circle=e.circle}}zc.noSubdivision=new zc({fill:new Rc(0,0),line:new Rc(0,0),tile:new Rc(0,0),stencil:new Rc(0,0),circle:1}),Y(`SubdivisionGranularityExpression`,Rc),Y(`SubdivisionGranularitySetting`,zc);let Bc=-32768,Vc=32767;class Hc{constructor(e,t){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=e,this._granularityCellSize=O/e,this._canonical=t}_getKey(e,t){return(e+=32768)<<16|t+32768}_vertexToIndex(e,t){if(e<-32768||t<-32768||e>32767||t>32767)throw Error(`Vertex coordinates are out of signed 16 bit integer range.`);let n=0|Math.round(e),r=0|Math.round(t),i=this._getKey(n,r);if(this._vertexDictionary.has(i))return this._vertexDictionary.get(i);let a=this._vertexBuffer.length/2;return this._vertexDictionary.set(i,a),this._vertexBuffer.push(n,r),a}_subdivideTrianglesScanline(e){if(this._granularity<2)return function(e,t){let n=[];for(let r=0;r<t.length;r+=3){let i=t[r],a=t[r+1],o=t[r+2],s=e[2*i],c=e[2*i+1];(e[2*a]-s)*(e[2*o+1]-c)-(e[2*a+1]-c)*(e[2*o]-s)>0?(n.push(i),n.push(o),n.push(a)):(n.push(i),n.push(a),n.push(o))}return n}(this._vertexBuffer,e);let t=[],n=e.length;for(let r=0;r<n;r+=3){let n=[e[r+0],e[r+1],e[r+2]],i=[this._vertexBuffer[2*e[r+0]+0],this._vertexBuffer[2*e[r+0]+1],this._vertexBuffer[2*e[r+1]+0],this._vertexBuffer[2*e[r+1]+1],this._vertexBuffer[2*e[r+2]+0],this._vertexBuffer[2*e[r+2]+1]],a=1/0,o=1/0,s=-1/0,c=-1/0;for(let e=0;e<3;e++){let t=i[2*e],n=i[2*e+1];a=Math.min(a,t),s=Math.max(s,t),o=Math.min(o,n),c=Math.max(c,n)}if(a===s||o===c)continue;let l=Math.floor(a/this._granularityCellSize),u=Math.ceil(s/this._granularityCellSize),d=Math.floor(o/this._granularityCellSize),f=Math.ceil(c/this._granularityCellSize);if(l!==u||d!==f)for(let e=d;e<f;e++){let r=this._scanlineGenerateVertexRingForCellRow(e,i,n);Gc(this._vertexBuffer,r,t)}else t.push(...n)}return t}_scanlineGenerateVertexRingForCellRow(e,t,n){let r=e*this._granularityCellSize,i=r+this._granularityCellSize,a=[];for(let e=0;e<3;e++){let o=t[2*e],s=t[2*e+1],c=t[2*(e+1)%6],l=t[(2*(e+1)+1)%6],u=t[2*(e+2)%6],d=t[(2*(e+2)+1)%6],f=c-o,p=l-s,m=f===0,h=p===0,g=(r-s)/p,_=(i-s)/p,v=Math.min(g,_),y=Math.max(g,_);if(!h&&(v>=1||y<=0)||h&&(s<r||s>i)){l>=r&&l<=i&&a.push(n[(e+1)%3]);continue}!h&&v>0&&a.push(this._vertexToIndex(o+f*v,s+p*v));let b=o+f*Math.max(v,0),x=o+f*Math.min(y,1);m||this._generateIntraEdgeVertices(a,o,s,c,l,b,x),!h&&y<1&&a.push(this._vertexToIndex(o+f*y,s+p*y)),(h||l>=r&&l<=i)&&a.push(n[(e+1)%3]),!h&&(l<=r||l>=i)&&this._generateInterEdgeVertices(a,o,s,c,l,u,d,x,r,i)}return a}_generateIntraEdgeVertices(e,t,n,r,i,a,o){let s=r-t,c=i-n,l=c===0,u=l?Math.min(t,r):Math.min(a,o),d=l?Math.max(t,r):Math.max(a,o),f=Math.floor(u/this._granularityCellSize)+1,p=Math.ceil(d/this._granularityCellSize)-1;if(l?t<r:a<o)for(let r=f;r<=p;r++){let i=r*this._granularityCellSize;e.push(this._vertexToIndex(i,n+c*(i-t)/s))}else for(let r=p;r>=f;r--){let i=r*this._granularityCellSize;e.push(this._vertexToIndex(i,n+c*(i-t)/s))}}_generateInterEdgeVertices(e,t,n,r,i,a,o,s,c,l){let u=i-n,d=a-r,f=o-i,p=(c-i)/f,m=(l-i)/f,h=Math.min(p,m),g=Math.max(p,m),_=r+d*h,v=Math.floor(Math.min(_,s)/this._granularityCellSize)+1,y=Math.ceil(Math.max(_,s)/this._granularityCellSize)-1,b=s<_,x=f===0;if(x&&(o===c||o===l))return;if(x||h>=1||g<=0){let e=n-o,r=a+(t-a)*Math.min((c-o)/e,(l-o)/e);v=Math.floor(Math.min(r,s)/this._granularityCellSize)+1,y=Math.ceil(Math.max(r,s)/this._granularityCellSize)-1,b=s<r}let S=u>0?l:c;if(b)for(let t=v;t<=y;t++)e.push(this._vertexToIndex(t*this._granularityCellSize,S));else for(let t=y;t>=v;t--)e.push(this._vertexToIndex(t*this._granularityCellSize,S))}_generateOutline(e){let t=[];for(let n of e){let e=Wc(n,this._granularity,!0),r=this._pointArrayToIndices(e),i=[];for(let e=1;e<r.length;e++)i.push(r[e-1]),i.push(r[e]);t.push(i)}return t}_handlePoles(e){let t=!1,n=!1;this._canonical&&(this._canonical.y===0&&(t=!0),this._canonical.y===(1<<this._canonical.z)-1&&(n=!0)),(t||n)&&this._fillPoles(e,t,n)}_ensureNoPoleVertices(){let e=this._vertexBuffer;for(let t=0;t<e.length;t+=2){let n=e[t+1];n===Bc&&(e[t+1]=-32767),n===Vc&&(e[t+1]=32766)}}_generatePoleQuad(e,t,n,r,i,a){r>i==(a===Bc)?(e.push(n),e.push(t),e.push(this._vertexToIndex(r,a)),e.push(this._vertexToIndex(i,a)),e.push(n),e.push(this._vertexToIndex(r,a))):(e.push(t),e.push(n),e.push(this._vertexToIndex(r,a)),e.push(n),e.push(this._vertexToIndex(i,a)),e.push(this._vertexToIndex(r,a)))}_fillPoles(e,t,n){let r=this._vertexBuffer,i=O,a=e.length;for(let o=2;o<a;o+=3){let a=e[o-2],s=e[o-1],c=e[o],l=r[2*a],u=r[2*a+1],d=r[2*s],f=r[2*s+1],p=r[2*c],m=r[2*c+1];t&&(u===0&&f===0&&this._generatePoleQuad(e,a,s,l,d,Bc),f===0&&m===0&&this._generatePoleQuad(e,s,c,d,p,Bc),m===0&&u===0&&this._generatePoleQuad(e,c,a,p,l,Bc)),n&&(u===i&&f===i&&this._generatePoleQuad(e,a,s,l,d,Vc),f===i&&m===i&&this._generatePoleQuad(e,s,c,d,p,Vc),m===i&&u===i&&this._generatePoleQuad(e,c,a,p,l,Vc))}}_initializeVertices(e){for(let t=0;t<e.length;t+=2)this._vertexToIndex(e[t],e[t+1])}subdividePolygonInternal(e,t){if(this._used)throw Error(`Subdivision: multiple use not allowed.`);this._used=!0;let{flattened:n,holeIndices:r}=function(e){let t=[],n=[];for(let r of e)if(r.length!==0){r!==e[0]&&t.push(n.length/2);for(let e=0;e<r.length;e++)n.push(r[e].x),n.push(r[e].y)}return{flattened:n,holeIndices:t}}(e),i;this._initializeVertices(n);try{let e=function(e,t,n=2){let r=t&&t.length,i=r?t[0]*n:e.length,a=pc(e,0,i,n,!0),o=[];if(!a||a.next===a.prev)return o;let s,c,l;if(r&&(a=function(e,t,n,r){let i=[];for(let n=0,a=t.length;n<a;n++){let o=pc(e,t[n]*r,n<a-1?t[n+1]*r:e.length,r,!1);o===o.next&&(o.steiner=!0),i.push(wc(o))}i.sort(bc);for(let e=0;e<i.length;e++)n=xc(i[e],n);return n}(e,t,a,n)),e.length>80*n){s=e[0],c=e[1];let t=s,r=c;for(let a=n;a<i;a+=n){let n=e[a],i=e[a+1];n<s&&(s=n),i<c&&(c=i),n>t&&(t=n),i>r&&(r=i)}l=Math.max(t-s,r-c),l=l===0?0:32767/l}return hc(a,o,n,s,c,l,0),o}(n,r),t=this._convertIndices(n,e);i=this._subdivideTrianglesScanline(t)}catch(e){console.error(e)}let a=[];return t&&(a=this._generateOutline(e)),this._ensureNoPoleVertices(),this._handlePoles(i),{verticesFlattened:this._vertexBuffer,indicesTriangles:i,indicesLineList:a}}_convertIndices(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(this._vertexToIndex(e[2*t[r]],e[2*t[r]+1]));return n}_pointArrayToIndices(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];t.push(this._vertexToIndex(r.x,r.y))}return t}}function Uc(e,t,n,r=!0){return new Hc(n,t).subdividePolygonInternal(e,r)}function Wc(e,t,r=!1){if(!e||e.length<1||e.length<2)return[];let i=e[0],a=e[e.length-1],o=r&&(i.x!==a.x||i.y!==a.y);if(t<2)return o?[...e,e[0]]:[...e];let s=Math.floor(O/t),c=[];c.push(new n(e[0].x,e[0].y));let l=e.length,u=o?l:l-1;for(let t=0;t<u;t++){let r=e[t],i=t<l-1?e[t+1]:e[0],a=r.x,o=r.y,u=i.x,d=i.y,f=a!==u,p=o!==d;if(!f&&!p)continue;let m=u-a,h=d-o,g=Math.abs(m),_=Math.abs(h),v=a,y=o;for(;;){let e=m>0?(Math.floor(v/s)+1)*s:(Math.ceil(v/s)-1)*s,t=h>0?(Math.floor(y/s)+1)*s:(Math.ceil(y/s)-1)*s,r=Math.abs(v-e),i=Math.abs(y-t),a=Math.abs(v-u),o=Math.abs(y-d),l=f?r/g:1/0,b=p?i/_:1/0;if((a<=r||!f)&&(o<=i||!p))break;if(l<b&&f||!p){v=e,y+=h*l;let t=new n(v,Math.round(y));c[c.length-1].x===t.x&&c[c.length-1].y===t.y||c.push(t)}else{v+=m*b,y=t;let e=new n(Math.round(v),y);c[c.length-1].x===e.x&&c[c.length-1].y===e.y||c.push(e)}}let b=new n(u,d);c[c.length-1].x===b.x&&c[c.length-1].y===b.y||c.push(b)}return c}function Gc(e,t,n){if(t.length===0)throw Error(`Subdivision vertex ring is empty.`);let r=0,i=e[2*t[0]];for(let n=1;n<t.length;n++){let a=e[2*t[n]];a<i&&(i=a,r=n)}let a=t.length,o=r,s=(o+1)%a;for(;;){let r=o-1>=0?o-1:a-1,i=(s+1)%a,c=e[2*t[r]],l=e[2*t[i]],u=e[2*t[o]],d=e[2*t[o]+1],f=e[2*t[s]+1],p=!1;if(c<l)p=!0;else if(c>l)p=!1;else{let n=f-d,a=-(e[2*t[s]]-u),o=d<f?1:-1;((c-u)*n+(e[2*t[r]+1]-d)*a)*o>((l-u)*n+(e[2*t[i]+1]-d)*a)*o&&(p=!0)}if(p){let e=t[r],i=t[o],c=t[s];e!==i&&e!==c&&i!==c&&n.push(c,i,e),o--,o<0&&(o=a-1)}else{let e=t[i],r=t[o],c=t[s];e!==r&&e!==c&&r!==c&&n.push(c,r,e),s++,s>=a&&(s=0)}if(r===i)break}}function Kc(e,t,n,r,i,a,o,s,c){let l=i.length/2,u=o&&s&&c;if(l<Uo.MAX_VERTEX_ARRAY_LENGTH){let d=t.prepareSegment(l,n,r),f=d.vertexLength;for(let e=0;e<a.length;e+=3)r.emplaceBack(f+a[e],f+a[e+1],f+a[e+2]);let p,m;d.vertexLength+=l,d.primitiveLength+=a.length/3,u&&(m=o.prepareSegment(l,n,s),p=m.vertexLength,m.vertexLength+=l);for(let t=0;t<i.length;t+=2)e(i[t],i[t+1]);if(u)for(let e=0;e<c.length;e++){let t=c[e];for(let e=1;e<t.length;e+=2)s.emplaceBack(p+t[e-1],p+t[e]);m.primitiveLength+=t.length/2}}else (function(e,t,n,r,i,a){let o=[];for(let e=0;e<r.length/2;e++)o.push(-1);let s={count:0},c=0,l=e.getOrCreateLatestSegment(t,n),u=l.vertexLength;for(let d=2;d<i.length;d+=3){let f=i[d-2],p=i[d-1],m=i[d],h=o[f]<c,g=o[p]<c,_=o[m]<c;l.vertexLength+((h?1:0)+(g?1:0)+(_?1:0))>Uo.MAX_VERTEX_ARRAY_LENGTH&&(l=e.createNewSegment(t,n),c=s.count,h=!0,g=!0,_=!0,u=0);let v=qc(o,r,a,s,f,h,l),y=qc(o,r,a,s,p,g,l),b=qc(o,r,a,s,m,_,l);n.emplaceBack(u+v-c,u+y-c,u+b-c),l.primitiveLength++}})(t,n,r,i,a,e),u&&function(e,t,n,r,i,a){let o=[];for(let e=0;e<r.length/2;e++)o.push(-1);let s={count:0},c=0,l=e.getOrCreateLatestSegment(t,n),u=l.vertexLength;for(let d=0;d<i.length;d++){let f=i[d];for(let p=1;p<i[d].length;p+=2){let i=f[p-1],d=f[p],m=o[i]<c,h=o[d]<c;l.vertexLength+((m?1:0)+(h?1:0))>Uo.MAX_VERTEX_ARRAY_LENGTH&&(l=e.createNewSegment(t,n),c=s.count,m=!0,h=!0,u=0);let g=qc(o,r,a,s,i,m,l),_=qc(o,r,a,s,d,h,l);n.emplaceBack(u+g-c,u+_-c),l.primitiveLength++}}}(o,n,s,i,c,e),t.forceNewSegmentOnNextPrepare(),o?.forceNewSegmentOnNextPrepare()}function qc(e,t,n,r,i,a,o){if(a){let a=r.count;return n(t[2*i],t[2*i+1]),e[i]=r.count,r.count++,o.vertexLength++,a}return e[i]}class Jc{constructor(e){this.zoom=e.zoom,this.globalState=e.globalState,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Ao,this.indexArray=new Bo,this.indexArray2=new Vo,this.programConfigurations=new hs(e.layers,e.zoom),this.segments=new Uo,this.segments2=new Uo,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,n){this.hasPattern=dc(`fill`,this.layers,t);let r=this.layers[0].layout.get(`fill-sort-key`),i=!r.isConstant(),a=[];for(let{feature:o,id:s,index:c,sourceLayerIndex:l}of e){let e=this.layers[0]._featureFilter.needGeometry,u=xs(o,e);if(!this.layers[0]._featureFilter.filter(new Ea(this.zoom,{globalState:this.globalState}),u,n))continue;let d=i?r.evaluate(u,{},n,t.availableImages):void 0,f={id:s,properties:o.properties,type:o.type,sourceLayerIndex:l,index:c,geometry:e?u.geometry:bs(o),patterns:{},sortKey:d};a.push(f)}i&&a.sort(((e,t)=>e.sortKey-t.sortKey));for(let r of a){let{geometry:i,index:a,sourceLayerIndex:o}=r;if(this.hasPattern){let e=fc(`fill`,this.layers,r,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(r,i,a,n,{},t.subdivisionGranularity);t.featureIndex.insert(e[a].feature,i,a,o,this.index)}}update(e,t,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:n,globalState:this.globalState})}addFeatures(e,t,n){for(let r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,t,n,e.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,uc),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,n,r,i,a){for(let e of ir(t,500)){let t=Uc(e,r,a.fill.getGranularityForZoomLevel(r.z)),n=this.layoutVertexArray;Kc(((e,t)=>{n.emplaceBack(e,t)}),this.segments,this.layoutVertexArray,this.indexArray,t.verticesFlattened,t.indicesTriangles,this.segments2,this.indexArray2,t.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,{imagePositions:i,canonical:r,globalState:this.globalState})}}let Yc,Xc;Y(`FillBucket`,Jc,{omit:[`layers`,`patternFeatures`]});var Zc={get paint(){return Xc||=new Ra({"fill-antialias":new Q(I.paint_fill[`fill-antialias`]),"fill-opacity":new $(I.paint_fill[`fill-opacity`]),"fill-color":new $(I.paint_fill[`fill-color`]),"fill-outline-color":new $(I.paint_fill[`fill-outline-color`]),"fill-translate":new Q(I.paint_fill[`fill-translate`]),"fill-translate-anchor":new Q(I.paint_fill[`fill-translate-anchor`]),"fill-pattern":new Fa(I.paint_fill[`fill-pattern`])})},get layout(){return Yc||=new Ra({"fill-sort-key":new $(I.layout_fill[`fill-sort-key`])})}};class Qc extends Ba{constructor(e){super(e,Zc)}recalculate(e,t){super.recalculate(e,t);let n=this.paint._values[`fill-outline-color`];n.value.kind===`constant`&&n.value.value===void 0&&(this.paint._values[`fill-outline-color`]=this.paint._values[`fill-color`])}createBucket(e){return new Jc(e)}queryRadius(){return Ls(this.paint.get(`fill-translate`))}queryIntersectsFeature({queryGeometry:e,geometry:t,transform:n,pixelsToTileUnits:r}){return Ds(Rs(e,this.paint.get(`fill-translate`),this.paint.get(`fill-translate-anchor`),-n.bearingInRadians,r),t)}isTileClipped(){return!0}}let $c=Wa([{name:`a_pos`,components:2,type:`Int16`},{name:`a_normal_ed`,components:4,type:`Int16`}],4),el=Wa([{name:`a_centroid`,components:2,type:`Int16`}],4),{members:tl}=$c;class nl{constructor(e,t,n,r,i){this.properties={},this.extent=n,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=r,this._values=i,e.readFields(rl,this,t)}loadGeometry(){let e=this._pbf;e.pos=this._geometry;let t=e.readVarint()+e.pos,r=[],i,a=1,o=0,s=0,c=0;for(;e.pos<t;){if(o<=0){let t=e.readVarint();a=7&t,o=t>>3}if(o--,a===1||a===2)s+=e.readSVarint(),c+=e.readSVarint(),a===1&&(i&&r.push(i),i=[]),i&&i.push(new n(s,c));else{if(a!==7)throw Error(`unknown command ${a}`);i&&i.push(i[0].clone())}}return i&&r.push(i),r}bbox(){let e=this._pbf;e.pos=this._geometry;let t=e.readVarint()+e.pos,n=1,r=0,i=0,a=0,o=1/0,s=-1/0,c=1/0,l=-1/0;for(;e.pos<t;){if(r<=0){let t=e.readVarint();n=7&t,r=t>>3}if(r--,n===1||n===2)i+=e.readSVarint(),a+=e.readSVarint(),i<o&&(o=i),i>s&&(s=i),a<c&&(c=a),a>l&&(l=a);else if(n!==7)throw Error(`unknown command ${n}`)}return[o,c,s,l]}toGeoJSON(e,t,n){let r=this.extent*2**n,i=this.extent*e,a=this.extent*t,o=this.loadGeometry();function s(e){return[360*(e.x+i)/r-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+a)/r)*Math.PI))-90]}function c(e){return e.map(s)}let l;if(this.type===1){let e=[];for(let t of o)e.push(t[0]);let t=c(e);l=e.length===1?{type:`Point`,coordinates:t[0]}:{type:`MultiPoint`,coordinates:t}}else if(this.type===2){let e=o.map(c);l=e.length===1?{type:`LineString`,coordinates:e[0]}:{type:`MultiLineString`,coordinates:e}}else{if(this.type!==3)throw Error(`unknown feature type`);{let e=function(e){let t=e.length;if(t<=1)return[e];let n=[],r,i;for(let a=0;a<t;a++){let t=il(e[a]);t!==0&&(i===void 0&&(i=t<0),i===t<0?(r&&n.push(r),r=[e[a]]):r&&r.push(e[a]))}return r&&n.push(r),n}(o),t=[];for(let n of e)t.push(n.map(c));l=t.length===1?{type:`Polygon`,coordinates:t[0]}:{type:`MultiPolygon`,coordinates:t}}}let u={type:`Feature`,geometry:l,properties:this.properties};return this.id!=null&&(u.id=this.id),u}}function rl(e,t,n){e===1?t.id=n.readVarint():e===2?function(e,t){let n=e.readVarint()+e.pos;for(;e.pos<n;){let n=t._keys[e.readVarint()],r=t._values[e.readVarint()];t.properties[n]=r}}(n,t):e===3?t.type=n.readVarint():e===4&&(t._geometry=n.pos)}function il(e){let t=0;for(let n,r,i=0,a=e.length,o=a-1;i<a;o=i++)n=e[i],r=e[o],t+=(r.x-n.x)*(n.y+r.y);return t}nl.types=[`Unknown`,`Point`,`LineString`,`Polygon`];class al{constructor(e,t){this.version=1,this.name=``,this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(ol,this,t),this.length=this._features.length}feature(e){if(e<0||e>=this._features.length)throw Error(`feature index out of bounds`);this._pbf.pos=this._features[e];let t=this._pbf.readVarint()+this._pbf.pos;return new nl(this._pbf,t,this.extent,this._keys,this._values)}}function ol(e,t,n){e===15?t.version=n.readVarint():e===1?t.name=n.readString():e===5?t.extent=n.readVarint():e===2?t._features.push(n.pos):e===3?t._keys.push(n.readString()):e===4&&t._values.push(function(e){let t=null,n=e.readVarint()+e.pos;for(;e.pos<n;){let n=e.readVarint()>>3;t=n===1?e.readString():n===2?e.readFloat():n===3?e.readDouble():n===4?e.readVarint64():n===5?e.readVarint():n===6?e.readSVarint():n===7?e.readBoolean():null}if(t==null)throw Error(`unknown feature value`);return t}(n))}class sl{constructor(e,t){this.layers=e.readFields(cl,{},t)}}function cl(e,t,n){if(e===3){let e=new al(n,n.readVarint()+n.pos);e.length&&(t[e.name]=e)}}let ll=2**13;function ul(e,t,n,r,i,a,o,s){e.emplaceBack(t,n,2*Math.floor(r*ll)+o,i*ll*2,a*ll*2,Math.round(s))}class dl{constructor(e){this.zoom=e.zoom,this.globalState=e.globalState,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasPattern=!1,this.layoutVertexArray=new jo,this.centroidVertexArray=new Oo,this.indexArray=new Bo,this.programConfigurations=new hs(e.layers,e.zoom),this.segments=new Uo,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,n){this.features=[],this.hasPattern=dc(`fill-extrusion`,this.layers,t);for(let{feature:r,id:i,index:a,sourceLayerIndex:o}of e){let e=this.layers[0]._featureFilter.needGeometry,s=xs(r,e);if(!this.layers[0]._featureFilter.filter(new Ea(this.zoom,{globalState:this.globalState}),s,n))continue;let c={id:i,sourceLayerIndex:o,index:a,geometry:e?s.geometry:bs(r),properties:r.properties,type:r.type,patterns:{}};this.hasPattern?this.features.push(fc(`fill-extrusion`,this.layers,c,this.zoom,t)):this.addFeature(c,c.geometry,a,n,{},t.subdivisionGranularity),t.featureIndex.insert(r,c.geometry,a,o,this.index,!0)}}addFeatures(e,t,n){for(let r of this.features){let{geometry:i}=r;this.addFeature(r,i,r.index,t,n,e.subdivisionGranularity)}}update(e,t,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:n,globalState:this.globalState})}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,tl),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,el.members,!0),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(e,t,n,r,i,a){for(let n of ir(t,500)){let t={x:0,y:0,sampleCount:0},i=this.layoutVertexArray.length;this.processPolygon(t,r,e,n,a);let o=this.layoutVertexArray.length-i,s=Math.floor(t.x/t.sampleCount),c=Math.floor(t.y/t.sampleCount);for(let e=0;e<o;e++)this.centroidVertexArray.emplaceBack(s,c)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,{imagePositions:i,canonical:r,globalState:this.globalState})}processPolygon(e,t,n,r,i){if(r.length<1||ml(r[0]))return;for(let t of r)t.length!==0&&fl(e,t);let a={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},o=i.fill.getGranularityForZoomLevel(t.z),s=nl.types[n.type]===`Polygon`;for(let e of r){if(e.length===0||ml(e))continue;let t=Wc(e,o,s);this._generateSideFaces(t,a)}if(!s)return;let c=Uc(r,t,o,!1),l=this.layoutVertexArray;Kc(((e,t)=>{ul(l,e,t,0,0,1,1,0)}),this.segments,this.layoutVertexArray,this.indexArray,c.verticesFlattened,c.indicesTriangles)}_generateSideFaces(e,t){let n=0;for(let r=1;r<e.length;r++){let i=e[r],a=e[r-1];if(pl(i,a))continue;t.segment.vertexLength+4>Uo.MAX_VERTEX_ARRAY_LENGTH&&(t.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));let o=i.sub(a)._perp()._unit(),s=a.dist(i);n+s>32768&&(n=0),ul(this.layoutVertexArray,i.x,i.y,o.x,o.y,0,0,n),ul(this.layoutVertexArray,i.x,i.y,o.x,o.y,0,1,n),n+=s,ul(this.layoutVertexArray,a.x,a.y,o.x,o.y,0,0,n),ul(this.layoutVertexArray,a.x,a.y,o.x,o.y,0,1,n);let c=t.segment.vertexLength;this.indexArray.emplaceBack(c,c+2,c+1),this.indexArray.emplaceBack(c+1,c+2,c+3),t.segment.vertexLength+=4,t.segment.primitiveLength+=2}}}function fl(e,t){for(let n=0;n<t.length;n++){let r=t[n];n===t.length-1&&t[0].x===r.x&&t[0].y===r.y||(e.x+=r.x,e.y+=r.y,e.sampleCount++)}}function pl(e,t){return e.x===t.x&&(e.x<0||e.x>O)||e.y===t.y&&(e.y<0||e.y>O)}function ml(e){return e.every((e=>e.x<0))||e.every((e=>e.x>O))||e.every((e=>e.y<0))||e.every((e=>e.y>O))}let hl;Y(`FillExtrusionBucket`,dl,{omit:[`layers`,`features`]});var gl={get paint(){return hl||=new Ra({"fill-extrusion-opacity":new Q(I[`paint_fill-extrusion`][`fill-extrusion-opacity`]),"fill-extrusion-color":new $(I[`paint_fill-extrusion`][`fill-extrusion-color`]),"fill-extrusion-translate":new Q(I[`paint_fill-extrusion`][`fill-extrusion-translate`]),"fill-extrusion-translate-anchor":new Q(I[`paint_fill-extrusion`][`fill-extrusion-translate-anchor`]),"fill-extrusion-pattern":new Fa(I[`paint_fill-extrusion`][`fill-extrusion-pattern`]),"fill-extrusion-height":new $(I[`paint_fill-extrusion`][`fill-extrusion-height`]),"fill-extrusion-base":new $(I[`paint_fill-extrusion`][`fill-extrusion-base`]),"fill-extrusion-vertical-gradient":new Q(I[`paint_fill-extrusion`][`fill-extrusion-vertical-gradient`])})}};class _l extends Ba{constructor(e){super(e,gl)}createBucket(e){return new dl(e)}queryRadius(){return Ls(this.paint.get(`fill-extrusion-translate`))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:r,geometry:i,transform:a,pixelsToTileUnits:o,pixelPosMatrix:s}){let c=Rs(e,this.paint.get(`fill-extrusion-translate`),this.paint.get(`fill-extrusion-translate-anchor`),-a.bearingInRadians,o),l=this.paint.get(`fill-extrusion-height`).evaluate(t,r),u=this.paint.get(`fill-extrusion-base`).evaluate(t,r),d=function(e,t){let r=[];for(let i of e){let e=[i.x,i.y,0,1];C(e,e,t),r.push(new n(e[0]/e[3],e[1]/e[3]))}return r}(c,s),f=function(e,t,r,i){let a=[],o=[],s=i[8]*t,c=i[9]*t,l=i[10]*t,u=i[11]*t,d=i[8]*r,f=i[9]*r,p=i[10]*r,m=i[11]*r;for(let t of e){let e=[],r=[];for(let a of t){let t=a.x,o=a.y,h=i[0]*t+i[4]*o+i[12],g=i[1]*t+i[5]*o+i[13],_=i[2]*t+i[6]*o+i[14],v=i[3]*t+i[7]*o+i[15],y=_+l,b=v+u,x=h+d,S=g+f,C=_+p,w=v+m,T=new n((h+s)/b,(g+c)/b);T.z=y/b,e.push(T);let E=new n(x/w,S/w);E.z=C/w,r.push(E)}a.push(e),o.push(r)}return[a,o]}(i,u,l,s);return function(e,t,n){let r=1/0;Ds(n,t)&&(r=yl(n,t[0]));for(let i=0;i<t.length;i++){let a=t[i],o=e[i];for(let e=0;e<a.length-1;e++){let t=a[e],i=[t,a[e+1],o[e+1],o[e],t];Ts(n,i)&&(r=Math.min(r,yl(n,i)))}}return r!==1/0&&r}(f[0],f[1],d)}}function vl(e,t){return e.x*t.x+e.y*t.y}function yl(e,t){if(e.length===1){let n=0,r=t[n++],i;for(;!i||r.equals(i);)if(i=t[n++],!i)return 1/0;for(;n<t.length;n++){let a=t[n],o=e[0],s=i.sub(r),c=a.sub(r),l=o.sub(r),u=vl(s,s),d=vl(s,c),f=vl(c,c),p=vl(l,s),m=vl(l,c),h=u*f-d*d,g=(f*p-d*m)/h,_=(u*m-d*p)/h,v=r.z*(1-g-_)+i.z*g+a.z*_;if(isFinite(v))return v}return 1/0}{let e=1/0;for(let n of t)e=Math.min(e,n.z);return e}}let{members:bl}=Wa([{name:`a_pos_normal`,components:2,type:`Int16`},{name:`a_data`,components:4,type:`Uint8`}],4),{members:xl}=Wa([{name:`a_uv_x`,components:1,type:`Float32`},{name:`a_split_index`,components:1,type:`Float32`}]),Sl=Math.cos(Math.PI/180*37.5),Cl=2**14/.5;class wl{constructor(e){this.zoom=e.zoom,this.globalState=e.globalState,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((e=>{this.gradients[e.id]={}})),this.layoutVertexArray=new Mo,this.layoutVertexArray2=new No,this.indexArray=new Bo,this.programConfigurations=new hs(e.layers,e.zoom),this.segments=new Uo,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,n){this.hasPattern=dc(`line`,this.layers,t);let r=this.layers[0].layout.get(`line-sort-key`),i=!r.isConstant(),a=[];for(let{feature:t,id:o,index:s,sourceLayerIndex:c}of e){let e=this.layers[0]._featureFilter.needGeometry,l=xs(t,e);if(!this.layers[0]._featureFilter.filter(new Ea(this.zoom,{globalState:this.globalState}),l,n))continue;let u=i?r.evaluate(l,{},n):void 0,d={id:o,properties:t.properties,type:t.type,sourceLayerIndex:c,index:s,geometry:e?l.geometry:bs(t),patterns:{},sortKey:u};a.push(d)}i&&a.sort(((e,t)=>e.sortKey-t.sortKey));for(let r of a){let{geometry:i,index:a,sourceLayerIndex:o}=r;if(this.hasPattern){let e=fc(`line`,this.layers,r,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(r,i,a,n,{},t.subdivisionGranularity);t.featureIndex.insert(e[a].feature,i,a,o,this.index)}}update(e,t,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:n,globalState:this.globalState})}addFeatures(e,t,n){for(let r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,t,n,e.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,xl)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,bl),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&Object.prototype.hasOwnProperty.call(e.properties,`mapbox_clip_start`)&&Object.prototype.hasOwnProperty.call(e.properties,`mapbox_clip_end`))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,t,n,r,i,a){let o=this.layers[0].layout,s=o.get(`line-join`).evaluate(e,{}),c=o.get(`line-cap`),l=o.get(`line-miter-limit`),u=o.get(`line-round-limit`);this.lineClips=this.lineFeatureClips(e);for(let n of t)this.addLine(n,e,s,c,l,u,r,a);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,{imagePositions:i,canonical:r,globalState:this.globalState})}addLine(e,t,n,r,i,a,o,s){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=Wc(e,o?s.line.getGranularityForZoomLevel(o.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t<e.length-1;t++)this.totalDistance+=e[t].dist(e[t+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}let c=nl.types[t.type]===`Polygon`,l=e.length;for(;l>=2&&e[l-1].equals(e[l-2]);)l--;let u=0;for(;u<l-1&&e[u].equals(e[u+1]);)u++;if(l<(c?3:2))return;n===`bevel`&&(i=1.05);let d=this.overscaling<=16?122880/(512*this.overscaling):0,f=this.segments.prepareSegment(10*l,this.layoutVertexArray,this.indexArray),p,m,h,g,_;this.e1=this.e2=-1,c&&(p=e[l-2],_=e[u].sub(p)._unit()._perp());for(let t=u;t<l;t++){if(h=t===l-1?c?e[u+1]:void 0:e[t+1],h&&e[t].equals(h))continue;_&&(g=_),p&&(m=p),p=e[t],_=h?h.sub(p)._unit()._perp():g,g||=_;let o=g.add(_);o.x===0&&o.y===0||o._unit();let s=g.x*_.x+g.y*_.y,v=o.x*_.x+o.y*_.y,y=v===0?1/0:1/v,b=2*Math.sqrt(2-2*v),x=v<Sl&&m&&h,S=g.x*_.y-g.y*_.x>0;if(x&&t>u){let e=p.dist(m);if(e>2*d){let t=p.sub(p.sub(m)._mult(d/e)._round());this.updateDistance(m,t),this.addCurrentVertex(t,g,0,0,f),m=t}}let C=m&&h,w=C?n:c?`butt`:r;if(C&&w===`round`&&(y<a?w=`miter`:y<=2&&(w=`fakeround`)),w===`miter`&&y>i&&(w=`bevel`),w===`bevel`&&(y>2&&(w=`flipbevel`),y<i&&(w=`miter`)),m&&this.updateDistance(m,p),w===`miter`)o._mult(y),this.addCurrentVertex(p,o,0,0,f);else if(w===`flipbevel`){if(y>100)o=_.mult(-1);else{let e=y*g.add(_).mag()/g.sub(_).mag();o._perp()._mult(e*(S?-1:1))}this.addCurrentVertex(p,o,0,0,f),this.addCurrentVertex(p,o.mult(-1),0,0,f)}else if(w===`bevel`||w===`fakeround`){let e=-Math.sqrt(y*y-1),t=S?e:0,n=S?0:e;if(m&&this.addCurrentVertex(p,g,t,n,f),w===`fakeround`){let e=Math.round(180*b/Math.PI/20);for(let t=1;t<e;t++){let n=t/e;if(n!==.5){let e=n-.5;n+=n*e*(n-1)*((1.0904+s*(s*(3.55645-1.43519*s)-3.2452))*e*e+(.848013+s*(.215638*s-1.06021)))}let r=_.sub(g)._mult(n)._add(g)._unit()._mult(S?-1:1);this.addHalfVertex(p,r.x,r.y,!1,S,0,f)}}h&&this.addCurrentVertex(p,_,-t,-n,f)}else if(w===`butt`)this.addCurrentVertex(p,o,0,0,f);else if(w===`square`){let e=m?1:-1;this.addCurrentVertex(p,o,e,e,f)}else w===`round`&&(m&&(this.addCurrentVertex(p,g,0,0,f),this.addCurrentVertex(p,g,1,1,f,!0)),h&&(this.addCurrentVertex(p,_,-1,-1,f,!0),this.addCurrentVertex(p,_,0,0,f)));if(x&&t<l-1){let e=p.dist(h);if(e>2*d){let t=p.add(h.sub(p)._mult(d/e)._round());this.updateDistance(p,t),this.addCurrentVertex(t,_,0,0,f),p=t}}}}addCurrentVertex(e,t,n,r,i,a=!1){let o=t.y*r-t.x,s=-t.y-t.x*r;this.addHalfVertex(e,t.x+t.y*n,t.y-t.x*n,a,!1,n,i),this.addHalfVertex(e,o,s,a,!0,-r,i),this.distance>Cl/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,t,n,r,i,a))}addHalfVertex({x:e,y:t},n,r,i,a,o,s){let c=.5*(this.lineClips?this.scaledDistance*(Cl-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(i?1:0),(t<<1)+(a?1:0),Math.round(63*n)+128,Math.round(63*r)+128,1+(o===0?0:o<0?-1:1)|(63&c)<<2,c>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);let l=s.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,l,this.e2),s.primitiveLength++),a?this.e2=l:this.e1=l}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}}let Tl,El;Y(`LineBucket`,wl,{omit:[`layers`,`patternFeatures`]});var Dl={get paint(){return El||=new Ra({"line-opacity":new $(I.paint_line[`line-opacity`]),"line-color":new $(I.paint_line[`line-color`]),"line-translate":new Q(I.paint_line[`line-translate`]),"line-translate-anchor":new Q(I.paint_line[`line-translate-anchor`]),"line-width":new $(I.paint_line[`line-width`]),"line-gap-width":new $(I.paint_line[`line-gap-width`]),"line-offset":new $(I.paint_line[`line-offset`]),"line-blur":new $(I.paint_line[`line-blur`]),"line-dasharray":new Ia(I.paint_line[`line-dasharray`]),"line-pattern":new Fa(I.paint_line[`line-pattern`]),"line-gradient":new La(I.paint_line[`line-gradient`])})},get layout(){return Tl||=new Ra({"line-cap":new Q(I.layout_line[`line-cap`]),"line-join":new $(I.layout_line[`line-join`]),"line-miter-limit":new Q(I.layout_line[`line-miter-limit`]),"line-round-limit":new Q(I.layout_line[`line-round-limit`]),"line-sort-key":new $(I.layout_line[`line-sort-key`])})}};class Ol extends ${possiblyEvaluate(e,t){return t=new Ea(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,n,r){return t=F({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,n,r)}}let kl;class Al extends Ba{constructor(e){super(e,Dl),this.gradientVersion=0,kl||(kl=new Ol(Dl.paint.properties[`line-width`].specification),kl.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if(e===`line-gradient`){let e=this.gradientExpression();this.stepInterpolant=!!function(e){return e._styleExpression!==void 0}(e)&&e._styleExpression.expression instanceof fn,this.gradientVersion=(this.gradientVersion+1)%(2**53-1)}}gradientExpression(){return this._transitionablePaint._values[`line-gradient`].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values[`line-floorwidth`]=kl.possiblyEvaluate(this._transitioningPaint._values[`line-width`].value,e)}createBucket(e){return new wl(e)}queryRadius(e){let t=e,n=jl(Is(`line-width`,this,t),Is(`line-gap-width`,this,t)),r=Is(`line-offset`,this,t);return n/2+Math.abs(r)+Ls(this.paint.get(`line-translate`))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:r,geometry:i,transform:a,pixelsToTileUnits:o}){let s=Rs(e,this.paint.get(`line-translate`),this.paint.get(`line-translate-anchor`),-a.bearingInRadians,o),c=o/2*jl(this.paint.get(`line-width`).evaluate(t,r),this.paint.get(`line-gap-width`).evaluate(t,r)),l=this.paint.get(`line-offset`).evaluate(t,r);return l&&(i=function(e,t){let r=[];for(let i=0;i<e.length;i++){let a=e[i],o=[];for(let e=0;e<a.length;e++){let r=a[e-1],i=a[e],s=a[e+1],c=e===0?new n(0,0):i.sub(r)._unit()._perp(),l=e===a.length-1?new n(0,0):s.sub(i)._unit()._perp(),u=c._add(l)._unit(),d=u.x*l.x+u.y*l.y;d!==0&&u._mult(1/d),o.push(u._mult(t)._add(i))}r.push(o)}return r}(i,l*o)),function(e,t,n){for(let r=0;r<t.length;r++){let i=t[r];if(e.length>=3){for(let t=0;t<i.length;t++)if(Ps(e,i[t]))return!0}if(Os(e,i,n))return!0}return!1}(s,i,c)}isTileClipped(){return!0}}function jl(e,t){return t>0?t+2*e:e}let Ml=Wa([{name:`a_pos_offset`,components:4,type:`Int16`},{name:`a_data`,components:4,type:`Uint16`},{name:`a_pixeloffset`,components:4,type:`Int16`}],4),Nl=Wa([{name:`a_projected_pos`,components:3,type:`Float32`}],4);Wa([{name:`a_fade_opacity`,components:1,type:`Uint32`}],4);let Pl=Wa([{name:`a_placed`,components:2,type:`Uint8`},{name:`a_shift`,components:2,type:`Float32`},{name:`a_box_real`,components:2,type:`Int16`}]);Wa([{type:`Int16`,name:`anchorPointX`},{type:`Int16`,name:`anchorPointY`},{type:`Int16`,name:`x1`},{type:`Int16`,name:`y1`},{type:`Int16`,name:`x2`},{type:`Int16`,name:`y2`},{type:`Uint32`,name:`featureIndex`},{type:`Uint16`,name:`sourceLayerIndex`},{type:`Uint16`,name:`bucketIndex`}]);let Fl=Wa([{name:`a_pos`,components:2,type:`Int16`},{name:`a_anchor_pos`,components:2,type:`Int16`},{name:`a_extrude`,components:2,type:`Int16`}],4),Il=Wa([{name:`a_pos`,components:2,type:`Float32`},{name:`a_radius`,components:1,type:`Float32`},{name:`a_flags`,components:2,type:`Int16`}],4);Wa([{name:`triangle`,components:3,type:`Uint16`}]),Wa([{type:`Int16`,name:`anchorX`},{type:`Int16`,name:`anchorY`},{type:`Uint32`,name:`glyphStartIndex`},{type:`Uint32`,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`}]),Wa([{type:`Int16`,name:`anchorX`},{type:`Int16`,name:`anchorY`},{type:`Int16`,name:`rightJustifiedTextSymbolIndex`},{type:`Int16`,name:`centerJustifiedTextSymbolIndex`},{type:`Int16`,name:`leftJustifiedTextSymbolIndex`},{type:`Int16`,name:`verticalPlacedTextSymbolIndex`},{type:`Int16`,name:`placedIconSymbolIndex`},{type:`Int16`,name:`verticalPlacedIconSymbolIndex`},{type:`Uint16`,name:`key`},{type:`Uint16`,name:`textBoxStartIndex`},{type:`Uint16`,name:`textBoxEndIndex`},{type:`Uint16`,name:`verticalTextBoxStartIndex`},{type:`Uint16`,name:`verticalTextBoxEndIndex`},{type:`Uint16`,name:`iconBoxStartIndex`},{type:`Uint16`,name:`iconBoxEndIndex`},{type:`Uint16`,name:`verticalIconBoxStartIndex`},{type:`Uint16`,name:`verticalIconBoxEndIndex`},{type:`Uint16`,name:`featureIndex`},{type:`Uint16`,name:`numHorizontalGlyphVertices`},{type:`Uint16`,name:`numVerticalGlyphVertices`},{type:`Uint16`,name:`numIconVertices`},{type:`Uint16`,name:`numVerticalIconVertices`},{type:`Uint16`,name:`useRuntimeCollisionCircles`},{type:`Uint32`,name:`crossTileID`},{type:`Float32`,name:`textBoxScale`},{type:`Float32`,name:`collisionCircleDiameter`},{type:`Uint16`,name:`textAnchorOffsetStartIndex`},{type:`Uint16`,name:`textAnchorOffsetEndIndex`},{type:`Float32`,name:`angle`}]),Wa([{type:`Float32`,name:`offsetX`}]),Wa([{type:`Int16`,name:`x`},{type:`Int16`,name:`y`},{type:`Int16`,name:`tileUnitDistanceFromAnchor`}]),Wa([{type:`Uint16`,name:`textAnchor`},{type:`Float32`,components:2,name:`textOffset`}]);let Ll={debnames:`Jacob Marisplein`,logLineStrings(e,t,n){let r=40265318;for(let e=0;e<t.z;e++)r/=2;let i=t.x*r-20132659,a=20132659-t.y*r,o=r/8192,s=`SELECT 'SRID=33013;MULTILINESTRING(`;for(let t=0;t<e.length;t++){let n=e[t];s=`${s}(`;for(let e=0;e<n.length;e++)s=`${s+(n[e].x*o+i)} ${a-n[e].y*o}`,e<n.length-1&&(s=`${s},`);s=`${s})`,t<e.length-1&&(s=`${s},`)}s=`${s})'::geometry`,n!==void 0&&console.log(n),console.log(s)},logPoints(e,t){let n=40265318;for(let e=0;e<t.z;e++)n/=2;let r=t.x*n-20132659,i=20132659-t.y*n,a=n/8192,o=`SELECT 'SRID=33013;MULTIPOINT(`;for(let t=0;t<e.length;t++)o=`${o+(e[t].x*a+r)} ${i-e[t].y*a}`,t<e.length-1&&(o=`${o},`);o=`${o})'::geometry`,console.log(o)},logPoint(e,t,n){let r=40265318;for(let e=0;e<t.z;e++)r/=2;let i=t.x*r-20132659,a=20132659-t.y*r,o=r/8192;n!==void 0&&console.log(n),console.log(`SELECT 'SRID=33013;POINT(${e.x*o+i} ${a-e.y*o})'::geometry`)}};function Rl(e){let t=0;for(let n=0;n<e.length-1;n++)t+=e[n].dist(e[n+1]);return t}function zl(e,t,n){return e.sections.forEach((e=>{e.text=function(e,t,n){let r=t.layout.get(`text-transform`).evaluate(n,{});return r===`uppercase`?e=e.toLocaleUpperCase():r===`lowercase`&&(e=e.toLocaleLowerCase()),Ta.applyArabicShaping&&(e=Ta.applyArabicShaping(e)),e}(e.text,t,n)})),e}function Bl(e,t){function n(e,t){let n=t?e[0]:e[e.length-1];return`${n.x}:${n.y}`}function r(e){function t(t){let r=n(e,t),i=o.get(r);a[i]=[],o.delete(r)}t(!0),t(!1)}function i(e,t,n){e!==t&&(o.set(e,n),o.set(t,n))}let a=[],o=new Map;e.lines.forEach((e=>{let s=n(e,!0),c=n(e,!1),l=o.get(s),u=o.get(c);if(l!==void 0&&u!==void 0&&l!==u){let o=a[l],d=a[u],f=n(o,!0)===s,p=n(d,!0)===c;if(t||!f&&p){r(o),r(d),f&&o.reverse(),p||d.reverse();let t=o.concat(e.slice(1),d.slice(1));s=n(t,!0),c=n(t,!1),a[l]=t,i(s,c,l)}else a.push(e)}else if(l!==void 0||u!==void 0){let o=l!==void 0,d=l===void 0?u:l,f=a[d],p=n(f,!0)===(l===void 0?c:s),m;r(f),o===!p?m=o?f.concat(e.slice(1)):e.concat(f.slice(1)):t?(o&&e.reverse(),p||f.reverse(),m=e.concat(f.slice(1))):(m=f,a.push(e)),s=n(m,!0),c=n(m,!1),a[d]=m,i(s,c,d)}else i(s,c,a.push(e)-1)}));let s=e.feature;return s.geometry=a.filter((e=>e.length>0)),s}let Vl={"!":`︕`,"#":`#`,$:`$`,"%":`%`,"&":`&`,"(":`︵`,")":`︶`,"*":`*`,"+":`+`,",":`︐`,"-":`︲`,".":`・`,"/":`/`,":":`︓`,";":`︔`,"<":`︿`,"=":`=`,">":`﹀`,"?":`︖`,"@":`@`,"[":`﹇`,"\\":`\`,"]":`﹈`,"^":`^`,_:`︳`,"`":```,"{":`︷`,"|":`―`,"}":`︸`,"~":`~`,"¢":`¢`,"£":`£`,"¥":`¥`,"¦":`¦`,"¬":`¬`,"¯":` ̄`,"–":`︲`,"—":`︱`,"‘":`﹃`,"’":`﹄`,"“":`﹁`,"”":`﹂`,"…":`︙`,"‧":`・`,"₩":`₩`,"、":`︑`,"。":`︒`,"〈":`︿`,"〉":`﹀`,"《":`︽`,"》":`︾`,"「":`﹁`,"」":`﹂`,"『":`﹃`,"』":`﹄`,"【":`︻`,"】":`︼`,"〔":`︹`,"〕":`︺`,"〖":`︗`,"〗":`︘`,"!":`︕`,"(":`︵`,")":`︶`,",":`︐`,"-":`︲`,".":`・`,":":`︓`,";":`︔`,"<":`︿`,">":`﹀`,"?":`︖`,"[":`﹇`,"]":`﹈`,"_":`︳`,"{":`︷`,"|":`―`,"}":`︸`,"⦅":`︵`,"⦆":`︶`,"。":`︒`,"「":`﹁`,"」":`﹂`};var Hl=24;let Ul=4294967296,Wl=1/Ul,Gl=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`);class Kl{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,t,n=this.length){for(;this.pos<n;){let n=this.readVarint(),r=n>>3,i=this.pos;this.type=7&n,e(r,t,this),this.pos===i&&this.skip(n)}return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){let e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){let e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){let e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Ul;return this.pos+=8,e}readSFixed64(){let e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Ul;return this.pos+=8,e}readFloat(){let e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){let e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){let t=this.buf,n,r;return r=t[this.pos++],n=127&r,r<128?n:(r=t[this.pos++],n|=(127&r)<<7,r<128?n:(r=t[this.pos++],n|=(127&r)<<14,r<128?n:(r=t[this.pos++],n|=(127&r)<<21,r<128?n:(r=t[this.pos],n|=(15&r)<<28,function(e,t,n){let r=n.buf,i,a;if(a=r[n.pos++],i=(112&a)>>4,a<128||(a=r[n.pos++],i|=(127&a)<<3,a<128)||(a=r[n.pos++],i|=(127&a)<<10,a<128)||(a=r[n.pos++],i|=(127&a)<<17,a<128)||(a=r[n.pos++],i|=(127&a)<<24,a<128)||(a=r[n.pos++],i|=(1&a)<<31,a<128))return ql(e,i,t);throw Error(`Expected varint not more than 10 bytes`)}(n,e,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){let e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return!!this.readVarint()}readString(){let e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&Gl?Gl.decode(this.buf.subarray(t,e)):function(e,t,n){let r=``,i=t;for(;i<n;){let t=e[i],a,o,s,c=null,l=t>239?4:t>223?3:t>191?2:1;if(i+l>n)break;l===1?t<128&&(c=t):l===2?(a=e[i+1],(192&a)==128&&(c=(31&t)<<6|63&a,c<=127&&(c=null))):l===3?(a=e[i+1],o=e[i+2],(192&a)==128&&(192&o)==128&&(c=(15&t)<<12|(63&a)<<6|63&o,(c<=2047||c>=55296&&c<=57343)&&(c=null))):l===4&&(a=e[i+1],o=e[i+2],s=e[i+3],(192&a)==128&&(192&o)==128&&(192&s)==128&&(c=(15&t)<<18|(63&a)<<12|(63&o)<<6|63&s,(c<=65535||c>=1114112)&&(c=null))),c===null?(c=65533,l=1):c>65535&&(c-=65536,r+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),r+=String.fromCharCode(c),i+=l}return r}(this.buf,t,e)}readBytes(){let e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){let n=this.readPackedEnd();for(;this.pos<n;)e.push(this.readVarint(t));return e}readPackedSVarint(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSVarint());return e}readPackedBoolean(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readBoolean());return e}readPackedFloat(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFloat());return e}readPackedDouble(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readDouble());return e}readPackedFixed32(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed32());return e}readPackedSFixed32(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed32());return e}readPackedFixed64(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed64());return e}readPackedSFixed64(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed64());return e}readPackedEnd(){return this.type===2?this.readVarint()+this.pos:this.pos+1}skip(e){let t=7&e;if(t===0)for(;this.buf[this.pos++]>127;);else if(t===2)this.pos=this.readVarint()+this.pos;else if(t===5)this.pos+=4;else{if(t!==1)throw Error(`Unimplemented type: ${t}`);this.pos+=8}}writeTag(e,t){this.writeVarint(e<<3|t)}realloc(e){let t=this.length||16;for(;t<this.pos+e;)t*=2;if(t!==this.length){let e=new Uint8Array(t);e.set(this.buf),this.buf=e,this.dataView=new DataView(e.buffer),this.length=t}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(e){this.realloc(4),this.dataView.setInt32(this.pos,e,!0),this.pos+=4}writeSFixed32(e){this.realloc(4),this.dataView.setInt32(this.pos,e,!0),this.pos+=4}writeFixed64(e){this.realloc(8),this.dataView.setInt32(this.pos,-1&e,!0),this.dataView.setInt32(this.pos+4,Math.floor(e*Wl),!0),this.pos+=8}writeSFixed64(e){this.realloc(8),this.dataView.setInt32(this.pos,-1&e,!0),this.dataView.setInt32(this.pos+4,Math.floor(e*Wl),!0),this.pos+=8}writeVarint(e){(e=+e||0)>268435455||e<0?function(e,t){let n,r;if(e>=0?(n=e%4294967296|0,r=e/4294967296|0):(n=~(-e%4294967296),r=~(-e/4294967296),4294967295^n?n=n+1|0:(n=0,r=r+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw Error(`Given varint doesn't fit into 10 bytes`);t.realloc(10),function(e,t,n){n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,n.buf[n.pos]=127&(e>>>=7)}(n,0,t),function(e,t){let n=(7&e)<<4;t.buf[t.pos++]|=n|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))))}(r,t)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))}writeSVarint(e){this.writeVarint(e<0?2*-e-1:2*e)}writeBoolean(e){this.writeVarint(+e)}writeString(e){e=String(e),this.realloc(4*e.length),this.pos++;let t=this.pos;this.pos=function(e,t,n){for(let r,i,a=0;a<t.length;a++){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!i){r>56319||a+1===t.length?(e[n++]=239,e[n++]=191,e[n++]=189):i=r;continue}if(r<56320){e[n++]=239,e[n++]=191,e[n++]=189,i=r;continue}r=i-55296<<10|r-56320|65536,i=null}else i&&=(e[n++]=239,e[n++]=191,e[n++]=189,null);r<128?e[n++]=r:(r<2048?e[n++]=r>>6|192:(r<65536?e[n++]=r>>12|224:(e[n++]=r>>18|240,e[n++]=r>>12&63|128),e[n++]=r>>6&63|128),e[n++]=63&r|128)}return n}(this.buf,e,this.pos);let n=this.pos-t;n>=128&&Jl(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){let t=e.length;this.writeVarint(t),this.realloc(t);for(let n=0;n<t;n++)this.buf[this.pos++]=e[n]}writeRawMessage(e,t){this.pos++;let n=this.pos;e(t,this);let r=this.pos-n;r>=128&&Jl(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r}writeMessage(e,t,n){this.writeTag(e,2),this.writeRawMessage(t,n)}writePackedVarint(e,t){t.length&&this.writeMessage(e,Yl,t)}writePackedSVarint(e,t){t.length&&this.writeMessage(e,Xl,t)}writePackedBoolean(e,t){t.length&&this.writeMessage(e,$l,t)}writePackedFloat(e,t){t.length&&this.writeMessage(e,Zl,t)}writePackedDouble(e,t){t.length&&this.writeMessage(e,Ql,t)}writePackedFixed32(e,t){t.length&&this.writeMessage(e,eu,t)}writePackedSFixed32(e,t){t.length&&this.writeMessage(e,tu,t)}writePackedFixed64(e,t){t.length&&this.writeMessage(e,nu,t)}writePackedSFixed64(e,t){t.length&&this.writeMessage(e,ru,t)}writeBytesField(e,t){this.writeTag(e,2),this.writeBytes(t)}writeFixed32Field(e,t){this.writeTag(e,5),this.writeFixed32(t)}writeSFixed32Field(e,t){this.writeTag(e,5),this.writeSFixed32(t)}writeFixed64Field(e,t){this.writeTag(e,1),this.writeFixed64(t)}writeSFixed64Field(e,t){this.writeTag(e,1),this.writeSFixed64(t)}writeVarintField(e,t){this.writeTag(e,0),this.writeVarint(t)}writeSVarintField(e,t){this.writeTag(e,0),this.writeSVarint(t)}writeStringField(e,t){this.writeTag(e,2),this.writeString(t)}writeFloatField(e,t){this.writeTag(e,5),this.writeFloat(t)}writeDoubleField(e,t){this.writeTag(e,1),this.writeDouble(t)}writeBooleanField(e,t){this.writeVarintField(e,+t)}}function ql(e,t,n){return n?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function Jl(e,t,n){let r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));n.realloc(r);for(let t=n.pos-1;t>=e;t--)n.buf[t+r]=n.buf[t]}function Yl(e,t){for(let n=0;n<e.length;n++)t.writeVarint(e[n])}function Xl(e,t){for(let n=0;n<e.length;n++)t.writeSVarint(e[n])}function Zl(e,t){for(let n=0;n<e.length;n++)t.writeFloat(e[n])}function Ql(e,t){for(let n=0;n<e.length;n++)t.writeDouble(e[n])}function $l(e,t){for(let n=0;n<e.length;n++)t.writeBoolean(e[n])}function eu(e,t){for(let n=0;n<e.length;n++)t.writeFixed32(e[n])}function tu(e,t){for(let n=0;n<e.length;n++)t.writeSFixed32(e[n])}function nu(e,t){for(let n=0;n<e.length;n++)t.writeFixed64(e[n])}function ru(e,t){for(let n=0;n<e.length;n++)t.writeSFixed64(e[n])}function iu(e,t,n){e===1&&n.readMessage(au,t)}function au(e,t,n){if(e===3){let{id:e,bitmap:r,width:i,height:a,left:o,top:s,advance:c}=n.readMessage(ou,{});t.push({id:e,bitmap:new Xs({width:i+6,height:a+6},r),metrics:{width:i,height:a,left:o,top:s,advance:c}})}}function ou(e,t,n){e===1?t.id=n.readVarint():e===2?t.bitmap=n.readBytes():e===3?t.width=n.readVarint():e===4?t.height=n.readVarint():e===5?t.left=n.readSVarint():e===6?t.top=n.readSVarint():e===7&&(t.advance=n.readVarint())}function su(e){let t=0,n=0;for(let r of e)t+=r.w*r.h,n=Math.max(n,r.w);e.sort(((e,t)=>t.h-e.h));let r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),n),h:1/0}],i=0,a=0;for(let t of e)for(let e=r.length-1;e>=0;e--){let n=r[e];if(!(t.w>n.w||t.h>n.h)){if(t.x=n.x,t.y=n.y,a=Math.max(a,t.y+t.h),i=Math.max(i,t.x+t.w),t.w===n.w&&t.h===n.h){let t=r.pop();t&&e<r.length&&(r[e]=t)}else t.h===n.h?(n.x+=t.w,n.w-=t.w):t.w===n.w?(n.y+=t.h,n.h-=t.h):(r.push({x:n.x+t.w,y:n.y,w:n.w-t.w,h:t.h}),n.y+=t.h,n.h-=t.h);break}}return{w:i,h:a,fill:t/(i*a)||0}}class cu{constructor(e,{pixelRatio:t,version:n,stretchX:r,stretchY:i,content:a,textFitWidth:o,textFitHeight:s}){this.paddedRect=e,this.pixelRatio=t,this.stretchX=r,this.stretchY=i,this.content=a,this.version=n,this.textFitWidth=o,this.textFitHeight=s}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class lu{constructor(e,t){let n={},r={};this.haveRenderCallbacks=[];let i=[];this.addImages(e,n,i),this.addImages(t,r,i);let{w:a,h:o}=su(i),s=new Zs({width:a||1,height:o||1});for(let t in e){let r=e[t],i=n[t].paddedRect;Zs.copy(r.data,s,{x:0,y:0},{x:i.x+1,y:i.y+1},r.data)}for(let e in t){let n=t[e],i=r[e].paddedRect,a=i.x+1,o=i.y+1,c=n.data.width,l=n.data.height;Zs.copy(n.data,s,{x:0,y:0},{x:a,y:o},n.data),Zs.copy(n.data,s,{x:0,y:l-1},{x:a,y:o-1},{width:c,height:1}),Zs.copy(n.data,s,{x:0,y:0},{x:a,y:o+l},{width:c,height:1}),Zs.copy(n.data,s,{x:c-1,y:0},{x:a-1,y:o},{width:1,height:l}),Zs.copy(n.data,s,{x:0,y:0},{x:a+c,y:o},{width:1,height:l})}this.image=s,this.iconPositions=n,this.patternPositions=r}addImages(e,t,n){for(let r in e){let i=e[r],a={x:0,y:0,w:i.data.width+2,h:i.data.height+2};n.push(a),t[r]=new cu(a,i),i.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(e,t){e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(let n in e.updatedImages)this.patchUpdatedImage(this.iconPositions[n],e.getImage(n),t),this.patchUpdatedImage(this.patternPositions[n],e.getImage(n),t)}patchUpdatedImage(e,t,n){if(!e||!t||e.version===t.version)return;e.version=t.version;let[r,i]=e.tl;n.update(t.data,void 0,{x:r,y:i})}}var uu;Y(`ImagePosition`,cu),Y(`ImageAtlas`,lu),e.W=void 0,(uu=e.W||={})[uu.none=0]=`none`,uu[uu.horizontal=1]=`horizontal`,uu[uu.vertical=2]=`vertical`,uu[uu.horizontalOnly=3]=`horizontalOnly`;class du{constructor(){this.scale=1,this.fontStack=``,this.imageName=null,this.verticalAlign=`bottom`}static forText(e,t,n){let r=new du;return r.scale=e||1,r.fontStack=t,r.verticalAlign=n||`bottom`,r}static forImage(e,t){let n=new du;return n.imageName=e,n.verticalAlign=t||`bottom`,n}}class fu{constructor(){this.text=``,this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,t){let n=new fu;for(let r=0;r<e.sections.length;r++){let i=e.sections[r];i.image?n.addImageSection(i):n.addTextSection(i,t)}return n}length(){return this.text.length}getSection(e){return this.sections[this.sectionIndex[e]]}getSectionIndex(e){return this.sectionIndex[e]}getCharCode(e){return this.text.charCodeAt(e)}verticalizePunctuation(){this.text=function(e){let t=``;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n+1)||null,i=e.charCodeAt(n-1)||null;t+=r&&ba(r)&&!Vl[e[n+1]]||i&&ba(i)&&!Vl[e[n-1]]||!Vl[e[n]]?e[n]:Vl[e[n]]}return t}(this.text)}trim(){let e=0;for(let t=0;t<this.text.length&&hu[this.text.charCodeAt(t)];t++)e++;let t=this.text.length;for(let n=this.text.length-1;n>=0&&n>=e&&hu[this.text.charCodeAt(n)];n--)t--;this.text=this.text.substring(e,t),this.sectionIndex=this.sectionIndex.slice(e,t)}substring(e,t){let n=new fu;return n.text=this.text.substring(e,t),n.sectionIndex=this.sectionIndex.slice(e,t),n.sections=this.sections,n}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((e,t)=>Math.max(e,this.sections[t].scale)),0)}getMaxImageSize(e){let t=0,n=0;for(let r=0;r<this.length();r++){let i=this.getSection(r);if(i.imageName){let r=e[i.imageName];if(!r)continue;let a=r.displaySize;t=Math.max(t,a[0]),n=Math.max(n,a[1])}}return{maxImageWidth:t,maxImageHeight:n}}addTextSection(e,t){this.text+=e.text,this.sections.push(du.forText(e.scale,e.fontStack||t,e.verticalAlign));let n=this.sections.length-1;for(let t=0;t<e.text.length;++t)this.sectionIndex.push(n)}addImageSection(e){let t=e.image?e.image.name:``;if(t.length===0)return void se(`Can't add FormattedSection with an empty image.`);let n=this.getNextImageSectionCharCode();n?(this.text+=String.fromCharCode(n),this.sections.push(du.forImage(t,e.verticalAlign)),this.sectionIndex.push(this.sections.length-1)):se(`Reached maximum number of images 6401`)}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function pu(e,t){let n=[],r=e.text,i=0;for(let r of t)n.push(e.substring(i,r)),i=r;return i<r.length&&n.push(e.substring(i,r.length)),n}function mu(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=fu.fromFeature(t,a),_;f===e.W.vertical&&g.verticalizePunctuation();let{processBidirectionalText:v,processStyledBidirectionalText:y}=Ta;if(v&&g.sections.length===1){_=[];let e=v(g.toString(),Cu(g,u,o,n,i,m));for(let t of e){let e=new fu;e.text=t,e.sections=g.sections;for(let n=0;n<t.length;n++)e.sectionIndex.push(0);_.push(e)}}else if(y){_=[];let e=y(g.text,g.sectionIndex,Cu(g,u,o,n,i,m));for(let t of e){let e=new fu;e.text=t[0],e.sectionIndex=t[1],e.sections=g.sections,_.push(e)}}else _=pu(g,Cu(g,u,o,n,i,m));let b=[],x={positionedLines:b,text:g.toString(),top:d[1],bottom:d[1],left:d[0],right:d[0],writingMode:f,iconsInText:!1,verticalizable:!1};return function(e,t,n,r,i,a,o,s,c,l,u,d){let f=0,p=0,m=0,h=0,g=s===`right`?1:s===`left`?0:.5,_=Hl/d,v=0;for(let o of i){o.trim();let i=o.getMaxScale(),s={positionedGlyphs:[],lineOffset:0};e.positionedLines[v]=s;let d=s.positionedGlyphs,y=0;if(!o.length()){p+=a,++v;continue}let b=Tu(r,o,_);for(let a=0;a<o.length();a++){let s=o.getSection(a),m=o.getSectionIndex(a),h=o.getCharCode(a),g=Du(c,u,h),v;if(s.imageName){if(e.iconsInText=!0,s.scale*=_,v=ku(s,g,i,b,r),!v)continue;y=Math.max(y,v.imageOffset)}else if(v=Ou(s,h,g,b,t,n),!v)continue;let{rect:x,metrics:S,baselineOffset:C}=v;d.push({glyph:h,imageName:s.imageName,x:f,y:p+C+-17,vertical:g,scale:s.scale,fontStack:s.fontStack,sectionIndex:m,metrics:S,rect:x}),g?(e.verticalizable=!0,f+=(s.imageName?S.advance:Hl)*s.scale+l):f+=S.advance*s.scale+l}d.length!==0&&(m=Math.max(f-l,m),Au(d,0,d.length-1,g)),f=0,s.lineOffset=Math.max(y,(i-1)*Hl);let x=a*i+y;p+=x,h=Math.max(x,h),++v}let{horizontalAlign:y,verticalAlign:b}=wu(o);(function(e,t,n,r,i,a,o,s,c){let l=(t-n)*i,u=0;u=a===o?-r*c*o+.5*o:-s*r- -17;for(let t of e)for(let e of t.positionedGlyphs)e.x+=l,e.y+=u})(e.positionedLines,g,y,b,m,h,a,p,i.length),e.top+=-b*p,e.bottom=e.top+p,e.left+=-y*m,e.right=e.left+m}(x,n,r,i,_,s,c,l,f,u,p,h),!function(e){for(let t of e)if(t.positionedGlyphs.length!==0)return!1;return!0}(b)&&x}let hu={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},gu={10:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},_u={40:!0};function vu(e,t,n,r,i,a){if(t.imageName){let e=r[t.imageName];return e?e.displaySize[0]*t.scale*Hl/a+i:0}{let r=n[t.fontStack],a=r&&r[e];return a?a.metrics.advance*t.scale+i:0}}function yu(e,t,n,r){let i=(e-t)**2;return r?e<t?i/2:2*i:i+Math.abs(n)*n}function bu(e,t,n){let r=0;return e===10&&(r-=1e4),n&&(r+=150),e!==40&&e!==65288||(r+=50),t!==41&&t!==65289||(r+=50),r}function xu(e,t,n,r,i,a){let o=null,s=yu(t,n,i,a);for(let e of r){let r=yu(t-e.x,n,i,a)+e.badness;r<=s&&(o=e,s=r)}return{index:e,x:t,priorBreak:o,badness:s}}function Su(e){return e?Su(e.priorBreak).concat(e.index):[]}function Cu(e,t,n,r,i,a){if(!e)return[];let o=[],s=function(e,t,n,r,i,a){let o=0;for(let n=0;n<e.length();n++){let s=e.getSection(n);o+=vu(e.getCharCode(n),s,r,i,t,a)}return o/Math.max(1,Math.ceil(o/n))}(e,t,n,r,i,a),c=e.text.indexOf(`​`)>=0,l=0;for(let n=0;n<e.length();n++){let d=e.getSection(n),f=e.getCharCode(n);if(hu[f]||(l+=vu(f,d,r,i,t,a)),n<e.length()-1){let t=!((u=f)<11904)&&(!!Z[`CJK Compatibility Forms`](u)||!!Z[`CJK Compatibility`](u)||!!Z[`CJK Strokes`](u)||!!Z[`CJK Symbols and Punctuation`](u)||!!Z[`Enclosed CJK Letters and Months`](u)||!!Z[`Halfwidth and Fullwidth Forms`](u)||!!Z[`Ideographic Description Characters`](u)||!!Z[`Vertical Forms`](u)||va.test(String.fromCodePoint(u)));(gu[f]||t||d.imageName||n!==e.length()-2&&_u[e.getCharCode(n+1)])&&o.push(xu(n+1,l,s,o,bu(f,e.getCharCode(n+1),t&&c),!1))}}var u;return Su(xu(e.length(),l,s,o,0,!0))}function wu(e){let t=.5,n=.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`:n=1;break;case`top`:case`top-right`:case`top-left`:n=0}return{horizontalAlign:t,verticalAlign:n}}function Tu(e,t,n){let r=t.getMaxScale()*Hl,{maxImageWidth:i,maxImageHeight:a}=t.getMaxImageSize(e),o=Math.max(r,a*n);return{verticalLineContentWidth:Math.max(r,i*n),horizontalLineContentHeight:o}}function Eu(e){switch(e){case`top`:return 0;case`center`:return .5;default:return 1}}function Du(t,n,r){return!(t===e.W.horizontal||!n&&!ya(r)||n&&(hu[r]||(i=r,/\p{sc=Arab}/u.test(String.fromCodePoint(i)))));var i}function Ou(e,t,n,r,i,a){let o=a[e.fontStack],s=function(e,t,n,r){if(e&&e.rect)return e;let i=t[n.fontStack],a=i&&i[r];return a?{rect:null,metrics:a.metrics}:null}(o&&o[t],i,e,t);if(s===null)return null;let c;if(n)c=r.verticalLineContentWidth-e.scale*Hl;else{let t=Eu(e.verticalAlign);c=(r.horizontalLineContentHeight-e.scale*Hl)*t}return{rect:s.rect,metrics:s.metrics,baselineOffset:c}}function ku(e,t,n,r,i){let a=i[e.imageName];if(!a)return null;let o=a.paddedRect,s=a.displaySize,c={width:s[0],height:s[1],left:1,top:-3,advance:t?s[1]:s[0]},l;if(t)l=r.verticalLineContentWidth-s[1]*e.scale;else{let t=Eu(e.verticalAlign);l=(r.horizontalLineContentHeight-s[1]*e.scale)*t}return{rect:o,metrics:c,baselineOffset:l,imageOffset:(t?s[0]:s[1])*e.scale-Hl*n}}function Au(e,t,n,r){if(r===0)return;let i=e[n],a=(e[n].x+i.metrics.advance*i.scale)*r;for(let r=t;r<=n;r++)e[r].x-=a}function ju(e,t,n){let{horizontalAlign:r,verticalAlign:i}=wu(n),a=t[0]-e.displaySize[0]*r,o=t[1]-e.displaySize[1]*i;return{image:e,top:o,bottom:o+e.displaySize[1],left:a,right:a+e.displaySize[0]}}function Mu(e){let t=e.left,n=e.top,r=e.right-t,i=e.bottom-n,a=e.image.textFitWidth??`stretchOrShrink`,o=e.image.textFitHeight??`stretchOrShrink`,s=(e.image.content[2]-e.image.content[0])/(e.image.content[3]-e.image.content[1]);if(o===`proportional`){if(a===`stretchOnly`&&r/i<s||a===`proportional`){let e=Math.ceil(i*s);t*=e/r,r=e}}else if(a===`proportional`&&o===`stretchOnly`&&s!==0&&r/i>s){let e=Math.ceil(r/s);n*=e/i,i=e}return{x1:t,y1:n,x2:t+r,y2:n+i}}function Nu(e,t,n,r,i,a){let o=e.image,s;if(o.content){let e=o.content,t=o.pixelRatio||1;s=[e[0]/t,e[1]/t,o.displaySize[0]-e[2]/t,o.displaySize[1]-e[3]/t]}let c=t.left*a,l=t.right*a,u,d,f,p;n===`width`||n===`both`?(p=i[0]+c-r[3],d=i[0]+l+r[1]):(p=i[0]+(c+l-o.displaySize[0])/2,d=p+o.displaySize[0]);let m=t.top*a,h=t.bottom*a;return n===`height`||n===`both`?(u=i[1]+m-r[0],f=i[1]+h+r[2]):(u=i[1]+(m+h-o.displaySize[1])/2,f=u+o.displaySize[1]),{image:o,top:u,right:d,bottom:f,left:p,collisionPadding:s}}let Pu=32640;function Fu(e,t){let{expression:n}=t;if(n.kind===`constant`)return{kind:`constant`,layoutSize:n.evaluate(new Ea(e+1))};if(n.kind===`source`)return{kind:`source`};{let{zoomStops:t,interpolationType:r}=n,i=0;for(;i<t.length&&t[i]<=e;)i++;i=Math.max(0,i-1);let a=i;for(;a<t.length&&t[a]<e+1;)a++;a=Math.min(t.length-1,a);let o=t[i],s=t[a];return n.kind===`composite`?{kind:`composite`,minZoom:o,maxZoom:s,interpolationType:r}:{kind:`camera`,minZoom:o,maxZoom:s,minSize:n.evaluate(new Ea(o)),maxSize:n.evaluate(new Ea(s)),interpolationType:r}}}function Iu(e,t,n){let r=`never`,i=e.get(t);return i?r=i:e.get(n)&&(r=`always`),r}let Lu=[{name:`a_fade_opacity`,components:1,type:`Uint8`,offset:0}];function Ru(e,t,n,r,i,a,o,s,c,l,u,d,f){let p=s?Math.min(Pu,Math.round(s[0])):0,m=s?Math.min(Pu,Math.round(s[1])):0;e.emplaceBack(t,n,Math.round(32*r),Math.round(32*i),a,o,(p<<1)+(c?1:0),m,16*l,16*u,256*d,256*f)}function zu(e,t,n){e.emplaceBack(t.x,t.y,n),e.emplaceBack(t.x,t.y,n),e.emplaceBack(t.x,t.y,n),e.emplaceBack(t.x,t.y,n)}function Bu(e){for(let t of e.sections)if(wa(t.text))return!0;return!1}class Vu{constructor(e){this.layoutVertexArray=new Fo,this.indexArray=new Bo,this.programConfigurations=e,this.segments=new Uo,this.dynamicLayoutVertexArray=new Io,this.opacityVertexArray=new Lo,this.hasVisibleVertices=!1,this.placedSymbolArray=new yo}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(e,t,n,r){this.isEmpty()||(n&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Ml.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,Nl.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,Lu,!0),this.opacityVertexBuffer.itemSize=1),(n||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())}}Y(`SymbolBuffers`,Vu);class Hu{constructor(e,t,n){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new n,this.segments=new Uo,this.collisionVertexArray=new zo}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,Pl.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}Y(`CollisionBuffers`,Hu);class Uu{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.globalState=t.globalState,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];let n=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Fu(this.zoom,n[`text-size`]),this.iconSizeData=Fu(this.zoom,n[`icon-size`]);let r=this.layers[0].layout,i=r.get(`symbol-sort-key`),a=r.get(`symbol-z-order`);this.canOverlap=Iu(r,`text-overlap`,`text-allow-overlap`)!==`never`||Iu(r,`icon-overlap`,`icon-allow-overlap`)!==`never`||r.get(`text-ignore-placement`)||r.get(`icon-ignore-placement`),this.sortFeaturesByKey=a!==`viewport-y`&&!i.isConstant(),this.sortFeaturesByY=(a===`viewport-y`||a===`auto`&&!this.sortFeaturesByKey)&&this.canOverlap,r.get(`symbol-placement`)===`point`&&(this.writingModes=r.get(`text-writing-mode`).map((t=>e.W[t]))),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.sourceID=t.sourceID}createArrays(){this.text=new Vu(new hs(this.layers,this.zoom,(e=>/^text/.test(e)))),this.icon=new Vu(new hs(this.layers,this.zoom,(e=>/^icon/.test(e)))),this.glyphOffsetArray=new So,this.lineVertexArray=new Co,this.symbolInstances=new xo,this.textAnchorOffsets=new To}calculateGlyphDependencies(e,t,n,r,i){for(let a=0;a<e.length;a++)if(t[e.charCodeAt(a)]=!0,(n||r)&&i){let n=Vl[e.charAt(a)];n&&(t[n.charCodeAt(0)]=!0)}}populate(t,n,r){let i=this.layers[0],a=i.layout,o=a.get(`text-font`),s=a.get(`text-field`),c=a.get(`icon-image`),l=(s.value.kind!==`constant`||s.value.value instanceof Rt&&!s.value.value.isEmpty()||s.value.value.toString().length>0)&&(o.value.kind!==`constant`||o.value.value.length>0),u=c.value.kind!==`constant`||!!c.value.value||Object.keys(c.parameters).length>0,d=a.get(`symbol-sort-key`);if(this.features=[],!l&&!u)return;let f=n.iconDependencies,p=n.glyphDependencies,m=n.availableImages,h=new Ea(this.zoom,{globalState:this.globalState}),g=!1;for(let{feature:n,id:s,index:c,sourceLayerIndex:_}of t){let t=i._featureFilter.needGeometry,v=xs(n,t);if(!i._featureFilter.filter(h,v,r))continue;let y,b;if(t||(v.geometry=bs(n)),l){let e=i.getValueAndResolveTokens(`text-field`,v,r,m),t=Rt.factory(e),n=this.hasRTLText=this.hasRTLText||Bu(t);(!n||Ta.getRTLTextPluginStatus()===`unavailable`||n&&Ta.isParsed())&&(y=zl(t,i,v))}if(u){let e=i.getValueAndResolveTokens(`icon-image`,v,r,m);b=e instanceof Gt?e:Gt.fromString(e),b&&(g=!0)}if(!(y&&y.toString()||b))continue;let x=this.sortFeaturesByKey?d.evaluate(v,{},r):void 0;if(this.features.push({id:s,text:y,icon:b,index:c,sourceLayerIndex:_,geometry:v.geometry,properties:n.properties,type:nl.types[n.type],sortKey:x}),b&&(f[b.name]=!0),y){let t=o.evaluate(v,{},r).join(`,`),n=a.get(`text-rotation-alignment`)!==`viewport`&&a.get(`symbol-placement`)!==`point`;this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(e.W.vertical)>=0;for(let e of y.sections)if(e.image)f[e.image.name]=!0;else{let r=pa(y.toString()),i=e.fontStack||t,a=p[i]=p[i]||{};this.calculateGlyphDependencies(e.text,a,n,this.allowVerticalPlacement,r)}}}a.get(`symbol-placement`)===`line`&&(this.features=function(e,t){let n={};e.forEach((e=>{let t=e.text?e.text.toString():`nn>`,r=n[t];r===void 0&&(r={feature:e,lines:[]},n[t]=r),e.geometry.forEach((e=>r.lines.push(e)))}));let r=[];for(let e in n)r.push(Bl(n[e],t));return r}(this.features,!g),this.features.forEach((e=>{e.geometry.forEach((e=>{e.len=Rl(e)})),e.geometry.sort(((e,t)=>t.len-e.len)),e.text instanceof Rt&&e.text?.toString()===Ll.debnames&&Ll.logLineStrings(e.geometry,r)}))),this.sortFeaturesByKey&&this.features.sort(((e,t)=>e.sortKey-t.sortKey))}update(e,t,n){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:n,globalState:this.globalState}),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:n,globalState:this.globalState}))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){let n=this.lineVertexArray.length;if(e.segment!==void 0){let n=e.dist(t[e.segment+1]),r=e.dist(t[e.segment]),i={};for(let r=e.segment+1;r<t.length;r++)i[r]={x:t[r].x,y:t[r].y,tileUnitDistanceFromAnchor:n},r<t.length-1&&(n+=t[r+1].dist(t[r]));for(let n=e.segment||0;n>=0;n--)i[n]={x:t[n].x,y:t[n].y,tileUnitDistanceFromAnchor:r},n>0&&(r+=t[n-1].dist(t[n]));for(let e=0;e<t.length;e++){let t=i[e];this.lineVertexArray.emplaceBack(t.x,t.y,t.tileUnitDistanceFromAnchor)}}return{lineStartIndex:n,lineLength:this.lineVertexArray.length-n}}addSymbols(t,n,r,i,a,o,s,c,l,u,d,f){let p=t.indexArray,m=t.layoutVertexArray,h=t.segments.prepareSegment(4*n.length,m,p,this.canOverlap?o.sortKey:void 0),g=this.glyphOffsetArray.length,_=h.vertexLength,v=this.allowVerticalPlacement&&s===e.W.vertical?Math.PI/2:0,y=o.text&&o.text.sections;for(let e=0;e<n.length;e++){let{tl:i,tr:a,bl:s,br:l,tex:u,pixelOffsetTL:d,pixelOffsetBR:g,minFontScaleX:_,minFontScaleY:b,glyphOffset:x,isSDF:S,sectionIndex:C}=n[e],w=h.vertexLength,T=x[1];Ru(m,c.x,c.y,i.x,T+i.y,u.x,u.y,r,S,d.x,d.y,_,b),Ru(m,c.x,c.y,a.x,T+a.y,u.x+u.w,u.y,r,S,g.x,d.y,_,b),Ru(m,c.x,c.y,s.x,T+s.y,u.x,u.y+u.h,r,S,d.x,g.y,_,b),Ru(m,c.x,c.y,l.x,T+l.y,u.x+u.w,u.y+u.h,r,S,g.x,g.y,_,b),zu(t.dynamicLayoutVertexArray,c,v),p.emplaceBack(w,w+2,w+1),p.emplaceBack(w+1,w+2,w+3),h.vertexLength+=4,h.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(x[0]),e!==n.length-1&&C===n[e+1].sectionIndex||t.programConfigurations.populatePaintArrays(m.length,o,o.index,{imagePositions:{},canonical:f,formattedSection:y&&y[C],globalState:this.globalState})}t.placedSymbolArray.emplaceBack(c.x,c.y,g,this.glyphOffsetArray.length-g,_,l,u,c.segment,r?r[0]:0,r?r[1]:0,i[0],i[1],s,0,!1,0,d)}_addCollisionDebugVertex(e,t,n,r,i,a){return t.emplaceBack(0,0),e.emplaceBack(n.x,n.y,r,i,Math.round(a.x),Math.round(a.y))}addCollisionDebugVertices(e,t,r,i,a,o,s){let c=a.segments.prepareSegment(4,a.layoutVertexArray,a.indexArray),l=c.vertexLength,u=a.layoutVertexArray,d=a.collisionVertexArray,f=s.anchorX,p=s.anchorY;this._addCollisionDebugVertex(u,d,o,f,p,new n(e,t)),this._addCollisionDebugVertex(u,d,o,f,p,new n(r,t)),this._addCollisionDebugVertex(u,d,o,f,p,new n(r,i)),this._addCollisionDebugVertex(u,d,o,f,p,new n(e,i)),c.vertexLength+=4;let m=a.indexArray;m.emplaceBack(l,l+1),m.emplaceBack(l+1,l+2),m.emplaceBack(l+2,l+3),m.emplaceBack(l+3,l),c.primitiveLength+=4}addDebugCollisionBoxes(e,t,n,r){for(let i=e;i<t;i++){let e=this.collisionBoxArray.get(i);this.addCollisionDebugVertices(e.x1,e.y1,e.x2,e.y2,r?this.textCollisionBox:this.iconCollisionBox,e.anchorPoint,n)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Hu(Ro,Fl.members,Vo),this.iconCollisionBox=new Hu(Ro,Fl.members,Vo);for(let e=0;e<this.symbolInstances.length;e++){let t=this.symbolInstances.get(e);this.addDebugCollisionBoxes(t.textBoxStartIndex,t.textBoxEndIndex,t,!0),this.addDebugCollisionBoxes(t.verticalTextBoxStartIndex,t.verticalTextBoxEndIndex,t,!0),this.addDebugCollisionBoxes(t.iconBoxStartIndex,t.iconBoxEndIndex,t,!1),this.addDebugCollisionBoxes(t.verticalIconBoxStartIndex,t.verticalIconBoxEndIndex,t,!1)}}_deserializeCollisionBoxesForSymbol(e,t,n,r,i,a,o,s,c){let l={};for(let r=t;r<n;r++){let t=e.get(r);l.textBox={x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,anchorPointX:t.anchorPointX,anchorPointY:t.anchorPointY},l.textFeatureIndex=t.featureIndex;break}for(let t=r;t<i;t++){let n=e.get(t);l.verticalTextBox={x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,anchorPointX:n.anchorPointX,anchorPointY:n.anchorPointY},l.verticalTextFeatureIndex=n.featureIndex;break}for(let t=a;t<o;t++){let n=e.get(t);l.iconBox={x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,anchorPointX:n.anchorPointX,anchorPointY:n.anchorPointY},l.iconFeatureIndex=n.featureIndex;break}for(let t=s;t<c;t++){let n=e.get(t);l.verticalIconBox={x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,anchorPointX:n.anchorPointX,anchorPointY:n.anchorPointY},l.verticalIconFeatureIndex=n.featureIndex;break}return l}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let t=0;t<this.symbolInstances.length;t++){let n=this.symbolInstances.get(t);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,n.textBoxStartIndex,n.textBoxEndIndex,n.verticalTextBoxStartIndex,n.verticalTextBoxEndIndex,n.iconBoxStartIndex,n.iconBoxEndIndex,n.verticalIconBoxStartIndex,n.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,t){let n=e.placedSymbolArray.get(t),r=n.vertexStartIndex+4*n.numGlyphs;for(let t=n.vertexStartIndex;t<r;t+=4)e.indexArray.emplaceBack(t,t+2,t+1),e.indexArray.emplaceBack(t+1,t+2,t+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;let t=Math.sin(e),n=Math.cos(e),r=[],i=[],a=[];for(let e=0;e<this.symbolInstances.length;++e){a.push(e);let o=this.symbolInstances.get(e);r.push(0|Math.round(t*o.anchorX+n*o.anchorY)),i.push(o.featureIndex)}return a.sort(((e,t)=>r[e]-r[t]||i[t]-i[e])),a}addToSortKeyRanges(e,t){let n=this.sortKeyRanges[this.sortKeyRanges.length-1];n&&n.sortKey===t?n.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(let e of this.symbolInstanceIndexes){let t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex),[t.rightJustifiedTextSymbolIndex,t.centerJustifiedTextSymbolIndex,t.leftJustifiedTextSymbolIndex].forEach(((e,t,n)=>{e>=0&&n.indexOf(e)===t&&this.addIndicesForPlacedSymbol(this.text,e)})),t.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,t.verticalPlacedTextSymbolIndex),t.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.placedIconSymbolIndex),t.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Wu,Gu;Y(`SymbolBucket`,Uu,{omit:[`layers`,`collisionBoxArray`,`features`,`compareText`]}),Uu.addDynamicAttributes=zu;var Ku={get paint(){return Gu||=new Ra({"icon-opacity":new $(I.paint_symbol[`icon-opacity`]),"icon-color":new $(I.paint_symbol[`icon-color`]),"icon-halo-color":new $(I.paint_symbol[`icon-halo-color`]),"icon-halo-width":new $(I.paint_symbol[`icon-halo-width`]),"icon-halo-blur":new $(I.paint_symbol[`icon-halo-blur`]),"icon-translate":new Q(I.paint_symbol[`icon-translate`]),"icon-translate-anchor":new Q(I.paint_symbol[`icon-translate-anchor`]),"text-opacity":new $(I.paint_symbol[`text-opacity`]),"text-color":new $(I.paint_symbol[`text-color`],{runtimeType:Xe,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new $(I.paint_symbol[`text-halo-color`]),"text-halo-width":new $(I.paint_symbol[`text-halo-width`]),"text-halo-blur":new $(I.paint_symbol[`text-halo-blur`]),"text-translate":new Q(I.paint_symbol[`text-translate`]),"text-translate-anchor":new Q(I.paint_symbol[`text-translate-anchor`])})},get layout(){return Wu||=new Ra({"symbol-placement":new Q(I.layout_symbol[`symbol-placement`]),"symbol-spacing":new Q(I.layout_symbol[`symbol-spacing`]),"symbol-avoid-edges":new Q(I.layout_symbol[`symbol-avoid-edges`]),"symbol-sort-key":new $(I.layout_symbol[`symbol-sort-key`]),"symbol-z-order":new Q(I.layout_symbol[`symbol-z-order`]),"icon-allow-overlap":new Q(I.layout_symbol[`icon-allow-overlap`]),"icon-overlap":new Q(I.layout_symbol[`icon-overlap`]),"icon-ignore-placement":new Q(I.layout_symbol[`icon-ignore-placement`]),"icon-optional":new Q(I.layout_symbol[`icon-optional`]),"icon-rotation-alignment":new Q(I.layout_symbol[`icon-rotation-alignment`]),"icon-size":new $(I.layout_symbol[`icon-size`]),"icon-text-fit":new Q(I.layout_symbol[`icon-text-fit`]),"icon-text-fit-padding":new Q(I.layout_symbol[`icon-text-fit-padding`]),"icon-image":new $(I.layout_symbol[`icon-image`]),"icon-rotate":new $(I.layout_symbol[`icon-rotate`]),"icon-padding":new $(I.layout_symbol[`icon-padding`]),"icon-keep-upright":new Q(I.layout_symbol[`icon-keep-upright`]),"icon-offset":new $(I.layout_symbol[`icon-offset`]),"icon-anchor":new $(I.layout_symbol[`icon-anchor`]),"icon-pitch-alignment":new Q(I.layout_symbol[`icon-pitch-alignment`]),"text-pitch-alignment":new Q(I.layout_symbol[`text-pitch-alignment`]),"text-rotation-alignment":new Q(I.layout_symbol[`text-rotation-alignment`]),"text-field":new $(I.layout_symbol[`text-field`]),"text-font":new $(I.layout_symbol[`text-font`]),"text-size":new $(I.layout_symbol[`text-size`]),"text-max-width":new $(I.layout_symbol[`text-max-width`]),"text-line-height":new Q(I.layout_symbol[`text-line-height`]),"text-letter-spacing":new $(I.layout_symbol[`text-letter-spacing`]),"text-justify":new $(I.layout_symbol[`text-justify`]),"text-radial-offset":new $(I.layout_symbol[`text-radial-offset`]),"text-variable-anchor":new Q(I.layout_symbol[`text-variable-anchor`]),"text-variable-anchor-offset":new $(I.layout_symbol[`text-variable-anchor-offset`]),"text-anchor":new $(I.layout_symbol[`text-anchor`]),"text-max-angle":new Q(I.layout_symbol[`text-max-angle`]),"text-writing-mode":new Q(I.layout_symbol[`text-writing-mode`]),"text-rotate":new $(I.layout_symbol[`text-rotate`]),"text-padding":new Q(I.layout_symbol[`text-padding`]),"text-keep-upright":new Q(I.layout_symbol[`text-keep-upright`]),"text-transform":new $(I.layout_symbol[`text-transform`]),"text-offset":new $(I.layout_symbol[`text-offset`]),"text-allow-overlap":new Q(I.layout_symbol[`text-allow-overlap`]),"text-overlap":new Q(I.layout_symbol[`text-overlap`]),"text-ignore-placement":new Q(I.layout_symbol[`text-ignore-placement`]),"text-optional":new Q(I.layout_symbol[`text-optional`])})}};class qu{constructor(e){if(e.property.overrides===void 0)throw Error(`overrides must be provided to instantiate FormatSectionOverride class`);this.type=e.property.overrides?e.property.overrides.runtimeType:Ye,this.defaultValue=e}evaluate(e){if(e.formattedSection){let 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}}Y(`FormatSectionOverride`,qu,{omit:[`defaultValue`]});class Ju extends Ba{constructor(e){super(e,Ku)}recalculate(e,t){if(super.recalculate(e,t),this.layout.get(`icon-rotation-alignment`)===`auto`&&(this.layout._values[`icon-rotation-alignment`]=this.layout.get(`symbol-placement`)===`point`?`viewport`:`map`),this.layout.get(`text-rotation-alignment`)===`auto`&&(this.layout._values[`text-rotation-alignment`]=this.layout.get(`symbol-placement`)===`point`?`viewport`:`map`),this.layout.get(`text-pitch-alignment`)===`auto`&&(this.layout._values[`text-pitch-alignment`]=this.layout.get(`text-rotation-alignment`)===`map`?`map`:`viewport`),this.layout.get(`icon-pitch-alignment`)===`auto`&&(this.layout._values[`icon-pitch-alignment`]=this.layout.get(`icon-rotation-alignment`)),this.layout.get(`symbol-placement`)===`point`){let e=this.layout.get(`text-writing-mode`);if(e){let t=[];for(let n of e)t.indexOf(n)<0&&t.push(n);this.layout._values[`text-writing-mode`]=t}else this.layout._values[`text-writing-mode`]=[`horizontal`]}this._setPaintOverrides()}getValueAndResolveTokens(e,t,n,r){let i=this.layout.get(e).evaluate(t,{},n,r),a=this._unevaluatedLayout._values[e];return a.isDataDriven()||ri(a.value)||!i?i:function(e,t){return t.replace(/{([^{}]+)}/g,((t,n)=>e&&n in e?String(e[n]):``))}(t.properties,i)}createBucket(e){return new Uu(e)}queryRadius(){return 0}queryIntersectsFeature(){throw Error(`Should take a different path in FeatureIndex`)}_setPaintOverrides(){for(let e of Ku.paint.overridableProperties){if(!Ju.hasPaintOverride(this.layout,e))continue;let t=this.paint.get(e),n=new ni(new qu(t),t.property.specification),r=null;r=t.value.kind===`constant`||t.value.kind===`source`?new ai(`source`,n):new oi(`composite`,n,t.value.zoomStops),this.paint._values[e]=new Na(t.property,r,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,n){return!(!this.layout||t.isDataDriven()||n.isDataDriven())&&Ju.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){let n=e.get(`text-field`),r=Ku.paint.properties[t],i=!1,a=e=>{for(let t of e)if(r.overrides&&r.overrides.hasOverride(t))return void(i=!0)};if(n.value.kind===`constant`&&n.value.value instanceof Rt)a(n.value.value.sections);else if(n.value.kind===`source`){let e=t=>{i||(t instanceof G&&Yt(t.value)===et?a(t.value.sections):t instanceof Mn?a(t.sections):t.eachChild(e))},t=n.value;t._styleExpression&&e(t._styleExpression.expression)}return i}}let Yu;var Xu={get paint(){return Yu||=new Ra({"background-color":new Q(I.paint_background[`background-color`]),"background-pattern":new Ia(I.paint_background[`background-pattern`]),"background-opacity":new Q(I.paint_background[`background-opacity`])})}};class Zu extends Ba{constructor(e){super(e,Xu)}}let Qu;var $u={get paint(){return Qu||=new Ra({"raster-opacity":new Q(I.paint_raster[`raster-opacity`]),"raster-hue-rotate":new Q(I.paint_raster[`raster-hue-rotate`]),"raster-brightness-min":new Q(I.paint_raster[`raster-brightness-min`]),"raster-brightness-max":new Q(I.paint_raster[`raster-brightness-max`]),"raster-saturation":new Q(I.paint_raster[`raster-saturation`]),"raster-contrast":new Q(I.paint_raster[`raster-contrast`]),"raster-resampling":new Q(I.paint_raster[`raster-resampling`]),"raster-fade-duration":new Q(I.paint_raster[`raster-fade-duration`])})}};class ed extends Ba{constructor(e){super(e,$u)}}class td extends Ba{constructor(e){super(e,{}),this.onAdd=e=>{this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)},this.onRemove=e=>{this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)},this.implementation=e}is3D(){return this.implementation.renderingMode===`3d`}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw Error(`Custom layers cannot be serialized`)}}class nd{constructor(e){this._methodToThrottle=e,this._triggered=!1,typeof MessageChannel<`u`&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._methodToThrottle()}),0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}let rd={once:!0};function id(e,t,r,i,a){let o=[];for(let s=0;s<e.length;s++){let c=e[s],l;for(let e=0;e<c.length-1;e++){let s=c[e],u=c[e+1];s.x<t&&u.x<t||(s.x<t?s=new n(t,s.y+(t-s.x)/(u.x-s.x)*(u.y-s.y))._round():u.x<t&&(u=new n(t,s.y+(t-s.x)/(u.x-s.x)*(u.y-s.y))._round()),s.y<r&&u.y<r||(s.y<r?s=new n(s.x+(r-s.y)/(u.y-s.y)*(u.x-s.x),r)._round():u.y<r&&(u=new n(s.x+(r-s.y)/(u.y-s.y)*(u.x-s.x),r)._round()),s.x>=i&&u.x>=i||(s.x>=i?s=new n(i,s.y+(i-s.x)/(u.x-s.x)*(u.y-s.y))._round():u.x>=i&&(u=new n(i,s.y+(i-s.x)/(u.x-s.x)*(u.y-s.y))._round()),s.y>=a&&u.y>=a||(s.y>=a?s=new n(s.x+(a-s.y)/(u.y-s.y)*(u.x-s.x),a)._round():u.y>=a&&(u=new n(s.x+(a-s.y)/(u.y-s.y)*(u.x-s.x),a)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(u)))))}}return o}class ad{constructor(){this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0}extend(e){return this.minX=Math.min(this.minX,e.x),this.minY=Math.min(this.minY,e.y),this.maxX=Math.max(this.maxX,e.x),this.maxY=Math.max(this.maxY,e.y),this}expandBy(e){return this.minX-=e,this.minY-=e,this.maxX+=e,this.maxY+=e,(this.minX>this.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(e){return this.expandBy(-e)}map(e){let t=new ad;return t.extend(e(new n(this.minX,this.minY))),t.extend(e(new n(this.maxX,this.minY))),t.extend(e(new n(this.minX,this.maxY))),t.extend(e(new n(this.maxX,this.maxY))),t}static fromPoints(e){let t=new ad;for(let n of e)t.extend(n);return t}contains(e){return e.x>=this.minX&&e.x<=this.maxX&&e.y>=this.minY&&e.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(e){return!this.empty()&&!e.empty()&&e.minX>=this.minX&&e.maxX<=this.maxX&&e.minY>=this.minY&&e.maxY<=this.maxY}intersects(e){return!this.empty()&&!e.empty()&&e.minX<=this.maxX&&e.maxX>=this.minX&&e.minY<=this.maxY&&e.maxY>=this.minY}}let od=6371008.8;class sd{constructor(e,t){if(isNaN(e)||isNaN(t))throw Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw Error(`Invalid LngLat latitude value: must be between -90 and 90`)}wrap(){return new sd(te(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){let t=Math.PI/180,n=this.lat*t,r=e.lat*t,i=Math.sin(n)*Math.sin(r)+Math.cos(n)*Math.cos(r)*Math.cos((e.lng-this.lng)*t);return od*Math.acos(Math.min(i,1))}static convert(e){if(e instanceof sd)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new sd(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e==`object`&&e)return new sd(Number(`lng`in e?e.lng:e.lon),Number(e.lat));throw 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>]")}}let cd=2*Math.PI*od;function ld(e){return cd*Math.cos(e*Math.PI/180)}function ud(e){return(180+e)/360}function dd(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function fd(e,t){return e/ld(t)}function pd(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function md(e,t){return e*ld(pd(t))}class hd{constructor(e,t,n=0){this.x=+e,this.y=+t,this.z=+n}static fromLngLat(e,t=0){let n=sd.convert(e);return new hd(ud(n.lng),dd(n.lat),fd(t,n.lat))}toLngLat(){return new sd(360*this.x-180,pd(this.y))}toAltitude(){return md(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/cd*(e=pd(this.y),1/Math.cos(e*Math.PI/180));var e}}function gd(e,t,n){var r=2*Math.PI*6378137/256/2**n;return[e*r-2*Math.PI*6378137/2,t*r-2*Math.PI*6378137/2]}class _d{constructor(e,t,n){if(!function(e,t,n){return!(e<0||e>25||n<0||n>=2**e||t<0||t>=2**e)}(e,t,n))throw Error(`x=${t}, y=${n}, z=${e} outside of bounds. 0<=x<${2**e}, 0<=y<${2**e} 0<=z<=25 `);this.z=e,this.x=t,this.y=n,this.key=bd(0,e,e,t,n)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t,n){let r=(a=this.y,o=this.z,s=gd(256*(i=this.x),256*(a=2**o-a-1),o),c=gd(256*(i+1),256*(a+1),o),s[0]+`,`+s[1]+`,`+c[0]+`,`+c[1]);var i,a,o,s,c;let l=function(e,t,n){let r,i=``;for(let a=e;a>0;a--)r=1<<a-1,i+=(t&r?1:0)+(n&r?2:0);return i}(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace(/{prefix}/g,(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String(n===`tms`?2**this.z-this.y-1:this.y)).replace(/{ratio}/g,t>1?`@2x`:``).replace(/{quadkey}/g,l).replace(/{bbox-epsg-3857}/g,r)}isChildOf(e){let t=this.z-e.z;return t>0&&e.x===this.x>>t&&e.y===this.y>>t}getTilePoint(e){let t=2**this.z;return new n((e.x*t-this.x)*O,(e.y*t-this.y)*O)}toString(){return`${this.z}/${this.x}/${this.y}`}}class vd{constructor(e,t){this.wrap=e,this.canonical=t,this.key=bd(e,t.z,t.z,t.x,t.y)}}class yd{constructor(e,t,n,r,i){if(this.terrainRttPosMatrix32f=null,e<n)throw Error(`overscaledZ should be >= z; overscaledZ = ${e}; z = ${n}`);this.overscaledZ=e,this.wrap=t,this.canonical=new _d(n,+r,+i),this.key=bd(t,e,n,r,i)}clone(){return new yd(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){if(e>this.overscaledZ)throw Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);let t=this.canonical.z-e;return e>this.canonical.z?new yd(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new yd(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}calculateScaledKey(e,t){if(e>this.overscaledZ)throw Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);let n=this.canonical.z-e;return e>this.canonical.z?bd(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y):bd(this.wrap*+t,e,e,this.canonical.x>>n,this.canonical.y>>n)}isChildOf(e){if(e.wrap!==this.wrap)return!1;let t=this.canonical.z-e.canonical.z;return e.overscaledZ===0||e.overscaledZ<this.overscaledZ&&e.canonical.x===this.canonical.x>>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new yd(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];let t=this.canonical.z+1,n=2*this.canonical.x,r=2*this.canonical.y;return[new yd(t,this.wrap,t,n,r),new yd(t,this.wrap,t,n+1,r),new yd(t,this.wrap,t,n,r+1),new yd(t,this.wrap,t,n+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 yd(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new yd(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return 2**(this.overscaledZ-this.canonical.z)}toUnwrapped(){return new vd(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(e){return this.canonical.getTilePoint(new hd(e.x-this.wrap,e.y))}}function bd(e,t,n,r,i){(e*=2)<0&&(e=-1*e-1);let a=1<<n;return(a*a*e+a*i+r).toString(36)+n.toString(36)+t.toString(36)}function xd(e,t){return t?e.properties[t]:e.id}Y(`CanonicalTileID`,_d),Y(`OverscaledTileID`,yd,{omit:[`terrainRttPosMatrix32f`]});class Sd{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t<e.length;t++){let n=e[t];this._stringToNumber[n]=t,this._numberToString[t]=n}}encode(e){return this._stringToNumber[e]}decode(e){if(e>=this._numberToString.length)throw Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class Cd{constructor(e,t,n,r,i,a){this.type=`Feature`,this._vectorTileFeature=e,e._z=t,e._x=n,e._y=r,this.properties=e.properties,this.id=i,this._wrap=a}get geometry(){return this._geometry===void 0&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(e){this._geometry=e}clippedAndUnwrappedGeometry(){let e=2**this._vectorTileFeature._z,t=this._vectorTileFeature._x+this._wrap*e;if(this._vectorTileFeature.type!==2)return this._vectorTileFeature.toGeoJSON(t,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry;let n=this._vectorTileFeature.extent,r=n*e,i=n*t,a=n*this._vectorTileFeature._y;function o(e){return[360*(e.x+i)/r-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+a)/r)*Math.PI))-90]}let s=id(this._vectorTileFeature.loadGeometry(),0,0,this._vectorTileFeature.extent,this._vectorTileFeature.extent);s.forEach((e=>function(e){let t=0;for(;t<e.length-1;)e[t].x===e[t+1].x&&e[t].y===e[t+1].y?e.splice(t,1):t++}(e)));let c=s.filter((e=>e.length>1)).map((function(e){return e.map(o)}));return c.length===1?{type:`LineString`,coordinates:c[0]}:{type:`MultiLineString`,coordinates:c}}toJSON(){let e={geometry:this.geometry};for(let t in this)t!==`_geometry`&&t!==`_vectorTileFeature`&&(e[t]=this[t]);return e}}class wd{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new oa(O,16,0),this.grid3D=new oa(O,16,0),this.featureIndexArray=new Do,this.promoteId=t}insert(e,t,n,r,i,a){let o=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(n,r,i);let s=a?this.grid3D:this.grid;for(let e=0;e<t.length;e++){let n=t[e],r=[1/0,1/0,-1/0,-1/0];for(let e=0;e<n.length;e++){let t=n[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)}r[0]<O&&r[1]<O&&r[2]>=0&&r[3]>=0&&s.insert(o,r[0],r[1],r[2],r[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new sl(new Kl(this.rawTileData)).layers,this.sourceLayerCoder=new Sd(this.vtLayers?Object.keys(this.vtLayers).sort():[`_geojsonTileLayer`])),this.vtLayers}query(e,t,r,i){this.loadVTLayers();let a=e.params??{},o=O/e.tileSize/e.scale,s=pi(a.filter),c=e.queryGeometry,l=e.queryPadding*o,u=ad.fromPoints(c),d=this.grid.query(u.minX-l,u.minY-l,u.maxX+l,u.maxY+l,null,a.skipGeoCheck),f=ad.fromPoints(e.cameraQueryGeometry).expandBy(l),p=this.grid3D.query(f.minX,f.minY,f.maxX,f.maxY,((t,r,i,a)=>function(e,t,r,i,a){for(let n of e)if(t<=n.x&&r<=n.y&&i>=n.x&&a>=n.y)return!0;let o=[new n(t,r),new n(t,a),new n(i,a),new n(i,r)];if(e.length>2){for(let t of o)if(Ps(e,t))return!0}for(let t=0;t<e.length-1;t++)if(Fs(e[t],e[t+1],o))return!0;return!1}(e.cameraQueryGeometry,t-l,r-l,i+l,a+l)));for(let e of p)d.push(e);d.sort(Ed);let m={},h;for(let n=0;n<d.length;n++){let l=d[n];if(l===h)continue;h=l;let u=this.featureIndexArray.get(l),f=null;this.loadMatchingFeature(m,u.bucketIndex,u.sourceLayerIndex,u.featureIndex,s,a.layers,a.availableImages,t,r,i,((t,n,r)=>(f||=bs(t),a.skipGeoCheck||n.queryIntersectsFeature({queryGeometry:c,feature:t,featureState:r,geometry:f,zoom:this.z,transform:e.transform,pixelsToTileUnits:o,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation}))))}return m}loadMatchingFeature(e,t,n,r,i,a,o,s,c,l,u){let d=this.bucketLayerIDs[t];if(a&&!d.some((e=>a.has(e))))return;let f=this.sourceLayerCoder.decode(n),p=this.vtLayers[f].feature(r);if(i.needGeometry){let e=xs(p,!0);if(!i.filter(new Ea(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!i.filter(new Ea(this.tileID.overscaledZ),p))return;let m=this.getId(p,f);for(let t=0;t<d.length;t++){let n=d[t];if(a&&!a.has(n))continue;let i=s[n];if(!i)continue;let f={};m&&l&&(f=l.getState(i.sourceLayer||`_geojsonTileLayer`,m));let h=F({},c[n]);h.paint=Td(h.paint,i.paint,p,f,o),h.layout=Td(h.layout,i.layout,p,f,o);let g=!u||u(p,i,f);if(!g)continue;let _=new Cd(p,this.z,this.x,this.y,m,this.tileID.wrap);_.layer=h;let v=e[n];v===void 0&&(v=e[n]=[]),v.push({featureIndex:r,feature:_,intersectionZ:g})}}lookupSymbolFeatures(e,t,n,r,i,a,o,s){let c={};this.loadVTLayers();let l=pi(i);for(let i of e)this.loadMatchingFeature(c,n,r,i,l,a,o,s,t);return c}hasLayer(e){for(let t of this.bucketLayerIDs)for(let n of t)if(e===n)return!0;return!1}getId(e,t){var n;let r=e.id;return this.promoteId&&(r=e.properties[typeof this.promoteId==`string`?this.promoteId:this.promoteId[t]],typeof r==`boolean`&&(r=Number(r)),r===void 0&&(n=e.properties)!=null&&n.cluster&&this.promoteId&&(r=Number(e.properties.cluster_id))),r}}function Td(e,t,n,r,i){return re(e,((e,a)=>{let o=t instanceof Pa?t.get(a):null;return o&&o.evaluate?o.evaluate(n,r,i):o}))}function Ed(e,t){return t-e}Y(`FeatureIndex`,wd,{omit:[`rawTileData`,`sourceLayerCoder`]});class Dd extends n{constructor(e,t,n,r){super(e,t),this.angle=n,r!==void 0&&(this.segment=r)}clone(){return new Dd(this.x,this.y,this.angle,this.segment)}}Y(`Anchor`,Dd);class Od{constructor(e){this.curDist=0,this.totalDistance=0,this.segm=-1,this.cs=e}travelRouteAbsolute(e){return this.segm=-1,this.travelRouteRelative(e)}travelRouteRelative(e){let t;this.segm<1&&(t=this.cs[0],this.segm=1,this.curDist=0,this.totalDistance=0);let r=this.cs[this.segm-1];this.curDist+=e,this.totalDistance+=e;let i=this.curDist;if(e<0)for(i===0&&(t=r);i<0&&this.segm>1;){let e=this.cs[this.segm-2],n=r.dist(e);i+=n,this.curDist+=n,this.segm--,r=e,t=e}for(;i>0&&this.segm<this.cs.length;){let e=this.cs[this.segm],a=r.dist(e);if(a<i)i-=a,this.curDist-=a,this.segm++,r=e,t=e;else{let o=i/a;t=new n(r.x+(e.x-r.x)*o,r.y+(e.y-r.y)*o),i=0}}return i>0&&(t=this.cs[this.cs.length-1]),i<=0?t:null}angleOfCurrentSegm(){return this.cs[this.segm].angleTo(this.cs[this.segm-1])}}function kd(e,t,n,r,i){if(t.segment===void 0||n===0)return!0;let a=t,o=t.segment+1,s=0;for(;s>-n/2&&(o--,!(o<0));)s-=e[o].dist(a),a=e[o];o=Math.max(o,0),s+=e[o].dist(e[o+1]),o++;let c=[],l=0;for(;s<n/2;){let t=e[o-1],n=e[o],a=e[o+1];if(!a)break;let u=t.angleTo(n)-n.angleTo(a);for(u=Math.abs((u+3*Math.PI)%(2*Math.PI)-Math.PI),c.push({distance:s,angleDelta:u}),l+=u;s-c[0].distance>r;)l-=c.shift().angleDelta;if(l>i)return!1;o++,s+=n.dist(a)}return!0}function Ad(e,t,n){return e?.6*t*n:0}function jd(e,t){return Math.max(e?e.right-e.left:0,t?t.right-t.left:0)}function Md(e,t,n,r,i,a){let o=Ad(n,i,a),s=jd(n,r)*a,c=0,l=Rl(e)/2;for(let n=0;n<e.length-1;n++){let r=e[n],i=e[n+1],a=r.dist(i);if(c+a>l){let u=(l-c)/a,d=new Dd(yn.number(r.x,i.x,u),yn.number(r.y,i.y,u),i.angleTo(r),n);return d._round(),!o||kd(e,d,s,o,t)?d:void 0}c+=a}}function Nd(e,t,n,r,i,a,o,s,c,l,u){let d=Ad(r,a,o),f=jd(r,i)*o,p=f/4,m=Rl(e),h=(r?.text)?.toString()===Ll.debnames;function g(t,r,i,a){if(t.x>=0&&t.x<c&&t.y>=0&&t.y<c&&i-p>=0&&i+p<=m){let i=new Dd(t.x,t.y,a,r);if(i._round(),!d||kd(e,i,f,d,n))return b.push(i),!0;h&&Ll.logPoint(i,l,`Skipped anchor`)}return!1}let _=Math.floor((m-t)/(f+t));_<=0&&(_=1),u&&(_=1),_>1&&(t=(m-_*f)/(_+1));let v=_===1?m/2:(t+f)/2,y=v;h&&Ll.logLineStrings([e],l,`debnames anchorCount=${_}, spacing=${t}, firstAnchorOffset=${v}, lineLength=${m}, labelLength=${f}`);let b=[],x=new Od(e);for(;b.length<_;){let e=x.travelRouteRelative(y);if(!e)break;g(e,x.segm-1,x.totalDistance,x.angleOfCurrentSegm())?(y=t,x.travelRouteRelative(f)):y=2}if(b.length===0)for(h&&Ll.logLineStrings(e,l,`no anchors found, search back from ${v}`),x.travelRouteAbsolute(v);b.length===0;){let e=x.travelRouteRelative(-2);if(!e)break;g(e,x.segm-1,x.totalDistance,x.angleOfCurrentSegm())}return b}function Pd(e,t,r,i){let a=[],o=e.image,s=o.pixelRatio,c=o.paddedRect.w-2,l=o.paddedRect.h-2,u={x1:e.left,y1:e.top,x2:e.right,y2:e.bottom},d=o.stretchX||[[0,c]],f=o.stretchY||[[0,l]],p=(e,t)=>e+t[1]-t[0],m=d.reduce(p,0),h=f.reduce(p,0),g=c-m,_=l-h,v=0,y=m,b=0,x=h,S=0,C=g,w=0,T=_;if(o.content&&i){let t=o.content,n=t[2]-t[0],r=t[3]-t[1];(o.textFitWidth||o.textFitHeight)&&(u=Mu(e)),v=Fd(d,0,t[0]),b=Fd(f,0,t[1]),y=Fd(d,t[0],t[2]),x=Fd(f,t[1],t[3]),S=t[0]-v,w=t[1]-b,C=n-y,T=r-x}let E=u.x1,D=u.y1,O=u.x2-E,k=u.y2-D,A=(e,i,a,c)=>{let l=Ld(e.stretch-v,y,O,E),u=Rd(e.fixed-S,C,e.stretch,m),d=Ld(i.stretch-b,x,k,D),f=Rd(i.fixed-w,T,i.stretch,h),p=Ld(a.stretch-v,y,O,E),g=Rd(a.fixed-S,C,a.stretch,m),_=Ld(c.stretch-b,x,k,D),A=Rd(c.fixed-w,T,c.stretch,h),j=new n(l,d),M=new n(p,d),N=new n(p,_),P=new n(l,_),ee=new n(u/s,f/s),te=new n(g/s,A/s),F=t*Math.PI/180;if(F){let e=Math.sin(F),t=Math.cos(F),n=[t,-e,e,t];j._matMult(n),M._matMult(n),P._matMult(n),N._matMult(n)}let ne=e.stretch+e.fixed,re=i.stretch+i.fixed;return{tl:j,tr:M,bl:P,br:N,tex:{x:o.paddedRect.x+1+ne,y:o.paddedRect.y+1+re,w:a.stretch+a.fixed-ne,h:c.stretch+c.fixed-re},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:ee,pixelOffsetBR:te,minFontScaleX:C/s/O,minFontScaleY:T/s/k,isSDF:r}};if(i&&(o.stretchX||o.stretchY)){let e=Id(d,g,m),t=Id(f,_,h);for(let n=0;n<e.length-1;n++){let r=e[n],i=e[n+1];for(let e=0;e<t.length-1;e++)a.push(A(r,t[e],i,t[e+1]))}}else a.push(A({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:c+1},{fixed:0,stretch:l+1}));return a}function Fd(e,t,n){let r=0;for(let i of e)r+=Math.max(t,Math.min(n,i[1]))-Math.max(t,Math.min(n,i[0]));return r}function Id(e,t,n){let r=[{fixed:-1,stretch:0}];for(let[t,n]of e){let e=r[r.length-1];r.push({fixed:t-e.stretch,stretch:e.stretch}),r.push({fixed:t-e.stretch,stretch:e.stretch+(n-t)})}return r.push({fixed:t+1,stretch:n}),r}function Ld(e,t,n,r){return e/t*n+r}function Rd(e,t,n,r){return e-t*n/r}class zd{constructor(e,t,r,i,a,o,s,c,l,u,d,f=[0,0],p=`center`){if(this.boxStartIndex=e.length,l){let e=o.top,t=o.bottom,n=o.collisionPadding;n&&(e-=n[1],t+=n[3]);let r=t-e;r>0&&(r=Math.max(10,r),this.circleDiameter=r)}else{let{x1:l,x2:m,y1:h,y2:g}=d?function(e,t,n=[0,0],r=`center`){let i=e.right-e.left,a=e.bottom-e.top,{horizontalAlign:o,verticalAlign:s}=wu(r),c=n[0]+t[0]-i*o,l=n[1]+t[1]-a*s;return{x1:c,y1:l,x2:c+t[2]-t[0],y2:l+t[3]-t[1]}}(o,d,f,p):{x1:o.left,y1:o.top,x2:o.right,y2:o.bottom},_=o.image?.content&&(o.image.textFitWidth||o.image.textFitHeight)?Mu(o):{x1:l,y1:h,x2:m,y2:g};_.y1=_.y1*s-c[0],_.y2=_.y2*s+c[2],_.x1=_.x1*s-c[3],_.x2=_.x2*s+c[1];let v=o.collisionPadding;if(v&&(_.x1-=v[0]*s,_.y1-=v[1]*s,_.x2+=v[2]*s,_.y2+=v[3]*s),u){let e=new n(_.x1,_.y1),t=new n(_.x2,_.y1),r=new n(_.x1,_.y2),i=new n(_.x2,_.y2),a=u*Math.PI/180;e._rotate(a),t._rotate(a),r._rotate(a),i._rotate(a),_.x1=Math.min(e.x,t.x,r.x,i.x),_.x2=Math.max(e.x,t.x,r.x,i.x),_.y1=Math.min(e.y,t.y,r.y,i.y),_.y2=Math.max(e.y,t.y,r.y,i.y)}e.emplaceBack(t.x,t.y,_.x1,_.y1,_.x2,_.y2,r,i,a)}this.boxEndIndex=e.length}}class Bd{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(this.length===0)return;let 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){let{data:t,compare:n}=this,r=t[e];for(;e>0;){let i=e-1>>1,a=t[i];if(n(r,a)>=0)break;t[e]=a,e=i}t[e]=r}_down(e){let{data:t,compare:n}=this,r=this.length>>1,i=t[e];for(;e<r;){let r=1+(e<<1),a=r+1;if(a<this.length&&n(t[a],t[r])<0&&(r=a),n(t[r],i)>=0)break;t[e]=t[r],e=r}t[e]=i}}function Vd(e,t=1,r=!1){let i=ad.fromPoints(e[0]),a=Math.min(i.width(),i.height()),o=a/2,s=new Bd([],Hd),{minX:c,minY:l,maxX:u,maxY:d}=i;if(a===0)return new n(c,l);for(let t=c;t<u;t+=a)for(let n=l;n<d;n+=a)s.push(new Ud(t+o,n+o,o,e));let f=function(e){let t=0,n=0,r=0,i=e[0];for(let e=0,a=i.length,o=a-1;e<a;o=e++){let a=i[e],s=i[o],c=a.x*s.y-s.x*a.y;n+=(a.x+s.x)*c,r+=(a.y+s.y)*c,t+=3*c}return new Ud(n/t,r/t,0,e)}(e),p=s.length;for(;s.length;){let n=s.pop();(n.d>f.d||!f.d)&&(f=n,r&&console.log(`found best %d after %d probes`,Math.round(1e4*n.d)/1e4,p)),n.max-f.d<=t||(o=n.h/2,s.push(new Ud(n.p.x-o,n.p.y-o,o,e)),s.push(new Ud(n.p.x+o,n.p.y-o,o,e)),s.push(new Ud(n.p.x-o,n.p.y+o,o,e)),s.push(new Ud(n.p.x+o,n.p.y+o,o,e)),p+=4)}return r&&(console.log(`num probes: ${p}`),console.log(`best distance: ${f.d}`)),f.p}function Hd(e,t){return t.max-e.max}function Ud(e,t,r,i){this.p=new n(e,t),this.h=r,this.d=function(e,t){let n=!1,r=1/0;for(let i=0;i<t.length;i++){let a=t[i];for(let t=0,i=a.length,o=i-1;t<i;o=t++){let i=a[t],s=a[o];i.y>e.y!=s.y>e.y&&e.x<(s.x-i.x)*(e.y-i.y)/(s.y-i.y)+i.x&&(n=!n),r=Math.min(r,Ms(e,i,s))}}return(n?1:-1)*Math.sqrt(r)}(this.p,i),this.max=this.d+this.h*Math.SQRT2}var Wd;e.aE=void 0,(Wd=e.aE||={})[Wd.center=1]=`center`,Wd[Wd.left=2]=`left`,Wd[Wd.right=3]=`right`,Wd[Wd.top=4]=`top`,Wd[Wd.bottom=5]=`bottom`,Wd[Wd[`top-left`]=6]=`top-left`,Wd[Wd[`top-right`]=7]=`top-right`,Wd[Wd[`bottom-left`]=8]=`bottom-left`,Wd[Wd[`bottom-right`]=9]=`bottom-right`;let Gd=1/0;function Kd(e,t){return t[1]===Gd?function(e,t){let n=0,r=0;t<0&&(t=0);let i=t/Math.SQRT2;switch(e){case`top-right`:case`top-left`:r=i-7;break;case`bottom-right`:case`bottom-left`:r=7-i;break;case`bottom`:r=7-t;break;case`top`:r=t-7}switch(e){case`top-right`:case`bottom-right`:n=-i;break;case`top-left`:case`bottom-left`:n=i;break;case`left`:n=t;break;case`right`:n=-t}return[n,r]}(e,t[0]):function(e,t,n){let r=0,i=0;switch(t=Math.abs(t),n=Math.abs(n),e){case`top-right`:case`top-left`:case`top`:i=n-7;break;case`bottom-right`:case`bottom-left`:case`bottom`:i=7-n}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,i]}(e,t[0],t[1])}function qd(e,t,n){let r=e.layout,i=r.get(`text-variable-anchor-offset`)?.evaluate(t,{},n);if(i){let e=i.values,t=[];for(let n=0;n<e.length;n+=2){let r=t[n]=e[n],i=e[n+1].map((e=>e*Hl));r.startsWith(`top`)?i[1]-=7:r.startsWith(`bottom`)&&(i[1]+=7),t[n+1]=i}return new Wt(t)}let a=r.get(`text-variable-anchor`);if(a){let i;i=e._unevaluatedLayout.getValue(`text-radial-offset`)===void 0?r.get(`text-offset`).evaluate(t,{},n).map((e=>e*Hl)):[r.get(`text-radial-offset`).evaluate(t,{},n)*Hl,Gd];let o=[];for(let e of a)o.push(e,Kd(e,i));return new Wt(o)}return null}function Jd(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 Yd(t,n,r,i,a,o,s,c,l,u,d,f){let p=o.textMaxSize.evaluate(n,{});p===void 0&&(p=s);let m=t.layers[0].layout,h=m.get(`icon-offset`).evaluate(n,{},d),g=Zd(r.horizontal),_=s/24,v=t.tilePixelRatio*_,y=t.tilePixelRatio*p/24,b=t.tilePixelRatio*c,x=t.tilePixelRatio*m.get(`symbol-spacing`),S=m.get(`text-padding`)*t.tilePixelRatio,C=function(e,t,n,r=1){let i=e.get(`icon-padding`).evaluate(t,{},n),a=i&&i.values;return[a[0]*r,a[1]*r,a[2]*r,a[3]*r]}(m,n,d,t.tilePixelRatio),w=m.get(`text-max-angle`)/180*Math.PI,T=m.get(`text-rotation-alignment`)!==`viewport`&&m.get(`symbol-placement`)!==`point`,E=m.get(`icon-rotation-alignment`)===`map`&&m.get(`symbol-placement`)!==`point`,D=m.get(`symbol-placement`),k=x/2,A=m.get(`icon-text-fit`),j;i&&A!==`none`&&(t.allowVerticalPlacement&&r.vertical&&(j=Nu(i,r.vertical,A,m.get(`icon-text-fit-padding`),h,_)),g&&(i=Nu(i,g,A,m.get(`icon-text-fit-padding`),h,_)));let M=d?f.line.getGranularityForZoomLevel(d.z):1,N=(c,f)=>{f.x<0||f.x>=O||f.y<0||f.y>=O||function(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T){let E=t.addToLineVertexArray(n,r),D,O,k,A,j=0,M=0,N=0,P=0,ee=-1,te=-1,F={},ne=Qo(``);if(t.allowVerticalPlacement&&i.vertical){let e=c.layout.get(`text-rotate`).evaluate(x,{},w)+90;k=new zd(l,n,u,d,f,i.vertical,p,m,h,e),s&&(A=new zd(l,n,u,d,f,s,_,v,h,e))}if(a){let r=x.properties[`icon-collision-box`],i=c.layout.get(`icon-anchor`).evaluate(x,{},w),o=c.layout.get(`icon-rotate`).evaluate(x,{}),p=c.layout.get(`icon-text-fit`)!==`none`,m=Pd(a,o,C,p),h=s?Pd(s,o,C,p):void 0;O=new zd(l,n,u,d,f,a,_,v,!1,o,r,b,i),j=4*m.length;let g=t.iconSizeData,T=null;g.kind===`source`?(T=[128*c.layout.get(`icon-size`).evaluate(x,{})],T[0]>Pu&&se(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):g.kind===`composite`&&(T=[128*S.compositeIconSizes[0].evaluate(x,{},w),128*S.compositeIconSizes[1].evaluate(x,{},w)],(T[0]>Pu||T[1]>Pu)&&se(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),t.addSymbols(t.icon,m,T,b,y,x,e.W.none,n,E.lineStartIndex,E.lineLength,-1,w),ee=t.icon.placedSymbolArray.length-1,h&&(M=4*h.length,t.addSymbols(t.icon,h,T,b,y,x,e.W.vertical,n,E.lineStartIndex,E.lineLength,-1,w),te=t.icon.placedSymbolArray.length-1)}let re=Object.keys(i.horizontal);for(let r of re){let a=i.horizontal[r];D||=(ne=Qo(a.text),new zd(l,n,u,d,f,a,p,m,h,c.layout.get(`text-rotate`).evaluate(x,{},w)));let s=a.positionedLines.length===1;if(N+=Xd(t,n,a,o,c,h,x,g,E,i.vertical?e.W.horizontal:e.W.horizontalOnly,s?re:[r],F,ee,S,w),s)break}i.vertical&&(P+=Xd(t,n,i.vertical,o,c,h,x,g,E,e.W.vertical,[`vertical`],F,te,S,w));let ie=D?D.boxStartIndex:t.collisionBoxArray.length,ae=D?D.boxEndIndex:t.collisionBoxArray.length,oe=k?k.boxStartIndex:t.collisionBoxArray.length,ce=k?k.boxEndIndex:t.collisionBoxArray.length,le=O?O.boxStartIndex:t.collisionBoxArray.length,ue=O?O.boxEndIndex:t.collisionBoxArray.length,de=A?A.boxStartIndex:t.collisionBoxArray.length,fe=A?A.boxEndIndex:t.collisionBoxArray.length,pe=-1,me=(e,t)=>e&&e.circleDiameter?Math.max(e.circleDiameter,t):t;pe=me(D,pe),pe=me(k,pe),pe=me(O,pe),pe=me(A,pe);let he=pe>-1?1:0;he&&(pe*=T/Hl),x.sortKey!==void 0&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey);let ge=qd(c,x,w),[_e,ve]=function(t,n){let r=t.length,i=n?.values;if(i?.length>0)for(let n=0;n<i.length;n+=2){let r=i[n+1];t.emplaceBack(e.aE[i[n]],r[0],r[1])}return[r,t.length]}(t.textAnchorOffsets,ge);t.symbolInstances.emplaceBack(n.x,n.y,F.right>=0?F.right:-1,F.center>=0?F.center:-1,F.left>=0?F.left:-1,F.vertical||-1,ee,te,ne,ie,ae,oe,ce,le,ue,de,fe,u,N,P,j,M,he,0,p,pe,_e,ve,n.angle)}(t,f,c,r,i,a,j,t.layers[0],t.collisionBoxArray,n.index,n.sourceLayerIndex,t.index,v,[S,S,S,S],T,l,b,C,E,h,n,o,u,d,s)};if(D===`line`)for(let e of id(n.geometry,0,0,O,O)){let a=Wc(e,M);if(a.length>1){let e=Nd(a,x,w,r.vertical||g,i,24,y,0,O,d,t.layerIds[0].endsWith(`-abbr`));for(let n of e)g&&Qd(t,g.text,k,n)||N(a,n);(g?.text)?.toString()===Ll.debnames&&(Ll.logLineStrings(id(n.geometry,0,0,O,O),d),Ll.logPoints(e,d))}}else if(D===`line-center`){for(let e of n.geometry)if(e.length>1){let t=Wc(e,M),n=Md(t,w,r.vertical||g,i,24,y);n&&N(t,n)}}else if(n.type===`Polygon`)for(let e of ir(n.geometry,0)){let t=Vd(e,16);N(Wc(e[0],M,!0),new Dd(t.x,t.y,0))}else if(n.type===`LineString`)for(let e of n.geometry){let t=Wc(e,M);N(t,new Dd(t[0].x,t[0].y,0))}else if(n.type===`Point`)for(let e of n.geometry)for(let t of e)N([t],new Dd(t.x,t.y,0))}function Xd(e,t,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=function(e,t,r,i,a,o,s,c){let l=i.layout.get(`text-rotate`).evaluate(o,{})*Math.PI/180,u=[];for(let e of t.positionedLines)for(let i of e.positionedGlyphs){if(!i.rect)continue;let o=i.rect||{},d=4,f=!0,p=1,m=0,h=(a||c)&&i.vertical,g=i.metrics.advance*i.scale/2;if(c&&t.verticalizable&&(m=e.lineOffset/2-(i.imageName?-(Hl-i.metrics.width*i.scale)/2:(i.scale-1)*Hl)),i.imageName){let e=s[i.imageName];f=e.sdf,p=e.pixelRatio,d=1/p}let _=a?[i.x+g,i.y]:[0,0],v=a?[0,0]:[i.x+g+r[0],i.y+r[1]-m],y=[0,0];h&&(y=v,v=[0,0]);let b=i.metrics.isDoubleResolution?2:1,x=(i.metrics.left-d)*i.scale-g+v[0],S=(-i.metrics.top-d)*i.scale+v[1],C=x+o.w/b*i.scale/p,w=S+o.h/b*i.scale/p,T=new n(x,S),E=new n(C,S),D=new n(x,w),O=new n(C,w);if(h){let e=new n(-g,g- -17),t=-Math.PI/2,r=12-g,a=new n(22-r,-(i.imageName?r:0)),o=new n(...y);T._rotateAround(t,e)._add(a)._add(o),E._rotateAround(t,e)._add(a)._add(o),D._rotateAround(t,e)._add(a)._add(o),O._rotateAround(t,e)._add(a)._add(o)}if(l){let e=Math.sin(l),t=Math.cos(l),n=[t,-e,e,t];T._matMult(n),E._matMult(n),D._matMult(n),O._matMult(n)}let k=new n(0,0),A=new n(0,0);u.push({tl:T,tr:E,bl:D,br:O,tex:o,writingMode:t.writingMode,glyphOffset:_,sectionIndex:i.sectionIndex,isSDF:f,pixelOffsetTL:k,pixelOffsetBR:A,minFontScaleX:0,minFontScaleY:0})}return u}(0,r,c,a,o,s,i,e.allowVerticalPlacement),_=e.textSizeData,v=null;_.kind===`source`?(v=[128*a.layout.get(`text-size`).evaluate(s,{})],v[0]>Pu&&se(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):_.kind===`composite`&&(v=[128*m.compositeTextSizes[0].evaluate(s,{},h),128*m.compositeTextSizes[1].evaluate(s,{},h)],(v[0]>Pu||v[1]>Pu)&&se(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,g,v,c,o,s,u,t,l.lineStartIndex,l.lineLength,p,h);for(let t of d)f[t]=e.text.placedSymbolArray.length-1;return 4*g.length}function Zd(e){for(let t in e)return e[t];return null}function Qd(e,t,n,r){let i=e.compareText;if(t in i){let e=i[t];for(let t=e.length-1;t>=0;t--)if(r.dist(e[t])<n)return!0}else i[t]=[];return i[t].push(r),!1}let $d=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class ef{static from(e){if(!(e instanceof ArrayBuffer))throw Error(`Data must be an instance of ArrayBuffer.`);let[t,n]=new Uint8Array(e,0,2);if(t!==219)throw Error(`Data does not appear to be in a KDBush format.`);let r=n>>4;if(r!==1)throw Error(`Got v${r} data when expected v1.`);let i=$d[15&n];if(!i)throw Error(`Unrecognized array type.`);let[a]=new Uint16Array(e,2,1),[o]=new Uint32Array(e,4,1);return new ef(o,a,i,e)}constructor(e,t=64,n=Float64Array,r){if(isNaN(e)||e<0)throw Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=n,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;let i=$d.indexOf(this.ArrayType),a=2*e*this.ArrayType.BYTES_PER_ELEMENT,o=e*this.IndexArrayType.BYTES_PER_ELEMENT,s=(8-o%8)%8;if(i<0)throw Error(`Unexpected typed array class: ${n}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+o+s,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+a+o+s),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+o+s,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){let n=this._pos>>1;return this.ids[n]=n,this.coords[this._pos++]=e,this.coords[this._pos++]=t,n}finish(){let e=this._pos>>1;if(e!==this.numItems)throw Error(`Added ${e} items when expected ${this.numItems}.`);return tf(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,n,r){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:i,coords:a,nodeSize:o}=this,s=[0,i.length-1,0],c=[];for(;s.length;){let l=s.pop()||0,u=s.pop()||0,d=s.pop()||0;if(u-d<=o){for(let o=d;o<=u;o++){let s=a[2*o],l=a[2*o+1];s>=e&&s<=n&&l>=t&&l<=r&&c.push(i[o])}continue}let f=d+u>>1,p=a[2*f],m=a[2*f+1];p>=e&&p<=n&&m>=t&&m<=r&&c.push(i[f]),(l===0?e<=p:t<=m)&&(s.push(d),s.push(f-1),s.push(1-l)),(l===0?n>=p:r>=m)&&(s.push(f+1),s.push(u),s.push(1-l))}return c}within(e,t,n){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:r,coords:i,nodeSize:a}=this,o=[0,r.length-1,0],s=[],c=n*n;for(;o.length;){let l=o.pop()||0,u=o.pop()||0,d=o.pop()||0;if(u-d<=a){for(let n=d;n<=u;n++)of(i[2*n],i[2*n+1],e,t)<=c&&s.push(r[n]);continue}let f=d+u>>1,p=i[2*f],m=i[2*f+1];of(p,m,e,t)<=c&&s.push(r[f]),(l===0?e-n<=p:t-n<=m)&&(o.push(d),o.push(f-1),o.push(1-l)),(l===0?e+n>=p:t+n>=m)&&(o.push(f+1),o.push(u),o.push(1-l))}return s}}function tf(e,t,n,r,i,a){if(i-r<=n)return;let o=r+i>>1;nf(e,t,o,r,i,a),tf(e,t,n,r,o-1,1-a),tf(e,t,n,o+1,i,1-a)}function nf(e,t,n,r,i,a){for(;i>r;){if(i-r>600){let o=i-r+1,s=n-r+1,c=Math.log(o),l=.5*Math.exp(2*c/3),u=.5*Math.sqrt(c*l*(o-l)/o)*(s-o/2<0?-1:1);nf(e,t,n,Math.max(r,Math.floor(n-s*l/o+u)),Math.min(i,Math.floor(n+(o-s)*l/o+u)),a)}let o=t[2*n+a],s=r,c=i;for(rf(e,t,r,n),t[2*i+a]>o&&rf(e,t,r,i);s<c;){for(rf(e,t,s,c),s++,c--;t[2*s+a]<o;)s++;for(;t[2*c+a]>o;)c--}t[2*r+a]===o?rf(e,t,r,c):(c++,rf(e,t,c,i)),c<=n&&(r=c+1),n<=c&&(i=c-1)}}function rf(e,t,n,r){af(e,n,r),af(t,2*n,2*r),af(t,2*n+1,2*r+1)}function af(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function of(e,t,n,r){let i=e-n,a=t-r;return i*i+a*a}var sf;e.cy=void 0,(sf=e.cy||={}).create=`create`,sf.load=`load`,sf.fullLoad=`fullLoad`;let cf=null,lf=[],uf=1e3/60,df=`loadTime`,ff=`fullLoadTime`;e.$=C,e.A=f,e.B=function([e,t,n]){return t+=90,t*=Math.PI/180,n*=Math.PI/180,{x:e*Math.cos(t)*Math.sin(n),y:e*Math.sin(t)*Math.sin(n),z:e*Math.cos(n)}},e.C=yn,e.D=Q,e.E=Pe,e.F=Ea,e.G=na,e.H=function(e){if(ue==null){let t=e.navigator?e.navigator.userAgent:null;ue=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match(`Safari`)&&!t.match(`Chrome`)))}return ue},e.I=cu,e.J=class{constructor(e,t){this.target=e,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new nd((()=>this.process())),this.subscription=ge(this.target,`message`,(e=>this.receive(e)),!1),this.globalScope=le(self)?e:window}registerMessageHandler(e,t){this.messageHandlers[e]=t}sendAsync(e,t){return new Promise(((n,r)=>{let i=Math.round(0xde0b6b3a7640000*Math.random()).toString(36).substring(0,10),a=t?ge(t.signal,`abort`,(()=>{a?.unsubscribe(),delete this.resolveRejects[i];let t={id:i,type:`<cancel>`,origin:location.origin,targetMapId:e.targetMapId,sourceMapId:this.mapId};this.target.postMessage(t)}),rd):null;this.resolveRejects[i]={resolve:e=>{a?.unsubscribe(),n(e)},reject:e=>{a?.unsubscribe(),r(e)}};let o=[],s=Object.assign(Object.assign({},e),{id:i,sourceMapId:this.mapId,origin:location.origin,data:da(e.data,o)});this.target.postMessage(s,{transfer:o})}))}receive(e){let t=e.data,n=t.id;if(!(t.origin!==`file://`&&location.origin!==`file://`&&t.origin!==`resource://android`&&location.origin!==`resource://android`&&t.origin!==location.origin||t.targetMapId&&this.mapId!==t.targetMapId)){if(t.type===`<cancel>`){delete this.tasks[n];let e=this.abortControllers[n];delete this.abortControllers[n],e&&e.abort();return}if(le(self)||t.mustQueue)return this.tasks[n]=t,this.taskQueue.push(n),void this.invoker.trigger();this.processTask(n,t)}}process(){if(this.taskQueue.length===0)return;let e=this.taskQueue.shift(),t=this.tasks[e];delete this.tasks[e],this.taskQueue.length>0&&this.invoker.trigger(),t&&this.processTask(e,t)}processTask(e,n){return t(this,void 0,void 0,(function*(){if(n.type===`<response>`){let t=this.resolveRejects[e];if(delete this.resolveRejects[e],!t)return;n.error?t.reject(fa(n.error)):t.resolve(fa(n.data));return}if(!this.messageHandlers[n.type])return void this.completeTask(e,Error(`Could not find a registered handler for ${n.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(`, `)}`));let t=fa(n.data),r=new AbortController;this.abortControllers[e]=r;try{let i=yield this.messageHandlers[n.type](n.sourceMapId,t,r);this.completeTask(e,null,i)}catch(t){this.completeTask(e,t)}}))}completeTask(e,t,n){let r=[];delete this.abortControllers[e];let i={id:e,type:`<response>`,sourceMapId:this.mapId,origin:location.origin,error:t?da(t):null,data:da(n,r)};this.target.postMessage(i,{transfer:r})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},e.K=Te,e.L=ee,e.M=function(){var e=new f(16);return f!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e},e.N=function(e,t,n){var r=n[0],i=n[1],a=n[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]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*a,e[9]=t[9]*a,e[10]=t[10]*a,e[11]=t[11]*a,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},e.O=function(e,t){let n=0,r=0;if(e.kind===`constant`)r=e.layoutSize;else if(e.kind!==`source`){let{interpolationType:i,minZoom:a,maxZoom:o}=e,s=i?ee(_n.interpolationFactor(i,t,a,o),0,1):0;e.kind===`camera`?r=yn.number(e.minSize,e.maxSize,s):n=s}return{uSizeT:n,uSize:r}},e.P=n,e.Q=function(e,{uSize:t,uSizeT:n},{lowerSize:r,upperSize:i}){return e.kind===`source`?r/128:e.kind===`composite`?yn.number(r/128,i/128,n):t},e.R=Zs,e.S=function(e,t){var n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14],_=t[15],v=n*s-r*o,y=n*c-i*o,b=n*l-a*o,x=r*c-i*s,S=r*l-a*s,C=i*l-a*c,w=u*h-d*m,T=u*g-f*m,E=u*_-p*m,D=d*g-f*h,O=d*_-p*h,k=f*_-p*g,A=v*k-y*O+b*D+x*E-S*T+C*w;return A?(e[0]=(s*k-c*O+l*D)*(A=1/A),e[1]=(i*O-r*k-a*D)*A,e[2]=(h*C-g*S+_*x)*A,e[3]=(f*S-d*C-p*x)*A,e[4]=(c*E-o*k-l*T)*A,e[5]=(n*k-i*E+a*T)*A,e[6]=(g*b-m*C-_*y)*A,e[7]=(u*C-f*b+p*y)*A,e[8]=(o*O-s*E+l*w)*A,e[9]=(r*E-n*O-a*w)*A,e[10]=(m*S-h*b+_*v)*A,e[11]=(d*b-u*S-p*v)*A,e[12]=(s*T-o*D-c*w)*A,e[13]=(n*D-r*T+i*w)*A,e[14]=(h*y-m*x-g*v)*A,e[15]=(u*x-d*y+f*v)*A,e):null},e.T=oc,e.U=E,e.V=function(e){var t=e[0],n=e[1];return Math.sqrt(t*t+n*n)},e.X=function(e){return e[0]=0,e[1]=0,e},e.Y=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e},e.Z=zu,e._=t,e.a=Ce,e.a$=S,e.a0=function(e,t,r,i){let a=t.y-e.y,o=t.x-e.x,s=i.y-r.y,c=i.x-r.x,l=s*o-c*a;if(l===0)return null;let u=(c*(e.y-r.y)-s*(e.x-r.x))/l;return new n(e.x+u*o,e.y+u*a)},e.a1=id,e.a2=ad,e.a3=Ts,e.a4=m,e.a5=function(e,t,n){var r,i,a,o,s,c,l,u,d,f,p,m,h=n[0],g=n[1],_=n[2];return t===e?(e[12]=t[0]*h+t[4]*g+t[8]*_+t[12],e[13]=t[1]*h+t[5]*g+t[9]*_+t[13],e[14]=t[2]*h+t[6]*g+t[10]*_+t[14],e[15]=t[3]*h+t[7]*g+t[11]*_+t[15]):(i=t[1],a=t[2],o=t[3],s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11],e[0]=r=t[0],e[1]=i,e[2]=a,e[3]=o,e[4]=s,e[5]=c,e[6]=l,e[7]=u,e[8]=d,e[9]=f,e[10]=p,e[11]=m,e[12]=r*h+s*g+d*_+t[12],e[13]=i*h+c*g+f*_+t[13],e[14]=a*h+l*g+p*_+t[14],e[15]=o*h+u*g+m*_+t[15]),e},e.a6=function(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e)t=Math.min(t,a.x),n=Math.min(n,a.y),r=Math.max(r,a.x),i=Math.max(i,a.y);return[t,n,r,i]},e.a7=Hl,e.a8=function(e,t,n){var r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11],h=t[12],g=t[13],_=t[14],v=t[15],y=n[0],b=n[1],x=n[2],S=n[3];return e[0]=y*r+b*s+x*d+S*h,e[1]=y*i+b*c+x*f+S*g,e[2]=y*a+b*l+x*p+S*_,e[3]=y*o+b*u+x*m+S*v,e[4]=(y=n[4])*r+(b=n[5])*s+(x=n[6])*d+(S=n[7])*h,e[5]=y*i+b*c+x*f+S*g,e[6]=y*a+b*l+x*p+S*_,e[7]=y*o+b*u+x*m+S*v,e[8]=(y=n[8])*r+(b=n[9])*s+(x=n[10])*d+(S=n[11])*h,e[9]=y*i+b*c+x*f+S*g,e[10]=y*a+b*l+x*p+S*_,e[11]=y*o+b*u+x*m+S*v,e[12]=(y=n[12])*r+(b=n[13])*s+(x=n[14])*d+(S=n[15])*h,e[13]=y*i+b*c+x*f+S*g,e[14]=y*a+b*l+x*p+S*_,e[15]=y*o+b*u+x*m+S*v,e},e.a9=function(e,t){let n={};for(let r=0;r<t.length;r++){let i=t[r];i in e&&(n[i]=e[i])}return n},e.aA=function(e){var t=e[0],n=e[1];return t*t+n*n},e.aB=function(e,t){let n=[];for(let r in e)r in t||n.push(r);return n},e.aC=k,e.aD=function(e,t,n,r,i=!1){if(!n[0]&&!n[1])return[0,0];let a=i?r===`map`?-e.bearingInRadians:0:r===`viewport`?e.bearingInRadians:0;if(a){let e=Math.sin(a),t=Math.cos(a);n=[n[0]*t-n[1]*e,n[0]*e+n[1]*t]}return[i?n[0]:k(t,n[0],e.zoom,e.detailLevel),i?n[1]:k(t,n[1],e.zoom,e.detailLevel)]},e.aF=Iu,e.aG=Jd,e.aH=wu,e.aI=ef,e.aJ=Wa,e.aK=zc,e.aL=Oo,e.aM=Uo,e.aN=Bo,e.aO=te,e.aP=ve,e.aQ=md,e.aR=y,e.aS=v,e.aT=function(e){var t=new f(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},e.aU=function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e},e.aV=function(e,t){var n=t[0],r=t[1],i=t[2],a=n*n+r*r+i*i;return a>0&&(a=1/Math.sqrt(a)),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a,e},e.aW=b,e.aX=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},e.aY=function(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e[3]=t[3]*n[3],e},e.aZ=g,e.a_=function(e,t,n){let r=t[0]*n[0]+t[1]*n[1]+t[2]*n[2];return r===0?null:(-(e[0]*n[0]+e[1]*n[1]+e[2]*n[2])-n[3])/r},e.aa=sd,e.ab=dd,e.ac=ud,e.ad=l,e.ae=u,e.af=pe,e.ag=yd,e.ah=O,e.ai=function(e,t){if(!e)return t??{};if(!t)return e;let n=Object.assign({},e);if(t.removeAll&&(n.removeAll=!0),t.remove){let e=new Set(n.remove?n.remove.concat(t.remove):t.remove);n.remove=Array.from(e.values())}if(t.add){let e=n.add?n.add.concat(t.add):t.add,r=new Map(e.map((e=>[e.id,e])));n.add=Array.from(r.values())}if(t.update){let e=new Map(n.update?.map((e=>[e.id,e])));for(let n of t.update){let t=e.get(n.id)??{id:n.id};n.newGeometry&&(t.newGeometry=n.newGeometry),n.addOrUpdateProperties&&(t.addOrUpdateProperties=(t.addOrUpdateProperties??[]).concat(n.addOrUpdateProperties)),n.removeProperties&&(t.removeProperties=(t.removeProperties??[]).concat(n.removeProperties)),n.removeAllProperties&&(t.removeAllProperties=!0),e.set(n.id,t)}n.update=Array.from(e.values())}return n},e.aj=hd,e.ak=25,e.al=_d,e.am=e=>{let t=window.document.createElement(`video`);return t.muted=!0,new Promise((n=>{t.onloadstart=()=>{n(t)};for(let n of e){let e=window.document.createElement(`source`);ke(n)||(t.crossOrigin=`Anonymous`),e.src=n,t.appendChild(e)}}))},e.an=L,e.ao=function(){return ne++},e.ap=_o,e.aq=Uu,e.ar=pi,e.as=xs,e.at=Cd,e.au=function(e){let t={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((e,n,r,i)=>{let a=r||i;return t[n]=!a||a.toLowerCase(),``})),t[`max-age`]){let e=parseInt(t[`max-age`],10);isNaN(e)?delete t[`max-age`]:t[`max-age`]=e}return t},e.av=_e,e.aw=function(e){return 2**e},e.ax=85.051129,e.ay=fd,e.az=function(e){return Math.log(e)/Math.LN2},e.b=de,e.b$=class extends rs{constructor(e,t){super(e,t),this.current=[]}set(e){if(e!=this.current){this.current=e;let t=new Float32Array(e);this.gl.uniform1fv(this.location,t)}}},e.b0=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e},e.b1=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]},e.b2=vd,e.b3=bd,e.b4=function(e,t,n,r,i){var a=1/Math.tan(t/2);if(e[0]=a/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,i!=null&&i!==1/0){var o=1/(r-i);e[10]=(i+r)*o,e[14]=2*i*r*o}else e[10]=-1,e[14]=-2*r;return e},e.b5=function(e){var t=new f(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},e.b6=function(e,t,n){var r=Math.sin(n),i=Math.cos(n),a=t[0],o=t[1],s=t[2],c=t[3],l=t[4],u=t[5],d=t[6],f=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]=a*i+l*r,e[1]=o*i+u*r,e[2]=s*i+d*r,e[3]=c*i+f*r,e[4]=l*i-a*r,e[5]=u*i-o*r,e[6]=d*i-s*r,e[7]=f*i-c*r,e},e.b7=function(e,t,n){var r=Math.sin(n),i=Math.cos(n),a=t[4],o=t[5],s=t[6],c=t[7],l=t[8],u=t[9],d=t[10],f=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]=a*i+l*r,e[5]=o*i+u*r,e[6]=s*i+d*r,e[7]=c*i+f*r,e[8]=l*i-a*r,e[9]=u*i-o*r,e[10]=d*i-s*r,e[11]=f*i-c*r,e},e.b8=function(){let e=new Float32Array(16);return m(e),e},e.b9=function(){let e=new Float64Array(16);return m(e),e},e.bA=function(e,t){let n=A(e,360),r=A(t,360),i=r-n,a=r>n?i-360:i+360;return Math.abs(i)<Math.abs(a)?i:a},e.bB=function(e){return e[0]=0,e[1]=0,e[2]=0,e},e.bC=function(e,t,n,r){let i=Math.sqrt(e*e+t*t),a=Math.sqrt(n*n+r*r);e/=i,t/=i,n/=a,r/=a;let o=Math.acos(e*n+t*r);return-t*n+e*r>0?o:-o},e.bD=function(e,t){let n=A(e,2*Math.PI),r=A(t,2*Math.PI);return Math.min(Math.abs(n-r),Math.abs(n-r+2*Math.PI),Math.abs(n-r-2*Math.PI))},e.bE=function(){let e={},t=I.$version;for(let n in I.$root){let r=I.$root[n];if(r.required){let i=null;i=n===`version`?t:r.type===`array`?[]:{},i!=null&&(e[n]=i)}}return e},e.bF=X,e.bG=De,e.bH=function e(t,n){if(Array.isArray(t)){if(!Array.isArray(n)||t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!e(t[r],n[r]))return!1;return!0}if(typeof t==`object`&&t&&n!==null){if(typeof n!=`object`||Object.keys(t).length!==Object.keys(n).length)return!1;for(let r in t)if(!e(t[r],n[r]))return!1;return!0}return t===n},e.bI=function(e){e=e.slice();let t=Object.create(null);for(let n=0;n<e.length;n++)t[e[n].id]=e[n];for(let n=0;n<e.length;n++)`ref`in e[n]&&(e[n]=Ie(e[n],t[e[n].ref]));return e},e.bJ=function(e){if(e.type===`custom`)return new td(e);switch(e.type){case`background`:return new Zu(e);case`circle`:return new Hs(e);case`color-relief`:return new lc(e);case`fill`:return new Qc(e);case`fill-extrusion`:return new _l(e);case`heatmap`:return new ec(e);case`hillshade`:return new rc(e);case`line`:return new Al(e);case`raster`:return new ed(e);case`symbol`:return new Ju(e)}},e.bK=ae,e.bL=function(e,t){if(!e)return[{command:`setStyle`,args:[t]}];let n=[];try{if(!Le(e.version,t.version))return[{command:`setStyle`,args:[t]}];Le(e.center,t.center)||n.push({command:`setCenter`,args:[t.center]}),Le(e.state,t.state)||n.push({command:`setGlobalState`,args:[t.state]}),Le(e.centerAltitude,t.centerAltitude)||n.push({command:`setCenterAltitude`,args:[t.centerAltitude]}),Le(e.zoom,t.zoom)||n.push({command:`setZoom`,args:[t.zoom]}),Le(e.bearing,t.bearing)||n.push({command:`setBearing`,args:[t.bearing]}),Le(e.pitch,t.pitch)||n.push({command:`setPitch`,args:[t.pitch]}),Le(e.roll,t.roll)||n.push({command:`setRoll`,args:[t.roll]}),Le(e.sprite,t.sprite)||n.push({command:`setSprite`,args:[t.sprite]}),Le(e.glyphs,t.glyphs)||n.push({command:`setGlyphs`,args:[t.glyphs]}),Le(e.transition,t.transition)||n.push({command:`setTransition`,args:[t.transition]}),Le(e.light,t.light)||n.push({command:`setLight`,args:[t.light]}),Le(e.terrain,t.terrain)||n.push({command:`setTerrain`,args:[t.terrain]}),Le(e.sky,t.sky)||n.push({command:`setSky`,args:[t.sky]}),Le(e.projection,t.projection)||n.push({command:`setProjection`,args:[t.projection]});let r={},i=[];(function(e,t,n,r){let i;for(i in t||={},e||={})Object.prototype.hasOwnProperty.call(e,i)&&(Object.prototype.hasOwnProperty.call(t,i)||Be(i,n,r));for(i in t)Object.prototype.hasOwnProperty.call(t,i)&&(Object.prototype.hasOwnProperty.call(e,i)?Le(e[i],t[i])||(e[i].type===`geojson`&&t[i].type===`geojson`&&He(e,t,i)?Re(n,{command:`setGeoJSONSourceData`,args:[i,t[i].data]}):Ve(i,t,n,r)):ze(i,t,n))})(e.sources,t.sources,i,r);let a=[];e.layers&&e.layers.forEach((e=>{`source`in e&&r[e.source]?n.push({command:`removeLayer`,args:[e.id]}):a.push(e)})),n=n.concat(i),function(e,t,n){t||=[];let r=(e||=[]).map(We),i=t.map(We),a=e.reduce(Ge,{}),o=t.reduce(Ge,{}),s=r.slice(),c=Object.create(null),l,u,d,f,p;for(let e=0,t=0;e<r.length;e++)l=r[e],Object.prototype.hasOwnProperty.call(o,l)?t++:(Re(n,{command:`removeLayer`,args:[l]}),s.splice(s.indexOf(l,t),1));for(let e=0,t=0;e<i.length;e++)l=i[i.length-1-e],s[s.length-1-e]!==l&&(Object.prototype.hasOwnProperty.call(a,l)?(Re(n,{command:`removeLayer`,args:[l]}),s.splice(s.lastIndexOf(l,s.length-t),1)):t++,f=s[s.length-e],Re(n,{command:`addLayer`,args:[o[l],f]}),s.splice(s.length-e,0,l),c[l]=!0);for(let e=0;e<i.length;e++)if(l=i[e],u=a[l],d=o[l],!c[l]&&!Le(u,d))if(Le(u.source,d.source)&&Le(u[`source-layer`],d[`source-layer`])&&Le(u.type,d.type)){for(p in Ue(u.layout,d.layout,n,l,null,`setLayoutProperty`),Ue(u.paint,d.paint,n,l,null,`setPaintProperty`),Le(u.filter,d.filter)||Re(n,{command:`setFilter`,args:[l,d.filter]}),Le(u.minzoom,d.minzoom)&&Le(u.maxzoom,d.maxzoom)||Re(n,{command:`setLayerZoomRange`,args:[l,d.minzoom,d.maxzoom]}),u)Object.prototype.hasOwnProperty.call(u,p)&&p!==`layout`&&p!==`paint`&&p!==`filter`&&p!==`metadata`&&p!==`minzoom`&&p!==`maxzoom`&&(p.indexOf(`paint.`)===0?Ue(u[p],d[p],n,l,p.slice(6),`setPaintProperty`):Le(u[p],d[p])||Re(n,{command:`setLayerProperty`,args:[l,p,d[p]]}));for(p in d)Object.prototype.hasOwnProperty.call(d,p)&&!Object.prototype.hasOwnProperty.call(u,p)&&p!==`layout`&&p!==`paint`&&p!==`filter`&&p!==`metadata`&&p!==`minzoom`&&p!==`maxzoom`&&(p.indexOf(`paint.`)===0?Ue(u[p],d[p],n,l,p.slice(6),`setPaintProperty`):Le(u[p],d[p])||Re(n,{command:`setLayerProperty`,args:[l,p,d[p]]}))}else Re(n,{command:`removeLayer`,args:[l]}),f=s[s.lastIndexOf(l)+1],Re(n,{command:`addLayer`,args:[d,f]})}(a,t.layers,n)}catch(e){console.warn(`Unable to compute style diff:`,e),n=[{command:`setStyle`,args:[t]}]}return n},e.bM=function(e){let t=[],n=e.id;return n===void 0&&t.push({message:`layers.${n}: missing required property "id"`}),e.render===void 0&&t.push({message:`layers.${n}: missing required method "render"`}),e.renderingMode&&e.renderingMode!==`2d`&&e.renderingMode!==`3d`&&t.push({message:`layers.${n}: property "renderingMode" must be either "2d" or "3d"`}),t},e.bN=re,e.bO=ie,e.bP=function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)for(let r=0;r<4;r++)if(e[n][r]!==t[n][r])return!1;return!0},e.bQ=class extends rs{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1i(this.location,e))}},e.bR=os,e.bS=class extends rs{constructor(e,t){super(e,t),this.current=ss}set(e){if(e[12]!==this.current[12]||e[0]!==this.current[0])return this.current=e,void this.gl.uniformMatrix4fv(this.location,!1,e);for(let t=1;t<16;t++)if(e[t]!==this.current[t]){this.current=e,this.gl.uniformMatrix4fv(this.location,!1,e);break}}},e.bT=as,e.bU=class extends rs{constructor(e,t){super(e,t),this.current=[0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]||(this.current=e,this.gl.uniform3f(this.location,e[0],e[1],e[2]))}},e.bV=class extends rs{constructor(e,t){super(e,t),this.current=[0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]||(this.current=e,this.gl.uniform2f(this.location,e[0],e[1]))}},e.bW=p,e.bX=function(e,t){var n=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=n,e[2]=0,e[3]=-n,e[4]=r,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},e.bY=function(e,t,n){var r=t[0],i=t[1],a=t[2];return e[0]=r*n[0]+i*n[3]+a*n[6],e[1]=r*n[1]+i*n[4]+a*n[7],e[2]=r*n[2]+i*n[5]+a*n[8],e},e.bZ=function(e,t,n,r,i,a,o){var s=1/(t-n),c=1/(r-i),l=1/(a-o);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*c,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+n)*s,e[13]=(i+r)*c,e[14]=(o+a)*l,e[15]=1,e},e.b_=class extends rs{constructor(e,t){super(e,t),this.current=[]}set(e){if(e!=this.current){this.current=e;let t=new Float32Array(4*e.length);for(let n=0;n<e.length;n++)t[4*n]=e[n].r,t[4*n+1]=e[n].g,t[4*n+2]=e[n].b,t[4*n+3]=e[n].a;this.gl.uniform4fv(this.location,t)}}},e.ba=function(){return new Float64Array(16)},e.bb=function(e,t,n){let r=new Float64Array(4);return T(r,e,t-90,n),r},e.bc=function(e,t,n,r){var i,a,o,s,c,l=t[0],u=t[1],f=t[2],p=t[3],m=n[0],h=n[1],g=n[2],_=n[3];return(a=l*m+u*h+f*g+p*_)<0&&(a=-a,m=-m,h=-h,g=-g,_=-_),1-a>d?(i=Math.acos(a),o=Math.sin(i),s=Math.sin((1-r)*i)/o,c=Math.sin(r*i)/o):(s=1-r,c=r),e[0]=s*l+c*m,e[1]=s*u+c*h,e[2]=s*f+c*g,e[3]=s*p+c*_,e},e.bd=function(e){let t=new Float64Array(9);var n,r,i,a,o,s,c,l,u,d=(i=(r=e)[0])*(c=i+i),f=(a=r[1])*c,p,m=(o=r[2])*c,h=o*(l=a+a),g,_=(s=r[3])*c,v=s*l,y=s*(u=o+o);(n=t)[0]=1-(p=a*l)-(g=o*u),n[3]=f-y,n[6]=m+v,n[1]=f+y,n[4]=1-d-g,n[7]=h-_,n[2]=m-v,n[5]=h+_,n[8]=1-d-p;let b=ve(-Math.asin(ee(t[2],-1,1))),x,S;return Math.hypot(t[5],t[8])<.001?(x=0,S=-ve(Math.atan2(t[3],t[4]))):(x=ve(t[5]===0&&t[8]===0?0:Math.atan2(t[5],t[8])),S=ve(t[1]===0&&t[0]===0?0:Math.atan2(t[1],t[0]))),{roll:x,pitch:b+90,bearing:S}},e.be=function(e,t){return e.roll==t.roll&&e.pitch==t.pitch&&e.bearing==t.bearing},e.bf=U,e.bg=is,e.bh=Bc,e.bi=Vc,e.bj=Rc,e.bk=j,e.bl=M,e.bm=Kt,e.bn=function(e,t,n,r,i){return j(r,i,ee((e-t)/(n-t),0,1))},e.bo=A,e.bp=function(){return new Float64Array(3)},e.bq=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e},e.br=T,e.bs=function(e,t,n){var r=n[0],i=n[1],a=n[2],o=n[3],s=t[0],c=t[1],l=t[2],u=i*l-a*c,d=a*s-r*l,f=r*c-i*s;return e[0]=s+o*(u+=u)+i*(f+=f)-a*(d+=d),e[1]=c+o*d+a*u-r*f,e[2]=l+o*f+r*d-i*u,e},e.bt=function(e,t,n){let r=(i=[e[0],e[1],e[2],t[0],t[1],t[2],n[0],n[1],n[2]])[0]*((u=i[8])*(o=i[4])-(s=i[5])*(l=i[7]))+i[1]*(-u*(a=i[3])+s*(c=i[6]))+i[2]*(l*a-o*c);var i,a,o,s,c,l,u;if(r===0)return null;let d=b([],[t[0],t[1],t[2]],[n[0],n[1],n[2]]),f=b([],[n[0],n[1],n[2]],[e[0],e[1],e[2]]),p=b([],[e[0],e[1],e[2]],[t[0],t[1],t[2]]),m=y([],d,-e[3]);return v(m,m,y([],f,-t[3])),v(m,m,y([],p,-n[3])),y(m,m,1/r),m},e.bu=od,e.bv=function(){return new Float64Array(4)},e.bw=function(e,t,n,r){var i=[],a=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],a[0]=i[0]*Math.cos(r)-i[1]*Math.sin(r),a[1]=i[0]*Math.sin(r)+i[1]*Math.cos(r),a[2]=i[2],e[0]=a[0]+n[0],e[1]=a[1]+n[1],e[2]=a[2]+n[2],e},e.bx=function(e,t,n,r){var i=[],a=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],a[0]=i[0],a[1]=i[1]*Math.cos(r)-i[2]*Math.sin(r),a[2]=i[1]*Math.sin(r)+i[2]*Math.cos(r),e[0]=a[0]+n[0],e[1]=a[1]+n[1],e[2]=a[2]+n[2],e},e.by=function(e,t,n,r){var i=[],a=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],a[0]=i[2]*Math.sin(r)+i[0]*Math.cos(r),a[1]=i[1],a[2]=i[2]*Math.cos(r)-i[0]*Math.sin(r),e[0]=a[0]+n[0],e[1]=a[1]+n[1],e[2]=a[2]+n[2],e},e.bz=function(e,t,n){var r=Math.sin(n),i=Math.cos(n),a=t[0],o=t[1],s=t[2],c=t[3],l=t[8],u=t[9],d=t[10],f=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]=a*i-l*r,e[1]=o*i-u*r,e[2]=s*i-d*r,e[3]=c*i-f*r,e[8]=a*r+l*i,e[9]=o*r+u*i,e[10]=s*r+d*i,e[11]=c*r+f*i,e},e.c=Se,e.c0=class extends io{},e.c1=Il,e.c2=class extends oo{},e.c3=$s,e.c4=function(e){return e<=1?1:2**Math.ceil(Math.log(e)/Math.LN2)},e.c5=Qs,e.c6=function(e,t,n){var r=t[0],i=t[1],a=t[2],o=n[3]*r+n[7]*i+n[11]*a+n[15];return e[0]=(n[0]*r+n[4]*i+n[8]*a+n[12])/(o||=1),e[1]=(n[1]*r+n[5]*i+n[9]*a+n[13])/o,e[2]=(n[2]*r+n[6]*i+n[10]*a+n[14])/o,e},e.c7=class extends Ja{},e.c8=class extends mo{},e.c9=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.cA=function(e,t,n,r,i,a){let o=Rt.fromString(e),s=fu.fromFeature(o,t);return pu(s,Cu(s,n*Hl,r*Hl,a,{},i))},e.cB=Ee,e.cC=function(e,t){Ce.REGISTERED_PROTOCOLS[e]=t},e.cD=function(e){delete Ce.REGISTERED_PROTOCOLS[e]},e.cE=ii,e.cF=function(e,t){let n={};for(let r=0;r<e.length;r++){let i=t&&t[e[r].id]||Si(e[r]);t&&(t[e[r].id]=i);let a=n[i];a||=n[i]=[],a.push(e[r])}let r=[];for(let e in n)r.push(n[e]);return r},e.cG=Y,e.cH=Sd,e.cI=wd,e.cJ=lu,e.cK=function(t){t.bucket.createArrays(),t.bucket.tilePixelRatio=O/(512*t.bucket.overscaling),t.bucket.compareText={},t.bucket.iconsNeedLinear=!1;let n=t.bucket.layers[0],r=n.layout,i=n.metadata,a=n._unevaluatedLayout._values,o={layoutIconSize:a[`icon-size`].possiblyEvaluate(new Ea(t.bucket.zoom+1),t.canonical),layoutTextSize:a[`text-size`].possiblyEvaluate(new Ea(t.bucket.zoom+1),t.canonical),textMaxSize:a[`text-size`].possiblyEvaluate(new Ea(18))};if(t.bucket.textSizeData.kind===`composite`){let{minZoom:e,maxZoom:n}=t.bucket.textSizeData;o.compositeTextSizes=[a[`text-size`].possiblyEvaluate(new Ea(e),t.canonical),a[`text-size`].possiblyEvaluate(new Ea(n),t.canonical)]}if(t.bucket.iconSizeData.kind===`composite`){let{minZoom:e,maxZoom:n}=t.bucket.iconSizeData;o.compositeIconSizes=[a[`icon-size`].possiblyEvaluate(new Ea(e),t.canonical),a[`icon-size`].possiblyEvaluate(new Ea(n),t.canonical)]}let s=r.get(`text-line-height`)*Hl,c=r.get(`text-rotation-alignment`)!==`viewport`&&r.get(`symbol-placement`)!==`point`,l=r.get(`text-keep-upright`),u=r.get(`text-size`);for(let a of t.bucket.features){let d=r.get(`text-font`).evaluate(a,{},t.canonical).join(`,`),f=u.evaluate(a,{},t.canonical),p=o.layoutTextSize.evaluate(a,{},t.canonical),m=o.layoutIconSize.evaluate(a,{},t.canonical),h={horizontal:{},vertical:void 0},g=a.text,_,v=[0,0];if(g){let o=g.toString(),u=i?.[`text-letter-spacing-correction`]??0,m=(r.get(`text-letter-spacing`).evaluate(a,{},t.canonical)+u)*Hl,_=ma(o)?m:0,y=r.get(`text-anchor`).evaluate(a,{},t.canonical),b=qd(n,a,t.canonical);if(!b){let e=r.get(`text-radial-offset`).evaluate(a,{},t.canonical);v=e?Kd(y,[e*Hl,Gd]):r.get(`text-offset`).evaluate(a,{},t.canonical).map((e=>e*Hl))}let x=c?`center`:r.get(`text-justify`).evaluate(a,{},t.canonical),S=r.get(`symbol-placement`)===`point`?r.get(`text-max-width`).evaluate(a,{},t.canonical)*Hl:1/0,C=()=>{t.bucket.allowVerticalPlacement&&pa(o)&&(h.vertical=mu(g,t.glyphMap,t.glyphPositions,t.imagePositions,d,S,s,y,`left`,_,v,e.W.vertical,!0,p,f))};if(!c&&b){let n=new Set;if(x===`auto`)for(let e=0;e<b.values.length;e+=2)n.add(Jd(b.values[e]));else n.add(x);let r=!1;for(let i of n)if(!h.horizontal[i])if(r)h.horizontal[i]=h.horizontal[0];else{let n=mu(g,t.glyphMap,t.glyphPositions,t.imagePositions,d,S,s,`center`,i,_,v,e.W.horizontal,!1,p,f);n&&(h.horizontal[i]=n,r=n.positionedLines.length===1)}C()}else{x===`auto`&&(x=Jd(y));let n=mu(g,t.glyphMap,t.glyphPositions,t.imagePositions,d,S,s,y,x,_,v,e.W.horizontal,!1,p,f);n&&(h.horizontal[x]=n),C(),pa(o)&&c&&l&&(h.vertical=mu(g,t.glyphMap,t.glyphPositions,t.imagePositions,d,S,s,y,x,_,v,e.W.vertical,!1,p,f))}}let y=!1;if(a.icon&&a.icon.name){let e=t.imageMap[a.icon.name];if(e){_=ju(t.imagePositions[a.icon.name],r.get(`icon-offset`).evaluate(a,{},t.canonical),r.get(`icon-anchor`).evaluate(a,{},t.canonical)),y=!!e.sdf,t.bucket.sdfIcons===void 0?t.bucket.sdfIcons=y:t.bucket.sdfIcons!==y&&se(`Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer`);let n=a.properties?.[`icon-rotate`]??r.get(`icon-rotate`).constantOr(1),i=a.properties?.[`icon-size`]??r.get(`icon-size`).constantOr(1);e.pixelRatio===t.bucket.pixelRatio&&n===0&&i===1||(t.bucket.iconsNeedLinear=!0)}}let b=Zd(h.horizontal)||h.vertical;t.bucket.iconsInText=!!b&&b.iconsInText,(b||_)&&Yd(t.bucket,a,h,_,t.imageMap,o,p,m,v,y,t.canonical,t.subdivisionGranularity)}t.showCollisionBoxes&&t.bucket.generateCollisionDebugBuffers()},e.cL=wl,e.cM=Jc,e.cN=dl,e.cO=sl,e.cP=Kl,e.cQ=class{constructor(e){this._marks={start:[e.url,`start`].join(`#`),end:[e.url,`end`].join(`#`),measure:e.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let e=performance.getEntriesByName(this._marks.measure);return e.length===0&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),e=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),e}},e.cR=function(e,n,r,i,a){return t(this,void 0,void 0,(function*(){if(u())try{return yield pe(e,n,r,i,a)}catch{}return function(e,t,n,r,i){let a=e.width,o=e.height;me&&he||(me=new OffscreenCanvas(a,o),he=me.getContext(`2d`,{willReadFrequently:!0})),me.width=a,me.height=o,he.drawImage(e,0,0,a,o);let s=he.getImageData(t,n,r,i);return he.clearRect(0,0,a,o),s.data}(e,n,r,i,a)}))},e.cS=sc,e.cT=r,e.cU=al,e.cV=nl,e.cW=function(e,t){let n=new Map;if(e!=null)if(e.type===`Feature`)n.set(xd(e,t),e);else for(let r of e.features)n.set(xd(r,t),r);return n},e.cX=function(e,t){if(e==null)return!0;if(e.type===`Feature`)return xd(e,t)!=null;if(e.type===`FeatureCollection`){let n=new Set;for(let r of e.features){let e=xd(r,t);if(e==null||n.has(e))return!1;n.add(e)}return!0}return!1},e.cY=function(e,t,n){if(t.removeAll&&e.clear(),t.remove)for(let n of t.remove)e.delete(n);if(t.add)for(let r of t.add){let t=xd(r,n);t!=null&&e.set(t,r)}if(t.update)for(let n of t.update){let t=e.get(n.id);if(t==null)continue;let r=!n.removeAllProperties&&(n.removeProperties?.length>0||n.addOrUpdateProperties?.length>0);if((n.newGeometry||n.removeAllProperties||r)&&(t=Object.assign({},t),e.set(n.id,t),r&&(t.properties=Object.assign({},t.properties))),n.newGeometry&&(t.geometry=n.newGeometry),n.removeAllProperties)t.properties={};else if(n.removeProperties?.length>0)for(let e of n.removeProperties)Object.prototype.hasOwnProperty.call(t.properties,e)&&delete t.properties[e];if(n.addOrUpdateProperties?.length>0)for(let{key:e,value:r}of n.addOrUpdateProperties)t.properties[e]=r}},e.cZ=Ta,e.ca=function(e,t){var n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=e[6],l=e[7],u=e[8],f=e[9],p=e[10],m=e[11],h=e[12],g=e[13],_=e[14],v=e[15],y=t[0],b=t[1],x=t[2],S=t[3],C=t[4],w=t[5],T=t[6],E=t[7],D=t[8],O=t[9],k=t[10],A=t[11],j=t[12],M=t[13],N=t[14],P=t[15];return Math.abs(n-y)<=d*Math.max(1,Math.abs(n),Math.abs(y))&&Math.abs(r-b)<=d*Math.max(1,Math.abs(r),Math.abs(b))&&Math.abs(i-x)<=d*Math.max(1,Math.abs(i),Math.abs(x))&&Math.abs(a-S)<=d*Math.max(1,Math.abs(a),Math.abs(S))&&Math.abs(o-C)<=d*Math.max(1,Math.abs(o),Math.abs(C))&&Math.abs(s-w)<=d*Math.max(1,Math.abs(s),Math.abs(w))&&Math.abs(c-T)<=d*Math.max(1,Math.abs(c),Math.abs(T))&&Math.abs(l-E)<=d*Math.max(1,Math.abs(l),Math.abs(E))&&Math.abs(u-D)<=d*Math.max(1,Math.abs(u),Math.abs(D))&&Math.abs(f-O)<=d*Math.max(1,Math.abs(f),Math.abs(O))&&Math.abs(p-k)<=d*Math.max(1,Math.abs(p),Math.abs(k))&&Math.abs(m-A)<=d*Math.max(1,Math.abs(m),Math.abs(A))&&Math.abs(h-j)<=d*Math.max(1,Math.abs(h),Math.abs(j))&&Math.abs(g-M)<=d*Math.max(1,Math.abs(g),Math.abs(M))&&Math.abs(_-N)<=d*Math.max(1,Math.abs(_),Math.abs(N))&&Math.abs(v-P)<=d*Math.max(1,Math.abs(v),Math.abs(P))},e.cb=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},e.cc=e=>e.type===`symbol`,e.cd=e=>e.type===`circle`,e.ce=e=>e.type===`heatmap`,e.cf=e=>e.type===`line`,e.cg=e=>e.type===`fill`,e.ch=e=>e.type===`fill-extrusion`,e.ci=e=>e.type===`hillshade`,e.cj=e=>e.type===`color-relief`,e.ck=e=>e.type===`raster`,e.cl=e=>e.type===`background`,e.cm=e=>e.type===`custom`,e.cn=N,e.co=function(e,t,n){let r=D(t.x-n.x,t.y-n.y),i=D(e.x-n.x,e.y-n.y);var a,o;return ve(Math.atan2(r[0]*i[1]-r[1]*i[0],(a=r)[0]*(o=i)[0]+a[1]*o[1]))},e.cp=P,e.cq=function(e,t){return be[t]&&(e instanceof MouseEvent||e instanceof WheelEvent)},e.cr=function(e,t){return ye[t]&&`touches`in e},e.cs=function(e){return ye[e]||be[e]},e.ct=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[4]*i+n[12],e[1]=n[1]*r+n[5]*i+n[13],e},e.cu=function(e,t){let{x:n,y:r}=hd.fromLngLat(t);return!(e<0||e>25||r<0||r>=1||n<0||n>=1)},e.cv=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},e.cw=class extends qa{},e.cx={mark(e){performance.mark(e)},frame(e){let t=e;cf!=null&&lf.push(t-cf),cf=t},clearMetrics(){cf=null,lf=[],performance.clearMeasures(df),performance.clearMeasures(ff);for(let t in e.cy)performance.clearMarks(e.cy[t])},getPerformanceMetrics(){performance.measure(df,e.cy.create,e.cy.load),performance.measure(ff,e.cy.create,e.cy.fullLoad);let t=performance.getEntriesByName(df)[0].duration,n=performance.getEntriesByName(ff)[0].duration,r=lf.length,i=1/(lf.reduce(((e,t)=>e+t),0)/r/1e3),a=lf.filter((e=>e>uf)).reduce(((e,t)=>e+(t-uf)/uf),0);return{loadTime:t,fullLoadTime:n,fps:i,percentDroppedFrames:a/(r+a)*100,totalFrames:r}}},e.cz=function(e){return e.message===xe},e.d=ke,e.e=F,e.f=e=>t(void 0,void 0,void 0,(function*(){if(e.byteLength===0)return createImageBitmap(new ImageData(1,1));let t=new Blob([new Uint8Array(e)],{type:`image/png`});try{return createImageBitmap(t)}catch(e){throw Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})),e.g=we,e.h=e=>new Promise(((t,n)=>{let r=new Image;r.onload=()=>{t(r),URL.revokeObjectURL(r.src),r.onload=null,window.requestAnimationFrame((()=>{r.src=fe}))},r.onerror=()=>n(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.`));let i=new Blob([new Uint8Array(e)],{type:`image/png`});r.src=e.byteLength?URL.createObjectURL(i):fe})),e.i=le,e.j=(e,t)=>Oe(F(e,{type:`json`}),t),e.k=Ne,e.l=Me,e.m=Oe,e.n=(e,t)=>Oe(F(e,{type:`arrayBuffer`}),t),e.o=function(e){return new Kl(e).readFields(iu,[])},e.p=su,e.q=Xs,e.r=Ra,e.s=ge,e.t=ka,e.u=Z,e.v=I,e.w=se,e.x=ta,e.y=aa,e.z=ea})),n(`worker`,[`./shared`],(function(e){class t{constructor(e){this.keyCache={},e&&this.replace(e)}replace(e){this._layerConfigs={},this._layers={},this.update(e,[])}update(t,n){for(let n of t){this._layerConfigs[n.id]=n;let t=this._layers[n.id]=e.bJ(n);t._featureFilter=e.ar(t.filter),this.keyCache[n.id]&&delete this.keyCache[n.id]}for(let e of n)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};let r=e.cF(Object.values(this._layerConfigs),this.keyCache);for(let e of r){let t=e.map((e=>this._layers[e.id])),n=t[0];if(n.visibility===`none`)continue;let r=n.source||``,i=this.familiesBySource[r];i||=this.familiesBySource[r]={};let a=n.sourceLayer||`_geojsonTileLayer`,o=i[a];o||=i[a]=[],o.push(t)}}}class n{constructor(t){let n={},r=[];for(let e in t){let i=t[e],a=n[e]={};for(let e in i){let t=i[+e];if(!t||t.bitmap.width===0||t.bitmap.height===0)continue;let n={x:0,y:0,w:t.bitmap.width+2,h:t.bitmap.height+2};r.push(n),a[e]={rect:n,metrics:t.metrics}}}let{w:i,h:a}=e.p(r),o=new e.q({width:i||1,height:a||1});for(let r in t){let i=t[r];for(let t in i){let a=i[+t];if(!a||a.bitmap.width===0||a.bitmap.height===0)continue;let s=n[r][t].rect;e.q.copy(a.bitmap,o,{x:0,y:0},{x:s.x+1,y:s.y+1},a.bitmap)}}this.image=o,this.positions=n}}e.cG(`GlyphAtlas`,n);class r{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.uid=t.uid,this.zoom=t.zoom,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.inFlightDependencies=[],this.globalState=t.globalState}parse(t,r,a,o,s){return e._(this,void 0,void 0,(function*(){this.status=`parsing`,this.data=t,this.collisionBoxArray=new e.ap;let c=new e.cH(Object.keys(t.layers).sort()),l=new e.cI(this.tileID,this.promoteId);l.bucketLayerIDs=[];let u={},d={featureIndex:l,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:a,subdivisionGranularity:s},f=r.familiesBySource[this.source];for(let n in f){let r=t.layers[n];if(!r)continue;r.version===1&&e.w(`Vector tile source "${this.source}" layer "${n}" does not use vector tile spec v2 and therefore may have some rendering errors.`);let o=c.encode(n),s=[];for(let e=0;e<r.length;e++){let t=r.feature(e),i=l.getId(t,n);s.push({feature:t,id:i,index:e,sourceLayerIndex:o})}for(let t of f[n]){let n=t[0];n.source!==this.source&&e.w(`layer.source = ${n.source} does not equal this.source = ${this.source}`),n.minzoom&&this.zoom<Math.floor(n.minzoom)||n.maxzoom&&this.zoom>=n.maxzoom||n.visibility!==`none`&&(i(t,this.zoom,a,this.globalState),(u[n.id]=n.createBucket({index:l.bucketLayerIDs.length,layers:t,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:o,sourceID:this.source,globalState:this.globalState})).populate(s,d,this.tileID.canonical),l.bucketLayerIDs.push(t.map((e=>e.id))))}}let p=e.bN(d.glyphDependencies,(e=>Object.keys(e).map(Number)));this.inFlightDependencies.forEach((e=>e?.abort())),this.inFlightDependencies=[];let m=Promise.resolve({});if(Object.keys(p).length){let e=new AbortController;this.inFlightDependencies.push(e),m=o.sendAsync({type:`GG`,data:{stacks:p,source:this.source,tileID:this.tileID,type:`glyphs`}},e)}let h=Object.keys(d.iconDependencies),g=Promise.resolve({});if(h.length){let e=new AbortController;this.inFlightDependencies.push(e),g=o.sendAsync({type:`GI`,data:{icons:h,source:this.source,tileID:this.tileID,type:`icons`}},e)}let _=Object.keys(d.patternDependencies),v=Promise.resolve({});if(_.length){let e=new AbortController;this.inFlightDependencies.push(e),v=o.sendAsync({type:`GI`,data:{icons:_,source:this.source,tileID:this.tileID,type:`patterns`}},e)}let[y,b,x]=yield Promise.all([m,g,v]),S=new n(y),C=new e.cJ(b,x);for(let t in u){let n=u[t];n instanceof e.aq?(i(n.layers,this.zoom,a,this.globalState),e.cK({bucket:n,glyphMap:y,glyphPositions:S.positions,imageMap:b,imagePositions:C.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:d.subdivisionGranularity})):n.hasPattern&&(n instanceof e.cL||n instanceof e.cM||n instanceof e.cN)&&(i(n.layers,this.zoom,a,this.globalState),n.addFeatures(d,this.tileID.canonical,C.patternPositions))}return this.status=`done`,{buckets:Object.values(u).filter((e=>!e.isEmpty())),featureIndex:l,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:S.image,imageAtlas:C,glyphMap:this.returnDependencies?y:null,iconMap:this.returnDependencies?b:null,glyphPositions:this.returnDependencies?S.positions:null}}))}}function i(t,n,r,i){let a=new e.F(n,{globalState:i});for(let e of t)e.recalculate(a,r)}class a{constructor(e,t,n){this.actor=e,this.layerIndex=t,this.availableImages=n,this.fetching={},this.loading={},this.loaded={}}loadVectorTile(t,n){return e._(this,void 0,void 0,(function*(){let r=yield e.n(t.request,n);try{return{vectorTile:new e.cO(new e.cP(r.data)),rawData:r.data,cacheControl:r.cacheControl,expires:r.expires}}catch(e){let n=new Uint8Array(r.data),i=`Unable to parse the tile at ${t.request.url}, `;throw i+=n[0]===31&&n[1]===139?`please make sure the data is not gzipped and that you have configured the relevant header in the server`:`got error: ${e.message}`,Error(i)}}))}loadTile(t){return e._(this,void 0,void 0,(function*(){let n=t.uid,i=!!(t&&t.request&&t.request.collectResourceTiming)&&new e.cQ(t.request),a=new r(t);this.loading[n]=a;let o=new AbortController;a.abort=o;try{let r=yield this.loadVectorTile(t,o);if(delete this.loading[n],!r)return null;let s=r.rawData,c={};r.expires&&(c.expires=r.expires),r.cacheControl&&(c.cacheControl=r.cacheControl);let l={};if(i){let e=i.finish();e&&(l.resourceTiming=JSON.parse(JSON.stringify(e)))}a.vectorTile=r.vectorTile;let u=a.parse(r.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);this.loaded[n]=a,this.fetching[n]={rawTileData:s,cacheControl:c,resourceTiming:l};try{let t=yield u;return e.e({rawTileData:s.slice(0)},t,c,l)}finally{delete this.fetching[n]}}catch(e){throw delete this.loading[n],a.status=`done`,this.loaded[n]=a,e}}))}reloadTile(t){return e._(this,void 0,void 0,(function*(){let n=t.uid;if(!this.loaded||!this.loaded[n])throw Error(`Should not be trying to reload a tile that was never loaded or has been removed`);let r=this.loaded[n];if(r.showCollisionBoxes=t.showCollisionBoxes,r.globalState=t.globalState,r.status===`parsing`){let i=yield r.parse(r.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity),a;if(this.fetching[n]){let{rawTileData:t,cacheControl:r,resourceTiming:o}=this.fetching[n];delete this.fetching[n],a=e.e({rawTileData:t.slice(0)},i,r,o)}else a=i;return a}if(r.status===`done`&&r.vectorTile)return r.parse(r.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity)}))}abortTile(t){return e._(this,void 0,void 0,(function*(){let e=this.loading,n=t.uid;e&&e[n]&&e[n].abort&&(e[n].abort.abort(),delete e[n])}))}removeTile(t){return e._(this,void 0,void 0,(function*(){this.loaded&&this.loaded[t.uid]&&delete this.loaded[t.uid]}))}}class o{constructor(){this.loaded={}}loadTile(t){return e._(this,void 0,void 0,(function*(){let{uid:n,encoding:r,rawImageData:i,redFactor:a,greenFactor:o,blueFactor:s,baseShift:c}=t,l=i.width+2,u=i.height+2,d=e.b(i)?new e.R({width:l,height:u},yield e.cR(i,-1,-1,l,u)):i,f=new e.cS(n,d,r,a,o,s,c);return this.loaded=this.loaded||{},this.loaded[n]=f,f}))}removeTile(e){let t=this.loaded,n=e.uid;t&&t[n]&&delete t[n]}}var s,c,l=function(){if(c)return s;function e(e,n){if(e.length!==0){t(e[0],n);for(var r=1;r<e.length;r++)t(e[r],!n)}}function t(e,t){for(var n=0,r=0,i=0,a=e.length,o=a-1;i<a;o=i++){var s=(e[i][0]-e[o][0])*(e[o][1]+e[i][1]),c=n+s;r+=Math.abs(n)>=Math.abs(s)?n-c+s:s-c+n,n=c}n+r>=0!=!!t&&e.reverse()}return c=1,s=function t(n,r){var i,a=n&&n.type;if(a===`FeatureCollection`)for(i=0;i<n.features.length;i++)t(n.features[i],r);else if(a===`GeometryCollection`)for(i=0;i<n.geometries.length;i++)t(n.geometries[i],r);else if(a===`Feature`)t(n.geometry,r);else if(a===`Polygon`)e(n.coordinates,r);else if(a===`MultiPolygon`)for(i=0;i<n.coordinates.length;i++)e(n.coordinates[i],r);return n}}(),u=e.cT(l);class d extends e.cV{constructor(t,n){super(new e.cP,0,n,[],[]),this.feature=t,this.type=t.type,this.properties=t.tags?t.tags:{},`id`in t&&(typeof t.id==`string`?this.id=parseInt(t.id,10):typeof t.id!=`number`||isNaN(t.id)||(this.id=t.id))}loadGeometry(){let t=[],n=this.feature.type===1?[this.feature.geometry]:this.feature.geometry;for(let r of n){let n=[];for(let t of r)n.push(new e.P(t[0],t[1]));t.push(n)}return t}}class f extends e.cU{constructor(t,n){super(new e.cP),this.layers={_geojsonTileLayer:this},this.name=`_geojsonTileLayer`,this.version=n?n.version:1,this.extent=n?n.extent:4096,this.length=t.length,this.features=t}feature(e){return new d(this.features[e],this.extent)}}function p(e,t){t.writeVarintField(15,e.version||1),t.writeStringField(1,e.name||``),t.writeVarintField(5,e.extent||4096);let n={keys:[],values:[],keycache:{},valuecache:{}};for(let r=0;r<e.length;r++)n.feature=e.feature(r),t.writeMessage(2,m,n);let r=n.keys;for(let e of r)t.writeStringField(3,e);let i=n.values;for(let e of i)t.writeMessage(4,y,e)}function m(e,t){if(!e.feature)return;let n=e.feature;n.id!==void 0&&t.writeVarintField(1,n.id),t.writeMessage(2,h,e),t.writeVarintField(3,n.type),t.writeMessage(4,v,n)}function h(e,t){for(let n in e.feature?.properties){let r=e.feature.properties[n],i=e.keycache[n];if(r===null)continue;i===void 0&&(e.keys.push(n),i=e.keys.length-1,e.keycache[n]=i),t.writeVarint(i),typeof r!=`string`&&typeof r!=`boolean`&&typeof r!=`number`&&(r=JSON.stringify(r));let a=typeof r+`:`+r,o=e.valuecache[a];o===void 0&&(e.values.push(r),o=e.values.length-1,e.valuecache[a]=o),t.writeVarint(o)}}function g(e,t){return(t<<3)+(7&e)}function _(e){return e<<1^e>>31}function v(e,t){let n=e.loadGeometry(),r=e.type,i=0,a=0;for(let o of n){let n=1;r===1&&(n=o.length),t.writeVarint(g(1,n));let s=r===3?o.length-1:o.length;for(let e=0;e<s;e++){e===1&&r!==1&&t.writeVarint(g(2,s-1));let n=o[e].x-i,c=o[e].y-a;t.writeVarint(_(n)),t.writeVarint(_(c)),i+=n,a+=c}e.type===3&&t.writeVarint(g(7,1))}}function y(e,t){let n=typeof e;n===`string`?t.writeStringField(1,e):n===`boolean`?t.writeBooleanField(7,e):n===`number`&&(e%1==0?e<0?t.writeSVarintField(6,e):t.writeVarintField(5,e):t.writeDoubleField(3,e))}let b={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e},x=Math.fround||(S=new Float32Array(1),e=>(S[0]=+e,S[0]));var S;class C{constructor(e){this.options=Object.assign(Object.create(b),e),this.trees=Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){let{log:t,minZoom:n,maxZoom:r}=this.options;t&&console.time(`total time`);let i=`prepare ${e.length} points`;t&&console.time(i),this.points=e;let a=[];for(let t=0;t<e.length;t++){let n=e[t];if(!n.geometry)continue;let[r,i]=n.geometry.coordinates,o=x(E(r)),s=x(D(i));a.push(o,s,1/0,t,-1,1),this.options.reduce&&a.push(0)}let o=this.trees[r+1]=this._createTree(a);t&&console.timeEnd(i);for(let e=r;e>=n;e--){let n=+Date.now();o=this.trees[e]=this._createTree(this._cluster(o,e)),t&&console.log(`z%d: %d clusters in %dms`,e,o.numItems,+Date.now()-n)}return t&&console.timeEnd(`total time`),this}getClusters(e,t){let n=((e[0]+180)%360+360)%360-180,r=Math.max(-90,Math.min(90,e[1])),i=e[2]===180?180:((e[2]+180)%360+360)%360-180,a=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)n=-180,i=180;else if(n>i){let e=this.getClusters([n,r,180,a],t),o=this.getClusters([-180,r,i,a],t);return e.concat(o)}let o=this.trees[this._limitZoom(t)],s=o.range(E(n),D(a),E(i),D(r)),c=o.data,l=[];for(let e of s){let t=this.stride*e;l.push(c[t+5]>1?w(c,t,this.clusterProps):this.points[c[t+3]])}return l}getChildren(e){let t=this._getOriginId(e),n=this._getOriginZoom(e),r=`No cluster with the specified id.`,i=this.trees[n];if(!i)throw Error(r);let a=i.data;if(t*this.stride>=a.length)throw Error(r);let o=this.options.radius/(this.options.extent*2**(n-1)),s=i.within(a[t*this.stride],a[t*this.stride+1],o),c=[];for(let t of s){let n=t*this.stride;a[n+4]===e&&c.push(a[n+5]>1?w(a,n,this.clusterProps):this.points[a[n+3]])}if(c.length===0)throw Error(r);return c}getLeaves(e,t,n){let r=[];return this._appendLeaves(r,e,t||=10,n||=0,0),r}getTile(e,t,n){let r=this.trees[this._limitZoom(e)],i=2**e,{extent:a,radius:o}=this.options,s=o/a,c=(n-s)/i,l=(n+1+s)/i,u={features:[]};return this._addTileFeatures(r.range((t-s)/i,c,(t+1+s)/i,l),r.data,t,n,i,u),t===0&&this._addTileFeatures(r.range(1-s/i,c,1,l),r.data,i,n,i,u),t===i-1&&this._addTileFeatures(r.range(0,c,s/i,l),r.data,-1,n,i,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){let n=this.getChildren(e);if(t++,n.length!==1)break;e=n[0].properties.cluster_id}return t}_appendLeaves(e,t,n,r,i){let a=this.getChildren(t);for(let t of a){let a=t.properties;if(a&&a.cluster?i+a.point_count<=r?i+=a.point_count:i=this._appendLeaves(e,a.cluster_id,n,r,i):i<r?i++:e.push(t),e.length===n)break}return i}_createTree(t){let n=new e.aI(t.length/this.stride|0,this.options.nodeSize,Float32Array);for(let e=0;e<t.length;e+=this.stride)n.add(t[e],t[e+1]);return n.finish(),n.data=t,n}_addTileFeatures(e,t,n,r,i,a){for(let o of e){let e=o*this.stride,s=t[e+5]>1,c,l,u;if(s)c=T(t,e,this.clusterProps),l=t[e],u=t[e+1];else{let n=this.points[t[e+3]];c=n.properties;let[r,i]=n.geometry.coordinates;l=E(r),u=D(i)}let d={type:1,geometry:[[Math.round(this.options.extent*(l*i-n)),Math.round(this.options.extent*(u*i-r))]],tags:c},f;f=s||this.options.generateId?t[e+3]:this.points[t[e+3]].id,f!==void 0&&(d.id=f),a.features.push(d)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){let{radius:n,extent:r,reduce:i,minPoints:a}=this.options,o=n/(r*2**t),s=e.data,c=[],l=this.stride;for(let n=0;n<s.length;n+=l){if(s[n+2]<=t)continue;s[n+2]=t;let r=s[n],u=s[n+1],d=e.within(s[n],s[n+1],o),f=s[n+5],p=f;for(let e of d){let n=e*l;s[n+2]>t&&(p+=s[n+5])}if(p>f&&p>=a){let e,a=r*f,o=u*f,m=-1,h=(n/l<<5)+(t+1)+this.points.length;for(let r of d){let c=r*l;if(s[c+2]<=t)continue;s[c+2]=t;let u=s[c+5];a+=s[c]*u,o+=s[c+1]*u,s[c+4]=h,i&&(e||(e=this._map(s,n,!0),m=this.clusterProps.length,this.clusterProps.push(e)),i(e,this._map(s,c)))}s[n+4]=h,c.push(a/p,o/p,1/0,h,-1,p),i&&c.push(m)}else{for(let e=0;e<l;e++)c.push(s[n+e]);if(p>1)for(let e of d){let n=e*l;if(!(s[n+2]<=t)){s[n+2]=t;for(let e=0;e<l;e++)c.push(s[n+e])}}}}return c}_getOriginId(e){return e-this.points.length>>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t,n){if(e[t+5]>1){let r=this.clusterProps[e[t+6]];return n?Object.assign({},r):r}let r=this.points[e[t+3]].properties,i=this.options.map(r);return n&&i===r?Object.assign({},i):i}}function w(e,t,n){return{type:`Feature`,id:e[t+3],properties:T(e,t,n),geometry:{type:`Point`,coordinates:[(r=e[t],360*(r-.5)),O(e[t+1])]}};var r}function T(e,t,n){let r=e[t+5],i=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+`k`:r,a=e[t+6],o=a===-1?{}:Object.assign({},n[a]);return Object.assign(o,{cluster:!0,cluster_id:e[t+3],point_count:r,point_count_abbreviated:i})}function E(e){return e/360+.5}function D(e){let t=Math.sin(e*Math.PI/180),n=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return n<0?0:n>1?1:n}function O(e){let t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function k(e,t,n,r){let i=r,a=t+(n-t>>1),o,s=n-t,c=e[t],l=e[t+1],u=e[n],d=e[n+1];for(let r=t+3;r<n;r+=3){let t=A(e[r],e[r+1],c,l,u,d);if(t>i)o=r,i=t;else if(t===i){let e=Math.abs(r-a);e<s&&(o=r,s=e)}}i>r&&(o-t>3&&k(e,t,o,r),e[o+2]=i,n-o>3&&k(e,o,n,r))}function A(e,t,n,r,i,a){let o=i-n,s=a-r;if(o!==0||s!==0){let c=((e-n)*o+(t-r)*s)/(o*o+s*s);c>1?(n=i,r=a):c>0&&(n+=o*c,r+=s*c)}return o=e-n,s=t-r,o*o+s*s}function j(e,t,n,r){let i={id:e??null,type:t,geometry:n,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(t===`Point`||t===`MultiPoint`||t===`LineString`)M(i,n);else if(t===`Polygon`)M(i,n[0]);else if(t===`MultiLineString`)for(let e of n)M(i,e);else if(t===`MultiPolygon`)for(let e of n)M(i,e[0]);return i}function M(e,t){for(let n=0;n<t.length;n+=3)e.minX=Math.min(e.minX,t[n]),e.minY=Math.min(e.minY,t[n+1]),e.maxX=Math.max(e.maxX,t[n]),e.maxY=Math.max(e.maxY,t[n+1])}function N(e,t,n,r){if(!t.geometry)return;let i=t.geometry.coordinates;if(i&&i.length===0)return;let a=t.geometry.type,o=(n.tolerance/((1<<n.maxZoom)*n.extent))**2,s=[],c=t.id;if(n.promoteId?c=t.properties[n.promoteId]:n.generateId&&(c=r||0),a===`Point`)P(i,s);else if(a===`MultiPoint`)for(let e of i)P(e,s);else if(a===`LineString`)ee(i,s,o,!1);else if(a===`MultiLineString`){if(n.lineMetrics){for(let n of i)s=[],ee(n,s,o,!1),e.push(j(c,`LineString`,s,t.properties));return}te(i,s,o,!1)}else if(a===`Polygon`)te(i,s,o,!0);else{if(a!==`MultiPolygon`){if(a===`GeometryCollection`){for(let i of t.geometry.geometries)N(e,{id:c,geometry:i,properties:t.properties},n,r);return}throw Error(`Input data is not a valid GeoJSON object.`)}for(let e of i){let t=[];te(e,t,o,!0),s.push(t)}}e.push(j(c,a,s,t.properties))}function P(e,t){t.push(F(e[0]),ne(e[1]),0)}function ee(e,t,n,r){let i,a,o=0;for(let n=0;n<e.length;n++){let s=F(e[n][0]),c=ne(e[n][1]);t.push(s,c,0),n>0&&(o+=r?(i*c-s*a)/2:Math.sqrt((s-i)**2+(c-a)**2)),i=s,a=c}let s=t.length-3;t[2]=1,k(t,0,s,n),t[s+2]=1,t.size=Math.abs(o),t.start=0,t.end=t.size}function te(e,t,n,r){for(let i=0;i<e.length;i++){let a=[];ee(e[i],a,n,r),t.push(a)}}function F(e){return e/360+.5}function ne(e){let t=Math.sin(e*Math.PI/180),n=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return n<0?0:n>1?1:n}function re(e,t,n,r,i,a,o,s){if(r/=t,a>=(n/=t)&&o<r)return e;if(o<n||a>=r)return null;let c=[];for(let t of e){let e=t.geometry,a=t.type,o=i===0?t.minX:t.minY,l=i===0?t.maxX:t.maxY;if(o>=n&&l<r){c.push(t);continue}if(l<n||o>=r)continue;let u=[];if(a===`Point`||a===`MultiPoint`)ie(e,u,n,r,i);else if(a===`LineString`)ae(e,u,n,r,i,!1,s.lineMetrics);else if(a===`MultiLineString`)se(e,u,n,r,i,!1);else if(a===`Polygon`)se(e,u,n,r,i,!0);else if(a===`MultiPolygon`)for(let t of e){let e=[];se(t,e,n,r,i,!0),e.length&&u.push(e)}if(u.length){if(s.lineMetrics&&a===`LineString`){for(let e of u)c.push(j(t.id,a,e,t.tags));continue}a!==`LineString`&&a!==`MultiLineString`||(u.length===1?(a=`LineString`,u=u[0]):a=`MultiLineString`),a!==`Point`&&a!==`MultiPoint`||(a=u.length===3?`Point`:`MultiPoint`),c.push(j(t.id,a,u,t.tags))}}return c.length?c:null}function ie(e,t,n,r,i){for(let a=0;a<e.length;a+=3){let o=e[a+i];o>=n&&o<=r&&ce(t,e[a],e[a+1],e[a+2])}}function ae(e,t,n,r,i,a,o){let s=oe(e),c=i===0?le:ue,l,u,d=e.start;for(let f=0;f<e.length-3;f+=3){let p=e[f],m=e[f+1],h=e[f+2],g=e[f+3],_=e[f+4],v=i===0?p:m,y=i===0?g:_,b=!1;o&&(l=Math.sqrt((p-g)**2+(m-_)**2)),v<n?y>n&&(u=c(s,p,m,g,_,n),o&&(s.start=d+l*u)):v>r?y<r&&(u=c(s,p,m,g,_,r),o&&(s.start=d+l*u)):ce(s,p,m,h),y<n&&v>=n&&(u=c(s,p,m,g,_,n),b=!0),y>r&&v<=r&&(u=c(s,p,m,g,_,r),b=!0),!a&&b&&(o&&(s.end=d+l*u),t.push(s),s=oe(e)),o&&(d+=l)}let f=e.length-3,p=e[f],m=e[f+1],h=i===0?p:m;h>=n&&h<=r&&ce(s,p,m,e[f+2]),f=s.length-3,a&&f>=3&&(s[f]!==s[0]||s[f+1]!==s[1])&&ce(s,s[0],s[1],s[2]),s.length&&t.push(s)}function oe(e){let t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function se(e,t,n,r,i,a){for(let o of e)ae(o,t,n,r,i,a,!1)}function ce(e,t,n,r){e.push(t,n,r)}function le(e,t,n,r,i,a){let o=(a-t)/(r-t);return ce(e,a,n+(i-n)*o,1),o}function ue(e,t,n,r,i,a){let o=(a-n)/(i-n);return ce(e,t+(r-t)*o,a,1),o}function de(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=i.type,o;if(a===`Point`||a===`MultiPoint`||a===`LineString`)o=fe(i.geometry,t);else if(a===`MultiLineString`||a===`Polygon`){o=[];for(let e of i.geometry)o.push(fe(e,t))}else if(a===`MultiPolygon`){o=[];for(let e of i.geometry){let n=[];for(let r of e)n.push(fe(r,t));o.push(n)}}n.push(j(i.id,a,o,i.tags))}return n}function fe(e,t){let n=[];n.size=e.size,e.start!==void 0&&(n.start=e.start,n.end=e.end);for(let r=0;r<e.length;r+=3)n.push(e[r]+t,e[r+1],e[r+2]);return n}function pe(e,t){if(e.transformed)return e;let n=1<<e.z,r=e.x,i=e.y;for(let a of e.features){let e=a.geometry,o=a.type;if(a.geometry=[],o===1)for(let o=0;o<e.length;o+=2)a.geometry.push(me(e[o],e[o+1],t,n,r,i));else for(let o=0;o<e.length;o++){let s=[];for(let a=0;a<e[o].length;a+=2)s.push(me(e[o][a],e[o][a+1],t,n,r,i));a.geometry.push(s)}}return e.transformed=!0,e}function me(e,t,n,r,i,a){return[Math.round(n*(e*r-i)),Math.round(n*(t*r-a))]}function he(e,t,n,r,i){let a=t===i.maxZoom?0:i.tolerance/((1<<t)*i.extent),o={features:[],numPoints:0,numSimplified:0,numFeatures:e.length,source:null,x:n,y:r,z:t,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(let t of e)ge(o,t,a,i);return o}function ge(e,t,n,r){let i=t.geometry,a=t.type,o=[];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),a===`Point`||a===`MultiPoint`)for(let t=0;t<i.length;t+=3)o.push(i[t],i[t+1]),e.numPoints++,e.numSimplified++;else if(a===`LineString`)_e(o,i,e,n,!1,!1);else if(a===`MultiLineString`||a===`Polygon`)for(let t=0;t<i.length;t++)_e(o,i[t],e,n,a===`Polygon`,t===0);else if(a===`MultiPolygon`)for(let t=0;t<i.length;t++){let r=i[t];for(let t=0;t<r.length;t++)_e(o,r[t],e,n,!0,t===0)}if(o.length){let n=t.tags||null;if(a===`LineString`&&r.lineMetrics){n={};for(let e in t.tags)n[e]=t.tags[e];n.mapbox_clip_start=i.start/i.size,n.mapbox_clip_end=i.end/i.size}let s={geometry:o,type:a===`Polygon`||a===`MultiPolygon`?3:a===`LineString`||a===`MultiLineString`?2:1,tags:n};t.id!==null&&(s.id=t.id),e.features.push(s)}}function _e(e,t,n,r,i,a){let o=r*r;if(r>0&&t.size<(i?o:r))return void(n.numPoints+=t.length/3);let s=[];for(let e=0;e<t.length;e+=3)(r===0||t[e+2]>o)&&(n.numSimplified++,s.push(t[e],t[e+1])),n.numPoints++;i&&function(e,t){let n=0;for(let t=0,r=e.length,i=r-2;t<r;i=t,t+=2)n+=(e[t]-e[i])*(e[t+1]+e[i+1]);if(n>0===t)for(let t=0,n=e.length;t<n/2;t+=2){let r=e[t],i=e[t+1];e[t]=e[n-2-t],e[t+1]=e[n-1-t],e[n-2-t]=r,e[n-1-t]=i}}(s,a),e.push(s)}let ve={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0};class ye{constructor(e,t){let n=(t=this.options=function(e,t){for(let n in t)e[n]=t[n];return e}(Object.create(ve),t)).debug;if(n&&console.time(`preprocess data`),t.maxZoom<0||t.maxZoom>24)throw Error(`maxZoom should be in the 0-24 range`);if(t.promoteId&&t.generateId)throw Error(`promoteId and generateId cannot be used together.`);let r=function(e,t){let n=[];if(e.type===`FeatureCollection`)for(let r=0;r<e.features.length;r++)N(n,e.features[r],t,r);else N(n,e.type===`Feature`?e:{geometry:e},t);return n}(e,t);this.tiles={},this.tileCoords=[],n&&(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){let n=t.buffer/t.extent,r=e,i=re(e,1,-1-n,n,0,-1,2,t),a=re(e,1,1-n,2+n,0,-1,2,t);return(i||a)&&(r=re(e,1,-n,1+n,0,-1,2,t)||[],i&&(r=de(i,1).concat(r)),a&&(r=r.concat(de(a,-1)))),r}(r,t),r.length&&this.splitTile(r,0,0,0),n&&(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,n,r,i,a,o){let s=[e,t,n,r],c=this.options,l=c.debug;for(;s.length;){r=s.pop(),n=s.pop(),t=s.pop(),e=s.pop();let u=1<<t,d=be(t,n,r),f=this.tiles[d];if(!f&&(l>1&&console.time(`creation`),f=this.tiles[d]=he(e,t,n,r,c),this.tileCoords.push({z:t,x:n,y:r}),l)){l>1&&(console.log(`tile z%d-%d-%d (features: %d, points: %d, simplified: %d)`,t,n,r,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd(`creation`));let e=`z${t}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}if(f.source=e,i==null){if(t===c.indexMaxZoom||f.numPoints<=c.indexMaxPoints)continue}else{if(t===c.maxZoom||t===i)continue;if(i!=null){let e=i-t;if(n!==a>>e||r!==o>>e)continue}}if(f.source=null,e.length===0)continue;l>1&&console.time(`clipping`);let p=.5*c.buffer/c.extent,m=.5-p,h=.5+p,g=1+p,_=null,v=null,y=null,b=null,x=re(e,u,n-p,n+h,0,f.minX,f.maxX,c),S=re(e,u,n+m,n+g,0,f.minX,f.maxX,c);e=null,x&&=(_=re(x,u,r-p,r+h,1,f.minY,f.maxY,c),v=re(x,u,r+m,r+g,1,f.minY,f.maxY,c),null),S&&=(y=re(S,u,r-p,r+h,1,f.minY,f.maxY,c),b=re(S,u,r+m,r+g,1,f.minY,f.maxY,c),null),l>1&&console.timeEnd(`clipping`),s.push(_||[],t+1,2*n,2*r),s.push(v||[],t+1,2*n,2*r+1),s.push(y||[],t+1,2*n+1,2*r),s.push(b||[],t+1,2*n+1,2*r+1)}}getTile(e,t,n){e=+e,t=+t,n=+n;let{extent:r,debug:i}=this.options;if(e<0||e>24)return null;let a=1<<e,o=be(e,t=t+a&a-1,n);if(this.tiles[o])return pe(this.tiles[o],r);i>1&&console.log(`drilling down to z%d-%d-%d`,e,t,n);let s,c=e,l=t,u=n;for(;!s&&c>0;)c--,l>>=1,u>>=1,s=this.tiles[be(c,l,u)];return s&&s.source?(i>1&&(console.log(`found parent tile z%d-%d-%d`,c,l,u),console.time(`drilling down`)),this.splitTile(s.source,c,l,u,e,t,n),i>1&&console.timeEnd(`drilling down`),this.tiles[o]?pe(this.tiles[o],r):null):null}}function be(e,t,n){return 32*((1<<e)*n+t)+e}class xe extends a{constructor(){super(...arguments),this._dataUpdateable=new Map}loadVectorTile(t,n){return e._(this,void 0,void 0,(function*(){let n=t.tileID.canonical;if(!this._geoJSONIndex)throw Error(`Unable to parse the data into a cluster or geojson`);let r=this._geoJSONIndex.getTile(n.z,n.x,n.y);if(!r)return null;let i=new f(r.features,{version:2,extent:e.ah}),a=function(t){let n=new e.cP;return function(e,t){for(let n in e.layers)t.writeMessage(3,p,e.layers[n])}(t,n),n.finish()}(i);return a.byteOffset===0&&a.byteLength===a.buffer.byteLength||(a=new Uint8Array(a)),{vectorTile:i,rawData:a.buffer}}))}loadData(t){return e._(this,void 0,void 0,(function*(){var n;(n=this._pendingRequest)==null||n.abort();let r=!!(t&&t.request&&t.request.collectResourceTiming)&&new e.cQ(t.request);this._pendingRequest=new AbortController;try{this._pendingData=this.loadAndProcessGeoJSON(t,this._pendingRequest);let n=yield this._pendingData;this._geoJSONIndex=t.cluster?new C(function({superclusterOptions:t,clusterProperties:n}){if(!n||!t)return t;let r={},i={},a={accumulated:null,zoom:0},o={properties:null},s=Object.keys(n);for(let t of s){let[a,o]=n[t],s=e.cE(o),c=e.cE(typeof a==`string`?[a,[`accumulated`],[`get`,t]]:a);r[t]=s.value,i[t]=c.value}return t.map=e=>{o.properties=e;let t={};for(let e of s)t[e]=r[e].evaluate(a,o);return t},t.reduce=(e,t)=>{o.properties=t;for(let t of s)a.accumulated=e[t],e[t]=i[t].evaluate(a,o)},t}(t)).load(n.features):function(e,t){return new ye(e,t)}(n,t.geojsonVtOptions),this.loaded={};let i={data:n};if(r){let e=r.finish();e&&(i.resourceTiming={},i.resourceTiming[t.source]=JSON.parse(JSON.stringify(e)))}return i}catch(t){if(delete this._pendingRequest,e.cz(t))return{abandoned:!0};throw t}}))}getData(){return e._(this,void 0,void 0,(function*(){return this._pendingData}))}reloadTile(e){let t=this.loaded;return t&&t[e.uid]?super.reloadTile(e):this.loadTile(e)}loadAndProcessGeoJSON(t,n){return e._(this,void 0,void 0,(function*(){let r=yield this.loadGeoJSON(t,n);if(delete this._pendingRequest,typeof r!=`object`)throw Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`);if(u(r,!0),t.filter){let n=e.cE(t.filter,{type:`boolean`,"property-type":`data-driven`,overridable:!1,transition:!1});if(n.result===`error`)throw Error(n.value.map((e=>`${e.key}: ${e.message}`)).join(`, `));r={type:`FeatureCollection`,features:r.features.filter((e=>n.value.evaluate({zoom:0},e)))}}return r}))}loadGeoJSON(t,n){return e._(this,void 0,void 0,(function*(){let{promoteId:r}=t;if(t.request){let i=yield e.j(t.request,n);return this._dataUpdateable=e.cX(i.data,r)?e.cW(i.data,r):void 0,i.data}if(typeof t.data==`string`)try{let n=JSON.parse(t.data);return this._dataUpdateable=e.cX(n,r)?e.cW(n,r):void 0,n}catch{throw Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`)}if(!t.dataDiff)throw Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw Error(`Cannot update existing geojson data in ${t.source}`);return e.cY(this._dataUpdateable,t.dataDiff,r),{type:`FeatureCollection`,features:Array.from(this._dataUpdateable.values())}}))}removeSource(t){return e._(this,void 0,void 0,(function*(){this._pendingRequest&&this._pendingRequest.abort()}))}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset)}}class Se{constructor(t){this.self=t,this.actor=new e.J(t),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(e,t)=>{if(this.externalWorkerSourceTypes[e])throw Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=t},this.self.addProtocol=e.cC,this.self.removeProtocol=e.cD,this.self.registerRTLTextPlugin=t=>{e.cZ.setMethods(t)},this.actor.registerMessageHandler(`LDT`,((e,t)=>this._getDEMWorkerSource(e,t.source).loadTile(t))),this.actor.registerMessageHandler(`RDT`,((t,n)=>e._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(t,n.source).removeTile(n)})))),this.actor.registerMessageHandler(`GCEZ`,((t,n)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,n.type,n.source).getClusterExpansionZoom(n)})))),this.actor.registerMessageHandler(`GCC`,((t,n)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,n.type,n.source).getClusterChildren(n)})))),this.actor.registerMessageHandler(`GCL`,((t,n)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,n.type,n.source).getClusterLeaves(n)})))),this.actor.registerMessageHandler(`LD`,((e,t)=>this._getWorkerSource(e,t.type,t.source).loadData(t))),this.actor.registerMessageHandler(`GD`,((e,t)=>this._getWorkerSource(e,t.type,t.source).getData())),this.actor.registerMessageHandler(`LT`,((e,t)=>this._getWorkerSource(e,t.type,t.source).loadTile(t))),this.actor.registerMessageHandler(`RT`,((e,t)=>this._getWorkerSource(e,t.type,t.source).reloadTile(t))),this.actor.registerMessageHandler(`AT`,((e,t)=>this._getWorkerSource(e,t.type,t.source).abortTile(t))),this.actor.registerMessageHandler(`RMT`,((e,t)=>this._getWorkerSource(e,t.type,t.source).removeTile(t))),this.actor.registerMessageHandler(`RS`,((t,n)=>e._(this,void 0,void 0,(function*(){if(!this.workerSources[t]||!this.workerSources[t][n.type]||!this.workerSources[t][n.type][n.source])return;let e=this.workerSources[t][n.type][n.source];delete this.workerSources[t][n.type][n.source],e.removeSource!==void 0&&e.removeSource(n)})))),this.actor.registerMessageHandler(`RM`,(t=>e._(this,void 0,void 0,(function*(){delete this.layerIndexes[t],delete this.availableImages[t],delete this.workerSources[t],delete this.demWorkerSources[t]})))),this.actor.registerMessageHandler(`SR`,((t,n)=>e._(this,void 0,void 0,(function*(){this.referrer=n})))),this.actor.registerMessageHandler(`SRPS`,((e,t)=>this._syncRTLPluginState(e,t))),this.actor.registerMessageHandler(`IS`,((t,n)=>e._(this,void 0,void 0,(function*(){this.self.importScripts(n)})))),this.actor.registerMessageHandler(`SI`,((e,t)=>this._setImages(e,t))),this.actor.registerMessageHandler(`UL`,((t,n)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(t).update(n.layers,n.removedIds)})))),this.actor.registerMessageHandler(`SL`,((t,n)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(t).replace(n)}))))}_setImages(t,n){return e._(this,void 0,void 0,(function*(){this.availableImages[t]=n;for(let e in this.workerSources[t]){let r=this.workerSources[t][e];for(let e in r)r[e].availableImages=n}}))}_syncRTLPluginState(t,n){return e._(this,void 0,void 0,(function*(){return yield e.cZ.syncState(n,this.self.importScripts)}))}_getAvailableImages(e){let t=this.availableImages[e];return t||=[],t}_getLayerIndex(e){let n=this.layerIndexes[e];return n||=this.layerIndexes[e]=new t,n}_getWorkerSource(e,t,n){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][t]||(this.workerSources[e][t]={}),!this.workerSources[e][t][n]){let r={sendAsync:(t,n)=>(t.targetMapId=e,this.actor.sendAsync(t,n))};switch(t){case`vector`:this.workerSources[e][t][n]=new a(r,this._getLayerIndex(e),this._getAvailableImages(e));break;case`geojson`:this.workerSources[e][t][n]=new xe(r,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][t][n]=new this.externalWorkerSourceTypes[t](r,this._getLayerIndex(e),this._getAvailableImages(e))}}return this.workerSources[e][t][n]}_getDEMWorkerSource(e,t){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][t]||(this.demWorkerSources[e][t]=new o),this.demWorkerSources[e][t]}}return e.i(self)&&(self.worker=new Se(self)),Se})),n(`index`,[`exports`,`./shared`],(function(e,t){var n=`5.7.0-mc.5`;function r(){var e=new t.A(4);return t.A!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let i,a,o={now:typeof performance<`u`&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frame(e,n,r){let i=requestAnimationFrame((e=>{a(),n(e)})),{unsubscribe:a}=t.s(e.signal,`abort`,(()=>{a(),cancelAnimationFrame(i),r(t.c())}),!1)},frameAsync(e){return new Promise(((t,n)=>{this.frame(e,t,n)}))},getImageData(e,t=0){return this.getImageCanvasContext(e).getImageData(-t,-t,e.width+2*t,e.height+2*t)},getImageCanvasContext(e){let t=window.document.createElement(`canvas`),n=t.getContext(`2d`,{willReadFrequently:!0});if(!n)throw Error(`failed to create canvas 2d context`);return t.width=e.width,t.height=e.height,n.drawImage(e,0,0,e.width,e.height),n},resolveURL:e=>(i||=document.createElement(`a`),i.href=e,i.href),hardwareConcurrency:typeof navigator<`u`&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(a??=matchMedia(`(prefers-reduced-motion: reduce)`),a.matches)}};class s{static testProp(e){if(!s.docStyle)return e[0];for(let t=0;t<e.length;t++)if(e[t]in s.docStyle)return e[t];return e[0]}static create(e,t,n){let r=window.document.createElement(e);return t!==void 0&&(r.className=t),n&&n.appendChild(r),r}static createNS(e,t){return window.document.createElementNS(e,t)}static disableDrag(){s.docStyle&&s.selectProp&&(s.userSelect=s.docStyle[s.selectProp],s.docStyle[s.selectProp]=`none`)}static enableDrag(){s.docStyle&&s.selectProp&&(s.docStyle[s.selectProp]=s.userSelect)}static setTransform(e,t){e.style[s.transformProp]=t}static addEventListener(e,t,n,r={}){e.addEventListener(t,n,`passive`in r?r:r.capture)}static removeEventListener(e,t,n,r={}){e.removeEventListener(t,n,`passive`in r?r:r.capture)}static suppressClickInternal(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener(`click`,s.suppressClickInternal,!0)}static suppressClick(){window.addEventListener(`click`,s.suppressClickInternal,!0),window.setTimeout((()=>{window.removeEventListener(`click`,s.suppressClickInternal,!0)}),0)}static getScale(e,t){let n=e.getBoundingClientRect();return{x:(n.width/e.offsetWidth||1)*t,y:(n.height/e.offsetHeight||1)*t,boundingClientRect:n}}static getPoint(e,n,r){let i=n.boundingClientRect;return new t.P((r.clientX-i.left)/n.x-e.clientLeft,(r.clientY-i.top)/n.y-e.clientTop)}static mousePos(e,t,n){let r=s.getScale(e,n);return s.getPoint(e,r,t)}static touchPos(e,t,n){let r=[],i=s.getScale(e,n);for(let n=0;n<t.length;n++)r.push(s.getPoint(e,i,t[n]));return r}static mouseButton(e){return e.button}static remove(e){e.parentNode&&e.parentNode.removeChild(e)}static sanitize(e){let t=new DOMParser().parseFromString(e,`text/html`).body||document.createElement(`body`),n=t.querySelectorAll(`script`);for(let e of n)e.remove();return s.clean(t),t.innerHTML}static isPossiblyDangerous(e,t){let n=t.replace(/\s+/g,``).toLowerCase();return!(![`src`,`href`,`xlink:href`].includes(e)||!n.includes(`javascript:`)&&!n.includes(`data:`))||!!e.startsWith(`on`)||void 0}static clean(e){let t=e.children;for(let e of t)s.removeAttributes(e),s.clean(e)}static removeAttributes(e){for(let{name:t,value:n}of e.attributes)s.isPossiblyDangerous(t,n)&&e.removeAttribute(t)}}s.docStyle=typeof window<`u`&&window.document&&window.document.documentElement.style,s.selectProp=s.testProp([`userSelect`,`MozUserSelect`,`WebkitUserSelect`,`msUserSelect`]),s.transformProp=s.testProp([`transform`,`WebkitTransform`]);let c={supported:!1,testSupport:function(e){!d&&u&&(f?p(e):l=e)}},l,u,d=!1,f=!1;function p(e){let t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t);try{if(e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,u),e.isContextLost())return;c.supported=!0}catch{}e.deleteTexture(t),d=!0}var m;typeof document<`u`&&(u=document.createElement(`img`),u.onload=()=>{l&&p(l),l=null,f=!0},u.onerror=()=>{d=!0,l=null},u.src=`data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=`),function(e){let n,r,i,a;e.resetRequestQueue=()=>{n=[],r=0,i=0,a={}},e.addThrottleControl=e=>{let t=i++;return a[t]=e,t},e.removeThrottleControl=e=>{delete a[e],s()},e.getImage=(e,r,i=!0)=>new Promise(((a,o)=>{c.supported&&(e.headers||={},e.headers.accept=`image/webp,*/*`),t.e(e,{type:`image`}),n.push({abortController:r,requestParameters:e,supportImageRefresh:i,state:`queued`,onError:e=>{o(e)},onSuccess:e=>{a(e)}}),s()}));let o=e=>t._(this,void 0,void 0,(function*(){e.state=`running`;let{requestParameters:n,supportImageRefresh:i,onError:a,onSuccess:o,abortController:c}=e,u=!1===i&&!t.i(self)&&!t.g(n.url)&&(!n.headers||Object.keys(n.headers).reduce(((e,t)=>e&&t===`accept`),!0));r++;let d=u?l(n,c):t.m(n,c);try{let n=yield d;delete e.abortController,e.state=`completed`,n.data instanceof HTMLImageElement||t.b(n.data)?o(n):n.data&&o({data:yield(f=n.data,typeof createImageBitmap==`function`?t.f(f):t.h(f)),cacheControl:n.cacheControl,expires:n.expires})}catch(t){delete e.abortController,a(t)}finally{r--,s()}var f})),s=()=>{let e=(()=>{for(let e of Object.keys(a))if(a[e]())return!0;return!1})()?t.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:t.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let t=r;t<e&&n.length>0;t++){let e=n.shift();e.abortController.signal.aborted?t--:o(e)}},l=(e,n)=>new Promise(((r,i)=>{let a=new Image,o=e.url,s=e.credentials;s&&s===`include`?a.crossOrigin=`use-credentials`:(s&&s===`same-origin`||!t.d(o))&&(a.crossOrigin=`anonymous`),n.signal.addEventListener(`abort`,(()=>{a.src=``,i(t.c())})),a.fetchPriority=`high`,a.onload=()=>{a.onerror=a.onload=null,r({data:a})},a.onerror=()=>{a.onerror=a.onload=null,n.signal.aborted||i(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.`))},a.src=o}))}(m||={}),m.resetRequestQueue();class h{constructor(e){this._transformRequestFn=e??null}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function g(e){let t=[];if(typeof e==`string`)t.push({id:`default`,url:e});else if(e&&e.length>0){let n=[];for(let{id:r,url:i}of e){let e=`${r}${i}`;n.indexOf(e)===-1&&(n.push(e),t.push({id:r,url:i}))}}return t}function _(e,t,n){try{let r=new URL(e);return r.pathname+=`${t}${n}`,r.toString()}catch{throw Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function v(e,n,r,i){return t._(this,void 0,void 0,(function*(){let a=g(e),s=r>1?`@2x`:``,c={},l={};for(let{id:e,url:r}of a){let a=n.transformRequest(_(r,s,`.json`),`SpriteJSON`);c[e]=t.j(a,i);let o=n.transformRequest(_(r,s,`.png`),`SpriteImage`);l[e]=m.getImage(o,i)}return yield Promise.all([...Object.values(c),...Object.values(l)]),function(e,n){return t._(this,void 0,void 0,(function*(){let t={};for(let r in e){t[r]={};let i=o.getImageCanvasContext((yield n[r]).data),a=(yield e[r]).data;for(let e in a){let{width:n,height:o,x:s,y:c,sdf:l,pixelRatio:u,stretchX:d,stretchY:f,content:p,textFitWidth:m,textFitHeight:h,id:g}=a[e];t[r][e]={data:null,pixelRatio:u,sdf:l,stretchX:d,stretchY:f,content:p,textFitWidth:m,textFitHeight:h,spriteData:{width:n,height:o,x:s,y:c,context:i},id:g}}}return t}))}(c,l)}))}function y(e){let{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class b extends t.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(let{ids:e,promiseResolve:t}of this.requestors)t(this._getImagesForIds(e));this.requestors=[]}}getImage(e){let n=this.images[e];if(n&&!n.data&&n.spriteData){let e=n.spriteData;n.data=new t.R({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),n.spriteData=null}return n}addImage(e,t){if(this.images[e])throw Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,t)&&(this.images[e]=t)}_validate(e,n){let r=!0,i=n.data||n.spriteData;return this._validateStretch(n.stretchX,i&&i.width)||(this.fire(new t.k(Error(`Image "${e}" has invalid "stretchX" value`))),r=!1),this._validateStretch(n.stretchY,i&&i.height)||(this.fire(new t.k(Error(`Image "${e}" has invalid "stretchY" value`))),r=!1),this._validateContent(n.content,n)||(this.fire(new t.k(Error(`Image "${e}" has invalid "content" value`))),r=!1),r}_validateStretch(e,t){if(!e)return!0;let n=0;for(let r of e){if(r[0]<n||r[1]<r[0]||t<r[1])return!1;n=r[1]}return!0}_validateContent(e,t){if(!e)return!0;if(e.length!==4)return!1;let n=t.spriteData,r=n&&n.width||t.data.width,i=n&&n.height||t.data.height;return!(e[0]<0||r<e[0]||e[1]<0||i<e[1]||e[2]<0||r<e[2]||e[3]<0||i<e[3]||e[2]<e[0]||e[3]<e[1])}updateImage(e,t,n=!0){let r=this.getImage(e);if(n&&(r.data.width!==t.data.width||r.data.height!==t.data.height))throw Error(`size mismatch between old image (${r.data.width}x${r.data.height}) and new image (${t.data.width}x${t.data.height}).`);t.version=r.version+1,this.images[e]=t,this.updatedImages[e]=!0}removeImage(e){let t=this.images[e];delete this.images[e],delete this.patterns[e],t.userImage&&t.userImage.onRemove&&t.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(e){return new Promise(((t,n)=>{let r=!0;if(!this.isLoaded())for(let t of e)this.images[t]||(r=!1);this.isLoaded()||r?t(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:t})}))}_getImagesForIds(e){let n={};for(let r of e){let e=this.getImage(r);e||=(this.fire(new t.l(`styleimagemissing`,{id:r})),this.getImage(r)),e?n[r]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,textFitWidth:e.textFitWidth,textFitHeight:e.textFitHeight,hasRenderCallback:!!(e.userImage&&e.userImage.render)}:t.w(`Image "${r}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}return n}getPixelSize(){let{width:e,height:t}=this.atlasImage;return{width:e,height:t}}getPattern(e){let n=this.patterns[e],r=this.getImage(e);if(!r)return null;if(n&&n.position.version===r.version)return n.position;if(n)n.position.version=r.version;else{let n={w:r.data.width+2,h:r.data.height+2,x:0,y:0},i=new t.I(n,r);this.patterns[e]={bin:n,position:i}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){let n=e.gl;this.atlasTexture?this.dirty&&=(this.atlasTexture.update(this.atlasImage),!1):this.atlasTexture=new t.T(e,this.atlasImage,n.RGBA),this.atlasTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}_updatePatternAtlas(){let e=[];for(let t in this.patterns)e.push(this.patterns[t].bin);let{w:n,h:r}=t.p(e),i=this.atlasImage;i.resize({width:n||1,height:r||1});for(let e in this.patterns){let{bin:n}=this.patterns[e],r=n.x+1,a=n.y+1,o=this.getImage(e).data,s=o.width,c=o.height;t.R.copy(o,i,{x:0,y:0},{x:r,y:a},{width:s,height:c}),t.R.copy(o,i,{x:0,y:c-1},{x:r,y:a-1},{width:s,height:1}),t.R.copy(o,i,{x:0,y:0},{x:r,y:a+c},{width:s,height:1}),t.R.copy(o,i,{x:s-1,y:0},{x:r-1,y:a},{width:1,height:c}),t.R.copy(o,i,{x:0,y:0},{x:r+s,y:a},{width:1,height:c})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(let n of e){if(this.callbackDispatchedThisFrame[n])continue;this.callbackDispatchedThisFrame[n]=!0;let e=this.getImage(n);e||t.w(`Image with ID: "${n}" was not found`),y(e)&&this.updateImage(n,e)}}}let x=0x56bc75e2d63100000;function S(e,t,n,r,i,a,o,s,c){for(let l=t;l<t+r;l++)C(e,n*a+l,a,i,o,s,c);for(let l=n;l<n+i;l++)C(e,l*a+t,1,r,o,s,c)}function C(e,t,n,r,i,a,o){a[0]=0,o[0]=-x,o[1]=x,i[0]=e[t];for(let s=1,c=0,l=0;s<r;s++){i[s]=e[t+s*n];let r=s*s;do{let e=a[c];l=(i[s]-i[e]+r-e*e)/(s-e)/2}while(l<=o[c]&&--c>-1);c++,a[c]=s,o[c]=l,o[c+1]=x}for(let s=0,c=0;s<r;s++){for(;o[c+1]<s;)c++;let r=a[c],l=s-r;e[t+s*n]=i[r]+l*l}}class w{constructor(e,t,n){this.requestManager=e,this.localIdeographFontFamily=t,this.entries={},this.lang=n}setURL(e){this.url=e}getGlyphs(e){return t._(this,void 0,void 0,(function*(){let t=[];for(let n in e)for(let r of e[n])t.push(this._getAndCacheGlyphsPromise(n,r));let n=yield Promise.all(t),r={};for(let{stack:e,id:t,glyph:i}of n)r[e]||(r[e]={}),r[e][t]=i&&{id:i.id,bitmap:i.bitmap.clone(),metrics:i.metrics};return r}))}getGlyphMap(e,t){let n=t.map((t=>({id:t,glyph:this.entries[e]?.glyphs[t]}))),r={[e]:{}};for(let{id:t,glyph:i}of n)r[e][t]=i&&{metrics:i.metrics};return r}_getAndCacheGlyphsPromise(e,n){return t._(this,void 0,void 0,(function*(){let t=this.entries[e];t||=this.entries[e]={glyphs:{},requests:{},ranges:{}};let r=t.glyphs[n];if(r!==void 0)return{stack:e,id:n,glyph:r};if(r=this._tinySDF(t,e,n),r)return t.glyphs[n]=r,{stack:e,id:n,glyph:r};let i=Math.floor(n/256);if(256*i>65535)throw Error(`glyphs > 65535 not supported`);if(t.ranges[i])return{stack:e,id:n,glyph:r};if(!this.url)throw Error(`glyphsUrl is not set`);if(!t.requests[i]){let n=w.loadGlyphRange(e,i,this.url,this.requestManager);t.requests[i]=n}let a=yield t.requests[i];for(let e in a)this._doesCharSupportLocalGlyph(+e)||(t.glyphs[+e]=a[+e]);return t.ranges[i]=!0,{stack:e,id:n,glyph:a[n]||null}}))}_doesCharSupportLocalGlyph(e){return!!this.localIdeographFontFamily&&(/\p{Ideo}|\p{sc=Hang}|\p{sc=Hira}|\p{sc=Kana}/u.test(String.fromCodePoint(e))||t.u[`CJK Unified Ideographs`](e)||t.u[`Hangul Syllables`](e)||t.u.Hiragana(e)||t.u.Katakana(e)||t.u[`CJK Symbols and Punctuation`](e)||t.u[`Halfwidth and Fullwidth Forms`](e))}_tinySDF(e,n,r){let i=this.localIdeographFontFamily;if(!i||!this._doesCharSupportLocalGlyph(r))return;let a=e.tinySDF;if(!a){let t=`400`;/bold/i.test(n)?t=`900`:/medium/i.test(n)?t=`500`:/light/i.test(n)&&(t=`200`),a=e.tinySDF=new w.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,lang:this.lang,fontFamily:i,fontWeight:t})}let o=a.draw(String.fromCharCode(r));return{id:r,bitmap:new t.q({width:o.width||60,height:o.height||60},o.data),metrics:{width:o.glyphWidth/2||24,height:o.glyphHeight/2||24,left:o.glyphLeft/2+.5||0,top:o.glyphTop/2-27.5||-8,advance:o.glyphAdvance/2||24,isDoubleResolution:!0}}}}w.loadGlyphRange=function(e,n,r,i){return t._(this,void 0,void 0,(function*(){let a=256*n,o=a+255,s=i.transformRequest(r.replace(`{fontstack}`,e).replace(`{range}`,`${a}-${o}`),`Glyphs`),c=yield t.n(s,new AbortController);if(!c||!c.data)throw Error(`Could not load glyph range. range: ${n}, ${a}-${o}`);let l={};for(let e of t.o(c.data))l[e.id]=e;return l}))},w.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:n=8,cutoff:r=.25,fontFamily:i=`sans-serif`,fontWeight:a=`normal`,fontStyle:o=`normal`,lang:s=null}={}){this.buffer=t,this.cutoff=r,this.radius=n,this.lang=s;let c=this.size=e+4*t,l=this.ctx=this._createCanvas(c).getContext(`2d`,{willReadFrequently:!0});l.font=`${o} ${a} ${e}px ${i}`,l.textBaseline=`alphabetic`,l.textAlign=`left`,l.fillStyle=`black`,this.gridOuter=new Float64Array(c*c),this.gridInner=new Float64Array(c*c),this.f=new Float64Array(c),this.z=new Float64Array(c+1),this.v=new Uint16Array(c)}_createCanvas(e){let t=document.createElement(`canvas`);return t.width=t.height=e,t}draw(e){let{width:t,actualBoundingBoxAscent:n,actualBoundingBoxDescent:r,actualBoundingBoxLeft:i,actualBoundingBoxRight:a}=this.ctx.measureText(e),o=Math.ceil(n),s=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(a-i))),c=Math.min(this.size-this.buffer,o+Math.ceil(r)),l=s+2*this.buffer,u=c+2*this.buffer,d=Math.max(l*u,0),f=new Uint8ClampedArray(d),p={data:f,width:l,height:u,glyphWidth:s,glyphHeight:c,glyphTop:o,glyphLeft:0,glyphAdvance:t};if(s===0||c===0)return p;let{ctx:m,buffer:h,gridInner:g,gridOuter:_}=this;this.lang&&(m.lang=this.lang),m.clearRect(h,h,s,c),m.fillText(e,h,h+o);let v=m.getImageData(h,h,s,c);_.fill(x,0,d),g.fill(0,0,d);for(let e=0;e<c;e++)for(let t=0;t<s;t++){let n=v.data[4*(e*s+t)+3]/255;if(n===0)continue;let r=(e+h)*l+t+h;if(n===1)_[r]=0,g[r]=x;else{let e=.5-n;_[r]=e>0?e*e:0,g[r]=e<0?e*e:0}}S(_,0,0,l,u,l,this.f,this.v,this.z),S(g,h,h,s,c,l,this.f,this.v,this.z);for(let e=0;e<d;e++){let t=Math.sqrt(_[e])-Math.sqrt(g[e]);f[e]=Math.round(255-255*(t/this.radius+this.cutoff))}return p}};class T{constructor(){this.specification=t.v.light.position}possiblyEvaluate(e,n){return t.B(e.expression.evaluate(n))}interpolate(e,n,r){return{x:t.C.number(e.x,n.x,r),y:t.C.number(e.y,n.y,r),z:t.C.number(e.z,n.z,r)}}}let E;class D extends t.E{constructor(e){super(),E||=new t.r({anchor:new t.D(t.v.light.anchor),position:new T,color:new t.D(t.v.light.color),intensity:new t.D(t.v.light.intensity)}),this._transitionable=new t.t(E),this.setLight(e),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,n={}){if(!this._validate(t.x,e,n))for(let t in e){let n=e[t];t.endsWith(`-transition`)?this._transitionable.setTransition(t.slice(0,-11),n):this._transitionable.setValue(t,n)}}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,n,r){return(!r||!1!==r.validate)&&t.y(this,e.call(t.z,{value:n,style:{glyphs:!0,sprite:!0},styleSpec:t.v}))}}let O=new t.r({"sky-color":new t.D(t.v.sky[`sky-color`]),"horizon-color":new t.D(t.v.sky[`horizon-color`]),"fog-color":new t.D(t.v.sky[`fog-color`]),"fog-ground-blend":new t.D(t.v.sky[`fog-ground-blend`]),"horizon-fog-blend":new t.D(t.v.sky[`horizon-fog-blend`]),"sky-horizon-blend":new t.D(t.v.sky[`sky-horizon-blend`]),"atmosphere-blend":new t.D(t.v.sky[`atmosphere-blend`])});class k extends t.E{constructor(e){super(),this._transitionable=new t.t(O),this.setSky(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new t.F(0))}setSky(e,n={}){if(!this._validate(t.G,e,n)){e||={"sky-color":`transparent`,"horizon-color":`transparent`,"fog-color":`transparent`,"fog-ground-blend":1,"atmosphere-blend":0};for(let t in e){let n=e[t];t.endsWith(`-transition`)?this._transitionable.setTransition(t.slice(0,-11),n):this._transitionable.setValue(t,n)}}}getSky(){return this._transitionable.serialize()}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,n,r={}){return!1!==r?.validate&&t.y(this,e.call(t.z,t.e({value:n,style:{glyphs:!0,sprite:!0},styleSpec:t.v})))}calculateFogBlendOpacity(e){return e<60?0:e<70?(e-60)/10:1}}class A{constructor(e,t){this.width=e,this.height=t,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(e,t){let n=e.join(`,`)+String(t);return this.dashEntry[n]||(this.dashEntry[n]=this.addDash(e,t)),this.dashEntry[n]}getDashRanges(e,t,n){let r=[],i=e.length%2==1?-e[e.length-1]*n:0,a=e[0]*n,o=!0;r.push({left:i,right:a,isDash:o,zeroLength:e[0]===0});let s=e[0];for(let t=1;t<e.length;t++){o=!o;let c=e[t];i=s*n,s+=c,a=s*n,r.push({left:i,right:a,isDash:o,zeroLength:c===0})}return r}addRoundDash(e,t,n){let r=t/2;for(let t=-n;t<=n;t++){let i=this.width*(this.nextRow+n+t),a=0,o=e[a];for(let s=0;s<this.width;s++){s/o.right>1&&(o=e[++a]);let c=Math.abs(s-o.left),l=Math.abs(s-o.right),u=Math.min(c,l),d,f=t/n*(r+1);if(o.isDash){let e=r-Math.abs(f);d=Math.sqrt(u*u+e*e)}else d=r-Math.sqrt(u*u+f*f);this.data[i+s]=Math.max(0,Math.min(255,d+128))}}}addRegularDash(e){for(let t=e.length-1;t>=0;--t){let n=e[t],r=e[t+1];n.zeroLength?e.splice(t,1):r&&r.isDash===n.isDash&&(r.left=n.left,e.splice(t,1))}let t=e[0],n=e[e.length-1];t.isDash===n.isDash&&(t.left=n.left-this.width,n.right=t.right+this.width);let r=this.width*this.nextRow,i=0,a=e[i];for(let t=0;t<this.width;t++){t/a.right>1&&(a=e[++i]);let n=Math.abs(t-a.left),o=Math.abs(t-a.right),s=Math.min(n,o);this.data[r+t]=Math.max(0,Math.min(255,(a.isDash?s:-s)+128))}}addDash(e,n){let r=n?7:0,i=2*r+1;if(this.nextRow+i>this.height)return t.w(`LineAtlas out of space`),null;let a=0;for(let t=0;t<e.length;t++)a+=e[t];if(a!==0){let t=this.width/a,i=this.getDashRanges(e,this.width,t);n?this.addRoundDash(i,t,r):this.addRegularDash(i)}let o={y:(this.nextRow+r+.5)/this.height,height:2*r/this.height,width:a};return this.nextRow+=i,this.dirty=!0,o}bind(e){let t=e.gl;this.texture?(t.bindTexture(t.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,t.texSubImage2D(t.TEXTURE_2D,0,0,0,this.width,this.height,t.ALPHA,t.UNSIGNED_BYTE,this.data))):(this.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texImage2D(t.TEXTURE_2D,0,t.ALPHA,this.width,this.height,0,t.ALPHA,t.UNSIGNED_BYTE,this.data))}}let j=`maplibre_preloaded_worker_pool`;class M{constructor(){this.active={}}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length<M.workerCount;)this.workers.push(new Worker(t.a.WORKER_URL));return this.active[e]=!0,this.workers.slice()}release(e){delete this.active[e],this.numActive()===0&&(this.workers.forEach((e=>{e.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[j]}numActive(){return Object.keys(this.active).length}}let N=Math.floor(o.hardwareConcurrency/2),P,ee;function te(){return P||=new M,P}M.workerCount=t.H(globalThis)?Math.max(Math.min(N,3),1):1;class F{constructor(e,n){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=n;let r=this.workerPool.acquire(n);for(let e=0;e<r.length;e++){let i=new t.J(r[e],n);i.name=`Worker ${e}`,this.actors.push(i)}if(!this.actors.length)throw Error(`No actors found`)}broadcast(e,t){let n=[];for(let r of this.actors)n.push(r.sendAsync({type:e,data:t}));return Promise.all(n)}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(e=!0){this.actors.forEach((e=>{e.remove()})),this.actors=[],e&&this.workerPool.release(this.id)}registerMessageHandler(e,t){for(let n of this.actors)n.registerMessageHandler(e,t)}}function ne(){return ee||(ee=new F(te(),t.K),ee.registerMessageHandler(`GR`,((e,n,r)=>t.m(n,r)))),ee}class re{constructor(e,t){this.reset(e,t)}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e<this.points.length;e++)this._distances[e]=this._distances[e-1]+this.points[e].dist(this.points[e-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(t||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(e){if(this.points.length===1)return this.points[0];e=t.L(e,0,1);let n=1,r=this._distances[n],i=e*this.paddedLength+this.padding;for(;r<i&&n<this._distances.length;)r=this._distances[++n];let a=n-1,o=this._distances[a],s=r-o,c=s>0?(i-o)/s:0;return this.points[a].mult(1-c).add(this.points[n].mult(c))}}function ie(e,t){let n=!0;return e===`always`||e!==`never`&&t!==`never`||(n=!1),n}class ae{constructor(e,t,n){let r=this.boxCells=[],i=this.circleCells=[];this.xCellCount=Math.ceil(e/n),this.yCellCount=Math.ceil(t/n);for(let e=0;e<this.xCellCount*this.yCellCount;e++)r.push([]),i.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,n,r,i){this._forEachCell(t,n,r,i,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(t),this.bboxes.push(n),this.bboxes.push(r),this.bboxes.push(i)}insertCircle(e,t,n,r){this._forEachCell(t-r,n-r,t+r,n+r,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(t),this.circles.push(n),this.circles.push(r)}_insertBoxCell(e,t,n,r,i,a){this.boxCells[i].push(a)}_insertCircleCell(e,t,n,r,i,a){this.circleCells[i].push(a)}_query(e,t,n,r,i,a,o){if(n<0||e>this.width||r<0||t>this.height)return[];let s=[];if(e<=0&&t<=0&&this.width<=n&&this.height<=r){if(i)return[{key:null,x1:e,y1:t,x2:n,y2:r}];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++){let t=this.circles[3*e],n=this.circles[3*e+1],r=this.circles[3*e+2];s.push({key:this.circleKeys[e],x1:t-r,y1:n-r,x2:t+r,y2:n+r})}}else this._forEachCell(e,t,n,r,this._queryCell,s,{hitTest:i,overlapMode:a,seenUids:{box:{},circle:{}}},o);return s}query(e,t,n,r){return this._query(e,t,n,r,!1,null)}hitTest(e,t,n,r,i,a){return this._query(e,t,n,r,!0,i,a).length>0}hitTestCircle(e,t,n,r,i){let a=e-n,o=e+n,s=t-n,c=t+n;if(o<0||a>this.width||c<0||s>this.height)return!1;let l=[];return this._forEachCell(a,s,o,c,this._queryCellCircle,l,{hitTest:!0,overlapMode:r,circle:{x:e,y:t,radius:n},seenUids:{box:{},circle:{}}},i),l.length>0}_queryCell(e,t,n,r,i,a,o,s){let{seenUids:c,hitTest:l,overlapMode:u}=o,d=this.boxCells[i];if(d!==null){let i=this.bboxes;for(let o of d)if(!c.box[o]){c.box[o]=!0;let d=4*o,f=this.boxKeys[o];if(e<=i[d+2]&&t<=i[d+3]&&n>=i[d+0]&&r>=i[d+1]&&(!s||s(f))&&(!l||!ie(u,f.overlapMode))&&(a.push({key:f,x1:i[d],y1:i[d+1],x2:i[d+2],y2:i[d+3]}),l))return!0}}let f=this.circleCells[i];if(f!==null){let i=this.circles;for(let o of f)if(!c.circle[o]){c.circle[o]=!0;let d=3*o,f=this.circleKeys[o];if(this._circleAndRectCollide(i[d],i[d+1],i[d+2],e,t,n,r)&&(!s||s(f))&&(!l||!ie(u,f.overlapMode))){let e=i[d],t=i[d+1],n=i[d+2];if(a.push({key:f,x1:e-n,y1:t-n,x2:e+n,y2:t+n}),l)return!0}}}return!1}_queryCellCircle(e,t,n,r,i,a,o,s){let{circle:c,seenUids:l,overlapMode:u}=o,d=this.boxCells[i];if(d!==null){let e=this.bboxes;for(let t of d)if(!l.box[t]){l.box[t]=!0;let n=4*t,r=this.boxKeys[t];if(this._circleAndRectCollide(c.x,c.y,c.radius,e[n+0],e[n+1],e[n+2],e[n+3])&&(!s||s(r))&&!ie(u,r.overlapMode))return a.push(!0),!0}}let f=this.circleCells[i];if(f!==null){let e=this.circles;for(let t of f)if(!l.circle[t]){l.circle[t]=!0;let n=3*t,r=this.circleKeys[t];if(this._circlesCollide(e[n],e[n+1],e[n+2],c.x,c.y,c.radius)&&(!s||s(r))&&!ie(u,r.overlapMode))return a.push(!0),!0}}}_forEachCell(e,t,n,r,i,a,o,s){let c=this._convertToXCellCoord(e),l=this._convertToYCellCoord(t),u=this._convertToXCellCoord(n),d=this._convertToYCellCoord(r);for(let f=c;f<=u;f++)for(let c=l;c<=d;c++)if(i.call(this,e,t,n,r,this.xCellCount*c+f,a,o,s))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,n,r,i,a){let o=r-e,s=i-t,c=n+a;return c*c>o*o+s*s}_circleAndRectCollide(e,t,n,r,i,a,o){let s=(a-r)/2,c=Math.abs(e-(r+s));if(c>s+n)return!1;let l=(o-i)/2,u=Math.abs(t-(i+l));if(u>l+n)return!1;if(c<=s||u<=l)return!0;let d=c-s,f=u-l;return d*d+f*f<=n*n}}function oe(e,n,i){let a=t.M();if(!e){let{vecSouth:e,vecEast:t}=ce(n),i=r();i[0]=t[0],i[1]=t[1],i[2]=e[0],i[3]=e[1],o=i,(f=(c=(s=i)[0])*(d=s[3])-(u=s[2])*(l=s[1]))&&(o[0]=d*(f=1/f),o[1]=-l*f,o[2]=-u*f,o[3]=c*f),a[0]=i[0],a[1]=i[1],a[4]=i[2],a[5]=i[3]}var o,s,c,l,u,d,f;return t.N(a,a,[1/i,1/i,1]),a}function se(e,n,r,i){if(e){let e=t.M();if(!n){let{vecSouth:t,vecEast:n}=ce(r);e[0]=n[0],e[1]=n[1],e[4]=t[0],e[5]=t[1]}return t.N(e,e,[i,i,1]),e}return r.pixelsToClipSpaceMatrix}function ce(e){let n=Math.cos(e.rollInRadians),r=Math.sin(e.rollInRadians),i=Math.cos(e.pitchInRadians),a=Math.cos(e.bearingInRadians),o=Math.sin(e.bearingInRadians),s=t.U();s[0]=-a*i*r-o*n,s[1]=-o*i*r+a*n;let c=t.V(s);c<1e-9?t.X(s):t.Y(s,s,1/c);let l=t.U();l[0]=a*i*n-o*r,l[1]=o*i*n+a*r;let u=t.V(l);return u<1e-9?t.X(l):t.Y(l,l,1/u),{vecEast:l,vecSouth:s}}function le(e,n,r,i){let a;i?(a=[e,n,i(e,n),1],t.$(a,a,r)):(a=[e,n,0,1],Ee(a,a,r));let o=a[3];return{point:new t.P(a[0]/o,a[1]/o),signedDistanceFromCamera:o,isOccluded:!1}}function ue(e,t){return .5+e/t*.5}function de(e,t){return e.x>=-t[0]&&e.x<=t[0]&&e.y>=-t[1]&&e.y<=t[1]}function fe(e,n,r,i,a,o,s,c,l,u,d,f,p){let m=r?e.textSizeData:e.iconSizeData,h=t.O(m,n.transform.zoom),g=[256/n.width*2+1,256/n.height*2+1],_=r?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;_.clear();let v=e.lineVertexArray,y=r?e.text.placedSymbolArray:e.icon.placedSymbolArray,b=n.transform.width/n.transform.height,x=!1;for(let r=0;r<y.length;r++){let S=y.get(r);if(S.hidden||S.writingMode===t.W.vertical&&!x){Te(S.numGlyphs,_);continue}x=!1;let C=new t.P(S.anchorX,S.anchorY),w={getElevation:p,pitchedLabelPlaneMatrix:i,lineVertexArray:v,pitchWithMap:o,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:n.transform,tileAnchorPoint:C,unwrappedTileID:l,width:u,height:d,translation:f},T=be(S.anchorX,S.anchorY,w);if(!de(T.point,g)){Te(S.numGlyphs,_);continue}let E=ue(n.transform.cameraToCenterDistance,T.signedDistanceFromCamera),D=t.Q(m,h,S),O=o?D*n.transform.getPitchedTextCorrection(S.anchorX,S.anchorY,l)/E:D*E,k=he({projectionContext:w,pitchedLabelPlaneMatrixInverse:a,symbol:S,fontSize:O,flip:!1,keepUpright:s,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:_,aspectRatio:b,rotateToLine:c});x=k.useVertical,(k.notEnoughRoom||x||k.needsFlipping&&he({projectionContext:w,pitchedLabelPlaneMatrixInverse:a,symbol:S,fontSize:O,flip:!0,keepUpright:s,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:_,aspectRatio:b,rotateToLine:c}).notEnoughRoom)&&Te(S.numGlyphs,_)}r?e.text.dynamicLayoutVertexBuffer.updateData(_):e.icon.dynamicLayoutVertexBuffer.updateData(_)}function pe(e,t,n,r,i,a,o,s){let c=a.glyphStartIndex+a.numGlyphs,l=a.lineStartIndex,u=a.lineStartIndex+a.lineLength,d=t.getoffsetX(a.glyphStartIndex),f=t.getoffsetX(c-1),p=Ce(e*d,n,r,i,a.segment,l,u,s,o);if(!p)return null;let m=Ce(e*f,n,r,i,a.segment,l,u,s,o);return m?s.projectionCache.anyProjectionOccluded?null:{first:p,last:m}:null}function me(e,n,r,i){return e===t.W.horizontal&&Math.abs(r.y-n.y)>Math.abs(r.x-n.x)*i?{useVertical:!0}:(e===t.W.vertical?n.y<r.y:n.x>r.x)?{needsFlipping:!0}:null}function he(e){let{projectionContext:n,pitchedLabelPlaneMatrixInverse:r,symbol:i,fontSize:a,flip:o,keepUpright:s,glyphOffsetArray:c,dynamicLayoutVertexArray:l,aspectRatio:u,rotateToLine:d}=e,f=a/24,p=i.lineOffsetX*f,m=i.lineOffsetY*f,h;if(i.numGlyphs>1){let e=i.glyphStartIndex+i.numGlyphs,t=i.lineStartIndex,a=i.lineStartIndex+i.lineLength,l=pe(f,c,p,m,o,i,d,n);if(!l)return{notEnoughRoom:!0};let g=ye(l.first.point.x,l.first.point.y,n,r),_=ye(l.last.point.x,l.last.point.y,n,r);if(s&&!o){let e=me(i.writingMode,g,_,u);if(e)return e}h=[l.first];for(let r=i.glyphStartIndex+1;r<e-1;r++){let e=Ce(f*c.getoffsetX(r),p,m,o,i.segment,t,a,n,d);if(!e)return{notEnoughRoom:!0};h.push(e)}h.push(l.last)}else{if(s&&!o){let e=ve(n.tileAnchorPoint.x,n.tileAnchorPoint.y,n).point,a=i.lineStartIndex+i.segment+1,o=new t.P(n.lineVertexArray.getx(a),n.lineVertexArray.gety(a)),s=ve(o.x,o.y,n),c=s.signedDistanceFromCamera>0?s.point:ge(n.tileAnchorPoint,o,e,1,n),l=ye(e.x,e.y,n,r),d=ye(c.x,c.y,n,r),f=me(i.writingMode,l,d,u);if(f)return f}let e=Ce(f*c.getoffsetX(i.glyphStartIndex),p,m,o,i.segment,i.lineStartIndex,i.lineStartIndex+i.lineLength,n,d);if(!e||n.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};h=[e]}for(let e of h)t.Z(l,e.point,e.angle);return{}}function ge(e,t,n,r,i){let a=e.add(e.sub(t)._unit()),o=ve(a.x,a.y,i).point,s=n.sub(o);return n.add(s._mult(r/s.mag()))}function _e(e,n,r){let i=n.projectionCache;if(i.projections[e])return i.projections[e];let a=new t.P(n.lineVertexArray.getx(e),n.lineVertexArray.gety(e)),o=ve(a.x,a.y,n);if(o.signedDistanceFromCamera>0)return i.projections[e]=o.point,i.anyProjectionOccluded=i.anyProjectionOccluded||o.isOccluded,o.point;let s=e-r.direction;return ge(r.distanceFromAnchor===0?n.tileAnchorPoint:new t.P(n.lineVertexArray.getx(s),n.lineVertexArray.gety(s)),a,r.previousVertex,r.absOffsetX-r.distanceFromAnchor+1,n)}function ve(e,t,n){let r=e+n.translation[0],i=t+n.translation[1],a;return n.pitchWithMap?(a=le(r,i,n.pitchedLabelPlaneMatrix,n.getElevation),a.isOccluded=!1):(a=n.transform.projectTileCoordinates(r,i,n.unwrappedTileID,n.getElevation),a.point.x=(.5*a.point.x+.5)*n.width,a.point.y=(.5*-a.point.y+.5)*n.height),a}function ye(e,n,r,i){if(r.pitchWithMap){let a=[e,n,0,1];return t.$(a,a,i),r.transform.projectTileCoordinates(a[0]/a[3],a[1]/a[3],r.unwrappedTileID,r.getElevation).point}return{x:e/r.width*2-1,y:1-n/r.height*2}}function be(e,t,n){return n.transform.projectTileCoordinates(e,t,n.unwrappedTileID,n.getElevation)}function xe(e,t,n){return e._unit()._perp()._mult(t*n)}function Se(e,n,r,i,a,o,s,c,l){if(c.projectionCache.offsets[e])return c.projectionCache.offsets[e];let u=r.add(n);if(e+l.direction<i||e+l.direction>=a)return c.projectionCache.offsets[e]=u,u;let d=_e(e+l.direction,c,l),f=xe(d.sub(r),s,l.direction),p=r.add(f),m=d.add(f);return c.projectionCache.offsets[e]=t.a0(o,u,p,m)||u,c.projectionCache.offsets[e]}function Ce(e,t,n,r,i,a,o,s,c){let l=r?e-t:e+t,u=l>0?1:-1,d=0;r&&(u*=-1,d=Math.PI),u<0&&(d+=Math.PI);let f,p=u>0?a+i:a+i+1;s.projectionCache.cachedAnchorPoint?f=s.projectionCache.cachedAnchorPoint:(f=ve(s.tileAnchorPoint.x,s.tileAnchorPoint.y,s).point,s.projectionCache.cachedAnchorPoint=f);let m,h,g=f,_=f,v=0,y=0,b=Math.abs(l),x=[],S;for(;v+y<=b;){if(p+=u,p<a||p>=o)return null;v+=y,_=g,h=m;let e={absOffsetX:b,direction:u,distanceFromAnchor:v,previousVertex:_};if(g=_e(p,s,e),n===0)x.push(_),S=g.sub(_);else{let t,r=g.sub(_);t=r.mag()===0?xe(_e(p+u,s,e).sub(g),n,u):xe(r,n,u),h||=_.add(t),m=Se(p,t,g,a,o,h,n,s,e),x.push(h),S=m.sub(h)}y=S.mag()}if(!S)return null;let C=S._mult((b-v)/y)._add(h||_),w=d+Math.atan2(g.y-_.y,g.x-_.x);return x.push(C),{point:C,angle:c?w:0,path:x}}let we=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Te(e,t){for(let n=0;n<e;n++){let e=t.length;t.resize(e+4),t.float32.set(we,3*e)}}function Ee(e,t,n){let r=t[0],i=t[1];return e[0]=n[0]*r+n[4]*i+n[12],e[1]=n[1]*r+n[5]*i+n[13],e[3]=n[3]*r+n[7]*i+n[15],e}class De{constructor(e,t=[],n=1,r=new ae(e.width+200,e.height+200,25),i=new ae(e.width+200,e.height+200,25)){this.transform=e,this.grid=r,this.ignoredGrid=i,this.pitchFactor=Math.cos(e.pitch*Math.PI/180)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+100,this.screenBottomBoundary=e.height+100,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.perspectiveRatioCutoff=.6;for(let e=0;e<t.length;e++){let r=t[e];this.grid.insert(`label-free-area-${e}`,r[0]/n+100,r[1]/n+100,r[2]/n+100,r[3]/n+100)}}placeCollisionBox(e,t,n,r,i,a,o,s,c,l,u,d){let f=this.projectAndGetPerspectiveRatio(e.anchorPointX+s[0],e.anchorPointY+s[1],i,l,d),p=n*f.perspectiveRatio,m;if(a||o)m=this._projectCollisionBox(e,p,r,i,a,o,s,f,l,u,d);else{let t=f.x+(u?u.x*p:0),n=f.y+(u?u.y*p:0);m={allPointsOccluded:!1,box:[t+e.x1*p,n+e.y1*p,t+e.x2*p,n+e.y2*p]}}let[h,g,_,v]=m.box,y=a?m.allPointsOccluded:f.isOccluded,b=y;return b||=f.perspectiveRatio<this.perspectiveRatioCutoff,b||=!this.isInsideGrid(h,g,_,v),b||t!==`always`&&this.grid.hitTest(h,g,_,v,t,c)?{box:[h,g,_,v],placeable:!1,offscreen:!1,occluded:y}:{box:[h,g,_,v],placeable:!0,offscreen:this.isOffscreen(h,g,_,v),occluded:y}}placeCollisionCircles(e,n,r,i,a,o,s,c,l,u,d,f,p,m){let h=[],g=new t.P(n.anchorX,n.anchorY),_=this.getPerspectiveRatio(g.x,g.y,o,m),v=(l?a*this.transform.getPitchedTextCorrection(n.anchorX,n.anchorY,o)/_:a*_)/t.a7,y={getElevation:m,pitchedLabelPlaneMatrix:s,lineVertexArray:r,pitchWithMap:l,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:this.transform,tileAnchorPoint:g,unwrappedTileID:o,width:this.transform.width,height:this.transform.height,translation:p},b=pe(v,i,n.lineOffsetX*v,n.lineOffsetY*v,!1,n,!1,y),x=!1,S=!1,C=!0;if(b){let n=.5*d*_+f,r=new t.P(-100,-100),i=new t.P(this.screenRightBoundary,this.screenBottomBoundary),a=new re,o=b.first,s=b.last,p=[];for(let e=o.path.length-1;e>=1;e--)p.push(o.path[e]);for(let e=1;e<s.path.length;e++)p.push(s.path[e]);let m=2.5*n;if(l){let e=this.projectPathToScreenSpace(p,y);p=e.some((e=>e.signedDistanceFromCamera<=0))?[]:e.map((e=>e.point))}let g=[];if(p.length>0){let e=p[0].clone(),n=p[0].clone();for(let t=1;t<p.length;t++)e.x=Math.min(e.x,p[t].x),e.y=Math.min(e.y,p[t].y),n.x=Math.max(n.x,p[t].x),n.y=Math.max(n.y,p[t].y);g=e.x>=r.x&&n.x<=i.x&&e.y>=r.y&&n.y<=i.y?[p]:n.x<r.x||e.x>i.x||n.y<r.y||e.y>i.y?[]:t.a1([p],r.x,r.y,i.x,i.y)}for(let t of g){a.reset(t,.25*n);let r=0;r=a.length<=.5*n?1:Math.ceil(a.paddedLength/m)+1;for(let t=0;t<r;t++){let i=t/Math.max(r-1,1),o=a.lerp(i),s=o.x+100,l=o.y+100;h.push(s,l,n,0);let d=s-n,f=l-n,p=s+n,m=l+n;if(C&&=this.isOffscreen(d,f,p,m),S||=this.isInsideGrid(d,f,p,m),e!==`always`&&this.grid.hitTestCircle(s,l,n,e,u)&&(x=!0,!c))return{circles:[],offscreen:!1,collisionDetected:x}}}}return{circles:!c&&x||!S||_<this.perspectiveRatioCutoff?[]:h,offscreen:C,collisionDetected:x}}projectPathToScreenSpace(e,n){return function(e){let t=0,n=0,r=0,i=0;for(let a=0;a<e.length;a++)e[a].isOccluded?(r=a+1,i=0):(i++,i>n&&(n=i,t=r));return e.slice(t,t+n)}(function(e,n){let r=t.M();return t.S(r,n.pitchedLabelPlaneMatrix),e.map((e=>{let t=le(e.x,e.y,r,n.getElevation),i=n.transform.projectTileCoordinates(t.point.x,t.point.y,n.unwrappedTileID,n.getElevation);return i.point.x=(.5*i.point.x+.5)*n.width,i.point.y=(.5*-i.point.y+.5)*n.height,i}))}(e,n))}queryRenderedSymbols(e){if(e.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};let n=[],r=new t.a2;for(let i of e){let e=new t.P(i.x+100,i.y+100);r.extend(e),n.push(e)}let{minX:i,minY:a,maxX:o,maxY:s}=r,c=this.grid.query(i,a,o,s).concat(this.ignoredGrid.query(i,a,o,s)),l={},u={};for(let e of c){let r=e.key;if(r.bucketInstanceId===void 0||r.featureIndex===void 0||(l[r.bucketInstanceId]===void 0&&(l[r.bucketInstanceId]={}),l[r.bucketInstanceId][r.featureIndex]))continue;let i=[new t.P(e.x1,e.y1),new t.P(e.x2,e.y1),new t.P(e.x2,e.y2),new t.P(e.x1,e.y2)];t.a3(n,i)&&(l[r.bucketInstanceId][r.featureIndex]=!0,u[r.bucketInstanceId]===void 0&&(u[r.bucketInstanceId]=[]),u[r.bucketInstanceId].push(r.featureIndex))}return u}insertCollisionBox(e,t,n,r,i,a){(n?this.ignoredGrid:this.grid).insert({bucketInstanceId:r,featureIndex:i,collisionGroupID:a,overlapMode:t},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,n,r,i,a){let o=n?this.ignoredGrid:this.grid,s={bucketInstanceId:r,featureIndex:i,collisionGroupID:a,overlapMode:t};for(let t=0;t<e.length;t+=4)o.insertCircle(s,e[t],e[t+1],e[t+2])}projectAndGetPerspectiveRatio(e,n,r,i,a){if(a){let r;i?(r=[e,n,i(e,n),1],t.$(r,r,a)):(r=[e,n,0,1],Ee(r,r,a));let o=r[3];return{x:(r[0]/o+1)/2*this.transform.width+100,y:(-r[1]/o+1)/2*this.transform.height+100,perspectiveRatio:.5+this.transform.cameraToCenterDistance/o*.5,isOccluded:!1,signedDistanceFromCamera:o}}{let t=this.transform.projectTileCoordinates(e,n,r,i);return{x:(t.point.x+1)/2*this.transform.width+100,y:(1-t.point.y)/2*this.transform.height+100,perspectiveRatio:.5+this.transform.cameraToCenterDistance/t.signedDistanceFromCamera*.5,isOccluded:t.isOccluded,signedDistanceFromCamera:t.signedDistanceFromCamera}}}getPerspectiveRatio(e,t,n,r){let i=this.transform.projectTileCoordinates(e,t,n,r);return .5+this.transform.cameraToCenterDistance/i.signedDistanceFromCamera*.5}isOffscreen(e,t,n,r){return n<100||e>=this.screenRightBoundary||r<100||t>this.screenBottomBoundary}isInsideGrid(e,t,n,r){return n>=0&&e<this.gridRightBoundary&&r>=0&&t<this.gridBottomBoundary}getViewportMatrix(){let e=t.a4([]);return t.a5(e,e,[-100,-100,0]),e}_projectCollisionBox(e,n,r,i,a,o,s,c,l,u,d){let f=1,p=0,m=0,h=1,g=e.anchorPointX+s[0],_=e.anchorPointY+s[1];if(o&&!a){let e=this.projectAndGetPerspectiveRatio(g+1,_,i,l,d),t=e.x-c.x,n=Math.atan((e.y-c.y)/t)+(t<0?Math.PI:0),r=Math.sin(n),a=Math.cos(n);f=a,p=r,m=-r,h=a}else if(!o&&a){let e=ce(this.transform);f=e.vecEast[0],p=e.vecEast[1],m=e.vecSouth[0],h=e.vecSouth[1]}let v=c.x,y=c.y,b=n;a&&(v=g,y=_,b=2**-(this.transform.zoom-r.overscaledZ),b*=this.transform.getPitchedTextCorrection(g,_,i),u||(b*=t.L(.5+c.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4))),u&&(v+=f*u.x*b+m*u.y*b,y+=p*u.x*b+h*u.y*b);let x=e.x1*b,S=e.x2*b,C=(x+S)/2,w=e.y1*b,T=e.y2*b,E=(w+T)/2,D=[{offsetX:x,offsetY:w},{offsetX:C,offsetY:w},{offsetX:S,offsetY:w},{offsetX:S,offsetY:E},{offsetX:S,offsetY:T},{offsetX:C,offsetY:T},{offsetX:x,offsetY:T},{offsetX:x,offsetY:E}],O=[];for(let{offsetX:e,offsetY:n}of D)O.push(new t.P(v+f*e+m*n,y+p*e+h*n));let k=!1;if(a){let e=O.map((e=>this.projectAndGetPerspectiveRatio(e.x,e.y,i,l,d)));k=e.some((e=>!e.isOccluded)),O=e.map((e=>new t.P(e.x,e.y)))}else k=!0;return{box:t.a6(O),allPointsOccluded:!k}}}function Oe(e,n){let r=t.M();return t.a5(r,r,[1,1,0]),t.N(r,r,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?t.a8(r,r,e.calculatePosMatrix(n.toUnwrapped())):r}function ke(e,t,n,r,i,a,o){let s=function(e,t,n){if(e)for(let r of e){let e=t[r];if(e&&e.source===n&&e.type===`fill-extrusion`)return!0}else for(let e in t){let r=t[e];if(r.source===n&&r.type===`fill-extrusion`)return!0}return!1}(i?.layers??null,t,e.id),c=a.maxPitchScaleFactor(),l=e.tilesIn(r,c,s,i?.skipGeoCheck);l.sort(Ae);let u=[];for(let r of l)u.push({wrappedTileID:r.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(t,n,e._state,r.queryGeometry,r.cameraQueryGeometry,r.scale,i,a,c,Oe(e.transform,r.tileID),o?(e,t)=>o(r.tileID,e,t):void 0)});return function(e,t){for(let n in e)for(let r of e[n])je(r,t);return e}(function(e){let t={},n={};for(let r of e){let e=r.queryResults,i=r.wrappedTileID,a=n[i]=n[i]||{};for(let n in e){let r=e[n],i=a[n]=a[n]||{},o=t[n]=t[n]||[];for(let e of r)i[e.featureIndex]||o.push(e)}}return t}(u),e)}function Ae(e,t){let n=e.tileID,r=t.tileID;return n.overscaledZ-r.overscaledZ||n.canonical.y-r.canonical.y||n.wrap-r.wrap||n.canonical.x-r.canonical.x}function je(e,t){let n=e.feature,r=t.getFeatureState(n.layer[`source-layer`],n.id);n.source=n.layer.source,n.layer[`source-layer`]&&(n.sourceLayer=n.layer[`source-layer`]),n.state=r}function Me(e,n,r){let{glyphCircles:i,placedBoxes:a,anchorAngles:o,variableAnchors:s}=e.style.placement,c=n.bucketInstanceId,l=r.featureIndex;if(c in i&&l in i[c]){let e=i[c][l],n=o[c][l],a=0;r.feature.paths=[],e.forEach((e=>{let i=[],o=e.length/4;for(let t=0;t<o;t++)i.push(e[4*t]-100),i.push(e[4*t+1]-100);let s=i.length/2;if(i[0]>i[i.length-2]){let e=[];for(let t=1;t<=s;t++)e.push(i[2*(s-t)]),e.push(i[2*(s-t)+1]);i=e}if(s===1){let e=n[a],o=new t.P(i[0],i[1]),s=new t.P(i[0]-20,i[1]),c=new t.P(i[0]+20,i[1]);s=s.rotateAround(e,o),c=c.rotateAround(e,o),r.feature.paths.push([s.x,s.y,c.x,c.y])}else{let e=Ne(i[2],i[3],i[0],i[1],20);e!==void 0&&(i[0]=e.x,i[1]=e.y);let t=i.length,n=Ne(i[t-4],i[t-3],i[t-2],i[t-1],20);n!==void 0&&(i[t-2]=n.x,i[t-1]=n.y),r.feature.paths.push(i)}a++}))}if(c in a&&l in a[c]){let e=a[c][l];r.feature.iconBoxes=[],r.feature.textBoxes=[],e.forEach((e=>{let{purpose:t,coords:n}=e;(t===`icon`?r.feature.iconBoxes:r.feature.textBoxes).push(n.map((e=>e-100)))}))}if(c in o&&l in o[c]){let e=o[c][l];r.feature.angles=[],e.forEach((e=>{r.feature.angles.push(180*e/Math.PI)}))}c in s&&l in s[c]&&(r.feature[`placement-anchor`]=s[c][l])}function Ne(e,t,n,r,i){if(e===n&&t===r)return;let a=Math.sqrt((e-n)**2+(t-r)**2),o=(i+a)/a;return{x:e+(n-e)*o,y:t+(r-t)*o}}function Pe(e,n,r){return t._(this,void 0,void 0,(function*(){let i=e;if(e.url?i=(yield t.j(n.transformRequest(e.url,`Source`),r)).data:yield o.frameAsync(r),!i)return null;let a=t.a9(t.e(i,e),[`tiles`,`minzoom`,`maxzoom`,`attribution`,`bounds`,`scheme`,`tileSize`,`encoding`]);return`vector_layers`in i&&i.vector_layers&&(a.vectorLayerIds=i.vector_layers.map((e=>e.id))),a}))}class I{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):Array.isArray(e)&&(e.length===4?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1])))}setNorthEast(e){return this._ne=e instanceof t.aa?new t.aa(e.lng,e.lat):t.aa.convert(e),this}setSouthWest(e){return this._sw=e instanceof t.aa?new t.aa(e.lng,e.lat):t.aa.convert(e),this}extend(e){let n=this._sw,r=this._ne,i,a;if(e instanceof t.aa)i=e,a=e;else{if(!(e instanceof I))return Array.isArray(e)?e.length===4||e.every(Array.isArray)?this.extend(I.convert(e)):this.extend(t.aa.convert(e)):e&&(`lng`in e||`lon`in e)&&`lat`in e?this.extend(t.aa.convert(e)):this;if(i=e._sw,a=e._ne,!i||!a)return this}return n||r?(n.lng=Math.min(i.lng,n.lng),n.lat=Math.min(i.lat,n.lat),r.lng=Math.max(a.lng,r.lng),r.lat=Math.max(a.lat,r.lat)):(this._sw=new t.aa(i.lng,i.lat),this._ne=new t.aa(a.lng,a.lat)),this}getCenter(){return new t.aa((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new t.aa(this.getWest(),this.getNorth())}getSouthEast(){return new t.aa(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){let{lng:n,lat:r}=t.aa.convert(e),i=this._sw.lng<=n&&n<=this._ne.lng;return this._sw.lng>this._ne.lng&&(i=this._sw.lng>=n&&n>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&i}static convert(e){return e instanceof I?e:e&&new I(e)}static fromLngLat(e,n=0){let r=360*n/40075017,i=r/Math.cos(Math.PI/180*e.lat);return new I(new t.aa(e.lng-i,e.lat-r),new t.aa(e.lng+i,e.lat+r))}adjustAntiMeridian(){let e=new t.aa(this._sw.lng,this._sw.lat),n=new t.aa(this._ne.lng,this._ne.lat);return new I(e,e.lng>n.lng?new t.aa(n.lng+360,n.lat):n)}}class Fe{constructor(e,t,n){this.bounds=I.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=n||24}validateBounds(e){return Array.isArray(e)&&e.length===4?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){let n=2**e.z,r=Math.floor(t.ac(this.bounds.getWest())*n),i=Math.floor(t.ab(this.bounds.getNorth())*n),a=Math.ceil(t.ac(this.bounds.getEast())*n),o=Math.ceil(t.ab(this.bounds.getSouth())*n);return e.x>=r&&e.x<a&&e.y>=i&&e.y<o}}class Ie extends t.E{constructor(e,n,r,i){if(super(),this.id=e,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,t.e(this,t.a9(n,[`url`,`scheme`,`tileSize`,`promoteId`])),this._options=t.e({type:`vector`},n),this._collectResourceTiming=n.collectResourceTiming,this.tileSize!==512)throw Error(`vector tile sources must have a tileSize of 512`);this.setEventedParent(i)}load(){return t._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new t.l(`dataloading`,{dataType:`source`})),this._tileJSONRequest=new AbortController;try{let e=yield Pe(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,this.map.style.sourceCaches[this.id].clearTiles(),e&&(t.e(this,e),e.bounds&&(this.tileBounds=new Fe(e.bounds,this.minzoom,this.maxzoom)),this.fire(new t.l(`data`,{dataType:`source`,sourceDataType:`metadata`})),this.fire(new t.l(`data`,{dataType:`source`,sourceDataType:`content`})))}catch(e){this._tileJSONRequest=null,this.fire(new t.k(e))}}))}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}setSourceProperty(e){this._tileJSONRequest&&this._tileJSONRequest.abort(),e(),this.load()}setTiles(e){return this.setSourceProperty((()=>{this._options.tiles=e})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e})),this}onRemove(){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null)}serialize(){return t.e({},this._options)}loadTile(e){return t._(this,void 0,void 0,(function*(){let t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio()*this.map.getScale(),this.scheme),n={request:this.map._requestManager.transformRequest(t,`Tile`),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio()*this.map.getScale(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,globalState:this.map.getGlobalState()};n.request.collectResourceTiming=this._collectResourceTiming;let r=`RT`;if(e.actor&&e.state!==`expired`){if(e.state===`loading`)return new Promise(((t,n)=>{e.reloadPromise={resolve:t,reject:n}}))}else e.actor=this.dispatcher.getActor(),r=`LT`;e.abortController=new AbortController;try{let t=yield e.actor.sendAsync({type:r,data:n},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,t)}catch(t){if(delete e.abortController,e.aborted)return;if(t&&t.status!==404)throw t;this._afterTileLoadWorkerResponse(e,null)}}))}_afterTileLoadWorkerResponse(e,t){if(t&&t.resourceTiming&&(e.resourceTiming=t.resourceTiming),t&&this.map._refreshExpiredTiles&&e.setExpiryData(t),e.loadVectorData(t,this.map.painter),e.reloadPromise){let t=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(t.resolve).catch(t.reject)}}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&(yield e.actor.sendAsync({type:`AT`,data:{uid:e.uid,type:this.type,source:this.id}}))}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.unloadVectorData(),e.actor&&(yield e.actor.sendAsync({type:`RMT`,data:{uid:e.uid,type:this.type,source:this.id}}))}))}hasTransition(){return!1}}class Le extends t.E{constructor(e,n,r,i){super(),this.id=e,this.dispatcher=r,this.setEventedParent(i),this.type=`raster`,this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme=`xyz`,this.tileSize=512,this._loaded=!1,this._options=t.e({type:`raster`},n),t.e(this,t.a9(n,[`url`,`scheme`,`tileSize`]))}load(){return t._(this,arguments,void 0,(function*(e=!1){this._loaded=!1,this.fire(new t.l(`dataloading`,{dataType:`source`})),this._tileJSONRequest=new AbortController;try{let n=yield Pe(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,n&&(t.e(this,n),n.bounds&&(this.tileBounds=new Fe(n.bounds,this.minzoom,this.maxzoom)),this.fire(new t.l(`data`,{dataType:`source`,sourceDataType:`metadata`})),this.fire(new t.l(`data`,{dataType:`source`,sourceDataType:`content`,sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this.fire(new t.k(e))}}))}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null)}setSourceProperty(e){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null),e(),this.load(!0)}setTiles(e){return this.setSourceProperty((()=>{this._options.tiles=e})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e})),this}serialize(){return t.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return t._(this,void 0,void 0,(function*(){let n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio()*this.map.getScale(),this.scheme);e.abortController=new AbortController;try{let r=yield m.getImage(this.map._requestManager.transformRequest(n,`Tile`),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state=`unloaded`);if(r&&r.data){this.map._refreshExpiredTiles&&(r.cacheControl||r.expires)&&e.setExpiryData({cacheControl:r.cacheControl,expires:r.expires});let n=this.map.painter.context,i=n.gl,a=r.data;e.texture=this.map.painter.getTileTexture(a.width),e.texture?e.texture.update(a,{useMipmap:!0}):(e.texture=new t.T(n,a,i.RGBA,{useMipmap:!0}),e.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE,i.LINEAR_MIPMAP_NEAREST)),e.state=`loaded`}}catch(t){if(delete e.abortController,e.aborted)e.state=`unloaded`;else if(t)throw e.state=`errored`,t}}))}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)}))}hasTransition(){return!1}}class Re extends Le{constructor(e,n,r,i){super(e,n,r,i),this.type=`raster-dem`,this.maxzoom=22,this._options=t.e({type:`raster-dem`},n),this.encoding=n.encoding||`mapbox`,this.redFactor=n.redFactor,this.greenFactor=n.greenFactor,this.blueFactor=n.blueFactor,this.baseShift=n.baseShift}loadTile(e){return t._(this,void 0,void 0,(function*(){let n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio()*this.map.getScale(),this.scheme),r=this.map._requestManager.transformRequest(n,`Tile`);e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{let n=yield m.getImage(r,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state=`unloaded`);if(n&&n.data){let r=n.data;this.map._refreshExpiredTiles&&(n.cacheControl||n.expires)&&e.setExpiryData({cacheControl:n.cacheControl,expires:n.expires});let i=t.b(r)&&t.ad()?r:yield this.readImageNow(r),a={type:this.type,uid:e.uid,source:this.id,rawImageData:i,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};(!e.actor||e.state===`expired`)&&(e.actor=this.dispatcher.getActor(),e.dem=yield e.actor.sendAsync({type:`LDT`,data:a}),e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0),e.state=`loaded`}}catch(t){if(delete e.abortController,e.aborted)e.state=`unloaded`;else if(t)throw e.state=`errored`,t}}))}readImageNow(e){return t._(this,void 0,void 0,(function*(){if(typeof VideoFrame<`u`&&t.ae()){let n=e.width+2,r=e.height+2;try{return new t.R({width:n,height:r},yield t.af(e,-1,-1,n,r))}catch{}}return o.getImageData(e,1)}))}_getNeighboringTiles(e){let n=e.canonical,r=2**n.z,i=(n.x-1+r)%r,a=n.x===0?e.wrap-1:e.wrap,o=(n.x+1+r)%r,s=n.x+1===r?e.wrap+1:e.wrap,c={};return c[new t.ag(e.overscaledZ,a,n.z,i,n.y).key]={backfilled:!1},c[new t.ag(e.overscaledZ,s,n.z,o,n.y).key]={backfilled:!1},n.y>0&&(c[new t.ag(e.overscaledZ,a,n.z,i,n.y-1).key]={backfilled:!1},c[new t.ag(e.overscaledZ,e.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},c[new t.ag(e.overscaledZ,s,n.z,o,n.y-1).key]={backfilled:!1}),n.y+1<r&&(c[new t.ag(e.overscaledZ,a,n.z,i,n.y+1).key]={backfilled:!1},c[new t.ag(e.overscaledZ,e.wrap,n.z,n.x,n.y+1).key]={backfilled:!1},c[new t.ag(e.overscaledZ,s,n.z,o,n.y+1).key]={backfilled:!1}),c}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.demTexture&&this.map.painter.saveTileTexture(e.demTexture),e.fbo&&(e.fbo.destroy(),delete e.fbo),e.dem&&delete e.dem,delete e.neighboringTiles,e.state=`unloaded`,e.actor&&(yield e.actor.sendAsync({type:`RDT`,data:{type:this.type,uid:e.uid,source:this.id}}))}))}}class ze extends t.E{constructor(e,n,r,i){super(),this.id=e,this.type=`geojson`,this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._isUpdatingWorker=!1,this._pendingWorkerUpdate={data:n.data},this.actor=r.getActor(),this.setEventedParent(i),this._data=n.data,this._options=t.e({},n),this._collectResourceTiming=n.collectResourceTiming,n.maxzoom!==void 0&&(this.maxzoom=n.maxzoom),n.type&&(this.type=n.type),n.attribution&&(this.attribution=n.attribution),this.promoteId=n.promoteId,n.clusterMaxZoom!==void 0&&this.maxzoom<=n.clusterMaxZoom&&t.w(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${n.clusterMaxZoom}".`),this.workerOptions=t.e({source:this.id,cluster:n.cluster||!1,geojsonVtOptions:{buffer:this._pixelsToTileUnits(n.buffer===void 0?128:n.buffer),tolerance:this._pixelsToTileUnits(n.tolerance===void 0?.375:n.tolerance),extent:t.ah,maxZoom:this.maxzoom,lineMetrics:n.lineMetrics||!1,generateId:n.generateId||!1},superclusterOptions:{maxZoom:this._getClusterMaxZoom(n.clusterMaxZoom),minPoints:Math.max(2,n.clusterMinPoints||2),extent:t.ah,radius:this._pixelsToTileUnits(n.clusterRadius||50),log:!1,generateId:n.generateId||!1},clusterProperties:n.clusterProperties,filter:n.filter},n.workerOptions),typeof this.promoteId==`string`&&(this.workerOptions.promoteId=this.promoteId)}_pixelsToTileUnits(e){return e*(t.ah/this.tileSize)}_getClusterMaxZoom(e){let n=e?Math.round(e):this.maxzoom-1;return Number.isInteger(e)||e===void 0||t.w(`Integer expected for option 'clusterMaxZoom': provided value "${e}" rounded to "${n}"`),n}load(){return t._(this,void 0,void 0,(function*(){yield this._updateWorkerData()}))}onAdd(e){this.map=e,this.load()}setData(e){return this._data=e,this._pendingWorkerUpdate={data:e},this._updateWorkerData(),this}updateData(e){return this._pendingWorkerUpdate.diff=t.ai(this._pendingWorkerUpdate.diff,e),this._updateWorkerData(),this}getData(){return t._(this,void 0,void 0,(function*(){let e=t.e({type:this.type},this.workerOptions);return this.actor.sendAsync({type:`GD`,data:e})}))}getCoordinatesFromGeometry(e){return e.type===`GeometryCollection`?e.geometries.map((e=>e.coordinates)).flat(1/0):e.coordinates.flat(1/0)}getBounds(){return t._(this,void 0,void 0,(function*(){let e=new I,t=yield this.getData(),n;switch(t.type){case`FeatureCollection`:n=t.features.map((e=>this.getCoordinatesFromGeometry(e.geometry))).flat(1/0);break;case`Feature`:n=this.getCoordinatesFromGeometry(t.geometry);break;default:n=this.getCoordinatesFromGeometry(t)}if(n.length==0)return e;for(let t=0;t<n.length-1;t+=2)e.extend([n[t],n[t+1]]);return e}))}setClusterOptions(e){return this.workerOptions.cluster=e.cluster,e&&(e.clusterRadius!==void 0&&(this.workerOptions.superclusterOptions.radius=this._pixelsToTileUnits(e.clusterRadius)),e.clusterMaxZoom!==void 0&&(this.workerOptions.superclusterOptions.maxZoom=this._getClusterMaxZoom(e.clusterMaxZoom))),this._updateWorkerData(),this}getClusterExpansionZoom(e){return this.actor.sendAsync({type:`GCEZ`,data:{type:this.type,clusterId:e,source:this.id}})}getClusterChildren(e){return this.actor.sendAsync({type:`GCC`,data:{type:this.type,clusterId:e,source:this.id}})}getClusterLeaves(e,t,n){return this.actor.sendAsync({type:`GCL`,data:{type:this.type,source:this.id,clusterId:e,limit:t,offset:n}})}_updateWorkerData(){return t._(this,void 0,void 0,(function*(){if(this._isUpdatingWorker)return;let{data:e,diff:n}=this._pendingWorkerUpdate;if(!e&&!n)return void t.w(`No data or diff provided to GeoJSONSource ${this.id}.`);let r=t.e({type:this.type},this.workerOptions);e?(typeof e==`string`?(r.request=this.map._requestManager.transformRequest(o.resolveURL(e),`Source`),r.request.collectResourceTiming=this._collectResourceTiming):r.data=JSON.stringify(e),this._pendingWorkerUpdate.data=void 0):n&&(r.dataDiff=n,this._pendingWorkerUpdate.diff=void 0),this._isUpdatingWorker=!0,this.fire(new t.l(`dataloading`,{dataType:`source`}));try{let e=yield this.actor.sendAsync({type:`LD`,data:r});if(this._isUpdatingWorker=!1,this._removed||e.abandoned)return void this.fire(new t.l(`dataabort`,{dataType:`source`}));this._data=e.data;let n=null;e.resourceTiming&&e.resourceTiming[this.id]&&(n=e.resourceTiming[this.id].slice(0));let i={dataType:`source`};this._collectResourceTiming&&n&&n.length>0&&t.e(i,{resourceTiming:n}),this.fire(new t.l(`data`,Object.assign(Object.assign({},i),{sourceDataType:`metadata`}))),this.fire(new t.l(`data`,Object.assign(Object.assign({},i),{sourceDataType:`content`})))}catch(e){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new t.l(`dataabort`,{dataType:`source`}));this.fire(new t.k(e))}finally{(this._pendingWorkerUpdate.data||this._pendingWorkerUpdate.diff)&&this._updateWorkerData()}}))}loaded(){return!this._isUpdatingWorker&&this._pendingWorkerUpdate.data===void 0&&this._pendingWorkerUpdate.diff===void 0}loadTile(e){return t._(this,void 0,void 0,(function*(){let t=e.actor?`RT`:`LT`;e.actor=this.actor;let n={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio()*this.map.getScale(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,globalState:this.map.getGlobalState()};e.abortController=new AbortController;let r=yield this.actor.sendAsync({type:t,data:n},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(r,this.map.painter,t===`RT`)}))}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.unloadVectorData(),yield this.actor.sendAsync({type:`RMT`,data:{uid:e.uid,type:this.type,source:this.id}})}))}onRemove(){this._removed=!0,this.actor.sendAsync({type:`RS`,data:{type:this.type,source:this.id}})}serialize(){return t.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}class Be extends t.E{constructor(e,t,n,r){super(),this.flippedWindingOrder=!1,this.id=e,this.dispatcher=n,this.coordinates=t.coordinates,this.type=`image`,this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=t}load(e){return t._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new t.l(`dataloading`,{dataType:`source`})),this.url=this.options.url,this._request=new AbortController;try{let t=yield m.getImage(this.map._requestManager.transformRequest(this.url,`Image`),this._request);this._request=null,this._loaded=!0,t&&t.data&&(this.image=t.data,e&&(this.coordinates=e),this._finishLoading())}catch(e){this._request=null,this._loaded=!0,this.fire(new t.k(e))}}))}loaded(){return this._loaded}updateImage(e){return e.url?(this._request&&=(this._request.abort(),null),this.options.url=e.url,this.load(e.coordinates).finally((()=>{this.texture=null})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.l(`data`,{dataType:`source`,sourceDataType:`metadata`})))}onAdd(e){this.map=e,this.load()}onRemove(){this._request&&=(this._request.abort(),null)}setCoordinates(e){this.coordinates=e;let n=e.map(t.aj.fromLngLat);var r;return this.tileID=function(e){let n=t.a2.fromPoints(e),r=n.width(),i=n.height(),a=Math.max(0,Math.floor(-Math.log(Math.max(r,i))/Math.LN2)),o=2**a;return new t.al(a,Math.floor((n.minX+n.maxX)/2*o),Math.floor((n.minY+n.maxY)/2*o))}(n),this.terrainTileRanges=this._getOverlappingTileRanges(n),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=n.map((e=>this.tileID.getTilePoint(e)._round())),this.flippedWindingOrder=((r=this.tileCoords)[1].x-r[0].x)*(r[2].y-r[0].y)-(r[1].y-r[0].y)*(r[2].x-r[0].x)<0,this.fire(new t.l(`data`,{dataType:`source`,sourceDataType:`content`})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;let e=this.map.painter.context,n=e.gl;this.texture||(this.texture=new t.T(e,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let r=!1;for(let e in this.tiles){let t=this.tiles[e];t.state!==`loaded`&&(t.state=`loaded`,t.texture=this.texture,r=!0)}r&&this.fire(new t.l(`data`,{dataType:`source`,sourceDataType:`idle`,sourceId:this.id}))}loadTile(e){return t._(this,void 0,void 0,(function*(){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state=`errored`}))}serialize(){return{type:`image`,url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(e){let{minX:n,minY:r,maxX:i,maxY:a}=t.a2.fromPoints(e),o={};for(let e=0;e<=t.ak;e++){let t=2**e;o[e]={minTileX:Math.floor(n*t),minTileY:Math.floor(r*t),maxTileX:Math.floor(i*t),maxTileY:Math.floor(a*t)}}return o}}class Ve extends Be{constructor(e,t,n,r){super(e,t,n,r),this.roundZoom=!0,this.type=`video`,this.options=t}load(){return t._(this,void 0,void 0,(function*(){this._loaded=!1;let e=this.options;this.urls=[];for(let t of e.urls)this.urls.push(this.map._requestManager.transformRequest(t,`Source`).url);try{let e=yield t.am(this.urls);if(this._loaded=!0,!e)return;this.video=e,this.video.loop=!0,this.video.addEventListener(`playing`,(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading()}catch(e){this.fire(new t.k(e))}}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){let n=this.video.seekable;e<n.start(0)||e>n.end(0)?this.fire(new t.k(new t.an(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;let e=this.map.painter.context,n=e.gl;this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new t.T(e,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let r=!1;for(let e in this.tiles){let t=this.tiles[e];t.state!==`loaded`&&(t.state=`loaded`,t.texture=this.texture,r=!0)}r&&this.fire(new t.l(`data`,{dataType:`source`,sourceDataType:`idle`,sourceId:this.id}))}serialize(){return{type:`video`,urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class He extends Be{constructor(e,n,r,i){super(e,n,r,i),n.coordinates?Array.isArray(n.coordinates)&&n.coordinates.length===4&&!n.coordinates.some((e=>!Array.isArray(e)||e.length!==2||e.some((e=>typeof e!=`number`))))||this.fire(new t.k(new t.an(`sources.${e}`,null,`"coordinates" property must be an array of 4 longitude/latitude array pairs`))):this.fire(new t.k(new t.an(`sources.${e}`,null,`missing required property "coordinates"`))),n.animate&&typeof n.animate!=`boolean`&&this.fire(new t.k(new t.an(`sources.${e}`,null,`optional "animate" property must be a boolean value`))),n.canvas?typeof n.canvas==`string`||n.canvas instanceof HTMLCanvasElement||this.fire(new t.k(new t.an(`sources.${e}`,null,`"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance`))):this.fire(new t.k(new t.an(`sources.${e}`,null,`missing required property "canvas"`))),this.options=n,this.animate=n.animate===void 0||n.animate}load(){return t._(this,void 0,void 0,(function*(){this._loaded=!0,this.canvas||=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.k(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(),!1)},this._finishLoading())}))}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;let n=this.map.painter.context,r=n.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new t.T(n,this.canvas,r.RGBA,{premultiply:!0});let i=!1;for(let e in this.tiles){let t=this.tiles[e];t.state!==`loaded`&&(t.state=`loaded`,t.texture=this.texture,i=!0)}i&&this.fire(new t.l(`data`,{dataType:`source`,sourceDataType:`idle`,sourceId:this.id}))}serialize(){return{type:`canvas`,coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(let e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}}let Ue={},We=e=>{switch(e){case`geojson`:return ze;case`image`:return Be;case`raster`:return Le;case`raster-dem`:return Re;case`vector`:return Ie;case`video`:return Ve;case`canvas`:return He}return Ue[e]},Ge=`RTLPluginLoaded`;class L extends t.E{constructor(){super(...arguments),this.status=`unavailable`,this.url=null,this.dispatcher=ne()}_syncState(e){return this.status=e,this.dispatcher.broadcast(`SRPS`,{pluginStatus:e,pluginURL:this.url}).catch((e=>{throw this.status=`error`,e}))}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status=`unavailable`,this.url=null}setRTLTextPlugin(e){return t._(this,arguments,void 0,(function*(e,t=!1){if(this.url)throw Error(`setRTLTextPlugin cannot be called multiple times.`);if(this.url=o.resolveURL(e),!this.url)throw Error(`requested url ${e} is invalid`);if(this.status===`unavailable`){if(!t)return this._requestImport();this.status=`deferred`,this._syncState(this.status)}else if(this.status===`requested`)return this._requestImport()}))}_requestImport(){return t._(this,void 0,void 0,(function*(){yield this._syncState(`loading`),this.status=`loaded`,this.fire(new t.l(Ge))}))}lazyLoad(){this.status===`unavailable`?this.status=`requested`:this.status===`deferred`&&this._requestImport()}}let Ke=null;function qe(){return Ke||=new L,Ke}class Je{constructor(e,n){this.timeAdded=0,this.fadeEndTime=0,this.tileID=e,this.uid=t.ao(),this.uses=0,this.tileSize=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state=`loading`}registerFadeDuration(e){let t=e+this.timeAdded;t<this.fadeEndTime||(this.fadeEndTime=t)}wasRequested(){return this.state===`errored`||this.state===`loaded`||this.state===`reloading`}clearTextures(e){this.demTexture&&e.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(e,n,r){if(this.hasData()&&this.unloadVectorData(),this.state=`loaded`,e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestFeatureIndex.rawTileData=e.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(e,t){let n={};if(!t)return n;for(let r of e){let e=r.layerIds.map((e=>t.getLayer(e))).filter(Boolean);if(e.length!==0){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((t=>e.filter((e=>e.id===t))[0])));for(let t of e)n[t.id]=r}}return n}(e.buckets,n?.style),this.hasSymbolBuckets=!1;for(let e in this.buckets){let n=this.buckets[e];if(n instanceof t.aq){if(this.hasSymbolBuckets=!0,!r)break;n.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(let e in this.buckets){let n=this.buckets[e];if(n instanceof t.aq&&n.hasRTLText){this.hasRTLText=!0,qe().lazyLoad();break}}this.queryPadding=0;for(let e in this.buckets){let t=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,n.style.getLayer(e).queryRadius(t))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage)}else this.collisionBoxArray=new t.ap}unloadVectorData(){for(let e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&=null,this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state=`unloaded`}getBucket(e){return this.buckets[e.id]}upload(e){for(let t in this.buckets){let n=this.buckets[t];n.uploadPending()&&n.upload(e)}let n=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new t.T(e,this.imageAtlas.image,n.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&=(this.glyphAtlasTexture=new t.T(e,this.glyphAtlasImage,n.ALPHA),null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,n,r,i,a,o,s,c,l,u){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:i,scale:a,tileSize:this.tileSize,pixelPosMatrix:l,transform:s,params:o,queryPadding:this.queryPadding*c,getElevation:u},e,t,n):{}}querySourceFeatures(e,n){let r=this.latestFeatureIndex;if(!r||!r.rawTileData)return;let i=r.loadVTLayers(),a=n&&n.sourceLayer?n.sourceLayer:``,o=i._geojsonTileLayer||i[a];if(!o)return;let s=t.ar(n&&n.filter),{z:c,x:l,y:u}=this.tileID.canonical,d={z:c,x:l,y:u};for(let n=0;n<o.length;n++){let i=o.feature(n);if(s.needGeometry){let e=t.as(i,!0);if(!s.filter(new t.F(this.tileID.overscaledZ),e,this.tileID.canonical))continue}else if(!s.filter(new t.F(this.tileID.overscaledZ),i))continue;let f=r.getId(i,a),p=new t.at(i,c,l,u,f,this.tileID.wrap);p.tile=d,e.push(p)}}hasData(){return this.state===`loaded`||this.state===`reloading`||this.state===`expired`}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){let n=this.expirationTime;if(e.cacheControl){let n=t.au(e.cacheControl);n[`max-age`]&&(this.expirationTime=Date.now()+1e3*n[`max-age`])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){let e=Date.now(),t=!1;if(this.expirationTime>e)t=!1;else if(n)if(this.expirationTime<n)t=!0;else{let r=this.expirationTime-n;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(),2**31-1)}setFeatureState(e,t){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||Object.keys(e).length===0)return;let n=this.latestFeatureIndex.loadVTLayers();for(let r in this.buckets){if(!t.style.hasLayer(r))continue;let i=this.buckets[r],a=i.layers[0].sourceLayer||`_geojsonTileLayer`,o=n[a],s=e[a];if(!o||!s||Object.keys(s).length===0)continue;i.update(s,o,this.imageAtlas&&this.imageAtlas.patternPositions||{});let c=t&&t.style&&t.style.getLayer(r);c&&(this.queryPadding=Math.max(this.queryPadding,c.queryRadius(i)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<o.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(e){this.symbolFadeHoldUntil=o.now()+e}setDependencies(e,t){let n={};for(let e of t)n[e]=!0;this.dependencies[e]=n}hasDependency(e,t){for(let n of e){let e=this.dependencies[n];if(e){for(let n of t)if(e[n])return!0}}return!1}}class Ye{constructor(e,t){this.max=e,this.onRemove=t,this.reset()}reset(){for(let e in this.data)for(let t of this.data[e])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}add(e,t,n){let r=e.wrapped().key;this.data[r]===void 0&&(this.data[r]=[]);let i={value:t,timeout:void 0};if(n!==void 0&&(i.timeout=setTimeout((()=>{this.remove(e,i)}),n)),this.data[r].push(i),this.order.push(r),this.order.length>this.max){let 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){let t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),this.data[e].length===0&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){let 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;let n=e.wrapped().key,r=t===void 0?0:this.data[n].indexOf(t),i=this.data[n][r];return this.data[n].splice(r,1),i.timeout&&clearTimeout(i.timeout),this.data[n].length===0&&delete this.data[n],this.onRemove(i.value),this.order.splice(this.order.indexOf(n),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){let e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){let t=[];for(let n in this.data)for(let r of this.data[n])e(r.value)||t.push(r);for(let e of t)this.remove(e.value.tileID,e)}}class R{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,n,r){let i=String(n);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][i]=this.stateChanges[e][i]||{},t.e(this.stateChanges[e][i],r),this.deletedStates[e]===null){this.deletedStates[e]={};for(let t in this.state[e])t!==i&&(this.deletedStates[e][t]=null)}else if(this.deletedStates[e]&&this.deletedStates[e][i]===null){this.deletedStates[e][i]={};for(let t in this.state[e][i])r[t]||(this.deletedStates[e][i][t]=null)}else for(let t in r)this.deletedStates[e]&&this.deletedStates[e][i]&&this.deletedStates[e][i][t]===null&&delete this.deletedStates[e][i][t]}removeFeatureState(e,t,n){if(this.deletedStates[e]===null)return;let r=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},n&&t!==void 0)this.deletedStates[e][r]!==null&&(this.deletedStates[e][r]=this.deletedStates[e][r]||{},this.deletedStates[e][r][n]=null);else if(t!==void 0)if(this.stateChanges[e]&&this.stateChanges[e][r])for(n in this.deletedStates[e][r]={},this.stateChanges[e][r])this.deletedStates[e][r][n]=null;else this.deletedStates[e][r]=null;else this.deletedStates[e]=null}getState(e,n){let r=String(n),i=t.e({},(this.state[e]||{})[r],(this.stateChanges[e]||{})[r]);if(this.deletedStates[e]===null)return{};if(this.deletedStates[e]){let t=this.deletedStates[e][n];if(t===null)return{};for(let e in t)delete i[e]}return i}initializeTileState(e,t){e.setFeatureState(this.state,t)}coalesceChanges(e,n){let r={};for(let e in this.stateChanges){this.state[e]=this.state[e]||{};let n={};for(let r in this.stateChanges[e])this.state[e][r]||(this.state[e][r]={}),t.e(this.state[e][r],this.stateChanges[e][r]),n[r]=this.state[e][r];r[e]=n}for(let e in this.deletedStates){this.state[e]=this.state[e]||{};let n={};if(this.deletedStates[e]===null)for(let t in this.state[e])n[t]={},this.state[e][t]={};else for(let t in this.deletedStates[e]){if(this.deletedStates[e][t]===null)this.state[e][t]={};else for(let n of Object.keys(this.deletedStates[e][t]))delete this.state[e][t][n];n[t]=this.state[e][t]}r[e]=r[e]||{},t.e(r[e],n)}if(this.stateChanges={},this.deletedStates={},Object.keys(r).length!==0)for(let t in e)e[t].setFeatureState(r,n)}}let z=89.25;function B(e,n){let r=t.L(n.lat,-t.ax,t.ax);return new t.P(t.ac(n.lng)*e,t.ab(r)*e)}function Xe(e,n){return new t.aj(n.x/e,n.y/e).toLngLat()}function Ze(e){return e.cameraToCenterDistance*Math.min(.85*Math.tan(t.av(90-e.pitch)),Math.tan(t.av(z-e.pitch)))}function Qe(e,n){let r=e.canonical,i=n/t.aw(r.z),a=r.x+2**r.z*e.wrap,o=t.a4(new Float64Array(16));return t.a5(o,o,[a*i,r.y*i,0]),t.N(o,o,[i/t.ah,i/t.ah,1]),o}function V(e,n,r,i,a){let o=t.aj.fromLngLat(e,n),s=a*t.ay(1,e.lat),c=s*Math.cos(t.av(r)),l=Math.sqrt(s*s-c*c),u=l*Math.sin(t.av(-i)),d=l*Math.cos(t.av(-i));return new t.aj(o.x+u,o.y+d,o.z+c)}function $e(e,t,n){let r=t.intersectsFrustum(e);if(!n||r===0)return r;let i=t.intersectsPlane(n);return i===0?0:r===2&&i===2?2:1}function et(e,t,n){let r=0,i=(n-t)/10;for(let a=0;a<10;a++)r+=i*Math.cos(t+(a+.5)/10*(n-t))**+e;return r}function tt(e,n){return function(r,i,a,o,s){let c=2*((e-1)/t.az(Math.cos(t.av(z-s))/Math.cos(t.av(z)))-1),l=Math.acos(a/o),u=2*et(c-1,0,t.av(s/2)),d=Math.min(t.av(z),l+t.av(s/2)),f=et(c-1,Math.min(d,l-t.av(s/2)),d),p=Math.atan(i/a),m=Math.hypot(i,a),h=r;return h+=t.az(o/m/Math.max(.5,Math.cos(t.av(s/2)))),h+=c*t.az(Math.cos(p))/2,h-=t.az(Math.max(1,f/u/n))/2,h}}let nt=tt(9.314,3);function rt(e,n){let r=(n.roundZoom?Math.round:Math.floor)(e.zoom+t.az(e.tileSize/n.tileSize));return Math.max(0,r)}function it(e,n){let r=e.getCameraFrustum(),i=e.getClippingPlane(),a=e.screenPointToMercatorCoordinate(e.getCameraPoint()),o=t.aj.fromLngLat(e.center,e.elevation);a.z=o.z+Math.cos(e.pitchInRadians)*e.cameraToCenterDistance/e.worldSize;let s=e.getCoveringTilesDetailsProvider(),c=s.allowVariableZoom(e,n),l=rt(e,n),u=n.minzoom||0,d=n.maxzoom===void 0?e.maxZoom:n.maxzoom,f=Math.min(Math.max(0,l),d),p=2**f,m=[p*a.x,p*a.y,0],h=[p*o.x,p*o.y,0],g=Math.hypot(o.x-a.x,o.y-a.y),_=Math.abs(o.z-a.z),v=Math.hypot(g,_),y=e=>({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),b=[],x=[];if(e.renderWorldCopies&&s.allowWorldCopies())for(let e=1;e<=3;e++)b.push(y(-e)),b.push(y(e));for(b.push(y(0));b.length>0;){let p=b.pop(),g=p.x,y=p.y,S=p.fullyVisible,C={x:g,y,z:p.zoom},w=s.getTileBoundingVolume(C,p.wrap,e.elevation,n);if(!S){let e=$e(r,w,i);if(e===0)continue;S=e===2}let T=s.distanceToTile2d(a.x,a.y,C,w),E=l;c&&(E=(n.calculateTileZoom||nt)(e.zoom+t.az(e.tileSize/n.tileSize),T,_,v,e.fov)),E=(n.roundZoom?Math.round:Math.floor)(E),E=Math.max(0,E);let D=Math.min(E,d);if(p.wrap=s.getWrap(o,C,p.wrap),p.zoom>=D){if(p.zoom<u)continue;let e=f-p.zoom,r=m[0]-.5-(g<<e),i=m[1]-.5-(y<<e),a=n.reparseOverscaled?Math.max(p.zoom,E):p.zoom;x.push({tileID:new t.ag(p.zoom===d?a:p.zoom,p.wrap,p.zoom,g,y),distanceSq:t.aA([h[0]-.5-g,h[1]-.5-y]),tileDistanceToCamera:Math.sqrt(r*r+i*i)})}else for(let e=0;e<4;e++)b.push({zoom:p.zoom+1,x:(g<<1)+e%2,y:(y<<1)+(e>>1),wrap:p.wrap,fullyVisible:S})}return x.sort(((e,t)=>e.distanceSq-t.distanceSq)).map((e=>e.tileID))}let at=t.a2.fromPoints([new t.P(0,0),new t.P(t.ah,t.ah)]);class ot extends t.E{constructor(e,t,n){super(),this.id=e,this.dispatcher=n,this.on(`data`,(e=>this._dataHandler(e))),this.on(`dataloading`,(()=>{this._sourceErrored=!1})),this.on(`error`,(()=>{this._sourceErrored=this._source.loaded()})),this._source=((e,t,n,r)=>{let i=new(We(t.type))(e,t,n,r);if(i.id!==e)throw Error(`Expected Source id to be ${e} instead of ${i.id}`);return i})(e,t,n,this),this._tiles={},this._cache=new Ye(0,(e=>this._unloadTile(e))),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new R,this._didEmitContent=!1,this._updated=!1}onAdd(e){this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(e)}onRemove(e){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(e)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;if(!(this.used===void 0&&this.usedForTerrain===void 0||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(let e in this._tiles){let t=this._tiles[e];if(t.state!==`loaded`&&t.state!==`errored`)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;let e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(e,n,r){return t._(this,void 0,void 0,(function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,n,r)}catch(n){e.state=`errored`,n.status===404?this.update(this.transform,this.terrain):this._source.fire(new t.k(n,{tile:e}))}}))}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e)}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new t.l(`dataabort`,{tile:e,coord:e.tileID,dataType:`source`}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(let t in this._tiles){let n=this._tiles[t];n.upload(e),n.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map((e=>e.tileID)).sort(st).map((e=>e.key))}getRenderableIds(e){let n=[];for(let t in this._tiles)this._isIdRenderable(t,e)&&n.push(this._tiles[t]);return e?n.sort(((e,n)=>{let r=e.tileID,i=n.tileID,a=new t.P(r.canonical.x,r.canonical.y)._rotate(-this.transform.bearingInRadians),o=new t.P(i.canonical.x,i.canonical.y)._rotate(-this.transform.bearingInRadians);return r.overscaledZ-i.overscaledZ||o.y-a.y||o.x-a.x})).map((e=>e.tileID.key)):n.map((e=>e.tileID)).sort(st).map((e=>e.key))}hasRenderableParent(e){let t=this.findLoadedParent(e,0);return!!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())}reload(e){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(let t in this._tiles)e?this._reloadTile(t,`expired`):this._tiles[t].state!==`errored`&&this._reloadTile(t,`reloading`)}}_reloadTile(e,n){return t._(this,void 0,void 0,(function*(){let t=this._tiles[e];t&&(t.state!==`loading`&&(t.state=n),yield this._loadTile(t,e,n))}))}_tileLoaded(e,n,r){e.timeAdded=o.now(),r===`expired`&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(n,e),this.getSource().type===`raster-dem`&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new t.l(`data`,{dataType:`source`,tile:e,coord:e.tileID}))}_backfillDEM(e){let t=this.getRenderableIds();for(let r=0;r<t.length;r++){let i=t[r];if(e.neighboringTiles&&e.neighboringTiles[i]){let t=this.getTileByID(i);n(e,t),n(t,e)}}function n(e,t){e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0;let n=t.tileID.canonical.x-e.tileID.canonical.x,r=t.tileID.canonical.y-e.tileID.canonical.y,i=2**e.tileID.canonical.z,a=t.tileID.key;n===0&&r===0||Math.abs(r)>1||(Math.abs(n)>1&&(Math.abs(n+i)===1?n+=i:Math.abs(n-i)===1&&(n-=i)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,n,r),e.neighboringTiles&&e.neighboringTiles[a]&&(e.neighboringTiles[a].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,n,r){for(let i in this._tiles){let a=this._tiles[i];if(r[i]||!a.hasData()||a.tileID.overscaledZ<=t||a.tileID.overscaledZ>n)continue;let o=a.tileID;for(;a&&a.tileID.overscaledZ>t+1;){let e=a.tileID.scaledTo(a.tileID.overscaledZ-1);a=this._tiles[e.key],a&&a.hasData()&&(o=e)}let s=o;for(;s.overscaledZ>t;)if(s=s.scaledTo(s.overscaledZ-1),e[s.key]||e[s.canonical.key]){r[o.key]=o;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){let n=this._loadedParentTiles[e.key];return n&&n.tileID.overscaledZ>=t?n:null}for(let n=e.overscaledZ-1;n>=t;n--){let t=e.scaledTo(n),r=this._getLoadedTile(t);if(r)return r}}findLoadedSibling(e){return this._getLoadedTile(e)}_getLoadedTile(e){let t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(e.wrapped().key)}updateCacheSize(e){let n=Math.ceil(e.width/this._source.tileSize)+1,r=Math.ceil(e.height/this._source.tileSize)+1,i=Math.floor(n*r*(this._maxTileCacheZoomLevels===null?t.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),a=typeof this._maxTileCacheSize==`number`?Math.min(this._maxTileCacheSize,i):i;this._cache.setMaxSize(a)}handleWrapJump(e){let t=Math.round((e-(this._prevLng===void 0?e:this._prevLng))/360);if(this._prevLng=e,t){let e={};for(let n in this._tiles){let r=this._tiles[n];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),e[r.tileID.key]=r}this._tiles=e;for(let e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(let e in this._tiles)this._setTileReloadTimer(e,this._tiles[e])}}_updateCoveredAndRetainedTiles(e,t,n,r,i,a){let s={},c={},l=Object.keys(e),u=o.now();for(let n of l){let r=e[n],i=this._tiles[n];if(!i||i.fadeEndTime!==0&&i.fadeEndTime<=u)continue;let a=this.findLoadedParent(r,t),o=this.findLoadedSibling(r),l=a||o||null;l&&(this._addTile(l.tileID),s[l.tileID.key]=l.tileID),c[n]=r}this._retainLoadedChildren(c,r,n,e);for(let t in s)e[t]||(this._coveredTiles[t]=!0,e[t]=s[t]);if(a){let t={},n={};for(let e of i)this._tiles[e.key].hasData()?t[e.key]=e:n[e.key]=e;for(let r in n){let i=n[r].children(this._source.maxzoom);this._tiles[i[0].key]&&this._tiles[i[1].key]&&this._tiles[i[2].key]&&this._tiles[i[3].key]&&(t[i[0].key]=e[i[0].key]=i[0],t[i[1].key]=e[i[1].key]=i[1],t[i[2].key]=e[i[2].key]=i[2],t[i[3].key]=e[i[3].key]=i[3],delete n[r])}for(let r in n){let i=n[r],a=this.findLoadedParent(i,this._source.minzoom),o=this.findLoadedSibling(i),s=a||o||null;if(s){t[s.tileID.key]=e[s.tileID.key]=s.tileID;for(let e in t)t[e].isChildOf(s.tileID)&&delete t[e]}}for(let e in this._tiles)t[e]||(this._coveredTiles[e]=!0)}}update(e,n){if(!this._sourceLoaded||this._paused)return;let r;this.transform=e,this.terrain=n,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?r=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new t.ag(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(r=it(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:n,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(r=r.filter((e=>this._source.hasTile(e))))):r=[];let i=rt(e,this._source),a=Math.max(i-ot.maxOverzooming,this._source.minzoom),o=Math.max(i+ot.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){let e={};for(let t of r)if(t.canonical.z>this._source.minzoom){let n=t.scaledTo(t.canonical.z-1);e[n.key]=n;let r=t.scaledTo(Math.max(this._source.minzoom,Math.min(t.canonical.z,5)));e[r.key]=r}r=r.concat(Object.values(e))}let s=r.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,s&&this.fire(new t.l(`data`,{sourceDataType:`idle`,dataType:`source`,sourceId:this.id}));let c=this._updateRetainedTiles(r,i);ct(this._source.type)&&this._updateCoveredAndRetainedTiles(c,a,o,i,r,n);for(let e in c)this._tiles[e].clearFadeHold();let l=t.aB(this._tiles,c);for(let e of l){let t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(e)}this._updateLoadedParentTileCache(),this._updateLoadedSiblingTileCache()}releaseSymbolFadeTiles(){for(let e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(e)}_updateRetainedTiles(e,t){let n={},r={},i=Math.max(t-ot.maxOverzooming,this._source.minzoom),a=Math.max(t+ot.maxUnderzooming,this._source.minzoom),o={};for(let r of e){let e=this._addTile(r);n[r.key]=r,e.hasData()||t<this._source.maxzoom&&(o[r.key]=r)}this._retainLoadedChildren(o,t,a,n);for(let a of e){let e=this._tiles[a.key];if(e.hasData())continue;if(t+1>this._source.maxzoom){let e=a.children(this._source.maxzoom)[0],t=this.getTile(e);if(t&&t.hasData()){n[e.key]=e;continue}}else{let e=a.children(this._source.maxzoom);if(e.length===4&&n[e[0].key]&&n[e[1].key]&&n[e[2].key]&&n[e[3].key])continue}let o=e.wasRequested();for(let t=a.overscaledZ-1;t>=i;--t){let i=a.scaledTo(t);if(r[i.key])break;if(r[i.key]=!0,e=this.getTile(i),!e&&o&&(e=this._addTile(i)),e){let t=e.hasData();if((t||!this.map?.cancelPendingTileRequestsWhileZooming||o)&&(n[i.key]=i),o=e.wasRequested(),t)break}}}return n}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(let e in this._tiles){let t=[],n,r=this._tiles[e].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){n=this._loadedParentTiles[r.key];break}t.push(r.key);let e=r.scaledTo(r.overscaledZ-1);if(n=this._getLoadedTile(e),n)break;r=e}for(let e of t)this._loadedParentTiles[e]=n}}_updateLoadedSiblingTileCache(){this._loadedSiblingTiles={};for(let e in this._tiles){let t=this._tiles[e].tileID,n=this._getLoadedTile(t);this._loadedSiblingTiles[t.key]=n}}_addTile(e){let n=this._tiles[e.key];if(n)return n;n=this._cache.getAndRemove(e),n&&(this._setTileReloadTimer(e.key,n),n.tileID=e,this._state.initializeTileState(n,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,n)));let r=n;return n||(n=new Je(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(n,e.key,n.state)),n.uses++,this._tiles[e.key]=n,r||this._source.fire(new t.l(`dataloading`,{tile:n,coord:n.tileID,dataType:`source`})),n}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);let n=t.getExpiryTimeout();n&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,`expired`),delete this._timers[e]}),n))}refreshTiles(e){for(let t in this._tiles)(this._isIdRenderable(t)||this._tiles[t].state==`errored`)&&e.some((e=>e.equals(this._tiles[t].tileID.canonical)))&&this._reloadTile(t,`expired`)}_removeTile(e){let 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()&&t.state!==`reloading`?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))))}_dataHandler(e){let t=e.sourceDataType;e.dataType===`source`&&t===`metadata`&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&e.dataType===`source`&&t===`content`&&(this.reload(e.sourceDataChanged),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(let e in this._tiles)this._removeTile(e);this._cache.reset()}tilesIn(e,n,r,i){let a=[],o=this.transform;if(!o)return a;let s=o.getCoveringTilesDetailsProvider().allowWorldCopies(),c=r?o.getCameraQueryGeometry(e):e,l=e=>o.screenPointToMercatorCoordinate(e,this.terrain),u=this.transformBbox(e,l,!s),d=this.transformBbox(c,l,!s),f=this.getIds(),p=t.a2.fromPoints(d);for(let e=0;e<f.length;e++){let r=this._tiles[f[e]];if(r.holdingForFade())continue;let c=s?[r.tileID]:[r.tileID.unwrapTo(-1),r.tileID.unwrapTo(0)],l=2**(o.zoom-r.tileID.overscaledZ),m=n*r.queryPadding*t.ah/r.tileSize/l;for(let e of c){let n=p.map((n=>e.getTilePoint(new t.aj(n.x,n.y))));if(n.expandBy(m),i||n.intersects(at)){let t=u.map((t=>e.getTilePoint(t))),n=d.map((t=>e.getTilePoint(t)));a.push({tile:r,tileID:s?e:e.unwrapTo(0),queryGeometry:t,cameraQueryGeometry:n,scale:l})}}}return a}transformBbox(e,n,r){let i=e.map(n);if(r){let r=t.a2.fromPoints(e);r.shrinkBy(.001*Math.min(r.width(),r.height()));let a=r.map(n);t.a2.fromPoints(i).covers(a)||(i=i.map((e=>e.x>.5?new t.aj(e.x-1,e.y,e.z):e)))}return i}getVisibleCoordinates(e){let t=this.getRenderableIds(e).map((e=>this._tiles[e].tileID));return this.transform&&this.transform.populateCache(t),t}hasTransition(){if(this._source.hasTransition())return!0;if(ct(this._source.type)){let e=o.now();for(let t in this._tiles)if(this._tiles[t].fadeEndTime>=e)return!0}return!1}setFeatureState(e,t,n){this._state.updateState(e||=`_geojsonTileLayer`,t,n)}removeFeatureState(e,t,n){this._state.removeFeatureState(e||=`_geojsonTileLayer`,t,n)}getFeatureState(e,t){return this._state.getState(e||=`_geojsonTileLayer`,t)}setDependencies(e,t,n){let r=this._tiles[e];r&&r.setDependencies(t,n)}reloadTilesForDependencies(e,t){for(let n in this._tiles)this._tiles[n].hasDependency(e,t)&&this._reloadTile(n,`reloading`);this._cache.filter((n=>!n.hasDependency(e,t)))}}function st(e,t){let n=Math.abs(2*e.wrap)-+(e.wrap<0),r=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-n||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function ct(e){return e===`raster`||e===`image`||e===`video`}ot.maxOverzooming=10,ot.maxUnderzooming=3;class lt{constructor(e,t,n,r){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):r&&n?1:0,this.placed=n}isHidden(){return this.opacity===0&&!this.placed}}class ut{constructor(e,t,n,r,i){this.text=new lt(e?e.text:null,t,n,i),this.icon=new lt(e?e.icon:null,t,r,i)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class dt{constructor(e,t,n){this.text=e,this.icon=t,this.skipFade=n}}class ft{constructor(e,t,n,r,i){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=n,this.bucketIndex=r,this.tileID=i}}class pt{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){let t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:e=>e.collisionGroupID===t}}return this.collisionGroups[e]}}function mt(e,n,r,i,a){let{horizontalAlign:o,verticalAlign:s}=t.aH(e);return new t.P(-(o-.5)*n+i[0]*a,-(s-.5)*r+i[1]*a)}class ht{constructor(e,t,n,r,i,a,o){this.transform=e.clone(),this.terrain=t,this.collisionIndex=new De(this.transform,a,o),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=n,this.retainedQueryData={},this.collisionGroups=new pt(r),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.glyphCircles={},this.placedBoxes={},this.anchorAngles={},this.variableAnchors={},this.prevPlacement=i,i&&(i.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){let t=this.terrain;return t?(n,r)=>t.getElevation(e,n,r):null}getBucketParts(e,n,r,i){let a=r.getBucket(n),o=r.latestFeatureIndex;if(!a||!o||n.id!==a.layerIds[0])return;let s=r.collisionBoxArray,c=a.layers[0].layout,l=a.layers[0].paint,u=2**(this.transform.zoom-r.tileID.overscaledZ),d=r.tileSize/t.ah,f=r.tileID.toUnwrapped(),p=c.get(`text-rotation-alignment`)===`map`,m=t.aC(r,1,this.transform.zoom,this.transform.detailLevel),h=t.aD(this.collisionIndex.transform,r,l.get(`text-translate`),l.get(`text-translate-anchor`)),g=t.aD(this.collisionIndex.transform,r,l.get(`icon-translate`),l.get(`icon-translate-anchor`)),_=oe(p,this.transform,m);this.retainedQueryData[a.bucketInstanceId]=new ft(a.bucketInstanceId,o,a.sourceLayerIndex,a.index,r.tileID);let v={bucket:a,layout:c,translationText:h,translationIcon:g,unwrappedTileID:f,pitchedLabelPlaneMatrix:_,scale:u,textPixelRatio:d,holdingForFade:r.holdingForFade(),collisionBoxArray:s,partiallyEvaluatedTextSize:t.O(a.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(i)for(let t of a.sortKeyRanges){let{sortKey:n,symbolInstanceStart:r,symbolInstanceEnd:i}=t;e.push({sortKey:n,symbolInstanceStart:r,symbolInstanceEnd:i,parameters:v})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:v})}attemptAnchorPlacement(e,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b){let x=t.aE[e.textAnchor],S=[e.textOffset0,e.textOffset1],C=mt(x,r,i,S,a),w=this.collisionIndex.placeCollisionBox(n,f,c,l,u,s,o,g,d.predicate,y,C,b);if((!v||this.collisionIndex.placeCollisionBox(v,f,c,l,u,s,o,_,d.predicate,y,C,b).placeable)&&w.placeable){let e;if(this.prevPlacement&&this.prevPlacement.variableOffsets[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID].text&&(e=this.prevPlacement.variableOffsets[p.crossTileID].anchor),p.crossTileID===0)throw Error(`symbolInstance.crossTileID can't be 0`);return this.variableOffsets[p.crossTileID]={textOffset:S,width:r,height:i,anchor:x,textBoxScale:a,prevAnchor:e},this.markUsedJustification(m,x,p,h),m.allowVerticalPlacement&&(this.markUsedOrientation(m,h,p),this.placedOrientations[p.crossTileID]=h),{shift:C,placedGlyphBoxes:w}}}placeLayerBucketPart(e,n,r){let{bucket:i,layout:a,translationText:o,translationIcon:s,unwrappedTileID:c,pitchedLabelPlaneMatrix:l,textPixelRatio:u,holdingForFade:d,collisionBoxArray:f,partiallyEvaluatedTextSize:p,collisionGroup:m}=e.parameters,h=a.get(`text-optional`),g=a.get(`icon-optional`),_=t.aF(a,`text-overlap`,`text-allow-overlap`),v=_===`always`,y=t.aF(a,`icon-overlap`,`icon-allow-overlap`),b=y===`always`,x=a.get(`text-rotation-alignment`)===`map`,S=a.get(`text-pitch-alignment`)===`map`,C=a.get(`icon-text-fit`)!==`none`,w=a.get(`symbol-z-order`)===`viewport-y`,T=v&&(b||!i.hasIconData()||g),E=b&&(v||!i.hasTextData()||h);!i.collisionArrays&&f&&i.deserializeCollisionBoxes(f);let D=this.retainedQueryData[i.bucketInstanceId].tileID,O=this._getTerrainElevationFunc(D),k=this.transform.getFastPathSimpleProjectionMatrix(D),A=(e,f,b)=>{if(n[e.crossTileID])return;if(d)return void(this.placements[e.crossTileID]=new dt(!1,!1,!1));let w=!1,A=!1,j=!0,M=null,N={box:null,placeable:!1,offscreen:null,occluded:!1},P={placeable:!1},ee=null,te=null,F=null,ne=0,re=0,ie=0;f.textFeatureIndex?ne=f.textFeatureIndex:e.useRuntimeCollisionCircles&&(ne=e.featureIndex),f.verticalTextFeatureIndex&&(re=f.verticalTextFeatureIndex);let ae=f.textBox;if(ae){let n=n=>{let r=t.W.horizontal;if(i.allowVerticalPlacement&&!n&&this.prevPlacement){let t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,r=t,this.markUsedOrientation(i,r,e))}return r},a=(n,r)=>{if(i.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&f.verticalTextBox){for(let e of i.writingModes)if(e===t.W.vertical?(N=r(),P=N):N=n(),N&&N.placeable)break}else N=n()},l=e.textAnchorOffsetStartIndex,d=e.textAnchorOffsetEndIndex;if(d===l){let r=(t,n)=>{let r=this.collisionIndex.placeCollisionBox(t,_,u,D,c,S,x,o,m.predicate,O,void 0,k);return r&&r.placeable&&(this.markUsedOrientation(i,n,e),this.placedOrientations[e.crossTileID]=n),r};a((()=>r(ae,t.W.horizontal)),(()=>{let n=f.verticalTextBox;return i.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&n?r(n,t.W.vertical):{box:null,offscreen:null}})),n(N&&N.placeable)}else{let p=t.aE[this.prevPlacement?.variableOffsets[e.crossTileID]?.anchor],h=(n,a,f)=>{let h=n.x2-n.x1,g=n.y2-n.y1,v=e.textBoxScale,b=C&&y===`never`?a:null,T=null,E=_===`never`?1:2,A=`never`;p&&E++;for(let r=0;r<E;r++){for(let r=l;r<d;r++){let a=i.textAnchorOffsets.get(r);if(p&&a.textAnchor!==p)continue;let l=this.attemptAnchorPlacement(a,n,h,g,v,x,S,u,D,c,m,A,e,i,f,o,s,b,O);if(l&&(T=l.placedGlyphBoxes,T&&T.placeable))return w=!0,M=l.shift,this.addVariableAnchor(i.bucketInstanceId,ne,t.aE[a.textAnchor]),T}p?p=null:A=_}return r&&!T&&(T={box:this.collisionIndex.placeCollisionBox(ae,`always`,u,D,c,S,x,o,m.predicate,O,void 0,k).box,offscreen:!1,placeable:!1,occluded:!1}),T};a((()=>h(ae,f.iconBox,t.W.horizontal)),(()=>{let n=f.verticalTextBox;return i.allowVerticalPlacement&&(!N||!N.placeable)&&e.numVerticalGlyphVertices>0&&n?h(n,f.verticalIconBox,t.W.vertical):{box:null,occluded:!0,offscreen:null}})),N&&(w=N.placeable,j=N.offscreen);let g=n(N&&N.placeable);if(!w&&this.prevPlacement){let t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(i,t.anchor,e,g))}}}if(ee=N,w=ee&&ee.placeable,j=ee&&ee.offscreen,e.useRuntimeCollisionCircles){let n=i.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),s=t.Q(i.textSizeData,p,n),u=a.get(`text-padding`);te=this.collisionIndex.placeCollisionCircles(_,n,i.lineVertexArray,i.glyphOffsetArray,s,c,l,r,S,m.predicate,e.collisionCircleDiameter,u,o,O),te.circles.length&&te.collisionDetected&&!r&&t.w(`Collisions detected, but collision boxes are not shown`),w=v||te.circles.length>0&&!te.collisionDetected,j&&=te.offscreen}if(f.iconFeatureIndex&&(ie=f.iconFeatureIndex),f.iconBox){let e=e=>this.collisionIndex.placeCollisionBox(e,y,u,D,c,S,x,s,m.predicate,O,C&&M?M:void 0,k);P&&P.placeable&&f.verticalIconBox?(F=e(f.verticalIconBox),A=F.placeable):(F=e(f.iconBox),A=F.placeable),j&&=F.offscreen}let oe=h||e.numHorizontalGlyphVertices===0&&e.numVerticalGlyphVertices===0,se=g||e.numIconVertices===0;oe||se?se?oe||(A&&=w):w=A&&w:A=w=A&&w;let ce=A&&F.placeable;if(w&&ee.placeable&&(P&&P.placeable&&re?this.collisionIndex.insertCollisionBox(ee.box,_,a.get(`text-ignore-placement`),i.bucketInstanceId,re,m.ID):(this.collisionIndex.insertCollisionBox(ee.box,_,a.get(`text-ignore-placement`),i.bucketInstanceId,ne,m.ID),this.addPlacedBox(i.bucketInstanceId,ne,ee.box,`text`))),ce&&(this.collisionIndex.insertCollisionBox(F.box,y,a.get(`icon-ignore-placement`),i.bucketInstanceId,ie,m.ID),this.addPlacedBox(i.bucketInstanceId,ie,F.box,`icon`)),(w||A)&&this.addAnchorAngle(i.bucketInstanceId,ne,e.angle),te&&w&&(this.collisionIndex.insertCollisionCircles(te.circles,_,a.get(`text-ignore-placement`),i.bucketInstanceId,ne,m.ID),j||this.addGlyphCircles(i.bucketInstanceId,ne,te.circles)),r&&this.storeCollisionData(i.bucketInstanceId,b,f,ee,F,te),e.crossTileID===0)throw Error(`symbolInstance.crossTileID can't be 0`);if(i.bucketInstanceId===0)throw Error(`bucket.bucketInstanceId can't be 0`);this.placements[e.crossTileID]=new dt((w||T)&&!ee?.occluded,(A||E)&&!F?.occluded,j||i.justReloaded),n[e.crossTileID]=!0};if(w){if(e.symbolInstanceStart!==0)throw Error(`bucket.bucketInstanceId should be 0`);let t=i.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=t.length-1;e>=0;--e){let n=t[e];A(i.symbolInstances.get(n),i.collisionArrays[n],n)}}else for(let t=e.symbolInstanceStart;t<e.symbolInstanceEnd;t++)A(i.symbolInstances.get(t),i.collisionArrays[t],t);i.justReloaded=!1}storeCollisionData(e,t,n,r,i,a){if(n.textBox||n.iconBox){let a,o;this.collisionBoxArrays.has(e)?a=this.collisionBoxArrays.get(e):(a=new Map,this.collisionBoxArrays.set(e,a)),a.has(t)?o=a.get(t):(o={text:null,icon:null},a.set(t,o)),n.textBox&&(o.text=r.box),n.iconBox&&(o.icon=i.box)}if(a){let t=this.collisionCircleArrays[e];t===void 0&&(t=this.collisionCircleArrays[e]=[]);for(let e=0;e<a.circles.length;e+=4)t.push(a.circles[e+0]-100),t.push(a.circles[e+1]-100),t.push(a.circles[e+2]),t.push(a.collisionDetected?1:0)}}markUsedJustification(e,n,r,i){let a;a=i===t.W.vertical?r.verticalPlacedTextSymbolIndex:{left:r.leftJustifiedTextSymbolIndex,center:r.centerJustifiedTextSymbolIndex,right:r.rightJustifiedTextSymbolIndex}[t.aG(n)];let o=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex,r.verticalPlacedTextSymbolIndex];for(let t of o)t>=0&&(e.text.placedSymbolArray.get(t).crossTileID=a>=0&&t!==a?0:r.crossTileID)}markUsedOrientation(e,n,r){let i=n===t.W.horizontal||n===t.W.horizontalOnly?n:0,a=n===t.W.vertical?n:0,o=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];for(let t of o)e.text.placedSymbolArray.get(t).placedOrientation=i;r.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).placedOrientation=a)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;let t=this.prevPlacement,n=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;let r=t?t.symbolFadeChange(e):1,i=t?t.opacities:{},a=t?t.variableOffsets:{},o=t?t.placedOrientations:{};for(let e in this.placements){let t=this.placements[e],a=i[e];a?(this.opacities[e]=new ut(a,r,t.text,t.icon),n=n||t.text!==a.text.placed||t.icon!==a.icon.placed):(this.opacities[e]=new ut(null,r,t.text,t.icon,t.skipFade),n=n||t.text||t.icon)}for(let e in i){let t=i[e];if(!this.opacities[e]){let i=new ut(t,r,!1,!1);i.isHidden()||(this.opacities[e]=i,n=n||t.text.placed||t.icon.placed)}}for(let e in a)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=a[e]);for(let e in o)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=o[e]);if(t&&t.lastPlacementChangeTime===void 0)throw Error(`Last placement time for previous placement is not defined`);n?this.lastPlacementChangeTime=e:typeof this.lastPlacementChangeTime!=`number`&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){let n={};for(let r of t){let t=r.getBucket(e);t&&r.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,r.tileID,n,r.collisionBoxArray)}}updateBucketOpacities(e,n,r,i){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();let a=e.layers[0],o=a.layout,s=new ut(null,0,!1,!1,!0),c=o.get(`text-allow-overlap`),l=o.get(`icon-allow-overlap`),u=a._unevaluatedLayout.hasValue(`text-variable-anchor`)||a._unevaluatedLayout.hasValue(`text-variable-anchor-offset`),d=o.get(`text-rotation-alignment`)===`map`,f=o.get(`text-pitch-alignment`)===`map`,p=o.get(`icon-text-fit`)!==`none`,m=new ut(null,0,c&&(l||!e.hasIconData()||o.get(`icon-optional`)),l&&(c||!e.hasTextData()||o.get(`text-optional`)),!0);!e.collisionArrays&&i&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(i);let h=(e,t,n)=>{for(let r=0;r<t/4;r++)e.opacityVertexArray.emplaceBack(n);e.hasVisibleVertices=e.hasVisibleVertices||n!==St},g=this.collisionBoxArrays.get(e.bucketInstanceId);for(let n=0;n<e.symbolInstances.length;n++){let i=e.symbolInstances.get(n),{numHorizontalGlyphVertices:a,numVerticalGlyphVertices:o,crossTileID:c}=i,l=this.opacities[c];r[c]?l=s:l||(l=m,this.opacities[c]=l),r[c]=!0;let _=i.numIconVertices>0,v=this.placedOrientations[i.crossTileID],y=v===t.W.vertical,b=v===t.W.horizontal||v===t.W.horizontalOnly;if(a>0||o>0){let t=xt(l.text);h(e.text,a,y?St:t),h(e.text,o,b?St:t);let n=l.text.isHidden();[i.rightJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.leftJustifiedTextSymbolIndex].forEach((t=>{t>=0&&(e.text.placedSymbolArray.get(t).hidden=n||y?1:0)})),i.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(i.verticalPlacedTextSymbolIndex).hidden=n||b?1:0);let r=this.variableOffsets[i.crossTileID];r&&this.markUsedJustification(e,r.anchor,i,v);let s=this.placedOrientations[i.crossTileID];s&&(this.markUsedJustification(e,`left`,i,s),this.markUsedOrientation(e,s,i))}if(_){let t=xt(l.icon),n=!(p&&i.verticalPlacedIconSymbolIndex&&y);i.placedIconSymbolIndex>=0&&(h(e.icon,i.numIconVertices,n?t:St),e.icon.placedSymbolArray.get(i.placedIconSymbolIndex).hidden=l.icon.isHidden()),i.verticalPlacedIconSymbolIndex>=0&&(h(e.icon,i.numVerticalIconVertices,n?St:t),e.icon.placedSymbolArray.get(i.verticalPlacedIconSymbolIndex).hidden=l.icon.isHidden())}let x=g&&g.has(n)?g.get(n):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){let r=e.collisionArrays[n];if(r){let n=new t.P(0,0);if(r.textBox||r.verticalTextBox){let t=!0;if(u){let e=this.variableOffsets[c];e?(n=mt(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),d&&n._rotate(f?-this.transform.bearingInRadians:this.transform.bearingInRadians)):t=!1}if(r.textBox||r.verticalTextBox){let i;r.textBox&&(i=y),r.verticalTextBox&&(i=b),gt(e.textCollisionBox.collisionVertexArray,l.text.placed,!t||i,x.text,n.x,n.y)}}if(r.iconBox||r.verticalIconBox){let t=!!(!b&&r.verticalIconBox),i;r.iconBox&&(i=t),r.verticalIconBox&&(i=!t),gt(e.iconCollisionBox.collisionVertexArray,l.icon.placed,i,x.icon,p?n.x:0,p?n.y:0)}}}}if(e.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.bucketInstanceId])}symbolFadeChange(e){return this.fadeDuration===0?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){let n=this.zoomAtLastRecencyCheck===t?1-this.zoomAdjustment(t):1;return this.zoomAtLastRecencyCheck=t,this.commitTime+this.fadeDuration*n>e}setStale(){this.stale=!0}addGlyphCircles(e,t,n){e in this.glyphCircles||(this.glyphCircles[e]={}),t in this.glyphCircles[e]||(this.glyphCircles[e][t]=[]),this.glyphCircles[e][t].push(n)}addPlacedBox(e,t,n,r){e in this.placedBoxes||(this.placedBoxes[e]={}),t in this.placedBoxes[e]||(this.placedBoxes[e][t]=[]),this.placedBoxes[e][t].push({purpose:r,coords:n})}addAnchorAngle(e,t,n){e in this.anchorAngles||(this.anchorAngles[e]={}),t in this.anchorAngles[e]||(this.anchorAngles[e][t]=[]),this.anchorAngles[e][t].push(n)}addVariableAnchor(e,t,n){e in this.variableAnchors||(this.variableAnchors[e]={}),this.variableAnchors[e][t]=n}}function gt(e,t,n,r,i,a){r&&r.length!==0||(r=[0,0,0,0]);let o=r[0]-100,s=r[1]-100,c=r[2]-100,l=r[3]-100;e.emplaceBack(t?1:0,n?1:0,i||0,a||0,o,s),e.emplaceBack(t?1:0,n?1:0,i||0,a||0,c,s),e.emplaceBack(t?1:0,n?1:0,i||0,a||0,c,l),e.emplaceBack(t?1:0,n?1:0,i||0,a||0,o,l)}let _t=2**25,vt=2**24,yt=2**17,bt=2**16;function xt(e){if(e.opacity===0&&!e.placed)return 0;if(e.opacity===1&&e.placed)return 4294967295;let t=e.placed?1:0,n=Math.floor(127*e.opacity);return n*_t+t*vt+n*yt+t*bt+n*512+t*256+n*2+t}let St=0;class Ct{constructor(e){this._sortAcrossTiles=e.layout.get(`symbol-z-order`)!==`viewport-y`&&!e.layout.get(`symbol-sort-key`).isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,t,n,r,i){let a=this._bucketParts;for(;this._currentTileIndex<e.length;)if(t.getBucketParts(a,r,e[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,i())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,a.sort(((e,t)=>e.sortKey-t.sortKey)));this._currentPartIndex<a.length;)if(t.placeLayerBucketPart(a[this._currentPartIndex],this._seenCrossTileIDs,n),this._currentPartIndex++,i())return!0;return!1}}class wt{constructor(e,t,n,r,i,a,o,s,c,l){this.placement=new ht(e,t,a,o,s,c,l),this._currentPlacementIndex=n.length-1,this._forceFullPlacement=r,this._showCollisionBoxes=i,this._done=!1}isDone(){return this._done}continuePlacement(e,t,n){let r=o.now(),i=()=>!this._forceFullPlacement&&o.now()-r>2;for(;this._currentPlacementIndex>=0;){let r=t[e[this._currentPlacementIndex]],a=this.placement.collisionIndex.transform.zoom;if(r.type===`symbol`&&(!r.minzoom||r.minzoom<=a)&&(!r.maxzoom||r.maxzoom>a)){if(this._inProgressLayer||=new Ct(r),this._inProgressLayer.continuePlacement(n[r.source],this.placement,this._showCollisionBoxes,r,i))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}let Tt=512/t.ah/2;class Et{constructor(e,n,r){this.tileID=e,this.bucketInstanceId=r,this._symbolsByKey={};let i=new Map;for(let e=0;e<n.length;e++){let t=n.get(e),r=t.key,a=i.get(r);a?a.push(t):i.set(r,[t])}for(let[e,n]of i){let r={positions:n.map((e=>({x:Math.floor(e.anchorX*Tt),y:Math.floor(e.anchorY*Tt)}))),crossTileIDs:n.map((e=>e.crossTileID))};if(r.positions.length>128){let e=new t.aI(r.positions.length,16,Uint16Array);for(let{x:t,y:n}of r.positions)e.add(t,n);e.finish(),delete r.positions,r.index=e}this._symbolsByKey[e]=r}}getScaledCoordinates(e,n){let{x:r,y:i,z:a}=this.tileID.canonical,{x:o,y:s,z:c}=n.canonical,l=Tt/2**(c-a),u=(s*t.ah+e.anchorY)*l,d=i*t.ah*Tt;return{x:Math.floor((o*t.ah+e.anchorX)*l-r*t.ah*Tt),y:Math.floor(u-d)}}findMatches(e,t,n){let r=this.tileID.canonical.z<t.canonical.z?1:2**(this.tileID.canonical.z-t.canonical.z);for(let i=0;i<e.length;i++){let a=e.get(i);if(a.crossTileID)continue;let o=this._symbolsByKey[a.key];if(!o)continue;let s=this.getScaledCoordinates(a,t);if(o.index){let e=o.index.range(s.x-r,s.y-r,s.x+r,s.y+r).sort();for(let t of e){let e=o.crossTileIDs[t];if(!n[e]){n[e]=!0,a.crossTileID=e;break}}}else if(o.positions)for(let e=0;e<o.positions.length;e++){let t=o.positions[e],i=o.crossTileIDs[e];if(Math.abs(t.x-s.x)<=r&&Math.abs(t.y-s.y)<=r&&!n[i]){n[i]=!0,a.crossTileID=i;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map((({crossTileIDs:e})=>e))}}class Dt{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Ot{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){let t=Math.round((e-this.lng)/360);if(t!==0)for(let e in this.indexes){let n=this.indexes[e],r={};for(let e in n){let i=n[e];i.tileID=i.tileID.unwrapTo(i.tileID.wrap+t),r[i.tileID.key]=i}this.indexes[e]=r}this.lng=e}addBucket(e,t,n){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]={});let r=this.usedCrossTileIDs[e.overscaledZ];for(let n in this.indexes){let i=this.indexes[n];if(Number(n)>e.overscaledZ)for(let n in i){let a=i[n];a.tileID.isChildOf(e)&&a.findMatches(t.symbolInstances,e,r)}else{let a=i[e.scaledTo(Number(n)).key];a&&a.findMatches(t.symbolInstances,e,r)}}for(let e=0;e<t.symbolInstances.length;e++){let i=t.symbolInstances.get(e);i.crossTileID||(i.crossTileID=n.generate(),r[i.crossTileID]=!0)}return this.indexes[e.overscaledZ]===void 0&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new Et(e,t.symbolInstances,t.bucketInstanceId),!0}removeBucketCrossTileIDs(e,t){for(let n of t.getCrossTileIDsLists())for(let t of n)delete this.usedCrossTileIDs[e][t]}removeStaleBuckets(e){let t=!1;for(let n in this.indexes){let r=this.indexes[n];for(let i in r)e[r[i].bucketInstanceId]||(this.removeBucketCrossTileIDs(n,r[i]),delete r[i],t=!0)}return t}}class kt{constructor(){this.layerIndexes={},this.crossTileIDs=new Dt,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,t,n){let r=this.layerIndexes[e.id];r===void 0&&(r=this.layerIndexes[e.id]=new Ot);let i=!1,a={};r.handleWrapJump(n);for(let n of t){let t=n.getBucket(e);t&&e.id===t.layerIds[0]&&(t.bucketInstanceId||=++this.maxBucketInstanceId,r.addBucket(n.tileID,t,this.crossTileIDs)&&(i=!0),a[t.bucketInstanceId]=!0)}return r.removeStaleBuckets(a)&&(i=!0),i}pruneUnusedLayers(e){let t={};e.forEach((e=>{t[e]=!0}));for(let e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}var At=`void main() {fragColor=vec4(1.0);}`;let jt={prelude:H(`#ifdef GL_ES
2
+ precision mediump float;
3
+ #else
4
+ #if !defined(lowp)
5
+ #define lowp
6
+ #endif
7
+ #if !defined(mediump)
8
+ #define mediump
9
+ #endif
10
+ #if !defined(highp)
11
+ #define highp
12
+ #endif
13
+ #endif
14
+ out highp vec4 fragColor;`,`#ifdef GL_ES
15
+ precision highp float;
16
+ #else
17
+ #if !defined(lowp)
18
+ #define lowp
19
+ #endif
20
+ #if !defined(mediump)
21
+ #define mediump
22
+ #endif
23
+ #if !defined(highp)
24
+ #define highp
25
+ #endif
26
+ #endif
27
+ vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0
28
+ );}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c
29
+ );}
30
+ #ifdef TERRAIN3D
31
+ uniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;
32
+ #endif
33
+ const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {
34
+ #ifdef TERRAIN3D
35
+ highp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));
36
+ #else
37
+ return 1.0;
38
+ #endif
39
+ }float calculate_visibility(vec4 pos) {
40
+ #ifdef TERRAIN3D
41
+ vec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;
42
+ #else
43
+ return 1.0;
44
+ #endif
45
+ }float ele(vec2 pos) {
46
+ #ifdef TERRAIN3D
47
+ vec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;
48
+ #else
49
+ return 0.0;
50
+ #endif
51
+ }float get_elevation(vec2 pos) {
52
+ #ifdef TERRAIN3D
53
+ #ifdef GLOBE
54
+ if ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}
55
+ #endif
56
+ vec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;
57
+ #else
58
+ return 0.0;
59
+ #endif
60
+ }const float PI=3.141592653589793;uniform mat4 u_projection_matrix;`),projectionMercator:H(``,`float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}`),projectionGlobe:H(``,`#define GLOBE_RADIUS 6371008.8
61
+ uniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos
62
+ );}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY);
63
+ if (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len
64
+ );if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}`),background:H(`uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;
65
+ #ifdef OVERDRAW_INSPECTOR
66
+ fragColor=vec4(1.0);
67
+ #endif
68
+ }`,`in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}`),backgroundPattern:H(`uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;
69
+ #ifdef OVERDRAW_INSPECTOR
70
+ fragColor=vec4(1.0);
71
+ #endif
72
+ }`,`uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}`),circle:H(`in vec3 v_data;in float v_visibility;
73
+ #pragma mapbox: define highp vec4 color
74
+ #pragma mapbox: define mediump float radius
75
+ #pragma mapbox: define lowp float blur
76
+ #pragma mapbox: define lowp float opacity
77
+ #pragma mapbox: define highp vec4 stroke_color
78
+ #pragma mapbox: define mediump float stroke_width
79
+ #pragma mapbox: define lowp float stroke_opacity
80
+ void main() {
81
+ #pragma mapbox: initialize highp vec4 color
82
+ #pragma mapbox: initialize mediump float radius
83
+ #pragma mapbox: initialize lowp float blur
84
+ #pragma mapbox: initialize lowp float opacity
85
+ #pragma mapbox: initialize highp vec4 stroke_color
86
+ #pragma mapbox: initialize mediump float stroke_width
87
+ #pragma mapbox: initialize lowp float stroke_opacity
88
+ vec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}
89
+ #ifdef OVERDRAW_INSPECTOR
90
+ fragColor=vec4(1.0);
91
+ #endif
92
+ }`,`uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out vec3 v_data;out float v_visibility;
93
+ #pragma mapbox: define highp vec4 color
94
+ #pragma mapbox: define mediump float radius
95
+ #pragma mapbox: define lowp float blur
96
+ #pragma mapbox: define lowp float opacity
97
+ #pragma mapbox: define highp vec4 stroke_color
98
+ #pragma mapbox: define mediump float stroke_width
99
+ #pragma mapbox: define lowp float stroke_opacity
100
+ void main(void) {
101
+ #pragma mapbox: initialize highp vec4 color
102
+ #pragma mapbox: initialize mediump float radius
103
+ #pragma mapbox: initialize lowp float blur
104
+ #pragma mapbox: initialize lowp float opacity
105
+ #pragma mapbox: initialize highp vec4 stroke_color
106
+ #pragma mapbox: initialize mediump float stroke_width
107
+ #pragma mapbox: initialize lowp float stroke_opacity
108
+ vec2 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {
109
+ #ifdef GLOBE
110
+ vec3 center_vector=projectToSphere(circle_center);
111
+ #endif
112
+ float angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {
113
+ #ifdef GLOBE
114
+ vec4 projected_center=interpolateProjection(circle_center,center_vector,ele);
115
+ #else
116
+ vec4 projected_center=projectTileWithElevation(circle_center,ele);
117
+ #endif
118
+ corner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}
119
+ #ifdef GLOBE
120
+ vec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);
121
+ #else
122
+ gl_Position=projectTileWithElevation(corner_position,ele);
123
+ #endif
124
+ } else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}`),clippingMask:H(At,`in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}`),heatmap:H(`uniform highp float u_intensity;in vec2 v_extrude;
125
+ #pragma mapbox: define highp float weight
126
+ #define GAUSS_COEF 0.3989422804014327
127
+ void main() {
128
+ #pragma mapbox: initialize highp float weight
129
+ float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);
130
+ #ifdef OVERDRAW_INSPECTOR
131
+ fragColor=vec4(1.0);
132
+ #endif
133
+ }`,`uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out vec2 v_extrude;
134
+ #pragma mapbox: define highp float weight
135
+ #pragma mapbox: define mediump float radius
136
+ const highp float ZERO=1.0/255.0/16.0;
137
+ #define GAUSS_COEF 0.3989422804014327
138
+ void main(void) {
139
+ #pragma mapbox: initialize highp float weight
140
+ #pragma mapbox: initialize mediump float radius
141
+ vec2 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 circle_center=floor(pos_raw/8.0);
142
+ #ifdef GLOBE
143
+ vec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);
144
+ #else
145
+ gl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));
146
+ #endif
147
+ }`),heatmapTexture:H(`uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity;
148
+ #ifdef OVERDRAW_INSPECTOR
149
+ fragColor=vec4(0.0);
150
+ #endif
151
+ }`,`uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}`),collisionBox:H(`in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}`,`in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}`),collisionCircle:H(`in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);fragColor=color*alpha*opacity_t;}`,`in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}`),colorRelief:H(`#ifdef GL_ES
152
+ precision highp float;
153
+ #endif
154
+ uniform sampler2D u_image;uniform vec4 u_unpack;uniform sampler2D u_elevation_stops;uniform sampler2D u_color_stops;uniform int u_color_ramp_size;uniform float u_opacity;in vec2 v_pos;float getElevation(vec2 coord) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}float getElevationStop(int stop) {float x=(float(stop)+0.5)/float(u_color_ramp_size);vec4 data=texture(u_elevation_stops,vec2(x,0))*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {float el=getElevation(v_pos);int r=(u_color_ramp_size-1);int l=0;float el_l=getElevationStop(l);float el_r=getElevationStop(r);while(r-l > 1){int m=(r+l)/2;float el_m=getElevationStop(m);if(el < el_m){r=m;el_r=el_m;}else
155
+ {l=m;el_l=el_m;}}float x=(float(l)+(el-el_l)/(el_r-el_l)+0.5)/float(u_color_ramp_size);fragColor=u_opacity*texture(u_color_stops,vec2(x,0));
156
+ #ifdef OVERDRAW_INSPECTOR
157
+ fragColor=vec4(1.0);
158
+ #endif
159
+ }`,`uniform vec2 u_dimension;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_pos/8192.0)*scale+epsilon;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}`),debug:H(`uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}`,`in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}`),depth:H(At,`in vec2 a_pos;void main() {
160
+ #ifdef GLOBE
161
+ gl_Position=projectTileFor3D(a_pos,0.0);
162
+ #else
163
+ gl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);
164
+ #endif
165
+ }`),fill:H(`#pragma mapbox: define highp vec4 color
166
+ #pragma mapbox: define lowp float opacity
167
+ void main() {
168
+ #pragma mapbox: initialize highp vec4 color
169
+ #pragma mapbox: initialize lowp float opacity
170
+ fragColor=color*opacity;
171
+ #ifdef OVERDRAW_INSPECTOR
172
+ fragColor=vec4(1.0);
173
+ #endif
174
+ }`,`uniform vec2 u_fill_translate;in vec2 a_pos;
175
+ #pragma mapbox: define highp vec4 color
176
+ #pragma mapbox: define lowp float opacity
177
+ void main() {
178
+ #pragma mapbox: initialize highp vec4 color
179
+ #pragma mapbox: initialize lowp float opacity
180
+ gl_Position=projectTile(a_pos+u_fill_translate,a_pos);}`),fillOutline:H(`in vec2 v_pos;
181
+ #ifdef GLOBE
182
+ in float v_depth;
183
+ #endif
184
+ #pragma mapbox: define highp vec4 outline_color
185
+ #pragma mapbox: define lowp float opacity
186
+ void main() {
187
+ #pragma mapbox: initialize highp vec4 outline_color
188
+ #pragma mapbox: initialize lowp float opacity
189
+ float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);
190
+ #ifdef GLOBE
191
+ if (v_depth > 1.0) {discard;}
192
+ #endif
193
+ #ifdef OVERDRAW_INSPECTOR
194
+ fragColor=vec4(1.0);
195
+ #endif
196
+ }`,`uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;
197
+ #ifdef GLOBE
198
+ out float v_depth;
199
+ #endif
200
+ #pragma mapbox: define highp vec4 outline_color
201
+ #pragma mapbox: define lowp float opacity
202
+ void main() {
203
+ #pragma mapbox: initialize highp vec4 outline_color
204
+ #pragma mapbox: initialize lowp float opacity
205
+ gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
206
+ #ifdef GLOBE
207
+ v_depth=gl_Position.z/gl_Position.w;
208
+ #endif
209
+ }`),fillOutlinePattern:H(`uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;
210
+ #ifdef GLOBE
211
+ in float v_depth;
212
+ #endif
213
+ #pragma mapbox: define lowp float opacity
214
+ #pragma mapbox: define lowp vec4 pattern_from
215
+ #pragma mapbox: define lowp vec4 pattern_to
216
+ void main() {
217
+ #pragma mapbox: initialize lowp float opacity
218
+ #pragma mapbox: initialize mediump vec4 pattern_from
219
+ #pragma mapbox: initialize mediump vec4 pattern_to
220
+ vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;
221
+ #ifdef GLOBE
222
+ if (v_depth > 1.0) {discard;}
223
+ #endif
224
+ #ifdef OVERDRAW_INSPECTOR
225
+ fragColor=vec4(1.0);
226
+ #endif
227
+ }`,`uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;
228
+ #ifdef GLOBE
229
+ out float v_depth;
230
+ #endif
231
+ #pragma mapbox: define lowp float opacity
232
+ #pragma mapbox: define lowp vec4 pattern_from
233
+ #pragma mapbox: define lowp vec4 pattern_to
234
+ #pragma mapbox: define lowp float pixel_ratio_from
235
+ #pragma mapbox: define lowp float pixel_ratio_to
236
+ void main() {
237
+ #pragma mapbox: initialize lowp float opacity
238
+ #pragma mapbox: initialize mediump vec4 pattern_from
239
+ #pragma mapbox: initialize mediump vec4 pattern_to
240
+ #pragma mapbox: initialize lowp float pixel_ratio_from
241
+ #pragma mapbox: initialize lowp float pixel_ratio_to
242
+ vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
243
+ #ifdef GLOBE
244
+ v_depth=gl_Position.z/gl_Position.w;
245
+ #endif
246
+ }`),fillPattern:H(`#ifdef GL_ES
247
+ precision highp float;
248
+ #endif
249
+ uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;
250
+ #pragma mapbox: define lowp float opacity
251
+ #pragma mapbox: define lowp vec4 pattern_from
252
+ #pragma mapbox: define lowp vec4 pattern_to
253
+ void main() {
254
+ #pragma mapbox: initialize lowp float opacity
255
+ #pragma mapbox: initialize mediump vec4 pattern_from
256
+ #pragma mapbox: initialize mediump vec4 pattern_to
257
+ vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;
258
+ #ifdef OVERDRAW_INSPECTOR
259
+ fragColor=vec4(1.0);
260
+ #endif
261
+ }`,`uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;
262
+ #pragma mapbox: define lowp float opacity
263
+ #pragma mapbox: define lowp vec4 pattern_from
264
+ #pragma mapbox: define lowp vec4 pattern_to
265
+ #pragma mapbox: define lowp float pixel_ratio_from
266
+ #pragma mapbox: define lowp float pixel_ratio_to
267
+ void main() {
268
+ #pragma mapbox: initialize lowp float opacity
269
+ #pragma mapbox: initialize mediump vec4 pattern_from
270
+ #pragma mapbox: initialize mediump vec4 pattern_to
271
+ #pragma mapbox: initialize lowp float pixel_ratio_from
272
+ #pragma mapbox: initialize lowp float pixel_ratio_to
273
+ vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}`),fillExtrusion:H(`in vec4 v_color;void main() {fragColor=v_color;
274
+ #ifdef OVERDRAW_INSPECTOR
275
+ fragColor=vec4(1.0);
276
+ #endif
277
+ }`,`uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed;
278
+ #ifdef TERRAIN3D
279
+ in vec2 a_centroid;
280
+ #endif
281
+ out vec4 v_color;
282
+ #pragma mapbox: define highp float base
283
+ #pragma mapbox: define highp float height
284
+ #pragma mapbox: define highp vec4 color
285
+ void main() {
286
+ #pragma mapbox: initialize highp float base
287
+ #pragma mapbox: initialize highp float height
288
+ #pragma mapbox: initialize highp vec4 color
289
+ vec3 normal=a_normal_ed.xyz;
290
+ #ifdef TERRAIN3D
291
+ float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);
292
+ #else
293
+ float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
294
+ #endif
295
+ base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;
296
+ #ifdef GLOBE
297
+ vec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);
298
+ #else
299
+ gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);
300
+ #endif
301
+ float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);
302
+ #ifdef GLOBE
303
+ mat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);
304
+ #endif
305
+ directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}`),fillExtrusionPattern:H(`uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;
306
+ #pragma mapbox: define lowp float base
307
+ #pragma mapbox: define lowp float height
308
+ #pragma mapbox: define lowp vec4 pattern_from
309
+ #pragma mapbox: define lowp vec4 pattern_to
310
+ #pragma mapbox: define lowp float pixel_ratio_from
311
+ #pragma mapbox: define lowp float pixel_ratio_to
312
+ void main() {
313
+ #pragma mapbox: initialize lowp float base
314
+ #pragma mapbox: initialize lowp float height
315
+ #pragma mapbox: initialize mediump vec4 pattern_from
316
+ #pragma mapbox: initialize mediump vec4 pattern_to
317
+ #pragma mapbox: initialize lowp float pixel_ratio_from
318
+ #pragma mapbox: initialize lowp float pixel_ratio_to
319
+ vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;
320
+ #ifdef OVERDRAW_INSPECTOR
321
+ fragColor=vec4(1.0);
322
+ #endif
323
+ }`,`uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed;
324
+ #ifdef TERRAIN3D
325
+ in vec2 a_centroid;
326
+ #endif
327
+ #ifdef GLOBE
328
+ out vec3 v_sphere_pos;
329
+ #endif
330
+ out vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;
331
+ #pragma mapbox: define lowp float base
332
+ #pragma mapbox: define lowp float height
333
+ #pragma mapbox: define lowp vec4 pattern_from
334
+ #pragma mapbox: define lowp vec4 pattern_to
335
+ #pragma mapbox: define lowp float pixel_ratio_from
336
+ #pragma mapbox: define lowp float pixel_ratio_to
337
+ void main() {
338
+ #pragma mapbox: initialize lowp float base
339
+ #pragma mapbox: initialize lowp float height
340
+ #pragma mapbox: initialize mediump vec4 pattern_from
341
+ #pragma mapbox: initialize mediump vec4 pattern_to
342
+ #pragma mapbox: initialize lowp float pixel_ratio_from
343
+ #pragma mapbox: initialize lowp float pixel_ratio_to
344
+ vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;
345
+ #ifdef TERRAIN3D
346
+ float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);
347
+ #else
348
+ float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
349
+ #endif
350
+ base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;
351
+ #ifdef GLOBE
352
+ vec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);
353
+ #else
354
+ gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);
355
+ #endif
356
+ vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0
357
+ ? a_pos
358
+ : vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}`),hillshadePrepare:H(`#ifdef GL_ES
359
+ precision highp float;
360
+ #endif
361
+ uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {vec2 epsilon=1.0/u_dimension;float tileSize=u_dimension.x-2.0;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0);
362
+ #ifdef OVERDRAW_INSPECTOR
363
+ fragColor=vec4(1.0);
364
+ #endif
365
+ }`,`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:H(`uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];
366
+ #define PI 3.141592653589793
367
+ #define STANDARD 0
368
+ #define COMBINED 1
369
+ #define IGOR 2
370
+ #define MULTIDIRECTIONAL 3
371
+ #define BASIC 4
372
+ float get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else
373
+ {fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else
374
+ {fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec4 pixel=texture(u_image,v_pos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);}
375
+ #ifdef OVERDRAW_INSPECTOR
376
+ fragColor=vec4(1.0);
377
+ #endif
378
+ }`,`uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}`),line:H(`uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;
379
+ #ifdef GLOBE
380
+ in float v_depth;
381
+ #endif
382
+ #pragma mapbox: define highp vec4 color
383
+ #pragma mapbox: define lowp float blur
384
+ #pragma mapbox: define lowp float opacity
385
+ void main() {
386
+ #pragma mapbox: initialize highp vec4 color
387
+ #pragma mapbox: initialize lowp float blur
388
+ #pragma mapbox: initialize lowp float opacity
389
+ float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);fragColor=color*(alpha*opacity);
390
+ #ifdef GLOBE
391
+ if (v_depth > 1.0) {discard;}
392
+ #endif
393
+ #ifdef OVERDRAW_INSPECTOR
394
+ fragColor=vec4(1.0);
395
+ #endif
396
+ }`,`
397
+ #define scale 0.015873016
398
+ in vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;
399
+ #ifdef GLOBE
400
+ out float v_depth;
401
+ #endif
402
+ #pragma mapbox: define highp vec4 color
403
+ #pragma mapbox: define lowp float blur
404
+ #pragma mapbox: define lowp float opacity
405
+ #pragma mapbox: define mediump float gapwidth
406
+ #pragma mapbox: define lowp float offset
407
+ #pragma mapbox: define mediump float width
408
+ void main() {
409
+ #pragma mapbox: initialize highp vec4 color
410
+ #pragma mapbox: initialize lowp float blur
411
+ #pragma mapbox: initialize lowp float opacity
412
+ #pragma mapbox: initialize mediump float gapwidth
413
+ #pragma mapbox: initialize lowp float offset
414
+ #pragma mapbox: initialize mediump float width
415
+ float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
416
+ #ifdef GLOBE
417
+ v_depth=gl_Position.z/gl_Position.w;
418
+ #endif
419
+ #ifdef TERRAIN3D
420
+ v_gamma_scale=1.0;
421
+ #else
422
+ float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
423
+ #endif
424
+ v_width2=vec2(outset,inset);}`),lineGradient:H(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;
425
+ #ifdef GLOBE
426
+ in float v_depth;
427
+ #endif
428
+ #pragma mapbox: define lowp float blur
429
+ #pragma mapbox: define lowp float opacity
430
+ void main() {
431
+ #pragma mapbox: initialize lowp float blur
432
+ #pragma mapbox: initialize lowp float opacity
433
+ float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);
434
+ #ifdef GLOBE
435
+ if (v_depth > 1.0) {discard;}
436
+ #endif
437
+ #ifdef OVERDRAW_INSPECTOR
438
+ fragColor=vec4(1.0);
439
+ #endif
440
+ }`,`
441
+ #define scale 0.015873016
442
+ in vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;
443
+ #ifdef GLOBE
444
+ out float v_depth;
445
+ #endif
446
+ #pragma mapbox: define lowp float blur
447
+ #pragma mapbox: define lowp float opacity
448
+ #pragma mapbox: define mediump float gapwidth
449
+ #pragma mapbox: define lowp float offset
450
+ #pragma mapbox: define mediump float width
451
+ void main() {
452
+ #pragma mapbox: initialize lowp float blur
453
+ #pragma mapbox: initialize lowp float opacity
454
+ #pragma mapbox: initialize mediump float gapwidth
455
+ #pragma mapbox: initialize lowp float offset
456
+ #pragma mapbox: initialize mediump float width
457
+ float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
458
+ #ifdef GLOBE
459
+ v_depth=gl_Position.z/gl_Position.w;
460
+ #endif
461
+ #ifdef TERRAIN3D
462
+ v_gamma_scale=1.0;
463
+ #else
464
+ float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
465
+ #endif
466
+ v_width2=vec2(outset,inset);}`),linePattern:H(`#ifdef GL_ES
467
+ precision highp float;
468
+ #endif
469
+ uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;
470
+ #ifdef GLOBE
471
+ in float v_depth;
472
+ #endif
473
+ #pragma mapbox: define lowp vec4 pattern_from
474
+ #pragma mapbox: define lowp vec4 pattern_to
475
+ #pragma mapbox: define lowp float pixel_ratio_from
476
+ #pragma mapbox: define lowp float pixel_ratio_to
477
+ #pragma mapbox: define lowp float blur
478
+ #pragma mapbox: define lowp float opacity
479
+ void main() {
480
+ #pragma mapbox: initialize mediump vec4 pattern_from
481
+ #pragma mapbox: initialize mediump vec4 pattern_to
482
+ #pragma mapbox: initialize lowp float pixel_ratio_from
483
+ #pragma mapbox: initialize lowp float pixel_ratio_to
484
+ #pragma mapbox: initialize lowp float blur
485
+ #pragma mapbox: initialize lowp float opacity
486
+ vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;
487
+ #ifdef GLOBE
488
+ if (v_depth > 1.0) {discard;}
489
+ #endif
490
+ #ifdef OVERDRAW_INSPECTOR
491
+ fragColor=vec4(1.0);
492
+ #endif
493
+ }`,`
494
+ #define scale 0.015873016
495
+ #define LINE_DISTANCE_SCALE 2.0
496
+ in vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;
497
+ #ifdef GLOBE
498
+ out float v_depth;
499
+ #endif
500
+ #pragma mapbox: define lowp float blur
501
+ #pragma mapbox: define lowp float opacity
502
+ #pragma mapbox: define lowp float offset
503
+ #pragma mapbox: define mediump float gapwidth
504
+ #pragma mapbox: define mediump float width
505
+ #pragma mapbox: define lowp float floorwidth
506
+ #pragma mapbox: define lowp vec4 pattern_from
507
+ #pragma mapbox: define lowp vec4 pattern_to
508
+ #pragma mapbox: define lowp float pixel_ratio_from
509
+ #pragma mapbox: define lowp float pixel_ratio_to
510
+ void main() {
511
+ #pragma mapbox: initialize lowp float blur
512
+ #pragma mapbox: initialize lowp float opacity
513
+ #pragma mapbox: initialize lowp float offset
514
+ #pragma mapbox: initialize mediump float gapwidth
515
+ #pragma mapbox: initialize mediump float width
516
+ #pragma mapbox: initialize lowp float floorwidth
517
+ #pragma mapbox: initialize mediump vec4 pattern_from
518
+ #pragma mapbox: initialize mediump vec4 pattern_to
519
+ #pragma mapbox: initialize lowp float pixel_ratio_from
520
+ #pragma mapbox: initialize lowp float pixel_ratio_to
521
+ float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
522
+ #ifdef GLOBE
523
+ v_depth=gl_Position.z/gl_Position.w;
524
+ #endif
525
+ #ifdef TERRAIN3D
526
+ v_gamma_scale=1.0;
527
+ #else
528
+ float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
529
+ #endif
530
+ v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}`),lineSDF:H(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;
531
+ #ifdef GLOBE
532
+ in float v_depth;
533
+ #endif
534
+ #pragma mapbox: define highp vec4 color
535
+ #pragma mapbox: define lowp float blur
536
+ #pragma mapbox: define lowp float opacity
537
+ #pragma mapbox: define mediump float width
538
+ #pragma mapbox: define lowp float floorwidth
539
+ void main() {
540
+ #pragma mapbox: initialize highp vec4 color
541
+ #pragma mapbox: initialize lowp float blur
542
+ #pragma mapbox: initialize lowp float opacity
543
+ #pragma mapbox: initialize mediump float width
544
+ #pragma mapbox: initialize lowp float floorwidth
545
+ float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);
546
+ #ifdef GLOBE
547
+ if (v_depth > 1.0) {discard;}
548
+ #endif
549
+ #ifdef OVERDRAW_INSPECTOR
550
+ fragColor=vec4(1.0);
551
+ #endif
552
+ }`,`
553
+ #define scale 0.015873016
554
+ #define LINE_DISTANCE_SCALE 2.0
555
+ in vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;
556
+ #ifdef GLOBE
557
+ out float v_depth;
558
+ #endif
559
+ #pragma mapbox: define highp vec4 color
560
+ #pragma mapbox: define lowp float blur
561
+ #pragma mapbox: define lowp float opacity
562
+ #pragma mapbox: define mediump float gapwidth
563
+ #pragma mapbox: define lowp float offset
564
+ #pragma mapbox: define mediump float width
565
+ #pragma mapbox: define lowp float floorwidth
566
+ void main() {
567
+ #pragma mapbox: initialize highp vec4 color
568
+ #pragma mapbox: initialize lowp float blur
569
+ #pragma mapbox: initialize lowp float opacity
570
+ #pragma mapbox: initialize mediump float gapwidth
571
+ #pragma mapbox: initialize lowp float offset
572
+ #pragma mapbox: initialize mediump float width
573
+ #pragma mapbox: initialize lowp float floorwidth
574
+ float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
575
+ #ifdef GLOBE
576
+ v_depth=gl_Position.z/gl_Position.w;
577
+ #endif
578
+ #ifdef TERRAIN3D
579
+ v_gamma_scale=1.0;
580
+ #else
581
+ float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
582
+ #endif
583
+ v_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}`),raster:H(`uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture(u_image0,v_pos0);vec4 color1=texture(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);
584
+ #ifdef OVERDRAW_INSPECTOR
585
+ fragColor=vec4(1.0);
586
+ #endif
587
+ }`,`uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;
588
+ #ifdef GLOBE
589
+ if (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}
590
+ #endif
591
+ v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}`),symbolIcon:H(`uniform sampler2D u_texture;in vec2 v_tex;in float v_fade_opacity;
592
+ #pragma mapbox: define lowp float opacity
593
+ void main() {
594
+ #pragma mapbox: initialize lowp float opacity
595
+ lowp float alpha=opacity*v_fade_opacity;fragColor=texture(u_texture,v_tex)*alpha;
596
+ #ifdef OVERDRAW_INSPECTOR
597
+ fragColor=vec4(1.0);
598
+ #endif
599
+ }`,`in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out float v_fade_opacity;
600
+ #pragma mapbox: define lowp float opacity
601
+ void main() {
602
+ #pragma mapbox: initialize lowp float opacity
603
+ vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
604
+ camera_to_anchor_distance/u_camera_to_center_distance :
605
+ u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;
606
+ #ifdef GLOBE
607
+ if(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}
608
+ #endif
609
+ vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}`),symbolSDF:H(`#define SDF_PX 8.0
610
+ uniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1;
611
+ #pragma mapbox: define highp vec4 fill_color
612
+ #pragma mapbox: define highp vec4 halo_color
613
+ #pragma mapbox: define lowp float opacity
614
+ #pragma mapbox: define lowp float halo_width
615
+ #pragma mapbox: define lowp float halo_blur
616
+ void main() {
617
+ #pragma mapbox: initialize highp vec4 fill_color
618
+ #pragma mapbox: initialize highp vec4 halo_color
619
+ #pragma mapbox: initialize lowp float opacity
620
+ #pragma mapbox: initialize lowp float halo_width
621
+ #pragma mapbox: initialize lowp float halo_blur
622
+ float EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}fragColor=color*(alpha*opacity*fade_opacity);
623
+ #ifdef OVERDRAW_INSPECTOR
624
+ fragColor=vec4(1.0);
625
+ #endif
626
+ }`,`in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_data0;out vec3 v_data1;
627
+ #pragma mapbox: define highp vec4 fill_color
628
+ #pragma mapbox: define highp vec4 halo_color
629
+ #pragma mapbox: define lowp float opacity
630
+ #pragma mapbox: define lowp float halo_width
631
+ #pragma mapbox: define lowp float halo_blur
632
+ void main() {
633
+ #pragma mapbox: initialize highp vec4 fill_color
634
+ #pragma mapbox: initialize highp vec4 halo_color
635
+ #pragma mapbox: initialize lowp float opacity
636
+ #pragma mapbox: initialize lowp float halo_width
637
+ #pragma mapbox: initialize lowp float halo_blur
638
+ vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
639
+ camera_to_anchor_distance/u_camera_to_center_distance :
640
+ u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;
641
+ #ifdef GLOBE
642
+ if(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}
643
+ #endif
644
+ vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}`),symbolTextAndIcon:H(`#define SDF_PX 8.0
645
+ #define SDF 1.0
646
+ #define ICON 0.0
647
+ uniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;in vec4 v_data0;in vec4 v_data1;
648
+ #pragma mapbox: define highp vec4 fill_color
649
+ #pragma mapbox: define highp vec4 halo_color
650
+ #pragma mapbox: define lowp float opacity
651
+ #pragma mapbox: define lowp float halo_width
652
+ #pragma mapbox: define lowp float halo_blur
653
+ void main() {
654
+ #pragma mapbox: initialize highp vec4 fill_color
655
+ #pragma mapbox: initialize highp vec4 halo_color
656
+ #pragma mapbox: initialize lowp float opacity
657
+ #pragma mapbox: initialize lowp float halo_width
658
+ #pragma mapbox: initialize lowp float halo_blur
659
+ float fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;fragColor=texture(u_texture_icon,tex_icon)*alpha;
660
+ #ifdef OVERDRAW_INSPECTOR
661
+ fragColor=vec4(1.0);
662
+ #endif
663
+ return;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);fragColor=color*(alpha*opacity*fade_opacity);
664
+ #ifdef OVERDRAW_INSPECTOR
665
+ fragColor=vec4(1.0);
666
+ #endif
667
+ }`,`in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec4 v_data0;out vec4 v_data1;
668
+ #pragma mapbox: define highp vec4 fill_color
669
+ #pragma mapbox: define highp vec4 halo_color
670
+ #pragma mapbox: define lowp float opacity
671
+ #pragma mapbox: define lowp float halo_width
672
+ #pragma mapbox: define lowp float halo_blur
673
+ void main() {
674
+ #pragma mapbox: initialize highp vec4 fill_color
675
+ #pragma mapbox: initialize highp vec4 halo_color
676
+ #pragma mapbox: initialize lowp float opacity
677
+ #pragma mapbox: initialize lowp float halo_width
678
+ #pragma mapbox: initialize lowp float halo_blur
679
+ vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
680
+ camera_to_anchor_distance/u_camera_to_center_distance :
681
+ u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;
682
+ #ifdef GLOBE
683
+ if(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}
684
+ #endif
685
+ vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}`),terrain:H(`uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}`,`in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}`),terrainDepth:H(`in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}`,`in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}`),terrainCoords:H(`precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}`,`in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}`),projectionErrorMeasurement:H(`in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}`,`in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}`),atmosphere:H(`in vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758
686
+ );color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}`,`in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}`),sky:H(`uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}`,`in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}`)};function H(e,t){let n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=t.match(/in ([\w]+) ([\w]+)/g),i=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),a=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=a?a.concat(i):i,s={};return{fragmentSource:e=e.replace(n,((e,t,n,r,i)=>(s[i]=!0,t===`define`?`\n#ifndef HAS_UNIFORM_u_${i}\nin ${n} ${r} ${i};\n#else\nuniform ${n} ${r} u_${i};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${i}\n ${n} ${r} ${i} = u_${i};\n#endif\n`))),vertexSource:t=t.replace(n,((e,t,n,r,i)=>{let a=r===`float`?`vec2`:`vec4`,o=i.match(/color/)?`color`:a;return s[i]?t===`define`?`\n#ifndef HAS_UNIFORM_u_${i}\nuniform lowp float u_${i}_t;\nin ${n} ${a} a_${i};\nout ${n} ${r} ${i};\n#else\nuniform ${n} ${r} u_${i};\n#endif\n`:o===`vec4`?`\n#ifndef HAS_UNIFORM_u_${i}\n ${i} = a_${i};\n#else\n ${n} ${r} ${i} = u_${i};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${i}\n ${i} = unpack_mix_${o}(a_${i}, u_${i}_t);\n#else\n ${n} ${r} ${i} = u_${i};\n#endif\n`:t===`define`?`\n#ifndef HAS_UNIFORM_u_${i}\nuniform lowp float u_${i}_t;\nin ${n} ${a} a_${i};\n#else\nuniform ${n} ${r} u_${i};\n#endif\n`:o===`vec4`?`\n#ifndef HAS_UNIFORM_u_${i}\n ${n} ${r} ${i} = a_${i};\n#else\n ${n} ${r} ${i} = u_${i};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${i}\n ${n} ${r} ${i} = unpack_mix_${o}(a_${i}, u_${i}_t);\n#else\n ${n} ${r} ${i} = u_${i};\n#endif\n`})),staticAttributes:r,staticUniforms:o}}class Mt{constructor(e,t,n){this.vertexBuffer=e,this.indexBuffer=t,this.segments=n}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var Nt=t.aJ([{name:`a_pos`,type:`Int16`,components:2}]);let Pt=`#define PROJECTION_MERCATOR`,U=`mercator`;class Ft{constructor(){this._cachedMesh=null}get name(){return`mercator`}get useSubdivision(){return!1}get shaderVariantName(){return U}get shaderDefine(){return Pt}get shaderPreludeCode(){return jt.projectionMercator}get vertexShaderPreludeCode(){return jt.projectionMercator.vertexSource}get subdivisionGranularity(){return t.aK.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,n,r,i,a){if(this._cachedMesh)return this._cachedMesh;let o=new t.aL;o.emplaceBack(0,0),o.emplaceBack(t.ah,0),o.emplaceBack(0,t.ah),o.emplaceBack(t.ah,t.ah);let s=e.createVertexBuffer(o,Nt.members),c=t.aM.simpleSegment(0,0,4,2),l=new t.aN;return l.emplaceBack(1,0,2),l.emplaceBack(1,2,3),this._cachedMesh=new Mt(s,e.createIndexBuffer(l),c),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(e){}}class It{constructor(e=0,t=0,n=0,r=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(n)||n<0||isNaN(r)||r<0)throw Error(`Invalid value for edge-insets, top, bottom, left and right must all be numbers`);this.top=e,this.bottom=t,this.left=n,this.right=r}interpolate(e,n,r){return n.top!=null&&e.top!=null&&(this.top=t.C.number(e.top,n.top,r)),n.bottom!=null&&e.bottom!=null&&(this.bottom=t.C.number(e.bottom,n.bottom,r)),n.left!=null&&e.left!=null&&(this.left=t.C.number(e.left,n.left,r)),n.right!=null&&e.right!=null&&(this.right=t.C.number(e.right,n.right,r)),this}getCenter(e,n){let r=t.L((this.left+e-this.right)/2,0,e),i=t.L((this.top+n-this.bottom)/2,0,n);return new t.P(r,i)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new It(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Lt(e,t){if(!e.renderWorldCopies||e.lngRange)return;let n=t.lng-e.center.lng;t.lng+=n>180?-360:n<-180?360:0}function Rt(e){return Math.max(0,Math.floor(e))}class zt{constructor(e,n,r,i,a,o){this._callbacks=e,this._tileSize=512,this._renderWorldCopies=o===void 0||!!o,this._minZoom=n||0,this._maxZoom=r||22,this._minPitch=i??0,this._maxPitch=a??60,this.setMaxBounds(),this._width=0,this._height=0,this._center=new t.aa(0,0),this._elevation=0,this._zoom=0,this._tileZoom=Rt(this._zoom),this._scale=t.aw(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new It,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0,this._detailLevel=0,this._rasterAlignment=!0}apply(e,n,r){this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=Rt(this._zoom),this._scale=t.aw(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new It(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!r&&e.autoCalculateNearFarZ,this._detailLevel=e.detailLevel,n&&this._constrain(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.getConstrained(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.getConstrained(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)))}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){e===void 0?e=!0:e===null&&(e=!1),this._renderWorldCopies=e}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new t.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){let n=t.aO(e,-180,180)*Math.PI/180;var i,a,o,s,c,l,u,d,f;this._bearingInRadians!==n&&(this._unmodified=!1,this._bearingInRadians=n,this._calcMatrices(),this._rotationMatrix=r(),i=this._rotationMatrix,o=-this._bearingInRadians,s=(a=this._rotationMatrix)[0],c=a[1],l=a[2],u=a[3],d=Math.sin(o),f=Math.cos(o),i[0]=s*f+l*d,i[1]=c*f+u*d,i[2]=s*-d+l*f,i[3]=c*-d+u*f)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){let n=t.L(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==n&&(this._unmodified=!1,this._pitchInRadians=n,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){let t=e/180*Math.PI;this._rollInRadians!==t&&(this._unmodified=!1,this._rollInRadians=t,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return t.aP(this._fovInRadians)}setFov(e){e=t.L(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=t.av(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){let n=this.getConstrained(this._center,e).zoom;this._zoom!==n&&(this._unmodified=!1,this._zoom=n,this._tileZoom=Math.max(0,Math.floor(n)),this._scale=t.aw(n),this._constrain(),this._calcMatrices())}get center(){return this._center}setCenter(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._constrain(),this._calcMatrices())}get detailLevel(){return this._detailLevel}setDetailLevel(e){if((e=Math.round(t.L(e,-3,3)))===this._detailLevel)return;let n=this._detailLevel;this._detailLevel=e,this.setZoom(this.zoom+this.detailLevel-n)}get rasterAlignment(){return this._rasterAlignment}setRasterAlignment(e){this._rasterAlignment=e}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,t){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=t,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,n){this._unmodified=!1,this._edgeInsets.interpolate(e,t,n),this._constrain(),this._calcMatrices()}resize(e,t,n=!0){this._width=e,this._height=t,n&&this._constrain(),this._calcMatrices()}getMaxBounds(){return this._latRange&&this._latRange.length===2&&this._lngRange&&this._lngRange.length===2?new I([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this._constrain()):(this._lngRange=null,this._latRange=[-t.ax,t.ax])}getConstrained(e,t){return this._callbacks.getConstrained(e,t)}getCameraQueryGeometry(e,n){if(n.length===1)return[n[0],e];{let{minX:r,minY:i,maxX:a,maxY:o}=t.a2.fromPoints(n).extend(e);return[new t.P(r,i),new t.P(a,i),new t.P(a,o),new t.P(r,o),new t.P(r,i)]}}_constrain(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;let e=this._unmodified,{center:t,zoom:n}=this.getConstrained(this.center,this.zoom);this.setCenter(t),this.setZoom(n),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=t.a4(new Float64Array(16));t.N(e,e,[this._width/2,-this._height/2,1]),t.a5(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=t.a4(new Float64Array(16)),t.N(e,e,[1,-1,1]),t.a5(e,e,[-1,-1,0]),t.N(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height*2**this._detailLevel}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,n,r,i){let a=r===void 0?this.bearing:r,o=i=i===void 0?this.pitch:i,s=t.aj.fromLngLat(e,n),c=-Math.cos(t.av(o)),l=Math.sin(t.av(o)),u=l*Math.sin(t.av(a)),d=-l*Math.cos(t.av(a)),f=this.elevation,p=n-f,m;c*p>=0||Math.abs(c)<.1?(m=1e4,f=n+m*c):m=-p/c;let h,g,_=t.aQ(1,s.y),v=0;do{if(v+=1,v>10)break;g=m/_,h=new t.aj(s.x+u*g,s.y+d*g),_=1/h.meterInMercatorCoordinateUnits()}while(Math.abs(m-g*_)>1e-12);return{center:h.toLngLat(),elevation:f,zoom:t.az(this.height/2/Math.tan(this.fovInRadians/2)/g/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;let n=t.ay(1,this.center.lat)*this.worldSize,r=this.cameraToCenterDistance/n,i=t.aj.fromLngLat(this.center,this.elevation),a=V(this.center,this.elevation,this.pitch,this.bearing,r);this._elevation=e;let o=this.calculateCenterFromCameraLngLatAlt(a.toLngLat(),t.aQ(a.z,i.y),this.bearing,this.pitch);this._elevation=o.elevation,this._center=o.center,this.setZoom(o.zoom)}getCameraPoint(){let e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.P(e*Math.sin(this.rollInRadians),e*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){let e=t.ay(1,this.center.lat)*this.worldSize;return V(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return[0,0,1,1];let n=e.canonical.z>=0?1<<e.canonical.z:2**e.canonical.z;return[e.canonical.x/n,e.canonical.y/n,1/n/t.ah,1/n/t.ah]}}class Bt{constructor(e,n){this.min=e,this.max=n,this.center=t.aR([],t.aS([],this.min,this.max),.5)}quadrant(e){let n=[e%2==0,e<2],r=t.aT(this.min),i=t.aT(this.max);for(let e=0;e<n.length;e++)r[e]=n[e]?this.min[e]:this.center[e],i[e]=n[e]?this.center[e]:this.max[e];return i[2]=this.max[2],new Bt(r,i)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}intersectsFrustum(e){let t=!0;for(let n=0;n<e.planes.length;n++){let r=this.intersectsPlane(e.planes[n]);if(r===0)return 0;r===1&&(t=!1)}return t?2:e.aabb.min[0]>this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]<this.min[0]||e.aabb.max[1]<this.min[1]||e.aabb.max[2]<this.min[2]?0:1}intersectsPlane(e){let t=e[3],n=e[3];for(let r=0;r<3;r++)e[r]>0?(t+=e[r]*this.min[r],n+=e[r]*this.max[r]):(n+=e[r]*this.min[r],t+=e[r]*this.max[r]);return t>=0?2:n<0?0:1}}class Vt{distanceToTile2d(e,t,n,r){let i=r.distanceX([e,t]),a=r.distanceY([e,t]);return Math.hypot(i,a)}getWrap(e,t,n){return n}getTileBoundingVolume(e,n,r,i){let a=0,o=0;if(i?.terrain){let s=new t.ag(e.z,n,e.z,e.x,e.y),c=i.terrain.getMinMaxElevation(s);a=c.minElevation??Math.min(0,r),o=c.maxElevation??Math.max(0,r)}let s=1<<e.z;return new Bt([n+e.x/s,e.y/s,a],[n+(e.x+1)/s,(e.y+1)/s,o])}allowVariableZoom(e,n){let r=e.fov*(Math.abs(Math.cos(e.rollInRadians))*e.height+Math.abs(Math.sin(e.rollInRadians))*e.width)/e.height,i=t.L(78.5-r/2,0,60);return!!n.terrain||e.pitch>i}allowWorldCopies(){return!0}prepareNextFrame(){}}class Ht{constructor(e,t,n){this.points=e,this.planes=t,this.aabb=n}static fromInvProjectionMatrix(e,n=1,r=0,i,a){let o=a?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],s=2**r,c=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((r=>function(e,n,r,i){let a=t.$([],e,n),o=1/a[3]/r*i;return t.aY(a,a,[o,o,1/a[3],o])}(r,e,n,s)));i&&function(e,n,r,i){let a=i?4:0,o=i?0:4,s=0,c=[],l=[];for(let n=0;n<4;n++){let r=t.aU([],e[n+o],e[n+a]),i=t.aZ(r);t.aR(r,r,1/i),c.push(i),l.push(r)}for(let n=0;n<4;n++){let i=t.a_(e[n+a],l[n],r);s=i!==null&&i>=0?Math.max(s,i):Math.max(s,c[n])}let u=function(e,n){let r=t.aU([],e[n[0]],e[n[1]]),i=t.aU([],e[n[2]],e[n[1]]),a=[0,0,0,0];return t.aV(a,t.aW([],r,i)),a[3]=-t.aX(a,e[n[0]]),a}(e,n),d=function(e,n){let r=t.a$(e),i=t.b0([],e,1/r),a=t.aU([],n,t.aR([],i,t.aX(n,i))),o=t.a$(a);if(o>0){let e=Math.sqrt(1-i[3]*i[3]),r=t.aR([],i,-i[3]),s=t.aS([],r,t.aR([],a,e/o));return t.b1(n,s)}return null}(r,u);if(d!==null){let e=d/t.aX(l[0],u);s=Math.min(s,e)}for(let t=0;t<4;t++){let n=Math.min(s,c[t]);e[t+o]=[e[t+a][0]+l[t][0]*n,e[t+a][1]+l[t][1]*n,e[t+a][2]+l[t][2]*n,1]}}(c,o[0],i,a);let l=o.map((e=>{let n=t.aU([],c[e[0]],c[e[1]]),r=t.aU([],c[e[2]],c[e[1]]),i=t.aV([],t.aW([],n,r)),a=-t.aX(i,c[e[1]]);return i.concat(a)})),u=[1/0,1/0,1/0],d=[-1/0,-1/0,-1/0];for(let e of c)for(let t=0;t<3;t++)u[t]=Math.min(u[t],e[t]),d[t]=Math.max(d[t],e[t]);return new Ht(c,l,new Bt(u,d))}}class Ut{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setDetailLevel(e){this._helper.setDetailLevel(e)}setRasterAlignment(e){this._helper.setRasterAlignment(e)}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,n){return this._helper.interpolatePadding(e,t,n)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,n=!0){this._helper.resize(e,t,n)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get detailLevel(){return this._helper.detailLevel}get rasterAlignment(){return this._helper.rasterAlignment}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,t){}constructor(e,t,n,r,i){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this._helper=new zt({calcMatrices:()=>{this._calcMatrices()},getConstrained:(e,t)=>this.getConstrained(e,t)},e,t,n,r,i),this._coveringTilesDetailsProvider=new Vt}clone(){let e=new Ut;return e.apply(this),e}apply(e,t,n){this._helper.apply(e,t,n)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){let n=[new t.b2(0,e)];if(this._helper._renderWorldCopies){let r=this.screenPointToMercatorCoordinate(new t.P(0,0)),i=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,0)),a=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,this._helper._height)),o=this.screenPointToMercatorCoordinate(new t.P(0,this._helper._height)),s=Math.floor(Math.min(r.x,i.x,a.x,o.x)),c=Math.floor(Math.max(r.x,i.x,a.x,o.x));for(let r=s-1;r<=c+1;r++)r!==0&&n.push(new t.b2(r,e))}return n}getCameraFrustum(){return Ht.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){let t=this.screenPointToLocation(this.centerPoint,e),n=e?e.getElevationForLngLatZoom(t,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(n)}setLocationAtPoint(e,n){let r=t.ay(this.elevation,this.center.lat),i=this.screenPointToMercatorCoordinateAtZ(n,r),a=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,r),o=t.aj.fromLngLat(e),s=new t.aj(o.x-(i.x-a.x),o.y-(i.y-a.y));this.setCenter(s?.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,n){return n?this.coordinatePoint(t.aj.fromLngLat(e),n.getElevationForLngLatZoom(e,this._helper._tileZoom),this._pixelMatrix3D):this.coordinatePoint(t.aj.fromLngLat(e))}screenPointToLocation(e,t){return this.screenPointToMercatorCoordinate(e,t)?.toLngLat()}screenPointToMercatorCoordinate(e,t){if(t){let n=t.pointCoordinate(e);if(n!=null)return n}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,n){let r=n||0,i=[e.x,e.y,0,1],a=[e.x,e.y,1,1];t.$(i,i,this._pixelMatrixInverse),t.$(a,a,this._pixelMatrixInverse);let o=i[3],s=a[3],c=i[1]/o,l=a[1]/s,u=i[2]/o,d=a[2]/s,f=u===d?0:(r-u)/(d-u);return new t.aj(t.C.number(i[0]/o,a[0]/s,f)/this.worldSize,t.C.number(c,l,f)/this.worldSize,r)}screenPointToMercatorCoordinateClamped(e){let n=[e.x,e.y,0,1],r=[e.x,e.y,1,1];t.$(n,n,this._pixelMatrixInverse),t.$(r,r,this._pixelMatrixInverse);let i=n[3],a=r[3],o=n[1]/i,s=r[1]/a,c=n[2]/i,l=r[2]/a,u=c===l?0:(0-c)/(l-c);return u<0&&(u=1-u),new t.aj(t.C.number(n[0]/i,r[0]/a,u)/this.worldSize,t.L(t.C.number(o,s,u)/this.worldSize,0,1),0)}coordinatePoint(e,n=0,r=this._pixelMatrix){let i=[e.x*this.worldSize,e.y*this.worldSize,n,1];return t.$(i,i,r),new t.P(i[0]/i[3],i[1]/i[3])}getBounds(){let e=Math.max(0,this._helper._height/2-Ze(this));return new I().extend(this.screenPointToLocation(new t.P(0,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new t.P(0,this._helper._height)))}isPointOnMapSurface(e,t){return t?t.pointCoordinate(e)!=null:e.y>this.height/2-Ze(this)}calculatePosMatrix(e,n=!1,r){let i=e.key??t.b3(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),a=n?this._alignedPosMatrixCache:this._posMatrixCache;if(a.has(i)){let e=a.get(i);return r?e.f32:e.f64}let o=Qe(e,this.worldSize);t.a8(o,n?this._alignedProjMatrix:this._viewProjMatrix,o);let s={f64:o,f32:new Float32Array(o)};return a.set(i,s),r?s.f32:s.f64}calculateFogMatrix(e){let n=e.key,r=this._fogMatrixCacheF32;if(r.has(n))return r.get(n);let i=Qe(e,this.worldSize);return t.a8(i,this._fogMatrix,i),r.set(n,new Float32Array(i)),r.get(n)}getConstrained(e,n){n=t.L(+n,this.minZoom,this.maxZoom);let r={center:new t.aa(e.lng,e.lat),zoom:n},i=this._helper._lngRange;if(!this._helper._renderWorldCopies&&i===null){let e=179.9999999999;i=[-e,e]}let a=this.tileSize*t.aw(r.zoom),o=0,s=a,c=0,l=a,u=0,d=0,{x:f,y:p}=this.size;if(this._helper._latRange){let e=this._helper._latRange;o=t.ab(e[1])*a,s=t.ab(e[0])*a,s-o<p&&(u=p/(s-o))}i&&(c=t.aO(t.ac(i[0])*a,0,a),l=t.aO(t.ac(i[1])*a,0,a),l<c&&(l+=a),l-c<f&&(d=f/(l-c)));let{x:m,y:h}=B(a,e),g,_,v=Math.max(d||0,u||0);if(v)return r.center=Xe(a,new t.P(d?(l+c)/2:m,u?(s+o)/2:h)).wrap(),r.zoom+=t.az(v),r;if(this._helper._latRange){let e=p/2;h-e<o&&(_=o+e),h+e>s&&(_=s-e)}if(i){let e=(c+l)/2,n=m;this._helper._renderWorldCopies&&(n=t.aO(m,e-a/2,e+a/2));let r=f/2;n-r<c&&(g=c+r),n+r>l&&(g=l-r)}return(g!==void 0||_!==void 0)&&(r.center=Xe(a,new t.P(g??m,_??h)).wrap()),r}calculateCenterFromCameraLngLatAlt(e,t,n,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,n,r)}_calculateNearFarZIfNeeded(e,n,r){if(!this._helper.autoCalculateNearFarZ)return;let i=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),a=e-i*this._helper._pixelPerMeter/Math.cos(n),o=i<0?a:e,s=Math.PI/2+this.pitchInRadians,c=t.av(this.fov)*(Math.abs(Math.cos(t.av(this.roll)))*this.height+Math.abs(Math.sin(t.av(this.roll)))*this.width)/this.height*(.5+r.y/this.height),l=Math.sin(c)*o/Math.sin(t.L(Math.PI-s-c,.01,Math.PI-.01)),u=Ze(this),d=Math.atan(u/this._helper.cameraToCenterDistance),f=t.av(.75),p=d>f?2*d*(.5+r.y/(2*u)):f,m=Math.sin(p)*o/Math.sin(t.L(Math.PI-s-p,.01,Math.PI-.01)),h=Math.min(l,m);this._helper._farZ=1.01*(Math.cos(Math.PI/2-n)*h+o),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;let e=this.centerOffset,n=B(this.worldSize,this.center),r=n.x,i=n.y;this._helper._pixelPerMeter=t.ay(1,this.center.lat)*this.worldSize;let a=t.av(Math.min(this.pitch,z)),o=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(a)),s;this._calculateNearFarZIfNeeded(o,a,e),s=new Float64Array(16),t.b4(s,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),t.S(this._invProjMatrix,s),s[8]=2*-e.x/this._helper._width,s[9]=2*e.y/this._helper._height,this._projectionMatrix=t.b5(s),t.N(s,s,[1,-1,1]),t.a5(s,s,[0,0,-this._helper.cameraToCenterDistance]),t.b6(s,s,-this.rollInRadians),t.b7(s,s,this.pitchInRadians),t.b6(s,s,-this.bearingInRadians),t.a5(s,s,[-r,-i,0]),this._mercatorMatrix=t.N([],s,[this.worldSize,this.worldSize,this.worldSize]),t.N(s,s,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=t.a8(new Float64Array(16),this.clipSpaceToPixelsMatrix,s),t.a5(s,s,[0,0,-this.elevation]),this._viewProjMatrix=s,this._invViewProjMatrix=t.S([],s);let c=[0,0,-1,1];if(t.$(c,c,this._invViewProjMatrix),this._cameraPosition=[c[0]/c[3],c[1]/c[3],c[2]/c[3]],this._fogMatrix=new Float64Array(16),t.b4(this._fogMatrix,this.fovInRadians,this.width/this.height,o,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,t.N(this._fogMatrix,this._fogMatrix,[1,-1,1]),t.a5(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),t.b6(this._fogMatrix,this._fogMatrix,-this.rollInRadians),t.b7(this._fogMatrix,this._fogMatrix,this.pitchInRadians),t.b6(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),t.a5(this._fogMatrix,this._fogMatrix,[-r,-i,0]),t.N(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),t.a5(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=t.a8(new Float64Array(16),this.clipSpaceToPixelsMatrix,s),this._helper.rasterAlignment){let e=this._helper._width%2/2,n=this._helper._height%2/2,a=Math.cos(this.bearingInRadians),o=Math.sin(-this.bearingInRadians),c=r-Math.round(r)+a*e+o*n,l=i-Math.round(i)+a*n+o*e,u=new Float64Array(s);t.a5(u,u,[c>.5?c-1:c,l>.5?l-1:l,0]),this._alignedProjMatrix=u,s=t.S(new Float64Array(16),this._pixelMatrix)}else this._alignedProjMatrix=new Float64Array(s);if(!s)throw Error(`failed to invert matrix`);this._pixelMatrixInverse=s,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;let e=this.screenPointToMercatorCoordinate(new t.P(0,0)),n=[e.x*this.worldSize,e.y*this.worldSize,0,1];return t.$(n,n,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){let e=t.ay(1,this.center.lat)*this.worldSize;return V(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,n){let r=t.aj.fromLngLat(e),i=[r.x*this.worldSize,r.y*this.worldSize,n,1];return t.$(i,i,this._viewProjMatrix),i[2]/i[3]}getProjectionData(e){let{overscaledTileID:n,aligned:r,applyTerrainMatrix:i}=e,a=this._helper.getMercatorTileCoordinates(n),o=n?this.calculatePosMatrix(n,r,!0):null,s;return s=n&&n.terrainRttPosMatrix32f&&i?n.terrainRttPosMatrix32f:o||t.b8(),{mainMatrix:s,tileMercatorCoords:a,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:s}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,t,n){return 1}transformLightDirection(e){return t.aT(e)}getRayDirectionFromPixel(e){throw Error(`Not implemented.`)}projectTileCoordinates(e,n,r,i){let a=this.calculatePosMatrix(r),o;i?(o=[e,n,i(e,n),1],t.$(o,o,a)):(o=[e,n,0,1],Ee(o,o,a));let s=o[3];return{point:new t.P(o[0]/s,o[1]/s),signedDistanceFromCamera:s,isOccluded:!1}}populateCache(e){for(let t of e)this.calculatePosMatrix(t)}getMatrixForModel(e,n){let r=t.aj.fromLngLat(e,n),i=r.meterInMercatorCoordinateUnits(),a=t.b9();return t.a5(a,a,[r.x,r.y,r.z]),t.b6(a,a,Math.PI),t.b7(a,a,Math.PI/2),t.N(a,a,[-i,i,i]),a}getProjectionDataForCustomLayer(e=!0){let n=new t.ag(0,0,0,0,0),r=this.getProjectionData({overscaledTileID:n,applyGlobeMatrix:e}),i=Qe(n,this.worldSize);t.a8(i,this._viewProjMatrix,i),r.tileMercatorCoords=[0,0,1,1];let a=[t.ah,t.ah,this.worldSize/this._helper.pixelsPerMeter],o=t.ba();return t.N(o,i,a),r.fallbackMatrix=o,r.mainMatrix=o,r}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function Wt(){t.w(`Map cannot fit within canvas with the given bounds, padding, and/or offset.`)}function Gt(e){if(e.useSlerp)if(e.k<1){let n=t.bb(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),r=t.bb(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),i=new Float64Array(4);t.bc(i,n,r,e.k);let a=t.bd(i);e.tr.setRoll(a.roll),e.tr.setPitch(a.pitch),e.tr.setBearing(a.bearing)}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(t.C.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(t.C.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(t.C.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k))}function Kt(e,n,r,i,a){let o=a.padding,s=B(a.worldSize,r.getNorthWest()),c=B(a.worldSize,r.getNorthEast()),l=B(a.worldSize,r.getSouthEast()),u=B(a.worldSize,r.getSouthWest()),d=t.av(-i),f=s.rotate(d),p=c.rotate(d),m=l.rotate(d),h=u.rotate(d),g=new t.P(Math.max(f.x,p.x,h.x,m.x),Math.max(f.y,p.y,h.y,m.y)),_=new t.P(Math.min(f.x,p.x,h.x,m.x),Math.min(f.y,p.y,h.y,m.y)),v=g.sub(_),y=(a.width-(o.left+o.right+n.left+n.right))/v.x,b=(a.height-(o.top+o.bottom+n.top+n.bottom))/v.y;if(b<0||y<0)return void Wt();let x=Math.min(t.az(a.scale*Math.min(y,b)),e.maxZoom),S=t.P.convert(e.offset),C=new t.P((n.left-n.right)/2,(n.top-n.bottom)/2).rotate(t.av(i)),w=S.add(C).mult(a.scale/t.aw(x));return{center:Xe(a.worldSize,s.add(l).div(2).sub(w)),zoom:x,bearing:i}}class qt{get useGlobeControls(){return!1}handlePanInertia(e,t){return{easingOffset:e,easingCenter:t.center}}handleMapControlsRollPitchBearingZoom(e,t){e.bearingDelta&&t.setBearing(t.bearing+e.bearingDelta),e.pitchDelta&&t.setPitch(t.pitch+e.pitchDelta),e.rollDelta&&t.setRoll(t.roll+e.rollDelta),e.zoomDelta&&t.setZoom(t.zoom+e.zoomDelta)}handleMapControlsPan(e,t,n){e.around.distSqr(t.centerPoint)<.01||t.setLocationAtPoint(n,e.around)}cameraForBoxAndBearing(e,t,n,r,i){return Kt(e,t,n,r,i)}handleJumpToCenterZoom(e,n){e.zoom!==(n.zoom===void 0?e.zoom:+n.zoom)&&e.setZoom(+n.zoom),n.center!==void 0&&e.setCenter(t.aa.convert(n.center))}handleEaseTo(e,n){let r=e.zoom,i=e.padding,a={roll:e.roll,pitch:e.pitch,bearing:e.bearing},o={roll:n.roll===void 0?e.roll:n.roll,pitch:n.pitch===void 0?e.pitch:n.pitch,bearing:n.bearing===void 0?e.bearing:n.bearing},s=n.zoom!==void 0,c=!e.isPaddingEqual(n.padding),l=!1,u=s?+n.zoom:e.zoom,d=e.centerPoint.add(n.offsetAsPoint),f=e.screenPointToLocation(d),{center:p,zoom:m}=e.getConstrained(t.aa.convert(n.center||f),u??r);Lt(e,p);let h=B(e.worldSize,f),g=B(e.worldSize,p).sub(h),_=t.aw(m-r);return l=m!==r,{easeFunc:s=>{if(l&&e.setZoom(t.C.number(r,m,s)),t.be(a,o)||Gt({startEulerAngles:a,endEulerAngles:o,tr:e,k:s,useSlerp:a.roll!=o.roll}),c&&(e.interpolatePadding(i,n.padding,s),d=e.centerPoint.add(n.offsetAsPoint)),n.around)e.setLocationAtPoint(n.around,n.aroundPoint);else{let n=t.aw(e.zoom-r),i=(m>r?Math.min(2,_):Math.max(.5,_))**(1-s),a=Xe(e.worldSize,h.add(g.mult(s*i)).mult(n));e.setLocationAtPoint(e.renderWorldCopies?a.wrap():a,d)}},isZooming:l,elevationCenter:p}}handleFlyTo(e,n){let r=n.zoom!==void 0,i=e.zoom,a=e.getConstrained(t.aa.convert(n.center||n.locationAtOffset),r?+n.zoom:i),o=a.center,s=a.zoom;Lt(e,o);let c=B(e.worldSize,n.locationAtOffset),l=B(e.worldSize,o).sub(c),u=l.mag(),d=t.aw(s-i),f;if(n.minZoom!==void 0){let r=Math.min(+n.minZoom,i,s),a=e.getConstrained(o,r).zoom;f=t.aw(a-i)}return{easeFunc:(n,r,a,u)=>{e.setZoom(n===1?s:i+t.az(r));let d=n===1?o:Xe(e.worldSize,c.add(l.mult(a)).mult(r));e.setLocationAtPoint(e.renderWorldCopies?d.wrap():d,u)},scaleOfZoom:d,targetCenter:o,scaleOfMinZoom:f,pixelPathLength:u}}}class Jt{constructor(e,t,n){this.blendFunction=e,this.blendColor=t,this.mask=n}}Jt.Replace=[1,0],Jt.disabled=new Jt(Jt.Replace,t.bf.transparent,[!1,!1,!1,!1]),Jt.unblended=new Jt(Jt.Replace,t.bf.transparent,[!0,!0,!0,!0]),Jt.alphaBlended=new Jt([1,771],t.bf.transparent,[!0,!0,!0,!0]);let Yt=2305;class W{constructor(e,t,n){this.enable=e,this.mode=t,this.frontFace=n}}W.disabled=new W(!1,1029,Yt),W.backCCW=new W(!0,1029,Yt),W.frontCCW=new W(!0,1028,Yt);class G{constructor(e,t,n){this.func=e,this.mask=t,this.range=n}}G.ReadOnly=!1,G.ReadWrite=!0,G.disabled=new G(519,G.ReadOnly,[0,1]);let Xt=7680;class K{constructor(e,t,n,r,i,a){this.test=e,this.ref=t,this.mask=n,this.fail=r,this.depthFail=i,this.pass=a}}K.disabled=new K({func:519,mask:0},0,0,Xt,Xt,Xt);let Zt=new WeakMap;function Qt(e){if(Zt.has(e))return Zt.get(e);{let t=e.getParameter(e.VERSION)?.startsWith(`WebGL 2.0`);return Zt.set(e,t),t}}class $t{get awaitingQuery(){return!!this._readbackQueue}constructor(e){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=e;let n=e.context,r=n.gl;this._texFormat=r.RGBA,this._texType=r.UNSIGNED_BYTE;let i=new t.aL;i.emplaceBack(-1,-1),i.emplaceBack(2,-1),i.emplaceBack(-1,2);let a=new t.aN;a.emplaceBack(0,1,2),this._fullscreenTriangle=new Mt(n.createVertexBuffer(i,Nt.members),n.createIndexBuffer(a),t.aM.simpleSegment(0,0,i.length,a.length)),this._resultBuffer=new Uint8Array(4),n.activeTexture.set(r.TEXTURE1);let o=r.createTexture();r.bindTexture(r.TEXTURE_2D,o),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texImage2D(r.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=n.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(o),Qt(r)&&(this._pbo=r.createBuffer(),r.bindBuffer(r.PIXEL_PACK_BUFFER,this._pbo),r.bufferData(r.PIXEL_PACK_BUFFER,4,r.STREAM_READ),r.bindBuffer(r.PIXEL_PACK_BUFFER,null))}destroy(){let e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(e,t){let n=this._updateCount;return this._readbackQueue?n>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():n>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,t),this._updateCount++,this._measuredError}_bindFramebuffer(){let e=this._cachedRenderContext.context,t=e.gl;e.activeTexture.set(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(e,n){let r=this._cachedRenderContext.context,i=r.gl;if(this._bindFramebuffer(),r.viewport.set([0,0,this._texWidth,this._texHeight]),r.clear({color:t.bf.transparent}),this._cachedRenderContext.useProgram(`projectionErrorMeasurement`).draw(r,i.TRIANGLES,G.disabled,K.disabled,Jt.unblended,W.disabled,((e,t)=>({u_input:e,u_output_expected:t}))(e,n),null,null,`$clipping`,this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&Qt(i)){i.bindBuffer(i.PIXEL_PACK_BUFFER,this._pbo),i.readBuffer(i.COLOR_ATTACHMENT0),i.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),i.bindBuffer(i.PIXEL_PACK_BUFFER,null);let e=i.fenceSync(i.SYNC_GPU_COMMANDS_COMPLETE,0);i.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:e}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){let e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&Qt(e)){let n=e.clientWaitSync(this._readbackQueue.sync,0,0);if(n===e.WAIT_FAILED)return t.w(`WebGL2 clientWaitSync failed.`),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(n===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=$t._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(e){let t=0;return t+=e[0]/256,t+=e[1]/65536,t+=e[2]/16777216,e[3]<127&&(t=-t),t/128}}let en=t.ah/128;function tn(e,n){let r=e.granularity===void 0?1:Math.max(e.granularity,1),i=r+(e.generateBorders?2:0),a=r+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),o=i+1,s=a+1,c=e.generateBorders?-1:0,l=e.generateBorders||e.extendToNorthPole?-1:0,u=r+(e.generateBorders?1:0),d=r+(e.generateBorders||e.extendToSouthPole?1:0),f=o*s,p=i*a*6,m=o*s>65536;if(m&&n===`16bit`)throw Error(`Granularity is too large and meshes would not fit inside 16 bit vertex indices.`);let h=m||n===`32bit`,g=new Int16Array(2*f),_=0;for(let n=l;n<=d;n++)for(let i=c;i<=u;i++){let a=i/r*t.ah;i===-1&&(a=-en),i===r+1&&(a=t.ah+en);let o=n/r*t.ah;n===-1&&(o=e.extendToNorthPole?t.bh:-en),n===r+1&&(o=e.extendToSouthPole?t.bi:t.ah+en),g[_++]=a,g[_++]=o}let v=h?new Uint32Array(p):new Uint16Array(p),y=0;for(let e=0;e<a;e++)for(let t=0;t<i;t++){let n=t+1+e*o,r=t+(e+1)*o,i=t+1+(e+1)*o;v[y++]=t+e*o,v[y++]=r,v[y++]=n,v[y++]=n,v[y++]=r,v[y++]=i}return{vertices:g.buffer.slice(0),indices:v.buffer.slice(0),uses32bitIndices:h}}let nn=new t.aK({fill:new t.bj(128,2),line:new t.bj(512,0),tile:new t.bj(128,32),stencil:new t.bj(128,1),circle:3});class rn{constructor(){this._tileMeshCache={},this._errorCorrectionUsable=0,this._errorMeasurementLastValue=0,this._errorCorrectionPreviousValue=0,this._errorMeasurementLastChangeTime=-1e3}get name(){return`vertical-perspective`}get transitionState(){return 1}get useSubdivision(){return!0}get shaderVariantName(){return`globe`}get shaderDefine(){return`#define GLOBE`}get shaderPreludeCode(){return jt.projectionGlobe}get vertexShaderPreludeCode(){return jt.projectionMercator.vertexSource}get subdivisionGranularity(){return nn}get useGlobeControls(){return!0}get latitudeErrorCorrectionRadians(){return this._errorCorrectionUsable}destroy(){this._errorMeasurement&&this._errorMeasurement.destroy()}updateGPUdependent(e){this._errorMeasurement||=new $t(e);let n=t.ab(this._errorQueryLatitudeDegrees),r=2*Math.atan(Math.exp(Math.PI-n*Math.PI*2))-.5*Math.PI,i=this._errorMeasurement.updateErrorLoop(n,r),a=o.now();i!==this._errorMeasurementLastValue&&(this._errorCorrectionPreviousValue=this._errorCorrectionUsable,this._errorMeasurementLastValue=i,this._errorMeasurementLastChangeTime=a);let s=Math.min(Math.max((a-this._errorMeasurementLastChangeTime)/1e3/.5,0),1);this._errorCorrectionUsable=t.bk(this._errorCorrectionPreviousValue,-this._errorMeasurementLastValue,t.bl(s))}_getMeshKey(e){return`${e.granularity.toString(36)}_${e.generateBorders?`b`:``}${e.extendToNorthPole?`n`:``}${e.extendToSouthPole?`s`:``}`}getMeshFromTileID(e,t,n,r,i){let a=(i===`stencil`?nn.stencil:nn.tile).getGranularityForZoomLevel(t.z);return this._getMesh(e,{granularity:a,generateBorders:n,extendToNorthPole:t.y===0&&r,extendToSouthPole:t.y===(1<<t.z)-1&&r})}_getMesh(e,n){let r=this._getMeshKey(n);if(r in this._tileMeshCache)return this._tileMeshCache[r];let i=function(e,n){let r=tn(n,`16bit`),i=t.aL.deserialize({arrayBuffer:r.vertices,length:r.vertices.byteLength/2/2}),a=t.aN.deserialize({arrayBuffer:r.indices,length:r.indices.byteLength/2/3});return new Mt(e.createVertexBuffer(i,Nt.members),e.createIndexBuffer(a),t.aM.simpleSegment(0,0,i.length,a.length))}(e,n);return this._tileMeshCache[r]=i,i}recalculate(e){}hasTransition(){let e=o.now(),t=!1;return t||=(e-this._errorMeasurementLastChangeTime)/1e3<.7,t||=this._errorMeasurement&&this._errorMeasurement.awaitingQuery,t}setErrorQueryLatitudeDegrees(e){this._errorQueryLatitudeDegrees=e}}let an=new t.r({type:new t.D(t.v.projection.type)});class on extends t.E{constructor(e){super(),this._transitionable=new t.t(an),this.setProjection(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new t.F(0)),this._mercatorProjection=new Ft,this._verticalPerspectiveProjection=new rn}get transitionState(){let e=this.properties.get(`type`);if(typeof e==`string`&&e===`mercator`)return 0;if(typeof e==`string`&&e===`vertical-perspective`)return 1;if(e instanceof t.bm){if(e.from===`vertical-perspective`&&e.to===`mercator`)return 1-e.transition;if(e.from===`mercator`&&e.to===`vertical-perspective`)return e.transition}return 1}get useGlobeRendering(){return this.transitionState>0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return`globe`}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e)}getMeshFromTileID(e,t,n,r,i){return this.currentProjection.getMeshFromTileID(e,t,n,r,i)}setProjection(e){this._transitionable.setValue(`type`,e?.type||`mercator`)}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}setErrorQueryLatitudeDegrees(e){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(e),this._mercatorProjection.setErrorQueryLatitudeDegrees(e)}}function sn(e){let t=un(e.worldSize,e.center.lat);return 2*Math.PI*t}function cn(e,n,r,i,a){let o=1/(1<<a),s=n/t.ah*o+i*o,c=t.bo((e/t.ah*o+r*o)*Math.PI*2+Math.PI,2*Math.PI),l=2*Math.atan(Math.exp(Math.PI-s*Math.PI*2))-.5*Math.PI,u=Math.cos(l),d=new Float64Array(3);return d[0]=Math.sin(c)*u,d[1]=Math.sin(l),d[2]=Math.cos(c)*u,d}function ln(e){return function(e,t){let n=Math.cos(t),r=new Float64Array(3);return r[0]=Math.sin(e)*n,r[1]=Math.sin(t),r[2]=Math.cos(e)*n,r}(e.lng*Math.PI/180,e.lat*Math.PI/180)}function un(e,t){return e/(2*Math.PI)/Math.cos(t*Math.PI/180)}function dn(e){let n=Math.asin(e[1])/Math.PI*180,r=Math.sqrt(e[0]*e[0]+e[2]*e[2]);if(r>1e-6){let i=e[0]/r,a=Math.acos(e[2]/r),o=(i>0?a:-a)/Math.PI*180;return new t.aa(t.aO(o,-180,180),n)}return new t.aa(0,n)}function fn(e){return Math.cos(e*Math.PI/180)}function pn(e,n){let r=fn(e),i=fn(n);return t.az(i/r)}function mn(e,n){let r=e.rotate(n.bearingInRadians),i=n.zoom+pn(n.center.lat,0),a=t.bk(1/fn(n.center.lat),1/fn(Math.min(Math.abs(n.center.lat),60)),t.bn(i,7,3,0,1)),o=360/sn({worldSize:n.worldSize,center:{lat:n.center.lat}});return new t.aa(n.center.lng-r.x*o*a,t.L(n.center.lat+r.y*o,-t.ax,t.ax))}function hn(e){let t=.5*e,n=Math.sin(t),r=Math.cos(t);return Math.log(n+r)-Math.log(r-n)}function gn(e,n,r,i){let a=e.lat+r*i;if(Math.abs(r)>1){let o=(Math.sign(e.lat+r)===Math.sign(e.lat)?Math.abs(e.lat):-Math.abs(e.lat))*Math.PI/180,s=Math.abs(e.lat+r)*Math.PI/180,c=hn(o+i*(s-o)),l=hn(o),u=hn(s);return new t.aa(e.lng+n*((c-l)/(u-l)),a)}return new t.aa(e.lng+n*i,a)}class _n{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=e}swapBuffers(){if(!this._hadAnyChanges)return;let e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(e,t,n,r){let i=`${e.z}_${e.x}_${e.y}_${r?.terrain?`t`:``}`,a=this._cache.get(i);if(a)return a;let o=this._cachePrevious.get(i);if(o)return this._cache.set(i,o),o;let s=this._boundingVolumeFactory(e,t,n,r);return this._cache.set(i,s),this._hadAnyChanges=!0,s}}class vn{constructor(e,t,n,r){this.min=n,this.max=r,this.points=e,this.planes=t}static fromAabb(e,t){let n=[];for(let r=0;r<8;r++)n.push([1&~r?e[0]:t[0],(r>>1&1)==1?t[1]:e[1],(r>>2&1)==1?t[2]:e[2]]);return new vn(n,[[-1,0,0,t[0]],[1,0,0,-e[0]],[0,-1,0,t[1]],[0,1,0,-e[1]],[0,0,-1,t[2]],[0,0,1,-e[2]]],e,t)}static fromCenterSizeAngles(e,n,r){let i=t.br([],r[0],r[1],r[2]),a=t.bs([],[n[0],0,0],i),o=t.bs([],[0,n[1],0],i),s=t.bs([],[0,0,n[2]],i),c=[...e],l=[...e];for(let t=0;t<8;t++)for(let n=0;n<3;n++){let r=e[n]+a[n]*(1&~t?-1:1)+o[n]*((t>>1&1)==1?1:-1)+s[n]*((t>>2&1)==1?1:-1);c[n]=Math.min(c[n],r),l[n]=Math.max(l[n],r)}let u=[];for(let n=0;n<8;n++){let r=[...e];t.aS(r,r,t.aR([],a,1&~n?-1:1)),t.aS(r,r,t.aR([],o,(n>>1&1)==1?1:-1)),t.aS(r,r,t.aR([],s,(n>>2&1)==1?1:-1)),u.push(r)}return new vn(u,[[...a,-t.aX(a,u[0])],[...o,-t.aX(o,u[0])],[...s,-t.aX(s,u[0])],[-a[0],-a[1],-a[2],-t.aX(a,u[7])],[-o[0],-o[1],-o[2],-t.aX(o,u[7])],[-s[0],-s[1],-s[2],-t.aX(s,u[7])]],c,l)}intersectsFrustum(e){let t=!0,n=this.points.length,r=this.planes.length,i=e.planes.length,a=e.points.length;for(let r=0;r<i;r++){let i=e.planes[r],a=0;for(let e=0;e<n;e++){let t=this.points[e];i[0]*t[0]+i[1]*t[1]+i[2]*t[2]+i[3]>=0&&a++}if(a===0)return 0;a<n&&(t=!1)}if(t)return 2;for(let t=0;t<r;t++){let n=this.planes[t],r=0;for(let t=0;t<a;t++){let i=e.points[t];n[0]*i[0]+n[1]*i[1]+n[2]*i[2]+n[3]>=0&&r++}if(r===0)return 0}return 1}intersectsPlane(e){let t=this.points.length,n=0;for(let r=0;r<t;r++){let t=this.points[r];e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]>=0&&n++}return n===t?2:n===0?0:1}}function yn(e,t,n){let r=e-t;return r<0?-r:Math.max(0,r-n)}function bn(e,t,n,r,i){let a=e-n,o;return o=a<0?Math.min(-a,1+a-i):a>1?Math.min(Math.max(a-i,0),1-a):0,Math.max(o,yn(t,r,i))}class xn{constructor(){this._boundingVolumeCache=new _n(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,t,n,r){let i=1<<n.z,a=1/i,o=n.x/i,s=n.y/i,c=2;return c=Math.min(c,bn(e,t,o,s,a)),c=Math.min(c,bn(e,t,o+.5,-s-a,a)),c=Math.min(c,bn(e,t,o+.5,2-s-a,a)),c}getWrap(e,t,n){let r=1<<t.z,i=1/r,a=t.x/r,o=yn(e.x,a,i),s=yn(e.x,a-1,i),c=yn(e.x,a+1,i),l=Math.min(o,s,c);return l===c?1:l===s?-1:0}allowVariableZoom(e,t){return rt(e,t)>4}allowWorldCopies(){return!1}getTileBoundingVolume(e,t,n,r){return this._boundingVolumeCache.getTileBoundingVolume(e,t,n,r)}_computeTileBoundingVolume(e,n,r,i){let a=0,o=0;if(i?.terrain){let s=new t.ag(e.z,n,e.z,e.x,e.y),c=i.terrain.getMinMaxElevation(s);a=c.minElevation??Math.min(0,r),o=c.maxElevation??Math.max(0,r)}if(a/=t.bu,o/=t.bu,a+=1,o+=1,e.z<=0)return vn.fromAabb([-o,-o,-o],[o,o,o]);if(e.z===1)return vn.fromAabb([e.x===0?-o:0,e.y===0?0:-o,-o],[e.x===0?0:o,e.y===0?o:0,o]);{let n=[cn(0,0,e.x,e.y,e.z),cn(t.ah,0,e.x,e.y,e.z),cn(t.ah,t.ah,e.x,e.y,e.z),cn(0,t.ah,e.x,e.y,e.z)],r=[];for(let e of n)r.push(t.aR([],e,o));if(o!==a)for(let e of n)r.push(t.aR([],e,a));e.y===0&&r.push([0,1,0]),e.y===(1<<e.z)-1&&r.push([0,-1,0]);let i=[1,1,1],s=[-1,-1,-1];for(let e of r)for(let t=0;t<3;t++)i[t]=Math.min(i[t],e[t]),s[t]=Math.max(s[t],e[t]);let c=cn(t.ah/2,t.ah/2,e.x,e.y,e.z),l=t.aW([],[0,1,0],c);t.aV(l,l);let u=t.aW([],c,l);t.aV(u,u);let d=t.aW([],n[2],n[1]);t.aV(d,d);let f=t.aW([],n[0],n[3]);t.aV(f,f),r.push(t.aR([],c,o)),e.y>=(1<<e.z)/2&&r.push(t.aR([],cn(t.ah/2,0,e.x,e.y,e.z),o)),e.y<(1<<e.z)/2&&r.push(t.aR([],cn(t.ah/2,t.ah,e.x,e.y,e.z),o));let p=Sn(c,r),m=Sn(u,r),h=[-c[0],-c[1],-c[2],p.max],g=[c[0],c[1],c[2],-p.min],_=[-u[0],-u[1],-u[2],m.max],v=[u[0],u[1],u[2],-m.min],y=[...d,0],b=[...f,0],x=[];return e.y===0?x.push(t.bt(b,y,h),t.bt(b,y,g)):x.push(t.bt(_,y,h),t.bt(_,y,g),t.bt(_,b,h),t.bt(_,b,g)),e.y===(1<<e.z)-1?x.push(t.bt(b,y,h),t.bt(b,y,g)):x.push(t.bt(v,y,h),t.bt(v,y,g),t.bt(v,b,h),t.bt(v,b,g)),new vn(x,[h,g,_,v,y,b],i,s)}}}function Sn(e,n){let r=1/0,i=-1/0;for(let a of n){let n=t.aX(e,a);r=Math.min(r,n),i=Math.max(i,n)}return{min:r,max:i}}class Cn{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setDetailLevel(e){this._helper.setDetailLevel(e)}setRasterAlignment(e){this._helper.setRasterAlignment(e)}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,n){return this._helper.interpolatePadding(e,t,n)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t){this._helper.resize(e,t)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get detailLevel(){return this._helper.detailLevel}get rasterAlignment(){return this._helper.rasterAlignment}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e){}constructor(){this._cachedClippingPlane=t.bv(),this._projectionMatrix=t.b9(),this._globeViewProjMatrix32f=t.b8(),this._globeViewProjMatrixNoCorrection=t.b9(),this._globeViewProjMatrixNoCorrectionInverted=t.b9(),this._globeProjMatrixInverted=t.b9(),this._cameraPosition=t.bp(),this._globeLatitudeErrorCorrectionRadians=0,this._helper=new zt({calcMatrices:()=>{this._calcMatrices()},getConstrained:(e,t)=>this.getConstrained(e,t)}),this._coveringTilesDetailsProvider=new xn}clone(){let e=new Cn;return e.apply(this),e}apply(e,t){this._globeLatitudeErrorCorrectionRadians=t||0,this._helper.apply(e)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){let e=t.bp();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){let{overscaledTileID:t,applyGlobeMatrix:n}=e,r=this._helper.getMercatorTileCoordinates(t);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:r,clippingPlane:this._cachedClippingPlane,projectionTransition:n?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){let n=this.pitchInRadians,r=this.cameraToCenterDistance/e,i=Math.sin(n)*r,a=Math.cos(n)*r+1,o=1/Math.sqrt(i*i+a*a)*1,s=-i,c=a,l=Math.sqrt(s*s+c*c);s/=l,c/=l;let u=[0,s,c];t.bw(u,u,[0,0,0],-this.bearingInRadians),t.bx(u,u,[0,0,0],-1*this.center.lat*Math.PI/180),t.by(u,u,[0,0,0],this.center.lng*Math.PI/180);let d=1/t.aZ(u);return t.aR(u,u,d),[...u,-o*d]}isLocationOccluded(e){return!this.isSurfacePointVisible(ln(e))}transformLightDirection(e){let n=this._helper._center.lng*Math.PI/180,r=this._helper._center.lat*Math.PI/180,i=Math.cos(r),a=[Math.sin(n)*i,Math.sin(r),Math.cos(n)*i],o=[a[2],0,-a[0]],s=[0,0,0];t.aW(s,o,a),t.aV(o,o),t.aV(s,s);let c=[0,0,0];return t.aV(c,[o[0]*e[0]+s[0]*e[1]+a[0]*e[2],o[1]*e[0]+s[1]*e[1]+a[1]*e[2],o[2]*e[0]+s[2]*e[1]+a[2]*e[2]]),c}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,n,r){let i=function(e,n,r){let i=1/(1<<r.z);return new t.aj(e/t.ah*i+r.x*i,n/t.ah*i+r.y*i)}(e,n,r.canonical),a=(o=i.y,[t.bo(i.x*Math.PI*2+Math.PI,2*Math.PI),2*Math.atan(Math.exp(Math.PI-o*Math.PI*2))-.5*Math.PI]);var o;return this.getCircleRadiusCorrection()/Math.cos(a[1])}projectTileCoordinates(e,n,r,i){let a=r.canonical,o=cn(e,n,a.x,a.y,a.z),s=1+(i?i(e,n):0)/t.bu,c=[o[0]*s,o[1]*s,o[2]*s,1];t.$(c,c,this._globeViewProjMatrixNoCorrection);let l=this._cachedClippingPlane,u=l[0]*o[0]+l[1]*o[1]+l[2]*o[2]+l[3]<0;return{point:new t.P(c[0]/c[3],c[1]/c[3]),signedDistanceFromCamera:c[3],isOccluded:u}}_calcMatrices(){if(!this._helper._width||!this._helper._height)return;let e=un(this.worldSize,this.center.lat),n=t.ba(),r=t.ba();this._helper.autoCalculateNearFarZ&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+2*e),t.b4(n,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);let i=this.centerOffset;n[8]=2*-i.x/this._helper._width,n[9]=2*i.y/this._helper._height,this._projectionMatrix=t.b5(n),this._globeProjMatrixInverted=t.ba(),t.S(this._globeProjMatrixInverted,n),t.a5(n,n,[0,0,-this.cameraToCenterDistance]),t.b6(n,n,this.rollInRadians),t.b7(n,n,-this.pitchInRadians),t.b6(n,n,this.bearingInRadians),t.a5(n,n,[0,0,-e]);let a=t.bp();a[0]=e,a[1]=e,a[2]=e,t.b7(r,n,this.center.lat*Math.PI/180),t.bz(r,r,-this.center.lng*Math.PI/180),t.N(r,r,a),this._globeViewProjMatrixNoCorrection=r,t.b7(n,n,this.center.lat*Math.PI/180-this._globeLatitudeErrorCorrectionRadians),t.bz(n,n,-this.center.lng*Math.PI/180),t.N(n,n,a),this._globeViewProjMatrix32f=new Float32Array(n),this._globeViewProjMatrixNoCorrectionInverted=t.ba(),t.S(this._globeViewProjMatrixNoCorrectionInverted,r);let o=t.bp();this._cameraPosition=t.bp(),this._cameraPosition[2]=this.cameraToCenterDistance/e,t.bw(this._cameraPosition,this._cameraPosition,o,-this.rollInRadians),t.bx(this._cameraPosition,this._cameraPosition,o,this.pitchInRadians),t.bw(this._cameraPosition,this._cameraPosition,o,-this.bearingInRadians),t.aS(this._cameraPosition,this._cameraPosition,[0,0,1]),t.bx(this._cameraPosition,this._cameraPosition,o,-this.center.lat*Math.PI/180),t.by(this._cameraPosition,this._cameraPosition,o,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(e);let s=t.b5(this._globeViewProjMatrixNoCorrectionInverted);t.N(s,s,[1,1,-1]),this._cachedFrustum=Ht.fromInvProjectionMatrix(s,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(e){t.w(`calculateFogMatrix is not supported on globe projection.`);let n=t.ba();return t.a4(n),n}getVisibleUnwrappedCoordinates(e){return[new t.b2(0,e)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){e&&t.w(`terrain is not fully supported on vertical perspective projection.`),this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,n){if(!this._globeViewProjMatrixNoCorrection)return 1;let r=ln(e);t.aR(r,r,1+n/t.bu);let i=t.bv();return t.$(i,[r[0],r[1],r[2],1],this._globeViewProjMatrixNoCorrection),i[2]/i[3]}populateCache(e){}getBounds(){let e=.5*this.width,n=.5*this.height,r=[new t.P(0,0),new t.P(e,0),new t.P(this.width,0),new t.P(this.width,n),new t.P(this.width,this.height),new t.P(e,this.height),new t.P(0,this.height),new t.P(0,n)],i=[];for(let e of r)i.push(this.unprojectScreenPoint(e));let a=0,o=0,s=0,c=0,l=this.center;for(let e of i){let n=t.bA(l.lng,e.lng),r=t.bA(l.lat,e.lat);n<o&&(o=n),n>a&&(a=n),r<c&&(c=r),r>s&&(s=r)}let u=[l.lng+o,l.lat+c,l.lng+a,l.lat+s];return this.isSurfacePointOnScreen([0,1,0])&&(u[3]=90,u[0]=-180,u[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(u[1]=-90,u[0]=-180,u[2]=180),new I(u)}getConstrained(e,n){let r=t.L(e.lat,-t.ax,t.ax),i=t.L(+n,this.minZoom+pn(0,r),this.maxZoom);return{center:new t.aa(e.lng,r),zoom:i}}calculateCenterFromCameraLngLatAlt(e,t,n,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,n,r)}setLocationAtPoint(e,n){let r=ln(this.unprojectScreenPoint(n)),i=ln(e),a=t.bp();t.bB(a);let o=t.bp();t.by(o,r,a,-this.center.lng*Math.PI/180),t.bx(o,o,a,this.center.lat*Math.PI/180);let s=i[0]*i[0]+i[2]*i[2],c=o[0]*o[0];if(s<c)return;let l=Math.sqrt(s-c),u=-l,d=t.bC(i[0],i[2],o[0],l),f=t.bC(i[0],i[2],o[0],u),p=t.bp();t.by(p,i,a,-d);let m=t.bC(p[1],p[2],o[1],o[2]),h=t.bp();t.by(h,i,a,-f);let g=t.bC(h[1],h[2],o[1],o[2]),_=.5*Math.PI,v=m>=-_&&m<=_,y=g>=-_&&g<=_,b,x;if(v&&y){let e=this.center.lng*Math.PI/180,n=this.center.lat*Math.PI/180;t.bD(d,e)+t.bD(m,n)<t.bD(f,e)+t.bD(g,n)?(b=d,x=m):(b=f,x=g)}else if(v)b=d,x=m;else{if(!y)return;b=f,x=g}let S=b/Math.PI*180,C=x/Math.PI*180,w=this.center.lat;this.setCenter(new t.aa(S,t.L(C,-90,90))),this.setZoom(this.zoom+pn(w,this.center.lat))}locationToScreenPoint(e,n){let r=ln(e);if(n){let i=n.getElevationForLngLatZoom(e,this._helper._tileZoom);t.aR(r,r,1+i/t.bu)}return this._projectSurfacePointToScreen(r)}_projectSurfacePointToScreen(e){let n=t.bv();return t.$(n,[...e,1],this._globeViewProjMatrixNoCorrection),n[0]/=n[3],n[1]/=n[3],new t.P((.5*n[0]+.5)*this.width,(.5*-n[1]+.5)*this.height)}screenPointToMercatorCoordinate(e,n){if(n){let t=n.pointCoordinate(e);if(t)return t}return t.aj.fromLngLat(this.unprojectScreenPoint(e))}screenPointToLocation(e,t){return this.screenPointToMercatorCoordinate(e,t)?.toLngLat()}isPointOnMapSurface(e,t){let n=this._cameraPosition,r=this.getRayDirectionFromPixel(e);return!!this.rayPlanetIntersection(n,r)}getRayDirectionFromPixel(e){let n=t.bv();n[0]=e.x/this.width*2-1,n[1]=-1*(e.y/this.height*2-1),n[2]=1,n[3]=1,t.$(n,n,this._globeViewProjMatrixNoCorrectionInverted),n[0]/=n[3],n[1]/=n[3],n[2]/=n[3];let r=t.bp();r[0]=n[0]-this._cameraPosition[0],r[1]=n[1]-this._cameraPosition[1],r[2]=n[2]-this._cameraPosition[2];let i=t.bp();return t.aV(i,r),i}isSurfacePointVisible(e){let t=this._cachedClippingPlane;return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]>=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return!1;let n=t.bv();return t.$(n,[...e,1],this._globeViewProjMatrixNoCorrection),n[0]/=n[3],n[1]/=n[3],n[2]/=n[3],n[0]>-1&&n[0]<1&&n[1]>-1&&n[1]<1&&n[2]>-1&&n[2]<1}rayPlanetIntersection(e,n){let r=t.aX(e,n),i=t.bp(),a=t.bp();t.aR(a,n,r),t.aU(i,e,a);let o=1-t.aX(i,i);if(o<0)return null;let s=t.aX(e,e)-1,c=-r+(r<0?1:-1)*Math.sqrt(o),l=s/c,u=c;return{tMin:Math.min(l,u),tMax:Math.max(l,u)}}unprojectScreenPoint(e){let n=this._cameraPosition,r=this.getRayDirectionFromPixel(e),i=this.rayPlanetIntersection(n,r);if(i){let e=t.bp();t.aS(e,n,[r[0]*i.tMin,r[1]*i.tMin,r[2]*i.tMin]);let a=t.bp();return t.aV(a,e),dn(a)}let a=this._cachedClippingPlane,o=a[0]*r[0]+a[1]*r[1]+a[2]*r[2],s=-t.b1(a,n)/o,c=t.bp();if(s>0)t.aS(c,n,[r[0]*s,r[1]*s,r[2]*s]);else{let e=t.bp();t.aS(e,n,[2*r[0],2*r[1],2*r[2]]);let i=t.b1(this._cachedClippingPlane,e);t.aU(c,e,[this._cachedClippingPlane[0]*i,this._cachedClippingPlane[1]*i,this._cachedClippingPlane[2]*i])}let l=function(e){let n=t.bp();return n[0]=e[0]*-e[3],n[1]=e[1]*-e[3],n[2]=e[2]*-e[3],{center:n,radius:Math.sqrt(1-e[3]*e[3])}}(a);return dn(function(e,n,r){let i=t.bp();t.aU(i,r,e);let a=t.bp();return t.bq(a,e,i,n/t.a$(i)),a}(l.center,l.radius,c))}getMatrixForModel(e,n){let r=t.aa.convert(e),i=1/t.bu,a=t.b9();return t.bz(a,a,r.lng/180*Math.PI),t.b7(a,a,-r.lat/180*Math.PI),t.a5(a,a,[0,0,1+n/t.bu]),t.b7(a,a,.5*Math.PI),t.N(a,a,[i,i,i]),a}getProjectionDataForCustomLayer(e=!0){let n=this.getProjectionData({overscaledTileID:new t.ag(0,0,0,0,0),applyGlobeMatrix:e});return n.tileMercatorCoords=[0,0,1,1],n}getFastPathSimpleProjectionMatrix(e){}}class wn{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setDetailLevel(e){this._helper.setDetailLevel(e)}setRasterAlignment(e){this._helper.setRasterAlignment(e)}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,n){return this._helper.interpolatePadding(e,t,n)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,n=!0){this._helper.resize(e,t,n)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get detailLevel(){return this._helper.detailLevel}get rasterAlignment(){return this._helper.rasterAlignment}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e,t){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=t,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this._helper=new zt({calcMatrices:()=>{this._calcMatrices()},getConstrained:(e,t)=>this.getConstrained(e,t)}),this._globeness=1,this._mercatorTransform=new Ut,this._verticalPerspectiveTransform=new Cn}clone(){let e=new wn;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this),e}apply(e){this._helper.apply(e),this._mercatorTransform.apply(this),this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){let t=this._mercatorTransform.getProjectionData(e),n=this._verticalPerspectiveTransform.getProjectionData(e);return{mainMatrix:this.isGlobeRendering?n.mainMatrix:t.mainMatrix,clippingPlane:n.clippingPlane,tileMercatorCoords:n.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:t.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return t.bk(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return t.bk(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,n,r){let i=this._mercatorTransform.getPitchedTextCorrection(e,n,r),a=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,n,r);return t.bk(i,a,this._globeness)}projectTileCoordinates(e,t,n,r){return this.currentTransform.projectTileCoordinates(e,t,n,r)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,t){return this.currentTransform.lngLatToCameraDepth(e,t)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e)}getBounds(){return this.currentTransform.getBounds()}getConstrained(e,t){return this.currentTransform.getConstrained(e,t)}calculateCenterFromCameraLngLatAlt(e,t,n,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,n,r)}setLocationAtPoint(e,t){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,t),void this.apply(this._mercatorTransform);this._verticalPerspectiveTransform.setLocationAtPoint(e,t),this.apply(this._verticalPerspectiveTransform)}locationToScreenPoint(e,t){return this.currentTransform.locationToScreenPoint(e,t)}screenPointToMercatorCoordinate(e,t){return this.currentTransform.screenPointToMercatorCoordinate(e,t)}screenPointToLocation(e,t){return this.currentTransform.screenPointToLocation(e,t)}isPointOnMapSurface(e,t){return this.currentTransform.isPointOnMapSurface(e,t)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,t){return this.currentTransform.getMatrixForModel(e,t)}getProjectionDataForCustomLayer(e=!0){let t=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return t;let n=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return n.fallbackMatrix=t.mainMatrix,n}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class Tn{get useGlobeControls(){return!0}handlePanInertia(e,n){let r=mn(e,n);return Math.abs(r.lng-n.center.lng)>180&&(r.lng=n.center.lng+179.5*Math.sign(r.lng-n.center.lng)),{easingCenter:r,easingOffset:new t.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,n){let r=e.around,i=n.screenPointToLocation(r);e.bearingDelta&&n.setBearing(n.bearing+e.bearingDelta),e.pitchDelta&&n.setPitch(n.pitch+e.pitchDelta),e.rollDelta&&n.setRoll(n.roll+e.rollDelta);let a=n.zoom;e.zoomDelta&&n.setZoom(n.zoom+e.zoomDelta);let o=n.zoom-a;if(o===0)return;let s=t.bA(n.center.lng,i.lng),c=s/(Math.abs(s/180)+1),l=t.bA(n.center.lat,i.lat),u=n.getRayDirectionFromPixel(r),d=n.cameraPosition,f=-1*t.aX(d,u),p=t.bp();t.aS(p,d,[u[0]*f,u[1]*f,u[2]*f]);let m=t.aZ(p)-1,h=Math.exp(.5*-Math.max(m-.3,0)),g=un(n.worldSize,n.center.lat)/Math.min(n.width,n.height),_=t.bn(g,.9,.5,1,.25),v=(1-t.aw(-o))*Math.min(h,_),y=n.center.lat,b=n.zoom,x=new t.aa(n.center.lng+c*v,t.L(n.center.lat+l*v,-t.ax,t.ax));n.setLocationAtPoint(i,r);let S=n.center,C=t.bn(Math.abs(s),45,85,0,1),w=t.bn(g,.75,.35,0,1),T=Math.max(C,w)**.25,E=t.bA(S.lng,x.lng),D=t.bA(S.lat,x.lat);n.setCenter(new t.aa(S.lng+E*T,S.lat+D*T).wrap()),n.setZoom(b+pn(y,n.center.lat))}handleMapControlsPan(e,t,n){if(!e.panDelta)return;let r=t.center.lat,i=t.zoom;t.setCenter(mn(e.panDelta,t).wrap()),t.setZoom(i+pn(r,t.center.lat))}cameraForBoxAndBearing(e,n,r,i,a){let o=Kt(e,n,r,i,a),s=n.left/a.width*2-1,c=(a.width-n.right)/a.width*2-1,l=n.top/a.height*-2+1,u=(a.height-n.bottom)/a.height*-2+1,d=t.bA(r.getWest(),r.getEast())<0,f=d?r.getEast():r.getWest(),p=d?r.getWest():r.getEast(),m=Math.max(r.getNorth(),r.getSouth()),h=Math.min(r.getNorth(),r.getSouth()),g=f+.5*t.bA(f,p),_=m+.5*t.bA(m,h),v=a.clone();v.setCenter(o.center),v.setBearing(o.bearing),v.setPitch(0),v.setRoll(0),v.setZoom(o.zoom);let y=v.modelViewProjectionMatrix,b=[ln(r.getNorthWest()),ln(r.getNorthEast()),ln(r.getSouthWest()),ln(r.getSouthEast()),ln(new t.aa(p,_)),ln(new t.aa(f,_)),ln(new t.aa(g,m)),ln(new t.aa(g,h))],x=ln(o.center),S=1/0;for(let e of b)s<0&&(S=Tn.getLesserNonNegativeNonNull(S,Tn.solveVectorScale(e,x,y,`x`,s))),c>0&&(S=Tn.getLesserNonNegativeNonNull(S,Tn.solveVectorScale(e,x,y,`x`,c))),l>0&&(S=Tn.getLesserNonNegativeNonNull(S,Tn.solveVectorScale(e,x,y,`y`,l))),u<0&&(S=Tn.getLesserNonNegativeNonNull(S,Tn.solveVectorScale(e,x,y,`y`,u)));if(Number.isFinite(S)&&S!==0)return o.zoom=v.zoom+t.az(S),o;Wt()}handleJumpToCenterZoom(e,n){let r=e.center.lat,i=e.getConstrained(n.center?t.aa.convert(n.center):e.center,e.zoom).center;e.setCenter(i.wrap());let a=n.zoom===void 0?e.zoom+pn(r,i.lat):+n.zoom;e.zoom!==a&&e.setZoom(a)}handleEaseTo(e,n){let r=e.zoom,i=e.center,a=e.padding,o={roll:e.roll,pitch:e.pitch,bearing:e.bearing},s={roll:n.roll===void 0?e.roll:n.roll,pitch:n.pitch===void 0?e.pitch:n.pitch,bearing:n.bearing===void 0?e.bearing:n.bearing},c=n.zoom!==void 0,l=!e.isPaddingEqual(n.padding),u=!1,d=n.center?t.aa.convert(n.center):i,f=e.getConstrained(d,r).center;Lt(e,f);let p=e.clone();p.setCenter(f),p.setZoom(c?+n.zoom:r+pn(i.lat,d.lat)),p.setBearing(n.bearing);let m=new t.P(t.L(e.centerPoint.x+n.offsetAsPoint.x,0,e.width),t.L(e.centerPoint.y+n.offsetAsPoint.y,0,e.height));p.setLocationAtPoint(f,m);let h=(n.offset&&n.offsetAsPoint.mag())>0?p.center:f,g=c?+n.zoom:r+pn(i.lat,h.lat),_=r+pn(i.lat,0),v=g+pn(h.lat,0),y=t.bA(i.lng,h.lng),b=t.bA(i.lat,h.lat),x=t.aw(v-_);return u=g!==r,{easeFunc:r=>{if(t.be(o,s)||Gt({startEulerAngles:o,endEulerAngles:s,tr:e,k:r,useSlerp:o.roll!=s.roll}),l&&e.interpolatePadding(a,n.padding,r),n.around)t.w(`Easing around a point is not supported under globe projection.`),e.setLocationAtPoint(n.around,n.aroundPoint);else{let t=gn(i,y,b,r*(v>_?Math.min(2,x):Math.max(.5,x))**(1-r));e.setCenter(t.wrap())}if(u){let n=t.C.number(_,v,r)+pn(0,e.center.lat);e.setZoom(n)}},isZooming:u,elevationCenter:h}}handleFlyTo(e,n){let r=n.zoom!==void 0,i=e.center,a=e.zoom,o=e.padding,s=!e.isPaddingEqual(n.padding),c=e.getConstrained(t.aa.convert(n.center||n.locationAtOffset),a).center,l=r?+n.zoom:e.zoom+pn(e.center.lat,c.lat),u=e.clone();u.setCenter(c),u.setZoom(l),u.setBearing(n.bearing);let d=new t.P(t.L(e.centerPoint.x+n.offsetAsPoint.x,0,e.width),t.L(e.centerPoint.y+n.offsetAsPoint.y,0,e.height));u.setLocationAtPoint(c,d);let f=u.center;Lt(e,f);let p=function(e,n,r){let i=ln(n),a=ln(r),o=t.aX(i,a),s=Math.acos(o),c=sn(e);return s/(2*Math.PI)*c}(e,i,f),m=a+pn(i.lat,0),h=l+pn(f.lat,0),g=t.aw(h-m),_;if(typeof n.minZoom==`number`){let r=+n.minZoom+pn(f.lat,0),i=Math.min(r,m,h)+pn(0,f.lat),a=e.getConstrained(f,i).zoom+pn(f.lat,0);_=t.aw(a-m)}let v=t.bA(i.lng,f.lng),y=t.bA(i.lat,f.lat);return{easeFunc:(r,a,c,u)=>{let d=gn(i,v,y,c);s&&e.interpolatePadding(o,n.padding,r);let p=r===1?f:d;e.setCenter(p.wrap());let h=m+t.az(a);e.setZoom(r===1?l:h+pn(0,p.lat))},scaleOfZoom:g,targetCenter:f,scaleOfMinZoom:_,pixelPathLength:p}}static solveVectorScale(e,t,n,r,i){let a=r===`x`?[n[0],n[4],n[8],n[12]]:[n[1],n[5],n[9],n[13]],o=[n[3],n[7],n[11],n[15]],s=e[0]*a[0]+e[1]*a[1]+e[2]*a[2],c=e[0]*o[0]+e[1]*o[1]+e[2]*o[2],l=t[0]*a[0]+t[1]*a[1]+t[2]*a[2],u=t[0]*o[0]+t[1]*o[1]+t[2]*o[2];return l+i*c===s+i*u||o[3]*(s-l)+a[3]*(u-c)+s*u==l*c?null:(l+a[3]-i*u-i*o[3])/(l-s-i*u+i*c)}static getLesserNonNegativeNonNull(e,t){return t!==null&&t>=0&&t<e?t:e}}class En{constructor(e){this._globe=e,this._mercatorCameraHelper=new qt,this._verticalPerspectiveCameraHelper=new Tn}get useGlobeControls(){return this._globe.useGlobeRendering}get currentHelper(){return this.useGlobeControls?this._verticalPerspectiveCameraHelper:this._mercatorCameraHelper}handlePanInertia(e,t){return this.currentHelper.handlePanInertia(e,t)}handleMapControlsRollPitchBearingZoom(e,t){return this.currentHelper.handleMapControlsRollPitchBearingZoom(e,t)}handleMapControlsPan(e,t,n){this.currentHelper.handleMapControlsPan(e,t,n)}cameraForBoxAndBearing(e,t,n,r,i){return this.currentHelper.cameraForBoxAndBearing(e,t,n,r,i)}handleJumpToCenterZoom(e,t){this.currentHelper.handleJumpToCenterZoom(e,t)}handleEaseTo(e,t){return this.currentHelper.handleEaseTo(e,t)}handleFlyTo(e,t){return this.currentHelper.handleFlyTo(e,t)}}let Dn=(e,n)=>t.y(e,n&&n.filter((e=>e.identifier!==`source.canvas`))),On=t.bE();class kn extends t.E{constructor(e,n={}){super(),this._rtlPluginLoaded=()=>{for(let e in this.sourceCaches){let t=this.sourceCaches[e].getSource().type;t!==`vector`&&t!==`geojson`||this.sourceCaches[e].reload()}},this.map=e,this.dispatcher=new F(te(),e._getMapId()),this.dispatcher.registerMessageHandler(`GG`,((e,t)=>this.getGlyphs(e,t))),this.dispatcher.registerMessageHandler(`GI`,((e,t)=>this.getImages(e,t))),this.imageManager=new b,this.imageManager.setEventedParent(this);let r=e._container?.lang||typeof document<`u`&&document.documentElement?.lang||void 0;this.glyphManager=new w(e._requestManager,n.localIdeographFontFamily,r),this.lineAtlas=new A(256,512),this.crossTileSymbolIndex=new kt,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new t.bF,this._loaded=!1,this._availableImages=[],this._labelFreeAreas=[],this._globalState={},this._resetUpdates(),this.dispatcher.broadcast(`SR`,t.bG()),qe().on(Ge,this._rtlPluginLoaded),this.on(`data`,(e=>{if(e.dataType!==`source`||e.sourceDataType!==`metadata`)return;let t=this.sourceCaches[e.sourceId];if(!t)return;let n=t.getSource();if(n&&n.vectorLayerIds)for(let e in this._layers){let t=this._layers[e];t.source===n.id&&this._validateLayer(t)}}))}setGlobalStateProperty(e,n){this._checkLoaded();let r=n===null?this.stylesheet.state?.[e]?.default??null:n;if(t.bH(r,this._globalState[e]))return this;this._globalState[e]=r,this._applyGlobalStateChanges([e])}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();let n=[];for(let r in e)!t.bH(this._globalState[r],e[r].default)&&(n.push(r),this._globalState[r]=e[r].default);this._applyGlobalStateChanges(n)}_applyGlobalStateChanges(e){if(e.length===0)return;let t=new Set;for(let n in this._layers){let r=this._layers[n],i=r.getLayoutAffectingGlobalStateRefs(),a=r.getPaintAffectingGlobalStateRefs();for(let n of e)if(i.has(n)&&t.add(r.source),a.has(n))for(let{name:e,value:t}of a.get(n))this._updatePaintProperty(r,e,t)}for(let e in this.sourceCaches)t.has(e)&&(this._reloadSource(e),this._changed=!0)}loadURL(e,n={},r){this.fire(new t.l(`dataloading`,{dataType:`style`})),n.validate=typeof n.validate!=`boolean`||n.validate;let i=this.map._requestManager.transformRequest(e,`Style`);this._loadStyleRequest=new AbortController;let a=this._loadStyleRequest;t.j(i,this._loadStyleRequest).then((e=>{this._loadStyleRequest=null,this._load(e.data,n,r)})).catch((e=>{this._loadStyleRequest=null,e&&!a.signal.aborted&&this.fire(new t.k(e))}))}loadJSON(e,n={},r){this.fire(new t.l(`dataloading`,{dataType:`style`})),this._frameRequest=new AbortController,o.frameAsync(this._frameRequest).then((()=>{this._frameRequest=null,n.validate=!1!==n.validate,this._load(e,n,r)})).catch((()=>{}))}loadEmpty(){this.fire(new t.l(`dataloading`,{dataType:`style`})),this._load(On,{validate:!1})}_load(e,n,r){let i=n.transformStyle?n.transformStyle(r,e):e;if(!n.validate||!Dn(this,t.z(i))){i=Object.assign({},i),this._loaded=!0,this.stylesheet=i;for(let e in i.sources)this.addSource(e,i.sources[e],{validate:!1});i.sprite?this._loadSprite(i.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(i.glyphs),this._createLayers(),this.light=new D(this.stylesheet.light),this._setProjectionInternal(this.stylesheet.projection?.type||`mercator`),this.sky=new k(this.stylesheet.sky),this.map.setTerrain(this.stylesheet.terrain??null),this.setGlobalState(this.stylesheet.state??null),this.fire(new t.l(`data`,{dataType:`style`})),this.fire(new t.l(`style.load`))}}_createLayers(){let e=t.bI(this.stylesheet.layers);this.dispatcher.broadcast(`SL`,e),this._order=e.map((e=>e.id)),this._layers={},this._serializedLayers=null;for(let n of e){let e=t.bJ(n);e.setEventedParent(this,{layer:{id:n.id}}),this._layers[n.id]=e}}_loadSprite(e,n=!1,r=void 0){let i;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,v(e,this.map._requestManager,this.map.getPixelRatio()*this.map.getScale(),this._spriteRequest).then((e=>{if(this._spriteRequest=null,e)for(let t in e){this._spritesImagesIds[t]=[];let r=this._spritesImagesIds[t]?this._spritesImagesIds[t].filter((t=>!(t in e))):[];for(let e of r)this.imageManager.removeImage(e),this._changedImages[e]=!0;for(let r in e[t]){let i=t===`default`?r:`${t}:${r}`;this._spritesImagesIds[t].push(i),i in this.imageManager.images?this.imageManager.updateImage(i,e[t][r],!1):this.imageManager.addImage(i,e[t][r]),n&&(this._changedImages[i]=!0)}}})).catch((e=>{this._spriteRequest=null,i=e,this.fire(new t.k(i))})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),n&&(this._changed=!0),this.dispatcher.broadcast(`SI`,this._availableImages),this.fire(new t.l(`data`,{dataType:`style`})),r&&r(i)}))}_unloadSprite(){for(let e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast(`SI`,this._availableImages),this.fire(new t.l(`data`,{dataType:`style`}))}_validateLayer(e){let n=this.sourceCaches[e.source];if(!n)return;let r=e.sourceLayer;if(!r)return;let i=n.getSource();(i.type===`geojson`||i.vectorLayerIds&&i.vectorLayerIds.indexOf(r)===-1)&&this.fire(new t.k(Error(`Source layer "${r}" does not exist on source "${i.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(let e in this.sourceCaches)if(!this.sourceCaches[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(e,n=!1){let r=this._serializedAllLayers();if(!e||e.length===0)return Object.values(n?t.bK(r):r);let i=[];for(let a of e)if(r[a]){let e=n?t.bK(r[a]):r[a];i.push(e)}return i}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};let t=Object.keys(this._layers);for(let n of t){let t=this._layers[n];t.type!==`custom`&&(e[n]=t.serialize())}return e}hasTransitions(){if(this.light?.hasTransition()||this.sky?.hasTransition()||this.projection?.hasTransition())return!0;for(let e in this.sourceCaches)if(this.sourceCaches[e].hasTransition())return!0;for(let e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw Error(`Style is not done loading.`)}update(e){if(!this._loaded)return;let n=this._changed;if(n){let t=Object.keys(this._updatedLayers),n=Object.keys(this._removedLayers);(t.length||n.length)&&this._updateWorkerLayers(t,n);for(let e in this._updatedSources){let t=this._updatedSources[e];if(t===`reload`)this._reloadSource(e);else{if(t!==`clear`)throw Error(`Invalid action ${t}`);this._clearSource(e)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(let t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}let r={};for(let e in this.sourceCaches){let t=this.sourceCaches[e];r[e]=t.used,t.used=!1}for(let t of this._order){let n=this._layers[t];n.recalculate(e,this._availableImages),!n.isHidden(e.zoom)&&n.source&&(this.sourceCaches[n.source].used=!0)}for(let e in r){let n=this.sourceCaches[e];!!r[e]!=!!n.used&&n.fire(new t.l(`data`,{sourceDataType:`visibility`,dataType:`source`,sourceId:e}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,n&&this.fire(new t.l(`data`,{dataType:`style`}))}_updateTilesForChangedImages(){let e=Object.keys(this._changedImages);if(e.length){for(let t in this.sourceCaches)this.sourceCaches[t].reloadTilesForDependencies([`icons`,`patterns`],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(let e in this.sourceCaches)this.sourceCaches[e].reloadTilesForDependencies([`glyphs`],[``]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,t){this.dispatcher.broadcast(`UL`,{layers:this._serializeByIds(e,!1),removedIds:t})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,n={}){var r;this._checkLoaded();let i=this.serialize();if(e=n.transformStyle?n.transformStyle(i,e):e,((r=n.validate)==null||r)&&Dn(this,t.z(e)))return!1;(e=t.bK(e)).layers=t.bI(e.layers);let a=t.bL(i,e),o=this._getOperationsToPerform(a);if(o.unimplemented.length>0)throw Error(`Unimplemented: ${o.unimplemented.join(`, `)}.`);if(o.operations.length===0)return!1;for(let e of o.operations)e();return this.stylesheet=e,this._serializedLayers=null,!0}_getOperationsToPerform(e){let t=[],n=[];for(let r of e)switch(r.command){case`setCenter`:case`setZoom`:case`setBearing`:case`setPitch`:case`setRoll`:continue;case`addLayer`:t.push((()=>this.addLayer.apply(this,r.args)));break;case`removeLayer`:t.push((()=>this.removeLayer.apply(this,r.args)));break;case`setPaintProperty`:t.push((()=>this.setPaintProperty.apply(this,r.args)));break;case`setLayoutProperty`:t.push((()=>this.setLayoutProperty.apply(this,r.args)));break;case`setFilter`:t.push((()=>this.setFilter.apply(this,r.args)));break;case`addSource`:t.push((()=>this.addSource.apply(this,r.args)));break;case`removeSource`:t.push((()=>this.removeSource.apply(this,r.args)));break;case`setLayerZoomRange`:t.push((()=>this.setLayerZoomRange.apply(this,r.args)));break;case`setLight`:t.push((()=>this.setLight.apply(this,r.args)));break;case`setGeoJSONSourceData`:t.push((()=>this.setGeoJSONSourceData.apply(this,r.args)));break;case`setGlyphs`:t.push((()=>this.setGlyphs.apply(this,r.args)));break;case`setSprite`:t.push((()=>this.setSprite.apply(this,r.args)));break;case`setTerrain`:t.push((()=>this.map.setTerrain.apply(this,r.args)));break;case`setSky`:t.push((()=>this.setSky.apply(this,r.args)));break;case`setProjection`:this.setProjection.apply(this,r.args);break;case`setGlobalState`:t.push((()=>this.setGlobalState.apply(this,r.args)));break;case`setTransition`:t.push((()=>{}));break;default:n.push(r.command)}return{operations:t,unimplemented:n}}addImage(e,n){if(this.getImage(e))return this.fire(new t.k(Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,n),this._afterImageUpdated(e)}updateImage(e,t){this.imageManager.updateImage(e,t)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new t.k(Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e)}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast(`SI`,this._availableImages),this.fire(new t.l(`data`,{dataType:`style`}))}addImages(e){for(let t in e)this.getImage(t)&&this.imageManager.removeImage(t),this.imageManager.addImage(t,e[t]),this._changedImages[t]=!0;return this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast(`SI`,this._availableImages),this.fire(new t.l(`data`,{dataType:`style`})),this}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,n,r={}){if(this._checkLoaded(),this.sourceCaches[e]!==void 0)throw Error(`Source "${e}" already exists.`);if(!n.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(`, `)}.`);if([`vector`,`raster`,`geojson`,`video`,`image`].indexOf(n.type)>=0&&this._validate(t.z.source,`sources.${e}`,n,null,r))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);let i=this.sourceCaches[e]=new ot(e,n,this.dispatcher);i.style=this,i.setEventedParent(this,(()=>({isSourceLoaded:i.loaded(),source:i.serialize(),sourceId:e}))),i.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),this.sourceCaches[e]===void 0)throw Error(`There is no source with this ID`);for(let n in this._layers)if(this._layers[n].source===e)return this.fire(new t.k(Error(`Source "${e}" cannot be removed while layer "${n}" is using it.`)));let n=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],n.fire(new t.l(`data`,{sourceDataType:`metadata`,dataType:`source`,sourceId:e})),n.setEventedParent(null),n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,t){if(this._checkLoaded(),this.sourceCaches[e]===void 0)throw Error(`There is no source with this ID=${e}`);let n=this.sourceCaches[e].getSource();if(n.type!==`geojson`)throw Error(`geojsonSource.type is ${n.type}, which is !== 'geojson`);n.setData(t),this._changed=!0}getSource(e){return this.sourceCaches[e]&&this.sourceCaches[e].getSource()}addLayer(e,n,r={}){this._checkLoaded();let i=e.id;if(this.getLayer(i))return void this.fire(new t.k(Error(`Layer "${i}" already exists on this map.`)));let a;if(e.type===`custom`){if(Dn(this,t.bM(e)))return;a=t.bJ(e)}else{if(`source`in e&&typeof e.source==`object`&&(this.addSource(i,e.source),e=t.bK(e),e=t.e(e,{source:i})),this._validate(t.z.layer,`layers.${i}`,e,{arrayIndex:-1},r))return;a=t.bJ(e),this._validateLayer(a),a.setEventedParent(this,{layer:{id:i}})}let o=n?this._order.indexOf(n):this._order.length;if(n&&o===-1)this.fire(new t.k(Error(`Cannot add layer "${i}" before non-existing layer "${n}".`)));else{if(this._order.splice(o,0,i),this._layerOrderChanged=!0,this._layers[i]=a,this._removedLayers[i]&&a.source&&a.type!==`custom`){let e=this._removedLayers[i];delete this._removedLayers[i],e.type===a.type?(this._updatedSources[a.source]=`reload`,this.sourceCaches[a.source].pause()):this._updatedSources[a.source]=`clear`}this._updateLayer(a),a.onAdd&&a.onAdd(this.map)}}moveLayer(e,n){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new t.k(Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===n)return;let r=this._order.indexOf(e);this._order.splice(r,1);let i=n?this._order.indexOf(n):this._order.length;n&&i===-1?this.fire(new t.k(Error(`Cannot move layer "${e}" before non-existing layer "${n}".`))):(this._order.splice(i,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();let n=this._layers[e];if(!n)return void this.fire(new t.k(Error(`Cannot remove non-existing layer "${e}".`)));n.setEventedParent(null);let r=this._order.indexOf(e);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=n,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],n.onRemove&&n.onRemove(this.map)}getLayer(e){return this._layers[e]}setLayersOrder(e){this._checkLoaded(),this._order=e.filter((e=>this._layers[e]!==void 0)),this._layerOrderChanged=!0}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,n,r){this._checkLoaded();let i=this.getLayer(e);i?i.minzoom===n&&i.maxzoom===r||(n!=null&&(i.minzoom=n),r!=null&&(i.maxzoom=r),this._updateLayer(i)):this.fire(new t.k(Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,n,r={}){this._checkLoaded();let i=this.getLayer(e);if(i){if(!t.bH(i.filter,n))return n==null?(i.setFilter(void 0),void this._updateLayer(i)):void(this._validate(t.z.filter,`layers.${i.id}.filter`,n,null,r)||(i.setFilter(t.bK(n)),this._updateLayer(i)))}else this.fire(new t.k(Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return t.bK(this.getLayer(e).filter)}setLayoutProperty(e,n,r,i={}){this._checkLoaded();let a=this.getLayer(e);a?t.bH(a.getLayoutProperty(n),r)||(a.setLayoutProperty(n,r,i),this._updateLayer(a)):this.fire(new t.k(Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,n){let r=this.getLayer(e);if(r)return r.getLayoutProperty(n);this.fire(new t.k(Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,n,r,i={}){this._checkLoaded();let a=this.getLayer(e);a?t.bH(a.getPaintProperty(n),r)||this._updatePaintProperty(a,n,r,i):this.fire(new t.k(Error(`Cannot style non-existing layer "${e}".`)))}_updatePaintProperty(e,t,n,r={}){e.setPaintProperty(t,n,r)&&this._updateLayer(e),this._changed=!0,this._updatedPaintProps[e.id]=!0,this._serializedLayers=null}getPaintProperty(e,t){return this.getLayer(e).getPaintProperty(t)}setFeatureState(e,n){this._checkLoaded();let r=e.source,i=e.sourceLayer,a=this.sourceCaches[r];if(a===void 0)return void this.fire(new t.k(Error(`The source '${r}' does not exist in the map's style.`)));let o=a.getSource().type;o===`geojson`&&i?this.fire(new t.k(Error(`GeoJSON sources cannot have a sourceLayer parameter.`))):o!==`vector`||i?(e.id===void 0&&this.fire(new t.k(Error(`The feature id parameter must be provided.`))),a.setFeatureState(i,e.id,n)):this.fire(new t.k(Error(`The sourceLayer parameter must be provided for vector source types.`)))}removeFeatureState(e,n){this._checkLoaded();let r=e.source,i=this.sourceCaches[r];if(i===void 0)return void this.fire(new t.k(Error(`The source '${r}' does not exist in the map's style.`)));let a=i.getSource().type,o=a===`vector`?e.sourceLayer:void 0;a!==`vector`||o?n&&typeof e.id!=`string`&&typeof e.id!=`number`?this.fire(new t.k(Error(`A feature id is required to remove its specific state property.`))):i.removeFeatureState(o,e.id,n):this.fire(new t.k(Error(`The sourceLayer parameter must be provided for vector source types.`)))}getFeatureState(e){this._checkLoaded();let n=e.source,r=e.sourceLayer,i=this.sourceCaches[n];if(i!==void 0)return i.getSource().type!==`vector`||r?(e.id===void 0&&this.fire(new t.k(Error(`The feature id parameter must be provided.`))),i.getFeatureState(r,e.id)):void this.fire(new t.k(Error(`The sourceLayer parameter must be provided for vector source types.`)));this.fire(new t.k(Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return t.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;let e=t.bN(this.sourceCaches,(e=>e.serialize())),n=this._serializeByIds(this._order,!0),r=this.map.getTerrain()||void 0,i=this.stylesheet;return t.bO({version:i.version,name:i.name,metadata:i.metadata,light:i.light,sky:i.sky,center:i.center,zoom:i.zoom,bearing:i.bearing,pitch:i.pitch,sprite:i.sprite,glyphs:i.glyphs,transition:i.transition,projection:i.projection,sources:e,layers:n,terrain:r},(e=>e!==void 0))}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&this.sourceCaches[e.source].getSource().type!==`raster`&&(this._updatedSources[e.source]=`reload`,this.sourceCaches[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){let t=e=>this._layers[e].type===`fill-extrusion`,n={},r=[];for(let i=this._order.length-1;i>=0;i--){let a=this._order[i];if(t(a)){n[a]=i;for(let t of e){let e=t[a];if(e)for(let t of e)r.push(t)}}}r.sort(((e,t)=>t.intersectionZ-e.intersectionZ));let i=[];for(let a=this._order.length-1;a>=0;a--){let o=this._order[a];if(t(o))for(let e=r.length-1;e>=0;e--){let t=r[e].feature;if(n[t.layer.id]<a)break;i.push(t),r.pop()}else for(let t of e){let e=t[o];if(e)for(let t of e)i.push(t.feature)}}return i}queryRenderedFeatures(e,n,r){n&&n.filter&&this._validate(t.z.filter,`queryRenderedFeatures.filter`,n.filter,null,n);let i={};if(n&&n.layers){if(!(Array.isArray(n.layers)||n.layers instanceof Set))return this.fire(new t.k(Error(`parameters.layers must be an Array or a Set of strings`))),[];for(let e of n.layers){let n=this._layers[e];if(!n)return this.fire(new t.k(Error(`The layer '${e}' does not exist in the map's style and cannot be queried for features.`))),[];i[n.source]=!0}}let a=[];n.availableImages=this._availableImages;let o=this._serializedAllLayers(),s=n.layers instanceof Set?n.layers:Array.isArray(n.layers)?new Set(n.layers):null,c=Object.assign(Object.assign({},n),{layers:s});for(let t in this.sourceCaches)n.layers&&!i[t]||a.push(ke(this.sourceCaches[t],this._layers,o,e,c,r,this.map.terrain?(e,t,n)=>this.map.terrain.getElevation(e,t,n):void 0));return this.placement&&a.push(function(e,t,n,r,i,a,o){let s={},c=a.queryRenderedSymbols(r),l=[];for(let e of Object.keys(c).map(Number))l.push(o[e]);l.sort(Ae);for(let r of l){let a=r.featureIndex.lookupSymbolFeatures(c[r.bucketInstanceId],t,r.bucketIndex,r.sourceLayerIndex,i.filter,i.layers,i.availableImages,e);for(let t in a){let i=s[t]=s[t]||[],o=a[t];o.sort(((e,t)=>{let n=r.featureSortOrder;if(n){let r=n.indexOf(e.featureIndex);return n.indexOf(t.featureIndex)-r}return t.featureIndex-e.featureIndex}));for(let a of o)i.push(a),Me(n[e[t].source],r,a)}}return function(e,t,n){for(let r in e)for(let i of e[r])je(i,n[t[r].source]);return e}(s,e,n)}(this._layers,o,this.sourceCaches,e,c,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(a)}querySourceFeatures(e,n){n&&n.filter&&this._validate(t.z.filter,`querySourceFeatures.filter`,n.filter,null,n);let r=this.sourceCaches[e];return r?function(e,t){let n=e.getRenderableIds().map((t=>e.getTileByID(t))),r=[],i={};for(let e=0;e<n.length;e++){let a=n[e],o=a.tileID.canonical.key;i[o]||(i[o]=!0,a.querySourceFeatures(r,t))}return r}(r,n):[]}getLight(){return this.light.getLight()}setLight(e,n={}){this._checkLoaded();let r=this.light.getLight(),i=!1;for(let n in e)if(!t.bH(e[n],r[n])){i=!0;break}if(!i)return;let a={now:o.now(),transition:t.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(e,n),this.light.updateTransitions(a)}getProjection(){return this.stylesheet?.projection}setProjection(e){if(this._checkLoaded(),this.projection){if(this.projection.name===e.type)return;this.projection.destroy(),delete this.projection}this.stylesheet.projection=e,this._setProjectionInternal(e.type)}getSky(){return this.stylesheet?.sky}setSky(e,n={}){this._checkLoaded();let r=this.getSky(),i=!1;if(!e&&!r)return;if(e&&!r)i=!0;else if(!e&&r)i=!0;else for(let n in e)if(!t.bH(e[n],r[n])){i=!0;break}if(!i)return;let a={now:o.now(),transition:t.e({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=e,this.sky.setSky(e,n),this.sky.updateTransitions(a)}_setProjectionInternal(e){let n=function(e){if(Array.isArray(e)){let t=new on({type:e});return{projection:t,transform:new wn,cameraHelper:new En(t)}}switch(e){case`mercator`:return{projection:new Ft,transform:new Ut,cameraHelper:new qt};case`globe`:{let e=new on({type:[`interpolate`,[`linear`],[`zoom`],11,`vertical-perspective`,12,`mercator`]});return{projection:e,transform:new wn,cameraHelper:new En(e)}}case`vertical-perspective`:return{projection:new rn,transform:new Cn,cameraHelper:new Tn};default:return t.w(`Unknown projection name: ${e}. Falling back to mercator projection.`),{projection:new Ft,transform:new Ut,cameraHelper:new qt}}}(e);this.projection=n.projection,this.map.migrateProjection(n.transform,n.cameraHelper);for(let e in this.sourceCaches)this.sourceCaches[e].reload()}_validate(e,n,r,i,a={}){return(!a||!1!==a.validate)&&Dn(this,e.call(t.z,t.e({key:n,style:this.serialize(),value:r,styleSpec:t.v},i)))}_remove(e=!0){this._frameRequest&&=(this._frameRequest.abort(),null),this._loadStyleRequest&&=(this._loadStyleRequest.abort(),null),this._spriteRequest&&=(this._spriteRequest.abort(),null),qe().off(Ge,this._rtlPluginLoaded);for(let e in this._layers)this._layers[e].setEventedParent(null);for(let e in this.sourceCaches){let t=this.sourceCaches[e];t.setEventedParent(null),t.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),e&&this.dispatcher.broadcast(`RM`,void 0),this.dispatcher.remove(e)}_clearSource(e){this.sourceCaches[e].clearTiles()}_reloadSource(e){this.sourceCaches[e].resume(),this.sourceCaches[e].reload()}_updateSources(e){for(let t in this.sourceCaches)this.sourceCaches[t].update(e,this.map.terrain)}_generateCollisionBoxes(){for(let e in this.sourceCaches)this._reloadSource(e)}_updatePlacement(e,t,n,r,i=!1){let a=!1,s=!1,c={};for(let t of this._order){let n=this._layers[t];if(n.type!==`symbol`)continue;if(!c[n.source]){let e=this.sourceCaches[n.source];c[n.source]=e.getRenderableIds(!0).map((t=>e.getTileByID(t))).sort(((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)))}let r=this.crossTileSymbolIndex.addLayer(n,c[n.source],e.center.lng);a||=r}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((i=i||this._layerOrderChanged||n===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(o.now(),e.zoom))&&(this.pauseablePlacement=new wt(e,this.map.terrain,this._order,i,t,n,r,this.placement,this._labelFreeAreas,this.map.getScale()),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,c),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(o.now()),s=!0),a&&this.pauseablePlacement.placement.setStale()),s||a)for(let e of this._order){let t=this._layers[e];t.type===`symbol`&&this.placement.updateLayerOpacities(t,c[t.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(o.now())}_releaseSymbolFadeTiles(){for(let e in this.sourceCaches)this.sourceCaches[e].releaseSymbolFadeTiles()}getImages(e,n){return t._(this,void 0,void 0,(function*(){let e=yield this.imageManager.getImages(n.icons);this._updateTilesForChangedImages();let t=this.sourceCaches[n.source];return t&&t.setDependencies(n.tileID.key,n.type,n.icons),e}))}getGlyphs(e,n){return t._(this,void 0,void 0,(function*(){let e=yield this.glyphManager.getGlyphs(n.stacks),t=this.sourceCaches[n.source];return t&&t.setDependencies(n.tileID.key,n.type,[``]),e}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,n={}){this._checkLoaded(),e&&this._validate(t.z.glyphs,`glyphs`,e,null,n)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}addSprite(e,n,r={},i){this._checkLoaded();let a=[{id:e,url:n}],o=[...g(this.stylesheet.sprite),...a];this._validate(t.z.sprite,`sprite`,o,null,r)||(this.stylesheet.sprite=o,this._loadSprite(a,!0,i))}removeSprite(e){this._checkLoaded();let n=g(this.stylesheet.sprite);if(n.find((t=>t.id===e))){if(this._spritesImagesIds[e])for(let t of this._spritesImagesIds[e])this.imageManager.removeImage(t),this._changedImages[t]=!0;n.splice(n.findIndex((t=>t.id===e)),1),this.stylesheet.sprite=n.length>0?n:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast(`SI`,this._availableImages),this.fire(new t.l(`data`,{dataType:`style`}))}else this.fire(new t.k(Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return g(this.stylesheet.sprite)}setSprite(e,n={},r){this._checkLoaded(),e&&this._validate(t.z.sprite,`sprite`,e,null,n)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,r):(this._unloadSprite(),r&&r(null)))}setLabelFreeAreas(e){return!t.bP(e,this._labelFreeAreas)&&(this._labelFreeAreas=e,!0)}}var An=t.aJ([{name:`a_pos`,type:`Int16`,components:2},{name:`a_texture_pos`,type:`Int16`,components:2}]);class jn{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,t,n,r,i,a,o,s,c){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);!this.vao||this.boundProgram!==t||this.boundLayoutVertexBuffer!==n||l||this.boundIndexBuffer!==i||this.boundVertexOffset!==a||this.boundDynamicVertexBuffer!==o||this.boundDynamicVertexBuffer2!==s||this.boundDynamicVertexBuffer3!==c?this.freshBind(t,n,r,i,a,o,s,c):(e.bindVertexArray.set(this.vao),o&&o.bind(),i&&i.dynamicDraw&&i.bind(),s&&s.bind(),c&&c.bind())}freshBind(e,t,n,r,i,a,o,s){let c=e.numAttributes,l=this.context,u=l.gl;this.vao&&this.destroy(),this.vao=l.createVertexArray(),l.bindVertexArray.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=t,this.boundPaintVertexBuffers=n,this.boundIndexBuffer=r,this.boundVertexOffset=i,this.boundDynamicVertexBuffer=a,this.boundDynamicVertexBuffer2=o,this.boundDynamicVertexBuffer3=s,t.enableAttributes(u,e);for(let t of n)t.enableAttributes(u,e);a&&a.enableAttributes(u,e),o&&o.enableAttributes(u,e),s&&s.enableAttributes(u,e),t.bind(),t.setVertexAttribPointers(u,e,i);for(let t of n)t.bind(),t.setVertexAttribPointers(u,e,i);a&&(a.bind(),a.setVertexAttribPointers(u,e,i)),r&&r.bind(),o&&(o.bind(),o.setVertexAttribPointers(u,e,i)),s&&(s.bind(),s.setVertexAttribPointers(u,e,i)),l.currentNumAttributes=c}destroy(){this.vao&&=(this.context.deleteVertexArray(this.vao),null)}}let Mn=(e,n,r,i,a)=>({u_texture:0,u_ele_delta:e,u_fog_matrix:n,u_fog_color:r?r.properties.get(`fog-color`):t.bf.white,u_fog_ground_blend:r?r.properties.get(`fog-ground-blend`):1,u_fog_ground_blend_opacity:a?0:r?r.calculateFogBlendOpacity(i):0,u_horizon_color:r?r.properties.get(`horizon-color`):t.bf.white,u_horizon_fog_blend:r?r.properties.get(`horizon-fog-blend`):1,u_is_globe_mode:a?1:0}),Nn={mainMatrix:`u_projection_matrix`,tileMercatorCoords:`u_projection_tile_mercator_coords`,clippingPlane:`u_projection_clipping_plane`,projectionTransition:`u_projection_transition`,fallbackMatrix:`u_projection_fallback_matrix`};function Pn(e){let t=[];for(let n=0;n<e.length;n++){if(e[n]===null)continue;let r=e[n].split(` `);t.push(r.pop())}return t}class Fn{constructor(e,n,r,i,a,o,s,c,l=[]){let u=e.gl;this.program=u.createProgram();let d=Pn(n.staticAttributes),f=r?r.getBinderAttributes():[],p=d.concat(f),m=jt.prelude.staticUniforms?Pn(jt.prelude.staticUniforms):[],h=s.staticUniforms?Pn(s.staticUniforms):[],g=n.staticUniforms?Pn(n.staticUniforms):[],_=r?r.getBinderUniforms():[],v=m.concat(h).concat(g).concat(_),y=[];for(let e of v)y.indexOf(e)<0&&y.push(e);let b=r?r.defines():[];Qt(u)&&b.unshift(`#version 300 es`),a&&b.push(`#define OVERDRAW_INSPECTOR;`),o&&b.push(`#define TERRAIN3D;`),c&&b.push(c),l&&b.push(...l);let x=b.concat(jt.prelude.fragmentSource,s.fragmentSource,n.fragmentSource).join(`
687
+ `),S=b.concat(jt.prelude.vertexSource,s.vertexSource,n.vertexSource).join(`
688
+ `);Qt(u)||(x=function(e){return e.replace(/\bin\s/g,`varying `).replace(`out highp vec4 fragColor;`,``).replace(/fragColor/g,`gl_FragColor`).replace(/texture\(/g,`texture2D(`)}(x),S=function(e){return e.replace(/\bin\s/g,`attribute `).replace(/\bout\s/g,`varying `).replace(/texture\(/g,`texture2D(`)}(S));let C=u.createShader(u.FRAGMENT_SHADER);if(u.isContextLost())return void(this.failedToCreate=!0);if(u.shaderSource(C,x),u.compileShader(C),!u.getShaderParameter(C,u.COMPILE_STATUS))throw Error(`Could not compile fragment shader: ${u.getShaderInfoLog(C)}`);u.attachShader(this.program,C);let w=u.createShader(u.VERTEX_SHADER);if(u.isContextLost())return void(this.failedToCreate=!0);if(u.shaderSource(w,S),u.compileShader(w),!u.getShaderParameter(w,u.COMPILE_STATUS))throw Error(`Could not compile vertex shader: ${u.getShaderInfoLog(w)}`);u.attachShader(this.program,w),this.attributes={};let T={};this.numAttributes=p.length;for(let e=0;e<this.numAttributes;e++)p[e]&&(u.bindAttribLocation(this.program,e,p[e]),this.attributes[p[e]]=e);if(u.linkProgram(this.program),!u.getProgramParameter(this.program,u.LINK_STATUS))throw Error(`Program failed to link: ${u.getProgramInfoLog(this.program)}`);u.deleteShader(w),u.deleteShader(C);for(let e=0;e<y.length;e++){let t=y[e];if(t&&!T[t]){let e=u.getUniformLocation(this.program,t);e&&(T[t]=e)}}this.fixedUniforms=i(e,T),this.terrainUniforms=((e,n)=>({u_depth:new t.bQ(e,n.u_depth),u_terrain:new t.bQ(e,n.u_terrain),u_terrain_dim:new t.bg(e,n.u_terrain_dim),u_terrain_matrix:new t.bS(e,n.u_terrain_matrix),u_terrain_unpack:new t.bT(e,n.u_terrain_unpack),u_terrain_exaggeration:new t.bg(e,n.u_terrain_exaggeration)}))(e,T),this.projectionUniforms=((e,n)=>({u_projection_matrix:new t.bS(e,n.u_projection_matrix),u_projection_tile_mercator_coords:new t.bT(e,n.u_projection_tile_mercator_coords),u_projection_clipping_plane:new t.bT(e,n.u_projection_clipping_plane),u_projection_transition:new t.bg(e,n.u_projection_transition),u_projection_fallback_matrix:new t.bS(e,n.u_projection_fallback_matrix)}))(e,T),this.binderUniforms=r?r.getUniforms(e,T):[]}draw(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v){let y=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(n),e.setStencilMode(r),e.setColorMode(i),e.setCullFace(a),s){e.activeTexture.set(y.TEXTURE2),y.bindTexture(y.TEXTURE_2D,s.depthTexture),e.activeTexture.set(y.TEXTURE3),y.bindTexture(y.TEXTURE_2D,s.texture);for(let e in this.terrainUniforms)this.terrainUniforms[e].set(s[e])}if(c)for(let e in c)this.projectionUniforms[Nn[e]].set(c[e]);if(o)for(let e in this.fixedUniforms)this.fixedUniforms[e].set(o[e]);h&&h.setUniforms(e,this.binderUniforms,p,{zoom:m});let b=0;switch(t){case y.LINES:b=2;break;case y.TRIANGLES:b=3;break;case y.LINE_STRIP:b=1}for(let n of f.get()){let r=n.vaos||={};(r[l]||(r[l]=new jn)).bind(e,this,u,h?h.getPaintVertexBuffers():[],d,n.vertexOffset,g,_,v),y.drawElements(t,n.primitiveLength*b,y.UNSIGNED_SHORT,n.primitiveOffset*b*2)}}}function In(e,n,r){let i=1/t.aC(r,1,n.transform.tileZoom,n.transform.detailLevel),a=2**r.tileID.overscaledZ,o=r.tileSize*2**n.transform.tileZoom/a,s=o*(r.tileID.canonical.x+r.tileID.wrap*a),c=o*r.tileID.canonical.y;return{u_image:0,u_texsize:r.imageAtlasTexture.size,u_scale:[i,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[s>>16,c>>16],u_pixel_coord_lower:[65535&s,65535&c]}}let Ln=(e,n,r,i)=>{let a=e.style.light,o=a.properties.get(`position`),s=[o.x,o.y,o.z],c=t.bW();a.properties.get(`anchor`)===`viewport`&&t.bX(c,e.transform.bearingInRadians),t.bY(s,s,c);let l=e.transform.transformLightDirection(s),u=a.properties.get(`color`);return{u_lightpos:s,u_lightpos_globe:l,u_lightintensity:a.properties.get(`intensity`),u_lightcolor:[u.r,u.g,u.b],u_vertical_gradient:+n,u_opacity:r,u_fill_translate:i}},Rn=(e,n,r,i,a,o,s)=>t.e(Ln(e,n,r,i),In(o,e,s),{u_height_factor:-(2**a.overscaledZ)/s.tileSize/8}),zn=(e,n,r,i)=>t.e(In(n,e,r),{u_fill_translate:i}),Bn=(e,t)=>({u_world:e,u_fill_translate:t}),Vn=(e,n,r,i,a)=>t.e(zn(e,n,r,a),{u_world:i}),Hn=(e,n,r,i,a)=>{let o=e.transform,s,c,l=0;if(r.paint.get(`circle-pitch-alignment`)===`map`){let e=t.aC(n,1,o.zoom,o.detailLevel);s=!0,c=[e,e],l=e/(t.ah*2**n.tileID.overscaledZ)*2*Math.PI*a}else s=!1,c=o.pixelsToGLUnits;return{u_camera_to_center_distance:o.cameraToCenterDistance,u_scale_with_map:+(r.paint.get(`circle-pitch-scale`)===`map`),u_pitch_with_map:+s,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:c,u_globe_extrude_scale:l,u_translate:i}},Un=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),Wn=e=>({u_viewport_size:[e.width,e.height]}),Gn=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),Kn=(e,n,r,i,a)=>{let o=t.aC(e,1,n,r)/(t.ah*2**e.tileID.overscaledZ)*2*Math.PI*a;return{u_extrude_scale:t.aC(e,1,n,r),u_intensity:i,u_globe_extrude_scale:o}},qn=(e,n,r,i)=>{let a=t.M();t.bZ(a,0,e.width,e.height,0,0,1);let o=e.context.gl;return{u_matrix:a,u_world:[o.drawingBufferWidth,o.drawingBufferHeight],u_image:r,u_color_ramp:i,u_opacity:n.paint.get(`heatmap-opacity`)}},Jn=(e,t,n)=>{let r=n.paint.get(`hillshade-accent-color`),i;switch(n.paint.get(`hillshade-method`)){case`basic`:i=4;break;case`combined`:i=1;break;case`igor`:i=2;break;case`multidirectional`:i=3;break;default:i=0}let a=n.getIlluminationProperties();for(let t=0;t<a.directionRadians.length;t++)n.paint.get(`hillshade-illumination-anchor`)===`viewport`&&(a.directionRadians[t]+=e.transform.bearingInRadians);return{u_image:0,u_latrange:Xn(0,t.tileID),u_exaggeration:n.paint.get(`hillshade-exaggeration`),u_altitudes:a.altitudeRadians,u_azimuths:a.directionRadians,u_accent:r,u_method:i,u_highlights:a.highlightColor,u_shadows:a.shadowColor}},Yn=(e,n)=>{let r=n.stride,i=t.M();return t.bZ(i,0,t.ah,-t.ah,0,0,1),t.a5(i,i,[0,-t.ah,0]),{u_matrix:i,u_image:1,u_dimension:[r,r],u_zoom:e.overscaledZ,u_unpack:n.getUnpackVector()}};function Xn(e,n){let r=2**n.canonical.z,i=n.canonical.y;return[new t.aj(0,i/r).toLngLat().lat,new t.aj(0,(i+1)/r).toLngLat().lat]}let Zn=(e,t,n=0)=>({u_image:0,u_unpack:t.getUnpackVector(),u_dimension:[t.stride,t.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:n,u_opacity:e.paint.get(`color-relief-opacity`)}),Qn=(e,n,r,i)=>{let a=e.transform;return{u_translation:rr(e,n,r),u_ratio:i/t.aC(n,1,a.zoom,a.detailLevel),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]]}},$n=(e,n,r,i,a)=>t.e(Qn(e,n,r,i),{u_image:0,u_image_height:a}),er=(e,n,r,i,a)=>{let o=e.transform,s=nr(n,o);return{u_translation:rr(e,n,r),u_texsize:n.imageAtlasTexture.size,u_ratio:i/t.aC(n,1,o.zoom,o.detailLevel),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[s,a.fromScale,a.toScale],u_fade:a.t,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},tr=(e,n,r,i,a,o)=>{let s=e.lineAtlas,c=nr(n,e.transform),l=r.layout.get(`line-cap`)===`round`,u=s.getDash(a.from,l),d=s.getDash(a.to,l),f=u.width*o.fromScale,p=d.width*o.toScale;return t.e(Qn(e,n,r,i),{u_patternscale_a:[c/f,-u.height/2],u_patternscale_b:[c/p,-d.height/2],u_sdfgamma:s.width/(256*Math.min(f,p)*e.pixelRatio)/2,u_image:0,u_tex_y_a:u.y,u_tex_y_b:d.y,u_mix:o.t})};function nr(e,n){return 1/t.aC(e,1,n.tileZoom,n.detailLevel)}function rr(e,n,r){return t.aD(e.transform,n,r.paint.get(`line-translate`),r.paint.get(`line-translate-anchor`))}let ir=(e,t,n,r,i)=>{return{u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,u_fade_t:n.mix,u_opacity:n.opacity*r.paint.get(`raster-opacity`),u_image0:0,u_image1:1,u_brightness_low:r.paint.get(`raster-brightness-min`),u_brightness_high:r.paint.get(`raster-brightness-max`),u_saturation_factor:(o=r.paint.get(`raster-saturation`),o>0?1-1/(1.001-o):-o),u_contrast_factor:(a=r.paint.get(`raster-contrast`),a>0?1/(1-a):1+a),u_spin_weights:ar(r.paint.get(`raster-hue-rotate`)),u_coords_top:[i[0].x,i[0].y,i[1].x,i[1].y],u_coords_bottom:[i[3].x,i[3].y,i[2].x,i[2].y]};var a,o};function ar(e){e*=Math.PI/180;let t=Math.sin(e),n=Math.cos(e);return[(2*n+1)/3,(-Math.sqrt(3)*t-n+1)/3,(Math.sqrt(3)*t-n+1)/3]}let or=(e,t,n,r,i,a,o,s,c,l,u,d,f)=>{let p=o.transform;return{u_is_size_zoom_constant:+(e===`constant`||e===`source`),u_is_size_feature_constant:+(e===`constant`||e===`camera`),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:p.cameraToCenterDistance,u_pitch:p.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:p.width/p.height,u_fade_change:o.options.fadeDuration?o.symbolFadeChange:1,u_label_plane_matrix:s,u_coord_matrix:c,u_is_text:+u,u_pitch_with_map:+r,u_is_along_line:i,u_is_variable_anchor:a,u_texsize:d,u_texture:0,u_translation:l,u_pitched_scale:f}},sr=(e,n,r,i,a,o,s,c,l,u,d,f,p,m)=>{let h=s.transform;return t.e(or(e,n,r,i,a,o,s,c,l,u,d,f,m),{u_gamma_scale:i?Math.cos(h.pitch*Math.PI/180)*h.cameraToCenterDistance:1,u_device_pixel_ratio:s.pixelRatio,u_is_halo:1})},cr=(e,n,r,i,a,o,s,c,l,u,d,f,p)=>t.e(sr(e,n,r,i,a,o,s,c,l,u,!0,d,0,p),{u_texsize_icon:f,u_texture_icon:1}),lr=(e,t)=>({u_opacity:e,u_color:t}),ur=(e,n,r,i,a)=>t.e(function(e,n,r,i){let a=r.imageManager.getPattern(e.from.toString()),o=r.imageManager.getPattern(e.to.toString()),{width:s,height:c}=r.imageManager.getPixelSize(),l=2**i.tileID.overscaledZ,u=i.tileSize*2**r.transform.tileZoom/l,d=u*(i.tileID.canonical.x+i.tileID.wrap*l),f=u*i.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:a.tl,u_pattern_br_a:a.br,u_pattern_tl_b:o.tl,u_pattern_br_b:o.br,u_texsize:[s,c],u_mix:n.t,u_pattern_size_a:a.displaySize,u_pattern_size_b:o.displaySize,u_scale_a:n.fromScale,u_scale_b:n.toScale,u_tile_units_to_pixels:1/t.aC(i,1,r.transform.tileZoom,r.transform.detailLevel),u_pixel_coord_upper:[d>>16,f>>16],u_pixel_coord_lower:[65535&d,65535&f]}}(r,a,n,i),{u_opacity:e}),dr=(e,t)=>{},fr={fillExtrusion:(e,n)=>({u_lightpos:new t.bU(e,n.u_lightpos),u_lightpos_globe:new t.bU(e,n.u_lightpos_globe),u_lightintensity:new t.bg(e,n.u_lightintensity),u_lightcolor:new t.bU(e,n.u_lightcolor),u_vertical_gradient:new t.bg(e,n.u_vertical_gradient),u_opacity:new t.bg(e,n.u_opacity),u_fill_translate:new t.bV(e,n.u_fill_translate)}),fillExtrusionPattern:(e,n)=>({u_lightpos:new t.bU(e,n.u_lightpos),u_lightpos_globe:new t.bU(e,n.u_lightpos_globe),u_lightintensity:new t.bg(e,n.u_lightintensity),u_lightcolor:new t.bU(e,n.u_lightcolor),u_vertical_gradient:new t.bg(e,n.u_vertical_gradient),u_height_factor:new t.bg(e,n.u_height_factor),u_opacity:new t.bg(e,n.u_opacity),u_fill_translate:new t.bV(e,n.u_fill_translate),u_image:new t.bQ(e,n.u_image),u_texsize:new t.bV(e,n.u_texsize),u_pixel_coord_upper:new t.bV(e,n.u_pixel_coord_upper),u_pixel_coord_lower:new t.bV(e,n.u_pixel_coord_lower),u_scale:new t.bU(e,n.u_scale),u_fade:new t.bg(e,n.u_fade)}),fill:(e,n)=>({u_fill_translate:new t.bV(e,n.u_fill_translate)}),fillPattern:(e,n)=>({u_image:new t.bQ(e,n.u_image),u_texsize:new t.bV(e,n.u_texsize),u_pixel_coord_upper:new t.bV(e,n.u_pixel_coord_upper),u_pixel_coord_lower:new t.bV(e,n.u_pixel_coord_lower),u_scale:new t.bU(e,n.u_scale),u_fade:new t.bg(e,n.u_fade),u_fill_translate:new t.bV(e,n.u_fill_translate)}),fillOutline:(e,n)=>({u_world:new t.bV(e,n.u_world),u_fill_translate:new t.bV(e,n.u_fill_translate)}),fillOutlinePattern:(e,n)=>({u_world:new t.bV(e,n.u_world),u_image:new t.bQ(e,n.u_image),u_texsize:new t.bV(e,n.u_texsize),u_pixel_coord_upper:new t.bV(e,n.u_pixel_coord_upper),u_pixel_coord_lower:new t.bV(e,n.u_pixel_coord_lower),u_scale:new t.bU(e,n.u_scale),u_fade:new t.bg(e,n.u_fade),u_fill_translate:new t.bV(e,n.u_fill_translate)}),circle:(e,n)=>({u_camera_to_center_distance:new t.bg(e,n.u_camera_to_center_distance),u_scale_with_map:new t.bQ(e,n.u_scale_with_map),u_pitch_with_map:new t.bQ(e,n.u_pitch_with_map),u_extrude_scale:new t.bV(e,n.u_extrude_scale),u_device_pixel_ratio:new t.bg(e,n.u_device_pixel_ratio),u_globe_extrude_scale:new t.bg(e,n.u_globe_extrude_scale),u_translate:new t.bV(e,n.u_translate)}),collisionBox:(e,n)=>({u_pixel_extrude_scale:new t.bV(e,n.u_pixel_extrude_scale)}),collisionCircle:(e,n)=>({u_viewport_size:new t.bV(e,n.u_viewport_size)}),debug:(e,n)=>({u_color:new t.bR(e,n.u_color),u_overlay:new t.bQ(e,n.u_overlay),u_overlay_scale:new t.bg(e,n.u_overlay_scale)}),depth:dr,clippingMask:dr,heatmap:(e,n)=>({u_extrude_scale:new t.bg(e,n.u_extrude_scale),u_intensity:new t.bg(e,n.u_intensity),u_globe_extrude_scale:new t.bg(e,n.u_globe_extrude_scale)}),heatmapTexture:(e,n)=>({u_matrix:new t.bS(e,n.u_matrix),u_world:new t.bV(e,n.u_world),u_image:new t.bQ(e,n.u_image),u_color_ramp:new t.bQ(e,n.u_color_ramp),u_opacity:new t.bg(e,n.u_opacity)}),hillshade:(e,n)=>({u_image:new t.bQ(e,n.u_image),u_latrange:new t.bV(e,n.u_latrange),u_exaggeration:new t.bg(e,n.u_exaggeration),u_altitudes:new t.b$(e,n.u_altitudes),u_azimuths:new t.b$(e,n.u_azimuths),u_accent:new t.bR(e,n.u_accent),u_method:new t.bQ(e,n.u_method),u_shadows:new t.b_(e,n.u_shadows),u_highlights:new t.b_(e,n.u_highlights)}),hillshadePrepare:(e,n)=>({u_matrix:new t.bS(e,n.u_matrix),u_image:new t.bQ(e,n.u_image),u_dimension:new t.bV(e,n.u_dimension),u_zoom:new t.bg(e,n.u_zoom),u_unpack:new t.bT(e,n.u_unpack)}),colorRelief:(e,n)=>({u_image:new t.bQ(e,n.u_image),u_unpack:new t.bT(e,n.u_unpack),u_dimension:new t.bV(e,n.u_dimension),u_elevation_stops:new t.bQ(e,n.u_elevation_stops),u_color_stops:new t.bQ(e,n.u_color_stops),u_color_ramp_size:new t.bQ(e,n.u_color_ramp_size),u_opacity:new t.bg(e,n.u_opacity)}),line:(e,n)=>({u_translation:new t.bV(e,n.u_translation),u_ratio:new t.bg(e,n.u_ratio),u_device_pixel_ratio:new t.bg(e,n.u_device_pixel_ratio),u_units_to_pixels:new t.bV(e,n.u_units_to_pixels)}),lineGradient:(e,n)=>({u_translation:new t.bV(e,n.u_translation),u_ratio:new t.bg(e,n.u_ratio),u_device_pixel_ratio:new t.bg(e,n.u_device_pixel_ratio),u_units_to_pixels:new t.bV(e,n.u_units_to_pixels),u_image:new t.bQ(e,n.u_image),u_image_height:new t.bg(e,n.u_image_height)}),linePattern:(e,n)=>({u_translation:new t.bV(e,n.u_translation),u_texsize:new t.bV(e,n.u_texsize),u_ratio:new t.bg(e,n.u_ratio),u_device_pixel_ratio:new t.bg(e,n.u_device_pixel_ratio),u_image:new t.bQ(e,n.u_image),u_units_to_pixels:new t.bV(e,n.u_units_to_pixels),u_scale:new t.bU(e,n.u_scale),u_fade:new t.bg(e,n.u_fade)}),lineSDF:(e,n)=>({u_translation:new t.bV(e,n.u_translation),u_ratio:new t.bg(e,n.u_ratio),u_device_pixel_ratio:new t.bg(e,n.u_device_pixel_ratio),u_units_to_pixels:new t.bV(e,n.u_units_to_pixels),u_patternscale_a:new t.bV(e,n.u_patternscale_a),u_patternscale_b:new t.bV(e,n.u_patternscale_b),u_sdfgamma:new t.bg(e,n.u_sdfgamma),u_image:new t.bQ(e,n.u_image),u_tex_y_a:new t.bg(e,n.u_tex_y_a),u_tex_y_b:new t.bg(e,n.u_tex_y_b),u_mix:new t.bg(e,n.u_mix)}),raster:(e,n)=>({u_tl_parent:new t.bV(e,n.u_tl_parent),u_scale_parent:new t.bg(e,n.u_scale_parent),u_buffer_scale:new t.bg(e,n.u_buffer_scale),u_fade_t:new t.bg(e,n.u_fade_t),u_opacity:new t.bg(e,n.u_opacity),u_image0:new t.bQ(e,n.u_image0),u_image1:new t.bQ(e,n.u_image1),u_brightness_low:new t.bg(e,n.u_brightness_low),u_brightness_high:new t.bg(e,n.u_brightness_high),u_saturation_factor:new t.bg(e,n.u_saturation_factor),u_contrast_factor:new t.bg(e,n.u_contrast_factor),u_spin_weights:new t.bU(e,n.u_spin_weights),u_coords_top:new t.bT(e,n.u_coords_top),u_coords_bottom:new t.bT(e,n.u_coords_bottom)}),symbolIcon:(e,n)=>({u_is_size_zoom_constant:new t.bQ(e,n.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bQ(e,n.u_is_size_feature_constant),u_size_t:new t.bg(e,n.u_size_t),u_size:new t.bg(e,n.u_size),u_camera_to_center_distance:new t.bg(e,n.u_camera_to_center_distance),u_pitch:new t.bg(e,n.u_pitch),u_rotate_symbol:new t.bQ(e,n.u_rotate_symbol),u_aspect_ratio:new t.bg(e,n.u_aspect_ratio),u_fade_change:new t.bg(e,n.u_fade_change),u_label_plane_matrix:new t.bS(e,n.u_label_plane_matrix),u_coord_matrix:new t.bS(e,n.u_coord_matrix),u_is_text:new t.bQ(e,n.u_is_text),u_pitch_with_map:new t.bQ(e,n.u_pitch_with_map),u_is_along_line:new t.bQ(e,n.u_is_along_line),u_is_variable_anchor:new t.bQ(e,n.u_is_variable_anchor),u_texsize:new t.bV(e,n.u_texsize),u_texture:new t.bQ(e,n.u_texture),u_translation:new t.bV(e,n.u_translation),u_pitched_scale:new t.bg(e,n.u_pitched_scale)}),symbolSDF:(e,n)=>({u_is_size_zoom_constant:new t.bQ(e,n.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bQ(e,n.u_is_size_feature_constant),u_size_t:new t.bg(e,n.u_size_t),u_size:new t.bg(e,n.u_size),u_camera_to_center_distance:new t.bg(e,n.u_camera_to_center_distance),u_pitch:new t.bg(e,n.u_pitch),u_rotate_symbol:new t.bQ(e,n.u_rotate_symbol),u_aspect_ratio:new t.bg(e,n.u_aspect_ratio),u_fade_change:new t.bg(e,n.u_fade_change),u_label_plane_matrix:new t.bS(e,n.u_label_plane_matrix),u_coord_matrix:new t.bS(e,n.u_coord_matrix),u_is_text:new t.bQ(e,n.u_is_text),u_pitch_with_map:new t.bQ(e,n.u_pitch_with_map),u_is_along_line:new t.bQ(e,n.u_is_along_line),u_is_variable_anchor:new t.bQ(e,n.u_is_variable_anchor),u_texsize:new t.bV(e,n.u_texsize),u_texture:new t.bQ(e,n.u_texture),u_gamma_scale:new t.bg(e,n.u_gamma_scale),u_device_pixel_ratio:new t.bg(e,n.u_device_pixel_ratio),u_is_halo:new t.bQ(e,n.u_is_halo),u_translation:new t.bV(e,n.u_translation),u_pitched_scale:new t.bg(e,n.u_pitched_scale)}),symbolTextAndIcon:(e,n)=>({u_is_size_zoom_constant:new t.bQ(e,n.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bQ(e,n.u_is_size_feature_constant),u_size_t:new t.bg(e,n.u_size_t),u_size:new t.bg(e,n.u_size),u_camera_to_center_distance:new t.bg(e,n.u_camera_to_center_distance),u_pitch:new t.bg(e,n.u_pitch),u_rotate_symbol:new t.bQ(e,n.u_rotate_symbol),u_aspect_ratio:new t.bg(e,n.u_aspect_ratio),u_fade_change:new t.bg(e,n.u_fade_change),u_label_plane_matrix:new t.bS(e,n.u_label_plane_matrix),u_coord_matrix:new t.bS(e,n.u_coord_matrix),u_is_text:new t.bQ(e,n.u_is_text),u_pitch_with_map:new t.bQ(e,n.u_pitch_with_map),u_is_along_line:new t.bQ(e,n.u_is_along_line),u_is_variable_anchor:new t.bQ(e,n.u_is_variable_anchor),u_texsize:new t.bV(e,n.u_texsize),u_texsize_icon:new t.bV(e,n.u_texsize_icon),u_texture:new t.bQ(e,n.u_texture),u_texture_icon:new t.bQ(e,n.u_texture_icon),u_gamma_scale:new t.bg(e,n.u_gamma_scale),u_device_pixel_ratio:new t.bg(e,n.u_device_pixel_ratio),u_is_halo:new t.bQ(e,n.u_is_halo),u_translation:new t.bV(e,n.u_translation),u_pitched_scale:new t.bg(e,n.u_pitched_scale)}),background:(e,n)=>({u_opacity:new t.bg(e,n.u_opacity),u_color:new t.bR(e,n.u_color)}),backgroundPattern:(e,n)=>({u_opacity:new t.bg(e,n.u_opacity),u_image:new t.bQ(e,n.u_image),u_pattern_tl_a:new t.bV(e,n.u_pattern_tl_a),u_pattern_br_a:new t.bV(e,n.u_pattern_br_a),u_pattern_tl_b:new t.bV(e,n.u_pattern_tl_b),u_pattern_br_b:new t.bV(e,n.u_pattern_br_b),u_texsize:new t.bV(e,n.u_texsize),u_mix:new t.bg(e,n.u_mix),u_pattern_size_a:new t.bV(e,n.u_pattern_size_a),u_pattern_size_b:new t.bV(e,n.u_pattern_size_b),u_scale_a:new t.bg(e,n.u_scale_a),u_scale_b:new t.bg(e,n.u_scale_b),u_pixel_coord_upper:new t.bV(e,n.u_pixel_coord_upper),u_pixel_coord_lower:new t.bV(e,n.u_pixel_coord_lower),u_tile_units_to_pixels:new t.bg(e,n.u_tile_units_to_pixels)}),terrain:(e,n)=>({u_texture:new t.bQ(e,n.u_texture),u_ele_delta:new t.bg(e,n.u_ele_delta),u_fog_matrix:new t.bS(e,n.u_fog_matrix),u_fog_color:new t.bR(e,n.u_fog_color),u_fog_ground_blend:new t.bg(e,n.u_fog_ground_blend),u_fog_ground_blend_opacity:new t.bg(e,n.u_fog_ground_blend_opacity),u_horizon_color:new t.bR(e,n.u_horizon_color),u_horizon_fog_blend:new t.bg(e,n.u_horizon_fog_blend),u_is_globe_mode:new t.bg(e,n.u_is_globe_mode)}),terrainDepth:(e,n)=>({u_ele_delta:new t.bg(e,n.u_ele_delta)}),terrainCoords:(e,n)=>({u_texture:new t.bQ(e,n.u_texture),u_terrain_coords_id:new t.bg(e,n.u_terrain_coords_id),u_ele_delta:new t.bg(e,n.u_ele_delta)}),projectionErrorMeasurement:(e,n)=>({u_input:new t.bg(e,n.u_input),u_output_expected:new t.bg(e,n.u_output_expected)}),atmosphere:(e,n)=>({u_sun_pos:new t.bU(e,n.u_sun_pos),u_atmosphere_blend:new t.bg(e,n.u_atmosphere_blend),u_globe_position:new t.bU(e,n.u_globe_position),u_globe_radius:new t.bg(e,n.u_globe_radius),u_inv_proj_matrix:new t.bS(e,n.u_inv_proj_matrix)}),sky:(e,n)=>({u_sky_color:new t.bR(e,n.u_sky_color),u_horizon_color:new t.bR(e,n.u_horizon_color),u_horizon:new t.bV(e,n.u_horizon),u_horizon_normal:new t.bV(e,n.u_horizon_normal),u_sky_horizon_blend:new t.bg(e,n.u_sky_horizon_blend),u_sky_blend:new t.bg(e,n.u_sky_blend)})};class pr{constructor(e,t,n){this.context=e;let r=e.gl;this.buffer=r.createBuffer(),this.dynamicDraw=!!n,this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||delete t.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){let t=this.context.gl;if(!this.dynamicDraw)throw Error(`Attempted to update data while not in dynamic mode.`);this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}let mr={Int8:`BYTE`,Uint8:`UNSIGNED_BYTE`,Int16:`SHORT`,Uint16:`UNSIGNED_SHORT`,Int32:`INT`,Uint32:`UNSIGNED_INT`,Float32:`FLOAT`};class hr{constructor(e,t,n,r){this.length=t.length,this.attributes=n,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.context=e;let i=e.gl;this.buffer=i.createBuffer(),e.bindVertexBuffer.set(this.buffer),i.bufferData(i.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?i.DYNAMIC_DRAW:i.STATIC_DRAW),this.dynamicDraw||delete t.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);let t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,t){for(let n=0;n<this.attributes.length;n++){let r=t.attributes[this.attributes[n].name];r!==void 0&&e.enableVertexAttribArray(r)}}setVertexAttribPointers(e,t,n){for(let r=0;r<this.attributes.length;r++){let i=this.attributes[r],a=t.attributes[i.name];a!==void 0&&e.vertexAttribPointer(a,i.components,e[mr[i.type]],!1,this.itemSize,i.offset+this.itemSize*(n||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class gr{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 _r extends gr{getDefault(){return t.bf.transparent}set(e){let 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 vr extends gr{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class yr extends gr{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class br extends gr{getDefault(){return[!0,!0,!0,!0]}set(e){let 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 xr extends gr{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class Sr extends gr{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class Cr extends gr{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){let 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 wr extends gr{getDefault(){let e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){let 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 Tr extends gr{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1}}class Er extends gr{getDefault(){return[0,1]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1)}}class Dr extends gr{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),this.current=e,this.dirty=!1}}class Or extends gr{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class kr extends gr{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.BLEND):t.disable(t.BLEND),this.current=e,this.dirty=!1}}class q extends gr{getDefault(){let e=this.gl;return[e.ONE,e.ZERO]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.blendFunc(e[0],e[1]),this.current=e,this.dirty=!1)}}class Ar extends gr{getDefault(){return t.bf.transparent}set(e){let 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 jr extends gr{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquation(e),this.current=e,this.dirty=!1)}}class Mr extends gr{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),this.current=e,this.dirty=!1}}class Nr extends gr{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class Pr extends gr{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}class Fr extends gr{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}}class Ir extends gr{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class Lr extends gr{getDefault(){let e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class Rr extends gr{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e),this.current=e,this.dirty=!1}}class zr extends gr{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindRenderbuffer(t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class Br extends gr{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindTexture(t.TEXTURE_2D,e),this.current=e,this.dirty=!1}}class Vr extends gr{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class Hr extends gr{getDefault(){return null}set(e){let t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class Ur extends gr{getDefault(){return null}set(e){var t;if(e===this.current&&!this.dirty)return;let n=this.gl;Qt(n)?n.bindVertexArray(e):(t=n.getExtension(`OES_vertex_array_object`))==null||t.bindVertexArrayOES(e),this.current=e,this.dirty=!1}}class Wr extends gr{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.pixelStorei(t.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}}class Gr extends gr{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}}class Kr extends gr{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}}class qr extends gr{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}}class J extends qr{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class Jr extends qr{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class Yr extends qr{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}let Xr=`Framebuffer is not complete`;class Zr{constructor(e,t,n,r,i){this.context=e,this.width=t,this.height=n;let a=e.gl,o=this.framebuffer=a.createFramebuffer();if(this.colorAttachment=new J(e,o),r)this.depthAttachment=i?new Yr(e,o):new Jr(e,o);else if(i)throw Error(`Stencil cannot be set without depth`);if(a.checkFramebufferStatus(a.FRAMEBUFFER)!==a.FRAMEBUFFER_COMPLETE)throw Error(Xr)}destroy(){let e=this.context.gl,t=this.colorAttachment.get();if(t&&e.deleteTexture(t),this.depthAttachment){let t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t)}e.deleteFramebuffer(this.framebuffer)}}class Qr{constructor(e){if(this.gl=e,this.clearColor=new _r(this),this.clearDepth=new vr(this),this.clearStencil=new yr(this),this.colorMask=new br(this),this.depthMask=new xr(this),this.stencilMask=new Sr(this),this.stencilFunc=new Cr(this),this.stencilOp=new wr(this),this.stencilTest=new Tr(this),this.depthRange=new Er(this),this.depthTest=new Dr(this),this.depthFunc=new Or(this),this.blend=new kr(this),this.blendFunc=new q(this),this.blendColor=new Ar(this),this.blendEquation=new jr(this),this.cullFace=new Mr(this),this.cullFaceSide=new Nr(this),this.frontFace=new Pr(this),this.program=new Fr(this),this.activeTexture=new Ir(this),this.viewport=new Lr(this),this.bindFramebuffer=new Rr(this),this.bindRenderbuffer=new zr(this),this.bindTexture=new Br(this),this.bindVertexBuffer=new Vr(this),this.bindElementBuffer=new Hr(this),this.bindVertexArray=new Ur(this),this.pixelStoreUnpack=new Wr(this),this.pixelStoreUnpackPremultiplyAlpha=new Gr(this),this.pixelStoreUnpackFlipY=new Kr(this),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.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),Qt(e)){this.HALF_FLOAT=e.HALF_FLOAT;let t=e.getExtension(`EXT_color_buffer_half_float`);this.RGBA16F=e.RGBA16F??t?.RGBA16F_EXT,this.RGB16F=e.RGB16F??t?.RGB16F_EXT,e.getExtension(`EXT_color_buffer_float`)}else e.getExtension(`EXT_color_buffer_half_float`),e.getExtension(`OES_texture_half_float_linear`),this.HALF_FLOAT=e.getExtension(`OES_texture_half_float`)?.HALF_FLOAT_OES}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(e,t){return new pr(this,e,t)}createVertexBuffer(e,t,n){return new hr(this,e,t,n)}createRenderbuffer(e,t,n){let r=this.gl,i=r.createRenderbuffer();return this.bindRenderbuffer.set(i),r.renderbufferStorage(r.RENDERBUFFER,e,t,n),this.bindRenderbuffer.set(null),i}createFramebuffer(e,t,n,r){return new Zr(this,e,t,n,r)}clear({color:e,depth:t,stencil:n}){let r=this.gl,i=0;e&&(i|=r.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!0,!0,!0,!0])),t!==void 0&&(i|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),n!==void 0&&(i|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(n),this.stencilMask.set(255)),r.clear(i)}setCullFace(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1)}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1)}setColorMode(e){t.bH(e.blendFunction,Jt.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor)),this.colorMask.set(e.mask)}createVertexArray(){return Qt(this.gl)?this.gl.createVertexArray():this.gl.getExtension(`OES_vertex_array_object`)?.createVertexArrayOES()}deleteVertexArray(e){return Qt(this.gl)?this.gl.deleteVertexArray(e):this.gl.getExtension(`OES_vertex_array_object`)?.deleteVertexArrayOES(e)}unbindVAO(){this.bindVertexArray.set(null)}}let $r;function ei(e,n,r,i,a){let o=e.context,s=e.transform,c=o.gl,l=e.useProgram(`collisionBox`),u=[],d=0,f=0;for(let t=0;t<i.length;t++){let p=i[t],m=n.getTile(p).getBucket(r);if(!m)continue;let h=a?m.textCollisionBox:m.iconCollisionBox,g=m.collisionCircleArray;g.length>0&&(u.push({circleArray:g,circleOffset:f,coord:p}),d+=g.length/4,f=d),h&&l.draw(o,c.LINES,G.disabled,K.disabled,e.colorModeForRenderPass(),W.disabled,Un(e.transform),e.style.map.terrain&&e.style.map.terrain.getTerrainData(p),s.getProjectionData({overscaledTileID:p,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),r.id,h.layoutVertexBuffer,h.indexBuffer,h.segments,null,e.transform.zoom,null,null,h.collisionVertexBuffer)}if(!a||!u.length)return;let p=e.useProgram(`collisionCircle`),m=new t.c0;m.resize(4*d),m._trim();let h=0;for(let e of u)for(let t=0;t<e.circleArray.length/4;t++){let n=4*t,r=e.circleArray[n+0],i=e.circleArray[n+1],a=e.circleArray[n+2],o=e.circleArray[n+3];m.emplace(h++,r,i,a,o,0),m.emplace(h++,r,i,a,o,1),m.emplace(h++,r,i,a,o,2),m.emplace(h++,r,i,a,o,3)}(!$r||$r.length<2*d)&&($r=function(e){let n=2*e,r=new t.c2;r.resize(n),r._trim();for(let e=0;e<n;e++){let 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}(d));let g=o.createIndexBuffer($r,!0),_=o.createVertexBuffer(m,t.c1.members,!0);for(let n of u){let i=Wn(e.transform);p.draw(o,c.TRIANGLES,G.disabled,K.disabled,e.colorModeForRenderPass(),W.disabled,i,e.style.map.terrain&&e.style.map.terrain.getTerrainData(n.coord),null,r.id,_,g,t.aM.simpleSegment(0,2*n.circleOffset,n.circleArray.length,n.circleArray.length/2),null,e.transform.zoom,null,null,null)}_.destroy(),g.destroy()}let ti=t.a4(new Float32Array(16));function ni(e,n,r,i,a,o){let{horizontalAlign:s,verticalAlign:c}=t.aH(e);return new t.P((-(s-.5)*n/a+i[0])*o,(-(c-.5)*r/a+i[1])*o)}function ri(e,n,r,i,a,o){let s=n.tileAnchorPoint.add(new t.P(n.translation[0],n.translation[1]));if(n.pitchWithMap){let e=i.mult(o);r||(e=e.rotate(-a));let t=s.add(e);return le(t.x,t.y,n.pitchedLabelPlaneMatrix,n.getElevation).point}if(r){let t=ve(n.tileAnchorPoint.x+1,n.tileAnchorPoint.y,n).point.sub(e),r=Math.atan(t.y/t.x)+(t.x<0?Math.PI:0);return e.add(i.rotate(r))}return e.add(i)}function ii(e,n,r,i,a,o,s,c,l,u,d,f){let p=e.text.placedSymbolArray,m=e.text.dynamicLayoutVertexArray,h=e.icon.dynamicLayoutVertexArray,g={};m.clear();for(let h=0;h<p.length;h++){let _=p.get(h),v=_.hidden||!_.crossTileID||e.allowVerticalPlacement&&!_.placedOrientation?null:i[_.crossTileID];if(v){let i=new t.P(_.anchorX,_.anchorY),p={getElevation:f,width:a.width,height:a.height,pitchedLabelPlaneMatrix:o,pitchWithMap:r,transform:a,tileAnchorPoint:i,translation:u,unwrappedTileID:d},h=r?be(i.x,i.y,p):ve(i.x,i.y,p),y=ue(a.cameraToCenterDistance,h.signedDistanceFromCamera),b=t.Q(e.textSizeData,c,_)*y/t.a7;r&&(b*=e.tilePixelRatio/s);let{width:x,height:S,anchor:C,textOffset:w,textBoxScale:T}=v,E=ni(C,x,S,w,T,b),D=a.getPitchedTextCorrection(i.x+u[0],i.y+u[1],d),O=ri(h.point,p,n,E,-a.bearingInRadians,D),k=e.allowVerticalPlacement&&_.placedOrientation===t.W.vertical?Math.PI/2:0;for(let e=0;e<_.numGlyphs;e++)t.Z(m,O,k);l&&_.associatedIconIndex>=0&&(g[_.associatedIconIndex]={shiftedAnchor:O,angle:k})}else Te(_.numGlyphs,m)}if(l){h.clear();let n=e.icon.placedSymbolArray;for(let e=0;e<n.length;e++){let r=n.get(e);if(r.hidden)Te(r.numGlyphs,h);else{let n=g[e];if(n)for(let e=0;e<r.numGlyphs;e++)t.Z(h,n.shiftedAnchor,n.angle);else Te(r.numGlyphs,h)}}e.icon.dynamicLayoutVertexBuffer.updateData(h)}e.text.dynamicLayoutVertexBuffer.updateData(m)}function ai(e,t,n){return n.iconsInText&&t?`symbolTextAndIcon`:e?`symbolSDF`:`symbolIcon`}function oi(e,n,r,i,a,o,s,c,l,u,d,f,p){let m=e.context,h=m.gl,g=e.transform,_=c===`map`,v=l===`map`,y=c!==`viewport`&&r.layout.get(`symbol-placement`)!==`point`,b=_&&!v&&!y,x=!r.layout.get(`symbol-sort-key`).isConstant(),S=!1,C=e.getDepthModeForSublayer(0,G.ReadOnly),w=r._unevaluatedLayout.hasValue(`text-variable-anchor`)||r._unevaluatedLayout.hasValue(`text-variable-anchor-offset`),T=[],E=g.getCircleRadiusCorrection();for(let c of i){let i=n.getTile(c),l=i.getBucket(r);if(!l)continue;let d=a?l.text:l.icon;if(!d||!d.segments.get().length||!d.hasVisibleVertices)continue;let f=d.programConfigurations.get(r.id),m=a||l.sdfIcons,C=a?l.textSizeData:l.iconSizeData,D=v||g.pitch!==0,O=e.useProgram(ai(m,a,l),f),k=t.O(C,g.zoom),A=e.style.map.terrain&&e.style.map.terrain.getTerrainData(c),j,M,N,P,ee=[0,0],te=null;a?(M=i.glyphAtlasTexture,N=h.LINEAR,j=i.glyphAtlasTexture.size,l.iconsInText&&(ee=i.imageAtlasTexture.size,te=i.imageAtlasTexture,P=D||e.options.rotating||e.options.zooming||C.kind===`composite`||C.kind===`camera`?h.LINEAR:h.NEAREST)):(M=i.imageAtlasTexture,N=m||e.options.rotating||e.options.zooming||!g.rasterAlignment||l.iconsNeedLinear||D?h.LINEAR:h.NEAREST,j=i.imageAtlasTexture.size);let F=t.aC(i,1,e.transform.zoom,e.transform.detailLevel),ne=oe(_,e.transform,F),re=t.M();t.S(re,ne);let ie=se(v,_,e.transform,F),ae=t.aD(g,i,o,s),ce=g.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!p,applyTerrainMatrix:!0}),le=w&&l.hasTextData(),ue=r.layout.get(`icon-text-fit`)!==`none`&&le&&l.hasIconData();if(y){let t=e.style.map.terrain?(t,n)=>e.style.map.terrain.getElevation(c,t,n):null;fe(l,e,a,ne,re,v,u,r.layout.get(`text-rotation-alignment`)===`map`,c.toUnwrapped(),g.width,g.height,ae,t)}let de=a&&w||ue,pe=y||de?ti:v?ne:e.transform.clipSpaceToPixelsMatrix,me=m&&r.paint.get(a?`text-halo-width`:`icon-halo-width`).constantOr(1)!==0,he;he=m?l.iconsInText?cr(C.kind,k,b,v,y,de,e,pe,ie,ae,j,ee,E):sr(C.kind,k,b,v,y,de,e,pe,ie,ae,a,j,0,E):or(C.kind,k,b,v,y,de,e,pe,ie,ae,a,j,E);let ge={program:O,buffers:d,uniformValues:he,projectionData:ce,atlasTexture:M,atlasTextureIcon:te,atlasInterpolation:N,atlasInterpolationIcon:P,isSDF:m,hasHalo:me};if(x&&l.canOverlap){S=!0;let e=d.segments.get();for(let n of e)T.push({segments:new t.aM([n]),sortKey:n.sortKey,state:ge,terrainData:A})}else T.push({segments:d.segments,sortKey:0,state:ge,terrainData:A})}S&&T.sort(((e,t)=>e.sortKey-t.sortKey));for(let t of T){let n=t.state;if(m.activeTexture.set(h.TEXTURE0),n.atlasTexture.bind(n.atlasInterpolation,h.CLAMP_TO_EDGE),n.atlasTextureIcon&&(m.activeTexture.set(h.TEXTURE1),n.atlasTextureIcon&&n.atlasTextureIcon.bind(n.atlasInterpolationIcon,h.CLAMP_TO_EDGE)),n.isSDF){let i=n.uniformValues;n.hasHalo&&(i.u_is_halo=1,si(n.buffers,t.segments,r,e,n.program,C,d,f,i,n.projectionData,t.terrainData)),i.u_is_halo=0}si(n.buffers,t.segments,r,e,n.program,C,d,f,n.uniformValues,n.projectionData,t.terrainData)}}function si(e,t,n,r,i,a,o,s,c,l,u){let d=r.context;i.draw(d,d.gl.TRIANGLES,a,o,s,W.backCCW,c,u,l,n.id,e.layoutVertexBuffer,e.indexBuffer,t,n.paint,r.transform.zoom,e.programConfigurations.get(n.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function ci(e,n,r,i,a){let o=e.context,s=o.gl,c=K.disabled,l=new Jt([s.ONE,s.ONE],t.bf.transparent,[!0,!0,!0,!0]),u=n.getBucket(r);if(!u)return;let d=i.key,f=r.heatmapFbos.get(d);f||(f=ui(o,n.tileSize,n.tileSize),r.heatmapFbos.set(d,f)),o.bindFramebuffer.set(f.framebuffer),o.viewport.set([0,0,n.tileSize,n.tileSize]),o.clear({color:t.bf.transparent});let p=u.programConfigurations.get(r.id),m=e.useProgram(`heatmap`,p,!a),h=e.transform.getProjectionData({overscaledTileID:n.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),g=e.style.map.terrain.getTerrainData(i);m.draw(o,s.TRIANGLES,G.disabled,c,l,W.disabled,Kn(n,e.transform.zoom,e.transform.detailLevel,r.paint.get(`heatmap-intensity`),1),g,h,r.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,r.paint,e.transform.zoom,p)}function li(e,t,n,r,i){let a=e.context,o=a.gl,s=e.transform;a.setColorMode(e.colorModeForRenderPass());let c=di(a,t),l=n.key,u=t.heatmapFbos.get(l);if(!u)return;a.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,u.colorAttachment.get()),a.activeTexture.set(o.TEXTURE1),c.bind(o.LINEAR,o.CLAMP_TO_EDGE);let d=s.getProjectionData({overscaledTileID:n,applyTerrainMatrix:i,applyGlobeMatrix:!r});e.useProgram(`heatmapTexture`).draw(a,o.TRIANGLES,G.disabled,K.disabled,e.colorModeForRenderPass(),W.disabled,qn(e,t,0,1),null,d,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,s.zoom),u.destroy(),t.heatmapFbos.delete(l)}function ui(e,t,n){let r=e.gl,i=r.createTexture();r.bindTexture(r.TEXTURE_2D,i),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR);let a=e.HALF_FLOAT??r.UNSIGNED_BYTE,o=e.RGBA16F??r.RGBA;r.texImage2D(r.TEXTURE_2D,0,o,t,n,0,r.RGBA,a,null);let s=e.createFramebuffer(t,n,!1,!1);return s.colorAttachment.set(i),s}function di(e,n){return n.colorRampTexture||=new t.T(e,n.colorRamp,e.gl.RGBA),n.colorRampTexture}function fi(e,t,n,r,i){if(!n||!r||!r.imageAtlas)return;let a=r.imageAtlas.patternPositions,o=a[n.to.toString()],s=a[n.from.toString()];if(!o&&s&&(o=s),!s&&o&&(s=o),!o||!s){let e=i.getPaintProperty(t);o=a[e],s=a[e]}o&&s&&e.setConstantPatternPositions(o,s)}function pi(e,n,r,i,a,o,s,c){let l=e.context.gl,u=`fill-pattern`,d=r.paint.get(u),f=d&&d.constantOr(1),p=r.getCrossfadeParameters(),m,h,g,_,v,y=e.transform,b=r.paint.get(`fill-translate`),x=r.paint.get(`fill-translate-anchor`);s?(h=f&&!r.getPaintProperty(`fill-outline-color`)?`fillOutlinePattern`:`fillOutline`,m=l.LINES):(h=f?`fillPattern`:`fill`,m=l.TRIANGLES);let S=d.constantOr(null);for(let d of i){let i=n.getTile(d);if(f&&!i.patternsLoaded())continue;let C=i.getBucket(r);if(!C)continue;let w=C.programConfigurations.get(r.id),T=e.useProgram(h,w),E=e.style.map.terrain&&e.style.map.terrain.getTerrainData(d);f&&(e.context.activeTexture.set(l.TEXTURE0),i.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),w.updatePaintBuffers(p)),fi(w,u,S,i,r);let D=y.getProjectionData({overscaledTileID:d,applyGlobeMatrix:!c,applyTerrainMatrix:!0}),O=t.aD(y,i,b,x);if(s){_=C.indexBuffer2,v=C.segments2;let t=[l.drawingBufferWidth,l.drawingBufferHeight];g=h===`fillOutlinePattern`&&f?Vn(e,p,i,t,O):Bn(t,O)}else _=C.indexBuffer,v=C.segments,g=f?zn(e,p,i,O):{u_fill_translate:O};let k=e.stencilModeForClipping(d);T.draw(e.context,m,a,k,o,W.backCCW,g,E,D,r.id,C.layoutVertexBuffer,_,v,r.paint,e.transform.zoom,w)}}function mi(e,n,r,i,a,o,s,c){let l=e.context,u=l.gl,d=`fill-extrusion-pattern`,f=r.paint.get(d),p=f.constantOr(1),m=r.getCrossfadeParameters(),h=r.paint.get(`fill-extrusion-opacity`),g=f.constantOr(null),_=e.transform;for(let f of i){let i=n.getTile(f),v=i.getBucket(r);if(!v)continue;let y=e.style.map.terrain&&e.style.map.terrain.getTerrainData(f),b=v.programConfigurations.get(r.id),x=e.useProgram(p?`fillExtrusionPattern`:`fillExtrusion`,b);p&&(e.context.activeTexture.set(u.TEXTURE0),i.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),b.updatePaintBuffers(m));let S=_.getProjectionData({overscaledTileID:f,applyGlobeMatrix:!c,applyTerrainMatrix:!0});fi(b,d,g,i,r);let C=t.aD(_,i,r.paint.get(`fill-extrusion-translate`),r.paint.get(`fill-extrusion-translate-anchor`)),w=r.paint.get(`fill-extrusion-vertical-gradient`),T=p?Rn(e,w,h,C,f,m,i):Ln(e,w,h,C);x.draw(l,l.gl.TRIANGLES,a,o,s,W.backCCW,T,y,S,r.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,r.paint,e.transform.zoom,b,e.style.map.terrain&&v.centroidVertexBuffer)}}function hi(e,t,n,r,i,a,o,s,c){let l=e.style.projection,u=e.context,d=e.transform,f=u.gl,p=[`#define NUM_ILLUMINATION_SOURCES ${n.paint.get(`hillshade-highlight-color`).values.length}`],m=e.useProgram(`hillshade`,null,!1,p),h=!e.options.moving;for(let p of r){let r=t.getTile(p),g=r.fbo;if(!g)continue;let _=l.getMeshFromTileID(u,p.canonical,s,!0,`raster`),v=e.style.map.terrain?.getTerrainData(p);u.activeTexture.set(f.TEXTURE0),f.bindTexture(f.TEXTURE_2D,g.colorAttachment.get());let y=d.getProjectionData({overscaledTileID:p,aligned:h,applyGlobeMatrix:!c,applyTerrainMatrix:!0});m.draw(u,f.TRIANGLES,a,i[p.overscaledZ],o,W.backCCW,Jn(e,r,n),v,y,n.id,_.vertexBuffer,_.indexBuffer,_.segments)}}function gi(e,n,r,i,a,o,s,c,l){let u=e.style.projection,d=e.context,f=e.transform,p=d.gl,m=e.useProgram(`colorRelief`),h=!e.options.moving,g=!0,_=0;for(let v of i){let i=n.getTile(v),y=i.dem;if(g){let e=p.getParameter(p.MAX_TEXTURE_SIZE),{elevationTexture:t,colorTexture:n}=r.getColorRampTextures(d,e,y.getUnpackVector());d.activeTexture.set(p.TEXTURE1),t.bind(p.NEAREST,p.CLAMP_TO_EDGE),d.activeTexture.set(p.TEXTURE4),n.bind(p.LINEAR,p.CLAMP_TO_EDGE),g=!1,_=t.size[0]}if(!y||!y.data)continue;let b=y.stride,x=y.getPixels();if(d.activeTexture.set(p.TEXTURE0),d.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||e.getTileTexture(b),i.demTexture){let e=i.demTexture;e.update(x,{premultiply:!1}),e.bind(p.LINEAR,p.CLAMP_TO_EDGE)}else i.demTexture=new t.T(d,x,p.RGBA,{premultiply:!1}),i.demTexture.bind(p.LINEAR,p.CLAMP_TO_EDGE);let S=u.getMeshFromTileID(d,v.canonical,c,!0,`raster`),C=e.style.map.terrain?.getTerrainData(v),w=f.getProjectionData({overscaledTileID:v,aligned:h,applyGlobeMatrix:!l,applyTerrainMatrix:!0});m.draw(d,p.TRIANGLES,o,a[v.overscaledZ],s,W.backCCW,Zn(r,i.dem,_),C,w,r.id,S.vertexBuffer,S.indexBuffer,S.segments)}}let _i=[new t.P(0,0),new t.P(t.ah,0),new t.P(t.ah,t.ah),new t.P(0,t.ah)];function vi(e,t,n,r,i,a,o,s,c=!1,l=!1){let u=r[r.length-1].overscaledZ,d=e.context,f=d.gl,p=e.useProgram(`raster`),m=e.transform,h=e.style.projection,g=e.colorModeForRenderPass(),_=!e.options.moving;for(let v of r){let r=e.getDepthModeForSublayer(v.overscaledZ-u,n.paint.get(`raster-opacity`)===1?G.ReadWrite:G.ReadOnly,f.LESS),y=t.getTile(v);y.registerFadeDuration(n.paint.get(`raster-fade-duration`));let b=t.findLoadedParent(v,0),x=t.findLoadedSibling(v),S=yi(y,b||x||null,t,n,e.transform,e.style.map.terrain),C,w,T=n.paint.get(`raster-resampling`)===`nearest`?f.NEAREST:f.LINEAR;d.activeTexture.set(f.TEXTURE0),y.texture.bind(T,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST),d.activeTexture.set(f.TEXTURE1),b?(b.texture.bind(T,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST),C=2**(b.tileID.overscaledZ-y.tileID.overscaledZ),w=[y.tileID.canonical.x*C%1,y.tileID.canonical.y*C%1]):y.texture.bind(T,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST),y.texture.useMipmap&&d.extTextureFilterAnisotropic&&e.transform.pitch>20&&f.texParameterf(f.TEXTURE_2D,d.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,d.extTextureFilterAnisotropicMax);let E=e.style.map.terrain&&e.style.map.terrain.getTerrainData(v),D=m.getProjectionData({overscaledTileID:v,aligned:_,applyGlobeMatrix:!l,applyTerrainMatrix:!0}),O=ir(w||[0,0],C||1,S,n,s),k=h.getMeshFromTileID(d,v.canonical,a,o,`raster`);p.draw(d,f.TRIANGLES,r,i?i[v.overscaledZ]:K.disabled,g,c?W.frontCCW:W.backCCW,O,E,D,n.id,k.vertexBuffer,k.indexBuffer,k.segments)}}function yi(e,n,r,i,a,s){let c=i.paint.get(`raster-fade-duration`);if(!s&&c>0){let i=o.now(),s=(i-e.timeAdded)/c,l=n?(i-n.timeAdded)/c:-1,u=r.getSource(),d=rt(a,{tileSize:u.tileSize,roundZoom:u.roundZoom}),f=!n||Math.abs(n.tileID.overscaledZ-d)>Math.abs(e.tileID.overscaledZ-d),p=f&&e.refreshedUponExpiration?1:t.L(f?s:1-l,0,1);return e.refreshedUponExpiration&&s>=1&&(e.refreshedUponExpiration=!1),n?{opacity:1,mix:1-p}:{opacity:p,mix:0}}return{opacity:1,mix:0}}let bi=new t.bf(1,0,0,1),xi=new t.bf(0,1,0,1),Si=new t.bf(0,0,1,1),Ci=new t.bf(1,0,1,1),wi=new t.bf(0,1,1,1);function Ti(e,t,n,r){Di(e,0,t+n/2,e.transform.width,n,r)}function Ei(e,t,n,r){Di(e,t-n/2,0,n,e.transform.height,r)}function Di(e,t,n,r,i,a){let o=e.context,s=o.gl;s.enable(s.SCISSOR_TEST),s.scissor(t*e.pixelRatio,n*e.pixelRatio,r*e.pixelRatio,i*e.pixelRatio),o.clear({color:a}),s.disable(s.SCISSOR_TEST)}function Oi(e,n,r){let i=e.context,a=i.gl,o=e.useProgram(`debug`),s=G.disabled,c=K.disabled,l=e.colorModeForRenderPass(),u=`$debug`,d=e.style.map.terrain&&e.style.map.terrain.getTerrainData(r);i.activeTexture.set(a.TEXTURE0);let f=n.getTileByID(r.key).latestRawTileData,p=Math.floor((f&&f.byteLength||0)/1024),m=n.getTile(r).tileSize,h=512/Math.min(m,512)*(r.overscaledZ/e.transform.zoom)*.5,g=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(g+=` => ${r.overscaledZ}`),function(e,t){e.initDebugOverlayCanvas();let n=e.debugOverlayCanvas,r=e.context.gl,i=e.debugOverlayCanvas.getContext(`2d`);i.clearRect(0,0,n.width,n.height),i.shadowColor=`white`,i.shadowBlur=2,i.lineWidth=1.5,i.strokeStyle=`white`,i.textBaseline=`top`,i.font=`bold 36px Open Sans, sans-serif`,i.fillText(t,5,5),i.strokeText(t,5,5),e.debugOverlayTexture.update(n),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(e,`${g} ${p}kB`);let _=e.transform.getProjectionData({overscaledTileID:r,applyGlobeMatrix:!0,applyTerrainMatrix:!0});o.draw(i,a.TRIANGLES,s,c,Jt.alphaBlended,W.disabled,Gn(t.bf.transparent,h),null,_,u,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),o.draw(i,a.LINE_STRIP,s,c,l,W.disabled,Gn(t.bf.red),d,_,u,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function ki(e,t,n,r){let{isRenderingGlobe:i}=r,a=e.context,o=a.gl,s=e.transform,c=e.colorModeForRenderPass(),l=e.getDepthModeFor3D(),u=e.useProgram(`terrain`);a.bindFramebuffer.set(null),a.viewport.set([0,0,e.width,e.height]);for(let r of n){let n=t.getTerrainMesh(r.tileID),d=e.renderToTexture.getTexture(r),f=t.getTerrainData(r.tileID);a.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,d.texture);let p=Mn(t.getMeshFrameDelta(s.zoom),s.calculateFogMatrix(r.tileID.toUnwrapped()),e.style.sky,s.pitch,i),m=s.getProjectionData({overscaledTileID:r.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});u.draw(a,o.TRIANGLES,l,K.disabled,c,W.backCCW,p,f,m,`terrain`,n.vertexBuffer,n.indexBuffer,n.segments)}}function Ai(e,n){if(!n.mesh){let r=new t.aL;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(1,1),r.emplaceBack(-1,1);let i=new t.aN;i.emplaceBack(0,1,2),i.emplaceBack(0,2,3),n.mesh=new Mt(e.createVertexBuffer(r,Nt.members),e.createIndexBuffer(i),t.aM.simpleSegment(0,0,r.length,i.length))}return n.mesh}class ji{constructor(e,n){this.context=new Qr(e),this.transform=n,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:t.a4(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=ot.maxUnderzooming+ot.maxOverzooming+1,this.depthEpsilon=1/2**16,this.crossTileSymbolIndex=new kt}resize(e,t,n,r){if(this.width=Math.floor(e*n),this.height=Math.floor(t*n),this.pixelRatio=n*r,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let e of this.style._order)this.style._layers[e].resize()}setup(){let e=this.context,n=new t.aL;n.emplaceBack(0,0),n.emplaceBack(t.ah,0),n.emplaceBack(0,t.ah),n.emplaceBack(t.ah,t.ah),this.tileExtentBuffer=e.createVertexBuffer(n,Nt.members),this.tileExtentSegments=t.aM.simpleSegment(0,0,4,2);let r=new t.aL;r.emplaceBack(0,0),r.emplaceBack(t.ah,0),r.emplaceBack(0,t.ah),r.emplaceBack(t.ah,t.ah),this.debugBuffer=e.createVertexBuffer(r,Nt.members),this.debugSegments=t.aM.simpleSegment(0,0,4,5);let i=new t.c7;i.emplaceBack(0,0,0,0),i.emplaceBack(t.ah,0,t.ah,0),i.emplaceBack(0,t.ah,0,t.ah),i.emplaceBack(t.ah,t.ah,t.ah,t.ah),this.rasterBoundsBuffer=e.createVertexBuffer(i,An.members),this.rasterBoundsSegments=t.aM.simpleSegment(0,0,4,2);let a=new t.aL;a.emplaceBack(0,0),a.emplaceBack(t.ah,0),a.emplaceBack(0,t.ah),a.emplaceBack(t.ah,t.ah),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(a,Nt.members),this.rasterBoundsSegmentsPosOnly=t.aM.simpleSegment(0,0,4,5);let o=new t.aL;o.emplaceBack(0,0),o.emplaceBack(1,0),o.emplaceBack(0,1),o.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(o,Nt.members),this.viewportSegments=t.aM.simpleSegment(0,0,4,2);let s=new t.c8;s.emplaceBack(0),s.emplaceBack(1),s.emplaceBack(3),s.emplaceBack(2),s.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(s);let c=new t.aN;c.emplaceBack(1,0,2),c.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(c);let l=this.context.gl;this.stencilClearMode=new K({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.tileExtentMesh=new Mt(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){let e=this.context,n=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;let r=t.M();t.bZ(r,0,this.width,this.height,0,0,1),t.N(r,r,[n.drawingBufferWidth,n.drawingBufferHeight,0]);let i={mainMatrix:r,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:r};this.useProgram(`clippingMask`,null,!0).draw(e,n.TRIANGLES,G.disabled,this.stencilClearMode,Jt.disabled,W.disabled,null,null,i,`$clipping`,this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,t,n){if(this.currentStencilSource===e.source||!e.isTileClipped()||!t||!t.length)return;this.currentStencilSource=e.source,this.nextStencilID+t.length>256&&this.clearStencil();let r=this.context;r.setColorMode(Jt.disabled),r.setDepthMode(G.disabled);let i={};for(let e of t)i[e.key]=this.nextStencilID++;this._renderTileMasks(i,t,n,!0),this._renderTileMasks(i,t,n,!1),this._tileClippingMaskIDs=i}_renderTileMasks(e,t,n,r){let i=this.context,a=i.gl,o=this.style.projection,s=this.transform,c=this.useProgram(`clippingMask`);for(let l of t){let t=e[l.key],u=this.style.map.terrain&&this.style.map.terrain.getTerrainData(l),d=o.getMeshFromTileID(this.context,l.canonical,r,!0,`stencil`),f=s.getProjectionData({overscaledTileID:l,applyGlobeMatrix:!n,applyTerrainMatrix:!0});c.draw(i,a.TRIANGLES,G.disabled,new K({func:a.ALWAYS,mask:0},t,255,a.KEEP,a.KEEP,a.REPLACE),Jt.disabled,n?W.disabled:W.backCCW,null,u,f,`$clipping`,d.vertexBuffer,d.indexBuffer,d.segments)}}_renderTilesDepthBuffer(){let e=this.context,t=e.gl,n=this.style.projection,r=this.transform,i=this.useProgram(`depth`),a=this.getDepthModeFor3D(),o=it(r,{tileSize:r.tileSize});for(let s of o){let o=this.style.map.terrain&&this.style.map.terrain.getTerrainData(s),c=n.getMeshFromTileID(this.context,s.canonical,!0,!0,`raster`),l=r.getProjectionData({overscaledTileID:s,applyGlobeMatrix:!0,applyTerrainMatrix:!0});i.draw(e,t.TRIANGLES,a,K.disabled,Jt.disabled,W.backCCW,null,o,l,`$clipping`,c.vertexBuffer,c.indexBuffer,c.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let e=this.nextStencilID++,t=this.context.gl;return new K({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){let t=this.context.gl;return new K({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){let t=this.context.gl,n=e.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),r=n[n.length-1].overscaledZ,i=n[0].overscaledZ-r+1;if(i>1){this.currentStencilSource=void 0,this.nextStencilID+i>256&&this.clearStencil();let e={};for(let n=0;n<i;n++)e[n+r]=new K({func:t.GEQUAL,mask:255},n+this.nextStencilID,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID+=i,[e,n]}return[{[r]:K.disabled},n]}stencilConfigForOverlapTwoPass(e){let t=this.context.gl,n=e.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),r=n[n.length-1].overscaledZ,i=n[0].overscaledZ-r+1;if(this.clearStencil(),i>1){let e={},a={};for(let n=0;n<i;n++)e[n+r]=new K({func:t.GREATER,mask:255},i+1+n,255,t.KEEP,t.KEEP,t.REPLACE),a[n+r]=new K({func:t.GREATER,mask:255},1+n,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID=2*i+1,[e,a,n]}return this.nextStencilID=3,[{[r]:new K({func:t.GREATER,mask:255},2,255,t.KEEP,t.KEEP,t.REPLACE)},{[r]:new K({func:t.GREATER,mask:255},1,255,t.KEEP,t.KEEP,t.REPLACE)},n]}colorModeForRenderPass(){let e=this.context.gl;if(this._showOverdrawInspector){let n=1/8;return new Jt([e.CONSTANT_COLOR,e.ONE],new t.bf(n,n,n,0),[!0,!0,!0,!0])}return this.renderPass===`opaque`?Jt.unblended:Jt.alphaBlended}getDepthModeForSublayer(e,t,n){if(!this.opaquePassEnabledForLayer())return G.disabled;let r=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new G(n||this.context.gl.LEQUAL,t,[r,r])}getDepthModeFor3D(){return new G(this.context.gl.LEQUAL,G.ReadWrite,this.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(e,n){var r;this.style=e,this.options=n,this.lineAtlas=e.lineAtlas,this.imageManager=e.imageManager,this.glyphManager=e.glyphManager,this.symbolFadeChange=e.placement.symbolFadeChange(o.now()),this.imageManager.beginFrame();let i=this.style._order,a=this.style.sourceCaches,s={},c={},l={},u={isRenderingToTexture:!1,isRenderingGlobe:e.projection?.transitionState>0};for(let e in a){let t=a[e];t.used&&t.prepare(this.context),s[e]=t.getVisibleCoordinates(!1),c[e]=s[e].slice().reverse(),l[e]=t.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let e=0;e<i.length;e++)if(this.style._layers[i[e]].is3D()){this.opaquePassCutoff=e;break}this.maybeDrawDepthAndCoords(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass=`offscreen`;for(let e of i){let t=this.style._layers[e];if(!t.hasOffscreenPass()||t.isHidden(this.transform.zoom))continue;let n=c[t.source];(t.type===`custom`||n.length)&&this.renderLayer(this,a[t.source],t,n,u)}if((r=this.style.projection)==null||r.updateGPUdependent({context:this.context,useProgram:e=>this.useProgram(e)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:n.showOverdrawInspector?t.bf.black:t.bf.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(e,t){let n=e.context,r=n.gl,i=((e,t,n)=>{let r=Math.cos(t.rollInRadians),i=Math.sin(t.rollInRadians),a=Ze(t),o=t.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:e.properties.get(`sky-color`),u_horizon_color:e.properties.get(`horizon-color`),u_horizon:[(t.width/2-a*i)*n,(t.height/2+a*r)*n],u_horizon_normal:[-i,r],u_sky_horizon_blend:e.properties.get(`sky-horizon-blend`)*t.height/2*n,u_sky_blend:o}})(t,e.style.map.transform,e.pixelRatio),a=new G(r.LEQUAL,G.ReadWrite,[0,1]),o=K.disabled,s=e.colorModeForRenderPass(),c=e.useProgram(`sky`),l=Ai(n,t);c.draw(n,r.TRIANGLES,a,o,s,W.disabled,i,null,void 0,`sky`,l.vertexBuffer,l.indexBuffer,l.segments)}(this,this.style.sky),this._showOverdrawInspector=n.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass=`opaque`,this.currentLayer=i.length-1;this.currentLayer>=0;this.currentLayer--){let e=this.style._layers[i[this.currentLayer]],t=a[e.source],n=s[e.source];this._renderTileClippingMasks(e,n,!1),this.renderLayer(this,t,e,n,u)}this.renderPass=`translucent`;let d=!1;for(this.currentLayer=0;this.currentLayer<i.length;this.currentLayer++){let e=this.style._layers[i[this.currentLayer]],t=a[e.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(e,u))continue;this.opaquePassEnabledForLayer()||d||(d=!0,u.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());let n=(e.type===`symbol`?l:c)[e.source];this._renderTileClippingMasks(e,s[e.source],!!this.renderToTexture),this.renderLayer(this,t,e,n,u)}if(u.isRenderingGlobe&&function(e,n,r){let i=e.context,a=i.gl,o=e.useProgram(`atmosphere`),s=new G(a.LEQUAL,G.ReadOnly,[0,1]),c=e.transform,l=function(e,n){let r=e.properties.get(`position`),i=[-r.x,-r.y,-r.z],a=t.a4(new Float64Array(16));return e.properties.get(`anchor`)===`map`&&(t.b6(a,a,n.rollInRadians),t.b7(a,a,-n.pitchInRadians),t.b6(a,a,n.bearingInRadians),t.b7(a,a,n.center.lat*Math.PI/180),t.bz(a,a,-n.center.lng*Math.PI/180)),t.c6(i,i,a),i}(r,e.transform),u=c.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),d=n.properties.get(`atmosphere-blend`)*u.projectionTransition;if(d===0)return;let f=un(c.worldSize,c.center.lat),p=c.inverseProjectionMatrix,m=new Float64Array(4);m[3]=1,t.$(m,m,c.modelViewProjectionMatrix),m[0]/=m[3],m[1]/=m[3],m[2]/=m[3],m[3]=1,t.$(m,m,p),m[0]/=m[3],m[1]/=m[3],m[2]/=m[3],m[3]=1;let h=((e,t,n,r,i)=>({u_sun_pos:e,u_atmosphere_blend:t,u_globe_position:n,u_globe_radius:r,u_inv_proj_matrix:i}))(l,d,[m[0],m[1],m[2]],f,p),g=Ai(i,n);o.draw(i,a.TRIANGLES,s,K.disabled,Jt.alphaBlended,W.disabled,h,null,null,`atmosphere`,g.vertexBuffer,g.indexBuffer,g.segments)}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){let e=function(e,t){let n=null,r=Object.values(e._layers).flatMap((n=>n.source&&!n.isHidden(t)?[e.sourceCaches[n.source]]:[])),i=r.filter((e=>e.getSource().type===`vector`)),a=r.filter((e=>e.getSource().type!==`vector`)),o=e=>{(!n||n.getSource().maxzoom<e.getSource().maxzoom)&&(n=e)};return i.forEach((e=>o(e))),n||a.forEach((e=>o(e))),n}(this.style,this.transform.zoom);e&&function(e,t,n){for(let r=0;r<n.length;r++)Oi(e,t,n[r])}(this,e,e.getVisibleCoordinates())}this.options.showPadding&&function(e){let t=e.transform.padding;Ti(e,e.transform.height-(t.top||0),3,bi),Ti(e,t.bottom||0,3,xi),Ei(e,t.left||0,3,Si),Ei(e,e.transform.width-(t.right||0),3,Ci);let n=e.transform.centerPoint;(function(e,t,n,r){Di(e,t-1,n-10,2,20,r),Di(e,t-10,n-1,20,2,r)})(e,n.x,e.transform.height-n.y,wi)}(this),this.context.setDefault()}maybeDrawDepthAndCoords(e){if(!this.style||!this.style.map||!this.style.map.terrain)return;let n=this.terrainFacilitator.matrix,r=this.transform.modelViewProjectionMatrix,i=this.terrainFacilitator.dirty;i||=e?!t.c9(n,r):!t.ca(n,r),i||=this.style.map.terrain.sourceCache.anyTilesAfterTime(this.terrainFacilitator.renderTime),i&&(t.cb(n,r),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(e,n){let r=e.context,i=r.gl,a=e.transform,o=Jt.unblended,s=new G(i.LEQUAL,G.ReadWrite,[0,1]),c=n.sourceCache.getRenderableTiles(),l=e.useProgram(`terrainDepth`);r.bindFramebuffer.set(n.getFramebuffer(`depth`).framebuffer),r.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),r.clear({color:t.bf.transparent,depth:1});for(let e of c){let t=n.getTerrainMesh(e.tileID),c=n.getTerrainData(e.tileID),u=a.getProjectionData({overscaledTileID:e.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),d={u_ele_delta:n.getMeshFrameDelta(a.zoom)};l.draw(r,i.TRIANGLES,s,K.disabled,o,W.backCCW,d,c,u,`terrain`,t.vertexBuffer,t.indexBuffer,t.segments)}r.bindFramebuffer.set(null),r.viewport.set([0,0,e.width,e.height])}(this,this.style.map.terrain),function(e,n){let r=e.context,i=r.gl,a=e.transform,o=Jt.unblended,s=new G(i.LEQUAL,G.ReadWrite,[0,1]),c=n.getCoordsTexture(),l=n.sourceCache.getRenderableTiles(),u=e.useProgram(`terrainCoords`);r.bindFramebuffer.set(n.getFramebuffer(`coords`).framebuffer),r.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),r.clear({color:t.bf.transparent,depth:1}),n.coordsIndex=[];for(let e of l){let t=n.getTerrainMesh(e.tileID),l=n.getTerrainData(e.tileID);r.activeTexture.set(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,c.texture);let d={u_terrain_coords_id:(255-n.coordsIndex.length)/255,u_texture:0,u_ele_delta:n.getMeshFrameDelta(a.zoom)},f=a.getProjectionData({overscaledTileID:e.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});u.draw(r,i.TRIANGLES,s,K.disabled,o,W.backCCW,d,l,f,`terrain`,t.vertexBuffer,t.indexBuffer,t.segments),n.coordsIndex.push(e.tileID.key)}r.bindFramebuffer.set(null),r.viewport.set([0,0,e.width,e.height])}(this,this.style.map.terrain))}renderLayer(e,n,r,i,a){r.isHidden(this.transform.zoom)||(r.type===`background`||r.type===`custom`||(i||[]).length)&&(this.id=r.id,t.cc(r)?function(e,n,r,i,a,o){if(e.renderPass!==`translucent`)return;let{isRenderingToTexture:s}=o,c=K.disabled,l=e.colorModeForRenderPass();(r._unevaluatedLayout.hasValue(`text-variable-anchor`)||r._unevaluatedLayout.hasValue(`text-variable-anchor-offset`))&&function(e,n,r,i,a,o,s,c,l){let u=n.transform,d=n.style.map.terrain,f=a===`map`,p=o===`map`;for(let a of e){let e=i.getTile(a),o=e.getBucket(r);if(!o||!o.text||!o.text.segments.get().length)continue;let m=t.O(o.textSizeData,u.zoom),h=t.aC(e,1,n.transform.zoom,n.transform.detailLevel),g=oe(f,n.transform,h),_=r.layout.get(`icon-text-fit`)!==`none`&&o.hasIconData();if(m){let n=2**(u.zoom-e.tileID.overscaledZ),r=d?(e,t)=>d.getElevation(a,e,t):null;ii(o,f,p,l,u,g,n,m,_,t.aD(u,e,s,c),a.toUnwrapped(),r)}}}(i,e,r,n,r.layout.get(`text-rotation-alignment`),r.layout.get(`text-pitch-alignment`),r.paint.get(`text-translate`),r.paint.get(`text-translate-anchor`),a),r.paint.get(`icon-opacity`).constantOr(1)!==0&&oi(e,n,r,i,!1,r.paint.get(`icon-translate`),r.paint.get(`icon-translate-anchor`),r.layout.get(`icon-rotation-alignment`),r.layout.get(`icon-pitch-alignment`),r.layout.get(`icon-keep-upright`),c,l,s),r.paint.get(`text-opacity`).constantOr(1)!==0&&oi(e,n,r,i,!0,r.paint.get(`text-translate`),r.paint.get(`text-translate-anchor`),r.layout.get(`text-rotation-alignment`),r.layout.get(`text-pitch-alignment`),r.layout.get(`text-keep-upright`),c,l,s),n.map.showCollisionBoxes&&(ei(e,n,r,i,!0),ei(e,n,r,i,!1))}(e,n,r,i,this.style.placement.variableOffsets,a):t.cd(r)?function(e,n,r,i,a){if(e.renderPass!==`translucent`)return;let{isRenderingToTexture:o}=a,s=r.paint.get(`circle-opacity`),c=r.paint.get(`circle-stroke-width`),l=r.paint.get(`circle-stroke-opacity`),u=!r.layout.get(`circle-sort-key`).isConstant();if(s.constantOr(1)===0&&(c.constantOr(1)===0||l.constantOr(1)===0))return;let d=e.context,f=d.gl,p=e.transform,m=e.getDepthModeForSublayer(0,G.ReadOnly),h=K.disabled,g=e.colorModeForRenderPass(),_=[],v=p.getCircleRadiusCorrection();for(let a=0;a<i.length;a++){let s=i[a],c=n.getTile(s),l=c.getBucket(r);if(!l)continue;let d=r.paint.get(`circle-translate`),f=r.paint.get(`circle-translate-anchor`),m=t.aD(p,c,d,f),h=l.programConfigurations.get(r.id),g=e.useProgram(`circle`,h),y=l.layoutVertexBuffer,b=l.indexBuffer,x=e.style.map.terrain&&e.style.map.terrain.getTerrainData(s),S={programConfiguration:h,program:g,layoutVertexBuffer:y,indexBuffer:b,uniformValues:Hn(e,c,r,m,v),terrainData:x,projectionData:p.getProjectionData({overscaledTileID:s,applyGlobeMatrix:!o,applyTerrainMatrix:!0})};if(u){let e=l.segments.get();for(let n of e)_.push({segments:new t.aM([n]),sortKey:n.sortKey,state:S})}else _.push({segments:l.segments,sortKey:0,state:S})}u&&_.sort(((e,t)=>e.sortKey-t.sortKey));for(let t of _){let{programConfiguration:n,program:i,layoutVertexBuffer:a,indexBuffer:o,uniformValues:s,terrainData:c,projectionData:l}=t.state;i.draw(d,f.TRIANGLES,m,h,g,W.backCCW,s,c,l,r.id,a,o,t.segments,r.paint,e.transform.zoom,n)}}(e,n,r,i,a):t.ce(r)?function(e,n,r,i,a){if(r.paint.get(`heatmap-opacity`)===0)return;let o=e.context,{isRenderingToTexture:s,isRenderingGlobe:c}=a;if(e.style.map.terrain){for(let t of i){let i=n.getTile(t);n.hasRenderableParent(t)||(e.renderPass===`offscreen`?ci(e,i,r,t,c):e.renderPass===`translucent`&&li(e,r,t,s,c))}o.viewport.set([0,0,e.width,e.height])}else e.renderPass===`offscreen`?function(e,n,r,i){let a=e.context,o=a.gl,s=e.transform,c=K.disabled,l=new Jt([o.ONE,o.ONE],t.bf.transparent,[!0,!0,!0,!0]);(function(e,n,r){let i=e.gl;e.activeTexture.set(i.TEXTURE1),e.viewport.set([0,0,n.width/4,n.height/4]);let a=r.heatmapFbos.get(t.c3);a?(i.bindTexture(i.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer)):(a=ui(e,n.width/4,n.height/4),r.heatmapFbos.set(t.c3,a))})(a,e,r),a.clear({color:t.bf.transparent});for(let t=0;t<i.length;t++){let u=i[t];if(n.hasRenderableParent(u))continue;let d=n.getTile(u),f=d.getBucket(r);if(!f)continue;let p=f.programConfigurations.get(r.id),m=e.useProgram(`heatmap`,p),h=s.getProjectionData({overscaledTileID:u,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),g=s.getCircleRadiusCorrection();m.draw(a,o.TRIANGLES,G.disabled,c,l,W.backCCW,Kn(d,s.zoom,s.detailLevel,r.paint.get(`heatmap-intensity`),g),null,h,r.id,f.layoutVertexBuffer,f.indexBuffer,f.segments,r.paint,s.zoom,p)}a.viewport.set([0,0,e.width,e.height])}(e,n,r,i):e.renderPass===`translucent`&&function(e,n){let r=e.context,i=r.gl;r.setColorMode(e.colorModeForRenderPass());let a=n.heatmapFbos.get(t.c3);a&&(r.activeTexture.set(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,a.colorAttachment.get()),r.activeTexture.set(i.TEXTURE1),di(r,n).bind(i.LINEAR,i.CLAMP_TO_EDGE),e.useProgram(`heatmapTexture`).draw(r,i.TRIANGLES,G.disabled,K.disabled,e.colorModeForRenderPass(),W.disabled,qn(e,n,0,1),null,null,n.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,n.paint,e.transform.zoom))}(e,r)}(e,n,r,i,a):t.cf(r)?function(e,n,r,i,a){if(e.renderPass!==`translucent`)return;let{isRenderingToTexture:o}=a,s=r.paint.get(`line-opacity`),c=r.paint.get(`line-width`);if(s.constantOr(1)===0||c.constantOr(1)===0)return;let l=e.getDepthModeForSublayer(0,G.ReadOnly),u=e.colorModeForRenderPass(),d=r.paint.get(`line-dasharray`),f=r.paint.get(`line-pattern`),p=f.constantOr(1),m=r.paint.get(`line-gradient`),h=r.getCrossfadeParameters(),g=p?`linePattern`:d?`lineSDF`:m?`lineGradient`:`line`,_=e.context,v=_.gl,y=e.transform,b=!0;for(let a of i){let i=n.getTile(a);if(p&&!i.patternsLoaded())continue;let s=i.getBucket(r);if(!s)continue;let c=s.programConfigurations.get(r.id),x=e.context.program.get(),S=e.useProgram(g,c),C=b||S.program!==x,w=e.style.map.terrain&&e.style.map.terrain.getTerrainData(a),T=f.constantOr(null);if(T&&i.imageAtlas){let e=i.imageAtlas,t=e.patternPositions[T.to.toString()],n=e.patternPositions[T.from.toString()];t&&n&&c.setConstantPatternPositions(t,n)}let E=y.getProjectionData({overscaledTileID:a,applyGlobeMatrix:!o,applyTerrainMatrix:!0}),D=y.getPixelScale(),O=p?er(e,i,r,D,h):d?tr(e,i,r,D,d,h):m?$n(e,i,r,D,s.lineClipsArray.length):Qn(e,i,r,D);if(p)_.activeTexture.set(v.TEXTURE0),i.imageAtlasTexture.bind(v.LINEAR,v.CLAMP_TO_EDGE),c.updatePaintBuffers(h);else if(d&&(C||e.lineAtlas.dirty))_.activeTexture.set(v.TEXTURE0),e.lineAtlas.bind(_);else if(m){let i=s.gradients[r.id],o=i.texture;if(r.gradientVersion!==i.version){let c=256;if(r.stepInterpolant){let r=n.getSource().maxzoom,i=a.canonical.z===r?Math.ceil(1<<e.transform.maxZoom-a.canonical.z):1;c=t.L(t.c4(s.maxLineLength/t.ah*1024*i),256,_.maxTextureSize)}i.gradient=t.c5({expression:r.gradientExpression(),evaluationKey:`lineProgress`,resolution:c,image:i.gradient||void 0,clips:s.lineClipsArray}),i.texture?i.texture.update(i.gradient):i.texture=new t.T(_,i.gradient,v.RGBA),i.version=r.gradientVersion,o=i.texture}_.activeTexture.set(v.TEXTURE0),o.bind(r.stepInterpolant?v.NEAREST:v.LINEAR,v.CLAMP_TO_EDGE)}let k=e.stencilModeForClipping(a);S.draw(_,v.TRIANGLES,l,k,u,W.disabled,O,w,E,r.id,s.layoutVertexBuffer,s.indexBuffer,s.segments,r.paint,e.transform.zoom,c,s.layoutVertexBuffer2),b=!1}}(e,n,r,i,a):t.cg(r)?function(e,n,r,i,a){let o=r.paint.get(`fill-color`),s=r.paint.get(`fill-opacity`);if(s.constantOr(1)===0)return;let{isRenderingToTexture:c}=a,l=e.colorModeForRenderPass(),u=r.paint.get(`fill-pattern`),d=e.opaquePassEnabledForLayer()&&!u.constantOr(1)&&o.constantOr(t.bf.transparent).a===1&&s.constantOr(0)===1?`opaque`:`translucent`;e.renderPass===d&&pi(e,n,r,i,e.getDepthModeForSublayer(1,e.renderPass===`opaque`?G.ReadWrite:G.ReadOnly),l,!1,c),e.renderPass===`translucent`&&r.paint.get(`fill-antialias`)&&pi(e,n,r,i,e.getDepthModeForSublayer(r.getPaintProperty(`fill-outline-color`)?2:0,G.ReadOnly),l,!0,c)}(e,n,r,i,a):t.ch(r)?function(e,t,n,r,i){let a=n.paint.get(`fill-extrusion-opacity`);if(a===0)return;let{isRenderingToTexture:o}=i;if(e.renderPass===`translucent`){let i=new G(e.context.gl.LEQUAL,G.ReadWrite,e.depthRangeFor3D);if(a!==1||n.paint.get(`fill-extrusion-pattern`).constantOr(1))mi(e,t,n,r,i,K.disabled,Jt.disabled,o),mi(e,t,n,r,i,e.stencilModeFor3D(),e.colorModeForRenderPass(),o);else{let a=e.colorModeForRenderPass();mi(e,t,n,r,i,K.disabled,a,o)}}}(e,n,r,i,a):t.ci(r)?function(e,n,r,i,a){if(e.renderPass!==`offscreen`&&e.renderPass!==`translucent`)return;let{isRenderingToTexture:o}=a,s=e.context,c=e.style.projection.useSubdivision,l=e.getDepthModeForSublayer(0,G.ReadOnly),u=e.colorModeForRenderPass();if(e.renderPass===`offscreen`)(function(e,n,r,i,a,o,s){let c=e.context,l=c.gl;for(let u of r){let r=n.getTile(u),d=r.dem;if(!d||!d.data||!r.needsHillshadePrepare)continue;let f=d.dim,p=d.stride,m=d.getPixels();if(c.activeTexture.set(l.TEXTURE1),c.pixelStoreUnpackPremultiplyAlpha.set(!1),r.demTexture=r.demTexture||e.getTileTexture(p),r.demTexture){let e=r.demTexture;e.update(m,{premultiply:!1}),e.bind(l.NEAREST,l.CLAMP_TO_EDGE)}else r.demTexture=new t.T(c,m,l.RGBA,{premultiply:!1}),r.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);c.activeTexture.set(l.TEXTURE0);let h=r.fbo;if(!h){let e=new t.T(c,{width:f,height:f,data:null},l.RGBA);e.bind(l.LINEAR,l.CLAMP_TO_EDGE),h=r.fbo=c.createFramebuffer(f,f,!0,!1),h.colorAttachment.set(e.texture)}c.bindFramebuffer.set(h.framebuffer),c.viewport.set([0,0,f,f]),e.useProgram(`hillshadePrepare`).draw(c,l.TRIANGLES,a,o,s,W.disabled,Yn(r.tileID,d),null,null,i.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments),r.needsHillshadePrepare=!1}})(e,n,i,r,l,K.disabled,u),s.viewport.set([0,0,e.width,e.height]);else if(e.renderPass===`translucent`)if(c){let[t,a,s]=e.stencilConfigForOverlapTwoPass(i);hi(e,n,r,s,t,l,u,!1,o),hi(e,n,r,s,a,l,u,!0,o)}else{let[t,a]=e.getStencilConfigForOverlapAndUpdateStencilID(i);hi(e,n,r,a,t,l,u,!1,o)}}(e,n,r,i,a):t.cj(r)?function(e,t,n,r,i){if(e.renderPass!==`translucent`||!r.length)return;let{isRenderingToTexture:a}=i,o=e.style.projection.useSubdivision,s=e.getDepthModeForSublayer(0,G.ReadOnly),c=e.colorModeForRenderPass();if(o){let[i,o,l]=e.stencilConfigForOverlapTwoPass(r);gi(e,t,n,l,i,s,c,!1,a),gi(e,t,n,l,o,s,c,!0,a)}else{let[i,o]=e.getStencilConfigForOverlapAndUpdateStencilID(r);gi(e,t,n,o,i,s,c,!1,a)}}(e,n,r,i,a):t.ck(r)?function(e,t,n,r,i){if(e.renderPass!==`translucent`||n.paint.get(`raster-opacity`)===0||!r.length)return;let{isRenderingToTexture:a}=i,o=t.getSource(),s=e.style.projection.useSubdivision;if(o instanceof Be)vi(e,t,n,r,null,!1,!1,o.tileCoords,o.flippedWindingOrder,a);else if(s){let[i,o,s]=e.stencilConfigForOverlapTwoPass(r);vi(e,t,n,s,i,!1,!0,_i,!1,a),vi(e,t,n,s,o,!0,!0,_i,!1,a)}else{let[i,o]=e.getStencilConfigForOverlapAndUpdateStencilID(r);vi(e,t,n,o,i,!1,!0,_i,!1,a)}}(e,n,r,i,a):t.cl(r)?function(e,t,n,r,i){let a=n.paint.get(`background-color`),o=n.paint.get(`background-opacity`);if(o===0)return;let{isRenderingToTexture:s}=i,c=e.context,l=c.gl,u=e.style.projection,d=e.transform,f=d.tileSize,p=n.paint.get(`background-pattern`);if(e.isPatternMissing(p))return;let m=!p&&a.a===1&&o===1&&e.opaquePassEnabledForLayer()?`opaque`:`translucent`;if(e.renderPass!==m)return;let h=K.disabled,g=e.getDepthModeForSublayer(0,m===`opaque`?G.ReadWrite:G.ReadOnly),_=e.colorModeForRenderPass(),v=e.useProgram(p?`backgroundPattern`:`background`),y=r||it(d,{tileSize:f,terrain:e.style.map.terrain});p&&(c.activeTexture.set(l.TEXTURE0),e.imageManager.bind(e.context));let b=n.getCrossfadeParameters();for(let t of y){let r=d.getProjectionData({overscaledTileID:t,applyGlobeMatrix:!s,applyTerrainMatrix:!0}),i=p?ur(o,e,p,{tileID:t,tileSize:f},b):lr(o,a),m=e.style.map.terrain&&e.style.map.terrain.getTerrainData(t),y=u.getMeshFromTileID(c,t.canonical,!1,!0,`raster`);v.draw(c,l.TRIANGLES,g,h,_,W.backCCW,i,m,r,n.id,y.vertexBuffer,y.indexBuffer,y.segments)}}(e,0,r,i,a):t.cm(r)&&function(e,t,n,r){let{isRenderingGlobe:i}=r,a=e.context,o=n.implementation,s=e.style.projection,c=e.transform,l=c.getProjectionDataForCustomLayer(i),u={farZ:c.farZ,nearZ:c.nearZ,fov:c.fov*Math.PI/180,modelViewProjectionMatrix:c.modelViewProjectionMatrix,projectionMatrix:c.projectionMatrix,shaderData:{variantName:s.shaderVariantName,vertexShaderPrelude:`const float PI = 3.141592653589793;\nuniform mat4 u_projection_matrix;\n${s.shaderPreludeCode.vertexSource}`,define:s.shaderDefine},defaultProjectionData:l},d=o.renderingMode?o.renderingMode:`2d`;if(e.renderPass===`offscreen`){let t=o.prerender;t&&(e.setCustomLayerDefaults(),a.setColorMode(e.colorModeForRenderPass()),t.call(o,a.gl,u),a.setDirty(),e.setBaseState())}else if(e.renderPass===`translucent`){e.setCustomLayerDefaults(),a.setColorMode(e.colorModeForRenderPass()),a.setStencilMode(K.disabled);let t=d===`3d`?e.getDepthModeFor3D():e.getDepthModeForSublayer(0,G.ReadOnly);a.setDepthMode(t),o.render(a.gl,u),a.setDirty(),e.setBaseState(),a.bindFramebuffer.set(null)}}(e,0,r,a))}saveTileTexture(e){let t=this._tileTextures[e.size[0]];t?t.push(e):this._tileTextures[e.size[0]]=[e]}getTileTexture(e){let t=this._tileTextures[e];return t&&t.length>0?t.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;let t=this.imageManager.getPattern(e.from.toString()),n=this.imageManager.getPattern(e.to.toString());return!t||!n}useProgram(e,t,n=!1,r=[]){this.cache=this.cache||{};let i=!!this.style.map.terrain,a=this.style.projection,o=n?jt.projectionMercator:a.shaderPreludeCode,s=n?Pt:a.shaderDefine,c=e+(t?t.cacheKey:``)+`/${n?U:a.shaderVariantName}`+(this._showOverdrawInspector?`/overdraw`:``)+(i?`/terrain`:``)+(r?`/${r.join(`/`)}`:``);return this.cache[c]||(this.cache[c]=new Fn(this.context,jt[e],t,fr[e],this._showOverdrawInspector,i,o,s,r)),this.cache[c]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){let 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(){this.debugOverlayCanvas??(this.debugOverlayCanvas=document.createElement(`canvas`),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new t.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){let{drawingBufferWidth:e,drawingBufferHeight:t}=this.context.gl;return this.width!==e||this.height!==t}}function Mi(e,t){let n,r=!1,i=null,a=null,o=()=>{i=null,r&&=(e.apply(a,n),i=setTimeout(o,t),!1)};return(...e)=>(r=!0,a=this,n=e,i||o(),i)}class Ni{constructor(e){this._getCurrentHash=()=>{let e=window.location.hash.replace(`#`,``);if(this._hashName){let t;return e.split(`&`).map((e=>e.split(`=`))).forEach((e=>{e[0]===this._hashName&&(t=e)})),(t&&t[1]||``).split(`/`)}return e.split(`/`)},this._onHashChange=()=>{let e=this._getCurrentHash();if(!this._isValidHash(e))return!1;let t=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(e[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:t,pitch:+(e[4]||0)}),!0},this._updateHashUnthrottled=()=>{let e=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,e)},this._removeHash=()=>{let e=this._getCurrentHash();if(e.length===0)return;let t=e.join(`/`),n=t;n.split(`&`).length>0&&(n=n.split(`&`)[0]),this._hashName&&(n=`${this._hashName}=${t}`);let r=window.location.hash.replace(n,``);r.startsWith(`#&`)?r=r.slice(0,1)+r.slice(2):r===`#`&&(r=``);let i=window.location.href.replace(/(#.+)?$/,r);i=i.replace(`&&`,`&`),window.history.replaceState(window.history.state,null,i)},this._updateHash=Mi(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,addEventListener(`hashchange`,this._onHashChange,!1),this._map.on(`moveend`,this._updateHash),this}remove(){return removeEventListener(`hashchange`,this._onHashChange,!1),this._map.off(`moveend`,this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){let t=this._map.getCenter(),n=Math.round(100*this._map.getZoom())/100,r=10**Math.ceil((n*Math.LN2+Math.log(512/360/.5))/Math.LN10),i=Math.round(t.lng*r)/r,a=Math.round(t.lat*r)/r,o=this._map.getBearing(),s=this._map.getPitch(),c=``;if(c+=e?`/${i}/${a}/${n}`:`${n}/${a}/${i}`,(o||s)&&(c+=`/`+Math.round(10*o)/10),s&&(c+=`/${Math.round(s)}`),this._hashName){let e=this._hashName,t=!1,n=window.location.hash.slice(1).split(`&`).map((n=>{let r=n.split(`=`)[0];return r===e?(t=!0,`${r}=${c}`):n})).filter((e=>e));return t||n.push(`${e}=${c}`),`#${n.join(`&`)}`}return`#${c}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return!1;try{new t.aa(+e[2],+e[1])}catch{return!1}let n=+e[0],r=+(e[3]||0),i=+(e[4]||0);return n>=this._map.getMinZoom()&&n<=this._map.getMaxZoom()&&r>=-180&&r<=180&&i>=this._map.getMinPitch()&&i<=this._map.getMaxPitch()}}let Pi={linearity:.3,easing:t.cn(0,0,.3,1)},Fi=t.e({deceleration:2500,maxSpeed:1400},Pi),Ii=t.e({deceleration:20,maxSpeed:1400},Pi),Li=t.e({deceleration:1e3,maxSpeed:360},Pi),Ri=t.e({deceleration:1e3,maxSpeed:90},Pi),zi=t.e({deceleration:1e3,maxSpeed:360},Pi);class Bi{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:o.now(),settings:e})}_drainInertiaBuffer(){let e=this._inertiaBuffer,t=o.now();for(;e.length>0&&t-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;let n={zoom:0,bearing:0,pitch:0,roll:0,pan:new t.P(0,0),pinchAround:void 0,around:void 0};for(let{settings:e}of this._inertiaBuffer)n.zoom+=e.zoomDelta||0,n.bearing+=e.bearingDelta||0,n.pitch+=e.pitchDelta||0,n.roll+=e.rollDelta||0,e.panDelta&&n.pan._add(e.panDelta),e.around&&(n.around=e.around),e.pinchAround&&(n.pinchAround=e.pinchAround);let r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,i={};if(n.pan.mag()){let a=Hi(n.pan.mag(),r,t.e({},Fi,e||{})),o=n.pan.mult(a.amount/n.pan.mag()),s=this._map.cameraHelper.handlePanInertia(o,this._map.transform);i.center=s.easingCenter,i.offset=s.easingOffset,Vi(i,a)}if(n.zoom){let e=Hi(n.zoom,r,Ii);i.zoom=this._map.transform.zoom+e.amount,Vi(i,e)}if(n.bearing){let e=Hi(n.bearing,r,Li);i.bearing=this._map.transform.bearing+t.L(e.amount,-179,179),Vi(i,e)}if(n.pitch){let e=Hi(n.pitch,r,Ri);i.pitch=this._map.transform.pitch+e.amount,Vi(i,e)}if(n.roll){let e=Hi(n.roll,r,zi);i.roll=this._map.transform.roll+t.L(e.amount,-179,179),Vi(i,e)}if(i.zoom||i.bearing){let e=n.pinchAround===void 0?n.around:n.pinchAround;i.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),t.e(i,{noMoveStart:!0})}}function Vi(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing)}function Hi(e,n,r){let{maxSpeed:i,linearity:a,deceleration:o}=r,s=t.L(e*a/(n/1e3),-i,i),c=Math.abs(s)/(o*a);return{easing:r.easing,duration:1e3*c,amount:c/2*s}}class Ui extends t.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,r,i={}){r=r instanceof MouseEvent?r:new MouseEvent(e,r);let a=s.mousePos(n.getCanvas(),r,n.getScale()),o=n.unproject(a);super(e,t.e({point:a,lngLat:o,originalEvent:r},i)),this._defaultPrevented=!1,this.target=n}}class Wi extends t.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,r){let i=e===`touchend`?r.changedTouches:r.touches,a=s.touchPos(n.getCanvasContainer(),i,n.getScale()),o=a.map((e=>n.unproject(e))),c=a.reduce(((e,t,n,r)=>e.add(t.div(r.length))),new t.P(0,0));super(e,{points:a,point:c,lngLats:o,lngLat:n.unproject(c),originalEvent:r}),this._defaultPrevented=!1}}class Gi extends t.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,n){super(e,{originalEvent:n}),this._defaultPrevented=!1}}class Ki{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new Gi(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new Ui(e.type,this._map,e))}mouseup(e){this._map.fire(new Ui(e.type,this._map,e))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this._map.fire(new Ui(e.type,this._map,e))}dblclick(e){return this._firePreventable(new Ui(e.type,this._map,e))}mouseover(e){this._map.fire(new Ui(e.type,this._map,e))}mouseout(e){this._map.fire(new Ui(e.type,this._map,e))}touchstart(e){return this._firePreventable(new Wi(e.type,this._map,e))}touchmove(e){this._map.fire(new Wi(e.type,this._map,e))}touchend(e){this._map.fire(new Wi(e.type,this._map,e))}touchcancel(e){this._map.fire(new Wi(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class qi{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new Ui(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Ui(`contextmenu`,this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new Ui(e.type,this._map,e)),this._map.listens(`contextmenu`)&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Ji{constructor(e){this._map=e}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this._map.terrain)}}class Yi{constructor(e,t){this._map=e,this._tr=new Ji(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&&e.button===0&&(s.disableDrag(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;let n=t;if(this._lastPos.equals(n)||!this._box&&n.dist(this._startPos)<this._clickTolerance)return;let r=this._startPos;this._lastPos=n,this._box||(this._box=s.create(`div`,`maplibregl-boxzoom`,this._container),this._container.classList.add(`maplibregl-crosshair`),this._fireEvent(`boxzoomstart`,e));let i=Math.min(r.x,n.x),a=Math.max(r.x,n.x),o=Math.min(r.y,n.y),c=Math.max(r.y,n.y);s.setTransform(this._box,`translate(${i}px,${o}px)`),this._box.style.width=a-i+`px`,this._box.style.height=c-o+`px`}mouseupWindow(e,n){if(!this._active||e.button!==0)return;let r=this._startPos,i=n;if(this.reset(),s.suppressClick(),r.x!==i.x||r.y!==i.y)return this._map.fire(new t.l(`boxzoomend`,{originalEvent:e})),{cameraAnimation:e=>e.fitScreenCoordinates(r,i,this._tr.bearing,{linear:!0})};this._fireEvent(`boxzoomcancel`,e)}keydown(e){this._active&&e.keyCode===27&&(this.reset(),this._fireEvent(`boxzoomcancel`,e))}reset(){this._active=!1,this._container.classList.remove(`maplibregl-crosshair`),this._box&&=(s.remove(this._box),null),s.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,n){return this._map.fire(new t.l(e,{originalEvent:n}))}}function Xi(e,t){if(e.length!==t.length)throw Error(`The number of touches and points are not equal - touches ${e.length}, points ${t.length}`);let n={};for(let r=0;r<e.length;r++)n[e[r].identifier]=t[r];return n}class Zi{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(e,n,r){(this.centroid||r.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=e.timeStamp),r.length===this.numTouches&&(this.centroid=function(e){let n=new t.P(0,0);for(let t of e)n._add(t);return n.div(e.length)}(n),this.touches=Xi(r,n)))}touchmove(e,t,n){if(this.aborted||!this.centroid)return;let r=Xi(n,t);for(let e in this.touches){let t=r[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0)}}touchend(e,t,n){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),n.length===0){let e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class Qi{constructor(e){this.singleTap=new Zi(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,t,n){this.singleTap.touchstart(e,t,n)}touchmove(e,t,n){this.singleTap.touchmove(e,t,n)}touchend(e,t,n){let r=this.singleTap.touchend(e,t,n);if(r){let t=e.timeStamp-this.lastTime<500,n=!this.lastTap||this.lastTap.dist(r)<30;if(t&&n||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class $i{constructor(e){this._tr=new Ji(e),this._zoomIn=new Qi({numTouches:1,numTaps:2}),this._zoomOut=new Qi({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,n){this._zoomIn.touchstart(e,t,n),this._zoomOut.touchstart(e,t,n)}touchmove(e,t,n){this._zoomIn.touchmove(e,t,n),this._zoomOut.touchmove(e,t,n)}touchend(e,t,n){let r=this._zoomIn.touchend(e,t,n),i=this._zoomOut.touchend(e,t,n),a=this._tr;return r?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:a.zoom+1,around:a.unproject(r)},{originalEvent:e})}):i?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:a.zoom-1,around:a.unproject(i)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ea{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){let t=this._moveFunction(...e);if(t.bearingDelta||t.pitchDelta||t.rollDelta||t.around||t.panDelta)return this._active=!0,t}dragStart(e,t){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(t)?t[0]:t,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,t){if(!this.isEnabled())return;let n=this._lastPoint;if(!n)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);let r=Array.isArray(t)?t[0]:t;return!this._moved&&r.dist(n)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=r,this._move(n,r))}dragEnd(e){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(e)&&(this._moved&&s.suppressClick(),this.reset(e))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}let ta={0:1,2:2};class na{constructor(e){this._correctEvent=e.checkCorrectEvent}startMove(e){this._eventButton=s.mouseButton(e)}endMove(e){delete this._eventButton}isValidStartEvent(e){return this._correctEvent(e)}isValidMoveEvent(e){return!function(e,t){let n=ta[t];return e.buttons===void 0||(e.buttons&n)!==n}(e,this._eventButton)}isValidEndEvent(e){return s.mouseButton(e)===this._eventButton}}class ra{constructor(){this._firstTouch=void 0}_isOneFingerTouch(e){return e.targetTouches.length===1}_isSameTouchEvent(e){return e.targetTouches[0].identifier===this._firstTouch}startMove(e){this._firstTouch=e.targetTouches[0].identifier}endMove(e){delete this._firstTouch}isValidStartEvent(e){return this._isOneFingerTouch(e)}isValidMoveEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}isValidEndEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}}class ia{constructor(e=new na({checkCorrectEvent:()=>!0}),t=new ra){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=t}_executeRelevantHandler(e,t,n){return e instanceof MouseEvent?t(e):typeof TouchEvent<`u`&&e instanceof TouchEvent?n(e):void 0}startMove(e){this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.startMove(e)),(e=>this.oneFingerTouchMoveStateManager.startMove(e)))}endMove(e){this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.endMove(e)),(e=>this.oneFingerTouchMoveStateManager.endMove(e)))}isValidStartEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidStartEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidStartEvent(e)))}isValidMoveEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidMoveEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(e)))}isValidEndEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidEndEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidEndEvent(e)))}}let aa=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault()}};class oa{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._map=t,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new t.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,t,n){return this._calculateTransform(e,t,n)}touchmove(e,t,n){if(this._active){if(!this._shouldBePrevented(n.length))return e.preventDefault(),this._calculateTransform(e,t,n);this._map.cooperativeGestures.notifyGestureBlocked(`touch_pan`,e)}}touchend(e,t,n){this._calculateTransform(e,t,n),this._active&&this._shouldBePrevented(n.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,n,r){r.length>0&&(this._active=!0);let i=Xi(r,n),a=new t.P(0,0),o=new t.P(0,0),s=0;for(let e in i){let t=i[e],n=this._touches[e];n&&(a._add(t),o._add(t.sub(n)),s++,i[e]=t)}if(this._touches=i,this._shouldBePrevented(s)||!o.mag())return;let c=o.div(s);return this._sum._add(c),this._sum.mag()<this._clickTolerance?void 0:{around:a.div(s),panDelta:c}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class sa{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(e,t,n){this._firstTwoTouches||n.length<2||(this._firstTwoTouches=[n[0].identifier,n[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,n){if(!this._firstTwoTouches)return;e.preventDefault();let[r,i]=this._firstTwoTouches,a=Y(n,t,r),o=Y(n,t,i);if(!a||!o)return;let s=this._aroundCenter?null:a.add(o).div(2);return this._move([a,o],s,e)}touchend(e,t,n){if(!this._firstTwoTouches)return;let[r,i]=this._firstTwoTouches,a=Y(n,t,r),o=Y(n,t,i);a&&o||(this._active&&s.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&e.around===`center`}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}}function Y(e,t,n){for(let r=0;r<e.length;r++)if(e[r].identifier===n)return t[r]}function ca(e,t){return Math.log(e/t)/Math.LN2}class la extends sa{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,t){let n=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,n),pinchAround:t}}}function ua(e,t){return 180*e.angleWith(t)/Math.PI}class da extends sa{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1])}_move(e,t,n){let r=this._vector;if(this._vector=e[0].sub(e[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:ua(this._vector,r),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());let t=25/(Math.PI*this._minDiameter)*360,n=ua(e,this._startVector);return Math.abs(n)<t}}function fa(e){return Math.abs(e.y)>Math.abs(e.x)}class X extends sa{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,t,n){super.touchstart(e,t,n),this._currentTouchCount=n.length}_start(e){this._lastPoints=e,fa(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,n){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;let r=e[0].sub(this._lastPoints[0]),i=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(r,i,n.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(r.y+i.y)/2*-.5}):void 0}gestureBeginsVertically(e,t,n){if(this._valid!==void 0)return this._valid;let r=e.mag()>=2,i=t.mag()>=2;if(!r&&!i)return;if(!r||!i)return this._firstMove===void 0&&(this._firstMove=n),n-this._firstMove<100&&void 0;let a=e.y>0==t.y>0;return fa(e)&&fa(t)&&a}}let Z={panStep:100,bearingStep:15,pitchStep:10};class pa{constructor(e){this._tr=new Ji(e);let t=Z;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,n=0,r=0,i=0,a=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?n=-1:(e.preventDefault(),i=-1);break;case 39:e.shiftKey?n=1:(e.preventDefault(),i=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),a=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),a=1);break;default:return}return this._rotationDisabled&&(n=0,r=0),{cameraAnimation:o=>{let s=this._tr;o.easeTo({duration:300,easeId:`keyboardHandler`,easing:ma,zoom:t?Math.round(s.zoom)+t*(e.shiftKey?2:1):s.zoom,bearing:s.bearing+n*this._bearingStep,pitch:s.pitch+r*this._pitchStep,offset:[-i*this._panStep,-a*this._panStep],center:s.center},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function ma(e){return e*(2-e)}let ha=4.000244140625;class ga{constructor(e,t){this._onTimeout=e=>{this._type=`wheel`,this._delta-=this._lastValue,this._active||this._start(e)},this._map=e,this._tr=new Ji(e),this._triggerRenderFrame=t,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&e.around===`center`)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return!!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked(`wheel_zoom`,e);let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY,n=o.now(),r=n-(this._lastWheelEventTime||0);this._lastWheelEventTime=n,t!==0&&t%ha==0?this._type=`wheel`:t!==0&&Math.abs(t)<4?this._type=`trackpad`:r>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(r*t)<200?`trackpad`:`wheel`,this._timeout&&(clearTimeout(this._timeout),this._timeout=null,t+=this._lastValue)),e.shiftKey&&t&&(t/=4),this._type&&(this._lastWheelEvent=e,this._delta-=t,this._active||this._start(e)),e.preventDefault()}_start(e){if(!this._delta)return;this._frameId&&=null,this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);let n=s.mousePos(this._map.getCanvas(),e,this._map.getScale()),r=this._tr;this._aroundPoint=this._aroundCenter?r.transform.locationToScreenPoint(t.aa.convert(r.center)):n,this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;let e=this._tr.transform;if(typeof this._lastExpectedZoom==`number`){let t=e.zoom-this._lastExpectedZoom;typeof this._startZoom==`number`&&(this._startZoom+=t),typeof this._targetZoom==`number`&&(this._targetZoom+=t)}if(this._delta!==0){let n=this._type===`wheel`&&Math.abs(this._delta)>ha?this._wheelZoomRate:this._defaultZoomRate,r=2/(1+Math.exp(-Math.abs(this._delta*n)));this._delta<0&&r!==0&&(r=1/r);let i=typeof this._targetZoom==`number`?t.aw(this._targetZoom):e.scale;this._targetZoom=e.getConstrained(e.getCameraLngLat(),t.az(i*r)).zoom,this._type===`wheel`&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}let n=typeof this._targetZoom==`number`?this._targetZoom:e.zoom,r=this._startZoom,i=this._easing,a,s=!1;if(this._type===`wheel`&&r&&i){let e=o.now()-this._lastWheelEventTime,c=Math.min((e+5)/200,1),l=i(c);a=t.C.number(r,n,l),c<1?this._frameId||=!0:s=!0}else a=n,s=!0;return this._active=!0,s&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout}),200)),this._lastExpectedZoom=a,{noInertia:!0,needsRenderFrame:!s,zoomDelta:a-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let n=t.cp;if(this._prevEase){let e=this._prevEase,r=(o.now()-e.start)/e.duration,i=e.easing(r+.01)-e.easing(r),a=.27/Math.sqrt(i*i+1e-4)*.01,s=Math.sqrt(.0729-a*a);n=t.cn(a,s,.25,1)}return this._prevEase={start:o.now(),duration:e,easing:n},n}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class _a{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 va{constructor(e){this._tr=new Ji(e),this.reset()}reset(){this._active=!1}dblclick(e,t){return e.preventDefault(),{cameraAnimation:n=>{n.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(t)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ya{constructor(){this._tap=new Qi({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,t,n){if(!this._swipePoint)if(this._tapTime){let r=t[0],i=e.timeStamp-this._tapTime<500,a=this._tapPoint.dist(r)<30;i&&a?n.length>0&&(this._swipePoint=r,this._swipeTouch=n[0].identifier):this.reset()}else this._tap.touchstart(e,t,n)}touchmove(e,t,n){if(this._tapTime){if(this._swipePoint){if(n[0].identifier!==this._swipeTouch)return;let r=t[0],i=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:i/128}}}else this._tap.touchmove(e,t,n)}touchend(e,t,n){if(this._tapTime)this._swipePoint&&n.length===0&&this.reset();else{let r=this._tap.touchend(e,t,n);r&&(this._tapTime=e.timeStamp,this._tapPoint=r)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ba{constructor(e,t,n){this._el=e,this._mousePan=t,this._touchPan=n}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add(`maplibregl-touch-drag-pan`)}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove(`maplibregl-touch-drag-pan`)}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class xa{constructor(e,t,n,r){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=t,this._mousePitch=n,this._mouseRoll=r}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class Sa{constructor(e,t,n,r){this._el=e,this._touchZoom=t,this._touchRotate=n,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add(`maplibregl-touch-zoom-rotate`)}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove(`maplibregl-touch-zoom-rotate`)}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}class Ca{constructor(e,t){this._bypassKey=navigator.userAgent.indexOf(`Mac`)===-1?`ctrlKey`:`metaKey`,this._map=e,this._options=t,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;let e=this._map.getCanvasContainer();e.classList.add(`maplibregl-cooperative-gestures`),this._container=s.create(`div`,`maplibregl-cooperative-gesture-screen`,e);let t=this._map._getUIString(`CooperativeGesturesHandler.WindowsHelpText`);this._bypassKey===`metaKey`&&(t=this._map._getUIString(`CooperativeGesturesHandler.MacHelpText`));let n=this._map._getUIString(`CooperativeGesturesHandler.MobileHelpText`),r=document.createElement(`div`);r.className=`maplibregl-desktop-message`,r.textContent=t,this._container.appendChild(r);let i=document.createElement(`div`);i.className=`maplibregl-mobile-message`,i.textContent=n,this._container.appendChild(i),this._container.setAttribute(`aria-hidden`,`true`)}_destroyUI(){this._container&&(s.remove(this._container),this._map.getCanvasContainer().classList.remove(`maplibregl-cooperative-gestures`)),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,n){this._enabled&&(this._map.fire(new t.l(`cooperativegestureprevented`,{gestureType:e,originalEvent:n})),this._container.classList.add(`maplibregl-show`),setTimeout((()=>{this._container.classList.remove(`maplibregl-show`)}),100))}}let wa=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class Ta extends t.l{}function Ea(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class Da{constructor(e,n){this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`)},this.handleEvent=(e,n)=>{if(e.type===`blur`)return void this.stop(!0);this._updatingCamera=!0;let r=e.type===`renderFrame`?void 0:e,i={needsRenderFrame:!1},a={},o={};for(let{handlerName:c,handler:l,allowed:u}of this._handlers){if(!l.isEnabled())continue;let d;if(this._blockedByActive(o,u,c))l.reset();else if(l[n||e.type]){if(t.cq(e,n||e.type)){let t=s.mousePos(this._map.getCanvas(),e,this._map.getScale());d=l[n||e.type](e,t)}else if(t.cr(e,n||e.type)){let t=this._getMapTouches(e.touches),r=s.touchPos(this._map.getCanvas(),t,this._map.getScale());d=l[n||e.type](e,r,t)}else t.cs(n||e.type)||(d=l[n||e.type](e));this.mergeHandlerResult(i,a,d,c,r),d&&d.needsRenderFrame&&this._triggerRenderFrame()}(d||l.isActive())&&(o[c]=l)}let c={};for(let e in this._previousActiveHandlers)o[e]||(c[e]=r);this._previousActiveHandlers=o,(Object.keys(c).length||Ea(i))&&(this._changes.push([i,a,c]),this._triggerRenderFrame()),(Object.keys(o).length||Ea(i))&&this._map._stop(!0),this._updatingCamera=!1;let{cameraAnimation:l}=i;l&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],l(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Bi(e),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(n);let 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(let[e,t,n]of this._listeners)s.addEventListener(e,t,e===document?this.handleWindowEvent:this.handleEvent,n)}destroy(){for(let[e,t,n]of this._listeners)s.removeEventListener(e,t,e===document?this.handleWindowEvent:this.handleEvent,n)}_addDefaultHandlers(e){let n=this._map,r=n.getCanvasContainer();this._add(`mapEvent`,new Ki(n,e));let i=n.boxZoom=new Yi(n,e);this._add(`boxZoom`,i),e.interactive&&e.boxZoom&&i.enable();let a=n.cooperativeGestures=new Ca(n,e.cooperativeGestures);this._add(`cooperativeGestures`,a),e.cooperativeGestures&&a.enable();let o=new $i(n),c=new va(n);n.doubleClickZoom=new _a(c,o),this._add(`tapZoom`,o),this._add(`clickZoom`,c),e.interactive&&e.doubleClickZoom&&n.doubleClickZoom.enable();let l=new ya;this._add(`tapDragZoom`,l);let u=n.touchPitch=new X(n);this._add(`touchPitch`,u),e.interactive&&e.touchPitch&&n.touchPitch.enable(e.touchPitch);let d=()=>n.project(n.getCenter()),f=function({enable:e,clickTolerance:n,aroundCenter:r=!0,minPixelCenterThreshold:i=100,rotateDegreesPerPixelMoved:a=.8},o){return new ea({clickTolerance:n,move:(e,n)=>{let s=o();if(r&&Math.abs(s.y-e.y)>i)return{bearingDelta:t.co(new t.P(e.x,n.y),n,s)};let c=(n.x-e.x)*a;return r&&n.y<s.y&&(c=-c),{bearingDelta:c}},moveStateManager:new na({checkCorrectEvent:e=>s.mouseButton(e)===0&&e.ctrlKey||s.mouseButton(e)===2&&!e.ctrlKey}),enable:e,assignEvents:aa})}(e,d),p=function({enable:e,clickTolerance:t,pitchDegreesPerPixelMoved:n=-.5}){return new ea({clickTolerance:t,move:(e,t)=>({pitchDelta:(t.y-e.y)*n}),moveStateManager:new na({checkCorrectEvent:e=>s.mouseButton(e)===0&&e.ctrlKey||s.mouseButton(e)===2}),enable:e,assignEvents:aa})}(e),m=function({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:n=.3},r){return new ea({clickTolerance:t,move:(e,t)=>{let i=r(),a=(t.x-e.x)*n;return t.y<i.y&&(a=-a),{rollDelta:a}},moveStateManager:new na({checkCorrectEvent:e=>s.mouseButton(e)===2&&e.ctrlKey}),enable:e,assignEvents:aa})}(e,d);n.dragRotate=new xa(e,f,p,m),this._add(`mouseRotate`,f,[`mousePitch`]),this._add(`mousePitch`,p,[`mouseRotate`,`mouseRoll`]),this._add(`mouseRoll`,m,[`mousePitch`]),e.interactive&&e.dragRotate&&n.dragRotate.enable();let h=function({enable:e,clickTolerance:t}){return new ea({clickTolerance:t,move:(e,t)=>({around:t,panDelta:t.sub(e)}),activateOnStart:!0,moveStateManager:new na({checkCorrectEvent:e=>s.mouseButton(e)===0&&!e.ctrlKey}),enable:e,assignEvents:aa})}(e),g=new oa(e,n);n.dragPan=new ba(r,h,g),this._add(`mousePan`,h),this._add(`touchPan`,g,[`touchZoom`,`touchRotate`]),e.interactive&&e.dragPan&&n.dragPan.enable(e.dragPan);let _=new da,v=new la;n.touchZoomRotate=new Sa(r,v,_,l),this._add(`touchRotate`,_,[`touchPan`,`touchZoom`]),this._add(`touchZoom`,v,[`touchPan`,`touchRotate`]),e.interactive&&e.touchZoomRotate&&n.touchZoomRotate.enable(e.touchZoomRotate);let y=n.scrollZoom=new ga(n,(()=>this._triggerRenderFrame()));this._add(`scrollZoom`,y,[`mousePan`]),e.interactive&&e.scrollZoom&&n.scrollZoom.enable(e.scrollZoom);let b=n.keyboard=new pa(n);this._add(`keyboard`,b),e.interactive&&e.keyboard&&n.keyboard.enable(),this._add(`blockableMapEvent`,new qi(n))}_add(e,t,n){this._handlers.push({handlerName:e,handler:t,allowed:n}),this._handlersById[e]=t}stop(e){if(!this._updatingCamera){for(let{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(let{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!!wa(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,t,n){for(let r in e)if(r!==n&&(!t||t.indexOf(r)<0))return!0;return!1}_getMapTouches(e){let t=[];for(let n of e)this._el.contains(n.target)&&t.push(n);return t}mergeHandlerResult(e,n,r,i,a){if(!r)return;t.e(e,r);let o={handlerName:i,originalEvent:r.originalEvent||a};r.zoomDelta!==void 0&&(n.zoom=o),r.panDelta!==void 0&&(n.drag=o),r.rollDelta!==void 0&&(n.roll=o),r.pitchDelta!==void 0&&(n.pitch=o),r.bearingDelta!==void 0&&(n.rotate=o)}_applyChanges(){let e={},n={},r={};for(let[i,a,o]of this._changes)i.panDelta&&(e.panDelta=(e.panDelta||new t.P(0,0))._add(i.panDelta)),i.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+i.zoomDelta),i.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+i.bearingDelta),i.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+i.pitchDelta),i.rollDelta&&(e.rollDelta=(e.rollDelta||0)+i.rollDelta),i.around!==void 0&&(e.around=i.around),i.pinchAround!==void 0&&(e.pinchAround=i.pinchAround),i.noInertia&&(e.noInertia=i.noInertia),t.e(n,a),t.e(r,o);this._updateMapTransform(e,n,r),this._changes=[]}_updateMapTransform(e,t,n){let r=this._map,i=r._getTransformForUpdate(),a=r.terrain;if(!(Ea(e)||a&&this._terrainMovement))return this._fireEvents(t,n,!0);r._stop(!0);let{panDelta:o,zoomDelta:s,bearingDelta:c,pitchDelta:l,rollDelta:u,around:d,pinchAround:f}=e;f!==void 0&&(d=f),d||=r.transform.centerPoint,a&&!i.isPointOnMapSurface(d)&&(d=i.centerPoint);let p={panDelta:o,zoomDelta:s,rollDelta:u,pitchDelta:l,bearingDelta:c,around:d};this._map.cameraHelper.useGlobeControls&&!i.isPointOnMapSurface(d)&&(d=i.centerPoint);let m=d.distSqr(i.centerPoint)<.01?i.center:i.screenPointToLocation(o?d.sub(o):d);a?(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(p,i),this._terrainMovement||!t.drag&&!t.zoom?t.drag&&this._terrainMovement?i.setCenter(i.screenPointToLocation(i.centerPoint.sub(o))):this._map.cameraHelper.handleMapControlsPan(p,i,m):(this._terrainMovement=!0,this._map._elevationFreeze=!0,this._map.cameraHelper.handleMapControlsPan(p,i,m))):(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(p,i),this._map.cameraHelper.handleMapControlsPan(p,i,m)),r._applyUpdatedTransform(i),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,n,!0)}_fireEvents(e,n,r){let i=wa(this._eventsInProgress),a=wa(e),s={};for(let t in e){let{originalEvent:n}=e[t];this._eventsInProgress[t]||(s[`${t}start`]=n),this._eventsInProgress[t]=e[t]}!i&&a&&this._fireEvent(`movestart`,a.originalEvent);for(let e in s)this._fireEvent(e,s[e]);a&&this._fireEvent(`move`,a.originalEvent);for(let t in e){let{originalEvent:n}=e[t];this._fireEvent(t,n)}let c={},l;for(let e in this._eventsInProgress){let{handlerName:t,originalEvent:r}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=n[t]||r,c[`${e}end`]=l)}for(let e in c)this._fireEvent(e,c[e]);let u=wa(this._eventsInProgress),d=(i||a)&&!u;if(d&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;let e=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&e.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(e)}if(r&&d){this._updatingCamera=!0;let e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),n=e=>e!==0&&-this._bearingSnap<e&&e<this._bearingSnap;!e||!e.essential&&o.prefersReducedMotion?(this._map.fire(new t.l(`moveend`,{originalEvent:l})),n(this._map.getBearing())&&this._map.resetNorth()):(n(e.bearing||this._map.getBearing())&&(e.bearing=0),e.freezeElevation=!0,this._map.easeTo(e,{originalEvent:l})),this._updatingCamera=!1}}_fireEvent(e,n){this._map.fire(new t.l(e,n?{originalEvent:n}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((e=>{delete this._frameId,this.handleEvent(new Ta(`renderFrame`,{timeStamp:e})),this._applyChanges()}))}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class Oa extends t.E{constructor(e,t,n){super(),this._renderFrameCallback=()=>{let e=Math.min((o.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=n.bearingSnap,this.cameraHelper=t,this.on(`moveend`,(()=>{delete this._requestedCameraState}))}migrateProjection(e,t){e.apply(this.transform),this.transform=e,this.cameraHelper=t}getCenter(){return new t.aa(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,t){return this.jumpTo({elevation:e},t),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,n,r){return e=t.P.convert(e).mult(-1),this.panTo(this.transform.center,t.e({offset:e},n),r)}panTo(e,n,r){return this.easeTo(t.e({center:e},n),r)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,n,r){return this.easeTo(t.e({zoom:e},n),r)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,n){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new t.l(`movestart`,n)).fire(new t.l(`move`,n)).fire(new t.l(`moveend`,n))),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(e,n,r){return this.easeTo(t.e({bearing:e},n),r)}resetNorth(e,n){return this.rotateTo(0,t.e({duration:1e3},e),n),this}resetNorthPitch(e,n){return this.easeTo(t.e({bearing:0,pitch:0,roll:0,duration:1e3},e),n),this}snapToNorth(e,t){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(e,t):this}getPitch(){return this.transform.pitch}setPitch(e,t){return this.jumpTo({pitch:e},t),this}getRoll(){return this.transform.roll}setRoll(e,t){return this.jumpTo({roll:e},t),this}cameraForBounds(e,t){e=I.convert(e).adjustAntiMeridian();let n=t&&t.bearing||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),n,t)}_cameraForBoxAndBearing(e,n,r,i){let a={top:0,bottom:0,right:0,left:0};if(typeof(i=t.e({padding:a,offset:[0,0],maxZoom:this.transform.maxZoom},i)).padding==`number`){let e=i.padding;i.padding={top:e,bottom:e,right:e,left:e}}let o=t.e(a,i.padding);i.padding=o;let s=this.transform,c=new I(e,n);return this.cameraHelper.cameraForBoxAndBearing(i,o,c,r,s)}fitBounds(e,t,n){return this._fitInternal(this.cameraForBounds(e,t),t,n)}fitScreenCoordinates(e,n,r,i,a){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(t.P.convert(e)),this.transform.screenPointToLocation(t.P.convert(n)),r,i),i,a)}_fitInternal(e,n,r){return e?(delete(n=t.e(e,n)).padding,n.linear?this.easeTo(n,r):this.flyTo(n,r)):this}jumpTo(e,n){this.stop();let r=this._getTransformForUpdate(),i=!1,a=!1,o=!1,s=r.zoom;this.cameraHelper.handleJumpToCenterZoom(r,e);let c=r.zoom!==s;return`elevation`in e&&r.elevation!==+e.elevation&&r.setElevation(+e.elevation),`bearing`in e&&r.bearing!==+e.bearing&&(i=!0,r.setBearing(+e.bearing)),`pitch`in e&&r.pitch!==+e.pitch&&(a=!0,r.setPitch(+e.pitch)),`roll`in e&&r.roll!==+e.roll&&(o=!0,r.setRoll(+e.roll)),e.padding==null||r.isPaddingEqual(e.padding)||r.setPadding(e.padding),this._applyUpdatedTransform(r),this.fire(new t.l(`movestart`,n)).fire(new t.l(`move`,n)),c&&this.fire(new t.l(`zoomstart`,n)).fire(new t.l(`zoom`,n)).fire(new t.l(`zoomend`,n)),i&&this.fire(new t.l(`rotatestart`,n)).fire(new t.l(`rotate`,n)).fire(new t.l(`rotateend`,n)),a&&this.fire(new t.l(`pitchstart`,n)).fire(new t.l(`pitch`,n)).fire(new t.l(`pitchend`,n)),o&&this.fire(new t.l(`rollstart`,n)).fire(new t.l(`roll`,n)).fire(new t.l(`rollend`,n)),this.fire(new t.l(`moveend`,n))}calculateCameraOptionsFromTo(e,n,r,i=0){let a=t.aj.fromLngLat(e,n),o=t.aj.fromLngLat(r,i),s=o.x-a.x,c=o.y-a.y,l=o.z-a.z,u=Math.hypot(s,c,l);if(u===0)throw Error(`Can't calculate camera options with same From and To`);let d=Math.hypot(s,c),f=t.az(this.transform.cameraToCenterDistance/u/this.transform.tileSize),p=180*Math.atan2(s,-c)/Math.PI,m=180*Math.acos(d/u)/Math.PI;return m=l<0?90-m:90+m,{center:o.toLngLat(),elevation:i,zoom:f,pitch:m,bearing:p}}calculateCameraOptionsFromCameraLngLatAltRotation(e,t,n,r,i){let a=this.transform.calculateCenterFromCameraLngLatAlt(e,t,n,r);return{center:a.center,elevation:a.elevation,zoom:a.zoom,bearing:n,pitch:r,roll:i}}easeTo(e,n){this._stop(!1,e.easeId),(!1===(e=t.e({offset:[0,0],duration:500,easing:t.cp},e)).animate||!e.essential&&o.prefersReducedMotion)&&(e.duration=0);let r=this._getTransformForUpdate(),i=this.getBearing(),a=r.pitch,s=r.roll,c=`bearing`in e?this._normalizeBearing(e.bearing,i):i,l=`pitch`in e?+e.pitch:a,u=`roll`in e?this._normalizeBearing(e.roll,s):s,d=`padding`in e?e.padding:r.padding,f=t.P.convert(e.offset),p,m;e.around&&(p=t.aa.convert(e.around),m=r.locationToScreenPoint(p));let h={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},g=this.cameraHelper.handleEaseTo(r,{bearing:c,pitch:l,roll:u,padding:d,around:p,aroundPoint:m,offsetAsPoint:f,offset:e.offset,zoom:e.zoom,center:e.center});return this._rotating=this._rotating||i!==c,this._pitching=this._pitching||l!==a,this._rolling=this._rolling||u!==s,this._padding=!r.isPaddingEqual(d),this._zooming=this._zooming||g.isZooming,this._easeId=e.easeId,this._prepareEase(n,e.noMoveStart,h),this.terrain&&this._prepareElevation(g.elevationCenter),this._ease((t=>{g.easeFunc(t),this.terrain&&!e.freezeElevation&&this._updateElevation(t),this._applyUpdatedTransform(r),this._fireMoveEvents(n)}),(t=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(n,t)}),e),this}_prepareEase(e,n,r={}){this._moving=!0,n||r.moving||this.fire(new t.l(`movestart`,e)),this._zooming&&!r.zooming&&this.fire(new t.l(`zoomstart`,e)),this._rotating&&!r.rotating&&this.fire(new t.l(`rotatestart`,e)),this._pitching&&!r.pitching&&this.fire(new t.l(`pitchstart`,e)),this._rolling&&!r.rolling&&this.fire(new t.l(`rollstart`,e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(e){this._elevationStart!==void 0&&this._elevationCenter!==void 0||this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));let n=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&n!==this._elevationTarget){let t=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(t-(n-(t*e+this._elevationStart))/(1-e)),this._elevationTarget=n}this.transform.setElevation(t.C.number(this._elevationStart,this._elevationTarget,e))}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||=this.transform.clone(),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return{};let t=e.getCameraLngLat(),n=e.getCameraAltitude(),r=this.terrain?this.terrain.getElevationForLngLatZoom(t,e.zoom):0;if(n<r){let n=this.calculateCameraOptionsFromTo(t,r,e.center,e.elevation);return{pitch:n.pitch,zoom:n.zoom}}return{}}_applyUpdatedTransform(e){let t=[];if(t.push((e=>this._elevateCameraIfInsideTerrain(e))),this.transformCameraUpdate&&t.push((e=>this.transformCameraUpdate(e))),!t.length)return;let n=e.clone();for(let e of t){let t=n.clone(),{center:r,zoom:i,roll:a,pitch:o,bearing:s,elevation:c}=e(t);r&&t.setCenter(r),c!==void 0&&t.setElevation(c),i!==void 0&&t.setZoom(i),a!==void 0&&t.setRoll(a),o!==void 0&&t.setPitch(o),s!==void 0&&t.setBearing(s),n.apply(t)}this.transform.apply(n)}_fireMoveEvents(e){this.fire(new t.l(`move`,e)),this._zooming&&this.fire(new t.l(`zoom`,e)),this._rotating&&this.fire(new t.l(`rotate`,e)),this._pitching&&this.fire(new t.l(`pitch`,e)),this._rolling&&this.fire(new t.l(`roll`,e))}_afterEase(e,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId;let r=this._zooming,i=this._rotating,a=this._pitching,o=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,r&&this.fire(new t.l(`zoomend`,e)),i&&this.fire(new t.l(`rotateend`,e)),a&&this.fire(new t.l(`pitchend`,e)),o&&this.fire(new t.l(`rollend`,e)),this.fire(new t.l(`moveend`,e))}flyTo(e,n){if(!e.essential&&o.prefersReducedMotion){let r=t.a9(e,[`center`,`zoom`,`bearing`,`pitch`,`roll`,`elevation`]);return this.jumpTo(r,n)}this.stop(),e=t.e({offset:[0,0],speed:1.2,curve:1.42,easing:t.cp},e);let r=this._getTransformForUpdate(),i=r.bearing,a=r.pitch,s=r.roll,c=r.padding,l=`bearing`in e?this._normalizeBearing(e.bearing,i):i,u=`pitch`in e?+e.pitch:a,d=`roll`in e?this._normalizeBearing(e.roll,s):s,f=`padding`in e?e.padding:r.padding,p=t.P.convert(e.offset),m=r.centerPoint.add(p),h=r.screenPointToLocation(m),g=this.cameraHelper.handleFlyTo(r,{bearing:l,pitch:u,roll:d,padding:f,locationAtOffset:h,offsetAsPoint:p,center:e.center,minZoom:e.minZoom,zoom:e.zoom}),_=e.curve,v=Math.max(r.width,r.height),y=v/g.scaleOfZoom,b=g.pixelPathLength;typeof g.scaleOfMinZoom==`number`&&(_=Math.sqrt(v/g.scaleOfMinZoom/b*2));let x=_*_;function S(e){let t=(y*y-v*v+(e?-1:1)*x*x*b*b)/(2*(e?y:v)*x*b);return Math.log(Math.sqrt(t*t+1)-t)}function C(e){return(Math.exp(e)-Math.exp(-e))/2}function w(e){return(Math.exp(e)+Math.exp(-e))/2}let T=S(!1),E=function(e){return w(T)/w(T+_*e)},D=function(e){return v*((w(T)*(C(t=T+_*e)/w(t))-C(T))/x)/b;var t},O=(S(!0)-T)/_;if(Math.abs(b)<2e-6||!isFinite(O)){if(Math.abs(v-y)<1e-6)return this.easeTo(e,n);let t=y<v?-1:1;O=Math.abs(Math.log(y/v))/_,D=()=>0,E=e=>Math.exp(t*_*e)}return e.duration=`duration`in e?+e.duration:1e3*O/(`screenSpeed`in e?+e.screenSpeed/_:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=i!==l,this._pitching=u!==a,this._rolling=d!==s,this._padding=!r.isPaddingEqual(f),this._prepareEase(n,!1),this.terrain&&this._prepareElevation(g.targetCenter),this._ease((o=>{let h=o*O,_=1/E(h),v=D(h);this._rotating&&r.setBearing(t.C.number(i,l,o)),this._pitching&&r.setPitch(t.C.number(a,u,o)),this._rolling&&r.setRoll(t.C.number(s,d,o)),this._padding&&(r.interpolatePadding(c,f,o),m=r.centerPoint.add(p)),g.easeFunc(o,_,v,m),this.terrain&&!e.freezeElevation&&this._updateElevation(o),this._applyUpdatedTransform(r),this._fireMoveEvents(n)}),(()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(n)}),e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,t){var n;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){let e=this._onEaseEnd;delete this._onEaseEnd,e.call(this,t)}return e||(n=this.handlers)==null||n.stop(!1),this}_ease(e,t,n){!1===n.animate||n.duration===0?(e(1),t()):(this._easeStart=o.now(),this._easeOptions=n,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,n){e=t.aO(e,-180,180);let r=Math.abs(e-n);return Math.abs(e-360-n)<r&&(e-=360),Math.abs(e+360-n)<r&&(e+=360),e}queryTerrainElevation(e){return this.terrain?this.terrain.getElevationForLngLatZoom(t.aa.convert(e),this.transform.tileZoom):null}}let ka={compact:!0,customAttribution:void 0};class Aa{constructor(e=ka){this._toggleAttribution=()=>{this._container.classList.contains(`maplibregl-compact`)&&(this._container.classList.contains(`maplibregl-compact-show`)?(this._container.setAttribute(`open`,``),this._container.classList.remove(`maplibregl-compact-show`),this._updateAttributions()):(this._container.classList.add(`maplibregl-compact-show`),this._container.removeAttribute(`open`)))},this._updateData=e=>{!e||e.sourceDataType!==`metadata`&&e.sourceDataType!==`visibility`&&e.dataType!==`style`&&e.type!==`terrain`||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute(`open`,``):this._container.classList.contains(`maplibregl-compact`)||this._container.classList.contains(`maplibregl-attrib-empty`)||(this._container.setAttribute(`open`,``),this._container.classList.add(`maplibregl-compact`,`maplibregl-compact-show`)):(this._container.setAttribute(`open`,``),this._container.classList.contains(`maplibregl-compact`)&&this._container.classList.remove(`maplibregl-compact`,`maplibregl-compact-show`))},this._updateCompactMinimize=()=>{this._container.classList.contains(`maplibregl-compact`)&&this._container.classList.contains(`maplibregl-compact-show`)&&this._container.classList.remove(`maplibregl-compact-show`),this._updateAttributions()},this._extendAttribution=e=>{e.preventDefault(),this._extended=!0,this._updateAttributions()},this._shrinkAttribution=e=>{e.preventDefault(),this._extended=!1,this._updateAttributions()},this.options=e}getDefaultPosition(){return`bottom-right`}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=s.create(`details`,`maplibregl-ctrl maplibregl-ctrl-attrib`),this._compactButton=s.create(`summary`,`maplibregl-ctrl-attrib-button`,this._container),this._compactButton.addEventListener(`click`,this._toggleAttribution),this._extendButton=s.create(`a`,`maplibregl-attrib-others`),this._extendButton.setAttribute(`href`,`#`),this._extendButton.addEventListener(`click`,this._extendAttribution),this._extendButton.innerHTML=`| Show more`,this._shrinkButton=s.create(`a`,`maplibregl-attrib-others`),this._shrinkButton.setAttribute(`href`,`#`),this._shrinkButton.addEventListener(`click`,this._shrinkAttribution),this._shrinkButton.innerHTML=`| Show less`,this._setElementTitle(this._compactButton,`ToggleAttribution`),this._innerContainer=s.create(`div`,`maplibregl-ctrl-attrib-inner`,this._container),this._updateAttributions(),this._updateCompact(),this._map.on(`styledata`,this._updateData),this._map.on(`sourcedata`,this._updateData),this._map.on(`terrain`,this._updateData),this._map.on(`resize`,this._updateCompact),this._map.on(`drag`,this._updateCompactMinimize),this._container}onRemove(){s.remove(this._container),this._map.off(`styledata`,this._updateData),this._map.off(`sourcedata`,this._updateData),this._map.off(`terrain`,this._updateData),this._map.off(`resize`,this._updateCompact),this._map.off(`drag`,this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._extended=void 0,this._extendButton=void 0,this._shrinkButton=void 0,this._fullAttribHTML=void 0,this._displayedAttribHTML=void 0}_setElementTitle(e,t){let n=this._map._getUIString(`AttributionControl.${t}`);e.title=n,e.setAttribute(`aria-label`,n)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map((e=>typeof e==`string`?e:``))):typeof this.options.customAttribution==`string`&&e.push(this.options.customAttribution)),this._map.style.stylesheet){let e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}let t=this._map.style.sourceCaches;for(let n in t){let r=t[n];if(r.used||r.usedForTerrain){let t=r.getSource();if(typeof t.attribution==`string`){let n=t.attribution.split(`|`).map((e=>e.trim()));for(let t of n)e.indexOf(t)<0&&e.push(t)}}}let n=`<a href="https://mapcreator.io" target="_blank">&copy; Mapcreator</a>`;e.indexOf(n)<0&&e.push(n),e=e.filter((e=>String(e).trim())),e.sort(((e,t)=>e.length-t.length)),e=e.filter(((t,n)=>{for(let r=n+1;r<e.length;r++)if(e[r].indexOf(t)>=0)return!1;return!0}));for(let t of[`OpenStreetMap`,`Mapcreator`]){let n=e.findIndex((e=>e.includes(t)));if(n!==-1&&n!==0){let t=e[n];e.splice(n,1),e.unshift(t)}}let r=e.join(` `),i;i=e.length<=2||this._extended?r:e.slice(0,2).join(` `),r===this._fullAttribHTML&&i===this._displayedAttribHTML||(this._fullAttribHTML=r,this._displayedAttribHTML=i,e.length?(this._innerContainer.innerHTML=s.sanitize(i),e.length>2&&(this._innerContainer.innerHTML+=`&nbsp;`,this._innerContainer.appendChild(this._extended?this._shrinkButton:this._extendButton)),this._container.classList.remove(`maplibregl-attrib-empty`)):this._container.classList.add(`maplibregl-attrib-empty`),this._updateCompact(),this._map.fire(`attributionchange`),this._editLink=null)}}class ja{constructor(e={}){this._updateCompact=()=>{let e=this._container.children;if(e.length){let t=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&t.classList.add(`maplibregl-compact`):t.classList.remove(`maplibregl-compact`)}},this.options=e}getDefaultPosition(){return`bottom-left`}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=s.create(`div`,`maplibregl-ctrl`);let t=s.create(`a`,`maplibregl-ctrl-logo`);return t.target=`_blank`,t.rel=`noopener nofollow`,t.href=`https://maplibre.org/`,t.setAttribute(`aria-label`,this._map._getUIString(`LogoControl.Title`)),t.setAttribute(`rel`,`noopener nofollow`),this._container.appendChild(t),this._container.style.display=`block`,this._map.on(`resize`,this._updateCompact),this._updateCompact(),this._container}onRemove(){s.remove(this._container),this._map.off(`resize`,this._updateCompact),this._map=void 0,this._compact=void 0}}class Ma{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){let t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){let t=this._currentlyRunning,n=t?this._queue.concat(t):this._queue;for(let t of n)if(t.id===e)return void(t.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw Error(`Attempting to run(), but is already running.`);let t=this._currentlyRunning=this._queue;this._queue=[];for(let n of t)if(!n.cancelled&&(n.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Na=t.aJ([{name:`a_pos3d`,type:`Int16`,components:3}]);class Pa extends t.E{constructor(e){super(),this._lastTilesetChange=o.now(),this.sourceCache=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(e,n){this.sourceCache.update(e,n),this._renderableTilesKeys=[];let r={};for(let i of it(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n,calculateTileZoom:this.sourceCache._source.calculateTileZoom}))r[i.key]=!0,this._renderableTilesKeys.push(i.key),this._tiles[i.key]||(i.terrainRttPosMatrix32f=new Float64Array(16),t.bZ(i.terrainRttPosMatrix32f,0,t.ah,t.ah,0,0,1),this._tiles[i.key]=new Je(i,this.tileSize),this._lastTilesetChange=o.now());for(let e in this._tiles)r[e]||delete this._tiles[e]}freeRtt(e){for(let t in this._tiles){let n=this._tiles[t];(!e||n.tileID.equals(e)||n.tileID.isChildOf(e)||e.isChildOf(n.tileID))&&(n.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map((e=>this.getTileByID(e)))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,t){return t?this._getTerrainCoordsForTileRanges(e,t):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){let n={};for(let r of this._renderableTilesKeys){let i=this._tiles[r].tileID,a=e.clone(),o=t.ba();if(i.canonical.equals(e.canonical))t.bZ(o,0,t.ah,t.ah,0,0,1);else if(i.canonical.isChildOf(e.canonical)){let n=i.canonical.z-e.canonical.z,r=i.canonical.x-(i.canonical.x>>n<<n),a=i.canonical.y-(i.canonical.y>>n<<n),s=t.ah>>n;t.bZ(o,0,s,s,0,0,1),t.a5(o,o,[-r*s,-a*s,0])}else{if(!e.canonical.isChildOf(i.canonical))continue;{let n=e.canonical.z-i.canonical.z,r=e.canonical.x-(e.canonical.x>>n<<n),a=e.canonical.y-(e.canonical.y>>n<<n),s=t.ah>>n;t.bZ(o,0,t.ah,t.ah,0,0,1),t.a5(o,o,[r*s,a*s,0]),t.N(o,o,[1/2**n,1/2**n,0])}}a.terrainRttPosMatrix32f=new Float32Array(o),n[r]=a}return n}_getTerrainCoordsForTileRanges(e,n){let r={};for(let i of this._renderableTilesKeys){let a=this._tiles[i].tileID;if(!this._isWithinTileRanges(a,n))continue;let o=e.clone(),s=t.ba();if(a.canonical.z===e.canonical.z){let n=e.canonical.x-a.canonical.x,r=e.canonical.y-a.canonical.y;t.bZ(s,0,t.ah,t.ah,0,0,1),t.a5(s,s,[n*t.ah,r*t.ah,0])}else if(a.canonical.z>e.canonical.z){let n=a.canonical.z-e.canonical.z,r=a.canonical.x-(a.canonical.x>>n<<n),i=a.canonical.y-(a.canonical.y>>n<<n),o=e.canonical.x-(a.canonical.x>>n),c=e.canonical.y-(a.canonical.y>>n),l=t.ah>>n;t.bZ(s,0,l,l,0,0,1),t.a5(s,s,[-r*l+o*t.ah,-i*l+c*t.ah,0])}else{let n=e.canonical.z-a.canonical.z,r=e.canonical.x-(e.canonical.x>>n<<n),i=e.canonical.y-(e.canonical.y>>n<<n),o=(e.canonical.x>>n)-a.canonical.x,c=(e.canonical.y>>n)-a.canonical.y,l=t.ah<<n;t.bZ(s,0,l,l,0,0,1),t.a5(s,s,[r*t.ah+o*l,i*t.ah+c*l,0])}o.terrainRttPosMatrix32f=new Float32Array(s),r[i]=o}return r}getSourceTile(e,t){let n=this.sourceCache._source,r=e.overscaledZ-this.deltaZoom;if(r>n.maxzoom&&(r=n.maxzoom),r<n.minzoom)return null;this._sourceTileCache[e.key]||(this._sourceTileCache[e.key]=e.scaledTo(r).key);let i=this.sourceCache.getTileByID(this._sourceTileCache[e.key]);if((!i||!i.dem)&&t)for(;r>=n.minzoom&&(!i||!i.dem);)i=this.sourceCache.getTileByID(e.scaledTo(r--).key);return i}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,t){return t[e.canonical.z]&&e.canonical.x>=t[e.canonical.z].minTileX&&e.canonical.x<=t[e.canonical.z].maxTileX&&e.canonical.y>=t[e.canonical.z].minTileY&&e.canonical.y<=t[e.canonical.z].maxTileY}}class Q{constructor(e,t,n){this._meshCache={},this.painter=e,this.sourceCache=new Pa(t),this.options=n,this.exaggeration=typeof n.exaggeration==`number`?n.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(e,n,r,i=t.ah){if(!(n>=0&&n<i&&r>=0&&r<i))return 0;let a=this.getTerrainData(e),o=a.tile?.dem;if(!o)return 0;let s=t.ct([],[n/i*t.ah,r/i*t.ah],a.u_terrain_matrix),c=[s[0]*o.dim,s[1]*o.dim],l=Math.floor(c[0]),u=Math.floor(c[1]),d=c[0]-l,f=c[1]-u;return o.get(l,u)*(1-d)*(1-f)+o.get(l+1,u)*d*(1-f)+o.get(l,u+1)*(1-d)*f+o.get(l+1,u+1)*d*f}getElevationForLngLatZoom(e,n){if(!t.cu(n,e.wrap()))return 0;let{tileID:r,mercatorX:i,mercatorY:a}=this._getOverscaledTileIDFromLngLatZoom(e,n);return this.getElevation(r,i%t.ah,a%t.ah,t.ah)}getElevation(e,n,r,i=t.ah){return this.getDEMElevation(e,n,r,i)*this.exaggeration}getTerrainData(e){if(!this._emptyDemTexture){let e=this.painter.context,n=new t.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new t.T(e,n,e.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new t.T(e,new t.R({width:1,height:1}),e.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=t.a4([])}let n=this.sourceCache.getSourceTile(e,!0);if(n&&n.dem&&(!n.demTexture||n.needsTerrainPrepare)){let e=this.painter.context;n.demTexture=this.painter.getTileTexture(n.dem.stride),n.demTexture?n.demTexture.update(n.dem.getPixels(),{premultiply:!1}):n.demTexture=new t.T(e,n.dem.getPixels(),e.gl.RGBA,{premultiply:!1}),n.demTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),n.needsTerrainPrepare=!1}let r=n&&n+n.tileID.key+e.key;if(r&&!this._demMatrixCache[r]){let r=this.sourceCache.sourceCache._source.maxzoom,i=e.canonical.z-n.tileID.canonical.z;e.overscaledZ>e.canonical.z&&(e.canonical.z>=r?i=e.canonical.z-r:t.w(`cannot calculate elevation if elevation maxzoom > source.maxzoom`));let a=e.canonical.x-(e.canonical.x>>i<<i),o=e.canonical.y-(e.canonical.y>>i<<i),s=t.cv(new Float64Array(16),[1/(t.ah<<i),1/(t.ah<<i),0]);t.a5(s,s,[a*t.ah,o*t.ah,0]),this._demMatrixCache[e.key]={matrix:s,coord:e}}return{u_depth:2,u_terrain:3,u_terrain_dim:n&&n.dem&&n.dem.dim||1,u_terrain_matrix:r?this._demMatrixCache[e.key].matrix:this._emptyDemMatrix,u_terrain_unpack:n&&n.dem&&n.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(n&&n.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:n}}getFramebuffer(e){let n=this.painter,r=n.width/devicePixelRatio,i=n.height/devicePixelRatio;return!this._fbo||this._fbo.width===r&&this._fbo.height===i||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new t.T(n.context,{width:r,height:i,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new t.T(n.context,{width:r,height:i,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=n.context.createFramebuffer(r,i,!0,!1),this._fbo.depthAttachment.set(n.context.createRenderbuffer(n.context.gl.DEPTH_COMPONENT16,r,i))),this._fbo.colorAttachment.set(e===`coords`?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){let e=this.painter.context;if(this._coordsTexture)return this._coordsTexture;let n=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let e=0,t=0;e<this._coordsTextureSize;e++)for(let r=0;r<this._coordsTextureSize;r++,t+=4)n[t+0]=255&r,n[t+1]=255&e,n[t+2]=r>>8<<4|e>>8,n[t+3]=0;let r=new t.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(n.buffer)),i=new t.T(e,r,e.gl.RGBA,{premultiply:!1});return i.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=i,i}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);let n=new Uint8Array(4),r=this.painter.context,i=r.gl,a=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),o=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),s=Math.round(this.painter.height/devicePixelRatio);r.bindFramebuffer.set(this.getFramebuffer(`coords`).framebuffer),i.readPixels(a,s-o-1,1,1,i.RGBA,i.UNSIGNED_BYTE,n),r.bindFramebuffer.set(null);let c=n[0]+(n[2]>>4<<8),l=n[1]+((15&n[2])<<8),u=this.coordsIndex[255-n[3]],d=u&&this.sourceCache.getTileByID(u);if(!d)return null;let f=this._coordsTextureSize,p=(1<<d.tileID.canonical.z)*f;return new t.aj((d.tileID.canonical.x*f+c)/p+d.tileID.wrap,(d.tileID.canonical.y*f+l)/p,this.getElevation(d.tileID,c,l,f))}depthAtPoint(e){let t=new Uint8Array(4),n=this.painter.context,r=n.gl;return n.bindFramebuffer.set(this.getFramebuffer(`depth`).framebuffer),r.readPixels(e.x,this.painter.height/devicePixelRatio-e.y-1,1,1,r.RGBA,r.UNSIGNED_BYTE,t),n.bindFramebuffer.set(null),(t[0]/16777216+t[1]/65536+t[2]/256+t[3])/256}getTerrainMesh(e){let n=this.painter.style.projection?.transitionState>0,r=n&&e.canonical.y===0,i=n&&e.canonical.y===(1<<e.canonical.z)-1,a=`m_${r?`n`:``}_${i?`s`:``}`;if(this._meshCache[a])return this._meshCache[a];let o=this.painter.context,s=new t.cw,c=new t.aN,l=this.meshSize,u=t.ah/l,d=l*l;for(let e=0;e<=l;e++)for(let t=0;t<=l;t++)s.emplaceBack(t*u,e*u,0);for(let e=0;e<d;e+=l+1)for(let t=0;t<l;t++)c.emplaceBack(t+e,l+t+e+1,l+t+e+2),c.emplaceBack(t+e,l+t+e+2,t+e+1);let f=s.length,p=f+(l+1),m=(l+1)*l,h=r?t.bh:0,g=r?0:1,_=i?t.bi:t.ah,v=i?0:1;for(let e=0;e<=l;e++)s.emplaceBack(e*u,h,g);for(let e=0;e<=l;e++)s.emplaceBack(e*u,_,v);for(let e=0;e<l;e++)c.emplaceBack(m+e,p+e,p+e+1),c.emplaceBack(m+e,p+e+1,m+e+1),c.emplaceBack(0+e,f+e+1,f+e),c.emplaceBack(0+e,0+e+1,f+e+1);let y=s.length,b=y+2*(l+1);for(let e of[0,1])for(let n=0;n<=l;n++)for(let r of[0,1])s.emplaceBack(e*t.ah,n*u,r);for(let e=0;e<2*l;e+=2)c.emplaceBack(y+e,y+e+1,y+e+3),c.emplaceBack(y+e,y+e+3,y+e+2),c.emplaceBack(b+e,b+e+3,b+e+1),c.emplaceBack(b+e,b+e+2,b+e+3);let x=new Mt(o.createVertexBuffer(s,Na.members),o.createIndexBuffer(c),t.aM.simpleSegment(0,0,s.length,c.length));return this._meshCache[a]=x,x}getMeshFrameDelta(e){return 2*Math.PI*t.bu/2**Math.max(e,0)/5}getMinTileElevationForLngLatZoom(e,n){if(!t.cu(n,e.wrap()))return 0;let{tileID:r}=this._getOverscaledTileIDFromLngLatZoom(e,n);return this.getMinMaxElevation(r).minElevation??0}getMinMaxElevation(e){let t=this.getTerrainData(e).tile,n={minElevation:null,maxElevation:null};return t&&t.dem&&(n.minElevation=t.dem.min*this.exaggeration,n.maxElevation=t.dem.max*this.exaggeration),n}_getOverscaledTileIDFromLngLatZoom(e,n){let r=t.aj.fromLngLat(e.wrap()),i=(1<<n)*t.ah,a=r.x*i,o=r.y*i,s=Math.floor(a/t.ah),c=Math.floor(o/t.ah);return{tileID:new t.ag(n,0,n,s,c),mercatorX:a,mercatorY:o}}}class ${constructor(e,t,n){this._context=e,this._size=t,this._tileSize=n,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(let e of this._objects)e.texture.destroy(),e.fbo.destroy()}_createObject(e){let n=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),r=new t.T(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return r.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),this._context.extTextureFilterAnisotropic&&this._context.gl.texParameterf(this._context.gl.TEXTURE_2D,this._context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this._context.extTextureFilterAnisotropicMax),n.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),n.colorAttachment.set(r.texture),{id:e,fbo:n,texture:r,stamp:-1,inUse:!1}}getObjectForId(e){return this._objects[e]}useObject(e){e.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter((t=>e.id!==t)),this._recentlyUsed.push(e.id)}stampObject(e){e.stamp=++this._stamp}getOrCreateFreeObject(){for(let e of this._recentlyUsed)if(!this._objects[e].inUse)return this._objects[e];if(this._objects.length>=this._size)throw Error(`No free RenderPool available, call freeAllObjects() required!`);let e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1}freeAllObjects(){for(let e of this._objects)this.freeObject(e)}isFull(){return!(this._objects.length<this._size)&&!1===this._objects.some((e=>!e.inUse))}}let Fa={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class Ia{constructor(e,t){this.painter=e,this.terrain=t,this.pool=new $(e.context,30,t.sourceCache.tileSize*t.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,t){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=e._order.filter((n=>!e._layers[n].isHidden(t))),this._coordsAscending={};for(let t in e.sourceCaches){this._coordsAscending[t]={};let n=e.sourceCaches[t].getVisibleCoordinates(),r=e.sourceCaches[t].getSource(),i=r instanceof Be?r.terrainTileRanges:null;for(let e of n){let n=this.terrain.sourceCache.getTerrainCoords(e,i);for(let e in n)this._coordsAscending[t][e]||(this._coordsAscending[t][e]=[]),this._coordsAscending[t][e].push(n[e])}}this._coordsAscendingStr={};for(let t of e._order){let n=e._layers[t],r=n.source;if(Fa[n.type]&&!this._coordsAscendingStr[r]){this._coordsAscendingStr[r]={};for(let e in this._coordsAscending[r])this._coordsAscendingStr[r][e]=this._coordsAscending[r][e].map((e=>e.key)).sort().join()}}for(let e of this._renderableTiles)for(let t in this._coordsAscendingStr){let n=this._coordsAscendingStr[t][e.tileID.key];n&&n!==e.rttCoords[t]&&(e.rtt=[])}}renderLayer(e,n){if(e.isHidden(this.painter.transform.zoom))return!1;let r=Object.assign(Object.assign({},n),{isRenderingToTexture:!0}),i=e.type,a=this.painter,o=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(Fa[i]&&(this._prevType&&Fa[this._prevType]||this._stacks.push([]),this._prevType=i,this._stacks[this._stacks.length-1].push(e.id),!o))return!0;if(Fa[this._prevType]||Fa[i]&&o){this._prevType=i;let e=this._stacks.length-1,n=this._stacks[e]||[];for(let i of this._renderableTiles){if(this.pool.isFull()&&(ki(this.painter,this.terrain,this._rttTiles,r),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(i),i.rtt[e]){let t=this.pool.getObjectForId(i.rtt[e].id);if(t.stamp===i.rtt[e].stamp){this.pool.useObject(t);continue}}let o=this.pool.getOrCreateFreeObject();this.pool.useObject(o),this.pool.stampObject(o),i.rtt[e]={id:o.id,stamp:o.stamp},a.context.bindFramebuffer.set(o.fbo.framebuffer),a.context.clear({color:t.bf.transparent,stencil:0}),a.currentStencilSource=void 0;for(let e=0;e<n.length;e++){let t=a.style._layers[n[e]],s=t.source?this._coordsAscending[t.source][i.tileID.key]:[i.tileID];a.context.viewport.set([0,0,o.fbo.width,o.fbo.height]),a._renderTileClippingMasks(t,s,!0),a.renderLayer(a,a.style.sourceCaches[t.source],t,s,r),t.source&&(i.rttCoords[t.source]=this._coordsAscendingStr[t.source][i.tileID.key])}}return ki(this.painter,this.terrain,this._rttTiles,r),this._rttTiles=[],this.pool.freeAllObjects(),Fa[i]}return!1}}let La={"AttributionControl.ToggleAttribution":`Toggle attribution`,"AttributionControl.MapFeedback":`Map feedback`,"FullscreenControl.Enter":`Enter fullscreen`,"FullscreenControl.Exit":`Exit fullscreen`,"GeolocateControl.FindMyLocation":`Find my location`,"GeolocateControl.LocationNotAvailable":`Location not available`,"LogoControl.Title":`MapLibre logo`,"Map.Title":`Map`,"Marker.Title":`Map marker`,"NavigationControl.ResetBearing":`Reset bearing to north`,"NavigationControl.ZoomIn":`Zoom in`,"NavigationControl.ZoomOut":`Zoom out`,"Popup.Close":`Close popup`,"ScaleControl.Feet":`ft`,"ScaleControl.Meters":`m`,"ScaleControl.Kilometers":`km`,"ScaleControl.Miles":`mi`,"ScaleControl.NauticalMiles":`nm`,"GlobeControl.Enable":`Enable globe`,"GlobeControl.Disable":`Disable globe`,"TerrainControl.Enable":`Enable terrain`,"TerrainControl.Disable":`Disable terrain`,"CooperativeGesturesHandler.WindowsHelpText":`Use Ctrl + scroll to zoom the map`,"CooperativeGesturesHandler.MacHelpText":`Use ⌘ + scroll to zoom the map`,"CooperativeGesturesHandler.MobileHelpText":`Use two fingers to move the map`},Ra=n,za={hash:!1,interactive:!0,bearingSnap:7,attributionControl:ka,maplibreLogo:!1,refreshExpiredTiles:!0,canvasContextAttributes:{antialias:!1,preserveDrawingBuffer:!1,powerPreference:`high-performance`,failIfMajorPerformanceCaveat:!1,desynchronized:!1,contextType:void 0},scrollZoom:!0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,trackResize:!0,center:[0,0],elevation:0,zoom:0,bearing:0,pitch:0,roll:0,renderWorldCopies:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:t.a.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:`sans-serif`,pitchWithRotate:!0,rollEnabled:!1,validateStyle:!0,maxCanvasSize:[4096,4096],scale:1,cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0},Ba={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};class Va{constructor(e,n,r=!1){this.mousedown=e=>{this.startMove(e,s.mousePos(this.element,e,this.map.getScale())),s.addEventListener(window,`mousemove`,this.mousemove),s.addEventListener(window,`mouseup`,this.mouseup)},this.mousemove=e=>{this.move(e,s.mousePos(this.element,e,this.map.getScale()))},this.mouseup=e=>{this._rotatePitchHandler.dragEnd(e),this.offTemp()},this.touchstart=e=>{e.targetTouches.length===1?(this._startPos=this._lastPos=s.touchPos(this.element,e.targetTouches,this.map.getScale())[0],this.startMove(e,this._startPos),s.addEventListener(window,`touchmove`,this.touchmove,{passive:!1}),s.addEventListener(window,`touchend`,this.touchend)):this.reset()},this.touchmove=e=>{e.targetTouches.length===1?(this._lastPos=s.touchPos(this.element,e.targetTouches,this.map.getScale())[0],this.move(e,this._lastPos)):this.reset()},this.touchend=e=>{e.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),delete this._startPos,delete this._lastPos,this.offTemp()},this.reset=()=>{this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=n,this._rotatePitchHandler=new ea({clickTolerance:3,move:(e,i)=>{let a=n.getBoundingClientRect(),o=new t.P((a.bottom-a.top)/2,(a.right-a.left)/2);return{bearingDelta:t.co(new t.P(e.x,i.y),i,o),pitchDelta:r?-.5*(i.y-e.y):void 0}},moveStateManager:new ia,enable:!0,assignEvents:()=>{}}),this.map=e,s.addEventListener(n,`mousedown`,this.mousedown),s.addEventListener(n,`touchstart`,this.touchstart,{passive:!1}),s.addEventListener(n,`touchcancel`,this.reset)}startMove(e,t){this._rotatePitchHandler.dragStart(e,t),s.disableDrag()}move(e,t){let n=this.map,{bearingDelta:r,pitchDelta:i}=this._rotatePitchHandler.dragMove(e,t)||{};r&&n.setBearing(n.getBearing()+r),i&&n.setPitch(n.getPitch()+i)}off(){let e=this.element;s.removeEventListener(e,`mousedown`,this.mousedown),s.removeEventListener(e,`touchstart`,this.touchstart,{passive:!1}),s.removeEventListener(window,`touchmove`,this.touchmove,{passive:!1}),s.removeEventListener(window,`touchend`,this.touchend),s.removeEventListener(e,`touchcancel`,this.reset),this.offTemp()}offTemp(){s.enableDrag(),s.removeEventListener(window,`mousemove`,this.mousemove),s.removeEventListener(window,`mouseup`,this.mouseup),s.removeEventListener(window,`touchmove`,this.touchmove,{passive:!1}),s.removeEventListener(window,`touchend`,this.touchend)}}let Ha;function Ua(e,n,r,i=!1){if(i||!r.getCoveringTilesDetailsProvider().allowWorldCopies())return e?.wrap();let a=new t.aa(e.lng,e.lat);if(e=new t.aa(e.lng,e.lat),n){let i=new t.aa(e.lng-360,e.lat),a=new t.aa(e.lng+360,e.lat),o=r.locationToScreenPoint(e).distSqr(n);r.locationToScreenPoint(i).distSqr(n)<o?e=i:r.locationToScreenPoint(a).distSqr(n)<o&&(e=a)}for(;Math.abs(e.lng-r.center.lng)>180;){let t=r.locationToScreenPoint(e);if(t.x>=0&&t.y>=0&&t.x<=r.width&&t.y<=r.height)break;e.lng>r.center.lng?e.lng-=360:e.lng+=360}return e.lng!==a.lng&&r.isPointOnMapSurface(r.locationToScreenPoint(e))?e:a}let Wa={center:`translate(-50%,-50%)`,top:`translate(-50%,0)`,"top-left":`translate(0,0)`,"top-right":`translate(-100%,0)`,bottom:`translate(-50%,-100%)`,"bottom-left":`translate(0,-100%)`,"bottom-right":`translate(-100%,-100%)`,left:`translate(0,-50%)`,right:`translate(-100%,-50%)`};function Ga(e,t,n){let r=e.classList;for(let e in Wa)r.remove(`maplibregl-${n}-anchor-${e}`);r.add(`maplibregl-${n}-anchor-${t}`)}class Ka extends t.E{constructor(e){if(super(),this._onKeyPress=e=>{let t=e.code,n=e.charCode||e.keyCode;t!==`Space`&&t!==`Enter`&&n!==32&&n!==13||this.togglePopup()},this._onMapClick=e=>{let t=e.originalEvent.target,n=this._element;this._popup&&(t===n||n.contains(t))&&this.togglePopup()},this._update=e=>{if(!this._map)return;let t=this._map.loaded()&&!this._map.isMoving();(e?.type===`terrain`||e?.type===`render`&&!t)&&this._map.once(`render`,this._update),this._lngLat=Ua(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let n=``;this._rotationAlignment===`viewport`||this._rotationAlignment===`auto`?n=`rotateZ(${this._rotation}deg)`:this._rotationAlignment===`map`&&(n=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let r=``;this._pitchAlignment===`viewport`||this._pitchAlignment===`auto`?r=`rotateX(0deg)`:this._pitchAlignment===`map`&&(r=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||e&&e.type!==`moveend`||(this._pos=this._pos.round()),s.setTransform(this._element,`${Wa[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${r} ${n}`),o.frameAsync(new AbortController).then((()=>{this._updateOpacity(e&&e.type===`moveend`)})).catch((()=>{}))},this._onMove=e=>{if(!this._isDragging){let t=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=t}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents=`none`,this._state===`pending`&&(this._state=`active`,this.fire(new t.l(`dragstart`))),this.fire(new t.l(`drag`)))},this._onUp=()=>{this._element.style.pointerEvents=`auto`,this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off(`mousemove`,this._onMove),this._map.off(`touchmove`,this._onMove),this._state===`active`&&this.fire(new t.l(`dragend`)),this._state=`inactive`},this._addDragHandler=e=>{this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos).add(this._offset),this._pointerdownPos=e.point,this._state=`pending`,this._map.on(`mousemove`,this._onMove),this._map.on(`touchmove`,this._onMove),this._map.once(`mouseup`,this._onUp),this._map.once(`touchend`,this._onUp))},this._anchor=e&&e.anchor||`center`,this._color=e&&e.color||`#3FB1CE`,this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._subpixelPositioning=e&&e.subpixelPositioning||!1,this._isDragging=!1,this._state=`inactive`,this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||`auto`,this._pitchAlignment=e&&e.pitchAlignment&&e.pitchAlignment!==`auto`?e.pitchAlignment:this._rotationAlignment,this.setOpacity(e?.opacity,e?.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=t.P.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=s.create(`div`);let n=s.createNS(`http://www.w3.org/2000/svg`,`svg`);n.setAttributeNS(null,`display`,`block`),n.setAttributeNS(null,`height`,`41px`),n.setAttributeNS(null,`width`,`27px`),n.setAttributeNS(null,`viewBox`,`0 0 27 41`);let r=s.createNS(`http://www.w3.org/2000/svg`,`g`);r.setAttributeNS(null,`stroke`,`none`),r.setAttributeNS(null,`stroke-width`,`1`),r.setAttributeNS(null,`fill`,`none`),r.setAttributeNS(null,`fill-rule`,`evenodd`);let i=s.createNS(`http://www.w3.org/2000/svg`,`g`);i.setAttributeNS(null,`fill-rule`,`nonzero`);let a=s.createNS(`http://www.w3.org/2000/svg`,`g`);a.setAttributeNS(null,`transform`,`translate(3.0, 29.0)`),a.setAttributeNS(null,`fill`,`#000000`);for(let e of[{rx:`10.5`,ry:`5.25002273`},{rx:`10.5`,ry:`5.25002273`},{rx:`9.5`,ry:`4.77275007`},{rx:`8.5`,ry:`4.29549936`},{rx:`7.5`,ry:`3.81822308`},{rx:`6.5`,ry:`3.34094679`},{rx:`5.5`,ry:`2.86367051`},{rx:`4.5`,ry:`2.38636864`}]){let t=s.createNS(`http://www.w3.org/2000/svg`,`ellipse`);t.setAttributeNS(null,`opacity`,`0.04`),t.setAttributeNS(null,`cx`,`10.5`),t.setAttributeNS(null,`cy`,`5.80029008`),t.setAttributeNS(null,`rx`,e.rx),t.setAttributeNS(null,`ry`,e.ry),a.appendChild(t)}let o=s.createNS(`http://www.w3.org/2000/svg`,`g`);o.setAttributeNS(null,`fill`,this._color);let c=s.createNS(`http://www.w3.org/2000/svg`,`path`);c.setAttributeNS(null,`d`,`M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z`),o.appendChild(c);let l=s.createNS(`http://www.w3.org/2000/svg`,`g`);l.setAttributeNS(null,`opacity`,`0.25`),l.setAttributeNS(null,`fill`,`#000000`);let u=s.createNS(`http://www.w3.org/2000/svg`,`path`);u.setAttributeNS(null,`d`,`M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z`),l.appendChild(u);let d=s.createNS(`http://www.w3.org/2000/svg`,`g`);d.setAttributeNS(null,`transform`,`translate(6.0, 7.0)`),d.setAttributeNS(null,`fill`,`#FFFFFF`);let f=s.createNS(`http://www.w3.org/2000/svg`,`g`);f.setAttributeNS(null,`transform`,`translate(8.0, 8.0)`);let p=s.createNS(`http://www.w3.org/2000/svg`,`circle`);p.setAttributeNS(null,`fill`,`#000000`),p.setAttributeNS(null,`opacity`,`0.25`),p.setAttributeNS(null,`cx`,`5.5`),p.setAttributeNS(null,`cy`,`5.5`),p.setAttributeNS(null,`r`,`5.4999962`);let m=s.createNS(`http://www.w3.org/2000/svg`,`circle`);m.setAttributeNS(null,`fill`,`#FFFFFF`),m.setAttributeNS(null,`cx`,`5.5`),m.setAttributeNS(null,`cy`,`5.5`),m.setAttributeNS(null,`r`,`5.4999962`),f.appendChild(p),f.appendChild(m),i.appendChild(a),i.appendChild(o),i.appendChild(l),i.appendChild(d),i.appendChild(f),n.appendChild(i),n.setAttributeNS(null,`height`,41*this._scale+`px`),n.setAttributeNS(null,`width`,27*this._scale+`px`),this._element.appendChild(n),this._offset=t.P.convert(e&&e.offset||[0,-14])}if(this._element.classList.add(`maplibregl-marker`),this._element.addEventListener(`dragstart`,(e=>{e.preventDefault()})),this._element.addEventListener(`mousedown`,(e=>{e.preventDefault()})),Ga(this._element,this._anchor,`marker`),e&&e.className)for(let t of e.className.split(` `))this._element.classList.add(t);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.hasAttribute(`aria-label`)||this._element.setAttribute(`aria-label`,e._getUIString(`Marker.Title`)),e.getCanvasContainer().appendChild(this._element),e.on(`move`,this._update),e.on(`moveend`,this._update),e.on(`terrain`,this._update),e.on(`projectiontransition`,this._update),this.setDraggable(this._draggable),this._update(),this._map.on(`click`,this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off(`click`,this._onMapClick),this._map.off(`move`,this._update),this._map.off(`moveend`,this._update),this._map.off(`terrain`,this._update),this._map.off(`projectiontransition`,this._update),this._map.off(`mousedown`,this._addDragHandler),this._map.off(`touchstart`,this._addDragHandler),this._map.off(`mouseup`,this._onUp),this._map.off(`touchend`,this._onUp),this._map.off(`mousemove`,this._onMove),this._map.off(`touchmove`,this._onMove),delete this._map),s.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.aa.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener(`keypress`,this._onKeyPress),this._originalTabIndex||this._element.removeAttribute(`tabindex`)),e){if(!(`offset`in e.options)){let t=38.1,n=13.5,r=13.5/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[r,-1*(t-n+r)],"bottom-right":[-r,-1*(t-n+r)],left:[n,-1*(t-n)],right:[-n,-1*(t-n)]}:this._offset}this._popup=e,this._originalTabIndex=this._element.getAttribute(`tabindex`),this._originalTabIndex||this._element.setAttribute(`tabindex`,`0`),this._element.addEventListener(`keypress`,this._onKeyPress)}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){let e=this._popup;return this._element.style.opacity===this._opacityWhenCovered||e&&(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map))),this}_updateOpacity(e=!1){var n;let r=this._map?.terrain,i=this._map.transform.isLocationOccluded(this._lngLat);if(!r||i){let e=i?this._opacityWhenCovered:this._opacity;this._element.style.opacity!==e&&(this._element.style.opacity=e);return}if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null}),100)}let a=this._map,o=a.terrain.depthAtPoint(this._pos),s=a.terrain.getElevationForLngLatZoom(this._lngLat,a.transform.tileZoom);if(a.transform.lngLatToCameraDepth(this._lngLat,s)-o<.006)return void(this._element.style.opacity=this._opacity);let c=-this._offset.y/a.transform.pixelsPerMeter,l=Math.sin(a.getPitch()*Math.PI/180)*c,u=a.terrain.depthAtPoint(new t.P(this._pos.x,this._pos.y-this._offset.y)),d=a.transform.lngLatToCameraDepth(this._lngLat,s+l)-u>.006;(n=this._popup)!=null&&n.isOpen()&&d&&this._popup.remove(),this._element.style.opacity=d?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(e){return this._offset=t.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e)}removeClassName(e){this._element.classList.remove(e)}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on(`mousedown`,this._addDragHandler),this._map.on(`touchstart`,this._addDragHandler)):(this._map.off(`mousedown`,this._addDragHandler),this._map.off(`touchstart`,this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||`auto`,this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&e!==`auto`?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,t){return(this._opacity===void 0||e===void 0&&t===void 0)&&(this._opacity=`1`,this._opacityWhenCovered=`0.2`),e!==void 0&&(this._opacity=e),t!==void 0&&(this._opacityWhenCovered=t),this._map&&this._updateOpacity(!0),this}}let qa={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0},Ja=0,Ya=!1,Xa={maxWidth:100,unit:`metric`};function Za(e,t,n){let r=n&&n.maxWidth||100,i=e._container.clientHeight/2,a=e._container.clientWidth/2,o=e.unproject([a-r/2,i]),s=e.unproject([a+r/2,i]),c=Math.round(e.project(s).x-e.project(o).x),l=Math.min(r,c,e._container.clientWidth),u=o.distanceTo(s);if(n&&n.unit===`imperial`){let n=3.2808*u;n>5280?Qa(t,l,n/5280,e._getUIString(`ScaleControl.Miles`)):Qa(t,l,n,e._getUIString(`ScaleControl.Feet`))}else n&&n.unit===`nautical`?Qa(t,l,u/1852,e._getUIString(`ScaleControl.NauticalMiles`)):u>=1e3?Qa(t,l,u/1e3,e._getUIString(`ScaleControl.Kilometers`)):Qa(t,l,u,e._getUIString(`ScaleControl.Meters`))}function Qa(e,t,n,r){let i=function(e){let t=10**(`${Math.floor(e)}`.length-1),n=e/t;return n=n>=10?10:n>=5?5:n>=3?3:n>=2?2:n>=1?1:function(e){let t=10**Math.ceil(-Math.log(e)/Math.LN10);return Math.round(e*t)/t}(n),t*n}(n);e.style.width=i/n*t+`px`,e.innerHTML=`${i}&nbsp;${r}`}let $a={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:``,maxWidth:`240px`,subpixelPositioning:!1,locationOccludedOpacity:void 0},eo=[`a[href]`,`[tabindex]:not([tabindex='-1'])`,`[contenteditable]:not([contenteditable='false'])`,`button:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`].join(`, `);function to(e){if(e){if(typeof e==`number`){let n=Math.round(Math.abs(e)/Math.SQRT2);return{center:new t.P(0,0),top:new t.P(0,e),"top-left":new t.P(n,n),"top-right":new t.P(-n,n),bottom:new t.P(0,-e),"bottom-left":new t.P(n,-n),"bottom-right":new t.P(-n,-n),left:new t.P(e,0),right:new t.P(-e,0)}}if(e instanceof t.P||Array.isArray(e)){let n=t.P.convert(e);return{center:n,top:n,"top-left":n,"top-right":n,bottom:n,"bottom-left":n,"bottom-right":n,left:n,right:n}}return{center:t.P.convert(e.center||[0,0]),top:t.P.convert(e.top||[0,0]),"top-left":t.P.convert(e[`top-left`]||[0,0]),"top-right":t.P.convert(e[`top-right`]||[0,0]),bottom:t.P.convert(e.bottom||[0,0]),"bottom-left":t.P.convert(e[`bottom-left`]||[0,0]),"bottom-right":t.P.convert(e[`bottom-right`]||[0,0]),left:t.P.convert(e.left||[0,0]),right:t.P.convert(e.right||[0,0])}}return to(new t.P(0,0))}let no=n;e.AJAXError=t.cB,e.Event=t.l,e.Evented=t.E,e.LngLat=t.aa,e.MercatorCoordinate=t.aj,e.Point=t.P,e.addProtocol=t.cC,e.config=t.a,e.createExpression=t.cE,e.removeProtocol=t.cD,e.AttributionControl=Aa,e.BoxZoomHandler=Yi,e.CanvasSource=He,e.CooperativeGesturesHandler=Ca,e.DoubleClickZoomHandler=_a,e.DragPanHandler=ba,e.DragRotateHandler=xa,e.EdgeInsets=It,e.FullscreenControl=class extends t.E{constructor(e={}){super(),this._onFullscreenChange=()=>{let e=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;e?.shadowRoot?.fullscreenElement;)e=e.shadowRoot.fullscreenElement;e===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,e&&e.container&&(e.container instanceof HTMLElement?this._container=e.container:t.w(`Full screen control 'container' must be a DOM element.`)),`onfullscreenchange`in document?this._fullscreenchange=`fullscreenchange`:`onmozfullscreenchange`in document?this._fullscreenchange=`mozfullscreenchange`:`onwebkitfullscreenchange`in document?this._fullscreenchange=`webkitfullscreenchange`:`onmsfullscreenchange`in document&&(this._fullscreenchange=`MSFullscreenChange`)}onAdd(e){return this._map=e,this._container||=this._map.getContainer(),this._controlContainer=s.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._setupUI(),this._controlContainer}onRemove(){s.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){let e=this._fullscreenButton=s.create(`button`,`maplibregl-ctrl-fullscreen`,this._controlContainer);s.create(`span`,`maplibregl-ctrl-icon`,e).setAttribute(`aria-hidden`,`true`),e.type=`button`,this._updateTitle(),this._fullscreenButton.addEventListener(`click`,this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){let e=this._getTitle();this._fullscreenButton.setAttribute(`aria-label`,e),this._fullscreenButton.title=e}_getTitle(){return this._map._getUIString(this._isFullscreen()?`FullscreenControl.Exit`:`FullscreenControl.Enter`)}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle(`maplibregl-ctrl-shrink`),this._fullscreenButton.classList.toggle(`maplibregl-ctrl-fullscreen`),this._updateTitle(),this._fullscreen?(this.fire(new t.l(`fullscreenstart`)),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new t.l(`fullscreenend`)),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle(`maplibregl-pseudo-fullscreen`),this._handleFullscreenChange(),this._map.resize()}},e.GeoJSONSource=ze,e.GeolocateControl=class extends t.E{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new t.l(`outofmaxbounds`,e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case`WAITING_ACTIVE`:case`ACTIVE_LOCK`:case`ACTIVE_ERROR`:this._watchState=`ACTIVE_LOCK`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active-error`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active`);break;case`BACKGROUND`:case`BACKGROUND_ERROR`:this._watchState=`BACKGROUND`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background-error`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-background`);break;default:throw Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&this._watchState!==`OFF`&&this._updateMarker(e),this.options.trackUserLocation&&this._watchState!==`ACTIVE_LOCK`||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove(`maplibregl-user-location-dot-stale`),this.fire(new t.l(`geolocate`,e)),this._finish()}},this._updateCamera=e=>{let n=new t.aa(e.coords.longitude,e.coords.latitude),r=e.coords.accuracy,i=this._map.getBearing(),a=t.e({bearing:i},this.options.fitBoundsOptions),o=I.fromLngLat(n,r);this._map.fitBounds(o,a,{geolocateSource:!0})},this._updateMarker=e=>{if(e){let n=new t.aa(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()},this._onError=e=>{if(this._map){if(e.code===1){this._watchState=`OFF`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active-error`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background-error`),this._geolocateButton.disabled=!0;let e=this._map._getUIString(`GeolocateControl.LocationNotAvailable`);this._geolocateButton.title=e,this._geolocateButton.setAttribute(`aria-label`,e),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(e.code===3&&Ya)return;this.options.trackUserLocation&&this._setErrorState()}this._watchState!==`OFF`&&this.options.showUserLocation&&this._dotElement.classList.add(`maplibregl-user-location-dot-stale`),this.fire(new t.l(`error`,e)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener(`contextmenu`,(e=>e.preventDefault())),this._geolocateButton=s.create(`button`,`maplibregl-ctrl-geolocate`,this._container),s.create(`span`,`maplibregl-ctrl-icon`,this._geolocateButton).setAttribute(`aria-hidden`,`true`),this._geolocateButton.type=`button`,this._geolocateButton.disabled=!0)},this._finishSetupUI=e=>{if(this._map){if(!1===e){t.w(`Geolocation support is not available so the GeolocateControl will be disabled.`);let e=this._map._getUIString(`GeolocateControl.LocationNotAvailable`);this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute(`aria-label`,e)}else{let e=this._map._getUIString(`GeolocateControl.FindMyLocation`);this._geolocateButton.disabled=!1,this._geolocateButton.title=e,this._geolocateButton.setAttribute(`aria-label`,e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute(`aria-pressed`,`false`),this._watchState=`OFF`),this.options.showUserLocation&&(this._dotElement=s.create(`div`,`maplibregl-user-location-dot`),this._userLocationDotMarker=new Ka({element:this._dotElement}),this._circleElement=s.create(`div`,`maplibregl-user-location-accuracy-circle`),this._accuracyCircleMarker=new Ka({element:this._circleElement,pitchAlignment:`map`}),this.options.trackUserLocation&&(this._watchState=`OFF`),this._map.on(`zoom`,this._onZoom)),this._geolocateButton.addEventListener(`click`,(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on(`movestart`,(e=>{let n=e?.[0]instanceof ResizeObserverEntry;e.geolocateSource||this._watchState!==`ACTIVE_LOCK`||n||this._map.isZooming()||(this._watchState=`BACKGROUND`,this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-background`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this.fire(new t.l(`trackuserlocationend`)),this.fire(new t.l(`userlocationlostfocus`)))}))}},this.options=t.e({},qa,e)}onAdd(e){return this._map=e,this._container=s.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._setupUI(),function(){return t._(this,arguments,void 0,(function*(e=!1){if(Ha!==void 0&&!e)return Ha;if(window.navigator.permissions===void 0)return Ha=!!window.navigator.geolocation,Ha;try{Ha=(yield window.navigator.permissions.query({name:`geolocation`})).state!==`denied`}catch{Ha=!!window.navigator.geolocation}return Ha}))}().then((e=>this._finishSetupUI(e))),this._container}onRemove(){this._geolocationWatchID!==void 0&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),s.remove(this._container),this._map.off(`zoom`,this._onZoom),this._map=void 0,Ja=0,Ya=!1}_isOutOfMapMaxBounds(e){let t=this._map.getMaxBounds(),n=e.coords;return t&&(n.longitude<t.getWest()||n.longitude>t.getEast()||n.latitude<t.getSouth()||n.latitude>t.getNorth())}_setErrorState(){switch(this._watchState){case`WAITING_ACTIVE`:this._watchState=`ACTIVE_ERROR`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active-error`);break;case`ACTIVE_LOCK`:this._watchState=`ACTIVE_ERROR`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active-error`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-waiting`);break;case`BACKGROUND`:this._watchState=`BACKGROUND_ERROR`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-background-error`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-waiting`);break;case`ACTIVE_ERROR`:break;default:throw Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){let e=this._map.getBounds(),t=e.getSouthEast(),n=e.getNorthEast(),r=t.distanceTo(n),i=Math.ceil(this._accuracy/(r/this._map._container.clientHeight)*2);this._circleElement.style.width=`${i}px`,this._circleElement.style.height=`${i}px`}trigger(){if(!this._setup)return t.w(`Geolocate control triggered before added to a map`),!1;if(this.options.trackUserLocation){switch(this._watchState){case`OFF`:this._watchState=`WAITING_ACTIVE`,this.fire(new t.l(`trackuserlocationstart`));break;case`WAITING_ACTIVE`:case`ACTIVE_LOCK`:case`ACTIVE_ERROR`:case`BACKGROUND_ERROR`:Ja--,Ya=!1,this._watchState=`OFF`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active-error`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background-error`),this.fire(new t.l(`trackuserlocationend`));break;case`BACKGROUND`:this._watchState=`ACTIVE_LOCK`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background`),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new t.l(`trackuserlocationstart`)),this.fire(new t.l(`userlocationfocus`));break;default:throw Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case`WAITING_ACTIVE`:this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active`);break;case`ACTIVE_LOCK`:this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active`);break;case`OFF`:break;default:throw Error(`Unexpected watchState ${this._watchState}`)}if(this._watchState===`OFF`&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let e;this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.setAttribute(`aria-pressed`,`true`),Ja++,Ja>1?(e={maximumAge:6e5,timeout:0},Ya=!0):(e=this.options.positionOptions,Ya=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.setAttribute(`aria-pressed`,`false`),this.options.showUserLocation&&this._updateMarker(null)}},e.GlobeControl=class{constructor(){this._toggleProjection=()=>{let e=this._map.getProjection()?.type;this._map.setProjection(e!==`mercator`&&e?{type:`mercator`}:{type:`globe`}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{this._globeButton.classList.remove(`maplibregl-ctrl-globe`),this._globeButton.classList.remove(`maplibregl-ctrl-globe-enabled`),this._map.getProjection()?.type===`globe`?(this._globeButton.classList.add(`maplibregl-ctrl-globe-enabled`),this._globeButton.title=this._map._getUIString(`GlobeControl.Disable`)):(this._globeButton.classList.add(`maplibregl-ctrl-globe`),this._globeButton.title=this._map._getUIString(`GlobeControl.Enable`))}}onAdd(e){return this._map=e,this._container=s.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._globeButton=s.create(`button`,`maplibregl-ctrl-globe`,this._container),s.create(`span`,`maplibregl-ctrl-icon`,this._globeButton).setAttribute(`aria-hidden`,`true`),this._globeButton.type=`button`,this._globeButton.addEventListener(`click`,this._toggleProjection),this._updateGlobeIcon(),this._map.on(`styledata`,this._updateGlobeIcon),this._container}onRemove(){s.remove(this._container),this._map.off(`styledata`,this._updateGlobeIcon),this._globeButton.removeEventListener(`click`,this._toggleProjection),this._map=void 0}},e.Hash=Ni,e.ImageSource=Be,e.KeyboardHandler=pa,e.LngLatBounds=I,e.LogoControl=ja,e.Map=class extends Oa{constructor(e){t.cx.mark(t.cy.create);let n=Object.assign(Object.assign(Object.assign({},za),e),{canvasContextAttributes:Object.assign(Object.assign({},za.canvasContextAttributes),e.canvasContextAttributes)});if(n.minZoom!=null&&n.maxZoom!=null&&n.minZoom>n.maxZoom)throw Error(`maxZoom must be greater than or equal to minZoom`);if(n.minPitch!=null&&n.maxPitch!=null&&n.minPitch>n.maxPitch)throw Error(`maxPitch must be greater than or equal to minPitch`);if(n.minPitch!=null&&n.minPitch<0)throw Error(`minPitch must be greater than or equal to 0`);if(n.maxPitch!=null&&n.maxPitch>180)throw Error(`maxPitch must be less than or equal to 180`);let r=new Ut,i=new qt;if(n.minZoom!==void 0&&r.setMinZoom(n.minZoom),n.maxZoom!==void 0&&r.setMaxZoom(n.maxZoom),n.minPitch!==void 0&&r.setMinPitch(n.minPitch),n.maxPitch!==void 0&&r.setMaxPitch(n.maxPitch),n.renderWorldCopies!==void 0&&r.setRenderWorldCopies(n.renderWorldCopies),super(r,i,{bearingSnap:n.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Ma,this._controls=[],this._mapId=t.ao(),this._contextLost=e=>{e.preventDefault(),this._frameRequest&&=(this._frameRequest.abort(),null),this.fire(new t.l(`webglcontextlost`,{originalEvent:e}))},this._contextRestored=e=>{this._setupPainter(),this.resize(),this._update(),this.fire(new t.l(`webglcontextrestored`,{originalEvent:e}))},this._onMapScroll=e=>{if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=n.interactive,this._maxTileCacheSize=n.maxTileCacheSize,this._maxTileCacheZoomLevels=n.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},n.canvasContextAttributes),this._trackResize=!0===n.trackResize,this._bearingSnap=n.bearingSnap,this._centerClampedToGround=n.centerClampedToGround,this._refreshExpiredTiles=!0===n.refreshExpiredTiles,this._fadeDuration=n.fadeDuration,this._crossSourceCollisions=!0===n.crossSourceCollisions,this._collectResourceTiming=!0===n.collectResourceTiming,this._locale=Object.assign(Object.assign({},La),n.locale),this._clickTolerance=n.clickTolerance,this._overridePixelRatio=n.pixelRatio,this._maxCanvasSize=n.maxCanvasSize,this.transformCameraUpdate=n.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=!0===n.cancelPendingTileRequestsWhileZooming,this._dynamicScale=n.scale,this._imageQueueHandle=m.addThrottleControl((()=>this.isMoving())),this._requestManager=new h(n.transformRequest),typeof n.container==`string`){if(this._container=document.getElementById(n.container),!this._container)throw Error(`Container '${n.container}' not found.`)}else{if(!(n.container instanceof HTMLElement))throw Error(`Invalid type: 'container' must be a String or HTMLElement.`);this._container=n.container}if(n.maxBounds&&this.setMaxBounds(n.maxBounds),this._setupContainer(),this._setupPainter(),this.on(`move`,(()=>this._update(!1))),this.on(`moveend`,(()=>this._update(!1))),this.on(`zoom`,(()=>this._update(!0))),this.on(`terrain`,(()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)})),this.once(`idle`,(()=>{this._idleTriggered=!0})),typeof window<`u`){addEventListener(`online`,this._onWindowOnline,!1);let e=!1,t=Mi((e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw())}),50);this._resizeObserver=new ResizeObserver((n=>{e?t(n):e=!0})),this._resizeObserver.observe(this._container)}this.handlers=new Da(this,n),this._hash=n.hash&&new Ni(typeof n.hash==`string`&&n.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:n.center,elevation:n.elevation,zoom:n.zoom,bearing:n.bearing,pitch:n.pitch,roll:n.roll}),n.bounds&&(this.resize(),this.fitBounds(n.bounds,t.e({},n.fitBoundsOptions,{duration:0}))));let a=typeof n.style==`string`||n.style?.projection?.type!==`globe`;this.resize(null,a),this._localIdeographFontFamily=n.localIdeographFontFamily,this._validateStyle=n.validateStyle,n.style?this.setStyle(n.style,{localIdeographFontFamily:n.localIdeographFontFamily}):n.style===null&&this._lazyInitEmptyStyle(),n.attributionControl&&this.addControl(new Aa(typeof n.attributionControl==`boolean`?void 0:n.attributionControl)),n.maplibreLogo&&this.addControl(new ja,n.logoPosition),this.on(`style.load`,(()=>{if(a||this._resizeTransform(),this.transform.unmodified){let e=t.a9(this.style.stylesheet,[`center`,`zoom`,`bearing`,`pitch`,`roll`]);this.jumpTo(e)}})),this.on(`data`,(e=>{this._update(e.dataType===`style`),this.fire(new t.l(`${e.dataType}data`,e))})),this.on(`dataloading`,(e=>{this.fire(new t.l(`${e.dataType}dataloading`,e))})),this.on(`dataabort`,(e=>{this.fire(new t.l(`sourcedataabort`,e))}))}_getMapId(){return this._mapId}setGlobalStateProperty(e,t){return this.style.setGlobalStateProperty(e,t),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(e,n){if(n===void 0&&(n=e.getDefaultPosition?e.getDefaultPosition():`top-right`),!e||!e.onAdd)return this.fire(new t.k(Error(`Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.`)));let r=e.onAdd(this);this._controls.push(e);let i=this._controlPositions[n];return n.indexOf(`bottom`)===-1?i.appendChild(r):i.insertBefore(r,i.firstChild),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new t.k(Error(`Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.`)));let n=this._controls.indexOf(e);return n>-1&&this._controls.splice(n,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}coveringTiles(e){return it(this.transform,e)}calculateCameraOptionsFromTo(e,t,n,r){return r==null&&this.terrain&&(r=this.terrain.getElevationForLngLatZoom(n,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(e,t,n,r)}resize(e,n=!0){let[r,i]=this._containerDimensions(),a=this.getScale(),o=this._getClampedPixelRatio(r,i);if(this._resizeCanvas(r,i,o),this.painter.resize(r,i,o,a),this.painter.overLimit()){let e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];let t=this._getClampedPixelRatio(r,i);this._resizeCanvas(r,i,t),this.painter.resize(r,i,t,a)}this._resizeTransform(n);let s=!this._moving;return s&&(this.stop(),this.fire(new t.l(`movestart`,e)).fire(new t.l(`move`,e))),this.fire(new t.l(`resize`,e)),s&&this.fire(new t.l(`moveend`,e)),this}_resizeTransform(e=!0){var t;let[n,r]=this._containerDimensions(),i=this.getScale(),a=n/i,o=r/i;this.transform.resize(a,o,e),(t=this._requestedCameraState)==null||t.resize(a,o,e)}_getClampedPixelRatio(e,t){let{0:n,1:r}=this._maxCanvasSize,i=this.getPixelRatio(),a=e*i,o=t*i;return Math.min(a>n?n/a:1,o>r?r/o:1)*i}getPixelRatio(){return this._overridePixelRatio??devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize()}getScale(){return this._dynamicScale}setScale(e){this._dynamicScale=e,this.resize()}getDetailLevel(){return this.transform.detailLevel}setDetailLevel(e){this.transform.setDetailLevel(e),this._update()}getRasterAlignment(){return this.transform.rasterAlignment}setRasterAlignment(e){this.transform.setRasterAlignment(e),this._update()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(e){return this.transform.setMaxBounds(I.convert(e)),this._update()}setMinZoom(e){if((e??=-2)>=-2&&e<=this.transform.maxZoom)return this.transform.setMinZoom(e),this._update(),this.getZoom()<e&&this.setZoom(e),this;throw Error(`minZoom must be between -2 and the current maxZoom, inclusive`)}getMinZoom(){return this.transform.minZoom}setMaxZoom(e){if((e??=22)>=this.transform.minZoom)return this.transform.setMaxZoom(e),this._update(),this.getZoom()>e&&this.setZoom(e),this;throw Error(`maxZoom must be greater than the current minZoom`)}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e??=0)<0)throw Error(`minPitch must be greater than or equal to 0`);if(e>=0&&e<=this.transform.maxPitch)return this.transform.setMinPitch(e),this._update(),this.getPitch()<e&&this.setPitch(e),this;throw Error(`minPitch must be between 0 and the current maxPitch, inclusive`)}getMinPitch(){return this.transform.minPitch}setMaxPitch(e){if((e??=60)>180)throw Error(`maxPitch must be less than or equal to 180`);if(e>=this.transform.minPitch)return this.transform.setMaxPitch(e),this._update(),this.getPitch()>e&&this.setPitch(e),this;throw Error(`maxPitch must be greater than the current minPitch`)}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.setRenderWorldCopies(e),this._update()}project(e){return this.transform.locationToScreenPoint(t.aa.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this.terrain)}unprojectClamped(e){return this.transform instanceof Ut?this.transform.screenPointToMercatorCoordinateClamped(t.P.convert(e)).toLngLat():this.unproject(e)}projectWithScaleCorrection(e){return this.project(e).mult(this.getScale())}unprojectWithScaleCorrection(e){return this.unproject(t.P.convert(e).div(this.getScale()))}isMoving(){return this._moving||this.handlers?.isMoving()}isZooming(){return this._zooming||this.handlers?.isZooming()}isRotating(){return this._rotating||this.handlers?.isRotating()}_createDelegatedListener(e,t,n){if(e===`mouseenter`||e===`mouseover`){let r=!1;return{layers:t,listener:n,delegates:{mousemove:i=>{let a=t.filter((e=>this.getLayer(e))),o=a.length===0?[]:this.queryRenderedFeatures(i.point,{layers:a});o.length?r||(r=!0,n.call(this,new Ui(e,this,i.originalEvent,{features:o}))):r=!1},mouseout:()=>{r=!1}}}}if(e===`mouseleave`||e===`mouseout`){let r=!1;return{layers:t,listener:n,delegates:{mousemove:i=>{let a=t.filter((e=>this.getLayer(e)));(a.length===0?[]:this.queryRenderedFeatures(i.point,{layers:a})).length?r=!0:r&&(r=!1,n.call(this,new Ui(e,this,i.originalEvent)))},mouseout:t=>{r&&(r=!1,n.call(this,new Ui(e,this,t.originalEvent)))}}}}{let r=e=>{let r=t.filter((e=>this.getLayer(e))),i=r.length===0?[]:this.queryRenderedFeatures(e.point,{layers:r});i.length&&(e.features=i,n.call(this,e),delete e.features)};return{layers:t,listener:n,delegates:{[e]:r}}}}_saveDelegatedListener(e,t){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(t)}_removeDelegatedListener(e,t,n){if(!this._delegatedListeners||!this._delegatedListeners[e])return;let r=this._delegatedListeners[e];for(let e=0;e<r.length;e++){let i=r[e];if(i.listener===n&&i.layers.length===t.length&&i.layers.every((e=>t.includes(e)))){for(let e in i.delegates)this.off(e,i.delegates[e]);r.splice(e,1);return}}}on(e,t,n){if(n===void 0)return super.on(e,t);let r=typeof t==`string`?[t]:t,i=this._createDelegatedListener(e,r,n);this._saveDelegatedListener(e,i);for(let e in i.delegates)this.on(e,i.delegates[e]);return{unsubscribe:()=>{this._removeDelegatedListener(e,r,n)}}}once(e,t,n){if(n===void 0)return super.once(e,t);let r=typeof t==`string`?[t]:t,i=this._createDelegatedListener(e,r,n);for(let t in i.delegates){let a=i.delegates[t];i.delegates[t]=(...t)=>{this._removeDelegatedListener(e,r,n),a(...t)}}this._saveDelegatedListener(e,i);for(let e in i.delegates)this.once(e,i.delegates[e]);return this}off(e,t,n){return n===void 0?super.off(e,t):(this._removeDelegatedListener(e,typeof t==`string`?[t]:t,n),this)}queryRenderedFeatures(e,n){if(!this.style)return[];let r,i=e instanceof t.P||Array.isArray(e),a=i?e:[[0,0],[this.transform.width,this.transform.height]];if(n=n||(i?{}:e)||{},a instanceof t.P||typeof a[0]==`number`)r=[t.P.convert(a)];else{let e=t.P.convert(a[0]),n=t.P.convert(a[1]);r=[e,new t.P(n.x,e.y),n,new t.P(e.x,n.y),e]}return this.style.queryRenderedFeatures(r,n,this.transform)}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}setStyle(e,n){return!1!==(n=t.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},n)).diff&&n.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,n),this):(this._localIdeographFontFamily=n.localIdeographFontFamily,this._updateStyle(e,n))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){let t=this._locale[e];if(t==null)throw Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){var n;if(t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once(`style.load`,(()=>this._updateStyle(e,t)));let r=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new kn(this,t||{}),this.style.setEventedParent(this,{style:this.style}),typeof e==`string`?this.style.loadURL(e,t,r):this.style.loadJSON(e,t,r),this):((n=this.style?.projection)==null||n.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new kn(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(e,n){if(typeof e==`string`){let r=this._requestManager.transformRequest(e,`Style`);t.j(r,new AbortController).then((e=>{this._updateDiff(e.data,n)})).catch((e=>{e&&this.fire(new t.k(e))}))}else typeof e==`object`&&this._updateDiff(e,n)}_updateDiff(e,n){try{this.style.setState(e,n)&&this._update(!0)}catch(r){t.w(`Unable to perform style diff: ${r.message||r.error||r}. Rebuilding the style from scratch.`),this._updateStyle(e,n)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():t.w(`There is no style added to the map.`)}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){let n=this.style&&this.style.sourceCaches[e];if(n!==void 0)return n.loaded();this.fire(new t.k(Error(`There is no source with ID '${e}'`)))}setTerrain(e){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off(`data`,this._terrainDataCallback),e){let n=this.style.sourceCaches[e.source];if(!n)throw Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);this.terrain===null&&n.reload();for(let n in this.style._layers){let r=this.style._layers[n];r.type===`hillshade`&&r.source===e.source&&t.w(`You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.`),r.type===`color-relief`&&r.source===e.source&&t.w(`You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.`)}this.terrain=new Q(this.painter,n,e),this.painter.renderToTexture=new Ia(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=t=>{t.dataType===`style`?this.terrain.sourceCache.freeRtt():t.dataType===`source`&&t.tile&&(t.sourceId!==e.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),t.source?.type===`image`?this.terrain.sourceCache.freeRtt():this.terrain.sourceCache.freeRtt(t.tile.tileID))},this.style.on(`data`,this._terrainDataCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new t.l(`terrain`,{terrain:e})),this}getTerrain(){return this.terrain?.options??null}areTilesLoaded(){let e=this.style&&this.style.sourceCaches;for(let t in e){let n=e[t]._tiles;for(let e in n){let t=n[e];if(t.state!==`loaded`&&t.state!==`errored`)return!1}}return!0}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style.getSource(e)}setSourceTileLodParams(e,t,n){if(n){let r=this.getSource(n);if(!r)throw Error(`There is no source with ID "${n}", cannot set LOD parameters`);r.calculateTileZoom=tt(Math.max(1,e),Math.max(1,t))}else for(let n in this.style.sourceCaches)this.style.sourceCaches[n].getSource().calculateTileZoom=tt(Math.max(1,e),Math.max(1,t));return this._update(!0),this}refreshTiles(e,n){let r=this.style.sourceCaches[e];if(!r)throw Error(`There is no source cache with ID "${e}", cannot refresh tile`);n===void 0?r.reload(!0):r.refreshTiles(n.map((e=>new t.al(e.z,e.x,e.y))))}addImage(e,n,r={}){let{pixelRatio:i=1,sdf:a=!1,stretchX:s,stretchY:c,content:l,textFitWidth:u,textFitHeight:d}=r;if(this._lazyInitEmptyStyle(),!(n instanceof HTMLImageElement||t.b(n))){if(n.width===void 0||n.height===void 0)return this.fire(new t.k(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`")));{let{width:r,height:o,data:f}=n,p=n;return this.style.addImage(e,{data:new t.R({width:r,height:o},new Uint8Array(f)),pixelRatio:i,stretchX:s,stretchY:c,content:l,textFitWidth:u,textFitHeight:d,sdf:a,version:0,userImage:p}),p.onAdd&&p.onAdd(this,e),this}}{let{width:r,height:f,data:p}=o.getImageData(n);this.style.addImage(e,{data:new t.R({width:r,height:f},p),pixelRatio:i,stretchX:s,stretchY:c,content:l,textFitWidth:u,textFitHeight:d,sdf:a,version:0})}}updateImage(e,n){let r=this.style.getImage(e);if(!r)return this.fire(new t.k(Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let{width:i,height:a,data:s}=n instanceof HTMLImageElement||t.b(n)?o.getImageData(n):n;if(i===void 0||a===void 0)return this.fire(new t.k(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(i!==r.data.width||a!==r.data.height)return this.fire(new t.k(Error(`The width and height of the updated image must be that same as the previous version of the image`)));let c=!(n instanceof HTMLImageElement||t.b(n));return r.data.replace(s,c),this.style.updateImage(e,r),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new t.k(Error(`Missing required image id`))),!1)}removeImage(e){this.style.removeImage(e)}addImages(e){this.style.addImages(e)}loadImage(e){return m.getImage(this._requestManager.transformRequest(e,`Image`),new AbortController)}listImages(){return this.style.listImages()}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}setLayersOrder(e){return this._lazyInitEmptyStyle(),this.style.setLayersOrder(e),this._update(!0)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(e,t,n){return this.style.setLayerZoomRange(e,t,n),this._update(!0)}setFilter(e,t,n={}){return this.style.setFilter(e,t,n),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,n,r={}){return this.style.setPaintProperty(e,t,n,r),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,n,r={}){return this.style.setLayoutProperty(e,t,n,r),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setGlyphs(e,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(e,t,n={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,t,n,(e=>{e||this._update(!0)})),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,t,(e=>{e||this._update(!0)})),this}loadSprite(e){return v(e,this._requestManager,this.getPixelRatio()*this.getScale(),new AbortController).then((e=>e.default??{}))}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,t=0;return this._container&&(e=this._container.clientWidth||400,t=this._container.clientHeight||300),[e,t]}_setupContainer(){let e=this._container;e.classList.add(`maplibregl-map`);let t=this._canvasContainer=s.create(`div`,`maplibregl-canvas-container`,e);this._interactive&&t.classList.add(`maplibregl-interactive`),this._canvas=s.create(`canvas`,`maplibregl-canvas`,t),this._canvas.addEventListener(`webglcontextlost`,this._contextLost,!1),this._canvas.addEventListener(`webglcontextrestored`,this._contextRestored,!1),this._canvas.setAttribute(`tabindex`,this._interactive?`0`:`-1`),this._canvas.setAttribute(`aria-label`,this._getUIString(`Map.Title`)),this._canvas.setAttribute(`role`,`region`);let n=this._containerDimensions(),r=this._getClampedPixelRatio(n[0],n[1]);this._resizeCanvas(n[0],n[1],r);let i=this._controlContainer=s.create(`div`,`maplibregl-control-container`,e),a=this._controlPositions={};[`top-left`,`top-right`,`bottom-left`,`bottom-right`].forEach((e=>{a[e]=s.create(`div`,`maplibregl-ctrl-${e} `,i)})),this._container.addEventListener(`scroll`,this._onMapScroll,!1)}_resizeCanvas(e,t,n){this._canvas.width=Math.floor(n*e),this._canvas.height=Math.floor(n*t),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`}_setupPainter(){let e=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0}),t=null;this._canvas.addEventListener(`webglcontextcreationerror`,(n=>{t={requestedAttributes:e},n&&(t.statusMessage=n.statusMessage,t.type=n.type)}),{once:!0});let n=null;if(n=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,e):this._canvas.getContext(`webgl2`,e)||this._canvas.getContext(`webgl`,e),!n){let e=`Failed to initialize WebGL`;throw t?(t.message=e,Error(JSON.stringify(t))):Error(e)}this.painter=new ji(n,this.transform),c.testSupport(n)}migrateProjection(e,n){super.migrateProjection(e,n),this.painter.transform=e,this.fire(new t.l(`projectiontransition`,{newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_render(e){var n;let r=this._idleTriggered?this._fadeDuration:0,i=this.style.projection?.transitionState>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let a=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;let e=this.transform.zoom,n=o.now();this.style.zoomHistory.update(e,n);let i=new t.F(e,{now:n,fadeDuration:r,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition(),globalState:this.style.getGlobalState()}),s=i.crossFadingFactor();s===1&&s===this._crossFadingFactor||(a=!0,this._crossFadingFactor=s),this.style.update(i)}let s=this.style.projection?.transitionState>0!==i;(n=this.style.projection)==null||n.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(this.style.projection?.transitionState,this.style.projection?.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||s)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,r,this._crossSourceCollisions,s),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:r,showPadding:this.showPadding}),this.fire(new t.l(`render`)),this.loaded()&&!this._loaded&&(this._loaded=!0,t.cx.mark(t.cy.load),this.fire(new t.l(`load`))),this.style&&(this.style.hasTransitions()||a)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let c=this._sourcesDirty||this._styleDirty||this._placementDirty;return c||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new t.l(`idle`)),!this._loaded||this._fullyLoaded||c||(this._fullyLoaded=!0,t.cx.mark(t.cy.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&=(this._frameRequest.abort(),null),this._render(0)),this}remove(){var e;this._hash&&this._hash.remove();for(let e of this._controls)e.onRemove(this);this._controls=[],this._frameRequest&&=(this._frameRequest.abort(),null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),typeof window<`u`&&removeEventListener(`online`,this._onWindowOnline,!1),m.removeThrottleControl(this._imageQueueHandle),(e=this._resizeObserver)==null||e.disconnect();let n=this.painter.context.gl.getExtension(`WEBGL_lose_context`);n!=null&&n.loseContext&&n.loseContext(),this._canvas.removeEventListener(`webglcontextrestored`,this._contextRestored,!1),this._canvas.removeEventListener(`webglcontextlost`,this._contextLost,!1),s.remove(this._canvasContainer),s.remove(this._controlContainer),this._container.removeEventListener(`scroll`,this._onMapScroll,!1),this._container.classList.remove(`maplibregl-map`),t.cx.clearMetrics(),this._removed=!0,this.fire(new t.l(`remove`))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,o.frame(this._frameRequest,(e=>{t.cx.frame(e),this._frameRequest=null;try{this._render(e)}catch(e){if(!t.cz(e)&&!function(e){return e.message===Xr}(e))throw e}}),(()=>{})))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}get version(){return Ra}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}setLabelFreeAreas(e){this.style.setLabelFreeAreas(e)&&this.triggerRepaint()}getGlyphMap(e,t){let n=this.style.glyphManager,r=new Set;for(let t=0;t<e.length;t++)r.add(e.charCodeAt(t));return n.getGlyphMap(t,Array.from(r))}getLineBreaks(e,n,r,i,a,o=this.getGlyphMap(e,n)){return t.cA(e,n,r,i,a,o).map((({text:e})=>e))}},e.MapMouseEvent=Ui,e.MapTouchEvent=Wi,e.MapWheelEvent=Gi,e.Marker=Ka,e.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{let e=this._map.getZoom(),t=e===this._map.getMaxZoom(),n=e===this._map.getMinZoom();this._zoomInButton.disabled=t,this._zoomOutButton.disabled=n,this._zoomInButton.setAttribute(`aria-disabled`,t.toString()),this._zoomOutButton.setAttribute(`aria-disabled`,n.toString())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.cos(this._map.transform.pitchInRadians)**.5}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.cos(this._map.transform.pitchInRadians)**.5}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(e,t)=>{let n=this._map._getUIString(`NavigationControl.${t}`);e.title=n,e.setAttribute(`aria-label`,n)},this.options=t.e({},Ba,e),this._container=s.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._container.addEventListener(`contextmenu`,(e=>e.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton(`maplibregl-ctrl-zoom-in`,(e=>this._map.zoomIn({},{originalEvent:e}))),s.create(`span`,`maplibregl-ctrl-icon`,this._zoomInButton).setAttribute(`aria-hidden`,`true`),this._zoomOutButton=this._createButton(`maplibregl-ctrl-zoom-out`,(e=>this._map.zoomOut({},{originalEvent:e}))),s.create(`span`,`maplibregl-ctrl-icon`,this._zoomOutButton).setAttribute(`aria-hidden`,`true`)),this.options.showCompass&&(this._compass=this._createButton(`maplibregl-ctrl-compass`,(e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})})),this._compassIcon=s.create(`span`,`maplibregl-ctrl-icon`,this._compass),this._compassIcon.setAttribute(`aria-hidden`,`true`))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,`ZoomIn`),this._setButtonTitle(this._zoomOutButton,`ZoomOut`),this._map.on(`zoom`,this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,`ResetBearing`),this.options.visualizePitch&&this._map.on(`pitch`,this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on(`roll`,this._rotateCompassArrow),this._map.on(`rotate`,this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Va(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){s.remove(this._container),this.options.showZoom&&this._map.off(`zoom`,this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off(`pitch`,this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off(`roll`,this._rotateCompassArrow),this._map.off(`rotate`,this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(e,t){let n=s.create(`button`,e,this._container);return n.type=`button`,n.addEventListener(`click`,t),n}},e.Popup=class extends t.E{constructor(e){super(),this._updateOpacity=()=>{this.options.locationOccludedOpacity!==void 0&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:``)},this.remove=()=>(this._content&&s.remove(this._content),this._container&&(s.remove(this._container),delete this._container),this._map&&(this._map.off(`move`,this._update),this._map.off(`move`,this._onClose),this._map.off(`click`,this._onClose),this._map.off(`remove`,this.remove),this._map.off(`mousemove`,this._onMouseMove),this._map.off(`mouseup`,this._onMouseUp),this._map.off(`drag`,this._onDrag),this._map._canvasContainer.classList.remove(`maplibregl-track-pointer`),delete this._map,this.fire(new t.l(`close`))),this),this._onMouseUp=e=>{this._update(e.point)},this._onMouseMove=e=>{this._update(e.point)},this._onDrag=e=>{this._update(e.point)},this._update=e=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=s.create(`div`,`maplibregl-popup`,this._map.getContainer()),this._tip=s.create(`div`,`maplibregl-popup-tip`,this._container),this._container.appendChild(this._content),this.options.className)for(let e of this.options.className.split(` `))this._container.classList.add(e);this._closeButton&&this._closeButton.setAttribute(`aria-label`,this._map._getUIString(`Popup.Close`)),this._trackPointer&&this._container.classList.add(`maplibregl-popup-track-pointer`)}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=Ua(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),this._trackPointer&&!e)return;let t=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationToScreenPoint(this._lngLat));let n=this.options.anchor,r=to(this.options.offset);if(!n){let e=this._container.offsetWidth,i=this._container.offsetHeight,a;a=t.y+r.bottom.y<i?[`top`]:t.y>this._map.transform.height-i?[`bottom`]:[],t.x<e/2?a.push(`left`):t.x>this._map.transform.width-e/2&&a.push(`right`),n=a.length===0?`bottom`:a.join(`-`)}let i=t.add(r[n]);this.options.subpixelPositioning||(i=i.round()),s.setTransform(this._container,`${Wa[n]} translate(${i.x}px,${i.y}px)`),Ga(this._container,n,`popup`),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=t.e(Object.create($a),e)}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on(`click`,this._onClose),this.options.closeOnMove&&this._map.on(`move`,this._onClose),this._map.on(`remove`,this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on(`mousemove`,this._onMouseMove),this._map.on(`mouseup`,this._onMouseUp),this._container&&this._container.classList.add(`maplibregl-popup-track-pointer`),this._map._canvasContainer.classList.add(`maplibregl-track-pointer`)):this._map.on(`move`,this._update),this.fire(new t.l(`open`)),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.aa.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on(`move`,this._update),this._map.off(`mousemove`,this._onMouseMove),this._container&&this._container.classList.remove(`maplibregl-popup-track-pointer`),this._map._canvasContainer.classList.remove(`maplibregl-track-pointer`)),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off(`move`,this._update),this._map.on(`mousemove`,this._onMouseMove),this._map.on(`drag`,this._onDrag),this._container&&this._container.classList.add(`maplibregl-popup-track-pointer`),this._map._canvasContainer.classList.add(`maplibregl-track-pointer`)),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){let t=document.createDocumentFragment(),n=document.createElement(`body`),r;for(n.innerHTML=e;r=n.firstChild,r;)t.appendChild(r);return this.setDOMContent(t)}getMaxWidth(){return this._container?.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=s.create(`div`,`maplibregl-popup-content`,this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e}_createCloseButton(){this.options.closeButton&&(this._closeButton=s.create(`button`,`maplibregl-popup-close-button`,this._content),this._closeButton.type=`button`,this._closeButton.innerHTML=`&#215;`,this._closeButton.addEventListener(`click`,this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;let e=this._container.querySelector(eo);e&&e.focus()}},e.RasterDEMTileSource=Re,e.RasterTileSource=Le,e.ScaleControl=class{constructor(e){this._onMove=()=>{Za(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,Za(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},Xa),e)}getDefaultPosition(){return`bottom-left`}onAdd(e){return this._map=e,this._container=s.create(`div`,`maplibregl-ctrl maplibregl-ctrl-scale`,e.getContainer()),this._map.on(`move`,this._onMove),this._onMove(),this._container}onRemove(){s.remove(this._container),this._map.off(`move`,this._onMove),this._map=void 0}},e.ScrollZoomHandler=ga,e.Style=kn,e.TerrainControl=class{constructor(e){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove(`maplibregl-ctrl-terrain`),this._terrainButton.classList.remove(`maplibregl-ctrl-terrain-enabled`),this._map.terrain?(this._terrainButton.classList.add(`maplibregl-ctrl-terrain-enabled`),this._terrainButton.title=this._map._getUIString(`TerrainControl.Disable`)):(this._terrainButton.classList.add(`maplibregl-ctrl-terrain`),this._terrainButton.title=this._map._getUIString(`TerrainControl.Enable`))},this.options=e}onAdd(e){return this._map=e,this._container=s.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._terrainButton=s.create(`button`,`maplibregl-ctrl-terrain`,this._container),s.create(`span`,`maplibregl-ctrl-icon`,this._terrainButton).setAttribute(`aria-hidden`,`true`),this._terrainButton.type=`button`,this._terrainButton.addEventListener(`click`,this._toggleTerrain),this._updateTerrainIcon(),this._map.on(`terrain`,this._updateTerrainIcon),this._container}onRemove(){s.remove(this._container),this._map.off(`terrain`,this._updateTerrainIcon),this._map=void 0}},e.TwoFingersTouchPitchHandler=X,e.TwoFingersTouchRotateHandler=da,e.TwoFingersTouchZoomHandler=la,e.TwoFingersTouchZoomRotateHandler=Sa,e.VectorTileSource=Ie,e.VideoSource=Ve,e.addSourceType=(e,n)=>t._(void 0,void 0,void 0,(function*(){if(We(e))throw Error(`A source type called "${e}" already exists.`);((e,t)=>{Ue[e]=t})(e,n)})),e.clearPrewarmedResources=function(){let e=P;e&&(e.isPreloaded()&&e.numActive()===1?(e.release(j),P=null):console.warn(`Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()`))},e.createTileMesh=tn,e.getMaxParallelImageRequests=function(){return t.a.MAX_PARALLEL_IMAGE_REQUESTS},e.getRTLTextPluginStatus=function(){return qe().getRTLTextPluginStatus()},e.getVersion=function(){return no},e.getWorkerCount=function(){return M.workerCount},e.getWorkerUrl=function(){return t.a.WORKER_URL},e.importScriptInWorkers=function(e){return ne().broadcast(`IS`,e)},e.prewarm=function(){te().acquire(j)},e.setMaxParallelImageRequests=function(e){t.a.MAX_PARALLEL_IMAGE_REQUESTS=e},e.setRTLTextPlugin=function(e,t){return qe().setRTLTextPlugin(e,t)},e.setWorkerCount=function(e){M.workerCount=e},e.setWorkerUrl=function(e){t.a.WORKER_URL=e}})),e}))}))(),d={"sky-color":`#6babff`,"sky-horizon-blend":1,"horizon-color":[`interpolate-hcl`,[`linear`],[`zoom`],0,`#edf7fc`,9,`#edf7fc`,10,`#dcf0fa`],"horizon-fog-blend":.5,"fog-color":`#edf7fc`,"fog-ground-blend":.5,"atmosphere-blend":1},f={top_left:{x:5,y:5,unit:`px`},top_center:{x:0,y:5,unit:`px`},top_right:{x:5,y:5,unit:`px`},right_center:{x:5,y:0,unit:`px`},bottom_right:{x:5,y:5,unit:`px`},bottom_center:{x:0,y:5,unit:`px`},bottom_left:{x:5,y:5,unit:`px`},left_center:{x:5,y:0,unit:`px`}},p={top_left:{x:`left`,y:`top`},top_center:{x:`center`,y:`top`},top_right:{x:`right`,y:`top`},right_center:{x:`right`,y:`center`},bottom_right:{x:`right`,y:`bottom`},bottom_center:{x:`center`,y:`bottom`},bottom_left:{x:`left`,y:`bottom`},left_center:{x:`left`,y:`center`}},m={fill:{props:[`fill-opacity`],defaultValue:1},line:{props:[`line-opacity`],defaultValue:1},circle:{props:[`circle-opacity`,`circle-stroke-opacity`],defaultValue:1},heatmap:{props:[`heatmap-opacity`],defaultValue:1},"fill-extrusion":{props:[`fill-extrusion-opacity`],defaultValue:1},symbol:{props:[`icon-opacity`,`text-opacity`],defaultValue:1},raster:{props:[`raster-opacity`],defaultValue:1},hillshade:{props:[`hillshade-exaggeration`],defaultValue:.5},"color-relief":{props:[`color-relief-opacity`],defaultValue:1},background:{props:[`background-opacity`],defaultValue:1}};function h(e,t){for(let n of t.getStyle().layers){if(n.type!==`symbol`||n.id.startsWith(`custom-`)||n.id.startsWith(`gl-`))continue;let r=n.layout&&n.layout[`text-field`];n[`source-layer`]&&Array.isArray(r)&&r[0]===`coalesce`&&!r.find(e=>Array.isArray(e)&&e[1]===`name:abbr`)&&t.setLayoutProperty(n.id,`text-field`,g(n.source,e),{validate:!1})}}function g(e,t){return t!==`en`&&t!==`native`&&(t=y(t,_.TWO)),t===`native`?[`get`,`name`]:e.startsWith(`mc-base`)?[`coalesce`,[`get`,`name:${t}`],[`case`,[`has`,`name_is_latin`],[`get`,`name`],[`get`,`name:en`]]]:[`coalesce`,[`get`,`name:${t}`],[`get`,`name:en`],[`get`,`name`]]}var _=Object.freeze({THREE:`ISO 639-2/B`,API:`ISO 639-2/B`,TWO:`ISO 639-1`,MAPLIBRE_COMPAT:`ISO 639-1`,ENDONYM:`name`,NAME:`name`,LOCALE:`locale`,i18n:`locale`}),v=Object.freeze([{[_.TWO]:`en`,[_.THREE]:`eng`,[_.ENDONYM]:`English`,[_.LOCALE]:`en_GB`},{[_.TWO]:`da`,[_.THREE]:`dan`,[_.ENDONYM]:`Dansk`,[_.LOCALE]:`da_DK`},{[_.TWO]:`nl`,[_.THREE]:`dut`,[_.ENDONYM]:`Nederlands`,[_.LOCALE]:`nl_NL`},{[_.TWO]:`fi`,[_.THREE]:`fin`,[_.ENDONYM]:`Suomi`,[_.LOCALE]:`fi_FI`},{[_.TWO]:`fr`,[_.THREE]:`fre`,[_.ENDONYM]:`Francais`,[_.LOCALE]:`fr_FR`},{[_.TWO]:`de`,[_.THREE]:`ger`,[_.ENDONYM]:`Deutsch`,[_.LOCALE]:`de_DE`},{[_.TWO]:`it`,[_.THREE]:`ita`,[_.ENDONYM]:`Italiano`,[_.LOCALE]:`it_IT`},{[_.TWO]:`no`,[_.THREE]:`nor`,[_.ENDONYM]:`Norsk`,[_.LOCALE]:`nn_NO`},{[_.TWO]:`pl`,[_.THREE]:`pol`,[_.ENDONYM]:`Polski`,[_.LOCALE]:`pl_PL`},{[_.TWO]:`pt`,[_.THREE]:`por`,[_.ENDONYM]:`Portugues`,[_.LOCALE]:`pt_PT`},{[_.TWO]:`es`,[_.THREE]:`spa`,[_.ENDONYM]:`Espanol`,[_.LOCALE]:`es_ES`},{[_.TWO]:`sv`,[_.THREE]:`swe`,[_.ENDONYM]:`Svenska`,[_.LOCALE]:`sv_SE`},{[_.TWO]:`ja`,[_.THREE]:`jpn`,[_.ENDONYM]:`日本語`,[_.LOCALE]:`ja_JP`},{[_.TWO]:`zh`,[_.THREE]:`chi`,[_.ENDONYM]:`汉语`,[_.LOCALE]:`zh_CN`},{[_.TWO]:`ru`,[_.THREE]:`rus`,[_.ENDONYM]:`Русский`,[_.LOCALE]:`ru_RU`},{[_.TWO]:`uk`,[_.THREE]:`ukr`,[_.ENDONYM]:`Украї́нська`,[_.LOCALE]:`uk_UK`},{[_.TWO]:`lv`,[_.THREE]:`lav`,[_.ENDONYM]:`Latviešu valoda`,[_.LOCALE]:`lv-LV`},{[_.TWO]:`kk`,[_.THREE]:`kaz`,[_.ENDONYM]:`қазақша`,[_.LOCALE]:`kk-KZ`},{[_.TWO]:`ar`,[_.THREE]:`ara`,[_.ENDONYM]:`العربية`,[_.LOCALE]:`ar_SA`},{[_.TWO]:`native`,[_.THREE]:`native`,[_.ENDONYM]:`Native`,[_.LOCALE]:`native`}]);function y(e,t=_.MAPLIBRE_COMPAT){return(v.find(t=>Object.values(t).some(t=>t===e))??v[0])[t]}var b=/^\s*[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?\s*$/;function x(e){return e/180*Math.PI}function S(e){return e*180/Math.PI}function C(e,t){let n=Math.PI/180,r=e.lat*n,i=t.lat*n,a=Math.sin(r)*Math.sin(i)+Math.cos(r)*Math.cos(i)*Math.cos((t.lng-e.lng)*n);return 6371e3*Math.acos(Math.min(a,1))}function w(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}function T(e,t){return e.startsWith(`$`)?E(t[e.slice(1)]):e}function E(e){return typeof e==`string`?e:typeof e==`number`?String(e):typeof e==`boolean`?String(e).toUpperCase():typeof e==`object`&&e&&(e.t===`n`||e.t===`d`)?e.w??``:``}function D(e){return typeof e==`string`&&b.test(e)?Number(e):typeof e==`string`||typeof e==`number`||typeof e==`boolean`?e:typeof e==`object`&&e&&e.t===`n`?e.v:null}function O(e){return e=e.trim(),/^\$?[\w\-_]+$/.test(e)?e:(/(?:https?:\/\/)?(?:www\.)?youtu\.?be(?:\.com)?\/?.*(?:watch|embed)?(?:.*v=|v\/|\/)([\w\-_]+)&?/.exec(e)||[])[1]}var k=72;function A(e,t,n){if(e===t)return n;let r={millimeter:1,centimeter:.1,meter:.001,kilometer:1e-6,foot:.00328084,mile:6.21371e-7,nauticalMile:5.39957e-7,inch:.0393701,pixel:.0393701*k,pica:.236222};return n/r[e]*r[t]}function j(e,t,n){return e+(t-e)*n}function M(e,t,n){return(n-e)/(t-e)}function N(e,t,n){return Math.max(Math.min(e,n),t)}function P(e){let t=e.split(``).map(e=>e.charCodeAt(0)).reduce((e,t)=>(e^=t,e+(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24)),2166136261);return t^=t<<3,t+=t>>5,t^=t<<4,t+=t>>17,t^=t<<25,t+=t>>6,`0000000${(t>>>0).toString(16)}`.substr(-8)}function ee(e,t){if(t.clientWidth>0&&t.clientHeight>0){let n=e.export?.unit??`pixel`,r=e.export?.size??[600,400],i=A(n,`pixel`,r[0]),a=A(n,`pixel`,r[1]);return Math.min(t.clientWidth/i,t.clientHeight/a)}return 1}function te(e,t,n=1e-4){return Math.abs(e-t)<n}function F(e,t){let n=document.createElement(`div`);n.className=`adornment`;let{svg:r,scale:i=1}=e,a=new DOMParser().parseFromString(r,`image/svg+xml`).querySelector(`svg`);if(a){let e=new RegExp(b.toString().replace(/^\/\^|\$\/$/g,``).replace(/.*/,`^($&)[, ]($&)[, ]($&)[, ]($&)$$`)),r=a.getAttribute(`width`),o=a.getAttribute(`height`);if(r&&o&&b.test(r)&&b.test(o))a.setAttribute(`width`,String(Number(r)*i*t)),a.setAttribute(`height`,String(Number(o)*i*t));else{let n=e.exec(a.getAttribute(`viewBox`)),r=n?Number(n[3]):300,o=n?Number(n[4]):150;a.setAttribute(`width`,String(r*i*t)),a.setAttribute(`height`,String(o*i*t))}a.classList.add(`adornment-svg`),n.appendChild(a)}return n}function ne(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function re(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function ie(){}var ae=.7,oe=1/ae,se=`\\s*([+-]?\\d+)\\s*`,ce=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,le=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,ue=/^#([0-9a-f]{3,8})$/,de=RegExp(`^rgb\\(${se},${se},${se}\\)$`),fe=RegExp(`^rgb\\(${le},${le},${le}\\)$`),pe=RegExp(`^rgba\\(${se},${se},${se},${ce}\\)$`),me=RegExp(`^rgba\\(${le},${le},${le},${ce}\\)$`),he=RegExp(`^hsl\\(${ce},${le},${le}\\)$`),ge=RegExp(`^hsla\\(${ce},${le},${le},${ce}\\)$`),_e={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};ne(ie,Se,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:ve,formatHex:ve,formatHex8:ye,formatHsl:be,formatRgb:xe,toString:xe});function ve(){return this.rgb().formatHex()}function ye(){return this.rgb().formatHex8()}function be(){return I(this).formatHsl()}function xe(){return this.rgb().formatRgb()}function Se(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=ue.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Ce(t):n===3?new De(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?we(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?we(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=de.exec(e))?new De(t[1],t[2],t[3],1):(t=fe.exec(e))?new De(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=pe.exec(e))?we(t[1],t[2],t[3],t[4]):(t=me.exec(e))?we(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=he.exec(e))?Pe(t[1],t[2]/100,t[3]/100,1):(t=ge.exec(e))?Pe(t[1],t[2]/100,t[3]/100,t[4]):_e.hasOwnProperty(e)?Ce(_e[e]):e===`transparent`?new De(NaN,NaN,NaN,0):null}function Ce(e){return new De(e>>16&255,e>>8&255,e&255,1)}function we(e,t,n,r){return r<=0&&(e=t=n=NaN),new De(e,t,n,r)}function Te(e){return e instanceof ie||(e=Se(e)),e?(e=e.rgb(),new De(e.r,e.g,e.b,e.opacity)):new De}function Ee(e,t,n,r){return arguments.length===1?Te(e):new De(e,t,n,r??1)}function De(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}ne(De,Ee,re(ie,{brighter(e){return e=e==null?oe:oe**+e,new De(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?ae:ae**+e,new De(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new De(Me(this.r),Me(this.g),Me(this.b),je(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Oe,formatHex:Oe,formatHex8:ke,formatRgb:Ae,toString:Ae}));function Oe(){return`#${Ne(this.r)}${Ne(this.g)}${Ne(this.b)}`}function ke(){return`#${Ne(this.r)}${Ne(this.g)}${Ne(this.b)}${Ne((isNaN(this.opacity)?1:this.opacity)*255)}`}function Ae(){let e=je(this.opacity);return`${e===1?`rgb(`:`rgba(`}${Me(this.r)}, ${Me(this.g)}, ${Me(this.b)}${e===1?`)`:`, ${e})`}`}function je(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Me(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ne(e){return e=Me(e),(e<16?`0`:``)+e.toString(16)}function Pe(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Ie(e,t,n,r)}function I(e){if(e instanceof Ie)return new Ie(e.h,e.s,e.l,e.opacity);if(e instanceof ie||(e=Se(e)),!e)return new Ie;if(e instanceof Ie)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new Ie(o,s,c,e.opacity)}function Fe(e,t,n,r){return arguments.length===1?I(e):new Ie(e,t,n,r??1)}function Ie(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}ne(Ie,Fe,re(ie,{brighter(e){return e=e==null?oe:oe**+e,new Ie(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?ae:ae**+e,new Ie(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new De(ze(e>=240?e-240:e+120,i,r),ze(e,i,r),ze(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Ie(Le(this.h),Re(this.s),Re(this.l),je(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=je(this.opacity);return`${e===1?`hsl(`:`hsla(`}${Le(this.h)}, ${Re(this.s)*100}%, ${Re(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function Le(e){return e=(e||0)%360,e<0?e+360:e}function Re(e){return Math.max(0,Math.min(1,e||0))}function ze(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var Be=Math.PI/180,Ve=180/Math.PI,He=18,Ue=.96422,We=1,Ge=.82521,L=4/29,Ke=6/29,qe=3*Ke*Ke,Je=Ke*Ke*Ke;function Ye(e){if(e instanceof z)return new z(e.l,e.a,e.b,e.opacity);if(e instanceof et)return tt(e);e instanceof De||(e=Te(e));var t=Qe(e.r),n=Qe(e.g),r=Qe(e.b),i=B((.2225045*t+.7168786*n+.0606169*r)/We),a,o;return t===n&&n===r?a=o=i:(a=B((.4360747*t+.3850649*n+.1430804*r)/Ue),o=B((.0139322*t+.0971045*n+.7141733*r)/Ge)),new z(116*i-16,500*(a-i),200*(i-o),e.opacity)}function R(e,t,n,r){return arguments.length===1?Ye(e):new z(e,t,n,r??1)}function z(e,t,n,r){this.l=+e,this.a=+t,this.b=+n,this.opacity=+r}ne(z,R,re(ie,{brighter(e){return new z(this.l+He*(e??1),this.a,this.b,this.opacity)},darker(e){return new z(this.l-He*(e??1),this.a,this.b,this.opacity)},rgb(){var e=(this.l+16)/116,t=isNaN(this.a)?e:e+this.a/500,n=isNaN(this.b)?e:e-this.b/200;return t=Ue*Xe(t),e=We*Xe(e),n=Ge*Xe(n),new De(Ze(3.1338561*t-1.6168667*e-.4906146*n),Ze(-.9787684*t+1.9161415*e+.033454*n),Ze(.0719453*t-.2289914*e+1.4052427*n),this.opacity)}}));function B(e){return e>Je?e**(1/3):e/qe+L}function Xe(e){return e>Ke?e*e*e:qe*(e-L)}function Ze(e){return 255*(e<=.0031308?12.92*e:1.055*e**(1/2.4)-.055)}function Qe(e){return(e/=255)<=.04045?e/12.92:((e+.055)/1.055)**2.4}function V(e){if(e instanceof et)return new et(e.h,e.c,e.l,e.opacity);if(e instanceof z||(e=Ye(e)),e.a===0&&e.b===0)return new et(NaN,0<e.l&&e.l<100?0:NaN,e.l,e.opacity);var t=Math.atan2(e.b,e.a)*Ve;return new et(t<0?t+360:t,Math.sqrt(e.a*e.a+e.b*e.b),e.l,e.opacity)}function $e(e,t,n,r){return arguments.length===1?V(e):new et(e,t,n,r??1)}function et(e,t,n,r){this.h=+e,this.c=+t,this.l=+n,this.opacity=+r}function tt(e){if(isNaN(e.h))return new z(e.l,0,0,e.opacity);var t=e.h*Be;return new z(e.l,Math.cos(t)*e.c,Math.sin(t)*e.c,e.opacity)}ne(et,$e,re(ie,{brighter(e){return new et(this.h,this.c,this.l+He*(e??1),this.opacity)},darker(e){return new et(this.h,this.c,this.l-He*(e??1),this.opacity)},rgb(){return tt(this).rgb()}}));var nt=e=>()=>e;function rt(e,t){return function(n){return e+n*t}}function it(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function at(e,t){var n=t-e;return n?rt(e,n>180||n<-180?n-360*Math.round(n/360):n):nt(isNaN(e)?t:e)}function ot(e){return(e=+e)==1?st:function(t,n){return n-t?it(t,n,e):nt(isNaN(t)?n:t)}}function st(e,t){var n=t-e;return n?rt(e,n):nt(isNaN(e)?t:e)}var ct=(function e(t){var n=ot(t);function r(e,t){var r=n((e=Ee(e)).r,(t=Ee(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=st(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function lt(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function ut(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function dt(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o;for(o=0;o<r;++o)i[o]=bt(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(e){for(o=0;o<r;++o)a[o]=i[o](e);return a}}function ft(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function pt(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function mt(e,t){var n={},r={},i;for(i in(typeof e!=`object`||!e)&&(e={}),(typeof t!=`object`||!t)&&(t={}),t)i in e?n[i]=bt(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var ht=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,gt=new RegExp(ht.source,`g`);function _t(e){return function(){return e}}function vt(e){return function(t){return e(t)+``}}function yt(e,t){var n=ht.lastIndex=gt.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=ht.exec(e))&&(i=gt.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:pt(r,i)})),n=gt.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?vt(c[0].x):_t(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}function bt(e,t){var n=typeof t,r;return t==null||n===`boolean`?nt(t):(n===`number`?pt:n===`string`?(r=Se(t))?(t=r,ct):yt:t instanceof Se?ct:t instanceof Date?ft:ut(t)?lt:Array.isArray(t)?dt:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?mt:pt)(e,t)}function xt(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}function St(e){return function(t,n){var r=e((t=$e(t)).h,(n=$e(n)).h),i=st(t.c,n.c),a=st(t.l,n.l),o=st(t.opacity,n.opacity);return function(e){return t.h=r(e),t.c=i(e),t.l=a(e),t.opacity=o(e),t+``}}}var Ct=St(at);function wt(e,t){t===void 0&&(t=e,e=bt);for(var n=0,r=t.length-1,i=t[0],a=Array(r<0?0:r);n<r;)a[n]=e(i,i=t[++n]);return function(e){var t=Math.max(0,Math.min(r-1,Math.floor(e*=r)));return a[t](e-t)}}function Tt(e,t){for(var n=Array(t),r=0;r<t;++r)n[r]=e(r/(t-1));return n}function Et(e,t){return e==null||t==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function Dt(e,t){return e==null||t==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function Ot(e){let t,n,r;e.length===2?(t=e===Et||e===Dt?e:kt,n=e,r=e):(t=Et,n=(t,n)=>Et(e(t),n),r=(t,n)=>e(t)-n);function i(e,r,i=0,a=e.length){if(i<a){if(t(r,r)!==0)return a;do{let t=i+a>>>1;n(e[t],r)<0?i=t+1:a=t}while(i<a)}return i}function a(e,r,i=0,a=e.length){if(i<a){if(t(r,r)!==0)return a;do{let t=i+a>>>1;n(e[t],r)<=0?i=t+1:a=t}while(i<a)}return i}function o(e,t,n=0,a=e.length){let o=i(e,t,n,a-1);return o>n&&r(e[o-1],t)>-r(e[o],t)?o-1:o}return{left:i,center:o,right:a}}function kt(){return 0}function At(e){return e===null?NaN:+e}var jt=Ot(Et),H=jt.right;jt.left,Ot(At).center;function Mt(e,t){let n,r;if(t===void 0)for(let t of e)t!=null&&(n===void 0?t>=t&&(n=r=t):(n>t&&(n=t),r<t&&(r=t)));else{let i=-1;for(let a of e)(a=t(a,++i,e))!=null&&(n===void 0?a>=a&&(n=r=a):(n>a&&(n=a),r<a&&(r=a)))}return[n,r]}var Nt=class{constructor(){this._partials=new Float64Array(32),this._n=0}add(e){let t=this._partials,n=0;for(let r=0;r<this._n&&r<32;r++){let i=t[r],a=e+i,o=Math.abs(e)<Math.abs(i)?e-(a-i):i-(a-e);o&&(t[n++]=o),e=a}return t[n]=e,this._n=n+1,this}valueOf(){let e=this._partials,t=this._n,n,r,i,a=0;if(t>0){for(a=e[--t];t>0&&(n=a,r=e[--t],a=n+r,i=r-(a-n),!i););t>0&&(i<0&&e[t-1]<0||i>0&&e[t-1]>0)&&(r=i*2,n=a+r,r==n-a&&(a=n))}return a}},Pt=class extends Map{constructor(e,t=Lt){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(let[t,n]of e)this.set(t,n)}get(e){return super.get(U(this,e))}has(e){return super.has(U(this,e))}set(e,t){return super.set(Ft(this,e),t)}delete(e){return super.delete(It(this,e))}};function U({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):n}function Ft({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function It({_intern:e,_key:t},n){let r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function Lt(e){return typeof e==`object`&&e?e.valueOf():e}var Rt=Math.sqrt(50),zt=Math.sqrt(10),Bt=Math.sqrt(2);function Vt(e,t,n){let r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/10**i,o=a>=Rt?10:a>=zt?5:a>=Bt?2:1,s,c,l;return i<0?(l=10**-i/o,s=Math.round(e*l),c=Math.round(t*l),s/l<e&&++s,c/l>t&&--c,l=-l):(l=10**i*o,s=Math.round(e/l),c=Math.round(t/l),s*l<e&&++s,c*l>t&&--c),c<s&&.5<=n&&n<2?Vt(e,t,n*2):[s,c,l]}function Ht(e,t,n){if(t=+t,e=+e,n=+n,!(n>0))return[];if(e===t)return[e];let r=t<e,[i,a,o]=r?Vt(t,e,n):Vt(e,t,n);if(!(a>=i))return[];let s=a-i+1,c=Array(s);if(r)if(o<0)for(let e=0;e<s;++e)c[e]=(a-e)/-o;else for(let e=0;e<s;++e)c[e]=(a-e)*o;else if(o<0)for(let e=0;e<s;++e)c[e]=(i+e)/-o;else for(let e=0;e<s;++e)c[e]=(i+e)*o;return c}function Ut(e,t,n){return t=+t,e=+e,n=+n,Vt(e,t,n)[2]}function Wt(e,t,n){t=+t,e=+e,n=+n;let r=t<e,i=r?Ut(t,e,n):Ut(e,t,n);return(r?-1:1)*(i<0?1/-i:i)}function Gt(e,t,n=At){if(!(!(r=e.length)||isNaN(t=+t))){if(t<=0||r<2)return+n(e[0],0,e);if(t>=1)return+n(e[r-1],r-1,e);var r,i=(r-1)*t,a=Math.floor(i),o=+n(e[a],a,e);return o+(+n(e[a+1],a+1,e)-o)*(i-a)}}function*Kt(e){for(let t of e)yield*t}function qt(e){return Array.from(Kt(e))}function Jt(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((t-e)/n))|0,a=Array(i);++r<i;)a[r]=e+r*n;return a}function Yt(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e);break}return this}var W=Symbol(`implicit`);function G(){var e=new Pt,t=[],n=[],r=W;function i(i){let a=e.get(i);if(a===void 0){if(r!==W)return r;e.set(i,a=t.push(i)-1)}return n[a%n.length]}return i.domain=function(n){if(!arguments.length)return t.slice();t=[],e=new Pt;for(let r of n)e.has(r)||e.set(r,t.push(r)-1);return i},i.range=function(e){return arguments.length?(n=Array.from(e),i):n.slice()},i.unknown=function(e){return arguments.length?(r=e,i):r},i.copy=function(){return G(t,n).unknown(r)},Yt.apply(i,arguments),i}function Xt(e){return function(){return e}}function K(e){return+e}var Zt=[0,1];function Qt(e){return e}function $t(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:Xt(isNaN(t)?NaN:.5)}function en(e,t){var n;return e>t&&(n=e,e=t,t=n),function(n){return Math.max(e,Math.min(t,n))}}function tn(e,t,n){var r=e[0],i=e[1],a=t[0],o=t[1];return i<r?(r=$t(i,r),a=n(o,a)):(r=$t(r,i),a=n(a,o)),function(e){return a(r(e))}}function nn(e,t,n){var r=Math.min(e.length,t.length)-1,i=Array(r),a=Array(r),o=-1;for(e[r]<e[0]&&(e=e.slice().reverse(),t=t.slice().reverse());++o<r;)i[o]=$t(e[o],e[o+1]),a[o]=n(t[o],t[o+1]);return function(t){var n=H(e,t,1,r)-1;return a[n](i[n](t))}}function rn(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function an(){var e=Zt,t=Zt,n=bt,r,i,a,o=Qt,s,c,l;function u(){var n=Math.min(e.length,t.length);return o!==Qt&&(o=en(e[0],e[n-1])),s=n>2?nn:tn,c=l=null,d}function d(i){return i==null||isNaN(i=+i)?a:(c||=s(e.map(r),t,n))(r(o(i)))}return d.invert=function(n){return o(i((l||=s(t,e.map(r),pt))(n)))},d.domain=function(t){return arguments.length?(e=Array.from(t,K),u()):e.slice()},d.range=function(e){return arguments.length?(t=Array.from(e),u()):t.slice()},d.rangeRound=function(e){return t=Array.from(e),n=xt,u()},d.clamp=function(e){return arguments.length?(o=e?!0:Qt,u()):o!==Qt},d.interpolate=function(e){return arguments.length?(n=e,u()):n},d.unknown=function(e){return arguments.length?(a=e,d):a},function(e,t){return r=e,i=t,u()}}function on(){return an()(Qt,Qt)}function sn(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString(`en`).replace(/,/g,``):e.toString(10)}function cn(e,t){if(!isFinite(e)||e===0)return null;var n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf(`e`),r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function ln(e){return e=cn(Math.abs(e)),e?e[1]:NaN}function un(e,t){return function(n,r){for(var i=n.length,a=[],o=0,s=e[0],c=0;i>0&&s>0&&(c+s+1>r&&(s=Math.max(1,r-c)),a.push(n.substring(i-=s,i+s)),!((c+=s+1)>r));)s=e[o=(o+1)%e.length];return a.reverse().join(t)}}function dn(e){return function(t){return t.replace(/[0-9]/g,function(t){return e[+t]})}}var fn=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function pn(e){if(!(t=fn.exec(e)))throw Error(`invalid format: `+e);var t;return new mn({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}pn.prototype=mn.prototype;function mn(e){this.fill=e.fill===void 0?` `:e.fill+``,this.align=e.align===void 0?`>`:e.align+``,this.sign=e.sign===void 0?`-`:e.sign+``,this.symbol=e.symbol===void 0?``:e.symbol+``,this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?``:e.type+``}mn.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?`0`:``)+(this.width===void 0?``:Math.max(1,this.width|0))+(this.comma?`,`:``)+(this.precision===void 0?``:`.`+Math.max(0,this.precision|0))+(this.trim?`~`:``)+this.type};function hn(e){out:for(var t=e.length,n=1,r=-1,i;n<t;++n)switch(e[n]){case`.`:r=i=n;break;case`0`:r===0&&(r=n),i=n;break;default:if(!+e[n])break out;r>0&&(r=0);break}return r>0?e.slice(0,r)+e.slice(i+1):e}var gn;function _n(e,t){var n=cn(e,t);if(!n)return gn=void 0,e.toPrecision(t);var r=n[0],i=n[1],a=i-(gn=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return a===o?r:a>o?r+Array(a-o+1).join(`0`):a>0?r.slice(0,a)+`.`+r.slice(a):`0.`+Array(1-a).join(`0`)+cn(e,Math.max(0,t+a-1))[0]}function vn(e,t){var n=cn(e,t);if(!n)return e+``;var r=n[0],i=n[1];return i<0?`0.`+Array(-i).join(`0`)+r:r.length>i+1?r.slice(0,i+1)+`.`+r.slice(i+1):r+Array(i-r.length+2).join(`0`)}var yn={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+``,d:sn,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>vn(e*100,t),r:vn,s:_n,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function bn(e){return e}var xn=Array.prototype.map,Sn=[`y`,`z`,`a`,`f`,`p`,`n`,`µ`,`m`,``,`k`,`M`,`G`,`T`,`P`,`E`,`Z`,`Y`];function Cn(e){var t=e.grouping===void 0||e.thousands===void 0?bn:un(xn.call(e.grouping,Number),e.thousands+``),n=e.currency===void 0?``:e.currency[0]+``,r=e.currency===void 0?``:e.currency[1]+``,i=e.decimal===void 0?`.`:e.decimal+``,a=e.numerals===void 0?bn:dn(xn.call(e.numerals,String)),o=e.percent===void 0?`%`:e.percent+``,s=e.minus===void 0?`−`:e.minus+``,c=e.nan===void 0?`NaN`:e.nan+``;function l(e,l){e=pn(e);var u=e.fill,d=e.align,f=e.sign,p=e.symbol,m=e.zero,h=e.width,g=e.comma,_=e.precision,v=e.trim,y=e.type;y===`n`?(g=!0,y=`g`):yn[y]||(_===void 0&&(_=12),v=!0,y=`g`),(m||u===`0`&&d===`=`)&&(m=!0,u=`0`,d=`=`);var b=(l&&l.prefix!==void 0?l.prefix:``)+(p===`$`?n:p===`#`&&/[boxX]/.test(y)?`0`+y.toLowerCase():``),x=(p===`$`?r:/[%p]/.test(y)?o:``)+(l&&l.suffix!==void 0?l.suffix:``),S=yn[y],C=/[defgprs%]/.test(y);_=_===void 0?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,_)):Math.max(0,Math.min(20,_));function w(e){var n=b,r=x,o,l,p;if(y===`c`)r=S(e)+r,e=``;else{e=+e;var w=e<0||1/e<0;if(e=isNaN(e)?c:S(Math.abs(e),_),v&&(e=hn(e)),w&&+e==0&&f!==`+`&&(w=!1),n=(w?f===`(`?f:s:f===`-`||f===`(`?``:f)+n,r=(y===`s`&&!isNaN(e)&&gn!==void 0?Sn[8+gn/3]:``)+r+(w&&f===`(`?`)`:``),C){for(o=-1,l=e.length;++o<l;)if(p=e.charCodeAt(o),48>p||p>57){r=(p===46?i+e.slice(o+1):e.slice(o))+r,e=e.slice(0,o);break}}}g&&!m&&(e=t(e,1/0));var T=n.length+e.length+r.length,E=T<h?Array(h-T+1).join(u):``;switch(g&&m&&(e=t(E+e,E.length?h-r.length:1/0),E=``),d){case`<`:e=n+e+r+E;break;case`=`:e=n+E+e+r;break;case`^`:e=E.slice(0,T=E.length>>1)+n+e+r+E.slice(T);break;default:e=E+n+e+r;break}return a(e)}return w.toString=function(){return e+``},w}function u(e,t){var n=Math.max(-8,Math.min(8,Math.floor(ln(t)/3)))*3,r=10**-n,i=l((e=pn(e),e.type=`f`,e),{suffix:Sn[8+n/3]});return function(e){return i(r*e)}}return{format:l,formatPrefix:u}}var wn,Tn,En;Dn({thousands:`,`,grouping:[3],currency:[`$`,``]});function Dn(e){return wn=Cn(e),Tn=wn.format,En=wn.formatPrefix,wn}function On(e){return Math.max(0,-ln(Math.abs(e)))}function kn(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(ln(t)/3)))*3-ln(Math.abs(e)))}function An(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,ln(t)-ln(e))+1}function jn(e,t,n,r){var i=Wt(e,t,n),a;switch(r=pn(r??`,f`),r.type){case`s`:var o=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(a=kn(i,o))&&(r.precision=a),En(r,o);case``:case`e`:case`g`:case`p`:case`r`:r.precision==null&&!isNaN(a=An(i,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=a-(r.type===`e`));break;case`f`:case`%`:r.precision==null&&!isNaN(a=On(i))&&(r.precision=a-(r.type===`%`)*2);break}return Tn(r)}function Mn(e){var t=e.domain;return e.ticks=function(e){var n=t();return Ht(n[0],n[n.length-1],e??10)},e.tickFormat=function(e,n){var r=t();return jn(r[0],r[r.length-1],e??10,n)},e.nice=function(n){n??=10;var r=t(),i=0,a=r.length-1,o=r[i],s=r[a],c,l,u=10;for(s<o&&(l=o,o=s,s=l,l=i,i=a,a=l);u-- >0;){if(l=Ut(o,s,n),l===c)return r[i]=o,r[a]=s,t(r);if(l>0)o=Math.floor(o/l)*l,s=Math.ceil(s/l)*l;else if(l<0)o=Math.ceil(o*l)/l,s=Math.floor(s*l)/l;else break;c=l}return e},e}function Nn(){var e=on();return e.copy=function(){return rn(e,Nn())},Yt.apply(e,arguments),Mn(e)}function Pn(){var e=[],t=[],n=[],r;function i(){var r=0,i=Math.max(1,t.length);for(n=Array(i-1);++r<i;)n[r-1]=Gt(e,r/i);return a}function a(e){return e==null||isNaN(e=+e)?r:t[H(n,e)]}return a.invertExtent=function(r){var i=t.indexOf(r);return i<0?[NaN,NaN]:[i>0?n[i-1]:e[0],i<n.length?n[i]:e[e.length-1]]},a.domain=function(t){if(!arguments.length)return e.slice();e=[];for(let n of t)n!=null&&!isNaN(n=+n)&&e.push(n);return e.sort(Et),i()},a.range=function(e){return arguments.length?(t=Array.from(e),i()):t.slice()},a.unknown=function(e){return arguments.length?(r=e,a):r},a.quantiles=function(){return n.slice()},a.copy=function(){return Pn().domain(e).range(t).unknown(r)},Yt.apply(a,arguments)}function Fn(){var e=0,t=1,n=1,r=[.5],i=[0,1],a;function o(e){return e!=null&&e<=e?i[H(r,e,0,n)]:a}function s(){var i=-1;for(r=Array(n);++i<n;)r[i]=((i+1)*t-(i-n)*e)/(n+1);return o}return o.domain=function(n){return arguments.length?([e,t]=n,e=+e,t=+t,s()):[e,t]},o.range=function(e){return arguments.length?(n=(i=Array.from(e)).length-1,s()):i.slice()},o.invertExtent=function(a){var o=i.indexOf(a);return o<0?[NaN,NaN]:o<1?[e,r[0]]:o>=n?[r[n-1],t]:[r[o-1],r[o]]},o.unknown=function(e){return arguments.length&&(a=e),o},o.thresholds=function(){return r.slice()},o.copy=function(){return Fn().domain([e,t]).range(i).unknown(a)},Yt.apply(Mn(o),arguments)}var In=6371008.8;In*100,In*100,360/(2*Math.PI),In*3.28084,In*39.37,In/1e3,In/1e3,In/1609.344,In*1e3,In*1e3,In/1852,In*1.0936;function Ln(e,t,n={}){let r={type:`Feature`};return(n.id===0||n.id)&&(r.id=n.id),n.bbox&&(r.bbox=n.bbox),r.properties=t||{},r.geometry=e,r}function Rn(e,t,n={}){for(let t of e){if(t.length<4)throw Error(`Each LinearRing of a Polygon must have 4 or more Positions.`);if(t[t.length-1].length!==t[0].length)throw Error(`First and last Position are not equivalent.`);for(let e=0;e<t[t.length-1].length;e++)if(t[t.length-1][e]!==t[0][e])throw Error(`First and last Position are not equivalent.`)}return Ln({type:`Polygon`,coordinates:e},t,n)}function zn(e,t,n={}){if(e.length<2)throw Error(`coordinates must be an array of two or more positions`);return Ln({type:`LineString`,coordinates:e},t,n)}function Bn(e,t={}){let n={type:`FeatureCollection`};return t.id&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.features=e,n}function Vn(e,t,n={}){return Ln({type:`MultiLineString`,coordinates:e},t,n)}function Hn(e,t,n={}){return Ln({type:`MultiPolygon`,coordinates:e},t,n)}function Un(e,t,n){if(e!==null)for(var r,i,a,o,s,c,l,u=0,d=0,f,p=e.type,m=p===`FeatureCollection`,h=p===`Feature`,g=m?e.features.length:1,_=0;_<g;_++){l=m?e.features[_].geometry:h?e.geometry:e,f=l?l.type===`GeometryCollection`:!1,s=f?l.geometries.length:1;for(var v=0;v<s;v++){var y=0,b=0;if(o=f?l.geometries[v]:l,o!==null){c=o.coordinates;var x=o.type;switch(u=n&&(x===`Polygon`||x===`MultiPolygon`)?1:0,x){case null:break;case`Point`:if(t(c,d,_,y,b)===!1)return!1;d++,y++;break;case`LineString`:case`MultiPoint`:for(r=0;r<c.length;r++){if(t(c[r],d,_,y,b)===!1)return!1;d++,x===`MultiPoint`&&y++}x===`LineString`&&y++;break;case`Polygon`:case`MultiLineString`:for(r=0;r<c.length;r++){for(i=0;i<c[r].length-u;i++){if(t(c[r][i],d,_,y,b)===!1)return!1;d++}x===`MultiLineString`&&y++,x===`Polygon`&&b++}x===`Polygon`&&y++;break;case`MultiPolygon`:for(r=0;r<c.length;r++){for(b=0,i=0;i<c[r].length;i++){for(a=0;a<c[r][i].length-u;a++){if(t(c[r][i][a],d,_,y,b)===!1)return!1;d++}b++}y++}break;case`GeometryCollection`:for(r=0;r<o.geometries.length;r++)if(Un(o.geometries[r],t,n)===!1)return!1;break;default:throw Error(`Unknown Geometry Type`)}}}}}function Wn(e,t){var n,r,i,a,o,s,c,l,u,d,f=0,p=e.type===`FeatureCollection`,m=e.type===`Feature`,h=p?e.features.length:1;for(n=0;n<h;n++){for(s=p?e.features[n].geometry:m?e.geometry:e,l=p?e.features[n].properties:m?e.properties:{},u=p?e.features[n].bbox:m?e.bbox:void 0,d=p?e.features[n].id:m?e.id:void 0,c=s?s.type===`GeometryCollection`:!1,o=c?s.geometries.length:1,i=0;i<o;i++){if(a=c?s.geometries[i]:s,a===null){if(t(null,f,l,u,d)===!1)return!1;continue}switch(a.type){case`Point`:case`LineString`:case`MultiPoint`:case`Polygon`:case`MultiLineString`:case`MultiPolygon`:if(t(a,f,l,u,d)===!1)return!1;break;case`GeometryCollection`:for(r=0;r<a.geometries.length;r++)if(t(a.geometries[r],f,l,u,d)===!1)return!1;break;default:throw Error(`Unknown Geometry Type`)}}f++}}function Gn(e,t,n){var r=n;return Wn(e,function(e,i,a,o,s){r=i===0&&n===void 0?e:t(r,e,i,a,o,s)}),r}function Kn(e,t){t||={},t.iterations=t.iterations||1;let{iterations:n}=t,r=[];if(!e)throw Error(`inputPolys is required`);return Wn(e,function(e,t,i){if(e.type===`Polygon`){let t=[[]];for(let r=0;r<n;r++){let n=[],i=e;r>0&&(i=Rn(t).geometry),qn(i,n),t=n.slice(0)}r.push(Rn(t,i))}else if(e.type===`MultiPolygon`){let t=[[[]]];for(let r=0;r<n;r++){let n=[],i=e;r>0&&(i=Hn(t).geometry),Jn(i,n),t=n.slice(0)}r.push(Hn(t,i))}else throw Error(`geometry is invalid, must be Polygon or MultiPolygon`)}),Bn(r)}function qn(e,t){var n,r;Un(e,function(e,i,a,o,s){if(r!==s)t.push([]);else{var c=n[0],l=n[1],u=e[0],d=e[1];t[s].push([.75*c+.25*u,.75*l+.25*d]),t[s].push([.25*c+.75*u,.25*l+.75*d])}n=e,r=s},!1),t.forEach(function(e){e.push(e[0])})}function Jn(e,t){let n,r,i;Un(e,function(e,a,o,s,c){if(r!==s)t.push([[]]);else if(i!==c)t[s].push([]);else{var l=n[0],u=n[1],d=e[0],f=e[1];t[s][c].push([.75*l+.25*d,.75*u+.25*f]),t[s][c].push([.25*l+.75*d,.25*u+.75*f])}n=e,r=s,i=c},!1),t.forEach(function(e){e.forEach(function(e){e.push(e[0])})})}function Yn(e){return e.type===`Feature`?e.geometry:e}function Xn(e,t,n){var r=e.length,i=$n(e[0],t),a=[],o,s,c;let l,u;for(n||=[],o=1;o<r;o++){for(l=e[o-1],u=e[o],s=c=$n(u,t);;)if(!(i|s)){a.push(l),s===c?o===r-1&&a.push(u):(a.push(u),o<r-1&&(n.push(a),a=[]));break}else if(i&s)break;else i?(l=Qn(l,u,i,t),i=$n(l,t)):(u=Qn(l,u,s,t),s=$n(u,t));i=c}return a.length&&n.push(a),n}function Zn(e,t){var n,r,i,a,o,s,c;for(r=1;r<=8;r*=2){for(n=[],i=e[e.length-1],a=!($n(i,t)&r),o=0;o<e.length;o++)s=e[o],c=!($n(s,t)&r),c!==a&&n.push(Qn(i,s,r,t)),c&&n.push(s),i=s,a=c;if(e=n,!e.length)break}return n}function Qn(e,t,n,r){return n&8?[e[0]+(t[0]-e[0])*(r[3]-e[1])/(t[1]-e[1]),r[3]]:n&4?[e[0]+(t[0]-e[0])*(r[1]-e[1])/(t[1]-e[1]),r[1]]:n&2?[r[2],e[1]+(t[1]-e[1])*(r[2]-e[0])/(t[0]-e[0])]:n&1?[r[0],e[1]+(t[1]-e[1])*(r[0]-e[0])/(t[0]-e[0])]:null}function $n(e,t){var n=0;return e[0]<t[0]?n|=1:e[0]>t[2]&&(n|=2),e[1]<t[1]?n|=4:e[1]>t[3]&&(n|=8),n}function er(e,t){let n=Yn(e),r=n.type,i=e.type===`Feature`?e.properties:{},a=n.coordinates;switch(r){case`LineString`:case`MultiLineString`:{let e=[];return r===`LineString`&&(a=[a]),a.forEach(n=>{Xn(n,t,e)}),e.length===1?zn(e[0],i):Vn(e,i)}case`Polygon`:return Rn(tr(a,t),i);case`MultiPolygon`:return Hn(a.map(e=>tr(e,t)),i);default:throw Error(`geometry `+r+` not supported`)}}function tr(e,t){let n=[];for(let r of e){let e=Zn(r,t);e.length>0&&((e[0][0]!==e[e.length-1][0]||e[0][1]!==e[e.length-1][1])&&e.push(e[0]),e.length>=4&&n.push(e))}return n}var nr=er;function rr(e,t){let n=[],r=Math.PI*2/100;for(let i=0;i<100;i++)n.push(ar(e,t,i*r));if(or(e,t)){let e=n[0],t=n[n.length-1],r=(t[0]+e[0]-360)/2,i=(e[1]+t[1])/2;n.push([r,i]),n.push([r,90]),n.push([r+360,90]),n.push([r+360,i])}if(sr(e,t)){let e=n[49],t=n[50],r=(t[0]+e[0]-360)/2,i=(e[1]+t[1])/2;n.splice(50,0,[r+360,i],[r+360,-90],[r,-90],[r,i])}return n.push(n[0]),n}function ir(e,t,n){let r=[],i=t/100;for(let t=0;t<=100;t++)r.push(ar(e,t*i,x(n)));return nr(zn(r),[-1/0,-85.051129,1/0,85.051129]).geometry.coordinates}function ar(e,t,n){let r=t/6378.1,i=x(e.lng),a=x(e.lat),o=Math.asin(Math.sin(a)*Math.cos(r)+Math.cos(a)*Math.sin(r)*Math.cos(n));return[S(i+Math.atan2(Math.sin(n)*Math.sin(r)*Math.cos(a),Math.cos(r)-Math.sin(a)*Math.sin(o))),S(o)]}function or(e,t){return C(e,{lng:0,lat:90})/1e3<t}function sr(e,t){return C(e,{lng:0,lat:-90})/1e3<t}function cr(e){let{polygonType:t}=e,n=typeof e.anchorPoints?.[0]?.[0]==`number`?[e.anchorPoints]:e.anchorPoints;return t===`smooth`?Kn(Rn(n),{iterations:4}).features?.[0]?.geometry?.coordinates??n.slice():n.slice()}function lr(e,t){return`${e}-${P(`${t.vectorUrl}/${t.sourceLayerId}`)}`}function ur(e){return`custom-area-${P(e.vectorUrl)}`}function dr(e,t){return e.reduce((e,n)=>{let r=n.dataBindings?.[t];return typeof r==`object`&&r&&r.t===`n`?e.push(r.v):typeof r==`number`?e.push(r):typeof r==`string`&&r&&e.push(b.test(r)?Number(r):r),e},[])}function fr(e,t){let n=e.length;if(n<2)return 0;let r=t.projectWithScaleCorrection(e[n-1]),i=t.projectWithScaleCorrection(e[n-2]),a=r.x-i.x,o=i.y-r.y;return(90-180/Math.PI*Math.atan2(o,a)+360)%360}var pr=[[`#EDF8E9`,`#BAE4B3`,`#74C476`,`#31A354`,`#006D2C`],[`#EFF3FF`,`#BDD7E7`,`#6BAED6`,`#3182BD`,`#08519C`],[`#F0F9E8`,`#BAE4BC`,`#7BCCC4`,`#43A2CA`,`#0868AC`],[`#EDF8FB`,`#B3CDE3`,`#8C96C6`,`#8856A7`,`#810F7C`],[`#FEF0D9`,`#FDCC8A`,`#FC8D59`,`#E34A33`,`#B30000`],[`#FEEBE2`,`#FBB4B9`,`#F768A1`,`#C51B8A`,`#7A0177`],[`#D7191C`,`#FDAE61`,`#FFFFBF`,`#ABDDA4`,`#2B83BA`],[`#7B3294`,`#C2A5CF`,`#F7F7F7`,`#A6DBA0`,`#008837`]],mr=[],hr=[/transparent/,/#[0-9a-fA-F]{3,4}/,/#[0-9a-fA-F]{6}/,/#[0-9a-fA-F]{8}/,/rgba?\(\s*(?:(?:\d{1,3}%?|none)\s*,\s*){2}(?:\d{1,3}%?|none)(?:\s*,\s*(?:0|1|0?\.\d+|\d+%|none))?\s*\)/,/rgba?\(\s*(?:\d{1,3}%?|none)\s+(?:\d{1,3}%?|none)\s+(?:\d{1,3}%?|none)(?:\s*\/\s*(?:0|1|0?\.\d+|\d+%|none))?\s*\)/,/hsla?\(\s*(?:[+-]?\d*\.?\d+(?:deg|grad|rad|turn)?|none)\s*,\s*(?:\d{1,3}%|none)\s*,\s*(?:\d{1,3}%|none)(?:\s*,\s*(?:0|1|0?\.\d+|\d+%|none))?\s*\)/,/hsla?\(\s*(?:[+-]?\d*\.?\d+(?:deg|grad|rad|turn)?|none)\s+(?:\d{1,3}%|none)\s+(?:\d{1,3}%|none)(?:\s*\/\s*(?:0|1|0?\.\d+|\d+%|none))?\s*\)/].map(e=>e.toString().replace(/^\/|\/$/g,``)).join(`|`),gr=RegExp(`^\\s*(${hr})\\s*$`);function _r(e,t){let[n,r]=Mt(e),i=t.length;return Jt(i).map(e=>n+e*(r-n)/(i-1))}var vr={linear:(e,t)=>Nn(_r(e,t),t).interpolate(Ct).nice(4),quantile:(e,t)=>Pn(e,t),quantize:(e,t)=>Fn(Mt(e),t).nice(),categorical:(e,t)=>G(e,t)};function yr(e){if(e.choropleth){let t=br(e),n=Cr(e.fillColor);if(t&&n){let{choropleth:r}=e,i=r.categoricalColors[n],a=r.colorMode===`categorical`?t.map(e=>i.values[e]):xr(r.lowerColor,r.upperColor,r.colorMode===`linear`?void 0:r.colorCount);return vr[r.colorMode](t,a)}}}function br(e){if(e.choropleth){let t=e.fillColor?.match(/\$\{([^}]+)}/)?.[1];if(t){let n=dr(Object.values(e.models),t);if(!n.length||n.some(e=>typeof e!=`string`||!gr.test(e)))return e.choropleth.colorMode===`categorical`?Array.from(new Set(n)):n}}}function xr(e,t,n){let r=pr.find(n=>n[0]===e&&n[n.length-1]===t)??mr.find(n=>n[0]===e&&n[n.length-1]===t);return r?Tt(wt(Ct,r),n??r.length):Tt(Ct(e,t),n??2)}function Sr(e,t){let n=t?dr(e,t):void 0;return n?.length?n.every(e=>typeof e==`number`)?`number`:n.every(e=>typeof e==`string`&&gr.test(e))?`color`:`string`:void 0}function Cr(e){return e?.match(/\$\{([^}]+)}/)?.[1]}function wr(e){let t=Object.create(null);for(let n in e){let r=e[n];t[r]=r in t?null:n}return t}function Tr(e,t){let n=t?Sr(e,t):void 0;return n!==void 0&&n!==`color`}function Er(){return navigator.userAgent.toLowerCase().indexOf(`mobile`)>=0}function Dr(){return window.InstallTrigger!==void 0}(function(){var e=function(e){return e.map(function(e){return{type:e.type,values:Array.prototype.slice.call(e.values)}})},t=function(e){var t=[],n=null,r=null,i=null,a=null;return e.forEach(function(e){var o=e.type;if(o===`M`){var s=e.values[0],c=e.values[1];t.push({type:`M`,values:[s,c]}),i=s,a=c,n=s,r=c}else if(o===`m`){var s=n+e.values[0],c=r+e.values[1];t.push({type:`M`,values:[s,c]}),i=s,a=c,n=s,r=c}else if(o===`L`){var s=e.values[0],c=e.values[1];t.push({type:`L`,values:[s,c]}),n=s,r=c}else if(o===`l`){var s=n+e.values[0],c=r+e.values[1];t.push({type:`L`,values:[s,c]}),n=s,r=c}else if(o===`C`){var l=e.values[0],u=e.values[1],d=e.values[2],f=e.values[3],s=e.values[4],c=e.values[5];t.push({type:`C`,values:[l,u,d,f,s,c]}),n=s,r=c}else if(o===`c`){var l=n+e.values[0],u=r+e.values[1],d=n+e.values[2],f=r+e.values[3],s=n+e.values[4],c=r+e.values[5];t.push({type:`C`,values:[l,u,d,f,s,c]}),n=s,r=c}else if(o===`Q`){var l=e.values[0],u=e.values[1],s=e.values[2],c=e.values[3];t.push({type:`Q`,values:[l,u,s,c]}),n=s,r=c}else if(o===`q`){var l=n+e.values[0],u=r+e.values[1],s=n+e.values[2],c=r+e.values[3];t.push({type:`Q`,values:[l,u,s,c]}),n=s,r=c}else if(o===`A`){var s=e.values[5],c=e.values[6];t.push({type:`A`,values:[e.values[0],e.values[1],e.values[2],e.values[3],e.values[4],s,c]}),n=s,r=c}else if(o===`a`){var s=n+e.values[5],c=r+e.values[6];t.push({type:`A`,values:[e.values[0],e.values[1],e.values[2],e.values[3],e.values[4],s,c]}),n=s,r=c}else if(o===`H`){var s=e.values[0];t.push({type:`H`,values:[s]}),n=s}else if(o===`h`){var s=n+e.values[0];t.push({type:`H`,values:[s]}),n=s}else if(o===`V`){var c=e.values[0];t.push({type:`V`,values:[c]}),r=c}else if(o===`v`){var c=r+e.values[0];t.push({type:`V`,values:[c]}),r=c}else if(o===`S`){var d=e.values[0],f=e.values[1],s=e.values[2],c=e.values[3];t.push({type:`S`,values:[d,f,s,c]}),n=s,r=c}else if(o===`s`){var d=n+e.values[0],f=r+e.values[1],s=n+e.values[2],c=r+e.values[3];t.push({type:`S`,values:[d,f,s,c]}),n=s,r=c}else if(o===`T`){var s=e.values[0],c=e.values[1];t.push({type:`T`,values:[s,c]}),n=s,r=c}else if(o===`t`){var s=n+e.values[0],c=r+e.values[1];t.push({type:`T`,values:[s,c]}),n=s,r=c}else (o===`Z`||o===`z`)&&(t.push({type:`Z`,values:[]}),n=i,r=a)}),t},n=function(e){var t=[],n=null,i=null,a=null,o=null,s=null,c=null,l=null;return e.forEach(function(e){if(e.type===`M`){var u=e.values[0],d=e.values[1];t.push({type:`M`,values:[u,d]}),c=u,l=d,o=u,s=d}else if(e.type===`C`){var f=e.values[0],p=e.values[1],m=e.values[2],h=e.values[3],u=e.values[4],d=e.values[5];t.push({type:`C`,values:[f,p,m,h,u,d]}),i=m,a=h,o=u,s=d}else if(e.type===`L`){var u=e.values[0],d=e.values[1];t.push({type:`L`,values:[u,d]}),o=u,s=d}else if(e.type===`H`){var u=e.values[0];t.push({type:`L`,values:[u,s]}),o=u}else if(e.type===`V`){var d=e.values[0];t.push({type:`L`,values:[o,d]}),s=d}else if(e.type===`S`){var m=e.values[0],h=e.values[1],u=e.values[2],d=e.values[3],g,_;n===`C`||n===`S`?(g=o+(o-i),_=s+(s-a)):(g=o,_=s),t.push({type:`C`,values:[g,_,m,h,u,d]}),i=m,a=h,o=u,s=d}else if(e.type===`T`){var u=e.values[0],d=e.values[1],f,p;n===`Q`||n===`T`?(f=o+(o-i),p=s+(s-a)):(f=o,p=s);var g=o+2*(f-o)/3,_=s+2*(p-s)/3,v=u+2*(f-u)/3,y=d+2*(p-d)/3;t.push({type:`C`,values:[g,_,v,y,u,d]}),i=f,a=p,o=u,s=d}else if(e.type===`Q`){var f=e.values[0],p=e.values[1],u=e.values[2],d=e.values[3],g=o+2*(f-o)/3,_=s+2*(p-s)/3,v=u+2*(f-u)/3,y=d+2*(p-d)/3;t.push({type:`C`,values:[g,_,v,y,u,d]}),i=f,a=p,o=u,s=d}else if(e.type===`A`){var b=Math.abs(e.values[0]),x=Math.abs(e.values[1]),S=e.values[2],C=e.values[3],w=e.values[4],u=e.values[5],d=e.values[6];b===0||x===0?(t.push({type:`C`,values:[o,s,u,d,u,d]}),o=u,s=d):(o!==u||s!==d)&&(r(o,s,u,d,b,x,S,C,w).forEach(function(e){t.push({type:`C`,values:e})}),o=u,s=d)}else e.type===`Z`&&(t.push(e),o=c,s=l);n=e.type}),t},r=function(e,t,n,i,a,o,s,c,l,u){var d=function(e){return Math.PI*e/180},f=function(e,t,n){return{x:e*Math.cos(n)-t*Math.sin(n),y:e*Math.sin(n)+t*Math.cos(n)}},p=d(s),m=[],h,g,_,v;if(u)h=u[0],g=u[1],_=u[2],v=u[3];else{var y=f(e,t,-p);e=y.x,t=y.y;var b=f(n,i,-p);n=b.x,i=b.y;var x=(e-n)/2,S=(t-i)/2,C=x*x/(a*a)+S*S/(o*o);C>1&&(C=Math.sqrt(C),a=C*a,o=C*o);var w=c===l?-1:1,T=a*a,E=o*o,D=T*E-T*S*S-E*x*x,O=T*S*S+E*x*x,k=w*Math.sqrt(Math.abs(D/O));_=k*a*S/o+(e+n)/2,v=k*-o*x/a+(t+i)/2,h=Math.asin(parseFloat(((t-v)/o).toFixed(9))),g=Math.asin(parseFloat(((i-v)/o).toFixed(9))),e<_&&(h=Math.PI-h),n<_&&(g=Math.PI-g),h<0&&(h=Math.PI*2+h),g<0&&(g=Math.PI*2+g),l&&h>g&&(h-=Math.PI*2),!l&&g>h&&(g-=Math.PI*2)}var A=g-h;if(Math.abs(A)>Math.PI*120/180){var j=g,M=n,N=i;g=l&&g>h?h+Math.PI*120/180*1:h+Math.PI*120/180*-1,n=_+a*Math.cos(g),i=v+o*Math.sin(g),m=r(n,i,M,N,a,o,s,0,l,[g,j,_,v])}A=g-h;var P=Math.cos(h),ee=Math.sin(h),te=Math.cos(g),F=Math.sin(g),ne=Math.tan(A/4),re=4/3*a*ne,ie=4/3*o*ne,ae=[e,t],oe=[e+re*ee,t-ie*P],se=[n+re*F,i-ie*te],ce=[n,i];if(oe[0]=2*ae[0]-oe[0],oe[1]=2*ae[1]-oe[1],u)return[oe,se,ce].concat(m);m=[oe,se,ce].concat(m);for(var le=[],ue=0;ue<m.length;ue+=3){var a=f(m[ue][0],m[ue][1],p),o=f(m[ue+1][0],m[ue+1][1],p),de=f(m[ue+2][0],m[ue+2][1],p);le.push([a.x,a.y,o.x,o.y,de.x,de.y])}return le};let i=SVGPathElement.prototype.getPathData!==void 0&&SVGPathElement.prototype.setPathData!==void 0;if(i)try{document.createElementNS(`http://www.w3.org/2000/svg`,`path`).setPathData([{type:`M`,values:[0,0]}])}catch{i=!1}if(i===!1){var a={Z:`Z`,M:`M`,L:`L`,C:`C`,Q:`Q`,A:`A`,H:`H`,V:`V`,S:`S`,T:`T`,z:`Z`,m:`m`,l:`l`,c:`c`,q:`q`,a:`a`,h:`h`,v:`v`,s:`s`,t:`t`},o=function(e){this._string=e,this._currentIndex=0,this._endIndex=this._string.length,this._prevCommand=null,this._skipOptionalSpaces()},s=window.navigator.userAgent.indexOf(`MSIE `)!==-1;o.prototype={parseSegment:function(){var e=this._string[this._currentIndex],t=a[e]?a[e]:null;if(t===null){if(this._prevCommand===null||(t=(e===`+`||e===`-`||e===`.`||e>=`0`&&e<=`9`)&&this._prevCommand!==`Z`?this._prevCommand===`M`?`L`:this._prevCommand===`m`?`l`:this._prevCommand:null,t===null))return null}else this._currentIndex+=1;this._prevCommand=t;var n=null,r=t.toUpperCase();return r===`H`||r===`V`?n=[this._parseNumber()]:r===`M`||r===`L`||r===`T`?n=[this._parseNumber(),this._parseNumber()]:r===`S`||r===`Q`?n=[this._parseNumber(),this._parseNumber(),this._parseNumber(),this._parseNumber()]:r===`C`?n=[this._parseNumber(),this._parseNumber(),this._parseNumber(),this._parseNumber(),this._parseNumber(),this._parseNumber()]:r===`A`?n=[this._parseNumber(),this._parseNumber(),this._parseNumber(),this._parseArcFlag(),this._parseArcFlag(),this._parseNumber(),this._parseNumber()]:r===`Z`&&(this._skipOptionalSpaces(),n=[]),n===null||n.indexOf(null)>=0?null:{type:t,values:n}},hasMoreData:function(){return this._currentIndex<this._endIndex},peekSegmentType:function(){var e=this._string[this._currentIndex];return a[e]?a[e]:null},initialCommandIsMoveTo:function(){if(!this.hasMoreData())return!0;var e=this.peekSegmentType();return e===`M`||e===`m`},_isCurrentSpace:function(){var e=this._string[this._currentIndex];return e<=` `&&(e===` `||e===`
689
+ `||e===` `||e===`\r`||e===`\f`)},_skipOptionalSpaces:function(){for(;this._currentIndex<this._endIndex&&this._isCurrentSpace();)this._currentIndex+=1;return this._currentIndex<this._endIndex},_skipOptionalSpacesOrDelimiter:function(){return this._currentIndex<this._endIndex&&!this._isCurrentSpace()&&this._string[this._currentIndex]!==`,`?!1:(this._skipOptionalSpaces()&&this._currentIndex<this._endIndex&&this._string[this._currentIndex]===`,`&&(this._currentIndex+=1,this._skipOptionalSpaces()),this._currentIndex<this._endIndex)},_parseNumber:function(){var e=0,t=0,n=1,r=0,i=1,a=1,o=this._currentIndex;if(this._skipOptionalSpaces(),this._currentIndex<this._endIndex&&this._string[this._currentIndex]===`+`?this._currentIndex+=1:this._currentIndex<this._endIndex&&this._string[this._currentIndex]===`-`&&(this._currentIndex+=1,i=-1),this._currentIndex===this._endIndex||(this._string[this._currentIndex]<`0`||this._string[this._currentIndex]>`9`)&&this._string[this._currentIndex]!==`.`)return null;for(var s=this._currentIndex;this._currentIndex<this._endIndex&&this._string[this._currentIndex]>=`0`&&this._string[this._currentIndex]<=`9`;)this._currentIndex+=1;if(this._currentIndex!==s)for(var c=this._currentIndex-1,l=1;c>=s;)t+=l*(this._string[c]-`0`),--c,l*=10;if(this._currentIndex<this._endIndex&&this._string[this._currentIndex]===`.`){if(this._currentIndex+=1,this._currentIndex>=this._endIndex||this._string[this._currentIndex]<`0`||this._string[this._currentIndex]>`9`)return null;for(;this._currentIndex<this._endIndex&&this._string[this._currentIndex]>=`0`&&this._string[this._currentIndex]<=`9`;)n*=10,r+=(this._string.charAt(this._currentIndex)-`0`)/n,this._currentIndex+=1}if(this._currentIndex!==o&&this._currentIndex+1<this._endIndex&&(this._string[this._currentIndex]===`e`||this._string[this._currentIndex]===`E`)&&this._string[this._currentIndex+1]!==`x`&&this._string[this._currentIndex+1]!==`m`){if(this._currentIndex+=1,this._string[this._currentIndex]===`+`?this._currentIndex+=1:this._string[this._currentIndex]===`-`&&(this._currentIndex+=1,a=-1),this._currentIndex>=this._endIndex||this._string[this._currentIndex]<`0`||this._string[this._currentIndex]>`9`)return null;for(;this._currentIndex<this._endIndex&&this._string[this._currentIndex]>=`0`&&this._string[this._currentIndex]<=`9`;)e*=10,e+=this._string[this._currentIndex]-`0`,this._currentIndex+=1}var u=t+r;return u*=i,e&&(u*=10**(a*e)),o===this._currentIndex?null:(this._skipOptionalSpacesOrDelimiter(),u)},_parseArcFlag:function(){if(this._currentIndex>=this._endIndex)return null;var e=null,t=this._string[this._currentIndex];if(this._currentIndex+=1,t===`0`)e=0;else if(t===`1`)e=1;else return null;return this._skipOptionalSpacesOrDelimiter(),e}};var c=function(e){if(!e||e.length===0)return[];var t=new o(e),n=[];if(t.initialCommandIsMoveTo())for(;t.hasMoreData();){var r=t.parseSegment();if(r===null)break;n.push(r)}return n},l=SVGPathElement.prototype.setAttribute,u=SVGPathElement.prototype.setAttributeNS,d=SVGPathElement.prototype.removeAttribute,f=SVGPathElement.prototype.removeAttributeNS,p=window.Symbol?Symbol():`__cachedPathData`,m=window.Symbol?Symbol():`__cachedNormalizedPathData`;SVGPathElement.prototype.setAttribute=function(e,t){e===`d`&&(this[p]=null,this[m]=null),l.call(this,e,t)},SVGPathElement.prototype.setAttributeNS=function(e,t,n){if(t===`d`){var r=`http://www.w3.org/2000/svg`;if(e)for(var i of this.ownerSVGElement.attributes)i.name===`xmlns:${e}`&&(r=i.value);r===`http://www.w3.org/2000/svg`&&(this[p]=null,this[m]=null)}u.call(this,e,t,n)},SVGPathElement.prototype.removeAttribute=function(e,t){e===`d`&&(this[p]=null,this[m]=null),d.call(this,e)},SVGPathElement.prototype.removeAttributeNS=function(e,t){if(t===`d`){var n=`http://www.w3.org/2000/svg`;if(e)for(var r of this.ownerSVGElement.attributes)r.name===`xmlns:${e}`&&(n=r.value);n===`http://www.w3.org/2000/svg`&&(this[p]=null,this[m]=null)}f.call(this,e,t)},SVGPathElement.prototype.getPathData=function(r){if(r&&r.normalize){if(this[m])return e(this[m]);var i;this[p]?i=e(this[p]):(i=c(this.getAttribute(`d`)||``),this[p]=e(i));var a=n(t(i));return this[m]=e(a),a}else if(this[p])return e(this[p]);else{var i=c(this.getAttribute(`d`)||``);return this[p]=e(i),i}},SVGPathElement.prototype.setPathData=function(e){if(e.length===0)s?this.setAttribute(`d`,``):this.removeAttribute(`d`);else{for(var t=``,n=0,r=e.length;n<r;n+=1){var i=e[n];n>0&&(t+=` `),t+=i.type,i.values&&i.values.length>0&&(t+=` `+i.values.join(` `))}this.setAttribute(`d`,t)}}}SVGRectElement.prototype.getPathData||(SVGRectElement.prototype.getPathData=function(e){var t=this.x.baseVal.value,r=this.y.baseVal.value,i=this.width.baseVal.value,a=this.height.baseVal.value,o=this.hasAttribute(`rx`)?this.rx.baseVal.value:this.ry.baseVal.value,s=this.hasAttribute(`ry`)?this.ry.baseVal.value:this.rx.baseVal.value;o>i/2&&(o=i/2),s>a/2&&(s=a/2);var c=[{type:`M`,values:[t+o,r]},{type:`H`,values:[t+i-o]},{type:`A`,values:[o,s,0,0,1,t+i,r+s]},{type:`V`,values:[r+a-s]},{type:`A`,values:[o,s,0,0,1,t+i-o,r+a]},{type:`H`,values:[t+o]},{type:`A`,values:[o,s,0,0,1,t,r+a-s]},{type:`V`,values:[r+s]},{type:`A`,values:[o,s,0,0,1,t+o,r]},{type:`Z`,values:[]}];return c=c.filter(function(e){return!(e.type===`A`&&(e.values[0]===0||e.values[1]===0))}),e&&e.normalize===!0&&(c=n(c)),c}),SVGCircleElement.prototype.getPathData||(SVGCircleElement.prototype.getPathData=function(e){var t=this.cx.baseVal.value,r=this.cy.baseVal.value,i=this.r.baseVal.value,a=[{type:`M`,values:[t+i,r]},{type:`A`,values:[i,i,0,0,1,t,r+i]},{type:`A`,values:[i,i,0,0,1,t-i,r]},{type:`A`,values:[i,i,0,0,1,t,r-i]},{type:`A`,values:[i,i,0,0,1,t+i,r]},{type:`Z`,values:[]}];return e&&e.normalize===!0&&(a=n(a)),a}),SVGEllipseElement.prototype.getPathData||(SVGEllipseElement.prototype.getPathData=function(e){var t=this.cx.baseVal.value,r=this.cy.baseVal.value,i=this.rx.baseVal.value,a=this.ry.baseVal.value,o=[{type:`M`,values:[t+i,r]},{type:`A`,values:[i,a,0,0,1,t,r+a]},{type:`A`,values:[i,a,0,0,1,t-i,r]},{type:`A`,values:[i,a,0,0,1,t,r-a]},{type:`A`,values:[i,a,0,0,1,t+i,r]},{type:`Z`,values:[]}];return e&&e.normalize===!0&&(o=n(o)),o}),SVGLineElement.prototype.getPathData||(SVGLineElement.prototype.getPathData=function(){return[{type:`M`,values:[this.x1.baseVal.value,this.y1.baseVal.value]},{type:`L`,values:[this.x2.baseVal.value,this.y2.baseVal.value]}]}),SVGPolylineElement.prototype.getPathData||(SVGPolylineElement.prototype.getPathData=function(){for(var e=[],t=0;t<this.points.numberOfItems;t+=1){var n=this.points.getItem(t);e.push({type:t===0?`M`:`L`,values:[n.x,n.y]})}return e}),SVGPolygonElement.prototype.getPathData||(SVGPolygonElement.prototype.getPathData=function(){for(var e=[],t=0;t<this.points.numberOfItems;t+=1){var n=this.points.getItem(t);e.push({type:t===0?`M`:`L`,values:[n.x,n.y]})}return e.push({type:`Z`,values:[]}),e})})();function Or(e){return e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}async function kr(e,t,n){for(let r of e)try{let e=await fetch(`${t}/fonts/${r}.woff2?access_token=${n}`).then(e=>e.arrayBuffer());document.fonts.add(new FontFace(r,e))}catch{}}function q(e,t,n=1e-4){return Math.abs(e-t)<n}async function Ar(e,t,n){if(Dr()||e.length<2e6)try{return await jr(e,t,n)}catch{}return await Mr(new Blob([e],{type:`image/svg+xml`}),t,n)}function jr(e,t,n){let r=new Image;return r.width=t,r.height=n,new Promise((t,n)=>{r.onload=()=>t(r),r.onerror=()=>n(Error(`Failed to quickly generate image from svg`)),r.src=`data:image/svg+xml;base64,${btoa(e)}`})}async function Mr(e,t,n){let r=new Image;r.width=t,r.height=n;let i=URL.createObjectURL(e);try{await new Promise((e,t)=>{r.onload=()=>e(),r.onerror=()=>t(Error(`Failed to safely generate image from svg`)),r.src=i})}finally{URL.revokeObjectURL(i)}return r}var Nr=/\$\{([^}]+)}/g,Pr=new DOMParser,Fr=new XMLSerializer,Ir=new Map;function Lr(e){let t=Ir.get(e);return t||(t=Pr.parseFromString(e,`image/svg+xml`).documentElement,Ir.set(e,t)),t}function Rr(e){let t=Fr.serializeToString(e);return Ir.has(t)||Ir.set(t,e),t}var zr=class{_seen=[];_svg=null;_element=null;constructor(e){this._svg=e}setElement(){return this._element=Lr(this._svg).cloneNode(!0),this._svg=null,this._element}getSvgString(){return this._svg??Rr(this._element)}getSvgSize(){let e=this._element??Lr(this._svg);return[e.width.baseVal.value,e.height.baseVal.value]}getSvgColors(){let e=[],t=[],n=(this._element??Lr(this._svg)).querySelectorAll(`[mol_edit_style=true]`);for(let r=0;r<n.length;++r){let i=n[r],a=i.id;if(a&&t.every(e=>e.id!==a)){let n=i.getAttribute(`fill`)?.trim();if(n){let r=new J(n);if(r.badValue)e.push({name:`fill#${a}`,color:n});else{let{rgba:t}=r,n=i.getAttribute(`fill-opacity`);t[3]*=n?N(Number(n),0,1):1,e.push({name:`fill#${a}`,color:J.fromRGB(t)})}t.push(i)}let r=i.getAttribute(`stroke`)?.trim();if(r){let n=new J(r);if(n.badValue)e.push({name:`stroke#${a}`,color:r});else{let{rgba:t}=n,r=i.getAttribute(`stroke-opacity`);t[3]*=r?N(Number(r),0,1):1,e.push({name:`stroke#${a}`,color:J.fromRGB(t)})}t.push(i)}}}return e}setSvgColors(e){let t=[],n=(this._element??this.setElement()).querySelectorAll(`[mol_edit_style=true]`);for(let r=0;r<n.length;++r){let i=n[r],a=i.id;if(a&&t.every(e=>e.id!==a)&&(i.getAttribute(`fill`)?.trim()||i.getAttribute(`stroke`)?.trim())){let n=e.find(e=>e.name===`fill#${a}`);if(n?.color){let[e,t,r,a]=n.color.rgba;i.setAttribute(`fill`,`rgb(${e},${t},${r})`),i.setAttribute(`fill-opacity`,String(a))}let r=e.find(e=>e.name===`stroke#${a}`);if(r?.color){let[e,t,n,a]=r.color.rgba;i.setAttribute(`stroke`,`rgb(${e},${t},${n})`),i.setAttribute(`stroke-opacity`,String(a))}t.push(i)}}return this}getSvgTexts(){let e=[],t=(this._element??Lr(this._svg)).querySelectorAll(`[mol_edit_text=true]`);for(let n=0;n<t.length;++n){let r=t[n],i=r.id;i&&e.every(e=>e.name!==i)&&e.push({name:i,text:r.textContent||void 0,isMultiline:/^\s*true/i.test(r.getAttribute(`mol_wrap`)??`false`)})}return e}setSvgTexts(e){this._seen=[];let t=this._element??this.setElement(),n=t.querySelectorAll(`[mol_edit_text=true]`);document.body.appendChild(t);try{let r=t.width.baseVal.value/t.viewBox.baseVal.width;for(let r=0;r<n.length;++r){let i=n[r],a=i.id;if(a&&this._seen.every(e=>e.id!==a)){let n=e.find(e=>e.name===a);if(i.querySelector(`textPath`)){if(n)for(let e=0;e<i.childNodes.length;++e)i.childNodes[e].nodeName===`textPath`&&(i.childNodes[e].childNodes[0].nodeValue=n.text??``)}else this.wrapText(t,i,n&&(n.text??``));this.nodeChanged(i)}}this._seen.length&&(this.resetSize(r),this.resetAnchor())}finally{document.body.removeChild(t)}return this}nodeChanged(e){if(!e.id||this._seen.includes(e))return;let t=this._element??this.setElement(),n=this.getBBox(e),r=0,i=t.querySelectorAll(`[mol_wrap~="${e.id}"]`)??[];for(r=0;r<i.length;++r)this.wrapText(t,i[r]);for(i=t.querySelectorAll(`[mol_autoresizeid~="${e.id}"]`)??[],r=0;r<i.length;++r)this.autoResizeId(i[r],n);for(i=t.querySelectorAll(`[mol_samewidth~="${e.id}"]`)??[],r=0;r<i.length;++r)this.sameWidth(i[r],n);for(i=t.querySelectorAll(`[mol_sameheight~="${e.id}"]`)??[],r=0;r<i.length;++r)this.sameHeight(i[r],n);for(i=t.querySelectorAll(`[mol_stack~="${e.id}"]`)??[],r=0;r<i.length;++r)this.stack(i[r],n);for(i=t.querySelectorAll(`[mol_rectposition~="${e.id}"]`)??[],r=0;r<i.length;++r)this.rectPosition(i[r],n);for(i=t.querySelectorAll(`[mol_pathposition~="${e.id}"]`)??[],r=0;r<i.length;++r)this.pathPosition(i[r],e);for(i=t.querySelectorAll(`[mol_copyposition~="${e.id}"]`)??[],r=0;r<i.length;++r)this.copyPosition(i[r],e);this._seen.push(e)}autoResizeId(e,t){let n=e.attributes.mol_autoresizemargin?.value,r=[0,0,0,0];if(n){let e=n.split(` `).map(e=>parseFloat(e));r=e.length===1?[e[0],e[0],e[0],e[0]]:[e[0],e[1],e[2],e[3]]}q(e.attributes.x.value,t.x-r[0])&&q(e.attributes.y.value,t.y-r[2])&&q(e.attributes.width.value,t.width+r[0]+r[1])&&q(e.attributes.height.value,t.height+r[2]+r[3])||(e.attributes.x.value=t.x-r[0],e.attributes.y.value=t.y-r[2],e.attributes.width.value=t.width+r[0]+r[1],e.attributes.height.value=t.height+r[2]+r[3],this.nodeChanged(e))}sameWidth(e,t){let n=t.width+2*parseFloat(e.attributes.mol_samewidth.value.split(` `)[1]);q(e.attributes.width.value,n)||(e.attributes.width.value=n,this.nodeChanged(e))}sameHeight(e,t){let n=t.height+2*parseFloat(e.attributes.mol_sameheight.value.split(` `)[1]);q(e.attributes.height.value,n)||(this._seen.push(e),e.attributes.height.value=n,this.nodeChanged(e))}stack(e,t){let n=!1;switch(e.attributes.mol_stack.value.split(` `)[0]){case`top`:n=!(q(e.attributes.width.value,t.width)&&q(e.attributes.x.value,t.x)&&q(e.attributes.y.value,t.y-e.attributes.height.value)),n&&(e.attributes.width.value=t.width,e.attributes.x.value=t.x,e.attributes.y.value=t.y-e.attributes.height.value);break;case`bottom`:n=!(q(e.attributes.width.value,t.width)&&q(e.attributes.x.value,t.x)&&q(e.attributes.y.value,t.y+t.height)),n&&(e.attributes.width.value=t.width,e.attributes.x.value=t.x,e.attributes.y.value=t.y+t.height);break;case`left`:n=!(q(e.attributes.height.value,t.height)&&q(e.attributes.x.value,t.x-e.attributes.width.value)&&q(e.attributes.y.value,t.y)),n&&(e.attributes.height.value=t.height,e.attributes.x.value=t.x-e.attributes.width.value,e.attributes.y.value=t.y);break;case`right`:n=!(q(e.attributes.height.value,t.height)&&q(e.attributes.x.value,t.x+t.width)&&q(e.attributes.y.value,t.y)),n&&(e.attributes.height.value=t.height,e.attributes.x.value=t.x+t.width,e.attributes.y.value=t.y);break}n&&this.nodeChanged(e)}rectPosition(e,t){let n=e.attributes.mol_rectposition.value.split(` `)[1],r=e.attributes.mol_rectposition.value.split(` `)[2],i=parseFloat(e.attributes.mol_rectposition.value.split(` `)[3])||0,a={x:0,y:0};switch(n){case`center`:a={x:t.x+t.width/2,y:t.y+t.height/2};break;case`top`:case`bottom`:switch(a.x=t.x,r){case`start`:a.x+=i;break;case`middle`:a.x+=t.width/2+i;break;case`end`:a.x+=t.width-i;break}a.y=t.y,n===`bottom`&&(a.y+=t.height);break;case`left`:case`right`:switch(a.y=t.y,r){case`start`:a.y+=i;break;case`middle`:a.y+=t.height/2+i;break;case`end`:a.y+=t.height+i;break}a.x=t.x,n===`right`&&(a.x+=t.width);break}let o=this.getCoordinate(e,0,0);o&&!(q(o.x,a.x)&&q(o.y,a.y))&&(this.moveElement(e,a),this.nodeChanged(e))}pathPosition(e,t){let n=e.attributes.mol_pathposition.value.split(` `).map(e=>parseFloat(e)),r=this.getCoordinate(e,0,0),i=this.getCoordinate(t,n[1],n[2]);i&&r&&!(q(i.x,r.x)&&q(i.y,r.y))&&(this.moveElement(e,i),this.nodeChanged(e))}copyPosition(e,t){let n=e.attributes.mol_copyposition.value.split(` `).map(e=>parseFloat(e)),r=this.getCoordinate(e,n[0],n[1]),i=this.getCoordinate(t,n[3],n[4]);i&&r&&!(q(i.x,r.x)&&q(i.y,r.y))&&(this.setCoordinate(e,i,n[0],n[1]),this.nodeChanged(e))}resetSize(e){let t=this._element??this.setElement(),n=this.getBBox(t);n.x-=.1*n.width,n.y-=.1*n.height,n.width*=1.2,n.height*=1.2,t.setAttribute(`viewBox`,`${n.x} ${n.y} ${n.width} ${n.height}`),t.setAttribute(`width`,`${n.width*e}`),t.setAttribute(`height`,`${n.height*e}`)}resetAnchor(){let e=(this._element??Lr(this._svg)).querySelector(`[mol_edit_anchor]`);if(e){let t=e.getAttribute(`mol_edit_anchor`).split(` `).map(e=>parseFloat(e)),n=this.getCoordinate(e,t[0],t[1]),r=this._element??this.setElement(),i=r.getElementById(`scale`);if(i){let e=i.getAttribute(`transform`),t=(/scale\(([\d.]+)\)/i.exec(e)||[``,`1`]).map(Number.parseFloat)[1];n.x*=t,n.y*=t}r.setAttribute(`mol_svganchor`,`${n.x} ${n.y}`)}}getBBox(e){function t(e){if(e.nodeName!==`text`)return``;let t=e.textContent,n=0;for(;n<e.childNodes.length&&e.childNodes[n].nodeName===`tspan`&&e.childNodes[n].textContent.match(/\S+/)===null;)t=t.slice(e.childNodes[n].textContent.length),n++;for(n=e.childNodes.length-1;n>=0&&e.childNodes[n].nodeName===`tspan`&&e.childNodes[n].textContent.match(/\S+/)===null;)t=t.slice(0,t.length-e.childNodes[n].textContent.length),n--;let r=t.split(`
690
+ `);for(t=r[0],n=1;n<r.length;++n)r[n].length>t.length&&(t=r[n]);return t}let n=null,r=e.getBBox();if(e.nodeName===`text`){let i=t(e),a=r.width,o=r.x,s=i.match(/\S+.*\S+/);if(s&&s.length>0){let e=i.match(/^\s*/);e.length>0&&(o-=a/s[0].length*e[0].length),a+=a/s[0].length*(i.length-s[0].length)}n={width:a,height:r.height,x:o,y:r.y,descent:r.y+r.height-Number(e.getAttribute(`y`))}}else n={x:r.x,y:r.y,width:Math.max(1,r.width),height:Math.max(1,r.height)};return n}nodeToPoints(e){let t=[],n,r,i;for(r=e.points.length?e.points.length:e.points.numberOfItems,i=0;i<r;++i)n=e.points.getItem(i),t.push(n);return t}pointsToString(e){let t=``,n;for(n=0;n<e.length;++n)t=`${t} ${e[n].x.toString()}, ${e[n].y.toString()}`;return t}getCoordinate(e,t,n){let r={x:0,y:0},i=[],a=[];switch(e.nodeName){case`rect`:if(t===0)return r.x=parseFloat(e.getAttribute(`x`)),r.y=parseFloat(e.getAttribute(`y`)),r;if(t===1)return r.x=parseFloat(e.getAttribute(`x`))+parseFloat(e.getAttribute(`width`)),r.y=parseFloat(e.getAttribute(`y`))+parseFloat(e.getAttribute(`height`)),r;break;case`circle`:if(t===0)return r.x=parseFloat(e.getAttribute(`cx`)),r.y=parseFloat(e.getAttribute(`cy`)),r;if(t===1)return r.x=parseFloat(e.getAttribute(`cx`))+parseFloat(e.getAttribute(`r`)),r.y=parseFloat(e.getAttribute(`cy`)),r;break;case`ellipse`:if(t===0)return r.x=parseFloat(e.getAttribute(`cx`)),r.y=parseFloat(e.getAttribute(`cy`)),r;if(t===1)return r.x=parseFloat(e.getAttribute(`cx`))+parseFloat(e.getAttribute(`rx`)),r.y=parseFloat(e.getAttribute(`cy`)),r;if(t===2)return r.x=parseFloat(e.getAttribute(`cx`)),r.y=parseFloat(e.getAttribute(`cy`))-parseFloat(e.getAttribute(`ry`)),r;break;case`line`:if(t===0)return r.x=parseFloat(e.getAttribute(`x1`)),r.y=parseFloat(e.getAttribute(`y1`)),r;if(t===1)return r.x=parseFloat(e.getAttribute(`x2`)),r.y=parseFloat(e.getAttribute(`y2`)),r;break;case`polyline`:if(i=this.nodeToPoints(e),t<i.length)return r.x=i[t].x,r.y=i[t].y,r;break;case`polygon`:if(i=this.nodeToPoints(e),t<i.length)return r.x=i[t].x,r.y=i[t].y,r;break;case`path`:switch(a=e.getPathData({normalize:!0}),a[n].type){case`M`:switch(t){case 0:return r.x=a[n].values[0],r.y=a[n].values[1],r}break;case`L`:switch(t){case 0:return r.x=a[n].values[0],r.y=a[n].values[1],r}break}break}return null}setCoordinate(e,t,n,r){let i=``,a=[],o=[],s=0,c=0,l=0;switch(e.nodeName){case`rect`:n===0&&(e.setAttribute(`x`,t.x.toString()),e.setAttribute(`y`,t.y.toString())),n===1&&(s=t.x-Number(e.getAttribute(`x`)),s>=0?e.setAttribute(`width`,s.toString()):(c=Number(e.getAttribute(`x`))+s,e.setAttribute(`x`,c.toString()),e.setAttribute(`width`,`0`)),s=t.y-Number(e.getAttribute(`y`)),s>=0?e.setAttribute(`height`,s.toString()):(c=Number(e.getAttribute(`y`))+s,e.setAttribute(`y`,c.toString()),e.setAttribute(`height`,`0`)));break;case`circle`:n===0&&(e.setAttribute(`cx`,t.x.toString()),e.setAttribute(`cy`,t.y.toString())),n===1&&(c=parseFloat(e.getAttribute(`cx`))-t.x,l=parseFloat(e.getAttribute(`cy`))-t.y,s=Math.sqrt(c*c+l*l),e.setAttribute(`r`,s.toString()));break;case`ellipse`:n===0&&(e.setAttribute(`cx`,t.x.toString()),e.setAttribute(`cy`,t.y.toString())),n===1&&(s=Math.abs(parseFloat(e.getAttribute(`cx`))-t.x),e.setAttribute(`rx`,s.toString())),n===2&&(s=Math.abs(parseFloat(e.getAttribute(`cy`))-t.y),e.setAttribute(`ry`,s.toString()));break;case`line`:n===0&&(e.setAttribute(`x1`,t.x.toString()),e.setAttribute(`y2`,t.y.toString())),n===1&&(e.setAttribute(`x2`,t.x.toString()),e.setAttribute(`y2`,t.y.toString()));break;case`polyline`:a=this.nodeToPoints(e),n<a.length&&(a[n].x=t.x,a[n].y=t.y,i=this.pointsToString(a),e.setAttribute(`points`,i));break;case`polygon`:a=this.nodeToPoints(e),n<a.length&&(a[n].x=t.x,a[n].y=t.y,i=this.pointsToString(a),e.setAttribute(`points`,i));break;case`path`:if(!r)break;switch(o=e.getPathData({normalize:!0}),o[r].type){case`M`:o[r].values[0]=t.x,o[r].values[1]=t.y;break;case`L`:o[r].values[0]=t.x,o[r].values[1]=t.y;break}e.setPathData(o);break}}moveElement(e,t){let n={x:0,y:0},r={x:0,y:0},i=0,a=!1,o=[];switch(e.nodeName){case`rect`:case`circle`:case`ellipse`:n=this.getCoordinate(e,0,0),a=!q(n.x,t.x)||!q(n.y,t.y),a&&this.setCoordinate(e,t,0,0);break;case`polyline`:case`polygon`:if(n=this.getCoordinate(e,0,0),r.x=t.x-n.x,r.y=t.y-n.y,a=!q(r.x,0)||!q(r.y,0),a)for(this.setCoordinate(e,t,0,0),i=1,n=this.getCoordinate(e,i,0);n!==null;)n.x+=r.x,n.y+=r.y,this.setCoordinate(n,i,0,void 0),i++,n=this.getCoordinate(e,i,0);break;case`path`:if(n=this.getCoordinate(e,0,0),r.x=t.x-n.x,r.y=t.y-n.y,a=!q(r.x,0)||!q(r.y,0),a){o=e.getPathData({normalize:!0});for(let e=0;e<o.length;++e){let t=o[e];(t?.type===`M`||t?.type===`L`)&&(t.values[0]+=r.x,t.values[1]+=r.y)}e.setPathData(o)}break}return a}wrapText(e,t,n){let r=[],i=0,a,o=0,s=``,c=``,l,u,d,f=0,p=``,m,h=`http://www.w3.org/2000/svg`;for(n??=t.textContent;t.hasChildNodes();)t.removeChild(t.firstChild);let g=document.createTextNode(`gh`);t.appendChild(g);let _=t.getAttribute(`y`),v=null,y=``,b=[],x=0,S=0,C=!1;if(t.hasAttribute(`mol_wrap`)&&(b=t.getAttribute(`mol_wrap`).split(` `,4),b[0]===`true`&&(y=b[1],y===`newlineOnly`?(C=!0,y=``,x=0):x=parseFloat(b[2]),S=b.length>=4?parseFloat(b[3]):x)),y){let n=e.getElementById(y);v=this.getBBox(n||t)}else v=this.getBBox(t);let w=v.x,T=v.y,E=v.width,D=1e4;y!==``&&!C&&(D=E-2*x),v=this.getBBox(t);let O=v.height;t.hasAttribute(`font-size`)&&(O=parseFloat(t.getAttribute(`font-size`)));let k=v.y+v.height-_;if(t.removeChild(g),w+=x,T+=x+v.height,t.hasAttribute(`text-anchor`))switch(t.getAttribute(`text-anchor`)){case`end`:w=w-x+E-x;break;case`middle`:w=w-x+E/2;break}p=t.getAttribute(`id`),t.setAttribute(`x`,w.toString()),t.setAttribute(`y`,(T-k).toString()),n&&(r=n.replace(/\n/g,`
691
+ §`).replace(/-/g,`-§`).replace(/ /g,` §`).replace(/\t/g,` §`).split(`§`));let A=parseFloat(t.attributes.y.value);for(u=document.createElementNS(h,`tspan`),u.setAttributeNS(null,`x`,String(w)),u.setAttributeNS(null,`y`,String(A+o)),d=p+f.toString(),u.setAttribute(`id`,d),f++,s=``,i=0,l=document.createTextNode(s),u.appendChild(l),t.appendChild(u),o+=O,a=0;a<r.length;)c=s+r[a],i++,l.nodeValue=c,m=e.querySelector(`#${d}`).getComputedTextLength(),m<D?(s=c,s.length>0&&s[s.length-1]===`
692
+ `&&a<r.length-1&&(l.nodeValue=s,u=document.createElementNS(h,`tspan`),u.setAttributeNS(null,`x`,String(w)),u.setAttributeNS(null,`y`,String(A+o)),d=p+f.toString(),u.setAttribute(`id`,d),o+=O+S,f++,s=``,i=0,l=document.createTextNode(s),u.appendChild(l),t.appendChild(u)),a++):(i>1?l.nodeValue=s:(s=c,a++),s.length>0&&s[s.length-1]===`
693
+ `&&(s=s.substr(0,s.length-1),l.nodeValue=s),u=document.createElementNS(h,`tspan`),u.setAttributeNS(null,`x`,String(w)),u.setAttributeNS(null,`y`,String(A+o)),d=p+f.toString(),u.setAttribute(`id`,d),o+=O+S,f++,s=``,i=0,l=document.createTextNode(s),u.appendChild(l),t.appendChild(u));return t.childElementCount===1&&t.firstElementChild.replaceWith(t.firstElementChild.textContent),o}},Br=class{map;keyCache=new Map;constructor(e){this.map=e}getMapLibreImageKey(e,t){let n=this.keyCache.get(t);n||(n=new Map,this.keyCache.set(t,n));let r=n.get(e);if(!r){let i=e+t,a=new zr(e).getSvgSize(),o=Math.max(a[0]*t,1),s=Math.max(a[1]*t,1);r=`mc-image-${P(i)}`,Ar(e,o,s).then(e=>this.map.addImage(r,e,{pixelRatio:t})).catch(e=>console.log(e)),n.set(e,r)}return r}},Vr=0,Hr=``,Ur=document.createElement(`canvas`).getContext(`2d`);function Wr(e,t,n){let r=0,i=0,a=0,o=0;if(Ur){(Vr!==n||Hr!==t)&&(Ur.font=`${n}px ${t}`,Hr=t,Vr=n),{actualBoundingBoxAscent:a,actualBoundingBoxDescent:o}=Ur.measureText(`█`);for(let t=0;t<e.length;++t){let{actualBoundingBoxLeft:n,actualBoundingBoxRight:i}=Ur.measureText(e[t]);n+i>r&&(r=n+i)}i=(a+o)*e.length}return{width:r,height:i,ascent:a,descent:o}}function Gr(e,t,n,r,i){let a=n??t,o=!r,s=a?.match(/\$\{([^}]+)}/)?.[1],c=s?o?E(e[s]):D(e[s]):null,l=s?o?c:typeof c!=`boolean`&&c!==null&&c!==``?r(c):i:a;return l&&!new J(l).badValue?l:`#000000`}function Kr(e,t,n){return(n??t)?.split(Nr).map((t,n)=>n&1?E(e[t]):t).join(``)||void 0}function qr(e,t,n){let r=t;if(t){let i=new zr(t),a=i.getSvgColors(),o=i.getSvgTexts(),s=n?new Map(new zr(n).getSvgColors().map(({name:e,color:t})=>[e,t])):new Map,c=n?new Map(new zr(n).getSvgTexts().map(({name:e,text:t})=>[e,t])):new Map,l=a.map(({name:t,color:n})=>({name:t,color:new J(Gr(e,n?.toString(),s.get(t)?.toString()))})).filter((e,t)=>typeof a[t].color==`string`||!e.color.sameColor(a[t].color)),u=o.map(({name:t,text:n})=>({name:t,text:Kr(e,n,c.get(t))})).filter((e,t)=>e.text!==o[t].text);l.length&&i.setSvgColors(l),u.length&&i.setSvgTexts(u),(l.length||u.length)&&(r=i.getSvgString())}return r}var J=class e{_error=!1;_rgba;static fromRGB(t){let n=new e(`transparent`);return n._rgba[0]=t[0],n._rgba[1]=t[1],n._rgba[2]=t[2],n._rgba[3]=t.length>3?t[3]:1,n}constructor(e){e=String(e).trim().toLowerCase();let t=this._rgba=[0,0,0,1],n=e.length,r;if(n===0)this._error=!0;else if(e===`transparent`||e===`none`)t[3]=0;else if(e[0]===`#`)n<6?(t[0]=parseInt(e[1]+e[1],16)||0,t[1]=parseInt(e[2]+e[2],16)||0,t[2]=parseInt(e[3]+e[3],16)||0,n===5&&(t[3]=parseInt(e[4]+e[4],16)/255)):(t[0]=parseInt(e[1]+e[2],16)||0,t[1]=parseInt(e[3]+e[4],16)||0,t[2]=parseInt(e[5]+e[6],16)||0,n>8&&(t[3]=parseInt(e[7]+e[8],16)/255));else if(e in $r){let n=$r[e];t[0]=n[0],t[1]=n[1],t[2]=n[2]}else if(r=/^(rgba?|hs[lv]a?)\s*\(([^)]*)\)/.exec(e)){let e=r[1].replace(/a$/,``),n=r[2].trim().split(/\s*[,/]\s*|\s+/).map(Yr,{space:e});e===`rgb`?(t[0]=n[0],t[1]=n[1],t[2]=n[2],n.length>3&&(t[3]=n[3])):e===`hsl`?Zr(n,t):e===`hsv`&&Qr(n,t)}else this._error=!0}get badValue(){return this._error}get a(){return this._rgba[3]}get hex(){return`#${(Math.round(this._rgba[0])<<16|Math.round(this._rgba[1])<<8|Math.round(this._rgba[2])).toString(16).padStart(6,`0`)}`}get rgba(){return this._rgba.slice()}sameColor(e){return q(this._rgba[0],e._rgba[0])&&q(this._rgba[1],e._rgba[1])&&q(this._rgba[2],e._rgba[2])&&q(this._rgba[3],e._rgba[3])}toString(){let[e,t,n,r]=this._rgba;return r===1?this.hex:`rgba(${Math.round(e)}, ${Math.round(t)}, ${Math.round(n)}, ${r})`}},Jr={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};function Yr(e,t){let{space:n}=this;if(e[e.length-1]===`%`){let r=parseFloat(e),i=t<3&&n===`rgb`?255:1,a=t>0&&t<3&&n[0]===`h`?1:100;return(r<0?0:r>100?100:r)/a*i}if(n[t]===`h`||t===2&&n[n.length-1]===`h`){if(e in Jr)return Jr[e];let t=parseFloat(e);switch(!0){case e.endsWith(`turn`):t*=360;break;case e.endsWith(`grad`):t=t*360/400;break;case e.endsWith(`rad`):t=t*180/Math.PI;break}return(t%360+360)%360}if(e===`none`)return 0;{let r=parseFloat(e),i=t<3&&n===`rgb`?255:1;return r<0?0:r>i?i:r}}function Xr(e,t,n){return n<0&&(n+=1),n>1&&--n,(n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e)*255}function Zr(e,t=[0,0,0,1]){let n=e[0]/360,r=e[1]/100,i=e[2]/100;if(r===0)t[2]=t[1]=t[0]=i*255;else{let e=i<.5?i*(1+r):i+r-i*r,a=2*i-e;t[0]=Xr(a,e,n+1/3),t[1]=Xr(a,e,n),t[2]=Xr(a,e,n-1/3)}return e.length>3&&(t[3]=e[3]),t}function Qr(e,t=[0,0,0,1]){let n=e[0]/60,r=e[1]/100,i=e[2]/100*255,a=Math.floor(n),o=n-a,s=i*(1-r),c=i*(1-o*r),l=i*(1-(1-o)*r);switch(a%6){case 0:t[0]=i,t[1]=l,t[2]=s;break;case 1:t[0]=c,t[1]=i,t[2]=s;break;case 2:t[0]=s,t[1]=i,t[2]=l;break;case 3:t[0]=s,t[1]=c,t[2]=i;break;case 4:t[0]=l,t[1]=s,t[2]=i;break;case 5:t[0]=i,t[1]=s,t[2]=c;break}return e.length>3&&(t[3]=e[3]),t}var $r={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function ei(e,t,n){let{title:r=``,titleFontColor:i=`#000000`,titleFont:a=t,titleFontSize:o=24,entries:s,entryFontColor:c=`#000000`,entryFont:l=t,entryFontSize:u=13,entryShape:d=`rectangle`,layout:f=`vertical`,background:p=`#ffffff`,showBackground:m=!1}=e,h=Wr([r],a,o),g=s.map(e=>Wr([e.label],l,u)),_=r.trim().length>0,v,y;f===`vertical`?(v=Math.max(h.width,...g.map(e=>e.width+15+10))+30,y=30+(_?h.height+20:0)+g.reduce((e,t)=>e+t.height,0)+Math.max(g.length-1,0)*20):(v=Math.max(h.width+30,30+g.reduce((e,t)=>e+t.width+15+10,0)+Math.max(g.length-1,0)*20),y=30+(_?h.height+20:0)+Math.max(0,...g.map(e=>e.height)));let b=[];m&&b.push(`
694
+ <rect
695
+ x="0"
696
+ y="0"
697
+ rx="10"
698
+ ry="10"
699
+ width="${v}"
700
+ height="${y}"
701
+ fill="${p}"
702
+ />
703
+ `);let x=15,S=15;_&&(b.push(`
704
+ <text
705
+ x="${x}"
706
+ y="${S+h.ascent}"
707
+ font-family="${a}"
708
+ font-size="${o}"
709
+ fill="${i}"
710
+ >
711
+ ${Or(r)}
712
+ </text>
713
+ `),S+=h.height+20);for(let e=0;e<s.length;e++){let t=s[e],n=g[e];if(d===`rectangle`)b.push(`
714
+ <rect
715
+ x="${x}"
716
+ y="${S+n.height/2-15/2}"
717
+ rx="2"
718
+ ry="2"
719
+ width="15"
720
+ height="15"
721
+ fill="${t.color}"
722
+ />
723
+ `);else if(d===`circle`)b.push(`
724
+ <circle
725
+ cx="${x+15/2}"
726
+ cy="${S+n.height/2}"
727
+ r="${15/2}"
728
+ fill="${t.color}"
729
+ />
730
+ `);else if(d===`line`)b.push(`
731
+ <line
732
+ x1="${x}"
733
+ y1="${S+n.height/2}"
734
+ x2="${x+15}"
735
+ y2="${S+n.height/2}"
736
+ stroke="${t.color}"
737
+ stroke-width="2"
738
+ stroke-linecap="round"
739
+ />
740
+ `);else if(d===`icon`&&t.svg.length>0){let e=new DOMParser().parseFromString(t.svg,`image/svg+xml`).querySelector(`svg`);e&&(e.setAttribute(`width`,`15`),e.setAttribute(`height`,`15`),e.setAttribute(`transform`,`translate(${x}, ${S+n.height/2-15/2})`),b.push(e.outerHTML))}b.push(`
741
+ <text
742
+ x="${x+15+10}"
743
+ y="${S+n.ascent}"
744
+ font-family="${l}"
745
+ font-size="${u}"
746
+ fill="${c}"
747
+ >
748
+ ${Or(t.label)}
749
+ </text>
750
+ `),f===`vertical`?S+=n.height+20:x+=n.width+15+10+20}return`
751
+ <svg
752
+ class="adornment-svg"
753
+ xmlns="http://www.w3.org/2000/svg"
754
+ width="${v*n}"
755
+ height="${y*n}"
756
+ viewBox="0 0 ${v} ${y}"
757
+ >
758
+ ${b.join(``)}
759
+ </svg>
760
+ `}var ti=`ArialMT`,ni=15;function ri(e,t,n,r,i,a){let o=document.createElement(`div`);o.className=`adornment`,e.showBackground&&(o.style.boxShadow=`0 0 7px 0 rgba(33, 37, 41, 0.25)`,o.style.borderRadius=`10px`);let s=[e.titleFont??ti,e.labelFont??ti];return kr(Array.from(new Set(s)),r,i).then(()=>o.innerHTML=ii(e,t,n,a)),o}function ii(e,t,n,r){let{target:i}=e,a=t.registry?.models?.[i.modelType]?.find(e=>e.id===i.groupId),o=a?.models??[],s=a?.choropleth,c=Cr(a?.fillColor);return!s||!c||a.models.every(e=>!(e.visible??!0))||!Tr(o,c)?ai():s.colorMode===`categorical`?ci(e,s,c,r):s.colorMode===`linear`?oi(e,a,n,r):s.colorMode===`quantile`||s.colorMode===`quantize`?si(e,a,n,r):ai()}function ai(){return`
761
+ <svg
762
+ class="adornment-svg"
763
+ xmlns="http://www.w3.org/2000/svg"
764
+ width="0"
765
+ height="0"
766
+ viewBox="0 0 0 0"
767
+ >
768
+ </svg>
769
+ `}function oi(e,t,n,r){let i=15/2,{id:a,layout:o=`vertical`,labelFont:s=ti,labelFontSize:c=13,labelFontColor:l=`#000000`,numberFormat:u=`.2~s`,title:d=``,titleFont:f=ti,titleFontSize:p=14,titleFontColor:m=`#000000`,showBackground:h=!1,background:g=`#ffffff`}=e,_=`gradient-${a}`,v=o===`horizontal`,y=yr(t);if(y===void 0)return ai();let b=[],[x,S]=Mt(y.domain()),C=Ht(x,S,4),w=li(u),T=C.map(e=>w(e)),E=T.map(e=>Wr([e],s,c)),D=[];for(let e=0;e<32;e++){let t=e/31;D.push(`<stop offset="${t*100}%" stop-color="${y(x+t*(S-x))}" />`)}let O=v?``:`rotate(90)`;b.push(`
770
+ <defs>
771
+ <linearGradient id="${_}" gradientTransform="${O}">
772
+ ${D.join(``)}
773
+ </linearGradient>
774
+ </defs>
775
+ `);let k=Wr([d],f,p),A=d.trim().length>0,P={width:Math.max(0,...E.map(e=>e.width)),height:Math.max(0,...E.map(e=>e.height)),ascent:Math.max(0,...E.map(e=>e.ascent))},ee=A?k.height+10:0,te=A?k.width:0,F=C.length-1,ne=N(45*F,Math.ceil(v?(P.width+10)*F:(P.height+10)*F),Math.floor(v?n.getContainer().clientWidth-10-ni*2:n.getContainer().clientHeight-10-ni*2-ee)),re=Math.ceil(v?ni*2+Math.max(te,ne):ni*2+Math.max(te,25+P.width)),ie=Math.ceil(v?ni*2+ee+20+5+P.ascent:ni*2+ee+ne);h&&b.push(`
776
+ <rect
777
+ x="0"
778
+ y="0"
779
+ rx="10"
780
+ ry="10"
781
+ width="${re}"
782
+ height="${ie}"
783
+ fill="${g}"
784
+ />
785
+ `);let ae=ni,oe=ni;A&&(b.push(`
786
+ <text
787
+ x="${ae}"
788
+ y="${oe+k.ascent}"
789
+ font-family="${f}"
790
+ font-size="${p}"
791
+ fill="${m}"
792
+ >
793
+ ${Or(d)}
794
+ </text>
795
+ `),oe+=k.height+10),b.push(`
796
+ <rect
797
+ x="${ae}"
798
+ y="${oe}"
799
+ rx="${i}"
800
+ ry="${i}"
801
+ width="${v?ne:15}"
802
+ height="${v?15:ne}"
803
+ fill="url(#${_})"
804
+ />
805
+ `);for(let e=1;e<C.length-1;e++){let t=C[e],n=T[e],r=E[e],a=j(0,ne,M(x,S,t));a>i&&a<ne-i&&b.push(`
806
+ <line
807
+ x1="${v?Math.floor(ae+a)+.5:ae}"
808
+ y1="${v?oe:Math.floor(oe+a)+.5}"
809
+ x2="${v?Math.floor(ae+a)+.5:ae+20}"
810
+ y2="${v?oe+20:Math.floor(oe+a)+.5}"
811
+ stroke="#ffffff"
812
+ />
813
+ `),b.push(`
814
+ <text
815
+ x="${v?ae+a:ae+20+5}"
816
+ y="${v?oe+20+5+r.ascent:oe+a-r.descent+r.height/2}"
817
+ font-family="${s}"
818
+ font-size="${c}"
819
+ fill="${l}"
820
+ text-anchor="${v?`middle`:`start`}"
821
+ >
822
+ ${Or(n)}
823
+ </text>
824
+ `)}return`
825
+ <svg
826
+ class="adornment-svg"
827
+ xmlns="http://www.w3.org/2000/svg"
828
+ width="${re*r}"
829
+ height="${ie*r}"
830
+ viewBox="0 0 ${re} ${ie}"
831
+ >
832
+ ${b.join(``)}
833
+ </svg>
834
+ `}function si(e,t,n,r){let i=yr(t),a=i?.range(),o=[],s=0,c=0;if(i&&a&&a.length>1){let{layout:t=`vertical`,labelFont:r=ti,labelFontSize:l=13,labelFontColor:u=`#000000`,labelStyle:d=`range`,numberFormat:f=`.2~s`,title:p=``,titleFont:m=ti,titleFontSize:h=14,titleFontColor:g=`#000000`,showBackground:_=!1,background:v=`#ffffff`}=e,y=t===`vertical`,b=d===`range`,x=li(f),S=b?a.map(e=>i.invertExtent(e)).map((e,t,n)=>t===0?`< ${x(e[1])}`:t===n.length-1?`> ${x(e[0])}`:`${x(e[0])} – ${x(e[1])}`):a.map(e=>i.invertExtent(e)).reduce((e,t,n)=>(n&&e.push(x(t[0])),e),[]),C=S.map(e=>Wr([e],r,l)),w=Wr([p],m,h),T=p.trim().length>0,E={width:Math.max(0,...C.map(e=>e.width)),height:Math.max(0,...C.map(e=>e.height)),ascent:Math.max(0,...C.map(e=>e.ascent))},D=T?w.height+10:0,O=T?w.width:0,k=a.length,A=45,j=15/2;y?(A=N(A,Math.ceil(E.height)+10,Math.floor((n.getContainer().clientHeight-10-ni*2-D)/k)),s=Math.ceil(ni*2+D+k*A),c=Math.ceil(ni*2+Math.max(O,25+E.width))):(A=N(A,Math.ceil(E.width)+10,Math.floor((n.getContainer().clientWidth-10-ni*2)/k)),c=Math.ceil(ni*2+Math.max(O,k*A)),s=Math.ceil(ni*2+D+15+10+E.ascent)),_&&o.push(`
835
+ <rect
836
+ x="0"
837
+ y="0"
838
+ rx="10"
839
+ ry="10"
840
+ width="${c}"
841
+ height="${s}"
842
+ fill="${v}"
843
+ />
844
+ `);let M=ni,P=ni;T&&(o.push(`
845
+ <text
846
+ x="${M}"
847
+ y="${P+w.ascent}"
848
+ font-family="${m}"
849
+ font-size="${h}"
850
+ fill="${g}"
851
+ >
852
+ ${Or(p)}
853
+ </text>
854
+ `),P+=D);let ee=y?15:A,te=y?A:15,F=y?0:A,ne=y?A:0,re=b?15:20,ie=y?`M ${M} ${P+j} v ${A-j} h 15 v ${-(A-j)} a ${j} ${j} 0 0 0 -15 0 z`:`M ${M+j} ${P} h ${A-j} v 15 h ${-(A-j)} a ${j} ${j} 0 0 1 0 -15 z`;o.push(`<path d="${ie}" fill="${a[0]}" />`),M+=F,P+=ne;for(let e=1;e<k-1;e++,M+=F,P+=ne)o.push(`
855
+ <rect
856
+ x="${M}"
857
+ y="${P}"
858
+ width="${ee}"
859
+ height="${te}"
860
+ fill="${a[e]}"
861
+ />
862
+ `),o.push(`
863
+ <line
864
+ x1="${y?M:M+.5}"
865
+ y1="${y?P+.5:P}"
866
+ x2="${y?M+re:M+.5}"
867
+ y2="${y?P+.5:P+re}"
868
+ stroke="#ffffff"
869
+ />
870
+ `);let ae=y?`M ${M} ${P} v ${A-j} a ${j} ${j} 0 0 0 15 0 v ${-(A-j)} z`:`M ${M} ${P} h ${A-j} a ${j} ${j} 0 0 1 0 15 h ${-(A-j)} z`;o.push(`<path d="${ae}" fill="${a[k-1]}" />`),o.push(`
871
+ <line
872
+ x1="${y?M:M+.5}"
873
+ y1="${y?P+.5:P}"
874
+ x2="${y?M+re:M+.5}"
875
+ y2="${y?P+.5:P+re}"
876
+ stroke="#ffffff"
877
+ />
878
+ `),M=ni,P=ni+D;for(let e=0;e<S.length;e++,M+=F,P+=ne)o.push(`
879
+ <text
880
+ x="${y?M+15+10:M+(b?A/2:A)}"
881
+ y="${y?P+(b?A/2:A)-E.height/2+E.ascent:P+15+10+E.ascent}"
882
+ text-anchor="${y?`start`:`middle`}"
883
+ font-family="${r}"
884
+ font-size="${l}"
885
+ fill="${u}"
886
+ >
887
+ ${Or(S[e])}
888
+ </text>
889
+ `)}return`
890
+ <svg
891
+ class="adornment-svg"
892
+ xmlns="http://www.w3.org/2000/svg"
893
+ width="${c*r}"
894
+ height="${s*r}"
895
+ viewBox="0 0 ${c} ${s}"
896
+ >
897
+ ${o.join(``)}
898
+ </svg>
899
+ `}function ci(e,t,n,r){let i=t.categoricalColors[n];if(i===void 0)return ai();let a=wr(i.values),o=Object.entries(i.colors).map(([e,n])=>({color:e,label:n.title??a[e]??t.defaultGroupName,order:n.order,hidden:n.hidden,svg:``})).filter(e=>!e.hidden).sort((e,t)=>e.order-t.order);return ei({type:`manualLegend`,id:e.id,name:e.name,position:e.position,stacking:e.stacking??`vertical`,layout:e.layout??`vertical`,title:e.title??``,titleFont:e.titleFont??ti,titleFontColor:e.titleFontColor??`#000000`,titleFontSize:e.titleFontSize??14,entryFont:e.labelFont??ti,entryFontColor:e.labelFontColor??`#000000`,entryFontSize:e.labelFontSize??13,entryShape:`rectangle`,entries:o,background:e.background??`#ffffff`,showBackground:e.showBackground??!1},ti,r)}function li(e){let{decimal:t,group:n}=ui();return Cn({decimal:t,thousands:n,grouping:[3],currency:[``,``]}).format(e)}function ui(){let e=new Intl.NumberFormat(navigator.languages).formatToParts(1000.1),t=e.find(e=>e.type===`decimal`)?.value,n=e.find(e=>e.type===`group`)?.value;return t!==void 0&&n!==void 0?{decimal:t,group:n}:{decimal:`.`,group:`,`}}function di(e,t,n,r){let i=document.createElement(`div`);i.className=`adornment`,e.showBackground&&(i.style.boxShadow=`0 0 7px 0 rgba(33, 37, 41, 0.25)`,i.style.borderRadius=`10px`);let a=`ArialMT`,o=[e.titleFont??a,e.entryFont??a];return kr(Array.from(new Set(o)),t,n).then(()=>i.innerHTML=ei(e,a,r)),i}function fi(e,t,n){let r=document.createElement(`div`);r.className=`adornment`;let i=(e.scale??1)*30,a=i*n;return r.style.cssText=`width: ${a}px; height: ${a}px`,t.on(`move`,()=>{r.innerHTML=pi(t,i,n)}),r.innerHTML=pi(t,i,n),r}function pi(e,t,n){let r=e.getBearing(),i=e.getPitch();return`
900
+ <svg class="adornment-svg" width="${t*n}" height="${t*n}" viewBox="-5 -5 30 30" xmlns="http://www.w3.org/2000/svg">
901
+ <g class="tilt" style="transform-origin: 33% 33%; transform: rotateX(${i}deg);">
902
+ <g class="rotate" style="transform-origin: 33% 33%; transform: rotate(${-r}deg);">
903
+ <path d="M0 20L10 0L20 20L10 12.7711L0 20Z" fill="#343A40" />
904
+ </g>
905
+ </g>
906
+ </svg>
907
+ `}var mi=`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="currentColor"><path d="M5.5 1h1v10h-1z"/><path d="M1 6.5v-1h10v1z"/></svg>
908
+ `,hi=`<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="M11 6.144H1v-1h10v1Z"/></svg>
909
+ `;function gi(e){let t=document.createElement(`button`);return t.className=e.className,t.innerHTML=`${e.content}`,t.addEventListener(`click`,e.onClick),t}function _i(e){return gi({type:`button`,className:`control-button zoom-in-button`,content:mi,onClick:()=>e.zoomIn()})}function vi(e){return gi({type:`button`,className:`control-button zoom-out-button`,content:hi,onClick:()=>e.zoomOut()})}var yi=`<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="M4.774 6.44a.556.556 0 0 1 .832.734l-.047.052L2.897 9.89h1.436a.555.555 0 0 1 .065 1.107L4.333 11H1.556a.556.556 0 0 1-.552-.49L1 10.443V7.667a.556.556 0 0 1 1.107-.065l.004.065v1.436l2.663-2.662ZM10.444 1a.555.555 0 0 1 .552.49l.004.066v2.777a.556.556 0 0 1-1.107.065l-.004-.065V2.897L7.226 5.559a.556.556 0 0 1-.832-.733l.047-.052L9.103 2.11H7.667a.556.556 0 0 1-.065-1.107L7.667 1h2.777Z"/></svg>
910
+ `;function bi(){return!!(document.fullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled||document.webkitFullscreenEnabled)}function xi(e){return document.fullscreenElement===e||document.webkitFullscreenElement===e||document.mozFullScreenElement===e||document.msFullscreenElement===e}function Si(e){e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.msRequestFullscreen?e.msRequestFullscreen():e.webkitRequestFullscreen&&e.webkitRequestFullscreen()}function Ci(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen?document.msExitFullscreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen()}function wi(e){return gi({type:`button`,className:`control-button fullscreen-control-button`,content:yi,onClick:()=>{let t=e.getContainer();if(bi())xi(t)?Ci():Si(t);else{let e=document.location.href;e+=e.includes(`?`)?`&`:`?`,e+=`close-tab`,window.open(e,`_blank`)}}})}var Ti=`<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M5.571.875V0h.858v.875a5.143 5.143 0 0 1 4.696 4.696H12v.858h-.875a5.143 5.143 0 0 1-4.696 4.696V12H5.57v-.875A5.143 5.143 0 0 1 .875 6.429H0V5.57h.875A5.143 5.143 0 0 1 5.571.875Zm0 .86a4.286 4.286 0 0 0-3.835 3.836h.835v.858h-.835a4.286 4.286 0 0 0 3.835 3.835V9.43h.858v.835a4.285 4.285 0 0 0 3.835-3.835H9.43v-.86h.835A4.285 4.285 0 0 0 6.43 1.736v.835h-.86v-.835Zm-.177 3.659a.857.857 0 1 1 1.212 1.212.857.857 0 0 1-1.212-1.212Z"/></svg>
911
+ `,Ei=`<svg width="34" viewBox="5 5 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#a)" fill="#343A40"><path d="M15.016 22.656a5.797 5.797 0 0 1-1.016-.46c-2.858-1.65-3.846-5.338-2.196-8.196 1.65-2.858 5.338-3.846 8.196-2.196 2.858 1.65 3.846 5.338 2.196 8.196-.2.346-.434.673-.694.962l2.933 2.72A10.1 10.1 0 0 0 25.66 22c2.75-4.763 1.103-10.91-3.66-13.66S11.09 7.237 8.34 12 7.237 22.91 12 25.66a9.61 9.61 0 0 0 1.635.748l1.381-3.752Z"/><path d="m11.01 17.183-3.999.06a10.051 10.051 0 0 0 6.427 9.097l1.484-3.714a6.025 6.025 0 0 1-3.913-5.443Zm13.284 5.183 1-1.732-2.598-1.5-1 1.732 2.598 1.5Zm-3.428-10.062 1.5-2.598-1.732-1-1.5 2.598 1.732 1Zm-9.562 2.562 1-1.732-2.598-1.5-1 1.732 2.598 1.5Z"/><path d="m13.366 25.294 1.5-2.598-1.732-1-1.5 2.598 1.732 1Z"/></g><defs><clipPath id="a"><path fill="#fff" d="m33.393 12.607-12 20.784-20.785-12 12-20.784z"/></clipPath></defs></svg>
912
+ `,Di=`<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"><g filter="url(#a)"><circle cx="16" cy="16" r="10" fill="#349CF2"/><circle cx="16" cy="16" r="9" stroke="#fff" stroke-width="2"/></g><defs><filter id="a" x="0" y="0" width="32" height="32" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feColorMatrix in="SourceAlpha" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/><feOffset dy="4"/><feGaussianBlur stdDeviation="2"/><feComposite in2="hardAlpha" operator="out"/><feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/><feBlend in2="BackgroundImageFix" result="effect1_dropShadow_15_3175"/><feBlend in="SourceGraphic" in2="effect1_dropShadow_15_3175" result="shape"/></filter></defs></svg>
913
+ `,Oi=e=>{let t=2*window.devicePixelRatio,n=new Br(e).getMapLibreImageKey(Di,t);e.setLayoutProperty(`location-dot`,`icon-image`,n)},ki=e=>{e.getSource(`location-circle`)||e.addSource(`location-circle`,{type:`geojson`,data:{type:`FeatureCollection`,features:[]}}),e.getSource(`location-dot`)||e.addSource(`location-dot`,{type:`geojson`,data:{type:`Feature`,geometry:{type:`Point`,coordinates:[]},properties:{}}}),e.getLayer(`location-circle`)||e.addLayer({id:`location-circle`,type:`fill`,source:`location-circle`,layout:{},paint:{"fill-color":`#349CF2`,"fill-opacity":.15,"fill-outline-color":`#005196`}},`mc-before-names`),e.getLayer(`location-dot`)||e.addLayer({id:`location-dot`,type:`symbol`,source:`location-dot`,layout:{"icon-padding":0},paint:{"icon-opacity":1},metadata:{"mc-name":`location dot`,"mc-skip-load":!0}},`mc-before-names`),Oi(e)},Ai=(e,t,n)=>{let r=e.getSource(`location-dot`);r&&r.setData({type:`Feature`,geometry:{type:`Point`,coordinates:[t,n]},properties:{}})},ji=(e,t,n)=>{let r=n/1e3,i=[],a=r/(111.32*Math.cos(t*Math.PI/180)),o=r/110.574;for(let n=0;n<64;n++){let r=n/64*(2*Math.PI),s=a*Math.cos(r),c=o*Math.sin(r);i.push([e+s,t+c])}return i.push(i[0]),{type:`FeatureCollection`,features:[{type:`Feature`,geometry:{type:`Polygon`,coordinates:[i]}}]}},Mi=()=>{let e=document.querySelector(`.map`),t=document.createElement(`div`);t.classList.add(`location-notification`),t.textContent=`Geolocation is not available`,e?.appendChild(t),setTimeout(()=>{e?.removeChild(t)},3e3)};function Ni(e){let t=!1,n=e=>{let n=document.querySelector(`.geolocation-button`),r=n?.querySelector(`.geolocation-icon`),i=n?.querySelector(`.locating-icon`);r&&i&&(r.classList.toggle(`active`,!e),i.classList.toggle(`active`,e)),t=e},r=t=>{let{longitude:r,latitude:i,accuracy:a}=t.coords,o=[r,i];e.easeTo?e.easeTo({center:o,zoom:19,duration:1e3}):e.setCenter&&e.setCenter(o);let s=e.getSource(`location-circle`);s&&s.setData(ji(r,i,a/2)),Ai(e,r,i),e.once(`moveend`,()=>n(!1))},i=e=>{console.error(`Geolocation error:`,e),n(!1)};return gi({type:`button`,className:`control-button geolocation-button`,content:`
914
+ <div class="location-icon geolocation-icon active">${Ti}</div>
915
+ <div class="location-icon locating-icon">${Ei}</div>
916
+ `,onClick:()=>{if(!t){if(e.getSource(`location-circle`)||ki(e),n(!0),!navigator.geolocation){Mi(),n(!1);return}navigator.geolocation.getCurrentPosition(r,i,{maximumAge:6e4,timeout:5e3})}}})}var Pi=`<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="M6.155 1.146A.546.546 0 0 1 6.53 1c.14 0 .275.053.375.146l1.588 1.5c.1.094.155.221.155.354 0 .132-.056.26-.155.353l-1.588 1.5a.546.546 0 0 1-.373.14.545.545 0 0 1-.37-.146.487.487 0 0 1-.154-.349.486.486 0 0 1 .148-.352L6.84 3.5H6c-1.878 0-3.441 1.476-3.441 3.25S4.122 10 6 10s3.441-1.476 3.441-3.25c0-.133.056-.26.155-.354a.546.546 0 0 1 .375-.146c.14 0 .275.053.374.146.1.094.155.221.155.354C10.5 9.076 8.463 11 6 11S1.5 9.076 1.5 6.75 3.537 2.5 6 2.5h.84l-.685-.647A.486.486 0 0 1 6 1.5c0-.133.056-.26.155-.354Z"/></svg>
917
+ `;function Fi(e,t){return gi({type:`button`,className:`control-button refresh-button`,content:Pi,onClick:()=>{e.easeTo({center:t.center,zoom:t.zoom,pitch:t.pitch,bearing:t.rotation})}})}var Ii=`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="currentColor"><path d="M5.374.952a4.546 4.546 0 0 1 4.656 4.175 4.55 4.55 0 0 1-.958 3.184l1.824 1.81a.55.55 0 0 1 0 .765.55.55 0 0 1-.602.121.6.6 0 0 1-.179-.12l-1.807-1.81A4.544 4.544 0 0 1 .953 5.376 4.553 4.553 0 0 1 5.374.952m1.454 1.37a3.447 3.447 0 0 0-4.505 4.51 3.45 3.45 0 0 0 3.186 2.13A3.45 3.45 0 0 0 8.957 5.51a3.455 3.455 0 0 0-2.129-3.187"/></svg>
918
+ `,Li=`<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="currentColor"><path d="m7.038 5.96 3.03 3.03L13.1 5.958l1.01 1.01L11.078 10l3.031 3.032-1.01 1.01-3.031-3.031-3.03 3.028-1.01-1.01L9.059 10l-3.03-3.03z"/></svg>
919
+ `,Ri={da_DK:{search:`Search`,videoAlert:`The video will only work when you publish the map`,mobileHelpText:`Use two fingers to move the map`,windowsHelpText:`Use Ctrl + scroll to zoom the map`,macHelpText:`Use ⌘ + scroll to zoom the map`},de_DE:{search:`Suche`,videoAlert:`Das Video ist in der veröffentlichten Karte sichtbar.`,mobileHelpText:`Verwenden Sie zwei Finger um die Karte zu bewegen`,windowsHelpText:`Verwenden Sie Strg + Scroll um in der Karte zu zoomen`,macHelpText:`Verwenden Sie ⌘ + Scroll um in der Karte zu zoomen`},en_GB:{search:`Search`,videoAlert:`The video will only work when you publish the map`,mobileHelpText:`Use two fingers to move the map`,windowsHelpText:`Use Ctrl + scroll to zoom the map`,macHelpText:`Use ⌘ + scroll to zoom the map`},es_ES:{search:`Buscar`,videoAlert:`The video will only work when you publish the map`,mobileHelpText:`Use dos dedos para mover el mapa`,windowsHelpText:`Use Ctrl + desplazamiento para hacer zoom en el mapa`,macHelpText:`Use ⌘ + desplazamiento para hacer zoom en el mapa`},fr_FR:{search:`Rechercher`,videoAlert:`Votre vidéo sera diffusée sur la carte publiée`,mobileHelpText:`Utilisez deux doigts pour déplacer la carte`,windowsHelpText:`Utilisez Ctrl + défilement pour zoomer sur la carte`,macHelpText:`Utilisez ⌘ + défilement pour zoomer sur la carte`},it_IT:{search:`Cercare`,videoAlert:`The video will only work when you publish the map`,mobileHelpText:`Usa due dita per muovere la mappa`,windowsHelpText:`Usa Ctrl + Scroll per ingrandire la mappa`,macHelpText:`Usa ⌘ + Scroll per ingrandire la mappa`},nl_NL:{search:`Zoeken`,videoAlert:`The video will only work when you publish the map`,mobileHelpText:`Gebruik twee vingers om de kaart te bewegen`,windowsHelpText:`Gebruik Ctrl + Scroll om de kaart te zoomen`,macHelpText:`Gebruik ⌘ + Scroll om de kaart te zoomen`}};function zi(){let e=navigator.language.replace(`-`,`_`),t=Object.keys(Ri);return t.find(t=>t===e)??t.find(t=>t.split(`_`)[0]===e.split(`_`)[0])??`en_GB`}var Bi=zi();function Vi(e){return Ri[Bi][e]??e}var Hi=class{async getLocationInBounds(e,t,n=10){try{let r=await this._callGraphHopper({limit:n,q:e,point:`${t.lat},${t.lng}`});return this._mapResults(r.hits)}catch(e){return console.warn(`Geocoding failed: `,e),[]}}async _callGraphHopper(e){let t=new URLSearchParams(e);t.append(`key`,`c5c40ac9-ed73-4e20-aed6-cfe495604ca8`),t.append(`locale`,Bi.slice(0,2));let n={headers:{Accept:`application/json`}},r=`https://graphhopper.com/api/1/geocode?${t}`;return await(await fetch(r,n)).json()}_mapResults(e){return e.map(e=>({id:e.osm_id.toString(),labelTitle:e.name,position:{lng:e.point.lng,lat:e.point.lat},bbox:e.extent?[{lng:e.extent[0],lat:e.extent[1]},{lng:e.extent[2],lat:e.extent[3]}]:null,subtitle:[e.osm_value,e.city,e.state,e.country].filter(Boolean).join(`, `)}))}},Ui=class{map;mapContainer;container;control;input;dropdown;inputWrapper;button;isOpen=!1;geocoder=new Hi;suggestions=[];items=[];index=0;debounce;constructor(e){this.map=e,this.container=document.createElement(`div`),this.control=document.createElement(`div`),this.input=document.createElement(`input`),this.dropdown=document.createElement(`div`),this.inputWrapper=document.createElement(`div`),this.button=document.createElement(`button`),this.mapContainer=this.map.getContainer()}init(){this.container.className=`geocoder-container`,this.control.className=`geocoder-control`,this.input.className=`geocoder-input`,this.dropdown.className=`geocoder-dropdown`,this.inputWrapper.className=`geocoder-input-wrapper`,this.button.className=`control-button`,this.input.type=`text`,this.input.placeholder=Vi(`search`),this.button.innerHTML=Ii;let e=document.createElement(`button`);e.className=`geocoder-clear`,e.innerHTML=Li;let t=document.createElement(`div`);return t.className=`geocoder-scrollwrapper`,t.append(this.dropdown),this.inputWrapper.append(this.input,e),this.control.append(this.button,this.inputWrapper,t),e.addEventListener(`click`,()=>this.clearAll()),this.button.addEventListener(`click`,()=>this.toggle()),this.input.addEventListener(`input`,()=>this.onInput()),this.input.addEventListener(`keydown`,e=>this.onKeyDown(e)),this.dropdown.addEventListener(`mousemove`,e=>this.onMouseMove(e)),this.mapContainer.addEventListener(`mousedown`,e=>this.clickOutside(e)),window.addEventListener(`resize`,()=>this.setMaxSizes()),this.setMaxSizes(),this.updateVisibility(),this.container.append(this.control),this.container}clickOutside(e){e.target instanceof Node&&!this.control.contains(e.target)&&this.hide()}setMaxSizes(){let{width:e,height:t}=this.mapContainer.getBoundingClientRect();this.control.style.maxWidth=`${e-40}px`,this.dropdown.style.maxHeight=`${Math.min(310,t-63)}px`}toggle(){this.isOpen=!this.isOpen,this.button.classList.toggle(`open`),this.updateVisibility(),this.isOpen&&this.input.focus()}hide(){this.isOpen&&(this.isOpen=!1,this.button.classList.remove(`open`),this.updateVisibility())}clearDropdown(){this.suggestions=[],this.items=[],this.dropdown.innerHTML=``}clearAll(){this.input.value=``,this.clearDropdown()}updateVisibility(){let e=this.isOpen;this.inputWrapper.style.display=e?`flex`:`none`,e||this.clearAll()}onInput(){let e=this.input.value.trim();if(this.debounce&&clearTimeout(this.debounce),e.length<2){this.dropdown.innerHTML=``;return}this.debounce=window.setTimeout(async()=>{this.suggestions=await this.geocoder.getLocationInBounds(e,this.map.getCenter(),20),this.items=[],this.renderSuggestions()},200)}renderSuggestions(){this.dropdown.innerHTML=``,this.items=[],this.index=0,this.suggestions.forEach(e=>{let t=document.createElement(`div`),n=document.createElement(`div`),r=document.createElement(`div`);t.className=`geocoder-suggestion`,n.className=`title`,r.className=`subtitle`,n.textContent=e.labelTitle,r.textContent=e.subtitle,t.append(n,r),t.addEventListener(`mousedown`,t=>{t.stopPropagation(),this.goToSelection(e)}),this.dropdown.appendChild(t),this.items.push({data:e,el:t})}),this.updateHighlight()}updateHighlight(){this.items.forEach((e,t)=>{e.el.classList.toggle(`highlight`,t===this.index)})}onKeyDown(e){if(e.key===`ArrowUp`)e.preventDefault(),this.index--,this.index<0&&(this.index=this.items.length-1),this.adjustScroll();else if(e.key===`ArrowDown`)e.preventDefault(),this.index++,this.index>this.items.length-1&&(this.index=0),this.adjustScroll();else if(e.key===`Enter`){e.preventDefault();let t=this.items[this.index];t&&this.goToSelection(t.data)}else e.key===`Escape`&&(e.preventDefault(),this.hide());this.updateHighlight()}onMouseMove(e){let t=e.target.closest(`.geocoder-suggestion`);this.index=this.items.findIndex(e=>e.el===t),this.updateHighlight()}goToSelection(e){e.bbox?this.map.fitBounds(e.bbox,{duration:0,animate:!1}):this.map.jumpTo({center:e.position,zoom:16}),this.input.value=e.labelTitle,this.clearDropdown()}adjustScroll(){let e=this.items[this.index].el,t=this.dropdown,n=t.getBoundingClientRect(),r=e.getBoundingClientRect();r.bottom>n.bottom?t.scrollTop+=r.bottom-n.bottom:r.top<n.top&&(t.scrollTop+=r.top-n.top)}};function Wi(e,t,n){let r=document.createElement(`div`);r.classList.add(`web-control`,`adornment`);let i=e.buttons.flatMap(e=>e===`zoom`?[`zoomIn`,`zoomOut`]:e);return(Er()?i.filter(e=>e!==`zoomIn`&&e!==`zoomOut`):i).forEach(e=>{let i;if(e===`zoomIn`)i=_i(t);else if(e===`zoomOut`)i=vi(t);else if(e===`fullscreen`)i=wi(t);else if(e===`geolocation`)i=Ni(t);else if(e===`refresh`)i=Fi(t,n);else if(e===`search`)i=new Ui(t).init();else return;r.appendChild(i)}),r}var Gi={here:{href:`https://www.here.com/`,label:`© HERE 2025`},mapcreator:{href:`https://mapcreator.io/`,label:`© Mapcreator`},openStreetMap:{href:`https://www.openstreetmap.org/copyright/`,label:`© OpenStreetMap`}};function Ki(e,t,n){let r=document.createElement(`div`);r.className=`adornment`;let i=()=>{r.innerHTML=Yi(t,e,n)};return i(),t.on(`attributionchange`,i),t.on(`zoomend`,i),r}function qi(e){let t=Object.values(e.style.sourceCaches),n=[Gi.mapcreator],r={osm:!1,here:!1};for(let e=0;e<t.length&&!(r.osm&&r.here);++e){let n=t[e];if(n.used){let e=n.getSource();`attribution`in e&&typeof e.attribution==`string`&&(e.attribution.includes(`OpenStreetMap`)&&(r.osm=!0),e.attribution.includes(`HERE`)&&(r.here=!0))}}return r.osm&&n.push(Gi.openStreetMap),r.here&&n.push(Gi.here),n}function Ji(e,t,n){let r=document.createElement(`span`);r.style.fontFamily=t,r.style.fontSize=`${n}px`,r.style.position=`absolute`,r.style.visibility=`hidden`,r.innerText=e,document.body.appendChild(r);let i=Math.max(r.offsetWidth,1);return r.remove(),i}function Yi(e,t,n){let{color:r=`#000000`,font:i=`Arial, sans-serif`,fontSize:a=10,orientation:o=`horizontal`,position:s}=t,c=qi(e),l=Ji(c.map(({label:e})=>e).join(` `),i,a),u=a*1.2,d=o===`vertical`,f=[`top_left`,`bottom_left`].includes(s),p=d?u:l,m=d?l:u,h=d?f?-90:90:0,g=d?f?.38*a:.3*a:.38*a,_=c.map(e=>`<a href="${e.href}" target="_blank">${e.label}</a>`).join(` `);return`
920
+ <svg
921
+ class="adornment-svg"
922
+ xmlns="http://www.w3.org/2000/svg"
923
+ viewBox="0 0 ${p} ${m}"
924
+ width="${p*n}"
925
+ height="${m*n}"
926
+ overflow="visible"
927
+ >
928
+ <text
929
+ x="${p/2}"
930
+ y="${m/2+g}"
931
+ transform="rotate(${h} ${p/2} ${m/2})"
932
+ font-family="${i}"
933
+ font-size="${a}"
934
+ fill="${r}"
935
+ text-anchor="middle"
936
+ pointer-events="none"
937
+ >${_}</text>
938
+ </svg>
939
+ `}function Xi(e){return Gn(e,(e,t)=>e+Zi(t),0)}function Zi(e){let t=0,n;switch(e.type){case`Polygon`:return Qi(e.coordinates);case`MultiPolygon`:for(n=0;n<e.coordinates.length;n++)t+=Qi(e.coordinates[n]);return t;case`Point`:case`MultiPoint`:case`LineString`:case`MultiLineString`:return 0}return 0}function Qi(e){let t=0;if(e&&e.length>0){t+=Math.abs(ta(e[0]));for(let n=1;n<e.length;n++)t-=Math.abs(ta(e[n]))}return t}var $i=In*In/2,ea=Math.PI/180;function ta(e){let t=e.length-1;if(t<=2)return 0;let n=0,r=0;for(;r<t;){let i=e[r],a=e[r+1===t?0:r+1],o=e[r+2>=t?(r+2)%t:r+2],s=i[0]*ea,c=a[1]*ea,l=o[0]*ea;n+=(l-s)*Math.sin(c),r++}return n*$i}function na(e){return e}function ra(e){if(e==null)return na;var t,n,r=e.scale[0],i=e.scale[1],a=e.translate[0],o=e.translate[1];return function(e,s){s||(t=n=0);var c=2,l=e.length,u=Array(l);for(u[0]=(t+=e[0])*r+a,u[1]=(n+=e[1])*i+o;c<l;)u[c]=e[c],++c;return u}}function ia(e,t){for(var n,r=e.length,i=r-t;i<--r;)n=e[i],e[i++]=e[r],e[r]=n}function aa(e,t){return typeof t==`string`&&(t=e.objects[t]),t.type===`GeometryCollection`?{type:`FeatureCollection`,features:t.geometries.map(function(t){return oa(e,t)})}:oa(e,t)}function oa(e,t){var n=t.id,r=t.bbox,i=t.properties==null?{}:t.properties,a=sa(e,t);return n==null&&r==null?{type:`Feature`,properties:i,geometry:a}:r==null?{type:`Feature`,id:n,properties:i,geometry:a}:{type:`Feature`,id:n,bbox:r,properties:i,geometry:a}}function sa(e,t){var n=ra(e.transform),r=e.arcs;function i(e,t){t.length&&t.pop();for(var i=r[e<0?~e:e],a=0,o=i.length;a<o;++a)t.push(n(i[a],a));e<0&&ia(t,o)}function a(e){return n(e)}function o(e){for(var t=[],n=0,r=e.length;n<r;++n)i(e[n],t);return t.length<2&&t.push(t[0]),t}function s(e){for(var t=o(e);t.length<4;)t.push(t[0]);return t}function c(e){return e.map(s)}function l(e){var t=e.type,n;switch(t){case`GeometryCollection`:return{type:t,geometries:e.geometries.map(l)};case`Point`:n=a(e.coordinates);break;case`MultiPoint`:n=e.coordinates.map(a);break;case`LineString`:n=o(e.arcs);break;case`MultiLineString`:n=e.arcs.map(o);break;case`Polygon`:n=c(e.arcs);break;case`MultiPolygon`:n=e.arcs.map(c);break;default:return null}return{type:t,coordinates:n}}return l(t)}var Y=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,ca=Math.ceil,la=Math.floor,ua=`[BigNumber Error] `,da=ua+`Number primitive has more than 15 significant digits: `,fa=0x5af3107a4000,X=14,Z=9007199254740991,pa=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,0xe8d4a51000,0x9184e72a000],ma=1e7,ha=1e9;function ga(e){var t,n,r,i=v.prototype={constructor:v,toString:null,valueOf:null},a=new v(1),o=20,s=4,c=-7,l=21,u=-1e7,d=1e7,f=!1,p=1,m=0,h={prefix:``,groupSize:3,secondaryGroupSize:0,groupSeparator:`,`,decimalSeparator:`.`,fractionGroupSize:0,fractionGroupSeparator:`\xA0`,suffix:``},g=`0123456789abcdefghijklmnopqrstuvwxyz`,_=!0;function v(e,t){var i,a,c,l,f,p,m,h,y=this;if(!(y instanceof v))return new v(e,t);if(t==null){if(e&&e._isBigNumber===!0){y.s=e.s,!e.c||e.e>d?y.c=y.e=null:e.e<u?y.c=[y.e=0]:(y.e=e.e,y.c=e.c.slice());return}if((p=typeof e==`number`)&&e*0==0){if(y.s=1/e<0?(e=-e,-1):1,e===~~e){for(l=0,f=e;f>=10;f/=10,l++);l>d?y.c=y.e=null:(y.e=l,y.c=[e]);return}h=String(e)}else{if(!Y.test(h=String(e)))return r(y,h,p);y.s=h.charCodeAt(0)==45?(h=h.slice(1),-1):1}(l=h.indexOf(`.`))>-1&&(h=h.replace(`.`,``)),(f=h.search(/e/i))>0?(l<0&&(l=f),l+=+h.slice(f+1),h=h.substring(0,f)):l<0&&(l=h.length)}else{if(ba(t,2,g.length,`Base`),t==10&&_)return y=new v(e),S(y,o+y.e+1,s);if(h=String(e),p=typeof e==`number`){if(e*0!=0)return r(y,h,p,t);if(y.s=1/e<0?(h=h.slice(1),-1):1,v.DEBUG&&h.replace(/^0\.0*|\./,``).length>15)throw Error(da+e)}else y.s=h.charCodeAt(0)===45?(h=h.slice(1),-1):1;for(i=g.slice(0,t),l=f=0,m=h.length;f<m;f++)if(i.indexOf(a=h.charAt(f))<0){if(a==`.`){if(f>l){l=m;continue}}else if(!c&&(h==h.toUpperCase()&&(h=h.toLowerCase())||h==h.toLowerCase()&&(h=h.toUpperCase()))){c=!0,f=-1,l=0;continue}return r(y,String(e),p,t)}p=!1,h=n(h,t,10,y.s),(l=h.indexOf(`.`))>-1?h=h.replace(`.`,``):l=h.length}for(f=0;h.charCodeAt(f)===48;f++);for(m=h.length;h.charCodeAt(--m)===48;);if(h=h.slice(f,++m)){if(m-=f,p&&v.DEBUG&&m>15&&(e>Z||e!==la(e)))throw Error(da+y.s*e);if((l=l-f-1)>d)y.c=y.e=null;else if(l<u)y.c=[y.e=0];else{if(y.e=l,y.c=[],f=(l+1)%X,l<0&&(f+=X),f<m){for(f&&y.c.push(+h.slice(0,f)),m-=X;f<m;)y.c.push(+h.slice(f,f+=X));f=X-(h=h.slice(f)).length}else f-=m;for(;f--;h+=`0`);y.c.push(+h)}}else y.c=[y.e=0]}v.clone=ga,v.ROUND_UP=0,v.ROUND_DOWN=1,v.ROUND_CEIL=2,v.ROUND_FLOOR=3,v.ROUND_HALF_UP=4,v.ROUND_HALF_DOWN=5,v.ROUND_HALF_EVEN=6,v.ROUND_HALF_CEIL=7,v.ROUND_HALF_FLOOR=8,v.EUCLID=9,v.config=v.set=function(e){var t,n;if(e!=null)if(typeof e==`object`){if(e.hasOwnProperty(t=`DECIMAL_PLACES`)&&(n=e[t],ba(n,0,ha,t),o=n),e.hasOwnProperty(t=`ROUNDING_MODE`)&&(n=e[t],ba(n,0,8,t),s=n),e.hasOwnProperty(t=`EXPONENTIAL_AT`)&&(n=e[t],n&&n.pop?(ba(n[0],-ha,0,t),ba(n[1],0,ha,t),c=n[0],l=n[1]):(ba(n,-ha,ha,t),c=-(l=n<0?-n:n))),e.hasOwnProperty(t=`RANGE`))if(n=e[t],n&&n.pop)ba(n[0],-ha,-1,t),ba(n[1],1,ha,t),u=n[0],d=n[1];else if(ba(n,-ha,ha,t),n)u=-(d=n<0?-n:n);else throw Error(ua+t+` cannot be zero: `+n);if(e.hasOwnProperty(t=`CRYPTO`))if(n=e[t],n===!!n)if(n)if(typeof crypto<`u`&&crypto&&(crypto.getRandomValues||crypto.randomBytes))f=n;else throw f=!n,Error(ua+`crypto unavailable`);else f=n;else throw Error(ua+t+` not true or false: `+n);if(e.hasOwnProperty(t=`MODULO_MODE`)&&(n=e[t],ba(n,0,9,t),p=n),e.hasOwnProperty(t=`POW_PRECISION`)&&(n=e[t],ba(n,0,ha,t),m=n),e.hasOwnProperty(t=`FORMAT`))if(n=e[t],typeof n==`object`)h=n;else throw Error(ua+t+` not an object: `+n);if(e.hasOwnProperty(t=`ALPHABET`))if(n=e[t],typeof n==`string`&&!/^.?$|[+\-.\s]|(.).*\1/.test(n))_=n.slice(0,10)==`0123456789`,g=n;else throw Error(ua+t+` invalid: `+n)}else throw Error(ua+`Object expected: `+e);return{DECIMAL_PLACES:o,ROUNDING_MODE:s,EXPONENTIAL_AT:[c,l],RANGE:[u,d],CRYPTO:f,MODULO_MODE:p,POW_PRECISION:m,FORMAT:h,ALPHABET:g}},v.isBigNumber=function(e){if(!e||e._isBigNumber!==!0)return!1;if(!v.DEBUG)return!0;var t,n,r=e.c,i=e.e,a=e.s;out:if({}.toString.call(r)==`[object Array]`){if((a===1||a===-1)&&i>=-ha&&i<=ha&&i===la(i)){if(r[0]===0){if(i===0&&r.length===1)return!0;break out}if(t=(i+1)%X,t<1&&(t+=X),String(r[0]).length==t){for(t=0;t<r.length;t++)if(n=r[t],n<0||n>=fa||n!==la(n))break out;if(n!==0)return!0}}}else if(r===null&&i===null&&(a===null||a===1||a===-1))return!0;throw Error(ua+`Invalid BigNumber: `+e)},v.maximum=v.max=function(){return b(arguments,-1)},v.minimum=v.min=function(){return b(arguments,1)},v.random=(function(){var e=9007199254740992,t=Math.random()*e&2097151?function(){return la(Math.random()*e)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(e){var n,r,i,s,c,l=0,u=[],d=new v(a);if(e==null?e=o:ba(e,0,ha),s=ca(e/X),f)if(crypto.getRandomValues){for(n=crypto.getRandomValues(new Uint32Array(s*=2));l<s;)c=n[l]*131072+(n[l+1]>>>11),c>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),n[l]=r[0],n[l+1]=r[1]):(u.push(c%0x5af3107a4000),l+=2);l=s/2}else if(crypto.randomBytes){for(n=crypto.randomBytes(s*=7);l<s;)c=(n[l]&31)*281474976710656+n[l+1]*1099511627776+n[l+2]*4294967296+n[l+3]*16777216+(n[l+4]<<16)+(n[l+5]<<8)+n[l+6],c>=9e15?crypto.randomBytes(7).copy(n,l):(u.push(c%0x5af3107a4000),l+=7);l=s/7}else throw f=!1,Error(ua+`crypto unavailable`);if(!f)for(;l<s;)c=t(),c<9e15&&(u[l++]=c%0x5af3107a4000);for(s=u[--l],e%=X,s&&e&&(c=pa[X-e],u[l]=la(s/c)*c);u[l]===0;u.pop(),l--);if(l<0)u=[i=0];else{for(i=-1;u[0]===0;u.splice(0,1),i-=X);for(l=1,c=u[0];c>=10;c/=10,l++);l<X&&(i-=X-l)}return d.e=i,d.c=u,d}})(),v.sum=function(){for(var e=1,t=arguments,n=new v(t[0]);e<t.length;)n=n.plus(t[e++]);return n},n=(function(){var e=`0123456789`;function n(e,t,n,r){for(var i,a=[0],o,s=0,c=e.length;s<c;){for(o=a.length;o--;a[o]*=t);for(a[0]+=r.indexOf(e.charAt(s++)),i=0;i<a.length;i++)a[i]>n-1&&(a[i+1]??(a[i+1]=0),a[i+1]+=a[i]/n|0,a[i]%=n)}return a.reverse()}return function(r,i,a,c,l){var u,d,f,p,h,_,y,b,x=r.indexOf(`.`),S=o,C=s;for(x>=0&&(p=m,m=0,r=r.replace(`.`,``),b=new v(i),_=b.pow(r.length-x),m=p,b.c=n(Ca(va(_.c),_.e,`0`),10,a,e),b.e=b.c.length),y=n(r,i,a,l?(u=g,e):(u=e,g)),f=p=y.length;y[--p]==0;y.pop());if(!y[0])return u.charAt(0);if(x<0?--f:(_.c=y,_.e=f,_.s=c,_=t(_,b,S,C,a),y=_.c,h=_.r,f=_.e),d=f+S+1,x=y[d],p=a/2,h=h||d<0||y[d+1]!=null,h=C<4?(x!=null||h)&&(C==0||C==(_.s<0?3:2)):x>p||x==p&&(C==4||h||C==6&&y[d-1]&1||C==(_.s<0?8:7)),d<1||!y[0])r=h?Ca(u.charAt(1),-S,u.charAt(0)):u.charAt(0);else{if(y.length=d,h)for(--a;++y[--d]>a;)y[d]=0,d||(++f,y=[1].concat(y));for(p=y.length;!y[--p];);for(x=0,r=``;x<=p;r+=u.charAt(y[x++]));r=Ca(r,f,u.charAt(0))}return r}})(),t=(function(){function e(e,t,n){var r,i,a,o,s=0,c=e.length,l=t%ma,u=t/ma|0;for(e=e.slice();c--;)a=e[c]%ma,o=e[c]/ma|0,r=u*a+o*l,i=l*a+r%ma*ma+s,s=(i/n|0)+(r/ma|0)+u*o,e[c]=i%n;return s&&(e=[s].concat(e)),e}function t(e,t,n,r){var i,a;if(n!=r)a=n>r?1:-1;else for(i=a=0;i<n;i++)if(e[i]!=t[i]){a=e[i]>t[i]?1:-1;break}return a}function n(e,t,n,r){for(var i=0;n--;)e[n]-=i,i=e[n]<t[n]?1:0,e[n]=i*r+e[n]-t[n];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(r,i,a,o,s){var c,l,u,d,f,p,m,h,g,_,y,b,x,C,w,T,E,D=r.s==i.s?1:-1,O=r.c,k=i.c;if(!O||!O[0]||!k||!k[0])return new v(!r.s||!i.s||(O?k&&O[0]==k[0]:!k)?NaN:O&&O[0]==0||!k?D*0:D/0);for(h=new v(D),g=h.c=[],l=r.e-i.e,D=a+l+1,s||(s=fa,l=_a(r.e/X)-_a(i.e/X),D=D/X|0),u=0;k[u]==(O[u]||0);u++);if(k[u]>(O[u]||0)&&l--,D<0)g.push(1),d=!0;else{for(C=O.length,T=k.length,u=0,D+=2,f=la(s/(k[0]+1)),f>1&&(k=e(k,f,s),O=e(O,f,s),T=k.length,C=O.length),x=T,_=O.slice(0,T),y=_.length;y<T;_[y++]=0);E=k.slice(),E=[0].concat(E),w=k[0],k[1]>=s/2&&w++;do{if(f=0,c=t(k,_,T,y),c<0){if(b=_[0],T!=y&&(b=b*s+(_[1]||0)),f=la(b/w),f>1)for(f>=s&&(f=s-1),p=e(k,f,s),m=p.length,y=_.length;t(p,_,m,y)==1;)f--,n(p,T<m?E:k,m,s),m=p.length,c=1;else f==0&&(c=f=1),p=k.slice(),m=p.length;if(m<y&&(p=[0].concat(p)),n(_,p,y,s),y=_.length,c==-1)for(;t(k,_,T,y)<1;)f++,n(_,T<y?E:k,y,s),y=_.length}else c===0&&(f++,_=[0]);g[u++]=f,_[0]?_[y++]=O[x]||0:(_=[O[x]],y=1)}while((x++<C||_[0]!=null)&&D--);d=_[0]!=null,g[0]||g.splice(0,1)}if(s==fa){for(u=1,D=g[0];D>=10;D/=10,u++);S(h,a+(h.e=u+l*X-1)+1,o,d)}else h.e=l,h.r=+d;return h}})();function y(e,t,n,r){var i,a,o,u,d;if(n==null?n=s:ba(n,0,8),!e.c)return e.toString();if(i=e.c[0],o=e.e,t==null)d=va(e.c),d=r==1||r==2&&(o<=c||o>=l)?Sa(d,o):Ca(d,o,`0`);else if(e=S(new v(e),t,n),a=e.e,d=va(e.c),u=d.length,r==1||r==2&&(t<=a||a<=c)){for(;u<t;d+=`0`,u++);d=Sa(d,a)}else if(t-=o+(r===2&&a>o),d=Ca(d,a,`0`),a+1>u){if(--t>0)for(d+=`.`;t--;d+=`0`);}else if(t+=a-u,t>0)for(a+1==u&&(d+=`.`);t--;d+=`0`);return e.s<0&&i?`-`+d:d}function b(e,t){for(var n,r,i=1,a=new v(e[0]);i<e.length;i++)r=new v(e[i]),(!r.s||(n=ya(a,r))===t||n===0&&a.s===t)&&(a=r);return a}function x(e,t,n){for(var r=1,i=t.length;!t[--i];t.pop());for(i=t[0];i>=10;i/=10,r++);return(n=r+n*X-1)>d?e.c=e.e=null:n<u?e.c=[e.e=0]:(e.e=n,e.c=t),e}r=(function(){var e=/^(-?)0([xbo])(?=\w[\w.]*$)/i,t=/^([^.]+)\.$/,n=/^\.([^.]+)$/,r=/^-?(Infinity|NaN)$/,i=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(a,o,s,c){var l,u=s?o:o.replace(i,``);if(r.test(u))a.s=isNaN(u)?null:u<0?-1:1;else{if(!s&&(u=u.replace(e,function(e,t,n){return l=(n=n.toLowerCase())==`x`?16:n==`b`?2:8,!c||c==l?t:e}),c&&(l=c,u=u.replace(t,`$1`).replace(n,`0.$1`)),o!=u))return new v(u,l);if(v.DEBUG)throw Error(ua+`Not a`+(c?` base `+c:``)+` number: `+o);a.s=null}a.c=a.e=null}})();function S(e,t,n,r){var i,a,o,s,c,l,f,p=e.c,m=pa;if(p){out:{for(i=1,s=p[0];s>=10;s/=10,i++);if(a=t-i,a<0)a+=X,o=t,c=p[l=0],f=la(c/m[i-o-1]%10);else if(l=ca((a+1)/X),l>=p.length)if(r){for(;p.length<=l;p.push(0));c=f=0,i=1,a%=X,o=a-X+1}else break out;else{for(c=s=p[l],i=1;s>=10;s/=10,i++);a%=X,o=a-X+i,f=o<0?0:la(c/m[i-o-1]%10)}if(r=r||t<0||p[l+1]!=null||(o<0?c:c%m[i-o-1]),r=n<4?(f||r)&&(n==0||n==(e.s<0?3:2)):f>5||f==5&&(n==4||r||n==6&&(a>0?o>0?c/m[i-o]:0:p[l-1])%10&1||n==(e.s<0?8:7)),t<1||!p[0])return p.length=0,r?(t-=e.e+1,p[0]=m[(X-t%X)%X],e.e=-t||0):p[0]=e.e=0,e;if(a==0?(p.length=l,s=1,l--):(p.length=l+1,s=m[X-a],p[l]=o>0?la(c/m[i-o]%m[o])*s:0),r)for(;;)if(l==0){for(a=1,o=p[0];o>=10;o/=10,a++);for(o=p[0]+=s,s=1;o>=10;o/=10,s++);a!=s&&(e.e++,p[0]==fa&&(p[0]=1));break}else{if(p[l]+=s,p[l]!=fa)break;p[l--]=0,s=1}for(a=p.length;p[--a]===0;p.pop());}e.e>d?e.c=e.e=null:e.e<u&&(e.c=[e.e=0])}return e}function C(e){var t,n=e.e;return n===null?e.toString():(t=va(e.c),t=n<=c||n>=l?Sa(t,n):Ca(t,n,`0`),e.s<0?`-`+t:t)}return i.absoluteValue=i.abs=function(){var e=new v(this);return e.s<0&&(e.s=1),e},i.comparedTo=function(e,t){return ya(this,new v(e,t))},i.decimalPlaces=i.dp=function(e,t){var n,r,i,a=this;if(e!=null)return ba(e,0,ha),t==null?t=s:ba(t,0,8),S(new v(a),e+a.e+1,t);if(!(n=a.c))return null;if(r=((i=n.length-1)-_a(this.e/X))*X,i=n[i])for(;i%10==0;i/=10,r--);return r<0&&(r=0),r},i.dividedBy=i.div=function(e,n){return t(this,new v(e,n),o,s)},i.dividedToIntegerBy=i.idiv=function(e,n){return t(this,new v(e,n),0,1)},i.exponentiatedBy=i.pow=function(e,t){var n,r,i,o,c,l,u,d,f,p=this;if(e=new v(e),e.c&&!e.isInteger())throw Error(ua+`Exponent not an integer: `+C(e));if(t!=null&&(t=new v(t)),l=e.e>14,!p.c||!p.c[0]||p.c[0]==1&&!p.e&&p.c.length==1||!e.c||!e.c[0])return f=new v(C(p)**(l?e.s*(2-xa(e)):+C(e))),t?f.mod(t):f;if(u=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new v(NaN);r=!u&&p.isInteger()&&t.isInteger(),r&&(p=p.mod(t))}else if(e.e>9&&(p.e>0||p.e<-1||(p.e==0?p.c[0]>1||l&&p.c[1]>=24e7:p.c[0]<8e13||l&&p.c[0]<=9999975e7)))return o=p.s<0&&xa(e)?-0:0,p.e>-1&&(o=1/o),new v(u?1/o:o);else m&&(o=ca(m/X+2));for(l?(n=new v(.5),u&&(e.s=1),d=xa(e)):(i=Math.abs(+C(e)),d=i%2),f=new v(a);;){if(d){if(f=f.times(p),!f.c)break;o?f.c.length>o&&(f.c.length=o):r&&(f=f.mod(t))}if(i){if(i=la(i/2),i===0)break;d=i%2}else if(e=e.times(n),S(e,e.e+1,1),e.e>14)d=xa(e);else{if(i=+C(e),i===0)break;d=i%2}p=p.times(p),o?p.c&&p.c.length>o&&(p.c.length=o):r&&(p=p.mod(t))}return r?f:(u&&(f=a.div(f)),t?f.mod(t):o?S(f,m,s,c):f)},i.integerValue=function(e){var t=new v(this);return e==null?e=s:ba(e,0,8),S(t,t.e+1,e)},i.isEqualTo=i.eq=function(e,t){return ya(this,new v(e,t))===0},i.isFinite=function(){return!!this.c},i.isGreaterThan=i.gt=function(e,t){return ya(this,new v(e,t))>0},i.isGreaterThanOrEqualTo=i.gte=function(e,t){return(t=ya(this,new v(e,t)))===1||t===0},i.isInteger=function(){return!!this.c&&_a(this.e/X)>this.c.length-2},i.isLessThan=i.lt=function(e,t){return ya(this,new v(e,t))<0},i.isLessThanOrEqualTo=i.lte=function(e,t){return(t=ya(this,new v(e,t)))===-1||t===0},i.isNaN=function(){return!this.s},i.isNegative=function(){return this.s<0},i.isPositive=function(){return this.s>0},i.isZero=function(){return!!this.c&&this.c[0]==0},i.minus=function(e,t){var n,r,i,a,o=this,c=o.s;if(e=new v(e,t),t=e.s,!c||!t)return new v(NaN);if(c!=t)return e.s=-t,o.plus(e);var l=o.e/X,u=e.e/X,d=o.c,f=e.c;if(!l||!u){if(!d||!f)return d?(e.s=-t,e):new v(f?o:NaN);if(!d[0]||!f[0])return f[0]?(e.s=-t,e):new v(d[0]?o:s==3?-0:0)}if(l=_a(l),u=_a(u),d=d.slice(),c=l-u){for((a=c<0)?(c=-c,i=d):(u=l,i=f),i.reverse(),t=c;t--;i.push(0));i.reverse()}else for(r=(a=(c=d.length)<(t=f.length))?c:t,c=t=0;t<r;t++)if(d[t]!=f[t]){a=d[t]<f[t];break}if(a&&(i=d,d=f,f=i,e.s=-e.s),t=(r=f.length)-(n=d.length),t>0)for(;t--;d[n++]=0);for(t=fa-1;r>c;){if(d[--r]<f[r]){for(n=r;n&&!d[--n];d[n]=t);--d[n],d[r]+=fa}d[r]-=f[r]}for(;d[0]==0;d.splice(0,1),--u);return d[0]?x(e,d,u):(e.s=s==3?-1:1,e.c=[e.e=0],e)},i.modulo=i.mod=function(e,n){var r,i,a=this;return e=new v(e,n),!a.c||!e.s||e.c&&!e.c[0]?new v(NaN):!e.c||a.c&&!a.c[0]?new v(a):(p==9?(i=e.s,e.s=1,r=t(a,e,0,3),e.s=i,r.s*=i):r=t(a,e,0,p),e=a.minus(r.times(e)),!e.c[0]&&p==1&&(e.s=a.s),e)},i.multipliedBy=i.times=function(e,t){var n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_=this,y=_.c,b=(e=new v(e,t)).c;if(!y||!b||!y[0]||!b[0])return!_.s||!e.s||y&&!y[0]&&!b||b&&!b[0]&&!y?e.c=e.e=e.s=null:(e.s*=_.s,!y||!b?e.c=e.e=null:(e.c=[0],e.e=0)),e;for(r=_a(_.e/X)+_a(e.e/X),e.s*=_.s,c=y.length,d=b.length,c<d&&(m=y,y=b,b=m,i=c,c=d,d=i),i=c+d,m=[];i--;m.push(0));for(h=fa,g=ma,i=d;--i>=0;){for(n=0,f=b[i]%g,p=b[i]/g|0,o=c,a=i+o;a>i;)l=y[--o]%g,u=y[o]/g|0,s=p*l+u*f,l=f*l+s%g*g+m[a]+n,n=(l/h|0)+(s/g|0)+p*u,m[a--]=l%h;m[a]=n}return n?++r:m.splice(0,1),x(e,m,r)},i.negated=function(){var e=new v(this);return e.s=-e.s||null,e},i.plus=function(e,t){var n,r=this,i=r.s;if(e=new v(e,t),t=e.s,!i||!t)return new v(NaN);if(i!=t)return e.s=-t,r.minus(e);var a=r.e/X,o=e.e/X,s=r.c,c=e.c;if(!a||!o){if(!s||!c)return new v(i/0);if(!s[0]||!c[0])return c[0]?e:new v(s[0]?r:i*0)}if(a=_a(a),o=_a(o),s=s.slice(),i=a-o){for(i>0?(o=a,n=c):(i=-i,n=s),n.reverse();i--;n.push(0));n.reverse()}for(i=s.length,t=c.length,i-t<0&&(n=c,c=s,s=n,t=i),i=0;t;)i=(s[--t]=s[t]+c[t]+i)/fa|0,s[t]=fa===s[t]?0:s[t]%fa;return i&&(s=[i].concat(s),++o),x(e,s,o)},i.precision=i.sd=function(e,t){var n,r,i,a=this;if(e!=null&&e!==!!e)return ba(e,1,ha),t==null?t=s:ba(t,0,8),S(new v(a),e,t);if(!(n=a.c))return null;if(i=n.length-1,r=i*X+1,i=n[i]){for(;i%10==0;i/=10,r--);for(i=n[0];i>=10;i/=10,r++);}return e&&a.e+1>r&&(r=a.e+1),r},i.shiftedBy=function(e){return ba(e,-Z,Z),this.times(`1e`+e)},i.squareRoot=i.sqrt=function(){var e,n,r,i,a,c=this,l=c.c,u=c.s,d=c.e,f=o+4,p=new v(`0.5`);if(u!==1||!l||!l[0])return new v(!u||u<0&&(!l||l[0])?NaN:l?c:1/0);if(u=Math.sqrt(+C(c)),u==0||u==1/0?(n=va(l),(n.length+d)%2==0&&(n+=`0`),u=Math.sqrt(+n),d=_a((d+1)/2)-(d<0||d%2),u==1/0?n=`5e`+d:(n=u.toExponential(),n=n.slice(0,n.indexOf(`e`)+1)+d),r=new v(n)):r=new v(u+``),r.c[0]){for(d=r.e,u=d+f,u<3&&(u=0);;)if(a=r,r=p.times(a.plus(t(c,a,f,1))),va(a.c).slice(0,u)===(n=va(r.c)).slice(0,u))if(r.e<d&&--u,n=n.slice(u-3,u+1),n==`9999`||!i&&n==`4999`){if(!i&&(S(a,a.e+o+2,0),a.times(a).eq(c))){r=a;break}f+=4,u+=4,i=1}else{(!+n||!+n.slice(1)&&n.charAt(0)==`5`)&&(S(r,r.e+o+2,1),e=!r.times(r).eq(c));break}}return S(r,r.e+o+1,s,e)},i.toExponential=function(e,t){return e!=null&&(ba(e,0,ha),e++),y(this,e,t,1)},i.toFixed=function(e,t){return e!=null&&(ba(e,0,ha),e=e+this.e+1),y(this,e,t)},i.toFormat=function(e,t,n){var r,i=this;if(n==null)e!=null&&t&&typeof t==`object`?(n=t,t=null):e&&typeof e==`object`?(n=e,e=t=null):n=h;else if(typeof n!=`object`)throw Error(ua+`Argument not an object: `+n);if(r=i.toFixed(e,t),i.c){var a,o=r.split(`.`),s=+n.groupSize,c=+n.secondaryGroupSize,l=n.groupSeparator||``,u=o[0],d=o[1],f=i.s<0,p=f?u.slice(1):u,m=p.length;if(c&&(a=s,s=c,c=a,m-=a),s>0&&m>0){for(a=m%s||s,u=p.substr(0,a);a<m;a+=s)u+=l+p.substr(a,s);c>0&&(u+=l+p.slice(a)),f&&(u=`-`+u)}r=d?u+(n.decimalSeparator||``)+((c=+n.fractionGroupSize)?d.replace(RegExp(`\\d{`+c+`}\\B`,`g`),`$&`+(n.fractionGroupSeparator||``)):d):u}return(n.prefix||``)+r+(n.suffix||``)},i.toFraction=function(e){var n,r,i,o,c,l,u,f,p,m,h,g,_=this,y=_.c;if(e!=null&&(u=new v(e),!u.isInteger()&&(u.c||u.s!==1)||u.lt(a)))throw Error(ua+`Argument `+(u.isInteger()?`out of range: `:`not an integer: `)+C(u));if(!y)return new v(_);for(n=new v(a),p=r=new v(a),i=f=new v(a),g=va(y),c=n.e=g.length-_.e-1,n.c[0]=pa[(l=c%X)<0?X+l:l],e=!e||u.comparedTo(n)>0?c>0?n:p:u,l=d,d=1/0,u=new v(g),f.c[0]=0;m=t(u,n,0,1),o=r.plus(m.times(i)),o.comparedTo(e)!=1;)r=i,i=o,p=f.plus(m.times(o=p)),f=o,n=u.minus(m.times(o=n)),u=o;return o=t(e.minus(r),i,0,1),f=f.plus(o.times(p)),r=r.plus(o.times(i)),f.s=p.s=_.s,c*=2,h=t(p,i,c,s).minus(_).abs().comparedTo(t(f,r,c,s).minus(_).abs())<1?[p,i]:[f,r],d=l,h},i.toNumber=function(){return+C(this)},i.toPrecision=function(e,t){return e!=null&&ba(e,1,ha),y(this,e,t,2)},i.toString=function(e){var t,r=this,i=r.s,a=r.e;return a===null?i?(t=`Infinity`,i<0&&(t=`-`+t)):t=`NaN`:(e==null?t=a<=c||a>=l?Sa(va(r.c),a):Ca(va(r.c),a,`0`):e===10&&_?(r=S(new v(r),o+a+1,s),t=Ca(va(r.c),r.e,`0`)):(ba(e,2,g.length,`Base`),t=n(Ca(va(r.c),a,`0`),10,e,i,!0)),i<0&&r.c[0]&&(t=`-`+t)),t},i.valueOf=i.toJSON=function(){return C(this)},i._isBigNumber=!0,i[Symbol.toStringTag]=`BigNumber`,i[Symbol.for(`nodejs.util.inspect.custom`)]=i.valueOf,e!=null&&v.set(e),v}function _a(e){var t=e|0;return e>0||e===t?t:t-1}function va(e){for(var t,n,r=1,i=e.length,a=e[0]+``;r<i;){for(t=e[r++]+``,n=X-t.length;n--;t=`0`+t);a+=t}for(i=a.length;a.charCodeAt(--i)===48;);return a.slice(0,i+1||1)}function ya(e,t){var n,r,i=e.c,a=t.c,o=e.s,s=t.s,c=e.e,l=t.e;if(!o||!s)return null;if(n=i&&!i[0],r=a&&!a[0],n||r)return n?r?0:-s:o;if(o!=s)return o;if(n=o<0,r=c==l,!i||!a)return r?0:!i^n?1:-1;if(!r)return c>l^n?1:-1;for(s=(c=i.length)<(l=a.length)?c:l,o=0;o<s;o++)if(i[o]!=a[o])return i[o]>a[o]^n?1:-1;return c==l?0:c>l^n?1:-1}function ba(e,t,n,r){if(e<t||e>n||e!==la(e))throw Error(ua+(r||`Argument`)+(typeof e==`number`?e<t||e>n?` out of range: `:` not an integer: `:` not a primitive number: `)+String(e))}function xa(e){var t=e.c.length-1;return _a(e.e/X)==t&&e.c[t]%2!=0}function Sa(e,t){return(e.length>1?e.charAt(0)+`.`+e.slice(1):e)+(t<0?`e`:`e+`)+t}function Ca(e,t,n){var r,i;if(t<0){for(i=n+`.`;++t;i+=n);e=i+e}else if(r=e.length,++t>r){for(i=n,t-=r;--t;i+=n);e+=i}else t<r&&(e=e.slice(0,t)+`.`+e.slice(t));return e}var wa=ga(),Ta=class{key;left=null;right=null;constructor(e){this.key=e}},Ea=class extends Ta{constructor(e){super(e)}},Da=class{size=0;modificationCount=0;splayCount=0;splay(e){let t=this.root;if(t==null)return this.compare(e,e),-1;let n=null,r=null,i=null,a=null,o=t,s=this.compare,c;for(;;)if(c=s(o.key,e),c>0){let t=o.left;if(t==null||(c=s(t.key,e),c>0&&(o.left=t.right,t.right=o,o=t,t=o.left,t==null)))break;n==null?r=o:n.left=o,n=o,o=t}else if(c<0){let t=o.right;if(t==null||(c=s(t.key,e),c<0&&(o.right=t.left,t.left=o,o=t,t=o.right,t==null)))break;i==null?a=o:i.right=o,i=o,o=t}else break;return i!=null&&(i.right=o.left,o.left=a),n!=null&&(n.left=o.right,o.right=r),this.root!==o&&(this.root=o,this.splayCount++),c}splayMin(e){let t=e,n=t.left;for(;n!=null;){let e=n;t.left=e.right,e.right=t,t=e,n=t.left}return t}splayMax(e){let t=e,n=t.right;for(;n!=null;){let e=n;t.right=e.left,e.left=t,t=e,n=t.right}return t}_delete(e){if(this.root==null||this.splay(e)!=0)return null;let t=this.root,n=t,r=t.left;if(this.size--,r==null)this.root=t.right;else{let e=t.right;t=this.splayMax(r),t.right=e,this.root=t}return this.modificationCount++,n}addNewRoot(e,t){this.size++,this.modificationCount++;let n=this.root;if(n==null){this.root=e;return}t<0?(e.left=n,e.right=n.right,n.right=null):(e.right=n,e.left=n.left,n.left=null),this.root=e}_first(){let e=this.root;return e==null?null:(this.root=this.splayMin(e),this.root)}_last(){let e=this.root;return e==null?null:(this.root=this.splayMax(e),this.root)}clear(){this.root=null,this.size=0,this.modificationCount++}has(e){return this.validKey(e)&&this.splay(e)==0}defaultCompare(){return(e,t)=>e<t?-1:e>t?1:0}wrap(){return{getRoot:()=>this.root,setRoot:e=>{this.root=e},getSize:()=>this.size,getModificationCount:()=>this.modificationCount,getSplayCount:()=>this.splayCount,setSplayCount:e=>{this.splayCount=e},splay:e=>this.splay(e),has:e=>this.has(e)}}},Oa=class e extends Da{root=null;compare;validKey;constructor(e,t){super(),this.compare=e??this.defaultCompare(),this.validKey=t??(e=>e!=null&&e!=null)}delete(e){return this.validKey(e)?this._delete(e)!=null:!1}deleteAll(e){for(let t of e)this.delete(t)}forEach(e){let t=this[Symbol.iterator](),n;for(;n=t.next(),!n.done;)e(n.value,n.value,this)}add(e){let t=this.splay(e);return t!=0&&this.addNewRoot(new Ea(e),t),this}addAndReturn(e){let t=this.splay(e);return t!=0&&this.addNewRoot(new Ea(e),t),this.root.key}addAll(e){for(let t of e)this.add(t)}isEmpty(){return this.root==null}isNotEmpty(){return this.root!=null}single(){if(this.size==0)throw`Bad state: No element`;if(this.size>1)throw`Bad state: Too many element`;return this.root.key}first(){if(this.size==0)throw`Bad state: No element`;return this._first().key}last(){if(this.size==0)throw`Bad state: No element`;return this._last().key}lastBefore(e){if(e==null)throw`Invalid arguments(s)`;if(this.root==null)return null;if(this.splay(e)<0)return this.root.key;let t=this.root.left;if(t==null)return null;let n=t.right;for(;n!=null;)t=n,n=t.right;return t.key}firstAfter(e){if(e==null)throw`Invalid arguments(s)`;if(this.root==null)return null;if(this.splay(e)>0)return this.root.key;let t=this.root.right;if(t==null)return null;let n=t.left;for(;n!=null;)t=n,n=t.left;return t.key}retainAll(t){let n=new e(this.compare,this.validKey),r=this.modificationCount;for(let e of t){if(r!=this.modificationCount)throw`Concurrent modification during iteration.`;this.validKey(e)&&this.splay(e)==0&&n.add(this.root.key)}n.size!=this.size&&(this.root=n.root,this.size=n.size,this.modificationCount++)}lookup(e){return!this.validKey(e)||this.splay(e)!=0?null:this.root.key}intersection(t){let n=new e(this.compare,this.validKey);for(let e of this)t.has(e)&&n.add(e);return n}difference(t){let n=new e(this.compare,this.validKey);for(let e of this)t.has(e)||n.add(e);return n}union(e){let t=this.clone();return t.addAll(e),t}clone(){let t=new e(this.compare,this.validKey);return t.size=this.size,t.root=this.copyNode(this.root),t}copyNode(e){if(e==null)return null;function t(e,n){let r,i;do{if(r=e.left,i=e.right,r!=null){let e=new Ea(r.key);n.left=e,t(r,e)}if(i!=null){let t=new Ea(i.key);n.right=t,e=i,n=t}}while(i!=null)}let n=new Ea(e.key);return t(e,n),n}toSet(){return this.clone()}entries(){return new ja(this.wrap())}keys(){return this[Symbol.iterator]()}values(){return this[Symbol.iterator]()}[Symbol.iterator](){return new Aa(this.wrap())}[Symbol.toStringTag]=`[object Set]`},ka=class{tree;path=[];modificationCount=null;splayCount;constructor(e){this.tree=e,this.splayCount=e.getSplayCount()}[Symbol.iterator](){return this}next(){return this.moveNext()?{done:!1,value:this.current()}:{done:!0,value:null}}current(){if(!this.path.length)return null;let e=this.path[this.path.length-1];return this.getValue(e)}rebuildPath(e){this.path.splice(0,this.path.length),this.tree.splay(e),this.path.push(this.tree.getRoot()),this.splayCount=this.tree.getSplayCount()}findLeftMostDescendent(e){for(;e!=null;)this.path.push(e),e=e.left}moveNext(){if(this.modificationCount!=this.tree.getModificationCount()){if(this.modificationCount==null){this.modificationCount=this.tree.getModificationCount();let e=this.tree.getRoot();for(;e!=null;)this.path.push(e),e=e.left;return this.path.length>0}throw`Concurrent modification during iteration.`}if(!this.path.length)return!1;this.splayCount!=this.tree.getSplayCount()&&this.rebuildPath(this.path[this.path.length-1].key);let e=this.path[this.path.length-1],t=e.right;if(t!=null){for(;t!=null;)this.path.push(t),t=t.left;return!0}for(this.path.pop();this.path.length&&this.path[this.path.length-1].right===e;)e=this.path.pop();return this.path.length>0}},Aa=class extends ka{getValue(e){return e.key}},ja=class extends ka{getValue(e){return[e.key,e.key]}},Ma=e=>()=>e,Na=e=>{let t=e?(t,n)=>n.minus(t).abs().isLessThanOrEqualTo(e):Ma(!1);return(e,n)=>t(e,n)?0:e.comparedTo(n)};function Pa(e){let t=e?(t,n,r,i,a)=>t.exponentiatedBy(2).isLessThanOrEqualTo(i.minus(n).exponentiatedBy(2).plus(a.minus(r).exponentiatedBy(2)).times(e)):Ma(!1);return(e,n,r)=>{let i=e.x,a=e.y,o=r.x,s=r.y,c=a.minus(s).times(n.x.minus(o)).minus(i.minus(o).times(n.y.minus(s)));return t(c,i,a,o,s)?0:c.comparedTo(0)}}var Q=e=>e,$=e=>{if(e){let t=new Oa(Na(e)),n=new Oa(Na(e)),r=(e,t)=>t.addAndReturn(e),i=e=>({x:r(e.x,t),y:r(e.y,n)});return i({x:new wa(0),y:new wa(0)}),i}return Q},Fa=e=>({set:e=>{Ia=Fa(e)},reset:()=>Fa(e),compare:Na(e),snap:$(e),orient:Pa(e)}),Ia=Fa(),La=(e,t)=>e.ll.x.isLessThanOrEqualTo(t.x)&&t.x.isLessThanOrEqualTo(e.ur.x)&&e.ll.y.isLessThanOrEqualTo(t.y)&&t.y.isLessThanOrEqualTo(e.ur.y),Ra=(e,t)=>{if(t.ur.x.isLessThan(e.ll.x)||e.ur.x.isLessThan(t.ll.x)||t.ur.y.isLessThan(e.ll.y)||e.ur.y.isLessThan(t.ll.y))return null;let n=e.ll.x.isLessThan(t.ll.x)?t.ll.x:e.ll.x,r=e.ur.x.isLessThan(t.ur.x)?e.ur.x:t.ur.x,i=e.ll.y.isLessThan(t.ll.y)?t.ll.y:e.ll.y,a=e.ur.y.isLessThan(t.ur.y)?e.ur.y:t.ur.y;return{ll:{x:n,y:i},ur:{x:r,y:a}}},za=(e,t)=>e.x.times(t.y).minus(e.y.times(t.x)),Ba=(e,t)=>e.x.times(t.x).plus(e.y.times(t.y)),Va=e=>Ba(e,e).sqrt(),Ha=(e,t,n)=>{let r={x:t.x.minus(e.x),y:t.y.minus(e.y)},i={x:n.x.minus(e.x),y:n.y.minus(e.y)};return za(i,r).div(Va(i)).div(Va(r))},Ua=(e,t,n)=>{let r={x:t.x.minus(e.x),y:t.y.minus(e.y)},i={x:n.x.minus(e.x),y:n.y.minus(e.y)};return Ba(i,r).div(Va(i)).div(Va(r))},Wa=(e,t,n)=>t.y.isZero()?null:{x:e.x.plus(t.x.div(t.y).times(n.minus(e.y))),y:n},Ga=(e,t,n)=>t.x.isZero()?null:{x:n,y:e.y.plus(t.y.div(t.x).times(n.minus(e.x)))},Ka=(e,t,n,r)=>{if(t.x.isZero())return Ga(n,r,e.x);if(r.x.isZero())return Ga(e,t,n.x);if(t.y.isZero())return Wa(n,r,e.y);if(r.y.isZero())return Wa(e,t,n.y);let i=za(t,r);if(i.isZero())return null;let a={x:n.x.minus(e.x),y:n.y.minus(e.y)},o=za(a,t).div(i),s=za(a,r).div(i),c=e.x.plus(s.times(t.x)),l=n.x.plus(o.times(r.x)),u=e.y.plus(s.times(t.y)),d=n.y.plus(o.times(r.y));return{x:c.plus(l).div(2),y:u.plus(d).div(2)}},qa=class e{point;isLeft;segment;otherSE;consumedBy;static compare(t,n){let r=e.comparePoints(t.point,n.point);return r===0?(t.point!==n.point&&t.link(n),t.isLeft===n.isLeft?to.compare(t.segment,n.segment):t.isLeft?1:-1):r}static comparePoints(e,t){return e.x.isLessThan(t.x)?-1:e.x.isGreaterThan(t.x)?1:e.y.isLessThan(t.y)?-1:e.y.isGreaterThan(t.y)?1:0}constructor(e,t){e.events===void 0?e.events=[this]:e.events.push(this),this.point=e,this.isLeft=t}link(e){if(e.point===this.point)throw Error(`Tried to link already linked events`);let t=e.point.events;for(let e=0,n=t.length;e<n;e++){let n=t[e];this.point.events.push(n),n.point=this.point}this.checkForConsuming()}checkForConsuming(){let e=this.point.events.length;for(let t=0;t<e;t++){let n=this.point.events[t];if(n.segment.consumedBy===void 0)for(let r=t+1;r<e;r++){let e=this.point.events[r];e.consumedBy===void 0&&n.otherSE.point.events===e.otherSE.point.events&&n.segment.consume(e.segment)}}}getAvailableLinkedEvents(){let e=[];for(let t=0,n=this.point.events.length;t<n;t++){let n=this.point.events[t];n!==this&&!n.segment.ringOut&&n.segment.isInResult()&&e.push(n)}return e}getLeftmostComparator(e){let t=new Map,n=n=>{let r=n.otherSE;t.set(n,{sine:Ha(this.point,e.point,r.point),cosine:Ua(this.point,e.point,r.point)})};return(e,r)=>{t.has(e)||n(e),t.has(r)||n(r);let{sine:i,cosine:a}=t.get(e),{sine:o,cosine:s}=t.get(r);return i.isGreaterThanOrEqualTo(0)&&o.isGreaterThanOrEqualTo(0)?a.isLessThan(s)?1:a.isGreaterThan(s)?-1:0:i.isLessThan(0)&&o.isLessThan(0)?a.isLessThan(s)?-1:a.isGreaterThan(s)?1:0:o.isLessThan(i)?-1:o.isGreaterThan(i)?1:0}}},Ja=class e{events;poly;_isExteriorRing;_enclosingRing;static factory(t){let n=[];for(let r=0,i=t.length;r<i;r++){let i=t[r];if(!i.isInResult()||i.ringOut)continue;let a=null,o=i.leftSE,s=i.rightSE,c=[o],l=o.point,u=[];for(;a=o,o=s,c.push(o),o.point!==l;)for(;;){let t=o.getAvailableLinkedEvents();if(t.length===0){let e=c[0].point,t=c[c.length-1].point;throw Error(`Unable to complete output ring starting at [${e.x}, ${e.y}]. Last matching segment found ends at [${t.x}, ${t.y}].`)}if(t.length===1){s=t[0].otherSE;break}let r=null;for(let e=0,t=u.length;e<t;e++)if(u[e].point===o.point){r=e;break}if(r!==null){let t=u.splice(r)[0],i=c.splice(t.index);i.unshift(i[0].otherSE),n.push(new e(i.reverse()));continue}u.push({index:c.length,point:o.point});let i=o.getLeftmostComparator(a);s=t.sort(i)[0].otherSE;break}n.push(new e(c))}return n}constructor(e){this.events=e;for(let t=0,n=e.length;t<n;t++)e[t].segment.ringOut=this;this.poly=null}getGeom(){let e=this.events[0].point,t=[e];for(let n=1,r=this.events.length-1;n<r;n++){let r=this.events[n].point,i=this.events[n+1].point;Ia.orient(r,e,i)!==0&&(t.push(r),e=r)}if(t.length===1)return null;let n=t[0],r=t[1];Ia.orient(n,e,r)===0&&t.shift(),t.push(t[0]);let i=this.isExteriorRing()?1:-1,a=this.isExteriorRing()?0:t.length-1,o=this.isExteriorRing()?t.length:-1,s=[];for(let e=a;e!=o;e+=i)s.push([t[e].x.toNumber(),t[e].y.toNumber()]);return s}isExteriorRing(){if(this._isExteriorRing===void 0){let e=this.enclosingRing();this._isExteriorRing=e?!e.isExteriorRing():!0}return this._isExteriorRing}enclosingRing(){return this._enclosingRing===void 0&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}_calcEnclosingRing(){let e=this.events[0];for(let t=1,n=this.events.length;t<n;t++){let n=this.events[t];qa.compare(e,n)>0&&(e=n)}let t=e.segment.prevInResult(),n=t?t.prevInResult():null;for(;;){if(!t)return null;if(!n)return t.ringOut;if(n.ringOut!==t.ringOut)return n.ringOut?.enclosingRing()===t.ringOut?t.ringOut?.enclosingRing():t.ringOut;t=n.prevInResult(),n=t?t.prevInResult():null}}},Ya=class{exteriorRing;interiorRings;constructor(e){this.exteriorRing=e,e.poly=this,this.interiorRings=[]}addInterior(e){this.interiorRings.push(e),e.poly=this}getGeom(){let e=this.exteriorRing.getGeom();if(e===null)return null;let t=[e];for(let e=0,n=this.interiorRings.length;e<n;e++){let n=this.interiorRings[e].getGeom();n!==null&&t.push(n)}return t}},Xa=class{rings;polys;constructor(e){this.rings=e,this.polys=this._composePolys(e)}getGeom(){let e=[];for(let t=0,n=this.polys.length;t<n;t++){let n=this.polys[t].getGeom();n!==null&&e.push(n)}return e}_composePolys(e){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];if(!r.poly)if(r.isExteriorRing())t.push(new Ya(r));else{let e=r.enclosingRing();e?.poly||t.push(new Ya(e)),e?.poly?.addInterior(r)}}return t}},Za=class{queue;tree;segments;constructor(e,t=to.compare){this.queue=e,this.tree=new Oa(t),this.segments=[]}process(e){let t=e.segment,n=[];if(e.consumedBy)return e.isLeft?this.queue.delete(e.otherSE):this.tree.delete(t),n;e.isLeft&&this.tree.add(t);let r=t,i=t;do r=this.tree.lastBefore(r);while(r!=null&&r.consumedBy!=null);do i=this.tree.firstAfter(i);while(i!=null&&i.consumedBy!=null);if(e.isLeft){let a=null;if(r){let e=r.getIntersection(t);if(e!==null&&(t.isAnEndpoint(e)||(a=e),!r.isAnEndpoint(e))){let t=this._splitSafely(r,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}}let o=null;if(i){let e=i.getIntersection(t);if(e!==null&&(t.isAnEndpoint(e)||(o=e),!i.isAnEndpoint(e))){let t=this._splitSafely(i,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}}if(a!==null||o!==null){let e=null;e=a===null?o:o===null||qa.comparePoints(a,o)<=0?a:o,this.queue.delete(t.rightSE),n.push(t.rightSE);let r=t.split(e);for(let e=0,t=r.length;e<t;e++)n.push(r[e])}n.length>0?(this.tree.delete(t),n.push(e)):(this.segments.push(t),t.prev=r)}else{if(r&&i){let e=r.getIntersection(i);if(e!==null){if(!r.isAnEndpoint(e)){let t=this._splitSafely(r,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}if(!i.isAnEndpoint(e)){let t=this._splitSafely(i,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}}}this.tree.delete(t)}return n}_splitSafely(e,t){this.tree.delete(e);let n=e.rightSE;this.queue.delete(n);let r=e.split(t);return r.push(n),e.consumedBy===void 0&&this.tree.add(e),r}},Qa=new class{type;numMultiPolys;run(e,t,n){Qa.type=e;let r=[new io(t,!0)];for(let e=0,t=n.length;e<t;e++)r.push(new io(n[e],!1));if(Qa.numMultiPolys=r.length,Qa.type===`difference`){let e=r[0],t=1;for(;t<r.length;)Ra(r[t].bbox,e.bbox)===null?r.splice(t,1):t++}if(Qa.type===`intersection`)for(let e=0,t=r.length;e<t;e++){let t=r[e];for(let n=e+1,i=r.length;n<i;n++)if(Ra(t.bbox,r[n].bbox)===null)return[]}let i=new Oa(qa.compare);for(let e=0,t=r.length;e<t;e++){let t=r[e].getSweepEvents();for(let e=0,n=t.length;e<n;e++)i.add(t[e])}let a=new Za(i),o=null;for(i.size!=0&&(o=i.first(),i.delete(o));o;){let e=a.process(o);for(let t=0,n=e.length;t<n;t++){let n=e[t];n.consumedBy===void 0&&i.add(n)}i.size==0?o=null:(o=i.first(),i.delete(o))}return Ia.reset(),new Xa(Ja.factory(a.segments)).getGeom()}},$a=Qa,eo=0,to=class e{id;leftSE;rightSE;rings;windings;ringOut;consumedBy;prev;_prevInResult;_beforeState;_afterState;_isInResult;static compare(e,t){let n=e.leftSE.point.x,r=t.leftSE.point.x,i=e.rightSE.point.x,a=t.rightSE.point.x;if(a.isLessThan(n))return 1;if(i.isLessThan(r))return-1;let o=e.leftSE.point.y,s=t.leftSE.point.y,c=e.rightSE.point.y,l=t.rightSE.point.y;if(n.isLessThan(r)){if(s.isLessThan(o)&&s.isLessThan(c))return 1;if(s.isGreaterThan(o)&&s.isGreaterThan(c))return-1;let n=e.comparePoint(t.leftSE.point);if(n<0)return 1;if(n>0)return-1;let r=t.comparePoint(e.rightSE.point);return r===0?-1:r}if(n.isGreaterThan(r)){if(o.isLessThan(s)&&o.isLessThan(l))return-1;if(o.isGreaterThan(s)&&o.isGreaterThan(l))return 1;let n=t.comparePoint(e.leftSE.point);if(n!==0)return n;let r=e.comparePoint(t.rightSE.point);return r<0?1:r>0?-1:1}if(o.isLessThan(s))return-1;if(o.isGreaterThan(s))return 1;if(i.isLessThan(a)){let n=t.comparePoint(e.rightSE.point);if(n!==0)return n}if(i.isGreaterThan(a)){let n=e.comparePoint(t.rightSE.point);if(n<0)return 1;if(n>0)return-1}if(!i.eq(a)){let e=c.minus(o),t=i.minus(n),u=l.minus(s),d=a.minus(r);if(e.isGreaterThan(t)&&u.isLessThan(d))return 1;if(e.isLessThan(t)&&u.isGreaterThan(d))return-1}return i.isGreaterThan(a)?1:i.isLessThan(a)||c.isLessThan(l)?-1:c.isGreaterThan(l)?1:e.id<t.id?-1:e.id>t.id?1:0}constructor(e,t,n,r){this.id=++eo,this.leftSE=e,e.segment=this,e.otherSE=t,this.rightSE=t,t.segment=this,t.otherSE=e,this.rings=n,this.windings=r}static fromRing(t,n,r){let i,a,o,s=qa.comparePoints(t,n);if(s<0)i=t,a=n,o=1;else if(s>0)i=n,a=t,o=-1;else throw Error(`Tried to create degenerate segment at [${t.x}, ${t.y}]`);return new e(new qa(i,!0),new qa(a,!1),[r],[o])}replaceRightSE(e){this.rightSE=e,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}bbox(){let e=this.leftSE.point.y,t=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:e.isLessThan(t)?e:t},ur:{x:this.rightSE.point.x,y:e.isGreaterThan(t)?e:t}}}vector(){return{x:this.rightSE.point.x.minus(this.leftSE.point.x),y:this.rightSE.point.y.minus(this.leftSE.point.y)}}isAnEndpoint(e){return e.x.eq(this.leftSE.point.x)&&e.y.eq(this.leftSE.point.y)||e.x.eq(this.rightSE.point.x)&&e.y.eq(this.rightSE.point.y)}comparePoint(e){return Ia.orient(this.leftSE.point,e,this.rightSE.point)}getIntersection(e){let t=this.bbox(),n=e.bbox(),r=Ra(t,n);if(r===null)return null;let i=this.leftSE.point,a=this.rightSE.point,o=e.leftSE.point,s=e.rightSE.point,c=La(t,o)&&this.comparePoint(o)===0,l=La(n,i)&&e.comparePoint(i)===0,u=La(t,s)&&this.comparePoint(s)===0,d=La(n,a)&&e.comparePoint(a)===0;if(l&&c)return d&&!u?a:!d&&u?s:null;if(l)return u&&i.x.eq(s.x)&&i.y.eq(s.y)?null:i;if(c)return d&&a.x.eq(o.x)&&a.y.eq(o.y)?null:o;if(d&&u)return null;if(d)return a;if(u)return s;let f=Ka(i,this.vector(),o,e.vector());return f===null||!La(r,f)?null:Ia.snap(f)}split(t){let n=[],r=t.events!==void 0,i=new qa(t,!0),a=new qa(t,!1),o=this.rightSE;this.replaceRightSE(a),n.push(a),n.push(i);let s=new e(i,o,this.rings.slice(),this.windings.slice());return qa.comparePoints(s.leftSE.point,s.rightSE.point)>0&&s.swapEvents(),qa.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),r&&(i.checkForConsuming(),a.checkForConsuming()),n}swapEvents(){let e=this.rightSE;this.rightSE=this.leftSE,this.leftSE=e,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let e=0,t=this.windings.length;e<t;e++)this.windings[e]*=-1}consume(t){let n=this,r=t;for(;n.consumedBy;)n=n.consumedBy;for(;r.consumedBy;)r=r.consumedBy;let i=e.compare(n,r);if(i!==0){if(i>0){let e=n;n=r,r=e}if(n.prev===r){let e=n;n=r,r=e}for(let e=0,t=r.rings.length;e<t;e++){let t=r.rings[e],i=r.windings[e],a=n.rings.indexOf(t);a===-1?(n.rings.push(t),n.windings.push(i)):n.windings[a]+=i}r.rings=null,r.windings=null,r.consumedBy=n,r.leftSE.consumedBy=n.leftSE,r.rightSE.consumedBy=n.rightSE}}prevInResult(){return this._prevInResult===void 0&&(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null),this._prevInResult}beforeState(){return this._beforeState===void 0&&(this.prev?this._beforeState=(this.prev.consumedBy||this.prev).afterState():this._beforeState={rings:[],windings:[],multiPolys:[]}),this._beforeState}afterState(){if(this._afterState!==void 0)return this._afterState;let e=this.beforeState();this._afterState={rings:e.rings.slice(0),windings:e.windings.slice(0),multiPolys:[]};let t=this._afterState.rings,n=this._afterState.windings,r=this._afterState.multiPolys;for(let e=0,r=this.rings.length;e<r;e++){let r=this.rings[e],i=this.windings[e],a=t.indexOf(r);a===-1?(t.push(r),n.push(i)):n[a]+=i}let i=[],a=[];for(let e=0,r=t.length;e<r;e++){if(n[e]===0)continue;let r=t[e],o=r.poly;if(a.indexOf(o)===-1)if(r.isExterior)i.push(o);else{a.indexOf(o)===-1&&a.push(o);let e=i.indexOf(r.poly);e!==-1&&i.splice(e,1)}}for(let e=0,t=i.length;e<t;e++){let t=i[e].multiPoly;r.indexOf(t)===-1&&r.push(t)}return this._afterState}isInResult(){if(this.consumedBy)return!1;if(this._isInResult!==void 0)return this._isInResult;let e=this.beforeState().multiPolys,t=this.afterState().multiPolys;switch($a.type){case`union`:this._isInResult=e.length===0!=(t.length===0);break;case`intersection`:{let n,r;e.length<t.length?(n=e.length,r=t.length):(n=t.length,r=e.length),this._isInResult=r===$a.numMultiPolys&&n<r;break}case`xor`:this._isInResult=Math.abs(e.length-t.length)%2==1;break;case`difference`:{let n=e=>e.length===1&&e[0].isSubject;this._isInResult=n(e)!==n(t);break}}return this._isInResult}},no=class{poly;isExterior;segments;bbox;constructor(e,t,n){if(!Array.isArray(e)||e.length===0||(this.poly=t,this.isExterior=n,this.segments=[],typeof e[0][0]!=`number`||typeof e[0][1]!=`number`))throw Error(`Input geometry is not a valid Polygon or MultiPolygon`);let r=Ia.snap({x:new wa(e[0][0]),y:new wa(e[0][1])});this.bbox={ll:{x:r.x,y:r.y},ur:{x:r.x,y:r.y}};let i=r;for(let t=1,n=e.length;t<n;t++){if(typeof e[t][0]!=`number`||typeof e[t][1]!=`number`)throw Error(`Input geometry is not a valid Polygon or MultiPolygon`);let n=Ia.snap({x:new wa(e[t][0]),y:new wa(e[t][1])});n.x.eq(i.x)&&n.y.eq(i.y)||(this.segments.push(to.fromRing(i,n,this)),n.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=n.x),n.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=n.y),n.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=n.x),n.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=n.y),i=n)}(!r.x.eq(i.x)||!r.y.eq(i.y))&&this.segments.push(to.fromRing(i,r,this))}getSweepEvents(){let e=[];for(let t=0,n=this.segments.length;t<n;t++){let n=this.segments[t];e.push(n.leftSE),e.push(n.rightSE)}return e}},ro=class{multiPoly;exteriorRing;interiorRings;bbox;constructor(e,t){if(!Array.isArray(e))throw Error(`Input geometry is not a valid Polygon or MultiPolygon`);this.exteriorRing=new no(e[0],this,!0),this.bbox={ll:{x:this.exteriorRing.bbox.ll.x,y:this.exteriorRing.bbox.ll.y},ur:{x:this.exteriorRing.bbox.ur.x,y:this.exteriorRing.bbox.ur.y}},this.interiorRings=[];for(let t=1,n=e.length;t<n;t++){let n=new no(e[t],this,!1);n.bbox.ll.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=n.bbox.ll.x),n.bbox.ll.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=n.bbox.ll.y),n.bbox.ur.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=n.bbox.ur.x),n.bbox.ur.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=n.bbox.ur.y),this.interiorRings.push(n)}this.multiPoly=t}getSweepEvents(){let e=this.exteriorRing.getSweepEvents();for(let t=0,n=this.interiorRings.length;t<n;t++){let n=this.interiorRings[t].getSweepEvents();for(let t=0,r=n.length;t<r;t++)e.push(n[t])}return e}},io=class{isSubject;polys;bbox;constructor(e,t){if(!Array.isArray(e))throw Error(`Input geometry is not a valid Polygon or MultiPolygon`);try{typeof e[0][0][0]==`number`&&(e=[e])}catch{}this.polys=[],this.bbox={ll:{x:new wa(1/0),y:new wa(1/0)},ur:{x:new wa(-1/0),y:new wa(-1/0)}};for(let t=0,n=e.length;t<n;t++){let n=new ro(e[t],this);n.bbox.ll.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=n.bbox.ll.x),n.bbox.ll.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=n.bbox.ll.y),n.bbox.ur.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=n.bbox.ur.x),n.bbox.ur.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=n.bbox.ur.y),this.polys.push(n)}this.isSubject=t}getSweepEvents(){let e=[];for(let t=0,n=this.polys.length;t<n;t++){let n=this.polys[t].getSweepEvents();for(let t=0,r=n.length;t<r;t++)e.push(n[t])}return e}},ao=(e,...t)=>$a.run(`intersection`,e,t);Ia.set;function oo(e,t={}){let n=[];if(Wn(e,e=>{n.push(e.coordinates)}),n.length<2)throw Error(`Must specify at least 2 geometries`);let r=ao(n[0],...n.slice(1));return r.length===0?null:r.length===1?Rn(r[0],t.properties):Hn(r,t.properties)}var so=1e-6,co=Math.PI,lo=co/2,uo=co/4,fo=co*2,po=180/co,mo=co/180,ho=Math.abs,go=Math.atan,_o=Math.atan2,vo=Math.cos,yo=Math.ceil,bo=Math.exp,xo=Math.log,So=Math.sin,Co=Math.sign||function(e){return e>0?1:e<0?-1:0},wo=Math.sqrt,To=Math.tan;function Eo(e){return e>1?0:e<-1?co:Math.acos(e)}function Do(e){return e>1?lo:e<-1?-lo:Math.asin(e)}function Oo(){}function ko(e,t){e&&jo.hasOwnProperty(e.type)&&jo[e.type](e,t)}var Ao={Feature:function(e,t){ko(e.geometry,t)},FeatureCollection:function(e,t){for(var n=e.features,r=-1,i=n.length;++r<i;)ko(n[r].geometry,t)}},jo={Sphere:function(e,t){t.sphere()},Point:function(e,t){e=e.coordinates,t.point(e[0],e[1],e[2])},MultiPoint:function(e,t){for(var n=e.coordinates,r=-1,i=n.length;++r<i;)e=n[r],t.point(e[0],e[1],e[2])},LineString:function(e,t){Mo(e.coordinates,t,0)},MultiLineString:function(e,t){for(var n=e.coordinates,r=-1,i=n.length;++r<i;)Mo(n[r],t,0)},Polygon:function(e,t){No(e.coordinates,t)},MultiPolygon:function(e,t){for(var n=e.coordinates,r=-1,i=n.length;++r<i;)No(n[r],t)},GeometryCollection:function(e,t){for(var n=e.geometries,r=-1,i=n.length;++r<i;)ko(n[r],t)}};function Mo(e,t,n){var r=-1,i=e.length-n,a;for(t.lineStart();++r<i;)a=e[r],t.point(a[0],a[1],a[2]);t.lineEnd()}function No(e,t){var n=-1,r=e.length;for(t.polygonStart();++n<r;)Mo(e[n],t,1);t.polygonEnd()}function Po(e,t){e&&Ao.hasOwnProperty(e.type)?Ao[e.type](e,t):ko(e,t)}function Fo(e){return[_o(e[1],e[0]),Do(e[2])]}function Io(e){var t=e[0],n=e[1],r=vo(n);return[r*vo(t),r*So(t),So(n)]}function Lo(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Ro(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function zo(e,t){e[0]+=t[0],e[1]+=t[1],e[2]+=t[2]}function Bo(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function Vo(e){var t=wo(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);e[0]/=t,e[1]/=t,e[2]/=t}function Ho(e,t){function n(n,r){return n=e(n,r),t(n[0],n[1])}return e.invert&&t.invert&&(n.invert=function(n,r){return n=t.invert(n,r),n&&e.invert(n[0],n[1])}),n}function Uo(e,t){return ho(e)>co&&(e-=Math.round(e/fo)*fo),[e,t]}Uo.invert=Uo;function Wo(e,t,n){return(e%=fo)?t||n?Ho(Ko(e),qo(t,n)):Ko(e):t||n?qo(t,n):Uo}function Go(e){return function(t,n){return t+=e,ho(t)>co&&(t-=Math.round(t/fo)*fo),[t,n]}}function Ko(e){var t=Go(e);return t.invert=Go(-e),t}function qo(e,t){var n=vo(e),r=So(e),i=vo(t),a=So(t);function o(e,t){var o=vo(t),s=vo(e)*o,c=So(e)*o,l=So(t),u=l*n+s*r;return[_o(c*i-u*a,s*n-l*r),Do(u*i+c*a)]}return o.invert=function(e,t){var o=vo(t),s=vo(e)*o,c=So(e)*o,l=So(t),u=l*i-c*a;return[_o(c*i+l*a,s*n+u*r),Do(u*n-s*r)]},o}function Jo(e){e=Wo(e[0]*mo,e[1]*mo,e.length>2?e[2]*mo:0);function t(t){return t=e(t[0]*mo,t[1]*mo),t[0]*=po,t[1]*=po,t}return t.invert=function(t){return t=e.invert(t[0]*mo,t[1]*mo),t[0]*=po,t[1]*=po,t},t}function Yo(e,t,n,r,i,a){if(n){var o=vo(t),s=So(t),c=r*n;i==null?(i=t+r*fo,a=t-c/2):(i=Xo(o,i),a=Xo(o,a),(r>0?i<a:i>a)&&(i+=r*fo));for(var l,u=i;r>0?u>a:u<a;u-=c)l=Fo([o,-s*vo(u),-s*So(u)]),e.point(l[0],l[1])}}function Xo(e,t){t=Io(t),t[0]-=e,Vo(t);var n=Eo(-t[1]);return((-t[2]<0?-n:n)+fo-so)%fo}function Zo(){var e=[],t;return{point:function(e,n,r){t.push([e,n,r])},lineStart:function(){e.push(t=[])},lineEnd:Oo,rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))},result:function(){var n=e;return e=[],t=null,n}}}function Qo(e,t){return ho(e[0]-t[0])<1e-6&&ho(e[1]-t[1])<1e-6}function $o(e,t,n,r){this.x=e,this.z=t,this.o=n,this.e=r,this.v=!1,this.n=this.p=null}function es(e,t,n,r,i){var a=[],o=[],s,c;if(e.forEach(function(e){if(!((t=e.length-1)<=0)){var t,n=e[0],r=e[t],c;if(Qo(n,r)){if(!n[2]&&!r[2]){for(i.lineStart(),s=0;s<t;++s)i.point((n=e[s])[0],n[1]);i.lineEnd();return}r[0]+=2*so}a.push(c=new $o(n,e,null,!0)),o.push(c.o=new $o(n,null,c,!1)),a.push(c=new $o(r,e,null,!1)),o.push(c.o=new $o(r,null,c,!0))}}),a.length){for(o.sort(t),ts(a),ts(o),s=0,c=o.length;s<c;++s)o[s].e=n=!n;for(var l=a[0],u,d;;){for(var f=l,p=!0;f.v;)if((f=f.n)===l)return;u=f.z,i.lineStart();do{if(f.v=f.o.v=!0,f.e){if(p)for(s=0,c=u.length;s<c;++s)i.point((d=u[s])[0],d[1]);else r(f.x,f.n.x,1,i);f=f.n}else{if(p)for(u=f.p.z,s=u.length-1;s>=0;--s)i.point((d=u[s])[0],d[1]);else r(f.x,f.p.x,-1,i);f=f.p}f=f.o,u=f.z,p=!p}while(!f.v);i.lineEnd()}}}function ts(e){if(t=e.length){for(var t,n=0,r=e[0],i;++n<t;)r.n=i=e[n],i.p=r,r=i;r.n=i=e[0],i.p=r}}function ns(e){return ho(e[0])<=co?e[0]:Co(e[0])*((ho(e[0])+co)%fo-co)}function rs(e,t){var n=ns(t),r=t[1],i=So(r),a=[So(n),-vo(n),0],o=0,s=0,c=new Nt;i===1?r=lo+so:i===-1&&(r=-lo-so);for(var l=0,u=e.length;l<u;++l)if(f=(d=e[l]).length)for(var d,f,p=d[f-1],m=ns(p),h=p[1]/2+uo,g=So(h),_=vo(h),v=0;v<f;++v,m=b,g=S,_=C,p=y){var y=d[v],b=ns(y),x=y[1]/2+uo,S=So(x),C=vo(x),w=b-m,T=w>=0?1:-1,E=T*w,D=E>co,O=g*S;if(c.add(_o(O*T*So(E),_*C+O*vo(E))),o+=D?w+T*fo:w,D^m>=n^b>=n){var k=Ro(Io(p),Io(y));Vo(k);var A=Ro(a,k);Vo(A);var j=(D^w>=0?-1:1)*Do(A[2]);(r>j||r===j&&(k[0]||k[1]))&&(s+=D^w>=0?1:-1)}}return(o<-1e-6||o<1e-6&&c<-1e-12)^s&1}function is(e,t,n,r){return function(i){var a=t(i),o=Zo(),s=t(o),c=!1,l,u,d,f={point:p,lineStart:h,lineEnd:g,polygonStart:function(){f.point=_,f.lineStart=v,f.lineEnd=y,u=[],l=[]},polygonEnd:function(){f.point=p,f.lineStart=h,f.lineEnd=g,u=qt(u);var e=rs(l,r);u.length?(c||=(i.polygonStart(),!0),es(u,os,e,n,i)):e&&(c||=(i.polygonStart(),!0),i.lineStart(),n(null,null,1,i),i.lineEnd()),c&&=(i.polygonEnd(),!1),u=l=null},sphere:function(){i.polygonStart(),i.lineStart(),n(null,null,1,i),i.lineEnd(),i.polygonEnd()}};function p(t,n){e(t,n)&&i.point(t,n)}function m(e,t){a.point(e,t)}function h(){f.point=m,a.lineStart()}function g(){f.point=p,a.lineEnd()}function _(e,t){d.push([e,t]),s.point(e,t)}function v(){s.lineStart(),d=[]}function y(){_(d[0][0],d[0][1]),s.lineEnd();var e=s.clean(),t=o.result(),n,r=t.length,a,f,p;if(d.pop(),l.push(d),d=null,r){if(e&1){if(f=t[0],(a=f.length-1)>0){for(c||=(i.polygonStart(),!0),i.lineStart(),n=0;n<a;++n)i.point((p=f[n])[0],p[1]);i.lineEnd()}return}r>1&&e&2&&t.push(t.pop().concat(t.shift())),u.push(t.filter(as))}}return f}}function as(e){return e.length>1}function os(e,t){return((e=e.x)[0]<0?e[1]-lo-so:lo-e[1])-((t=t.x)[0]<0?t[1]-lo-so:lo-t[1])}var ss=is(function(){return!0},cs,us,[-co,-lo]);function cs(e){var t=NaN,n=NaN,r=NaN,i;return{lineStart:function(){e.lineStart(),i=1},point:function(a,o){var s=a>0?co:-co,c=ho(a-t);ho(c-co)<1e-6?(e.point(t,n=(n+o)/2>0?lo:-lo),e.point(r,n),e.lineEnd(),e.lineStart(),e.point(s,n),e.point(a,n),i=0):r!==s&&c>=co&&(ho(t-r)<1e-6&&(t-=r*so),ho(a-s)<1e-6&&(a-=s*so),n=ls(t,n,a,o),e.point(r,n),e.lineEnd(),e.lineStart(),e.point(s,n),i=0),e.point(t=a,n=o),r=s},lineEnd:function(){e.lineEnd(),t=n=NaN},clean:function(){return 2-i}}}function ls(e,t,n,r){var i,a,o=So(e-n);return ho(o)>1e-6?go((So(t)*(a=vo(r))*So(n)-So(r)*(i=vo(t))*So(e))/(i*a*o)):(t+r)/2}function us(e,t,n,r){var i;if(e==null)i=n*lo,r.point(-co,i),r.point(0,i),r.point(co,i),r.point(co,0),r.point(co,-i),r.point(0,-i),r.point(-co,-i),r.point(-co,0),r.point(-co,i);else if(ho(e[0]-t[0])>1e-6){var a=e[0]<t[0]?co:-co;i=n*a/2,r.point(-a,i),r.point(0,i),r.point(a,i)}else r.point(t[0],t[1])}function ds(e){var t=vo(e),n=2*mo,r=t>0,i=ho(t)>so;function a(t,r,i,a){Yo(a,e,n,i,t,r)}function o(e,n){return vo(e)*vo(n)>t}function s(e){var t,n,a,s,u;return{lineStart:function(){s=a=!1,u=1},point:function(d,f){var p=[d,f],m,h=o(d,f),g=r?h?0:l(d,f):h?l(d+(d<0?co:-co),f):0;if(!t&&(s=a=h)&&e.lineStart(),h!==a&&(m=c(t,p),(!m||Qo(t,m)||Qo(p,m))&&(p[2]=1)),h!==a)u=0,h?(e.lineStart(),m=c(p,t),e.point(m[0],m[1])):(m=c(t,p),e.point(m[0],m[1],2),e.lineEnd()),t=m;else if(i&&t&&r^h){var _;!(g&n)&&(_=c(p,t,!0))&&(u=0,r?(e.lineStart(),e.point(_[0][0],_[0][1]),e.point(_[1][0],_[1][1]),e.lineEnd()):(e.point(_[1][0],_[1][1]),e.lineEnd(),e.lineStart(),e.point(_[0][0],_[0][1],3)))}h&&(!t||!Qo(t,p))&&e.point(p[0],p[1]),t=p,a=h,n=g},lineEnd:function(){a&&e.lineEnd(),t=null},clean:function(){return u|(s&&a)<<1}}}function c(e,n,r){var i=Io(e),a=Io(n),o=[1,0,0],s=Ro(i,a),c=Lo(s,s),l=s[0],u=c-l*l;if(!u)return!r&&e;var d=t*c/u,f=-t*l/u,p=Ro(o,s),m=Bo(o,d);zo(m,Bo(s,f));var h=p,g=Lo(m,h),_=Lo(h,h),v=g*g-_*(Lo(m,m)-1);if(!(v<0)){var y=wo(v),b=Bo(h,(-g-y)/_);if(zo(b,m),b=Fo(b),!r)return b;var x=e[0],S=n[0],C=e[1],w=n[1],T;S<x&&(T=x,x=S,S=T);var E=S-x,D=ho(E-co)<so,O=D||E<1e-6;if(!D&&w<C&&(T=C,C=w,w=T),O?D?C+w>0^b[1]<(ho(b[0]-x)<1e-6?C:w):C<=b[1]&&b[1]<=w:E>co^(x<=b[0]&&b[0]<=S)){var k=Bo(h,(-g+y)/_);return zo(k,m),[b,Fo(k)]}}}function l(t,n){var i=r?e:co-e,a=0;return t<-i?a|=1:t>i&&(a|=2),n<-i?a|=4:n>i&&(a|=8),a}return is(o,s,a,r?[0,-e]:[-co,e-co])}function fs(e,t,n,r,i,a){var o=e[0],s=e[1],c=t[0],l=t[1],u=0,d=1,f=c-o,p=l-s,m=n-o;if(!(!f&&m>0)){if(m/=f,f<0){if(m<u)return;m<d&&(d=m)}else if(f>0){if(m>d)return;m>u&&(u=m)}if(m=i-o,!(!f&&m<0)){if(m/=f,f<0){if(m>d)return;m>u&&(u=m)}else if(f>0){if(m<u)return;m<d&&(d=m)}if(m=r-s,!(!p&&m>0)){if(m/=p,p<0){if(m<u)return;m<d&&(d=m)}else if(p>0){if(m>d)return;m>u&&(u=m)}if(m=a-s,!(!p&&m<0)){if(m/=p,p<0){if(m>d)return;m>u&&(u=m)}else if(p>0){if(m<u)return;m<d&&(d=m)}return u>0&&(e[0]=o+u*f,e[1]=s+u*p),d<1&&(t[0]=o+d*f,t[1]=s+d*p),!0}}}}}var ps=1e9,ms=-ps;function hs(e,t,n,r){function i(i,a){return e<=i&&i<=n&&t<=a&&a<=r}function a(i,a,s,l){var u=0,d=0;if(i==null||(u=o(i,s))!==(d=o(a,s))||c(i,a)<0^s>0)do l.point(u===0||u===3?e:n,u>1?r:t);while((u=(u+s+4)%4)!==d);else l.point(a[0],a[1])}function o(r,i){return ho(r[0]-e)<1e-6?i>0?0:3:ho(r[0]-n)<1e-6?i>0?2:1:ho(r[1]-t)<1e-6?i>0?1:0:i>0?3:2}function s(e,t){return c(e.x,t.x)}function c(e,t){var n=o(e,1),r=o(t,1);return n===r?n===0?t[1]-e[1]:n===1?e[0]-t[0]:n===2?e[1]-t[1]:t[0]-e[0]:n-r}return function(o){var c=o,l=Zo(),u,d,f,p,m,h,g,_,v,y,b,x={point:S,lineStart:E,lineEnd:D,polygonStart:w,polygonEnd:T};function S(e,t){i(e,t)&&c.point(e,t)}function C(){for(var t=0,n=0,i=d.length;n<i;++n)for(var a=d[n],o=1,s=a.length,c=a[0],l,u,f=c[0],p=c[1];o<s;++o)l=f,u=p,c=a[o],f=c[0],p=c[1],u<=r?p>r&&(f-l)*(r-u)>(p-u)*(e-l)&&++t:p<=r&&(f-l)*(r-u)<(p-u)*(e-l)&&--t;return t}function w(){c=l,u=[],d=[],b=!0}function T(){var e=C(),t=b&&e,n=(u=qt(u)).length;(t||n)&&(o.polygonStart(),t&&(o.lineStart(),a(null,null,1,o),o.lineEnd()),n&&es(u,s,e,a,o),o.polygonEnd()),c=o,u=d=f=null}function E(){x.point=O,d&&d.push(f=[]),y=!0,v=!1,g=_=NaN}function D(){u&&(O(p,m),h&&v&&l.rejoin(),u.push(l.result())),x.point=S,v&&c.lineEnd()}function O(a,o){var s=i(a,o);if(d&&f.push([a,o]),y)p=a,m=o,h=s,y=!1,s&&(c.lineStart(),c.point(a,o));else if(s&&v)c.point(a,o);else{var l=[g=Math.max(ms,Math.min(ps,g)),_=Math.max(ms,Math.min(ps,_))],u=[a=Math.max(ms,Math.min(ps,a)),o=Math.max(ms,Math.min(ps,o))];fs(l,u,e,t,n,r)?(v||(c.lineStart(),c.point(l[0],l[1])),c.point(u[0],u[1]),s||c.lineEnd(),b=!1):s&&(c.lineStart(),c.point(a,o),b=!1)}g=a,_=o,v=s}return x}}function gs(e,t,n){var r=Jt(e,t-so,n).concat(t);return function(e){return r.map(function(t){return[e,t]})}}function _s(e,t,n){var r=Jt(e,t-so,n).concat(t);return function(e){return r.map(function(t){return[t,e]})}}function vs(){var e,t,n,r,i,a,o,s,c=10,l=c,u=90,d=360,f,p,m,h,g=2.5;function _(){return{type:`MultiLineString`,coordinates:v()}}function v(){return Jt(yo(r/u)*u,n,u).map(m).concat(Jt(yo(s/d)*d,o,d).map(h)).concat(Jt(yo(t/c)*c,e,c).filter(function(e){return ho(e%u)>so}).map(f)).concat(Jt(yo(a/l)*l,i,l).filter(function(e){return ho(e%d)>so}).map(p))}return _.lines=function(){return v().map(function(e){return{type:`LineString`,coordinates:e}})},_.outline=function(){return{type:`Polygon`,coordinates:[m(r).concat(h(o).slice(1),m(n).reverse().slice(1),h(s).reverse().slice(1))]}},_.extent=function(e){return arguments.length?_.extentMajor(e).extentMinor(e):_.extentMinor()},_.extentMajor=function(e){return arguments.length?(r=+e[0][0],n=+e[1][0],s=+e[0][1],o=+e[1][1],r>n&&(e=r,r=n,n=e),s>o&&(e=s,s=o,o=e),_.precision(g)):[[r,s],[n,o]]},_.extentMinor=function(n){return arguments.length?(t=+n[0][0],e=+n[1][0],a=+n[0][1],i=+n[1][1],t>e&&(n=t,t=e,e=n),a>i&&(n=a,a=i,i=n),_.precision(g)):[[t,a],[e,i]]},_.step=function(e){return arguments.length?_.stepMajor(e).stepMinor(e):_.stepMinor()},_.stepMajor=function(e){return arguments.length?(u=+e[0],d=+e[1],_):[u,d]},_.stepMinor=function(e){return arguments.length?(c=+e[0],l=+e[1],_):[c,l]},_.precision=function(c){return arguments.length?(g=+c,f=gs(a,i,90),p=_s(t,e,g),m=gs(s,o,90),h=_s(r,n,g),_):g},_.extentMajor([[-180,-90+so],[180,90-so]]).extentMinor([[-180,-80-so],[180,80+so]])}var ys=e=>e,bs=new Nt,xs=new Nt,Ss,Cs,ws,Ts,Es={point:Oo,lineStart:Oo,lineEnd:Oo,polygonStart:function(){Es.lineStart=Ds,Es.lineEnd=As},polygonEnd:function(){Es.lineStart=Es.lineEnd=Es.point=Oo,bs.add(ho(xs)),xs=new Nt},result:function(){var e=bs/2;return bs=new Nt,e}};function Ds(){Es.point=Os}function Os(e,t){Es.point=ks,Ss=ws=e,Cs=Ts=t}function ks(e,t){xs.add(Ts*e-ws*t),ws=e,Ts=t}function As(){ks(Ss,Cs)}var js=1/0,Ms=js,Ns=-js,Ps=Ns,Fs={point:Is,lineStart:Oo,lineEnd:Oo,polygonStart:Oo,polygonEnd:Oo,result:function(){var e=[[js,Ms],[Ns,Ps]];return Ns=Ps=-(Ms=js=1/0),e}};function Is(e,t){e<js&&(js=e),e>Ns&&(Ns=e),t<Ms&&(Ms=t),t>Ps&&(Ps=t)}var Ls=0,Rs=0,zs=0,Bs=0,Vs=0,Hs=0,Us=0,Ws=0,Gs=0,Ks,qs,Js,Ys,Xs={point:Zs,lineStart:Qs,lineEnd:tc,polygonStart:function(){Xs.lineStart=nc,Xs.lineEnd=rc},polygonEnd:function(){Xs.point=Zs,Xs.lineStart=Qs,Xs.lineEnd=tc},result:function(){var e=Gs?[Us/Gs,Ws/Gs]:Hs?[Bs/Hs,Vs/Hs]:zs?[Ls/zs,Rs/zs]:[NaN,NaN];return Ls=Rs=zs=Bs=Vs=Hs=Us=Ws=Gs=0,e}};function Zs(e,t){Ls+=e,Rs+=t,++zs}function Qs(){Xs.point=$s}function $s(e,t){Xs.point=ec,Zs(Js=e,Ys=t)}function ec(e,t){var n=e-Js,r=t-Ys,i=wo(n*n+r*r);Bs+=i*(Js+e)/2,Vs+=i*(Ys+t)/2,Hs+=i,Zs(Js=e,Ys=t)}function tc(){Xs.point=Zs}function nc(){Xs.point=ic}function rc(){ac(Ks,qs)}function ic(e,t){Xs.point=ac,Zs(Ks=Js=e,qs=Ys=t)}function ac(e,t){var n=e-Js,r=t-Ys,i=wo(n*n+r*r);Bs+=i*(Js+e)/2,Vs+=i*(Ys+t)/2,Hs+=i,i=Ys*e-Js*t,Us+=i*(Js+e),Ws+=i*(Ys+t),Gs+=i*3,Zs(Js=e,Ys=t)}function oc(e){this._context=e}oc.prototype={_radius:4.5,pointRadius:function(e){return this._radius=e,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){this._line===0&&this._context.closePath(),this._point=NaN},point:function(e,t){switch(this._point){case 0:this._context.moveTo(e,t),this._point=1;break;case 1:this._context.lineTo(e,t);break;default:this._context.moveTo(e+this._radius,t),this._context.arc(e,t,this._radius,0,fo);break}},result:Oo};var sc=new Nt,cc,lc,uc,dc,fc,pc={point:Oo,lineStart:function(){pc.point=mc},lineEnd:function(){cc&&hc(lc,uc),pc.point=Oo},polygonStart:function(){cc=!0},polygonEnd:function(){cc=null},result:function(){var e=+sc;return sc=new Nt,e}};function mc(e,t){pc.point=hc,lc=dc=e,uc=fc=t}function hc(e,t){dc-=e,fc-=t,sc.add(wo(dc*dc+fc*fc)),dc=e,fc=t}var gc,_c,vc,yc,bc=class{constructor(e){this._append=e==null?xc:Sc(e),this._radius=4.5,this._=``}pointRadius(e){return this._radius=+e,this}polygonStart(){this._line=0}polygonEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){this._line===0&&(this._+=`Z`),this._point=NaN}point(e,t){switch(this._point){case 0:this._append`M${e},${t}`,this._point=1;break;case 1:this._append`L${e},${t}`;break;default:if(this._append`M${e},${t}`,this._radius!==vc||this._append!==_c){let e=this._radius,t=this._;this._=``,this._append`m0,${e}a${e},${e} 0 1,1 0,${-2*e}a${e},${e} 0 1,1 0,${2*e}z`,vc=e,_c=this._append,yc=this._,this._=t}this._+=yc;break}}result(){let e=this._;return this._=``,e.length?e:null}};function xc(e){let t=1;this._+=e[0];for(let n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function Sc(e){let t=Math.floor(e);if(!(t>=0))throw RangeError(`invalid digits: ${e}`);if(t>15)return xc;if(t!==gc){let e=10**t;gc=t,_c=function(t){let n=1;this._+=t[0];for(let r=t.length;n<r;++n)this._+=Math.round(arguments[n]*e)/e+t[n]}}return _c}function Cc(e,t){let n=3,r=4.5,i,a;function o(e){return e&&(typeof r==`function`&&a.pointRadius(+r.apply(this,arguments)),Po(e,i(a))),a.result()}return o.area=function(e){return Po(e,i(Es)),Es.result()},o.measure=function(e){return Po(e,i(pc)),pc.result()},o.bounds=function(e){return Po(e,i(Fs)),Fs.result()},o.centroid=function(e){return Po(e,i(Xs)),Xs.result()},o.projection=function(t){return arguments.length?(i=t==null?(e=null,ys):(e=t).stream,o):e},o.context=function(e){return arguments.length?(a=e==null?(t=null,new bc(n)):new oc(t=e),typeof r!=`function`&&a.pointRadius(r),o):t},o.pointRadius=function(e){return arguments.length?(r=typeof e==`function`?e:(a.pointRadius(+e),+e),o):r},o.digits=function(e){if(!arguments.length)return n;if(e==null)n=null;else{let t=Math.floor(e);if(!(t>=0))throw RangeError(`invalid digits: ${e}`);n=t}return t===null&&(a=new bc(n)),o},o.projection(e).digits(n).context(t)}function wc(e){return function(t){var n=new Tc;for(var r in e)n[r]=e[r];return n.stream=t,n}}function Tc(){}Tc.prototype={constructor:Tc,point:function(e,t){this.stream.point(e,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function Ec(e,t,n){var r=e.clipExtent&&e.clipExtent();return e.scale(150).translate([0,0]),r!=null&&e.clipExtent(null),Po(n,e.stream(Fs)),t(Fs.result()),r!=null&&e.clipExtent(r),e}function Dc(e,t,n){return Ec(e,function(n){var r=t[1][0]-t[0][0],i=t[1][1]-t[0][1],a=Math.min(r/(n[1][0]-n[0][0]),i/(n[1][1]-n[0][1])),o=+t[0][0]+(r-a*(n[1][0]+n[0][0]))/2,s=+t[0][1]+(i-a*(n[1][1]+n[0][1]))/2;e.scale(150*a).translate([o,s])},n)}function Oc(e,t,n){return Dc(e,[[0,0],t],n)}function kc(e,t,n){return Ec(e,function(n){var r=+t,i=r/(n[1][0]-n[0][0]),a=(r-i*(n[1][0]+n[0][0]))/2,o=-i*n[0][1];e.scale(150*i).translate([a,o])},n)}function Ac(e,t,n){return Ec(e,function(n){var r=+t,i=r/(n[1][1]-n[0][1]),a=-i*n[0][0],o=(r-i*(n[1][1]+n[0][1]))/2;e.scale(150*i).translate([a,o])},n)}var jc=16,Mc=vo(30*mo);function Nc(e,t){return+t?Fc(e,t):Pc(e)}function Pc(e){return wc({point:function(t,n){t=e(t,n),this.stream.point(t[0],t[1])}})}function Fc(e,t){function n(r,i,a,o,s,c,l,u,d,f,p,m,h,g){var _=l-r,v=u-i,y=_*_+v*v;if(y>4*t&&h--){var b=o+f,x=s+p,S=c+m,C=wo(b*b+x*x+S*S),w=Do(S/=C),T=ho(ho(S)-1)<1e-6||ho(a-d)<1e-6?(a+d)/2:_o(x,b),E=e(T,w),D=E[0],O=E[1],k=D-r,A=O-i,j=v*k-_*A;(j*j/y>t||ho((_*k+v*A)/y-.5)>.3||o*f+s*p+c*m<Mc)&&(n(r,i,a,o,s,c,D,O,T,b/=C,x/=C,S,h,g),g.point(D,O),n(D,O,T,b,x,S,l,u,d,f,p,m,h,g))}}return function(t){var r,i,a,o,s,c,l,u,d,f,p,m,h={point:g,lineStart:_,lineEnd:y,polygonStart:function(){t.polygonStart(),h.lineStart=b},polygonEnd:function(){t.polygonEnd(),h.lineStart=_}};function g(n,r){n=e(n,r),t.point(n[0],n[1])}function _(){u=NaN,h.point=v,t.lineStart()}function v(r,i){var a=Io([r,i]),o=e(r,i);n(u,d,l,f,p,m,u=o[0],d=o[1],l=r,f=a[0],p=a[1],m=a[2],jc,t),t.point(u,d)}function y(){h.point=g,t.lineEnd()}function b(){_(),h.point=x,h.lineEnd=S}function x(e,t){v(r=e,t),i=u,a=d,o=f,s=p,c=m,h.point=v}function S(){n(u,d,l,f,p,m,i,a,r,o,s,c,jc,t),h.lineEnd=y,y()}return h}}var Ic=wc({point:function(e,t){this.stream.point(e*mo,t*mo)}});function Lc(e){return wc({point:function(t,n){var r=e(t,n);return this.stream.point(r[0],r[1])}})}function Rc(e,t,n,r,i){function a(a,o){return a*=r,o*=i,[t+e*a,n-e*o]}return a.invert=function(a,o){return[(a-t)/e*r,(n-o)/e*i]},a}function zc(e,t,n,r,i,a){if(!a)return Rc(e,t,n,r,i);var o=vo(a),s=So(a),c=o*e,l=s*e,u=o/e,d=s/e,f=(s*n-o*t)/e,p=(s*t+o*n)/e;function m(e,a){return e*=r,a*=i,[c*e-l*a+t,n-l*e-c*a]}return m.invert=function(e,t){return[r*(u*e-d*t+f),i*(p-d*e-u*t)]},m}function Bc(e){return Vc(function(){return e})()}function Vc(e){var t,n=150,r=480,i=250,a=0,o=0,s=0,c=0,l=0,u,d=0,f=1,p=1,m=null,h=ss,g=null,_,v,y,b=ys,x=.5,S,C,w,T,E;function D(e){return w(e[0]*mo,e[1]*mo)}function O(e){return e=w.invert(e[0],e[1]),e&&[e[0]*po,e[1]*po]}D.stream=function(e){return T&&E===e?T:T=Ic(Lc(u)(h(S(b(E=e)))))},D.preclip=function(e){return arguments.length?(h=e,m=void 0,A()):h},D.postclip=function(e){return arguments.length?(b=e,g=_=v=y=null,A()):b},D.clipAngle=function(e){return arguments.length?(h=+e?ds(m=e*mo):(m=null,ss),A()):m*po},D.clipExtent=function(e){return arguments.length?(b=e==null?(g=_=v=y=null,ys):hs(g=+e[0][0],_=+e[0][1],v=+e[1][0],y=+e[1][1]),A()):g==null?null:[[g,_],[v,y]]},D.scale=function(e){return arguments.length?(n=+e,k()):n},D.translate=function(e){return arguments.length?(r=+e[0],i=+e[1],k()):[r,i]},D.center=function(e){return arguments.length?(a=e[0]%360*mo,o=e[1]%360*mo,k()):[a*po,o*po]},D.rotate=function(e){return arguments.length?(s=e[0]%360*mo,c=e[1]%360*mo,l=e.length>2?e[2]%360*mo:0,k()):[s*po,c*po,l*po]},D.angle=function(e){return arguments.length?(d=e%360*mo,k()):d*po},D.reflectX=function(e){return arguments.length?(f=e?-1:1,k()):f<0},D.reflectY=function(e){return arguments.length?(p=e?-1:1,k()):p<0},D.precision=function(e){return arguments.length?(S=Nc(C,x=e*e),A()):wo(x)},D.fitExtent=function(e,t){return Dc(D,e,t)},D.fitSize=function(e,t){return Oc(D,e,t)},D.fitWidth=function(e,t){return kc(D,e,t)},D.fitHeight=function(e,t){return Ac(D,e,t)};function k(){var e=zc(n,0,0,f,p,d).apply(null,t(a,o)),m=zc(n,r-e[0],i-e[1],f,p,d);return u=Wo(s,c,l),C=Ho(t,m),w=Ho(u,C),S=Nc(C,x),A()}function A(){return T=E=null,D}return function(){return t=e.apply(this,arguments),D.invert=t.invert&&O,k()}}function Hc(e){return function(t,n){var r=wo(t*t+n*n),i=e(r),a=So(i),o=vo(i);return[_o(t*a,r*o),Do(r&&n*a/r)]}}function Uc(e,t){return[e,xo(To((lo+t)/2))]}Uc.invert=function(e,t){return[e,2*go(bo(t))-lo]};function Wc(){return Gc(Uc).scale(961/fo)}function Gc(e){var t=Bc(e),n=t.center,r=t.scale,i=t.translate,a=t.clipExtent,o=null,s,c,l;t.scale=function(e){return arguments.length?(r(e),u()):r()},t.translate=function(e){return arguments.length?(i(e),u()):i()},t.center=function(e){return arguments.length?(n(e),u()):n()},t.clipExtent=function(e){return arguments.length?(e==null?o=s=c=l=null:(o=+e[0][0],s=+e[0][1],c=+e[1][0],l=+e[1][1]),u()):o==null?null:[[o,s],[c,l]]};function u(){var n=co*r(),i=t(Jo(t.rotate()).invert([0,0]));return a(o==null?[[i[0]-n,i[1]-n],[i[0]+n,i[1]+n]]:e===Uc?[[Math.max(i[0]-n,o),s],[Math.min(i[0]+n,c),l]]:[[o,Math.max(i[1]-n,s)],[c,Math.min(i[1]+n,l)]])}return u()}function Kc(e,t){return[vo(t)*So(e),So(t)]}Kc.invert=Hc(Do);function qc(){return Bc(Kc).scale(249.5).clipAngle(90+so)}var Jc=100;function Yc(e,t,n,r){let i=document.createElement(`div`);i.className=`adornment`;let a=e.scale??1,o=a*Jc;i.style.width=`${o*r}px`,i.style.height=`${o*r}px`,i.style.flexGrow=`0`,i.style.flexShrink=`0`;let s={id:e.id,map:t,container:i,moveEndPosition:t.getCenter(),geoJson:void 0,isGlobe:e.isGlobe,boundingBox:e.boundingBox,scale:a,backgroundColor:e.backgroundColor??`#000000`,globeBackgroundColor:e.globeBackgroundColor??`#000000`,borderColor:e.borderColor??`#000000`,primaryFillColor:e.primaryFillColor??`#000000`,primaryStrokeColor:e.primaryStrokeColor??`#000000`,secondaryFillColor:e.secondaryFillColor??`#000000`,secondaryStrokeColor:e.secondaryStrokeColor??`#000000`,graticuleColor:e.graticuleColor??`#000000`,frameColor:e.frameColor??`#000000`,frameOutlineColor:e.frameOutlineColor??`#000000`,dotColor:e.dotColor??`#000000`,dotOutlineColor:e.dotOutlineColor??`#000000`,mapScale:r,globeFallbackActive:!1,globeGeoJsonRequested:!1,globeGeoJson:void 0};return fetch(`${n}/data/insetmaps/${e.fileName}`).then(e=>e.json()).then(e=>{s.geoJson=aa(e,Object.keys(e.objects)[0]),Xc(s)}),t.on(`moveend`,()=>{s.moveEndPosition=t.getCenter(),(s.isGlobe||s.globeFallbackActive)&&Xc(s)}),t.on(`move`,()=>{if(!s.isGlobe){let[e,r,i,a]=s.boundingBox,o=$c(t),c=oo(Bn([o,Rn([[[e,r],[e,a],[i,a],[i,r],[e,r]]])])),l=Xi(o),u=(c?Xi(c):0)<l*.75;s.globeFallbackActive!==u&&(s.globeFallbackActive=u,s.moveEndPosition=t.getCenter(),Xc(s)),s.globeFallbackActive&&!s.globeGeoJsonRequested&&(s.globeGeoJsonRequested=!0,fetch(`${n}/data/insetmaps/world-110m.json`).then(e=>e.json()).then(e=>{s.globeGeoJson=aa(e,Object.keys(e.objects)[0]),s.moveEndPosition=t.getCenter(),Xc(s)}))}Qc(s)}),i}function Xc(e){let{id:t,container:n,scale:r,backgroundColor:i,globeBackgroundColor:a,secondaryFillColor:o,secondaryStrokeColor:s,primaryFillColor:c,primaryStrokeColor:l,graticuleColor:u,borderColor:d,frameColor:f,frameOutlineColor:p,dotColor:m,dotOutlineColor:h}=e,g=e.globeFallbackActive&&e.globeGeoJson!==void 0,_=g?e.globeGeoJson:e.geoJson,v=g||e.isGlobe;if(_===void 0)return;let y=Jc*r,b=y/2,x=.1*r,S=[v?`<circle cx="${b}" cy="${b}" r="${b}" fill="${a}"></circle>`:`<rect x="0" y="0" width="${y}" height="${y}" fill="${i}"></rect>`],{path:C}=Zc(e),w=C({..._,features:_.features.filter(e=>e.properties?.class!==`P1`)});w&&S.push(`
940
+ <path
941
+ d="${w}"
942
+ fill="${o}"
943
+ stroke="${s}"
944
+ stroke-width="${x}"
945
+ ></path>
946
+ `);let T=C({..._,features:_.features.filter(e=>e.properties?.class===`P1`)});if(T&&S.push(`
947
+ <path
948
+ d="${T}"
949
+ fill="${c}"
950
+ stroke="${l}"
951
+ stroke-width="${x}"
952
+ ></path>
953
+ `),v){let e=C(Bn(vs().step([10,10]).lines().map(e=>zn(e.coordinates))));S.push(`
954
+ <path
955
+ d="${e}"
956
+ fill="none"
957
+ stroke="${u}"
958
+ stroke-width="${x}"
959
+ ></path>
960
+ `)}S.push(`
961
+ <path
962
+ id="frame-outline-${t}"
963
+ fill="none"
964
+ stroke="${p}"
965
+ stroke-width="${4*r}"
966
+ ></path>
967
+ `),S.push(`
968
+ <path
969
+ id="frame-${t}"
970
+ fill="none"
971
+ stroke="${f}"
972
+ stroke-width="${2*r}"
973
+ ></path>
974
+ `),S.push(`
975
+ <circle
976
+ id="dot-${t}"
977
+ r="${5*r}"
978
+ fill="${m}"
979
+ stroke="${h}"
980
+ stroke-width="${2*r}"
981
+ ></circle>
982
+ `),v||S.push(`
983
+ <rect
984
+ x="${r/2}"
985
+ y="${r/2}"
986
+ width="${y-r}"
987
+ height="${y-r}"
988
+ fill="none"
989
+ stroke="${d}"
990
+ stroke-width="${r}"
991
+ ></rect>
992
+ `),n.innerHTML=`
993
+ <svg
994
+ class="adornment-svg"
995
+ xmlns="http://www.w3.org/2000/svg"
996
+ viewBox="0 0 ${y} ${y}"
997
+ width="${y*e.mapScale}"
998
+ height="${y*e.mapScale}"
999
+ >
1000
+ ${S.join(``)}
1001
+ </svg>
1002
+ `,Qc(e)}function Zc(e){let{scale:t,boundingBox:n,moveEndPosition:r}=e,i=e.globeFallbackActive&&e.globeGeoJson!==void 0||e.isGlobe,a=Jc*t,o=Cc(),s;if(i){let{lng:e,lat:t}=r;s=qc().scale(a/2).translate([a/2,a/2]).rotate([-e,-t]).clipAngle(90)}else{s=Wc().scale(1).translate([0,0]);let e=s([n[0],n[3]]),t=s([n[2],n[1]]),r=Math.abs(t[0]-e[0]),i=Math.abs(t[1]-e[1]),o=(e[0]+t[0])/2,c=(e[1]+t[1])/2,l=1/Math.max(r/a,i/a);s.scale(l).translate([a/2-l*o,a/2-l*c])}return o.projection(s),{path:o,projection:s}}function Qc(e){let{id:t,map:n,container:r,scale:i}=e,a=r.querySelector(`#frame-${t}`),o=r.querySelector(`#frame-outline-${t}`),s=r.querySelector(`#dot-${t}`);if(!a||!o||!s)return;let c=$c(n),{path:l,projection:u}=Zc(e),d=1/0,f=-1/0,p=1/0,m=-1/0,h=1/0,g=-1/0;Un(c,e=>{let t=u(e);d=Math.min(d,e[0]),f=Math.max(f,e[0]),p=Math.min(p,t[0]),m=Math.max(m,t[0]),h=Math.min(h,t[1]),g=Math.max(g,t[1])});let _=10*i;if(m-p<_||g-h<_){a.style.display=`none`,o.style.display=`none`,s.style.display=`block`;let e=n.getCenter(),[t,r]=u([e.lng,e.lat]);s.setAttribute(`cx`,String(t)),s.setAttribute(`cy`,String(r))}else if(f-d<180){a.style.display=`block`,o.style.display=`block`,s.style.display=`none`;let e=l(c);a.setAttribute(`d`,e),o.setAttribute(`d`,e)}else a.style.display=`none`,o.style.display=`none`,s.style.display=`none`}function $c(e){let t=e.getCanvas().width,n=e.getCanvas().height,r=[];for(let n=0;n<64;n++){let{lng:i,lat:a}=e.unprojectWithScaleCorrection([j(0,t,n/64),0]);r.push([i,a])}for(let i=0;i<64;i++){let{lng:a,lat:o}=e.unprojectWithScaleCorrection([t,j(0,n,i/64)]);r.push([a,o])}for(let i=0;i<64;i++){let{lng:a,lat:o}=e.unprojectWithScaleCorrection([j(t,0,i/64),n]);r.push([a,o])}for(let t=0;t<64;t++){let{lng:i,lat:a}=e.unprojectWithScaleCorrection([0,j(n,0,t/64)]);r.push([i,a])}let{lng:i,lat:a}=e.unprojectWithScaleCorrection([0,0]);return r.push([i,a]),{type:`Feature`,properties:{},geometry:{coordinates:[r],type:`Polygon`}}}var el=[10,5,3,2,1];function tl(e,t=1e-6){let n=Math.floor(e);if(e-=n,e<t)return[n,1];if(1-t<e)return[n+1,1];let r=0,i=1,a=1,o=1;for(;;){let s=r+a,c=i+o;if(c*(e+t)<s)a=s,o=c;else if(s<(e-t)*c)r=s,i=c;else return[n*c+s,c]}}function nl(e){let t=10**Math.floor(Math.log10(e)),n=e/t;for(let e of el)if(n>=e)return e*t;return rl(n)*t}function rl(e){let t=10**Math.ceil(-Math.log(e)/Math.LN10);return Math.round(e*t)/t}var il={kilometer:`km`,meter:`m`,mile:`mi`,foot:`ft`,nauticalMile:`nm`};function al(e,t,n){let r=document.createElement(`div`);return r.className=`adornment`,r.innerHTML=ol(t,e,n),t.on(`move`,()=>{r.innerHTML=ol(t,e,n)}),r}function ol(e,t,n){let{maxWidth:r=100,fontSize:i=8,font:a=`Arial, sans-serif`,color:o=`#000000`,unit:s=`metric_and_imperial`}=t,c=e.getCenter(),l=e.projectWithScaleCorrection(c),u=C(c,e.unprojectWithScaleCorrection([l.x+r,l.y])),d=Object.fromEntries(Object.entries(il).map(([e,t])=>{let n=A(`meter`,e,u),r=nl(n)||0;return[e,{value:n,ratio:n?r/n:0,humanized:r<1?`${tl(r).join(`/`)} ${t}`:`${r} ${t}`}]})),f=d.meter.value>1e3?d.kilometer:d.meter,p=d.foot.value>5280?d.mile:d.foot,m={imperial:p,metric:f,nautical:d.nauticalMile},h=s===`metric_and_imperial`?void 0:m[s],g={metric:Math.round(r*f.ratio),imperial:Math.round(r*p.ratio)},_=s===`metric_and_imperial`?Math.max(g.metric,g.imperial):Math.round(r*(h?.ratio??0)),v=i+7;if(s===`metric_and_imperial`){let e=v+i*2;return`
1003
+ <svg
1004
+ class="adornment-svg"
1005
+ xmlns="http://www.w3.org/2000/svg"
1006
+ width="${_*n}"
1007
+ height="${e*n}"
1008
+ viewBox="0 0 ${_} ${e}"
1009
+ >
1010
+ <line
1011
+ x1="0"
1012
+ y1="${v-.5}"
1013
+ x2="${_}"
1014
+ y2="${v-.5}"
1015
+ stroke="${o}"
1016
+ stroke-width="1"
1017
+ />
1018
+ <line
1019
+ x1="0.5"
1020
+ y1="${v-5}"
1021
+ x2="0.5"
1022
+ y2="${v+5}"
1023
+ stroke="${o}"
1024
+ stroke-width="1"
1025
+ />
1026
+ <line
1027
+ x1="${g.imperial-.5}"
1028
+ y1="${v-5}"
1029
+ x2="${g.imperial-.5}"
1030
+ y2="${v}"
1031
+ stroke="${o}"
1032
+ stroke-width="1"
1033
+ />
1034
+ <line
1035
+ x1="${g.metric-.5}"
1036
+ y1="${v}"
1037
+ x2="${g.metric-.5}"
1038
+ y2="${v+5}"
1039
+ stroke="${o}"
1040
+ stroke-width="1"
1041
+ />
1042
+ <text
1043
+ x="0"
1044
+ y="${v+7+i}"
1045
+ font-size="${i}px"
1046
+ font-family="${a}"
1047
+ font-weight="bold"
1048
+ fill="${o}"
1049
+ text-anchor="start"
1050
+ >
1051
+ 0
1052
+ </text>
1053
+ <text
1054
+ x="${g.imperial}"
1055
+ y="${v-7}"
1056
+ font-size="${i}px"
1057
+ font-family="${a}"
1058
+ font-weight="bold"
1059
+ fill="${o}"
1060
+ text-anchor="end"
1061
+ >
1062
+ ${p.humanized}
1063
+ </text>
1064
+ <text
1065
+ x="${g.metric}"
1066
+ y="${v+7+i}"
1067
+ font-size="${i}px"
1068
+ font-family="${a}"
1069
+ font-weight="bold"
1070
+ fill="${o}"
1071
+ text-anchor="end"
1072
+ >
1073
+ ${f.humanized}
1074
+ </text>
1075
+ </svg>
1076
+ `}let y=v+i+5;return`
1077
+ <svg
1078
+ class="adornment-svg"
1079
+ xmlns="http://www.w3.org/2000/svg"
1080
+ width="${_*n}"
1081
+ height="${y*n}"
1082
+ viewBox="0 0 ${_} ${y}"
1083
+ >
1084
+ <line
1085
+ x1="0"
1086
+ y1="4.5"
1087
+ x2="${_}"
1088
+ y2="4.5"
1089
+ stroke="${o}"
1090
+ stroke-width="1"
1091
+ />
1092
+ <line
1093
+ x1="0.5"
1094
+ y1="0"
1095
+ x2="0.5"
1096
+ y2="10"
1097
+ stroke="${o}"
1098
+ stroke-width="1"
1099
+ />
1100
+ <line
1101
+ x1="${_-.5}"
1102
+ y1="0"
1103
+ x2="${_-.5}"
1104
+ y2="10"
1105
+ stroke="${o}"
1106
+ stroke-width="1"
1107
+ />
1108
+ <text
1109
+ x="0"
1110
+ y="${i+12}"
1111
+ font-size="${i}px"
1112
+ font-family="${a}"
1113
+ font-weight="bold"
1114
+ fill="${o}"
1115
+ text-anchor="start"
1116
+ >
1117
+ 0
1118
+ </text>
1119
+ <text
1120
+ x="${_}"
1121
+ y="${i+12}"
1122
+ font-size="${i}px"
1123
+ font-family="${a}"
1124
+ font-weight="bold"
1125
+ fill="${o}"
1126
+ text-anchor="end"
1127
+ >
1128
+ ${h?.humanized??``}
1129
+ </text>
1130
+ </svg>
1131
+ `}function sl(e,t,n,r){let i=document.createElement(`div`);i.className=`adornment`;let a=`ArialMT`,o=[e.titleFont??a,e.subtitleFont??a];return kr(Array.from(new Set(o)),t,n).then(()=>i.innerHTML=cl(e,a,r)),i}function cl(e,t,n){let{title:r,titleColor:i=`#000000`,titleFont:a=t,titleFontSize:o=20,titleJustify:s=`center`,subtitle:c,subtitleColor:l=`#000000`,subtitleFont:u=t,subtitleFontSize:d=12,subtitleJustify:f=`center`,background:p=`#ffffff`,showBackground:m=!1}=e,h=0,g=0,_=0,v=0,y=0,b=r.trim().length>0?Wr([r],a,o):null,x=c.trim().length>0?Wr([c],u,d):null;if(h=Math.max(b?.width??0,x?.width??0),b){let{ascent:e,descent:t}=b;g=e+t,v=8+e}if(x){let{ascent:e,descent:t}=x;_=e+t,y=b?v+b.descent+e+6:8+e}let S=h+16,C=g+_+16,w=s===`center`?S/2:s===`right`?S-8:8,T=f===`center`?S/2:f===`right`?S-8:8,E=``;if(E+=`<svg class="adornment-svg" xmlns="http://www.w3.org/2000/svg" width="${S*n}" height="${C*n}" viewBox="0 0 ${S} ${C}">`,E+=`<rect x="0" y="0" width="${S}" height="${C}" fill="${p}" rx="6" style="visibility:${m?`visible`:`hidden`}" />`,b||x){let e=s===`center`?`middle`:s===`right`?`end`:`start`,t=f===`center`?`middle`:f===`right`?`end`:`start`;E+=`<text x="${w}" y="${v}" fill="${i}" font-family="${a}" font-size="${o}" text-anchor="${e}">`,b&&(E+=`${Or(r)}`),x&&(E+=`<tspan x="${T}" y="${y}" fill="${l}" font-family="${u}" font-size="${d}" text-anchor="${t}">`,E+=`${Or(c)}`,E+=`</tspan>`),E+=`</text>`}return E+=`</svg>`,E}var ll=[`top_left`,`top_right`,`bottom_left`,`bottom_right`,`top_center`,`left_center`,`right_center`,`bottom_center`],ul=new Map;function dl(e,t,n,r,i,a,o,s,c){let{adornments:l=[]}=e;fl(n,t,s,c),l.forEach(t=>{t.type===`custom`?ml(F(t,s),t.position,t.stacking):t.type===`scalebar`?ml(al(t,n,s),t.position,t.stacking):t.type===`northArrow`?ml(fi(t,n,s),t.position,t.stacking):t.type===`webControls`&&t.buttons?ml(Wi(t,n,r),t.position,t.stacking):t.type===`insetMap`?ml(Yc(t,n,a,s),t.position,t.stacking):t.type===`heading`?ml(sl(t,i,o,s),t.position,t.stacking):t.type===`manualLegend`?ml(di(t,i,o,s),t.position,t.stacking):t.type===`connectedLegend`?ml(ri(t,e,n,i,o,s),t.position,t.stacking):t.type===`copyright`&&c===`video`&&ml(Ki(t,n,s),t.position,t.stacking)}),hl(n),n.on(`moveend`,()=>hl(n))}function fl(e,t,n,r){let i=e.getContainer();for(let e of ll){let a=document.createElement(`div`);a.classList.add(`adornment-container`,e),a.style.cssText=pl(e,t[e],n,r);let o=document.createElement(`div`),s=document.createElement(`div`);o.classList.add(`inner`),s.classList.add(`inner`,`vertical`),a.append(o,s),i.appendChild(a),ul.set(e,{horizontal:o,vertical:s})}}function pl(e,t,n,r){let i=p[e],a=``,o=[],s=t.x*n,c=t.y*n,{unit:l}=t;return i.x===`center`?o.push(`translateX(${s}${l})`):a+=`${i.x}: ${s}${l};`,i.y===`center`?o.push(`translateY(${c}${l})`):e===`bottom_right`&&r!==`video`?a+=`${i.y}: max(${c}${l}, 25px);`:a+=`${i.y}: ${c}${l};`,o.length&&(a+=`transform: ${o.join(` `)};`),a}function ml(e,t,n){n||=[`left_center`,`right_center`].includes(t)?`vertical`:`horizontal`;let r=ul.get(t),i=t===`left_center`||t===`right_center`?`vertical`:`horizontal`;r?.[i].hasChildNodes()||(n=i),(r?.[n])?.appendChild(e)}function hl(e){let t=Array.from(document.querySelectorAll(`.adornment, .maplibregl-ctrl-attrib`)),n=[];t.forEach(e=>{let t=e.getBoundingClientRect();t&&n.push([t.x,t.y,t.x+t.width,t.y+t.height])}),e.setLabelFreeAreas(n)}function gl(e,t,n,r,i){e.addSource(t.id,{type:`geojson`,data:{type:`FeatureCollection`,features:t.models.filter(e=>e.visible??!0).map(e=>_l(t,e,r,i))}}),e.addLayer({id:t.id,type:`fill`,source:t.id,metadata:{"mc-model-type":`polygon`,"mc-group-id":t.id},paint:{"fill-color":[`get`,`fill-color`],"fill-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]}},n),e.addLayer({id:`${t.id}-pattern`,type:`fill`,source:t.id,filter:[`has`,`fill-pattern`],paint:{"fill-pattern":[`get`,`fill-pattern`],"fill-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]},metadata:{"mc-model-type":`polygon`,"mc-group-id":t.id}},n),e.addLayer({id:`${t.id}-outline`,type:`line`,source:t.id,metadata:{"mc-model-type":`polygon`,"mc-group-id":t.id},layout:{"line-cap":`round`,"line-join":`round`},paint:{"line-width":[`get`,`outline-width`],"line-color":[`get`,`outline-color`],"line-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]}},n)}function _l(e,t,n,r){let i=t.fillPattern===void 0?void 0:r.getMapLibreImageKey(n[t.fillPattern],2*window.devicePixelRatio);return{type:`Feature`,id:w(t.id),properties:{id:t.id,"fill-color":e.fillColor||t.fillColor?Gr(t.dataBindings??{},t.fillColor,e.fillColor):`#000000`,"outline-color":e.outlineColor||t.outlineColor?Gr(t.dataBindings??{},t.outlineColor,e.outlineColor):`#000000`,"outline-width":t.outlineWidth??0,"fill-pattern":i},geometry:{type:`Polygon`,coordinates:cr(t)}}}function vl(e,t,n,r,i){e.addSource(t.id,{type:`geojson`,data:{type:`FeatureCollection`,features:t.models.filter(e=>e.visible??!0).map(e=>yl(t,e,1,r,i))}}),e.addLayer({id:t.id,type:`fill`,source:t.id,metadata:{"mc-model-type":`circle`,"mc-group-id":t.id},filter:[`==`,[`geometry-type`],`Polygon`],paint:{"fill-color":[`get`,`fill-color`],"fill-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]}},n),e.addLayer({id:`${t.id}-pattern`,type:`fill`,source:t.id,filter:[`has`,`fill-pattern`],paint:{"fill-pattern":[`get`,`fill-pattern`],"fill-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]},metadata:{"mc-model-type":`circle`,"mc-group-id":t.id}},n),e.addLayer({id:`${t.id}-radius-line`,type:`line`,source:t.id,metadata:{"mc-model-type":`circle`,"mc-group-id":t.id},filter:[`all`,[`==`,[`geometry-type`],`LineString`],[`get`,`radius-line-enabled`]],paint:{"line-color":[`get`,`radius-line-color`],"line-width":[`get`,`radius-line-width`],"line-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]}},n),e.addLayer({id:`${t.id}-outline`,type:`line`,source:t.id,metadata:{"mc-model-type":`circle`,"mc-group-id":t.id},filter:[`==`,[`geometry-type`],`Polygon`],layout:{"line-cap":`round`,"line-join":`round`},paint:{"line-width":[`get`,`outline-width`],"line-color":[`get`,`outline-color`],"line-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]}},n)}function yl(e,t,n,r,i){let a=t.fillPattern===void 0?void 0:i.getMapLibreImageKey(r[t.fillPattern],2*window.devicePixelRatio);return{type:`Feature`,id:w(t.id),properties:{id:t.id,"fill-color":e.fillColor||t.fillColor?Gr(t.dataBindings??{},t.fillColor,e.fillColor):`#000000`,"outline-color":e.outlineColor||t.outlineColor?Gr(t.dataBindings??{},t.outlineColor,e.outlineColor):`#000000`,"outline-width":t.outlineWidth??0,"fill-pattern":a,"radius-line-enabled":t.radiusLineEnabled??!1,"radius-line-color":e.radiusLineColor||t.radiusLineColor?Gr(t.dataBindings??{},t.radiusLineColor,e.radiusLineColor):`#000000`,"radius-line-width":t.radiusLineWidth??0},geometry:{type:`GeometryCollection`,geometries:[{type:`Polygon`,coordinates:[rr(t.center,t.radius*n)]},{type:`LineString`,coordinates:ir(t.center,t.radius*n,t.radiusLineBearing??0)}]}}}var bl=`Roboto-Regular`;function xl(e,t,n,r,i){let a=[],o=new Set,s=new Set,c=[`match`,[`get`,`text-font`]],l=!!t.clustering;for(let e of t.models)(e.visible??!0)&&a.push(Cl(t,e,1,r,i)),o.add(e.textFont),s.add(e.textLineHeight??1.2);if(Array.from(o).length>0){for(let e of Array.from(o))c.push(e,[`literal`,[e,bl]]);c.push([`literal`,[bl]])}e.addSource(t.id,{type:`geojson`,data:{type:`FeatureCollection`,features:a},cluster:l,clusterRadius:t.clusterRadius??50,clusterMaxZoom:t.clusterMaxZoom??14}),s.forEach(r=>{e.addLayer({id:`${t.id}-${r}`,type:`symbol`,source:t.id,metadata:{"mc-model-type":`marker`,"mc-group-id":t.id},layout:{"icon-allow-overlap":!t.collisionDetection,"icon-ignore-placement":!t.collisionDetection,"text-allow-overlap":!t.collisionDetection,"text-ignore-placement":!t.collisionDetection,"icon-image":[`get`,`mc-image-key`],"icon-anchor":[`get`,`icon-anchor`],"icon-size":[`get`,`icon-size`],"icon-rotate":[`get`,`icon-rotate`],"icon-offset":[`get`,`icon-offset`],"text-field":`{text}`,"text-font":c,"text-max-width":[`get`,`text-max-width`],"text-offset":[`get`,`text-offset`],"text-rotate":[`get`,`text-rotate`],"text-size":[`get`,`text-size`],"text-anchor":[`get`,`text-anchor`],"text-letter-spacing":[`get`,`text-letter-spacing`],"text-line-height":r,"text-justify":[`get`,`text-justify`]},paint:{"icon-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1],"text-color":[`get`,`text-color`],"text-halo-color":[`get`,`text-halo-color`],"text-halo-width":[`get`,`text-halo-width`],"text-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]},filter:[`all`,[`==`,[`get`,`text-line-height`],r],[`!`,[`has`,`point_count`]]]},n)}),l&&(e.addLayer({id:`${t.id}-circle-cluster`,type:`circle`,source:t.id,filter:[`has`,`point_count`],paint:{"circle-color":{property:`point_count`,type:`interval`,stops:t.clusterCircleColor??[]},"circle-radius":{property:`point_count`,type:`interval`,stops:t.clusterCircleRadius??[]}}}),e.addLayer({id:`${t.id}-text-cluster`,type:`symbol`,source:t.id,filter:[`has`,`point_count`],paint:{"text-color":{property:`point_count`,type:`interval`,stops:t.clusterTextColor??[]}},layout:{"text-font":[`literal`,[bl]],"text-field":`{point_count_abbreviated}`,"text-size":{property:`point_count`,type:`interval`,stops:t.clusterTextSize??[]}}}),Sl(e,t))}function Sl(e,t){e.on(`click`,`${t.id}-circle-cluster`,async t=>{let n=e.queryRenderedFeatures(t.point).find(e=>e.properties.cluster);if(!n)return;let r=e.getSource(n.source);if(!r)return;let i=await r.getClusterExpansionZoom(Number(n.id));e.easeTo({center:n.geometry.coordinates,zoom:i})})}function Cl(e,t,n,r,i){let a=t.svg===void 0?void 0:i.getMapLibreImageKey(qr(t.dataBindings??{},r[t.svg],e.svg?r[e.svg]:void 0),window.devicePixelRatio*(t.iconScale??1));return{type:`Feature`,id:w(t.id),properties:{id:t.id,"mc-image-key":a,"icon-anchor":t.iconAnchor??`center`,"icon-rotate":t.iconRotation??0,"icon-offset":t.iconOffset??[0,0],"icon-size":(t.iconScale??1)*n,text:e.text||t.text?Kr(t.dataBindings??{},t.text,e.text):void 0,"text-anchor":t.textAnchor??`center`,"text-font":t.textFont,"text-offset":[(t.textOffset?.[0]??0)/(t.textSize??16),(t.textOffset?.[1]??0)/(t.textSize??16)],"text-rotate":t.textRotation??0,"text-max-width":t.textMaxWidth??10,"text-size":(t.textSize??16)*n,"text-color":e.textColor||t.textColor?Gr(t.dataBindings??{},t.textColor,e.textColor):`#000000`,"text-halo-color":e.textHaloColor||t.textHaloColor?Gr(t.dataBindings??{},t.textHaloColor,e.textHaloColor):`#000000`,"text-halo-width":t.textHaloWidth??0,"text-line-height":t.textLineHeight??1.2,"text-letter-spacing":t.textLetterSpacing??0,"text-justify":t.textJustify??`center`},geometry:{type:`Point`,coordinates:[t.lngLat.lng,t.lngLat.lat]}}}async function wl(e,t,n,r,i,a){let o=await Promise.all(t.map(e=>`${r}/styles/${e}.json?access_token=${i}`).map(e=>fetch(e).then(e=>e.json())));for(let t=0;t<e.length;t++){let n=e[t],r=o[t];for(let e of r.layers)e.metadata===void 0&&(e.metadata={}),e.metadata[`mc-original-layer-id`]=e.id,e.id=`${n} | ${e.id}`}return await Promise.all(o.map(e=>Tl(e,n,i,a))),o}async function Tl(e,t,n,r){for(let n in e.sources)t.getSource(n)===void 0&&t.addSource(n,e.sources[n]);e.sprite!==void 0&&await Dl(t,e.sprite,n);for(let n of e.layers){t.getLayer(n.id)!==void 0&&t.removeLayer(n.id);let e=n.metadata?.[`mc-add-before`]??`mc-before-none`;t.addLayer(El(n,r),e)}}function El(e,t){let n=t??{},r=e.metadata?.[`mc-original-layer-id`],i=r===void 0?{}:n[r]??{},a={...e,layout:{...e.layout,...i.layout},paint:{...e.paint,...i.paint},metadata:{...e.metadata,...i.metadata}};return i.minzoom!==void 0&&(a.minzoom=i.minzoom),i.maxzoom!==void 0&&(a.maxzoom=i.maxzoom),`filter`in i&&a.type!==`background`&&(a.filter=i.filter),a}async function Dl(e,t,n){try{let r=`${t}.json?access_token=${n}`,i=`${t}.png?access_token=${n}`,[a,o]=await Promise.all([fetch(r),fetch(i)]);if(!a.ok||!o.ok)throw Error(`Failed to load sprite from ${t}`);let s=await a.json(),c=await o.blob(),l=await new Promise((e,t)=>{let n=new Image;n.onload=()=>e(n),n.onerror=e=>t(e),n.src=URL.createObjectURL(c)}),u=document.createElement(`canvas`),d=u.getContext(`2d`,{willReadFrequently:!0});if(!d)throw Error(`Failed to get canvas context`);for(let[t,n]of Object.entries(s)){if(e.hasImage(t))continue;let{x:r,y:i,width:a,height:o,pixelRatio:s}=n;u.width=a*s,u.height=o*s,d.clearRect(0,0,u.width,u.height),d.drawImage(l,r,i,a,o,0,0,u.width,u.height);let c=d.getImageData(0,0,u.width,u.height);e.addImage(t,c,{pixelRatio:s})}}catch(e){console.error(e)}}var Ol=`<svg xmlns="http://www.w3.org/2000/svg" width="6" height="10" viewBox="0 0 6 10" fill="currentColor"><path d="m0 4.647 4.282 4.4a.814.814 0 0 0 1.166-1.134L2.27 4.647l3.178-3.266A.814.814 0 1 0 4.282.246z"/></svg>
1132
+ `,kl=`<svg xmlns="http://www.w3.org/2000/svg" width="10" height="11" viewBox="0 0 10 11" fill="currentColor"><path d="M.21.71a.714.714 0 0 1 1.011 0l3.78 3.78L8.778.71a.715.715 0 0 1 1.013 1.01L6.01 5.501l3.78 3.778a.715.715 0 0 1-1.01 1.012L5 6.51l-3.779 3.78A.716.716 0 0 1 .21 9.28L3.99 5.5.21 1.721A.714.714 0 0 1 .21.71"/></svg>
1133
+ `,Al=`<svg xmlns="http://www.w3.org/2000/svg" width="6" height="10" viewBox="0 0 6 10" fill="currentColor"><path d="m5.678 4.647-4.282 4.4A.814.814 0 1 1 .23 7.914l3.177-3.266L.23 1.381A.814.814 0 1 1 1.396.246z"/></svg>
1134
+ `,jl=`<svg width="20" height="20" viewBox="0 0 40 40" stroke="currentColor" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M20 4.167 1.667 35.834h36.667z" stroke-width="2" stroke-linejoin="round"/><path d="M20 29.167v.834m0-14.167.007 8.333" stroke-width="2" stroke-linecap="round"/></svg>
1135
+ `;function Ml(e,t){let{allowFullscreen:n,loop:r}=e,i=T(e.src,t),a,o=i.match(/(?:youtube\.com\/(?:watch\?.*v=|embed\/|v\/)|youtu\.be\/)([-\w]{11})/)?.[1];a=o?`https://www.youtube.com/embed/${o}`:i;let s=[];if(n||s.push(`fs=0`),r&&o&&s.push(`loop=1&playlist=${o}`),a=Pl(a),a=Nl(a),s.length){let e=a.includes(`?`)?`&`:`?`;a+=`${e}${s.join(`&`)}`}return a}function Nl(e){return e.replace(/([?&])si=[^&]+(&)?/,(e,t,n)=>t===`?`&&!n?``:t===`?`&&n?`?`:n?`&`:``)}function Pl(e){let t=new URL(e),n=t.searchParams.get(`t`);if(!n)return e;let r=0,i=/^((\d+)m)?((\d+)s)?$/;if(/^\d+$/.test(n))r=parseInt(n,10);else{let e=n.match(i);if(e){let t=parseInt(e[2]||`0`,10),n=parseInt(e[4]||`0`,10);r=t*60+n}}return r>0&&(t.searchParams.delete(`t`),t.searchParams.set(`start`,String(r))),t.toString()}function Fl(e,t,n,r){let i;if(t?.type===`video`)i=r===`preview`?Bl(t.src,n):`
1136
+ <div class="youtube-container">
1137
+ <iframe
1138
+ src="${Ml(t,n)}"
1139
+ width="100%" height="300" style="border: none" allowfullscreen>
1140
+ </iframe>
1141
+ </div>
1142
+ `;else if(t?.type===`image`){let e=T(t.src,n),r=T(t.alt,n);i=`
1143
+ <div class="image-container ${t.fill?`fill`:``}">
1144
+ <img src="${e}" alt="${r}" />
1145
+ </div>
1146
+ `}i=i?`<div class="media-content">${i}</div>`:``;let a=e?`<div class="text-content">${Rl(e,n)}</div>`:``;return`
1147
+ <div class="popup-scroll-wrapper">
1148
+ <div class="mc-popup">
1149
+ ${i}
1150
+ ${a}
1151
+ </div>
1152
+ </div>
1153
+ `}var Il=`
1154
+ <button class="mc-popup-button close">
1155
+ ${kl}
1156
+ </button>
1157
+ `,Ll=`
1158
+ <div class="cycle-buttons">
1159
+ <button class="mc-popup-button prev">
1160
+ ${Ol}
1161
+ </button>
1162
+ <button class="mc-popup-button next">
1163
+ ${Al}
1164
+ </button>
1165
+ </div>
1166
+ `;function Rl(e,t){return e?(e=e.replace(/placeholder="[^"]+"/,``),e=e.replace(/onerror="[^"]+"/,``),e=e.replace(/youtube\.com\/embed\/\$([^"'<>\\]+)/gi,(e,n)=>{let r=E(t[n]);return r?`youtube.com/embed/${O(r)}?`:``}),e=e.replace(/(\S+?)\s*=\s*"\$([^"]+?)"/g,(e,n,r)=>{let i=E(t[r]);return[`src`,`href`].includes(n)&&!i?``:[`src`,`href`].includes(n)?/^(mailto:|tel:|ftp:|data:|http:\/\/|https:\/\/)/i.test(i)?` ${n}="${i}"`:` ${n}="${zl(i)}"`:` ${n}="${i}"`}),e=e.replace(/>\$(.+?)</gi,(e,n)=>`>${E(t[n])}<`),e=e.replace(/<span\s+class="mention"\s+data-mention-id="[^"]*">(.*?)<\/span>/gim,(e,t)=>t),e):``}function zl(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}function Bl(e,t){return`
1167
+ <div class="youtube-placeholder">
1168
+ <img src="${`https://img.youtube.com/vi/${O(T(e,t))}/hqdefault.jpg`}" />
1169
+ <div class="popup-alert">
1170
+ <div class="alert-icon">${jl}</div>
1171
+ <div>${Vi(`videoAlert`)}</div>
1172
+ </div>
1173
+ </div>
1174
+ `}var Vl=[`area`,`circle`,`dot`,`line`,`marker`,`polygon`],Hl=class{data;customGroupIds;constructor(e){this.data={area:{},circle:{},dot:{},line:{},marker:{},polygon:{}};for(let t of Vl)for(let n of e.registry?.models?.[t]??[]){this.data[t][n.id]={};for(let e of n.models){if(t===`area`){let t=e;t.featureId===void 0&&(t.featureId=Number(t.id),t.id=`${t.vectorUrl}-${t.id}`)}this.data[t][n.id][e.id]=e}}let{beforeWaters:t=[],beforeBoundaries:n=[],beforeNames:r=[],beforeNone:i=[]}=e.registry?.slots??{};this.customGroupIds=[...t,...n,...r,...i].map(e=>e.groupId)}getModel(e){let t=String(e.properties?.id),n=e.layer.metadata,r=n?.[`mc-group-id`],i=n?.[`mc-model-type`],a=n?.[`mc-model-id-prefix`];if(a&&(t=`${a}-${t}`),!(r===void 0||t===void 0||i===void 0))return this.data[i]?.[r]?.[t]}getPopupElements(){let e=[],t=[`circle`,`dot`,`line`,`marker`,`polygon`];for(let n of this.customGroupIds)for(let r of t){let t=this.data[r]?.[n];if(t)for(let[r,i]of Object.entries(t))(i.popup||i.popupMedia)&&e.push({groupId:n,modelId:r,popup:i.popup,popupMedia:i.popupMedia,lngLat:i.lngLat,center:i.center,radius:i.radius,anchorPoints:i.anchorPoints,dataBindings:i.dataBindings})}return e.reverse()}},Ul=class{map;popupElements;markerLayerIds;resizeObserver;constructor(e,t){this.map=e,this.popupElements=t,this.markerLayerIds=this.map.getStyle().layers.filter(e=>e.id.startsWith(`custom-marker`)).filter(e=>!e.id.endsWith(`-cluster`)).map(e=>e.id)}highlight(e){if(this.deselect(),!e)return;let{groupId:t,modelId:n}=e,r=this.popupElements.filter(e=>e.groupId===t);r.length>1&&t.startsWith(`custom-marker`)&&this.highlightGroupedMarker(t,n,r),t.startsWith(`custom-marker`)&&this.fadeOtherMarkers(t),this.repositionMap(e)}deselect(){this.markerLayerIds.forEach(e=>{this.map.setPaintProperty(e,`icon-opacity`,1),this.map.setPaintProperty(e,`text-opacity`,1)}),this.resizeObserver?.disconnect()}highlightGroupedMarker(e,t,n){let r=this.markerLayerIds.find(t=>t.startsWith(e));r&&(this.map.setPaintProperty(r,`icon-opacity`,[`case`,[`boolean`,[`feature-state`,`highlighted`],!1],1,.3]),this.map.setPaintProperty(r,`text-opacity`,[`case`,[`boolean`,[`feature-state`,`highlighted`],!1],1,.3]),n.forEach(n=>{this.map.setFeatureState({source:e,id:w(n.modelId)},{highlighted:n.modelId===t})}))}fadeOtherMarkers(e){this.markerLayerIds.filter(t=>!t.startsWith(e)).forEach(e=>{this.map.setPaintProperty(e,`icon-opacity`,.3),this.map.setPaintProperty(e,`text-opacity`,.3)})}repositionMap(e){let t,n=20;e.lngLat===void 0?e.anchorPoints===void 0?e.center!==void 0&&e.radius!==void 0&&(t=this.getElementBounds(rr(e.center,e.radius))):t=this.getElementBounds(this.flattenCoordinates(e.anchorPoints)):(t=new u.LngLatBounds(e.lngLat,e.lngLat),n=40);let r=document.querySelector(`.popup-container`);if(!r||!t)return;this.resizeObserver?.disconnect();let i=0;this.resizeObserver=new ResizeObserver(e=>{let r=e[0].contentRect.height;r>i&&(i=r,this.panToElement(t,n))}),this.resizeObserver.observe(r)}getElementBounds(e){let t=new u.LngLatBounds(e[0],e[0]);for(let n of e)t.extend(n);return t}flattenCoordinates(e){return Array.isArray(e[0][0])?e.flat():e}panToElement(e,t){let n=this.map;if(n.getProjection()?.type===`globe`&&[e.getSouthWest(),e.getNorthEast(),e.getNorthWest(),e.getSouthEast()].some(e=>!this.visibleOnGlobe(e.lng,e.lat))){n.easeTo({center:e.getCenter(),duration:500});return}let r=n.projectWithScaleCorrection(e.getSouthWest()),i=n.projectWithScaleCorrection(e.getNorthEast()),a=n.getContainer().clientWidth,o=n.getContainer().clientHeight,s=a>600,c=document.querySelector(`.popup-container`)?.getBoundingClientRect(),l=c?.width??0,u=c?.height??0;s||(u=Math.min(u,o/2));let d=o-r.y>u+t,f=r.x>t+(s&&!d?l:0),p=i.x<a-t,m=i.y>t,h=s?r.y<o-t:d;if(!(f&&p&&m&&h))if(i.x-r.x+2*t<a&&r.y-i.y+2*t<o){let t=e.getCenter();n.easeTo({center:t,duration:500,offset:s?[0,0]:[0,-30]})}else n.fitBounds(e,{padding:t,maxZoom:n.getZoom(),duration:500,linear:!0})}visibleOnGlobe(e,t){let{lng:n,lat:r}=this.map.getCenter(),i=this.map.getPitch()*Math.PI/180,a=this.map.getBearing()*Math.PI/180,o=this.lngLatToUnitVector(n,r),s=this.lngLatToUnitVector(e,t),c=this.normalize(this.cross([0,0,1],o)),l=this.rotateAroundZ(c,a),u=this.rotateVectorAroundAxis(o,l,i);return u[0]*s[0]+u[1]*s[1]+u[2]*s[2]>.3}lngLatToUnitVector(e,t){let n=t*Math.PI/180,r=e*Math.PI/180;return[Math.cos(n)*Math.cos(r),Math.cos(n)*Math.sin(r),Math.sin(n)]}rotateVectorAroundAxis(e,t,n){let[r,i,a]=e,[o,s,c]=t,l=Math.cos(n),u=Math.sin(n),d=r*o+i*s+a*c;return[r*l+(s*a-c*i)*u+o*d*(1-l),i*l+(c*r-o*a)*u+s*d*(1-l),a*l+(o*i-s*r)*u+c*d*(1-l)]}rotateAroundZ(e,t){let[n,r,i]=e,a=Math.cos(t),o=Math.sin(t);return[n*a-r*o,n*o+r*a,i]}cross(e,t){let[n,r,i]=e,[a,o,s]=t;return[r*s-i*o,i*a-n*s,n*o-r*a]}normalize(e){let[t,n,r]=e,i=Math.hypot(t,n,r);return[t/i,n/i,r/i]}},Wl=class{map;popupPosition=`bottomLeft`;mapContainer;popupContainer;feature;currentFeatureId;currentModelId;popupElements=[];language=`en`;promoteIdCache=new Map;publication;floatingPopup;registry;highlightManager;mode;restrictMapMovement;center;constructor(e,t){this.map=e,this.mode=t,this.mapContainer=this.map.getContainer(),this.popupContainer=document.createElement(`div`),this.popupContainer.classList.add(`popup-container`),this.map.on(`mousemove`,e=>this.onMouseMove(e)),this.map.on(`click`,e=>this.onClick(e))}setJobObject(e){this.registry=new Hl(e)}setParams(e,t,n,r){this.popupPosition=e,this.language=t,this.restrictMapMovement=n,this.center=r}setPublication(e){this.publication=e}setpopupElements(){this.popupElements=this.registry.getPopupElements()}setHighlightManager(){this.highlightManager=new Ul(this.map,this.registry.getPopupElements())}onMouseMove(e){this.feature=this.getInteractiveFeature(e),this.feature?this.map.getCanvas().style.cursor=`pointer`:this.map.getCanvas().style.cursor=``}onClick(e){this.feature=this.getInteractiveFeature(e),this.currentModelId=this.feature?.properties?.id,this.feature&&(!this.mapContainer.contains(this.popupContainer)||this.feature?.id!==this.currentFeatureId)?(this.addPopup(e),this.highlightManager?.highlight(this.getPopupElementFromFeature(this.feature))):(this.hidePopup(),this.highlightManager?.highlight(void 0))}getPopupElementFromFeature(e){return this.popupElements.find(t=>t.modelId===e.properties.id)}getInteractiveFeature(e){return this.map.queryRenderedFeatures(e.point).find(e=>{if(Object.keys(e.layer.metadata??{}).some(e=>e.startsWith(`mc-interactivity-template`)))return!0;let t=this.registry.getModel(e);return!!(t?.popup??t?.popupMedia)})}addPopup(e){if(!this.feature)return;this.floatingPopup?.remove();let t=Number(this.feature.id);this.currentFeatureId=isNaN(t)?this.feature.id:t;let n=this.getTemplate(this.feature);if(n){if(this.popupPosition===`mapElement`){if(this.feature.geometry.type===`Point`)this.addFloatingPopup(n,this.feature.geometry.coordinates);else{let{lng:t,lat:r}=this.map.unprojectWithScaleCorrection(e.point);this.addFloatingPopup(n,[t,r])}return}this.popupContainer.innerHTML=n,this.popupElements.find(e=>e.modelId===this.currentModelId)&&this.addPopupControls(),this.mapContainer.appendChild(this.popupContainer)}}addFloatingPopup(e,t){let n=this.restrictMapMovement?this.getAnchor(t):void 0;this.floatingPopup=new u.Popup({maxWidth:`none`,closeButton:!1,offset:20,...n!==void 0&&{anchor:n}}).setLngLat(t).setHTML(e).addTo(this.map)}getAnchor(e){let t=this.map.projectWithScaleCorrection(e),n=this.map.getContainer().clientWidth,r=this.map.getContainer().clientHeight,i,a;return i=t.y<r*.33?`top`:t.y>r*.66?`bottom`:`center`,a=t.x<n*.33?`left`:t.x>n*.66?`right`:`center`,i===`center`&&a===`center`?`bottom`:i===`center`?a:a===`center`?i:`${i}-${a}`}hidePopup(){this.popupContainer&&(this.popupContainer.remove(),this.feature=void 0,this.currentFeatureId=void 0),this.restrictMapMovement&&this.center&&this.map.easeTo({center:this.center})}getTemplate(e){let{layer:t}=e,n,r=this.registry.getModel(e);if(r?.popup||r?.popupMedia)n=Fl(r.popup,r.popupMedia,r.dataBindings??{},this.mode);else{let r=[];this.publication&&(r.push(`:${this.publication}-${this.language}`),r.push(`:${this.publication}-:en`)),r.push(`:${this.language}`),r.push(`:en`),r.push(``);for(let i of r){let r=t.metadata?.[`mc-interactivity-template${i}`];if(r){n=this.fillDatalayerTemplate(e,r,i);break}}n&&=`
1175
+ <div class="popup-scroll-wrapper">
1176
+ <div class="mc-popup data-layer text-content">${n}</div>
1177
+ </div>
1178
+ `}return n}htmlToElement(e){let t=document.createElement(`template`);return t.innerHTML=e.trim(),t.content.firstElementChild}addPopupControls(){let e=this.htmlToElement(Il);if(e&&(e.addEventListener(`click`,()=>{this.hidePopup(),this.highlightManager.highlight(void 0)}),this.popupContainer.appendChild(e)),this.popupElements.length<2)return;let t=this.htmlToElement(Ll);t&&(t.querySelector(`.prev`)?.addEventListener(`click`,()=>this.cyclePopups(!1)),t.querySelector(`.next`)?.addEventListener(`click`,()=>this.cyclePopups()),this.popupContainer.appendChild(t))}fillDatalayerTemplate(e,t,n){let r=`data-mention-id`,i=new DOMParser().parseFromString(t,`text/html`).body;for(let t of i.querySelectorAll(`[${r}]`)){let i=this.getProperty(e,t.getAttribute(r),n);i!==void 0&&(t.innerText=i)}return i.innerHTML}getProperty(e,t,n){if(!t)return;let r=t.endsWith(`:en`)?[t.replace(`:en`,n),t]:[t];for(let t of r){let n=e.properties[t]??this.getVectorProperty(e,t);if(n!==void 0)return n}}getVectorProperty(e,t){let n=this.promoteIdCache.get(e.source);n===void 0&&(n=this.map.getSource(e.source)?.serialize().promoteId||`id`,this.promoteIdCache.set(e.source,n));try{let r=e.properties[n];return e.layer.metadata.properties[t][r]}catch{return}}cyclePopups(e=!0){let t=this.popupElements?.findIndex(e=>e.modelId===this.currentModelId);if(t!==-1){let n=0;n=e?t===this.popupElements.length-1?0:t+1:t===0?this.popupElements.length-1:t-1;let r=this.popupElements?.[n];this.highlightManager.highlight(r);let i=Fl(r.popup,r.popupMedia,r.dataBindings??{},this.mode),a=this.popupContainer;this.popupContainer.remove(),a.innerHTML=i,this.mapContainer.appendChild(a),this.currentModelId=r.modelId,this.addPopupControls(),e?this.popupContainer.querySelector(`.mc-popup-button.next`)?.focus():this.popupContainer.querySelector(`.mc-popup-button.prev`)?.focus(),this.currentFeatureId=void 0}}},Gl=class e{static#e(e){let t=0,n=[t];for(let r=1;r<e.length;++r){let i=e[r-1],a=e[r],o=a.x-i.x,s=a.y-i.y;t+=Math.sqrt(o*o+s*s),n.push(t)}return n}static#t(e,t){return e.x===t.x&&e.y===t.y}#n;#r;#i;#a;constructor(t){this.#n=t.filter((e,n)=>n===0||t[n][0]!==t[n-1][0]||t[n][1]!==t[n-1][1]),this.#r=this.#n.map(e=>u.MercatorCoordinate.fromLngLat(e)),this.#i=e.#e(this.#r),this.#a=this.#i[this.#i.length-1]}sample(e){let t=this.#r,n=this.#i;if(t.length<2)return t[0];e*=this.#a;for(let r=1;r<t.length;++r){let i=t[r-1],a=t[r],o=n[r-1],s=n[r];if(s>=e){let t=(e-o)/(s-o);return new u.MercatorCoordinate(j(i.x,a.x,t),j(i.y,a.y,t))}}return new u.MercatorCoordinate(t[t.length-1].x,t[t.length-1].y)}slice(t,n){if(this.#n.length<2)return this.#n;let r=this.#r.filter((e,r)=>this.#i[r]>=t*this.#a&&this.#i[r]<=n*this.#a);if(t>0){let n=this.sample(t);e.#t(n,r[0])||r.unshift(n)}if(n<1){let t=this.sample(n);e.#t(t,r[r.length-1])||r.push(t)}return r.map(e=>{let{lng:t,lat:n}=e.toLngLat();return[t,n]})}get length(){return this.#a}},Kl={solid:[1,0],dotted:[.7,.3],dashed:[3.5,1.5]};function ql(e,t,n,r){e.addSource(t.id,{type:`geojson`,data:{type:`FeatureCollection`,features:t.models.filter(e=>e.visible??!0).map(n=>Jl(e,t,n,1,r))}}),Object.entries(Kl).forEach(([r,i])=>{t.models.some(e=>(e.lineStyle??`solid`)===r)&&e.addLayer({id:`${t.id}-${r}`,type:`line`,source:t.id,metadata:{"mc-model-type":`line`,"mc-group-id":t.id},filter:[`all`,[`==`,[`geometry-type`],`LineString`],[`==`,[`get`,`line-style`],r]],paint:{"line-width":[`get`,`line-width`],"line-color":[`get`,`line-color`],"line-dasharray":i,"line-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]}},n)}),e.addLayer({id:`${t.id}-clickable`,type:`line`,source:t.id,metadata:{"mc-model-type":`line`,"mc-group-id":t.id},paint:{"line-width":[`max`,[`get`,`line-width`],15],"line-opacity":0},filter:[`==`,[`geometry-type`],`LineString`]},n),t.models.some(e=>e.svg)&&e.addLayer({id:`${t.id}-icon`,type:`symbol`,source:t.id,metadata:{"mc-model-type":`line`,"mc-group-id":t.id},layout:{"icon-allow-overlap":!0,"icon-ignore-placement":!0,"icon-image":[`get`,`mc-image-key`],"icon-anchor":`center`,"icon-size":[`get`,`icon-size`],"icon-rotate":[`get`,`icon-rotate`],"icon-offset":[`get`,`icon-offset`]},paint:{"icon-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]},filter:[`==`,[`geometry-type`],`Point`]},n)}function Jl(e,t,n,r,i){let a=new Gl(n.geometry).slice(0,r),o=n.svg===void 0?void 0:i.getMapLibreImageKey(qr(n.dataBindings??{},n.svg,void 0),window.devicePixelRatio*(n.iconScale??1));return{type:`Feature`,id:w(n.id),properties:{id:n.id,"line-width":n.lineWidth??3,"line-color":t.lineColor||n.lineColor?Gr(n.dataBindings??{},n.lineColor,t.lineColor):`#000000`,"line-style":n.lineStyle??`solid`,"mc-image-key":o,"icon-rotate":Yl(n,a,e),"icon-offset":n.iconOffset,"icon-size":n.iconScale},geometry:{type:`GeometryCollection`,geometries:[{type:`LineString`,coordinates:a},{type:`Point`,coordinates:a[a.length-1]}]}}}function Yl(e,t,n){return e.iconRotation?e.iconAlign?fr(t,n)+e.iconRotation:e.iconRotation:0}function Xl(e,t,n,r,i,a,o){let s=yr(t),c=new Map,l=new Map;for(let e of t.models){let n=e.featureId,a=t.id,o=[],u=ur(e),d=lr(a,e),f=l.get(d)??{model:e,featureIds:o,modelIdToFillColor:{},modelIdToFillPattern:{},modelIdToOutlineColor:{},modelIdToOutlineWidth:{}};if(e.visible??!0){f.featureIds.push(n);let a=e.fillPattern===void 0?null:i.getMapLibreImageKey(r[e.fillPattern],2*window.devicePixelRatio);f.modelIdToFillColor[n]=t.fillColor||e.fillColor?Gr(e.dataBindings??{},e.fillColor,t.fillColor,s,t.choropleth?.unmatchedColor):`#000000`,f.modelIdToFillPattern[n]=a,f.modelIdToOutlineColor[n]=t.outlineColor||e.outlineColor?Gr(e.dataBindings??{},e.outlineColor,t.outlineColor):`#000000`,f.modelIdToOutlineWidth[n]=e.outlineWidth??.5}c.set(u,e),l.set(d,f)}for(let t of c.keys())e.getSource(t)||e.addSource(t,{type:`vector`,url:`${a}${c.get(t).vectorUrl}?access_token=${o}`});for(let r of l.keys()){let{model:i}=l.get(r),{sourceLayerId:a}=i,o=ur(i);e.addLayer({id:r,type:`fill`,source:o,"source-layer":a,filter:[`literal`,!1],metadata:{"mc-model-type":`area`,"mc-model-id-prefix":i.vectorUrl,"mc-group-id":t.id},paint:{"fill-color":`#ffffff`,"fill-outline-color":`#000000`,"fill-antialias":!1}},n),e.addLayer({id:`${r}-pattern`,type:`fill`,source:o,"source-layer":a,filter:[`literal`,!1],metadata:{"mc-model-type":`area`,"mc-model-id-prefix":i.vectorUrl,"mc-group-id":t.id},paint:{"fill-pattern":[`get`,`fill-pattern`]},layout:{visibility:`visible`}},n),e.addLayer({id:`${r}-outline`,type:`line`,source:o,"source-layer":a,filter:[`literal`,!1],metadata:{"mc-model-type":`area`,"mc-model-id-prefix":i.vectorUrl,"mc-group-id":t.id},paint:{"line-color":`#000000`,"line-width":.5}},n)}l.forEach((t,n)=>{let{featureIds:r,modelIdToFillColor:i,modelIdToFillPattern:a,modelIdToOutlineColor:o,modelIdToOutlineWidth:s}=t;e.setFilter(n,[`in`,`id`,...r]),e.setFilter(`${n}-outline`,[`in`,`id`,...r]),e.setPaintProperty(n,`fill-color`,[`get`,[`case`,[`==`,[`typeof`,[`get`,`id`]],`number`],[`to-string`,[`get`,`id`]],[`get`,`id`]],[`literal`,i]]),e.setPaintProperty(`${n}-outline`,`line-color`,[`get`,[`case`,[`==`,[`typeof`,[`get`,`id`]],`number`],[`to-string`,[`get`,`id`]],[`get`,`id`]],[`literal`,o]]),e.setPaintProperty(`${n}-outline`,`line-width`,[`get`,[`case`,[`==`,[`typeof`,[`get`,`id`]],`number`],[`to-string`,[`get`,`id`]],[`get`,`id`]],[`literal`,s]]),e.setFilter(`${n}-pattern`,[`to-boolean`,[`get`,[`case`,[`==`,[`typeof`,[`get`,`id`]],`number`],[`to-string`,[`get`,`id`]],[`get`,`id`]],[`literal`,a]]]),e.setPaintProperty(`${n}-pattern`,`fill-pattern`,[`get`,[`case`,[`==`,[`typeof`,[`get`,`id`]],`number`],[`to-string`,[`get`,`id`]],[`get`,`id`]],[`literal`,a]])})}function Zl(e,t,n){e.addSource(t.id,{type:`geojson`,data:{type:`FeatureCollection`,features:t.models.filter(e=>e.visible??!0).map(e=>Ql(t,e))}}),e.addLayer({id:t.id,type:`circle`,source:t.id,metadata:{"mc-model-type":`dot`,"mc-group-id":t.id},paint:{"circle-color":[`get`,`circle-color`],"circle-radius":[`get`,`circle-radius`],"circle-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]}},n)}function Ql(e,t){return{type:`Feature`,id:t.id,properties:{id:t.id,"circle-radius":t.radius,"circle-color":e.fillColor||t.fillColor?Gr(t.dataBindings??{},t.fillColor,e.fillColor):`#000000`},geometry:{type:`Point`,coordinates:[t.center.lng,t.center.lat]}}}function $l(e,t,n,r){return t+n/r*e}function eu(e,t,n,r){return n*((e=e/r-1)*e*e+1)+t}function tu(e,t,n,r){let i=1.70158,a=0,o=n;return e===0?t:(e/=r)===1?t+n:(a||=r*.3,o<Math.abs(n)?(o=n,i=a/4):i=a/(2*Math.PI)*Math.asin(n/o),o*2**(-10*e)*Math.sin((e*r-i)*(2*Math.PI)/a)+n+t)}function nu(e,t,n,r,i){return i===void 0&&(i=1.70158),n*((e=e/r-1)*e*((i+1)*e+i)+1)+t}function ru(e,t,n,r){return(e/=r)<1/2.75?n*(7.5625*e*e)+t:e<2/2.75?n*(7.5625*(e-=1.5/2.75)*e+.75)+t:e<2.5/2.75?n*(7.5625*(e-=2.25/2.75)*e+.9375)+t:n*(7.5625*(e-=2.625/2.75)*e+.984375)+t}var iu={linear:$l,easeOutCubic:eu,easeOutBack:nu,easeOutBounce:ru,easeOutElastic:tu};function au(e){return e.entryType===`fade`||e.exitType===`fade`||e.entryType===`instant`||e.exitType===`instant`}function ou(e){return e.entryType===`grow`||e.exitType===`grow`}function su(e,t,n){let{entry:r,entryDuration:i,exit:a,exitDuration:o}=e,{entryType:s,entryEasing:c,exitType:l,exitEasing:u}=e;return n<r&&(s===t||s===`instant`&&t===`fade`)||n>a&&(l===t||l===`instant`&&t===`fade`)?0:i>0&&n<r+i&&s===t?iu[c](n-r,0,1,i):o>0&&n>a-o&&l===t?iu[u](n-(a-o),1,-1,o):1}function cu(e){let t=e.length>0?[lu(e[0])]:[],n=0,r=0;for(let i=1;i<e.length;++i){let a=lu(e[i]);n+=uu(e[i-1].center[0],a.center[0]),r+=uu(e[i-1].bearing,a.bearing),a.center[0]+=n*360,a.x+=n,a.bearing+=r*360,t.push(a)}return t}function lu(e){return{...e,center:[e.center[0],e.center[1]]}}function uu(e,t){if(Math.abs(e)+Math.abs(t)>180){if(e>0&&t<0)return 1;if(e<0&&t>0)return-1}return 0}function du(e){return 2**-e}function fu(e){return e.length>0?e[e.length-1].time:0}function pu(e){return te(e,23.976)?24e3/1001:te(e,29.97)?3e4/1001:te(e,59.94)?6e4/1001:e}function mu(e){return e<0?-1:1}function hu(e,t,n){var r=e._x1-e._x0,i=t-e._x1,a=(e._y1-e._y0)/(r||i<0&&-0),o=(n-e._y1)/(i||r<0&&-0),s=(a*i+o*r)/(r+i);return(mu(a)+mu(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(s))||0}function gu(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function _u(e,t,n){var r=e._x0,i=e._y0,a=e._x1,o=e._y1,s=(a-r)/3;e._context.bezierCurveTo(r+s,i+s*t,a-s,o-s*n,a,o)}function vu(e){this._context=e}vu.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:_u(this,this._t0,gu(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,_u(this,gu(this,n=hu(this,e,t)),n);break;default:_u(this,this._t0,n=hu(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function yu(e){this._context=new bu(e)}(yu.prototype=Object.create(vu.prototype)).point=function(e,t){vu.prototype.point.call(this,t,e)};function bu(e){this._context=e}bu.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,r,i,a){this._context.bezierCurveTo(t,e,r,n,a,i)}};function xu(e){return new vu(e)}function Su(e){return e}var{cbrt:Cu,sqrt:wu,PI:Tu}=Math,Eu=(e,t,n,r,i)=>{let a=t+n*e,o=a**2+r;if(o>0){let e=wu(o);return Cu(a+e)+Cu(a-e)-i}let s=Cu(wu(a*a-o)),c=a?Math.atan(wu(-o)/a):-Tu/2,l;return l=n<0?(a>0?2*Tu:Tu)-c:i<0?(a>0?2*Tu:-3*Tu)+c:(a>0?0:Tu)+c,2*s*Math.cos(l/3)-i},Du=(e,t,n,r)=>((t*e+3*n)*e+r)*e;function Ou(e,t,n,r){if(!(0<=e&&e<=1&&0<=n&&n<=1))throw Error(`bezier x values must be in [0, 1] range`);if(e===t&&n===r)return Su;let i=6*(3*e-3*n+1),a=6*(n-2*e),o=3*e,s=i*i,c=a*a,l=a/i,u=3*a*o/s-c*a/(s*i),d=2*o/i-c/s,f=d*d*d,p=3/i,m=3*t-3*r+1,h=r-2*t,g=3*t,_=i?Eu:Su;return function(e){return e===0||e===1?e:Du(_(e,u,p,f,l),m,h,g)}}var ku=l(s(((e,t)=>{t.exports=n;function n(e,t,n,r){var i,a,o,s,c,l,u,d,f,p,m,h,g,_;for(typeof t!=`function`&&(r=n,n=t,t=null),r||={},s=r.tolerance===void 0?1e-7:r.tolerance,_=r.epsilon===void 0?2220446049250313e-31:r.epsilon,c=r.maxIterations===void 0?20:r.maxIterations,m=r.h===void 0?1e-4:r.h,g=r.verbose===void 0?!1:r.verbose,h=1/m,l=0;l++<c;){if(a=e(n),t?o=t(n):(u=e(n+m),d=e(n-m),f=e(n+2*m),p=e(n-2*m),o=(p-f+8*(u-d))*h/12),Math.abs(o)<=_*Math.abs(a))return g&&console.log(`Newton-Raphson: failed to converged due to nearly zero first derivative`),!1;if(i=n-a/o,Math.abs(i-n)<=s*Math.abs(i))return g&&console.log(`Newton-Raphson: converged to x = `+i+` after `+l+` iterations`),i;n=i}return g&&console.log(`Newton-Raphson: Maximum iterations reached (`+c+`)`),!1}}))(),1),Au=class{segments;constructor(e){this.segments=[];let t=new ju,n=xu(t);n.lineStart();for(let t of e)n.point(t.x,t.y);n.lineEnd(),this.segments=t.segments}sample(e){if(e<=0)return this.segments[0].startY;if(e>=this.segments[this.segments.length-1].endX)return this.segments[this.segments.length-1].endY;let t=this.segments.find(t=>e>=t.startX&&e<t.endX),n=M(t.startX,t.endX,e);return t.startY!==t.endY&&t.easing!==void 0?j(t.startY,t.endY,t.easing(n)):j(t.startY,t.endY,n)}solve(e,t){let n=(0,ku.default)(t=>this.sample(t)-e,t);return n===!1?t:n}},ju=class{previousPoint={x:0,y:0};segments=[];bezierCurveTo(e,t,n,r,i,a){let o=this.previousPoint.x,s=this.previousPoint.y,c=i===o?void 0:Ou((e-o)/(i-o),(t-s)/(a-s),(n-o)/(i-o),(r-s)/(a-s));this.segments.push({startX:o,endX:i,startY:s,endY:a,easing:c}),this.previousPoint={x:i,y:a}}lineTo(e,t){this.segments.push({startX:this.previousPoint.x,endX:e,startY:this.previousPoint.y,endY:t,easing:void 0}),this.previousPoint={x:e,y:t}}moveTo(e,t){this.previousPoint={x:e,y:t}}closePath(){}arc(){}rect(){}arcTo(){}quadraticCurveTo(){}},Mu=class{script;xCurve;yCurve;fovCurve;zoomCurve;pitchCurve;bearingCurve;altitudeCurve;elevationCurve;constructor(e){this.script=cu(e),this.xCurve=this.createMonotonicCurve(this.script,`x`),this.yCurve=this.createMonotonicCurve(this.script,`y`),this.fovCurve=this.createMonotonicCurve(this.script,`fov`),this.zoomCurve=this.createMonotonicCurve(this.script,`zoom`),this.pitchCurve=this.createMonotonicCurve(this.script,`pitch`),this.bearingCurve=this.createMonotonicCurve(this.script,`bearing`),this.altitudeCurve=this.createMonotonicCurve(this.script,`altitude`),this.elevationCurve=this.createMonotonicCurve(this.script,`elevation`)}sample(e){let t=this.zoomCurve.sample(e),n=this.altitudeCurve.solve(du(t),e),r=this.xCurve.sample(n),i=this.yCurve.sample(n),a=this.elevationCurve.sample(n),o=this.bearingCurve.sample(e),s=this.pitchCurve.sample(e),c=this.fovCurve.sample(e);return{center:new u.MercatorCoordinate(r,i).toLngLat(),zoom:t,bearing:o,pitch:s,fov:c,elevation:a}}createMonotonicCurve(e,t){let n=[];for(let r=0;r<e.length;r++){let i=r===0,a=r===e.length-1,o=e[r],s=e[r+1],c=e[r-1],l=this.getKeyframeValue(o,t);if(i&&n.push({x:-1,y:l}),n.push({x:o.time,y:l}),!i&&!a&&c.transition===`instant`&&o.transition===`ease`&&n.push({x:o.time+.1,y:l}),!a)if(o.transition===`linear`){let e=o.time+.1,r=s.time-.1,i=M(o.time,s.time,e),a=M(o.time,s.time,r),c=this.getKeyframeValue(s,t);n.push({x:e,y:j(l,c,i)}),n.push({x:r,y:j(l,c,a)})}else o.transition===`instant`&&(n.push({x:o.time+.1,y:l}),n.push({x:s.time-.1,y:l}));a&&n.push({x:o.time+1,y:l})}return new Au(n)}sampleAutoHideOpacity(e){let t=this.script;if(t.length<2)return 1;let n=this.getKeyframeIndexByTime(e);if(n===-1||n===t.length-1)return 1;let r=t[n],i=t[n+1],a=n>0?t[n-1]:void 0,o;if(r.hideLabels===(a?.hideLabels??!1))o=r.hideLabels?0:1;else{let t=e-r.time,n=Math.min(400,i.time-r.time);o=N(eu(t,r.hideLabels?1:0,r.hideLabels?-1:1,n),0,1)}let s;if(n===t.length-2&&r.hideLabels){let t=Math.max(r.time,i.time-400);s=N(eu(e-t,0,1,i.time-t),0,1)}else s=0;return Math.max(o,s)}getKeyframeIndexByTime(e){let t=this.script;if(t.length!==0){for(let n=0;n<t.length;n++)if(e<t[n].time)return n-1;return t.length-1}}getKeyframeValue(e,t){return t===`altitude`?du(e.zoom):e[t]}},Nu=Pu;function Pu(e,t,n){var r=null,i=null,a=function(){r&&=(clearTimeout(r),i=null,null)},o=function(){var e=i;a(),e&&e()},s=function(){if(!t)return e.apply(this,arguments);var o=this,s=arguments,c=n&&!r;if(a(),i=function(){e.apply(o,s)},r=setTimeout(function(){if(r=null,!c){var e=i;return i=null,e()}},t),c)return i()};return s.cancel=a,s.flush=o,s}var Fu=class{mcMap;cameraCurve;jobObject;svgs;svgCache;duration;mapstyle;overlays;layerInfo;playhead;playbackContext;constructor(e,t,n,r,i,a,o){this.mcMap=e,this.playhead=0,this.playbackContext=void 0;let s=(t.video?.keyframes??[]).map(e=>{let{x:t,y:n}=u.MercatorCoordinate.fromLngLat(e.center);return{...e,x:t,y:n,fov:e.fov??36.87,elevation:e.elevation??0}});this.duration=fu(s),this.cameraCurve=new Mu(s),this.jobObject=t,this.svgs=n,this.svgCache=r,this.mapstyle=i,this.overlays=a,this.layerInfo=o}play(){this.playbackContext===void 0&&this.duration>0&&(this.playhead>=this.duration&&(this.playhead=0),this.playbackContext={startTime:Date.now(),startPlayhead:this.playhead},this.mcMap.fire(`playstart`,{time:this.playhead}),this.playFrame())}pause(){this.playbackContext!==void 0&&(this.playbackContext=void 0,this.mcMap.fire(`playend`,{time:this.playhead}))}seekTo(e){this.duration>0&&(e=N(e,0,this.duration),this.prepareForPlayback(),this.setCamera(e),this.playbackContext!==void 0&&(this.playbackContext={startTime:Date.now(),startPlayhead:e}))}async*frames(){let e=this.mcMap.map,t=pu(this.jobObject.export?.frameRate??60),n=Math.ceil(this.duration*t/1e3);e._fadeDuration=0,e.style.stylesheet.transition={duration:0,delay:0},e.setCenterClampedToGround(!1);let r=e.getCanvas(),{width:i,height:a}=r,o=new OffscreenCanvas(i,a).getContext(`2d`,{desynchronized:!0,willReadFrequently:!0}),s=e.getContainer(),c=s.getBoundingClientRect();for(let e=0;e<n;e++)yield this.captureFrame(e*1e3/t,r,o,i,a,s,c);e._fadeDuration=300,e.style.stylesheet.transition=void 0,e.setCenterClampedToGround(!0)}async captureFrame(e,t,n,r,i,a,o){return this.setCamera(e),await this.mcMap.map.once(`idle`),n.fillStyle=`#ffffff`,n.fillRect(0,0,r,i),n.drawImage(t,0,0),await this.drawAdornments(n,a,o),n.getImageData(0,0,r,i)}async drawAdornments(e,t,n){let r=t.querySelectorAll(`.adornment-svg`),i=await Promise.all(Array.from(r).map(async e=>{let t=e.outerHTML,r=e.getBoundingClientRect(),i=r.left-n.left,a=r.top-n.top,o=r.width,s=r.height;return{image:await Ar(t,o,s),x:i,y:a}}));for(let t of i)e.drawImage(t.image,t.x,t.y)}playFrame(){if(this.playbackContext!==void 0){let e=this.playbackContext.startPlayhead+(Date.now()-this.playbackContext.startTime);this.prepareForPlayback(),e>this.duration?(this.setCamera(this.duration),this.playbackContext=void 0,this.mcMap.fire(`playend`,{time:this.playhead})):(this.setCamera(e),requestAnimationFrame(()=>this.playFrame()))}}setCamera(e){this.playhead=e;let t=this.mcMap.map,n=this.cameraCurve.sample(e),r=t.getCenter(),i=t.getZoom(),a=t.getBearing(),o=t.getPitch(),s=t.getCenterElevation(),c=t.getVerticalFieldOfView();n.center.lat!==r.lat||n.center.lng!==r.lng||n.zoom!==i||n.bearing!==a||n.pitch!==o||n.elevation!==s||n.fov!==c?(t.setVerticalFieldOfView(n.fov),t.jumpTo(n)):t.triggerRepaint(),this.applyAnimations(e),this.mcMap.fire(`play`,{time:e})}applyAnimations(e){let t=this.mcMap.map,{svgs:n,svgCache:r}=this,i=this.jobObject.video?.animations??[];for(let n of i){let{target:r}=n;if(r.type===`model`&&au(n)){let{modelType:i,groupId:a,modelId:o}=r,s=su(n,`fade`,e);(i===`polygon`||i===`circle`||i===`line`||i===`marker`||i===`dot`)&&(o===void 0?t.setGlobalStateProperty(`opacity-${a}`,s===1?null:s):t.setFeatureState({source:a,id:w(o)},{opacity:s}))}}for(let n of this.jobObject.registry?.models?.area??[]){let{groupAnimation:r,modelAnimations:a}=this.getGroupAnimations(i,`area`,n.id,`opacity`);if(!(r===void 0&&a.size===0))if(r!==void 0&&a.size===0){let i=su(r,`fade`,e);n.models.reduce((e,t)=>e.add(lr(n.id,t)),new Set).forEach(e=>{t.setPaintProperty(e,`fill-opacity`,i),t.setPaintProperty(`${e}-outline`,`line-opacity`,i),t.setPaintProperty(`${e}-pattern`,`fill-opacity`,i)})}else{let i=r===void 0?1:su(r,`fade`,e),o={};for(let t of n.models){let r=t.featureId===void 0?t.id:String(t.featureId),s=lr(n.id,t),c=a.get(t.id),l=c===void 0?i:su(c,`fade`,e);o[s]??={},o[s][r]=l}for(let[e,n]of Object.entries(o)){let r=[`get`,[`case`,[`==`,[`typeof`,[`get`,`id`]],`number`],[`to-string`,[`get`,`id`]],[`get`,`id`]],[`literal`,n]];t.setPaintProperty(e,`fill-opacity`,r),t.setPaintProperty(`${e}-outline`,`line-opacity`,r),t.setPaintProperty(`${e}-pattern`,`fill-opacity`,r)}}}for(let a of this.jobObject.registry?.models?.circle??[]){let{groupAnimation:o,modelAnimations:s}=this.getGroupAnimations(i,`circle`,a.id,`scale`),c=o===void 0?1:su(o,`grow`,e);(o!==void 0||s.size>0)&&t.getSource(a.id).setData({type:`FeatureCollection`,features:a.models.filter(e=>e.visible??!0).map(t=>{let i=s.get(t.id);return yl(a,t,i===void 0?c:su(i,`grow`,e),n,r)})})}for(let n of this.jobObject.registry?.models?.line??[]){let{groupAnimation:a,modelAnimations:o}=this.getGroupAnimations(i,`line`,n.id,`scale`),s=a===void 0?1:su(a,`grow`,e);(a!==void 0||o.size>0)&&t.getSource(n.id).setData({type:`FeatureCollection`,features:n.models.filter(e=>e.visible??!0).map(i=>{let a=o.get(i.id);return Jl(t,n,i,a===void 0?s:su(a,`grow`,e),r)})})}for(let a of this.jobObject.registry?.models?.marker??[]){let{groupAnimation:o,modelAnimations:s}=this.getGroupAnimations(i,`marker`,a.id,`scale`),c=o===void 0?1:su(o,`grow`,e);(o!==void 0||s.size>0)&&t.getSource(a.id).setData({type:`FeatureCollection`,features:a.models.filter(e=>e.visible??!0).map(t=>{let i=s.get(t.id);return Cl(a,t,i===void 0?c:su(i,`grow`,e),n,r)})})}let a=this.cameraCurve.sampleAutoHideOpacity(e);for(let t of this.mapstyle.layers){let n=this.getLayerOpacity(i,t,e,void 0);n===void 0?t.type===`symbol`&&this.setLayerOpacity(t,a):this.setLayerOpacity(t,n)}for(let[t,n]of this.overlays)for(let r of n.layers){let n=this.getLayerOpacity(i,r,e,t);n===void 0?this.resetLayerOpacity(r):this.setLayerOpacity(r,n)}}prepareForPlayback(){let e=this.mcMap.map;e.setCenterClampedToGround(!1),e.style?.stylesheet&&(e.style.stylesheet.transition={duration:0,delay:0}),this.restoreAfterPlayback()}restoreAfterPlayback=Nu(()=>{let e=this.mcMap.map;e.setCenterClampedToGround(!0),e.style?.stylesheet&&(e.style.stylesheet.transition=void 0)},300);getGroupAnimations(e,t,n,r){let i,a=new Map;for(let o of e){let{target:e}=o;e.type===`model`&&e.modelType===t&&e.groupId===n&&(r===`opacity`&&au(o)||r===`scale`&&ou(o))&&(e.modelId===void 0?i=o:a.set(e.modelId,o))}return{groupAnimation:i,modelAnimations:a}}getLayerOpacity(e,t,n,r){let i,a,o=1/0;r!==void 0&&(i=e.find(e=>e.target.type===`overlay`&&e.target.id===r));for(let n of e){let{target:e}=n;e.type===`layer`&&e.ids.includes(t.id)&&e.ids.length<o&&(a=n,o=e.ids.length)}let s=this.layerInfo[t.id]?.opacity??1;return a===void 0?i===void 0?void 0:su(i,`fade`,n)*s:su(a,`fade`,n)*s}setLayerOpacity(e,t){let n=this.mcMap.map,r=m[e.type];if(r){for(let i of r.props)n.setPaintProperty(e.id,i,t*r.defaultValue);n.setLayoutProperty(e.id,`visibility`,t===0?`none`:this.layerInfo[e.id]?.visibility?`visible`:`none`)}}resetLayerOpacity(e){let t=this.mcMap.map,n=m[e.type];if(!n)return;let r=this.layerInfo[e.id],i=r?.opacity;if(i!==void 0)for(let r of n.props)t.setPaintProperty(e.id,r,i*n.defaultValue);else for(let r of n.props){let i=e.paint?.[r]??n.defaultValue;t.setPaintProperty(e.id,r,i)}t.setLayoutProperty(e.id,`visibility`,r?.visibility?`visible`:`none`)}},Iu=class extends u.Evented{map;video;constructor(e,t,n,r,i,a,o){super(),this.map=e,this.video=new Fu(this,t,n,r,i,a,o)}on(e,t){return super.on(e,t)}once(e,t){return super.once(e,t)}off(e,t){return super.off(e,t)}fire(e,t){return super.fire(e,t)}play(){this.video.play()}pause(){this.video.pause()}seekTo(e){this.video.seekTo(e)}frames(){return this.video.frames()}};async function Lu(e){let{accessToken:t,mode:n=`sdk`,env:r=`production`}=e,i=r===`bleeding`?`https://vapi.bleeding.mc-cdn.io`:r===`beta`?`https://vapi.beta.mc-cdn.io`:`https://vapi.mc-cdn.io`,a=r===`bleeding`?`https://cdn.bleeding.mapcreator.io`:r===`beta`?`https://cdn.beta.mapcreator.io`:`https://cdn.mapcreator.io`,o=typeof e.job==`string`?await Ru(e.job,a,t):e.job;await zu();let s=new u.Map({container:e.container,attributionControl:!1,style:null,maxBounds:[-1/0,-90,1/0,90],maxPitch:85,maxZoom:22,locale:{"CooperativeGesturesHandler.WindowsHelpText":Vi(`windowsHelpText`),"CooperativeGesturesHandler.MacHelpText":Vi(`macHelpText`),"CooperativeGesturesHandler.MobileHelpText":Vi(`mobileHelpText`)},canvasContextAttributes:{preserveDrawingBuffer:n===`video`}}),c=s.getContainer();c.classList.add(`mc-map`),c.classList.add(`mc-mode-${n}`);let l=new Br(s),d=new Wl(s,n),{map:{language:p,pitch:m=0,rotation:g=0,center:v,hideBasemap:b,detailLevel:x=0,projection:S=`mercator`,terrain:C=!1,terrainExaggeration:w=1},registry:T={},web:E,positionOffsets:D,title:O}=o,{models:k={},slots:A={},svgs:j={}}=T;Hu(r,i,t),s.resize(),n===`app`&&(document.title=O?`${O} - Mapcreator`:`Mapcreator`),s.setPitch(m),s.setBearing(g);let M=ee(o,c),N,P;if(n===`video`?(P=o.map.zoom-x,N=M):(P=o.map.zoom-x+Math.log2(M),N=1),s.setScale(N),s.setZoom(P),s.setCenter(v),s.setDetailLevel(x),s.setMinZoom(x),s.addControl(new u.AttributionControl({compact:!1})),n===`app`&&s.cooperativeGestures.enable(),dl(o,D??f,s,{center:v,zoom:P,pitch:m,rotation:g},i,a,t,N,n),d.setJobObject(o),E){let{restrictMapMovement:e,popupPosition:t}=E;e&&(s.boxZoom.disable(),s.doubleClickZoom.disable(),s.dragPan.disable(),s.dragRotate.disable(),s.keyboard.disable(),s.scrollZoom.disable(),s.touchPitch.disable(),s.touchZoomRotate.disable()),d.setParams(t,y(p,_.TWO),e,v)}let te=await fetch(`${i}/styles/${o.meta.mapstyleSet}.json?access_token=${t}`).then(e=>e.json());s.setStyle(null),s.setStyle(te),await s.once(`style.load`),n===`app`&&Uu(s.getStyle().metadata?.customCssFilePath,t),h(p,s);let F=await wl(o.map.overlays??[],o.meta.layers??[],s,i,t,te.metadata?.styleOverride),ne=(o.map.overlays??[]).reduce((e,t,n)=>e.set(t,F[n]),new Map);Ku(s,l,k,A,j,i,t),h(p,s),d.setPublication(te.metadata?.publication),d.setpopupElements(),d.setHighlightManager(),s.setProjection({type:S===`globe`?`globe`:`mercator`}),Bu(s,S),C&&Vu(s,i,t,w);let re=Wu(o.map.layerInfo,te,F);return Gu(s,re,!b),new Iu(s,o,j,l,te,ne,re)}function Ru(e,t,n){return fetch(`${t}/jobs/${e}.json?access_token=${n}`).then(e=>e.json())}function zu(){return new Promise(e=>{let t=()=>{window.innerWidth>0&&window.innerHeight>0&&(window.removeEventListener(`resize`,t),e())};window.addEventListener(`resize`,t),t()})}function Bu(e,t){let n=e.getStyle().metadata??{},r=n[`mc:background-color`]??`#f8f8f8`,i=n[`mc:background-color-globe`]??`#000000`;e.getContainer().style.backgroundColor=t===`globe`?i:r,e.setSky(e.getStyle().sky??d),e.setLight({position:[1.15,210,45]})}function Vu(e,t,n,r){e.addSource(`mc-dem`,{type:`raster-dem`,tiles:[`${t}/dataset/jaxa_terrainrgb/{z}/{x}/{y}?access_token=${n}`],attribution:`<a href="https://earth.jaxa.jp/en/data/policy" target="_blank">© AW3D30 (JAXA)</a>`,minzoom:0,maxzoom:12}),e.setTerrain({source:`mc-dem`,exaggeration:r})}function Hu(e,t,n){let r=`${t}/stylesheets/ff-${e===`beta`?`b-`:``}${n}.css?access_token=${n}`,i=document.createElement(`link`);i.setAttribute(`rel`,`stylesheet`),i.setAttribute(`href`,r),i.setAttribute(`type`,`text/css`),document.head.insertBefore(i,document.head.firstChild)}function Uu(e,t){if(document.getElementById(`custom-style`)?.remove(),!e)return;let n;e.startsWith(`http`)?(e=`${e}?access_token=${t}`,n=document.createElement(`link`),n.setAttribute(`rel`,`stylesheet`),n.setAttribute(`href`,e.replace(/https?:/,``))):(n=document.createElement(`style`),n.appendChild(document.createTextNode(e))),n.setAttribute(`id`,`custom-style`),n.setAttribute(`type`,`text/css`),document.head.appendChild(n)}function Wu(e,t,n){let r=e?.reduce((e,t)=>(e[t.id]={visibility:t.visibility,...t.opacity!==void 0&&{opacity:t.opacity}},e),{})??{},i={};for(let e of t.layers)i[e.id]=r[e.id]??{visibility:(e.layout?.visibility??`visible`)===`visible`};for(let e of n)for(let t of e.layers)i[t.id]=r[t.id]??{visibility:!1};return i}function Gu(e,t,n){for(let r in t){let i=e.getLayer(r);if(i!==void 0){let a=t[r];if(e.setLayoutProperty(r,`visibility`,a.visibility&&n?`visible`:`none`),a.opacity===void 0)continue;let o=m[i.type];if(!o)continue;let{props:s,defaultValue:c}=o;for(let t of s)e.setPaintProperty(r,t,a.opacity*c)}}}function Ku(e,t,n,r,i,a,o){let{beforeNone:s=[],beforeNames:c=[],beforeBoundaries:l=[],beforeWaters:u=[]}=r;s.forEach(r=>{qu(e,t,n,r,i,`mc-before-none`,a,o)}),c.forEach(r=>{qu(e,t,n,r,i,`mc-before-names`,a,o)}),l.forEach(r=>{qu(e,t,n,r,i,`mc-before-boundaries`,a,o)}),u.forEach(r=>{qu(e,t,n,r,i,`mc-before-waters`,a,o)})}function qu(e,t,n,r,i,a,o,s){if(r.type===`marker`){let o=n.marker?.find(e=>e.id===r.groupId);o&&xl(e,o,a,i,t)}else if(r.type===`polygon`){let o=n.polygon?.find(e=>e.id===r.groupId);o&&gl(e,o,a,i,t)}else if(r.type===`circle`){let o=n.circle?.find(e=>e.id===r.groupId);o&&vl(e,o,a,i,t)}else if(r.type===`line`){let i=n.line?.find(e=>e.id===r.groupId);i&&ql(e,i,a,t)}else if(r.type===`dot`){let t=n.dot?.find(e=>e.id===r.groupId);t&&Zl(e,t,a)}else if(r.type===`area`){let c=n.area?.find(e=>e.id===r.groupId);c&&Xl(e,c,a,i,t,o,s)}}e.initMap=Lu,e.setRTLTextPlugin=u.setRTLTextPlugin});