@mapvx/web-components 0.9.0-dev.3 → 0.10.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.
- package/dist/cjs/{base-floor-selector-C8tXYk9W.cjs → base-floor-selector-BMedqz0P.cjs} +3 -3
- package/dist/cjs/{class-map-DISSQ8nF.cjs → class-map-C2D175vh.cjs} +3 -3
- package/dist/cjs/{compact-floor-selector-BJkUv0BS.cjs → compact-floor-selector-DnF3Y0bm.cjs} +3 -3
- package/dist/cjs/{consume-DHGUcjnF.cjs → consume-DGHiJ7I1.cjs} +3 -3
- package/dist/cjs/{custom-map-DbyZ9EK1.cjs → custom-map-DMTzK90c.cjs} +3 -3
- package/dist/cjs/{enable-3d-attribute-BSYIYIR9.cjs → enable-3d-attribute-COwMFAl3.cjs} +4 -4
- package/dist/cjs/{floor-selector-CJVs0IRb.cjs → floor-selector-BdcHwHM5.cjs} +3 -3
- package/dist/cjs/index.cjs +3 -3
- package/dist/cjs/map-view-with-modal.cjs +3 -3
- package/dist/cjs/{qr-modal-BdL3fOhS.cjs → qr-modal-CVcwWbMz.cjs} +3 -3
- package/dist/cjs/{route-options-Brl4A4MD.cjs → route-options-bipiWsdN.cjs} +3 -3
- package/dist/cjs/route-view-totems.cjs +3 -3
- package/dist/es/assets/{base-floor-selector-DWcWg26z.js → base-floor-selector-tMT3OqNn.js} +3 -3
- package/dist/es/assets/{class-map-D1siPz5g.js → class-map-DARMkWL5.js} +3 -3
- package/dist/es/assets/{compact-floor-selector-LOwA4Kgm.js → compact-floor-selector-Cn32jNQ1.js} +3 -3
- package/dist/es/assets/{consume-DDxKBV3a.js → consume-CHy7FszE.js} +3 -3
- package/dist/es/assets/{custom-map-CuC_VSae.js → custom-map-D5CN1bK4.js} +3 -3
- package/dist/es/assets/{enable-3d-attribute-weTE_-As.js → enable-3d-attribute-ByF7UVrM.js} +3 -3
- package/dist/es/assets/{floor-selector-CxZUO8Ht.js → floor-selector-Dl4c0hkj.js} +3 -3
- package/dist/es/assets/{qr-modal-pVy0sZh6.js → qr-modal-CcTW0MC4.js} +3 -3
- package/dist/es/assets/{route-options-By5c6MeY.js → route-options-JdoUif98.js} +3 -3
- package/dist/es/index.js +3 -3
- package/dist/es/map-view-with-modal.js +3 -3
- package/dist/es/route-view-totems.js +3 -3
- package/dist/iife/map-view-with-modal.js +3 -3
- package/dist/iife/route-view-totems.js +3 -3
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
7
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="412a3fd8-bd5a-5add-91bb-d68d5cf611a8")}catch(e){}}();
|
|
8
8
|
const e=globalThis,t=e.ShadowRoot&&(void 0===e.ShadyCSS||e.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,r=Symbol(),i=new WeakMap;let n=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==r)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const r=this.t;if(t&&void 0===e){const t=void 0!==r&&1===r.length;t&&(e=i.get(r)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),t&&i.set(r,e))}return e}toString(){return this.cssText}};const a=e=>new n("string"==typeof e?e:e+"",void 0,r),s=(e,...t)=>{const i=1===e.length?e[0]:t.reduce((t,r,i)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if("number"==typeof e)return e;throw Error("Value passed to 'css' function must be a 'css' function result: "+e+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(r)+e[i+1],e[0]);return new n(i,e,r)},o=t?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const r of e.cssRules)t+=r.cssText;return a(t)})(e):e,{is:l,defineProperty:u,getOwnPropertyDescriptor:c,getOwnPropertyNames:h,getOwnPropertySymbols:d,getPrototypeOf:p}=Object,f=globalThis,m=f.trustedTypes,g=m?m.emptyScript:"",y=f.reactiveElementPolyfillSupport,_=(e,t)=>e,v={toAttribute(e,t){switch(t){case Boolean:e=e?g:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let r=e;switch(t){case Boolean:r=null!==e;break;case Number:r=null===e?null:Number(e);break;case Object:case Array:try{r=JSON.parse(e)}catch(e){r=null}}return r}},x=(e,t)=>!l(e,t),b={attribute:!0,type:String,converter:v,reflect:!1,useDefault:!1,hasChanged:x};
|
|
9
9
|
/**
|
|
10
10
|
* @license
|
|
@@ -37,7 +37,7 @@ const le=e=>(t,r)=>{void 0!==r?r.addInitializer(()=>{customElements.define(e,t)}
|
|
|
37
37
|
* @license
|
|
38
38
|
* Copyright 2018 Google LLC
|
|
39
39
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
40
|
-
*/const de=e=>e??G,pe=()=>import("./custom-map-CuC_VSae.js"),fe=()=>import("./floor-selector-CxZUO8Ht.js"),me=()=>import("./compact-floor-selector-LOwA4Kgm.js"),ge=()=>import("./qr-modal-pVy0sZh6.js"),ye=()=>import("./route-options-By5c6MeY.js"),_e=async()=>{try{await import("./styles-DLXHFhZH.js")}catch{}};class ve{constructor(){this.MEASUREMENT_ID="G-6XL8YD35QR",this.isInitialized=!1,this.sessionId=""}static getInstance(){return ve.instance||(ve.instance=new ve),ve.instance}generateSessionId(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}initialize(e){if(this.isInitialized)return;ve.component=e,this.sessionId=this.generateSessionId();const t=document.createElement("script");t.async=!0,t.src=`https://www.googletagmanager.com/gtag/js?id=${this.MEASUREMENT_ID}`,document.head.appendChild(t),window.dataLayer=window.dataLayer||[];window.gtag=window.gtag||((...e)=>{window.dataLayer.push(e)}),window.gtag("js",/* @__PURE__ */new Date),window.gtag("config",this.MEASUREMENT_ID,{send_page_view:!0,groups:"mapvx"}),this.isInitialized=!0}resetSessionId(){this.sessionId=this.generateSessionId()}trackPageView(e){this.isInitialized&&window.gtag("event","page_view",{page_title:e,page_location:window.location.href,page_path:e,component:ve.component,session_id:this.sessionId,send_to:"mapvx"})}trackEvent(e,t){this.isInitialized&&window.gtag("event",e,{...t,component:ve.component,session_id:this.sessionId,send_to:"mapvx"})}trackUserTiming(e,t,r){this.isInitialized&&window.gtag("event","timing_complete",{name:t,value:r,event_category:e,component:ve.component,session_id:this.sessionId,send_to:"mapvx"})}trackException(e,t=!1){this.isInitialized&&window.gtag("event","exception",{description:e,fatal:t,component:ve.component,session_id:this.sessionId,send_to:"mapvx"})}}const xe="/mvx-tiles-sw.js",be="/",we="https://tiles.mapvx.com/tiles";async function Ee(){if(!("serviceWorker"in navigator))return;const e=navigator.serviceWorker.ready;e&&await e.catch(()=>{})}async function Se(e=xe,t="/"){if("undefined"==typeof navigator||!("serviceWorker"in navigator))return null;try{return await navigator.serviceWorker.register(e,{scope:t})}catch{return null}}function De(e,t){if(!e?.active)return;const r=t.apiKey?.trim()??"",i=t.placeId?.trim()??"";""!==r&&""!==i&&e.active.postMessage({type:"INITIAL_TILE_LOAD",apiKey:r,placeId:i,tilesBaseUrl:t.tilesBaseUrl??we})}function Te(e,t,r=864e5){if(!e)return()=>{};const i=window.setInterval(()=>{if(!e.active)return;const r=t.apiKey?.trim()??"",i=t.placeId?.trim()??"";""!==r&&""!==i&&e.active.postMessage({type:"REFRESH_TILES",apiKey:r,placeId:i,tilesBaseUrl:t.tilesBaseUrl??we})},r);return()=>window.clearInterval(i)}async function Ae(e){const t=await Se(e.swPath,e.swScope);await Ee(),De(t,e);return{registration:t,stopPeriodicRefresh:e.enablePeriodicRefresh?Te(t,e):()=>{}}}const Pe="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,Ie=globalThis,Ce="10.68.0";function Fe(){return Me(Ie),Ie}function Me(e){const t=e.__SENTRY__=e.__SENTRY__||{};return t.version=t.version||Ce,t[Ce]=t[Ce]||{}}function ke(e,t,r=Ie){const i=r.__SENTRY__=r.__SENTRY__||{},n=i[Ce]=i[Ce]||{};return n[e]||(n[e]=t())}const Re=["debug","info","warn","error","log","assert","trace"],Le={};function ze(e){if(!("console"in Ie))return e();const t=Ie.console,r={},i=Object.keys(Le);i.forEach(e=>{const i=Le[e];r[e]=t[e],t[e]=i});try{return e()}finally{i.forEach(e=>{t[e]=r[e]})}}function Be(){return $e().enabled}function Oe(e,...t){Pe&&Be()&&ze(()=>{Ie.console[e](`Sentry Logger [${e}]:`,...t)})}function $e(){return Pe?ke("loggerSettings",()=>({enabled:!1})):{enabled:!1}}const Ne={enable:function(){$e().enabled=!0},disable:function(){$e().enabled=!1},isEnabled:Be,log:function(...e){Oe("log",...e)},warn:function(...e){Oe("warn",...e)},error:function(...e){Oe("error",...e)}},je="?",Ve=/\(error: (.*)\)/,Ue=/captureMessage|captureException/;function qe(...e){const t=e.sort((e,t)=>e[0]-t[0]).map(e=>e[1]);return(e,r=0,i=0)=>{const n=[],a=e.split("\n");for(let s=r;s<a.length;s++){let e=a[s];e.length>1024&&(e=e.slice(0,1024));const r=Ve.test(e)?e.replace(Ve,"$1"):e;if(!r.includes("Error: ")){for(const e of t){const t=e(r);if(t){n.push(t);break}}if(n.length>=50+i)break}}return function(e){if(!e.length)return[];const t=Array.from(e);/sentryWrapped/.test(Ge(t).function||"")&&t.pop();t.reverse(),Ue.test(Ge(t).function||"")&&(t.pop(),Ue.test(Ge(t).function||"")&&t.pop());return t.slice(0,50).map(e=>({...e,filename:e.filename||Ge(t).filename,function:e.function||je}))}(n.slice(i))}}function Ge(e){return e[e.length-1]||{}}const Ze="<anonymous>";function We(e){try{return e&&"function"==typeof e&&e.name||Ze}catch{return Ze}}function He(e){const t=e.exception;if(t){const e=[];try{return t.values.forEach(t=>{t.stacktrace.frames&&e.push(...t.stacktrace.frames)}),e}catch{return}}}const Xe={},Ye={};function Ke(e,t){return Xe[e]=Xe[e]||[],Xe[e].push(t),()=>{const r=Xe[e];if(r){const e=r.indexOf(t);-1!==e&&r.splice(e,1)}}}function Je(e,t){if(!Ye[e]){Ye[e]=!0;try{t()}catch(gd){Pe&&Ne.error(`Error while instrumenting ${e}`,gd)}}}function Qe(e,t){const r=e&&Xe[e];if(r)for(const i of r)try{i(t)}catch(gd){Pe&&Ne.error(`Error while triggering instrumentation handler.\nType: ${e}\nName: ${We(i)}\nError:`,gd)}}let et=null;function tt(){et=Ie.onerror,Ie.onerror=function(e,t,r,i,n){return Qe("error",{column:i,error:n,line:r,msg:e,url:t}),!!et&&et.apply(this,arguments)},Ie.onerror.__SENTRY_INSTRUMENTED__=!0}let rt=null;function it(){rt=Ie.onunhandledrejection,Ie.onunhandledrejection=function(e){return Qe("unhandledrejection",e),!rt||rt.apply(this,arguments)},Ie.onunhandledrejection.__SENTRY_INSTRUMENTED__=!0}const nt=Object.prototype.toString;function at(e){switch(nt.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return gt(e,Error)}}function st(e,t){return nt.call(e)===`[object ${t}]`}function ot(e){return st(e,"ErrorEvent")}function lt(e){return st(e,"DOMError")}function ut(e){return st(e,"String")}function ct(e){return"object"==typeof e&&null!==e&&"__sentry_template_string__"in e&&"__sentry_template_values__"in e}function ht(e){return null===e||ct(e)||"object"!=typeof e&&"function"!=typeof e}function dt(e){return st(e,"Object")}function pt(e){return"object"==typeof e&&null!==e}function ft(e){return"undefined"!=typeof Event&>(e,Event)}function mt(e){return Boolean(e?.then&&"function"==typeof e.then)}function gt(e,t){try{return e instanceof t}catch{return!1}}function yt(e){return"undefined"!=typeof Request&>(e,Request)}function _t(e,t,r){if(!(t in e))return;const i=e[t];if("function"!=typeof i)return;const n=r(i);"function"==typeof n&&xt(n,i);try{e[t]=n}catch{Pe&&Ne.log(`Failed to replace method "${t}" in object`,e)}}function vt(e,t,r){try{Object.defineProperty(e,t,{value:r,writable:!0,configurable:!0})}catch{Pe&&Ne.log(`Failed to add non-enumerable property "${String(t)}" to object`,e)}}function xt(e,t){try{const r=t.prototype||{};e.prototype=t.prototype=r,vt(e,"__sentry_original__",t)}catch{}}function bt(e){return e.__sentry_original__}function wt(e){if(at(e))return{message:e.message,name:e.name,stack:e.stack,...Et(e)};if(ft(e)){const{type:t,target:r,currentTarget:i,detail:n}=e;return{type:t,target:r,currentTarget:i,...n?{detail:n}:{},...Et(e)}}return e}function Et(e){return pt(e)?Object.fromEntries(Object.entries(e)):{}}let St;function Dt(e){if(void 0!==St)return St?St(e):e();const t=/* @__PURE__ */Symbol.for("__SENTRY_SAFE_RANDOM_ID_WRAPPER__"),r=Ie;return t in r&&"function"==typeof r[t]?(St=r[t],St(e)):(St=null,e())}function Tt(){return Dt(()=>Math.random())}function At(){return Dt(()=>Date.now())}const Pt=/* @__PURE__ */Symbol.for("sentry.skipNormalization"),It=/* @__PURE__ */Symbol.for("sentry.overrideNormalizationDepth");let Ct,Ft;function Mt(e,t=100,r=1/0){try{return Rt("",e,t,r)}catch(i){return{ERROR:`**non-serializable** (${i})`}}}function kt(e,t=3,r=102400){const i=Mt(e,t);return n=i,function(e){return~-encodeURI(e).split(/%..|./).length}(JSON.stringify(n))>r?kt(e,t-1,r):i;var n}function Rt(e,t,r=1/0,i=1/0,n=function(){const e=/* @__PURE__ */new WeakSet;function t(t){return!!e.has(t)||(e.add(t),!1)}function r(t){e.delete(t)}return[t,r]}()){const[a,s]=n;if(null==t||["boolean","string"].includes(typeof t)||"number"==typeof t&&Number.isFinite(t))return t;const o=Lt(e,t);if(!o.startsWith("[object "))return o;if(function(e){return Boolean(e[Pt])}(t))return t;const l=function(e){const t=e[It];return"number"==typeof t?t:void 0}(t),u=void 0!==l?l:r;if(0===u)return o.replace("object ","");if(a(t))return"[Circular ~]";const c=t;if(c&&"function"==typeof c.toJSON)try{return Rt("",c.toJSON(),u-1,i,n)}catch{}const h=Array.isArray(t)?[]:{};let d=0;const p=wt(t);for(const f in p){if(!Object.prototype.hasOwnProperty.call(p,f))continue;if(d>=i){h[f]="[MaxProperties ~]";break}const e=p[f];h[f]=Rt(f,e,u-1,i,n),d++}return s(t),h}function Lt(e,t){try{if(Ct){const e=Ct(t);if(e)return e}if("undefined"!=typeof global&&t===global)return"[Global]";if("number"==typeof t&&!Number.isFinite(t))return`[${t}]`;if("function"==typeof t)return`[Function: ${We(t)}]`;if("symbol"==typeof t)return`[${String(t)}]`;if("bigint"==typeof t)return`[BigInt: ${String(t)}]`;const e=function(e){const t=Object.getPrototypeOf(e);return t?.constructor?t.constructor.name:"null prototype"}(t);return`[object ${e}]`}catch(r){return`**non-serializable** (${r})`}}function zt(e,t=0){return"string"!=typeof e||0===t||e.length<=t?e:`${e.slice(0,t)}...`}function Bt(e,t){if(!Array.isArray(e))return"";const r=[];for(let i=0;i<e.length;i++){const t=e[i];ht(t)?r.push(String(t)):t instanceof Error?r.push(t.message?`${t.name}: ${t.message}`:t.name):r.push(Lt(0,t))}return r.join(t)}function Ot(e,t,r=!1){return!!ut(e)&&(st(t,"RegExp")?t.test(e):ut(t)?r?e===t:e.includes(t):"function"==typeof t&&t(e))}function $t(e,t=[],r=!1){for(const i of t)if(Ot(e,i,r))return!0;return!1}function Nt(e=function(){const e=Ie;return e.crypto||e.msCrypto}()){try{if(e?.randomUUID)return Dt(()=>e.randomUUID()).replace(/-/g,"")}catch{}return Ft||(Ft="10000000100040008000100000000000"),Ft.replace(/[018]/g,e=>(e^(16*Tt()&15)>>e/4).toString(16))}function jt(e){return e.exception?.values?.[0]}function Vt(e){const{message:t,event_id:r}=e;if(t)return t;const i=jt(e);return i?i.type&&i.value?`${i.type}: ${i.value}`:i.type||i.value||r||"<unknown>":r||"<unknown>"}function Ut(e,t,r){const i=e.exception=e.exception||{},n=i.values=i.values||[],a=n[0]=n[0]||{};a.value||(a.value=t||""),a.type||(a.type="Error")}function qt(e,t){const r=jt(e);if(!r)return;const i=r.mechanism;if(r.mechanism={type:"generic",handled:!0,...i,...t},t&&"data"in t){const e={...i?.data,...t.data};r.mechanism.data=e}}function Gt(e){if(function(e){try{return e.__sentry_captured__}catch{}}(e))return!0;try{vt(e,"__sentry_captured__",!0)}catch{}return!1}function Zt(){return At()/1e3}let Wt;function Ht(){return(Wt??(Wt=function(){const{performance:e}=Ie;if(!e?.now||!e.timeOrigin)return Zt;const t=e.timeOrigin;return()=>(t+Dt(()=>e.now()))/1e3}()))()}function Xt(e){const t=Ht(),r={sid:Nt(),init:!0,timestamp:t,started:t,duration:0,status:"ok",errors:0,ignoreDuration:!1,toJSON:()=>function(e){return{sid:`${e.sid}`,init:e.init,started:new Date(1e3*e.started).toISOString(),timestamp:new Date(1e3*e.timestamp).toISOString(),status:e.status,errors:e.errors,did:"number"==typeof e.did||"string"==typeof e.did?`${e.did}`:void 0,duration:e.duration,abnormal_mechanism:e.abnormal_mechanism,attrs:{release:e.release,environment:e.environment,ip_address:e.ipAddress,user_agent:e.userAgent}}}(r)};return e&&Yt(r,e),r}function Yt(e,t={}){if(t.user&&(!e.ipAddress&&t.user.ip_address&&(e.ipAddress=t.user.ip_address),e.did||t.did||(e.did=t.user.id||t.user.email||t.user.username)),e.timestamp=t.timestamp||Ht(),t.abnormal_mechanism&&(e.abnormal_mechanism=t.abnormal_mechanism),t.ignoreDuration&&(e.ignoreDuration=t.ignoreDuration),t.sid&&(e.sid=32===t.sid.length?t.sid:Nt()),void 0!==t.init&&(e.init=t.init),!e.did&&t.did&&(e.did=`${t.did}`),"number"==typeof t.started&&(e.started=t.started),e.ignoreDuration)e.duration=void 0;else if("number"==typeof t.duration)e.duration=t.duration;else{const t=e.timestamp-e.started;e.duration=t>=0?t:0}t.release&&(e.release=t.release),t.environment&&(e.environment=t.environment),!e.ipAddress&&t.ipAddress&&(e.ipAddress=t.ipAddress),!e.userAgent&&t.userAgent&&(e.userAgent=t.userAgent),"number"==typeof t.errors&&(e.errors=t.errors),t.status&&(e.status=t.status)}function Kt(e,t,r=2){if(!t||"object"!=typeof t||r<=0)return t;if(e&&0===Object.keys(t).length)return e;const i={...e};for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(i[n]=Kt(i[n],t[n],r-1));return i}function Jt(){return Nt()}function Qt(){return Nt().substring(16)}function er(e){if(e){if("object"==typeof e&&"deref"in e&&"function"==typeof e.deref)try{return e.deref()}catch{return}return e}}const tr="_sentrySpan";function rr(e,t){t?vt(e,tr,function(e){try{const t=Ie.WeakRef;if("function"==typeof t)return new t(e)}catch{}return e}(t)):delete e[tr]}function ir(e){return er(e[tr])}let nr=class e{constructor(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._attachments=[],this._user={},this._tags={},this._attributes={},this._extra={},this._contexts={},this._sdkProcessingMetadata={},this._propagationContext={traceId:Jt(),sampleRand:Tt()}}clone(){const t=new e;return t._breadcrumbs=[...this._breadcrumbs],t._tags={...this._tags},t._attributes={...this._attributes},t._extra={...this._extra},t._contexts={...this._contexts},this._contexts.flags&&(t._contexts.flags={values:[...this._contexts.flags.values]}),t._user=this._user,t._level=this._level,t._session=this._session,t._transactionName=this._transactionName,t._fingerprint=this._fingerprint,t._eventProcessors=[...this._eventProcessors],t._attachments=[...this._attachments],t._sdkProcessingMetadata={...this._sdkProcessingMetadata},t._propagationContext={...this._propagationContext},t._client=this._client,t._lastEventId=this._lastEventId,t._conversationId=this._conversationId,rr(t,ir(this)),t}setClient(e){this._client=e}setLastEventId(e){this._lastEventId=e}getClient(){return this._client}lastEventId(){return this._lastEventId}addScopeListener(e){this._scopeListeners.push(e)}addEventProcessor(e){return this._eventProcessors.push(e),this}setUser(e){return this._user=e||{email:void 0,id:void 0,ip_address:void 0,username:void 0},this._session&&Yt(this._session,{user:e}),this._notifyScopeListeners(),this}getUser(){return this._user}setConversationId(e){return this._conversationId=e||void 0,this._notifyScopeListeners(),this}setTags(e){return this._tags={...this._tags,...e},this._notifyScopeListeners(),this}setTag(e,t){return this.setTags({[e]:t})}setAttributes(e){return this._attributes={...this._attributes,...e},this._notifyScopeListeners(),this}setAttribute(e,t){return this.setAttributes({[e]:t})}removeAttribute(e){return e in this._attributes&&(delete this._attributes[e],this._notifyScopeListeners()),this}setExtras(e){return this._extra={...this._extra,...e},this._notifyScopeListeners(),this}setExtra(e,t){return this._extra={...this._extra,[e]:t},this._notifyScopeListeners(),this}setFingerprint(e){return this._fingerprint=e,this._notifyScopeListeners(),this}setLevel(e){return this._level=e,this._notifyScopeListeners(),this}setTransactionName(e){return this._transactionName=e,this._notifyScopeListeners(),this}setContext(e,t){return null===t?delete this._contexts[e]:this._contexts[e]=t,this._notifyScopeListeners(),this}setSession(e){return e?this._session=e:delete this._session,this._notifyScopeListeners(),this}getSession(){return this._session}update(t){if(!t)return this;const r="function"==typeof t?t(this):t,i=r instanceof e?r.getScopeData():dt(r)?t:void 0,{tags:n,attributes:a,extra:s,user:o,contexts:l,level:u,fingerprint:c=[],propagationContext:h,conversationId:d}=i||{};return this._tags={...this._tags,...n},this._attributes={...this._attributes,...a},this._extra={...this._extra,...s},this._contexts={...this._contexts,...l},o&&Object.keys(o).length&&(this._user=o),u&&(this._level=u),c.length&&(this._fingerprint=c),h&&(this._propagationContext=h),d&&(this._conversationId=d),this}clear(){return this._breadcrumbs=[],this._tags={},this._attributes={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._session=void 0,this._conversationId=void 0,rr(this,void 0),this._attachments=[],this.setPropagationContext({traceId:Jt(),sampleRand:Tt()}),this._notifyScopeListeners(),this}addBreadcrumb(e,t){const r="number"==typeof t?t:100;if(r<=0)return this;const i={timestamp:Zt(),...e,message:e.message?zt(e.message,2048):e.message};return this._breadcrumbs.push(i),this._breadcrumbs.length>r&&(this._breadcrumbs=this._breadcrumbs.slice(-r),this._client?.recordDroppedEvent("buffer_overflow","log_item")),this._notifyScopeListeners(),this}getLastBreadcrumb(){return this._breadcrumbs[this._breadcrumbs.length-1]}clearBreadcrumbs(){return this._breadcrumbs=[],this._notifyScopeListeners(),this}addAttachment(e){return this._attachments.push(e),this}clearAttachments(){return this._attachments=[],this}getScopeData(){return{breadcrumbs:this._breadcrumbs,attachments:this._attachments,contexts:this._contexts,tags:this._tags,attributes:this._attributes,extra:this._extra,user:this._user,level:this._level,fingerprint:this._fingerprint||[],eventProcessors:this._eventProcessors,propagationContext:this._propagationContext,sdkProcessingMetadata:this._sdkProcessingMetadata,transactionName:this._transactionName,span:ir(this),conversationId:this._conversationId}}setSDKProcessingMetadata(e){return this._sdkProcessingMetadata=Kt(this._sdkProcessingMetadata,e,2),this}setPropagationContext(e){return this._propagationContext=e,this}getPropagationContext(){return this._propagationContext}captureException(e,t){const r=t?.event_id||Nt();if(!this._client)return Pe&&Ne.warn("No client configured on scope - will not capture exception!"),r;const i=new Error("Sentry syntheticException");return this._client.captureException(e,{originalException:e,syntheticException:i,...t,event_id:r},this),r}captureMessage(e,t,r){const i=r?.event_id||Nt();if(!this._client)return Pe&&Ne.warn("No client configured on scope - will not capture message!"),i;const n=r?.syntheticException??new Error(e);return this._client.captureMessage(e,t,{originalException:e,syntheticException:n,...r,event_id:i},this),i}captureEvent(e,t){const r=e.event_id||t?.event_id||Nt();return this._client?(this._client.captureEvent(e,{...t,event_id:r},this),r):(Pe&&Ne.warn("No client configured on scope - will not capture event!"),r)}_notifyScopeListeners(){this._notifyingListeners||(this._notifyingListeners=!0,this._scopeListeners.forEach(e=>{e(this)}),this._notifyingListeners=!1)}};const ar=e=>e instanceof Promise&&!e[sr],sr=/* @__PURE__ */Symbol("chained PromiseLike"),or=(e,t)=>{if(!t)return e;let r=!1;for(const i in e){if(i in t)continue;r=!0;const n=e[i];"function"==typeof n?Object.defineProperty(t,i,{value:(...t)=>n.apply(e,t),enumerable:!0,configurable:!0,writable:!0}):t[i]=n}return r&&Object.assign(t,{[sr]:!0}),t};let lr=class{constructor(e,t){let r,i;r=e||new nr,i=t||new nr,this._stack=[{scope:r}],this._isolationScope=i}withScope(e){const t=this._pushScope();let r;try{r=e(t)}catch(gd){throw this._popScope(),gd}return mt(r)?((e,t,r)=>{const i=e.then(e=>(t(e),e),e=>{throw r(e),e});return ar(i)&&ar(e)?i:or(e,i)})(r,()=>this._popScope(),()=>this._popScope()):(this._popScope(),r)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this._isolationScope}getStackTop(){return this._stack[this._stack.length-1]}_pushScope(){const e=this.getScope().clone();return this._stack.push({client:this.getClient(),scope:e}),e}_popScope(){return!(this._stack.length<=1)&&!!this._stack.pop()}};function ur(){const e=Me(Fe());return e.stack=e.stack||new lr(ke("defaultCurrentScope",()=>new nr),ke("defaultIsolationScope",()=>new nr))}function cr(e){return ur().withScope(e)}function hr(e,t){const r=ur();return r.withScope(()=>(r.getStackTop().scope=e,t(e)))}function dr(e){return ur().withScope(()=>e(ur().getIsolationScope()))}function pr(e){const t=Me(e);return t.acs?t.acs:{withIsolationScope:dr,withScope:cr,withSetScope:hr,withSetIsolationScope:(e,t)=>dr(t),getCurrentScope:()=>ur().getScope(),getIsolationScope:()=>ur().getIsolationScope()}}function fr(e,t){const{value:r,unit:i}="object"==typeof(n=e)&&null!=n&&!Array.isArray(n)&&Object.keys(n).includes("value")?e:{value:e,unit:void 0};var n;const a=function(e){if(Array.isArray(e))return{value:e,type:"array"};const t="string"==typeof e?"string":"boolean"==typeof e?"boolean":"number"!=typeof e||Number.isNaN(e)?null:Number.isInteger(e)?"integer":"double";if(t)return{value:e,type:t}}(r),s=i&&"string"==typeof i?{unit:i}:{};if(a)return{...a,...s};if(!t||"skip-undefined"===t&&void 0===r)return;let o="";try{o=JSON.stringify(r)??""}catch{}return{value:o,type:"string",...s}}function mr(e,t=!1){const r={};for(const[i,n]of Object.entries(e??{})){const e=fr(n,t);e&&(r[i]=e)}return r}function gr(){return pr(Fe()).getCurrentScope()}function yr(){return pr(Fe()).getIsolationScope()}function _r(){return gr().getClient()}function vr(e){const t=e.getPropagationContext(),{traceId:r,parentSpanId:i,propagationSpanId:n}=t,a={trace_id:r,span_id:n||Qt()};return i&&(a.parent_span_id=i),a}const xr="sentry.op",br="sentry.profile_id",wr="sentry.exclusive_time";function Er(e){const t=e;return{scope:t._sentryScope,isolationScope:er(t._sentryIsolationScope)}}const Sr="sentry-";function Dr(e){const t=function(e){if(!e||!ut(e)&&!Array.isArray(e))return;if(Array.isArray(e))return e.reduce((e,t)=>{const r=Tr(t);return Object.entries(r).forEach(([t,r])=>{e[t]=r}),e},{});return Tr(e)}(e);if(!t)return;const r=Object.entries(t).reduce((e,[t,r])=>{if(t.startsWith(Sr)){e[t.slice(7)]=r}return e},{});return Object.keys(r).length>0?r:void 0}function Tr(e){return e.split(",").map(e=>{const t=e.indexOf("=");if(-1===t)return[];return[e.slice(0,t),e.slice(t+1)].map(e=>{try{return decodeURIComponent(e.trim())}catch{return}})}).reduce((e,[t,r])=>(t&&r&&(e[t]=r),e),{})}const Ar=/^o(\d+)\./,Pr=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)((?:\[[:.%\w]+\]|[\w.-]+))(?::(\d+))?\/(.+)/;function Ir(e,t=!1){const{host:r,path:i,pass:n,port:a,projectId:s,protocol:o,publicKey:l}=e;return`${o}://${l}${t&&n?`:${n}`:""}@${r}${a?`:${a}`:""}/${i?`${i}/`:i}${s}`}function Cr(e){return{protocol:e.protocol,publicKey:e.publicKey||"",pass:e.pass||"",host:e.host,port:e.port||"",path:e.path||"",projectId:e.projectId}}function Fr(e){const t=e.getOptions(),{host:r}=e.getDsn()||{};let i;return t.orgId?i=String(t.orgId):r&&(i=function(e){const t=e.match(Ar);return t?.[1]}(r)),i}function Mr(e){const t="string"==typeof e?function(e){const t=Pr.exec(e);if(!t)return void ze(()=>{console.error(`Invalid Sentry Dsn: ${e}`)});const[r,i,n="",a="",s="",o=""]=t.slice(1);let l="",u=o;const c=u.split("/");if(c.length>1&&(l=c.slice(0,-1).join("/"),u=c.pop()),u){const e=u.match(/^\d+/);e&&(u=e[0])}return Cr({host:a,pass:n,path:l,projectId:u,port:s,protocol:r,publicKey:i})}(e):Cr(e);if(t&&function(e){if(!Pe)return!0;const{port:t,projectId:r,protocol:i}=e;return!(["protocol","publicKey","host","projectId"].find(t=>!e[t]&&(Ne.error(`Invalid Sentry Dsn: ${t} missing`),!0))||(r.match(/^\d+$/)?function(e){return"http"===e||"https"===e}(i)?t&&isNaN(parseInt(t,10))&&(Ne.error(`Invalid Sentry Dsn: Invalid port ${t}`),1):(Ne.error(`Invalid Sentry Dsn: Invalid protocol ${i}`),1):(Ne.error(`Invalid Sentry Dsn: Invalid projectId ${r}`),1)))}(t))return t}let kr=!1;function Rr(e){const{spanId:t,traceId:r,isRemote:i}=e.spanContext(),n=i?t:Or(e).parent_span_id,a=Er(e).scope;return{parent_span_id:n,span_id:i?a?.getPropagationContext().propagationSpanId||Qt():t,trace_id:r}}function Lr(e){return e&&e.length>0?e.map(({context:{spanId:e,traceId:t,traceFlags:r,...i},attributes:n})=>({span_id:e,trace_id:t,sampled:1===r,attributes:n,...i})):void 0}function zr(e){return"number"==typeof e?Br(e):Array.isArray(e)?e[0]+e[1]/1e9:e instanceof Date?Br(e.getTime()):Ht()}function Br(e){return e>9999999999?e/1e3:e}function Or(e){if(function(e){return"function"==typeof e.getSpanJSON}(e))return e.getSpanJSON();const{spanId:t,traceId:r}=e.spanContext();if(function(e){const t=e;return!!(t.attributes&&t.startTime&&t.name&&t.endTime&&t.status)}(e)){const{attributes:i,startTime:n,name:a,endTime:s,status:o,links:l}=e;return{span_id:t,trace_id:r,data:i,description:a,parent_span_id:$r(e),start_timestamp:zr(n),timestamp:zr(s)||void 0,status:Nr(o),op:i[xr],origin:i["sentry.origin"],links:Lr(l)}}return{span_id:t,trace_id:r,start_timestamp:0,data:{}}}function $r(e){return"parentSpanId"in e?e.parentSpanId:"parentSpanContext"in e?e.parentSpanContext?.spanId:void 0}function Nr(e){if(e&&0!==e.code)return 1===e.code?"ok":e.message||"internal_error"}const jr=function(e){return e._sentryRootSpan||e};function Vr(){kr||(ze(()=>{console.warn("[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly or use `ignoreSpans`.")}),kr=!0)}function Ur(e){if("boolean"==typeof __SENTRY_TRACING__&&!__SENTRY_TRACING__)return!1;const t=e||_r()?.getOptions();return!(!t||null==t.tracesSampleRate&&!t.tracesSampler)}function qr(e){Ne.log(`Ignoring span ${e.op} - ${e.description} because it matches \`ignoreSpans\`.`)}function Gr(e,t){if(!t?.length)return!1;for(const r of t){if(Hr(r)){if(e.description&&Ot(e.description,r))return Pe&&qr(e),!0;continue}const t=!!r.attributes&&Object.keys(r.attributes).length>0;if(!r.name&&!r.op&&!t)continue;const i=!r.name||e.description&&Ot(e.description,r.name),n=!r.op||e.op&&Ot(e.op,r.op),a=!r.attributes||Object.entries(r.attributes).every(([t,r])=>Zr(e.attributes?.[t],r));if(i&&n&&a)return Pe&&qr(e),!0}return!1}function Zr(e,t){return"string"==typeof e&&("string"==typeof t||t instanceof RegExp)?Ot(e,t):Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((e,r)=>e===t[r]):e===t}function Wr(e,t){const r=t.parent_span_id,i=t.span_id;if(r)for(const n of e)n.parent_span_id===i&&(n.parent_span_id=r)}function Hr(e){return"string"==typeof e||e instanceof RegExp}const Xr=/* @__PURE__ */Symbol.for("sentry.nonRecordingSpan");const Yr="production";function Kr(e,t){const r=t.getOptions(),{publicKey:i}=t.getDsn()||{},n={environment:r.environment||Yr,release:r.release,public_key:i,trace_id:e,org_id:Fr(t)};return t.emit("createDsc",n),n}function Jr(e,t){const r=t.getPropagationContext();return r.dsc||Kr(r.traceId,e)}function Qr(e){const t=_r();if(!t)return{};const r=jr(e),i=Or(r),n=i.data,a=r.spanContext().traceState,s=a?.get("sentry.sample_rate")??n["sentry.sample_rate"]??n["sentry.previous_trace_sample_rate"];function o(e){return"number"!=typeof s&&"string"!=typeof s||(e.sample_rate=`${s}`),e}const l=r._frozenDsc;if(l)return o(l);const u=function(e){return!!e&&!0===e[Xr]}(r),c=u&&"ignored"===r.dropReason;if(u&&(!Ur(t.getOptions())||c)){const e=Er(r).scope;if(e){const r={...Jr(t,e)};return c&&(r.sampled="false"),o(r)}}const h=a?.get("sentry.dsc"),d=h&&Dr(h);if(d)return o(d);const p=Kr(e.spanContext().traceId,t),f=n["sentry.source"]??n["sentry.segment.name.source"],m=i.description;return"url"!==f&&m&&(p.transaction=m),Ur()&&(p.sampled=String(function(e){const{traceFlags:t}=e.spanContext();return 1===t}(r)),p.sample_rand=a?.get("sentry.sample_rand")??Er(r).scope?.getPropagationContext().sampleRand.toString()),o(p),t.emit("createDsc",p,r),p}function ei(e,t=[]){return[e,t]}function ti(e,t){const[r,i]=e;return[r,[...i,t]]}function ri(e,t){const r=e[1];for(const i of r){if(t(i,i[0].type))return!0}return!1}function ii(e){const t=Me(Ie);return t.encodePolyfill?t.encodePolyfill(e):(new TextEncoder).encode(e)}function ni(e){const[t,r]=e;let i=JSON.stringify(t);function n(e){"string"==typeof i?i="string"==typeof e?i+e:[ii(i),e]:i.push("string"==typeof e?ii(e):e)}for(const a of r){const[e,t]=a;if(n(`\n${JSON.stringify(e)}\n`),"string"==typeof t||t instanceof Uint8Array)n(t);else{let e;try{e=JSON.stringify(t)}catch{e=JSON.stringify(Mt(t))}n(e)}}return"string"==typeof i?i:function(e){const t=e.reduce((e,t)=>e+t.length,0),r=new Uint8Array(t);let i=0;for(const n of e)r.set(n,i),i+=n.length;return r}(i)}function ai(e){const t="string"==typeof e.data?ii(e.data):e.data;return[{type:"attachment",length:t.length,filename:e.filename,content_type:e.contentType,attachment_type:e.attachmentType},t]}const si={sessions:"session",event:"error",client_report:"internal",user_report:"default",profile_chunk:"profile",replay_event:"replay",replay_recording:"replay",check_in:"monitor",raw_security:"security",log:"log_item",trace_metric:"metric"};function oi(e){return function(e){return e in si}(e)?si[e]:e}function li(e){if(!e?.sdk)return;const{name:t,version:r}=e.sdk;return{name:t,version:r}}function ui(e,t,r,i){const n=li(r),a=e.type&&"replay_event"!==e.type?e.type:"event";!function(e,t){if(!t)return e;const r=e.sdk||{};e.sdk={...r,name:r.name||t.name,version:r.version||t.version,integrations:[...e.sdk?.integrations||[],...t.integrations||[]],packages:[...e.sdk?.packages||[],...t.packages||[]],settings:e.sdk?.settings||t.settings?{...e.sdk?.settings,...t.settings}:void 0}}(e,r?.sdk);const s=function(e,t,r,i){const n=e.sdkProcessingMetadata?.dynamicSamplingContext;return{event_id:e.event_id,sent_at:new Date(At()).toISOString(),...t&&{sdk:t},...!!r&&i&&{dsn:Ir(i)},...n&&{trace:n}}}(e,n,i,t);delete e.sdkProcessingMetadata;return ei(s,[[{type:a},e]])}function ci(e,t){const{fingerprint:r,span:i,breadcrumbs:n,sdkProcessingMetadata:a}=t;!function(e,t){const{extra:r,tags:i,user:n,contexts:a,level:s,transactionName:o}=t;Object.keys(r).length&&(e.extra={...r,...e.extra});Object.keys(i).length&&(e.tags={...i,...e.tags});Object.keys(n).length&&(e.user={...n,...e.user});Object.keys(a).length&&(e.contexts={...a,...e.contexts});s&&(e.level=s);o&&"transaction"!==e.type&&(e.transaction=o)}(e,t),i&&function(e,t){e.contexts={trace:Rr(t),...e.contexts},e.sdkProcessingMetadata={dynamicSamplingContext:Qr(t),...e.sdkProcessingMetadata};const r=jr(t),i=Or(r).description;i&&!e.transaction&&"transaction"===e.type&&(e.transaction=i)}(e,i),function(e,t){e.fingerprint=e.fingerprint?Array.isArray(e.fingerprint)?e.fingerprint:[e.fingerprint]:[],t&&(e.fingerprint=e.fingerprint.concat(t));e.fingerprint.length||delete e.fingerprint}(e,r),function(e,t){const r=[...e.breadcrumbs||[],...t];e.breadcrumbs=r.length?r:void 0}(e,n),function(e,t){e.sdkProcessingMetadata={...e.sdkProcessingMetadata,...t}}(e,a)}function hi(e,t){const{extra:r,tags:i,attributes:n,user:a,contexts:s,level:o,sdkProcessingMetadata:l,breadcrumbs:u,fingerprint:c,eventProcessors:h,attachments:d,propagationContext:p,transactionName:f,span:m}=t;di(e,"extra",r),di(e,"tags",i),di(e,"attributes",n),di(e,"user",a),di(e,"contexts",s),e.sdkProcessingMetadata=Kt(e.sdkProcessingMetadata,l,2),o&&(e.level=o),f&&(e.transactionName=f),m&&(e.span=m),u.length&&(e.breadcrumbs=[...e.breadcrumbs,...u]),c.length&&(e.fingerprint=[...e.fingerprint,...c]),h.length&&(e.eventProcessors=[...e.eventProcessors,...h]),d.length&&(e.attachments=[...e.attachments,...d]),e.propagationContext={...e.propagationContext,...p}}function di(e,t,r){e[t]=Kt(e[t],r,1)}function pi(e,t){const r=ke("globalScope",()=>new nr).getScopeData();return e&&hi(r,e.getScopeData()),t&&hi(r,t.getScopeData()),r}const fi="url.full",mi="user_agent.original";function gi(e,t){const r=e.attributes??(e.attributes={});Object.entries(t).forEach(([e,t])=>{null==t||e in r||(r[e]=t)})}function yi(e){return new Ei(t=>{t(e)})}function _i(e){return new Ei((t,r)=>{r(e)})}let vi,xi,bi,wi,Ei=class e{constructor(e){this._state=0,this._handlers=[],this._runExecutor(e)}then(t,r){return new e((e,i)=>{this._handlers.push([!1,r=>{if(t)try{e(t(r))}catch(gd){i(gd)}else e(r)},t=>{if(r)try{e(r(t))}catch(gd){i(gd)}else i(t)}]),this._executeHandlers()})}catch(e){return this.then(e=>e,e)}finally(t){return new e((e,r)=>{let i,n;return this.then(e=>{n=!1,i=e,t&&t()},e=>{n=!0,i=e,t&&t()}).then(()=>{n?r(i):e(i)})})}_executeHandlers(){if(0===this._state)return;const e=this._handlers.slice();this._handlers=[],e.forEach(e=>{e[0]||(1===this._state&&e[1](this._value),2===this._state&&e[2](this._value),e[0]=!0)})}_runExecutor(e){const t=(e,t)=>{0===this._state&&(mt(t)?t.then(r,i):(this._state=e,this._value=t,this._executeHandlers()))},r=e=>{t(1,e)},i=e=>{t(2,e)};try{e(r,i)}catch(gd){i(gd)}}};function Si(e,t,r,i=0){try{const n=Di(t,r,e,i);return mt(n)?n:yi(n)}catch(n){return _i(n)}}function Di(e,t,r,i){const n=r[i];if(!e||!n)return e;const a=n({...e},t);return Pe&&null===a&&Ne.log(`Event processor "${n.id||"?"}" dropped event`),mt(a)?a.then(e=>Di(e,t,r,i+1)):Di(a,t,r,i+1)}function Ti(e,t,r,i,n,a){const{normalizeDepth:s=3,normalizeMaxBreadth:o=1e3}=e,l={...t,event_id:t.event_id||r.event_id||Nt(),timestamp:t.timestamp||Zt()},u=r.integrations||e.integrations.map(e=>e.name);!function(e,t){const{environment:r,release:i,dist:n,maxValueLength:a}=t;e.environment=e.environment||r||Yr,!e.release&&i&&(e.release=i);!e.dist&&n&&(e.dist=n);const s=e.request;s?.url&&a&&(s.url=zt(s.url,a));a&&e.exception?.values?.forEach(e=>{e.value&&(e.value=zt(e.value,a))})}(l,e),function(e,t){t.length>0&&(e.sdk=e.sdk||{},e.sdk.integrations=[...e.sdk.integrations||[],...t])}(l,u),n&&n.emit("applyFrameMetadata",t),void 0===t.type&&function(e,t){const r=function(e){const t=Ie._sentryDebugIds,r=Ie._debugIds;if(!t&&!r)return{};const i=t?Object.keys(t):[],n=r?Object.keys(r):[];if(wi&&i.length===xi&&n.length===bi)return wi;xi=i.length,bi=n.length,wi={},vi||(vi={});const a=(t,r)=>{for(const i of t){const t=r[i],n=vi?.[i];if(n&&wi&&t)wi[n[0]]=t,vi&&(vi[i]=[n[0],t]);else if(t){const r=e(i);for(let e=r.length-1;e>=0;e--){const n=r[e],a=n?.filename;if(a&&wi&&vi){wi[a]=t,vi[i]=[a,t];break}}}}};return t&&a(i,t),r&&a(n,r),wi}(t);e.exception?.values?.forEach(e=>{e.stacktrace?.frames?.forEach(e=>{e.filename&&(e.debug_id=r[e.filename])})})}(l,e.stackParser);const c=function(e,t){if(!t)return e;const r=e?e.clone():new nr;return r.update(t),r}(i,r.captureContext);r.mechanism&&qt(l,r.mechanism);const h=n?n.getEventProcessors():[],d=pi(a,c),p=[...r.attachments||[],...d.attachments];p.length&&(r.attachments=p),ci(l,d);const f=[...h,...d.eventProcessors];return(r.data&&!0===r.data.__sentry__?yi(l):Si(f,l,r)).then(e=>(e&&function(e){const t={};if(e.exception?.values?.forEach(e=>{e.stacktrace?.frames?.forEach(e=>{e.debug_id&&(e.abs_path?t[e.abs_path]=e.debug_id:e.filename&&(t[e.filename]=e.debug_id),delete e.debug_id)})}),0===Object.keys(t).length)return;e.debug_meta=e.debug_meta||{},e.debug_meta.images=e.debug_meta.images||[];const r=e.debug_meta.images;Object.entries(t).forEach(([e,t])=>{r.push({type:"sourcemap",code_file:e,debug_id:t})})}(e),"number"==typeof s&&s>0?function(e,t,r){if(!e)return null;const i={...e,...e.breadcrumbs&&{breadcrumbs:e.breadcrumbs.map(e=>({...e,...e.data&&{data:Mt(e.data,t,r)}}))},...e.user&&{user:Mt(e.user,t,r)},...e.contexts&&{contexts:Mt(e.contexts,t,r)},...e.extra&&{extra:Mt(e.extra,t,r)}};e.contexts?.trace&&i.contexts&&(i.contexts.trace=e.contexts.trace,e.contexts.trace.data&&(i.contexts.trace.data=Mt(e.contexts.trace.data,t,r)));e.spans&&(i.spans=e.spans.map(e=>({...e,...e.data&&{data:Mt(e.data,t,r)}})));e.contexts?.flags&&i.contexts&&(i.contexts.flags=Mt(e.contexts.flags,3,r));return i}(e,s,o):e))}function Ai(e){if(e)return function(e){return e instanceof nr||"function"==typeof e}(e)||function(e){return Object.keys(e).some(e=>Pi.includes(e))}(e)?{captureContext:e}:e}const Pi=["user","level","extra","contexts","tags","fingerprint","propagationContext"];function Ii(e,t){return gr().captureException(e,Ai(t))}function Ci(e,t){const r="string"==typeof t?t:void 0,i="string"!=typeof t?{captureContext:t}:void 0;return gr().captureMessage(e,r,i)}function Fi(e,t){return gr().captureEvent(e,t)}function Mi(e,t){yr().setTag(e,t)}function ki(e){const t=yr(),{user:r}=pi(t,gr()),{userAgent:i}=Ie.navigator||{},n=Xt({user:r,...i&&{userAgent:i},...e}),a=t.getSession();return"ok"===a?.status&&Yt(a,{status:"exited"}),Ri(),t.setSession(n),n}function Ri(){const e=yr(),t=gr().getSession()||e.getSession();t&&function(e){let t={};"ok"===e.status&&(t={status:"exited"}),Yt(e,t)}(t),Li(),e.setSession()}function Li(){const e=yr(),t=_r(),r=e.getSession();r&&t&&t.captureSession(r)}function zi(e=!1){e?Ri():Li()}function Bi(e){return"object"==typeof e&&"function"==typeof e.unref&&e.unref(),e}function Oi(e,t,r){return t||`${function(e){return`${function(e){const t=e.protocol?`${e.protocol}:`:"",r=e.port?`:${e.port}`:"";return`${t}//${e.host}${r}${e.path?`/${e.path}`:""}/api/`}(e)}${e.projectId}/envelope/`}(e)}?${function(e,t){const r={sentry_version:"7"};return e.publicKey&&(r.sentry_key=e.publicKey),t&&(r.sentry_client=`${t.name}/${t.version}`),new URLSearchParams(r).toString()}(e,r)}`}const $i=[];function Ni(e){const t=e.defaultIntegrations||[],r=e.integrations;let i;if(t.forEach(e=>{e.isDefaultInstance=!0}),Array.isArray(r))i=[...t,...r];else if("function"==typeof r){const e=r(t);i=Array.isArray(e)?e:[e]}else i=t;return function(e){const t={};return e.forEach(e=>{const{name:r}=e,i=t[r];i&&!i.isDefaultInstance&&e.isDefaultInstance||(t[r]=e)}),Object.values(t)}(i)}function ji(e,t){for(const r of t)r?.afterAllSetup&&r.afterAllSetup(e)}function Vi(e,t,r){if(r[t.name])Pe&&Ne.log(`Integration skipped because it was already installed: ${t.name}`);else{if(r[t.name]=t,$i.includes(t.name)||"function"!=typeof t.setupOnce||(t.setupOnce(),$i.push(t.name)),t.setup&&"function"==typeof t.setup&&t.setup(e),"function"==typeof t.preprocessEvent){const r=t.preprocessEvent.bind(t);e.on("preprocessEvent",(t,i)=>r(t,i,e))}if("function"==typeof t.processEvent){const r=t.processEvent.bind(t),i=Object.assign((t,i)=>r(t,i,e),{id:t.name});e.addEventProcessor(i)}["processSpan","processSegmentSpan"].forEach(r=>{const i=t[r];"function"==typeof i&&e.on(r,r=>i.call(t,r,e))}),Pe&&Ne.log(`Integration installed: ${t.name}`)}}function Ui(){return!("undefined"!=typeof __SENTRY_BROWSER_BUNDLE__&&__SENTRY_BROWSER_BUNDLE__)&&"[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0)}function qi(){return"undefined"!=typeof window&&(!Ui()||function(){const e=Ie.process;return"renderer"===e?.type}())}function Gi(e,t){const r=t?"auto":"never";return[{type:"log",item_count:e.length,content_type:"application/vnd.sentry.items.log+json"},{version:2,...qi()&&{ingest_settings:{infer_ip:r,infer_user_agent:r}},items:e}]}function Zi(e,t){const r=t??function(e){return Wi().get(e)}(e)??[];if(0===r.length)return;const i=e.getOptions(),n=function(e,t,r,i,n){const a={};return t?.sdk&&(a.sdk={name:t.sdk.name,version:t.sdk.version}),r&&i&&(a.dsn=Ir(i)),ei(a,[Gi(e,n)])}(r,i._metadata,i.tunnel,e.getDsn(),e.getDataCollectionOptions().userInfo);Wi().set(e,[]),e.emit("flushLogs"),e.sendEnvelope(n)}function Wi(){return ke("clientToLogBufferMap",()=>/* @__PURE__ */new WeakMap)}function Hi(e,t){const r=t?"auto":"never";return[{type:"trace_metric",item_count:e.length,content_type:"application/vnd.sentry.items.trace-metric+json"},{version:2,...qi()&&{ingest_settings:{infer_ip:r,infer_user_agent:r}},items:e}]}function Xi(e,t){const r=t??function(e){return Yi().get(e)}(e)??[];if(0===r.length)return;const i=e.getOptions(),n=function(e,t,r,i,n){const a={};return t?.sdk&&(a.sdk={name:t.sdk.name,version:t.sdk.version}),r&&i&&(a.dsn=Ir(i)),ei(a,[Hi(e,n)])}(r,i._metadata,i.tunnel,e.getDsn(),e.getDataCollectionOptions().userInfo);Yi().set(e,[]),e.emit("flushMetrics"),e.sendEnvelope(n)}function Yi(){return ke("clientToMetricBufferMap",()=>/* @__PURE__ */new WeakMap)}function Ki(e){const t={trace_id:e.trace_id,span_id:e.span_id,parent_span_id:e.parent_span_id,name:e.description||"",start_timestamp:e.start_timestamp,end_timestamp:e.timestamp||e.start_timestamp,status:e.status&&"ok"!==e.status&&"cancelled"!==e.status?"error":"ok",is_segment:!1,attributes:{...e.data},links:e.links};return r=t,{...r,attributes:mr(r.attributes),links:r.links?.map(e=>({...e,attributes:mr(e.attributes)}))};var r}const Ji=/* @__PURE__ */Symbol.for("SentryBufferFullError");function Qi(e=100){const t=/* @__PURE__ */new Set;function r(e){t.delete(e)}return{get $(){return Array.from(t)},add:function(i){if(!(t.size<e))return _i(Ji);const n=i();return t.add(n),n.then(()=>r(n),()=>r(n)),n},drain:function(e){if(!t.size)return yi(!0);const r=Promise.allSettled(Array.from(t)).then(()=>!0);if(!e)return r;const i=[r,new Promise(t=>Bi(setTimeout(()=>t(!1),e)))];return Promise.race(i)}}}function en(e,{statusCode:t,headers:r},i=At()){const n={...e},a=r?.["x-sentry-rate-limits"],s=r?.["retry-after"];if(a)for(const o of a.trim().split(",")){const[e,t,,,r]=o.split(":",5),a=parseInt(e,10),s=1e3*(isNaN(a)?60:a);if(t)for(const o of t.split(";"))"metric_bucket"===o&&r&&!r.split(";").includes("custom")||(n[o]=i+s);else n.all=i+s}else s?n.all=i+function(e,t=At()){const r=parseInt(`${e}`,10);if(!isNaN(r))return 1e3*r;const i=Date.parse(`${e}`);return isNaN(i)?6e4:i-t}(s,i):429===t&&(n.all=i+6e4);return n}function tn(e,t,r=Qi(e.bufferSize||64)){let i={};return{send:function(n){const a=[];if(ri(n,(t,r)=>{const n=oi(r);!function(e,t,r=At()){return function(e,t){return e[t]||e.all||0}(e,t)>r}(i,n)?a.push(t):e.recordDroppedEvent("ratelimit_backoff",n)}),0===a.length)return Promise.resolve({});const s=ei(n[0],a),o=t=>{!function(e,t){return ri(e,(e,r)=>t.includes(r))}(s,["client_report"])?ri(s,(r,i)=>{e.recordDroppedEvent(t,oi(i))}):Pe&&Ne.warn(`Dropping client report. Will not send outcomes (reason: ${t}).`)};return r.add(()=>t({body:ni(s)}).then(e=>413===e.statusCode?(Pe&&Ne.error("Sentry responded with status code 413. Envelope was discarded due to exceeding size limits."),o("send_error"),e):(Pe&&void 0!==e.statusCode&&(e.statusCode<200||e.statusCode>=300)&&Ne.warn(`Sentry responded with status code ${e.statusCode} to sent event.`),i=en(i,e),e),e=>{throw o("network_error"),Pe&&Ne.error("Encountered error running transport request:",e),e})).then(e=>e,e=>{if(e===Ji)return Pe&&Ne.error("Skipped sending event because buffer is full."),o("queue_overflow"),Promise.resolve({});throw e})},flush:e=>r.drain(e)}}function rn(e){const t=[];e.message&&t.push(e.message);try{const r=e.exception.values[e.exception.values.length-1];r?.value&&(t.push(r.value),r.type&&t.push(`${r.type}: ${r.value}`))}catch{}return t}const nn=["forwarded","-ip","remote-","via","-user"];const an={userInfo:!0,cookies:!0,httpHeaders:{request:!0,response:!0},httpBodies:["incomingRequest","outgoingRequest","incomingResponse","outgoingResponse"],urlQueryParams:!0,graphQL:{document:!0,variables:!0},genAI:{inputs:!0,outputs:!0},databaseQueryData:!0,stackFrameVariables:!0,frameContextLines:5};function sn(e){const t=null!=e.dataCollection?an:!0===e.sendDefaultPii?{userInfo:!0,cookies:!0,httpHeaders:{request:!0,response:!0},httpBodies:["incomingRequest","outgoingRequest","incomingResponse","outgoingResponse"],urlQueryParams:!0,graphQL:{document:!0,variables:!0},genAI:{inputs:!0,outputs:!0},databaseQueryData:!0,stackFrameVariables:!0,frameContextLines:7}:{userInfo:!1,cookies:{deny:nn},httpHeaders:{request:{deny:nn},response:{deny:nn}},httpBodies:[],urlQueryParams:{deny:nn},graphQL:{document:!0,variables:!0},genAI:{inputs:!1,outputs:!1},databaseQueryData:!1,stackFrameVariables:!0,frameContextLines:7};const r=e.dataCollection??{};return{userInfo:r.userInfo??t.userInfo,cookies:r.cookies??t.cookies,httpHeaders:{request:r.httpHeaders?.request??t.httpHeaders.request,response:r.httpHeaders?.response??t.httpHeaders.response},httpBodies:r.httpBodies??t.httpBodies,urlQueryParams:r.urlQueryParams??r.queryParams??t.urlQueryParams,graphQL:{document:r.graphQL?.document??t.graphQL.document,variables:r.graphQL?.variables??t.graphQL.variables},genAI:{inputs:r.genAI?.inputs??t.genAI.inputs,outputs:r.genAI?.outputs??t.genAI.outputs},databaseQueryData:r.databaseQueryData??t.databaseQueryData,stackFrameVariables:r.stackFrameVariables??t.stackFrameVariables,frameContextLines:r.frameContextLines??t.frameContextLines}}const on="Not capturing exception because it's already been captured.",ln="Discarded session because of missing or non-string release",un=/* @__PURE__ */Symbol.for("SentryInternalError"),cn=/* @__PURE__ */Symbol.for("SentryDoNotSendEventError");function hn(e){return{message:e,[un]:!0}}function dn(e){return{message:e,[cn]:!0}}function pn(e){return pt(e)&&un in e}function fn(e){return pt(e)&&cn in e}function mn(e,t,r,i,n){let a,s=0,o=!1;e.on(r,()=>{s=0,clearTimeout(a),o=!1}),e.on(t,t=>{if(s+=i(t),s>=8e5)n(e);else if(!o){const t=e.getOptions()._flushInterval??5e3;t>0&&(o=!0,a=Bi(setTimeout(()=>{n(e)},t)))}}),e.on("flush",()=>{n(e)})}let gn=class{constructor(e){if(this._options=e,this._integrations={},this._numProcessing=0,this._outcomes={},this._hooks={},this._eventProcessors=[],this._promiseBuffer=Qi(e.transportOptions?.bufferSize??64),this._dataCollection=sn(e),e.dsn?this._dsn=Mr(e.dsn):Pe&&Ne.warn("No DSN provided, client will not send events."),this._dsn){const t=Oi(this._dsn,e.tunnel,e._metadata?e._metadata.sdk:void 0);this._transport=e.transport({tunnel:this._options.tunnel,recordDroppedEvent:this.recordDroppedEvent.bind(this),...e.transportOptions,url:t})}this._options.enableLogs=this._options.enableLogs??this._options._experiments?.enableLogs,this._options.enableLogs&&mn(this,"afterCaptureLog","flushLogs",bn,Zi);(this._options.enableMetrics??this._options._experiments?.enableMetrics??!0)&&mn(this,"afterCaptureMetric","flushMetrics",xn,Xi)}captureException(e,t,r){const i=Nt();if(Gt(e))return Pe&&Ne.log(on),i;const n={event_id:i,...t};return this._process(()=>this.eventFromException(e,n).then(e=>this._captureEvent(e,n,r)).then(e=>e),"error"),n.event_id}captureMessage(e,t,r,i){const n={event_id:Nt(),...r},a=ct(e)?e:String(e),s=ht(e),o=s?this.eventFromMessage(a,t,n):this.eventFromException(e,n);return this._process(()=>o.then(e=>this._captureEvent(e,n,i)),s?"unknown":"error"),n.event_id}captureEvent(e,t,r){const i=Nt();if(t?.originalException&&Gt(t.originalException))return Pe&&Ne.log(on),i;const n={event_id:i,...t},a=e.sdkProcessingMetadata||{},s=a.capturedSpanScope,o=a.capturedSpanIsolationScope,l=yn(e.type);return this._process(()=>this._captureEvent(e,n,s||r,o),l),n.event_id}captureSession(e){this.sendSession(e),Yt(e,{init:!1})}getDsn(){return this._dsn}getOptions(){return this._options}getDataCollectionOptions(){return this._dataCollection}getSdkMetadata(){return this._options._metadata}getTransport(){return this._transport}async flush(e){const t=this._transport;if(this.emit("flush"),!t)return!0;const r=await this._isClientDoneProcessing(e),i=await t.flush(e);return r&&i}async close(e){const t=await this.flush(e);return this.getOptions().enabled=!1,this.emit("close"),t}getEventProcessors(){return this._eventProcessors}addEventProcessor(e){this._eventProcessors.push(e)}init(){(this._isEnabled()||this._options.integrations.some(({name:e})=>e.startsWith("Spotlight")))&&this._setupIntegrations()}getIntegrationByName(e){return this._integrations[e]}getIntegrationNames(){return Object.keys(this._integrations)}addIntegration(e){const t=this._integrations[e.name];!t&&e.beforeSetup&&e.beforeSetup(this),Vi(this,e,this._integrations),t||ji(this,[e])}sendEvent(e,t={}){this.emit("beforeSendEvent",e,t);const r=function(e,t){if("transaction"!==e.type||!e.spans?.length||!e.sdkProcessingMetadata?.hasGenAiSpans||!1===t.getOptions().streamGenAiSpans||function(e){return"stream"===e.getOptions().traceLifecycle}(t))return;const r=[],i=[];for(const a of e.spans)a.op?.startsWith("gen_ai.")?r.push(Ki(a)):i.push(a);if(0===r.length)return;e.spans=i;const n=t.getDataCollectionOptions().userInfo?"auto":"never";return[{type:"span",item_count:r.length,content_type:"application/vnd.sentry.items.span.v2+json"},{version:2,...qi()&&{ingest_settings:{infer_ip:n,infer_user_agent:n}},items:r}]}(e,this);let i=ui(e,this._dsn,this._options._metadata,this._options.tunnel);for(const n of t.attachments||[])i=ti(i,ai(n));r&&(i=ti(i,r)),this.sendEnvelope(i).then(t=>this.emit("afterSendEvent",e,t))}sendSession(e){const{release:t,environment:r=Yr}=this._options;if("aggregates"in e){const i=e.attrs||{};if(!i.release&&!t)return void(Pe&&Ne.warn(ln));i.release=i.release||t,i.environment=i.environment||r,e.attrs=i}else{if(!e.release&&!t)return void(Pe&&Ne.warn(ln));e.release=e.release||t,e.environment=e.environment||r}this.emit("beforeSendSession",e);const i=function(e,t,r,i){const n=li(r);return ei({sent_at:new Date(At()).toISOString(),...n&&{sdk:n},...!!i&&t&&{dsn:Ir(t)}},["aggregates"in e?[{type:"sessions"},e]:[{type:"session"},e.toJSON()]])}(e,this._dsn,this._options._metadata,this._options.tunnel);this.sendEnvelope(i)}recordDroppedEvent(e,t,r=1){if(this._options.sendClientReports){const i=`${e}:${t}`;Pe&&Ne.log(`Recording outcome: "${i}"${r>1?` (${r} times)`:""}`),this._outcomes[i]=(this._outcomes[i]||0)+r}}on(e,t){const r=this._hooks[e]=this._hooks[e]||/* @__PURE__ */new Set,i=(...e)=>t(...e);return r.add(i),()=>{r.delete(i)}}emit(e,...t){const r=this._hooks[e];r&&r.forEach(e=>e(...t))}async sendEnvelope(e){if(this.emit("beforeEnvelope",e),this._isEnabled()&&this._transport)try{return await this._transport.send(e)}catch(t){return Pe&&Ne.error("Error while sending envelope:",t),{}}return Pe&&Ne.error("Transport disabled"),{}}registerCleanup(e){}dispose(){}_setupIntegrations(){const{integrations:e}=this._options;this._integrations=function(e,t){const r={};return t.forEach(t=>{t?.beforeSetup&&t.beforeSetup(e)}),t.forEach(t=>{t&&Vi(e,t,r)}),r}(this,e),ji(this,e)}_updateSessionFromEvent(e,t){let r="fatal"===t.level,i=!1;const n=t.exception?.values;if(n){i=!0,r=!1;for(const e of n)if(!1===e.mechanism?.handled){r=!0;break}}const a="ok"===e.status;(a&&0===e.errors||a&&r)&&(Yt(e,{...r&&{status:"crashed"},errors:e.errors||Number(i||r)}),this.captureSession(e))}async _isClientDoneProcessing(e){let t=0;for(;!e||t<e;){if(await new Promise(e=>setTimeout(e,1)),!this._numProcessing)return!0;t++}return!1}_isEnabled(){return!1!==this.getOptions().enabled&&void 0!==this._transport}_prepareEvent(e,t,r,i){const n=this.getOptions(),a=this.getIntegrationNames();return!t.integrations&&a.length&&(t.integrations=a),this.emit("preprocessEvent",e,t),e.type||i.setLastEventId(e.event_id||t.event_id),Ti(n,e,t,r,this,i).then(e=>{if(null===e)return e;this.emit("postprocessEvent",e,t),e.contexts={trace:{...e.contexts?.trace,...vr(r)},...e.contexts};const i=Jr(this,r);return e.sdkProcessingMetadata={dynamicSamplingContext:i,...e.sdkProcessingMetadata},e})}_captureEvent(e,t={},r=gr(),i=yr()){return Pe&&_n(e)&&Ne.log(`Captured error event \`${rn(e)[0]||"<unknown>"}\``),this._processEvent(e,t,r,i).then(e=>e.event_id,e=>{Pe&&(fn(e)?Ne.log(e.message):pn(e)?Ne.warn(e.message):Ne.warn(e))})}_processEvent(e,t,r,i){const n=this.getOptions(),{sampleRate:a}=n,s=vn(e),o=_n(e),l=`before send for type \`${e.type||"error"}\``,u=void 0===a?void 0:function(e){if("boolean"==typeof e)return Number(e);const t="string"==typeof e?parseFloat(e):e;return"number"!=typeof t||isNaN(t)||t<0||t>1?void 0:t}(a);if(o&&"number"==typeof u&&Tt()>u)return this.recordDroppedEvent("sample_rate","error"),_i(dn(`Discarding event because it's not included in the random sample (sampling rate = ${a})`));const c=yn(e.type);return this._prepareEvent(e,t,r,i).then(e=>{if(null===e)throw this.recordDroppedEvent("event_processor",c),dn("An event processor returned `null`, will not send event.");if(!0===t.data?.__sentry__)return e;const r=function(e,t,r,i){const{beforeSend:n,beforeSendTransaction:a,ignoreSpans:s}=t,o=(l=t.beforeSendSpan,!(l&&"function"==typeof l&&"_streamed"in l&&l._streamed)&&t.beforeSendSpan);var l;let u=r;if(_n(u)&&n)return n(u,i);if(vn(u)){if(o||s){const t=function(e){const{trace_id:t,parent_span_id:r,span_id:i,status:n,origin:a,data:s,op:o}=e.contexts?.trace??{};return{data:s??{},description:e.transaction,op:o,parent_span_id:r,span_id:i??"",start_timestamp:e.start_timestamp??0,status:n,timestamp:e.timestamp,trace_id:t??"",origin:a,profile_id:s?.[br],exclusive_time:s?.[wr],measurements:e.measurements,is_segment:!0}}(u);if(s?.length&&Gr({description:t.description,op:t.op,attributes:t.data},s))return null;if(o){const e=o(t);e?u=Kt(r,{type:"transaction",timestamp:(c=e).timestamp,start_timestamp:c.start_timestamp,transaction:c.description,contexts:{trace:{trace_id:c.trace_id,span_id:c.span_id,parent_span_id:c.parent_span_id,op:c.op,status:c.status,origin:c.origin,data:{...c.data,...c.profile_id&&{[br]:c.profile_id},...c.exclusive_time&&{[wr]:c.exclusive_time}}}},measurements:c.measurements}):Vr()}if(u.spans){const t=[],r=u.spans;for(const e of r)if(s?.length&&Gr({description:e.description,op:e.op,attributes:e.data},s))Wr(r,e);else if(o){const r=o(e);r?t.push(r):(Vr(),t.push(e))}else t.push(e);const i=u.spans.length-t.length;i&&e.recordDroppedEvent("before_send","span",i),u.spans=t}}if(a){if(u.spans){const e=u.spans.length;u.sdkProcessingMetadata={...r.sdkProcessingMetadata,spanCountBeforeProcessing:e}}return a(u,i)}}var c;return u}(this,n,e,t);return function(e,t){const r=`${t} must return \`null\` or a valid event.`;if(mt(e))return e.then(e=>{if(!dt(e)&&null!==e)throw hn(r);return e},e=>{throw hn(`${t} rejected with ${e}`)});if(!dt(e)&&null!==e)throw hn(r);return e}(r,l)}).then(n=>{if(null===n){if(this.recordDroppedEvent("before_send",c),s){const t=1+(e.spans||[]).length;this.recordDroppedEvent("before_send","span",t)}throw dn(`${l} returned \`null\`, will not send event.`)}const a=r.getSession()||i.getSession();if(o&&a&&this._updateSessionFromEvent(a,n),s){const e=(n.sdkProcessingMetadata?.spanCountBeforeProcessing||0)-(n.spans?n.spans.length:0);e>0&&this.recordDroppedEvent("before_send","span",e)}const u=n.transaction_info;if(s&&u&&n.transaction!==e.transaction){const e="custom";n.transaction_info={...u,source:e}}return this.sendEvent(n,t),n}).then(null,e=>{if(fn(e)||pn(e))throw e;throw this.captureException(e,{mechanism:{handled:!1,type:"internal"},data:{__sentry__:!0},originalException:e}),hn(`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.\nReason: ${e}`)})}_process(e,t){this._numProcessing++,this._promiseBuffer.add(e).then(e=>(this._numProcessing--,e),e=>(this._numProcessing--,e===Ji&&this.recordDroppedEvent("queue_overflow",t),e))}_clearOutcomes(){const e=this._outcomes;return this._outcomes={},Object.entries(e).map(([e,t])=>{const[r,i]=e.split(":");return{reason:r,category:i,quantity:t}})}_flushOutcomes(){Pe&&Ne.log("Flushing outcomes...");const e=this._clearOutcomes();if(0===e.length)return void(Pe&&Ne.log("No outcomes to send"));if(!this._dsn)return void(Pe&&Ne.log("No dsn provided, will not send outcomes"));Pe&&Ne.log("Sending outcomes:",e);const t=(r=e,ei((i=this._options.tunnel&&Ir(this._dsn))?{dsn:i}:{},[[{type:"client_report"},{timestamp:Zt(),discarded_events:r}]]));var r,i;this.sendEnvelope(t)}};function yn(e){return"replay_event"===e?"replay":e||"error"}function _n(e){return void 0===e.type}function vn(e){return"transaction"===e.type}function xn(e){let t=0;return e.name&&(t+=2*e.name.length),t+=8,t+wn(e.attributes)}function bn(e){let t=0;return e.message&&(t+=2*e.message.length),t+wn(e.attributes)}function wn(e){if(!e)return 0;let t=0;return Object.values(e).forEach(e=>{Array.isArray(e)?t+=e.length*En(e[0]):ht(e)?t+=En(e):t+=100}),t}function En(e){return"string"==typeof e?2*e.length:"number"==typeof e?8:"boolean"==typeof e?4:0}function Sn(e,t){!0===t.debug&&(Pe?Ne.enable():ze(()=>{console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.")}));gr().update(t.initialScope);const r=new e(t);return function(e){gr().setClient(e)}(r),r.init(),r}function Dn(e){if(!e)return{};const t=e.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)return{};const r=t[6]||"",i=t[8]||"";return{host:t[4],path:t[5],protocol:t[2],search:r,hash:i,relative:t[5]+r+i}}function Tn(e){"aggregates"in e?void 0===e.attrs?.ip_address&&(e.attrs={...e.attrs,ip_address:"{{auto}}"}):void 0===e.ipAddress&&(e.ipAddress="{{auto}}")}const An=100;function Pn(e,t){const r=_r(),i=yr();if(!r)return;const{beforeBreadcrumb:n=null,maxBreadcrumbs:a=An}=r.getOptions();if(a<=0)return;const s={timestamp:Zt(),...e},o=n?ze(()=>n(s,t)):s;null!==o&&(r.emit&&r.emit("beforeAddBreadcrumb",o,t),i.addBreadcrumb(o,a))}const In=/* @__PURE__ */new WeakMap,Cn=()=>({name:"FunctionToString",setupOnce(){const e=Function.prototype.toString;try{Function.prototype.toString=function(...t){const r=bt(this);let i;try{In.has(_r())&&void 0!==r&&(i=r)}catch{}return e.apply(i??this,t)}}catch{}},setup(e){In.set(e,!0)}}),Fn=[/^Script error\.?$/,/^Javascript error: Script error\.? on line 0$/,/^ResizeObserver loop completed with undelivered notifications.$/,/^Cannot redefine property: googletag$/,/^Can't find variable: gmo$/,/^undefined is not an object \(evaluating 'a\.[A-Z]'\)$/,/can't redefine non-configurable property "solana"/,/vv\(\)\.getRestrictions is not a function/,/Can't find variable: _AutofillCallbackHandler/,/Object Not Found Matching Id:\d+, MethodName:simulateEvent/,/^Java exception was raised during method invocation$/],Mn=(e={})=>{let t;return{name:"EventFilters",setup(r){const i=r.getOptions();t=Rn(e,i)},processEvent(r,i,n){if(!t){const r=n.getOptions();t=Rn(e,r)}return function(e,t){if(e.type){if("transaction"===e.type&&function(e,t){if(!t?.length)return!1;const r=e.transaction;return!!r&&$t(r,t)}(e,t.ignoreTransactions))return Pe&&Ne.warn(`Event dropped due to being matched by \`ignoreTransactions\` option.\nEvent: ${Vt(e)}`),!0}else{if(function(e,t){if(!t?.length)return!1;return rn(e).some(e=>$t(e,t))}(e,t.ignoreErrors))return Pe&&Ne.warn(`Event dropped due to being matched by \`ignoreErrors\` option.\nEvent: ${Vt(e)}`),!0;if(function(e){if(!e.exception?.values?.length)return!1;return!e.message&&!e.exception.values.some(e=>e.stacktrace||e.type&&"Error"!==e.type||e.value)}(e))return Pe&&Ne.warn(`Event dropped due to not having an error message, error type or stacktrace.\nEvent: ${Vt(e)}`),!0;if(function(e,t){if(!t?.length)return!1;const r=Ln(e);return!!r&&$t(r,t)}(e,t.denyUrls))return Pe&&Ne.warn(`Event dropped due to being matched by \`denyUrls\` option.\nEvent: ${Vt(e)}.\nUrl: ${Ln(e)}`),!0;if(!function(e,t){if(!t?.length)return!0;const r=Ln(e);return!r||$t(r,t)}(e,t.allowUrls))return Pe&&Ne.warn(`Event dropped due to not being matched by \`allowUrls\` option.\nEvent: ${Vt(e)}.\nUrl: ${Ln(e)}`),!0}return!1}(r,t)?null:r}}},kn=(e={})=>({...Mn(e),name:"InboundFilters"});function Rn(e={},t={}){return{allowUrls:[...e.allowUrls||[],...t.allowUrls||[]],denyUrls:[...e.denyUrls||[],...t.denyUrls||[]],ignoreErrors:[...e.ignoreErrors||[],...t.ignoreErrors||[],...e.disableErrorDefaults?[]:Fn],ignoreTransactions:[...e.ignoreTransactions||[],...t.ignoreTransactions||[]]}}function Ln(e){try{const t=[...e.exception?.values??[]].reverse().find(e=>void 0===e.mechanism?.parent_id&&e.stacktrace?.frames?.length),r=t?.stacktrace?.frames;return r?function(e=[]){for(let t=e.length-1;t>=0;t--){const r=e[t];if(r&&"<anonymous>"!==r.filename&&"[native code]"!==r.filename)return r.filename||null}return null}(r):null}catch{return Pe&&Ne.error(`Cannot extract url for event ${Vt(e)}`),null}}function zn(e,t,r,i,n,a){if(!n.exception?.values||!a||!gt(a.originalException,Error))return;const s=n.exception.values.length>0?n.exception.values[n.exception.values.length-1]:void 0;s&&(n.exception.values=Bn(e,t,i,a.originalException,r,n.exception.values,s,0))}function Bn(e,t,r,i,n,a,s,o){if(a.length>=r+1)return a;let l=[...a];if(gt(i[n],Error)){$n(s,o,i);const a=e(t,i[n]),u=l.length;Nn(a,n,u,o),l=Bn(e,t,r,i[n],n,[a,...l],a,u)}return On(i)&&i.errors.forEach((a,u)=>{if(gt(a,Error)){$n(s,o,i);const c=e(t,a),h=l.length;Nn(c,`errors[${u}]`,h,o),l=Bn(e,t,r,a,n,[c,...l],c,h)}}),l}function On(e){return Array.isArray(e.errors)}function $n(e,t,r){e.mechanism={handled:!0,type:"auto.core.linked_errors",...On(r)&&{is_exception_group:!0},...e.mechanism,exception_id:t}}function Nn(e,t,r,i){e.mechanism={handled:!0,...e.mechanism,type:"chained",source:t,exception_id:r,parent_id:i}}function jn(e){return function(e){return at(e)&&"__sentry_fetch_url_host__"in e&&"string"==typeof e.__sentry_fetch_url_host__}(e)?`${e.message} (${e.__sentry_fetch_url_host__})`:e.message}const Vn=/* @__PURE__ */new Set([]);const Un=/* @__PURE__ */new Set;function qn(){"console"in Ie&&Re.forEach(function(e){!Un.has(e)&&e in Ie.console&&(Un.add(e),_t(Ie.console,e,function(t){return Le[e]=t,function(...t){const r=t[0],i=Le[e],n=Vn.size&&"string"==typeof r&&$t(r,Vn);n||Qe("console",{args:t,level:e}),(!n||Pe&&Ne.isEnabled())&&i?.apply(Ie.console,t)}}))})}function Gn(e){return"warn"===e?"warning":["fatal","error","warning","log","info","debug"].includes(e)?e:"log"}const Zn=()=>{let e;return{name:"Dedupe",processEvent(t){if(t.type)return t;try{if(function(e,t){if(!t)return!1;if(function(e,t){const r=e.message,i=t.message;if(!r&&!i)return!1;if(r&&!i||!r&&i)return!1;if(r!==i)return!1;if(!Hn(e,t))return!1;if(!Wn(e,t))return!1;return!0}(e,t))return!0;if(function(e,t){const r=Xn(t),i=Xn(e);if(!r||!i)return!1;if(r.type!==i.type||r.value!==i.value)return!1;if(!Hn(e,t))return!1;if(!Wn(e,t))return!1;return!0}(e,t))return!0;return!1}(t,e))return Pe&&Ne.warn("Event dropped due to being a duplicate of previously captured event."),null}catch{}return e=t}}};function Wn(e,t){let r=He(e),i=He(t);if(!r&&!i)return!0;if(r&&!i||!r&&i)return!1;if(i.length!==r.length)return!1;for(let n=0;n<i.length;n++){const e=i[n],t=r[n];if(e.filename!==t.filename||e.lineno!==t.lineno||e.colno!==t.colno||e.function!==t.function)return!1}return!0}function Hn(e,t){let r=e.fingerprint,i=t.fingerprint;if(!r&&!i)return!0;if(r&&!i||!r&&i)return!1;try{return!(r.join("")!==i.join(""))}catch{return!1}}function Xn(e){return e.exception?.values?.[0]}const Yn=()=>({name:"ConversationId",setup(e){e.on("spanStart",e=>{const t=gr().getScopeData(),r=yr().getScopeData(),i=t.conversationId||r.conversationId;if(i){const{op:t,data:r,description:n}=Or(e);if(!t?.startsWith("gen_ai.")&&!r["ai.operationId"]&&!n?.startsWith("ai."))return;e.setAttribute("gen_ai.conversation.id",i)}})}});function Kn(e){return void 0===e?void 0:e>=400&&e<500?"warning":e>=500?"error":void 0}const Jn=Ie;function Qn(e){return e&&/^function\s+\w+\(\)\s+\{\s+\[native code\]\s+\}$/.test(e.toString())}function ea(){if("string"==typeof EdgeRuntime)return!0;if(!function(){if(!("fetch"in Jn))return!1;try{return new Headers,new Request("data:,"),new Response,!0}catch{return!1}}())return!1;if(Qn(Jn.fetch))return!0;let e=!1;const t=Jn.document;if(t&&"function"==typeof t.createElement)try{const r=t.createElement("iframe");r.hidden=!0,t.head.appendChild(r),r.contentWindow?.fetch&&(e=Qn(r.contentWindow.fetch)),t.head.removeChild(r)}catch(r){Pe&&Ne.warn("Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ",r)}return e}function ta(e,t){const r="fetch",i=Ke(r,e);return Je(r,()=>function(e,t=!1){if(t&&!ea())return;_t(Ie,"fetch",function(e){return function(...t){const r=new Error,{method:i,url:n}=function(e){if(0===e.length)return{method:"GET",url:""};if(2===e.length){const[t,r]=e;return{url:ia(t),method:ra(r,"method")?String(r.method).toUpperCase():yt(t)&&ra(t,"method")?String(t.method).toUpperCase():"GET"}}const t=e[0];return{url:ia(t),method:ra(t,"method")?String(t.method).toUpperCase():"GET"}}(t),a={args:t,fetchData:{method:i,url:n},startTimestamp:1e3*Ht(),virtualError:r,headers:na(t)};return Qe("fetch",{...a}),e.apply(Ie,t).then(async e=>(Qe("fetch",{...a,endTimestamp:1e3*Ht(),response:e}),e),e=>{Qe("fetch",{...a,endTimestamp:1e3*Ht(),error:e}),at(e)&&void 0===e.stack&&(e.stack=r.stack,vt(e,"framesToPop",1));const t=_r(),i=t?.getOptions().enhanceFetchErrorMessages??"always";if(!1!==i&&e instanceof TypeError&&("Failed to fetch"===e.message||"Load failed"===e.message||"NetworkError when attempting to fetch resource."===e.message))try{const t=new URL(a.fetchData.url).host;"always"===i?e.message=`${e.message} (${t})`:vt(e,"__sentry_fetch_url_host__",t)}catch{}throw e})}})}(0,t)),i}function ra(e,t){return pt(e)&&!!e[t]}function ia(e){return"string"==typeof e?e:e?ra(e,"url")?e.url:e.toString?e.toString():"":""}function na(e){const[t,r]=e;try{if("object"==typeof r&&null!==r&&"headers"in r&&r.headers)return new Headers(r.headers);if(yt(t))return new Headers(t.headers)}catch{}}const aa=Ie;function sa(){try{return aa.document.location.href}catch{return""}}const oa=Ie;let la=0;function ua(){return la>0}function ca(e,t={}){if("function"!=typeof e)return e;try{if(Object.prototype.hasOwnProperty.call(e,"__sentry_wrapped__")){const t=e.__sentry_wrapped__;return"function"==typeof t?t:e}if(bt(e))return e}catch{return e}const r=function(...r){Ie._sentryWrappedDepth=(Ie._sentryWrappedDepth||0)+1;try{const i=r.map(e=>ca(e,t));return e.apply(this,i)}catch(i){throw la++,setTimeout(()=>{la--}),function(...e){const t=pr(Fe());if(2===e.length){const[r,i]=e;return r?t.withSetScope(r,i):t.withScope(i)}t.withScope(e[0])}(e=>{e.addEventProcessor(e=>(t.mechanism&&(Ut(e,void 0),qt(e,t.mechanism)),e.extra={...e.extra,arguments:r},e)),Ii(i)}),i}finally{Ie._sentryWrappedDepth=(Ie._sentryWrappedDepth||0)-1}};try{for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t])}catch{}xt(r,e),vt(e,"__sentry_wrapped__",r);try{Object.getOwnPropertyDescriptor(r,"name").configurable&&Object.defineProperty(r,"name",{get:()=>e.name})}catch{}return r}function ha(){const e=sa(),{referrer:t}=oa.document||{},{userAgent:r}=oa.navigator||{};return{url:e,headers:{...t&&{Referer:t},...r&&{"User-Agent":r}}}}function da(e,t){const r=ma(e,t),i={type:_a(t),value:va(t)};return r.length&&(i.stacktrace={frames:r}),void 0===i.type&&""===i.value&&(i.value="Unrecoverable error caught"),i}function pa(e,t,r,i){const n=_r(),a=n?.getOptions().normalizeDepth,s=(o=t,Object.values(o).find(e=>e instanceof Error));var o;const l={__serialized__:kt(t,a)};if(s)return{exception:{values:[da(e,s)]},extra:l};const u={exception:{values:[{type:ft(t)?t.constructor.name:i?"UnhandledRejection":"Error",value:wa(t,{isUnhandledRejection:i})}]},extra:l};if(r){const t=ma(e,r);t.length&&(u.exception.values[0].stacktrace={frames:t})}return u}function fa(e,t){return{exception:{values:[da(e,t)]}}}function ma(e,t){const r=t.stacktrace||t.stack||"",i=function(e){if(e&&ga.test(e.message))return 1;return 0}(t),n=function(e){if("number"==typeof e.framesToPop)return e.framesToPop;return 0}(t);try{return e(r,i,n)}catch{}return[]}const ga=/Minified React error #\d+;/i;function ya(e){return"undefined"!=typeof WebAssembly&&void 0!==WebAssembly.Exception&&e instanceof WebAssembly.Exception}function _a(e){const t=e?.name;if(!t&&ya(e)){return e.message&&Array.isArray(e.message)&&2==e.message.length?e.message[0]:"WebAssembly.Exception"}return t}function va(e){const t=e?.message;return ya(e)?Array.isArray(e.message)&&2==e.message.length?e.message[1]:"wasm exception":t?t.error&&"string"==typeof t.error.message?jn(t.error):jn(e):"No error message"}function xa(e,t,r,i,n){let a;if(ot(t)&&t.error){return fa(e,t.error)}if(lt(t)||st(t,"DOMException")){const n=t;if("stack"in t){a=fa(e,t);const n=a.exception?.values?.[0];if(i&&r&&n&&!n.stacktrace){const t=ma(e,r);t.length&&(n.stacktrace={frames:t},qt(a,{synthetic:!0}))}}else{const t=n.name||(lt(n)?"DOMError":"DOMException"),s=n.message?`${t}: ${n.message}`:t;a=ba(e,s,r,i),Ut(a,s)}return"code"in n&&(a.tags={...a.tags,"DOMException.code":`${n.code}`}),a}if(at(t))return fa(e,t);if(dt(t)||ft(t)){return a=pa(e,t,r,n),qt(a,{synthetic:!0}),a}return a=ba(e,t,r,i),Ut(a,`${t}`),qt(a,{synthetic:!0}),a}function ba(e,t,r,i){const n={};if(i&&r){const i=ma(e,r);i.length&&(n.exception={values:[{value:t,stacktrace:{frames:i}}]}),qt(n,{synthetic:!0})}if(ct(t)){const{__sentry_template_string__:e,__sentry_template_values__:r}=t;return n.logentry={message:e,params:r},n}return n.message=t,n}function wa(e,{isUnhandledRejection:t}){const r=function(e){const t=Object.keys(wt(e));return t.sort(),t[0]?t.join(", "):"[object has no keys]"}(e),i=t?"promise rejection":"exception";if(ot(e))return`Event \`ErrorEvent\` captured as ${i} with message \`${e.message}\``;if(ft(e)){return`Event \`${function(e){try{const t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}(e)}\` (type=${e.type}) captured as ${i}`}return`Object captured as ${i} with keys: ${r}`}let Ea=class extends gn{constructor(e){const t=(r=e,{release:"string"==typeof __SENTRY_RELEASE__?__SENTRY_RELEASE__:oa.SENTRY_RELEASE?.id,sendClientReports:!0,parentSpanIsAlwaysRootSpan:!0,...r});var r;!function(e,t,r=[t],i="npm"){const n=(e._metadata=e._metadata||{}).sdk=e._metadata.sdk||{};n.name||(n.name=`sentry.javascript.${t}`,n.packages=r.map(e=>({name:`${i}:@sentry/${e}`,version:Ce})),n.version=Ce)}(t,"browser",["browser"],oa.SENTRY_SDK_SOURCE||"npm"),super(t);const{userInfo:i}=this.getDataCollectionOptions();t._metadata?.sdk&&(t._metadata.sdk.settings={infer_ip:i?"auto":"never",...t._metadata.sdk.settings});const{sendClientReports:n}=this._options;oa.document&&oa.document.addEventListener("visibilitychange",()=>{"hidden"===oa.document.visibilityState&&(n&&this._flushOutcomes(),queueMicrotask(()=>{this.flush()}))}),i&&this.on("beforeSendSession",Tn)}eventFromException(e,t){return function(e,t,r,i){const n=xa(e,t,r?.syntheticException||void 0,i);return qt(n),n.level="error",r?.event_id&&(n.event_id=r.event_id),yi(n)}(this._options.stackParser,e,t,this._options.attachStacktrace)}eventFromMessage(e,t="info",r){return function(e,t,r="info",i,n){const a=ba(e,t,i?.syntheticException||void 0,n);return a.level=r,i?.event_id&&(a.event_id=i.event_id),yi(a)}(this._options.stackParser,e,t,r,this._options.attachStacktrace)}_prepareEvent(e,t,r,i){return e.platform=e.platform||"javascript",super._prepareEvent(e,t,r,i)}};const Sa="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,Da=Ie;function Ta(e,t,r){Da.document&&Da.addEventListener(e,t,r)}function Aa(e,t,r){Da.document&&Da.removeEventListener(e,t,r)}const Pa={};try{"undefined"!=typeof Node&&(Pa.parentNode=Object.getOwnPropertyDescriptor(Node.prototype,"parentNode").get),"undefined"!=typeof Element&&(Pa.tagName=Object.getOwnPropertyDescriptor(Element.prototype,"tagName").get,Pa.id=Object.getOwnPropertyDescriptor(Element.prototype,"id").get,Pa.className=Object.getOwnPropertyDescriptor(Element.prototype,"className").get,Pa.getAttribute=Element.prototype.getAttribute),"undefined"!=typeof HTMLElement&&(Pa.dataset=Object.getOwnPropertyDescriptor(HTMLElement.prototype,"dataset").get)}catch{}function Ia(e,t,r){const i=Pa[t];if(i)try{return i.call(e,r)}catch{}const n=e[t];return"function"==typeof n?n.call(e,r):n}function Ca(e,t={}){if(!e)return"<unknown>";try{let r=e;const i=5,n=[];let a=0,s=0;const o=" > ",l=o.length;let u;const c=Array.isArray(t)?t:t.keyAttrs,h=!Array.isArray(t)&&t.maxStringLength||80;for(;r&&a++<i&&(u=Fa(r,c),!("html"===u||a>1&&s+n.length*l+u.length>=h));)n.push(u),s+=u.length,r=Ia(r,"parentNode");return n.reverse().join(o)}catch{return"<unknown>"}}function Fa(e,t){const r=[],i=Ia(e,"tagName");if(!i)return"";if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement){const t=Ia(e,"dataset");if(t){if(t.sentryComponent)return t.sentryComponent;if(t.sentryElement)return t.sentryElement}}r.push(i.toLowerCase());const n=t?.length?t.filter(t=>Ia(e,"getAttribute",t)).map(t=>[t,Ia(e,"getAttribute",t)]):null;if(n?.length)n.forEach(e=>{r.push(`[${e[0]}="${e[1]}"]`)});else{const t=Ia(e,"id");t&&r.push(`#${t}`);const i=Ia(e,"className");if(i&&ut(i)){const e=i.split(/\s+/);for(const t of e)r.push(`.${t}`)}}for(const a of["aria-label","type","name","title","alt"]){const t=Ia(e,"getAttribute",a);t&&r.push(`[${a}="${t}"]`)}return r.join("")}let Ma,ka,Ra,La;function za(){if(!Da.document)return;const e=Qe.bind(null,"dom"),t=Ba(e,!0);Da.document.addEventListener("click",t,!1),Da.document.addEventListener("keypress",t,!1),["EventTarget","Node"].forEach(t=>{const r=Da,i=r[t]?.prototype;i?.hasOwnProperty?.("addEventListener")&&(_t(i,"addEventListener",function(t){return function(r,i,n){if("click"===r||"keypress"==r)try{const i=this.__sentry_instrumentation_handlers__=this.__sentry_instrumentation_handlers__||{},a=i[r]=i[r]||{refCount:0};if(!a.handler){const i=Ba(e);a.handler=i,t.call(this,r,i,n)}a.refCount++}catch{}return t.call(this,r,i,n)}}),_t(i,"removeEventListener",function(e){return function(t,r,i){if("click"===t||"keypress"==t)try{const r=this.__sentry_instrumentation_handlers__||{},n=r[t];n&&(n.refCount--,n.refCount<=0&&(e.call(this,t,n.handler,i),n.handler=void 0,delete r[t]),0===Object.keys(r).length&&delete this.__sentry_instrumentation_handlers__)}catch{}return e.call(this,t,r,i)}}))})}function Ba(e,t=!1){return r=>{if(!r||r._sentryCaptured)return;const i=function(e){try{return e.target}catch{return null}}(r);if(function(e,t){return"keypress"===e&&(!t?.tagName||"INPUT"!==t.tagName&&"TEXTAREA"!==t.tagName&&!t.isContentEditable)}(r.type,i))return;vt(r,"_sentryCaptured",!0),i&&!i._sentryId&&vt(i,"_sentryId",Nt());const n="keypress"===r.type?"input":r.type;if(!function(e){if(e.type!==ka)return!1;try{if(!e.target||e.target._sentryId!==Ra)return!1}catch{}return!0}(r)){e({event:r,name:n,global:t}),ka=r.type,Ra=i?i._sentryId:void 0}clearTimeout(Ma),Ma=Da.setTimeout(()=>{Ra=void 0,ka=void 0},1e3)}}function Oa(e){const t="history";Ke(t,e),Je(t,$a)}function $a(){function e(e){return function(...t){const r=t.length>2?t[2]:void 0;if(r){const i=La,n=function(e){try{return new URL(e,Da.location.origin).toString()}catch{return e}}(String(r));if(La=n,i===n)return e.apply(this,t);Qe("history",{from:i,to:n})}return e.apply(this,t)}}Da.addEventListener("popstate",()=>{const e=Da.location.href,t=La;if(La=e,t===e)return;Qe("history",{from:t,to:e})}),"history"in Jn&&Jn.history&&(_t(Da.history,"pushState",e),_t(Da.history,"replaceState",e))}const Na={};const ja="__sentry_xhr_v3__";function Va(){if(!Da.XMLHttpRequest)return;const e=XMLHttpRequest.prototype;e.open=new Proxy(e.open,{apply(e,t,r){const i=new Error,n=1e3*Ht(),a=ut(r[0])?r[0].toUpperCase():void 0,s=function(e){if(ut(e))return e;try{return e.toString()}catch{}return}(r[1]);if(!a||!s)return e.apply(t,r);t[ja]={method:a,url:s,request_headers:{}},"POST"===a&&s.match(/sentry_key/)&&(t.__sentry_own_request__=!0);const o=()=>{const e=t[ja];if(e&&4===t.readyState){try{e.status_code=t.status}catch{}Qe("xhr",{endTimestamp:1e3*Ht(),startTimestamp:n,xhr:t,virtualError:i}),t.removeEventListener("readystatechange",o)}};return"onreadystatechange"in t&&"function"==typeof t.onreadystatechange?t.onreadystatechange=new Proxy(t.onreadystatechange,{apply:(e,t,r)=>(o(),e.apply(t,r))}):t.addEventListener("readystatechange",o),t.setRequestHeader=new Proxy(t.setRequestHeader,{apply(e,t,r){const[i,n]=r,a=t[ja];return a&&ut(i)&&ut(n)&&(a.request_headers[i.toLowerCase()]=n),e.apply(t,r)}}),e.apply(t,r)}}),e.send=new Proxy(e.send,{apply(e,t,r){const i=t[ja];if(!i)return e.apply(t,r);void 0!==r[0]&&(i.body=r[0]);return Qe("xhr",{startTimestamp:1e3*Ht(),xhr:t}),e.apply(t,r)}})}function Ua(e,t=function(e){const t=Na[e];if(t)return t;let r=Da[e];if(Qn(r))return Na[e]=r.bind(Da);const i=Da.document;if(i&&"function"==typeof i.createElement)try{const t=i.createElement("iframe");t.hidden=!0,i.head.appendChild(t);const n=t.contentWindow;n?.[e]&&(r=n[e]),i.head.removeChild(t)}catch(gd){Sa&&Ne.warn(`Could not create sandbox iframe for ${e} check, bailing to window.${e}: `,gd)}return r?Na[e]=r.bind(Da):r}("fetch")){let r=0,i=0;return tn(e,async function(n){const a=n.body.length;r+=a,i++;const s={body:n.body,method:"POST",referrerPolicy:"strict-origin",headers:e.headers,keepalive:r<=6e4&&i<15,...e.fetchOptions};try{const r=await t(e.url,s);return{statusCode:r.status,headers:{"x-sentry-rate-limits":r.headers.get("X-Sentry-Rate-Limits"),"retry-after":r.headers.get("Retry-After")}}}catch(gd){throw Na["fetch"]=void 0,gd}finally{r-=a,i--}},Qi(e.bufferSize||40))}const qa="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__;function Ga(e,t,r,i){const n={filename:e,function:"<anonymous>"===t?je:t,in_app:!0};return void 0!==r&&(n.lineno=r),void 0!==i&&(n.colno=i),n}const Za=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Wa=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Ha=/\((\S*)(?::(\d+))(?::(\d+))\)/,Xa=/at (.+?) ?\(data:(.+?),/,Ya=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Ka=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Ja=qe(...[[30,e=>{const t=e.match(Xa);if(t)return{filename:`<data:${t[2]}>`,function:t[1]};const r=Za.exec(e);if(r){const[,e,t,i]=r;return Ga(e,je,+t,+i)}const i=Wa.exec(e);if(i){if(0===i[2]?.indexOf("eval")){const e=Ha.exec(i[2]);e&&(i[2]=e[1],i[3]=e[2],i[4]=e[3])}const[e,t]=Qa(i[1]||je,i[2]);return Ga(t,e,i[3]?+i[3]:void 0,i[4]?+i[4]:void 0)}}],[50,e=>{const t=Ya.exec(e);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){const e=Ka.exec(t[3]);e&&(t[1]=t[1]||"eval",t[3]=e[1],t[4]=e[2],t[5]="")}let e=t[3],r=t[1]||je;return[r,e]=Qa(r,e),Ga(e,r,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}}]]),Qa=(e,t)=>{const r=-1!==e.indexOf("safari-extension"),i=-1!==e.indexOf("safari-web-extension");return r||i?[-1!==e.indexOf("@")?e.split("@")[0]:je,r?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]},es=1024,ts=(e={})=>{const t={console:!0,dom:!0,fetch:!0,history:!0,sentry:!0,xhr:!0,...e};return{name:"Breadcrumbs",setup(e){var r;t.console&&function(e){const t="console",r=Ke(t,e);Je(t,qn)}(function(e){return function(t){if(_r()!==e)return;const r={category:"console",data:{arguments:t.args,logger:"console"},level:Gn(t.level),message:Bt(t.args," ")};if("assert"===t.level){if(!1!==t.args[0])return;r.message=`Assertion failed: ${Bt(t.args.slice(1)," ")||"console.assert"}`,r.data.arguments=t.args.slice(1)}Pn(r,{input:t.args,level:t.level})}}(e)),t.dom&&(r=function(e,t){return function(r){if(_r()!==e)return;let i,n,a="object"==typeof t?t.serializeAttribute:void 0,s="object"==typeof t&&"number"==typeof t.maxStringLength?t.maxStringLength:void 0;s&&s>es&&(qa&&Ne.warn(`\`dom.maxStringLength\` cannot exceed 1024, but a value of ${s} was configured. Sentry will use 1024 instead.`),s=es),"string"==typeof a&&(a=[a]);try{const e=r.event,t=function(e){return!!e&&!!e.target}(e)?e.target:e;i=Ca(t,{keyAttrs:a,maxStringLength:s}),n=function(e,t=5){if(!aa.HTMLElement)return null;let r=e;for(let i=0;i<t;i++){if(!r)return null;if(r instanceof HTMLElement){if(r.dataset.sentryComponent)return r.dataset.sentryComponent;if(r.dataset.sentryElement)return r.dataset.sentryElement}r=r.parentNode}return null}(t)}catch{i="<unknown>"}if(0===i.length)return;const o={category:`ui.${r.name}`,message:i};n&&(o.data={"ui.component_name":n}),Pn(o,{event:r.event,name:r.name,global:r.global})}}(e,t.dom),Ke("dom",r),Je("dom",za)),t.xhr&&function(e){Ke("xhr",e),Je("xhr",Va)}(function(e){return function(t){if(_r()!==e)return;const{startTimestamp:r,endTimestamp:i}=t,n=t.xhr[ja];if(!r||!i||!n)return;const{method:a,url:s,status_code:o,body:l}=n,u={method:a,url:s,status_code:o},c={xhr:t.xhr,input:l,startTimestamp:r,endTimestamp:i},h={category:"xhr",data:u,type:"http",level:Kn(o)};e.emit("beforeOutgoingRequestBreadcrumb",h,c),Pn(h,c)}}(e)),t.fetch&&ta(function(e){return function(t){if(_r()!==e)return;const{startTimestamp:r,endTimestamp:i}=t;if(i&&(!t.fetchData.url.match(/sentry_key/)||"POST"!==t.fetchData.method))if(t.error){const n={data:t.error,input:t.args,startTimestamp:r,endTimestamp:i},a={category:"fetch",data:t.fetchData,level:"error",type:"http"};e.emit("beforeOutgoingRequestBreadcrumb",a,n),Pn(a,n)}else{const n=t.response,a={...t.fetchData,status_code:n?.status},s={input:t.args,response:n,startTimestamp:r,endTimestamp:i},o={category:"fetch",data:a,type:"http",level:Kn(a.status_code)};e.emit("beforeOutgoingRequestBreadcrumb",o,s),Pn(o,s)}}}(e)),t.history&&Oa(function(e){return function(t){if(_r()!==e)return;let r=t.from,i=t.to;const n=Dn(oa.location.href);let a=r?Dn(r):void 0;const s=Dn(i);a?.path||(a=n),n.protocol===s.protocol&&n.host===s.host&&(i=s.relative),n.protocol===a.protocol&&n.host===a.host&&(r=a.relative),Pn({category:"navigation",data:{from:r,to:i}})}}(e)),t.sentry&&e.on("beforeSendEvent",function(e){return function(t){_r()===e&&Pn({category:"sentry."+("transaction"===t.type?"transaction":"event"),event_id:t.event_id,level:t.level,message:Vt(t)},{event:t})}}(e))}}};const rs="EventTarget,Window,Node,ApplicationCache,AudioTrackList,BroadcastChannel,ChannelMergerNode,CryptoOperation,EventSource,FileReader,HTMLUnknownElement,IDBDatabase,IDBRequest,IDBTransaction,KeyOperation,MediaController,MessagePort,ModalWindow,Notification,SVGElementInstance,Screen,SharedWorker,TextTrack,TextTrackCue,TextTrackList,WebSocket,WebSocketWorker,Worker,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload".split(","),is=(e={})=>{const t={XMLHttpRequest:!0,eventTarget:!0,requestAnimationFrame:!0,setInterval:!0,setTimeout:!0,unregisterOriginalCallbacks:!1,...e};return{name:"BrowserApiErrors",setupOnce(){t.setTimeout&&_t(oa,"setTimeout",ns),t.setInterval&&_t(oa,"setInterval",ns),t.requestAnimationFrame&&_t(oa,"requestAnimationFrame",as),t.XMLHttpRequest&&"XMLHttpRequest"in oa&&_t(XMLHttpRequest.prototype,"send",ss);const e=t.eventTarget;if(e){(Array.isArray(e)?e:rs).forEach(e=>function(e,t){const r=oa,i=r[e]?.prototype;if(!i?.hasOwnProperty?.("addEventListener"))return;_t(i,"addEventListener",function(r){return function(i,n,a){try{"function"==typeof n.handleEvent&&(n.handleEvent=ca(n.handleEvent,{mechanism:{data:{handler:We(n),target:e},handled:!1,type:"auto.browser.browserapierrors.handleEvent"}}))}catch{}return t.unregisterOriginalCallbacks&&function(e,t,r){e&&"object"==typeof e&&"removeEventListener"in e&&"function"==typeof e.removeEventListener&&e.removeEventListener(t,r)}(this,i,n),r.apply(this,[i,ca(n,{mechanism:{data:{handler:We(n),target:e},handled:!1,type:"auto.browser.browserapierrors.addEventListener"}}),a])}}),_t(i,"removeEventListener",function(e){return function(t,r,i){try{if(Object.prototype.hasOwnProperty.call(r,"__sentry_wrapped__")){const n=r.__sentry_wrapped__;n&&e.call(this,t,n,i)}}catch{}return e.call(this,t,r,i)}})}(e,t))}}}};function ns(e){return function(...t){const r=t[0];return t[0]=ca(r,{mechanism:{handled:!1,type:`auto.browser.browserapierrors.${We(e)}`}}),e.apply(this,t)}}function as(e){return function(t){return e.apply(this,[ca(t,{mechanism:{data:{handler:We(e)},handled:!1,type:"auto.browser.browserapierrors.requestAnimationFrame"}})])}}function ss(e){return function(...t){const r=this;return["onload","onerror","onprogress","onreadystatechange"].forEach(e=>{e in r&&"function"==typeof r[e]&&_t(r,e,function(t){const r={mechanism:{data:{handler:We(t)},handled:!1,type:`auto.browser.browserapierrors.xhr.${e}`}},i=bt(t);return i&&(r.mechanism.data.handler=We(i)),ca(t,r)})}),e.apply(this,t)}}const os=(e={})=>{const t=e.lifecycle??"route";return{name:"BrowserSession",setupOnce(){if(void 0===oa.document)return void(qa&&Ne.warn("Using the `browserSessionIntegration` in non-browser environments is not supported."));ki({ignoreDuration:!0});let e=!1;(e=>{const t=Da.requestIdleCallback||Da.setTimeout;"hidden"===Da.document?.visibilityState?e():(Ta("visibilitychange",e=(e=>{let t=!1;return()=>{t||(e(),t=!0)}})(e),{once:!0,capture:!0}),Ta("pagehide",e,{once:!0,capture:!0}),t(()=>{e(),Aa("visibilitychange",e,{capture:!0}),Aa("pagehide",e,{capture:!0})}))})(()=>{e||(zi(),e=!0)});const r=yr();let i=r.getUser();r.addScopeListener(t=>{const r=t.getUser();i?.id===r?.id&&i?.ip_address===r?.ip_address||(i=r,e&&zi())}),"route"===t&&Oa(({from:t,to:r})=>{t!==r&&(ki({ignoreDuration:!0}),zi(),e=!0)})}}},ls=()=>({name:"CultureContext",preprocessEvent(e){const t=us();t&&(e.contexts={...e.contexts,culture:{...t,...e.contexts?.culture}})},processSegmentSpan(e){const t=us();t&&gi(e,{"culture.locale":t.locale,"culture.timezone":t.timezone,"culture.calendar":t.calendar})}});function us(){try{const e=oa.Intl;if(!e)return;const t=e.DateTimeFormat().resolvedOptions();return{locale:t.locale,timezone:t.timeZone,calendar:t.calendar}}catch{return}}const cs=(e={})=>{const t={onerror:!0,onunhandledrejection:!0,...e};return{name:"GlobalHandlers",setupOnce(){Error.stackTraceLimit=50},setup(e){t.onerror&&(!function(e){!function(e){const t="error";Ke(t,e),Je(t,tt)}(t=>{const{stackParser:r,attachStacktrace:i}=ds();if(_r()!==e||ua())return;const{msg:n,url:a,line:s,column:o,error:l}=t,u=function(e,t,r,i){const n=e.exception=e.exception||{},a=n.values=n.values||[],s=a[0]=a[0]||{},o=s.stacktrace=s.stacktrace||{},l=o.frames=o.frames||[];0===l.length&&l.push({colno:i,lineno:r,filename:ps(t)??sa(),function:je,in_app:!0});return e}(xa(r,l||n,void 0,i,!1),a,s,o);u.level="error",Fi(u,{originalException:l,mechanism:{handled:!1,type:"auto.browser.global_handlers.onerror"}})})}(e),hs("onerror")),t.onunhandledrejection&&(!function(e){!function(e){const t="unhandledrejection";Ke(t,e),Je(t,it)}(t=>{const{stackParser:r,attachStacktrace:i}=ds();if(_r()!==e||ua())return;const n=function(e){if(ht(e))return e;try{if("reason"in e)return e.reason;if("detail"in e&&"reason"in e.detail)return e.detail.reason}catch{}return e}(t),a=ht(n)?{exception:{values:[{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(n)}`}]}}:xa(r,n,void 0,i,!0);a.level="error",Fi(a,{originalException:n,mechanism:{handled:!1,type:"auto.browser.global_handlers.onunhandledrejection"}})})}(e),hs("onunhandledrejection"))}}};function hs(e){qa&&Ne.log(`Global Handler attached: ${e}`)}function ds(){const e=_r();return e?.getOptions()||{stackParser:()=>[],attachStacktrace:!1}}function ps(e){if(ut(e)&&0!==e.length)return e.startsWith("data:")?`<${function(e,t=!0){if(e.startsWith("data:")){const r=e.match(/^data:([^;,]+)/),i=r?r[1]:"text/plain",n=e.includes(";base64,"),a=e.indexOf(",");let s="";if(t&&-1!==a){const t=e.slice(a+1);s=t.length>10?`${t.slice(0,10)}... [truncated]`:t}return`data:${i}${n?",base64":""}${s?`,${s}`:""}`}return e}(e,!1)}>`:e}const fs=()=>({name:"HttpContext",preprocessEvent(e){if(!oa.navigator&&!oa.location&&!oa.document)return;const t=ha(),r={...t.headers,...e.request?.headers};e.request={...t,...e.request,headers:r}},processSegmentSpan(e){const t=e.attributes?.[xr];if(!oa.navigator&&!oa.location&&!oa.document)return;const r=ha();gi(e,{[fi]:"http.client"!==t?r.url:void 0,"http.request.header.user_agent":r.headers["User-Agent"],"http.request.header.referer":r.headers.Referer})}}),ms=(e={})=>{const t=e.limit||5,r=e.key||"cause";return{name:"LinkedErrors",preprocessEvent(e,i,n){zn(da,n.getOptions().stackParser,r,t,e,i)}}},gs=/^HTML(\w*)Element$/;function ys(e){if("undefined"!=typeof window&&e===window)return"[Window]";if("undefined"!=typeof document&&e===document)return"[Document]";if(function(e){if("undefined"==typeof Element)return!1;try{return e instanceof Element}catch{return!1}}(e)){const t=function(e){const t=Object.getPrototypeOf(e);return t?.constructor?t.constructor.name:"null prototype"}(e);if(gs.test(t))return`[HTMLElement: ${Ca(e)}]`}}function _s(){return!!function(){if(void 0===oa.window)return!1;const e=oa;if(e.nw)return!1;const t=e.chrome||e.browser;if(!t?.runtime?.id)return!1;const r=sa();return!(oa===oa.top&&/^(?:chrome-extension|moz-extension|ms-browser-extension|safari-web-extension):\/\//.test(r))}()&&(qa&&ze(()=>{console.error("[Sentry] You cannot use Sentry.init() in a browser extension, see: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/")}),!0)}function vs(e={}){const t=!e.skipBrowserExtensionCheck&&_s();let r=null==e.defaultIntegrations?[kn(),Cn(),Yn(),is(),ts(),cs(),ms(),Zn(),fs(),ls(),os()]:e.defaultIntegrations;const i={...e,enabled:!t&&e.enabled,stackParser:(n=e.stackParser||Ja,Array.isArray(n)?qe(...n):n),integrations:Ni({integrations:e.integrations,defaultIntegrations:r}),transport:e.transport||Ua};var n;return Ct=ys,Sn(Ea,i)}class xs{constructor(){this.initialized=!1}static initialize(e){const t=xs.getInstance();if(t.initialized)return void Mi("component",e);vs({dsn:"https://98a864152051bb3d42f8e955f2ab3078@sentry.mapvx.app/6",environment:"production",release:"0.9.0-dev.3"}),Mi("component",e),t.initialized=!0}static getInstance(){return xs.instance||(xs.instance=new xs),xs.instance}error(e,t){Ii(e,t?{extra:t}:void 0)}info(e,t){Ci(e,{level:"info",extra:t})}warning(e,t){Ci(e,{level:"warning",extra:t})}critical(e,t){Ci(e,{level:"fatal",extra:t})}}
|
|
40
|
+
*/const de=e=>e??G,pe=()=>import("./custom-map-D5CN1bK4.js"),fe=()=>import("./floor-selector-Dl4c0hkj.js"),me=()=>import("./compact-floor-selector-Cn32jNQ1.js"),ge=()=>import("./qr-modal-CcTW0MC4.js"),ye=()=>import("./route-options-JdoUif98.js"),_e=async()=>{try{await import("./styles-DLXHFhZH.js")}catch{}};class ve{constructor(){this.MEASUREMENT_ID="G-6XL8YD35QR",this.isInitialized=!1,this.sessionId=""}static getInstance(){return ve.instance||(ve.instance=new ve),ve.instance}generateSessionId(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}initialize(e){if(this.isInitialized)return;ve.component=e,this.sessionId=this.generateSessionId();const t=document.createElement("script");t.async=!0,t.src=`https://www.googletagmanager.com/gtag/js?id=${this.MEASUREMENT_ID}`,document.head.appendChild(t),window.dataLayer=window.dataLayer||[];window.gtag=window.gtag||((...e)=>{window.dataLayer.push(e)}),window.gtag("js",/* @__PURE__ */new Date),window.gtag("config",this.MEASUREMENT_ID,{send_page_view:!0,groups:"mapvx"}),this.isInitialized=!0}resetSessionId(){this.sessionId=this.generateSessionId()}trackPageView(e){this.isInitialized&&window.gtag("event","page_view",{page_title:e,page_location:window.location.href,page_path:e,component:ve.component,session_id:this.sessionId,send_to:"mapvx"})}trackEvent(e,t){this.isInitialized&&window.gtag("event",e,{...t,component:ve.component,session_id:this.sessionId,send_to:"mapvx"})}trackUserTiming(e,t,r){this.isInitialized&&window.gtag("event","timing_complete",{name:t,value:r,event_category:e,component:ve.component,session_id:this.sessionId,send_to:"mapvx"})}trackException(e,t=!1){this.isInitialized&&window.gtag("event","exception",{description:e,fatal:t,component:ve.component,session_id:this.sessionId,send_to:"mapvx"})}}const xe="/mvx-tiles-sw.js",be="/",we="https://tiles.mapvx.com/tiles";async function Ee(){if(!("serviceWorker"in navigator))return;const e=navigator.serviceWorker.ready;e&&await e.catch(()=>{})}async function Se(e=xe,t="/"){if("undefined"==typeof navigator||!("serviceWorker"in navigator))return null;try{return await navigator.serviceWorker.register(e,{scope:t})}catch{return null}}function De(e,t){if(!e?.active)return;const r=t.apiKey?.trim()??"",i=t.placeId?.trim()??"";""!==r&&""!==i&&e.active.postMessage({type:"INITIAL_TILE_LOAD",apiKey:r,placeId:i,tilesBaseUrl:t.tilesBaseUrl??we})}function Te(e,t,r=864e5){if(!e)return()=>{};const i=window.setInterval(()=>{if(!e.active)return;const r=t.apiKey?.trim()??"",i=t.placeId?.trim()??"";""!==r&&""!==i&&e.active.postMessage({type:"REFRESH_TILES",apiKey:r,placeId:i,tilesBaseUrl:t.tilesBaseUrl??we})},r);return()=>window.clearInterval(i)}async function Ae(e){const t=await Se(e.swPath,e.swScope);await Ee(),De(t,e);return{registration:t,stopPeriodicRefresh:e.enablePeriodicRefresh?Te(t,e):()=>{}}}const Pe="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,Ie=globalThis,Ce="10.68.0";function Fe(){return Me(Ie),Ie}function Me(e){const t=e.__SENTRY__=e.__SENTRY__||{};return t.version=t.version||Ce,t[Ce]=t[Ce]||{}}function ke(e,t,r=Ie){const i=r.__SENTRY__=r.__SENTRY__||{},n=i[Ce]=i[Ce]||{};return n[e]||(n[e]=t())}const Re=["debug","info","warn","error","log","assert","trace"],Le={};function ze(e){if(!("console"in Ie))return e();const t=Ie.console,r={},i=Object.keys(Le);i.forEach(e=>{const i=Le[e];r[e]=t[e],t[e]=i});try{return e()}finally{i.forEach(e=>{t[e]=r[e]})}}function Be(){return $e().enabled}function Oe(e,...t){Pe&&Be()&&ze(()=>{Ie.console[e](`Sentry Logger [${e}]:`,...t)})}function $e(){return Pe?ke("loggerSettings",()=>({enabled:!1})):{enabled:!1}}const Ne={enable:function(){$e().enabled=!0},disable:function(){$e().enabled=!1},isEnabled:Be,log:function(...e){Oe("log",...e)},warn:function(...e){Oe("warn",...e)},error:function(...e){Oe("error",...e)}},je="?",Ve=/\(error: (.*)\)/,Ue=/captureMessage|captureException/;function qe(...e){const t=e.sort((e,t)=>e[0]-t[0]).map(e=>e[1]);return(e,r=0,i=0)=>{const n=[],a=e.split("\n");for(let s=r;s<a.length;s++){let e=a[s];e.length>1024&&(e=e.slice(0,1024));const r=Ve.test(e)?e.replace(Ve,"$1"):e;if(!r.includes("Error: ")){for(const e of t){const t=e(r);if(t){n.push(t);break}}if(n.length>=50+i)break}}return function(e){if(!e.length)return[];const t=Array.from(e);/sentryWrapped/.test(Ge(t).function||"")&&t.pop();t.reverse(),Ue.test(Ge(t).function||"")&&(t.pop(),Ue.test(Ge(t).function||"")&&t.pop());return t.slice(0,50).map(e=>({...e,filename:e.filename||Ge(t).filename,function:e.function||je}))}(n.slice(i))}}function Ge(e){return e[e.length-1]||{}}const Ze="<anonymous>";function We(e){try{return e&&"function"==typeof e&&e.name||Ze}catch{return Ze}}function He(e){const t=e.exception;if(t){const e=[];try{return t.values.forEach(t=>{t.stacktrace.frames&&e.push(...t.stacktrace.frames)}),e}catch{return}}}const Xe={},Ye={};function Ke(e,t){return Xe[e]=Xe[e]||[],Xe[e].push(t),()=>{const r=Xe[e];if(r){const e=r.indexOf(t);-1!==e&&r.splice(e,1)}}}function Je(e,t){if(!Ye[e]){Ye[e]=!0;try{t()}catch(gd){Pe&&Ne.error(`Error while instrumenting ${e}`,gd)}}}function Qe(e,t){const r=e&&Xe[e];if(r)for(const i of r)try{i(t)}catch(gd){Pe&&Ne.error(`Error while triggering instrumentation handler.\nType: ${e}\nName: ${We(i)}\nError:`,gd)}}let et=null;function tt(){et=Ie.onerror,Ie.onerror=function(e,t,r,i,n){return Qe("error",{column:i,error:n,line:r,msg:e,url:t}),!!et&&et.apply(this,arguments)},Ie.onerror.__SENTRY_INSTRUMENTED__=!0}let rt=null;function it(){rt=Ie.onunhandledrejection,Ie.onunhandledrejection=function(e){return Qe("unhandledrejection",e),!rt||rt.apply(this,arguments)},Ie.onunhandledrejection.__SENTRY_INSTRUMENTED__=!0}const nt=Object.prototype.toString;function at(e){switch(nt.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return gt(e,Error)}}function st(e,t){return nt.call(e)===`[object ${t}]`}function ot(e){return st(e,"ErrorEvent")}function lt(e){return st(e,"DOMError")}function ut(e){return st(e,"String")}function ct(e){return"object"==typeof e&&null!==e&&"__sentry_template_string__"in e&&"__sentry_template_values__"in e}function ht(e){return null===e||ct(e)||"object"!=typeof e&&"function"!=typeof e}function dt(e){return st(e,"Object")}function pt(e){return"object"==typeof e&&null!==e}function ft(e){return"undefined"!=typeof Event&>(e,Event)}function mt(e){return Boolean(e?.then&&"function"==typeof e.then)}function gt(e,t){try{return e instanceof t}catch{return!1}}function yt(e){return"undefined"!=typeof Request&>(e,Request)}function _t(e,t,r){if(!(t in e))return;const i=e[t];if("function"!=typeof i)return;const n=r(i);"function"==typeof n&&xt(n,i);try{e[t]=n}catch{Pe&&Ne.log(`Failed to replace method "${t}" in object`,e)}}function vt(e,t,r){try{Object.defineProperty(e,t,{value:r,writable:!0,configurable:!0})}catch{Pe&&Ne.log(`Failed to add non-enumerable property "${String(t)}" to object`,e)}}function xt(e,t){try{const r=t.prototype||{};e.prototype=t.prototype=r,vt(e,"__sentry_original__",t)}catch{}}function bt(e){return e.__sentry_original__}function wt(e){if(at(e))return{message:e.message,name:e.name,stack:e.stack,...Et(e)};if(ft(e)){const{type:t,target:r,currentTarget:i,detail:n}=e;return{type:t,target:r,currentTarget:i,...n?{detail:n}:{},...Et(e)}}return e}function Et(e){return pt(e)?Object.fromEntries(Object.entries(e)):{}}let St;function Dt(e){if(void 0!==St)return St?St(e):e();const t=/* @__PURE__ */Symbol.for("__SENTRY_SAFE_RANDOM_ID_WRAPPER__"),r=Ie;return t in r&&"function"==typeof r[t]?(St=r[t],St(e)):(St=null,e())}function Tt(){return Dt(()=>Math.random())}function At(){return Dt(()=>Date.now())}const Pt=/* @__PURE__ */Symbol.for("sentry.skipNormalization"),It=/* @__PURE__ */Symbol.for("sentry.overrideNormalizationDepth");let Ct,Ft;function Mt(e,t=100,r=1/0){try{return Rt("",e,t,r)}catch(i){return{ERROR:`**non-serializable** (${i})`}}}function kt(e,t=3,r=102400){const i=Mt(e,t);return n=i,function(e){return~-encodeURI(e).split(/%..|./).length}(JSON.stringify(n))>r?kt(e,t-1,r):i;var n}function Rt(e,t,r=1/0,i=1/0,n=function(){const e=/* @__PURE__ */new WeakSet;function t(t){return!!e.has(t)||(e.add(t),!1)}function r(t){e.delete(t)}return[t,r]}()){const[a,s]=n;if(null==t||["boolean","string"].includes(typeof t)||"number"==typeof t&&Number.isFinite(t))return t;const o=Lt(e,t);if(!o.startsWith("[object "))return o;if(function(e){return Boolean(e[Pt])}(t))return t;const l=function(e){const t=e[It];return"number"==typeof t?t:void 0}(t),u=void 0!==l?l:r;if(0===u)return o.replace("object ","");if(a(t))return"[Circular ~]";const c=t;if(c&&"function"==typeof c.toJSON)try{return Rt("",c.toJSON(),u-1,i,n)}catch{}const h=Array.isArray(t)?[]:{};let d=0;const p=wt(t);for(const f in p){if(!Object.prototype.hasOwnProperty.call(p,f))continue;if(d>=i){h[f]="[MaxProperties ~]";break}const e=p[f];h[f]=Rt(f,e,u-1,i,n),d++}return s(t),h}function Lt(e,t){try{if(Ct){const e=Ct(t);if(e)return e}if("undefined"!=typeof global&&t===global)return"[Global]";if("number"==typeof t&&!Number.isFinite(t))return`[${t}]`;if("function"==typeof t)return`[Function: ${We(t)}]`;if("symbol"==typeof t)return`[${String(t)}]`;if("bigint"==typeof t)return`[BigInt: ${String(t)}]`;const e=function(e){const t=Object.getPrototypeOf(e);return t?.constructor?t.constructor.name:"null prototype"}(t);return`[object ${e}]`}catch(r){return`**non-serializable** (${r})`}}function zt(e,t=0){return"string"!=typeof e||0===t||e.length<=t?e:`${e.slice(0,t)}...`}function Bt(e,t){if(!Array.isArray(e))return"";const r=[];for(let i=0;i<e.length;i++){const t=e[i];ht(t)?r.push(String(t)):t instanceof Error?r.push(t.message?`${t.name}: ${t.message}`:t.name):r.push(Lt(0,t))}return r.join(t)}function Ot(e,t,r=!1){return!!ut(e)&&(st(t,"RegExp")?t.test(e):ut(t)?r?e===t:e.includes(t):"function"==typeof t&&t(e))}function $t(e,t=[],r=!1){for(const i of t)if(Ot(e,i,r))return!0;return!1}function Nt(e=function(){const e=Ie;return e.crypto||e.msCrypto}()){try{if(e?.randomUUID)return Dt(()=>e.randomUUID()).replace(/-/g,"")}catch{}return Ft||(Ft="10000000100040008000100000000000"),Ft.replace(/[018]/g,e=>(e^(16*Tt()&15)>>e/4).toString(16))}function jt(e){return e.exception?.values?.[0]}function Vt(e){const{message:t,event_id:r}=e;if(t)return t;const i=jt(e);return i?i.type&&i.value?`${i.type}: ${i.value}`:i.type||i.value||r||"<unknown>":r||"<unknown>"}function Ut(e,t,r){const i=e.exception=e.exception||{},n=i.values=i.values||[],a=n[0]=n[0]||{};a.value||(a.value=t||""),a.type||(a.type="Error")}function qt(e,t){const r=jt(e);if(!r)return;const i=r.mechanism;if(r.mechanism={type:"generic",handled:!0,...i,...t},t&&"data"in t){const e={...i?.data,...t.data};r.mechanism.data=e}}function Gt(e){if(function(e){try{return e.__sentry_captured__}catch{}}(e))return!0;try{vt(e,"__sentry_captured__",!0)}catch{}return!1}function Zt(){return At()/1e3}let Wt;function Ht(){return(Wt??(Wt=function(){const{performance:e}=Ie;if(!e?.now||!e.timeOrigin)return Zt;const t=e.timeOrigin;return()=>(t+Dt(()=>e.now()))/1e3}()))()}function Xt(e){const t=Ht(),r={sid:Nt(),init:!0,timestamp:t,started:t,duration:0,status:"ok",errors:0,ignoreDuration:!1,toJSON:()=>function(e){return{sid:`${e.sid}`,init:e.init,started:new Date(1e3*e.started).toISOString(),timestamp:new Date(1e3*e.timestamp).toISOString(),status:e.status,errors:e.errors,did:"number"==typeof e.did||"string"==typeof e.did?`${e.did}`:void 0,duration:e.duration,abnormal_mechanism:e.abnormal_mechanism,attrs:{release:e.release,environment:e.environment,ip_address:e.ipAddress,user_agent:e.userAgent}}}(r)};return e&&Yt(r,e),r}function Yt(e,t={}){if(t.user&&(!e.ipAddress&&t.user.ip_address&&(e.ipAddress=t.user.ip_address),e.did||t.did||(e.did=t.user.id||t.user.email||t.user.username)),e.timestamp=t.timestamp||Ht(),t.abnormal_mechanism&&(e.abnormal_mechanism=t.abnormal_mechanism),t.ignoreDuration&&(e.ignoreDuration=t.ignoreDuration),t.sid&&(e.sid=32===t.sid.length?t.sid:Nt()),void 0!==t.init&&(e.init=t.init),!e.did&&t.did&&(e.did=`${t.did}`),"number"==typeof t.started&&(e.started=t.started),e.ignoreDuration)e.duration=void 0;else if("number"==typeof t.duration)e.duration=t.duration;else{const t=e.timestamp-e.started;e.duration=t>=0?t:0}t.release&&(e.release=t.release),t.environment&&(e.environment=t.environment),!e.ipAddress&&t.ipAddress&&(e.ipAddress=t.ipAddress),!e.userAgent&&t.userAgent&&(e.userAgent=t.userAgent),"number"==typeof t.errors&&(e.errors=t.errors),t.status&&(e.status=t.status)}function Kt(e,t,r=2){if(!t||"object"!=typeof t||r<=0)return t;if(e&&0===Object.keys(t).length)return e;const i={...e};for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(i[n]=Kt(i[n],t[n],r-1));return i}function Jt(){return Nt()}function Qt(){return Nt().substring(16)}function er(e){if(e){if("object"==typeof e&&"deref"in e&&"function"==typeof e.deref)try{return e.deref()}catch{return}return e}}const tr="_sentrySpan";function rr(e,t){t?vt(e,tr,function(e){try{const t=Ie.WeakRef;if("function"==typeof t)return new t(e)}catch{}return e}(t)):delete e[tr]}function ir(e){return er(e[tr])}let nr=class e{constructor(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._attachments=[],this._user={},this._tags={},this._attributes={},this._extra={},this._contexts={},this._sdkProcessingMetadata={},this._propagationContext={traceId:Jt(),sampleRand:Tt()}}clone(){const t=new e;return t._breadcrumbs=[...this._breadcrumbs],t._tags={...this._tags},t._attributes={...this._attributes},t._extra={...this._extra},t._contexts={...this._contexts},this._contexts.flags&&(t._contexts.flags={values:[...this._contexts.flags.values]}),t._user=this._user,t._level=this._level,t._session=this._session,t._transactionName=this._transactionName,t._fingerprint=this._fingerprint,t._eventProcessors=[...this._eventProcessors],t._attachments=[...this._attachments],t._sdkProcessingMetadata={...this._sdkProcessingMetadata},t._propagationContext={...this._propagationContext},t._client=this._client,t._lastEventId=this._lastEventId,t._conversationId=this._conversationId,rr(t,ir(this)),t}setClient(e){this._client=e}setLastEventId(e){this._lastEventId=e}getClient(){return this._client}lastEventId(){return this._lastEventId}addScopeListener(e){this._scopeListeners.push(e)}addEventProcessor(e){return this._eventProcessors.push(e),this}setUser(e){return this._user=e||{email:void 0,id:void 0,ip_address:void 0,username:void 0},this._session&&Yt(this._session,{user:e}),this._notifyScopeListeners(),this}getUser(){return this._user}setConversationId(e){return this._conversationId=e||void 0,this._notifyScopeListeners(),this}setTags(e){return this._tags={...this._tags,...e},this._notifyScopeListeners(),this}setTag(e,t){return this.setTags({[e]:t})}setAttributes(e){return this._attributes={...this._attributes,...e},this._notifyScopeListeners(),this}setAttribute(e,t){return this.setAttributes({[e]:t})}removeAttribute(e){return e in this._attributes&&(delete this._attributes[e],this._notifyScopeListeners()),this}setExtras(e){return this._extra={...this._extra,...e},this._notifyScopeListeners(),this}setExtra(e,t){return this._extra={...this._extra,[e]:t},this._notifyScopeListeners(),this}setFingerprint(e){return this._fingerprint=e,this._notifyScopeListeners(),this}setLevel(e){return this._level=e,this._notifyScopeListeners(),this}setTransactionName(e){return this._transactionName=e,this._notifyScopeListeners(),this}setContext(e,t){return null===t?delete this._contexts[e]:this._contexts[e]=t,this._notifyScopeListeners(),this}setSession(e){return e?this._session=e:delete this._session,this._notifyScopeListeners(),this}getSession(){return this._session}update(t){if(!t)return this;const r="function"==typeof t?t(this):t,i=r instanceof e?r.getScopeData():dt(r)?t:void 0,{tags:n,attributes:a,extra:s,user:o,contexts:l,level:u,fingerprint:c=[],propagationContext:h,conversationId:d}=i||{};return this._tags={...this._tags,...n},this._attributes={...this._attributes,...a},this._extra={...this._extra,...s},this._contexts={...this._contexts,...l},o&&Object.keys(o).length&&(this._user=o),u&&(this._level=u),c.length&&(this._fingerprint=c),h&&(this._propagationContext=h),d&&(this._conversationId=d),this}clear(){return this._breadcrumbs=[],this._tags={},this._attributes={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._session=void 0,this._conversationId=void 0,rr(this,void 0),this._attachments=[],this.setPropagationContext({traceId:Jt(),sampleRand:Tt()}),this._notifyScopeListeners(),this}addBreadcrumb(e,t){const r="number"==typeof t?t:100;if(r<=0)return this;const i={timestamp:Zt(),...e,message:e.message?zt(e.message,2048):e.message};return this._breadcrumbs.push(i),this._breadcrumbs.length>r&&(this._breadcrumbs=this._breadcrumbs.slice(-r),this._client?.recordDroppedEvent("buffer_overflow","log_item")),this._notifyScopeListeners(),this}getLastBreadcrumb(){return this._breadcrumbs[this._breadcrumbs.length-1]}clearBreadcrumbs(){return this._breadcrumbs=[],this._notifyScopeListeners(),this}addAttachment(e){return this._attachments.push(e),this}clearAttachments(){return this._attachments=[],this}getScopeData(){return{breadcrumbs:this._breadcrumbs,attachments:this._attachments,contexts:this._contexts,tags:this._tags,attributes:this._attributes,extra:this._extra,user:this._user,level:this._level,fingerprint:this._fingerprint||[],eventProcessors:this._eventProcessors,propagationContext:this._propagationContext,sdkProcessingMetadata:this._sdkProcessingMetadata,transactionName:this._transactionName,span:ir(this),conversationId:this._conversationId}}setSDKProcessingMetadata(e){return this._sdkProcessingMetadata=Kt(this._sdkProcessingMetadata,e,2),this}setPropagationContext(e){return this._propagationContext=e,this}getPropagationContext(){return this._propagationContext}captureException(e,t){const r=t?.event_id||Nt();if(!this._client)return Pe&&Ne.warn("No client configured on scope - will not capture exception!"),r;const i=new Error("Sentry syntheticException");return this._client.captureException(e,{originalException:e,syntheticException:i,...t,event_id:r},this),r}captureMessage(e,t,r){const i=r?.event_id||Nt();if(!this._client)return Pe&&Ne.warn("No client configured on scope - will not capture message!"),i;const n=r?.syntheticException??new Error(e);return this._client.captureMessage(e,t,{originalException:e,syntheticException:n,...r,event_id:i},this),i}captureEvent(e,t){const r=e.event_id||t?.event_id||Nt();return this._client?(this._client.captureEvent(e,{...t,event_id:r},this),r):(Pe&&Ne.warn("No client configured on scope - will not capture event!"),r)}_notifyScopeListeners(){this._notifyingListeners||(this._notifyingListeners=!0,this._scopeListeners.forEach(e=>{e(this)}),this._notifyingListeners=!1)}};const ar=e=>e instanceof Promise&&!e[sr],sr=/* @__PURE__ */Symbol("chained PromiseLike"),or=(e,t)=>{if(!t)return e;let r=!1;for(const i in e){if(i in t)continue;r=!0;const n=e[i];"function"==typeof n?Object.defineProperty(t,i,{value:(...t)=>n.apply(e,t),enumerable:!0,configurable:!0,writable:!0}):t[i]=n}return r&&Object.assign(t,{[sr]:!0}),t};let lr=class{constructor(e,t){let r,i;r=e||new nr,i=t||new nr,this._stack=[{scope:r}],this._isolationScope=i}withScope(e){const t=this._pushScope();let r;try{r=e(t)}catch(gd){throw this._popScope(),gd}return mt(r)?((e,t,r)=>{const i=e.then(e=>(t(e),e),e=>{throw r(e),e});return ar(i)&&ar(e)?i:or(e,i)})(r,()=>this._popScope(),()=>this._popScope()):(this._popScope(),r)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this._isolationScope}getStackTop(){return this._stack[this._stack.length-1]}_pushScope(){const e=this.getScope().clone();return this._stack.push({client:this.getClient(),scope:e}),e}_popScope(){return!(this._stack.length<=1)&&!!this._stack.pop()}};function ur(){const e=Me(Fe());return e.stack=e.stack||new lr(ke("defaultCurrentScope",()=>new nr),ke("defaultIsolationScope",()=>new nr))}function cr(e){return ur().withScope(e)}function hr(e,t){const r=ur();return r.withScope(()=>(r.getStackTop().scope=e,t(e)))}function dr(e){return ur().withScope(()=>e(ur().getIsolationScope()))}function pr(e){const t=Me(e);return t.acs?t.acs:{withIsolationScope:dr,withScope:cr,withSetScope:hr,withSetIsolationScope:(e,t)=>dr(t),getCurrentScope:()=>ur().getScope(),getIsolationScope:()=>ur().getIsolationScope()}}function fr(e,t){const{value:r,unit:i}="object"==typeof(n=e)&&null!=n&&!Array.isArray(n)&&Object.keys(n).includes("value")?e:{value:e,unit:void 0};var n;const a=function(e){if(Array.isArray(e))return{value:e,type:"array"};const t="string"==typeof e?"string":"boolean"==typeof e?"boolean":"number"!=typeof e||Number.isNaN(e)?null:Number.isInteger(e)?"integer":"double";if(t)return{value:e,type:t}}(r),s=i&&"string"==typeof i?{unit:i}:{};if(a)return{...a,...s};if(!t||"skip-undefined"===t&&void 0===r)return;let o="";try{o=JSON.stringify(r)??""}catch{}return{value:o,type:"string",...s}}function mr(e,t=!1){const r={};for(const[i,n]of Object.entries(e??{})){const e=fr(n,t);e&&(r[i]=e)}return r}function gr(){return pr(Fe()).getCurrentScope()}function yr(){return pr(Fe()).getIsolationScope()}function _r(){return gr().getClient()}function vr(e){const t=e.getPropagationContext(),{traceId:r,parentSpanId:i,propagationSpanId:n}=t,a={trace_id:r,span_id:n||Qt()};return i&&(a.parent_span_id=i),a}const xr="sentry.op",br="sentry.profile_id",wr="sentry.exclusive_time";function Er(e){const t=e;return{scope:t._sentryScope,isolationScope:er(t._sentryIsolationScope)}}const Sr="sentry-";function Dr(e){const t=function(e){if(!e||!ut(e)&&!Array.isArray(e))return;if(Array.isArray(e))return e.reduce((e,t)=>{const r=Tr(t);return Object.entries(r).forEach(([t,r])=>{e[t]=r}),e},{});return Tr(e)}(e);if(!t)return;const r=Object.entries(t).reduce((e,[t,r])=>{if(t.startsWith(Sr)){e[t.slice(7)]=r}return e},{});return Object.keys(r).length>0?r:void 0}function Tr(e){return e.split(",").map(e=>{const t=e.indexOf("=");if(-1===t)return[];return[e.slice(0,t),e.slice(t+1)].map(e=>{try{return decodeURIComponent(e.trim())}catch{return}})}).reduce((e,[t,r])=>(t&&r&&(e[t]=r),e),{})}const Ar=/^o(\d+)\./,Pr=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)((?:\[[:.%\w]+\]|[\w.-]+))(?::(\d+))?\/(.+)/;function Ir(e,t=!1){const{host:r,path:i,pass:n,port:a,projectId:s,protocol:o,publicKey:l}=e;return`${o}://${l}${t&&n?`:${n}`:""}@${r}${a?`:${a}`:""}/${i?`${i}/`:i}${s}`}function Cr(e){return{protocol:e.protocol,publicKey:e.publicKey||"",pass:e.pass||"",host:e.host,port:e.port||"",path:e.path||"",projectId:e.projectId}}function Fr(e){const t=e.getOptions(),{host:r}=e.getDsn()||{};let i;return t.orgId?i=String(t.orgId):r&&(i=function(e){const t=e.match(Ar);return t?.[1]}(r)),i}function Mr(e){const t="string"==typeof e?function(e){const t=Pr.exec(e);if(!t)return void ze(()=>{console.error(`Invalid Sentry Dsn: ${e}`)});const[r,i,n="",a="",s="",o=""]=t.slice(1);let l="",u=o;const c=u.split("/");if(c.length>1&&(l=c.slice(0,-1).join("/"),u=c.pop()),u){const e=u.match(/^\d+/);e&&(u=e[0])}return Cr({host:a,pass:n,path:l,projectId:u,port:s,protocol:r,publicKey:i})}(e):Cr(e);if(t&&function(e){if(!Pe)return!0;const{port:t,projectId:r,protocol:i}=e;return!(["protocol","publicKey","host","projectId"].find(t=>!e[t]&&(Ne.error(`Invalid Sentry Dsn: ${t} missing`),!0))||(r.match(/^\d+$/)?function(e){return"http"===e||"https"===e}(i)?t&&isNaN(parseInt(t,10))&&(Ne.error(`Invalid Sentry Dsn: Invalid port ${t}`),1):(Ne.error(`Invalid Sentry Dsn: Invalid protocol ${i}`),1):(Ne.error(`Invalid Sentry Dsn: Invalid projectId ${r}`),1)))}(t))return t}let kr=!1;function Rr(e){const{spanId:t,traceId:r,isRemote:i}=e.spanContext(),n=i?t:Or(e).parent_span_id,a=Er(e).scope;return{parent_span_id:n,span_id:i?a?.getPropagationContext().propagationSpanId||Qt():t,trace_id:r}}function Lr(e){return e&&e.length>0?e.map(({context:{spanId:e,traceId:t,traceFlags:r,...i},attributes:n})=>({span_id:e,trace_id:t,sampled:1===r,attributes:n,...i})):void 0}function zr(e){return"number"==typeof e?Br(e):Array.isArray(e)?e[0]+e[1]/1e9:e instanceof Date?Br(e.getTime()):Ht()}function Br(e){return e>9999999999?e/1e3:e}function Or(e){if(function(e){return"function"==typeof e.getSpanJSON}(e))return e.getSpanJSON();const{spanId:t,traceId:r}=e.spanContext();if(function(e){const t=e;return!!(t.attributes&&t.startTime&&t.name&&t.endTime&&t.status)}(e)){const{attributes:i,startTime:n,name:a,endTime:s,status:o,links:l}=e;return{span_id:t,trace_id:r,data:i,description:a,parent_span_id:$r(e),start_timestamp:zr(n),timestamp:zr(s)||void 0,status:Nr(o),op:i[xr],origin:i["sentry.origin"],links:Lr(l)}}return{span_id:t,trace_id:r,start_timestamp:0,data:{}}}function $r(e){return"parentSpanId"in e?e.parentSpanId:"parentSpanContext"in e?e.parentSpanContext?.spanId:void 0}function Nr(e){if(e&&0!==e.code)return 1===e.code?"ok":e.message||"internal_error"}const jr=function(e){return e._sentryRootSpan||e};function Vr(){kr||(ze(()=>{console.warn("[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly or use `ignoreSpans`.")}),kr=!0)}function Ur(e){if("boolean"==typeof __SENTRY_TRACING__&&!__SENTRY_TRACING__)return!1;const t=e||_r()?.getOptions();return!(!t||null==t.tracesSampleRate&&!t.tracesSampler)}function qr(e){Ne.log(`Ignoring span ${e.op} - ${e.description} because it matches \`ignoreSpans\`.`)}function Gr(e,t){if(!t?.length)return!1;for(const r of t){if(Hr(r)){if(e.description&&Ot(e.description,r))return Pe&&qr(e),!0;continue}const t=!!r.attributes&&Object.keys(r.attributes).length>0;if(!r.name&&!r.op&&!t)continue;const i=!r.name||e.description&&Ot(e.description,r.name),n=!r.op||e.op&&Ot(e.op,r.op),a=!r.attributes||Object.entries(r.attributes).every(([t,r])=>Zr(e.attributes?.[t],r));if(i&&n&&a)return Pe&&qr(e),!0}return!1}function Zr(e,t){return"string"==typeof e&&("string"==typeof t||t instanceof RegExp)?Ot(e,t):Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((e,r)=>e===t[r]):e===t}function Wr(e,t){const r=t.parent_span_id,i=t.span_id;if(r)for(const n of e)n.parent_span_id===i&&(n.parent_span_id=r)}function Hr(e){return"string"==typeof e||e instanceof RegExp}const Xr=/* @__PURE__ */Symbol.for("sentry.nonRecordingSpan");const Yr="production";function Kr(e,t){const r=t.getOptions(),{publicKey:i}=t.getDsn()||{},n={environment:r.environment||Yr,release:r.release,public_key:i,trace_id:e,org_id:Fr(t)};return t.emit("createDsc",n),n}function Jr(e,t){const r=t.getPropagationContext();return r.dsc||Kr(r.traceId,e)}function Qr(e){const t=_r();if(!t)return{};const r=jr(e),i=Or(r),n=i.data,a=r.spanContext().traceState,s=a?.get("sentry.sample_rate")??n["sentry.sample_rate"]??n["sentry.previous_trace_sample_rate"];function o(e){return"number"!=typeof s&&"string"!=typeof s||(e.sample_rate=`${s}`),e}const l=r._frozenDsc;if(l)return o(l);const u=function(e){return!!e&&!0===e[Xr]}(r),c=u&&"ignored"===r.dropReason;if(u&&(!Ur(t.getOptions())||c)){const e=Er(r).scope;if(e){const r={...Jr(t,e)};return c&&(r.sampled="false"),o(r)}}const h=a?.get("sentry.dsc"),d=h&&Dr(h);if(d)return o(d);const p=Kr(e.spanContext().traceId,t),f=n["sentry.source"]??n["sentry.segment.name.source"],m=i.description;return"url"!==f&&m&&(p.transaction=m),Ur()&&(p.sampled=String(function(e){const{traceFlags:t}=e.spanContext();return 1===t}(r)),p.sample_rand=a?.get("sentry.sample_rand")??Er(r).scope?.getPropagationContext().sampleRand.toString()),o(p),t.emit("createDsc",p,r),p}function ei(e,t=[]){return[e,t]}function ti(e,t){const[r,i]=e;return[r,[...i,t]]}function ri(e,t){const r=e[1];for(const i of r){if(t(i,i[0].type))return!0}return!1}function ii(e){const t=Me(Ie);return t.encodePolyfill?t.encodePolyfill(e):(new TextEncoder).encode(e)}function ni(e){const[t,r]=e;let i=JSON.stringify(t);function n(e){"string"==typeof i?i="string"==typeof e?i+e:[ii(i),e]:i.push("string"==typeof e?ii(e):e)}for(const a of r){const[e,t]=a;if(n(`\n${JSON.stringify(e)}\n`),"string"==typeof t||t instanceof Uint8Array)n(t);else{let e;try{e=JSON.stringify(t)}catch{e=JSON.stringify(Mt(t))}n(e)}}return"string"==typeof i?i:function(e){const t=e.reduce((e,t)=>e+t.length,0),r=new Uint8Array(t);let i=0;for(const n of e)r.set(n,i),i+=n.length;return r}(i)}function ai(e){const t="string"==typeof e.data?ii(e.data):e.data;return[{type:"attachment",length:t.length,filename:e.filename,content_type:e.contentType,attachment_type:e.attachmentType},t]}const si={sessions:"session",event:"error",client_report:"internal",user_report:"default",profile_chunk:"profile",replay_event:"replay",replay_recording:"replay",check_in:"monitor",raw_security:"security",log:"log_item",trace_metric:"metric"};function oi(e){return function(e){return e in si}(e)?si[e]:e}function li(e){if(!e?.sdk)return;const{name:t,version:r}=e.sdk;return{name:t,version:r}}function ui(e,t,r,i){const n=li(r),a=e.type&&"replay_event"!==e.type?e.type:"event";!function(e,t){if(!t)return e;const r=e.sdk||{};e.sdk={...r,name:r.name||t.name,version:r.version||t.version,integrations:[...e.sdk?.integrations||[],...t.integrations||[]],packages:[...e.sdk?.packages||[],...t.packages||[]],settings:e.sdk?.settings||t.settings?{...e.sdk?.settings,...t.settings}:void 0}}(e,r?.sdk);const s=function(e,t,r,i){const n=e.sdkProcessingMetadata?.dynamicSamplingContext;return{event_id:e.event_id,sent_at:new Date(At()).toISOString(),...t&&{sdk:t},...!!r&&i&&{dsn:Ir(i)},...n&&{trace:n}}}(e,n,i,t);delete e.sdkProcessingMetadata;return ei(s,[[{type:a},e]])}function ci(e,t){const{fingerprint:r,span:i,breadcrumbs:n,sdkProcessingMetadata:a}=t;!function(e,t){const{extra:r,tags:i,user:n,contexts:a,level:s,transactionName:o}=t;Object.keys(r).length&&(e.extra={...r,...e.extra});Object.keys(i).length&&(e.tags={...i,...e.tags});Object.keys(n).length&&(e.user={...n,...e.user});Object.keys(a).length&&(e.contexts={...a,...e.contexts});s&&(e.level=s);o&&"transaction"!==e.type&&(e.transaction=o)}(e,t),i&&function(e,t){e.contexts={trace:Rr(t),...e.contexts},e.sdkProcessingMetadata={dynamicSamplingContext:Qr(t),...e.sdkProcessingMetadata};const r=jr(t),i=Or(r).description;i&&!e.transaction&&"transaction"===e.type&&(e.transaction=i)}(e,i),function(e,t){e.fingerprint=e.fingerprint?Array.isArray(e.fingerprint)?e.fingerprint:[e.fingerprint]:[],t&&(e.fingerprint=e.fingerprint.concat(t));e.fingerprint.length||delete e.fingerprint}(e,r),function(e,t){const r=[...e.breadcrumbs||[],...t];e.breadcrumbs=r.length?r:void 0}(e,n),function(e,t){e.sdkProcessingMetadata={...e.sdkProcessingMetadata,...t}}(e,a)}function hi(e,t){const{extra:r,tags:i,attributes:n,user:a,contexts:s,level:o,sdkProcessingMetadata:l,breadcrumbs:u,fingerprint:c,eventProcessors:h,attachments:d,propagationContext:p,transactionName:f,span:m}=t;di(e,"extra",r),di(e,"tags",i),di(e,"attributes",n),di(e,"user",a),di(e,"contexts",s),e.sdkProcessingMetadata=Kt(e.sdkProcessingMetadata,l,2),o&&(e.level=o),f&&(e.transactionName=f),m&&(e.span=m),u.length&&(e.breadcrumbs=[...e.breadcrumbs,...u]),c.length&&(e.fingerprint=[...e.fingerprint,...c]),h.length&&(e.eventProcessors=[...e.eventProcessors,...h]),d.length&&(e.attachments=[...e.attachments,...d]),e.propagationContext={...e.propagationContext,...p}}function di(e,t,r){e[t]=Kt(e[t],r,1)}function pi(e,t){const r=ke("globalScope",()=>new nr).getScopeData();return e&&hi(r,e.getScopeData()),t&&hi(r,t.getScopeData()),r}const fi="url.full",mi="user_agent.original";function gi(e,t){const r=e.attributes??(e.attributes={});Object.entries(t).forEach(([e,t])=>{null==t||e in r||(r[e]=t)})}function yi(e){return new Ei(t=>{t(e)})}function _i(e){return new Ei((t,r)=>{r(e)})}let vi,xi,bi,wi,Ei=class e{constructor(e){this._state=0,this._handlers=[],this._runExecutor(e)}then(t,r){return new e((e,i)=>{this._handlers.push([!1,r=>{if(t)try{e(t(r))}catch(gd){i(gd)}else e(r)},t=>{if(r)try{e(r(t))}catch(gd){i(gd)}else i(t)}]),this._executeHandlers()})}catch(e){return this.then(e=>e,e)}finally(t){return new e((e,r)=>{let i,n;return this.then(e=>{n=!1,i=e,t&&t()},e=>{n=!0,i=e,t&&t()}).then(()=>{n?r(i):e(i)})})}_executeHandlers(){if(0===this._state)return;const e=this._handlers.slice();this._handlers=[],e.forEach(e=>{e[0]||(1===this._state&&e[1](this._value),2===this._state&&e[2](this._value),e[0]=!0)})}_runExecutor(e){const t=(e,t)=>{0===this._state&&(mt(t)?t.then(r,i):(this._state=e,this._value=t,this._executeHandlers()))},r=e=>{t(1,e)},i=e=>{t(2,e)};try{e(r,i)}catch(gd){i(gd)}}};function Si(e,t,r,i=0){try{const n=Di(t,r,e,i);return mt(n)?n:yi(n)}catch(n){return _i(n)}}function Di(e,t,r,i){const n=r[i];if(!e||!n)return e;const a=n({...e},t);return Pe&&null===a&&Ne.log(`Event processor "${n.id||"?"}" dropped event`),mt(a)?a.then(e=>Di(e,t,r,i+1)):Di(a,t,r,i+1)}function Ti(e,t,r,i,n,a){const{normalizeDepth:s=3,normalizeMaxBreadth:o=1e3}=e,l={...t,event_id:t.event_id||r.event_id||Nt(),timestamp:t.timestamp||Zt()},u=r.integrations||e.integrations.map(e=>e.name);!function(e,t){const{environment:r,release:i,dist:n,maxValueLength:a}=t;e.environment=e.environment||r||Yr,!e.release&&i&&(e.release=i);!e.dist&&n&&(e.dist=n);const s=e.request;s?.url&&a&&(s.url=zt(s.url,a));a&&e.exception?.values?.forEach(e=>{e.value&&(e.value=zt(e.value,a))})}(l,e),function(e,t){t.length>0&&(e.sdk=e.sdk||{},e.sdk.integrations=[...e.sdk.integrations||[],...t])}(l,u),n&&n.emit("applyFrameMetadata",t),void 0===t.type&&function(e,t){const r=function(e){const t=Ie._sentryDebugIds,r=Ie._debugIds;if(!t&&!r)return{};const i=t?Object.keys(t):[],n=r?Object.keys(r):[];if(wi&&i.length===xi&&n.length===bi)return wi;xi=i.length,bi=n.length,wi={},vi||(vi={});const a=(t,r)=>{for(const i of t){const t=r[i],n=vi?.[i];if(n&&wi&&t)wi[n[0]]=t,vi&&(vi[i]=[n[0],t]);else if(t){const r=e(i);for(let e=r.length-1;e>=0;e--){const n=r[e],a=n?.filename;if(a&&wi&&vi){wi[a]=t,vi[i]=[a,t];break}}}}};return t&&a(i,t),r&&a(n,r),wi}(t);e.exception?.values?.forEach(e=>{e.stacktrace?.frames?.forEach(e=>{e.filename&&(e.debug_id=r[e.filename])})})}(l,e.stackParser);const c=function(e,t){if(!t)return e;const r=e?e.clone():new nr;return r.update(t),r}(i,r.captureContext);r.mechanism&&qt(l,r.mechanism);const h=n?n.getEventProcessors():[],d=pi(a,c),p=[...r.attachments||[],...d.attachments];p.length&&(r.attachments=p),ci(l,d);const f=[...h,...d.eventProcessors];return(r.data&&!0===r.data.__sentry__?yi(l):Si(f,l,r)).then(e=>(e&&function(e){const t={};if(e.exception?.values?.forEach(e=>{e.stacktrace?.frames?.forEach(e=>{e.debug_id&&(e.abs_path?t[e.abs_path]=e.debug_id:e.filename&&(t[e.filename]=e.debug_id),delete e.debug_id)})}),0===Object.keys(t).length)return;e.debug_meta=e.debug_meta||{},e.debug_meta.images=e.debug_meta.images||[];const r=e.debug_meta.images;Object.entries(t).forEach(([e,t])=>{r.push({type:"sourcemap",code_file:e,debug_id:t})})}(e),"number"==typeof s&&s>0?function(e,t,r){if(!e)return null;const i={...e,...e.breadcrumbs&&{breadcrumbs:e.breadcrumbs.map(e=>({...e,...e.data&&{data:Mt(e.data,t,r)}}))},...e.user&&{user:Mt(e.user,t,r)},...e.contexts&&{contexts:Mt(e.contexts,t,r)},...e.extra&&{extra:Mt(e.extra,t,r)}};e.contexts?.trace&&i.contexts&&(i.contexts.trace=e.contexts.trace,e.contexts.trace.data&&(i.contexts.trace.data=Mt(e.contexts.trace.data,t,r)));e.spans&&(i.spans=e.spans.map(e=>({...e,...e.data&&{data:Mt(e.data,t,r)}})));e.contexts?.flags&&i.contexts&&(i.contexts.flags=Mt(e.contexts.flags,3,r));return i}(e,s,o):e))}function Ai(e){if(e)return function(e){return e instanceof nr||"function"==typeof e}(e)||function(e){return Object.keys(e).some(e=>Pi.includes(e))}(e)?{captureContext:e}:e}const Pi=["user","level","extra","contexts","tags","fingerprint","propagationContext"];function Ii(e,t){return gr().captureException(e,Ai(t))}function Ci(e,t){const r="string"==typeof t?t:void 0,i="string"!=typeof t?{captureContext:t}:void 0;return gr().captureMessage(e,r,i)}function Fi(e,t){return gr().captureEvent(e,t)}function Mi(e,t){yr().setTag(e,t)}function ki(e){const t=yr(),{user:r}=pi(t,gr()),{userAgent:i}=Ie.navigator||{},n=Xt({user:r,...i&&{userAgent:i},...e}),a=t.getSession();return"ok"===a?.status&&Yt(a,{status:"exited"}),Ri(),t.setSession(n),n}function Ri(){const e=yr(),t=gr().getSession()||e.getSession();t&&function(e){let t={};"ok"===e.status&&(t={status:"exited"}),Yt(e,t)}(t),Li(),e.setSession()}function Li(){const e=yr(),t=_r(),r=e.getSession();r&&t&&t.captureSession(r)}function zi(e=!1){e?Ri():Li()}function Bi(e){return"object"==typeof e&&"function"==typeof e.unref&&e.unref(),e}function Oi(e,t,r){return t||`${function(e){return`${function(e){const t=e.protocol?`${e.protocol}:`:"",r=e.port?`:${e.port}`:"";return`${t}//${e.host}${r}${e.path?`/${e.path}`:""}/api/`}(e)}${e.projectId}/envelope/`}(e)}?${function(e,t){const r={sentry_version:"7"};return e.publicKey&&(r.sentry_key=e.publicKey),t&&(r.sentry_client=`${t.name}/${t.version}`),new URLSearchParams(r).toString()}(e,r)}`}const $i=[];function Ni(e){const t=e.defaultIntegrations||[],r=e.integrations;let i;if(t.forEach(e=>{e.isDefaultInstance=!0}),Array.isArray(r))i=[...t,...r];else if("function"==typeof r){const e=r(t);i=Array.isArray(e)?e:[e]}else i=t;return function(e){const t={};return e.forEach(e=>{const{name:r}=e,i=t[r];i&&!i.isDefaultInstance&&e.isDefaultInstance||(t[r]=e)}),Object.values(t)}(i)}function ji(e,t){for(const r of t)r?.afterAllSetup&&r.afterAllSetup(e)}function Vi(e,t,r){if(r[t.name])Pe&&Ne.log(`Integration skipped because it was already installed: ${t.name}`);else{if(r[t.name]=t,$i.includes(t.name)||"function"!=typeof t.setupOnce||(t.setupOnce(),$i.push(t.name)),t.setup&&"function"==typeof t.setup&&t.setup(e),"function"==typeof t.preprocessEvent){const r=t.preprocessEvent.bind(t);e.on("preprocessEvent",(t,i)=>r(t,i,e))}if("function"==typeof t.processEvent){const r=t.processEvent.bind(t),i=Object.assign((t,i)=>r(t,i,e),{id:t.name});e.addEventProcessor(i)}["processSpan","processSegmentSpan"].forEach(r=>{const i=t[r];"function"==typeof i&&e.on(r,r=>i.call(t,r,e))}),Pe&&Ne.log(`Integration installed: ${t.name}`)}}function Ui(){return!("undefined"!=typeof __SENTRY_BROWSER_BUNDLE__&&__SENTRY_BROWSER_BUNDLE__)&&"[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0)}function qi(){return"undefined"!=typeof window&&(!Ui()||function(){const e=Ie.process;return"renderer"===e?.type}())}function Gi(e,t){const r=t?"auto":"never";return[{type:"log",item_count:e.length,content_type:"application/vnd.sentry.items.log+json"},{version:2,...qi()&&{ingest_settings:{infer_ip:r,infer_user_agent:r}},items:e}]}function Zi(e,t){const r=t??function(e){return Wi().get(e)}(e)??[];if(0===r.length)return;const i=e.getOptions(),n=function(e,t,r,i,n){const a={};return t?.sdk&&(a.sdk={name:t.sdk.name,version:t.sdk.version}),r&&i&&(a.dsn=Ir(i)),ei(a,[Gi(e,n)])}(r,i._metadata,i.tunnel,e.getDsn(),e.getDataCollectionOptions().userInfo);Wi().set(e,[]),e.emit("flushLogs"),e.sendEnvelope(n)}function Wi(){return ke("clientToLogBufferMap",()=>/* @__PURE__ */new WeakMap)}function Hi(e,t){const r=t?"auto":"never";return[{type:"trace_metric",item_count:e.length,content_type:"application/vnd.sentry.items.trace-metric+json"},{version:2,...qi()&&{ingest_settings:{infer_ip:r,infer_user_agent:r}},items:e}]}function Xi(e,t){const r=t??function(e){return Yi().get(e)}(e)??[];if(0===r.length)return;const i=e.getOptions(),n=function(e,t,r,i,n){const a={};return t?.sdk&&(a.sdk={name:t.sdk.name,version:t.sdk.version}),r&&i&&(a.dsn=Ir(i)),ei(a,[Hi(e,n)])}(r,i._metadata,i.tunnel,e.getDsn(),e.getDataCollectionOptions().userInfo);Yi().set(e,[]),e.emit("flushMetrics"),e.sendEnvelope(n)}function Yi(){return ke("clientToMetricBufferMap",()=>/* @__PURE__ */new WeakMap)}function Ki(e){const t={trace_id:e.trace_id,span_id:e.span_id,parent_span_id:e.parent_span_id,name:e.description||"",start_timestamp:e.start_timestamp,end_timestamp:e.timestamp||e.start_timestamp,status:e.status&&"ok"!==e.status&&"cancelled"!==e.status?"error":"ok",is_segment:!1,attributes:{...e.data},links:e.links};return r=t,{...r,attributes:mr(r.attributes),links:r.links?.map(e=>({...e,attributes:mr(e.attributes)}))};var r}const Ji=/* @__PURE__ */Symbol.for("SentryBufferFullError");function Qi(e=100){const t=/* @__PURE__ */new Set;function r(e){t.delete(e)}return{get $(){return Array.from(t)},add:function(i){if(!(t.size<e))return _i(Ji);const n=i();return t.add(n),n.then(()=>r(n),()=>r(n)),n},drain:function(e){if(!t.size)return yi(!0);const r=Promise.allSettled(Array.from(t)).then(()=>!0);if(!e)return r;const i=[r,new Promise(t=>Bi(setTimeout(()=>t(!1),e)))];return Promise.race(i)}}}function en(e,{statusCode:t,headers:r},i=At()){const n={...e},a=r?.["x-sentry-rate-limits"],s=r?.["retry-after"];if(a)for(const o of a.trim().split(",")){const[e,t,,,r]=o.split(":",5),a=parseInt(e,10),s=1e3*(isNaN(a)?60:a);if(t)for(const o of t.split(";"))"metric_bucket"===o&&r&&!r.split(";").includes("custom")||(n[o]=i+s);else n.all=i+s}else s?n.all=i+function(e,t=At()){const r=parseInt(`${e}`,10);if(!isNaN(r))return 1e3*r;const i=Date.parse(`${e}`);return isNaN(i)?6e4:i-t}(s,i):429===t&&(n.all=i+6e4);return n}function tn(e,t,r=Qi(e.bufferSize||64)){let i={};return{send:function(n){const a=[];if(ri(n,(t,r)=>{const n=oi(r);!function(e,t,r=At()){return function(e,t){return e[t]||e.all||0}(e,t)>r}(i,n)?a.push(t):e.recordDroppedEvent("ratelimit_backoff",n)}),0===a.length)return Promise.resolve({});const s=ei(n[0],a),o=t=>{!function(e,t){return ri(e,(e,r)=>t.includes(r))}(s,["client_report"])?ri(s,(r,i)=>{e.recordDroppedEvent(t,oi(i))}):Pe&&Ne.warn(`Dropping client report. Will not send outcomes (reason: ${t}).`)};return r.add(()=>t({body:ni(s)}).then(e=>413===e.statusCode?(Pe&&Ne.error("Sentry responded with status code 413. Envelope was discarded due to exceeding size limits."),o("send_error"),e):(Pe&&void 0!==e.statusCode&&(e.statusCode<200||e.statusCode>=300)&&Ne.warn(`Sentry responded with status code ${e.statusCode} to sent event.`),i=en(i,e),e),e=>{throw o("network_error"),Pe&&Ne.error("Encountered error running transport request:",e),e})).then(e=>e,e=>{if(e===Ji)return Pe&&Ne.error("Skipped sending event because buffer is full."),o("queue_overflow"),Promise.resolve({});throw e})},flush:e=>r.drain(e)}}function rn(e){const t=[];e.message&&t.push(e.message);try{const r=e.exception.values[e.exception.values.length-1];r?.value&&(t.push(r.value),r.type&&t.push(`${r.type}: ${r.value}`))}catch{}return t}const nn=["forwarded","-ip","remote-","via","-user"];const an={userInfo:!0,cookies:!0,httpHeaders:{request:!0,response:!0},httpBodies:["incomingRequest","outgoingRequest","incomingResponse","outgoingResponse"],urlQueryParams:!0,graphQL:{document:!0,variables:!0},genAI:{inputs:!0,outputs:!0},databaseQueryData:!0,stackFrameVariables:!0,frameContextLines:5};function sn(e){const t=null!=e.dataCollection?an:!0===e.sendDefaultPii?{userInfo:!0,cookies:!0,httpHeaders:{request:!0,response:!0},httpBodies:["incomingRequest","outgoingRequest","incomingResponse","outgoingResponse"],urlQueryParams:!0,graphQL:{document:!0,variables:!0},genAI:{inputs:!0,outputs:!0},databaseQueryData:!0,stackFrameVariables:!0,frameContextLines:7}:{userInfo:!1,cookies:{deny:nn},httpHeaders:{request:{deny:nn},response:{deny:nn}},httpBodies:[],urlQueryParams:{deny:nn},graphQL:{document:!0,variables:!0},genAI:{inputs:!1,outputs:!1},databaseQueryData:!1,stackFrameVariables:!0,frameContextLines:7};const r=e.dataCollection??{};return{userInfo:r.userInfo??t.userInfo,cookies:r.cookies??t.cookies,httpHeaders:{request:r.httpHeaders?.request??t.httpHeaders.request,response:r.httpHeaders?.response??t.httpHeaders.response},httpBodies:r.httpBodies??t.httpBodies,urlQueryParams:r.urlQueryParams??r.queryParams??t.urlQueryParams,graphQL:{document:r.graphQL?.document??t.graphQL.document,variables:r.graphQL?.variables??t.graphQL.variables},genAI:{inputs:r.genAI?.inputs??t.genAI.inputs,outputs:r.genAI?.outputs??t.genAI.outputs},databaseQueryData:r.databaseQueryData??t.databaseQueryData,stackFrameVariables:r.stackFrameVariables??t.stackFrameVariables,frameContextLines:r.frameContextLines??t.frameContextLines}}const on="Not capturing exception because it's already been captured.",ln="Discarded session because of missing or non-string release",un=/* @__PURE__ */Symbol.for("SentryInternalError"),cn=/* @__PURE__ */Symbol.for("SentryDoNotSendEventError");function hn(e){return{message:e,[un]:!0}}function dn(e){return{message:e,[cn]:!0}}function pn(e){return pt(e)&&un in e}function fn(e){return pt(e)&&cn in e}function mn(e,t,r,i,n){let a,s=0,o=!1;e.on(r,()=>{s=0,clearTimeout(a),o=!1}),e.on(t,t=>{if(s+=i(t),s>=8e5)n(e);else if(!o){const t=e.getOptions()._flushInterval??5e3;t>0&&(o=!0,a=Bi(setTimeout(()=>{n(e)},t)))}}),e.on("flush",()=>{n(e)})}let gn=class{constructor(e){if(this._options=e,this._integrations={},this._numProcessing=0,this._outcomes={},this._hooks={},this._eventProcessors=[],this._promiseBuffer=Qi(e.transportOptions?.bufferSize??64),this._dataCollection=sn(e),e.dsn?this._dsn=Mr(e.dsn):Pe&&Ne.warn("No DSN provided, client will not send events."),this._dsn){const t=Oi(this._dsn,e.tunnel,e._metadata?e._metadata.sdk:void 0);this._transport=e.transport({tunnel:this._options.tunnel,recordDroppedEvent:this.recordDroppedEvent.bind(this),...e.transportOptions,url:t})}this._options.enableLogs=this._options.enableLogs??this._options._experiments?.enableLogs,this._options.enableLogs&&mn(this,"afterCaptureLog","flushLogs",bn,Zi);(this._options.enableMetrics??this._options._experiments?.enableMetrics??!0)&&mn(this,"afterCaptureMetric","flushMetrics",xn,Xi)}captureException(e,t,r){const i=Nt();if(Gt(e))return Pe&&Ne.log(on),i;const n={event_id:i,...t};return this._process(()=>this.eventFromException(e,n).then(e=>this._captureEvent(e,n,r)).then(e=>e),"error"),n.event_id}captureMessage(e,t,r,i){const n={event_id:Nt(),...r},a=ct(e)?e:String(e),s=ht(e),o=s?this.eventFromMessage(a,t,n):this.eventFromException(e,n);return this._process(()=>o.then(e=>this._captureEvent(e,n,i)),s?"unknown":"error"),n.event_id}captureEvent(e,t,r){const i=Nt();if(t?.originalException&&Gt(t.originalException))return Pe&&Ne.log(on),i;const n={event_id:i,...t},a=e.sdkProcessingMetadata||{},s=a.capturedSpanScope,o=a.capturedSpanIsolationScope,l=yn(e.type);return this._process(()=>this._captureEvent(e,n,s||r,o),l),n.event_id}captureSession(e){this.sendSession(e),Yt(e,{init:!1})}getDsn(){return this._dsn}getOptions(){return this._options}getDataCollectionOptions(){return this._dataCollection}getSdkMetadata(){return this._options._metadata}getTransport(){return this._transport}async flush(e){const t=this._transport;if(this.emit("flush"),!t)return!0;const r=await this._isClientDoneProcessing(e),i=await t.flush(e);return r&&i}async close(e){const t=await this.flush(e);return this.getOptions().enabled=!1,this.emit("close"),t}getEventProcessors(){return this._eventProcessors}addEventProcessor(e){this._eventProcessors.push(e)}init(){(this._isEnabled()||this._options.integrations.some(({name:e})=>e.startsWith("Spotlight")))&&this._setupIntegrations()}getIntegrationByName(e){return this._integrations[e]}getIntegrationNames(){return Object.keys(this._integrations)}addIntegration(e){const t=this._integrations[e.name];!t&&e.beforeSetup&&e.beforeSetup(this),Vi(this,e,this._integrations),t||ji(this,[e])}sendEvent(e,t={}){this.emit("beforeSendEvent",e,t);const r=function(e,t){if("transaction"!==e.type||!e.spans?.length||!e.sdkProcessingMetadata?.hasGenAiSpans||!1===t.getOptions().streamGenAiSpans||function(e){return"stream"===e.getOptions().traceLifecycle}(t))return;const r=[],i=[];for(const a of e.spans)a.op?.startsWith("gen_ai.")?r.push(Ki(a)):i.push(a);if(0===r.length)return;e.spans=i;const n=t.getDataCollectionOptions().userInfo?"auto":"never";return[{type:"span",item_count:r.length,content_type:"application/vnd.sentry.items.span.v2+json"},{version:2,...qi()&&{ingest_settings:{infer_ip:n,infer_user_agent:n}},items:r}]}(e,this);let i=ui(e,this._dsn,this._options._metadata,this._options.tunnel);for(const n of t.attachments||[])i=ti(i,ai(n));r&&(i=ti(i,r)),this.sendEnvelope(i).then(t=>this.emit("afterSendEvent",e,t))}sendSession(e){const{release:t,environment:r=Yr}=this._options;if("aggregates"in e){const i=e.attrs||{};if(!i.release&&!t)return void(Pe&&Ne.warn(ln));i.release=i.release||t,i.environment=i.environment||r,e.attrs=i}else{if(!e.release&&!t)return void(Pe&&Ne.warn(ln));e.release=e.release||t,e.environment=e.environment||r}this.emit("beforeSendSession",e);const i=function(e,t,r,i){const n=li(r);return ei({sent_at:new Date(At()).toISOString(),...n&&{sdk:n},...!!i&&t&&{dsn:Ir(t)}},["aggregates"in e?[{type:"sessions"},e]:[{type:"session"},e.toJSON()]])}(e,this._dsn,this._options._metadata,this._options.tunnel);this.sendEnvelope(i)}recordDroppedEvent(e,t,r=1){if(this._options.sendClientReports){const i=`${e}:${t}`;Pe&&Ne.log(`Recording outcome: "${i}"${r>1?` (${r} times)`:""}`),this._outcomes[i]=(this._outcomes[i]||0)+r}}on(e,t){const r=this._hooks[e]=this._hooks[e]||/* @__PURE__ */new Set,i=(...e)=>t(...e);return r.add(i),()=>{r.delete(i)}}emit(e,...t){const r=this._hooks[e];r&&r.forEach(e=>e(...t))}async sendEnvelope(e){if(this.emit("beforeEnvelope",e),this._isEnabled()&&this._transport)try{return await this._transport.send(e)}catch(t){return Pe&&Ne.error("Error while sending envelope:",t),{}}return Pe&&Ne.error("Transport disabled"),{}}registerCleanup(e){}dispose(){}_setupIntegrations(){const{integrations:e}=this._options;this._integrations=function(e,t){const r={};return t.forEach(t=>{t?.beforeSetup&&t.beforeSetup(e)}),t.forEach(t=>{t&&Vi(e,t,r)}),r}(this,e),ji(this,e)}_updateSessionFromEvent(e,t){let r="fatal"===t.level,i=!1;const n=t.exception?.values;if(n){i=!0,r=!1;for(const e of n)if(!1===e.mechanism?.handled){r=!0;break}}const a="ok"===e.status;(a&&0===e.errors||a&&r)&&(Yt(e,{...r&&{status:"crashed"},errors:e.errors||Number(i||r)}),this.captureSession(e))}async _isClientDoneProcessing(e){let t=0;for(;!e||t<e;){if(await new Promise(e=>setTimeout(e,1)),!this._numProcessing)return!0;t++}return!1}_isEnabled(){return!1!==this.getOptions().enabled&&void 0!==this._transport}_prepareEvent(e,t,r,i){const n=this.getOptions(),a=this.getIntegrationNames();return!t.integrations&&a.length&&(t.integrations=a),this.emit("preprocessEvent",e,t),e.type||i.setLastEventId(e.event_id||t.event_id),Ti(n,e,t,r,this,i).then(e=>{if(null===e)return e;this.emit("postprocessEvent",e,t),e.contexts={trace:{...e.contexts?.trace,...vr(r)},...e.contexts};const i=Jr(this,r);return e.sdkProcessingMetadata={dynamicSamplingContext:i,...e.sdkProcessingMetadata},e})}_captureEvent(e,t={},r=gr(),i=yr()){return Pe&&_n(e)&&Ne.log(`Captured error event \`${rn(e)[0]||"<unknown>"}\``),this._processEvent(e,t,r,i).then(e=>e.event_id,e=>{Pe&&(fn(e)?Ne.log(e.message):pn(e)?Ne.warn(e.message):Ne.warn(e))})}_processEvent(e,t,r,i){const n=this.getOptions(),{sampleRate:a}=n,s=vn(e),o=_n(e),l=`before send for type \`${e.type||"error"}\``,u=void 0===a?void 0:function(e){if("boolean"==typeof e)return Number(e);const t="string"==typeof e?parseFloat(e):e;return"number"!=typeof t||isNaN(t)||t<0||t>1?void 0:t}(a);if(o&&"number"==typeof u&&Tt()>u)return this.recordDroppedEvent("sample_rate","error"),_i(dn(`Discarding event because it's not included in the random sample (sampling rate = ${a})`));const c=yn(e.type);return this._prepareEvent(e,t,r,i).then(e=>{if(null===e)throw this.recordDroppedEvent("event_processor",c),dn("An event processor returned `null`, will not send event.");if(!0===t.data?.__sentry__)return e;const r=function(e,t,r,i){const{beforeSend:n,beforeSendTransaction:a,ignoreSpans:s}=t,o=(l=t.beforeSendSpan,!(l&&"function"==typeof l&&"_streamed"in l&&l._streamed)&&t.beforeSendSpan);var l;let u=r;if(_n(u)&&n)return n(u,i);if(vn(u)){if(o||s){const t=function(e){const{trace_id:t,parent_span_id:r,span_id:i,status:n,origin:a,data:s,op:o}=e.contexts?.trace??{};return{data:s??{},description:e.transaction,op:o,parent_span_id:r,span_id:i??"",start_timestamp:e.start_timestamp??0,status:n,timestamp:e.timestamp,trace_id:t??"",origin:a,profile_id:s?.[br],exclusive_time:s?.[wr],measurements:e.measurements,is_segment:!0}}(u);if(s?.length&&Gr({description:t.description,op:t.op,attributes:t.data},s))return null;if(o){const e=o(t);e?u=Kt(r,{type:"transaction",timestamp:(c=e).timestamp,start_timestamp:c.start_timestamp,transaction:c.description,contexts:{trace:{trace_id:c.trace_id,span_id:c.span_id,parent_span_id:c.parent_span_id,op:c.op,status:c.status,origin:c.origin,data:{...c.data,...c.profile_id&&{[br]:c.profile_id},...c.exclusive_time&&{[wr]:c.exclusive_time}}}},measurements:c.measurements}):Vr()}if(u.spans){const t=[],r=u.spans;for(const e of r)if(s?.length&&Gr({description:e.description,op:e.op,attributes:e.data},s))Wr(r,e);else if(o){const r=o(e);r?t.push(r):(Vr(),t.push(e))}else t.push(e);const i=u.spans.length-t.length;i&&e.recordDroppedEvent("before_send","span",i),u.spans=t}}if(a){if(u.spans){const e=u.spans.length;u.sdkProcessingMetadata={...r.sdkProcessingMetadata,spanCountBeforeProcessing:e}}return a(u,i)}}var c;return u}(this,n,e,t);return function(e,t){const r=`${t} must return \`null\` or a valid event.`;if(mt(e))return e.then(e=>{if(!dt(e)&&null!==e)throw hn(r);return e},e=>{throw hn(`${t} rejected with ${e}`)});if(!dt(e)&&null!==e)throw hn(r);return e}(r,l)}).then(n=>{if(null===n){if(this.recordDroppedEvent("before_send",c),s){const t=1+(e.spans||[]).length;this.recordDroppedEvent("before_send","span",t)}throw dn(`${l} returned \`null\`, will not send event.`)}const a=r.getSession()||i.getSession();if(o&&a&&this._updateSessionFromEvent(a,n),s){const e=(n.sdkProcessingMetadata?.spanCountBeforeProcessing||0)-(n.spans?n.spans.length:0);e>0&&this.recordDroppedEvent("before_send","span",e)}const u=n.transaction_info;if(s&&u&&n.transaction!==e.transaction){const e="custom";n.transaction_info={...u,source:e}}return this.sendEvent(n,t),n}).then(null,e=>{if(fn(e)||pn(e))throw e;throw this.captureException(e,{mechanism:{handled:!1,type:"internal"},data:{__sentry__:!0},originalException:e}),hn(`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.\nReason: ${e}`)})}_process(e,t){this._numProcessing++,this._promiseBuffer.add(e).then(e=>(this._numProcessing--,e),e=>(this._numProcessing--,e===Ji&&this.recordDroppedEvent("queue_overflow",t),e))}_clearOutcomes(){const e=this._outcomes;return this._outcomes={},Object.entries(e).map(([e,t])=>{const[r,i]=e.split(":");return{reason:r,category:i,quantity:t}})}_flushOutcomes(){Pe&&Ne.log("Flushing outcomes...");const e=this._clearOutcomes();if(0===e.length)return void(Pe&&Ne.log("No outcomes to send"));if(!this._dsn)return void(Pe&&Ne.log("No dsn provided, will not send outcomes"));Pe&&Ne.log("Sending outcomes:",e);const t=(r=e,ei((i=this._options.tunnel&&Ir(this._dsn))?{dsn:i}:{},[[{type:"client_report"},{timestamp:Zt(),discarded_events:r}]]));var r,i;this.sendEnvelope(t)}};function yn(e){return"replay_event"===e?"replay":e||"error"}function _n(e){return void 0===e.type}function vn(e){return"transaction"===e.type}function xn(e){let t=0;return e.name&&(t+=2*e.name.length),t+=8,t+wn(e.attributes)}function bn(e){let t=0;return e.message&&(t+=2*e.message.length),t+wn(e.attributes)}function wn(e){if(!e)return 0;let t=0;return Object.values(e).forEach(e=>{Array.isArray(e)?t+=e.length*En(e[0]):ht(e)?t+=En(e):t+=100}),t}function En(e){return"string"==typeof e?2*e.length:"number"==typeof e?8:"boolean"==typeof e?4:0}function Sn(e,t){!0===t.debug&&(Pe?Ne.enable():ze(()=>{console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.")}));gr().update(t.initialScope);const r=new e(t);return function(e){gr().setClient(e)}(r),r.init(),r}function Dn(e){if(!e)return{};const t=e.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)return{};const r=t[6]||"",i=t[8]||"";return{host:t[4],path:t[5],protocol:t[2],search:r,hash:i,relative:t[5]+r+i}}function Tn(e){"aggregates"in e?void 0===e.attrs?.ip_address&&(e.attrs={...e.attrs,ip_address:"{{auto}}"}):void 0===e.ipAddress&&(e.ipAddress="{{auto}}")}const An=100;function Pn(e,t){const r=_r(),i=yr();if(!r)return;const{beforeBreadcrumb:n=null,maxBreadcrumbs:a=An}=r.getOptions();if(a<=0)return;const s={timestamp:Zt(),...e},o=n?ze(()=>n(s,t)):s;null!==o&&(r.emit&&r.emit("beforeAddBreadcrumb",o,t),i.addBreadcrumb(o,a))}const In=/* @__PURE__ */new WeakMap,Cn=()=>({name:"FunctionToString",setupOnce(){const e=Function.prototype.toString;try{Function.prototype.toString=function(...t){const r=bt(this);let i;try{In.has(_r())&&void 0!==r&&(i=r)}catch{}return e.apply(i??this,t)}}catch{}},setup(e){In.set(e,!0)}}),Fn=[/^Script error\.?$/,/^Javascript error: Script error\.? on line 0$/,/^ResizeObserver loop completed with undelivered notifications.$/,/^Cannot redefine property: googletag$/,/^Can't find variable: gmo$/,/^undefined is not an object \(evaluating 'a\.[A-Z]'\)$/,/can't redefine non-configurable property "solana"/,/vv\(\)\.getRestrictions is not a function/,/Can't find variable: _AutofillCallbackHandler/,/Object Not Found Matching Id:\d+, MethodName:simulateEvent/,/^Java exception was raised during method invocation$/],Mn=(e={})=>{let t;return{name:"EventFilters",setup(r){const i=r.getOptions();t=Rn(e,i)},processEvent(r,i,n){if(!t){const r=n.getOptions();t=Rn(e,r)}return function(e,t){if(e.type){if("transaction"===e.type&&function(e,t){if(!t?.length)return!1;const r=e.transaction;return!!r&&$t(r,t)}(e,t.ignoreTransactions))return Pe&&Ne.warn(`Event dropped due to being matched by \`ignoreTransactions\` option.\nEvent: ${Vt(e)}`),!0}else{if(function(e,t){if(!t?.length)return!1;return rn(e).some(e=>$t(e,t))}(e,t.ignoreErrors))return Pe&&Ne.warn(`Event dropped due to being matched by \`ignoreErrors\` option.\nEvent: ${Vt(e)}`),!0;if(function(e){if(!e.exception?.values?.length)return!1;return!e.message&&!e.exception.values.some(e=>e.stacktrace||e.type&&"Error"!==e.type||e.value)}(e))return Pe&&Ne.warn(`Event dropped due to not having an error message, error type or stacktrace.\nEvent: ${Vt(e)}`),!0;if(function(e,t){if(!t?.length)return!1;const r=Ln(e);return!!r&&$t(r,t)}(e,t.denyUrls))return Pe&&Ne.warn(`Event dropped due to being matched by \`denyUrls\` option.\nEvent: ${Vt(e)}.\nUrl: ${Ln(e)}`),!0;if(!function(e,t){if(!t?.length)return!0;const r=Ln(e);return!r||$t(r,t)}(e,t.allowUrls))return Pe&&Ne.warn(`Event dropped due to not being matched by \`allowUrls\` option.\nEvent: ${Vt(e)}.\nUrl: ${Ln(e)}`),!0}return!1}(r,t)?null:r}}},kn=(e={})=>({...Mn(e),name:"InboundFilters"});function Rn(e={},t={}){return{allowUrls:[...e.allowUrls||[],...t.allowUrls||[]],denyUrls:[...e.denyUrls||[],...t.denyUrls||[]],ignoreErrors:[...e.ignoreErrors||[],...t.ignoreErrors||[],...e.disableErrorDefaults?[]:Fn],ignoreTransactions:[...e.ignoreTransactions||[],...t.ignoreTransactions||[]]}}function Ln(e){try{const t=[...e.exception?.values??[]].reverse().find(e=>void 0===e.mechanism?.parent_id&&e.stacktrace?.frames?.length),r=t?.stacktrace?.frames;return r?function(e=[]){for(let t=e.length-1;t>=0;t--){const r=e[t];if(r&&"<anonymous>"!==r.filename&&"[native code]"!==r.filename)return r.filename||null}return null}(r):null}catch{return Pe&&Ne.error(`Cannot extract url for event ${Vt(e)}`),null}}function zn(e,t,r,i,n,a){if(!n.exception?.values||!a||!gt(a.originalException,Error))return;const s=n.exception.values.length>0?n.exception.values[n.exception.values.length-1]:void 0;s&&(n.exception.values=Bn(e,t,i,a.originalException,r,n.exception.values,s,0))}function Bn(e,t,r,i,n,a,s,o){if(a.length>=r+1)return a;let l=[...a];if(gt(i[n],Error)){$n(s,o,i);const a=e(t,i[n]),u=l.length;Nn(a,n,u,o),l=Bn(e,t,r,i[n],n,[a,...l],a,u)}return On(i)&&i.errors.forEach((a,u)=>{if(gt(a,Error)){$n(s,o,i);const c=e(t,a),h=l.length;Nn(c,`errors[${u}]`,h,o),l=Bn(e,t,r,a,n,[c,...l],c,h)}}),l}function On(e){return Array.isArray(e.errors)}function $n(e,t,r){e.mechanism={handled:!0,type:"auto.core.linked_errors",...On(r)&&{is_exception_group:!0},...e.mechanism,exception_id:t}}function Nn(e,t,r,i){e.mechanism={handled:!0,...e.mechanism,type:"chained",source:t,exception_id:r,parent_id:i}}function jn(e){return function(e){return at(e)&&"__sentry_fetch_url_host__"in e&&"string"==typeof e.__sentry_fetch_url_host__}(e)?`${e.message} (${e.__sentry_fetch_url_host__})`:e.message}const Vn=/* @__PURE__ */new Set([]);const Un=/* @__PURE__ */new Set;function qn(){"console"in Ie&&Re.forEach(function(e){!Un.has(e)&&e in Ie.console&&(Un.add(e),_t(Ie.console,e,function(t){return Le[e]=t,function(...t){const r=t[0],i=Le[e],n=Vn.size&&"string"==typeof r&&$t(r,Vn);n||Qe("console",{args:t,level:e}),(!n||Pe&&Ne.isEnabled())&&i?.apply(Ie.console,t)}}))})}function Gn(e){return"warn"===e?"warning":["fatal","error","warning","log","info","debug"].includes(e)?e:"log"}const Zn=()=>{let e;return{name:"Dedupe",processEvent(t){if(t.type)return t;try{if(function(e,t){if(!t)return!1;if(function(e,t){const r=e.message,i=t.message;if(!r&&!i)return!1;if(r&&!i||!r&&i)return!1;if(r!==i)return!1;if(!Hn(e,t))return!1;if(!Wn(e,t))return!1;return!0}(e,t))return!0;if(function(e,t){const r=Xn(t),i=Xn(e);if(!r||!i)return!1;if(r.type!==i.type||r.value!==i.value)return!1;if(!Hn(e,t))return!1;if(!Wn(e,t))return!1;return!0}(e,t))return!0;return!1}(t,e))return Pe&&Ne.warn("Event dropped due to being a duplicate of previously captured event."),null}catch{}return e=t}}};function Wn(e,t){let r=He(e),i=He(t);if(!r&&!i)return!0;if(r&&!i||!r&&i)return!1;if(i.length!==r.length)return!1;for(let n=0;n<i.length;n++){const e=i[n],t=r[n];if(e.filename!==t.filename||e.lineno!==t.lineno||e.colno!==t.colno||e.function!==t.function)return!1}return!0}function Hn(e,t){let r=e.fingerprint,i=t.fingerprint;if(!r&&!i)return!0;if(r&&!i||!r&&i)return!1;try{return!(r.join("")!==i.join(""))}catch{return!1}}function Xn(e){return e.exception?.values?.[0]}const Yn=()=>({name:"ConversationId",setup(e){e.on("spanStart",e=>{const t=gr().getScopeData(),r=yr().getScopeData(),i=t.conversationId||r.conversationId;if(i){const{op:t,data:r,description:n}=Or(e);if(!t?.startsWith("gen_ai.")&&!r["ai.operationId"]&&!n?.startsWith("ai."))return;e.setAttribute("gen_ai.conversation.id",i)}})}});function Kn(e){return void 0===e?void 0:e>=400&&e<500?"warning":e>=500?"error":void 0}const Jn=Ie;function Qn(e){return e&&/^function\s+\w+\(\)\s+\{\s+\[native code\]\s+\}$/.test(e.toString())}function ea(){if("string"==typeof EdgeRuntime)return!0;if(!function(){if(!("fetch"in Jn))return!1;try{return new Headers,new Request("data:,"),new Response,!0}catch{return!1}}())return!1;if(Qn(Jn.fetch))return!0;let e=!1;const t=Jn.document;if(t&&"function"==typeof t.createElement)try{const r=t.createElement("iframe");r.hidden=!0,t.head.appendChild(r),r.contentWindow?.fetch&&(e=Qn(r.contentWindow.fetch)),t.head.removeChild(r)}catch(r){Pe&&Ne.warn("Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ",r)}return e}function ta(e,t){const r="fetch",i=Ke(r,e);return Je(r,()=>function(e,t=!1){if(t&&!ea())return;_t(Ie,"fetch",function(e){return function(...t){const r=new Error,{method:i,url:n}=function(e){if(0===e.length)return{method:"GET",url:""};if(2===e.length){const[t,r]=e;return{url:ia(t),method:ra(r,"method")?String(r.method).toUpperCase():yt(t)&&ra(t,"method")?String(t.method).toUpperCase():"GET"}}const t=e[0];return{url:ia(t),method:ra(t,"method")?String(t.method).toUpperCase():"GET"}}(t),a={args:t,fetchData:{method:i,url:n},startTimestamp:1e3*Ht(),virtualError:r,headers:na(t)};return Qe("fetch",{...a}),e.apply(Ie,t).then(async e=>(Qe("fetch",{...a,endTimestamp:1e3*Ht(),response:e}),e),e=>{Qe("fetch",{...a,endTimestamp:1e3*Ht(),error:e}),at(e)&&void 0===e.stack&&(e.stack=r.stack,vt(e,"framesToPop",1));const t=_r(),i=t?.getOptions().enhanceFetchErrorMessages??"always";if(!1!==i&&e instanceof TypeError&&("Failed to fetch"===e.message||"Load failed"===e.message||"NetworkError when attempting to fetch resource."===e.message))try{const t=new URL(a.fetchData.url).host;"always"===i?e.message=`${e.message} (${t})`:vt(e,"__sentry_fetch_url_host__",t)}catch{}throw e})}})}(0,t)),i}function ra(e,t){return pt(e)&&!!e[t]}function ia(e){return"string"==typeof e?e:e?ra(e,"url")?e.url:e.toString?e.toString():"":""}function na(e){const[t,r]=e;try{if("object"==typeof r&&null!==r&&"headers"in r&&r.headers)return new Headers(r.headers);if(yt(t))return new Headers(t.headers)}catch{}}const aa=Ie;function sa(){try{return aa.document.location.href}catch{return""}}const oa=Ie;let la=0;function ua(){return la>0}function ca(e,t={}){if("function"!=typeof e)return e;try{if(Object.prototype.hasOwnProperty.call(e,"__sentry_wrapped__")){const t=e.__sentry_wrapped__;return"function"==typeof t?t:e}if(bt(e))return e}catch{return e}const r=function(...r){Ie._sentryWrappedDepth=(Ie._sentryWrappedDepth||0)+1;try{const i=r.map(e=>ca(e,t));return e.apply(this,i)}catch(i){throw la++,setTimeout(()=>{la--}),function(...e){const t=pr(Fe());if(2===e.length){const[r,i]=e;return r?t.withSetScope(r,i):t.withScope(i)}t.withScope(e[0])}(e=>{e.addEventProcessor(e=>(t.mechanism&&(Ut(e,void 0),qt(e,t.mechanism)),e.extra={...e.extra,arguments:r},e)),Ii(i)}),i}finally{Ie._sentryWrappedDepth=(Ie._sentryWrappedDepth||0)-1}};try{for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t])}catch{}xt(r,e),vt(e,"__sentry_wrapped__",r);try{Object.getOwnPropertyDescriptor(r,"name").configurable&&Object.defineProperty(r,"name",{get:()=>e.name})}catch{}return r}function ha(){const e=sa(),{referrer:t}=oa.document||{},{userAgent:r}=oa.navigator||{};return{url:e,headers:{...t&&{Referer:t},...r&&{"User-Agent":r}}}}function da(e,t){const r=ma(e,t),i={type:_a(t),value:va(t)};return r.length&&(i.stacktrace={frames:r}),void 0===i.type&&""===i.value&&(i.value="Unrecoverable error caught"),i}function pa(e,t,r,i){const n=_r(),a=n?.getOptions().normalizeDepth,s=(o=t,Object.values(o).find(e=>e instanceof Error));var o;const l={__serialized__:kt(t,a)};if(s)return{exception:{values:[da(e,s)]},extra:l};const u={exception:{values:[{type:ft(t)?t.constructor.name:i?"UnhandledRejection":"Error",value:wa(t,{isUnhandledRejection:i})}]},extra:l};if(r){const t=ma(e,r);t.length&&(u.exception.values[0].stacktrace={frames:t})}return u}function fa(e,t){return{exception:{values:[da(e,t)]}}}function ma(e,t){const r=t.stacktrace||t.stack||"",i=function(e){if(e&&ga.test(e.message))return 1;return 0}(t),n=function(e){if("number"==typeof e.framesToPop)return e.framesToPop;return 0}(t);try{return e(r,i,n)}catch{}return[]}const ga=/Minified React error #\d+;/i;function ya(e){return"undefined"!=typeof WebAssembly&&void 0!==WebAssembly.Exception&&e instanceof WebAssembly.Exception}function _a(e){const t=e?.name;if(!t&&ya(e)){return e.message&&Array.isArray(e.message)&&2==e.message.length?e.message[0]:"WebAssembly.Exception"}return t}function va(e){const t=e?.message;return ya(e)?Array.isArray(e.message)&&2==e.message.length?e.message[1]:"wasm exception":t?t.error&&"string"==typeof t.error.message?jn(t.error):jn(e):"No error message"}function xa(e,t,r,i,n){let a;if(ot(t)&&t.error){return fa(e,t.error)}if(lt(t)||st(t,"DOMException")){const n=t;if("stack"in t){a=fa(e,t);const n=a.exception?.values?.[0];if(i&&r&&n&&!n.stacktrace){const t=ma(e,r);t.length&&(n.stacktrace={frames:t},qt(a,{synthetic:!0}))}}else{const t=n.name||(lt(n)?"DOMError":"DOMException"),s=n.message?`${t}: ${n.message}`:t;a=ba(e,s,r,i),Ut(a,s)}return"code"in n&&(a.tags={...a.tags,"DOMException.code":`${n.code}`}),a}if(at(t))return fa(e,t);if(dt(t)||ft(t)){return a=pa(e,t,r,n),qt(a,{synthetic:!0}),a}return a=ba(e,t,r,i),Ut(a,`${t}`),qt(a,{synthetic:!0}),a}function ba(e,t,r,i){const n={};if(i&&r){const i=ma(e,r);i.length&&(n.exception={values:[{value:t,stacktrace:{frames:i}}]}),qt(n,{synthetic:!0})}if(ct(t)){const{__sentry_template_string__:e,__sentry_template_values__:r}=t;return n.logentry={message:e,params:r},n}return n.message=t,n}function wa(e,{isUnhandledRejection:t}){const r=function(e){const t=Object.keys(wt(e));return t.sort(),t[0]?t.join(", "):"[object has no keys]"}(e),i=t?"promise rejection":"exception";if(ot(e))return`Event \`ErrorEvent\` captured as ${i} with message \`${e.message}\``;if(ft(e)){return`Event \`${function(e){try{const t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}(e)}\` (type=${e.type}) captured as ${i}`}return`Object captured as ${i} with keys: ${r}`}let Ea=class extends gn{constructor(e){const t=(r=e,{release:"string"==typeof __SENTRY_RELEASE__?__SENTRY_RELEASE__:oa.SENTRY_RELEASE?.id,sendClientReports:!0,parentSpanIsAlwaysRootSpan:!0,...r});var r;!function(e,t,r=[t],i="npm"){const n=(e._metadata=e._metadata||{}).sdk=e._metadata.sdk||{};n.name||(n.name=`sentry.javascript.${t}`,n.packages=r.map(e=>({name:`${i}:@sentry/${e}`,version:Ce})),n.version=Ce)}(t,"browser",["browser"],oa.SENTRY_SDK_SOURCE||"npm"),super(t);const{userInfo:i}=this.getDataCollectionOptions();t._metadata?.sdk&&(t._metadata.sdk.settings={infer_ip:i?"auto":"never",...t._metadata.sdk.settings});const{sendClientReports:n}=this._options;oa.document&&oa.document.addEventListener("visibilitychange",()=>{"hidden"===oa.document.visibilityState&&(n&&this._flushOutcomes(),queueMicrotask(()=>{this.flush()}))}),i&&this.on("beforeSendSession",Tn)}eventFromException(e,t){return function(e,t,r,i){const n=xa(e,t,r?.syntheticException||void 0,i);return qt(n),n.level="error",r?.event_id&&(n.event_id=r.event_id),yi(n)}(this._options.stackParser,e,t,this._options.attachStacktrace)}eventFromMessage(e,t="info",r){return function(e,t,r="info",i,n){const a=ba(e,t,i?.syntheticException||void 0,n);return a.level=r,i?.event_id&&(a.event_id=i.event_id),yi(a)}(this._options.stackParser,e,t,r,this._options.attachStacktrace)}_prepareEvent(e,t,r,i){return e.platform=e.platform||"javascript",super._prepareEvent(e,t,r,i)}};const Sa="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,Da=Ie;function Ta(e,t,r){Da.document&&Da.addEventListener(e,t,r)}function Aa(e,t,r){Da.document&&Da.removeEventListener(e,t,r)}const Pa={};try{"undefined"!=typeof Node&&(Pa.parentNode=Object.getOwnPropertyDescriptor(Node.prototype,"parentNode").get),"undefined"!=typeof Element&&(Pa.tagName=Object.getOwnPropertyDescriptor(Element.prototype,"tagName").get,Pa.id=Object.getOwnPropertyDescriptor(Element.prototype,"id").get,Pa.className=Object.getOwnPropertyDescriptor(Element.prototype,"className").get,Pa.getAttribute=Element.prototype.getAttribute),"undefined"!=typeof HTMLElement&&(Pa.dataset=Object.getOwnPropertyDescriptor(HTMLElement.prototype,"dataset").get)}catch{}function Ia(e,t,r){const i=Pa[t];if(i)try{return i.call(e,r)}catch{}const n=e[t];return"function"==typeof n?n.call(e,r):n}function Ca(e,t={}){if(!e)return"<unknown>";try{let r=e;const i=5,n=[];let a=0,s=0;const o=" > ",l=o.length;let u;const c=Array.isArray(t)?t:t.keyAttrs,h=!Array.isArray(t)&&t.maxStringLength||80;for(;r&&a++<i&&(u=Fa(r,c),!("html"===u||a>1&&s+n.length*l+u.length>=h));)n.push(u),s+=u.length,r=Ia(r,"parentNode");return n.reverse().join(o)}catch{return"<unknown>"}}function Fa(e,t){const r=[],i=Ia(e,"tagName");if(!i)return"";if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement){const t=Ia(e,"dataset");if(t){if(t.sentryComponent)return t.sentryComponent;if(t.sentryElement)return t.sentryElement}}r.push(i.toLowerCase());const n=t?.length?t.filter(t=>Ia(e,"getAttribute",t)).map(t=>[t,Ia(e,"getAttribute",t)]):null;if(n?.length)n.forEach(e=>{r.push(`[${e[0]}="${e[1]}"]`)});else{const t=Ia(e,"id");t&&r.push(`#${t}`);const i=Ia(e,"className");if(i&&ut(i)){const e=i.split(/\s+/);for(const t of e)r.push(`.${t}`)}}for(const a of["aria-label","type","name","title","alt"]){const t=Ia(e,"getAttribute",a);t&&r.push(`[${a}="${t}"]`)}return r.join("")}let Ma,ka,Ra,La;function za(){if(!Da.document)return;const e=Qe.bind(null,"dom"),t=Ba(e,!0);Da.document.addEventListener("click",t,!1),Da.document.addEventListener("keypress",t,!1),["EventTarget","Node"].forEach(t=>{const r=Da,i=r[t]?.prototype;i?.hasOwnProperty?.("addEventListener")&&(_t(i,"addEventListener",function(t){return function(r,i,n){if("click"===r||"keypress"==r)try{const i=this.__sentry_instrumentation_handlers__=this.__sentry_instrumentation_handlers__||{},a=i[r]=i[r]||{refCount:0};if(!a.handler){const i=Ba(e);a.handler=i,t.call(this,r,i,n)}a.refCount++}catch{}return t.call(this,r,i,n)}}),_t(i,"removeEventListener",function(e){return function(t,r,i){if("click"===t||"keypress"==t)try{const r=this.__sentry_instrumentation_handlers__||{},n=r[t];n&&(n.refCount--,n.refCount<=0&&(e.call(this,t,n.handler,i),n.handler=void 0,delete r[t]),0===Object.keys(r).length&&delete this.__sentry_instrumentation_handlers__)}catch{}return e.call(this,t,r,i)}}))})}function Ba(e,t=!1){return r=>{if(!r||r._sentryCaptured)return;const i=function(e){try{return e.target}catch{return null}}(r);if(function(e,t){return"keypress"===e&&(!t?.tagName||"INPUT"!==t.tagName&&"TEXTAREA"!==t.tagName&&!t.isContentEditable)}(r.type,i))return;vt(r,"_sentryCaptured",!0),i&&!i._sentryId&&vt(i,"_sentryId",Nt());const n="keypress"===r.type?"input":r.type;if(!function(e){if(e.type!==ka)return!1;try{if(!e.target||e.target._sentryId!==Ra)return!1}catch{}return!0}(r)){e({event:r,name:n,global:t}),ka=r.type,Ra=i?i._sentryId:void 0}clearTimeout(Ma),Ma=Da.setTimeout(()=>{Ra=void 0,ka=void 0},1e3)}}function Oa(e){const t="history";Ke(t,e),Je(t,$a)}function $a(){function e(e){return function(...t){const r=t.length>2?t[2]:void 0;if(r){const i=La,n=function(e){try{return new URL(e,Da.location.origin).toString()}catch{return e}}(String(r));if(La=n,i===n)return e.apply(this,t);Qe("history",{from:i,to:n})}return e.apply(this,t)}}Da.addEventListener("popstate",()=>{const e=Da.location.href,t=La;if(La=e,t===e)return;Qe("history",{from:t,to:e})}),"history"in Jn&&Jn.history&&(_t(Da.history,"pushState",e),_t(Da.history,"replaceState",e))}const Na={};const ja="__sentry_xhr_v3__";function Va(){if(!Da.XMLHttpRequest)return;const e=XMLHttpRequest.prototype;e.open=new Proxy(e.open,{apply(e,t,r){const i=new Error,n=1e3*Ht(),a=ut(r[0])?r[0].toUpperCase():void 0,s=function(e){if(ut(e))return e;try{return e.toString()}catch{}return}(r[1]);if(!a||!s)return e.apply(t,r);t[ja]={method:a,url:s,request_headers:{}},"POST"===a&&s.match(/sentry_key/)&&(t.__sentry_own_request__=!0);const o=()=>{const e=t[ja];if(e&&4===t.readyState){try{e.status_code=t.status}catch{}Qe("xhr",{endTimestamp:1e3*Ht(),startTimestamp:n,xhr:t,virtualError:i}),t.removeEventListener("readystatechange",o)}};return"onreadystatechange"in t&&"function"==typeof t.onreadystatechange?t.onreadystatechange=new Proxy(t.onreadystatechange,{apply:(e,t,r)=>(o(),e.apply(t,r))}):t.addEventListener("readystatechange",o),t.setRequestHeader=new Proxy(t.setRequestHeader,{apply(e,t,r){const[i,n]=r,a=t[ja];return a&&ut(i)&&ut(n)&&(a.request_headers[i.toLowerCase()]=n),e.apply(t,r)}}),e.apply(t,r)}}),e.send=new Proxy(e.send,{apply(e,t,r){const i=t[ja];if(!i)return e.apply(t,r);void 0!==r[0]&&(i.body=r[0]);return Qe("xhr",{startTimestamp:1e3*Ht(),xhr:t}),e.apply(t,r)}})}function Ua(e,t=function(e){const t=Na[e];if(t)return t;let r=Da[e];if(Qn(r))return Na[e]=r.bind(Da);const i=Da.document;if(i&&"function"==typeof i.createElement)try{const t=i.createElement("iframe");t.hidden=!0,i.head.appendChild(t);const n=t.contentWindow;n?.[e]&&(r=n[e]),i.head.removeChild(t)}catch(gd){Sa&&Ne.warn(`Could not create sandbox iframe for ${e} check, bailing to window.${e}: `,gd)}return r?Na[e]=r.bind(Da):r}("fetch")){let r=0,i=0;return tn(e,async function(n){const a=n.body.length;r+=a,i++;const s={body:n.body,method:"POST",referrerPolicy:"strict-origin",headers:e.headers,keepalive:r<=6e4&&i<15,...e.fetchOptions};try{const r=await t(e.url,s);return{statusCode:r.status,headers:{"x-sentry-rate-limits":r.headers.get("X-Sentry-Rate-Limits"),"retry-after":r.headers.get("Retry-After")}}}catch(gd){throw Na["fetch"]=void 0,gd}finally{r-=a,i--}},Qi(e.bufferSize||40))}const qa="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__;function Ga(e,t,r,i){const n={filename:e,function:"<anonymous>"===t?je:t,in_app:!0};return void 0!==r&&(n.lineno=r),void 0!==i&&(n.colno=i),n}const Za=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Wa=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Ha=/\((\S*)(?::(\d+))(?::(\d+))\)/,Xa=/at (.+?) ?\(data:(.+?),/,Ya=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Ka=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Ja=qe(...[[30,e=>{const t=e.match(Xa);if(t)return{filename:`<data:${t[2]}>`,function:t[1]};const r=Za.exec(e);if(r){const[,e,t,i]=r;return Ga(e,je,+t,+i)}const i=Wa.exec(e);if(i){if(0===i[2]?.indexOf("eval")){const e=Ha.exec(i[2]);e&&(i[2]=e[1],i[3]=e[2],i[4]=e[3])}const[e,t]=Qa(i[1]||je,i[2]);return Ga(t,e,i[3]?+i[3]:void 0,i[4]?+i[4]:void 0)}}],[50,e=>{const t=Ya.exec(e);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){const e=Ka.exec(t[3]);e&&(t[1]=t[1]||"eval",t[3]=e[1],t[4]=e[2],t[5]="")}let e=t[3],r=t[1]||je;return[r,e]=Qa(r,e),Ga(e,r,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}}]]),Qa=(e,t)=>{const r=-1!==e.indexOf("safari-extension"),i=-1!==e.indexOf("safari-web-extension");return r||i?[-1!==e.indexOf("@")?e.split("@")[0]:je,r?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]},es=1024,ts=(e={})=>{const t={console:!0,dom:!0,fetch:!0,history:!0,sentry:!0,xhr:!0,...e};return{name:"Breadcrumbs",setup(e){var r;t.console&&function(e){const t="console",r=Ke(t,e);Je(t,qn)}(function(e){return function(t){if(_r()!==e)return;const r={category:"console",data:{arguments:t.args,logger:"console"},level:Gn(t.level),message:Bt(t.args," ")};if("assert"===t.level){if(!1!==t.args[0])return;r.message=`Assertion failed: ${Bt(t.args.slice(1)," ")||"console.assert"}`,r.data.arguments=t.args.slice(1)}Pn(r,{input:t.args,level:t.level})}}(e)),t.dom&&(r=function(e,t){return function(r){if(_r()!==e)return;let i,n,a="object"==typeof t?t.serializeAttribute:void 0,s="object"==typeof t&&"number"==typeof t.maxStringLength?t.maxStringLength:void 0;s&&s>es&&(qa&&Ne.warn(`\`dom.maxStringLength\` cannot exceed 1024, but a value of ${s} was configured. Sentry will use 1024 instead.`),s=es),"string"==typeof a&&(a=[a]);try{const e=r.event,t=function(e){return!!e&&!!e.target}(e)?e.target:e;i=Ca(t,{keyAttrs:a,maxStringLength:s}),n=function(e,t=5){if(!aa.HTMLElement)return null;let r=e;for(let i=0;i<t;i++){if(!r)return null;if(r instanceof HTMLElement){if(r.dataset.sentryComponent)return r.dataset.sentryComponent;if(r.dataset.sentryElement)return r.dataset.sentryElement}r=r.parentNode}return null}(t)}catch{i="<unknown>"}if(0===i.length)return;const o={category:`ui.${r.name}`,message:i};n&&(o.data={"ui.component_name":n}),Pn(o,{event:r.event,name:r.name,global:r.global})}}(e,t.dom),Ke("dom",r),Je("dom",za)),t.xhr&&function(e){Ke("xhr",e),Je("xhr",Va)}(function(e){return function(t){if(_r()!==e)return;const{startTimestamp:r,endTimestamp:i}=t,n=t.xhr[ja];if(!r||!i||!n)return;const{method:a,url:s,status_code:o,body:l}=n,u={method:a,url:s,status_code:o},c={xhr:t.xhr,input:l,startTimestamp:r,endTimestamp:i},h={category:"xhr",data:u,type:"http",level:Kn(o)};e.emit("beforeOutgoingRequestBreadcrumb",h,c),Pn(h,c)}}(e)),t.fetch&&ta(function(e){return function(t){if(_r()!==e)return;const{startTimestamp:r,endTimestamp:i}=t;if(i&&(!t.fetchData.url.match(/sentry_key/)||"POST"!==t.fetchData.method))if(t.error){const n={data:t.error,input:t.args,startTimestamp:r,endTimestamp:i},a={category:"fetch",data:t.fetchData,level:"error",type:"http"};e.emit("beforeOutgoingRequestBreadcrumb",a,n),Pn(a,n)}else{const n=t.response,a={...t.fetchData,status_code:n?.status},s={input:t.args,response:n,startTimestamp:r,endTimestamp:i},o={category:"fetch",data:a,type:"http",level:Kn(a.status_code)};e.emit("beforeOutgoingRequestBreadcrumb",o,s),Pn(o,s)}}}(e)),t.history&&Oa(function(e){return function(t){if(_r()!==e)return;let r=t.from,i=t.to;const n=Dn(oa.location.href);let a=r?Dn(r):void 0;const s=Dn(i);a?.path||(a=n),n.protocol===s.protocol&&n.host===s.host&&(i=s.relative),n.protocol===a.protocol&&n.host===a.host&&(r=a.relative),Pn({category:"navigation",data:{from:r,to:i}})}}(e)),t.sentry&&e.on("beforeSendEvent",function(e){return function(t){_r()===e&&Pn({category:"sentry."+("transaction"===t.type?"transaction":"event"),event_id:t.event_id,level:t.level,message:Vt(t)},{event:t})}}(e))}}};const rs="EventTarget,Window,Node,ApplicationCache,AudioTrackList,BroadcastChannel,ChannelMergerNode,CryptoOperation,EventSource,FileReader,HTMLUnknownElement,IDBDatabase,IDBRequest,IDBTransaction,KeyOperation,MediaController,MessagePort,ModalWindow,Notification,SVGElementInstance,Screen,SharedWorker,TextTrack,TextTrackCue,TextTrackList,WebSocket,WebSocketWorker,Worker,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload".split(","),is=(e={})=>{const t={XMLHttpRequest:!0,eventTarget:!0,requestAnimationFrame:!0,setInterval:!0,setTimeout:!0,unregisterOriginalCallbacks:!1,...e};return{name:"BrowserApiErrors",setupOnce(){t.setTimeout&&_t(oa,"setTimeout",ns),t.setInterval&&_t(oa,"setInterval",ns),t.requestAnimationFrame&&_t(oa,"requestAnimationFrame",as),t.XMLHttpRequest&&"XMLHttpRequest"in oa&&_t(XMLHttpRequest.prototype,"send",ss);const e=t.eventTarget;if(e){(Array.isArray(e)?e:rs).forEach(e=>function(e,t){const r=oa,i=r[e]?.prototype;if(!i?.hasOwnProperty?.("addEventListener"))return;_t(i,"addEventListener",function(r){return function(i,n,a){try{"function"==typeof n.handleEvent&&(n.handleEvent=ca(n.handleEvent,{mechanism:{data:{handler:We(n),target:e},handled:!1,type:"auto.browser.browserapierrors.handleEvent"}}))}catch{}return t.unregisterOriginalCallbacks&&function(e,t,r){e&&"object"==typeof e&&"removeEventListener"in e&&"function"==typeof e.removeEventListener&&e.removeEventListener(t,r)}(this,i,n),r.apply(this,[i,ca(n,{mechanism:{data:{handler:We(n),target:e},handled:!1,type:"auto.browser.browserapierrors.addEventListener"}}),a])}}),_t(i,"removeEventListener",function(e){return function(t,r,i){try{if(Object.prototype.hasOwnProperty.call(r,"__sentry_wrapped__")){const n=r.__sentry_wrapped__;n&&e.call(this,t,n,i)}}catch{}return e.call(this,t,r,i)}})}(e,t))}}}};function ns(e){return function(...t){const r=t[0];return t[0]=ca(r,{mechanism:{handled:!1,type:`auto.browser.browserapierrors.${We(e)}`}}),e.apply(this,t)}}function as(e){return function(t){return e.apply(this,[ca(t,{mechanism:{data:{handler:We(e)},handled:!1,type:"auto.browser.browserapierrors.requestAnimationFrame"}})])}}function ss(e){return function(...t){const r=this;return["onload","onerror","onprogress","onreadystatechange"].forEach(e=>{e in r&&"function"==typeof r[e]&&_t(r,e,function(t){const r={mechanism:{data:{handler:We(t)},handled:!1,type:`auto.browser.browserapierrors.xhr.${e}`}},i=bt(t);return i&&(r.mechanism.data.handler=We(i)),ca(t,r)})}),e.apply(this,t)}}const os=(e={})=>{const t=e.lifecycle??"route";return{name:"BrowserSession",setupOnce(){if(void 0===oa.document)return void(qa&&Ne.warn("Using the `browserSessionIntegration` in non-browser environments is not supported."));ki({ignoreDuration:!0});let e=!1;(e=>{const t=Da.requestIdleCallback||Da.setTimeout;"hidden"===Da.document?.visibilityState?e():(Ta("visibilitychange",e=(e=>{let t=!1;return()=>{t||(e(),t=!0)}})(e),{once:!0,capture:!0}),Ta("pagehide",e,{once:!0,capture:!0}),t(()=>{e(),Aa("visibilitychange",e,{capture:!0}),Aa("pagehide",e,{capture:!0})}))})(()=>{e||(zi(),e=!0)});const r=yr();let i=r.getUser();r.addScopeListener(t=>{const r=t.getUser();i?.id===r?.id&&i?.ip_address===r?.ip_address||(i=r,e&&zi())}),"route"===t&&Oa(({from:t,to:r})=>{t!==r&&(ki({ignoreDuration:!0}),zi(),e=!0)})}}},ls=()=>({name:"CultureContext",preprocessEvent(e){const t=us();t&&(e.contexts={...e.contexts,culture:{...t,...e.contexts?.culture}})},processSegmentSpan(e){const t=us();t&&gi(e,{"culture.locale":t.locale,"culture.timezone":t.timezone,"culture.calendar":t.calendar})}});function us(){try{const e=oa.Intl;if(!e)return;const t=e.DateTimeFormat().resolvedOptions();return{locale:t.locale,timezone:t.timeZone,calendar:t.calendar}}catch{return}}const cs=(e={})=>{const t={onerror:!0,onunhandledrejection:!0,...e};return{name:"GlobalHandlers",setupOnce(){Error.stackTraceLimit=50},setup(e){t.onerror&&(!function(e){!function(e){const t="error";Ke(t,e),Je(t,tt)}(t=>{const{stackParser:r,attachStacktrace:i}=ds();if(_r()!==e||ua())return;const{msg:n,url:a,line:s,column:o,error:l}=t,u=function(e,t,r,i){const n=e.exception=e.exception||{},a=n.values=n.values||[],s=a[0]=a[0]||{},o=s.stacktrace=s.stacktrace||{},l=o.frames=o.frames||[];0===l.length&&l.push({colno:i,lineno:r,filename:ps(t)??sa(),function:je,in_app:!0});return e}(xa(r,l||n,void 0,i,!1),a,s,o);u.level="error",Fi(u,{originalException:l,mechanism:{handled:!1,type:"auto.browser.global_handlers.onerror"}})})}(e),hs("onerror")),t.onunhandledrejection&&(!function(e){!function(e){const t="unhandledrejection";Ke(t,e),Je(t,it)}(t=>{const{stackParser:r,attachStacktrace:i}=ds();if(_r()!==e||ua())return;const n=function(e){if(ht(e))return e;try{if("reason"in e)return e.reason;if("detail"in e&&"reason"in e.detail)return e.detail.reason}catch{}return e}(t),a=ht(n)?{exception:{values:[{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(n)}`}]}}:xa(r,n,void 0,i,!0);a.level="error",Fi(a,{originalException:n,mechanism:{handled:!1,type:"auto.browser.global_handlers.onunhandledrejection"}})})}(e),hs("onunhandledrejection"))}}};function hs(e){qa&&Ne.log(`Global Handler attached: ${e}`)}function ds(){const e=_r();return e?.getOptions()||{stackParser:()=>[],attachStacktrace:!1}}function ps(e){if(ut(e)&&0!==e.length)return e.startsWith("data:")?`<${function(e,t=!0){if(e.startsWith("data:")){const r=e.match(/^data:([^;,]+)/),i=r?r[1]:"text/plain",n=e.includes(";base64,"),a=e.indexOf(",");let s="";if(t&&-1!==a){const t=e.slice(a+1);s=t.length>10?`${t.slice(0,10)}... [truncated]`:t}return`data:${i}${n?",base64":""}${s?`,${s}`:""}`}return e}(e,!1)}>`:e}const fs=()=>({name:"HttpContext",preprocessEvent(e){if(!oa.navigator&&!oa.location&&!oa.document)return;const t=ha(),r={...t.headers,...e.request?.headers};e.request={...t,...e.request,headers:r}},processSegmentSpan(e){const t=e.attributes?.[xr];if(!oa.navigator&&!oa.location&&!oa.document)return;const r=ha();gi(e,{[fi]:"http.client"!==t?r.url:void 0,"http.request.header.user_agent":r.headers["User-Agent"],"http.request.header.referer":r.headers.Referer})}}),ms=(e={})=>{const t=e.limit||5,r=e.key||"cause";return{name:"LinkedErrors",preprocessEvent(e,i,n){zn(da,n.getOptions().stackParser,r,t,e,i)}}},gs=/^HTML(\w*)Element$/;function ys(e){if("undefined"!=typeof window&&e===window)return"[Window]";if("undefined"!=typeof document&&e===document)return"[Document]";if(function(e){if("undefined"==typeof Element)return!1;try{return e instanceof Element}catch{return!1}}(e)){const t=function(e){const t=Object.getPrototypeOf(e);return t?.constructor?t.constructor.name:"null prototype"}(e);if(gs.test(t))return`[HTMLElement: ${Ca(e)}]`}}function _s(){return!!function(){if(void 0===oa.window)return!1;const e=oa;if(e.nw)return!1;const t=e.chrome||e.browser;if(!t?.runtime?.id)return!1;const r=sa();return!(oa===oa.top&&/^(?:chrome-extension|moz-extension|ms-browser-extension|safari-web-extension):\/\//.test(r))}()&&(qa&&ze(()=>{console.error("[Sentry] You cannot use Sentry.init() in a browser extension, see: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/")}),!0)}function vs(e={}){const t=!e.skipBrowserExtensionCheck&&_s();let r=null==e.defaultIntegrations?[kn(),Cn(),Yn(),is(),ts(),cs(),ms(),Zn(),fs(),ls(),os()]:e.defaultIntegrations;const i={...e,enabled:!t&&e.enabled,stackParser:(n=e.stackParser||Ja,Array.isArray(n)?qe(...n):n),integrations:Ni({integrations:e.integrations,defaultIntegrations:r}),transport:e.transport||Ua};var n;return Ct=ys,Sn(Ea,i)}class xs{constructor(){this.initialized=!1}static initialize(e){const t=xs.getInstance();if(t.initialized)return void Mi("component",e);vs({dsn:"https://98a864152051bb3d42f8e955f2ab3078@sentry.mapvx.app/6",environment:"production",release:"0.10.0"}),Mi("component",e),t.initialized=!0}static getInstance(){return xs.instance||(xs.instance=new xs),xs.instance}error(e,t){Ii(e,t?{extra:t}:void 0)}info(e,t){Ci(e,{level:"info",extra:t})}warning(e,t){Ci(e,{level:"warning",extra:t})}critical(e,t){Ci(e,{level:"fatal",extra:t})}}
|
|
41
41
|
/**
|
|
42
42
|
* @license
|
|
43
43
|
* Copyright 2021 Google LLC
|
|
@@ -68,4 +68,4 @@ let ws=class{get value(){return this.o}set value(e){this.setValue(e)}setValue(e,
|
|
|
68
68
|
* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.9.0/LICENSE.txt
|
|
69
69
|
*/function MC(){var e=new Id(4);return Id!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let kC,RC,LC;const zC={frame(e,t,r,i){let n=i||window,a=n.requestAnimationFrame(e=>{s(),t(e)}),{unsubscribe:s}=of(e.signal,"abort",()=>{s(),n.cancelAnimationFrame(a),r(new xf(e.signal.reason))},!1)},frameAsync(e,t){return new Promise((r,i)=>{this.frame(e,r,i,t)})},getImageData(e,t=0){return this.getImageCanvasContext(e).getImageData(-t,-t,e.width+2*t,e.height+2*t)},getImageCanvasContext(e){let t;if(Ad()&&!Pd())t=new OffscreenCanvas(e.width,e.height).getContext("2d",{willReadFrequently:!0});else{let r=window.document.createElement("canvas");r.width=e.width,r.height=e.height,t=r.getContext("2d",{willReadFrequently:!0})}if(!t)throw Error("failed to create canvas 2d context");return t.drawImage(e,0,0,e.width,e.height),t},resolveURL:e=>(kC||=document.createElement("a"),kC.href=e,kC.href),get hardwareConcurrency(){return typeof navigator<"u"&&navigator.hardwareConcurrency||4},get prefersReducedMotion(){return void 0===LC?!!matchMedia&&(RC??=matchMedia("(prefers-reduced-motion: reduce)"),RC.matches):LC},set prefersReducedMotion(e){LC=e}},BC=new class{constructor(){this._frozenAt=null}getCurrentTime(){return null===this._frozenAt?performance.now():this._frozenAt}setNow(e){this._frozenAt=e}restoreNow(){this._frozenAt=null}isFrozen(){return null!==this._frozenAt}};function OC(){return BC.getCurrentTime()}var $C=class e{static{this.docStyle=typeof window<"u"&&window.document?.documentElement.style}static{this.selectProp=!e.docStyle||"userSelect"in e.docStyle?"userSelect":"webkitUserSelect"}static create(e,t,r){let i=window.document.createElement(e);return void 0!==t&&(i.className=t),r&&r.appendChild(i),i}static createNS(e,t){return window.document.createElementNS(e,t)}static disableDrag(){e.docStyle&&e.selectProp&&(e.userSelect=e.docStyle[e.selectProp],e.docStyle[e.selectProp]="none")}static enableDrag(){e.docStyle&&e.selectProp&&(e.docStyle[e.selectProp]=e.userSelect)}static suppressClickInternal(t){t.preventDefault(),t.stopPropagation(),window.removeEventListener("click",e.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",e.suppressClickInternal,!0),window.setTimeout(()=>{window.removeEventListener("click",e.suppressClickInternal,!0)},0)}static getScale(e){let t=e.getBoundingClientRect();return{x:t.width/e.offsetWidth||1,y:t.height/e.offsetHeight||1,boundingClientRect:t}}static getPoint(e,t,r){let i=t.boundingClientRect;return new Sd((r.clientX-i.left)/t.x-e.clientLeft,(r.clientY-i.top)/t.y-e.clientTop)}static mousePos(t,r){let i=e.getScale(t);return e.getPoint(t,i,r)}static touchPos(t,r){let i=[],n=e.getScale(t);for(let a of r)i.push(e.getPoint(t,n,a));return i}static sanitize(t){let r=(new DOMParser).parseFromString(t,"text/html").body||document.createElement("body"),i=r.querySelectorAll("script, iframe");for(let e of i)e.remove();return e.clean(r),r.innerHTML}static isPossiblyDangerous(e,t){let r=t.replace(/\s+/g,"").toLowerCase();if(["src","href","xlink:href"].includes(e)&&(r.includes("javascript:")||r.includes("data:"))||"srcdoc"===e||e.startsWith("on"))return!0}static clean(t){let r=t.children;for(let i of r)e.removeAttributes(i),e.clean(i)}static removeAttributes(t){for(let{name:r,value:i}of Array.from(t.attributes))e.isPossiblyDangerous(r,i)&&t.removeAttribute(r)}};let NC;(function(e){let t,r,i,n;e.resetRequestQueue=()=>{t=[],r=0,i=0,n={}},e.addThrottleControl=e=>{let t=i++;return n[t]=e,t},e.removeThrottleControl=e=>{delete n[e],o()};e.transformAndGetImage=async function(e,t,r,i,n=!0,a){let s=await e.transformRequest(t,r);return wf(i.signal),NC.getImage(s,i,n,a)},e.getImage=(e,r,i=!0,n)=>new Promise((a,s)=>{e.headers||={},e.headers.accept="image/webp,*/*",jp(e,{type:"image"});let l={abortController:r,requestParameters:e,supportImageRefresh:i,imageBitmapOptions:n,state:"queued",onError:e=>{s(e)},onSuccess:e=>{a(e)}};t.push(l),o()});let a=(e,t)=>"function"==typeof createImageBitmap?(async(e,t)=>{let r=new Blob([new Uint8Array(e)],{type:"image/png"});try{return createImageBitmap(r,t)}catch(e){throw Error(`Could not load image because of ${xp(e).message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})(e,t):(e=>new Promise((t,r)=>{let i=new Image;i.onload=()=>{t(i),URL.revokeObjectURL(i.src),i.onload=null,window.requestAnimationFrame(()=>i.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=")},i.onerror=()=>r(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 n=new Blob([new Uint8Array(e)],{type:"image/png"});i.src=URL.createObjectURL(n)}))(e),s=async e=>{e.state="running";let{requestParameters:t,supportImageRefresh:i,imageBitmapOptions:n,onError:s,onSuccess:u,abortController:c}=e,h=!1===i&&!n&&!rf(self)&&!Sf(t.url)&&(!t.headers||Object.keys(t.headers).reduce((e,t)=>e&&"accept"===t,!0));r++;let d=h?l(t,c):Pf(t,c);try{let t=await d;delete e.abortController,e.state="completed",t.data instanceof HTMLImageElement||af(t.data)?u(t):t.data&&0!==t.data.byteLength?u({data:await a(t.data,n),cacheControl:t.cacheControl,expires:t.expires}):u({data:null,cacheControl:t.cacheControl,expires:t.expires})}catch(t){delete e.abortController,s(xp(t))}finally{r--,o()}},o=()=>{let e=(()=>{for(let e of Object.keys(n))if(n[e]())return!0;return!1})()?Ef.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:Ef.MAX_PARALLEL_IMAGE_REQUESTS;for(let i=r;i<e&&t.length>0;i++){let e=t.shift();e.abortController.signal.aborted?i--:s(e)}},l=(e,t)=>new Promise((r,i)=>{let n=new Image,a=e.url,s=e.credentials;s&&"include"===s?n.crossOrigin="use-credentials":(s&&"same-origin"===s||!Ff(a))&&(n.crossOrigin="anonymous"),t.signal.addEventListener("abort",()=>{n.src="",i(new xf(t.signal.reason))}),n.fetchPriority="high",n.onload=()=>{n.onerror=n.onload=null,r({data:n})},n.onerror=()=>{n.onerror=n.onload=null,!t.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."))},n.src=a})})(NC||={}),NC.resetRequestQueue();var jC=class{constructor(e){this._transformRequestFn=e??null}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}},VC=class extends Rf{},UC=class extends VC{},qC=class extends VC{constructor(e={}){super("style.load",e)}},GC=class extends VC{constructor(e,t={}){super(e,t),this.dataType="style"}},ZC=class extends VC{constructor(e,t={}){super(e,t),this.dataType="source"}},WC=class extends VC{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,r,i={}){r=r instanceof MouseEvent?r:new MouseEvent(e,r);let n=$C.mousePos(t.getCanvas(),r);super(e,jp({point:n,lngLat:t.unproject(n),originalEvent:r},i)),this._defaultPrevented=!1,this.target=t}},HC=class extends VC{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,r){let i="touchend"===e?r.changedTouches:r.touches,n=$C.touchPos(t.getCanvasContainer(),i),a=n.map(e=>t.unproject(e)),s=n.reduce((e,t,r,i)=>e.add(t.div(i.length)),new Sd(0,0));super(e,{points:n,point:s,lngLats:a,lngLat:t.unproject(s),originalEvent:r}),this._defaultPrevented=!1}},XC=class extends VC{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t){super("wheel",{originalEvent:t}),this._defaultPrevented=!1}},YC=class extends VC{},KC=class extends VC{constructor(e={}){super("terrain",e)}},JC=class extends VC{constructor(e={}){super("projectiontransition",e)}},QC=class extends VC{},eF=class extends VC{constructor(e={}){super("styleimagemissing",e)}};function tF(e,t){let r={};for(let i in e)"ref"!==i&&(r[i]=e[i]);return $f.forEach(e=>{e in t&&(r[e]=t[e])}),r}function rF(e){e=e.slice();let t=Object.create(null);for(let r=0;r<e.length;r++)t[e[r].id]=e[r];for(let r=0;r<e.length;r++)"ref"in e[r]&&(e[r]=tF(e[r],t[e[r].ref]));return e}function iF(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!iF(e[r],t[r]))return!1;return!0}if("object"==typeof e&&e&&null!==t){if("object"!=typeof t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let r in e)if(!iF(e[r],t[r]))return!1;return!0}return e===t}function nF(e,t){e.push(t)}function aF(e,t,r){nF(r,{command:"addSource",args:[e,t[e]]})}function sF(e,t,r){nF(t,{command:"removeSource",args:[e]}),r[e]=!0}function oF(e,t,r,i){sF(e,r,i),aF(e,t,r)}function lF(e,t,r){let i;for(i in e[r])if(Object.prototype.hasOwnProperty.call(e[r],i)&&"data"!==i&&!iF(e[r][i],t[r][i]))return!1;for(i in t[r])if(Object.prototype.hasOwnProperty.call(t[r],i)&&"data"!==i&&!iF(e[r][i],t[r][i]))return!1;return!0}function uF(e,t,r,i,n,a){e||={},t||={};for(let s in e)Object.prototype.hasOwnProperty.call(e,s)&&(iF(e[s],t[s])||r.push({command:a,args:[i,s,t[s],n]}));for(let s in t)Object.prototype.hasOwnProperty.call(t,s)&&!Object.prototype.hasOwnProperty.call(e,s)&&(iF(e[s],t[s])||r.push({command:a,args:[i,s,t[s],n]}))}function cF(e){return e.id}function hF(e,t){return e[t.id]=t,e}function dF(e,t){if(!e)return[{command:"setStyle",args:[t]}];let r=[];try{if(!iF(e.version,t.version))return[{command:"setStyle",args:[t]}];iF(e.center,t.center)||r.push({command:"setCenter",args:[t.center]}),iF(e.state,t.state)||r.push({command:"setGlobalState",args:[t.state]}),iF(e.centerAltitude,t.centerAltitude)||r.push({command:"setCenterAltitude",args:[t.centerAltitude]}),iF(e.zoom,t.zoom)||r.push({command:"setZoom",args:[t.zoom]}),iF(e.bearing,t.bearing)||r.push({command:"setBearing",args:[t.bearing]}),iF(e.pitch,t.pitch)||r.push({command:"setPitch",args:[t.pitch]}),iF(e.roll,t.roll)||r.push({command:"setRoll",args:[t.roll]}),iF(e.sprite,t.sprite)||r.push({command:"setSprite",args:[t.sprite]}),iF(e.glyphs,t.glyphs)||r.push({command:"setGlyphs",args:[t.glyphs]}),iF(e["font-faces"],t["font-faces"])||r.push({command:"setFontFaces",args:[t["font-faces"]]}),iF(e.transition,t.transition)||r.push({command:"setTransition",args:[t.transition]}),iF(e.light,t.light)||r.push({command:"setLight",args:[t.light]}),iF(e.terrain,t.terrain)||r.push({command:"setTerrain",args:[t.terrain]}),iF(e.sky,t.sky)||r.push({command:"setSky",args:[t.sky]}),iF(e.projection,t.projection)||r.push({command:"setProjection",args:[t.projection]});let i={},n=[];!function(e,t,r,i){let n;for(n in e||={},t||={},e)Object.prototype.hasOwnProperty.call(e,n)&&(Object.prototype.hasOwnProperty.call(t,n)||sF(n,r,i));for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&(Object.prototype.hasOwnProperty.call(e,n)?iF(e[n],t[n])||("geojson"===e[n].type&&"geojson"===t[n].type&&lF(e,t,n)?nF(r,{command:"setGeoJSONSourceData",args:[n,t[n].data]}):oF(n,t,r,i)):aF(n,t,r))}(e.sources,t.sources,n,i);let a=[];e.layers&&e.layers.forEach(e=>{"source"in e&&i[e.source]?r.push({command:"removeLayer",args:[e.id]}):a.push(e)}),r=r.concat(n),function(e,t,r){e||=[],t||=[];let i,n,a,s,o,l=e.map(cF),u=t.map(cF),c=e.reduce(hF,{}),h=t.reduce(hF,{}),d=l.slice(),p=Object.create(null);for(let f=0,m=0;f<l.length;f++)i=l[f],Object.prototype.hasOwnProperty.call(h,i)?m++:(nF(r,{command:"removeLayer",args:[i]}),d.splice(d.indexOf(i,m),1));for(let f=0,m=0;f<u.length;f++)i=u[u.length-1-f],d[d.length-1-f]!==i&&(Object.prototype.hasOwnProperty.call(c,i)?(nF(r,{command:"removeLayer",args:[i]}),d.splice(d.lastIndexOf(i,d.length-m),1)):m++,s=d[d.length-f],nF(r,{command:"addLayer",args:[h[i],s]}),d.splice(d.length-f,0,i),p[i]=!0);for(let f=0;f<u.length;f++)if(i=u[f],n=c[i],a=h[i],!p[i]&&!iF(n,a)){if(!iF(n.source,a.source)||!iF(n["source-layer"],a["source-layer"])||!iF(n.type,a.type)){nF(r,{command:"removeLayer",args:[i]}),s=d[d.lastIndexOf(i)+1],nF(r,{command:"addLayer",args:[a,s]});continue}for(o in uF(n.layout,a.layout,r,i,null,"setLayoutProperty"),uF(n.paint,a.paint,r,i,null,"setPaintProperty"),iF(n.filter,a.filter)||nF(r,{command:"setFilter",args:[i,a.filter]}),(!iF(n.minzoom,a.minzoom)||!iF(n.maxzoom,a.maxzoom))&&nF(r,{command:"setLayerZoomRange",args:[i,a.minzoom,a.maxzoom]}),n)Object.prototype.hasOwnProperty.call(n,o)&&"layout"!==o&&"paint"!==o&&"filter"!==o&&"metadata"!==o&&"minzoom"!==o&&"maxzoom"!==o&&(0===o.indexOf("paint.")?uF(n[o],a[o],r,i,o.slice(6),"setPaintProperty"):iF(n[o],a[o])||nF(r,{command:"setLayerProperty",args:[i,o,a[o]]}));for(o in a)Object.prototype.hasOwnProperty.call(a,o)&&!Object.prototype.hasOwnProperty.call(n,o)&&"layout"!==o&&"paint"!==o&&"filter"!==o&&"metadata"!==o&&"minzoom"!==o&&"maxzoom"!==o&&(0===o.indexOf("paint.")?uF(n[o],a[o],r,i,o.slice(6),"setPaintProperty"):iF(n[o],a[o])||nF(r,{command:"setLayerProperty",args:[i,o,a[o]]}))}}(a,t.layers,r)}catch(e){console.warn("Unable to compute style diff:",e),r=[{command:"setStyle",args:[t]}]}return r}function pF(e){let t=[];if("string"==typeof e)t.push({id:"default",url:e});else if(e&&e.length>0){let r=[];for(let{id:i,url:n}of e){let e=`${i}${n}`;r.includes(e)||(r.push(e),t.push({id:i,url:n}))}}return t}function fF(e,t,r){try{let i=new URL(e);return i.pathname+=`${t}${r}`,i.toString()}catch{throw Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}async function mF(e,t,r,i){let n=pF(e),a=r>1?"@2x":"",s={},o={};for(let{id:l,url:u}of n){let e=await t.transformRequest(fF(u,a,".json"),"SpriteJSON");s[l]=If(e,i);let r=await t.transformRequest(fF(u,a,".png"),"SpriteImage");o[l]=NC.getImage(r,i)}return await Promise.all([...Object.values(s),...Object.values(o)]),async function(e,t){let r={};for(let i in e){r[i]={};let n=(await t[i]).data;if(!n)throw Error(`Could not load sprite image for ${i}: the response is empty`);let a=zC.getImageCanvasContext(n),s=(await e[i]).data;for(let e in s){let{width:t,height:n,x:o,y:l,sdf:u,pixelRatio:c,stretchX:h,stretchY:d,content:p,textFitWidth:f,textFitHeight:m}=s[e],g={width:t,height:n,x:o,y:l,context:a};r[i][e]={data:null,pixelRatio:c,sdf:u,stretchX:h,stretchY:d,content:p,textFitWidth:f,textFitHeight:m,spriteData:g}}}return r}(s,o)}var gF=class extends zf{constructor(){super(),this.images={},this.updateVersion=0,this.loaded=!1,this.requestors=[],this.missingImageResolver=null,this._spriteImagesIds={},this._imagesIds=null,this._renderCallbacksDispatchedThisFrame={}}destroy(){for(let e of Object.keys(this.images))this.removeImage(e);this._spriteImagesIds={}}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 t=this.images[e];if(t&&!t.data&&t.spriteData){let e=t.spriteData;t.data=new Dw({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),t.spriteData=null}return t}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,this._imagesIds=null,t.isWebGLImage&&this.updateImage(e,t,!1))}_validate(e,t){let r=!0,i=t.data||t.spriteData;return this._validateStretch(t.stretchX,i?.width)||(this.fire(new Lf(Error(`Image "${e}" has invalid "stretchX" value`))),r=!1),this._validateStretch(t.stretchY,i?.height)||(this.fire(new Lf(Error(`Image "${e}" has invalid "stretchY" value`))),r=!1),this._validateContent(t.content,t)||(this.fire(new Lf(Error(`Image "${e}" has invalid "content" value`))),r=!1),r}_validateStretch(e,t){if(!e)return!0;let r=0;for(let i of e){if(i[0]<r||i[1]<i[0]||t<i[1])return!1;r=i[1]}return!0}_validateContent(e,t){if(!e)return!0;if(4!==e.length)return!1;let r=t.spriteData,i=r?.width||t.data.width,n=r?.height||t.data.height;return!(e[0]<0||i<e[0]||e[1]<0||n<e[1]||e[2]<0||i<e[2]||e[3]<0||n<e[3]||e[2]<e[0])&&e[3]>=e[1]}updateImage(e,t,r=!0){let i=this.images[e];if(r){let e=i.data||i.spriteData;if(e.width!==t.data.width||e.height!==t.data.height)throw Error(`size mismatch between old image (${e.width}x${e.height}) and new image (${t.data.width}x${t.data.height}).`)}t.version=(i.version??0)+1,this.images[e]=t,this.updateVersion++}removeImage(e){let t=this.images[e];t&&(delete this.images[e],this._imagesIds=null,t.userImage?.onRemove&&t.userImage.onRemove())}listImages(){return this._imagesIds??=Object.keys(this.images),this._imagesIds}_getSpriteImageId(e,t){return"default"===e?t:`${e}:${t}`}setSpriteImages(e,t){let r=this._spriteImagesIds[e]??[],i=[];for(let s in t){let r=this._getSpriteImageId(e,s);i.push(r),r in this.images?this.updateImage(r,t[s],!1):this.addImage(r,t[s])}let n=new Set(i),a=r.filter(e=>!n.has(e));for(let s of a)this.removeImage(s);return this._spriteImagesIds[e]=i,{loaded:i,removed:a}}removeSpriteImages(e){let t=this._spriteImagesIds[e]??[];for(let r of t)this.removeImage(r);return delete this._spriteImagesIds[e],t}removeAllSpriteImages(){let e=Object.values(this._spriteImagesIds).flat();for(let t of e)this.removeImage(t);return this._spriteImagesIds={},e}setMissingImageResolver(e){this.missingImageResolver=e}getImages(e){return new Promise((t,r)=>{let i=!0;if(!this.isLoaded())for(let n of e)this.images[n]||(i=!1);this.isLoaded()||i?t(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:t})})}async _getImagesForIds(e){let t=new Set(e.filter(e=>!this.getImage(e))),r=this.missingImageResolver;r&&await Promise.allSettled(Array.from(t,e=>r(e)));let i={};for(let n of e){let e=this.getImage(n);e&&(t.delete(n),i[n]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,textFitWidth:e.textFitWidth,textFitHeight:e.textFitHeight,hasRenderCallback:!!e.userImage?.render,isWebGLImage:e.isWebGLImage})}for(let n of t)this.fire(new eF({id:n})),Qp(`Image "${n}" could not be loaded. Please make sure you have added the image before it is needed with map.addImage(), resolved it with map.setMissingStyleImageResolver(), or included it in a "sprite" property in your style.`);return i}beginFrame(){this._renderCallbacksDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(let t of e){if(this._renderCallbacksDispatchedThisFrame[t])continue;this._renderCallbacksDispatchedThisFrame[t]=!0;let e=this.getImage(t);e||Qp(`Image with ID: "${t}" was not found`),eT(e)&&this.updateImage(t,e)}}cloneImages(){let e={};for(let t in this.images){let r=this.images[t];e[t]={...r,data:r.data?r.data.clone():null}}return e}},yF=class{constructor(e){this._imageManager=e,this._entries={},this._image=new Dw({width:1,height:1}),this._dirty=!0}destroy(){this._texture&&=(this._texture.destroy(),null),this._entries={},this._image=new Dw({width:1,height:1}),this._dirty=!0}getPixelSize(){let{width:e,height:t}=this._image;return{width:e,height:t}}getPattern(e){let t=this._imageManager.getImage(e);if(!t)return null;let r=this._entries[e];if(r?.image!==t){let r={w:t.data.width+2,h:t.data.height+2,x:0,y:0};this._entries[e]={bin:r,position:new rT(r,t),image:t}}else{if(r.position.version===t.version)return r.position;r.position.version=t.version}return this._update(),this._entries[e].position}bind(e){let t=e.gl;this._texture?this._dirty&&=(this._texture.update(this._image),!1):(this._texture=new zw(e,this._image,t.RGBA),this._dirty=!1),this._texture.bind(t.LINEAR,t.CLAMP_TO_EDGE)}_update(){for(let n in this._entries)this._imageManager.getImage(n)||delete this._entries[n];let e=[];for(let n in this._entries)e.push(this._entries[n].bin);let{w:t,h:r}=tT(e),i=this._image;i.resize({width:t||1,height:r||1});for(let n in this._entries){let{bin:e}=this._entries[n],t=e.x+1,r=e.y+1,a=this._entries[n].image.data,s=a.width,o=a.height;Dw.copy(a,i,{x:0,y:0},{x:t,y:r},{width:s,height:o}),Dw.copy(a,i,{x:0,y:o-1},{x:t,y:r-1},{width:s,height:1}),Dw.copy(a,i,{x:0,y:0},{x:t,y:r+o},{width:s,height:1}),Dw.copy(a,i,{x:s-1,y:0},{x:t-1,y:r},{width:1,height:o}),Dw.copy(a,i,{x:0,y:0},{x:t+s,y:r},{width:1,height:o})}this._dirty=!0}};const _F=1114111,vF={start:0,end:_F};let xF=0;function bF(e){let t=/^u\+([0-9a-f]*)(\?+)$/i.exec(e);if(t){let[,e,r]=t;return e.length+r.length>6?null:wF(parseInt(`${e}${"0".repeat(r.length)}`,16),parseInt(`${e}${"f".repeat(r.length)}`,16))}let r=/^u\+([0-9a-f]{1,6})(?:-([0-9a-f]{1,6}))?$/i.exec(e);if(!r)return null;let i=parseInt(r[1],16);return wF(i,void 0===r[2]?i:parseInt(r[2],16))}function wF(e,t){return e>t||e>_F?null:{start:e,end:Math.min(t,_F)}}function EF(e,t){return e.ranges.some(({start:e,end:r})=>t>=e&&t<=r)}var SF=class{constructor(e){this.requestManager=e,this._faces={},this._registered=new Set}setFontFaces(e){this._unregisterAll(),this._faces={};for(let[t,r]of Object.entries(e??{})){let e=Array.isArray(r)?r:[r];this._faces[t]=e.map(e=>this._declareFontFace(t,e)).filter(e=>null!==e)}}hasFontFaces(){return Object.keys(this._faces).length>0}async getFontFamily(e,t){for(let r of e.split(","))for(let e of this._faces[r.trim()]??[])if(EF(e,t)&&(e.loaded??=this._loadFontFace(e),await e.loaded))return e.family;return null}_declareFontFace(e,t){let r="string"==typeof t?{url:t}:t;if("string"!=typeof r?.url)return Qp(`Ignoring the font face declared for "${e}": it has no URL.`),null;let i="maplibre-gl-font-face-"+xF++,n=r["unicode-range"];if(!n?.length)return{url:r.url,ranges:[vF],family:i};let a=[];for(let s of n){let e=bF(s);e?a.push(e):Qp(`Ignoring the unicode range "${s}" of the font face at ${r.url}: it is not a valid range.`)}return a.length?{url:r.url,ranges:a,family:i}:null}async _loadFontFace(e){if(typeof FontFace>"u"||typeof document>"u"||!document.fonts)return Qp(`Ignoring the font face at ${e.url}: this environment has no CSS Font Loading API.`),!1;let t;try{return t=new FontFace(e.family,await this._downloadFontFile(e.url)),!!Object.values(this._faces).some(t=>t.includes(e))&&(document.fonts.add(t),this._registered.add(t),await t.load(),!0)}catch(vd){return t&&this._unregister(t),Qp(`Ignoring the font face at ${e.url}: ${xp(vd).message}`),!1}}async _downloadFontFile(e){let t=await this.requestManager.transformRequest(e,"Glyphs"),r=await Cf(t,new AbortController);if(!r?.data)throw Error(`the response was empty for the font file at ${e}`);return r.data}_unregister(e){document.fonts?.delete(e),this._registered.delete(e)}_unregisterAll(){for(let e of this._registered)document.fonts?.delete(e);this._registered.clear()}destroy(){this._unregisterAll(),this._faces={}}};const DF=1e20,TF=new Float64Array(256);for(let Nj=0;Nj<256;Nj++){let e=.5-(Nj/255)**(1/2.2);TF[Nj]=e*Math.abs(e)}TF[255]=-1e20;var AF=class{constructor({fontSize:e=24,buffer:t=3,radius:r=8,cutoff:i=.25,fontFamily:n="sans-serif",fontWeight:a="normal",fontStyle:s="normal",lang:o=null}={}){this.buffer=t,this.radius=r,this.cutoff=i,this.lang=o;let l=this.size=e+4*t,u=this._createCanvas(l),c=this.ctx=u.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${a} ${e}px ${n}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(l*l),this.gridInner=new Float64Array(l*l),this.f=new Float64Array(l),this.z=new Float64Array(l+1),this.v=new Uint16Array(l)}_createCanvas(e){if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(e,e);let t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){let{width:t,actualBoundingBoxAscent:r,actualBoundingBoxDescent:i,actualBoundingBoxLeft:n,actualBoundingBoxRight:a}=this.ctx.measureText(e),s=Math.ceil(r),o=Math.floor(-n),l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(a)-o)),u=Math.max(0,Math.min(this.size-this.buffer,s+Math.ceil(i))),c=l+2*this.buffer,h=u+2*this.buffer,d=Math.max(c*h,0),p=new Uint8ClampedArray(d),f={data:p,width:c,height:h,glyphWidth:l,glyphHeight:u,glyphTop:s,glyphLeft:o,glyphAdvance:t};if(0===l||0===u)return f;let{ctx:m,buffer:g,gridInner:y,gridOuter:_}=this;this.lang&&(m.lang=this.lang),m.clearRect(g,g,l,u),m.fillText(e,g-o,g+s);let v=m.getImageData(g,g,l,u);_.fill(DF,0,d),y.fill(0,0,d);let x=3;for(let S=0;S<u;S++){let e=(S+g)*c+g;for(let t=0;t<l;t++,x+=4,e++){let t=v.data[x];if(0===t)continue;let r=TF[t];_[e]=Math.max(0,r),y[e]=Math.max(0,-r)}}PF(_,0,0,c,h,c,this.f,this.v,this.z);let b=Math.min(g,1);PF(y,g-b,g-b,l+2*b,u+2*b,c,this.f,this.v,this.z);let w=255/this.radius,E=255*(1-this.cutoff);for(let S=0;S<d;S++){let e=Math.sqrt(_[S])-Math.sqrt(y[S]);p[S]=Math.round(E-w*e)}return f}};function PF(e,t,r,i,n,a,s,o,l){for(let u=t;u<t+i;u++)IF(e,r*a+u,a,n,s,o,l);for(let u=r;u<r+n;u++)IF(e,u*a+t,1,i,s,o,l)}function IF(e,t,r,i,n,a,s){a[0]=0,s[0]=-1e20,s[1]=DF,n[0]=e[t];for(let o=1,l=0,u=0;o<i;o++){n[o]=e[t+o*r];let i=o*o;do{let e=a[l];u=(n[o]-n[e]+i-e*e)/(o-e)/2}while(u<=s[l]&&--l>-1);l++,a[l]=o,s[l]=u,s[l+1]=DF}for(let o=0,l=0;o<i;o++){for(;s[l+1]<o;)l++;let i=a[l],u=o-i;e[t+o*r]=n[i]+u*u}}const CF=Of.layout_symbol["text-font"].default.join(","),FF=(e,t)=>{let r=new AF(e);return r.buffer=t,r};var MF=class{constructor(e,t,r,i=FF){this.requestManager=e,this.localIdeographFontFamily=t,this.entries={},this.lang=r,this.fontFaceManager=new SF(e),this.createRasterizer=i}setURL(e){this.url=e}setFontFaces(e){this.fontFaceManager.setFontFaces(e),this.entries={}}async getGlyphs(e){let t=[];for(let n in e)for(let r of e[n])t.push(this._getAndCacheGlyphsPromise(n,r));let r=await Promise.all(t),i={};for(let{stack:n,id:a,glyph:s}of r)i[n]||={},i[n][a]=s&&{id:s.id,bitmap:s.bitmap.clone(),metrics:s.metrics};return i}async _getAndCacheGlyphsPromise(e,t){this.entries[e]??={glyphs:{},requests:{},ranges:{}};let r=this.entries[e],i=r.glyphs[t];if(void 0!==i)return{stack:e,id:t,glyph:i};let n=t.codePointAt(0),a=this.fontFaceManager.hasFontFaces()?await this.fontFaceManager.getFontFamily(e,n):null;return a?(i=r.glyphs[t]=await this._drawGlyph(r,e,t,a),{stack:e,id:t,glyph:i}):!this.url||bD(t)||this._charUsesLocalIdeographFontFamily(n)?(i=r.glyphs[t]=await this._drawGlyph(r,e,t),{stack:e,id:t,glyph:i}):await this._downloadAndCacheRangePromise(e,t)}async _downloadAndCacheRangePromise(e,t){let r=t.codePointAt(0),i=this.entries[e],n=Math.floor(r/256);if(i.ranges[n])return{stack:e,id:t,glyph:null};i.requests[n]||=this._loadGlyphRange(e,n);try{let a=await i.requests[n];for(let e in a)i.glyphs[String.fromCodePoint(+e)]=a[+e];return i.ranges[n]=!0,{stack:e,id:t,glyph:a[r]||null}}catch(wd){let s=i.glyphs[t]=await this._drawGlyph(i,e,t);return this._warnOnMissingGlyphRange(s,n,r,xp(wd)),{stack:e,id:t,glyph:s}}}async _loadGlyphRange(e,t){let r=256*t,i=r+255,n=await this.requestManager.transformRequest(this.url.replace("{fontstack}",e).replace("{range}",`${r}-${i}`),"Glyphs"),a=await Cf(n,new AbortController);if(!a?.data)throw Error(`Could not load glyph range. range: ${t}, ${r}-${i}`);let s={};for(let o of function(e){return new XD(e).readFields(YD,[])}(a.data))s[o.id]=o;return s}_warnOnMissingGlyphRange(e,t,r,i){let n=256*t;Qp(`Unable to load glyph range ${t}, ${n}-${n+255}. Rendering codepoint U+${r.toString(16).padStart(4,"0").toUpperCase()} locally instead. ${i}`)}_charUsesLocalIdeographFontFamily(e){return!!this.localIdeographFontFamily&&function(e){return/[\u02EA\u02EB\u1100-\u11FF\u2E80-\u2FDF\u3000-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))}(e)}async _drawGlyph(e,t,r,i){let n=(await this._getTinySDF(e,t,r,i)).draw(r),a=/^\p{gc=Cf}+$/u.test(r);return{id:r.codePointAt(0),bitmap:new Sw({width:n.width||60,height:n.height||60},n.data),metrics:{width:a?0:n.glyphWidth/2||24,height:n.glyphHeight/2||24,left:n.glyphLeft/2+.5||0,top:n.glyphTop/2-27.5||-8,advance:a?0:n.glyphAdvance/2||24,isDoubleResolution:!0}}}_getTinySDF(e,t,r,i){let n=bD(r);if(i){let t=n?"clusterTinySDFs":"fontFaceTinySDFs";return e[t]??={},e[t][i]||=this._createTinySDF(i,!1,n?3:1),e[t][i]}let a=t===CF&&""!==this.localIdeographFontFamily&&this._charUsesLocalIdeographFontFamily(r.codePointAt(0)),s=a?this.localIdeographFontFamily:t;if(n)return e.clusterTinySDFs??={},e.clusterTinySDFs[s]||=this._createTinySDF(s,!0,3),e.clusterTinySDFs[s];let o=a?"ideographTinySDF":"tinySDF";return e[o]||=this._createTinySDF(s),e[o]}async _createTinySDF(e,t=!0,r=1){let i=e?e.split(","):[];i.push("sans-serif");let n=i.map(e=>/[-\w]+/.test(e)?e:`'${CSS.escape(e)}'`).join(","),a=t?this._fontWeight(i[0]):void 0,s=t?this._fontStyle(i[0]):"normal";if(typeof document<"u"&&document.fonts?.load)try{await document.fonts.load(`${s} ${a||"normal"} 48px ${n}`)}catch(e){Qp(`Failed to load font "${n}": ${xp(e).message}`)}return this.createRasterizer({fontSize:48,buffer:Math.max(6,Math.ceil(48*(r-1)/4)),radius:16,cutoff:.25,fontFamily:n,fontWeight:a,fontStyle:s,lang:this.lang},6)}_fontStyle(e){return/italic/i.test(e)?"italic":/oblique/i.test(e)?"oblique":"normal"}_fontWeight(e){let t,r={thin:100,hairline:100,"extra light":200,"ultra light":200,light:300,normal:400,regular:400,medium:500,semibold:600,demibold:600,bold:700,"extra bold":800,"ultra bold":800,black:900,heavy:900,"extra black":950,"ultra black":950};for(let[i,n]of Object.entries(r))RegExp(`\\b${i}\\b`,"i").test(e)&&(t=`${n}`);return t}destroy(){for(let e in this.entries){let t=this.entries[e];t.tinySDF=null,t.ideographTinySDF=null,t.fontFaceTinySDFs={},t.glyphs={},t.requests={},t.ranges={}}this.entries={},this.fontFaceManager.destroy()}};let kF;var RF=class extends zf{constructor(e,t){super(),this._transitionable=new Cv(kF||=new Uv({anchor:new Ov(Of.light.anchor,"anchor"),position:new Ov(Of.light.position,"position"),color:new Ov(Of.light.color,"color"),intensity:new Ov(Of.light.intensity,"intensity")}),"light",t),this.setLight(e),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}getCartesianPosition(){return function([e,t,r]){return t+=90,t*=Math.PI/180,r*=Math.PI/180,[e*Math.cos(t)*Math.sin(r),e*Math.sin(t)*Math.sin(r),e*Math.cos(r)]}(this.properties.get("position"))}setLight(e,t={}){if(!this._validate(dv.light,e,t))for(let r in e){let t=e[r];r.endsWith("-transition")?this._transitionable.setTransition(r.slice(0,-11),t):this._transitionable.setValue(r,t)}}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,t,r){return gv(this,e,{value:t},r)}};let LF;var zF=class extends zf{constructor(e,t){super(),this._transitionable=new Cv(LF||=new Uv({"sky-color":new Ov(Of.sky["sky-color"],"sky-color"),"horizon-color":new Ov(Of.sky["horizon-color"],"horizon-color"),"fog-color":new Ov(Of.sky["fog-color"],"fog-color"),"fog-ground-blend":new Ov(Of.sky["fog-ground-blend"],"fog-ground-blend"),"horizon-fog-blend":new Ov(Of.sky["horizon-fog-blend"],"horizon-fog-blend"),"sky-horizon-blend":new Ov(Of.sky["sky-horizon-blend"],"sky-horizon-blend"),"atmosphere-blend":new Ov(Of.sky["atmosphere-blend"],"atmosphere-blend")}),"sky",t),this.setSky(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new Tv(0))}setSky(e,t={}){if(!this._validate(dv.sky,e,t)){e||={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0};for(let t in e){let r=e[t];t.endsWith("-transition")?this._transitionable.setTransition(t.slice(0,-11),r):this._transitionable.setValue(t,r)}}}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,t,r={}){return gv(this,e,{value:t},r)}calculateFogBlendOpacity(e){return e<60?0:e<70?(e-60)/10:1}},BF=class{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 r=e.join(",")+String(t);return this.dashEntry[r]||=this.addDash(e,t),this.dashEntry[r]}getDashRanges(e,t,r){let i=[],n=e.length%2==1?-e[e.length-1]*r:0,a=e[0]*r,s=!0;i.push({left:n,right:a,isDash:s,zeroLength:0===e[0]});let o=e[0];for(let l=1;l<e.length;l++){s=!s;let t=e[l];n=o*r,o+=t,a=o*r,i.push({left:n,right:a,isDash:s,zeroLength:0===t})}return i}addRoundDash(e,t,r){let i=t/2;for(let n=-r;n<=r;n++){let t=this.nextRow+r+n,a=this.width*t,s=0,o=e[s];for(let l=0;l<this.width;l++){l/o.right>1&&(o=e[++s]);let t,u=Math.abs(l-o.left),c=Math.abs(l-o.right),h=Math.min(u,c),d=n/r*(i+1);if(o.isDash){let e=i-Math.abs(d);t=Math.sqrt(h*h+e*e)}else t=i-Math.sqrt(h*h+d*d);this.data[a+l]=Math.max(0,Math.min(255,t+128))}}}addRegularDash(e){for(let s=e.length-1;s>=0;--s){let t=e[s],r=e[s+1];t.zeroLength?e.splice(s,1):r?.isDash===t.isDash&&(r.left=t.left,e.splice(s,1))}let t=e[0],r=e[e.length-1];t.isDash===r.isDash&&(t.left=r.left-this.width,r.right=t.right+this.width);let i=this.width*this.nextRow,n=0,a=e[n];for(let s=0;s<this.width;s++){s/a.right>1&&(a=e[++n]);let t=Math.abs(s-a.left),r=Math.abs(s-a.right),o=Math.min(t,r),l=a.isDash?o:-o;this.data[i+s]=Math.max(0,Math.min(255,l+128))}}addDash(e,t){let r=t?7:0,i=2*r+1;if(this.nextRow+i>this.height)return Qp("LineAtlas out of space"),null;let n=0;for(let s of e)n+=s;if(0!==n){let i=this.width/n,a=this.getDashRanges(e,this.width,i);t?this.addRoundDash(a,i,r):this.addRegularDash(a)}let a={y:this.nextRow+r,height:2*r,width:n};return this.nextRow+=i,this.dirty=!0,a}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))}};function OF(e,t){if(t)try{return new Worker(e,{type:"module"})}catch(e){console.warn("Module worker not supported, falling back to classic worker",e)}return new Worker(e)}async function $F(){let e=Ef.WORKER_URL||function(){let e=import.meta.url;if(!/^https?:/.test(e))return"";let t=e.endsWith("-dev.mjs")?"maplibre-gl-worker-dev.mjs":"maplibre-gl-worker.mjs";return new URL(`./${t}`,e).href}(),t=!e?.endsWith(".cjs");if(!function(e){if(!e)return!1;let t=globalThis.location;if(!t)return!1;try{return new URL(e,t.href).origin!==t.origin}catch{return!1}}(e))return OF(e,t);if(t){let r=function(e){let t=new Blob([`import ${JSON.stringify(new URL(e,globalThis.location?.href).href)}`],{type:"text/javascript"});return URL.createObjectURL(t)}(e);try{return OF(r,t)}finally{URL.revokeObjectURL(r)}}let r=await async function(e){let t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch worker script (${t.status}): ${e}`);let r=await t.text(),i=new Blob([r],{type:"text/javascript"});return URL.createObjectURL(i)}(e);try{return OF(r,t)}finally{URL.revokeObjectURL(r)}}var NF=class e{constructor(){this.active={},this.workersPromise=null}async acquire(t){if(this.active[t]=!0,!this.workersPromise){let t=[];for(;t.length<e.workerCount;)t.push($F());this.workersPromise=Promise.all(t)}return(await this.workersPromise).slice()}release(e){if(delete this.active[e],0===this.numActive()&&this.workersPromise){let e=this.workersPromise;this.workersPromise=null,e.then(e=>{for(let t of e)t.terminate()})}}isPreloaded(){return!!this.active.maplibre_preloaded_worker_pool}numActive(){return Object.keys(this.active).length}};const jF=Math.floor(zC.hardwareConcurrency/2);let VF;function UF(){return VF||=new NF,VF}NF.workerCount=function(e){if(null==nf){let t=e.navigator?e.navigator.userAgent:null;nf=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return nf}(globalThis)?Math.max(Math.min(jF,3),1):1;var qF=class{constructor(e,t){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=t,this.removed=!1,this.actorsPromise=this.initActors(t)}async initActors(e){let t=await this.workerPool.acquire(e);if(this.removed)return[];if(this.actors=t.map((t,r)=>{let i=new SA(t,e);return i.name=`Worker ${r}`,i}),!this.actors.length)throw Error("No actors found");return this.actors}async broadcast(e,t){let r=await this.actorsPromise;return Promise.all(r.map(r=>r.sendAsync({type:e,data:t})))}async getActor(){let e=await this.actorsPromise;return this.currentActor=(this.currentActor+1)%e.length,e[this.currentActor]}async waitForInitComplete(){0===this.actors.length&&await this.actorsPromise}getReadyActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(e=!0){this.removed=!0;for(let t of this.actors)t.remove();this.actors=[],e&&this.workerPool.release(this.id)}async registerMessageHandler(e,t){let r=await this.actorsPromise;for(let i of r)i.registerMessageHandler(e,t)}async unregisterMessageHandler(e){let t=await this.actorsPromise;for(let r of t)r.unregisterMessageHandler(e)}};let GF;function ZF(e,t){let r=Fd();return zd(r,r,[1,1,0]),Bd(r,r,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?Ld(r,r,e.calculatePosMatrix(t.toUnwrapped())):r}function WF(e,t,r,i,n,a,s){let o=function(e,t,r){if(e)for(let i of e){let e=t[i];if(e?.source===r&&"fill-extrusion"===e.type)return!0}else for(let i in t){let e=t[i];if(e.source===r&&"fill-extrusion"===e.type)return!0}return!1}(n?.layers??null,t,e.id),l=a.maxPitchScaleFactor(),u=e.tilesIn(i,l,o);u.sort(XF);let c=[];for(let h of u)c.push({wrappedTileID:h.tileID.wrapped().key,queryResults:h.tile.queryRenderedFeatures(t,r,e.getState(),h.queryGeometry,h.cameraQueryGeometry,h.scale,n,a,l,ZF(a,h.tileID),s?(e,t)=>s(h.tileID,e,t):void 0)});return function(e,t){for(let r in e)for(let i of e[r])YF(i,t);return e}(function(e){let t={},r={};for(let{queryResults:i,wrappedTileID:n}of e){r[n]||={};let e=r[n];for(let r in i){let n=i[r];e[r]||={};let a=e[r];t[r]||=[];for(let e of n)a[e.featureIndex]||(a[e.featureIndex]=!0,t[r].push(e))}}return t}(c),e)}function HF(e,t,r,i,n,a,s){let o={},l=a.queryRenderedSymbols(i),u=[];for(let c of Object.keys(l).map(Number))u.push(s[c]);u.sort(XF);for(let c of u){let r=c.featureIndex.lookupSymbolFeatures(l[c.bucketInstanceId],t,c.bucketIndex,c.sourceLayerIndex,{filterSpec:n.filter,globalState:n.globalState},n.layers,n.availableImages,e);for(let e in r){o[e]||=[];let t=r[e];t.sort((e,t)=>{let r=c.featureSortOrder;if(r){let i=r.indexOf(e.featureIndex);return r.indexOf(t.featureIndex)-i}return t.featureIndex-e.featureIndex});for(let r of t)o[e].push(r)}}return function(e,t,r){for(let i in e)for(let n of e[i]){YF(n,r[t[i].source])}return e}(o,e,r)}function XF(e,t){let r=e.tileID,i=t.tileID;return r.overscaledZ-i.overscaledZ||r.canonical.y-i.canonical.y||r.wrap-i.wrap||r.canonical.x-i.canonical.x}function YF(e,t){let r=e.feature,i=t.getFeatureState(r.layer["source-layer"],r.id);r.source=r.layer.source,r.layer["source-layer"]&&(r.sourceLayer=r.layer["source-layer"]),r.state=i}async function KF(e,t,r,i){let n=e;if(e.url?n=(await If(await t.transformRequest(e.url,"Source"),r)).data:await zC.frameAsync(r,i),!n)return null;let a=Vp(jp(n,e),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in n&&n.vector_layers&&(a.vectorLayerIds=n.vector_layers.map(e=>e.id)),a}var JF=class e{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):Array.isArray(e)&&(4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1])))}setNorthEast(e){return this._ne=e instanceof nS?new nS(e.lng,e.lat):nS.convert(e),this}setSouthWest(e){return this._sw=e instanceof nS?new nS(e.lng,e.lat):nS.convert(e),this}extend(t){let r,i,n=this._sw,a=this._ne;if(t instanceof nS)r=t,i=t;else{if(!(t instanceof e)){if(Array.isArray(t)){if(4===t.length||t.every(Array.isArray)){let r=t;return this.extend(e.convert(r))}{let e=t;return this.extend(nS.convert(e))}}return t&&("lng"in t||"lon"in t)&&"lat"in t?this.extend(nS.convert(t)):this}if(r=t._sw,i=t._ne,!r||!i)return this}return n||a?(n.lng=Math.min(r.lng,n.lng),n.lat=Math.min(r.lat,n.lat),a.lng=Math.max(i.lng,a.lng),a.lat=Math.max(i.lat,a.lat)):(this._sw=new nS(r.lng,r.lat),this._ne=new nS(i.lng,i.lat)),this}getCenter(){return new nS((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 nS(this.getWest(),this.getNorth())}getSouthEast(){return new nS(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:t,lat:r}=nS.convert(e),i=this._sw.lat<=r&&r<=this._ne.lat,n=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(n=this._sw.lng>=t&&t>=this._ne.lng),i&&n}intersects(t){if(!((t=e.convert(t)).getNorth()>=this.getSouth()&&t.getSouth()<=this.getNorth()))return!1;let r=Math.abs(this.getEast()-this.getWest()),i=Math.abs(t.getEast()-t.getWest());if(r>=360||i>=360)return!0;let n=Np(this.getWest(),-180,180),a=Np(this.getEast(),-180,180),s=Np(t.getWest(),-180,180),o=Np(t.getEast(),-180,180),l=n>a,u=s>o;return!(!l||!u)||(l?o>=n||s<=a:u?a>=s||n<=o:s<=a&&o>=n)}static convert(t){return t instanceof e||!t?t:new e(t)}static fromLngLat(t,r=0){let i=360*r/40075017,n=i/Math.cos(Math.PI/180*t.lat);return new e(new nS(t.lng-n,t.lat-i),new nS(t.lng+n,t.lat+i))}adjustAntiMeridian(){let t=new nS(this._sw.lng,this._sw.lat),r=new nS(this._ne.lng,this._ne.lat);return t.lng>r.lng?new e(t,new nS(r.lng+360,r.lat)):new e(t,r)}},QF=class{constructor(e,t,r){this.bounds=JF.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=r||24}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){let t=2**e.z,r=Math.floor(oS(this.bounds.getWest())*t),i=Math.floor(lS(this.bounds.getNorth())*t),n=Math.ceil(oS(this.bounds.getEast())*t),a=Math.ceil(lS(this.bounds.getSouth())*t);return e.x>=r&&e.x<n&&e.y>=i&&e.y<a}},eM=class extends zf{constructor(e,t,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,jp(this,Vp(t,["url","scheme","tileSize","promoteId","encoding"])),this._options=jp({type:"vector"},t),this._collectResourceTiming=t.collectResourceTiming,512!==this.tileSize)throw Error("vector tile sources must have a tileSize of 512");this.setEventedParent(i)}async load(e=!1){this._loaded=!1,this.fire(new ZC("dataloading")),this._tileJSONRequest=new AbortController;try{let t=await KF(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,t&&(jp(this,t),t.bounds&&(this.tileBounds=new QF(t.bounds,this.minzoom,this.maxzoom)),this.fire(new ZC("data",{sourceDataType:"metadata"})),this.fire(new ZC("data",{sourceDataType:"content",sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,bf(e)||this.fire(new Lf(xp(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(!0)}setTiles(e){return this.setSourceProperty(()=>{this.tiles=e,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 jp({},this._options)}async loadTile(e){let t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r={request:await this.map._requestManager.transformRequest(t,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,encoding:this.encoding,overzoomParameters:await this._getOverzoomParameters(e),etag:e.etag};r.request.collectResourceTiming=this._collectResourceTiming,await this.dispatcher.waitForInitComplete();let i="RT";if(e.actor&&"expired"!==e.state){if("loading"===e.state)return new Promise((t,r)=>{e.reloadPromise={resolve:t,reject:r}})}else e.actor=this.dispatcher.getReadyActor(),i="LT";e.abortController=new AbortController;try{let t=await e.actor.sendAsync({type:i,data:r},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,t);let n={};return t?.etagUnmodified&&(n.unmodified=!0),n}catch(t){if(delete e.abortController,e.aborted||bf(t))return;if(t&&404!==t.status)throw t;this._afterTileLoadWorkerResponse(e,null)}}async _getOverzoomParameters(e){if(e.tileID.canonical.z<=this.maxzoom||void 0===this.map._zoomLevelsToOverscale)return;let t=e.tileID.scaledTo(this.maxzoom).canonical,r=t.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:t,overzoomRequest:await this.map._requestManager.transformRequest(r,"Tile")}}_afterTileLoadWorkerResponse(e,t){if(t?.resourceTiming&&(e.resourceTiming=t.resourceTiming),t&&this.map._refreshExpiredTiles&&e.setExpiryData(t),e.etag=t?.etag,e.loadVectorData(t,this.map.painter),e.reloadPromise){let t=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(t.resolve).catch(t.reject)}}async abortTile(e){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&await e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}})}async unloadTile(e){e.unloadVectorData(),e.actor&&await e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}})}hasTransition(){return!1}},tM=class extends zf{constructor(e,t,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._premultiplyAlpha=!0,this._options=jp({type:"raster"},t),jp(this,Vp(t,["url","scheme","tileSize"]))}async load(e=!1){this._loaded=!1,this.fire(new ZC("dataloading")),this._tileJSONRequest=new AbortController;try{let t=await KF(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,t&&(jp(this,t),t.bounds&&(this.tileBounds=new QF(t.bounds,this.minzoom,this.maxzoom)),this.fire(new ZC("data",{sourceDataType:"metadata"})),this.fire(new ZC("data",{sourceDataType:"content",sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,bf(e)||this.fire(new Lf(xp(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.tiles=e,this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}serialize(){return jp({},this._options)}setPremultiplyAlpha(e){return this._premultiplyAlpha===e||this.setSourceProperty(()=>{this._premultiplyAlpha=e}),this}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}async loadTile(e){let t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r=this._premultiplyAlpha,i=r?void 0:{premultiplyAlpha:"none"};e.abortController=new AbortController;try{let n=await NC.transformAndGetImage(this.map._requestManager,t,"Tile",e.abortController,this.map._refreshExpiredTiles,i);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(n){this.map._refreshExpiredTiles&&(n.cacheControl||n.expires)&&e.setExpiryData({cacheControl:n.cacheControl,expires:n.expires});let t=this.map.painter.context,i=t.gl,a=n.data??new Dw({width:1,height:1},new Uint8Array(4));e.texture=this.map.painter.getTileTexture(a.width),e.texture?e.texture.update(a,{useMipmap:!0,premultiply:r}):(e.texture=new zw(t,a,i.RGBA,{useMipmap:!0,premultiply:r}),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}}async abortTile(e){e.abortController&&(e.abortController.abort(),delete e.abortController)}async unloadTile(e){e.texture&&this.map.painter.saveTileTexture(e.texture)}hasTransition(){return!1}},rM=class extends tM{constructor(e,t,r,i){super(e,t,r,i),this.type="raster-dem",this.maxzoom=22,this._options=jp({type:"raster-dem"},t),this.encoding=t.encoding||"mapbox",this.redFactor=t.redFactor,this.greenFactor=t.greenFactor,this.blueFactor=t.blueFactor,this.baseShift=t.baseShift}async loadTile(e){let t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{let r=await NC.transformAndGetImage(this.map._requestManager,t,"Tile",e.abortController,this.map._refreshExpiredTiles,{colorSpaceConversion:"none"});if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(r){if(this.map._refreshExpiredTiles&&(r.cacheControl||r.expires)&&e.setExpiryData({cacheControl:r.cacheControl,expires:r.expires}),!r.data)return void(e.state="loaded");let t=r.data,i=af(t)&&Ad()?t:await this.readImageNow(t),n={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};if(e.actor&&"expired"!==e.state&&"reloading"!==e.state)return;await this.dispatcher.waitForInitComplete(),(!e.actor||"expired"===e.state)&&(e.actor=this.dispatcher.getReadyActor()),e.dem=await e.actor.sendAsync({type:"LDT",data:n}),e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.needsColorReliefPrepare=!0,e.state="loaded"}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}}async readImageNow(e){if(typeof VideoFrame<"u"&&Pd()){let t=e.width+4,r=e.height+4;try{return new Dw({width:t,height:r},await sf(e,-2,-2,t,r))}catch{}}return zC.getImageData(e,2)}_getNeighboringTiles(e){let t=e.canonical,r=2**t.z,i=(t.x-1+r)%r,n=0===t.x?e.wrap-1:e.wrap,a=(t.x+1+r)%r,s=t.x+1===r?e.wrap+1:e.wrap,o={};return o[new PA(e.overscaledZ,n,t.z,i,t.y).key]={backfilled:!1},o[new PA(e.overscaledZ,s,t.z,a,t.y).key]={backfilled:!1},t.y>0&&(o[new PA(e.overscaledZ,n,t.z,i,t.y-1).key]={backfilled:!1},o[new PA(e.overscaledZ,e.wrap,t.z,t.x,t.y-1).key]={backfilled:!1},o[new PA(e.overscaledZ,s,t.z,a,t.y-1).key]={backfilled:!1}),t.y+1<r&&(o[new PA(e.overscaledZ,n,t.z,i,t.y+1).key]={backfilled:!1},o[new PA(e.overscaledZ,e.wrap,t.z,t.x,t.y+1).key]={backfilled:!1},o[new PA(e.overscaledZ,s,t.z,a,t.y+1).key]={backfilled:!1}),o}async unloadTile(e){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&&await e.actor.sendAsync({type:"RDT",data:{type:this.type,uid:e.uid,source:this.id}})}};function iM(e,t){return t?e.properties[t]:e.id}function nM(e,t,r){if(!e)return t||{};if(!t)return e||{};let i=sM(e),n=sM(t);!function(e,t){t.removeAll&&(e.add.clear(),e.update.clear(),e.remove.clear(),t.remove.clear());for(let r of t.remove)e.add.delete(r),e.update.delete(r);for(let[r,i]of t.update){let n=e.update.get(r);n&&(t.update.set(r,aM(n,i)),e.update.delete(r))}}(i,n);let a={};if((i.removeAll||n.removeAll)&&(a.removeAll=!0),a.remove=new Set([...i.remove,...n.remove]),a.add=new Map([...i.add,...n.add]),a.update=new Map([...i.update,...n.update]),a.remove.size&&a.add.size)for(let o of a.add.keys())a.remove.delete(o);let s=function(e){let t={};return e.removeAll&&(t.removeAll=e.removeAll),e.remove&&(t.remove=Array.from(e.remove)),e.add&&(t.add=Array.from(e.add.values())),e.update&&(t.update=Array.from(e.update.values())),t}(a);return s}function aM(e,t){let r={id:e.id};if(t.removeAllProperties&&(delete e.removeProperties,delete e.addOrUpdateProperties,delete t.removeProperties),t.removeProperties&&e.addOrUpdateProperties){let r=new Set(t.removeProperties);e.addOrUpdateProperties=e.addOrUpdateProperties.filter(e=>!r.has(e.key))}return(e.removeAllProperties||t.removeAllProperties)&&(r.removeAllProperties=!0),(e.removeProperties||t.removeProperties)&&(r.removeProperties=[...e.removeProperties||[],...t.removeProperties||[]]),(e.addOrUpdateProperties||t.addOrUpdateProperties)&&(r.addOrUpdateProperties=[...e.addOrUpdateProperties||[],...t.addOrUpdateProperties||[]]),(e.newGeometry||t.newGeometry)&&(r.newGeometry=t.newGeometry||e.newGeometry),r}function sM(e){if(!e)return{};let t={};return t.removeAll=e.removeAll,t.remove=new Set(e.remove||[]),t.add=new Map(e.add?.map(e=>[e.id,e])),t.update=new Map(e.update?.map(e=>[e.id,e])),t}function oM(e){return e&&0!==e.length?"number"==typeof e[0]?[e]:e.flatMap(e=>oM(e)):[]}function lM(e){return"GeometryCollection"===e.type?e.geometries.flatMap(e=>lM(e)):oM(e.coordinates)}function uM(e){let t,r=new JF;switch(e.type){case"FeatureCollection":t=e.features.flatMap(e=>lM(e.geometry));break;case"Feature":t=lM(e.geometry);break;default:t=lM(e)}if(0===t.length)return r;for(let i of t){let[e,t]=i;r.extend([e,t])}return r}var cM=class extends zf{constructor(e,t,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:t.data},this.actorPromise=r.getActor(),this.setEventedParent(i),this._data="string"==typeof t.data?{url:t.data}:{geojson:t.data},this._options=jp({},t),this._collectResourceTiming=t.collectResourceTiming,void 0!==t.maxzoom&&(this.maxzoom=t.maxzoom),t.type&&(this.type=t.type),t.attribution&&(this.attribution=t.attribution),this.promoteId=t.promoteId,void 0!==t.clusterMaxZoom&&this.maxzoom<=t.clusterMaxZoom&&Qp(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${t.clusterMaxZoom}".`),this.workerOptions=jp({source:this.id,geojsonVtOptions:{buffer:this._pixelsToTileUnits(void 0===t.buffer?128:t.buffer),tolerance:this._pixelsToTileUnits(void 0===t.tolerance?.375:t.tolerance),extent:_p,maxZoom:this.maxzoom,lineMetrics:t.lineMetrics||!1,generateId:t.generateId||!1,promoteId:"string"==typeof t.promoteId?t.promoteId:void 0,cluster:t.cluster||!1,clusterOptions:{maxZoom:this._getClusterMaxZoom(t.clusterMaxZoom),minPoints:Math.max(2,t.clusterMinPoints||2),extent:_p,radius:this._pixelsToTileUnits(t.clusterRadius||50),log:!1,generateId:t.generateId||!1}},clusterProperties:t.clusterProperties,filter:t.filter},t.workerOptions)}_hasPendingWorkerUpdate(){return void 0!==this._pendingWorkerUpdate.data||void 0!==this._pendingWorkerUpdate.diff||this._pendingWorkerUpdate.updateCluster}_pixelsToTileUnits(e){return e*(_p/this.tileSize)}_tileUnitsToPixels(e){return e/(_p/this.tileSize)}_getClusterMaxZoom(e){let t=e?Math.round(e):this.maxzoom-1;return Number.isInteger(e)||void 0===e||Qp(`Integer expected for option 'clusterMaxZoom': provided value "${e}" rounded to "${t}"`),t}async load(){await this._updateWorkerData()}onAdd(e){this.map=e,this.load()}setData(e){return this._data="string"==typeof e?{url:e}:{geojson:e},this._pendingWorkerUpdate={data:e},this._updateWorkerData()}updateData(e){return this._pendingWorkerUpdate.diff=nM(this._pendingWorkerUpdate.diff,e),this._updateWorkerData()}async getData(){return this._data.url&&await this.once("data"),this._data.geojson?this._data.geojson:{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}}async getBounds(){return uM(await this.getData())}setClusterOptions(e){return this.workerOptions.geojsonVtOptions.cluster=e.cluster,void 0!==e.clusterRadius&&(this.workerOptions.geojsonVtOptions.clusterOptions.radius=this._pixelsToTileUnits(e.clusterRadius)),void 0!==e.clusterMaxZoom&&(this.workerOptions.geojsonVtOptions.clusterOptions.maxZoom=this._getClusterMaxZoom(e.clusterMaxZoom)),this._pendingWorkerUpdate.updateCluster=!0,this._updateWorkerData()}getClusterOptions(){let{cluster:e,clusterOptions:t}=this.workerOptions.geojsonVtOptions;return{cluster:e,clusterMaxZoom:t.maxZoom,clusterRadius:this._tileUnitsToPixels(t.radius)}}async getClusterExpansionZoom(e){return(await this.actorPromise).sendAsync({type:"GCEZ",data:{type:this.type,clusterId:e,source:this.id}})}async getClusterChildren(e){return(await this.actorPromise).sendAsync({type:"GCC",data:{type:this.type,clusterId:e,source:this.id}})}async getClusterLeaves(e,t,r){return(await this.actorPromise).sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:e,limit:t,offset:r}})}async _updateWorkerData(){if(this._isUpdatingWorker)return this._updatePromise;if(!this._hasPendingWorkerUpdate())return void Qp(`No pending worker updates for GeoJSONSource ${this.id}.`);let{data:e,diff:t,updateCluster:r}=this._pendingWorkerUpdate,i=this._getLoadGeoJSONParameters(e,t,r);void 0===e?t?this._pendingWorkerUpdate.diff=void 0:r&&(this._pendingWorkerUpdate.updateCluster=void 0):this._pendingWorkerUpdate.data=void 0,this._updatePromise=this._dispatchWorkerUpdate(i),await this._updatePromise}async _getLoadGeoJSONParameters(e,t,r){let i=jp({type:this.type,source:this.id},this.workerOptions);return"string"==typeof e?(i.request=await this.map._requestManager.transformRequest(zC.resolveURL(e),"Source"),i.request.collectResourceTiming=this._collectResourceTiming,i):void 0!==e?(i.data=e,i):t?(i.dataDiff=t,i):r?(i.updateCluster=!0,i):void 0}async _dispatchWorkerUpdate(e){this._isUpdatingWorker=!0,this.fire(new ZC("dataloading"));try{let t=await e,r=await(await this.actorPromise).sendAsync({type:"LD",data:t});if(this._isUpdatingWorker=!1,this._removed||r.abandoned)return void this.fire(new ZC("dataabort"));r.data&&(this._data={geojson:r.data});let i=this._applyDiffToSource(t.dataDiff),n=this._getShouldReloadTileOptions(i),a={};this._applyResourceTiming(a,r),this.fire(new ZC("data",{...a,sourceDataType:"metadata"})),this.fire(new ZC("data",{...a,sourceDataType:"content",shouldReloadTileOptions:n}))}catch(e){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new ZC("dataabort"));this.fire(new Lf(xp(e)))}finally{this._hasPendingWorkerUpdate()&&await this._updateWorkerData()}}_applyResourceTiming(e,t){if(!this._collectResourceTiming)return;let r=t.resourceTiming?.[this.id];if(!r)return;let i=r.slice(0);i?.length&&jp(e,{resourceTiming:i})}_applyDiffToSource(e){if(!e)return;let t="string"==typeof this.promoteId?this.promoteId:void 0;if(!this._data.url&&!this._data.updateable){let e=function(e,t){let r=new Map;if(null==e||null==e.type)return r;if("Feature"===e.type){let i=iM(e,t);return null==i?void 0:(r.set(i,e),r)}if("FeatureCollection"===e.type){let i=new Set;for(let n of e.features){let e=iM(n,t);if(null==e||i.has(e))return;i.add(e),r.set(e,n)}return r}}(this._data.geojson,t);if(!e)throw Error(`GeoJSONSource "${this.id}": GeoJSON data is not compatible with updateData`);this._data={updateable:e}}if(!this._data.updateable)return;let r=function(e,t,r){let i=[];if(t.removeAll)e.clear();else if(t.remove)for(let n of t.remove){let t=e.get(n);t&&(i.push(t.geometry),e.delete(n))}if(t.add)for(let n of t.add){let t=iM(n,r);if(null==t)continue;let a=e.get(t);a&&i.push(a.geometry),i.push(n.geometry),e.set(t,n)}if(t.update)for(let n of t.update){let t=e.get(n.id);if(!t)continue;let r=!!n.newGeometry,a=n.removeAllProperties||n.removeProperties?.length>0||n.addOrUpdateProperties?.length>0;if(!r&&!a)continue;i.push(t.geometry);let s={...t};if(e.set(n.id,s),r&&(i.push(n.newGeometry),s.geometry=n.newGeometry),a){if(s.properties=n.removeAllProperties?{}:{...s.properties||{}},n.removeProperties)for(let e of n.removeProperties)delete s.properties[e];if(n.addOrUpdateProperties)for(let{key:e,value:t}of n.addOrUpdateProperties)s.properties[e]=t}}return i}(this._data.updateable,e,t);return e.removeAll||this._options.cluster?void 0:r}_getShouldReloadTileOptions(e){if(e)return{affectedBounds:e.filter(Boolean).map(e=>uM(e))}}shouldReloadTile(e,{affectedBounds:t}){if("loading"===e.state)return!0;if("unloaded"===e.state)return!1;let{buffer:r,extent:i}=this.workerOptions.geojsonVtOptions,n=function({x:e,y:t,z:r},i=0){let n=cS((e-i)/2**r),a=hS((t+1+i)/2**r),s=cS((e+1+i)/2**r),o=hS((t-i)/2**r);return new JF([n,a],[s,o])}(e.tileID.canonical,r/i);for(let a of t)if(n.intersects(a))return!0;return!1}loaded(){return!this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}async loadTile(e){let t=e.actor?"RT":"LT";e.actor=await this.actorPromise;let r={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(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};e.abortController=new AbortController;try{let i=await(await this.actorPromise).sendAsync({type:t,data:r},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(i,this.map.painter,"RT"===t)}catch(t){if(delete e.abortController,e.aborted||bf(t))return;throw t}}async abortTile(e){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0}async unloadTile(e){e.unloadVectorData(),await(await this.actorPromise).sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}})}onRemove(){this._removed=!0,this.actorPromise.then(e=>e.sendAsync({type:"RS",data:{type:this.type,source:this.id}}))}serialize(){return jp({},this._options,{type:this.type,data:this._data.updateable?{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}:this._data.url||this._data.geojson})}hasTransition(){return!1}};const hM=[0,0,1],dM=(e,t,r,i,n,a)=>({u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,u_image_warp:a,u_fade_t:r.mix,u_opacity:r.opacity*i.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:i.paint.get("raster-brightness-min"),u_brightness_high:i.paint.get("raster-brightness-max"),u_saturation_factor:mM(i.paint.get("raster-saturation")),u_contrast_factor:fM(i.paint.get("raster-contrast")),u_spin_weights:pM(i.paint.get("raster-hue-rotate")),u_coords_top:[n[0].x,n[0].y,n[1].x,n[1].y],u_coords_bottom:[n[3].x,n[3].y,n[2].x,n[2].y]});function pM(e){e*=Math.PI/180;let t=Math.sin(e),r=Math.cos(e);return[(2*r+1)/3,(-Math.sqrt(3)*t-r+1)/3,(Math.sqrt(3)*t-r+1)/3]}function fM(e){return e>0?1/(1-e):1+e}function mM(e){return e>0?1-1/(1.001-e):-e}var gM=class{constructor(e,t,r){this.vertexBuffer=e,this.indexBuffer=t,this.segments=r}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}};const yM=ex([{name:"a_pos",type:"Int16",components:2}]);function _M(e,t){let r=function(e,t){let r=void 0===e.granularity?1:Math.max(e.granularity,1),i=r+(e.generateBorders?2:0),n=r+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),a=i+1,s=n+1,o=e.generateBorders?-1:0,l=e.generateBorders||e.extendToNorthPole?-1:0,u=r+ +!!e.generateBorders,c=r+(e.generateBorders||e.extendToSouthPole?1:0),h=a*s,d=i*n*6,p=a*s>65536;if(p&&"16bit"===t)throw Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");let f=p||"32bit"===t,m=new Int16Array(2*h),g=0;for(let v=l;v<=c;v++)for(let t=o;t<=u;t++){let i=t/r*_p;-1===t&&(i=-64),t===r+1&&(i=8256);let n=v/r*_p;-1===v&&(n=e.extendToNorthPole?FE:-64),v===r+1&&(n=e.extendToSouthPole?ME:8256),m[g++]=i,m[g++]=n}let y=f?new Uint32Array(d):new Uint16Array(d),_=0;for(let v=0;v<n;v++)for(let e=0;e<i;e++){let t=e+v*a,r=e+1+v*a,i=e+(v+1)*a,n=e+1+(v+1)*a;y[_++]=t,y[_++]=i,y[_++]=r,y[_++]=r,y[_++]=i,y[_++]=n}return{vertices:m.buffer.slice(0),indices:y.buffer.slice(0),uses32bitIndices:f}}(t,"16bit"),i=Ox.deserialize({arrayBuffer:r.vertices,length:r.vertices.byteLength/2/2}),n=tb.deserialize({arrayBuffer:r.indices,length:r.indices.byteLength/2/3});return new gM(e.createVertexBuffer(i,yM.members),e.createIndexBuffer(n),ab.simpleSegment(0,0,i.length,n.length))}var vM=class extends zf{constructor(e,t,r,i){super(),this.imageWarp=hM,this.flippedWindingOrder=!1,this._warp="auto",this._imageDirty=!1,this._subdividedQuad=!1,this._subdividedMesh=null,this.id=e,this.dispatcher=r,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(i),this.options=t}async load(e){if(void 0===this.options.url)return this._loaded=!0,void this._finishLoading();this._loaded=!1,this.fire(new ZC("dataloading")),this.url=this.options.url,this._abortController=new AbortController;try{let t=await NC.transformAndGetImage(this.map._requestManager,this.url,"Image",this._abortController);this._abortController=null,this._loaded=!0,t?.data?(this._setImage(t.data),e&&(this.coordinates=e),this._finishLoading()):this.fire(new Lf(Error(`Could not load image ${this.url}: the response is empty`)))}catch(e){if(bf(e))return;this._abortController=null,this._loaded=!0,this.fire(new Lf(xp(e)))}}loaded(){return this._loaded}updateImage(e){return this._abortController&&=(this._abortController.abort(),null),"image"in e?(this._loaded=!0,this._setImage(e.image),e.coordinates&&(this.coordinates=e.coordinates),this._finishLoading(),this):e.url?(this.options.url=e.url,this.load(e.coordinates),this):this}_setImage(e){this.image=e,this._imageDirty=!0}getMesh(e,t){return!this._subdividedQuad||t?null:(this._subdividedMesh??=_M(e,{granularity:16}),this._subdividedMesh)}_disposeTexture(){this.texture?.destroy(),this.texture=null}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new ZC("data",{sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._abortController&&=(this._abortController.abort(),null),this._disposeTexture(),this._subdividedMesh?.destroy(),this._subdividedMesh=null,this.image=null,this.tiles={}}setWarp(e){return this._warp===e||(this._warp=e,this.tileCoords&&this.setCoordinates(this.coordinates)),this}getWarp(){return this._warp}setCoordinates(e){this.coordinates=e;let t=e.map(pS.fromLngLat);return this.tileID=function(e){let t=WE.fromPoints(e),r=t.width(),i=t.height(),n=Math.max(0,Math.floor(-Math.log(Math.max(r,i))/Math.LN2)),a=2**n;return new TA(n,Math.floor((t.minX+t.maxX)/2*a),Math.floor((t.minY+t.maxY)/2*a))}(t),this.terrainTileRanges=this._getOverlappingTileRanges(t),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=t.map(e=>this.tileID.getTilePoint(e)._round()),this.imageWarp=function(e,t){if("flat"===t||xM(e))return hM;let[r,i,n,a]=e,s=r.x-i.x+n.x-a.x,o=r.y-i.y+n.y-a.y,l=[i.x-n.x,i.y-n.y,a.x-n.x,a.y-n.y],[u,c,h,d]=l,p=function(e){return e[0]*e[3]-e[2]*e[1]}(l),f=(s*d-h*o)/p,m=(u*o-s*c)/p,g=[1,1+f,1+f+m,1+m],y=Math.max(...g)/Math.min(...g),_="perspective"===t?0:function(e){let t=(1-4/e)/(1-4/512);return Math.max(0,t)}(y);return!(y>=1&&y<=512)||_>=1?hM:[f,m,_]}(this.tileCoords,this._warp),this._subdividedQuad=this.imageWarp[2]>0&&!xM(this.tileCoords),this.flippedWindingOrder=function(e){let t=e[1].x-e[0].x,r=e[1].y-e[0].y,i=e[2].x-e[0].x;return t*(e[2].y-e[0].y)-r*i<0}(this.tileCoords),this.fire(new ZC("data",{sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;let e=this.map.painter.context,t=e.gl;this.texture?this._imageDirty&&(this.texture.update(this.image),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE)):(this.texture=new zw(e,this.image,t.RGBA),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE)),this._imageDirty=!1;let r=!1;for(let i in this.tiles){let e=this.tiles[i];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,r=!0)}r&&this.fire(new ZC("data",{sourceDataType:"idle",sourceId:this.id}))}async loadTile(e){this.tileID?.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored"}serialize(){let e={type:"image",coordinates:this.coordinates};return void 0!==this.options.url&&(e.url=this.options.url),e}hasTransition(){return!1}_getOverlappingTileRanges(e){let{minX:t,minY:r,maxX:i,maxY:n}=WE.fromPoints(e),a={};for(let s=0;s<=25;s++){let e=2**s,o=Math.floor(t*e),l=Math.floor(r*e),u=Math.floor(i*e),c=Math.floor(n*e),h=(o%e+e)%e,d=u%e,p=Math.floor(o/e),f=Math.floor(u/e);a[s]={minWrap:p,maxWrap:f,minTileXWrapped:h,maxTileXWrapped:d,minTileY:l,maxTileY:c}}return a}};function xM(e){let[t,r,i,n]=e;return t.x+i.x===r.x+n.x&&t.y+i.y===r.y+n.y}var bM=class extends vM{constructor(e,t,r,i){super(e,t,r,i),this._onPlayingHandler=()=>{this.map?.triggerRepaint()},this.roundZoom=!0,this.type="video",this.options=t}async load(){this._loaded=!1;let e=this.options;this.urls=[];for(let t of e.urls)this.urls.push((await this.map._requestManager.transformRequest(t,"Source")).url);try{let e=await(e=>{let t=window.document.createElement("video");return t.muted=!0,new Promise(r=>{t.onloadstart=()=>{r(t)};for(let i of e){let e=window.document.createElement("source");Ff(i)||(t.crossOrigin="Anonymous"),e.src=i,t.appendChild(e)}})})(this.urls);if(this._loaded=!0,!e)return;this.video=e,this.video.loop=!0,this.video.addEventListener("playing",this._onPlayingHandler),this.map&&this.video.play(),this._finishLoading()}catch(e){this.fire(new Lf(xp(e)))}}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){let t=this.video.seekable;e<t.start(0)||e>t.end(0)?this.fire(new Lf(new Nf(`sources.${this.id}`,null,`Playback for this video can be set only between the ${t.start(0)} and ${t.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)))}onRemove(){super.onRemove(),this.video&&(this.video.removeEventListener("playing",this._onPlayingHandler),this.video.pause())}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;let e=this.map.painter.context,t=e.gl;this.texture?this.video.paused||(this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE),t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,this.video)):(this.texture=new zw(e,this.video,t.RGBA),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE));let r=!1;for(let i in this.tiles){let e=this.tiles[i];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,r=!0)}r&&this.fire(new ZC("data",{sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},wM=class extends vM{constructor(e,t,r,i){super(e,t,r,i),t.coordinates?(!Array.isArray(t.coordinates)||4!==t.coordinates.length||t.coordinates.some(e=>!Array.isArray(e)||2!==e.length||e.some(e=>"number"!=typeof e)))&&this.fire(new Lf(new Nf(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new Lf(new Nf(`sources.${e}`,null,'missing required property "coordinates"'))),t.animate&&"boolean"!=typeof t.animate&&this.fire(new Lf(new Nf(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),t.canvas?"string"!=typeof t.canvas&&!(t.canvas instanceof HTMLCanvasElement)&&this.fire(new Lf(new Nf(`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 Lf(new Nf(`sources.${e}`,null,'missing required property "canvas"'))),this.options=t,this.animate=void 0===t.animate||t.animate}async load(){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 Lf(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._playing=!1,super.onRemove()}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()||0===Object.keys(this.tiles).length)return;let t=this.map.painter.context,r=t.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new zw(t,this.canvas,r.RGBA,{premultiply:!0}),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE));let i=!1;for(let n in this.tiles){let e=this.tiles[n];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,i=!0)}i&&this.fire(new ZC("data",{sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",animate:this.animate,canvas:this.options.canvas,coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(let e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}};const EM={},SM=e=>{switch(e){case"geojson":return cM;case"image":return vM;case"raster":return tM;case"raster-dem":return rM;case"vector":return eM;case"video":return bM;case"canvas":return wM}return EM[e]};const DM="RTLPluginLoaded";var TM=class extends zf{constructor(...e){super(...e),this.status="unavailable",this.url=null,this.dispatcher=(GF||(GF=new qF(UF(),Df),GF.registerMessageHandler("GR",(e,t,r)=>Pf(t,r))),GF)}_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}async setRTLTextPlugin(e,t=!1){if(this.url)throw Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=zC.resolveURL(e),!this.url)throw Error(`requested url ${e} is invalid`);if("unavailable"===this.status){if(!t)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if("requested"===this.status)return this._requestImport()}async _requestImport(){await this._syncState("loading"),this.status="loaded",this.fire(new Rf(DM))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}};let AM=null;function PM(){return AM||=new TM,AM}var IM=class{constructor(e,t){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=e,this.uid=qp(),this.uses=0,this.tileSize=t,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rttObjects=[],this.rttFingerprint={},this.expiredRequestCount=0,this.state="loading",this.featureStateRevision=-1}isRenderable(e){return this.hasData()&&(!this.fadeEndTime||this.fadeOpacity>0)&&(e||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:e,fadingDirection:t,fadingParentID:r,fadeEndTime:i}){this.resetFadeLogic(),this.fadingRole=e,this.fadingDirection=t,this.fadingParentID=r,this.fadeEndTime=i}setSelfFadeLogic(e){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=e}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=OC(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}clearTextures(e){this.demTexture&&e.saveTileTexture(this.demTexture),this.demTexture=null}getRTT(e){return this.rttObjects[e]}acquireRTT(e,t,r){return this.rttObjects[t]=e.acquireRTT(r)}releaseRTT(e){if(0!==this.rttObjects.length){for(let t of this.rttObjects)t&&e.releaseRTT(t);this.rttObjects.length=0}}loadVectorData(e,t,r){if(!0!==e?.etagUnmodified)if(this.hasData()&&this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestEncoding=e.encoding,this.latestFeatureIndex.rawTileData=e.rawTileData,this.latestFeatureIndex.encoding=e.encoding):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData,this.latestFeatureIndex.encoding=this.latestEncoding)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(e,t){let r={};if(!t)return r;for(let i of e){let e=i.layerIds.map(e=>t.getLayer(e)).filter(Boolean);if(0!==e.length){i.layers=e,i.stateDependentLayerIds&&(i.stateDependentLayers=i.stateDependentLayerIds.map(t=>e.filter(e=>e.id===t)[0]));for(let t of e)r[t.id]=i}}return r}(e.buckets,t?.style),this.hasSymbolBuckets=!1;for(let e in this.buckets){let t=this.buckets[e];if(t instanceof cA){if(this.hasSymbolBuckets=!0,!r)break;t.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(let e in this.buckets){let t=this.buckets[e];if(t instanceof cA&&t.hasRTLText){this.hasRTLText=!0,PM().lazyLoad();break}}this.queryPadding=0;for(let e in this.buckets){let r=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,t.style.getLayer(e).queryRadius(r))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),this.dashPositions=e.dashPositions}else this.collisionBoxArray=new Ax;else this.state="loaded"}unloadVectorData(){for(let e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.imageAtlas=null,this.dashPositions=null,this.latestFeatureIndex=null,this.state="unloaded"}getBucket(e){return this.buckets[e.id]}upload(e){for(let r in this.buckets){let t=this.buckets[r];t.uploadPending()&&t.upload(e)}let t=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new zw(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&=(this.glyphAtlasTexture=new zw(e,this.glyphAtlasImage,t.ALPHA),null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,r,i,n,a,s,o,l,u,c){return this.latestFeatureIndex?.rawTileData?this.latestFeatureIndex.query({queryGeometry:i,cameraQueryGeometry:n,scale:a,tileSize:this.tileSize,pixelPosMatrix:u,transform:o,params:s,queryPadding:this.queryPadding*l,getElevation:c},e,t,r):{}}querySourceFeatures(e,t){let r=this.latestFeatureIndex;if(!r?.rawTileData)return;let i=r.loadVTLayers(),n=t?.sourceLayer?t.sourceLayer:"",a=i._geojsonTileLayer||i[n];if(!a)return;let s=__(t?.filter,`querySourceFeatures[${n}].filter`,t?.globalState),{z:o,x:l,y:u}=this.tileID.canonical,c={z:o,x:l,y:u};for(let h=0;h<a.length;h++){let t=a.feature(h);if(s.needGeometry){let e=Vb(t,!0);if(!s.filter(new Tv(this.tileID.overscaledZ),e,this.tileID.canonical))continue}else if(!s.filter(new Tv(this.tileID.overscaledZ),t))continue;let i=r.getId(t,n),d=new LA(t,o,l,u,i);d.tile=c,e.push(d)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){let t=this.expirationTime;if(e.cacheControl){let t=function(e){let t={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(e,r,i,n)=>{let a=i||n;return t[r]=!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.cacheControl);t["max-age"]&&(this.expirationTime=Date.now()+1e3*t["max-age"])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){let e=Date.now(),r=!1;if(this.expirationTime>e)r=!1;else if(t)if(this.expirationTime<t)r=!0;else{let i=this.expirationTime-t;i?this.expirationTime=e+Math.max(i,3e4):r=!0}else r=!0;r?(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,r){if(!this.latestFeatureIndex?.rawTileData||0===Object.keys(e).length||this.featureStateRevision===r)return;this.featureStateRevision=r;let i=this.latestFeatureIndex.loadVTLayers();for(let n in this.buckets){if(!t.style.hasLayer(n))continue;let r=this.buckets[n],a=r.layers[0].sourceLayer||"_geojsonTileLayer",s=i[a],o=e[a];if(!s||!o||0===o.length)continue;r.update(o,s,this.imageAtlas?.patternPositions||{},this.dashPositions||{});let l=t?.style?.getLayer(n);l&&(this.queryPadding=Math.max(this.queryPadding,l.queryRadius(r)))}}holdingForSymbolFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<OC()}clearSymbolFadeHold(){this.symbolFadeHoldUntil=void 0}setSymbolHoldDuration(e){this.symbolFadeHoldUntil=OC()+e}setDependencies(e,t){let r={};for(let i of t)r[i]=!0;this.dependencies[e]=r}hasDependency(e,t){for(let r of e){let e=this.dependencies[r];if(e)for(let r of t)if(e[r])return!0}return!1}};function CM(e){let t=[];for(let r in e)t.push({id:r,state:e[r]});return t}var FM=class{constructor(){this.state={},this.stateChanges={},this.deletedStates={},this.revision=0}updateState(e,t,r){let i=String(t);if(this.stateChanges[e]||={},this.stateChanges[e][i]||={},jp(this.stateChanges[e][i],r),null===this.deletedStates[e]){this.deletedStates[e]={};for(let t in this.state[e])if(t===i){this.deletedStates[e][i]={};for(let n in this.state[e][t])void 0===r[n]&&(this.deletedStates[e][i][n]=null)}else this.deletedStates[e][t]=null}else if(null===this.deletedStates[e]?.[i]){this.deletedStates[e][i]={};for(let t in this.state[e][i])void 0===r[t]&&(this.deletedStates[e][i][t]=null)}else for(let n in r)null===this.deletedStates[e]?.[i]?.[n]&&delete this.deletedStates[e][i][n]}removeFeatureState(e,t,r){if(null===this.deletedStates[e])return;let i=String(t);if(this.deletedStates[e]||={},r&&void 0!==t)null!==this.deletedStates[e][i]&&(this.deletedStates[e][i]||={},this.deletedStates[e][i][r]=null);else if(void 0!==t)if(this.stateChanges[e]?.[i])for(r in this.deletedStates[e][i]={},this.stateChanges[e][i])this.deletedStates[e][i][r]=null;else this.deletedStates[e][i]=null;else this.deletedStates[e]=null}getState(e,t){let r=String(t),i=this.state[e]||{},n=this.stateChanges[e]||{},a=jp({},i[r],n[r]);if(null===this.deletedStates[e])return{};if(this.deletedStates[e]){let r=this.deletedStates[e][t];if(null===r)return{};for(let e in r)delete a[e]}return a}initializeTileState(e,t){let r={};for(let i in this.state)r[i]=CM(this.state[i]);e.setFeatureState(r,t,this.revision)}coalesceChanges(e,t){let r={};for(let n in this.stateChanges){this.state[n]||={},r[n]||={};for(let e in this.stateChanges[n])this.state[n][e]||={},jp(this.state[n][e],this.stateChanges[n][e]),r[n][e]=this.state[n][e]}for(let n in this.deletedStates)if(this.state[n]||={},r[n]||={},null===this.deletedStates[n])for(let e in this.state[n])this.state[n][e]={},r[n][e]={};else for(let e in this.deletedStates[n]){if(null===this.deletedStates[n][e])this.state[n][e]={};else for(let t of Object.keys(this.deletedStates[n][e]))delete this.state[n][e][t];r[n][e]=this.state[n][e]}if(this.stateChanges={},this.deletedStates={},0===Object.keys(r).length)return;this.revision++;let i={};for(let n in r)i[n]=CM(r[n]);e.setFeatureState(i,t,this.revision)}},MM=class e{constructor(e,t){this.min=e,this.max=t,this.center=Xd([],Wd([],this.min,this.max),.5)}quadrant(t){let r=[t%2==0,t<2],i=qd(this.min),n=qd(this.max);for(let e=0;e<r.length;e++)i[e]=r[e]?this.min[e]:this.center[e],n[e]=r[e]?this.center[e]:this.max[e];return n[2]=this.max[2],new e(i,n)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}intersectsFrustum(e){let t=!0;for(let r of e.planes){let e=this.intersectsPlane(r);if(0===e)return 0;1===e&&(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],r=e[3];for(let i=0;i<3;i++)e[i]>0?(t+=e[i]*this.min[i],r+=e[i]*this.max[i]):(r+=e[i]*this.min[i],t+=e[i]*this.max[i]);return t>=0?2:r<0?0:1}},kM=class e{constructor(e,t,r){this.points=e,this.planes=t,this.aabb=r}static fromInvProjectionMatrix(t,r=1,i=0,n,a){let s=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]],o=2**i,l=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(e=>function(e,t,r,i){let n=sp([],e,t),a=1/n[3]/r*i;return op(n,n,[a,a,1/n[3],a])}(e,t,r,o));n&&function(e,t,r,i){let n=i?4:0,a=i?0:4,s=0,o=[],l=[];for(let h=0;h<4;h++){let t=np([],e[h+a],e[h+n]),r=Gd(t);Xd(t,t,1/r),o.push(r),l.push(t)}for(let h=0;h<4;h++){let t=Ip(e[h+n],l[h],r);s=null!==t&&t>=0?Math.max(s,t):Math.max(s,o[h])}let u=function(e,t){let r=np([],e[t[0]],e[t[1]]),i=np([],e[t[2]],e[t[1]]),n=[0,0,0,0];return Kd(n,Qd([],r,i)),n[3]=-Jd(n,e[t[0]]),n}(e,t),c=function(e,t){let r=ap(e),i=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e}([],e,1/r),n=np([],t,Xd([],i,Jd(t,i))),a=ap(n);if(a>0){let e=Math.sqrt(1-i[3]*i[3]);return Ap(t,Wd([],Xd([],i,-i[3]),Xd([],n,e/a)))}return null}(r,u);if(null!==c){let e=c/Jd(l[0],u);s=Math.min(s,e)}for(let h=0;h<4;h++){let t=Math.min(s,o[h]);e[h+a]=[e[h+n][0]+l[h][0]*t,e[h+n][1]+l[h][1]*t,e[h+n][2]+l[h][2]*t,1]}}(l,s[0],n,a);let u=s.map(e=>{let t=Kd([],Qd([],np([],l[e[0]],l[e[1]]),np([],l[e[2]],l[e[1]]))),r=-Jd(t,l[e[1]]);return t.concat(r)}),c=[1/0,1/0,1/0],h=[-1/0,-1/0,-1/0];for(let e of l)for(let t=0;t<3;t++)c[t]=Math.min(c[t],e[t]),h[t]=Math.max(h[t],e[t]);return new e(l,u,new MM(c,h))}};function RM(e,t,r){let i=t.intersectsFrustum(e);if(!r||0===i)return i;let n=t.intersectsPlane(r);return 0===n?0:2===i&&2===n?2:1}function LM(e,t,r){let i=0,n=(r-t)/10;for(let a=0;a<10;a++){let s=t+(a+.5)/10*(r-t);i+=n*Math.cos(s)**+e}return i}function zM(e,t){return function(r,i,n,a,s){let o=2*((e-1)/Zp(Math.cos(lf(fS-s))/Math.cos(lf(fS)))-1),l=Math.acos(n/a),u=2*LM(o-1,0,lf(s/2)),c=Math.min(lf(fS),l+lf(s/2)),h=LM(o-1,Math.min(c,l-lf(s/2)),c),d=Math.atan(i/n),p=r;return p+=Zp(a/Math.hypot(i,n)/Math.max(.5,Math.cos(lf(s/2)))),p+=o*Zp(Math.cos(d))/2,p-=Zp(Math.max(1,h/u/t))/2,p}}const BM=zM(9.314,3);function OM(e,t){let r=(t.roundZoom?Math.round:Math.floor)(e.zoom+Zp(e.tileSize/t.tileSize));return Math.max(0,r)}function $M(e,t){let r=e.getCameraFrustum(),i=e.getClippingPlane();if(i&&t.maxContentElevation>0){let n=Math.hypot(i[0],i[1],i[2]);if(n>0){let a=1+t.maxContentElevation/iS,s=$p(-i[3]/n,-1,1),o=Math.cos(Math.acos(s)+Math.acos(1/a));i=[i[0],i[1],i[2],-o*n],r=function(e,t,r){let i=e.planes[1],n=e.points.map(e=>{let n=i[0]*e[0]+i[1]*e[1]+i[2]*e[2]+i[3];if(Math.abs(n)>1e-6)return e;let a=[e[0]-r[0],e[1]-r[1],e[2]-r[2]],s=i[0]*a[0]+i[1]*a[1]+i[2]*a[2];if(s>=-1e-9)return e;let o=t/-s;return[e[0]+a[0]*o,e[1]+a[1]*o,e[2]+a[2]*o,e[3]]}),a=e.planes.map((e,r)=>1===r?[e[0],e[1],e[2],e[3]+t]:e),s=[1/0,1/0,1/0],o=[-1/0,-1/0,-1/0];for(let l of n)for(let e=0;e<3;e++)s[e]=Math.min(s[e],l[e]),o[e]=Math.max(o[e],l[e]);return new kM(n,a,new MM(s,o))}(r,Math.sqrt(a*a-1),e.cameraPosition)}}let n=function(e){let t=uS(1,e.center.lat)*e.worldSize;return xS(e.center,e.elevation,e.pitch,e.bearing,e.cameraToCenterDistance/t)}(e),a=pS.fromLngLat(e.center,e.elevation),s=function(e,t){let r=$p((15-(fS-e.pitch-e.fov/2))/15,0,1),i=Math.max(500,t??0);return e.elevation+r*i}(e,t.maxContentElevation),o=e.getCoveringTilesDetailsProvider(),l=o.allowVariableZoom(e,t),u=OM(e,t),c=t.minzoom||0,h=void 0===t.maxzoom?e.maxZoom:t.maxzoom,d=Math.min(Math.max(0,u),h),p=2**d,f=[p*n.x,p*n.y,0],m=[p*a.x,p*a.y,0],g=Math.hypot(a.x-n.x,a.y-n.y),y=Math.abs(a.z-n.z),_=Math.hypot(g,y),v=e=>({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),x=[],b=[];if(e.renderWorldCopies&&o.allowWorldCopies())for(let w=1;w<=3;w++)x.push(v(-w)),x.push(v(w));for(x.push(v(0));x.length>0;){let p=x.pop(),g=p.x,v=p.y,w=p.fullyVisible,E={x:g,y:v,z:p.zoom},S=o.getTileBoundingVolume(E,p.wrap,s,t);if(!w){let e=RM(r,S,i);if(0===e)continue;w=2===e}let D=o.distanceToTile2d(n.x,n.y,E,S),T=u;l&&(T=(t.calculateTileZoom||BM)(e.zoom+Zp(e.tileSize/t.tileSize),D,y,_,e.fov)),T=(t.roundZoom?Math.round:Math.floor)(T),T=Math.max(0,T);let A=Math.min(T,h);if(p.wrap=o.getWrap(a,E,p.wrap),p.zoom>=A){if(p.zoom<c)continue;let e=d-p.zoom,r=f[0]-.5-(g<<e),i=f[1]-.5-(v<<e),n=t.reparseOverscaled?Math.max(p.zoom,T):p.zoom;b.push({tileID:new PA(p.zoom===h?n:p.zoom,p.wrap,p.zoom,g,v),distanceSq:yp([m[0]-.5-g,m[1]-.5-v]),tileDistanceToCamera:Math.sqrt(r*r+i*i)});continue}for(let e=0;e<4;e++){let t=(g<<1)+e%2,r=(v<<1)+(e>>1),i=p.zoom+1;x.push({zoom:i,x:t,y:r,wrap:p.wrap,fullyVisible:w})}}return b.sort((e,t)=>e.distanceSq-t.distanceSq).map(e=>e.tileID)}function NM(e){return"raster"===e||"image"===e||"video"===e}function jM(e,t,r,i,n,a,s){let o=OC(),l=function(e){if(!e.length)return new Set;let t=Math.max(...e.map(e=>e.canonical.z)),r=1/0,i=-1/0,n=1/0,a=-1/0,s=[];for(let l of e){let{x:e,y:o,z:u}=l.canonical,c=2**(t-u),h=e*c,d=o*c;s.push({id:l,x:h,y:d}),h<r&&(r=h),h>i&&(i=h),d<n&&(n=d),d>a&&(a=d)}let o=new Set;for(let l of s)(l.x===r||l.x===i||l.y===n||l.y===a)&&o.add(l.id);return o}(t);for(let u of t){let t=e.getTileById(u.key);(0===t.fadingDirection||0===t.fadeOpacity)&&t.resetFadeLogic(),!VM(e,t,r,o,i,n,s)&&(UM(e,t,r,o,a,s)||GM(t,l,o,s)||t.resetFadeLogic())}}function VM(e,t,r,i,n,a,s){if(!t.hasData())return!1;let{tileID:o,fadingRole:l,fadingDirection:u,fadingParentID:c}=t;if(0===l&&1===u&&c)return r[c.key]=c,!0;let h=Math.max(o.overscaledZ-n,a);for(let d=o.overscaledZ-1;d>=h;d--){let n=o.scaledTo(d),a=e.getLoadedTile(n);if(a)return t.setCrossFadeLogic({fadingRole:0,fadingDirection:1,fadingParentID:a.tileID,fadeEndTime:i+s}),a.setCrossFadeLogic({fadingRole:1,fadingDirection:0,fadeEndTime:i+s}),r[n.key]=n,!0}return!1}function UM(e,t,r,i,n,a){if(!t.hasData())return!1;let s=t.tileID.children(n),o=qM(e,t,s,r,i,n,a);if(o)return!0;for(let l of s)qM(e,t,l.children(n),r,i,n,a)&&(o=!0);return o}function qM(e,t,r,i,n,a,s){if(r[0].overscaledZ>=a)return!1;let o=!1;for(let l of r){let r=e.getLoadedTile(l);if(!r)continue;let{fadingRole:a,fadingDirection:u,fadingParentID:c}=r;(0!==a||0!==u||!c)&&(r.setCrossFadeLogic({fadingRole:0,fadingDirection:0,fadingParentID:t.tileID,fadeEndTime:n+s}),t.setCrossFadeLogic({fadingRole:1,fadingDirection:1,fadeEndTime:n+s})),i[l.key]=l,o=!0}return o}function GM(e,t,r,i){let n=e.tileID;if(e.selfFading)return!0;if(e.hasData())return!1;if(t.has(n)){let t=r+i;return e.setSelfFadeLogic(t),!0}return!1}function ZM(e,t){e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.needsColorReliefPrepare=!0;let r=t.tileID.canonical.x-e.tileID.canonical.x,i=t.tileID.canonical.y-e.tileID.canonical.y,n=2**e.tileID.canonical.z,a=t.tileID.key;(0!==r||0!==i)&&(Math.abs(i)>1||(Math.abs(r)>1&&(1===Math.abs(r+n)?r+=n:1===Math.abs(r-n)&&(r-=n)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,r,i),e.neighboringTiles?.[a]&&(e.neighboringTiles[a].backfilled=!0))))}var WM=class{constructor(){this._tiles={}}handleWrapJump(e){let t={};for(let r in this._tiles){let i=this._tiles[r];i.tileID=i.tileID.unwrapTo(i.tileID.wrap+e),t[i.tileID.key]=i}this._tiles=t}setFeatureState(e,t,r){for(let i in this._tiles)this._tiles[i].setFeatureState(e,t,r)}getAllTiles(){return Object.values(this._tiles)}getAllIds(e=!1){return e?Object.values(this._tiles).map(e=>e.tileID).sort(MA).map(e=>e.key):Object.keys(this._tiles)}getTileById(e){return this._tiles[e]}setTile(e,t){this._tiles[e]=t}deleteTileById(e){delete this._tiles[e]}getLoadedTile(e){let t=this.getTileById(e.key);return t?.hasData()?t:null}isIdRenderable(e,t=!1){return this.getTileById(e)?.isRenderable(t)}getRenderableIds(e=0,t){let r=[];for(let i of this.getAllIds())this.isIdRenderable(i,t)&&r.push(this.getTileById(i));return t?r.sort((t,r)=>{let i=t.tileID,n=r.tileID,a=new Sd(i.canonical.x,i.canonical.y)._rotate(-e),s=new Sd(n.canonical.x,n.canonical.y)._rotate(-e);return i.overscaledZ-n.overscaledZ||s.y-a.y||s.x-a.x}).map(e=>e.tileID.key):r.map(e=>e.tileID).sort(MA).map(e=>e.key)}},HM=class e extends zf{static{this.maxUnderzooming=10}static{this.maxOverzooming=3}constructor(e,t,r){super(),this._maxContentElevationSeen=0,this.id=e,this.dispatcher=r,this.on("data",e=>{this._dataHandler(e)}),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=((e,t,r,i)=>{let n=new(SM(t.type))(e,t,r,i);if(n.id!==e)throw Error(`Expected Source id to be ${e} instead of ${n.id}`);return n})(e,t,r,this),this._inViewTiles=new WM,this._outOfViewCache=new FC(0,e=>this._unloadTile(e)),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new FM,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?.onAdd&&this._source.onAdd(e)}onRemove(e){for(let t of this._inViewTiles.getAllTiles())t.unloadVectorData();this.clearTiles(),this._source?.onRemove&&this._source.onRemove(e),this._inViewTiles=new WM}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(let e of this._inViewTiles.getAllTiles())if("loaded"!==e.state&&"errored"!==e.state)return!1;return!0}getSource(){return this._source}getState(){return this._state}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)}async _loadTile(e,t,r,i){try{let n=await this._source.loadTile(e);this._tileLoaded(e,t,r,i,n)}catch(t){e.state="errored",404===t.status?this.update(this.transform,this.terrain):this._source.fire(new Lf(xp(t),{tile:e}))}}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e)}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new ZC("dataabort",{tile:e,coord:e.tileID}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._inViewTiles,this.map?this.map.painter:null);for(let t of this._inViewTiles.getAllTiles())t.upload(e),t.prepare(this.map.style.imageManager)}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(e){return this._inViewTiles.getRenderableIds(this.transform?.bearingInRadians,e)}hasRenderableParent(e){let t=e.overscaledZ-1;if(t>=this._source.minzoom){let r=this.getLoadedTile(e.scaledTo(t));if(r)return this._inViewTiles.isIdRenderable(r.tileID.key)}return!1}reload(e,t=void 0){if(this._paused)this._shouldReloadOnResume=!0;else{this._outOfViewCache.reset();for(let r of this._inViewTiles.getAllIds()){let i=this._inViewTiles.getTileById(r);(!t||this._source.shouldReloadTile(i,t))&&(e?this._reloadTile(r,"errored"===i.state?"loading":"expired"):"errored"!==i.state&&this._reloadTile(r,"reloading"))}}}async _reloadTile(e,t){let r=this._inViewTiles.getTileById(e);if(!r)return;let i=r.hasData();"loading"!==r.state&&(r.state=t),await this._loadTile(r,e,t,i)}_tileLoaded(e,t,r,i,n){i||(e.timeAdded=OC(),e.selfFading&&(e.fadeEndTime=e.timeAdded+this._rasterFadeDuration)),"expired"===r&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(t,e),!n?.unmodified&&("raster-dem"===this.getSource().type&&e.dem&&function(e,t){let r=t.getRenderableIds();for(let i of r){if(!e.neighboringTiles?.[i])continue;let r=t.getTileById(i);e.neighboringTiles[i].backfilled||ZM(e,r),!r.neighboringTiles?.[e.tileID.key]?.backfilled&&ZM(r,e)}}(e,this._inViewTiles),e.featureStateRevision=-1,this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new ZC("data",{tile:e,coord:e.tileID})))}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._inViewTiles.getTileById(e)}_retainLoadedChildren(t,r){let i=this._getLoadedDescendents(r),n=new Set;for(let a of r){let r=i[a.key];if(!r?.length){n.add(a);continue}let s=a.overscaledZ+e.maxOverzooming,o=r.filter(e=>e.tileID.overscaledZ<=s);if(!o.length){n.add(a);continue}let l=Math.min(...o.map(e=>e.tileID.overscaledZ)),u=o.filter(e=>e.tileID.overscaledZ===l).map(e=>e.tileID);for(let e of u)t[e.key]=e;this._areDescendentsComplete(u,l,a.overscaledZ)||n.add(a)}return n}_getLoadedDescendents(e){let t={};for(let r of this._inViewTiles.getAllTiles().filter(e=>e.hasData()))for(let i of e)r.tileID.isChildOf(i)&&(t[i.key]||=[],t[i.key].push(r));return t}_areDescendentsComplete(e,t,r){return 1===e.length&&e[0].isOverscaled()?e[0].overscaledZ===t:4**(t-r)===e.length}getLoadedTile(e){return this._inViewTiles.getLoadedTile(e)}updateCacheSize(e){let t=(Math.ceil(e.width/this._source.tileSize)+1)*(Math.ceil(e.height/this._source.tileSize)+1),r=null===this._maxTileCacheZoomLevels?Ef.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels,i=Math.floor(t*r),n="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,i):i;this._outOfViewCache.setMaxSize(n)}handleWrapJump(e){let t=(e-(void 0===this._prevLng?e:this._prevLng))/360,r=Math.round(t);this._prevLng=e,r&&(this._inViewTiles.handleWrapJump(r),this._resetTileReloadTimers())}_updateMaxContentElevation(){let e=this._maxContentElevationSeen,t=this.map?.style?._layers;if(!t)return e;let r=this._inViewTiles.getAllTiles();for(let i in t){let n=t[i];if("symbol"!==n.type||n.source!==this.id||n.isHidden(this.transform.zoom))continue;let a=n;if(a.layout){e=Math.max(e,a.layout.get("symbol-height-offset").constantOr(0));for(let t of r){let r=t.getBucket(n);r&&r.maxHeightOffset>e&&(e=r.maxHeightOffset)}}}return this._maxContentElevationSeen=e,e}update(e,t){if(!this._sourceLoaded||this._paused)return;let r;this.transform=e,this.terrain=t,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?r=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(e=>new PA(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)):(r=$M(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:"vector"===this._source.type&&void 0!==this.map._zoomLevelsToOverscale?Math.max(this._source.maxzoom,e.maxZoom-this.map._zoomLevelsToOverscale):this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:t,calculateTileZoom:this._source.calculateTileZoom,maxContentElevation:this._updateMaxContentElevation()}),this._source.hasTile&&(r=r.filter(e=>this._source.hasTile(e)))):r=[],this.usedForTerrain&&(r=this._addTerrainIdealTiles(r));let i=0===r.length&&!this._updated&&this._didEmitContent;this._updated=!0,i&&this.fire(new ZC("data",{sourceDataType:"idle",sourceId:this.id}));let n=OM(e,this._source),a=this._updateRetainedTiles(r,n),s=NM(this._source.type);s&&this._rasterFadeDuration>0&&!t&&jM(this._inViewTiles,r,a,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),s?this._cleanUpRasterTiles(a):this._cleanUpVectorTiles(a)}_cleanUpRasterTiles(e){for(let t of this._inViewTiles.getAllIds())e[t]||this._removeTile(t)}_cleanUpVectorTiles(e){for(let t of this._inViewTiles.getAllIds()){let r=this._inViewTiles.getTileById(t);e[t]?r.clearSymbolFadeHold():r.hasSymbolBuckets?r.holdingForSymbolFade()?r.symbolFadeFinished()&&this._removeTile(t):r.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(t)}}_addTerrainIdealTiles(e){let t=[];for(let r of e)if(r.canonical.z>this._source.minzoom){let e=r.scaledTo(r.canonical.z-1);t.push(e);let i=r.scaledTo(Math.max(this._source.minzoom,Math.min(r.canonical.z,5)));t.push(i)}return e.concat(t)}releaseSymbolFadeTiles(){for(let e of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(e).holdingForSymbolFade()&&this._removeTile(e)}_updateRetainedTiles(t,r){let i=new Set;for(let e of t)this._addTile(e).hasData()||i.add(e);let n=t.reduce((e,t)=>(e[t.key]=t,e),{}),a=this._retainLoadedChildren(n,i),s={},o=Math.max(r-e.maxUnderzooming,this._source.minzoom);for(let e of a){let t=this._inViewTiles.getTileById(e.key),r=t?.wasRequested();for(let i=e.overscaledZ-1;i>=o;--i){let a=e.scaledTo(i);if(s[a.key])break;if(s[a.key]=!0,t=this.getTile(a),!t&&r&&(t=this._addTile(a)),t){let e=t.hasData();if((e||!this.map?.cancelPendingTileRequestsWhileZooming||r)&&(n[a.key]=a),r=t.wasRequested(),e)break}}}return n}_addTile(e){let t=this._inViewTiles.getTileById(e.key);if(t)return t;t=this._outOfViewCache.getAndRemove(e),t&&(t.resetFadeLogic(),this._setTileReloadTimer(e.key,t),t.tileID=e,this._state.initializeTileState(t,this.map?this.map.painter:null));let r=t;return t||(t=new IM(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(t,e.key,t.state,!1)),t.uses++,this._inViewTiles.setTile(e.key,t),r||this._source.fire(new ZC("dataloading",{tile:t,coord:t.tileID})),t}_setTileReloadTimer(e,t){this._clearTileReloadTimer(e);let r=t.getExpiryTimeout();if(r){let t=()=>{this._reloadTile(e,"expired"),delete this._timers[e]};this._timers[e]=setTimeout(t,r)}}_clearTileReloadTimer(e){let t=this._timers[e];t&&(clearTimeout(t),delete this._timers[e])}_resetTileReloadTimers(){for(let e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(let e of this._inViewTiles.getAllIds()){let t=this._inViewTiles.getTileById(e);this._setTileReloadTimer(e,t)}}refreshTiles(e){for(let t of this._inViewTiles.getAllIds()){let r=this._inViewTiles.getTileById(t);(this._inViewTiles.isIdRenderable(t)||"errored"==r.state)&&e.some(e=>e.equals(r.tileID.canonical))&&this._reloadTile(t,"expired")}}_removeTile(e){let t=this._inViewTiles.getTileById(e);t&&(t.uses--,this._inViewTiles.deleteTileById(e),this._clearTileReloadTimer(e),!(t.uses>0)&&(t.hasData()&&"reloading"!==t.state?this._outOfViewCache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))))}_dataHandler(e){if("source"===e.dataType){if("metadata"===e.sourceDataType)return void(this._sourceLoaded=!0);"content"===e.sourceDataType&&this._sourceLoaded&&!this._paused&&(this.reload(e.sourceDataChanged,e.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}}resetMaxContentElevation(){this._maxContentElevationSeen=0}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1,this.resetMaxContentElevation();for(let e of this._inViewTiles.getAllIds())this._removeTile(e);this._outOfViewCache.reset()}tilesIn(e,t,r){let i=[],n=this.transform;if(!n)return i;let a=n.getCoveringTilesDetailsProvider().allowWorldCopies(),s=r?n.getCameraQueryGeometry(e):e,o=e=>n.screenPointToMercatorCoordinate(e,this.terrain),l=this.transformBbox(e,o,!a),u=this.transformBbox(s,o,!a),c=this.getIds(),h=WE.fromPoints(u);for(let d of c){let e=this._inViewTiles.getTileById(d);if(e.holdingForSymbolFade())continue;let r=a?[e.tileID]:[e.tileID.unwrapTo(-1),e.tileID.unwrapTo(0)],s=2**(n.zoom-e.tileID.overscaledZ),o=t*e.queryPadding*_p/e.tileSize/s;for(let t of r){let r=h.map(e=>t.getTilePoint(new pS(e.x,e.y)));if(r.expandBy(o),r.intersects(HE)){let r=l.map(e=>t.getTilePoint(e)),n=u.map(e=>t.getTilePoint(e));i.push({tile:e,tileID:a?t:t.unwrapTo(0),queryGeometry:r,cameraQueryGeometry:n,scale:s})}}}return i}transformBbox(e,t,r){let i=e.map(t);if(r){let r=WE.fromPoints(e);r.shrinkBy(.001*Math.min(r.width(),r.height()));let n=r.map(t);WE.fromPoints(i).covers(n)||(i=i.map(e=>e.x>.5?new pS(e.x-1,e.y,e.z):e))}return i}getVisibleCoordinates(e){let t=this.getRenderableIds(e).map(e=>this._inViewTiles.getTileById(e).tileID);return this.transform&&this.transform.populateCache(t),t}hasTransition(){return!!this._source.hasTransition()||NM(this._source.type)&&function(e,t){if(t<=0)return!1;let r=OC();for(let i of e.getAllTiles())if(i.fadeEndTime>=r)return!0;return!1}(this._inViewTiles,this._rasterFadeDuration)}setRasterFadeDuration(e){this._rasterFadeDuration=e}setFeatureState(e,t,r){e||=kA,this._state.updateState(e,t,r)}removeFeatureState(e,t,r){e||=kA,this._state.removeFeatureState(e,t,r)}getFeatureState(e,t){return e||=kA,this._state.getState(e,t)}setDependencies(e,t,r){let i=this._inViewTiles.getTileById(e);i&&i.setDependencies(t,r)}reloadTilesForDependencies(e,t){for(let r of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(r).hasDependency(e,t)&&this._reloadTile(r,"reloading");this._outOfViewCache.filter(r=>!r.hasDependency(e,t))}areTilesLoaded(){for(let e of this._inViewTiles.getAllTiles())if("loaded"!==e.state&&"errored"!==e.state)return!1;return!0}},XM=class{constructor(e,t){this.reset(e,t)}reset(e,t){this.points=e||[],this._distances=[0];for(let r=1;r<this.points.length;r++)this._distances[r]=this._distances[r-1]+this.points[r].dist(this.points[r-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(1===this.points.length)return this.points[0];e=$p(e,0,1);let t=1,r=this._distances[t],i=e*this.paddedLength+this.padding;for(;r<i&&t<this._distances.length;)r=this._distances[++t];let n=t-1,a=this._distances[n],s=r-a,o=s>0?(i-a)/s:0;return this.points[n].mult(1-o).add(this.points[t].mult(o))}};function YM(e,t,r,i,n){return n?e?e(t,r)+i:0===i?void 0:i:i}function KM(e,t){let r=!0;return"always"===e||("never"===e||"never"===t)&&(r=!1),r}var JM=class{constructor(e,t,r){let i=this.boxCells=[],n=this.circleCells=[];this.xCellCount=Math.ceil(e/r),this.yCellCount=Math.ceil(t/r);for(let a=0;a<this.xCellCount*this.yCellCount;a++)i.push([]),n.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=e,this.height=t,this.xScale=this.xCellCount/e,this.yScale=this.yCellCount/t,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,t,r,i,n){this._forEachCell(t,r,i,n,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(t),this.bboxes.push(r),this.bboxes.push(i),this.bboxes.push(n)}insertCircle(e,t,r,i){this._forEachCell(t-i,r-i,t+i,r+i,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(t),this.circles.push(r),this.circles.push(i)}_insertBoxCell(e,t,r,i,n,a){this.boxCells[n].push(a)}_insertCircleCell(e,t,r,i,n,a){this.circleCells[n].push(a)}_query(e,t,r,i,n,a,s){if(r<0||e>this.width||i<0||t>this.height)return[];let o=[];if(e<=0&&t<=0&&this.width<=r&&this.height<=i){if(n)return[{key:null,x1:e,y1:t,x2:r,y2:i}];for(let e=0;e<this.boxKeys.length;e++)o.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],r=this.circles[3*e+1],i=this.circles[3*e+2];o.push({key:this.circleKeys[e],x1:t-i,y1:r-i,x2:t+i,y2:r+i})}}else{let l={hitTest:n,overlapMode:a,seenUids:{box:{},circle:{}}};this._forEachCell(e,t,r,i,this._queryCell,o,l,s)}return o}query(e,t,r,i){return this._query(e,t,r,i,!1,null)}hitTest(e,t,r,i,n,a){return this._query(e,t,r,i,!0,n,a).length>0}hitTestCircle(e,t,r,i,n){let a=e-r,s=e+r,o=t-r,l=t+r;if(s<0||a>this.width||l<0||o>this.height)return!1;let u=[],c={hitTest:!0,overlapMode:i,circle:{x:e,y:t,radius:r},seenUids:{box:{},circle:{}}};return this._forEachCell(a,o,s,l,this._queryCellCircle,u,c,n),u.length>0}_queryCell(e,t,r,i,n,a,s,o){let{seenUids:l,hitTest:u,overlapMode:c}=s,h=this.boxCells[n],d=1e-6;if(null!==h){let n=this.bboxes;for(let s of h)if(!l.box[s]){l.box[s]=!0;let h=4*s,p=this.boxKeys[s];if(e<=n[h+2]+d&&t<=n[h+3]+d&&r>=n[h+0]-d&&i>=n[h+1]-d&&(!o||o(p))&&(!u||!KM(c,p.overlapMode))&&(a.push({key:p,x1:n[h],y1:n[h+1],x2:n[h+2],y2:n[h+3]}),u))return!0}}let p=this.circleCells[n];if(null!==p){let n=this.circles;for(let s of p)if(!l.circle[s]){l.circle[s]=!0;let h=3*s,d=this.circleKeys[s];if(this._circleAndRectCollide(n[h],n[h+1],n[h+2],e,t,r,i)&&(!o||o(d))&&(!u||!KM(c,d.overlapMode))){let e=n[h],t=n[h+1],r=n[h+2];if(a.push({key:d,x1:e-r,y1:t-r,x2:e+r,y2:t+r}),u)return!0}}}return!1}_queryCellCircle(e,t,r,i,n,a,s,o){let{circle:l,seenUids:u,overlapMode:c}=s,h=this.boxCells[n];if(null!==h){let e=this.bboxes;for(let t of h)if(!u.box[t]){u.box[t]=!0;let r=4*t,i=this.boxKeys[t];if(this._circleAndRectCollide(l.x,l.y,l.radius,e[r+0],e[r+1],e[r+2],e[r+3])&&(!o||o(i))&&!KM(c,i.overlapMode))return a.push(!0),!0}}let d=this.circleCells[n];if(null!==d){let e=this.circles;for(let t of d)if(!u.circle[t]){u.circle[t]=!0;let r=3*t,i=this.circleKeys[t];if(this._circlesCollide(e[r],e[r+1],e[r+2],l.x,l.y,l.radius)&&(!o||o(i))&&!KM(c,i.overlapMode))return a.push(!0),!0}}}_forEachCell(e,t,r,i,n,a,s,o){let l=this._convertToXCellCoord(e),u=this._convertToYCellCoord(t),c=this._convertToXCellCoord(r),h=this._convertToYCellCoord(i);for(let d=l;d<=c;d++)for(let l=u;l<=h;l++){let u=this.xCellCount*l+d;if(n.call(this,e,t,r,i,u,a,s,o))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,r,i,n,a){let s=i-e,o=n-t,l=r+a;return l*l>s*s+o*o}_circleAndRectCollide(e,t,r,i,n,a,s){let o=(a-i)/2,l=Math.abs(e-(i+o));if(l>o+r)return!1;let u=(s-n)/2,c=Math.abs(t-(n+u));if(c>u+r)return!1;if(l<=o||c<=u)return!0;let h=l-o,d=c-u;return h*h+d*d<=r*r}};function QM(e,t){let r=1/(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]),i=1/(t[8]*t[8]+t[9]*t[9]+t[10]*t[10]),n=t[0]*r,a=t[4]*r,s=t[8]*i,o=t[1]*r,l=t[5]*r,u=t[9]*i,c=t[2]*r,h=t[6]*r,d=t[10]*i;e[0]=n,e[1]=a,e[2]=s,e[4]=o,e[5]=l,e[6]=u,e[8]=c,e[9]=h,e[10]=d;let p=t[12],f=t[13],m=t[14];return e[12]=-n*p-o*f-c*m,e[13]=-a*p-l*f-h*m,e[14]=-s*p-u*f-d*m,e[3]=0,e[7]=0,e[11]=0,e[15]=1,e}const ek=Fd();function tk(e,t,r){let i=Fd();if(!e){let{vecSouth:e,vecEast:r}=ik(t),n=MC();n[0]=r[0],n[1]=r[1],n[2]=e[0],n[3]=e[1],function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],s=r*a-n*i;s&&(s=1/s,e[0]=a*s,e[1]=-i*s,e[2]=-n*s,e[3]=r*s)}(n,n),i[0]=n[0],i[1]=n[1],i[4]=n[2],i[5]=n[3]}return Bd(i,i,[1/r,1/r,1]),i}function rk(e,t,r,i){if(e){let e=Fd();if(!t){let{vecSouth:t,vecEast:i}=ik(r);e[0]=i[0],e[1]=i[1],e[4]=t[0],e[5]=t[1]}return Bd(e,e,[i,i,1]),e}return r.pixelsToClipSpaceMatrix}function ik(e){let t=Math.cos(e.rollInRadians),r=Math.sin(e.rollInRadians),i=Math.cos(e.pitchInRadians),n=Math.cos(e.bearingInRadians),a=Math.sin(e.bearingInRadians),s=dp();s[0]=-n*i*r-a*t,s[1]=-a*i*r+n*t;let o=mp(s);o<1e-9?gp(s):fp(s,s,1/o);let l=dp();l[0]=n*i*t-a*r,l[1]=a*i*t+n*r;let u=mp(l);return u<1e-9?gp(l):fp(l,l,1/u),{vecEast:l,vecSouth:s}}function nk(e,t,r){return YM(e.getElevation,t,r,e.heightOffset??0,e.heightAnchorGround??!0)}function ak(e,t,r,i){let n;null==i?(n=[e,t,0,1],wk(n,n,r)):(n=[e,t,i,1],sp(n,n,r));let a=n[3];return{point:new Sd(n[0]/a,n[1]/a),signedDistanceFromCamera:a,isOccluded:!1}}function sk(e,t){return.5+e/t*.5}function ok(e,t){return e.x>=-t[0]&&e.x<=t[0]&&e.y>=-t[1]&&e.y<=t[1]}function lk(e,t,r,i,n,a,s,o,l,u,c,h,d){let p=r?e.textSizeData:e.iconSizeData,f=AT(p,t.transform.zoom),m=[256/t.width*2+1,256/t.height*2+1],g=r?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;g.clear();let y=e.lineVertexArray,_=r?e.text.placedSymbolArray:e.icon.placedSymbolArray,v=t.transform.width/t.transform.height,x=!1;for(let b=0;b<_.length;b++){let r=_.get(b);if(r.hidden||2===r.writingMode&&!x){bk(r.numGlyphs,g);continue}x=!1;let w=new Sd(r.anchorX,r.anchorY),E={getElevation:d,pitchedLabelPlaneMatrix:i,lineVertexArray:y,pitchWithMap:a,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:t.transform,tileAnchorPoint:w,unwrappedTileID:l,width:u,height:c,translation:h},S=gk(r.anchorX,r.anchorY,E);if(!ok(S.point,m)){bk(r.numGlyphs,g);continue}let D=S.signedDistanceFromCamera,T=sk(t.transform.cameraToCenterDistance,D),A=TT(p,f,r),P=a?A*t.transform.getPitchedTextCorrection(r.anchorX,r.anchorY,l)/T:A*T,I=hk({projectionContext:E,pitchedLabelPlaneMatrixInverse:n,symbol:r,fontSize:P,flip:!1,keepUpright:s,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:g,aspectRatio:v,rotateToLine:o});x=I.useVertical,(I.notEnoughRoom||x||I.needsFlipping&&hk({projectionContext:E,pitchedLabelPlaneMatrixInverse:n,symbol:r,fontSize:P,flip:!0,keepUpright:s,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:g,aspectRatio:v,rotateToLine:o}).notEnoughRoom)&&bk(r.numGlyphs,g)}r?e.text.dynamicLayoutVertexBuffer.updateData(g):e.icon.dynamicLayoutVertexBuffer.updateData(g)}function uk(e,t,r,i,n,a,s,o){let l=a.glyphStartIndex+a.numGlyphs,u=a.lineStartIndex,c=a.lineStartIndex+a.lineLength,h=t.getoffsetX(a.glyphStartIndex),d=t.getoffsetX(l-1),p=vk(e*h,r,i,n,a.segment,u,c,o,s);if(!p)return null;let f=vk(e*d,r,i,n,a.segment,u,c,o,s);return!f||o.projectionCache.anyProjectionOccluded?null:{first:p,last:f}}function ck(e,t,r,i){return 1===e&&Math.abs(r.y-t.y)>Math.abs(r.x-t.x)*i?{useVertical:!0}:(2===e?t.y<r.y:t.x>r.x)?{needsFlipping:!0}:null}function hk(e){let t,{projectionContext:r,pitchedLabelPlaneMatrixInverse:i,symbol:n,fontSize:a,flip:s,keepUpright:o,glyphOffsetArray:l,dynamicLayoutVertexArray:u,aspectRatio:c,rotateToLine:h}=e,d=a/24,p=n.lineOffsetX*d,f=n.lineOffsetY*d;if(n.numGlyphs>1){let e=n.glyphStartIndex+n.numGlyphs,a=n.lineStartIndex,u=n.lineStartIndex+n.lineLength,m=uk(d,l,p,f,s,n,h,r);if(!m)return{notEnoughRoom:!0};let g=mk(m.first.point.x,m.first.point.y,r,i),y=mk(m.last.point.x,m.last.point.y,r,i);if(o&&!s){let e=ck(n.writingMode,g,y,c);if(e)return e}t=[m.first];for(let i=n.glyphStartIndex+1;i<e-1;i++){let e=vk(d*l.getoffsetX(i),p,f,s,n.segment,a,u,r,h);if(!e)return{notEnoughRoom:!0};t.push(e)}t.push(m.last)}else{if(o&&!s){let e=fk(r.tileAnchorPoint.x,r.tileAnchorPoint.y,r).point,t=n.lineStartIndex+n.segment+1,a=new Sd(r.lineVertexArray.getx(t),r.lineVertexArray.gety(t)),s=fk(a.x,a.y,r),o=s.signedDistanceFromCamera>0?s.point:dk(r.tileAnchorPoint,a,e,1,r),l=mk(e.x,e.y,r,i),u=mk(o.x,o.y,r,i),h=ck(n.writingMode,l,u,c);if(h)return h}let e=vk(d*l.getoffsetX(n.glyphStartIndex),p,f,s,n.segment,n.lineStartIndex,n.lineStartIndex+n.lineLength,r,h);if(!e||r.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};t=[e]}for(let m of t)sA(u,m.point,m.angle);return{}}function dk(e,t,r,i,n){let a=e.add(e.sub(t)._unit()),s=fk(a.x,a.y,n).point,o=r.sub(s);return r.add(o._mult(i/o.mag()))}function pk(e,t,r){let i=t.projectionCache;if(i.projections[e])return i.projections[e];let n=new Sd(t.lineVertexArray.getx(e),t.lineVertexArray.gety(e)),a=fk(n.x,n.y,t);if(a.signedDistanceFromCamera>0)return i.projections[e]=a.point,i.anyProjectionOccluded||=a.isOccluded,a.point;let s=e-r.direction,o=0===r.distanceFromAnchor?t.tileAnchorPoint:new Sd(t.lineVertexArray.getx(s),t.lineVertexArray.gety(s)),l=r.absOffsetX-r.distanceFromAnchor+1;return dk(o,n,r.previousVertex,l,t)}function fk(e,t,r){let i,n=e+r.translation[0],a=t+r.translation[1];return r.pitchWithMap?(i=ak(n,a,r.pitchedLabelPlaneMatrix,nk(r,n,a)),i.isOccluded=!1):(i=r.transform.projectTileCoordinates(n,a,r.unwrappedTileID,nk(r,n,a)),i.point.x=(.5*i.point.x+.5)*r.width,i.point.y=(.5*-i.point.y+.5)*r.height),i}function mk(e,t,r,i){if(r.pitchWithMap){let n=[e,t,0,1];sp(n,n,i);let a=n[0]/n[3],s=n[1]/n[3];return r.transform.projectTileCoordinates(a,s,r.unwrappedTileID,nk(r,a,s)).point}return{x:e/r.width*2-1,y:1-t/r.height*2}}function gk(e,t,r){return r.transform.projectTileCoordinates(e,t,r.unwrappedTileID,nk(r,e,t))}function yk(e,t,r){return e._unit()._perp()._mult(t*r)}function _k(e,t,r,i,n,a,s,o,l){if(o.projectionCache.offsets[e])return o.projectionCache.offsets[e];let u=r.add(t);if(e+l.direction<i||e+l.direction>=n)return o.projectionCache.offsets[e]=u,u;let c=pk(e+l.direction,o,l),h=yk(c.sub(r),s,l.direction),d=r.add(h),p=c.add(h);return o.projectionCache.offsets[e]=tf(a,u,d,p)||u,o.projectionCache.offsets[e]}function vk(e,t,r,i,n,a,s,o,l){let u=i?e-t:e+t,c=u>0?1:-1,h=0;i&&(c*=-1,h=Math.PI),c<0&&(h+=Math.PI);let d,p=c>0?a+n:a+n+1;o.projectionCache.cachedAnchorPoint?d=o.projectionCache.cachedAnchorPoint:(d=fk(o.tileAnchorPoint.x,o.tileAnchorPoint.y,o).point,o.projectionCache.cachedAnchorPoint=d);let f,m,g,y=d,_=d,v=0,x=0,b=Math.abs(u),w=[];for(;v+x<=b;){if(p+=c,p<a||p>=s)return null;v+=x,_=y,m=f;let e={absOffsetX:b,direction:c,distanceFromAnchor:v,previousVertex:_};if(y=pk(p,o,e),0===r)w.push(_),g=y.sub(_);else{let t,i=y.sub(_);t=0===i.mag()?yk(pk(p+c,o,e).sub(y),r,c):yk(i,r,c),m||=_.add(t),f=_k(p,t,y,a,s,m,r,o,e),w.push(m),g=f.sub(m)}x=g.mag()}let E=(b-v)/x,S=g._mult(E)._add(m||_),D=h+Math.atan2(y.y-_.y,y.x-_.x);return w.push(S),{point:S,angle:l?D:0,path:w}}const xk=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function bk(e,t){for(let r=0;r<e;r++){let e=t.length;t.resize(e+4),t.float32.set(xk,3*e)}}function wk(e,t,r){let i=t[0],n=t[1];return e[0]=r[0]*i+r[4]*n+r[12],e[1]=r[1]*i+r[5]*n+r[13],e[3]=r[3]*i+r[7]*n+r[15],e}var Ek=class{constructor(e,t=new JM(e.width+200,e.height+200,25),r=new JM(e.width+200,e.height+200,25)){this.transform=e,this.grid=t,this.ignoredGrid=r,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}placeCollisionBox(e,t,r,i,n,a,s,o,l,u,c,h,d=0,p=!0){let f,m=e.anchorPointX+o[0],g=e.anchorPointY+o[1],y=this.projectAndGetPerspectiveRatio(m,g,n,YM(u,m,g,d,p),h),_=r*y.perspectiveRatio;if(a||s)f=this._projectCollisionBox(e,_,i,n,a,s,o,y,u,c,h,d,p);else{let t=y.x+(c?c.x*_:0),r=y.y+(c?c.y*_:0);f={allPointsOccluded:!1,box:[t+e.x1*_,r+e.y1*_,t+e.x2*_,r+e.y2*_]}}let[v,x,b,w]=f.box,E=a?f.allPointsOccluded:y.isOccluded,S=E;return S||=y.perspectiveRatio<this.perspectiveRatioCutoff,S||=!this.isInsideGrid(v,x,b,w),S||"always"!==t&&this.grid.hitTest(v,x,b,w,t,l)?{box:[v,x,b,w],placeable:!1,offscreen:!1,occluded:E}:{box:[v,x,b,w],placeable:!0,offscreen:this.isOffscreen(v,x,b,w),occluded:E}}placeCollisionCircles(e,t,r,i,n,a,s,o,l,u,c,h,d,p){let f=[],m=new Sd(t.anchorX,t.anchorY),g=this.getPerspectiveRatio(m.x,m.y,a,p?.(m.x,m.y)),y=(l?n*this.transform.getPitchedTextCorrection(t.anchorX,t.anchorY,a)/g:n*g)/24,_=t.lineOffsetX*y,v=t.lineOffsetY*y,x={getElevation:p,pitchedLabelPlaneMatrix:s,lineVertexArray:r,pitchWithMap:l,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:this.transform,tileAnchorPoint:m,unwrappedTileID:a,width:this.transform.width,height:this.transform.height,translation:d},b=uk(y,i,_,v,!1,t,!1,x),w=!1,E=!1,S=!0;if(b){let t=.5*c*g+h,r=new Sd(-100,-100),i=new Sd(this.screenRightBoundary,this.screenBottomBoundary),n=new XM,a=b.first,s=b.last,d=[];for(let e=a.path.length-1;e>=1;e--)d.push(a.path[e]);for(let e=1;e<s.path.length;e++)d.push(s.path[e]);let p=2.5*t;if(l){let e=this.projectPathToScreenSpace(d,x);d=e.some(e=>e.signedDistanceFromCamera<=0)?[]:e.map(e=>e.point)}let m=[];if(d.length>0){let e=d[0].clone(),t=d[0].clone();for(let r=1;r<d.length;r++)e.x=Math.min(e.x,d[r].x),e.y=Math.min(e.y,d[r].y),t.x=Math.max(t.x,d[r].x),t.y=Math.max(t.y,d[r].y);m=e.x>=r.x&&t.x<=i.x&&e.y>=r.y&&t.y<=i.y?[d]:t.x<r.x||e.x>i.x||t.y<r.y||e.y>i.y?[]:zT([d],r.x,r.y,i.x,i.y)}for(let l of m){n.reset(l,.25*t);let r=0;r=n.length<=.5*t?1:Math.ceil(n.paddedLength/p)+1;for(let i=0;i<r;i++){let a=i/Math.max(r-1,1),s=n.lerp(a),l=s.x+100,c=s.y+100;f.push(l,c,t,0);let h=l-t,d=c-t,p=l+t,m=c+t;if(S&&=this.isOffscreen(h,d,p,m),E||=this.isInsideGrid(h,d,p,m),"always"!==e&&this.grid.hitTestCircle(l,c,t,e,u)&&(w=!0,!o))return{circles:[],offscreen:!1,collisionDetected:w}}}}return{circles:!o&&w||!E||g<this.perspectiveRatioCutoff?[]:f,offscreen:S,collisionDetected:w}}projectPathToScreenSpace(e,t){return function(e){let t=0,r=0,i=0,n=0;for(let a=0;a<e.length;a++)e[a].isOccluded?(i=a+1,n=0):(n++,n>r&&(r=n,t=i));return e.slice(t,t+r)}(function(e,t){let r=ek;return function(e,t){let r=1/(t[0]*t[5]-t[1]*t[4]);e[0]=t[5]*r,e[1]=-t[1]*r,e[2]=0,e[3]=0,e[4]=-t[4]*r,e[5]=t[0]*r,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1/t[10],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1/t[15]}(r,t.pitchedLabelPlaneMatrix),e.map(e=>{let i=ak(e.x,e.y,r,nk(t,e.x,e.y)),n=t.transform.projectTileCoordinates(i.point.x,i.point.y,t.unwrappedTileID,nk(t,i.point.x,i.point.y));return n.point.x=(.5*n.point.x+.5)*t.width,n.point.y=(.5*-n.point.y+.5)*t.height,n})}(e,t))}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};let t=[],r=new WE;for(let c of e){let e=new Sd(c.x+100,c.y+100);r.extend(e),t.push(e)}let{minX:i,minY:n,maxX:a,maxY:s}=r,o=this.grid.query(i,n,a,s).concat(this.ignoredGrid.query(i,n,a,s)),l={},u={};for(let c of o){let e=c.key;(void 0===l[e.bucketInstanceId]&&(l[e.bucketInstanceId]={}),l[e.bucketInstanceId][e.featureIndex])||Zb(t,[new Sd(c.x1,c.y1),new Sd(c.x2,c.y1),new Sd(c.x2,c.y2),new Sd(c.x1,c.y2)])&&(l[e.bucketInstanceId][e.featureIndex]=!0,void 0===u[e.bucketInstanceId]&&(u[e.bucketInstanceId]=[]),u[e.bucketInstanceId].push(e.featureIndex))}return u}insertCollisionBox(e,t,r,i,n,a){let s={bucketInstanceId:i,featureIndex:n,collisionGroupID:a,overlapMode:t};(r?this.ignoredGrid:this.grid).insert(s,e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,r,i,n,a){let s=r?this.ignoredGrid:this.grid,o={bucketInstanceId:i,featureIndex:n,collisionGroupID:a,overlapMode:t};for(let l=0;l<e.length;l+=4)s.insertCircle(o,e[l],e[l+1],e[l+2])}projectAndGetPerspectiveRatio(e,t,r,i,n){if(n){let r;null==i?(r=[e,t,0,1],wk(r,r,n)):(r=[e,t,i,1],sp(r,r,n));let a=r[3];return{x:(r[0]/a+1)/2*this.transform.width+100,y:(-r[1]/a+1)/2*this.transform.height+100,perspectiveRatio:.5+this.transform.cameraToCenterDistance/a*.5,isOccluded:!1,signedDistanceFromCamera:a}}{let n=this.transform.projectTileCoordinates(e,t,r,i);return{x:(n.point.x+1)/2*this.transform.width+100,y:(1-n.point.y)/2*this.transform.height+100,perspectiveRatio:.5+this.transform.cameraToCenterDistance/n.signedDistanceFromCamera*.5,isOccluded:n.isOccluded,signedDistanceFromCamera:n.signedDistanceFromCamera}}}getPerspectiveRatio(e,t,r,i){let n=this.transform.projectTileCoordinates(e,t,r,i);return.5+this.transform.cameraToCenterDistance/n.signedDistanceFromCamera*.5}isOffscreen(e,t,r,i){return r<100||e>=this.screenRightBoundary||i<100||t>this.screenBottomBoundary}isInsideGrid(e,t,r,i){return r>=0&&e<this.gridRightBoundary&&i>=0&&t<this.gridBottomBoundary}getViewportMatrix(){let e=kd([]);return zd(e,e,[-100,-100,0]),e}_projectCollisionBox(e,t,r,i,n,a,s,o,l,u,c,h=0,d=!0){let p=1,f=0,m=0,g=1,y=e.anchorPointX+s[0],_=e.anchorPointY+s[1];if(a&&!n){let e=this.projectAndGetPerspectiveRatio(y+1,_,i,YM(l,y+1,_,h,d),c),t=e.x-o.x,r=e.y-o.y,n=Math.atan(r/t)+(t<0?Math.PI:0),a=Math.sin(n),s=Math.cos(n);p=s,f=a,m=-a,g=s}else if(!a&&n){let e=ik(this.transform);p=e.vecEast[0],f=e.vecEast[1],m=e.vecSouth[0],g=e.vecSouth[1]}let v=o.x,x=o.y,b=t;if(n&&(v=y,x=_,b=2**-(this.transform.zoom-r.overscaledZ),b*=this.transform.getPitchedTextCorrection(y,_,i),!u)){b*=$p(.5+.5*(o.signedDistanceFromCamera/this.transform.cameraToCenterDistance),0,4)}u&&(v+=p*u.x*b+m*u.y*b,x+=f*u.x*b+g*u.y*b);let w=e.x1*b,E=e.x2*b,S=(w+E)/2,D=e.y1*b,T=e.y2*b,A=(D+T)/2,P=[{offsetX:w,offsetY:D},{offsetX:S,offsetY:D},{offsetX:E,offsetY:D},{offsetX:E,offsetY:A},{offsetX:E,offsetY:T},{offsetX:S,offsetY:T},{offsetX:w,offsetY:T},{offsetX:w,offsetY:A}],I=[];for(let{offsetX:F,offsetY:M}of P)I.push(new Sd(v+p*F+m*M,x+f*F+g*M));let C=!1;if(n){let e=I.map(e=>this.projectAndGetPerspectiveRatio(e.x,e.y,i,YM(l,e.x,e.y,h,d),c));C=e.some(e=>!e.isOccluded),I=e.map(e=>new Sd(e.x,e.y))}else C=!0;return{box:zp(I),allPointsOccluded:!C}}},Sk=class{constructor(e,t,r,i){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):i&&r?1:0,this.placed=r}isHidden(){return 0===this.opacity&&!this.placed}},Dk=class{constructor(e,t,r,i,n){this.text=new Sk(e?e.text:null,t,r,n),this.icon=new Sk(e?e.icon:null,t,i,n)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}},Tk=class{constructor(e,t,r){this.text=e,this.icon=t,this.skipFade=r}},Ak=class{constructor(e,t,r,i,n){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=r,this.bucketIndex=i,this.tileID=n}},Pk=class{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 Ik(e,t,r,i,n){let{horizontalAlign:a,verticalAlign:s}=cT(e),o=-(s-.5)*r;return new Sd(-(a-.5)*t+i[0]*n,o+i[1]*n)}var Ck=class{constructor(e,t,r,i,n){this.transform=e.clone(),this.terrain=t,this.collisionIndex=new Ek(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=r,this.retainedQueryData={},this.collisionGroups=new Pk(i),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=n,n&&(n.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){let t=this.terrain;if(t)return(r,i)=>t.getElevation(e,r,i)}getBucketParts(e,t,r,i){let n=r.getBucket(t),a=r.latestFeatureIndex;if(!n||!a||t.id!==n.layerIds[0])return;let s=r.collisionBoxArray,o=n.layers[0].layout,l=n.layers[0].paint,u=2**(this.transform.zoom-r.tileID.overscaledZ),c=r.tileSize/_p,h=r.tileID.toUnwrapped(),d="map"===o.get("text-rotation-alignment"),p=vp(r,1,this.transform.zoom),f=Tp(this.collisionIndex.transform,r,l.get("text-translate"),l.get("text-translate-anchor")),m=Tp(this.collisionIndex.transform,r,l.get("icon-translate"),l.get("icon-translate-anchor")),g=tk(d,this.transform,p);this.retainedQueryData[n.bucketInstanceId]=new Ak(n.bucketInstanceId,a,n.sourceLayerIndex,n.index,r.tileID);let y={bucket:n,layout:o,translationText:f,translationIcon:m,unwrappedTileID:h,pitchedLabelPlaneMatrix:g,scale:u,textPixelRatio:c,holdingForFade:r.holdingForSymbolFade(),collisionBoxArray:s,partiallyEvaluatedTextSize:AT(n.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(n.sourceID)};if(i)for(let _ of n.sortKeyRanges){let{sortKey:t,symbolInstanceStart:r,symbolInstanceEnd:i}=_;e.push({sortKey:t,symbolInstanceStart:r,symbolInstanceEnd:i,parameters:y})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:n.symbolInstances.length,parameters:y})}attemptAnchorPlacement(e,t,r,i,n,a,s,o,l,u,c,h,d,p,f,m,g,y,_,v,x,b){let w=HT[e.textAnchor],E=[e.textOffset0,e.textOffset1],S=Ik(w,r,i,E,n),D=this.collisionIndex.placeCollisionBox(t,h,o,l,u,s,a,m,c.predicate,_,S,v,x,b);if((!y||this.collisionIndex.placeCollisionBox(y,h,o,l,u,s,a,g,c.predicate,_,S,v,x,b).placeable)&&D.placeable){let e;if(this.prevPlacement?.variableOffsets[d.crossTileID]&&this.prevPlacement?.placements[d.crossTileID]?.text&&(e=this.prevPlacement.variableOffsets[d.crossTileID].anchor),0===d.crossTileID)throw Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[d.crossTileID]={textOffset:E,width:r,height:i,anchor:w,textBoxScale:n,prevAnchor:e},this.markUsedJustification(p,w,d,f),p.allowVerticalPlacement&&(this.markUsedOrientation(p,f,d),this.placedOrientations[d.crossTileID]=f),{shift:S,placedGlyphBoxes:D}}}placeLayerBucketPart(e,t,r){let{bucket:i,layout:n,translationText:a,translationIcon:s,unwrappedTileID:o,pitchedLabelPlaneMatrix:l,textPixelRatio:u,holdingForFade:c,collisionBoxArray:h,partiallyEvaluatedTextSize:d,collisionGroup:p}=e.parameters,f=n.get("text-optional"),m=n.get("icon-optional"),g=iA(n,"text-overlap","text-allow-overlap"),y="always"===g,_=iA(n,"icon-overlap","icon-allow-overlap"),v="always"===_,x="map"===n.get("text-rotation-alignment"),b="map"===n.get("text-pitch-alignment"),w="none"!==n.get("icon-text-fit"),E="viewport-y"===n.get("symbol-z-order"),S="ground"===n.get("symbol-height-anchor"),D=y&&(v||!i.hasIconData()||m),T=v&&(y||!i.hasTextData()||f);!i.collisionArrays&&h&&i.deserializeCollisionBoxes(h);let A=this.retainedQueryData[i.bucketInstanceId].tileID,P=this._getTerrainElevationFunc(A),I=this.transform.getFastPathSimpleProjectionMatrix(A),C=(e,h,v)=>{if(t[e.crossTileID])return;if(c)return void(this.placements[e.crossTileID]=new Tk(!1,!1,!1));let E=e.heightOffset,C=!1,F=!1,M=!0,k=null,R={box:null,placeable:!1,offscreen:null,occluded:!1},L={placeable:!1},z=null,B=null,O=null,$=0,N=0,j=0;h.textFeatureIndex?$=h.textFeatureIndex:e.useRuntimeCollisionCircles&&($=e.featureIndex),h.verticalTextFeatureIndex&&(N=h.verticalTextFeatureIndex);let V=h.textBox;if(V){let t=t=>{let r=1;if(i.allowVerticalPlacement&&!t&&this.prevPlacement){let t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,r=t,this.markUsedOrientation(i,r,e))}return r},n=(t,r)=>{if(i.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&h.verticalTextBox){for(let e of i.writingModes)if(2===e?(R=r(),L=R):R=t(),R?.placeable)break}else R=t()},l=e.textAnchorOffsetStartIndex,c=e.textAnchorOffsetEndIndex;if(c===l){let r=(t,r)=>{let n=this.collisionIndex.placeCollisionBox(t,g,u,A,o,b,x,a,p.predicate,P,void 0,I,E,S);return n?.placeable&&(this.markUsedOrientation(i,r,e),this.placedOrientations[e.crossTileID]=r),n};n(()=>r(V,1),()=>{let t=h.verticalTextBox;return i.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&t?r(t,2):{box:null,offscreen:null}}),t(R?.placeable)}else{let d=HT[this.prevPlacement?.variableOffsets[e.crossTileID]?.anchor],f=(t,n,h)=>{let f=t.x2-t.x1,m=t.y2-t.y1,y=e.textBoxScale,v=w&&"never"===_?n:null,D=null,T="never"===g?1:2,F="never";d&&T++;for(let r=0;r<T;r++){for(let r=l;r<c;r++){let n=i.textAnchorOffsets.get(r);if(d&&n.textAnchor!==d)continue;let l=this.attemptAnchorPlacement(n,t,f,m,y,x,b,u,A,o,p,F,e,i,h,a,s,v,P,I,E,S);if(l&&(D=l.placedGlyphBoxes,D?.placeable))return C=!0,k=l.shift,D}d?d=null:F=g}return r&&!D&&(D={box:this.collisionIndex.placeCollisionBox(V,"always",u,A,o,b,x,a,p.predicate,P,void 0,I,E,S).box,offscreen:!1,placeable:!1,occluded:!1}),D};n(()=>f(V,h.iconBox,1),()=>{let t=h.verticalTextBox,r=R?.placeable;return i.allowVerticalPlacement&&!r&&e.numVerticalGlyphVertices>0&&t?f(t,h.verticalIconBox,2):{box:null,occluded:!0,offscreen:null}}),R&&(C=R.placeable,M=R.offscreen);let m=t(R?.placeable);if(!C&&this.prevPlacement){let t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(i,t.anchor,e,m))}}}if(z=R,C=z?.placeable,M=z?.offscreen,e.useRuntimeCollisionCircles&&e.centerJustifiedTextSymbolIndex>=0){let t=i.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),s=TT(i.textSizeData,d,t),u=n.get("text-padding"),c=e.collisionCircleDiameter;B=this.collisionIndex.placeCollisionCircles(g,t,i.lineVertexArray,i.glyphOffsetArray,s,o,l,r,b,p.predicate,c,u,a,P),B.circles.length&&B.collisionDetected&&!r&&Qp("Collisions detected, but collision boxes are not shown"),C=y||B.circles.length>0&&!B.collisionDetected,M&&=B.offscreen}if(h.iconFeatureIndex&&(j=h.iconFeatureIndex),h.iconBox){let e=e=>this.collisionIndex.placeCollisionBox(e,_,u,A,o,b,x,s,p.predicate,P,w&&k?k:void 0,I,E,S);L&&L.placeable&&h.verticalIconBox?(O=e(h.verticalIconBox),F=O.placeable):(O=e(h.iconBox),F=O.placeable),M&&=O.offscreen}let U=f||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,q=m||0===e.numIconVertices;U||q?q?U||(F&&=C):C=F&&C:F=C=F&&C;let G=C&&z.placeable,Z=F&&O.placeable;if(G&&(L&&L.placeable&&N?this.collisionIndex.insertCollisionBox(z.box,g,n.get("text-ignore-placement"),i.bucketInstanceId,N,p.ID):this.collisionIndex.insertCollisionBox(z.box,g,n.get("text-ignore-placement"),i.bucketInstanceId,$,p.ID)),Z&&this.collisionIndex.insertCollisionBox(O.box,_,n.get("icon-ignore-placement"),i.bucketInstanceId,j,p.ID),B&&C&&this.collisionIndex.insertCollisionCircles(B.circles,g,n.get("text-ignore-placement"),i.bucketInstanceId,$,p.ID),r&&this.storeCollisionData(i.bucketInstanceId,v,h,z,O,B),0===e.crossTileID)throw Error("symbolInstance.crossTileID can't be 0");if(0===i.bucketInstanceId)throw Error("bucket.bucketInstanceId can't be 0");let W=(C||D)&&!z?.occluded,H=(F||T)&&!O?.occluded;this.placements[e.crossTileID]=new Tk(W,H,M||i.justReloaded),t[e.crossTileID]=!0};if(E){if(0!==e.symbolInstanceStart)throw Error("bucket.bucketInstanceId should be 0");let t=i.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=t.length-1;e>=0;--e){let r=t[e];C(i.symbolInstances.get(r),i.collisionArrays[r],r)}}else for(let F=e.symbolInstanceStart;F<e.symbolInstanceEnd;F++)C(i.symbolInstances.get(F),i.collisionArrays[F],F);i.justReloaded=!1}storeCollisionData(e,t,r,i,n,a){if(r.textBox||r.iconBox){let a,s;this.collisionBoxArrays.has(e)?a=this.collisionBoxArrays.get(e):(a=new Map,this.collisionBoxArrays.set(e,a)),a.has(t)?s=a.get(t):(s={text:null,icon:null},a.set(t,s)),r.textBox&&(s.text=i.box),r.iconBox&&(s.icon=n.box)}if(a){let t=this.collisionCircleArrays[e];void 0===t&&(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)}}markUsedJustification(e,t,r,i){let n,a={left:r.leftJustifiedTextSymbolIndex,center:r.centerJustifiedTextSymbolIndex,right:r.rightJustifiedTextSymbolIndex};n=2===i?r.verticalPlacedTextSymbolIndex:a[JT(t)];let s=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex,r.verticalPlacedTextSymbolIndex];for(let o of s)o>=0&&(e.text.placedSymbolArray.get(o).crossTileID=n>=0&&o!==n?0:r.crossTileID)}markUsedOrientation(e,t,r){let i=1===t||3===t?t:0,n=2===t?t:0,a=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];for(let s of a)e.text.placedSymbolArray.get(s).placedOrientation=i;r.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).placedOrientation=n)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;let t=this.prevPlacement,r=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;let i=t?t.symbolFadeChange(e):1,n=t?t.opacities:{},a=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(let o in this.placements){let e=this.placements[o],t=n[o];t?(this.opacities[o]=new Dk(t,i,e.text,e.icon),r||=e.text!==t.text.placed,r||=e.icon!==t.icon.placed):(this.opacities[o]=new Dk(null,i,e.text,e.icon,e.skipFade),r||=e.text||e.icon)}for(let o in n){let e=n[o];if(!this.opacities[o]){let t=new Dk(e,i,!1,!1);t.isHidden()||(this.opacities[o]=t,r||=e.text.placed,r||=e.icon.placed)}}for(let o in a)!this.variableOffsets[o]&&this.opacities[o]&&!this.opacities[o].isHidden()&&(this.variableOffsets[o]=a[o]);for(let o in s)!this.placedOrientations[o]&&this.opacities[o]&&!this.opacities[o].isHidden()&&(this.placedOrientations[o]=s[o]);if(t&&void 0===t.lastPlacementChangeTime)throw Error("Last placement time for previous placement is not defined");r?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){let r={};for(let i of t){let t=i.getBucket(e);t&&i.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,i.tileID,r,i.collisionBoxArray)}}updateBucketOpacities(e,t,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 n=e.layers[0],a=n.layout,s=new Dk(null,0,!1,!1,!0),o=a.get("text-allow-overlap"),l=a.get("icon-allow-overlap"),u=n._unevaluatedLayout.hasValue("text-variable-anchor")||n._unevaluatedLayout.hasValue("text-variable-anchor-offset"),c="map"===a.get("text-rotation-alignment"),h="map"===a.get("text-pitch-alignment"),d="none"!==a.get("icon-text-fit"),p=new Dk(null,0,o&&(l||!e.hasIconData()||a.get("icon-optional")),l&&(o||!e.hasTextData()||a.get("text-optional")),!0);!e.collisionArrays&&i&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(i);let f=(e,t,r)=>{for(let i=0;i<t/4;i++)e.opacityVertexArray.emplaceBack(r);e.hasVisibleVertices||=r!==Bk},m=this.collisionBoxArrays.get(e.bucketInstanceId);for(let g=0;g<e.symbolInstances.length;g++){let t=e.symbolInstances.get(g),{numHorizontalGlyphVertices:i,numVerticalGlyphVertices:n,crossTileID:a}=t,o=r[a],l=this.opacities[a];o?l=s:l||(l=p,this.opacities[a]=l),r[a]=!0;let y=i>0||n>0,_=t.numIconVertices>0,v=this.placedOrientations[t.crossTileID],x=2===v,b=1===v||3===v;if(y){let r=zk(l.text),a=x?Bk:r;f(e.text,i,a);let s=b?Bk:r;f(e.text,n,s);let o=l.text.isHidden(),u=[t.rightJustifiedTextSymbolIndex,t.centerJustifiedTextSymbolIndex,t.leftJustifiedTextSymbolIndex];for(let t of u)t>=0&&(e.text.placedSymbolArray.get(t).hidden=o||x?1:0);t.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(t.verticalPlacedTextSymbolIndex).hidden=o||b?1:0);let c=this.variableOffsets[t.crossTileID];c&&this.markUsedJustification(e,c.anchor,t,v);let h=this.placedOrientations[t.crossTileID];h&&(this.markUsedJustification(e,"left",t,h),this.markUsedOrientation(e,h,t))}if(_){let r=zk(l.icon),i=!(d&&t.verticalPlacedIconSymbolIndex&&x);if(t.placedIconSymbolIndex>=0){let n=i?r:Bk;f(e.icon,t.numIconVertices,n),e.icon.placedSymbolArray.get(t.placedIconSymbolIndex).hidden=l.icon.isHidden()}if(t.verticalPlacedIconSymbolIndex>=0){let n=i?Bk:r;f(e.icon,t.numVerticalIconVertices,n),e.icon.placedSymbolArray.get(t.verticalPlacedIconSymbolIndex).hidden=l.icon.isHidden()}}let w=m?.has(g)?m.get(g):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){let t=e.collisionArrays[g];if(t){let r=new Sd(0,0);if(t.textBox||t.verticalTextBox){let i=!0;if(u){let e=this.variableOffsets[a];e?(r=Ik(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),c&&r._rotate(h?-this.transform.bearingInRadians:this.transform.bearingInRadians)):i=!1}if(t.textBox||t.verticalTextBox){let n;t.textBox&&(n=x),t.verticalTextBox&&(n=b),Fk(e.textCollisionBox.collisionVertexArray,l.text.placed,!i||n,w.text,r.x,r.y)}}if(t.iconBox||t.verticalIconBox){let i,n=!(b||!t.verticalIconBox);t.iconBox&&(i=n),t.verticalIconBox&&(i=!n),Fk(e.iconCollisionBox.collisionVertexArray,l.icon.placed,i,w.icon,d?r.x:0,d?r.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 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(e,t){let r=this.zoomAtLastRecencyCheck===t?1-this.zoomAdjustment(t):1;return this.zoomAtLastRecencyCheck=t,this.commitTime+this.fadeDuration*r>e}setStale(){this.stale=!0}};function Fk(e,t,r,i,n,a){(!i||0===i.length)&&(i=[0,0,0,0]);let s=i[0]-100,o=i[1]-100,l=i[2]-100,u=i[3]-100;e.emplaceBack(+!!t,+!!r,n||0,a||0,s,o),e.emplaceBack(+!!t,+!!r,n||0,a||0,l,o),e.emplaceBack(+!!t,+!!r,n||0,a||0,l,u),e.emplaceBack(+!!t,+!!r,n||0,a||0,s,u)}const Mk=2**25,kk=2**24,Rk=2**17,Lk=65536;function zk(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;let t=+!!e.placed,r=Math.floor(127*e.opacity);return r*Mk+t*kk+r*Rk+t*Lk+512*r+256*t+2*r+t}const Bk=0;var Ok=class{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,t,r,i,n){let a=this._bucketParts;for(;this._currentTileIndex<e.length;){let r=e[this._currentTileIndex];if(t.getBucketParts(a,i,r,this._sortAcrossTiles),this._currentTileIndex++,n())return!0}for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,a.sort((e,t)=>e.sortKey-t.sortKey));this._currentPartIndex<a.length;){let e=a[this._currentPartIndex];if(t.placeLayerBucketPart(e,this._seenCrossTileIDs,r),this._currentPartIndex++,n())return!0}return!1}},$k=class{constructor(e,t,r,i,n,a,s,o){this.placement=new Ck(e,t,a,s,o),this._currentPlacementIndex=r.length-1,this._forceFullPlacement=i,this._showCollisionBoxes=n,this._done=!1}isDone(){return this._done}continuePlacement(e,t,r){let i=OC(),n=()=>!this._forceFullPlacement&&OC()-i>2;for(;this._currentPlacementIndex>=0;){let i=t[e[this._currentPlacementIndex]],a=this.placement.collisionIndex.transform.zoom;if(mA(i)&&i.layout&&(!i.minzoom||i.minzoom<=a)&&(!i.maxzoom||i.maxzoom>a)){if(this._inProgressLayer||=new Ok(i),this._inProgressLayer.continuePlacement(r[i.source],this.placement,this._showCollisionBoxes,i,n))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}};const Nk=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],jk=new Uint32Array(96);var Vk=class e{static from(t){if(!t||void 0===t.byteLength||t.buffer)throw Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");let[r,i]=new Uint8Array(t,0,2);if(219!==r)throw Error("Data does not appear to be in a KDBush format.");let n=i>>4;if(1!==n)throw Error(`Got v${n} data when expected v1.`);let a=Nk[15&i];if(!a)throw Error("Unrecognized array type.");let[s]=new Uint16Array(t,2,1),[o]=new Uint32Array(t,4,1);return new e(o,s,a,void 0,t)}constructor(e,t=64,r=Float64Array,i=ArrayBuffer,n){if(isNaN(e)||e<0)throw Error(`Unexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=r,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;let a=Nk.indexOf(this.ArrayType),s=2*e*this.ArrayType.BYTES_PER_ELEMENT,o=e*this.IndexArrayType.BYTES_PER_ELEMENT,l=(8-o%8)%8;if(a<0)throw Error(`Unexpected typed array class: ${r}.`);if(n)this.data=n,this.ids=new this.IndexArrayType(n,8,e),this.coords=new r(n,8+o+l,2*e),this._pos=2*e,this._finished=!0;else{let n=this.data=new i(8+s+o+l);this.ids=new this.IndexArrayType(n,8,e),this.coords=new r(n,8+o+l,2*e),this._pos=0,this._finished=!1,new Uint8Array(n,0,2).set([219,16+a]),new Uint16Array(n,2,1)[0]=t,new Uint32Array(n,4,1)[0]=e}}add(e,t){let r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=e,this.coords[this._pos++]=t,r}finish(){let e=this._pos>>1;if(e!==this.numItems)throw Error(`Added ${e} items when expected ${this.numItems}.`);return Uk(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,r,i){if(!this._finished)throw Error("Data not yet indexed - call index.finish().");let{ids:n,coords:a,nodeSize:s}=this;jk[0]=0,jk[1]=n.length-1,jk[2]=0;let o=3,l=[];for(;o>0;){let u=jk[--o],c=jk[--o],h=jk[--o];if(c-h<=s){for(let s=h;s<=c;s++){let o=a[2*s],u=a[2*s+1];o>=e&&o<=r&&u>=t&&u<=i&&l.push(n[s])}continue}let d=h+c>>1,p=a[2*d],f=a[2*d+1];p>=e&&p<=r&&f>=t&&f<=i&&l.push(n[d]),(0===u?e<=p:t<=f)&&(jk[o++]=h,jk[o++]=d-1,jk[o++]=1-u),(0===u?r>=p:i>=f)&&(jk[o++]=d+1,jk[o++]=c,jk[o++]=1-u)}return l}within(e,t,r){let i=[];return this.withinInto(e,t,r,i),i}withinInto(e,t,r,i){if(!this._finished)throw Error("Data not yet indexed - call index.finish().");let{ids:n,coords:a,nodeSize:s}=this;jk[0]=0,jk[1]=n.length-1,jk[2]=0;let o=3,l=0,u=r*r;for(;o>0;){let c=jk[--o],h=jk[--o],d=jk[--o];if(h-d<=s){for(let r=d;r<=h;r++)Wk(a[2*r],a[2*r+1],e,t)<=u&&(i[l++]=n[r]);continue}let p=d+h>>1,f=a[2*p],m=a[2*p+1];Wk(f,m,e,t)<=u&&(i[l++]=n[p]),(0===c?e-r<=f:t-r<=m)&&(jk[o++]=d,jk[o++]=p-1,jk[o++]=1-c),(0===c?e+r>=f:t+r>=m)&&(jk[o++]=p+1,jk[o++]=h,jk[o++]=1-c)}return l}};function Uk(e,t,r,i,n,a){if(n-i<=r)return;let s=i+n>>1;qk(e,t,s,i,n,a),Uk(e,t,r,i,s-1,1-a),Uk(e,t,r,s+1,n,1-a)}function qk(e,t,r,i,n,a){for(;n>i;){if(n-i>600){let s=n-i+1,o=r-i+1,l=Math.log(s),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(s-u)/s)*(o-s/2<0?-1:1);qk(e,t,r,Math.max(i,Math.floor(r-o*u/s+c)),Math.min(n,Math.floor(r+(s-o)*u/s+c)),a)}let s=t[2*r+a],o=i,l=n;for(Gk(e,t,i,r),t[2*n+a]>s&&Gk(e,t,i,n);o<l;){for(Gk(e,t,o,l),o++,l--;t[2*o+a]<s;)o++;for(;t[2*l+a]>s;)l--}t[2*i+a]===s?Gk(e,t,i,l):(l++,Gk(e,t,l,n)),l<=r&&(i=l+1),r<=l&&(n=l-1)}}function Gk(e,t,r,i){Zk(e,r,i),Zk(t,2*r,2*i),Zk(t,2*r+1,2*i+1)}function Zk(e,t,r){let i=e[t];e[t]=e[r],e[r]=i}function Wk(e,t,r,i){let n=e-r,a=t-i;return n*n+a*a}const Hk=.03125;var Xk=class{constructor(e,t,r){this.tileID=e,this.bucketInstanceId=r,this._symbolsByKey={};let i=new Map;for(let n=0;n<t.length;n++){let e=t.get(n),r=e.key,a=i.get(r);a?a.push(e):i.set(r,[e])}for(let[n,a]of i){let e={positions:a.map(e=>({x:Math.floor(e.anchorX*Hk),y:Math.floor(e.anchorY*Hk)})),crossTileIDs:a.map(e=>e.crossTileID)};if(e.positions.length>128){let t=new Vk(e.positions.length,16,Uint16Array);for(let{x:r,y:i}of e.positions)t.add(r,i);t.finish(),delete e.positions,e.index=t}this._symbolsByKey[n]=e}}getScaledCoordinates(e,t){let{x:r,y:i,z:n}=this.tileID.canonical,{x:a,y:s,z:o}=t.canonical,l=Hk/2**(o-n),u=(a*_p+e.anchorX)*l,c=(s*_p+e.anchorY)*l,h=r*_p*Hk,d=i*_p*Hk;return{x:Math.floor(u-h),y:Math.floor(c-d)}}findMatches(e,t,r){let i=this.tileID.canonical.z<t.canonical.z?1:2**(this.tileID.canonical.z-t.canonical.z);for(let n=0;n<e.length;n++){let a=e.get(n);if(a.crossTileID)continue;let s=this._symbolsByKey[a.key];if(!s)continue;let o=this.getScaledCoordinates(a,t);s.index?this.findMatchesForIndexedEntry(s,a,o,i,r):s.positions&&this.findMatchesForNonIndexedEntry(s,a,o,i,r)}}findMatchesForIndexedEntry(e,t,r,i,n){let a=e.index.range(r.x-i,r.y-i,r.x+i,r.y+i),s=1/0;for(let o of a)o<s&&!n[e.crossTileIDs[o]]&&(s=o);if(s!==1/0){let r=e.crossTileIDs[s];n[r]=!0,t.crossTileID=r}}findMatchesForNonIndexedEntry(e,t,r,i,n){for(let a=0;a<e.positions.length;a++){let s=e.positions[a],o=e.crossTileIDs[a];if(Math.abs(s.x-r.x)<=i&&Math.abs(s.y-r.y)<=i&&!n[o]){n[o]=!0,t.crossTileID=o;break}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map(({crossTileIDs:e})=>e)}},Yk=class{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}},Kk=class{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){let t=Math.round((e-this.lng)/360);if(0!==t)for(let r in this.indexes){let e=this.indexes[r],i={};for(let r in e){let n=e[r];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+t),i[n.tileID.key]=n}this.indexes[r]=i}this.lng=e}addBucket(e,t,r){if(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 n=0;n<t.symbolInstances.length;n++){t.symbolInstances.get(n).crossTileID=0}this.usedCrossTileIDs[e.overscaledZ]||={};let i=this.usedCrossTileIDs[e.overscaledZ];for(let n in this.indexes){let r=this.indexes[n];if(Number(n)>e.overscaledZ)for(let n in r){let a=r[n];a.tileID.isChildOf(e)&&a.findMatches(t.symbolInstances,e,i)}else{let a=r[e.scaledTo(Number(n)).key];a&&a.findMatches(t.symbolInstances,e,i)}}for(let n=0;n<t.symbolInstances.length;n++){let e=t.symbolInstances.get(n);e.crossTileID||(e.crossTileID=r.generate(),i[e.crossTileID]=!0)}return void 0===this.indexes[e.overscaledZ]&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new Xk(e,t.symbolInstances,t.bucketInstanceId),!0}removeBucketCrossTileIDs(e,t){for(let r of t.getCrossTileIDsLists())for(let t of r)delete this.usedCrossTileIDs[e][t]}removeStaleBuckets(e){let t=!1;for(let r in this.indexes){let i=this.indexes[r];for(let n in i)e[i[n].bucketInstanceId]||(this.removeBucketCrossTileIDs(r,i[n]),delete i[n],t=!0)}return t}},Jk=class{constructor(){this.layerIndexes={},this.crossTileIDs=new Yk,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,t,r){let i=this.layerIndexes[e.id];void 0===i&&(i=this.layerIndexes[e.id]=new Kk);let n=!1,a={};i.handleWrapJump(r);for(let s of t){let t=s.getBucket(e);e.id===t?.layerIds[0]&&(t.bucketInstanceId||=(this.maxBucketInstanceId+=1,this.maxBucketInstanceId),i.addBucket(s.tileID,t,this.crossTileIDs)&&(n=!0),a[t.bucketInstanceId]=!0)}return i.removeStaleBuckets(a)&&(n=!0),n}pruneUnusedLayers(e){let t={};for(let r of e)t[r]=!0;for(let r in this.layerIndexes)t[r]||delete this.layerIndexes[r]}},Qk="void main() {fragColor=vec4(1.0);}";const eR={prelude:tR("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nout highp vec4 fragColor;layout(std140) uniform ProjectionUBO {highp mat4 u_projection_matrix;highp mat4 u_projection_fallback_matrix;highp vec4 u_projection_tile_mercator_coords;highp vec4 u_projection_clipping_plane;highp float u_projection_transition;highp int u_projection_clip_antimeridian;};layout(std140) uniform FrameUBO {highp vec2 u_units_to_pixels;highp vec2 u_world_size;highp float u_camera_to_center_distance;highp float u_symbol_fade_change;highp float u_aspect_ratio;highp float u_device_pixel_ratio;highp vec2 u_viewport_size;highp vec2 u_pixel_extrude_scale;highp float u_pitch;};","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const uint packedOpacity) {return vec2(float(packedOpacity >> 1u)/127.0,float(packedOpacity & 1u));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c\n);}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform highp sampler2D u_depth;layout(std140) uniform TerrainUBO {highp mat4 u_terrain_matrix;highp vec4 u_terrain_unpack;highp float u_terrain_dim;highp float u_terrain_exaggeration;};\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(ivec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texelFetch(u_terrain,pos,0)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\n#ifdef GLOBE\nif ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}\n#endif\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+2.0;vec2 f=fract(coord);ivec2 c=ivec2(floor(coord));ivec2 hi=textureSize(u_terrain,0)-1;float tl=ele(clamp(c,ivec2(0),hi));float tr=ele(clamp(c+ivec2(1,0),ivec2(0),hi));float bl=ele(clamp(c+ivec2(0,1),ivec2(0),hi));float br=ele(clamp(c+ivec2(1,1),ivec2(0),hi));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}const float PI=3.141592653589793;\n#define PROJECTION_UBO\nlayout(std140) uniform ProjectionUBO {highp mat4 u_projection_matrix;highp mat4 u_projection_fallback_matrix;highp vec4 u_projection_tile_mercator_coords;highp vec4 u_projection_clipping_plane;highp float u_projection_transition;highp int u_projection_clip_antimeridian;};layout(std140) uniform FrameUBO {highp vec2 u_units_to_pixels;highp vec2 u_world_size;highp float u_camera_to_center_distance;highp float u_symbol_fade_change;highp float u_aspect_ratio;highp float u_device_pixel_ratio;highp vec2 u_viewport_size;highp vec2 u_pixel_extrude_scale;highp float u_pitch;};"),projectionMercator:tR("\nvoid clipAntimeridian() {}","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:tR("in highp float v_projection_tile_x;void clipAntimeridian() {if (u_projection_clip_antimeridian !=0 && (v_projection_tile_x < 0.0 || v_projection_tile_x >=8192.0)) {discard;}}","#define GLOBE_RADIUS 6371008.8\n#ifndef PROJECTION_UBO\nuniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;\n#endif\nout highp float v_projection_tile_x;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos\n);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float t=exp(PI-(mercator_pos_y*PI*2.0));return (2.0*t)/(t*t+1.0);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY);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;float spherical_x=mercator_pos.x*PI*2.0+PI;float t=exp(PI-(mercator_pos.y*PI*2.0));float t2=t*t;float denom=t2+1.0;float sin_sy=(t2-1.0)/denom;float cos_sy=(2.0*t)/denom;vec3 pos=vec3(sin(spherical_x)*cos_sy,sin_sy,cos(spherical_x)*cos_sy\n);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {v_projection_tile_x=posInTile.x;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) {v_projection_tile_x=posInTile.x;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:tR("uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:tR("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;layout(location=0) 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:tR("in vec3 v_data;flat in float v_visibility;\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define mediump float radius\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define highp vec4 stroke_color\n#pragma maplibre: define mediump float stroke_width\n#pragma maplibre: define lowp float stroke_opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize mediump float radius\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize highp vec4 stroke_color\n#pragma maplibre: initialize mediump float stroke_width\n#pragma maplibre: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform vec2 u_translate;layout(location=0) in ivec2 a_pos;out vec3 v_data;flat out float v_visibility;\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define mediump float radius\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define highp vec4 stroke_color\n#pragma maplibre: define mediump float stroke_width\n#pragma maplibre: define lowp float stroke_opacity\nvoid main(void) {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize mediump float radius\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize highp vec4 stroke_color\n#pragma maplibre: initialize mediump float stroke_width\n#pragma maplibre: initialize lowp float stroke_opacity\nivec2 pos_raw=a_pos+32768;vec2 extrude=vec2(pos_raw & 7)/7.0*2.0-1.0;vec2 circle_center=vec2(pos_raw >> 3)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {\n#ifdef GLOBE\nvec3 center_vector=projectToSphere(circle_center);\n#endif\nfloat angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {\n#ifdef GLOBE\nvec4 projected_center=interpolateProjection(circle_center,center_vector,ele);\n#else\nvec4 projected_center=projectTileWithElevation(circle_center,ele);\n#endif\ncorner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}\n#ifdef GLOBE\nvec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);\n#else\ngl_Position=projectTileWithElevation(corner_position,ele);\n#endif\n} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:tR(Qk,"layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:tR("uniform highp float u_intensity;in vec2 v_extrude;\n#pragma maplibre: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma maplibre: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;layout(location=0) in ivec2 a_pos;out vec2 v_extrude;\n#pragma maplibre: define highp float weight\n#pragma maplibre: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma maplibre: initialize highp float weight\n#pragma maplibre: initialize mediump float radius\nivec2 pos_raw=a_pos+32768;vec2 unscaled_extrude=vec2(pos_raw & 7)/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=vec2(pos_raw >> 3);\n#ifdef GLOBE\nvec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);\n#else\ngl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));\n#endif\n}"),heatmapTexture:tR("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world_size,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:tR("flat in float v_placed;flat 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;}}","layout(location=0) in vec2 a_anchor_pos;layout(location=1) in vec2 a_placed;layout(location=2) in vec2 a_box_real;flat out float v_placed;flat 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:tR("flat in float v_radius;in vec2 v_extrude;flat 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;}","layout(location=0) in vec2 a_pos;layout(location=1) in float a_radius;layout(location=2) in vec2 a_flags;flat out float v_radius;out vec2 v_extrude;flat 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:tR("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;uniform vec4 u_unpack;uniform sampler2D u_elevation_stops;uniform sampler2D u_color_stops;uniform int u_color_ramp_size;uniform float u_opacity;in vec2 v_pos;float getElevation(vec2 coord) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}float getElevationStop(int stop) {vec4 data=texelFetch(u_elevation_stops,ivec2(stop,0),0)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {float el=getElevation(v_pos);int r=(u_color_ramp_size-1);int l=0;float el_l=getElevationStop(l);float el_r=getElevationStop(r);while(r-l > 1){int m=(r+l)/2;float el_m=getElevationStop(m);if(el < el_m){r=m;el_r=el_m;}else\n{l=m;el_l=el_m;}}float x=(float(l)+(el-el_l)/(el_r-el_l)+0.5)/float(u_color_ramp_size);fragColor=u_opacity*texture(u_color_stops,vec2(x,0));\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_dimension;layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=2.0/u_dimension;float scale=(u_dimension.x-4.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:tR("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);}","layout(location=0) 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:tR(Qk,"layout(location=0) in vec2 a_pos;void main() {\n#ifdef GLOBE\ngl_Position=projectTileFor3D(a_pos,0.0);\n#else\ngl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);\n#endif\n}"),fill:tR("#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float opacity\nfragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float opacity\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}gl_Position=projectTile(a_pos+u_fill_translate,a_pos);}"),fillOutline:tR("in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define highp vec4 outline_color\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 outline_color\n#pragma maplibre: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define highp vec4 outline_color\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 outline_color\n#pragma maplibre: initialize lowp float opacity\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world_size;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:tR("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;uniform bool u_sdf_pattern;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\nvoid main() {\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);if (u_sdf_pattern) {highp float sdf_edge=(256.0-64.0)/256.0;highp float sdf_gamma_a=max(fwidth(color1.a)*0.5,1.0/255.0/16.0);highp float sdf_gamma_b=max(fwidth(color2.a)*0.5,1.0/255.0/16.0);float sdf_alpha_a=smoothstep(sdf_edge-sdf_gamma_a,sdf_edge+sdf_gamma_a,color1.a);float sdf_alpha_b=smoothstep(sdf_edge-sdf_gamma_b,sdf_edge+sdf_gamma_b,color2.a);fragColor=mix(color*sdf_alpha_a,color*sdf_alpha_b,u_fade)*alpha*opacity;} else {fragColor=mix(color1,color2,u_fade)*alpha*opacity;}\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}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_size;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:tR("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform bool u_sdf_pattern;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\nvoid main() {\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);if (u_sdf_pattern) {highp float sdf_edge=(256.0-64.0)/256.0;highp float sdf_gamma_a=max(fwidth(color1.a)*0.5,1.0/255.0/16.0);highp float sdf_gamma_b=max(fwidth(color2.a)*0.5,1.0/255.0/16.0);float sdf_alpha_a=smoothstep(sdf_edge-sdf_gamma_a,sdf_edge+sdf_gamma_a,color1.a);float sdf_alpha_b=smoothstep(sdf_edge-sdf_gamma_b,sdf_edge+sdf_gamma_b,color2.a);fragColor=mix(color*sdf_alpha_a,color*sdf_alpha_b,u_fade)*opacity;} else {fragColor=mix(color1,color2,u_fade)*opacity;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}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:tR("in vec4 v_color;void main() {fragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;layout(location=1) in ivec4 a_normal_ed;\n#ifdef TERRAIN3D\nlayout(location=2) in vec2 a_centroid;\n#endif\nout vec4 v_color;\n#pragma maplibre: define highp float base\n#pragma maplibre: define highp float height\n#pragma maplibre: define highp vec4 color\nvoid main() {\n#pragma maplibre: initialize highp float base\n#pragma maplibre: initialize highp float height\n#pragma maplibre: initialize highp vec4 color\nvec3 normal=vec3(a_normal_ed.xyz);\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=float(a_normal_ed.x & 1);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nfloat colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);\n#ifdef GLOBE\nmat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);\n#endif\ndirectional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:tR("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;\n#pragma maplibre: define lowp float base\n#pragma maplibre: define lowp float height\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float base\n#pragma maplibre: initialize lowp float height\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;layout(location=0) in vec2 a_pos;layout(location=1) in ivec4 a_normal_ed;\n#ifdef TERRAIN3D\nlayout(location=2) in vec2 a_centroid;\n#endif\n#ifdef GLOBE\nout vec3 v_sphere_pos;\n#endif\nout vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;\n#pragma maplibre: define lowp float base\n#pragma maplibre: define lowp float height\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float base\n#pragma maplibre: initialize lowp float height\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=vec3(a_normal_ed.xyz);float edgedistance=float(a_normal_ed.w);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=float(a_normal_ed.x & 1);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nvec2 pos=a_normal_ed.x==1 && a_normal_ed.y==0 && a_normal_ed.z==16384\n? a_pos\n: vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),hillshadePrepare:tR("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(ivec2 texel) {vec4 data=texelFetch(u_image,texel,0)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {ivec2 pos=ivec2(gl_FragCoord.xy)+ivec2(1);float tileSize=u_dimension.x-4.0;float a=getElevation(pos+ivec2(-1,-1));float b=getElevation(pos+ivec2(0,-1));float c=getElevation(pos+ivec2(1,-1));float d=getElevation(pos+ivec2(-1,0));float e=getElevation(pos);float f=getElevation(pos+ivec2(1,0));float g=getElevation(pos+ivec2(-1,1));float h=getElevation(pos+ivec2(0,1));float i=getElevation(pos+ivec2(1,1));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;layout(location=0) in vec2 a_pos;layout(location=1) 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:tR("uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];\n#define PI 3.141592653589793\n#define STANDARD 0\n#define COMBINED 1\n#define IGOR 2\n#define MULTIDIRECTIONAL 3\n#define BASIC 4\nfloat get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else\n{fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else\n{fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec2 size=vec2(textureSize(u_image,0));vec2 texturePos=(v_pos*(size-2.0)+1.0)/size;vec4 pixel=texture(u_image,texturePos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;layout(location=0) 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:tR("flat in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\nclipAntimeridian();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);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nlayout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;out vec2 v_normal;flat out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float gapwidth\n#pragma maplibre: define lowp float offset\n#pragma maplibre: define mediump float width\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float gapwidth\n#pragma maplibre: initialize lowp float offset\n#pragma maplibre: initialize mediump float width\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);v_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*2.0;vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:tR("uniform sampler2D u_image;flat in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\nclipAntimeridian();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);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nlayout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;layout(location=2) in float a_uv_x;layout(location=3) in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform float u_image_height;out vec2 v_normal;flat out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float gapwidth\n#pragma maplibre: define lowp float offset\n#pragma maplibre: define mediump float width\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float gapwidth\n#pragma maplibre: initialize lowp float offset\n#pragma maplibre: initialize mediump float width\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);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=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:tR("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;flat in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;flat in float v_width;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\nclipAntimeridian();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;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nlayout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;out vec2 v_normal;flat out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;flat out float v_width;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define lowp float offset\n#pragma maplibre: define mediump float gapwidth\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize lowp float offset\n#pragma maplibre: initialize mediump float gapwidth\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);float a_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*LINE_DISTANCE_SCALE;vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:tR("uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;flat in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define mediump vec4 dasharray_from\n#pragma maplibre: define mediump vec4 dasharray_to\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 dasharray_from\n#pragma maplibre: initialize mediump vec4 dasharray_to\nclipAntimeridian();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);float sdfgamma=(u_lineatlas_width/256.0/u_device_pixel_ratio)/min(dasharray_from.w,dasharray_to.w);alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nlayout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;flat out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float gapwidth\n#pragma maplibre: define lowp float offset\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define mediump vec4 dasharray_from\n#pragma maplibre: define mediump vec4 dasharray_to\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float gapwidth\n#pragma maplibre: initialize lowp float offset\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 dasharray_from\n#pragma maplibre: initialize mediump vec4 dasharray_to\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);float a_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*LINE_DISTANCE_SCALE;vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),lineGradientSDF:tR("uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;flat in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define mediump vec4 dasharray_from\n#pragma maplibre: define mediump vec4 dasharray_to\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 dasharray_from\n#pragma maplibre: initialize mediump vec4 dasharray_to\nclipAntimeridian();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);float sdfdist_a=texture(u_image_dash,v_tex_a).a;float sdfdist_b=texture(u_image_dash,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0)/min(dasharray_from.w,dasharray_to.w);float dash_alpha=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*dash_alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nlayout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;layout(location=2) in float a_uv_x;layout(location=3) in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform float u_image_height;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;flat out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float gapwidth\n#pragma maplibre: define lowp float offset\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define mediump vec4 dasharray_from\n#pragma maplibre: define mediump vec4 dasharray_to\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float gapwidth\n#pragma maplibre: initialize lowp float offset\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 dasharray_from\n#pragma maplibre: initialize mediump vec4 dasharray_to\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);float a_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*LINE_DISTANCE_SCALE;float texel_height=1.0/u_image_height;float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),layerOpacity:tR("uniform sampler2D u_image;uniform float u_opacity;in vec2 v_pos;void main() {fragColor=texture(u_image,v_pos)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos.x*2.0-1.0,1.0-a_pos.y*2.0,0.0,1.0);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),raster:tR("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec3 v_pos0;in vec3 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.xy/v_pos0.z);vec4 color1=texture(u_image1,v_pos1.xy/v_pos1.z);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec3 u_image_warp;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;layout(location=0) in vec2 a_pos;out vec3 v_pos0;out vec3 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 topLeft=u_coords_top.xy;vec2 topRight=u_coords_top.zw;vec2 bottomLeft=u_coords_bottom.xy;vec2 bottomRight=u_coords_bottom.zw;vec2 bilinearPos=mix(mix(topLeft,topRight,fractionalPos.x),mix(bottomLeft,bottomRight,fractionalPos.x),fractionalPos.y);float denominator=dot(u_image_warp.xy,fractionalPos)+1.0;vec2 acrossTop=topRight-topLeft+u_image_warp.x*topRight;vec2 downLeft=bottomLeft-topLeft+u_image_warp.y*bottomLeft;vec2 projectivePos=(acrossTop*fractionalPos.x+downLeft*fractionalPos.y+topLeft)/denominator;vec2 position=mix(projectivePos,bilinearPos,u_image_warp.z);gl_Position=projectTile(position,position);vec2 texturePos=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {texturePos.y=0.0;}if (a_pos.y > 32766.5) {texturePos.y=1.0;}\n#endif\nfloat perspectiveRatio=mix(1.0/denominator,1.0,u_image_warp.z);v_pos0=vec3(texturePos*perspectiveRatio,perspectiveRatio);vec2 parentPos=(texturePos*u_scale_parent)+u_tl_parent;v_pos1=vec3(parentPos*perspectiveRatio,perspectiveRatio);}"),symbolIcon:tR("uniform sampler2D u_texture;in vec2 v_tex;flat in float v_total_opacity;void main() {fragColor=texture(u_texture,v_tex)*v_total_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","layout(location=0) in vec4 a_pos_offset;layout(location=1) in uvec4 a_data;layout(location=2) in vec4 a_pixeloffset;layout(location=3) in vec3 a_projected_pos;layout(location=4) in uint a_fade_opacity;layout(location=5) in float a_height_offset;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 bool u_rotate_symbol;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;uniform bool u_is_offset;uniform bool u_height_anchor_ground;out vec2 v_tex;flat out float v_total_opacity;\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=vec2(a_data.xy);vec2 a_size=vec2(a_data.zw);float a_size_min=float(a_data.z >> 1u);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=a_height_offset+(u_height_anchor_ground ? get_elevation(a_pos) : 0.0);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);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_symbol_fade_change :-u_symbol_fade_change;float visibility=calculate_visibility(projectedPoint);v_total_opacity=opacity*max(0.0,min(visibility,fade_opacity[0]+fade_change));if (v_total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);if (!u_is_offset) {size*=perspective_ratio;}float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;}"),symbolSDF:tR("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform bool u_is_plain;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1;\n#pragma maplibre: define highp vec4 fill_color\n#pragma maplibre: define highp vec4 halo_color\n#pragma maplibre: define lowp float halo_width\n#pragma maplibre: define lowp float halo_blur\nvoid main() {\n#pragma maplibre: initialize highp vec4 fill_color\n#pragma maplibre: initialize highp vec4 halo_color\n#pragma maplibre: initialize lowp float halo_width\n#pragma maplibre: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float total_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;lowp float dist=texture(u_texture,tex).a;lowp vec4 color_alpha_out_text,color_alpha_out_halo;if (u_is_plain){highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);color_alpha_out_text=total_opacity*alpha*fill_color;}if (u_is_halo) {float gamma_halo=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);float inner_edge_halo=inner_edge+gamma_halo*gamma_scale;highp float gamma_scaled_halo=gamma_halo*gamma_scale;highp float alpha_halo=smoothstep(inner_edge_halo-gamma_scaled_halo,inner_edge_halo+gamma_scaled_halo,dist);highp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha_halo= min(smoothstep(halo_edge-gamma_scaled_halo,halo_edge+gamma_scaled_halo,dist),1.0-alpha_halo);color_alpha_out_halo=total_opacity*alpha_halo*halo_color;}if (u_is_plain && u_is_halo) {fragColor=color_alpha_out_text+(1.-color_alpha_out_text.a)*color_alpha_out_halo;} else if (u_is_halo){fragColor=color_alpha_out_halo;} else {fragColor=color_alpha_out_text;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","layout(location=0) in vec4 a_pos_offset;layout(location=1) in uvec4 a_data;layout(location=2) in vec4 a_pixeloffset;layout(location=3) in vec3 a_projected_pos;layout(location=4) in uint a_fade_opacity;layout(location=5) in float a_height_offset;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 bool u_rotate_symbol;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;uniform bool u_is_offset;uniform bool u_height_anchor_ground;out vec2 v_data0;out vec3 v_data1;\n#pragma maplibre: define highp vec4 fill_color\n#pragma maplibre: define highp vec4 halo_color\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define lowp float halo_width\n#pragma maplibre: define lowp float halo_blur\nvoid main() {\n#pragma maplibre: initialize highp vec4 fill_color\n#pragma maplibre: initialize highp vec4 halo_color\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize lowp float halo_width\n#pragma maplibre: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=vec2(a_data.xy);vec2 a_size=vec2(a_data.zw);float a_size_min=float(a_data.z >> 1u);vec2 a_pxoffset=a_pixeloffset.xy/16.0;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=a_height_offset+(u_height_anchor_ground ? get_elevation(a_pos) : 0.0);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);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_symbol_fade_change :-u_symbol_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));float total_opacity=opacity*interpolated_fade_opacity;if (total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);if (!u_is_offset) {size*=perspective_ratio;}float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,total_opacity);}"),symbolTextAndIcon:tR("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform bool u_is_text;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;in vec4 v_data0;in vec3 v_data1;flat in float v_is_sdf;\n#pragma maplibre: define highp vec4 fill_color\n#pragma maplibre: define highp vec4 halo_color\n#pragma maplibre: define lowp float halo_width\n#pragma maplibre: define lowp float halo_blur\nvoid main() {\n#pragma maplibre: initialize highp vec4 fill_color\n#pragma maplibre: initialize highp vec4 halo_color\n#pragma maplibre: initialize lowp float halo_width\n#pragma maplibre: initialize lowp float halo_blur\nfloat total_opacity=v_data1[2];if (v_is_sdf==ICON) {vec2 tex_icon=v_data0.zw;fragColor=texture(u_texture_icon,tex_icon)*total_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;lowp float dist=texture(u_texture,tex).a;lowp vec4 color_alpha_out,color_alpha_out_halo;if (u_is_text) {highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);color_alpha_out=fill_color*(alpha*total_opacity);}if (u_is_halo) {highp float gamma_halo=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);lowp float buff_halo=(6.0-halo_width/fontScale)/SDF_PX;highp float gamma_scaled_halo=gamma_halo*gamma_scale;highp float alpha_halo=smoothstep(buff_halo-gamma_scaled_halo,buff_halo+gamma_scaled_halo,dist);color_alpha_out_halo=halo_color*(alpha_halo*total_opacity);}if (u_is_text && u_is_halo) {fragColor=color_alpha_out+(1.-color_alpha_out.a)*color_alpha_out_halo;} else if (u_is_halo) {fragColor=color_alpha_out_halo;} else {fragColor=color_alpha_out;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","layout(location=0) in vec4 a_pos_offset;layout(location=1) in uvec4 a_data;layout(location=2) in vec3 a_projected_pos;layout(location=3) in uint a_fade_opacity;layout(location=4) in float a_height_offset;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_rotate_symbol;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;uniform bool u_is_offset;uniform bool u_height_anchor_ground;out vec4 v_data0;out vec3 v_data1;flat out float v_is_sdf;\n#pragma maplibre: define highp vec4 fill_color\n#pragma maplibre: define highp vec4 halo_color\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define lowp float halo_width\n#pragma maplibre: define lowp float halo_blur\nvoid main() {\n#pragma maplibre: initialize highp vec4 fill_color\n#pragma maplibre: initialize highp vec4 halo_color\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize lowp float halo_width\n#pragma maplibre: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=vec2(a_data.xy);vec2 a_size=vec2(a_data.zw);float a_size_min=float(a_data.z >> 1u);float is_sdf=float(a_data.z & 1u);float ele=a_height_offset+(u_height_anchor_ground ? get_elevation(a_pos) : 0.0);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);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_symbol_fade_change :-u_symbol_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));float total_opacity=opacity*interpolated_fade_opacity;if (total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);if (!u_is_offset) {size*=perspective_ratio;}float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec3(gamma_scale,size,total_opacity);v_is_sdf=is_sdf;}"),terrain:tR("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 && u_fog_ground_blend_opacity > 0.0 && 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;}}","layout(location=0) 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,ele-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:tR("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);}","layout(location=0) 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;}"),atmosphere:tR("#ifdef GL_ES\nprecision highp float;\n#endif\nin vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758\n);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}","layout(location=0) 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:tR("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;uniform vec3 u_globe_position;uniform float u_globe_radius;in vec3 v_view_direction;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 (u_sky_blend > 0.0) {vec3 ray=normalize(v_view_direction);float globe_distance=length(u_globe_position);float angle_to_globe_center=acos(clamp(dot(ray,u_globe_position)/globe_distance,-1.0,1.0));float horizon_angle=asin(min(u_globe_radius/globe_distance,1.0));blend=mix(blend,(angle_to_globe_center-horizon_angle)*u_camera_to_center_distance*u_device_pixel_ratio,u_sky_blend);}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);}","layout(location=0) in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 v_view_direction;void main() {v_view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,1.0,1.0);}")};function tR(e,t){let r=/#pragma maplibre: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,i=t.match(/in ([\w]+) ([\w]+)/g),n=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),a=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),s=a?a.concat(n):n,o=i?i.length:0,l={};return e=e.replace(r,(e,t,r,i,n)=>(l[n]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nin ${r} ${i} ${n};\n#else\nuniform ${r} ${i} u_${n};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${n}\n ${r} ${i} ${n} = u_${n};\n#endif\n`)),t=t.replace(r,(e,t,r,i,n)=>{let a="float"===i?"vec2":"vec4",s=n.match(/color/)?"color":a;return l[n]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nlayout(location = ${o++}) in ${r} ${a} a_${n};\nout ${r} ${i} ${n};\n#else\nuniform ${r} ${i} u_${n};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = a_${n};\n#else\n ${r} ${i} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = unpack_mix_${s}(a_${n}, u_${n}_t);\n#else\n ${r} ${i} ${n} = u_${n};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nlayout(location = ${o++}) in ${r} ${a} a_${n};\n#else\nuniform ${r} ${i} u_${n};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${n}\n ${r} ${i} ${n} = a_${n};\n#else\n ${r} ${i} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${r} ${i} ${n} = unpack_mix_${s}(a_${n}, u_${n}_t);\n#else\n ${r} ${i} ${n} = u_${n};\n#endif\n`}),{fragmentSource:e,vertexSource:t,staticAttributes:i,staticUniforms:s}}const rR="#define PROJECTION_MERCATOR",iR="mercator";var nR=class{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return iR}get shaderDefine(){return rR}get shaderPreludeCode(){return eR.projectionMercator}get vertexShaderPreludeCode(){return eR.projectionMercator.vertexSource}get subdivisionGranularity(){return CE.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}destroy(){}getMeshFromTileID(e,t,r,i,n){if(this._cachedMesh)return this._cachedMesh;let a=new Ox;a.emplaceBack(0,0),a.emplaceBack(_p,0),a.emplaceBack(0,_p),a.emplaceBack(_p,_p);let s=e.createVertexBuffer(a,yM.members),o=ab.simpleSegment(0,0,4,2),l=new tb;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3);let u=e.createIndexBuffer(l);return this._cachedMesh=new gM(s,u,o),this._cachedMesh}recalculate(){}hasTransition(){return!1}},aR=class e{constructor(e=0,t=0,r=0,i=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(r)||r<0||isNaN(i)||i<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=r,this.right=i}interpolate(e,t,r){return null!=t.top&&null!=e.top&&(this.top=ng.number(e.top,t.top,r)),null!=t.bottom&&null!=e.bottom&&(this.bottom=ng.number(e.bottom,t.bottom,r)),null!=t.left&&null!=e.left&&(this.left=ng.number(e.left,t.left,r)),null!=t.right&&null!=e.right&&(this.right=ng.number(e.right,t.right,r)),this}getCenter(e,t){return new Sd($p((this.left+e-this.right)/2,0,e),$p((this.top+t-this.bottom)/2,0,t))}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new e(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}};function sR(e,t){if(!e.renderWorldCopies||e.lngRange)return;let r=t.lng-e.center.lng;t.lng+=r>180?-360:r<-180?360:0}function oR(e){return Math.max(0,Math.floor(e))}var lR=class{constructor(e,t){this.applyConstrain=(e,t)=>null===this._constrainOverride?this._callbacks.defaultConstrain(e,t):this._constrainOverride(e,t),this._callbacks=e,this._tileSize=512,this._renderWorldCopies=void 0===t?.renderWorldCopies||!!t?.renderWorldCopies,this._minZoom=t?.minZoom||0,this._maxZoom=t?.maxZoom||22,this._minPitch=null==t?.minPitch?0:t?.minPitch,this._maxPitch=null==t?.maxPitch?60:t?.maxPitch,this._constrainOverride=t?.constrainOverride??null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new nS(0,0),this._elevation=0,this._zoom=0,this._tileZoom=oR(this._zoom),this._scale=Gp(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new aR,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(e,t,r){this._constrainOverride=e.constrainOverride,this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=oR(this._zoom),this._scale=Gp(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 aR(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,t&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){if(this._minZoom===e)return;this._minZoom=e;let t=this._unmodified;this.setZoom(this.applyConstrain(this._center,this.zoom).zoom),this._unmodified=t}get maxZoom(){return this._maxZoom}setMaxZoom(e){if(this._maxZoom===e)return;this._maxZoom=e;let t=this._unmodified;this.setZoom(this.applyConstrain(this._center,this.zoom).zoom),this._unmodified=t}get minPitch(){return this._minPitch}setMinPitch(e){if(this._minPitch===e)return;this._minPitch=e;let t=this._unmodified;this.setPitch(Math.max(this.pitch,e)),this._unmodified=t}get maxPitch(){return this._maxPitch}setMaxPitch(e){if(this._maxPitch===e)return;this._maxPitch=e;let t=this._unmodified;this.setPitch(Math.min(this.pitch,e)),this._unmodified=t}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}get constrainOverride(){return this._constrainOverride}setConstrainOverride(e){void 0===e&&(e=null),this._constrainOverride!==e&&(this._constrainOverride=e,this.constrainInternal(),this._calcMatrices())}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new Sd(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){let t=Np(e,-180,180)*Math.PI/180;this._bearingInRadians!==t&&(this._unmodified=!1,this._bearingInRadians=t,this._calcMatrices(),this._rotationMatrix=MC(),function(e,t,r){var i=t[0],n=t[1],a=t[2],s=t[3],o=Math.sin(r),l=Math.cos(r);e[0]=i*l+a*o,e[1]=n*l+s*o,e[2]=i*-o+a*l,e[3]=n*-o+s*l}(this._rotationMatrix,this._rotationMatrix,-this._bearingInRadians))}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){let t=$p(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==t&&(this._unmodified=!1,this._pitchInRadians=t,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 uf(this._fovInRadians)}setFov(e){e=$p(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=lf(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){let t=this.applyConstrain(this._center,e).zoom;this._zoom!==t&&(this._unmodified=!1,this._zoom=t,this._tileZoom=Math.max(0,Math.floor(t)),this._scale=Gp(t),this.constrainInternal(),this._calcMatrices())}get center(){return this._center}setCenter(e){(e.lat!==this._center.lat||e.lng!==this._center.lng)&&(this._unmodified=!1,this._center=e,this.constrainInternal(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this.constrainInternal(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,t){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=t,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,r){this._unmodified=!1,this._edgeInsets.interpolate(e,t,r),this.constrainInternal(),this._calcMatrices()}resize(e,t,r=!0){this._width=e,this._height=t,r&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){return 2!==this._latRange?.length||2!==this._lngRange?.length?null:new JF([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]])}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-pf,pf])}getCameraQueryGeometry(e,t){if(1===t.length)return[t[0],e];{let{minX:r,minY:i,maxX:n,maxY:a}=WE.fromPoints(t).extend(e);return[new Sd(r,i),new Sd(n,i),new Sd(n,a),new Sd(r,a),new Sd(r,i)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;let e=this._unmodified,{center:t,zoom:r}=this.applyConstrain(this.center,this.zoom);this.setCenter(t),this.setZoom(r),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._pixelPerMeter=uS(1,this.center.lat)*this.worldSize,!this._width||!this._height)return;this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=kd(new Float64Array(16));Bd(e,e,[this._width/2,-this._height/2,1]),zd(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=kd(new Float64Array(16)),Bd(e,e,[1,-1,1]),zd(e,e,[-1,-1,0]),Bd(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e;let t=this.fovInRadians/2;this._cameraToCenterDistance=.5/Math.tan(t)*this._height,this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,t,r,i){let n,a,s=void 0===r?this.bearing:r,o=i=void 0===i?this.pitch:i,{distanceToCenter:l,clampedElevation:u}=this._distanceToCenterFromAltElevationPitch(t,this.elevation,o),{x:c,y:h}=bS(o,s),d=pS.fromLngLat(e,t),p=dS(1,d.y),f=0;do{if(f+=1,f>10)break;a=l/p;let e=c*a,t=h*a;n=new pS(d.x+e,d.y+t),p=1/n.meterInMercatorCoordinateUnits()}while(Math.abs(l-a*p)>1e-12);return{center:n.toLngLat(),elevation:u,zoom:Zp(this.height/2/Math.tan(this.fovInRadians/2)/a/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e===0)return;let t=1/this.worldSize,r=uS(1,this.center.lat)*this.worldSize,i=pS.fromLngLat(this.center,this.elevation),n=i.x/t,a=i.y/t,s=i.z/t,o=this.pitch,l=this.bearing,{x:u,y:c,z:h}=bS(o,l),d=this.cameraToCenterDistance,p=n+d*-u,f=a+d*-c,m=s+d*h,{distanceToCenter:g,clampedElevation:y}=this._distanceToCenterFromAltElevationPitch(m/r,e,o),_=g*r,v=new pS((p+u*_)*t,(f+c*_)*t,0).toLngLat(),x=uS(1,v.lat),b=Zp(this.height/2/Math.tan(this.fovInRadians/2)/g/x/this.tileSize);this._elevation=y,this._center=v,this.setZoom(b)}_distanceToCenterFromAltElevationPitch(e,t,r){let i,n=-Math.cos(lf(r)),a=e-t,s=t;return n*a>=0||Math.abs(n)<.1?(i=1e4,s=e+i*n):i=-a/n,{distanceToCenter:i,clampedElevation:s}}getCameraPoint(){let e=this.pitchInRadians,t=Math.tan(e)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new Sd(t*Math.sin(this.rollInRadians),t*Math.cos(this.rollInRadians)))}getMercatorTileCoordinates(e){if(!e)return[0,0,1,1];let t=e.canonical.z>=0?1<<e.canonical.z:2**e.canonical.z;return[e.canonical.x/t,e.canonical.y/t,1/t/_p,1/t/_p]}},uR=class{distanceToTile2d(e,t,r,i){let n=i,a=n.distanceX([e,t]),s=n.distanceY([e,t]);return Math.hypot(a,s)}getWrap(e,t,r){return r}getTileBoundingVolume(e,t,r,i){let n=Math.min(0,r),a=Math.max(0,r);if(i?.terrain){let r=new PA(e.z,t,e.z,e.x,e.y),s=i.terrain.getMinMaxElevation(r);n=s.minElevation??n,a=s.maxElevation??a}let s=1<<e.z;return new MM([t+e.x/s,e.y/s,n],[t+(e.x+1)/s,(e.y+1)/s,a])}allowVariableZoom(e,t){let r=$p(78.5-e.fov*(Math.abs(Math.cos(e.rollInRadians))*e.height+Math.abs(Math.sin(e.rollInRadians))*e.width)/e.height/2,0,60);return!!t.terrain||e.pitch>r}allowWorldCopies(){return!0}prepareNextFrame(){}};const cR=ex([{name:"a_pos3d",type:"Int16",components:3}]);var hR=class extends zf{constructor(e){super(),this._lastTilesetChange=OC(),this.tileManager=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null,this.releaseAllRTT()}getSource(){return this.tileManager._source}update(e,t){this.tileManager.update(e,t),this._renderableTilesKeys=[];let r={},i=!1;for(let n of $M(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:t,calculateTileZoom:this.tileManager._source.calculateTileZoom}))r[n.key]=!0,this._renderableTilesKeys.push(n.key),this._tiles[n.key]||(n.terrainRttPosMatrix32f=new Float32Array(16),Vd(n.terrainRttPosMatrix32f,0,_p,_p,0,0,1),this._tiles[n.key]=new IM(n,this.tileSize),this._lastTilesetChange=OC(),i=!0);for(let n in this._tiles)r[n]||(this._tiles[n].releaseRTT(this.tileManager.map.painter),delete this._tiles[n],i=!0);return i}releaseRTT(e){for(let t in this._tiles){let r=this._tiles[t];(r.tileID.equals(e)||r.tileID.isChildOf(e)||e.isChildOf(r.tileID))&&r.releaseRTT(this.tileManager.map.painter)}}releaseAllRTT(){for(let e in this._tiles)this._tiles[e].releaseRTT(this.tileManager.map.painter)}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 t={};for(let r of this._renderableTilesKeys){let i=this._tiles[r].tileID,n=e.clone(),a=Ep();if(i.canonical.equals(e.canonical))Vd(a,0,_p,_p,0,0,1);else if(i.canonical.isChildOf(e.canonical)){let t=i.canonical.z-e.canonical.z,r=i.canonical.x-(i.canonical.x>>t<<t),n=i.canonical.y-(i.canonical.y>>t<<t),s=_p>>t;Vd(a,0,s,s,0,0,1),zd(a,a,[-r*s,-n*s,0])}else{if(!e.canonical.isChildOf(i.canonical))continue;{let t=e.canonical.z-i.canonical.z,r=e.canonical.x-(e.canonical.x>>t<<t),n=e.canonical.y-(e.canonical.y>>t<<t),s=_p>>t;Vd(a,0,_p,_p,0,0,1),zd(a,a,[r*s,n*s,0]),Bd(a,a,[1/2**t,1/2**t,0])}}n.terrainRttPosMatrix32f=new Float32Array(a),t[r]=n}return t}_getTerrainCoordsForTileRanges(e,t){let r={};for(let i of this._renderableTilesKeys){let n=this._tiles[i].tileID;if(!this._isWithinTileRanges(n,t))continue;let a=e.clone(),s=Ep();if(n.canonical.z===e.canonical.z){let t=e.canonical.x-n.canonical.x+e.wrap*(1<<e.canonical.z),r=e.canonical.y-n.canonical.y;Vd(s,0,_p,_p,0,0,1),zd(s,s,[t*_p,r*_p,0])}else if(n.canonical.z>e.canonical.z){let t=n.canonical.z-e.canonical.z,r=n.canonical.x-(n.canonical.x>>t<<t)+e.wrap*(1<<n.canonical.z),i=n.canonical.y-(n.canonical.y>>t<<t),a=e.canonical.x-(n.canonical.x>>t),o=e.canonical.y-(n.canonical.y>>t),l=_p>>t;Vd(s,0,l,l,0,0,1),zd(s,s,[-r*l+a*_p,-i*l+o*_p,0])}else{let t=e.canonical.z-n.canonical.z,r=e.canonical.x-(e.canonical.x>>t<<t)+e.wrap*(1<<e.canonical.z),i=e.canonical.y-(e.canonical.y>>t<<t),a=(e.canonical.x>>t)-n.canonical.x,o=(e.canonical.y>>t)-n.canonical.y,l=_p<<t;Vd(s,0,l,l,0,0,1),zd(s,s,[r*_p+a*l,i*_p+o*l,0])}a.terrainRttPosMatrix32f=new Float32Array(s),r[i]=a}return r}getSourceTile(e,t){let r=this.tileManager._source,i=e.overscaledZ-this.deltaZoom;if(i>r.maxzoom&&(i=r.maxzoom),i<r.minzoom)return;this._sourceTileCache[e.key]||=e.scaledTo(i).key;let n=this.findTileInCaches(this._sourceTileCache[e.key]);if(!n?.dem&&t)for(;i>=r.minzoom&&!n?.dem;)n=this.findTileInCaches(e.scaledTo(i--).key);return n}findTileInCaches(e){let t=this.tileManager.getTileByID(e);return t||(t=this.tileManager._outOfViewCache.getByKey(e),t)}anyTilesAfterTime(e=OC()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,t){let r=t[e.canonical.z];return!!r&&(e.wrap>r.minWrap||e.wrap<r.maxWrap||e.canonical.x>=r.minTileXWrapped&&e.canonical.x<=r.maxTileXWrapped&&e.canonical.y>=r.minTileY&&e.canonical.y<=r.maxTileY)}};const dR=_p*(1-1e-12);var pR=class{constructor(e,t,r,i="auto"){this._meshCache={},this.painter=e,this.tileManager=new hR(t),this.options=r,this.exaggeration="number"==typeof r.exaggeration?r.exaggeration:1,this._terrainSkirtLength=i,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache=new Map,this._elevationSamplerCache=new Map}destroy(){this._fbo&&=(this._fbo.destroy(),null),this._fboDepthTexture&&=(this._fboDepthTexture.destroy(),null),this._emptyDemTexture&&=(this._emptyDemTexture.destroy(),null),this._emptyDepthTexture&&=(this._emptyDepthTexture.destroy(),null);for(let e in this._meshCache)this._meshCache[e].destroy();this._meshCache={},this.tileManager.destruct()}getDEMElevation(e,t,r,i=_p){let n=e.normalizeCoordinates(t,r,i);if(!n)return 0;let a=this.getElevationSampler(n.tileID);return a?a(n.x,n.y,i):0}getElevationForLngLatZoom(e,t){if(!DA(t,e.wrap()))return 0;let{tileID:r,mercatorX:i,mercatorY:n}=this._getOverscaledTileIDFromLngLatZoom(e,t);return this.getElevation(r,i%_p,n%_p,_p)}getElevationForLngLat(e,t){let r=this.getCoverageIndex();if(r){let t=pS.fromLngLat(e),i=mR(r,this.exaggeration,t.x,t.y);if(i.demLoaded)return i.elevation}let i=$M(t,{maxzoom:this.tileManager.maxzoom,minzoom:this.tileManager.minzoom,tileSize:512,terrain:this}),n=0;for(let a of i)a.canonical.z>n&&(n=Math.min(a.canonical.z,this.tileManager.maxzoom));return this.getElevationForLngLatZoom(e,n)}getElevation(e,t,r,i=_p){return this.getDEMElevation(e,t,r,i)*this.exaggeration}resetElevationCache(){this._elevationSamplerCache.clear(),this._coverageIndex=void 0}getCoverageIndex(){return void 0===this._coverageIndex&&(this._coverageIndex=this._buildCoverageIndex()),this._coverageIndex}_buildCoverageIndex(){let e=[],t=new Map,r=0,i=0;for(let n of this.tileManager.getRenderableTiles()){if(!n)continue;let{canonical:a,wrap:s}=n.tileID;e.includes(a.z)||e.push(a.z);let o=this.getElevationSampler(n.tileID);t.set(`${s}/${a.z}/${a.x}/${a.y}`,o);let{minElevation:l,maxElevation:u}=this.getMinMaxElevation(n.tileID);r=Math.min(r,l??0),i=Math.max(i,u??0)}return 0===t.size?null:(e.sort((e,t)=>t-e),{zooms:e,samplerPerTile:t,minElevation:r-10,maxElevation:i+10})}getElevationSampler(e){let t=e.key,r=this._elevationSamplerCache.get(t);if(r)return r;let i=this.tileManager.getSourceTile(e,!0),n=i?.dem;if(!i||!n)return null;let a=this._getDEMTileMatrix(e,i),s=a[0]*n.dim,o=a[5]*n.dim,l=a[12]*n.dim,u=a[13]*n.dim,c=(e,t,r)=>{let i=8192===r?1:_p/r;return n.sampleBilinear(e*i*s+l,t*i*o+u)};return this._elevationSamplerCache.set(t,c),c}_getDEMTileMatrix(e,t){let r=`${t.tileID.key}/${e.key}`,i=this._demMatrixCache.get(r);if(i)return i;let n=this.tileManager.getSource().maxzoom,a=e.canonical.z-t.tileID.canonical.z;e.overscaledZ>e.canonical.z&&(e.canonical.z>=n?a=e.canonical.z-n:Qp("cannot calculate elevation if elevation maxzoom > source.maxzoom"));let s=e.canonical.x-(e.canonical.x>>a<<a),o=e.canonical.y-(e.canonical.y>>a<<a),l=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}(new Float64Array(16),[1/(_p<<a),1/(_p<<a),0]);return zd(l,l,[s*_p,o*_p,0]),this._demMatrixCache.set(r,l),l}getTerrainData(e){if(!this._emptyDemTexture){let e=this.painter.context,t=new Dw({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new zw(e,t,e.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new zw(e,new Dw({width:1,height:1}),e.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=kd([])}let t=this.tileManager.getSourceTile(e,!0);if(t?.dem&&(!t.demTexture||t.needsTerrainPrepare)){let e=this.painter.context;t.demTexture||=this.painter.getTileTexture(t.dem.stride),t.demTexture?t.demTexture.update(t.dem.getPixels(),{premultiply:!1}):t.demTexture=new zw(e,t.dem.getPixels(),e.gl.RGBA,{premultiply:!1}),t.demTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),t.needsTerrainPrepare=!1}let r=t?this._getDEMTileMatrix(e,t):this._emptyDemMatrix;return{u_depth:2,u_terrain:3,u_terrain_dim:t?.dem?.dim||1,u_terrain_matrix:r,u_terrain_unpack:t?.dem?.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(t?.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:t}}getFramebuffer(){let e=this.painter,t=e.width/devicePixelRatio,r=e.height/devicePixelRatio;return this._fbo&&(this._fbo.width!==t||this._fbo.height!==r)&&(this._fbo.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture),this._fboDepthTexture||(this._fboDepthTexture=new zw(e.context,{width:t,height:r,data:null},e.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(e.context.gl.NEAREST,e.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=e.context.createFramebuffer(t,r,!0,!1),this._fbo.depthAttachment.set(e.context.createRenderbuffer(e.context.gl.DEPTH_COMPONENT16,t,r))),this._fbo.colorAttachment.set(this._fboDepthTexture.texture),this._fbo}depthAtPoint(e){let t=new Uint8Array(4),r=this.painter.context,i=r.gl;return r.bindFramebuffer.set(this.getFramebuffer().framebuffer),i.readPixels(e.x,this.painter.height/devicePixelRatio-e.y-1,1,1,i.RGBA,i.UNSIGNED_BYTE,t),r.bindFramebuffer.set(null),(t[0]/16777216+t[1]/65536+t[2]/256+t[3])/256}getTerrainMesh(e){let t=this.painter.style.projection?.transitionState>0,r=t&&0===e.canonical.y,i=t&&e.canonical.y===(1<<e.canonical.z)-1,n=`m_${r?"n":""}_${i?"s":""}`;if(this._meshCache[n])return this._meshCache[n];let a=this.painter.context,s=new $x,o=new tb,l=this.meshSize,u=_p/l,c=l*l;for(let d=0;d<=l;d++)for(let e=0;e<=l;e++)s.emplaceBack(e*u,d*u,0);for(let d=0;d<c;d+=l+1)for(let e=0;e<l;e++)o.emplaceBack(e+d,l+e+d+1,l+e+d+2),o.emplaceBack(e+d,l+e+d+2,e+d+1);"none"!==this._terrainSkirtLength&&this._buildSkirts(s,o,l,u,r,i);let h=new gM(a.createVertexBuffer(s,cR.members),a.createIndexBuffer(o),ab.simpleSegment(0,0,s.length,o.length));return this._meshCache[n]=h,h}getSkirtLength(e){return 2*Math.PI*iS/2**Math.max(e,0)/5}getMinTileElevationForLngLatZoom(e,t){if(!DA(t,e.wrap()))return 0;let{tileID:r}=this._getOverscaledTileIDFromLngLatZoom(e,t);return this.getMinMaxElevation(r).minElevation??0}getMinMaxElevation(e){let t=this.tileManager.getSourceTile(e,!0),r={minElevation:null,maxElevation:null};return t?.dem&&(r.minElevation=t.dem.min*this.exaggeration,r.maxElevation=t.dem.max*this.exaggeration),r}_getOverscaledTileIDFromLngLatZoom(e,t){let r=pS.fromLngLat(e.wrap()),i=(1<<t)*_p,n=r.x*i,a=r.y*i,s=Math.floor(n/_p),o=Math.floor(a/_p);return{tileID:new PA(t,0,t,s,o),mercatorX:n,mercatorY:a}}_buildSkirts(e,t,r,i,n,a){let s=e.length,o=s+(r+1),l=(r+1)*r,u=n?FE:0,c=+!n,h=a?ME:_p,d=+!a;for(let m=0;m<=r;m++)e.emplaceBack(m*i,u,c);for(let m=0;m<=r;m++)e.emplaceBack(m*i,h,d);for(let m=0;m<r;m++)t.emplaceBack(l+m,o+m,o+m+1),t.emplaceBack(l+m,o+m+1,l+m+1),t.emplaceBack(0+m,s+m+1,s+m),t.emplaceBack(0+m,0+m+1,s+m+1);let p=e.length,f=p+2*(r+1);for(let m of[0,1])for(let t=0;t<=r;t++)for(let r of[0,1])e.emplaceBack(m*_p,t*i,r);for(let m=0;m<2*r;m+=2)t.emplaceBack(p+m,p+m+1,p+m+3),t.emplaceBack(p+m,p+m+3,p+m+2),t.emplaceBack(f+m,f+m+3,f+m+1),t.emplaceBack(f+m,f+m+2,f+m+3)}};const fR={covered:!1,demLoaded:!1,elevation:0};function mR(e,t,r,i){if(i<0||i>=1)return fR;let n=Math.floor(r),a=r-n;for(let s of e.zooms){let r=1<<s,o=a*r,l=i*r,u=Math.floor(o),c=Math.floor(l),h=`${n}/${s}/${u}/${c}`;if(!e.samplerPerTile.has(h))continue;let d=e.samplerPerTile.get(h);return d?{covered:!0,demLoaded:!0,elevation:d(Math.min((o-u)*_p,dR),Math.min((l-c)*_p,dR),_p)*t}:{covered:!0,demLoaded:!1,elevation:0}}return fR}function gR(e,t){return e.covered&&t<=e.elevation+1e-6}function yR(e,t,r,i,n){for(let a=0;a<40&&i-r>n;a++){let n=(r+i)/2;t(e,n)?i=n:r=n}return{lo:r,hi:i}}var _R=class e{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,r){this._helper.interpolatePadding(e,t,r)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,r=!0){this._helper.resize(e,t,r)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e){}constructor(e){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(e,t)=>{t=$p(+t,this.minZoom,this.maxZoom);let r={center:new nS(e.lng,e.lat),zoom:t},i=this._helper._lngRange;!this._helper._renderWorldCopies&&null===i&&(i=[-179.9999999999,180-1e-10]);let n=this.tileSize*Gp(r.zoom),a=0,s=n,o=0,l=n,u=0,c=0,{x:h,y:d}=this.size;if(this._helper._latRange){let e=this._helper._latRange;a=lS(e[1])*n,s=lS(e[0])*n,s-a<d&&(u=d/(s-a))}i&&(o=Np(oS(i[0])*n,0,n),l=Np(oS(i[1])*n,0,n),l<o&&(l+=n),l-o<h&&(c=h/(l-o)));let p,f,{x:m,y:g}=gS(n,e),y=Math.max(c||0,u||0);if(y){let e=new Sd(c?(l+o)/2:m,u?(s+a)/2:g);return r.center=yS(n,e).wrap(),r.zoom+=Zp(y),r}if(this._helper._latRange){let e=d/2;g-e<a&&(f=a+e),g+e>s&&(f=s-e)}if(i){let e=(o+l)/2,t=m;this._helper._renderWorldCopies&&(t=Np(m,e-n/2,e+n/2));let r=h/2;t-r<o&&(p=o+r),t+r>l&&(p=l-r)}if(void 0!==p||void 0!==f){let e=new Sd(p??m,f??g);r.center=yS(n,e).wrap()}return r},this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new lR({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._coveringTilesDetailsProvider=new uR}clone(){let t=new e;return t.apply(this,!1),t}apply(e,t,r){this._helper.apply(e,t,r)}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 t=[new AA(0,e)];if(this._helper._renderWorldCopies){let r=this.screenPointToMercatorCoordinate(new Sd(0,0)),i=this.screenPointToMercatorCoordinate(new Sd(this._helper._width,0)),n=this.screenPointToMercatorCoordinate(new Sd(this._helper._width,this._helper._height)),a=this.screenPointToMercatorCoordinate(new Sd(0,this._helper._height)),s=Math.floor(Math.min(r.x,i.x,n.x,a.x)),o=Math.floor(Math.max(r.x,i.x,n.x,a.x));for(let l=s-1;l<=o+1;l++)0!==l&&t.push(new AA(l,e))}return t}getCameraFrustum(){return kM.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){let t=this.screenPointToLocation(this.centerPoint,e),r=e?e.getElevationForLngLat(t,this):0;this._helper.recalculateZoomAndCenter(r)}setLocationAtPoint(e,t,r=this.elevation){let i=r-this.elevation,n=this.screenPointToMercatorCoordinateAtZ(t,i),a=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,0),s=pS.fromLngLat(e),o=new pS(s.x-(n.x-a.x),s.y-(n.y-a.y));this.setCenter(o?.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,t){return t?this.coordinatePoint(pS.fromLngLat(e),t.getElevationForLngLat(e,this),this._pixelMatrix3D):this.coordinatePoint(pS.fromLngLat(e))}screenPointToLocation(e,t){return this.screenPointToMercatorCoordinate(e,t)?.toLngLat()}screenPointToLocationAtElevation(e,t){return this.screenPointToMercatorCoordinateAtZ(e,t-this.elevation)?.toLngLat()}screenPointToMercatorCoordinate(e,t){if(t){let r=this.screenTerrainPointToMercatorCoordinate(e,t);if(null!=r)return r}return this.screenPointToMercatorCoordinateAtZ(e)}screenTerrainPointToMercatorCoordinate(e,t){let r=t.getCoverageIndex();if(!r)return null;let{near:i,far:n}=this.getRaySegmentFromPixel(e),a=this.worldSize,s=n[0]-i[0],o=n[1]-i[1],l=n[2]-i[2],u={index:r,exaggeration:t.exaggeration,near:i,dx:s,dy:o,dz:l,worldSize:a},c=0,h=1;if(0===l){if(i[2]>r.maxElevation||i[2]<r.minElevation)return null}else{let e=(r.maxElevation-i[2])/l,t=(r.minElevation-i[2])/l;if(c=Math.max(c,Math.min(e,t)),h=Math.min(h,Math.max(e,t)),c>h)return null}let d=Math.hypot(s,o),p=$p(Math.ceil(d*(h-c)/4),1,512),f=0,m=!xR(u,0);for(let g=0;g<=p;g++){let e=c+(h-c)*g/p;if(m){if(xR(u,e)){let{lo:t,hi:r}=yR(u,xR,f,e,.001/d),n=vR(u,t),c=vR(u,r),h=i[2]+t*l-n.elevation,p=i[2]+r*l-c.elevation,m=n.covered&&h>p?$p(t+h*(r-t)/(h-p),t,r):r;return new pS((i[0]+m*s)/a,(i[1]+m*o)/a,vR(u,m).elevation)}}else m=!xR(u,e);f=e}return null}getRaySegmentFromPixel(e){let t=[e.x,e.y,0,1],r=[e.x,e.y,1,1];sp(t,t,this._pixelMatrixInverse),sp(r,r,this._pixelMatrixInverse);let i=t[3],n=r[3],a=this.elevation;return{near:[t[0]/i,t[1]/i,t[2]/i+a],far:[r[0]/n,r[1]/n,r[2]/n+a]}}screenPointToMercatorCoordinateAtZ(e,t){let r=t||0,{near:i,far:n}=this.getRaySegmentFromPixel(e),a=i[2]===n[2]?0:(r+this.elevation-i[2])/(n[2]-i[2]);return new pS(ng.number(i[0],n[0],a)/this.worldSize,ng.number(i[1],n[1],a)/this.worldSize,r)}coordinatePoint(e,t=0,r=this._pixelMatrix){let i=[e.x*this.worldSize,e.y*this.worldSize,t,1];return sp(i,i,r),new Sd(i[0]/i[3],i[1]/i[3])}getBounds(){let e=Math.max(0,this._helper._height/2-_S(this));return(new JF).extend(this.screenPointToLocation(new Sd(0,e))).extend(this.screenPointToLocation(new Sd(this._helper._width,e))).extend(this.screenPointToLocation(new Sd(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new Sd(0,this._helper._height)))}isPointOnMapSurface(e,t){return t?null!=this.screenTerrainPointToMercatorCoordinate(e,t):e.y>this.height/2-_S(this)}calculatePosMatrix(e,t=!1,r=!1){let i=e.key??IA(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),n=t?this._alignedPosMatrixCache:this._posMatrixCache;if(n.has(i)){let e=n.get(i);return r?e.f32:e.f64}let a=vS(e,this.worldSize);Ld(a,t?this._alignedProjMatrix:this._viewProjMatrix,a);let s={f64:a,f32:new Float32Array(a)};return n.set(i,s),r?s.f32:s.f64}calculateFogMatrix(e){let t=e.key,r=this._fogMatrixCacheF32;if(r.has(t))return r.get(t);let i=vS(e,this.worldSize);return Ld(i,this._fogMatrix,i),r.set(t,new Float32Array(i)),r.get(t)}calculateCenterFromCameraLngLatAlt(e,t,r,i){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,r,i)}calculateCameraOptionsFromTo(e,t,r,i){let n=pS.fromLngLat(e,t),a=pS.fromLngLat(r,i),s=a.x-n.x,o=a.y-n.y,l=a.z-n.z,u=Math.hypot(s,o,l);if(0===u)throw Error("Can't calculate camera options with same From and To");let c=Math.hypot(s,o),h=Zp(this.cameraToCenterDistance/u/this.tileSize),d=uf(Math.atan2(s,-o)),p=uf(Math.acos(c/u));return p=l<0?90-p:90+p,{center:a.toLngLat(),elevation:i,zoom:h,pitch:p,bearing:d}}_calculateNearFarZIfNeeded(e,t,r){if(!this._helper.autoCalculateNearFarZ)return;let i=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),n=e-i*this._helper._pixelPerMeter/Math.cos(t),a=i<0?n:e,s=Math.PI/2+this.pitchInRadians,o=lf(this.fov)*(Math.abs(Math.cos(lf(this.roll)))*this.height+Math.abs(Math.sin(lf(this.roll)))*this.width)/this.height*(.5+r.y/this.height),l=Math.sin(o)*a/Math.sin($p(Math.PI-s-o,.01,Math.PI-.01)),u=_S(this),c=Math.atan(u/this._helper.cameraToCenterDistance),h=lf(.75),d=c>h?2*c*(.5+r.y/(2*u)):h,p=Math.sin(d)*a/Math.sin($p(Math.PI-s-d,.01,Math.PI-.01)),f=Math.min(l,p);this._helper._farZ=1.01*(Math.cos(Math.PI/2-t)*f+a),this._helper._nearZ=this._helper._height/50}_calcMatrices(){let e,t=this.centerOffset,r=gS(this.worldSize,this.center),i=r.x,n=r.y,a=lf(Math.min(this.pitch,fS)),s=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(a));this._calculateNearFarZIfNeeded(s,a,t),e=new Float64Array(16),jd(e,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),function(e,t){e[0]=1/t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1/t[5],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=0,e[11]=1/t[14],e[12]=0,e[13]=0,e[14]=-1,e[15]=t[10]/t[14]}(this._invProjMatrix,e),e[8]=2*-t.x/this._helper._width,e[9]=2*t.y/this._helper._height,this._projectionMatrix=Md(e),Bd(e,e,[1,-1,1]),zd(e,e,[0,0,-this._helper.cameraToCenterDistance]),Nd(e,e,-this.rollInRadians),Od(e,e,this.pitchInRadians),Nd(e,e,-this.bearingInRadians),zd(e,e,[-i,-n,0]),this._mercatorMatrix=Bd([],e,[this.worldSize,this.worldSize,this.worldSize]),Bd(e,e,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=Ld(new Float64Array(16),this.clipSpaceToPixelsMatrix,e),zd(e,e,[0,0,-this.elevation]),this._viewProjMatrix=e,this._invViewProjMatrix=Rd([],e);let o=[0,0,-1,1];sp(o,o,this._invViewProjMatrix),this._cameraPosition=[o[0]/o[3],o[1]/o[3],o[2]/o[3]],this._fogMatrix=new Float64Array(16),jd(this._fogMatrix,this.fovInRadians,this.width/this.height,s,this._helper._farZ),this._fogMatrix[8]=2*-t.x/this.width,this._fogMatrix[9]=2*t.y/this.height,Bd(this._fogMatrix,this._fogMatrix,[1,-1,1]),zd(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),Nd(this._fogMatrix,this._fogMatrix,-this.rollInRadians),Od(this._fogMatrix,this._fogMatrix,this.pitchInRadians),Nd(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),zd(this._fogMatrix,this._fogMatrix,[-i,-n,0]),Bd(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),zd(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=Ld(new Float64Array(16),this.clipSpaceToPixelsMatrix,e);let l=this._helper._width%2/2,u=this._helper._height%2/2,c=Math.cos(this.bearingInRadians),h=Math.sin(-this.bearingInRadians),d=i-Math.round(i)+c*l+h*u,p=n-Math.round(n)+c*u+h*l,f=new Float64Array(e);if(zd(f,f,[d>.5?d-1:d,p>.5?p-1:p,0]),this._alignedProjMatrix=f,e=Rd(new Float64Array(16),this._pixelMatrix),!e)throw Error("failed to invert matrix");this._pixelMatrixInverse=e,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;let e=this.screenPointToMercatorCoordinate(new Sd(0,0)),t=[e.x*this.worldSize,e.y*this.worldSize,0,1];return sp(t,t,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this.cameraToCenterDistance/this.pixelsPerMeter+this.elevation}getCameraLngLat(){let e=uS(1,this.center.lat)*this.worldSize,t=this._helper.cameraToCenterDistance/e;return xS(this.center,this.elevation,this.pitch,this.bearing,t).toLngLat()}lngLatToCameraDepth(e,t){let r=pS.fromLngLat(e),i=[r.x*this.worldSize,r.y*this.worldSize,t,1];return sp(i,i,this._viewProjMatrix),i[2]/i[3]}getProjectionData(e){let t,{overscaledTileID:r,aligned:i,applyTerrainMatrix:n}=e,a=this._helper.getMercatorTileCoordinates(r),s=r?this.calculatePosMatrix(r,i,!0):null;return t=r?.terrainRttPosMatrix32f&&n?r.terrainRttPosMatrix32f:s||Dp(),{mainMatrix:t,tileMercatorCoords:a,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:t,clipAntimeridian:!1}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,t,r){return 1}transformLightDirection(e){return qd(e)}getRayDirectionFromPixel(e){throw Error("Not implemented.")}projectTileCoordinates(e,t,r,i){let n,a=this.calculatePosMatrix(r);null==i?(n=[e,t,0,1],wk(n,n,a)):(n=[e,t,i,1],sp(n,n,a));let s=n[3];return{point:new Sd(n[0]/s,n[1]/s),signedDistanceFromCamera:s,isOccluded:!1}}populateCache(e){for(let t of e)this.calculatePosMatrix(t)}getProjectionDataForCustomLayer(e=!0){let t=new PA(0,0,0,0,0),r=this.getProjectionData({overscaledTileID:t,applyGlobeMatrix:e}),i=vS(t,this.worldSize);Ld(i,this._viewProjMatrix,i);let n=[_p,_p,this.worldSize/this._helper.pixelsPerMeter],a=Ep();return Bd(a,i,n),{...r,tileMercatorCoords:[0,0,1,1],fallbackMatrix:a,mainMatrix:a}}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}};function vR(e,t){return mR(e.index,e.exaggeration,(e.near[0]+t*e.dx)/e.worldSize,(e.near[1]+t*e.dy)/e.worldSize)}function xR(e,t){return gR(vR(e,t),e.near[2]+t*e.dz)}function bR(){Qp("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function wR(e){if(e.useSlerp)if(e.k<1){let t=df(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),r=df(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),i=new Float64Array(4);up(i,t,r,e.k);let n=function(e){let t=new Float64Array(9);!function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],s=r+r,o=i+i,l=n+n,u=r*s,c=i*s,h=i*o,d=n*s,p=n*o,f=n*l,m=a*s,g=a*o,y=a*l;e[0]=1-h-f,e[3]=c-y,e[6]=d+g,e[1]=c+y,e[4]=1-u-f,e[7]=p-m,e[2]=d-g,e[5]=p+m,e[8]=1-u-h}(t,e);let r,i,n=uf(-Math.asin($p(t[2],-1,1)));return Math.hypot(t[5],t[8])<.001?(r=0,i=-uf(Math.atan2(t[3],t[4]))):(r=uf(0===t[5]&&0===t[8]?0:Math.atan2(t[5],t[8])),i=uf(0===t[1]&&0===t[0]?0:Math.atan2(t[1],t[0]))),{roll:r,pitch:n+90,bearing:i}}(i);e.tr.setRoll(n.roll),e.tr.setPitch(n.pitch),e.tr.setBearing(n.bearing)}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(ng.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(ng.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(ng.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k))}function ER(e,t,r,i,n){let a=n.padding,s=gS(n.worldSize,r.getNorthWest()),o=gS(n.worldSize,r.getNorthEast()),l=gS(n.worldSize,r.getSouthEast()),u=gS(n.worldSize,r.getSouthWest()),c=lf(-i),h=s.rotate(c),d=o.rotate(c),p=l.rotate(c),f=u.rotate(c),m=new Sd(Math.max(h.x,d.x,f.x,p.x),Math.max(h.y,d.y,f.y,p.y)),g=new Sd(Math.min(h.x,d.x,f.x,p.x),Math.min(h.y,d.y,f.y,p.y)),y=m.sub(g),_=n.width-(a.left+a.right+t.left+t.right),v=n.height-(a.top+a.bottom+t.top+t.bottom),x=_/y.x,b=v/y.y;if(b<0||x<0)return void bR();let w=Math.min(Zp(n.scale*Math.min(x,b)),e.maxZoom),E=Sd.convert(e.offset),S=new Sd((t.left-t.right)/2,(t.top-t.bottom)/2).rotate(lf(i)),D=E.add(S).mult(n.scale/Gp(w));return{center:yS(n.worldSize,s.add(l).div(2).sub(D)),zoom:w,bearing:i}}var SR=class{get useGlobeControls(){return!1}handlePanInertia(e,t){let r=e.mag(),i=Math.abs(_S(t));return{easingOffset:e.mult(Math.min(.75*i/r,1)),easingCenter:t.center}}handleMapControlsRollPitchBearingZoom(e,t){e.bearingDelta&&t.setBearing(t.bearing+e.bearingDelta),e.pitchDelta&&t.setPitch(t.pitch+e.pitchDelta),e.rollDelta&&t.setRoll(t.roll+e.rollDelta),e.zoomDelta&&t.setZoom(t.zoom+e.zoomDelta)}handleMapControlsPan(e,t,r){e.around.distSqr(t.centerPoint)<.01||t.setLocationAtPoint(r,e.around,e.aroundElevation)}cameraForBoxAndBearing(e,t,r,i,n){return ER(e,t,r,i,n)}handleJumpToCenterZoom(e,t){let r=void 0===t.zoom?e.zoom:+t.zoom;e.zoom!==r&&e.setZoom(+t.zoom),void 0!==t.center&&e.setCenter(nS.convert(t.center))}handleEaseTo(e,t){let r=e.zoom,i=e.padding,n={roll:e.roll,pitch:e.pitch,bearing:e.bearing},a={roll:void 0===t.roll?e.roll:t.roll,pitch:void 0===t.pitch?e.pitch:t.pitch,bearing:void 0===t.bearing?e.bearing:t.bearing},s=void 0!==t.zoom,o=!e.isPaddingEqual(t.padding),l=!1,u=s?+t.zoom:e.zoom,c=e.centerPoint.add(t.offsetAsPoint),h=e.screenPointToLocation(c),{center:d,zoom:p}=e.applyConstrain(nS.convert(t.center||h),u??r);sR(e,d);let f=gS(e.worldSize,h),m=gS(e.worldSize,d).sub(f),g=Gp(p-r);return l=p!==r,{easeFunc:s=>{if(l&&e.setZoom(ng.number(r,p,s)),cf(n,a)||wR({startEulerAngles:n,endEulerAngles:a,tr:e,k:s,useSlerp:n.roll!=a.roll}),o&&(e.interpolatePadding(i,t.padding,s),c=e.centerPoint.add(t.offsetAsPoint)),t.around)e.setLocationAtPoint(t.around,t.aroundPoint);else{let t=Gp(e.zoom-r),i=(p>r?Math.min(2,g):Math.max(.5,g))**(1-s),n=yS(e.worldSize,f.add(m.mult(s*i)).mult(t));e.setLocationAtPoint(e.renderWorldCopies?n.wrap():n,c)}},isZooming:l,elevationCenter:d}}handleFlyTo(e,t){let r=void 0!==t.zoom,i=e.zoom,n=e.applyConstrain(nS.convert(t.center||t.locationAtOffset),r?+t.zoom:i),a=n.center,s=n.zoom;sR(e,a);let o=e.worldSize,l=gS(o,t.locationAtOffset),u=gS(o,a).sub(l),c=u.mag(),h=Gp(s-i),d=void 0===t.minZoom?e.minZoom:+t.minZoom,p=Math.max(d,e.minZoom),f=Math.min(p,i,s),m=e.applyConstrain(a,f).zoom;return{easeFunc:(t,r,n,c)=>{e.setZoom(1===t?s:i+Zp(r));let h=1===t?a:yS(o,l.add(u.mult(n)));e.setLocationAtPoint(e.renderWorldCopies?h.wrap():h,c)},scaleOfZoom:h,targetCenter:a,scaleOfMinZoom:Gp(m-i),pixelPathLength:c}}};let DR;const TR=new CE({fill:new IE(128,2),line:new IE(512,0),tile:new IE(128,32),stencil:new IE(128,1),circle:3});var AR=class{constructor(){this._tileMeshCache={}}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 eR.projectionGlobe}get vertexShaderPreludeCode(){return eR.projectionMercator.vertexSource}get subdivisionGranularity(){return TR}get useGlobeControls(){return!0}destroy(){}_getMeshKey(e){return`${e.granularity.toString(36)}_${e.generateBorders?"b":""}${e.extendToNorthPole?"n":""}${e.extendToSouthPole?"s":""}`}getMeshFromTileID(e,t,r,i,n){let a=("stencil"===n?TR.stencil:TR.tile).getGranularityForZoomLevel(t.z),s=0===t.y&&i,o=t.y===(1<<t.z)-1&&i;return this._getMesh(e,{granularity:a,generateBorders:r,extendToNorthPole:s,extendToSouthPole:o})}_getMesh(e,t){let r=this._getMeshKey(t);if(r in this._tileMeshCache)return this._tileMeshCache[r];let i=_M(e,t);return this._tileMeshCache[r]=i,i}recalculate(e){}hasTransition(){return!1}},PR=class extends zf{constructor(e,t){super(),this._transitionable=new Cv(DR||=new Uv({type:new Ov(Of.projection.type,"type")}),"projection",t),this.setProjection(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new Tv(0)),this._mercatorProjection=new nR,this._verticalPerspectiveProjection=new AR}get transitionState(){let e=this.properties.get("type");if("string"==typeof e&&"mercator"===e)return 0;if("string"==typeof e&&"vertical-perspective"===e)return 1;if(e instanceof Gm){if(e.from===e.to)return"mercator"===e.from?0:1;if("vertical-perspective"===e.from&&"mercator"===e.to)return 1-e.transition;if("mercator"===e.from&&"vertical-perspective"===e.to)return e.transition}return 1}get useGlobeRendering(){return this.transitionState>0}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()}getMeshFromTileID(e,t,r,i,n){return this.currentProjection.getMeshFromTileID(e,t,r,i,n)}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)}};function IR(e){let t=MR(e.worldSize,e.center.lat);return 2*Math.PI*t}function CR(e,t,r,i,n){let a=1/(1<<n),s=t/_p*a+i*a,o=kp((e/_p*a+r*a)*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),c=new Float64Array(3);return c[0]=Math.sin(o)*u,c[1]=Math.sin(l),c[2]=Math.cos(o)*u,c}function FR(e){return function(e,t){let r=Math.cos(t),i=new Float64Array(3);return i[0]=Math.sin(e)*r,i[1]=Math.sin(t),i[2]=Math.cos(e)*r,i}(e.lng*Math.PI/180,e.lat*Math.PI/180)}function MR(e,t){return e/(2*Math.PI)/Math.cos(t*Math.PI/180)}function kR(e){let t=sp(bp(),[0,0,0,1],e.modelViewProjectionMatrix);return sp(t,t,e.inverseProjectionMatrix),[t[0]/t[3],t[1]/t[3],t[2]/t[3]]}function RR(e){let t=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,n=e[2]/r,a=Math.acos(n),s=(i>0?a:-a)/Math.PI*180;return new nS(Np(s,-180,180),t)}return new nS(0,t)}const LR=.98*Math.PI;function zR(e,t){let r=e.cameraPosition,i=Gd(r);if(i<=1)return e.screenPointToLocation(t);let n=wp();Kd(n,r);let a=e.getRayDirectionFromPixel(t),s=-Jd(a,n),o=wp();Yd(o,a,n,s);let l=Gd(o);if(l<1e-9)return e.screenPointToLocation(t);let u=Math.atan2(l,s),c=.9*Math.asin(1/i);if(u<c)return e.screenPointToLocation(t);let h=i*Math.sin(c),d=Math.asin($p(h,-1,1))-c,p=i*Math.cos(c)/Math.sqrt(Math.max(1-h*h,1e-12))-1,f=LR-d,m=u-c,g=d+p*m*f/(f+p*m),y=wp();Xd(y,o,1/l);let _=wp();return Xd(_,n,Math.cos($p(g,0,LR))),Yd(_,_,y,Math.sin($p(g,0,LR))),Kd(_,_),RR(_)}function BR(e,t,r,i,n=!0){let a=zR(e,r),s=t;if(i)s=zR(e,r.sub(i));else if(!e.isPointOnMapSurface(r))return;let o=FR(a),l=FR(s),u=function(e,t){return cp(bp(),-e.lng,-e.lat,t)}(e.center,e.bearing),c=Qd(wp(),l,o),h=Math.sqrt(Jd(c,c)),d=Math.acos($p(Jd(l,o),-1,1))/2,p=Math.sin(d),f=h?hp(c[1]/h*p,-c[0]/h*p,c[2]/h*p,Math.cos(d)):hp(0,0,0,1),{lng:m,lat:g,bearing:y}=function(e){let t=e[0],r=e[1],i=e[2],n=e[3];return{lng:180*-Math.atan2(2*(n*t+r*i),1-2*(t*t+r*r))/Math.PI,lat:180*-Math.asin($p(2*(n*r-i*t),-1,1))/Math.PI,bearing:180*Math.atan2(2*(n*i+t*r),1-2*(r*r+i*i))/Math.PI}}(function(e,t,r){var i=t[0],n=t[1],a=t[2],s=t[3],o=r[0],l=r[1],u=r[2],c=r[3];return e[0]=i*c+s*o+n*u-a*l,e[1]=n*c+s*l+a*o-i*u,e[2]=a*c+s*u+i*l-n*o,e[3]=s*c-i*o-n*l-a*u,e}(bp(),u,f)),_=e.center.lat,v=e.zoom,x=$p(g,-90,90),b=n?function(e,t,r,i){let n=e.center.lng,a=e.center.lat,s=a>=0?90:-90,o=e.locationToScreenPoint(new nS(0,s)),l=t.x-o.x,u=t.y-o.y,c=l*l+u*u,h=$p(1-(pf-Math.abs(a))/12,0,1),d=h*h*(3-2*h),p=kp(i-n+180,360)-180,f=0;if(d>0&&r){f=(s>0?1:-1)*((l*r.y-u*r.x)/Math.max(c,400))*180/Math.PI}return n+(1-d)*p+d*f}(e,r,i,m):m;e.setCenter(new nS(Np(b,-180,180),x)),n||e.setBearing(y),e.setZoom(v+$R(_,e.center.lat))}function OR(e){return Math.cos(e*Math.PI/180)}function $R(e,t){let r=OR(e);return Zp(OR(t)/r)}function NR(e,t){let r=e.rotate(t.bearingInRadians),i=t.zoom+$R(t.center.lat,0),n=Lp(1/OR(t.center.lat),1/OR(Math.min(Math.abs(t.center.lat),60)),Rp(i,7,3,0,1)),a=function(e,t){return 360/IR({worldSize:e,center:{lat:t}})}(t.worldSize,t.center.lat);return new nS(t.center.lng-r.x*a*n,$p(t.center.lat+r.y*a,-pf,pf))}function jR(e){let t=.5*e,r=Math.sin(t),i=Math.cos(t);return Math.log(r+i)-Math.log(i-r)}function VR(e,t,r,i){let n=e.lat+r*i;if(Math.abs(r)>1){let a=e.lat+r,s=(Math.sign(a)===Math.sign(e.lat)?Math.abs(e.lat):-Math.abs(e.lat))*Math.PI/180,o=Math.abs(e.lat+r)*Math.PI/180,l=jR(s+i*(o-s)),u=jR(s),c=(l-u)/(jR(o)-u),h=e.lng+t*c;return new nS(h,n)}{let r=e.lng+t*i;return new nS(r,n)}}function UR(e,t,r=1){let i=Jd(e,t),n=r*r,a=wp(),s=wp();Xd(s,t,i),np(a,e,s);let o=n-Jd(a,a);if(o<0)return null;let l=Jd(e,e)-n,u=-i+(i<0?1:-1)*Math.sqrt(o),c=l/u,h=u;return{tMin:Math.min(c,h),tMax:Math.max(c,h)}}var qR=class{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,r,i){let n=`${e.z}_${e.x}_${e.y}_${i?.terrain?"t":""}_${Math.round(r)}`,a=this._cache.get(n);if(a)return a;let s=this._cachePrevious.get(n);if(s)return this._cache.set(n,s),s;let o=this._boundingVolumeFactory(e,t,r,i);return this._cache.set(n,o),this._hadAnyChanges=!0,o}},GR=class e{constructor(e,t,r,i){this.min=r,this.max=i,this.points=e,this.planes=t}static fromAabb(t,r){let i=[];for(let e=0;e<8;e++)i.push([1&~e?t[0]:r[0],1==(e>>1&1)?r[1]:t[1],1==(e>>2&1)?r[2]:t[2]]);return new e(i,[[-1,0,0,r[0]],[1,0,0,-t[0]],[0,-1,0,r[1]],[0,1,0,-t[1]],[0,0,-1,r[2]],[0,0,1,-t[2]]],t,r)}static fromCenterSizeAngles(t,r,i){let n=cp([],i[0],i[1],i[2]),a=ep([],[r[0],0,0],n),s=ep([],[0,r[1],0],n),o=ep([],[0,0,r[2]],n),l=[...t],u=[...t];for(let e=0;e<8;e++)for(let r=0;r<3;r++){let i=t[r]+a[r]*(1&~e?-1:1)+s[r]*(1==(e>>1&1)?1:-1)+o[r]*(1==(e>>2&1)?1:-1);l[r]=Math.min(l[r],i),u[r]=Math.max(u[r],i)}let c=[];for(let e=0;e<8;e++){let r=[...t];Wd(r,r,Xd([],a,1&~e?-1:1)),Wd(r,r,Xd([],s,1==(e>>1&1)?1:-1)),Wd(r,r,Xd([],o,1==(e>>2&1)?1:-1)),c.push(r)}return new e(c,[[...a,-Jd(a,c[0])],[...s,-Jd(s,c[0])],[...o,-Jd(o,c[0])],[-a[0],-a[1],-a[2],-Jd(a,c[7])],[-s[0],-s[1],-s[2],-Jd(s,c[7])],[-o[0],-o[1],-o[2],-Jd(o,c[7])]],l,u)}intersectsFrustum(e){let t=!0,r=this.points.length,i=this.planes.length,n=e.planes.length,a=e.points.length;for(let s=0;s<n;s++){let i=e.planes[s],n=0;for(let e=0;e<r;e++){let t=this.points[e];i[0]*t[0]+i[1]*t[1]+i[2]*t[2]+i[3]>=0&&n++}if(0===n)return 0;n<r&&(t=!1)}if(t)return 2;for(let s=0;s<i;s++){let t=this.planes[s],r=0;for(let i=0;i<a;i++){let n=e.points[i];t[0]*n[0]+t[1]*n[1]+t[2]*n[2]+t[3]>=0&&r++}if(0===r)return 0}return 1}intersectsPlane(e){let t=this.points.length,r=0;for(let i=0;i<t;i++){let t=this.points[i];e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]>=0&&r++}return r===t?2:0===r?0:1}};function ZR(e,t,r){let i=e-t;return i<0?-i:Math.max(0,i-r)}function WR(e,t,r,i,n){let a,s=e-r;return a=s<0?Math.min(-s,1+s-n):s>n?Math.min(Math.max(s-n,0),1-s):0,Math.max(a,ZR(t,i,n))}var HR=class{constructor(){this._boundingVolumeCache=new qR(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,t,r,i){let n=1<<r.z,a=1/n,s=r.x/n,o=r.y/n,l=2;return l=Math.min(l,WR(e,t,s,o,a)),l=Math.min(l,WR(e,t,s+.5,-o-a,a)),l=Math.min(l,WR(e,t,s+.5,2-o-a,a)),l}getWrap(e,t,r){let i=1<<t.z,n=1/i,a=t.x/i,s=ZR(e.x,a,n),o=ZR(e.x,a-1,n),l=ZR(e.x,a+1,n),u=Math.min(s,o,l);return u===l?1:u===o?-1:0}allowVariableZoom(e,t){return OM(e,t)>4}allowWorldCopies(){return!1}getTileBoundingVolume(e,t,r,i){return this._boundingVolumeCache.getTileBoundingVolume(e,t,r,i)}_computeTileBoundingVolume(e,t,r,i){let n=Math.min(0,r),a=Math.max(0,r);if(i?.terrain){let r=new PA(e.z,t,e.z,e.x,e.y),s=i.terrain.getMinMaxElevation(r);n=s.minElevation??n,a=Math.max(s.maxElevation??a,a)}if(n/=iS,a/=iS,n+=1,a+=1,e.z<=0)return GR.fromAabb([-a,-a,-a],[a,a,a]);if(1===e.z)return GR.fromAabb([0===e.x?-a:0,0===e.y?0:-a,-a],[0===e.x?0:a,0===e.y?a:0,a]);{let t=[CR(0,0,e.x,e.y,e.z),CR(_p,0,e.x,e.y,e.z),CR(_p,_p,e.x,e.y,e.z),CR(0,_p,e.x,e.y,e.z)],r=[];for(let e of t)r.push(Xd([],e,a));if(a!==n)for(let e of t)r.push(Xd([],e,n));0===e.y&&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 o=CR(_p/2,_p/2,e.x,e.y,e.z),l=Qd([],[0,1,0],o);Kd(l,l);let u=Qd([],o,l);Kd(u,u);let c=Qd([],t[2],t[1]);Kd(c,c);let h=Qd([],t[0],t[3]);Kd(h,h),r.push(Xd([],o,a)),e.y>=(1<<e.z)/2&&r.push(Xd([],CR(_p/2,0,e.x,e.y,e.z),a)),e.y<(1<<e.z)/2&&r.push(Xd([],CR(_p/2,_p,e.x,e.y,e.z),a));let d=XR(o,r),p=XR(u,r),f=[-o[0],-o[1],-o[2],d.max],m=[o[0],o[1],o[2],-d.min],g=[-u[0],-u[1],-u[2],p.max],y=[u[0],u[1],u[2],-p.min],_=[...c,0],v=[...h,0],x=[];return 0===e.y?x.push(Pp(v,_,f),Pp(v,_,m)):x.push(Pp(g,_,f),Pp(g,_,m),Pp(g,v,f),Pp(g,v,m)),e.y===(1<<e.z)-1?x.push(Pp(v,_,f),Pp(v,_,m)):x.push(Pp(y,_,f),Pp(y,_,m),Pp(y,v,f),Pp(y,v,m)),new GR(x,[f,m,g,y,_,v],i,s)}}};function XR(e,t){let r=1/0,i=-1/0;for(let n of t){let t=Jd(e,n);r=Math.min(r,t),i=Math.max(i,t)}return{min:r,max:i}}var YR=class e{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,r){this._helper.interpolatePadding(e,t,r)}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)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e){}constructor(e){this._cachedClippingPlane=bp(),this._projectionMatrix=Sp(),this._globeViewProjMatrix32f=Dp(),this._globeViewProjMatrixF64=Sp(),this._globeViewProjMatrixF64Inverted=Sp(),this._globeProjMatrixInverted=Sp(),this._cameraPosition=wp(),this.defaultConstrain=(e,t)=>{let r=$p(e.lat,-pf,pf),i=$p(+t,this.minZoom+$R(0,r),this.maxZoom);return{center:new nS(e.lng,r),zoom:i}},this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new lR({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._coveringTilesDetailsProvider=new HR}clone(){let t=new e;return t.apply(this,!1),t}apply(e,t){this._helper.apply(e,t)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixF64}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){let e=wp();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:r}=e,i=this._helper.getMercatorTileCoordinates(t);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:i,clippingPlane:this._cachedClippingPlane,projectionTransition:+!!r,fallbackMatrix:this._globeViewProjMatrix32f,clipAntimeridian:0===t?.canonical.z}}_computeClippingPlane(e){let t=this.pitchInRadians,r=this.cameraToCenterDistance/e,i=Math.sin(t)*r,n=Math.cos(t)*r+1,a=1/Math.sqrt(i*i+n*n)*1,s=-i,o=n,l=Math.sqrt(s*s+o*o);s/=l,o/=l;let u=[0,s,o];ip(u,u,[0,0,0],-this.bearingInRadians),tp(u,u,[0,0,0],-1*this.center.lat*Math.PI/180),rp(u,u,[0,0,0],this.center.lng*Math.PI/180);let c=1/Gd(u);return Xd(u,u,c),[...u,-a*c]}isLocationOccluded(e){return!this.isSurfacePointVisible(FR(e))}transformLightDirection(e){let t=this._helper._center.lng*Math.PI/180,r=this._helper._center.lat*Math.PI/180,i=Math.cos(r),n=[Math.sin(t)*i,Math.sin(r),Math.cos(t)*i],a=[n[2],0,-n[0]],s=[0,0,0];Qd(s,a,n),Kd(a,a),Kd(s,s);let o=[0,0,0];return Kd(o,[a[0]*e[0]+s[0]*e[1]+n[0]*e[2],a[1]*e[0]+s[1]*e[1]+n[1]*e[2],a[2]*e[0]+s[2]*e[1]+n[2]*e[2]]),o}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,t,r){let i=mS(e,t,r.canonical),n=function(e,t){return[kp(e*Math.PI*2+Math.PI,2*Math.PI),2*Math.atan(Math.exp(Math.PI-t*Math.PI*2))-.5*Math.PI]}(i.x,i.y);return this.getCircleRadiusCorrection()/Math.cos(n[1])}projectTileCoordinates(e,t,r,i){let n,a=r.canonical,s=CR(e,t,a.x,a.y,a.z),o=1+(i??0)/iS,l=s[0]*o,u=s[1]*o,c=s[2]*o,h=[l,u,c,1];if(sp(h,h,this._globeViewProjMatrixF64),o<=1){let e=this._cachedClippingPlane;n=e[0]*s[0]+e[1]*s[1]+e[2]*s[2]+e[3]<0}else n=this._isLineOfSightBlocked(l,u,c);return{point:new Sd(h[0]/h[3],h[1]/h[3]),signedDistanceFromCamera:h[3],isOccluded:n}}_isLineOfSightBlocked(e,t,r){let i=this._cameraPosition,n=e-i[0],a=t-i[1],s=r-i[2],o=n*n+a*a+s*s;if(0===o)return!1;let l=$p(-(i[0]*n+i[1]*a+i[2]*s)/o,0,1),u=i[0]+l*n,c=i[1]+l*a,h=i[2]+l*s;return u*u+c*c+h*h<1}_calcMatrices(){let e=MR(this.worldSize,this.center.lat),t=Ep();this._helper.autoCalculateNearFarZ&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+2*e),jd(t,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);let r=this.centerOffset;t[8]=2*-r.x/this._helper._width,t[9]=2*r.y/this._helper._height,this._projectionMatrix=Md(t),this._globeProjMatrixInverted=Ep(),Rd(this._globeProjMatrixInverted,t),zd(t,t,[0,0,-this.cameraToCenterDistance]),Nd(t,t,this.rollInRadians),Od(t,t,-this.pitchInRadians),Nd(t,t,this.bearingInRadians),zd(t,t,[0,0,-e]);let i=wp();i[0]=e,i[1]=e,i[2]=e,Od(t,t,this.center.lat*Math.PI/180),$d(t,t,-this.center.lng*Math.PI/180),Bd(t,t,i),this._globeViewProjMatrixF64=t,this._globeViewProjMatrix32f=new Float32Array(t),this._globeViewProjMatrixF64Inverted=Ep(),Rd(this._globeViewProjMatrixF64Inverted,t);let n=wp();this._cameraPosition=wp(),this._cameraPosition[2]=this.cameraToCenterDistance/e,ip(this._cameraPosition,this._cameraPosition,n,-this.rollInRadians),tp(this._cameraPosition,this._cameraPosition,n,this.pitchInRadians),ip(this._cameraPosition,this._cameraPosition,n,-this.bearingInRadians),Wd(this._cameraPosition,this._cameraPosition,[0,0,1]),tp(this._cameraPosition,this._cameraPosition,n,-this.center.lat*Math.PI/180),rp(this._cameraPosition,this._cameraPosition,n,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(e);let a=Md(this._globeViewProjMatrixF64Inverted);Bd(a,a,[1,1,-1]),this._cachedFrustum=kM.fromInvProjectionMatrix(a,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(e){Qp("calculateFogMatrix is not supported on globe projection.");let t=Ep();return kd(t),t}getVisibleUnwrappedCoordinates(e){return[new AA(0,e)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){e?Qp("terrain is not fully supported on vertical perspective projection."):this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return(Gd(this._cameraPosition)-1)*iS}getCameraLngLat(){let e=wp();return Kd(e,this._cameraPosition),RR(e)}lngLatToCameraDepth(e,t){let r=FR(e);Xd(r,r,1+t/iS);let i=bp();return sp(i,[r[0],r[1],r[2],1],this._globeViewProjMatrixF64),i[2]/i[3]}populateCache(e){}getBounds(){let e=.5*this.width,t=.5*this.height,r=[new Sd(0,0),new Sd(e,0),new Sd(this.width,0),new Sd(this.width,t),new Sd(this.width,this.height),new Sd(e,this.height),new Sd(0,this.height),new Sd(0,t)],i=[];for(let c of r)i.push(this.unprojectScreenPoint(c));let n=0,a=0,s=0,o=0,l=this.center;for(let c of i){let e=Fp(l.lng,c.lng),t=Fp(l.lat,c.lat);e<a&&(a=e),e>n&&(n=e),t<o&&(o=t),t>s&&(s=t)}let u=[l.lng+a,l.lat+o,l.lng+n,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 JF(u)}calculateCenterFromCameraLngLatAlt(e,t,r,i){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,r,i)}calculateCameraOptionsFromTo(e,t,r,i){let n=nS.convert(r),a=FR(nS.convert(e));Xd(a,a,1+t/iS);let s=FR(n),o=Xd(wp(),s,1+i/iS),l=Hd(wp(),a,s),u=Gd(l);if(u<1e-12||function(e,t){var r=t[0]-e[0],i=t[1]-e[1],n=t[2]-e[2];return Math.sqrt(r*r+i*i+n*n)}(a,o)<1e-12)throw Error("Can't calculate camera options with same From and To");let c=wp();rp(l,l,c,-lf(n.lng)),tp(l,l,c,lf(n.lat));let h=uf(Math.acos($p(l[2]/u,-1,1))),d=Math.hypot(l[0],l[1])<1e-9*u?this.bearing:uf(Math.atan2(-l[0],-l[1]));return{center:n,elevation:i,zoom:Zp(this.cameraToCenterDistance/u/MR(this.tileSize,n.lat)),pitch:h,bearing:d}}setLocationAtPoint(e,t,r){let i=FR(this.unprojectScreenPoint(t)),n=FR(e),a=wp();!function(e){e[0]=0,e[1]=0,e[2]=0}(a);let s=wp();rp(s,i,a,-this.center.lng*Math.PI/180),tp(s,s,a,this.center.lat*Math.PI/180);let o=n[0]*n[0]+n[2]*n[2],l=s[0]*s[0];if(o<l)return;let u=Math.sqrt(o-l),c=-u,h=Cp(n[0],n[2],s[0],u),d=Cp(n[0],n[2],s[0],c),p=wp();rp(p,n,a,-h);let f=Cp(p[1],p[2],s[1],s[2]),m=wp();rp(m,n,a,-d);let g,y,_=Cp(m[1],m[2],s[1],s[2]),v=.5*Math.PI,x=f>=-v&&f<=v,b=_>=-v&&_<=v;if(x&&b){let e=this.center.lng*Math.PI/180,t=this.center.lat*Math.PI/180;Mp(h,e)+Mp(f,t)<Mp(d,e)+Mp(_,t)?(g=h,y=f):(g=d,y=_)}else if(x)g=h,y=f;else{if(!b)return;g=d,y=_}let w=g/Math.PI*180,E=y/Math.PI*180,S=this.center.lat;this.setCenter(new nS(w,$p(E,-90,90))),this.setZoom(this.zoom+$R(S,this.center.lat))}locationToScreenPoint(e,t){let r=FR(e);if(t){Xd(r,r,1+t.getElevationForLngLatZoom(e,this._helper._tileZoom)/iS)}return this._projectSurfacePointToScreen(r)}_projectSurfacePointToScreen(e){let t=bp();return sp(t,[...e,1],this._globeViewProjMatrixF64),t[0]/=t[3],t[1]/=t[3],new Sd((.5*t[0]+.5)*this.width,(.5*-t[1]+.5)*this.height)}screenPointToMercatorCoordinate(e,t){if(t){let r=this.screenTerrainPointToMercatorCoordinate(e,t);if(r)return r}return pS.fromLngLat(this.unprojectScreenPoint(e))}screenTerrainPointToMercatorCoordinate(e,t){let r=t.getCoverageIndex();if(!r)return null;let i=this.cameraPosition,n=this.getRayDirectionFromPixel(e),a=UR(i,n,1+r.maxElevation/iS);if(!a)return null;let s=UR(i,n,1+r.minElevation/iS),o=Math.max(a.tMin,0),l=s?s.tMin:a.tMax;if(l<=o)return null;let u={index:r,exaggeration:t.exaggeration,origin:i,direction:n},c=0;for(let h=0;h<=256;h++){let e=o+(l-o)*h/256;if(JR(u,e)){let{hi:t}=yR(u,JR,c,e,1e-12),{sample:r,mercator:i}=KR(u,t);return new pS(i.x,i.y,r.elevation)}c=e}return null}screenPointToLocation(e,t){return this.screenPointToMercatorCoordinate(e,t)?.toLngLat()}screenPointToLocationAtElevation(e,t){return this.screenPointToLocation(e)}isPointOnMapSurface(e,t){return!!UR(this._cameraPosition,this.getRayDirectionFromPixel(e))}getRayDirectionFromPixel(e){let t=bp();t[0]=e.x/this.width*2-1,t[1]=-1*(e.y/this.height*2-1),t[2]=1,t[3]=1,sp(t,t,this._globeViewProjMatrixF64Inverted),t[0]/=t[3],t[1]/=t[3],t[2]/=t[3];let r=wp();r[0]=t[0]-this._cameraPosition[0],r[1]=t[1]-this._cameraPosition[1],r[2]=t[2]-this._cameraPosition[2];let i=wp();return Kd(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 t=bp();return sp(t,[...e,1],this._globeViewProjMatrixF64),t[0]/=t[3],t[1]/=t[3],t[2]/=t[3],t[0]>-1&&t[0]<1&&t[1]>-1&&t[1]<1&&t[2]>-1&&t[2]<1}unprojectScreenPoint(e){let t=this._cameraPosition,r=this.getRayDirectionFromPixel(e),i=UR(t,r);if(i){let e=wp();Wd(e,t,[r[0]*i.tMin,r[1]*i.tMin,r[2]*i.tMin]);let n=wp();return Kd(n,e),RR(n)}let n=this._cachedClippingPlane,a=n[0]*r[0]+n[1]*r[1]+n[2]*r[2],s=-Ap(n,t)/a,o=wp();if(s>0)Wd(o,t,[r[0]*s,r[1]*s,r[2]*s]);else{let e=wp();Wd(e,t,[2*r[0],2*r[1],2*r[2]]);let i=Ap(this._cachedClippingPlane,e);np(o,e,[this._cachedClippingPlane[0]*i,this._cachedClippingPlane[1]*i,this._cachedClippingPlane[2]*i])}let l=function(e){let t=wp();return t[0]=e[0]*-e[3],t[1]=e[1]*-e[3],t[2]=e[2]*-e[3],{center:t,radius:Math.sqrt(1-e[3]*e[3])}}(n);return RR(function(e,t,r){let i=wp();np(i,r,e);let n=wp();return Yd(n,e,i,t/ap(i)),n}(l.center,l.radius,o))}getProjectionDataForCustomLayer(e=!0){let t=this.getProjectionData({overscaledTileID:new PA(0,0,0,0,0),applyGlobeMatrix:e});return t.tileMercatorCoords=[0,0,1,1],t}getFastPathSimpleProjectionMatrix(e){}};function KR(e,t){let r=wp();Yd(r,e.origin,e.direction,t);let i=Gd(r),n=wp();Xd(n,r,1/i);let a=RR(n),s=pS.fromLngLat(a),o=new pS(s.x,$p(s.y,0,.999999999)),l=mR(e.index,e.exaggeration,o.x,o.y),u=Math.abs(a.lat)>85.051129?0:l.elevation;return{sample:{...l,elevation:u},radius:i,mercator:o}}function JR(e,t){let{sample:r,radius:i}=KR(e,t);return gR(r,(i-1)*iS)}var QR=class e{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,r){this._helper.interpolatePadding(e,t,r)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,r=!0){this._helper.resize(e,t,r)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e){this._globeness=e,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(e){this._globeness=1,this.defaultConstrain=(e,t)=>this.currentTransform.defaultConstrain(e,t),this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new lR({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._globeness=1,this._mercatorTransform=new _R,this._verticalPerspectiveTransform=new YR}clone(){let t=new e;return t._globeness=this._globeness,t.apply(this,!1),t}apply(e,t){this._helper.apply(e,t),this._mercatorTransform.apply(this,!1),this._verticalPerspectiveTransform.apply(this,!1)}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),r=this._verticalPerspectiveTransform.getProjectionData(e);return{mainMatrix:this.isGlobeRendering?r.mainMatrix:t.mainMatrix,clippingPlane:r.clippingPlane,tileMercatorCoords:r.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:t.fallbackMatrix,clipAntimeridian:r.clipAntimeridian}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return Lp(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return Lp(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,t,r){return Lp(this._mercatorTransform.getPitchedTextCorrection(e,t,r),this._verticalPerspectiveTransform.getPitchedTextCorrection(e,t,r),this._globeness)}projectTileCoordinates(e,t,r,i){return this.currentTransform.projectTileCoordinates(e,t,r,i)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,!1),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.currentTransform.recalculateZoomAndCenter(e)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this.currentTransform.getCameraAltitude()}getCameraLngLat(){return this.currentTransform.getCameraLngLat()}lngLatToCameraDepth(e,t){return this.currentTransform.lngLatToCameraDepth(e,t)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(e,t,r,i){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,r,i)}calculateCameraOptionsFromTo(e,t,r,i){return this.currentTransform.calculateCameraOptionsFromTo(e,t,r,i)}setLocationAtPoint(e,t,r){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,t,r),void this.apply(this._mercatorTransform,!1);this._verticalPerspectiveTransform.setLocationAtPoint(e,t,r),this.apply(this._verticalPerspectiveTransform,!1)}locationToScreenPoint(e,t){return this.currentTransform.locationToScreenPoint(e,t)}screenPointToMercatorCoordinate(e,t){return this.currentTransform.screenPointToMercatorCoordinate(e,t)}screenTerrainPointToMercatorCoordinate(e,t){return this.currentTransform.screenTerrainPointToMercatorCoordinate(e,t)}screenPointToLocation(e,t){return this.currentTransform.screenPointToLocation(e,t)}screenPointToLocationAtElevation(e,t){return this.currentTransform.screenPointToLocationAtElevation(e,t)}isPointOnMapSurface(e,t){return this.currentTransform.isPointOnMapSurface(e,t)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getProjectionDataForCustomLayer(e=!0){let t=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return t;let r=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return r.fallbackMatrix=t.mainMatrix,r.projectionTransition=this._globeness,r}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}},eL=class e{get useGlobeControls(){return!0}handlePanInertia(e,t){let r=NR(e,t);return Math.abs(r.lng-t.center.lng)>180&&(r.lng=t.center.lng+179.5*Math.sign(r.lng-t.center.lng)),{easingCenter:r,easingOffset:new Sd(0,0)}}handleMapControlsRollPitchBearingZoom(e,t){let r=e.around,i=t.screenPointToLocation(r);e.bearingDelta&&t.setBearing(t.bearing+e.bearingDelta),e.pitchDelta&&t.setPitch(t.pitch+e.pitchDelta),e.rollDelta&&t.setRoll(t.roll+e.rollDelta);let n=t.zoom;e.zoomDelta&&t.setZoom(t.zoom+e.zoomDelta);let a=t.zoom-n;if(0===a)return;let s=Fp(t.center.lng,i.lng),o=s/(Math.abs(s/180)+1),l=Fp(t.center.lat,i.lat),u=t.getRayDirectionFromPixel(r),c=t.cameraPosition,h=-1*Jd(c,u),d=wp();Wd(d,c,[u[0]*h,u[1]*h,u[2]*h]);let p=Gd(d),f=p-1,m=Math.exp(.5*-Math.max(f-.3,0)),g=Rp(p,.95,.999,0,1),y=Rp(MR(t.worldSize,t.center.lat)/Math.min(t.width,t.height),.9,.5,1,.25),_=Math.min(m,Lp(1,y,g)),v=(1-Gp(-a))*_,x=t.center.lat,b=t.zoom,w=new nS(t.center.lng+o*v,$p(t.center.lat+l*v,-pf,pf));t.setLocationAtPoint(i,r);let E=t.center,S=Rp(Math.abs(s),45,85,0,1),D=Math.max(S,g)**.25,T=Fp(E.lng,w.lng),A=Fp(E.lat,w.lat);t.setCenter(new nS(E.lng+T*D,E.lat+A*D).wrap()),t.setZoom(b+$R(x,t.center.lat))}handleMapControlsPan(e,t,r){e.panDelta&&BR(t,r,t.isPointOnMapSurface(e.around)?e.around:t.centerPoint,e.panDelta)}cameraForBoxAndBearing(t,r,i,n,a){let s=ER(t,r,i,n,a),o=r.left/a.width*2-1,l=(a.width-r.right)/a.width*2-1,u=r.top/a.height*-2+1,c=(a.height-r.bottom)/a.height*-2+1,h=Fp(i.getWest(),i.getEast())<0,d=h?i.getEast():i.getWest(),p=h?i.getWest():i.getEast(),f=Math.max(i.getNorth(),i.getSouth()),m=Math.min(i.getNorth(),i.getSouth()),g=d+.5*Fp(d,p),y=f+.5*Fp(f,m),_=a.clone();_.setCenter(s.center),_.setBearing(s.bearing),_.setPitch(0),_.setRoll(0),_.setZoom(s.zoom);let v=_.modelViewProjectionMatrix,x=[FR(i.getNorthWest()),FR(i.getNorthEast()),FR(i.getSouthWest()),FR(i.getSouthEast()),FR(new nS(p,y)),FR(new nS(d,y)),FR(new nS(g,f)),FR(new nS(g,m))],b=FR(s.center),w=1/0;for(let E of x)o<0&&(w=e.getLesserNonNegativeNonNull(w,e.solveVectorScale(E,b,v,"x",o))),l>0&&(w=e.getLesserNonNegativeNonNull(w,e.solveVectorScale(E,b,v,"x",l))),u>0&&(w=e.getLesserNonNegativeNonNull(w,e.solveVectorScale(E,b,v,"y",u))),c<0&&(w=e.getLesserNonNegativeNonNull(w,e.solveVectorScale(E,b,v,"y",c)));if(Number.isFinite(w)&&0!==w)return s.zoom=Math.min(_.zoom+Zp(w),t.maxZoom),s;bR()}handleJumpToCenterZoom(e,t){let r=e.center.lat,i=e.applyConstrain(t.center?nS.convert(t.center):e.center,e.zoom).center;e.setCenter(i.wrap());let n=void 0===t.zoom?e.zoom+$R(r,i.lat):+t.zoom;e.zoom!==n&&e.setZoom(n)}handleEaseTo(e,t){let r=e.zoom,i=e.center,n=e.padding,a={roll:e.roll,pitch:e.pitch,bearing:e.bearing},s={roll:void 0===t.roll?e.roll:t.roll,pitch:void 0===t.pitch?e.pitch:t.pitch,bearing:void 0===t.bearing?e.bearing:t.bearing},o=void 0!==t.zoom,l=!e.isPaddingEqual(t.padding),u=!1,c=t.center?nS.convert(t.center):i,h=e.applyConstrain(c,r).center;sR(e,h);let d=e.clone();d.setCenter(h),d.setZoom(o?+t.zoom:r+$R(i.lat,c.lat)),d.setBearing(t.bearing);let p=new Sd($p(e.centerPoint.x+t.offsetAsPoint.x,0,e.width),$p(e.centerPoint.y+t.offsetAsPoint.y,0,e.height));d.setLocationAtPoint(h,p);let f=(t.offset&&t.offsetAsPoint.mag())>0?d.center:h,m=o?+t.zoom:r+$R(i.lat,f.lat),g=r+$R(i.lat,0),y=m+$R(f.lat,0),_=Fp(i.lng,f.lng),v=Fp(i.lat,f.lat),x=Gp(y-g);return u=m!==r,{easeFunc:r=>{if(cf(a,s)||wR({startEulerAngles:a,endEulerAngles:s,tr:e,k:r,useSlerp:a.roll!=s.roll}),l&&e.interpolatePadding(n,t.padding,r),t.around)Qp("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(t.around,t.aroundPoint);else{let t=r*(y>g?Math.min(2,x):Math.max(.5,x))**(1-r),n=VR(i,_,v,t);e.setCenter(n.wrap())}if(u){let t=ng.number(g,y,r)+$R(0,e.center.lat);e.setZoom(t)}},isZooming:u,elevationCenter:f}}handleFlyTo(e,t){let r=void 0!==t.zoom,i=e.center,n=e.zoom,a=e.padding,s=!e.isPaddingEqual(t.padding),o=e.applyConstrain(nS.convert(t.center||t.locationAtOffset),n).center,l=r?+t.zoom:e.zoom+$R(e.center.lat,o.lat),u=e.clone();u.setCenter(o),u.setZoom(l),u.setBearing(t.bearing);let c=new Sd($p(e.centerPoint.x+t.offsetAsPoint.x,0,e.width),$p(e.centerPoint.y+t.offsetAsPoint.y,0,e.height));u.setLocationAtPoint(o,c);let h=u.center;sR(e,h);let d=function(e,t,r){let i=Jd(FR(t),FR(r)),n=Math.acos(i),a=IR(e);return n/(2*Math.PI)*a}(e,i,h),p=n+$R(i.lat,0),f=l+$R(h.lat,0),m=Gp(f-p),g="number"==typeof t.minZoom?+t.minZoom:e.minZoom,y=Math.max(g,e.minZoom)+$R(h.lat,0),_=Math.min(y,p,f)+$R(0,h.lat),v=Gp(e.applyConstrain(h,_).zoom+$R(h.lat,0)-p),x=Fp(i.lng,h.lng),b=Fp(i.lat,h.lat);return{easeFunc:(r,n,o,u)=>{let c=VR(i,x,b,o);s&&e.interpolatePadding(a,t.padding,r);let d=1===r?h:c;e.setCenter(d.wrap());let f=p+Zp(n);e.setZoom(1===r?l:f+$R(0,d.lat))},scaleOfZoom:m,targetCenter:h,scaleOfMinZoom:v,pixelPathLength:d}}static solveVectorScale(e,t,r,i,n){let a=n,s="x"===i?[r[0],r[4],r[8],r[12]]:[r[1],r[5],r[9],r[13]],o=[r[3],r[7],r[11],r[15]],l=e[0]*s[0]+e[1]*s[1]+e[2]*s[2],u=e[0]*o[0]+e[1]*o[1]+e[2]*o[2],c=t[0]*s[0]+t[1]*s[1]+t[2]*s[2],h=t[0]*o[0]+t[1]*o[1]+t[2]*o[2];return c+a*u===l+a*h||o[3]*(l-c)+s[3]*(h-u)+l*h===c*u?null:(c+s[3]-a*h-a*o[3])/(c-l-a*h+a*u)}static getLesserNonNegativeNonNull(e,t){return null!==t&&t>=0&&t<e?t:e}},tL=class{constructor(e){this._globe=e,this._mercatorCameraHelper=new SR,this._verticalPerspectiveCameraHelper=new eL}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){this.currentHelper.handleMapControlsRollPitchBearingZoom(e,t)}handleMapControlsPan(e,t,r){this.currentHelper.handleMapControlsPan(e,t,r)}cameraForBoxAndBearing(e,t,r,i,n){return this.currentHelper.cameraForBoxAndBearing(e,t,r,i,n)}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)}};const rL=function(){let e={},t=Of.$version;for(let r in Of.$root){let i=Of.$root[r];if(i.required){let n=null;n="version"===r?t:"array"===i.type?[]:{},null!=n&&(e[r]=n)}}return e}();var iL=class extends zf{constructor(e,t={}){super(),this._rtlPluginLoaded=()=>{for(let e in this.tileManagers){let t=this.tileManagers[e].getSource().type;("vector"===t||"geojson"===t)&&this.tileManagers[e].reload()}},this.map=e,this.dispatcher=new qF(UF(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",(e,t)=>this.getGlyphs(e,t)),this.dispatcher.registerMessageHandler("GI",(e,t)=>this.getImages(e,t)),this.dispatcher.registerMessageHandler("GDA",(e,t)=>this.getDashes(e,t)),this.imageManager=new gF,this.imageManager.setEventedParent(this),this.imageManager.setMissingImageResolver(e._missingStyleImageResolver),this.patternAtlas=new yF(this.imageManager);let r=e._container?.lang||typeof document<"u"&&document.documentElement?.lang||void 0;this.glyphManager=new MF(e._requestManager,t.localIdeographFontFamily,r),this.lineAtlas=new BF(256,512),this.crossTileSymbolIndex=new Jk,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",Af()),PM().on(DM,this._rtlPluginLoaded),this.on("data",e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;let t=this.tileManagers[e.sourceId];if(!t)return;let r=t.getSource();if(r?.vectorLayerIds)for(let i in this._layers){let e=this._layers[i];e.source===r.id&&this._validateLayer(e)}})}_setInitialValues(){this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new Dv,this._imagesListDirty=!1,this._globalState={},this._serializedLayers={},this.stylesheet=null,this.light=null,this.sky=null,this.projection&&(this.projection.destroy(),delete this.projection),this._loaded=!1,this._changed=!1,this._updatedLayers={},this._updatedSources={},this._changedImages={},this._glyphsDidChange=!1,this._updatedPaintProps={},this._layerOrderChanged=!1,this._symbolPlacementTriggered=!1,this._placedProjectionTransition=void 0,this.crossTileSymbolIndex=new(this.crossTileSymbolIndex?.constructor||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(e,t){this._checkLoaded();let r=null===t?this.stylesheet.state?.[e]?.default??null:t;if(Yp(r,this._globalState[e]))return this;this._globalState[e]=r,this._applyGlobalStateChanges([e])}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();let t=[];for(let r in e)Yp(this._globalState[r],e[r].default)||(t.push(r),this._globalState[r]=e[r].default);this._applyGlobalStateChanges(t)}_applyGlobalStateChanges(e){if(0===e.length)return;let t=new Set,r={};for(let i of e){r[i]=this._globalState[i];for(let e in this._layers){let r=this._layers[e],n=r.getLayoutAffectingGlobalStateRefs(),a=r.getPaintAffectingGlobalStateRefs(),s=r.getVisibilityAffectingGlobalStateRefs();if(n.has(i)&&t.add(r.source),a.has(i))for(let{name:e,value:t}of a.get(i))this._updatePaintProperty(r,e,t);s?.has(i)&&(r.recalculateVisibility(),this._updateLayer(r))}}this.dispatcher.broadcast("UGS",r);for(let i in this.tileManagers)t.has(i)&&(this._reloadSource(i),this._changed=!0)}async loadURL(e,t={},r){this.fire(new GC("dataloading")),t.validate="boolean"!=typeof t.validate||t.validate,this._loadStyleRequest=new AbortController;let i=this._loadStyleRequest;try{let n=await this.map._requestManager.transformRequest(e,"Style");wf(i.signal);let a=await If(n,i);this._loadStyleRequest===i&&(this._loadStyleRequest=null),this._load(a.data,t,r)}catch(e){this._loadStyleRequest===i&&(this._loadStyleRequest=null),e&&!i.signal.aborted&&this.fire(new Lf(xp(e)))}}loadJSON(e,t={},r){this.fire(new GC("dataloading")),this._frameRequest=new AbortController,zC.frameAsync(this._frameRequest,this.map._ownerWindow).then(()=>{this._frameRequest=null,t.validate=!1!==t.validate,this._load(e,t,r)}).catch(()=>{})}loadEmpty(){this.fire(new GC("dataloading")),this._load(rL,{validate:!1})}_load(e,t,r){let i=t.transformStyle?t.transformStyle(r,e):e;if(!t.validate||!fv(this,i)){i={...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.glyphManager.setFontFaces(i["font-faces"]),this._createLayers(),this.light=new RF(this.stylesheet.light??{},this._globalState),this._setProjectionInternal(this.stylesheet.projection?.type||"mercator"),this.sky=new zF(this.stylesheet.sky,this._globalState),this.map.setTerrain(this.stylesheet.terrain??null,{validate:!1}),this.fire(new GC("data")),this.fire(new qC)}}_createLayers(){let e=rF(this.stylesheet.layers);this.setGlobalState(this.stylesheet.state??null),this.dispatcher.broadcast("SL",e),this._order=e.map(e=>e.id),this._layers={},this._serializedLayers=null;for(let t of e){let e=bA(t,this._globalState);if(e.setEventedParent(this,{layer:{id:t.id}}),this._layers[t.id]=e,Xv(e)&&this.tileManagers[e.source]){let r=t.paint?.["raster-fade-duration"]??e.paint.get("raster-fade-duration");this.tileManagers[e.source].setRasterFadeDuration(r)}}}async _loadSprite(e,t=!1,r=void 0){this.imageManager.setLoaded(!1);let i,n=new AbortController;this._spriteRequest=n;try{let r=await mF(e,this.map._requestManager,this.map.getPixelRatio(),n);if(!r)return;for(let e in r){let{loaded:i,removed:n}=this.imageManager.setSpriteImages(e,r[e]);this._markImagesChanged(n),t&&this._markImagesChanged(i)}}catch(e){i=e,n.signal.aborted||this.fire(new Lf(i))}finally{this._spriteRequest=null,this.imageManager.setLoaded(!0),t&&(this._changed=!0),this.dispatcher.broadcast("SI",this.imageManager.listImages()),this.fire(new GC("data")),r?.(i)}}_unloadSprite(){this._markImagesChanged(this.imageManager.removeAllSpriteImages()),this._imagesListDirty=!0,this._changed=!0,this.fire(new GC("data"))}_validateLayer(e){let t=this.tileManagers[e.source];if(!t)return;let r=e.sourceLayer;if(!r)return;let i=t.getSource();("geojson"===i.type||i.vectorLayerIds&&!i.vectorLayerIds.includes(r))&&this.fire(new Lf(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.tileManagers)if(!this.tileManagers[e].loaded())return!1;return this.imageManager.isLoaded()}_serializeByIds(e,t=!1){let r=this._serializedAllLayers();if(!e||0===e.length)return Object.values(t?Kp(r):r);let i=[];for(let n of e)if(r[n]){let e=t?Kp(r[n]):r[n];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 r of t){let t=this._layers[r];"custom"!==t.type&&(e[r]=t.serialize())}return e}hasTransitions(){if(this.light?.hasTransition()||this.sky?.hasTransition()||this.projection?.hasTransition())return!0;for(let e in this.tileManagers)if(this.tileManagers[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 t=this._changed;if(t){this._imagesListDirty&&=(this.dispatcher.broadcast("SI",this.imageManager.listImages()),!1);let t=Object.keys(this._updatedLayers),r=Object.keys(this._removedLayers);(t.length||r.length)&&this._updateWorkerLayers(t,r);for(let e in this._updatedSources){let t=this._updatedSources[e];if("reload"===t)this._reloadSource(e);else{if("clear"!==t)throw Error(`Invalid action ${t}`);this._clearSource(e)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(let i in this._updatedPaintProps)this._layers[i].updateTransitions(e);this._resetUpdates()}let r={};for(let n in this.tileManagers){let e=this.tileManagers[n];r[n]=e.used,e.used=!1}let i=this.imageManager.listImages();for(let n of this._order){let t=this._layers[n];t.recalculate(e,i),!t.isHidden(e.zoom)&&t.source&&(this.tileManagers[t.source].used=!0)}for(let n in r){let e=this.tileManagers[n];!!r[n]!=!!e.used&&e.fire(new ZC("data",{sourceDataType:"visibility",sourceId:n}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,t&&this.fire(new GC("data"))}_updateTilesForChangedImages(){let e=Object.keys(this._changedImages);if(e.length){for(let t in this.tileManagers)this.tileManagers[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(let e in this.tileManagers)this.tileManagers[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:t})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,t={}){this._checkLoaded();let r=this.serialize();if(e=t.transformStyle?t.transformStyle(r,e):e,(t.validate??1)&&fv(this,e))return!1;(e=Kp(e)).layers=rF(e.layers);let i=dF(r,e),n=this._getOperationsToPerform(i);if(n.unimplemented.length>0)throw Error(`Unimplemented: ${n.unimplemented.join(", ")}.`);if(0===n.operations.length)return!1;for(let a of n.operations)a();return this.stylesheet=e,this._serializedLayers=null,this.fire(new qC({style:this})),!0}_getOperationsToPerform(e){let t=[],r=[];for(let i of e)switch(i.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":t.push(()=>this.addLayer.apply(this,i.args));break;case"removeLayer":t.push(()=>this.removeLayer.apply(this,i.args));break;case"setPaintProperty":t.push(()=>this.setPaintProperty.apply(this,i.args));break;case"setLayoutProperty":t.push(()=>this.setLayoutProperty.apply(this,i.args));break;case"setFilter":t.push(()=>this.setFilter.apply(this,i.args));break;case"addSource":t.push(()=>this.addSource.apply(this,i.args));break;case"removeSource":t.push(()=>this.removeSource.apply(this,i.args));break;case"setLayerZoomRange":t.push(()=>this.setLayerZoomRange.apply(this,i.args));break;case"setLight":t.push(()=>this.setLight.apply(this,i.args));break;case"setGeoJSONSourceData":t.push(()=>this.setGeoJSONSourceData.apply(this,i.args));break;case"setGlyphs":t.push(()=>this.setGlyphs.apply(this,i.args));break;case"setFontFaces":t.push(()=>this.setFontFaces.apply(this,i.args));break;case"setSprite":t.push(()=>this.setSprite.apply(this,i.args));break;case"setTerrain":t.push(()=>this.map.setTerrain.apply(this,i.args));break;case"setSky":t.push(()=>this.setSky.apply(this,i.args));break;case"setProjection":this.setProjection.apply(this,i.args);break;case"setGlobalState":t.push(()=>this.setGlobalState.apply(this,i.args));break;case"setTransition":t.push(()=>{});break;default:r.push(i.command)}return{operations:t,unimplemented:r}}addImage(e,t){this.getImage(e)?this.fire(new Lf(Error(`An image named "${e}" already exists.`))):(this.imageManager.addImage(e,t),this._afterImageUpdated(e))}updateImage(e,t){this.imageManager.updateImage(e,t)}getImage(e){return this.imageManager.getImage(e)}setMissingImageResolver(e){this.imageManager.setMissingImageResolver(e)}removeImage(e){this.getImage(e)?(this.imageManager.removeImage(e),this._afterImageUpdated(e)):this.fire(new Lf(Error(`An image named "${e}" does not exist.`)))}_markImagesChanged(e){for(let t of e)this._changedImages[t]=!0}_afterImageUpdated(e){this._changedImages[e]=!0,this._imagesListDirty=!0,this._changed=!0,this.fire(new GC("data"))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,t,r={}){if(this._checkLoaded(),void 0!==this.tileManagers[e])throw Error(`Source "${e}" already exists.`);if(!t.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(t).join(", ")}.`);if(pv.has(t.type)&&this._validate(dv.source,`sources.${e}`,t,null,r))return;this.map?._collectResourceTiming&&(t.collectResourceTiming=!0);let i=this.tileManagers[e]=new HM(e,t,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(),void 0===this.tileManagers[e])throw Error(`There is no source with this ID=${e}`);for(let r in this._layers)if(this._layers[r].source===e)return this.fire(new Lf(Error(`Source "${e}" cannot be removed while layer "${r}" is using it.`)));let t=this.tileManagers[e];delete this.tileManagers[e],delete this._updatedSources[e],t.fire(new ZC("data",{sourceDataType:"metadata",sourceId:e})),t.setEventedParent(null),t.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,t){if(this._checkLoaded(),void 0===this.tileManagers[e])throw Error(`There is no source with this ID=${e}`);let r=this.tileManagers[e].getSource();if("geojson"!==r.type)throw Error(`geojsonSource.type is ${r.type}, which is !== 'geojson`);r.setData(t),this._changed=!0}getSource(e){return this.tileManagers[e]?.getSource()}addLayer(e,t,r={}){this._checkLoaded();let i,n=e.id;if(this.getLayer(n))return void this.fire(new Lf(Error(`Layer "${n}" already exists on this map.`)));if("custom"===e.type){if(mv(this,function(e){let t=[],r=e.id;return void 0===r&&t.push(new Nf(`layers.${r}`,null,'missing required property "id"')),void 0===e.render&&t.push(new Nf(`layers.${r}`,null,'missing required method "render"')),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push(new Nf(`layers.${r}`,null,'property "renderingMode" must be either "2d" or "3d"')),t}(e)))return;i=bA(e,this._globalState)}else{if("source"in e&&"object"==typeof e.source&&(this.addSource(n,e.source),e=jp(e=Kp(e),{source:n})),this._validate(dv.layer,`layers.${n}`,e,{arrayIndex:-1},r))return;i=bA(e,this._globalState),this._validateLayer(i),i.setEventedParent(this,{layer:{id:n}})}let a=t?this._order.indexOf(t):this._order.length;if(t&&-1===a)this.fire(new Lf(Error(`Cannot add layer "${n}" before non-existing layer "${t}".`)));else{if(this._order.splice(a,0,n),this._layerOrderChanged=!0,this._layers[n]=i,this._removedLayers[n]&&i.source&&"custom"!==i.type){let e=this._removedLayers[n];delete this._removedLayers[n],e.type===i.type?(this._updatedSources[i.source]="reload",this.tileManagers[i.source].pause()):this._updatedSources[i.source]="clear"}this._updateLayer(i),i.onAdd&&i.onAdd(this.map)}}moveLayer(e,t){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new Lf(Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===t)return;if(t&&!this._order.includes(t))return void this.fire(new Lf(Error(`Cannot move layer "${e}" before non-existing layer "${t}".`)));let r=this._order.indexOf(e);this._order.splice(r,1);let i=t?this._order.indexOf(t):this._order.length;this._order.splice(i,0,e),this._layerOrderChanged=!0}removeLayer(e){this._checkLoaded();let t=this._layers[e];if(!t)return void this.fire(new Lf(Error(`Cannot remove non-existing layer "${e}".`)));t.setEventedParent(null);let r=this._order.indexOf(e);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=t,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],"symbol"===t.type&&t.source&&this.tileManagers[t.source]?.resetMaxContentElevation(),t.onRemove&&t.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,t,r){this._checkLoaded();let i=this.getLayer(e);i?(i.minzoom!==t||i.maxzoom!==r)&&(null!=t&&(i.minzoom=t),null!=r&&(i.maxzoom=r),this._updateLayer(i)):this.fire(new Lf(Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,t,r={}){this._checkLoaded();let i=this.getLayer(e);if(i){if(!Yp(i.filter,t)){if(null==t)return i.setFilter(void 0),void this._updateLayer(i);this._validate(dv.filter,`layers.${i.id}.filter`,t,null,r)||(i.setFilter(Kp(t)),this._updateLayer(i))}}else this.fire(new Lf(Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return Kp(this.getLayer(e).filter)}setLayoutProperty(e,t,r,i={}){this._checkLoaded();let n=this.getLayer(e);n?Yp(n.getLayoutProperty(t),r)||(n.setLayoutProperty(t,r,i),this._updateLayer(n)):this.fire(new Lf(Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,t){let r=this.getLayer(e);if(r)return r.getLayoutProperty(t);this.fire(new Lf(Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,t,r,i={}){this._checkLoaded();let n=this.getLayer(e);n?Yp(n.getPaintProperty(t),r)||this._updatePaintProperty(n,t,r,i):this.fire(new Lf(Error(`Cannot style non-existing layer "${e}".`)))}_updatePaintProperty(e,t,r,i={}){e.setPaintProperty(t,r,i)&&this._updateLayer(e),Xv(e)&&"raster-fade-duration"===t&&this.tileManagers[e.source].setRasterFadeDuration(r),this._changed=!0,this._updatedPaintProps[e.id]=!0,"symbol"===e.type&&this.triggerSymbolPlacement(),this._serializedLayers=null}getPaintProperty(e,t){return this.getLayer(e).getPaintProperty(t)}setFeatureState(e,t){this._checkLoaded();let r=e.source,i=e.sourceLayer,n=this.tileManagers[r];if(void 0===n)return void this.fire(new Lf(Error(`The source '${r}' does not exist in the map's style.`)));let a=n.getSource().type;if("geojson"===a&&i)return void this.fire(new Lf(Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===a&&!i)return void this.fire(new Lf(Error("The sourceLayer parameter must be provided for vector source types.")));if(void 0===e.id)return void this.fire(new Lf(Error("The feature id parameter must be provided.")));let s=["__proto__","constructor","prototype"];t&&Object.keys(t).some(e=>s.includes(e))?this.fire(new Lf(Error(`The feature state should not include one of the following keys: ${s}`))):n.setFeatureState(i,e.id,t)}removeFeatureState(e,t){this._checkLoaded();let r=e.source,i=this.tileManagers[r];if(void 0===i)return void this.fire(new Lf(Error(`The source '${r}' does not exist in the map's style.`)));let n=i.getSource().type,a="vector"===n?e.sourceLayer:void 0;"vector"!==n||a?t&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new Lf(Error("A feature id is required to remove its specific state property."))):i.removeFeatureState(a,e.id,t):this.fire(new Lf(Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();let t=e.source,r=e.sourceLayer,i=this.tileManagers[t];if(void 0!==i){if("vector"!==i.getSource().type||r)return void 0===e.id&&this.fire(new Lf(Error("The feature id parameter must be provided."))),i.getFeatureState(r,e.id);this.fire(new Lf(Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new Lf(Error(`The source '${t}' does not exist in the map's style.`)))}getTransition(){return jp({duration:300,delay:0},this.stylesheet?.transition)}serialize(){if(!this._loaded)return;let e=Hp(this.tileManagers,e=>e.serialize()),t=this._serializeByIds(this._order,!0),r=this.map.getTerrain()||void 0,i=this.stylesheet;return Xp({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,"font-faces":i["font-faces"],transition:i.transition,projection:i.projection,state:i.state,sources:e,layers:t,terrain:r},e=>void 0!==e)}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&"raster"!==this.tileManagers[e.source].getSource().type&&(this._updatedSources[e.source]="reload",this.tileManagers[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){let t=e=>"fill-extrusion"===this._layers[e].type,r={},i=[];for(let a=this._order.length-1;a>=0;a--){let n=this._order[a];if(t(n)){r[n]=a;for(let t of e){let e=t[n];if(e)for(let t of e)i.push(t)}}}i.sort((e,t)=>t.intersectionZ-e.intersectionZ);let n=[];for(let a=this._order.length-1;a>=0;a--){let s=this._order[a];if(t(s))for(let e=i.length-1;e>=0;e--){let t=i[e].feature;if(r[t.layer.id]<a)break;n.push(t),i.pop()}else for(let t of e){let e=t[s];if(e)for(let t of e)n.push(t.feature)}}return n}queryRenderedFeatures(e,t,r){t?.filter&&this._validate(dv.filter,"queryRenderedFeatures.filter",t.filter,null,t);let i={};if(t?.layers){if(!(Array.isArray(t.layers)||t.layers instanceof Set))return this.fire(new Lf(Error("parameters.layers must be an Array or a Set of strings"))),[];for(let e of t.layers){let t=this._layers[e];if(!t)return this.fire(new Lf(Error(`The layer '${e}' does not exist in the map's style and cannot be queried for features.`))),[];i[t.source]=!0}}let n=[];t.availableImages=this.imageManager.listImages();let a=this._serializedAllLayers(),s=t.layers instanceof Set?t.layers:Array.isArray(t.layers)?new Set(t.layers):null,o={...t,layers:s,globalState:this._globalState};for(let l in this.tileManagers)(!t.layers||i[l])&&n.push(WF(this.tileManagers[l],this._layers,a,e,o,r,this.map.terrain?(e,t,r)=>this.map.terrain.getElevation(e,t,r):void 0));return this.placement&&n.push(HF(this._layers,a,this.tileManagers,e,o,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(n)}querySourceFeatures(e,t){t?.filter&&this._validate(dv.filter,"querySourceFeatures.filter",t.filter,null,t);let r=this.tileManagers[e];return r?function(e,t){let r=e.getRenderableIds().map(t=>e.getTileByID(t)),i=[],n={};for(let a of r){let e=a.tileID.canonical.key;n[e]||(n[e]=!0,a.querySourceFeatures(i,t))}return i}(r,t?{...t,globalState:this._globalState}:{globalState:this._globalState}):[]}getLight(){return this.light.getLight()}setLight(e,t={}){this._checkLoaded();let r=this.light.getLight(),i=!1;for(let a in e)if(!Yp(e[a],r[a])){i=!0;break}if(!i)return;let n={now:OC(),transition:jp({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(e,t),this.light.updateTransitions(n)}getProjection(){return this.stylesheet?.projection}setProjection(e){this._checkLoaded();let t=e??{type:"mercator"};if(this.stylesheet.projection=e,this.projection){if(this.projection.name===t.type)return;this.projection.destroy(),delete this.projection}this._setProjectionInternal(t.type)}getSky(){return this.stylesheet?.sky}setSky(e,t={}){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 a in e)if(!Yp(e[a],r[a])){i=!0;break}if(!i)return;let n={now:OC(),transition:jp({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=e,this.sky.setSky(e,t),this.sky.updateTransitions(n)}_setProjectionInternal(e){let t=function(e,t,r){let i={constrainOverride:t};if(Array.isArray(e)){let t=new PR({type:e},r);return{projection:t,transform:new QR(i),cameraHelper:new tL(t)}}switch(e){case"mercator":return{projection:new nR,transform:new _R(i),cameraHelper:new SR};case"globe":{let e=new PR({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]},{});return{projection:e,transform:new QR(i),cameraHelper:new tL(e)}}case"vertical-perspective":return{projection:new AR,transform:new YR(i),cameraHelper:new eL};default:return Qp(`Unknown projection name: ${e}. Falling back to mercator projection.`),{projection:new nR,transform:new _R(i),cameraHelper:new SR}}}(e,this.map._camera?.transform.constrainOverride,this._globalState);this.projection=t.projection,this.map.migrateProjection(t.transform,t.cameraHelper);for(let r in this.tileManagers)this.tileManagers[r].reload()}_validate(e,t,r,i,n={}){return!1!==n.validate&&gv(this,e,{key:t,style:this.serialize(),value:r,...i},n)}_remove(e=!0){this._frameRequest&&=(this._frameRequest.abort(),null),this._loadStyleRequest&&=(this._loadStyleRequest.abort(),null),this._spriteRequest&&=(this._spriteRequest.abort(),null),PM().off(DM,this._rtlPluginLoaded);for(let t in this._layers)this._layers[t].setEventedParent(null);for(let t in this.tileManagers){let e=this.tileManagers[t];e.setEventedParent(null),e.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),e&&this.dispatcher.broadcast("RM",void 0),this.dispatcher.remove(e)}_clearSource(e){this.tileManagers[e].clearTiles()}_reloadSource(e){this.tileManagers[e].resume(),this.tileManagers[e].reload()}_updateSources(e){for(let t in this.tileManagers)this.tileManagers[t].update(e,this.map.terrain)}_generateCollisionBoxes(){for(let e in this.tileManagers)this._reloadSource(e)}triggerSymbolPlacement(){this._symbolPlacementTriggered=!0}_placementInputsChanged(e,t,r){let i=this.pauseablePlacement;return!i||this._symbolPlacementTriggered||this._placedProjectionTransition!==this.projection?.transitionState||i._showCollisionBoxes!==t||i.placement.collisionGroups.crossSourceCollisions!==r||i.placement.transform.renderWorldCopies!==e.renderWorldCopies||!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]}(i.placement.transform.modelViewProjectionMatrix,e.modelViewProjectionMatrix)}_updatePlacement(e,t,r,i,n=!1){let a=!1,s=!1,o={};for(let c of this._order){let t=this._layers[c];if("symbol"!==t.type)continue;if(!o[t.source]){let e=this.tileManagers[t.source];o[t.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(t,o[t.source],e.center.lng);a||=r}this.crossTileSymbolIndex.pruneUnusedLayers(this._order),n||=this._layerOrderChanged||0===r;let l=a||this._placementInputsChanged(e,t,i),u=this.pauseablePlacement?.isDone()&&!this.placement.stillRecent(OC(),e.zoom);if((n||!this.pauseablePlacement||u&&(l||this.placement.stale))&&(this._symbolPlacementTriggered=!1,this._placedProjectionTransition=this.projection?.transitionState,this.pauseablePlacement=new $k(e,this.map.terrain,this._order,n,t,r,i,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?l&&this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,o),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(OC()),s=!0),a&&this.pauseablePlacement.placement.setStale()),s||a)for(let c of this._order){let e=this._layers[c];"symbol"===e.type&&this.placement.updateLayerOpacities(e,o[e.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(OC())}_releaseSymbolFadeTiles(){for(let e in this.tileManagers)this.tileManagers[e].releaseSymbolFadeTiles()}async getImages(e,t){let r=await this.imageManager.getImages(t.icons);this._updateTilesForChangedImages();let i=this.tileManagers[t.source];return i&&i.setDependencies(t.tileID.key,t.type,t.icons),r}async getGlyphs(e,t){let r=await this.glyphManager.getGlyphs(t.stacks),i=this.tileManagers[t.source];return i&&i.setDependencies(t.tileID.key,t.type,[""]),r}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,t={}){this._checkLoaded(),(!e||!this._validate(dv.glyphs,"glyphs",e,null,t))&&(this._changed=!0,this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}getFontFaces(){return this.stylesheet["font-faces"]||null}setFontFaces(e){this._checkLoaded(),this._changed=!0,this._glyphsDidChange=!0,this.stylesheet["font-faces"]=e,this.glyphManager.setFontFaces(e)}async getDashes(e,t){let r={};for(let[i,n]of Object.entries(t.dashes))r[i]=this.lineAtlas.getDash(n.dasharray,n.round);return r}addSprite(e,t,r={},i){this._checkLoaded();let n=[{id:e,url:t}],a=[...pF(this.stylesheet.sprite),...n];this._validate(dv.sprite,"sprite",a,null,r)||(this.stylesheet.sprite=a,this._loadSprite(n,!0,i))}removeSprite(e){this._checkLoaded();let t=pF(this.stylesheet.sprite);if(!t.find(t=>t.id===e))return void this.fire(new Lf(Error(`Sprite "${e}" doesn't exists on this map.`)));let r=this.imageManager.removeSpriteImages(e);this._markImagesChanged(r),t.splice(t.findIndex(t=>t.id===e),1),this.stylesheet.sprite=t.length>0?t:void 0,this._imagesListDirty=!0,this._changed=!0,this.fire(new GC("data"))}getSprite(){return pF(this.stylesheet.sprite)}setSprite(e,t={},r){this._checkLoaded(),(!e||!this._validate(dv.sprite,"sprite",e,null,t))&&(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,r):(this._unloadSprite(),r&&r(null)))}destroy(){this._frameRequest&&=(this._frameRequest.abort(),null),this._loadStyleRequest&&=(this._loadStyleRequest.abort(),null),this._spriteRequest&&=(this._spriteRequest.abort(),null);for(let e in this.tileManagers){let t=this.tileManagers[e];t.setEventedParent(null),t.onRemove(this.map)}this.tileManagers={},this.imageManager&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this.patternAtlas.destroy()),this.glyphManager&&this.glyphManager.destroy();for(let e in this._layers){let t=this._layers[e];t.setEventedParent(null),t.onRemove&&t.onRemove(this.map)}this._setInitialValues(),this.setEventedParent(null),this.dispatcher.unregisterMessageHandler("GG"),this.dispatcher.unregisterMessageHandler("GI"),this.dispatcher.unregisterMessageHandler("GDA"),this.dispatcher.remove(!0),this._listeners={},this._oneTimeListeners={}}};const nL=ex([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);var aL=class{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,t,r,i,n,a,s,o,l){this.context=e;let u=this.boundPaintVertexBuffers.length!==i.length;for(let c=0;!u&&c<i.length;c++)this.boundPaintVertexBuffers[c]!==i[c]&&(u=!0);!this.vao||this.boundProgram!==t||this.boundLayoutVertexBuffer!==r||u||this.boundIndexBuffer!==n||this.boundVertexOffset!==a||this.boundDynamicVertexBuffer!==s||this.boundDynamicVertexBuffer2!==o||this.boundDynamicVertexBuffer3!==l?this.freshBind(t,r,i,n,a,s,o,l):e.bindVertexArray.set(this.vao)}freshBind(e,t,r,i,n,a,s,o){let l=e.numAttributes,u=this.context,c=u.gl;this.vao&&this.destroy(),this.vao=u.createVertexArray(),u.bindVertexArray.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=t,this.boundPaintVertexBuffers=r,this.boundIndexBuffer=i,this.boundVertexOffset=n,this.boundDynamicVertexBuffer=a,this.boundDynamicVertexBuffer2=s,this.boundDynamicVertexBuffer3=o,t.enableAttributes(c,e);for(let h of r)h.enableAttributes(c,e);a&&a.enableAttributes(c,e),s&&s.enableAttributes(c,e),o&&o.enableAttributes(c,e),t.bind(),t.setVertexAttribPointers(c,e,n);for(let h of r)h.bind(),h.setVertexAttribPointers(c,e,n);a&&(a.bind(),a.setVertexAttribPointers(c,e,n)),i&&i.bind(),s&&(s.bind(),s.setVertexAttribPointers(c,e,n)),o&&(o.bind(),o.setVertexAttribPointers(c,e,n)),u.currentNumAttributes=l}destroy(){this.vao&&=(this.context.deleteVertexArray(this.vao),null)}};const sL=(e,t,r,i,n)=>({u_texture:0,u_ele_delta:e,u_fog_matrix:t,u_fog_color:r?r.properties.get("fog-color"):Rm.white,u_fog_ground_blend:r?r.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:n?0:r?r.calculateFogBlendOpacity(i):0,u_horizon_color:r?r.properties.get("horizon-color"):Rm.white,u_horizon_fog_blend:r?r.properties.get("horizon-fog-blend"):1,u_is_globe_mode:+!!n}),oL=e=>({u_ele_delta:e}),lL={ProjectionUBO:0,TerrainUBO:1,FrameUBO:2};const uL={float:[1,1],int:[1,1],vec2:[2,2],vec4:[4,4],mat4:[16,4]};function cL(e){let t={},r=0;for(let{name:i,type:n}of e){let[e,a]=uL[n];r=Math.ceil(r/a)*a,t[i]=r,r+=e}return{offsets:t,contentWords:r,sizeWords:4*Math.ceil(r/4)}}var hL=class{constructor(e,t,r){this.context=e,this.binding=t,this.contentWords=r.contentWords;let i=e.gl;this.buffer=i.createBuffer(),i.bindBuffer(i.UNIFORM_BUFFER,this.buffer),i.bufferData(i.UNIFORM_BUFFER,4*r.sizeWords,i.DYNAMIC_DRAW),i.bindBufferBase(i.UNIFORM_BUFFER,t,this.buffer),this.uploaded=new Float32Array(r.sizeWords),this.pending=new Float32Array(r.sizeWords),this.uploadedWords=new Uint32Array(this.uploaded.buffer),this.pendingWords=new Uint32Array(this.pending.buffer),this.hasData=!1,this.bindingDirty=!1}upload(){let e=this.context.gl,t=!this.hasData;if(!t){let e=this.pendingWords,r=this.uploadedWords;for(let i=0;i<this.contentWords;i++)if(e[i]!==r[i]){t=!0;break}}this.bindingDirty&&=(e.bindBufferBase(e.UNIFORM_BUFFER,this.binding,this.buffer),!1),t&&(e.bindBuffer(e.UNIFORM_BUFFER,this.buffer),e.bufferSubData(e.UNIFORM_BUFFER,0,this.pending),this.uploaded.set(this.pending),this.hasData=!0)}destroy(){let e=this.context.gl;this.buffer&&(e.deleteBuffer(this.buffer),delete this.buffer)}};const dL=cL([{name:"u_projection_matrix",type:"mat4"},{name:"u_projection_fallback_matrix",type:"mat4"},{name:"u_projection_tile_mercator_coords",type:"vec4"},{name:"u_projection_clipping_plane",type:"vec4"},{name:"u_projection_transition",type:"float"},{name:"u_projection_clip_antimeridian",type:"int"}]),pL=dL.offsets;const fL=cL([{name:"u_terrain_matrix",type:"mat4"},{name:"u_terrain_unpack",type:"vec4"},{name:"u_terrain_dim",type:"float"},{name:"u_terrain_exaggeration",type:"float"}]),mL=fL.offsets;function gL(e){let t=[];for(let r of e){if(null===r)continue;let e=r.split(" ");t.push(e.pop())}return t}var yL=class{constructor(e,t,r,i,n,a,s,o,l=[]){let u=e.gl;this.program=u.createProgram();let c=gL(t.staticAttributes),h=r?r.getBinderAttributes():[],d=c.concat(h),p=eR.prelude.staticUniforms?gL(eR.prelude.staticUniforms):[],f=t.staticUniforms?gL(t.staticUniforms):[],m=r?r.getBinderUniforms():[],g=p.concat(f).concat(m),y=[];for(let D of g)y.includes(D)||y.push(D);let _=r?r.defines():[];_.unshift("#version 300 es"),n&&_.push("#define OVERDRAW_INSPECTOR;"),a&&_.push("#define TERRAIN3D;"),o&&_.push(o),l&&_.push(...l);let v=_.concat(eR.prelude.fragmentSource,s.fragmentSource,t.fragmentSource).join("\n"),x=_.concat(eR.prelude.vertexSource,s.vertexSource,t.vertexSource).join("\n"),b=u.createShader(u.FRAGMENT_SHADER);if(u.isContextLost())return void(this.failedToCreate=!0);u.shaderSource(b,v),u.compileShader(b),u.attachShader(this.program,b);let w=u.createShader(u.VERTEX_SHADER);if(u.isContextLost())return void(this.failedToCreate=!0);u.shaderSource(w,x),u.compileShader(w),u.attachShader(this.program,w),this.attributes={};let E={};if(this.numAttributes=d.length,u.linkProgram(this.program),!u.getProgramParameter(this.program,u.LINK_STATUS)){if(u.isContextLost())return void(this.failedToCreate=!0);throw u.getShaderParameter(b,u.COMPILE_STATUS)?u.getShaderParameter(w,u.COMPILE_STATUS)?Error(`Program failed to link: ${u.getProgramInfoLog(this.program)}`):Error(`Could not compile vertex shader: ${u.getShaderInfoLog(w)}`):Error(`Could not compile fragment shader: ${u.getShaderInfoLog(b)}`)}!function(e,t){for(let[r,i]of Object.entries(lL)){let n=e.getUniformBlockIndex(t,r);n!==e.INVALID_INDEX&&e.uniformBlockBinding(t,n,i)}}(u,this.program);let S=function(e,t){let r=new Set([e.INT,e.INT_VEC2,e.INT_VEC3,e.INT_VEC4,e.UNSIGNED_INT,e.UNSIGNED_INT_VEC2,e.UNSIGNED_INT_VEC3,e.UNSIGNED_INT_VEC4]),i=new Set,n=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let a=0;a<n;a++){let n=e.getActiveAttrib(t,a);n&&r.has(n.type)&&i.add(n.name)}return i}(u,this.program);for(let D of d){if(!D)continue;let e=u.getAttribLocation(this.program,D);e>=0&&(this.attributes[D]={location:e,isInteger:S.has(D)})}u.deleteShader(w),u.deleteShader(b);for(let D of y)if(D&&!E[D]){let e=u.getUniformLocation(this.program,D);e&&(E[D]=e)}this.fixedUniforms=i(e,E),this.terrainUniforms=((e,t)=>({u_depth:new yb(e,t.u_depth),u_terrain:new yb(e,t.u_terrain)}))(e,E),this.binderUniforms=r?r.getUniforms(e,E):[]}draw(e,t,r,i,n,a,s,o,l,u,c,h,d,p,f,m,g,y,_){let v=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(r),e.setStencilMode(i),e.setColorMode(n),e.setCullFace(a),o){e.activeTexture.set(v.TEXTURE2),v.bindTexture(v.TEXTURE_2D,o.depthTexture),e.activeTexture.set(v.TEXTURE3),v.bindTexture(v.TEXTURE_2D,o.texture);for(let e in this.terrainUniforms)this.terrainUniforms[e].set(o[e]);!function(e,t){let r=e.pending;r.set(t.u_terrain_matrix,mL.u_terrain_matrix),r.set(t.u_terrain_unpack,mL.u_terrain_unpack),r[mL.u_terrain_dim]=t.u_terrain_dim,r[mL.u_terrain_exaggeration]=t.u_terrain_exaggeration,e.upload()}(e.terrainUniformBuffer,o)}if(l&&function(e,t){let r=e.pending;r.set(t.mainMatrix,pL.u_projection_matrix),r.set(t.fallbackMatrix,pL.u_projection_fallback_matrix),r.set(t.tileMercatorCoords,pL.u_projection_tile_mercator_coords),r.set(t.clippingPlane,pL.u_projection_clipping_plane),r[pL.u_projection_transition]=t.projectionTransition,e.pendingWords[pL.u_projection_clip_antimeridian]=+!!t.clipAntimeridian,e.upload()}(e.projectionUniformBuffer,l),s)for(let b in this.fixedUniforms)this.fixedUniforms[b].set(s[b]);m&&m.setUniforms(e,this.binderUniforms,p,{zoom:f});let x=0;switch(t){case v.LINES:x=2;break;case v.TRIANGLES:x=3;break;case v.LINE_STRIP:x=1}for(let b of d.get())b.vaos||={},b.vaos[u]||=new aL,b.vaos[u].bind(e,this,c,m?m.getPaintVertexBuffers():[],h,b.vertexOffset,g,y,_),v.drawElements(t,b.primitiveLength*x,v.UNSIGNED_SHORT,b.primitiveOffset*x*2)}};function _L(e,t,r){let i=1/vp(r,1,t.transform.tileZoom),n=2**r.tileID.overscaledZ,a=r.tileSize*2**t.transform.tileZoom/n,s=a*(r.tileID.canonical.x+r.tileID.wrap*n),o=a*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,o>>16],u_pixel_coord_lower:[65535&s,65535&o]}}const vL=(e,t,r,i)=>{let n=e.style.light,a=n.getCartesianPosition(),s=Cd();"viewport"===n.properties.get("anchor")&&function(e,t){var r=Math.sin(t),i=Math.cos(t);e[0]=i,e[1]=r,e[2]=0,e[3]=-r,e[4]=i,e[5]=0,e[6]=0,e[7]=0,e[8]=1}(s,e.transform.bearingInRadians),function(e,t,r){var i=t[0],n=t[1],a=t[2];e[0]=i*r[0]+n*r[3]+a*r[6],e[1]=i*r[1]+n*r[4]+a*r[7],e[2]=i*r[2]+n*r[5]+a*r[8]}(a,a,s);let o=e.transform.transformLightDirection(a),l=n.properties.get("color");return{u_lightpos:a,u_lightpos_globe:o,u_lightintensity:n.properties.get("intensity"),u_lightcolor:[l.r,l.g,l.b],u_vertical_gradient:+t,u_opacity:r,u_fill_translate:i}},xL=(e,t,r,i,n,a,s)=>jp(vL(e,t,r,i),_L(a,e,s),{u_height_factor:-(2**n.overscaledZ)/s.tileSize/8}),bL=(e,t,r,i,n)=>jp(_L(t,e,r),{u_fill_translate:i,u_sdf_pattern:+!!n}),wL=e=>({u_fill_translate:e}),EL=e=>({u_fill_translate:e}),SL=(e,t,r,i,n)=>bL(e,t,r,i,n),DL=(e,t,r,i,n)=>{let a,s,o=e.transform,l=0;if("map"===r.paint.get("circle-pitch-alignment")){let e=vp(t,1,o.zoom);a=!0,s=[e,e],l=e/(_p*2**t.tileID.overscaledZ)*2*Math.PI*n}else a=!1,s=o.pixelsToGLUnits;return{u_scale_with_map:+("map"===r.paint.get("circle-pitch-scale")),u_pitch_with_map:+a,u_extrude_scale:s,u_globe_extrude_scale:l,u_translate:i}},TL=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),AL=(e,t,r,i)=>{let n=vp(e,1,t)/(_p*2**e.tileID.overscaledZ)*2*Math.PI*i;return{u_extrude_scale:vp(e,1,t),u_intensity:r,u_globe_extrude_scale:n}},PL=(e,t,r,i)=>{let n=Fd();return Vd(n,0,e.width,e.height,0,0,1),{u_matrix:n,u_image:r,u_color_ramp:i,u_opacity:t.paint.get("heatmap-opacity")}},IL=(e,t,r)=>{let i,n=r.paint.get("hillshade-accent-color");switch(r.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=r.getIlluminationProperties();for(let s=0;s<a.directionRadians.length;s++)"viewport"===r.paint.get("hillshade-illumination-anchor")&&(a.directionRadians[s]+=e.transform.bearingInRadians);return{u_image:0,u_latrange:FL(e,t.tileID),u_exaggeration:r.paint.get("hillshade-exaggeration"),u_altitudes:a.altitudeRadians,u_azimuths:a.directionRadians,u_accent:n,u_method:i,u_highlights:a.highlightColor,u_shadows:a.shadowColor}},CL=(e,t)=>{let r=t.stride,i=Fd();return Vd(i,0,_p,-_p,0,0,1),zd(i,i,[0,-_p,0]),{u_matrix:i,u_image:1,u_dimension:[r,r],u_zoom:e.overscaledZ,u_unpack:t.getUnpackVector()}};function FL(e,t){let r=2**t.canonical.z,i=t.canonical.y;return[new pS(0,i/r).toLngLat().lat,new pS(0,(i+1)/r).toLngLat().lat]}const ML=(e,t,r=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:r,u_opacity:e.paint.get("color-relief-opacity")}),kL=(e,t,r,i)=>{let n=e.transform;return{u_translation:$L(e,t,r),u_ratio:i/vp(t,1,n.zoom)}},RL=(e,t,r,i,n)=>jp(kL(e,t,r,i),{u_image:0,u_image_height:n}),LL=(e,t,r,i,n)=>{let a=e.transform,s=OL(t,a);return{u_translation:$L(e,t,r),u_texsize:t.imageAtlasTexture.size,u_ratio:i/vp(t,1,a.zoom),u_image:0,u_scale:[s,n.fromScale,n.toScale],u_fade:n.t}},zL=(e,t,r,i,n)=>{let a=OL(t,e.transform);return jp(kL(e,t,r,i),{u_tileratio:a,u_crossfade_from:n.fromScale,u_crossfade_to:n.toScale,u_image:0,u_mix:n.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})},BL=(e,t,r,i,n,a)=>{let s=OL(t,e.transform);return jp(kL(e,t,r,i),{u_image:0,u_image_height:a,u_tileratio:s,u_crossfade_from:n.fromScale,u_crossfade_to:n.toScale,u_image_dash:1,u_mix:n.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})};function OL(e,t){return 1/vp(e,1,t.tileZoom)}function $L(e,t,r){return Tp(e.transform,t,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}const NL=(e,t,r,i,n,a,s,o,l,u,c,h,d,p,f)=>({u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_rotate_symbol:+r,u_label_plane_matrix:o,u_coord_matrix:l,u_is_text:+c,u_pitch_with_map:+i,u_is_along_line:n,u_is_variable_anchor:a,u_texsize:h,u_texture:0,u_translation:u,u_pitched_scale:d,u_is_offset:p,u_height_anchor_ground:+f}),jL=(e,t,r,i,n,a,s,o,l,u,c,h,d,p,f,m)=>{let g=s.transform;return jp(NL(e,t,r,i,n,a,0,o,l,u,c,h,p,f,m),{u_gamma_scale:i?Math.cos(g.pitch*Math.PI/180)*g.cameraToCenterDistance:1,u_is_halo:+!!d,u_is_plain:1})},VL=(e,t,r,i,n,a,s,o,l,u,c,h,d,p,f)=>jp(jL(e,t,r,i,n,a,s,o,l,u,!0,c,!0,d,p,f),{u_texsize_icon:h,u_texture_icon:1}),UL=(e,t)=>({u_opacity:e,u_color:t}),qL=(e,t,r,i,n)=>jp(function(e,t,r,i){let n=r.patternAtlas.getPattern(e.from.toString()),a=r.patternAtlas.getPattern(e.to.toString()),{width:s,height:o}=r.patternAtlas.getPixelSize(),l=2**i.tileID.overscaledZ,u=i.tileSize*2**r.transform.tileZoom/l,c=u*(i.tileID.canonical.x+i.tileID.wrap*l),h=u*i.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:n.tl,u_pattern_br_a:n.br,u_pattern_tl_b:a.tl,u_pattern_br_b:a.br,u_texsize:[s,o],u_mix:t.t,u_pattern_size_a:n.displaySize,u_pattern_size_b:a.displaySize,u_scale_a:t.fromScale,u_scale_b:t.toScale,u_tile_units_to_pixels:1/vp(i,1,r.transform.tileZoom),u_pixel_coord_upper:[c>>16,h>>16],u_pixel_coord_lower:[65535&c,65535&h]}}(r,n,t,i),{u_opacity:e}),GL=(e,t)=>({}),ZL={fillExtrusion:(e,t)=>({u_lightpos:new xb(e,t.u_lightpos),u_lightpos_globe:new xb(e,t.u_lightpos_globe),u_lightintensity:new _b(e,t.u_lightintensity),u_lightcolor:new xb(e,t.u_lightcolor),u_vertical_gradient:new _b(e,t.u_vertical_gradient),u_opacity:new _b(e,t.u_opacity),u_fill_translate:new vb(e,t.u_fill_translate)}),fillExtrusionPattern:(e,t)=>({u_lightpos:new xb(e,t.u_lightpos),u_lightpos_globe:new xb(e,t.u_lightpos_globe),u_lightintensity:new _b(e,t.u_lightintensity),u_lightcolor:new xb(e,t.u_lightcolor),u_vertical_gradient:new _b(e,t.u_vertical_gradient),u_height_factor:new _b(e,t.u_height_factor),u_opacity:new _b(e,t.u_opacity),u_fill_translate:new vb(e,t.u_fill_translate),u_image:new yb(e,t.u_image),u_texsize:new vb(e,t.u_texsize),u_pixel_coord_upper:new vb(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new vb(e,t.u_pixel_coord_lower),u_scale:new xb(e,t.u_scale),u_fade:new _b(e,t.u_fade)}),fill:(e,t)=>({u_fill_translate:new vb(e,t.u_fill_translate)}),fillPattern:(e,t)=>({u_image:new yb(e,t.u_image),u_texsize:new vb(e,t.u_texsize),u_pixel_coord_upper:new vb(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new vb(e,t.u_pixel_coord_lower),u_scale:new xb(e,t.u_scale),u_fade:new _b(e,t.u_fade),u_sdf_pattern:new yb(e,t.u_sdf_pattern),u_fill_translate:new vb(e,t.u_fill_translate)}),fillOutline:(e,t)=>({u_fill_translate:new vb(e,t.u_fill_translate)}),fillOutlinePattern:(e,t)=>({u_image:new yb(e,t.u_image),u_texsize:new vb(e,t.u_texsize),u_pixel_coord_upper:new vb(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new vb(e,t.u_pixel_coord_lower),u_scale:new xb(e,t.u_scale),u_fade:new _b(e,t.u_fade),u_sdf_pattern:new yb(e,t.u_sdf_pattern),u_fill_translate:new vb(e,t.u_fill_translate)}),circle:(e,t)=>({u_scale_with_map:new yb(e,t.u_scale_with_map),u_pitch_with_map:new yb(e,t.u_pitch_with_map),u_extrude_scale:new vb(e,t.u_extrude_scale),u_globe_extrude_scale:new _b(e,t.u_globe_extrude_scale),u_translate:new vb(e,t.u_translate)}),collisionBox:GL,collisionCircle:GL,debug:(e,t)=>({u_color:new wb(e,t.u_color),u_overlay:new yb(e,t.u_overlay),u_overlay_scale:new _b(e,t.u_overlay_scale)}),depth:GL,clippingMask:GL,heatmap:(e,t)=>({u_extrude_scale:new _b(e,t.u_extrude_scale),u_intensity:new _b(e,t.u_intensity),u_globe_extrude_scale:new _b(e,t.u_globe_extrude_scale)}),heatmapTexture:(e,t)=>({u_matrix:new Tb(e,t.u_matrix),u_image:new yb(e,t.u_image),u_color_ramp:new yb(e,t.u_color_ramp),u_opacity:new _b(e,t.u_opacity)}),hillshade:(e,t)=>({u_image:new yb(e,t.u_image),u_latrange:new vb(e,t.u_latrange),u_exaggeration:new _b(e,t.u_exaggeration),u_altitudes:new Sb(e,t.u_altitudes),u_azimuths:new Sb(e,t.u_azimuths),u_accent:new wb(e,t.u_accent),u_method:new yb(e,t.u_method),u_shadows:new Eb(e,t.u_shadows),u_highlights:new Eb(e,t.u_highlights)}),hillshadePrepare:(e,t)=>({u_matrix:new Tb(e,t.u_matrix),u_image:new yb(e,t.u_image),u_dimension:new vb(e,t.u_dimension),u_zoom:new _b(e,t.u_zoom),u_unpack:new bb(e,t.u_unpack)}),colorRelief:(e,t)=>({u_image:new yb(e,t.u_image),u_unpack:new bb(e,t.u_unpack),u_dimension:new vb(e,t.u_dimension),u_elevation_stops:new yb(e,t.u_elevation_stops),u_color_stops:new yb(e,t.u_color_stops),u_color_ramp_size:new yb(e,t.u_color_ramp_size),u_opacity:new _b(e,t.u_opacity)}),line:(e,t)=>({u_translation:new vb(e,t.u_translation),u_ratio:new _b(e,t.u_ratio)}),lineGradient:(e,t)=>({u_translation:new vb(e,t.u_translation),u_ratio:new _b(e,t.u_ratio),u_image:new yb(e,t.u_image),u_image_height:new _b(e,t.u_image_height)}),linePattern:(e,t)=>({u_translation:new vb(e,t.u_translation),u_texsize:new vb(e,t.u_texsize),u_ratio:new _b(e,t.u_ratio),u_image:new yb(e,t.u_image),u_scale:new xb(e,t.u_scale),u_fade:new _b(e,t.u_fade)}),lineSDF:(e,t)=>({u_translation:new vb(e,t.u_translation),u_ratio:new _b(e,t.u_ratio),u_image:new yb(e,t.u_image),u_mix:new _b(e,t.u_mix),u_tileratio:new _b(e,t.u_tileratio),u_crossfade_from:new _b(e,t.u_crossfade_from),u_crossfade_to:new _b(e,t.u_crossfade_to),u_lineatlas_width:new _b(e,t.u_lineatlas_width),u_lineatlas_height:new _b(e,t.u_lineatlas_height)}),lineGradientSDF:(e,t)=>({u_translation:new vb(e,t.u_translation),u_ratio:new _b(e,t.u_ratio),u_image:new yb(e,t.u_image),u_image_height:new _b(e,t.u_image_height),u_tileratio:new _b(e,t.u_tileratio),u_crossfade_from:new _b(e,t.u_crossfade_from),u_crossfade_to:new _b(e,t.u_crossfade_to),u_image_dash:new yb(e,t.u_image_dash),u_mix:new _b(e,t.u_mix),u_lineatlas_width:new _b(e,t.u_lineatlas_width),u_lineatlas_height:new _b(e,t.u_lineatlas_height)}),layerOpacity:(e,t)=>({u_image:new yb(e,t.u_image),u_opacity:new _b(e,t.u_opacity)}),raster:(e,t)=>({u_tl_parent:new vb(e,t.u_tl_parent),u_scale_parent:new _b(e,t.u_scale_parent),u_buffer_scale:new _b(e,t.u_buffer_scale),u_image_warp:new xb(e,t.u_image_warp),u_fade_t:new _b(e,t.u_fade_t),u_opacity:new _b(e,t.u_opacity),u_image0:new yb(e,t.u_image0),u_image1:new yb(e,t.u_image1),u_brightness_low:new _b(e,t.u_brightness_low),u_brightness_high:new _b(e,t.u_brightness_high),u_saturation_factor:new _b(e,t.u_saturation_factor),u_contrast_factor:new _b(e,t.u_contrast_factor),u_spin_weights:new xb(e,t.u_spin_weights),u_coords_top:new bb(e,t.u_coords_top),u_coords_bottom:new bb(e,t.u_coords_bottom)}),symbolIcon:(e,t)=>({u_is_size_zoom_constant:new yb(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new yb(e,t.u_is_size_feature_constant),u_size_t:new _b(e,t.u_size_t),u_size:new _b(e,t.u_size),u_rotate_symbol:new yb(e,t.u_rotate_symbol),u_label_plane_matrix:new Tb(e,t.u_label_plane_matrix),u_coord_matrix:new Tb(e,t.u_coord_matrix),u_is_text:new yb(e,t.u_is_text),u_pitch_with_map:new yb(e,t.u_pitch_with_map),u_is_along_line:new yb(e,t.u_is_along_line),u_is_variable_anchor:new yb(e,t.u_is_variable_anchor),u_texsize:new vb(e,t.u_texsize),u_texture:new yb(e,t.u_texture),u_translation:new vb(e,t.u_translation),u_pitched_scale:new _b(e,t.u_pitched_scale),u_is_offset:new yb(e,t.u_is_offset),u_height_anchor_ground:new yb(e,t.u_height_anchor_ground)}),symbolSDF:(e,t)=>({u_is_size_zoom_constant:new yb(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new yb(e,t.u_is_size_feature_constant),u_size_t:new _b(e,t.u_size_t),u_size:new _b(e,t.u_size),u_rotate_symbol:new yb(e,t.u_rotate_symbol),u_label_plane_matrix:new Tb(e,t.u_label_plane_matrix),u_coord_matrix:new Tb(e,t.u_coord_matrix),u_is_text:new yb(e,t.u_is_text),u_pitch_with_map:new yb(e,t.u_pitch_with_map),u_is_along_line:new yb(e,t.u_is_along_line),u_is_variable_anchor:new yb(e,t.u_is_variable_anchor),u_texsize:new vb(e,t.u_texsize),u_texture:new yb(e,t.u_texture),u_gamma_scale:new _b(e,t.u_gamma_scale),u_is_halo:new yb(e,t.u_is_halo),u_is_plain:new yb(e,t.u_is_plain),u_translation:new vb(e,t.u_translation),u_pitched_scale:new _b(e,t.u_pitched_scale),u_is_offset:new yb(e,t.u_is_offset),u_height_anchor_ground:new yb(e,t.u_height_anchor_ground)}),symbolTextAndIcon:(e,t)=>({u_is_size_zoom_constant:new yb(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new yb(e,t.u_is_size_feature_constant),u_size_t:new _b(e,t.u_size_t),u_size:new _b(e,t.u_size),u_rotate_symbol:new yb(e,t.u_rotate_symbol),u_label_plane_matrix:new Tb(e,t.u_label_plane_matrix),u_coord_matrix:new Tb(e,t.u_coord_matrix),u_is_text:new yb(e,t.u_is_text),u_pitch_with_map:new yb(e,t.u_pitch_with_map),u_is_along_line:new yb(e,t.u_is_along_line),u_is_variable_anchor:new yb(e,t.u_is_variable_anchor),u_texsize:new vb(e,t.u_texsize),u_texsize_icon:new vb(e,t.u_texsize_icon),u_texture:new yb(e,t.u_texture),u_texture_icon:new yb(e,t.u_texture_icon),u_gamma_scale:new _b(e,t.u_gamma_scale),u_is_halo:new yb(e,t.u_is_halo),u_translation:new vb(e,t.u_translation),u_pitched_scale:new _b(e,t.u_pitched_scale),u_is_offset:new yb(e,t.u_is_offset),u_height_anchor_ground:new yb(e,t.u_height_anchor_ground)}),background:(e,t)=>({u_opacity:new _b(e,t.u_opacity),u_color:new wb(e,t.u_color)}),backgroundPattern:(e,t)=>({u_opacity:new _b(e,t.u_opacity),u_image:new yb(e,t.u_image),u_pattern_tl_a:new vb(e,t.u_pattern_tl_a),u_pattern_br_a:new vb(e,t.u_pattern_br_a),u_pattern_tl_b:new vb(e,t.u_pattern_tl_b),u_pattern_br_b:new vb(e,t.u_pattern_br_b),u_texsize:new vb(e,t.u_texsize),u_mix:new _b(e,t.u_mix),u_pattern_size_a:new vb(e,t.u_pattern_size_a),u_pattern_size_b:new vb(e,t.u_pattern_size_b),u_scale_a:new _b(e,t.u_scale_a),u_scale_b:new _b(e,t.u_scale_b),u_pixel_coord_upper:new vb(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new vb(e,t.u_pixel_coord_lower),u_tile_units_to_pixels:new _b(e,t.u_tile_units_to_pixels)}),terrain:(e,t)=>({u_texture:new yb(e,t.u_texture),u_ele_delta:new _b(e,t.u_ele_delta),u_fog_matrix:new Tb(e,t.u_fog_matrix),u_fog_color:new wb(e,t.u_fog_color),u_fog_ground_blend:new _b(e,t.u_fog_ground_blend),u_fog_ground_blend_opacity:new _b(e,t.u_fog_ground_blend_opacity),u_horizon_color:new wb(e,t.u_horizon_color),u_horizon_fog_blend:new _b(e,t.u_horizon_fog_blend),u_is_globe_mode:new _b(e,t.u_is_globe_mode)}),terrainDepth:(e,t)=>({u_ele_delta:new _b(e,t.u_ele_delta)}),atmosphere:(e,t)=>({u_sun_pos:new xb(e,t.u_sun_pos),u_atmosphere_blend:new _b(e,t.u_atmosphere_blend),u_globe_position:new xb(e,t.u_globe_position),u_globe_radius:new _b(e,t.u_globe_radius),u_inv_proj_matrix:new Tb(e,t.u_inv_proj_matrix)}),sky:(e,t)=>({u_sky_color:new wb(e,t.u_sky_color),u_horizon_color:new wb(e,t.u_horizon_color),u_horizon:new vb(e,t.u_horizon),u_horizon_normal:new vb(e,t.u_horizon_normal),u_sky_horizon_blend:new _b(e,t.u_sky_horizon_blend),u_sky_blend:new _b(e,t.u_sky_blend),u_inv_proj_matrix:new Tb(e,t.u_inv_proj_matrix),u_globe_position:new xb(e,t.u_globe_position),u_globe_radius:new _b(e,t.u_globe_radius)})};var WL=class{constructor(e,t,r){this.context=e;let i=e.gl;this.buffer=i.createBuffer(),this.dynamicDraw=!!r,this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),i.bufferData(i.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?i.DYNAMIC_DRAW:i.STATIC_DRAW),this.dynamicDraw||t.freeBufferAfterUpload()}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(){let e=this.context.gl;this.buffer&&(e.deleteBuffer(this.buffer),delete this.buffer)}};const HL={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};var XL=class{constructor(e,t,r,i){this.length=t.length,this.attributes=r,this.itemSize=t.bytesPerElement,this.dynamicDraw=i,this.context=e;let n=e.gl;this.buffer=n.createBuffer(),e.bindVertexBuffer.set(this.buffer),n.bufferData(n.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||t.freeBufferAfterUpload()}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 r of this.attributes){let i=t.attributes[r.name];void 0!==i&&e.enableVertexAttribArray(i.location)}}setVertexAttribPointers(e,t,r){for(let i of this.attributes){let n=t.attributes[i.name];if(void 0!==n){let t=i.offset+this.itemSize*(r||0);n.isInteger?e.vertexAttribIPointer(n.location,i.components,e[HL[i.type]],this.itemSize,t):e.vertexAttribPointer(n.location,i.components,e[HL[i.type]],!1,this.itemSize,t)}}}destroy(){let e=this.context.gl;this.buffer&&(e.deleteBuffer(this.buffer),delete this.buffer)}},YL=class{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)}},KL=class extends YL{getDefault(){return Rm.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)}},JL=class extends YL{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}},QL=class extends YL{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}},ez=class extends YL{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)}},tz=class extends YL{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}},rz=class extends YL{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}},iz=class extends YL{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)}},nz=class extends YL{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)}},az=class extends YL{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}},sz=class extends YL{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)}},oz=class extends YL{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}},lz=class extends YL{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}},uz=class extends YL{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}},cz=class extends YL{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)}},hz=class extends YL{getDefault(){return Rm.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)}},dz=class extends YL{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquation(e),this.current=e,this.dirty=!1)}},pz=class extends YL{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}},fz=class extends YL{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}},mz=class extends YL{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}},gz=class extends YL{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}},yz=class extends YL{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}},_z=class extends YL{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)}},vz=class extends YL{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}},xz=class extends YL{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}},bz=class extends YL{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}},wz=class extends YL{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}},Ez=class extends YL{getDefault(){return null}set(e){let t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}},Sz=class extends YL{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1)}},Dz=class extends YL{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}},Tz=class extends YL{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}},Az=class extends YL{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}},Pz=class extends YL{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}},Iz=class extends Pz{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}},Cz=class extends Pz{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}},Fz=class extends Pz{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}},Mz=class{constructor(e,t,r,i,n){this.context=e,this.width=t,this.height=r;let a=e.gl,s=this.framebuffer=a.createFramebuffer();if(this.colorAttachment=new Iz(e,s),i)this.depthAttachment=n?new Fz(e,s):new Cz(e,s);else if(n)throw Error("Stencil cannot be set without depth")}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)}};const kz=cL([{name:"u_units_to_pixels",type:"vec2"},{name:"u_world_size",type:"vec2"},{name:"u_camera_to_center_distance",type:"float"},{name:"u_symbol_fade_change",type:"float"},{name:"u_aspect_ratio",type:"float"},{name:"u_device_pixel_ratio",type:"float"},{name:"u_viewport_size",type:"vec2"},{name:"u_pixel_extrude_scale",type:"vec2"},{name:"u_pitch",type:"float"}]),Rz=kz.offsets;var Lz=class{constructor(e,t,r){this.blendFunction=e,this.blendColor=t,this.mask=r}};Lz.Replace=[1,0],Lz.disabled=new Lz(Lz.Replace,Rm.transparent,[!1,!1,!1,!1]),Lz.unblended=new Lz(Lz.Replace,Rm.transparent,[!0,!0,!0,!0]),Lz.alphaBlended=new Lz([1,771],Rm.transparent,[!0,!0,!0,!0]);var zz=class{constructor(e){this.gl=e,this.clearColor=new KL(this),this.clearDepth=new JL(this),this.clearStencil=new QL(this),this.colorMask=new ez(this),this.depthMask=new tz(this),this.stencilMask=new rz(this),this.stencilFunc=new iz(this),this.stencilOp=new nz(this),this.stencilTest=new az(this),this.depthRange=new sz(this),this.depthTest=new oz(this),this.depthFunc=new lz(this),this.blend=new uz(this),this.blendFunc=new cz(this),this.blendColor=new hz(this),this.blendEquation=new dz(this),this.cullFace=new pz(this),this.cullFaceSide=new fz(this),this.frontFace=new mz(this),this.program=new gz(this),this.activeTexture=new yz(this),this.viewport=new _z(this),this.bindFramebuffer=new vz(this),this.bindRenderbuffer=new xz(this),this.bindTexture=new bz(this),this.bindVertexBuffer=new wz(this),this.bindElementBuffer=new Ez(this),this.bindVertexArray=new Sz(this),this.pixelStoreUnpack=new Dz(this),this.pixelStoreUnpackPremultiplyAlpha=new Tz(this),this.pixelStoreUnpackFlipY=new Az(this),this.extTextureFilterAnisotropic=e.getExtension("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),e.getExtension("EXT_color_buffer_half_float"),e.getExtension("EXT_color_buffer_float"),this.projectionUniformBuffer=function(e){return new hL(e,lL.ProjectionUBO,dL)}(this),this.terrainUniformBuffer=function(e){return new hL(e,lL.TerrainUBO,fL)}(this),this.frameUniformBuffer=function(e){return new hL(e,lL.FrameUBO,kz)}(this)}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,this.projectionUniformBuffer.bindingDirty=!0,this.terrainUniformBuffer.bindingDirty=!0,this.frameUniformBuffer.bindingDirty=!0}setCustomLayerDefaults(){this.unbindVAO(),this.cullFace.setDefault(),this.activeTexture.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}createIndexBuffer(e,t){return new WL(this,e,t)}createVertexBuffer(e,t,r){return new XL(this,e,t,r)}createRenderbuffer(e,t,r){let i=this.gl,n=i.createRenderbuffer();return this.bindRenderbuffer.set(n),i.renderbufferStorage(i.RENDERBUFFER,e,t,r),this.bindRenderbuffer.set(null),n}createFramebuffer(e,t,r,i){return new Mz(this,e,t,r,i)}clear({color:e,depth:t,stencil:r}){let i=this.gl,n=0;e&&(n|=i.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!0,!0,!0,!0])),void 0!==t&&(n|=i.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==r&&(n|=i.STENCIL_BUFFER_BIT,this.clearStencil.set(r),this.stencilMask.set(255)),i.clear(n)}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){Yp(e.blendFunction,Lz.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 this.gl.createVertexArray()}deleteVertexArray(e){this.gl.deleteVertexArray(e)}unbindVAO(){this.bindVertexArray.set(null)}},Bz=class{constructor(e,t,r){this.func=e,this.mask=t,this.range=r}};Bz.ReadOnly=!1,Bz.ReadWrite=!0,Bz.disabled=new Bz(519,Bz.ReadOnly,[0,1]);const Oz=7680;var $z=class{constructor(e,t,r,i,n,a){this.test=e,this.ref=t,this.mask=r,this.fail=i,this.depthFail=n,this.pass=a}};$z.disabled=new $z({func:519,mask:0},0,0,Oz,Oz,Oz);const Nz=2305;var jz=class{constructor(e,t,r){this.enable=e,this.mode=t,this.frontFace=r}};let Vz;function Uz(e,t,r,i,n){let a=e.context,s=e.transform,o=a.gl,l=e.useProgram("collisionBox"),u=[],c=0,h=0;for(let y of i){let i=t.getTile(y).getBucket(r);if(!i)continue;let d=n?i.textCollisionBox:i.iconCollisionBox,p=i.collisionCircleArray;p.length>0&&(u.push({circleArray:p,circleOffset:h,coord:y}),c+=p.length/4,h=c),d&&l.draw(a,o.LINES,Bz.disabled,$z.disabled,e.colorModeForRenderPass(),jz.disabled,null,e.style.map.terrain?.getTerrainData(y),s.getProjectionData({overscaledTileID:y,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),r.id,d.layoutVertexBuffer,d.indexBuffer,d.segments,null,e.transform.zoom,null,null,d.collisionVertexBuffer)}if(!n||!u.length)return;let d=e.useProgram("collisionCircle"),p=new Jx;p.resize(4*c),p._trim();let f=0;for(let y of u)for(let e=0;e<y.circleArray.length/4;e++){let t=4*e,r=y.circleArray[t+0],i=y.circleArray[t+1],n=y.circleArray[t+2],a=y.circleArray[t+3];p.emplace(f++,r,i,n,a,0),p.emplace(f++,r,i,n,a,1),p.emplace(f++,r,i,n,a,2),p.emplace(f++,r,i,n,a,3)}(!Vz||Vz.length<2*c)&&(Vz=function(e){let t=2*e,r=new eb;r.resize(t),r._trim();for(let i=0;i<t;i++){let e=6*i;r.uint16[e+0]=4*i+0,r.uint16[e+1]=4*i+1,r.uint16[e+2]=4*i+2,r.uint16[e+3]=4*i+2,r.uint16[e+4]=4*i+3,r.uint16[e+5]=4*i+0}return r}(c));let m=a.createIndexBuffer(Vz,!0),g=a.createVertexBuffer(p,KS.members,!0);for(let y of u)d.draw(a,o.TRIANGLES,Bz.disabled,$z.disabled,e.colorModeForRenderPass(),jz.disabled,null,e.style.map.terrain?.getTerrainData(y.coord),null,r.id,g,m,ab.simpleSegment(0,2*y.circleOffset,y.circleArray.length,y.circleArray.length/2),null,e.transform.zoom,null,null,null);g.destroy(),m.destroy()}jz.disabled=new jz(!1,1029,Nz),jz.backCCW=new jz(!0,1029,Nz),jz.frontCCW=new jz(!0,1028,Nz);const qz=kd(new Float32Array(16));function Gz(e,t,r,i,n,a){let{horizontalAlign:s,verticalAlign:o}=cT(e),l=-(o-.5)*r;return new Sd((-(s-.5)*t/n+i[0])*a,(l/n+i[1])*a)}function Zz(e,t,r,i,n,a){let s=t.tileAnchorPoint.add(new Sd(t.translation[0],t.translation[1]));if(t.pitchWithMap){let e=i.mult(a);r||(e=e.rotate(-n));let o=s.add(e);return ak(o.x,o.y,t.pitchedLabelPlaneMatrix,nk(t,o.x,o.y)).point}if(r){let r=fk(t.tileAnchorPoint.x+1,t.tileAnchorPoint.y,t).point.sub(e),n=Math.atan(r.y/r.x)+(r.x<0?Math.PI:0);return e.add(i.rotate(n))}return e.add(i)}function Wz(e,t,r,i,n,a,s,o,l,u,c,h,d){let p=e.text.placedSymbolArray,f=e.text.dynamicLayoutVertexArray,m=e.icon.dynamicLayoutVertexArray,g={};f.clear();for(let y=0;y<p.length;y++){let m=p.get(y),_=e.allowVerticalPlacement&&!m.placedOrientation,v=m.hidden||!m.crossTileID||_?null:i[m.crossTileID];if(v){let i=new Sd(m.anchorX,m.anchorY),p={getElevation:h,heightOffset:m.heightOffset,heightAnchorGround:d,width:n.width,height:n.height,pitchedLabelPlaneMatrix:a,pitchWithMap:r,transform:n,tileAnchorPoint:i,translation:u,unwrappedTileID:c},y=r?gk(i.x,i.y,p):fk(i.x,i.y,p),_=sk(n.cameraToCenterDistance,y.signedDistanceFromCamera),x=TT(e.textSizeData,o,m)*_/24;r&&(x*=e.tilePixelRatio/s);let{width:b,height:w,anchor:E,textOffset:S,textBoxScale:D}=v,T=Gz(E,b,w,S,D,x),A=n.getPitchedTextCorrection(i.x+u[0],i.y+u[1],c),P=Zz(y.point,p,t,T,-n.bearingInRadians,A),I=e.allowVerticalPlacement&&2===m.placedOrientation?Math.PI/2:0;for(let e=0;e<m.numGlyphs;e++)sA(f,P,I);l&&m.associatedIconIndex>=0&&(g[m.associatedIconIndex]={shiftedAnchor:P,angle:I})}else bk(m.numGlyphs,f)}if(l){m.clear();let t=e.icon.placedSymbolArray;for(let e=0;e<t.length;e++){let r=t.get(e);if(r.hidden)bk(r.numGlyphs,m);else{let t=g[e];if(t)for(let e=0;e<r.numGlyphs;e++)sA(m,t.shiftedAnchor,t.angle);else bk(r.numGlyphs,m)}}e.icon.dynamicLayoutVertexBuffer.updateData(m)}e.text.dynamicLayoutVertexBuffer.updateData(f)}function Hz(e,t,r){return r.iconsInText&&t?"symbolTextAndIcon":e?"symbolSDF":"symbolIcon"}function Xz(e,t,r,i,n,a,s,o,l,u,c,h,d){let p=e.context,f=p.gl,m=e.transform,g="map"===o,y="map"===l,_="viewport"!==o&&"point"!==r.layout.get("symbol-placement"),v=g&&!y&&!_,x=!r.layout.get("symbol-sort-key").isConstant(),b=!1,w=e.getDepthModeForSublayer(0,Bz.ReadOnly),E=r._unevaluatedLayout.hasValue("text-variable-anchor")||r._unevaluatedLayout.hasValue("text-variable-anchor-offset"),S=[],D=m.getCircleRadiusCorrection();for(let P of i){let i=t.getTile(P),o=i.getBucket(r);if(!o)continue;let l=n?o.text:o.icon;if(!l?.segments.get().length||!l.hasVisibleVertices)continue;let c,h,p,w,T=l.programConfigurations.get(r.id),A=n||o.sdfIcons,I=n?o.textSizeData:o.iconSizeData,C=y||0!==m.pitch,F=e.useProgram(Hz(A,n,o),T),M=AT(I,m.zoom),k=e.style.map.terrain?.getTerrainData(P),R=[0,0],L=null;if(n){if(h=i.glyphAtlasTexture,p=f.LINEAR,c=i.glyphAtlasTexture.size,o.iconsInText){R=i.imageAtlasTexture.size,L=i.imageAtlasTexture;let t="composite"===I.kind||"camera"===I.kind;w=C||e.options.rotating||e.options.zooming||t?f.LINEAR:f.NEAREST}}else{let t=1!==r.layout.get("icon-size").constantOr(0)||o.iconsNeedLinear;h=i.imageAtlasTexture,p=A||e.options.rotating||e.options.zooming||t||C?f.LINEAR:f.NEAREST,c=i.imageAtlasTexture.size}let z=vp(i,1,e.transform.zoom),B=tk(g,e.transform,z),O=rk(y,g,e.transform,z),$=Tp(m,i,a,s),N=m.getProjectionData({overscaledTileID:P,applyGlobeMatrix:!d,applyTerrainMatrix:!0}),j=E&&o.hasTextData(),V="none"!==r.layout.get("icon-text-fit")&&j&&o.hasIconData(),U=r._unevaluatedLayout.hasValue("icon-offset"),q="ground"===r.layout.get("symbol-height-anchor");if(_){let t=Fd();QM(t,B);let i=e.style.map.terrain?(t,r)=>e.style.map.terrain.getElevation(P,t,r):void 0;lk(o,e,n,B,t,y,u,"map"===r.layout.get("text-rotation-alignment"),P.toUnwrapped(),m.width,m.height,$,i)}let G,Z=n&&E||V,W=y?B:e.transform.clipSpaceToPixelsMatrix,H=_||Z?qz:W,X=A&&0!==r.paint.get(n?"text-halo-width":"icon-halo-width").constantOr(1);G=A?o.iconsInText?VL(I.kind,M,v,y,_,Z,e,H,O,$,c,R,D,U,q):jL(I.kind,M,v,y,_,Z,e,H,O,$,n,c,X,D,U,q):NL(I.kind,M,v,y,_,Z,0,H,O,$,n,c,D,U,q);let Y={program:F,buffers:l,uniformValues:G,projectionData:N,atlasTexture:h,atlasTextureIcon:L,atlasInterpolation:p,atlasInterpolationIcon:w,isSDF:A,hasHalo:X};if(x&&o.canOverlap){b=!0;let e=l.segments.get();for(let t of e)S.push({segments:new ab([t]),sortKey:t.sortKey,state:Y,terrainData:k})}else S.push({segments:l.segments,sortKey:0,state:Y,terrainData:k})}b&&S.sort((e,t)=>e.sortKey-t.sortKey);let T=r.paint.get(n?"text-halo-width":"icon-halo-width").constantOr(null)??1/0,A=24*r.layout.get("text-letter-spacing").constantOr(0)<0||T>1;for(let P of S){let t=P.state;p.activeTexture.set(f.TEXTURE0),t.atlasTexture.bind(t.atlasInterpolation,f.CLAMP_TO_EDGE),t.atlasTextureIcon&&(p.activeTexture.set(f.TEXTURE1),t.atlasTextureIcon&&t.atlasTextureIcon.bind(t.atlasInterpolationIcon,f.CLAMP_TO_EDGE));let i=t.isSDF&&t.hasHalo;if(i){let i=t.uniformValues;i.u_is_halo=1,A&&(i.u_is_plain=0,Yz(t.buffers,P.segments,r,e,t.program,w,c,h,i,t.projectionData,P.terrainData),i.u_is_halo=0,i.u_is_plain=1)}Yz(t.buffers,P.segments,r,e,t.program,w,c,h,t.uniformValues,t.projectionData,P.terrainData),i&&!A&&(t.uniformValues.u_is_halo=0)}}function Yz(e,t,r,i,n,a,s,o,l,u,c){let h=i.context,d=h.gl;n.draw(h,d.TRIANGLES,a,s,o,jz.backCCW,l,c,u,r.id,e.layoutVertexBuffer,e.indexBuffer,t,r.paint,i.transform.zoom,e.programConfigurations.get(r.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function Kz(e,t,r,i,n){let a=e.context,s=a.gl,o=$z.disabled,l=new Lz([s.ONE,s.ONE],Rm.transparent,[!0,!0,!0,!0]),u=t.getBucket(r);if(!u)return;let c=i.key,h=r.heatmapFbos.get(c);h||(h=Qz(a,t.tileSize,t.tileSize),r.heatmapFbos.set(c,h)),a.bindFramebuffer.set(h.framebuffer),a.viewport.set([0,0,t.tileSize,t.tileSize]),a.clear({color:Rm.transparent});let d=u.programConfigurations.get(r.id),p=e.useProgram("heatmap",d,!n),f=e.transform.getProjectionData({overscaledTileID:t.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),m=e.style.map.terrain.getTerrainData(i);p.draw(a,s.TRIANGLES,Bz.disabled,o,l,jz.disabled,AL(t,e.transform.zoom,r.paint.get("heatmap-intensity"),1),m,f,r.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,r.paint,e.transform.zoom,d)}function Jz(e,t,r,i,n){let a=e.context,s=a.gl,o=e.transform;a.setColorMode(e.colorModeForRenderPass());let l=eB(a,t),u=r.key,c=t.heatmapFbos.get(u);if(!c)return;a.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,c.colorAttachment.get()),a.activeTexture.set(s.TEXTURE1),l.bind(s.LINEAR,s.CLAMP_TO_EDGE);let h=o.getProjectionData({overscaledTileID:r,applyTerrainMatrix:n,applyGlobeMatrix:!i});e.useProgram("heatmapTexture").draw(a,s.TRIANGLES,Bz.disabled,$z.disabled,e.colorModeForRenderPass(),jz.disabled,PL(e,t,0,1),null,h,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,o.zoom),c.destroy(),t.heatmapFbos.delete(u)}function Qz(e,t,r){let i=e.gl,n=i.createTexture();i.bindTexture(i.TEXTURE_2D,n),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texStorage2D(i.TEXTURE_2D,1,i.RGBA16F,t,r);let a=e.createFramebuffer(t,r,!1,!1);return a.colorAttachment.set(n),a}function eB(e,t){return t.colorRampTexture||=new zw(e,t.colorRamp,e.gl.RGBA),t.colorRampTexture}function tB(e,t,r,i){let n=e.context,a=n.bindFramebuffer.get(),s=n.viewport.get(),[,,o,l]=s;return function(e,t,r){let i=e.context.gl;if(!e.layerOpacityFbo){let n=e.context.createFramebuffer(t,r,!0,!0),a=i.createTexture();return i.bindTexture(i.TEXTURE_2D,a),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,t,r,0,i.RGBA,i.UNSIGNED_BYTE,null),n.colorAttachment.set(a),n.depthAttachment.set(e.context.createRenderbuffer(i.DEPTH_STENCIL,t,r)),e.layerOpacityFbo=n,void e.context.bindFramebuffer.set(e.layerOpacityFbo.framebuffer)}if(e.layerOpacityFbo.width===t&&e.layerOpacityFbo.height===r)return void e.context.bindFramebuffer.set(e.layerOpacityFbo.framebuffer);let n=e.layerOpacityFbo;i.bindTexture(i.TEXTURE_2D,n.colorAttachment.get()),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,t,r,0,i.RGBA,i.UNSIGNED_BYTE,null),e.context.bindRenderbuffer.set(n.depthAttachment.get()),i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,t,r),e.context.bindRenderbuffer.set(null),n.width=t,n.height=r,e.context.bindFramebuffer.set(n.framebuffer)}(e,o,l),n.viewport.set([0,0,o,l]),n.clear({color:Rm.transparent,depth:1,stencil:0}),e.currentStencilSource=void 0,e.renderTileClippingMasks(t,r,i),{compositeTarget:a,compositeViewport:s}}function rB(e,t,r,i){let n=e.context,a=n.gl;n.bindFramebuffer.set(r.compositeTarget),n.viewport.set(r.compositeViewport),n.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,e.layerOpacityFbo.colorAttachment.get()),e.useProgram("layerOpacity").draw(n,a.TRIANGLES,Bz.disabled,$z.disabled,e.colorModeForRenderPass(),jz.disabled,((e,t)=>({u_image:t,u_opacity:e}))(t,0),null,null,i.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,i.paint,e.transform.zoom),e.currentStencilSource=void 0}function iB(e,t,r,i,n,a,s,o){let l=256;if(n.stepInterpolant){let i=t.getSource().maxzoom,n=s.canonical.z===i?Math.ceil(1<<e.transform.maxZoom-s.canonical.z):1;l=$p(function(e){return e<=1?1:2**Math.ceil(Math.log(e)/Math.LN2)}(a.maxLineLength/_p*1024*n),256,r.maxTextureSize)}return o.gradient=Aw({expression:n.gradientExpression(),evaluationKey:"lineProgress",resolution:l,image:o.gradient||void 0,clips:a.lineClipsArray}),o.texture?o.texture.update(o.gradient):o.texture=new zw(r,o.gradient,i.RGBA),o.version=n.gradientVersion,o.texture}function nB(e,t,r,i,n){e.activeTexture.set(t.TEXTURE0),r.imageAtlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE),i.updatePaintBuffers(n)}function aB(e,t,r,i,n,a){(n||e.lineAtlas.dirty)&&(t.activeTexture.set(r.TEXTURE0),e.lineAtlas.bind(t)),i.updatePaintBuffers(a)}function sB(e,t,r,i,n,a,s){let o=a.gradients[n.id],l=o.texture;n.gradientVersion!==o.version&&(l=iB(e,t,r,i,n,a,s,o)),r.activeTexture.set(i.TEXTURE0),l.bind(n.stepInterpolant?i.NEAREST:i.LINEAR,i.CLAMP_TO_EDGE)}function oB(e,t,r,i,n,a,s,o,l){let u=a.gradients[n.id],c=u.texture;n.gradientVersion!==u.version&&(c=iB(e,t,r,i,n,a,s,u)),r.activeTexture.set(i.TEXTURE0),c.bind(n.stepInterpolant?i.NEAREST:i.LINEAR,i.CLAMP_TO_EDGE),r.activeTexture.set(i.TEXTURE1),e.lineAtlas.bind(r),o.updatePaintBuffers(l)}function lB(e,t,r,i,n,a){let s,{isRenderingToTexture:o}=n,l=e.getDepthModeForSublayer(0,Bz.ReadOnly),u=e.colorModeForRenderPass(),c=r.paint.get("line-dasharray"),h=c.constantOr(1),d=r.paint.get("line-pattern"),p=d.constantOr(1),f=r.paint.get("line-gradient"),m=r.getCrossfadeParameters();s=p?"linePattern":h&&f?"lineGradientSDF":h?"lineSDF":f?"lineGradient":"line";let g=e.context,y=g.gl,_=e.transform,v=!0;for(let x of i){let i=t.getTile(x);if(p&&!i.patternsLoaded())continue;let n=i.getBucket(r);if(!n)continue;let b=n.programConfigurations.get(r.id),w=e.context.program.get(),E=e.useProgram(s,b),S=v||E.program!==w,D=a?e.getTerrainDataForTile(x,o):null,T=d.constantOr(null),A=c?.constantOr(null);if(T&&i.imageAtlas){let e=i.imageAtlas,t=e.patternPositions[T.to.toString()],r=e.patternPositions[T.from.toString()];t&&r&&b.setConstantPatternPositions(t,r)}else if(A){let t="round"===r.layout.get("line-cap").constantOr(null),i=e.lineAtlas.getDash(A.to,t),n=e.lineAtlas.getDash(A.from,t);b.setConstantDashPositions(i,n)}let P,I=_.getProjectionData({overscaledTileID:x,applyGlobeMatrix:!o,applyTerrainMatrix:!0}),C=_.getPixelScale();p?(P=LL(e,i,r,C,m),nB(g,y,i,b,m)):h&&f?(P=BL(e,i,r,C,m,n.lineClipsArray.length),oB(e,t,g,y,r,n,x,b,m)):h?(P=zL(e,i,r,C,m),aB(e,g,y,b,S,m)):f?(P=RL(e,i,r,C,n.lineClipsArray.length),sB(e,t,g,y,r,n,x)):P=kL(e,i,r,C);let F=e.stencilModeForClipping(x);E.draw(g,y.TRIANGLES,l,F,u,jz.disabled,P,D,I,r.id,n.layoutVertexBuffer,n.indexBuffer,n.segments,r.paint,e.transform.zoom,b,n.layoutVertexBuffer2),v=!1}}function uB(e,t,r,i,n){if(!r||!i?.imageAtlas)return;let a=i.imageAtlas.patternPositions,s=a[r.to.toString()],o=a[r.from.toString()];if(!s&&o&&(s=o),!o&&s&&(o=s),!s||!o){let e=n.getPaintProperty(t);s=a[e],o=a[e]}s&&o&&e.setConstantPatternPositions(s,o)}function cB(e,t,r,i,n){let{isRenderingToTexture:a}=n,s=e.colorModeForRenderPass();dB(e,t,r,i,e.getDepthModeForSublayer(1,Bz.ReadOnly),s,!1,a),hB(e,t,r,i,n)}function hB(e,t,r,i,n){if(!r.paint.get("fill-antialias"))return;let{isRenderingToTexture:a}=n,s=e.colorModeForRenderPass();dB(e,t,r,i,e.getDepthModeForSublayer(r.getPaintProperty("fill-outline-color")?2:0,Bz.ReadOnly),s,!0,a)}function dB(e,t,r,i,n,a,s,o){let l,u,c,h,d,p=e.context.gl,f="fill-pattern",m=r.paint.get(f),g=m?.constantOr(1),y=r.getCrossfadeParameters(),_=e.transform,v=r.paint.get("fill-translate"),x=r.paint.get("fill-translate-anchor");s?(u=g&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",l=p.LINES):(u=g?"fillPattern":"fill",l=p.TRIANGLES);let b=m.constantOr(null);for(let w of i){let i=t.getTile(w);if(g&&!i.patternsLoaded())continue;let m=i.getBucket(r);if(!m)continue;let E=m.sdfPatterns[r.id]??!1,S=m.programConfigurations.get(r.id),D=e.useProgram(u,S),T=e.getTerrainDataForTile(w,o);g&&(e.context.activeTexture.set(p.TEXTURE0),i.imageAtlasTexture.bind(p.LINEAR,p.CLAMP_TO_EDGE),S.updatePaintBuffers(y)),uB(S,f,b,i,r);let A=_.getProjectionData({overscaledTileID:w,applyGlobeMatrix:!o,applyTerrainMatrix:!0}),P=Tp(_,i,v,x);s?(h=m.indexBuffer2,d=m.segments2,c="fillOutlinePattern"===u&&g?SL(e,y,i,P,E):EL(P)):(h=m.indexBuffer,d=m.segments,c=g?bL(e,y,i,P,E):wL(P));let I=e.stencilModeForClipping(w);D.draw(e.context,l,n,I,a,jz.backCCW,c,T,A,r.id,m.layoutVertexBuffer,h,d,r.paint,e.transform.zoom,S)}}function pB(e,t,r,i,n,a,s,o){let l=e.context,u=l.gl,c="fill-extrusion-pattern",h=r.paint.get(c),d=h.constantOr(1),p=r.getCrossfadeParameters(),f=r.paint.get("fill-extrusion-opacity"),m=h.constantOr(null),g=e.transform;for(let y of i){let i=t.getTile(y),h=i.getBucket(r);if(!h)continue;let _=e.style.map.terrain?.getTerrainData(y),v=h.programConfigurations.get(r.id),x=e.useProgram(d?"fillExtrusionPattern":"fillExtrusion",v);d&&(e.context.activeTexture.set(u.TEXTURE0),i.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),v.updatePaintBuffers(p));let b=g.getProjectionData({overscaledTileID:y,applyGlobeMatrix:!o,applyTerrainMatrix:!0});uB(v,c,m,i,r);let w=Tp(g,i,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),E=r.paint.get("fill-extrusion-vertical-gradient"),S=d?xL(e,E,f,w,y,p,i):vL(e,E,f,w);x.draw(l,l.gl.TRIANGLES,n,a,s,jz.backCCW,S,_,b,r.id,h.layoutVertexBuffer,h.indexBuffer,h.segments,r.paint,e.transform.zoom,v,e.style.map.terrain&&h.centroidVertexBuffer)}}function fB(e,t,r,i,n,a,s,o,l){let u=e.style.projection,c=e.context,h=e.transform,d=c.gl,p=[`#define NUM_ILLUMINATION_SOURCES ${r.paint.get("hillshade-highlight-color").values.length}`],f=e.useProgram("hillshade",null,!1,p),m=!e.options.moving;for(let g of i){let i=t.getTile(g),p=i.fbo;if(!p)continue;let y=u.getMeshFromTileID(c,g.canonical,o,!0,"raster"),_=e.getTerrainDataForTile(g,l);c.activeTexture.set(d.TEXTURE0),d.bindTexture(d.TEXTURE_2D,p.colorAttachment.get());let v=h.getProjectionData({overscaledTileID:g,aligned:m,applyGlobeMatrix:!l,applyTerrainMatrix:!0});f.draw(c,d.TRIANGLES,a,n[g.overscaledZ],s,jz.backCCW,IL(e,i,r),_,v,r.id,y.vertexBuffer,y.indexBuffer,y.segments)}}let mB=0;function gB(e,t,r,i,n,a,s,o,l){let u=e.style.projection,c=e.context,h=e.transform,d=c.gl,p=e.useProgram("colorRelief"),f=!e.options.moving,m="nearest"===r.paint.get("resampling")?d.NEAREST:d.LINEAR,g=!0,y=0;for(let _ of i){let i=t.getTile(_),v=i.dem;if(!v?.data)continue;if(g){mB||=d.getParameter(d.MAX_TEXTURE_SIZE);let e=mB,{elevationTexture:t,colorTexture:i}=r.getColorRampTextures(c,e,v.getUnpackVector());c.activeTexture.set(d.TEXTURE1),t.bind(d.NEAREST,d.CLAMP_TO_EDGE),c.activeTexture.set(d.TEXTURE4),i.bind(d.LINEAR,d.CLAMP_TO_EDGE),g=!1,y=t.size[0]}let x=v.stride;c.activeTexture.set(d.TEXTURE0),(!i.demTexture||i.needsColorReliefPrepare)&&(c.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture||=e.getTileTexture(x)??new zw(c,{width:x,height:x,data:null},d.RGBA),i.demTexture.update(v.getPixels(),{premultiply:!1}),i.needsColorReliefPrepare=!1),i.demTexture.bind(m,d.CLAMP_TO_EDGE);let b=u.getMeshFromTileID(c,_.canonical,o,!0,"raster"),w=e.getTerrainDataForTile(_,l),E=h.getProjectionData({overscaledTileID:_,aligned:f,applyGlobeMatrix:!l,applyTerrainMatrix:!0});p.draw(c,d.TRIANGLES,a,n[_.overscaledZ],s,jz.backCCW,ML(r,i.dem,y),w,E,r.id,b.vertexBuffer,b.indexBuffer,b.segments)}}const yB=[new Sd(0,0),new Sd(_p,0),new Sd(_p,_p),new Sd(0,_p)];function _B(e,t,r,i,n,a,s,o,l,u=!1,c=!1,h=null){let d=i[i.length-1].overscaledZ,p=e.context,f=p.gl,m=e.useProgram("raster"),g=e.transform,y=e.style.projection,_=e.colorModeForRenderPass(),v=!e.options.moving,x=r.paint.get("raster-opacity"),b="nearest"===r.paint.get("resampling")||"nearest"===r.paint.get("raster-resampling")?f.NEAREST:f.LINEAR,w=r.paint.get("raster-fade-duration"),E=!!e.style.map.terrain;for(let S of i){let i=e.getDepthModeForSublayer(S.overscaledZ-d,1===x?Bz.ReadWrite:Bz.ReadOnly,f.LESS),D=t.getTile(S);p.activeTexture.set(f.TEXTURE0),D.texture.bind(b,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST),p.activeTexture.set(f.TEXTURE1);let{parentTile:T,parentScaleBy:A,parentTopLeft:P,fadeValues:I}=vB(D,t,w,E);D.fadeOpacity=I.tileOpacity,T?(T.fadeOpacity=I.parentTileOpacity,T.texture.bind(b,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST)):D.texture.bind(b,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST),D.texture.useMipmap&&p.extTextureFilterAnisotropic&&e.transform.pitch>e.options.anisotropicFilterPitch&&f.texParameterf(f.TEXTURE_2D,p.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,p.extTextureFilterAnisotropicMax);let C=e.getTerrainDataForTile(S,c),F=g.getProjectionData({overscaledTileID:S,aligned:v,applyGlobeMatrix:!c,applyTerrainMatrix:!0}),M=dM(P,A,I.fadeMix,r,o,l),k=h??y.getMeshFromTileID(p,S.canonical,a,s,"raster"),R=n?n[S.overscaledZ]:$z.disabled;m.draw(p,f.TRIANGLES,i,R,_,u?jz.frontCCW:jz.backCCW,M,C,F,r.id,k.vertexBuffer,k.indexBuffer,k.segments)}}function vB(e,t,r,i){let n={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(0===r||i)return n;if(e.fadingParentID){let i=t.getLoadedTile(e.fadingParentID);if(!i)return n;let a=2**(i.tileID.overscaledZ-e.tileID.overscaledZ);return{parentTile:i,parentScaleBy:a,parentTopLeft:[e.tileID.canonical.x*a%1,e.tileID.canonical.y*a%1],fadeValues:xB(e,i,r)}}return e.selfFading?{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:bB(e,r)}:n}function xB(e,t,r){let i=OC(),n=(i-e.timeAdded)/r,a=(i-t.timeAdded)/r,s=1===e.fadingDirection,o=$p(n,0,1),l=$p(1-a,0,1),u=s?o:l;return{tileOpacity:u,parentTileOpacity:s?l:o,fadeMix:{opacity:1,mix:1-u}}}function bB(e,t){let r=$p((OC()-e.timeAdded)/t,0,1);return{tileOpacity:r,fadeMix:{opacity:r,mix:0}}}const wB=new Rm(1,0,0,1),EB=new Rm(0,1,0,1),SB=new Rm(0,0,1,1),DB=new Rm(1,0,1,1),TB=new Rm(0,1,1,1);function AB(e,t,r,i){IB(e,0,t+r/2,e.transform.width,r,i)}function PB(e,t,r,i){IB(e,t-r/2,0,r,e.transform.height,i)}function IB(e,t,r,i,n,a){let s=e.context,o=s.gl;o.enable(o.SCISSOR_TEST),o.scissor(t*e.pixelRatio,r*e.pixelRatio,i*e.pixelRatio,n*e.pixelRatio),s.clear({color:a}),o.disable(o.SCISSOR_TEST)}function CB(e,t,r){let i=e.context,n=i.gl,a=e.useProgram("debug"),s=Bz.disabled,o=$z.disabled,l=e.colorModeForRenderPass(),u="$debug",c=e.style.map.terrain?.getTerrainData(r);i.activeTexture.set(n.TEXTURE0);let h=t.getTileByID(r.key).latestRawTileData?.byteLength||0,d=Math.floor(h/1024),p=t.getTile(r).tileSize,f=512/Math.min(p,512)*(r.overscaledZ/e.transform.zoom)*.5,m=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(m+=` => ${r.overscaledZ}`),function(e,t){e.initDebugOverlayCanvas();let r=e.debugOverlayCanvas,i=e.context.gl,n=e.debugOverlayCanvas.getContext("2d");n.clearRect(0,0,r.width,r.height),n.shadowColor="white",n.shadowBlur=2,n.lineWidth=1.5,n.strokeStyle="white",n.textBaseline="top",n.font="bold 36px Open Sans, sans-serif",n.fillText(t,5,5),n.strokeText(t,5,5),e.debugOverlayTexture.update(r),e.debugOverlayTexture.bind(i.LINEAR,i.CLAMP_TO_EDGE)}(e,`${m} ${d}kB`);let g=e.transform.getProjectionData({overscaledTileID:r,applyGlobeMatrix:!0,applyTerrainMatrix:!0});a.draw(i,n.TRIANGLES,s,o,Lz.alphaBlended,jz.disabled,TL(Rm.transparent,f),null,g,u,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),a.draw(i,n.LINE_STRIP,s,o,l,jz.disabled,TL(Rm.red),c,g,u,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function FB(e,t){if(!t.mesh){let r=new Ox;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(1,1),r.emplaceBack(-1,1);let i=new tb;i.emplaceBack(0,1,2),i.emplaceBack(0,2,3),t.mesh=new gM(e.createVertexBuffer(r,yM.members),e.createIndexBuffer(i),ab.simpleSegment(0,0,r.length,i.length))}return t.mesh}const MB={symbol:function(e,t,r,i,n,a){if("translucent"!==a.currentPass)return;let{isRenderingToTexture:s}=a,o=$z.disabled,l=e.colorModeForRenderPass();(r._unevaluatedLayout.hasValue("text-variable-anchor")||r._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(e,t,r,i,n,a,s,o,l){let u=t.transform,c=t.style.map.terrain,h="map"===n,d="map"===a;for(let p of e){let e=i.getTile(p),n=e.getBucket(r);if(!n?.text?.segments.get().length)continue;let a=AT(n.textSizeData,u.zoom),f=vp(e,1,t.transform.zoom),m=tk(h,t.transform,f),g="none"!==r.layout.get("icon-text-fit")&&n.hasIconData();if(a){let t=2**(u.zoom-e.tileID.overscaledZ),i=c?(e,t)=>c.getElevation(p,e,t):void 0;Wz(n,h,d,l,u,m,t,a,g,Tp(u,e,s,o),p.toUnwrapped(),i,"ground"===r.layout.get("symbol-height-anchor"))}}}(i,e,r,t,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),n),0!==r.paint.get("icon-opacity").constantOr(1)&&Xz(e,t,r,i,!1,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),r.layout.get("icon-rotation-alignment").constantOr("viewport"),r.layout.get("icon-pitch-alignment"),r.layout.get("icon-keep-upright"),o,l,s),0!==r.paint.get("text-opacity").constantOr(1)&&Xz(e,t,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"),o,l,s),t.map.showCollisionBoxes&&(Uz(e,t,r,i,!0),Uz(e,t,r,i,!1))},circle:function(e,t,r,i,n){if("translucent"!==n.currentPass)return;let{isRenderingToTexture:a}=n,s=r.paint.get("circle-opacity"),o=r.paint.get("circle-stroke-width"),l=r.paint.get("circle-stroke-opacity"),u=!r.layout.get("circle-sort-key").isConstant();if(0===s.constantOr(1)&&(0===o.constantOr(1)||0===l.constantOr(1)))return;let c=e.context,h=c.gl,d=e.transform,p=e.getDepthModeForSublayer(0,Bz.ReadOnly),f=$z.disabled,m=e.colorModeForRenderPass(),g=[],y=d.getCircleRadiusCorrection();for(let _ of i){let i=t.getTile(_),n=i.getBucket(r);if(!n)continue;let s=Tp(d,i,r.paint.get("circle-translate"),r.paint.get("circle-translate-anchor")),o=n.programConfigurations.get(r.id),l=e.useProgram("circle",o),c=n.layoutVertexBuffer,h=n.indexBuffer,p=e.style.map.terrain?.getTerrainData(_),f={programConfiguration:o,program:l,layoutVertexBuffer:c,indexBuffer:h,uniformValues:DL(e,i,r,s,y),terrainData:p,projectionData:d.getProjectionData({overscaledTileID:_,applyGlobeMatrix:!a,applyTerrainMatrix:!0})};if(u){let e=n.segments.get();for(let t of e)g.push({segments:new ab([t]),sortKey:t.sortKey,state:f})}else g.push({segments:n.segments,sortKey:0,state:f})}u&&g.sort((e,t)=>e.sortKey-t.sortKey);for(let _ of g){let{programConfiguration:t,program:i,layoutVertexBuffer:n,indexBuffer:a,uniformValues:s,terrainData:o,projectionData:l}=_.state,u=_.segments;i.draw(c,h.TRIANGLES,p,f,m,jz.backCCW,s,o,l,r.id,n,a,u,r.paint,e.transform.zoom,t)}},heatmap:function(e,t,r,i,n){if(0===r.paint.get("heatmap-opacity"))return;let a=e.context,{isRenderingToTexture:s,isRenderingGlobe:o}=n;if(e.style.map.terrain){for(let a of i){let i=t.getTile(a);t.hasRenderableParent(a)||("offscreen"===n.currentPass?Kz(e,i,r,a,o):"translucent"===n.currentPass&&Jz(e,r,a,s,o))}a.viewport.set([0,0,e.width,e.height])}else"offscreen"===n.currentPass?function(e,t,r,i){let n=e.context,a=n.gl,s=e.transform,o=$z.disabled,l=new Lz([a.ONE,a.ONE],Rm.transparent,[!0,!0,!0,!0]);(function(e,t,r){let i=e.gl;e.activeTexture.set(i.TEXTURE1),e.viewport.set([0,0,t.width/4,t.height/4]);let n=r.heatmapFbos.get(Pw);n?(i.bindTexture(i.TEXTURE_2D,n.colorAttachment.get()),e.bindFramebuffer.set(n.framebuffer)):(n=Qz(e,t.width/4,t.height/4),r.heatmapFbos.set(Pw,n))})(n,e,r),n.clear({color:Rm.transparent});for(let u of i){if(t.hasRenderableParent(u))continue;let i=t.getTile(u),c=i.getBucket(r);if(!c)continue;let h=c.programConfigurations.get(r.id),d=e.useProgram("heatmap",h),p=s.getProjectionData({overscaledTileID:u,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),f=s.getCircleRadiusCorrection();d.draw(n,a.TRIANGLES,Bz.disabled,o,l,jz.backCCW,AL(i,s.zoom,r.paint.get("heatmap-intensity"),f),null,p,r.id,c.layoutVertexBuffer,c.indexBuffer,c.segments,r.paint,s.zoom,h)}n.viewport.set([0,0,e.width,e.height])}(e,t,r,i):"translucent"===n.currentPass&&function(e,t){let r=e.context,i=r.gl;r.setColorMode(e.colorModeForRenderPass());let n=t.heatmapFbos.get(Pw);n&&(r.activeTexture.set(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,n.colorAttachment.get()),r.activeTexture.set(i.TEXTURE1),eB(r,t).bind(i.LINEAR,i.CLAMP_TO_EDGE),e.useProgram("heatmapTexture").draw(r,i.TRIANGLES,Bz.disabled,$z.disabled,e.colorModeForRenderPass(),jz.disabled,PL(e,t,0,1),null,null,t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,t.paint,e.transform.zoom))}(e,r)},line:function(e,t,r,i,n){if("translucent"!==n.currentPass)return;let a=r.paint.get("line-opacity"),s=r.paint.get("line-width"),o=r.paint.get("line-layer-opacity");if(0===a.constantOr(1)||0===s.constantOr(1)||0===o)return;let l=!!e.style.map.terrain;if(o<1){let a=tB(e,r,i,l);return lB(e,t,r,i,n,l),void rB(e,o,a,r)}lB(e,t,r,i,n,l)},fill:function(e,t,r,i,n){let a=r.paint.get("fill-color"),s=r.paint.get("fill-opacity"),o=r.paint.get("fill-layer-opacity");if(0===s.constantOr(1)||0===o)return;if(o<1){if("translucent"!==n.currentPass)return;let a=tB(e,r,i,!!e.style.map.terrain);return cB(e,t,r,i,n),void rB(e,o,a,r)}let l=r.paint.get("fill-pattern"),u=e.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===a.constantOr(Rm.transparent).a&&1===s.constantOr(0);if(u&&"opaque"===n.currentPass){let{isRenderingToTexture:a}=n,s=e.colorModeForRenderPass();return void dB(e,t,r,i,e.getDepthModeForSublayer(1,Bz.ReadWrite),s,!1,a)}u&&"translucent"===n.currentPass?hB(e,t,r,i,n):"translucent"===n.currentPass&&cB(e,t,r,i,n)},fillExtrusion:function(e,t,r,i,n){let a=r.paint.get("fill-extrusion-opacity");if(0===a)return;let{isRenderingToTexture:s}=n;if("translucent"===n.currentPass){let o=new Bz(e.context.gl.LEQUAL,Bz.ReadWrite,n.depthRangeFor3D);if(1!==a||r.paint.get("fill-extrusion-pattern").constantOr(1))pB(e,t,r,i,o,$z.disabled,Lz.disabled,s),pB(e,t,r,i,o,e.stencilModeFor3D(),e.colorModeForRenderPass(),s);else{let n=e.colorModeForRenderPass();pB(e,t,r,i,o,$z.disabled,n,s)}}},hillshade:function(e,t,r,i,n){if("offscreen"!==n.currentPass&&"translucent"!==n.currentPass)return;let{isRenderingToTexture:a}=n,s=e.context,o=e.style.projection.useSubdivision,l=e.getDepthModeForSublayer(0,Bz.ReadOnly),u=e.colorModeForRenderPass();if("offscreen"===n.currentPass)(function(e,t,r,i,n,a,s){let o=e.context,l=o.gl,u="nearest"===i.paint.get("resampling")?l.NEAREST:l.LINEAR;for(let c of r){let r=t.getTile(c),h=r.dem;if(!h?.data||!r.needsHillshadePrepare)continue;let d=h.dim+2,p=h.stride,f=h.getPixels();if(o.activeTexture.set(l.TEXTURE1),o.pixelStoreUnpackPremultiplyAlpha.set(!1),r.demTexture||=e.getTileTexture(p),r.demTexture){let e=r.demTexture;e.update(f,{premultiply:!1}),e.bind(l.NEAREST,l.CLAMP_TO_EDGE)}else r.demTexture=new zw(o,f,l.RGBA,{premultiply:!1}),r.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);o.activeTexture.set(l.TEXTURE0);let m=r.fbo;if(!m){let e=new zw(o,{width:d,height:d,data:null},l.RGBA);e.bind(u,l.CLAMP_TO_EDGE),m=r.fbo=o.createFramebuffer(d,d,!0,!1),m.colorAttachment.set(e.texture)}o.bindFramebuffer.set(m.framebuffer),o.viewport.set([0,0,d,d]),e.useProgram("hillshadePrepare").draw(o,l.TRIANGLES,n,a,s,jz.disabled,CL(r.tileID,h),null,null,i.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments),r.needsHillshadePrepare=!1}})(e,t,i,r,l,$z.disabled,u),s.viewport.set([0,0,e.width,e.height]);else if("translucent"===n.currentPass)if(o){let[n,s,o]=e.stencilConfigForOverlapTwoPass(i);fB(e,t,r,o,n,l,u,!1,a),fB(e,t,r,o,s,l,u,!0,a)}else{let[n,s]=e.getStencilConfigForOverlapAndUpdateStencilID(i);fB(e,t,r,s,n,l,u,!1,a)}},colorRelief:function(e,t,r,i,n){if("translucent"!==n.currentPass||!i.length)return;let{isRenderingToTexture:a}=n,s=e.style.projection.useSubdivision,o=e.getDepthModeForSublayer(0,Bz.ReadOnly),l=e.colorModeForRenderPass();if(s){let[n,s,u]=e.stencilConfigForOverlapTwoPass(i);gB(e,t,r,u,n,o,l,!1,a),gB(e,t,r,u,s,o,l,!0,a)}else{let[n,s]=e.getStencilConfigForOverlapAndUpdateStencilID(i);gB(e,t,r,s,n,o,l,!1,a)}},raster:function(e,t,r,i,n){if("translucent"!==n.currentPass||0===r.paint.get("raster-opacity")||!i.length)return;let{isRenderingToTexture:a}=n,s=t.getSource(),o=e.style.projection.useSubdivision;if(s instanceof vM)_B(e,t,r,i,null,!1,!1,s.tileCoords,s.imageWarp,s.flippedWindingOrder,a,s.getMesh(e.context,o));else if(o){let[n,s,o]=e.stencilConfigForOverlapTwoPass(i);_B(e,t,r,o,n,!1,!0,yB,hM,!1,a),_B(e,t,r,o,s,!0,!0,yB,hM,!1,a)}else{let[n,s]=e.getStencilConfigForOverlapAndUpdateStencilID(i);_B(e,t,r,s,n,!1,!0,yB,hM,!1,a)}},background:function(e,t,r,i,n){let a=r.paint.get("background-color"),s=r.paint.get("background-opacity");if(0===s)return;let{isRenderingToTexture:o}=n,l=e.context,u=l.gl,c=e.style.projection,h=e.transform,d=h.tileSize,p=r.paint.get("background-pattern");if(e.isPatternMissing(p))return;let f=!p&&1===a.a&&1===s&&e.opaquePassEnabledForLayer()?"opaque":"translucent";if(n.currentPass!==f)return;let m=$z.disabled,g=e.getDepthModeForSublayer(0,"opaque"===f?Bz.ReadWrite:Bz.ReadOnly),y=e.colorModeForRenderPass(),_=e.useProgram(p?"backgroundPattern":"background"),v=i||$M(h,{tileSize:d,terrain:e.style.map.terrain});p&&(l.activeTexture.set(u.TEXTURE0),e.patternAtlas.bind(e.context));let x=r.getCrossfadeParameters();for(let b of v){let t=h.getProjectionData({overscaledTileID:b,applyGlobeMatrix:!o,applyTerrainMatrix:!0}),i=p?qL(s,e,p,{tileID:b,tileSize:d},x):UL(s,a),n=e.getTerrainDataForTile(b,o),f=c.getMeshFromTileID(l,b.canonical,!1,!0,"raster");_.draw(l,u.TRIANGLES,g,m,y,jz.backCCW,i,n,t,r.id,f.vertexBuffer,f.indexBuffer,f.segments)}},sky:function(e,t){let r=e.context,i=r.gl,n=((e,t,r)=>{let i=Math.cos(t.rollInRadians),n=Math.sin(t.rollInRadians),a=_S(t),s=t.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:e.properties.get("sky-color"),u_horizon_color:e.properties.get("horizon-color"),u_horizon:[(t.width/2-a*n)*r,(t.height/2+a*i)*r],u_horizon_normal:[-n,i],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*t.height/2*r,u_sky_blend:s,u_inv_proj_matrix:t.inverseProjectionMatrix,u_globe_position:kR(t),u_globe_radius:MR(t.worldSize,t.center.lat)}})(t,e.transform,e.pixelRatio),a=new Bz(i.LEQUAL,Bz.ReadWrite,[0,1]),s=$z.disabled,o=e.colorModeForRenderPass(),l=e.useProgram("sky"),u=FB(r,t);l.draw(r,i.TRIANGLES,a,s,o,jz.disabled,n,null,void 0,"sky",u.vertexBuffer,u.indexBuffer,u.segments)},atmosphere:function(e,t,r){let i=e.context,n=i.gl,a=e.useProgram("atmosphere"),s=new Bz(n.LEQUAL,Bz.ReadOnly,[0,1]),o=e.transform,l=function(e,t){let r=e.getCartesianPosition();!function(e,t){e[0]=-t[0],e[1]=-t[1],e[2]=-t[2]}(r,r);let i=kd(new Float64Array(16));return"map"===e.properties.get("anchor")&&(Nd(i,i,t.rollInRadians),Od(i,i,-t.pitchInRadians),Nd(i,i,t.bearingInRadians),Od(i,i,t.center.lat*Math.PI/180),$d(i,i,-t.center.lng*Math.PI/180)),function(e,t,r){var i=t[0],n=t[1],a=t[2],s=r[3]*i+r[7]*n+r[11]*a+r[15];s||=1,e[0]=(r[0]*i+r[4]*n+r[8]*a+r[12])/s,e[1]=(r[1]*i+r[5]*n+r[9]*a+r[13])/s,e[2]=(r[2]*i+r[6]*n+r[10]*a+r[14])/s}(r,r,i),r}(r,e.transform),u=o.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),c=t.properties.get("atmosphere-blend")*u.projectionTransition;if(0===c)return;let h=MR(o.worldSize,o.center.lat),d=((e,t,r,i,n)=>({u_sun_pos:e,u_atmosphere_blend:t,u_globe_position:r,u_globe_radius:i,u_inv_proj_matrix:n}))(l,c,kR(o),h,o.inverseProjectionMatrix),p=FB(i,t);a.draw(i,n.TRIANGLES,s,$z.disabled,Lz.alphaBlended,jz.disabled,d,null,null,"atmosphere",p.vertexBuffer,p.indexBuffer,p.segments)},custom:function(e,t,r,i){let{isRenderingGlobe:n}=i,a=e.context,s=r.implementation,o=e.style.projection,l=e.transform,u=l.getProjectionDataForCustomLayer(n),c={farZ:l.farZ,nearZ:l.nearZ,fov:l.fov*Math.PI/180,modelViewProjectionMatrix:l.modelViewProjectionMatrix,projectionMatrix:l.projectionMatrix,shaderData:{variantName:o.shaderVariantName,vertexShaderPrelude:`const float PI = 3.141592653589793;\nuniform mat4 u_projection_matrix;\n${o.shaderPreludeCode.vertexSource}`,define:o.shaderDefine},defaultProjectionData:u,getProjectionData:e=>l.getProjectionData({overscaledTileID:new PA(e.tileID.canonical.z,e.tileID.wrap??0,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),aligned:e.aligned,applyGlobeMatrix:e.applyGlobeMatrix,applyTerrainMatrix:e.applyTerrainMatrix})},h=s.renderingMode?s.renderingMode:"2d";if("offscreen"===i.currentPass){let t=s.prerender;t&&(e.setCustomLayerDefaults(),a.setColorMode(e.colorModeForRenderPass()),t.call(s,a.gl,c),a.setDirty(),e.setBaseState())}else if("translucent"===i.currentPass){e.setCustomLayerDefaults(),a.setColorMode(e.colorModeForRenderPass()),a.setStencilMode($z.disabled);let t="3d"===h?e.getDepthModeFor3D():e.getDepthModeForSublayer(0,Bz.ReadOnly);a.setDepthMode(t),s.render(a.gl,c),a.setDirty(),e.setBaseState(),a.bindFramebuffer.set(null)}},debug:function(e,t,r){for(let i of r)CB(e,t,i)},debugPadding:function(e){let t=e.transform.padding;AB(e,e.transform.height-(t.top||0),3,wB),AB(e,t.bottom||0,3,EB),PB(e,t.left||0,3,SB),PB(e,e.transform.width-(t.right||0),3,DB);let r=e.transform.centerPoint;!function(e,t,r,i){IB(e,t-1,r-10,2,20,i),IB(e,t-10,r-1,20,2,i)}(e,r.x,e.transform.height-r.y,TB)},terrainDepth:function(e,t){let r=e.context,i=r.gl,n=e.transform,a=Lz.unblended,s=new Bz(i.LEQUAL,Bz.ReadWrite,[0,1]),o=t.tileManager.getRenderableTiles(),l=e.useProgram("terrainDepth");r.bindFramebuffer.set(t.getFramebuffer().framebuffer),r.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),r.clear({color:Rm.white,depth:1});for(let u of o){let e=t.getTerrainMesh(u.tileID),o=t.getTerrainData(u.tileID),c=n.getProjectionData({overscaledTileID:u.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),h=oL(t.getSkirtLength(n.zoom));l.draw(r,i.TRIANGLES,s,$z.disabled,a,jz.backCCW,h,o,c,"terrain",e.vertexBuffer,e.indexBuffer,e.segments)}r.bindFramebuffer.set(null),r.viewport.set([0,0,e.width,e.height])}};var kB=class e{constructor(e,t){this.drawFunctions=MB,this.context=new zz(e),this.transform=t,this.layerOpacityFbo=null,this._tileTextures={},this._rttObjectRecyclePool=[],this._rttSharedFbo=null,this.terrainFacilitator={depthDirty:!0,matrix:kd(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=HM.maxOverzooming+HM.maxUnderzooming+1,this.depthEpsilon=1/65536,this.crossTileSymbolIndex=new Jk}resize(e,t,r){if(this.width=Math.floor(e*r),this.height=Math.floor(t*r),this.pixelRatio=r,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let i of this.style._order)this.style._layers[i].resize()}setup(){let e=this.context,t=new Ox;t.emplaceBack(0,0),t.emplaceBack(_p,0),t.emplaceBack(0,_p),t.emplaceBack(_p,_p),this.tileExtentBuffer=e.createVertexBuffer(t,yM.members),this.tileExtentSegments=ab.simpleSegment(0,0,4,2);let r=new Ox;r.emplaceBack(0,0),r.emplaceBack(_p,0),r.emplaceBack(0,_p),r.emplaceBack(_p,_p),this.debugBuffer=e.createVertexBuffer(r,yM.members),this.debugSegments=ab.simpleSegment(0,0,4,5);let i=new Nx;i.emplaceBack(0,0,0,0),i.emplaceBack(_p,0,_p,0),i.emplaceBack(0,_p,0,_p),i.emplaceBack(_p,_p,_p,_p),this.rasterBoundsBuffer=e.createVertexBuffer(i,nL.members),this.rasterBoundsSegments=ab.simpleSegment(0,0,4,2);let n=new Ox;n.emplaceBack(0,0),n.emplaceBack(_p,0),n.emplaceBack(0,_p),n.emplaceBack(_p,_p),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(n,yM.members),this.rasterBoundsSegmentsPosOnly=ab.simpleSegment(0,0,4,5);let a=new Ox;a.emplaceBack(0,0),a.emplaceBack(1,0),a.emplaceBack(0,1),a.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(a,yM.members),this.viewportSegments=ab.simpleSegment(0,0,4,2);let s=new ib;s.emplaceBack(0),s.emplaceBack(1),s.emplaceBack(3),s.emplaceBack(2),s.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(s);let o=new tb;o.emplaceBack(1,0,2),o.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(o);let l=this.context.gl;this.stencilClearMode=new $z({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.tileExtentMesh=new gM(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){let e=this.context,t=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;let r=Fd();Vd(r,0,this.width,this.height,0,0,1),Bd(r,r,[t.drawingBufferWidth,t.drawingBufferHeight,0]);let i={mainMatrix:r,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:r,clipAntimeridian:!1};this.useProgram("clippingMask",null,!0).draw(e,t.TRIANGLES,Bz.disabled,this.stencilClearMode,Lz.disabled,jz.disabled,null,null,i,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}renderTileClippingMasks(e,t,r){if(this.currentStencilSource===e.source||!e.isTileClipped()||!t?.length)return;this.currentStencilSource=e.source,this.nextStencilID+t.length>256&&this.clearStencil();let i=this.context;i.setColorMode(Lz.disabled),i.setDepthMode(Bz.disabled);let n={};for(let a of t)n[a.key]=this.nextStencilID++;this.style.projection.useSubdivision&&this._renderTileMasks(n,t,r,!0),this._renderTileMasks(n,t,r,!1),this._tileClippingMaskIDs=n}_renderTileMasks(e,t,r,i){let n=this.context,a=n.gl,s=this.style.projection,o=this.transform,l=this.useProgram("clippingMask");for(let u of t){let t=e[u.key],c=this.getTerrainDataForTile(u,r),h=s.getMeshFromTileID(this.context,u.canonical,i,!0,"stencil"),d=o.getProjectionData({overscaledTileID:u,applyGlobeMatrix:!r,applyTerrainMatrix:!0});l.draw(n,a.TRIANGLES,Bz.disabled,new $z({func:a.ALWAYS,mask:0},t,255,a.KEEP,a.KEEP,a.REPLACE),Lz.disabled,r?jz.disabled:jz.backCCW,null,c,d,"$clipping",h.vertexBuffer,h.indexBuffer,h.segments)}}getTerrainDataForTile(e,t){return t&&"mercator"===this.style.projection?.name?null:this.style.map.terrain?.getTerrainData(e)||null}_renderTilesDepthBuffer(){let e=this.context,t=e.gl,r=this.style.projection,i=this.transform,n=this.useProgram("depth"),a=this.getDepthModeFor3D(),s=$M(i,{tileSize:i.tileSize});for(let o of s){let s=this.style.map.terrain?.getTerrainData(o),l=r.getMeshFromTileID(this.context,o.canonical,!0,!0,"raster"),u=i.getProjectionData({overscaledTileID:o,applyGlobeMatrix:!0,applyTerrainMatrix:!0});n.draw(e,t.TRIANGLES,a,$z.disabled,Lz.disabled,jz.backCCW,null,s,u,"$clipping",l.vertexBuffer,l.indexBuffer,l.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let e=this.nextStencilID++,t=this.context.gl;return new $z({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){let t=this.context.gl;return new $z({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){let t=this.context.gl,r=e.sort((e,t)=>t.overscaledZ-e.overscaledZ),i=r[r.length-1].overscaledZ,n=r[0].overscaledZ-i+1;if(n>1){this.currentStencilSource=void 0,this.nextStencilID+n>256&&this.clearStencil();let e={};for(let r=0;r<n;r++)e[r+i]=new $z({func:t.GEQUAL,mask:255},r+this.nextStencilID,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID+=n,[e,r]}return[{[i]:$z.disabled},r]}stencilConfigForOverlapTwoPass(e){let t=this.context.gl,r=e.sort((e,t)=>t.overscaledZ-e.overscaledZ),i=r[r.length-1].overscaledZ,n=r[0].overscaledZ-i+1;if(this.clearStencil(),n>1){let e={},a={};for(let r=0;r<n;r++)e[r+i]=new $z({func:t.GREATER,mask:255},n+1+r,255,t.KEEP,t.KEEP,t.REPLACE),a[r+i]=new $z({func:t.GREATER,mask:255},1+r,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID=2*n+1,[e,a,r]}return this.nextStencilID=3,[{[i]:new $z({func:t.GREATER,mask:255},2,255,t.KEEP,t.KEEP,t.REPLACE)},{[i]:new $z({func:t.GREATER,mask:255},1,255,t.KEEP,t.KEEP,t.REPLACE)},r]}colorModeForRenderPass(){let e=this.context.gl;if(this._showOverdrawInspector){let t=1/8;return new Lz([e.CONSTANT_COLOR,e.ONE],new Rm(t,t,t,0),[!0,!0,!0,!0])}return"opaque"===this.renderOptions.currentPass?Lz.unblended:Lz.alphaBlended}getDepthModeForSublayer(e,t,r){if(!this.opaquePassEnabledForLayer())return Bz.disabled;let i=1-((1+this.renderOptions.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new Bz(r||this.context.gl.LEQUAL,t,[i,i])}getDepthModeFor3D(){return new Bz(this.context.gl.LEQUAL,Bz.ReadWrite,this.renderOptions.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.renderOptions.currentLayer<this.renderOptions.opaquePassCutoff}render(e,t){this.style=e,this.options=t;let r=this.renderOptions=function(e,t,r){let i=t?.transitionState??0;return{currentPass:"offscreen",currentLayer:0,opaquePassCutoff:1/0,depthRangeFor3D:[0,1],isRenderingToTexture:!1,transform:e,terrain:r,projectionTransition:i,isRenderingGlobe:i>0}}(this.transform,e.projection,e.map.terrain??null);this.lineAtlas=e.lineAtlas,this.imageManager=e.imageManager,this.patternAtlas=e.patternAtlas,this.glyphManager=e.glyphManager,this.symbolFadeChange=e.placement.symbolFadeChange(OC()),function(e,t){let r=e.pending,{transform:i}=t,n=t.context.gl;r[Rz.u_units_to_pixels]=1/i.pixelsToGLUnits[0],r[Rz.u_units_to_pixels+1]=1/i.pixelsToGLUnits[1],r[Rz.u_world_size]=n.drawingBufferWidth,r[Rz.u_world_size+1]=n.drawingBufferHeight,r[Rz.u_camera_to_center_distance]=i.cameraToCenterDistance,r[Rz.u_symbol_fade_change]=t.options.fadeDuration?t.symbolFadeChange:1,r[Rz.u_aspect_ratio]=i.width/i.height,r[Rz.u_device_pixel_ratio]=t.pixelRatio,r[Rz.u_viewport_size]=i.width,r[Rz.u_viewport_size+1]=i.height,r[Rz.u_pixel_extrude_scale]=1/i.width,r[Rz.u_pixel_extrude_scale+1]=1/i.height,r[Rz.u_pitch]=i.pitch/360*2*Math.PI,e.upload()}(this.context.frameUniformBuffer,this),this.imageManager.beginFrame();let i=this.style._order,n=this.style.tileManagers,a={},s={},o={};for(let u in n){let e=n[u];e.used&&e.prepare(this.context),a[u]=e.getVisibleCoordinates(!1),s[u]=a[u].slice().reverse(),o[u]=e.getVisibleCoordinates(!0).reverse()}r.opaquePassCutoff=1/0;for(let u=0;u<i.length;u++){let e=i[u];if(this.style._layers[e].is3D()){r.opaquePassCutoff=u;break}}this.maybeDrawDepth(),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),r.opaquePassCutoff=0),r.currentPass="offscreen";for(let u of i){let e=this.style._layers[u];if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;let t=s[e.source];("custom"===e.type||t.length)&&this.renderLayer(this,n[e.source],e,t,r)}if(this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:t.showOverdrawInspector?Rm.black:Rm.transparent,depth:1}),this.clearStencil(),this.style.sky&&this.drawFunctions.sky(this,this.style.sky),this._showOverdrawInspector=t.showOverdrawInspector,r.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(r.currentPass="opaque",r.currentLayer=i.length-1;r.currentLayer>=0;r.currentLayer--){let e=this.style._layers[i[r.currentLayer]];if(e.isHidden(this.transform.zoom))continue;let t=n[e.source],s=a[e.source];this.renderTileClippingMasks(e,s,!1),this.renderLayer(this,t,e,s,r)}r.currentPass="translucent";let l=!1;for(r.currentLayer=0;r.currentLayer<i.length;r.currentLayer++){let e=this.style._layers[i[r.currentLayer]];if(e.isHidden(this.transform.zoom))continue;let t=n[e.source];if(this.renderToTexture?.renderLayer(e,r))continue;!this.opaquePassEnabledForLayer()&&!l&&(l=!0,r.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());let u=("symbol"===e.type?o:s)[e.source];this.renderTileClippingMasks(e,a[e.source],!!this.renderToTexture),this.renderLayer(this,t,e,u,r)}if(r.isRenderingGlobe&&this.drawFunctions.atmosphere(this,this.style.sky,this.style.light),this.options.showTileBoundaries){let e=function(e,t){let r=null,i=Object.values(e._layers).flatMap(r=>r.source&&!r.isHidden(t)?[e.tileManagers[r.source]]:[]),n=i.filter(e=>"vector"===e.getSource().type),a=i.filter(e=>"vector"!==e.getSource().type),s=e=>{(!r||r.getSource().maxzoom<e.getSource().maxzoom)&&(r=e)};for(let o of n)s(o);if(!r)for(let o of a)s(o);return r}(this.style,this.transform.zoom);e&&this.drawFunctions.debug(this,e,e.getVisibleCoordinates())}this.options.showPadding&&this.drawFunctions.debugPadding(this),this.context.setDefault()}maybeDrawDepth(){if(!this.style?.projection||!this.style.map?.terrain)return;let e=this.terrainFacilitator.matrix,t=this.transform.modelViewProjectionMatrix,r=this.terrainFacilitator.depthDirty;r||=!function(e,t){var r=e[0],i=e[1],n=e[2],a=e[3],s=e[4],o=e[5],l=e[6],u=e[7],c=e[8],h=e[9],d=e[10],p=e[11],f=e[12],m=e[13],g=e[14],y=e[15],_=t[0],v=t[1],x=t[2],b=t[3],w=t[4],E=t[5],S=t[6],D=t[7],T=t[8],A=t[9],P=t[10],I=t[11],C=t[12],F=t[13],M=t[14],k=t[15];return Math.abs(r-_)<=1e-6*Math.max(1,Math.abs(r),Math.abs(_))&&Math.abs(i-v)<=1e-6*Math.max(1,Math.abs(i),Math.abs(v))&&Math.abs(n-x)<=1e-6*Math.max(1,Math.abs(n),Math.abs(x))&&Math.abs(a-b)<=1e-6*Math.max(1,Math.abs(a),Math.abs(b))&&Math.abs(s-w)<=1e-6*Math.max(1,Math.abs(s),Math.abs(w))&&Math.abs(o-E)<=1e-6*Math.max(1,Math.abs(o),Math.abs(E))&&Math.abs(l-S)<=1e-6*Math.max(1,Math.abs(l),Math.abs(S))&&Math.abs(u-D)<=1e-6*Math.max(1,Math.abs(u),Math.abs(D))&&Math.abs(c-T)<=1e-6*Math.max(1,Math.abs(c),Math.abs(T))&&Math.abs(h-A)<=1e-6*Math.max(1,Math.abs(h),Math.abs(A))&&Math.abs(d-P)<=1e-6*Math.max(1,Math.abs(d),Math.abs(P))&&Math.abs(p-I)<=1e-6*Math.max(1,Math.abs(p),Math.abs(I))&&Math.abs(f-C)<=1e-6*Math.max(1,Math.abs(f),Math.abs(C))&&Math.abs(m-F)<=1e-6*Math.max(1,Math.abs(m),Math.abs(F))&&Math.abs(g-M)<=1e-6*Math.max(1,Math.abs(g),Math.abs(M))&&Math.abs(y-k)<=1e-6*Math.max(1,Math.abs(y),Math.abs(k))}(e,t),r||=this.style.map.terrain.tileManager.anyTilesAfterTime(this.terrainFacilitator.renderTime),r&&(function(e,t){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,t),this.terrainFacilitator.renderTime=OC(),this.terrainFacilitator.depthDirty=!1,this.drawFunctions.terrainDepth(this,this.style.map.terrain))}renderLayer(e,t,r,i,n){if(r.isHidden(this.transform.zoom)||"background"!==r.type&&"custom"!==r.type&&!(i||[]).length)return;this.id=r.id;let a=this.drawFunctions;mA(r)?a.symbol(e,t,r,i,this.style.placement.variableOffsets,n):(e=>"circle"===e.type)(r)?a.circle(e,t,r,i,n):(e=>"heatmap"===e.type)(r)?a.heatmap(e,t,r,i,n):(e=>"line"===e.type)(r)?a.line(e,t,r,i,n):(e=>"fill"===e.type)(r)?a.fill(e,t,r,i,n):(e=>"fill-extrusion"===e.type)(r)?a.fillExtrusion(e,t,r,i,n):(e=>"hillshade"===e.type)(r)?a.hillshade(e,t,r,i,n):(e=>"color-relief"===e.type)(r)?a.colorRelief(e,t,r,i,n):Xv(r)?a.raster(e,t,r,i,n):(e=>"background"===e.type)(r)?a.background(e,t,r,i,n):(e=>"custom"===e.type)(r)&&a.custom(e,t,r,n)}static{this.MAX_TEXTURE_POOL_SIZE_PER_BUCKET=50}saveTileTexture(t){let r=this._tileTextures[t.size[0]];r?r.length<e.MAX_TEXTURE_POOL_SIZE_PER_BUCKET?r.push(t):t.destroy():this._tileTextures[t.size[0]]=[t]}getTileTexture(e){let t=this._tileTextures[e];return t&&t.length>0?t.pop():null}acquireRTT(e){let t=this.context.gl,r=this._rttObjectRecyclePool.pop();if(r)return r.size!==e&&(r.texture.update({width:e,height:e,data:null},{premultiply:!1,useMipmap:!0}),r.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE,t.LINEAR_MIPMAP_LINEAR),this.context.extTextureFilterAnisotropic&&t.texParameterf(t.TEXTURE_2D,this.context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this.context.extTextureFilterAnisotropicMax),r.size=e),r;let i=new zw(this.context,{width:e,height:e,data:null},t.RGBA,{premultiply:!1,useMipmap:!0});return i.bind(t.LINEAR,t.CLAMP_TO_EDGE,t.LINEAR_MIPMAP_LINEAR),this.context.extTextureFilterAnisotropic&&t.texParameterf(t.TEXTURE_2D,this.context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this.context.extTextureFilterAnisotropicMax),{texture:i,size:e}}bindRTT(e){let t=this.context.gl,r=e.size;if(!this._rttSharedFbo){let e=this.context.createFramebuffer(r,r,!0,!0),i=this.context.createRenderbuffer(t.DEPTH_STENCIL,r,r);e.depthAttachment.set(i),this._rttSharedFbo={fbo:e,depthRenderbuffer:i,size:r}}this._rttSharedFbo.size!==r&&(this.context.bindRenderbuffer.set(this._rttSharedFbo.depthRenderbuffer),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,r,r),this.context.bindRenderbuffer.set(null),this._rttSharedFbo.fbo.width=r,this._rttSharedFbo.fbo.height=r,this._rttSharedFbo.size=r),this._rttSharedFbo.fbo.colorAttachment.set(e.texture.texture),this.context.bindFramebuffer.set(this._rttSharedFbo.fbo.framebuffer)}releaseRTT(e){this._rttObjectRecyclePool.push(e)}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;let t=this.patternAtlas.getPattern(e.from.toString()),r=this.patternAtlas.getPattern(e.to.toString());return!t||!r}useProgram(e,t,r=!1,i=[]){this.cache||={};let n=!!this.style.map.terrain,a=this.style.projection,s=r?eR.projectionMercator:a.shaderPreludeCode,o=r?rR:a.shaderDefine,l=`/${r?iR:a.shaderVariantName}`,u=e+(t?t.cacheKey:"")+l+(this._showOverdrawInspector?"/overdraw":"")+(n?"/terrain":"")+(i?`/${i.join("/")}`:"");return this.cache[u]||=new yL(this.context,eR[e],t,ZL[e],this._showOverdrawInspector,n,s,o,i),this.cache[u]}setCustomLayerDefaults(){this.context.setCustomLayerDefaults()}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(){if(null==this.debugOverlayCanvas){this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512;let e=this.context.gl;this.debugOverlayTexture=new zw(this.context,this.debugOverlayCanvas,e.RGBA)}}destroy(){if(this._tileTextures){for(let e in this._tileTextures){let t=this._tileTextures[e];if(t)for(let e of t)e.destroy()}this._tileTextures={}}for(let e of this._rttObjectRecyclePool)e.texture.destroy();if(this._rttObjectRecyclePool=[],this._rttSharedFbo){this._rttSharedFbo.fbo.colorAttachment.set(null),this._rttSharedFbo.fbo.depthAttachment.set(null);let e=this.context.gl;e.deleteRenderbuffer(this._rttSharedFbo.depthRenderbuffer),e.deleteFramebuffer(this._rttSharedFbo.fbo.framebuffer),this._rttSharedFbo=null}if(this.layerOpacityFbo?.destroy(),this.layerOpacityFbo=null,this.tileExtentBuffer&&this.tileExtentBuffer.destroy(),this.debugBuffer&&this.debugBuffer.destroy(),this.rasterBoundsBuffer&&this.rasterBoundsBuffer.destroy(),this.rasterBoundsBufferPosOnly&&this.rasterBoundsBufferPosOnly.destroy(),this.viewportBuffer&&this.viewportBuffer.destroy(),this.tileBorderIndexBuffer&&this.tileBorderIndexBuffer.destroy(),this.quadTriangleIndexBuffer&&this.quadTriangleIndexBuffer.destroy(),this.tileExtentMesh&&this.tileExtentMesh.vertexBuffer?.destroy(),this.tileExtentMesh&&this.tileExtentMesh.indexBuffer?.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.context.projectionUniformBuffer.destroy(),this.context.terrainUniformBuffer.destroy(),this.context.frameUniformBuffer.destroy(),this.cache){for(let e in this.cache){let t=this.cache[e];t?.program&&this.context.gl.deleteProgram(t.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){let{drawingBufferWidth:e,drawingBufferHeight:t}=this.context.gl;return this.width!==e||this.height!==t}},RB=class extends Error{constructor(e,t){super("WebGL2 is required to display this map. We are sorry, but it seems that your browser does not support WebGL2, a technology for rendering 3D graphics on the web. Read more on https://wiki.openstreetmap.org/wiki/This_map_requires_WebGL"),this.name="GPUInitializationError",this.requestedAttributes=e,this.statusMessage=t?.statusMessage??null}};function LB(e,t){let r,i=!1,n=null,a=()=>{n=null,i&&=(e(...r),n=setTimeout(a,t),!1)};return(...e)=>(i=!0,r=e,n||a(),n)}var zB=class{constructor(e){this._getHashParams=()=>new URLSearchParams(window.location.hash.replace("#","")),this._getCurrentHash=()=>{let e=this._getHashParams();return this._hashName?(e.get(this._hashName)||"").split("/"):([...e.keys()][0]??"").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._getHashParams();if(this._hashName)e.delete(this._hashName);else{let t=Array.from(e.keys());t.length>0&&e.delete(t[0])}let t=decodeURIComponent(e.toString()).replace(/=&/g,"&").replace(/=$/g,""),r=t?`#${t}`:"",i=window.location.href.replace(/(#.+)?$/,r);i=i.replace("&&","&"),window.history.replaceState(window.history.state,null,i)},this._updateHash=LB(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(),r=Math.round(100*this._map.getZoom())/100,i=10**Math.ceil((r*Math.LN2+Math.log(512/360/.5))/Math.LN10),n=Math.round(t.lng*i)/i,a=Math.round(t.lat*i)/i,s=this._map.getBearing(),o=this._map.getPitch(),l="";if(l+=e?`/${n}/${a}/${r}`:`${r}/${a}/${n}`,(s||o)&&(l+="/"+Math.round(10*s)/10),o&&(l+=`/${Math.round(o)}`),this._hashName){let e=this._getHashParams();return e.set(this._hashName,l),`#${decodeURIComponent(e.toString()).replace(/=&/g,"&").replace(/=$/g,"")}`}return`#${l}`}_isValidHash(e){if(e.length<3||e.some(e=>isNaN(+e)))return!1;try{new nS(+e[2],+e[1])}catch{return!1}let t=+e[0],r=+(e[3]||0),i=+(e[4]||0);return t>=this._map.getMinZoom()&&t<=this._map.getMaxZoom()&&r>=-180&&r<=180&&i>=this._map.getMinPitch()&&i<=this._map.getMaxPitch()}};const BB={linearity:.3,easing:Bp(0,0,.3,1)},OB=jp({deceleration:2500,maxSpeed:1400},BB),$B=jp({deceleration:20,maxSpeed:1400},BB),NB=jp({deceleration:1e3,maxSpeed:360},BB),jB=jp({deceleration:1e3,maxSpeed:90},BB),VB=jp({deceleration:1e3,maxSpeed:360},BB);var UB=class{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:OC(),settings:e})}_drainInertiaBuffer(){let e=this._inertiaBuffer,t=OC();for(;e.length>0&&t-e[0].time>160;)e.shift()}_getVelocityEntries(){let e=this._inertiaBuffer,t=OC()-60,r=Math.max(0,e.length-2);for(;r>0&&e[r-1].time>=t;)r--;return e.slice(r)}_onMoveEnd(e){this._drainInertiaBuffer();let t=this._getVelocityEntries();if(t.length<2)return void this.clear();let r={zoom:0,bearing:0,pitch:0,roll:0,pan:new Sd(0,0),pinchAround:void 0,around:void 0};for(let{settings:a}of t)a.around&&(r.around=a.around),a.pinchAround&&(r.pinchAround=a.pinchAround);for(let{settings:a}of t.slice(1))r.zoom+=a.zoomDelta||0,r.bearing+=a.bearingDelta||0,r.pitch+=a.pitchDelta||0,r.roll+=a.rollDelta||0,a.panDelta&&r.pan._add(a.panDelta);if(!(r.pan.mag()||r.zoom||r.bearing||r.pitch||r.roll))return void this.clear();let i=OC()-t[0].time,n={};if(r.pan.mag()){let t=GB(r.pan.mag(),i,jp({},OB,e||{})),a=r.pan.mult(t.amount/r.pan.mag()),s=this._map._camera.cameraHelper.handlePanInertia(a,this._map._camera.transform);n.center=s.easingCenter,n.offset=s.easingOffset,qB(n,t)}if(r.zoom){let e=GB(r.zoom,i,$B);n.zoom=Wp(this._map.getZoom()+e.amount,this._map.getZoomSnap(),e.amount),qB(n,e)}if(r.bearing){let e=GB(r.bearing,i,NB);n.bearing=this._map.getBearing()+$p(e.amount,-179,179),qB(n,e)}if(r.pitch){let e=GB(r.pitch,i,jB);n.pitch=this._map.getPitch()+e.amount,qB(n,e)}if(r.roll){let e=GB(r.roll,i,VB);n.roll=this._map.getRoll()+$p(e.amount,-179,179),qB(n,e)}if(n.zoom||n.bearing){let e=void 0===r.pinchAround?r.around:r.pinchAround;n.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),jp(n,{noMoveStart:!0})}};function qB(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing)}function GB(e,t,r){let{maxSpeed:i,linearity:n,deceleration:a}=r,s=$p(e*n/(t/1e3),-i,i),o=Math.abs(s)/(a*n);return{easing:r.easing,duration:1e3*o,amount:o/2*s}}var ZB=class{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new XC(this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new WC(e.type,this._map,e))}mouseup(e){this._map.fire(new WC(e.type,this._map,e))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this._map.fire(new WC(e.type,this._map,e))}dblclick(e){return this._firePreventable(new WC(e.type,this._map,e))}mouseover(e){this._map.fire(new WC(e.type,this._map,e))}mouseout(e){this._map.fire(new WC(e.type,this._map,e))}touchstart(e){return this._firePreventable(new HC(e.type,this._map,e))}touchmove(e){this._map.fire(new HC(e.type,this._map,e))}touchend(e){this._map.fire(new HC(e.type,this._map,e))}touchcancel(e){this._map.fire(new HC(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},WB=class{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new WC(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new WC("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new WC(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},HB=class{constructor(e,t,r){this._map=e,this._tr=r,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1,t.boxZoom&&"object"==typeof t.boxZoom&&(this._boxZoomEnd=t.boxZoom.boxZoomEnd)}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&($C.disableDrag(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;let r=t;if(this._lastPos.equals(r)||!this._box&&r.dist(this._startPos)<this._clickTolerance)return;let i=this._startPos;this._lastPos=r,this._box||(this._box=$C.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",e));let n=Math.min(i.x,r.x),a=Math.max(i.x,r.x),s=Math.min(i.y,r.y),o=Math.max(i.y,r.y);this._box.style.transform=`translate(${n}px,${s}px)`,this._box.style.width=a-n+"px",this._box.style.height=o-s+"px"}mouseupWindow(e,t){if(!this._active||0!==e.button)return;let r=this._startPos,i=t;if(this.reset(),$C.suppressClick(),r.x!==i.x||r.y!==i.y)return this._map.fire(new YC("boxzoomend",{originalEvent:e})),this._boxZoomEnd?void this._boxZoomEnd(this._map,r,i,e):{cameraAnimation:e=>e.fitScreenCoordinates(r,i,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e)}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&=(this._box.remove(),null),$C.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,t){return this._map.fire(new YC(e,{originalEvent:t}))}};function XB(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 r={};for(let i=0;i<e.length;i++)r[e[i].identifier]=t[i];return r}var YB=class{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(e,t,r){(this.centroid||r.length>this.numTouches)&&(this.aborted=!0),!this.aborted&&(void 0===this.startTime&&(this.startTime=e.timeStamp),r.length===this.numTouches&&(this.centroid=function(e){let t=new Sd(0,0);for(let r of e)t._add(r);return t.div(e.length)}(t),this.touches=XB(r,t)))}touchmove(e,t,r){if(this.aborted||!this.centroid)return;let i=XB(r,t);for(let n in this.touches){let e=this.touches[n],t=i[n];(!t||t.dist(e)>30)&&(this.aborted=!0)}}touchend(e,t,r){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===r.length){let e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}},KB=class{constructor(e){this.singleTap=new YB(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,t,r){this.singleTap.touchstart(e,t,r)}touchmove(e,t,r){this.singleTap.touchmove(e,t,r)}touchend(e,t,r){let i=this.singleTap.touchend(e,t,r);if(i){let t=e.timeStamp-this.lastTime<500,r=!this.lastTap||this.lastTap.dist(i)<30;if((!t||!r)&&this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=i,this.count===this.numTaps)return this.reset(),i}}},JB=class{constructor(e,t){this._tr=t,this._zoomIn=new KB({numTouches:1,numTaps:2}),this._zoomOut=new KB({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,r){this._zoomIn.touchstart(e,t,r),this._zoomOut.touchstart(e,t,r)}touchmove(e,t,r){this._zoomIn.touchmove(e,t,r),this._zoomOut.touchmove(e,t,r)}touchend(e,t,r){let i=this._zoomIn.touchend(e,t,r),n=this._zoomOut.touchend(e,t,r),a=this._tr;return i?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:Wp(a.zoom+1,t.getZoomSnap()),around:a.unproject(i)},{originalEvent:e})}):n?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:Wp(a.zoom-1,t.getZoomSnap()),around:a.unproject(n)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},QB=class{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 r=this._lastPoint;if(!r)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);let i=Array.isArray(t)?t[0]:t;return!this._moved&&i.dist(r)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=i,this._move(r,i))}dragEnd(e){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(e)&&(this._moved&&$C.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}};const eO={0:1,2:2};var tO=class{constructor(e){this._correctEvent=e.checkCorrectEvent}startMove(e){this._eventButton=e.button}endMove(e){delete this._eventButton}isValidStartEvent(e){return this._correctEvent(e)}isValidMoveEvent(e){return!function(e,t){let r=eO[t];return void 0===e.buttons||(e.buttons&r)!==r}(e,this._eventButton)}isValidEndEvent(e){return e.button===this._eventButton}},rO=class{constructor(){this._firstTouch=void 0}_isOneFingerTouch(e){return 1===e.targetTouches.length}_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)}},iO=class{constructor(e=new tO({checkCorrectEvent:()=>!0}),t=new rO){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=t}_executeRelevantHandler(e,t,r){return e instanceof MouseEvent?t(e):typeof TouchEvent<"u"&&e instanceof TouchEvent?r(e):void 0}startMove(e){this._executeRelevantHandler(e,e=>{this.mouseMoveStateManager.startMove(e)},e=>{this.oneFingerTouchMoveStateManager.startMove(e)})}endMove(e){this._executeRelevantHandler(e,e=>{this.mouseMoveStateManager.endMove(e)},e=>{this.oneFingerTouchMoveStateManager.endMove(e)})}isValidStartEvent(e){return!!this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidStartEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidStartEvent(e))}isValidMoveEvent(e){return!!this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidMoveEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(e))}isValidEndEvent(e){return!!this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidEndEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidEndEvent(e))}};const nO=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault()}};function aO({enable:e,clickTolerance:t,aroundCenter:r=!0,minPixelCenterThreshold:i=100,rotateSpeed:n=.8},a){return new QB({clickTolerance:t,move:(e,t)=>{let s=a();if(r&&Math.abs(s.y-e.y)>i)return{bearingDelta:hf(new Sd(e.x,t.y),t,s)};let o=(t.x-e.x)*n;return r&&t.y<s.y&&(o=-o),{bearingDelta:o}},moveStateManager:new tO({checkCorrectEvent:e=>0===e.button&&e.ctrlKey||2===e.button&&!e.ctrlKey}),enable:e,assignEvents:nO})}var sO=class{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._map=t,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new Sd(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,t,r){return this._calculateTransform(e,t,r)}touchmove(e,t,r){if(this._active)return this._shouldBePrevented(r.length)?void this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e):(e.preventDefault(),this._calculateTransform(e,t,r))}touchend(e,t,r){this._calculateTransform(e,t,r),this._active&&this._shouldBePrevented(r.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,t,r){r.length>0&&(this._active=!0);let i=XB(r,t),n=new Sd(0,0),a=new Sd(0,0),s=0;for(let l in i){let e=i[l],t=this._touches[l];t&&(n._add(e),a._add(e.sub(t)),s++,i[l]=e)}if(this._touches=i,this._shouldBePrevented(s)||!a.mag())return;let o=a.div(s);return this._sum._add(o),this._sum.mag()<this._clickTolerance?void 0:{around:n.div(s),panDelta:o}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},oO=class{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(e,t,r){this._firstTwoTouches||r.length<2||(this._firstTwoTouches=[r[0].identifier,r[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,r){if(!this._firstTwoTouches)return;e.preventDefault();let[i,n]=this._firstTwoTouches,a=lO(r,t,i),s=lO(r,t,n);if(!a||!s)return;let o=this._aroundCenter?null:a.add(s).div(2);return this._move([a,s],o,e)}touchend(e,t,r){if(!this._firstTwoTouches)return;let[i,n]=this._firstTwoTouches,a=lO(r,t,i),s=lO(r,t,n);a&&s||(this._active&&$C.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}};function lO(e,t,r){for(let i=0;i<e.length;i++)if(e[i].identifier===r)return t[i]}function uO(e,t){return Math.log(e/t)/Math.LN2}var cO=class extends oO{constructor(){super(),this._zoomRate=1,this._zoomThreshold=.1}setZoomRate(e){this._zoomRate=e??1}setZoomThreshold(e){this._zoomThreshold=e??.1}reset(){super.reset(),delete this._distance,delete this._startDistance}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,t){let r=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(Math.abs(uO(this._distance,this._startDistance))<this._zoomThreshold))return this._active=!0,{zoomDelta:uO(this._distance,r)*this._zoomRate,pinchAround:t}}};function hO(e,t){return 180*e.angleWith(t)/Math.PI}var dO=class extends oO{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,r){let i=this._vector;if(this._vector=e[0].sub(e[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:hO(this._vector,i),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());let t=25/(Math.PI*this._minDiameter)*360,r=hO(e,this._startVector);return Math.abs(r)<t}};function pO(e){return Math.abs(e.y)>Math.abs(e.x)}var fO=class extends oO{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,r){super.touchstart(e,t,r),this._currentTouchCount=r.length}_start(e){this._lastPoints=e,pO(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,r){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;let i=e[0].sub(this._lastPoints[0]),n=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(i,n,r.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(i.y+n.y)/2*-.5}):void 0}gestureBeginsVertically(e,t,r){if(void 0!==this._valid)return this._valid;let i=e.mag()>=2,n=t.mag()>=2;if(!i&&!n)return;if(!i||!n)return void 0===this._firstMove&&(this._firstMove=r),r-this._firstMove<100&&void 0;let a=e.y>0==t.y>0;return pO(e)&&pO(t)&&a}};const mO={panStep:100,bearingStep:15,pitchStep:10};var gO=class{constructor(e,t){this._tr=t;let r=mO;this._panStep=r.panStep,this._bearingStep=r.bearingStep,this._pitchStep=r.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,r=0,i=0,n=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?r=-1:(e.preventDefault(),n=-1);break;case 39:e.shiftKey?r=1:(e.preventDefault(),n=1);break;case 38:e.shiftKey?i=1:(e.preventDefault(),a=-1);break;case 40:e.shiftKey?i=-1:(e.preventDefault(),a=1);break;default:return}return this._rotationDisabled&&(r=0,i=0),{cameraAnimation:s=>{let o=this._tr;s.easeTo({duration:300,easeId:"keyboardHandler",easing:yO,zoom:t?Wp(o.zoom+t*(e.shiftKey?2:1),s.getZoomSnap()):o.zoom,bearing:o.bearing+r*this._bearingStep,pitch:o.pitch+i*this._pitchStep,offset:[-n*this._panStep,-a*this._panStep],center:o.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 yO(e){return e*(2-e)}const _O=4.000244140625;var vO=class{constructor(e,t,r){this._onTimeout=e=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)},this._map=e,this._tr=r,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||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return!!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY,r=OC(),i=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==t&&t%_O==0?this._type="wheel":0!==t&&Math.abs(t)<4?this._type="trackpad":i>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(i*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._needsRerender=!1,this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);let t=$C.mousePos(this._map.getCanvas(),e),r=this._tr;this._aroundPoint=this._aroundCenter?r.transform.locationToScreenPoint(nS.convert(r.center)):t,this._needsRerender||(this._needsRerender=!0,this._triggerRenderFrame())}renderFrame(){if(!this._needsRerender||(this._needsRerender=!1,!this.isActive()))return;let e=this._tr.transform;if("number"==typeof this._lastExpectedZoom){let t=e.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=t),"number"==typeof this._targetZoom&&(this._targetZoom+=t)}if(0!==this._delta){let t="wheel"===this._type&&Math.abs(this._delta)>_O?this._wheelZoomRate:this._defaultZoomRate,r=2/(1+Math.exp(-Math.abs(this._delta*t)));this._delta<0&&0!==r&&(r=1/r);let i="number"==typeof this._targetZoom?Gp(this._targetZoom):e.scale,n=e.applyConstrain(e.getCameraLngLat(),Zp(i*r)).zoom,a=this._map.getZoomSnap();if("wheel"===this._type&&a>0){let t=Wp(e.zoom,a);this._targetZoom=Wp(n,a,n-t)}else this._targetZoom=n;"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}let t,r="number"==typeof this._targetZoom?this._targetZoom:e.zoom,i=this._startZoom,n=this._easing,a=!1;if("wheel"===this._type&&i&&n){let e=OC()-this._lastWheelEventTime,s=Math.min((e+5)/200,1),o=n(s);t=ng.number(i,r,o),s<1?this._needsRerender=!0:a=!0}else t=r,a=!0;return this._active=!0,a&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout},200)),this._lastExpectedZoom=t,{noInertia:!0,needsRenderFrame:!a,zoomDelta:t-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let t=Op;if(this._prevEase){let e=this._prevEase,r=(OC()-e.start)/e.duration,i=e.easing(r+.01)-e.easing(r),n=.27/Math.sqrt(i*i+1e-4)*.01;t=Bp(n,Math.sqrt(.0729-n*n),.25,1)}return this._prevEase={start:OC(),duration:e,easing:t},t}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}},xO=class{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()}},bO=class{constructor(e,t){this._tr=t,this.reset()}reset(){this._active=!1}dblclick(e,t){return e.preventDefault(),{cameraAnimation:r=>{r.easeTo({duration:300,zoom:Wp(this._tr.zoom+(e.shiftKey?-1:1),r.getZoomSnap()),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}},wO=class{constructor(){this._tap=new KB({numTouches:1,numTaps:1}),this._zoomRate=1,this.reset()}setZoomRate(e){this._zoomRate=e??1}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,t,r){if(!this._swipePoint)if(this._tapTime){let i=t[0],n=e.timeStamp-this._tapTime<500,a=this._tapPoint.dist(i)<30;n&&a?r.length>0&&(this._swipePoint=i,this._swipeTouch=r[0].identifier):this.reset()}else this._tap.touchstart(e,t,r)}touchmove(e,t,r){if(this._tapTime){if(this._swipePoint){if(r[0].identifier!==this._swipeTouch)return;let i=t[0],n=i.y-this._swipePoint.y;return this._swipePoint=i,e.preventDefault(),this._active=!0,{zoomDelta:n/128*this._zoomRate}}}else this._tap.touchmove(e,t,r)}touchend(e,t,r){if(this._tapTime)this._swipePoint&&0===r.length&&this.reset();else{let i=this._tap.touchend(e,t,r);i&&(this._tapTime=e.timeStamp,this._tapPoint=i)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},EO=class{constructor(e,t,r){this._el=e,this._mousePan=t,this._touchPan=r}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()}},SO=class{constructor(e,t,r,i){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=t,this._mousePitch=r,this._mouseRoll=i}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()}},DO=class{constructor(e,t,r,i){this._el=e,this._touchZoom=t,this._touchRotate=r,this._tapDragZoom=i,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()}setZoomRate(e){this._touchZoom.setZoomRate(e),this._tapDragZoom.setZoomRate(e)}setZoomThreshold(e){this._touchZoom.setZoomThreshold(e)}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}},TO=class{constructor(e,t){this._bypassKey=navigator.userAgent.includes("Mac")?"metaKey":"ctrlKey",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=$C.create("div","maplibregl-cooperative-gesture-screen",e);let t=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(t=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));let r=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),i=document.createElement("div");i.className="maplibregl-desktop-message",i.textContent=t,this._container.appendChild(i);let n=document.createElement("div");n.className="maplibregl-mobile-message",n.textContent=r,this._container.appendChild(n),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(this._container.remove(),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,t){this._enabled&&(this._map.fire(new VC("cooperativegestureprevented",{gestureType:e,originalEvent:t})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}},AO=class{constructor(e){this._camera=e}get transform(){return this._camera._requestedCameraState||this._camera.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(Sd.convert(e),this._camera.terrain)}};const PO=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;var IO=class extends Rf{};function CO(e){return e.panDelta?.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}var FO=class{get _ownerDocument(){return this._el?.ownerDocument||document}get _ownerWindow(){return this._el?.ownerDocument?.defaultView||window}constructor(e,t,r){this._terrainGestureAnchorElevation=null,this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`)},this.handleEvent=(e,t)=>{if("blur"===e.type)return void this.stop(!0);this._updatingCamera=!0;let r="renderFrame"===e.type?void 0:e,i={needsRenderFrame:!1},n={},a={};for(let{handlerName:l,handler:u,allowed:c}of this._handlers){if(!u.isEnabled())continue;let s;if(this._blockedByActive(a,c,l))u.reset();else if(u[t||e.type]){if(yf(e,t||e.type)){let r=$C.mousePos(this._map.getCanvas(),e);s=u[t||e.type](e,r)}else if(gf(e,t||e.type)){let r=e.touches,i=this._getMapTouches(r),n=$C.touchPos(this._map.getCanvas(),i);s=u[t||e.type](e,n,i)}else _f(t||e.type)||(s=u[t||e.type](e));this.mergeHandlerResult(i,n,s,l,r),s?.needsRenderFrame&&this._triggerRenderFrame()}(s||u.isActive())&&(a[l]=u)}let s={};for(let l in this._previousActiveHandlers)a[l]||(s[l]=r);this._previousActiveHandlers=a,(Object.keys(s).length||CO(i))&&(this._changes.push([i,n,s]),this._triggerRenderFrame()),(Object.keys(a).length||CO(i))&&this._camera.stop(!0),this._updatingCamera=!1;let{cameraAnimation:o}=i;o&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],o(this._map))},this._map=e,this._camera=t,this._transformProvider=new AO(this._camera),this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new UB(e),this._bearingSnap=r.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(r);let i=this._el;this._listeners=[[i,"touchstart",{passive:!0}],[i,"touchmove",{passive:!1}],[i,"touchend",void 0],[i,"touchcancel",void 0],[i,"mousedown",void 0],[i,"mousemove",void 0],[i,"mouseup",void 0],[this._ownerDocument,"mousemove",{capture:!0}],[this._ownerDocument,"mouseup",void 0],[i,"mouseover",void 0],[i,"mouseout",void 0],[i,"dblclick",void 0],[i,"click",void 0],[i,"keydown",{capture:!1}],[i,"keyup",void 0],[i,"wheel",{passive:!1}],[i,"contextmenu",void 0],[this._ownerWindow,"blur",void 0]];for(let[n,a,s]of this._listeners)n.addEventListener(a,n===this._ownerDocument?this.handleWindowEvent:this.handleEvent,s)}destroy(){for(let[e,t,r]of this._listeners)e.removeEventListener(t,e===this._ownerDocument?this.handleWindowEvent:this.handleEvent,r)}_addDefaultHandlers(e){let t=this._map,r=t.getCanvasContainer();this._add("mapEvent",new ZB(t,e));let i=t.boxZoom=new HB(t,e,this._transformProvider);this._add("boxZoom",i),e.interactive&&e.boxZoom&&i.enable();let n=t.cooperativeGestures=new TO(t,e.cooperativeGestures);this._add("cooperativeGestures",n),e.cooperativeGestures&&n.enable();let a=new JB(t,this._transformProvider),s=new bO(t,this._transformProvider);t.doubleClickZoom=new xO(s,a),this._add("tapZoom",a),this._add("clickZoom",s),e.interactive&&e.doubleClickZoom&&t.doubleClickZoom.enable();let o=new wO;this._add("tapDragZoom",o);let l=t.touchPitch=new fO(t);this._add("touchPitch",l),e.interactive&&e.touchPitch&&t.touchPitch.enable(e.touchPitch);let u=()=>t.project(t.getCenter()),c=aO(e,u),h=function({enable:e,clickTolerance:t,pitchSpeed:r=-.5}){return new QB({clickTolerance:t,move:(e,t)=>({pitchDelta:(t.y-e.y)*r}),moveStateManager:new tO({checkCorrectEvent:e=>0===e.button&&e.ctrlKey||2===e.button}),enable:e,assignEvents:nO})}(e),d=function({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:r=.3},i){return new QB({clickTolerance:t,move:(e,t)=>{let n=i(),a=(t.x-e.x)*r;return t.y<n.y&&(a=-a),{rollDelta:a}},moveStateManager:new tO({checkCorrectEvent:e=>2===e.button&&e.ctrlKey}),enable:e,assignEvents:nO})}(e,u);t.dragRotate=new SO(e,c,h,d),this._add("mouseRotate",c,["mousePitch"]),this._add("mousePitch",h,["mouseRotate","mouseRoll"]),this._add("mouseRoll",d,["mousePitch"]),e.interactive&&e.dragRotate&&t.dragRotate.enable();let p=function({enable:e,clickTolerance:t}){return new QB({clickTolerance:t,move:(e,t)=>({around:t,panDelta:t.sub(e)}),activateOnStart:!0,moveStateManager:new tO({checkCorrectEvent:e=>0===e.button&&!e.ctrlKey}),enable:e,assignEvents:nO})}(e),f=new sO(e,t);t.dragPan=new EO(r,p,f),this._add("mousePan",p),this._add("touchPan",f,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&t.dragPan.enable(e.dragPan);let m=new dO,g=new cO;t.touchZoomRotate=new DO(r,g,m,o),this._add("touchRotate",m,["touchPan","touchZoom"]),this._add("touchZoom",g,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&t.touchZoomRotate.enable(e.touchZoomRotate),this._add("blockableMapEvent",new WB(t));let y=t.scrollZoom=new vO(t,()=>this._triggerRenderFrame(),this._transformProvider);this._add("scrollZoom",y,["mousePan"]),e.interactive&&e.scrollZoom&&t.scrollZoom.enable(e.scrollZoom);let _=t.keyboard=new gO(t,this._transformProvider);this._add("keyboard",_),e.interactive&&e.keyboard&&t.keyboard.enable()}_add(e,t,r){this._handlers.push({handlerName:e,handler:t,allowed:r}),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!!PO(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,t,r){for(let i in e)if(i!==r&&!t?.includes(i))return!0;return!1}_getMapTouches(e){let t=[];for(let r of e){let e=r.target;this._el.contains(e)&&t.push(r)}return t}mergeHandlerResult(e,t,r,i,n){if(!r)return;jp(e,r);let a={handlerName:i,originalEvent:r.originalEvent||n};void 0!==r.zoomDelta&&(t.zoom=a),void 0!==r.panDelta&&(t.drag=a),void 0!==r.rollDelta&&(t.roll=a),void 0!==r.pitchDelta&&(t.pitch=a),void 0!==r.bearingDelta&&(t.rotate=a)}_applyChanges(){let e={},t={},r={};for(let[i,n,a]of this._changes)i.panDelta&&(e.panDelta=(e.panDelta||new Sd(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),void 0!==i.around&&(e.around=i.around),void 0!==i.pinchAround&&(e.pinchAround=i.pinchAround),i.noInertia&&(e.noInertia=i.noInertia),jp(t,n),jp(r,a);this._updateMapTransform(e,t,r),this._changes=[]}_updateMapTransform(e,t,r){let i=this._map,n=this._camera.getTransformForUpdate(),a=i.terrain;if(!(CO(e)||a&&this._terrainMovement))return void this._fireEvents(t,r,!0);this._camera.stop(!0);let{panDelta:s,zoomDelta:o,bearingDelta:l,pitchDelta:u,rollDelta:c}=e,{around:h,aroundOnSurface:d}=this._resolveAround(e,a,n),p=a?this._terrainGestureElevation(a,h,d,n,t):void 0,f={panDelta:s,zoomDelta:o,rollDelta:c,pitchDelta:u,bearingDelta:l,around:h,aroundElevation:p};this._camera.cameraHelper.useGlobeControls&&!n.isPointOnMapSurface(h)&&(h=n.centerPoint);let m=this._computePreZoomAroundLoc(n,h,s,p);this._handleMapControls({terrain:a,tr:n,deltasForHelper:f,preZoomAroundLoc:m,combinedEventsInProgress:t,panDelta:s}),this._camera.applyUpdatedTransform(n),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,r,!0)}_resolveAround(e,t,r){let i=void 0===e.pinchAround?e.around:e.pinchAround;return i||=this._camera.transform.centerPoint,t&&!r.isPointOnMapSurface(i)?{around:r.centerPoint,aroundOnSurface:!1}:{around:i,aroundOnSurface:!0}}_terrainGestureElevation(e,t,r,i,n){if(!r)return;if(!this._terrainMovement&&(n.drag||n.zoom)){let r=i.screenTerrainPointToMercatorCoordinate(t,e);this._terrainGestureAnchorElevation=r?r.z:null}if(null===this._terrainGestureAnchorElevation)return;let a=this._terrainGestureAnchorElevation;return t.distSqr(i.centerPoint)<.01||a-i.elevation>=.9*(i.getCameraAltitude()-i.elevation)?void 0:a}_computePreZoomAroundLoc(e,t,r,i){if(t.distSqr(e.centerPoint)<.01)return e.center;let n=r?t.sub(r):t;return void 0===i?e.screenPointToLocation(n):e.screenPointToLocationAtElevation(n,i)}_handleMapControls({terrain:e,tr:t,deltasForHelper:r,preZoomAroundLoc:i,combinedEventsInProgress:n,panDelta:a}){let s=this._camera.cameraHelper;if(s.handleMapControlsRollPitchBearingZoom(r,t),e)return s.useGlobeControls?(!this._terrainMovement&&(n.drag||n.zoom)&&(this._terrainMovement=!0,this._camera.elevationFreeze=!0),void s.handleMapControlsPan(r,t,i)):this._terrainMovement||!n.drag&&!n.zoom?void(void 0===r.aroundElevation&&n.drag&&this._terrainMovement&&a?t.setCenter(t.screenPointToLocation(t.centerPoint.sub(a))):s.handleMapControlsPan(r,t,i)):(this._terrainMovement=!0,this._camera.elevationFreeze=!0,void s.handleMapControlsPan(r,t,i));s.handleMapControlsPan(r,t,i)}_fireEvents(e,t,r){let i=PO(this._eventsInProgress),n=PO(e),a={};for(let c in e){let{originalEvent:t}=e[c];this._eventsInProgress[c]||(a[`${c}start`]=t),this._eventsInProgress[c]=e[c]}!i&&n&&this._fireEvent("movestart",n.originalEvent);for(let c in a)this._fireEvent(c,a[c]);n&&this._fireEvent("move",n.originalEvent);for(let c in e){let{originalEvent:t}=e[c];this._fireEvent(c,t)}let s,o={};for(let c in this._eventsInProgress){let{handlerName:e,originalEvent:r}=this._eventsInProgress[c];this._handlersById[e].isActive()||(delete this._eventsInProgress[c],s=t[e]||r,o[`${c}end`]=s)}for(let c in o)this._fireEvent(c,o[c]);let l=PO(this._eventsInProgress),u=(i||n)&&!l;if(u&&this._terrainMovement){this._camera.elevationFreeze=!1,this._terrainMovement=!1,this._terrainGestureAnchorElevation=null;let e=this._camera.getTransformForUpdate();this._map.getCenterClampedToGround()&&e.recalculateZoomAndCenter(this._map.terrain),this._camera.applyUpdatedTransform(e)}if(r&&u){this._updatingCamera=!0;let e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),t=e=>0!==e&&-this._bearingSnap<e&&e<this._bearingSnap;!e||!e.essential&&zC.prefersReducedMotion?(this._map.fire(new UC("moveend",{originalEvent:s})),t(this._map.getBearing())&&this._map.resetNorth()):(t(e.bearing||this._map.getBearing())&&(e.bearing=0),e.freezeElevation=!0,this._map.easeTo(e,{originalEvent:s})),this._updatingCamera=!1}}_fireEvent(e,t){this._map.fire(new UC(e,t?{originalEvent:t}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(e=>{delete this._frameId,this.handleEvent(new IO("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}},MO=class extends zf{constructor(e){super(),this._renderFrameCallback=()=>{let e=Math.min((OC()-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.transform=new _R,this.cameraHelper=new SR,void 0!==e.minZoom&&this.transform.setMinZoom(e.minZoom),void 0!==e.maxZoom&&this.transform.setMaxZoom(e.maxZoom),void 0!==e.minPitch&&this.transform.setMinPitch(e.minPitch),void 0!==e.maxPitch&&this.transform.setMaxPitch(e.maxPitch),void 0!==e.renderWorldCopies&&this.transform.setRenderWorldCopies(e.renderWorldCopies),null!==e.transformConstrain&&this.transform.setConstrainOverride(e.transformConstrain),this._moving=!1,this._zooming=!1,this._bearingSnap=e.bearingSnap,this._zoomSnap=e.zoomSnap,this._requestRenderFrame=e.requestRenderFrame,this._cancelRenderFrame=e.cancelRenderFrame,this.terrain=e.terrain,this._centerClampedToGround=e.centerClampedToGround??!0,this.transformCameraUpdate=e.transformCameraUpdate??null,this._stopHandlers=e.stopHandlers??(()=>{}),this.on("moveend",()=>{delete this._requestedCameraState})}migrateProjection(e,t){if(e.apply(this.transform,!0),this.transform=e,this.cameraHelper=t,this._requestedCameraState){let t=e.clone();t.apply(this._requestedCameraState,!0),this._requestedCameraState=t}}getCenter(){return new nS(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,t,r){return e=Sd.convert(e).mult(-1),this.panTo(this.transform.center,jp({offset:e},t),r)}panTo(e,t,r){return this.easeTo(jp({center:e},t),r)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,t,r){return this.easeTo(jp({zoom:e},t),r)}zoomIn(e,t){return this.zoomTo(Wp(this.getZoom()+1,this._zoomSnap),e,t),this}zoomOut(e,t){return this.zoomTo(Wp(this.getZoom()-1,this._zoomSnap),e,t),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,t){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new UC("movestart",t)).fire(new UC("move",t)).fire(new UC("moveend",t))),this}getBearing(){return this.transform.bearing}setZoomSnap(e){return this._zoomSnap=e,this}getZoomSnap(){return this._zoomSnap}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(e,t,r){return this.easeTo(jp({bearing:e},t),r)}resetNorth(e,t){return this.rotateTo(0,jp({duration:1e3},e),t),this}resetNorthPitch(e,t){return this.easeTo(jp({bearing:0,pitch:0,roll:0,duration:1e3},e),t),this}snapToNorth(e,t){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(e,t):this}getPitch(){return this.transform.pitch}setPitch(e,t){return this.jumpTo({pitch:e},t),this}getRoll(){return this.transform.roll}setRoll(e,t){return this.jumpTo({roll:e},t),this}cameraForBounds(e,t){e=JF.convert(e).adjustAntiMeridian();let r=t?.bearing||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),r,t)}_cameraForBoxAndBearing(e,t,r,i){let n={top:0,bottom:0,right:0,left:0};if("number"==typeof(i=jp({padding:n,offset:[0,0],maxZoom:this.transform.maxZoom},i)).padding){let e=i.padding;i.padding={top:e,bottom:e,right:e,left:e}}let a=jp(n,i.padding);i.padding=a;let s=this.transform,o=new JF(e,t),l=this.cameraHelper.cameraForBoxAndBearing(i,a,o,r,s);return l&&this._zoomSnap&&(l.zoom=Wp(l.zoom,this._zoomSnap,-1)),l}fitBounds(e,t,r){return this._fitInternal(this.cameraForBounds(e,t),t,r)}fitScreenCoordinates(e,t,r,i,n){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(Sd.convert(e)),this.transform.screenPointToLocation(Sd.convert(t)),r,i),i,n)}_fitInternal(e,t,r){return e?(delete(t=jp(e,t)).padding,t.linear?this.easeTo(t,r):this.flyTo(t,r)):this}jumpTo(e,t){this.stop(),void 0!==e.zoom&&this._zoomSnap&&(e.zoom=Wp(e.zoom,this._zoomSnap));let r=this.getTransformForUpdate(),i=!1,n=!1,a=!1,s=r.zoom;this.terrain&&r.setElevation(this.terrain.getElevationForLngLat(e.center?nS.convert(e.center):r.center,r)),this.cameraHelper.handleJumpToCenterZoom(r,e);let o=r.zoom!==s;return void 0!==e.elevation&&r.elevation!==+e.elevation&&r.setElevation(+e.elevation),void 0!==e.bearing&&r.bearing!==+e.bearing&&(i=!0,r.setBearing(+e.bearing)),void 0!==e.pitch&&r.pitch!==+e.pitch&&(n=!0,r.setPitch(+e.pitch)),void 0!==e.roll&&r.roll!==+e.roll&&(a=!0,r.setRoll(+e.roll)),null!=e.padding&&!r.isPaddingEqual(e.padding)&&r.setPadding(e.padding),this.applyUpdatedTransform(r),this.fire(new UC("movestart",t)).fire(new UC("move",t)),o&&this.fire(new UC("zoomstart",t)).fire(new UC("zoom",t)).fire(new UC("zoomend",t)),i&&this.fire(new UC("rotatestart",t)).fire(new UC("rotate",t)).fire(new UC("rotateend",t)),n&&this.fire(new UC("pitchstart",t)).fire(new UC("pitch",t)).fire(new UC("pitchend",t)),a&&this.fire(new UC("rollstart",t)).fire(new UC("roll",t)).fire(new UC("rollend",t)),this.fire(new UC("moveend",t))}calculateCameraOptionsFromCameraLngLatAltRotation(e,t,r,i,n){let a=this.transform.calculateCenterFromCameraLngLatAlt(e,t,r,i);return{center:a.center,elevation:a.elevation,zoom:a.zoom,bearing:r,pitch:i,roll:n}}easeTo(e,t){this._stop(!1,e.easeId),void 0!==(e=jp({offset:[0,0],duration:500,easing:Op},e)).zoom&&this._zoomSnap&&(e.zoom=Wp(e.zoom,this._zoomSnap)),(!1===e.animate||!e.essential&&zC.prefersReducedMotion)&&(e.duration=0);let r,i,n=this.getTransformForUpdate(),a=this.getBearing(),s=n.pitch,o=n.roll,l=void 0===e.bearing?a:this._normalizeBearing(e.bearing,a),u=void 0===e.pitch?s:+e.pitch,c=void 0===e.roll?o:this._normalizeBearing(e.roll,o),h=void 0===e.padding?n.padding:e.padding,d=Sd.convert(e.offset);e.around&&(r=nS.convert(e.around),i=n.locationToScreenPoint(r));let p={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},f=this.cameraHelper.handleEaseTo(n,{bearing:l,pitch:u,roll:c,padding:h,around:r,aroundPoint:i,offsetAsPoint:d,offset:e.offset,zoom:e.zoom,center:e.center});return this._rotating||=a!==l,this._pitching||=u!==s,this._rolling||=c!==o,this._padding=!n.isPaddingEqual(h),this._zooming||=f.isZooming,this._easeId=e.easeId,this._prepareEase(t,e.noMoveStart,p),this.terrain&&this._prepareElevation(f.elevationCenter),this._ease(r=>{f.easeFunc(r),this.terrain&&!e.freezeElevation&&this._updateElevation(r),this.applyUpdatedTransform(n),this._fireMoveEvents(t)},r=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(t,r)},e),this}_prepareEase(e,t,r={}){this._moving=!0,!t&&!r.moving&&this.fire(new UC("movestart",e)),this._zooming&&!r.zooming&&this.fire(new UC("zoomstart",e)),this._rotating&&!r.rotating&&this.fire(new UC("rotatestart",e)),this._pitching&&!r.pitching&&this.fire(new UC("pitchstart",e)),this._rolling&&!r.rolling&&this.fire(new UC("rollstart",e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLat(e,this.transform),this.elevationFreeze=!0}_updateElevation(e){(void 0===this._elevationStart||void 0===this._elevationCenter)&&this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));let t=this.terrain.getElevationForLngLat(this._elevationCenter,this.transform);if(e<1&&t!==this._elevationTarget){let r=this._elevationTarget-this._elevationStart,i=(t-(r*e+this._elevationStart))/(1-e);this._elevationStart+=e*(r-i),this._elevationTarget=t}this.transform.setElevation(ng.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(),r=e.getCameraAltitude(),i=this.terrain?this.terrain.getElevationForLngLatZoom(t,e.zoom):0;if(r<i){let r=e.calculateCameraOptionsFromTo(t,i,e.center,e.elevation);return{pitch:r.pitch,zoom:r.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 r=e.clone();for(let i of t){let e=r.clone(),{center:t,zoom:n,roll:a,pitch:s,bearing:o,elevation:l}=i(e);t&&e.setCenter(t),void 0!==l&&e.setElevation(l),void 0!==n&&e.setZoom(n),void 0!==a&&e.setRoll(a),void 0!==s&&e.setPitch(s),void 0!==o&&e.setBearing(o),r.apply(e,!1)}this.transform.apply(r,!1)}_fireMoveEvents(e){this.fire(new UC("move",e)),this._zooming&&this.fire(new UC("zoom",e)),this._rotating&&this.fire(new UC("rotate",e)),this._pitching&&this.fire(new UC("pitch",e)),this._rolling&&this.fire(new UC("roll",e))}_afterEase(e,t){if(this._easeId&&t&&this._easeId===t)return;delete this._easeId;let r=this._zooming,i=this._rotating,n=this._pitching,a=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,r&&this.fire(new UC("zoomend",e)),i&&this.fire(new UC("rotateend",e)),n&&this.fire(new UC("pitchend",e)),a&&this.fire(new UC("rollend",e)),this.fire(new UC("moveend",e))}flyTo(e,t){if(!e.essential&&zC.prefersReducedMotion){let r=Vp(e,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(r,t)}this.stop(),void 0!==(e=jp({offset:[0,0],speed:1.2,curve:1.42,easing:Op},e)).zoom&&this._zoomSnap&&(e.zoom=Wp(e.zoom,this._zoomSnap));let r=this.getTransformForUpdate(),i=r.bearing,n=r.pitch,a=r.roll,s=r.padding,o=void 0===e.bearing?i:this._normalizeBearing(e.bearing,i),l=void 0===e.pitch?n:+e.pitch,u=void 0===e.roll?a:this._normalizeBearing(e.roll,a),c=void 0===e.padding?r.padding:e.padding,h=Sd.convert(e.offset),d=r.centerPoint.add(h),p=r.screenPointToLocation(d),f=this.cameraHelper.handleFlyTo(r,{bearing:o,pitch:l,roll:u,padding:c,locationAtOffset:p,offsetAsPoint:h,center:e.center,minZoom:e.minZoom,zoom:e.zoom}),m=e.curve,g=Math.max(r.width,r.height),y=g/f.scaleOfZoom,_=f.pixelPathLength,v=g/f.scaleOfMinZoom;m=Math.min(m,Math.sqrt(v/_*2));let x=m*m;function b(e){let t=(y*y-g*g+(e?-1:1)*x*x*_*_)/(2*(e?y:g)*x*_);return Math.log(Math.sqrt(t*t+1)-t)}function w(e){return(Math.exp(e)-Math.exp(-e))/2}function E(e){return(Math.exp(e)+Math.exp(-e))/2}let S=b(!1),D=function(e){return E(S)/E(S+m*e)},T=function(e){return g*((E(S)*function(e){return w(e)/E(e)}(S+m*e)-w(S))/x)/_},A=(b(!0)-S)/m;if(Math.abs(_)<2e-6||!isFinite(A)){if(Math.abs(g-y)<1e-6)return this.easeTo(e,t);let r=y<g?-1:1;A=Math.abs(Math.log(y/g))/m,T=()=>0,D=e=>Math.exp(r*m*e)}if(void 0!==e.duration)e.duration=+e.duration;else{let t=void 0===e.screenSpeed?+e.speed:+e.screenSpeed/m;e.duration=1e3*A/t}return e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=i!==o,this._pitching=l!==n,this._rolling=u!==a,this._padding=!r.isPaddingEqual(c),this._prepareEase(t,!1),this.terrain&&this._prepareElevation(f.targetCenter),this._ease(p=>{let m=p*A,g=1/D(m),y=T(m);this._rotating&&r.setBearing(ng.number(i,o,p)),this._pitching&&r.setPitch(ng.number(n,l,p)),this._rolling&&r.setRoll(ng.number(a,u,p)),this._padding&&(r.interpolatePadding(s,c,p),d=r.centerPoint.add(h)),f.easeFunc(p,g,y,d),this.terrain&&!e.freezeElevation&&this._updateElevation(p),this.applyUpdatedTransform(r),this._fireMoveEvents(t)},()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(t)},e),this}isEasing(){return!!this._easeFrameId}stop(e){return this._stop(e)}_stop(e,t){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||this._stopHandlers(),this}_ease(e,t,r){!1===r.animate||0===r.duration?(e(1),t()):(this._easeStart=OC(),this._easeOptions=r,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,t){e=Np(e,-180,180);let r=Math.abs(e-t);return Math.abs(e-360-t)<r&&(e-=360),Math.abs(e+360-t)<r&&(e+=360),e}isMoving(){return this._moving}isZooming(){return this._zooming}isRotating(){return this._rotating}};const kO={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};var RO=class{constructor(e=kO){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=e=>{e&&("terrain"===e.type||"style"===e.dataType||"source"===e.dataType&&("metadata"===e.sourceDataType||"visibility"===e.sourceDataType))&&this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):!this._container.classList.contains("maplibregl-compact")&&!this._container.classList.contains("maplibregl-attrib-empty")&&(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=$C.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=$C.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=$C.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(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(e,t){let r=this._map._getUIString(`AttributionControl.${t}`);e.title=r,e.setAttribute("aria-label",r)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map(e=>"string"==typeof e?e:"")):"string"==typeof this.options.customAttribution&&e.push(this.options.customAttribution)),this._map.style.stylesheet){let e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}let t=this._map.style.tileManagers;for(let i in t){let r=t[i];if(r.used||r.usedForTerrain){let t=r.getSource();t.attribution&&!e.includes(t.attribution)&&e.push(t.attribution)}}e=e.filter(e=>String(e).trim()),e.sort((e,t)=>e.length-t.length),e=e.filter((t,r)=>{for(let i=r+1;i<e.length;i++)if(e[i].includes(t))return!1;return!0});let r=e.join(" | ");r!==this._attribHTML&&(this._attribHTML=r,e.length?(this._innerContainer.innerHTML=$C.sanitize(r),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}},LO=class{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?.compact,this._container=$C.create("div","maplibregl-ctrl");let t=$C.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(){this._container.remove(),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}},zO=class{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,r=t?this._queue.concat(t):this._queue;for(let i of r)if(i.id===e)return void(i.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=[];let r,i=!1;for(let n of t)if(!n.cancelled){try{n.callback(e)}catch(e){i||(i=!0,r=e)}if(this._cleared)break}if(this._cleared=!1,this._currentlyRunning=!1,i)throw r}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}};const BO=["none","zoom","sourceTiles","visibleLayers","revision"];var OO=class{constructor(e,t,r,i){this._tileKeys=e.map(e=>e.key).sort().join(),this._revision=t,this._zoom=r,this._visibleLayerIds=i}difference(e){return this._revision===e?._revision?this._visibleLayerIds===e._visibleLayerIds?this._tileKeys===e._tileKeys?this._zoom===e._zoom?"none":"zoom":"sourceTiles":"visibleLayers":"revision"}};const $O={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};var NO=class{constructor(e,t){this.needsFollowUpFrame=!1,this.painter=e,this.terrain=t,this.rttSize=t.tileManager.tileSize*t.qualityFactor}getTexture(e){return e.getRTT(this._stacks.length-1).texture}prepareForRender(e,t){let r=t!==this._lastPrepareZoom;this._lastPrepareZoom=t,this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=e._order.filter(r=>!e._layers[r].isHidden(t));let i=this._renderableLayerIds.join(),n=new Set;for(let o of this._renderableLayerIds){let t=e._layers[o],r=t.source;r&&$O[t.type]&&n.add(r)}this._coordsAscending={},this._rttFingerprints={};for(let o of n){let r=e.tileManagers[o];if(!r)continue;this._coordsAscending[o]={};let n=this._coordsAscending[o],a=r.getSource(),s=a instanceof vM?a.terrainTileRanges:null;for(let e of r.getVisibleCoordinates()){let t=this.terrain.tileManager.getTerrainCoords(e,s);for(let e in t)n[e]||=[],n[e].push(t[e])}this._rttFingerprints[o]={};let l=this._rttFingerprints[o],u=r.getState().revision;for(let e in n)l[e]=new OO(n[e],u,t,i)}this.needsFollowUpFrame=!1;let a=r||this.painter.options.moving,s=!1;for(let o of this._renderableTiles){let e=this._textureDifference(o);"none"!==e&&("zoom"===e&&a||"visibleLayers"===e&&r?this.needsFollowUpFrame=!0:"zoom"===e||"sourceTiles"===e?(s?this.needsFollowUpFrame=!0:o.releaseRTT(this.painter),s=!0):o.releaseRTT(this.painter))}}_textureDifference(e){let t="none";for(let r in this._rttFingerprints){let i=this._rttFingerprints[r][e.tileID.key];if(!i)continue;let n=i.difference(e.rttFingerprint[r]);BO.indexOf(n)>BO.indexOf(t)&&(t=n)}return t}renderLayer(e,t){if(e.isHidden(this.painter.transform.zoom))return!1;let r={...t,isRenderingToTexture:!0},i=e.type,n=this.painter,a=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if($O[i]&&((!this._prevType||!$O[this._prevType])&&this._stacks.push([]),this._prevType=i,this._stacks[this._stacks.length-1].push(e.id),!a))return!0;if($O[this._prevType]||$O[i]&&a){this._prevType=i;let e=this._stacks.length-1,t=this._stacks[e]||[];for(let i of this._renderableTiles){if(this._rttTiles.push(i),i.getRTT(e))continue;let a=i.acquireRTT(n,e,this.rttSize);n.bindRTT(a),n.context.clear({color:Rm.transparent,stencil:0}),n.currentStencilSource=void 0;for(let e of t){let t=n.style._layers[e],a=t.source?this._coordsAscending[t.source][i.tileID.key]:[i.tileID];n.context.viewport.set([0,0,this.rttSize,this.rttSize]),n.renderTileClippingMasks(t,a,!0),n.renderLayer(n,n.style.tileManagers[t.source],t,a,r),t.source&&(i.rttFingerprint[t.source]=this._rttFingerprints[t.source][i.tileID.key])}a.texture.generateMipmap()}return function(e,t,r,i){let{isRenderingGlobe:n}=i,a=e.context,s=a.gl,o=e.transform,l=e.colorModeForRenderPass(),u=e.getDepthModeFor3D(),c=e.useProgram("terrain");a.bindFramebuffer.set(null),a.viewport.set([0,0,e.width,e.height]);for(let h of r){let r=t.getTerrainMesh(h.tileID),i=e.renderToTexture.getTexture(h),d=t.getTerrainData(h.tileID);a.activeTexture.set(s.TEXTURE0),i.bind(s.LINEAR,s.CLAMP_TO_EDGE,s.LINEAR_MIPMAP_LINEAR);let p=t.getSkirtLength(o.zoom),f=o.calculateFogMatrix(h.tileID.toUnwrapped()),m=sL(p,f,e.style.sky,o.pitch,n),g=o.getProjectionData({overscaledTileID:h.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});c.draw(a,s.TRIANGLES,u,$z.disabled,l,jz.backCCW,m,d,g,"terrain",r.vertexBuffer,r.indexBuffer,r.segments)}}(this.painter,this.terrain,this._rttTiles,r),this._rttTiles=[],$O[i]}return!1}};const jO={"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":"Drag to rotate map, click to reset 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"},VO={hash:!1,interactive:!0,bearingSnap:7,zoomSnap:0,attributionControl:kO,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:Ef.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,transformConstrain:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,rollEnabled:!1,rotateSpeed:.8,pitchSpeed:-.5,reduceMotion:void 0,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0,terrainSkirtLength:"auto",zoomLevelsToOverscale:4,anisotropicFilterPitch:20};var UO=class extends zf{get _ownerWindow(){return this._container?.ownerDocument?.defaultView||window}constructor(e){super(),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new zO,this._controls=[],this._mapId=qp(),this._styleUrl=null,this._missingStyleImageResolver=null,this._lostContextStyle={style:null,images:null},this._contextLost=e=>{if(e.preventDefault(),this._frameRequest&&=(this._frameRequest.abort(),null),this.painter.destroy(),this._lostContextStyle=this._getStyleAndImages(),this.style){for(let e of Object.values(this.style._layers))if("custom"===e.type&&console.warn(`Custom layer with id '${e.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),e._listeners)for(let[t]of Object.entries(e._listeners))console.warn(`Custom layer with id '${e.id}' had event listeners for event '${t}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`);this.style.destroy(),this.style=null,this.fire(new QC("webglcontextlost",{originalEvent:e}))}else this.fire(new QC("webglcontextlost",{originalEvent:e}))},this._contextRestored=e=>{if(this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&this.style){this.style.imageManager.images=this._lostContextStyle.images;for(let e in this._lostContextStyle.images){let t=this._lostContextStyle.images[e];t.isWebGLImage&&this.style.imageManager.updateImage(e,t,!1)}}this._lostContextStyle={style:null,images:null};try{this._setupPainter()}catch(e){return void this.fire(new Lf(e))}this.resize(),this._update(),this._resizeInternal(),this.fire(new QC("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()};let t={...VO,...e,canvasContextAttributes:{...VO.canvasContextAttributes,...e.canvasContextAttributes}};if(null!=t.minZoom&&null!=t.maxZoom&&t.minZoom>t.maxZoom)throw Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>180)throw Error("maxPitch must be less than or equal to 180");this._camera=new MO({minZoom:t.minZoom,maxZoom:t.maxZoom,minPitch:t.minPitch,maxPitch:t.maxPitch,bearingSnap:t.bearingSnap,zoomSnap:t.zoomSnap,renderWorldCopies:t.renderWorldCopies,centerClampedToGround:t.centerClampedToGround,terrain:this.terrain,transformConstrain:t.transformConstrain,requestRenderFrame:e=>this._requestRenderFrame(e),cancelRenderFrame:e=>this._cancelRenderFrame(e),transformCameraUpdate:t.transformCameraUpdate,stopHandlers:()=>this._handlers?.stop(!1)}),this._camera.setEventedParent(this),this._interactive=t.interactive,this._maxTileCacheSize=t.maxTileCacheSize,this._maxTileCacheZoomLevels=t.maxTileCacheZoomLevels,this._canvasContextAttributes={...t.canvasContextAttributes},this._trackResize=!0===t.trackResize,this._terrainSkirtLength=t.terrainSkirtLength,this._refreshExpiredTiles=!0===t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._crossSourceCollisions=!0===t.crossSourceCollisions,this._collectResourceTiming=!0===t.collectResourceTiming,this._locale={...jO,...t.locale},this._clickTolerance=t.clickTolerance,this._overridePixelRatio=t.pixelRatio,this._maxCanvasSize=t.maxCanvasSize,this._zoomLevelsToOverscale=t.zoomLevelsToOverscale,this.cancelPendingTileRequestsWhileZooming=!0===t.cancelPendingTileRequestsWhileZooming,this.setAnisotropicFilterPitch(t.anisotropicFilterPitch),void 0!==t.reduceMotion&&(zC.prefersReducedMotion=t.reduceMotion),this._requestManager=new jC(t.transformRequest),this._container=this._resolveContainer(t.container),t.maxBounds&&this.setMaxBounds(t.maxBounds),this._setupContainer();try{this._setupPainter()}catch(e){throw this._cleanupContainer(),e}this._imageQueueHandle=NC.addThrottleControl(()=>this.isMoving()),this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this.on("terrain",()=>{this.painter.terrainFacilitator.depthDirty=!0,this._update(!0)}),this.once("idle",()=>this._idleTriggered=!0),this._handlers=new FO(this,this._camera,t),typeof window<"u"&&(this._ownerWindow.addEventListener("online",this._onWindowOnline,!1),this._setupResizeObserver());let r="string"==typeof t.hash&&t.hash||void 0;this._hash=t.hash?new zB(r).addTo(this):void 0,this._hash?._onHashChange()||(this.jumpTo({center:t.center,elevation:t.elevation,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch,roll:t.roll}),t.bounds&&(this.resize(),this.fitBounds(t.bounds,jp({},t.fitBoundsOptions,{duration:0}))));let i="string"==typeof t.style||"globe"!==t.style?.projection?.type;this.resize(null,i),this._localIdeographFontFamily=t.localIdeographFontFamily,this._validateStyle=t.validateStyle,t.style&&this.setStyle(t.style,{localIdeographFontFamily:t.localIdeographFontFamily}),t.attributionControl&&this.addControl(new RO("boolean"==typeof t.attributionControl?void 0:t.attributionControl)),t.maplibreLogo&&this.addControl(new LO,t.logoPosition),this.on("style.load",()=>{if(i||this._resizeTransform(),this._camera.transform.unmodified){let e=Vp(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(e)}}),this.on("data",e=>{this._update("style"===e.dataType),this.fire("style"===e.dataType?new GC("styledata",e):new ZC("sourcedata",e))}),this.on("dataloading",e=>{this.fire("style"===e.dataType?new GC("styledataloading",e):new ZC("sourcedataloading",e))}),this.on("dataabort",e=>{this.fire(new ZC("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,t){if(void 0===t&&(t=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e?.onAdd)return this.fire(new Lf(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[t];return t.includes("bottom")?i.insertBefore(r,i.firstChild):i.appendChild(r),this}removeControl(e){if(!e?.onRemove)return this.fire(new Lf(Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));let t=this._controls.indexOf(e);return t>-1&&this._controls.splice(t,1),e.onRemove(this),this}hasControl(e){return this._controls.includes(e)}coveringTiles(e){return $M(this._camera.transform,e)}setTransformCameraUpdate(e){this._camera.transformCameraUpdate=e}getCenter(){return new nS(this._camera.transform.center.lng,this._camera.transform.center.lat)}setCenter(e,t){return this._camera.setCenter(e,t),this}getCenterElevation(){return this._camera.transform.elevation}setCenterElevation(e,t){return this._camera.setCenterElevation(e,t),this}setCenterClampedToGround(e){this._camera.setCenterClampedToGround(e)}panBy(e,t,r){return this._camera.panBy(e,t,r),this}panTo(e,t,r){return this._camera.panTo(e,t,r),this}getZoom(){return this._camera.transform.zoom}setZoom(e,t){return this._camera.setZoom(e,t),this}zoomTo(e,t,r){return this._camera.zoomTo(e,t,r),this}zoomIn(e,t){return this._camera.zoomIn(e,t),this}zoomOut(e,t){return this._camera.zoomOut(e,t),this}getVerticalFieldOfView(){return this._camera.transform.fov}setVerticalFieldOfView(e,t){return this._camera.setVerticalFieldOfView(e,t),this}getBearing(){return this._camera.transform.bearing}setBearing(e,t){return this._camera.setBearing(e,t),this}getZoomSnap(){return this._camera.getZoomSnap()}setZoomSnap(e){return this._camera.setZoomSnap(e),this}getPadding(){return this._camera.transform.padding}setPadding(e,t){return this._camera.setPadding(e,t),this}rotateTo(e,t,r){return this._camera.rotateTo(e,t,r),this}resetNorth(e,t){return this._camera.resetNorth(e,t),this}resetNorthPitch(e,t){return this._camera.resetNorthPitch(e,t),this}snapToNorth(e,t){return this._camera.snapToNorth(e,t),this}getPitch(){return this._camera.transform.pitch}setPitch(e,t){return this._camera.setPitch(e,t),this}getRoll(){return this._camera.transform.roll}setRoll(e,t){return this._camera.setRoll(e,t),this}cameraForBounds(e,t){return this._camera.cameraForBounds(e,t)}fitBounds(e,t,r){return this._camera.fitBounds(e,t,r),this}fitScreenCoordinates(e,t,r,i,n){return this._camera.fitScreenCoordinates(e,t,r,i,n),this}jumpTo(e,t){return this._camera.jumpTo(e,t),this}calculateCameraOptionsFromCameraLngLatAltRotation(e,t,r,i,n){return this._camera.calculateCameraOptionsFromCameraLngLatAltRotation(e,t,r,i,n)}easeTo(e,t){return this._camera.easeTo(e,t),this}flyTo(e,t){return this._camera.flyTo(e,t),this}stop(){return this._camera.stop(),this}queryTerrainElevation(e){return this.terrain?this.terrain.getElevationForLngLat(nS.convert(e),this._camera.transform):null}getCenterClampedToGround(){return this._camera.getCenterClampedToGround()}calculateCameraOptionsFromTo(e,t,r,i){return null==i&&this.terrain&&(i=this.terrain.getElevationForLngLat(r,this._camera.transform)),this._camera.transform.calculateCameraOptionsFromTo(e,t,r,i??0)}resize(e,t=!0){if(null!==this._lostContextStyle.style)return this;this._resizeInternal(t);let r=!this._camera._moving;return r&&(this.stop(),this.fire(new UC("movestart",e)).fire(new UC("move",e))),this.fire(new VC("resize",e)),r&&this.fire(new UC("moveend",e)),this}_resizeInternal(e=!0){let[t,r]=this._containerDimensions(),i=this._getClampedPixelRatio(t,r);if(this._resizeCanvas(t,r,i),this.painter.resize(t,r,i),this.painter.overLimit()){let e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];let i=this._getClampedPixelRatio(t,r);this._resizeCanvas(t,r,i),this.painter.resize(t,r,i)}this._resizeTransform(e)}_resizeTransform(e=!0){let[t,r]=this._containerDimensions();this._camera.transform.resize(t,r,e),this._camera._requestedCameraState?.resize(t,r,e)}_getClampedPixelRatio(e,t){let{0:r,1:i}=this._maxCanvasSize,n=this.getPixelRatio(),a=e*n,s=t*n,o=a>r?r/a:1,l=s>i?i/s:1,u=Math.min(o,l);return u<1&&Qp("The canvas is larger than maxCanvasSize and is rendered at a lower pixel ratio to fit. Increase maxCanvasSize, within MAX_TEXTURE_SIZE, to render at full resolution."),u*n}getPixelRatio(){return this._overridePixelRatio??devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize()}getBounds(){return this._camera.transform.getBounds()}getMaxBounds(){return this._camera.transform.getMaxBounds()}setMaxBounds(e){return this._camera.transform.setMaxBounds(JF.convert(e)),this._update()}setMinZoom(e){if(e??=-2,e>=-2&&e<=this._camera.transform.maxZoom){let t=this._camera.transform.zoom,r=this._camera.getTransformForUpdate();return r.setMinZoom(e),this._camera.applyUpdatedTransform(r),this._update(),t!==this._camera.transform.zoom&&this.fire(new UC("zoomstart")).fire(new UC("zoom")).fire(new UC("zoomend")).fire(new UC("movestart")).fire(new UC("move")).fire(new UC("moveend")),this}throw Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(e=!1){let t=this._camera.transform;return e?t.applyConstrain(t.center,t.minZoom).zoom:t.minZoom}setMaxZoom(e){if(e??=22,e>=this._camera.transform.minZoom){let t=this._camera.transform.zoom,r=this._camera.getTransformForUpdate();return r.setMaxZoom(e),this._camera.applyUpdatedTransform(r),this._update(),t!==this._camera.transform.zoom&&this.fire(new UC("zoomstart")).fire(new UC("zoom")).fire(new UC("zoomend")).fire(new UC("movestart")).fire(new UC("move")).fire(new UC("moveend")),this}throw Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this._camera.transform.maxZoom}setMinPitch(e){if(e??=0,e<0)throw Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this._camera.transform.maxPitch){let t=this._camera.transform.pitch,r=this._camera.getTransformForUpdate();return r.setMinPitch(e),this._camera.applyUpdatedTransform(r),this._update(),t!==this._camera.transform.pitch&&this.fire(new UC("pitchstart")).fire(new UC("pitch")).fire(new UC("pitchend")).fire(new UC("movestart")).fire(new UC("move")).fire(new UC("moveend")),this}throw Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this._camera.transform.minPitch}setMaxPitch(e){if(e??=60,e>180)throw Error("maxPitch must be less than or equal to 180");if(e>=this._camera.transform.minPitch){let t=this._camera.transform.pitch,r=this._camera.getTransformForUpdate();return r.setMaxPitch(e),this._camera.applyUpdatedTransform(r),this._update(),t!==this._camera.transform.pitch&&this.fire(new UC("pitchstart")).fire(new UC("pitch")).fire(new UC("pitchend")).fire(new UC("movestart")).fire(new UC("move")).fire(new UC("moveend")),this}throw Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this._camera.transform.maxPitch}getAnisotropicFilterPitch(){return this._anisotropicFilterPitch}setAnisotropicFilterPitch(e){if(e??=20,e>180)throw Error("anisotropicFilterPitch must be less than or equal to 180");if(e<0)throw Error("anisotropicFilterPitch must be greater than or equal to 0");return this._anisotropicFilterPitch=e,this._update()}getRenderWorldCopies(){return this._camera.transform.renderWorldCopies}setRenderWorldCopies(e){return this._camera.transform.setRenderWorldCopies(e),this._update()}setTransformConstrain(e){return this._camera.transform.setConstrainOverride(e),this._update()}project(e){return this._camera.transform.locationToScreenPoint(nS.convert(e),this.style&&this.terrain)}unproject(e){return this._camera.transform.screenPointToLocation(Sd.convert(e),this.terrain)}isMoving(){return this._camera.isMoving()||this._handlers?.isMoving()||!1}isZooming(){return this._camera.isZooming()||this._handlers?.isZooming()||!1}isRotating(){return this._camera.isRotating()||this._handlers?.isRotating()||!1}_createDelegatedListener(e,t,r){if("mouseenter"===e||"mouseover"===e){let i=!1;return{layers:t,listener:r,delegates:{mousemove:n=>{let a=t.filter(e=>this.getLayer(e)),s=0===a.length?[]:this.queryRenderedFeatures(n.point,{layers:a});s.length?i||(i=!0,r.call(this,new WC(e,this,n.originalEvent,{features:s}))):i=!1},mouseout:()=>{i=!1}}}}if("mouseleave"===e||"mouseout"===e){let i=!1;return{layers:t,listener:r,delegates:{mousemove:n=>{let a=t.filter(e=>this.getLayer(e));(0===a.length?[]:this.queryRenderedFeatures(n.point,{layers:a})).length?i=!0:i&&(i=!1,r.call(this,new WC(e,this,n.originalEvent)))},mouseout:t=>{i&&(i=!1,r.call(this,new WC(e,this,t.originalEvent)))}}}}{let i=e=>{let i=t.filter(e=>this.getLayer(e)),n=0===i.length?[]:this.queryRenderedFeatures(e.point,{layers:i});n.length&&(e.features=n,r.call(this,e),delete e.features)};return{layers:t,listener:r,delegates:{[e]:i}}}}_saveDelegatedListener(e,t){this._delegatedListeners||={},this._delegatedListeners[e]||=[],this._delegatedListeners[e].push(t)}_removeDelegatedListener(e,t,r){if(!this._delegatedListeners?.[e])return;let i=this._delegatedListeners[e];for(let n=0;n<i.length;n++){let e=i[n];if(e.listener===r&&e.layers.length===t.length&&e.layers.every(e=>t.includes(e))){for(let t in e.delegates)this.off(t,e.delegates[t]);return void i.splice(n,1)}}}on(e,t,r){if(void 0===r)return super.on(e,t);let i="string"==typeof t?[t]:t,n=this._createDelegatedListener(e,i,r);this._saveDelegatedListener(e,n);for(let a in n.delegates)this.on(a,n.delegates[a]);return{unsubscribe:()=>{this._removeDelegatedListener(e,i,r)}}}once(e,t,r){if(void 0===r)return super.once(e,t);let i="string"==typeof t?[t]:t,n=this._createDelegatedListener(e,i,r);for(let a in n.delegates){let t=n.delegates[a];n.delegates[a]=(...n)=>{this._removeDelegatedListener(e,i,r),t(...n)}}this._saveDelegatedListener(e,n);for(let a in n.delegates)this.once(a,n.delegates[a]);return this}off(e,t,r){if(void 0===r)return super.off(e,t);let i="string"==typeof t?[t]:t;return this._removeDelegatedListener(e,i,r),this}queryRenderedFeatures(e,t){if(!this.style)return[];let r,i=e instanceof Sd||Array.isArray(e),n=i?e:[[0,0],[this._camera.transform.width,this._camera.transform.height]];if(t||=(i?{}:e)||{},n instanceof Sd||"number"==typeof n[0])r=[Sd.convert(n)];else{let e=Sd.convert(n[0]),t=Sd.convert(n[1]);r=[e,new Sd(t.x,e.y),t,new Sd(e.x,t.y),e]}return this.style.queryRenderedFeatures(r,t,this._camera.transform)}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}setStyle(e,t){return t=jp({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},t),this._styleUrl="string"==typeof e?e:null,!1!==t.diff&&t.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,t),this):(this._localIdeographFontFamily=t.localIdeographFontFamily,this._updateStyle(e,t))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){let t=this._locale[e];if(null==t)throw Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){if(this._diffStyleRequest?.abort(),this._diffStyleRequest=null,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 iL(this,t||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e,t,r):this.style.loadJSON(e,t,r),this):(this._frameRequest&&=(this._frameRequest.abort(),null),this.style?.projection?.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new iL(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}async _diffStyle(e,t){if(this._diffStyleRequest?.abort(),"string"==typeof e){let r=e;this._diffStyleRequest=new AbortController;let i=this._diffStyleRequest;try{let e=await this._requestManager.transformRequest(r,"Style");if(i.signal.aborted)return void(this._diffStyleRequest=null);let n=await If(e,i);this._diffStyleRequest=null,this._updateDiff(n.data,t)}catch(e){this._diffStyleRequest=null,bf(e)||this.fire(new Lf(xp(e)))}}else"object"==typeof e&&(this._diffStyleRequest=null,this._updateDiff(e,t))}_updateDiff(e,t){try{this.style.setState(e,t)&&this._update(!0)}catch(vd){Qp(`Unable to perform style diff: ${xp(vd).message}. Rebuilding the style from scratch.`),this._updateStyle(e,t)}}getStyle(){if(this.style)return this.style.serialize()}getStyleUrl(){return this._styleUrl}_getStyleAndImages(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){if(this.style)return this.style.loaded();Qp("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 t=this.style?.tileManagers[e];if(void 0!==t)return t.loaded();this.fire(new Lf(Error(`There is no tile manager with ID '${e}'`)))}setTerrain(e,t={}){if(this.style._checkLoaded(),e&&gv(this,dv.terrain,{value:e},t))return this;if(this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),e){let t=this.style.tileManagers[e.source];if(!t)throw Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);null===this.terrain&&t.reload();for(let r in this.style._layers){let t=this.style._layers[r];"hillshade"===t.type&&t.source===e.source&&Qp("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality."),"color-relief"===t.type&&t.source===e.source&&Qp("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&&this.terrain.destroy(),this.terrain=new pR(this.painter,t,e,this._terrainSkirtLength),this.painter.renderToTexture=new NO(this.painter,this.terrain),this._camera.terrain=this.terrain,this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),this._camera.transform.setElevation(this.terrain.getElevationForLngLat(this._camera.transform.center,this._camera.transform)),this._terrainDataCallback=t=>this._handleTerrainDataEvent(t,e.source),this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.destroy(),this.terrain=null,this.painter.renderToTexture=null,this._camera.terrain=null,this._camera.transform.setMinElevationForCurrentTile(0),this.getCenterClampedToGround()&&this._camera.transform.setElevation(0);return this.style.triggerSymbolPlacement(),this.fire(new KC({terrain:e})),this}_handleTerrainDataEvent(e,t){if("style"===e.dataType)return void this.terrain.tileManager.releaseAllRTT();let r=e.sourceId===t;if(r&&(this.terrain.resetElevationCache(),this.style.triggerSymbolPlacement()),r&&e.tile&&!this._camera.elevationFreeze&&(this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),this.getCenterClampedToGround()&&this._camera.transform.setElevation(this.terrain.getElevationForLngLat(this._camera.transform.center,this._camera.transform))),e.tile){if("image"===e.source?.type)return void this.terrain.tileManager.releaseAllRTT();this.terrain.tileManager.releaseRTT(e.tile.tileID)}}getTerrain(){return this.terrain?.options??null}areTilesLoaded(){let e=this.style?.tileManagers;for(let t of Object.values(e))if(!t.areTilesLoaded())return!1;return!0}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style?.getSource(e)}setSourceTileLodParams(e,t,r){if(r){let i=this.getSource(r);if(!i)throw Error(`There is no source with ID "${r}", cannot set LOD parameters`);i.calculateTileZoom=zM(Math.max(1,e),Math.max(1,t))}else for(let i in this.style.tileManagers)this.style.tileManagers[i].getSource().calculateTileZoom=zM(Math.max(1,e),Math.max(1,t));return this._update(!0),this}refreshTiles(e,t){let r=this.style.tileManagers[e];if(!r)throw Error(`There is no tile manager with ID "${e}", cannot refresh tile`);void 0===t?r.reload(!0):r.refreshTiles(t.map(e=>new TA(e.z,e.x,e.y)))}addImage(e,t,r={}){this._lazyInitEmptyStyle();let i=this._createStyleImage(t,r);return i?(this.style.addImage(e,i),i.userImage?.onAdd&&i.userImage.onAdd(this,e),this):this}setMissingStyleImageResolver(e){return this._missingStyleImageResolver=e,this.style?.setMissingImageResolver(e),this}_createStyleImage(e,t={}){let{pixelRatio:r=1,sdf:i=!1,stretchX:n,stretchY:a,content:s,textFitWidth:o,textFitHeight:l}=t;if(e instanceof HTMLImageElement||af(e)){let{width:t,height:u,data:c}=zC.getImageData(e);return{data:new Dw({width:t,height:u},c),pixelRatio:r,stretchX:n,stretchY:a,content:s,textFitWidth:o,textFitHeight:l,sdf:i,version:0}}if(void 0===e.width||void 0===e.height)return this.fire(new Lf(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`"))),null;{let{width:t,height:u,data:c}=e,h=e,d=QD(h.data);return{data:d?new Dw({width:t,height:u}):new Dw({width:t,height:u},new Uint8Array(c)),pixelRatio:r,stretchX:n,stretchY:a,content:s,textFitWidth:o,textFitHeight:l,sdf:i,version:0,isWebGLImage:d,userImage:h}}}updateImage(e,t){let r=this.style.getImage(e);if(!r)return this.fire(new Lf(Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let{width:i,height:n,data:a}=t instanceof HTMLImageElement||af(t)?zC.getImageData(t):t;if(void 0===i||void 0===n)return this.fire(new Lf(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||n!==r.data.height)return this.fire(new Lf(Error("The width and height of the updated image must be that same as the previous version of the image")));if(r.isWebGLImage=QD(a),r.isWebGLImage)r.userImage=t;else{let e=!(t instanceof HTMLImageElement||af(t));r.data.replace(a,e)}return this.style.updateImage(e,r),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new Lf(Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}async loadImage(e){let t=await NC.getImage(await this._requestManager.transformRequest(e,"Image"),new AbortController);if(!t.data)throw Error(`Could not load image ${e}: the response is empty`);return t}listImages(){return this.style?.listImages()??[]}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style?.getLayer(e)}getLayersOrder(){return this.style?.getLayersOrder()??[]}setLayerZoomRange(e,t,r){return this.style.setLayerZoomRange(e,t,r),this._update(!0)}setFilter(e,t,r={}){return this.style?.setFilter(e,t,r),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,r,i={}){return this.style?.setPaintProperty(e,t,r,i),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,r,i={}){return this.style.setLayoutProperty(e,t,r,i),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()}setFontFaces(e){return this._lazyInitEmptyStyle(),this.style.setFontFaces(e),this._update(!0)}getFontFaces(){return this.style.getFontFaces()}addSprite(e,t,r={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,t,r,e=>{e||this._update(!0)}),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,t,e=>{e||this._update(!0)}),this}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,t=0;return this._container&&(e=this._container.clientWidth||400,t=this._container.clientHeight||300),[e,t]}_shouldHandleInitialResize(){if(!this._container?.clientWidth||!this._container.clientHeight)return!1;let[e,t]=this._containerDimensions();return e!==this._camera.transform.width||t!==this._camera.transform.height}_setupResizeObserver(){let e=!1,t=LB(e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw())},50),r=this._ownerWindow.ResizeObserver??ResizeObserver;this._resizeObserver=new r(r=>{!e&&(e=!0,!this._shouldHandleInitialResize())||t(r)}),this._resizeObserver.observe(this._container)}_resolveContainer(e){if("string"==typeof e){let t=document.getElementById(e);if(!t)throw Error(`Container '${e}' not found.`);return t}if(e instanceof HTMLElement||e&&"object"==typeof e&&1===e.nodeType)return e;throw Error("Invalid type: 'container' must be a String or HTMLElement.")}_setupContainer(){let e=this._container;e.classList.add("maplibregl-map");let t=this._canvasContainer=$C.create("div","maplibregl-canvas-container",e);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=$C.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 r=this._containerDimensions(),i=this._getClampedPixelRatio(r[0],r[1]);this._resizeCanvas(r[0],r[1],i);let n=this._controlContainer=$C.create("div","maplibregl-control-container",e),a=this._controlPositions={};for(let s of["top-left","top-right","bottom-left","bottom-right"])a[s]=$C.create("div",`maplibregl-ctrl-${s} `,n);this._container.addEventListener("scroll",this._onMapScroll,!1)}_cleanupContainer(){this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),this._canvasContainer.remove(),this._controlContainer.remove(),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map")}_resizeCanvas(e,t,r){this._canvas.width=Math.floor(r*e),this._canvas.height=Math.floor(r*t),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`}_setupPainter(){let e={...this._canvasContextAttributes,alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0},t=null;this._canvas.addEventListener("webglcontextcreationerror",e=>{t=e},{once:!0});let r=this._canvas.getContext("webgl2",e);if(!r)throw new RB(e,t);this.painter=new kB(r,this._camera.transform)}migrateProjection(e,t){this._camera.migrateProjection(e,t),this.painter.transform=e,this.fire(new JC({newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style?._loaded?(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){let t=this._idleTriggered?this._fadeDuration:0,r=this.style.projection?.transitionState>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let i=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;let e=this._camera.transform.zoom,r=OC();this.style.zoomHistory.update(e,r);let n=new Tv(e,{now:r,fadeDuration:t,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),a=n.crossFadingFactor();(1!==a||a!==this._crossFadingFactor)&&(i=!0,this._crossFadingFactor=a),this.style.update(n)}let n=this.style.projection?.transitionState>0!==r;this._camera.transform.setTransitionState(this.style.projection?.transitionState),this.style&&(this._sourcesDirty||n)&&(this._sourcesDirty=!1,this.style._updateSources(this._camera.transform)),this.terrain?(this.terrain.tileManager.update(this._camera.transform,this.terrain)&&this.terrain.resetElevationCache(),this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),!this._camera.elevationFreeze&&this.getCenterClampedToGround()&&this._camera.transform.setElevation(this.terrain.getElevationForLngLat(this._camera.transform.center,this._camera.transform))):(this._camera.transform.setMinElevationForCurrentTile(0),this.getCenterClampedToGround()&&this._camera.transform.setElevation(0)),this._placementDirty=this.style?._updatePlacement(this._camera.transform,this.showCollisionBoxes,t,this._crossSourceCollisions,n),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:t,showPadding:this.showPadding,anisotropicFilterPitch:this.getAnisotropicFilterPitch()}),this.fire(new VC("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new VC("load"))),this.style&&(this.style.hasTransitions()||i)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let a=this._sourcesDirty||this._styleDirty||this._placementDirty||this.painter.renderToTexture?.needsFollowUpFrame;return a||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new VC("idle")),this._loaded&&!this._fullyLoaded&&!a&&(this._fullyLoaded=!0),this}redraw(){return this.style&&(this._frameRequest&&=(this._frameRequest.abort(),null),this._render(0)),this}remove(){this._hash&&this._hash.remove();for(let t of this._controls)t.onRemove(this);this._controls=[],this._frameRequest&&=(this._frameRequest.abort(),null),this._renderTaskQueue.clear(),this._diffStyleRequest?.abort(),this.painter.destroy(),this._handlers.destroy(),this.setStyle(null),typeof window<"u"&&this._ownerWindow.removeEventListener("online",this._onWindowOnline,!1),NC.removeThrottleControl(this._imageQueueHandle),this._resizeObserver?.disconnect();let e=this.painter.context.gl.getExtension("WEBGL_lose_context");e?.loseContext&&e.loseContext(),this._cleanupContainer(),this._removed=!0,this.fire(new VC("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,zC.frame(this._frameRequest,e=>{this._frameRequest=null;try{this._render(e)}catch(e){if(!bf(e))throw e}},()=>{},this._ownerWindow))}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"6.9.0"}getCameraTargetElevation(){return this._camera.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}};const qO={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};var GO=class{constructor(e){this._updateZoomButtons=()=>{let e=this._map.getZoom(),t=e===this._map.getMaxZoom(),r=e===this._map.getMinZoom(!0);this._zoomInButton.disabled=t,this._zoomOutButton.disabled=r,this._zoomInButton.setAttribute("aria-disabled",t.toString()),this._zoomOutButton.setAttribute("aria-disabled",r.toString())},this._rotateCompassArrow=()=>{let e=this._map.getPitch(),t=this._map.getRoll(),r=this._map.getBearing(),i=1/Math.cos(lf(e))**.5;this.options.visualizePitch&&this.options.visualizeRoll?this._compassIcon.style.transform=`scale(${i}) rotateZ(${-t}deg) rotateX(${e}deg) rotateZ(${-r}deg)`:this.options.visualizePitch?this._compassIcon.style.transform=`scale(${i}) rotateX(${e}deg) rotateZ(${-r}deg)`:this.options.visualizeRoll?this._compassIcon.style.transform=`rotate(${-r-t}deg)`:this._compassIcon.style.transform=`rotate(${-r}deg)`},this._setButtonTitle=(e,t)=>{let r=this._map._getUIString(`NavigationControl.${t}`);e.title=r,e.setAttribute("aria-label",r)},this.options=jp({},qO,e),this._container=$C.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})),$C.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})),$C.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=$C.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("move",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 ZO(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){this._container.remove(),this.options.showZoom&&this._map.off("move",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 r=$C.create("button",e,this._container);return r.type="button",r.addEventListener("click",t),r}},ZO=class{constructor(e,t,r=!1){this.mousedown=e=>{this.startMove(e,$C.mousePos(this.element,e)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)},this.mousemove=e=>{this.move(e,$C.mousePos(this.element,e))},this.mouseup=e=>{this._rotatePitchHandler.dragEnd(e),this.offTemp()},this.touchstart=e=>{1===e.targetTouches.length?(this._startPos=this._lastPos=$C.touchPos(this.element,e.targetTouches)[0],this.startMove(e,this._startPos),window.addEventListener("touchmove",this.touchmove,{passive:!1}),window.addEventListener("touchend",this.touchend)):this.reset()},this.touchmove=e=>{1===e.targetTouches.length?(this._lastPos=$C.touchPos(this.element,e.targetTouches)[0],this.move(e,this._lastPos)):this.reset()},this.touchend=e=>{0===e.targetTouches.length&&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=t;let i=new iO;this._rotatePitchHandler=new QB({clickTolerance:3,move:(e,i)=>{let n=t.getBoundingClientRect(),a=new Sd((n.bottom-n.top)/2,(n.right-n.left)/2);return{bearingDelta:hf(new Sd(e.x,i.y),i,a),pitchDelta:r?-.5*(i.y-e.y):void 0}},moveStateManager:i,enable:!0,assignEvents:()=>{}}),this.map=e,t.addEventListener("mousedown",this.mousedown),t.addEventListener("touchstart",this.touchstart,{passive:!1}),t.addEventListener("touchcancel",this.reset)}startMove(e,t){this._rotatePitchHandler.dragStart(e,t),$C.disableDrag()}move(e,t){let r=this.map,{bearingDelta:i,pitchDelta:n}=this._rotatePitchHandler.dragMove(e,t)||{};i&&r.setBearing(r.getBearing()+i),n&&r.setPitch(r.getPitch()+n)}off(){let e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){$C.enableDrag(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend)}};function WO(e,t,r,i=!1){if(i||!r.getCoveringTilesDetailsProvider().allowWorldCopies())return e?.wrap();let n=new nS(e.lng,e.lat);if(e=new nS(e.lng,e.lat),t){let i=new nS(e.lng-360,e.lat),n=new nS(e.lng+360,e.lat),a=r.locationToScreenPoint(e).distSqr(t);r.locationToScreenPoint(i).distSqr(t)<a?e=i:r.locationToScreenPoint(n).distSqr(t)<a&&(e=n)}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!==n.lng&&r.isPointOnMapSurface(r.locationToScreenPoint(e))?e:n}const HO={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 XO(e,t,r){let i=e.classList;for(let n in HO)i.remove(`maplibregl-${r}-anchor-${n}`);i.add(`maplibregl-${r}-anchor-${t}`)}const YO={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]},KO="#3FB1CE";function JO(e,t,r=[]){let i=$C.createNS("http://www.w3.org/2000/svg",e);for(let n in t)i.setAttributeNS(null,n,t[n]);for(let n of r)i.appendChild(n);return i}let QO;var e$=class extends Rf{},t$=class extends Rf{},r$=class extends zf{constructor(e){if(super(),this._onClick=e=>{this.fire(new t$("click",{originalEvent:e}))},this._onKeyPress=e=>{("Space"===e.code||"Enter"===e.code)&&this.togglePopup()},this._onKeyDown=e=>{if(!this._defaultMarker||!this._draggable||!this._map||!this._lngLat||e.composedPath()[0]!==this._element||e.altKey||e.ctrlKey||e.metaKey)return;let t=YO[e.key];if(!t)return;e.preventDefault(),e.stopPropagation();let r=e.shiftKey?10:1,i=this._map.project(this._lngLat);this.setLngLat(this._map.unproject(new Sd(i.x+t[0]*r,i.y+t[1]*r))),this._keyboardDragActive||(this._keyboardDragActive=!0,this.fire(new e$("dragstart"))),this.fire(new e$("drag"))},this._onKeyUp=e=>{YO[e.key]&&this._endKeyboardDrag()},this._onBlur=()=>{this._endKeyboardDrag()},this._onMapClick=e=>{let t=e.originalEvent.target,r=this._element;this._popup&&(t===r||r.contains(t))&&this.togglePopup()},this._update=e=>{if(!this._map)return;let t=this._map.loaded()&&!this._map.isMoving();("terrain"===e?.type||"render"===e?.type&&!t)&&this._map.once("render",this._update),this._lngLat=WO(this._lngLat,this._flatPos,this._map._camera.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map._camera.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let r="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?r=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(r=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let i="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?i="rotateX(0deg)":"map"===this._pitchAlignment&&(i=`rotateX(${this._map.getPitch()}deg)`),!this._subpixelPositioning&&(!e||"moveend"===e.type)&&(this._pos=this._pos.round()),this._element.style.transform=`${HO[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${i} ${r}`,zC.frameAsync(new AbortController,this._map._ownerWindow).then(()=>{this._updateOpacity("moveend"===e?.type)}).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","pending"===this._state&&(this._state="active",this.fire(new e$("dragstart"))),this.fire(new e$("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new e$("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?.anchor||"center",this._color=e?.color||KO,this._scale=e?.scale||1,this._draggable=e?.draggable||!1,this._clickTolerance=e?.clickTolerance||0,this._subpixelPositioning=e?.subpixelPositioning||!1,this._isDragging=!1,this._roleManaged=!1,this._tabIndexManaged=!1,this._keyboardDragActive=!1,this._state="inactive",this._rotation=e?.rotation||0,this._rotationAlignment=e?.rotationAlignment||"auto",this._pitchAlignment=e?.pitchAlignment&&"auto"!==e.pitchAlignment?e.pitchAlignment:this._rotationAlignment,this.setOpacity(e?.opacity,e?.opacityWhenCovered),e?.element)this._element=e.element,this._offset=Sd.convert(e?.offset||[0,0]);else{this._defaultMarker=!0,this._element=$C.create("div");let t=(QO||(QO=JO("svg",{display:"block",height:"41px",width:"27px",viewBox:"0 0 27 41"},[JO("g",{"fill-rule":"nonzero"},[JO("g",{transform:"translate(3.0, 29.0)",fill:"#000000"},[["10.5","5.25002273"],["10.5","5.25002273"],["9.5","4.77275007"],["8.5","4.29549936"],["7.5","3.81822308"],["6.5","3.34094679"],["5.5","2.86367051"],["4.5","2.38636864"]].map(([e,t])=>JO("ellipse",{opacity:"0.04",cx:"10.5",cy:"5.80029008",rx:e,ry:t}))),JO("g",{fill:KO},[JO("path",{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"})]),JO("g",{opacity:"0.25",fill:"#000000"},[JO("path",{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"})]),JO("g",{transform:"translate(6.0, 7.0)",fill:"#FFFFFF"}),JO("g",{transform:"translate(8.0, 8.0)"},[JO("circle",{fill:"#000000",opacity:"0.25",cx:"5.5",cy:"5.5",r:"5.4999962"}),JO("circle",{fill:"#FFFFFF",cx:"5.5",cy:"5.5",r:"5.4999962"})])])]),QO)).cloneNode(!0);t.setAttributeNS(null,"height",41*this._scale+"px"),t.setAttributeNS(null,"width",27*this._scale+"px"),function(e){return e.firstElementChild.children[1]}(t).setAttributeNS(null,"fill",this._color),this._element.appendChild(t),this._offset=Sd.convert(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()}),XO(this._element,this._anchor,"marker"),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._defaultMarker&&!this._element.hasAttribute("aria-label")&&this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),this._updateAccessibilityRole(),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._element.addEventListener("click",this._onClick),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),this._element.removeEventListener("click",this._onClick),this._element.removeEventListener("keydown",this._onKeyDown),this._element.removeEventListener("keyup",this._onKeyUp),this._element.removeEventListener("blur",this._onBlur),this._element.removeEventListener("keypress",this._onKeyPress),this._keyboardDragActive=!1,this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=nS.convert(e),this._pos=null,this._update(),this._popup&&this._popup.setLngLat(this._lngLat),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress)),e){if(!("offset"in e.options)){let t=13.5/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[t,-1*(24.6+t)],"bottom-right":[-t,-1*(24.6+t)],left:[13.5,-24.6],right:[-13.5,-24.6]}:this._offset}this._popup=e,this._element.addEventListener("keypress",this._onKeyPress)}return this._updateTabIndex(),this._updateAccessibilityRole(),this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}_endKeyboardDrag(){this._keyboardDragActive&&(this._keyboardDragActive=!1,this.fire(new e$("dragend")))}getPopup(){return this._popup}togglePopup(){let e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){let t=this._map?.terrain,r=this._map._camera.transform.isLocationOccluded(this._lngLat);if(!t||r){let e=r?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==e&&(this._element.style.opacity=e,this._element.classList.toggle("maplibregl-marker-covered",r)))}if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}let i=this._map,n=i.terrain.depthAtPoint(this._pos),a=i.terrain.getElevationForLngLat(this._lngLat,i._camera.transform);if(i._camera.transform.lngLatToCameraDepth(this._lngLat,a)-n<.006)return this._element.style.opacity=this._opacity,void this._element.classList.remove("maplibregl-marker-covered");let s=-this._offset.y/i._camera.transform.pixelsPerMeter,o=Math.sin(i.getPitch()*Math.PI/180)*s,l=i.terrain.depthAtPoint(new Sd(this._pos.x,this._pos.y-this._offset.y)),u=i._camera.transform.lngLatToCameraDepth(this._lngLat,a+o)-l>.006;this._popup?.isOpen()&&u&&this._popup.remove(),this._element.style.opacity=u?this._opacityWhenCovered:this._opacity,this._element.classList.toggle("maplibregl-marker-covered",u)}getOffset(){return this._offset}setOffset(e){return this._offset=Sd.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._element.classList.toggle("maplibregl-marker-draggable",this._draggable),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._defaultMarker&&(this._draggable?(this._element.addEventListener("keydown",this._onKeyDown),this._element.addEventListener("keyup",this._onKeyUp),this._element.addEventListener("blur",this._onBlur)):(this._element.removeEventListener("keydown",this._onKeyDown),this._element.removeEventListener("keyup",this._onKeyUp),this._element.removeEventListener("blur",this._onBlur),this._endKeyboardDrag())),this._updateTabIndex(),this._updateAccessibilityRole(),this}isDraggable(){return this._draggable}_updateTabIndex(){this._popup||this._defaultMarker&&this._draggable?this._element.hasAttribute("tabindex")||(this._element.setAttribute("tabindex","0"),this._tabIndexManaged=!0):this._tabIndexManaged&&=("0"===this._element.getAttribute("tabindex")&&this._element.removeAttribute("tabindex"),!1)}_updateAccessibilityRole(){if(!this._defaultMarker||this._element.hasAttribute("role")&&!this._roleManaged)return;let e=this._draggable||this._popup?"button":"img";this._element.setAttribute("role",e),this._roleManaged=!0}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&"auto"!==e?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,t){return(void 0===this._opacity||void 0===e&&void 0===t)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==e&&(this._opacity=String(e)),void 0!==t&&(this._opacityWhenCovered=String(t)),this._map&&this._updateOpacity(!0),this}};const i$={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0,padding:void 0},n$=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");var a$=class extends Rf{},s$=class extends zf{constructor(e){super(),this._updateOpacity=()=>{void 0!==this.options.locationOccludedOpacity&&(this._map._camera.transform.isLocationOccluded(this.getLngLat())?this._container.style.opacity=`${this.options.locationOccludedOpacity}`:this._container.style.opacity="")},this.remove=()=>(this._content&&this._content.remove(),this._container&&(this._container.remove(),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("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousemove",this._update),this._map.off("mouseup",this._update),this._map.off("drag",this._update),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new a$("close"))),this),this._update=e=>{let t,r=this._lngLat||this._trackPointer;if(!this._map||!r||!this._content)return;if(!this._container){if(this._container=$C.create("div","maplibregl-popup",this._map.getContainer()),this._tip=$C.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=WO(this._lngLat,this._flatPos,this._map._camera.transform,this._trackPointer),e&&"point"in e&&e.point&&(t=e.point),this._trackPointer&&!t)return;let i=this._flatPos=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&t?t:this._map._camera.transform.locationToScreenPoint(this._lngLat));let n=this.options.anchor,a=o$(this.options.offset);if(!n){let e,t=this._container.offsetWidth,r=this._container.offsetHeight,s=function(e){return e?{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}:{top:0,right:0,bottom:0,left:0}}(this.options.padding);e=i.y+a.bottom.y<r+s.top?["top"]:i.y>this._map._camera.transform.height-r-s.bottom?["bottom"]:[],i.x<t/2+s.left?e.push("left"):i.x>this._map._camera.transform.width-t/2-s.right&&e.push("right"),n=0===e.length?"bottom":e.join("-")}let s=i.add(a[n]);this.options.subpixelPositioning||(s=s.round()),this._container.style.transform=`${HO[n]} translate(${s.x}px,${s.y}px)`,XO(this._container,n,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=jp(Object.create(i$),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._map.on("terrain",this._update),this._map.on("projectiontransition",this._update),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._update),this._map.on("mouseup",this._update),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 a$("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=nS.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._update),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._update),this._map.on("drag",this._update),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,r=document.createDocumentFragment(),i=document.createElement("body");for(i.innerHTML=e;t=i.firstChild,t;)r.appendChild(t);return this.setDOMContent(r)}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=$C.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}setPadding(e){this.options.padding=e,this._update()}_createCloseButton(){this.options.closeButton&&(this._closeButton=$C.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;let e=this._container.querySelector(n$);e&&e.focus()}};function o$(e){if(!e)return o$(new Sd(0,0));if("number"==typeof e){let t=Math.round(Math.abs(e)/Math.SQRT2);return{center:new Sd(0,0),top:new Sd(0,e),"top-left":new Sd(t,t),"top-right":new Sd(-t,t),bottom:new Sd(0,-e),"bottom-left":new Sd(t,-t),"bottom-right":new Sd(-t,-t),left:new Sd(e,0),right:new Sd(-e,0)}}if(e instanceof Sd||Array.isArray(e)){let t=Sd.convert(e);return{center:t,top:t,"top-left":t,"top-right":t,bottom:t,"bottom-left":t,"bottom-right":t,left:t,right:t}}return{center:Sd.convert(e.center||[0,0]),top:Sd.convert(e.top||[0,0]),"top-left":Sd.convert(e["top-left"]||[0,0]),"top-right":Sd.convert(e["top-right"]||[0,0]),bottom:Sd.convert(e.bottom||[0,0]),"bottom-left":Sd.convert(e["bottom-left"]||[0,0]),"bottom-right":Sd.convert(e["bottom-right"]||[0,0]),left:Sd.convert(e.left||[0,0]),right:Sd.convert(e.right||[0,0])}}class l${constructor(e=1){var t;this.waiters=[],this.slotsInUse=0,this.slotLimit=null!==(t=function(e){if(!Number.isFinite(e))return null;const t=Math.floor(e);return t<1||t>64?null:t}(e))&&void 0!==t?t:1}get limit(){return this.slotLimit}get inUse(){return this.slotsInUse}get waiting(){return this.waiters.length}acquire(e){return(null==e?void 0:e.aborted)?Promise.reject(new DOMException("Aborted","AbortError")):this.slotsInUse<this.slotLimit?(this.slotsInUse++,Promise.resolve()):new Promise((t,r)=>{const i=()=>{this.slotsInUse++,t()};this.waiters.push(i),e&&e.addEventListener("abort",()=>{const e=this.waiters.indexOf(i);-1!==e&&(this.waiters.splice(e,1),r(new DOMException("Aborted","AbortError")))},{once:!0})})}release(){if(this.slotsInUse>0){this.slotsInUse--;const e=this.waiters.shift();e&&e()}}}let u$=null;function c$(){if(null===u$&&!Ef.WORKER_URL)try{const e=new Blob(['/**\n* MapLibre GL JS\n* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.9.0/LICENSE.txt\n*/var c1=Object.create,pp=Object.defineProperty,p1=Object.getOwnPropertyDescriptor,f1=Object.getOwnPropertyNames,d1=Object.getPrototypeOf,fp=Object.prototype.hasOwnProperty,hl=(t,e)=>()=>(e||(t((e={exports:{}}).exports,e),t=null),e.exports),y1=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(var n=f1(e),a=0,s=n.length,o;a<s;a++)o=n[a],!fp.call(t,o)&&o!==r&&pp(t,o,{get:(l=>e[l]).bind(null,o),enumerable:!(i=p1(e,o))||i.enumerable});return t},m1=(t,e,r)=>(r=t==null?{}:c1(d1(t)),y1(e||!t||!t.__esModule||!fp.call(t,"default")?pp(r,"default",{value:t,enumerable:!0}):r,t));function B(t,e){this.x=t,this.y=e}B.prototype={clone(){return new B(this.x,this.y)},add(t){return this.clone()._add(t)},sub(t){return this.clone()._sub(t)},multByPoint(t){return this.clone()._multByPoint(t)},divByPoint(t){return this.clone()._divByPoint(t)},mult(t){return this.clone()._mult(t)},div(t){return this.clone()._div(t)},rotate(t){return this.clone()._rotate(t)},rotateAround(t,e){return this.clone()._rotateAround(t,e)},matMult(t){return this.clone()._matMult(t)},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(t){return this.x===t.x&&this.y===t.y},dist(t){return Math.sqrt(this.distSqr(t))},distSqr(t){let e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle(){return Math.atan2(this.y,this.x)},angleTo(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith(t){return this.angleWithSep(t.x,t.y)},angleWithSep(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult(t){let e=t[0]*this.x+t[1]*this.y,r=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=r,this},_add(t){return this.x+=t.x,this.y+=t.y,this},_sub(t){return this.x-=t.x,this.y-=t.y,this},_mult(t){return this.x*=t,this.y*=t,this},_div(t){return this.x/=t,this.y/=t,this},_multByPoint(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint(t){return this.x/=t.x,this.y/=t.y,this},_unit(){return this._div(this.mag()),this},_perp(){let t=this.y;return this.y=this.x,this.x=-t,this},_rotate(t){let e=Math.cos(t),r=Math.sin(t),i=e*this.x-r*this.y,n=r*this.x+e*this.y;return this.x=i,this.y=n,this},_rotateAround(t,e){let r=Math.cos(t),i=Math.sin(t),n=e.x+r*(this.x-e.x)-i*(this.y-e.y),a=e.y+i*(this.x-e.x)+r*(this.y-e.y);return this.x=n,this.y=a,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:B},B.convert=function(t){if(t instanceof B)return t;if(Array.isArray(t))return new B(+t[0],+t[1]);if(t.x!==void 0&&t.y!==void 0)return new B(+t.x,+t.y);throw Error("Expected [x, y] or {x, y} point format")};function g1(t,e,r,i){let n=3*t,a=3*(r-t)-n,s=1-n-a,o=3*e,l=3*(i-e)-o,u=1-o-l;return function(h,c=1e-6){if(h<=0)return 0;if(h>=1)return 1;let p=h;for(let y=0;y<8;y++){let m=((s*p+a)*p+n)*p-h;if(Math.abs(m)<c)return((u*p+l)*p+o)*p;let g=(3*s*p+2*a)*p+n;if(Math.abs(g)<1e-6)break;p-=m/g}let f=0,d=1;p=h;for(let y=0;y<20;y++){let m=((s*p+a)*p+n)*p;if(Math.abs(m-h)<c)break;h>m?f=p:d=p,p=(f+d)*.5}return((u*p+l)*p+o)*p}}var Ds;function x1(){return Ds??(Ds=typeof OffscreenCanvas<"u"&&!!new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),Ds}var On;function v1(){if(On==null&&(On=!1,x1())){let t=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(t){for(let r=0;r<25;r++){let i=r*4;t.fillStyle=`rgb(${i},${i+1},${i+2})`,t.fillRect(r%5,Math.floor(r/5),1,1)}let e=t.getImageData(0,0,5,5).data;for(let r=0;r<100;r++)if(r%4!=3&&e[r]!==r){On=!0;break}}}return On||!1}var he=typeof Float32Array<"u"?Float32Array:Array;Math.PI/180,180/Math.PI;function b1(){var t=new he(9);return he!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function dp(){var t=new he(3);return he!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function w1(t){var e=t[0],r=t[1],i=t[2];return Math.sqrt(e*e+r*r+i*i)}function eh(t,e,r){var i=new he(3);return i[0]=t,i[1]=e,i[2]=r,i}function D1(t,e){var r=e[0],i=e[1],n=e[2],a=r*r+i*i+n*n;return a>0&&(a=1/Math.sqrt(a)),t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a,t}function _1(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function _s(t,e,r){var i=e[0],n=e[1],a=e[2],s=r[0],o=r[1],l=r[2];return t[0]=n*l-a*o,t[1]=a*s-i*l,t[2]=i*o-n*s,t}var A1=w1;(function(){var t=dp();return function(e,r,i,n,a,s){var o,l;for(r||(r=3),i||(i=0),l=n?Math.min(n*r+i,e.length):e.length,o=i;o<l;o+=r)t[0]=e[o],t[1]=e[o+1],t[2]=e[o+2],a(t,t,s),e[o]=t[0],e[o+1]=t[1],e[o+2]=t[2];return e}})();function S1(){var t=new he(4);return he!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function E1(t,e){var r=e[0],i=e[1],n=e[2],a=e[3],s=r*r+i*i+n*n+a*a;return s>0&&(s=1/Math.sqrt(s)),t[0]=r*s,t[1]=i*s,t[2]=n*s,t[3]=a*s,t}function F1(t,e,r){var i=e[0],n=e[1],a=e[2],s=e[3];return t[0]=r[0]*i+r[4]*n+r[8]*a+r[12]*s,t[1]=r[1]*i+r[5]*n+r[9]*a+r[13]*s,t[2]=r[2]*i+r[6]*n+r[10]*a+r[14]*s,t[3]=r[3]*i+r[7]*n+r[11]*a+r[15]*s,t}(function(){var t=S1();return function(e,r,i,n,a,s){var o,l;for(r||(r=4),i||(i=0),l=n?Math.min(n*r+i,e.length):e.length,o=i;o<l;o+=r)t[0]=e[o],t[1]=e[o+1],t[2]=e[o+2],t[3]=e[o+3],a(t,t,s),e[o]=t[0],e[o+1]=t[1],e[o+2]=t[2],e[o+3]=t[3];return e}})();function rh(){var t=new he(4);return he!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function T1(t,e,r){r*=.5;var i=Math.sin(r);return t[0]=i*e[0],t[1]=i*e[1],t[2]=i*e[2],t[3]=Math.cos(r),t}function As(t,e,r,i){var n=e[0],a=e[1],s=e[2],o=e[3],l=r[0],u=r[1],h=r[2],c=r[3],p,f=n*l+a*u+s*h+o*c,d,y,m;return f<0&&(f=-f,l=-l,u=-u,h=-h,c=-c),1-f>1e-6?(p=Math.acos(f),d=Math.sin(p),y=Math.sin((1-i)*p)/d,m=Math.sin(i*p)/d):(y=1-i,m=i),t[0]=y*n+m*l,t[1]=y*a+m*u,t[2]=y*s+m*h,t[3]=y*o+m*c,t}function k1(t,e){var r=e[0]+e[4]+e[8],i;if(r>0)i=Math.sqrt(r+1),t[3]=.5*i,i=.5/i,t[0]=(e[5]-e[7])*i,t[1]=(e[6]-e[2])*i,t[2]=(e[1]-e[3])*i;else{var n=0;e[4]>e[0]&&(n=1),e[8]>e[n*3+n]&&(n=2);var a=(n+1)%3,s=(n+2)%3;i=Math.sqrt(e[n*3+n]-e[a*3+a]-e[s*3+s]+1),t[n]=.5*i,i=.5/i,t[3]=(e[a*3+s]-e[s*3+a])*i,t[a]=(e[a*3+n]+e[n*3+a])*i,t[s]=(e[s*3+n]+e[n*3+s])*i}return t}var ih=E1;(function(){var t=dp(),e=eh(1,0,0),r=eh(0,1,0);return function(i,n,a){var s=_1(n,a);return s<-.999999?(_s(t,e,n),A1(t)<1e-6&&_s(t,r,n),D1(t,t),T1(i,t,Math.PI),i):s>.999999?(i[0]=0,i[1]=0,i[2]=0,i[3]=1,i):(_s(t,n,a),i[0]=t[0],i[1]=t[1],i[2]=t[2],i[3]=1+s,ih(i,i))}})(),(function(){var t=rh(),e=rh();return function(r,i,n,a,s,o){return As(t,i,s,o),As(e,n,a,o),As(r,t,e,2*o*(1-o)),r}})(),(function(){var t=b1();return function(e,r,i,n){return t[0]=i[0],t[3]=i[1],t[6]=i[2],t[1]=n[0],t[4]=n[1],t[7]=n[2],t[2]=-r[0],t[5]=-r[1],t[8]=-r[2],ih(e,k1(e,t))}})();function I1(){var t=new he(2);return he!=Float32Array&&(t[0]=0,t[1]=0),t}(function(){var t=I1();return function(e,r,i,n,a,s){var o,l;for(r||(r=2),i||(i=0),l=n?Math.min(n*r+i,e.length):e.length,o=i;o<l;o+=r)t[0]=e[o],t[1]=e[o+1],a(t,t,s),e[o]=t[0],e[o+1]=t[1];return e}})();var mt=8192;var yp="__$json__:";function Wi(t){return t instanceof Error?t:Error(typeof t=="string"?t:String(t))}function C1(t){if(t<=0)return 0;if(t>=1)return 1;let e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}function M1(t,e,r,i){return g1(t,e,r,i)}var i5=M1(.25,.1,.25,1);function Zi(t,e,r){return Math.min(r,Math.max(e,t))}function B1(t,e,r){let i=r-e,n=((t-e)%i+i)%i+e;return n===e?r:n}function qt(t,...e){for(let r of e)for(let i in r)t[i]=r[i];return t}function P1(t){return Math.log(t)/Math.LN2%1==0}function Aa(t,e,r){let i={};for(let n in t)i[n]=e.call(r||this,t[n],n,t);return i}function z1(t,e,r){let i={};for(let n in t)e.call(r||this,t[n],n,t)&&(i[n]=t[n]);return i}function Xe(t){return Array.isArray(t)?t.map(Xe):typeof t=="object"&&t?Aa(t,Xe):t}var nh={};function Mt(t){nh[t]||(typeof console<"u"&&console.warn(t),nh[t]=!0)}function We(t,e,r){return(r.y-t.y)*(e.x-t.x)>(e.y-t.y)*(r.x-t.x)}function dr(t){return typeof WorkerGlobalScope<"u"&&t!==void 0&&t instanceof WorkerGlobalScope}function Sa(t){return typeof ImageBitmap<"u"&&t instanceof ImageBitmap}function L1(t,e,r,i,n){let a=Math.max(-e,0)*4,s=(Math.max(0,r)-r)*i*4+a,o=i*4,l=Math.max(0,e),u=Math.max(0,r),h=Math.min(t.width,e+i),c=Math.min(t.height,r+n);return{rect:{x:l,y:u,width:h-l,height:c-u},layout:[{offset:s,stride:o}]}}async function V1(t,e,r,i,n){if(typeof VideoFrame>"u")throw Error("VideoFrame not supported");let a=new VideoFrame(t,{timestamp:0});try{let s=a?.format;if(!s||!(s.startsWith("BGR")||s.startsWith("RGB")))throw Error(`Unrecognized format ${s}`);let o=s.startsWith("BGR"),l=new Uint8ClampedArray(i*n*4);if(await a.copyTo(l,L1(t,e,r,i,n)),o)for(let u=0;u<l.length;u+=4){let h=l[u];l[u]=l[u+2],l[u+2]=h}return l}finally{a.close()}}var _i,Ai;function O1(t,e,r,i,n){let a=t.width,s=t.height;(!_i||!Ai)&&(_i=new OffscreenCanvas(a,s),Ai=_i.getContext("2d",{willReadFrequently:!0})),_i.width=a,_i.height=s,Ai.drawImage(t,0,0,a,s);let o=Ai.getImageData(e,r,i,n);return Ai.clearRect(0,0,a,s),o.data}async function mp(t,e,r,i,n){if(v1())try{return await V1(t,e,r,i,n)}catch{}return O1(t,e,r,i,n)}function ah(t,e,r,i){return t.addEventListener(e,r,i),{unsubscribe:()=>{t.removeEventListener(e,r,i)}}}function sh(t){return t*Math.PI/180}var oh="AbortError",cl=class extends Error{constructor(t=oh){super(t instanceof Error?t.message:t),this.name=oh,t instanceof Error&&t.stack&&(this.stack=t.stack)}};function pl(t){return t instanceof Error&&t.name==="AbortError"}function R1(t){if(t.aborted)throw new cl(t.reason)}var fl={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function $1(t){return fl.REGISTERED_PROTOCOLS[t.substring(0,t.indexOf("://"))]}function gp(t,e){fl.REGISTERED_PROTOCOLS[t]=e}function xp(t){delete fl.REGISTERED_PROTOCOLS[t]}var lh="global-dispatcher",ua=class extends Error{constructor(t,e,r,i){super(`AJAXError: ${e} (${t}): ${r}`),this.status=t,this.statusText=e,this.url=r,this.body=i}};function vp(){if(dr(self))return self.worker?.referrer;if(window.location.protocol==="blob:")try{return window.parent.location.href}catch{}return window.location.href}var N1=t=>t.startsWith("file:")||vp()?.startsWith("file:")&&!/^\\w+:/.test(t);async function U1(t,e){let r=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,cache:t.cache,referrer:vp(),referrerPolicy:t.referrerPolicy,signal:e.signal});t.type==="json"&&!r.headers.has("Accept")&&r.headers.set("Accept","application/json");let i;try{i=await fetch(r)}catch(s){throw pl(s)?s:new ua(0,Wi(s).message,t.url,new Blob)}if(!i.ok){let s=await i.blob();throw new ua(i.status,i.statusText,t.url,s)}let n;n=t.type==="arrayBuffer"||t.type==="image"?i.arrayBuffer():t.type==="json"?i.json():i.text();let a=await n;return R1(e.signal),{data:a,cacheControl:i.headers.get("Cache-Control"),expires:i.headers.get("Expires"),etag:i.headers.get("ETag")}}function q1(t,e){return new Promise((r,i)=>{let n=new XMLHttpRequest;n.open(t.method||"GET",t.url,!0),(t.type==="arrayBuffer"||t.type==="image")&&(n.responseType="arraybuffer");for(let a in t.headers)n.setRequestHeader(a,t.headers[a]);t.type==="json"&&(n.responseType="text",t.headers?.Accept||n.setRequestHeader("Accept","application/json")),n.withCredentials=t.credentials==="include",n.onerror=()=>{i(Error(n.statusText))},n.onload=()=>{if(!e.signal.aborted)if((n.status>=200&&n.status<300||n.status===0)&&n.response!==null){let a=n.response;if(t.type==="json")try{a=JSON.parse(n.response)}catch(s){i(s);return}r({data:a,cacheControl:n.getResponseHeader("Cache-Control"),expires:n.getResponseHeader("Expires"),etag:n.getResponseHeader("ETag")})}else{let a=new Blob([n.response],{type:n.getResponseHeader("Content-Type")});i(new ua(n.status,n.statusText,t.url,a))}},e.signal.addEventListener("abort",()=>{n.abort(),i(new cl(e.signal.reason))}),n.send(t.body)})}var Ea=async function(t,e){if(t.url.includes("://")&&!/^https?:|^file:/.test(t.url)){let r=$1(t.url);if(r){let i=await r(t,e);return!i.data&&t.type==="arrayBuffer"?qt(i,{data:new ArrayBuffer(0)}):i}if(dr(self)&&self.worker?.actor)return self.worker.actor.sendAsync({type:"GR",data:t,targetMapId:lh},e)}if(!N1(t.url)){if(fetch&&Request&&AbortController&&Object.hasOwn(Request.prototype,"signal"))return U1(t,e);if(dr(self)&&self.worker?.actor)return self.worker.actor.sendAsync({type:"GR",data:t,mustQueue:!0,targetMapId:lh},e)}return q1(t,e)},bp=(t,e)=>Ea(qt(t,{type:"json"}),e),wp=(t,e)=>Ea(qt(t,{type:"arrayBuffer"}),e);function uh(t,e,r){r[t]?.includes(e)||(r[t]||(r[t]=[]),r[t].push(e))}function Ss(t,e,r){if(r?.[t]){let i=r[t].indexOf(e);i!==-1&&r[t].splice(i,1)}}var Dp=class{constructor(t,e={}){qt(this,e),this.type=t}},ha=class extends Dp{constructor(t,e={}){super("error",qt({error:t},e))}},j1=class{on(t,e){return this._listeners||(this._listeners={}),uh(t,e,this._listeners),{unsubscribe:()=>{this.off(t,e)}}}off(t,e){return Ss(t,e,this._listeners),Ss(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners||(this._oneTimeListeners={}),uh(t,e,this._oneTimeListeners),this):new Promise(r=>this.once(t,r))}fire(t,e){let r=typeof t=="string"?new Dp(t,e||{}):t,i=r.type;if(this.listens(i)){r.target=this;let n=this._listeners?.[i]?.slice()??[];for(let o of n)o.call(this,r);let a=this._oneTimeListeners?.[i]?.slice()??[];for(let o of a)Ss(i,o,this._oneTimeListeners),o.call(this,r);let s=this._eventedParent;s&&(qt(r,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),s.fire(r))}else r instanceof ha&&console.error(r.error);return this}listens(t){return!!(this._listeners?.[t]?.length||this._oneTimeListeners?.[t]?.length||this._eventedParent?.listens(t))}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}},_p={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number",length:2},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},"font-faces":{type:"fontFaces"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},encoding:{type:"enum",values:{mvt:{},mlt:{}},default:"mvt"},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"filter"},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:{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",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-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",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-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",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"},"fill-extrusion-rounded-corner-distance":{type:"number",default:0,minimum:0,units:"meters","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"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","feature"]},"property-type":"data-driven"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-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","feature"]},"property-type":"data-driven"},"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"},"symbol-height-offset":{type:"number",default:0,units:"meters",requires:[{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-height-anchor":{type:"enum",values:{ground:{},absolute:{}},default:"ground",requires:["symbol-height-offset"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},filter:{type:"boolean",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},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:"expression_name",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-layer-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","global-state"]},"property-type":"data-constant"},"fill-color":{type:"color",default:"#000000",transition:!0,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,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default: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-layer-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","global-state"]},"property-type":"data-constant"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,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"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",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"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},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"}},interpolation:{type:"array",value:"interpolation_name",minimum:1},interpolation_name:{type:"enum",values:{linear:{syntax:{overloads:[{parameters:[],"output-type":"interpolation"}],parameters:[]}},exponential:{syntax:{overloads:[{parameters:["base"],"output-type":"interpolation"}],parameters:[{name:"base",type:"number literal"}]}},"cubic-bezier":{syntax:{overloads:[{parameters:["x1","y1","x2","y2"],"output-type":"interpolation"}],parameters:[{name:"x1",type:"number literal"},{name:"y1",type:"number literal"},{name:"x2",type:"number literal"},{name:"y2",type:"number literal"}]}}}}},D=_p,Ap=["type","source","source-layer","minzoom","maxzoom","filter","layout"],T=class{constructor(t,e,r,i,n="error"){this.message=(t?`${t}: `:"")+r,i&&(this.identifier=i),this.severity=n,e!=null&&e.__line__&&(this.line=e.__line__)}},cn={kind:"null"},k={kind:"number"},X={kind:"string"},tt={kind:"boolean"},ue={kind:"color"},Fa={kind:"projectionDefinition"},cr={kind:"object"},H={kind:"value"},G1={kind:"error"},Ta={kind:"collator"},pn={kind:"formatted"},ka={kind:"padding"},Hi={kind:"colorArray"},Ia={kind:"numberArray"},fn={kind:"resolvedImage"},Ca={kind:"variableAnchorOffsetCollection"};function Nt(t,e){return{kind:"array",itemType:t,N:e}}function yt(t){if(t.kind==="array"){let e=yt(t.itemType);return typeof t.N=="number"?`array<${e}, ${t.N}>`:t.itemType.kind==="value"?"array":`array<${e}>`}return t.kind}var Y1=[cn,k,X,tt,ue,Fa,pn,cr,Nt(H),ka,Ia,Hi,fn,Ca];function Ki(t,e){if(e.kind==="error")return null;if(t.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!Ki(t.itemType,e.itemType))&&(typeof t.N!="number"||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if(t.kind==="value"){for(let r of Y1)if(!Ki(r,e))return null}}return`Expected ${yt(t)} but found ${yt(e)} instead.`}function dl(t,e){return e.some(r=>r.kind===t.kind)}function pr(t,e){return e.some(r=>r==="null"?t===null:r==="array"?Array.isArray(t):r==="object"?t&&!Array.isArray(t)&&typeof t=="object":r===typeof t)}function Ue(t,e){return t.kind==="array"&&e.kind==="array"?t.itemType.kind===e.itemType.kind&&typeof t.N=="number":t.kind===e.kind}var Sp=.96422,Ep=.82521,Fp=4/29,Ws=6/29,Tp=3*Ws*Ws,X1=Math.PI/180,W1=180/Math.PI;function kp(t){return t%=360,t<0&&(t+=360),t}function Ip([t,e,r,i]){t=Es(t),e=Es(e),r=Es(r);let n,a,s=Fs((.2225045*t+.7168786*e+.0606169*r)/1);t===e&&e===r?n=a=s:(n=Fs((.4360747*t+.3850649*e+.1430804*r)/Sp),a=Fs((.0139322*t+.0971045*e+.7141733*r)/Ep));let o=116*s-16;return[o<0?0:o,500*(n-s),200*(s-a),i]}function Es(t){return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function Fs(t){return t>.008856451679035631?t**(1/3):t/Tp+Fp}function Cp([t,e,r,i]){let n=(t+16)/116,a=isNaN(e)?n:n+e/500,s=isNaN(r)?n:n-r/200;return n=1*ks(n),a=Sp*ks(a),s=Ep*ks(s),[Ts(3.1338561*a-1.6168667*n-.4906146*s),Ts(-.9787684*a+1.9161415*n+.033454*s),Ts(.0719453*a-.2289914*n+1.4052427*s),i]}function Ts(t){return t=t<=.00304?12.92*t:1.055*t**(1/2.4)-.055,t<0?0:t>1?1:t}function ks(t){return t>Ws?t*t*t:Tp*(t-Fp)}function Z1(t){let[e,r,i,n]=Ip(t),a=Math.sqrt(r*r+i*i);return[Math.round(a*1e4)?kp(Math.atan2(i,r)*W1):NaN,a,e,n]}function H1([t,e,r,i]){return t=isNaN(t)?0:t*X1,Cp([r,Math.cos(t)*e,Math.sin(t)*e,i])}function K1([t,e,r,i]){t=kp(t),e/=100,r/=100;function n(a){let s=(a+t/30)%12,o=e*Math.min(r,1-r);return r-o*Math.max(-1,Math.min(s-3,9-s,1))}return[n(0),n(8),n(4),i]}var J1=Object.hasOwn||function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};function Ni(t,e){return J1(t,e)?t[e]:void 0}function Q1(t){if(t=t.toLowerCase().trim(),t==="transparent")return[0,0,0,0];let e=Ni(t0,t);if(e){let[i,n,a]=e;return[i/255,n/255,a/255,1]}if(t.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(t)){let i=t.length<6?1:2,n=1;return[Rn(t.slice(n,n+=i)),Rn(t.slice(n,n+=i)),Rn(t.slice(n,n+=i)),Rn(t.slice(n,n+i)||"ff")]}if(t.startsWith("rgb")){let i=t.match(/^rgba?\\(\\s*([\\de.+-]+)(%)?(?:\\s+|\\s*(,)\\s*)([\\de.+-]+)(%)?(?:\\s+|\\s*(,)\\s*)([\\de.+-]+)(%)?(?:\\s*([,\\/])\\s*([\\de.+-]+)(%)?)?\\s*\\)$/);if(i){let[n,a,s,o,l,u,h,c,p,f,d,y]=i,m=[o||" ",h||" ",f].join("");if(m===" "||m===" /"||m===",,"||m===",,,"){let g=[s,u,p].join(""),x=g==="%%%"?100:g===""?255:0;if(x){let b=[Vr(+a/x,0,1),Vr(+l/x,0,1),Vr(+c/x,0,1),d?hh(+d,y):1];if(ch(b))return b}}return}}let r=t.match(/^hsla?\\(\\s*([\\de.+-]+)(?:deg)?(?:\\s+|\\s*(,)\\s*)([\\de.+-]+)%(?:\\s+|\\s*(,)\\s*)([\\de.+-]+)%(?:\\s*([,\\/])\\s*([\\de.+-]+)(%)?)?\\s*\\)$/);if(r){let[i,n,a,s,o,l,u,h,c]=r,p=[a||" ",o||" ",u].join("");if(p===" "||p===" /"||p===",,"||p===",,,"){let f=[+n,Vr(+s,0,100),Vr(+l,0,100),h?hh(+h,c):1];if(ch(f))return K1(f)}}}function Rn(t){return parseInt(t.padEnd(2,t),16)/255}function hh(t,e){return Vr(e?t/100:t,0,1)}function Vr(t,e,r){return Math.min(Math.max(e,t),r)}function ch(t){return!t.some(Number.isNaN)}var t0={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 He(t,e,r){return t+r*(e-t)}function Jr(t,e,r){return t.map((i,n)=>He(i,e[n],r))}function e0(t){return t==="rgb"||t==="hcl"||t==="lab"}var Bt,gt=(Bt=class{constructor(e,r,i,n=1,a=!0){this.r=e,this.g=r,this.b=i,this.a=n,a||(this.r*=n,this.g*=n,this.b*=n,n||this.overwriteGetter("rgb",[e,r,i,n]))}static parse(e){if(e instanceof Bt)return e;if(typeof e!="string")return;let r=Q1(e);if(r)return new Bt(...r,!1)}get rgb(){let{r:e,g:r,b:i,a:n}=this,a=n||1/0;return this.overwriteGetter("rgb",[e/a,r/a,i/a,n])}get hcl(){return this.overwriteGetter("hcl",Z1(this.rgb))}get lab(){return this.overwriteGetter("lab",Ip(this.rgb))}overwriteGetter(e,r){return Object.defineProperty(this,e,{value:r}),r}toString(){let[e,r,i,n]=this.rgb;return`rgba(${[e,r,i].map(a=>Math.round(a*255)).join(",")},${n})`}static interpolate(e,r,i,n="rgb"){switch(n){case"rgb":{let[a,s,o,l]=Jr(e.rgb,r.rgb,i);return new Bt(a,s,o,l,!1)}case"hcl":{let[a,s,o,l]=e.hcl,[u,h,c,p]=r.hcl,f,d;if(!isNaN(a)&&!isNaN(u)){let b=u-a;u>a&&b>180?b-=360:u<a&&a-u>180&&(b+=360),f=a+i*b}else isNaN(a)?isNaN(u)?f=NaN:(f=u,(o===1||o===0)&&(d=h)):(f=a,(c===1||c===0)&&(d=s));let[y,m,g,x]=H1([f,d??He(s,h,i),He(o,c,i),He(l,p,i)]);return new Bt(y,m,g,x,!1)}case"lab":{let[a,s,o,l]=Cp(Jr(e.lab,r.lab,i));return new Bt(a,s,o,l,!1)}}}},Bt.black=new Bt(0,0,0,1),Bt.white=new Bt(1,1,1,1),Bt.transparent=new Bt(0,0,0,0),Bt.red=new Bt(1,0,0,1),Bt),r0=["bottom","center","top"],Zs=class{constructor(t,e,r,i,n,a){this.text=t,this.image=e,this.scale=r,this.fontStack=i,this.textColor=n,this.verticalAlign=a}},Be=class ra{constructor(e){this.sections=e}static fromString(e){return new ra([new Zs(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 ra?e:ra.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map(e=>e.text).join("")}},Ae=class Bi{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Bi)return e;if(typeof e=="number")return new Bi([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(let r of e)if(typeof r!="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 Bi(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,r,i){return new Bi(Jr(e.values,r.values,i))}},Se=class Pi{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Pi)return e;if(typeof e=="number")return new Pi([e]);if(Array.isArray(e)){for(let r of e)if(typeof r!="number")return;return new Pi(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,r,i){return new Pi(Jr(e.values,r.values,i))}},se=class zi{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof zi)return e;if(typeof e=="string"){let i=gt.parse(e);return i?new zi([i]):void 0}if(!Array.isArray(e))return;let r=[];for(let i of e){if(typeof i!="string")return;let n=gt.parse(i);if(!n)return;r.push(n)}return new zi(r)}toString(){return JSON.stringify(this.values)}static interpolate(e,r,i,n="rgb"){let a=[];if(e.values.length!=r.values.length)throw Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${r.values.length}), cannot interpolate.`);for(let s=0;s<e.values.length;s++)a.push(gt.interpolate(e.values[s],r.values[s],i,n));return new zi(a)}},ct=class extends Error{constructor(t,e){super(t),this.name="RuntimeError",this.path=e}toJSON(){return this.message}},i0=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]),De=class ia{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof ia)return e;if(!(!Array.isArray(e)||e.length<1||e.length%2!=0)){for(let r=0;r<e.length;r+=2){let i=e[r],n=e[r+1];if(typeof i!="string"||!i0.has(i)||!Array.isArray(n)||n.length!==2||typeof n[0]!="number"||typeof n[1]!="number")return}return new ia(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,r,i,n){let a=e.values,s=r.values;if(a.length!==s.length)throw new ct(`Cannot interpolate values of different length. from: ${e.toString()}, to: ${r.toString()}`,n);let o=[];for(let l=0;l<a.length;l+=2){if(a[l]!==s[l])throw new ct(`Cannot interpolate values containing mismatched anchors. from[${l}]: ${a[l]}, to[${l}]: ${s[l]}`,n);o.push(a[l]);let[u,h]=a[l+1],[c,p]=s[l+1];o.push([He(u,c,i),He(h,p,i)])}return new ia(o)}},_e=class Mp{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new Mp({name:e,available:!1}):null}},br=class Or{constructor(e,r,i){this.from=e,this.to=r,this.transition=i}toString(){return this.from===this.to&&this.transition===1?this.from:JSON.stringify([this.from,this.to,this.transition])}static interpolate(e,r,i){return new Or(e,r,i)}static parse(e){if(e instanceof Or)return e;if(Array.isArray(e)&&e.length===3&&typeof e[0]=="string"&&typeof e[1]=="string"&&typeof e[2]=="number")return new Or(e[0],e[1],e[2]);if(typeof e=="object"&&typeof e.from=="string"&&typeof e.to=="string"&&typeof e.transition=="number")return new Or(e.from,e.to,e.transition);if(typeof e=="string")return new Or(e,e,1)}},yl=class{constructor(t,e,r){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}};function Bp(t,e,r,i){return typeof t=="number"&&t>=0&&t<=255&&typeof e=="number"&&e>=0&&e<=255&&typeof r=="number"&&r>=0&&r<=255?i===void 0||typeof i=="number"&&i>=0&&i<=1?null:`Invalid rgba value [${[t,e,r,i].join(", ")}]: \'a\' must be between 0 and 1.`:`Invalid rgba value [${(typeof i=="number"?[t,e,r,i]:[t,e,r]).join(", ")}]: \'r\', \'g\', and \'b\' must be between 0 and 255.`}function Qr(t){if(t===null||typeof t=="string"||typeof t=="boolean"||typeof t=="number"||t instanceof br||t instanceof gt||t instanceof yl||t instanceof Be||t instanceof Ae||t instanceof Se||t instanceof se||t instanceof De||t instanceof _e)return!0;if(Array.isArray(t)){for(let e of t)if(!Qr(e))return!1;return!0}if(typeof t=="object"){for(let e in t)if(!Qr(t[e]))return!1;return!0}return!1}function At(t){if(t===null)return cn;if(typeof t=="string")return X;if(typeof t=="boolean")return tt;if(typeof t=="number")return k;if(t instanceof gt)return ue;if(t instanceof br)return Fa;if(t instanceof yl)return Ta;if(t instanceof Be)return pn;if(t instanceof Ae)return ka;if(t instanceof Se)return Ia;if(t instanceof se)return Hi;if(t instanceof De)return Ca;if(t instanceof _e)return fn;if(Array.isArray(t)){let e=t.length,r;for(let i of t){let n=At(i);if(!r)r=n;else{if(r===n)continue;r=H;break}}return Nt(r||H,e)}return cr}function Ui(t){let e=typeof t;return t===null?"":e==="string"||e==="number"||e==="boolean"?String(t):t instanceof gt||t instanceof br||t instanceof Be||t instanceof Ae||t instanceof Se||t instanceof se||t instanceof De||t instanceof _e?t.toString():JSON.stringify(t)}var ti=class Pp{constructor(e,r){this.type=e,this.value=r}static parse(e,r){if(e.length!==2)return r.error(`\'literal\' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Qr(e[1]))return r.error(`invalid value of type "${typeof e[1]}"`);let i=e[1],n=At(i),a=r.expectedType;return n.kind==="array"&&n.N===0&&a&&a.kind==="array"&&(typeof a.N!="number"||a.N===0)&&(n=a),new Pp(n,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}},n0=["Unknown","Point","LineString","Polygon"],zp=class{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"?n0[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(t){let e=this._parseColorCache.get(t);return e||(e=gt.parse(t),this._parseColorCache.set(t,e)),e}};function Ma(t,e,r){let i=t.length-1,n=0,a=i,s=0,o,l;for(;n<=a;)if(s=Math.floor((n+a)/2),o=t[s],l=t[s+1],o<=e){if(s===i||e<l)return s;n=s+1}else if(o>e)a=s-1;else throw new ct("Input is not a number.",r);return 0}var ml=class Lp{constructor(e,r,i,n){this.type=e,this.input=r,this.key=n,this.labels=[],this.outputs=[];for(let[a,s]of i)this.labels.push(a),this.outputs.push(s)}static parse(e,r){if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");let i=r.parse(e[1],1,k);if(!i)return null;let n=[],a=null;r.expectedType&&r.expectedType.kind!=="value"&&(a=r.expectedType);for(let s=1;s<e.length;s+=2){let o=s===1?-1/0:e[s],l=e[s+1],u=s,h=s+1;if(typeof o!="number")return r.error(\'Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.\',u);if(n.length&&n[n.length-1][0]>=o)return r.error(\'Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.\',u);let c=r.parse(l,h,a);if(!c)return null;a||(a=c.type),n.push([o,c])}return new Lp(a,i,n,r.key)}evaluate(e){let r=this.labels,i=this.outputs;if(r.length===1)return i[0].evaluate(e);let n=this.input.evaluate(e);if(n<=r[0])return i[0].evaluate(e);let a=r.length;return n>=r[a-1]?i[a-1].evaluate(e):i[Ma(r,n,this.key)].evaluate(e)}eachChild(e){e(this.input);for(let r of this.outputs)e(r)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}};function a0(t,e,r,i){let n=3*t,a=3*(r-t)-n,s=1-n-a,o=3*e,l=3*(i-e)-o,u=1-o-l;return function(h,c=1e-6){if(h<=0)return 0;if(h>=1)return 1;let p=h;for(let y=0;y<8;y++){let m=((s*p+a)*p+n)*p-h;if(Math.abs(m)<c)return((u*p+l)*p+o)*p;let g=(3*s*p+2*a)*p+n;if(Math.abs(g)<1e-6)break;p-=m/g}let f=0,d=1;p=h;for(let y=0;y<20;y++){let m=((s*p+a)*p+n)*p;if(Math.abs(m-h)<c)break;h>m?f=p:d=p,p=(f+d)*.5}return((u*p+l)*p+o)*p}}var be=class Hs{constructor(e,r,i,n,a,s){this.type=e,this.operator=r,this.interpolation=i,this.input=n,this.key=s,this.labels=[],this.outputs=[];for(let[o,l]of a)this.labels.push(o),this.outputs.push(l)}static interpolationFactor(e,r,i,n){let a=0;if(e.name==="exponential")a=Is(r,e.base,i,n);else if(e.name==="linear")a=Is(r,1,i,n);else if(e.name==="cubic-bezier"){let s=e.controlPoints;a=a0(s[0],s[1],s[2],s[3])(Is(r,1,i,n))}return a}static parse(e,r){let[i,n,a,...s]=e;if(!Array.isArray(n)||n.length===0)return r.error("Expected an interpolation type expression.",1);if(n[0]==="linear")n={name:"linear"};else if(n[0]==="exponential"){let u=n[1];if(typeof u!="number")return r.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:u}}else if(n[0]==="cubic-bezier"){let u=n.slice(1);if(u.length!==4||u.some(h=>typeof h!="number"||h<0||h>1))return r.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:u}}else return r.error(`Unknown interpolation type ${String(n[0])}`,1,0);if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");if(a=r.parse(a,2,k),!a)return null;let o=[],l=null;(i==="interpolate-hcl"||i==="interpolate-lab")&&r.expectedType!=Hi?l=ue:r.expectedType&&r.expectedType.kind!=="value"&&(l=r.expectedType);for(let u=0;u<s.length;u+=2){let h=s[u],c=s[u+1],p=u+3,f=u+4;if(typeof h!="number")return r.error(\'Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.\',p);if(o.length&&o[o.length-1][0]>=h)return r.error(\'Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.\',p);let d=r.parse(c,f,l);if(!d)return null;l||(l=d.type),o.push([h,d])}return!Ue(l,k)&&!Ue(l,Fa)&&!Ue(l,ue)&&!Ue(l,ka)&&!Ue(l,Ia)&&!Ue(l,Hi)&&!Ue(l,Ca)&&!Ue(l,Nt(k))?r.error(`Type ${yt(l)} is not interpolatable.`):new Hs(l,i,n,a,o,r.key)}evaluate(e){let r=this.labels,i=this.outputs;if(r.length===1)return i[0].evaluate(e);let n=this.input.evaluate(e);if(n<=r[0])return i[0].evaluate(e);let a=r.length;if(n>=r[a-1])return i[a-1].evaluate(e);let s=Ma(r,n,this.key),o=r[s],l=r[s+1],u=Hs.interpolationFactor(this.interpolation,n,o,l),h=i[s].evaluate(e),c=i[s+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return He(h,c,u);case"color":return gt.interpolate(h,c,u);case"padding":return Ae.interpolate(h,c,u);case"colorArray":return se.interpolate(h,c,u);case"numberArray":return Se.interpolate(h,c,u);case"variableAnchorOffsetCollection":return De.interpolate(h,c,u,this.key);case"array":return Jr(h,c,u);case"projectionDefinition":return br.interpolate(h,c,u)}case"interpolate-hcl":switch(this.type.kind){case"color":return gt.interpolate(h,c,u,"hcl");case"colorArray":return se.interpolate(h,c,u,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return gt.interpolate(h,c,u,"lab");case"colorArray":return se.interpolate(h,c,u,"lab")}}}eachChild(e){e(this.input);for(let r of this.outputs)e(r)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}};function Is(t,e,r,i){let n=i-r,a=t-r;return n===0?0:e===1?a/n:(e**+a-1)/(e**+n-1)}var yr={color:gt.interpolate,number:He,padding:Ae.interpolate,numberArray:Se.interpolate,colorArray:se.interpolate,variableAnchorOffsetCollection:De.interpolate,array:Jr},Vp=class Op{constructor(e){this.type=pn,this.sections=e}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");let i=e[1];if(!Array.isArray(i)&&typeof i=="object")return r.error("First argument must be an image or text section.");let n=[],a=!1;for(let s=1;s<=e.length-1;++s){let o=e[s];if(a&&typeof o=="object"&&!Array.isArray(o)){a=!1;let l=null;if(o["font-scale"]&&(l=r.parse(o["font-scale"],1,k),!l))return null;let u=null;if(o["text-font"]&&(u=r.parse(o["text-font"],1,Nt(X)),!u))return null;let h=null;if(o["text-color"]&&(h=r.parse(o["text-color"],1,ue),!h))return null;let c=null;if(o["vertical-align"]){if(typeof o["vertical-align"]=="string"&&!r0.includes(o["vertical-align"]))return r.error(`\'vertical-align\' must be one of: \'bottom\', \'center\', \'top\' but found \'${o["vertical-align"]}\' instead.`);if(c=r.parse(o["vertical-align"],1,X),!c)return null}let p=n[n.length-1];p.scale=l,p.font=u,p.textColor=h,p.verticalAlign=c}else{let l=r.parse(e[s],1,H);if(!l)return null;let u=l.type.kind;if(u!=="string"&&u!=="value"&&u!=="null"&&u!=="resolvedImage")return r.error("Formatted text type must be \'string\', \'value\', \'image\' or \'null\'.");a=!0,n.push({content:l,scale:null,font:null,textColor:null,verticalAlign:null})}}return new Op(n)}evaluate(e){return new Be(this.sections.map(r=>{let i=r.content.evaluate(e);return At(i)===fn?new Zs("",i,null,null,null,r.verticalAlign?r.verticalAlign.evaluate(e):null):new Zs(Ui(i),null,r.scale?r.scale.evaluate(e):null,r.font?r.font.evaluate(e).join(","):null,r.textColor?r.textColor.evaluate(e):null,r.verticalAlign?r.verticalAlign.evaluate(e):null)}))}eachChild(e){for(let r of this.sections)e(r.content),r.scale&&e(r.scale),r.font&&e(r.font),r.textColor&&e(r.textColor),r.verticalAlign&&e(r.verticalAlign)}outputDefined(){return!1}};function Rp(t,e,r=0,i=t.length-1,n=s0){for(;i>r;){if(i-r>600){let l=i-r+1,u=e-r+1,h=Math.log(l),c=.5*Math.exp(2*h/3),p=.5*Math.sqrt(h*c*(l-c)/l)*(u-l/2<0?-1:1);Rp(t,e,Math.max(r,Math.floor(e-u*c/l+p)),Math.min(i,Math.floor(e+(l-u)*c/l+p)),n)}let a=t[e],s=r,o=i;for(Si(t,r,e),n(t[i],a)>0&&Si(t,r,i);s<o;){for(Si(t,s,o),s++,o--;n(t[s],a)<0;)s++;for(;n(t[o],a)>0;)o--}n(t[r],a)===0?Si(t,r,o):(o++,Si(t,o,i)),o<=e&&(r=o+1),e<=o&&(i=o-1)}}function Si(t,e,r){let i=t[e];t[e]=t[r],t[r]=i}function s0(t,e){return t<e?-1:+(t>e)}function Ba(t,e){if(t.length<=1)return[t];let r=[],i,n;for(let a of t){let s=l0(a);s!==0&&(a.area=Math.abs(s),n===void 0&&(n=s<0),n===s<0?(i&&r.push(i),i=[a]):i.push(a))}if(i&&r.push(i),e>1)for(let a=0;a<r.length;a++)r[a].length<=e||(Rp(r[a],e,1,r[a].length-1,o0),r[a]=r[a].slice(0,e));return r}function o0(t,e){return e.area-t.area}function l0(t){let e=0;for(let r=0,i=t.length,n=i-1,a,s;r<i;n=r++)a=t[r],s=t[n],e+=(s.x-a.x)*(a.y+s.y);return e}var $n={string:X,number:k,boolean:tt,object:cr},Ie=class $p{constructor(e,r,i){this.type=e,this.args=r,this.key=i}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");let i=1,n,a=e[0];if(a==="array"){let o;if(e.length>2){let u=e[1];if(typeof u!="string"||!(u in $n)||u==="object")return r.error(\'The item type argument of "array" must be one of string, number, boolean\',1);o=$n[u],i++}else o=H;let l;if(e.length>3){if(e[2]!==null&&(typeof e[2]!="number"||e[2]<0||e[2]!==Math.floor(e[2])))return r.error(\'The length argument to "array" must be a positive integer literal\',2);l=e[2],i++}n=Nt(o,l)}else{if(!$n[a])throw Error(`Types doesn\'t contain name = ${a}`);n=$n[a]}let s=[];for(;i<e.length;i++){let o=r.parse(e[i],i,H);if(!o)return null;s.push(o)}return new $p(n,s,r.key)}evaluate(e){for(let r=0;r<this.args.length;r++){let i=this.args[r].evaluate(e);if(!Ki(this.type,At(i)))return i;if(r===this.args.length-1)throw new ct(`Expected value to be of type ${yt(this.type)}, but found ${yt(At(i))} instead.`,this.key)}throw Error()}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}},ph={"to-boolean":tt,"to-color":ue,"to-number":k,"to-string":X},Ur=class Np{constructor(e,r,i){this.type=e,this.args=r,this.key=i}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");let i=e[0];if(!ph[i])throw Error(`Can\'t parse ${i} as it is not part of the known types`);if((i==="to-boolean"||i==="to-string")&&e.length!==2)return r.error("Expected one argument.");let n=ph[i],a=[];for(let s=1;s<e.length;s++){let o=r.parse(e[s],s,H);if(!o)return null;a.push(o)}return new Np(n,a,r.key)}evaluate(e){switch(this.type.kind){case"boolean":return!!this.args[0].evaluate(e);case"color":{let r,i;for(let n of this.args){if(r=n.evaluate(e),i=null,r instanceof gt)return r;if(typeof r=="string"){let a=e.parseColor(r);if(a)return a}else if(Array.isArray(r)&&(i=r.length<3||r.length>4?`Invalid rgba value ${JSON.stringify(r)}: expected an array containing either three or four numeric values.`:Bp(r[0],r[1],r[2],r[3]),!i))return new gt(r[0]/255,r[1]/255,r[2]/255,r[3])}throw new ct(i||`Could not parse color from value \'${typeof r=="string"?r:JSON.stringify(r)}\'`,this.key)}case"padding":{let r;for(let i of this.args){r=i.evaluate(e);let n=Ae.parse(r);if(n)return n}throw new ct(`Could not parse padding from value \'${typeof r=="string"?r:JSON.stringify(r)}\'`,this.key)}case"numberArray":{let r;for(let i of this.args){r=i.evaluate(e);let n=Se.parse(r);if(n)return n}throw new ct(`Could not parse numberArray from value \'${typeof r=="string"?r:JSON.stringify(r)}\'`,this.key)}case"colorArray":{let r;for(let i of this.args){r=i.evaluate(e);let n=se.parse(r);if(n)return n}throw new ct(`Could not parse colorArray from value \'${typeof r=="string"?r:JSON.stringify(r)}\'`,this.key)}case"variableAnchorOffsetCollection":{let r;for(let i of this.args){r=i.evaluate(e);let n=De.parse(r);if(n)return n}throw new ct(`Could not parse variableAnchorOffsetCollection from value \'${typeof r=="string"?r:JSON.stringify(r)}\'`,this.key)}case"number":{let r=null;for(let i of this.args){if(r=i.evaluate(e),r===null)return 0;let n=Number(r);if(!isNaN(n))return n}throw new ct(`Could not convert ${JSON.stringify(r)} to number.`,this.key)}case"formatted":return Be.fromString(Ui(this.args[0].evaluate(e)));case"resolvedImage":return _e.fromString(Ui(this.args[0].evaluate(e)));case"projectionDefinition":{let r=this.args[0].evaluate(e);if(br.parse(r))return r;throw new ct(`Could not parse projectionDefinition from value \'${typeof r=="string"?r:JSON.stringify(r)}\'`,this.key)}default:return Ui(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}},Up=class qp{constructor(e,r){this.type=r.type,this.bindings=[].concat(e),this.result=r}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(let r of this.bindings)e(r[1]);e(this.result)}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);let i=[];for(let a=1;a<e.length-1;a+=2){let s=e[a];if(typeof s!="string")return r.error(`Expected string, but found ${typeof s} instead.`,a);if(/[^a-zA-Z0-9_]/.test(s))return r.error("Variable names must contain only alphanumeric characters or \'_\'.",a);let o=r.parse(e[a+1],a+1);if(!o)return null;i.push([s,o])}let n=r.parse(e[e.length-1],e.length-1,r.expectedType,i);return n?new qp(i,n):null}outputDefined(){return this.result.outputDefined()}},jp=class Gp{constructor(e,r){this.type=r.type,this.name=e,this.boundExpression=r}static parse(e,r){if(e.length!==2||typeof e[1]!="string")return r.error("\'var\' expression requires exactly one string literal argument.");let i=e[1];return r.scope.has(i)?new Gp(i,r.scope.get(i)):r.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}},u0=class Yp{constructor(e,r,i,n){this.type=e,this.index=r,this.input=i,this.key=n}static parse(e,r){if(e.length!==3)return r.error(`Expected 2 arguments, but found ${e.length-1} instead.`);let i=r.parse(e[1],1,k),n=r.parse(e[2],2,Nt(r.expectedType||H));if(!i||!n)return null;let a=n.type;return new Yp(a.itemType,i,n,r.key)}evaluate(e){let r=this.index.evaluate(e),i=this.input.evaluate(e);if(r<0)throw new ct(`Array index out of bounds: ${r} < 0.`,this.key);if(r>=i.length)throw new ct(`Array index out of bounds: ${r} > ${i.length-1}.`,this.key);if(r!==Math.floor(r))throw new ct(`Array index must be an integer, but found ${r} instead.`,this.key);return i[r]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}},h0=class Xp{constructor(e,r,i){this.needle=e,this.haystack=r,this.key=i,this.type=tt}static parse(e,r){if(e.length!==3)return r.error(`Expected 2 arguments, but found ${e.length-1} instead.`);let i=r.parse(e[1],1,H),n=r.parse(e[2],2,H);return!i||!n?null:dl(i.type,[tt,X,k,cn,H])?new Xp(i,n,r.key):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${yt(i.type)} instead`)}evaluate(e){let r=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!i)return!1;if(!pr(r,["boolean","string","number","null"]))throw new ct(`Expected first argument to be of type boolean, string, number or null, but found ${yt(At(r))} instead.`,this.key);if(!pr(i,["string","array"]))throw new ct(`Expected second argument to be of type array or string, but found ${yt(At(i))} instead.`,this.key);return i.indexOf(r)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}},c0=class Ks{constructor(e,r,i,n){this.needle=e,this.haystack=r,this.key=i,this.fromIndex=n,this.type=k}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);let i=r.parse(e[1],1,H),n=r.parse(e[2],2,H);if(!i||!n)return null;if(!dl(i.type,[tt,X,k,cn,H]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${yt(i.type)} instead`);if(e.length===4){let a=r.parse(e[3],3,k);return a?new Ks(i,n,r.key,a):null}return new Ks(i,n,r.key)}evaluate(e){let r=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!pr(r,["boolean","string","number","null"]))throw new ct(`Expected first argument to be of type boolean, string, number or null, but found ${yt(At(r))} instead.`,this.key);let n;if(this.fromIndex&&(n=this.fromIndex.evaluate(e)),pr(i,["string"])){let a=i.indexOf(r,n);return a===-1?-1:[...i.slice(0,a)].length}if(pr(i,["array"]))return i.indexOf(r,n);throw new ct(`Expected second argument to be of type array or string, but found ${yt(At(i))} instead.`,this.key)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}},p0=class Wp{constructor(e,r,i,n,a,s){this.inputType=e,this.type=r,this.input=i,this.cases=n,this.outputs=a,this.otherwise=s}static parse(e,r){if(e.length<5)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return r.error("Expected an even number of arguments.");let i,n;r.expectedType&&r.expectedType.kind!=="value"&&(n=r.expectedType);let a={},s=[];for(let u=2;u<e.length-1;u+=2){let h=e[u],c=e[u+1];Array.isArray(h)||(h=[h]);let p=r.concat(u);if(h.length===0)return p.error("Expected at least one branch label.");for(let d of h){if(typeof d!="number"&&typeof d!="string")return p.error("Branch labels must be numbers or strings.");if(typeof d=="number"&&Math.abs(d)>2**53-1)return p.error(`Branch labels must be integers no larger than ${2**53-1}.`);if(typeof d=="number"&&Math.floor(d)!==d)return p.error("Numeric branch labels must be integer values.");if(!i)i=At(d);else if(p.checkSubtype(i,At(d)))return null;if(a[String(d)]!==void 0)return p.error("Branch labels must be unique.");a[String(d)]=s.length}let f=r.parse(c,u,n);if(!f)return null;n||(n=f.type),s.push(f)}let o=r.parse(e[1],1,H);if(!o)return null;let l=r.parse(e[e.length-1],e.length-1,n);return!l||o.type.kind!=="value"&&r.concat(1).checkSubtype(i,o.type)?null:new Wp(i,n,o,a,s,l)}evaluate(e){let r=this.input.evaluate(e);return(At(r)===this.inputType&&this.outputs[this.cases[r]]||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()}},f0=class Zp{constructor(e,r,i){this.type=e,this.branches=r,this.otherwise=i}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return r.error("Expected an odd number of arguments.");let i;r.expectedType&&r.expectedType.kind!=="value"&&(i=r.expectedType);let n=[];for(let s=1;s<e.length-1;s+=2){let o=r.parse(e[s],s,tt);if(!o)return null;let l=r.parse(e[s+1],s+1,i);if(!l)return null;n.push([o,l]),i||(i=l.type)}let a=r.parse(e[e.length-1],e.length-1,i);if(!a)return null;if(!i)throw Error("Can\'t infer output type");return new Zp(i,n,a)}evaluate(e){for(let[r,i]of this.branches)if(r.evaluate(e))return i.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(let[r,i]of this.branches)e(r),e(i);e(this.otherwise)}outputDefined(){return this.branches.every(([e,r])=>r.outputDefined())&&this.otherwise.outputDefined()}},d0=class Js{constructor(e,r,i,n,a){this.type=e,this.input=r,this.beginIndex=i,this.key=n,this.endIndex=a}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);let i=r.parse(e[1],1,H),n=r.parse(e[2],2,k);if(!i||!n)return null;if(!dl(i.type,[Nt(H),X,H]))return r.error(`Expected first argument to be of type array or string, but found ${yt(i.type)} instead`);if(e.length===4){let a=r.parse(e[3],3,k);return a?new Js(i.type,i,n,r.key,a):null}return new Js(i.type,i,n,r.key)}evaluate(e){let r=this.input.evaluate(e),i=this.beginIndex.evaluate(e),n;if(this.endIndex&&(n=this.endIndex.evaluate(e)),pr(r,["string"]))return[...r].slice(i,n).join("");if(pr(r,["array"]))return r.slice(i,n);throw new ct(`Expected first argument to be of type array or string, but found ${yt(At(r))} instead.`,this.key)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}},Hp=class Qs{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");let i=null,n=r.expectedType;n&&n.kind!=="value"&&(i=n);let a=[];for(let s of e.slice(1)){let o=r.parse(s,1+a.length,i,void 0,{typeAnnotation:"omit"});if(!o)return null;i||(i=o.type),a.push(o)}if(!i)throw Error("No output type");return n&&a.some(s=>Ki(n,s.type))?new Qs(H,a):new Qs(i,a)}evaluate(e){let r=null,i=0,n;for(let a of this.args)if(i++,r=a.evaluate(e),r&&r instanceof _e&&!r.available&&(n||(n=r.name),r=null,i===this.args.length&&(r=n)),r!==null)break;return r}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}};function fh(t,e){return t==="=="||t==="!="?e.kind==="boolean"||e.kind==="string"||e.kind==="number"||e.kind==="null"||e.kind==="value":e.kind==="string"||e.kind==="number"||e.kind==="value"}function y0(t,e,r){return e===r}function m0(t,e,r){return e!==r}function g0(t,e,r){return e<r}function x0(t,e,r){return e>r}function v0(t,e,r){return e<=r}function b0(t,e,r){return e>=r}function Kp(t,e,r,i){return i.compare(e,r)===0}function w0(t,e,r,i){return!Kp(t,e,r,i)}function D0(t,e,r,i){return i.compare(e,r)<0}function _0(t,e,r,i){return i.compare(e,r)>0}function A0(t,e,r,i){return i.compare(e,r)<=0}function S0(t,e,r,i){return i.compare(e,r)>=0}function si(t,e,r){let i=t!=="=="&&t!=="!=";return class Jp{constructor(a,s,o,l){this.lhs=a,this.rhs=s,this.key=o,this.collator=l,this.type=tt,this.hasUntypedArgument=a.type.kind==="value"||s.type.kind==="value"}static parse(a,s){if(a.length!==3&&a.length!==4)return s.error("Expected two or three arguments.");let o=a[0],l=s.parse(a[1],1,H);if(!l)return null;if(!fh(o,l.type))return s.concat(1).error(`"${o}" comparisons are not supported for type \'${yt(l.type)}\'.`);let u=s.parse(a[2],2,H);if(!u)return null;if(!fh(o,u.type))return s.concat(2).error(`"${o}" comparisons are not supported for type \'${yt(u.type)}\'.`);if(l.type.kind!==u.type.kind&&l.type.kind!=="value"&&u.type.kind!=="value")return s.error(`Cannot compare types \'${yt(l.type)}\' and \'${yt(u.type)}\'.`);i&&(l.type.kind==="value"&&u.type.kind!=="value"?l=new Ie(u.type,[l],s.key):l.type.kind!=="value"&&u.type.kind==="value"&&(u=new Ie(l.type,[u],s.key)));let h=null;if(a.length===4){if(l.type.kind!=="string"&&u.type.kind!=="string"&&l.type.kind!=="value"&&u.type.kind!=="value")return s.error("Cannot use collator to compare non-string types.");if(h=s.parse(a[3],3,Ta),!h)return null}return new Jp(l,u,s.key,h)}evaluate(a){let s=this.lhs.evaluate(a),o=this.rhs.evaluate(a);if(i&&this.hasUntypedArgument){let l=At(s),u=At(o);if(l.kind!==u.kind||l.kind!=="string"&&l.kind!=="number")throw new ct(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${l.kind}, ${u.kind}) instead.`,this.key)}if(this.collator&&!i&&this.hasUntypedArgument){let l=At(s),u=At(o);if(l.kind!=="string"||u.kind!=="string")return e(a,s,o)}return this.collator?r(a,s,o,this.collator.evaluate(a)):e(a,s,o)}eachChild(a){a(this.lhs),a(this.rhs),this.collator&&a(this.collator)}outputDefined(){return!0}}}var E0=si("==",y0,Kp),F0=si("!=",m0,w0),T0=si("<",g0,D0),k0=si(">",x0,_0),I0=si("<=",v0,A0),C0=si(">=",b0,S0),Qp=class tf{constructor(e,r,i){this.type=Ta,this.locale=i,this.caseSensitive=e,this.diacriticSensitive=r}static parse(e,r){if(e.length!==2)return r.error("Expected one argument.");let i=e[1];if(typeof i!="object"||Array.isArray(i))return r.error("Collator options argument must be an object.");let n=r.parse(i["case-sensitive"]!==void 0&&i["case-sensitive"],1,tt);if(!n)return null;let a=r.parse(i["diacritic-sensitive"]!==void 0&&i["diacritic-sensitive"],1,tt);if(!a)return null;let s=null;return i.locale&&(s=r.parse(i.locale,1,X),!s)?null:new tf(n,a,s)}evaluate(e){return new yl(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}},M0=class ef{constructor(e,r,i,n,a,s){this.type=X,this.number=e,this.locale=r,this.currency=i,this.unit=n,this.minFractionDigits=a,this.maxFractionDigits=s}static parse(e,r){if(e.length!==3)return r.error("Expected two arguments.");let i=r.parse(e[1],1,k);if(!i)return null;let n=e[2];if(typeof n!="object"||Array.isArray(n))return r.error("NumberFormat options argument must be an object.");let a=null;if(n.locale&&(a=r.parse(n.locale,1,X),!a))return null;let s=null;if(n.currency&&(s=r.parse(n.currency,1,X),!s))return null;let o=null;if(n.unit&&(o=r.parse(n.unit,1,X),!o))return null;if(s&&o)return r.error("NumberFormat options `currency` and `unit` are mutually exclusive");let l=null;if(n["min-fraction-digits"]&&(l=r.parse(n["min-fraction-digits"],1,k),!l))return null;let u=null;return n["max-fraction-digits"]&&(u=r.parse(n["max-fraction-digits"],1,k),!u)?null:new ef(i,a,s,o,l,u)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":this.unit?"unit":"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}},B0=class rf{constructor(e){this.type=fn,this.input=e}static parse(e,r){if(e.length!==2)return r.error("Expected two arguments.");let i=r.parse(e[1],1,X);return i?new rf(i):r.error("No image name provided.")}evaluate(e){let r=this.input.evaluate(e),i=_e.fromString(r);return i&&e.availableImages&&(i.available=e.availableImages.indexOf(r)>-1),i}eachChild(e){e(this.input)}outputDefined(){return!1}},P0=class nf{constructor(e,r){this.input=e,this.key=r,this.type=k}static parse(e,r){if(e.length!==2)return r.error(`Expected 1 argument, but found ${e.length-1} instead.`);let i=r.parse(e[1],1);return i?i.type.kind!=="array"&&i.type.kind!=="string"&&i.type.kind!=="value"?r.error(`Expected argument of type string or array, but found ${yt(i.type)} instead.`):new nf(i,r.key):null}evaluate(e){let r=this.input.evaluate(e);if(typeof r=="string")return[...r].length;if(Array.isArray(r))return r.length;throw new ct(`Expected value to be of type string or array, but found ${yt(At(r))} instead.`,this.key)}eachChild(e){e(this.input)}outputDefined(){return!1}},we=8192;function z0(t,e){let r=L0(t[0]),i=O0(t[1]),n=2**e.z;return[Math.round(r*n*we),Math.round(i*n*we)]}function gl(t,e){let r=2**e.z,i=(t[0]/we+e.x)/r,n=(t[1]/we+e.y)/r;return[V0(i),R0(n)]}function L0(t){return(180+t)/360}function V0(t){return t*360-180}function O0(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function R0(t){return 360/Math.PI*Math.atan(Math.exp((180-t*360)*Math.PI/180))-90}function dn(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1])}function Ji(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function $0(t,e,r){return e[1]>t[1]!=r[1]>t[1]&&t[0]<(r[0]-e[0])*(t[1]-e[1])/(r[1]-e[1])+e[0]}function N0(t,e,r){let i=t[0]-e[0],n=t[1]-e[1],a=t[0]-r[0],s=t[1]-r[1];return i*s-a*n===0&&i*a<=0&&n*s<=0}function Pa(t,e,r,i){let n=[e[0]-t[0],e[1]-t[1]];return G0([i[0]-r[0],i[1]-r[1]],n)!==0&&!!(dh(t,e,r,i)&&dh(r,i,t,e))}function U0(t,e,r){for(let i of r)for(let n=0;n<i.length-1;++n)if(Pa(t,e,i[n],i[n+1]))return!0;return!1}function oi(t,e,r=!1){let i=!1;for(let n of e)for(let a=0;a<n.length-1;a++){if(N0(t,n[a],n[a+1]))return r;$0(t,n[a],n[a+1])&&(i=!i)}return i}function q0(t,e){for(let r of e)if(oi(t,r))return!0;return!1}function af(t,e){for(let r of t)if(!oi(r,e))return!1;for(let r=0;r<t.length-1;++r)if(U0(t[r],t[r+1],e))return!1;return!0}function j0(t,e){for(let r of e)if(af(t,r))return!0;return!1}function G0(t,e){return t[0]*e[1]-t[1]*e[0]}function dh(t,e,r,i){let n=t[0]-r[0],a=t[1]-r[1],s=e[0]-r[0],o=e[1]-r[1],l=i[0]-r[0],u=i[1]-r[1],h=n*u-l*a,c=s*u-l*o;return h>0&&c<0||h<0&&c>0}function xl(t,e,r){let i=[];for(let n=0;n<t.length;n++){let a=[];for(let s=0;s<t[n].length;s++){let o=z0(t[n][s],r);dn(e,o),a.push(o)}i.push(a)}return i}function sf(t,e,r){let i=[];for(let n=0;n<t.length;n++){let a=xl(t[n],e,r);i.push(a)}return i}function of(t,e,r,i){if(t[0]<r[0]||t[0]>r[2]){let n=i*.5,a=t[0]-r[0]>n?-i:r[0]-t[0]>n?i:0;a===0&&(a=t[0]-r[2]>n?-i:r[2]-t[0]>n?i:0),t[0]+=a}dn(e,t)}function Y0(t){t[0]=t[1]=1/0,t[2]=t[3]=-1/0}function yh(t,e,r,i){let n=2**i.z*we,a=[i.x*we,i.y*we],s=[];for(let o of t)for(let l of o){let u=[l.x+a[0],l.y+a[1]];of(u,e,r,n),s.push(u)}return s}function mh(t,e,r,i){let n=2**i.z*we,a=[i.x*we,i.y*we],s=[];for(let o of t){let l=[];for(let u of o){let h=[u.x+a[0],u.y+a[1]];dn(e,h),l.push(h)}s.push(l)}if(e[2]-e[0]<=n/2){Y0(e);for(let o of s)for(let l of o)of(l,e,r,n)}return s}function X0(t,e){let r=[1/0,1/0,-1/0,-1/0],i=[1/0,1/0,-1/0,-1/0],n=t.canonicalID();if(e.type==="Polygon"){let a=xl(e.coordinates,i,n),s=yh(t.geometry(),r,i,n);if(!Ji(r,i))return!1;for(let o of s)if(!oi(o,a))return!1}if(e.type==="MultiPolygon"){let a=sf(e.coordinates,i,n),s=yh(t.geometry(),r,i,n);if(!Ji(r,i))return!1;for(let o of s)if(!q0(o,a))return!1}return!0}function W0(t,e){let r=[1/0,1/0,-1/0,-1/0],i=[1/0,1/0,-1/0,-1/0],n=t.canonicalID();if(e.type==="Polygon"){let a=xl(e.coordinates,i,n),s=mh(t.geometry(),r,i,n);if(!Ji(r,i))return!1;for(let o of s)if(!af(o,a))return!1}if(e.type==="MultiPolygon"){let a=sf(e.coordinates,i,n),s=mh(t.geometry(),r,i,n);if(!Ji(r,i))return!1;for(let o of s)if(!j0(o,a))return!1}return!0}var vl=class na{constructor(e,r){this.type=tt,this.geojson=e,this.geometries=r}static parse(e,r){if(e.length!==2)return r.error(`\'within\' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Qr(e[1])){let i=e[1];if(i.type==="FeatureCollection"){let n=[];for(let a of i.features){let{type:s,coordinates:o}=a.geometry;s==="Polygon"&&n.push(o),s==="MultiPolygon"&&n.push(...o)}if(n.length)return new na(i,{type:"MultiPolygon",coordinates:n})}else if(i.type==="Feature"){let n=i.geometry.type;if(n==="Polygon"||n==="MultiPolygon")return new na(i,i.geometry)}else if(i.type==="Polygon"||i.type==="MultiPolygon")return new na(i,i)}return r.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 X0(e,this.geometries);if(e.geometryType()==="LineString")return W0(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}},lf=class{constructor(t=[],e=(r,i)=>r<i?-1:+(r>i)){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;let t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){let{data:e,compare:r}=this,i=e[t];for(;t>0;){let n=t-1>>1,a=e[n];if(r(i,a)>=0)break;e[t]=a,t=n}e[t]=i}_down(t){let{data:e,compare:r}=this,i=this.length>>1,n=e[t];for(;t<i;){let a=(t<<1)+1,s=a+1;if(s<this.length&&r(e[s],e[a])<0&&(a=s),r(e[a],n)>=0)break;e[t]=e[a],t=a}e[t]=n}},gh=Math.PI/180,bl=class{constructor(t){let e=gh*6378.137*1e3,r=Math.cos(t*gh),i=1/(1-.0066943799901413165*(1-r*r)),n=Math.sqrt(i);this.kx=e*n*r,this.ky=e*n*i*.9933056200098587}distance(t,e){let r=this.wrap(t[0]-e[0])*this.kx,i=(t[1]-e[1])*this.ky;return Math.sqrt(r*r+i*i)}pointOnLine(t,e){let r=1/0,i,n,a,s;for(let o=0;o<t.length-1;o++){let l=t[o][0],u=t[o][1],h=this.wrap(t[o+1][0]-l)*this.kx,c=(t[o+1][1]-u)*this.ky,p=0;(h!==0||c!==0)&&(p=(this.wrap(e[0]-l)*this.kx*h+(e[1]-u)*this.ky*c)/(h*h+c*c),p>1?(l=t[o+1][0],u=t[o+1][1]):p>0&&(l+=h/this.kx*p,u+=c/this.ky*p)),h=this.wrap(e[0]-l)*this.kx,c=(e[1]-u)*this.ky;let f=h*h+c*c;f<r&&(r=f,i=l,n=u,a=o,s=p)}return{point:[i,n],index:a,t:Math.max(0,Math.min(1,s))}}wrap(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}};function uf(t,e){return e[0]-t[0]}function ca(t){return t[1]-t[0]+1}function Pe(t,e){return t[1]>=t[0]&&t[1]<e}function to(t,e){if(t[0]>t[1])return[null,null];let r=ca(t);if(e){if(r===2)return[t,null];let n=Math.floor(r/2);return[[t[0],t[0]+n],[t[0]+n,t[1]]]}if(r===1)return[t,null];let i=Math.floor(r/2)-1;return[[t[0],t[0]+i],[t[0]+i+1,t[1]]]}function eo(t,e){if(!Pe(e,t.length))return[1/0,1/0,-1/0,-1/0];let r=[1/0,1/0,-1/0,-1/0];for(let i=e[0];i<=e[1];++i)dn(r,t[i]);return r}function ro(t){let e=[1/0,1/0,-1/0,-1/0];for(let r of t)for(let i of r)dn(e,i);return e}function xh(t){return t[0]!==-1/0&&t[1]!==-1/0&&t[2]!==1/0&&t[3]!==1/0}function wl(t,e,r){if(!xh(t)||!xh(e))return NaN;let i=0,n=0;return t[2]<e[0]&&(i=e[0]-t[2]),t[0]>e[2]&&(i=t[0]-e[2]),t[1]>e[3]&&(n=t[1]-e[3]),t[3]<e[1]&&(n=e[1]-t[3]),r.distance([0,0],[i,n])}function ur(t,e,r){let i=r.pointOnLine(e,t);return r.distance(t,i.point)}function Dl(t,e,r,i,n){let a=Math.min(ur(t,[r,i],n),ur(e,[r,i],n)),s=Math.min(ur(r,[t,e],n),ur(i,[t,e],n));return Math.min(a,s)}function Z0(t,e,r,i,n){if(!(Pe(e,t.length)&&Pe(i,r.length)))return 1/0;let a=1/0;for(let s=e[0];s<e[1];++s){let o=t[s],l=t[s+1];for(let u=i[0];u<i[1];++u){let h=r[u],c=r[u+1];if(Pa(o,l,h,c))return 0;a=Math.min(a,Dl(o,l,h,c,n))}}return a}function H0(t,e,r,i,n){if(!(Pe(e,t.length)&&Pe(i,r.length)))return NaN;let a=1/0;for(let s=e[0];s<=e[1];++s)for(let o=i[0];o<=i[1];++o)if(a=Math.min(a,n.distance(t[s],r[o])),a===0)return a;return a}function K0(t,e,r){if(oi(t,e,!0))return 0;let i=1/0;for(let n of e){let a=n[0],s=n[n.length-1];if(a!==s&&(i=Math.min(i,ur(t,[s,a],r)),i===0))return i;let o=r.pointOnLine(n,t);if(i=Math.min(i,r.distance(t,o.point)),i===0)return i}return i}function J0(t,e,r,i){if(!Pe(e,t.length))return NaN;for(let a=e[0];a<=e[1];++a)if(oi(t[a],r,!0))return 0;let n=1/0;for(let a=e[0];a<e[1];++a){let s=t[a],o=t[a+1];for(let l of r)for(let u=0,h=l.length,c=h-1;u<h;c=u++){let p=l[c],f=l[u];if(Pa(s,o,p,f))return 0;n=Math.min(n,Dl(s,o,p,f,i))}}return n}function vh(t,e){for(let r of t)for(let i of r)if(oi(i,e,!0))return!0;return!1}function Q0(t,e,r,i=1/0){let n=ro(t),a=ro(e);if(i!==1/0&&wl(n,a,r)>=i)return i;if(Ji(n,a)){if(vh(t,e))return 0}else if(vh(e,t))return 0;let s=1/0;for(let o of t)for(let l=0,u=o.length,h=u-1;l<u;h=l++){let c=o[h],p=o[l];for(let f of e)for(let d=0,y=f.length,m=y-1;d<y;m=d++){let g=f[m],x=f[d];if(Pa(c,p,g,x))return 0;s=Math.min(s,Dl(c,p,g,x,r))}}return s}function bh(t,e,r,i,n,a){if(!a)return;let s=wl(eo(i,a),n,r);s<e&&t.push([s,a,[0,0]])}function Nn(t,e,r,i,n,a,s){if(!a||!s)return;let o=wl(eo(i,a),eo(n,s),r);o<e&&t.push([o,a,s])}function pa(t,e,r,i,n=1/0){let a=Math.min(i.distance(t[0],r[0][0]),n);if(a===0)return a;let s=new lf([[0,[0,t.length-1],[0,0]]],uf),o=ro(r);for(;s.length>0;){let l=s.pop();if(l[0]>=a)continue;let u=l[1],h=e?50:100;if(ca(u)<=h){if(!Pe(u,t.length))return NaN;if(e){let c=J0(t,u,r,i);if(isNaN(c)||c===0)return c;a=Math.min(a,c)}else for(let c=u[0];c<=u[1];++c){let p=K0(t[c],r,i);if(a=Math.min(a,p),a===0)return 0}}else{let c=to(u,e);bh(s,a,i,t,o,c[0]),bh(s,a,i,t,o,c[1])}}return a}function fa(t,e,r,i,n,a=1/0){let s=Math.min(a,n.distance(t[0],r[0]));if(s===0)return s;let o=new lf([[0,[0,t.length-1],[0,r.length-1]]],uf);for(;o.length>0;){let l=o.pop();if(l[0]>=s)continue;let u=l[1],h=l[2],c=e?50:100,p=i?50:100;if(ca(u)<=c&&ca(h)<=p){if(!Pe(u,t.length)&&Pe(h,r.length))return NaN;let f;if(e&&i)f=Z0(t,u,r,h,n),s=Math.min(s,f);else if(e&&!i){let d=t.slice(u[0],u[1]+1);for(let y=h[0];y<=h[1];++y)if(f=ur(r[y],d,n),s=Math.min(s,f),s===0)return s}else if(!e&&i){let d=r.slice(h[0],h[1]+1);for(let y=u[0];y<=u[1];++y)if(f=ur(t[y],d,n),s=Math.min(s,f),s===0)return s}else f=H0(t,u,r,h,n),s=Math.min(s,f)}else{let f=to(u,e),d=to(h,i);Nn(o,s,n,t,r,f[0],d[0]),Nn(o,s,n,t,r,f[0],d[1]),Nn(o,s,n,t,r,f[1],d[0]),Nn(o,s,n,t,r,f[1],d[1])}}return s}function tm(t,e){let r=t.geometry(),i=r.flat().map(s=>gl([s.x,s.y],t.canonical));if(r.length===0)return NaN;let n=new bl(i[0][1]),a=1/0;for(let s of e){switch(s.type){case"Point":a=Math.min(a,fa(i,!1,[s.coordinates],!1,n,a));break;case"LineString":a=Math.min(a,fa(i,!1,s.coordinates,!0,n,a));break;case"Polygon":a=Math.min(a,pa(i,!1,s.coordinates,n,a))}if(a===0)return a}return a}function em(t,e){let r=t.geometry(),i=r.flat().map(s=>gl([s.x,s.y],t.canonical));if(r.length===0)return NaN;let n=new bl(i[0][1]),a=1/0;for(let s of e){switch(s.type){case"Point":a=Math.min(a,fa(i,!0,[s.coordinates],!1,n,a));break;case"LineString":a=Math.min(a,fa(i,!0,s.coordinates,!0,n,a));break;case"Polygon":a=Math.min(a,pa(i,!0,s.coordinates,n,a))}if(a===0)return a}return a}function rm(t,e){let r=t.geometry();if(r.length===0||r[0].length===0)return NaN;let i=Ba(r,0).map(s=>s.map(o=>o.map(l=>gl([l.x,l.y],t.canonical)))),n=new bl(i[0][0][0][1]),a=1/0;for(let s of e)for(let o of i){switch(s.type){case"Point":a=Math.min(a,pa([s.coordinates],!1,o,n,a));break;case"LineString":a=Math.min(a,pa(s.coordinates,!0,o,n,a));break;case"Polygon":a=Math.min(a,Q0(o,s.coordinates,n,a))}if(a===0)return a}return a}function Cs(t){return t.type==="MultiPolygon"?t.coordinates.map(e=>({type:"Polygon",coordinates:e})):t.type==="MultiLineString"?t.coordinates.map(e=>({type:"LineString",coordinates:e})):t.type==="MultiPoint"?t.coordinates.map(e=>({type:"Point",coordinates:e})):[t]}var _l=class aa{constructor(e,r){this.type=k,this.geojson=e,this.geometries=r}static parse(e,r){if(e.length!==2)return r.error(`\'distance\' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Qr(e[1])){let i=e[1];if(i.type==="FeatureCollection")return new aa(i,i.features.map(n=>Cs(n.geometry)).flat());if(i.type==="Feature")return new aa(i,Cs(i.geometry));if("type"in i&&"coordinates"in i)return new aa(i,Cs(i))}return r.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 tm(e,this.geometries);if(e.geometryType()==="LineString")return em(e,this.geometries);if(e.geometryType()==="Polygon")return rm(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}},im=class hf{constructor(e){let r=null;for(let i of e)if(!r)r=i.type;else{if(r===i.type)continue;r=H;break}this.type=Nt(r??H,e.length),this.arr=e}static parse(e,r){if(e.length!==2)return r.error(`\'semiliteral\' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Qr(e[1]))return r.error(`invalid value of type "${typeof e[1]}"`);let i=e[1],n=At(i);if(n.kind==="array"){let a=i.map(s=>r.parse(s,null,H));return new hf(a)}return new ti(n,i)}evaluate(e){return this.arr.map(r=>r.evaluate(e))}eachChild(e){this.arr.forEach(e)}outputDefined(){return this.arr.every(e=>e.outputDefined())}},Al=class cf{constructor(e){this.key=e,this.type=H}static parse(e,r){if(e.length!==2)return r.error(`Expected 1 argument, but found ${e.length-1} instead.`);let i=e[1];return i==null?r.error("Global state property must be defined."):typeof i=="string"?new cf(i):r.error(`Global state property must be string, but found ${typeof e[1]} instead.`)}evaluate(e){let r=e.globals?.globalState;return!r||Object.keys(r).length===0?null:Ni(r,this.key)??null}eachChild(){}outputDefined(){return!1}},Gr={"==":E0,"!=":F0,">":k0,"<":T0,">=":C0,"<=":I0,array:Ie,at:u0,boolean:Ie,case:f0,coalesce:Hp,collator:Qp,format:Vp,image:B0,in:h0,"index-of":c0,interpolate:be,"interpolate-hcl":be,"interpolate-lab":be,length:P0,let:Up,literal:ti,match:p0,number:Ie,"number-format":M0,object:Ie,semiliteral:im,slice:d0,step:ml,string:Ie,"to-boolean":Ur,"to-color":Ur,"to-number":Ur,"to-string":Ur,var:jp,within:vl,distance:_l,"global-state":Al},ge=class extends Error{constructor(t,e){super(e),this.message=e,this.key=t}},nm=class pf{constructor(e,r=[]){this.parent=e,this.bindings={};for(let[i,n]of r)this.bindings[i]=n}concat(e){return new pf(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]?!0:this.parent?this.parent.has(e):!1}},ff=class df{constructor(e,r,i=[],n,a=new nm,s=[]){this.registry=e,this.path=i,this.key=i.map(o=>`[${o}]`).join(""),this.scope=a,this.errors=s,this.expectedType=n,this._isConstant=r}parse(e,r,i,n,a={}){return r?this.concat(r,i,n)._parse(e,a):this._parse(e,a)}_parse(e,r){(e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number")&&(e=["literal",e]);let i=this.key;function n(a,s,o){return o==="assert"?new Ie(s,[a],i):o==="coerce"?new Ur(s,[a],i):a}if(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 a=e[0];if(typeof a!="string")return this.error(`Expression name must be a string, but found ${typeof a} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;let s=this.registry[a];if(s){let o=s.parse(e,this);if(!o)return null;if(this.expectedType){let l=this.expectedType,u=o.type;if((l.kind==="string"||l.kind==="number"||l.kind==="boolean"||l.kind==="object"||l.kind==="array")&&u.kind==="value")o=n(o,l,r.typeAnnotation||"assert");else if(l.kind==="projectionDefinition"&&["string","array","value"].includes(u.kind)||["color","formatted","resolvedImage"].includes(l.kind)&&["value","string"].includes(u.kind)||["padding","numberArray"].includes(l.kind)&&["value","number","array"].includes(u.kind)||l.kind==="colorArray"&&["value","string","array"].includes(u.kind)||l.kind==="variableAnchorOffsetCollection"&&["value","array"].includes(u.kind))o=n(o,l,r.typeAnnotation||"coerce");else if(this.checkSubtype(l,u))return null}if(!(o instanceof ti)&&o.type.kind!=="resolvedImage"&&this._isConstant(o)){let l=new zp;try{o=new ti(o.type,o.evaluate(l))}catch(u){return this.error(u.message),null}}return o}return this.error(`Unknown expression "${a}". If you wanted a literal array, use ["literal", [...]].`,0)}return e===void 0?this.error("\'undefined\' value invalid. Use null instead."):typeof e=="object"?this.error(\'Bare objects invalid. Use ["literal", {...}] instead.\'):this.error(`Expected an array, but found ${typeof e} instead.`)}concat(e,r,i){let n=typeof e=="number"?this.path.concat(e):this.path,a=i?this.scope.concat(i):this.scope;return new df(this.registry,this._isConstant,n,r||null,a,this.errors)}error(e,...r){let i=`${this.key}${r.map(n=>`[${n}]`).join("")}`;this.errors.push(new ge(i,e))}checkSubtype(e,r){let i=Ki(e,r);return i&&this.error(i),i}},wr=class Li{constructor(e,r,i,n,a){this.name=e,this.type=r,this._evaluate=i,this.args=n,this.key=a}evaluate(e){return this._evaluate(e,this.args,this.key)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,r){let i=e[0],n=Li.definitions[i];if(!n)return r.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);let a=Array.isArray(n)?n[0]:n.type,s=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,o=s.filter(([u])=>!Array.isArray(u)||u.length===e.length-1),l=null;for(let[u,h]of o){l=new ff(r.registry,da,r.path,null,r.scope);let c=[],p=!1;for(let f=1;f<e.length;f++){let d=e[f],y=Array.isArray(u)?u[f-1]:u.type,m=l.parse(d,1+c.length,y);if(!m){p=!0;break}c.push(m)}if(!p){if(Array.isArray(u)&&u.length!==c.length){l.error(`Expected ${u.length} arguments, but found ${c.length} instead.`);continue}for(let f=0;f<c.length;f++){let d=Array.isArray(u)?u[f]:u.type,y=c[f];l.concat(f+1).checkSubtype(d,y.type)}if(l.errors.length===0)return new Li(i,a,h,c,r.key)}}if(o.length===1)r.errors.push(...l.errors);else{let u=(o.length?o:s).map(([c])=>sm(c)).join(" | "),h=[];for(let c=1;c<e.length;c++){let p=r.parse(e[c],1+h.length);if(!p)return null;h.push(yt(p.type))}r.error(`Expected arguments of type ${u}, but found (${h.join(", ")}) instead.`)}return null}static register(e,r){Li.definitions=r;for(let i in r)e[i]=Li}};function wh(t,[e,r,i,n],a){e=e.evaluate(t),r=r.evaluate(t),i=i.evaluate(t);let s=n?n.evaluate(t):1,o=Bp(e,r,i,s);if(o)throw new ct(o,a);return new gt(e/255,r/255,i/255,s,!1)}function Dh(t,e){return t in e&&e[t]!==void 0}function Ms(t,e){let r=e[t];return r===void 0?null:r}function am(t,e,r,i){for(;r<=i;){let n=r+i>>1;if(e[n]===t)return!0;e[n]>t?i=n-1:r=n+1}return!1}function ar(t){return{type:t}}wr.register(Gr,{error:[G1,[X],(t,[e],r)=>{throw new ct(e.evaluate(t),r)}],typeof:[X,[H],(t,[e])=>yt(At(e.evaluate(t)))],"to-rgba":[Nt(k,4),[ue],(t,[e])=>{let[r,i,n,a]=e.evaluate(t).rgb;return[r*255,i*255,n*255,a]}],rgb:[ue,[k,k,k],wh],rgba:[ue,[k,k,k,k],wh],has:{type:tt,overloads:[[[X],(t,[e])=>Dh(e.evaluate(t),t.properties())],[[X,cr],(t,[e,r])=>Dh(e.evaluate(t),r.evaluate(t))]]},get:{type:H,overloads:[[[X],(t,[e])=>Ms(e.evaluate(t),t.properties())],[[X,cr],(t,[e,r])=>Ms(e.evaluate(t),r.evaluate(t))]]},"feature-state":[H,[X],(t,[e])=>Ms(e.evaluate(t),t.featureState||{})],properties:[cr,[],t=>t.properties()],"geometry-type":[X,[],t=>t.geometryType()],id:[H,[],t=>t.id()],zoom:[k,[],t=>t.globals.zoom],"heatmap-density":[k,[],t=>t.globals.heatmapDensity||0],elevation:[k,[],t=>t.globals.elevation||0],"line-progress":[k,[],t=>t.globals.lineProgress||0],accumulated:[H,[],t=>t.globals.accumulated===void 0?null:t.globals.accumulated],"+":[k,ar(k),(t,e)=>{let r=0;for(let i of e)r+=i.evaluate(t);return r}],"*":[k,ar(k),(t,e)=>{let r=1;for(let i of e)r*=i.evaluate(t);return r}],"-":{type:k,overloads:[[[k,k],(t,[e,r])=>e.evaluate(t)-r.evaluate(t)],[[k],(t,[e])=>-e.evaluate(t)]]},"/":[k,[k,k],(t,[e,r])=>e.evaluate(t)/r.evaluate(t)],"%":[k,[k,k],(t,[e,r])=>e.evaluate(t)%r.evaluate(t)],ln2:[k,[],()=>Math.LN2],pi:[k,[],()=>Math.PI],e:[k,[],()=>Math.E],"^":[k,[k,k],(t,[e,r])=>e.evaluate(t)**+r.evaluate(t)],sqrt:[k,[k],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[k,[k],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[k,[k],(t,[e])=>Math.log(e.evaluate(t))],log2:[k,[k],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[k,[k],(t,[e])=>Math.sin(e.evaluate(t))],cos:[k,[k],(t,[e])=>Math.cos(e.evaluate(t))],tan:[k,[k],(t,[e])=>Math.tan(e.evaluate(t))],asin:[k,[k],(t,[e])=>Math.asin(e.evaluate(t))],acos:[k,[k],(t,[e])=>Math.acos(e.evaluate(t))],atan:[k,[k],(t,[e])=>Math.atan(e.evaluate(t))],min:[k,ar(k),(t,e)=>Math.min(...e.map(r=>r.evaluate(t)))],max:[k,ar(k),(t,e)=>Math.max(...e.map(r=>r.evaluate(t)))],abs:[k,[k],(t,[e])=>Math.abs(e.evaluate(t))],round:[k,[k],(t,[e])=>{let r=e.evaluate(t);return r<0?-Math.round(-r):Math.round(r)}],floor:[k,[k],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[k,[k],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[tt,[X,H],(t,[e,r])=>t.properties()[e.value]===r.value],"filter-id-==":[tt,[H],(t,[e])=>t.id()===e.value],"filter-type-==":[tt,[X],(t,[e])=>t.geometryType()===e.value],"filter-<":[tt,[X,H],(t,[e,r])=>{let i=t.properties()[e.value],n=r.value;return typeof i==typeof n&&i<n}],"filter-id-<":[tt,[H],(t,[e])=>{let r=t.id(),i=e.value;return typeof r==typeof i&&r<i}],"filter->":[tt,[X,H],(t,[e,r])=>{let i=t.properties()[e.value],n=r.value;return typeof i==typeof n&&i>n}],"filter-id->":[tt,[H],(t,[e])=>{let r=t.id(),i=e.value;return typeof r==typeof i&&r>i}],"filter-<=":[tt,[X,H],(t,[e,r])=>{let i=t.properties()[e.value],n=r.value;return typeof i==typeof n&&i<=n}],"filter-id-<=":[tt,[H],(t,[e])=>{let r=t.id(),i=e.value;return typeof r==typeof i&&r<=i}],"filter->=":[tt,[X,H],(t,[e,r])=>{let i=t.properties()[e.value],n=r.value;return typeof i==typeof n&&i>=n}],"filter-id->=":[tt,[H],(t,[e])=>{let r=t.id(),i=e.value;return typeof r==typeof i&&r>=i}],"filter-has":[tt,[H],(t,[e])=>{let r=e.value,i=t.properties();return r in i&&i[r]!==void 0}],"filter-has-id":[tt,[],t=>t.id()!==null&&t.id()!==void 0],"filter-type-in":[tt,[Nt(X)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[tt,[Nt(H)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[tt,[X,Nt(H)],(t,[e,r])=>r.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[tt,[X,Nt(H)],(t,[e,r])=>am(t.properties()[e.value],r.value,0,r.value.length-1)],all:{type:tt,overloads:[[[tt,tt],(t,[e,r])=>e.evaluate(t)&&r.evaluate(t)],[ar(tt),(t,e)=>{for(let r of e)if(!r.evaluate(t))return!1;return!0}]]},any:{type:tt,overloads:[[[tt,tt],(t,[e,r])=>e.evaluate(t)||r.evaluate(t)],[ar(tt),(t,e)=>{for(let r of e)if(r.evaluate(t))return!0;return!1}]]},"!":[tt,[tt],(t,[e])=>!e.evaluate(t)],"is-supported-script":[tt,[X],(t,[e])=>{let r=t.globals&&t.globals.isSupportedScript;return!r||r(e.evaluate(t))}],upcase:[X,[X],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[X,[X],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[X,ar(H),(t,e)=>e.map(r=>Ui(r.evaluate(t))).join("")],split:[Nt(X),[X,X],(t,[e,r])=>e.evaluate(t).split(r.evaluate(t))],join:[X,[Nt(X),X],(t,[e,r])=>e.evaluate(t).join(r.evaluate(t))],"resolved-locale":[X,[Ta],(t,[e])=>e.evaluate(t).resolvedLocale()]});function sm(t){return Array.isArray(t)?`(${t.map(yt).join(", ")})`:`(${yt(t.type)}...)`}function da(t){if(t instanceof jp)return da(t.boundExpression);if(t instanceof wr&&t.name==="error"||t instanceof Qp||t instanceof vl||t instanceof _l||t instanceof Al)return!1;let e=t instanceof Ur||t instanceof Ie,r=!0;return t.eachChild(i=>{r&&(r=e?da(i):i instanceof ti)}),r?za(t)&&La(t,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"]):!1}function za(t){if(t instanceof wr&&(t.name==="get"&&t.args.length===1||t.name==="feature-state"||t.name==="has"&&t.args.length===1||t.name==="properties"||t.name==="geometry-type"||t.name==="id"||/^filter-/.test(t.name))||t instanceof vl||t instanceof _l)return!1;let e=!0;return t.eachChild(r=>{e&&!za(r)&&(e=!1)}),e}function Qi(t){if(t instanceof wr&&t.name==="feature-state")return!1;let e=!0;return t.eachChild(r=>{e&&!Qi(r)&&(e=!1)}),e}function La(t,e){if(t instanceof wr&&e.indexOf(t.name)>=0)return!1;let r=!0;return t.eachChild(i=>{r&&!La(i,e)&&(r=!1)}),r}function ei(t){return t["property-type"]==="data-driven"||t["property-type"]==="cross-faded-data-driven"}function yf(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function Sl(t){return!!t.expression&&t.expression.interpolated}var El=/^(.*)-transition$/;function tn(t,...e){for(let r of e)for(let i in r)t[i]=r[i];return t}function J(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":t===null?"null":typeof t}function Va(t){return typeof t=="object"&&!!t&&!Array.isArray(t)&&At(t)===cr}function om(t){return t}function lm(t){switch(t.type){case"color":return gt.parse;case"padding":return Ae.parse;case"numberArray":return Se.parse;case"colorArray":return se.parse;default:return null}}function um(t){switch(t){case"exponential":return gf;case"interval":return cm;case"categorical":return hm;case"identity":return pm;default:throw Error(`Unknown function type "${t}"`)}}function mf(t,e){let r=t.stops&&typeof t.stops[0][0]=="object",i=r||t.property!==void 0,n=r||!i,a=t.type||(Sl(e)?"exponential":"interval"),s=lm(e);if(s&&(t=tn({},t),t.stops&&(t.stops=t.stops.map(h=>[h[0],s(h[1])])),t.default?t.default=s(t.default):t.default=s(e.default)),t.colorSpace&&!e0(t.colorSpace))throw Error(`Unknown color space: "${t.colorSpace}"`);let o=um(a),l,u;if(a==="categorical"){l=Object.create(null);for(let h of t.stops)l[h[0]]=h[1];u=typeof t.stops[0][0]}if(r){let h={},c=[];for(let d=0;d<t.stops.length;d++){let y=t.stops[d],m=y[0].zoom;h[m]===void 0&&(h[m]={zoom:m,type:t.type,property:t.property,default:t.default,stops:[]},c.push(m)),h[m].stops.push([y[0].value,y[1]])}let p=[];for(let d of c)p.push([h[d].zoom,mf(h[d],e)]);let f={name:"linear"};return{kind:"composite",interpolationType:f,interpolationFactor:be.interpolationFactor.bind(void 0,f),zoomStops:p.map(d=>d[0]),evaluate({zoom:d},y){return gf({stops:p,base:t.base},e,d).evaluate(d,y)}}}if(n){let h=a==="exponential"?{name:"exponential",base:t.base===void 0?1:t.base}:null;return{kind:"camera",interpolationType:h,interpolationFactor:be.interpolationFactor.bind(void 0,h),zoomStops:t.stops.map(c=>c[0]),evaluate:({zoom:c})=>o(t,e,c,l,u)}}return{kind:"source",evaluate(h,c){let p=c&&c.properties?c.properties[t.property]:void 0;return p===void 0?yn(t.default,e.default):o(t,e,p,l,u)}}}function yn(t,e,r){if(t!==void 0)return t;if(e!==void 0)return e;if(r!==void 0)return r}function hm(t,e,r,i,n){return yn(typeof r===n?i[r]:void 0,t.default,e.default)}function cm(t,e,r){if(J(r)!=="number")return yn(t.default,e.default);let i=t.stops.length;if(i===1||r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[i-1][0])return t.stops[i-1][1];let n=Ma(t.stops.map(a=>a[0]),r,"");return t.stops[n][1]}function gf(t,e,r){let i=t.base===void 0?1:t.base;if(J(r)!=="number")return yn(t.default,e.default);let n=t.stops.length;if(n===1||r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[n-1][0])return t.stops[n-1][1];let a=Ma(t.stops.map(h=>h[0]),r,""),s=fm(r,i,t.stops[a][0],t.stops[a+1][0]),o=t.stops[a][1],l=t.stops[a+1][1],u=yr[e.type]||om;return typeof o.evaluate=="function"?{evaluate(...h){let c=o.evaluate.apply(void 0,h),p=l.evaluate.apply(void 0,h);if(c!==void 0&&p!==void 0)return u(c,p,s,t.colorSpace)}}:u(o,l,s,t.colorSpace)}function pm(t,e,r){switch(e.type){case"color":r=gt.parse(r);break;case"formatted":r=Be.fromString(r.toString());break;case"resolvedImage":r=_e.fromString(r.toString());break;case"padding":r=Ae.parse(r);break;case"colorArray":r=se.parse(r);break;case"numberArray":r=Se.parse(r);break;default:J(r)!==e.type&&(e.type!=="enum"||!e.values[r])&&(r=void 0)}return yn(r,t.default,e.default)}function fm(t,e,r,i){let n=i-r,a=t-r;return n===0?0:e===1?a/n:(e**+a-1)/(e**+n-1)}function io(t){return{result:"success",value:t}}function Rr(t){return{result:"error",value:t}}var Fl=class{constructor(t,e,r,i){this.expression=t,this._warningHistory={},this._evaluator=new zp,this._defaultValue=r?_f(r):null,this._enumValues=r&&r.type==="enum"?r.values:null,this._globalState=i,this._rootKey=e}evaluateWithoutErrorHandling(t,e,r,i,n,a){return this._globalState&&(t=ri(t,this._globalState)),this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=r,this._evaluator.canonical=i,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=a,this.expression.evaluate(this._evaluator)}evaluate(t,e,r,i,n,a){this._globalState&&(t=ri(t,this._globalState)),this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=r||null,this._evaluator.canonical=i,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=a||null;try{let s=this.expression.evaluate(this._evaluator);if(s==null||typeof s=="number"&&s!==s)return this._defaultValue;if(this._enumValues&&!(s in this._enumValues))throw new ct(`Expected value to be one of ${Object.keys(this._enumValues).map(o=>JSON.stringify(o)).join(", ")}, but found ${JSON.stringify(s)} instead.`,"");return s}catch(s){let o=s instanceof ct?s.path:"",l=`${o}|${s.message}`;return this._warningHistory[l]||(this._warningHistory[l]=!0,typeof console<"u"&&console.warn(xf(this._rootKey,o,s.message,this._defaultValue))),this._defaultValue}}};function xf(t,e,r,i){return`${t}${e}: ${r}${i==null?"":` Falling back to ${String(i)}.`}`}function vf(t){if(!t)throw Error(\'rootKey must identify the location of the expression in the style JSON, e.g. "layers[3].paint.line-width".\')}function Oa(t){return Array.isArray(t)&&t.length>0&&typeof t[0]=="string"&&t[0]in Gr}function tr(t,e,r,i){vf(e);let n=new ff(Gr,da,[],r?mm(r):void 0),a=n.parse(t,void 0,void 0,void 0,r&&r.type==="string"?{typeAnnotation:"coerce"}:void 0);return a?io(new Fl(a,e,r,i)):Rr(n.errors)}var en=class{constructor(t,e,r){this.kind=t,this._styleExpression=e,this.isStateDependent=t!=="constant"&&!Qi(e.expression),this.globalStateRefs=mn(e.expression),this._globalState=r}evaluateWithoutErrorHandling(t,e,r,i,n,a){return this._globalState&&(t=ri(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,e,r,i,n,a)}evaluate(t,e,r,i,n,a){return this._globalState&&(t=ri(t,this._globalState)),this._styleExpression.evaluate(t,e,r,i,n,a)}},ya=class{constructor(t,e,r,i,n){this.kind=t,this.zoomStops=r,this._styleExpression=e,this.isStateDependent=t!=="camera"&&!Qi(e.expression),this.globalStateRefs=mn(e.expression),this.interpolationType=i,this._globalState=n}evaluateWithoutErrorHandling(t,e,r,i,n,a){return this._globalState&&(t=ri(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,e,r,i,n,a)}evaluate(t,e,r,i,n,a){return this._globalState&&(t=ri(t,this._globalState)),this._styleExpression.evaluate(t,e,r,i,n,a)}interpolationFactor(t,e,r){return this.interpolationType?be.interpolationFactor(this.interpolationType,t,e,r):0}};function dm(t){return t._styleExpression!==void 0}function bf(t,e,r,i){let n=tr(t,e,r,i);if(n.result==="error")return n;let a=n.value.expression,s=za(a);if(!s&&!ei(r))return Rr([new ge("","data expressions not supported")]);let o=La(a,["zoom"]);if(!o&&!yf(r))return Rr([new ge("","zoom expressions not supported")]);let l=sa(a);if(!l&&!o)return Rr([new ge("",\'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.\')]);if(l instanceof ge)return Rr([l]);if(l instanceof be&&!Sl(r))return Rr([new ge("",\'"interpolate" expressions cannot be used with this property\')]);if(!l)return io(s?new en("constant",n.value,i):new en("source",n.value,i));let u=l instanceof be?l.interpolation:void 0;return io(s?new ya("camera",n.value,l.labels,u,i):new ya("composite",n.value,l.labels,u,i))}var wf=class Df{constructor(e,r,i){this.isStateDependent=!1,this.globalStateRefs=new Set,this._globalState=null,vf(r),this._parameters=e,this._specification=i,this._rootKey=r,this._defaultValue=_f(i),this._warningHistory={};let n=mf(this._parameters,this._specification);this.kind=n.kind,this.interpolationFactor=n.interpolationFactor,this.zoomStops=n.zoomStops,this.interpolationType=n.interpolationType,this._innerEvaluate=n.evaluate}evaluate(e,r){try{return this._innerEvaluate(e,r)}catch(i){let n=i instanceof Error?i.message:String(i),a=`|${n}`;return this._warningHistory[a]||(this._warningHistory[a]=!0,typeof console<"u"&&console.warn(xf(this._rootKey,"",n,this._defaultValue))),this._defaultValue}}static deserialize(e){return new Df(e._parameters,e._rootKey,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification,_rootKey:e._rootKey}}};function ym(t,e,r,i){if(Va(t))return new wf(t,e,r);if(Oa(t)){let n=bf(t,e,r,i);if(n.result==="error")throw Error(n.value.map(a=>`${a.key}: ${a.message}`).join(", "));return n.value}{let n=t;return r.type==="color"&&typeof t=="string"?n=gt.parse(t):r.type==="padding"&&(typeof t=="number"||Array.isArray(t))?n=Ae.parse(t):r.type==="numberArray"&&(typeof t=="number"||Array.isArray(t))?n=Se.parse(t):r.type==="colorArray"&&(typeof t=="string"||Array.isArray(t))?n=se.parse(t):r.type==="variableAnchorOffsetCollection"&&Array.isArray(t)?n=De.parse(t):r.type==="projectionDefinition"&&typeof t=="string"&&(n=br.parse(t)),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>n}}}function sa(t){let e=null;if(t instanceof Up)e=sa(t.result);else if(t instanceof Hp){for(let r of t.args)if(e=sa(r),e)break}else(t instanceof ml||t instanceof be)&&t.input instanceof wr&&t.input.name==="zoom"&&(e=t);return e instanceof ge||t.eachChild(r=>{let i=sa(r);i instanceof ge?e=i:!e&&i?e=new ge("",\'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.\'):e&&i&&e!==i&&(e=new ge("",\'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.\'))}),e}function mn(t,e=new Set){return t instanceof Al&&e.add(t.key),t.eachChild(r=>{mn(r,e)}),e}function mm(t){let e={color:ue,string:X,number:k,enum:X,boolean:tt,formatted:pn,padding:ka,numberArray:Ia,colorArray:Hi,projectionDefinition:Fa,resolvedImage:fn,variableAnchorOffsetCollection:Ca};return t.type==="array"?Nt(e[t.value]||H,t.length):e[t.type]}function _f(t){if(t.type==="color"&&Va(t.default))return new gt(0,0,0,0);switch(t.type){case"color":return gt.parse(t.default)||null;case"padding":return Ae.parse(t.default)||null;case"numberArray":return Se.parse(t.default)||null;case"colorArray":return se.parse(t.default)||null;case"variableAnchorOffsetCollection":return De.parse(t.default)||null;case"projectionDefinition":return br.parse(t.default)||null;default:return t.default===void 0?null:t.default}}function ri(t,e){let{zoom:r,heatmapDensity:i,elevation:n,lineProgress:a,isSupportedScript:s,accumulated:o}=t??{};return{zoom:r,heatmapDensity:i,elevation:n,lineProgress:a,isSupportedScript:s,accumulated:o,globalState:e}}function gm(t){let e=!1;for(let r of t){let i=Af(r);if(i==="expression")return"expression";i==="legacy"&&(e=!0)}return e?"legacy":"neutral"}function Af(t){if(typeof t=="boolean")return"neutral";if(!Array.isArray(t)||t.length===0)return"legacy";switch(t[0]){case"has":return t.length<2||t[1]==="$id"||t[1]==="$type"?"legacy":t.length===2?"neutral":"expression";case"in":return t.length>=3&&(typeof t[1]!="string"||Array.isArray(t[2]))?"expression":"legacy";case"!in":case"!has":return"legacy";case"==":case"!=":case">":case">=":case"<":case"<=":return t.length!==3||Array.isArray(t[1])||Array.isArray(t[2])?"expression":"legacy";case"none":return"legacy";case"any":case"all":return gm(t.slice(1));default:return"expression"}}function Tl(t){return Af(t)!=="legacy"}function _h(t){return t==="$type"?["geometry-type"]:t==="$id"?["id"]:["get",t]}function xm(t){switch(t[0]){case"==":case"!=":case"<":case"<=":case">":case">=":return t.length!==3||typeof t[1]!="string"?null:[t[0],_h(t[1]),t[2]];case"in":case"!in":{if(t.length<2||typeof t[1]!="string")return null;let e=["in",_h(t[1]),["literal",t.slice(2)]];return t[0]==="!in"?["!",e]:e}case"has":case"!has":{if(t.length!==2||typeof t[1]!="string"||t[1]==="$type"||t[1]==="$id")return null;let e=["has",t[1]];return t[0]==="!has"?["!",e]:e}default:return null}}function Sf(t){if((t[0]==="<"||t[0]==="<="||t[0]===">"||t[0]===">=")&&t[1]==="$type")return`"$type" cannot be use with operator "${t[0]}"`;let e=xm(t);return e?`Mixing deprecated filter syntax with expression syntax is not supported. Replace ${JSON.stringify(t)} with ${JSON.stringify(e)}.`:`Mixing deprecated filter syntax with expression syntax is not supported. Convert ${JSON.stringify(t)} to expression syntax.`}function Bs(t,e,r){let i=r[t];return Array.isArray(i)?Tl(i)?kl(i,e.concat(t)):{path:e.concat(t),legacyFilter:i}:null}function kl(t,e=[]){if(!Array.isArray(t)||t.length<1)return null;switch(t[0]){case"all":case"any":case"none":for(let r=1;r<t.length;r++){let i=Bs(r,e,t);if(i)return i}break;case"!":{let r=Bs(1,e,t);if(r)return r;break}case"case":for(let r=1;r<t.length-1;r+=2){let i=Bs(r,e,t);if(i)return i}}return null}function vm(t,e){let r=kl(t);if(!r||typeof console>"u")return;let i=r.path.map(n=>`[${n}]`).join("");console.warn(`${e}${i}: ${Sf(r.legacyFilter)}`)}var bm={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function ii(t,e,r){if(t==null)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};Tl(t)?vm(t,e):t=ma(t);let i=tr(t,e,bm,r);if(i.result==="error")throw Error(i.value.map(n=>`${n.key}: ${n.message}`).join(", "));return{filter:(n,a,s)=>i.value.evaluate(n,a,{},s),needGeometry:Ef(t),getGlobalStateRefs:()=>mn(i.value.expression)}}function wm(t,e){return t<e?-1:+(t>e)}function Ef(t){if(!Array.isArray(t))return!1;if(t[0]==="within"||t[0]==="distance")return!0;for(let e=1;e<t.length;e++)if(Ef(t[e]))return!0;return!1}function ma(t){if(!t)return!0;let e=t[0];return t.length<=1?e!=="any":e==="=="?Ps(t[1],t[2],"=="):e==="!="?Un(Ps(t[1],t[2],"==")):e==="<"||e===">"||e==="<="||e===">="?Ps(t[1],t[2],e):e==="any"?Dm(t.slice(1)):e==="all"?["all"].concat(t.slice(1).map(ma)):e==="none"?["all"].concat(t.slice(1).map(ma).map(Un)):e==="in"?Ah(t[1],t.slice(2)):e==="!in"?Un(Ah(t[1],t.slice(2))):e==="has"?Sh(t[1]):e!=="!has"||Un(Sh(t[1]))}function Ps(t,e,r){switch(t){case"$type":return[`filter-type-${r}`,e];case"$id":return[`filter-id-${r}`,e];default:return[`filter-${r}`,t,e]}}function Dm(t){return["any"].concat(t.map(ma))}function Ah(t,e){if(e.length===0)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some(r=>typeof r!=typeof e[0])?["filter-in-large",t,["literal",e.sort(wm)]]:["filter-in-small",t,["literal",e]]}}function Sh(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function Un(t){return["!",t]}function Ff(t){let e=t.key,r=t.value;return r?[new T(e,r,"constants have been deprecated as of v8")]:[]}function Dt(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function mr(t){if(Array.isArray(t))return t.map(mr);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){let e={};for(let r in t)e[r]=mr(t[r]);return e}return Dt(t)}function Jt(t){let e=t.key,r=t.value,i=t.valueSpec||{},n=t.objectElementValidators||{},a=t.style,s=t.styleSpec,o=t.validateSpec,l=[],u=J(r);if(u!=="object")return[new T(e,r,`object expected, ${u} found`)];for(let h in r){let c=h.split(".")[0],p=Ni(i,c)||i["*"],f;if(Ni(n,c))f=n[c];else if(Ni(i,c)){if(r[h]===void 0)continue;f=o}else if(n["*"])f=n["*"];else if(i["*"])f=o;else{l.push(new T(e,r[h],`unknown property "${h}"`));continue}l=l.concat(f({key:(e&&`${e}.`)+h,value:r[h],valueSpec:p,style:a,styleSpec:s,object:r,objectKey:h,validateSpec:o},r))}for(let h in i)n[h]||i[h].required&&i[h].default===void 0&&r[h]===void 0&&l.push(new T(e,r,`missing required property "${h}"`));return l}function Il(t){let e=t.value,r=t.valueSpec,i=t.validateSpec,n=t.style,a=t.styleSpec,s=t.key,o=t.arrayElementValidator||i;if(J(e)!=="array")return[new T(s,e,`array expected, ${J(e)} found`)];if(r.length&&e.length!==r.length)return[new T(s,e,`array length ${r.length} expected, length ${e.length} found`)];let l={type:r.value,values:r.values};a.$version<7&&(l.function=r.function),J(r.value)==="object"&&(l=r.value);let u=[];for(let h=0;h<e.length;h++)u=u.concat(o({array:e,arrayIndex:h,value:e[h],valueSpec:l,validateSpec:t.validateSpec,style:n,styleSpec:a,key:`${s}[${h}]`}));return u}function Ra(t){let e=t.key,r=t.value,i=t.valueSpec,n=J(r);return n==="number"&&r!==r&&(n="NaN"),n==="number"?"minimum"in i&&r<i.minimum?[new T(e,r,`${r} is less than the minimum value ${i.minimum}`)]:"maximum"in i&&r>i.maximum?[new T(e,r,`${r} is greater than the maximum value ${i.maximum}`)]:[]:[new T(e,r,`number expected, ${n} found`)]}function Tf(t){let e=t.valueSpec,r=Dt(t.value.type),i,n={},a,s,o=r!=="categorical"&&t.value.property===void 0,l=!o,u=J(t.value.stops)==="array"&&J(t.value.stops[0])==="array"&&J(t.value.stops[0][0])==="object",h=Jt({key:t.key,value:t.value,valueSpec:t.styleSpec.function,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:c,default:d}});return r==="identity"&&o&&h.push(new T(t.key,t.value,\'missing required property "property"\')),r!=="identity"&&!t.value.stops&&h.push(new T(t.key,t.value,\'missing required property "stops"\')),r==="exponential"&&t.valueSpec.expression&&!Sl(t.valueSpec)&&h.push(new T(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!ei(t.valueSpec)?h.push(new T(t.key,t.value,"property functions not supported")):o&&!yf(t.valueSpec)&&h.push(new T(t.key,t.value,"zoom functions not supported"))),(r==="categorical"||u)&&t.value.property===void 0&&h.push(new T(t.key,t.value,\'"property" property is required\')),h;function c(y){if(r==="identity")return[new T(y.key,y.value,\'identity function may not have a "stops" property\')];let m=[],g=y.value;return m=m.concat(Il({key:y.key,value:g,valueSpec:y.valueSpec,validateSpec:y.validateSpec,style:y.style,styleSpec:y.styleSpec,arrayElementValidator:p})),J(g)==="array"&&g.length===0&&m.push(new T(y.key,g,"array must have at least one stop")),m}function p(y){let m=[],g=y.value,x=y.key;if(J(g)!=="array")return[new T(x,g,`array expected, ${J(g)} found`)];if(g.length!==2)return[new T(x,g,`array length 2 expected, length ${g.length} found`)];if(u){if(J(g[0])!=="object")return[new T(x,g,`object expected, ${J(g[0])} found`)];if(g[0].zoom===void 0)return[new T(x,g,"object stop key must have zoom")];if(g[0].value===void 0)return[new T(x,g,"object stop key must have value")];if(s&&s>Dt(g[0].zoom))return[new T(x,g[0].zoom,"stop zoom values must appear in ascending order")];Dt(g[0].zoom)!==s&&(s=Dt(g[0].zoom),a=void 0,n={}),m=m.concat(Jt({key:`${x}[0]`,value:g[0],valueSpec:{zoom:{}},validateSpec:y.validateSpec,style:y.style,styleSpec:y.styleSpec,objectElementValidators:{zoom:Ra,value:f}}))}else m=m.concat(f({key:`${x}[0]`,value:g[0],valueSpec:{},validateSpec:y.validateSpec,style:y.style,styleSpec:y.styleSpec},g));return Oa(mr(g[1]))?m.concat([new T(`${x}[1]`,g[1],"expressions are not allowed in function stops.")]):m.concat(y.validateSpec({key:`${x}[1]`,value:g[1],valueSpec:e,validateSpec:y.validateSpec,style:y.style,styleSpec:y.styleSpec}))}function f(y,m){let g=J(y.value),x=Dt(y.value),b=y.value===null?m:y.value;if(!i)i=g;else if(g!==i)return[new T(y.key,b,`${g} stop domain type must match previous stop domain type ${i}`)];if(g!=="number"&&g!=="string"&&g!=="boolean")return[new T(y.key,b,"stop domain value must be a number, string, or boolean")];if(g!=="number"&&r!=="categorical"){let v=`number expected, ${g} found`;return ei(e)&&r===void 0&&(v+=\'\\nIf you intended to use a categorical function, specify `"type": "categorical"`.\'),[new T(y.key,b,v)]}return r==="categorical"&&g==="number"&&(!isFinite(x)||Math.floor(x)!==x)?[new T(y.key,b,`integer expected, found ${x}`)]:r!=="categorical"&&g==="number"&&a!==void 0&&x<a?[new T(y.key,b,"stop domain values must appear in ascending order")]:(a=x,r==="categorical"&&x in n?[new T(y.key,b,"stop domain values must be unique")]:(n[x]=!0,[]))}function d(y){return y.validateSpec({key:y.key,value:y.value,valueSpec:e,validateSpec:y.validateSpec,style:y.style,styleSpec:y.styleSpec})}}function ni(t){let e=(t.expressionContext==="property"?bf:tr)(mr(t.value),t.key,t.valueSpec);if(e.result==="error")return e.value.map(i=>new T(`${t.key}${i.key}`,t.value,i.message));let r=e.value.expression||e.value._styleExpression.expression;if(t.expressionContext==="property"&&t.propertyKey==="text-font"&&!r.outputDefined())return[new T(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if(t.expressionContext==="property"&&t.propertyType==="layout"&&!Qi(r))return[new T(t.key,t.value,\'"feature-state" data expressions are not supported with layout properties.\')];if(t.expressionContext==="filter"&&!Qi(r))return[new T(t.key,t.value,\'"feature-state" data expressions are not supported with filters.\')];if(t.expressionContext&&t.expressionContext.indexOf("cluster")===0){if(!La(r,["zoom","feature-state"]))return[new T(t.key,t.value,\'"zoom" and "feature-state" expressions are not supported with cluster properties.\')];if(t.expressionContext==="cluster-initial"&&!za(r))return[new T(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function _m(t){let e=t.value,r=t.key,i=J(e);return i==="boolean"?[]:[new T(r,e,`boolean expected, ${i} found`)]}function no(t){let e=t.key,r=t.value,i=J(r);return i==="string"?gt.parse(String(r))?[]:[new T(e,r,`color expected, "${r}" found`)]:[new T(e,r,`color expected, ${i} found`)]}function rn(t){let e=t.key,r=t.value,i=t.valueSpec,n=[];return Array.isArray(i.values)?i.values.indexOf(Dt(r))===-1&&n.push(new T(e,r,`expected one of [${i.values.join(", ")}], ${JSON.stringify(r)} found`)):Object.keys(i.values).indexOf(Dt(r))===-1&&n.push(new T(e,r,`expected one of [${Object.keys(i.values).join(", ")}], ${JSON.stringify(r)} found`)),n}function Am(t,e){let r=t;for(let i of e)r=r[i];return r}function Sm(t,e){let r=kl(e);return r?[new T(`${t.key}${r.path.map(i=>`[${i}]`).join("")}`,Am(t.value,r.path),Sf(r.legacyFilter),null,"warning")]:[]}function Cl(t){let e=mr(t.value);return Tl(e)?[...Sm(t,e),...ni(tn({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}}))]:kf(t)}function kf(t){let e=t.value,r=t.key;if(J(e)!=="array")return[new T(r,e,`array expected, ${J(e)} found`)];let i=t.styleSpec,n,a=[];if(e.length<1)return[new T(r,e,"filter array must have at least 1 element")];switch(a=a.concat(rn({key:`${r}[0]`,value:e[0],valueSpec:i.filter_operator,style:t.style,styleSpec:t.styleSpec})),Dt(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&Dt(e[1])==="$type"&&a.push(new T(r,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":e.length!==3&&a.push(new T(r,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(n=J(e[1]),n!=="string"&&a.push(new T(`${r}[1]`,e[1],`string expected, ${n} found`)));for(let s=2;s<e.length;s++)n=J(e[s]),Dt(e[1])==="$type"?a=a.concat(rn({key:`${r}[${s}]`,value:e[s],valueSpec:i.geometry_type,style:t.style,styleSpec:t.styleSpec})):n!=="string"&&n!=="number"&&n!=="boolean"&&a.push(new T(`${r}[${s}]`,e[s],`string, number, or boolean expected, ${n} found`));break;case"any":case"all":case"none":for(let s=1;s<e.length;s++)a=a.concat(kf({key:`${r}[${s}]`,value:e[s],style:t.style,styleSpec:t.styleSpec}));break;case"has":case"!has":n=J(e[1]),e.length===2?n!=="string"&&a.push(new T(`${r}[1]`,e[1],`string expected, ${n} found`)):a.push(new T(r,e,`filter array for "${e[0]}" operator must have 2 elements`))}return a}function If(t,e){let r=t.key,i=t.validateSpec,n=t.style,a=t.styleSpec,s=t.value,o=t.objectKey,l=a[`${e}_${t.layerType}`];if(!l)return[];let u=o.match(El);if(e==="paint"&&u&&l[u[1]]&&l[u[1]].transition)return i({key:r,value:s,valueSpec:a.transition,style:n,styleSpec:a});let h=t.valueSpec||l[o];if(!h)return[new T(r,s,`unknown property "${o}"`)];let c;if(J(s)==="string"&&ei(h)&&!h.tokens&&(c=/^{([^}]+)}$/.exec(s)))return[new T(r,s,`"${o}" does not support interpolation syntax\nUse an identity property function instead: \\`{ "type": "identity", "property": ${JSON.stringify(c[1])} }\\`.`)];let p=[];return t.layerType==="symbol"&&o==="text-font"&&Va(mr(s))&&Dt(s.type)==="identity"&&p.push(new T(r,s,\'"text-font" does not support identity functions\')),p.concat(i({key:t.key,value:s,valueSpec:h,style:n,styleSpec:a,expressionContext:"property",propertyType:e,propertyKey:o}))}function Cf(t){return If(t,"paint")}function Mf(t){return If(t,"layout")}function Bf(t){let e=[],r=t.value,i=t.key,n=t.style,a=t.styleSpec;if(J(r)!=="object")return[new T(i,r,`object expected, ${J(r)} found`)];!r.type&&!r.ref&&e.push(new T(i,r,\'either "type" or "ref" is required\'));let s=Dt(r.type),o=Dt(r.ref);if(r.id){let l=Dt(r.id);for(let u=0;u<t.arrayIndex;u++){let h=n.layers[u];Dt(h.id)===l&&e.push(new T(i,r.id,`duplicate layer id "${r.id}", previously used at line ${h.id.__line__}`))}}if("ref"in r){["type","source","source-layer","filter","layout"].forEach(u=>{u in r&&e.push(new T(i,r[u],`"${u}" is prohibited for ref layers`))});let l;n.layers.forEach(u=>{Dt(u.id)===o&&(l=u)}),l?l.ref?e.push(new T(i,r.ref,"ref cannot reference another ref layer")):s=Dt(l.type):e.push(new T(i,r.ref,`ref layer "${o}" not found`))}else if(s!=="background")if(!r.source)e.push(new T(i,r,\'missing required property "source"\'));else{let l=n.sources&&n.sources[r.source],u=l&&Dt(l.type);l?u==="vector"&&s==="raster"?e.push(new T(i,r.source,`layer "${r.id}" requires a raster source`)):u!=="raster-dem"&&s==="hillshade"||u!=="raster-dem"&&s==="color-relief"?e.push(new T(i,r.source,`layer "${r.id}" requires a raster-dem source`)):u==="raster"&&s!=="raster"?e.push(new T(i,r.source,`layer "${r.id}" requires a vector source`)):u==="vector"&&!r["source-layer"]?e.push(new T(i,r,`layer "${r.id}" must specify a "source-layer"`)):u==="raster-dem"&&s!=="hillshade"&&s!=="color-relief"?e.push(new T(i,r.source,"raster-dem source can only be used with layer type \'hillshade\' or \'color-relief\'.")):s==="line"&&r.paint&&r.paint["line-gradient"]&&(u!=="geojson"||!l.lineMetrics)&&e.push(new T(i,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \\`lineMetrics\\` enabled.`)):e.push(new T(i,r.source,`source "${r.source}" not found`))}return s==="raster"&&r.paint?.resampling&&r.paint?.["raster-resampling"]&&e.push(new T(i,r.paint,`layer "${r.id}" redundantly specifies "resampling" and "raster-resampling" paint properties, but only one is allowed. It is advised to use "resampling".`)),e=e.concat(Jt({key:i,value:r,valueSpec:a.layer,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*"(){return[]},type(){return t.validateSpec({key:`${i}.type`,value:r.type,valueSpec:a.layer.type,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,object:r,objectKey:"type"})},filter:Cl,layout(l){return Jt({layer:r,key:l.key,value:l.value,style:l.style,styleSpec:l.styleSpec,validateSpec:l.validateSpec,objectElementValidators:{"*"(u){return Mf(tn({layerType:s},u))}}})},paint(l){return Jt({layer:r,key:l.key,value:l.value,style:l.style,styleSpec:l.styleSpec,validateSpec:l.validateSpec,objectElementValidators:{"*"(u){return Cf(tn({layerType:s},u))}}})}}})),e}function Je(t){let e=t.value,r=t.key,i=J(e);return i==="string"?[]:[new T(r,e,`string expected, ${i} found`)]}function Em(t){let e=t.sourceName??"",r=t.value,i=t.styleSpec,n=i.source_raster_dem,a=t.style,s=[],o=J(r);if(r===void 0)return s;if(o!=="object")return s.push(new T("source_raster_dem",r,`object expected, ${o} found`)),s;let l=Dt(r.encoding)==="custom",u=["redFactor","greenFactor","blueFactor","baseShift"],h=t.value.encoding?`"${t.value.encoding}"`:"Default";for(let c in r)!l&&u.includes(c)?s.push(new T(c,r[c],`In "${e}": "${c}" is only valid when "encoding" is set to "custom". ${h} encoding found`)):n[c]?s=s.concat(t.validateSpec({key:c,value:r[c],valueSpec:n[c],validateSpec:t.validateSpec,style:a,styleSpec:i})):s.push(new T(c,r[c],`unknown property "${c}"`));return s}var Eh={promoteId:Fm};function Pf(t){let e=t.value,r=t.key,i=t.styleSpec,n=t.style,a=t.validateSpec;if(!e.type)return[new T(r,e,\'"type" is required\')];let s=Dt(e.type),o;switch(s){case"vector":case"raster":return o=Jt({key:r,value:e,valueSpec:i[`source_${s.replace("-","_")}`],style:t.style,styleSpec:i,objectElementValidators:Eh,validateSpec:a}),o;case"raster-dem":return o=Em({sourceName:r,value:e,style:t.style,styleSpec:i,validateSpec:a}),o;case"geojson":if(o=Jt({key:r,value:e,valueSpec:i.source_geojson,style:n,styleSpec:i,validateSpec:a,objectElementValidators:Eh}),e.cluster)for(let l in e.clusterProperties){let[u,h]=e.clusterProperties[l],c=typeof u=="string"?[u,["accumulated"],["get",l]]:u;o.push(...ni({key:`${r}.${l}.map`,value:h,validateSpec:a,expressionContext:"cluster-map"})),o.push(...ni({key:`${r}.${l}.reduce`,value:c,validateSpec:a,expressionContext:"cluster-reduce"}))}return o;case"video":return Jt({key:r,value:e,valueSpec:i.source_video,style:n,validateSpec:a,styleSpec:i});case"image":return Jt({key:r,value:e,valueSpec:i.source_image,style:n,validateSpec:a,styleSpec:i});case"canvas":return[new T(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return rn({key:`${r}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:n,validateSpec:a,styleSpec:i})}}function Fm({key:t,value:e}){if(J(e)==="string")return Je({key:t,value:e});{let r=[];for(let i in e)r.push(...Je({key:`${t}.${i}`,value:e[i]}));return r}}function zf(t){let e=t.value,r=t.styleSpec,i=r.light,n=t.style,a=[],s=J(e);if(e===void 0)return a;if(s!=="object")return a=a.concat([new T("light",e,`object expected, ${s} found`)]),a;for(let o in e){let l=o.match(El);a=l&&i[l[1]]&&i[l[1]].transition?a.concat(t.validateSpec({key:o,value:e[o],valueSpec:r.transition,validateSpec:t.validateSpec,style:n,styleSpec:r})):i[o]?a.concat(t.validateSpec({key:o,value:e[o],valueSpec:i[o],validateSpec:t.validateSpec,style:n,styleSpec:r})):a.concat([new T(o,e[o],`unknown property "${o}"`)])}return a}function Lf(t){let e=t.value,r=t.styleSpec,i=r.sky,n=t.style,a=J(e);if(e===void 0)return[];if(a!=="object")return[new T("sky",e,`object expected, ${a} found`)];let s=[];for(let o in e){let l=o.match(El);s=l&&i[l[1]]&&i[l[1]].transition?s.concat(t.validateSpec({key:o,value:e[o],valueSpec:r.transition,style:n,styleSpec:r})):i[o]?s.concat(t.validateSpec({key:o,value:e[o],valueSpec:i[o],style:n,styleSpec:r})):s.concat([new T(o,e[o],`unknown property "${o}"`)])}return s}function Vf(t){let e=t.value,r=t.styleSpec,i=r.terrain,n=t.style,a=[],s=J(e);if(e===void 0)return a;if(s!=="object")return a=a.concat([new T("terrain",e,`object expected, ${s} found`)]),a;for(let o in e)a=i[o]?a.concat(t.validateSpec({key:o,value:e[o],valueSpec:i[o],validateSpec:t.validateSpec,style:n,styleSpec:r})):a.concat([new T(o,e[o],`unknown property "${o}"`)]);return a}function Tm(t){return Je(t).length===0?[]:ni(t)}function km(t){return Je(t).length===0?[]:ni(t)}function Im(t){let e=t.key,r=t.value;if(J(r)==="array"){if(r.length<1||r.length>4)return[new T(e,r,`padding requires 1 to 4 values; ${r.length} values found`)];let i={type:"number"},n=[];for(let a=0;a<r.length;a++)n=n.concat(t.validateSpec({key:`${e}[${a}]`,value:r[a],validateSpec:t.validateSpec,valueSpec:i}));return n}return Ra({key:e,value:r,valueSpec:{}})}function Cm(t){let e=t.key,r=t.value;if(J(r)==="array"){let i={type:"number"};if(r.length<1)return[new T(e,r,"array length at least 1 expected, length 0 found")];let n=[];for(let a=0;a<r.length;a++)n=n.concat(t.validateSpec({key:`${e}[${a}]`,value:r[a],validateSpec:t.validateSpec,valueSpec:i}));return n}return Ra({key:e,value:r,valueSpec:{}})}function Mm(t){let e=t.key,r=t.value;if(J(r)==="array"){if(r.length<1)return[new T(e,r,"array length at least 1 expected, length 0 found")];let i=[];for(let n=0;n<r.length;n++)i=i.concat(no({key:`${e}[${n}]`,value:r[n],valueSpec:{}}));return i}return no({key:e,value:r,valueSpec:{}})}function Bm(t){let e=t.key,r=t.value,i=J(r),n=t.styleSpec;if(i!=="array"||r.length<1||r.length%2!=0)return[new T(e,r,"variableAnchorOffsetCollection requires a non-empty array of even length")];let a=[];for(let s=0;s<r.length;s+=2)a=a.concat(rn({key:`${e}[${s}]`,value:r[s],valueSpec:n.layout_symbol["text-anchor"]})),a=a.concat(Il({key:`${e}[${s+1}]`,value:r[s+1],valueSpec:{length:2,value:"number"},validateSpec:t.validateSpec,style:t.style,styleSpec:n}));return a}function Of(t){let e=[],r=t.value,i=t.key;if(Array.isArray(r)){let n=[],a=[];for(let s in r)r[s].id&&n.includes(r[s].id)&&e.push(new T(i,r,`all the sprites\' ids must be unique, but ${r[s].id} is duplicated`)),n.push(r[s].id),r[s].url&&a.includes(r[s].url)&&e.push(new T(i,r,`all the sprites\' URLs must be unique, but ${r[s].url} is duplicated`)),a.push(r[s].url),e=e.concat(Jt({key:`${i}[${s}]`,value:r[s],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:t.validateSpec}));return e}return Je({key:i,value:r})}function Pm(t){let e=t.value,r=t.styleSpec,i=r.projection,n=t.style,a=J(e);if(e===void 0)return[];if(a!=="object")return[new T("projection",e,`object expected, ${a} found`)];let s=[];for(let o in e)s=i[o]?s.concat(t.validateSpec({key:o,value:e[o],valueSpec:i[o],style:n,styleSpec:r})):s.concat([new T(o,e[o],`unknown property "${o}"`)]);return s}function zm(t){let e=t.key,r=t.value;r=r instanceof String?r.valueOf():r;let i=J(r);return i==="array"&&!Vm(r)&&!Lm(r)?[new T(e,r,`projection expected, invalid array ${JSON.stringify(r)} found`)]:["array","string"].includes(i)?[]:[new T(e,r,`projection expected, invalid type "${i}" found`)]}function Lm(t){return!!["interpolate","step","literal"].includes(t[0])}function Vm(t){return Array.isArray(t)&&t.length===3&&typeof t[0]=="string"&&typeof t[1]=="string"&&typeof t[2]=="number"}function ao(t){return!!t&&t.constructor===Object}function Rf(t){return ao(t.value)?[]:[new T(t.key,t.value,`object expected, ${J(t.value)} found`)]}var Fh=1114111,Om=/^u\\+(?:([0-9a-f]{1,6})(?:-([0-9a-f]{1,6}))?|([0-9a-f]{0,5}\\?{1,6}))$/i;function Rm(t,e){if(J(e)!=="string")return[];let r=`${e}`,i=()=>[new T(t,e,\'invalid unicode range, expected a value such as "U+26", "U+0-10FFFF" or "U+4??"\')],n=r.match(Om);if(!n)return i();let[,a,s,o]=n;if(o!==void 0)return o.length>6?i():[];let l=parseInt(a,16),u=s===void 0?l:parseInt(s,16);return l>Fh||u>Fh?[new T(t,e,"unicode range is out of bounds, the maximum code point is U+10FFFF")]:l>u?[new T(t,e,`unicode range start must not be greater than its end, but ${r} is`)]:[]}function $f(t){let e=t.key??"font-faces",r=t.value,i=t.validateSpec,n=t.styleSpec??_p,a=t.style;if(!ao(r))return[new T(e,r,`object expected, ${J(r)} found`)];let s=[];for(let o in r){let l=r[o],u=J(l);if(u==="string")s.push(...Je({key:`${e}.${o}`,value:l}));else if(u==="array"){let h={url:{type:"string",required:!0},"unicode-range":{type:"array",value:"string"}};for(let[c,p]of l.entries()){let f=`${e}.${o}[${c}]`;s.push(...Jt({key:f,value:p,valueSpec:h,styleSpec:n,style:a,validateSpec:i}));let d=ao(p)?p["unicode-range"]:void 0;if(J(d)==="array")for(let[y,m]of d.entries())s.push(...Rm(`${f}.unicode-range[${y}]`,m))}}else s.push(new T(`${e}.${o}`,l,`string or array expected, ${u} found`))}return s}var Th={"*"(){return[]},array:Il,boolean:_m,number:Ra,color:no,constants:Ff,enum:rn,filter:Cl,function:Tf,layer:Bf,object:Jt,source:Pf,light:zf,sky:Lf,terrain:Vf,projection:Pm,projectionDefinition:zm,string:Je,formatted:Tm,resolvedImage:km,padding:Im,numberArray:Cm,colorArray:Mm,variableAnchorOffsetCollection:Bm,sprite:Of,state:Rf,fontFaces:$f};function qi(t){let e=t.value,r=t.valueSpec,i=t.styleSpec;return t.validateSpec=qi,r.expression&&Va(Dt(e))?Tf(t):r.expression&&Oa(mr(e))?ni(t):r.type&&Th[r.type]?Th[r.type](t):Jt(tn({},t,{valueSpec:r.type?i[r.type]:r}))}function Nf(t){let e=t.value,r=t.key,i=Je(t);return i.length||(e.indexOf("{fontstack}")===-1&&i.push(new T(r,e,\'"glyphs" url must include a "{fontstack}" token\')),e.indexOf("{range}")===-1&&i.push(new T(r,e,\'"glyphs" url must include a "{range}" token\'))),i}function Kt(t,e=D){let r=[];return r=r.concat(qi({key:"",value:t,valueSpec:e.$root,styleSpec:e,style:t,validateSpec:qi,objectElementValidators:{glyphs:Nf,"*"(){return[]}}})),t.constants&&(r=r.concat(Ff({key:"constants",value:t.constants,style:t,styleSpec:e,validateSpec:qi}))),Uf(r)}Kt.source=re(ee(Pf)),Kt.sprite=re(ee(Of)),Kt.glyphs=re(ee(Nf)),Kt.fontFaces=re(ee($f)),Kt.light=re(ee(zf)),Kt.sky=re(ee(Lf)),Kt.terrain=re(ee(Vf)),Kt.state=re(ee(Rf)),Kt.layer=re(ee(Bf)),Kt.filter=re(ee(Cl)),Kt.paintProperty=re(ee(Cf)),Kt.layoutProperty=re(ee(Mf));function ee(t){return function(e){return t(Object.assign({},e,{validateSpec:qi}))}}function Uf(t){return[].concat(t).sort((e,r)=>e.line-r.line)}function re(t){return function(...e){return Uf(t.apply(this,e))}}var $m={type:"enum","property-type":"data-constant",expression:{interpolated:!1,parameters:["global-state"]},values:{visible:{},none:{}},transition:!1,default:"visible"},Nm=class{constructor(t,e,r){this._rootKey=e,this._globalState=r,this.setValue(t)}evaluate(){return this._literalValue??this._compiledValue.evaluate({})}setValue(t){if(t==null||t==="visible"||t==="none"){this._literalValue=t==="none"?"none":"visible",this._compiledValue=void 0,this._globalStateRefs=new Set;return}let e=tr(t,this._rootKey,$m,this._globalState);if(e.result==="error")throw this._literalValue="visible",this._compiledValue=void 0,Error(e.value.map(r=>`${r.key}: ${r.message}`).join(", "));this._literalValue=void 0,this._compiledValue=e.value,this._globalStateRefs=mn(e.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}};function Um(t,e,r){return new Nm(t,e,r)}var kh=Kt,n5=new Set(Object.keys(D).filter(t=>t.startsWith("source_")).map(t=>t.slice(7).replaceAll("_","-")));function qm(t,e){let r=!1;for(let i of e){if(i.severity==="warning"){Mt(i.message);continue}t.fire(new ha(Error(i.message))),r=!0}return r}function jm(t,e,r,i){return i?.validate!==!1&&qm(t,e({styleSpec:D,...r}))}var so=class qf{constructor(e,r,i){let n=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;let s=new Int32Array(this.arrayBuffer);e=s[0],r=s[1],i=s[2],this.d=r+2*i;for(let u=0;u<this.d*this.d;u++){let h=s[3+u],c=s[3+u+1];n.push(h===c?null:s.subarray(h,c))}let o=s[3+n.length],l=s[3+n.length+1];this.keys=s.subarray(o,l),this.bboxes=s.subarray(l),this.insert=this._insertReadonly}else{this.d=r+2*i;for(let s=0;s<this.d*this.d;s++)n.push([]);this.keys=[],this.bboxes=[]}this.n=r,this.extent=e,this.padding=i,this.scale=r/e,this.uid=0;let a=i/r*e;this.min=-a,this.max=e+a}insert(e,r,i,n,a){this._forEachCell(r,i,n,a,this._insertCell,this.uid++,void 0,void 0),this.keys.push(e),this.bboxes.push(r),this.bboxes.push(i),this.bboxes.push(n),this.bboxes.push(a)}_insertReadonly(){throw Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(e,r,i,n,a,s){this.cells[a].push(s)}query(e,r,i,n,a){let s=this.min,o=this.max;if(e<=s&&r<=s&&o<=i&&o<=n&&!a)return[...this.keys];{let l=[];return this._forEachCell(e,r,i,n,this._queryCell,l,{},a),l}}_queryCell(e,r,i,n,a,s,o,l){let u=this.cells[a];if(u!==null){let h=this.keys,c=this.bboxes;for(let p of u)if(o[p]===void 0){let f=p*4;(l?l(c[f+0],c[f+1],c[f+2],c[f+3]):e<=c[f+2]&&r<=c[f+3]&&i>=c[f+0]&&n>=c[f+1])?(o[p]=!0,s.push(h[p])):o[p]=!1}}}_forEachCell(e,r,i,n,a,s,o,l){let u=this._convertToCellCoord(e),h=this._convertToCellCoord(r),c=this._convertToCellCoord(i),p=this._convertToCellCoord(n);for(let f=u;f<=c;f++)for(let d=h;d<=p;d++){let y=this.d*d+f;if((!l||l(this._convertFromCellCoord(f),this._convertFromCellCoord(d),this._convertFromCellCoord(f+1),this._convertFromCellCoord(d+1)))&&a.call(this,e,r,i,n,y,s,o,l))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,r=3+this.cells.length+1+1,i=0;for(let s of this.cells)i+=s.length;let n=new Int32Array(r+i+this.keys.length+this.bboxes.length);n[0]=this.extent,n[1]=this.n,n[2]=this.padding;let a=r;for(let s=0;s<e.length;s++){let o=e[s];n[3+s]=a,n.set(o,a),a+=o.length}return n[3+e.length]=a,n.set(this.keys,a),a+=this.keys.length,n[3+e.length+1]=a,n.set(this.bboxes,a),a+=this.bboxes.length,n.buffer}static serialize(e,r){let i=e.toArrayBuffer();return r&&r.push(i),{buffer:i}}static deserialize(e){return new qf(e.buffer)}},Ce={};function I(t,e,r={}){if(Ce[t])throw Error(`${t} is already registered.`);Object.defineProperty(e,"_classRegistryKey",{value:t,writeable:!1}),Ce[t]={klass:e,omit:r.omit||[],shallow:r.shallow||[]}}I("Object",Object),I("Set",Set),I("TransferableGridIndex",so),I("Color",gt),I("Error",Error),I("AJAXError",ua),I("ResolvedImage",_e),I("StylePropertyFunction",wf),I("StyleExpression",Fl,{omit:["_evaluator"]}),I("ZoomDependentExpression",ya),I("ZoomConstantExpression",en),I("CompoundExpression",wr,{omit:["_evaluate"]});for(let t in Gr)Gr[t]._classRegistryKey||I(`Expression_${t}`,Gr[t]);function jf(t){return t&&typeof ArrayBuffer<"u"&&(t instanceof ArrayBuffer||t.constructor?.name==="ArrayBuffer")}function Ml(t){let e=t.constructor;return t.$name||e._classRegistryKey}function Gm(t){if(typeof t!="object"||!t)return!1;let e=Ml(t);return e&&e!=="Object"}function Gf(t){return!Gm(t)&&(t==null||typeof t=="boolean"||typeof t=="number"||typeof t=="string"||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||t instanceof Blob||t instanceof Error||jf(t)||Sa(t)||ArrayBuffer.isView(t)||t instanceof ImageData)}function ji(t,e){if(Gf(t))return(jf(t)||Sa(t))&&e&&e.push(t),ArrayBuffer.isView(t)&&e&&e.push(t.buffer),t instanceof ImageData&&e&&e.push(t.data.buffer),t;if(Array.isArray(t)){let a=[];for(let s of t)a.push(ji(s,e));return a}if(typeof t!="object")throw Error(`can\'t serialize object of type ${typeof t}`);let r=Ml(t);if(!r)throw Error(`can\'t serialize object of unregistered class ${t.constructor.name}`);if(!Ce[r])throw Error(`${r} is not registered.`);let{klass:i}=Ce[r],n=i.serialize?i.serialize(t,e):{};if(i.serialize){if(n===e?.[e.length-1])throw Error("statically serialized object won\'t survive transfer of $name property")}else{for(let a in t){if(!t.hasOwnProperty(a)||Ce[r].omit.includes(a))continue;let s=t[a];s!==void 0&&(n[a]=Ce[r].shallow.includes(a)?s:ji(s,e))}t instanceof Error&&(n.message=t.message)}if(n.$name)throw Error("$name property is reserved for worker serialization logic.");return r!=="Object"&&(n.$name=r),n}function Gi(t){if(Gf(t))return t;if(Array.isArray(t))return t.map(Gi);if(typeof t!="object")throw Error(`can\'t deserialize object of type ${typeof t}`);let e=Ml(t)||"Object";if(!Ce[e])throw Error(`can\'t deserialize unregistered class ${e}`);let{klass:r}=Ce[e];if(!r)throw Error(`can\'t deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(t);let i=Object.create(r.prototype);for(let n of Object.keys(t)){if(n==="$name")continue;let a=t[n];i[n]=Ce[e].shallow.includes(n)?a:Gi(a)}return i}var Ih=class{constructor(){this.first=!0}update(t,e){let r=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=r,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=r,!0):(this.lastFloorZoom>r?(this.lastIntegerZoom=r+1,this.lastIntegerZoomTime=e):this.lastFloorZoom<r&&(this.lastIntegerZoom=r,this.lastIntegerZoomTime=e),t!==this.lastZoom&&(this.lastZoom=t,this.lastFloorZoom=r,!0))}},at=class{constructor(t,e){this.zoom=t,e?(this.now=e.now||0,this.fadeDuration=e.fadeDuration||0,this.zoomHistory=e.zoomHistory||new Ih,this.transition=e.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Ih,this.transition={})}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){let t=this.zoom,e=t-Math.floor(t),r=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*r}:{fromScale:.5,toScale:1,t:1-(1-r)*e}}},Ym="-transition",$a=class{constructor(t,e,r,i){this.property=t,this.value=e,this.expression=ym(e===void 0?t.specification.default:e,r,t.specification,i)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(t,e,r){return this.property.possiblyEvaluate(this,t,e,r)}},oo=class{constructor(t,e,r){this.property=t,this.value=new $a(t,void 0,e,r)}transitioned(t,e){return new Ch(this.property,this.value,e,qt({},t.transition,this.transition),t.now)}untransitioned(){return new Ch(this.property,this.value,null,{},0)}},Xm=class{constructor(t,e,r){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues),this._globalState=r,this._rootKey=e}_propertyRootKey(t){return`${this._rootKey}.${String(t)}`}hasProperty(t){return t in this._properties.defaultTransitionablePropertyValues}getValue(t){return Xe(this._values[t].value.value)}setValue(t,e){Object.hasOwn(this._values,t)||(this._values[t]=new oo(this._values[t].property,this._propertyRootKey(t),this._globalState)),this._values[t].value=new $a(this._values[t].property,e===null?void 0:Xe(e),this._propertyRootKey(t),this._globalState)}getTransition(t){return Xe(this._values[t].transition)}setTransition(t,e){Object.hasOwn(this._values,t)||(this._values[t]=new oo(this._values[t].property,this._propertyRootKey(t),this._globalState)),this._values[t].transition=Xe(e)||void 0}serialize(){let t={};for(let e of Object.keys(this._values)){let r=this.getValue(e);r!==void 0&&(t[e]=r);let i=this.getTransition(e);i!==void 0&&(t[`${e}${Ym}`]=i)}return t}transitioned(t,e){let r=new Mh(this._properties);for(let i of Object.keys(this._values))r._values[i]=this._values[i].transitioned(t,e._values[i]);return r}untransitioned(){let t=new Mh(this._properties);for(let e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}},Ch=class{constructor(t,e,r,i,n){this.property=t,this.value=e,this.begin=n+i.delay||0,this.end=this.begin+i.duration||0,t.specification.transition&&(i.delay||i.duration)&&(this.prior=r)}possiblyEvaluate(t,e,r){let i=t.now||0,n=this.value.possiblyEvaluate(t,e,r),a=this.prior;if(!a)return n;if(i>this.end||this.value.isDataDriven())return this.prior=null,n;if(i<this.begin)return a.possiblyEvaluate(t,e,r);{let s=(i-this.begin)/(this.end-this.begin);return this.property.interpolate(a.possiblyEvaluate(t,e,r),n,C1(s))}}},Mh=class{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,e,r){let i=new Na(this._properties);for(let n of Object.keys(this._values))i._values[n]=this._values[n].possiblyEvaluate(t,e,r);return i}hasTransition(){for(let t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}},Wm=class{constructor(t,e,r){this._properties=t,this._values=Object.create(t.defaultPropertyValues),this._globalState=r,this._rootKey=e}_propertyRootKey(t){return`${this._rootKey}.${String(t)}`}hasValue(t){return this._values[t].value!==void 0}hasProperty(t){return t in this._properties.defaultPropertyValues}getValue(t){return Xe(this._values[t].value)}setValue(t,e){this._values[t]=new $a(this._values[t].property,e===null?void 0:Xe(e),this._propertyRootKey(t),this._globalState)}serialize(){let t={};for(let e of Object.keys(this._values)){let r=this.getValue(e);r!==void 0&&(t[e]=r)}return t}possiblyEvaluate(t,e,r){let i=new Na(this._properties);for(let n of Object.keys(this._values))i._values[n]=this._values[n].possiblyEvaluate(t,e,r);return i}},ae=class{constructor(t,e,r){this.property=t,this.value=e,this.parameters=r}isConstant(){return this.value.kind==="constant"}constantOr(t){return this.value.kind==="constant"?this.value.value:t}evaluate(t,e,r,i){return this.property.evaluate(this.value,this.parameters,t,e,r,i)}},Na=class{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}};function Bh(t){if(Array.isArray(t))return t.length;let e=t?.values;return Array.isArray(e)?e.length:void 0}function Yf(t,e){let r=Bh(t),i=Bh(e);return r!==void 0&&i!==void 0&&r!==i}var z=class{constructor(t,e){this.specification=t,this.name=e}possiblyEvaluate(t,e){if(t.isDataDriven())throw Error("Value should not be data driven");return t.expression.evaluate(e)}interpolate(t,e,r){if(Yf(t,e))return Mt(`Property "${this.name}" is trying to interpolate arrays of different lengths. Rendering may \'jump\'.`),e;let i=this.specification.type,n=yr[i];return n?n(t,e,r):t}},U=class{constructor(t,e,r){this.specification=t,this.name=e,this.overrides=r}possiblyEvaluate(t,e,r,i){return t.expression.kind==="constant"||t.expression.kind==="camera"?new ae(this,{kind:"constant",value:t.expression.evaluate(e,null,{},r,i)},e):new ae(this,t.expression,e)}interpolate(t,e,r){if(t.value.kind!=="constant"||e.value.kind!=="constant")return t;if(t.value.value===void 0||e.value.value===void 0)return new ae(this,{kind:"constant",value:void 0},t.parameters);if(Yf(t.value.value,e.value.value))return Mt(`Property "${this.name}" is trying to interpolate arrays of different lengths. Rendering may \'jump\'.`),e;let i=this.specification.type,n=yr[i];if(n){let a=n(t.value.value,e.value.value,r);return new ae(this,{kind:"constant",value:a},t.parameters)}return t}evaluate(t,e,r,i,n,a){return t.kind==="constant"?t.value:t.evaluate(e,r,i,n,a)}},nn=class extends U{possiblyEvaluate(t,e,r,i){if(t.value===void 0)return new ae(this,{kind:"constant",value:void 0},e);if(t.expression.kind==="constant"){let n=t.expression.evaluate(e,null,{},r,i),a=t.property.specification.type==="resolvedImage"&&typeof n!="string"?n.name:n,s=this._calculate(a,a,a,e);return new ae(this,{kind:"constant",value:s},e)}if(t.expression.kind==="camera"){let n=this._calculate(t.expression.evaluate({zoom:e.zoom-1}),t.expression.evaluate({zoom:e.zoom}),t.expression.evaluate({zoom:e.zoom+1}),e);return new ae(this,{kind:"constant",value:n},e)}return new ae(this,t.expression,e)}evaluate(t,e,r,i,n,a){if(t.kind==="source"){let s=t.evaluate(e,r,i,n,a);return this._calculate(s,s,s,e)}return t.kind==="composite"?this._calculate(t.evaluate({zoom:Math.floor(e.zoom)-1},r,i),t.evaluate({zoom:Math.floor(e.zoom)},r,i),t.evaluate({zoom:Math.floor(e.zoom)+1},r,i),e):t.value}_calculate(t,e,r,i){return i.zoom>i.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:r,to:e}}interpolate(t){return t}},Xf=class{constructor(t,e){this.specification=t,this.name=e}possiblyEvaluate(t,e,r,i){if(t.value!==void 0){if(t.expression.kind==="constant"){let n=t.expression.evaluate(e,null,{},r,i);return this._calculate(n,n,n,e)}return this._calculate(t.expression.evaluate(new at(Math.floor(e.zoom-1),e)),t.expression.evaluate(new at(Math.floor(e.zoom),e)),t.expression.evaluate(new at(Math.floor(e.zoom+1),e)),e)}}_calculate(t,e,r,i){return i.zoom>i.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:r,to:e}}interpolate(t){return t}},Ua=class{constructor(t,e){this.specification=t,this.name=e}possiblyEvaluate(t,e,r,i){return!!t.expression.evaluate(e,null,{},r,i)}interpolate(){return!1}},jt=class{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(let e in t){let r=t[e];r.specification.overridable&&this.overridableProperties.push(e);let i=this.defaultPropertyValues[e]=new $a(r,void 0,r.name,void 0),n=this.defaultTransitionablePropertyValues[e]=new oo(r,r.name,void 0);this.defaultTransitioningPropertyValues[e]=n.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=i.possiblyEvaluate({})}}};I("DataDrivenProperty",U),I("DataConstantProperty",z),I("CrossFadedDataDrivenProperty",nn),I("CrossFadedProperty",Xf),I("ColorRampProperty",Ua);var Ph=" is a PAINT property not a LAYOUT property. Use get/setPaintProperty instead?",zs=" is a LAYOUT property not a PAINT property. Use get/setLayoutProperty instead?",pe=class extends j1{constructor(t,e,r){if(super(),this.id=t.id,this.type=t.type,this._globalState=r,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},this._visibilityExpression=Um(this.visibility,`layers[${this.id}].layout.visibility`,r),t.type!=="custom"&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,t.type!=="background"&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter,this._featureFilter=ii(t.filter,`layers[${this.id}].filter`,r)),e.layout&&(this._unevaluatedLayout=new Wm(e.layout,`layers[${this.id}].layout`,r)),e.paint)){this._transitionablePaint=new Xm(e.paint,`layers[${this.id}].paint`,r);for(let i in t.paint)this.setPaintProperty(i,t.paint[i],{validate:!1});for(let i in t.layout)this.setLayoutProperty(i,t.layout[i],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Na(e.paint)}}setFilter(t){this.filter=t,this._featureFilter=ii(t,`layers[${this.id}].filter`,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){if(t==="visibility")return this.visibility;if(this._transitionablePaint?.hasProperty(t))throw Error(t+Ph);if(!this._unevaluatedLayout)throw Error(`Cannot get layout property "${t}" on layer type "${this.type}" which has no layout properties.`);return this._unevaluatedLayout.getValue(t)}getLayoutAffectingGlobalStateRefs(){let t=new Set;for(let e of this._visibilityExpression.getGlobalStateRefs())t.add(e);if(this._unevaluatedLayout)for(let e in this._unevaluatedLayout._values){let r=this._unevaluatedLayout._values[e];for(let i of r.getGlobalStateRefs())t.add(i)}for(let e of this._featureFilter.getGlobalStateRefs())t.add(e);return t}getPaintAffectingGlobalStateRefs(){let t=new globalThis.Map;if(this._transitionablePaint)for(let e in this._transitionablePaint._values){let r=this._transitionablePaint._values[e].value;for(let i of r.getGlobalStateRefs()){let n=t.get(i)??[];n.push({name:e,value:r.value}),t.set(i,n)}}return t}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(t,e,r={}){if(t==="visibility"){this.visibility=e,this._visibilityExpression.setValue(e),this.recalculateVisibility();return}if(this._transitionablePaint?.hasProperty(t)){this.fire(new ha(Error(t+Ph)));return}e!=null&&this._validate(kh.layoutProperty,`layers.${this.id}.layout.${t}`,t,e,r)||this._unevaluatedLayout.setValue(t,e)}getPaintProperty(t){if(t.endsWith("-transition")){let e=t.slice(0,-11);if(e==="visibility"||this._unevaluatedLayout?.hasProperty(e))throw Error(t+zs);return this._transitionablePaint.getTransition(e)}if(t==="visibility"||this._unevaluatedLayout?.hasProperty(t))throw Error(t+zs);return this._transitionablePaint.getValue(t)}setPaintProperty(t,e,r={}){if(t==="visibility"||this._unevaluatedLayout?.hasProperty(t))return this.fire(new ha(Error(t+zs))),!1;if(e!=null&&this._validate(kh.paintProperty,`layers.${this.id}.paint.${t}`,t,e,r))return!1;if(t.endsWith("-transition"))return this._transitionablePaint.setTransition(t.slice(0,-11),e||void 0),!1;{let i=this._transitionablePaint._values[t],n=i.property.specification["property-type"]==="cross-faded-data-driven",a=i.value.isDataDriven(),s=i.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);let o=this._transitionablePaint._values[t].value;return o.isDataDriven()||a||n||this._handleOverridablePaintPropertyUpdate(t,s,o)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,e,r){return!1}isHidden(t=this.minzoom,e=!1){return this.minzoom&&t<(e?Math.floor(this.minzoom):this.minzoom)||this.maxzoom&&t>=this.maxzoom?!0:this._evaluatedVisibility==="none"}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculateVisibility(){this._evaluatedVisibility=this._visibilityExpression.evaluate()}recalculate(t,e){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e)}serialize(){let t={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?.serialize(),paint:this._transitionablePaint?.serialize()};return this.visibility&&(t.layout||(t.layout={}),t.layout.visibility=this.visibility),z1(t,(e,r)=>e!==void 0&&!(r==="layout"&&!Object.keys(e).length)&&!(r==="paint"&&!Object.keys(e).length))}_validate(t,e,r,i,n={}){return jm(this,t,{key:e,layerType:this.type,objectKey:r,value:i},n)}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(let t in this.paint._values){let e=this.paint.get(t);if(e instanceof ae&&ei(e.property.specification)&&(e.value.kind==="source"||e.value.kind==="composite")&&e.value.isStateDependent)return!0}return!1}},zh,Zm=()=>zh||(zh=new jt({"raster-opacity":new z(D.paint_raster["raster-opacity"],"raster-opacity"),"raster-hue-rotate":new z(D.paint_raster["raster-hue-rotate"],"raster-hue-rotate"),"raster-brightness-min":new z(D.paint_raster["raster-brightness-min"],"raster-brightness-min"),"raster-brightness-max":new z(D.paint_raster["raster-brightness-max"],"raster-brightness-max"),"raster-saturation":new z(D.paint_raster["raster-saturation"],"raster-saturation"),"raster-contrast":new z(D.paint_raster["raster-contrast"],"raster-contrast"),resampling:new z(D.paint_raster.resampling,"resampling"),"raster-resampling":new z(D.paint_raster["raster-resampling"],"raster-resampling"),"raster-fade-duration":new z(D.paint_raster["raster-fade-duration"],"raster-fade-duration")})),Hm={get paint(){return Zm()}};var Km=class extends pe{constructor(t,e){super(t,Hm,e)}},Jm={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array},gn=class{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}},xt=class{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){let e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(this.capacity*5),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);let e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}}_refreshViews(){throw Error("_refreshViews() must be implemented by each concrete StructArray layout")}freeBufferAfterUpload(){this.arrayBuffer=new ArrayBuffer(0),this._refreshViews()}};function St(t,e=1){let r=0,i=0;return{members:t.map(n=>{let a=Qm(n.type),s=r=Lh(r,Math.max(e,a)),o=n.components||1;return i=Math.max(i,a),r+=a*o,{name:n.name,type:n.type,components:o,offset:s}}),size:Lh(r,Math.max(i,e)),alignment:e}}function Qm(t){return Jm[t].BYTES_PER_ELEMENT}function Lh(t,e){return Math.ceil(t/e)*e}var an=class extends xt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e){let r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){let i=t*2;return this.int16[i+0]=e,this.int16[i+1]=r,t}};an.prototype.bytesPerElement=4,I("StructArrayLayout2i4",an);var lo=class extends xt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r){let i=this.length;return this.resize(i+1),this.emplace(i,t,e,r)}emplace(t,e,r,i){let n=t*3;return this.int16[n+0]=e,this.int16[n+1]=r,this.int16[n+2]=i,t}};lo.prototype.bytesPerElement=6,I("StructArrayLayout3i6",lo);var Vh=class extends xt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r,i){let n=this.length;return this.resize(n+1),this.emplace(n,t,e,r,i)}emplace(t,e,r,i,n){let a=t*4;return this.int16[a+0]=e,this.int16[a+1]=r,this.int16[a+2]=i,this.int16[a+3]=n,t}};Vh.prototype.bytesPerElement=8,I("StructArrayLayout4i8",Vh);var uo=class extends xt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r,i,n,a){let s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,i,n,a)}emplace(t,e,r,i,n,a,s){let o=t*6;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=i,this.int16[o+3]=n,this.int16[o+4]=a,this.int16[o+5]=s,t}};uo.prototype.bytesPerElement=12,I("StructArrayLayout2i4i12",uo);var ho=class extends xt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r,i,n,a){let s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,i,n,a)}emplace(t,e,r,i,n,a,s){let o=t*4,l=t*8;return this.int16[o+0]=e,this.int16[o+1]=r,this.uint8[l+4]=i,this.uint8[l+5]=n,this.uint8[l+6]=a,this.uint8[l+7]=s,t}};ho.prototype.bytesPerElement=8,I("StructArrayLayout2i4ub8",ho);var sn=class extends xt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e){let r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){let i=t*2;return this.float32[i+0]=e,this.float32[i+1]=r,t}};sn.prototype.bytesPerElement=8,I("StructArrayLayout2f8",sn);var co=class extends xt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,r,i,n,a,s,o,l,u){let h=this.length;return this.resize(h+1),this.emplace(h,t,e,r,i,n,a,s,o,l,u)}emplace(t,e,r,i,n,a,s,o,l,u,h){let c=t*10;return this.uint16[c+0]=e,this.uint16[c+1]=r,this.uint16[c+2]=i,this.uint16[c+3]=n,this.uint16[c+4]=a,this.uint16[c+5]=s,this.uint16[c+6]=o,this.uint16[c+7]=l,this.uint16[c+8]=u,this.uint16[c+9]=h,t}};co.prototype.bytesPerElement=20,I("StructArrayLayout10ui20",co);var po=class extends xt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,r,i,n,a,s,o){let l=this.length;return this.resize(l+1),this.emplace(l,t,e,r,i,n,a,s,o)}emplace(t,e,r,i,n,a,s,o,l){let u=t*8;return this.uint16[u+0]=e,this.uint16[u+1]=r,this.uint16[u+2]=i,this.uint16[u+3]=n,this.uint16[u+4]=a,this.uint16[u+5]=s,this.uint16[u+6]=o,this.uint16[u+7]=l,t}};po.prototype.bytesPerElement=16,I("StructArrayLayout8ui16",po);var fo=class extends xt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r,i,n,a,s,o,l,u,h,c,p){let f=this.length;return this.resize(f+1),this.emplace(f,t,e,r,i,n,a,s,o,l,u,h,c,p)}emplace(t,e,r,i,n,a,s,o,l,u,h,c,p,f){let d=t*14,y=t*7;return this.int16[d+0]=e,this.int16[d+1]=r,this.int16[d+2]=i,this.int16[d+3]=n,this.uint16[d+4]=a,this.uint16[d+5]=s,this.uint16[d+6]=o,this.uint16[d+7]=l,this.int16[d+8]=u,this.int16[d+9]=h,this.int16[d+10]=c,this.int16[d+11]=p,this.float32[y+6]=f,t}};fo.prototype.bytesPerElement=28,I("StructArrayLayout4i4ui4i1f28",fo);var yo=class extends xt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r){let i=this.length;return this.resize(i+1),this.emplace(i,t,e,r)}emplace(t,e,r,i){let n=t*3;return this.float32[n+0]=e,this.float32[n+1]=r,this.float32[n+2]=i,t}};yo.prototype.bytesPerElement=12,I("StructArrayLayout3f12",yo);var mo=class extends xt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){let e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){let r=t*1;return this.uint32[r+0]=e,t}};mo.prototype.bytesPerElement=4,I("StructArrayLayout1ul4",mo);var go=class extends xt{_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(t,e,r,i,n,a,s,o,l){let u=this.length;return this.resize(u+1),this.emplace(u,t,e,r,i,n,a,s,o,l)}emplace(t,e,r,i,n,a,s,o,l,u){let h=t*10,c=t*5;return this.int16[h+0]=e,this.int16[h+1]=r,this.int16[h+2]=i,this.int16[h+3]=n,this.int16[h+4]=a,this.int16[h+5]=s,this.uint32[c+3]=o,this.uint16[h+8]=l,this.uint16[h+9]=u,t}};go.prototype.bytesPerElement=20,I("StructArrayLayout6i1ul2ui20",go);var xo=class extends xt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r,i,n,a){let s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,i,n,a)}emplace(t,e,r,i,n,a,s){let o=t*6;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=i,this.int16[o+3]=n,this.int16[o+4]=a,this.int16[o+5]=s,t}};xo.prototype.bytesPerElement=12,I("StructArrayLayout2i2i2i12",xo);var Oh=class extends xt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r,i,n){let a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,i,n)}emplace(t,e,r,i,n,a){let s=t*4,o=t*8;return this.float32[s+0]=e,this.float32[s+1]=r,this.float32[s+2]=i,this.int16[o+6]=n,this.int16[o+7]=a,t}};Oh.prototype.bytesPerElement=16,I("StructArrayLayout2f1f2i16",Oh);var vo=class extends xt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r,i,n,a){let s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,i,n,a)}emplace(t,e,r,i,n,a,s){let o=t*16,l=t*4,u=t*8;return this.uint8[o+0]=e,this.uint8[o+1]=r,this.float32[l+1]=i,this.float32[l+2]=n,this.int16[u+6]=a,this.int16[u+7]=s,t}};vo.prototype.bytesPerElement=16,I("StructArrayLayout2ub2f2i16",vo);var bo=class extends xt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,r){let i=this.length;return this.resize(i+1),this.emplace(i,t,e,r)}emplace(t,e,r,i){let n=t*3;return this.uint16[n+0]=e,this.uint16[n+1]=r,this.uint16[n+2]=i,t}};bo.prototype.bytesPerElement=6,I("StructArrayLayout3ui6",bo);var wo=class extends xt{_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(t,e,r,i,n,a,s,o,l,u,h,c,p,f,d,y,m,g){let x=this.length;return this.resize(x+1),this.emplace(x,t,e,r,i,n,a,s,o,l,u,h,c,p,f,d,y,m,g)}emplace(t,e,r,i,n,a,s,o,l,u,h,c,p,f,d,y,m,g,x){let b=t*26,v=t*13,w=t*52;return this.int16[b+0]=e,this.int16[b+1]=r,this.uint16[b+2]=i,this.uint16[b+3]=n,this.uint32[v+2]=a,this.uint32[v+3]=s,this.uint32[v+4]=o,this.uint16[b+10]=l,this.uint16[b+11]=u,this.uint16[b+12]=h,this.float32[v+7]=c,this.float32[v+8]=p,this.uint8[w+36]=f,this.uint8[w+37]=d,this.uint8[w+38]=y,this.uint32[v+10]=m,this.int16[b+22]=g,this.float32[v+12]=x,t}};wo.prototype.bytesPerElement=52,I("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i1f52",wo);var Do=class extends xt{_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(t,e,r,i,n,a,s,o,l,u,h,c,p,f,d,y,m,g,x,b,v,w,_,A,S,F,L,V,P){let R=this.length;return this.resize(R+1),this.emplace(R,t,e,r,i,n,a,s,o,l,u,h,c,p,f,d,y,m,g,x,b,v,w,_,A,S,F,L,V,P)}emplace(t,e,r,i,n,a,s,o,l,u,h,c,p,f,d,y,m,g,x,b,v,w,_,A,S,F,L,V,P,R){let E=t*34,$=t*17;return this.int16[E+0]=e,this.int16[E+1]=r,this.int16[E+2]=i,this.int16[E+3]=n,this.int16[E+4]=a,this.int16[E+5]=s,this.int16[E+6]=o,this.int16[E+7]=l,this.uint16[E+8]=u,this.uint16[E+9]=h,this.uint16[E+10]=c,this.uint16[E+11]=p,this.uint16[E+12]=f,this.uint16[E+13]=d,this.uint16[E+14]=y,this.uint16[E+15]=m,this.uint16[E+16]=g,this.uint16[E+17]=x,this.uint16[E+18]=b,this.uint16[E+19]=v,this.uint16[E+20]=w,this.uint16[E+21]=_,this.uint16[E+22]=A,this.uint32[$+12]=S,this.float32[$+13]=F,this.float32[$+14]=L,this.uint16[E+30]=V,this.uint16[E+31]=P,this.float32[$+16]=R,t}};Do.prototype.bytesPerElement=68,I("StructArrayLayout8i15ui1ul2f2ui1f68",Do);var ga=class extends xt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){let e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){let r=t*1;return this.float32[r+0]=e,t}};ga.prototype.bytesPerElement=4,I("StructArrayLayout1f4",ga);var _o=class extends xt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r){let i=this.length;return this.resize(i+1),this.emplace(i,t,e,r)}emplace(t,e,r,i){let n=t*6,a=t*3;return this.uint16[n+0]=e,this.float32[a+1]=r,this.float32[a+2]=i,t}};_o.prototype.bytesPerElement=12,I("StructArrayLayout1ui2f12",_o);var Ao=class extends xt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,r){let i=this.length;return this.resize(i+1),this.emplace(i,t,e,r)}emplace(t,e,r,i){let n=t*2,a=t*4;return this.uint32[n+0]=e,this.uint16[a+2]=r,this.uint16[a+3]=i,t}};Ao.prototype.bytesPerElement=8,I("StructArrayLayout1ul2ui8",Ao);var So=class extends xt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e){let r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){let i=t*2;return this.uint16[i+0]=e,this.uint16[i+1]=r,t}};So.prototype.bytesPerElement=4,I("StructArrayLayout2ui4",So);var Rh=class extends xt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){let e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){let r=t*1;return this.uint16[r+0]=e,t}};Rh.prototype.bytesPerElement=2,I("StructArrayLayout1ui2",Rh);var Eo=class extends xt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r,i){let n=this.length;return this.resize(n+1),this.emplace(n,t,e,r,i)}emplace(t,e,r,i,n){let a=t*4;return this.float32[a+0]=e,this.float32[a+1]=r,this.float32[a+2]=i,this.float32[a+3]=n,t}};Eo.prototype.bytesPerElement=16,I("StructArrayLayout4f16",Eo);var Wf=class extends gn{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 B(this.anchorPointX,this.anchorPointY)}};Wf.prototype.size=20;var Bl=class extends go{get(t){return new Wf(this,t)}};I("CollisionBoxArray",Bl);var Zf=class extends gn{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(t){this._structArray.uint8[this._pos1+37]=t}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(t){this._structArray.uint8[this._pos1+38]=t}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(t){this._structArray.uint32[this._pos4+10]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}get heightOffset(){return this._structArray.float32[this._pos4+12]}};Zf.prototype.size=52;var Hf=class extends wo{get(t){return new Zf(this,t)}};I("PlacedSymbolArray",Hf);var Kf=class extends gn{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(t){this._structArray.uint32[this._pos4+12]=t}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 heightOffset(){return this._structArray.float32[this._pos4+16]}};Kf.prototype.size=68;var Jf=class extends Do{get(t){return new Kf(this,t)}};I("SymbolInstanceArray",Jf);var Qf=class extends ga{getoffsetX(t){return this.float32[t*1+0]}};I("GlyphOffsetArray",Qf);var td=class extends lo{getx(t){return this.int16[t*3+0]}gety(t){return this.int16[t*3+1]}gettileUnitDistanceFromAnchor(t){return this.int16[t*3+2]}};I("SymbolLineVertexArray",td);var ed=class extends gn{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]}};ed.prototype.size=12;var rd=class extends _o{get(t){return new ed(this,t)}};I("TextAnchorOffsetArray",rd);var id=class extends gn{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]}};id.prototype.size=8;var nd=class extends Ao{get(t){return new id(this,t)}};I("FeatureIndexArray",nd);var tg=class extends an{};var eg=class extends an{},rg=class extends an{},ig=class extends uo{},ng=class extends ho{},ag=class extends sn{},zr=class extends co{},$h=class extends po{},sg=class extends fo{},og=class extends yo{},lg=class extends mo{},Nh=class extends xo{};var ug=class extends vo{};var xn=class extends bo{},Fo=class extends So{};var To=St([{name:"a_pos",components:2,type:"Int16"}],4),hg=To.members;To.size,To.alignment;var te=class $r{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(e,r,i,n){let a=this.segments[this.segments.length-1];return e>$r.MAX_VERTEX_ARRAY_LENGTH&&Mt(`Max vertices per segment is ${$r.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}. Consider using the \\`fillLargeMeshArrays\\` function if you require meshes with more than ${$r.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!a||a.vertexLength+e>$r.MAX_VERTEX_ARRAY_LENGTH||a.sortKey!==n?this.createNewSegment(r,i,n):a}createNewSegment(e,r,i){let n={vertexOffset:e.length,primitiveOffset:r.length,vertexLength:0,primitiveLength:0,vaos:{}};return i!==void 0&&(n.sortKey=i),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(n),n}getOrCreateLatestSegment(e,r,i){return this.prepareSegment(0,e,r,i)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(let e of this.segments)for(let r in e.vaos)e.vaos[r].destroy()}static simpleSegment(e,r,i,n){return new $r([{vertexOffset:e,primitiveOffset:r,vertexLength:i,primitiveLength:n,vaos:{},sortKey:0}])}};te.MAX_VERTEX_ARRAY_LENGTH=2**16-1,I("SegmentVector",te);function Uh(t,e){return t=Zi(Math.floor(t),0,255),e=Zi(Math.floor(e),0,255),256*t+e}var cg=St([{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"}]),pg=St([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]),fg=hl(((t,e)=>{function r(i,n){for(var a=i.length&3,s=i.length-a,o=n,l,u=3432918353,h=461845907,c,p=0;p<s;)c=i.charCodeAt(p)&255|(i.charCodeAt(++p)&255)<<8|(i.charCodeAt(++p)&255)<<16|(i.charCodeAt(++p)&255)<<24,++p,c=(c&65535)*u+(((c>>>16)*u&65535)<<16)&4294967295,c=c<<15|c>>>17,c=(c&65535)*h+(((c>>>16)*h&65535)<<16)&4294967295,o^=c,o=o<<13|o>>>19,l=(o&65535)*5+(((o>>>16)*5&65535)<<16)&4294967295,o=(l&65535)+27492+(((l>>>16)+58964&65535)<<16);switch(c=0,a){case 3:c^=(i.charCodeAt(p+2)&255)<<16;case 2:c^=(i.charCodeAt(p+1)&255)<<8;case 1:c^=i.charCodeAt(p)&255,c=(c&65535)*u+(((c>>>16)*u&65535)<<16)&4294967295,c=c<<15|c>>>17,c=(c&65535)*h+(((c>>>16)*h&65535)<<16)&4294967295,o^=c}return o^=i.length,o^=o>>>16,o=(o&65535)*2246822507+(((o>>>16)*2246822507&65535)<<16)&4294967295,o^=o>>>13,o=(o&65535)*3266489909+(((o>>>16)*3266489909&65535)<<16)&4294967295,o^=o>>>16,o>>>0}e!==void 0&&(e.exports=r)})),dg=hl(((t,e)=>{function r(i,n){for(var a=i.length,s=n^a,o=0,l;a>=4;)l=i.charCodeAt(o)&255|(i.charCodeAt(++o)&255)<<8|(i.charCodeAt(++o)&255)<<16|(i.charCodeAt(++o)&255)<<24,l=(l&65535)*1540483477+(((l>>>16)*1540483477&65535)<<16),l^=l>>>24,l=(l&65535)*1540483477+(((l>>>16)*1540483477&65535)<<16),s=(s&65535)*1540483477+(((s>>>16)*1540483477&65535)<<16)^l,a-=4,++o;switch(a){case 3:s^=(i.charCodeAt(o+2)&255)<<16;case 2:s^=(i.charCodeAt(o+1)&255)<<8;case 1:s^=i.charCodeAt(o)&255,s=(s&65535)*1540483477+(((s>>>16)*1540483477&65535)<<16)}return s^=s>>>13,s=(s&65535)*1540483477+(((s>>>16)*1540483477&65535)<<16),s^=s>>>15,s>>>0}e.exports=r})),ko=m1(hl(((t,e)=>{var r=fg(),i=dg();e.exports=r,e.exports.murmur3=r,e.exports.murmur2=i}))(),1),ad=class sd{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,r,i,n){this.ids.push(qh(e)),this.positions.push(r,i,n)}getPositions(e){if(!this.indexed)throw Error("Trying to get index, but feature positions are not indexed");let r=qh(e),i=0,n=this.ids.length-1;for(;i<n;){let s=i+n>>1;this.ids[s]>=r?n=s:i=s+1}let a=[];for(;this.ids[i]===r;){let s=this.positions[3*i],o=this.positions[3*i+1],l=this.positions[3*i+2];a.push({index:s,start:o,end:l}),i++}return a}static serialize(e,r){let i=new Float64Array(e.ids),n=new Uint32Array(e.positions);return Io(i,n,0,i.length-1),r&&r.push(i.buffer,n.buffer),{ids:i,positions:n}}static deserialize(e){let r=new sd;return r.ids=e.ids,r.positions=e.positions,r.indexed=!0,r}};function qh(t){let e=+t;return!isNaN(e)&&e<=2**53-1?e:(0,ko.default)(String(t))}function Io(t,e,r,i){for(;r<i;){let n=t[r+i>>1],a=r-1,s=i+1;for(;;){do a++;while(t[a]<n);do s--;while(t[s]>n);if(a>=s)break;qn(t,a,s),qn(e,3*a,3*s),qn(e,3*a+1,3*s+1),qn(e,3*a+2,3*s+2)}s-r<i-s?(Io(t,e,r,s),r=s+1):(Io(t,e,s+1,i),i=s)}}function qn(t,e,r){let i=t[e];t[e]=t[r],t[r]=i}I("FeaturePositionMap",ad);var Pl=class{constructor(t,e){this.gl=t.gl,this.location=e}};var zl=class extends Pl{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1f(this.location,t))}};var yg=class extends Pl{constructor(t,e){super(t,e),this.current=[0,0,0,0]}set(t){(t[0]!==this.current[0]||t[1]!==this.current[1]||t[2]!==this.current[2]||t[3]!==this.current[3])&&(this.current=t,this.gl.uniform4f(this.location,t[0],t[1],t[2],t[3]))}},mg=class extends Pl{constructor(t,e){super(t,e),this.current=gt.transparent}set(t){(t.r!==this.current.r||t.g!==this.current.g||t.b!==this.current.b||t.a!==this.current.a)&&(this.current=t,this.gl.uniform4f(this.location,t.r,t.g,t.b,t.a))}};var a5=new Float32Array(16);function Co(t){return[Uh(255*t.r,255*t.g),Uh(255*t.b,255*t.a)]}var Vi=class{constructor(t,e,r){this.value=t,this.uniformNames=e.map(i=>`u_${i}`),this.type=r}setUniform(t,e,r){t.set(r.constantOr(this.value))}getBinding(t,e,r){return this.type==="color"?new mg(t,e):new zl(t,e)}},lr=class{constructor(t,e){this.uniformNames=e.map(r=>`u_${r}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,e){this.pixelRatioFrom=e.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=e.tlbr,this.patternTo=t.tlbr}setConstantDashPositions(t,e){this.dashTo=[0,t.y,t.height,t.width],this.dashFrom=[0,e.y,e.height,e.width]}setUniform(t,e,r,i){let n=null;i==="u_pattern_to"?n=this.patternTo:i==="u_pattern_from"?n=this.patternFrom:i==="u_dasharray_to"?n=this.dashTo:i==="u_dasharray_from"?n=this.dashFrom:i==="u_pixel_ratio_to"?n=this.pixelRatioTo:i==="u_pixel_ratio_from"&&(n=this.pixelRatioFrom),n!==null&&t.set(n)}getBinding(t,e,r){return r.startsWith("u_pattern")||r.startsWith("u_dasharray_")?new yg(t,e):new zl(t,e)}},Te=class{constructor(t,e,r,i){this.expression=t,this.type=r,this.maxValue=0,this.paintVertexAttributes=e.map(n=>({name:`a_${n}`,type:"Float32",components:r==="color"?2:1,offset:0})),this.paintVertexArray=new i}populatePaintArray(t,e,r){let i=this.paintVertexArray.length,n=this.expression.evaluate(new at(0,r),e,{},r.canonical,[],r.formattedSection);this.paintVertexArray.resize(t),this._setPaintValue(i,t,n)}updatePaintArray(t,e,r,i,n){let a=this.expression.evaluate(new at(0,n),r,i);this._setPaintValue(t,e,a)}_setPaintValue(t,e,r){if(this.type==="color"){let i=Co(r);for(let n=t;n<e;n++)this.paintVertexArray.emplace(n,i[0],i[1])}else{for(let i=t;i<e;i++)this.paintVertexArray.emplace(i,r);this.maxValue=Math.max(this.maxValue,Math.abs(r))}}upload(t){this.paintVertexArray?.arrayBuffer.byteLength&&(this.paintVertexBuffer?.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}},le=class{constructor(t,e,r,i,n,a){this.expression=t,this.uniformNames=e.map(s=>`u_${s}_t`),this.type=r,this.useIntegerZoom=i,this.zoom=n,this.maxValue=0,this.paintVertexAttributes=e.map(s=>({name:`a_${s}`,type:"Float32",components:r==="color"?4:2,offset:0})),this.paintVertexArray=new a}populatePaintArray(t,e,r){let i=this.expression.evaluate(new at(this.zoom,r),e,{},r.canonical,[],r.formattedSection),n=this.expression.evaluate(new at(this.zoom+1,r),e,{},r.canonical,[],r.formattedSection),a=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(a,t,i,n)}updatePaintArray(t,e,r,i,n){let a=this.expression.evaluate(new at(this.zoom,n),r,i),s=this.expression.evaluate(new at(this.zoom+1,n),r,i);this._setPaintValue(t,e,a,s)}_setPaintValue(t,e,r,i){if(this.type==="color"){let n=Co(r),a=Co(i);for(let s=t;s<e;s++)this.paintVertexArray.emplace(s,n[0],n[1],a[0],a[1])}else{for(let n=t;n<e;n++)this.paintVertexArray.emplace(n,r,i);this.maxValue=Math.max(this.maxValue,Math.abs(r),Math.abs(i))}}upload(t){this.paintVertexArray?.arrayBuffer.byteLength&&(this.paintVertexBuffer?.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(t,e){let r=this.useIntegerZoom?Math.floor(e.zoom):e.zoom,i=Zi(this.expression.interpolationFactor(r,this.zoom,this.zoom+1),0,1);t.set(i)}getBinding(t,e,r){return new zl(t,e)}},je=class{constructor(t,e,r,i,n,a){this.expression=t,this.type=e,this.useIntegerZoom=r,this.zoom=i,this.layerId=a,this.zoomInPaintVertexArray=new n,this.zoomOutPaintVertexArray=new n}populatePaintArray(t,e,r){let i=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(t),this.zoomOutPaintVertexArray.resize(t),this._setPaintValues(i,t,this.getPositionIds(e),r)}updatePaintArray(t,e,r,i,n){this._setPaintValues(t,e,this.getPositionIds(r),n)}_setPaintValues(t,e,r,i){let n=this.getPositions(i);if(!n||!r)return;let a=n[r.min],s=n[r.mid],o=n[r.max];if(a&&s&&o)for(let l=t;l<e;l++)this.emplace(this.zoomInPaintVertexArray,l,a,s),this.emplace(this.zoomOutPaintVertexArray,l,o,s)}upload(t){if(this.zoomInPaintVertexArray?.arrayBuffer.byteLength&&this.zoomOutPaintVertexArray?.arrayBuffer.byteLength){let e=this.getVertexAttributes();this.zoomInPaintVertexBuffer=t.createVertexBuffer(this.zoomInPaintVertexArray,e,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=t.createVertexBuffer(this.zoomOutPaintVertexArray,e,this.expression.isStateDependent)}}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}},od=class extends je{getPositions(t){return t.imagePositions}getPositionIds(t){return t.patterns?.[this.layerId]}getVertexAttributes(){return cg.members}emplace(t,e,r,i){t.emplace(e,r.tlbr[0],r.tlbr[1],r.tlbr[2],r.tlbr[3],i.tlbr[0],i.tlbr[1],i.tlbr[2],i.tlbr[3],r.pixelRatio,i.pixelRatio)}},ld=class extends je{getPositions(t){return t.dashPositions}getPositionIds(t){return t.dashes?.[this.layerId]}getVertexAttributes(){return pg.members}emplace(t,e,r,i){t.emplace(e,0,r.y,r.height,r.width,0,i.y,i.height,i.width)}},ud=class{constructor(t,e,r){this.binders={},this._buffers=[];let i=[];for(let n in t.paint._values){if(!r(n))continue;let a=t.paint.get(n);if(!(a instanceof ae)||!ei(a.property.specification))continue;let s=gg(n,t.type),o=a.value,l=a.property.specification.type,u=a.property.useIntegerZoom,h=a.property.specification["property-type"],c=h==="cross-faded"||h==="cross-faded-data-driven";if(o.kind==="constant")this.binders[n]=c?new lr(o.value,s):new Vi(o.value,s,l),i.push(`/u_${n}`);else if(o.kind==="source"||c){let p=jh(n,l,"source");this.binders[n]=c?n==="line-dasharray"?new ld(o,l,u,e,p,t.id):new od(o,l,u,e,p,t.id):new Te(o,s,l,p),i.push(`/a_${n}`)}else{let p=jh(n,l,"composite");this.binders[n]=new le(o,s,l,u,e,p),i.push(`/z_${n}`)}}this.cacheKey=i.sort().join("")}getMaxValue(t){let e=this.binders[t];return e instanceof Te||e instanceof le?e.maxValue:0}populatePaintArrays(t,e,r){for(let i in this.binders){let n=this.binders[i];(n instanceof Te||n instanceof le||n instanceof je)&&n.populatePaintArray(t,e,r)}}setConstantPatternPositions(t,e){for(let r in this.binders){let i=this.binders[r];i instanceof lr&&i.setConstantPatternPositions(t,e)}}setConstantDashPositions(t,e){for(let r in this.binders){let i=this.binders[r];i instanceof lr&&i.setConstantDashPositions(t,e)}}updatePaintArrays(t,e,r,i,n){let a=!1;for(let s of t){let o=e.getPositions(s.id);for(let l of o){let u=r.feature(l.index);for(let h in this.binders){let c=this.binders[h];(c instanceof Te||c instanceof le||c instanceof je)&&c.expression.isStateDependent===!0&&(c.expression=i.paint.get(h).value,c.updatePaintArray(l.start,l.end,u,s.state,n),a=!0)}}}return a}defines(){let t=[];for(let e in this.binders){let r=this.binders[e];(r instanceof Vi||r instanceof lr)&&t.push(...r.uniformNames.map(i=>`#define HAS_UNIFORM_${i}`))}return t}getBinderAttributes(){let t=[];for(let e in this.binders){let r=this.binders[e];if(r instanceof Te||r instanceof le)for(let i of r.paintVertexAttributes)t.push(i.name);else if(r instanceof je){let i=r.getVertexAttributes();for(let n of i)t.push(n.name)}}return t}getBinderUniforms(){let t=[];for(let e in this.binders){let r=this.binders[e];if(r instanceof Vi||r instanceof lr||r instanceof le)for(let i of r.uniformNames)t.push(i)}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t,e){let r=[];for(let i in this.binders){let n=this.binders[i];if(n instanceof Vi||n instanceof lr||n instanceof le){for(let a of n.uniformNames)if(e[a]){let s=n.getBinding(t,e[a],a);r.push({name:a,property:i,binding:s})}}}return r}setUniforms(t,e,r,i){for(let{name:n,property:a,binding:s}of e)this.binders[a].setUniform(s,i,r.get(a),n)}updatePaintBuffers(t){this._buffers=[];for(let e in this.binders){let r=this.binders[e];if(t&&r instanceof je){let i=t.fromScale===2?r.zoomInPaintVertexBuffer:r.zoomOutPaintVertexBuffer;i&&this._buffers.push(i)}else(r instanceof Te||r instanceof le)&&r.paintVertexBuffer&&this._buffers.push(r.paintVertexBuffer)}}upload(t){for(let e in this.binders){let r=this.binders[e];(r instanceof Te||r instanceof le||r instanceof je)&&r.upload(t)}this.updatePaintBuffers()}destroy(){for(let t in this.binders){let e=this.binders[t];(e instanceof Te||e instanceof le||e instanceof je)&&e.destroy()}}},gr=class{constructor(t,e,r=()=>!0){this.programConfigurations={};for(let i of t)this.programConfigurations[i.id]=new ud(i,e,r);this.needsUpload=!1,this._featureMap=new ad,this._bufferOffset=0}populatePaintArrays(t,e,r,i){for(let n in this.programConfigurations)this.programConfigurations[n].populatePaintArrays(t,e,i);e.id!==void 0&&this._featureMap.add(e.id,r,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,r,i){for(let n of r)this.needsUpload=this.programConfigurations[n.id].updatePaintArrays(t,this._featureMap,e,n,i)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(let e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1}}destroy(){for(let t in this.programConfigurations)this.programConfigurations[t].destroy()}};function gg(t,e){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-dasharray":["dasharray_to","dasharray_from"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}function xg(t){return{"line-pattern":{source:zr,composite:zr},"fill-pattern":{source:zr,composite:zr},"fill-extrusion-pattern":{source:zr,composite:zr},"line-dasharray":{source:$h,composite:$h}}[t]}function jh(t,e,r){let i={color:{source:sn,composite:Eo},number:{source:ga,composite:sn}};return xg(t)?.[r]||i[e][r]}I("ConstantBinder",Vi),I("CrossFadedConstantBinder",lr),I("SourceExpressionBinder",Te),I("CrossFadedPatternBinder",od),I("CrossFadedDasharrayBinder",ld),I("CompositeExpressionBinder",le),I("ProgramConfiguration",ud,{omit:["_buffers"]}),I("ProgramConfigurationSet",gr);var Mo=2**14-1,Gh=-Mo-1;function Dr(t){let e=mt/t.extent,r=t.loadGeometry();for(let i of r)for(let n of i){let a=Math.round(n.x*e),s=Math.round(n.y*e);n.x=Zi(a,Gh,Mo),n.y=Zi(s,Gh,Mo),(a<n.x||a>n.x+1||s<n.y||s>n.y+1)&&Mt("Geometry exceeds allowed extent, reduce your vector tile buffer size")}return r}function li(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?Dr(t):[]}}var Yh=-32768;function vg(t,e,r,i,n){t.emplaceBack(Yh+e*8+i,Yh+r*8+n)}var Ll=class{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(e=>e.id),this.index=t.index,this.hasDependencies=!1,this.layoutVertexArray=new eg,this.indexArray=new xn,this.segments=new te,this.programConfigurations=new gr(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(t,e,r){let i=this.layers[0],n=[],a=null,s=!1,o=i.type==="heatmap";if(i.type==="circle"){let c=i;a=c.layout.get("circle-sort-key"),s=!a.isConstant(),o||(o=c.paint.get("circle-pitch-alignment")==="map")}let l=o?e.subdivisionGranularity.circle:1,u=new at(this.zoom),h=this.layers[0]._featureFilter.needGeometry;for(let{feature:c,id:p,index:f,sourceLayerIndex:d}of t){let y=li(c,h);if(!this.layers[0]._featureFilter.filter(u,y,r))continue;let m=s?a.evaluate(y,{},r):void 0,g={id:p,properties:c.properties,type:c.type,sourceLayerIndex:d,index:f,geometry:h?y.geometry:Dr(c),patterns:{},sortKey:m};n.push(g)}s&&n.sort((c,p)=>c.sortKey-p.sortKey);for(let c of n){let{geometry:p,index:f,sourceLayerIndex:d}=c,y=t[f].feature;this.addFeature(c,p,f,r,l),e.featureIndex.insert(y,p,f,d,this.index)}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,{imagePositions:r})}addFeatures(t){}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,hg),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,r,i,n=1){let a;switch(n){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: ${n}; valid values are 1, 3, 5, 7.`)}let s=a.length;for(let o of e)for(let l of o){let u=l.x,h=l.y;if(u<0||u>=8192||h<0||h>=8192)continue;let c=this.segments.prepareSegment(s*s,this.layoutVertexArray,this.indexArray,t.sortKey),p=c.vertexLength;for(let f=0;f<s;f++)for(let d=0;d<s;d++)vg(this.layoutVertexArray,u,h,a[d],a[f]);for(let f=0;f<s-1;f++)for(let d=0;d<s-1;d++){let y=p+f*s+d,m=p+(f+1)*s+d;this.indexArray.emplaceBack(y,m+1,y+1),this.indexArray.emplaceBack(y,m,m+1)}c.vertexLength+=s*s,c.primitiveLength+=(s-1)*(s-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,{imagePositions:{},canonical:i})}};I("CircleBucket",Ll,{omit:["layers"]});function bg(t,e){for(let r of t)if(ai(e,r))return!0;for(let r of e)if(ai(t,r))return!0;return Vl(t,e)}function qa(t,e,r){return ai(t,e)?!0:Bo(e,t,r)}function hd(t,e){if(t.length===1)return Xh(e,t[0]);for(let r of e)for(let i of r)if(ai(t,i))return!0;for(let r of t)if(Xh(e,r))return!0;for(let r of e)if(Vl(t,r))return!0;return!1}function wg(t,e,r){for(let i of e){if(t.length>=3){for(let n of i)if(ai(t,n))return!0}if(Dg(t,i,r))return!0}return!1}function Dg(t,e,r){if(t.length>1){if(Vl(t,e))return!0;for(let i of e)if(Bo(i,t,r))return!0}for(let i of t)if(Bo(i,e,r))return!0;return!1}function Vl(t,e){if(t.length===0||e.length===0)return!1;for(let r=0;r<t.length-1;r++){let i=t[r],n=t[r+1];for(let a=0;a<e.length-1;a++){let s=e[a],o=e[a+1];if(_g(i,n,s,o))return!0}}return!1}function _g(t,e,r,i){return We(t,r,i)!==We(e,r,i)&&We(t,e,r)!==We(t,e,i)}function Bo(t,e,r){let i=r*r;if(e.length===1)return t.distSqr(e[0])<i;for(let n=1;n<e.length;n++){let a=e[n-1],s=e[n];if(cd(t,a,s)<i)return!0}return!1}function cd(t,e,r){let i=e.distSqr(r);if(i===0)return t.distSqr(e);let n=((t.x-e.x)*(r.x-e.x)+(t.y-e.y)*(r.y-e.y))/i;return n<0?t.distSqr(e):n>1?t.distSqr(r):t.distSqr(r.sub(e)._mult(n)._add(e))}function Xh(t,e){let r=!1,i,n,a;for(let s of t){i=s;for(let o=0,l=i.length-1;o<i.length;l=o++)n=i[o],a=i[l],n.y>e.y!=a.y>e.y&&e.x<(a.x-n.x)*(e.y-n.y)/(a.y-n.y)+n.x&&(r=!r)}return r}function ai(t,e){let r=!1;for(let i=0,n=t.length-1;i<t.length;n=i++){let a=t[i],s=t[n];a.y>e.y!=s.y>e.y&&e.x<(s.x-a.x)*(e.y-a.y)/(s.y-a.y)+a.x&&(r=!r)}return r}function Ag(t,e,r,i,n){for(let s of t)if(e<=s.x&&r<=s.y&&i>=s.x&&n>=s.y)return!0;let a=[new B(e,r),new B(e,n),new B(i,n),new B(i,r)];if(t.length>2){for(let s of a)if(ai(t,s))return!0}for(let s=0;s<t.length-1;s++){let o=t[s],l=t[s+1];if(Sg(o,l,a))return!0}return!1}function Sg(t,e,r){let i=r[0],n=r[2];if(t.x<i.x&&e.x<i.x||t.x>n.x&&e.x>n.x||t.y<i.y&&e.y<i.y||t.y>n.y&&e.y>n.y)return!1;let a=We(t,e,r[0]);return a!==We(t,e,r[1])||a!==We(t,e,r[2])||a!==We(t,e,r[3])}function Yr(t,e,r){let i=e.paint.get(t).value;return i.kind==="constant"?i.value:r.programConfigurations.get(e.id).getMaxValue(t)}function ja(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Ga(t,e,r,i,n){if(!e[0]&&!e[1])return t;let a=B.convert(e)._mult(n);r==="viewport"&&a._rotate(-i);let s=[];for(let o of t)s.push(o.sub(a));return s}function Eg(t){let e=[];for(let r=0;r<t.length;r++){let i=t[r],n=e.at(-1);(r===0||n&&!i.equals(n))&&e.push(i)}return e}function Fg(t,e){let r=[];for(let i of t){let n=Eg(i),a=[];for(let s=0;s<n.length;s++){let o=n[s],l=n[s-1],u=n[s+1],h=s===0?new B(0,0):o.sub(l)._unit()._perp(),c=s===n.length-1?new B(0,0):u.sub(o)._unit()._perp(),p=h._add(c)._unit(),f=p.x*c.x+p.y*c.y;f!==0&&p._mult(1/f),a.push(p._mult(e)._add(o))}r.push(a)}return r}function Tg({queryGeometry:t,size:e},r){return qa(t,r,e)}function kg({queryGeometry:t,size:e,transform:r,unwrappedTileID:i,getElevation:n},a){return qa(t,a,e*(r.projectTileCoordinates(a.x,a.y,i,n?.(a.x,a.y)).signedDistanceFromCamera/r.cameraToCenterDistance))}function Ig({queryGeometry:t,size:e,transform:r,unwrappedTileID:i,getElevation:n},a){let s=r.projectTileCoordinates(a.x,a.y,i,n?.(a.x,a.y)).signedDistanceFromCamera,o=e*(r.cameraToCenterDistance/s);return qa(t,Ol(a,r,i,n),o)}function Cg({queryGeometry:t,size:e,transform:r,unwrappedTileID:i,getElevation:n},a){return qa(t,Ol(a,r,i,n),e)}function pd({queryGeometry:t,size:e,transform:r,unwrappedTileID:i,getElevation:n,pitchAlignment:a="map",pitchScale:s="map"},o){let l=a==="map"?s==="map"?Tg:kg:s==="map"?Ig:Cg,u={queryGeometry:t,size:e,transform:r,unwrappedTileID:i,getElevation:n};for(let h of o)for(let c of h)if(l(u,c))return!0;return!1}function Ol(t,e,r,i){let n=e.projectTileCoordinates(t.x,t.y,r,i?.(t.x,t.y)).point;return new B((n.x*.5+.5)*e.width,(-n.y*.5+.5)*e.height)}function Mg(t,e,r,i){return t.map(n=>Ol(n,e,r,i))}var Wh,Bg=()=>Wh||(Wh=new jt({"circle-sort-key":new U(D.layout_circle["circle-sort-key"],"circle-sort-key")})),Zh,Pg=()=>Zh||(Zh=new jt({"circle-radius":new U(D.paint_circle["circle-radius"],"circle-radius"),"circle-color":new U(D.paint_circle["circle-color"],"circle-color"),"circle-blur":new U(D.paint_circle["circle-blur"],"circle-blur"),"circle-opacity":new U(D.paint_circle["circle-opacity"],"circle-opacity"),"circle-translate":new z(D.paint_circle["circle-translate"],"circle-translate"),"circle-translate-anchor":new z(D.paint_circle["circle-translate-anchor"],"circle-translate-anchor"),"circle-pitch-scale":new z(D.paint_circle["circle-pitch-scale"],"circle-pitch-scale"),"circle-pitch-alignment":new z(D.paint_circle["circle-pitch-alignment"],"circle-pitch-alignment"),"circle-stroke-width":new U(D.paint_circle["circle-stroke-width"],"circle-stroke-width"),"circle-stroke-color":new U(D.paint_circle["circle-stroke-color"],"circle-stroke-color"),"circle-stroke-opacity":new U(D.paint_circle["circle-stroke-opacity"],"circle-stroke-opacity")})),zg={get paint(){return Pg()},get layout(){return Bg()}};var Lg=class extends pe{constructor(t,e){super(t,zg,e)}createBucket(t){return new Ll(t)}queryRadius(t){let e=t;return Yr("circle-radius",this,e)+Yr("circle-stroke-width",this,e)+ja(this.paint.get("circle-translate"))}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:r,geometry:i,transform:n,pixelsToTileUnits:a,unwrappedTileID:s,getElevation:o}){let l=Ga(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),-n.bearingInRadians,a),u=this.paint.get("circle-radius").evaluate(e,r)+this.paint.get("circle-stroke-width").evaluate(e,r),h=this.paint.get("circle-pitch-scale"),c=this.paint.get("circle-pitch-alignment"),p,f;return c==="map"?(p=l,f=u*a):(p=Mg(l,n,s,o),f=u),pd({queryGeometry:p,size:f,transform:n,unwrappedTileID:s,getElevation:o,pitchAlignment:c,pitchScale:h},i)}},fd=class extends Ll{};I("HeatmapBucket",fd,{omit:["layers"]});var Hh,Vg=()=>Hh||(Hh=new jt({"heatmap-radius":new U(D.paint_heatmap["heatmap-radius"],"heatmap-radius"),"heatmap-weight":new U(D.paint_heatmap["heatmap-weight"],"heatmap-weight"),"heatmap-intensity":new z(D.paint_heatmap["heatmap-intensity"],"heatmap-intensity"),"heatmap-color":new Ua(D.paint_heatmap["heatmap-color"],"heatmap-color"),"heatmap-opacity":new z(D.paint_heatmap["heatmap-opacity"],"heatmap-opacity")})),Og={get paint(){return Vg()}};function Rl(t,{width:e,height:r},i,n){if(!n)n=new Uint8Array(e*r*i);else if(n instanceof Uint8ClampedArray)n=new Uint8Array(n.buffer);else if(n.length!==e*r*i)throw RangeError(`mismatched image size. expected: ${n.length} but got: ${e*r*i}`);return t.width=e,t.height=r,t.data=n,t}function dd(t,{width:e,height:r},i){if(e===t.width&&r===t.height)return;let n=Rl({},{width:e,height:r},i);$l(t,n,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,e),height:Math.min(t.height,r)},i),t.width=e,t.height=r,t.data=n.data}function $l(t,e,r,i,n,a){if(n.width===0||n.height===0)return e;if(n.width>t.width||n.height>t.height||r.x>t.width-n.width||r.y>t.height-n.height)throw RangeError("out of range source coordinates for image copy");if(n.width>e.width||n.height>e.height||i.x>e.width-n.width||i.y>e.height-n.height)throw RangeError("out of range destination coordinates for image copy");let s=t.data,o=e.data;if(s===o)throw Error("srcData equals dstData, so image is already copied");for(let l=0;l<n.height;l++){let u=((r.y+l)*t.width+r.x)*a,h=((i.y+l)*e.width+i.x)*a;for(let c=0;c<n.width*a;c++)o[h+c]=s[u+c]}return e}var Ya=class yd{constructor(e,r){Rl(this,e,1,r)}resize(e){dd(this,e,1)}clone(){return new yd({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,r,i,n,a){$l(e,r,i,n,a,1)}},Wt=class md{constructor(e,r){Rl(this,e,4,r)}resize(e){dd(this,e,4)}replace(e,r){r?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new md({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,r,i,n,a){$l(e,r,i,n,a,4)}setPixel(e,r,i){let n=(e*this.width+r)*4;this.data[n+0]=Math.round(i.r*255/i.a),this.data[n+1]=Math.round(i.g*255/i.a),this.data[n+2]=Math.round(i.b*255/i.a),this.data[n+3]=Math.round(i.a*255)}};function Ls(t){let e=new Uint8Array(t.length);for(let r=0;r<t.length;r+=4){let i=t[r+3];e[r+0]=Math.round(t[r+0]*i/255),e[r+1]=Math.round(t[r+1]*i/255),e[r+2]=Math.round(t[r+2]*i/255),e[r+3]=i}return e}I("AlphaImage",Ya),I("RGBAImage",Wt);function Rg(t){let e={},r=t.resolution||256,i=t.clips?t.clips.length:1,n=t.image||new Wt({width:r,height:i});if(!P1(r))throw Error(`width is not a power of 2 - ${r}`);let a=(s,o,l)=>{e[t.evaluationKey]=l;let u=t.expression.evaluate(e);n.setPixel(s/4/r,o/4,u)};if(t.clips)for(let s=0,o=0;s<i;++s,o+=r*4)for(let l=0,u=0;l<r;l++,u+=4){let h=l/(r-1),{start:c,end:p}=t.clips[s],f=c*(1-h)+p*h;a(o,u,f)}else for(let s=0,o=0;s<r;s++,o+=4){let l=s/(r-1);a(0,o,l)}return n}var $g="big-fb";var Ng=class extends pe{createBucket(t){return new fd(t)}constructor(t,e){super(t,Og,e),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){t==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){let t=this._transitionablePaint._values["heatmap-color"].value.expression;this.colorRamp=Rg({expression:t,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has("big-fb")&&this.heatmapFbos.delete($g)}queryRadius(t){return Yr("heatmap-radius",this,t)}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:r,geometry:i,transform:n,pixelsToTileUnits:a,unwrappedTileID:s,getElevation:o}){return pd({queryGeometry:t,size:this.paint.get("heatmap-radius").evaluate(e,r)*a,transform:n,unwrappedTileID:s,getElevation:o},i)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&!this.isHidden()}},Kh,Ug=()=>Kh||(Kh=new jt({"hillshade-illumination-direction":new z(D.paint_hillshade["hillshade-illumination-direction"],"hillshade-illumination-direction"),"hillshade-illumination-altitude":new z(D.paint_hillshade["hillshade-illumination-altitude"],"hillshade-illumination-altitude"),"hillshade-illumination-anchor":new z(D.paint_hillshade["hillshade-illumination-anchor"],"hillshade-illumination-anchor"),"hillshade-exaggeration":new z(D.paint_hillshade["hillshade-exaggeration"],"hillshade-exaggeration"),"hillshade-shadow-color":new z(D.paint_hillshade["hillshade-shadow-color"],"hillshade-shadow-color"),"hillshade-highlight-color":new z(D.paint_hillshade["hillshade-highlight-color"],"hillshade-highlight-color"),"hillshade-accent-color":new z(D.paint_hillshade["hillshade-accent-color"],"hillshade-accent-color"),"hillshade-method":new z(D.paint_hillshade["hillshade-method"],"hillshade-method"),resampling:new z(D.paint_hillshade.resampling,"resampling")})),qg={get paint(){return Ug()}};var jg=class extends pe{constructor(t,e){super(t,qg,e),this.recalculate({zoom:0,zoomHistory:{}},void 0)}getIlluminationProperties(){let t=this.paint.get("hillshade-illumination-direction").values,e=this.paint.get("hillshade-illumination-altitude").values,r=this.paint.get("hillshade-highlight-color").values,i=this.paint.get("hillshade-shadow-color").values,n=Math.max(t.length,e.length,r.length,i.length);t=t.concat(Array(n-t.length).fill(t.at(-1))),e=e.concat(Array(n-e.length).fill(e.at(-1))),r=r.concat(Array(n-r.length).fill(r.at(-1))),i=i.concat(Array(n-i.length).fill(i.at(-1)));let a=e.map(sh);return{directionRadians:t.map(sh),altitudeRadians:a,shadowColor:i,highlightColor:r}}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&!this.isHidden()}},Jh,Gg=()=>Jh||(Jh=new jt({"color-relief-opacity":new z(D["paint_color-relief"]["color-relief-opacity"],"color-relief-opacity"),"color-relief-color":new Ua(D["paint_color-relief"]["color-relief-color"],"color-relief-color"),resampling:new z(D["paint_color-relief"].resampling,"resampling")})),Yg={get paint(){return Gg()}};function jn(t){return"data"in t}var Qh=class{constructor(t,e,r,i){this.context=t,this.format=r,this.texture=t.gl.createTexture(),this._ownedHandle=this.texture,this.update(e,i)}update(t,e,r){let{width:i,height:n}=t,a=(this.size?.[0]!==i||this.size[1]!==n)&&!r,{context:s}=this,{gl:o}=s;this.useMipmap=!!e?.useMipmap,a&&this.size&&this.format===o.RGBA&&(o.deleteTexture(this.texture),this.texture=o.createTexture(),this._ownedHandle=this.texture,this.magFilter=void 0,this.minFilter=void 0,this.wrap=void 0),o.bindTexture(o.TEXTURE_2D,this.texture),s.pixelStoreUnpackFlipY.set(!1),s.pixelStoreUnpack.set(1);let l=this.format===o.RGBA&&e?.premultiply!==!1;if(a)if(this.size=[i,n],this.format===o.RGBA&&i>0&&n>0){let u=this.useMipmap?Math.floor(Math.log2(Math.max(i,n)))+1:1;if(o.texStorage2D(o.TEXTURE_2D,u,o.RGBA8,i,n),jn(t)){s.pixelStoreUnpackPremultiplyAlpha.set(!1);let{data:h}=t;l&&h&&(h=Ls(h)),h&&o.texSubImage2D(o.TEXTURE_2D,0,0,0,i,n,o.RGBA,o.UNSIGNED_BYTE,h)}else s.pixelStoreUnpackPremultiplyAlpha.set(l),o.texSubImage2D(o.TEXTURE_2D,0,0,0,o.RGBA,o.UNSIGNED_BYTE,t)}else jn(t)?(s.pixelStoreUnpackPremultiplyAlpha.set(!1),this._uploadRawData(t,l,i,n,o)):(s.pixelStoreUnpackPremultiplyAlpha.set(l),this._uploadDomImage(t,o));else{let{x:u,y:h}=r||{x:0,y:0};jn(t)?(s.pixelStoreUnpackPremultiplyAlpha.set(!1),this._updateRawData(t,l,u,h,i,n,o)):(s.pixelStoreUnpackPremultiplyAlpha.set(l),this._updateDomImage(t,u,h,o))}this.useMipmap&&!(jn(t)&&t.data===null)&&o.generateMipmap(o.TEXTURE_2D),s.pixelStoreUnpackFlipY.setDefault(),s.pixelStoreUnpack.setDefault(),s.pixelStoreUnpackPremultiplyAlpha.setDefault()}_uploadDomImage(t,e){e.texImage2D(e.TEXTURE_2D,0,this.format,this.format,e.UNSIGNED_BYTE,t)}_uploadRawData(t,e,r,i,n){let{data:a}=t;e&&a&&(a=Ls(a)),n.texImage2D(n.TEXTURE_2D,0,this.format,r,i,0,this.format,n.UNSIGNED_BYTE,a)}_updateDomImage(t,e,r,i){i.texSubImage2D(i.TEXTURE_2D,0,e,r,i.RGBA,i.UNSIGNED_BYTE,t)}_updateRawData(t,e,r,i,n,a,s){let{data:o}=t;e&&o&&(o=Ls(o)),s.texSubImage2D(s.TEXTURE_2D,0,r,i,n,a,s.RGBA,s.UNSIGNED_BYTE,o)}bind(t,e,r){let{context:i}=this,{gl:n}=i;this.texture!==this._ownedHandle&&(this.texture=this._ownedHandle),n.bindTexture(n.TEXTURE_2D,this.texture),(r===n.LINEAR_MIPMAP_NEAREST||r===n.LINEAR_MIPMAP_LINEAR)&&!this.useMipmap&&(r=n.LINEAR);let a=r||t;t!==this.magFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),this.magFilter=t),a!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,a),this.minFilter=a),e!==this.wrap&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrap=e)}generateMipmap(){if(!this.useMipmap)return;let{gl:t}=this.context;t.bindTexture(t.TEXTURE_2D,this.texture),t.generateMipmap(t.TEXTURE_2D)}destroy(){let{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null,this._ownedHandle=null}},Me,Nl=(Me=class{constructor(e,r,i,n=1,a=1,s=1,o=0){if(this.uid=e,r.height!==r.width)throw RangeError("DEM tiles must be square");if(i&&!["mapbox","terrarium","custom"].includes(i)){Mt(`"${i}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);return}this.stride=r.height;let l=this.dim=r.height-4;switch(this.data=new Uint32Array(r.data.buffer),Me.byteViewCache.set(this,new Uint8Array(this.data.buffer)),i){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=n,this.greenFactor=a,this.blueFactor=s,this.baseShift=o;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let h=-2;h<l+2;h++){let c=this._idx(0,Math.max(0,Math.min(l-1,h)));(h<0||h>=l)&&this.data.copyWithin(this._idx(0,h),c,c+l),this.data.fill(this.data[c],this._idx(-2,h),this._idx(0,h)),this.data.fill(this.data[c+l-1],this._idx(l,h),this._idx(l+1,h)+1)}let u=this._getByteView();this.min=2**53-1,this.max=-(2**53-1);for(let h=0;h<l;h++)for(let c=0;c<l;c++){let p=this._idx(h,c)*4,f=this._unpackAtIndex(u,p);f>this.max&&(this.max=f),f<this.min&&(this.min=f)}}get(e,r){let i=this._getByteView(),n=this._idx(e,r)*4;return this._unpackAtIndex(i,n)}sampleBilinear(e,r){let i=Math.floor(e),n=Math.floor(r);if(i<-1||i>=this.dim||n<-1||n>=this.dim)throw RangeError(`Out of range source coordinates for DEM data. x: ${e}, y: ${r}, dim: ${this.dim}`);let a=this._getByteView(),s=((n+2)*this.stride+i+2)*4,o=this.stride*4,l=e-i,u=r-n,h=this._unpackAtIndex(a,s),c=this._unpackAtIndex(a,s+4),p=this._unpackAtIndex(a,s+o),f=this._unpackAtIndex(a,s+o+4);return h*(1-l)*(1-u)+c*l*(1-u)+p*(1-l)*u+f*l*u}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(e,r){if(e<-2||e>=this.dim+2||r<-2||r>=this.dim+2)throw RangeError(`Out of range source coordinates for DEM data. x: ${e}, y: ${r}, dim: ${this.dim}`);return(r+2)*this.stride+(e+2)}unpack(e,r,i){return e*this.redFactor+r*this.greenFactor+i*this.blueFactor-this.baseShift}pack(e){return gd(e,this.getUnpackVector())}getPixels(){return new Wt({width:this.stride,height:this.stride},this._getByteView())}backfillBorder(e,r,i){if(this.dim!==e.dim)throw Error("dem dimension mismatch");let n=r*this.dim,a=r*this.dim+this.dim,s=i*this.dim,o=i*this.dim+this.dim;switch(r){case-1:n=a-2;break;case 1:a=n+2}switch(i){case-1:s=o-2;break;case 1:o=s+2}let l=-r*this.dim,u=-i*this.dim;for(let h=s;h<o;h++)for(let c=n;c<a;c++)this.data[this._idx(c,h)]=e.data[this._idx(c+l,h+u)]}_getByteView(){let e=Me.byteViewCache.get(this);return e?.buffer!==this.data.buffer&&(e=new Uint8Array(this.data.buffer),Me.byteViewCache.set(this,e)),e}_unpackAtIndex(e,r){return this.unpack(e[r],e[r+1],e[r+2])}},Me.byteViewCache=new WeakMap,Me);function gd(t,e){let r=e[0],i=e[1],n=e[2],a=e[3],s=Math.min(r,i,n),o=Math.round((t+a)/s);return{r:Math.floor(o*s/r)%256,g:Math.floor(o*s/i)%256,b:Math.floor(o*s/n)%256}}I("DEMData",Nl);var Xg=class extends pe{constructor(t,e){super(t,Yg,e)}_createColorRamp(t){let e={elevationStops:[],colorStops:[]},r=this._transitionablePaint._values["color-relief-color"].value.expression;if(r instanceof en&&r._styleExpression.expression instanceof be){this.colorRampExpression=r;let a=r._styleExpression.expression;e.elevationStops=a.labels,e.colorStops=[];for(let s of e.elevationStops)e.colorStops.push(a.evaluate({globals:{elevation:s}}))}if(e.elevationStops.length<1&&(e.elevationStops=[0],e.colorStops=[gt.transparent]),e.elevationStops.length<2&&(e.elevationStops.push(e.elevationStops[0]+1),e.colorStops.push(e.colorStops[0])),e.elevationStops.length<=t)return e;let i={elevationStops:[],colorStops:[]},n=(e.elevationStops.length-1)/(t-1);for(let a=0;a<e.elevationStops.length-.5;a+=n)i.elevationStops.push(e.elevationStops[Math.round(a)]),i.colorStops.push(e.colorStops[Math.round(a)]);return Mt(`Too many colors in specification of ${this.id} color-relief layer, may not render properly. Max possible colors: ${t}, provided: ${e.elevationStops.length}`),i}_colorRampChanged(){return this.colorRampExpression!=this._transitionablePaint._values["color-relief-color"].value.expression}getColorRampTextures(t,e,r){if(this.colorRampTextures&&!this._colorRampChanged())return this.colorRampTextures;let i=this._createColorRamp(e),n=new Wt({width:i.colorStops.length,height:1}),a=new Wt({width:i.colorStops.length,height:1});for(let s=0;s<i.elevationStops.length;s++){let o=gd(i.elevationStops[s],r);a.setPixel(0,s,new gt(o.r/255,o.g/255,o.b/255,1)),n.setPixel(0,s,i.colorStops[s])}return this.colorRampTextures={elevationTexture:new Qh(t,a,t.gl.RGBA),colorTexture:new Qh(t,n,t.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return!this.isHidden()&&!!this.colorRampTextures}},Po=St([{name:"a_pos",components:2,type:"Int16"}],4),Wg=Po.members;Po.size,Po.alignment;function xa(t,e,r){let i=r.patternDependencies,n=!1;for(let a of e){let s=a.paint.get(`${t}-pattern`);s.isConstant()||(n=!0);let o=s.constantOr(null);o&&(n=!0,i[o.to]=!0,i[o.from]=!0)}return n}function Ul(t,e,r,i,n){let{zoom:a}=i,s=n.patternDependencies;for(let o of e){let l=o.paint.get(`${t}-pattern`).value;if(l.kind!=="constant"){let u=l.evaluate({zoom:a-1},r,{},n.availableImages),h=l.evaluate({zoom:a},r,{},n.availableImages),c=l.evaluate({zoom:a+1},r,{},n.availableImages);u=u?.name?u.name:u,h=h?.name?h.name:h,c=c?.name?c.name:c,s[u]=!0,s[h]=!0,s[c]=!0,r.patterns[o.id]={min:u,mid:h,max:c}}}return r}var on=new Set,zo=!1;function Zg(t,e,r=2){let i=e&&e.length,n=i?e[0]*r:t.length;on.size&&on.clear();let a=xd(t,0,n,r,!0),s=[];if(!a||a.next===a.prev)return s;let o=0,l=0,u=0;if(i&&(a=tx(t,e,a,r)),t.length>80*r){o=t[0],l=t[1];let h=o,c=l;for(let p=r;p<n;p+=r){let f=t[p],d=t[p+1];f<o&&(o=f),d<l&&(l=d),f>h&&(h=f),d>c&&(c=d)}u=Math.max(h-o,c-l),u=u===0?0:32767/u}return Lo(a,s,o,l,u),s}function xd(t,e,r,i,n){let a=null;if(n===fx(t,e,r,i)>0)for(let s=e;s<r;s+=i)a=rc(s/i|0,t[s],t[s+1],a);else for(let s=r-i;s>=e;s-=i)a=rc(s/i|0,t[s],t[s+1],a);return a&&ln(a,a.next)&&(hn(a),a=a.next),a}function xr(t,e=t){let r=e===t,i=t,n;do n=!1,i!==i.next&&(on.size===0||!on.has(i))&&(ln(i,i.next)||Ft(i.prev,i,i.next)===0)?((r||i===e)&&(e=i.prev),zo=!0,hn(i),i=i.prev,n=!0):(r||i!==e)&&(i=i.next,n=!r);while(n||i!==e);return e}function Lo(t,e,r,i,n){n&&ox(t,r,i,n);let a=t,s=!1;for(;t.prev!==t.next;){let o=t.prev,l=t.next;if(Ft(o,t,l)<0&&(n?Kg(t,r,i,n):Hg(t))){e.push(o.i,t.i,l.i),hn(t),t=l,a=l;continue}if(t=l,t===a){if(zo=!1,t=xr(t),zo){a=t;continue}if(!s){t=Jg(t,e),a=t,s=!0;continue}Qg(t,e,r,i,n);break}}}function Hg(t){let e=t.prev,r=t,i=t.next,n=e.x,a=r.x,s=i.x,o=e.y,l=r.y,u=i.y,h=Math.min(n,a,s),c=Math.min(o,l,u),p=Math.max(n,a,s),f=Math.max(o,l,u),d=i.next;for(;d!==e;){if(d.x>=h&&d.x<=p&&d.y>=c&&d.y<=f&&(n!==d.x||o!==d.y)&&ba(n,o,a,l,s,u,d.x,d.y)&&Ft(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}function Kg(t,e,r,i){let n=t.prev,a=t,s=t.next,o=n.x,l=a.x,u=s.x,h=n.y,c=a.y,p=s.y,f=Math.min(o,l,u),d=Math.min(h,c,p),y=Math.max(o,l,u),m=Math.max(h,c,p),g=$o(f,d,e,r,i),x=$o(y,m,e,r,i),b=t.prevZ;for(;b&&b.z>=g;){if(b.x>=f&&b.x<=y&&b.y>=d&&b.y<=m&&b!==s&&(o!==b.x||h!==b.y)&&ba(o,h,l,c,u,p,b.x,b.y)&&Ft(b.prev,b,b.next)>=0)return!1;b=b.prevZ}let v=t.nextZ;for(;v&&v.z<=x;){if(v.x>=f&&v.x<=y&&v.y>=d&&v.y<=m&&v!==s&&(o!==v.x||h!==v.y)&&ba(o,h,l,c,u,p,v.x,v.y)&&Ft(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Jg(t,e){let r=t,i=!1;do{let n=r.prev,a=r.next.next;bd(n,r,r.next,a,!1)&&un(n,a)&&un(a,n)&&(e.push(n.i,r.i,a.i),hn(r),hn(r.next),r=t=a,i=!0),r=r.next}while(r!==t);return i?xr(r):r}function Qg(t,e,r,i,n){let a=t;do{let s=a.next.next;for(;s!==a.prev;){if(a.i!==s.i&&hx(a,s)){let o=wd(a,s);a=xr(a,a.next),o=xr(o,o.next),Lo(a,e,r,i,n),Lo(o,e,r,i,n);return}s=s.next}a=a.next}while(a!==t)}var Vo=!1;function tx(t,e,r,i){let n=[];for(let a=0,s=e.length;a<s;a++){let o=xd(t,e[a]*i,a<s-1?e[a+1]*i:t.length,i,!1);o===o.next&&on.add(o),n.push(ux(o))}n.sort(ex),ix(t.length/i,e.length),vd(r,r),Vo=!0;for(let a=0;a<n.length;a++)r=rx(n[a],r);return Vo=!1,xr(r)}function ex(t,e){return t.x-e.x||t.y-e.y||(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)}function rx(t,e){let r=ax(t,e);if(!r)return e;let i=wd(r,t),n=i.next;return vd(r,n.next),xr(i,i.next),xr(r,r.next)}var wt=new Float64Array,va=0,Oo=[],Ro=[];function ix(t,e){let r=Math.ceil((t+2*e)/16)+e+2;wt.length<r*4&&(wt=new Float64Array(r*4)),va=0}function vd(t,e){let r=t;do{let i=va++;Oo[i]=r;let n=1/0,a=1/0,s=-1/0,o=-1/0,l=0;do{let h=r.next;r.z=i,r.x<n&&(n=r.x),r.x>s&&(s=r.x),r.y<a&&(a=r.y),r.y>o&&(o=r.y),h.x<n&&(n=h.x),h.x>s&&(s=h.x),h.y<a&&(a=h.y),h.y>o&&(o=h.y),r=h}while(++l<16&&r!==e);Ro[i]=r;let u=i*4;wt[u]=n,wt[u+1]=a,wt[u+2]=s,wt[u+3]=o}while(r!==e)}function nx(t,e){let r=t.z*4;e.x<wt[r]&&(wt[r]=e.x),e.y<wt[r+1]&&(wt[r+1]=e.y),e.x>wt[r+2]&&(wt[r+2]=e.x),e.y>wt[r+3]&&(wt[r+3]=e.y)}function tc(t){let e=Ro[t];for(;e.prev.next!==e;)e=e.next;return Ro[t]=e,e}function ec(t){let e=Oo[t];for(;e.prev.next!==e;)e=e.next;return Oo[t]=e,e}function ax(t,e){let r=e,i=t.x,n=t.y,a=-1/0,s;if(ln(t,r))return r;for(let p=0,f=0;p<va;p++,f+=4){if(n<wt[f+1]||n>wt[f+3]||wt[f]>i||wt[f+2]<=a)continue;let d=tc(p);r=ec(p);do{if(r.prev.next===r){if(ln(t,r.next))return r.next;if(n<=r.y&&n>=r.next.y&&r.next.y!==r.y){let y=r.x+(n-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(y<=i&&y>a&&(a=y,s=r.x<r.next.x?r:r.next,y===i))return s}}r=r.next}while(r!==d)}if(!s)return null;let o=s.x,l=s.y,u=Math.min(n,l),h=Math.max(n,l),c=1/0;for(let p=0,f=0;p<va;p++,f+=4){if(wt[f+2]<o||wt[f]>i||wt[f+3]<u||wt[f+1]>h)continue;let d=tc(p);r=ec(p);do{if(r.prev.next===r&&i>=r.x&&r.x>=o&&i!==r.x&&ba(n<l?i:a,n,o,l,n<l?a:i,n,r.x,r.y)){let y=Math.abs(n-r.y)/(i-r.x);(un(r,t)||r.y===n&&r.next.y===n&&r.next.x>i)&&(y<c||y===c&&(r.x>s.x||r.x===s.x&&sx(s,r)))&&(s=r,c=y)}r=r.next}while(r!==d)}return s}function sx(t,e){return Ft(t.prev,t,e.prev)<0&&Ft(e.next,t,t.next)<0}var ne=[],Ei=[],sr=new Uint32Array,Fi=new Uint32Array,Ti=new Uint32Array(256);function ox(t,e,r,i){let n=t,a=0;do n.z=$o(n.x,n.y,e,r,i),ne[a++]=n,n=n.next;while(n!==t);lx(a);let s=null;for(let o=0;o<a;o++){let l=ne[o];l.prevZ=s,s&&(s.nextZ=l),s=l}s.nextZ=null}function lx(t){if(t<=32){for(let e=1;e<t;e++){let r=ne[e],i=r.z,n=e-1;for(;n>=0&&ne[n].z>i;)ne[n+1]=ne[n],n--;ne[n+1]=r}return}sr.length<t&&(sr=new Uint32Array(t),Fi=new Uint32Array(t),Ei=Array(t));for(let e=0;e<t;e++)sr[e]=ne[e].z;Gn(t,ne,sr,Ei,Fi,0),Gn(t,Ei,Fi,ne,sr,8),Gn(t,ne,sr,Ei,Fi,16),Gn(t,Ei,Fi,ne,sr,24)}function Gn(t,e,r,i,n,a){Ti.fill(0);for(let o=0;o<t;o++)Ti[r[o]>>>a&255]++;let s=0;for(let o=0;o<256;o++){let l=Ti[o];Ti[o]=s,s+=l}for(let o=0;o<t;o++){let l=r[o],u=Ti[l>>>a&255]++;i[u]=e[o],n[u]=l}}function $o(t,e,r,i,n){return t=(t-r)*n|0,e=(e-i)*n|0,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t|e<<1}function ux(t){let e=t,r=t;do(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next;while(e!==t);return r}function ba(t,e,r,i,n,a,s,o){return(n-s)*(e-o)>=(t-s)*(a-o)&&(t-s)*(i-o)>=(r-s)*(e-o)&&(r-s)*(a-o)>=(n-s)*(i-o)}function hx(t,e){let r=ln(t,e)&&Ft(t.prev,t,t.next)>0&&Ft(e.prev,e,e.next)>0;return t.next.i!==e.i&&(r||un(t,e)&&un(e,t)&&(Ft(t.prev,t,e.prev)!==0||Ft(t,e.prev,e)!==0))&&!cx(t,e)&&(r||px(t,e))}function Ft(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function ln(t,e){return t.x===e.x&&t.y===e.y}function bd(t,e,r,i,n=!0){let a=Ft(t,e,r),s=Ft(t,e,i),o=Ft(r,i,t),l=Ft(r,i,e);return(a>0&&s<0||a<0&&s>0)&&(o>0&&l<0||o<0&&l>0)?!0:n?!!(a===0&&Yn(t,r,e)||s===0&&Yn(t,i,e)||o===0&&Yn(r,t,i)||l===0&&Yn(r,e,i)):!1}function Yn(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function cx(t,e){let r=Math.min(t.x,e.x),i=Math.max(t.x,e.x),n=Math.min(t.y,e.y),a=Math.max(t.y,e.y),s=t;do{let o=s.next;if(s.x>i&&o.x>i||s.x<r&&o.x<r||s.y>a&&o.y>a||s.y<n&&o.y<n){s=o;continue}if(s.i!==t.i&&o.i!==t.i&&s.i!==e.i&&o.i!==e.i&&bd(s,o,t,e))return!0;s=o}while(s!==t);return!1}function un(t,e){return Ft(t.prev,t,t.next)<0?Ft(t,e,t.next)>=0&&Ft(t,t.prev,e)>=0:Ft(t,e,t.prev)<0||Ft(t,t.next,e)<0}function px(t,e){let r=t,i=!1,n=(t.x+e.x)/2,a=(t.y+e.y)/2;do{let s=r.next;r.y>a!=s.y>a&&n<(s.x-r.x)*(a-r.y)/(s.y-r.y)+r.x&&(i=!i),r=s}while(r!==t);return i}function wd(t,e){let r=No(t.i,t.x,t.y),i=No(e.i,e.x,e.y),n=t.next,a=e.prev;return t.next=e,e.prev=t,r.next=n,n.prev=r,i.next=r,r.prev=i,a.next=i,i.prev=a,i}function rc(t,e,r,i){let n=No(t,e,r);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function hn(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ),Vo&&nx(t.prev,t.next)}function No(t,e,r){return{i:t,x:e,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null}}function fx(t,e,r,i){let n=0;for(let a=e,s=r-i;a<r;a+=i)n+=(t[s]-t[a])*(t[a+1]+t[s+1]),s=a;return n}var Oi=class{constructor(t,e){if(e>t)throw Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=t,this._minGranularity=e}getGranularityForZoomLevel(t){let e=1<<t;return Math.max(Math.floor(this._baseZoomGranularity/e),this._minGranularity,1)}},fr,dx=(fr=class{constructor(e){this.fill=e.fill,this.line=e.line,this.tile=e.tile,this.stencil=e.stencil,this.circle=e.circle}},fr.noSubdivision=new fr({fill:new Oi(0,0),line:new Oi(0,0),tile:new Oi(0,0),stencil:new Oi(0,0),circle:1}),fr);I("SubdivisionGranularityExpression",Oi),I("SubdivisionGranularitySetting",dx);var Vs=-32768,Os=32767,yx=class{constructor(t,e){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=t,this._granularityCellSize=mt/t,this._canonical=e}_getKey(t,e){return t+=32768,e+=32768,t<<16|e<<0}_vertexToIndex(t,e){if(t<-32768||e<-32768||t>32767||e>32767)throw Error("Vertex coordinates are out of signed 16 bit integer range.");let r=Math.round(t)|0,i=Math.round(e)|0,n=this._getKey(r,i);if(this._vertexDictionary.has(n))return this._vertexDictionary.get(n);let a=this._vertexBuffer.length/2;return this._vertexDictionary.set(n,a),this._vertexBuffer.push(r,i),a}_subdivideTrianglesScanline(t){if(this._granularity<2)return gx(this._vertexBuffer,t);let e=[],r=t.length;for(let i=0;i<r;i+=3){let n=[t[i+0],t[i+1],t[i+2]],a=[this._vertexBuffer[t[i+0]*2+0],this._vertexBuffer[t[i+0]*2+1],this._vertexBuffer[t[i+1]*2+0],this._vertexBuffer[t[i+1]*2+1],this._vertexBuffer[t[i+2]*2+0],this._vertexBuffer[t[i+2]*2+1]],s=1/0,o=1/0,l=-1/0,u=-1/0;for(let d=0;d<3;d++){let y=a[d*2],m=a[d*2+1];s=Math.min(s,y),l=Math.max(l,y),o=Math.min(o,m),u=Math.max(u,m)}if(s===l||o===u)continue;let h=Math.floor(s/this._granularityCellSize),c=Math.ceil(l/this._granularityCellSize),p=Math.floor(o/this._granularityCellSize),f=Math.ceil(u/this._granularityCellSize);if(h===c&&p===f){e.push(...n);continue}for(let d=p;d<f;d++){let y=this._scanlineGenerateVertexRingForCellRow(d,a,n);xx(this._vertexBuffer,y,e)}}return e}_scanlineGenerateVertexRingForCellRow(t,e,r){let i=t*this._granularityCellSize,n=i+this._granularityCellSize,a=[];for(let s=0;s<3;s++){let o=e[s*2],l=e[s*2+1],u=e[(s+1)*2%6],h=e[((s+1)*2+1)%6],c=e[(s+2)*2%6],p=e[((s+2)*2+1)%6],f=u-o,d=h-l,y=f===0,m=d===0,g=(i-l)/d,x=(n-l)/d,b=Math.min(g,x),v=Math.max(g,x);if(!m&&(b>=1||v<=0)||m&&(l<i||l>n)){h>=i&&h<=n&&a.push(r[(s+1)%3]);continue}if(!m&&b>0){let A=o+f*b,S=l+d*b;a.push(this._vertexToIndex(A,S))}let w=o+f*Math.max(b,0),_=o+f*Math.min(v,1);if(y||this._generateIntraEdgeVertices(a,o,l,u,h,w,_),!m&&v<1){let A=o+f*v,S=l+d*v;a.push(this._vertexToIndex(A,S))}(m||h>=i&&h<=n)&&a.push(r[(s+1)%3]),!m&&(h<=i||h>=n)&&this._generateInterEdgeVertices(a,o,l,u,h,c,p,_,i,n)}return a}_generateIntraEdgeVertices(t,e,r,i,n,a,s){let o=i-e,l=n-r,u=l===0,h=u?Math.min(e,i):Math.min(a,s),c=u?Math.max(e,i):Math.max(a,s),p=Math.floor(h/this._granularityCellSize)+1,f=Math.ceil(c/this._granularityCellSize)-1;if(u?e<i:a<s)for(let d=p;d<=f;d++){let y=d*this._granularityCellSize,m=r+l*(y-e)/o;t.push(this._vertexToIndex(y,m))}else for(let d=f;d>=p;d--){let y=d*this._granularityCellSize,m=r+l*(y-e)/o;t.push(this._vertexToIndex(y,m))}}_generateInterEdgeVertices(t,e,r,i,n,a,s,o,l,u){let h=n-r,c=a-i,p=s-n,f=(l-n)/p,d=(u-n)/p,y=Math.min(f,d),m=Math.max(f,d),g=i+c*y,x=Math.floor(Math.min(g,o)/this._granularityCellSize)+1,b=Math.ceil(Math.max(g,o)/this._granularityCellSize)-1,v=o<g,w=p===0;if(w&&(s===l||s===u))return;if(w||y>=1||m<=0){let A=e-a,S=r-s,F=(l-s)/S,L=(u-s)/S,V=a+A*Math.min(F,L);x=Math.floor(Math.min(V,o)/this._granularityCellSize)+1,b=Math.ceil(Math.max(V,o)/this._granularityCellSize)-1,v=o<V}let _=h>0?u:l;if(v)for(let A=x;A<=b;A++){let S=A*this._granularityCellSize;t.push(this._vertexToIndex(S,_))}else for(let A=b;A>=x;A--){let S=A*this._granularityCellSize;t.push(this._vertexToIndex(S,_))}}_generateOutline(t){let e=[];for(let r of t){let i=hr(r,this._granularity,!0),n=this._pointArrayToIndices(i),a=[];for(let s=1;s<n.length;s++)a.push(n[s-1]),a.push(n[s]);e.push(a)}return e}_handlePoles(t){let e=!1,r=!1;this._canonical&&(this._canonical.y===0&&(e=!0),this._canonical.y===(1<<this._canonical.z)-1&&(r=!0)),(e||r)&&this._fillPoles(t,e,r)}_ensureNoPoleVertices(){let t=this._vertexBuffer;for(let e=0;e<t.length;e+=2){let r=t[e+1];r===-32768&&(t[e+1]=-32767),r===32767&&(t[e+1]=32766)}}_generatePoleQuad(t,e,r,i,n,a){i>n==(a===-32768)?(t.push(r),t.push(e),t.push(this._vertexToIndex(i,a)),t.push(this._vertexToIndex(n,a)),t.push(r),t.push(this._vertexToIndex(i,a))):(t.push(e),t.push(r),t.push(this._vertexToIndex(i,a)),t.push(r),t.push(this._vertexToIndex(n,a)),t.push(this._vertexToIndex(i,a)))}_fillPoles(t,e,r){let i=this._vertexBuffer,n=mt,a=t.length;for(let s=2;s<a;s+=3){let o=t[s-2],l=t[s-1],u=t[s],h=i[o*2],c=i[o*2+1],p=i[l*2],f=i[l*2+1],d=i[u*2],y=i[u*2+1];e&&(c===0&&f===0&&this._generatePoleQuad(t,o,l,h,p,Vs),f===0&&y===0&&this._generatePoleQuad(t,l,u,p,d,Vs),y===0&&c===0&&this._generatePoleQuad(t,u,o,d,h,Vs)),r&&(c===n&&f===n&&this._generatePoleQuad(t,o,l,h,p,Os),f===n&&y===n&&this._generatePoleQuad(t,l,u,p,d,Os),y===n&&c===n&&this._generatePoleQuad(t,u,o,d,h,Os))}}_initializeVertices(t){for(let e=0;e<t.length;e+=2)this._vertexToIndex(t[e],t[e+1])}subdividePolygonInternal(t,e){if(this._used)throw Error("Subdivision: multiple use not allowed.");this._used=!0;let{flattened:r,holeIndices:i}=mx(t);this._initializeVertices(r);let n;try{let s=Zg(r,i),o=this._convertIndices(r,s);n=this._subdivideTrianglesScanline(o)}catch(s){console.error(s)}let a=[];return e&&(a=this._generateOutline(t)),this._ensureNoPoleVertices(),this._handlePoles(n),this._granularity>=2&&this._canonical?.z===0&&(n=this._removeTrianglesOutsideTileX(n),a=a.map(s=>this._removeLinesOutsideTileX(s))),{verticesFlattened:this._vertexBuffer,indicesTriangles:n,indicesLineList:a}}_vertexOutsideTileX(t){let e=this._vertexBuffer[t*2];return e<0||e>8192}_removeTrianglesOutsideTileX(t){let e=[];for(let r=0;r<t.length;r+=3)this._vertexOutsideTileX(t[r])||this._vertexOutsideTileX(t[r+1])||this._vertexOutsideTileX(t[r+2])||e.push(t[r],t[r+1],t[r+2]);return e}_removeLinesOutsideTileX(t){let e=[];for(let r=0;r<t.length;r+=2)this._vertexOutsideTileX(t[r])||this._vertexOutsideTileX(t[r+1])||e.push(t[r],t[r+1]);return e}_convertIndices(t,e){let r=[];for(let i of e){let n=t[i*2],a=t[i*2+1];r.push(this._vertexToIndex(n,a))}return r}_pointArrayToIndices(t){let e=[];for(let r of t)e.push(this._vertexToIndex(r.x,r.y));return e}};function Dd(t,e,r,i=!0){return new yx(r,e).subdividePolygonInternal(t,i)}function hr(t,e,r=!1){if(!t||t.length<1||t.length<2)return[];let i=t[0],n=t[t.length-1],a=r&&(i.x!==n.x||i.y!==n.y);if(e<2)return a?[...t,t[0]]:[...t];let s=Math.floor(mt/e),o=[];o.push(new B(t[0].x,t[0].y));let l=t.length,u=a?l:l-1;for(let h=0;h<u;h++){let c=t[h],p=h<l-1?t[h+1]:t[0],f=c.x,d=c.y,y=p.x,m=p.y,g=f!==y,x=d!==m;if(!g&&!x)continue;let b=y-f,v=m-d,w=Math.abs(b),_=Math.abs(v),A=f,S=d;for(;;){let L=b>0?(Math.floor(A/s)+1)*s:(Math.ceil(A/s)-1)*s,V=v>0?(Math.floor(S/s)+1)*s:(Math.ceil(S/s)-1)*s,P=Math.abs(A-L),R=Math.abs(S-V),E=Math.abs(A-y),$=Math.abs(S-m),O=g?P/w:1/0,M=x?R/_:1/0;if((E<=P||!g)&&($<=R||!x))break;if(O<M&&g||!x){A=L,S+=v*O;let j=new B(A,Math.round(S));(o[o.length-1].x!==j.x||o[o.length-1].y!==j.y)&&o.push(j)}else{A+=b*M,S=V;let j=new B(Math.round(A),S);(o[o.length-1].x!==j.x||o[o.length-1].y!==j.y)&&o.push(j)}}let F=new B(y,m);(o[o.length-1].x!==F.x||o[o.length-1].y!==F.y)&&o.push(F)}return o}function mx(t){let e=[],r=[];for(let i of t)if(i.length!==0){i!==t[0]&&e.push(r.length/2);for(let n of i)r.push(n.x),r.push(n.y)}return{flattened:r,holeIndices:e}}function gx(t,e){let r=[];for(let i=0;i<e.length;i+=3){let n=e[i],a=e[i+1],s=e[i+2],o=t[n*2],l=t[n*2+1],u=t[a*2],h=t[a*2+1],c=t[s*2],p=t[s*2+1],f=u-o,d=h-l,y=c-o;f*(p-l)-d*y>0?(r.push(n),r.push(s),r.push(a)):(r.push(n),r.push(a),r.push(s))}return r}function xx(t,e,r){if(e.length===0)throw Error("Subdivision vertex ring is empty.");let i=0,n=t[e[0]*2];for(let l=1;l<e.length;l++){let u=t[e[l]*2];u<n&&(n=u,i=l)}let a=e.length,s=i,o=(s+1)%a;for(;;){let l=s-1>=0?s-1:a-1,u=(o+1)%a,h=t[e[l]*2],c=t[e[l]*2+1],p=t[e[u]*2],f=t[e[u]*2+1],d=t[e[s]*2],y=t[e[s]*2+1],m=t[e[o]*2],g=t[e[o]*2+1],x=!1;if(h<p)x=!0;else if(h>p)x=!1;else{let b=g-y,v=-(m-d),w=y<g?1:-1;((h-d)*b+(c-y)*v)*w>((p-d)*b+(f-y)*v)*w&&(x=!0)}if(x){let b=e[l],v=e[s],w=e[o];b!==v&&b!==w&&v!==w&&r.push(w,v,b),s--,s<0&&(s=a-1)}else{let b=e[u],v=e[s],w=e[o];b!==v&&b!==w&&v!==w&&r.push(w,v,b),o++,o>=a&&(o=0)}if(l===u)break}}function _d(t,e,r,i,n,a,s,o,l){let u=n.length/2,h=s&&o&&l;if(u<te.MAX_VERTEX_ARRAY_LENGTH){let c=e.prepareSegment(u,r,i),p=c.vertexLength;for(let y=0;y<a.length;y+=3)i.emplaceBack(p+a[y],p+a[y+1],p+a[y+2]);c.vertexLength+=u,c.primitiveLength+=a.length/3;let f,d;h&&(d=s.prepareSegment(u,r,o),f=d.vertexLength,d.vertexLength+=u);for(let y=0;y<n.length;y+=2)t(n[y],n[y+1]);if(h)for(let y of l){for(let m=1;m<y.length;m+=2)o.emplaceBack(f+y[m-1],f+y[m]);d.primitiveLength+=y.length/2}}else vx(e,r,i,n,a,t),h&&bx(s,r,o,n,l,t),e.forceNewSegmentOnNextPrepare(),s?.forceNewSegmentOnNextPrepare()}function Yi(t,e,r,i,n,a,s){if(a){let o=i.count;return r(e[n*2],e[n*2+1]),t[n]=i.count,i.count++,s.vertexLength++,o}return t[n]}function vx(t,e,r,i,n,a){let s=[];for(let c=0;c<i.length/2;c++)s.push(-1);let o={count:0},l=0,u=t.getOrCreateLatestSegment(e,r),h=u.vertexLength;for(let c=2;c<n.length;c+=3){let p=n[c-2],f=n[c-1],d=n[c],y=s[p]<l,m=s[f]<l,g=s[d]<l,x=+!!y+ +!!m+ +!!g;u.vertexLength+x>te.MAX_VERTEX_ARRAY_LENGTH&&(u=t.createNewSegment(e,r),l=o.count,y=!0,m=!0,g=!0,h=0);let b=Yi(s,i,a,o,p,y,u),v=Yi(s,i,a,o,f,m,u),w=Yi(s,i,a,o,d,g,u);r.emplaceBack(h+b-l,h+v-l,h+w-l),u.primitiveLength++}}function bx(t,e,r,i,n,a){let s=[];for(let c=0;c<i.length/2;c++)s.push(-1);let o={count:0},l=0,u=t.getOrCreateLatestSegment(e,r),h=u.vertexLength;for(let c of n)for(let p=1;p<c.length;p+=2){let f=c[p-1],d=c[p],y=s[f]<l,m=s[d]<l,g=+!!y+ +!!m;u.vertexLength+g>te.MAX_VERTEX_ARRAY_LENGTH&&(u=t.createNewSegment(e,r),l=o.count,y=!0,m=!0,h=0);let x=Yi(s,i,a,o,f,y,u),b=Yi(s,i,a,o,d,m,u);r.emplaceBack(h+x-l,h+b-l),u.primitiveLength++}}var Ad=class{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(e=>e.id),this.index=t.index,this.hasDependencies=!1,this.sdfPatterns={},this.patternFeatures=[],this.layoutVertexArray=new rg,this.indexArray=new xn,this.indexArray2=new Fo,this.programConfigurations=new gr(t.layers,t.zoom),this.segments=new te,this.segments2=new te,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(t,e,r){this.hasDependencies=xa("fill",this.layers,e);let i=this.layers[0].layout.get("fill-sort-key"),n=!i.isConstant(),a=[],s=new at(this.zoom),o=this.layers[0]._featureFilter.needGeometry;for(let{feature:l,id:u,index:h,sourceLayerIndex:c}of t){let p=li(l,o);if(!this.layers[0]._featureFilter.filter(s,p,r))continue;let f=n?i.evaluate(p,{},r,e.availableImages):void 0,d={id:u,properties:l.properties,type:l.type,sourceLayerIndex:c,index:h,geometry:o?p.geometry:Dr(l),patterns:{},sortKey:f};a.push(d)}n&&a.sort((l,u)=>l.sortKey-u.sortKey);for(let l of a){let{geometry:u,index:h,sourceLayerIndex:c}=l;if(this.hasDependencies){let f=Ul("fill",this.layers,l,{zoom:this.zoom},e);this.patternFeatures.push(f)}else this.addFeature(l,u,h,r,{},e.subdivisionGranularity);let p=t[h].feature;e.featureIndex.insert(p,u,h,c,this.index)}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,{imagePositions:r})}addFeatures({options:t,canonical:e,patternPositions:r,patternMap:i}){this.detectSdfPatterns(i);for(let n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,e,r,t.subdivisionGranularity)}detectSdfPatterns(t){for(let e of this.patternFeatures)for(let r in e.patterns){let i=e.patterns[r];this.recordSdfPattern(r,t[i.min]),this.recordSdfPattern(r,t[i.mid]),this.recordSdfPattern(r,t[i.max])}for(let e of this.layers){let r=e.paint.get("fill-pattern").constantOr(null);r&&(this.recordSdfPattern(e.id,t[r.from.toString()]),this.recordSdfPattern(e.id,t[r.to.toString()]))}}recordSdfPattern(t,e){if(!e)return;let r=e.sdf===!0,i=this.sdfPatterns[t];i===void 0?this.sdfPatterns[t]=r:i!==r&&Mt(`Style sheet warning: Cannot mix SDF and non-SDF fill patterns in layer "${t}"`)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Wg),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,e,r,i,n,a){for(let s of Ba(e,500)){let o=Dd(s,i,a.fill.getGranularityForZoomLevel(i.z)),l=this.layoutVertexArray;_d((u,h)=>{l.emplaceBack(u,h)},this.segments,this.layoutVertexArray,this.indexArray,o.verticesFlattened,o.indicesTriangles,this.segments2,this.indexArray2,o.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,{imagePositions:n,canonical:i})}};I("FillBucket",Ad,{omit:["layers","patternFeatures"]});var ic,wx=()=>ic||(ic=new jt({"fill-sort-key":new U(D.layout_fill["fill-sort-key"],"fill-sort-key")})),nc,Dx=()=>nc||(nc=new jt({"fill-antialias":new z(D.paint_fill["fill-antialias"],"fill-antialias"),"fill-opacity":new U(D.paint_fill["fill-opacity"],"fill-opacity"),"fill-layer-opacity":new z(D.paint_fill["fill-layer-opacity"],"fill-layer-opacity"),"fill-color":new U(D.paint_fill["fill-color"],"fill-color"),"fill-outline-color":new U(D.paint_fill["fill-outline-color"],"fill-outline-color"),"fill-translate":new z(D.paint_fill["fill-translate"],"fill-translate"),"fill-translate-anchor":new z(D.paint_fill["fill-translate-anchor"],"fill-translate-anchor"),"fill-pattern":new nn(D.paint_fill["fill-pattern"],"fill-pattern")})),_x={get paint(){return Dx()},get layout(){return wx()}};var Ax=class extends pe{constructor(t,e){super(t,_x,e)}recalculate(t,e){super.recalculate(t,e);let r=this.paint._values["fill-outline-color"];r.value.kind==="constant"&&r.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new Ad(t)}queryRadius(){return ja(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:t,geometry:e,transform:r,pixelsToTileUnits:i}){return hd(Ga(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-r.bearingInRadians,i),e)}isTileClipped(){return!0}},Uo=St([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Sx=St([{name:"a_centroid",components:2,type:"Int16"}],4),Ex=Uo.members;Uo.size,Uo.alignment;var wa=class qo{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 r=new qo;return r.extend(e(new B(this.minX,this.minY))),r.extend(e(new B(this.maxX,this.minY))),r.extend(e(new B(this.minX,this.maxY))),r.extend(e(new B(this.maxX,this.maxY))),r}static fromPoints(e){let r=new qo;for(let i of e)r.extend(i);return r}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}},s5=wa.fromPoints([new B(0,0),new B(mt,mt)]);function jo(t,e){return t.x===e.x&&(t.x<0||t.x>8192)||t.y===e.y&&(t.y<0||t.y>8192)}function ac(t){return t.every(e=>e.x<0)||t.every(e=>e.x>8192)||t.every(e=>e.y<0)||t.every(e=>e.y>8192)}var vn=class{constructor(t,e,r,i,n){for(this.properties=Object.create(null),this.extent=r,this.type=0,this.id=void 0,this._pbf=t,this._geometry=-1,this._keys=i,this._values=n;t.pos<e;){let a=t.readVarint();if(a===8)this.id=t.readVarint();else if(a===18){let s=t.readVarint()+t.pos;for(;t.pos<s;){let o=i[t.readVarint()],l=n[t.readVarint()];this.properties[o]=l}}else a===24?this.type=t.readVarint():(a===34&&(this._geometry=t.pos),t.skip(a))}}loadGeometry(){if(this._geometry<0)throw Error("feature has no geometry");let t=this._pbf;t.pos=this._geometry;let e=t.readVarint()+t.pos,r=[],i,n=1,a=0,s=0,o=0;for(;t.pos<e;){if(a<=0){let l=t.readVarint();if(n=l&7,a=l>>3,a===0)continue}if(a--,n===1)s+=t.readSVarint(),o+=t.readSVarint(),i&&r.push(i),i=[new B(s,o)];else if(n===2)s+=t.readSVarint(),o+=t.readSVarint(),i&&i.push(new B(s,o));else if(n===7)i&&i.push(i[0].clone());else throw Error(`unknown command ${n}`)}return i&&r.push(i),r}bbox(){if(this._geometry<0)throw Error("feature has no geometry");let t=this._pbf;t.pos=this._geometry;let e=t.readVarint()+t.pos,r=1,i=0,n=0,a=0,s=1/0,o=-1/0,l=1/0,u=-1/0;for(;t.pos<e;){if(i<=0){let h=t.readVarint();if(r=h&7,i=h>>3,i===0)continue}if(i--,r===1||r===2)n+=t.readSVarint(),a+=t.readSVarint(),n<s&&(s=n),n>o&&(o=n),a<l&&(l=a),a>u&&(u=a);else if(r!==7)throw Error(`unknown command ${r}`)}return[s,l,o,u]}toGeoJSON(t,e,r){let i=this.extent*2**r,n=this.extent*t,a=this.extent*e,s=this.loadGeometry();function o(c){return[(c.x+n)*360/i-180,360/Math.PI*Math.atan(Math.exp((1-(c.y+a)*2/i)*Math.PI))-90]}function l(c){return c.map(o)}let u;if(this.type===1){let c=[];for(let f of s)c.push(f[0]);let p=l(c);u=c.length===1?{type:"Point",coordinates:p[0]}:{type:"MultiPoint",coordinates:p}}else if(this.type===2){let c=s.map(l);u=c.length===1?{type:"LineString",coordinates:c[0]}:{type:"MultiLineString",coordinates:c}}else if(this.type===3){let c=Sd(s),p=[];for(let f of c)p.push(f.map(l));u=p.length===1?{type:"Polygon",coordinates:p[0]}:{type:"MultiPolygon",coordinates:p}}else throw Error("unknown feature type");let h={type:"Feature",geometry:u,properties:this.properties};return this.id!=null&&(h.id=this.id),h}};vn.types=["Unknown","Point","LineString","Polygon"];function Sd(t){let e=t.length;if(e<=1)return[t];let r=[],i,n;for(let a=0;a<e;a++){let s=Fx(t[a]);s!==0&&(n===void 0&&(n=s<0),n===s<0?(i&&r.push(i),i=[t[a]]):i&&i.push(t[a]))}return i&&r.push(i),r}function Fx(t){let e=0;for(let r=0,i=t.length,n=i-1,a,s;r<i;n=r++)a=t[r],s=t[n],e+=(s.x-a.x)*(a.y+s.y);return e}var Tx=class{constructor(t,e){for(this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],e===void 0&&(e=t.length);t.pos<e;){let r=t.readVarint();r===10?this.name=t.readString():r===18?(this._features.push(t.pos),t.skip(r)):r===26?this._keys.push(t.readString()):r===34?this._values.push(kx(t)):r===40?this.extent=t.readVarint():r===120?this.version=t.readVarint():t.skip(r)}this.length=this._features.length}feature(t){if(t<0||t>=this._features.length)throw Error("feature index out of bounds");this._pbf.pos=this._features[t];let e=this._pbf.readVarint()+this._pbf.pos;return new vn(this._pbf,e,this.extent,this._keys,this._values)}};function kx(t){let e=null,r=t.readVarint()+t.pos;for(;t.pos<r;){let i=t.readVarint();e=i===10?t.readString():i===21?t.readFloat():i===25?t.readDouble():i===32?t.readVarint(!0):i===40?t.readVarint():i===48?t.readSVarint():i===56?t.readBoolean():(t.skip(i),null)}if(e==null)throw Error("unknown feature value");return e}var ql=class{constructor(t,e=t.length){let r=Object.create(null);for(;t.pos<e;){let i=t.readVarint();if(i===26){let n=new Tx(t,t.readVarint()+t.pos);n.length&&(r[n.name]=n)}else t.skip(i)}this.layers=r}},Ed=63710088e-1,sc=class Ri{constructor(e,r){if(isNaN(e)||isNaN(r))throw Error(`Invalid LngLat object: (${e}, ${r})`);if(this.lng=+e,this.lat=+r,this.lat>90||this.lat<-90)throw Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Ri(B1(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){let r=Math.PI/180,i=this.lat*r,n=e.lat*r,a=Math.sin(i)*Math.sin(n)+Math.cos(i)*Math.cos(n)*Math.cos((e.lng-this.lng)*r);return Ed*Math.acos(Math.min(a,1))}static convert(e){if(e instanceof Ri)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new Ri(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e)return new Ri(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>]")}},Fd=2*Math.PI*Ed;function Td(t){return Fd*Math.cos(t*Math.PI/180)}function Ix(t){return(180+t)/360}function Cx(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function Mx(t,e){return t/Td(e)}function Bx(t){return t*360-180}function Go(t){let e=180-t*360;return 360/Math.PI*Math.atan(Math.exp(e*Math.PI/180))-90}function Px(t,e){return t*Td(Go(e))}function zx(t){return 1/Math.cos(t*Math.PI/180)}var jl=class kd{constructor(e,r,i=0){this.x=+e,this.y=+r,this.z=+i}static fromLngLat(e,r=0){let i=sc.convert(e);return new kd(Ix(i.lng),Cx(i.lat),Mx(r,i.lat))}toLngLat(){return new sc(Bx(this.x),Go(this.y))}toAltitude(){return Px(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Fd*zx(Go(this.y))}};function Lx(t,e,r){let i=1/(1<<r.z);return new jl(t/mt*i+r.x*i,e/mt*i+r.y*i)}function Vx(t,e,r){return Lx(t,e,r).toLngLat()}function oc(t,e,r){if(e<=0||!t||t.length===0)return t;let i=Ox(e,r);return t.map(n=>Rx(n,i))}function Ox(t,e){let r=Vx(mt/2,mt/2,e),i=jl.fromLngLat(r).meterInMercatorCoordinateUnits(),n=(1<<e.z)*mt;return t*i*n}function Rx(t,e){if(!t||t.length<3)return t;let r=t[0].x===t[t.length-1].x&&t[0].y===t[t.length-1].y,i=r?t.length-1:t.length;if(i<3)return t;let n=[];for(let s=0;s<i;s++){let o=t[(s-1+i)%i],l=t[s],u=t[(s+1)%i];if(jo(o,l)||jo(l,u)){n.push(l.clone());continue}Nx(n,o,l,u,e)}let a=$x(n);return a.length<3?t:(r&&a.push(a[0].clone()),a)}function $x(t){let e=[];for(let r of t){let i=r.round(),n=e[e.length-1];(n?.x!==i.x||n?.y!==i.y)&&e.push(i)}for(;e.length>1&&e[0].x===e[e.length-1].x&&e[0].y===e[e.length-1].y;)e.pop();return e}function Nx(t,e,r,i,n){let a=e.sub(r),s=i.sub(r),o=a.mag(),l=s.mag();if(o<1e-6||l<1e-6){t.push(r.clone());return}a._div(o),s._div(l);let u=a.x*s.x+a.y*s.y;if(Math.abs(u)>Math.cos(5*Math.PI/180)){t.push(r.clone());return}let h=.2,c=Math.min(n,o*h,l*h),p=r.add(a.mult(c)),f=r.add(s.mult(c)),d=Math.sqrt((1+u)/2),y=r.add(a.add(s)._unit()._mult(c/d)),m=p.sub(y).angleWith(f.sub(y)),g=Math.max(2,Math.ceil(Math.abs(m)/(Math.PI/6)-1e-6));for(let x=0;x<=g;x++)t.push(p.rotateAround(x/g*m,y))}var Rs=8192;function ki(t,e,r,i,n,a,s,o){t.emplaceBack(e,r,Math.floor(i*Rs)*2+s,n*Rs*2,a*Rs*2,Math.round(o))}var Id=class{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(e=>e.id),this.index=t.index,this.hasDependencies=!1,this.layoutVertexArray=new ig,this.centroidVertexArray=new tg,this.indexArray=new xn,this.programConfigurations=new gr(t.layers,t.zoom),this.segments=new te,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(t,e,r){this.features=[],this.hasDependencies=xa("fill-extrusion",this.layers,e);let i=new at(this.zoom),n=this.layers[0],a=n.layout.get("fill-extrusion-rounded-corner-distance"),s=n._featureFilter.needGeometry;for(let{feature:o,id:l,index:u,sourceLayerIndex:h}of t){let c=li(o,s);if(!n._featureFilter.filter(i,c,r))continue;let p=s?c.geometry:Dr(o),f={id:l,sourceLayerIndex:h,index:u,geometry:a>0?oc(p,a,r):p,properties:o.properties,type:o.type,patterns:{}};this.hasDependencies?this.features.push(Ul("fill-extrusion",this.layers,f,{zoom:this.zoom},e)):this.addFeature(f,f.geometry,u,r,{},e.subdivisionGranularity),e.featureIndex.insert(o,f.geometry,u,h,this.index,!0)}}addFeatures({options:t,canonical:e,patternPositions:r}){for(let i of this.features){let{geometry:n}=i;this.addFeature(i,n,i.index,e,r,t.subdivisionGranularity)}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,{imagePositions:r})}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ex),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Sx.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(t,e,r,i,n,a){let s=this.layers[0],o=s.layout?s.layout.get("fill-extrusion-rounded-corner-distance"):0,l=o>0?oc(e,o,i):e;for(let u of Ba(l,500)){let h={x:0,y:0,sampleCount:0},c=this.layoutVertexArray.length;this.processPolygon(h,i,t,u,a);let p=this.layoutVertexArray.length-c,f=Math.floor(h.x/h.sampleCount),d=Math.floor(h.y/h.sampleCount);for(let y=0;y<p;y++)this.centroidVertexArray.emplaceBack(f,d)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,{imagePositions:n,canonical:i})}processPolygon(t,e,r,i,n){if(i.length<1||ac(i[0]))return;for(let h of i)h.length!==0&&Ux(t,h);let a={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},s=n.fill.getGranularityForZoomLevel(e.z),o=vn.types[r.type]==="Polygon";for(let h of i){if(h.length===0||ac(h))continue;let c=hr(h,s,o);this._generateSideFaces(c,a)}if(!o)return;let l=Dd(i,e,s,!1),u=this.layoutVertexArray;_d((h,c)=>{ki(u,h,c,0,0,1,1,0)},this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles)}_generateSideFaces(t,e){let r=0;for(let i=1;i<t.length;i++){let n=t[i],a=t[i-1];if(jo(n,a))continue;e.segment.vertexLength+4>te.MAX_VERTEX_ARRAY_LENGTH&&(e.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));let s=n.sub(a)._perp()._unit(),o=a.dist(n);r+o>32768&&(r=0),ki(this.layoutVertexArray,n.x,n.y,s.x,s.y,0,0,r),ki(this.layoutVertexArray,n.x,n.y,s.x,s.y,0,1,r),r+=o,ki(this.layoutVertexArray,a.x,a.y,s.x,s.y,0,0,r),ki(this.layoutVertexArray,a.x,a.y,s.x,s.y,0,1,r);let l=e.segment.vertexLength;this.indexArray.emplaceBack(l,l+2,l+1),this.indexArray.emplaceBack(l+1,l+2,l+3),e.segment.vertexLength+=4,e.segment.primitiveLength+=2}}};function Ux(t,e){for(let r=0;r<e.length;r++){let i=e[r];(r!==e.length-1||e[0].x!==i.x||e[0].y!==i.y)&&(t.x+=i.x,t.y+=i.y,t.sampleCount++)}}I("FillExtrusionBucket",Id,{omit:["layers","features"]});var lc,qx=()=>lc||(lc=new jt({"fill-extrusion-rounded-corner-distance":new z(D["layout_fill-extrusion"]["fill-extrusion-rounded-corner-distance"],"fill-extrusion-rounded-corner-distance")})),uc,jx=()=>uc||(uc=new jt({"fill-extrusion-opacity":new z(D["paint_fill-extrusion"]["fill-extrusion-opacity"],"fill-extrusion-opacity"),"fill-extrusion-color":new U(D["paint_fill-extrusion"]["fill-extrusion-color"],"fill-extrusion-color"),"fill-extrusion-translate":new z(D["paint_fill-extrusion"]["fill-extrusion-translate"],"fill-extrusion-translate"),"fill-extrusion-translate-anchor":new z(D["paint_fill-extrusion"]["fill-extrusion-translate-anchor"],"fill-extrusion-translate-anchor"),"fill-extrusion-pattern":new nn(D["paint_fill-extrusion"]["fill-extrusion-pattern"],"fill-extrusion-pattern"),"fill-extrusion-height":new U(D["paint_fill-extrusion"]["fill-extrusion-height"],"fill-extrusion-height"),"fill-extrusion-base":new U(D["paint_fill-extrusion"]["fill-extrusion-base"],"fill-extrusion-base"),"fill-extrusion-vertical-gradient":new z(D["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"],"fill-extrusion-vertical-gradient")})),Gx={get paint(){return jx()},get layout(){return qx()}};var Yx=class extends pe{constructor(t,e){super(t,Gx,e)}createBucket(t){return new Id(t)}queryRadius(){return ja(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:r,geometry:i,transform:n,pixelsToTileUnits:a,pixelPosMatrix:s}){let o=Ga(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-n.bearingInRadians,a),l=this.paint.get("fill-extrusion-height").evaluate(e,r),u=this.paint.get("fill-extrusion-base").evaluate(e,r),h=Zx(o,s,0),c=Wx(i,u,l,s),p=c[0],f=c[1];return Xx(p,f,h)}};function Ii(t,e){return t.x*e.x+t.y*e.y}function hc(t,e){if(t.length===1){let r=0,i=e[r++],n;for(;!n||i.equals(n);)if(n=e[r++],!n)return 1/0;for(;r<e.length;r++){let a=e[r],s=t[0],o=n.sub(i),l=a.sub(i),u=s.sub(i),h=Ii(o,o),c=Ii(o,l),p=Ii(l,l),f=Ii(u,o),d=Ii(u,l),y=h*p-c*c,m=(p*f-c*d)/y,g=(h*d-c*f)/y,x=1-m-g,b=i.z*x+n.z*m+a.z*g;if(isFinite(b))return b}return 1/0}{let r=1/0;for(let i of e)r=Math.min(r,i.z);return r}}function Xx(t,e,r){let i=1/0;hd(r,e)&&(i=hc(r,e[0]));for(let n=0;n<e.length;n++){let a=e[n],s=t[n];for(let o=0;o<a.length-1;o++){let l=a[o],u=a[o+1],h=s[o],c=[l,u,s[o+1],h,l];bg(r,c)&&(i=Math.min(i,hc(r,c)))}}return i!==1/0&&i}function Wx(t,e,r,i){let n=[],a=[],s=i[8]*e,o=i[9]*e,l=i[10]*e,u=i[11]*e,h=i[8]*r,c=i[9]*r,p=i[10]*r,f=i[11]*r;for(let d of t){let y=[],m=[];for(let g of d){let x=g.x,b=g.y,v=i[0]*x+i[4]*b+i[12],w=i[1]*x+i[5]*b+i[13],_=i[2]*x+i[6]*b+i[14],A=i[3]*x+i[7]*b+i[15],S=v+s,F=w+o,L=_+l,V=A+u,P=v+h,R=w+c,E=_+p,$=A+f,O=new B(S/V,F/V);O.z=L/V,y.push(O);let M=new B(P/$,R/$);M.z=E/$,m.push(M)}n.push(y),a.push(m)}return[n,a]}function Zx(t,e,r){let i=[];for(let n of t){let a=[n.x,n.y,r,1];F1(a,a,e),i.push(new B(a[0]/a[3],a[1]/a[3]))}return i}function Yo(t,e,r,i){let n=i,a=e+(r-e>>1),s=r-e,o,l=t[e],u=t[e+1],h=t[r],c=t[r+1];for(let p=e+3;p<r;p+=3){let f=Hx(t[p],t[p+1],l,u,h,c);if(f>n){o=p,n=f;continue}if(f===n){let d=Math.abs(p-a);d<s&&(o=p,s=d)}}n>i&&(o-e>3&&Yo(t,e,o,i),t[o+2]=n,r-o>3&&Yo(t,o,r,i))}function Hx(t,e,r,i,n,a){let s=n-r,o=a-i;if(s!==0||o!==0){let l=((t-r)*s+(e-i)*o)/(s*s+o*o);l>1?(r=n,i=a):l>0&&(r+=s*l,i+=o*l)}return s=t-r,o=e-i,s*s+o*o}function Ct(t,e,r,i){let n={type:e,geom:r},a={id:t??null,type:n.type,geometry:n.geom,tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};switch(n.type){case"Point":case"MultiPoint":Ci(a,n.geom);break;case"LineString":Ci(a,n.geom.points);break;case"Polygon":Ci(a,n.geom[0].points);break;case"MultiLineString":for(let s of n.geom)Ci(a,s.points);break;case"MultiPolygon":for(let s of n.geom)Ci(a,s[0].points)}return a}function Gl(t){let e=t;t.points.length>64&&(e.points=new Float64Array(t.points))}function Ci(t,e){for(let r=0;r<e.length;r+=3)t.minX=Math.min(t.minX,e[r]),t.minY=Math.min(t.minY,e[r+1]),t.maxX=Math.max(t.maxX,e[r]),t.maxY=Math.max(t.maxY,e[r+1])}function Yl(t,e){let r=[];switch(t.type){case"FeatureCollection":for(let i=0;i<t.features.length;i++)oa(r,t.features[i],e,i);break;case"Feature":oa(r,t,e);break;default:oa(r,{type:"Feature",geometry:t,properties:void 0},e)}return r}function oa(t,e,r,i,n=0){if(!e.geometry)return;if(n>1024)throw Error("GeometryCollection nesting exceeds supported depth: 1024");if(e.geometry.type==="GeometryCollection"){Jx(t,e,e.geometry,r,i,n+1);return}if(!e.geometry.coordinates?.length)return;let a=Kx(e,r,i),s=(r.tolerance/((1<<r.maxZoom)*r.extent))**2;switch(e.geometry.type){case"Point":Qx(t,a,e.geometry,e.properties);return;case"MultiPoint":t2(t,a,e.geometry,e.properties);return;case"LineString":e2(t,a,e.geometry,s,e.properties);return;case"MultiLineString":r2(t,a,e.geometry,s,r,e.properties);return;case"Polygon":i2(t,a,e.geometry,s,e.properties);return;case"MultiPolygon":n2(t,a,e.geometry,s,e.properties);return;default:throw Error("Input data is not a valid GeoJSON object.")}}function Kx(t,e,r){return e.promoteId?t.properties?.[e.promoteId]:e.generateId?r||0:t.id}function Jx(t,e,r,i,n,a=0){for(let s of r.geometries)oa(t,{id:e.id,type:"Feature",geometry:s,properties:e.properties},i,n,a)}function Qx(t,e,r,i){let n=[];n.push(Xr(r.coordinates[0]),Wr(r.coordinates[1]),0),t.push(Ct(e,"Point",n,i))}function t2(t,e,r,i){let n=[];for(let a of r.coordinates)n.push(Xr(a[0]),Wr(a[1]),0);t.push(Ct(e,"MultiPoint",n,i))}function e2(t,e,r,i,n){let a={points:[]};Xl(r.coordinates,a,i,!1),t.push(Ct(e,"LineString",a,n))}function r2(t,e,r,i,n,a){if(n.lineMetrics)for(let s of r.coordinates){let o={points:[]};Xl(s,o,i,!1),t.push(Ct(e,"LineString",o,a))}else{let s=[];Wl(r.coordinates,s,i,!1),t.push(Ct(e,"MultiLineString",s,a))}}function i2(t,e,r,i,n){let a=[];Wl(r.coordinates,a,i,!0),t.push(Ct(e,"Polygon",a,n))}function n2(t,e,r,i,n){let a=[];for(let s of r.coordinates){let o=[];Wl(s,o,i,!0),a.push(o)}t.push(Ct(e,"MultiPolygon",a,n))}function Xl(t,e,r,i){let n,a,s=0;for(let l=0;l<t.length;l++){let u=Xr(t[l][0]),h=Wr(t[l][1]);e.points.push(u,h,0),l>0&&(s+=i?(n*h-u*a)/2:Math.sqrt((u-n)**2+(h-a)**2)),n=u,a=h}let o=e.points.length-3;e.points[2]=1,r>0&&Yo(e.points,0,o,r),e.points[o+2]=1,Gl(e),e.size=Math.abs(s),e.start=0,e.end=e.size}function Wl(t,e,r,i){for(let n=0;n<t.length;n++){let a={points:[]};Xl(t[n],a,r,i),e.push(a)}}function Xr(t){return t/360+.5}function Wr(t){let e=Math.sin(t*Math.PI/180),r=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return r<0?0:r>1?1:r}function a2(t){return{type:"FeatureCollection",features:t.map(e=>Da(e))}}function Da(t){let e={type:"Feature",geometry:s2(t),properties:t.tags};return t.id!=null&&(e.id=t.id),e}function s2(t){let{type:e,geometry:r}=t;switch(e){case"Point":return{type:e,coordinates:Cd(r[0],r[1])};case"MultiPoint":return{type:e,coordinates:Xn(r)};case"LineString":return{type:e,coordinates:Xn(r.points)};case"MultiLineString":case"Polygon":return{type:e,coordinates:r.map(i=>Xn(i.points))};case"MultiPolygon":return{type:e,coordinates:r.map(i=>i.map(n=>Xn(n.points)))}}}function Xn(t){let e=[];for(let r=0;r<t.length;r+=3)e.push(Cd(t[r],t[r+1]));return e}function Cd(t,e){return[Md(t),Bd(e)]}function Md(t){return(t-.5)*360}function Bd(t){let e=(180-t*360)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function ke(t,e,r,i,n,a,s,o){if(r/=e,i/=e,a>=r&&s<i)return t;if(s<r||a>=i)return null;let l=[];for(let u of t){let h=n===0?u.minX:u.minY,c=n===0?u.maxX:u.maxY;if(h>=r&&c<i){l.push(u);continue}if(!(c<r||h>=i))switch(u.type){case"Point":case"MultiPoint":o2(u,l,r,i,n);continue;case"LineString":l2(u,l,r,i,n,o);continue;case"MultiLineString":u2(u,l,r,i,n);continue;case"Polygon":h2(u,l,r,i,n);continue;case"MultiPolygon":c2(u,l,r,i,n);continue}}return l.length?l:null}function o2(t,e,r,i,n){let a=[];if(p2(t.geometry,a,r,i,n),!a.length)return;let s=a.length===3?"Point":"MultiPoint";e.push(Ct(t.id,s,a,t.tags))}function l2(t,e,r,i,n,a){let s=[];if(Pd(t.geometry,s,r,i,n,!1,a.lineMetrics),s.length){if(a.lineMetrics){for(let o of s)e.push(Ct(t.id,"LineString",o,t.tags));return}if(s.length>1){e.push(Ct(t.id,"MultiLineString",s,t.tags));return}e.push(Ct(t.id,"LineString",s[0],t.tags))}}function u2(t,e,r,i,n){let a=[];if(Zl(t.geometry,a,r,i,n,!1),a.length){if(a.length===1){e.push(Ct(t.id,"LineString",a[0],t.tags));return}e.push(Ct(t.id,"MultiLineString",a,t.tags))}}function h2(t,e,r,i,n){let a=[];Zl(t.geometry,a,r,i,n,!0),a.length&&e.push(Ct(t.id,"Polygon",a,t.tags))}function c2(t,e,r,i,n){let a=[];for(let s of t.geometry){let o=[];Zl(s,o,r,i,n,!0),o.length&&a.push(o)}a.length&&e.push(Ct(t.id,"MultiPolygon",a,t.tags))}function p2(t,e,r,i,n){for(let a=0;a<t.length;a+=3){let s=t[a+n];s>=r&&s<=i&&Zr(e,t[a],t[a+1],t[a+2])}}function Pd(t,e,r,i,n,a,s){let o=cc(t),l=n===0?f2:d2,u=t.start,h,c;for(let g=0;g<t.points.length-3;g+=3){let x=t.points[g],b=t.points[g+1],v=t.points[g+2],w=t.points[g+3],_=t.points[g+4],A=n===0?x:b,S=n===0?w:_,F=!1;s&&(h=Math.sqrt((x-w)**2+(b-_)**2)),A<r?S>r&&(c=l(o,x,b,w,_,r),s&&(o.start=u+h*c)):A>i?S<i&&(c=l(o,x,b,w,_,i),s&&(o.start=u+h*c)):Zr(o.points,x,b,v),S<r&&A>=r&&(c=l(o,x,b,w,_,r),F=!0),S>i&&A<=i&&(c=l(o,x,b,w,_,i),F=!0),!a&&F&&(s&&(o.end=u+h*c),e.push(o),o=cc(t)),s&&(u+=h)}let p=t.points.length-3,f=t.points[p],d=t.points[p+1],y=t.points[p+2],m=n===0?f:d;m>=r&&m<=i&&Zr(o.points,f,d,y),p=o.points.length-3,a&&p>=3&&(o.points[p]!==o.points[0]||o.points[p+1]!==o.points[1])&&Zr(o.points,o.points[0],o.points[1],o.points[2]),o.points.length&&(Gl(o),e.push(o))}function cc(t){return{points:[],size:t.size,start:t.start,end:t.end}}function Zl(t,e,r,i,n,a){for(let s of t)Pd(s,e,r,i,n,a,!1)}function Zr(t,e,r,i){t.push(e,r,i)}function f2(t,e,r,i,n,a){let s=(a-e)/(i-e);return Zr(t.points,a,r+(n-r)*s,1),s}function d2(t,e,r,i,n,a){let s=(a-r)/(n-r);return Zr(t.points,e+(i-e)*s,a,1),s}function Hl(t,e){let r=e.buffer/e.extent,i=t,n=ke(t,1,-1-r,r,0,-1,2,e),a=ke(t,1,1-r,2+r,0,-1,2,e);return!n&&!a||(i=ke(t,1,-r,1+r,0,-1,2,e)||[],n&&(i=pc(n,1).concat(i)),a&&(i=i.concat(pc(a,-1)))),i}function pc(t,e){let r=[];for(let i of t)switch(i.type){case"Point":case"MultiPoint":{let n=y2(i.geometry,e);r.push(Ct(i.id,i.type,n,i.tags));continue}case"LineString":{let n=$s(i.geometry,e);r.push(Ct(i.id,i.type,n,i.tags));continue}case"MultiLineString":case"Polygon":{let n=[];for(let a of i.geometry)n.push($s(a,e));r.push(Ct(i.id,i.type,n,i.tags));continue}case"MultiPolygon":{let n=[];for(let a of i.geometry){let s=[];for(let o of a)s.push($s(o,e));n.push(s)}r.push(Ct(i.id,i.type,n,i.tags));continue}}return r}function y2(t,e){let r=[];for(let i=0;i<t.length;i+=3)r.push(t[i]+e,t[i+1],t[i+2]);return r}function $s(t,e){let r={points:[],size:t.size};t.start!==void 0&&(r.start=t.start,r.end=t.end);for(let i=0;i<t.points.length;i+=3)r.points.push(t.points[i]+e,t.points[i+1],t.points[i+2]);return Gl(r),r}function m2(t,e,r){let i=x2(e,r),n=[];if(i.removeAll&&(n=t,t=[]),i.remove.size||i.add.size){let a=[];for(let s of t)(i.remove.has(s.id)||i.add.has(s.id))&&a.push(s);if(a.length){n=n.concat(a);let s=new Set(a.map(o=>o.id));t=t.filter(o=>!s.has(o.id))}if(i.add.size){let s=Yl({type:"FeatureCollection",features:Array.from(i.add.values())},r);s=Hl(s,r),n=n.concat(s),t=t.concat(s)}}if(i.update.size){let a=new Map,s=[];for(let o of t)i.update.has(o.id)?a.set(o.id,[...a.get(o.id)||[],o]):s.push(o);for(let[o,l]of i.update){let u=a.get(o);if(!u||u.length===0)continue;let h=g2(u,l,r);n=n.concat(u,h),s=s.concat(h)}t=s}return{affected:n,source:t}}function g2(t,e,r){let i=!!e.newGeometry,n=e.removeAllProperties||e.removeProperties?.length>0||e.addOrUpdateProperties?.length>0;if(i){let a=t[0],s=Yl({type:"FeatureCollection",features:[{type:"Feature",id:a.id,geometry:e.newGeometry,properties:n?fc(a.tags,e):a.tags}]},r);return s=Hl(s,r),s}if(n){let a=[];for(let s of t){let o={...s};o.tags=fc(o.tags,e),a.push(o)}return a}return t}function fc(t,e){if(e.removeAllProperties)return{};let r={...t||{}};if(e.removeProperties)for(let i of e.removeProperties)delete r[i];if(e.addOrUpdateProperties)for(let{key:i,value:n}of e.addOrUpdateProperties)r[i]=n;return r}function x2(t,e){return t?{removeAll:t.removeAll,remove:new Set(t.remove||[]),add:new Map(t.add?.map(r=>[e.promoteId?r.properties[e.promoteId]:r.id,r])),update:new Map(t.update?.map(r=>[r.id,r]))}:{remove:new Set,add:new Map,update:new Map}}var dc=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],dt=new Uint32Array(96),v2=class zd{static from(e){if(!e||e.byteLength===void 0||e.buffer)throw Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");let[r,i]=new Uint8Array(e,0,2);if(r!==219)throw Error("Data does not appear to be in a KDBush format.");let n=i>>4;if(n!==1)throw Error(`Got v${n} data when expected v1.`);let a=dc[i&15];if(!a)throw Error("Unrecognized array type.");let[s]=new Uint16Array(e,2,1),[o]=new Uint32Array(e,4,1);return new zd(o,s,a,void 0,e)}constructor(e,r=64,i=Float64Array,n=ArrayBuffer,a){if(isNaN(e)||e<0)throw Error(`Unexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+r,2),65535),this.ArrayType=i,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;let s=dc.indexOf(this.ArrayType),o=e*2*this.ArrayType.BYTES_PER_ELEMENT,l=e*this.IndexArrayType.BYTES_PER_ELEMENT,u=(8-l%8)%8;if(s<0)throw Error(`Unexpected typed array class: ${i}.`);if(a)this.data=a,this.ids=new this.IndexArrayType(a,8,e),this.coords=new i(a,8+l+u,e*2),this._pos=e*2,this._finished=!0;else{let h=this.data=new n(8+o+l+u);this.ids=new this.IndexArrayType(h,8,e),this.coords=new i(h,8+l+u,e*2),this._pos=0,this._finished=!1,new Uint8Array(h,0,2).set([219,16+s]),new Uint16Array(h,2,1)[0]=r,new Uint32Array(h,4,1)[0]=e}}add(e,r){let i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=e,this.coords[this._pos++]=r,i}finish(){let e=this._pos>>1;if(e!==this.numItems)throw Error(`Added ${e} items when expected ${this.numItems}.`);return Xo(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,r,i,n){if(!this._finished)throw Error("Data not yet indexed - call index.finish().");let{ids:a,coords:s,nodeSize:o}=this;dt[0]=0,dt[1]=a.length-1,dt[2]=0;let l=3,u=[];for(;l>0;){let h=dt[--l],c=dt[--l],p=dt[--l];if(c-p<=o){for(let m=p;m<=c;m++){let g=s[2*m],x=s[2*m+1];g>=e&&g<=i&&x>=r&&x<=n&&u.push(a[m])}continue}let f=p+c>>1,d=s[2*f],y=s[2*f+1];d>=e&&d<=i&&y>=r&&y<=n&&u.push(a[f]),(h===0?e<=d:r<=y)&&(dt[l++]=p,dt[l++]=f-1,dt[l++]=1-h),(h===0?i>=d:n>=y)&&(dt[l++]=f+1,dt[l++]=c,dt[l++]=1-h)}return u}within(e,r,i){let n=[];return this.withinInto(e,r,i,n),n}withinInto(e,r,i,n){if(!this._finished)throw Error("Data not yet indexed - call index.finish().");let{ids:a,coords:s,nodeSize:o}=this;dt[0]=0,dt[1]=a.length-1,dt[2]=0;let l=3,u=0,h=i*i;for(;l>0;){let c=dt[--l],p=dt[--l],f=dt[--l];if(p-f<=o){for(let g=f;g<=p;g++)yc(s[2*g],s[2*g+1],e,r)<=h&&(n[u++]=a[g]);continue}let d=f+p>>1,y=s[2*d],m=s[2*d+1];yc(y,m,e,r)<=h&&(n[u++]=a[d]),(c===0?e-i<=y:r-i<=m)&&(dt[l++]=f,dt[l++]=d-1,dt[l++]=1-c),(c===0?e+i>=y:r+i>=m)&&(dt[l++]=d+1,dt[l++]=p,dt[l++]=1-c)}return u}};function Xo(t,e,r,i,n,a){if(n-i<=r)return;let s=i+n>>1;Ld(t,e,s,i,n,a),Xo(t,e,r,i,s-1,1-a),Xo(t,e,r,s+1,n,1-a)}function Ld(t,e,r,i,n,a){for(;n>i;){if(n-i>600){let u=n-i+1,h=r-i+1,c=Math.log(u),p=.5*Math.exp(2*c/3),f=.5*Math.sqrt(c*p*(u-p)/u)*(h-u/2<0?-1:1);Ld(t,e,r,Math.max(i,Math.floor(r-h*p/u+f)),Math.min(n,Math.floor(r+(u-h)*p/u+f)),a)}let s=e[2*r+a],o=i,l=n;for(Mi(t,e,i,r),e[2*n+a]>s&&Mi(t,e,i,n);o<l;){for(Mi(t,e,o,l),o++,l--;e[2*o+a]<s;)o++;for(;e[2*l+a]>s;)l--}e[2*i+a]===s?Mi(t,e,i,l):(l++,Mi(t,e,l,n)),l<=r&&(i=l+1),r<=l&&(n=l-1)}}function Mi(t,e,r,i){Ns(t,r,i),Ns(e,2*r,2*i),Ns(e,2*r+1,2*i+1)}function Ns(t,e,r){let i=t[e];t[e]=t[r],t[r]=i}function yc(t,e,r,i){let n=t-r,a=e-i;return n*n+a*a}var Wo={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:t=>t},b2=class{constructor(t){this.options=Object.assign(Object.create(Wo),t),this.trees=Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[],this.points=[]}load(t){let e=[];for(let r of t){if(!r.geometry)continue;let[i,n]=r.geometry.coordinates,[a,s]=[Xr(i),Wr(n)],o={id:r.id,type:"Point",geometry:[a,s],tags:r.properties};e.push(o)}this.createIndex(e)}initialize(t){let e=[];for(let r of t)r.type==="Point"&&e.push(r);this.createIndex(e)}updateIndex(t,e,r){this.options=Object.assign(Object.create(Wo),r.clusterOptions),this.initialize(t)}createIndex(t){let{log:e,minZoom:r,maxZoom:i}=this.options;e&&console.time("total time");let n=`prepare ${t.length} points`;e&&console.time(n),this.points=t;let a=[];for(let o=0;o<t.length;o++){let l=t[o];if(!l?.geometry)continue;let[u,h]=l.geometry;u=Math.fround(u),h=Math.fround(h),a.push(u,h,1/0,o,-1,1),this.options.reduce&&a.push(0)}let s=this.trees[i+1]=this.createTree(a);e&&console.timeEnd(n);for(let o=i;o>=r;o--){let l=Date.now();s=this.trees[o]=this.createTree(this.cluster(s,o)),e&&console.log("z%d: %d clusters in %dms",o,s.numItems,Date.now()-l)}e&&console.timeEnd("total time")}getClusters(t,e){return this.getClustersInternal(t,e).map(r=>Da(r))}getClustersInternal(t,e){let r=((t[0]+180)%360+360)%360-180,i=Math.max(-90,Math.min(90,t[1])),n=t[2]===180?180:((t[2]+180)%360+360)%360-180,a=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)r=-180,n=180;else if(r>n){let h=this.getClustersInternal([r,i,180,a],e),c=this.getClustersInternal([-180,i,n,a],e);return h.concat(c)}let s=this.trees[this.limitZoom(e)],o=s.range(Xr(r),Wr(a),Xr(n),Wr(i)),l=s.flatData,u=[];for(let h of o){let c=this.stride*h;u.push(l[c+5]>1?w2(l,c,this.clusterProps):this.points[l[c+3]])}return u}getChildren(t){let e=this.getOriginId(t),r=this.getOriginZoom(t),i=Error("No cluster with the specified id: "+t),n=this.trees[r];if(!n)throw i;let a=n.flatData;if(e*this.stride>=a.length)throw i;let s=this.options.radius/(this.options.extent*2**(r-1)),o=a[e*this.stride],l=a[e*this.stride+1],u=n.within(o,l,s),h=[];for(let c of u){let p=c*this.stride;a[p+4]===t&&h.push(a[p+5]>1?D2(a,p,this.clusterProps):Da(this.points[a[p+3]]))}if(h.length===0)throw i;return h}getLeaves(t,e,r){e||(e=10),r||(r=0);let i=[];return this.appendLeaves(i,t,e,r,0),i}getTile(t,e,r){let i=this.trees[this.limitZoom(t)];if(!i)return null;let n=2**t,{extent:a,radius:s}=this.options,o=s/a,l=(r-o)/n,u=(r+1+o)/n,h={transformed:!0,features:[],source:null,x:e,y:r,z:t};return this.addTileFeatures(i.range((e-o)/n,l,(e+1+o)/n,u),i.flatData,e,r,n,h),e===0&&this.addTileFeatures(i.range(1-o/n,l,1,u),i.flatData,n,r,n,h),e===n-1&&this.addTileFeatures(i.range(0,l,o/n,u),i.flatData,-1,r,n,h),h}getClusterExpansionZoom(t){return this.getOriginZoom(t)}appendLeaves(t,e,r,i,n){let a=this.getChildren(e);for(let s of a){let o=s.properties;if(o?.cluster?n+o.point_count<=i?n+=o.point_count:n=this.appendLeaves(t,o.cluster_id,r,i,n):n<i?n++:t.push(s),t.length===r)break}return n}createTree(t){let e=new v2(t.length/this.stride|0,this.options.nodeSize,Float32Array);for(let r=0;r<t.length;r+=this.stride)e.add(t[r],t[r+1]);return e.finish(),e.flatData=t,e.data=null,e}addTileFeatures(t,e,r,i,n,a){for(let s of t){let o=s*this.stride,l=e[o+5]>1,u,h,c;if(l)u=Kl(e,o,this.clusterProps),h=e[o],c=e[o+1];else{let d=this.points[e[o+3]];u=d.tags,[h,c]=d.geometry}let p={type:1,geometry:[[Math.round(this.options.extent*(h*n-r)),Math.round(this.options.extent*(c*n-i))]],tags:u},f;f=l||this.options.generateId?e[o+3]:this.points[e[o+3]].id,f!==void 0&&(p.id=f),a.features.push(p)}}limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}cluster(t,e){let{radius:r,extent:i,reduce:n,minPoints:a}=this.options,s=r/(i*2**e),o=t.flatData,l=[],u=this.stride;for(let h=0;h<o.length;h+=u){if(o[h+2]<=e)continue;o[h+2]=e;let c=o[h],p=o[h+1],f=t.within(o[h],o[h+1],s),d=o[h+5],y=d;for(let m of f){let g=m*u;o[g+2]>e&&(y+=o[g+5])}if(y>d&&y>=a){let m=c*d,g=p*d,x,b=-1,v=((h/u|0)<<5)+(e+1)+this.points.length;for(let w of f){let _=w*u;if(o[_+2]<=e)continue;o[_+2]=e;let A=o[_+5];m+=o[_]*A,g+=o[_+1]*A,o[_+4]=v,n&&(x||(x=this.map(o,h,!0),b=this.clusterProps.length,this.clusterProps.push(x)),n(x,this.map(o,_)))}o[h+4]=v,l.push(m/y,g/y,1/0,v,-1,y),n&&l.push(b)}else{for(let m=0;m<u;m++)l.push(o[h+m]);if(y>1)for(let m of f){let g=m*u;if(!(o[g+2]<=e)){o[g+2]=e;for(let x=0;x<u;x++)l.push(o[g+x])}}}}return l}getOriginId(t){return t-this.points.length>>5}getOriginZoom(t){return(t-this.points.length)%32}map(t,e,r){if(t[e+5]>1){let a=this.clusterProps[t[e+6]];return r?Object.assign({},a):a}let i=this.points[t[e+3]].tags,n=this.options.map(i);return r&&n===i?Object.assign({},n):n}};function w2(t,e,r){return{id:t[e+3],type:"Point",tags:Kl(t,e,r),geometry:[t[e],t[e+1]]}}function D2(t,e,r){return{type:"Feature",id:t[e+3],properties:Kl(t,e,r),geometry:{type:"Point",coordinates:[Md(t[e]),Bd(t[e+1])]}}}function Kl(t,e,r){let i=t[e+5],n=i>=1e4?`${Math.round(i/1e3)}k`:i>=1e3?`${Math.round(i/100)/10}k`:i,a=t[e+6],s=a===-1?{}:Object.assign({},r[a]);return Object.assign(s,{cluster:!0,cluster_id:t[e+3],point_count:i,point_count_abbreviated:n})}var Vd="geojsonvt_clip_start",Od="geojsonvt_clip_end";function mc(t,e,r,i,n){let a=e===n.maxZoom?0:n.tolerance/((1<<e)*n.extent),s={transformed:!1,features:[],source:null,x:r,y:i,z:e,minX:2,minY:1,maxX:-1,maxY:0,numPoints:0,numSimplified:0,numFeatures:t.length};for(let o of t)_2(s,o,a,n);return s}function _2(t,e,r,i){switch(t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),e.type){case"Point":case"MultiPoint":A2(t,e);return;case"LineString":S2(t,e,r,i);return;case"MultiLineString":case"Polygon":E2(t,e,r);return;case"MultiPolygon":F2(t,e,r);return}}function A2(t,e){let r=[];for(let n=0;n<e.geometry.length;n+=3)r.push(e.geometry[n],e.geometry[n+1]),t.numPoints++,t.numSimplified++;if(!r.length)return;let i={type:1,tags:e.tags||null,geometry:r};e.id!==null&&(i.id=e.id),t.features.push(i)}function S2(t,e,r,i){let n=[];if(Jl(n,e.geometry,t,r,!1,!1),!n.length)return;let a=e.tags||null;if(i.lineMetrics){a={};for(let o in e.tags)a[o]=e.tags[o];a[Vd]=e.geometry.start/e.geometry.size,a[Od]=e.geometry.end/e.geometry.size}let s={type:2,tags:a,geometry:n};e.id!==null&&(s.id=e.id),t.features.push(s)}function E2(t,e,r){let i=[];for(let a=0;a<e.geometry.length;a++)Jl(i,e.geometry[a],t,r,e.type==="Polygon",a===0);if(!i.length)return;let n={type:e.type==="Polygon"?3:2,tags:e.tags||null,geometry:i};e.id!==null&&(n.id=e.id),t.features.push(n)}function F2(t,e,r){let i=[];for(let a=0;a<e.geometry.length;a++){let s=e.geometry[a];for(let o=0;o<s.length;o++)Jl(i,s[o],t,r,!0,o===0)}if(!i.length)return;let n={type:3,tags:e.tags||null,geometry:i};e.id!==null&&(n.id=e.id),t.features.push(n)}function Jl(t,e,r,i,n,a){let s=i*i;if(i>0&&e.size<(n?s:i)){r.numPoints+=e.points.length/3;return}let o=[];for(let l=0;l<e.points.length;l+=3)(i===0||e.points[l+2]>s)&&(r.numSimplified++,o.push(e.points[l],e.points[l+1])),r.numPoints++;n&&T2(o,a),t.push(o)}function T2(t,e){let r=0;for(let i=0,n=t.length,a=n-2;i<n;a=i,i+=2)r+=(t[i]-t[a])*(t[i+1]+t[a+1]);if(r>0===e)for(let i=0,n=t.length;i<n/2;i+=2){let a=t[i],s=t[i+1];t[i]=t[n-2-i],t[i+1]=t[n-1-i],t[n-2-i]=a,t[n-1-i]=s}}function gc(t,e){if(t.transformed)return t;let r=1<<t.z,i=t.x,n=t.y;for(let a of t.features)a.type===1?k2(a,e,r,i,n):I2(a,e,r,i,n);return t.transformed=!0,t}function k2(t,e,r,i,n){let a=t,s=t.geometry,o=[];for(let l=0;l<s.length;l+=2)o.push(Rd(s[l],s[l+1],e,r,i,n));return a.geometry=o,a}function I2(t,e,r,i,n){let a=t,s=t.geometry,o=[];for(let l of s){let u=[];for(let h=0;h<l.length;h+=2)u.push(Rd(l[h],l[h+1],e,r,i,n));o.push(u)}return a.geometry=o,a}function Rd(t,e,r,i,n,a){return[Math.round(r*(t*i-n)),Math.round(r*(e*i-a))]}var C2=class{constructor(t){this.options=t,this.total=0,this.stats={},this.tiles={},this.tileCoords=[],this.stats={},this.total=0}initialize(t){this.splitTile(t,0,0,0),this.options.debug&&(t.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)))}updateIndex(t,e,r){r.debug>1&&(console.log("invalidating tiles"),console.time("invalidating")),this.invalidateTiles(e),r.debug>1&&console.timeEnd("invalidating");let[i,n,a]=[0,0,0],s=mc(t,i,n,a,r);s.source=t;let o=Wn(i,n,a);if(this.tiles[o]=s,this.tileCoords.push({z:i,x:n,y:a,id:o}),r.debug){let l=`z${i}`;this.stats[l]=(this.stats[l]||0)+1,this.total++}}getClusterExpansionZoom(t){return null}getChildren(t){return null}getLeaves(t,e,r){return null}getTile(t,e,r){let{extent:i,debug:n}=this.options,a=1<<t;e=e+a&a-1;let s=Wn(t,e,r);if(this.tiles[s])return gc(this.tiles[s],i);n>1&&console.log("drilling down to z%d-%d-%d",t,e,r);let o=t,l=e,u=r,h;for(;!h&&o>0;)o--,l>>=1,u>>=1,h=this.tiles[Wn(o,l,u)];return!h?.source||(n>1&&(console.log("found parent tile z%d-%d-%d",o,l,u),console.time("drilling down")),this.splitTile(h.source,o,l,u,t,e,r),n>1&&console.timeEnd("drilling down"),!this.tiles[s])?null:gc(this.tiles[s],i)}splitTile(t,e,r,i,n,a,s){let o=[t,e,r,i],l=this.options,u=l.debug;for(;o.length;){i=o.pop(),r=o.pop(),e=o.pop(),t=o.pop();let h=1<<e,c=Wn(e,r,i),p=this.tiles[c];if(!p&&(u>1&&console.time("creation"),p=this.tiles[c]=mc(t,e,r,i,l),this.tileCoords.push({z:e,x:r,y:i,id:c}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,r,i,p.numFeatures,p.numPoints,p.numSimplified),console.timeEnd("creation"));let A=`z${e}`;this.stats[A]=(this.stats[A]||0)+1,this.total++}if(p.source=t,n==null){if(e===l.indexMaxZoom||p.numPoints<=l.indexMaxPoints)continue}else{if(e===l.maxZoom||e===n)continue;if(n!=null){let A=n-e;if(r!==a>>A||i!==s>>A)continue}}if(p.source=null,!t.length)continue;u>1&&console.time("clipping");let f=.5*l.buffer/l.extent,d=.5-f,y=.5+f,m=1+f,g=null,x=null,b=null,v=null,w=ke(t,h,r-f,r+y,0,p.minX,p.maxX,l),_=ke(t,h,r+d,r+m,0,p.minX,p.maxX,l);w&&(g=ke(w,h,i-f,i+y,1,p.minY,p.maxY,l),x=ke(w,h,i+d,i+m,1,p.minY,p.maxY,l)),_&&(b=ke(_,h,i-f,i+y,1,p.minY,p.maxY,l),v=ke(_,h,i+d,i+m,1,p.minY,p.maxY,l)),u>1&&console.timeEnd("clipping"),o.push(g||[],e+1,r*2,i*2),o.push(x||[],e+1,r*2,i*2+1),o.push(b||[],e+1,r*2+1,i*2),o.push(v||[],e+1,r*2+1,i*2+1)}}invalidateTiles(t){if(!t.length)return;let e=this.options,{debug:r}=e,i=1/0,n=-1/0,a=1/0,s=-1/0;for(let u of t)i=Math.min(i,u.minX),n=Math.max(n,u.maxX),a=Math.min(a,u.minY),s=Math.max(s,u.maxY);let o=e.buffer/e.extent,l=new Set;for(let u in this.tiles){let h=this.tiles[u],c=1<<h.z,p=(h.x-o)/c,f=(h.x+1+o)/c,d=(h.y-o)/c,y=(h.y+1+o)/c;if(n<p||i>=f||s<d||a>=y)continue;let m=!1;for(let g of t)if(g.maxX>=p&&g.minX<f&&g.maxY>=d&&g.minY<y){m=!0;break}if(m){if(r){r>1&&console.log("invalidate tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",h.z,h.x,h.y,h.numFeatures,h.numPoints,h.numSimplified);let g=`z${h.z}`;this.stats[g]=(this.stats[g]||0)-1,this.total--}delete this.tiles[u],l.add(u)}}l.size&&(this.tileCoords=this.tileCoords.filter(u=>!l.has(u.id)))}};function Wn(t,e,r){return((1<<t)*r+e)*32+t}var M2={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,updateable:!1,cluster:!1,clusterOptions:Wo,debug:0},$d=class{constructor(t,e){e=this.options=Object.assign({},M2,e);let r=e.debug;if(r&&console.time("preprocess data"),e.maxZoom<0||e.maxZoom>24)throw Error("maxZoom should be in the 0-24 range");if(e.promoteId&&e.generateId)throw Error("promoteId and generateId cannot be used together.");let i=Yl(t,e);r&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",e.indexMaxZoom,e.indexMaxPoints),console.time("generate tiles")),i=Hl(i,e),e.updateable&&(this.source=i),this.initializeIndex(i,e)}initializeIndex(t,e){this.tileIndex=e.cluster?new b2(e.clusterOptions):new C2(e),t.length&&this.tileIndex.initialize(t)}getTile(t,e,r){return t=+t,e=+e,r=+r,t<0||t>24?null:this.tileIndex.getTile(t,e,r)}updateData(t,e){let r=this.options;if(!r.updateable)throw Error("to update tile geojson `updateable` option must be set to true");let{affected:i,source:n}=m2(this.source,t,r);e&&({affected:i,source:n}=this.filterUpdate(n,i,e)),i.length&&(this.source=n,this.tileIndex.updateIndex(n,i,r))}filterUpdate(t,e,r){let i=new Set;for(let n of t)n.id!=null&&(r(Da(n))||(e.push(n),i.add(n.id)));return t=t.filter(n=>!i.has(n.id)),{affected:e,source:t}}getData(){if(!this.options.updateable)throw Error("to retrieve data the `updateable` option must be set to true");return a2(this.source)}updateClusterOptions(t,e){let r=this.options.cluster;if(this.options.cluster=t,this.options.clusterOptions=e,r==t){this.tileIndex.updateIndex(this.source,[],this.options);return}this.initializeIndex(this.source,this.options)}getClusterExpansionZoom(t){return this.tileIndex.getClusterExpansionZoom(t)}getClusterChildren(t){return this.tileIndex.getChildren(t)}getClusterLeaves(t,e,r){return this.tileIndex.getLeaves(t,e,r)}},Zo=St([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),B2=Zo.members;Zo.size,Zo.alignment;var Ho=St([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),P2=Ho.members;Ho.size,Ho.alignment;var z2=Math.cos(75/2*(Math.PI/180)),Nd=1/2,xc=2**14/Nd,Ud=class{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(e=>e.id),this.index=t.index,this.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={};for(let e of this.layers)this.gradients[e.id]={};this.layoutVertexArray=new ng,this.layoutVertexArray2=new ag,this.indexArray=new xn,this.programConfigurations=new gr(t.layers,t.zoom),this.segments=new te,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(t,e,r){this.hasDependencies=xa("line",this.layers,e)||this.hasLineDasharray(this.layers);let i=this.layers[0].layout.get("line-sort-key"),n=!i.isConstant(),a=[],s=new at(this.zoom),o=this.layers[0]._featureFilter.needGeometry;for(let{feature:l,id:u,index:h,sourceLayerIndex:c}of t){let p=li(l,o);if(!this.layers[0]._featureFilter.filter(s,p,r))continue;let f=n?i.evaluate(p,{},r):void 0,d={id:u,properties:l.properties,type:l.type,sourceLayerIndex:c,index:h,geometry:o?p.geometry:Dr(l),patterns:{},dashes:{},sortKey:f};a.push(d)}n&&a.sort((l,u)=>l.sortKey-u.sortKey);for(let l of a){let{geometry:u,index:h,sourceLayerIndex:c}=l;this.hasDependencies?(xa("line",this.layers,e)?Ul("line",this.layers,l,{zoom:this.zoom},e):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,l,this.zoom,e),this.patternFeatures.push(l)):this.addFeature(l,u,h,r,{},{},e.subdivisionGranularity);let p=t[h].feature;e.featureIndex.insert(p,u,h,c,this.index)}}update(t,e,r,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,{imagePositions:r,dashPositions:i})}addFeatures({options:t,canonical:e,patternPositions:r,dashPositions:i}){for(let n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,e,r,i,t.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,P2)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,B2),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&Object.hasOwn(t.properties,"geojsonvt_clip_start")&&Object.hasOwn(t.properties,"geojsonvt_clip_end"))return{start:+t.properties[Vd],end:+t.properties[Od]}}addFeature(t,e,r,i,n,a,s){let o=this.layers[0].layout,l=o.get("line-join").evaluate(t,{}),u=o.get("line-cap").evaluate(t,{}),h=o.get("line-miter-limit").evaluate(t,{}),c=o.get("line-round-limit").evaluate(t,{});this.lineClips=this.lineFeatureClips(t);for(let p of e)this.addLine(p,t,l,u,h,c,i,s);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,{imagePositions:n,dashPositions:a,canonical:i})}addLine(t,e,r,i,n,a,s,o){this.distance=0,this.scaledDistance=0,this.totalDistance=0;let l=s?o.line.getGranularityForZoomLevel(s.z):1;if(t=hr(t,l),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let b=0;b<t.length-1;b++)this.totalDistance+=t[b].dist(t[b+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}let u=vn.types[e.type]==="Polygon",h=t.length;for(;h>=2&&t[h-1].equals(t[h-2]);)h--;let c=0;for(;c<h-1&&t[c].equals(t[c+1]);)c++;if(h-c<(u?3:2))return;r==="bevel"&&(n=1.05);let p=this.overscaling<=16?15*mt/(512*this.overscaling):0,f=this.segments.prepareSegment(h*10,this.layoutVertexArray,this.indexArray),d,y,m,g,x;this.e1=this.e2=-1,u&&(d=t[h-2],x=t[c].sub(d)._unit()._perp());for(let b=c;b<h;b++){if(m=b===h-1?u?t[c+1]:void 0:t[b+1],m&&t[b].equals(m))continue;x&&(g=x),d&&(y=d),d=t[b],x=m?m.sub(d)._unit()._perp():g,g||(g=x);let v=g.add(x);(v.x!==0||v.y!==0)&&v._unit();let w=g.x*x.x+g.y*x.y,_=v.x*x.x+v.y*x.y,A=_===0?1/0:1/_,S=2*Math.sqrt(2-2*_),F=_<z2&&y&&m,L=g.x*x.y-g.y*x.x>0;if(F&&b>c){let R=d.dist(y);if(R>2*p){let E=d.sub(d.sub(y)._mult(p/R)._round());this.updateDistance(y,E),this.addCurrentVertex(E,g,0,0,f),y=E}}let V=y&&m,P=V?r:u?"butt":i;if(V&&P==="round"&&(A<a?P="miter":A<=2&&(P="fakeround")),P==="miter"&&A>n&&(P="bevel"),P==="bevel"&&(A>2&&(P="flipbevel"),A<n&&(P="miter")),y&&this.updateDistance(y,d),P==="miter")v._mult(A),this.addCurrentVertex(d,v,0,0,f);else if(P==="flipbevel"){if(A>100)v=x.mult(-1);else{let R=A*g.add(x).mag()/g.sub(x).mag();v._perp()._mult(R*(L?-1:1))}this.addCurrentVertex(d,v,0,0,f),this.addCurrentVertex(d,v.mult(-1),0,0,f)}else if(P==="bevel"||P==="fakeround"){let R=-Math.sqrt(A*A-1),E=L?R:0,$=L?0:R;if(y&&this.addCurrentVertex(d,g,E,$,f),P==="fakeround"){let O=Math.round(S*180/Math.PI/20);for(let M=1;M<O;M++){let j=M/O;if(j!==.5){let pt=j-.5,st=1.0904+w*(-3.2452+w*(3.55645-w*1.43519)),ft=.848013+w*(-1.06021+w*.215638);j+=j*pt*(j-1)*(st*pt*pt+ft)}let it=x.sub(g)._mult(j)._add(g)._unit()._mult(L?-1:1);this.addHalfVertex(d,it.x,it.y,!1,L,0,f)}}m&&this.addCurrentVertex(d,x,-E,-$,f)}else if(P==="butt")this.addCurrentVertex(d,v,0,0,f);else if(P==="square"){let R=y?1:-1;this.addCurrentVertex(d,v,R,R,f)}else P==="round"&&(y&&(this.addCurrentVertex(d,g,0,0,f),this.addCurrentVertex(d,g,1,1,f,!0)),m&&(this.addCurrentVertex(d,x,-1,-1,f,!0),this.addCurrentVertex(d,x,0,0,f)));if(F&&b<h-1){let R=d.dist(m);if(R>2*p){let E=d.add(m.sub(d)._mult(p/R)._round());this.updateDistance(d,E),this.addCurrentVertex(E,x,0,0,f),d=E}}}}addCurrentVertex(t,e,r,i,n,a=!1){let s=e.x+e.y*r,o=e.y-e.x*r,l=-e.x+e.y*i,u=-e.y-e.x*i;this.addHalfVertex(t,s,o,a,!1,r,n),this.addHalfVertex(t,l,u,a,!0,-i,n),this.distance>xc/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,e,r,i,n,a))}addHalfVertex({x:t,y:e},r,i,n,a,s,o){let l=(this.lineClips?this.scaledDistance*(xc-1):this.scaledDistance)*Nd;if(this.layoutVertexArray.emplaceBack((t<<1)+ +!!n,(e<<1)+ +!!a,Math.round(63*r)+128,Math.round(63*i)+128,(s===0?0:s<0?-1:1)+1|(l&63)<<2,l>>6),this.lineClips){let h=(this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start);this.layoutVertexArray2.emplaceBack(h,this.lineClipsArray.length)}let u=o.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,u,this.e2),o.primitiveLength++),a?this.e2=u:this.e1=u}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}hasLineDasharray(t){for(let e of t){let r=e.paint.get("line-dasharray");if(r&&!r.isConstant())return!0}return!1}addLineDashDependencies(t,e,r,i){for(let n of t){let a=n.paint.get("line-dasharray");if(!a||a.value.kind==="constant")continue;let s=n.layout.get("line-cap").evaluate(e,{})==="round",o={dasharray:a.value.evaluate({zoom:r-1},e,{}),round:s},l={dasharray:a.value.evaluate({zoom:r},e,{}),round:s},u={dasharray:a.value.evaluate({zoom:r+1},e,{}),round:s},h=`${o.dasharray.join(",")},${o.round}`,c=`${l.dasharray.join(",")},${l.round}`,p=`${u.dasharray.join(",")},${u.round}`;i.dashDependencies[h]=o,i.dashDependencies[c]=l,i.dashDependencies[p]=u,e.dashes[n.id]={min:h,mid:c,max:p}}}};I("LineBucket",Ud,{omit:["layers","patternFeatures"]});var vc,L2=()=>vc||(vc=new jt({"line-cap":new U(D.layout_line["line-cap"],"line-cap"),"line-join":new U(D.layout_line["line-join"],"line-join"),"line-miter-limit":new U(D.layout_line["line-miter-limit"],"line-miter-limit"),"line-round-limit":new U(D.layout_line["line-round-limit"],"line-round-limit"),"line-sort-key":new U(D.layout_line["line-sort-key"],"line-sort-key")})),bc,V2=()=>bc||(bc=new jt({"line-opacity":new U(D.paint_line["line-opacity"],"line-opacity"),"line-layer-opacity":new z(D.paint_line["line-layer-opacity"],"line-layer-opacity"),"line-color":new U(D.paint_line["line-color"],"line-color"),"line-translate":new z(D.paint_line["line-translate"],"line-translate"),"line-translate-anchor":new z(D.paint_line["line-translate-anchor"],"line-translate-anchor"),"line-width":new U(D.paint_line["line-width"],"line-width"),"line-gap-width":new U(D.paint_line["line-gap-width"],"line-gap-width"),"line-offset":new U(D.paint_line["line-offset"],"line-offset"),"line-blur":new U(D.paint_line["line-blur"],"line-blur"),"line-dasharray":new nn(D.paint_line["line-dasharray"],"line-dasharray"),"line-pattern":new nn(D.paint_line["line-pattern"],"line-pattern"),"line-gradient":new Ua(D.paint_line["line-gradient"],"line-gradient")})),wc={get paint(){return V2()},get layout(){return L2()}},O2=class extends U{possiblyEvaluate(t,e){return e=new at(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,r,i){return e=qt({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,r,i)}},Zn;var R2=class extends pe{constructor(t,e){super(t,wc,e),this.gradientVersion=0,Zn||(Zn=new O2(wc.paint.properties["line-width"].specification,"line-floorwidth"),Zn.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(t){if(t==="line-gradient"){let e=this.gradientExpression();this.stepInterpolant=dm(e)?e._styleExpression.expression instanceof ml:!1,this.gradientVersion=(this.gradientVersion+1)%(2**53-1)}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=Zn.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new Ud(t)}queryRadius(t){let e=t,r=Dc(Yr("line-width",this,e),Yr("line-gap-width",this,e)),i=Yr("line-offset",this,e);return r/2+Math.abs(i)+ja(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:r,geometry:i,transform:n,pixelsToTileUnits:a}){let s=Ga(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-n.bearingInRadians,a),o=a/2*Dc(this.paint.get("line-width").evaluate(e,r),this.paint.get("line-gap-width").evaluate(e,r)),l=this.paint.get("line-offset").evaluate(e,r);return l&&(i=Fg(i,l*a)),wg(s,i,o)}isTileClipped(){return!0}};function Dc(t,e){return e>0?e+2*t:t}var $2=St([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"},{name:"a_height_offset",components:1,type:"Float32"}],4),N2=St([{name:"a_projected_pos",components:3,type:"Float32"}],4);St([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);var U2=St([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);St([{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"}]);var _c=St([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),o5=St([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);St([{name:"triangle",components:3,type:"Uint16"}]),St([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Float32",name:"heightOffset"}]),St([{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:"heightOffset"}]),St([{type:"Float32",name:"offsetX"}]),St([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),St([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);var vr=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(t){this.pluginStatus=t.pluginStatus,this.pluginURL=t.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(t){if(vr.isParsed())throw Error("RTL text plugin already registered.");this.applyArabicShaping=t.applyArabicShaping,this.processBidirectionalText=t.processBidirectionalText,this.processStyledBidirectionalText=t.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return this.applyArabicShaping!=null&&this.processBidirectionalText!=null&&this.processStyledBidirectionalText!=null}getRTLTextPluginStatus(){return this.pluginStatus}async syncState(t,e){if(this.isParsed())return this.getState();if(t.pluginStatus!=="loading")return this.setState(t),t;let r=t.pluginURL,i=new Promise(a=>{this.loadScriptResolve=a}),n=new Promise(a=>setTimeout(()=>a(),this.TIMEOUT));if(await e(r),await Promise.race([i,n]),this.isParsed()){let a={pluginStatus:"loaded",pluginURL:r};return this.setState(a),a}throw this.setState({pluginStatus:"error",pluginURL:""}),Error(`RTL Text Plugin failed to import scripts from ${r}`)}};function q2(t){return/[\\u0600-\\u0604\\u0606-\\u060B\\u060D-\\u061A\\u061C-\\u061E\\u0620-\\u063F\\u0641-\\u064A\\u0656-\\u066F\\u0671-\\u06DC\\u06DE-\\u070D\\u070F-\\u074A\\u074D-\\u077F\\u07C0-\\u07FA\\u07FD-\\u07FF\\u0840-\\u085B\\u085E\\u0860-\\u086A\\u0870-\\u0891\\u0897-\\u08E1\\u08E3-\\u08FF\\u1800\\u1801\\u1804\\u1806-\\u1819\\u1820-\\u1878\\u1880-\\u18AA\\uA840-\\uA877\\uFB50-\\uFD3D\\uFD40-\\uFDCF\\uFDF0-\\uFDFF\\uFE70-\\uFE74\\uFE76-\\uFEFC]|\\uD802[\\uDEC0-\\uDEE6\\uDEEB-\\uDEF6\\uDF80-\\uDF91\\uDF99-\\uDF9C\\uDFA9-\\uDFAF]|\\uD803[\\uDD00-\\uDD27\\uDD30-\\uDD39\\uDE60-\\uDE7E\\uDEC2-\\uDEC7\\uDED0-\\uDED8\\uDEFA-\\uDEFF\\uDF30-\\uDF59\\uDF70-\\uDF89\\uDFB0-\\uDFCB]|\\uD805[\\uDE60-\\uDE6C]|\\uD82F[\\uDC00-\\uDC6A\\uDC70-\\uDC7C\\uDC80-\\uDC88\\uDC90-\\uDC99\\uDC9C-\\uDC9F]|\\uD83A[\\uDD00-\\uDD4B\\uDD50-\\uDD59\\uDD5E\\uDD5F]|\\uD83B[\\uDE00-\\uDE03\\uDE05-\\uDE1F\\uDE21\\uDE22\\uDE24\\uDE27\\uDE29-\\uDE32\\uDE34-\\uDE37\\uDE39\\uDE3B\\uDE42\\uDE47\\uDE49\\uDE4B\\uDE4D-\\uDE4F\\uDE51\\uDE52\\uDE54\\uDE57\\uDE59\\uDE5B\\uDE5D\\uDE5F\\uDE61\\uDE62\\uDE64\\uDE67-\\uDE6A\\uDE6C-\\uDE72\\uDE74-\\uDE77\\uDE79-\\uDE7C\\uDE7E\\uDE80-\\uDE89\\uDE8B-\\uDE9B\\uDEA1-\\uDEA3\\uDEA5-\\uDEA9\\uDEAB-\\uDEBB\\uDEF0\\uDEF1]/gim.test(String.fromCodePoint(t))}function j2(t){return/[\\u0591-\\u05C7\\u05D0-\\u05EA\\u05EF-\\u05F4\\u0600-\\u0604\\u0606-\\u060B\\u060D-\\u061A\\u061C-\\u061E\\u0620-\\u063F\\u0641-\\u064A\\u0656-\\u066F\\u0671-\\u06DC\\u06DE-\\u070D\\u070F-\\u074A\\u074D-\\u07B1\\u07C0-\\u07FA\\u07FD-\\u082D\\u0830-\\u083E\\u0840-\\u085B\\u085E\\u0860-\\u086A\\u0870-\\u0891\\u0897-\\u08E1\\u08E3-\\u08FF\\uFB1D-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFD3D\\uFD40-\\uFDCF\\uFDF0-\\uFDFF\\uFE70-\\uFE74\\uFE76-\\uFEFC]|\\uD802[\\uDC00-\\uDC05\\uDC08\\uDC0A-\\uDC35\\uDC37\\uDC38\\uDC3C\\uDC3F-\\uDC55\\uDC57-\\uDC9E\\uDCA7-\\uDCAF\\uDCE0-\\uDCF2\\uDCF4\\uDCF5\\uDCFB-\\uDD1B\\uDD1F-\\uDD39\\uDD3F-\\uDD59\\uDD80-\\uDDB7\\uDDBC-\\uDDCF\\uDDD2-\\uDE03\\uDE05\\uDE06\\uDE0C-\\uDE13\\uDE15-\\uDE17\\uDE19-\\uDE35\\uDE38-\\uDE3A\\uDE3F-\\uDE48\\uDE50-\\uDE58\\uDE60-\\uDE9F\\uDEC0-\\uDEE6\\uDEEB-\\uDEF6\\uDF00-\\uDF35\\uDF39-\\uDF55\\uDF58-\\uDF72\\uDF78-\\uDF91\\uDF99-\\uDF9C\\uDFA9-\\uDFAF]|\\uD803[\\uDC00-\\uDC48\\uDC80-\\uDCB2\\uDCC0-\\uDCF2\\uDCFA-\\uDD27\\uDD30-\\uDD39\\uDD40-\\uDD65\\uDD69-\\uDD85\\uDD8E\\uDD8F\\uDE60-\\uDE7E\\uDE80-\\uDEA9\\uDEAB-\\uDEAD\\uDEB0\\uDEB1\\uDEC2-\\uDEC7\\uDED0-\\uDED8\\uDEFA-\\uDF27\\uDF30-\\uDF59\\uDF70-\\uDF89\\uDFB0-\\uDFCB\\uDFE0-\\uDFF6]|\\uD83A[\\uDC00-\\uDCC4\\uDCC7-\\uDCD6\\uDD00-\\uDD4B\\uDD50-\\uDD59\\uDD5E\\uDD5F]|\\uD83B[\\uDE00-\\uDE03\\uDE05-\\uDE1F\\uDE21\\uDE22\\uDE24\\uDE27\\uDE29-\\uDE32\\uDE34-\\uDE37\\uDE39\\uDE3B\\uDE42\\uDE47\\uDE49\\uDE4B\\uDE4D-\\uDE4F\\uDE51\\uDE52\\uDE54\\uDE57\\uDE59\\uDE5B\\uDE5D\\uDE5F\\uDE61\\uDE62\\uDE64\\uDE67-\\uDE6A\\uDE6C-\\uDE72\\uDE74-\\uDE77\\uDE79-\\uDE7C\\uDE7E\\uDE80-\\uDE89\\uDE8B-\\uDE9B\\uDEA1-\\uDEA3\\uDEA5-\\uDEA9\\uDEAB-\\uDEBB\\uDEF0\\uDEF1]/gim.test(String.fromCodePoint(t))}function G2(t){return/[\\u02EA\\u02EB\\u2E80-\\u2FDF\\u2FF0-\\u303F\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FD-\\u30FF\\u3105-\\u312F\\u31A0-\\u4DBF\\u4E00-\\uA48C\\uA490-\\uA4C6\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFE10-\\uFE1F\\uFE30-\\uFE4F\\uFF00-\\uFFEF]|\\uD81B[\\uDFE0-\\uDFFF]|[\\uD81C-\\uD822\\uD840-\\uD868\\uD86A-\\uD86D\\uD86F-\\uD872\\uD874-\\uD879\\uD880-\\uD883\\uD885-\\uD88C][\\uDC00-\\uDFFF]|\\uD823[\\uDC00-\\uDCD5\\uDCFF-\\uDD1E\\uDD80-\\uDDF2]|\\uD82B[\\uDFF0-\\uDFFF]|\\uD82C[\\uDC00-\\uDEFB]|\\uD83C[\\uDE00-\\uDEFF]|\\uD869[\\uDC00-\\uDEDF\\uDF00-\\uDFFF]|\\uD86E[\\uDC00-\\uDC1D\\uDC20-\\uDFFF]|\\uD873[\\uDC00-\\uDEAD\\uDEB0-\\uDFFF]|\\uD87A[\\uDC00-\\uDFE0\\uDFF0-\\uDFFF]|\\uD87B[\\uDC00-\\uDE5D]|\\uD87E[\\uDC00-\\uDE1D]|\\uD884[\\uDC00-\\uDF4A\\uDF50-\\uDFFF]|\\uD88D[\\uDC00-\\uDC79]/gim.test(String.fromCodePoint(t))}function Xa(t){return/[\\u02EA\\u02EB\\u1100-\\u11FF\\u1401-\\u167F\\u18B0-\\u18FF\\u2065\\u20DD-\\u20E0\\u20E2-\\u20E4\\u2B97\\u2BF0-\\u2BFF\\u2E50\\u2E51\\u2E80-\\u3007\\u3012\\u3013\\u3020-\\u302F\\u3031-\\u30FB\\u30FD-\\uA4CF\\uA960-\\uA97F\\uAC00-\\uD7FF\\uF900-\\uFAFF\\uFE10-\\uFE1F\\uFE30-\\uFE48\\uFE50-\\uFE57\\uFE5F-\\uFE62\\uFE67-\\uFE6F\\uFF00-\\uFF07\\uFF0A-\\uFF0C\\uFF0E-\\uFF19\\uFF1F-\\uFF3A\\uFF3C\\uFF3E\\uFF40-\\uFF5A\\uFFE0-\\uFFE2\\uFFE4-\\uFFE7\\uFFF0-\\uFFF8]|\\uD802[\\uDD80-\\uDD9F]|\\uD805[\\uDD80-\\uDDFF]|\\uD806[\\uDE00-\\uDEBF]|[\\uD80C-\\uD810\\uD81C-\\uD822\\uD83C\\uD83D\\uD840-\\uD87E\\uD880-\\uD8BE][\\uDC00-\\uDFFF]|\\uD811[\\uDC00-\\uDE7F]|\\uD81B[\\uDFE0-\\uDFFF]|\\uD823[\\uDC00-\\uDDFF]|\\uD82B[\\uDFF0-\\uDFFF]|\\uD82C[\\uDC00-\\uDEFF]|\\uD833[\\uDEC0-\\uDFCF]|\\uD834[\\uDC00-\\uDDFF\\uDEE0-\\uDF7F]|\\uD836[\\uDC00-\\uDEAF]|\\uD83E[\\uDD00-\\uDEFF]|[\\uD87F\\uD8BF][\\uDC00-\\uDFFD]/gim.test(String.fromCodePoint(t))}function Y2(t){return/[\\xA7\\xA9\\xAE\\xB1\\xBC-\\xBE\\xD7\\xF7\\u2016\\u2020\\u2021\\u2030\\u2031\\u203B\\u203C\\u2042\\u2047-\\u2049\\u2051\\u2100-\\u218F\\u221E\\u2234\\u2235\\u2300-\\u2307\\u230C-\\u231F\\u2324-\\u2328\\u232B\\u237D-\\u239A\\u23BE-\\u23CD\\u23CF\\u23D1-\\u23DB\\u23E2-\\u2422\\u2424-\\u24FF\\u25A0-\\u2619\\u2620-\\u2767\\u2776-\\u2793\\u2B12-\\u2B2F\\u2B50-\\u2B59\\u2BB8-\\u2BEB\\u3000-\\u303F\\u30A0-\\u30FF\\uE000-\\uF8FF\\uFE30-\\uFE6F\\uFF00-\\uFFEF\\uFFFC\\uFFFD]|[\\uDB80-\\uDBFF][\\uDC00-\\uDFFF]/gim.test(String.fromCodePoint(t))}function X2(t){return/[\\r\\u0300-\\u036F\\u0483-\\u0489\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u0600-\\u0605\\u0610-\\u061A\\u064B-\\u065F\\u0670\\u06D6-\\u06DD\\u06DF-\\u06E4\\u06E7\\u06E8\\u06EA-\\u06ED\\u070F\\u0711\\u0730-\\u074A\\u07A6-\\u07B0\\u07EB-\\u07F3\\u07FD\\u0816-\\u0819\\u081B-\\u0823\\u0825-\\u0827\\u0829-\\u082D\\u0859-\\u085B\\u0890\\u0891\\u0897-\\u089F\\u08CA-\\u0903\\u093A-\\u093C\\u093E-\\u094F\\u0951-\\u0957\\u0962\\u0963\\u0981-\\u0983\\u09BC\\u09BE-\\u09C4\\u09C7\\u09C8\\u09CB-\\u09CD\\u09D7\\u09E2\\u09E3\\u09FE\\u0A01-\\u0A03\\u0A3C\\u0A3E-\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A70\\u0A71\\u0A75\\u0A81-\\u0A83\\u0ABC\\u0ABE-\\u0AC5\\u0AC7-\\u0AC9\\u0ACB-\\u0ACD\\u0AE2\\u0AE3\\u0AFA-\\u0AFF\\u0B01-\\u0B03\\u0B3C\\u0B3E-\\u0B44\\u0B47\\u0B48\\u0B4B-\\u0B4D\\u0B55-\\u0B57\\u0B62\\u0B63\\u0B82\\u0BBE-\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCD\\u0BD7\\u0C00-\\u0C04\\u0C3C\\u0C3E-\\u0C44\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C62\\u0C63\\u0C81-\\u0C83\\u0CBC\\u0CBE-\\u0CC4\\u0CC6-\\u0CC8\\u0CCA-\\u0CCD\\u0CD5\\u0CD6\\u0CE2\\u0CE3\\u0CF3\\u0D00-\\u0D03\\u0D3B\\u0D3C\\u0D3E-\\u0D44\\u0D46-\\u0D48\\u0D4A-\\u0D4E\\u0D57\\u0D62\\u0D63\\u0D81-\\u0D83\\u0DCA\\u0DCF-\\u0DD4\\u0DD6\\u0DD8-\\u0DDF\\u0DF2\\u0DF3\\u0E31\\u0E33-\\u0E3A\\u0E47-\\u0E4E\\u0EB1\\u0EB3-\\u0EBC\\u0EC8-\\u0ECE\\u0F18\\u0F19\\u0F35\\u0F37\\u0F39\\u0F3E\\u0F3F\\u0F71-\\u0F84\\u0F86\\u0F87\\u0F8D-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u102D-\\u1037\\u1039-\\u103E\\u1056-\\u1059\\u105E-\\u1060\\u1071-\\u1074\\u1082\\u1084-\\u1086\\u108D\\u109D\\u1100-\\u11FF\\u135D-\\u135F\\u1712-\\u1715\\u1732-\\u1734\\u1752\\u1753\\u1772\\u1773\\u17B4-\\u17D3\\u17DD\\u180B-\\u180D\\u180F\\u1885\\u1886\\u18A9\\u1920-\\u192B\\u1930-\\u193B\\u1A17-\\u1A1B\\u1A55-\\u1A5E\\u1A60\\u1A62\\u1A65-\\u1A7C\\u1A7F\\u1AB0-\\u1ADD\\u1AE0-\\u1AEB\\u1B00-\\u1B04\\u1B34-\\u1B44\\u1B6B-\\u1B73\\u1B80-\\u1B82\\u1BA1-\\u1BAD\\u1BE6-\\u1BF3\\u1C24-\\u1C37\\u1CD0-\\u1CD2\\u1CD4-\\u1CE8\\u1CED\\u1CF4\\u1CF7-\\u1CF9\\u1DC0-\\u1DFF\\u200C\\u200D\\u20D0-\\u20F0\\u2CEF-\\u2CF1\\u2D7F\\u2DE0-\\u2DFF\\u302A-\\u302F\\u3099\\u309A\\uA66F-\\uA672\\uA674-\\uA67D\\uA69E\\uA69F\\uA6F0\\uA6F1\\uA802\\uA806\\uA80B\\uA823-\\uA827\\uA82C\\uA880\\uA881\\uA8B4-\\uA8C5\\uA8E0-\\uA8F1\\uA8FF\\uA926-\\uA92D\\uA947-\\uA953\\uA960-\\uA97C\\uA980-\\uA983\\uA9B3-\\uA9C0\\uA9E5\\uAA29-\\uAA36\\uAA43\\uAA4C\\uAA4D\\uAA7C\\uAAB0\\uAAB2-\\uAAB4\\uAAB7\\uAAB8\\uAABE\\uAABF\\uAAC1\\uAAEB-\\uAAEF\\uAAF5\\uAAF6\\uABE3-\\uABEA\\uABEC\\uABED\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uFB1E\\uFE00-\\uFE0F\\uFE20-\\uFE2F\\uFF9E\\uFF9F]|\\uD800[\\uDDFD\\uDEE0\\uDF76-\\uDF7A]|\\uD802[\\uDE01-\\uDE03\\uDE05\\uDE06\\uDE0C-\\uDE0F\\uDE38-\\uDE3A\\uDE3F\\uDEE5\\uDEE6]|\\uD803[\\uDD24-\\uDD27\\uDD69-\\uDD6D\\uDEAB\\uDEAC\\uDEFA-\\uDEFF\\uDF46-\\uDF50\\uDF82-\\uDF85]|\\uD804[\\uDC00-\\uDC02\\uDC38-\\uDC46\\uDC70\\uDC73\\uDC74\\uDC7F-\\uDC82\\uDCB0-\\uDCBA\\uDCBD\\uDCC2\\uDCCD\\uDD00-\\uDD02\\uDD27-\\uDD34\\uDD45\\uDD46\\uDD73\\uDD80-\\uDD82\\uDDB3-\\uDDC0\\uDDC2\\uDDC3\\uDDC9-\\uDDCC\\uDDCE\\uDDCF\\uDE2C-\\uDE37\\uDE3E\\uDE41\\uDEDF-\\uDEEA\\uDF00-\\uDF03\\uDF3B\\uDF3C\\uDF3E-\\uDF44\\uDF47\\uDF48\\uDF4B-\\uDF4D\\uDF57\\uDF62\\uDF63\\uDF66-\\uDF6C\\uDF70-\\uDF74\\uDFB8-\\uDFC0\\uDFC2\\uDFC5\\uDFC7-\\uDFCA\\uDFCC-\\uDFD2\\uDFE1\\uDFE2]|\\uD805[\\uDC35-\\uDC46\\uDC5E\\uDCB0-\\uDCC3\\uDDAF-\\uDDB5\\uDDB8-\\uDDC0\\uDDDC\\uDDDD\\uDE30-\\uDE40\\uDEAB-\\uDEB7\\uDF1D-\\uDF1F\\uDF22-\\uDF2B]|\\uD806[\\uDC2C-\\uDC3A\\uDD30-\\uDD35\\uDD37\\uDD38\\uDD3B-\\uDD43\\uDDD1-\\uDDD7\\uDDDA-\\uDDE0\\uDDE4\\uDE01-\\uDE0A\\uDE33-\\uDE39\\uDE3B-\\uDE3E\\uDE47\\uDE51-\\uDE5B\\uDE84-\\uDE99\\uDF60-\\uDF67]|\\uD807[\\uDC2F-\\uDC36\\uDC38-\\uDC3F\\uDC92-\\uDCA7\\uDCA9-\\uDCB6\\uDD31-\\uDD36\\uDD3A\\uDD3C\\uDD3D\\uDD3F-\\uDD47\\uDD8A-\\uDD8E\\uDD90\\uDD91\\uDD93-\\uDD97\\uDEF3-\\uDEF6\\uDF00-\\uDF03\\uDF34-\\uDF3A\\uDF3E-\\uDF42\\uDF5A]|\\uD80D[\\uDC40\\uDC47-\\uDC55]|\\uD818[\\uDD1E-\\uDD2F]|\\uD81A[\\uDEF0-\\uDEF4\\uDF30-\\uDF36]|\\uD81B[\\uDD63\\uDD67-\\uDD6A\\uDF4F\\uDF51-\\uDF87\\uDF8F-\\uDF92\\uDFE4\\uDFF0\\uDFF1]|\\uD82F[\\uDC9D\\uDC9E]|\\uD833[\\uDF00-\\uDF2D\\uDF30-\\uDF46]|\\uD834[\\uDD65-\\uDD69\\uDD6D-\\uDD72\\uDD7B-\\uDD82\\uDD85-\\uDD8B\\uDDAA-\\uDDAD\\uDE42-\\uDE44]|\\uD836[\\uDE00-\\uDE36\\uDE3B-\\uDE6C\\uDE75\\uDE84\\uDE9B-\\uDE9F\\uDEA1-\\uDEAF]|\\uD838[\\uDC00-\\uDC06\\uDC08-\\uDC18\\uDC1B-\\uDC21\\uDC23\\uDC24\\uDC26-\\uDC2A\\uDC8F\\uDD30-\\uDD36\\uDEAE\\uDEEC-\\uDEEF]|\\uD839[\\uDCEC-\\uDCEF\\uDDEE\\uDDEF\\uDEE3\\uDEE6\\uDEEE\\uDEEF\\uDEF5]|\\uD83A[\\uDCD0-\\uDCD6\\uDD44-\\uDD4A]|\\uD83C[\\uDDE6-\\uDDFF\\uDFFB-\\uDFFF]|\\uDB40[\\uDC20-\\uDC7F\\uDD00-\\uDDEF]/.test(t)}function Ac(t){return/[\\u0E01-\\u0E3A\\u0E40-\\u0E4E\\u0E81\\u0E82\\u0E84\\u0E86-\\u0E8A\\u0E8C-\\u0EA3\\u0EA5\\u0EA7-\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EC8-\\u0ECE\\u0EDC-\\u0EDF\\u0F00-\\u0F47\\u0F49-\\u0F6C\\u0F71-\\u0F97\\u0F99-\\u0FBC\\u0FBE-\\u0FCC\\u0FCE-\\u0FD4\\u0FD9\\u0FDA\\u1000-\\u103F\\u1050-\\u108F\\u109A-\\u109F\\u1780-\\u17D3\\u17D7\\u17DC\\u17DD\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u19DE\\u19DF\\u1A20-\\u1A5E\\u1A60-\\u1A7C\\u1AA0-\\u1AAD\\u1B00-\\u1B4C\\u1B4E-\\u1B7F\\uA980-\\uA9CD\\uA9D0-\\uA9D9\\uA9DE-\\uA9EF\\uA9FA-\\uA9FE\\uAA60-\\uAAC2\\uAADB-\\uAADF]|\\uD805[\\uDF00-\\uDF1A\\uDF1D-\\uDF2B\\uDF3A\\uDF3B\\uDF3F-\\uDF46]/gim.test(String.fromCodePoint(t))}function W2(t,e){return/(?:[\\u1039\\u17D2\\u1A60\\u1BAB\\u200D\\uAAF6]|\\uD802\\uDE3F|\\uD804[\\uDD33\\uDFD0]|\\uD806[\\uDD3E\\uDE47\\uDE99]|\\uD807[\\uDD45\\uDD97\\uDF42])$/.test(t)||/^\\p{gc=Mc}/u.test(e)}var Z2={C:"18g,1;g2,3;4nb,1",D:"17k,1;5,1;1,1;1,5;4,d;1,7;1,2;z,2;8,g;i,12;1,2;9,1;1,1;1,2;14,3;2,1;28,9;3,f;2,4;1,1;2,3;2,6;7a,1;2,5;1,1;g,a;5,2;2,6;1,f",R:"17m,4;1,1;1,1;5,4;l,1;14,3;1,3;g,i;12,1;2,9;1,1;1,1;2,2;1,1;o,2;2x,3;f,2;4,1;1,2;3,2;6u,j;b,1;r,3;1,1;2,2;6,1",T:"174,b;1,1;1a,l;g,1;2t,7;2,6;2,2;1,4;bt,9;16,o;1,t;1clb,1"},H2={1569:[65152,0,0,0],1570:[65153,65154,0,0],1571:[65155,65156,0,0],1572:[65157,65158,0,0],1573:[65159,65160,0,0],1574:[65161,65162,65163,65164],1575:[65165,65166,0,0],1576:[65167,65168,65169,65170],1577:[65171,65172,0,0],1578:[65173,65174,65175,65176],1579:[65177,65178,65179,65180],1580:[65181,65182,65183,65184],1581:[65185,65186,65187,65188],1582:[65189,65190,65191,65192],1583:[65193,65194,0,0],1584:[65195,65196,0,0],1585:[65197,65198,0,0],1586:[65199,65200,0,0],1587:[65201,65202,65203,65204],1588:[65205,65206,65207,65208],1589:[65209,65210,65211,65212],1590:[65213,65214,65215,65216],1591:[65217,65218,65219,65220],1592:[65221,65222,65223,65224],1593:[65225,65226,65227,65228],1594:[65229,65230,65231,65232],1601:[65233,65234,65235,65236],1602:[65237,65238,65239,65240],1603:[65241,65242,65243,65244],1604:[65245,65246,65247,65248],1605:[65249,65250,65251,65252],1606:[65253,65254,65255,65256],1607:[65257,65258,65259,65260],1608:[65261,65262,0,0],1609:[65263,65264,64488,64489],1610:[65265,65266,65267,65268],1611:[65136,0,0,65137],1612:[65138,0,0,0],1613:[65140,0,0,0],1614:[65142,0,0,65143],1615:[65144,0,0,65145],1616:[65146,0,0,65147],1617:[65148,0,0,65149],1618:[65150,0,0,65151],1649:[64336,64337,0,0],1655:[64477,0,0,0],1657:[64358,64359,64360,64361],1658:[64350,64351,64352,64353],1659:[64338,64339,64340,64341],1662:[64342,64343,64344,64345],1663:[64354,64355,64356,64357],1664:[64346,64347,64348,64349],1667:[64374,64375,64376,64377],1668:[64370,64371,64372,64373],1670:[64378,64379,64380,64381],1671:[64382,64383,64384,64385],1672:[64392,64393,0,0],1676:[64388,64389,0,0],1677:[64386,64387,0,0],1678:[64390,64391,0,0],1681:[64396,64397,0,0],1688:[64394,64395,0,0],1700:[64362,64363,64364,64365],1702:[64366,64367,64368,64369],1705:[64398,64399,64400,64401],1709:[64467,64468,64469,64470],1711:[64402,64403,64404,64405],1713:[64410,64411,64412,64413],1715:[64406,64407,64408,64409],1722:[64414,64415,0,0],1723:[64416,64417,64418,64419],1726:[64426,64427,64428,64429],1728:[64420,64421,0,0],1729:[64422,64423,64424,64425],1733:[64480,64481,0,0],1734:[64473,64474,0,0],1735:[64471,64472,0,0],1736:[64475,64476,0,0],1737:[64482,64483,0,0],1739:[64478,64479,0,0],1740:[64508,64509,64510,64511],1744:[64484,64485,64486,64487],1746:[64430,64431,0,0],1747:[64432,64433,0,0]},K2={\\u0644\\u0622:[65269,65270],\\u0644\\u0623:[65271,65272],\\u0644\\u0625:[65273,65274],\\u0644\\u0627:[65275,65276]},Sc=1604,J2=/[\\u0600-\\u06ff\\u0750-\\u077f\\u0870-\\u089f\\u08a0-\\u08ff\\ufb50-\\ufdff\\ufe70-\\ufeff]/;function Q2(t,e,r){let i=0;for(let n of t.split(";")){let[a,s]=n.split(",").map(l=>parseInt(l,36)),o=i+a;for(let l=o;l<o+s;l++)r.set(l,e);i=o+s}}var qd=new Map;for(let[t,e]of Object.entries(Z2))Q2(e,t,qd);function tv(t){return qd.get(t)??"U"}function ev(t){return t==="D"||t==="L"||t==="C"}function rv(t){return t==="D"||t==="R"||t==="C"}function iv(t,e,r){return t==="D"?e&&r?3:e?1:r?2:0:t==="R"?+!!e:t==="L"?r?2:0:null}function nv(t){return[...t].map(e=>{let r=e.codePointAt(0);return{codePoint:r,type:tv(r),form:null}})}function av(t){let e=t.filter(r=>r.type!=="T");for(let r=0;r<e.length;r++){let i=e[r],n=r>0&&ev(e[r-1].type),a=r+1<e.length&&rv(e[r+1].type);i.form=iv(i.type,n,a)}}function sv(t){let e=!1;for(let r of t)r.type==="T"?r.form=e?3:0:e=r.form===2||r.form===3}function ov(t){let e=[];for(let r=0;r<t.length;r++){let i=t[r];if(i.codePoint!==Sc){e.push(i);continue}let n=r+1;for(;n<t.length&&t[n].type==="T";)n++;let a=t[n],s=a&&K2[String.fromCodePoint(Sc,a.codePoint)];if(!s){e.push(i);continue}let o=i.form===3||i.form===1;e.push({codePoint:s[+!!o],type:"R",form:0}),e.push(...t.slice(r+1,n)),r=n}return e}function lv(t){if(t.form===null)return t.codePoint;let e=H2[t.codePoint];return e&&(e[t.form]||e[0])||t.codePoint}function uv(t){if(!J2.test(t))return t;let e=nv(t);return av(e),sv(e),ov(e).map(r=>String.fromCodePoint(lv(r))).join("")}function hv(t,e,r){let i=e.layout.get("text-transform").evaluate(r,{});return i==="uppercase"?t=t.toLocaleUpperCase():i==="lowercase"&&(t=t.toLocaleLowerCase()),(vr.applyArabicShaping??uv)(t)}function cv(t,e,r){for(let i of t.sections)i.text=hv(i.text,e,r);return t}function pv(t){let e={},r={},i=[],n=0;function a(u){i.push(t[u]),n++}function s(u,h,c){let p=r[u];return delete r[u],r[h]=p,i[p].geometry[0].pop(),i[p].geometry[0]=i[p].geometry[0].concat(c[0]),p}function o(u,h,c){let p=e[h];return delete e[h],e[u]=p,i[p].geometry[0].shift(),i[p].geometry[0]=c[0].concat(i[p].geometry[0]),p}function l(u,h,c){let p=c?h[0][h[0].length-1]:h[0][0];return`${u}:${p.x}:${p.y}`}for(let u=0;u<t.length;u++){let h=t[u],c=h.geometry,p=h.text?h.text.toString():null;if(!p){a(u);continue}let f=l(p,c),d=l(p,c,!0);if(f in r&&d in e&&r[f]!==e[d]){let y=o(f,d,c),m=s(f,d,i[y].geometry);delete e[f],delete r[d],r[l(p,i[m].geometry,!0)]=m,i[y].geometry=null}else f in r?s(f,d,c):d in e?o(f,d,c):(a(u),e[f]=n-1,r[d]=n-1)}return i.filter(u=>u.geometry)}var jd=typeof Intl<"u"&&"Segmenter"in Intl,Us,qs;function Ko(t){if(!jd||!X2(t))return[...t];Us??(Us=new Intl.Segmenter(void 0,{granularity:"grapheme"}));let e=[];for(let{segment:r}of Us.segment(t)){let i=e.length-1;i>=0&&W2(e[i],r)?e[i]+=r:e.push(r)}return e}function fv(t){let e=new Set;if(jd){qs??(qs=new Intl.Segmenter(void 0,{granularity:"word"}));for(let{index:i}of qs.segment(t))e.add(i);return e}let r=0;for(let i of t.split(/\\b|(?=\\p{Ideo})/u))e.add(r),r+=i.length;return e}function Gd(t){let e=t.codePointAt(0);return t.length>(e>65535?2:1)}function Ql(t){return/\\s/u.test(String.fromCodePoint(t))}function Jo(t){for(let e of t)if(Xa(e.codePointAt(0)))return!0;return!1}function dv(t){for(let e of t)if(!yv(e.codePointAt(0)))return!1;return!0}function yv(t){return!q2(t)}function Ec(t){return!(Xa(t)||Y2(t))}function Yd(t){return/\\p{sc=Arab}/u.test(String.fromCodePoint(t))}function Xd(t){return j2(t)}function Wd(t){for(let e of t)if(Xd(e.codePointAt(0)))return!0;return!1}var qr={"!":"\\uFE15","#":"\\uFF03",$:"\\uFF04","%":"\\uFF05","&":"\\uFF06","(":"\\uFE35",")":"\\uFE36","*":"\\uFF0A","+":"\\uFF0B",",":"\\uFE10","-":"\\uFE32",".":"\\u30FB","/":"\\uFF0F",":":"\\uFE13",";":"\\uFE14","<":"\\uFE3F","=":"\\uFF1D",">":"\\uFE40","?":"\\uFE16","@":"\\uFF20","[":"\\uFE47","\\\\":"\\uFF3C","]":"\\uFE48","^":"\\uFF3E",_:"\\uFE33","`":"\\uFF40","{":"\\uFE37","|":"\\u2015","}":"\\uFE38","~":"\\uFF5E","\\xA2":"\\uFFE0","\\xA3":"\\uFFE1","\\xA5":"\\uFFE5","\\xA6":"\\uFFE4","\\xAC":"\\uFFE2","\\xAF":"\\uFFE3","\\u2013":"\\uFE32","\\u2014":"\\uFE31","\\u2018":"\\uFE43","\\u2019":"\\uFE44","\\u201C":"\\uFE41","\\u201D":"\\uFE42","\\u2026":"\\uFE19","\\u22EF":"\\uFE19","\\u2027":"\\u30FB","\\u20A9":"\\uFFE6","\\u3001":"\\uFE11","\\u3002":"\\uFE12","\\u3008":"\\uFE3F","\\u3009":"\\uFE40","\\u300A":"\\uFE3D","\\u300B":"\\uFE3E","\\u300C":"\\uFE41","\\u300D":"\\uFE42","\\u300E":"\\uFE43","\\u300F":"\\uFE44","\\u3010":"\\uFE3B","\\u3011":"\\uFE3C","\\u3014":"\\uFE39","\\u3015":"\\uFE3A","\\u3016":"\\uFE17","\\u3017":"\\uFE18","\\uFF01":"\\uFE15","\\uFF08":"\\uFE35","\\uFF09":"\\uFE36","\\uFF0C":"\\uFE10","\\uFF0D":"\\uFE32","\\uFF0E":"\\u30FB","\\uFF1A":"\\uFE13","\\uFF1B":"\\uFE14","\\uFF1C":"\\uFE3F","\\uFF1E":"\\uFE40","\\uFF1F":"\\uFE16","\\uFF3B":"\\uFE47","\\uFF3D":"\\uFE48","\\uFF3F":"\\uFE33","\\uFF5B":"\\uFE37","\\uFF5C":"\\u2015","\\uFF5D":"\\uFE38","\\uFF5F":"\\uFE35","\\uFF60":"\\uFE36","\\uFF61":"\\uFE12","\\uFF62":"\\uFE41","\\uFF63":"\\uFE42"};function mv(t){let e="",r={premature:!0,value:void 0},i=t[Symbol.iterator](),n=i.next(),a=t[Symbol.iterator]();a.next();let s=a.next();for(;!n.done;)(s.done||!Ec(s.value.codePointAt(0))||qr[s.value])&&(r.premature||!Ec(r.value.codePointAt(0))||qr[r.value])&&qr[n.value]?e+=qr[n.value]:e+=n.value,r={value:n.value,premature:!1},n=i.next(),s=a.next();return e}var gv={10:!0,13:!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},xv={40:!0};function Fc(t,e,r,i,n,a){if("fontStack"in e){let s=r[e.fontStack],o=s?.[t];if(o)return o.metrics.advance*e.scale+n;let l=0;for(let u of t){let h=s?.[u];h&&(l+=h.metrics.advance*e.scale+n)}return l}{let s=i[e.imageName];return s?s.displaySize[0]*e.scale*24/a+n:0}}function Tc(t,e,r,i){let n=(t-e)**2;return i?t<e?n/2:n*2:n+Math.abs(r)*r}function kc(t){return/^\\s+$/u.test(t)}function vv(t,e,r){let i=0;return(t===10||t===13)&&(i-=1e4),r&&(i+=150),(t===40||t===65288)&&(i+=50),(e===41||e===65289)&&(i+=50),i}function Ic(t,e,r,i,n,a){let s=null,o=Tc(e,r,n,a);for(let l of i){let u=Tc(e-l.x,r,n,a)+l.badness;u<=o&&(s=l,o=u)}return{index:t,x:e,priorBreak:s,badness:o}}function Zd(t){return t?Zd(t.priorBreak).concat(t.index):[]}var tu=class Qo{constructor(e="",r=[],i=[]){this.text=e,this.sections=r,this.sectionIndex=i,this.imageSectionID=null,this._graphemes=null}graphemes(){return this._graphemes??(this._graphemes=Ko(this.text)),this._graphemes}static fromFeature(e,r){let i=new Qo;for(let n of e.sections)n.image?i.addImageSection(n):i.addTextSection(n,r);return i}length(){return this.graphemes().length}getSection(e){return this.sections[this.sectionIndex[e]]}getSectionIndex(e){return this.sectionIndex[e]}verticalizePunctuation(){this.text=mv(this.text),this._graphemes=null}hasZeroWidthSpaces(){return this.text.includes("\\u200B")}trim(){let e=this.graphemes(),r=0;for(;r<e.length&&kc(e[r]);)r++;let i=e.length;for(;i>r&&kc(e[i-1]);)i--;this.text=e.slice(r,i).join(""),this.sectionIndex=this.sectionIndex.slice(r,i),this._graphemes=null}substring(e,r){let i=this.graphemes().slice(e,r).join(""),n=this.sectionIndex.slice(e,r);return new Qo(i,this.sections,n)}toCodeUnitIndex(e){return this.graphemes().slice(0,e).join("").length}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,r)=>Math.max(e,this.sections[r].scale),0)}getMaxImageSize(e){let r=0,i=0;for(let n=0;n<this.length();n++){let a=this.getSection(n);if("imageName"in a){let s=e[a.imageName];if(!s)continue;let o=s.displaySize;r=Math.max(r,o[0]),i=Math.max(i,o[1])}}return{maxImageWidth:r,maxImageHeight:i}}_appendSection(e,r){let i=this.graphemes(),n=i.length>0?i[i.length-1]:"",a=Ko(n+e);this.text+=e,this._graphemes=i.slice(0,n?-1:void 0).concat(a);let s=a.length-+!!n;for(let o=0;o<s;o++)this.sectionIndex.push(r)}addTextSection(e,r){this.sections.push({scale:e.scale||1,verticalAlign:e.verticalAlign||"bottom",fontStack:e.fontStack||r}),this._appendSection(e.text,this.sections.length-1)}addImageSection(e){let r=e.image?e.image.name:"";if(r.length===0){Mt("Can\'t add FormattedSection with an empty image.");return}let i=this.getNextImageSectionCharCode();if(!i){Mt("Reached maximum number of images 6401");return}this.sections.push({scale:1,verticalAlign:e.verticalAlign||"bottom",imageName:r}),this._appendSection(String.fromCharCode(i),this.sections.length-1)}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(e,r,i,n,a){let s=[],o=this.determineAverageLineWidth(e,r,i,n,a),l=this.hasZeroWidthSpaces(),u=this.graphemes(),h=null,c=0,p=0;for(let f=0;f<u.length;f++){let d=u[f];if(f>0){let y=u[f-1].codePointAt(0),m=d.codePointAt(0),g=G2(y),x=Ac(y)&&Ac(m);(gv[y]||g||"imageName"in this.getSection(f-1)||u[f+1]!==void 0&&xv[m]||x&&(h??(h=fv(this.text))).has(p))&&s.push(Ic(f,c,o,s,vv(y,m,g&&l),!1))}Ql(d.codePointAt(0))||(c+=Fc(d,this.getSection(f),i,n,e,a)),p+=d.length}return Zd(Ic(this.length(),c,o,s,0,!0))}determineAverageLineWidth(e,r,i,n,a){let s=0,o=0;for(let u of this.graphemes()){let h=this.getSection(o);s+=Fc(u,h,i,n,e,a),o++}let l=Math.max(1,Math.ceil(s/r));return s/l}};function bv(){return(function(t){var e={R:"13k,1a,2,3,3,2+1j,ch+16,a+1,5+2,2+n,5,a,4,6+16,4+3,h+1b,4mo,179q,2+9,2+11,2i9+7y,2+68,4,3+4,5+13,4+3,2+4k,3+29,8+cf,1t+7z,w+17,3+3m,1t+3z,16o1+5r,8+30,8+mc,29+1r,29+4v,75+73",EN:"1c+9,3d+1,6,187+9,513,4+5,7+9,sf+j,175h+9,qw+q,161f+1d,4xt+a,25i+9",ES:"17,2,6dp+1,f+1,av,16vr,mx+1,4o,2",ET:"z+2,3h+3,b+1,ym,3e+1,2o,p4+1,8,6u,7c,g6,1wc,1n9+4,30+1b,2n,6d,qhx+1,h0m,a+1,49+2,63+1,4+1,6bb+3,12jj",AN:"16o+5,2j+9,2+1,35,ed,1ff2+9,87+u",CS:"18,2+1,b,2u,12k,55v,l,17v0,2,3,53,2+1,b",B:"a,3,f+2,2v,690",S:"9,2,k",WS:"c,k,4f4,1vk+a,u,1j,335",ON:"x+1,4+4,h+5,r+5,r+3,z,5+3,2+1,2+1,5,2+2,3+4,o,w,ci+1,8+d,3+d,6+8,2+g,39+1,9,6+1,2,33,b8,3+1,3c+1,7+1,5r,b,7h+3,sa+5,2,3i+6,jg+3,ur+9,2v,ij+1,9g+9,7+a,8m,4+1,49+x,14u,2+2,c+2,e+2,e+2,e+1,i+n,e+e,2+p,u+2,e+2,36+1,2+3,2+1,b,2+2,6+5,2,2,2,h+1,5+4,6+3,3+f,16+2,5+3l,3+81,1y+p,2+40,q+a,m+13,2r+ch,2+9e,75+hf,3+v,2+2w,6e+5,f+6,75+2a,1a+p,2+2g,d+5x,r+b,6+3,4+o,g,6+1,6+2,2k+1,4,2j,5h+z,1m+1,1e+f,t+2,1f+e,d+3,4o+3,2s+1,w,535+1r,h3l+1i,93+2,2s,b+1,3l+x,2v,4g+3,21+3,kz+1,g5v+1,5a,j+9,n+v,2,3,2+8,2+1,3+2,2,3,46+1,4+4,h+5,r+5,r+a,3h+2,4+6,b+4,78,1r+24,4+c,4,1hb,ey+6,103+j,16j+c,1ux+7,5+g,fsh,jdq+1t,4,57+2e,p1,1m,1m,1m,1m,4kt+1,7j+17,5+2r,d+e,3+e,2+e,2+10,m+4,w,1n+5,1q,4z+5,4b+rb,9+c,4+c,4+37,d+2g,8+b,l+b,5+1j,9+9,7+13,9+t,3+1,27+3c,2+29,2+3q,d+d,3+4,4+2,6+6,a+o,8+6,a+2,e+6,16+42,2+1i",BN:"0+8,6+d,2s+5,2+p,e,4m9,1kt+2,2b+5,5+5,17q9+v,7k,6p+8,6+1,119d+3,440+7,96s+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+75,6p+2rz,1ben+1,1ekf+1,1ekf+1",NSM:"lc+33,7o+6,7c+18,2,2+1,2+1,2,21+a,1d+k,h,2u+6,3+5,3+1,2+3,10,v+q,2k+a,1n+8,a,p+3,2+8,2+2,2+4,18+2,3c+e,2+v,1k,2,5+7,5,4+6,b+1,u,1n,5+3,9,l+1,r,3+1,1m,5+1,5+1,3+2,4,v+1,4,c+1,1m,5+4,2+1,5,l+1,n+5,2,1n,3,2+3,9,8+1,c+1,v,1q,d,1f,4,1m+2,6+2,2+3,8+1,c+1,u,1n,g+1,l+1,t+1,1m+1,5+3,9,l+1,u,21,8+2,2,2j,3+6,d+7,2r,3+8,c+5,23+1,s,2,2,1k+d,2+4,2+1,6+a,2+z,a,2v+3,2+5,2+1,3+1,q+1,5+2,h+3,e,3+1,7,g,jk+2,qb+2,u+2,u+1,v+1,1t+1,2+6,9,3+a,a,1a+2,3c+1,z,3b+2,5+1,a,7+2,64+1,3,1n,2+6,2,2,3+7,7+9,3,1d+g,1s+3,1d,2+4,2,6,15+8,d+1,x+3,3+1,2+2,1l,2+1,4,2+2,1n+7,3+1,49+2,2+c,2+6,5,7,4+1,5j+1l,2+4,k1+w,2db+2,3y,2p+v,ff+3,30+1,n9x+3,2+9,x+1,29+1,7l,4,5,q+1,6,48+1,r+h,e,13+7,q+a,1b+2,1d,3+3,3+1,14,1w+5,3+1,3+1,d,9,1c,1g,2+2,3+1,6+1,2,17+1,9,6n,3,5,fn5,ki+f,h+f,r2,6b,46+4,1af+2,2+1,6+3,15+2,5,4m+1,fy+3,as+1,4a+a,4x,1j+e,1l+2,1e+3,3+1,1y+2,11+4,2+7,1r,d+1,1h+8,b+3,3,2o+2,3,2+1,7,4h,4+7,m+1,1m+1,4,12+6,4+4,5g+7,3+2,2,o,2d+5,2,5+1,2+1,6n+3,7+1,2+1,s+1,2e+7,3,2+1,2z,2,3+5,2,2u+2,3+3,2+4,78+8,2+1,75+1,2,5,41+3,3+1,5,x+5,3+1,15+5,3+3,9,a+5,3+2,1b+c,2+1,bb+6,2+5,2d+l,3+6,2+1,2+1,3f+5,4,2+1,2+6,2,21+1,4,2,9o+1,f0c+4,1o+6,t5,1s+3,2a,f5l+1,43t+2,i+7,3+6,v+3,45+2,1j0+1i,5+1d,9,f,n+4,2+e,11t+6,2+g,3+6,2+1,2+4,7a+6,c6+3,15t+6,32+6,gzhy+6n",AL:"16w,3,2,e+1b,z+2,2+2s,g+1,8+1,b+m,2+t,s+2i,c+e,4h+f,1d+1e,1bwe+dp,3+3z,x+c,2+1,35+3y,2rm+z,5+7,b+5,dt+l,c+u,17nl+27,1t+27,4x+6n,3+d",LRO:"6ct",RLO:"6cu",LRE:"6cq",RLE:"6cr",PDF:"6cs",LRI:"6ee",RLI:"6ef",FSI:"6eg",PDI:"6eh"},r={},i={};r.L=1,i[1]="L",Object.keys(e).forEach(function(N,Q){r[N]=1<<Q+1,i[r[N]]=N}),Object.freeze(r);var n=r.LRI|r.RLI|r.FSI,a=r.L|r.R|r.AL,s=r.B|r.S|r.WS|r.ON|r.FSI|r.LRI|r.RLI|r.PDI,o=r.BN|r.RLE|r.LRE|r.RLO|r.LRO|r.PDF,l=r.S|r.WS|r.B|n|r.PDI|o,u=null;function h(){if(!u){u=new Map;var N=0;for(var Q in e)if(e.hasOwnProperty(Q))for(var Z=e[Q],C="",ut=void 0,Y=!1,G=0,K=0;K<=Z.length+1;K+=1){var $t=Z[K];if($t!==","&&K!==Z.length)$t==="+"?(Y=!0,G=N=G+parseInt(C,36),C=""):C+=$t;else{Y?ut=N+parseInt(C,36):(G=N=G+parseInt(C,36),ut=N),Y=!1,C="",G=ut;for(var vt=N;vt<ut+1;vt+=1)u.set(vt,r[Q])}}}}function c(N){return h(),u.get(N.codePointAt(0))||r.L}function p(N){return i[c(N)]}var f={pairs:"14>1,1e>2,u>2,2wt>1,1>1,1ge>1,1wp>1,1j>1,f>1,hm>1,1>1,u>1,u6>1,1>1,+5,28>1,w>1,1>1,+3,b8>1,1>1,+3,1>3,-1>-1,3>1,1>1,+2,1s>1,1>1,x>1,th>1,1>1,+2,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,4q>1,1e>2,u>2,2>1,+1",canonical:"6f1>-6dx,6dy>-6dx,6ec>-6ed,6ee>-6ed,6ww>2jj,-2ji>2jj,14r4>-1e7l,1e7m>-1e7l,1e7m>-1e5c,1e5d>-1e5b,1e5c>-14qx,14qy>-14qx,14vn>-1ecg,1ech>-1ecg,1edu>-1ecg,1eci>-1ecg,1eda>-1ecg,1eci>-1ecg,1eci>-168q,168r>-168q,168s>-14ye,14yf>-14ye"};function d(N,Q){var Z=0,C=new Map,ut=Q&&new Map,Y;return N.split(",").forEach(function G(K){if(K.indexOf("+")!==-1)for(var $t=+K;$t--;)G(Y);else{Y=K;var vt=K.split(">"),nt=vt[0],kt=vt[1];nt=String.fromCodePoint(Z+=parseInt(nt,36)),kt=String.fromCodePoint(Z+=parseInt(kt,36)),C.set(nt,kt),Q&&ut.set(kt,nt)}}),{map:C,reverseMap:ut}}var y,m,g;function x(){if(!y){var N=d(f.pairs,!0),Q=N.map,Z=N.reverseMap;y=Q,m=Z,g=d(f.canonical,!1).map}}function b(N){return x(),y.get(N)||null}function v(N){return x(),m.get(N)||null}function w(N){return x(),g.get(N)||null}var _=r.L,A=r.R,S=r.EN,F=r.ES,L=r.ET,V=r.AN,P=r.CS,R=r.B,E=r.S,$=r.ON,O=r.BN,M=r.NSM,j=r.AL,it=r.LRO,pt=r.RLO,st=r.LRE,ft=r.RLE,Gt=r.PDF,ze=r.LRI,fe=r.RLI,Le=r.FSI,Zt=r.PDI;function Sr(N,Q){for(var Z=125,C=new Uint32Array(N.length),ut=0;ut<N.length;ut++)C[ut]=c(N[ut]);var Y=new Map;function G(Yt,oe){var Xt=C[Yt];C[Yt]=oe,Y.set(Xt,Y.get(Xt)-1),Xt&s&&Y.set(s,Y.get(s)-1),Y.set(oe,(Y.get(oe)||0)+1),oe&s&&Y.set(s,(Y.get(s)||0)+1)}for(var K=new Uint8Array(N.length),$t=new Map,vt=[],nt=null,kt=0;kt<N.length;kt++)nt||vt.push(nt={start:kt,end:N.length-1,level:Q==="rtl"?1:Q==="ltr"?0:Qu(kt,!1)}),C[kt]&R&&(nt.end=kt,nt=null);for(var pi=ft|st|pt|it|n|Zt|Gt|R,ir=function(Yt){return Yt+(Yt&1?1:2)},Ve=function(Yt){return Yt+(Yt&1?2:1)},Oe=0;Oe<vt.length;Oe++){nt=vt[Oe];var ot=[{_level:nt.level,_override:0,_isolate:0}],bt=void 0,Fe=0,Re=0,Ha=0;Y.clear();for(var zt=nt.start;zt<=nt.end;zt++){var Lt=C[zt];if(bt=ot[ot.length-1],Y.set(Lt,(Y.get(Lt)||0)+1),Lt&s&&Y.set(s,(Y.get(s)||0)+1),Lt&pi)if(Lt&(ft|st)){K[zt]=bt._level;var Fu=(Lt===ft?Ve:ir)(bt._level);Fu<=Z&&!Fe&&!Re?ot.push({_level:Fu,_override:0,_isolate:0}):Fe||Re++}else if(Lt&(pt|it)){K[zt]=bt._level;var Tu=(Lt===pt?Ve:ir)(bt._level);Tu<=Z&&!Fe&&!Re?ot.push({_level:Tu,_override:Lt&pt?A:_,_isolate:0}):Fe||Re++}else if(Lt&n){Lt&Le&&(Lt=Qu(zt+1,!0)===1?fe:ze),K[zt]=bt._level,bt._override&&G(zt,bt._override);var ku=(Lt===fe?Ve:ir)(bt._level);ku<=Z&&Fe===0&&Re===0?(Ha++,ot.push({_level:ku,_override:0,_isolate:1,_isolInitIndex:zt})):Fe++}else if(Lt&Zt){if(Fe>0)Fe--;else if(Ha>0){for(Re=0;!ot[ot.length-1]._isolate;)ot.pop();var Ka=ot[ot.length-1]._isolInitIndex;Ka!=null&&($t.set(Ka,zt),$t.set(zt,Ka)),ot.pop(),Ha--}bt=ot[ot.length-1],K[zt]=bt._level,bt._override&&G(zt,bt._override)}else Lt&Gt?(Fe===0&&(Re>0?Re--:!bt._isolate&&ot.length>1&&(ot.pop(),bt=ot[ot.length-1])),K[zt]=bt._level):Lt&R&&(K[zt]=nt.level);else K[zt]=bt._level,bt._override&&Lt!==O&&G(zt,bt._override)}for(var kr=[],de=null,nr=nt.start;nr<=nt.end;nr++){var Ja=C[nr];if(!(Ja&o)){var Iu=K[nr],Cu=Ja&n,a1=Ja===Zt;de&&Iu===de._level?(de._end=nr,de._endsWithIsolInit=Cu):kr.push(de={_start:nr,_end:nr,_level:Iu,_startsWithPDI:a1,_endsWithIsolInit:Cu})}}for(var Qa=[],Dn=0;Dn<kr.length;Dn++){var _n=kr[Dn];if(!_n._startsWithPDI||_n._startsWithPDI&&!$t.has(_n._start)){for(var ts=[de=_n],Mu=void 0;de&&de._endsWithIsolInit&&(Mu=$t.get(de._end))!=null;)for(var An=Dn+1;An<kr.length;An++)if(kr[An]._start===Mu){ts.push(de=kr[An]);break}for(var Ir=[],es=0;es<ts.length;es++)for(var Bu=ts[es],rs=Bu._start;rs<=Bu._end;rs++)Ir.push(rs);for(var s1=K[Ir[0]],Pu=nt.level,Sn=Ir[0]-1;Sn>=0;Sn--)if(!(C[Sn]&o)){Pu=K[Sn];break}var is=Ir[Ir.length-1],o1=K[is],zu=nt.level;if(!(C[is]&n)){for(var En=is+1;En<=nt.end;En++)if(!(C[En]&o)){zu=K[En];break}}Qa.push({_seqIndices:Ir,_sosType:Math.max(Pu,s1)%2?A:_,_eosType:Math.max(zu,o1)%2?A:_})}}for(var ns=0;ns<Qa.length;ns++){var as=Qa[ns],q=as._seqIndices,fi=as._sosType,l1=as._eosType,Cr=K[q[0]]&1?A:_;if(Y.get(M))for(var Fn=0;Fn<q.length;Fn++){var Lu=q[Fn];if(C[Lu]&M){for(var ss=fi,Tn=Fn-1;Tn>=0;Tn--)if(!(C[q[Tn]]&o)){ss=C[q[Tn]];break}G(Lu,ss&(n|Zt)?$:ss)}}if(Y.get(S))for(var kn=0;kn<q.length;kn++){var Vu=q[kn];if(C[Vu]&S)for(var In=kn-1;In>=-1;In--){var Ou=In===-1?fi:C[q[In]];if(Ou&a){Ou===j&&G(Vu,V);break}}}if(Y.get(j))for(var os=0;os<q.length;os++){var Ru=q[os];C[Ru]&j&&G(Ru,A)}if(Y.get(F)||Y.get(P))for(var di=1;di<q.length-1;di++){var ls=q[di];if(C[ls]&(F|P)){for(var Mr=0,us=0,hs=di-1;hs>=0&&(Mr=C[q[hs]],Mr&o);hs--);for(var cs=di+1;cs<q.length&&(us=C[q[cs]],us&o);cs++);Mr===us&&(C[ls]===F?Mr===S:Mr&(S|V))&&G(ls,Mr)}}if(Y.get(S)){for(var ye=0;ye<q.length;ye++)if(C[q[ye]]&S){for(var Cn=ye-1;Cn>=0&&C[q[Cn]]&(L|o);Cn--)G(q[Cn],S);for(ye++;ye<q.length&&C[q[ye]]&(L|o|S);ye++)C[q[ye]]!==S&&G(q[ye],S)}}if(Y.get(L)||Y.get(F)||Y.get(P))for(var yi=0;yi<q.length;yi++){var $u=q[yi];if(C[$u]&(L|F|P)){G($u,$);for(var Mn=yi-1;Mn>=0&&C[q[Mn]]&o;Mn--)G(q[Mn],$);for(var Bn=yi+1;Bn<q.length&&C[q[Bn]]&o;Bn++)G(q[Bn],$)}}if(Y.get(S))for(var ps=0,Nu=fi;ps<q.length;ps++){var Uu=q[ps],fs=C[Uu];fs&S?Nu===_&&G(Uu,_):fs&a&&(Nu=fs)}if(Y.get(s)){for(var mi=A|S|V,qu=mi|_,Pn=[],Br=[],Pr=0;Pr<q.length;Pr++)if(C[q[Pr]]&s){var gi=N[q[Pr]],ju=void 0;if(b(gi)!==null)if(Br.length<63)Br.push({char:gi,seqIndex:Pr});else break;else if((ju=v(gi))!==null)for(var xi=Br.length-1;xi>=0;xi--){var ds=Br[xi].char;if(ds===ju||ds===v(w(gi))||b(w(ds))===gi){Pn.push([Br[xi].seqIndex,Pr]),Br.length=xi;break}}}Pn.sort(function(Yt,oe){return Yt[0]-oe[0]});for(var ys=0;ys<Pn.length;ys++){for(var Gu=Pn[ys],zn=Gu[0],ms=Gu[1],Yu=!1,me=0,gs=zn+1;gs<ms;gs++){var Xu=q[gs];if(C[Xu]&qu){Yu=!0;var Wu=C[Xu]&mi?A:_;if(Wu===Cr){me=Wu;break}}}if(Yu&&!me){me=fi;for(var xs=zn-1;xs>=0;xs--){var Zu=q[xs];if(C[Zu]&qu){var Hu=C[Zu]&mi?A:_;me=Hu===Cr?Cr:Hu;break}}}if(me){if(C[q[zn]]=C[q[ms]]=me,me!==Cr){for(var vi=zn+1;vi<q.length;vi++)if(!(C[q[vi]]&o)){c(N[q[vi]])&M&&(C[q[vi]]=me);break}}if(me!==Cr){for(var bi=ms+1;bi<q.length;bi++)if(!(C[q[bi]]&o)){c(N[q[bi]])&M&&(C[q[bi]]=me);break}}}}for(var $e=0;$e<q.length;$e++)if(C[q[$e]]&s){for(var Ku=$e,vs=$e,bs=fi,wi=$e-1;wi>=0;wi--)if(C[q[wi]]&o)Ku=wi;else{bs=C[q[wi]]&mi?A:_;break}for(var Ju=l1,Di=$e+1;Di<q.length;Di++)if(C[q[Di]]&(s|o))vs=Di;else{Ju=C[q[Di]]&mi?A:_;break}for(var ws=Ku;ws<=vs;ws++)C[q[ws]]=bs===Ju?bs:Cr;$e=vs}}}for(var Ht=nt.start;Ht<=nt.end;Ht++){var u1=K[Ht],Ln=C[Ht];if(u1&1?Ln&(_|S|V)&&K[Ht]++:Ln&A?K[Ht]++:Ln&(V|S)&&(K[Ht]+=2),Ln&o&&(K[Ht]=Ht===0?nt.level:K[Ht-1]),Ht===nt.end||c(N[Ht])&(E|R))for(var Vn=Ht;Vn>=0&&c(N[Vn])&l;Vn--)K[Vn]=nt.level}}return{levels:K,paragraphs:vt};function Qu(Yt,oe){for(var Xt=Yt;Xt<N.length;Xt++){var Ne=C[Xt];if(Ne&(A|j))return 1;if(Ne&(R|_)||oe&&Ne===Zt)return 0;if(Ne&n){var th=h1(Xt);Xt=th===-1?N.length:th}}return 0}function h1(Yt){for(var oe=1,Xt=Yt+1;Xt<N.length;Xt++){var Ne=C[Xt];if(Ne&R)break;if(Ne&Zt){if(--oe===0)return Xt}else Ne&n&&oe++}return-1}}var Er="14>1,j>2,t>2,u>2,1a>g,2v3>1,1>1,1ge>1,1wd>1,b>1,1j>1,f>1,ai>3,-2>3,+1,8>1k0,-1jq>1y7,-1y6>1hf,-1he>1h6,-1h5>1ha,-1h8>1qi,-1pu>1,6>3u,-3s>7,6>1,1>1,f>1,1>1,+2,3>1,1>1,+13,4>1,1>1,6>1eo,-1ee>1,3>1mg,-1me>1mk,-1mj>1mi,-1mg>1mi,-1md>1,1>1,+2,1>10k,-103>1,1>1,4>1,5>1,1>1,+10,3>1,1>8,-7>8,+1,-6>7,+1,a>1,1>1,u>1,u6>1,1>1,+5,26>1,1>1,2>1,2>2,8>1,7>1,4>1,1>1,+5,b8>1,1>1,+3,1>3,-2>1,2>1,1>1,+2,c>1,3>1,1>1,+2,h>1,3>1,a>1,1>1,2>1,3>1,1>1,d>1,f>1,3>1,1a>1,1>1,6>1,7>1,13>1,k>1,1>1,+19,4>1,1>1,+2,2>1,1>1,+18,m>1,a>1,1>1,lk>1,1>1,4>1,2>1,f>1,3>1,1>1,+3,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,6>1,4j>1,j>2,t>2,u>2,2>1,+1",er;function ci(){if(!er){var N=d(Er,!0),Q=N.map;N.reverseMap.forEach(function(Z,C){Q.set(C,Z)}),er=Q}}function Tt(N){return ci(),er.get(N)||null}function Ee(N,Q,Z,C){var ut=N.length;Z=Math.max(0,Z==null?0:+Z),C=Math.min(ut-1,C==null?ut-1:+C);for(var Y=new Map,G=Z;G<=C;G++)if(Q[G]&1){var K=Tt(N[G]);K!==null&&Y.set(G,K)}return Y}function rr(N,Q,Z,C){var ut=N.length;Z=Math.max(0,Z==null?0:+Z),C=Math.min(ut-1,C==null?ut-1:+C);var Y=[];return Q.paragraphs.forEach(function(G){var K=Math.max(Z,G.start),$t=Math.min(C,G.end);if(K<$t){for(var vt=Q.levels.slice(K,$t+1),nt=$t;nt>=K&&c(N[nt])&l;nt--)vt[nt]=G.level;for(var kt=G.level,pi=1/0,ir=0;ir<vt.length;ir++){var Ve=vt[ir];Ve>kt&&(kt=Ve),Ve<pi&&(pi=Ve|1)}for(var Oe=kt;Oe>=pi;Oe--)for(var ot=0;ot<vt.length;ot++)if(vt[ot]>=Oe){for(var bt=ot;ot+1<vt.length&&vt[ot+1]>=Oe;)ot++;ot>bt&&Y.push([bt+K,ot+K])}}}),Y}function Fr(N,Q,Z,C){var ut=Tr(N,Q,Z,C),Y=[].concat(N);return ut.forEach(function(G,K){Y[K]=(Q.levels[G]&1?Tt(N[G]):null)||N[G]}),Y.join("")}function Tr(N,Q,Z,C){for(var ut=rr(N,Q,Z,C),Y=[],G=0;G<N.length;G++)Y[G]=G;return ut.forEach(function(K){for(var $t=K[0],vt=K[1],nt=Y.slice($t,vt+1),kt=nt.length;kt--;)Y[vt-kt]=nt[kt]}),Y}return t.closingToOpeningBracket=v,t.getBidiCharType=c,t.getBidiCharTypeName=p,t.getCanonicalBracket=w,t.getEmbeddingLevels=Sr,t.getMirroredCharacter=Tt,t.getMirroredCharactersMap=Ee,t.getReorderSegments=rr,t.getReorderedIndices=Tr,t.getReorderedString=Fr,t.openingToClosingBracket=b,Object.defineProperty(t,"__esModule",{value:!0}),t})({})}var eu=bv(),wv=/[\\u061c\\u200e\\u200f\\u202a-\\u202e\\u2066-\\u2069]/,Dv=new Set(["WS","FSI","LRI","RLI","PDI"]),_v=new Set(["S","B"]);function Av(t,e,r,i){let n=[],a=r;for(let s of Ko(t.slice(r,i)))n.push({index:a,text:s,level:e[a]}),a+=s.length;return n}function Sv(t,e){let r=!0;for(let i=t.length-1;i>=0;i--){let n=eu.getBidiCharTypeName(t[i].text[0]);_v.has(n)?(t[i].level=e,r=!0):r&&Dv.has(n)?t[i].level=e:r=!1}}function Ev(t,e){let r=e,i=1/0;for(let{level:a}of t)a>r&&(r=a),(a|1)<i&&(i=a|1);let n=t.slice();for(let a=r;a>=i;a--)for(let s=0;s<n.length;s++){if(n[s].level<a)continue;let o=s;for(;o+1<n.length&&n[o+1].level>=a;)o++;for(let l=s,u=o;l<u;l++,u--)[n[l],n[u]]=[n[u],n[l]];s=o}return n}function Fv(t){return t.level%2==0?t.text:eu.getMirroredCharacter(t.text)??t.text}function Tv(t,e){return t.find(r=>e>=r.start&&e<=r.end)?.level??0}function kv(t,e,r,i,n){let a=Av(t,e,i,n);Sv(a,r);let s="",o=[];for(let l of Ev(a,r)){if(wv.test(l.text))continue;let u=Fv(l);s+=u,o.push(...Array(u.length).fill(l.index))}return{text:s,sourceIndices:o}}function Iv(t,e){let r=e.filter(a=>a>0&&a<t.length),i=[...new Set([0,...r,t.length])].sort((a,s)=>a-s),n=[];for(let a=0;a+1<i.length;a++)n.push([i[a],i[a+1]]);return n}function Hd(t,e){let{levels:r,paragraphs:i}=eu.getEmbeddingLevels(t);return Iv(t,e.concat(i.map(n=>n.start))).map(([n,a])=>kv(t,r,Tv(i,n),n,a))}function Cv(t,e){return Hd(t,e).map(r=>r.text)}function Mv(t,e,r){return Hd(t,r).map(i=>[i.text,i.sourceIndices.map(n=>e[n]??0)])}var tl=4294967296,Cc=1/tl,Mc=typeof TextDecoder>"u"?null:new TextDecoder("utf-8"),ru=class{constructor(t){this.buf=ArrayBuffer.isView(t)?t:new Uint8Array(t),this.dataView=new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength),this.pos=0,this.type=0,this._valueStart=-1,this.length=this.buf.length}readFields(t,e,r=this.length){let i;for(;i=this.nextField(r);)t(i,e,this);return e}readMessage(t,e){return this.readFields(t,e,this.readVarint()+this.pos)}readFixed32(){let t=this.dataView.getUint32(this.pos,!0);return this.pos+=4,t}readSFixed32(){let t=this.dataView.getInt32(this.pos,!0);return this.pos+=4,t}readFixed64(){let t=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*tl;return this.pos+=8,t}readSFixed64(){let t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*tl;return this.pos+=8,t}readFloat(){let t=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,t}readDouble(){let t=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,t}readVarint(t){let e=this.buf,r=e[this.pos++];if(r<128)return r;let i=r&127,n;return n=e[this.pos++],i|=(n&127)<<7,n<128||(n=e[this.pos++],i|=(n&127)<<14,n<128)||(n=e[this.pos++],i|=(n&127)<<21,n<128)?i:(n=e[this.pos],i|=(n&15)<<28,Pv(i,t,this))}readSVarint(){let t=this.readVarint();return t%2==1?(t+1)/-2:t/2}readBoolean(){return!!this.readVarint()}readString(){let t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&Mc?Mc.decode(this.buf.subarray(e,t)):Wv(this.buf,e,t)}readBytes(){let t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e}readPackedVarint(t=[],e){let r=this.readPackedEnd();for(;this.pos<r;)t.push(this.readVarint(e));return t}readPackedSVarint(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSVarint());return t}readPackedBoolean(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readBoolean());return t}readPackedFloat(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFloat());return t}readPackedDouble(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readDouble());return t}readPackedFixed32(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFixed32());return t}readPackedSFixed32(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSFixed32());return t}readPackedFixed64(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFixed64());return t}readPackedSFixed64(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSFixed64());return t}readPackedEnd(){return this.type===2?this.readVarint()+this.pos:this.pos+1}nextField(t=this.length){if(this.pos===this._valueStart&&this.skip(this.type),this.pos>=t)return 0;let e=this.readVarint();return this.type=e&7,this._valueStart=this.pos,e>>>3}skip(t){let e=t&7;if(e===0)for(;this.buf[this.pos++]>127;);else if(e===2)this.pos=this.readVarint()+this.pos;else if(e===5)this.pos+=4;else if(e===1)this.pos+=8;else throw Error(`Unimplemented type: ${e}`)}},Bv=class{constructor(t=new Uint8Array(16)){this.buf=ArrayBuffer.isView(t)?t:new Uint8Array(t),this.dataView=new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength),this.pos=0,this.length=this.buf.length}writeTag(t,e){this.writeVarint(t<<3|e)}realloc(t){let e=this.length||16;for(;e<this.pos+t;)e*=2;if(e!==this.length){let r=new Uint8Array(e);r.set(this.buf),this.buf=r,this.dataView=new DataView(r.buffer),this.length=e}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4}writeSFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4}writeFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,t&-1,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*Cc),!0),this.pos+=8}writeSFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,t&-1,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*Cc),!0),this.pos+=8}writeVarint(t){if(t=+t||0,t>=0&&t<128){this.pos>=this.length&&this.realloc(1),this.buf[this.pos++]=t;return}if(t>268435455||t<0){Lv(t,this);return}this.realloc(4),this.buf[this.pos++]=t&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=t>>>7&127)))}writeSVarint(t){this.writeVarint(t<0?-t*2-1:t*2)}writeBoolean(t){this.writeVarint(+t)}writeString(t){t=String(t),this.realloc(t.length*4),this.pos++;let e=this.pos;this.pos=Zv(this.buf,t,this.pos);let r=this.pos-e;r>=128&&Bc(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r}writeFloat(t){this.realloc(4),this.dataView.setFloat32(this.pos,t,!0),this.pos+=4}writeDouble(t){this.realloc(8),this.dataView.setFloat64(this.pos,t,!0),this.pos+=8}writeBytes(t){let e=t.length;this.writeVarint(e),this.realloc(e),this.buf.set(t,this.pos),this.pos+=e}writeRawMessage(t,e){this.pos++;let r=this.pos;t(e,this);let i=this.pos-r;i>=128&&Bc(r,i,this),this.pos=r-1,this.writeVarint(i),this.pos+=i}writeMessage(t,e,r){this.writeTag(t,2),this.writeRawMessage(e,r)}writePackedVarint(t,e){e.length&&this.writeMessage(t,Rv,e)}writePackedSVarint(t,e){e.length&&this.writeMessage(t,$v,e)}writePackedBoolean(t,e){e.length&&this.writeMessage(t,qv,e)}writePackedFloat(t,e){e.length&&this.writeMessage(t,Nv,e)}writePackedDouble(t,e){e.length&&this.writeMessage(t,Uv,e)}writePackedFixed32(t,e){e.length&&this.writeMessage(t,jv,e)}writePackedSFixed32(t,e){e.length&&this.writeMessage(t,Gv,e)}writePackedFixed64(t,e){e.length&&this.writeMessage(t,Yv,e)}writePackedSFixed64(t,e){e.length&&this.writeMessage(t,Xv,e)}writeBytesField(t,e){this.writeTag(t,2),this.writeBytes(e)}writeFixed32Field(t,e){this.writeTag(t,5),this.writeFixed32(e)}writeSFixed32Field(t,e){this.writeTag(t,5),this.writeSFixed32(e)}writeFixed64Field(t,e){this.writeTag(t,1),this.writeFixed64(e)}writeSFixed64Field(t,e){this.writeTag(t,1),this.writeSFixed64(e)}writeVarintField(t,e){this.writeTag(t,0),this.writeVarint(e)}writeSVarintField(t,e){this.writeTag(t,0),this.writeSVarint(e)}writeStringField(t,e){this.writeTag(t,2),this.writeString(e)}writeFloatField(t,e){this.writeTag(t,5),this.writeFloat(e)}writeDoubleField(t,e){this.writeTag(t,1),this.writeDouble(e)}writeBooleanField(t,e){this.writeVarintField(t,+e)}};function Pv(t,e,r){let i=r.buf,n,a;if(a=i[r.pos++],n=(a&112)>>4,a<128||(a=i[r.pos++],n|=(a&127)<<3,a<128)||(a=i[r.pos++],n|=(a&127)<<10,a<128)||(a=i[r.pos++],n|=(a&127)<<17,a<128)||(a=i[r.pos++],n|=(a&127)<<24,a<128)||(a=i[r.pos++],n|=(a&1)<<31,a<128))return zv(t,n,e);throw Error("Expected varint not more than 10 bytes")}function zv(t,e,r){return r?e*4294967296+(t>>>0):(e>>>0)*4294967296+(t>>>0)}function Lv(t,e){let r,i;if(t>=0?(r=t%4294967296|0,i=t/4294967296|0):(r=~(-t%4294967296),i=~(-t/4294967296),r^4294967295?r=r+1|0:(r=0,i=i+1|0)),t>=18446744073709552e3||t<-18446744073709552e3)throw Error("Given varint doesn\'t fit into 10 bytes");e.realloc(10),Vv(r,i,e),Ov(i,e)}function Vv(t,e,r){r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos]=t&127}function Ov(t,e){let r=(t&7)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127)))))}function Bc(t,e,r){let i=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(Math.LN2*7));r.realloc(i),r.buf.copyWithin(t+i,t,r.pos)}function Rv(t,e){let r=t.length,i=e.buf,n=e.pos,a=e.length;for(let s=0;s<r;s++){let o=t[s];if(o<0||n+10>a){e.pos=n,e.writeVarint(o),i=e.buf,n=e.pos,a=e.length;continue}for(;o>127;)i[n++]=o%128|128,o=Math.floor(o/128);i[n++]=o}e.pos=n}function $v(t,e){for(let r=0;r<t.length;r++)e.writeSVarint(t[r])}function Nv(t,e){for(let r=0;r<t.length;r++)e.writeFloat(t[r])}function Uv(t,e){for(let r=0;r<t.length;r++)e.writeDouble(t[r])}function qv(t,e){for(let r=0;r<t.length;r++)e.writeBoolean(t[r])}function jv(t,e){for(let r=0;r<t.length;r++)e.writeFixed32(t[r])}function Gv(t,e){for(let r=0;r<t.length;r++)e.writeSFixed32(t[r])}function Yv(t,e){for(let r=0;r<t.length;r++)e.writeFixed64(t[r])}function Xv(t,e){for(let r=0;r<t.length;r++)e.writeSFixed64(t[r])}function Wv(t,e,r){let i="",n=e;for(;n<r;){let a=t[n],s=null,o=a>239?4:a>223?3:a>191?2:1;if(n+o>r)break;let l,u,h;o===1?a<128&&(s=a):o===2?(l=t[n+1],(l&192)==128&&(s=(a&31)<<6|l&63,s<=127&&(s=null))):o===3?(l=t[n+1],u=t[n+2],(l&192)==128&&(u&192)==128&&(s=(a&15)<<12|(l&63)<<6|u&63,(s<=2047||s>=55296&&s<=57343)&&(s=null))):o===4&&(l=t[n+1],u=t[n+2],h=t[n+3],(l&192)==128&&(u&192)==128&&(h&192)==128&&(s=(a&15)<<18|(l&63)<<12|(u&63)<<6|h&63,(s<=65535||s>=1114112)&&(s=null))),s===null?(s=65533,o=1):s>65535&&(s-=65536,i+=String.fromCharCode(s>>>10&1023|55296),s=56320|s&1023),i+=String.fromCharCode(s),n+=o}return i}function Zv(t,e,r){for(let i=0,n,a;i<e.length;i++){if(n=e.charCodeAt(i),n>55295&&n<57344)if(a){if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,a=n;continue}n=a-55296<<10|n-56320|65536,a=null}else{n>56319||i+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):a=n;continue}else a&&(a=(t[r++]=239,t[r++]=191,t[r++]=189,null));n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=n&63|128)}return r}function Hv(t){return typeof t?.renderWithWebGL=="function"}function iu(t){let e=0,r=0;for(let s of t)e+=s.w*s.h,r=Math.max(r,s.w);t.sort((s,o)=>o.h-s.h);let i=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}],n=0,a=0;for(let s of t)for(let o=i.length-1;o>=0;o--){let l=i[o];if(!(s.w>l.w||s.h>l.h)){if(s.x=l.x,s.y=l.y,a=Math.max(a,s.y+s.h),n=Math.max(n,s.x+s.w),s.w===l.w&&s.h===l.h){let u=i.pop();u&&o<i.length&&(i[o]=u)}else s.h===l.h?(l.x+=s.w,l.w-=s.w):s.w===l.w?(l.y+=s.h,l.h-=s.h):(i.push({x:l.x+s.w,y:l.y,w:l.w-s.w,h:s.h}),l.y+=s.h,l.h-=s.h);break}}return{w:n,h:a,fill:e/(n*a)||0}}var Kd=class{constructor(t,{pixelRatio:e,version:r,isWebGLImage:i=!1,stretchX:n,stretchY:a,content:s,textFitWidth:o,textFitHeight:l}){this.paddedRect=t,this.pixelRatio=e,this.stretchX=n,this.stretchY=a,this.content=s,this.version=r,this.needsFirstWebGLRender=i,this.textFitWidth=o,this.textFitHeight=l}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]}},nu=class{constructor(t,e){let r={},i={};this.haveRenderCallbacks=[],this.patchedUpdateVersion=-1;let n=[];this.addImages(t,r,n),this.addImages(e,i,n);let{w:a,h:s}=iu(n),o=new Wt({width:a||1,height:s||1});for(let l in t){let u=t[l];if(u.isWebGLImage)continue;let h=r[l].paddedRect;Wt.copy(u.data,o,{x:0,y:0},{x:h.x+1,y:h.y+1},u.data)}for(let l in e){let u=e[l],h=i[l].paddedRect,c=h.x+1,p=h.y+1,f=u.data.width,d=u.data.height;Wt.copy(u.data,o,{x:0,y:0},{x:c,y:p},u.data),Wt.copy(u.data,o,{x:0,y:d-1},{x:c,y:p-1},{width:f,height:1}),Wt.copy(u.data,o,{x:0,y:0},{x:c,y:p+d},{width:f,height:1}),Wt.copy(u.data,o,{x:f-1,y:0},{x:c-1,y:p},{width:1,height:d}),Wt.copy(u.data,o,{x:0,y:0},{x:c+f,y:p},{width:1,height:d})}this.image=o,this.iconPositions=r,this.patternPositions=i}addImages(t,e,r){for(let i in t){let n=t[i],a={x:0,y:0,w:n.data.width+2,h:n.data.height+2};r.push(a),e[i]=new Kd(a,n),n.hasRenderCallback&&this.haveRenderCallbacks.push(i)}}patchUpdatedImages(t,e){if(t.dispatchRenderCallbacks(this.haveRenderCallbacks),this.patchedUpdateVersion!==t.updateVersion){this.patchedUpdateVersion=t.updateVersion;for(let r in this.iconPositions)this.patchUpdatedImage(this.iconPositions[r],t.getImage(r),e);for(let r in this.patternPositions)this.patchUpdatedImage(this.patternPositions[r],t.getImage(r),e)}}patchUpdatedImage(t,e,r){if(!t||!e||!t.needsFirstWebGLRender&&t.version===e.version)return;t.needsFirstWebGLRender=!1,t.version=e.version;let[i,n]=t.tl,a=e.userImage?.data;if(!Hv(a)){r.update(e.data,void 0,{x:i,y:n});return}let{width:s,height:o}=e.data;r.context.setCustomLayerDefaults(),a.renderWithWebGL({gl:r.context.gl,texture:r.texture,x:i,y:n,width:s,height:o}),r.context.setDirty()}};I("ImagePosition",Kd),I("ImageAtlas",nu);var Jd=(function(t){return t[t.none=0]="none",t[t.horizontal=1]="horizontal",t[t.vertical=2]="vertical",t[t.horizontalOnly=3]="horizontalOnly",t})(Jd||{});function Kv(t){for(let e of t)if(e.positionedGlyphs.length!==0)return!1;return!0}function Jv(t,e){let r=[],i=0;for(let n of e)r.push(t.substring(i,n)),i=n;return i<t.length()&&r.push(t.substring(i,t.length())),r}var Pc=/^\\p{gc=M}$/u;function Qv(t){let e=[],r=0;for(;r<t.length;){if(!Pc.test(t[r])){e.push(r),r++;continue}let i=r;for(;i<t.length&&Pc.test(t[i]);)i++;let n=t[i];if(n!==void 0&&Xd(n.codePointAt(0))){e.push(i);for(let a=i-1;a>=r;a--)e.push(a);r=i+1}else{for(let a=r;a<i;a++)e.push(a);r=i}}return e}function tb(t){let e=[],r=0;for(let i of t.graphemes())e.push(...Array(i.length).fill(t.sectionIndex[r])),r++;return e}function eb(t,e){let r=e.map(a=>t.toCodeUnitIndex(a)),i=vr.isParsed()?vr:null;if(t.sections.length===1)return i?i.processBidirectionalText(t.toString(),r).map(a=>zc(a,t.sections,[...a].map(()=>0))):Cv(t.toString(),r).map(a=>el([...a],t.sections,[...a].map(()=>0)));let n=tb(t);return i?i.processStyledBidirectionalText(t.text,n,r).map(([a,s])=>zc(a,t.sections,s)):Mv(t.text,n,r).map(([a,s])=>{let o=[...a];return el(o,t.sections,Qd(o).map(l=>s[l]??0))})}function el(t,e,r){let i=new tu(t.join(""),e,[]),n=0;for(let a of i.graphemes())i.sectionIndex.push(r[n]??0),n+=[...a].length;return i}function Qd(t){let e=[],r=0;for(let i of t)e.push(r),r+=i.length;return e}function zc(t,e,r){let i=[...t],n=Qd(i),a=Qv(i);return el(a.map(s=>i[s]),e,a.map(s=>r[n[s]]??0))}function Hn(t,e,r,i,n,a,s,o,l,u,h,c,p,f,d){let y=tu.fromFeature(t,n);c===2&&y.verticalizePunctuation();let m=y.determineLineBreaks(u,a,e,i,f),g=Wd(y.text)?eb(y,m):Jv(y,m),x=[],b={positionedLines:x,text:y.toString(),top:h[1],bottom:h[1],left:h[0],right:h[0],writingMode:c,iconsInText:!1,verticalizable:!1};return hb(b,e,r,i,g,s,o,l,c,u,p,d),!Kv(x)&&b}function ty(t){let e=.5,r=.5;switch(t){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(t){case"bottom":case"bottom-right":case"bottom-left":r=1;break;case"top":case"top-right":case"top-left":r=0}return{horizontalAlign:e,verticalAlign:r}}function rb(t,e,r){let i=e.getMaxScale()*24,{maxImageWidth:n,maxImageHeight:a}=e.getMaxImageSize(t),s=Math.max(i,a*r);return{verticalLineContentWidth:Math.max(i,n*r),horizontalLineContentHeight:s}}function ey(t){switch(t){case"top":return 0;case"center":return .5;default:return 1}}function ib(t,e,r,i){if(t?.rect)return t;let n=e[r.fontStack]?.[i];return n?{rect:null,metrics:n.metrics}:null}function nb(t,e,r){return!(t===1||!e&&!Xa(r)||e&&(Ql(r)||Yd(r)))}function la(t){return/\\p{Nd}/u.test(String.fromCodePoint(t))}function ry(t){return/\\p{Lu}/u.test(String.fromCodePoint(t))}function ab(t){return/[\\p{P}\\p{S}]/u.test(String.fromCodePoint(t))}function sb(t){let e=t.some(la)&&t.every(i=>la(i)||ab(i)),r=t.length<=3&&t.every(i=>ry(i)||la(i));return e||r}function ob(t){return(la(t)||ry(t))&&!Yd(t)}function lb(t,e){let r=!1;for(let i=0;i<t.length;i++){if(e[i])continue;let n=qr[t[i]];n&&(i===0||e[i-1])&&(i===t.length-1||e[i+1])&&(t[i]=n,e[i]=!0,r=!0)}return r}function ub(t){let e=t.graphemes().slice(),r=e.map(a=>a.codePointAt(0)),i=r.map(Xa),n=a=>!i[a]&&!Ql(r[a])&&!("imageName"in t.getSection(a));for(let a=0;a<r.length;a++){if(!n(a))continue;let s=a;for(;s+1<r.length&&n(s+1);)s++;if(sb(r.slice(a,s+1)))for(let o=a;o<=s;o++)i[o]=ob(r[o]);a=s}return lb(e,i)&&(t.text=e.join(""),t._graphemes=null),i}function hb(t,e,r,i,n,a,s,o,l,u,h,c){let p=0,f=0,d=0,y=0,m=o==="right"?1:o==="left"?0:.5,g=24/c,x=0;for(let w of n){w.trim();let _=w.getMaxScale(),A={positionedGlyphs:[],lineOffset:0};t.positionedLines[x]=A;let S=A.positionedGlyphs,F=0;if(!w.length()){f+=a,++x;continue}let L=rb(i,w,g),V=l===2&&!h?ub(w):null,P=w.graphemes();for(let $=0;$<P.length;$++){let O=w.getSection($),M=P[$],j=M.codePointAt(0),it=V?V[$]:nb(l,h,j),pt="fontStack"in O&&Gd(M)&&!e[O.fontStack]?.[M]?[...M]:[M];for(let st of pt){let ft={glyph:st.codePointAt(0),grapheme:st,imageName:null,x:p,y:f+-17,vertical:it,scale:1,fontStack:"",sectionIndex:w.getSectionIndex($),metrics:null,rect:null},Gt;if("fontStack"in O){if(Gt=cb(O,st,it,L,e,r),!Gt)continue;ft.fontStack=O.fontStack}else{if(t.iconsInText=!0,O.scale*=g,Gt=pb(O,it,_,L,i),!Gt)continue;F=Math.max(F,Gt.imageOffset),ft.imageName=O.imageName}let{rect:ze,metrics:fe,baselineOffset:Le}=Gt;if(ft.y+=Le,ft.scale=O.scale,ft.metrics=fe,ft.rect=ze,S.push(ft),!it)p+=fe.advance*O.scale+u;else{t.verticalizable=!0;let Zt="imageName"in O?fe.advance:24;p+=Zt*O.scale+u}}}if(S.length!==0){let $=p-u;d=Math.max($,d),fb(S,0,S.length-1,m)}p=0;let R=(_-1)*24;A.lineOffset=Math.max(F,R);let E=a*_+F;f+=E,y=Math.max(E,y),++x}let{horizontalAlign:b,verticalAlign:v}=ty(s);db(t.positionedLines,m,b,v,d,y,a,f,n.length),t.top+=-v*f,t.bottom=t.top+f,t.left+=-b*d,t.right=t.left+d}function cb(t,e,r,i,n,a){let s=a[t.fontStack]?.[e],o=ib(s,n,t,e);if(o===null)return null;let l;if(r)l=i.verticalLineContentWidth-t.scale*24;else{let u=ey(t.verticalAlign);l=(i.horizontalLineContentHeight-t.scale*24)*u}return{rect:o.rect,metrics:o.metrics,baselineOffset:l}}function pb(t,e,r,i,n){let a=n[t.imageName];if(!a)return null;let s=a.paddedRect,o=a.displaySize,l={width:o[0],height:o[1],left:1,top:-3,advance:e?o[1]:o[0]},u;if(e)u=i.verticalLineContentWidth-o[1]*t.scale;else{let c=ey(t.verticalAlign);u=(i.horizontalLineContentHeight-o[1]*t.scale)*c}let h=(e?o[0]:o[1])*t.scale-24*r;return{rect:s,metrics:l,baselineOffset:u,imageOffset:h}}function fb(t,e,r,i){if(i===0)return;let n=t[r],a=n.metrics.advance*n.scale,s=(t[r].x+a)*i;for(let o=e;o<=r;o++)t[o].x-=s}function db(t,e,r,i,n,a,s,o,l){let u=(e-r)*n,h=0;h=a===s?-i*l*s+.5*s:-o*i- -17;for(let c of t)for(let p of c.positionedGlyphs)p.x+=u,p.y+=h}function yb(t,e,r){let{horizontalAlign:i,verticalAlign:n}=ty(r),a=e[0],s=e[1],o=a-t.displaySize[0]*i,l=o+t.displaySize[0],u=s-t.displaySize[1]*n;return{image:t,top:u,bottom:u+t.displaySize[1],left:o,right:l}}function iy(t){let e=t.left,r=t.top,i=t.right-e,n=t.bottom-r,a=t.image.content[2]-t.image.content[0],s=t.image.content[3]-t.image.content[1],o=t.image.textFitWidth??"stretchOrShrink",l=t.image.textFitHeight??"stretchOrShrink",u=a/s;if(l==="proportional"){if(o==="stretchOnly"&&i/n<u||o==="proportional"){let h=Math.ceil(n*u);e*=h/i,i=h}}else if(o==="proportional"&&l==="stretchOnly"&&u!==0&&i/n>u){let h=Math.ceil(i/u);r*=h/n,n=h}return{x1:e,y1:r,x2:e+i,y2:r+n}}function Lc(t,e,r,i,n,a){let s=t.image,o;if(s.content){let m=s.content,g=s.pixelRatio||1;o=[m[0]/g,m[1]/g,s.displaySize[0]-m[2]/g,s.displaySize[1]-m[3]/g]}let l=e.left*a,u=e.right*a,h,c,p,f;r==="width"||r==="both"?(f=n[0]+l-i[3],c=n[0]+u+i[1]):(f=n[0]+(l+u-s.displaySize[0])/2,c=f+s.displaySize[0]);let d=e.top*a,y=e.bottom*a;return r==="height"||r==="both"?(h=n[1]+d-i[0],p=n[1]+y+i[2]):(h=n[1]+(d+y-s.displaySize[1])/2,p=h+s.displaySize[1]),{image:s,top:h,right:c,bottom:p,left:f,collisionPadding:o}}var Vc=32640;function Oc(t,e){let{expression:r}=e;if(r.kind==="constant")return{kind:"constant",layoutSize:r.evaluate(new at(t+1))};if(r.kind==="source")return{kind:"source"};if(r.kind==="composite"){let{minZoom:i,maxZoom:n}=mb(r.zoomStops,t);return{kind:"composite",minZoom:i,maxZoom:n,interpolationType:r.interpolationType}}{let i=gb(r),n=r.evaluate(new at(t+1));return{kind:"camera",zoomStops:r.zoomStops,sizes:i,layoutSize:n,interpolationType:r.interpolationType}}}function mb(t,e){let r=0;for(;r<t.length&&t[r]<=e;)r++;r=Math.max(0,r-1);let i=r;for(;i<t.length&&t[i]<e+1;)i++;return i=Math.min(t.length-1,i),{minZoom:t[r],maxZoom:t[i]}}function gb(t){return t.zoomStops.map(e=>t.evaluate(new at(e===-1/0?t.zoomStops[1]-1:e)))}var Hr=class ny extends B{constructor(e,r,i,n){super(e,r),this.angle=i,n!==void 0&&(this.segment=n)}clone(){return new ny(this.x,this.y,this.angle,this.segment)}};I("Anchor",Hr);function ay(t,e,r,i,n){if(e.segment===void 0||r===0)return!0;let a=e,s=e.segment+1,o=0;for(;o>-r/2;){if(s--,s<0)return!1;o-=t[s].dist(a),a=t[s]}o+=t[s].dist(t[s+1]),s++;let l=[],u=0;for(;o<r/2;){let h=t[s-1],c=t[s],p=t[s+1];if(!p)return!1;let f=h.angleTo(c)-c.angleTo(p);for(f=Math.abs((f+3*Math.PI)%(Math.PI*2)-Math.PI),l.push({distance:o,angleDelta:f}),u+=f;o-l[0].distance>i;)u-=l.shift().angleDelta;if(u>n)return!1;s++,o+=c.dist(p)}return!0}function sy(t){let e=0;for(let r=0;r<t.length-1;r++)e+=t[r].dist(t[r+1]);return e}function oy(t,e,r){return t?3/5*e*r:0}function ly(t,e){return Math.max(t?t.right-t.left:0,e?e.right-e.left:0)}function xb(t,e,r,i,n,a){let s=oy(r,n,a),o=ly(r,i)*a,l=0,u=sy(t)/2;for(let h=0;h<t.length-1;h++){let c=t[h],p=t[h+1],f=c.dist(p);if(l+f>u){let d=(u-l)/f,y=new Hr(yr.number(c.x,p.x,d),yr.number(c.y,p.y,d),p.angleTo(c),h);return y._round(),!s||ay(t,y,o,s,e)?y:void 0}l+=f}}function vb(t,e,r,i,n,a,s,o,l){let u=oy(i,a,s),h=ly(i,n),c=h*s,p=t[0].x===0||t[0].x===l||t[0].y===0||t[0].y===l;e-c<e/4&&(e=c+e/4);let f=a*2;return uy(t,p?e/2*o%e:(h/2+f)*s*o%e,e,u,r,c,p,!1,l)}function uy(t,e,r,i,n,a,s,o,l){let u=a/2,h=sy(t),c=0,p=e-r,f=[];for(let d=0;d<t.length-1;d++){let y=t[d],m=t[d+1],g=y.dist(m),x=m.angleTo(y);for(;p+r<c+g;){p+=r;let b=(p-c)/g,v=yr.number(y.x,m.x,b),w=yr.number(y.y,m.y,b);if(v>=0&&v<l&&w>=0&&w<l&&p-u>=0&&p+u<=h){let _=new Hr(v,w,x,d);_._round(),(!i||ay(t,_,a,i,n))&&f.push(_)}}c+=g}return!o&&!f.length&&!s&&(f=uy(t,c/2,r,i,n,a,s,!0,l)),f}function bb(t,e,r,i,n){let a=[];for(let s of t){let o;for(let l=0;l<s.length-1;l++){let u=s[l],h=s[l+1];u.x<e&&h.x<e||(u.x<e?u=new B(e,u.y+(h.y-u.y)*((e-u.x)/(h.x-u.x)))._round():h.x<e&&(h=new B(e,u.y+(h.y-u.y)*((e-u.x)/(h.x-u.x)))._round()),!(u.y<r&&h.y<r)&&(u.y<r?u=new B(u.x+(h.x-u.x)*((r-u.y)/(h.y-u.y)),r)._round():h.y<r&&(h=new B(u.x+(h.x-u.x)*((r-u.y)/(h.y-u.y)),r)._round()),!(u.x>=i&&h.x>=i)&&(u.x>=i?u=new B(i,u.y+(h.y-u.y)*((i-u.x)/(h.x-u.x)))._round():h.x>=i&&(h=new B(i,u.y+(h.y-u.y)*((i-u.x)/(h.x-u.x)))._round()),!(u.y>=n&&h.y>=n)&&(u.y>=n?u=new B(u.x+(h.x-u.x)*((n-u.y)/(h.y-u.y)),n)._round():h.y>=n&&(h=new B(u.x+(h.x-u.x)*((n-u.y)/(h.y-u.y)),n)._round()),(!o||!u.equals(o[o.length-1]))&&(o=[u],a.push(o)),o.push(h)))))}}return a}function hy(t,e,r,i,n,a){let s=Rc(t,e,r,n,0);return s=Rc(s,e,i,a,1),s}function Rc(t,e,r,i,n){switch(e){case 1:return wb(t,r,i,n);case 2:return $c(t,r,i,n,!1);case 3:return $c(t,r,i,n,!0)}return[]}function wb(t,e,r,i){let n=[];for(let a of t)for(let s of a){let o=i===0?s.x:s.y;o>=e&&o<=r&&n.push([s])}return n}function Db(t,e,r,i,n){let a=i===0?_b:Ab,s=[],o=[];for(let h=0;h<t.length-1;h++){let c=t[h],p=t[h+1],f=i===0?c.x:c.y,d=i===0?p.x:p.y,y=!1;f<e?d>e&&s.push(a(c,p,e)):f>r?d<r&&s.push(a(c,p,r)):s.push(c),d<e&&f>=e&&(s.push(a(c,p,e)),y=!0),d>r&&f<=r&&(s.push(a(c,p,r)),y=!0),!n&&y&&(o.push(s),s=[])}let l=t.length-1,u=i===0?t[l].x:t[l].y;return u>=e&&u<=r&&s.push(t[l]),n&&s.length>0&&!s[0].equals(s[s.length-1])&&s.push(new B(s[0].x,s[0].y)),s.length>0&&o.push(s),o}function $c(t,e,r,i,n){let a=[];for(let s of t){let o=Db(s,e,r,i,n);o.length>0&&a.push(...o)}return a}function _b(t,e,r){let i=(r-t.x)/(e.x-t.x);return new B(r,t.y+(e.y-t.y)*i)}function Ab(t,e,r){let i=(r-t.y)/(e.y-t.y);return new B(t.x+(e.x-t.x)*i,r)}function Nc(t,e,r,i){let n=[],a=t.image,s=a.pixelRatio,o=a.paddedRect.w-2,l=a.paddedRect.h-2,u={x1:t.left,y1:t.top,x2:t.right,y2:t.bottom},h=a.stretchX||[[0,o]],c=a.stretchY||[[0,l]],p=(E,$)=>E+$[1]-$[0],f=h.reduce(p,0),d=c.reduce(p,0),y=o-f,m=l-d,g=0,x=f,b=0,v=d,w=0,_=y,A=0,S=m;if(a.content&&i){let E=a.content,$=E[2]-E[0],O=E[3]-E[1];(a.textFitWidth||a.textFitHeight)&&(u=iy(t)),g=Kn(h,0,E[0]),b=Kn(c,0,E[1]),x=Kn(h,E[0],E[2]),v=Kn(c,E[1],E[3]),w=E[0]-g,A=E[1]-b,_=$-x,S=O-v}let F=u.x1,L=u.y1,V=u.x2-F,P=u.y2-L,R=(E,$,O,M)=>{let j=Jn(E.stretch-g,x,V,F),it=Qn(E.fixed-w,_,E.stretch,f),pt=Jn($.stretch-b,v,P,L),st=Qn($.fixed-A,S,$.stretch,d),ft=Jn(O.stretch-g,x,V,F),Gt=Qn(O.fixed-w,_,O.stretch,f),ze=Jn(M.stretch-b,v,P,L),fe=Qn(M.fixed-A,S,M.stretch,d),Le=new B(j,pt),Zt=new B(ft,pt),Sr=new B(ft,ze),Er=new B(j,ze),er=new B(it/s,st/s),ci=new B(Gt/s,fe/s),Tt=e*Math.PI/180;if(Tt){let N=Math.sin(Tt),Q=Math.cos(Tt),Z=[Q,-N,N,Q];Le._matMult(Z),Zt._matMult(Z),Er._matMult(Z),Sr._matMult(Z)}let Ee=E.stretch+E.fixed,rr=O.stretch+O.fixed,Fr=$.stretch+$.fixed,Tr=M.stretch+M.fixed;return{tl:Le,tr:Zt,bl:Er,br:Sr,tex:{x:a.paddedRect.x+1+Ee,y:a.paddedRect.y+1+Fr,w:rr-Ee,h:Tr-Fr},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:er,pixelOffsetBR:ci,minFontScaleX:_/s/V,minFontScaleY:S/s/P,isSDF:r}};if(!i||!a.stretchX&&!a.stretchY)n.push(R({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:o+1},{fixed:0,stretch:l+1}));else{let E=Uc(h,y,f),$=Uc(c,m,d);for(let O=0;O<E.length-1;O++){let M=E[O],j=E[O+1];for(let it=0;it<$.length-1;it++){let pt=$[it],st=$[it+1];n.push(R(M,pt,j,st))}}}return n}function Kn(t,e,r){let i=0;for(let n of t)i+=Math.max(e,Math.min(r,n[1]))-Math.max(e,Math.min(r,n[0]));return i}function Uc(t,e,r){let i=[{fixed:-1,stretch:0}];for(let[n,a]of t){let s=i[i.length-1];i.push({fixed:n-s.stretch,stretch:s.stretch}),i.push({fixed:n-s.stretch,stretch:s.stretch+(a-n)})}return i.push({fixed:e+1,stretch:r}),i}function Jn(t,e,r,i){return t/e*r+i}function Qn(t,e,r,i){return t-e*r/i}function Sb(t,e,r,i,n,a,s,o){let l=i.layout.get("text-rotate").evaluate(a,{})*Math.PI/180,u=[];for(let h of e.positionedLines)for(let c of h.positionedGlyphs){if(!c.rect)continue;let p=c.rect||{},f=4,d=!0,y=1,m=0,g=(n||o)&&c.vertical,x=c.metrics.advance*c.scale/2;if(o&&e.verticalizable){let M=(c.scale-1)*24,j=(24-c.metrics.width*c.scale)/2;m=h.lineOffset/2-(c.imageName?-j:M)}if(c.imageName){let M=s[c.imageName];d=M.sdf,y=M.pixelRatio,f=1/y}let b=n?[c.x+x,c.y]:[0,0],v=n?[0,0]:[c.x+x+r[0],c.y+r[1]-m],w=[0,0];g&&(w=v,v=[0,0]);let _=c.metrics.isDoubleResolution?2:1,A=(c.metrics.left-f)*c.scale-x+v[0],S=(-c.metrics.top-f)*c.scale+v[1],F=A+p.w/_*c.scale/y,L=S+p.h/_*c.scale/y,V=new B(A,S),P=new B(F,S),R=new B(A,L),E=new B(F,L);if(g){let M=new B(-x,x- -17),j=-Math.PI/2,it=12-x,pt=c.imageName?it:0,st=new B(22-it,-pt),ft=new B(...w);V._rotateAround(j,M)._add(st)._add(ft),P._rotateAround(j,M)._add(st)._add(ft),R._rotateAround(j,M)._add(st)._add(ft),E._rotateAround(j,M)._add(st)._add(ft)}if(l){let M=Math.sin(l),j=Math.cos(l),it=[j,-M,M,j];V._matMult(it),P._matMult(it),R._matMult(it),E._matMult(it)}let $=new B(0,0),O=new B(0,0);u.push({tl:V,tr:P,bl:R,br:E,tex:p,writingMode:e.writingMode,glyphOffset:b,sectionIndex:c.sectionIndex,isSDF:d,pixelOffsetTL:$,pixelOffsetBR:O,minFontScaleX:0,minFontScaleY:0})}return u}var ta=class{constructor(t,e,r,i,n,a,s,o,l,u){if(this.boxStartIndex=t.length,l){let h=a.top,c=a.bottom,p=a.collisionPadding;p&&(h-=p[1],c+=p[3]);let f=c-h;f>0&&(f=Math.max(10,f),this.circleDiameter=f)}else{let h=a.image?.content&&(a.image.textFitWidth||a.image.textFitHeight)?iy(a):{x1:a.left,y1:a.top,x2:a.right,y2:a.bottom};h.y1=h.y1*s-o[0],h.y2=h.y2*s+o[2],h.x1=h.x1*s-o[3],h.x2=h.x2*s+o[1];let c=a.collisionPadding;if(c&&(h.x1-=c[0]*s,h.y1-=c[1]*s,h.x2+=c[2]*s,h.y2+=c[3]*s),u){let p=new B(h.x1,h.y1),f=new B(h.x2,h.y1),d=new B(h.x1,h.y2),y=new B(h.x2,h.y2),m=u*Math.PI/180;p._rotate(m),f._rotate(m),d._rotate(m),y._rotate(m),h.x1=Math.min(p.x,f.x,d.x,y.x),h.x2=Math.max(p.x,f.x,d.x,y.x),h.y1=Math.min(p.y,f.y,d.y,y.y),h.y2=Math.max(p.y,f.y,d.y,y.y)}t.emplaceBack(e.x,e.y,h.x1,h.y1,h.x2,h.y2,r,i,n)}this.boxEndIndex=t.length}},Eb=class{constructor(t=[],e=(r,i)=>r<i?-1:+(r>i)){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;let t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){let{data:e,compare:r}=this,i=e[t];for(;t>0;){let n=t-1>>1,a=e[n];if(r(i,a)>=0)break;e[t]=a,t=n}e[t]=i}_down(t){let{data:e,compare:r}=this,i=this.length>>1,n=e[t];for(;t<i;){let a=(t<<1)+1,s=a+1;if(s<this.length&&r(e[s],e[a])<0&&(a=s),r(e[a],n)>=0)break;e[t]=e[a],t=a}e[t]=n}};function Fb(t,e=1){let r=wa.fromPoints(t[0]),i=Math.min(r.width(),r.height()),n=i/2,a=new Eb([],Tb),{minX:s,minY:o,maxX:l,maxY:u}=r;if(i===0)return new B(s,o);for(let p=s;p<l;p+=i)for(let f=o;f<u;f+=i)a.push(new Nr(p+n,f+n,n,t));let h=Ib(t),c=h;for(;a.length;){let p=a.pop();(p.d>c.d||!c.d)&&(c=p),!(p.max-c.d<=e)&&(n=p.h/2,a.push(new Nr(p.p.x-n,p.p.y-n,n,t)),a.push(new Nr(p.p.x+n,p.p.y-n,n,t)),a.push(new Nr(p.p.x-n,p.p.y+n,n,t)),a.push(new Nr(p.p.x+n,p.p.y+n,n,t)))}return h.d>0&&c.d-h.d<=e?h.p:c.p}function Tb(t,e){return e.max-t.max}var Nr=class{constructor(t,e,r,i){this.p=new B(t,e),this.h=r,this.d=kb(this.p,i),this.max=this.d+this.h*Math.SQRT2}};function kb(t,e){let r=!1,i=1/0;for(let n of e)for(let a=0,s=n.length,o=s-1;a<s;o=a++){let l=n[a],u=n[o];l.y>t.y!=u.y>t.y&&t.x<(u.x-l.x)*(t.y-l.y)/(u.y-l.y)+l.x&&(r=!r),i=Math.min(i,cd(t,l,u))}return(r?1:-1)*Math.sqrt(i)}function Ib(t){let e=0,r=0,i=0,n=t[0];for(let a=0,s=n.length,o=s-1;a<s;o=a++){let l=n[a],u=n[o],h=l.x*u.y-u.x*l.y;r+=(l.x+u.x)*h,i+=(l.y+u.y)*h,e+=h*3}return new Nr(r/e,i/e,0,t)}var Cb=(function(t){return t[t.center=1]="center",t[t.left=2]="left",t[t.right=3]="right",t[t.top=4]="top",t[t.bottom=5]="bottom",t[t["top-left"]=6]="top-left",t[t["top-right"]=7]="top-right",t[t["bottom-left"]=8]="bottom-left",t[t["bottom-right"]=9]="bottom-right",t})({}),au=1/0;function cy(t,e){function r(n,a){let s=0,o=0;a<0&&(a=0);let l=a/Math.SQRT2;switch(n){case"top-right":case"top-left":o=l-7;break;case"bottom-right":case"bottom-left":o=-l+7;break;case"bottom":o=-a+7;break;case"top":o=a-7}switch(n){case"top-right":case"bottom-right":s=-l;break;case"top-left":case"bottom-left":s=l;break;case"left":s=a;break;case"right":s=-a}return[s,o]}function i(n,a,s){let o=0,l=0;switch(a=Math.abs(a),s=Math.abs(s),n){case"top-right":case"top-left":case"top":l=s-7;break;case"bottom-right":case"bottom-left":case"bottom":l=-s+7}switch(n){case"top-right":case"bottom-right":case"right":o=-a;break;case"top-left":case"bottom-left":case"left":o=a}return[o,l]}return e[1]===au?r(t,e[0]):i(t,e[0],e[1])}function py(t,e,r){let i=t.layout,n=i.get("text-variable-anchor-offset")?.evaluate(e,{},r);if(n){let s=n.values,o=[];for(let l=0;l<s.length;l+=2){let u=o[l]=s[l],h=s[l+1].map(c=>c*24);u.startsWith("top")?h[1]-=7:u.startsWith("bottom")&&(h[1]+=7),o[l+1]=h}return new De(o)}let a=i.get("text-variable-anchor");if(a){let s;s=t._unevaluatedLayout.getValue("text-radial-offset")===void 0?i.get("text-offset").evaluate(e,{},r).map(l=>l*24):[i.get("text-radial-offset").evaluate(e,{},r)*24,au];let o=[];for(let l of a)o.push(l,cy(l,s));return new De(o)}return null}function Mb(t){var h;t.bucket.createArrays();let e=512*t.bucket.overscaling;t.bucket.tilePixelRatio=mt/e,t.bucket.compareText={},t.bucket.iconsNeedLinear=!1;let r=t.bucket.layers[0],i=r.layout,n=r._unevaluatedLayout._values,a={layoutIconSize:n["icon-size"].possiblyEvaluate(new at(t.bucket.zoom+1),t.canonical),layoutTextSize:n["text-size"].possiblyEvaluate(new at(t.bucket.zoom+1),t.canonical),textMaxSize:n["text-size"].possiblyEvaluate(new at(18))};if(t.bucket.textSizeData.kind==="composite"){let{minZoom:c,maxZoom:p}=t.bucket.textSizeData;a.compositeTextSizes=[n["text-size"].possiblyEvaluate(new at(c),t.canonical),n["text-size"].possiblyEvaluate(new at(p),t.canonical)]}if(t.bucket.iconSizeData.kind==="composite"){let{minZoom:c,maxZoom:p}=t.bucket.iconSizeData;a.compositeIconSizes=[n["icon-size"].possiblyEvaluate(new at(c),t.canonical),n["icon-size"].possiblyEvaluate(new at(p),t.canonical)]}let s=i.get("text-line-height")*24,o=i.get("text-rotation-alignment")!=="viewport"&&i.get("symbol-placement")!=="point",l=i.get("text-keep-upright"),u=i.get("text-size");for(let c of t.bucket.features){let p=i.get("text-font").evaluate(c,{},t.canonical).join(","),f=u.evaluate(c,{},t.canonical),d=a.layoutTextSize.evaluate(c,{},t.canonical),y=a.layoutIconSize.evaluate(c,{},t.canonical),m={horizontal:{},vertical:void 0},g=c.text,x=[0,0];if(g){let _=g.toString(),A=i.get("text-letter-spacing").evaluate(c,{},t.canonical)*24,S=dv(_)?A:0,F=i.get("text-anchor").evaluate(c,{},t.canonical),L=py(r,c,t.canonical);if(!L){let E=i.get("text-radial-offset").evaluate(c,{},t.canonical);x=E?cy(F,[E*24,au]):i.get("text-offset").evaluate(c,{},t.canonical).map($=>$*24)}let V=o?"center":i.get("text-justify").evaluate(c,{},t.canonical),P=i.get("symbol-placement")==="point"?i.get("text-max-width").evaluate(c,{},t.canonical)*24:1/0,R=()=>{t.bucket.allowVerticalPlacement&&Jo(_)&&(m.vertical=Hn(g,t.glyphMap,t.glyphPositions,t.imagePositions,p,P,s,F,"left",S,x,2,!0,d,f))};if(!o&&L){let E=new Set;if(V==="auto")for(let O=0;O<L.values.length;O+=2)E.add(qc(L.values[O]));else E.add(V);let $=!1;for(let O of E)if(!m.horizontal[O])if($)m.horizontal[O]=m.horizontal[0];else{let M=Hn(g,t.glyphMap,t.glyphPositions,t.imagePositions,p,P,s,"center",O,S,x,1,!1,d,f);M&&(m.horizontal[O]=M,$=M.positionedLines.length===1)}R()}else{V==="auto"&&(V=qc(F));let E=Hn(g,t.glyphMap,t.glyphPositions,t.imagePositions,p,P,s,F,V,S,x,1,!1,d,f);E&&(m.horizontal[V]=E),R(),Jo(_)&&o&&l&&(m.vertical=Hn(g,t.glyphMap,t.glyphPositions,t.imagePositions,p,P,s,F,V,S,x,2,!1,d,f))}}let b,v=!1;if(c.icon?.name){let _=t.imageMap[c.icon.name];_&&(b=yb(t.imagePositions[c.icon.name],i.get("icon-offset").evaluate(c,{},t.canonical),i.get("icon-anchor").evaluate(c,{},t.canonical)),v=!!_.sdf,t.bucket.sdfIcons===void 0?t.bucket.sdfIcons=v:t.bucket.sdfIcons!==v&&Mt("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),_.pixelRatio===t.bucket.pixelRatio?i.get("icon-rotate").constantOr(1)!==0&&(t.bucket.iconsNeedLinear=!0):t.bucket.iconsNeedLinear=!0)}let w=fy(m.horizontal)||m.vertical;(h=t.bucket).iconsInText||(h.iconsInText=w?w.iconsInText:!1),(w||b)&&Bb(t.bucket,c,m,b,t.imageMap,a,d,y,x,v,t.canonical,t.subdivisionGranularity)}t.showCollisionBoxes&&t.bucket.generateCollisionDebugBuffers()}function qc(t){switch(t){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Bb(t,e,r,i,n,a,s,o,l,u,h,c){let p=a.textMaxSize.evaluate(e,{});p===void 0&&(p=s);let f=t.layers[0].layout,d=f.get("icon-offset").evaluate(e,{},h),y=fy(r.horizontal),m=s/24,g=t.tilePixelRatio*m,x=t.tilePixelRatio*p/24,b=t.tilePixelRatio*o,v=t.tilePixelRatio*f.get("symbol-spacing"),w=f.get("text-padding")*t.tilePixelRatio,_=jb(f,e,h,t.tilePixelRatio),A=f.get("text-max-angle")/180*Math.PI,S=f.get("text-rotation-alignment")!=="viewport"&&f.get("symbol-placement")!=="point",F=f.get("icon-rotation-alignment").constantOr("viewport")==="map"&&f.get("symbol-placement")!=="point",L=f.get("symbol-placement"),V=v/2,P=f.get("icon-text-fit"),R;i&&P!=="none"&&(t.allowVerticalPlacement&&r.vertical&&(R=Lc(i,r.vertical,P,f.get("icon-text-fit-padding"),d,m)),y&&(i=Lc(i,y,P,f.get("icon-text-fit-padding"),d,m)));let E=h?c.line.getGranularityForZoomLevel(h.z):1,$=(O,M)=>{M.x<0||M.x>=8192||M.y<0||M.y>=8192||zb(t,M,O,r,i,n,R,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,g,[w,w,w,w],S,l,b,_,F,d,e,a,u,h,s)};if(L==="line")for(let O of bb(e.geometry,0,0,mt,mt)){let M=hr(O,E),j=vb(M,v,A,r.vertical||y,i,24,x,t.overscaling,mt);for(let it of j){let pt=y;(!pt||!Lb(t,pt.text,V,it))&&$(M,it)}}else if(L==="line-center"){for(let O of e.geometry)if(O.length>1){let M=hr(O,E),j=xb(M,A,r.vertical||y,i,24,x);j&&$(M,j)}}else if(e.type==="Polygon")for(let O of Ba(e.geometry,0)){let M=Fb(O,16);$(hr(O[0],E,!0),new Hr(M.x,M.y,0))}else if(e.type==="LineString")for(let O of e.geometry){let M=hr(O,E);$(M,new Hr(M[0].x,M[0].y,0))}else if(e.type==="Point")for(let O of e.geometry)for(let M of O)$([M],new Hr(M.x,M.y,0))}function Pb(t,e){let r=t.length,i=e?.values;if(i?.length>0)for(let n=0;n<i.length;n+=2){let a=Cb[i[n]],s=i[n+1];t.emplaceBack(a,s[0],s[1])}return[r,t.length]}function jc(t,e,r,i,n,a,s,o,l,u,h,c,p,f,d,y){let m=Sb(e,r,o,n,a,s,i,t.allowVerticalPlacement),g=t.textSizeData,x=null;g.kind==="source"?(x=[128*n.layout.get("text-size").evaluate(s,{})],x[0]>32640&&Mt(`${t.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):g.kind==="composite"&&(x=[128*d.compositeTextSizes[0].evaluate(s,{},y),128*d.compositeTextSizes[1].evaluate(s,{},y)],(x[0]>32640||x[1]>32640)&&Mt(`${t.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),t.addSymbols(t.text,m,x,o,a,s,h,e,u.lineStartIndex,u.lineLength,f,y,l);for(let b of c)p[b]=t.text.placedSymbolArray.length-1;return m.length*4}function fy(t){for(let e in t)return t[e];return null}function zb(t,e,r,i,n,a,s,o,l,u,h,c,p,f,d,y,m,g,x,b,v,w,_,A,S){let F=t.addToLineVertexArray(e,r),L=o.layout.get("symbol-height-offset").evaluate(v,{},A);L>t.maxHeightOffset&&(t.maxHeightOffset=L);let V,P,R,E,$=0,O=0,M=0,j=0,it=-1,pt=-1,st={},ft=(0,ko.default)("");if(t.allowVerticalPlacement&&i.vertical){let Q=o.layout.get("text-rotate").evaluate(v,{},A)+90,Z=i.vertical;R=new ta(l,e,u,h,c,Z,p,f,d,Q),s&&(E=new ta(l,e,u,h,c,s,m,g,d,Q))}if(n){let Q=o.layout.get("icon-rotate").evaluate(v,{}),Z=o.layout.get("icon-text-fit")!=="none",C=Nc(n,Q,_,Z),ut=s?Nc(s,Q,_,Z):void 0;P=new ta(l,e,u,h,c,n,m,g,!1,Q),$=C.length*4;let Y=t.iconSizeData,G=null;Y.kind==="source"?(G=[128*o.layout.get("icon-size").evaluate(v,{})],G[0]>32640&&Mt(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):Y.kind==="composite"&&(G=[128*w.compositeIconSizes[0].evaluate(v,{},A),128*w.compositeIconSizes[1].evaluate(v,{},A)],(G[0]>32640||G[1]>32640)&&Mt(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),t.addSymbols(t.icon,C,G,b,x,v,0,e,F.lineStartIndex,F.lineLength,-1,A,L),it=t.icon.placedSymbolArray.length-1,ut&&(O=ut.length*4,t.addSymbols(t.icon,ut,G,b,x,v,2,e,F.lineStartIndex,F.lineLength,-1,A,L),pt=t.icon.placedSymbolArray.length-1)}let Gt=Object.keys(i.horizontal);for(let Q of Gt){let Z=i.horizontal[Q];V||(V=(ft=(0,ko.default)(Z.text),new ta(l,e,u,h,c,Z,p,f,d,o.layout.get("text-rotate").evaluate(v,{},A))));let C=Z.positionedLines.length===1;if(M+=jc(t,e,Z,a,o,d,v,y,L,F,i.vertical?1:3,C?Gt:[Q],st,it,w,A),C)break}i.vertical&&(j+=jc(t,e,i.vertical,a,o,d,v,y,L,F,2,["vertical"],st,pt,w,A));let ze=V?V.boxStartIndex:t.collisionBoxArray.length,fe=V?V.boxEndIndex:t.collisionBoxArray.length,Le=R?R.boxStartIndex:t.collisionBoxArray.length,Zt=R?R.boxEndIndex:t.collisionBoxArray.length,Sr=P?P.boxStartIndex:t.collisionBoxArray.length,Er=P?P.boxEndIndex:t.collisionBoxArray.length,er=E?E.boxStartIndex:t.collisionBoxArray.length,ci=E?E.boxEndIndex:t.collisionBoxArray.length,Tt=-1,Ee=(Q,Z)=>Q?.circleDiameter?Math.max(Q.circleDiameter,Z):Z;Tt=Ee(V,Tt),Tt=Ee(R,Tt),Tt=Ee(P,Tt),Tt=Ee(E,Tt);let rr=+(Tt>-1);rr&&(Tt*=S/24),t.glyphOffsetArray.length>=t.maxGlyphs&&Mt("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),v.sortKey!==void 0&&t.addToSortKeyRanges(t.symbolInstances.length,v.sortKey);let Fr=py(o,v,A),[Tr,N]=Pb(t.textAnchorOffsets,Fr);t.symbolInstances.emplaceBack(e.x,e.y,st.right>=0?st.right:-1,st.center>=0?st.center:-1,st.left>=0?st.left:-1,st.vertical||-1,it,pt,ft,ze,fe,Le,Zt,Sr,Er,er,ci,u,M,j,$,O,rr,0,p,Tt,Tr,N,L)}function Lb(t,e,r,i){let n=t.compareText;if(!(e in n))n[e]=[];else{let a=n[e];for(let s=a.length-1;s>=0;s--)if(i.dist(a[s])<r)return!0}return n[e].push(i),!1}function Gc(t,e,r){let i="never",n=t.get(e);return n?i=n:t.get(r)&&(i="always"),i}var Vb=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function ea(t,e,r,i,n,a,s,o,l,u,h,c,p,f){let d=o?Math.min(Vc,Math.round(o[0])):0,y=o?Math.min(Vc,Math.round(o[1])):0;t.emplaceBack(e,r,Math.round(i*32),Math.round(n*32),a,s,(d<<1)+ +!!l,y,u*16,h*16,c*256,p*256,f)}function Ob(t,e,r){t.emplaceBack(e.x,e.y,r),t.emplaceBack(e.x,e.y,r),t.emplaceBack(e.x,e.y,r),t.emplaceBack(e.x,e.y,r)}function Rb(t){for(let e of t.sections)if(Wd(e.text))return!0;return!1}var rl=class{constructor(t){this.layoutVertexArray=new sg,this.indexArray=new xn,this.programConfigurations=t,this.segments=new te,this.dynamicLayoutVertexArray=new og,this.opacityVertexArray=new lg,this.hasVisibleVertices=!1,this.placedSymbolArray=new Hf}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(t,e,r,i){this.isEmpty()||(r&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,$2.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,e),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,N2.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,Vb,!0),this.opacityVertexBuffer.itemSize=1),(r||i)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}};I("SymbolBuffers",rl);var il=class{constructor(t,e,r){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new r,this.segments=new te,this.collisionVertexArray=new ug}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,U2.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}};I("CollisionBuffers",il);var dy=class{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(s=>s.id),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasDependencies=!0,this.hasRTLText=!1,this.maxHeightOffset=0,this.sortKeyRanges=[],this.collisionCircleArray=[],this.maxGlyphs=65535;let e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Oc(this.zoom,e["text-size"]),this.iconSizeData=Oc(this.zoom,e["icon-size"]);let r=this.layers[0].layout,i=r.get("symbol-sort-key"),n=r.get("symbol-z-order");this.canOverlap=Gc(r,"text-overlap","text-allow-overlap")!=="never"||Gc(r,"icon-overlap","icon-allow-overlap")!=="never"||r.get("text-ignore-placement")||r.get("icon-ignore-placement"),this.sortFeaturesByKey=n!=="viewport-y"&&!i.isConstant();let a=n==="viewport-y"||n==="auto"&&!this.sortFeaturesByKey;this.sortFeaturesByY=a&&this.canOverlap,r.get("symbol-placement")==="point"&&(this.writingModes=r.get("text-writing-mode").map(s=>Jd[s])),this.stateDependentLayerIds=this.layers.filter(s=>s.isStateDependent()).map(s=>s.id),this.sourceID=t.sourceID}createArrays(){this.text=new rl(new gr(this.layers,this.zoom,t=>t.startsWith("text"))),this.icon=new rl(new gr(this.layers,this.zoom,t=>t.startsWith("icon"))),this.glyphOffsetArray=new Qf,this.lineVertexArray=new td,this.symbolInstances=new Jf,this.textAnchorOffsets=new rd}calculateGlyphDependencies(t,e,r,i,n){var l;let a=(i||this.allowVerticalPlacement)&&n,s=tu.fromFeature(t,r),o=s.graphemes();for(let u=0;u<o.length;u++){let h=s.getSection(u);if("imageName"in h)continue;let c=e[l=h.fontStack]||(e[l]={}),p=o[u];Gd(p)&&(c[p]=!0);for(let f of p){if(c[f]=!0,!a)continue;let d=qr[f];d&&(c[d]=!0)}}}populate(t,e,r){let i=this.layers[0],n=i.layout,a=n.get("text-font"),s=n.get("text-field"),o=n.get("icon-image"),l=(s.value.kind!=="constant"||s.value.value instanceof Be&&!s.value.value.isEmpty()||s.value.value.toString().length>0)&&(a.value.kind!=="constant"||a.value.value.length>0),u=o.value.kind!=="constant"||!!o.value.value||Object.keys(o.parameters).length>0,h=n.get("symbol-sort-key");if(this.features=[],!l&&!u)return;let c=e.iconDependencies,p=e.glyphDependencies,f=e.availableImages,d=new at(this.zoom);for(let{feature:y,id:m,index:g,sourceLayerIndex:x}of t){let b=i._featureFilter.needGeometry,v=li(y,b);if(!i._featureFilter.filter(d,v,r))continue;b||(v.geometry=Dr(y));let w;if(l){let F=i.getValueAndResolveTokens("text-field",v,r,f),L=Be.factory(F);this.hasRTLText||(this.hasRTLText=Rb(L)),w=cv(L,i,v)}let _;if(u){let F=i.getValueAndResolveTokens("icon-image",v,r,f);_=F instanceof _e?F:_e.fromString(F)}if(!w&&!_)continue;let A=this.sortFeaturesByKey?h.evaluate(v,{},r):void 0,S={id:m,text:w,icon:_,index:g,sourceLayerIndex:x,geometry:v.geometry,properties:y.properties,type:vn.types[y.type],sortKey:A};if(this.features.push(S),_&&(c[_.name]=!0),w){let F=a.evaluate(v,{},r).join(","),L=n.get("text-rotation-alignment")!=="viewport"&&n.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes?.includes(2);let V=Jo(w.toString());this.calculateGlyphDependencies(w,p,F,L,V);for(let P of w.sections)P.image&&(c[P.image.name]=!0)}}n.get("symbol-placement")==="line"&&(this.features=pv(this.features)),this.sortFeaturesByKey&&this.features.sort((y,m)=>y.sortKey-m.sortKey)}update(t,e,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,{imagePositions:r}),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,{imagePositions:r}))}addFeatures({options:t,canonical:e,glyphMap:r,glyphPositions:i,iconMap:n,iconPositions:a,showCollisionBoxes:s}){Mb({bucket:this,glyphMap:r,glyphPositions:i,imageMap:n,imagePositions:a,showCollisionBoxes:s,canonical:e,subdivisionGranularity:t.subdivisionGranularity})}isEmpty(){return this.symbolInstances.length===0}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,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(t,e){let r=this.lineVertexArray.length;if(t.segment!==void 0){let i=t.dist(e[t.segment+1]),n=t.dist(e[t.segment]),a={};for(let s=t.segment+1;s<e.length;s++)a[s]={x:e[s].x,y:e[s].y,tileUnitDistanceFromAnchor:i},s<e.length-1&&(i+=e[s+1].dist(e[s]));for(let s=t.segment||0;s>=0;s--)a[s]={x:e[s].x,y:e[s].y,tileUnitDistanceFromAnchor:n},s>0&&(n+=e[s-1].dist(e[s]));for(let s=0;s<e.length;s++){let o=a[s];this.lineVertexArray.emplaceBack(o.x,o.y,o.tileUnitDistanceFromAnchor)}}return{lineStartIndex:r,lineLength:this.lineVertexArray.length-r}}addSymbols(t,e,r,i,n,a,s,o,l,u,h,c,p){let f=t.indexArray,d=t.layoutVertexArray,y=t.segments.prepareSegment(4*e.length,d,f,this.canOverlap?a.sortKey:void 0),m=this.glyphOffsetArray.length,g=y.vertexLength,x=this.allowVerticalPlacement&&s===2?Math.PI/2:0,b=a.text&&a.text.sections;for(let v=0;v<e.length;v++){let{tl:w,tr:_,bl:A,br:S,tex:F,pixelOffsetTL:L,pixelOffsetBR:V,minFontScaleX:P,minFontScaleY:R,glyphOffset:E,isSDF:$,sectionIndex:O}=e[v],M=y.vertexLength,j=E[1];ea(d,o.x,o.y,w.x,j+w.y,F.x,F.y,r,$,L.x,L.y,P,R,p),ea(d,o.x,o.y,_.x,j+_.y,F.x+F.w,F.y,r,$,V.x,L.y,P,R,p),ea(d,o.x,o.y,A.x,j+A.y,F.x,F.y+F.h,r,$,L.x,V.y,P,R,p),ea(d,o.x,o.y,S.x,j+S.y,F.x+F.w,F.y+F.h,r,$,V.x,V.y,P,R,p),Ob(t.dynamicLayoutVertexArray,o,x),f.emplaceBack(M,M+2,M+1),f.emplaceBack(M+1,M+2,M+3),y.vertexLength+=4,y.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(E[0]),(v===e.length-1||O!==e[v+1].sectionIndex)&&t.programConfigurations.populatePaintArrays(d.length,a,a.index,{imagePositions:{},canonical:c,formattedSection:b?.[O]})}t.placedSymbolArray.emplaceBack(o.x,o.y,m,this.glyphOffsetArray.length-m,g,l,u,o.segment,r?r[0]:0,r?r[1]:0,i[0],i[1],s,0,!1,0,h,p)}_addCollisionDebugVertex(t,e,r,i,n,a){return e.emplaceBack(0,0),t.emplaceBack(r.x,r.y,i,n,Math.round(a.x),Math.round(a.y))}addCollisionDebugVertices(t,e,r,i,n,a,s){let o=n.segments.prepareSegment(4,n.layoutVertexArray,n.indexArray),l=o.vertexLength,u=n.layoutVertexArray,h=n.collisionVertexArray,c=s.anchorX,p=s.anchorY;this._addCollisionDebugVertex(u,h,a,c,p,new B(t,e)),this._addCollisionDebugVertex(u,h,a,c,p,new B(r,e)),this._addCollisionDebugVertex(u,h,a,c,p,new B(r,i)),this._addCollisionDebugVertex(u,h,a,c,p,new B(t,i)),o.vertexLength+=4;let f=n.indexArray;f.emplaceBack(l,l+1),f.emplaceBack(l+1,l+2),f.emplaceBack(l+2,l+3),f.emplaceBack(l+3,l),o.primitiveLength+=4}addDebugCollisionBoxes(t,e,r,i){for(let n=t;n<e;n++){let a=this.collisionBoxArray.get(n),s=a.x1,o=a.y1,l=a.x2,u=a.y2;this.addCollisionDebugVertices(s,o,l,u,i?this.textCollisionBox:this.iconCollisionBox,a.anchorPoint,r)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new il(Nh,_c.members,Fo),this.iconCollisionBox=new il(Nh,_c.members,Fo);for(let t=0;t<this.symbolInstances.length;t++){let e=this.symbolInstances.get(t);this.addDebugCollisionBoxes(e.textBoxStartIndex,e.textBoxEndIndex,e,!0),this.addDebugCollisionBoxes(e.verticalTextBoxStartIndex,e.verticalTextBoxEndIndex,e,!0),this.addDebugCollisionBoxes(e.iconBoxStartIndex,e.iconBoxEndIndex,e,!1),this.addDebugCollisionBoxes(e.verticalIconBoxStartIndex,e.verticalIconBoxEndIndex,e,!1)}}_deserializeCollisionBoxesForSymbol(t,e,r,i,n,a,s,o,l){let u={};for(let h=e;h<r;h++){let c=t.get(h);u.textBox={x1:c.x1,y1:c.y1,x2:c.x2,y2:c.y2,anchorPointX:c.anchorPointX,anchorPointY:c.anchorPointY},u.textFeatureIndex=c.featureIndex;break}for(let h=i;h<n;h++){let c=t.get(h);u.verticalTextBox={x1:c.x1,y1:c.y1,x2:c.x2,y2:c.y2,anchorPointX:c.anchorPointX,anchorPointY:c.anchorPointY},u.verticalTextFeatureIndex=c.featureIndex;break}for(let h=a;h<s;h++){let c=t.get(h);u.iconBox={x1:c.x1,y1:c.y1,x2:c.x2,y2:c.y2,anchorPointX:c.anchorPointX,anchorPointY:c.anchorPointY},u.iconFeatureIndex=c.featureIndex;break}for(let h=o;h<l;h++){let c=t.get(h);u.verticalIconBox={x1:c.x1,y1:c.y1,x2:c.x2,y2:c.y2,anchorPointX:c.anchorPointX,anchorPointY:c.anchorPointY},u.verticalIconFeatureIndex=c.featureIndex;break}return u}deserializeCollisionBoxes(t){this.collisionArrays=[];for(let e=0;e<this.symbolInstances.length;e++){let r=this.symbolInstances.get(e);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(t,r.textBoxStartIndex,r.textBoxEndIndex,r.verticalTextBoxStartIndex,r.verticalTextBoxEndIndex,r.iconBoxStartIndex,r.iconBoxEndIndex,r.verticalIconBoxStartIndex,r.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(t,e){let r=t.placedSymbolArray.get(e),i=r.vertexStartIndex+r.numGlyphs*4;for(let n=r.vertexStartIndex;n<i;n+=4)t.indexArray.emplaceBack(n,n+2,n+1),t.indexArray.emplaceBack(n+1,n+2,n+3)}getSortedSymbolIndexes(t){if(this.sortedAngle===t&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;let e=Math.sin(t),r=Math.cos(t),i=[],n=[],a=[];for(let s=0;s<this.symbolInstances.length;++s){a.push(s);let o=this.symbolInstances.get(s);i.push(Math.round(e*o.anchorX+r*o.anchorY)|0),n.push(o.featureIndex)}return a.sort((s,o)=>i[s]-i[o]||n[o]-n[s]),a}addToSortKeyRanges(t,e){let r=this.sortKeyRanges[this.sortKeyRanges.length-1];r?.sortKey===e?r.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(let e of this.symbolInstanceIndexes){let r=this.symbolInstances.get(e);this.featureSortOrder.push(r.featureIndex);let i=[r.rightJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.leftJustifiedTextSymbolIndex];for(let n=0;n<i.length;n++){let a=i[n];a>=0&&i.indexOf(a)===n&&this.addIndicesForPlacedSymbol(this.text,a)}r.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,r.verticalPlacedTextSymbolIndex),r.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,r.placedIconSymbolIndex),r.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,r.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}};I("SymbolBucket",dy,{omit:["layers","collisionBoxArray","features","compareText"]});function $b(t,e){return e.replace(/{([^{}]+)}/g,(r,i)=>t&&i in t?String(t[i]):"")}var Yc,Nb=()=>Yc||(Yc=new jt({"symbol-placement":new z(D.layout_symbol["symbol-placement"],"symbol-placement"),"symbol-spacing":new z(D.layout_symbol["symbol-spacing"],"symbol-spacing"),"symbol-avoid-edges":new z(D.layout_symbol["symbol-avoid-edges"],"symbol-avoid-edges"),"symbol-sort-key":new U(D.layout_symbol["symbol-sort-key"],"symbol-sort-key"),"symbol-z-order":new z(D.layout_symbol["symbol-z-order"],"symbol-z-order"),"icon-allow-overlap":new z(D.layout_symbol["icon-allow-overlap"],"icon-allow-overlap"),"icon-overlap":new z(D.layout_symbol["icon-overlap"],"icon-overlap"),"icon-ignore-placement":new z(D.layout_symbol["icon-ignore-placement"],"icon-ignore-placement"),"icon-optional":new z(D.layout_symbol["icon-optional"],"icon-optional"),"icon-rotation-alignment":new U(D.layout_symbol["icon-rotation-alignment"],"icon-rotation-alignment"),"icon-size":new U(D.layout_symbol["icon-size"],"icon-size"),"icon-text-fit":new z(D.layout_symbol["icon-text-fit"],"icon-text-fit"),"icon-text-fit-padding":new z(D.layout_symbol["icon-text-fit-padding"],"icon-text-fit-padding"),"icon-image":new U(D.layout_symbol["icon-image"],"icon-image"),"icon-rotate":new U(D.layout_symbol["icon-rotate"],"icon-rotate"),"icon-padding":new U(D.layout_symbol["icon-padding"],"icon-padding"),"icon-keep-upright":new z(D.layout_symbol["icon-keep-upright"],"icon-keep-upright"),"icon-offset":new U(D.layout_symbol["icon-offset"],"icon-offset"),"icon-anchor":new U(D.layout_symbol["icon-anchor"],"icon-anchor"),"icon-pitch-alignment":new z(D.layout_symbol["icon-pitch-alignment"],"icon-pitch-alignment"),"text-pitch-alignment":new z(D.layout_symbol["text-pitch-alignment"],"text-pitch-alignment"),"text-rotation-alignment":new z(D.layout_symbol["text-rotation-alignment"],"text-rotation-alignment"),"text-field":new U(D.layout_symbol["text-field"],"text-field"),"text-font":new U(D.layout_symbol["text-font"],"text-font"),"text-size":new U(D.layout_symbol["text-size"],"text-size"),"text-max-width":new U(D.layout_symbol["text-max-width"],"text-max-width"),"text-line-height":new z(D.layout_symbol["text-line-height"],"text-line-height"),"text-letter-spacing":new U(D.layout_symbol["text-letter-spacing"],"text-letter-spacing"),"text-justify":new U(D.layout_symbol["text-justify"],"text-justify"),"text-radial-offset":new U(D.layout_symbol["text-radial-offset"],"text-radial-offset"),"text-variable-anchor":new z(D.layout_symbol["text-variable-anchor"],"text-variable-anchor"),"text-variable-anchor-offset":new U(D.layout_symbol["text-variable-anchor-offset"],"text-variable-anchor-offset"),"text-anchor":new U(D.layout_symbol["text-anchor"],"text-anchor"),"text-max-angle":new z(D.layout_symbol["text-max-angle"],"text-max-angle"),"text-writing-mode":new z(D.layout_symbol["text-writing-mode"],"text-writing-mode"),"text-rotate":new U(D.layout_symbol["text-rotate"],"text-rotate"),"text-padding":new z(D.layout_symbol["text-padding"],"text-padding"),"text-keep-upright":new z(D.layout_symbol["text-keep-upright"],"text-keep-upright"),"text-transform":new U(D.layout_symbol["text-transform"],"text-transform"),"text-offset":new U(D.layout_symbol["text-offset"],"text-offset"),"text-allow-overlap":new z(D.layout_symbol["text-allow-overlap"],"text-allow-overlap"),"text-overlap":new z(D.layout_symbol["text-overlap"],"text-overlap"),"text-ignore-placement":new z(D.layout_symbol["text-ignore-placement"],"text-ignore-placement"),"text-optional":new z(D.layout_symbol["text-optional"],"text-optional"),"symbol-height-offset":new U(D.layout_symbol["symbol-height-offset"],"symbol-height-offset"),"symbol-height-anchor":new z(D.layout_symbol["symbol-height-anchor"],"symbol-height-anchor")})),Xc,Ub=()=>Xc||(Xc=new jt({"icon-opacity":new U(D.paint_symbol["icon-opacity"],"icon-opacity"),"icon-color":new U(D.paint_symbol["icon-color"],"icon-color"),"icon-halo-color":new U(D.paint_symbol["icon-halo-color"],"icon-halo-color"),"icon-halo-width":new U(D.paint_symbol["icon-halo-width"],"icon-halo-width"),"icon-halo-blur":new U(D.paint_symbol["icon-halo-blur"],"icon-halo-blur"),"icon-translate":new z(D.paint_symbol["icon-translate"],"icon-translate"),"icon-translate-anchor":new z(D.paint_symbol["icon-translate-anchor"],"icon-translate-anchor"),"text-opacity":new U(D.paint_symbol["text-opacity"],"text-opacity"),"text-color":new U(D.paint_symbol["text-color"],"text-color",{runtimeType:ue,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new U(D.paint_symbol["text-halo-color"],"text-halo-color"),"text-halo-width":new U(D.paint_symbol["text-halo-width"],"text-halo-width"),"text-halo-blur":new U(D.paint_symbol["text-halo-blur"],"text-halo-blur"),"text-translate":new z(D.paint_symbol["text-translate"],"text-translate"),"text-translate-anchor":new z(D.paint_symbol["text-translate-anchor"],"text-translate-anchor")})),js={get paint(){return Ub()},get layout(){return Nb()}},yy=class{constructor(t){if(t.property.overrides===void 0)throw Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:cn,this.defaultValue=t}evaluate(t){if(t.formattedSection){let e=this.defaultValue.property.overrides;if(e?.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){if(!this.defaultValue.isConstant()){let e=this.defaultValue.value;t(e._styleExpression.expression)}}outputDefined(){return!1}serialize(){return null}};I("FormatSectionOverride",yy,{omit:["defaultValue"]});var qb=class nl extends pe{constructor(e,r){super(e,js,r)}recalculate(e,r){super.recalculate(e,r);let i=this.layout.get("icon-rotation-alignment");if((i.value.kind!=="constant"||i.value.value==="auto")&&(this.layout._values["icon-rotation-alignment"]=new ae(i.property,{kind:"constant",value:this.layout.get("symbol-placement")==="point"?"viewport":"map"},i.parameters)),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout.get("symbol-placement")==="point"?this.layout._values["text-rotation-alignment"]="viewport":this.layout._values["text-rotation-alignment"]="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").constantOr("viewport")),this.layout.get("symbol-placement")==="point"){let n=this.layout.get("text-writing-mode");if(n){let a=[];for(let s of n)a.includes(s)||a.push(s);this.layout._values["text-writing-mode"]=a}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,r,i,n){let a=this.layout.get(e).evaluate(r,{},i,n),s=this._unevaluatedLayout._values[e];return!s.isDataDriven()&&!Oa(s.value)&&a?$b(r.properties,a):a}createBucket(e){return new dy(e)}queryRadius(){return 0}queryIntersectsFeature(){throw Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(let e of js.paint.overridableProperties){if(!nl.hasPaintOverride(this.layout,e))continue;let r=this.paint.get(e),i=new Fl(new yy(r),`layers[${this.id}].paint.${r.property.name}`,r.property.specification),n=null;n=r.value.kind==="constant"||r.value.kind==="source"?new en("source",i):new ya("composite",i,r.value.zoomStops),this.paint._values[e]=new ae(r.property,n,r.parameters)}}_handleOverridablePaintPropertyUpdate(e,r,i){return!this.layout||r.isDataDriven()||i.isDataDriven()?!1:nl.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,r){let i=e.get("text-field"),n=js.paint.properties[r],a=!1,s=o=>{for(let l of o)if(n.overrides?.hasOverride(l)){a=!0;return}};if(i.value.kind==="constant"&&i.value.value instanceof Be)s(i.value.value.sections);else if(i.value.kind==="source"||i.value.kind==="composite"){let o=u=>{if(!a)if(u instanceof ti&&At(u.value)===pn){let h=u.value;s(h.sections)}else u instanceof Vp?s(u.sections):u.eachChild(o)},l=i.value;l._styleExpression&&o(l._styleExpression.expression)}return a}};function jb(t,e,r,i=1){let n=t.get("icon-padding").evaluate(e,{},r)?.values;return[n[0]*i,n[1]*i,n[2]*i,n[3]*i]}var Wc,Gb=()=>Wc||(Wc=new jt({"background-color":new z(D.paint_background["background-color"],"background-color"),"background-pattern":new Xf(D.paint_background["background-pattern"],"background-pattern"),"background-opacity":new z(D.paint_background["background-opacity"],"background-opacity")})),Yb={get paint(){return Gb()}};var Xb=class extends pe{constructor(t,e){super(t,Yb,e)}};var Wb=class extends pe{constructor(t,e){super(t,{},e),this.onAdd=r=>{this.implementation.onAdd&&this.implementation.onAdd(r,r.painter.context.gl)},this.onRemove=r=>{this.implementation.onRemove&&this.implementation.onRemove(r,r.painter.context.gl)},this.implementation=t}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")}};function my(t,e){if(t.type==="custom")return new Wb(t,e);switch(t.type){case"background":return new Xb(t,e);case"circle":return new Lg(t,e);case"color-relief":return new Xg(t,e);case"fill":return new Ax(t,e);case"fill-extrusion":return new Yx(t,e);case"heatmap":return new Ng(t,e);case"hillshade":return new jg(t,e);case"line":return new R2(t,e);case"raster":return new Km(t,e);case"symbol":return new qb(t,e)}}var Zb=class{constructor(t){this._methodToThrottle=t,this._triggered=!1,this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()}}trigger(){this._triggered||(this._triggered=!0,this._channel?.port1.postMessage(!0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}},Hb={once:!0},gy=class{constructor(t,e){this.target=t,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Zb(()=>this.process()),this.subscription=ah(this.target,"message",r=>this.receive(r),!1),this.globalScope=dr(self)?t:window}registerMessageHandler(t,e){this.messageHandlers[t]=e}unregisterMessageHandler(t){delete this.messageHandlers[t]}sendAsync(t,e){return new Promise((r,i)=>{let n=Math.round(Math.random()*1e18).toString(36).substring(0,10),a=e?ah(e.signal,"abort",()=>{a?.unsubscribe(),delete this.resolveRejects[n];let l={id:n,type:"<cancel>",origin:location.origin,targetMapId:t.targetMapId,sourceMapId:this.mapId};this.target.postMessage(l),i(new cl(e.signal.reason))},Hb):null;this.resolveRejects[n]={resolve:l=>{a?.unsubscribe(),r(l)},reject:l=>{a?.unsubscribe(),i(l)}};let s=[],o={...t,id:n,sourceMapId:this.mapId,origin:location.origin,data:ji(t.data,s)};this.target.postMessage(o,{transfer:s})})}receive(t){let e=t.data,r=e.id,i=["file://","resource://android","null"],n=[e.origin,location.origin],a=e.origin===location.origin,s=n.some(o=>i.includes(o));if((a||s)&&!(e.targetMapId&&this.mapId!==e.targetMapId)){if(e.type==="<cancel>"){delete this.tasks[r];let o=this.abortControllers[r];delete this.abortControllers[r],o&&o.abort();return}if(dr(self)||e.mustQueue){this.tasks[r]=e,this.taskQueue.push(r),this.invoker.trigger();return}this.processTask(r,e)}}process(){if(this.taskQueue.length===0)return;let t=this.taskQueue.shift(),e=this.tasks[t];delete this.tasks[t],this.taskQueue.length>0&&this.invoker.trigger(),e&&this.processTask(t,e)}async processTask(t,e){if(e.type==="<response>"){let n=this.resolveRejects[t];if(delete this.resolveRejects[t],!n)return;e.error?n.reject(Wi(Gi(e.error))):n.resolve(Gi(e.data));return}if(!this.messageHandlers[e.type]){this.completeTask(t,null,null);return}let r=Gi(e.data),i=new AbortController;this.abortControllers[t]=i;try{let n=await this.messageHandlers[e.type](e.sourceMapId,r,i);this.completeTask(t,null,n)}catch(n){this.completeTask(t,Wi(n))}}completeTask(t,e,r){let i=[];delete this.abortControllers[t];let n={id:t,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:e?ji(e):null,data:ji(r,i)};this.target.postMessage(n,{transfer:i})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}};function Kb(t,e,r){return!(t<0||t>25||r<0||r>=2**t||e<0||e>=2**t)}var xy=class{constructor(t,e,r){if(!Kb(t,e,r))throw Error(`x=${e}, y=${r}, z=${t} outside of bounds. 0<=x<${2**t}, 0<=y<${2**t} 0<=z<=25 `);this.z=t,this.x=e,this.y=r,this.key=Xi(0,t,t,e,r)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e,r){let i=Qb(this.x,this.y,this.z),n=tw(this.z,this.x,this.y);return t[(this.x+this.y)%t.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(r==="tms"?2**this.z-this.y-1:this.y)).replace(/{ratio}/g,e>1?"@2x":"").replace(/{quadkey}/g,n).replace(/{bbox-epsg-3857}/g,i)}isChildOf(t){let e=this.z-t.z;return e>0&&t.x===this.x>>e&&t.y===this.y>>e}getTilePoint(t){let e=2**this.z;return new B((t.x*e-this.x)*mt,(t.y*e-this.y)*mt)}toString(){return`${this.z}/${this.x}/${this.y}`}},Jb=class{constructor(t,e){this.wrap=t,this.canonical=e,this.key=Xi(t,e.z,e.z,e.x,e.y)}},su=class ie{constructor(e,r,i,n,a){if(this.terrainRttPosMatrix32f=null,e<i)throw Error(`overscaledZ should be >= z; overscaledZ = ${e}; z = ${i}`);this.overscaledZ=e,this.wrap=r,this.canonical=new xy(i,+n,+a),this.key=Xi(r,e,i,n,a)}clone(){return new ie(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 r=this.canonical.z-e;return e>this.canonical.z?new ie(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new ie(e,this.wrap,e,this.canonical.x>>r,this.canonical.y>>r)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(e,r){if(e>this.overscaledZ)throw Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);let i=this.canonical.z-e;return e>this.canonical.z?Xi(this.wrap*+r,e,this.canonical.z,this.canonical.x,this.canonical.y):Xi(this.wrap*+r,e,e,this.canonical.x>>i,this.canonical.y>>i)}isChildOf(e){if(e.wrap!==this.wrap||this.overscaledZ-e.overscaledZ<=0)return!1;if(e.overscaledZ===0)return this.overscaledZ>0;let r=this.canonical.z-e.canonical.z;return r<0?!1:e.canonical.x===this.canonical.x>>r&&e.canonical.y===this.canonical.y>>r}children(e){if(this.overscaledZ>=e)return[new ie(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];let r=this.canonical.z+1,i=this.canonical.x*2,n=this.canonical.y*2;return[new ie(r,this.wrap,r,i,n),new ie(r,this.wrap,r,i+1,n),new ie(r,this.wrap,r,i,n+1),new ie(r,this.wrap,r,i+1,n+1)]}isLessThan(e){return this.wrap<e.wrap?!0:this.wrap>e.wrap?!1:this.overscaledZ<e.overscaledZ?!0:this.overscaledZ>e.overscaledZ?!1:this.canonical.x<e.canonical.x?!0:this.canonical.x>e.canonical.x?!1:this.canonical.y<e.canonical.y}wrapped(){return new ie(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new ie(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return 2**(this.overscaledZ-this.canonical.z)}toUnwrapped(){return new Jb(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(e){return this.canonical.getTilePoint(new jl(e.x-this.wrap,e.y))}normalizeCoordinates(e,r,i=mt){if(e>=0&&e<i&&r>=0&&r<i)return{tileID:this,x:e,y:r};let n=Math.floor(e/i),a=Math.floor(r/i),s=e-n*i,o=r-a*i,l=this.canonical.z,u=1<<l,h=this.canonical.y+a;if(h<0||h>=u)return null;let c=this.canonical.x+n,p=this.wrap;return c<0?(p-=Math.ceil(-c/u),c=(c%u+u)%u):c>=u&&(p+=Math.floor(c/u),c%=u),{tileID:new ie(this.overscaledZ,p,l,c,h),x:s,y:o}}};function Xi(t,e,r,i,n){t*=2,t<0&&(t=t*-1-1);let a=1<<r;return(a*a*t+a*n+i).toString(36)+r.toString(36)+e.toString(36)}var Gs=Math.PI*6378137;function Qb(t,e,r){e=2**r-e-1;let i=Zc(t*256,e*256,r),n=Zc((t+1)*256,(e+1)*256,r);return`${i[0]},${i[1]},${n[0]},${n[1]}`}function Zc(t,e,r){let i=2*Gs/256/2**r;return[t*i-Gs,e*i-Gs]}function tw(t,e,r){let i="";for(let n=t;n>0;n--){let a=1<<n-1;i+=(e&a?1:0)+(r&a?2:0)}return i}I("CanonicalTileID",xy),I("OverscaledTileID",su,{omit:["terrainRttPosMatrix32f"]});var ew=class{constructor(t,e){this.feature=t,this.type=t.type,this.properties=t.tags?t.tags:{},this.extent=e,"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=[],e=this.feature.type===1?[this.feature.geometry]:this.feature.geometry;for(let r of e){let i=[];for(let n of r)i.push(new B(n[0],n[1]));t.push(i)}return t}},al="_geojsonTileLayer",vy=class{constructor(t,e){this.layers={[al]:this},this.name=al,this.version=e?e.version:1,this.extent=e?e.extent:4096,this.length=t.length,this.features=t}feature(t){return new ew(this.features[t],this.extent)}};function ou(t,e=""){let r=new Bv;return rw(t,r,e),r.finish()}function rw(t,e,r=""){for(let i in t.layers)e.writeMessage(3,(n,a)=>iw(n,a,r),t.layers[i])}function iw(t,e,r=""){e.writeVarintField(15,t.version||1),e.writeStringField(1,t.name||""),e.writeVarintField(5,t.extent||4096);let i={jsonPrefix:r,keys:[],values:[],keycache:{},valuecache:{}};for(let s=0;s<t.length;s++)i.feature=t.feature(s),e.writeMessage(2,nw,i);let n=i.keys;for(let s of n)e.writeStringField(3,s);let a=i.values;for(let s of a)e.writeMessage(4,ow,s)}function nw(t,e){if(!t.feature)return;let r=t.feature;r.id!==void 0&&e.writeVarintField(1,r.id),e.writeMessage(2,aw,t),e.writeVarintField(3,r.type),e.writeMessage(4,sw,r)}function aw(t,e){for(let r in t.feature?.properties){let i=t.feature.properties[r],n=t.keycache[r];if(i==null)continue;n===void 0&&(t.keys.push(r),n=t.keys.length-1,t.keycache[r]=n),e.writeVarint(n),typeof i!="string"&&typeof i!="boolean"&&typeof i!="number"&&(i=t.jsonPrefix+JSON.stringify(i));let a=typeof i+":"+i,s=t.valuecache[a];s===void 0&&(t.values.push(i),s=t.values.length-1,t.valuecache[a]=s),e.writeVarint(s)}}function Ys(t,e){return(e<<3)+(t&7)}function Hc(t){return t<<1^t>>31}function sw(t,e){let r=t.loadGeometry(),i=t.type,n=0,a=0;for(let s of r){let o=1;i===1&&(o=s.length),e.writeVarint(Ys(1,o));let l=i===3?s.length-1:s.length;for(let u=0;u<l;u++){u===1&&i!==1&&e.writeVarint(Ys(2,l-1));let h=s[u].x-n,c=s[u].y-a;e.writeVarint(Hc(h)),e.writeVarint(Hc(c)),n+=h,a+=c}t.type===3&&e.writeVarint(Ys(7,1))}}function ow(t,e){let r=typeof t;r==="string"?e.writeStringField(1,t):r==="boolean"?e.writeBooleanField(7,t):r==="number"&&(t%1==0?t<0?e.writeSVarintField(6,t):e.writeVarintField(5,t):e.writeDoubleField(3,t))}var lu=class{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e<t.length;e++){let r=t[e];this._stringToNumber[r]=e,this._numberToString[e]=r}}encode(t){return this._stringToNumber[t]}decode(t){if(t>=this._numberToString.length)throw Error(`Out of bounds. Index requested n=${t} can\'t be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}},lw=class{constructor(t,e,r,i,n){this.type="Feature",this._vectorTileFeature=t,this._x=r,this._y=i,this._z=e;for(let a in t.properties)typeof t.properties[a]=="string"&&t.properties[a].startsWith("__$json__:")&&(t.properties[a]=JSON.parse(t.properties[a].slice(10)));this.properties=t.properties,this.id=n}projectPoint(t,e,r,i){return[(t.x+e)*360/i-180,360/Math.PI*Math.atan(Math.exp((1-(t.y+r)*2/i)*Math.PI))-90]}projectLine(t,e,r,i){return t.map(n=>this.projectPoint(n,e,r,i))}get geometry(){if(this._geometry)return this._geometry;let t=this._vectorTileFeature,e=t.extent*2**this._z,r=t.extent*this._x,i=t.extent*this._y,n=t.loadGeometry();switch(t.type){case 1:{let a=[];for(let o of n)a.push(o[0]);let s=this.projectLine(a,r,i,e);this._geometry=a.length===1?{type:"Point",coordinates:s[0]}:{type:"MultiPoint",coordinates:s};break}case 2:{let a=n.map(s=>this.projectLine(s,r,i,e));this._geometry=a.length===1?{type:"LineString",coordinates:a[0]}:{type:"MultiLineString",coordinates:a};break}case 3:{let a=Sd(n),s=[];for(let o of a)s.push(o.map(l=>this.projectLine(l,r,i,e)));this._geometry=s.length===1?{type:"Polygon",coordinates:s[0]}:{type:"MultiPolygon",coordinates:s};break}default:throw Error(`unknown feature type: ${t.type}`)}return this._geometry}set geometry(t){this._geometry=t}toJSON(){let t={geometry:this.geometry};for(let e in this)e!=="_geometry"&&e!=="_vectorTileFeature"&&e!=="_x"&&e!=="_y"&&e!=="_z"&&(t[e]=this[e]);return t}},_r=class{constructor(t,e,r){this._name=t,this.dataBuffer=e,typeof r=="number"?this._size=r:(this.nullabilityBuffer=r,this._size=r.size())}getValue(t){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(t)?null:this.getValueFromBuffer(t)}has(t){return this.nullabilityBuffer?.get(t)||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}},Wa=class extends _r{},uu=class extends Wa{getValueFromBuffer(t){return this.dataBuffer[t]}},hu=class extends Wa{getValueFromBuffer(t){return this.dataBuffer[t]}},by=class extends _r{constructor(t,e,r,i){super(t,e,i),this.delta=r}},cu=class extends by{constructor(t,e,r,i,n){super(t,n?Int32Array.of(e):Uint32Array.of(e),r,i)}getValueFromBuffer(t){return this.dataBuffer[0]+t*this.delta}},pu=class extends _r{constructor(t,e,r,i){super(t,i?Int32Array.of(e):Uint32Array.of(e),r)}getValueFromBuffer(t){return this.dataBuffer[0]}},uw=class{constructor(t,e,r,i,n=4096){if(this._name=t,this._geometryVector=e,this._idVector=r,this._propertyVectors=i,this._extent=n,t.length===0)throw Error("Missing layer name")}get name(){return this._name}get idVector(){return this._idVector}get geometryVector(){return this._geometryVector}get propertyVectors(){return this._propertyVectors??[]}getPropertyVector(t){return this.propertyVectorsMap||(this.propertyVectorsMap=new Map(this.propertyVectors.map(e=>[e.name,e]))),this.propertyVectorsMap.get(t)}get numFeatures(){return this.geometryVector.numGeometries}get extent(){return this._extent}getFeatures(){let t=[],e=this.geometryVector.getGeometries();for(let r=0;r<this.numFeatures;r++){let i;if(this.idVector){let s=this.idVector.getValue(r);s!==null&&(i=this.containsMaxSafeIntegerValues(this.idVector)?Number(s):s)}let n={coordinates:e[r],type:this.geometryVector.geometryType(r)},a={};for(let s of this.propertyVectors){if(!s)continue;let o=s.name,l=s.getValue(r);l!==null&&(a[o]=l)}t.push({id:i,geometry:n,properties:a})}return t}containsMaxSafeIntegerValues(t){return t instanceof uu||t instanceof pu||t instanceof cu||t instanceof hu}},$i={FEATURE:0,VERTEX:1},rt={BOOLEAN:0,INT_8:1,UINT_8:2,INT_32:3,UINT_32:4,INT_64:5,UINT_64:6,FLOAT:7,DOUBLE:8,STRING:9},Ke={GEOMETRY:0,STRUCT:1,MAP:2},wy={ID:0},Dy=class{constructor(t){this.value=t}get(){return this.value}set(t){this.value=t}increment(){return this.value++}add(t){this.value+=t}},W;(function(t){t.NONE="NONE",t.DELTA="DELTA",t.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",t.RLE="RLE",t.MORTON="MORTON"})(W||(W={}));var Qt;(function(t){t.NONE="NONE",t.FAST_PFOR="FAST_PFOR",t.VARINT="VARINT"})(Qt||(Qt={}));var fu=new Uint32Array(33);fu[0]=0;for(let t=1;t<=32;t++)fu[t]=t===32?4294967295:4294967295>>>32-t;var sl=fu,_y=65536;function du(t,e){return t-t%e}function hw(t){return du(t+31,32)}function cw(t){if(!Number.isFinite(t)||t<=0)return _y;let e=du(Math.floor(t),256);return e===0?256:e}function pw(t){let e=t>>>0;return((e&255)<<24|(e&65280)<<8|e>>>8&65280|e>>>24&255)>>>0}function fw(t,e,r,i){let n=i,a=t[e]>>>0,s=t[e+1]>>>0;r[n++]=a>>>0&3,r[n++]=a>>>2&3,r[n++]=a>>>4&3,r[n++]=a>>>6&3,r[n++]=a>>>8&3,r[n++]=a>>>10&3,r[n++]=a>>>12&3,r[n++]=a>>>14&3,r[n++]=a>>>16&3,r[n++]=a>>>18&3,r[n++]=a>>>20&3,r[n++]=a>>>22&3,r[n++]=a>>>24&3,r[n++]=a>>>26&3,r[n++]=a>>>28&3,r[n++]=a>>>30&3,r[n++]=s>>>0&3,r[n++]=s>>>2&3,r[n++]=s>>>4&3,r[n++]=s>>>6&3,r[n++]=s>>>8&3,r[n++]=s>>>10&3,r[n++]=s>>>12&3,r[n++]=s>>>14&3,r[n++]=s>>>16&3,r[n++]=s>>>18&3,r[n++]=s>>>20&3,r[n++]=s>>>22&3,r[n++]=s>>>24&3,r[n++]=s>>>26&3,r[n++]=s>>>28&3,r[n]=s>>>30&3}function dw(t,e,r,i){let n=i,a=t[e]>>>0,s=t[e+1]>>>0,o=t[e+2]>>>0;r[n++]=a>>>0&7,r[n++]=a>>>3&7,r[n++]=a>>>6&7,r[n++]=a>>>9&7,r[n++]=a>>>12&7,r[n++]=a>>>15&7,r[n++]=a>>>18&7,r[n++]=a>>>21&7,r[n++]=a>>>24&7,r[n++]=a>>>27&7,r[n++]=(a>>>30|(s&1)<<2)&7,r[n++]=s>>>1&7,r[n++]=s>>>4&7,r[n++]=s>>>7&7,r[n++]=s>>>10&7,r[n++]=s>>>13&7,r[n++]=s>>>16&7,r[n++]=s>>>19&7,r[n++]=s>>>22&7,r[n++]=s>>>25&7,r[n++]=s>>>28&7,r[n++]=(s>>>31|(o&3)<<1)&7,r[n++]=o>>>2&7,r[n++]=o>>>5&7,r[n++]=o>>>8&7,r[n++]=o>>>11&7,r[n++]=o>>>14&7,r[n++]=o>>>17&7,r[n++]=o>>>20&7,r[n++]=o>>>23&7,r[n++]=o>>>26&7,r[n]=o>>>29&7}function yw(t,e,r,i){let n=i,a=t[e]>>>0,s=t[e+1]>>>0,o=t[e+2]>>>0,l=t[e+3]>>>0;r[n++]=a>>>0&15,r[n++]=a>>>4&15,r[n++]=a>>>8&15,r[n++]=a>>>12&15,r[n++]=a>>>16&15,r[n++]=a>>>20&15,r[n++]=a>>>24&15,r[n++]=a>>>28&15,r[n++]=s>>>0&15,r[n++]=s>>>4&15,r[n++]=s>>>8&15,r[n++]=s>>>12&15,r[n++]=s>>>16&15,r[n++]=s>>>20&15,r[n++]=s>>>24&15,r[n++]=s>>>28&15,r[n++]=o>>>0&15,r[n++]=o>>>4&15,r[n++]=o>>>8&15,r[n++]=o>>>12&15,r[n++]=o>>>16&15,r[n++]=o>>>20&15,r[n++]=o>>>24&15,r[n++]=o>>>28&15,r[n++]=l>>>0&15,r[n++]=l>>>4&15,r[n++]=l>>>8&15,r[n++]=l>>>12&15,r[n++]=l>>>16&15,r[n++]=l>>>20&15,r[n++]=l>>>24&15,r[n]=l>>>28&15}function mw(t,e,r,i){let n=i,a=t[e]>>>0,s=t[e+1]>>>0,o=t[e+2]>>>0,l=t[e+3]>>>0,u=t[e+4]>>>0;r[n++]=a>>>0&31,r[n++]=a>>>5&31,r[n++]=a>>>10&31,r[n++]=a>>>15&31,r[n++]=a>>>20&31,r[n++]=a>>>25&31,r[n++]=(a>>>30|(s&7)<<2)&31,r[n++]=s>>>3&31,r[n++]=s>>>8&31,r[n++]=s>>>13&31,r[n++]=s>>>18&31,r[n++]=s>>>23&31,r[n++]=(s>>>28|(o&1)<<4)&31,r[n++]=o>>>1&31,r[n++]=o>>>6&31,r[n++]=o>>>11&31,r[n++]=o>>>16&31,r[n++]=o>>>21&31,r[n++]=o>>>26&31,r[n++]=(o>>>31|(l&15)<<1)&31,r[n++]=l>>>4&31,r[n++]=l>>>9&31,r[n++]=l>>>14&31,r[n++]=l>>>19&31,r[n++]=l>>>24&31,r[n++]=(l>>>29|(u&3)<<3)&31,r[n++]=u>>>2&31,r[n++]=u>>>7&31,r[n++]=u>>>12&31,r[n++]=u>>>17&31,r[n++]=u>>>22&31,r[n]=u>>>27&31}function gw(t,e,r,i){let n=i,a=t[e]>>>0,s=t[e+1]>>>0,o=t[e+2]>>>0,l=t[e+3]>>>0,u=t[e+4]>>>0,h=t[e+5]>>>0;r[n++]=a>>>0&63,r[n++]=a>>>6&63,r[n++]=a>>>12&63,r[n++]=a>>>18&63,r[n++]=a>>>24&63,r[n++]=(a>>>30|(s&15)<<2)&63,r[n++]=s>>>4&63,r[n++]=s>>>10&63,r[n++]=s>>>16&63,r[n++]=s>>>22&63,r[n++]=(s>>>28|(o&3)<<4)&63,r[n++]=o>>>2&63,r[n++]=o>>>8&63,r[n++]=o>>>14&63,r[n++]=o>>>20&63,r[n++]=o>>>26&63,r[n++]=l>>>0&63,r[n++]=l>>>6&63,r[n++]=l>>>12&63,r[n++]=l>>>18&63,r[n++]=l>>>24&63,r[n++]=(l>>>30|(u&15)<<2)&63,r[n++]=u>>>4&63,r[n++]=u>>>10&63,r[n++]=u>>>16&63,r[n++]=u>>>22&63,r[n++]=(u>>>28|(h&3)<<4)&63,r[n++]=h>>>2&63,r[n++]=h>>>8&63,r[n++]=h>>>14&63,r[n++]=h>>>20&63,r[n]=h>>>26&63}function xw(t,e,r,i){let n=i,a=t[e]>>>0,s=t[e+1]>>>0,o=t[e+2]>>>0,l=t[e+3]>>>0,u=t[e+4]>>>0,h=t[e+5]>>>0,c=t[e+6]>>>0;r[n++]=a>>>0&127,r[n++]=a>>>7&127,r[n++]=a>>>14&127,r[n++]=a>>>21&127,r[n++]=(a>>>28|(s&7)<<4)&127,r[n++]=s>>>3&127,r[n++]=s>>>10&127,r[n++]=s>>>17&127,r[n++]=s>>>24&127,r[n++]=(s>>>31|(o&63)<<1)&127,r[n++]=o>>>6&127,r[n++]=o>>>13&127,r[n++]=o>>>20&127,r[n++]=(o>>>27|(l&3)<<5)&127,r[n++]=l>>>2&127,r[n++]=l>>>9&127,r[n++]=l>>>16&127,r[n++]=l>>>23&127,r[n++]=(l>>>30|(u&31)<<2)&127,r[n++]=u>>>5&127,r[n++]=u>>>12&127,r[n++]=u>>>19&127,r[n++]=(u>>>26|(h&1)<<6)&127,r[n++]=h>>>1&127,r[n++]=h>>>8&127,r[n++]=h>>>15&127,r[n++]=h>>>22&127,r[n++]=(h>>>29|(c&15)<<3)&127,r[n++]=c>>>4&127,r[n++]=c>>>11&127,r[n++]=c>>>18&127,r[n]=c>>>25&127}function vw(t,e,r,i){let n=i,a=t[e]>>>0,s=t[e+1]>>>0,o=t[e+2]>>>0,l=t[e+3]>>>0,u=t[e+4]>>>0,h=t[e+5]>>>0,c=t[e+6]>>>0,p=t[e+7]>>>0;r[n++]=a>>>0&255,r[n++]=a>>>8&255,r[n++]=a>>>16&255,r[n++]=a>>>24&255,r[n++]=s>>>0&255,r[n++]=s>>>8&255,r[n++]=s>>>16&255,r[n++]=s>>>24&255,r[n++]=o>>>0&255,r[n++]=o>>>8&255,r[n++]=o>>>16&255,r[n++]=o>>>24&255,r[n++]=l>>>0&255,r[n++]=l>>>8&255,r[n++]=l>>>16&255,r[n++]=l>>>24&255,r[n++]=u>>>0&255,r[n++]=u>>>8&255,r[n++]=u>>>16&255,r[n++]=u>>>24&255,r[n++]=h>>>0&255,r[n++]=h>>>8&255,r[n++]=h>>>16&255,r[n++]=h>>>24&255,r[n++]=c>>>0&255,r[n++]=c>>>8&255,r[n++]=c>>>16&255,r[n++]=c>>>24&255,r[n++]=p>>>0&255,r[n++]=p>>>8&255,r[n++]=p>>>16&255,r[n]=p>>>24&255}function bw(t,e,r,i){let n=i,a=t[e]>>>0,s=t[e+1]>>>0,o=t[e+2]>>>0,l=t[e+3]>>>0,u=t[e+4]>>>0,h=t[e+5]>>>0,c=t[e+6]>>>0,p=t[e+7]>>>0,f=t[e+8]>>>0;r[n++]=a>>>0&511,r[n++]=a>>>9&511,r[n++]=a>>>18&511,r[n++]=(a>>>27|(s&15)<<5)&511,r[n++]=s>>>4&511,r[n++]=s>>>13&511,r[n++]=s>>>22&511,r[n++]=(s>>>31|(o&255)<<1)&511,r[n++]=o>>>8&511,r[n++]=o>>>17&511,r[n++]=(o>>>26|(l&7)<<6)&511,r[n++]=l>>>3&511,r[n++]=l>>>12&511,r[n++]=l>>>21&511,r[n++]=(l>>>30|(u&127)<<2)&511,r[n++]=u>>>7&511,r[n++]=u>>>16&511,r[n++]=(u>>>25|(h&3)<<7)&511,r[n++]=h>>>2&511,r[n++]=h>>>11&511,r[n++]=h>>>20&511,r[n++]=(h>>>29|(c&63)<<3)&511,r[n++]=c>>>6&511,r[n++]=c>>>15&511,r[n++]=(c>>>24|(p&1)<<8)&511,r[n++]=p>>>1&511,r[n++]=p>>>10&511,r[n++]=p>>>19&511,r[n++]=(p>>>28|(f&31)<<4)&511,r[n++]=f>>>5&511,r[n++]=f>>>14&511,r[n]=f>>>23&511}function ww(t,e,r,i){let n=i,a=t[e]>>>0,s=t[e+1]>>>0,o=t[e+2]>>>0,l=t[e+3]>>>0,u=t[e+4]>>>0,h=t[e+5]>>>0,c=t[e+6]>>>0,p=t[e+7]>>>0,f=t[e+8]>>>0,d=t[e+9]>>>0;r[n++]=a>>>0&1023,r[n++]=a>>>10&1023,r[n++]=a>>>20&1023,r[n++]=(a>>>30|(s&255)<<2)&1023,r[n++]=s>>>8&1023,r[n++]=s>>>18&1023,r[n++]=(s>>>28|(o&63)<<4)&1023,r[n++]=o>>>6&1023,r[n++]=o>>>16&1023,r[n++]=(o>>>26|(l&15)<<6)&1023,r[n++]=l>>>4&1023,r[n++]=l>>>14&1023,r[n++]=(l>>>24|(u&3)<<8)&1023,r[n++]=u>>>2&1023,r[n++]=u>>>12&1023,r[n++]=u>>>22&1023,r[n++]=h>>>0&1023,r[n++]=h>>>10&1023,r[n++]=h>>>20&1023,r[n++]=(h>>>30|(c&255)<<2)&1023,r[n++]=c>>>8&1023,r[n++]=c>>>18&1023,r[n++]=(c>>>28|(p&63)<<4)&1023,r[n++]=p>>>6&1023,r[n++]=p>>>16&1023,r[n++]=(p>>>26|(f&15)<<6)&1023,r[n++]=f>>>4&1023,r[n++]=f>>>14&1023,r[n++]=(f>>>24|(d&3)<<8)&1023,r[n++]=d>>>2&1023,r[n++]=d>>>12&1023,r[n]=d>>>22&1023}function Dw(t,e,r,i){let n=i,a=t[e]>>>0,s=t[e+1]>>>0,o=t[e+2]>>>0,l=t[e+3]>>>0,u=t[e+4]>>>0,h=t[e+5]>>>0,c=t[e+6]>>>0,p=t[e+7]>>>0,f=t[e+8]>>>0,d=t[e+9]>>>0,y=t[e+10]>>>0;r[n++]=a>>>0&2047,r[n++]=a>>>11&2047,r[n++]=(a>>>22|(s&1)<<10)&2047,r[n++]=s>>>1&2047,r[n++]=s>>>12&2047,r[n++]=(s>>>23|(o&3)<<9)&2047,r[n++]=o>>>2&2047,r[n++]=o>>>13&2047,r[n++]=(o>>>24|(l&7)<<8)&2047,r[n++]=l>>>3&2047,r[n++]=l>>>14&2047,r[n++]=(l>>>25|(u&15)<<7)&2047,r[n++]=u>>>4&2047,r[n++]=u>>>15&2047,r[n++]=(u>>>26|(h&31)<<6)&2047,r[n++]=h>>>5&2047,r[n++]=h>>>16&2047,r[n++]=(h>>>27|(c&63)<<5)&2047,r[n++]=c>>>6&2047,r[n++]=c>>>17&2047,r[n++]=(c>>>28|(p&127)<<4)&2047,r[n++]=p>>>7&2047,r[n++]=p>>>18&2047,r[n++]=(p>>>29|(f&255)<<3)&2047,r[n++]=f>>>8&2047,r[n++]=f>>>19&2047,r[n++]=(f>>>30|(d&511)<<2)&2047,r[n++]=d>>>9&2047,r[n++]=d>>>20&2047,r[n++]=(d>>>31|(y&1023)<<1)&2047,r[n++]=y>>>10&2047,r[n]=y>>>21&2047}function _w(t,e,r,i){let n=i,a=t[e]>>>0,s=t[e+1]>>>0,o=t[e+2]>>>0,l=t[e+3]>>>0,u=t[e+4]>>>0,h=t[e+5]>>>0,c=t[e+6]>>>0,p=t[e+7]>>>0,f=t[e+8]>>>0,d=t[e+9]>>>0,y=t[e+10]>>>0,m=t[e+11]>>>0;r[n++]=a>>>0&4095,r[n++]=a>>>12&4095,r[n++]=(a>>>24|(s&15)<<8)&4095,r[n++]=s>>>4&4095,r[n++]=s>>>16&4095,r[n++]=(s>>>28|(o&255)<<4)&4095,r[n++]=o>>>8&4095,r[n++]=o>>>20&4095,r[n++]=l>>>0&4095,r[n++]=l>>>12&4095,r[n++]=(l>>>24|(u&15)<<8)&4095,r[n++]=u>>>4&4095,r[n++]=u>>>16&4095,r[n++]=(u>>>28|(h&255)<<4)&4095,r[n++]=h>>>8&4095,r[n++]=h>>>20&4095,r[n++]=c>>>0&4095,r[n++]=c>>>12&4095,r[n++]=(c>>>24|(p&15)<<8)&4095,r[n++]=p>>>4&4095,r[n++]=p>>>16&4095,r[n++]=(p>>>28|(f&255)<<4)&4095,r[n++]=f>>>8&4095,r[n++]=f>>>20&4095,r[n++]=d>>>0&4095,r[n++]=d>>>12&4095,r[n++]=(d>>>24|(y&15)<<8)&4095,r[n++]=y>>>4&4095,r[n++]=y>>>16&4095,r[n++]=(y>>>28|(m&255)<<4)&4095,r[n++]=m>>>8&4095,r[n]=m>>>20&4095}function Aw(t,e,r,i){let n=i,a=t[e]>>>0,s=t[e+1]>>>0,o=t[e+2]>>>0,l=t[e+3]>>>0,u=t[e+4]>>>0,h=t[e+5]>>>0,c=t[e+6]>>>0,p=t[e+7]>>>0,f=t[e+8]>>>0,d=t[e+9]>>>0,y=t[e+10]>>>0,m=t[e+11]>>>0,g=t[e+12]>>>0,x=t[e+13]>>>0,b=t[e+14]>>>0,v=t[e+15]>>>0;r[n++]=a>>>0&65535,r[n++]=a>>>16&65535,r[n++]=s>>>0&65535,r[n++]=s>>>16&65535,r[n++]=o>>>0&65535,r[n++]=o>>>16&65535,r[n++]=l>>>0&65535,r[n++]=l>>>16&65535,r[n++]=u>>>0&65535,r[n++]=u>>>16&65535,r[n++]=h>>>0&65535,r[n++]=h>>>16&65535,r[n++]=c>>>0&65535,r[n++]=c>>>16&65535,r[n++]=p>>>0&65535,r[n++]=p>>>16&65535,r[n++]=f>>>0&65535,r[n++]=f>>>16&65535,r[n++]=d>>>0&65535,r[n++]=d>>>16&65535,r[n++]=y>>>0&65535,r[n++]=y>>>16&65535,r[n++]=m>>>0&65535,r[n++]=m>>>16&65535,r[n++]=g>>>0&65535,r[n++]=g>>>16&65535,r[n++]=x>>>0&65535,r[n++]=x>>>16&65535,r[n++]=b>>>0&65535,r[n++]=b>>>16&65535,r[n++]=v>>>0&65535,r[n]=v>>>16&65535}function Sw(t,e,r,i){let n=i,a=e;for(let s=0;s<8;s++){let o=t[a++]>>>0;r[n++]=o>>>0&1,r[n++]=o>>>1&1,r[n++]=o>>>2&1,r[n++]=o>>>3&1,r[n++]=o>>>4&1,r[n++]=o>>>5&1,r[n++]=o>>>6&1,r[n++]=o>>>7&1,r[n++]=o>>>8&1,r[n++]=o>>>9&1,r[n++]=o>>>10&1,r[n++]=o>>>11&1,r[n++]=o>>>12&1,r[n++]=o>>>13&1,r[n++]=o>>>14&1,r[n++]=o>>>15&1,r[n++]=o>>>16&1,r[n++]=o>>>17&1,r[n++]=o>>>18&1,r[n++]=o>>>19&1,r[n++]=o>>>20&1,r[n++]=o>>>21&1,r[n++]=o>>>22&1,r[n++]=o>>>23&1,r[n++]=o>>>24&1,r[n++]=o>>>25&1,r[n++]=o>>>26&1,r[n++]=o>>>27&1,r[n++]=o>>>28&1,r[n++]=o>>>29&1,r[n++]=o>>>30&1,r[n++]=o>>>31&1}}function Ew(t,e,r,i){let n=i,a=e;for(let s=0;s<8;s++){let o=t[a++]>>>0,l=t[a++]>>>0;r[n++]=o>>>0&3,r[n++]=o>>>2&3,r[n++]=o>>>4&3,r[n++]=o>>>6&3,r[n++]=o>>>8&3,r[n++]=o>>>10&3,r[n++]=o>>>12&3,r[n++]=o>>>14&3,r[n++]=o>>>16&3,r[n++]=o>>>18&3,r[n++]=o>>>20&3,r[n++]=o>>>22&3,r[n++]=o>>>24&3,r[n++]=o>>>26&3,r[n++]=o>>>28&3,r[n++]=o>>>30&3,r[n++]=l>>>0&3,r[n++]=l>>>2&3,r[n++]=l>>>4&3,r[n++]=l>>>6&3,r[n++]=l>>>8&3,r[n++]=l>>>10&3,r[n++]=l>>>12&3,r[n++]=l>>>14&3,r[n++]=l>>>16&3,r[n++]=l>>>18&3,r[n++]=l>>>20&3,r[n++]=l>>>22&3,r[n++]=l>>>24&3,r[n++]=l>>>26&3,r[n++]=l>>>28&3,r[n++]=l>>>30&3}}function Fw(t,e,r,i){let n=i,a=e;for(let s=0;s<8;s++){let o=t[a++]>>>0,l=t[a++]>>>0,u=t[a++]>>>0;r[n++]=o>>>0&7,r[n++]=o>>>3&7,r[n++]=o>>>6&7,r[n++]=o>>>9&7,r[n++]=o>>>12&7,r[n++]=o>>>15&7,r[n++]=o>>>18&7,r[n++]=o>>>21&7,r[n++]=o>>>24&7,r[n++]=o>>>27&7,r[n++]=(o>>>30|(l&1)<<2)&7,r[n++]=l>>>1&7,r[n++]=l>>>4&7,r[n++]=l>>>7&7,r[n++]=l>>>10&7,r[n++]=l>>>13&7,r[n++]=l>>>16&7,r[n++]=l>>>19&7,r[n++]=l>>>22&7,r[n++]=l>>>25&7,r[n++]=l>>>28&7,r[n++]=(l>>>31|(u&3)<<1)&7,r[n++]=u>>>2&7,r[n++]=u>>>5&7,r[n++]=u>>>8&7,r[n++]=u>>>11&7,r[n++]=u>>>14&7,r[n++]=u>>>17&7,r[n++]=u>>>20&7,r[n++]=u>>>23&7,r[n++]=u>>>26&7,r[n++]=u>>>29&7}}function Tw(t,e,r,i){let n=i,a=e;for(let s=0;s<8;s++){let o=t[a++]>>>0,l=t[a++]>>>0,u=t[a++]>>>0,h=t[a++]>>>0;r[n++]=o>>>0&15,r[n++]=o>>>4&15,r[n++]=o>>>8&15,r[n++]=o>>>12&15,r[n++]=o>>>16&15,r[n++]=o>>>20&15,r[n++]=o>>>24&15,r[n++]=o>>>28&15,r[n++]=l>>>0&15,r[n++]=l>>>4&15,r[n++]=l>>>8&15,r[n++]=l>>>12&15,r[n++]=l>>>16&15,r[n++]=l>>>20&15,r[n++]=l>>>24&15,r[n++]=l>>>28&15,r[n++]=u>>>0&15,r[n++]=u>>>4&15,r[n++]=u>>>8&15,r[n++]=u>>>12&15,r[n++]=u>>>16&15,r[n++]=u>>>20&15,r[n++]=u>>>24&15,r[n++]=u>>>28&15,r[n++]=h>>>0&15,r[n++]=h>>>4&15,r[n++]=h>>>8&15,r[n++]=h>>>12&15,r[n++]=h>>>16&15,r[n++]=h>>>20&15,r[n++]=h>>>24&15,r[n++]=h>>>28&15}}function kw(t,e,r,i){let n=i,a=e;for(let s=0;s<8;s++){let o=t[a++]>>>0,l=t[a++]>>>0,u=t[a++]>>>0,h=t[a++]>>>0,c=t[a++]>>>0;r[n++]=o>>>0&31,r[n++]=o>>>5&31,r[n++]=o>>>10&31,r[n++]=o>>>15&31,r[n++]=o>>>20&31,r[n++]=o>>>25&31,r[n++]=(o>>>30|(l&7)<<2)&31,r[n++]=l>>>3&31,r[n++]=l>>>8&31,r[n++]=l>>>13&31,r[n++]=l>>>18&31,r[n++]=l>>>23&31,r[n++]=(l>>>28|(u&1)<<4)&31,r[n++]=u>>>1&31,r[n++]=u>>>6&31,r[n++]=u>>>11&31,r[n++]=u>>>16&31,r[n++]=u>>>21&31,r[n++]=u>>>26&31,r[n++]=(u>>>31|(h&15)<<1)&31,r[n++]=h>>>4&31,r[n++]=h>>>9&31,r[n++]=h>>>14&31,r[n++]=h>>>19&31,r[n++]=h>>>24&31,r[n++]=(h>>>29|(c&3)<<3)&31,r[n++]=c>>>2&31,r[n++]=c>>>7&31,r[n++]=c>>>12&31,r[n++]=c>>>17&31,r[n++]=c>>>22&31,r[n++]=c>>>27&31}}function Iw(t,e,r,i){let n=i,a=e;for(let s=0;s<8;s++){let o=t[a++]>>>0,l=t[a++]>>>0,u=t[a++]>>>0,h=t[a++]>>>0,c=t[a++]>>>0,p=t[a++]>>>0;r[n++]=o>>>0&63,r[n++]=o>>>6&63,r[n++]=o>>>12&63,r[n++]=o>>>18&63,r[n++]=o>>>24&63,r[n++]=(o>>>30|(l&15)<<2)&63,r[n++]=l>>>4&63,r[n++]=l>>>10&63,r[n++]=l>>>16&63,r[n++]=l>>>22&63,r[n++]=(l>>>28|(u&3)<<4)&63,r[n++]=u>>>2&63,r[n++]=u>>>8&63,r[n++]=u>>>14&63,r[n++]=u>>>20&63,r[n++]=u>>>26&63,r[n++]=h>>>0&63,r[n++]=h>>>6&63,r[n++]=h>>>12&63,r[n++]=h>>>18&63,r[n++]=h>>>24&63,r[n++]=(h>>>30|(c&15)<<2)&63,r[n++]=c>>>4&63,r[n++]=c>>>10&63,r[n++]=c>>>16&63,r[n++]=c>>>22&63,r[n++]=(c>>>28|(p&3)<<4)&63,r[n++]=p>>>2&63,r[n++]=p>>>8&63,r[n++]=p>>>14&63,r[n++]=p>>>20&63,r[n++]=p>>>26&63}}function Cw(t,e,r,i){let n=i,a=e;for(let s=0;s<8;s++){let o=t[a++]>>>0,l=t[a++]>>>0,u=t[a++]>>>0,h=t[a++]>>>0,c=t[a++]>>>0,p=t[a++]>>>0,f=t[a++]>>>0;r[n++]=o>>>0&127,r[n++]=o>>>7&127,r[n++]=o>>>14&127,r[n++]=o>>>21&127,r[n++]=(o>>>28|(l&7)<<4)&127,r[n++]=l>>>3&127,r[n++]=l>>>10&127,r[n++]=l>>>17&127,r[n++]=l>>>24&127,r[n++]=(l>>>31|(u&63)<<1)&127,r[n++]=u>>>6&127,r[n++]=u>>>13&127,r[n++]=u>>>20&127,r[n++]=(u>>>27|(h&3)<<5)&127,r[n++]=h>>>2&127,r[n++]=h>>>9&127,r[n++]=h>>>16&127,r[n++]=h>>>23&127,r[n++]=(h>>>30|(c&31)<<2)&127,r[n++]=c>>>5&127,r[n++]=c>>>12&127,r[n++]=c>>>19&127,r[n++]=(c>>>26|(p&1)<<6)&127,r[n++]=p>>>1&127,r[n++]=p>>>8&127,r[n++]=p>>>15&127,r[n++]=p>>>22&127,r[n++]=(p>>>29|(f&15)<<3)&127,r[n++]=f>>>4&127,r[n++]=f>>>11&127,r[n++]=f>>>18&127,r[n++]=f>>>25&127}}function Mw(t,e,r,i){let n=i,a=e;for(let s=0;s<8;s++){let o=t[a++]>>>0,l=t[a++]>>>0,u=t[a++]>>>0,h=t[a++]>>>0,c=t[a++]>>>0,p=t[a++]>>>0,f=t[a++]>>>0,d=t[a++]>>>0;r[n++]=o>>>0&255,r[n++]=o>>>8&255,r[n++]=o>>>16&255,r[n++]=o>>>24&255,r[n++]=l>>>0&255,r[n++]=l>>>8&255,r[n++]=l>>>16&255,r[n++]=l>>>24&255,r[n++]=u>>>0&255,r[n++]=u>>>8&255,r[n++]=u>>>16&255,r[n++]=u>>>24&255,r[n++]=h>>>0&255,r[n++]=h>>>8&255,r[n++]=h>>>16&255,r[n++]=h>>>24&255,r[n++]=c>>>0&255,r[n++]=c>>>8&255,r[n++]=c>>>16&255,r[n++]=c>>>24&255,r[n++]=p>>>0&255,r[n++]=p>>>8&255,r[n++]=p>>>16&255,r[n++]=p>>>24&255,r[n++]=f>>>0&255,r[n++]=f>>>8&255,r[n++]=f>>>16&255,r[n++]=f>>>24&255,r[n++]=d>>>0&255,r[n++]=d>>>8&255,r[n++]=d>>>16&255,r[n++]=d>>>24&255}}function Bw(t,e,r,i){let n=i,a=e;for(let s=0;s<128;s++){let o=t[a++]>>>0;r[n++]=o&65535,r[n++]=o>>>16&65535}}function Pw(t,e,r,i,n){let a=sl[n]>>>0,s=e,o=0,l=t[s]>>>0,u=i;for(let h=0;h<8;h++){for(let c=0;c<32;c++)if(o+n<=32){let p=l>>>o&a;r[u+c]=p|0,o+=n,o===32&&(o=0,s++,c!==31&&(l=t[s]>>>0))}else{let p=32-o,f=l>>>o;s++,l=t[s]>>>0;let d=n-p,y=-1>>>32-d>>>0,m=(f|(l&y)<<p)&a;r[u+c]=m|0,o=d}u+=32,o=0,h<7&&(l=t[s]>>>0)}}var ol=cw(_y),zw=3*ol/256+ol|0;function Ay(){let t=new Uint8Array(zw);return{dataToBePacked:Array(33),dataPointers:new Int32Array(33),byteContainer:t,byteContainerI32:new Int32Array(t.buffer,t.byteOffset,t.byteLength>>>2),exceptionSizes:new Int32Array(33)}}function Lw(t=16){if(t<0)throw RangeError(`initialEncodedWordCapacity must be >= 0, got ${t}`);let e=Math.max(16,t|0);return{encodedWords:new Uint32Array(e),decoderWorkspace:Ay()}}function Vw(t,e){if(e<=t.encodedWords.length)return t.encodedWords;let r=new Uint32Array(Math.max(16,e*2));return t.encodedWords=r,r}function Ow(t,e,r,i){i.byteContainer.length<r&&(i.byteContainer=new Uint8Array(r*2),i.byteContainerI32=void 0);let n=i.byteContainer,a=r>>>2;if(n.byteOffset&3)for(let o=0;o<a;o=o+1|0){let l=t[e+o|0]|0,u=o<<2;n[u]=l&255,n[u+1|0]=l>>>8&255,n[u+2|0]=l>>>16&255,n[u+3|0]=l>>>24&255}else{let o=i.byteContainerI32;(!o||o.buffer!==n.buffer||o.byteOffset!==n.byteOffset||o.length<a)&&(o=i.byteContainerI32=new Int32Array(n.buffer,n.byteOffset,n.byteLength>>>2)),o.set(t.subarray(e,e+a))}let s=r&3;if(s>0){let o=t[e+a|0]|0,l=a<<2;for(let u=0;u<s;u=u+1|0)n[l+u|0]=o>>>(u<<3)&255}return n}function Rw(t,e,r){let i=t[e++]|0,n=r.dataToBePacked;for(let a=2;a<=32;a=a+1|0){if(!(i>>>a-1&1))continue;if(e>=t.length)throw Error(`FastPFOR decode: truncated exception stream header (bitWidth=${a}, streamWordIndex=${e}, needWords=1, availableWords=${t.length-e}, encodedWords=${t.length})`);let s=t[e++]>>>0,o=hw(s),l=s*a+31>>>5;if(e+l>t.length)throw Error(`FastPFOR decode: truncated exception stream (bitWidth=${a}, size=${s}, streamWordIndex=${e}, needWords=${l}, availableWords=${t.length-e}, encodedWords=${t.length})`);let u=n[a];(!u||u.length<o)&&(u=n[a]=new Uint32Array(o));let h=0;for(;h<s;h=h+32|0)Zw(t,e,u,h,a),e=e+a|0;let c=h-s|0;e=e-(c*a>>>5)|0,r.exceptionSizes[a]=s}return e}function $w(t,e,r,i,n){switch(n){case 1:Sw(t,e,r,i);break;case 2:Ew(t,e,r,i);break;case 3:Fw(t,e,r,i);break;case 4:Tw(t,e,r,i);break;case 5:kw(t,e,r,i);break;case 6:Iw(t,e,r,i);break;case 7:Cw(t,e,r,i);break;case 8:Mw(t,e,r,i);break;case 16:Bw(t,e,r,i);break;default:Pw(t,e,r,i,n)}return e+(n<<3)|0}function Nw(t,e,r,i){if(r+2>e)throw Error(`FastPFOR decode: byteContainer underflow at block=${i} (need 2 bytes for [bitWidth, exceptionCount], bytePos=${r}, byteSize=${e})`);let n=t[r++],a=t[r++];if(n>32)throw Error(`FastPFOR decode: invalid bitWidth=${n} at block=${i} (expected 0..32). This likely indicates corrupted or truncated input.`);return{bitWidth:n,exceptionCount:a,bytePosIn:r}}function Uw(t,e,r,i,n,a){if(r+1>e)throw Error(`FastPFOR decode: exception header underflow at block=${a} (need 1 byte for maxBits, bytePos=${r}, byteSize=${e})`);let s=t[r++];if(s<i||s>32)throw Error(`FastPFOR decode: invalid maxBits=${s} at block=${a} (bitWidth=${i}, expected ${i}..32)`);let o=s-i|0;if(o<1||o>32)throw Error(`FastPFOR decode: invalid exceptionBitWidth=${o} at block=${a} (bitWidth=${i}, maxBits=${s})`);if(r+n>e)throw Error(`FastPFOR decode: exception positions underflow at block=${a} (need=${n}, have=${e-r})`);return{maxBits:s,exceptionBitWidth:o,bytePosIn:r}}function qw(t,e,r,i,n,a,s,o,l){let{maxBits:u,exceptionBitWidth:h,bytePosIn:c}=Uw(n,a,s,r,i,l);if(s=c,h===1){let m=1<<r;for(let g=0;g<i;g=g+1|0){let x=n[s++];t[x+e|0]|=m}return s}let p=o.dataToBePacked[h];if(!p)throw Error(`FastPFOR decode: missing exception stream for exceptionBitWidth=${h} (bitWidth=${r}, maxBits=${u}) at block ${l}`);let f=o.dataPointers,d=f[h]|0,y=o.exceptionSizes[h]|0;if(d+i>y)throw Error(`FastPFOR decode: exception stream overflow for exceptionBitWidth=${h} (ptr=${d}, need ${i}, size=${y}) at block ${l}`);for(let m=0;m<i;m=m+1|0){let g=n[s++],x=p[d++]|0;t[g+e|0]|=x<<r}return f[h]=d,s}function jw(t,e,r,i,n,a,s,o,l,u){let h=r|0,c=0;for(let p=0;p<s;p=p+1|0){let f=Nw(o,l,c,p);c=f.bytePosIn;let d=f.bitWidth,y=f.exceptionCount,m=a+p*256|0;switch(d){case 0:n.fill(0,m,m+256);break;case 32:for(let g=0;g<256;g=g+1|0)n[m+g|0]=t[h+g|0]|0;h=h+256|0;break;default:h=$w(t,h,n,m,d)}y>0&&(c=qw(n,m,d,y,o,l,c,u,p))}if(h!==i)throw Error(`FastPFOR decode: packed region mismatch (pageStart=${e}, packedStart=${r}, consumedPackedEnd=${h}, expectedPackedEnd=${i}, packedWords=${i-r}, encoded.length=${t.length})`)}function Gw(t,e,r,i,n,a){let s=r|0,o=t[s]|0;if(o<=0||s+o>t.length-1)throw Error(`FastPFOR decode: invalid whereMeta=${o} at pageStart=${s} (expected > 0 and pageStart+whereMeta < encoded.length=${t.length})`);let l=s+1|0,u=s+o|0,h=t[u]>>>0,c=h+3>>>2,p=u+1,f=p+c;if(f>=t.length)throw Error(`FastPFOR decode: invalid byteSize=${h} (metaInts=${c}, pageStart=${s}, packedEnd=${u}, byteContainerStart=${p}) causes bitmapPos=${f} out of bounds (encoded.length=${t.length})`);let d=Ow(t,p,h,a),y=h,m=Rw(t,f,a);return a.dataPointers.fill(0),jw(t,s,l,u,e,i|0,n/256|0,d,y,a),m}function Yw(t,e,r,i,n,a){let s=i+du(n,256),o=i,l=r;for(;o!==s;){let u=Math.min(ol,s-o);l=Gw(t,e,l,o,u,a),o=o+u|0}return l}function Xw(t,e,r,i,n,a){if(a===0)return e;let s=0,o=e,l=e+r,u=n,h=n,c=n+a,p=0,f=0;for(;o<l&&h<c;){let d=t[o]>>>s&255;if(s+=8,o+=s>>>5,s&=31,p|=(d&127)<<f,d&128)i[h++]=p|0,p=0,f=0;else if(f+=7,f>28)throw Error(`FastPFOR VByte: unterminated value (expected MSB=1 terminator within 5 bytes; shift=${f}, partial=${p}, decoded=${h-u}/${a}, inPos=${o}, inEnd=${l})`)}if(h!==c)throw Error(`FastPFOR VByte: truncated stream (decoded=${h-u}, expected=${a}, consumedWords=${o-e}/${r}, vbyteStart=${e}, vbyteEnd=${l})`);return o}function Ww(t,e,r){let i=0,n=0,a=new Uint32Array(e),s=r??Ay();if(t.length>0){let u=t[i]|0;if(i=i+1|0,u&255)throw Error(`FastPFOR decode: invalid alignedLength=${u} (expected multiple of 256)`);if(n+u>a.length)throw Error(`FastPFOR decode: output buffer too small (outPos=${n}, alignedLength=${u}, out.length=${a.length})`);i=Yw(t,a,i,n,u,s),n=n+u|0}let o=t.length-i|0,l=e-n|0;return Xw(t,i,o,a,n,l),a}function Zw(t,e,r,i,n){switch(n){case 2:fw(t,e,r,i);return;case 3:dw(t,e,r,i);return;case 4:yw(t,e,r,i);return;case 5:mw(t,e,r,i);return;case 6:gw(t,e,r,i);return;case 7:xw(t,e,r,i);return;case 8:vw(t,e,r,i);return;case 9:bw(t,e,r,i);return;case 10:ww(t,e,r,i);return;case 11:Dw(t,e,r,i);return;case 12:_w(t,e,r,i);return;case 16:Aw(t,e,r,i);return;case 32:for(let u=0;u<32;u=u+1|0)r[i+u|0]=t[e+u|0]|0;return}let a=sl[n]>>>0,s=e,o=0,l=t[s]>>>0;for(let u=0;u<32;u++)if(o+n<=32){let h=l>>>o&a;r[i+u]=h|0,o+=n,o===32&&(o=0,s++,u!==31&&(l=t[s]>>>0))}else{let h=32-o,c=l>>>o;s++,l=t[s]>>>0;let p=sl[n-h]>>>0,f=(c|(l&p)<<h)&a;r[i+u]=f|0,o=n-h}}function Hw(t,e,r,i){if(e<0||r<0||e+r>t.length)throw RangeError(`decodeBigEndianInt32sInto: out of bounds (offset=${e}, byteLength=${r}, bytes.length=${t.length})`);let n=Math.floor(r/4),a=r%4!=0,s=a?n+1:n;if(i.length<s)throw RangeError(`decodeBigEndianInt32sInto: out.length=${i.length} < ${s}`);if(n>0){let o=t.byteOffset+e;if(o&3)for(let l=0;l<n;l++){let u=e+l*4;i[l]=t[u]<<24|t[u+1]<<16|t[u+2]<<8|t[u+3]|0}else{let l=new Uint32Array(t.buffer,o,n);for(let u=0;u<n;u++)i[u]=pw(l[u])|0}}if(a){let o=e+n*4,l=r-n*4,u=0;for(let h=0;h<l;h++)u|=t[o+h]<<24-h*8;i[n]=u|0}return s}function Rt(t,e,r){let i=new Uint32Array(r),n=0,a=e.get();for(let s=0;s<i.length;s++){let o=t[a++],l=o&127;if(o<128){i[n++]=l;continue}if(o=t[a++],l|=(o&127)<<7,o<128){i[n++]=l;continue}if(o=t[a++],l|=(o&127)<<14,o<128){i[n++]=l;continue}if(o=t[a++],l|=(o&127)<<21,o<128){i[n++]=l;continue}o=t[a++],l|=(o&15)<<28,i[n++]=l}return e.set(a),i}function yu(t,e,r){let i=new BigUint64Array(r);for(let n=0;n<i.length;n++)i[n]=Kw(t,e);return i}function Kw(t,e){let r=0n,i=0,n=e.get();for(;n<t.length;){let a=t[n++];if(r|=BigInt(a&127)<<BigInt(i),!(a&128))break;if(i+=7,i>=64)throw Error("Varint too long")}return e.set(n),r}function Jw(t,e,r){let i=new Float64Array(r);for(let n=0;n<r;n++)i[n]=Qw(t,e);return i}function Qw(t,e){let r,i;return i=t[e.get()],e.increment(),r=i&127,i<128||(i=t[e.get()],e.increment(),r|=(i&127)<<7,i<128)||(i=t[e.get()],e.increment(),r|=(i&127)<<14,i<128)||(i=t[e.get()],e.increment(),r|=(i&127)<<21,i<128)?r:(i=t[e.get()],r|=(i&15)<<28,t3(r,t,e))}function t3(t,e,r){let i,n;if(n=e[r.get()],r.increment(),i=(n&112)>>4,n<128||(n=e[r.get()],r.increment(),i|=(n&127)<<3,n<128)||(n=e[r.get()],r.increment(),i|=(n&127)<<10,n<128)||(n=e[r.get()],r.increment(),i|=(n&127)<<17,n<128)||(n=e[r.get()],r.increment(),i|=(n&127)<<24,n<128)||(n=e[r.get()],r.increment(),i|=(n&1)<<31,n<128))return i*4294967296+(t>>>0);throw Error("Expected varint not more than 10 bytes")}function e3(t,e,r,i){return r3(t,e,r,i,Lw(r>>>2))}function r3(t,e,r,i,n){let a=i.get();if(r&3)throw Error(`FastPFOR: invalid encodedByteLength=${r} at offset=${a} (encodedBytes.length=${t.length}; expected a multiple of 4 bytes for an int32 big-endian word stream)`);let s=r>>>2,o=Vw(n,s);Hw(t,a,r,o);let l=Ww(o.subarray(0,s),e,n.decoderWorkspace);return i.add(r),l}function et(t){return t>>>1^-(t&1)}function Ot(t){return t>>1n^-(t&1n)}function Ge(t){return t%2==1?(t+1)/-2:t/2}function i3(t){let e=new Int32Array(t.length);for(let r=0;r<t.length;r++)e[r]=et(t[r]);return e}function n3(t){let e=new BigInt64Array(t.length);for(let r=0;r<t.length;r++)e[r]=Ot(t[r]);return e}function a3(t){for(let e=0;e<t.length;e++)t[e]=Ge(t[e])}function ll(t,e,r){if(r===void 0){r=0;for(let a=0;a<e;a++)r+=t[a]}let i=new Uint32Array(r),n=0;for(let a=0;a<e;a++){let s=t[a],o=t[a+e];i.fill(o,n,n+s),n+=s}return i}function ul(t,e,r){if(r===void 0){r=0;for(let a=0;a<e;a++)r+=Number(t[a])}let i=new BigUint64Array(r),n=0;for(let a=0;a<e;a++){let s=Number(t[a]),o=t[a+e];i.fill(o,n,n+s),n+=s}return i}function Sy(t,e,r){let i=new Float64Array(r),n=0;for(let a=0;a<e;a++){let s=t[a],o=t[a+e];i.fill(o,n,n+s),n+=s}return i}function Kc(t){let e=new Int32Array(t.length);e[0]=et(t[0]);let r=t.length/4*4,i=1;if(r>=4)for(;i<r-4;i+=4){let n=t[i],a=t[i+1],s=t[i+2],o=t[i+3];e[i]=et(n)+e[i-1],e[i+1]=et(a)+e[i],e[i+2]=et(s)+e[i+1],e[i+3]=et(o)+e[i+2]}for(;i!==t.length;++i)e[i]=et(t[i])+e[i-1];return e}function Jc(t){let e=new BigInt64Array(t.length);e[0]=Ot(t[0]);let r=t.length/4*4,i=1;if(r>=4)for(;i<r-4;i+=4){let n=t[i],a=t[i+1],s=t[i+2],o=t[i+3];e[i]=Ot(n)+e[i-1],e[i+1]=Ot(a)+e[i],e[i+2]=Ot(s)+e[i+1],e[i+3]=Ot(o)+e[i+2]}for(;i!==e.length;++i)e[i]=Ot(t[i])+e[i-1];return e}function s3(t){t[0]=Ge(t[0]);let e=t.length/4*4,r=1;if(e>=4)for(;r<e-4;r+=4){let i=t[r],n=t[r+1],a=t[r+2],s=t[r+3];t[r]=Ge(i)+t[r-1],t[r+1]=Ge(n)+t[r],t[r+2]=Ge(a)+t[r+1],t[r+3]=Ge(s)+t[r+2]}for(;r!==t.length;++r)t[r]=Ge(t[r])+t[r-1]}function o3(t,e,r){if(r===void 0){r=0;for(let a=0;a<e;a++)r+=t[a]}let i=new Int32Array(r),n=0;for(let a=0;a<e;a++){let s=t[a],o=t[a+e];o=et(o),i.fill(o,n,n+s),n+=s}return i}function l3(t,e,r){if(r===void 0){r=0;for(let a=0;a<e;a++)r+=Number(t[a])}let i=new BigInt64Array(r),n=0;for(let a=0;a<e;a++){let s=Number(t[a]),o=t[a+e];o=Ot(o),i.fill(o,n,n+s),n+=s}return i}function u3(t,e,r){let i=new Float64Array(r),n=0;for(let a=0;a<e;a++){let s=t[a],o=t[a+e];o=Ge(o),i.fill(o,n,n+s),n+=s}return i}function mu(t){let e=t.length/4*4,r=1;if(e>=4)for(let i=t[0];r<e-4;r+=4)i=t[r]+=i,i=t[r+1]+=i,i=t[r+2]+=i,i=t[r+3]+=i;for(;r!==t.length;)t[r]+=t[r-1],++r}function h3(t){let e=0;for(let r=0;r<t.length;r++)t[r]+=e,e=t[r]}function c3(t){if(t.length<2)return new Int32Array(t);let e=new Int32Array(t.length);e[0]=et(t[0]),e[1]=et(t[1]);let r=t.length/4*4,i=2;if(r>=4)for(;i<r-4;i+=4){let n=t[i],a=t[i+1],s=t[i+2],o=t[i+3];e[i]=et(n)+e[i-2],e[i+1]=et(a)+e[i-1],e[i+2]=et(s)+e[i],e[i+3]=et(o)+e[i+1]}for(;i!==t.length;i+=2)e[i]=et(t[i])+e[i-2],e[i+1]=et(t[i+1])+e[i-1];return e}function Ey(t,e,r,i){if(t.length<2)return new Int32Array(t);let n=new Int32Array(t.length),a=et(t[0]),s=et(t[1]);n[0]=qe(Math.round(a*e),r,i),n[1]=qe(Math.round(s*e),r,i);let o=t.length/16,l=2;if(o>=4)for(;l<o-4;l+=4){let u=t[l],h=t[l+1],c=et(u)+a,p=et(h)+s;n[l]=qe(Math.round(c*e),r,i),n[l+1]=qe(Math.round(p*e),r,i);let f=t[l+2],d=t[l+3];a=et(f)+c,s=et(d)+p,n[l+2]=qe(Math.round(a*e),r,i),n[l+3]=qe(Math.round(s*e),r,i)}for(;l!==t.length;l+=2)a+=et(t[l]),s+=et(t[l+1]),n[l]=qe(Math.round(a*e),r,i),n[l+1]=qe(Math.round(s*e),r,i);return n}function qe(t,e,r){return Math.min(r,Math.max(e,t))}function p3(t){let e=new Int32Array(t.length+1);e[0]=0,e[1]=et(t[0]);let r=e[1];for(let i=2;i!==e.length;++i){let n=t[i-1],a=et(n);r+=a,e[i]=e[i-1]+r}return new Uint32Array(e)}function f3(t,e,r){let i=new Int32Array(r+1);i[0]=0;let n=1,a=i[0];for(let s=0;s<e;s++){let o=t[s],l=t[s+e];l=et(l);for(let u=n;u<n+o;u++)i[u]=l+a,a=i[u];n+=o}return i}function d3(t,e,r){let i=new Uint32Array(r+1);i[0]=0;let n=1,a=i[0];for(let s=0;s<e;s++){let o=t[s],l=t[s+e];for(let u=n;u<n+o;u++)i[u]=l+a,a=i[u];n+=o}return i}function y3(t,e,r){let i=new Int32Array(r),n=0,a=0;for(let s=0;s<e;s++){let o=t[s],l=t[s+e],u=et(l);for(let h=0;h<o;h++)a+=u,i[n++]=a}return i}function m3(t,e,r){let i=new BigInt64Array(r),n=0,a=0n;for(let s=0;s<e;s++){let o=Number(t[s]),l=t[s+e],u=Ot(l);for(let h=0;h<o;h++)a+=u,i[n++]=a}return i}function Qc(t){let e=new Uint32Array(t.length);e[0]=et(t[0])>>>0;for(let r=1;r<t.length;r++)e[r]=e[r-1]+et(t[r])>>>0;return e}function tp(t){let e=new BigUint64Array(t.length);e[0]=BigInt.asUintN(64,Ot(t[0]));for(let r=1;r<t.length;r++)e[r]=BigInt.asUintN(64,e[r-1]+Ot(t[r]));return e}function g3(t){if(t.length<2)return new Uint32Array(t);let e=new Uint32Array(t.length);e[0]=et(t[0])>>>0,e[1]=et(t[1])>>>0;for(let r=2;r<t.length;r+=2)e[r]=e[r-2]+et(t[r])>>>0,e[r+1]=e[r-1]+et(t[r+1])>>>0;return e}function x3(t,e,r,i){let n=Ey(t,e,r,i);return new Uint32Array(n)}function v3(t){return t[1]}function b3(t){return et(t[1])}function w3(t){if(t.length===2){let e=et(t[1]);return[e,e]}return[et(t[2]),et(t[3])]}function D3(t){return t[1]}function _3(t){return Ot(t[1])}function A3(t){if(t.length===2){let e=Ot(t[1]);return[e,e]}return[Ot(t[2]),Ot(t[3])]}var _t;(function(t){t.PRESENT="PRESENT",t.DATA="DATA",t.OFFSET="OFFSET",t.LENGTH="LENGTH"})(_t||(_t={}));var Ut;(function(t){t.NONE="NONE",t.SINGLE="SINGLE",t.SHARED="SHARED",t.VERTEX="VERTEX",t.MORTON="MORTON",t.FSST="FSST"})(Ut||(Ut={}));var xe;(function(t){t.VERTEX="VERTEX",t.INDEX="INDEX",t.STRING="STRING",t.KEY="KEY"})(xe||(xe={}));var Et;(function(t){t.VAR_BINARY="VAR_BINARY",t.GEOMETRIES="GEOMETRIES",t.PARTS="PARTS",t.RINGS="RINGS",t.TRIANGLES="TRIANGLES",t.SYMBOL="SYMBOL",t.DICTIONARY="DICTIONARY"})(Et||(Et={}));var S3=[_t.PRESENT,_t.DATA,_t.OFFSET,_t.LENGTH],ep=[W.NONE,W.DELTA,W.COMPONENTWISE_DELTA,W.RLE,W.MORTON],E3=[Qt.NONE,Qt.FAST_PFOR,Qt.VARINT],F3=[Ut.NONE,Ut.SINGLE,Ut.SHARED,Ut.VERTEX,Ut.MORTON,Ut.FSST],T3=[xe.VERTEX,xe.INDEX,xe.STRING,xe.KEY],k3=[Et.VAR_BINARY,Et.GEOMETRIES,Et.PARTS,Et.RINGS,Et.TRIANGLES,Et.SYMBOL,Et.DICTIONARY];function ht(t,e){let r=M3(t,e);return r.logicalLevelTechnique1===W.MORTON?I3(r,t,e):(W.RLE===r.logicalLevelTechnique1||W.RLE===r.logicalLevelTechnique2)&&Qt.NONE!==r.physicalLevelTechnique?C3(r,t,e):r}function I3(t,e,r){let i=Rt(e,r,2);return{physicalStreamType:t.physicalStreamType,logicalStreamType:t.logicalStreamType,logicalLevelTechnique1:t.logicalLevelTechnique1,logicalLevelTechnique2:t.logicalLevelTechnique2,physicalLevelTechnique:t.physicalLevelTechnique,numValues:t.numValues,byteLength:t.byteLength,decompressedCount:t.decompressedCount,numBits:i[0],coordinateShift:i[1]}}function C3(t,e,r){let i=Rt(e,r,2);return{physicalStreamType:t.physicalStreamType,logicalStreamType:t.logicalStreamType,logicalLevelTechnique1:t.logicalLevelTechnique1,logicalLevelTechnique2:t.logicalLevelTechnique2,physicalLevelTechnique:t.physicalLevelTechnique,numValues:t.numValues,byteLength:t.byteLength,decompressedCount:i[1],runs:i[0],numRleValues:i[1]}}function M3(t,e){let r=t[e.get()],i=S3[r>>4],n={};switch(i){case _t.DATA:n={dictionaryType:F3[r&15]};break;case _t.OFFSET:n={offsetType:T3[r&15]};break;case _t.LENGTH:n={lengthType:k3[r&15]}}e.increment();let a=t[e.get()],s=ep[a>>5],o=ep[a>>2&7],l=E3[a&3];e.increment();let u=Rt(t,e,2),h=u[0],c=u[1];return{physicalStreamType:i,logicalStreamType:n,logicalLevelTechnique1:s,logicalLevelTechnique2:o,physicalLevelTechnique:l,numValues:h,byteLength:c,decompressedCount:h}}var lt;(function(t){t[t.FLAT=0]="FLAT",t[t.CONST=1]="CONST",t[t.SEQUENCE=2]="SEQUENCE",t[t.DICTIONARY=3]="DICTIONARY",t[t.FSST_DICTIONARY=4]="FSST_DICTIONARY"})(lt||(lt={}));var ce=class{constructor(t,e){this.values=t,this._size=e}get(t){let e=Math.floor(t/8),r=t%8;return(this.values[e]>>r&1)==1}set(t,e){let r=Math.floor(t/8),i=t%8;this.values[r]=this.values[r]|+!!e<<i}getInt(t){let e=Math.floor(t/8),r=t%8;return this.values[e]>>r&1}size(){return this._size}getBuffer(){return this.values}};function Ar(t,e,r){if(!e)return t;let i=e.size(),n=t.constructor,a=new n(i),s=0;for(let o=0;o<i;o++)a[o]=e.get(o)?t[s++]:r;return a}function B3(t,e,r){if(!r)return t;let i=r.size(),n=new ce(t,e),a=new ce(new Uint8Array(Math.ceil(i/8)),i),s=0;for(let o=0;o<i;o++){let l=r.get(o)?n.get(s++):!1;a.set(o,l)}return a.getBuffer()}function Fy(t,e,r){for(let i=0;i<t;i++){let n=ht(e,r);r.add(n.byteLength)}}function ui(t,e,r,i,n){let a=P3(t,Math.ceil(e/8),r,i);return n?B3(a,e,n):a}function P3(t,e,r,i){let n=new Uint8Array(e),a=0,s=i.get()+r;for(;a<e&&!(i.get()>=s);){let o=t[i.increment()];if(o<=127){let l=o+3,u=t[i.increment()],h=Math.min(a+l,e);n.fill(u,a,h),a=h}else{let l=256-o;for(let u=0;u<l&&a<e;u++)n[a++]=t[i.increment()]}}return i.set(s),n}function Ty(t,e,r,i){let n=e.get(),a=n+r*Float32Array.BYTES_PER_ELEMENT,s=new Uint8Array(t.subarray(n,a)).buffer,o=new Float32Array(s);return e.set(a),i?Ar(o,i,0):o}function ky(t,e,r,i){let n=e.get(),a=n+r*Float64Array.BYTES_PER_ELEMENT,s=new Uint8Array(t.subarray(n,a)).buffer,o=new Float64Array(s);return e.set(a),i?Ar(o,i,0):o}function z3(t,e,r){let i=e.get(),n=r*Uint32Array.BYTES_PER_ELEMENT,a=new DataView(t.buffer,t.byteOffset,t.byteLength),s=new Uint32Array(r);for(let o=0;o<r;o++)s[o]=a.getUint32(i+o*Uint32Array.BYTES_PER_ELEMENT,!0);return e.add(n),s}function L3(t,e,r){let i=e.get(),n=r*BigUint64Array.BYTES_PER_ELEMENT,a=new DataView(t.buffer,t.byteOffset,t.byteLength),s=new BigUint64Array(r);for(let o=0;o<r;o++)s[o]=a.getBigUint64(i+o*BigUint64Array.BYTES_PER_ELEMENT,!0);return e.add(n),s}var V3=new TextDecoder;function gu(t,e,r){return r-e>=12?V3.decode(t.subarray(e,r)):O3(t,e,r)}function O3(t,e,r){let i="",n=e;for(;n<r;){let a=t[n],s=null,o=a>239?4:a>223?3:a>191?2:1;if(n+o>r)break;let l,u,h;o===1?a<128&&(s=a):o===2?(l=t[n+1],(l&192)==128&&(s=(a&31)<<6|l&63,s<=127&&(s=null))):o===3?(l=t[n+1],u=t[n+2],(l&192)==128&&(u&192)==128&&(s=(a&15)<<12|(l&63)<<6|u&63,(s<=2047||s>=55296&&s<=57343)&&(s=null))):o===4&&(l=t[n+1],u=t[n+2],h=t[n+3],(l&192)==128&&(u&192)==128&&(h&192)==128&&(s=(a&15)<<18|(l&63)<<12|(u&63)<<6|h&63,(s<=65535||s>=1114112)&&(s=null))),s===null?(s=65533,o=1):s>65535&&(s-=65536,i+=String.fromCharCode(s>>>10&1023|55296),s=56320|s&1023),i+=String.fromCharCode(s),n+=o}return i}function _a(t,e,r,i,n){return q3(hi(t,e,r),r,i,n)}function Vt(t,e,r,i,n){return j3(hi(t,e,r),r,i,n)}function Ye(t,e,r){return Y3(hi(t,e,r),r)}function hi(t,e,r){let i=r.physicalLevelTechnique;switch(i){case Qt.FAST_PFOR:return e3(t,r.numValues,r.byteLength,e);case Qt.VARINT:return Rt(t,e,r.numValues);case Qt.NONE:return z3(t,e,r.numValues);default:throw Error(`Specified physicalLevelTechnique ${i} is not supported (yet).`)}}function bn(t,e,r){let i=r.physicalLevelTechnique;switch(i){case Qt.VARINT:return yu(t,e,r.numValues);case Qt.NONE:return L3(t,e,r.numValues);default:throw Error(`Specified physicalLevelTechnique ${i} is not supported (yet).`)}}function R3(t,e,r){let i=hi(t,e,r);return i.length===1?et(i[0]):b3(i)}function xu(t,e,r){let i=hi(t,e,r);return i.length===1?r.logicalLevelTechnique1===W.DELTA?et(i[0]):i[0]:v3(i)}function Iy(t,e,r){return w3(hi(t,e,r))}function Cy(t,e,r){return A3(yu(t,e,r.numValues))}function My(t,e,r,i){return Py(bn(t,e,r),r,i)}function vu(t,e,r,i){return zy(bn(t,e,r),r,i)}function $3(t,e,r,i){let n=N3(t,e,r,!1);return i?Ar(n,i,0):n}function N3(t,e,r,i){if(r.physicalLevelTechnique===Qt.VARINT)return G3(Jw(t,e,r.numValues),r,i);let n=bn(t,e,r),a=i?Py(n,r):zy(n,r);return Float64Array.from(a,Number)}function U3(t,e,r){let i=bn(t,e,r);return i.length===1?Ot(i[0]):_3(i)}function By(t,e,r){let i=bn(t,e,r);return i.length===1?r.logicalLevelTechnique1===W.DELTA?Ot(i[0]):i[0]:D3(i)}function q3(t,e,r,i){let n;switch(e.logicalLevelTechnique1){case W.DELTA:if(e.logicalLevelTechnique2===W.RLE){let a=e;if(!i)return y3(t,a.runs,a.numRleValues);t=ll(t,a.runs,a.numRleValues),n=Kc(t)}else n=Kc(t);break;case W.RLE:n=o3(t,e.runs,e.numRleValues);break;case W.MORTON:mu(t),n=new Int32Array(t);break;case W.COMPONENTWISE_DELTA:if(r&&!i)return Ey(t,r.scale,r.min,r.max);n=c3(t);break;case W.NONE:n=i3(t);break;default:throw Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}return i?Ar(n,i,0):n}function j3(t,e,r,i){let n;switch(e.logicalLevelTechnique1){case W.DELTA:if(e.logicalLevelTechnique2===W.RLE){let a=e;n=Qc(ll(t,a.runs,a.numRleValues))}else n=Qc(t);break;case W.RLE:n=ll(t,e.runs,e.numRleValues);break;case W.MORTON:mu(t),n=t;break;case W.COMPONENTWISE_DELTA:n=r&&!i?x3(t,r.scale,r.min,r.max):g3(t);break;case W.NONE:n=t;break;default:throw Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}return i?Ar(n,i,0):n}function Py(t,e,r){let i;switch(e.logicalLevelTechnique1){case W.DELTA:if(e.logicalLevelTechnique2===W.RLE){let n=e;if(!r)return m3(t,n.runs,n.numRleValues);t=ul(t,n.runs,n.numRleValues),i=Jc(t)}else i=Jc(t);break;case W.RLE:i=l3(t,e.runs,e.numRleValues);break;case W.NONE:i=n3(t);break;default:throw Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}return r?Ar(i,r,0n):i}function zy(t,e,r){let i;switch(e.logicalLevelTechnique1){case W.DELTA:if(e.logicalLevelTechnique2===W.RLE){let n=e;i=tp(ul(t,n.runs,n.numRleValues))}else i=tp(t);break;case W.RLE:i=ul(t,e.runs,e.numRleValues);break;case W.NONE:i=t;break;default:throw Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}return r?Ar(i,r,0n):i}function G3(t,e,r){switch(e.logicalLevelTechnique1){case W.DELTA:if(e.logicalLevelTechnique2===W.RLE){let i=e;t=Sy(t,i.runs,i.numRleValues)}return s3(t),t;case W.RLE:return W3(t,e,r);case W.NONE:return r&&a3(t),t;default:throw Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}}function Y3(t,e){if(e.logicalLevelTechnique1===W.DELTA&&e.logicalLevelTechnique2===W.NONE)return p3(t);if(e.logicalLevelTechnique1===W.RLE&&e.logicalLevelTechnique2===W.NONE){let r=e;return d3(t,r.runs,r.numRleValues)}if(e.logicalLevelTechnique1===W.NONE&&e.logicalLevelTechnique2===W.NONE){h3(t);let r=new Uint32Array(e.numValues+1);return r[0]=0,r.set(t,1),r}if(e.logicalLevelTechnique1===W.DELTA&&e.logicalLevelTechnique2===W.RLE){let r=e,i=f3(t,r.runs,r.numRleValues);return mu(i),new Uint32Array(i)}throw Error("Only delta encoding is supported for transforming length to offset streams yet.")}function Za(t,e,r,i,n="int32"){let a=t.logicalLevelTechnique1;if(a===W.RLE)return t.runs===1?lt.CONST:lt.FLAT;if(a!==W.DELTA||t.logicalLevelTechnique2!==W.RLE)return t.numValues===1?lt.CONST:lt.FLAT;let s=e instanceof ce?e.size():e,o=t;if(o.numRleValues!==s)return lt.FLAT;if(o.runs===1)return lt.SEQUENCE;if(o.runs!==2)return t.numValues===1?lt.CONST:lt.FLAT;let l=i.get();if(t.physicalLevelTechnique===Qt.VARINT)return X3(r,i,n)?lt.SEQUENCE:t.numValues===1?lt.CONST:lt.FLAT;let u=i.get(),h=new Int32Array(r.buffer,r.byteOffset+u,4);return i.set(l),h[2]===2&&h[3]===2?lt.SEQUENCE:t.numValues===1?lt.CONST:lt.FLAT}function X3(t,e,r){let i=new Dy(e.get());if(r==="int64"){let a=yu(t,i,4);return a[2]===2n&&a[3]===2n}let n=Rt(t,i,4);return n[2]===2&&n[3]===2}function W3(t,e,r){return r?u3(t,e.runs,e.numRleValues):Sy(t,e.runs,e.numRleValues)}var Ly=class extends Wa{getValueFromBuffer(t){return this.dataBuffer[t]}},Vy=class extends by{constructor(t,e,r,i,n){super(t,n?BigInt64Array.of(e):BigUint64Array.of(e),r,i)}getValueFromBuffer(t){return this.dataBuffer[0]+BigInt(t)*this.delta}};function bu(t,e,r){return{x:rp(t,e)-r,y:rp(t>>1,e)-r}}function rp(t,e){let r=0;for(let i=0;i<e;i++)r|=(t&1<<2*i)>>i;return r}var Pt;(function(t){t[t.POINT=0]="POINT",t[t.LINESTRING=1]="LINESTRING",t[t.POLYGON=2]="POLYGON",t[t.MULTIPOINT=3]="MULTIPOINT",t[t.MULTILINESTRING=4]="MULTILINESTRING",t[t.MULTIPOLYGON=5]="MULTIPOLYGON"})(Pt||(Pt={}));var ip;(function(t){t[t.POINT=0]="POINT",t[t.LINESTRING=1]="LINESTRING",t[t.POLYGON=2]="POLYGON"})(ip||(ip={}));var Qe;(function(t){t[t.MORTON=0]="MORTON",t[t.VEC_2=1]="VEC_2",t[t.VEC_3=2]="VEC_3"})(Qe||(Qe={}));function Z3(t){let e=Array(t.numGeometries),r=1,i=1,n=1,a=0,s=0,o=0,l=t.mortonSettings,u=t.topologyVector,h=u.geometryOffsets,c=u.partOffsets,p=u.ringOffsets,f=t.vertexOffsets,d=!f||f.length===0,y=t.containsPolygonGeometry(),m=t.vertexBuffer;for(let g=0;g<t.numGeometries;g++){let x=t.geometryType(g);switch(x){case Pt.POINT:{let b,v;if(d)b=m[s++],v=m[s++];else if(t.vertexBufferType===Qe.MORTON){let w=m[f[o++]],_=bu(w,l.numBits,l.coordinateShift);b=_.x,v=_.y}else{let w=f[o++]*2;b=m[w],v=m[w+1]}e[a++]=[[new B(b,v)]],h&&n++,c&&r++,p&&i++}break;case Pt.MULTIPOINT:{let b=h[n]-h[n-1];n++;let v;if(d){v=Array(b);for(let w=0;w<b;w++){let _=m[s++],A=m[s++];v[w]=new B(_,A)}}else v=or(t.vertexBufferType,m,f,o,b,!1,l),o+=b;e[a++]=v.map(w=>[w]),r+=b,i+=b}break;case Pt.LINESTRING:{let b;y?(b=p[i]-p[i-1],i++):b=c[r]-c[r-1],r++;let v;d?(v=Lr(m,s,b,!1),s+=b*2):(v=or(t.vertexBufferType,m,f,o,b,!1,l),o+=b),e[a++]=[v],h&&n++}break;case Pt.POLYGON:{let b=c[r]-c[r-1];r++;let v=Array(b-1),w,_=p[i]-p[i-1];if(i++,d){w=Lr(m,s,_,!0),s+=_*2;for(let A=0;A<v.length;A++)_=p[i]-p[i-1],i++,v[A]=Lr(m,s,_,!0),s+=_*2}else{w=or(t.vertexBufferType,m,f,o,_,!0,l),o+=_;for(let A=0;A<v.length;A++)_=p[i]-p[i-1],i++,v[A]=or(t.vertexBufferType,m,f,o,_,!0,l),o+=_}e[a++]=[w].concat(v),h&&n++}break;case Pt.MULTILINESTRING:{let b=h[n]-h[n-1];n++;let v=Array(b);for(let w=0;w<b;w++){let _;if(y?(_=p[i]-p[i-1],i++):_=c[r]-c[r-1],r++,d)v[w]=Lr(m,s,_,!1),s+=_*2;else{let A=or(t.vertexBufferType,m,f,o,_,!1,l);v[w]=A,o+=_}}e[a++]=v}break;case Pt.MULTIPOLYGON:{let b=h[n]-h[n-1];n++;let v=Array(b);for(let w=0;w<b;w++){let _=c[r]-c[r-1];r++;let A,S=Array(_-1),F=p[i]-p[i-1];i++,d?(A=Lr(m,s,F,!0),s+=F*2):(A=or(t.vertexBufferType,m,f,o,F,!0,l),o+=F);for(let L=0;L<S.length;L++){let V=p[i]-p[i-1];i++,d?(S[L]=Lr(m,s,V,!0),s+=V*2):(S[L]=or(t.vertexBufferType,m,f,o,V,!0,l),o+=V)}v[w]=[A].concat(S)}e[a++]=v.flat()}break;default:throw Error(`The specified geometry type (${x}) is currently not supported.`)}}return e}function or(t,e,r,i,n,a,s){return t===Qe.MORTON?K3(e,r,i,n,a,s):H3(e,r,i,n,a)}function Lr(t,e,r,i){let n=Array(i?r+1:r);for(let a=0;a<r*2;a+=2){let s=t[e+a],o=t[e+a+1];n[a/2]=new B(s,o)}return i&&(n[n.length-1]=n[0]),n}function H3(t,e,r,i,n){let a=Array(n?i+1:i);for(let s=0;s<i*2;s+=2){let o=e[r+s/2]*2,l=t[o],u=t[o+1];a[s/2]=new B(l,u)}return n&&(a[a.length-1]=a[0]),a}function K3(t,e,r,i,n,a){let s=Array(n?i+1:i);for(let o=0;o<i;o++){let l=t[e[r+o]],u=bu(l,a.numBits,a.coordinateShift);s[o]=new B(u.x,u.y)}return n&&(s[s.length-1]=s[0]),s}var Oy=class{constructor(t,e,r,i,n){this._vertexBufferType=t,this._topologyVector=e,this._vertexOffsets=r,this._vertexBuffer=i,this._mortonSettings=n}get vertexBufferType(){return this._vertexBufferType}get topologyVector(){return this._topologyVector}get vertexOffsets(){return this._vertexOffsets}get vertexBuffer(){return this._vertexBuffer}getSimpleEncodedVertex(t){let e=this.vertexOffsets?this.vertexOffsets[t]*2:t*2;return[this.vertexBuffer[e],this.vertexBuffer[e+1]]}getVertex(t){if(this.vertexOffsets&&this.mortonSettings){let r=this.vertexOffsets[t],i=this.vertexBuffer[r],n=bu(i,this.mortonSettings.numBits,this.mortonSettings.coordinateShift);return[n.x,n.y]}let e=this.vertexOffsets?this.vertexOffsets[t]*2:t*2;return[this.vertexBuffer[e],this.vertexBuffer[e+1]]}getGeometries(){return Z3(this)}get mortonSettings(){return this._mortonSettings}};function J3(t,e,r,i,n){return new Ry(t,e,Qe.VEC_2,r,i,n)}function Q3(t,e,r,i,n,a){return new Ry(t,e,Qe.MORTON,r,i,n,a)}var Ry=class extends Oy{constructor(t,e,r,i,n,a,s){super(r,i,n,a,s),this._numGeometries=t,this._geometryType=e}geometryType(t){return this._geometryType}get numGeometries(){return this._numGeometries}containsPolygonGeometry(){return this._geometryType===Pt.POLYGON||this._geometryType===Pt.MULTIPOLYGON}containsSingleGeometryType(){return!0}};function $y(t,e,r,i){return new Ny(Qe.VEC_2,t,e,r,i)}function t6(t,e,r,i,n){return new Ny(Qe.MORTON,t,e,r,i,n)}var Ny=class extends Oy{constructor(t,e,r,i,n,a){super(t,r,i,n,a),this._geometryTypes=e}geometryType(t){return this._geometryTypes[t]}get numGeometries(){return this._geometryTypes.length}containsPolygonGeometry(){for(let t=0;t<this.numGeometries;t++)if(this.geometryType(t)===Pt.POLYGON||this.geometryType(t)===Pt.MULTIPOLYGON)return!0;return!1}containsSingleGeometryType(){return!1}},Uy=class{constructor(t,e,r,i){this._triangleOffsets=t,this._indexBuffer=e,this._vertexBuffer=r,this._topologyVector=i}get triangleOffsets(){return this._triangleOffsets}get indexBuffer(){return this._indexBuffer}get vertexBuffer(){return this._vertexBuffer}get topologyVector(){return this._topologyVector}getGeometries(){if(!this._topologyVector)throw Error("Cannot convert GpuVector to coordinates without topology information");let t=new Uint32Array(this.numGeometries);for(let e=0;e<this.numGeometries;e++)t[e]=this.geometryType(e);return $y(t,this._topologyVector,void 0,this._vertexBuffer).getGeometries()}[Symbol.iterator](){return null}};function np(t,e,r,i,n,a){return new e6(t,e,r,i,n,a)}var e6=class extends Uy{constructor(t,e,r,i,n,a){super(r,i,n,a),this._numGeometries=t,this._geometryType=e}geometryType(t){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}};function ap(t,e,r,i,n){return new r6(t,e,r,i,n)}var r6=class extends Uy{constructor(t,e,r,i,n){super(e,r,i,n),this._geometryTypes=t}geometryType(t){return this._geometryTypes[t]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}};function i6(t,e,r,i,n){let a=ht(t,r),s=Za(a,i,t,r),o,l,u,h;if(s===lt.CONST){let b=xu(t,r,a),v,w,_,A;for(let S=0;S<e-1;S++){let F=ht(t,r);switch(F.physicalStreamType){case _t.LENGTH:switch(F.logicalStreamType.lengthType){case Et.GEOMETRIES:v=Ye(t,r,F);break;case Et.PARTS:w=Ye(t,r,F);break;case Et.RINGS:_=Ye(t,r,F);break;case Et.TRIANGLES:A=Ye(t,r,F)}break;case _t.OFFSET:switch(F.logicalStreamType.offsetType){case xe.VERTEX:o=Vt(t,r,F);break;case xe.INDEX:h=Vt(t,r,F)}break;case _t.DATA:if(Ut.VERTEX===F.logicalStreamType.dictionaryType)l=_a(t,r,F,n);else{let L=F;u={numBits:L.numBits,coordinateShift:L.coordinateShift},l=Vt(t,r,F,n)}}}return h?v!==void 0||w!==void 0?np(i,b,A,h,l,{geometryOffsets:v,partOffsets:w,ringOffsets:_}):np(i,b,A,h,l):u===void 0?J3(i,b,{geometryOffsets:v,partOffsets:w,ringOffsets:_},o,l):Q3(i,b,{geometryOffsets:v,partOffsets:w,ringOffsets:_},o,l,u)}let c=Vt(t,r,a),p,f,d,y;for(let b=0;b<e-1;b++){let v=ht(t,r);switch(v.physicalStreamType){case _t.LENGTH:switch(v.logicalStreamType.lengthType){case Et.GEOMETRIES:p=Vt(t,r,v);break;case Et.PARTS:f=Vt(t,r,v);break;case Et.RINGS:d=Vt(t,r,v);break;case Et.TRIANGLES:y=Ye(t,r,v)}break;case _t.OFFSET:switch(v.logicalStreamType.offsetType){case xe.VERTEX:o=Vt(t,r,v);break;case xe.INDEX:h=Vt(t,r,v)}break;case _t.DATA:if(Ut.VERTEX===v.logicalStreamType.dictionaryType)l=_a(t,r,v,n);else{let w=v;u={numBits:w.numBits,coordinateShift:w.coordinateShift},l=Vt(t,r,v,n)}}}let m,g,x;return p?(m=Xs(c,p,2),f&&d?(g=sp(c,m,f,!1),x=a6(c,m,g,d)):f&&(g=n6(c,m,f))):f&&d?(g=Xs(c,f,1),x=sp(c,g,d,!0)):f&&(g=Xs(c,f,0)),h&&!g?ap(c,y,h,l):h?ap(c,y,h,l,{geometryOffsets:m,partOffsets:g,ringOffsets:x}):u===void 0?$y(c,{geometryOffsets:m,partOffsets:g,ringOffsets:x},o,l):t6(c,{geometryOffsets:m,partOffsets:g,ringOffsets:x},o,l,u)}function Xs(t,e,r){let i=new Uint32Array(t.length+1),n=0;i[0]=n;let a=0;for(let s=0;s<t.length;s++)n=i[s+1]=n+(t[s]>r?e[a++]:1);return i}function sp(t,e,r,i){let n=new Uint32Array(e[e.length-1]+1),a=0;n[0]=a;let s=1,o=0;for(let l=0;l<t.length;l++){let u=t[l],h=e[l+1]-e[l];if(u===5||u===2||i&&(u===4||u===1))for(let c=0;c<h;c++)a=n[s++]=a+r[o++];else for(let c=0;c<h;c++)n[s++]=++a}return n}function n6(t,e,r){let i=new Uint32Array(e[e.length-1]+1),n=0;i[0]=n;let a=1,s=0;for(let o=0;o<t.length;o++){let l=t[o],u=e[o+1]-e[o];if(l===4||l===1)for(let h=0;h<u;h++)n=i[a++]=n+r[s++];else for(let h=0;h<u;h++)i[a++]=++n}return i}function a6(t,e,r,i){let n=new Uint32Array(r[r.length-1]+1),a=0;n[0]=a;let s=1,o=1,l=0;for(let u=0;u<t.length;u++){let h=t[u],c=e[u+1]-e[u];if(h!==0&&h!==3)for(let p=0;p<c;p++){let f=r[s]-r[s-1];s++;for(let d=0;d<f;d++)a=n[o++]=a+i[l++]}else for(let p=0;p<c;p++)n[o++]=++a,s++}return n}var s6=class extends _r{constructor(t,e,r){super(t,e.getBuffer(),r),this.dataVector=e}getValueFromBuffer(t){return this.dataVector.get(t)}},o6=class extends Wa{getValueFromBuffer(t){return this.dataBuffer[t]}},qy=class extends _r{constructor(t,e,r,i){super(t,i?BigInt64Array.of(e):BigUint64Array.of(e),r)}getValueFromBuffer(t){return this.dataBuffer[0]}},wu=class extends _r{constructor(t,e,r,i){super(t,r,i),this.offsetBuffer=e}},op=class extends wu{constructor(t,e,r,i){super(t,e,r,i??e.length-1)}getValueFromBuffer(t){let e=this.offsetBuffer[t],r=this.offsetBuffer[t+1];return gu(this.dataBuffer,e,r)}},Kr=class extends wu{constructor(t,e,r,i,n){super(t,r,i,n??e.length),this.indexBuffer=e,this.indexBuffer=e}getValueFromBuffer(t){let e=this.indexBuffer[t],r=this.offsetBuffer[e],i=this.offsetBuffer[e+1];return gu(this.dataBuffer,r,i)}};function l6(t,e){let r=0;for(let i=0;i<e.length;i++){let n=e[i];n===255?(r++,i++):r+=t[n]}return r}function u6(t,e,r){let i=new Uint32Array(e.length);for(let s=1;s<e.length;s++)i[s]=i[s-1]+e[s-1];let n=new Uint8Array(l6(e,r)),a=0;for(let s=0;s<r.length;s++){let o=r[s];if(o===255)s++,n[a++]=r[s];else{let l=e[o],u=i[o];for(;l-- >0;)n[a++]=t[u++]}}return n}var jy=class extends wu{constructor(t,e,r,i,n,a,s,o){super(t,r,i,s??e.length),this.indexBuffer=e,this.symbolOffsetBuffer=n,this.symbolTableBuffer=a,this.sharedDictionaryCache=o}getValueFromBuffer(t){this.decodedDictionary??(this.decodedDictionary=this.sharedDictionaryCache?.decodedDictionary,this.decodedDictionary??(this.decodedDictionary=this.decodeDictionary(),this.sharedDictionaryCache&&(this.sharedDictionaryCache.decodedDictionary=this.decodedDictionary)));let e=this.indexBuffer[t],r=this.offsetBuffer[e],i=this.offsetBuffer[e+1];return gu(this.decodedDictionary,r,i)}decodeDictionary(){return this.symbolLengthBuffer??(this.symbolLengthBuffer=this.offsetToLengthBuffer(this.symbolOffsetBuffer)),u6(this.symbolTableBuffer,this.symbolLengthBuffer,this.dataBuffer)}offsetToLengthBuffer(t){let e=new Uint32Array(t.length-1),r=t[0];for(let i=1;i<t.length;i++){let n=t[i];e[i-1]=n-r,r=n}return e}};function Gy(t,e,r,i,n){let a,s,o,l,u,h=n,c,p;for(let f=0;f<i;f++){let d=ht(e,r);switch(d.physicalStreamType){case _t.PRESENT:{let y=new ce(ui(e,d.numValues,d.byteLength,r),d.numValues);h=n??y;break}case _t.OFFSET:s=Vt(e,r,d,void 0,h);break;case _t.LENGTH:{let y=Ye(e,r,d);Et.DICTIONARY===d.logicalStreamType.lengthType?a=y:Et.SYMBOL===d.logicalStreamType.lengthType?l=y:c=y;break}case _t.DATA:{let y=e.subarray(r.get(),r.get()+d.byteLength);r.add(d.byteLength);let m=d.logicalStreamType.dictionaryType;Ut.FSST===m?u=y:Ut.SINGLE===m||Ut.SHARED===m?o=y:Ut.NONE===m&&(p=y);break}}}return h6(t,u,s,a,o,l,h)??c6(t,o,s,a,h)??p6(t,c,p,s,h)}function h6(t,e,r,i,n,a,s){if(e){if(!r||!i||!n||!a)throw Error(`Incomplete FSST dictionary string column "${t}"`);return new jy(t,r,i,n,a,e,s)}}function c6(t,e,r,i,n){if(e){if(!r||!i)throw Error(`Incomplete dictionary string column "${t}"`);return n?new Kr(t,r,i,e,n):new Kr(t,r,i,e)}}function p6(t,e,r,i,n){if(e&&r){if(i)return n?new Kr(t,i,e,r,n):new Kr(t,i,e,r);if(n&&n.size()!==e.length-1){let a=new Uint32Array(n.size()),s=0;for(let o=0;o<n.size();o++)n.get(o)?a[o]=s++:a[o]=0;return new Kr(t,a,e,r,n)}return n?new op(t,e,r,n):new op(t,e,r)}}function f6(t,e,r,i){let n,a,s,o,l=!1;for(;!l;){let f=ht(t,e);switch(f.physicalStreamType){case _t.LENGTH:Et.DICTIONARY===f.logicalStreamType.lengthType?n=Ye(t,e,f):s=Ye(t,e,f);break;case _t.DATA:Ut.SINGLE===f.logicalStreamType.dictionaryType||Ut.SHARED===f.logicalStreamType.dictionaryType?(a=t.subarray(e.get(),e.get()+f.byteLength),l=!0):o=t.subarray(e.get(),e.get()+f.byteLength),e.add(f.byteLength)}}if(r.type!=="complexType")throw Error(`Shared dictionary column ${r.name} must be a complex (struct) column.`);if(!n||!a)throw Error(`Incomplete shared dictionary for column "${r.name}"`);let u=r.complexType.children,h=[],c=o?{}:void 0,p=0;for(let f of u){let d=Rt(t,e,1)[0];if(d===0)continue;let y=f.name?`${r.name}${f.name}`:r.name;if(i&&!i.has(y)){Fy(d,t,e);continue}if(f.type!=="scalarField"||f.scalarField.physicalType!==rt.STRING)throw Error("Currently only scalar string fields are implemented for a struct.");if(d>1&&!f.nullable||d===1&&f.nullable)throw Error(`The number of streams for the child field ${f.name} does not match its nullability. nullibilty: ${f.nullable}, numStreams: ${d}`);let m;if(f.nullable){let x=ht(t,e);m=new ce(ui(t,x.numValues,x.byteLength,e),x.numValues)}let g=Vt(t,e,ht(t,e),void 0,m);if(o){if(!s)throw Error(`Incomplete shared FSST dictionary for column "${y}"`);h[p++]=new jy(y,g,n,a,s,o,m,c)}else h[p++]=new Kr(y,g,n,a,m)}return h}var lp=class extends _r{constructor(t,e,r){super(t,new Uint8Array,r??e.length),this.values=e}getValueFromBuffer(t){return this.values[t]}},ve;(function(t){t[t.STRING=1]="STRING",t[t.INT32=2]="INT32",t[t.UINT32=4]="UINT32",t[t.INT64=8]="INT64",t[t.UINT64=16]="UINT64",t[t.FLOAT=32]="FLOAT",t[t.DOUBLE=64]="DOUBLE",t[t.PRESENCE=128]="PRESENCE"})(ve||(ve={}));var Ze;(function(t){t[t.FALSE=0]="FALSE",t[t.TRUE=1]="TRUE",t[t.START_MAP=2]="START_MAP",t[t.START_LIST=3]="START_LIST",t[t.COUNT=4]="COUNT"})(Ze||(Ze={}));function d6(t,e,r,i){let n=y6(r);if(i===0)return n.map(h=>new lp(h,[]));let a=m6(t,e,i),s=(a.presentStream?a.presentCount:a.lengthStream.length)/n.length,o=[],l=0,u=0;for(let h=0;h<n.length;h++){let c=w6(a,h,s,l,u);o.push(new lp(n[h],c.value,c.nullabilityBuffer)),l=c.countsEnd,u=c.valuesEnd}return o}function y6(t){let e=t.type==="complexType"?t.complexType.children:void 0;return!e||e.length===0?[t.name]:e.map(r=>t.name+(r.name??""))}function m6(t,e,r){let i=t[e.get()];e.add(1);let n=Vt(t,e,ht(t,e)),a=r-1,s=[];i&ve.STRING&&(a-=g6(t,e,s)),a-=x6(t,e,i,s),a-=v6(t,e,i,s);let o,l=0;if(i&ve.PRESENCE){let h=b6(t,e);o=h.value,l=h.count,a--}let u=new Uint32Array;if(a>0&&(u=Vt(t,e,ht(t,e)),a--),a!==0)throw Error(`Unexpected number of remaining streams while decoding map column: ${a}`);return{lengthStream:n,dictionary:s,presentStream:o,presentCount:l,flattenedValues:u}}function g6(t,e,r){let i=t[e.get()];e.add(1);let n=Gy("",t,e,i);if(n)for(let a=0;a<n.size;a++)r.push(n.getValue(a));return i}function x6(t,e,r,i){let n=0;return r&ve.INT32?(jr(i,_a(t,e,ht(t,e))),n++):r&ve.INT64&&(jr(i,My(t,e,ht(t,e))),n++),r&ve.UINT32?(jr(i,Vt(t,e,ht(t,e))),n++):r&ve.UINT64&&(jr(i,vu(t,e,ht(t,e))),n++),n}function v6(t,e,r,i){let n=0;return r&ve.FLOAT&&(jr(i,Ty(t,e,ht(t,e).numValues)),n++),r&ve.DOUBLE&&(jr(i,ky(t,e,ht(t,e).numValues)),n++),n}function b6(t,e){let r=ht(t,e);if(r.physicalStreamType!==_t.PRESENT)throw Error(`Expected PRESENT stream for map column but found: ${r.physicalStreamType}`);let i=r.numValues,n=e.get(),a=new ce(ui(t,i,r.byteLength,e),i);return e.set(n+r.byteLength),{value:a,count:i}}function w6(t,e,r,i,n){let{lengthStream:a,flattenedValues:s,presentStream:o,dictionary:l}=t,u=e*r,h=r,c;if(o){c=new ce(new Uint8Array(Math.ceil(r/8)),r),h=0;for(let x=0;x<r;x++)o.get(u+x)&&(c.set(x,!0),h++)}let p=i+h;if(p>a.length)throw Error("Merged map counts underflow while decoding child streams");let f=Array(r),d=i,y=n;for(let x=0;x<r;x++){if(o&&!o.get(u+x)){f[x]=null;continue}let b=y+a[d++];if(b>s.length)throw Error("Map value stream underflow while decoding feature payload");let v=D6(s,y,b,l);f[x]=v.value,y=v.nextIndex}let m=0;for(let x=i;x<p;x++)m+=a[x];let g=n+m;if(y!==g)throw Error("Unused flattened map values remain after decode");return{value:f,nullabilityBuffer:c,countsEnd:p,valuesEnd:g}}function D6(t,e,r,i){return r-e===1||t[e]===Ze.START_LIST?Du(t,e,r,i):Yy(t,e,r,i)}function Yy(t,e,r,i){let n=Object.create(null),a=e;for(;a<r;){let s=Xy(t[a++],i);if(typeof s!="string")throw Error(`Map key dictionary index does not resolve to a string: ${s}`);let o=Du(t,a,r,i);n[s]=o.value,a=o.nextIndex}return{value:n,nextIndex:a}}function Du(t,e,r,i){if(e>=r)throw Error("Unexpected end of map value stream");let n=t[e];if(n===Ze.FALSE)return{value:!1,nextIndex:e+1};if(n===Ze.TRUE)return{value:!0,nextIndex:e+1};if(n===Ze.START_MAP){let a=up(t,e,r);return{value:Yy(t,e+2,a,i).value,nextIndex:a}}if(n===Ze.START_LIST){let a=up(t,e,r),s=[],o=e+2;for(;o<a;){let l=Du(t,o,a,i);s.push(l.value),o=l.nextIndex}return{value:s,nextIndex:a}}return{value:Xy(n,i),nextIndex:e+1}}function up(t,e,r){if(e+1>=r)throw Error("Missing length for nested map/list payload");let i=t[e+1];if(i<2)throw Error(`Invalid nested payload length: ${i}`);let n=e+i;if(n>r)throw Error("Nested payload exceeds containing payload bounds");return n}function Xy(t,e){let r=t-Ze.COUNT;if(r<0||r>=e.length)throw Error(`Scalar dictionary index out of range: ${t}`);return e[r]}function jr(t,e){for(let r of e)t.push(r)}function _6(t,e,r,i,n,a){return r.type==="scalarType"?a&&!a.has(r.name)?(Fy(i,t,e),null):A6(i,t,e,n,r.scalarType,r):r.complexType?.physicalType===Ke.MAP?d6(t,e,r,i):i===0?null:f6(t,e,r,a)}function A6(t,e,r,i,n,a){let s;if(t===0)return null;if(a.nullable){let l=ht(e,r),u=l.numValues,h=r.get(),c=ui(e,u,l.byteLength,r);r.set(h+l.byteLength),s=new ce(c,l.numValues)}let o=s??i;switch(n.physicalType){case rt.UINT_32:case rt.INT_32:return k6(e,r,a,n,o);case rt.STRING:{let l=a.nullable?t-1:t;return Gy(a.name,e,r,l,s)??null}case rt.BOOLEAN:return S6(e,r,a,i,o);case rt.UINT_64:case rt.INT_64:return T6(e,r,a,o,n);case rt.FLOAT:return E6(e,r,a,o);case rt.DOUBLE:return F6(e,r,a,o);default:throw Error(`The specified data type for the field is currently not supported: ${n}`)}}function S6(t,e,r,i,n){let a=ht(t,e),s=a.numValues,o=e.get(),l=wn(n)?n:void 0,u=ui(t,s,a.byteLength,e,l);e.set(o+a.byteLength);let h=new ce(u,s);return new s6(r.name,h,n)}function E6(t,e,r,i){let n=ht(t,e),a=wn(i)?i:void 0,s=Ty(t,e,n.numValues,a);return new o6(r.name,s,i)}function F6(t,e,r,i){let n=ht(t,e),a=wn(i)?i:void 0,s=ky(t,e,n.numValues,a);return new hu(r.name,s,i)}function T6(t,e,r,i,n){let a=ht(t,e),s=Za(a,i,t,e,"int64"),o=n.physicalType===rt.INT_64;if(s===lt.FLAT){let u=wn(i)?i:void 0,h=o?My(t,e,a,u):vu(t,e,a,u);return new Ly(r.name,h,i)}if(s===lt.SEQUENCE){let u=Cy(t,e,a);return new Vy(r.name,u[0],u[1],a.numRleValues,o)}let l=o?U3(t,e,a):By(t,e,a);return new qy(r.name,l,i,o)}function k6(t,e,r,i,n){let a=ht(t,e),s=Za(a,n,t,e),o=i.physicalType===rt.INT_32;if(s===lt.FLAT){let u=wn(n)?n:void 0,h=o?_a(t,e,a,void 0,u):Vt(t,e,a,void 0,u);return new uu(r.name,h,n)}if(s===lt.SEQUENCE){let u=Iy(t,e,a);return new cu(r.name,u[0],u[1],a.numRleValues,o)}let l=o?R3(t,e,a):xu(t,e,a);return new pu(r.name,l,n,o)}function wn(t){return t instanceof ce}var It={ID:0,ID_NULLABLE:1,ID_LONG:2,GEOMETRY:4,SCALAR_BASE:10,STRUCT:30,MAP:31};function Wy(t){switch(t){case It.ID:case It.ID|It.ID_NULLABLE:case It.ID|It.ID_LONG:case It.ID|It.ID_LONG|It.ID_NULLABLE:return{nullable:(t&It.ID_NULLABLE)!==0,columnScope:$i.FEATURE,type:"scalarType",scalarType:{longID:(t&It.ID_LONG)!==0,type:"logicalType",logicalType:wy.ID}};case It.GEOMETRY:return{nullable:!1,columnScope:$i.FEATURE,type:"complexType",complexType:{type:"physicalType",physicalType:Ke.GEOMETRY,children:[]}};case It.STRUCT:return{nullable:!1,columnScope:$i.FEATURE,type:"complexType",complexType:{type:"physicalType",physicalType:Ke.STRUCT,children:[]}};case It.MAP:return{nullable:!0,columnScope:$i.FEATURE,type:"complexType",complexType:{type:"physicalType",physicalType:Ke.MAP,children:[]}};default:return P6(t)}}function I6(t){return t>=It.SCALAR_BASE}function Zy(t){return t===It.STRUCT||t===It.MAP}function C6(t){if(t.type==="scalarType"){let e=t.scalarType;if(e.type==="physicalType")switch(e.physicalType){case rt.BOOLEAN:case rt.INT_8:case rt.UINT_8:case rt.INT_32:case rt.UINT_32:case rt.INT_64:case rt.UINT_64:case rt.FLOAT:case rt.DOUBLE:return!1;case rt.STRING:return!0;default:return!1}if(e.type==="logicalType")return!1}else if(t.type==="complexType"){let e=t.complexType;if(e.type==="physicalType")switch(e.physicalType){case Ke.GEOMETRY:case Ke.STRUCT:case Ke.MAP:return!0;default:return!1}}return console.warn("Unexpected column type in hasStreamCount",t),!1}function M6(t){return t.type==="scalarType"&&t.scalarType?.type==="logicalType"&&t.scalarType.logicalType===wy.ID}function B6(t){return t.type==="complexType"&&t.complexType?.type==="physicalType"&&t.complexType.physicalType===Ke.GEOMETRY}function P6(t){let e;switch(t){case 10:case 11:e=rt.BOOLEAN;break;case 12:case 13:e=rt.INT_8;break;case 14:case 15:e=rt.UINT_8;break;case 16:case 17:e=rt.INT_32;break;case 18:case 19:e=rt.UINT_32;break;case 20:case 21:e=rt.INT_64;break;case 22:case 23:e=rt.UINT_64;break;case 24:case 25:e=rt.FLOAT;break;case 26:case 27:e=rt.DOUBLE;break;case 28:case 29:e=rt.STRING;break;default:return null}return{nullable:!!(t&1),columnScope:$i.FEATURE,type:"scalarType",scalarType:{longID:!1,type:"physicalType",physicalType:e}}}var z6=new TextDecoder,hp="0-3(ID), 4(GEOMETRY), 10-29(scalars), 30(STRUCT), 31(MAP)";function _u(t,e){let r=Rt(t,e,1)[0];if(r===0)return"";let i=e.get(),n=i+r,a=t.subarray(i,n);return e.add(r),z6.decode(a)}function L6(t){let e=t.name,r=t.nullable;return t.type==="scalarType"?{type:"scalarField",scalarField:t.scalarType,name:e,nullable:r}:{type:"complexField",complexField:t.complexType,name:e,nullable:r}}function Hy(t,e){let r=Rt(t,e,1)[0]>>>0,i=r>=It.SCALAR_BASE?Wy(r):null;if(!i)throw Error(`Unsupported field type code ${r}. Supported: 10-29(scalars), 30(STRUCT), 31(MAP)`);let n={...i,name:_u(t,e)};if(n.type==="complexType"&&Zy(r)){let a=n.complexType,s=Rt(t,e,1)[0]>>>0;a.children=Array(s);for(let o=0;o<s;o++)a.children[o]=Hy(t,e)}return L6(n)}function V6(t,e){let r=Rt(t,e,1)[0]>>>0,i=Wy(r);if(!i)throw Error(`Unsupported column type code ${r}. Supported: ${hp}`);let n;if(I6(r))n=_u(t,e);else if(r<It.GEOMETRY)n="id";else if(r===It.GEOMETRY)n="geometry";else throw Error(`Unsupported column type code ${r}. Supported: ${hp}`);let a={...i,name:n};if(a.type==="complexType"&&Zy(r)){let s=Rt(t,e,1)[0]>>>0,o=a.complexType;o.children=Array(s);for(let l=0;l<s;l++)o.children[l]=Hy(t,e)}return a}function O6(t,e){let r={};r.featureTables=[];let i={};if(i.name=_u(t,e),i.name.length===0)throw Error("Missing layer name");let n=Rt(t,e,1)[0]>>>0,a=Rt(t,e,1)[0]>>>0;i.columns=Array(a);for(let s=0;s<a;s++)i.columns[s]=V6(t,e);return r.featureTables.push(i),[r,n]}function R6(t,e,r=!0){let i=new Dy(0),n=[];for(;i.get()<t.length;){let a=Rt(t,i,1)[0]>>>0,s=i.get()+a;if(s>t.length)throw Error(`Block overruns tile: ${s} > ${t.length}`);let o=Rt(t,i,1)[0]>>>0;if(o!==1&&o!==2){i.set(s);continue}let[l,u]=O6(t,i),h=l.featureTables[0],c=null,p=null,f=[],d=0;for(let m of h.columns){let g=m.name;if(M6(m)){let x=null;if(m.nullable){let v=ht(t,i),w=i.get(),_=ui(t,v.numValues,v.byteLength,i);i.set(w+v.byteLength),x=new ce(_,v.numValues)}let b=ht(t,i);d=x?x.size():b.decompressedCount,c=$6(t,m,i,g,b,x??d,r)}else if(B6(m)){let x=Rt(t,i,1)[0];if(d===0){let b=i.get();d=ht(t,i).decompressedCount,i.set(b)}e&&(e.scale=e.extent/u),p=i6(t,x,i,d,e)}else{let x=C6(m)?Rt(t,i,1)[0]:1;if(x===0)continue;let b=_6(t,i,m,x,d,void 0);if(b)if(Array.isArray(b))for(let v of b)f.push(v);else f.push(b)}}let y=new uw(h.name,p,c,f,u);n.push(y),i.set(s)}return n}function $6(t,e,r,i,n,a,s=!1){let o=e.scalarType?.longID?rt.UINT_64:rt.UINT_32,l=typeof a=="number"?void 0:a,u=Za(n,a,t,r,o===rt.UINT_64?"int64":"int32");if(o===rt.UINT_32)switch(u){case lt.FLAT:return new uu(i,Vt(t,r,n,void 0,l),a);case lt.SEQUENCE:{let h=Iy(t,r,n);return new cu(i,h[0],h[1],n.numRleValues,!1)}case lt.CONST:return new pu(i,xu(t,r,n),a,!1)}switch(u){case lt.FLAT:return s?new hu(i,$3(t,r,n,l),a):new Ly(i,vu(t,r,n,l),a);case lt.SEQUENCE:{let h=Cy(t,r,n);return new Vy(i,h[0],h[1],n.numRleValues,!1)}case lt.CONST:return new qy(i,By(t,r,n),a,!1)}throw Error("Vector type not supported for id column.")}var N6=class{constructor(t,e){switch(this._featureData=t,this.properties=this._featureData.properties||{},this._featureData.geometry?.type){case Pt.POINT:case Pt.MULTIPOINT:this.type=1;break;case Pt.LINESTRING:case Pt.MULTILINESTRING:this.type=2;break;case Pt.POLYGON:case Pt.MULTIPOLYGON:this.type=3;break;default:this.type=0}this.extent=e,this.id=Number(this._featureData.id)}loadGeometry(){let t=[];for(let e of this._featureData.geometry.coordinates){let r=[];for(let i of e)r.push(new B(i.x,i.y));t.push(r)}return t}},U6=class{constructor(t){this.features=[],this.featureTable=t,this.name=t.name,this.extent=t.extent,this.version=2,this.features=t.getFeatures(),this.length=this.features.length}feature(t){return new N6(this.features[t],this.extent)}},Au=class{constructor(t){this.layers={};let e=R6(new Uint8Array(t));this.layers=e.reduce((r,i)=>({...r,[i.name]:new U6(i)}),{})}},Su=class{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new so(mt,16,0),this.grid3D=new so(mt,16,0),this.featureIndexArray=new nd,this.promoteId=e}insert(t,e,r,i,n,a){let s=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,i,n);let o=a?this.grid3D:this.grid;for(let l of e){let u=[1/0,1/0,-1/0,-1/0];for(let h of l)u[0]=Math.min(u[0],h.x),u[1]=Math.min(u[1],h.y),u[2]=Math.max(u[2],h.x),u[3]=Math.max(u[3],h.y);u[0]<8192&&u[1]<8192&&u[2]>=0&&u[3]>=0&&o.insert(s,u[0],u[1],u[2],u[3])}}loadVTLayers(){return this.vtLayers||(this.encoding==="mlt"?this.vtLayers=new Au(this.rawTileData).layers:this.vtLayers=new ql(new ru(this.rawTileData)).layers,this.sourceLayerCoder=new lu(this.vtLayers?Object.keys(this.vtLayers).sort():[al])),this.vtLayers}query(t,e,r,i){this.loadVTLayers();let n=t.params,a=mt/t.tileSize/t.scale,s=ii(n.filter,"queryRenderedFeatures filter",n.globalState),o=t.queryGeometry,l=t.queryPadding*a,u=wa.fromPoints(o),h=this.grid.query(u.minX-l,u.minY-l,u.maxX+l,u.maxY+l),c=wa.fromPoints(t.cameraQueryGeometry).expandBy(l),p=this.grid3D.query(c.minX,c.minY,c.maxX,c.maxY,(y,m,g,x)=>Ag(t.cameraQueryGeometry,y-l,m-l,g+l,x+l));for(let y of p)h.push(y);h.sort(j6);let f={},d;for(let y of h){if(y===d)continue;d=y;let m=this.featureIndexArray.get(y),g=null;this.loadMatchingFeature(f,m.bucketIndex,m.sourceLayerIndex,m.featureIndex,s,n.layers,n.availableImages,e,r,i,(x,b,v)=>(g||(g=Dr(x)),b.queryIntersectsFeature({queryGeometry:o,feature:x,featureState:v,geometry:g,zoom:this.z,transform:t.transform,pixelsToTileUnits:a,pixelPosMatrix:t.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:t.getElevation})))}return f}loadMatchingFeature(t,e,r,i,n,a,s,o,l,u,h){let c=this.bucketLayerIDs[e];if(a&&!c.some(y=>a.has(y)))return;let p=this.sourceLayerCoder.decode(r),f=this.vtLayers[p].feature(i);if(n.needGeometry){let y=li(f,!0);if(!n.filter(new at(this.tileID.overscaledZ),y,this.tileID.canonical))return}else if(!n.filter(new at(this.tileID.overscaledZ),f))return;let d=this.getId(f,p);for(let y of c){if(a&&!a.has(y))continue;let m=o[y];if(!m)continue;let g={};d&&u&&(g=u.getState(m.sourceLayer||"_geojsonTileLayer",d));let x=qt({},l[y]);x.paint=cp(x.paint,m.paint,f,g,s),x.layout=cp(x.layout,m.layout,f,g,s);let b=!h||h(f,m,g);if(!b)continue;let v=new lw(f,this.z,this.x,this.y,d);v.layer=x;let w=t[y];w===void 0&&(w=t[y]=[]),w.push({featureIndex:i,feature:v,intersectionZ:b})}}lookupSymbolFeatures(t,e,r,i,n,a,s,o){let l={};this.loadVTLayers();let u=ii(n.filterSpec,"queryRenderedFeatures symbol filter",n.globalState);for(let h of t)this.loadMatchingFeature(l,r,i,h,u,a,s,o,e);return l}hasLayer(t){for(let e of this.bucketLayerIDs)for(let r of e)if(t===r)return!0;return!1}getId(t,e){let r=t.id;if(this.promoteId){let i=typeof this.promoteId=="string"?this.promoteId:this.promoteId[e];r=t.properties[i],typeof r=="boolean"&&(r=Number(r)),r===void 0&&t.properties?.cluster&&this.promoteId&&(r=Number(t.properties.cluster_id))}return r}};I("FeatureIndex",Su,{omit:["rawTileData","sourceLayerCoder"]});function q6(t){return typeof t=="object"&&!!t&&"evaluate"in t}function cp(t,e,r,i,n){return Aa(t,(a,s)=>{let o=e instanceof Na?e.get(s):null;return q6(o)?o.evaluate(r,i,void 0,n):o})}function j6(t,e){return e-t}var Ky=class{constructor(t){this.maxEntries=t,this.map=new Map}get(t){let e=this.map.get(t);return e!==void 0&&(this.map.delete(t),this.map.set(t,e)),e}set(t,e){if(this.map.has(t))this.map.delete(t);else if(this.map.size>=this.maxEntries){let r=this.map.keys().next().value;this.map.delete(r)}this.map.set(t,e)}clear(){this.map.clear()}};/**\n* MapLibre GL JS\n* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.9.0/LICENSE.txt\n*/function Eu(t){let e=typeof t;if(e==="number"||e==="boolean"||e==="string"||t==null)return JSON.stringify(t);if(Array.isArray(t)){let n="[";for(let a of t)n+=`${Eu(a)},`;return`${n}]`}let r=Object.keys(t).sort(),i="{";for(let n=0;n<r.length;n++)i+=`${JSON.stringify(r[n])}:${Eu(t[r[n]])},`;return`${i}}`}function G6(t){let e="";for(let r of Ap)e+=`/${Eu(t[r])}`;return e}function Y6(t,e){let r={};for(let n=0;n<t.length;n++){let a=e&&e[t[n].id]||G6(t[n]);e&&(e[t[n].id]=a);let s=r[a];s||(s=r[a]=[]),s.push(t[n])}let i=[];for(let n in r)i.push(r[n]);return i}var X6=class{constructor(t,e){this.keyCache={},t&&this.replace(t,e)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(t,e,r){for(let n of t){this._layerConfigs[n.id]=n;let a=this._layers[n.id]=my(n,r);a._featureFilter=ii(a.filter,`layers[${n.id}].filter`,r),this.keyCache[n.id]&&delete this.keyCache[n.id]}for(let n of e)delete this.keyCache[n],delete this._layerConfigs[n],delete this._layers[n];this.familiesBySource={};let i=Y6(Object.values(this._layerConfigs),this.keyCache);for(let n of i){let a=n.map(c=>this._layers[c.id]),s=a[0];if(s.isHidden())continue;let o=s.source||"",l=this.familiesBySource[o];l||(l=this.familiesBySource[o]={});let u=s.sourceLayer||"_geojsonTileLayer",h=l[u];h||(h=l[u]=[]),h.push(a)}}},t1=class{constructor(t){let e={},r=[];for(let s in t){let o=t[s],l=e[s]={};for(let u in o){let h=o[u];if(!h||h.bitmap.width===0||h.bitmap.height===0)continue;let c={x:0,y:0,w:h.bitmap.width+2,h:h.bitmap.height+2};r.push(c),l[u]={rect:c,metrics:h.metrics}}}let{w:i,h:n}=iu(r),a=new Ya({width:i||1,height:n||1});for(let s in t){let o=t[s];for(let l in o){let u=o[l];if(!u||u.bitmap.width===0||u.bitmap.height===0)continue;let h=e[s][l].rect;Ya.copy(u.bitmap,a,{x:0,y:0},{x:h.x+1,y:h.y+1},u.bitmap)}}this.image=a,this.positions=e}};I("GlyphAtlas",t1);var e1=class{constructor(t){this.tileID=new su(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=[]}async parse(t,e,r,i,n){this.data=t,this.collisionBoxArray=new Bl;let a=new lu(Object.keys(t.layers).sort()),s=new Su(this.tileID,this.promoteId);s.bucketLayerIDs=[];let o={},l={featureIndex:s,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:r,subdivisionGranularity:n},u=e.familiesBySource[this.source];for(let S in u){let F=t.layers[S];if(!F)continue;F.version===1&&Mt(`Vector tile source "${this.source}" layer "${S}" does not use vector tile spec v2 and therefore may have some rendering errors.`);let L=a.encode(S),V=[];for(let P=0;P<F.length;P++){let R=F.feature(P),E=s.getId(R,S);V.push({feature:R,id:E,index:P,sourceLayerIndex:L})}for(let P of u[S]){let R=P[0];R.source!==this.source&&Mt(`layer.source = ${R.source} does not equal this.source = ${this.source}`),!R.isHidden(this.zoom,!0)&&(Jy(P,this.zoom,r),(o[R.id]=R.createBucket({index:s.bucketLayerIDs.length,layers:P,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:L,sourceID:this.source})).populate(V,l,this.tileID.canonical),s.bucketLayerIDs.push(P.map(E=>E.id)))}}let h=Aa(l.glyphDependencies,S=>Object.keys(S));for(let S of this.inFlightDependencies)S?.abort();this.inFlightDependencies=[];let c=Promise.resolve({});if(Object.keys(h).length){let S=new AbortController;this.inFlightDependencies.push(S),c=i.sendAsync({type:"GG",data:{stacks:h,source:this.source,tileID:this.tileID,type:"glyphs"}},S)}let p=Object.keys(l.iconDependencies),f=Promise.resolve({});if(p.length){let S=new AbortController;this.inFlightDependencies.push(S),f=i.sendAsync({type:"GI",data:{icons:p,source:this.source,tileID:this.tileID,type:"icons"}},S)}let d=Object.keys(l.patternDependencies),y=Promise.resolve({});if(d.length){let S=new AbortController;this.inFlightDependencies.push(S),y=i.sendAsync({type:"GI",data:{icons:d,source:this.source,tileID:this.tileID,type:"patterns"}},S)}let m=l.dashDependencies,g=Promise.resolve({});if(Object.keys(m).length){let S=new AbortController;this.inFlightDependencies.push(S),g=i.sendAsync({type:"GDA",data:{dashes:m}},S)}let[x,b,v,w]=await Promise.all([c,f,y,g]),_=new t1(x),A=new nu(b,v);for(let S in o){let F=o[S];F.hasDependencies&&(Jy(F.layers,this.zoom,r),F.addFeatures({options:l,canonical:this.tileID.canonical,glyphMap:x,glyphPositions:_.positions,iconMap:b,iconPositions:A.iconPositions,patternMap:v,patternPositions:A.patternPositions,dashPositions:w,showCollisionBoxes:this.showCollisionBoxes}))}return{buckets:Object.values(o).filter(S=>!S.isEmpty()),featureIndex:s,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:_.image,imageAtlas:A,dashPositions:w,glyphMap:this.returnDependencies?x:null,iconMap:this.returnDependencies?b:null,glyphPositions:this.returnDependencies?_.positions:null}}};function Jy(t,e,r){let i=new at(e);for(let n of t)n.recalculate(i,r)}var r1=class{constructor(){this.loading={},this.loaded={},this.parsing={}}startLoading(t,e){this.loading[t]=e}finishLoading(t){delete this.loading[t]}abort(t){let e=this.loading[t];e?.abort&&(e.abort.abort(),delete this.loading[t])}getParsing(t){return this.parsing[t]}setParsing(t,e){this.parsing[t]=e}removeParsing(t){delete this.parsing[t]}markLoaded(t,e){this.loaded[t]=e}getLoaded(t){let e=this.loaded[t];if(e)return e}removeLoaded(t){delete this.loaded[t]}clearLoaded(){this.loaded={}}},i1=class{constructor(t){this.start=`${t}#start`,this.end=`${t}#end`,this.measure=t,performance.mark(this.start)}finish(){performance.mark(this.end);let t=performance.getEntriesByName(this.measure);return t.length===0&&(performance.measure(this.measure,this.start,this.end),t=performance.getEntriesByName(this.measure),performance.clearMarks(this.start),performance.clearMarks(this.end),performance.clearMeasures(this.measure)),t}},W6=class{constructor(t,e,r,i,n){this.type=t,this.properties=r||{},this.extent=n,this.pointsArray=e,this.id=i}loadGeometry(){return this.pointsArray.map(t=>t.map(e=>new B(e.x,e.y)))}},Z6=class{constructor(t,e,r){this.version=2,this._myFeatures=t,this.name=e,this.length=t.length,this.extent=r}feature(t){return this._myFeatures[t]}},H6=class{constructor(){this.layers={}}addLayer(t){this.layers[t.name]=t}};function K6(t,e,r){let{extent:i}=t,n=2**(r.z-e.z),a=(r.x-e.x*n)*i,s=(r.y-e.y*n)*i,o=[];for(let l=0;l<t.length;l++){let u=t.feature(l),h=u.loadGeometry();for(let c of h)for(let p of c)p.x=p.x*n-a,p.y=p.y*n-s;h=hy(h,u.type,-128,-128,i+128,i+128),h.length!==0&&o.push(new W6(u.type,h,u.properties,u.id,i))}return new Z6(o,t.name,i)}var J6=class{constructor(t,e,r){this.actor=t,this.layerIndex=e,this.availableImages=r,this.tileState=new r1,this.overzoomedTileResultCache=new Ky(1e3)}loadVectorTile(t,e){try{return{vectorTile:t.encoding==="mlt"?new Au(e):new ql(new ru(e)),rawData:e}}catch(r){let i=new Uint8Array(e),n=i[0]===31&&i[1]===139,a=`Unable to parse the tile at ${t.request.url}, `;throw a+=n?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${Wi(r).message}`,Error(a)}}async loadTile(t){let{uid:e,overzoomParameters:r}=t;r&&(t.request=r.overzoomRequest);let i=this._startRequestTiming(t),n=new e1(t);this.tileState.startLoading(e,n);let a=new AbortController;n.abort=a;try{let s=await wp(t.request,a);if(t.etag&&t.etag===s.etag)return this.tileState.finishLoading(e),this._getEtagUnmodifiedResult(s,i);let o=this.loadVectorTile(t,s.data);if(this.tileState.finishLoading(e),!o)return null;let{vectorTile:l,rawData:u}=o;r&&({vectorTile:l,rawData:u}=this._getOverzoomTile(t,l));let h=this._getExpiryData(s),c=this._finishRequestTiming(i);n.vectorTile=l,n.etag=s.etag,this.tileState.markLoaded(e,n);let p={rawData:u,cacheControl:h,resourceTiming:c};return this.tileState.setParsing(e,p),await this._parseWorkerTile(n,t)}catch(s){throw this.tileState.finishLoading(e),this.tileState.markLoaded(e,n),s}}_getEtagUnmodifiedResult(t,e){let r=this._getExpiryData(t),i=this._finishRequestTiming(e);return qt({etagUnmodified:!0},r,i)}async _parseWorkerTile(t,e){let r=this.tileState.getParsing(t.uid),i=await t.parse(t.vectorTile,this.layerIndex,this.availableImages,this.actor,e.subdivisionGranularity);if(r){let{rawData:n,cacheControl:a,resourceTiming:s}=r,o=e.overzoomParameters?"mvt":e.encoding;i=qt({rawTileData:n.slice(0),encoding:o},i,a,s),this.tileState.removeParsing(t.uid)}else t.etag&&(i=qt(i,{etag:t.etag}));return i}_getExpiryData({expires:t,cacheControl:e,etag:r}){let i={};return t&&(i.expires=t),e&&(i.cacheControl=e),r&&(i.etag=r),i}_startRequestTiming(t){if(t.request?.collectResourceTiming)return new i1(t.request.url)}_finishRequestTiming(t){let e=t?.finish();return e?{resourceTiming:JSON.parse(JSON.stringify(e))}:{}}_getOverzoomTile(t,e){let{tileID:r,source:i,overzoomParameters:n}=t,{maxZoomTileID:a}=n,s=`${a.key}_${r.key}_${t.request?.url}`,o=this.overzoomedTileResultCache.get(s);if(o)return o;let l=new H6,u=this.layerIndex.familiesBySource[i];for(let c in u){let p=e.layers[c];if(!p)continue;let f=K6(p,a,r.canonical);f.length>0&&l.addLayer(f)}let h={vectorTile:l,rawData:ou(l).buffer};return this.overzoomedTileResultCache.set(s,h),h}async reloadTile(t){let e=t.uid,r=this.tileState.getLoaded(e);if(!r)throw Error("Should not be trying to reload a tile that was never loaded or has been removed");if(r.vectorTile)return r.showCollisionBoxes=t.showCollisionBoxes,await this._parseWorkerTile(r,t)}async abortTile(t){this.tileState.abort(t.uid)}async removeTile(t){this.tileState.removeLoaded(t.uid)}},Q6=class{constructor(){this.loaded={}}async loadTile(t){let{uid:e,encoding:r,rawImageData:i,redFactor:n,greenFactor:a,blueFactor:s,baseShift:o}=t,l=i.width+4,u=i.height+4,h=Sa(i)?new Wt({width:l,height:u},await mp(i,-2,-2,l,u)):i,c=new Nl(e,h,r,n,a,s,o);return this.loaded||(this.loaded={}),this.loaded[e]=c,c}removeTile(t){let e=this.loaded,r=t.uid;e?.[r]&&delete e[r]}},t5=class{constructor(t,e,r,i=e5){this.actor=t,this.layerIndex=e,this.availableImages=r,this.tileState=new r1,this._createGeoJSONIndex=i}loadVectorTile(t){if(!this._geoJSONIndex)throw Error("Unable to parse the data into a cluster or geojson");let{z:e,x:r,y:i}=t.tileID.canonical,n=this._geoJSONIndex.getTile(e,r,i);if(!n)return null;let a=new vy(n.features,{version:2,extent:mt});return{vectorTile:a,rawData:ou(a,yp).buffer}}async loadTile(t){let{uid:e}=t,r=new e1(t);r.abort=new AbortController;try{let i=this.loadVectorTile(t);if(!i)return null;let{vectorTile:n,rawData:a}=i;r.vectorTile=n,this.tileState.markLoaded(e,r);let s={rawData:a};return this.tileState.setParsing(e,s),await this._parseWorkerTile(r,t)}catch(i){throw this.tileState.markLoaded(e,r),i}}async _parseWorkerTile(t,e){let r=this.tileState.getParsing(t.uid),i=await t.parse(t.vectorTile,this.layerIndex,this.availableImages,this.actor,e.subdivisionGranularity);if(r){let{rawData:n}=r;i=qt({rawTileData:n.slice(0),encoding:"mvt"},i),this.tileState.removeParsing(t.uid)}return i}async abortTile(t){this.tileState.abort(t.uid)}async removeTile(t){this.tileState.removeLoaded(t.uid)}async loadData(t){this._pendingRequest?.abort();let e=this._startRequestTiming(t);this._pendingRequest=new AbortController;try{await this.loadAndProcessGeoJSON(t,this._pendingRequest),delete this._pendingRequest,this.tileState.clearLoaded();let r={};return t.request&&(r.data=t.data),this._finishRequestTiming(e,t,r),r}catch(r){if(delete this._pendingRequest,!pl(r))throw r;return{abandoned:!0}}}_startRequestTiming(t){if(t.request?.collectResourceTiming)return new i1(t.request.url)}_finishRequestTiming(t,e,r){let i=t?.finish();i&&(r.resourceTiming={[e.source]:JSON.parse(JSON.stringify(i))})}async reloadTile(t){let e=t.uid,r=this.tileState.getLoaded(e);if(!r)return await this.loadTile(t);if(r.vectorTile)return r.showCollisionBoxes=t.showCollisionBoxes,await this._parseWorkerTile(r,t)}async loadAndProcessGeoJSON(t,e){if(t.request&&(t.data=(await bp(t.request,e)).data),t.data){t.data=this._filterGeoJSON(t.data,t.filter,t.source),this._geoJSONIndex=this._createGeoJSONIndex(t.data,t);return}if(t.dataDiff){this._geoJSONIndex??(this._geoJSONIndex=this._createGeoJSONIndex({type:"FeatureCollection",features:[]},t)),this._geoJSONIndex.updateData(t.dataDiff,this._getFilterPredicate(t.filter,t.source));return}if(t.updateCluster&&this._geoJSONIndex.updateClusterOptions(t.geojsonVtOptions.cluster,n1(t)),this._geoJSONIndex==null)throw Error(`Input data given to \'${t.source}\' is not a valid GeoJSON object.`)}_filterGeoJSON(t,e,r){if(t.type!=="FeatureCollection")return t;let i=this._getFilterPredicate(e,r);return i?{type:"FeatureCollection",features:t.features.filter(n=>i(n))}:t}_getFilterPredicate(t,e){if(typeof t!="boolean"&&!t?.length)return;let r=tr(t,`sources.${e}.filter`,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(r.result==="error")throw Error(r.value.map(i=>`${i.key}: ${i.message}`).join(", "));return i=>r.value.evaluate({zoom:0},i)}async removeSource(t){this._pendingRequest?.abort()}getClusterExpansionZoom(t){return this._geoJSONIndex.getClusterExpansionZoom(t.clusterId)}getClusterChildren(t){return this._geoJSONIndex.getClusterChildren(t.clusterId)}getClusterLeaves(t){return this._geoJSONIndex.getClusterLeaves(t.clusterId,t.limit,t.offset)}};function e5(t,e){let r=qt(e.geojsonVtOptions||{},{updateable:!0,clusterOptions:n1(e)});return new $d(t,r)}function n1({geojsonVtOptions:t,clusterProperties:e,source:r}){if(!e||!t.clusterOptions)return t.clusterOptions;let i={},n={},a={accumulated:null,zoom:0},s={properties:null},o=Object.keys(e);for(let l of o){let[u,h]=e[l],c=tr(h,`sources.${r}.clusterProperties.${l}[1]`),p=tr(typeof u=="string"?[u,["accumulated"],["get",l]]:u,`sources.${r}.clusterProperties.${l}[0]`);i[l]=c.value,n[l]=p.value}return t.clusterOptions.map=l=>{s.properties=l;let u={};for(let h of o)u[h]=i[h].evaluate(a,s);return u},t.clusterOptions.reduce=(l,u)=>{s.properties=u;for(let h of o)a.accumulated=l[h],l[h]=n[h].evaluate(a,s)},t.clusterOptions}async function Qy(t){if(t.endsWith(".mjs")){await import(t);return}let e=await fetch(t,{credentials:"same-origin"});if(!e.ok)throw Error(`Failed to load ${t}: ${e.status}`);let r=await e.text();if(/^[ \\t]*(import|export)\\s/m.test(r)){let i=URL.createObjectURL(new Blob([r],{type:"text/javascript"}));try{await import(i)}finally{URL.revokeObjectURL(i)}return}globalThis.eval(r)}var r5=class{constructor(t){this.self=t,this.actor=new gy(t),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=new Map,this.self.registerWorkerSource=(e,r)=>{if(this.externalWorkerSourceTypes[e])throw Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=r},this.self.addProtocol=gp,this.self.removeProtocol=xp,this.self.registerRTLTextPlugin=e=>{vr.setMethods(e)},this.self.makeRequest=Ea,this.actor.registerMessageHandler("LDT",(e,r)=>this._getDEMWorkerSource(e,r.source).loadTile(r)),this.actor.registerMessageHandler("RDT",async(e,r)=>{this._getDEMWorkerSource(e,r.source).removeTile(r)}),this.actor.registerMessageHandler("GCEZ",async(e,r)=>this._getWorkerSource(e,r.type,r.source).getClusterExpansionZoom(r)),this.actor.registerMessageHandler("GCC",async(e,r)=>this._getWorkerSource(e,r.type,r.source).getClusterChildren(r)),this.actor.registerMessageHandler("GCL",async(e,r)=>this._getWorkerSource(e,r.type,r.source).getClusterLeaves(r)),this.actor.registerMessageHandler("LD",(e,r)=>this._getWorkerSource(e,r.type,r.source).loadData(r)),this.actor.registerMessageHandler("LT",(e,r)=>this._getWorkerSource(e,r.type,r.source).loadTile(r)),this.actor.registerMessageHandler("RT",(e,r)=>this._getWorkerSource(e,r.type,r.source).reloadTile(r)),this.actor.registerMessageHandler("AT",(e,r)=>this._getWorkerSource(e,r.type,r.source).abortTile(r)),this.actor.registerMessageHandler("RMT",(e,r)=>this._getWorkerSource(e,r.type,r.source).removeTile(r)),this.actor.registerMessageHandler("RS",async(e,r)=>{if(!this.workerSources[e]?.[r.type]?.[r.source])return;let i=this.workerSources[e][r.type][r.source];delete this.workerSources[e][r.type][r.source],i.removeSource!==void 0&&i.removeSource(r)}),this.actor.registerMessageHandler("RM",async e=>{delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e],this.globalStates.delete(e)}),this.actor.registerMessageHandler("SR",async(e,r)=>{this.referrer=r}),this.actor.registerMessageHandler("SRPS",(e,r)=>this._syncRTLPluginState(e,r)),this.actor.registerMessageHandler("IS",async(e,r)=>{await Qy(r)}),this.actor.registerMessageHandler("SI",(e,r)=>this._setImages(e,r)),this.actor.registerMessageHandler("UL",async(e,r)=>{this._getLayerIndex(e).update(r.layers,r.removedIds,this._getGlobalState(e))}),this.actor.registerMessageHandler("UGS",async(e,r)=>{let i=this._getGlobalState(e);for(let n in r)i[n]=r[n]}),this.actor.registerMessageHandler("SL",async(e,r)=>{this._getLayerIndex(e).replace(r,this._getGlobalState(e))})}_getGlobalState(t){let e=this.globalStates.get(t);return e||(e={},this.globalStates.set(t,e)),e}async _setImages(t,e){this.availableImages[t]=e;for(let r in this.workerSources[t]){let i=this.workerSources[t][r];for(let n in i)i[n].availableImages=e}}async _syncRTLPluginState(t,e){return await vr.syncState(e,Qy)}_getAvailableImages(t){let e=this.availableImages[t];return e||(e=[]),e}_getLayerIndex(t){let e=this.layerIndexes[t];return e||(e=this.layerIndexes[t]=new X6),e}_getWorkerSource(t,e,r){var i,n;if((i=this.workerSources)[t]||(i[t]={}),(n=this.workerSources[t])[e]||(n[e]={}),!this.workerSources[t][e][r]){let a={sendAsync:(s,o)=>(s.targetMapId=t,this.actor.sendAsync(s,o))};switch(e){case"vector":this.workerSources[t][e][r]=new J6(a,this._getLayerIndex(t),this._getAvailableImages(t));break;case"geojson":this.workerSources[t][e][r]=new t5(a,this._getLayerIndex(t),this._getAvailableImages(t));break;default:this.workerSources[t][e][r]=new this.externalWorkerSourceTypes[e](a,this._getLayerIndex(t),this._getAvailableImages(t))}}return this.workerSources[t][e][r]}_getDEMWorkerSource(t,e){var r,i;return(r=this.demWorkerSources)[t]||(r[t]={}),(i=this.demWorkerSources[t])[e]||(i[e]=new Q6),this.demWorkerSources[t][e]}};dr(self)&&(self.worker=new r5(self));export{r5 as default};\n'],{type:"text/javascript"});u$=URL.createObjectURL(e),function(e){Ef.WORKER_URL=e}(u$)}catch(e){u$=null,console.warn("[MapVX] Could not install the bundled MapLibre worker:",e)}}function h$(e){var t,r,i,n,a,s;const o=null!==(t=null==e?void 0:e.backgroundColor)&&void 0!==t?t:"#276EF1",l=null!==(r=null==e?void 0:e.arrowColor)&&void 0!==r?r:"#FFFFFF",u=null!==(i=null==e?void 0:e.arrowWidth)&&void 0!==i?i:0,c=null!==(n=null==e?void 0:e.borderWidth)&&void 0!==n?n:0,h=null!==(a=null==e?void 0:e.borderColor)&&void 0!==a?a:"#000000",d=null!==(s=null==e?void 0:e.blur)&&void 0!==s?s:0,p=d>0?"blurFilter":"";return`data:image/svg+xml,${encodeURIComponent(`<?xml version="1.0" encoding="utf-8"?>\n<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"\n\t viewBox="0 0 30 30" style="enable-background:new 0 0 30 30;" xml:space="preserve">\n${d>0?`<defs><filter id="${p}"><feGaussianBlur in="SourceGraphic" stdDeviation="${d}"/></filter></defs>`:""}\n<g ${d>0?`filter="url(#${p})"`:""}>\n\t<circle cx="15" cy="15" r="15" style="${`fill:${o};`}${c>0?`stroke:${h};stroke-width:${c};`:""}"/>\n\t<path style="${`fill:${l};`}${u>0?`stroke:${l};stroke-width:${u};`:""}" d="M16.4471 7.26386C16.2568 6.80696 15.808 6.51052 15.3131 6.51052C14.8181 6.51052 14.3693 6.80696 14.179 7.26386L8.52211 20.7533C8.29366 21.2972 8.48404 21.9227 8.97085 22.2518C9.45767 22.5809 10.1104 22.5156 10.5265 22.0995L15.3131 17.3129L20.0996 22.0995C20.5157 22.5156 21.1657 22.5782 21.6553 22.2518C22.1448 21.9254 22.3325 21.2972 22.104 20.7533L16.4471 7.26386Z"/>\n</g>\n</svg>`)}`}const d$=h$();function p$(){let e="";const t="0123456789ABCDEF";for(let r=0;r<10;r++)e+=t.charAt(Math.floor(16*Math.random()));return e}function f$(e){const t={lat:-1/0,lng:-1/0},r={lat:1/0,lng:1/0};return e.forEach(e=>{e.lat>t.lat&&(t.lat=e.lat),e.lng>t.lng&&(t.lng=e.lng),e.lat<r.lat&&(r.lat=e.lat),e.lng<r.lng&&(r.lng=e.lng)}),[r,t]}var m$;!function(e){e[e.left=0]="left",e[e.right=1]="right",e[e.top=2]="top",e[e.bottom=3]="bottom"}(m$||(m$={}));const g$=40;class y${static createMarkerElement(e){var t,r,i,n;const a=document.createElement("div"),s=null!==(r=null===(t=e.iconProperties)||void 0===t?void 0:t.width)&&void 0!==r?r:g$,o=null!==(n=null===(i=e.iconProperties)||void 0===i?void 0:i.height)&&void 0!==n?n:g$;if(a.className="mapvx-marker",a.addEventListener("click",()=>{var t;null===(t=e.onClick)||void 0===t||t.call(e)}),e.element)return e.iconProperties&&(a.style.width=`${s}px`,a.style.height=`${o}px`),a.appendChild(e.element),this.setAndCreateText(e,a);a.style.width=`${s}px`,a.style.height=`${o}px`;const l=this.createIconElement(e,s,o);return a.appendChild(l),this.setAndCreateText(e,a)}static setAndCreateText(e,t){if(e.text){const r="string"==typeof e.text?this.createTextElement(e.text,e.textProperties):e.text,i=this.createTextContainer(r,e.textPosition,e.maxLabelWidthPx);t.appendChild(i)}return t}static createIconElement(e,t,r){if("string"==typeof e.icon)return this.createIcon(e);if(e.icon instanceof HTMLImageElement)return e.icon.style.width=`${t}px`,e.icon.style.height=`${r}px`,e.icon;if(e.icon)return e.icon;{const e=document.createElement("div");return e.className="icon-default",e.style.width=`${t}px`,e.style.height=`${r}px`,e}}static createTextContainer(e,t,r){const i=document.createElement("div");return i.className="text-container",i.style.maxWidth=`${null!=r?r:200}px`,this.setTextPositionClass(i,this.resolveTextPosition(t)),e.style.display="block",e.style.margin="0",i.appendChild(e),i}static resolveTextPosition(e){return null!=e?e:m$.right}static setTextPositionClass(e,t){e.classList.remove("top","bottom","left","right"),e.classList.add(m$[t])}static applyTextPosition(e,t,r){this.setTextPositionClass(e,t),e.style.visibility=r?"hidden":""}static createIcon(e){var t,r,i,n;const a=document.createElement("img");return a.src="string"==typeof e.icon?e.icon:"",a.width=null!==(r=null===(t=e.iconProperties)||void 0===t?void 0:t.width)&&void 0!==r?r:g$,a.height=null!==(n=null===(i=e.iconProperties)||void 0===i?void 0:i.height)&&void 0!==n?n:g$,a.style.objectFit="contain",a.style.filter="drop-shadow(0px 4px 4px rgba(0, 0, 0, 0.25))",a}static createTextElement(e,t){var r,i,n,a,s,o,l;const u=document.createElement("p");return u.textContent=e,u.style.fontSize=null!==(r=null==t?void 0:t.fontSize)&&void 0!==r?r:"14px",u.style.padding=null!==(i=null==t?void 0:t.padding)&&void 0!==i?i:"0px",u.style.margin=null!==(n=null==t?void 0:t.margin)&&void 0!==n?n:"0px",u.style.fontWeight=null!==(a=null==t?void 0:t.fontWeight)&&void 0!==a?a:"600",u.style.fontFamily=null!==(s=null==t?void 0:t.fontFamily)&&void 0!==s?s:"'Open Sans', sans-serif",u.style.color=null!==(o=null==t?void 0:t.color)&&void 0!==o?o:"#000000",u.style.textShadow=null!==(l=null==t?void 0:t.textShadow)&&void 0!==l?l:"-1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff",u}}class _$ extends r${constructor(e){var t,r,i,n,a;super({element:y$.createMarkerElement(e),draggable:!1,anchor:null!==(t=e.anchor)&&void 0!==t?t:"center",offset:[0,0]}),this.hiddenOnPurpose=!1,this.setLngLat([e.coordinate.lng,e.coordinate.lat]),this.setRotationAlignment(null!==(r=e.rotationAlignment)&&void 0!==r?r:"viewport"),this.setPitchAlignment("viewport"),"number"==typeof e.rotation&&this.setRotation(e.rotation),this.id=null!==(i=e.id)&&void 0!==i?i:p$(),this.coordinate=e.coordinate,this.floorId=null!==(n=e.floorId)&&void 0!==n?n:"",this.anchorType=null!==(a=e.anchor)&&void 0!==a?a:"center",this.currentConfig=e,this.applyLayoutState(e)}applyLayoutState(e){var t,r,i,n,a;this.iconSize={width:null!==(r=null===(t=e.iconProperties)||void 0===t?void 0:t.width)&&void 0!==r?r:g$,height:null!==(n=null===(i=e.iconProperties)||void 0===i?void 0:i.height)&&void 0!==n?n:g$},this.preferredTextPosition=y$.resolveTextPosition(e.textPosition),this.labelPriority=null!==(a=e.labelPriority)&&void 0!==a?a:0,this.measureIconFromDom=null!=e.element&&null==e.iconProperties,this.textContainerEl=this.findTextContainerEl()}mergeConfig(e){return Object.assign(Object.assign(Object.assign({},this.currentConfig),e),{element:e.element})}findTextContainerEl(){return Array.from(this._element.children).find(e=>e instanceof HTMLElement&&e.classList.contains("text-container"))}addToMap(e){e&&this.addTo(e)}updateIcon(e){var t,r;const i=this.mergeConfig(e);if(i.element)this._element.innerHTML="",this._element.appendChild(i.element);else{const e=y$.createMarkerElement(i),r=this._element.querySelector("div"),n=e.querySelector("div");n&&(null===(t=null==r?void 0:r.parentElement)||void 0===t||t.replaceChild(n,r))}this.setRotationAlignment(null!==(r=i.rotationAlignment)&&void 0!==r?r:"viewport"),this.setPitchAlignment("viewport"),"number"==typeof i.rotation&&this.setRotation(i.rotation),this.currentConfig=i,this.applyLayoutState(i)}setFloor(e){this.floorId=e}hide(){this.hiddenOnPurpose=!0,this.remove()}show(e){e&&this.addTo(e)}addTo(e){return this.hiddenOnPurpose=!1,super.addTo(e)}changeFloor(e,t,r=!1){e==this.floorId||r&&!this.floorId?this.show(t):this.hide()}}const v$={center:{fx:.5,fy:.5},top:{fx:.5,fy:0},bottom:{fx:.5,fy:1},left:{fx:0,fy:.5},right:{fx:1,fy:.5},"top-left":{fx:0,fy:0},"top-right":{fx:1,fy:0},"bottom-left":{fx:0,fy:1},"bottom-right":{fx:1,fy:1}},x$=[m$.right,m$.top,m$.left,m$.bottom];function b$(e,t,r){var i;const{fx:n,fy:a}=null!==(i=v$[r])&&void 0!==i?i:v$.center;return{left:e.x-n*t.width,top:e.y-a*t.height,width:t.width,height:t.height}}function w$(e,t,r,i,n){switch(r){case m$.left:return{left:e.left-i-t.width,top:e.top+e.height/2-t.height/2,width:t.width,height:t.height};case m$.top:return{left:e.left+e.width/2-t.width/2,top:e.top-n-t.height,width:t.width,height:t.height};case m$.bottom:return{left:e.left+e.width/2-t.width/2,top:e.top+e.height+n,width:t.width,height:t.height};case m$.right:default:return{left:e.left+e.width+i,top:e.top+e.height/2-t.height/2,width:t.width,height:t.height}}}function E$(e,t){return e.left<t.left+t.width&&e.left+e.width>t.left&&e.top<t.top+t.height&&e.top+e.height>t.top}class S${constructor(e,t){this.labelSizeCache=new WeakMap,this.iconSizeCache=new WeakMap,this.lastAppliedState=new WeakMap,this.attached=!1,this.mapvxMap=e,this.config=t,this.boundOnMove=()=>this.scheduleRelayout()}get map(){return this.mapvxMap.map}attach(){this.attached||(this.attached=!0,this.map.on("move",this.boundOnMove),this.remeasureWhenFontsLoad(),this.scheduleRelayout())}applyLayoutVariables(e){e.style.setProperty("--mapvx-label-gap",`${this.config.gapPx}px`),e.style.setProperty("--mapvx-label-vertical-gap",`${this.config.verticalGapPx}px`),e.style.setProperty("--mapvx-label-max-width",`${this.config.maxLabelWidthPx}px`)}remeasureWhenFontsLoad(){const e=document.fonts;e&&e.ready.then(()=>{this.attached&&(this.labelSizeCache=new WeakMap,this.iconSizeCache=new WeakMap,this.scheduleRelayout())}).catch(()=>{})}destroy(){this.attached&&(this.map.off("move",this.boundOnMove),this.attached=!1),void 0!==this.rafHandle&&(cancelAnimationFrame(this.rafHandle),this.rafHandle=void 0)}invalidateMarker(e){this.labelSizeCache.delete(e),this.iconSizeCache.delete(e),this.lastAppliedState.delete(e)}scheduleRelayout(){this.config.enabled&&void 0===this.rafHandle&&(this.rafHandle=requestAnimationFrame(()=>{this.rafHandle=void 0,this.performLayout()}))}performLayout(){if(!this.attached)return;const e=this.mapvxMap.getMarkers();if(0===e.length)return;const t=this.map.getContainer(),r=t.clientWidth,i=t.clientHeight,n=this.config.maxLabelWidthPx+Math.max(this.config.gapPx,this.config.verticalGapPx),a=this.map.getZoom()>=this.config.minZoomForLabels,s=this.readMarkers(e,r,i,n),o=this.decidePlacements(s,a);this.applyDecisions(o)}readMarkers(e,t,r,i){const n=[];for(const a of e){if(!a.getElement().isConnected)continue;const e=b$(this.map.project(a.getLngLat()),this.resolveIconSize(a),a.anchorType);e.left+e.width<-i||e.left>t+i||e.top+e.height<-i||e.top>r+i||n.push({marker:a,iconRect:e,labelSize:this.resolveLabelSize(a)})}return n}resolveLabelSize(e){const t=e.textContainerEl;if(t)return this.measureCached(this.labelSizeCache,e,t)}resolveIconSize(e){var t;return e.measureIconFromDom&&null!==(t=this.measureCached(this.iconSizeCache,e,e.getElement()))&&void 0!==t?t:e.iconSize}measureCached(e,t,r){const i=e.get(t);if(i)return i;const n={width:r.offsetWidth,height:r.offsetHeight};return n.width<=0||n.height<=0?void 0:(e.set(t,n),n)}decidePlacements(e,t){const r=[],i=e.filter(D$),n=new Map;if(!t){for(const e of i)n.set(e.marker,{position:e.marker.preferredTextPosition,hidden:!0});return n}i.sort((e,t)=>t.marker.labelPriority-e.marker.labelPriority);for(const a of i){const t=[a.marker.preferredTextPosition,...x$.filter(e=>e!==a.marker.preferredTextPosition)].map(e=>({position:e,rect:w$(a.iconRect,a.labelSize,e,this.config.gapPx,this.config.verticalGapPx)})).find(({rect:t})=>!this.collides(t,a.marker,e,r));t?(r.push(t.rect),n.set(a.marker,{position:t.position,hidden:!1})):n.set(a.marker,{position:a.marker.preferredTextPosition,hidden:!0})}return n}collides(e,t,r,i){const n=function(e,t){return{left:e.left-t,top:e.top-t,width:e.width+2*t,height:e.height+2*t}}(e,this.config.paddingPx);return r.some(e=>e.marker!==t&&E$(n,e.iconRect))||i.some(e=>E$(n,e))}applyDecisions(e){e.forEach((e,t)=>{const r=this.lastAppliedState.get(t);r&&r.position===e.position&&r.hidden===e.hidden||(t.textContainerEl&&y$.applyTextPosition(t.textContainerEl,e.position,e.hidden),this.lastAppliedState.set(t,e))})}}function D$(e){return void 0!==e.labelSize}function T$(e){return{id:e.id,route:e,aheadId:`AHEAD_${e.id}`,behindId:`BEHIND_${e.id}`,currentId:`CURRENT_${e.id}`,aheadSourceData:{type:"FeatureCollection",features:[]},behindSourceData:{type:"FeatureCollection",features:[]},currentSourceData:{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}},animationStatus:"NO_ROUTE",stepAnimationStatus:"NO_ROUTE",layerDrawConfigs:{}}}const{asin:A$,atan2:P$,cos:I$,sin:C$,pow:F$,sqrt:M$,PI:k$}=Math;function R$(e){return C$(e/2)*C$(e/2)}function L$(e){return e*(k$/180)}function z$(e){return e*(180/k$)}function B$(e,t){return e.lat===t.lat&&e.lng===t.lng}class O${static distance(e,t){const r=L$(e.lat),i=L$(t.lat),n=L$(e.lng),a=L$(t.lng)-n,s=R$(i-r)+I$(r)*I$(i)*R$(a);return 2*O$.EARTH_RADIUS*A$(M$(s))}static intermediatePointBetween(e,t,r){const i=L$(e.lat),n=L$(t.lat),a=L$(e.lng),s=L$(t.lng),o=O$.distance(e,t)/O$.EARTH_RADIUS,l=C$((1-r)*o)/C$(o),u=C$(r*o)/C$(o),c=l*I$(i)*I$(a)+u*I$(n)*I$(s),h=l*I$(i)*C$(a)+u*I$(n)*C$(s),d=l*C$(i)+u*C$(n),p=P$(d,M$(F$(c,2)+F$(h,2))),f=P$(h,c);return{lat:z$(p),lng:z$(f)}}static bearingInDegBetween(e,t){return z$(O$.bearingInRadBetween(e,t))}static bearingInRadBetween(e,t){const r=t.lng-e.lng,i=t.lat-e.lat;return(k$/2-P$(i,r)+2*k$)%(2*k$)}static intermediateAngleBetween(e,t,r){let i=(t-e+180)%360-180;return i<-180&&(i+=360),(e+360+i*r)%360}}O$.EARTH_RADIUS=6378e3;const $$={top:150,right:150,bottom:150,left:150},N$="rgba(0, 0, 0, 0)",j$=1/256,V$=e=>["interpolate",["linear"],["line-progress"],0,e,1,e];class U${constructor(e){this.routes=new Map,this.mapvxMap=e}get map(){return this.mapvxMap.map}resolveInstance(e){const t=null!=e?e:this.lastAddedRouteId;return t?this.routes.get(t):void 0}addSourcesAndLayersForRoute(e){this.map.addSource(e.aheadId,{type:"geojson",lineMetrics:!0,data:e.aheadSourceData}),this.map.addLayer({id:e.aheadId,type:"line",source:e.aheadId,layout:{"line-join":"round","line-cap":"round"}}),this.map.addSource(e.behindId,{type:"geojson",lineMetrics:!0,data:e.behindSourceData}),this.map.addLayer({id:e.behindId,type:"line",source:e.behindId,layout:{"line-join":"round","line-cap":"round"}}),this.map.addSource(e.currentId,{type:"geojson",lineMetrics:!0,data:e.currentSourceData}),this.map.addLayer({id:e.currentId,type:"line",source:e.currentId,layout:{"line-join":"round","line-cap":"round"}})}removeSourcesAndLayersForRoute(e){const t=[e.aheadId,e.behindId,e.currentId];for(const i of t){try{this.map.removeLayer(i)}catch(YF){}try{this.map.removeSource(i)}catch(r){}}}addSourcesAndLayers(){for(const e of this.routes.values())this.addSourcesAndLayersForRoute(e),this.restoreLayerPaint(e);this.syncRouteCollision()}restoreLayerPaint(e){var t;for(const[i,n]of Object.entries(e.layerDrawConfigs))this.setLayerPaint(e,i,n);const r=null!==(t=e.revealFraction)&&void 0!==t?t:0;e.revealFraction=void 0,this.applyReveal(e,r)}syncRouteCollision(){const e=[];for(const t of this.routes.values())for(const r of t.route.steps){const t=this.getFloorKeyForStep(r);for(const i of r.coordinates)e.push({lng:i.lng,lat:i.lat,floorKey:t})}this.mapvxMap.setRouteCollisionPath(e)}addRoute(e,t){const r=T$(e);this.routes.set(r.id,r),this.lastAddedRouteId=r.id,this.addSourcesAndLayersForRoute(r),this.setSourceData(r,r.aheadId,e.steps),this.setLayerPaint(r,r.aheadId,t),this.updateLayerFilter(r.aheadId),this.syncRouteCollision()}updateRouteProgress(e,t,r){const i=this.routes.get(e);if(!i)return;const n=i.route.steps;let a=1/0,s=0,o=0,l=0;for(let b=0;b<n.length;b++){const e=n[b].coordinates;for(let r=0;r<e.length-1;r++){const i=e[r],n=e[r+1],{fraction:u,dist:c}=this.projectPointToSegment(t,i,n);c<a&&(a=c,s=b,o=r,l=u)}}const u=[];for(let b=0;b<s;b++)u.push({type:"Feature",properties:{floor_key:this.getFloorKeyForStep(n[b])},geometry:{type:"LineString",coordinates:n[b].geoJsonCoordinates}});const c=n[s],h=c.coordinates,d=[];for(let b=0;b<=o;b++)d.push([h[b].lng,h[b].lat]);const p=h[o],f=h[Math.min(o+1,h.length-1)],m=p.lat+l*(f.lat-p.lat),g=p.lng+l*(f.lng-p.lng);d.push([g,m]),d.length>=2&&u.push({type:"Feature",properties:{floor_key:this.getFloorKeyForStep(c)},geometry:{type:"LineString",coordinates:d}});const y=[],_=[[g,m]];for(let b=o+1;b<h.length;b++)_.push([h[b].lng,h[b].lat]);_.length>=2&&y.push({type:"Feature",properties:{floor_key:this.getFloorKeyForStep(c)},geometry:{type:"LineString",coordinates:_}});for(let b=s+1;b<n.length;b++)y.push({type:"Feature",properties:{floor_key:this.getFloorKeyForStep(n[b])},geometry:{type:"LineString",coordinates:n[b].geoJsonCoordinates}});i.behindSourceData.features=u;const v=this.map.getSource(i.behindId);null==v||v.setData(i.behindSourceData),i.aheadSourceData.features=y;const x=this.map.getSource(i.aheadId);null==x||x.setData(i.aheadSourceData),this.setLayerPaint(i,i.behindId,r),this.updateLayerFilter(i.behindId),this.updateLayerFilter(i.aheadId)}projectPointToSegment(e,t,r){const i=r.lng-t.lng,n=r.lat-t.lat,a=i*i+n*n;if(0===a){const r=e.lng-t.lng,i=e.lat-t.lat;return{fraction:0,dist:r*r+i*i}}let s=((e.lng-t.lng)*i+(e.lat-t.lat)*n)/a;s=Math.max(0,Math.min(1,s));const o=t.lng+s*i,l=t.lat+s*n,u=e.lng-o,c=e.lat-l;return{fraction:s,dist:u*u+c*c}}setSourceData(e,t,r){const i=this.createFeaturesFrom(r),n=this.map.getSource(t);t===e.aheadId?(e.aheadSourceData.features=i,null==n||n.setData(e.aheadSourceData)):t===e.behindId&&(e.behindSourceData.features=i,null==n||n.setData(e.behindSourceData))}loadStepGeometry(e,t){var r;e.currentSourceData.properties={floor_key:this.getFloorKeyForStep(t)};const i=null!==(r=null==t?void 0:t.coordinates)&&void 0!==r?r:[];e.currentSourceData.geometry.coordinates=i.length>=2?i.map(e=>[e.lng,e.lat]):[];const n=[0];for(let s=1;s<i.length;s++)n.push(n[s-1]+O$.distance(i[s-1],i[s]));e.stepMetrics={cumulative:n,total:n[n.length-1]},e.revealFraction=void 0,this.applyReveal(e,0);const a=this.map.getSource(e.currentId);null==a||a.setData(e.currentSourceData)}fractionAlongStep(e,t,r){var i;const n=e.stepMetrics;if(!n||n.total<=0)return 1;const a=Math.min(t,n.cumulative.length-1);return((null!==(i=n.cumulative[a])&&void 0!==i?i:0)+r)/n.total}applyReveal(e,t){const r=e.currentLineColor;if(void 0===r)return;const i=Math.max(0,Math.min(1,t));e.revealFraction!==i&&this.hasSource(e.currentId)&&(e.revealFraction=i,this.map.setPaintProperty(e.currentId,"line-gradient",this.revealGradient(r,i),{validate:!1}))}revealGradient(e,t){return t<=0?V$(N$):t>=1?V$(e):["interpolate",["linear"],["line-progress"],t,e,Math.min(t+j$,1),N$]}stepSourcesReady(e){try{return!!this.map.getSource(e.currentId)&&!1!==this.map.isSourceLoaded(e.currentId)}catch(YF){return!1}}hasSource(e){try{return null!=this.map.getSource(e)}catch(YF){return!1}}applyPendingFloor(e){var t;const r=null===(t=e.conditions)||void 0===t?void 0:t.pendingFloor;r&&e.conditions&&(e.conditions.pendingFloor=void 0,this.updatePlaceFloorForRouting(e,r.placeId,r.floorKey),this.setMarkerLngLat(e,r.location))}setLayerPaint(e,t,r){e.layerDrawConfigs[t]=r;const i=this.preparePaintForLayer(r);for(const[n,a]of Object.entries(i))this.map.setPaintProperty(t,n,a)}setCurrentDrawConfig(e,t){e.currentDrawConfig=t,e.currentLineColor=this.lineColorExpression(t)}lineColorExpression(e){if("color"in e.routeStyle)return e.routeStyle.color;const{colors:t,positions:r}=e.routeStyle,i=null!=r?r:function(e){if(0===e)return[];if(1===e)return[0];const t=1/(e-1);return Array.from({length:e},(e,r)=>r*t)}(t.length);if(i.length!==t.length)throw new Error("Error: position array has different length than colors array");const n=function(e,t){return e.flatMap((e,r)=>[e,t[r]])}(i,t);return["interpolate",["linear"],["line-progress"],...n]}preparePaintForLayer(e){const t=this.lineColorExpression(e);return"string"==typeof t?{"line-color":t,"line-gradient":null,"line-width":e.polylineWidth}:{"line-color":null,"line-gradient":t,"line-width":e.polylineWidth}}updateLayerFilter(e,t){const r=null!=t?t:this.mapvxMap.getCurrentFloor();void 0!==r&&null!=this.map.getLayer(e)&&this.map.setFilter(e,["==",["get","floor_key"],r])}getFloorKeyForStep(e){var t,r,i,n,a,s,o;if(!e)return this.mapvxMap.getCurrentFloor();if((null!==(r=null===(t=e.startInsideFloor)||void 0===t?void 0:t.length)&&void 0!==r?r:0)>0)return(null!==(n=null===(i=e.endInsideFloor)||void 0===i?void 0:i.length)&&void 0!==n?n:0)>0&&e.startInsideFloor!==e.endInsideFloor&&!e.elevatorStep?e.endInsideFloor:e.startInsideFloor;if((null!==(s=null===(a=e.endInsideFloor)||void 0===a?void 0:a.length)&&void 0!==s?s:0)>0)return e.endInsideFloor;const l=this.mapvxMap.getInnerFloors().find(e=>!0===e.reachableFromGPS);return null!==(o=null==l?void 0:l.key)&&void 0!==o?o:""}createFeaturesFrom(e){return e.map(e=>({type:"Feature",properties:{floor_key:this.getFloorKeyForStep(e)},geometry:{type:"LineString",coordinates:e.geoJsonCoordinates}}))}updateRouteLayers(e){for(const t of this.routes.values())this.updateLayerFilter(t.aheadId,e),this.updateLayerFilter(t.behindId,e),this.updateLayerFilter(t.currentId,e)}getRouteMarkers(){const e=[];for(const t of this.routes.values())t.routeMarker&&e.push(t.routeMarker);return e}updateRouteMarkerVisibility(e){var t,r,i,n;const a=this.mapvxMap.isOutdoorFloor(e);for(const s of this.routes.values()){const o=null!==(r=null===(t=s.routeMarker)||void 0===t?void 0:t.floorId)&&void 0!==r?r:"";o===e||a&&""===o?null===(i=s.routeMarker)||void 0===i||i.show(this.map):null===(n=s.routeMarker)||void 0===n||n.hide()}}updatePlaceFloorForRouting(e,t,r){var i;t&&r&&(this.mapvxMap.updatePlaceAndFloorForRouting(t,r),this.updateRouteLayers(r),null===(i=e.routeMarker)||void 0===i||i.setFloor(r),this.updateRouteMarkerVisibility(r))}startAnimating(e,t,r){var i,n,a;const s=T$(e);this.routes.set(s.id,s),this.lastAddedRouteId=s.id,s.animationStatus="STARTED",s.route=e;const o=e.steps[0];if(this.addSourcesAndLayersForRoute(s),this.updatePlaceFloorForRouting(s,o.startInsidePlace,o.startInsideFloor),this.setSourceData(s,s.aheadId,e.steps),this.setSourceData(s,s.behindId,[]),this.setLayerPaint(s,s.aheadId,t.aheadConfig),this.setLayerPaint(s,s.behindId,t.behindConfig),this.setLayerPaint(s,s.currentId,t.behindConfig),this.setCurrentDrawConfig(s,t.behindConfig),this.loadStepGeometry(s,o),s.animationConfig=r,s.routeMarker=new _$({coordinate:o.startLocation,floorId:o.startInsideFloor,icon:t.routeIcon,rotationAlignment:"map"}),s.routeMarker.addToMap(this.map),(null===(i=r.autoFitByPlace)||void 0===i?void 0:i.enabled)&&e.steps.length>0&&o.startInsidePlace){s.currentPlaceId=o.startInsidePlace;const t={padding:null!==(n=r.autoFitByPlace.padding)&&void 0!==n?n:$$};this.mapvxMap.fitRouteByPlace(e,o.startInsidePlace,t)}s.conditions={index:0,coordinatesIndex:0,iconRotation:0,rotatingIcon:!0,startTime:void 0,progress:0,resetTime:!1,waitStartTime:void 0,awaitingSources:!0,animationId:requestAnimationFrame(e=>this.animateStep(e,s)),onFinish:e=>this.prepareForNextStep(e,s)},null===(a=r.callBack)||void 0===a||a.call(r,{isFinished:!1,step:o}),this.syncRouteCollision()}clearRouteInstance(e,t=!0){var r;t?this.applyPendingFloor(e):e.conditions&&(e.conditions.pendingFloor=void 0),null===(r=e.routeMarker)||void 0===r||r.remove(),e.routeMarker=void 0,this.setSourceData(e,e.aheadId,[]),this.setSourceData(e,e.behindId,[]),e.currentSourceData.geometry.coordinates=[];const i=this.map.getSource(e.currentId);null==i||i.setData(e.currentSourceData),"STARTED"!==e.animationStatus&&"ANIMATING"!==e.stepAnimationStatus||null==e.conditions||cancelAnimationFrame(e.conditions.animationId),e.animationStatus="NO_ROUTE",e.stepAnimationStatus="NO_ROUTE",e.conditions=void 0,e.animationConfig=void 0,e.currentPlaceId=void 0}removeRoute(e){const t=this.resolveInstance(e);if(t){if(this.clearRouteInstance(t),this.removeSourcesAndLayersForRoute(t),this.routes.delete(t.id),this.lastAddedRouteId===t.id){const e=[...this.routes.keys()];this.lastAddedRouteId=e.length>0?e[e.length-1]:void 0}this.syncRouteCollision()}}removeAllRoutes(){for(const e of this.routes.values())this.clearRouteInstance(e,!1),this.removeSourcesAndLayersForRoute(e);this.routes.clear(),this.lastAddedRouteId=void 0,this.syncRouteCollision()}getRouteIds(){return[...this.routes.keys()]}internalPause(e){"STARTED"==e.animationStatus&&null!=e.conditions&&(cancelAnimationFrame(e.conditions.animationId),e.animationStatus="PAUSED")}pauseAnimation(e){const t=this.resolveInstance(e);t&&this.internalPause(t)}internalResume(e){"PAUSED"==e.animationStatus&&null!=e.conditions&&(e.conditions.resetTime=!0,e.conditions.animationId=requestAnimationFrame(t=>this.animateStep(t,e)),e.animationStatus="STARTED")}resumeAnimation(e){const t=this.resolveInstance(e);t&&this.internalResume(t)}restartAnimation(e){var t,r,i,n,a;const s=this.resolveInstance(e);if(!s)throw new Error("Does not exist animated route to restart");if("NO_ROUTE"===s.animationStatus)throw new Error("Does not exist animated route to restart");if(null==s.conditions||null==s.animationConfig||null==s.route||null==s.routeMarker)throw new Error("Error: conditions and animationConfig should not be null at this point");"STARTED"===s.animationStatus&&cancelAnimationFrame(s.conditions.animationId),s.animationStatus="STARTED";const o=s.route.steps[0];if(this.updatePlaceFloorForRouting(s,o.startInsidePlace,o.startInsideFloor),this.setSourceData(s,s.aheadId,s.route.steps),this.setSourceData(s,s.behindId,[]),this.loadStepGeometry(s,o),null===(t=this.setMarkerRotation(s,0))||void 0===t||t.setLngLat(o.startLocation).addTo(this.map),(null===(r=s.animationConfig.autoFitByPlace)||void 0===r?void 0:r.enabled)&&s.route.steps.length>0&&o.startInsidePlace){s.currentPlaceId=o.startInsidePlace;const e={padding:null!==(i=s.animationConfig.autoFitByPlace.padding)&&void 0!==i?i:$$};this.mapvxMap.fitRouteByPlace(s.route,o.startInsidePlace,e)}s.conditions={index:0,coordinatesIndex:0,iconRotation:0,rotatingIcon:!0,startTime:void 0,progress:0,resetTime:!1,waitStartTime:void 0,awaitingSources:!0,animationId:requestAnimationFrame(e=>this.animateStep(e,s)),onFinish:e=>this.prepareForNextStep(e,s)},null===(a=(n=s.animationConfig).callBack)||void 0===a||a.call(n,{isFinished:!1,step:o})}stopAnimation(e){const t=this.resolveInstance(e);t&&"FINISHED"!=t.animationStatus&&(t.animationStatus="FINISHED")}addStepAnimation(e,t,r){var i,n,a;const s=T$(e);this.routes.set(s.id,s),this.lastAddedRouteId=s.id,s.stepAnimationStatus="WAITING",s.route=e;const o=e.steps[0];if(this.addSourcesAndLayersForRoute(s),this.updatePlaceFloorForRouting(s,o.startInsidePlace,o.startInsideFloor),this.setSourceData(s,s.aheadId,e.steps),this.setSourceData(s,s.behindId,[]),this.setLayerPaint(s,s.aheadId,t.aheadConfig),this.setLayerPaint(s,s.behindId,t.behindConfig),this.setLayerPaint(s,s.currentId,t.behindConfig),this.setCurrentDrawConfig(s,t.behindConfig),this.loadStepGeometry(s,o),s.animationConfig=r,s.routeMarker=new _$({coordinate:o.startLocation,floorId:o.startInsideFloor,icon:t.routeIcon,rotationAlignment:"map"}),s.routeMarker.addToMap(this.map),this.cameraFollow(s,o.startLocation),(null===(i=r.autoFitByPlace)||void 0===i?void 0:i.enabled)&&e.steps.length>0&&o.startInsidePlace){s.currentPlaceId=o.startInsidePlace;const t={padding:null!==(n=r.autoFitByPlace.padding)&&void 0!==n?n:$$};this.mapvxMap.fitRouteByPlace(e,o.startInsidePlace,t)}s.conditions={index:0,coordinatesIndex:0,iconRotation:0,rotatingIcon:!0,startTime:void 0,progress:0,resetTime:!1,waitStartTime:void 0,animationId:0,isStepByStep:!0,onFinish:()=>{var t,i,n,a;if(null==s.conditions||null==s.animationConfig||null==s.route)throw new Error("Error: conditions, animationConfig or route should not be null at this point");let{index:o}=s.conditions;o++;const l=s.route.steps.slice(0,o),u=s.route.steps.slice(o),c=s.route.steps[o];if(this.setSourceData(s,s.behindId,l),this.setSourceData(s,s.aheadId,u),this.loadStepGeometry(s,c),s.conditions.index=o,s.stepAnimationStatus="WAITING",o<e.steps.length){const a=e.steps[o];if((null===(t=r.autoFitByPlace)||void 0===t?void 0:t.enabled)&&a&&null!=s.route){const e=a.startInsidePlace||a.endInsidePlace;if(e&&e!==s.currentPlaceId){s.currentPlaceId=e;const t={padding:null!==(i=r.autoFitByPlace.padding)&&void 0!==i?i:$$};this.mapvxMap.fitRouteByPlace(s.route,e,t)}}null===(n=r.callBack)||void 0===n||n.call(r,{isFinished:!1,step:a})}else null===(a=r.callBack)||void 0===a||a.call(r,{isFinished:!0,step:null})}},null===(a=r.callBack)||void 0===a||a.call(r,{isFinished:!1,step:o}),this.syncRouteCollision()}nextStepAnimation(e){const t=this.resolveInstance(e);if(!t)throw new Error("Error: Does not exist step animation");if("NO_ROUTE"===t.stepAnimationStatus)throw new Error("Error: Does not exist step animation");if(null==t.conditions||null==t.animationConfig||null==t.route)throw new Error("Error: conditions, animationConfig or route should not be null at this point");"ANIMATING"===t.stepAnimationStatus&&cancelAnimationFrame(t.conditions.animationId),t.stepAnimationStatus="ANIMATING";const{index:r}=t.conditions;if(!(r<t.route.steps.length))throw new Error("Error: Does not exist next step to animate");t.conditions.coordinatesIndex=0,t.conditions.startTime=void 0,t.conditions.progress=0,t.conditions.rotatingIcon=!0,t.conditions.waitStartTime=void 0,t.conditions.animationId=requestAnimationFrame(e=>this.animateStep(e,t))}previousStepAnimation(e){var t,r,i,n;const a=this.resolveInstance(e);if(!a)throw new Error("Error: Does not exist step animation");if("NO_ROUTE"===a.stepAnimationStatus)throw new Error("Error: Does not exist step animation");if(null==a.conditions||null==a.animationConfig||null==a.route)throw new Error("Error: conditions, animationConfig or route should not be null at this point");"ANIMATING"===a.stepAnimationStatus&&cancelAnimationFrame(a.conditions.animationId),a.stepAnimationStatus="WAITING";let{index:s}=a.conditions;if(!(s>0))throw new Error("previous step doesn't exists to animate");{s--;const e=a.route.steps.slice(0,s),o=a.route.steps.slice(s),l=a.route.steps[s];this.setSourceData(a,a.behindId,e),this.setSourceData(a,a.aheadId,o),this.loadStepGeometry(a,l),l.startInsideFloor!=l.endInsideFloor&&l.startInsideFloor&&this.updatePlaceFloorForRouting(a,l.startInsidePlace,l.startInsideFloor),a.conditions.index=s,a.conditions.coordinatesIndex=0,a.conditions.startTime=void 0,a.conditions.progress=0,a.conditions.rotatingIcon=!0,a.conditions.waitStartTime=void 0,this.setMarkerLngLat(a,l.startLocation);const u=e[e.length-1];if(null!=u){const e=u.coordinates.slice(-2),t=O$.bearingInDegBetween(e[0],e[1]);this.setMarkerRotation(a,t)}else this.setMarkerRotation(a,0);if((null===(t=a.animationConfig.autoFitByPlace)||void 0===t?void 0:t.enabled)&&l&&null!=a.route){const e=l.startInsidePlace||l.endInsidePlace;if(e&&e!==a.currentPlaceId){a.currentPlaceId=e;const t={padding:null!==(r=a.animationConfig.autoFitByPlace.padding)&&void 0!==r?r:$$};this.mapvxMap.fitRouteByPlace(a.route,e,t)}}null===(n=(i=a.animationConfig).callBack)||void 0===n||n.call(i,{isFinished:!1,step:l})}}centerOnCurrentStep(e){var t;const r=this.resolveInstance(e);if(!r)throw new Error("Error: Does not exist step animation");if("NO_ROUTE"===r.stepAnimationStatus)throw new Error("Error: Does not exist step animation");if(null==r.conditions||null==r.animationConfig||null==r.route)throw new Error("Error: conditions, animationConfig or route should not be null at this point");const i=null===(t=r.routeMarker)||void 0===t?void 0:t.getLngLat();if(!i)throw new Error("Error: marker has no position set");this.map.panTo(i)}prepareForNextStep(e,t){var r,i,n,a,s,o;if(null==t.conditions||null==t.animationConfig||null==t.route)throw new Error("Error: conditions, animationConfig or route should not be null at this point");const{index:l}=t.conditions,u=t.route.steps.slice(0,l+1),c=t.route.steps.slice(l+1);if(this.setSourceData(t,t.behindId,u),this.setSourceData(t,t.aheadId,c),l+1<t.route.steps.length){const s=t.route.steps[l+1];this.loadStepGeometry(t,s),t.conditions.startTime=e,t.conditions.index++,t.conditions.coordinatesIndex=0,t.conditions.progress=0,t.conditions.rotatingIcon=!0,t.conditions.awaitingSources=!0,t.conditions.awaitDeadline=void 0;const o=t.route.steps[l],u=this.getFloorKeyForStep(o);if(!t.conditions.pendingFloor&&s.startInsideFloor&&s.startInsideFloor!==u&&(t.conditions.pendingFloor={placeId:s.startInsidePlace,floorKey:s.startInsideFloor,location:s.startLocation}),B$(t.route.steps[l].endLocation,s.startLocation)||(t.conditions.nextFloorFirstStepIndex=l+2),t.conditions.animationId=requestAnimationFrame(e=>this.animateStep(e,t)),(null===(r=t.animationConfig.autoFitByPlace)||void 0===r?void 0:r.enabled)&&s&&null!=t.route){const e=s.startInsidePlace||s.endInsidePlace;if(e&&e!==t.currentPlaceId){t.currentPlaceId=e;const r={padding:null!==(i=t.animationConfig.autoFitByPlace.padding)&&void 0!==i?i:$$};this.mapvxMap.fitRouteByPlace(t.route,e,r)}}t.conditions.pendingFloor?t.conditions.pendingStepCallback=s:null===(a=(n=t.animationConfig).callBack)||void 0===a||a.call(n,{isFinished:!1,step:s})}else{if(this.applyPendingFloor(t),null==t.conditions||null==t.animationConfig)return;t.animationStatus="FINISHED",null===(o=(s=t.animationConfig).callBack)||void 0===o||o.call(s,{isFinished:!0,step:null})}}animateStep(e,t){var r,i,n,a;if(null==t.conditions||null==t.animationConfig||null==t.route)throw new Error("Error: conditions and animationConfig should not be null at this point");let{startTime:s,resetTime:o,progress:l,waitStartTime:u}=t.conditions;const{coordinatesIndex:c,iconRotation:h,index:d,onFinish:p,rotatingIcon:f}=t.conditions,{stepTime:m,minimumSpeed:g,iconRotationTime:y,changeFloorTime:_}=t.animationConfig,v=t.conditions.lastFrameTime;if(t.conditions.lastFrameTime=e,null==s)return t.conditions.startTime=e,void(t.conditions.animationId=requestAnimationFrame(e=>this.animateStep(e,t)));if(t.conditions.awaitingSources){let a=null!==(r=t.conditions.awaitDeadline)&&void 0!==r?r:e+1500;if(null!=v&&e-v>500&&(a+=e-v),t.conditions.awaitDeadline=a,!this.stepSourcesReady(t)&&e<a)return t.conditions.startTime=e,void(t.conditions.animationId=requestAnimationFrame(e=>this.animateStep(e,t)));t.conditions.awaitingSources=!1,t.conditions.awaitDeadline=void 0,t.conditions.startTime=e;const s=t.conditions.pendingStepCallback;if(t.conditions.pendingStepCallback=void 0,t.conditions.animationId=requestAnimationFrame(e=>this.animateStep(e,t)),this.applyPendingFloor(t),null==t.conditions||null==t.animationConfig)return;return void(s&&(null===(n=(i=t.animationConfig).callBack)||void 0===n||n.call(i,{isFinished:!1,step:s})))}if(o)s=e-l,t.conditions.startTime=s,o=!1,t.conditions.resetTime=o;else if(null!=v&&e-v>500){const r=e-v;l=v-s,t.conditions.progress=l,s=e-l,t.conditions.startTime=s,null!=u&&(u+=r,t.conditions.waitStartTime=u)}else l=e-s,t.conditions.progress=l;let x=l/1e3;const b=t.route.steps[d];if(b.coordinates.length<=0)return void(null==p||p(e));const w=b.coordinates[c],E=b.coordinates[c+1];if(null!=w&&null!=E){if(f){const r=O$.bearingInDegBetween(w,E);if(0===y||t.conditions.nextFloorFirstStepIndex===d||Math.abs(r-t.conditions.iconRotation)<15)return t.conditions.nextFloorFirstStepIndex=void 0,this.setMarkerRotation(t,r),t.conditions.startTime=e,t.conditions.rotatingIcon=!1,t.conditions.iconRotation=r,void(t.conditions.animationId=requestAnimationFrame(e=>this.animateStep(e,t)));if(x<y){const e=O$.intermediateAngleBetween(h,r,x/y);return this.setMarkerRotation(t,e),void(t.conditions.animationId=requestAnimationFrame(e=>this.animateStep(e,t)))}return this.setMarkerRotation(t,r),t.conditions.startTime=e,t.conditions.rotatingIcon=!1,t.conditions.iconRotation=r,void(t.conditions.animationId=requestAnimationFrame(e=>this.animateStep(e,t)))}if(b.endInsideFloor&&b.startInsideFloor!==b.endInsideFloor)return null==u?(t.conditions.waitStartTime=e,void(t.conditions.animationId=requestAnimationFrame(e=>this.animateStep(e,t)))):e-u<1e3*_?void(t.conditions.animationId=requestAnimationFrame(e=>this.animateStep(e,t))):(t.conditions.waitStartTime=void 0,t.conditions.isStepByStep?(this.updatePlaceFloorForRouting(t,b.endInsidePlace,b.endInsideFloor),this.setMarkerLngLat(t,b.endLocation)):t.conditions.pendingFloor={placeId:b.endInsidePlace,floorKey:b.endInsideFloor,location:b.endLocation},void(null==p||p(e)));const r=Math.max(b.distance/m,null!=g?g:0);let i=w,n=E,o=O$.distance(i,n);for(;r*x>o;){if(t.conditions.coordinatesIndex+2>=b.coordinates.length)return this.applyReveal(t,this.fractionAlongStep(t,t.conditions.coordinatesIndex+1,0)),void(null==p||p(e));const u=o/r*1e3;s+=u,l-=u,t.conditions.startTime=s,t.conditions.progress=l,x=l/1e3,t.conditions.coordinatesIndex++;const c=b.coordinates[t.conditions.coordinatesIndex+1];if(!B$(n,c)){if(t.conditions.isStepByStep)return t.conditions.rotatingIcon=!0,t.conditions.startTime=e,t.conditions.progress=0,this.applyReveal(t,this.fractionAlongStep(t,t.conditions.coordinatesIndex,0)),void(t.conditions.animationId=requestAnimationFrame(e=>this.animateStep(e,t)));const r=O$.bearingInDegBetween(n,c);t.conditions.iconRotation=r,null===(a=t.routeMarker)||void 0===a||a.setRotation(r)}i=n,n=c,o=O$.distance(i,n)}const c=Math.min(r*x,o),v=0===o?n:O$.intermediatePointBetween(i,n,c/o);return this.applyReveal(t,this.fractionAlongStep(t,t.conditions.coordinatesIndex,c)),this.setMarkerLngLat(t,v),null==t.routeMarker||t.routeMarker.hiddenOnPurpose||t.routeMarker.getElement().isConnected||t.routeMarker.addTo(this.map),void(t.conditions.animationId=requestAnimationFrame(e=>this.animateStep(e,t)))}null==p||p(e)}setMarkerLngLat(e,t){var r,i;(null===(r=e.conditions)||void 0===r?void 0:r.isStepByStep)&&this.cameraFollow(e,t),null===(i=e.routeMarker)||void 0===i||i.setLngLat(t)}setMarkerRotation(e,t){var r,i,n,a,s;return(null===(r=e.conditions)||void 0===r?void 0:r.isStepByStep)&&!(null===(i=e.animationConfig)||void 0===i?void 0:i.keepFixedBearing)&&this.mapvxMap.updateCamera({duration:null===(n=e.animationConfig)||void 0===n?void 0:n.iconRotationTime,animate:!0,bearing:t,center:null===(a=e.routeMarker)||void 0===a?void 0:a.getLngLat()}),null===(s=e.routeMarker)||void 0===s?void 0:s.setRotation(t)}setMarkerFloor(e,t){var r;const i=this.resolveInstance(t);null===(r=null==i?void 0:i.routeMarker)||void 0===r||r.setFloor(e)}cameraFollow(e,t){var r,i,n,a;const s=null!==(i=null===(r=e.animationConfig)||void 0===r?void 0:r.keepFixedBearing)&&void 0!==i&&i;this.mapvxMap.updateCamera(Object.assign({center:t,animate:!0,duration:null===(n=e.animationConfig)||void 0===n?void 0:n.iconRotationTime},s?{}:{bearing:null===(a=e.routeMarker)||void 0===a?void 0:a.getRotation()}))}}var q$,G$,Z$;!function(e){e.cardinal="CARDINAL",e.clock="CLOCK",e.relative="RELATIVE"}(q$||(q$={})),function(e){e.metric="METRIC",e.imperial="IMPERIAL",e.steps="STEPS"}(G$||(G$={})),function(e){e.walking="WALKING",e.driving="DRIVING",e.bicycling="BICYCLING",e.transit="TRANSIT"}(Z$||(Z$={}));class W${constructor(e){var t,r,i,n,a;this.initialLocation=e.initialLocation,this.finalLocation=e.finalLocation,this.preferAccessibleRoute=null!==(t=e.preferAccessibleRoute)&&void 0!==t&&t,this.language=null!==(r=e.language)&&void 0!==r?r:"en",this.unitSystem=null!==(i=e.unitSystem)&&void 0!==i?i:G$.metric,this.announceFormat=null!==(n=e.announceFormat)&&void 0!==n?n:q$.relative,this.userBearing=null!==(a=e.userBearing)&&void 0!==a?a:0}}class H${constructor(e){var t,r;this.polylineWidth=null!==(t=e.polylineWidth)&&void 0!==t?t:10,this.routeStyle=null!==(r=e.routeStyle)&&void 0!==r?r:{type:"Solid",color:"#1257ED"}}}class X${constructor(e){var t,r,i,n,a;this.stepTime=null!==(t=e.stepTime)&&void 0!==t?t:3,this.minimumSpeed=null!==(r=e.minimumSpeed)&&void 0!==r?r:40,this.changeFloorTime=null!==(i=e.changeFloorTime)&&void 0!==i?i:0,this.iconRotationTime=null!==(n=e.iconRotationTime)&&void 0!==n?n:0,this.keepFixedBearing=null!==(a=e.keepFixedBearing)&&void 0!==a&&a,this.callBack=e.callBack,this.autoFitByPlace=e.autoFitByPlace}}class Y${constructor(e){var t,r,i;if(this.aheadPathStyle=null!==(t=e.aheadPathStyle)&&void 0!==t?t:{type:"Solid",color:"#0C0C0C"},this.behindPathStyle=null!==(r=e.behindPathStyle)&&void 0!==r?r:{type:"Solid",color:"#276EF1"},this.polylineWidth=null!==(i=e.polylineWidth)&&void 0!==i?i:10,null!=e.routeIcon)this.routeIcon=e.routeIcon;else{const t=new Image(40,40);null!=e.routeIconConfig?t.src=h$(e.routeIconConfig):t.src=d$,this.routeIcon=t}}get aheadConfig(){return new H$({polylineWidth:this.polylineWidth,routeStyle:this.aheadPathStyle})}get behindConfig(){return new H$({polylineWidth:this.polylineWidth,routeStyle:this.behindPathStyle})}}const K$="#276EF1",J$=["belowLabels","aboveBasemap","top"],Q$=K$,eN=.14,tN=K$,rN=2,iN=.65,nN="aboveBasemap";function aN(e){return Object.assign(Object.assign({},e),{coordinate:Object.assign({},e.coordinate)})}function sN(e,t){return Number.isFinite(e)?Math.max(0,Math.min(1,e)):t}function oN(e,t=!1){var r,i,n,a,s;if(function(e){if(!Number.isFinite(e)||e<=0)throw new Error(`Invalid radiusMeters: ${e}. Must be a positive finite number.`)}(e.radiusMeters),function(e){if(null==e||"object"!=typeof e)throw new Error("Invalid coordinate: expected an object with lat and lng properties.");if(!Number.isFinite(e.lat)||!Number.isFinite(e.lng)||e.lat<-90||e.lat>90||e.lng<-180||e.lng>180)throw new Error(`Invalid coordinate: lat=${e.lat}, lng=${e.lng}. latitude must be in [-90, 90], longitude in [-180, 180], and both finite.`)}(e.coordinate),void 0!==e.renderOrder&&!J$.includes(e.renderOrder))throw new Error(`Invalid renderOrder: ${String(e.renderOrder)}. Must be one of: ${J$.join(", ")}.`);return{id:null!==(r=e.id)&&void 0!==r?r:p$(),coordinate:{lat:e.coordinate.lat,lng:e.coordinate.lng},radiusMeters:e.radiusMeters,fillColor:null!==(i=e.fillColor)&&void 0!==i?i:Q$,fillOpacity:sN(e.fillOpacity,eN),strokeColor:null!==(n=e.strokeColor)&&void 0!==n?n:tN,strokeWidth:null!==(a=e.strokeWidth)&&void 0!==a?a:rN,strokeOpacity:sN(e.strokeOpacity,iN),floorId:e.floorId,renderOrder:null!==(s=e.renderOrder)&&void 0!==s?s:nN,hidden:t}}function lN(e,t,r,i=64){const n=Number.isFinite(i)?Math.max(3,Math.floor(i)):64,a=[],s=t*Math.PI/180,o=r/110574,l=r/(111320*Math.cos(s||1e-6)||1);for(let u=0;u<n;u+=1){const r=u/n*Math.PI*2;a.push([e+l*Math.cos(r),t+o*Math.sin(r)])}return a.push([a[0][0],a[0][1]]),a}function uN(e){if(e instanceof Error)return e;{const t=String(e);return new Error(t)}}class cN{constructor(){this.logger=md.getInstance()}logEvent(e,t={}){this.logger.logEvent(e,this.prepareSegmentation(t))}logError(e,...t){const r=uN(e);this.logger.logError(r,...t)}logWarning(e,...t){const r=uN(e);this.logger.logWarning(r,...t)}logDebug(...e){this.logger.logDebug(...e)}debugLog(...e){this.logger.debugLog(e)}}const hN={enabled:!0,maxTiles:400,ttlMs:18e5,persistToServiceWorker:!0,preloadAdjacentZooms:!1,maxConcurrentTileFetches:6},dN={enabled:!0,minZoomForLabels:Number.NEGATIVE_INFINITY,gapPx:8,verticalGapPx:4,paddingPx:4,maxLabelWidthPx:200};const pN=[];for(let Nj=0;Nj<256;++Nj)pN.push((Nj+256).toString(16).slice(1));let fN;const mN=new Uint8Array(16);const gN={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function yN(e,t,r){if(gN.randomUUID&&!e)return gN.randomUUID();const i=(e=e||{}).random??e.rng?.()??function(){if(!fN){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");fN=crypto.getRandomValues.bind(crypto)}return fN(mN)}();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e,t=0){return(pN[e[t+0]]+pN[e[t+1]]+pN[e[t+2]]+pN[e[t+3]]+"-"+pN[e[t+4]]+pN[e[t+5]]+"-"+pN[e[t+6]]+pN[e[t+7]]+"-"+pN[e[t+8]]+pN[e[t+9]]+"-"+pN[e[t+10]]+pN[e[t+11]]+pN[e[t+12]]+pN[e[t+13]]+pN[e[t+14]]+pN[e[t+15]]).toLowerCase()}(i)}class _N{constructor(e){this.id=yN(),this.legs=[],e.legs.forEach(e=>{const t=new vN(e);this.legs.push(t)})}get steps(){return this.legs.flatMap(e=>e.steps)}get duration(){return this.legs.map(e=>e.duration).reduce((e,t)=>e+t,0)}get length(){return this.legs.map(e=>e.distance).reduce((e,t)=>e+t,0)}}class vN{constructor(e){this.distance=e.distance.value,this.duration=e.duration.value,this.startLocation=e.start_location,this.endLocation=e.end_location,this.steps=[],e.steps.forEach(e=>{const t=new xN(e);this.steps.push(t)})}}class xN{constructor(e){this.distance=e.distance.value,this.duration=e.duration.value,this.startLocation=e.start_location,this.startInsideFloor=e.start_inside_floor,this.startInsidePlace=e.start_inside_place,this.endLocation=e.end_location,this.endInsideFloor=e.end_inside_floor,this.endInsidePlace=e.end_inside_place,this.htmlInstruction=e.html_instructions,this.plainInstruction=e.plain_instructions,this.maneuver=e.maneuver,this.elevatorStep=e.elevator_step,this.showPopup=e.show_popup,this.iconPrefix=e.icon_prefix,this.polyline=new bN(e.polyline)}get geoJsonCoordinates(){return this.polyline.geoJsonCoordinates}get coordinates(){return this.polyline.coordinates}}class bN{constructor(e){this.points=e.points,this.pointsLatLng=e.points_lat_lng,this.overviewPoints=e.overview_points,this.decodedPoints=function(e,t){void 0===t&&(t=5);for(var r=Math.pow(10,t),i=e.length,n=new Array(Math.floor(e.length/2)),a=0,s=0,o=0,l=0;a<i;++l){var u=1,c=0,h=void 0;do{u+=(h=e.charCodeAt(a++)-63-1)<<c,c+=5}while(h>=31);s+=1&u?~(u>>1):u>>1,u=1,c=0;do{u+=(h=e.charCodeAt(a++)-63-1)<<c,c+=5}while(h>=31);o+=1&u?~(u>>1):u>>1,n[l]=[s/r,o/r]}return n.length=l,n}(e.points).map(e=>({lat:e[0],lng:e[1]}))}get geoJsonCoordinates(){return null!=this.overviewPoints?this.overviewPoints.map(e=>[e.lng,e.lat]):this.decodedPoints.map(e=>[e.lng,e.lat])}get coordinates(){return null!=this.overviewPoints?this.overviewPoints:this.decodedPoints}}function wN(e,t){const r=null==e?void 0:e.trim().toLowerCase();return"video"===r||(null==r?void 0:r.startsWith("video/"))?"video":"image"===r||(null==r?void 0:r.startsWith("image/"))?"image":(null==t?void 0:t.trim().toLowerCase().startsWith("video/"))?"video":"image"}class EN{constructor(e){var t,r,i,n,a,s;this.id=e.id,this.name=e.name,this.status=e.status,this.startDate=e.startDate,this.endDate=null!==(t=e.endDate)&&void 0!==t?t:null,this.startTime=e.startTime,this.endTime=null!==(r=e.endTime)&&void 0!==r?r:null;const o=null!==(n=null!==(i=e.sortOrder)&&void 0!==i?i:e.order)&&void 0!==n?n:0;this.sortOrder=o,this.order=o,this.images=(null!==(a=e.images)&&void 0!==a?a:[]).map(e=>{var t,r;return{orientation:e.orientation,order:e.order,mediaType:wN(e.mediaType,e.type),durationSeconds:null!==(t=e.durationSeconds)&&void 0!==t?t:null,url:e.url,type:e.type,alt:null!==(r=e.alt)&&void 0!==r?r:[]}}),this.schedules=(null!==(s=e.schedules)&&void 0!==s?s:[]).map(e=>({dayOfWeek:e.dayOfWeek,startTime:e.startTime,endTime:e.endTime}))}}class SN{constructor(e){var t;this.mapvxId=e.id,this.country=e.country,this.city=e.city,this.title=e.title,this.category=e.category,this.icon=e.icon,this.description=e.description,this.hasPlaces=e.hasPlaces,this.properties=Fs.parseProperties(null!==(t=e.properties)&&void 0!==t?t:[])}}class DN{constructor(e){this.schedule=e.schedules,this.routes=e.realtimeSchedules}}const TN="https://api.mapvx.com";function AN(e){const t=e.startsWith("http://")||e.startsWith("https://")?e:`https://${e}`;return t.endsWith("/")?t.slice(0,-1):t}class PN{constructor(e,t="https://public-api.mapvx.com",r,i){var n,a,s,o;this.lang=e,this.mapvxRequestContext=r;const l=AN(t),u=null===(n=null==i?void 0:i.portalApiUrl)||void 0===n?void 0:n.trim(),c=u?AN(u):l;this.baseUrl=`${l}/api/sdk/v2/`,this.baseUrlPortal=`${c}/api/portal/`;const h=AN((null===(a=null==i?void 0:i.routeApiUrl)||void 0===a?void 0:a.trim())||TN),d=AN((null===(s=null==i?void 0:i.healthApiUrl)||void 0===s?void 0:s.trim())||TN),p=AN((null===(o=null==i?void 0:i.legacyApiUrl)||void 0===o?void 0:o.trim())||TN);this.baseUrlHealth=`${d}/api/sdk/v2/health`,this.oldBaseUrl=`${p}/api/sdk/`,this.routeBaseUrl=`${h}/sdk/`}setLang(e){this.lang=e}getMapVxContextHeaders(e){var t,r,i,n,a,s,o,l;if(!function(e){const t=e.trim().toLowerCase();return!!t&&/^(?:[a-z0-9-]+\.)*mapvx\.(?:com|dev)$/.test(t)}(e)||!this.mapvxRequestContext)return{};const u=this.mapvxRequestContext,c={};return(null===(t=u.baseUrl)||void 0===t?void 0:t.trim())&&(c["X-MapVx-Base-Url"]=u.baseUrl.trim()),(null===(r=u.totemId)||void 0===r?void 0:r.trim())&&(c["X-MapVx-Totem-Id"]=u.totemId.trim()),(null===(i=u.originId)||void 0===i?void 0:i.trim())&&(c["X-MapVx-Origin-Id"]=u.originId.trim()),(null===(n=u.institutionId)||void 0===n?void 0:n.trim())&&(c["X-MapVx-Institution-Id"]=u.institutionId.trim()),(null===(a=u.parentPlace)||void 0===a?void 0:a.trim())&&(c["X-MapVx-Parent-Place"]=u.parentPlace.trim()),(null===(s=u.institutionName)||void 0===s?void 0:s.trim())&&(c["X-MapVx-Institution-Name"]=u.institutionName.trim()),(null===(o=u.fullUrl)||void 0===o?void 0:o.trim())&&(c["X-MapVx-Full-Url"]=u.fullUrl.trim()),(null===(l=u.mvxProduct)||void 0===l?void 0:l.trim())&&(c["mvx-product"]=u.mvxProduct.trim()),c}async fetchFromUrl(e,t,r){const i=new URL(e);i.search=new URLSearchParams(t).toString();const n=i.hostname,a=this.getMapVxContextHeaders(n),s=Object.assign({},r);return Object.keys(a).length>0&&(s.headers=Object.assign(Object.assign({},r.headers&&"object"==typeof r.headers&&!Array.isArray(r.headers)?r.headers:{}),a)),fetch(i.toString(),s)}async fetchTransport(e,t){const r={method:"GET",headers:{"content-type":"application/json",Authorization:`Bearer ${e}`}},i={stopId:t,lang:this.lang};return this.fetchFromUrl(this.oldBaseUrl+"vehiclesWithSchedules",i,r)}async fetchStops(e,t,r){const i={method:"GET",headers:{"content-type":"application/json",Authorization:`Bearer ${e}`}},n={stopId:t,vehicleId:r,lang:this.lang};return this.fetchFromUrl(this.oldBaseUrl+"stops",n,i)}applyMapStyleParams(e,t,r,i){null!=t&&(e.place_id=t),null!=r&&(e.style_ref=r),null!=i&&(e.styleTheme=i)}async fetchMapStyle(e,t,r,i){const n={method:"GET",headers:{"content-type":"application/json",Authorization:`Bearer ${e}`}},a={lang:this.lang};return this.applyMapStyleParams(a,t,r,i),this.fetchFromUrl(this.baseUrl+"mapStyleJson",a,n)}async fetchMapStyleByBearer(e,t,r,i){const n={method:"GET",headers:{"content-type":"application/json",Authorization:`Bearer ${e}`}},a={lang:this.lang};return this.applyMapStyleParams(a,t,r,i),this.fetchFromUrl(this.baseUrlPortal+"mapStyleJson",a,n)}async fetchAnyMapStyle(e,t){const r={method:"GET",headers:{"content-type":"application/json",Authorization:`Bearer ${e}`}},i={lang:this.lang,institution_id:t};return this.fetchFromUrl(this.baseUrlPortal+"mapStyle",i,r)}async fetchAllowedPlaces(e){const t={method:"GET",headers:{"content-type":"application/json",Authorization:`Bearer ${e}`}},r={lang:this.lang};return this.fetchFromUrl(this.baseUrl+"availablePlaces",r,t)}async fetchPlacesFromAnyInstitution(e,t){const r={method:"GET",headers:{"content-type":"application/json",Authorization:`Bearer ${t}`}},i={institution_id:e,lang:this.lang};return this.fetchFromUrl(this.baseUrlPortal+"availablePlaces",i,r)}async fetchPlaceDetail(e,t,r,i,n){const a={method:"GET",headers:{"content-type":"application/json",Authorization:`Bearer ${e}`}},s={place_id:t,lang:this.lang};return void 0!==r&&(s.building=r),void 0!==i?s.floor=i:void 0!==n&&(s.floor=n),this.fetchFromUrl(this.baseUrl+"place",s,a)}async fetchAnyPlaceDetail(e,t,r,i,n){const a={method:"GET",headers:{"content-type":"application/json",Authorization:`Bearer ${e}`}},s={place_id:t,lang:this.lang};return void 0!==r&&(s.building=r),void 0!==i?s.floor=i:void 0!==n&&(s.floor=n),this.fetchFromUrl(this.baseUrlPortal+"place",s,a)}async fetchSubPlaces(e,t){const r={method:"GET",headers:{"content-type":"application/json",Authorization:`Bearer ${t}`}},i={targetPlace:e,lang:this.lang};return this.fetchFromUrl(this.baseUrl+"subPlaces",i,r)}async fetchAnySubPlaces(e,t){const r={method:"GET",headers:{"content-type":"application/json",Authorization:`Bearer ${t}`}},i={place_id:e,lang:this.lang};return this.fetchFromUrl(this.baseUrlPortal+"subPlaces",i,r)}buildRouteParams(e){const t={fromLatLng:void 0,fromBuilding:void 0,fromFloor:void 0,toLatLng:void 0,toBuilding:void 0,toFloor:void 0,fromPlaceId:void 0,toPlaceId:void 0,travelMode:Z$.walking,reducedMobility:e.preferAccessibleRoute?1:0,announceFormat:e.announceFormat,userBearing:e.userBearing,lang:this.lang,unitSystem:e.unitSystem};if("id"in e.initialLocation){const{id:r,buildingId:i,floorId:n,level:a}=e.initialLocation;t.fromPlaceId=r,void 0!==i&&(t.fromBuilding=i),void 0!==n?t.fromFloor=n:void 0!==a&&(t.fromFloor=a)}else{const{lat:r,lng:i,floorId:n,placeId:a}=e.initialLocation;t.fromLatLng=`${r},${i}`,t.fromFloor=n,t.fromBuilding=a}if("id"in e.finalLocation){const{id:r,buildingId:i,floorId:n,level:a}=e.finalLocation;t.toPlaceId=r,void 0!==i&&(t.toBuilding=i),void 0!==n?t.toFloor=n:void 0!==a&&(t.toFloor=a)}else{const{lat:r,lng:i,floorId:n,placeId:a}=e.finalLocation;t.toLatLng=`${r},${i}`,t.toFloor=n,t.toBuilding=a}const r={};for(const i in t){const e=t[i];null!=e&&(r[i]=e)}return r}async fetchRoute(e,t){const r={method:"GET",headers:{"content-type":"application/json",Authorization:`Bearer ${t}`}},i=this.buildRouteParams(e);return this.fetchFromUrl(this.routeBaseUrl+"route",i,r)}async fetchRouteV2(e,t){const r={method:"GET",headers:{"content-type":"application/json",Authorization:`Bearer ${t}`}},i=this.buildRouteParams(e);return this.fetchFromUrl(this.routeBaseUrl+"v2/route",i,r)}async fetchLiveRoute(e,t){const r={method:"GET",headers:{"content-type":"application/json",Authorization:`Bearer ${t}`}},i=this.buildRouteParams(e);return this.fetchFromUrl(this.routeBaseUrl+"liveroute",i,r)}async fetchInstitutions(e){const t={method:"GET",headers:{"content-type":"application/json",Authorization:`Bearer ${e}`}},r={lang:this.lang};return this.fetchFromUrl(this.baseUrl+"institution",r,t)}async fetchSearchResults(e,t,r,i,n,a,s,o){const l={method:"GET",headers:{"content-type":"application/json",Authorization:`Bearer ${r}`}},u={institution_id:e,input:t,lang:this.lang};return i&&(u.parentPlaces=[...i]),n&&(u.origin=n),a&&(u.lat=a),s&&(u.lng=s),o&&(u.floor=o),this.fetchFromUrl(this.baseUrl+"searchPlacesWithFilters",u,l)}async fetchSearchPlacesByTags(e,t,r,i,n,a,s,o,l){const u={method:"GET",headers:{"content-type":"application/json",Authorization:`Bearer ${r}`}},c={institution_id:e,tags:[...t],lang:this.lang};return i&&i.length>0&&(c.parentPlaces=[...i]),n&&(c.sort=n),a&&(c.origin=a),s&&(c.lat=s),o&&(c.lng=o),l&&(c.floor=l),this.fetchFromUrl(this.baseUrl+"searchPlacesByTags",c,u)}async fetchConfiguration(e,t,r){const i={method:"GET",headers:{"content-type":"application/json",Authorization:`Bearer ${e}`}},n={lang:this.lang};return t&&(n.place_id=t),r&&(n.product=r),this.fetchFromUrl(this.baseUrl+"configuration",n,i)}async fetchCampaigns(e,t,r){const i={method:"GET",headers:{"content-type":"application/json",Authorization:`Bearer ${e}`}},n={placeId:t};return r&&(n.kioskId=r),this.fetchFromUrl(this.baseUrl+"campaigns",n,i)}async fetchCategories(e,t){const r={method:"GET",headers:{"content-type":"application/json",Authorization:`Bearer ${e}`}},i={lang:this.lang};return t&&(i.id=t),this.fetchFromUrl(this.baseUrl+"category",i,r)}async fetchRoutesForOrigin(e,t,r,i,n,a){const s={method:"GET",headers:{"content-type":"application/json",Authorization:`Bearer ${e}`}},o={placeId:t,fromPlace:r,announceFormat:i,unitSystem:n,mode:a,lang:this.lang};return this.fetchFromUrl(this.routeBaseUrl+"routes_for_origin",o,s)}async fetchCacheTimestamp(e,t){const r={method:"GET",headers:{"content-type":"application/json",Authorization:`Bearer ${e}`}},i={placeId:t};return this.fetchFromUrl(this.routeBaseUrl+"cache_timestamp",i,r)}async fetchCssCustomization(e,t){const r={method:"GET",headers:{"content-type":"application/json",Authorization:`Bearer ${e}`}},i={type:t};return this.fetchFromUrl(this.baseUrl+"styles/customStyles",i,r)}async postHealth(e,t,r,i,n){const a={method:"POST",headers:{accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify({healthPingId:t,placeId:r,totemId:i,status:n})};return this.fetchFromUrl(this.baseUrlHealth,{},a)}}function IN(e){if("string"==typeof e)return e;if(e&&"object"==typeof e){const t=e;if("string"==typeof t.message)return t.message;if("string"==typeof t.error)return t.error}return JSON.stringify(e)}class CN extends cN{constructor(e,t,r,i,n,a){super(),this.currentLang="en",this.token=e,this.currentLang=t,this.requester=new PN(t,r,n,a),this.cache=null!=i?i:new Rs}setLang(e){this.currentLang=e,this.requester.setLang(e)}prepareSegmentation(e){return Object.assign(Object.assign({},e),{token:this.token})}async fetchAndParseMapStyle(e,t,r){const i=void 0===e&&void 0===t&&void 0===r;if(i&&this.baseStyle)return this.baseStyle;try{const n=await this.requester.fetchMapStyle(this.token,e,t,r);if(!n.ok){const e=await n.json();throw new Error(`Fetch failed with status ${n.status}: ${IN(e)}`)}const a=(await n.json()).style;return i&&(this.baseStyle=a),this.logEvent("fetchAndParseMapStyle"),a}catch(n){throw this.logError(n,{functionName:"fetchAndParseMapStyle"}),new Error("Failed to fetch and parse map style",{cause:n})}}async fetchAndParseMapStyleByBearer(e,t,r,i){try{const n=await this.requester.fetchMapStyleByBearer(t,e,r,i);if(!n.ok){const e=await n.json();throw new Error(`Fetch failed with status ${n.status}: ${IN(e)}`)}const a=(await n.json()).style;return this.logEvent("fetchAndParseMapStyleByBearer"),a}catch(n){throw this.logError(n,{functionName:"fetchAndParseMapStyleByBearer"}),new Error("Failed to fetch and parse map style with bearer token",{cause:n})}}async fetchAndParseAnyMapStyle(e,t){try{const r=await this.requester.fetchAnyMapStyle(t,e);if(!r.ok){const e=await r.json();throw new Error(`Fetch failed with status ${r.status}: ${IN(e)}`)}const i=(await r.json()).style;return this.logEvent("fetchAndParseAnyMapStyle"),i}catch(r){throw this.logError(r,{functionName:"fetchAndParseAnyMapStyle"}),new Error("Failed to fetch and parse map style with bearer token",{cause:r})}}async fetchAndParseInstitutions(){try{const e=await this.requester.fetchInstitutions(this.token);if(!e.ok){const t=await e.json();throw new Error(`Fetch failed with status ${e.status}: ${IN(t)}`)}const t=await e.json(),r=[];for(const n of t){const e=new SN(n);r.push(e)}r.sort((e,t)=>e.title.localeCompare(t.title));const i=r;if(i)return this.logEvent("fetchAndParseInstitutionsV2"),i;throw new Error("No institutions associated to this apiKey")}catch(e){throw this.logError(e,{functionName:"fetchAndParseInstitutionsV2"}),new Error("Failed to fetch and parse institution",{cause:e})}}async fetchAndParsePlaceDetail(e){try{const{id:t,buildingId:r,floorId:i,level:n}=e,a=this.placeCacheKey(t,r),s=this.cache.getPlace(a,this.currentLang);if(null!=s)return this.logEvent("fetchAndParsePlaceDetail",{cached:"true"}),s;const o=await this.requester.fetchPlaceDetail(this.token,t,r,i,n);if(!o.ok){const e=await o.json();throw new Error(`Fetch failed with status ${o.status}: ${IN(e)}`)}const l=await o.json(),u=new Ms(l);return this.cachePlace(u,r),this.logEvent("fetchAndParsePlaceDetail",{cached:"false"}),u}catch(t){throw new Error("Failed to fetch and parse place detail",{cause:t})}}async fetchAndParseAnyPlaceDetail(e,t){try{const{id:r,buildingId:i,floorId:n,level:a}=e,s=this.placeCacheKey(r,i),o=this.cache.getPlace(s,this.currentLang);if(null!=o)return this.logEvent("fetchAndParseAnyPlaceDetail",{cached:"true"}),o;const l=await this.requester.fetchAnyPlaceDetail(t,r,i,n,a);if(!l.ok){const e=await l.json();throw new Error(`Fetch failed with status ${l.status}: ${IN(e)}`)}const u=await l.json(),c=new Ms(u);return this.cachePlace(c,i),this.logEvent("fetchAndParseAnyPlaceDetail",{cached:"false"}),c}catch(r){throw new Error("Failed to fetch and parse place detail with bearer token",{cause:r})}}placeCacheKey(e,t){return null!=t?`${e}_${t}`:e}cachePlace(e,t){this.cache.setPlace(e.mapvxId,e,this.currentLang),null!=e.clientId&&this.cache.setPlace(this.placeCacheKey(e.clientId,t),e,this.currentLang)}async fetchAndParseSubPlaces(e){try{const t=this.cache.getSubPlaces(e,this.currentLang);if(null!=t)return this.logEvent("fetchAndParseSubPlaces",{cached:"true"}),t.data;const r=await this.requester.fetchSubPlaces(e,this.token);if(!r.ok){const e=await r.json();throw new Error(`Fetch failed with status ${r.status}: ${IN(e)}`)}const i=(await r.json()).map(e=>new Ms(e));return this.cache.setSubPlaces(e,this.currentLang,{timestamp:Date.now(),data:i}),this.logEvent("fetchAndParseSubPlaces",{cached:"false"}),i.forEach(e=>{this.cache.hasPlace(e.mapvxId,this.currentLang)||this.cache.setPlace(e.mapvxId,e,this.currentLang),null==e.clientId||this.cache.hasPlace(e.clientId,this.currentLang)||this.cache.setPlace(e.clientId,e,this.currentLang)}),i}catch(t){throw new Error("Failed to fetch and parse subplaces",{cause:t})}}async fetchAndParseAnySubPlaces(e,t){try{const r=await this.requester.fetchAnySubPlaces(e,t);if(!r.ok){const e=await r.json();throw new Error(`Fetch failed with status ${r.status}: ${IN(e)}`)}const i=(await r.json()).map(e=>new Ms(e));return this.logEvent("fetchAndParseAnySubPlaces"),i.forEach(e=>{this.cache.hasPlace(e.mapvxId,this.currentLang)||this.cache.setPlace(e.mapvxId,e,this.currentLang),null==e.clientId||this.cache.hasPlace(e.clientId,this.currentLang)||this.cache.setPlace(e.clientId,e,this.currentLang)}),i}catch(r){throw new Error("Failed to fetch and parse any subplaces",{cause:r})}}async fetchAndParseAvailablePlaces(){try{const e=await this.requester.fetchAllowedPlaces(this.token);if(!e.ok){const t=await e.json();throw new Error(`Fetch failed with status ${e.status}: ${IN(t)}`)}const t=(await e.json()).map(e=>new Ms(e));return this.logEvent("fetchAndParseAvailablePlaces"),t.forEach(e=>{this.cache.hasPlace(e.mapvxId,this.currentLang)||this.cache.setPlace(e.mapvxId,e,this.currentLang),null==e.clientId||this.cache.hasPlace(e.clientId,this.currentLang)||this.cache.setPlace(e.clientId,e,this.currentLang)}),t}catch(e){throw this.logError(e,{functionName:"fetchAndParseAvailablePlaces"}),new Error("Failed to fetch and parse parent places",{cause:e})}}async fetchAndParsePlacesFromInstitution(e,t){try{const r=await this.requester.fetchPlacesFromAnyInstitution(e,t);if(!r.ok){const e=await r.json();throw new Error(`Fetch failed with status ${r.status}: ${IN(e)}`)}const i=(await r.json()).map(e=>new Ms(e));return this.logEvent("fetchAndParsePlacesFromInstitution"),i.forEach(e=>{this.cache.hasPlace(e.mapvxId,this.currentLang)||this.cache.setPlace(e.mapvxId,e,this.currentLang),null==e.clientId||this.cache.hasPlace(e.clientId,this.currentLang)||this.cache.setPlace(e.clientId,e,this.currentLang)}),i}catch(r){throw this.logError(r,{functionName:"fetchAndParsePlacesFromInstitution"}),new Error("Failed to fetch and parse parent places from institution",{cause:r})}}getCachedPlaces(e){const t=[];return e.forEach(e=>{const r=this.cache.getPlace(e,this.currentLang);null!=r&&t.push(r)}),t}getCachedSubPlaces(e){const t=this.cache.getSubPlaces(e,this.currentLang);return null==t?void 0:t.data}async fetchAndParseRoute(e){try{let t="";"id"in e.finalLocation&&(t=e.finalLocation.id);const r=this.cache.getRoute(t);if(null!=r)return this.logEvent("fetchAndParseRoute",{cached:"true"}),this.debugLog("Route cache testing. Found in caché."),r.data;const i=await this.requester.fetchRoute(e,this.token);if(!i.ok){const e=await i.json();throw new Error(`Fetch failed with status ${i.status}: ${IN(e)}`)}const n=await i.json(),a=new _N(n[0]);return this.logEvent("fetchAndParseRoute"),this.debugLog("Route cache testing. Fetched."),a}catch(t){throw new Error("Failed to fetch and parse route",{cause:t})}}async fetchAndParseRouteV2(e){try{let t="";"id"in e.finalLocation&&(t=e.finalLocation.id);const r=this.cache.getRoute(t);if(null!=r)return this.logEvent("fetchAndParseRouteV2",{cached:"true"}),this.debugLog("Route cache testing. Found in caché."),r.data;const i=await this.requester.fetchRouteV2(e,this.token);if(!i.ok){const e=await i.json();throw new Error(`Fetch failed with status ${i.status}: ${IN(e)}`)}const n=await i.json(),a=new _N(n[0]);return this.logEvent("fetchAndParseRouteV2"),this.debugLog("Route cache testing. Fetched."),a}catch(t){throw new Error("Failed to fetch and parse route",{cause:t})}}async fetchAndParseLiveRoute(e){try{const t=await this.requester.fetchLiveRoute(e,this.token);if(!t.ok){const e=await t.json();throw new Error(`Fetch failed with status ${t.status}: ${IN(e)}`)}const r=await t.json(),i=new _N(r[0]);return this.logEvent("fetchAndParseLiveRoute"),this.debugLog("Live route fetched."),i}catch(t){throw new Error("Failed to fetch and parse route",{cause:t})}}async fetchAndParseTransport(e){try{const t=this.cache.getVehicle(e,this.currentLang);if(null!=t&&(Date.now()-t.timestamp<6e4||0===t.data.routes.length))return this.logEvent("fetchAndParseTransport",{cached:"true"}),t.data;const r=await this.requester.fetchTransport(this.token,e);if(!r.ok){const e=await r.json();throw new Error(`Fetch failed with status ${r.status}: ${IN(e)}`)}const i=await r.json();if(i.realtimeSchedules.length>0){const t=i.realtimeSchedules.map(t=>this.fetchAndParseStops(e,t.vehicleId)),r=await Promise.all(t);r.length>0&&i.realtimeSchedules.forEach(e=>{var t,i;e.stops=null!==(i=null===(t=r.find(t=>t.id==e.vehicleId))||void 0===t?void 0:t.places)&&void 0!==i?i:[]})}const n=new DN(i);return this.cache.setVehicle(e,{timestamp:Date.now(),data:n},this.currentLang),this.logEvent("fetchAndParseTransport",{cached:"false"}),n}catch(t){const r=this.cache.getVehicle(e,this.currentLang);if(null!=r){const e=new DN({realtimeSchedules:[],schedules:r.data.schedule});return this.logEvent("fetchAndParseTransport",{cached:"true"}),e}throw new Error("Failed to fetch and parse transport",{cause:t})}}async fetchAndParseStops(e,t){try{const r=this.cache.getStops(e+t,this.currentLang);if(null!=r&&Date.now()-r.timestamp<6e4)return this.logEvent("fetchAndParseStops",{cached:"true"}),{id:t,places:r.data};const i=await this.requester.fetchStops(this.token,e,t);if(!i.ok){const e=await i.json();throw new Error(`Fetch failed with status ${i.status}: ${IN(e)}`)}const n=(await i.json()).map(e=>new Ms(e));return this.cache.setStops(e+t,{timestamp:Date.now(),data:n},this.currentLang),this.logEvent("fetchAndParseStops",{cached:"false"}),{id:t,places:n}}catch(r){throw new Error("Failed to fetch and parse stops",{cause:r})}}async fetchAndParseSearchResults(e,t,r,i,n,a,s){try{const o=await this.requester.fetchSearchResults(e,t,this.token,r,i,n,a,s);if(!o.ok){const e=await o.json();throw new Error(`Fetch failed with status ${o.status}: ${IN(e)}`)}const l=await o.json();return l.map(e=>new Ms(e))}catch(o){throw new Error("Failed to fetch and parse search results",{cause:o})}}async fetchAndParseSearchPlacesByTags(e,t,r,i,n,a,s,o){try{const l=await this.requester.fetchSearchPlacesByTags(e,t,this.token,r,i,n,a,s,o);if(!l.ok){const e=await l.json();throw new Error(`Fetch failed with status ${l.status}: ${IN(e)}`)}const u=(await l.json()).map(e=>new Ms(e));return this.logEvent("fetchAndParseSearchPlacesByTags"),u.forEach(e=>{this.cache.hasPlace(e.mapvxId,this.currentLang)||this.cache.setPlace(e.mapvxId,e,this.currentLang),null==e.clientId||this.cache.hasPlace(e.clientId,this.currentLang)||this.cache.setPlace(e.clientId,e,this.currentLang)}),u}catch(l){throw new Error("Failed to fetch and parse search places by tags",{cause:l})}}async fetchAndParseRoutesFromOrigin(e,t,r,i,n){try{const a=await this.requester.fetchRoutesForOrigin(this.token,e,t,r,i,n);if(!a.ok){const e=await a.json();throw new Error(`Fetch failed with status ${a.status}: ${IN(e)}`)}const{routes:s,accessibleRoutes:o}=await a.json();Object.entries(s).forEach(([e,t])=>{const r=new _N(t[0]);this.cache.setRoute(e,{timestamp:Date.now(),data:r})}),Object.entries(o).forEach(([e,t])=>{const r=new _N(t[0]);this.cache.setAccessibleRoute(e,{timestamp:Date.now(),data:r})}),this.debugLog("Route cache testing. Cache populated!")}catch(a){throw new Error("Failed to fetch and parse routes from origin results",{cause:a})}}async fetchAndParseCacheTimestamp(e){try{const t=await this.requester.fetchCacheTimestamp(this.token,e);if(!t.ok){const e=await t.json();throw new Error(`Fetch failed with status ${t.status}: ${IN(e)}`)}const{lastUpdate:r}=await t.json();return r}catch(t){throw new Error("Failed to fetch and parse cache timestamp",{cause:t})}}cleanRoutesCache(){this.cache.cleanRoutesCache(),this.cache.cleanAccessibleRoutesCache()}async fetchAndParseConfiguration(e,t){try{const r=this.cache.getConfiguration(e||"default",t||"default",this.currentLang);if(null!=r)return this.logEvent("fetchAndParseConfiguration",{cached:"true"}),r.data;const i=await this.requester.fetchConfiguration(this.token,e,t);if(!i.ok){const e=await i.json();throw new Error(`Fetch failed with status ${i.status}: ${IN(e)}`)}const n=await i.json();return this.cache.setConfiguration(e||"default",t||"default",this.currentLang,{timestamp:Date.now(),data:n}),this.logEvent("fetchAndParseConfiguration",{cached:"false"}),n}catch(r){throw this.logError(r,{functionName:"fetchAndParseConfiguration"}),new Error("Failed to fetch and parse configuration",{cause:r})}}async fetchAndParseCampaigns(e,t){try{const r=await this.requester.fetchCampaigns(this.token,e,t);if(!r.ok){const e=await r.json();throw new Error(`Fetch failed with status ${r.status}: ${IN(e)}`)}const i=await r.json();Array.isArray(i)||this.logWarning(new Error("Campaigns response body was not an array"),{functionName:"fetchAndParseCampaigns",receivedType:null===i?"null":typeof i});const n=(Array.isArray(i)?i:[]).map(e=>new EN(e));return this.logEvent("fetchAndParseCampaigns",{count:String(n.length)}),n}catch(r){throw this.logError(r,{functionName:"fetchAndParseCampaigns"}),new Error("Failed to fetch and parse campaigns",{cause:r})}}async fetchAndParseCategories(e){try{const t=this.cache.getCategories(e||"default",this.currentLang);if(null!=t)return this.logEvent("fetchAndParseCategories",{cached:"true"}),t.data;const r=await this.requester.fetchCategories(this.token,e);if(!r.ok){const e=await r.json();throw new Error(`Fetch failed with status ${r.status}: ${IN(e)}`)}const i=await r.json();return this.cache.setCategories(e||"default",this.currentLang,{timestamp:Date.now(),data:i}),this.logEvent("fetchAndParseCategories",{cached:"false"}),i}catch(t){throw new Error("Failed to fetch and parse categories",{cause:t})}}async fetchAndParseCssCustomization(e){try{const t=await this.requester.fetchCssCustomization(this.token,e);if(!t.ok){const e=await t.json();throw new Error(`Fetch failed with status ${t.status}: ${IN(e)}`)}return await t.json()}catch(t){throw new Error("Failed to fetch and parse css customization",{cause:t})}}async postAndParseHealthPing(e,t,r,i){const n=await this.requester.postHealth(this.token,e,t,r,i);if(!n.ok){const e=await n.json();throw new Error(`Post failed with status ${n.status}: ${IN(e)}`)}return await n.json()}}const FN={maxCacheSize:64,maxRequests:6,refinementStrategy:"no-overlap",maxCacheByteSize:void 0},MN=[{type:"directional",color:16777215,intensity:2,position:{x:50,y:100,z:80}},{type:"directional",color:16777215,intensity:1.5,position:{x:-50,y:80,z:-60}},{type:"ambient",color:16777215,intensity:1.5}],kN=e=>{const t=e.match(/\w\w/g);if(!t||t.length<3)throw new Error(`Invalid hex color: ${e}`);return[Number.parseInt(t[0],16),Number.parseInt(t[1],16),Number.parseInt(t[2],16)]};function RN(e,t){var r,i,n,a,s,o;return{yaw:(null!==(r=null==e?void 0:e.yaw)&&void 0!==r?r:0)+(null!==(i=null==t?void 0:t.yaw)&&void 0!==i?i:0),pitch:(null!==(n=null==e?void 0:e.pitch)&&void 0!==n?n:0)+(null!==(a=null==t?void 0:t.pitch)&&void 0!==a?a:0),roll:(null!==(s=null==e?void 0:e.roll)&&void 0!==s?s:0)+(null!==(o=null==t?void 0:t.roll)&&void 0!==o?o:0)}}function LN(e,t){return void 0===e?[t,t,t]:"number"==typeof e?[e,e,e]:[e[0],e[1],e[2]]}function zN(e,t){const r=LN(e,1);return void 0===t?r:LN(t,1)}function BN(e,t,r){var i,n;return null!==(n=null!==(i=r.zoomTransparency)&&void 0!==i?i:null==t?void 0:t.zoomTransparency)&&void 0!==n?n:e.zoomTransparency}function ON(e,t,r){var i,n;return null!==(n=null!==(i=r.routeTransparency)&&void 0!==i?i:null==t?void 0:t.routeTransparency)&&void 0!==n?n:e.routeTransparency}function $N(e,t,r){return t>=e.minX&&t<=e.maxX&&r>=e.minZ&&r<=e.maxZ}function NN(e,t,r,i){const n=function(e,t){return e&&t>=e.zoom?e.opacity:1}(e,r),a=i&&t?t.opacity:1;return Math.min(n,a)}function jN(e,t){return"allFloors"===e.visibility.mode||e.visibility.floorKey===t}function VN(e,t,r,i,n){var a,s,o,l,u,c;const h=(e.x-t.x)/r,d=(e.y-t.y)/r,p=null!==(a=null==i?void 0:i.x)&&void 0!==a?a:0,f=null!==(s=null==i?void 0:i.y)&&void 0!==s?s:0,m=null!==(o=null==i?void 0:i.z)&&void 0!==o?o:0;return[h+p+(null!==(l=null==n?void 0:n.x)&&void 0!==l?l:0),f+(null!==(u=null==n?void 0:n.y)&&void 0!==u?u:0),d+m+(null!==(c=null==n?void 0:n.z)&&void 0!==c?c:0)]}function UN(e){return"Polygon"===e.type?[e.coordinates]:"MultiPolygon"===e.type?e.coordinates:[]}function qN(e){let t;return()=>(null!=t||(t=e().catch(e=>{throw t=void 0,e})),t)}const GN=qN(()=>Promise.all([import("./three.module-D4jhFriS.js"),import("./GLTFLoader-BEKnhytF.js"),import("./DRACOLoader-DboSVweJ.js"),import("./KTX2Loader-D0A8Dn9F.js")]).then(([e,t,r,i])=>({THREE:e,GLTFLoader:t.GLTFLoader,DRACOLoader:r.DRACOLoader,KTX2Loader:i.KTX2Loader}))),ZN=qN(()=>import("./meshopt_decoder.module-B_BTuQmi.js").then(e=>e.MeshoptDecoder)),WN=qN(()=>Promise.all([import("./index-BFX70Qt1.js"),import("./index-BaVRusgW.js"),import("./index-0opt8Rh1.js")]).then(([e,t,r])=>({MapboxOverlay:e.MapboxOverlay,MVTLayer:t.MVTLayer,IconLayer:r.IconLayer,PathLayer:r.PathLayer,TextLayer:r.TextLayer})));const HN=qN(()=>GN().then(e=>{const t=new e.DRACOLoader;t.setDecoderPath("https://mapvx-glb-assets.s3.us-east-1.amazonaws.com/decoders/draco/");const r=new e.GLTFLoader;r.setDRACOLoader(t);const i=new e.KTX2Loader;return i.setTranscoderPath("https://mapvx-glb-assets.s3.us-east-1.amazonaws.com/decoders/transcoder/"),r.setKTX2Loader(i),i.detectSupport(new e.THREE.WebGLRenderer({antialias:!0})),r.setMeshoptDecoder(function(e=ZN){return{supported:"object"==typeof WebAssembly,decodeGltfBufferAsync:async(t,r,i,n,a)=>{const s=await e();return await s.ready,s.decodeGltfBufferAsync(t,r,i,n,a)}}}()),r})),XN=5e5;async function YN(e,t={}){const{timeoutMs:r=XN,onProgress:i}=t,[n,{THREE:a}]=await Promise.all([HN(),GN()]);let s=!1;const o=new a.FileLoader;o.setResponseType("arraybuffer");const l=new Promise((t,r)=>{const l=e=>{s||r(e instanceof Error?e:new Error(String(e)))};o.load(e,r=>{if(s)return;const i=r;try{!function(e,t){if(e.byteLength<12)return;const r=new DataView(e,0,12);if(1179937895!==r.getUint32(0,!0))return;const i=r.getUint32(8,!0);if(i!==e.byteLength)throw new Error(`GLB download is truncated or corrupt: header declares ${i} bytes, received ${e.byteLength}: ${t}`)}(i,e)}catch(o){return void l(o)}n.parse(i,a.LoaderUtils.extractUrlBase(e),e=>{s||t(e.scene)},l)},e=>{s||null==i||i(e)},l)});if(!Number.isFinite(r)||r<=0)try{return await l}finally{s=!0}let u;const c=new Promise((t,i)=>{u=setTimeout(()=>i(new Error(`Timed out loading GLB after ${r}ms: ${e}`)),r)});try{return await Promise.race([l,c])}finally{s=!0,clearTimeout(u),o.abort()}}function KN(e,t){const r=(new e.Box3).setFromObject(t),i=r.getCenter(new e.Vector3);return i.y=r.min.y,i}const JN=["map","alphaMap","aoMap","bumpMap","displacementMap","emissiveMap","envMap","lightMap","metalnessMap","normalMap","roughnessMap","specularMap","gradientMap","clearcoatMap","clearcoatNormalMap","clearcoatRoughnessMap","sheenColorMap","sheenRoughnessMap","transmissionMap","thicknessMap","iridescenceMap","iridescenceThicknessMap","anisotropyMap"];function QN(e,t,r){if(r){const r=t;for(const t of JN){const i=r[t];i instanceof e.Texture&&i.dispose()}}t.dispose()}function ej(e,t){t.traverse(t=>{const r=t;if(!r.isMesh)return;const i=Array.isArray(r.material)?r.material:[r.material];for(const n of i)QN(e,n,!1)})}function tj(e,t){t.traverse(t=>{var r;const i=t;if(!i.isMesh)return;null===(r=i.geometry)||void 0===r||r.dispose();const n=Array.isArray(i.material)?i.material:[i.material];for(const a of n)QN(e,a,!0)})}class rj{constructor(e,t,r,i){var n,a,s;this.currentFloor="",this.threeMod=void 0,this.deckMod=void 0,this.deckOverlay=void 0,this.scene3DGlbScene=void 0,this.scene3DGlbRootByUrl=new globalThis.Map,this.scene3DGlbTemplateById=new globalThis.Map,this.scene3DGlbLightCount=0,this.scene3DModelsGroup=void 0,this.glbRenderer=void 0,this.scene3DRouteCollisionPoints=[],this.spriteIconMapping={},this.spriteAtlasImage=new Image,this.modelsUnloadedByLod=!1,this.glbTemplatesLoadInFlight=!1,this.map=e,this.scene3DConfig=t,this.initialCenter=r,this.onModelsProgress=i,this.deckTileCache=(e=>{var t;const r=(e,t)=>"number"==typeof e&&Number.isFinite(e)&&e>=1?Math.floor(e):t,i="number"==typeof(null==e?void 0:e.maxCacheByteSize)&&Number.isFinite(e.maxCacheByteSize)&&e.maxCacheByteSize>=1?Math.floor(e.maxCacheByteSize):FN.maxCacheByteSize;return{maxCacheSize:r(null==e?void 0:e.maxCacheSize,FN.maxCacheSize),maxRequests:r(null==e?void 0:e.maxRequests,FN.maxRequests),refinementStrategy:null!==(t=null==e?void 0:e.refinementStrategy)&&void 0!==t?t:FN.refinementStrategy,maxCacheByteSize:i}})(null===(n=t.customLayers)||void 0===n?void 0:n.tileCache),this.useTileWorker=null!==(s=null===(a=t.customLayers)||void 0===a?void 0:a.useTileWorker)&&void 0!==s&&s,this.lodThresholds=(e=>{const t=null==e?void 0:e.lod;if(!e||!1===e.enabled||!t||"number"!=typeof t.minZoom||!Number.isFinite(t.minZoom))return null;const r="number"==typeof t.hysteresis&&Number.isFinite(t.hysteresis)&&t.hysteresis>=0?t.hysteresis:.5;return{reloadAtOrAbove:t.minZoom,unloadBelow:t.minZoom-r}})(t.models)}async onMapLoad(){var e,t;try{await this.ensure3DLibs()}catch(n){return void console.error("Failed to load 3D libraries (three/deck.gl)",n)}if(!this.deckMod)return;const r=null===(t=null===(e=this.scene3DConfig.customLayers)||void 0===e?void 0:e.iconLayers)||void 0===t?void 0:t.spriteUrl;r&&await this.loadSpriteAtlas(r).catch(e=>console.error("Failed to load sprite atlas",e)),this.deckOverlay=new this.deckMod.MapboxOverlay({layers:[]}),this.map.addControl(this.deckOverlay),this.hideLayers(this.scene3DConfig.hideLayers),this.installDebugStatsHook();const i=this.scene3DConfig.models;void 0!==i&&!1!==i.enabled&&i.assets.length>0&&this.map.addLayer(this.createGlbCustomLayer()),this.updateDeckOverlay()}reattachToStyle(){if(!this.deckMod)return;this.hideLayers(this.scene3DConfig.hideLayers),this.installDebugStatsHook();const e=this.scene3DConfig.models;void 0!==e&&!1!==e.enabled&&e.assets.length>0&&this.map.addLayer(this.createGlbCustomLayer()),this.updateDeckOverlay()}onZoom(){this.applyModelOpacity(),this.updateLodForZoom()}updateLodForZoom(){if(!this.lodThresholds)return;const e=(t=this.map.getZoom(),r=this.lodThresholds,!(i=this.modelsUnloadedByLod)&&t<r.unloadBelow?"unload":i&&t>=r.reloadAtOrAbove?"reload":"none");var t,r,i;if("unload"===e){if(this.glbTemplatesLoadInFlight)return;this.unloadScene3DModelsForLod()}else"reload"===e&&this.reloadScene3DModelsForLod()}unloadScene3DModelsForLod(){var e,t;const r=null===(e=this.threeMod)||void 0===e?void 0:e.THREE;if(r){this.scene3DModelsGroup&&(ej(r,this.scene3DModelsGroup),null===(t=this.scene3DGlbScene)||void 0===t||t.remove(this.scene3DModelsGroup),this.scene3DModelsGroup=void 0);for(const e of this.scene3DGlbRootByUrl.values())tj(r,e);this.scene3DGlbRootByUrl.clear(),this.scene3DGlbTemplateById.clear(),this.modelsUnloadedByLod=!0,this.map.triggerRepaint()}}async reloadScene3DModelsForLod(){if(!this.glbTemplatesLoadInFlight){this.glbTemplatesLoadInFlight=!0;try{await this.loadScene3DGlbTemplates(),this.placeScene3DModels(),this.modelsUnloadedByLod=!1}catch(e){console.error("Failed to reload declarative GLB models after LOD unload",e)}finally{this.glbTemplatesLoadInFlight=!1}this.updateLodForZoom()}}setRouteCollisionPath(e){this.scene3DRouteCollisionPoints=e,this.recomputeRouteAffectedModels(),this.applyModelOpacity()}onFloorChange(e){const t=null!=e?e:"";t!==this.currentFloor&&(this.currentFloor=t,this.updateDeckOverlay(),this.placeScene3DModels())}refreshOverlay(e){this.currentFloor=null!=e?e:"",this.updateDeckOverlay()}getDebugStats(){var e,t,r,i,n,a,s,o,l,u,c;const h=null===(e=this.glbRenderer)||void 0===e?void 0:e.info,d=h?{geometries:h.memory.geometries,textures:h.memory.textures,programs:null!==(r=null===(t=h.programs)||void 0===t?void 0:t.length)&&void 0!==r?r:0,renderCalls:h.render.calls,triangles:h.render.triangles}:null;let p=null;try{const e=this.deckOverlay,t=null===(n=null===(i=null==e?void 0:e._deck)||void 0===i?void 0:i.layerManager)||void 0===n?void 0:n.layers;if(Array.isArray(t)){const e={};for(const r of t){const t=null===(o=null===(s=null===(a=null==r?void 0:r.state)||void 0===a?void 0:a.tileset)||void 0===s?void 0:s._cache)||void 0===o?void 0:o.size;if("number"==typeof t&&r.id){const i=r.id.split("-sublayer")[0];e[i]=Math.max(null!==(l=e[i])&&void 0!==l?l:0,t)}}p=e}}catch(LO){p=null}return{zoom:this.map.getZoom(),currentFloor:this.currentFloor,modelsUnloadedByLod:this.modelsUnloadedByLod,glbRoots:this.scene3DGlbRootByUrl.size,glbTemplates:this.scene3DGlbTemplateById.size,placedModels:null!==(c=null===(u=this.scene3DModelsGroup)||void 0===u?void 0:u.children.length)&&void 0!==c?c:0,three:d,deckTiles:p,deckTileCache:this.deckTileCache,lodThresholds:this.lodThresholds}}installDebugStatsHook(){const e=globalThis;e.__MVX_SCENE3D_DEBUG__&&(e.__mvxScene3DStats=()=>this.getDebugStats())}uninstallDebugStatsHook(){const e=globalThis;e.__mvxScene3DStats&&delete e.__mvxScene3DStats}dispose(){var e,t;const r=null===(e=this.threeMod)||void 0===e?void 0:e.THREE;if(r){this.scene3DModelsGroup&&(ej(r,this.scene3DModelsGroup),this.scene3DModelsGroup=void 0);for(const e of this.scene3DGlbRootByUrl.values())tj(r,e)}this.scene3DGlbRootByUrl.clear(),this.scene3DGlbTemplateById.clear(),this.scene3DGlbScene=void 0,null===(t=this.glbRenderer)||void 0===t||t.dispose(),this.glbRenderer=void 0,this.uninstallDebugStatsHook()}async ensure3DLibs(){var e,t;null!==(e=this.threeMod)&&void 0!==e||(this.threeMod=await GN()),null!==(t=this.deckMod)&&void 0!==t||(this.deckMod=await WN())}createGlbCustomLayer(){const e=this.threeMod.THREE,t=pS.fromLngLat(this.initialCenter,0),r=t.meterInMercatorCoordinateUnits(),i=(new e.Matrix4).makeTranslation(t.x,t.y,t.z).scale(new e.Vector3(r,-r,r)).multiply((new e.Matrix4).makeRotationX(Math.PI/2));this.scene3DGlbScene=new e.Scene;const n=this.scene3DConfig.models;if(n&&!1!==n.enabled&&n.assets.length>0){const t=function(e){return e.lights&&e.lights.length>0?[...e.lights]:[...MN]}(n);this.scene3DGlbLightCount=function(e,t,r){let i=0;for(const n of r){if("ambient"===n.type){t.add(new e.AmbientLight(n.color,n.intensity)),i++;continue}const r=new e.DirectionalLight(n.color,n.intensity);r.position.set(n.position.x,n.position.y,n.position.z),t.add(r),i++}return i}(e,this.scene3DGlbScene,t)}else this.scene3DGlbLightCount=0;let a,s;this.glbTemplatesLoadInFlight=!0,this.loadScene3DGlbTemplates().then(()=>{this.placeScene3DModels()}).catch(e=>{console.error("Failed to initialize declarative GLB models",e)}).finally(()=>{this.glbTemplatesLoadInFlight=!1,this.updateLodForZoom()});const o=new e.Matrix4;return{id:"3d-glb-models",type:"custom",renderingMode:"3d",onAdd:(t,r)=>{s=new e.Camera,a=new e.WebGLRenderer({canvas:t.getCanvas(),context:r,antialias:!0}),a.autoClear=!1,a.setSize=function(e,t){this.setViewport(0,0,e,t)},this.glbRenderer=a},onRemove:()=>{this.dispose()},render:(e,t)=>{var r;if(!(s&&a&&this.scene3DGlbScene&&this.scene3DModelsGroup&&0!==this.scene3DModelsGroup.children.length))return;const n=this.map.getCanvas(),l=n.width,u=n.height;if(0===l||0===u)return;const c=null===(r=t.defaultProjectionData)||void 0===r?void 0:r.mainMatrix;c&&(a.setSize(l,u),o.fromArray(c).multiply(i),s.projectionMatrix.copy(o),a.resetState(),a.render(this.scene3DGlbScene,s))}}}async loadScene3DGlbTemplates(){var e;const t=null===(e=this.threeMod)||void 0===e?void 0:e.THREE,r=this.scene3DConfig.models;if(!t||!r||!1===r.enabled||0===r.assets.length)return;this.scene3DGlbRootByUrl.clear(),this.scene3DGlbTemplateById.clear();const i=[...new Set(r.assets.map(e=>e.url))],n=new globalThis.Map,a=new l$(rj.GLB_LOAD_CONCURRENCY),s=new globalThis.Map,o=new globalThis.Map;let l=0;const u=i.length,c=e=>{var t;if(!this.onModelsProgress)return;let r=0,n=0;for(const l of i){r+=null!==(t=s.get(l))&&void 0!==t?t:0;const e=o.get(l);n=null==e||null===n?null:n+e}try{this.onModelsProgress({loadedAssets:l,totalAssets:u,loadedBytes:r,totalBytes:n,done:e})}catch(a){console.error("onScene3DModelsProgress callback threw",a)}};await Promise.all(i.map(async e=>{var t,r;await a.acquire();try{this.scene3DGlbRootByUrl.set(e,await YN(e,{onProgress:t=>{s.set(e,t.loaded),o.set(e,t.lengthComputable?t.total:null),c(!1)}}))}catch(i){n.set(e,i)}finally{l++,o.set(e,null!==(r=null!==(t=o.get(e))&&void 0!==t?t:s.get(e))&&void 0!==r?r:0),a.release(),c(!1)}})),c(!0);for(const h of r.assets){const e=this.scene3DGlbRootByUrl.get(h.url);if(!e){console.error(`Failed to load GLB asset "${h.id}" from ${h.url}`,n.get(h.url));continue}const r=KN(t,e);this.scene3DGlbTemplateById.set(h.id,{root:e,center:r})}}placeScene3DModels(){var e,t,r,i,n,a,s,o;const l=null===(e=this.threeMod)||void 0===e?void 0:e.THREE;if(!l||!this.scene3DGlbScene)return;const u=this.scene3DConfig.models;if(!u||!1===u.enabled)return;if(this.scene3DModelsGroup&&(ej(l,this.scene3DModelsGroup),this.scene3DGlbScene.remove(this.scene3DModelsGroup),this.scene3DModelsGroup=void 0),0===this.scene3DGlbTemplateById.size)return;const c=pS.fromLngLat(this.initialCenter,0),h=c.meterInMercatorCoordinateUnits(),d=this.currentFloor,p=new l.Group;p.position.set(null!==(r=null===(t=u.globalOffset)||void 0===t?void 0:t.x)&&void 0!==r?r:0,null!==(n=null===(i=u.globalOffset)||void 0===i?void 0:i.y)&&void 0!==n?n:0,null!==(s=null===(a=u.globalOffset)||void 0===a?void 0:a.z)&&void 0!==s?s:0);for(const f of u.placements){if(!jN(f,d))continue;const e=this.scene3DGlbTemplateById.get(f.assetId);if(!e)continue;const t=u.assets.find(e=>e.id===f.assetId);if(!t)continue;const r=pS.fromLngLat([f.position.lng,f.position.lat],null!==(o=f.position.altitude)&&void 0!==o?o:0),[i,n,a]=VN(r,c,h,t.defaultModelOffset,f.offset),s=new l.Group;s.position.set(i,n,a);const m=RN(t.defaultRotation,f.rotation);s.rotation.set(l.MathUtils.degToRad(m.pitch),l.MathUtils.degToRad(-m.yaw),l.MathUtils.degToRad(m.roll),"YXZ");const[g,y,_]=zN(t.defaultScale,f.scale);s.scale.set(g,y,_);const v=e.root.clone(!0);v.traverse(e=>{const t=e;t.isMesh&&(t.material=Array.isArray(t.material)?t.material.map(e=>e.clone()):t.material.clone())}),v.position.set(-e.center.x,-e.center.y,-e.center.z),s.userData.zoomTransparency=BN(u,t,f),s.userData.routeTransparency=ON(u,t,f);const x=(new l.Box3).setFromObject(v);s.userData.footprint={minX:x.min.x,maxX:x.max.x,minZ:x.min.z,maxZ:x.max.z},s.add(v),p.add(s)}this.scene3DModelsGroup=p,this.scene3DGlbScene.add(p),this.recomputeRouteAffectedModels(),this.applyModelOpacity(),this.map.triggerRepaint()}recomputeRouteAffectedModels(){var e;const t=null===(e=this.threeMod)||void 0===e?void 0:e.THREE,r=this.scene3DModelsGroup;if(!t||!r)return;const i=this.scene3DRouteCollisionPoints.filter(e=>e.floorKey===this.currentFloor),n=pS.fromLngLat(this.initialCenter,0),a=n.meterInMercatorCoordinateUnits(),s=i.map(e=>{const r=pS.fromLngLat([e.lng,e.lat],0),i=(r.x-n.x)/a,s=(r.y-n.y)/a;return new t.Vector3(i,0,s)});r.updateMatrixWorld(!0);const o=new t.Vector3;for(const l of r.children){const e=l.userData.routeTransparency,t=l.userData.footprint;e&&t&&0!==s.length?l.userData.routeAffected=s.some(e=>(o.copy(e),r.localToWorld(o),l.worldToLocal(o),$N(t,o.x,o.z))):l.userData.routeAffected=!1}}applyModelOpacity(){if(!this.scene3DModelsGroup)return;const e=this.map.getZoom();let t=!1;for(const r of this.scene3DModelsGroup.children){const i=NN(r.userData.zoomTransparency,r.userData.routeTransparency,e,!0===r.userData.routeAffected);r.traverse(e=>{const r=e;if(!r.isMesh)return;const n=Array.isArray(r.material)?r.material:[r.material];for(const a of n)a.opacity!==i&&(a.transparent=i<1,a.opacity=i,a.depthWrite=i>=1,t=!0)})}t&&this.map.triggerRepaint()}async loadSpriteAtlas(e){const[t,r]=await Promise.all([fetch(`${e}.json`).then(e=>e.json()),new Promise((t,r)=>{const i=new Image;i.crossOrigin="anonymous",i.onload=()=>t(i),i.onerror=r,i.src=`${e}.png`})]);this.spriteIconMapping=t,this.spriteAtlasImage=r}get deckTileLayerProps(){const{maxCacheSize:e,maxRequests:t,refinementStrategy:r,maxCacheByteSize:i}=this.deckTileCache,n={maxCacheSize:e,maxRequests:t,refinementStrategy:r,loadOptions:{worker:this.useTileWorker}};return void 0!==i&&(n.maxCacheByteSize=i),n}makeElevatedLinesLayer(e,t){var r;const i=this.deckMod;return i?new i.MVTLayer(Object.assign(Object.assign({},this.deckTileLayerProps),{id:"indoor-lines-elevated",data:t.dataUrl,binary:null!==(r=t.binaryData)&&void 0!==r&&r,renderSubLayers:r=>{var n,a,s,o;const l=function(e,t,r){var i;const n=e.filter(e=>{var r,i,n;return"room"===(null===(r=e.properties)||void 0===r?void 0:r.class)&&"empty"!==(null===(i=e.properties)||void 0===i?void 0:i.subclass)&&(null===(n=e.properties)||void 0===n?void 0:n.floor_key)===t}),a=[];for(const s of n){const e=(null===(i=s.properties)||void 0===i?void 0:i.height)?Number(s.properties.height):r;for(const t of UN(s.geometry))for(const r of t)a.push({path:r.map(([t,r])=>[t,r,e])})}return a}(r.data||[],e,null!==(n=t.defaultHeight)&&void 0!==n?n:5);return l.length?new i.PathLayer(Object.assign(Object.assign({},r),{id:`${r.id}-paths`,data:l,getPath:e=>e.path,getColor:kN(null!==(a=t.lineColor)&&void 0!==a?a:"#cbcbcb"),getWidth:null!==(s=t.lineWidth)&&void 0!==s?s:1.5,widthUnits:null!==(o=t.widthUnits)&&void 0!==o?o:"pixels",pickable:!1})):null},updateTriggers:{renderSubLayers:[e]}})):null}makeLabelLayer(e,t,r=!0){var i,n,a;const s=this.deckMod;return s?new s.MVTLayer(Object.assign(Object.assign({},this.deckTileLayerProps),{id:"indoor-labels",data:t.dataUrl,binary:null!==(i=t.binaryData)&&void 0!==i&&i,minZoom:null!==(n=t.minZoom)&&void 0!==n?n:19.5,maxZoom:null!==(a=t.maxZoom)&&void 0!==a?a:24,renderSubLayers:i=>{var n,a,o,l,u,c;const h=function(e,t,r,i){const n=e.filter(e=>{var i,n,a,s,o,l;if("area_name"!==(null===(i=e.properties)||void 0===i?void 0:i.layerName)&&"poi"!==(null===(n=e.properties)||void 0===n?void 0:n.layerName))return!1;if("Point"!==(null===(a=e.geometry)||void 0===a?void 0:a.type))return!1;const u=(null===(s=e.properties)||void 0===s?void 0:s["name:latin"])||(null===(o=e.properties)||void 0===o?void 0:o.name);return!(!u||(null===(l=e.properties)||void 0===l?void 0:l.floor_key)&&e.properties.floor_key!==t||r("logo-"+u))});return n.map(e=>{var t,r,n;return{position:[...e.geometry.coordinates.slice(0,2),(null===(t=e.properties)||void 0===t?void 0:t.height)?Number(e.properties.height):i],text:(null===(r=e.properties)||void 0===r?void 0:r["name:latin"])||(null===(n=e.properties)||void 0===n?void 0:n.name)||""}})}(i.data||[],e,e=>this.map.hasImage(e),null!==(n=t.defaultHeight)&&void 0!==n?n:5);return h.length?new s.TextLayer(Object.assign(Object.assign({},i),{id:`${i.id}-labels`,data:h,getPosition:e=>e.position,getText:e=>e.text,getSize:null!==(a=t.size)&&void 0!==a?a:16,getColor:kN(null!==(o=t.color)&&void 0!==o?o:"#91969b"),outlineColor:r?[255,255,255,255]:[0,0,0,0],outlineWidth:r?4:0,fontSettings:{sdf:r},fontFamily:null!==(l=t.fontFamily)&&void 0!==l?l:"Open Sans, sans-serif",fontWeight:null!==(u=t.fontWeight)&&void 0!==u?u:600,billboard:!0,pickable:!1,characterSet:"auto",wordBreak:"break-word",maxWidth:null!==(c=t.maxWidth)&&void 0!==c?c:150})):null},updateTriggers:{renderSubLayers:[e]}})):null}makePoiIconLayer(e,t){var r,i,n;const a=this.deckMod;return a&&this.spriteIconMapping&&this.spriteAtlasImage?new a.MVTLayer(Object.assign(Object.assign({},this.deckTileLayerProps),{id:"indoor-poi-icons",data:t.dataUrl,binary:null!==(r=t.binaryData)&&void 0!==r&&r,minZoom:null!==(i=t.minZoom)&&void 0!==i?i:17,maxZoom:null!==(n=t.maxZoom)&&void 0!==n?n:24,renderSubLayers:r=>{var i,n,s,o,l;const u=function(e,t,r){const i=e.filter(e=>{var r,i,n;if("Point"!==(null===(r=e.geometry)||void 0===r?void 0:r.type))return!1;if((null===(i=e.properties)||void 0===i?void 0:i.floor_key)&&e.properties.floor_key!==t)return!1;const a=null===(n=e.properties)||void 0===n?void 0:n.subclass;return"elevator"===a||"toilets"===a});return i.map(e=>{var t,i,n,a,s;return{position:[...e.geometry.coordinates.slice(0,2),(null===(t=e.properties)||void 0===t?void 0:t.height)?Number(e.properties.height):r],icon:(a=(null===(i=e.properties)||void 0===i?void 0:i.tags)||"",s=(null===(n=e.properties)||void 0===n?void 0:n.subclass)||"",a.includes("wheelchair")?"accessible_toilets":a.includes("changing_table")?"changing_table":s)}})}(r.data||[],e,null!==(i=t.defaultHeight)&&void 0!==i?i:5);return u.length?new a.IconLayer(Object.assign(Object.assign({},r),{id:`${r.id}-poi-icons`,data:u,iconAtlas:this.spriteAtlasImage,iconMapping:this.spriteIconMapping,getIcon:e=>e.icon,getPosition:e=>e.position,getSize:null!==(n=t.size)&&void 0!==n?n:2,sizeUnits:null!==(s=t.sizeUnits)&&void 0!==s?s:"meters",sizeScale:null!==(o=t.sizeScale)&&void 0!==o?o:1,billboard:null===(l=t.billboard)||void 0===l||l,pickable:!1})):null},updateTriggers:{renderSubLayers:[e]}})):null}makeStoreLogoLayer(e,t){var r,i,n;const a=this.deckMod;return a&&this.spriteIconMapping&&this.spriteAtlasImage?new a.MVTLayer(Object.assign(Object.assign({},this.deckTileLayerProps),{id:"indoor-store-logos",data:t.dataUrl,binary:null!==(r=t.binaryData)&&void 0!==r&&r,minZoom:null!==(i=t.minZoom)&&void 0!==i?i:13,maxZoom:null!==(n=t.maxZoom)&&void 0!==n?n:24,renderSubLayers:r=>{var i,n,s,o;const l=function(e,t,r,i){const n=e.filter(e=>{var i,n,a;if("Point"!==(null===(i=e.geometry)||void 0===i?void 0:i.type))return!1;if((null===(n=e.properties)||void 0===n?void 0:n.floor_key)&&e.properties.floor_key!==t)return!1;const s=null===(a=e.properties)||void 0===a?void 0:a.name;return!!s&&!!r["logo-"+s]});return n.map(e=>{var t,r,n;const a=null===(t=e.properties)||void 0===t?void 0:t.name;return{position:[...e.geometry.coordinates.slice(0,2),(null===(r=e.properties)||void 0===r?void 0:r.height)?Number(e.properties.height):i],icon:"logo-"+a,rotation:(null===(n=e.properties)||void 0===n?void 0:n.rotation_icon)?Number(e.properties.rotation_icon):0}})}(r.data||[],e,this.spriteIconMapping,null!==(i=t.defaultHeight)&&void 0!==i?i:5);return l.length?new a.IconLayer(Object.assign(Object.assign({},r),{id:`${r.id}-store-logos`,data:l,iconAtlas:this.spriteAtlasImage,iconMapping:this.spriteIconMapping,getIcon:e=>e.icon,getPosition:e=>e.position,getAngle:e=>-e.rotation,getSize:e=>{var r;return function(e,t,r){const i=e[t];if(!i)return 10;const n=i.pixelRatio,a=i.width/n,s=i.height/n;return s/Math.max(a,s)*10*(r[t]||1)}(this.spriteIconMapping,e.icon,null!==(r=t.logoScale)&&void 0!==r?r:{})},sizeUnits:null!==(n=t.sizeUnits)&&void 0!==n?n:"meters",sizeScale:null!==(s=t.sizeScale)&&void 0!==s?s:1,billboard:null!==(o=t.billboard)&&void 0!==o&&o,pickable:!1})):null},updateTriggers:{renderSubLayers:[e]}})):null}updateDeckOverlay(){if(!this.deckOverlay||!this.currentFloor)return;if(!this.scene3DConfig.customLayers)return;const{customLayers:e}=this.scene3DConfig,t=[];if(e.elevatedLinesLayer&&t.push(this.makeElevatedLinesLayer(this.currentFloor,e.elevatedLinesLayer)),e.labelsLayer&&t.push(this.makeLabelLayer(this.currentFloor,e.labelsLayer,!1)),e.iconLayers){const{storeLogosLayer:r,poiIconsLayer:i}=e.iconLayers;r&&t.push(this.makeStoreLogoLayer(this.currentFloor,r)),i&&t.push(this.makePoiIconLayer(this.currentFloor,i))}this.deckOverlay.setProps({layers:t})}hideLayers(e){if(e)for(const t of e){const e=this.map.getLayer(t);e&&this.map.setLayoutProperty(e.id,"visibility","none")}}}rj.GLB_LOAD_CONCURRENCY=4;const ij=(e,t,r)=>Math.min(Math.max(e,t),r);const nj=Math.PI/180;class aj{constructor(e){var t,r,i,n;this.dirty=!1,this.moved=!1,this.setCenter=e=>{this.pending.center=e,this.dirty=!0},this.setZoom=e=>{this.pending.zoom=e,this.dirty=!0},this.setBearing=e=>{this.pending.bearing=e,this.dirty=!0},this.setPitch=e=>{this.pending.pitch=e,this.dirty=!0},this.setPadding=e=>{this.pending.padding=e,this.dirty=!0},this.locationToScreenPoint=e=>(this.sync(),this.map.project(e)),this.screenPointToLocation=e=>(this.sync(),this.map.unproject(e)),this.isPointOnMapSurface=e=>{this.sync();const t=this.map.getPitch()*nj;if(t<=0)return!0;const r=this.map.getCanvas().clientHeight;if(!r)return!0;const i=this.map.getVerticalFieldOfView()*nj,n=r/2/Math.tan(i/2),{top:a,bottom:s}=this.pending.padding,o=r/2+(a-s)/2-n/Math.tan(t);return e.y>o},this.restore=()=>{this.moved&&(this.map.jumpTo({center:this.snapshot.center,zoom:this.snapshot.zoom,bearing:this.snapshot.bearing,pitch:this.snapshot.pitch,padding:this.snapshot.padding}),this.pending=Object.assign({},this.snapshot),this.dirty=!1,this.moved=!1)},this.map=e;const a=e.getPadding();this.snapshot={center:e.getCenter(),zoom:e.getZoom(),bearing:e.getBearing(),pitch:e.getPitch(),padding:{top:null!==(t=a.top)&&void 0!==t?t:0,bottom:null!==(r=a.bottom)&&void 0!==r?r:0,left:null!==(i=a.left)&&void 0!==i?i:0,right:null!==(n=a.right)&&void 0!==n?n:0}},this.pending=Object.assign({},this.snapshot)}get center(){return this.pending.center}get zoom(){return this.pending.zoom}sync(){this.dirty&&(this.map.jumpTo({center:this.pending.center,zoom:this.pending.zoom,bearing:this.pending.bearing,pitch:this.pending.pitch,padding:this.pending.padding}),this.dirty=!1,this.moved=!0)}}const sj="mapvx-circles",oj="mapvx-circles-fill",lj="mapvx-circles-line",uj={aboveBasemap:"",belowLabels:"-below-labels",top:"-top"};function cj(e){const t=uj[e];return{fill:oj+t,line:lj+t}}let hj=!1;function dj(e){return null==e?e:"function"==typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))}function pj(e){if(hj)return;const t=new l$(e);!function(e,t){Ef.REGISTERED_PROTOCOLS[e]=t}("cached-tile",(e,r)=>{const i=e.url.replace("cached-tile://","https://");return t.acquire(r.signal).then(()=>fetch(i,{signal:r.signal}).then(e=>{if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);return e.arrayBuffer()}).then(e=>({data:e})).finally(()=>{t.release()}))}),hj=!0}function fj(e,t){if(void 0===e)return 0;if("number"==typeof e)return e;const r=e.match(/^(-?\d*\.?\d+)(px|%|vh|vw)?$/);if(!r)return 0;const i=Number.parseFloat(r[1]);switch(r[2]||"px"){case"px":default:return i;case"%":return i/100*t;case"vh":return i/100*window.innerHeight;case"vw":return i/100*window.innerWidth}}function mj(e,t,r){return e?{top:fj(e.top,r),bottom:fj(e.bottom,r),left:fj(e.left,t),right:fj(e.right,t)}:{top:0,bottom:0,left:0,right:0}}class gj extends cN{get floorSettlePending(){return null!=this.floorSettleDeadline&&this.now()<this.floorSettleDeadline}now(){return"undefined"!=typeof performance?performance.now():Date.now()}constructor(e,t,r){var i,n,a;super(),this.liveRouteTicket=0,this.potentialParentPlaces=[],this.innerFloors=[],this.subPlaces=[],this.currentFloor="",this.baseFilters={},this.capturedBaseFilters=new Set,this.styleSwapGeneration=0,this.markers=[],this.circles=[],this.enableHover=!1,this.hoveredId="unselected",this.failedTiles=new Set,this.tileRetryState=new WeakMap,this.geoLocation=navigator.geolocation,this.floorSettleToken=0,this.floorSettleDeadline=null,this.scene3D=void 0,c$(),this.repository=new CN(r,null!==(i=e.lang)&&void 0!==i?i:"en",e.apiUrl,void 0,e.mapvxRequestContext,{routeApiUrl:e.routeApiUrl,healthApiUrl:e.healthApiUrl,legacyApiUrl:e.legacyApiUrl,portalApiUrl:e.portalApiUrl}),this.token=r,this.authToken=e.authToken,this.currentLang=null!==(n=e.lang)&&void 0!==n?n:"en",this.parentPlaceId=e.parentPlaceId,this.routeController=new U$(this),this.userLocationMarker=void 0,this.watchPositionID=void 0,this.onFloorChange=e.onFloorChange,this.onParentPlaceChange=e.onParentPlaceChange,this.mode=null!==(a=e.mode)&&void 0!==a?a:"2D",this.styleRef=e.styleRef,this.styleTheme=e.styleTheme,this.scene3DConfig=e.scene3D,this.initialCenter=e.center,this.tileCacheConfig=(()=>{const t=Object.assign(Object.assign({},hN),e.tileCache);return t.maxTiles=Math.min(t.maxTiles,1e5),t})(),this.markerLayoutConfig=Object.assign(Object.assign({},dN),e.markerLayout),this.markerLayoutController=new S$(this,this.markerLayoutConfig),this.markerLayoutController.applyLayoutVariables(t),null!=e.parentPlaceId&&this.initialPlaceDetailSetUp(e.parentPlaceId,e.authToken),e.otherPotentialParentPlacesIds&&e.otherPotentialParentPlacesIds.length>0&&this.loadOtherPotentialParentPlaces(e.otherPotentialParentPlacesIds),this.enableHover=e.enableHover||!1,this.initialMapStyleSetUp(e,t)}transformStyleForCaching(e){if(!e)return e;const t=dj(e);if(null==t?void 0:t.sources)for(const r of Object.keys(t.sources)){const e=t.sources[r];e.tiles&&Array.isArray(e.tiles)&&(e.tiles=e.tiles.map(e=>e.startsWith("https://")?e.replace("https://","cached-tile://"):e))}return t}initialPlaceDetailSetUp(e,t){t?this.repository.fetchAndParseAnyPlaceDetail({id:e},t).then(e=>{this.changeParentPlaceTo(e),this.potentialParentPlaces.push(e)}).catch(console.error):this.repository.fetchAndParsePlaceDetail({id:e}).then(e=>{this.changeParentPlaceTo(e),this.potentialParentPlaces.push(e)}).catch(console.error)}loadOtherPotentialParentPlaces(e){Promise.all(e.map(e=>this.repository.fetchAndParsePlaceDetail({id:e}))).then(e=>{this.potentialParentPlaces.push(...e)}).catch(console.error)}subPlacesLoad(e){this.repository.fetchAndParseSubPlaces(e).then(e=>{this.subPlaces=e}).catch(console.error)}initialMapStyleSetUp(e,t){e.institutionId&&e.authToken?this.repository.fetchAndParseAnyMapStyle(e.institutionId,e.authToken).then(r=>this.onMapStyleLoaded(e,t,r)).catch(console.error):this.fetchVenueStyle(e.parentPlaceId,e.styleRef,e.styleTheme).then(r=>this.onMapStyleLoaded(e,t,r)).catch(e=>{this.logError(e,{functionName:"initialMapStyleSetUp"})})}onMapStyleLoaded(e,t,r){var i,n,a,s,o,l,u;const c=this.tileCacheConfig.enabled&&this.tileCacheConfig.persistToServiceWorker;c&&pj(this.tileCacheConfig.maxConcurrentTileFetches);const h=c?this.transformStyleForCaching(r):r,d=Object.assign({container:t,style:h,center:e.center,zoom:e.zoom,pitch:null!==(i=e.pitch)&&void 0!==i?i:0,attributionControl:!1,maplibreLogo:!1,bearingSnap:null!==(n=e.bearingSnap)&&void 0!==n?n:0,cancelPendingTileRequestsWhileZooming:!0,maxTileCacheSize:this.tileCacheConfig.maxTiles},function(e){var t;const r={};if(void 0!==e.bearing&&(r.bearing=e.bearing),void 0!==e.interactive&&(r.interactive=e.interactive),void 0!==e.dragPan&&(r.dragPan=e.dragPan),void 0!==e.scrollZoom&&(r.scrollZoom=e.scrollZoom),void 0!==e.doubleClickZoom&&(r.doubleClickZoom=e.doubleClickZoom),void 0!==e.touchZoomRotate&&(r.touchZoomRotate=e.touchZoomRotate),void 0!==e.keyboard&&(r.keyboard=e.keyboard),!1===e.rotateEnabled&&(r.dragRotate=!1,r.pitchWithRotate=!1),!1===e.pitchEnabled){const i=Math.min(Math.max(null!==(t=e.pitch)&&void 0!==t?t:0,0),180);r.touchPitch=!1,r.pitchWithRotate=!1,r.minPitch=i,r.maxPitch=i}return r}(e));if(e.maxZoom&&(d.maxZoom=e.maxZoom),e.minZoom&&(d.minZoom=e.minZoom),void 0!==e.pixelRatio&&(d.pixelRatio=e.pixelRatio),void 0!==e.fadeDuration&&(d.fadeDuration=e.fadeDuration),e.maxBounds&&e.maxBounds.length>1){const t=f$(e.maxBounds);d.maxBounds=new JF([t[0].lng,t[0].lat],[t[1].lng,t[1].lat])}this.map=new UO(d),this.is3DSceneActive()&&this.scene3DConfig&&(this.scene3D=new rj(this.map,this.scene3DConfig,this.initialCenter,e.onScene3DModelsProgress)),function(e){return!1===e.rotateEnabled}(e)&&(null===(s=null===(a=this.map.touchZoomRotate)||void 0===a?void 0:a.disableRotation)||void 0===s||s.call(a)),this.map.addControl(new GO({showCompass:null===(o=e.showCompass)||void 0===o||o,showZoom:null===(l=e.showZoom)||void 0===l||l}),null!==(u=e.navigationPosition)&&void 0!==u?u:"top-right"),this.map.on("load",()=>{var t,i;null===(t=this.scene3D)||void 0===t||t.onMapLoad(),this.whenStyleUpdates(r),e.lang&&this.setLayersForLanguage(e.lang),null===(i=e.onMapReady)||void 0===i||i.call(e),this.onHover(),this.subscribeToFailedTiles(),this.markerLayoutController.attach()}),this.map.on("styledata",()=>{this.circles.length>0&&this.ensureCircleLayers()}),this.map.on("zoom",()=>{var e;null===(e=this.scene3D)||void 0===e||e.onZoom()}),this.map.on("zoomend",()=>{var t;null===(t=e.onZoomEnd)||void 0===t||t.call(e,this.getZoomLevel())}),this.map.on("rotate",()=>{var t;null===(t=e.onRotate)||void 0===t||t.call(e,this.map.getBearing())}),this.defaultClickListener()}setBaseFilters(e){if(!e)return;const t=["==",["get","public_place"],!0];e.layers.filter(e=>e.id.startsWith("indoor-")).forEach(e=>{const r=e.filter;this.captureDeclaredBaseFilter(e.id,r);const i=this.baseFilters[e.id];if(null!=i){const r=["all",i,t];this.map.setFilter(e.id,r)}else this.map.setFilter(e.id,t)})}captureDeclaredBaseFilter(e,t){if(this.capturedBaseFilters.has(e))return;this.capturedBaseFilters.add(e);const r=null!=t?t:this.safeGetFilter(e);null!=r&&(this.baseFilters[e]=r)}setLayersForLanguage(e){var t,r;const i=["aerodrome_label","mountain_peak","park","place","poi","transportation_name","water_name","waterway"],n=null!==(r=null===(t=this.map.getStyle())||void 0===t?void 0:t.layers)&&void 0!==r?r:[],a=n.filter(e=>{var t;return"symbol"===e.type&&"openmaptiles"===e.source&&i.includes(null!==(t=e["source-layer"])&&void 0!==t?t:"")}).map(e=>e.id);a.forEach(t=>{try{const r=this.map.getLayoutProperty(t,"symbol-placement");this.map.setLayoutProperty(t,"text-field",["case",["has",`name:${e}`],["get",`name:${e}`],["format",["get","name:latin"],"line"===r?" ":"\n",["get","name:nonlatin"]]])}catch(r){this.debugLog("Layer language update failed (layer may not exist)",r)}});const s=n.filter(e=>{var t;return"symbol"===e.type&&"indoorequal"===e.source&&void 0!==(null===(t=e.layout)||void 0===t?void 0:t["text-field"])}).map(e=>e.id);s.forEach(t=>{try{this.map.setLayoutProperty(t,"text-field",["case",["has",`name:${e}`],["get",`name:${e}`],["get","name"]])}catch(r){this.debugLog("Layer language update failed (layer may not exist)",r)}})}prepareSegmentation(e){var t;return Object.assign(Object.assign({},e),{token:this.token,parentPlaceId:null!==(t=this.parentPlaceId)&&void 0!==t?t:"None"})}destroyMap(){var e;this.circles=[],this.markerLayoutController.destroy(),this.clearPendingStyleSwapListener(),this.styleReadyTimer&&(clearTimeout(this.styleReadyTimer),this.styleReadyTimer=void 0),this.floorSettleToken++,this.floorSettleDeadline=null,null===(e=this.scene3D)||void 0===e||e.dispose(),this.map.remove(),this.unsubscribeFromFailedTiles()}clearTileCache(){try{this.failedTiles.clear(),this.map&&this.map.triggerRepaint(),this.logEvent("clearTileCache")}catch(e){this.debugLog("Tile cache clear failed (cache may not exist)",e)}}is3DSceneActive(){var e;return"3D"===this.mode&&!1!==(null===(e=this.scene3DConfig)||void 0===e?void 0:e.enabled)}getCurrentFloor(){var e;return null!==(e=this.currentFloor)&&void 0!==e?e:""}setRouteCollisionPath(e){var t;this.is3DSceneActive()&&(null===(t=this.scene3D)||void 0===t||t.setRouteCollisionPath(e))}changeParentPlaceTo(e,t=!1,r){var i,n,a,s,o,l,u;this.parentPlace=e,this.parentPlaceId=null==e?void 0:e.mapvxId,this.innerFloors=null!==(n=null===(i=null==e?void 0:e.innerFloors)||void 0===i?void 0:i.sort((e,t)=>e.index-t.index))&&void 0!==n?n:[],this.currentFloor=null!==(l=null!==(s=null===(a=this.innerFloors.find(e=>e.defaultFloor))||void 0===a?void 0:a.key)&&void 0!==s?s:null===(o=this.innerFloors[0])||void 0===o?void 0:o.key)&&void 0!==l?l:"",e&&this.subPlacesLoad(e.mapvxId),null===(u=this.scene3D)||void 0===u||u.onFloorChange(this.currentFloor),t&&this.fetchVenueStyle(null==e?void 0:e.mapvxId,this.styleRef,this.styleTheme).then(e=>{const t=this.tileCacheConfig.enabled&&this.tileCacheConfig.persistToServiceWorker?this.transformStyleForCaching(e):e;this.map.setStyle(t),this.resetBaseFilters(),this.whenStyleUpdates(t),null==r||r()}).catch(e=>{this.logError(e,{functionName:"changeParentPlaceTo"}),null==r||r()})}fetchVenueStyle(e,t,r){return this.authToken?this.repository.fetchAndParseMapStyleByBearer(e,this.authToken,t,r):this.repository.fetchAndParseMapStyle(e,t,r)}updatePlaceAndFloor(e,t){var r,i,n,a,s,o;const l=this.potentialParentPlaces.find(t=>t.mapvxId===e);this.parentPlace=l,this.parentPlaceId=null==l?void 0:l.mapvxId,this.innerFloors=null!==(r=null==l?void 0:l.innerFloors.sort((e,t)=>e.index-t.index))&&void 0!==r?r:[],this.currentFloor=null!==(s=null!==(n=null!=t?t:null===(i=this.innerFloors.find(e=>e.defaultFloor))||void 0===i?void 0:i.key)&&void 0!==n?n:null===(a=this.innerFloors[0])||void 0===a?void 0:a.key)&&void 0!==s?s:"",null===(o=this.scene3D)||void 0===o||o.onFloorChange(this.currentFloor)}updateParentPlaceAndFloor(e,t,r){var i,n,a,s;try{this.updatePlaceAndFloor(e,t),this.filterByFloorKey(this.currentFloor),null===(i=this.onParentPlaceChange)||void 0===i||i.call(this,e),null===(n=this.onFloorChange)||void 0===n||n.call(this,null!==(a=this.currentFloor)&&void 0!==a?a:""),this.logEvent("updateParentPlaceAndFloor"),null===(s=null==r?void 0:r.onComplete)||void 0===s||s.call(r)}catch(o){this.debugLog("Parent place/floor update failed",o)}}setLang(e){this.repository.setLang(e),this.currentLang=e,this.map.isStyleLoaded()?this.setLayersForLanguage(e):this.map.once("load",()=>this.setLayersForLanguage(e))}setParentPlace(e,t,r){this.changeParentPlaceTo(e,t,r)}setStyle(e,t,r){const i=++this.styleSwapGeneration,n=()=>this.styleSwapGeneration===i;let a=!1;const s=e=>{a||(a=!0,n()&&this.styleReadyTimer&&(clearTimeout(this.styleReadyTimer),this.styleReadyTimer=void 0),null==r||r(e))};if(this.styleReadyTimer&&clearTimeout(this.styleReadyTimer),this.styleReadyTimer=setTimeout(s,4e3),this.clearPendingStyleSwapListener(),!this.map){const e=new Error("setStyle called before the map finished initializing; wait for the map's load event");return this.logError(e,{functionName:"setStyle"}),void s(e)}this.fetchVenueStyle(this.parentPlaceId,e,t).then(r=>{if(!n())return;this.styleRef=e,this.styleTheme=t;const i=this.tileCacheConfig.enabled&&this.tileCacheConfig.persistToServiceWorker?this.transformStyleForCaching(r):r;this.map.setStyle(i,{diff:!1}),this.resetBaseFilters();const a=()=>{n()?this.hasLoadedStyle()&&(this.map.off("styledata",a),this.pendingStyleSwapListener===a&&(this.pendingStyleSwapListener=void 0),this.whenStyleUpdates(i),this.restoreStyleOverlays(),this.logEvent("setStyle")):this.map.off("styledata",a)};this.pendingStyleSwapListener=a,this.map.on("styledata",a),a(),this.map.once("idle",()=>{n()&&(this.filterByFloorKey(this.currentFloor),s())})}).catch(e=>{n()&&this.clearPendingStyleSwapListener(),this.logError(e,{functionName:"setStyle"}),s(e instanceof Error?e:new Error(String(e)))})}resetBaseFilters(){this.baseFilters={},this.capturedBaseFilters.clear()}restoreStyleOverlays(){const e=(e,t)=>{try{t()}catch(r){this.logError(r,{functionName:"restoreStyleOverlays",step:e})}};if(e("language",()=>this.setLayersForLanguage(this.currentLang)),this.coloredPlacesRequest){const{placeIds:t,color:r}=this.coloredPlacesRequest;e("coloredPlaces",()=>this.setPlacesAsSelected(t,r))}if(this.borderedPlacesRequest){const{placeIds:t,color:r,width:i}=this.borderedPlacesRequest;e("borderedPlaces",()=>this.addBorderToPlaces(t,r,i))}e("scene3D",()=>{var e;return null===(e=this.scene3D)||void 0===e?void 0:e.reattachToStyle()})}clearPendingStyleSwapListener(){var e;this.pendingStyleSwapListener&&(null===(e=this.map)||void 0===e||e.off("styledata",this.pendingStyleSwapListener),this.pendingStyleSwapListener=void 0)}removeParentPlace(){this.changeParentPlaceTo(void 0,!0)}whenStyleUpdates(e){var t;e&&this.setBaseFilters(e),this.routeController.addSourcesAndLayers(),this.refreshCircles(),this.filterByFloorKey(this.currentFloor),null===(t=this.scene3D)||void 0===t||t.refreshOverlay(this.currentFloor)}getMarkers(){const e=this.routeController.getRouteMarkers();return this.userLocationMarker&&e.push(this.userLocationMarker),e.length>0?[...this.markers,...e]:this.markers}addMarker(e){var t;try{if(e.id){const t=this.markers.findIndex(t=>t.id===e.id);if(-1!==t){this.markers[t].remove(),this.markers.splice(t,1),this.logEvent("removeMarker",{markerId:e.id,reason:"duplicate"})}}const r=new _$(Object.assign(Object.assign({},e),{maxLabelWidthPx:null!==(t=e.maxLabelWidthPx)&&void 0!==t?t:this.markerLayoutConfig.maxLabelWidthPx}));return this.floorSettlePending||r.changeFloor(this.currentFloor,this.map,this.isOutdoorFloor(this.currentFloor)),this.markers.push(r),this.markerLayoutController.scheduleRelayout(),this.logEvent("addMarker"),r.id}catch(r){throw new Error("Failed to add marker",{cause:r})}}updateMarker(e){var t;try{const r=this.markers.find(t=>t.id===e.id);return void 0!==r&&(r.updateIcon(e),this.markerLayoutController.invalidateMarker(r),this.markerLayoutController.scheduleRelayout()),this.logEvent("updateMarker"),null!==(t=null==r?void 0:r.id)&&void 0!==t?t:""}catch(r){throw new Error("Failed to update marker",{cause:r})}}updateMarkerPosition(e,t){try{const r=this.markers.find(t=>t.id===e);void 0!==r&&(r.setLngLat(t),this.markerLayoutController.scheduleRelayout()),this.logEvent("updateMarkerPosition")}catch(r){throw new Error("Failed to update marker position",{cause:r})}}showMarker(e){try{const t=this.markers.find(t=>t.id===e);null!==t&&this.map&&(null==t||t.show(this.map),this.markerLayoutController.scheduleRelayout()),this.logEvent("showMarker")}catch(t){this.debugLog("Show marker failed (marker may not exist)",t)}}hideMarker(e){try{const t=this.markers.find(t=>t.id===e);null!==t&&(null==t||t.hide(),this.markerLayoutController.scheduleRelayout()),this.logEvent("hideMarker")}catch(t){this.debugLog("Hide marker failed (marker may not exist)",t)}}removeMarker(e){try{const t=this.markers.find(t=>t.id===e);null!==t&&(null==t||t.remove(),this.markers=this.markers.filter(t=>t.id!==e),this.markerLayoutController.scheduleRelayout()),this.logEvent("removeMarker")}catch(t){throw new Error("Failed to remove marker",{cause:t})}}removeAllMarkers(){try{this.markers.forEach(e=>{e.remove()}),this.markers=[],this.markerLayoutController.scheduleRelayout(),this.logEvent("removeAllMarkers")}catch(e){throw new Error("Failed to remove all markers",{cause:e})}}addCircle(e){try{e.id&&(this.circles=this.circles.filter(t=>t.id!==e.id));const t=oN(e);return this.circles.push(t),this.refreshCircles(),this.logEvent("addCircle"),t.id}catch(t){throw new Error(`Failed to add circle: ${t instanceof Error?t.message:String(t)}`)}}updateCircle(e){try{const t=this.circles.findIndex(t=>t.id===e.id);return-1===t?null:(this.circles[t]=oN(e,this.circles[t].hidden),this.refreshCircles(),this.logEvent("updateCircle"),this.circles[t].id)}catch(t){throw new Error(`Failed to update circle: ${t instanceof Error?t.message:String(t)}`)}}getCircle(e){const t=this.circles.find(t=>t.id===e);return t?aN(t):void 0}getCircles(){return this.circles.map(aN)}hasCircle(e){return this.circles.some(t=>t.id===e)}updateCirclePosition(e,t,r){try{const i=this.circles.find(t=>t.id===e);if(void 0===i)return!1;if(!t)throw new Error("Circle center is required");const{lat:n,lng:a}=t;if(!Number.isFinite(n)||n<-90||n>90)throw new Error(`Invalid latitude: ${n}. Must be between -90 and 90.`);if(!Number.isFinite(a)||a<-180||a>180)throw new Error(`Invalid longitude: ${a}. Must be between -180 and 180.`);if(void 0!==r&&(!Number.isFinite(r)||r<=0))throw new Error(`Invalid radiusMeters: ${r}. Must be a positive finite number.`);return i.coordinate={lat:t.lat,lng:t.lng},void 0!==r&&(i.radiusMeters=r),this.refreshCircles(),this.logEvent("updateCirclePosition"),!0}catch(i){throw new Error(`Failed to update circle position: ${i instanceof Error?i.message:String(i)}`)}}updateCircleStyle(e,t){try{const r=this.circles.find(t=>t.id===e);return void 0!==r&&(void 0!==t.fillColor&&(r.fillColor=t.fillColor),void 0!==t.fillOpacity&&(r.fillOpacity=Math.max(0,Math.min(1,t.fillOpacity))),void 0!==t.strokeColor&&(r.strokeColor=t.strokeColor),void 0!==t.strokeWidth&&(r.strokeWidth=t.strokeWidth),void 0!==t.strokeOpacity&&(r.strokeOpacity=Math.max(0,Math.min(1,t.strokeOpacity))),this.refreshCircles(),this.logEvent("updateCircleStyle"),!0)}catch(r){throw new Error(`Failed to update circle style: ${r instanceof Error?r.message:String(r)}`)}}removeCircle(e){try{this.circles=this.circles.filter(t=>t.id!==e),this.refreshCircles(),this.logEvent("removeCircle")}catch(t){throw new Error("Failed to remove circle",{cause:t})}}removeAllCircles(){try{this.circles=[],this.refreshCircles(),this.logEvent("removeAllCircles")}catch(e){throw new Error("Failed to remove all circles",{cause:e})}}showCircle(e){try{const t=this.circles.find(t=>t.id===e);return void 0!==t&&(t.hidden=!1,this.refreshCircles(),this.logEvent("showCircle"),!0)}catch(t){return this.debugLog("Show circle failed",t),!1}}hideCircle(e){try{const t=this.circles.find(t=>t.id===e);return void 0!==t&&(t.hidden=!0,this.refreshCircles(),this.logEvent("hideCircle"),!0)}catch(t){return this.debugLog("Hide circle failed",t),!1}}circleFeatureCollection(){var e;const t=null!==(e=this.currentFloor)&&void 0!==e?e:"",r=this.isOutdoorFloor(t),i=this.circles.filter(e=>{var i;if(e.hidden)return!1;const n=null!==(i=e.floorId)&&void 0!==i?i:"";return n===t||r&&""===n}).map(e=>({type:"Feature",properties:{id:e.id,fillColor:e.fillColor,fillOpacity:e.fillOpacity,strokeColor:e.strokeColor,strokeWidth:e.strokeWidth,strokeOpacity:e.strokeOpacity,renderOrder:e.renderOrder},geometry:{type:"Polygon",coordinates:[lN(e.coordinate.lng,e.coordinate.lat,e.radiusMeters)]}}));return{type:"FeatureCollection",features:i}}circleBeforeIdFor(e){var t,r,i,n;if("top"===e)return;const a=(null!==(r=null===(t=this.map.getStyle())||void 0===t?void 0:t.layers)&&void 0!==r?r:[]).filter(e=>!function(e){return e.startsWith(oj)||e.startsWith(lj)}(e.id));if("belowLabels"===e)return null===(i=a.find(e=>"symbol"===e.type))||void 0===i?void 0:i.id;let s=-1;return a.forEach((e,t)=>{"symbol"!==e.type&&(s=t)}),null===(n=a.slice(s+1).find(e=>"symbol"===e.type))||void 0===n?void 0:n.id}ensureCircleLayers(){if(this.map)try{this.map.getSource(sj)||this.map.addSource(sj,{type:"geojson",data:this.circleFeatureCollection()});const e=new Set(this.circles.map(e=>e.renderOrder));e.add("aboveBasemap");for(const t of J$){if(!e.has(t))continue;const r=cj(t),i=this.circleBeforeIdFor(t),n=["==",["get","renderOrder"],t];if(this.map.getLayer(r.fill))this.map.moveLayer(r.fill,i);else{const e={id:r.fill,type:"fill",source:sj,filter:n,paint:{"fill-color":["get","fillColor"],"fill-opacity":["get","fillOpacity"]}};this.map.addLayer(e,i)}if(this.map.getLayer(r.line))this.map.moveLayer(r.line,i);else{const e={id:r.line,type:"line",source:sj,filter:n,paint:{"line-color":["get","strokeColor"],"line-width":["get","strokeWidth"],"line-opacity":["get","strokeOpacity"]}};this.map.addLayer(e,i)}}}catch(e){this.debugLog("Layers not added: style not loaded yet, the styledata listener will re-add them",e)}}refreshCircles(){if(this.map&&(0!==this.circles.length||this.map.getSource(sj))){this.ensureCircleLayers();try{const e=this.map.getSource(sj);null==e||e.setData(this.circleFeatureCollection())}catch(e){this.debugLog("Source not found (a new style may still be loading)",e)}}}filterByFloorKey(e){this.currentFloor=e;const t=null!=e?e:"";this.innerFloors.every(t=>t.key!==e)&&""!==e&&this.logEvent("invalidFloorKey",{floorKey:t});const r=this.safeStyleLayers();this.updateFiltersTo(t,r),this.updateMarkersWhenFloorSettles(t,r),this.refreshCircles(),this.routeController.updateRouteLayers(t),this.routeController.updateRouteMarkerVisibility(t)}updateMarkersWhenFloorSettles(e,t){const r=++this.floorSettleToken,i=void 0===t?this.safeStyleLayers():t;if("function"!=typeof requestAnimationFrame||null===i)return this.floorSettleDeadline=null,void this.updateMarkersTo(e);const n=this.floorSettleSourceIds(e,i),a=this.now()+1e3;this.floorSettleDeadline=a;let s=!1,o=0;const l=()=>{if(r!==this.floorSettleToken)return;o++;const t=n.every(e=>this.isSourceSettled(e));t||(s=!0);if(t&&(s||o>=3)||this.now()>=a)return this.floorSettleDeadline=null,void this.updateMarkersTo(e);requestAnimationFrame(l)};requestAnimationFrame(l)}floorSettleSourceIds(e,t){const r=new Set,i=t.find(t=>t.id===`raster-floor-${e}`);return i&&"source"in i&&"string"==typeof i.source&&r.add(i.source),r.add(this.indoorSourceId(t)),[...r]}indoorSourceId(e){for(const t of e)if(t.id.startsWith("indoor-")&&"source"in t&&"string"==typeof t.source)return t.source;return"indoorequal"}isSourceSettled(e){try{return!this.map.getSource(e)||!1!==this.map.isSourceLoaded(e)}catch(YF){return!0}}getContainer(){return this.map.getContainer()}resize(){try{this.map&&(this.map.resize(),this.logEvent("resize"))}catch(e){this.debugLog("Resize failed (map/container may not be ready)",e)}}updateMarkersTo(e){const t=this.isOutdoorFloor(e);this.markers.forEach(r=>{r.changeFloor(e,this.map,t)}),this.markerLayoutController.scheduleRelayout()}updateFiltersTo(e,t){var r,i,n;if(!this.map)return;const a=null!==(r=void 0===t?this.safeStyleLayers():t)&&void 0!==r?r:[],s="raster-floor-",o=a.filter(e=>e.id.startsWith(s)).map(e=>e.id),l=s+e;e&&o.includes(l)&&o.forEach(e=>{this.map.setLayoutProperty(e,"visibility",e===l?"visible":"none")}),a.filter(e=>e.id.startsWith("base-indoor-")).forEach(e=>{this.map.removeLayer(e.id)});const u=null===(i=this.innerFloors.find(t=>t.key===e))||void 0===i?void 0:i.baseFloor,c=a.filter(e=>e.id.startsWith("indoor-"));if(c.forEach(e=>this.captureDeclaredBaseFilter(e.id)),null!=u){const e=null===(n=c[0])||void 0===n?void 0:n.id;c.filter(e=>"fill-extrusion"!==e.type).forEach(t=>{const r=dj(t);r.id="base-"+t.id,this.baseFilters[r.id]=this.baseFilters[t.id],this.map.addLayer(r,e),this.applyLayerFilters(r,u)})}c.forEach(t=>{this.applyLayerFilters(t,e)})}safeGetFilter(e){try{return this.map.getFilter(e)}catch(YF){return}}applyLayerFilters(e,t){var r;e.id.startsWith("base-indoor-")||this.captureDeclaredBaseFilter(e.id);let i=this.baseFilters[e.id];const n=null!=t?t:"",a=["any",["in",n,["get","floor_key"]]],s=["==",["get","public_place"],!0],o=["!",["in",null!==(r=this.parentPlaceId)&&void 0!==r?r:"noRef",["get","is_subplace"]]],l=["in",n,["get","show_in_floor"]];let u=s;null!=this.parentPlaceId&&(u=["any",a,s]);const c=["all",u,["any",o,l]];if(e.id.includes("hover")?i=["in",this.hoveredId,["get","ref"]]:e.id.includes("colored")||"fill"!=e.type&&"fill-extrusion"!==e.type||c.push(["!",["in",this.hoveredId,["get","ref"]]]),this.capturedBaseFilters.add(e.id),null!=i){const t=["all",i,c];this.map.setFilter(e.id,t)}else this.map.setFilter(e.id,c)}getInnerFloors(){return this.innerFloors}isOutdoorFloor(e){var t,r;return!this.parentPlace||null!==(r=null===(t=this.innerFloors.find(t=>t.key===e))||void 0===t?void 0:t.reachableFromGPS)&&void 0!==r&&r}updateCamera(e,t){this.map.once("moveend",t),this.map.easeTo(Object.assign({},e))}setMaxZoom(e,t){var r;this.map.setMaxZoom(e),null===(r=null==t?void 0:t.onComplete)||void 0===r||r.call(t)}setMinZoom(e,t){var r;this.map.setMinZoom(e),null===(r=null==t?void 0:t.onComplete)||void 0===r||r.call(t)}setBearing(e,t){var r;if(Number.isFinite(e)){if(null==t?void 0:t.animate)return t.onComplete&&this.map.once("moveend",t.onComplete),void this.map.rotateTo(e,{duration:600});this.map.setBearing(e),null===(r=null==t?void 0:t.onComplete)||void 0===r||r.call(t)}}setRotationEnabled(e){var t,r,i,n,a,s,o,l,u,c;e?(null===(r=null===(t=this.map.dragRotate)||void 0===t?void 0:t.enable)||void 0===r||r.call(t),null===(n=null===(i=this.map.touchZoomRotate)||void 0===i?void 0:i.enableRotation)||void 0===n||n.call(i),null===(s=null===(a=this.map.keyboard)||void 0===a?void 0:a.enable)||void 0===s||s.call(a)):(null===(l=null===(o=this.map.dragRotate)||void 0===o?void 0:o.disable)||void 0===l||l.call(o),null===(c=null===(u=this.map.touchZoomRotate)||void 0===u?void 0:u.disableRotation)||void 0===c||c.call(u))}setPanEnabled(e){var t,r,i,n;e?null===(r=null===(t=this.map.dragPan)||void 0===t?void 0:t.enable)||void 0===r||r.call(t):null===(n=null===(i=this.map.dragPan)||void 0===i?void 0:i.disable)||void 0===n||n.call(i)}setScrollZoomEnabled(e){var t,r,i,n;e?null===(r=null===(t=this.map.scrollZoom)||void 0===t?void 0:t.enable)||void 0===r||r.call(t):null===(n=null===(i=this.map.scrollZoom)||void 0===i?void 0:i.disable)||void 0===n||n.call(i)}isInsideBounds(e){const t=this.map.getMaxBounds();return null==t||t.contains(e)}setMaxBounds(e,t){var r;if(e.length>1){const t=f$(e);this.map.setMaxBounds(new JF([t[0].lng,t[0].lat],[t[1].lng,t[1].lat]))}null===(r=null==t?void 0:t.onComplete)||void 0===r||r.call(t)}fitCoordinates(e,t){var r,i;if(0===e.length)return;const n=null==t?void 0:t.onComplete;if(1===e.length){const[t]=e;n&&this.map.once("moveend",n),this.map.setCenter({lat:t.lat,lng:t.lng})}else{let a,s,o,l;for(const t of e){const{lat:e,lng:r}=t;a=void 0===a?e:Math.min(a,e),s=void 0===s?r:Math.min(s,r),o=void 0===o?e:Math.max(o,e),l=void 0===l?r:Math.max(l,r)}const u=[null!=s?s:0,null!=a?a:0,null!=l?l:0,null!=o?o:0],c=this.map.getContainer(),h=c.clientWidth,d=c.clientHeight,p=mj(null==t?void 0:t.padding,h,d),f=Object.assign(Object.assign({},t),{padding:p}),m=this.map.getBearing(),g=this.map.getPitch();null!==(r=f.bearing)&&void 0!==r||(f.bearing=m),null!==(i=f.pitch)&&void 0!==i||(f.pitch=g),n&&this.map.once("moveend",n),this.map.fitBounds(u,f)}}easeToCoordinates(e,t){var r,i,n;if(0===e.length)return;const a=null==t?void 0:t.onComplete,s=this.map.getContainer(),o=s.clientWidth,l=s.clientHeight,u=mj(null==t?void 0:t.padding,o,l);if(1===e.length){const[r]=e;return a&&this.map.once("moveend",a),void this.map.easeTo(Object.assign(Object.assign({},t),{center:{lat:r.lat,lng:r.lng},padding:u}))}const c=null!==(r=null==t?void 0:t.bearing)&&void 0!==r?r:this.map.getBearing(),h=null!==(i=null==t?void 0:t.pitch)&&void 0!==i?i:this.map.getPitch(),d={bearing:c,padding:u,containerWidth:o,containerHeight:l,maxZoom:null!==(n=null==t?void 0:t.maxZoom)&&void 0!==n?n:this.map.getMaxZoom(),minZoom:this.map.getMinZoom()};let p=function(e,t){const{bearing:r,padding:i,containerWidth:n,containerHeight:a,maxZoom:s,minZoom:o}=t,l=-r*Math.PI/180,u=Math.cos(l),c=Math.sin(l);let h=1/0,d=1/0,p=-1/0,f=-1/0;for(const E of e){const e=pS.fromLngLat({lat:E.lat,lng:E.lng}),t=e.x*u-e.y*c,r=e.x*c+e.y*u;h=Math.min(h,t),d=Math.min(d,r),p=Math.max(p,t),f=Math.max(f,r)}const m=p-h||Number.EPSILON,g=f-d||Number.EPSILON,y=Math.max(1,n-i.left-i.right),_=Math.max(1,a-i.top-i.bottom),v=Math.min(y/m,_/g),x=ij(Math.log2(v/512),o,s),b=(h+p)/2,w=(d+f)/2;return{center:new pS(b*u+w*c,-b*c+w*u,0).toLngLat(),zoom:x}}(e,d);if(h>0){const t=new aj(this.map);try{p=function(e,t,r,i){const{bearing:n,pitch:a,padding:s,containerWidth:o,containerHeight:l,maxZoom:u,minZoom:c}=i;e.setBearing(n),e.setPitch(a),e.setPadding(s),e.setCenter(r.center),e.setZoom(r.zoom);const h=Math.max(1,o-s.left-s.right),d=Math.max(1,l-s.top-s.bottom);let p={center:r.center,zoom:r.zoom};for(let f=0;f<4;f++){let r=1/0,i=1/0,n=-1/0,a=-1/0,s=!0;for(const u of t){const t=e.locationToScreenPoint(new nS(u.lng,u.lat));if(!e.isPointOnMapSurface(t)){s=!1;break}r=Math.min(r,t.x),i=Math.min(i,t.y),n=Math.max(n,t.x),a=Math.max(a,t.y)}if(!s)break;const o=new Sd((r+n)/2,(i+a)/2);e.setCenter(e.screenPointToLocation(o));const l=Math.max(n-r,1e-6),f=Math.max(a-i,1e-6),m=Math.min(h/l,d/f),g=Math.log2(m);if(e.setZoom(ij(e.zoom+g,c,u)),p={center:e.center,zoom:e.zoom},Math.abs(g)<.01)break}return p}(t,e,p,Object.assign(Object.assign({},d),{pitch:h}))}finally{t.restore()}}a&&this.map.once("moveend",a),this.map.easeTo(Object.assign(Object.assign({},t),{center:p.center,zoom:p.zoom,bearing:c,pitch:h,padding:u}))}fitRouteByPlace(e,t,r){const i=e.steps.filter(e=>e.startInsidePlace===t||e.endInsidePlace===t);if(0===i.length)return;const n=i.flatMap(e=>function(e){var t,r,i,n,a,s;const o=[];(null===(t=e.startLocation)||void 0===t?void 0:t.lat)&&(null===(r=e.startLocation)||void 0===r?void 0:r.lng)&&o.push({lat:e.startLocation.lat,lng:e.startLocation.lng}),(null===(i=e.endLocation)||void 0===i?void 0:i.lat)&&(null===(n=e.endLocation)||void 0===n?void 0:n.lng)&&o.push({lat:e.endLocation.lat,lng:e.endLocation.lng});const l=null===(a=e.polyline)||void 0===a?void 0:a.overviewPoints;return Array.isArray(l)&&l.length>0?l.forEach(e=>{(null==e?void 0:e.lat)&&(null==e?void 0:e.lng)&&o.push({lat:e.lat,lng:e.lng})}):Array.isArray(null===(s=e.polyline)||void 0===s?void 0:s.pointsLatLng)&&e.polyline.pointsLatLng.length>0&&e.polyline.pointsLatLng.forEach(e=>{(null==e?void 0:e.lat)&&(null==e?void 0:e.lng)&&o.push({lat:e.lat,lng:e.lng})}),0===o.length&&e.coordinates?e.coordinates:o}(e));n.length>0&&this.fitCoordinates(n,r)}getZoomLevel(){return this.map.getZoom()}updateFloor(e,t){var r,i,n;try{this.filterByFloorKey(e),null===(r=this.scene3D)||void 0===r||r.onFloorChange(this.currentFloor),null===(i=this.onFloorChange)||void 0===i||i.call(this,e),this.logEvent("updateFloor",{floorId:e}),null===(n=null==t?void 0:t.onComplete)||void 0===n||n.call(t)}catch(a){this.debugLog("Floor update failed",a)}}updatePlaceAndFloorForRouting(e,t){var r;try{this.updatePlaceAndFloor(e,t);const i=this.safeStyleLayers();this.updateFiltersTo(t,i),this.updateMarkersWhenFloorSettles(t,i),null===(r=this.onFloorChange)||void 0===r||r.call(this,t),this.logEvent("updatePlaceAndFloorForRouting",{floorId:t})}catch(i){this.debugLog("Place/floor update for routing failed",i)}}async addRoute(e,t={}){try{this.logEvent("addRoute");const r=new W$(e),i=new H$(t),n=await this.repository.fetchAndParseRoute(r);return this.routeController.addRoute(n,i),n}catch(r){throw new Error("Error: Failed to add route",{cause:r})}}async addLiveRoute(e,t={}){try{this.logEvent("addLiveRoute");const r=new W$(e),i=new H$(t),n=++this.liveRouteTicket,a=await this.repository.fetchAndParseLiveRoute(r);return n!==this.liveRouteTicket||(void 0!==this.liveRouteId&&this.liveRouteId!==a.id&&this.routeController.removeRoute(this.liveRouteId),this.routeController.getRouteIds().includes(a.id)&&this.routeController.removeRoute(a.id),this.routeController.addRoute(a,i),this.liveRouteId=a.id),a}catch(r){const e=r instanceof Error?r.message:String(r);throw new Error(`Error: Failed to add route: ${e}`,{cause:r})}}updateRouteProgress(e,t,r={type:"Solid",color:"#276EF1"}){try{const i=new H$({routeStyle:r});this.routeController.updateRouteProgress(e,t,i)}catch(i){this.debugLog("Route update failed (route may not exist)",i)}}removeRoute(e){try{this.logEvent("removeRoute"),this.routeController.removeRoute(e)}catch(t){this.debugLog("Remove route failed (no route may exist)",t)}this.syncLiveRouteId()}removeRouteById(e){try{this.logEvent("removeRouteById"),this.routeController.removeRoute(e)}catch(t){this.debugLog("Remove route failed (route may not exist)",t)}this.syncLiveRouteId()}removeAllRoutes(){try{this.logEvent("removeAllRoutes"),this.routeController.removeAllRoutes()}catch(e){this.debugLog("Remove all routes failed",e)}this.syncLiveRouteId()}syncLiveRouteId(){void 0===this.liveRouteId||this.routeController.getRouteIds().includes(this.liveRouteId)||(this.liveRouteId=void 0)}getActiveRouteIds(){return this.routeController.getRouteIds()}addPopOver(e){const t=e.placeId;if(void 0!==t){const e=this.subPlaces.find(e=>e.clientId===t||e.mapvxId===t);void 0!==e&&(new s$).setLngLat(e.position).setText(e.title).addTo(this.map)}return""}removePopOver(e){throw Error("Not implemented")}startClickListener(e){this.clickCallback=e}stopClickListener(){this.clickCallback=void 0}defaultClickListener(){this.map.on("click",async e=>{var t,r;const i=this.map.queryRenderedFeatures(e.point).filter(e=>{var t;return"room"===e.properties.class&&(null===(t=e.properties)||void 0===t?void 0:t.floor_key)===this.currentFloor}),n=i[0],a=null==n?void 0:n.properties.ref;if(null!=a&&"string"==typeof a&&a.length>0){console.log("touchedFeature",a);let e=this.subPlaces.find(e=>e.mapvxId===a);if(void 0===e)for(const t of this.potentialParentPlaces){const r=this.repository.getCachedSubPlaces(t.mapvxId);if(r&&(e=r.find(e=>e.mapvxId===a),void 0!==e))break}if(void 0===e){const t=this.repository.getCachedPlaces([a]);0===t.length?(console.log("fetching place detail from server",a),e=await this.repository.fetchAndParsePlaceDetail({id:a})):(console.log("using cached place detail",a),e=null==t?void 0:t[0])}console.log("clickedPlace",null==e?void 0:e.title);const i=null!==(r=null!==(t=null==e?void 0:e.mapvxId)&&void 0!==t?t:null==e?void 0:e.clientId)&&void 0!==r?r:"";void 0!==e&&this.clickCallback&&this.clickCallback(i)}})}onHover(){this.enableHover&&(this.map.on("mousemove","hoverable",e=>{var t;const r=null===(t=e.features)||void 0===t?void 0:t.find(e=>{var t,r;return(null===(t=e.properties.ref)||void 0===t?void 0:t.length)>0&&(null===(r=e.properties)||void 0===r?void 0:r.floor_key)===this.currentFloor}),i=null==r?void 0:r.properties.ref;null!=i&&"string"==typeof i&&i.length>0?(this.hoveredId=i,this.updateFiltersTo(this.currentFloor)):void 0===i&&"unselected"!==this.hoveredId&&(this.hoveredId="unselected",this.updateFiltersTo(this.currentFloor))}),this.map.on("mouseleave","hoverable",()=>{this.hoveredId="unselected",this.updateFiltersTo(this.currentFloor)}))}setPlacesAsSelected(e,t){try{this.coloredPlacesRequest={placeIds:[...e],color:t},this.hasLayer("indoor-colored-places")||this.createColoredPlacesLayer();const r=this.createBasicFilters(),i=e.map(e=>["==",["get","ref"],e]),n=["any",...i],a=["all",n,r];if(this.map.setFilter("indoor-colored-places",a),this.capturedBaseFilters.add("indoor-colored-places"),this.baseFilters["indoor-colored-places"]=n,void 0!==t){const e=this.map.getLayer("indoor-colored-places");switch(null==e?void 0:e.type){case"fill":this.map.setPaintProperty("indoor-colored-places","fill-color",t);break;case"fill-extrusion":this.map.setPaintProperty("indoor-colored-places","fill-extrusion-color",t)}}}catch(r){this.debugLog("Place selection failed (layer may not exist)",r)}}is3DStyle(){return this.map.getStyle().layers.some(e=>"fill-extrusion"===e.type)}createColoredPlacesLayer(){if(this.is3DStyle()){const e={id:"indoor-colored-places",type:"fill-extrusion",source:"indoorequal","source-layer":"area",filter:["all",["has","ref"],["==",["get","ref"],"unselected"]],paint:{"fill-extrusion-height":2.5,"fill-extrusion-color":K$,"fill-extrusion-opacity":.8}};this.map.addLayer(e)}else{const e={id:"indoor-colored-places",type:"fill",source:"indoorequal","source-layer":"area",filter:["all",["has","ref"],["==",["get","ref"],"unselected"]],paint:{"fill-color":K$}};this.map.addLayer(e)}}createBasicFilters(){var e,t;const r=["==",["get","public_place"],!0],i=["!",["in",null!==(e=this.parentPlaceId)&&void 0!==e?e:"noRef",["get","is_subplace"]]],n=null!==(t=this.currentFloor)&&void 0!==t?t:"noRef",a=["in",n,["get","floor_key"]],s=["in",n,["get","show_in_floor"]];let o=r;null!=this.parentPlaceId&&(o=["any",a,r]);return["all",o,["any",i,s]]}hasLayer(e){return void 0!==this.map.getLayer(e)}clearColoredPlaces(){if(this.coloredPlacesRequest=void 0,this.hasLayer("indoor-colored-places")){const e=["==",["get","ref"],"unselected"];this.capturedBaseFilters.add("indoor-colored-places"),this.baseFilters["indoor-colored-places"]=e,this.map.setFilter("indoor-colored-places",e)}}async startAnimateRoute(e,t={},r={}){try{let i;if(e instanceof _N)i=e;else{const t=new W$(e);i=await this.repository.fetchAndParseRoute(t)}const n=new Y$(t),a=new X$(r);return this.routeController.startAnimating(i,n,a),i}catch(i){throw new Error("Error: Failed to start animating route",{cause:i})}}async startAnimateRouteV2(e,t={},r={}){try{let i;if(e instanceof _N)i=e;else{const t=new W$(e);i=await this.repository.fetchAndParseRouteV2(t)}const n=new Y$(t),a=new X$(r);return this.routeController.startAnimating(i,n,a),i}catch(i){throw new Error("Error: Failed to start animating route",{cause:i})}}pauseAnimateRoute(e){try{this.routeController.pauseAnimation(e),this.logEvent("pauseAnimateRoute")}catch(t){this.debugLog("Pause animation failed (no animation may be running)",t)}}resumeAnimateRoute(e){try{this.routeController.resumeAnimation(e),this.logEvent("resumeAnimateRoute")}catch(t){this.debugLog("Resume animation failed (no animation may be paused)",t)}}restartAnimateRoute(e){try{this.routeController.restartAnimation(e),this.logEvent("restartAnimateRoute")}catch(t){this.debugLog("Restart animation failed (no animation may exist)",t)}}stopAnimateRoute(){this.logWarning(new Error("Not implemented"),{functionName:"stopAnimateRoute"})}async addStepAnimation(e,t={},r={}){try{let i;if(e instanceof _N)i=e;else{const t=new W$(e);i=await this.repository.fetchAndParseRoute(t)}const n=new Y$(t),a=new X$(r);return this.routeController.addStepAnimation(i,n,a),this.logEvent("addStepAnimation"),i}catch(i){throw new Error("Error: Failed to add step animation",{cause:i})}}async addStepAnimationV2(e,t={},r={}){try{let i;if(e instanceof _N)i=e;else{const t=new W$(e);i=await this.repository.fetchAndParseRouteV2(t)}const n=new Y$(t),a=new X$(r);return this.routeController.addStepAnimation(i,n,a),this.logEvent("addStepAnimationV2"),i}catch(i){throw new Error("Error: Failed to add step animation",{cause:i})}}nextStepAnimation(e){try{this.routeController.nextStepAnimation(e),this.logEvent("nextStepAnimation")}catch(t){throw new Error("Error: Failed to animate step",{cause:t})}}previousStepAnimation(e){try{this.routeController.previousStepAnimation(e),this.logEvent("previousStepAnimation")}catch(t){const e=t instanceof Error?t.message:String(t);throw new Error("Error: Failed to prepare to animate previous step, "+e)}}centerOnCurrentStepAnimation(e){try{this.routeController.centerOnCurrentStep(e),this.logEvent("centerOnCurrentStepAnimation")}catch(t){const e=t instanceof Error?t.message:String(t);throw new Error("Error: Failed to center on current step animation, "+e)}}addUserLocationTracking(e,t,r){let i;if(null!=r)i=r;else{const e=new Image(40,40);e.src="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20aria-hidden%3D%22false%22%20role%3D%22img%22%3E%3Ccircle%20cx%3D%2212%22%20cy%3D%2212%22%20r%3D%226%22%20fill%3D%22var(--icon-fill%2C%20%23007aff)%22%20stroke%3D%22var(--icon-stroke%2C%20%23ffffff)%22%20stroke-width%3D%222%22/%3E%3C/svg%3E",i=e}const n=new _$({coordinate:{lat:0,lng:0},icon:i,text:""});n.addToMap(this.map),this.userLocationMarker=n,this.markerLayoutController.scheduleRelayout();this.geoLocation=null!=t?t:navigator.geolocation,this.watchPositionID=this.geoLocation.watchPosition(e=>{n.setLngLat([e.coords.longitude,e.coords.latitude]),this.markerLayoutController.scheduleRelayout()},e=>{console.error("Error getting user location:",e)},{enableHighAccuracy:e})}removeUserLocationTracking(){void 0!==this.userLocationMarker&&(this.userLocationMarker.remove(),this.userLocationMarker=void 0,this.markerLayoutController.scheduleRelayout(),this.watchPositionID&&(this.geoLocation.clearWatch(this.watchPositionID),this.watchPositionID=void 0))}getBearing(){return this.map.getBearing()}addBorderToPlaces(e,t,r){try{this.borderedPlacesRequest={placeIds:[...e],color:t,width:r},this.hasLayer("indoor-bordered-places")||this.createBorderedPlacesLayer();const i=this.createBasicFilters(),n=e.map(e=>["==",["get","ref"],e]),a=["any",...n],s=["all",a,i];this.map.setFilter("indoor-bordered-places",s),this.capturedBaseFilters.add("indoor-bordered-places"),this.baseFilters["indoor-bordered-places"]=a,void 0!==t&&void 0!==r&&(this.map.setPaintProperty("indoor-bordered-places","line-color",t),this.map.setPaintProperty("indoor-bordered-places","line-width",r))}catch(i){throw new Error("Failed to add border to places",{cause:i})}}createBorderedPlacesLayer(){const e={id:"indoor-bordered-places",type:"line",source:"indoorequal","source-layer":"area",filter:["all",["has","ref"],["==",["get","ref"],"unselected"]],paint:{"line-color":K$,"line-width":4}};this.map.addLayer(e)}clearBorderedPlaces(){if(this.borderedPlacesRequest=void 0,this.hasLayer("indoor-bordered-places")){const e=["==",["get","ref"],"unselected"];this.capturedBaseFilters.add("indoor-bordered-places"),this.baseFilters["indoor-bordered-places"]=e,this.map.setFilter("indoor-bordered-places",e)}}onWebGLContextLost(e){var t,r;e.originalEvent.preventDefault(),console.warn("Contexto WebGL perdido 😢");const i=null===(t=null==this?void 0:this.map)||void 0===t?void 0:t.getCanvas(),n=(null==i?void 0:i.getContext("webgl"))||(null==i?void 0:i.getContext("webgl2"));if(n&&n.isContextLost()){i.addEventListener("webglcontextrestored",()=>{console.debug("Contexto WebGL restaurado, forzando re-render"),this.map.triggerRepaint(),this.failedTiles.clear()},{once:!0});const e=n.getExtension("WEBGL_lose_context");null===(r=null==e?void 0:e.restoreContext)||void 0===r||r.call(e)}}onWebGLContextRestored(){console.debug("Evento webglcontextrestored recibido, haciendo map.redraw()"),this.map.redraw(),this.failedTiles.clear()}onSourceData(e){var t;if("vector"===e.source.type&&"indoorequal"===e.sourceId&&e.tile&&!e.isSourceLoaded){const r=null===(t=e.tile)||void 0===t?void 0:t.state;"errored"!==r&&"expired"!==r||this.failedTiles.add(e.tile)}}onSourceDataAbort(e){"vector"===e.source.type&&"indoorequal"===e.sourceId&&e.tile&&this.failedTiles.delete(e.tile)}safeStyleLayers(){var e,t,r;try{return null!==(r=null===(t=null===(e=this.map)||void 0===e?void 0:e.getStyle())||void 0===t?void 0:t.layers)&&void 0!==r?r:null}catch(yz){return null}}hasStyle(){var e;try{return null!=(null===(e=this.map)||void 0===e?void 0:e.getStyle())}catch(t){return!1}}hasLoadedStyle(){return!!this.hasStyle()&&!0===this.map.isStyleLoaded()}subscribeToFailedTiles(){this.retryTimer||(this.boundOnSourceData=this.onSourceData.bind(this),this.boundOnSourceDataAbort=this.onSourceDataAbort.bind(this),this.boundOnWebGLContextLost=this.onWebGLContextLost.bind(this),this.boundOnWebGLContextRestored=this.onWebGLContextRestored.bind(this),this.retryTimer=setInterval(()=>{if(!this.hasStyle())return;if(!this.map.getSource("indoorequal"))return void this.failedTiles.clear();const e=this.map.getSource("indoorequal");if(!e||"vector"!==e.type)return void this.failedTiles.clear();const t=[],r=[];this.failedTiles.forEach(e=>{e&&"unloaded"!==e.state&&"loading"!==e.state&&("errored"===e.state||"expired"===e.state)?t.push(e):r.push(e)}),r.forEach(e=>this.failedTiles.delete(e));const i=Date.now();t.forEach(t=>{var r;const n=null!==(r=this.tileRetryState.get(t))&&void 0!==r?r:{attempts:0,nextAttemptAt:0,pending:!1};if(n.pending||i<n.nextAttemptAt)return;const a=e=>{const r=n.attempts+1;if(r>=5)return this.debugLog(`Tile reload failed ${r} times, dropping it from the retry queue`,e),this.failedTiles.delete(t),void this.tileRetryState.delete(t);const i=1e3*2**(r-1);this.debugLog(`Tile reload failed (attempt ${r}/5), retrying in ${i}ms`,e),this.tileRetryState.set(t,{attempts:r,nextAttemptAt:Date.now()+i,pending:!1})};try{!t||"errored"!==t.state&&"expired"!==t.state||(this.tileRetryState.set(t,Object.assign(Object.assign({},n),{pending:!0})),e.loadTile(t).then(()=>{this.tileRetryState.delete(t)}).catch(a))}catch(s){a(s)}})},1e3),this.map.on("sourcedata",this.boundOnSourceData),this.map.on("sourcedataabort",this.boundOnSourceDataAbort),this.map.on("webglcontextlost",this.boundOnWebGLContextLost),this.map.on("webglcontextrestored",this.boundOnWebGLContextRestored))}unsubscribeFromFailedTiles(){this.retryTimer&&(clearInterval(this.retryTimer),this.retryTimer=void 0),this.boundOnSourceData&&(this.map.off("sourcedata",this.boundOnSourceData),this.boundOnSourceData=void 0),this.boundOnSourceDataAbort&&(this.map.off("sourcedataabort",this.boundOnSourceDataAbort),this.boundOnSourceDataAbort=void 0),this.boundOnWebGLContextLost&&(this.map.off("webglcontextlost",this.boundOnWebGLContextLost),this.boundOnWebGLContextLost=void 0),this.boundOnWebGLContextRestored&&(this.map.off("webglcontextrestored",this.boundOnWebGLContextRestored),this.boundOnWebGLContextRestored=void 0),this.failedTiles.clear()}}function yj(e){return"string"==typeof e?{id:e}:e}function _j(e,t){const r=Object.assign(Object.assign({},{lang:"en",apiUrl:"https://public-api.mapvx.com",routeApiUrl:"https://api.mapvx.com",healthApiUrl:"https://api.mapvx.com",legacyApiUrl:"https://api.mapvx.com",cache:{persistent:!1}}),t);return new vj(e,r)}class vj extends cN{constructor(e,t){var r,i,n;super(),this.maps=[],this.geoLocation=navigator.geolocation,this.headingListeners=[],this.token=e,this.config=t;const a=new Rs({persistent:null===(r=t.cache)||void 0===r?void 0:r.persistent,maxStorageBytes:null===(i=t.cache)||void 0===i?void 0:i.maxStorageBytes,configs:null===(n=t.cache)||void 0===n?void 0:n.configs});this.repository=new CN(e,this.config.lang,this.config.apiUrl,a,this.config.mapvxRequestContext,{routeApiUrl:this.config.routeApiUrl,healthApiUrl:this.config.healthApiUrl,legacyApiUrl:this.config.legacyApiUrl,portalApiUrl:this.config.portalApiUrl}),this.cachePlaces(),this.logEvent("initSDK")}cachePlaces(){this.repository.fetchAndParseAvailablePlaces().catch(()=>{})}setSdkLang(e){this.config.lang=e,this.repository.setLang(e),this.maps.forEach(t=>t.setLang(e))}unregisterMap(e){const t=this.maps.indexOf(e);t>=0&&this.maps.splice(t,1)}async getPlaceDetail(e){try{const t=yj(e),r=await this.repository.fetchAndParsePlaceDetail(t);return this.logEvent("getPlaceDetail",{id:t.id}),r}catch(t){throw new Error("Error getPlaceDetail",{cause:t})}}async getAnyPlaceDetail(e,t){try{const r=yj(e),i=await this.repository.fetchAndParseAnyPlaceDetail(r,t);return this.logEvent("getAnyPlaceDetail",{id:r.id}),i}catch(r){throw new Error("Error getAnyPlaceDetail",{cause:r})}}prepareSegmentation(e){return Object.assign(Object.assign({},e),{token:this.token})}createMap(e,t){try{t.lang=this.config.lang,t.apiUrl=this.config.apiUrl,t.portalApiUrl=this.config.portalApiUrl,t.mapvxRequestContext=this.config.mapvxRequestContext,t.routeApiUrl=this.config.routeApiUrl,t.healthApiUrl=this.config.healthApiUrl,t.legacyApiUrl=this.config.legacyApiUrl;const r=new gj(t,e,this.token),i=r.destroyMap.bind(r);return r.destroyMap=()=>{try{i()}finally{this.unregisterMap(r)}},this.maps.push(r),this.logEvent("createMap"),r}catch(r){throw new Error("Failed to create map",{cause:r})}}async getConfiguration(e,t){try{const r=await this.repository.fetchAndParseConfiguration(e,t);return this.logEvent("configuration"),r}catch(r){throw new Error("Failed to get configuration",{cause:r})}}async getCampaigns(e,t){try{const r=await this.repository.fetchAndParseCampaigns(e,t);return this.logEvent("campaigns"),r}catch(r){throw new Error("Failed to get campaigns",{cause:r})}}async getCategories(e){try{const t=await this.repository.fetchAndParseCategories(e);return this.logEvent("categories"),t}catch(t){throw new Error("Failed to get categories",{cause:t})}}async getTransport(e){try{return await this.repository.fetchAndParseTransport(e)}catch(t){throw new Error("Failed to get transport",{cause:t})}}getCachedPlaces(e){try{const t=this.repository.getCachedPlaces(e);return this.logEvent("getCachedPlaces"),t}catch(t){throw new Error("Failed to get cached places",{cause:t})}}async getAvailablePlaces(){try{const e=await this.repository.fetchAndParseAvailablePlaces();return this.logEvent("getAvailablePlaces"),e}catch(e){throw new Error("Failed to get available places",{cause:e})}}async getSubPlaces(e){try{const t=await this.repository.fetchAndParseSubPlaces(e);return this.logEvent("getSubPlaces"),t}catch(t){throw new Error("Failed to get subplaces",{cause:t})}}async getPlacesFromInstitution(e,t){try{const r=await this.repository.fetchAndParsePlacesFromInstitution(e,t);return this.logEvent("getPlacesFromInstitution"),r}catch(r){throw new Error("Failed to get places from institution",{cause:r})}}async getAnySubPlaces(e,t){try{const r=await this.repository.fetchAndParseAnySubPlaces(e,t);return this.logEvent("getAnySubPlaces"),r}catch(r){throw new Error("Failed to get any sub-places",{cause:r})}}async getInstitutions(){try{const e=await this.repository.fetchAndParseInstitutions();return this.logEvent("getInstitutions"),e}catch(e){throw new Error("Error getInstitution",{cause:e})}}async getRoute(e){try{const t=new W$(e),r=await this.repository.fetchAndParseRoute(t);return this.logEvent("getRoute"),r}catch(t){throw new Error("Failed to get route",{cause:t})}}async getRouteV2(e){try{const t=new W$(e),r=await this.repository.fetchAndParseRouteV2(t);return this.logEvent("getRouteV2"),r}catch(t){throw new Error("Failed to get route",{cause:t})}}async getLiveRoute(e){try{const t=new W$(e),r=await this.repository.fetchAndParseLiveRoute(t);return this.logEvent("getLiveRoute"),r}catch(t){throw new Error("Failed to get route",{cause:t})}}async getPlacesByInput(e,t,r,i,n,a,s,o){try{const l=r?i?[r,...i]:[r]:i,u=await this.repository.fetchAndParseSearchResults(t,e,l,n,a,s,o);return this.logEvent("getPlacesByInput"),u}catch(l){throw new Error("Failed to get places by input",{cause:l})}}async searchPlacesByTags(e,t,r={}){if(!t||0===t.length)throw new Error("searchPlacesByTags requires at least one tag");const{parentPlaces:i,sort:n,origin:a,lat:s,lng:o,floor:l}=r;if("distance"===n){const e=null!=s&&null!=o&&null!=l&&null!=i&&i.length>0;if(!a&&!e)throw new Error('searchPlacesByTags with sort "distance" requires "origin" or "lat" + "lng" + "floor" + "parentPlaces"')}try{const r=await this.repository.fetchAndParseSearchPlacesByTags(e,t,i,n,a,s,o,l);return this.logEvent("searchPlacesByTags"),r}catch(u){throw new Error("Failed to search places by tags",{cause:u})}}async getPlacesByCategory(e){try{return this.logEvent("getPlacesByCategory"),[]}catch(t){throw new Error("Failed to get places by category",{cause:t})}}setGeoLocation(e){this.geoLocation=e}getUserLocation(e={enableHighAccuracy:!0,timeout:6e4,maximumAge:1e4}){return new Promise((t,r)=>{this.geoLocation.getCurrentPosition(e=>{t(e)},e=>{r(e)},e)})}watchUserPosition(e,t,r={enableHighAccuracy:!0,timeout:6e4,maximumAge:1e3}){return this.geoLocation.watchPosition(t=>{e(t)},e=>{t(e)},r)}unWatchUserPosition(e){this.geoLocation.clearWatch(e)}watchUserHeading(e,t){const r=r=>{if(!function(e){return e instanceof DeviceOrientationEvent}(r))return;let i=null;void 0!==r.webkitCompassHeading?i=r.webkitCompassHeading||null:r.absolute&&null!==r.alpha&&(i=360-r.alpha),null!==i?e(i):t("Could not retrieve heading information.")};if(this.headingListeners.push(r),"ondeviceorientationabsolute"in window)window.addEventListener("deviceorientationabsolute",r);else if("ondeviceorientation"in window){window.addEventListener("deviceorientation",r)}}unwatchUserHeading(){this.headingListeners.forEach(e=>{window.removeEventListener("deviceorientationabsolute",e),window.removeEventListener("deviceorientation",e)}),this.headingListeners=[]}static getLang(){return this.config.lang}async loadRoutesForOriginCache(e,t,r,i,n){await this.repository.fetchAndParseRoutesFromOrigin(e,t,r,i,n)}async getCacheTimestamp(e){try{const t=await this.repository.fetchAndParseCacheTimestamp(e);return this.logEvent("getCacheTimestamp"),t}catch(t){throw new Error("Failed to get cache timestamp",{cause:t})}}cleanRoutesCache(){this.repository.cleanRoutesCache()}async getCssCustomization(e){try{const t=await this.repository.fetchAndParseCssCustomization(e);return this.logEvent("cssCustomization"),t}catch(t){throw new Error("Failed to get css customization",{cause:t})}}async notifyHealth(e,t,r,i){try{return await this.repository.postAndParseHealthPing(e,t,r,i)}catch(n){throw new Error("Failed to notify health",{cause:n})}}}const xj="compact";function bj(e){const t=e?.trim().toLowerCase();return"compact"===t||"full"===t?t:xj}function wj(e){return"object"==typeof e&&null!==e&&("inFloors"in e||"title"in e)}var Ej=/* @__PURE__ */(e=>(e.youAreHere="youAreHere",e.placePopup="placePopup",e.pin="pin",e.default="default",e))(Ej||{});const Sj="lazarillo-sdk",Dj={MINUTE:6e4,HOUR:36e5},Tj={MB_5:5242880,MB_10:10485760},Aj={persistent:!0,maxStorageBytes:Tj.MB_10,configs:{places:{maxItems:500,ttlMs:2*Dj.HOUR},subPlaces:{maxItems:200,ttlMs:Dj.HOUR},routes:{maxItems:100,ttlMs:15*Dj.MINUTE},accessibleRoutes:{maxItems:100,ttlMs:15*Dj.MINUTE},configurations:{maxItems:10,ttlMs:4*Dj.HOUR},categories:{maxItems:50,ttlMs:2*Dj.HOUR},vehicles:{maxItems:20,ttlMs:30*Dj.MINUTE},stops:{maxItems:50,ttlMs:30*Dj.MINUTE}}},Pj={persistent:!0,maxStorageBytes:Tj.MB_5,configs:{places:{maxItems:200,ttlMs:30*Dj.MINUTE},subPlaces:{maxItems:100,ttlMs:15*Dj.MINUTE},routes:{maxItems:50,ttlMs:5*Dj.MINUTE},accessibleRoutes:{maxItems:50,ttlMs:5*Dj.MINUTE},configurations:{maxItems:10,ttlMs:Dj.HOUR},categories:{maxItems:30,ttlMs:Dj.HOUR},vehicles:{maxItems:10,ttlMs:5*Dj.MINUTE},stops:{maxItems:20,ttlMs:5*Dj.MINUTE}}},Ij=Pj;function Cj(e,t){return t?{persistent:t.persistent??e.persistent,maxStorageBytes:t.maxStorageBytes??e.maxStorageBytes,configs:{places:t.configs?.places??e.configs.places,subPlaces:t.configs?.subPlaces??e.configs.subPlaces,routes:t.configs?.routes??e.configs.routes,accessibleRoutes:t.configs?.accessibleRoutes??e.configs.accessibleRoutes,configurations:t.configs?.configurations??e.configs.configurations,categories:t.configs?.categories??e.configs.categories,vehicles:t.configs?.vehicles??e.configs.vehicles,stops:t.configs?.stops??e.configs.stops}}:e}const Fj=["lz_places","lz_routes","lz_accessible_routes","lz_configurations","lz_categories","lz_vehicles","lz_stops","lz_subplaces"];function Mj(){Fj.forEach(e=>{try{localStorage.removeItem(e)}catch{}})}function kj(e,t){if(!e)return;const r=e;if("function"==typeof r.inFloor)return r.inFloor(t);const i=r.inFloors;return i&&0!==i.length?t.find(e=>e.key===i[0]):t.find(e=>e.reachableFromGPS)}const Rj="mvxError",Lj={PLACE_LOAD_FAILED:"No se pudieron cargar los datos del lugar. Intenta de nuevo.",ORIGIN_NOT_FOUND:"No se encontró el punto de origen.",DESTINATION_NOT_FOUND:"No se encontró el destino seleccionado.",ROUTE_NOT_FOUND:"No se pudo generar la ruta. Intenta de nuevo.",ROUTE_LOAD_FAILED:"No se pudo generar la ruta. Intenta de nuevo.",NETWORK_ERROR:"Sin conexión a internet. Verifica tu red e intenta de nuevo.",MAP_CONTEXT_LOST:"El mapa se reinició porque el navegador liberó sus recursos gráficos."},zj=/\bstatus (\d{3})\b/,Bj=e=>e.then(e=>({value:e,error:void 0}),e=>({value:void 0,error:e}));class Oj{constructor(e){this.connected=!1,this.enabledFloors=[],this.mapvxRequestContextKey="",this.appliedMapvxRequestContextKey="",this.effectiveCacheConfig=Ij,this.autoGenerateRoute=!1,this.venueRequest=0,this.placesRequest=0,this.routeRequest=0,this.host=e,this.host.addController(this),this.contextProvider=new Ss(this.host,{context:Sj,initialValue:{enabledFloors:[],markers:[],cameraInitialized:!1}})}static mapvxRequestContextKey(e){return e?JSON.stringify(e):""}static enrichWithInstitution(e,t,r){if(!e)return e;const i=e.institutionId||r?.parentInstitutionId||void 0,n=e.institutionName||(i?t?.cityOptions?.find(e=>"institution"===e.type&&e.institutionId===i)?.name:void 0)||void 0;return i===e.institutionId&&n===e.institutionName?e:{...e,institutionId:i,institutionName:n}}applyInstitutionContext(e,t,r,i,n){const a=Oj.enrichWithInstitution(r,i,n);if(!a)return;const s=Oj.mapvxRequestContextKey(a);if(s===this.appliedMapvxRequestContextKey)return;const o=_j(e,{lang:t,mapvxRequestContext:a,cache:this.effectiveCacheConfig});this.appliedMapvxRequestContextKey=s,this.contextProvider.setValue({...this.contextProvider.value,sdk:o})}static withDefaultMvxProduct(e){const t=e?.mvxProduct?.trim();return{...e??{},mvxProduct:t||"test"}}async prewarm(e,t,r,i){if(!this.connected)return;const n=this.contextProvider.value,a=n.parentPlaceId&&n.parentPlaceId!==r,s=++this.venueRequest,o=this.placesRequest;this.effectiveCacheConfig=Cj(Ij,i?.cacheConfig);const l=Oj.withDefaultMvxProduct(i?.mapvxRequestContext),u=_j(e,{lang:t,mapvxRequestContext:l,cache:this.effectiveCacheConfig});this.mapvxRequestContextKey=Oj.mapvxRequestContextKey(l),this.appliedMapvxRequestContextKey=this.mapvxRequestContextKey,this.contextProvider.setValue({...this.contextProvider.value,sdk:u,locale:t,parentPlaceId:r,parentPlace:a?void 0:this.contextProvider.value.parentPlace,generalConfig:a?void 0:this.contextProvider.value.generalConfig,originId:i?.originId??this.contextProvider.value.originId,destinationId:i?.destinationId??this.contextProvider.value.destinationId});try{const[n,a,c,h]=await Promise.all([u.getConfiguration(r).catch(()=>{}),Bj(u.getPlaceDetail(r)),i?.originId?u.getPlaceDetail(i.originId).catch(()=>{}):Promise.resolve(void 0),i?.destinationId?u.getPlaceDetail(i.destinationId).catch(()=>{}):Promise.resolve(void 0)]);if(s!==this.venueRequest)return;const d=a.value;d||this.reportParentPlaceFailure(r,a.error);const p=o===this.placesRequest,f=p?c:this.contextProvider.value.origin,m=p?h:this.contextProvider.value.destination,g=d?.innerFloors||[];let y,_=g;if(f||m){const e=[f,m].map(e=>kj(e,g)).filter(e=>void 0!==e);e.length>0&&(_=e),y=m?.inFloors?.[0]?g.find(e=>e.key===m.inFloors[0]):f?.inFloors?.[0]?g.find(e=>e.key===f.inFloors[0]):void 0}this.enabledFloors=_,this.contextProvider.setValue({...this.contextProvider.value,generalConfig:n,parentPlace:d,origin:f??this.contextProvider.value.origin,destination:m??this.contextProvider.value.destination,enabledFloors:_,currentFloor:y??this.contextProvider.value.currentFloor,markers:p?[...f?[{id:f.mapvxId,data:f,style:Ej.youAreHere}]:[],...m?[{id:m.mapvxId,data:m,style:Ej.placePopup}]:[]]:this.contextProvider.value.markers}),this.applyInstitutionContext(e,t,l,n,d)}catch(c){xs.getInstance().warning("Error prewarming SDK",{error:c,parentPlaceId:r})}}async initialize(e,t,r,i,n){if(!this.connected)return;const a=this.contextProvider.value,s=a.parentPlaceId&&a.parentPlaceId!==r,o=Oj.withDefaultMvxProduct(i),l=Oj.mapvxRequestContextKey(o);if(a.sdk&&a.locale===t&&a.parentPlaceId===r&&!s&&l===this.mapvxRequestContextKey)return;s&&this.contextProvider.setValue({...this.contextProvider.value,parentPlace:void 0,generalConfig:void 0}),await this.initializeSDK(e,t,r,o,n);const{originId:u,destinationId:c}=this.contextProvider.value;u&&c&&this.setOriginAndDestination(u,c)}async setOriginAndDestination(e,t,r={}){if(!this.connected)return;const i=++this.placesRequest;this.routeRequest++;const n=this.contextProvider.value.sdk;if(this.contextProvider.setValue({...this.contextProvider.value,originId:e,destinationId:t,origin:void 0,destination:void 0,route:void 0,markers:[],isRouteAnimating:!1,routeError:void 0,routeFailed:!1,placesFailed:!1,loadingRoute:!1,isNetworkError:!1,isLoading:!0,cameraInitialized:!1}),n)try{const[a,s]=await Promise.all([e,t].map(e=>e?.length>0?Bj(n.getPlaceDetail(e)):Promise.resolve({value:void 0,error:void 0})));if(i!==this.placesRequest)return;const o=a.value,l=s.value;this.contextProvider.setValue({...this.contextProvider.value,origin:o,destination:l}),this.createOriginDestinationMarkers(o,l);const u=l?.inFloors?.[0]||o?.inFloors?.[0];u&&this.setFloor(u);const c=this.contextProvider.value.parentPlace?.innerFloors||[],h=[o,l].filter(e=>!!e).map(e=>kj(e,c)).filter(e=>void 0!==e);this.enabledFloors=h,this.contextProvider.setValue({...this.contextProvider.value,enabledFloors:h,isLoading:!1});const d=this.placeFailures(e,a,t,s);if(d.length>0)return void this.showPlaceFailures(d);(this.autoGenerateRoute||r.thenRoute)&&o&&l&&await this.loadRoute(e,t,!!this.contextProvider.value.accessibleRoute)}catch(a){if(i!==this.placesRequest)return;const r=this.isNetworkError(a);xs.getInstance().warning("Error setting origin and destination",{error:a,originId:e,destinationId:t,isNetworkError:r});const n=r?"NETWORK_ERROR":"PLACE_LOAD_FAILED";this.contextProvider.setValue({...this.contextProvider.value,isLoading:!1,isNetworkError:r,placesFailed:!0,routeError:Lj[n]}),this.dispatchError({code:n,message:Lj[n],originId:e,destinationId:t})}else this.contextProvider.setValue({...this.contextProvider.value,isLoading:!1})}setAutoGenerateRoute(e){this.autoGenerateRoute=e}placeFailures(e,t,r,i){const n=[e&&!t.value?{result:t,notFound:"ORIGIN_NOT_FOUND",ids:{originId:e}}:void 0,r&&!i.value?{result:i,notFound:"DESTINATION_NOT_FOUND",ids:{destinationId:r}}:void 0].filter(e=>void 0!==e);return n.some(({result:e})=>this.isNetworkError(e.error))?[{code:"NETWORK_ERROR",originId:e,destinationId:r}]:n.map(({result:e,notFound:t,ids:r})=>({code:Oj.isNotFound(e)?t:"PLACE_LOAD_FAILED",...r}))}static isNotFound(e){return void 0===e.error||Oj.errorChain(e.error).some(e=>"404"===zj.exec(e.message)?.[1])}static errorChain(e){const t=[];let r=e;for(;r instanceof Error&&t.length<10;)t.push(r),r=r.cause;return t}showPlaceFailures(e){const[t]=e;this.contextProvider.setValue({...this.contextProvider.value,routeError:Lj[t.code],isNetworkError:"NETWORK_ERROR"===t.code,placesFailed:!0});for(const r of e)this.dispatchError({...r,message:Lj[r.code]})}reportParentPlaceFailure(e,t){const r=this.isNetworkError(t)?"NETWORK_ERROR":"PLACE_LOAD_FAILED";xs.getInstance().warning("Parent place could not be loaded",{error:t,parentPlaceId:e,code:r}),this.dispatchError({code:r,message:Lj[r],parentPlaceId:e})}dispatchError(e){const t=this.host;"function"==typeof t.dispatchEvent&&t.dispatchEvent(new CustomEvent(Rj,{detail:{parentPlaceId:this.contextProvider.value.parentPlaceId,...e},bubbles:!0,composed:!0}))}isNetworkError(e){const t=Oj.errorChain(e);return!t.some(e=>zj.test(e.message))&&t.some(e=>{const t=e.message.toLowerCase();return!!(e instanceof TypeError&&/fetch|network|load failed/.test(t))||/\b(network|offline|internet|connection)\b|net::err/.test(t)})}getDestination(){return this.contextProvider.value.destination}async loadRoute(e,t,r=!1){if(!this.connected)return;const i=this.contextProvider.value.sdk;if(!i)return;const n=++this.routeRequest;this.contextProvider.setValue({...this.contextProvider.value,loadingRoute:!0,routeError:void 0,routeFailed:!1,isNetworkError:!1});try{const a=await i.getRoute({initialLocation:{id:e},finalLocation:{id:t},preferAccessibleRoute:r});if(n!==this.routeRequest)return;if(!a)return ve.getInstance().trackEvent("route_error",{error_type:"no_route_found",origin_id:e,destination_id:t,accessible_route:r,parent_place_id:this.contextProvider.value.parentPlaceId}),this.contextProvider.setValue({...this.contextProvider.value,loadingRoute:!1,routeFailed:!0,routeError:Lj.ROUTE_NOT_FOUND}),void this.dispatchError({code:"ROUTE_NOT_FOUND",message:Lj.ROUTE_NOT_FOUND,originId:e,destinationId:t});const s=this.contextProvider.value.parentPlace?.innerFloors||[],o=a.legs.flatMap(e=>e.steps.flatMap(e=>[e.startInsideFloor,e.endInsideFloor])).map(e=>e?s.find(t=>t.key===e):void 0).filter(e=>void 0!==e),l=a.legs?.reduce((e,t)=>e+(t.distance??0),0)??0,u=a.legs?.reduce((e,t)=>e+(t.steps?.length??0),0)??0,c=new Set(o.map(e=>e.key));ve.getInstance().trackEvent("route_generation_completed",{origin_id:e,destination_id:t,accessible_route:r,distance_meters:Math.round(l),total_legs:a.legs?.length??0,total_steps:u,floor_count:c.size,parent_place_id:this.contextProvider.value.parentPlaceId}),this.contextProvider.setValue({...this.contextProvider.value,route:a,enabledFloors:o,isRouteAnimating:!1,loadingRoute:!1,routeError:void 0})}catch(a){if(n!==this.routeRequest)return;const i=this.isNetworkError(a);xs.getInstance().warning("Error loading route",{error:a,originId:e,destinationId:t,isNetworkError:i}),ve.getInstance().trackEvent("route_error",{error_type:i?"network_error":"api_error",error_message:a instanceof Error?a.message:"Unknown error",origin_id:e,destination_id:t,accessible_route:r,parent_place_id:this.contextProvider.value.parentPlaceId}),this.contextProvider.setValue({...this.contextProvider.value,loadingRoute:!1,routeFailed:!0,isNetworkError:i,routeError:i?Lj.NETWORK_ERROR:Lj.ROUTE_LOAD_FAILED});const s=i?"NETWORK_ERROR":"ROUTE_LOAD_FAILED";this.dispatchError({code:s,message:Lj[s],originId:e,destinationId:t})}}async loadConfig(e){const t=this.contextProvider.value.sdk;if(t)try{const r=await t.getConfiguration(e);this.contextProvider.setValue({...this.contextProvider.value,generalConfig:r})}catch(r){xs.getInstance().warning("Error loading config",{error:r,parentPlaceId:e})}}async initializeSDK(e,t,r,i,n){this.effectiveCacheConfig=Cj(Ij,n);const a=Oj.withDefaultMvxProduct(i),s=_j(e,{lang:t,mapvxRequestContext:a,cache:this.effectiveCacheConfig});this.mapvxRequestContextKey=Oj.mapvxRequestContextKey(a),this.appliedMapvxRequestContextKey=this.mapvxRequestContextKey,this.contextProvider.setValue({...this.contextProvider.value,sdk:s,locale:t,parentPlaceId:r});try{const[n,a]=await Promise.all([s.getConfiguration(r).catch(()=>{}),Bj(s.getPlaceDetail(r))]),o=a.value;o||this.contextProvider.value.parentPlaceId!==r||this.reportParentPlaceFailure(r,a.error);const{origin:l,destination:u}=this.contextProvider.value;let c=o?.innerFloors||[];const h=kj(l,c)||kj(u,c);(l||u)&&(c=[l,u].map(e=>kj(e,c)).filter(e=>void 0!==e),this.enabledFloors=c),this.contextProvider.setValue({...this.contextProvider.value,generalConfig:n,parentPlace:o,enabledFloors:c,currentFloor:h}),this.applyInstitutionContext(e,t,i,n,o)}catch(o){xs.getInstance().warning("Error initializing SDK",{error:o,parentPlaceId:r})}}createOriginDestinationMarkers(e,t){const r=[];e&&r.push({id:e.mapvxId,data:e,style:Ej.youAreHere}),t&&r.push({id:t.mapvxId,data:t,style:Ej.placePopup}),this.contextProvider.setValue({...this.contextProvider.value,markers:r})}setAccessibleRoute(e){this.contextProvider.setValue({...this.contextProvider.value,accessibleRoute:e});const{originId:t,destinationId:r,route:i,routeFailed:n,placesFailed:a}=this.contextProvider.value;t&&r&&(this.autoGenerateRoute&&a?this.setOriginAndDestination(t,r):(i||this.autoGenerateRoute&&n)&&this.loadRoute(t,r,e))}repeatRoute(){this.contextProvider.setValue({...this.contextProvider.value,isRouteAnimating:!0})}removeRoute(){this.contextProvider.setValue({...this.contextProvider.value,route:void 0,enabledFloors:this.enabledFloors})}routeAnimationFinished(){this.contextProvider.setValue({...this.contextProvider.value,isRouteAnimating:!1})}startRouteAnimation(){this.contextProvider.setValue({...this.contextProvider.value,isRouteAnimating:!0})}generateRoute(){const{originId:e,destinationId:t,accessibleRoute:r,placesFailed:i,origin:n,destination:a}=this.contextProvider.value;e&&t&&(!i&&n&&a?this.loadRoute(e,t,!!r):this.setOriginAndDestination(e,t,{thenRoute:!0}))}requestRouteIfIdle(){if(!this.autoGenerateRoute)return;const{originId:e,destinationId:t,origin:r,destination:i,route:n,loadingRoute:a,isLoading:s,accessibleRoute:o}=this.contextProvider.value;e&&t&&r&&i&&(n||a||s||this.loadRoute(e,t,!!o))}setFloor(e){const{parentPlace:t,currentFloor:r}=this.contextProvider.value;if(!t)return;if(r?.key===e)return;const i=(t.innerFloors??[]).find(t=>t.key===e);i&&this.contextProvider.setValue({...this.contextProvider.value,currentFloor:i})}hostConnected(){this.connected=!0}hostDisconnected(){this.connected=!1}setMapReady(e){this.contextProvider.setValue({...this.contextProvider.value,mapReady:e})}setCameraInitialized(e){this.contextProvider.setValue({...this.contextProvider.value,cameraInitialized:e})}resetData(){this.placesRequest++,this.routeRequest++,this.contextProvider.setValue({...this.contextProvider.value,originId:void 0,destinationId:void 0,origin:void 0,destination:void 0,route:void 0,enabledFloors:this.enabledFloors,currentFloor:this.contextProvider.value.parentPlace?.innerFloors?.[0],markers:[],accessibleRoute:!1,isRouteAnimating:!1,cameraInitialized:!1,routeError:void 0,routeFailed:!1,placesFailed:!1,isNetworkError:!1,isLoading:!1,loadingRoute:!1}),this.host.requestUpdate()}clearRouteError(){this.contextProvider.setValue({...this.contextProvider.value,routeError:void 0,isNetworkError:!1})}clearParentPlace(){this.contextProvider.setValue({...this.contextProvider.value,parentPlace:void 0,generalConfig:void 0})}}const $j={fromAttribute:e=>"false"!==e,toAttribute:e=>String(e)};export{ve as A,le as B,Fj as C,we as D,me as E,Sj as F,a as G,q as H,G as I,bs as J,Ej as K,wj as L,xe as M,bj as N,Tj as S,Dj as T,Pj as W,be as a,Ae as b,Aj as c,Ij as d,Mj as e,Rj as f,Lj as g,s as h,se as i,Oj as j,fe as k,pe as l,Cj as m,ge as n,ye as o,_e as p,xs as q,Se as r,Te as s,De as t,de as u,U as v,Ee as w,xj as x,he as y,$j as z};
|
|
70
70
|
|
|
71
|
-
//# debugId=
|
|
71
|
+
//# debugId=412a3fd8-bd5a-5add-91bb-d68d5cf611a8
|