signalk-binnacle 0.6.2 → 0.7.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.
@@ -0,0 +1,857 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TrendCharts-CiUGeOLI.js","assets/TrendCharts-DHXnahl6.css"])))=>i.map(i=>d[i]);
2
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var l=Array.isArray,u=Array.prototype.indexOf,d=Array.prototype.includes,f=Array.from,p=Object.defineProperty,m=Object.getOwnPropertyDescriptor,h=Object.getOwnPropertyDescriptors,g=Object.prototype,_=Array.prototype,v=Object.getPrototypeOf,y=Object.isExtensible;function b(e){return typeof e==`function`}var x=()=>{};function S(e){return typeof e?.then==`function`}function C(e){for(var t=0;t<e.length;t++)e[t]()}function w(){var e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function T(e,t){if(Array.isArray(e))return e;if(t===void 0||!(Symbol.iterator in e))return Array.from(e);let n=[];for(let r of e)if(n.push(r),n.length===t)break;return n}var E=1<<24,D=1024,O=2048,k=4096,A=8192,ee=16384,te=32768,j=1<<25,ne=65536,re=1<<19,ie=1<<20,ae=1<<25,oe=65536,se=1<<21,ce=1<<22,le=1<<23,ue=Symbol(`$state`),de=Symbol(`legacy props`),fe=Symbol(``),pe=Symbol(`attributes`),me=Symbol(`class`),he=Symbol(`style`),ge=Symbol(`text`),_e=Symbol(`form reset`),ve=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"},ye=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`);function be(e){throw Error(`https://svelte.dev/e/lifecycle_outside_component`)}function xe(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function Se(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function Ce(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function we(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function Te(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function Ee(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function De(e){throw Error(`https://svelte.dev/e/props_invalid_value`)}function Oe(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function ke(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function Ae(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function je(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var Me={},Ne=Symbol(`uninitialized`),Pe=`http://www.w3.org/1999/xhtml`,Fe=`http://www.w3.org/2000/svg`;function Ie(){console.warn(`https://svelte.dev/e/derived_inert`)}function Le(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function Re(){console.warn(`https://svelte.dev/e/select_multiple_invalid_value`)}function ze(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var Be=!1;function Ve(e){Be=e}var M;function He(e){if(e===null)throw Le(),Me;return M=e}function Ue(){return He(Sn(M))}function N(e){if(Be){if(Sn(M)!==null)throw Le(),Me;M=e}}function P(e=1){if(Be){for(var t=e,n=M;t--;)n=Sn(n);M=n}}function We(e=!0){for(var t=0,n=M;;){if(n.nodeType===8){var r=n.data;if(r===`]`){if(t===0)return n;--t}else (r===`[`||r===`[!`||r[0]===`[`&&!isNaN(Number(r.slice(1))))&&(t+=1)}var i=Sn(n);e&&n.remove(),n=i}}function Ge(e){if(!e||e.nodeType!==8)throw Le(),Me;return e.data}function Ke(e){return e===this.v}function qe(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function Je(e){return!qe(e,this.v)}var Ye=!1,Xe=!1,F=null;function Ze(e){F=e}function Qe(e){return tt(`getContext`).get(e)}function $e(e,t=!1,n){F={p:F,i:!1,c:null,e:null,s:e,x:null,r:fr,l:Xe&&!t?{s:null,u:null,$:[]}:null}}function et(e){var t=F,n=t.e;if(n!==null){t.e=null;for(var r of n)Bn(r)}return e!==void 0&&(t.x=e),t.i=!0,F=t.p,e??{}}function I(){return!Xe||F!==null&&F.l===null}function tt(e){return F===null&&be(e),F.c??=new Map(nt(F)||void 0)}function nt(e){let t=e.p;for(;t!==null;){let e=t.c;if(e!==null)return e;t=t.p}return null}var rt=[];function it(){var e=rt;rt=[],C(e)}function at(e){if(rt.length===0&&!Bt){var t=rt;queueMicrotask(()=>{t===rt&&it()})}rt.push(e)}function ot(){for(;rt.length>0;)it()}function st(e){var t=fr;if(t===null)return lr.f|=le,e;if(!(t.f&32768)&&!(t.f&4))throw e;ct(e,t)}function ct(e,t){if(!(t!==null&&t.f&16384)){for(;t!==null;){if(t.f&128){if(!(t.f&32768))throw e;try{t.b.error(e);return}catch(t){e=t}}t=t.parent}throw e}}var lt=~(O|k|D);function ut(e,t){e.f=e.f&lt|t}function dt(e){e.f&512||e.deps===null?ut(e,D):ut(e,k)}function ft(e){if(e!==null)for(let t of e)!(t.f&2)||!(t.f&65536)||(t.f^=oe,ft(t.deps))}function pt(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),ft(e.deps),ut(e,D)}var mt=!1,ht=!1;function gt(e){var t=ht;try{return ht=!1,[e(),ht]}finally{ht=t}}function _t(e){let t=0,n=on(0),r;return()=>{Ln()&&(W(n),Wn(()=>(t===0&&(r=Pr(()=>e(()=>un(n)))),t+=1,()=>{at(()=>{--t,t===0&&(r?.(),r=void 0,un(n))})})))}}var vt=ne|re;function yt(e,t,n,r){new bt(e,t,n,r)}var bt=class{parent;is_pending=!1;transform_error;#e;#t=Be?M:null;#n;#r;#i;#a=null;#o=null;#s=null;#c=null;#l=0;#u=0;#d=!1;#f=new Set;#p=new Set;#m=null;#h=_t(()=>(this.#m=on(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=fr;t.b=this,t.f|=128,n(e)},this.parent=fr.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=Gn(()=>{if(Be){let e=this.#t;Ue();let t=e.data===`[!`;if(e.data.startsWith(`[?`)){let t=JSON.parse(e.data.slice(2));this.#_(t)}else t?this.#v():this.#g()}else this.#y()},vt),Be&&(this.#e=M)}#g(){try{this.#a=qn(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed;t&&(this.#s=qn(()=>{t(this.#e,()=>e,()=>()=>{})}))}#v(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=qn(()=>e(this.#e)),at(()=>{var e=this.#c=document.createDocumentFragment(),t=bn();e.append(t),this.#a=this.#x(()=>qn(()=>this.#r(t))),this.#u===0&&(this.#e.before(e),this.#c=null,er(this.#o,()=>{this.#o=null}),this.#b(It))}))}#y(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=qn(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();ir(this.#a,e);let t=this.#n.pending;this.#o=qn(()=>t(this.#e))}else this.#b(It)}catch(e){this.error(e)}}#b(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){pt(e,this.#f,this.#p)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#n.pending}#x(e){var t=fr,n=lr,r=F;pr(this.#i),dr(this.#i),Ze(this.#i.ctx);try{return Kt.ensure(),e()}catch(e){return st(e),null}finally{pr(t),dr(n),Ze(r)}}#S(e,t){if(!this.has_pending_snippet()){this.parent&&this.parent.#S(e,t);return}this.#u+=e,this.#u===0&&(this.#b(t),this.#o&&er(this.#o,()=>{this.#o=null}),this.#c&&=(this.#e.before(this.#c),null))}update_pending_count(e,t){this.#S(e,t),this.#l+=e,!(!this.#m||this.#d)&&(this.#d=!0,at(()=>{this.#d=!1,this.#m&&cn(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),W(this.#m)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;It?.is_fork?(this.#a&&It.skip_effect(this.#a),this.#o&&It.skip_effect(this.#o),this.#s&&It.skip_effect(this.#s),It.oncommit(()=>{this.#C(e)})):this.#C(e)}#C(e){this.#a&&=(Zn(this.#a),null),this.#o&&=(Zn(this.#o),null),this.#s&&=(Zn(this.#s),null),Be&&(He(this.#t),P(),He(We()));var t=this.#n.onerror;let n=this.#n.failed;var r=!1,i=!1;let a=()=>{if(r){ze();return}r=!0,i&&je(),this.#s!==null&&er(this.#s,()=>{this.#s=null}),this.#x(()=>{this.#y()})},o=e=>{try{i=!0,t?.(e,a),i=!1}catch(e){ct(e,this.#i&&this.#i.parent)}n&&(this.#s=this.#x(()=>{try{return qn(()=>{var t=fr;t.b=this,t.f|=128,n(this.#e,()=>e,()=>a)})}catch(e){return ct(e,this.#i.parent),null}}))};at(()=>{var t;try{t=this.transform_error(e)}catch(e){ct(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(o,e=>ct(e,this.#i&&this.#i.parent)):o(t)})}};function xt(e,t,n,r){let i=I()?Tt:Ot;var a=e.filter(e=>!e.settled),o=t.map(i);if(n.length===0&&a.length===0){r(o);return}var s=fr,c=St(),l=a.length===1?a[0].promise:a.length>1?Promise.all(a.map(e=>e.promise)):null;function u(e){if(!(s.f&16384)){c();try{r([...o,...e])}catch(e){ct(e,s)}Ct()}}var d=wt();if(n.length===0){l.then(()=>u([])).finally(d);return}function f(){Promise.all(n.map(e=>Dt(e))).then(u).catch(e=>ct(e,s)).finally(d)}l?l.then(()=>{c(),f(),Ct()}):f()}function St(){var e=fr,t=lr,n=F,r=It;return function(i=!0){pr(e),dr(t),Ze(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function Ct(e=!0){pr(null),dr(null),Ze(null),e&&It?.deactivate()}function wt(){var e=fr,t=e.b,n=It,r=!!t?.is_rendered();return t?.update_pending_count(1,n),n.increment(r,e),()=>{t?.update_pending_count(-1,n),n.decrement(r,e)}}function Tt(e){var t=2|O;return fr!==null&&(fr.f|=re),{ctx:F,deps:null,effects:null,equals:Ke,f:t,fn:e,reactions:null,rv:0,v:Ne,wv:0,parent:fr,ac:null}}var Et=Symbol(`obsolete`);function Dt(e,t,n){let r=fr;r===null&&xe();var i=void 0,a=on(Ne),o=!lr,s=new Set;return Un(()=>{var t=fr,n=w();i=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==ve&&n.reject(e)}).finally(Ct)}catch(e){n.reject(e),Ct()}var c=It;if(o){if(t.f&32768)var l=wt();if(r.b?.is_rendered())c.async_deriveds.get(t)?.reject(Et);else for(let e of s.values())e.reject(Et);s.add(n),c.async_deriveds.set(t,n)}let u=(e,t=void 0)=>{l?.(),s.delete(n),t!==Et&&(c.activate(),t?(a.f|=le,cn(a,t)):(a.f&8388608&&(a.f^=le),cn(a,e)),c.deactivate())};n.promise.then(u,e=>u(null,e||`unknown`))}),Rn(()=>{for(let e of s)e.reject(Et)}),new Promise(e=>{function t(n){function r(){n===i?e(a):t(i)}n.then(r,r)}t(i)})}function R(e){let t=Tt(e);return Ye||hr(t),t}function Ot(e){let t=Tt(e);return t.equals=Je,t}function kt(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n<t.length;n+=1)Zn(t[n])}}function At(e){var t,n=fr,r=e.parent;if(!sr&&r!==null&&e.v!==Ne&&r.f&24576)return Ie(),e.v;pr(r);try{e.f&=~oe,kt(e),t=Dr(e)}finally{pr(n)}return t}function jt(e){var t=At(e);if(!e.equals(t)&&(e.wv=wr(),(!It?.is_fork||e.deps===null)&&(It===null?e.v=t:(It.capture(e,t,!0),Lt?.capture(e,t,!0)),e.deps===null))){ut(e,D);return}sr||(Rt===null?dt(e):(Ln()||It?.is_fork)&&Rt.set(e,t))}function Mt(e){if(e.effects!==null)for(let t of e.effects)(t.teardown||t.ac)&&(t.teardown?.(),t.ac?.abort(ve),t.fn!==null&&(t.teardown=x),t.ac=null,kr(t,0),Yn(t))}function Nt(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&t.fn!==null&&Ar(t)}var Pt=null,Ft=null,It=null,Lt=null,Rt=null,zt=null,Bt=!1,Vt=!1,Ht=null,Ut=null,Wt=0,Gt=1,Kt=class e{id=Gt++;#e=!1;linked=!0;#t=null;#n=null;async_deriveds=new Map;current=new Map;previous=new Map;#r=new Set;#i=new Set;#a=0;#o=new Map;#s=null;#c=[];#l=[];#u=new Set;#d=new Set;#f=new Map;#p=new Set;is_fork=!1;#m=!1;constructor(){Ft===null?Pt=Ft=this:(Ft.#n=this,this.#t=Ft),Ft=this}#h(){if(this.is_fork)return!0;for(let n of this.#o.keys()){for(var e=n,t=!1;e.parent!==null;){if(this.#f.has(e)){t=!0;break}e=e.parent}if(!t)return!0}return!1}skip_effect(e){this.#f.has(e)||this.#f.set(e,{d:[],m:[]}),this.#p.delete(e)}unskip_effect(e,t=e=>this.schedule(e)){var n=this.#f.get(e);if(n){this.#f.delete(e);for(var r of n.d)ut(r,O),t(r);for(r of n.m)ut(r,k),t(r)}this.#p.add(e)}#g(){this.#e=!0,Wt++>1e3&&(this.#S(),Jt());for(let e of this.#u)this.#d.delete(e),ut(e,O),this.schedule(e);for(let e of this.#d)ut(e,k),this.schedule(e);let t=this.#c;this.#c=[],this.apply();var n=Ht=[],r=[],i=Ut=[];for(let e of t)try{this.#_(e,n,r)}catch(t){throw tn(e),this.#h()||this.discard(),t}if(It=null,i.length>0){var a=e.ensure();for(let e of i)a.schedule(e)}if(Ht=null,Ut=null,this.#h()){this.#b(r),this.#b(n);for(let[e,t]of this.#f)en(e,t);i.length>0&&It.#g();return}let o=this.#v();if(o){this.#b(r),this.#b(n),o.#y(this);return}this.#u.clear(),this.#d.clear();for(let e of this.#r)e(this);this.#r.clear(),Lt=this,Xt(r),Xt(n),Lt=null,this.#s?.resolve();var s=It;if(this.#a===0&&(this.#c.length===0||s!==null)&&(this.#S(),Ye&&(this.#x(),It=s)),this.#c.length>0)if(s!==null){let e=s;e.#c.push(...this.#c.filter(t=>!e.#c.includes(t)))}else s=this;s!==null&&s.#g()}#_(e,t,n){e.f^=D;for(var r=e.first;r!==null;){var i=r.f,a=(i&96)!=0;if(!(a&&i&1024||i&8192||this.#f.has(r))&&r.fn!==null){a?r.f^=D:i&4?t.push(r):Ye&&i&16777224?n.push(r):Tr(r)&&(i&16&&this.#d.add(r),Ar(r));var o=r.first;if(o!==null){r=o;continue}}for(;r!==null;){var s=r.next;if(s!==null){r=s;break}r=r.parent}}}#v(){for(var e=this.#t;e!==null;){if(!e.is_fork){for(let[t,[,n]]of this.current)if(e.current.has(t)&&!n)return e}e=e.#t}return null}#y(e){for(let[t,n]of e.current)!this.previous.has(t)&&e.previous.has(t)&&this.previous.set(t,e.previous.get(t)),this.current.set(t,n);for(let[t,n]of e.async_deriveds){let e=this.async_deriveds.get(t);e&&n.promise.then(e.resolve).catch(e.reject)}e.async_deriveds.clear(),this.transfer_effects(e.#u,e.#d);let t=e=>{var n=e.reactions;if(n!==null)for(let e of n){var r=e.f;if(r&2)t(e);else{var i=e;r&4194320&&!this.async_deriveds.has(i)&&(this.#d.delete(i),ut(i,O),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#S(),It=this,this.#g()}#b(e){for(var t=0;t<e.length;t+=1)pt(e[t],this.#u,this.#d)}capture(e,t,n=!1){e.v!==Ne&&!this.previous.has(e)&&this.previous.set(e,e.v),e.f&8388608||(this.current.set(e,[t,n]),Rt?.set(e,t)),this.is_fork||(e.v=t)}activate(){It=this}deactivate(){It=null,Rt=null}flush(){try{Vt=!0,It=this,this.#g()}finally{Wt=0,zt=null,Ht=null,Ut=null,Vt=!1,It=null,Rt=null,rn.clear()}}discard(){for(let e of this.#i)e(this);this.#i.clear();for(let e of this.async_deriveds.values())e.reject(Et);this.#S(),this.#s?.resolve()}register_created_effect(e){this.#l.push(e)}#x(){for(let u=Pt;u!==null;u=u.#n){var e=u.id<this.id,t=[];for(let[r,[i,a]]of this.current){if(u.current.has(r)){var n=u.current.get(r)[0];if(e&&i!==n)u.current.set(r,[i,a]);else continue}t.push(r)}if(e)for(let[e,t]of this.async_deriveds){let n=u.async_deriveds.get(e);n&&t.promise.then(n.resolve).catch(n.reject)}var r=[...u.current.keys()].filter(e=>!u.current.get(e)[1]);if(!(!u.#e||r.length===0)){var i=r.filter(e=>!this.current.has(e));if(i.length===0)e&&u.discard();else if(t.length>0){if(e)for(let e of this.#p)u.unskip_effect(e,e=>{e.f&4194320?u.schedule(e):u.#b([e])});u.activate();var a=new Set,o=new Map;for(var s of t)Zt(s,i,a,o);o=new Map;var c=[...u.current].filter(([e,t])=>{let n=this.current.get(e);return n?n[0]!==t[0]||n[1]!==t[1]:!0}).map(([e])=>e);if(c.length>0)for(let e of this.#l)!(e.f&155648)&&Qt(e,c,o)&&(e.f&4194320?(ut(e,O),u.schedule(e)):u.#u.add(e));if(u.#c.length>0&&!u.#m){u.apply();for(var l of u.#c)u.#_(l,[],[]);u.#c=[]}u.deactivate()}}}}increment(e,t){if(this.#a+=1,e){let e=this.#o.get(t)??0;this.#o.set(t,e+1)}}decrement(e,t){if(--this.#a,e){let e=this.#o.get(t)??0;e===1?this.#o.delete(t):this.#o.set(t,e-1)}this.#m||(this.#m=!0,at(()=>{this.#m=!1,this.linked&&this.flush()}))}transfer_effects(e,t){for(let t of e)this.#u.add(t);for(let e of t)this.#d.add(e);e.clear(),t.clear()}oncommit(e){this.#r.add(e)}ondiscard(e){this.#i.add(e)}settled(){return(this.#s??=w()).promise}static ensure(){if(It===null){let t=It=new e;!Vt&&!Bt&&at(()=>{t.#e||t.flush()})}return It}apply(){if(!Ye||!this.is_fork&&this.#t===null&&this.#n===null){Rt=null;return}Rt=new Map;for(let[e,[t]]of this.current)Rt.set(e,t);for(let t=Pt;t!==null;t=t.#n)if(!(t===this||t.is_fork)){var e=!1;if(t.id<this.id){for(let[n,[,r]]of t.current)if(!r&&this.current.has(n)){e=!0;break}}if(!e)for(let[e,n]of t.previous)Rt.has(e)||Rt.set(e,n)}}schedule(e){if(zt=e,e.b?.is_pending&&e.f&16777228&&!(e.f&32768)){e.b.defer_effect(e);return}for(var t=e;t.parent!==null;){t=t.parent;var n=t.f;if(Ht!==null&&t===fr&&(Ye||(lr===null||!(lr.f&2))&&!mt))return;if(n&96){if(!(n&1024))return;t.f^=D}}this.#c.push(t)}#S(){if(this.linked){var e=this.#t,t=this.#n;e===null?Pt=t:e.#n=t,t===null?Ft=e:t.#t=e,this.linked=!1}}};function qt(e){var t=Bt;Bt=!0;try{var n;for(e&&(It!==null&&!It.is_fork&&It.flush(),n=e());;){if(ot(),It===null)return n;It.flush()}}finally{Bt=t}}function Jt(){try{Ee()}catch(e){ct(e,zt)}}var Yt=null;function Xt(e){var t=e.length;if(t!==0){for(var n=0;n<t;){var r=e[n++];if(!(r.f&24576)&&Tr(r)&&(Yt=new Set,Ar(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&$n(r),Yt?.size>0)){rn.clear();for(let e of Yt){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)Yt.has(n)&&(Yt.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||Ar(n)}}Yt.clear()}}Yt=null}}function Zt(e,t,n,r){if(!n.has(e)&&(n.add(e),e.reactions!==null))for(let i of e.reactions){let e=i.f;e&2?Zt(i,t,n,r):e&4194320&&!(e&2048)&&Qt(i,t,r)&&(ut(i,O),$t(i))}}function Qt(e,t,n){let r=n.get(e);if(r!==void 0)return r;if(e.deps!==null)for(let r of e.deps){if(d.call(t,r))return!0;if(r.f&2&&Qt(r,t,n))return n.set(r,!0),!0}return n.set(e,!1),!1}function $t(e){It.schedule(e)}function en(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),ut(e,D);for(var n=e.first;n!==null;)en(n,t),n=n.next}}function tn(e){ut(e,D);for(var t=e.first;t!==null;)tn(t),t=t.next}var nn=new Set,rn=new Map,an=!1;function on(e,t){return{f:0,v:e,reactions:null,equals:Ke,rv:0,wv:0}}function z(e,t){let n=on(e,t);return hr(n),n}function sn(e,t=!1,n=!0){let r=on(e);return t||(r.equals=Je),Xe&&n&&F!==null&&F.l!==null&&(F.l.s??=[]).push(r),r}function B(e,t,n=!1){return lr!==null&&(!ur||lr.f&131072)&&I()&&lr.f&4325394&&(mr===null||!mr.has(e))&&Ae(),cn(e,n?fn(t):t,Ut)}function cn(e,t,n=null){if(!e.equals(t)){rn.set(e,sr?t:e.v);var r=Kt.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&&At(t),Rt===null&&dt(t)}e.wv=wr(),dn(e,O,n),I()&&fr!==null&&fr.f&1024&&!(fr.f&96)&&(vr===null?yr([e]):vr.push(e)),!r.is_fork&&nn.size>0&&!an&&ln()}return t}function ln(){an=!1;for(let e of nn){e.f&1024&&ut(e,k);let t;try{t=Tr(e)}catch{t=!0}t&&Ar(e)}nn.clear()}function un(e){B(e,e.v+1)}function dn(e,t,n){var r=e.reactions;if(r!==null)for(var i=I(),a=r.length,o=0;o<a;o++){var s=r[o],c=s.f;if(!(!i&&s===fr)){var l=(c&O)===0;if(l&&ut(s,t),c&131072)nn.add(s);else if(c&2){var u=s;Rt?.delete(u),c&65536||(c&512&&(fr===null||!(fr.f&2097152))&&(s.f|=oe),dn(u,k,n))}else if(l){var d=s;c&16&&Yt!==null&&Yt.add(d),n===null?$t(d):n.push(d)}}}}function fn(e){if(typeof e!=`object`||!e||ue in e)return e;let t=v(e);if(t!==g&&t!==_)return e;var n=new Map,r=l(e),i=z(0),a=null,o=Sr,s=e=>{if(Sr===o)return e();var t=lr,n=Sr;dr(null),Cr(o);var r=e();return dr(t),Cr(n),r};return r&&n.set(`length`,z(e.length,a)),new Proxy(e,{defineProperty(e,t,r){(!(`value`in r)||r.configurable===!1||r.enumerable===!1||r.writable===!1)&&Oe();var i=n.get(t);return i===void 0?s(()=>{var e=z(r.value,a);return n.set(t,e),e}):B(i,r.value,!0),!0},deleteProperty(e,t){var r=n.get(t);if(r===void 0){if(t in e){let e=s(()=>z(Ne,a));n.set(t,e),un(i)}}else B(r,Ne),un(i);return!0},get(t,r,i){if(r===ue)return e;var o=n.get(r),c=r in t;if(o===void 0&&(!c||m(t,r)?.writable)&&(o=s(()=>z(fn(c?t[r]:Ne),a)),n.set(r,o)),o!==void 0){var l=W(o);return l===Ne?void 0:l}return Reflect.get(t,r,i)},getOwnPropertyDescriptor(e,t){var r=Reflect.getOwnPropertyDescriptor(e,t);if(r&&`value`in r){var i=n.get(t);i&&(r.value=W(i))}else if(r===void 0){var a=n.get(t),o=a?.v;if(a!==void 0&&o!==Ne)return{enumerable:!0,configurable:!0,value:o,writable:!0}}return r},has(e,t){if(t===ue)return!0;var r=n.get(t),i=r!==void 0&&r.v!==Ne||Reflect.has(e,t);return(r!==void 0||fr!==null&&(!i||m(e,t)?.writable))&&(r===void 0&&(r=s(()=>z(i?fn(e[t]):Ne,a)),n.set(t,r)),W(r)===Ne)?!1:i},set(e,t,o,c){var l=n.get(t),u=t in e;if(r&&t===`length`)for(var d=o;d<l.v;d+=1){var f=n.get(d+``);f===void 0?d in e&&(f=s(()=>z(Ne,a)),n.set(d+``,f)):B(f,Ne)}if(l===void 0)(!u||m(e,t)?.writable)&&(l=s(()=>z(void 0,a)),B(l,fn(o)),n.set(t,l));else{u=l.v!==Ne;var p=s(()=>fn(o));B(l,p)}var h=Reflect.getOwnPropertyDescriptor(e,t);if(h?.set&&h.set.call(c,o),!u){if(r&&typeof t==`string`){var g=n.get(`length`),_=Number(t);Number.isInteger(_)&&_>=g.v&&B(g,_+1)}un(i)}return!0},ownKeys(e){W(i);var t=Reflect.ownKeys(e).filter(e=>{var t=n.get(e);return t===void 0||t.v!==Ne});for(var[r,a]of n)a.v!==Ne&&!(r in e)&&t.push(r);return t},setPrototypeOf(){ke()}})}function pn(e){try{if(typeof e==`object`&&e&&ue in e)return e[ue]}catch{}return e}function mn(e,t){return Object.is(pn(e),pn(t))}new Set([`copyWithin`,`fill`,`pop`,`push`,`reverse`,`shift`,`sort`,`splice`,`unshift`]);var hn,gn,_n,vn;function yn(){if(hn===void 0){hn=window,gn=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;_n=m(t,`firstChild`).get,vn=m(t,`nextSibling`).get,y(e)&&(e[me]=void 0,e[pe]=null,e[he]=void 0,e.__e=void 0),y(n)&&(n[ge]=void 0)}}function bn(e=``){return document.createTextNode(e)}function xn(e){return _n.call(e)}function Sn(e){return vn.call(e)}function V(e,t){if(!Be)return xn(e);var n=xn(M);if(n===null)n=M.appendChild(bn());else if(t&&n.nodeType!==3){var r=bn();return n?.before(r),He(r),r}return t&&Dn(n),He(n),n}function Cn(e,t=!1){if(!Be){var n=xn(e);return n instanceof Comment&&n.data===``?Sn(n):n}if(t){if(M?.nodeType!==3){var r=bn();return M?.before(r),He(r),r}Dn(M)}return M}function H(e,t=1,n=!1){let r=Be?M:e;for(var i;t--;)i=r,r=Sn(r);if(!Be)return r;if(n){if(r?.nodeType!==3){var a=bn();return r===null?i?.after(a):r.before(a),He(a),a}Dn(r)}return He(r),r}function wn(e){e.textContent=``}function Tn(){return!Ye||Yt!==null?!1:(fr.f&te)!==0}function En(e,t,n){return t==null||t===`http://www.w3.org/1999/xhtml`?n?document.createElement(e,{is:n}):document.createElement(e):n?document.createElementNS(t,e,{is:n}):document.createElementNS(t,e)}function Dn(e){if(e.nodeValue.length<65536)return;let t=e.nextSibling;for(;t!==null&&t.nodeType===3;)t.remove(),e.nodeValue+=t.nodeValue,t=e.nextSibling}function On(e,t){if(t){let t=document.body;e.autofocus=!0,at(()=>{document.activeElement===t&&e.focus()})}}function kn(e){Be&&xn(e)!==null&&wn(e)}var An=!1;function jn(){An||(An=!0,document.addEventListener(`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let t of e.target.elements)t[_e]?.()})},{capture:!0}))}function Mn(e){var t=lr,n=fr;dr(null),pr(null);try{return e()}finally{dr(t),pr(n)}}function Nn(e,t,n,r=n){e.addEventListener(t,()=>Mn(n));let i=e[_e];i?e[_e]=()=>{i(),r(!0)}:e[_e]=()=>r(!0),jn()}function Pn(e){fr===null&&(lr===null&&Te(e),we()),sr&&Ce(e)}function Fn(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function In(e,t){var n=fr;n!==null&&n.f&8192&&(e|=A);var r={ctx:F,deps:null,nodes:null,f:e|O|512,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};It?.register_created_effect(r);var i=r;if(e&4)Ht===null?Kt.ensure().schedule(r):Ht.push(r);else if(t!==null){try{Ar(r)}catch(e){throw Zn(r),e}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&!(i.f&524288)&&(i=i.first,e&16&&e&65536&&i!==null&&(i.f|=ne))}if(i!==null&&(i.parent=n,n!==null&&Fn(i,n),lr!==null&&lr.f&2&&!(e&64))){var a=lr;(a.effects??=[]).push(i)}return r}function Ln(){return lr!==null&&!ur}function Rn(e){let t=In(8,null);return ut(t,D),t.teardown=e,t}function zn(e){Pn(`$effect`);var t=fr.f;if(!lr&&t&32&&F!==null&&!F.i){var n=F;(n.e??=[]).push(e)}else return Bn(e)}function Bn(e){return In(4|ie,e)}function Vn(e){Kt.ensure();let t=In(64|re,e);return(e={})=>new Promise(n=>{e.outro?er(t,()=>{Zn(t),n(void 0)}):(Zn(t),n(void 0))})}function Hn(e){return In(4,e)}function Un(e){return In(ce|re,e)}function Wn(e,t=0){return In(8|t,e)}function U(e,t=[],n=[],r=[]){xt(r,t,n,t=>{In(8,()=>{e(...t.map(W))})})}function Gn(e,t=0){return In(16|t,e)}function Kn(e,t=0){return In(E|t,e)}function qn(e){return In(32|re,e)}function Jn(e){var t=e.teardown;if(t!==null){let e=sr,n=lr;cr(!0),dr(null);try{t.call(null)}finally{cr(e),dr(n)}}}function Yn(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&Mn(()=>{e.abort(ve)});var r=n.next;n.f&64?n.parent=null:Zn(n,t),n=r}}function Xn(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||Zn(t),t=n}}function Zn(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(Qn(e.nodes.start,e.nodes.end),n=!0),e.f|=j,Yn(e,t&&!n),kr(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();Jn(e),e.f^=j,e.f|=ee;var i=e.parent;i!==null&&i.first!==null&&$n(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function Qn(e,t){for(;e!==null;){var n=e===t?null:Sn(e);e.remove(),e=n}}function $n(e){var t=e.parent,n=e.prev,r=e.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function er(e,t,n=!0){var r=[];tr(e,r,!0);var i=()=>{n&&Zn(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function tr(e,t,n){if(!(e.f&8192)){e.f^=A;var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)(e.is_global||n)&&t.push(e);for(var i=e.first;i!==null;){var a=i.next;if(!(i.f&64)){var o=(i.f&65536)!=0||(i.f&32)!=0&&(e.f&16)!=0;tr(i,t,o?n:!1)}i=a}}}function nr(e){rr(e,!0)}function rr(e,t){if(e.f&8192){e.f^=A,e.f&1024||(ut(e,O),Kt.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=(n.f&65536)!=0||(n.f&32)!=0;rr(n,i?t:!1),n=r}var a=e.nodes&&e.nodes.t;if(a!==null)for(let e of a)(e.is_global||t)&&e.in()}}function ir(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:Sn(n);t.append(n),n=i}}var ar=null,or=!1,sr=!1;function cr(e){sr=e}var lr=null,ur=!1;function dr(e){lr=e}var fr=null;function pr(e){fr=e}var mr=null;function hr(e){lr!==null&&(!Ye||lr.f&2)&&(mr??=new Set).add(e)}var gr=null,_r=0,vr=null;function yr(e){vr=e}var br=1,xr=0,Sr=xr;function Cr(e){Sr=e}function wr(){return++br}function Tr(e){var t=e.f;if(t&2048)return!0;if(t&2&&(e.f&=~oe),t&4096){for(var n=e.deps,r=n.length,i=0;i<r;i++){var a=n[i];if(Tr(a)&&jt(a),a.wv>e.wv)return!0}t&512&&Rt===null&&ut(e,D)}return!1}function Er(e,t,n=!0){var r=e.reactions;if(r!==null&&!(!Ye&&mr!==null&&mr.has(e)))for(var i=0;i<r.length;i++){var a=r[i];a.f&2?Er(a,t,!1):t===a&&(n?ut(a,O):a.f&1024&&ut(a,k),$t(a))}}function Dr(e){var t=gr,n=_r,r=vr,i=lr,a=mr,o=F,s=ur,c=Sr,l=e.f;gr=null,_r=0,vr=null,lr=l&96?null:e,mr=null,Ze(e.ctx),ur=!1,Sr=++xr,e.ac!==null&&(Mn(()=>{e.ac.abort(ve)}),e.ac=null);try{e.f|=se;var u=e.fn,d=u();e.f|=te;var f=e.deps,p=It?.is_fork;if(gr!==null){var m;if(p||kr(e,_r),f!==null&&_r>0)for(f.length=_r+gr.length,m=0;m<gr.length;m++)f[_r+m]=gr[m];else e.deps=f=gr;if(Ln()&&e.f&512)for(m=_r;m<f.length;m++)(f[m].reactions??=[]).push(e)}else !p&&f!==null&&_r<f.length&&(kr(e,_r),f.length=_r);if(I()&&vr!==null&&!ur&&f!==null&&!(e.f&6146))for(m=0;m<vr.length;m++)Er(vr[m],e);if(i!==null&&i!==e){if(xr++,i.deps!==null)for(let e=0;e<n;e+=1)i.deps[e].rv=xr;if(t!==null)for(let e of t)e.rv=xr;vr!==null&&(r===null?r=vr:r.push(...vr))}return e.f&8388608&&(e.f^=le),d}catch(e){return st(e)}finally{e.f^=se,gr=t,_r=n,vr=r,lr=i,mr=a,Ze(o),ur=s,Sr=c}}function Or(e,t){let n=t.reactions;if(n!==null){var r=u.call(n,e);if(r!==-1){var i=n.length-1;i===0?n=t.reactions=null:(n[r]=n[i],n.pop())}}if(n===null&&t.f&2&&(gr===null||!d.call(gr,t))){var a=t;a.f&512&&(a.f^=512,a.f&=~oe),a.v!==Ne&&dt(a),Mt(a),kr(a,0)}}function kr(e,t){var n=e.deps;if(n!==null)for(var r=t;r<n.length;r++)Or(e,n[r])}function Ar(e){var t=e.f;if(!(t&16384)){ut(e,D);var n=fr,r=or;fr=e,or=!0;try{t&16777232?Xn(e):Yn(e),Jn(e);var i=Dr(e);e.teardown=typeof i==`function`?i:null,e.wv=br}finally{or=r,fr=n}}}async function jr(){if(Ye)return new Promise(e=>{requestAnimationFrame(()=>e()),setTimeout(()=>e())});await Promise.resolve(),qt()}function W(e){var t=(e.f&2)!=0;if(ar?.add(e),lr!==null&&!ur&&!(fr!==null&&fr.f&16384)&&(mr===null||!mr.has(e))){var n=lr.deps;if(lr.f&2097152)e.rv<xr&&(e.rv=xr,gr===null&&n!==null&&n[_r]===e?_r++:gr===null?gr=[e]:gr.push(e));else{lr.deps??=[],d.call(lr.deps,e)||lr.deps.push(e);var r=e.reactions;r===null?e.reactions=[lr]:d.call(r,lr)||r.push(lr)}}if(sr&&rn.has(e))return rn.get(e);if(t){var i=e;if(sr){var a=i.v;return(!(i.f&1024)&&i.reactions!==null||Nr(i))&&(a=At(i)),rn.set(i,a),a}var o=(i.f&512)==0&&!ur&&lr!==null&&(or||(lr.f&512)!=0),s=(i.f&te)===0;Tr(i)&&(o&&(i.f|=512),jt(i)),o&&!s&&(Nt(i),Mr(i))}if(Rt?.has(e))return Rt.get(e);if(e.f&8388608)throw e.v;return e.v}function Mr(e){if(e.f|=512,e.deps!==null)for(let t of e.deps)(t.reactions??=[]).push(e),t.f&2&&!(t.f&512)&&(Nt(t),Mr(t))}function Nr(e){if(e.v===Ne)return!0;if(e.deps===null)return!1;for(let t of e.deps)if(rn.has(t)||t.f&2&&Nr(t))return!0;return!1}function Pr(e){var t=ur;try{return ur=!0,e()}finally{ur=t}}function Fr(e){if(!(typeof e!=`object`||!e||e instanceof EventTarget)){if(ue in e)Ir(e);else if(!Array.isArray(e))for(let t in e){let n=e[t];typeof n==`object`&&n&&ue in n&&Ir(n)}}}function Ir(e,t=new Set){if(typeof e==`object`&&e&&!(e instanceof EventTarget)&&!t.has(e)){t.add(e),e instanceof Date&&e.getTime();for(let n in e)try{Ir(e[n],t)}catch{}let n=v(e);if(n!==Object.prototype&&n!==Array.prototype&&n!==Map.prototype&&n!==Set.prototype&&n!==Date.prototype){let t=h(n);for(let n in t){let r=t[n].get;if(r)try{r.call(e)}catch{}}}}}function Lr(e){return e.endsWith(`capture`)&&e!==`gotpointercapture`&&e!==`lostpointercapture`}var Rr=[`beforeinput`,`click`,`change`,`dblclick`,`contextmenu`,`focusin`,`focusout`,`input`,`keydown`,`keyup`,`mousedown`,`mousemove`,`mouseout`,`mouseover`,`mouseup`,`pointerdown`,`pointermove`,`pointerout`,`pointerover`,`pointerup`,`touchend`,`touchmove`,`touchstart`];function zr(e){return Rr.includes(e)}var Br=`allowfullscreen.async.autofocus.autoplay.checked.controls.default.disabled.formnovalidate.indeterminate.inert.ismap.loop.multiple.muted.nomodule.novalidate.open.playsinline.readonly.required.reversed.seamless.selected.webkitdirectory.defer.disablepictureinpicture.disableremoteplayback`.split(`.`),Vr={formnovalidate:`formNoValidate`,ismap:`isMap`,nomodule:`noModule`,playsinline:`playsInline`,readonly:`readOnly`,defaultvalue:`defaultValue`,defaultchecked:`defaultChecked`,srcobject:`srcObject`,novalidate:`noValidate`,allowfullscreen:`allowFullscreen`,disablepictureinpicture:`disablePictureInPicture`,disableremoteplayback:`disableRemotePlayback`};function Hr(e){return e=e.toLowerCase(),Vr[e]??e}[...Br];var Ur=[`touchstart`,`touchmove`];function Wr(e){return Ur.includes(e)}var Gr=[`textarea`,`script`,`style`,`title`];function Kr(e){return Gr.includes(e)}var qr=Symbol(`events`),Jr=new Set,Yr=new Set;function Xr(e,t,n,r={}){function i(e){if(r.capture||ei.call(t,e),!e.cancelBubble)return Mn(()=>n?.call(this,e))}return e.startsWith(`pointer`)||e.startsWith(`touch`)||e===`wheel`?at(()=>{t.addEventListener(e,i,r)}):t.addEventListener(e,i,r),i}function Zr(e,t,n,r,i){var a={capture:r,passive:i},o=Xr(e,t,n,a);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&Rn(()=>{t.removeEventListener(e,o,a)})}function G(e,t,n){(t[qr]??={})[e]=n}function Qr(e){for(var t=0;t<e.length;t++)Jr.add(e[t]);for(var n of Yr)n(e)}var $r=null;function ei(e){var t=this,n=t.ownerDocument,r=e.type,i=e.composedPath?.()||[],a=i[0]||e.target;$r=e;var o=0,s=$r===e&&e[qr];if(s){var c=i.indexOf(s);if(c!==-1&&(t===document||t===window)){e[qr]=t;return}var l=i.indexOf(t);if(l===-1)return;c<=l&&(o=c)}if(a=i[o]||e.target,a!==t){p(e,`currentTarget`,{configurable:!0,get(){return a||n}});var u=lr,d=fr;dr(null),pr(null);try{for(var f,m=[];a!==null&&a!==t;){try{var h=a[qr]?.[r];h!=null&&(!a.disabled||e.target===a)&&h.call(a,e)}catch(e){f?m.push(e):f=e}if(e.cancelBubble)break;o++,a=o<i.length?i[o]:null}if(f){for(let e of m)queueMicrotask(()=>{throw e});throw f}}finally{e[qr]=t,delete e.currentTarget,dr(u),pr(d)}}}var ti=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function ni(e){return ti?.createHTML(e)??e}function ri(e){var t=En(`template`);return t.innerHTML=ni(e.replaceAll(`<!>`,`<!---->`)),t.content}function ii(e,t){var n=fr;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function K(e,t){var n=(t&1)!=0,r=(t&2)!=0,i,a=!e.startsWith(`<!>`);return()=>{if(Be)return ii(M,null),M;i===void 0&&(i=ri(a?e:`<!>`+e),n||(i=xn(i)));var t=r||gn?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=xn(t),s=t.lastChild;ii(o,s)}else ii(t,t);return t}}function ai(e,t,n=`svg`){var r=!e.startsWith(`<!>`),i=(t&1)!=0,a=`<${n}>${r?e:`<!>`+e}</${n}>`,o;return()=>{if(Be)return ii(M,null),M;if(!o){var e=xn(ri(a));if(i)for(o=document.createDocumentFragment();xn(e);)o.appendChild(xn(e));else o=xn(e)}var t=o.cloneNode(!0);if(i){var n=xn(t),r=t.lastChild;ii(n,r)}else ii(t,t);return t}}function oi(e,t){return ai(e,t,`svg`)}function si(e=``){if(!Be){var t=bn(e+``);return ii(t,t),t}var n=M;return n.nodeType===3?Dn(n):(n.before(n=bn()),He(n)),ii(n,n),n}function ci(){if(Be)return ii(M,null),M;var e=document.createDocumentFragment(),t=document.createComment(``),n=bn();return e.append(t,n),ii(t,n),e}function q(e,t){if(Be){var n=fr;(!(n.f&32768)||n.nodes.end===null)&&(n.nodes.end=M),Ue();return}e!==null&&e.before(t)}var li=!0;function ui(e){li=e}function J(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e[ge]??=e.nodeValue)&&(e[ge]=n,e.nodeValue=`${n}`)}function di(e,t){return pi(e,t)}var fi=new Map;function pi(e,{target:t,anchor:n,props:r={},events:i,context:a,intro:o=!0,transformError:s}){yn();var c=void 0,l=Vn(()=>{var l=n??t.appendChild(bn());yt(l,{pending:()=>{}},t=>{$e({});var n=F;if(a&&(n.c=a),i&&(r.$$events=i),Be&&ii(t,null),li=o,c=e(t,r)||{},li=!0,Be&&(fr.nodes.end=M,M===null||M.nodeType!==8||M.data!==`]`))throw Le(),Me;et()},s);var u=new Set,d=e=>{for(var n=0;n<e.length;n++){var r=e[n];if(!u.has(r)){u.add(r);var i=Wr(r);for(let e of[t,document]){var a=fi.get(e);a===void 0&&(a=new Map,fi.set(e,a));var o=a.get(r);o===void 0?(e.addEventListener(r,ei,{passive:i}),a.set(r,1)):a.set(r,o+1)}}}};return d(f(Jr)),Yr.add(d),()=>{for(var e of u)for(let n of[t,document]){var r=fi.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,ei),r.delete(e),r.size===0&&fi.delete(n)):r.set(e,i)}Yr.delete(d),l!==n&&l.parentNode?.removeChild(l)}});return mi.set(c,l),c}var mi=new WeakMap,hi=class{anchor;#e=new Map;#t=new Map;#n=new Map;#r=new Set;#i=!0;constructor(e,t=!0){this.anchor=e,this.#i=t}#a=e=>{if(this.#e.has(e)){var t=this.#e.get(e),n=this.#t.get(t);if(n)nr(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(nr(r.effect),this.#t.set(t,r.effect),this.#n.delete(t),r.fragment.lastChild.remove(),this.anchor.before(r.fragment),n=r.effect)}for(let[t,n]of this.#e){if(this.#e.delete(t),t===e)break;let r=this.#n.get(n);r&&(Zn(r.effect),this.#n.delete(n))}for(let[e,r]of this.#t){if(e===t||this.#r.has(e))continue;let i=()=>{if(Array.from(this.#e.values()).includes(e)){var t=document.createDocumentFragment();ir(r,t),t.append(bn()),this.#n.set(e,{effect:r,fragment:t})}else Zn(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),er(r,i,!1)):i()}}};#o=e=>{this.#e.delete(e);let t=Array.from(this.#e.values());for(let[e,n]of this.#n)t.includes(e)||(Zn(n.effect),this.#n.delete(e))};ensure(e,t){var n=It,r=Tn();if(t&&!this.#t.has(e)&&!this.#n.has(e))if(r){var i=document.createDocumentFragment(),a=bn();i.append(a),this.#n.set(e,{effect:qn(()=>t(a)),fragment:i})}else this.#t.set(e,qn(()=>t(this.anchor)));if(this.#e.set(n,e),r){for(let[t,r]of this.#t)t===e?n.unskip_effect(r):n.skip_effect(r);for(let[t,r]of this.#n)t===e?n.unskip_effect(r.effect):n.skip_effect(r.effect);n.oncommit(this.#a),n.ondiscard(this.#o)}else Be&&(this.anchor=M),this.#a(n)}},gi=0,_i=1,vi=2;function yi(e,t,n,r,i){Be&&Ue();var a=I(),o=Ne,s=a?on(o):sn(o,!1,!1),c=a?on(o):sn(o,!1,!1),l=new hi(e);Gn(()=>{var a=It,o=t(),u=!1;let d=Be&&S(o)===(e.data===`[!`);if(d&&(He(We()),Ve(!1)),S(o)){var f=St(),p=!1;let e=e=>{if(!u){p=!0,f(!1),It===a&&a.deactivate(),Kt.ensure();try{e()}finally{Ct(!1),Bt||qt()}}};o.then(t=>{e(()=>{cn(s,t),l.ensure(_i,r&&(e=>r(e,s)))})},t=>{e(()=>{if(cn(c,t),l.ensure(vi,i&&(e=>i(e,c))),!i)throw c.v})}),Be?l.ensure(gi,n):at(()=>{p||e(()=>{l.ensure(gi,n)})})}else cn(s,o),l.ensure(_i,r&&(e=>r(e,s)));return d&&Ve(!0),()=>{u=!0}})}function Y(e,t,n=!1){var r;Be&&(r=M,Ue());var i=new hi(e),a=n?ne:0;function o(e,t){if(Be){var n=Ge(r);if(e!==parseInt(n.substring(1))){var a=We();He(a),i.anchor=a,Ve(!1),i.ensure(e,t),Ve(!0);return}}i.ensure(e,t)}Gn(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}var bi=Symbol(`NaN`);function xi(e,t,n){Be&&Ue();var r=new hi(e),i=!I();Gn(()=>{var e=t();e!==e&&(e=bi),i&&typeof e==`object`&&e&&(e={}),r.ensure(e,n)})}function Si(e,t){return t}function Ci(e,t,n){for(var r=[],i=t.length,a,o=t.length,s=0;s<i;s++){let n=t[s];er(n,()=>{if(a){if(a.pending.delete(n),a.done.add(n),a.pending.size===0){var t=e.outrogroups;wi(e,f(a.done)),t.delete(a),t.size===0&&(e.outrogroups=null)}}else --o},!1)}if(o===0){var c=r.length===0&&n!==null;if(c){var l=n,u=l.parentNode;wn(u),u.append(l),e.items.clear()}wi(e,t,!c)}else a={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(a)}function wi(e,t,n=!0){var r;if(e.pending.size>0){r=new Set;for(let t of e.pending.values())for(let n of t)r.add(e.items.get(n).e)}for(var i=0;i<t.length;i++){var a=t[i];r?.has(a)?(a.f|=ae,ir(a,document.createDocumentFragment())):Zn(t[i],n)}}var Ti;function Ei(e,t,n,r,i,a=null){var o=e,s=new Map;if(t&4){var c=e;o=Be?He(xn(c)):c.appendChild(bn())}Be&&Ue();var u=null,d=Ot(()=>{var e=n();return l(e)?e:e==null?[]:f(e)}),p,m=new Map,h=!0;function g(e){v.effect.f&16384||(v.pending.delete(e),v.fallback=u,Oi(v,p,o,t,r),u!==null&&(p.length===0?u.f&33554432?(u.f^=ae,Ai(u,null,o)):nr(u):er(u,()=>{u=null})))}function _(e){v.pending.delete(e)}var v={effect:Gn(()=>{p=W(d);var e=p.length;let c=!1;Be&&Ge(o)===`[!`!=(e===0)&&(o=We(),He(o),Ve(!1),c=!0);for(var l=new Set,f=It,v=Tn(),y=0;y<e;y+=1){Be&&M.nodeType===8&&M.data===`]`&&(o=M,c=!0,Ve(!1));var b=p[y],x=r(b,y),S=h?null:s.get(x);S?(S.v&&cn(S.v,b),S.i&&cn(S.i,y),v&&f.unskip_effect(S.e)):(S=ki(s,h?o:Ti??=bn(),b,x,y,i,t,n),h||(S.e.f|=ae),s.set(x,S)),l.add(x)}if(e===0&&a&&!u&&(h?u=qn(()=>a(o)):(u=qn(()=>a(Ti??=bn())),u.f|=ae)),e>l.size&&Se(``,``,``),Be&&e>0&&He(We()),!h)if(m.set(f,l),v){for(let[e,t]of s)l.has(e)||f.skip_effect(t.e);f.oncommit(g),f.ondiscard(_)}else g(f);c&&Ve(!0),W(d)}),flags:t,items:s,pending:m,outrogroups:null,fallback:u};h=!1,Be&&(o=M)}function Di(e){for(;e!==null&&!(e.f&32);)e=e.next;return e}function Oi(e,t,n,r,i){var a=(r&8)!=0,o=t.length,s=e.items,c=Di(e.effect.first),l,u=null,d,p=[],m=[],h,g,_,v;if(a)for(v=0;v<o;v+=1)h=t[v],g=i(h,v),_=s.get(g).e,_.f&33554432||(_.nodes?.a?.measure(),(d??=new Set).add(_));for(v=0;v<o;v+=1){if(h=t[v],g=i(h,v),_=s.get(g).e,e.outrogroups!==null)for(let t of e.outrogroups)t.pending.delete(_),t.done.delete(_);if(_.f&8192&&(nr(_),a&&(_.nodes?.a?.unfix(),(d??=new Set).delete(_))),_.f&33554432)if(_.f^=ae,_===c)Ai(_,null,n);else{var y=u?u.next:c;_===e.effect.last&&(e.effect.last=_.prev),_.prev&&(_.prev.next=_.next),_.next&&(_.next.prev=_.prev),ji(e,u,_),ji(e,_,y),Ai(_,y,n),u=_,p=[],m=[],c=Di(u.next);continue}if(_!==c){if(l!==void 0&&l.has(_)){if(p.length<m.length){var b=m[0],x;u=b.prev;var S=p[0],C=p[p.length-1];for(x=0;x<p.length;x+=1)Ai(p[x],b,n);for(x=0;x<m.length;x+=1)l.delete(m[x]);ji(e,S.prev,C.next),ji(e,u,S),ji(e,C,b),c=b,u=C,--v,p=[],m=[]}else l.delete(_),Ai(_,c,n),ji(e,_.prev,_.next),ji(e,_,u===null?e.effect.first:u.next),ji(e,u,_),u=_;continue}for(p=[],m=[];c!==null&&c!==_;)(l??=new Set).add(c),m.push(c),c=Di(c.next);if(c===null)continue}_.f&33554432||p.push(_),u=_,c=Di(_.next)}if(e.outrogroups!==null){for(let t of e.outrogroups)t.pending.size===0&&(wi(e,f(t.done)),e.outrogroups?.delete(t));e.outrogroups.size===0&&(e.outrogroups=null)}if(c!==null||l!==void 0){var w=[];if(l!==void 0)for(_ of l)_.f&8192||w.push(_);for(;c!==null;)!(c.f&8192)&&c!==e.fallback&&w.push(c),c=Di(c.next);var T=w.length;if(T>0){var E=r&4&&o===0?n:null;if(a){for(v=0;v<T;v+=1)w[v].nodes?.a?.measure();for(v=0;v<T;v+=1)w[v].nodes?.a?.fix()}Ci(e,w,E)}}a&&at(()=>{if(d!==void 0)for(_ of d)_.nodes?.a?.apply()})}function ki(e,t,n,r,i,a,o,s){var c=o&1?o&16?on(n):sn(n,!1,!1):null,l=o&2?on(i):null;return{v:c,i:l,e:qn(()=>(a(t,c??n,l??i,s),()=>{e.delete(r)}))}}function Ai(e,t,n){if(e.nodes)for(var r=e.nodes.start,i=e.nodes.end,a=t&&!(t.f&33554432)?t.nodes.start:n;r!==null;){var o=Sn(r);if(a.before(r),r===i)return;r=o}}function ji(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function Mi(e,t,...n){var r=new hi(e);Gn(()=>{let e=t()??null;r.ensure(e,e&&(t=>e(t,...n)))},ne)}function Ni(e,t,n){var r;Be&&(r=M,Ue());var i=new hi(e);Gn(()=>{var e=t()??null;if(Be&&Ge(r)===`[`!=(e!==null)){var a=We();He(a),i.anchor=a,Ve(!1),i.ensure(e,e&&(t=>n(t,e))),Ve(!0);return}i.ensure(e,e&&(t=>n(t,e)))},ne)}var Pi=()=>performance.now(),Fi={tick:e=>requestAnimationFrame(e),now:()=>Pi(),tasks:new Set};function Ii(){let e=Fi.now();Fi.tasks.forEach(t=>{t.c(e)||(Fi.tasks.delete(t),t.f())}),Fi.tasks.size!==0&&Fi.tick(Ii)}function Li(e){let t;return Fi.tasks.size===0&&Fi.tick(Ii),{promise:new Promise(n=>{Fi.tasks.add(t={c:e,f:n})}),abort(){Fi.tasks.delete(t)}}}function Ri(e,t){Mn(()=>{e.dispatchEvent(new CustomEvent(t))})}function zi(e){if(e===`float`)return`cssFloat`;if(e===`offset`)return`cssOffset`;if(e.startsWith(`--`))return e;let t=e.split(`-`);return t.length===1?t[0]:t[0]+t.slice(1).map(e=>e[0].toUpperCase()+e.slice(1)).join(``)}function Bi(e){let t={},n=e.split(`;`);for(let e of n){let[n,r]=e.split(`:`);if(!n||r===void 0)break;let i=zi(n.trim());t[i]=r.trim()}return t}var Vi=e=>e;function Hi(e,t,n,r){var i=(e&1)!=0,a=(e&2)!=0,o=i&&a,s=(e&4)!=0,c=o?`both`:i?`in`:`out`,l,u=t.inert,d=t.style.overflow,f,p;function m(){return Mn(()=>l??=n()(t,r?.()??{},{direction:c}))}var h={is_global:s,in(){if(t.inert=u,!i){p?.abort(),p?.reset?.();return}a||f?.abort(),f=Ui(t,m(),p,1,()=>{Ri(t,`introstart`)},()=>{Ri(t,`introend`),f?.abort(),f=l=void 0,t.style.overflow=d})},out(e){if(!a){e?.(),l=void 0;return}t.inert=!0,p=Ui(t,m(),f,0,()=>{Ri(t,`outrostart`)},()=>{Ri(t,`outroend`),e?.()})},stop:()=>{f?.abort(),p?.abort()}},g=fr;if((g.nodes.t??=[]).push(h),i&&li){var _=s;if(!_){for(var v=g.parent;v&&v.f&65536;)for(;(v=v.parent)&&!(v.f&16););_=!v||(v.f&32768)!=0}_&&Hn(()=>{Pr(()=>h.in())})}}function Ui(e,t,n,r,i,a){var o=r===1;if(b(t)){var s,c=!1;return at(()=>{c||(s=Ui(e,t({direction:o?`in`:`out`}),n,r,i,a))}),{abort:()=>{c=!0,s?.abort()},deactivate:()=>s.deactivate(),reset:()=>s.reset(),t:()=>s.t()}}if(n?.deactivate(),!t?.duration&&!t?.delay)return i(),a(),{abort:x,deactivate:x,reset:x,t:()=>r};let{delay:l=0,css:u,tick:d,easing:f=Vi}=t;var p=[];if(o&&n===void 0&&(d&&d(0,1),u)){var m=Bi(u(0,1));p.push(m,m)}var h=()=>1-r,g=e.animate(p,{duration:l,fill:`forwards`});return g.onfinish=()=>{g.cancel(),i();var o=n?.t()??1-r;n?.abort();var s=r-o,c=t.duration*Math.abs(s),l=[];if(c>0){var p=!1;if(u)for(var m=Math.ceil(c/(1e3/60)),_=0;_<=m;_+=1){var v=o+s*f(_/m),y=Bi(u(v,1-v));l.push(y),p||=y.overflow===`hidden`}p&&(e.style.overflow=`hidden`),h=()=>{var e=g.currentTime;return o+s*f(e/c)},d&&Li(()=>{if(g.playState!==`running`)return!1;var e=h();return d(e,1-e),!0})}g=e.animate(l,{duration:c,fill:`forwards`}),g.onfinish=()=>{h=()=>r,d?.(r,1-r),a()}},{abort:()=>{g&&(g.cancel(),g.effect=null,g.onfinish=x)},deactivate:()=>{a=x},reset:()=>{r===0&&d?.(1,0)},t:()=>h()}}function Wi(e,t,n,r,i,a){let o=Be;Be&&Ue();var s=null;Be&&M.nodeType===1&&(s=M,Ue());var c=Be?M:e,l=new hi(c,!1);Gn(()=>{let e=t()||null;var a=i?i():n||e===`svg`?Fe:void 0;if(e===null){l.ensure(null,null),ui(!0);return}return l.ensure(e,t=>{if(e){if(s=Be?s:En(e,a),ii(s,s),r){var n=null;Be&&Kr(e)&&s.append(n=document.createComment(``));var i=Be?xn(s):s.appendChild(bn());Be&&(i===null?Ve(!1):He(i)),r(s,i),n?.remove()}fr.nodes.end=s,t.before(s)}Be&&He(t)}),ui(!0),()=>{e&&ui(!1)}},ne),Rn(()=>{ui(!0)}),o&&(Ve(!0),He(c))}function Gi(e,t,n){Hn(()=>{var r=Pr(()=>t(e,n?.())||{});if(n&&r?.update){var i=!1,a={};Wn(()=>{var e=n();Fr(e),i&&qe(a,e)&&(a=e,r.update(e))}),i=!0}if(r?.destroy)return()=>r.destroy()})}function Ki(e,t){var n=void 0,r;Kn(()=>{n!==(n=t())&&(r&&=(Zn(r),null),n&&(r=qn(()=>{Hn(()=>n(e))})))})}function qi(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=qi(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function Ji(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=qi(e))&&(r&&(r+=` `),r+=t);return r}function Yi(e){return typeof e==`object`?Ji(e):e??``}var Xi=[...`
3
+ \r\f\xA0\v`];function Zi(e,t,n){var r=e==null?``:``+e;if(t&&(r=r?r+` `+t:t),n){for(var i of Object.keys(n))if(n[i])r=r?r+` `+i:i;else if(r.length)for(var a=i.length,o=0;(o=r.indexOf(i,o))>=0;){var s=o+a;(o===0||Xi.includes(r[o-1]))&&(s===r.length||Xi.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function Qi(e,t=!1){var n=t?` !important;`:`;`,r=``;for(var i of Object.keys(e)){var a=e[i];a!=null&&a!==``&&(r+=` `+i+`: `+a+n)}return r}function $i(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function ea(e,t){if(t){var n=``,r,i;if(Array.isArray(t)?(r=t[0],i=t[1]):r=t,e){e=String(e).replaceAll(/\s*\/\*.*?\*\/\s*/g,``).trim();var a=!1,o=0,s=!1,c=[];r&&c.push(...Object.keys(r).map($i)),i&&c.push(...Object.keys(i).map($i));var l=0,u=-1;let t=e.length;for(var d=0;d<t;d++){var f=e[d];if(s?f===`/`&&e[d-1]===`*`&&(s=!1):a?a===f&&(a=!1):f===`/`&&e[d+1]===`*`?s=!0:f===`"`||f===`'`?a=f:f===`(`?o++:f===`)`&&o--,!s&&a===!1&&o===0){if(f===`:`&&u===-1)u=d;else if(f===`;`||d===t-1){if(u!==-1){var p=$i(e.substring(l,u).trim());if(!c.includes(p)){f!==`;`&&d++;var m=e.substring(l,d).trim();n+=` `+m+`;`}}l=d+1,u=-1}}}}return r&&(n+=Qi(r)),i&&(n+=Qi(i,!0)),n=n.trim(),n===``?null:n}return e==null?null:String(e)}function ta(e,t,n,r,i,a){var o=e[me];if(Be||o!==n||o===void 0){var s=Zi(n,r,a);(!Be||s!==e.getAttribute(`class`))&&(s==null?e.removeAttribute(`class`):t?e.className=s:e.setAttribute(`class`,s)),e[me]=n}else if(a&&i!==a)for(var c in a){var l=!!a[c];(i==null||l!==!!i[c])&&e.classList.toggle(c,l)}return a}function na(e,t={},n,r){for(var i in n){var a=n[i];t[i]!==a&&(n[i]==null?e.style.removeProperty(i):e.style.setProperty(i,a,r))}}function ra(e,t,n,r){var i=e[he];if(Be||i!==t){var a=ea(t,r);(!Be||a!==e.getAttribute(`style`))&&(a==null?e.removeAttribute(`style`):e.style.cssText=a),e[he]=t}else r&&(Array.isArray(r)?(na(e,n?.[0],r[0]),na(e,n?.[1],r[1],`important`)):na(e,n,r));return r}function ia(e,t,n=!1){if(e.multiple){if(t==null)return;if(!l(t))return Re();for(var r of e.options)r.selected=t.includes(oa(r));return}for(r of e.options)if(mn(oa(r),t)){r.selected=!0;return}(!n||t!==void 0)&&(e.selectedIndex=-1)}function aa(e){var t=new MutationObserver(()=>{ia(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`]}),Rn(()=>{t.disconnect()})}function oa(e){return`__value`in e?e.__value:e.value}var sa=Symbol(`class`),ca=Symbol(`style`),la=Symbol(`is custom element`),ua=Symbol(`is html`),da=ye?`link`:`LINK`,fa=ye?`input`:`INPUT`,pa=ye?`option`:`OPTION`,ma=ye?`select`:`SELECT`,ha=ye?`progress`:`PROGRESS`;function X(e){if(Be){var t=!1,n=()=>{if(!t){if(t=!0,e.hasAttribute(`value`)){var n=e.value;Z(e,`value`,null),e.value=n}if(e.hasAttribute(`checked`)){var r=e.checked;Z(e,`checked`,null),e.checked=r}}};e[_e]=n,at(n),jn()}}function ga(e,t){var n=xa(e);n.value===(n.value=t??void 0)||e.value===t&&(t!==0||e.nodeName!==ha)||(e.value=t??``)}function _a(e,t){var n=xa(e);n.checked!==(n.checked=t??void 0)&&(e.checked=t)}function va(e,t){t?e.hasAttribute(`selected`)||e.setAttribute(`selected`,``):e.removeAttribute(`selected`)}function Z(e,t,n,r){var i=xa(e);Be&&(i[t]=e.getAttribute(t),t===`src`||t===`srcset`||t===`href`&&e.nodeName===da)||i[t]!==(i[t]=n)&&(t===`loading`&&(e[fe]=n),n==null?e.removeAttribute(t):typeof n!=`string`&&Ca(e).includes(t)?e[t]=n:e.setAttribute(t,n))}function ya(e,t,n,r,i=!1,a=!1){if(Be&&i&&e.nodeName===fa){var o=e;(o.type===`checkbox`?`defaultChecked`:`defaultValue`)in n||X(o)}var s=xa(e),c=s[la],l=!s[ua];let u=Be&&c;u&&Ve(!1);var d=t||{},f=e.nodeName===pa;for(var p in t)p in n||(n[p]=null);n.class?n.class=Yi(n.class):(r||n[sa])&&(n.class=null),n[ca]&&(n.style??=null);var m=Ca(e);if(e.nodeName===fa&&`type`in n&&(`value`in n||`__value`in n)){var h=n.type;(h!==d.type||h===void 0&&e.hasAttribute(`type`))&&(d.type=h,Z(e,`type`,h,a))}for(let i in n){let o=n[i];if(f&&i===`value`&&o==null){e.value=e.__value=``,d[i]=o;continue}if(i===`class`){ta(e,e.namespaceURI===`http://www.w3.org/1999/xhtml`,o,r,t?.[sa],n[sa]),d[i]=o,d[sa]=n[sa];continue}if(i===`style`){ra(e,o,t?.[ca],n[ca]),d[i]=o,d[ca]=n[ca];continue}var g=d[i];if(!(o===g&&!(o===void 0&&e.hasAttribute(i)))){d[i]=o;var _=i[0]+i[1];if(_!==`$$`)if(_===`on`){let t={},n=`$$`+i,r=i.slice(2);var v=zr(r);if(Lr(r)&&(r=r.slice(0,-7),t.capture=!0),!v&&g){if(o!=null)continue;e.removeEventListener(r,d[n],t),d[n]=null}if(v)G(r,e,o),Qr([r]);else if(o!=null){function a(e){d[i].call(this,e)}d[n]=Xr(r,e,a,t)}}else if(i===`style`)Z(e,i,o);else if(i===`autofocus`)On(e,!!o);else if(!c&&(i===`__value`||i===`value`&&o!=null))e.value=e.__value=o;else if(i===`selected`&&f)va(e,o);else{var y=i;l||(y=Hr(y));var b=y===`defaultValue`||y===`defaultChecked`;if(o==null&&!c&&!b)if(s[i]=null,y===`value`||y===`checked`){let n=e,r=t===void 0;if(y===`value`){let e=n.defaultValue;n.removeAttribute(y),n.defaultValue=e,n.value=n.__value=r?e:null}else{let e=n.defaultChecked;n.removeAttribute(y),n.defaultChecked=e,n.checked=r?e:!1}}else e.removeAttribute(i);else b||m.includes(y)&&(c||typeof o!=`string`)?(e[y]=o,y in s&&(s[y]=Ne)):typeof o!=`function`&&Z(e,y,o,a)}}}return u&&Ve(!0),d}function ba(e,t,n=[],r=[],i=[],a,o=!1,s=!1){xt(i,n,r,n=>{var r=void 0,i={},c=e.nodeName===ma,l=!1;if(Kn(()=>{var u=t(...n.map(W)),d=ya(e,r,u,a,o,s);l&&c&&`value`in u&&ia(e,u.value);for(let e of Object.getOwnPropertySymbols(i))u[e]||Zn(i[e]);for(let t of Object.getOwnPropertySymbols(u)){var f=u[t];t.description===`@attach`&&(!r||f!==r[t])&&(i[t]&&Zn(i[t]),i[t]=qn(()=>Ki(e,()=>f))),d[t]=f}r=d}),c){var u=e;Hn(()=>{ia(u,r.value,!0),aa(u)})}l=!0})}function xa(e){return e[pe]??={[la]:e.nodeName.includes(`-`),[ua]:e.namespaceURI===Pe}}var Sa=new Map;function Ca(e){var t=e.getAttribute(`is`)||e.nodeName,n=Sa.get(t);if(n)return n;Sa.set(t,n=[]);for(var r,i=e,a=Element.prototype;a!==i;){for(var o in r=h(i),r)r[o].set&&o!==`innerHTML`&&o!==`textContent`&&o!==`innerText`&&n.push(o);i=v(i)}return n}function wa(e,t,n=t){var r=new WeakSet;Nn(e,`input`,async i=>{var a=i?e.defaultValue:e.value;if(a=Ta(e)?Ea(a):a,n(a),It!==null&&r.add(It),await jr(),a!==(a=t())){var o=e.selectionStart,s=e.selectionEnd,c=e.value.length;if(e.value=a??``,s!==null){var l=e.value.length;o===s&&s===c&&l>c?(e.selectionStart=l,e.selectionEnd=l):(e.selectionStart=o,e.selectionEnd=Math.min(s,l))}}}),(Be&&e.defaultValue!==e.value||Pr(t)==null&&e.value)&&(n(Ta(e)?Ea(e.value):e.value),It!==null&&r.add(It)),Wn(()=>{var n=t();if(e===document.activeElement){var i=Ye?Lt:It;if(r.has(i))return}Ta(e)&&n===Ea(e.value)||e.type===`date`&&!n&&!e.value||n!==e.value&&(e.value=n??``)})}function Ta(e){var t=e.type;return t===`number`||t===`range`}function Ea(e){return e===``?null:+e}function Da(e,t){return e===t||e?.[ue]===t}function Oa(e={},t,n,r){var i=F.r,a=fr;return Hn(()=>{var o,s;return Wn(()=>{o=s,s=r?.()||[],Pr(()=>{Da(n(...s),e)||(t(e,...s),o&&Da(n(...o),e)&&t(null,...o))})}),()=>{let r=a;for(;r!==i&&r.parent!==null&&r.parent.f&33554432;)r=r.parent;let o=()=>{s&&Da(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c?.()}}}),e}var ka={get(e,t){if(!e.exclude.has(t))return e.props[t]},set(e,t){return!1},getOwnPropertyDescriptor(e,t){if(!e.exclude.has(t)&&t in e.props)return{enumerable:!0,configurable:!0,value:e.props[t]}},has(e,t){return e.exclude.has(t)?!1:t in e.props},ownKeys(e){return Reflect.ownKeys(e.props).filter(t=>!e.exclude.has(t))}};function Aa(e,t,n){return new Proxy({props:e,exclude:t},ka)}var ja={get(e,t){let n=e.props.length;for(;n--;){let r=e.props[n];if(b(r)&&(r=r()),typeof r==`object`&&r&&t in r)return r[t]}},set(e,t,n){let r=e.props.length;for(;r--;){let i=e.props[r];b(i)&&(i=i());let a=m(i,t);if(a&&a.set)return a.set(n),!0}return!1},getOwnPropertyDescriptor(e,t){let n=e.props.length;for(;n--;){let r=e.props[n];if(b(r)&&(r=r()),typeof r==`object`&&r&&t in r){let e=m(r,t);return e&&!e.configurable&&(e.configurable=!0),e}}},has(e,t){if(t===ue||t===de)return!1;for(let n of e.props)if(b(n)&&(n=n()),n!=null&&t in n)return!0;return!1},ownKeys(e){let t=[];for(let n of e.props)if(b(n)&&(n=n()),n){for(let e in n)t.includes(e)||t.push(e);for(let e of Object.getOwnPropertySymbols(n))t.includes(e)||t.push(e)}return t}};function Ma(...e){return new Proxy({props:e},ja)}function Na(e,t,n,r){var i=!Xe||(n&2)!=0,a=(n&8)!=0,o=(n&16)!=0,s=r,c=!0,l=void 0,u=()=>o&&i?(l??=Tt(r),W(l)):(c&&(c=!1,s=o?Pr(r):r),s);let d;if(a){var f=ue in e||de in e;d=m(e,t)?.set??(f&&t in e?n=>e[t]=n:void 0)}var p,h=!1;a?[p,h]=gt(()=>e[t]):p=e[t],p===void 0&&r!==void 0&&(p=u(),d&&(i&&De(t),d(p)));var g=i?()=>{var n=e[t];return n===void 0?u():(c=!0,n)}:()=>{var n=e[t];return n!==void 0&&(s=void 0),n===void 0?s:n};if(i&&!(n&4))return g;if(d){var _=e.$$legacy;return(function(e,t){return arguments.length>0?((!i||!t||_||h)&&d(t?g():e),e):g()})}var v=!1,y=(n&1?Tt:Ot)(()=>(v=!1,g()));a&&W(y);var b=fr;return(function(e,t){if(arguments.length>0){let n=t?W(y):i&&a?fn(e):e;return B(y,n),v=!0,s!==void 0&&(s=n),e}return sr&&v||b.f&16384?y.v:W(y)})}function Pa(e){F===null&&be(`onMount`),Xe&&F.l!==null?Ia(F).m.push(e):zn(()=>{let t=Pr(e);if(typeof t==`function`)return t})}function Fa(e){F===null&&be(`onDestroy`),Pa(()=>()=>Pr(e))}function Ia(e){var t=e.l;return t.u??={a:[],b:[],m:[]}}typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`);var La={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`},Ra=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},za=Symbol(`lucide-context`),Ba=()=>Qe(za),Va=new Set([`$$slots`,`$$events`,`$$legacy`,`name`,`color`,`size`,`strokeWidth`,`absoluteStrokeWidth`,`iconNode`,`children`]),Ha=oi(`<svg><!><!></svg>`);function Ua(e,t){$e(t,!0);let n=Ba()??{},r=Na(t,`color`,19,()=>n.color??`currentColor`),i=Na(t,`size`,19,()=>n.size??24),a=Na(t,`strokeWidth`,19,()=>n.strokeWidth??2),o=Na(t,`absoluteStrokeWidth`,19,()=>n.absoluteStrokeWidth??!1),s=Na(t,`iconNode`,19,()=>[]),c=Aa(t,Va),l=R(()=>o()?Number(a())*24/Number(i()):a());var u=Ha();ba(u,e=>({...La,...e,...c,width:i(),height:i(),stroke:r(),"stroke-width":W(l),class:[`lucide-icon lucide`,n.class,t.name&&`lucide-${t.name}`,t.class]}),[()=>!t.children&&!Ra(c)&&{"aria-hidden":`true`}]);var d=V(u);Ei(d,17,s,Si,(e,t)=>{var n=R(()=>T(W(t),2));let r=()=>W(n)[0],i=()=>W(n)[1];var a=ci();Wi(Cn(a),r,!0,(e,t)=>{ba(e,()=>({...i()}))}),q(e,a)}),Mi(H(d),()=>t.children??x),N(u),q(e,u),et()}var Wa=new Set([`$$slots`,`$$events`,`$$legacy`]);function Ga(e,t){let n=Aa(t,Wa),r=[[`path`,{d:`M12 6v16`}],[`path`,{d:`m19 13 2-1a9 9 0 0 1-18 0l2 1`}],[`path`,{d:`M9 11h6`}],[`circle`,{cx:`12`,cy:`4`,r:`2`}]];Ua(e,Ma({name:`anchor`},()=>n,{get iconNode(){return r}}))}var Q=new Set([`$$slots`,`$$events`,`$$legacy`]);function Ka(e,t){let n=Aa(t,Q),r=[[`path`,{d:`M8 3 4 7l4 4`}],[`path`,{d:`M4 7h16`}],[`path`,{d:`m16 21 4-4-4-4`}],[`path`,{d:`M20 17H4`}]];Ua(e,Ma({name:`arrow-left-right`},()=>n,{get iconNode(){return r}}))}var qa=new Set([`$$slots`,`$$events`,`$$legacy`]);function Ja(e,t){let n=Aa(t,qa),r=[[`path`,{d:`m12 19-7-7 7-7`}],[`path`,{d:`M19 12H5`}]];Ua(e,Ma({name:`arrow-left`},()=>n,{get iconNode(){return r}}))}var Ya=new Set([`$$slots`,`$$events`,`$$legacy`]);function Xa(e,t){let n=Aa(t,Ya),r=[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`}],[`path`,{d:`m2 2 20 20`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`}]];Ua(e,Ma({name:`bell-off`},()=>n,{get iconNode(){return r}}))}var Za=new Set([`$$slots`,`$$events`,`$$legacy`]);function Qa(e,t){let n=Aa(t,Za),r=[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`}]];Ua(e,Ma({name:`bell`},()=>n,{get iconNode(){return r}}))}var $a=new Set([`$$slots`,`$$events`,`$$legacy`]);function eo(e,t){let n=Aa(t,$a),r=[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`}],[`path`,{d:`m19 9-5 5-4-4-3 3`}]];Ua(e,Ma({name:`chart-line`},()=>n,{get iconNode(){return r}}))}var to=new Set([`$$slots`,`$$events`,`$$legacy`]);function no(e,t){let n=Aa(t,to),r=[[`path`,{d:`M20 6 9 17l-5-5`}]];Ua(e,Ma({name:`check`},()=>n,{get iconNode(){return r}}))}var ro=new Set([`$$slots`,`$$events`,`$$legacy`]);function io(e,t){let n=Aa(t,ro),r=[[`path`,{d:`m6 9 6 6 6-6`}]];Ua(e,Ma({name:`chevron-down`},()=>n,{get iconNode(){return r}}))}var ao=new Set([`$$slots`,`$$events`,`$$legacy`]);function oo(e,t){let n=Aa(t,ao),r=[[`path`,{d:`m15 18-6-6 6-6`}]];Ua(e,Ma({name:`chevron-left`},()=>n,{get iconNode(){return r}}))}var so=new Set([`$$slots`,`$$events`,`$$legacy`]);function co(e,t){let n=Aa(t,so),r=[[`path`,{d:`m9 18 6-6-6-6`}]];Ua(e,Ma({name:`chevron-right`},()=>n,{get iconNode(){return r}}))}var lo=new Set([`$$slots`,`$$events`,`$$legacy`]);function uo(e,t){let n=Aa(t,lo),r=[[`path`,{d:`m18 15-6-6-6 6`}]];Ua(e,Ma({name:`chevron-up`},()=>n,{get iconNode(){return r}}))}var fo=new Set([`$$slots`,`$$events`,`$$legacy`]);function po(e,t){let n=Aa(t,fo),r=[[`path`,{d:`M12 2v2`}],[`path`,{d:`m4.93 4.93 1.41 1.41`}],[`path`,{d:`M20 12h2`}],[`path`,{d:`m19.07 4.93-1.41 1.41`}],[`path`,{d:`M15.947 12.65a4 4 0 0 0-5.925-4.128`}],[`path`,{d:`M13 22H7a5 5 0 1 1 4.9-6H13a3 3 0 0 1 0 6Z`}]];Ua(e,Ma({name:`cloud-sun`},()=>n,{get iconNode(){return r}}))}var mo=new Set([`$$slots`,`$$events`,`$$legacy`]);function ho(e,t){let n=Aa(t,mo),r=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`line`,{x1:`22`,x2:`18`,y1:`12`,y2:`12`}],[`line`,{x1:`6`,x2:`2`,y1:`12`,y2:`12`}],[`line`,{x1:`12`,x2:`12`,y1:`6`,y2:`2`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`18`}]];Ua(e,Ma({name:`crosshair`},()=>n,{get iconNode(){return r}}))}var go=new Set([`$$slots`,`$$events`,`$$legacy`]);function _o(e,t){let n=Aa(t,go),r=[[`path`,{d:`M12 15V3`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}],[`path`,{d:`m7 10 5 5 5-5`}]];Ua(e,Ma({name:`download`},()=>n,{get iconNode(){return r}}))}var vo=new Set([`$$slots`,`$$events`,`$$legacy`]);function yo(e,t){let n=Aa(t,vo),r=[[`path`,{d:`M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21`}],[`path`,{d:`m5.082 11.09 8.828 8.828`}]];Ua(e,Ma({name:`eraser`},()=>n,{get iconNode(){return r}}))}var bo=new Set([`$$slots`,`$$events`,`$$legacy`]);function xo(e,t){let n=Aa(t,bo),r=[[`path`,{d:`M15 3h6v6`}],[`path`,{d:`M10 14 21 3`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`}]];Ua(e,Ma({name:`external-link`},()=>n,{get iconNode(){return r}}))}var So=new Set([`$$slots`,`$$events`,`$$legacy`]);function Co(e,t){let n=Aa(t,So),r=[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`}],[`path`,{d:`m2 2 20 20`}]];Ua(e,Ma({name:`eye-off`},()=>n,{get iconNode(){return r}}))}var wo=new Set([`$$slots`,`$$events`,`$$legacy`]);function To(e,t){let n=Aa(t,wo),r=[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`}]];Ua(e,Ma({name:`eye`},()=>n,{get iconNode(){return r}}))}var Eo=new Set([`$$slots`,`$$events`,`$$legacy`]);function Do(e,t){let n=Aa(t,Eo),r=[[`circle`,{cx:`9`,cy:`12`,r:`1`}],[`circle`,{cx:`9`,cy:`5`,r:`1`}],[`circle`,{cx:`9`,cy:`19`,r:`1`}],[`circle`,{cx:`15`,cy:`12`,r:`1`}],[`circle`,{cx:`15`,cy:`5`,r:`1`}],[`circle`,{cx:`15`,cy:`19`,r:`1`}]];Ua(e,Ma({name:`grip-vertical`},()=>n,{get iconNode(){return r}}))}var Oo=new Set([`$$slots`,`$$events`,`$$legacy`]);function ko(e,t){let n=Aa(t,Oo),r=[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`}]];Ua(e,Ma({name:`layers`},()=>n,{get iconNode(){return r}}))}var Ao=new Set([`$$slots`,`$$events`,`$$legacy`]);function jo(e,t){let n=Aa(t,Ao),r=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`m4.93 4.93 4.24 4.24`}],[`path`,{d:`m14.83 9.17 4.24-4.24`}],[`path`,{d:`m14.83 14.83 4.24 4.24`}],[`path`,{d:`m9.17 14.83-4.24 4.24`}],[`circle`,{cx:`12`,cy:`12`,r:`4`}]];Ua(e,Ma({name:`life-buoy`},()=>n,{get iconNode(){return r}}))}var Mo=new Set([`$$slots`,`$$events`,`$$legacy`]);function No(e,t){let n=Aa(t,Mo),r=[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`}]];Ua(e,Ma({name:`link-2`},()=>n,{get iconNode(){return r}}))}var Po=new Set([`$$slots`,`$$events`,`$$legacy`]);function Fo(e,t){let n=Aa(t,Po),r=[[`line`,{x1:`2`,x2:`5`,y1:`12`,y2:`12`}],[`line`,{x1:`19`,x2:`22`,y1:`12`,y2:`12`}],[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`5`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`}],[`circle`,{cx:`12`,cy:`12`,r:`7`}],[`circle`,{cx:`12`,cy:`12`,r:`3`}]];Ua(e,Ma({name:`locate-fixed`},()=>n,{get iconNode(){return r}}))}var Io=new Set([`$$slots`,`$$events`,`$$legacy`]);function Lo(e,t){let n=Aa(t,Io),r=[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`}],[`circle`,{cx:`12`,cy:`10`,r:`3`}]];Ua(e,Ma({name:`map-pin`},()=>n,{get iconNode(){return r}}))}var Ro=new Set([`$$slots`,`$$events`,`$$legacy`]);function zo(e,t){let n=Aa(t,Ro),r=[[`path`,{d:`M4 5h16`}],[`path`,{d:`M4 12h16`}],[`path`,{d:`M4 19h16`}]];Ua(e,Ma({name:`menu`},()=>n,{get iconNode(){return r}}))}var Bo=new Set([`$$slots`,`$$events`,`$$legacy`]);function Vo(e,t){let n=Aa(t,Bo),r=[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`}]];Ua(e,Ma({name:`moon`},()=>n,{get iconNode(){return r}}))}var Ho=new Set([`$$slots`,`$$events`,`$$legacy`]);function Uo(e,t){let n=Aa(t,Ho),r=[[`polygon`,{points:`3 11 22 2 13 21 11 13 3 11`}]];Ua(e,Ma({name:`navigation`},()=>n,{get iconNode(){return r}}))}var Wo=new Set([`$$slots`,`$$events`,`$$legacy`]);function Go(e,t){let n=Aa(t,Wo),r=[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`}]];Ua(e,Ma({name:`pause`},()=>n,{get iconNode(){return r}}))}var Ko=new Set([`$$slots`,`$$events`,`$$legacy`]);function qo(e,t){let n=Aa(t,Ko),r=[[`path`,{d:`M12 17v5`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`}]];Ua(e,Ma({name:`pin`},()=>n,{get iconNode(){return r}}))}var Jo=new Set([`$$slots`,`$$events`,`$$legacy`]);function Yo(e,t){let n=Aa(t,Jo),r=[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`}]];Ua(e,Ma({name:`play`},()=>n,{get iconNode(){return r}}))}var Xo=new Set([`$$slots`,`$$events`,`$$legacy`]);function Zo(e,t){let n=Aa(t,Xo),r=[[`path`,{d:`M5 12h14`}],[`path`,{d:`M12 5v14`}]];Ua(e,Ma({name:`plus`},()=>n,{get iconNode(){return r}}))}var Qo=new Set([`$$slots`,`$$events`,`$$legacy`]);function $o(e,t){let n=Aa(t,Qo),r=[[`path`,{d:`M19.07 4.93A10 10 0 0 0 6.99 3.34`}],[`path`,{d:`M4 6h.01`}],[`path`,{d:`M2.29 9.62A10 10 0 1 0 21.31 8.35`}],[`path`,{d:`M16.24 7.76A6 6 0 1 0 8.23 16.67`}],[`path`,{d:`M12 18h.01`}],[`path`,{d:`M17.99 11.66A6 6 0 0 1 15.77 16.67`}],[`circle`,{cx:`12`,cy:`12`,r:`2`}],[`path`,{d:`m13.41 10.59 5.66-5.66`}]];Ua(e,Ma({name:`radar`},()=>n,{get iconNode(){return r}}))}var es=new Set([`$$slots`,`$$events`,`$$legacy`]);function ts(e,t){let n=Aa(t,es),r=[[`circle`,{cx:`6`,cy:`19`,r:`3`}],[`path`,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`}],[`circle`,{cx:`18`,cy:`5`,r:`3`}]];Ua(e,Ma({name:`route`},()=>n,{get iconNode(){return r}}))}var ns=new Set([`$$slots`,`$$events`,`$$legacy`]);function rs(e,t){let n=Aa(t,ns),r=[[`path`,{d:`M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z`}],[`path`,{d:`m14.5 12.5 2-2`}],[`path`,{d:`m11.5 9.5 2-2`}],[`path`,{d:`m8.5 6.5 2-2`}],[`path`,{d:`m17.5 15.5 2-2`}]];Ua(e,Ma({name:`ruler`},()=>n,{get iconNode(){return r}}))}var is=new Set([`$$slots`,`$$events`,`$$legacy`]);function as(e,t){let n=Aa(t,is),r=[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`}]];Ua(e,Ma({name:`save`},()=>n,{get iconNode(){return r}}))}var os=new Set([`$$slots`,`$$events`,`$$legacy`]);function ss(e,t){let n=Aa(t,os),r=[[`path`,{d:`M14 17H5`}],[`path`,{d:`M19 7h-9`}],[`circle`,{cx:`17`,cy:`17`,r:`3`}],[`circle`,{cx:`7`,cy:`7`,r:`3`}]];Ua(e,Ma({name:`settings-2`},()=>n,{get iconNode(){return r}}))}var cs=new Set([`$$slots`,`$$events`,`$$legacy`]);function ls(e,t){let n=Aa(t,cs),r=[[`path`,{d:`M17.971 4.285A2 2 0 0 1 21 6v12a2 2 0 0 1-3.029 1.715l-9.997-5.998a2 2 0 0 1-.003-3.432z`}],[`path`,{d:`M3 20V4`}]];Ua(e,Ma({name:`skip-back`},()=>n,{get iconNode(){return r}}))}var us=new Set([`$$slots`,`$$events`,`$$legacy`]);function ds(e,t){let n=Aa(t,us),r=[[`path`,{d:`M21 4v16`}],[`path`,{d:`M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z`}]];Ua(e,Ma({name:`skip-forward`},()=>n,{get iconNode(){return r}}))}var fs=new Set([`$$slots`,`$$events`,`$$legacy`]);function ps(e,t){let n=Aa(t,fs),r=[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`}],[`path`,{d:`M20 2v4`}],[`path`,{d:`M22 4h-4`}],[`circle`,{cx:`4`,cy:`20`,r:`2`}]];Ua(e,Ma({name:`sparkles`},()=>n,{get iconNode(){return r}}))}var ms=new Set([`$$slots`,`$$events`,`$$legacy`]);function hs(e,t){let n=Aa(t,ms),r=[[`circle`,{cx:`19`,cy:`5`,r:`2`}],[`circle`,{cx:`5`,cy:`19`,r:`2`}],[`path`,{d:`M5 17A12 12 0 0 1 17 5`}]];Ua(e,Ma({name:`spline`},()=>n,{get iconNode(){return r}}))}var gs=new Set([`$$slots`,`$$events`,`$$legacy`]);function _s(e,t){let n=Aa(t,gs),r=[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`}]];Ua(e,Ma({name:`square-pen`},()=>n,{get iconNode(){return r}}))}var vs=new Set([`$$slots`,`$$events`,`$$legacy`]);function ys(e,t){let n=Aa(t,vs),r=[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`}]];Ua(e,Ma({name:`square`},()=>n,{get iconNode(){return r}}))}var bs=new Set([`$$slots`,`$$events`,`$$legacy`]);function xs(e,t){let n=Aa(t,bs),r=[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`}]];Ua(e,Ma({name:`star`},()=>n,{get iconNode(){return r}}))}var Ss=new Set([`$$slots`,`$$events`,`$$legacy`]);function Cs(e,t){let n=Aa(t,Ss),r=[[`circle`,{cx:`12`,cy:`12`,r:`4`}],[`path`,{d:`M12 2v2`}],[`path`,{d:`M12 20v2`}],[`path`,{d:`m4.93 4.93 1.41 1.41`}],[`path`,{d:`m17.66 17.66 1.41 1.41`}],[`path`,{d:`M2 12h2`}],[`path`,{d:`M20 12h2`}],[`path`,{d:`m6.34 17.66-1.41 1.41`}],[`path`,{d:`m19.07 4.93-1.41 1.41`}]];Ua(e,Ma({name:`sun`},()=>n,{get iconNode(){return r}}))}var ws=new Set([`$$slots`,`$$events`,`$$legacy`]);function Ts(e,t){let n=Aa(t,ws),r=[[`path`,{d:`M12 10V2`}],[`path`,{d:`m4.93 10.93 1.41 1.41`}],[`path`,{d:`M2 18h2`}],[`path`,{d:`M20 18h2`}],[`path`,{d:`m19.07 10.93-1.41 1.41`}],[`path`,{d:`M22 22H2`}],[`path`,{d:`m16 6-4 4-4-4`}],[`path`,{d:`M16 18a4 4 0 0 0-8 0`}]];Ua(e,Ma({name:`sunset`},()=>n,{get iconNode(){return r}}))}var Es=new Set([`$$slots`,`$$events`,`$$legacy`]);function Ds(e,t){let n=Aa(t,Es),r=[[`path`,{d:`M10 11v6`}],[`path`,{d:`M14 11v6`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}],[`path`,{d:`M3 6h18`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}]];Ua(e,Ma({name:`trash-2`},()=>n,{get iconNode(){return r}}))}var Os=new Set([`$$slots`,`$$events`,`$$legacy`]);function ks(e,t){let n=Aa(t,Os),r=[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`}],[`path`,{d:`M12 9v4`}],[`path`,{d:`M12 17h.01`}]];Ua(e,Ma({name:`triangle-alert`},()=>n,{get iconNode(){return r}}))}var As=new Set([`$$slots`,`$$events`,`$$legacy`]);function js(e,t){let n=Aa(t,As),r=[[`path`,{d:`M9 14 4 9l5-5`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`}]];Ua(e,Ma({name:`undo-2`},()=>n,{get iconNode(){return r}}))}var Ms=new Set([`$$slots`,`$$events`,`$$legacy`]);function Ns(e,t){let n=Aa(t,Ms),r=[[`path`,{d:`M12 3v12`}],[`path`,{d:`m17 8-5-5-5 5`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}]];Ua(e,Ma({name:`upload`},()=>n,{get iconNode(){return r}}))}var Ps=new Set([`$$slots`,`$$events`,`$$legacy`]);function Fs(e,t){let n=Aa(t,Ps),r=[[`path`,{d:`M10 15H6a4 4 0 0 0-4 4v2`}],[`path`,{d:`m14.305 16.53.923-.382`}],[`path`,{d:`m15.228 13.852-.923-.383`}],[`path`,{d:`m16.852 12.228-.383-.923`}],[`path`,{d:`m16.852 17.772-.383.924`}],[`path`,{d:`m19.148 12.228.383-.923`}],[`path`,{d:`m19.53 18.696-.382-.924`}],[`path`,{d:`m20.772 13.852.924-.383`}],[`path`,{d:`m20.772 16.148.924.383`}],[`circle`,{cx:`18`,cy:`15`,r:`3`}],[`circle`,{cx:`9`,cy:`7`,r:`4`}]];Ua(e,Ma({name:`user-cog`},()=>n,{get iconNode(){return r}}))}var Is=new Set([`$$slots`,`$$events`,`$$legacy`]);function Ls(e,t){let n=Aa(t,Is),r=[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`}],[`line`,{x1:`22`,x2:`16`,y1:`9`,y2:`15`}],[`line`,{x1:`16`,x2:`22`,y1:`9`,y2:`15`}]];Ua(e,Ma({name:`volume-x`},()=>n,{get iconNode(){return r}}))}var Rs=new Set([`$$slots`,`$$events`,`$$legacy`]);function zs(e,t){let n=Aa(t,Rs),r=[[`path`,{d:`M2 12q2.5 2 5 0t5 0 5 0 5 0`}],[`path`,{d:`M2 19q2.5 2 5 0t5 0 5 0 5 0`}],[`path`,{d:`M2 5q2.5 2 5 0t5 0 5 0 5 0`}]];Ua(e,Ma({name:`waves-horizontal`},()=>n,{get iconNode(){return r}}))}var Bs=new Set([`$$slots`,`$$events`,`$$legacy`]);function Vs(e,t){let n=Aa(t,Bs),r=[[`path`,{d:`M18 6 6 18`}],[`path`,{d:`m6 6 12 12`}]];Ua(e,Ma({name:`x`},()=>n,{get iconNode(){return r}}))}var Hs=5e-4;function Us(e,t){return t<e?t+360:t}function Ws(e){let[t,n,r,i]=e;if(![t,n,r,i].every(Number.isFinite)||n>i)return null;let a=Us(t,r),o=a===t?t-Hs:t,s=a===t?a+Hs:a,c=i===n?n-Hs:n,l=i===n?i+Hs:i;return[[o,c],[s,l]]}function Gs([e,t,n,r]){return[Math.max(-180,e),Math.max(-85,t),Math.min(180,n),Math.min(85,r)]}function Ks([e,t,n,r],i){let a=(Us(e,n)-e)*i,o=(r-t)*i;return Gs([e-a,t-o,n+a,r+o])}function qs(e,t){return e[0]<=t[0]&&e[1]<=t[1]&&e[2]>=t[2]&&e[3]>=t[3]}function Js(e,t){return t.longitude>=e[0]&&t.longitude<=e[2]&&t.latitude>=e[1]&&t.latitude<=e[3]}function Ys(e){return[e.getWest(),e.getSouth(),e.getEast(),e.getNorth()]}function Xs(e){if(e.length===0)return;let t=1/0,n=1/0,r=-1/0,i=-1/0,a=1/0,o=-1/0;for(let{latitude:s,longitude:c}of e){c<t&&(t=c),c>r&&(r=c),s<n&&(n=s),s>i&&(i=s);let e=c<0?c+360:c;e<a&&(a=e),e>o&&(o=e)}if(o-a<r-t){let e=e=>e>180?e-360:e;return[e(a),n,e(o),i]}return[t,n,r,i]}function Zs(e){return typeof e==`object`&&!!e&&Number.isFinite(e.latitude)&&Number.isFinite(e.longitude)}function Qs(e){return typeof e==`number`&&Number.isFinite(e)&&e>=-90&&e<=90}function $s(e){return typeof e==`number`&&Number.isFinite(e)&&e>=-180&&e<=180}function ec(e){return Array.isArray(e)&&Number.isFinite(e[0])&&Number.isFinite(e[1])}function tc([e,t]){return{latitude:t,longitude:e}}function nc(e){return[e.longitude,e.latitude]}function rc(e,t){return{latitude:Number(e.latitude.toFixed(t)),longitude:Number(e.longitude.toFixed(t))}}function ic(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}var ac=.1;function oc(e){return(Math.round(e/ac)*ac).toFixed(1)}var sc=class{#e=z(fn(Date.now()));get now(){return W(this.#e)}set now(e){B(this.#e,e,!0)}#t;constructor(e=1e3){typeof setInterval==`function`&&(this.#t=setInterval(()=>{this.now=Date.now()},e))}dispose(){this.#t!==void 0&&clearInterval(this.#t),this.#t=void 0}},cc=4;function lc(e,t,n){if(e==null)return`--`;let r=e<0?t:n;return`${Math.abs(e).toFixed(cc)}° ${r}`}function uc(e){return lc(e,`S`,`N`)}function dc(e){return lc(e,`W`,`E`)}function fc(e,t){if(typeof document>`u`||typeof URL?.createObjectURL!=`function`)return;let n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=e,r.click(),setTimeout(()=>URL.revokeObjectURL(n),0)}function pc(e,t,n){fc(e,new Blob([t],{type:n}))}var mc=8e3;function hc(e,t=mc){return e?.signal?e:typeof AbortSignal>`u`||typeof AbortSignal.timeout!=`function`?e??{}:{...e,signal:AbortSignal.timeout(t)}}var gc=(e,t)=>globalThis.fetch(e,hc(t));async function _c(e,t,n=gc){try{let r=await n(e,t);return r.ok?await r.json():void 0}catch{return}}function vc(){if(typeof crypto<`u`&&typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=new Uint8Array(16);if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(e);else for(let t=0;t<16;t+=1)e[t]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`));return`${t[0]}${t[1]}${t[2]}${t[3]}-${t[4]}${t[5]}-${t[6]}${t[7]}-${t[8]}${t[9]}-${t[10]}${t[11]}${t[12]}${t[13]}${t[14]}${t[15]}`}function yc(e,t,n){return e+(t-e)*n}function bc(e){return typeof e==`number`&&Number.isFinite(e)}function xc(e,t,n){let r,i=1/0;for(let a of e){let e=t(a);if(Number.isNaN(e))continue;let o=Math.abs(e-n);o<i&&(i=o,r=a)}return r}function Sc(){return typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches===!0}function Cc(e){return e.length>0?e.charAt(0).toUpperCase()+e.slice(1):e}var wc=1.943844492,Tc=1852,Ec=180/Math.PI,Dc=273.15,Oc=Math.PI/180,kc=6e4,Ac=60*kc,jc=24*Ac;function Mc(e){return e==null?void 0:e*wc}function Nc(e){return e/wc}function Pc(e){if(e!=null)return(e*Ec+360)%360}function Fc(e,t){return Pc(e)??Pc(t)??0}function Ic(e){return e==null?void 0:e/100}function Lc(e){return e==null?void 0:e-Dc}function Rc(e,t){return e==null||Number.isNaN(e)?`--`:e.toFixed(t)}function zc(e,t=1){return Rc(Mc(e),t)}function Bc(e,t=0){return Rc(Pc(e),t)}function Vc(e,t=0){return Rc(Ic(e),t)}function Hc(e){return e==null?void 0:e/Tc}function Uc(e){return e*Tc}function Wc(e,t=2){return(Hc(e)??0).toFixed(t)}function Gc(e,t=1){return(Mc(e)??0).toFixed(t)}function Kc(e,t=2){return Rc(Hc(e),t)}var qc=.3048,Jc=25.4,Yc=3386.389,Xc=1609.344,Zc=3.785411784;function Qc(e){return e==null?void 0:e/qc}function $c(e){return e*qc}var el=$c(1e3);function tl(e){return e===`imperial`?`ft`:`m`}function nl(e,t,n=1){return Rc(t===`imperial`?Qc(e):e,n)}function rl(e){return e===`imperial`?`gal`:`L`}function il(e,t){return t===`imperial`?e/Zc:e}function al(e){return e===`imperial`?`°F`:`°C`}function ol(e){let t=Lc(e);return t==null?void 0:9/5*t+32}function sl(e,t,n=0){return Rc(t===`imperial`?ol(e):Lc(e),n)}function cl(e){return e===`imperial`?`inHg`:`hPa`}function ll(e,t){if(e!=null)return t===`imperial`?e/Yc:e/100}function ul(e,t){return t===`imperial`?Rc(e==null?void 0:e/Yc,2):Vc(e)}function dl(e){return e===`imperial`?`in/h`:`mm/h`}function fl(e,t){return t===`imperial`?Rc(e==null?void 0:e/Jc,2):Rc(e,1)}function pl(e){return e===`imperial`?`mi`:`km`}function ml(e,t=`metric`){return e==null?`--`:t===`imperial`?e<el?`${Math.round(Qc(e)??0)} ft`:`${Wc(e)} nm`:e<Tc?`${Math.round(e)} m`:`${Wc(e)} nm`}function hl(e,t=2){return Wc(e,t)}function gl(e,t=0){return(e/60).toFixed(t)}var _l={hour:`2-digit`,minute:`2-digit`},vl={hour:`2-digit`,minute:`2-digit`,second:`2-digit`},yl={weekday:`short`,hour:`2-digit`,minute:`2-digit`},bl={weekday:`short`,hour:`2-digit`},xl={weekday:`short`,hour:`2-digit`,minute:`2-digit`,timeZoneName:`short`},Sl={weekday:`short`,hour:`2-digit`,timeZoneName:`short`};function Cl(e,t){return new Date(e).toLocaleTimeString([],t?.seconds?vl:_l)}function wl(e,t){if(Number.isNaN(e))return``;let n=t?.minute===!1,r=t?.zone,i;return i=r?n?Sl:xl:n?bl:yl,new Date(e).toLocaleString([],i)}function Tl(e){let t=Math.round(e/60);return t<60?{value:`${t}`,unit:`min`}:{value:`${Math.floor(t/60)}h ${(t%60).toString().padStart(2,`0`)}m`,unit:``}}function El(e){let{value:t,unit:n}=Tl(e);return n?`${t} ${n}`:t}function Dl(e){return e||(typeof localStorage<`u`?localStorage:void 0)}var Ol=class{#e=z(void 0);get value(){return W(this.#e)}set value(e){B(this.#e,e,!0)}fromStorage;#t;#n;constructor(e,t,n){this.#t=e,this.#n=Dl(n);let r=this.#r(t);this.fromStorage=r.fromStorage,this.value=r.value}set(e){this.value=e;try{this.#n?.setItem(this.#t,JSON.stringify(e))}catch(e){console.warn(`Could not persist "${this.#t}".`,e)}}#r(e){let t=this.#n?.getItem(this.#t);if(t==null)return{value:e,fromStorage:!1};try{return{value:JSON.parse(t),fromStorage:!0}}catch{return{value:e,fromStorage:!1}}}};function kl(e){if(!e||typeof e!=`object`)return!1;let t=e;return Qs(t.lat)&&$s(t.lon)&&bc(t.zoom)&&t.zoom>=0&&t.zoom<=24}function Al(e=`binnacle:map-view`,t){return new Ol(e,null,t)}var jl={intervalSeconds:10,minMeters:10,colorMode:`speed`};function Ml(e){return new Ol(`binnacle:track-settings`,jl,e)}var Nl={dangerCpaMeters:Math.round(Uc(.5)),dangerTcpaSeconds:600,warningCpaMeters:Math.round(Uc(1)),warningTcpaSeconds:1200};function Pl(e){return new Ol(`binnacle:lookout-thresholds`,Nl,e)}var Fl=`binnacle:signalk-auth`,Il=`/signalk/v1/api/vessels/self`,Ll=`/signalk/v1/access/requests`,Rl=200;function zl(){return`binnacle-${typeof crypto<`u`&&`randomUUID`in crypto?crypto.randomUUID().slice(0,8):Math.floor(Math.random()*4294967295).toString(16).padStart(8,`0`)}`}var Bl=class{#e=z(`unknown`);get status(){return W(this.#e)}set status(e){B(this.#e,e,!0)}#t=z(null);get token(){return W(this.#t)}set token(e){B(this.#t,e,!0)}#n;#r;#i;#a;#o;#s;#c=!1;#l=0;#u=!1;#d=!1;#f=!1;constructor(e,t={}){this.#n=e,this.#r=t.fetch??globalThis.fetch.bind(globalThis),this.#i=t.schedule??((e,t)=>void setTimeout(e,t)),this.#a=t.pollMs??3e3,this.#o=new Ol(Fl,{clientId:zl(),token:null},t.storage);let n=this.#o.value,r=n.clientId.startsWith(`binnacle-`)?n.clientId:zl();(!this.#o.fromStorage||r!==n.clientId)&&this.#o.set({clientId:r,token:n.token}),this.token=this.#o.value.token}get clientId(){return this.#o.value.clientId}async probe(){let e=this.#o.value.token;if(e){let t=await this.#_(`${this.#n}${Il}`,{headers:{Authorization:`Bearer ${e}`},credentials:`omit`});if(t?.ok){this.token=e,this.status=`authenticated`;return}if(!t||t.status!==401&&t.status!==403)return;this.#g(null)}if((await this.#_(`${this.#n}${Il}`,{credentials:`omit`}))?.ok){this.status=`unsecured`;return}await this.requestAccess()}async requestAccess(){this.status=`requesting`;let e=await this.#_(`${this.#n}${Ll}`,{method:`POST`,credentials:`omit`,headers:{"Content-Type":`application/json`},body:JSON.stringify({clientId:this.clientId,description:`Binnacle chart plotter`})});if(!e){this.#h(()=>this.requestAccess());return}this.#l=0;let t=await this.#v(e);if(this.#s=typeof t.href==`string`?t.href:void 0,!this.#s){this.status=`denied`;return}this.#h()}async checkRequest(){if(!(this.#d||!this.#s||this.status===`authenticated`)){this.#d=!0;try{let e=await this.#_(`${this.#n}${this.#s}`,{credentials:`omit`});if(e&&(e.status===404||e.status===410)){await this.requestAccess();return}if(!e?.ok){this.#h();return}let t=await this.#v(e);if(t.state!==`COMPLETED`){this.#h();return}let n=t.accessRequest??{};n.permission===`APPROVED`&&typeof n.token==`string`?(this.#g(n.token),this.token=n.token,this.status=`authenticated`):this.status=`denied`}finally{this.#d=!1}}}watch(){this.#f||typeof window>`u`||(this.#f=!0,window.addEventListener(`focus`,this.#p),window.addEventListener(`storage`,this.#m),typeof document<`u`&&document.addEventListener(`visibilitychange`,this.#p))}recheck(){this.status===`requesting`&&this.checkRequest()}adoptToken(e){!e||this.status===`authenticated`||(this.#g(e),this.token=e,this.status=`authenticated`)}stop(){this.#c=!0,typeof window<`u`&&(window.removeEventListener(`focus`,this.#p),window.removeEventListener(`storage`,this.#m)),typeof document<`u`&&document.removeEventListener(`visibilitychange`,this.#p)}#p=()=>{typeof document<`u`&&document.visibilityState===`hidden`||this.recheck()};#m=e=>{if(!(e.key!==Fl||!e.newValue))try{let t=JSON.parse(e.newValue).token;t&&this.adoptToken(t)}catch{}};#h(e){if(!(this.#c||this.#u||this.status===`authenticated`)){if(this.#l>=Rl){this.status=`denied`;return}this.#l+=1,this.#u=!0,this.#i(()=>{this.#u=!1,e?e():this.checkRequest()},this.#a)}}#g(e){this.#o.set({...this.#o.value,token:e})}async#_(e,t){try{return await this.#r(e,t)}catch{return}}async#v(e){try{return await e.json()}catch{return{}}}},Vl=Symbol(`Comlink.proxy`),Hl=Symbol(`Comlink.endpoint`),Ul=Symbol(`Comlink.releaseProxy`),Wl=Symbol(`Comlink.finalizer`),Gl=Symbol(`Comlink.thrown`),Kl=e=>typeof e==`object`&&!!e||typeof e==`function`,ql=new Map([[`proxy`,{canHandle:e=>Kl(e)&&e[Vl],serialize(e){let{port1:t,port2:n}=new MessageChannel;return Yl(e,t),[n,[n]]},deserialize(e){return e.start(),Ql(e)}}],[`throw`,{canHandle:e=>Kl(e)&&Gl in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){throw e.isError?Object.assign(Error(e.value.message),e.value):e.value}}]]);function Jl(e,t){for(let n of e)if(t===n||n===`*`||n instanceof RegExp&&n.test(t))return!0;return!1}function Yl(e,t=globalThis,n=[`*`]){t.addEventListener(`message`,function r(i){if(!i||!i.data)return;if(!Jl(n,i.origin)){console.warn(`Invalid origin '${i.origin}' for comlink proxy`);return}let{id:a,type:o,path:s}=Object.assign({path:[]},i.data),c=(i.data.argumentList||[]).map(fu),l;try{let t=s.slice(0,-1).reduce((e,t)=>e[t],e),n=s.reduce((e,t)=>e[t],e);switch(o){case`GET`:l=n;break;case`SET`:t[s.slice(-1)[0]]=fu(i.data.value),l=!0;break;case`APPLY`:l=n.apply(t,c);break;case`CONSTRUCT`:l=uu(new n(...c));break;case`ENDPOINT`:{let{port1:t,port2:n}=new MessageChannel;Yl(e,n),l=lu(t,[t])}break;case`RELEASE`:l=void 0;break;default:return}}catch(e){l={value:e,[Gl]:0}}Promise.resolve(l).catch(e=>({value:e,[Gl]:0})).then(n=>{let[i,s]=du(n);t.postMessage(Object.assign(Object.assign({},i),{id:a}),s),o===`RELEASE`&&(t.removeEventListener(`message`,r),Zl(t),Wl in e&&typeof e[Wl]==`function`&&e[Wl]())}).catch(e=>{let[n,r]=du({value:TypeError(`Unserializable return value`),[Gl]:0});t.postMessage(Object.assign(Object.assign({},n),{id:a}),r)})}),t.start&&t.start()}function Xl(e){return e.constructor.name===`MessagePort`}function Zl(e){Xl(e)&&e.close()}function Ql(e,t){let n=new Map;return e.addEventListener(`message`,function(e){let{data:t}=e;if(!t||!t.id)return;let r=n.get(t.id);if(r)try{r(t)}finally{n.delete(t.id)}}),au(e,n,[],t)}function $l(e){if(e)throw Error(`Proxy has been released and is not useable`)}function eu(e){return pu(e,new Map,{type:`RELEASE`}).then(()=>{Zl(e)})}var tu=new WeakMap,nu=`FinalizationRegistry`in globalThis&&new FinalizationRegistry(e=>{let t=(tu.get(e)||0)-1;tu.set(e,t),t===0&&eu(e)});function ru(e,t){let n=(tu.get(t)||0)+1;tu.set(t,n),nu&&nu.register(e,t,e)}function iu(e){nu&&nu.unregister(e)}function au(e,t,n=[],r=function(){}){let i=!1,a=new Proxy(r,{get(r,o){if($l(i),o===Ul)return()=>{iu(a),eu(e),t.clear(),i=!0};if(o===`then`){if(n.length===0)return{then:()=>a};let r=pu(e,t,{type:`GET`,path:n.map(e=>e.toString())}).then(fu);return r.then.bind(r)}return au(e,t,[...n,o])},set(r,a,o){$l(i);let[s,c]=du(o);return pu(e,t,{type:`SET`,path:[...n,a].map(e=>e.toString()),value:s},c).then(fu)},apply(r,a,o){$l(i);let s=n[n.length-1];if(s===Hl)return pu(e,t,{type:`ENDPOINT`}).then(fu);if(s===`bind`)return au(e,t,n.slice(0,-1));let[c,l]=su(o);return pu(e,t,{type:`APPLY`,path:n.map(e=>e.toString()),argumentList:c},l).then(fu)},construct(r,a){$l(i);let[o,s]=su(a);return pu(e,t,{type:`CONSTRUCT`,path:n.map(e=>e.toString()),argumentList:o},s).then(fu)}});return ru(a,e),a}function ou(e){return Array.prototype.concat.apply([],e)}function su(e){let t=e.map(du);return[t.map(e=>e[0]),ou(t.map(e=>e[1]))]}var cu=new WeakMap;function lu(e,t){return cu.set(e,t),e}function uu(e){return Object.assign(e,{[Vl]:!0})}function du(e){for(let[t,n]of ql)if(n.canHandle(e)){let[r,i]=n.serialize(e);return[{type:`HANDLER`,name:t,value:r},i]}return[{type:`RAW`,value:e},cu.get(e)||[]]}function fu(e){switch(e.type){case`HANDLER`:return ql.get(e.name).deserialize(e.value);case`RAW`:return e.value}}function pu(e,t,n,r){return new Promise(i=>{let a=mu();t.set(a,i),e.start&&e.start(),e.postMessage(Object.assign({id:a},n),r)})}function mu(){return[,,,,].fill(0).map(()=>Math.floor(Math.random()*(2**53-1)).toString(16)).join(`-`)}function hu(){let e=new Worker(new URL(`/signalk-binnacle/assets/sk.worker-CQq_KzCx.js`,``+import.meta.url),{type:`module`}),t;e.onerror=e=>{let n=Error(`Signal K worker failed to load or threw: ${e.message??`unknown`}`);console.error(n.message,e),t?.(n)},e.onmessageerror=e=>{console.error(`Signal K worker message could not be deserialized`,e)};let n=Ql(e);return{raw:n,async connect(e,r){let i=new Promise((e,n)=>{t=n});try{await Promise.race([n.connect(e,uu(r)),i])}finally{t=void 0}},async publish(e){await n.publish(e)},async reconnect(){await n.reconnect()},async disconnect(){await n.disconnect()}}}function gu(e,t){if(!e&&!t)return;let n=e?{Authorization:`Bearer ${e}`}:void 0;return{...t,headers:{...n,...t?.headers}}}function _u(e){if(!(!e||typeof e!=`object`||Array.isArray(e)))return e}function vu(e){return typeof e==`string`&&e.length>0?e:void 0}function yu(e){if(!Array.isArray(e))return;let t=e.filter(e=>typeof e==`string`&&e.length>0);return t.length>0?t:void 0}async function bu(e,t,n,r,i){for(let a of t){let t=await xu(`${e}${a}`,n,r,i);if(t)return t}}async function xu(e,t,n,r){try{let i=await fetch(e,hc(gu(t)));if(!i.ok){r?.(e,i.status);return}let a=_u(await i.json());if(!a)return;let o=[];for(let[e,t]of Object.entries(a)){let r=n(e,t);r!==void 0&&o.push(r)}return o}catch{return}}async function Su(e,t,n,r){try{return await fetch(e,hc(gu(t,{method:n,...r===void 0?{}:{headers:{"Content-Type":`application/json`},body:JSON.stringify(r)}})))}catch{return}}async function Cu(e,t,n){return(await Su(e,t,`PUT`,n))?.ok??!1}async function wu(e,t){try{return(await fetch(e,hc(gu(t,{method:`DELETE`})))).ok}catch{return!1}}async function Tu(e,t){let n=await _c(`${e}/signalk/v2/features?enabled=1`,gu(t));if(!n||typeof n!=`object`)return;let r=new Set;if(Array.isArray(n.apis))for(let e of n.apis)typeof e==`string`&&r.add(e);let i=new Map;if(Array.isArray(n.plugins)){for(let e of n.plugins)if(e&&typeof e==`object`){let{id:t,version:n}=e;typeof t==`string`&&i.set(t,typeof n==`string`?n:``)}}return{apis:r,plugins:i}}var Eu=`/signalk/v2/api/history`;async function Du(e,t){let n=await _c(`${e}${Eu}/_providers`,gu(t));if(!(!n||typeof n!=`object`||Array.isArray(n)))return{ids:Object.keys(n).sort((e,t)=>(n[e]?.isDefault===!0?0:1)-(n[t]?.isDefault===!0?0:1))}}async function Ou(e,t,n){let r=new URLSearchParams({paths:n.paths.join(`,`),duration:String(n.durationSeconds)});n.resolutionSeconds!==void 0&&r.set(`resolution`,String(n.resolutionSeconds)),n.provider&&r.set(`provider`,n.provider);let i=await _c(`${e}${Eu}/values?${r}`,gu(t));if(!i||!Array.isArray(i.values))return;let a=[];for(let e of i.values){let{path:t,method:n}=e??{};if(typeof t!=`string`)return;a.push({path:t,method:typeof n==`string`?n:``})}let o=(Array.isArray(i.data)?i.data:[]).filter(e=>Array.isArray(e)&&typeof e[0]==`string`&&e.length===a.length+1);return{from:typeof i.range?.from==`string`?i.range.from:``,to:typeof i.range?.to==`string`?i.range.to:``,columns:a,rows:o}}async function ku(e,t,n,r){let i;for(let a of n.ids.length>0?n.ids:[void 0]){let n=await Ou(e,t,{...r,provider:a});if(n){if(n.rows.some(e=>e.slice(1).some(e=>e!=null)))return{values:n,provider:a};i??={values:n,provider:a}}}return i}var Au=`/signalk/v2/api/notifications`;async function ju(e,t,n){return Su(e,t,`POST`,n)}async function Mu(e){if(e?.ok)try{let t=await e.json();return typeof t?.id==`string`?t.id:void 0}catch{return}}async function Nu(e,t,n){return Mu(await ju(`${e}${Au}`,t,n))}async function Pu(e,t,n,r){let i=await Su(`${e}${Au}/${n}`,t,`PUT`,r);return i?i.ok?`updated`:i.status===400?`missing`:`failed`:`failed`}async function Fu(e,t,n){return wu(`${e}${Au}/${n}`,t)}async function Iu(e,t,n){return(await ju(`${e}${Au}/${n}/silence`,t))?.ok??!1}async function Lu(e,t,n){return(await ju(`${e}${Au}/${n}/acknowledge`,t))?.ok??!1}async function Ru(e,t,n){let r=n===void 0?{}:{message:n};return Mu(await ju(`${e}${Au}/mob`,t,r))}function zu(){return`${location.protocol}//${location.host}`}function Bu(e){let t=`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}/signalk/v1/stream`;return e?`${t}?token=${encodeURIComponent(e)}`:t}var Vu=`vessels.self`,Hu=`vessels.*`,Uu=`notifications.`,Wu=new Set([`alarm`,`emergency`]),Gu={phase:`connecting`,attempt:0},$={position:`navigation.position`,headingTrue:`navigation.headingTrue`,courseOverGroundTrue:`navigation.courseOverGroundTrue`,speedOverGround:`navigation.speedOverGround`,closestApproach:`navigation.closestApproach`,depthBelowTransducer:`environment.depth.belowTransducer`,windSpeedApparent:`environment.wind.speedApparent`,outsidePressure:`environment.outside.pressure`,anchorPosition:`navigation.anchor.position`,anchorMaxRadius:`navigation.anchor.maxRadius`,anchorNotification:`notifications.navigation.anchor`,mobNotification:`notifications.mob`,allNotifications:`${Uu}*`,name:`name`,aisShipType:`design.aisShipType`,courseNextPoint:`navigation.course.nextPoint`,coursePreviousPoint:`navigation.course.previousPoint`,courseActiveRoute:`navigation.course.activeRoute`,courseArrivalCircle:`navigation.course.arrivalCircle`,courseCalcValues:`navigation.course.calcValues`};function Ku(e,t){return e?.silenced===t?.silenced&&e?.acknowledged===t?.acknowledged&&e?.canSilence===t?.canSilence&&e?.canAcknowledge===t?.canAcknowledge}var qu=class{#e=z(void 0);get value(){return W(this.#e)}set value(e){B(this.#e,e,!0)}#t=z(0);get epoch(){return W(this.#t)}set epoch(e){B(this.#t,e,!0)}},Ju=class{#e=z(fn(Gu));get connection(){return W(this.#e)}set connection(e){B(this.#e,e,!0)}selfContext;aisTargets=new Map;#t=z(0);get aisVersion(){return W(this.#t)}set aisVersion(e){B(this.#t,e,!0)}notifications=new Map;#n=z(0);get notificationsVersion(){return W(this.#n)}set notificationsVersion(e){B(this.#n,e,!0)}#r=new Map;cell(e){let t=this.#r.get(e);return t||(t=new qu,this.#r.set(e,t)),t}applyFrame(e){!this.selfContext&&e.selfContext&&(this.selfContext=e.selfContext);for(let[t,n]of e.self){let r=this.cell(t);r.value=n,r.epoch=e.epoch,t.startsWith(`notifications.`)&&this.#i(t,n)}if(e.ais){for(let[t,n]of e.ais){let r=this.aisTargets.get(t);r||(r={values:new Map,lastUpdate:e.epoch},this.aisTargets.set(t,r));for(let[e,t]of n)r.values.set(e,t);r.lastUpdate=e.epoch}e.ais.size>0&&(this.aisVersion+=1)}let t=e.connection;(t.phase!==this.connection.phase||t.attempt!==this.connection.attempt)&&(this.connection=t)}#i(e,t){let n=t&&typeof t==`object`?t.state:void 0;if(typeof n!=`string`||n===`normal`||n===`nominal`){this.notifications.delete(e)&&(this.notificationsVersion+=1);return}let r=this.notifications.get(e);if(r!==t){if(r&&typeof r==`object`&&typeof t==`object`&&t){let e=r,n=t;if(e.state===n.state&&e.message===n.message&&e.id===n.id&&Ku(e.status,n.status))return}this.notifications.set(e,t),this.notificationsVersion+=1}}pruneAis(e,t){let n=0;for(let[r,i]of this.aisTargets)e-i.lastUpdate>t&&(this.aisTargets.delete(r),n+=1);return n>0&&(this.aisVersion+=1),n}},Yu=`/signalk/v2/api/resources/symbols`,Xu=/^[A-Za-z0-9_-]+:[^:]+$/;function Zu(e){let t=yu(e)?.filter(e=>Xu.test(e)&&!e.startsWith(`default:`));return t&&t.length>0?t:void 0}function Qu(e){if(!Array.isArray(e)||e.length!==2)return;let[t,n]=e;return typeof t==`number`&&typeof n==`number`?[t,n]:void 0}function $u(e,t){if(!t||typeof t!=`object`)return;let n=t;if(vu(n.mediaType)!==`image/svg+xml`)return;let r=Zu(n.alias),i=vu(n.url);if(!(!r||!i))return{uuid:vu(n.uuid)??e,aliases:r,name:vu(n.name)??e,url:i,roles:yu(n.roles)??[],scale:typeof n.scale==`number`&&n.scale>0?n.scale:void 0,anchor:Qu(n.anchor)}}function ed(e,t){return bu(e,[Yu],t,$u)}var td=7*kc,nd=5e3,rd=/^(-)?P(?:(\d+(?:\.\d+)?)Y)?(?:(\d+(?:\.\d+)?)M)?(?:(\d+(?:\.\d+)?)W)?(?:(\d+(?:\.\d+)?)D)?(?:T(?:(\d+(?:\.\d+)?)H)?(?:(\d+(?:\.\d+)?)M)?(?:(\d+(?:\.\d+)?)S)?)?$/;function id(e){if(bc(e))return e;if(typeof e!=`string`)return;let t=rd.exec(e.trim());if(!t)return;let[,n,r,i,a,o,s,c,l]=t;if(![r,i,a,o,s,c,l].some(e=>e!=null))return;let u=e=>e==null?0:Number.parseFloat(e),d=u(r)*31536e3+u(i)*2592e3+u(a)*604800+u(o)*86400+u(s)*3600+u(c)*60+u(l);return n===`-`?-d:d}var ad=class{#e;#t;#n=-1;constructor(e){this.#e=e}startPruning(){let e=setInterval(()=>this.#e.pruneAis(Date.now(),td),nd);return()=>clearInterval(e)}get version(){return this.#e.aisVersion}list(){let e=this.#e.aisVersion;if(this.#t&&this.#n===e)return this.#t;let t=[];for(let[e,n]of this.#e.aisTargets){let r=n.values.get($.position);if(!Zs(r))continue;let i=n.values.get($.name),a=n.values.get($.closestApproach);t.push({id:e,name:typeof i==`string`?i:void 0,position:r,cogRad:ic(n.values.get($.courseOverGroundTrue)),headingRad:ic(n.values.get($.headingTrue)),sogMps:ic(n.values.get($.speedOverGround)),shipTypeId:this.#r(n.values.get($.aisShipType),`id`),cpaMeters:this.#r(a,`distance`),tcpaSeconds:this.#i(a)})}return this.#t=t,this.#n=e,t}#r(e,t){if(typeof e==`object`&&e)return ic(e[t])}#i(e){if(typeof e==`object`&&e)return id(e.timeTo)}};function od(e){let t=e.lastIndexOf(`:`);return t>=0?e.slice(t+1):e}function sd(e,t){return e||od(t)}var cd=6371e3;function ld(e){return e-360*Math.round(e/360)}function ud(e,t,n,r=64){let i=n/cd,a=e*Oc,o=t*Oc,s=Math.sin(a),c=Math.cos(a),l=Math.sin(i),u=Math.cos(i),d=[];for(let e=0;e<=r;e+=1){let t=e/r*2*Math.PI,n=Math.asin(s*u+c*l*Math.cos(t)),i=o+Math.atan2(Math.sin(t)*l*c,u-s*Math.sin(n));d.push([i/Oc,n/Oc])}return d}function dd(e,t,n,r){let i=r/cd,a=e*Oc,o=t*Oc,s=Math.asin(Math.sin(a)*Math.cos(i)+Math.cos(a)*Math.sin(i)*Math.cos(n));return[(o+Math.atan2(Math.sin(n)*Math.sin(i)*Math.cos(a),Math.cos(i)-Math.sin(a)*Math.sin(s)))/Oc,s/Oc]}function fd(e,t,n,r){let i=(n-e)*Oc,a=(r-t)*Oc,o=Math.sin(i/2)**2+Math.cos(e*Oc)*Math.cos(n*Oc)*Math.sin(a/2)**2;return 2*cd*Math.asin(Math.min(1,Math.sqrt(o)))}function pd(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r+=1)if(fd(e[r].latitude,e[r].longitude,t[r].latitude,t[r].longitude)>n)return!1;return!0}var md=111320;function hd(e,t){return[ld(t.longitude-e.longitude)*md*Math.cos(e.latitude*Oc),(t.latitude-e.latitude)*md]}function gd(e){return[e.sogMps*Math.sin(e.cogRad),e.sogMps*Math.cos(e.cogRad)]}function _d(e,t){let[n,r]=hd(e,t),[i,a]=gd(e),[o,s]=gd(t),c=o-i,l=s-a,u=c*c+l*l,d=Math.hypot(n,r);if(u===0)return{cpaMeters:d,tcpaSeconds:0,closing:!1};let f=-(n*c+r*l)/u;if(f<=0)return{cpaMeters:d,tcpaSeconds:0,closing:!1};let p=n+c*f,m=r+l*f;return{cpaMeters:Math.hypot(p,m),tcpaSeconds:f,closing:!0}}function vd(e,t){return Math.log(Math.tan(Math.PI/4+t/2)/Math.tan(Math.PI/4+e/2))}function yd(e,t){let n=(t.latitude-e.latitude)*Oc,r=ld(t.longitude-e.longitude)*Oc,i=e.latitude*Oc,a=vd(i,t.latitude*Oc),o=Math.abs(a)>1e-12?n/a:Math.cos(i);return Math.hypot(n,o*r)*cd}function bd(e,t){let n=ld(t.longitude-e.longitude)*Oc,r=vd(e.latitude*Oc,t.latitude*Oc);return(Math.atan2(n,r)+2*Math.PI)%(2*Math.PI)}function xd(e,t,n){let r=yd(e,n),i=bd(e,n),a=bd(e,t);return r*Math.sin(i-a)}function Sd(e,t,n,r){let i=bd(e,t);return n*Math.cos(r-i)}function Cd(e,t){if(!(t<=0))return e/t}function wd(e){return!Number.isFinite(e)||e===0?null:e>0?`port`:`starboard`}function Td(e){return Math.max(10,Math.ceil(e+15))}var Ed=3,Dd=class{#e=0;update(e){return e?(this.#e+=1,this.#e>=Ed):(this.#e=0,!1)}reset(){this.#e=0}};function Od(e){return!e||typeof e!=`object`||!Zs(e.position)||!bc(e.radiusMeters)||e.radiusMeters<10?null:{position:{latitude:e.position.latitude,longitude:e.position.longitude},radiusMeters:e.radiusMeters,dragging:e.dragging===!0}}var kd=class{#e;#t;#n=new Dd;#r;#i;#a=z(null);#o=z(void 0);#s=0;constructor(e,t,n){this.#e=e,this.#t=t,this.#r=new Ol(`binnacle:anchor-watch`,null,n),this.#i=new Ol(`binnacle:anchor-radius`,50,n),B(this.#a,Od(this.#r.value),!0);for(let t of[$.anchorPosition,$.anchorMaxRadius,$.anchorNotification])e.cell(t)}#c=R(()=>{let e=this.#e.cell($.anchorPosition).value;return Zs(e)?e:void 0});#l=R(()=>ic(this.#e.cell($.anchorMaxRadius).value));#u=R(()=>{let e=this.#e.cell($.anchorNotification).value;if(!e||typeof e!=`object`)return;let t=e.state;return typeof t==`string`?t:void 0});#d=R(()=>{let e=W(this.#u);return e!==void 0&&Wu.has(e)});get mode(){return W(this.#c)?`server`:W(this.#a)?`client`:`off`}get watching(){return this.mode!==`off`}get fixLost(){return this.watching&&this.#t.positionStale}get degraded(){return this.fixLost&&this.mode!==`server`}get position(){return W(this.#c)??W(this.#a)?.position}get radiusMeters(){return W(this.#c)?W(this.#l):W(this.#a)?.radiusMeters}get preferredRadiusMeters(){return this.#i.value}#f=R(()=>{let e=this.position,t=this.#t.position;if(!(!e||!t))return fd(e.latitude,e.longitude,t.latitude,t.longitude)});get distanceMeters(){return W(this.#f)}get dragging(){return this.mode===`server`?W(this.#d):W(this.#a)?.dragging??!1}get acknowledged(){return this.mode===`server`&&W(this.#d)&&W(this.#o)!==void 0&&W(this.#o)===W(this.#u)}updateFix(){if(W(this.#c)){W(this.#a)&&this.#p(null),W(this.#d)||B(this.#o,void 0);return}B(this.#o,void 0);let e=W(this.#a),t=W(this.#f);if(!e||t===void 0)return;let n=this.#e.cell($.position).epoch;n!==this.#s&&(this.#s=n,this.#n.update(t>e.radiusMeters)&&!e.dragging&&this.#p({...e,dragging:!0}))}dropLocal(e,t=this.preferredRadiusMeters){this.#n.reset(),this.#p({position:e,radiusMeters:Math.max(10,t),dragging:!1})}raiseLocal(){this.#n.reset(),this.#p(null)}setRadiusLocal(e){if(!bc(e))return;let t=W(this.#a);t&&(this.#n.reset(),this.#p({...t,radiusMeters:Math.max(10,e)}))}movePositionLocal(e){let t=W(this.#a);t&&(this.#n.reset(),this.#p({...t,position:e}))}rememberRadius(e){bc(e)&&this.#i.set(Math.max(10,e))}acknowledge(){if(this.mode===`server`){B(this.#o,W(this.#u),!0);return}this.#n.reset();let e=W(this.#a);e?.dragging&&this.#p({...e,dragging:!1})}#p(e){B(this.#a,e,!0),this.#r.set(e)}},Ad={danger:0,warning:1,clear:2},jd=185,Md=120,Nd=Nc(1),Pd=1.1,Fd={contacts:[],worst:`clear`};Object.freeze(Fd),Object.freeze(Fd.contacts);function Id(e,t,n){return e<=n.dangerCpaMeters&&t<=n.dangerTcpaSeconds?`danger`:e<=n.warningCpaMeters&&t<=n.warningTcpaSeconds?`warning`:`clear`}function Ld(e,t,n,r){let i=Id(e,t,n);return r===void 0||Ad[i]<=Ad[r]?i:r===`danger`&&e<=n.dangerCpaMeters*Pd&&t<=n.dangerTcpaSeconds*Pd?`danger`:e<=n.warningCpaMeters*Pd&&t<=n.warningTcpaSeconds*Pd?`warning`:i}function Rd(e,t,n,r,i=!1){let a=e?{latitude:e.position.latitude,longitude:e.position.longitude,sogMps:e.sogMps,cogRad:e.cogRad}:void 0,o=[];for(let e of t){let t,s,c;if(bc(e.cpaMeters)&&bc(e.tcpaSeconds)){if(e.tcpaSeconds<=0)continue;t=e.cpaMeters,s=e.tcpaSeconds,c=`provider`}else{if(!a)continue;let n=e.cogRad===void 0?0:e.sogMps??0;if((i||a.sogMps<Nd)&&n<Nd)continue;let r=_d(a,{latitude:e.position.latitude,longitude:e.position.longitude,sogMps:n,cogRad:e.cogRad??0});if(!r.closing)continue;t=r.cpaMeters,s=r.tcpaSeconds,c=`computed`}let l=Ld(t,s,n,r?.get(e.id));l!==`clear`&&o.push({id:e.id,name:e.name,position:e.position,cpaMeters:t,tcpaSeconds:s,severity:l,source:c})}return o.length===0?Fd:(o.sort((e,t)=>Ad[e.severity]-Ad[t.severity]||e.tcpaSeconds-t.tcpaSeconds),{contacts:o,worst:o[0].severity})}var zd=class{#e;#t;#n;#r;#i=z(null);#a=!1;#o;#s=R(()=>{this.#t.version;let e=this.#e.position,t=Rd(e&&!this.#e.positionStale?{position:e,sogMps:this.#e.sogMps??0,cogRad:this.#e.cogRad??0}:void 0,this.#t.list(),this.#n.value,this.#o,this.#r());if(t.contacts.length===0)this.#o=void 0,this.#a=!0;else{let e=new Map;for(let n of t.contacts)e.set(n.id,n.severity);this.#o=e}return t});constructor(e,t,n,r=()=>!1){this.#e=e,this.#t=t,this.#n=n,this.#r=r}get assessment(){return W(this.#s)}get suppressed(){let e=this.#c();return e!==null&&!this.#a&&e===W(this.#i)}get escalating(){let e=W(this.#s).contacts[0];return!!e&&e.severity===`danger`&&e.cpaMeters<=jd&&e.tcpaSeconds<=Md}acknowledge(){this.#a=!1,B(this.#i,this.#c(),!0)}#c(){let e=this.assessment.contacts[0];return e?`${e.id}:${e.severity}`:null}},Bd=100,Vd=1.2,Hd=[$.courseNextPoint,$.coursePreviousPoint,$.courseActiveRoute,$.courseCalcValues,$.courseArrivalCircle],Ud=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t;for(let t of Hd)e.cell(t)}seed(e,t,n=Date.now()){let r=e=>this.#e.cell(e).epoch<n;e&&(r($.courseNextPoint)&&(this.#e.cell($.courseNextPoint).value=e.nextPoint),r($.coursePreviousPoint)&&(this.#e.cell($.coursePreviousPoint).value=e.previousPoint),r($.courseActiveRoute)&&(this.#e.cell($.courseActiveRoute).value=e.activeRoute),r($.courseArrivalCircle)&&(this.#e.cell($.courseArrivalCircle).value=e.arrivalCircle)),t&&r($.courseCalcValues)&&(this.#e.cell($.courseCalcValues).value=t)}clear(){for(let e of Hd)this.#e.cell(e).value=void 0}#n=R(()=>({nextPoint:this.#e.cell($.courseNextPoint).value,previousPoint:this.#e.cell($.coursePreviousPoint).value,activeRoute:this.#e.cell($.courseActiveRoute).value,arrivalCircle:this.#e.cell($.courseArrivalCircle).value}));#r=R(()=>this.#e.cell($.courseCalcValues).value);get active(){return!!W(this.#n).nextPoint?.position}get isLastPoint(){let e=W(this.#n).activeRoute;return e?.pointIndex==null||e?.pointTotal==null?!1:e.pointIndex>=e.pointTotal-1}get activePointIndex(){return W(this.#n).activeRoute?.pointIndex??void 0}get activePointTotal(){return W(this.#n).activeRoute?.pointTotal??void 0}get source(){let e=W(this.#r);return e&&(e.crossTrackError!=null||e.distance!=null||e.bearingTrue!=null||e.velocityMadeGood!=null||e.timeToGo!=null)?`server`:`computed`}get nextPointName(){return W(this.#n).nextPoint?.name}get nextPosition(){return this.#i}get estimatedTimeOfArrivalIso(){return W(this.#r)?.estimatedTimeOfArrival??void 0}get#i(){return W(this.#n).nextPoint?.position}get#a(){return this.#t.positionStale?void 0:this.#t.position}get#o(){return W(this.#n).previousPoint?.position??this.#a}#s=R(()=>{if(W(this.#r)?.distance!=null)return W(this.#r).distance;let e=this.#a;return e&&this.#i?yd(e,this.#i):void 0});get distanceToNextMeters(){return W(this.#s)}set distanceToNextMeters(e){B(this.#s,e)}#c=R(()=>{if(W(this.#r)?.bearingTrue!=null)return W(this.#r).bearingTrue;let e=this.#a;return e&&this.#i?bd(e,this.#i):void 0});get bearingToNextRad(){return W(this.#c)}set bearingToNextRad(e){B(this.#c,e)}#l=R(()=>{if(W(this.#r)?.crossTrackError!=null)return W(this.#r).crossTrackError;let e=this.#a;return e&&this.#o&&this.#i?xd(this.#o,this.#i,e):void 0});get crossTrackErrorMeters(){return W(this.#l)}set crossTrackErrorMeters(e){B(this.#l,e)}#u=R(()=>{if(W(this.#r)?.velocityMadeGood!=null)return W(this.#r).velocityMadeGood;let e=this.#a,t=this.#t.sogMps,n=this.#t.cogRad;return e&&this.#i&&t!=null&&n!=null?Sd(e,this.#i,t,n):void 0});get velocityMadeGoodMps(){return W(this.#u)}set velocityMadeGoodMps(e){B(this.#u,e)}#d=R(()=>{if(W(this.#r)?.timeToGo!=null)return W(this.#r).timeToGo;let e=this.distanceToNextMeters,t=this.#t.sogMps;return e!=null&&t!=null?Cd(e,t):void 0});get timeToGoSeconds(){return W(this.#d)}set timeToGoSeconds(e){B(this.#d,e)}#f=!1;#p;#m=R(()=>{let e=this.#i,t=e?`${e.latitude},${e.longitude}`:void 0;t!==this.#p&&(this.#p=t,this.#f=!1);let n=this.distanceToNextMeters;if(t===void 0||n==null)return this.#f=!1,!1;let r=W(this.#n).arrivalCircle??Bd;return this.#f?n>r*Vd&&(this.#f=!1):n<=r&&(this.#f=!0),this.#f});get arrived(){return W(this.#m)}set arrived(e){B(this.#m,e)}},Wd=class{#e=z(!1);#t=z(fn([]));get active(){return W(this.#e)}get points(){return W(this.#t)}#n=R(()=>{let e=[];for(let t=1;t<W(this.#t).length;t+=1){let n=W(this.#t)[t-1],r=W(this.#t)[t];e.push({from:n,to:r,distanceMeters:yd(n,r),bearingRad:bd(n,r)})}return e});get legs(){return W(this.#n)}set legs(e){B(this.#n,e)}get lastLeg(){return this.legs[this.legs.length-1]}#r=R(()=>{let e=0;for(let t of this.legs)e+=t.distanceMeters;return e});get totalMeters(){return W(this.#r)}start(){B(this.#t,[],!0),B(this.#e,!0)}stop(){B(this.#e,!1),B(this.#t,[],!0)}add(e){W(this.#e)&&B(this.#t,[...W(this.#t),e],!0)}undo(){B(this.#t,W(this.#t).slice(0,-1),!0)}clear(){B(this.#t,[],!0)}};function Gd(e){return!e||typeof e!=`object`||!bc(e.epochMs)||e.position!==void 0&&!Zs(e.position)?null:e}var Kd=class{#e;#t;#n;#r;#i=z(null);#a=z(!1);constructor(e,t,n,r){this.#e=e,this.#t=t,this.#n=n,this.#r=new Ol(`binnacle:mob`,null,r),B(this.#i,Gd(this.#r.value),!0),e.cell($.mobNotification)}#o=R(()=>{let e=this.#e.cell($.mobNotification).value;if(!(!e||typeof e!=`object`))return e});#s=R(()=>{let e=W(this.#o)?.state;return typeof e==`string`&&Wu.has(e)});#c=R(()=>{if(!W(this.#s))return;let e=W(this.#o)?.position;return Zs(e)?e:void 0});get active(){return W(this.#i)!==null||W(this.#s)}get position(){return W(this.#i)?.position??W(this.#c)}get markEpochMs(){return W(this.#i)?.epochMs}get elapsedSeconds(){if(!(!this.#n||!W(this.#i)))return Math.max(0,(this.#n.now-W(this.#i).epochMs)/1e3)}#l=R(()=>{let e=this.position,t=this.#t.position;if(!(!e||!t||this.#t.positionStale))return bd(t,e)});#u=R(()=>{let e=this.position,t=this.#t.position;if(!(!e||!t||this.#t.positionStale))return fd(t.latitude,t.longitude,e.latitude,e.longitude)});get bearingRad(){return W(this.#l)}get distanceMeters(){return W(this.#u)}get acknowledged(){return W(this.#a)}capture(){let e=this.#t.position;if(e)return{position:{latitude:e.latitude,longitude:e.longitude},epochMs:this.#n?.now??0}}captureAgeMs(e){if(this.#n)return Math.max(0,this.#n.now-e.epochMs)}trigger(e){let t=e??this.capture()??{epochMs:this.#n?.now??0};return B(this.#a,!1),this.#d(t),t}cancel(){B(this.#a,!1),this.#d(null)}acknowledge(){B(this.#a,!0)}#d(e){B(this.#i,e,!0),this.#r.set(e)}},qd={emergency:0,alarm:1,warn:2,alert:3};function Jd(e,t){if(!t||typeof t!=`object`)return;let n=t,r=n.state;if(typeof r!=`string`||!Object.hasOwn(qd,r))return;let i=Array.isArray(n.method)?n.method.filter(e=>typeof e==`string`):[],a=n.status&&typeof n.status==`object`?n.status:{},o=e=>typeof e==`boolean`?e:void 0;return{path:e,state:r,message:typeof n.message==`string`?n.message:``,method:i,timestamp:typeof n.createdAt==`string`?n.createdAt:void 0,id:typeof n.id==`string`?n.id:void 0,silenced:o(a.silenced),acknowledged:o(a.acknowledged),canSilence:o(a.canSilence),canAcknowledge:o(a.canAcknowledge)}}var Yd=class{#e;#t;#n=-1;constructor(e){this.#e=e}get version(){return this.#e.notificationsVersion}list(){let e=this.#e.notificationsVersion;if(this.#t&&this.#n===e)return this.#t;let t=[];for(let[e,n]of this.#e.notifications){let r=Jd(e,n);r&&t.push(r)}return t.sort((e,t)=>qd[e.state]-qd[t.state]||(e.path<t.path?-1:+(e.path>t.path))),this.#t=t,this.#n=e,t}},Xd=`binnacle:profiles`,Zd=class{load(){if(!(typeof localStorage>`u`))try{let e=localStorage.getItem(Xd);return e==null?void 0:JSON.parse(e)}catch{return}}save(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(Xd,JSON.stringify(e))}catch{}}};function Qd(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`string`&&typeof t.name==`string`&&!!t.settings&&typeof t.settings==`object`}var $d=class{#e=z(fn([]));get profiles(){return W(this.#e)}set profiles(e){B(this.#e,e,!0)}#t=z(void 0);get activeId(){return W(this.#t)}set activeId(e){B(this.#t,e,!0)}#n=z(!1);get isDirty(){return W(this.#n)}set isDirty(e){B(this.#n,e,!0)}#r=z(void 0);#i;#a;#o=!1;#s=!1;loadedFromStorage=!1;constructor(e=new Zd){this.#i=e;let t=e.load();t&&(this.loadedFromStorage=!0,this.profiles=Array.isArray(t.profiles)?t.profiles.filter(Qd):[],this.activeId=t.activeId,B(this.#r,t.defaultId,!0))}get active(){return this.profiles.find(e=>e.id===this.activeId)}get defaultId(){return W(this.#r)}seed(e){this.profiles.length>0||(this.profiles=e,this.#u())}async syncWithServer(e){if(this.#a)return!0;let t;try{t=await e.load()}catch{t=void 0}return t===void 0?!1:(this.#a=e,this.#c(t),this.#d(),!0)}#c(e){let t=new Map;for(let e of this.profiles)t.set(e.id,e);let n=Array.isArray(e.profiles)?e.profiles.filter(Qd):[];for(let e of n){let n=t.get(e.id);(!n||(e.updatedAt??0)>=(n.updatedAt??0))&&t.set(e.id,e)}this.profiles=[...t.values()],B(this.#r,e.defaultId??W(this.#r),!0),this.#i.save(this.#l())}save(e,t){let n=Date.now(),r={id:vc(),name:e,settings:t,createdAt:n,updatedAt:n};return this.profiles=[...this.profiles,r],this.#u(),r}update(e,t){let n=Date.now();this.profiles=this.profiles.map(r=>r.id===e?{...r,settings:t,updatedAt:n}:r),this.#u()}rename(e,t){this.profiles=this.profiles.map(n=>n.id===e?{...n,name:t,updatedAt:Date.now()}:n),this.#u()}remove(e){this.profiles=this.profiles.filter(t=>t.id!==e),this.activeId===e&&(this.activeId=void 0),W(this.#r)===e&&B(this.#r,void 0),this.#u()}setDefault(e){B(this.#r,e,!0),this.#u()}setActive(e){this.activeId=e,this.isDirty=!1,this.#u()}markDirty(){this.activeId!==void 0&&!this.isDirty&&(this.isDirty=!0)}clearDirty(){this.isDirty=!1}#l(){return{profiles:this.profiles,activeId:this.activeId,defaultId:W(this.#r)}}#u(){this.#i.save(this.#l()),this.#d()}#d(){this.#a&&(this.#o=!0,!this.#s&&this.#f())}async#f(){if(this.#a){for(this.#s=!0;this.#o;){this.#o=!1;let e=!1;try{e=await this.#a.save(this.#l())}catch{e=!1}if(!e){this.#a=void 0;break}}this.#s=!1}}},ef=e=>`${e}/signalk/v1/applicationData/user/signalk-binnacle/1.0.0`,tf=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}async load(){try{let e=await fetch(ef(this.#e),hc(gu(this.#t)));if(!e.ok)return;let t=await e.json();return!t||typeof t!=`object`||!Array.isArray(t.profiles)?{profiles:[],activeId:void 0,defaultId:void 0}:t}catch{return}}async save(e){try{return(await fetch(ef(this.#e),hc(gu(this.#t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})))).ok}catch{return!1}}};function nf(e){let t=e.waypoints.some(e=>e.name)?{coordinatesMeta:e.waypoints.map((e,t)=>({name:e.name??`${t+1}`}))}:{};return{name:e.name,distance:af(e.waypoints),feature:{type:`Feature`,geometry:{type:`LineString`,coordinates:e.waypoints.map(e=>nc(e.position))},properties:t}}}function rf(e,t){if(!t||typeof t!=`object`)return;let n=t,r=n.feature?.geometry;if(r?.type!==`LineString`||!Array.isArray(r.coordinates))return;let i=Array.isArray(n.feature?.properties?.coordinatesMeta)?n.feature?.properties?.coordinatesMeta:[],a=[];if(r.coordinates.forEach((e,t)=>{if(ec(e)){let n=vu(i[t]?.name);a.push({position:tc(e),...n?{name:n}:{}})}}),!(a.length<2))return{id:e,name:vu(n.name)??e,waypoints:a}}function af(e){let t=0;for(let n=1;n<e.length;n+=1)t+=yd(e[n-1].position,e[n].position);return t}function of(e,t){let n=0;for(let r=Math.max(0,t);r<e.length-1;r+=1)n+=yd(e[r].position,e[r+1].position);return n}function sf(e,t){return e.map((e,n)=>({type:`Feature`,geometry:{type:`Point`,coordinates:nc(e.position)},properties:{...t,index:n,name:e.name??`${n+1}`}}))}function cf(e){let t=[];for(let n=1;n<e.length;n+=1)t.push({fromIndex:n-1,distanceMeters:yd(e[n-1].position,e[n].position),bearingRad:bd(e[n-1].position,e[n].position)});return t}function lf(e,t){if(!e)return[];let n=e=>e>=0&&e<t;return e.kind===`waypoint`?n(e.index)?[e.index]:[]:[e.index,e.index+1].filter(n)}function uf(e,t){if(!e)return[];let n=Math.max(0,t-1),r=e=>e>=0&&e<n;return e.kind===`leg`?r(e.index)?[e.index]:[]:[e.index-1,e.index].filter(r)}function df(e,t){let n=e.waypoints,r=lf(t,n.length).map(e=>({type:`Feature`,geometry:{type:`Point`,coordinates:nc(n[e].position)},properties:{index:e}})),i=uf(t,n.length).map(e=>({type:`Feature`,geometry:{type:`LineString`,coordinates:[nc(n[e].position),nc(n[e+1].position)]},properties:{index:e}}));return{dots:{type:`FeatureCollection`,features:r},segments:{type:`FeatureCollection`,features:i}}}function ff(e){return{id:vc(),name:`${e.name} (reverse)`,waypoints:[...e.waypoints].reverse()}}var pf=class{#e=z(fn([]));get routes(){return W(this.#e)}set routes(e){B(this.#e,e,!0)}#t=z(fn(new Set));get shownIds(){return W(this.#t)}set shownIds(e){B(this.#t,e,!0)}#n=z(void 0);get working(){return W(this.#n)}set working(e){B(this.#n,e,!0)}#r=z(void 0);get activeId(){return W(this.#r)}set activeId(e){B(this.#r,e,!0)}#i=z(0);get version(){return W(this.#i)}set version(e){B(this.#i,e,!0)}#a=z(void 0);get highlight(){return W(this.#a)}set highlight(e){B(this.#a,e,!0)}#o=z(0);get editVersion(){return W(this.#o)}set editVersion(e){B(this.#o,e,!0)}setRoutes(e){this.routes=e,this.version+=1}isShown(e){return this.shownIds.has(e)}toggleShown(e,t){let n=new Set(this.shownIds);t?n.add(e):n.delete(e),this.shownIds=n,this.version+=1}setWorking(e){let t=this.working?.waypoints.length??0;this.working=e,(e?.waypoints.length??0)!==t&&(this.highlight=void 0),this.editVersion+=1}setHighlight(e){this.highlight=e,this.editVersion+=1}clearHighlight(){this.highlight&&(this.highlight=void 0,this.editVersion+=1)}setActive(e){this.activeId=e,this.version+=1}},mf={day:{background:`#f2efe8`,water:`#a8c9e0`,land:`#eae6dd`,landcover:`#d6e6c8`,road:`#c9c2b6`,boundary:`#b6a98f`,label:`#33414c`,danger:`#c8401f`,warning:`#e0a020`,note:`#7a3fa0`,tide:`#0d8a99`,waypoint:`#1f6fb0`,markerGlyph:`#ffffff`,select:`#ffb300`,routeHighlight:`#ff7a00`,navStarboard:`#d8392f`,navPort:`#1f9e54`,navLight:`#c026d3`,trackSlow:`#1a3a5a`,trackMid:`#2c6da3`,trackFast:`#6fb1e0`,trackSolid:`#1f6fb2`,ownVessel:{r:31,g:111,b:178,a:255},aisTarget:{r:224,g:160,b:32,a:255},rasterSaturation:0,rasterBrightnessMax:1},dusk:{background:`#0a151f`,water:`#10212e`,land:`#16242f`,landcover:`#152b24`,road:`#2a3b48`,boundary:`#3a4d5c`,label:`#9fb4c6`,danger:`#e0703a`,warning:`#d9a441`,note:`#9a6fc0`,tide:`#2f9fb0`,waypoint:`#4f8fc0`,markerGlyph:`#eef3f6`,select:`#ffc24d`,routeHighlight:`#ff9433`,navStarboard:`#e0573f`,navPort:`#3fae6a`,navLight:`#cf5bd9`,trackSlow:`#22455f`,trackMid:`#3f87bf`,trackFast:`#84c0ea`,trackSolid:`#4f9fd8`,ownVessel:{r:79,g:159,b:216,a:255},aisTarget:{r:217,g:164,b:65,a:255},rasterSaturation:0,rasterBrightnessMax:1},"night-red":{background:`#000000`,water:`#140402`,land:`#0c0301`,landcover:`#0f0402`,road:`#3a0c08`,boundary:`#4a0f0a`,label:`#9a3a2c`,danger:`#ff6a5a`,warning:`#b03a26`,note:`#9a2a18`,tide:`#c24a30`,waypoint:`#d96a50`,markerGlyph:`#ff9a86`,select:`#ffb39a`,routeHighlight:`#ff8c4d`,navStarboard:`#ff6a5a`,navPort:`#8e2a22`,navLight:`#c0503c`,trackSlow:`#3a0c08`,trackMid:`#9a3020`,trackFast:`#ff6a5a`,trackSolid:`#c8442e`,ownVessel:{r:224,g:71,b:58,a:255},aisTarget:{r:176,g:46,b:34,a:255},rasterSaturation:-1,rasterBrightnessMax:.45}};function hf(e){return{...mf[e],theme:e}}function gf(e,t,n){e.setPaintProperty(t,`raster-saturation`,n.rasterSaturation),e.setPaintProperty(t,`raster-brightness-max`,n.rasterBrightnessMax)}var _f=`binnacle:themePaint`,vf=`pmtiles://`,yf=`chart-`;function bf(e){return`${yf}${e}`}function xf(e,t){return e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`//`)||e.startsWith(`blob:`)||e.startsWith(`pmtiles://`)?e:`${t}${e.startsWith(`/`)?``:`/`}${e}`}function Sf(e){if(e.startsWith(`pmtiles://`))return e;if(e.endsWith(`.pmtiles`))return`${vf}${e}`}function Cf(e,t){let n=bf(e.identifier),r=`${n}-layer`,i=xf(e.tilemapUrl??e.url??``,t),a=Sf(i),o=a?{type:`raster`,url:a,tileSize:256,...e.bounds?{bounds:e.bounds}:{}}:{type:`raster`,tiles:[i],tileSize:256,...e.minzoom===void 0?{}:{minzoom:e.minzoom},...e.maxzoom===void 0?{}:{maxzoom:e.maxzoom},...e.bounds?{bounds:e.bounds}:{}};return{sources:{[n]:o},layers:[{id:r,type:`raster`,source:n}]}}var wf=12,Tf=.8,Ef=.5,Df=[{sourceLayer:`earth`,kind:`fill`,paint:`land`},{sourceLayer:`landcover`,kind:`fill`,paint:`landcover`},{sourceLayer:`landuse`,kind:`fill`,paint:`landcover`,minZoom:wf},{sourceLayer:`water`,kind:`fill`,paint:`water`},{sourceLayer:`roads`,kind:`line`,paint:`road`},{sourceLayer:`transportation`,kind:`line`,paint:`road`},{sourceLayer:`boundaries`,kind:`line`,paint:`boundary`},{sourceLayer:`boundary`,kind:`line`,paint:`boundary`}],Of=hf(`day`);function kf(e,t){let n=Of,r=t.length>0?new Set(t):new Set(Df.map(e=>e.sourceLayer)),i=[];for(let t of Df){let a=t.sourceLayer;if(!r.has(a))continue;let o=`${e}-${a}`,s=n[t.paint],c={[_f]:t.paint},l=t.minZoom===void 0?{}:{minzoom:t.minZoom};t.kind===`fill`?i.push({id:o,type:`fill`,source:e,"source-layer":a,paint:{"fill-color":s},metadata:c,...l}):i.push({id:o,type:`line`,source:e,"source-layer":a,paint:{"line-color":s,"line-width":t.paint===`boundary`?Tf:Ef},metadata:c,...l})}return i}function Af(e,t){let n=bf(e.identifier),r=xf(e.url??e.tilemapUrl??``,t),i={type:`vector`,url:Sf(r)??r,...e.minzoom===void 0?{}:{minzoom:e.minzoom},...e.maxzoom===void 0?{}:{maxzoom:e.maxzoom},...e.bounds?{bounds:e.bounds}:{}};return{sources:{[n]:i},layers:kf(n,e.layers??[])}}var jf=new Set([`png`,`jpg`,`jpeg`,`webp`,`avif`]);function Mf(e){return e.type===`tileJSON`||e.format===`mvt`||e.format===`pbf`?!0:e.format&&jf.has(e.format)?!1:(e.url??e.tilemapUrl??``).endsWith(`.pmtiles`)}function Nf(e,t){return e.type===`mapstyleJSON`?{sources:{},layers:[]}:Mf(e)?Af(e,t):Cf(e,t)}function Pf(e,t,n){let r=n?`visible`:`none`;for(let n of t)e.setLayoutProperty(n,`visibility`,r)}function Ff(e,t,n){for(let n of t)e.getLayer(n)&&e.removeLayer(n);for(let t of n)e.getSource(t)&&e.removeSource(t)}var If=c(o(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self,n.maplibregl=r())})(e,(function(){var e={},t={};function n(n,r,i){if(t[n]=i,n===`index`){var a=`var sharedModule = {}; (`+t.shared+`)(sharedModule); (`+t.worker+`)(sharedModule);`,o={};return t.shared(o),t.index(e,o),typeof window<`u`&&e.setWorkerUrl(window.URL.createObjectURL(new Blob([a],{type:`text/javascript`}))),e}}return n(`shared`,[`exports`],(function(e){function t(e,t,n,r){return new(n||=Promise)((function(i,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((r=r.apply(e,t||[])).next())}))}function n(e,t){this.x=e,this.y=t}function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var i,a;n.prototype={clone(){return new n(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){let t=e.x-this.x,n=e.y-this.y;return t*t+n*n},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){let t=e[2]*this.x+e[3]*this.y;return this.x=e[0]*this.x+e[1]*this.y,this.y=t,this},_add(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){let e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){let t=Math.cos(e),n=Math.sin(e),r=n*this.x+t*this.y;return this.x=t*this.x-n*this.y,this.y=r,this},_rotateAround(e,t){let n=Math.cos(e),r=Math.sin(e),i=t.y+r*(this.x-t.x)+n*(this.y-t.y);return this.x=t.x+n*(this.x-t.x)-r*(this.y-t.y),this.y=i,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:n},n.convert=function(e){if(e instanceof n)return e;if(Array.isArray(e))return new n(+e[0],+e[1]);if(e.x!==void 0&&e.y!==void 0)return new n(+e.x,+e.y);throw Error(`Expected [x, y] or {x, y} point format`)};var o=r(function(){if(a)return i;function e(e,t,n,r){this.cx=3*e,this.bx=3*(n-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(r-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=n,this.p2y=r}return a=1,i=e,e.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,t){if(t===void 0&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var n=e,r=0;r<8;r++){var i=this.sampleCurveX(n)-e;if(Math.abs(i)<t)return n;var a=this.sampleCurveDerivativeX(n);if(Math.abs(a)<1e-6)break;n-=i/a}var o=0,s=1;for(n=e,r=0;r<20&&(i=this.sampleCurveX(n),!(Math.abs(i-e)<t));r++)e>i?o=n:s=n,n=.5*(s-o)+o;return n},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},i}());let s,c;function l(){return s??=typeof OffscreenCanvas<`u`&&new OffscreenCanvas(1,1).getContext(`2d`)&&typeof createImageBitmap==`function`,s}function u(){if(c==null&&(c=!1,l())){let e=new OffscreenCanvas(5,5).getContext(`2d`,{willReadFrequently:!0});if(e){for(let t=0;t<25;t++){let n=4*t;e.fillStyle=`rgb(${n},${n+1},${n+2})`,e.fillRect(t%5,Math.floor(t/5),1,1)}let t=e.getImageData(0,0,5,5).data;for(let e=0;e<100;e++)if(e%4!=3&&t[e]!==e){c=!0;break}}}return c||!1}var d=1e-6,f=typeof Float32Array<`u`?Float32Array:Array;function p(){var e=new f(9);return f!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function m(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function h(){var e=new f(3);return f!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function g(e){var t=e[0],n=e[1],r=e[2];return Math.sqrt(t*t+n*n+r*r)}function _(e,t,n){var r=new f(3);return r[0]=e,r[1]=t,r[2]=n,r}function v(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e}function y(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e}function b(e,t,n){var r=t[0],i=t[1],a=t[2],o=n[0],s=n[1],c=n[2];return e[0]=i*c-a*s,e[1]=a*o-r*c,e[2]=r*s-i*o,e}var x,S=g;function C(e,t,n){var r=t[0],i=t[1],a=t[2],o=t[3];return e[0]=n[0]*r+n[4]*i+n[8]*a+n[12]*o,e[1]=n[1]*r+n[5]*i+n[9]*a+n[13]*o,e[2]=n[2]*r+n[6]*i+n[10]*a+n[14]*o,e[3]=n[3]*r+n[7]*i+n[11]*a+n[15]*o,e}function w(){var e=new f(4);return f!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function T(e,t,n,r){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:`zyx`,a=Math.PI/360;t*=a,r*=a,n*=a;var o=Math.sin(t),s=Math.cos(t),c=Math.sin(n),l=Math.cos(n),u=Math.sin(r),d=Math.cos(r);switch(i){case`xyz`:e[0]=o*l*d+s*c*u,e[1]=s*c*d-o*l*u,e[2]=s*l*u+o*c*d,e[3]=s*l*d-o*c*u;break;case`xzy`:e[0]=o*l*d-s*c*u,e[1]=s*c*d-o*l*u,e[2]=s*l*u+o*c*d,e[3]=s*l*d+o*c*u;break;case`yxz`:e[0]=o*l*d+s*c*u,e[1]=s*c*d-o*l*u,e[2]=s*l*u-o*c*d,e[3]=s*l*d+o*c*u;break;case`yzx`:e[0]=o*l*d+s*c*u,e[1]=s*c*d+o*l*u,e[2]=s*l*u-o*c*d,e[3]=s*l*d-o*c*u;break;case`zxy`:e[0]=o*l*d-s*c*u,e[1]=s*c*d+o*l*u,e[2]=s*l*u+o*c*d,e[3]=s*l*d-o*c*u;break;case`zyx`:e[0]=o*l*d-s*c*u,e[1]=s*c*d+o*l*u,e[2]=s*l*u-o*c*d,e[3]=s*l*d+o*c*u;break;default:throw Error(`Unknown angle order `+i)}return e}function E(){var e=new f(2);return f!=Float32Array&&(e[0]=0,e[1]=0),e}function D(e,t){var n=new f(2);return n[0]=e,n[1]=t,n}h(),x=new f(4),f!=Float32Array&&(x[0]=0,x[1]=0,x[2]=0,x[3]=0),h(),_(1,0,0),_(0,1,0),w(),w(),p(),E();let O=8192;function k(e,t,n){return t*(O/(e.tileSize*2**(n-e.tileID.overscaledZ)))}function A(e){return e instanceof Error?e:Error(typeof e==`string`?e:String(e))}function ee(e,t){return(e%t+t)%t}function te(e,t,n){return e*(1-n)+t*n}function j(e){if(e<=0)return 0;if(e>=1)return 1;let t=e*e,n=t*e;return 4*(e<.5?n:3*(e-t)+n-.75)}function ne(e,t,n,r){let i=new o(e,t,n,r);return e=>i.solve(e)}let re=ne(.25,.1,.25,1);function ie(e,t,n){return Math.min(n,Math.max(t,e))}function ae(e,t,n){let r=n-t,i=((e-t)%r+r)%r+t;return i===t?n:i}function oe(e,...t){for(let n of t)for(let t in n)e[t]=n[t];return e}let se=1;function ce(e,t,n){let r={};for(let n in e)r[n]=t.call(this,e[n],n,e);return r}function le(e,t,n){let r={};for(let n in e)t.call(this,e[n],n,e)&&(r[n]=e[n]);return r}function ue(e){return Array.isArray(e)?e.map(ue):typeof e==`object`&&e?ce(e,ue):e}let de={};function fe(e){de[e]||(typeof console<`u`&&console.warn(e),de[e]=!0)}function pe(e,t,n){return(n.y-e.y)*(t.x-e.x)>(t.y-e.y)*(n.x-e.x)}function me(e){return typeof WorkerGlobalScope<`u`&&e!==void 0&&e instanceof WorkerGlobalScope}let he=null;function ge(e){return typeof ImageBitmap<`u`&&e instanceof ImageBitmap}let _e=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=`;function ve(e,n,r,i,a){return t(this,void 0,void 0,(function*(){if(typeof VideoFrame>`u`)throw Error(`VideoFrame not supported`);let t=new VideoFrame(e,{timestamp:0});try{let o=t?.format;if(!o||!o.startsWith(`BGR`)&&!o.startsWith(`RGB`))throw Error(`Unrecognized format ${o}`);let s=o.startsWith(`BGR`),c=new Uint8ClampedArray(i*a*4);if(yield t.copyTo(c,function(e,t,n,r,i){let a=4*Math.max(-t,0),o=(Math.max(0,n)-n)*r*4+a,s=4*r,c=Math.max(0,t),l=Math.max(0,n);return{rect:{x:c,y:l,width:Math.min(e.width,t+r)-c,height:Math.min(e.height,n+i)-l},layout:[{offset:o,stride:s}]}}(e,n,r,i,a)),s)for(let e=0;e<c.length;e+=4){let t=c[e];c[e]=c[e+2],c[e+2]=t}return c}finally{t.close()}}))}let ye,be;function xe(e,t,n,r){return e.addEventListener(t,n,r),{unsubscribe:()=>{e.removeEventListener(t,n,r)}}}function Se(e){return e*Math.PI/180}function Ce(e){return e/Math.PI*180}let we={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},Te={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},Ee=`AbortError`;class De extends Error{constructor(e=Ee){super(e instanceof Error?e.message:e),this.name=Ee,e instanceof Error&&e.stack&&(this.stack=e.stack)}}function Oe(e){return e instanceof Error&&e.name===Ee}function ke(e){if(e.aborted)throw new De(e.reason)}let Ae={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:``};function je(e){return Ae.REGISTERED_PROTOCOLS[e.substring(0,e.indexOf(`://`))]}let Me=`global-dispatcher`;class Ne extends Error{constructor(e,t,n,r){super(`AJAXError: ${t} (${e}): ${n}`),this.status=e,this.statusText=t,this.url=n,this.body=r}}let Pe=()=>me(self)?self.worker?.referrer:(window.location.protocol===`blob:`?window.parent:window).location.href,Fe=function(e,n){return t(this,void 0,void 0,(function*(){if(e.url.includes(`://`)&&!/^https?:|^file:/.test(e.url)){let t=je(e.url);if(t){let r=yield t(e,n);return r.data||e.type!==`arrayBuffer`?r:oe(r,{data:new ArrayBuffer(0)})}if(me(self)&&self.worker?.actor)return self.worker.actor.sendAsync({type:`GR`,data:e,targetMapId:Me},n)}if(!(e=>e.startsWith(`file:`)||Pe()?.startsWith(`file:`)&&!/^\w+:/.test(e))(e.url)){if(fetch&&Request&&AbortController&&Object.hasOwn(Request.prototype,`signal`))return function(e,n){return t(this,void 0,void 0,(function*(){let t=new Request(e.url,{method:e.method||`GET`,body:e.body,credentials:e.credentials,headers:e.headers,cache:e.cache,referrer:Pe(),referrerPolicy:e.referrerPolicy,signal:n.signal}),r,i;e.type!==`json`||t.headers.has(`Accept`)||t.headers.set(`Accept`,`application/json`);try{r=yield fetch(t)}catch(t){throw Oe(t)?t:new Ne(0,A(t).message,e.url,new Blob)}if(!r.ok){let t=yield r.blob();throw new Ne(r.status,r.statusText,e.url,t)}i=e.type===`arrayBuffer`||e.type===`image`?r.arrayBuffer():e.type===`json`?r.json():r.text();let a=yield i;return ke(n.signal),{data:a,cacheControl:r.headers.get(`Cache-Control`),expires:r.headers.get(`Expires`),etag:r.headers.get(`ETag`)}}))}(e,n);if(me(self)&&self.worker?.actor)return self.worker.actor.sendAsync({type:`GR`,data:e,mustQueue:!0,targetMapId:Me},n)}return function(e,t){return new Promise(((n,r)=>{var i;let a=new XMLHttpRequest;a.open(e.method||`GET`,e.url,!0),e.type!==`arrayBuffer`&&e.type!==`image`||(a.responseType=`arraybuffer`);for(let t in e.headers)a.setRequestHeader(t,e.headers[t]);e.type===`json`&&(a.responseType=`text`,(i=e.headers)!=null&&i.Accept||a.setRequestHeader(`Accept`,`application/json`)),a.withCredentials=e.credentials===`include`,a.onerror=()=>{r(Error(a.statusText))},a.onload=()=>{if(!t.signal.aborted)if((a.status>=200&&a.status<300||a.status===0)&&a.response!==null){let t=a.response;if(e.type===`json`)try{t=JSON.parse(a.response)}catch(e){r(e);return}n({data:t,cacheControl:a.getResponseHeader(`Cache-Control`),expires:a.getResponseHeader(`Expires`),etag:a.getResponseHeader(`ETag`)})}else{let t=new Blob([a.response],{type:a.getResponseHeader(`Content-Type`)});r(new Ne(a.status,a.statusText,e.url,t))}},t.signal.addEventListener(`abort`,(()=>{a.abort(),r(new De(t.signal.reason))})),a.send(e.body)}))}(e,n)}))};function Ie(e){if(!e||e.indexOf(`://`)<=0||e.startsWith(`data:image/`)||e.startsWith(`blob:`))return!0;let t=new URL(e),n=window.location;return t.protocol===n.protocol&&t.host===n.host}function Le(e,t,n){var r;(r=n[e])!=null&&r.includes(t)||(n[e]||(n[e]=[]),n[e].push(t))}function Re(e,t,n){if(n?.[e]){let r=n[e].indexOf(t);r!==-1&&n[e].splice(r,1)}}class ze{constructor(e,t={}){oe(this,t),this.type=e}}class Be extends ze{constructor(e,t={}){super(`error`,oe({error:e},t))}}class Ve{on(e,t){return this._listeners||={},Le(e,t,this._listeners),{unsubscribe:()=>{this.off(e,t)}}}off(e,t){return Re(e,t,this._listeners),Re(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners||={},Le(e,t,this._oneTimeListeners),this):new Promise((t=>this.once(e,t)))}fire(e,t){typeof e==`string`&&(e=new ze(e,t||{}));let n=e.type;if(this.listens(n)){e.target=this;let t=this._listeners?.[n]?this._listeners[n].slice():[];for(let n of t)n.call(this,e);let r=this._oneTimeListeners?.[n]?this._oneTimeListeners[n].slice():[];for(let t of r)Re(n,t,this._oneTimeListeners),t.call(this,e);let i=this._eventedParent;i&&(oe(e,typeof this._eventedParentData==`function`?this._eventedParentData():this._eventedParentData),i.fire(e))}else e instanceof Be&&console.error(e.error);return this}listens(e){return this._listeners?.[e]?.length>0||this._oneTimeListeners?.[e]?.length>0||this._eventedParent?.listens(e)}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}}var M={$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:{required:!0,type:`string`},coordinates:{required:!0,type:`array`,length:4,value:{type:`array`,length:2,value:`number`}}},layer:{id:{type:`string`,required:!0},type:{type:`enum`,values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},metadata:{type:`*`},source:{type:`string`},"source-layer":{type:`string`},minzoom:{type:`number`,minimum:0,maximum:24},maxzoom:{type:`number`,minimum:0,maximum:24},filter:{type:`filter`},layout:{type:`layout`},paint:{type:`paint`}},layout:[`layout_fill`,`layout_line`,`layout_circle`,`layout_heatmap`,`layout_fill-extrusion`,`layout_symbol`,`layout_raster`,`layout_hillshade`,`layout_color-relief`,`layout_background`],layout_background:{visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,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`}},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`]},"property-type":`data-constant`},"icon-size":{type:`number`,default:1,minimum:0,units:`factor of the original icon size`,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"icon-text-fit":{type:`enum`,values:{none:{},width:{},height:{},both:{}},default:`none`,requires:[`icon-image`,`text-field`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"icon-text-fit-padding":{type:`array`,value:`number`,length:4,default:[0,0,0,0],units:`pixels`,requires:[`icon-image`,`text-field`,{"icon-text-fit":[`both`,`width`,`height`]}],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"icon-image":{type:`resolvedImage`,tokens:!0,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"icon-rotate":{type:`number`,default:0,period:360,units:`degrees`,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"icon-padding":{type:`padding`,default:[2],units:`pixels`,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"icon-keep-upright":{type:`boolean`,default:!1,requires:[`icon-image`,{"icon-rotation-alignment":`map`},{"symbol-placement":[`line`,`line-center`]}],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"icon-offset":{type:`array`,value:`number`,length:2,default:[0,0],requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"icon-anchor":{type:`enum`,values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:`center`,requires:[`icon-image`],expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"icon-pitch-alignment":{type:`enum`,values:{map:{},viewport:{},auto:{}},default:`auto`,requires:[`icon-image`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-pitch-alignment":{type:`enum`,values:{map:{},viewport:{},auto:{}},default:`auto`,requires:[`text-field`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-rotation-alignment":{type:`enum`,values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:`auto`,requires:[`text-field`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-field":{type:`formatted`,default:``,tokens:!0,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-font":{type:`array`,value:`string`,default:[`Open Sans Regular`,`Arial Unicode MS Regular`],requires:[`text-field`],expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-size":{type:`number`,default:16,minimum:0,units:`pixels`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-max-width":{type:`number`,default:10,minimum:0,units:`ems`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-line-height":{type:`number`,default:1.2,units:`ems`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"text-letter-spacing":{type:`number`,default:0,units:`ems`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-justify":{type:`enum`,values:{auto:{},left:{},center:{},right:{}},default:`center`,requires:[`text-field`],expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-radial-offset":{type:`number`,units:`ems`,default:0,requires:[`text-field`],"property-type":`data-driven`,expression:{interpolated:!0,parameters:[`zoom`,`feature`]}},"text-variable-anchor":{type:`array`,value:`enum`,values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:[`text-field`,{"symbol-placement":[`point`]}],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-variable-anchor-offset":{type:`variableAnchorOffsetCollection`,requires:[`text-field`,{"symbol-placement":[`point`]}],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-anchor":{type:`enum`,values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:`center`,requires:[`text-field`,{"!":`text-variable-anchor`}],expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-max-angle":{type:`number`,default:45,units:`degrees`,requires:[`text-field`,{"symbol-placement":[`line`,`line-center`]}],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"text-writing-mode":{type:`array`,value:`enum`,values:{horizontal:{},vertical:{}},requires:[`text-field`,{"symbol-placement":[`point`]}],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-rotate":{type:`number`,default:0,period:360,units:`degrees`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-padding":{type:`number`,default:2,minimum:0,units:`pixels`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"text-keep-upright":{type:`boolean`,default:!0,requires:[`text-field`,{"text-rotation-alignment":`map`},{"symbol-placement":[`line`,`line-center`]}],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-transform":{type:`enum`,values:{none:{},uppercase:{},lowercase:{}},default:`none`,requires:[`text-field`],expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-offset":{type:`array`,value:`number`,units:`ems`,length:2,default:[0,0],requires:[`text-field`,{"!":`text-radial-offset`}],expression:{interpolated:!0,parameters:[`zoom`,`feature`]},"property-type":`data-driven`},"text-allow-overlap":{type:`boolean`,default:!1,requires:[`text-field`,{"!":`text-overlap`}],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-overlap":{type:`enum`,values:{never:{},always:{},cooperative:{}},requires:[`text-field`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-ignore-placement":{type:`boolean`,default:!1,requires:[`text-field`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-optional":{type:`boolean`,default:!1,requires:[`text-field`,`icon-image`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},visibility:{type:`enum`,values:{visible:{},none:{}},default:`visible`,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-color":{type:`color`,default:`#000000`,transition:!0,requires:[{"!":`fill-pattern`}],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-outline-color":{type:`color`,transition:!0,requires:[{"!":`fill-pattern`},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-translate":{type:`array`,value:`number`,length:2,default:[0,0],transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"fill-translate-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`map`,requires:[`fill-translate`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"fill-pattern":{type:`resolvedImage`,transition:!0,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`cross-faded-data-driven`}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"fill-extrusion-color":{type:`color`,default:`#000000`,transition:!0,requires:[{"!":`fill-extrusion-pattern`}],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-extrusion-translate":{type:`array`,value:`number`,length:2,default:[0,0],transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"fill-extrusion-translate-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`map`,requires:[`fill-extrusion-translate`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"fill-extrusion-pattern":{type:`resolvedImage`,transition:!0,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`cross-faded-data-driven`},"fill-extrusion-height":{type:`number`,default:0,minimum:0,units:`meters`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-extrusion-base":{type:`number`,default:0,minimum:0,units:`meters`,transition:!0,requires:[`fill-extrusion-height`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-extrusion-vertical-gradient":{type:`boolean`,default:!0,transition:!1,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`}},paint_line:{"line-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"line-color":{type:`color`,default:`#000000`,transition:!0,requires:[{"!":`line-pattern`}],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"line-translate":{type:`array`,value:`number`,length:2,default:[0,0],transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"line-translate-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`map`,requires:[`line-translate`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"line-width":{type:`number`,default:1,minimum:0,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"line-gap-width":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"line-offset":{type:`number`,default:0,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"line-blur":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"line-dasharray":{type:`array`,value:`number`,minimum:0,transition:!0,units:`line widths`,requires:[{"!":`line-pattern`}],expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`cross-faded-data-driven`},"line-pattern":{type:`resolvedImage`,transition:!0,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`cross-faded-data-driven`},"line-gradient":{type:`color`,transition:!1,requires:[{"!":`line-dasharray`},{"!":`line-pattern`},{source:`geojson`,has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:[`line-progress`]},"property-type":`color-ramp`}},paint_circle:{"circle-radius":{type:`number`,default:5,minimum:0,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"circle-color":{type:`color`,default:`#000000`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"circle-blur":{type:`number`,default:0,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"circle-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"circle-translate":{type:`array`,value:`number`,length:2,default:[0,0],transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"circle-translate-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`map`,requires:[`circle-translate`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"circle-pitch-scale":{type:`enum`,values:{map:{},viewport:{}},default:`map`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"circle-pitch-alignment":{type:`enum`,values:{map:{},viewport:{}},default:`viewport`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"circle-stroke-width":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"circle-stroke-color":{type:`color`,default:`#000000`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"circle-stroke-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`}},paint_heatmap:{"heatmap-radius":{type:`number`,default:30,minimum:1,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"heatmap-weight":{type:`number`,default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"heatmap-intensity":{type:`number`,default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"heatmap-color":{type:`color`,default:[`interpolate`,[`linear`],[`heatmap-density`],0,`rgba(0, 0, 255, 0)`,.1,`royalblue`,.3,`cyan`,.5,`lime`,.7,`yellow`,1,`red`],transition:!1,expression:{interpolated:!0,parameters:[`heatmap-density`]},"property-type":`color-ramp`},"heatmap-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`}},paint_symbol:{"icon-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"icon-color":{type:`color`,default:`#000000`,transition:!0,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"icon-halo-color":{type:`color`,default:`rgba(0, 0, 0, 0)`,transition:!0,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"icon-halo-width":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"icon-halo-blur":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"icon-translate":{type:`array`,value:`number`,length:2,default:[0,0],transition:!0,units:`pixels`,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"icon-translate-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`map`,requires:[`icon-image`,`icon-translate`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"text-color":{type:`color`,default:`#000000`,transition:!0,overridable:!0,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"text-halo-color":{type:`color`,default:`rgba(0, 0, 0, 0)`,transition:!0,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"text-halo-width":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"text-halo-blur":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"text-translate":{type:`array`,value:`number`,length:2,default:[0,0],transition:!0,units:`pixels`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"text-translate-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`map`,requires:[`text-field`,`text-translate`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`}},paint_raster:{"raster-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"raster-hue-rotate":{type:`number`,default:0,period:360,transition:!0,units:`degrees`,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"raster-brightness-min":{type:`number`,default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"raster-brightness-max":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"raster-saturation":{type:`number`,default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"raster-contrast":{type:`number`,default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},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`}]}}}}};let He=[`type`,`source`,`source-layer`,`minzoom`,`maxzoom`,`filter`,`layout`];function Ue(e,t){let n={};for(let t in e)t!==`ref`&&(n[t]=e[t]);return He.forEach((e=>{e in t&&(n[e]=t[e])})),n}function N(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!N(e[n],t[n]))return!1;return!0}if(typeof e==`object`&&e&&t!==null){if(typeof t!=`object`||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(!N(e[n],t[n]))return!1;return!0}return e===t}function P(e,t){e.push(t)}function We(e,t,n){P(n,{command:`addSource`,args:[e,t[e]]})}function Ge(e,t,n){P(t,{command:`removeSource`,args:[e]}),n[e]=!0}function Ke(e,t,n,r){Ge(e,n,r),We(e,t,n)}function qe(e,t,n){let r;for(r in e[n])if(Object.prototype.hasOwnProperty.call(e[n],r)&&r!==`data`&&!N(e[n][r],t[n][r]))return!1;for(r in t[n])if(Object.prototype.hasOwnProperty.call(t[n],r)&&r!==`data`&&!N(e[n][r],t[n][r]))return!1;return!0}function Je(e,t,n,r,i,a){e||={},t||={};for(let o in e)Object.prototype.hasOwnProperty.call(e,o)&&(N(e[o],t[o])||n.push({command:a,args:[r,o,t[o],i]}));for(let o in t)Object.prototype.hasOwnProperty.call(t,o)&&!Object.prototype.hasOwnProperty.call(e,o)&&(N(e[o],t[o])||n.push({command:a,args:[r,o,t[o],i]}))}function Ye(e){return e.id}function Xe(e,t){return e[t.id]=t,e}class F{constructor(e,t,n,r){this.message=(e?`${e}: `:``)+n,r&&(this.identifier=r),t!=null&&t.__line__&&(this.line=t.__line__)}}function Ze(e,...t){for(let n of t)for(let t in n)e[t]=n[t];return e}class Qe extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}class $e{constructor(e,t=[]){this.parent=e,this.bindings={};for(let[e,n]of t)this.bindings[e]=n}concat(e){return new $e(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}let et={kind:`null`},I={kind:`number`},tt={kind:`string`},nt={kind:`boolean`},rt={kind:`color`},it={kind:`projectionDefinition`},at={kind:`object`},ot={kind:`value`},st={kind:`collator`},ct={kind:`formatted`},lt={kind:`padding`},ut={kind:`colorArray`},dt={kind:`numberArray`},ft={kind:`resolvedImage`},pt={kind:`variableAnchorOffsetCollection`};function mt(e,t){return{kind:`array`,itemType:e,N:t}}function ht(e){if(e.kind===`array`){let t=ht(e.itemType);return typeof e.N==`number`?`array<${t}, ${e.N}>`:e.itemType.kind===`value`?`array`:`array<${t}>`}return e.kind}let gt=[et,I,tt,nt,rt,it,ct,at,mt(ot),lt,dt,ut,ft,pt];function _t(e,t){if(t.kind===`error`)return null;if(e.kind===`array`){if(t.kind===`array`&&(t.N===0&&t.itemType.kind===`value`||!_t(e.itemType,t.itemType))&&(typeof e.N!=`number`||e.N===t.N))return null}else{if(e.kind===t.kind)return null;if(e.kind===`value`){for(let e of gt)if(!_t(e,t))return null}}return`Expected ${ht(e)} but found ${ht(t)} instead.`}function vt(e,t){return t.some((t=>t.kind===e.kind))}function yt(e,t){return t.some((t=>t===`null`?e===null:t===`array`?Array.isArray(e):t===`object`?e&&!Array.isArray(e)&&typeof e==`object`:t===typeof e))}function bt(e,t){return e.kind===`array`&&t.kind===`array`?e.itemType.kind===t.itemType.kind&&typeof e.N==`number`:e.kind===t.kind}let xt=.96422,St=.82521,Ct=4/29,wt=6/29,Tt=3*wt*wt,Et=Math.PI/180,Dt=180/Math.PI;function R(e){return(e%=360)<0&&(e+=360),e}function Ot([e,t,n,r]){let i,a,o=At((.2225045*(e=kt(e))+.7168786*(t=kt(t))+.0606169*(n=kt(n)))/1);e===t&&t===n?i=a=o:(i=At((.4360747*e+.3850649*t+.1430804*n)/xt),a=At((.0139322*e+.0971045*t+.7141733*n)/St));let s=116*o-16;return[s<0?0:s,500*(i-o),200*(o-a),r]}function kt(e){return e<=.04045?e/12.92:((e+.055)/1.055)**2.4}function At(e){return e>.008856451679035631?e**(1/3):e/Tt+Ct}function jt([e,t,n,r]){let i=(e+16)/116,a=isNaN(t)?i:i+t/500,o=isNaN(n)?i:i-n/200;return i=1*Nt(i),a=xt*Nt(a),o=St*Nt(o),[Mt(3.1338561*a-1.6168667*i-.4906146*o),Mt(-.9787684*a+1.9161415*i+.033454*o),Mt(.0719453*a-.2289914*i+1.4052427*o),r]}function Mt(e){return(e=e<=.00304?12.92*e:1.055*e**(1/2.4)-.055)<0?0:e>1?1:e}function Nt(e){return e>wt?e*e*e:Tt*(e-Ct)}let Pt=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};function Ft(e,t){return Pt(e,t)?e[t]:void 0}function It(e){return parseInt(e.padEnd(2,e),16)/255}function Lt(e,t){return Rt(t?e/100:e,0,1)}function Rt(e,t,n){return Math.min(Math.max(t,e),n)}function zt(e){return!e.some(Number.isNaN)}let Bt={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 Vt(e,t,n){return e+n*(t-e)}function Ht(e,t,n){return e.map(((e,r)=>Vt(e,t[r],n)))}class Ut{constructor(e,t,n,r=1,i=!0){this.r=e,this.g=t,this.b=n,this.a=r,i||(this.r*=r,this.g*=r,this.b*=r,r||this.overwriteGetter(`rgb`,[e,t,n,r]))}static parse(e){if(e instanceof Ut)return e;if(typeof e!=`string`)return;let t=function(e){if((e=e.toLowerCase().trim())===`transparent`)return[0,0,0,0];let t=Ft(Bt,e);if(t){let[e,n,r]=t;return[e/255,n/255,r/255,1]}if(e.startsWith(`#`)&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e)){let t=e.length<6?1:2,n=1;return[It(e.slice(n,n+=t)),It(e.slice(n,n+=t)),It(e.slice(n,n+=t)),It(e.slice(n,n+t)||`ff`)]}if(e.startsWith(`rgb`)){let t=e.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(t){let[e,n,r,i,a,o,s,c,l,u,d,f]=t,p=[i||` `,s||` `,u].join(``);if(p===` `||p===` /`||p===`,,`||p===`,,,`){let e=[r,o,l].join(``),t=e===`%%%`?100:e===``?255:0;if(t){let e=[Rt(+n/t,0,1),Rt(+a/t,0,1),Rt(+c/t,0,1),d?Lt(+d,f):1];if(zt(e))return e}}return}}let n=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(n){let[e,t,r,i,a,o,s,c,l]=n,u=[r||` `,a||` `,s].join(``);if(u===` `||u===` /`||u===`,,`||u===`,,,`){let e=[+t,Rt(+i,0,100),Rt(+o,0,100),c?Lt(+c,l):1];if(zt(e))return function([e,t,n,r]){function i(r){let i=(r+e/30)%12,a=t*Math.min(n,1-n);return n-a*Math.max(-1,Math.min(i-3,9-i,1))}return e=R(e),t/=100,n/=100,[i(0),i(8),i(4),r]}(e)}}}(e);return t?new Ut(...t,!1):void 0}get rgb(){let{r:e,g:t,b:n,a:r}=this,i=r||1/0;return this.overwriteGetter(`rgb`,[e/i,t/i,n/i,r])}get hcl(){return this.overwriteGetter(`hcl`,function(e){let[t,n,r,i]=Ot(e),a=Math.sqrt(n*n+r*r);return[Math.round(1e4*a)?R(Math.atan2(r,n)*Dt):NaN,a,t,i]}(this.rgb))}get lab(){return this.overwriteGetter(`lab`,Ot(this.rgb))}overwriteGetter(e,t){return Object.defineProperty(this,e,{value:t}),t}toString(){let[e,t,n,r]=this.rgb;return`rgba(${[e,t,n].map((e=>Math.round(255*e))).join(`,`)},${r})`}static interpolate(e,t,n,r=`rgb`){switch(r){case`rgb`:{let[r,i,a,o]=Ht(e.rgb,t.rgb,n);return new Ut(r,i,a,o,!1)}case`hcl`:{let[r,i,a,o]=e.hcl,[s,c,l,u]=t.hcl,d,f;if(isNaN(r)||isNaN(s))isNaN(r)?isNaN(s)?d=NaN:(d=s,a!==1&&a!==0||(f=c)):(d=r,l!==1&&l!==0||(f=i));else{let e=s-r;s>r&&e>180?e-=360:s<r&&r-s>180&&(e+=360),d=r+n*e}let[p,m,h,g]=function([e,t,n,r]){return e=isNaN(e)?0:e*Et,jt([n,Math.cos(e)*t,Math.sin(e)*t,r])}([d,f??Vt(i,c,n),Vt(a,l,n),Vt(o,u,n)]);return new Ut(p,m,h,g,!1)}case`lab`:{let[r,i,a,o]=jt(Ht(e.lab,t.lab,n));return new Ut(r,i,a,o,!1)}}}}Ut.black=new Ut(0,0,0,1),Ut.white=new Ut(1,1,1,1),Ut.transparent=new Ut(0,0,0,0),Ut.red=new Ut(1,0,0,1);class Wt{constructor(e,t,n){this.sensitivity=e?t?`variant`:`case`:t?`accent`:`base`,this.locale=n,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:`search`})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}let Gt=[`bottom`,`center`,`top`];class Kt{constructor(e,t,n,r,i,a){this.text=e,this.image=t,this.scale=n,this.fontStack=r,this.textColor=i,this.verticalAlign=a}}class qt{constructor(e){this.sections=e}static fromString(e){return new qt([new Kt(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 qt?e:qt.fromString(e)}toString(){return this.sections.length===0?``:this.sections.map((e=>e.text)).join(``)}}class Jt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Jt)return e;if(typeof e==`number`)return new Jt([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(let t of e)if(typeof t!=`number`)return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new Jt(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,n){return new Jt(Ht(e.values,t.values,n))}}class Yt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Yt)return e;if(typeof e==`number`)return new Yt([e]);if(Array.isArray(e)){for(let t of e)if(typeof t!=`number`)return;return new Yt(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,n){return new Yt(Ht(e.values,t.values,n))}}class Xt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Xt)return e;if(typeof e==`string`){let t=Ut.parse(e);return t?new Xt([t]):void 0}if(!Array.isArray(e))return;let t=[];for(let n of e){if(typeof n!=`string`)return;let e=Ut.parse(n);if(!e)return;t.push(e)}return new Xt(t)}toString(){return JSON.stringify(this.values)}static interpolate(e,t,n,r=`rgb`){let i=[];if(e.values.length!=t.values.length)throw Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${t.values.length}), cannot interpolate.`);for(let a=0;a<e.values.length;a++)i.push(Ut.interpolate(e.values[a],t.values[a],n,r));return new Xt(i)}}class Zt extends Error{constructor(e){super(e),this.name=`RuntimeError`}toJSON(){return this.message}}let Qt=new Set([`center`,`left`,`right`,`top`,`bottom`,`top-left`,`top-right`,`bottom-left`,`bottom-right`]);class $t{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof $t)return e;if(Array.isArray(e)&&!(e.length<1)&&e.length%2==0){for(let t=0;t<e.length;t+=2){let n=e[t],r=e[t+1];if(typeof n!=`string`||!Qt.has(n)||!Array.isArray(r)||r.length!==2||typeof r[0]!=`number`||typeof r[1]!=`number`)return}return new $t(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,n){let r=e.values,i=t.values;if(r.length!==i.length)throw new Zt(`Cannot interpolate values of different length. from: ${e.toString()}, to: ${t.toString()}`);let a=[];for(let e=0;e<r.length;e+=2){if(r[e]!==i[e])throw new Zt(`Cannot interpolate values containing mismatched anchors. from[${e}]: ${r[e]}, to[${e}]: ${i[e]}`);a.push(r[e]);let[t,o]=r[e+1],[s,c]=i[e+1];a.push([Vt(t,s,n),Vt(o,c,n)])}return new $t(a)}}class en{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new en({name:e,available:!1}):null}}class tn{constructor(e,t,n){this.from=e,this.to=t,this.transition=n}static interpolate(e,t,n){return new tn(e,t,n)}static parse(e){return e instanceof tn?e:Array.isArray(e)&&e.length===3&&typeof e[0]==`string`&&typeof e[1]==`string`&&typeof e[2]==`number`?new tn(e[0],e[1],e[2]):typeof e==`object`&&typeof e.from==`string`&&typeof e.to==`string`&&typeof e.transition==`number`?new tn(e.from,e.to,e.transition):typeof e==`string`?new tn(e,e,1):void 0}}function nn(e,t,n,r){return typeof e==`number`&&e>=0&&e<=255&&typeof t==`number`&&t>=0&&t<=255&&typeof n==`number`&&n>=0&&n<=255?r===void 0||typeof r==`number`&&r>=0&&r<=1?null:`Invalid rgba value [${[e,t,n,r].join(`, `)}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof r==`number`?[e,t,n,r]:[e,t,n]).join(`, `)}]: 'r', 'g', and 'b' must be between 0 and 255.`}function rn(e){if(e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`||e instanceof tn||e instanceof Ut||e instanceof Wt||e instanceof qt||e instanceof Jt||e instanceof Yt||e instanceof Xt||e instanceof $t||e instanceof en)return!0;if(Array.isArray(e)){for(let t of e)if(!rn(t))return!1;return!0}if(typeof e==`object`){for(let t in e)if(!rn(e[t]))return!1;return!0}return!1}function an(e){if(e===null)return et;if(typeof e==`string`)return tt;if(typeof e==`boolean`)return nt;if(typeof e==`number`)return I;if(e instanceof Ut)return rt;if(e instanceof tn)return it;if(e instanceof Wt)return st;if(e instanceof qt)return ct;if(e instanceof Jt)return lt;if(e instanceof Yt)return dt;if(e instanceof Xt)return ut;if(e instanceof $t)return pt;if(e instanceof en)return ft;if(Array.isArray(e)){let t=e.length,n;for(let t of e){let e=an(t);if(n){if(n===e)continue;n=ot;break}n=e}return mt(n||ot,t)}return at}function on(e){let t=typeof e;return e===null?``:t===`string`||t===`number`||t===`boolean`?String(e):e instanceof Ut||e instanceof tn||e instanceof qt||e instanceof Jt||e instanceof Yt||e instanceof Xt||e instanceof $t||e instanceof en?e.toString():JSON.stringify(e)}class z{constructor(e,t){this.type=e,this.value=t}static parse(e,t){if(e.length!==2)return t.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!rn(e[1]))return t.error(`invalid value`);let n=e[1],r=an(n),i=t.expectedType;return r.kind!==`array`||r.N!==0||!i||i.kind!==`array`||typeof i.N==`number`&&i.N!==0||(r=i),new z(r,n)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}let sn={string:tt,number:I,boolean:nt,object:at};class B{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error(`Expected at least one argument.`);let n,r=1,i=e[0];if(i===`array`){let i,a;if(e.length>2){let n=e[1];if(typeof n!=`string`||!(n in sn)||n===`object`)return t.error(`The item type argument of "array" must be one of string, number, boolean`,1);i=sn[n],r++}else i=ot;if(e.length>3){if(e[2]!==null&&(typeof e[2]!=`number`||e[2]<0||e[2]!==Math.floor(e[2])))return t.error(`The length argument to "array" must be a positive integer literal`,2);a=e[2],r++}n=mt(i,a)}else{if(!sn[i])throw Error(`Types doesn't contain name = ${i}`);n=sn[i]}let a=[];for(;r<e.length;r++){let n=t.parse(e[r],r,ot);if(!n)return null;a.push(n)}return new B(n,a)}evaluate(e){for(let t=0;t<this.args.length;t++){let n=this.args[t].evaluate(e);if(!_t(this.type,an(n)))return n;if(t===this.args.length-1)throw new Zt(`Expected value to be of type ${ht(this.type)}, but found ${ht(an(n))} instead.`)}throw Error()}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}let cn={"to-boolean":nt,"to-color":rt,"to-number":I,"to-string":tt};class ln{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error(`Expected at least one argument.`);let n=e[0];if(!cn[n])throw Error(`Can't parse ${n} as it is not part of the known types`);if((n===`to-boolean`||n===`to-string`)&&e.length!==2)return t.error(`Expected one argument.`);let r=cn[n],i=[];for(let n=1;n<e.length;n++){let r=t.parse(e[n],n,ot);if(!r)return null;i.push(r)}return new ln(r,i)}evaluate(e){switch(this.type.kind){case`boolean`:return!!this.args[0].evaluate(e);case`color`:{let t,n;for(let r of this.args){if(t=r.evaluate(e),n=null,t instanceof Ut)return t;if(typeof t==`string`){let n=e.parseColor(t);if(n)return n}else if(Array.isArray(t)&&(n=t.length<3||t.length>4?`Invalid rgba value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:nn(t[0],t[1],t[2],t[3]),!n))return new Ut(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new Zt(n||`Could not parse color from value '${typeof t==`string`?t:JSON.stringify(t)}'`)}case`padding`:{let t;for(let n of this.args){t=n.evaluate(e);let r=Jt.parse(t);if(r)return r}throw new Zt(`Could not parse padding from value '${typeof t==`string`?t:JSON.stringify(t)}'`)}case`numberArray`:{let t;for(let n of this.args){t=n.evaluate(e);let r=Yt.parse(t);if(r)return r}throw new Zt(`Could not parse numberArray from value '${typeof t==`string`?t:JSON.stringify(t)}'`)}case`colorArray`:{let t;for(let n of this.args){t=n.evaluate(e);let r=Xt.parse(t);if(r)return r}throw new Zt(`Could not parse colorArray from value '${typeof t==`string`?t:JSON.stringify(t)}'`)}case`variableAnchorOffsetCollection`:{let t;for(let n of this.args){t=n.evaluate(e);let r=$t.parse(t);if(r)return r}throw new Zt(`Could not parse variableAnchorOffsetCollection from value '${typeof t==`string`?t:JSON.stringify(t)}'`)}case`number`:{let t=null;for(let n of this.args){if(t=n.evaluate(e),t===null)return 0;let r=Number(t);if(!isNaN(r))return r}throw new Zt(`Could not convert ${JSON.stringify(t)} to number.`)}case`formatted`:return qt.fromString(on(this.args[0].evaluate(e)));case`resolvedImage`:return en.fromString(on(this.args[0].evaluate(e)));case`projectionDefinition`:return this.args[0].evaluate(e);default:return on(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}let un=[`Unknown`,`Point`,`LineString`,`Polygon`];class dn{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`?un[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&`geometry`in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(e){let t=this._parseColorCache.get(e);return t||(t=Ut.parse(e),this._parseColorCache.set(e,t)),t}}class fn{constructor(e,t,n=[],r,i=new $e,a=[]){this.registry=e,this.path=n,this.key=n.map((e=>`[${e}]`)).join(``),this.scope=i,this.errors=a,this.expectedType=r,this._isConstant=t}parse(e,t,n,r,i={}){return t?this.concat(t,n,r)._parse(e,i):this._parse(e,i)}_parse(e,t){function n(e,t,n){return n===`assert`?new B(t,[e]):n===`coerce`?new ln(t,[e]):e}if(e!==null&&typeof e!=`string`&&typeof e!=`boolean`&&typeof e!=`number`||(e=[`literal`,e]),Array.isArray(e)){if(e.length===0)return this.error(`Expected an array with at least one element. If you wanted a literal array, use ["literal", []].`);let r=e[0];if(typeof r!=`string`)return this.error(`Expression name must be a string, but found ${typeof r} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;let i=this.registry[r];if(i){let r=i.parse(e,this);if(!r)return null;if(this.expectedType){let e=this.expectedType,i=r.type;if(e.kind!==`string`&&e.kind!==`number`&&e.kind!==`boolean`&&e.kind!==`object`&&e.kind!==`array`||i.kind!==`value`){if(e.kind===`projectionDefinition`&&[`string`,`array`].includes(i.kind)||[`color`,`formatted`,`resolvedImage`].includes(e.kind)&&[`value`,`string`].includes(i.kind)||[`padding`,`numberArray`].includes(e.kind)&&[`value`,`number`,`array`].includes(i.kind)||e.kind===`colorArray`&&[`value`,`string`,`array`].includes(i.kind)||e.kind===`variableAnchorOffsetCollection`&&[`value`,`array`].includes(i.kind))r=n(r,e,t.typeAnnotation||`coerce`);else if(this.checkSubtype(e,i))return null}else r=n(r,e,t.typeAnnotation||`assert`)}if(!(r instanceof z)&&r.type.kind!==`resolvedImage`&&this._isConstant(r)){let e=new dn;try{r=new z(r.type,r.evaluate(e))}catch(e){return this.error(e.message),null}}return r}return this.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(e===void 0?`'undefined' value invalid. Use null instead.`:typeof e==`object`?`Bare objects invalid. Use ["literal", {...}] instead.`:`Expected an array, but found ${typeof e} instead.`)}concat(e,t,n){let r=typeof e==`number`?this.path.concat(e):this.path,i=n?this.scope.concat(n):this.scope;return new fn(this.registry,this._isConstant,r,t||null,i,this.errors)}error(e,...t){let n=`${this.key}${t.map((e=>`[${e}]`)).join(``)}`;this.errors.push(new Qe(n,e))}checkSubtype(e,t){let n=_t(e,t);return n&&this.error(n),n}}class pn{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(let t of this.bindings)e(t[1]);e(this.result)}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);let n=[];for(let r=1;r<e.length-1;r+=2){let i=e[r];if(typeof i!=`string`)return t.error(`Expected string, but found ${typeof i} instead.`,r);if(/[^a-zA-Z0-9_]/.test(i))return t.error(`Variable names must contain only alphanumeric characters or '_'.`,r);let a=t.parse(e[r+1],r+1);if(!a)return null;n.push([i,a])}let r=t.parse(e[e.length-1],e.length-1,t.expectedType,n);return r?new pn(n,r):null}outputDefined(){return this.result.outputDefined()}}class mn{constructor(e,t){this.type=t.type,this.name=e,this.boundExpression=t}static parse(e,t){if(e.length!==2||typeof e[1]!=`string`)return t.error(`'var' expression requires exactly one string literal argument.`);let n=e[1];return t.scope.has(n)?new mn(n,t.scope.get(n)):t.error(`Unknown variable "${n}". Make sure "${n}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}}class hn{constructor(e,t,n){this.type=e,this.index=t,this.input=n}static parse(e,t){if(e.length!==3)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);let n=t.parse(e[1],1,I),r=t.parse(e[2],2,mt(t.expectedType||ot));return n&&r?new hn(r.type.itemType,n,r):null}evaluate(e){let t=this.index.evaluate(e),n=this.input.evaluate(e);if(t<0)throw new Zt(`Array index out of bounds: ${t} < 0.`);if(t>=n.length)throw new Zt(`Array index out of bounds: ${t} > ${n.length-1}.`);if(t!==Math.floor(t))throw new Zt(`Array index must be an integer, but found ${t} instead.`);return n[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class gn{constructor(e,t){this.type=nt,this.needle=e,this.haystack=t}static parse(e,t){if(e.length!==3)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);let n=t.parse(e[1],1,ot),r=t.parse(e[2],2,ot);return n&&r?vt(n.type,[nt,tt,I,et,ot])?new gn(n,r):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${ht(n.type)} instead`):null}evaluate(e){let t=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(!n)return!1;if(!yt(t,[`boolean`,`string`,`number`,`null`]))throw new Zt(`Expected first argument to be of type boolean, string, number or null, but found ${ht(an(t))} instead.`);if(!yt(n,[`string`,`array`]))throw new Zt(`Expected second argument to be of type array or string, but found ${ht(an(n))} instead.`);return n.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class _n{constructor(e,t,n){this.type=I,this.needle=e,this.haystack=t,this.fromIndex=n}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);let n=t.parse(e[1],1,ot),r=t.parse(e[2],2,ot);if(!n||!r)return null;if(!vt(n.type,[nt,tt,I,et,ot]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${ht(n.type)} instead`);if(e.length===4){let i=t.parse(e[3],3,I);return i?new _n(n,r,i):null}return new _n(n,r)}evaluate(e){let t=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(!yt(t,[`boolean`,`string`,`number`,`null`]))throw new Zt(`Expected first argument to be of type boolean, string, number or null, but found ${ht(an(t))} instead.`);let r;if(this.fromIndex&&(r=this.fromIndex.evaluate(e)),yt(n,[`string`])){let e=n.indexOf(t,r);return e===-1?-1:[...n.slice(0,e)].length}if(yt(n,[`array`]))return n.indexOf(t,r);throw new Zt(`Expected second argument to be of type array or string, but found ${ht(an(n))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class vn{constructor(e,t,n,r,i,a){this.inputType=e,this.type=t,this.input=n,this.cases=r,this.outputs=i,this.otherwise=a}static parse(e,t){if(e.length<5)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return t.error(`Expected an even number of arguments.`);let n,r;t.expectedType&&t.expectedType.kind!==`value`&&(r=t.expectedType);let i={},a=[];for(let o=2;o<e.length-1;o+=2){let s=e[o],c=e[o+1];Array.isArray(s)||(s=[s]);let l=t.concat(o);if(s.length===0)return l.error(`Expected at least one branch label.`);for(let e of s){if(typeof e!=`number`&&typeof e!=`string`)return l.error(`Branch labels must be numbers or strings.`);if(typeof e==`number`&&Math.abs(e)>2**53-1)return l.error(`Branch labels must be integers no larger than ${2**53-1}.`);if(typeof e==`number`&&Math.floor(e)!==e)return l.error(`Numeric branch labels must be integer values.`);if(n){if(l.checkSubtype(n,an(e)))return null}else n=an(e);if(i[String(e)]!==void 0)return l.error(`Branch labels must be unique.`);i[String(e)]=a.length}let u=t.parse(c,o,r);if(!u)return null;r||=u.type,a.push(u)}let o=t.parse(e[1],1,ot);if(!o)return null;let s=t.parse(e[e.length-1],e.length-1,r);return s?o.type.kind!==`value`&&t.concat(1).checkSubtype(n,o.type)?null:new vn(n,r,o,i,a,s):null}evaluate(e){let t=this.input.evaluate(e);return(an(t)===this.inputType&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))&&this.otherwise.outputDefined()}}class yn{constructor(e,t,n){this.type=e,this.branches=t,this.otherwise=n}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return t.error(`Expected an odd number of arguments.`);let n;t.expectedType&&t.expectedType.kind!==`value`&&(n=t.expectedType);let r=[];for(let i=1;i<e.length-1;i+=2){let a=t.parse(e[i],i,nt);if(!a)return null;let o=t.parse(e[i+1],i+1,n);if(!o)return null;r.push([a,o]),n||=o.type}let i=t.parse(e[e.length-1],e.length-1,n);if(!i)return null;if(!n)throw Error(`Can't infer output type`);return new yn(n,r,i)}evaluate(e){for(let[t,n]of this.branches)if(t.evaluate(e))return n.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(let[t,n]of this.branches)e(t),e(n);e(this.otherwise)}outputDefined(){return this.branches.every((([e,t])=>t.outputDefined()))&&this.otherwise.outputDefined()}}class bn{constructor(e,t,n,r){this.type=e,this.input=t,this.beginIndex=n,this.endIndex=r}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);let n=t.parse(e[1],1,ot),r=t.parse(e[2],2,I);if(!n||!r)return null;if(!vt(n.type,[mt(ot),tt,ot]))return t.error(`Expected first argument to be of type array or string, but found ${ht(n.type)} instead`);if(e.length===4){let i=t.parse(e[3],3,I);return i?new bn(n.type,n,r,i):null}return new bn(n.type,n,r)}evaluate(e){let t=this.input.evaluate(e),n=this.beginIndex.evaluate(e),r;if(this.endIndex&&(r=this.endIndex.evaluate(e)),yt(t,[`string`]))return[...t].slice(n,r).join(``);if(yt(t,[`array`]))return t.slice(n,r);throw new Zt(`Expected first argument to be of type array or string, but found ${ht(an(t))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function xn(e,t){let n=e.length-1,r,i,a=0,o=n,s=0;for(;a<=o;)if(s=Math.floor((a+o)/2),r=e[s],i=e[s+1],r<=t){if(s===n||t<i)return s;a=s+1}else{if(!(r>t))throw new Zt(`Input is not a number.`);o=s-1}return 0}class Sn{constructor(e,t,n){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(let[e,t]of n)this.labels.push(e),this.outputs.push(t)}static parse(e,t){if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error(`Expected an even number of arguments.`);let n=t.parse(e[1],1,I);if(!n)return null;let r=[],i=null;t.expectedType&&t.expectedType.kind!==`value`&&(i=t.expectedType);for(let n=1;n<e.length;n+=2){let a=n===1?-1/0:e[n],o=e[n+1],s=n,c=n+1;if(typeof a!=`number`)return t.error(`Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.`,s);if(r.length&&r[r.length-1][0]>=a)return t.error(`Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.`,s);let l=t.parse(o,c,i);if(!l)return null;i||=l.type,r.push([a,l])}return new Sn(i,n,r)}evaluate(e){let t=this.labels,n=this.outputs;if(t.length===1)return n[0].evaluate(e);let r=this.input.evaluate(e);if(r<=t[0])return n[0].evaluate(e);let i=t.length;return r>=t[i-1]?n[i-1].evaluate(e):n[xn(t,r)].evaluate(e)}eachChild(e){e(this.input);for(let t of this.outputs)e(t)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function V(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var Cn,H,wn=V(function(){if(H)return Cn;function e(e,t,n,r){this.cx=3*e,this.bx=3*(n-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(r-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=n,this.p2y=r}return H=1,Cn=e,e.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,t){if(t===void 0&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var n=e,r=0;r<8;r++){var i=this.sampleCurveX(n)-e;if(Math.abs(i)<t)return n;var a=this.sampleCurveDerivativeX(n);if(Math.abs(a)<1e-6)break;n-=i/a}var o=0,s=1;for(n=e,r=0;r<20&&(i=this.sampleCurveX(n),!(Math.abs(i-e)<t));r++)e>i?o=n:s=n,n=.5*(s-o)+o;return n},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},Cn}());class Tn{constructor(e,t,n,r,i){this.type=e,this.operator=t,this.interpolation=n,this.input=r,this.labels=[],this.outputs=[];for(let[e,t]of i)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,n,r){let i=0;if(e.name===`exponential`)i=En(t,e.base,n,r);else if(e.name===`linear`)i=En(t,1,n,r);else if(e.name===`cubic-bezier`){let a=e.controlPoints;i=new wn(a[0],a[1],a[2],a[3]).solve(En(t,1,n,r))}return i}static parse(e,t){let[n,r,i,...a]=e;if(!Array.isArray(r)||r.length===0)return t.error(`Expected an interpolation type expression.`,1);if(r[0]===`linear`)r={name:`linear`};else if(r[0]===`exponential`){let e=r[1];if(typeof e!=`number`)return t.error(`Exponential interpolation requires a numeric base.`,1,1);r={name:`exponential`,base:e}}else{if(r[0]!==`cubic-bezier`)return t.error(`Unknown interpolation type ${String(r[0])}`,1,0);{let e=r.slice(1);if(e.length!==4||e.some((e=>typeof e!=`number`||e<0||e>1)))return t.error(`Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.`,1);r={name:`cubic-bezier`,controlPoints:e}}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error(`Expected an even number of arguments.`);if(i=t.parse(i,2,I),!i)return null;let o=[],s=null;n!==`interpolate-hcl`&&n!==`interpolate-lab`||t.expectedType==ut?t.expectedType&&t.expectedType.kind!==`value`&&(s=t.expectedType):s=rt;for(let e=0;e<a.length;e+=2){let n=a[e],r=a[e+1],i=e+3,c=e+4;if(typeof n!=`number`)return t.error(`Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.`,i);if(o.length&&o[o.length-1][0]>=n)return t.error(`Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.`,i);let l=t.parse(r,c,s);if(!l)return null;s||=l.type,o.push([n,l])}return bt(s,I)||bt(s,it)||bt(s,rt)||bt(s,lt)||bt(s,dt)||bt(s,ut)||bt(s,pt)||bt(s,mt(I))?new Tn(s,n,r,i,o):t.error(`Type ${ht(s)} is not interpolatable.`)}evaluate(e){let t=this.labels,n=this.outputs;if(t.length===1)return n[0].evaluate(e);let r=this.input.evaluate(e);if(r<=t[0])return n[0].evaluate(e);let i=t.length;if(r>=t[i-1])return n[i-1].evaluate(e);let a=xn(t,r),o=Tn.interpolationFactor(this.interpolation,r,t[a],t[a+1]),s=n[a].evaluate(e),c=n[a+1].evaluate(e);switch(this.operator){case`interpolate`:switch(this.type.kind){case`number`:return Vt(s,c,o);case`color`:return Ut.interpolate(s,c,o);case`padding`:return Jt.interpolate(s,c,o);case`colorArray`:return Xt.interpolate(s,c,o);case`numberArray`:return Yt.interpolate(s,c,o);case`variableAnchorOffsetCollection`:return $t.interpolate(s,c,o);case`array`:return Ht(s,c,o);case`projectionDefinition`:return tn.interpolate(s,c,o)}case`interpolate-hcl`:switch(this.type.kind){case`color`:return Ut.interpolate(s,c,o,`hcl`);case`colorArray`:return Xt.interpolate(s,c,o,`hcl`)}case`interpolate-lab`:switch(this.type.kind){case`color`:return Ut.interpolate(s,c,o,`lab`);case`colorArray`:return Xt.interpolate(s,c,o,`lab`)}}}eachChild(e){e(this.input);for(let t of this.outputs)e(t)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function En(e,t,n,r){let i=r-n,a=e-n;return i===0?0:t===1?a/i:(t**+a-1)/(t**+i-1)}let Dn={color:Ut.interpolate,number:Vt,padding:Jt.interpolate,numberArray:Yt.interpolate,colorArray:Xt.interpolate,variableAnchorOffsetCollection:$t.interpolate,array:Ht};class On{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error(`Expected at least one argument.`);let n=null,r=t.expectedType;r&&r.kind!==`value`&&(n=r);let i=[];for(let r of e.slice(1)){let e=t.parse(r,1+i.length,n,void 0,{typeAnnotation:`omit`});if(!e)return null;n||=e.type,i.push(e)}if(!n)throw Error(`No output type`);return new On(r&&i.some((e=>_t(r,e.type)))?ot:n,i)}evaluate(e){let t,n=null,r=0;for(let i of this.args)if(r++,n=i.evaluate(e),n&&n instanceof en&&!n.available&&(t||=n.name,n=null,r===this.args.length&&(n=t)),n!==null)break;return n}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}function kn(e,t){return e===`==`||e===`!=`?t.kind===`boolean`||t.kind===`string`||t.kind===`number`||t.kind===`null`||t.kind===`value`:t.kind===`string`||t.kind===`number`||t.kind===`value`}function An(e,t,n,r){return r.compare(t,n)===0}function jn(e,t,n){let r=e!==`==`&&e!==`!=`;return class i{constructor(e,t,n){this.type=nt,this.lhs=e,this.rhs=t,this.collator=n,this.hasUntypedArgument=e.type.kind===`value`||t.type.kind===`value`}static parse(e,t){if(e.length!==3&&e.length!==4)return t.error(`Expected two or three arguments.`);let n=e[0],a=t.parse(e[1],1,ot);if(!a)return null;if(!kn(n,a.type))return t.concat(1).error(`"${n}" comparisons are not supported for type '${ht(a.type)}'.`);let o=t.parse(e[2],2,ot);if(!o)return null;if(!kn(n,o.type))return t.concat(2).error(`"${n}" comparisons are not supported for type '${ht(o.type)}'.`);if(a.type.kind!==o.type.kind&&a.type.kind!==`value`&&o.type.kind!==`value`)return t.error(`Cannot compare types '${ht(a.type)}' and '${ht(o.type)}'.`);r&&(a.type.kind===`value`&&o.type.kind!==`value`?a=new B(o.type,[a]):a.type.kind!==`value`&&o.type.kind===`value`&&(o=new B(a.type,[o])));let s=null;if(e.length===4){if(a.type.kind!==`string`&&o.type.kind!==`string`&&a.type.kind!==`value`&&o.type.kind!==`value`)return t.error(`Cannot use collator to compare non-string types.`);if(s=t.parse(e[3],3,st),!s)return null}return new i(a,o,s)}evaluate(i){let a=this.lhs.evaluate(i),o=this.rhs.evaluate(i);if(r&&this.hasUntypedArgument){let t=an(a),n=an(o);if(t.kind!==n.kind||t.kind!==`string`&&t.kind!==`number`)throw new Zt(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${n.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){let e=an(a),n=an(o);if(e.kind!==`string`||n.kind!==`string`)return t(i,a,o)}return this.collator?n(i,a,o,this.collator.evaluate(i)):t(i,a,o)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}let Mn=jn(`==`,(function(e,t,n){return t===n}),An),Nn=jn(`!=`,(function(e,t,n){return t!==n}),(function(e,t,n,r){return!An(0,t,n,r)})),Pn=jn(`<`,(function(e,t,n){return t<n}),(function(e,t,n,r){return r.compare(t,n)<0})),Fn=jn(`>`,(function(e,t,n){return t>n}),(function(e,t,n,r){return r.compare(t,n)>0})),In=jn(`<=`,(function(e,t,n){return t<=n}),(function(e,t,n,r){return r.compare(t,n)<=0})),Ln=jn(`>=`,(function(e,t,n){return t>=n}),(function(e,t,n,r){return r.compare(t,n)>=0}));class Rn{constructor(e,t,n){this.type=st,this.locale=n,this.caseSensitive=e,this.diacriticSensitive=t}static parse(e,t){if(e.length!==2)return t.error(`Expected one argument.`);let n=e[1];if(typeof n!=`object`||Array.isArray(n))return t.error(`Collator options argument must be an object.`);let r=t.parse(n[`case-sensitive`]!==void 0&&n[`case-sensitive`],1,nt);if(!r)return null;let i=t.parse(n[`diacritic-sensitive`]!==void 0&&n[`diacritic-sensitive`],1,nt);if(!i)return null;let a=null;return n.locale&&(a=t.parse(n.locale,1,tt),!a)?null:new Rn(r,i,a)}evaluate(e){return new Wt(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}}class zn{constructor(e,t,n,r,i,a){this.type=tt,this.number=e,this.locale=t,this.currency=n,this.unit=r,this.minFractionDigits=i,this.maxFractionDigits=a}static parse(e,t){if(e.length!==3)return t.error(`Expected two arguments.`);let n=t.parse(e[1],1,I);if(!n)return null;let r=e[2];if(typeof r!=`object`||Array.isArray(r))return t.error(`NumberFormat options argument must be an object.`);let i=null;if(r.locale&&(i=t.parse(r.locale,1,tt),!i))return null;let a=null;if(r.currency&&(a=t.parse(r.currency,1,tt),!a))return null;let o=null;if(r.unit&&(o=t.parse(r.unit,1,tt),!o))return null;if(a&&o)return t.error("NumberFormat options `currency` and `unit` are mutually exclusive");let s=null;if(r[`min-fraction-digits`]&&(s=t.parse(r[`min-fraction-digits`],1,I),!s))return null;let c=null;return r[`max-fraction-digits`]&&(c=t.parse(r[`max-fraction-digits`],1,I),!c)?null:new zn(n,i,a,o,s,c)}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}}class Bn{constructor(e){this.type=ct,this.sections=e}static parse(e,t){if(e.length<2)return t.error(`Expected at least one argument.`);let n=e[1];if(!Array.isArray(n)&&typeof n==`object`)return t.error(`First argument must be an image or text section.`);let r=[],i=!1;for(let n=1;n<=e.length-1;++n){let a=e[n];if(i&&typeof a==`object`&&!Array.isArray(a)){i=!1;let e=null;if(a[`font-scale`]&&(e=t.parse(a[`font-scale`],1,I),!e))return null;let n=null;if(a[`text-font`]&&(n=t.parse(a[`text-font`],1,mt(tt)),!n))return null;let o=null;if(a[`text-color`]&&(o=t.parse(a[`text-color`],1,rt),!o))return null;let s=null;if(a[`vertical-align`]){if(typeof a[`vertical-align`]==`string`&&!Gt.includes(a[`vertical-align`]))return t.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${a[`vertical-align`]}' instead.`);if(s=t.parse(a[`vertical-align`],1,tt),!s)return null}let c=r[r.length-1];c.scale=e,c.font=n,c.textColor=o,c.verticalAlign=s}else{let a=t.parse(e[n],1,ot);if(!a)return null;let o=a.type.kind;if(o!==`string`&&o!==`value`&&o!==`null`&&o!==`resolvedImage`)return t.error(`Formatted text type must be 'string', 'value', 'image' or 'null'.`);i=!0,r.push({content:a,scale:null,font:null,textColor:null,verticalAlign:null})}}return new Bn(r)}evaluate(e){return new qt(this.sections.map((t=>{let n=t.content.evaluate(e);return an(n)===ft?new Kt(``,n,null,null,null,t.verticalAlign?t.verticalAlign.evaluate(e):null):new Kt(on(n),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(`,`):null,t.textColor?t.textColor.evaluate(e):null,t.verticalAlign?t.verticalAlign.evaluate(e):null)})))}eachChild(e){for(let t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor),t.verticalAlign&&e(t.verticalAlign)}outputDefined(){return!1}}class Vn{constructor(e){this.type=ft,this.input=e}static parse(e,t){if(e.length!==2)return t.error(`Expected two arguments.`);let n=t.parse(e[1],1,tt);return n?new Vn(n):t.error(`No image name provided.`)}evaluate(e){let t=this.input.evaluate(e),n=en.fromString(t);return n&&e.availableImages&&(n.available=e.availableImages.indexOf(t)>-1),n}eachChild(e){e(this.input)}outputDefined(){return!1}}class Hn{constructor(e){this.type=I,this.input=e}static parse(e,t){if(e.length!==2)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);let n=t.parse(e[1],1);return n?n.type.kind!==`array`&&n.type.kind!==`string`&&n.type.kind!==`value`?t.error(`Expected argument of type string or array, but found ${ht(n.type)} instead.`):new Hn(n):null}evaluate(e){let t=this.input.evaluate(e);if(typeof t==`string`)return[...t].length;if(Array.isArray(t))return t.length;throw new Zt(`Expected value to be of type string or array, but found ${ht(an(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}let Un=8192;function Wn(e,t){let n=(180+e[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,i=2**t.z;return[Math.round(n*i*Un),Math.round(r*i*Un)]}function U(e,t){let n=2**t.z;return[(i=(e[0]/Un+t.x)/n,360*i-180),(r=(e[1]/Un+t.y)/n,360/Math.PI*Math.atan(Math.exp((180-360*r)*Math.PI/180))-90)];var r,i}function Gn(e,t){e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.max(e[2],t[0]),e[3]=Math.max(e[3],t[1])}function Kn(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function qn(e,t,n){let r=e[0]-t[0],i=e[1]-t[1],a=e[0]-n[0],o=e[1]-n[1];return r*o-a*i==0&&r*a<=0&&i*o<=0}function Jn(e,t,n,r){return(i=[r[0]-n[0],r[1]-n[1]])[0]*(a=[t[0]-e[0],t[1]-e[1]])[1]-i[1]*a[0]!=0&&!(!er(e,t,n,r)||!er(n,r,e,t));var i,a}function Yn(e,t,n){for(let r of n)for(let n=0;n<r.length-1;++n)if(Jn(e,t,r[n],r[n+1]))return!0;return!1}function Xn(e,t,n=!1){let r=!1;for(let s of t)for(let t=0;t<s.length-1;t++){if(qn(e,s[t],s[t+1]))return n;(a=s[t])[1]>(i=e)[1]!=(o=s[t+1])[1]>i[1]&&i[0]<(o[0]-a[0])*(i[1]-a[1])/(o[1]-a[1])+a[0]&&(r=!r)}var i,a,o;return r}function Zn(e,t){for(let n of t)if(Xn(e,n))return!0;return!1}function Qn(e,t){for(let n of e)if(!Xn(n,t))return!1;for(let n=0;n<e.length-1;++n)if(Yn(e[n],e[n+1],t))return!1;return!0}function $n(e,t){for(let n of t)if(Qn(e,n))return!0;return!1}function er(e,t,n,r){let i=r[0]-n[0],a=r[1]-n[1],o=(e[0]-n[0])*a-i*(e[1]-n[1]),s=(t[0]-n[0])*a-i*(t[1]-n[1]);return o>0&&s<0||o<0&&s>0}function tr(e,t,n){let r=[];for(let i=0;i<e.length;i++){let a=[];for(let r=0;r<e[i].length;r++){let o=Wn(e[i][r],n);Gn(t,o),a.push(o)}r.push(a)}return r}function nr(e,t,n){let r=[];for(let i=0;i<e.length;i++){let a=tr(e[i],t,n);r.push(a)}return r}function rr(e,t,n,r){if(e[0]<n[0]||e[0]>n[2]){let t=.5*r,i=e[0]-n[0]>t?-r:n[0]-e[0]>t?r:0;i===0&&(i=e[0]-n[2]>t?-r:n[2]-e[0]>t?r:0),e[0]+=i}Gn(t,e)}function ir(e,t,n,r){let i=2**r.z*Un,a=[r.x*Un,r.y*Un],o=[];for(let r of e)for(let e of r){let r=[e.x+a[0],e.y+a[1]];rr(r,t,n,i),o.push(r)}return o}function ar(e,t,n,r){let i=2**r.z*Un,a=[r.x*Un,r.y*Un],o=[];for(let n of e){let e=[];for(let r of n){let n=[r.x+a[0],r.y+a[1]];Gn(t,n),e.push(n)}o.push(e)}if(t[2]-t[0]<=i/2){(s=t)[0]=s[1]=1/0,s[2]=s[3]=-1/0;for(let e of o)for(let r of e)rr(r,t,n,i)}var s;return o}class or{constructor(e,t){this.type=nt,this.geojson=e,this.geometries=t}static parse(e,t){if(e.length!==2)return t.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(rn(e[1])){let t=e[1];if(t.type===`FeatureCollection`){let e=[];for(let n of t.features){let{type:t,coordinates:r}=n.geometry;t===`Polygon`&&e.push(r),t===`MultiPolygon`&&e.push(...r)}if(e.length)return new or(t,{type:`MultiPolygon`,coordinates:e})}else if(t.type===`Feature`){let e=t.geometry.type;if(e===`Polygon`||e===`MultiPolygon`)return new or(t,t.geometry)}else if(t.type===`Polygon`||t.type===`MultiPolygon`)return new or(t,t)}return t.error(`'within' expression requires valid geojson object that contains polygon geometry type.`)}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()===`Point`)return function(e,t){let n=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],i=e.canonicalID();if(t.type===`Polygon`){let a=tr(t.coordinates,r,i),o=ir(e.geometry(),n,r,i);if(!Kn(n,r))return!1;for(let e of o)if(!Xn(e,a))return!1}if(t.type===`MultiPolygon`){let a=nr(t.coordinates,r,i),o=ir(e.geometry(),n,r,i);if(!Kn(n,r))return!1;for(let e of o)if(!Zn(e,a))return!1}return!0}(e,this.geometries);if(e.geometryType()===`LineString`)return function(e,t){let n=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],i=e.canonicalID();if(t.type===`Polygon`){let a=tr(t.coordinates,r,i),o=ar(e.geometry(),n,r,i);if(!Kn(n,r))return!1;for(let e of o)if(!Qn(e,a))return!1}if(t.type===`MultiPolygon`){let a=nr(t.coordinates,r,i),o=ar(e.geometry(),n,r,i);if(!Kn(n,r))return!1;for(let e of o)if(!$n(e,a))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let sr=class{constructor(e=[],t=(e,t)=>e<t?-1:+(e>t)){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;let e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){let{data:t,compare:n}=this,r=t[e];for(;e>0;){let i=e-1>>1,a=t[i];if(n(r,a)>=0)break;t[e]=a,e=i}t[e]=r}_down(e){let{data:t,compare:n}=this,r=this.length>>1,i=t[e];for(;e<r;){let r=1+(e<<1),a=r+1;if(a<this.length&&n(t[a],t[r])<0&&(r=a),n(t[r],i)>=0)break;t[e]=t[r],e=r}t[e]=i}};function cr(e,t,n=0,r=e.length-1,i=ur){for(;r>n;){if(r-n>600){let a=r-n+1,o=t-n+1,s=Math.log(a),c=.5*Math.exp(2*s/3),l=.5*Math.sqrt(s*c*(a-c)/a)*(o-a/2<0?-1:1);cr(e,t,Math.max(n,Math.floor(t-o*c/a+l)),Math.min(r,Math.floor(t+(a-o)*c/a+l)),i)}let a=e[t],o=n,s=r;for(lr(e,n,t),i(e[r],a)>0&&lr(e,n,r);o<s;){for(lr(e,o,s),o++,s--;i(e[o],a)<0;)o++;for(;i(e[s],a)>0;)s--}i(e[n],a)===0?lr(e,n,s):(s++,lr(e,s,r)),s<=t&&(n=s+1),t<=s&&(r=s-1)}}function lr(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function ur(e,t){return e<t?-1:+(e>t)}function dr(e,t){if(e.length<=1)return[e];let n=[],r,i;for(let t of e){let e=pr(t);e!==0&&(t.area=Math.abs(e),i===void 0&&(i=e<0),i===e<0?(r&&n.push(r),r=[t]):r.push(t))}if(r&&n.push(r),t>1)for(let e=0;e<n.length;e++)n[e].length<=t||(cr(n[e],t,1,n[e].length-1,fr),n[e]=n[e].slice(0,t));return n}function fr(e,t){return t.area-e.area}function pr(e){let t=0;for(let n,r,i=0,a=e.length,o=a-1;i<a;o=i++)n=e[i],r=e[o],t+=(r.x-n.x)*(n.y+r.y);return t}let mr=1/298.257223563,hr=mr*(2-mr),gr=Math.PI/180;class _r{constructor(e){let t=6378.137*gr*1e3,n=Math.cos(e*gr),r=1/(1-hr*(1-n*n)),i=Math.sqrt(r);this.kx=t*i*n,this.ky=t*i*r*(1-hr)}distance(e,t){let n=this.wrap(e[0]-t[0])*this.kx,r=(e[1]-t[1])*this.ky;return Math.sqrt(n*n+r*r)}pointOnLine(e,t){let n,r,i,a,o=1/0;for(let s=0;s<e.length-1;s++){let c=e[s][0],l=e[s][1],u=this.wrap(e[s+1][0]-c)*this.kx,d=(e[s+1][1]-l)*this.ky,f=0;u===0&&d===0||(f=(this.wrap(t[0]-c)*this.kx*u+(t[1]-l)*this.ky*d)/(u*u+d*d),f>1?(c=e[s+1][0],l=e[s+1][1]):f>0&&(c+=u/this.kx*f,l+=d/this.ky*f)),u=this.wrap(t[0]-c)*this.kx,d=(t[1]-l)*this.ky;let p=u*u+d*d;p<o&&(o=p,n=c,r=l,i=s,a=f)}return{point:[n,r],index:i,t:Math.max(0,Math.min(1,a))}}wrap(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}}function vr(e,t){return t[0]-e[0]}function yr(e){return e[1]-e[0]+1}function br(e,t){return e[1]>=e[0]&&e[1]<t}function xr(e,t){if(e[0]>e[1])return[null,null];let n=yr(e);if(t){if(n===2)return[e,null];let t=Math.floor(n/2);return[[e[0],e[0]+t],[e[0]+t,e[1]]]}if(n===1)return[e,null];let r=Math.floor(n/2)-1;return[[e[0],e[0]+r],[e[0]+r+1,e[1]]]}function Sr(e,t){if(!br(t,e.length))return[1/0,1/0,-1/0,-1/0];let n=[1/0,1/0,-1/0,-1/0];for(let r=t[0];r<=t[1];++r)Gn(n,e[r]);return n}function Cr(e){let t=[1/0,1/0,-1/0,-1/0];for(let n of e)for(let e of n)Gn(t,e);return t}function wr(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function Tr(e,t,n){if(!wr(e)||!wr(t))return NaN;let r=0,i=0;return e[2]<t[0]&&(r=t[0]-e[2]),e[0]>t[2]&&(r=e[0]-t[2]),e[1]>t[3]&&(i=e[1]-t[3]),e[3]<t[1]&&(i=t[1]-e[3]),n.distance([0,0],[r,i])}function Er(e,t,n){let r=n.pointOnLine(t,e);return n.distance(e,r.point)}function Dr(e,t,n,r,i){let a=Math.min(Er(e,[n,r],i),Er(t,[n,r],i)),o=Math.min(Er(n,[e,t],i),Er(r,[e,t],i));return Math.min(a,o)}function Or(e,t,n,r,i){if(!br(t,e.length)||!br(r,n.length))return 1/0;let a=1/0;for(let o=t[0];o<t[1];++o){let t=e[o],s=e[o+1];for(let e=r[0];e<r[1];++e){let r=n[e],o=n[e+1];if(Jn(t,s,r,o))return 0;a=Math.min(a,Dr(t,s,r,o,i))}}return a}function kr(e,t,n,r,i){if(!br(t,e.length)||!br(r,n.length))return NaN;let a=1/0;for(let o=t[0];o<=t[1];++o)for(let t=r[0];t<=r[1];++t)if(a=Math.min(a,i.distance(e[o],n[t])),a===0)return a;return a}function Ar(e,t,n){if(Xn(e,t,!0))return 0;let r=1/0;for(let i of t){let t=i[0],a=i[i.length-1];if(t!==a&&(r=Math.min(r,Er(e,[a,t],n)),r===0))return r;let o=n.pointOnLine(i,e);if(r=Math.min(r,n.distance(e,o.point)),r===0)return r}return r}function jr(e,t,n,r){if(!br(t,e.length))return NaN;for(let r=t[0];r<=t[1];++r)if(Xn(e[r],n,!0))return 0;let i=1/0;for(let a=t[0];a<t[1];++a){let t=e[a],o=e[a+1];for(let e of n)for(let n=0,a=e.length,s=a-1;n<a;s=n++){let a=e[s],c=e[n];if(Jn(t,o,a,c))return 0;i=Math.min(i,Dr(t,o,a,c,r))}}return i}function W(e,t){for(let n of e)for(let e of n)if(Xn(e,t,!0))return!0;return!1}function Mr(e,t,n,r=1/0){let i=Cr(e),a=Cr(t);if(r!==1/0&&Tr(i,a,n)>=r)return r;if(Kn(i,a)){if(W(e,t))return 0}else if(W(t,e))return 0;let o=1/0;for(let r of e)for(let e=0,i=r.length,a=i-1;e<i;a=e++){let i=r[a],s=r[e];for(let e of t)for(let t=0,r=e.length,a=r-1;t<r;a=t++){let r=e[a],c=e[t];if(Jn(i,s,r,c))return 0;o=Math.min(o,Dr(i,s,r,c,n))}}return o}function Nr(e,t,n,r,i,a){if(!a)return;let o=Tr(Sr(r,a),i,n);o<t&&e.push([o,a,[0,0]])}function Pr(e,t,n,r,i,a,o){if(!a||!o)return;let s=Tr(Sr(r,a),Sr(i,o),n);s<t&&e.push([s,a,o])}function Fr(e,t,n,r,i=1/0){let a=Math.min(r.distance(e[0],n[0][0]),i);if(a===0)return a;let o=new sr([[0,[0,e.length-1],[0,0]]],vr),s=Cr(n);for(;o.length>0;){let i=o.pop();if(i[0]>=a)continue;let c=i[1],l=t?50:100;if(yr(c)<=l){if(!br(c,e.length))return NaN;if(t){let t=jr(e,c,n,r);if(isNaN(t)||t===0)return t;a=Math.min(a,t)}else for(let t=c[0];t<=c[1];++t){let i=Ar(e[t],n,r);if(a=Math.min(a,i),a===0)return 0}}else{let n=xr(c,t);Nr(o,a,r,e,s,n[0]),Nr(o,a,r,e,s,n[1])}}return a}function Ir(e,t,n,r,i,a=1/0){let o=Math.min(a,i.distance(e[0],n[0]));if(o===0)return o;let s=new sr([[0,[0,e.length-1],[0,n.length-1]]],vr);for(;s.length>0;){let a=s.pop();if(a[0]>=o)continue;let c=a[1],l=a[2],u=t?50:100,d=r?50:100;if(yr(c)<=u&&yr(l)<=d){if(!br(c,e.length)&&br(l,n.length))return NaN;let a;if(t&&r)a=Or(e,c,n,l,i),o=Math.min(o,a);else if(t&&!r){let t=e.slice(c[0],c[1]+1);for(let e=l[0];e<=l[1];++e)if(a=Er(n[e],t,i),o=Math.min(o,a),o===0)return o}else if(!t&&r){let t=n.slice(l[0],l[1]+1);for(let n=c[0];n<=c[1];++n)if(a=Er(e[n],t,i),o=Math.min(o,a),o===0)return o}else a=kr(e,c,n,l,i),o=Math.min(o,a)}else{let a=xr(c,t),u=xr(l,r);Pr(s,o,i,e,n,a[0],u[0]),Pr(s,o,i,e,n,a[0],u[1]),Pr(s,o,i,e,n,a[1],u[0]),Pr(s,o,i,e,n,a[1],u[1])}}return o}function Lr(e){return e.type===`MultiPolygon`?e.coordinates.map((e=>({type:`Polygon`,coordinates:e}))):e.type===`MultiLineString`?e.coordinates.map((e=>({type:`LineString`,coordinates:e}))):e.type===`MultiPoint`?e.coordinates.map((e=>({type:`Point`,coordinates:e}))):[e]}class Rr{constructor(e,t){this.type=I,this.geojson=e,this.geometries=t}static parse(e,t){if(e.length!==2)return t.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(rn(e[1])){let t=e[1];if(t.type===`FeatureCollection`)return new Rr(t,t.features.map((e=>Lr(e.geometry))).flat());if(t.type===`Feature`)return new Rr(t,Lr(t.geometry));if(`type`in t&&`coordinates`in t)return new Rr(t,Lr(t))}return t.error(`'distance' expression requires valid geojson object that contains polygon geometry type.`)}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()===`Point`)return function(e,t){let n=e.geometry(),r=n.flat().map((t=>U([t.x,t.y],e.canonical)));if(n.length===0)return NaN;let i=new _r(r[0][1]),a=1/0;for(let e of t){switch(e.type){case`Point`:a=Math.min(a,Ir(r,!1,[e.coordinates],!1,i,a));break;case`LineString`:a=Math.min(a,Ir(r,!1,e.coordinates,!0,i,a));break;case`Polygon`:a=Math.min(a,Fr(r,!1,e.coordinates,i,a))}if(a===0)return a}return a}(e,this.geometries);if(e.geometryType()===`LineString`)return function(e,t){let n=e.geometry(),r=n.flat().map((t=>U([t.x,t.y],e.canonical)));if(n.length===0)return NaN;let i=new _r(r[0][1]),a=1/0;for(let e of t){switch(e.type){case`Point`:a=Math.min(a,Ir(r,!0,[e.coordinates],!1,i,a));break;case`LineString`:a=Math.min(a,Ir(r,!0,e.coordinates,!0,i,a));break;case`Polygon`:a=Math.min(a,Fr(r,!0,e.coordinates,i,a))}if(a===0)return a}return a}(e,this.geometries);if(e.geometryType()===`Polygon`)return function(e,t){let n=e.geometry();if(n.length===0||n[0].length===0)return NaN;let r=dr(n,0).map((t=>t.map((t=>t.map((t=>U([t.x,t.y],e.canonical))))))),i=new _r(r[0][0][0][1]),a=1/0;for(let e of t)for(let t of r){switch(e.type){case`Point`:a=Math.min(a,Fr([e.coordinates],!1,t,i,a));break;case`LineString`:a=Math.min(a,Fr(e.coordinates,!0,t,i,a));break;case`Polygon`:a=Math.min(a,Mr(t,e.coordinates,i,a))}if(a===0)return a}return a}(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class zr{constructor(e){this.type=ot,this.key=e}static parse(e,t){if(e.length!==2)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);let n=e[1];return n==null?t.error(`Global state property must be defined.`):typeof n==`string`?new zr(n):t.error(`Global state property must be string, but found ${typeof e[1]} instead.`)}evaluate(e){let t=e.globals?.globalState;return t&&Object.keys(t).length!==0?Ft(t,this.key):null}eachChild(){}outputDefined(){return!1}}let Br={"==":Mn,"!=":Nn,">":Fn,"<":Pn,">=":Ln,"<=":In,array:B,at:hn,boolean:B,case:yn,coalesce:On,collator:Rn,format:Bn,image:Vn,in:gn,"index-of":_n,interpolate:Tn,"interpolate-hcl":Tn,"interpolate-lab":Tn,length:Hn,let:pn,literal:z,match:vn,number:B,"number-format":zn,object:B,slice:bn,step:Sn,string:B,"to-boolean":ln,"to-color":ln,"to-number":ln,"to-string":ln,var:mn,within:or,distance:Rr,"global-state":zr};class Vr{constructor(e,t,n,r){this.name=e,this.type=t,this._evaluate=n,this.args=r}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,t){let n=e[0],r=Vr.definitions[n];if(!r)return t.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0);let i=Array.isArray(r)?r[0]:r.type,a=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,o=a.filter((([t])=>!Array.isArray(t)||t.length===e.length-1)),s=null;for(let[r,a]of o){s=new fn(t.registry,Kr,t.path,null,t.scope);let o=[],c=!1;for(let t=1;t<e.length;t++){let n=e[t],i=Array.isArray(r)?r[t-1]:r.type,a=s.parse(n,1+o.length,i);if(!a){c=!0;break}o.push(a)}if(!c)if(Array.isArray(r)&&r.length!==o.length)s.error(`Expected ${r.length} arguments, but found ${o.length} instead.`);else{for(let e=0;e<o.length;e++){let t=Array.isArray(r)?r[e]:r.type,n=o[e];s.concat(e+1).checkSubtype(t,n.type)}if(s.errors.length===0)return new Vr(n,i,a,o)}}if(o.length===1)t.errors.push(...s.errors);else{let n=(o.length?o:a).map((([e])=>{return t=e,Array.isArray(t)?`(${t.map(ht).join(`, `)})`:`(${ht(t.type)}...)`;var t})).join(` | `),r=[];for(let n=1;n<e.length;n++){let i=t.parse(e[n],1+r.length);if(!i)return null;r.push(ht(i.type))}t.error(`Expected arguments of type ${n}, but found (${r.join(`, `)}) instead.`)}return null}static register(e,t){Vr.definitions=t;for(let n in t)e[n]=Vr}}function Hr(e,[t,n,r,i]){t=t.evaluate(e),n=n.evaluate(e),r=r.evaluate(e);let a=i?i.evaluate(e):1,o=nn(t,n,r,a);if(o)throw new Zt(o);return new Ut(t/255,n/255,r/255,a,!1)}function Ur(e,t){return e in t}function Wr(e,t){let n=t[e];return n===void 0?null:n}function Gr(e){return{type:e}}function Kr(e){if(e instanceof mn)return Kr(e.boundExpression);if(e instanceof Vr&&e.name===`error`||e instanceof Rn||e instanceof or||e instanceof Rr||e instanceof zr)return!1;let t=e instanceof ln||e instanceof B,n=!0;return e.eachChild((e=>{n=t?n&&Kr(e):n&&e instanceof z})),!!n&&qr(e)&&Yr(e,[`zoom`,`heatmap-density`,`elevation`,`line-progress`,`accumulated`,`is-supported-script`])}function qr(e){if(e instanceof Vr&&(e.name===`get`&&e.args.length===1||e.name===`feature-state`||e.name===`has`&&e.args.length===1||e.name===`properties`||e.name===`geometry-type`||e.name===`id`||/^filter-/.test(e.name))||e instanceof or||e instanceof Rr)return!1;let t=!0;return e.eachChild((e=>{t&&!qr(e)&&(t=!1)})),t}function Jr(e){if(e instanceof Vr&&e.name===`feature-state`)return!1;let t=!0;return e.eachChild((e=>{t&&!Jr(e)&&(t=!1)})),t}function Yr(e,t){if(e instanceof Vr&&t.indexOf(e.name)>=0)return!1;let n=!0;return e.eachChild((e=>{n&&!Yr(e,t)&&(n=!1)})),n}function Xr(e){return{result:`success`,value:e}}function Zr(e){return{result:`error`,value:e}}function G(e){return e[`property-type`]===`data-driven`||e[`property-type`]===`cross-faded-data-driven`}function Qr(e){return!!e.expression&&e.expression.parameters.indexOf(`zoom`)>-1}function $r(e){return!!e.expression&&e.expression.interpolated}function ei(e){return e instanceof Number?`number`:e instanceof String?`string`:e instanceof Boolean?`boolean`:Array.isArray(e)?`array`:e===null?`null`:typeof e}function ti(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&an(e)===at}function ni(e){return e}function ri(e,t){let n=e.stops&&typeof e.stops[0][0]==`object`,r=n||!(n||e.property!==void 0),i=e.type||($r(t)?`exponential`:`interval`),a=function(e){switch(e.type){case`color`:return Ut.parse;case`padding`:return Jt.parse;case`numberArray`:return Yt.parse;case`colorArray`:return Xt.parse;default:return null}}(t);if(a&&((e=Ze({},e)).stops&&(e.stops=e.stops.map((e=>[e[0],a(e[1])]))),e.default=a(e.default?e.default:t.default)),e.colorSpace&&(o=e.colorSpace)!==`rgb`&&o!==`hcl`&&o!==`lab`)throw Error(`Unknown color space: "${e.colorSpace}"`);var o;let s=function(e){switch(e){case`exponential`:return oi;case`interval`:return ai;case`categorical`:return K;case`identity`:return si;default:throw Error(`Unknown function type "${e}"`)}}(i),c,l;if(i===`categorical`){c=Object.create(null);for(let t of e.stops)c[t[0]]=t[1];l=typeof e.stops[0][0]}if(n){let n={},r=[];for(let t=0;t<e.stops.length;t++){let i=e.stops[t],a=i[0].zoom;n[a]===void 0&&(n[a]={zoom:a,type:e.type,property:e.property,default:e.default,stops:[]},r.push(a)),n[a].stops.push([i[0].value,i[1]])}let i=[];for(let e of r)i.push([n[e].zoom,ri(n[e],t)]);let a={name:`linear`};return{kind:`composite`,interpolationType:a,interpolationFactor:Tn.interpolationFactor.bind(void 0,a),zoomStops:i.map((e=>e[0])),evaluate:({zoom:n},r)=>oi({stops:i,base:e.base},t,n).evaluate(n,r)}}if(r){let n=i===`exponential`?{name:`exponential`,base:e.base===void 0?1:e.base}:null;return{kind:`camera`,interpolationType:n,interpolationFactor:Tn.interpolationFactor.bind(void 0,n),zoomStops:e.stops.map((e=>e[0])),evaluate:({zoom:n})=>s(e,t,n,c,l)}}return{kind:`source`,evaluate(n,r){let i=r&&r.properties?r.properties[e.property]:void 0;return i===void 0?ii(e.default,t.default):s(e,t,i,c,l)}}}function ii(e,t,n){return e===void 0?t===void 0?n===void 0?void 0:n:t:e}function K(e,t,n,r,i){return ii(typeof n===i?r[n]:void 0,e.default,t.default)}function ai(e,t,n){if(ei(n)!==`number`)return ii(e.default,t.default);let r=e.stops.length;if(r===1||n<=e.stops[0][0])return e.stops[0][1];if(n>=e.stops[r-1][0])return e.stops[r-1][1];let i=xn(e.stops.map((e=>e[0])),n);return e.stops[i][1]}function oi(e,t,n){let r=e.base===void 0?1:e.base;if(ei(n)!==`number`)return ii(e.default,t.default);let i=e.stops.length;if(i===1||n<=e.stops[0][0])return e.stops[0][1];if(n>=e.stops[i-1][0])return e.stops[i-1][1];let a=xn(e.stops.map((e=>e[0])),n),o=function(e,t,n,r){let i=r-n,a=e-n;return i===0?0:t===1?a/i:(t**+a-1)/(t**+i-1)}(n,r,e.stops[a][0],e.stops[a+1][0]),s=e.stops[a][1],c=e.stops[a+1][1],l=Dn[t.type]||ni;return typeof s.evaluate==`function`?{evaluate(...t){let n=s.evaluate.apply(void 0,t),r=c.evaluate.apply(void 0,t);if(n!==void 0&&r!==void 0)return l(n,r,o,e.colorSpace)}}:l(s,c,o,e.colorSpace)}function si(e,t,n){switch(t.type){case`color`:n=Ut.parse(n);break;case`formatted`:n=qt.fromString(n.toString());break;case`resolvedImage`:n=en.fromString(n.toString());break;case`padding`:n=Jt.parse(n);break;case`colorArray`:n=Xt.parse(n);break;case`numberArray`:n=Yt.parse(n);break;default:ei(n)===t.type||t.type===`enum`&&t.values[n]||(n=void 0)}return ii(n,e.default,t.default)}Vr.register(Br,{error:[{kind:`error`},[tt],(e,[t])=>{throw new Zt(t.evaluate(e))}],typeof:[tt,[ot],(e,[t])=>ht(an(t.evaluate(e)))],"to-rgba":[mt(I,4),[rt],(e,[t])=>{let[n,r,i,a]=t.evaluate(e).rgb;return[255*n,255*r,255*i,a]}],rgb:[rt,[I,I,I],Hr],rgba:[rt,[I,I,I,I],Hr],has:{type:nt,overloads:[[[tt],(e,[t])=>Ur(t.evaluate(e),e.properties())],[[tt,at],(e,[t,n])=>Ur(t.evaluate(e),n.evaluate(e))]]},get:{type:ot,overloads:[[[tt],(e,[t])=>Wr(t.evaluate(e),e.properties())],[[tt,at],(e,[t,n])=>Wr(t.evaluate(e),n.evaluate(e))]]},"feature-state":[ot,[tt],(e,[t])=>Wr(t.evaluate(e),e.featureState||{})],properties:[at,[],e=>e.properties()],"geometry-type":[tt,[],e=>e.geometryType()],id:[ot,[],e=>e.id()],zoom:[I,[],e=>e.globals.zoom],"heatmap-density":[I,[],e=>e.globals.heatmapDensity||0],elevation:[I,[],e=>e.globals.elevation||0],"line-progress":[I,[],e=>e.globals.lineProgress||0],accumulated:[ot,[],e=>e.globals.accumulated===void 0?null:e.globals.accumulated],"+":[I,Gr(I),(e,t)=>{let n=0;for(let r of t)n+=r.evaluate(e);return n}],"*":[I,Gr(I),(e,t)=>{let n=1;for(let r of t)n*=r.evaluate(e);return n}],"-":{type:I,overloads:[[[I,I],(e,[t,n])=>t.evaluate(e)-n.evaluate(e)],[[I],(e,[t])=>-t.evaluate(e)]]},"/":[I,[I,I],(e,[t,n])=>t.evaluate(e)/n.evaluate(e)],"%":[I,[I,I],(e,[t,n])=>t.evaluate(e)%n.evaluate(e)],ln2:[I,[],()=>Math.LN2],pi:[I,[],()=>Math.PI],e:[I,[],()=>Math.E],"^":[I,[I,I],(e,[t,n])=>t.evaluate(e)**+n.evaluate(e)],sqrt:[I,[I],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[I,[I],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[I,[I],(e,[t])=>Math.log(t.evaluate(e))],log2:[I,[I],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[I,[I],(e,[t])=>Math.sin(t.evaluate(e))],cos:[I,[I],(e,[t])=>Math.cos(t.evaluate(e))],tan:[I,[I],(e,[t])=>Math.tan(t.evaluate(e))],asin:[I,[I],(e,[t])=>Math.asin(t.evaluate(e))],acos:[I,[I],(e,[t])=>Math.acos(t.evaluate(e))],atan:[I,[I],(e,[t])=>Math.atan(t.evaluate(e))],min:[I,Gr(I),(e,t)=>Math.min(...t.map((t=>t.evaluate(e))))],max:[I,Gr(I),(e,t)=>Math.max(...t.map((t=>t.evaluate(e))))],abs:[I,[I],(e,[t])=>Math.abs(t.evaluate(e))],round:[I,[I],(e,[t])=>{let n=t.evaluate(e);return n<0?-Math.round(-n):Math.round(n)}],floor:[I,[I],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[I,[I],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[nt,[tt,ot],(e,[t,n])=>e.properties()[t.value]===n.value],"filter-id-==":[nt,[ot],(e,[t])=>e.id()===t.value],"filter-type-==":[nt,[tt],(e,[t])=>e.geometryType()===t.value],"filter-<":[nt,[tt,ot],(e,[t,n])=>{let r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r<i}],"filter-id-<":[nt,[ot],(e,[t])=>{let n=e.id(),r=t.value;return typeof n==typeof r&&n<r}],"filter->":[nt,[tt,ot],(e,[t,n])=>{let r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r>i}],"filter-id->":[nt,[ot],(e,[t])=>{let n=e.id(),r=t.value;return typeof n==typeof r&&n>r}],"filter-<=":[nt,[tt,ot],(e,[t,n])=>{let r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r<=i}],"filter-id-<=":[nt,[ot],(e,[t])=>{let n=e.id(),r=t.value;return typeof n==typeof r&&n<=r}],"filter->=":[nt,[tt,ot],(e,[t,n])=>{let r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r>=i}],"filter-id->=":[nt,[ot],(e,[t])=>{let n=e.id(),r=t.value;return typeof n==typeof r&&n>=r}],"filter-has":[nt,[ot],(e,[t])=>t.value in e.properties()],"filter-has-id":[nt,[],e=>e.id()!==null&&e.id()!==void 0],"filter-type-in":[nt,[mt(tt)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[nt,[mt(ot)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[nt,[tt,mt(ot)],(e,[t,n])=>n.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[nt,[tt,mt(ot)],(e,[t,n])=>function(e,t,n,r){for(;n<=r;){let i=n+r>>1;if(t[i]===e)return!0;t[i]>e?r=i-1:n=i+1}return!1}(e.properties()[t.value],n.value,0,n.value.length-1)],all:{type:nt,overloads:[[[nt,nt],(e,[t,n])=>t.evaluate(e)&&n.evaluate(e)],[Gr(nt),(e,t)=>{for(let n of t)if(!n.evaluate(e))return!1;return!0}]]},any:{type:nt,overloads:[[[nt,nt],(e,[t,n])=>t.evaluate(e)||n.evaluate(e)],[Gr(nt),(e,t)=>{for(let n of t)if(n.evaluate(e))return!0;return!1}]]},"!":[nt,[nt],(e,[t])=>!t.evaluate(e)],"is-supported-script":[nt,[tt],(e,[t])=>{let n=e.globals&&e.globals.isSupportedScript;return!n||n(t.evaluate(e))}],upcase:[tt,[tt],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[tt,[tt],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[tt,Gr(ot),(e,t)=>t.map((t=>on(t.evaluate(e)))).join(``)],split:[mt(tt),[tt,tt],(e,[t,n])=>t.evaluate(e).split(n.evaluate(e))],join:[tt,[mt(tt),tt],(e,[t,n])=>t.evaluate(e).join(n.evaluate(e))],"resolved-locale":[tt,[st],(e,[t])=>t.evaluate(e).resolvedLocale()]});class ci{constructor(e,t,n){this.expression=e,this._warningHistory={},this._evaluator=new dn,this._defaultValue=t?function(e){if(e.type===`color`&&ti(e.default))return new Ut(0,0,0,0);switch(e.type){case`color`:return Ut.parse(e.default)||null;case`padding`:return Jt.parse(e.default)||null;case`numberArray`:return Yt.parse(e.default)||null;case`colorArray`:return Xt.parse(e.default)||null;case`variableAnchorOffsetCollection`:return $t.parse(e.default)||null;case`projectionDefinition`:return tn.parse(e.default)||null;default:return e.default===void 0?null:e.default}}(t):null,this._enumValues=t&&t.type===`enum`?t.values:null,this._globalState=n}evaluateWithoutErrorHandling(e,t,n,r,i,a){return this._globalState&&(e=hi(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=n,this._evaluator.canonical=r,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=a,this.expression.evaluate(this._evaluator)}evaluate(e,t,n,r,i,a){this._globalState&&(e=hi(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=n||null,this._evaluator.canonical=r,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=a||null;try{let e=this.expression.evaluate(this._evaluator);if(e==null||typeof e==`number`&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new Zt(`Expected value to be one of ${Object.keys(this._enumValues).map((e=>JSON.stringify(e))).join(`, `)}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,typeof console<`u`&&console.warn(e.message)),this._defaultValue}}}function q(e){return Array.isArray(e)&&e.length>0&&typeof e[0]==`string`&&e[0]in Br}function li(e,t,n){let r=new fn(Br,Kr,[],t?function(e){let t={color:rt,string:tt,number:I,enum:tt,boolean:nt,formatted:ct,padding:lt,numberArray:dt,colorArray:ut,projectionDefinition:it,resolvedImage:ft,variableAnchorOffsetCollection:pt};return e.type===`array`?mt(t[e.value]||ot,e.length):t[e.type]}(t):void 0),i=r.parse(e,void 0,void 0,void 0,t&&t.type===`string`?{typeAnnotation:`coerce`}:void 0);return i?Xr(new ci(i,t,n)):Zr(r.errors)}class ui{constructor(e,t,n){this.kind=e,this._styleExpression=t,this.isStateDependent=e!==`constant`&&!Jr(t.expression),this.globalStateRefs=mi(t.expression),this._globalState=n}evaluateWithoutErrorHandling(e,t,n,r,i,a){return this._globalState&&(e=hi(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,n,r,i,a)}evaluate(e,t,n,r,i,a){return this._globalState&&(e=hi(e,this._globalState)),this._styleExpression.evaluate(e,t,n,r,i,a)}}class J{constructor(e,t,n,r,i){this.kind=e,this.zoomStops=n,this._styleExpression=t,this.isStateDependent=e!==`camera`&&!Jr(t.expression),this.globalStateRefs=mi(t.expression),this.interpolationType=r,this._globalState=i}evaluateWithoutErrorHandling(e,t,n,r,i,a){return this._globalState&&(e=hi(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,n,r,i,a)}evaluate(e,t,n,r,i,a){return this._globalState&&(e=hi(e,this._globalState)),this._styleExpression.evaluate(e,t,n,r,i,a)}interpolationFactor(e,t,n){return this.interpolationType?Tn.interpolationFactor(this.interpolationType,e,t,n):0}}function di(e,t,n){let r=li(e,t,n);if(r.result===`error`)return r;let i=r.value.expression,a=qr(i);if(!a&&!G(t))return Zr([new Qe(``,`data expressions not supported`)]);let o=Yr(i,[`zoom`]);if(!o&&!Qr(t))return Zr([new Qe(``,`zoom expressions not supported`)]);let s=pi(i);return s||o?s instanceof Qe?Zr([s]):s instanceof Tn&&!$r(t)?Zr([new Qe(``,`"interpolate" expressions cannot be used with this property`)]):Xr(s?new J(a?`camera`:`composite`,r.value,s.labels,s instanceof Tn?s.interpolation:void 0,n):new ui(a?`constant`:`source`,r.value,n)):Zr([new Qe(``,`"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.`)])}class fi{constructor(e,t){this._parameters=e,this._specification=t,Ze(this,ri(this._parameters,this._specification))}static deserialize(e){return new fi(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function pi(e){let t=null;if(e instanceof pn)t=pi(e.result);else if(e instanceof On){for(let n of e.args)if(t=pi(n),t)break}else (e instanceof Sn||e instanceof Tn)&&e.input instanceof Vr&&e.input.name===`zoom`&&(t=e);return t instanceof Qe||e.eachChild((e=>{let n=pi(e);n instanceof Qe?t=n:!t&&n?t=new Qe(``,`"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.`):t&&n&&t!==n&&(t=new Qe(``,`Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.`))})),t}function mi(e,t=new Set){return e instanceof zr&&t.add(e.key),e.eachChild((e=>{mi(e,t)})),t}function hi(e,t){let{zoom:n,heatmapDensity:r,elevation:i,lineProgress:a,isSupportedScript:o,accumulated:s}=e??{};return{zoom:n,heatmapDensity:r,elevation:i,lineProgress:a,isSupportedScript:o,accumulated:s,globalState:t}}function gi(e){if(!0===e||!1===e)return!0;if(!Array.isArray(e)||e.length===0)return!1;switch(e[0]){case`has`:return e.length>=2&&e[1]!==`$id`&&e[1]!==`$type`;case`in`:return e.length>=3&&(typeof e[1]!=`string`||Array.isArray(e[2]));case`!in`:case`!has`:case`none`:return!1;case`==`:case`!=`:case`>`:case`>=`:case`<`:case`<=`:return e.length!==3||Array.isArray(e[1])||Array.isArray(e[2]);case`any`:case`all`:for(let t of e.slice(1))if(!gi(t)&&typeof t!=`boolean`)return!1;return!0;default:return!0}}let _i={type:`boolean`,default:!1,transition:!1,"property-type":`data-driven`,expression:{interpolated:!1,parameters:[`zoom`,`feature`]}};function vi(e,t){if(e==null)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};gi(e)||(e=bi(e));let n=li(e,_i,t);if(n.result===`error`)throw Error(n.value.map((e=>`${e.key}: ${e.message}`)).join(`, `));return{filter:(e,t,r)=>n.value.evaluate(e,t,{},r),needGeometry:Y(e),getGlobalStateRefs:()=>mi(n.value.expression)}}function yi(e,t){return e<t?-1:+(e>t)}function Y(e){if(!Array.isArray(e))return!1;if(e[0]===`within`||e[0]===`distance`)return!0;for(let t=1;t<e.length;t++)if(Y(e[t]))return!0;return!1}function bi(e){if(!e)return!0;let t=e[0];return e.length<=1?t!==`any`:t===`==`?xi(e[1],e[2],`==`):t===`!=`?wi(xi(e[1],e[2],`==`)):t===`<`||t===`>`||t===`<=`||t===`>=`?xi(e[1],e[2],t):t===`any`?(n=e.slice(1),[`any`].concat(n.map(bi))):t===`all`?[`all`].concat(e.slice(1).map(bi)):t===`none`?[`all`].concat(e.slice(1).map(bi).map(wi)):t===`in`?Si(e[1],e.slice(2)):t===`!in`?wi(Si(e[1],e.slice(2))):t===`has`?Ci(e[1]):t!==`!has`||wi(Ci(e[1]));var n}function xi(e,t,n){switch(e){case`$type`:return[`filter-type-${n}`,t];case`$id`:return[`filter-id-${n}`,t];default:return[`filter-${n}`,e,t]}}function Si(e,t){if(t.length===0)return!1;switch(e){case`$type`:return[`filter-type-in`,[`literal`,t]];case`$id`:return[`filter-id-in`,[`literal`,t]];default:return t.length>200&&!t.some((e=>typeof e!=typeof t[0]))?[`filter-in-large`,e,[`literal`,t.sort(yi)]]:[`filter-in-small`,e,[`literal`,t]]}}function Ci(e){switch(e){case`$type`:return!0;case`$id`:return[`filter-has-id`];default:return[`filter-has`,e]}}function wi(e){return[`!`,e]}function Ti(e){let t=typeof e;if(t===`number`||t===`boolean`||t===`string`||e==null)return JSON.stringify(e);if(Array.isArray(e)){let t=`[`;for(let n of e)t+=`${Ti(n)},`;return`${t}]`}let n=Object.keys(e).sort(),r=`{`;for(let t=0;t<n.length;t++)r+=`${JSON.stringify(n[t])}:${Ti(e[n[t]])},`;return`${r}}`}function Ei(e){let t=``;for(let n of He)t+=`/${Ti(e[n])}`;return t}function Di(e){let t=e.value;return t?[new F(e.key,t,`constants have been deprecated as of v8`)]:[]}function Oi(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function ki(e){if(Array.isArray(e))return e.map(ki);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){let t={};for(let n in e)t[n]=ki(e[n]);return t}return Oi(e)}function Ai(e){let t=e.key,n=e.value,r=e.valueSpec||{},i=e.objectElementValidators||{},a=e.style,o=e.styleSpec,s=e.validateSpec,c=[],l=ei(n);if(l!==`object`)return[new F(t,n,`object expected, ${l} found`)];for(let e in n){let l=e.split(`.`)[0],u=Ft(r,l)||r[`*`],d;if(Ft(i,l))d=i[l];else if(Ft(r,l)){if(n[e]===void 0)continue;d=s}else if(i[`*`])d=i[`*`];else{if(!r[`*`]){c.push(new F(t,n[e],`unknown property "${e}"`));continue}d=s}c=c.concat(d({key:(t&&`${t}.`)+e,value:n[e],valueSpec:u,style:a,styleSpec:o,object:n,objectKey:e,validateSpec:s},n))}for(let e in r)i[e]||r[e].required&&r[e].default===void 0&&n[e]===void 0&&c.push(new F(t,n,`missing required property "${e}"`));return c}function ji(e){let t=e.value,n=e.valueSpec,r=e.style,i=e.styleSpec,a=e.key,o=e.arrayElementValidator||e.validateSpec;if(ei(t)!==`array`)return[new F(a,t,`array expected, ${ei(t)} found`)];if(n.length&&t.length!==n.length)return[new F(a,t,`array length ${n.length} expected, length ${t.length} found`)];let s={type:n.value,values:n.values};i.$version<7&&(s.function=n.function),ei(n.value)===`object`&&(s=n.value);let c=[];for(let n=0;n<t.length;n++)c=c.concat(o({array:t,arrayIndex:n,value:t[n],valueSpec:s,validateSpec:e.validateSpec,style:r,styleSpec:i,key:`${a}[${n}]`}));return c}function Mi(e){let t=e.key,n=e.value,r=e.valueSpec,i=ei(n);return i===`number`&&n!=n&&(i=`NaN`),i===`number`?`minimum`in r&&n<r.minimum?[new F(t,n,`${n} is less than the minimum value ${r.minimum}`)]:`maximum`in r&&n>r.maximum?[new F(t,n,`${n} is greater than the maximum value ${r.maximum}`)]:[]:[new F(t,n,`number expected, ${i} found`)]}function Ni(e){let t=e.valueSpec,n=Oi(e.value.type),r,i,a,o={},s=n!==`categorical`&&e.value.property===void 0,c=!s,l=ei(e.value.stops)===`array`&&ei(e.value.stops[0])===`array`&&ei(e.value.stops[0][0])===`object`,u=Ai({key:e.key,value:e.value,valueSpec:e.styleSpec.function,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if(n===`identity`)return[new F(e.key,e.value,`identity function may not have a "stops" property`)];let t=[],r=e.value;return t=t.concat(ji({key:e.key,value:r,valueSpec:e.valueSpec,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:d})),ei(r)===`array`&&r.length===0&&t.push(new F(e.key,r,`array must have at least one stop`)),t},default:function(e){return e.validateSpec({key:e.key,value:e.value,valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec})}}});return n===`identity`&&s&&u.push(new F(e.key,e.value,`missing required property "property"`)),n===`identity`||e.value.stops||u.push(new F(e.key,e.value,`missing required property "stops"`)),n===`exponential`&&e.valueSpec.expression&&!$r(e.valueSpec)&&u.push(new F(e.key,e.value,`exponential functions not supported`)),e.styleSpec.$version>=8&&(c&&!G(e.valueSpec)?u.push(new F(e.key,e.value,`property functions not supported`)):s&&!Qr(e.valueSpec)&&u.push(new F(e.key,e.value,`zoom functions not supported`))),n!==`categorical`&&!l||e.value.property!==void 0||u.push(new F(e.key,e.value,`"property" property is required`)),u;function d(e){let n=[],r=e.value,s=e.key;if(ei(r)!==`array`)return[new F(s,r,`array expected, ${ei(r)} found`)];if(r.length!==2)return[new F(s,r,`array length 2 expected, length ${r.length} found`)];if(l){if(ei(r[0])!==`object`)return[new F(s,r,`object expected, ${ei(r[0])} found`)];if(r[0].zoom===void 0)return[new F(s,r,`object stop key must have zoom`)];if(r[0].value===void 0)return[new F(s,r,`object stop key must have value`)];if(a&&a>Oi(r[0].zoom))return[new F(s,r[0].zoom,`stop zoom values must appear in ascending order`)];Oi(r[0].zoom)!==a&&(a=Oi(r[0].zoom),i=void 0,o={}),n=n.concat(Ai({key:`${s}[0]`,value:r[0],valueSpec:{zoom:{}},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:Mi,value:f}}))}else n=n.concat(f({key:`${s}[0]`,value:r[0],validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec},r));return q(ki(r[1]))?n.concat([new F(`${s}[1]`,r[1],`expressions are not allowed in function stops.`)]):n.concat(e.validateSpec({key:`${s}[1]`,value:r[1],valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec}))}function f(e,a){let s=ei(e.value),c=Oi(e.value),l=e.value===null?a:e.value;if(r){if(s!==r)return[new F(e.key,l,`${s} stop domain type must match previous stop domain type ${r}`)]}else r=s;if(s!==`number`&&s!==`string`&&s!==`boolean`)return[new F(e.key,l,`stop domain value must be a number, string, or boolean`)];if(s!==`number`&&n!==`categorical`){let r=`number expected, ${s} found`;return G(t)&&n===void 0&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new F(e.key,l,r)]}return n!==`categorical`||s!==`number`||isFinite(c)&&Math.floor(c)===c?n!==`categorical`&&s===`number`&&i!==void 0&&c<i?[new F(e.key,l,`stop domain values must appear in ascending order`)]:(i=c,n===`categorical`&&c in o?[new F(e.key,l,`stop domain values must be unique`)]:(o[c]=!0,[])):[new F(e.key,l,`integer expected, found ${c}`)]}}function Pi(e){let t=(e.expressionContext===`property`?di:li)(ki(e.value),e.valueSpec);if(t.result===`error`)return t.value.map((t=>new F(`${e.key}${t.key}`,e.value,t.message)));let n=t.value.expression||t.value._styleExpression.expression;if(e.expressionContext===`property`&&e.propertyKey===`text-font`&&!n.outputDefined())return[new F(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if(e.expressionContext===`property`&&e.propertyType===`layout`&&!Jr(n))return[new F(e.key,e.value,`"feature-state" data expressions are not supported with layout properties.`)];if(e.expressionContext===`filter`&&!Jr(n))return[new F(e.key,e.value,`"feature-state" data expressions are not supported with filters.`)];if(e.expressionContext&&e.expressionContext.indexOf(`cluster`)===0){if(!Yr(n,[`zoom`,`feature-state`]))return[new F(e.key,e.value,`"zoom" and "feature-state" expressions are not supported with cluster properties.`)];if(e.expressionContext===`cluster-initial`&&!qr(n))return[new F(e.key,e.value,`Feature data expressions are not supported with initial expression part of cluster properties.`)]}return[]}function Fi(e){let t=e.key,n=e.value,r=ei(n);return r===`string`?Ut.parse(String(n))?[]:[new F(t,n,`color expected, "${n}" found`)]:[new F(t,n,`color expected, ${r} found`)]}function Ii(e){let t=e.key,n=e.value,r=e.valueSpec,i=[];return Array.isArray(r.values)?r.values.indexOf(Oi(n))===-1&&i.push(new F(t,n,`expected one of [${r.values.join(`, `)}], ${JSON.stringify(n)} found`)):Object.keys(r.values).indexOf(Oi(n))===-1&&i.push(new F(t,n,`expected one of [${Object.keys(r.values).join(`, `)}], ${JSON.stringify(n)} found`)),i}function Li(e){return gi(ki(e.value))?Pi(Ze({},e,{expressionContext:`filter`,valueSpec:{value:`boolean`}})):Ri(e)}function Ri(e){let t=e.value,n=e.key;if(ei(t)!==`array`)return[new F(n,t,`array expected, ${ei(t)} found`)];let r=e.styleSpec,i,a=[];if(t.length<1)return[new F(n,t,`filter array must have at least 1 element`)];switch(a=a.concat(Ii({key:`${n}[0]`,value:t[0],valueSpec:r.filter_operator,style:e.style,styleSpec:e.styleSpec})),Oi(t[0])){case`<`:case`<=`:case`>`:case`>=`:t.length>=2&&Oi(t[1])===`$type`&&a.push(new F(n,t,`"$type" cannot be use with operator "${t[0]}"`));case`==`:case`!=`:t.length!==3&&a.push(new F(n,t,`filter array for operator "${t[0]}" must have 3 elements`));case`in`:case`!in`:t.length>=2&&(i=ei(t[1]),i!==`string`&&a.push(new F(`${n}[1]`,t[1],`string expected, ${i} found`)));for(let o=2;o<t.length;o++)i=ei(t[o]),Oi(t[1])===`$type`?a=a.concat(Ii({key:`${n}[${o}]`,value:t[o],valueSpec:r.geometry_type,style:e.style,styleSpec:e.styleSpec})):i!==`string`&&i!==`number`&&i!==`boolean`&&a.push(new F(`${n}[${o}]`,t[o],`string, number, or boolean expected, ${i} found`));break;case`any`:case`all`:case`none`:for(let r=1;r<t.length;r++)a=a.concat(Ri({key:`${n}[${r}]`,value:t[r],style:e.style,styleSpec:e.styleSpec}));break;case`has`:case`!has`:i=ei(t[1]),t.length===2?i!==`string`&&a.push(new F(`${n}[1]`,t[1],`string expected, ${i} found`)):a.push(new F(n,t,`filter array for "${t[0]}" operator must have 2 elements`))}return a}function zi(e,t){let n=e.key,r=e.validateSpec,i=e.style,a=e.styleSpec,o=e.value,s=e.objectKey,c=a[`${t}_${e.layerType}`];if(!c)return[];let l=s.match(/^(.*)-transition$/);if(t===`paint`&&l&&c[l[1]]&&c[l[1]].transition)return r({key:n,value:o,valueSpec:a.transition,style:i,styleSpec:a});let u=e.valueSpec||c[s];if(!u)return[new F(n,o,`unknown property "${s}"`)];let d;if(ei(o)===`string`&&G(u)&&!u.tokens&&(d=/^{([^}]+)}$/.exec(o)))return[new F(n,o,`"${s}" does not support interpolation syntax\nUse an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(d[1])} }\`.`)];let f=[];return e.layerType===`symbol`&&s===`text-font`&&ti(ki(o))&&Oi(o.type)===`identity`&&f.push(new F(n,o,`"text-font" does not support identity functions`)),f.concat(r({key:e.key,value:o,valueSpec:u,style:i,styleSpec:a,expressionContext:`property`,propertyType:t,propertyKey:s}))}function Bi(e){return zi(e,`paint`)}function Vi(e){return zi(e,`layout`)}function Hi(e){var t,n;let r=[],i=e.value,a=e.key,o=e.style,s=e.styleSpec;if(ei(i)!==`object`)return[new F(a,i,`object expected, ${ei(i)} found`)];i.type||i.ref||r.push(new F(a,i,`either "type" or "ref" is required`));let c=Oi(i.type),l=Oi(i.ref);if(i.id){let t=Oi(i.id);for(let n=0;n<e.arrayIndex;n++){let e=o.layers[n];Oi(e.id)===t&&r.push(new F(a,i.id,`duplicate layer id "${i.id}", previously used at line ${e.id.__line__}`))}}if(`ref`in i){let e;[`type`,`source`,`source-layer`,`filter`,`layout`].forEach((e=>{e in i&&r.push(new F(a,i[e],`"${e}" is prohibited for ref layers`))})),o.layers.forEach((t=>{Oi(t.id)===l&&(e=t)})),e?e.ref?r.push(new F(a,i.ref,`ref cannot reference another ref layer`)):c=Oi(e.type):r.push(new F(a,i.ref,`ref layer "${l}" not found`))}else if(c!==`background`)if(i.source){let e=o.sources&&o.sources[i.source],t=e&&Oi(e.type);e?t===`vector`&&c===`raster`?r.push(new F(a,i.source,`layer "${i.id}" requires a raster source`)):t!==`raster-dem`&&c===`hillshade`||t!==`raster-dem`&&c===`color-relief`?r.push(new F(a,i.source,`layer "${i.id}" requires a raster-dem source`)):t===`raster`&&c!==`raster`?r.push(new F(a,i.source,`layer "${i.id}" requires a vector source`)):t!==`vector`||i[`source-layer`]?t===`raster-dem`&&c!==`hillshade`&&c!==`color-relief`?r.push(new F(a,i.source,`raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.`)):c!==`line`||!i.paint||!i.paint[`line-gradient`]||t===`geojson`&&e.lineMetrics||r.push(new F(a,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):r.push(new F(a,i,`layer "${i.id}" must specify a "source-layer"`)):r.push(new F(a,i.source,`source "${i.source}" not found`))}else r.push(new F(a,i,`missing required property "source"`));return c===`raster`&&(t=i.paint)!=null&&t.resampling&&(n=i.paint)!=null&&n[`raster-resampling`]&&r.push(new F(a,i.paint,`layer "${i.id}" redundantly specifies "resampling" and "raster-resampling" paint properties, but only one is allowed. It is advised to use "resampling".`)),r=r.concat(Ai({key:a,value:i,valueSpec:s.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":()=>[],type:()=>e.validateSpec({key:`${a}.type`,value:i.type,valueSpec:s.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:i,objectKey:`type`}),filter:Li,layout:e=>Ai({layer:i,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>Vi(Ze({layerType:c},e))}}),paint:e=>Ai({layer:i,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>Bi(Ze({layerType:c},e))}})}})),r}function Ui(e){let t=e.value,n=e.key,r=ei(t);return r===`string`?[]:[new F(n,t,`string expected, ${r} found`)]}let Wi={promoteId:function({key:e,value:t}){if(ei(t)===`string`)return Ui({key:e,value:t});{let n=[];for(let r in t)n.push(...Ui({key:`${e}.${r}`,value:t[r]}));return n}}};function Gi(e){let t=e.value,n=e.key,r=e.styleSpec,i=e.style,a=e.validateSpec;if(!t.type)return[new F(n,t,`"type" is required`)];let o=Oi(t.type),s;switch(o){case`vector`:case`raster`:return s=Ai({key:n,value:t,valueSpec:r[`source_${o.replace(`-`,`_`)}`],style:e.style,styleSpec:r,objectElementValidators:Wi,validateSpec:a}),s;case`raster-dem`:return s=function(e){let t=e.sourceName??``,n=e.value,r=e.styleSpec,i=r.source_raster_dem,a=e.style,o=[],s=ei(n);if(n===void 0)return o;if(s!==`object`)return o.push(new F(`source_raster_dem`,n,`object expected, ${s} found`)),o;let c=Oi(n.encoding)===`custom`,l=[`redFactor`,`greenFactor`,`blueFactor`,`baseShift`],u=e.value.encoding?`"${e.value.encoding}"`:`Default`;for(let s in n)!c&&l.includes(s)?o.push(new F(s,n[s],`In "${t}": "${s}" is only valid when "encoding" is set to "custom". ${u} encoding found`)):i[s]?o=o.concat(e.validateSpec({key:s,value:n[s],valueSpec:i[s],validateSpec:e.validateSpec,style:a,styleSpec:r})):o.push(new F(s,n[s],`unknown property "${s}"`));return o}({sourceName:n,value:t,style:e.style,styleSpec:r,validateSpec:a}),s;case`geojson`:if(s=Ai({key:n,value:t,valueSpec:r.source_geojson,style:i,styleSpec:r,validateSpec:a,objectElementValidators:Wi}),t.cluster)for(let e in t.clusterProperties){let[r,i]=t.clusterProperties[e],a=typeof r==`string`?[r,[`accumulated`],[`get`,e]]:r;s.push(...Pi({key:`${n}.${e}.map`,value:i,expressionContext:`cluster-map`})),s.push(...Pi({key:`${n}.${e}.reduce`,value:a,expressionContext:`cluster-reduce`}))}return s;case`video`:return Ai({key:n,value:t,valueSpec:r.source_video,style:i,validateSpec:a,styleSpec:r});case`image`:return Ai({key:n,value:t,valueSpec:r.source_image,style:i,validateSpec:a,styleSpec:r});case`canvas`:return[new F(n,null,`Please use runtime APIs to add canvas sources, rather than including them in stylesheets.`,`source.canvas`)];default:return Ii({key:`${n}.type`,value:t.type,valueSpec:{values:[`vector`,`raster`,`raster-dem`,`geojson`,`video`,`image`]}})}}function Ki(e){let t=e.value,n=e.styleSpec,r=n.light,i=e.style,a=[],o=ei(t);if(t===void 0)return a;if(o!==`object`)return a=a.concat([new F(`light`,t,`object expected, ${o} found`)]),a;for(let o in t){let s=o.match(/^(.*)-transition$/);a=a.concat(s&&r[s[1]]&&r[s[1]].transition?e.validateSpec({key:o,value:t[o],valueSpec:n.transition,validateSpec:e.validateSpec,style:i,styleSpec:n}):r[o]?e.validateSpec({key:o,value:t[o],valueSpec:r[o],validateSpec:e.validateSpec,style:i,styleSpec:n}):[new F(o,t[o],`unknown property "${o}"`)])}return a}function qi(e){let t=e.value,n=e.styleSpec,r=n.sky,i=e.style,a=ei(t);if(t===void 0)return[];if(a!==`object`)return[new F(`sky`,t,`object expected, ${a} found`)];let o=[];for(let a in t)o=o.concat(r[a]?e.validateSpec({key:a,value:t[a],valueSpec:r[a],style:i,styleSpec:n}):[new F(a,t[a],`unknown property "${a}"`)]);return o}function Ji(e){let t=e.value,n=e.styleSpec,r=n.terrain,i=e.style,a=[],o=ei(t);if(t===void 0)return a;if(o!==`object`)return a=a.concat([new F(`terrain`,t,`object expected, ${o} found`)]),a;for(let o in t)a=a.concat(r[o]?e.validateSpec({key:o,value:t[o],valueSpec:r[o],validateSpec:e.validateSpec,style:i,styleSpec:n}):[new F(o,t[o],`unknown property "${o}"`)]);return a}function Yi(e){let t=[],n=e.value,r=e.key;if(Array.isArray(n)){let i=[],a=[];for(let o in n)n[o].id&&i.includes(n[o].id)&&t.push(new F(r,n,`all the sprites' ids must be unique, but ${n[o].id} is duplicated`)),i.push(n[o].id),n[o].url&&a.includes(n[o].url)&&t.push(new F(r,n,`all the sprites' URLs must be unique, but ${n[o].url} is duplicated`)),a.push(n[o].url),t=t.concat(Ai({key:`${r}[${o}]`,value:n[o],valueSpec:{id:{type:`string`,required:!0},url:{type:`string`,required:!0}},validateSpec:e.validateSpec}));return t}return Ui({key:r,value:n})}function Xi(e){return!!e&&e.constructor===Object}function Zi(e){return Xi(e.value)?[]:[new F(e.key,e.value,`object expected, ${ei(e.value)} found`)]}let Qi={"*":()=>[],array:ji,boolean:function(e){let t=e.value,n=e.key,r=ei(t);return r===`boolean`?[]:[new F(n,t,`boolean expected, ${r} found`)]},number:Mi,color:Fi,constants:Di,enum:Ii,filter:Li,function:Ni,layer:Hi,object:Ai,source:Gi,light:Ki,sky:qi,terrain:Ji,projection:function(e){let t=e.value,n=e.styleSpec,r=n.projection,i=e.style,a=ei(t);if(t===void 0)return[];if(a!==`object`)return[new F(`projection`,t,`object expected, ${a} found`)];let o=[];for(let a in t)o=o.concat(r[a]?e.validateSpec({key:a,value:t[a],valueSpec:r[a],style:i,styleSpec:n}):[new F(a,t[a],`unknown property "${a}"`)]);return o},projectionDefinition:function(e){let t=e.key,n=e.value;n=n instanceof String?n.valueOf():n;let r=ei(n);return r!==`array`||function(e){return Array.isArray(e)&&e.length===3&&typeof e[0]==`string`&&typeof e[1]==`string`&&typeof e[2]==`number`}(n)||function(e){return!![`interpolate`,`step`,`literal`].includes(e[0])}(n)?[`array`,`string`].includes(r)?[]:[new F(t,n,`projection expected, invalid type "${r}" found`)]:[new F(t,n,`projection expected, invalid array ${JSON.stringify(n)} found`)]},string:Ui,formatted:function(e){return Ui(e).length===0?[]:Pi(e)},resolvedImage:function(e){return Ui(e).length===0?[]:Pi(e)},padding:function(e){let t=e.key,n=e.value;if(ei(n)===`array`){if(n.length<1||n.length>4)return[new F(t,n,`padding requires 1 to 4 values; ${n.length} values found`)];let r={type:`number`},i=[];for(let a=0;a<n.length;a++)i=i.concat(e.validateSpec({key:`${t}[${a}]`,value:n[a],validateSpec:e.validateSpec,valueSpec:r}));return i}return Mi({key:t,value:n,valueSpec:{}})},numberArray:function(e){let t=e.key,n=e.value;if(ei(n)===`array`){let r={type:`number`};if(n.length<1)return[new F(t,n,`array length at least 1 expected, length 0 found`)];let i=[];for(let a=0;a<n.length;a++)i=i.concat(e.validateSpec({key:`${t}[${a}]`,value:n[a],validateSpec:e.validateSpec,valueSpec:r}));return i}return Mi({key:t,value:n,valueSpec:{}})},colorArray:function(e){let t=e.key,n=e.value;if(ei(n)===`array`){if(n.length<1)return[new F(t,n,`array length at least 1 expected, length 0 found`)];let e=[];for(let r=0;r<n.length;r++)e=e.concat(Fi({key:`${t}[${r}]`,value:n[r]}));return e}return Fi({key:t,value:n})},variableAnchorOffsetCollection:function(e){let t=e.key,n=e.value,r=ei(n),i=e.styleSpec;if(r!==`array`||n.length<1||n.length%2!=0)return[new F(t,n,`variableAnchorOffsetCollection requires a non-empty array of even length`)];let a=[];for(let r=0;r<n.length;r+=2)a=a.concat(Ii({key:`${t}[${r}]`,value:n[r],valueSpec:i.layout_symbol[`text-anchor`]})),a=a.concat(ji({key:`${t}[${r+1}]`,value:n[r+1],valueSpec:{length:2,value:`number`},validateSpec:e.validateSpec,style:e.style,styleSpec:i}));return a},sprite:Yi,state:Zi,fontFaces:function(e){let t=e.key,n=e.value,r=e.validateSpec,i=e.styleSpec,a=e.style;if(!Xi(n))return[new F(t,n,`object expected, ${ei(n)} found`)];let o=[];for(let e in n){let s=n[e],c=ei(s);if(c===`string`)o.push(...Ui({key:`${t}.${e}`,value:s}));else if(c===`array`){let n={url:{type:`string`,required:!0},"unicode-range":{type:`array`,value:`string`}};for(let[c,l]of s.entries())o.push(...Ai({key:`${t}.${e}[${c}]`,value:l,valueSpec:n,styleSpec:i,style:a,validateSpec:r}))}else o.push(new F(`${t}.${e}`,s,`string or array expected, ${c} found`))}return o}};function $i(e){let t=e.value,n=e.valueSpec,r=e.styleSpec;return e.validateSpec=$i,n.expression&&ti(Oi(t))?Ni(e):n.expression&&q(ki(t))?Pi(e):n.type&&Qi[n.type]?Qi[n.type](e):Ai(Ze({},e,{valueSpec:n.type?r[n.type]:n}))}function ea(e){let t=e.value,n=e.key,r=Ui(e);return r.length||(t.indexOf(`{fontstack}`)===-1&&r.push(new F(n,t,`"glyphs" url must include a "{fontstack}" token`)),t.indexOf(`{range}`)===-1&&r.push(new F(n,t,`"glyphs" url must include a "{range}" token`))),r}function ta(e,t=M){let n=[];return n=n.concat($i({key:``,value:e,valueSpec:t.$root,styleSpec:t,style:e,validateSpec:$i,objectElementValidators:{glyphs:ea,"*":()=>[]}})),e.constants&&(n=n.concat(Di({key:`constants`,value:e.constants}))),ra(n)}function na(e){return function(t){return e(Object.assign({},t,{validateSpec:$i}))}}function ra(e){return[].concat(e).sort(((e,t)=>e.line-t.line))}function ia(e){return function(...t){return ra(e.apply(this,t))}}ta.source=ia(na(Gi)),ta.sprite=ia(na(Yi)),ta.glyphs=ia(na(ea)),ta.light=ia(na(Ki)),ta.sky=ia(na(qi)),ta.terrain=ia(na(Ji)),ta.state=ia(na(Zi)),ta.layer=ia(na(Hi)),ta.filter=ia(na(Li)),ta.paintProperty=ia(na(Bi)),ta.layoutProperty=ia(na(Vi));let aa={type:`enum`,"property-type":`data-constant`,expression:{interpolated:!1,parameters:[`global-state`]},values:{visible:{},none:{}},transition:!1,default:`visible`};class oa{constructor(e,t){this._globalState=t,this.setValue(e)}evaluate(){return this._literalValue??this._compiledValue.evaluate({})}setValue(e){if(e==null||e===`visible`||e===`none`)return this._literalValue=e===`none`?`none`:`visible`,this._compiledValue=void 0,void(this._globalStateRefs=new Set);let t=li(e,aa,this._globalState);if(t.result===`error`)throw this._literalValue=`visible`,this._compiledValue=void 0,Error(t.value.map((e=>`${e.key}: ${e.message}`)).join(`, `));this._literalValue=void 0,this._compiledValue=t.value,this._globalStateRefs=mi(t.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}}let sa=M,ca=ta,la=ca.light,ua=ca.sky,da=ca.paintProperty,fa=ca.layoutProperty;function pa(e,t){let n=!1;if(t?.length)for(let r of t)e.fire(new Be(Error(r.message))),n=!0;return n}class ma{constructor(e,t,n){let r=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;let i=new Int32Array(this.arrayBuffer);e=i[0],this.d=(t=i[1])+2*(n=i[2]);for(let e=0;e<this.d*this.d;e++){let t=i[3+e],n=i[3+e+1];r.push(t===n?null:i.subarray(t,n))}let a=i[3+r.length+1];this.keys=i.subarray(i[3+r.length],a),this.bboxes=i.subarray(a),this.insert=this._insertReadonly}else{this.d=t+2*n;for(let e=0;e<this.d*this.d;e++)r.push([]);this.keys=[],this.bboxes=[]}this.n=t,this.extent=e,this.padding=n,this.scale=t/e,this.uid=0;let i=n/t*e;this.min=-i,this.max=e+i}insert(e,t,n,r,i){this._forEachCell(t,n,r,i,this._insertCell,this.uid++,void 0,void 0),this.keys.push(e),this.bboxes.push(t),this.bboxes.push(n),this.bboxes.push(r),this.bboxes.push(i)}_insertReadonly(){throw Error(`Cannot insert into a GridIndex created from an ArrayBuffer.`)}_insertCell(e,t,n,r,i,a){this.cells[i].push(a)}query(e,t,n,r,i){let a=this.min,o=this.max;if(e<=a&&t<=a&&o<=n&&o<=r&&!i)return[...this.keys];{let a=[];return this._forEachCell(e,t,n,r,this._queryCell,a,{},i),a}}_queryCell(e,t,n,r,i,a,o,s){let c=this.cells[i];if(c!==null){let i=this.keys,l=this.bboxes;for(let u of c)if(o[u]===void 0){let c=4*u;(s?s(l[c+0],l[c+1],l[c+2],l[c+3]):e<=l[c+2]&&t<=l[c+3]&&n>=l[c+0]&&r>=l[c+1])?(o[u]=!0,a.push(i[u])):o[u]=!1}}}_forEachCell(e,t,n,r,i,a,o,s){let c=this._convertToCellCoord(e),l=this._convertToCellCoord(t),u=this._convertToCellCoord(n),d=this._convertToCellCoord(r);for(let f=c;f<=u;f++)for(let c=l;c<=d;c++){let l=this.d*c+f;if((!s||s(this._convertFromCellCoord(f),this._convertFromCellCoord(c),this._convertFromCellCoord(f+1),this._convertFromCellCoord(c+1)))&&i.call(this,e,t,n,r,l,a,o,s))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;let e=this.cells,t=3+this.cells.length+1+1,n=0;for(let e of this.cells)n+=e.length;let r=new Int32Array(t+n+this.keys.length+this.bboxes.length);r[0]=this.extent,r[1]=this.n,r[2]=this.padding;let i=t;for(let t=0;t<e.length;t++){let n=e[t];r[3+t]=i,r.set(n,i),i+=n.length}return r[3+e.length]=i,r.set(this.keys,i),i+=this.keys.length,r[3+e.length+1]=i,r.set(this.bboxes,i),i+=this.bboxes.length,r.buffer}static serialize(e,t){let n=e.toArrayBuffer();return t&&t.push(n),{buffer:n}}static deserialize(e){return new ma(e.buffer)}}let ha={};function X(e,t,n={}){if(ha[e])throw Error(`${e} is already registered.`);Object.defineProperty(t,"_classRegistryKey",{value:e,writeable:!1}),ha[e]={klass:t,omit:n.omit||[],shallow:n.shallow||[]}}X(`Object`,Object),X(`Set`,Set),X(`TransferableGridIndex`,ma),X(`Color`,Ut),X(`Error`,Error),X(`AJAXError`,Ne),X(`ResolvedImage`,en),X(`StylePropertyFunction`,fi),X(`StyleExpression`,ci,{omit:[`_evaluator`]}),X(`ZoomDependentExpression`,J),X(`ZoomConstantExpression`,ui),X(`CompoundExpression`,Vr,{omit:[`_evaluate`]});for(let e in Br)Br[e]._classRegistryKey||X(`Expression_${e}`,Br[e]);function ga(e){return e&&typeof ArrayBuffer<`u`&&(e instanceof ArrayBuffer||e.constructor?.name===`ArrayBuffer`)}function _a(e){return e.$name||e.constructor._classRegistryKey}function va(e){return!function(e){if(typeof e!=`object`||!e)return!1;let t=_a(e);return t&&t!==`Object`}(e)&&(e==null||typeof e==`boolean`||typeof e==`number`||typeof e==`string`||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp||e instanceof Blob||e instanceof Error||ga(e)||ge(e)||ArrayBuffer.isView(e)||e instanceof ImageData)}function Z(e,t){if(va(e))return(ga(e)||ge(e))&&t&&t.push(e),ArrayBuffer.isView(e)&&t&&t.push(e.buffer),e instanceof ImageData&&t&&t.push(e.data.buffer),e;if(Array.isArray(e)){let n=[];for(let r of e)n.push(Z(r,t));return n}if(typeof e!=`object`)throw Error(`can't serialize object of type `+typeof e);let n=_a(e);if(!n)throw Error(`can't serialize object of unregistered class ${e.constructor.name}`);if(!ha[n])throw Error(`${n} is not registered.`);let{klass:r}=ha[n],i=r.serialize?r.serialize(e,t):{};if(r.serialize){if(i===t?.[t.length-1])throw Error(`statically serialized object won't survive transfer of $name property`)}else{for(let r in e){if(!e.hasOwnProperty(r)||ha[n].omit.includes(r))continue;let a=e[r];i[r]=ha[n].shallow.includes(r)?a:Z(a,t)}e instanceof Error&&(i.message=e.message)}if(i.$name)throw Error(`$name property is reserved for worker serialization logic.`);return n!==`Object`&&(i.$name=n),i}function ya(e){if(va(e))return e;if(Array.isArray(e))return e.map(ya);if(typeof e!=`object`)throw Error(`can't deserialize object of type `+typeof e);let t=_a(e)||`Object`;if(!ha[t])throw Error(`can't deserialize unregistered class ${t}`);let{klass:n}=ha[t];if(!n)throw Error(`can't deserialize unregistered class ${t}`);if(n.deserialize)return n.deserialize(e);let r=Object.create(n.prototype);for(let n of Object.keys(e)){if(n===`$name`)continue;let i=e[n];r[n]=ha[t].shallow.includes(n)?i:ya(i)}return r}class ba{constructor(){this.first=!0}update(e,t){let n=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=n,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=n,!0):(this.lastFloorZoom>n?(this.lastIntegerZoom=n+1,this.lastIntegerZoomTime=t):this.lastFloorZoom<n&&(this.lastIntegerZoom=n,this.lastIntegerZoomTime=t),e!==this.lastZoom&&(this.lastZoom=e,this.lastFloorZoom=n,!0))}}function xa(e){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(e))}function Sa(e){return/[\u02EA\u02EB\u1100-\u11FF\u1400-\u167F\u18B0-\u18F5\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303F\u3041-\u3096\u309D-\u30FB\u30FD-\u30FF\u3105-\u312F\u3131-\u318E\u3190-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\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]|\uD802[\uDD80-\uDD9F]|\uD805[\uDD80-\uDDFF]|\uD806[\uDE00-\uDEBF]|\uD811[\uDC00-\uDE7F]|\uD81B[\uDFE0-\uDFE4\uDFF0-\uDFF6]|[\uD81C-\uD822\uD83D\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD30-\uDEFB]|\uD833[\uDEC0-\uDFCF]|\uD834[\uDC00-\uDDFF\uDEE0-\uDF7F]|\uD836[\uDC00-\uDEAF]|\uD83C[\uDC00-\uDE00\uDF00-\uDFFF]|\uD83E[\uDD00-\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))}function Ca(e){return/\s/u.test(String.fromCodePoint(e))}function wa(e){for(let t of e)if(Sa(t.codePointAt(0)))return!0;return!1}function Ta(e){for(let t of e)if(!Oa(t.codePointAt(0)))return!1;return!0}function Ea(e){let t=e.map((e=>{try{return RegExp(`\\p{sc=${e}}`,`u`).source}catch{return null}})).filter((e=>e));return new RegExp(t.join(`|`),`u`)}let Da=Ea([`Arab`,`Dupl`,`Mong`,`Ougr`,`Syrc`]);function Oa(e){return!Da.test(String.fromCodePoint(e))}function ka(e){return!(Sa(e)||(t=e,/[\xA7\xA9\xAE\xB1\xBC-\xBE\xD7\xF7\u2016\u2020\u2021\u2030\u2031\u203B\u203C\u2042\u2047-\u2049\u2051\u2100-\u218F\u221E\u2234\u2235\u2300-\u2307\u230C-\u231F\u2324-\u2328\u232B\u237D-\u239A\u23BE-\u23CD\u23CF\u23D1-\u23DB\u23E2-\u2422\u2424-\u24FF\u25A0-\u2619\u2620-\u2767\u2776-\u2793\u2B12-\u2B2F\u2B50-\u2B59\u2BB8-\u2BEB\u3000-\u303F\u30A0-\u30FF\uE000-\uF8FF\uFE30-\uFE6F\uFF00-\uFFEF\uFFFC\uFFFD]|[\uDB80-\uDBFF][\uDC00-\uDFFF]/gim.test(String.fromCodePoint(t))));var t}let Aa=Ea(`Adlm.Arab.Armi.Avst.Chrs.Cprt.Egyp.Elym.Gara.Hatr.Hebr.Hung.Khar.Lydi.Mand.Mani.Mend.Merc.Mero.Narb.Nbat.Nkoo.Orkh.Palm.Phli.Phlp.Phnx.Prti.Rohg.Samr.Sarb.Sogo.Syrc.Thaa.Todr.Yezi`.split(`.`));function ja(e){return Aa.test(String.fromCodePoint(e))}function Ma(e,t){return!(!t&&ja(e)||/[\u0900-\u0DFF\u0F00-\u109F\u1780-\u17FF]/gim.test(String.fromCodePoint(e)))}function Na(e){for(let t of e)if(ja(t.codePointAt(0)))return!0;return!1}let Pa=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus=`unavailable`,this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(e){this.pluginStatus=e.pluginStatus,this.pluginURL=e.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(e){if(Pa.isParsed())throw Error(`RTL text plugin already registered.`);this.applyArabicShaping=e.applyArabicShaping,this.processBidirectionalText=e.processBidirectionalText,this.processStyledBidirectionalText=e.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return this.applyArabicShaping!=null&&this.processBidirectionalText!=null&&this.processStyledBidirectionalText!=null}getRTLTextPluginStatus(){return this.pluginStatus}syncState(e,n){return t(this,void 0,void 0,(function*(){if(this.isParsed())return this.getState();if(e.pluginStatus!==`loading`)return this.setState(e),e;let t=e.pluginURL,r=new Promise((e=>{this.loadScriptResolve=e}));n(t);let i=new Promise((e=>setTimeout((()=>e()),this.TIMEOUT)));if(yield Promise.race([r,i]),this.isParsed()){let e={pluginStatus:`loaded`,pluginURL:t};return this.setState(e),e}throw this.setState({pluginStatus:`error`,pluginURL:``}),Error(`RTL Text Plugin failed to import scripts from ${t}`)}))}};class Fa{constructor(e,t){this.isSupportedScript=Ia,this.zoom=e,t?(this.now=t.now||0,this.fadeDuration=t.fadeDuration||0,this.zoomHistory=t.zoomHistory||new ba,this.transition=t.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new ba,this.transition={})}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){let e=this.zoom,t=e-Math.floor(e),n=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:t+(1-t)*n}:{fromScale:.5,toScale:1,t:1-(1-n)*t}}}function Ia(e){return function(e,t){for(let n of e)if(!Ma(n.codePointAt(0),t))return!1;return!0}(e,Pa.getRTLTextPluginStatus()===`loaded`)}let La=`-transition`;class Ra{constructor(e,t,n){this.property=e,this.value=t,this.expression=function(e,t,n){if(ti(e))return new fi(e,t);if(q(e)){let r=di(e,t,n);if(r.result===`error`)throw Error(r.value.map((e=>`${e.key}: ${e.message}`)).join(`, `));return r.value}{let n=e;return t.type===`color`&&typeof e==`string`?n=Ut.parse(e):t.type!==`padding`||typeof e!=`number`&&!Array.isArray(e)?t.type!==`numberArray`||typeof e!=`number`&&!Array.isArray(e)?t.type!==`colorArray`||typeof e!=`string`&&!Array.isArray(e)?t.type===`variableAnchorOffsetCollection`&&Array.isArray(e)?n=$t.parse(e):t.type===`projectionDefinition`&&typeof e==`string`&&(n=tn.parse(e)):n=Xt.parse(e):n=Yt.parse(e):n=Jt.parse(e),{globalStateRefs:new Set,_globalState:null,kind:`constant`,evaluate:()=>n}}}(t===void 0?e.specification.default:t,e.specification,n)}isDataDriven(){return this.expression.kind===`source`||this.expression.kind===`composite`}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(e,t,n){return this.property.possiblyEvaluate(this,e,t,n)}}class za{constructor(e,t){this.property=e,this.value=new Ra(e,void 0,t)}transitioned(e,t){return new Va(this.property,this.value,t,oe({},e.transition,this.transition),e.now)}untransitioned(){return new Va(this.property,this.value,null,{},0)}}class Ba{constructor(e,t){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._globalState=t}hasProperty(e){return e in this._properties.defaultTransitionablePropertyValues}getValue(e){return ue(this._values[e].value.value)}setValue(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new za(this._values[e].property,this._globalState)),this._values[e].value=new Ra(this._values[e].property,t===null?void 0:ue(t),this._globalState)}getTransition(e){return ue(this._values[e].transition)}setTransition(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new za(this._values[e].property,this._globalState)),this._values[e].transition=ue(t)||void 0}serialize(){let e={};for(let t of Object.keys(this._values)){let n=this.getValue(t);n!==void 0&&(e[t]=n);let r=this.getTransition(t);r!==void 0&&(e[`${t}${La}`]=r)}return e}transitioned(e,t){let n=new Ha(this._properties);for(let r of Object.keys(this._values))n._values[r]=this._values[r].transitioned(e,t._values[r]);return n}untransitioned(){let e=new Ha(this._properties);for(let t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class Va{constructor(e,t,n,r,i){this.property=e,this.value=t,this.begin=i+r.delay||0,this.end=this.begin+r.duration||0,e.specification.transition&&(r.delay||r.duration)&&(this.prior=n)}possiblyEvaluate(e,t,n){let r=e.now||0,i=this.value.possiblyEvaluate(e,t,n),a=this.prior;if(a){if(r>this.end||this.value.isDataDriven())return this.prior=null,i;if(r<this.begin)return a.possiblyEvaluate(e,t,n);{let o=(r-this.begin)/(this.end-this.begin);return this.property.interpolate(a.possiblyEvaluate(e,t,n),i,j(o))}}return i}}class Ha{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,t,n){let r=new Ga(this._properties);for(let i of Object.keys(this._values))r._values[i]=this._values[i].possiblyEvaluate(e,t,n);return r}hasTransition(){for(let e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class Ua{constructor(e,t){this._properties=e,this._values=Object.create(e.defaultPropertyValues),this._globalState=t}hasValue(e){return this._values[e].value!==void 0}hasProperty(e){return e in this._properties.defaultPropertyValues}getValue(e){return ue(this._values[e].value)}setValue(e,t){this._values[e]=new Ra(this._values[e].property,t===null?void 0:ue(t),this._globalState)}serialize(){let e={};for(let t of Object.keys(this._values)){let n=this.getValue(t);n!==void 0&&(e[t]=n)}return e}possiblyEvaluate(e,t,n){let r=new Ga(this._properties);for(let i of Object.keys(this._values))r._values[i]=this._values[i].possiblyEvaluate(e,t,n);return r}}class Wa{constructor(e,t,n){this.property=e,this.value=t,this.parameters=n}isConstant(){return this.value.kind===`constant`}constantOr(e){return this.value.kind===`constant`?this.value.value:e}evaluate(e,t,n,r){return this.property.evaluate(this.value,this.parameters,e,t,n,r)}}class Ga{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class Q{constructor(e){this.specification=e}possiblyEvaluate(e,t){if(e.isDataDriven())throw Error(`Value should not be data driven`);return e.expression.evaluate(t)}interpolate(e,t,n){let r=Dn[this.specification.type];return r?r(e,t,n):e}}class Ka{constructor(e,t){this.specification=e,this.overrides=t}possiblyEvaluate(e,t,n,r){return new Wa(this,e.expression.kind===`constant`||e.expression.kind===`camera`?{kind:`constant`,value:e.expression.evaluate(t,null,{},n,r)}:e.expression,t)}interpolate(e,t,n){if(e.value.kind!==`constant`||t.value.kind!==`constant`)return e;if(e.value.value===void 0||t.value.value===void 0)return new Wa(this,{kind:`constant`,value:void 0},e.parameters);let r=Dn[this.specification.type];if(r){let i=r(e.value.value,t.value.value,n);return new Wa(this,{kind:`constant`,value:i},e.parameters)}return e}evaluate(e,t,n,r,i,a){return e.kind===`constant`?e.value:e.evaluate(t,n,r,i,a)}}class qa extends Ka{possiblyEvaluate(e,t,n,r){if(e.value===void 0)return new Wa(this,{kind:`constant`,value:void 0},t);if(e.expression.kind===`constant`){let i=e.expression.evaluate(t,null,{},n,r),a=e.property.specification.type===`resolvedImage`&&typeof i!=`string`?i.name:i,o=this._calculate(a,a,a,t);return new Wa(this,{kind:`constant`,value:o},t)}if(e.expression.kind===`camera`){let n=this._calculate(e.expression.evaluate({zoom:t.zoom-1}),e.expression.evaluate({zoom:t.zoom}),e.expression.evaluate({zoom:t.zoom+1}),t);return new Wa(this,{kind:`constant`,value:n},t)}return new Wa(this,e.expression,t)}evaluate(e,t,n,r,i,a){if(e.kind===`source`){let o=e.evaluate(t,n,r,i,a);return this._calculate(o,o,o,t)}return e.kind===`composite`?this._calculate(e.evaluate({zoom:Math.floor(t.zoom)-1},n,r),e.evaluate({zoom:Math.floor(t.zoom)},n,r),e.evaluate({zoom:Math.floor(t.zoom)+1},n,r),t):e.value}_calculate(e,t,n,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:n,to:t}}interpolate(e){return e}}class Ja{constructor(e){this.specification=e}possiblyEvaluate(e,t,n,r){if(e.value!==void 0){if(e.expression.kind===`constant`){let i=e.expression.evaluate(t,null,{},n,r);return this._calculate(i,i,i,t)}return this._calculate(e.expression.evaluate(new Fa(Math.floor(t.zoom-1),t)),e.expression.evaluate(new Fa(Math.floor(t.zoom),t)),e.expression.evaluate(new Fa(Math.floor(t.zoom+1),t)),t)}}_calculate(e,t,n,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:n,to:t}}interpolate(e){return e}}class Ya{constructor(e){this.specification=e}possiblyEvaluate(e,t,n,r){return!!e.expression.evaluate(t,null,{},n,r)}interpolate(){return!1}}class Xa{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(let t in e){let n=e[t];n.specification.overridable&&this.overridableProperties.push(t);let r=this.defaultPropertyValues[t]=new Ra(n,void 0,void 0),i=this.defaultTransitionablePropertyValues[t]=new za(n,void 0);this.defaultTransitioningPropertyValues[t]=i.untransitioned(),this.defaultPossiblyEvaluatedValues[t]=r.possiblyEvaluate({})}}}X(`DataDrivenProperty`,Ka),X(`DataConstantProperty`,Q),X(`CrossFadedDataDrivenProperty`,qa),X(`CrossFadedProperty`,Ja),X(`ColorRampProperty`,Ya);let Za=` is a PAINT property not a LAYOUT property. Use get/setPaintProperty instead?`,Qa=` is a LAYOUT property not a PAINT property. Use get/setLayoutProperty instead?`;class $a extends Ve{constructor(e,t,n){if(super(),this.id=e.id,this.type=e.type,this._globalState=n,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},this._visibilityExpression=function(e,t){return new oa(e,t)}(this.visibility,n),e.type!==`custom`&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type!==`background`&&(this.source=e.source,this.sourceLayer=e[`source-layer`],this.filter=e.filter,this._featureFilter=vi(e.filter,n)),t.layout&&(this._unevaluatedLayout=new Ua(t.layout,n)),t.paint)){this._transitionablePaint=new Ba(t.paint,n);for(let t in e.paint)this.setPaintProperty(t,e.paint[t],{validate:!1});for(let t in e.layout)this.setLayoutProperty(t,e.layout[t],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Ga(t.paint)}}setFilter(e){this.filter=e,this._featureFilter=vi(e,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){if(e===`visibility`)return this.visibility;if(this._transitionablePaint?.hasProperty(e))throw Error(e+Za);if(!this._unevaluatedLayout)throw Error(`Cannot get layout property "${e}" on layer type "${this.type}" which has no layout properties.`);return this._unevaluatedLayout.getValue(e)}getLayoutAffectingGlobalStateRefs(){let e=new Set;for(let t of this._visibilityExpression.getGlobalStateRefs())e.add(t);if(this._unevaluatedLayout)for(let t in this._unevaluatedLayout._values){let n=this._unevaluatedLayout._values[t];for(let t of n.getGlobalStateRefs())e.add(t)}for(let t of this._featureFilter.getGlobalStateRefs())e.add(t);return e}getPaintAffectingGlobalStateRefs(){let e=new globalThis.Map;if(this._transitionablePaint)for(let t in this._transitionablePaint._values){let n=this._transitionablePaint._values[t].value;for(let r of n.getGlobalStateRefs()){let i=e.get(r)??[];i.push({name:t,value:n.value}),e.set(r,i)}}return e}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(e,t,n={}){if(e===`visibility`)return this.visibility=t,this._visibilityExpression.setValue(t),void this.recalculateVisibility();this._transitionablePaint?.hasProperty(e)?this.fire(new Be(Error(e+Za))):t!=null&&this._validate(fa,`layers.${this.id}.layout.${e}`,e,t,n)||this._unevaluatedLayout.setValue(e,t)}getPaintProperty(e){if(e.endsWith(La)){let t=e.slice(0,-11);if(t===`visibility`||this._unevaluatedLayout?.hasProperty(t))throw Error(e+Qa);return this._transitionablePaint.getTransition(t)}if(e===`visibility`||this._unevaluatedLayout?.hasProperty(e))throw Error(e+Qa);return this._transitionablePaint.getValue(e)}setPaintProperty(e,t,n={}){if(e===`visibility`||this._unevaluatedLayout?.hasProperty(e))return this.fire(new Be(Error(e+Qa))),!1;if(t!=null&&this._validate(da,`layers.${this.id}.paint.${e}`,e,t,n))return!1;if(e.endsWith(La))return this._transitionablePaint.setTransition(e.slice(0,-11),t||void 0),!1;{let n=this._transitionablePaint._values[e],r=n.property.specification[`property-type`]===`cross-faded-data-driven`,i=n.value.isDataDriven(),a=n.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);let o=this._transitionablePaint._values[e].value;return o.isDataDriven()||i||r||this._handleOverridablePaintPropertyUpdate(e,a,o)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,t,n){return!1}isHidden(e=this.minzoom,t=!1){return!!(this.minzoom&&e<(t?Math.floor(this.minzoom):this.minzoom))||!!(this.maxzoom&&e>=this.maxzoom)||this._evaluatedVisibility===`none`}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculateVisibility(){this._evaluatedVisibility=this._visibilityExpression.evaluate()}recalculate(e,t){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){let e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout?.serialize(),paint:this._transitionablePaint?.serialize()};return this.visibility&&(e.layout||={},e.layout.visibility=this.visibility),le(e,((e,t)=>!(e===void 0||t===`layout`&&!Object.keys(e).length||t===`paint`&&!Object.keys(e).length)))}_validate(e,t,n,r,i={}){return!1!==i?.validate&&pa(this,e.call(ca,{key:t,layerType:this.type,objectKey:n,value:r,styleSpec:M,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(let e in this.paint._values){let t=this.paint.get(e);if(t instanceof Wa&&G(t.property.specification)&&(t.value.kind===`source`||t.value.kind===`composite`)&&t.value.isStateDependent)return!0}return!1}}let eo;var to={get paint(){return eo||=new Xa({"raster-opacity":new Q(M.paint_raster[`raster-opacity`]),"raster-hue-rotate":new Q(M.paint_raster[`raster-hue-rotate`]),"raster-brightness-min":new Q(M.paint_raster[`raster-brightness-min`]),"raster-brightness-max":new Q(M.paint_raster[`raster-brightness-max`]),"raster-saturation":new Q(M.paint_raster[`raster-saturation`]),"raster-contrast":new Q(M.paint_raster[`raster-contrast`]),resampling:new Q(M.paint_raster.resampling),"raster-resampling":new Q(M.paint_raster[`raster-resampling`]),"raster-fade-duration":new Q(M.paint_raster[`raster-fade-duration`])})}};class no extends $a{constructor(e,t){super(e,to,t)}}let ro={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class io{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class ao{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,t){return e._trim(),t&&(e.isTransferred=!0,t.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){let t=Object.create(this.prototype);return t.arrayBuffer=e.arrayBuffer,t.length=e.length,t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement,t._refreshViews(),t}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);let t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}_refreshViews(){throw Error(`_refreshViews() must be implemented by each concrete StructArray layout`)}freeBufferAfterUpload(){this.arrayBuffer=new ArrayBuffer(0),this._refreshViews()}}function oo(e,t=1){let n=0,r=0;return{members:e.map((e=>{let i=ro[e.type].BYTES_PER_ELEMENT,a=n=so(n,Math.max(t,i)),o=e.components||1;return r=Math.max(r,i),n+=i*o,{name:e.name,type:e.type,components:o,offset:a}})),size:so(n,Math.max(r,t)),alignment:t}}function so(e,t){return Math.ceil(e/t)*t}class co extends ao{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){let n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){let r=2*e;return this.int16[r+0]=t,this.int16[r+1]=n,e}}co.prototype.bytesPerElement=4,X(`StructArrayLayout2i4`,co);class lo extends ao{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){let i=3*e;return this.int16[i+0]=t,this.int16[i+1]=n,this.int16[i+2]=r,e}}lo.prototype.bytesPerElement=6,X(`StructArrayLayout3i6`,lo);class uo extends ao{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r){let i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){let a=4*e;return this.int16[a+0]=t,this.int16[a+1]=n,this.int16[a+2]=r,this.int16[a+3]=i,e}}uo.prototype.bytesPerElement=8,X(`StructArrayLayout4i8`,uo);class fo extends ao{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i,a)}emplace(e,t,n,r,i,a,o){let s=6*e;return this.int16[s+0]=t,this.int16[s+1]=n,this.int16[s+2]=r,this.int16[s+3]=i,this.int16[s+4]=a,this.int16[s+5]=o,e}}fo.prototype.bytesPerElement=12,X(`StructArrayLayout2i4i12`,fo);class po extends ao{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i,a)}emplace(e,t,n,r,i,a,o){let s=4*e,c=8*e;return this.int16[s+0]=t,this.int16[s+1]=n,this.uint8[c+4]=r,this.uint8[c+5]=i,this.uint8[c+6]=a,this.uint8[c+7]=o,e}}po.prototype.bytesPerElement=8,X(`StructArrayLayout2i4ub8`,po);class mo extends ao{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){let n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){let r=2*e;return this.float32[r+0]=t,this.float32[r+1]=n,e}}mo.prototype.bytesPerElement=8,X(`StructArrayLayout2f8`,mo);class ho extends ao{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a,o,s,c,l){let u=this.length;return this.resize(u+1),this.emplace(u,e,t,n,r,i,a,o,s,c,l)}emplace(e,t,n,r,i,a,o,s,c,l,u){let d=10*e;return this.uint16[d+0]=t,this.uint16[d+1]=n,this.uint16[d+2]=r,this.uint16[d+3]=i,this.uint16[d+4]=a,this.uint16[d+5]=o,this.uint16[d+6]=s,this.uint16[d+7]=c,this.uint16[d+8]=l,this.uint16[d+9]=u,e}}ho.prototype.bytesPerElement=20,X(`StructArrayLayout10ui20`,ho);class go extends ao{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a,o,s){let c=this.length;return this.resize(c+1),this.emplace(c,e,t,n,r,i,a,o,s)}emplace(e,t,n,r,i,a,o,s,c){let l=8*e;return this.uint16[l+0]=t,this.uint16[l+1]=n,this.uint16[l+2]=r,this.uint16[l+3]=i,this.uint16[l+4]=a,this.uint16[l+5]=o,this.uint16[l+6]=s,this.uint16[l+7]=c,e}}go.prototype.bytesPerElement=16,X(`StructArrayLayout8ui16`,go);class _o extends ao{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a,o,s,c,l,u,d){let f=this.length;return this.resize(f+1),this.emplace(f,e,t,n,r,i,a,o,s,c,l,u,d)}emplace(e,t,n,r,i,a,o,s,c,l,u,d,f){let p=12*e;return this.int16[p+0]=t,this.int16[p+1]=n,this.int16[p+2]=r,this.int16[p+3]=i,this.uint16[p+4]=a,this.uint16[p+5]=o,this.uint16[p+6]=s,this.uint16[p+7]=c,this.int16[p+8]=l,this.int16[p+9]=u,this.int16[p+10]=d,this.int16[p+11]=f,e}}_o.prototype.bytesPerElement=24,X(`StructArrayLayout4i4ui4i24`,_o);class vo extends ao{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){let i=3*e;return this.float32[i+0]=t,this.float32[i+1]=n,this.float32[i+2]=r,e}}vo.prototype.bytesPerElement=12,X(`StructArrayLayout3f12`,vo);class yo extends ao{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){let t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint32[1*e+0]=t,e}}yo.prototype.bytesPerElement=4,X(`StructArrayLayout1ul4`,yo);class bo extends ao{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a,o,s,c){let l=this.length;return this.resize(l+1),this.emplace(l,e,t,n,r,i,a,o,s,c)}emplace(e,t,n,r,i,a,o,s,c,l){let u=10*e,d=5*e;return this.int16[u+0]=t,this.int16[u+1]=n,this.int16[u+2]=r,this.int16[u+3]=i,this.int16[u+4]=a,this.int16[u+5]=o,this.uint32[d+3]=s,this.uint16[u+8]=c,this.uint16[u+9]=l,e}}bo.prototype.bytesPerElement=20,X(`StructArrayLayout6i1ul2ui20`,bo);class xo extends ao{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i,a)}emplace(e,t,n,r,i,a,o){let s=6*e;return this.int16[s+0]=t,this.int16[s+1]=n,this.int16[s+2]=r,this.int16[s+3]=i,this.int16[s+4]=a,this.int16[s+5]=o,e}}xo.prototype.bytesPerElement=12,X(`StructArrayLayout2i2i2i12`,xo);class So extends ao{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i){let a=this.length;return this.resize(a+1),this.emplace(a,e,t,n,r,i)}emplace(e,t,n,r,i,a){let o=4*e,s=8*e;return this.float32[o+0]=t,this.float32[o+1]=n,this.float32[o+2]=r,this.int16[s+6]=i,this.int16[s+7]=a,e}}So.prototype.bytesPerElement=16,X(`StructArrayLayout2f1f2i16`,So);class Co extends ao{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i,a)}emplace(e,t,n,r,i,a,o){let s=16*e,c=4*e,l=8*e;return this.uint8[s+0]=t,this.uint8[s+1]=n,this.float32[c+1]=r,this.float32[c+2]=i,this.int16[l+6]=a,this.int16[l+7]=o,e}}Co.prototype.bytesPerElement=16,X(`StructArrayLayout2ub2f2i16`,Co);class wo extends ao{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){let i=3*e;return this.uint16[i+0]=t,this.uint16[i+1]=n,this.uint16[i+2]=r,e}}wo.prototype.bytesPerElement=6,X(`StructArrayLayout3ui6`,wo);class To extends ao{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){let _=this.length;return this.resize(_+1),this.emplace(_,e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}emplace(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_){let v=24*e,y=12*e,b=48*e;return this.int16[v+0]=t,this.int16[v+1]=n,this.uint16[v+2]=r,this.uint16[v+3]=i,this.uint32[y+2]=a,this.uint32[y+3]=o,this.uint32[y+4]=s,this.uint16[v+10]=c,this.uint16[v+11]=l,this.uint16[v+12]=u,this.float32[y+7]=d,this.float32[y+8]=f,this.uint8[b+36]=p,this.uint8[b+37]=m,this.uint8[b+38]=h,this.uint32[y+10]=g,this.int16[v+22]=_,e}}To.prototype.bytesPerElement=48,X(`StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48`,To);class Eo extends ao{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D){let O=this.length;return this.resize(O+1),this.emplace(O,e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D)}emplace(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O){let k=32*e,A=16*e;return this.int16[k+0]=t,this.int16[k+1]=n,this.int16[k+2]=r,this.int16[k+3]=i,this.int16[k+4]=a,this.int16[k+5]=o,this.int16[k+6]=s,this.int16[k+7]=c,this.uint16[k+8]=l,this.uint16[k+9]=u,this.uint16[k+10]=d,this.uint16[k+11]=f,this.uint16[k+12]=p,this.uint16[k+13]=m,this.uint16[k+14]=h,this.uint16[k+15]=g,this.uint16[k+16]=_,this.uint16[k+17]=v,this.uint16[k+18]=y,this.uint16[k+19]=b,this.uint16[k+20]=x,this.uint16[k+21]=S,this.uint16[k+22]=C,this.uint32[A+12]=w,this.float32[A+13]=T,this.float32[A+14]=E,this.uint16[k+30]=D,this.uint16[k+31]=O,e}}Eo.prototype.bytesPerElement=64,X(`StructArrayLayout8i15ui1ul2f2ui64`,Eo);class Do extends ao{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){let t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.float32[1*e+0]=t,e}}Do.prototype.bytesPerElement=4,X(`StructArrayLayout1f4`,Do);class Oo extends ao{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){let i=3*e;return this.uint16[6*e+0]=t,this.float32[i+1]=n,this.float32[i+2]=r,e}}Oo.prototype.bytesPerElement=12,X(`StructArrayLayout1ui2f12`,Oo);class ko extends ao{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){let i=4*e;return this.uint32[2*e+0]=t,this.uint16[i+2]=n,this.uint16[i+3]=r,e}}ko.prototype.bytesPerElement=8,X(`StructArrayLayout1ul2ui8`,ko);class Ao extends ao{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){let n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){let r=2*e;return this.uint16[r+0]=t,this.uint16[r+1]=n,e}}Ao.prototype.bytesPerElement=4,X(`StructArrayLayout2ui4`,Ao);class jo extends ao{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){let t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint16[1*e+0]=t,e}}jo.prototype.bytesPerElement=2,X(`StructArrayLayout1ui2`,jo);class Mo extends ao{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r){let i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){let a=4*e;return this.float32[a+0]=t,this.float32[a+1]=n,this.float32[a+2]=r,this.float32[a+3]=i,e}}Mo.prototype.bytesPerElement=16,X(`StructArrayLayout4f16`,Mo);class No extends io{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new n(this.anchorPointX,this.anchorPointY)}}No.prototype.size=20;class Po extends bo{get(e){return new No(this,e)}}X(`CollisionBoxArray`,Po);class Fo extends io{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}Fo.prototype.size=48;class Io extends To{get(e){return new Fo(this,e)}}X(`PlacedSymbolArray`,Io);class Lo extends io{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}Lo.prototype.size=64;class Ro extends Eo{get(e){return new Lo(this,e)}}X(`SymbolInstanceArray`,Ro);class zo extends Do{getoffsetX(e){return this.float32[1*e+0]}}X(`GlyphOffsetArray`,zo);class Bo extends lo{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}X(`SymbolLineVertexArray`,Bo);class Vo extends io{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]}}Vo.prototype.size=12;class Ho extends Oo{get(e){return new Vo(this,e)}}X(`TextAnchorOffsetArray`,Ho);class Uo extends io{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]}}Uo.prototype.size=8;class Wo extends ko{get(e){return new Uo(this,e)}}X(`FeatureIndexArray`,Wo);class Go extends co{}class Ko extends co{}class qo extends co{}class Jo extends fo{}class Yo extends po{}class Xo extends mo{}class Zo extends ho{}class Qo extends go{}class $o extends _o{}class es extends vo{}class ts extends yo{}class ns extends xo{}class rs extends Co{}class is extends wo{}class as extends Ao{}let{members:os}=oo([{name:`a_pos`,components:2,type:`Int16`}],4);class ss{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(e,t,n,r){let i=this.segments[this.segments.length-1];return e>ss.MAX_VERTEX_ARRAY_LENGTH&&fe(`Max vertices per segment is ${ss.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${ss.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!i||i.vertexLength+e>ss.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==r?this.createNewSegment(t,n,r):i}createNewSegment(e,t,n){let r={vertexOffset:e.length,primitiveOffset:t.length,vertexLength:0,primitiveLength:0,vaos:{}};return n!==void 0&&(r.sortKey=n),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(r),r}getOrCreateLatestSegment(e,t,n){return this.prepareSegment(0,e,t,n)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(let e of this.segments)for(let t in e.vaos)e.vaos[t].destroy()}static simpleSegment(e,t,n,r){return new ss([{vertexOffset:e,primitiveOffset:t,vertexLength:n,primitiveLength:r,vaos:{},sortKey:0}])}}function cs(e,t){return 256*(e=ie(Math.floor(e),0,255))+ie(Math.floor(t),0,255)}ss.MAX_VERTEX_ARRAY_LENGTH=2**16-1,X(`SegmentVector`,ss);let ls=oo([{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`}]),us=oo([{name:`a_dasharray_from`,components:4,type:`Uint16`},{name:`a_dasharray_to`,components:4,type:`Uint16`}]);var ds,fs,ps,ms={exports:{}},hs={exports:{}},gs={exports:{}},_s=r(function(){if(ps)return ms.exports;ps=1;var e=(ds||(ds=1,hs.exports=function(e,t){var n,r,i,a,o,s,c,l;for(r=e.length-(n=3&e.length),i=t,o=3432918353,s=461845907,l=0;l<r;)c=255&e.charCodeAt(l)|(255&e.charCodeAt(++l))<<8|(255&e.charCodeAt(++l))<<16|(255&e.charCodeAt(++l))<<24,++l,i=27492+(65535&(a=5*(65535&(i=(i^=c=(65535&(c=(c=(65535&c)*o+(((c>>>16)*o&65535)<<16)&4294967295)<<15|c>>>17))*s+(((c>>>16)*s&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(a>>>16)&65535)<<16);switch(c=0,n){case 3:c^=(255&e.charCodeAt(l+2))<<16;case 2:c^=(255&e.charCodeAt(l+1))<<8;case 1:i^=c=(65535&(c=(c=(65535&(c^=255&e.charCodeAt(l)))*o+(((c>>>16)*o&65535)<<16)&4294967295)<<15|c>>>17))*s+(((c>>>16)*s&65535)<<16)&4294967295}return i^=e.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0}),hs.exports),t=(fs||(fs=1,gs.exports=function(e,t){for(var n,r=e.length,i=t^r,a=0;r>=4;)n=1540483477*(65535&(n=255&e.charCodeAt(a)|(255&e.charCodeAt(++a))<<8|(255&e.charCodeAt(++a))<<16|(255&e.charCodeAt(++a))<<24))+((1540483477*(n>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),r-=4,++a;switch(r){case 3:i^=(255&e.charCodeAt(a+2))<<16;case 2:i^=(255&e.charCodeAt(a+1))<<8;case 1:i=1540483477*(65535&(i^=255&e.charCodeAt(a)))+((1540483477*(i>>>16)&65535)<<16)}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0}),gs.exports);return ms.exports=e,ms.exports.murmur3=e,ms.exports.murmur2=t,ms.exports}());class vs{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,n,r){this.ids.push(ys(e)),this.positions.push(t,n,r)}getPositions(e){if(!this.indexed)throw Error(`Trying to get index, but feature positions are not indexed`);let t=ys(e),n=0,r=this.ids.length-1;for(;n<r;){let e=n+r>>1;this.ids[e]>=t?r=e:n=e+1}let i=[];for(;this.ids[n]===t;)i.push({index:this.positions[3*n],start:this.positions[3*n+1],end:this.positions[3*n+2]}),n++;return i}static serialize(e,t){let n=new Float64Array(e.ids),r=new Uint32Array(e.positions);return bs(n,r,0,n.length-1),t&&t.push(n.buffer,r.buffer),{ids:n,positions:r}}static deserialize(e){let t=new vs;return t.ids=e.ids,t.positions=e.positions,t.indexed=!0,t}}function ys(e){let t=+e;return!isNaN(t)&&t<=2**53-1?t:_s(String(e))}function bs(e,t,n,r){for(;n<r;){let i=e[n+r>>1],a=n-1,o=r+1;for(;;){do a++;while(e[a]<i);do o--;while(e[o]>i);if(a>=o)break;xs(e,a,o),xs(t,3*a,3*o),xs(t,3*a+1,3*o+1),xs(t,3*a+2,3*o+2)}o-n<r-o?(bs(e,t,n,o),n=o+1):(bs(e,t,o+1,r),r=o)}}function xs(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}X(`FeaturePositionMap`,vs);class Ss{constructor(e,t){this.gl=e.gl,this.location=t}}class Cs extends Ss{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1f(this.location,e))}}class ws extends Ss{constructor(e,t){super(e,t),this.current=[0,0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]&&e[3]===this.current[3]||(this.current=e,this.gl.uniform4f(this.location,e[0],e[1],e[2],e[3]))}}class Ts extends Ss{constructor(e,t){super(e,t),this.current=Ut.transparent}set(e){e.r===this.current.r&&e.g===this.current.g&&e.b===this.current.b&&e.a===this.current.a||(this.current=e,this.gl.uniform4f(this.location,e.r,e.g,e.b,e.a))}}let Es=new Float32Array(16);function Ds(e){return[cs(255*e.r,255*e.g),cs(255*e.b,255*e.a)]}class Os{constructor(e,t,n){this.value=e,this.uniformNames=t.map((e=>`u_${e}`)),this.type=n}setUniform(e,t,n){e.set(n.constantOr(this.value))}getBinding(e,t,n){return this.type===`color`?new Ts(e,t):new Cs(e,t)}}class ks{constructor(e,t){this.uniformNames=t.map((e=>`u_${e}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,t){this.pixelRatioFrom=t.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=t.tlbr,this.patternTo=e.tlbr}setConstantDashPositions(e,t){this.dashTo=[0,e.y,e.height,e.width],this.dashFrom=[0,t.y,t.height,t.width]}setUniform(e,t,n,r){let i=null;r===`u_pattern_to`?i=this.patternTo:r===`u_pattern_from`?i=this.patternFrom:r===`u_dasharray_to`?i=this.dashTo:r===`u_dasharray_from`?i=this.dashFrom:r===`u_pixel_ratio_to`?i=this.pixelRatioTo:r===`u_pixel_ratio_from`&&(i=this.pixelRatioFrom),i!==null&&e.set(i)}getBinding(e,t,n){return n.startsWith(`u_pattern`)||n.startsWith(`u_dasharray_`)?new ws(e,t):new Cs(e,t)}}class As{constructor(e,t,n,r){this.expression=e,this.type=n,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:`a_${e}`,type:`Float32`,components:n===`color`?2:1,offset:0}))),this.paintVertexArray=new r}populatePaintArray(e,t,n){let r=this.paintVertexArray.length,i=this.expression.evaluate(new Fa(0,n),t,{},n.canonical,[],n.formattedSection);this.paintVertexArray.resize(e),this._setPaintValue(r,e,i)}updatePaintArray(e,t,n,r,i){let a=this.expression.evaluate(new Fa(0,i),n,r);this._setPaintValue(e,t,a)}_setPaintValue(e,t,n){if(this.type===`color`){let r=Ds(n);for(let n=e;n<t;n++)this.paintVertexArray.emplace(n,r[0],r[1])}else{for(let r=e;r<t;r++)this.paintVertexArray.emplace(r,n);this.maxValue=Math.max(this.maxValue,Math.abs(n))}}upload(e){var t;(t=this.paintVertexArray)!=null&&t.arrayBuffer.byteLength&&(this.paintVertexBuffer?.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class js{constructor(e,t,n,r,i,a){this.expression=e,this.uniformNames=t.map((e=>`u_${e}_t`)),this.type=n,this.useIntegerZoom=r,this.zoom=i,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:`a_${e}`,type:`Float32`,components:n===`color`?4:2,offset:0}))),this.paintVertexArray=new a}populatePaintArray(e,t,n){let r=this.expression.evaluate(new Fa(this.zoom,n),t,{},n.canonical,[],n.formattedSection),i=this.expression.evaluate(new Fa(this.zoom+1,n),t,{},n.canonical,[],n.formattedSection),a=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(a,e,r,i)}updatePaintArray(e,t,n,r,i){let a=this.expression.evaluate(new Fa(this.zoom,i),n,r),o=this.expression.evaluate(new Fa(this.zoom+1,i),n,r);this._setPaintValue(e,t,a,o)}_setPaintValue(e,t,n,r){if(this.type===`color`){let i=Ds(n),a=Ds(r);for(let n=e;n<t;n++)this.paintVertexArray.emplace(n,i[0],i[1],a[0],a[1])}else{for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,n,r);this.maxValue=Math.max(this.maxValue,Math.abs(n),Math.abs(r))}}upload(e){var t;(t=this.paintVertexArray)!=null&&t.arrayBuffer.byteLength&&(this.paintVertexBuffer?.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,t){let n=this.useIntegerZoom?Math.floor(t.zoom):t.zoom,r=ie(this.expression.interpolationFactor(n,this.zoom,this.zoom+1),0,1);e.set(r)}getBinding(e,t,n){return new Cs(e,t)}}class Ms{constructor(e,t,n,r,i,a){this.expression=e,this.type=t,this.useIntegerZoom=n,this.zoom=r,this.layerId=a,this.zoomInPaintVertexArray=new i,this.zoomOutPaintVertexArray=new i}populatePaintArray(e,t,n){let r=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(e),this.zoomOutPaintVertexArray.resize(e),this._setPaintValues(r,e,this.getPositionIds(t),n)}updatePaintArray(e,t,n,r,i){this._setPaintValues(e,t,this.getPositionIds(n),i)}_setPaintValues(e,t,n,r){let i=this.getPositions(r);if(!i||!n)return;let a=i[n.min],o=i[n.mid],s=i[n.max];if(a&&o&&s)for(let n=e;n<t;n++)this.emplace(this.zoomInPaintVertexArray,n,o,a),this.emplace(this.zoomOutPaintVertexArray,n,o,s)}upload(e){if(this.zoomInPaintVertexArray?.arrayBuffer.byteLength&&this.zoomOutPaintVertexArray?.arrayBuffer.byteLength){let t=this.getVertexAttributes();this.zoomInPaintVertexBuffer=e.createVertexBuffer(this.zoomInPaintVertexArray,t,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=e.createVertexBuffer(this.zoomOutPaintVertexArray,t,this.expression.isStateDependent)}}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class Ns extends Ms{getPositions(e){return e.imagePositions}getPositionIds(e){return e.patterns?.[this.layerId]}getVertexAttributes(){return ls.members}emplace(e,t,n,r){e.emplace(t,n.tlbr[0],n.tlbr[1],n.tlbr[2],n.tlbr[3],r.tlbr[0],r.tlbr[1],r.tlbr[2],r.tlbr[3],n.pixelRatio,r.pixelRatio)}}class Ps extends Ms{getPositions(e){return e.dashPositions}getPositionIds(e){return e.dashes?.[this.layerId]}getVertexAttributes(){return us.members}emplace(e,t,n,r){e.emplace(t,0,n.y,n.height,n.width,0,r.y,r.height,r.width)}}class Fs{constructor(e,t,n){this.binders={},this._buffers=[];let r=[];for(let i in e.paint._values){if(!n(i))continue;let a=e.paint.get(i);if(!(a instanceof Wa&&G(a.property.specification)))continue;let o=Ls(i,e.type),s=a.value,c=a.property.specification.type,l=a.property.useIntegerZoom,u=a.property.specification[`property-type`],d=u===`cross-faded`||u===`cross-faded-data-driven`;if(s.kind===`constant`)this.binders[i]=d?new ks(s.value,o):new Os(s.value,o,c),r.push(`/u_${i}`);else if(s.kind===`source`||d){let n=Rs(i,c,`source`);this.binders[i]=d?i===`line-dasharray`?new Ps(s,c,l,t,n,e.id):new Ns(s,c,l,t,n,e.id):new As(s,o,c,n),r.push(`/a_${i}`)}else{let e=Rs(i,c,`composite`);this.binders[i]=new js(s,o,c,l,t,e),r.push(`/z_${i}`)}}this.cacheKey=r.sort().join(``)}getMaxValue(e){let t=this.binders[e];return t instanceof As||t instanceof js?t.maxValue:0}populatePaintArrays(e,t,n){for(let r in this.binders){let i=this.binders[r];(i instanceof As||i instanceof js||i instanceof Ms)&&i.populatePaintArray(e,t,n)}}setConstantPatternPositions(e,t){for(let n in this.binders){let r=this.binders[n];r instanceof ks&&r.setConstantPatternPositions(e,t)}}setConstantDashPositions(e,t){for(let n in this.binders){let r=this.binders[n];r instanceof ks&&r.setConstantDashPositions(e,t)}}updatePaintArrays(e,t,n,r,i){let a=!1;for(let o in e){let s=t.getPositions(o);for(let t of s){let s=n.feature(t.index);for(let n in this.binders){let c=this.binders[n];(c instanceof As||c instanceof js||c instanceof Ms)&&!0===c.expression.isStateDependent&&(c.expression=r.paint.get(n).value,c.updatePaintArray(t.start,t.end,s,e[o],i),a=!0)}}}return a}defines(){let e=[];for(let t in this.binders){let n=this.binders[t];(n instanceof Os||n instanceof ks)&&e.push(...n.uniformNames.map((e=>`#define HAS_UNIFORM_${e}`)))}return e}getBinderAttributes(){let e=[];for(let t in this.binders){let n=this.binders[t];if(n instanceof As||n instanceof js)for(let t of n.paintVertexAttributes)e.push(t.name);else if(n instanceof Ms){let t=n.getVertexAttributes();for(let n of t)e.push(n.name)}}return e}getBinderUniforms(){let e=[];for(let t in this.binders){let n=this.binders[t];if(n instanceof Os||n instanceof ks||n instanceof js)for(let t of n.uniformNames)e.push(t)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,t){let n=[];for(let r in this.binders){let i=this.binders[r];if(i instanceof Os||i instanceof ks||i instanceof js){for(let a of i.uniformNames)if(t[a]){let o=i.getBinding(e,t[a],a);n.push({name:a,property:r,binding:o})}}}return n}setUniforms(e,t,n,r){for(let{name:e,property:i,binding:a}of t)this.binders[i].setUniform(a,r,n.get(i),e)}updatePaintBuffers(e){this._buffers=[];for(let t in this.binders){let n=this.binders[t];if(e&&n instanceof Ms){let t=e.fromScale===2?n.zoomInPaintVertexBuffer:n.zoomOutPaintVertexBuffer;t&&this._buffers.push(t)}else (n instanceof As||n instanceof js)&&n.paintVertexBuffer&&this._buffers.push(n.paintVertexBuffer)}}upload(e){for(let t in this.binders){let n=this.binders[t];(n instanceof As||n instanceof js||n instanceof Ms)&&n.upload(e)}this.updatePaintBuffers()}destroy(){for(let e in this.binders){let t=this.binders[e];(t instanceof As||t instanceof js||t instanceof Ms)&&t.destroy()}}}class Is{constructor(e,t,n=()=>!0){this.programConfigurations={};for(let r of e)this.programConfigurations[r.id]=new Fs(r,t,n);this.needsUpload=!1,this._featureMap=new vs,this._bufferOffset=0}populatePaintArrays(e,t,n,r){for(let n in this.programConfigurations)this.programConfigurations[n].populatePaintArrays(e,t,r);t.id!==void 0&&this._featureMap.add(t.id,n,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,n,r){for(let i of n)this.needsUpload=this.programConfigurations[i.id].updatePaintArrays(e,this._featureMap,t,i,r)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(let t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1}}destroy(){for(let e in this.programConfigurations)this.programConfigurations[e].destroy()}}function Ls(e,t){return{"text-opacity":[`opacity`],"icon-opacity":[`opacity`],"text-color":[`fill_color`],"icon-color":[`fill_color`],"text-halo-color":[`halo_color`],"icon-halo-color":[`halo_color`],"text-halo-blur":[`halo_blur`],"icon-halo-blur":[`halo_blur`],"text-halo-width":[`halo_width`],"icon-halo-width":[`halo_width`],"line-gap-width":[`gapwidth`],"line-dasharray":[`dasharray_to`,`dasharray_from`],"line-pattern":[`pattern_to`,`pattern_from`,`pixel_ratio_to`,`pixel_ratio_from`],"fill-pattern":[`pattern_to`,`pattern_from`,`pixel_ratio_to`,`pixel_ratio_from`],"fill-extrusion-pattern":[`pattern_to`,`pattern_from`,`pixel_ratio_to`,`pixel_ratio_from`]}[e]||[e.replace(`${t}-`,``).replace(/-/g,`_`)]}function Rs(e,t,n){let r={color:{source:mo,composite:Mo},number:{source:Do,composite:mo}};return function(e){return{"line-pattern":{source:Zo,composite:Zo},"fill-pattern":{source:Zo,composite:Zo},"fill-extrusion-pattern":{source:Zo,composite:Zo},"line-dasharray":{source:Qo,composite:Qo}}[e]}(e)?.[n]||r[t][n]}X(`ConstantBinder`,Os),X(`CrossFadedConstantBinder`,ks),X(`SourceExpressionBinder`,As),X(`CrossFadedPatternBinder`,Ns),X(`CrossFadedDasharrayBinder`,Ps),X(`CompositeExpressionBinder`,js),X(`ProgramConfiguration`,Fs,{omit:[`_buffers`]}),X(`ProgramConfigurationSet`,Is);let zs=2**14-1,Bs=-zs-1;function Vs(e){let t=O/e.extent,n=e.loadGeometry();for(let e of n)for(let n of e){let e=Math.round(n.x*t),r=Math.round(n.y*t);n.x=ie(e,Bs,zs),n.y=ie(r,Bs,zs),(e<n.x||e>n.x+1||r<n.y||r>n.y+1)&&fe(`Geometry exceeds allowed extent, reduce your vector tile buffer size`)}return n}function Hs(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Vs(e):[]}}let Us=-32768;function Ws(e,t,n,r,i){e.emplaceBack(Us+8*t+r,Us+8*n+i)}class Gs{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new Ko,this.indexArray=new is,this.segments=new ss,this.programConfigurations=new Is(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,n){let r=this.layers[0],i=[],a=null,o=!1,s=r.type===`heatmap`;if(r.type===`circle`){let e=r;a=e.layout.get(`circle-sort-key`),o=!a.isConstant(),s||=e.paint.get(`circle-pitch-alignment`)===`map`}let c=s?t.subdivisionGranularity.circle:1;for(let{feature:t,id:r,index:s,sourceLayerIndex:c}of e){let e=this.layers[0]._featureFilter.needGeometry,l=Hs(t,e);if(!this.layers[0]._featureFilter.filter(new Fa(this.zoom),l,n))continue;let u=o?a.evaluate(l,{},n):void 0,d={id:r,properties:t.properties,type:t.type,sourceLayerIndex:c,index:s,geometry:e?l.geometry:Vs(t),patterns:{},sortKey:u};i.push(d)}o&&i.sort(((e,t)=>e.sortKey-t.sortKey));for(let r of i){let{geometry:i,index:a,sourceLayerIndex:o}=r,s=e[a].feature;this.addFeature(r,i,a,n,c),t.featureIndex.insert(s,i,a,o,this.index)}}update(e,t,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:n})}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,os),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,t,n,r,i=1){let a;switch(i){case 1:a=[0,7];break;case 3:a=[0,2,5,7];break;case 5:a=[0,1,3,4,6,7];break;case 7:a=[0,1,2,3,4,5,6,7];break;default:throw Error(`Invalid circle bucket granularity: ${i}; valid values are 1, 3, 5, 7.`)}let o=a.length;for(let n of t)for(let t of n){let n=t.x,r=t.y;if(n<0||n>=O||r<0||r>=O)continue;let i=this.segments.prepareSegment(o*o,this.layoutVertexArray,this.indexArray,e.sortKey),s=i.vertexLength;for(let e=0;e<o;e++)for(let t=0;t<o;t++)Ws(this.layoutVertexArray,n,r,a[t],a[e]);for(let e=0;e<o-1;e++)for(let t=0;t<o-1;t++){let n=s+e*o+t,r=s+(e+1)*o+t;this.indexArray.emplaceBack(n,r+1,n+1),this.indexArray.emplaceBack(n,r,r+1)}i.vertexLength+=o*o,i.primitiveLength+=(o-1)*(o-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,{imagePositions:{},canonical:r})}}function Ks(e,t){for(let n of e)if(tc(t,n))return!0;for(let n of t)if(tc(e,n))return!0;return Xs(e,t)}function qs(e,t,n){return!!tc(e,t)||Qs(t,e,n)}function Js(e,t){if(e.length===1)return ec(t,e[0]);for(let n of t)for(let t of n)if(tc(e,t))return!0;for(let n of e)if(ec(t,n))return!0;for(let n of t)if(Xs(e,n))return!0;return!1}function Ys(e,t,n){if(e.length>1){if(Xs(e,t))return!0;for(let r of t)if(Qs(r,e,n))return!0}for(let r of e)if(Qs(r,t,n))return!0;return!1}function Xs(e,t){if(e.length===0||t.length===0)return!1;for(let n=0;n<e.length-1;n++){let r=e[n],i=e[n+1];for(let e=0;e<t.length-1;e++)if(Zs(r,i,t[e],t[e+1]))return!0}return!1}function Zs(e,t,n,r){return pe(e,n,r)!==pe(t,n,r)&&pe(e,t,n)!==pe(e,t,r)}function Qs(e,t,n){let r=n*n;if(t.length===1)return e.distSqr(t[0])<r;for(let n=1;n<t.length;n++)if($s(e,t[n-1],t[n])<r)return!0;return!1}function $s(e,t,n){let r=t.distSqr(n);if(r===0)return e.distSqr(t);let i=((e.x-t.x)*(n.x-t.x)+(e.y-t.y)*(n.y-t.y))/r;return e.distSqr(i<0?t:i>1?n:n.sub(t)._mult(i)._add(t))}function ec(e,t){let n,r,i,a=!1;for(let o of e){n=o;for(let e=0,o=n.length-1;e<n.length;o=e++)r=n[e],i=n[o],r.y>t.y!=i.y>t.y&&t.x<(i.x-r.x)*(t.y-r.y)/(i.y-r.y)+r.x&&(a=!a)}return a}function tc(e,t){let n=!1;for(let r=0,i=e.length-1;r<e.length;i=r++){let a=e[r],o=e[i];a.y>t.y!=o.y>t.y&&t.x<(o.x-a.x)*(t.y-a.y)/(o.y-a.y)+a.x&&(n=!n)}return n}function nc(e,t,n){let r=n[0],i=n[2];if(e.x<r.x&&t.x<r.x||e.x>i.x&&t.x>i.x||e.y<r.y&&t.y<r.y||e.y>i.y&&t.y>i.y)return!1;let a=pe(e,t,n[0]);return a!==pe(e,t,n[1])||a!==pe(e,t,n[2])||a!==pe(e,t,n[3])}function rc(e,t,n){let r=t.paint.get(e).value;return r.kind===`constant`?r.value:n.programConfigurations.get(t.id).getMaxValue(e)}function ic(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function ac(e,t,r,i,a){if(!t[0]&&!t[1])return e;let o=n.convert(t)._mult(a);r===`viewport`&&o._rotate(-i);let s=[];for(let t of e)s.push(t.sub(o));return s}function oc(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n],i=t.at(-1);(n===0||i&&!r.equals(i))&&t.push(r)}return t}function sc({queryGeometry:e,size:t},n){return qs(e,n,t)}function cc({queryGeometry:e,size:t,transform:n,unwrappedTileID:r,getElevation:i},a){return qs(e,a,t*(n.projectTileCoordinates(a.x,a.y,r,i).signedDistanceFromCamera/n.cameraToCenterDistance))}function lc({queryGeometry:e,size:t,transform:n,unwrappedTileID:r,getElevation:i},a){let o=n.projectTileCoordinates(a.x,a.y,r,i).signedDistanceFromCamera,s=t*(n.cameraToCenterDistance/o);return qs(e,fc(a,n,r,i),s)}function uc({queryGeometry:e,size:t,transform:n,unwrappedTileID:r,getElevation:i},a){return qs(e,fc(a,n,r,i),t)}function dc({queryGeometry:e,size:t,transform:n,unwrappedTileID:r,getElevation:i,pitchAlignment:a=`map`,pitchScale:o=`map`},s){let c=a===`map`?o===`map`?sc:cc:o===`map`?lc:uc,l={queryGeometry:e,size:t,transform:n,unwrappedTileID:r,getElevation:i};for(let e of s)for(let t of e)if(c(l,t))return!0;return!1}function fc(e,t,r,i){let a=t.projectTileCoordinates(e.x,e.y,r,i).point;return new n((.5*a.x+.5)*t.width,(.5*-a.y+.5)*t.height)}let pc,mc;X(`CircleBucket`,Gs,{omit:[`layers`]});var hc={get paint(){return mc||=new Xa({"circle-radius":new Ka(M.paint_circle[`circle-radius`]),"circle-color":new Ka(M.paint_circle[`circle-color`]),"circle-blur":new Ka(M.paint_circle[`circle-blur`]),"circle-opacity":new Ka(M.paint_circle[`circle-opacity`]),"circle-translate":new Q(M.paint_circle[`circle-translate`]),"circle-translate-anchor":new Q(M.paint_circle[`circle-translate-anchor`]),"circle-pitch-scale":new Q(M.paint_circle[`circle-pitch-scale`]),"circle-pitch-alignment":new Q(M.paint_circle[`circle-pitch-alignment`]),"circle-stroke-width":new Ka(M.paint_circle[`circle-stroke-width`]),"circle-stroke-color":new Ka(M.paint_circle[`circle-stroke-color`]),"circle-stroke-opacity":new Ka(M.paint_circle[`circle-stroke-opacity`])})},get layout(){return pc||=new Xa({"circle-sort-key":new Ka(M.layout_circle[`circle-sort-key`])})}};class gc extends $a{constructor(e,t){super(e,hc,t)}createBucket(e){return new Gs(e)}queryRadius(e){let t=e;return rc(`circle-radius`,this,t)+rc(`circle-stroke-width`,this,t)+ic(this.paint.get(`circle-translate`))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:n,geometry:r,transform:i,pixelsToTileUnits:a,unwrappedTileID:o,getElevation:s}){let c=ac(e,this.paint.get(`circle-translate`),this.paint.get(`circle-translate-anchor`),-i.bearingInRadians,a),l=this.paint.get(`circle-radius`).evaluate(t,n)+this.paint.get(`circle-stroke-width`).evaluate(t,n),u=this.paint.get(`circle-pitch-scale`),d=this.paint.get(`circle-pitch-alignment`),f,p;return d===`map`?(f=c,p=l*a):(f=function(e,t,n,r){return e.map((e=>fc(e,t,n,r)))}(c,i,o,s),p=l),dc({queryGeometry:f,size:p,transform:i,unwrappedTileID:o,getElevation:s,pitchAlignment:d,pitchScale:u},r)}}class _c extends Gs{}let vc;X(`HeatmapBucket`,_c,{omit:[`layers`]});var yc={get paint(){return vc||=new Xa({"heatmap-radius":new Ka(M.paint_heatmap[`heatmap-radius`]),"heatmap-weight":new Ka(M.paint_heatmap[`heatmap-weight`]),"heatmap-intensity":new Q(M.paint_heatmap[`heatmap-intensity`]),"heatmap-color":new Ya(M.paint_heatmap[`heatmap-color`]),"heatmap-opacity":new Q(M.paint_heatmap[`heatmap-opacity`])})}};function bc(e,{width:t,height:n},r,i){if(i){if(i instanceof Uint8ClampedArray)i=new Uint8Array(i.buffer);else if(i.length!==t*n*r)throw RangeError(`mismatched image size. expected: ${i.length} but got: ${t*n*r}`)}else i=new Uint8Array(t*n*r);return e.width=t,e.height=n,e.data=i,e}function xc(e,{width:t,height:n},r){if(t===e.width&&n===e.height)return;let i=bc({},{width:t,height:n},r);Sc(e,i,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,t),height:Math.min(e.height,n)},r),e.width=t,e.height=n,e.data=i.data}function Sc(e,t,n,r,i,a){if(i.width===0||i.height===0)return t;if(i.width>e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw RangeError(`out of range source coordinates for image copy`);if(i.width>t.width||i.height>t.height||r.x>t.width-i.width||r.y>t.height-i.height)throw RangeError(`out of range destination coordinates for image copy`);let o=e.data,s=t.data;if(o===s)throw Error(`srcData equals dstData, so image is already copied`);for(let c=0;c<i.height;c++){let l=((n.y+c)*e.width+n.x)*a,u=((r.y+c)*t.width+r.x)*a;for(let e=0;e<i.width*a;e++)s[u+e]=o[l+e]}return t}class Cc{constructor(e,t){bc(this,e,1,t)}resize(e){xc(this,e,1)}clone(){return new Cc({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,n,r,i){Sc(e,t,n,r,i,1)}}class wc{constructor(e,t){bc(this,e,4,t)}resize(e){xc(this,e,4)}replace(e,t){t?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new wc({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,n,r,i){Sc(e,t,n,r,i,4)}setPixel(e,t,n){let r=4*(e*this.width+t);this.data[r+0]=Math.round(255*n.r/n.a),this.data[r+1]=Math.round(255*n.g/n.a),this.data[r+2]=Math.round(255*n.b/n.a),this.data[r+3]=Math.round(255*n.a)}}function Tc(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n+=4){let r=e[n+3];t[n+0]=Math.round(e[n+0]*r/255),t[n+1]=Math.round(e[n+1]*r/255),t[n+2]=Math.round(e[n+2]*r/255),t[n+3]=r}return t}function Ec(e){let t={},n=e.resolution||256,r=e.clips?e.clips.length:1,i=e.image||new wc({width:n,height:r});if(Math.log(n)/Math.LN2%1!=0)throw Error(`width is not a power of 2 - ${n}`);let a=(r,a,o)=>{t[e.evaluationKey]=o;let s=e.expression.evaluate(t);i.setPixel(r/4/n,a/4,s)};if(e.clips)for(let t=0,i=0;t<r;++t,i+=4*n)for(let r=0,o=0;r<n;r++,o+=4){let s=r/(n-1),{start:c,end:l}=e.clips[t];a(i,o,c*(1-s)+l*s)}else for(let e=0,t=0;e<n;e++,t+=4)a(0,t,e/(n-1));return i}X(`AlphaImage`,Cc),X(`RGBAImage`,wc);let Dc=`big-fb`;class Oc extends $a{createBucket(e){return new _c(e)}constructor(e,t){super(e,yc,t),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){e===`heatmap-color`&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Ec({expression:this._transitionablePaint._values[`heatmap-color`].value.expression,evaluationKey:`heatmapDensity`,image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has(Dc)&&this.heatmapFbos.delete(Dc)}queryRadius(e){return rc(`heatmap-radius`,this,e)}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:n,geometry:r,transform:i,pixelsToTileUnits:a,unwrappedTileID:o,getElevation:s}){return dc({queryGeometry:e,size:this.paint.get(`heatmap-radius`).evaluate(t,n)*a,transform:i,unwrappedTileID:o,getElevation:s},r)}hasOffscreenPass(){return this.paint.get(`heatmap-opacity`)!==0&&!this.isHidden()}}let kc;var Ac={get paint(){return kc||=new Xa({"hillshade-illumination-direction":new Q(M.paint_hillshade[`hillshade-illumination-direction`]),"hillshade-illumination-altitude":new Q(M.paint_hillshade[`hillshade-illumination-altitude`]),"hillshade-illumination-anchor":new Q(M.paint_hillshade[`hillshade-illumination-anchor`]),"hillshade-exaggeration":new Q(M.paint_hillshade[`hillshade-exaggeration`]),"hillshade-shadow-color":new Q(M.paint_hillshade[`hillshade-shadow-color`]),"hillshade-highlight-color":new Q(M.paint_hillshade[`hillshade-highlight-color`]),"hillshade-accent-color":new Q(M.paint_hillshade[`hillshade-accent-color`]),"hillshade-method":new Q(M.paint_hillshade[`hillshade-method`]),resampling:new Q(M.paint_hillshade.resampling)})}};class jc extends $a{constructor(e,t){super(e,Ac,t),this.recalculate({zoom:0,zoomHistory:{}},void 0)}getIlluminationProperties(){let e=this.paint.get(`hillshade-illumination-direction`).values,t=this.paint.get(`hillshade-illumination-altitude`).values,n=this.paint.get(`hillshade-highlight-color`).values,r=this.paint.get(`hillshade-shadow-color`).values,i=Math.max(e.length,t.length,n.length,r.length);e=e.concat(Array(i-e.length).fill(e.at(-1))),t=t.concat(Array(i-t.length).fill(t.at(-1))),n=n.concat(Array(i-n.length).fill(n.at(-1))),r=r.concat(Array(i-r.length).fill(r.at(-1)));let a=t.map(Se);return{directionRadians:e.map(Se),altitudeRadians:a,shadowColor:r,highlightColor:n}}hasOffscreenPass(){return this.paint.get(`hillshade-exaggeration`)!==0&&!this.isHidden()}}let Mc;var Nc={get paint(){return Mc||=new Xa({"color-relief-opacity":new Q(M[`paint_color-relief`][`color-relief-opacity`]),"color-relief-color":new Ya(M[`paint_color-relief`][`color-relief-color`]),resampling:new Q(M[`paint_color-relief`].resampling)})}};function Pc(e){return`data`in e}class Fc{constructor(e,t,n,r){this.context=e,this.format=n,this.texture=e.gl.createTexture(),this._ownedHandle=this.texture,this.update(t,r)}update(e,t,n){let{width:r,height:i}=e,a=(this.size?.[0]!==r||this.size[1]!==i)&&!n,{context:o}=this,{gl:s}=o;this.useMipmap=!!t?.useMipmap,s.bindTexture(s.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1);let c=this.format===s.RGBA&&!1!==t?.premultiply;if(a)this.size=[r,i],Pc(e)?(o.pixelStoreUnpackPremultiplyAlpha.set(!1),this._uploadRawData(e,c,r,i,s)):(o.pixelStoreUnpackPremultiplyAlpha.set(c),this._uploadDomImage(e,s));else{let{x:t,y:a}=n||{x:0,y:0};Pc(e)?(o.pixelStoreUnpackPremultiplyAlpha.set(!1),this._updateRawData(e,c,t,a,r,i,s)):(o.pixelStoreUnpackPremultiplyAlpha.set(c),this._updateDomImage(e,t,a,s))}this.useMipmap&&this.isSizePowerOfTwo()&&s.generateMipmap(s.TEXTURE_2D),o.pixelStoreUnpackFlipY.setDefault(),o.pixelStoreUnpack.setDefault(),o.pixelStoreUnpackPremultiplyAlpha.setDefault()}_uploadDomImage(e,t){t.texImage2D(t.TEXTURE_2D,0,this.format,this.format,t.UNSIGNED_BYTE,e)}_uploadRawData(e,t,n,r,i){let{data:a}=e;t&&a&&(a=Tc(a)),i.texImage2D(i.TEXTURE_2D,0,this.format,n,r,0,this.format,i.UNSIGNED_BYTE,a)}_updateDomImage(e,t,n,r){r.texSubImage2D(r.TEXTURE_2D,0,t,n,r.RGBA,r.UNSIGNED_BYTE,e)}_updateRawData(e,t,n,r,i,a,o){let{data:s}=e;t&&s&&(s=Tc(s)),o.texSubImage2D(o.TEXTURE_2D,0,n,r,i,a,o.RGBA,o.UNSIGNED_BYTE,s)}bind(e,t,n){let{context:r}=this,{gl:i}=r;this.texture!==this._ownedHandle&&(this.texture=this._ownedHandle),i.bindTexture(i.TEXTURE_2D,this.texture),n!==i.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(n=i.LINEAR),e!==this.filter&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,e),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,n||e),this.filter=e),t!==this.wrap&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,t),this.wrap=t)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){let{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null,this._ownedHandle=null}}class Ic{constructor(e,t,n,r=1,i=1,a=1,o=0){if(this.uid=e,t.height!==t.width)throw RangeError(`DEM tiles must be square`);if(n&&![`mapbox`,`terrarium`,`custom`].includes(n))return void fe(`"${n}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=t.height;let s=this.dim=t.height-2;switch(this.data=new Uint32Array(t.data.buffer),n){case`terrarium`:this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case`custom`:this.redFactor=r,this.greenFactor=i,this.blueFactor=a,this.baseShift=o;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let e=0;e<s;e++)this.data[this._idx(-1,e)]=this.data[this._idx(0,e)],this.data[this._idx(s,e)]=this.data[this._idx(s-1,e)],this.data[this._idx(e,-1)]=this.data[this._idx(e,0)],this.data[this._idx(e,s)]=this.data[this._idx(e,s-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(s,-1)]=this.data[this._idx(s-1,0)],this.data[this._idx(-1,s)]=this.data[this._idx(0,s-1)],this.data[this._idx(s,s)]=this.data[this._idx(s-1,s-1)],this.min=2**53-1,this.max=-(2**53-1);for(let e=0;e<s;e++)for(let t=0;t<s;t++){let n=this.get(e,t);n>this.max&&(this.max=n),n<this.min&&(this.min=n)}}get(e,t){let n=new Uint8Array(this.data.buffer),r=4*this._idx(e,t);return this.unpack(n[r],n[r+1],n[r+2])}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(e,t){if(e<-1||e>=this.dim+1||t<-1||t>=this.dim+1)throw RangeError(`Out of range source coordinates for DEM data. x: ${e}, y: ${t}, dim: ${this.dim}`);return(t+1)*this.stride+(e+1)}unpack(e,t,n){return e*this.redFactor+t*this.greenFactor+n*this.blueFactor-this.baseShift}pack(e){return Lc(e,this.getUnpackVector())}getPixels(){return new wc({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,t,n){if(this.dim!==e.dim)throw Error(`dem dimension mismatch`);let r=t*this.dim,i=t*this.dim+this.dim,a=n*this.dim,o=n*this.dim+this.dim;switch(t){case-1:r=i-1;break;case 1:i=r+1}switch(n){case-1:a=o-1;break;case 1:o=a+1}let s=-t*this.dim,c=-n*this.dim;for(let t=a;t<o;t++)for(let n=r;n<i;n++)this.data[this._idx(n,t)]=e.data[this._idx(n+s,t+c)]}}function Lc(e,t){let n=t[0],r=t[1],i=t[2],a=t[3],o=Math.min(n,r,i),s=Math.round((e+a)/o);return{r:Math.floor(s*o/n)%256,g:Math.floor(s*o/r)%256,b:Math.floor(s*o/i)%256}}X(`DEMData`,Ic);class Rc extends $a{constructor(e,t){super(e,Nc,t)}_createColorRamp(e){let t={elevationStops:[],colorStops:[]},n=this._transitionablePaint._values[`color-relief-color`].value.expression;if(n instanceof ui&&n._styleExpression.expression instanceof Tn){this.colorRampExpression=n;let e=n._styleExpression.expression;t.elevationStops=e.labels,t.colorStops=[];for(let n of t.elevationStops)t.colorStops.push(e.evaluate({globals:{elevation:n}}))}if(t.elevationStops.length<1&&(t.elevationStops=[0],t.colorStops=[Ut.transparent]),t.elevationStops.length<2&&(t.elevationStops.push(t.elevationStops[0]+1),t.colorStops.push(t.colorStops[0])),t.elevationStops.length<=e)return t;let r={elevationStops:[],colorStops:[]},i=(t.elevationStops.length-1)/(e-1);for(let e=0;e<t.elevationStops.length-.5;e+=i)r.elevationStops.push(t.elevationStops[Math.round(e)]),r.colorStops.push(t.colorStops[Math.round(e)]);return fe(`Too many colors in specification of ${this.id} color-relief layer, may not render properly. Max possible colors: ${e}, provided: ${t.elevationStops.length}`),r}_colorRampChanged(){return this.colorRampExpression!=this._transitionablePaint._values[`color-relief-color`].value.expression}getColorRampTextures(e,t,n){if(this.colorRampTextures&&!this._colorRampChanged())return this.colorRampTextures;let r=this._createColorRamp(t),i=new wc({width:r.colorStops.length,height:1}),a=new wc({width:r.colorStops.length,height:1});for(let e=0;e<r.elevationStops.length;e++){let t=Lc(r.elevationStops[e],n);a.setPixel(0,e,new Ut(t.r/255,t.g/255,t.b/255,1)),i.setPixel(0,e,r.colorStops[e])}return this.colorRampTextures={elevationTexture:new Fc(e,a,e.gl.RGBA),colorTexture:new Fc(e,i,e.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return!this.isHidden()&&!!this.colorRampTextures}}let{members:zc}=oo([{name:`a_pos`,components:2,type:`Int16`}],4);function Bc(e,t,n){let r=n.patternDependencies,i=!1;for(let n of t){let t=n.paint.get(`${e}-pattern`);t.isConstant()||(i=!0);let a=t.constantOr(null);a&&(i=!0,r[a.to]=!0,r[a.from]=!0)}return i}function Vc(e,t,n,r,i){let{zoom:a}=r,o=i.patternDependencies;for(let r of t){let t=r.paint.get(`${e}-pattern`).value;if(t.kind!==`constant`){let e=t.evaluate({zoom:a-1},n,{},i.availableImages),s=t.evaluate({zoom:a},n,{},i.availableImages),c=t.evaluate({zoom:a+1},n,{},i.availableImages);e=e?.name?e.name:e,s=s?.name?s.name:s,c=c?.name?c.name:c,o[e]=!0,o[s]=!0,o[c]=!0,n.patterns[r.id]={min:e,mid:s,max:c}}}return n}function Hc(e,t,n,r,i){let a;if(i===function(e,t,n,r){let i=0;for(let a=t,o=n-r;a<n;a+=r)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}(e,t,n,r)>0)for(let i=t;i<n;i+=r)a=ul(i/r|0,e[i],e[i+1],a);else for(let i=n-r;i>=t;i-=r)a=ul(i/r|0,e[i],e[i+1],a);return a&&il(a,a.next)&&(dl(a),a=a.next),a}function Uc(e,t){if(!e)return e;t||=e;let n,r=e;do if(n=!1,r.steiner||!il(r,r.next)&&rl(r.prev,r,r.next)!==0)r=r.next;else{if(dl(r),r=t=r.prev,r===r.next)break;n=!0}while(n||r!==t);return t}function Wc(e,t,n,r,i,a,o){if(!e)return;!o&&a&&function(e,t,n,r){let i=e;do i.z===0&&(i.z=Qc(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){let t,n=1;do{let r,i=e;e=null;let a=null;for(t=0;i;){t++;let o=i,s=0;for(let e=0;e<n&&(s++,o=o.nextZ,o);e++);let c=n;for(;s>0||c>0&&o;)s!==0&&(c===0||!o||i.z<=o.z)?(r=i,i=i.nextZ,s--):(r=o,o=o.nextZ,c--),a?a.nextZ=r:e=r,r.prevZ=a,a=r;i=o}a.nextZ=null,n*=2}while(t>1)}(i)}(e,r,i,a);let s=e;for(;e.prev!==e.next;){let c=e.prev,l=e.next;if(a?Kc(e,r,i,a):Gc(e))t.push(c.i,e.i,l.i),dl(e),e=l.next,s=l.next;else if((e=l)===s){o?o===1?Wc(e=qc(Uc(e),t),t,n,r,i,a,2):o===2&&Jc(e,t,n,r,i,a):Wc(Uc(e),t,n,r,i,a,1);break}}}function Gc(e){let t=e.prev,n=e,r=e.next;if(rl(t,n,r)>=0)return!1;let i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=Math.min(i,a,o),d=Math.min(s,c,l),f=Math.max(i,a,o),p=Math.max(s,c,l),m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&tl(i,s,a,c,o,l,m.x,m.y)&&rl(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Kc(e,t,n,r){let i=e.prev,a=e,o=e.next;if(rl(i,a,o)>=0)return!1;let s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=Math.min(s,c,l),m=Math.min(u,d,f),h=Math.max(s,c,l),g=Math.max(u,d,f),_=Qc(p,m,t,n,r),v=Qc(h,g,t,n,r),y=e.prevZ,b=e.nextZ;for(;y&&y.z>=_&&b&&b.z<=v;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&tl(s,u,c,d,l,f,y.x,y.y)&&rl(y.prev,y,y.next)>=0||(y=y.prevZ,b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&tl(s,u,c,d,l,f,b.x,b.y)&&rl(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&tl(s,u,c,d,l,f,y.x,y.y)&&rl(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=v;){if(b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&tl(s,u,c,d,l,f,b.x,b.y)&&rl(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function qc(e,t){let n=e;do{let r=n.prev,i=n.next.next;!il(r,i)&&al(r,n,n.next,i)&&cl(r,i)&&cl(i,r)&&(t.push(r.i,n.i,i.i),dl(n),dl(n.next),n=e=i),n=n.next}while(n!==e);return Uc(n)}function Jc(e,t,n,r,i,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&nl(o,e)){let s=ll(o,e);o=Uc(o,o.next),s=Uc(s,s.next),Wc(o,t,n,r,i,a,0),Wc(s,t,n,r,i,a,0);return}e=e.next}o=o.next}while(o!==e)}function Yc(e,t){let n=e.x-t.x;return n===0&&(n=e.y-t.y,n===0)&&(n=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)),n}function Xc(e,t){let n=function(e,t){let n=t,r=e.x,i=e.y,a,o=-1/0;if(il(e,n))return n;do{if(il(e,n.next))return n.next;if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){let e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>o&&(o=e,a=n.x<n.next.x?n:n.next,e===r))return a}n=n.next}while(n!==t);if(!a)return null;let s=a,c=a.x,l=a.y,u=1/0;n=a;do{if(r>=n.x&&n.x>=c&&r!==n.x&&el(i<l?r:o,i,c,l,i<l?o:r,i,n.x,n.y)){let t=Math.abs(i-n.y)/(r-n.x);cl(n,e)&&(t<u||t===u&&(n.x>a.x||n.x===a.x&&Zc(a,n)))&&(a=n,u=t)}n=n.next}while(n!==s);return a}(e,t);if(!n)return t;let r=ll(n,e);return Uc(r,r.next),Uc(n,n.next)}function Zc(e,t){return rl(e.prev,e,t.prev)<0&&rl(t.next,e,e.next)<0}function Qc(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function $c(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function el(e,t,n,r,i,a,o,s){return(i-o)*(t-s)>=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function tl(e,t,n,r,i,a,o,s){return!(e===o&&t===s)&&el(e,t,n,r,i,a,o,s)}function nl(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&al(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(cl(e,t)&&cl(t,e)&&function(e,t){let n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}(e,t)&&(rl(e.prev,e,t.prev)||rl(e,t.prev,t))||il(e,t)&&rl(e.prev,e,e.next)>0&&rl(t.prev,t,t.next)>0)}function rl(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function il(e,t){return e.x===t.x&&e.y===t.y}function al(e,t,n,r){let i=sl(rl(e,t,n)),a=sl(rl(e,t,r)),o=sl(rl(n,r,e)),s=sl(rl(n,r,t));return i!==a&&o!==s||!(i!==0||!ol(e,n,t))||!(a!==0||!ol(e,r,t))||!(o!==0||!ol(n,e,r))||!(s!==0||!ol(n,t,r))}function ol(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function sl(e){return e>0?1:e<0?-1:0}function cl(e,t){return rl(e.prev,e,e.next)<0?rl(e,t,e.next)>=0&&rl(e,e.prev,t)>=0:rl(e,t,e.prev)<0||rl(e,e.next,t)<0}function ll(e,t){let n=fl(e.i,e.x,e.y),r=fl(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function ul(e,t,n,r){let i=fl(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function dl(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function fl(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class pl{constructor(e,t){if(t>e)throw Error(`Min granularity must not be greater than base granularity.`);this._baseZoomGranularity=e,this._minGranularity=t}getGranularityForZoomLevel(e){return Math.max(Math.floor(this._baseZoomGranularity/(1<<e)),this._minGranularity,1)}}class ml{constructor(e){this.fill=e.fill,this.line=e.line,this.tile=e.tile,this.stencil=e.stencil,this.circle=e.circle}}ml.noSubdivision=new ml({fill:new pl(0,0),line:new pl(0,0),tile:new pl(0,0),stencil:new pl(0,0),circle:1}),X(`SubdivisionGranularityExpression`,pl),X(`SubdivisionGranularitySetting`,ml);let hl=-32768,gl=32767;class _l{constructor(e,t){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=e,this._granularityCellSize=O/e,this._canonical=t}_getKey(e,t){return(e+=32768)<<16|t+32768}_vertexToIndex(e,t){if(e<-32768||t<-32768||e>32767||t>32767)throw Error(`Vertex coordinates are out of signed 16 bit integer range.`);let n=0|Math.round(e),r=0|Math.round(t),i=this._getKey(n,r);if(this._vertexDictionary.has(i))return this._vertexDictionary.get(i);let a=this._vertexBuffer.length/2;return this._vertexDictionary.set(i,a),this._vertexBuffer.push(n,r),a}_subdivideTrianglesScanline(e){if(this._granularity<2)return function(e,t){let n=[];for(let r=0;r<t.length;r+=3){let i=t[r],a=t[r+1],o=t[r+2],s=e[2*i],c=e[2*i+1];(e[2*a]-s)*(e[2*o+1]-c)-(e[2*a+1]-c)*(e[2*o]-s)>0?(n.push(i),n.push(o),n.push(a)):(n.push(i),n.push(a),n.push(o))}return n}(this._vertexBuffer,e);let t=[],n=e.length;for(let r=0;r<n;r+=3){let n=[e[r+0],e[r+1],e[r+2]],i=[this._vertexBuffer[2*e[r+0]+0],this._vertexBuffer[2*e[r+0]+1],this._vertexBuffer[2*e[r+1]+0],this._vertexBuffer[2*e[r+1]+1],this._vertexBuffer[2*e[r+2]+0],this._vertexBuffer[2*e[r+2]+1]],a=1/0,o=1/0,s=-1/0,c=-1/0;for(let e=0;e<3;e++){let t=i[2*e],n=i[2*e+1];a=Math.min(a,t),s=Math.max(s,t),o=Math.min(o,n),c=Math.max(c,n)}if(a===s||o===c)continue;let l=Math.floor(a/this._granularityCellSize),u=Math.ceil(s/this._granularityCellSize),d=Math.floor(o/this._granularityCellSize),f=Math.ceil(c/this._granularityCellSize);if(l!==u||d!==f)for(let e=d;e<f;e++){let r=this._scanlineGenerateVertexRingForCellRow(e,i,n);bl(this._vertexBuffer,r,t)}else t.push(...n)}return t}_scanlineGenerateVertexRingForCellRow(e,t,n){let r=e*this._granularityCellSize,i=r+this._granularityCellSize,a=[];for(let e=0;e<3;e++){let o=t[2*e],s=t[2*e+1],c=t[2*(e+1)%6],l=t[(2*(e+1)+1)%6],u=t[2*(e+2)%6],d=t[(2*(e+2)+1)%6],f=c-o,p=l-s,m=f===0,h=p===0,g=(r-s)/p,_=(i-s)/p,v=Math.min(g,_),y=Math.max(g,_);if(!h&&(v>=1||y<=0)||h&&(s<r||s>i)){l>=r&&l<=i&&a.push(n[(e+1)%3]);continue}!h&&v>0&&a.push(this._vertexToIndex(o+f*v,s+p*v));let b=o+f*Math.max(v,0),x=o+f*Math.min(y,1);m||this._generateIntraEdgeVertices(a,o,s,c,l,b,x),!h&&y<1&&a.push(this._vertexToIndex(o+f*y,s+p*y)),(h||l>=r&&l<=i)&&a.push(n[(e+1)%3]),!h&&(l<=r||l>=i)&&this._generateInterEdgeVertices(a,o,s,c,l,u,d,x,r,i)}return a}_generateIntraEdgeVertices(e,t,n,r,i,a,o){let s=r-t,c=i-n,l=c===0,u=l?Math.min(t,r):Math.min(a,o),d=l?Math.max(t,r):Math.max(a,o),f=Math.floor(u/this._granularityCellSize)+1,p=Math.ceil(d/this._granularityCellSize)-1;if(l?t<r:a<o)for(let r=f;r<=p;r++){let i=r*this._granularityCellSize;e.push(this._vertexToIndex(i,n+c*(i-t)/s))}else for(let r=p;r>=f;r--){let i=r*this._granularityCellSize;e.push(this._vertexToIndex(i,n+c*(i-t)/s))}}_generateInterEdgeVertices(e,t,n,r,i,a,o,s,c,l){let u=i-n,d=a-r,f=o-i,p=(c-i)/f,m=(l-i)/f,h=Math.min(p,m),g=Math.max(p,m),_=r+d*h,v=Math.floor(Math.min(_,s)/this._granularityCellSize)+1,y=Math.ceil(Math.max(_,s)/this._granularityCellSize)-1,b=s<_,x=f===0;if(x&&(o===c||o===l))return;if(x||h>=1||g<=0){let e=n-o,r=a+(t-a)*Math.min((c-o)/e,(l-o)/e);v=Math.floor(Math.min(r,s)/this._granularityCellSize)+1,y=Math.ceil(Math.max(r,s)/this._granularityCellSize)-1,b=s<r}let S=u>0?l:c;if(b)for(let t=v;t<=y;t++)e.push(this._vertexToIndex(t*this._granularityCellSize,S));else for(let t=y;t>=v;t--)e.push(this._vertexToIndex(t*this._granularityCellSize,S))}_generateOutline(e){let t=[];for(let n of e){let e=yl(n,this._granularity,!0),r=this._pointArrayToIndices(e),i=[];for(let e=1;e<r.length;e++)i.push(r[e-1]),i.push(r[e]);t.push(i)}return t}_handlePoles(e){let t=!1,n=!1;this._canonical&&(this._canonical.y===0&&(t=!0),this._canonical.y===(1<<this._canonical.z)-1&&(n=!0)),(t||n)&&this._fillPoles(e,t,n)}_ensureNoPoleVertices(){let e=this._vertexBuffer;for(let t=0;t<e.length;t+=2){let n=e[t+1];n===hl&&(e[t+1]=-32767),n===gl&&(e[t+1]=32766)}}_generatePoleQuad(e,t,n,r,i,a){r>i==(a===hl)?(e.push(n),e.push(t),e.push(this._vertexToIndex(r,a)),e.push(this._vertexToIndex(i,a)),e.push(n),e.push(this._vertexToIndex(r,a))):(e.push(t),e.push(n),e.push(this._vertexToIndex(r,a)),e.push(n),e.push(this._vertexToIndex(i,a)),e.push(this._vertexToIndex(r,a)))}_fillPoles(e,t,n){let r=this._vertexBuffer,i=O,a=e.length;for(let o=2;o<a;o+=3){let a=e[o-2],s=e[o-1],c=e[o],l=r[2*a],u=r[2*a+1],d=r[2*s],f=r[2*s+1],p=r[2*c],m=r[2*c+1];t&&(u===0&&f===0&&this._generatePoleQuad(e,a,s,l,d,hl),f===0&&m===0&&this._generatePoleQuad(e,s,c,d,p,hl),m===0&&u===0&&this._generatePoleQuad(e,c,a,p,l,hl)),n&&(u===i&&f===i&&this._generatePoleQuad(e,a,s,l,d,gl),f===i&&m===i&&this._generatePoleQuad(e,s,c,d,p,gl),m===i&&u===i&&this._generatePoleQuad(e,c,a,p,l,gl))}}_initializeVertices(e){for(let t=0;t<e.length;t+=2)this._vertexToIndex(e[t],e[t+1])}subdividePolygonInternal(e,t){if(this._used)throw Error(`Subdivision: multiple use not allowed.`);this._used=!0;let{flattened:n,holeIndices:r}=function(e){let t=[],n=[];for(let r of e)if(r.length!==0){r!==e[0]&&t.push(n.length/2);for(let e of r)n.push(e.x),n.push(e.y)}return{flattened:n,holeIndices:t}}(e),i;this._initializeVertices(n);try{let e=function(e,t,n=2){let r=t&&t.length,i=r?t[0]*n:e.length,a=Hc(e,0,i,n,!0),o=[];if(!a||a.next===a.prev)return o;let s,c,l;if(r&&(a=function(e,t,n,r){let i=[];for(let n=0,a=t.length;n<a;n++){let o=Hc(e,t[n]*r,n<a-1?t[n+1]*r:e.length,r,!1);o===o.next&&(o.steiner=!0),i.push($c(o))}i.sort(Yc);for(let e=0;e<i.length;e++)n=Xc(i[e],n);return n}(e,t,a,n)),e.length>80*n){s=e[0],c=e[1];let t=s,r=c;for(let a=n;a<i;a+=n){let n=e[a],i=e[a+1];n<s&&(s=n),i<c&&(c=i),n>t&&(t=n),i>r&&(r=i)}l=Math.max(t-s,r-c),l=l===0?0:32767/l}return Wc(a,o,n,s,c,l,0),o}(n,r),t=this._convertIndices(n,e);i=this._subdivideTrianglesScanline(t)}catch(e){console.error(e)}let a=[];return t&&(a=this._generateOutline(e)),this._ensureNoPoleVertices(),this._handlePoles(i),{verticesFlattened:this._vertexBuffer,indicesTriangles:i,indicesLineList:a}}_convertIndices(e,t){let n=[];for(let r of t)n.push(this._vertexToIndex(e[2*r],e[2*r+1]));return n}_pointArrayToIndices(e){let t=[];for(let n of e)t.push(this._vertexToIndex(n.x,n.y));return t}}function vl(e,t,n,r=!0){return new _l(n,t).subdividePolygonInternal(e,r)}function yl(e,t,r=!1){if(!e||e.length<1||e.length<2)return[];let i=e[0],a=e[e.length-1],o=r&&(i.x!==a.x||i.y!==a.y);if(t<2)return o?[...e,e[0]]:[...e];let s=Math.floor(O/t),c=[];c.push(new n(e[0].x,e[0].y));let l=e.length,u=o?l:l-1;for(let t=0;t<u;t++){let r=e[t],i=t<l-1?e[t+1]:e[0],a=r.x,o=r.y,u=i.x,d=i.y,f=a!==u,p=o!==d;if(!f&&!p)continue;let m=u-a,h=d-o,g=Math.abs(m),_=Math.abs(h),v=a,y=o;for(;;){let e=m>0?(Math.floor(v/s)+1)*s:(Math.ceil(v/s)-1)*s,t=h>0?(Math.floor(y/s)+1)*s:(Math.ceil(y/s)-1)*s,r=Math.abs(v-e),i=Math.abs(y-t),a=Math.abs(v-u),o=Math.abs(y-d),l=f?r/g:1/0,b=p?i/_:1/0;if((a<=r||!f)&&(o<=i||!p))break;if(l<b&&f||!p){v=e,y+=h*l;let t=new n(v,Math.round(y));c[c.length-1].x===t.x&&c[c.length-1].y===t.y||c.push(t)}else{v+=m*b,y=t;let e=new n(Math.round(v),y);c[c.length-1].x===e.x&&c[c.length-1].y===e.y||c.push(e)}}let b=new n(u,d);c[c.length-1].x===b.x&&c[c.length-1].y===b.y||c.push(b)}return c}function bl(e,t,n){if(t.length===0)throw Error(`Subdivision vertex ring is empty.`);let r=0,i=e[2*t[0]];for(let n=1;n<t.length;n++){let a=e[2*t[n]];a<i&&(i=a,r=n)}let a=t.length,o=r,s=(o+1)%a;for(;;){let r=o-1>=0?o-1:a-1,i=(s+1)%a,c=e[2*t[r]],l=e[2*t[i]],u=e[2*t[o]],d=e[2*t[o]+1],f=e[2*t[s]+1],p=!1;if(c<l)p=!0;else if(c>l)p=!1;else{let n=f-d,a=-(e[2*t[s]]-u),o=d<f?1:-1;((c-u)*n+(e[2*t[r]+1]-d)*a)*o>((l-u)*n+(e[2*t[i]+1]-d)*a)*o&&(p=!0)}if(p){let e=t[r],i=t[o],c=t[s];e!==i&&e!==c&&i!==c&&n.push(c,i,e),o--,o<0&&(o=a-1)}else{let e=t[i],r=t[o],c=t[s];e!==r&&e!==c&&r!==c&&n.push(c,r,e),s++,s>=a&&(s=0)}if(r===i)break}}function xl(e,t,n,r,i,a,o,s,c){let l=i.length/2,u=o&&s&&c;if(l<ss.MAX_VERTEX_ARRAY_LENGTH){let d=t.prepareSegment(l,n,r),f=d.vertexLength;for(let e=0;e<a.length;e+=3)r.emplaceBack(f+a[e],f+a[e+1],f+a[e+2]);let p,m;d.vertexLength+=l,d.primitiveLength+=a.length/3,u&&(m=o.prepareSegment(l,n,s),p=m.vertexLength,m.vertexLength+=l);for(let t=0;t<i.length;t+=2)e(i[t],i[t+1]);if(u)for(let e of c){for(let t=1;t<e.length;t+=2)s.emplaceBack(p+e[t-1],p+e[t]);m.primitiveLength+=e.length/2}}else (function(e,t,n,r,i,a){let o=[];for(let e=0;e<r.length/2;e++)o.push(-1);let s={count:0},c=0,l=e.getOrCreateLatestSegment(t,n),u=l.vertexLength;for(let d=2;d<i.length;d+=3){let f=i[d-2],p=i[d-1],m=i[d],h=o[f]<c,g=o[p]<c,_=o[m]<c;l.vertexLength+(+!!h+ +!!g+ +!!_)>ss.MAX_VERTEX_ARRAY_LENGTH&&(l=e.createNewSegment(t,n),c=s.count,h=!0,g=!0,_=!0,u=0);let v=Sl(o,r,a,s,f,h,l),y=Sl(o,r,a,s,p,g,l),b=Sl(o,r,a,s,m,_,l);n.emplaceBack(u+v-c,u+y-c,u+b-c),l.primitiveLength++}})(t,n,r,i,a,e),u&&function(e,t,n,r,i,a){let o=[];for(let e=0;e<r.length/2;e++)o.push(-1);let s={count:0},c=0,l=e.getOrCreateLatestSegment(t,n),u=l.vertexLength;for(let d of i)for(let i=1;i<d.length;i+=2){let f=d[i-1],p=d[i],m=o[f]<c,h=o[p]<c;l.vertexLength+(+!!m+ +!!h)>ss.MAX_VERTEX_ARRAY_LENGTH&&(l=e.createNewSegment(t,n),c=s.count,m=!0,h=!0,u=0);let g=Sl(o,r,a,s,f,m,l),_=Sl(o,r,a,s,p,h,l);n.emplaceBack(u+g-c,u+_-c),l.primitiveLength++}}(o,n,s,i,c,e),t.forceNewSegmentOnNextPrepare(),o?.forceNewSegmentOnNextPrepare()}function Sl(e,t,n,r,i,a,o){if(a){let a=r.count;return n(t[2*i],t[2*i+1]),e[i]=r.count,r.count++,o.vertexLength++,a}return e[i]}class Cl{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.layoutVertexArray=new qo,this.indexArray=new is,this.indexArray2=new as,this.programConfigurations=new Is(e.layers,e.zoom),this.segments=new ss,this.segments2=new ss,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,n){this.hasDependencies=Bc(`fill`,this.layers,t);let r=this.layers[0].layout.get(`fill-sort-key`),i=!r.isConstant(),a=[];for(let{feature:o,id:s,index:c,sourceLayerIndex:l}of e){let e=this.layers[0]._featureFilter.needGeometry,u=Hs(o,e);if(!this.layers[0]._featureFilter.filter(new Fa(this.zoom),u,n))continue;let d=i?r.evaluate(u,{},n,t.availableImages):void 0,f={id:s,properties:o.properties,type:o.type,sourceLayerIndex:l,index:c,geometry:e?u.geometry:Vs(o),patterns:{},sortKey:d};a.push(f)}i&&a.sort(((e,t)=>e.sortKey-t.sortKey));for(let r of a){let{geometry:i,index:a,sourceLayerIndex:o}=r;if(this.hasDependencies){let e=Vc(`fill`,this.layers,r,{zoom:this.zoom},t);this.patternFeatures.push(e)}else this.addFeature(r,i,a,n,{},t.subdivisionGranularity);t.featureIndex.insert(e[a].feature,i,a,o,this.index)}}update(e,t,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:n})}addFeatures(e,t,n){for(let r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,t,n,e.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,zc),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,t,n,r,i,a){for(let e of dr(t,500)){let t=vl(e,r,a.fill.getGranularityForZoomLevel(r.z)),n=this.layoutVertexArray;xl(((e,t)=>{n.emplaceBack(e,t)}),this.segments,this.layoutVertexArray,this.indexArray,t.verticesFlattened,t.indicesTriangles,this.segments2,this.indexArray2,t.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,{imagePositions:i,canonical:r})}}let wl,Tl;X(`FillBucket`,Cl,{omit:[`layers`,`patternFeatures`]});var El={get paint(){return Tl||=new Xa({"fill-antialias":new Q(M.paint_fill[`fill-antialias`]),"fill-opacity":new Ka(M.paint_fill[`fill-opacity`]),"fill-color":new Ka(M.paint_fill[`fill-color`]),"fill-outline-color":new Ka(M.paint_fill[`fill-outline-color`]),"fill-translate":new Q(M.paint_fill[`fill-translate`]),"fill-translate-anchor":new Q(M.paint_fill[`fill-translate-anchor`]),"fill-pattern":new qa(M.paint_fill[`fill-pattern`])})},get layout(){return wl||=new Xa({"fill-sort-key":new Ka(M.layout_fill[`fill-sort-key`])})}};class Dl extends $a{constructor(e,t){super(e,El,t)}recalculate(e,t){super.recalculate(e,t);let n=this.paint._values[`fill-outline-color`];n.value.kind===`constant`&&n.value.value===void 0&&(this.paint._values[`fill-outline-color`]=this.paint._values[`fill-color`])}createBucket(e){return new Cl(e)}queryRadius(){return ic(this.paint.get(`fill-translate`))}queryIntersectsFeature({queryGeometry:e,geometry:t,transform:n,pixelsToTileUnits:r}){return Js(ac(e,this.paint.get(`fill-translate`),this.paint.get(`fill-translate-anchor`),-n.bearingInRadians,r),t)}isTileClipped(){return!0}}let Ol=oo([{name:`a_pos`,components:2,type:`Int16`},{name:`a_normal_ed`,components:4,type:`Int16`}],4),kl=oo([{name:`a_centroid`,components:2,type:`Int16`}],4),{members:Al}=Ol;class jl{constructor(e,t,n,r,i){this.properties={},this.extent=n,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=r,this._values=i,e.readFields(Ml,this,t)}loadGeometry(){let e=this._pbf;e.pos=this._geometry;let t=e.readVarint()+e.pos,r=[],i,a=1,o=0,s=0,c=0;for(;e.pos<t;){if(o<=0){let t=e.readVarint();a=7&t,o=t>>3}if(o--,a===1||a===2)s+=e.readSVarint(),c+=e.readSVarint(),a===1&&(i&&r.push(i),i=[]),i&&i.push(new n(s,c));else{if(a!==7)throw Error(`unknown command ${a}`);i&&i.push(i[0].clone())}}return i&&r.push(i),r}bbox(){let e=this._pbf;e.pos=this._geometry;let t=e.readVarint()+e.pos,n=1,r=0,i=0,a=0,o=1/0,s=-1/0,c=1/0,l=-1/0;for(;e.pos<t;){if(r<=0){let t=e.readVarint();n=7&t,r=t>>3}if(r--,n===1||n===2)i+=e.readSVarint(),a+=e.readSVarint(),i<o&&(o=i),i>s&&(s=i),a<c&&(c=a),a>l&&(l=a);else if(n!==7)throw Error(`unknown command ${n}`)}return[o,c,s,l]}toGeoJSON(e,t,n){let r=this.extent*2**n,i=this.extent*e,a=this.extent*t,o=this.loadGeometry();function s(e){return[360*(e.x+i)/r-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+a)/r)*Math.PI))-90]}function c(e){return e.map(s)}let l;if(this.type===1){let e=[];for(let t of o)e.push(t[0]);let t=c(e);l=e.length===1?{type:`Point`,coordinates:t[0]}:{type:`MultiPoint`,coordinates:t}}else if(this.type===2){let e=o.map(c);l=e.length===1?{type:`LineString`,coordinates:e[0]}:{type:`MultiLineString`,coordinates:e}}else{if(this.type!==3)throw Error(`unknown feature type`);{let e=Nl(o),t=[];for(let n of e)t.push(n.map(c));l=t.length===1?{type:`Polygon`,coordinates:t[0]}:{type:`MultiPolygon`,coordinates:t}}}let u={type:`Feature`,geometry:l,properties:this.properties};return this.id!=null&&(u.id=this.id),u}}function Ml(e,t,n){e===1?t.id=n.readVarint():e===2?function(e,t){let n=e.readVarint()+e.pos;for(;e.pos<n;){let n=t._keys[e.readVarint()],r=t._values[e.readVarint()];t.properties[n]=r}}(n,t):e===3?t.type=n.readVarint():e===4&&(t._geometry=n.pos)}function Nl(e){let t=e.length;if(t<=1)return[e];let n=[],r,i;for(let a=0;a<t;a++){let t=Pl(e[a]);t!==0&&(i===void 0&&(i=t<0),i===t<0?(r&&n.push(r),r=[e[a]]):r&&r.push(e[a]))}return r&&n.push(r),n}function Pl(e){let t=0;for(let n,r,i=0,a=e.length,o=a-1;i<a;o=i++)n=e[i],r=e[o],t+=(r.x-n.x)*(n.y+r.y);return t}jl.types=[`Unknown`,`Point`,`LineString`,`Polygon`];class Fl{constructor(e,t){this.version=1,this.name=``,this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(Il,this,t),this.length=this._features.length}feature(e){if(e<0||e>=this._features.length)throw Error(`feature index out of bounds`);this._pbf.pos=this._features[e];let t=this._pbf.readVarint()+this._pbf.pos;return new jl(this._pbf,t,this.extent,this._keys,this._values)}}function Il(e,t,n){e===15?t.version=n.readVarint():e===1?t.name=n.readString():e===5?t.extent=n.readVarint():e===2?t._features.push(n.pos):e===3?t._keys.push(n.readString()):e===4&&t._values.push(function(e){let t=null,n=e.readVarint()+e.pos;for(;e.pos<n;){let n=e.readVarint()>>3;t=n===1?e.readString():n===2?e.readFloat():n===3?e.readDouble():n===4?e.readVarint64():n===5?e.readVarint():n===6?e.readSVarint():n===7?e.readBoolean():null}if(t==null)throw Error(`unknown feature value`);return t}(n))}class Ll{constructor(e,t){this.layers=e.readFields(Rl,{},t)}}function Rl(e,t,n){if(e===3){let e=new Fl(n,n.readVarint()+n.pos);e.length&&(t[e.name]=e)}}let zl=2**13;function Bl(e,t,n,r,i,a,o,s){e.emplaceBack(t,n,2*Math.floor(r*zl)+o,i*zl*2,a*zl*2,Math.round(s))}class Vl{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new Jo,this.centroidVertexArray=new Go,this.indexArray=new is,this.programConfigurations=new Is(e.layers,e.zoom),this.segments=new ss,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,n){this.features=[],this.hasDependencies=Bc(`fill-extrusion`,this.layers,t);for(let{feature:r,id:i,index:a,sourceLayerIndex:o}of e){let e=this.layers[0]._featureFilter.needGeometry,s=Hs(r,e);if(!this.layers[0]._featureFilter.filter(new Fa(this.zoom),s,n))continue;let c={id:i,sourceLayerIndex:o,index:a,geometry:e?s.geometry:Vs(r),properties:r.properties,type:r.type,patterns:{}};this.hasDependencies?this.features.push(Vc(`fill-extrusion`,this.layers,c,{zoom:this.zoom},t)):this.addFeature(c,c.geometry,a,n,{},t.subdivisionGranularity),t.featureIndex.insert(r,c.geometry,a,o,this.index,!0)}}addFeatures(e,t,n){for(let r of this.features){let{geometry:i}=r;this.addFeature(r,i,r.index,t,n,e.subdivisionGranularity)}}update(e,t,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:n})}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Al),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,kl.members,!0),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(e,t,n,r,i,a){for(let n of dr(t,500)){let t={x:0,y:0,sampleCount:0},i=this.layoutVertexArray.length;this.processPolygon(t,r,e,n,a);let o=this.layoutVertexArray.length-i,s=Math.floor(t.x/t.sampleCount),c=Math.floor(t.y/t.sampleCount);for(let e=0;e<o;e++)this.centroidVertexArray.emplaceBack(s,c)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,{imagePositions:i,canonical:r})}processPolygon(e,t,n,r,i){if(r.length<1||Wl(r[0]))return;for(let t of r)t.length!==0&&Hl(e,t);let a={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},o=i.fill.getGranularityForZoomLevel(t.z),s=jl.types[n.type]===`Polygon`;for(let e of r){if(e.length===0||Wl(e))continue;let t=yl(e,o,s);this._generateSideFaces(t,a)}if(!s)return;let c=vl(r,t,o,!1),l=this.layoutVertexArray;xl(((e,t)=>{Bl(l,e,t,0,0,1,1,0)}),this.segments,this.layoutVertexArray,this.indexArray,c.verticesFlattened,c.indicesTriangles)}_generateSideFaces(e,t){let n=0;for(let r=1;r<e.length;r++){let i=e[r],a=e[r-1];if(Ul(i,a))continue;t.segment.vertexLength+4>ss.MAX_VERTEX_ARRAY_LENGTH&&(t.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));let o=i.sub(a)._perp()._unit(),s=a.dist(i);n+s>32768&&(n=0),Bl(this.layoutVertexArray,i.x,i.y,o.x,o.y,0,0,n),Bl(this.layoutVertexArray,i.x,i.y,o.x,o.y,0,1,n),n+=s,Bl(this.layoutVertexArray,a.x,a.y,o.x,o.y,0,0,n),Bl(this.layoutVertexArray,a.x,a.y,o.x,o.y,0,1,n);let c=t.segment.vertexLength;this.indexArray.emplaceBack(c,c+2,c+1),this.indexArray.emplaceBack(c+1,c+2,c+3),t.segment.vertexLength+=4,t.segment.primitiveLength+=2}}}function Hl(e,t){for(let n=0;n<t.length;n++){let r=t[n];n===t.length-1&&t[0].x===r.x&&t[0].y===r.y||(e.x+=r.x,e.y+=r.y,e.sampleCount++)}}function Ul(e,t){return e.x===t.x&&(e.x<0||e.x>O)||e.y===t.y&&(e.y<0||e.y>O)}function Wl(e){return e.every((e=>e.x<0))||e.every((e=>e.x>O))||e.every((e=>e.y<0))||e.every((e=>e.y>O))}let Gl;X(`FillExtrusionBucket`,Vl,{omit:[`layers`,`features`]});var Kl={get paint(){return Gl||=new Xa({"fill-extrusion-opacity":new Q(M[`paint_fill-extrusion`][`fill-extrusion-opacity`]),"fill-extrusion-color":new Ka(M[`paint_fill-extrusion`][`fill-extrusion-color`]),"fill-extrusion-translate":new Q(M[`paint_fill-extrusion`][`fill-extrusion-translate`]),"fill-extrusion-translate-anchor":new Q(M[`paint_fill-extrusion`][`fill-extrusion-translate-anchor`]),"fill-extrusion-pattern":new qa(M[`paint_fill-extrusion`][`fill-extrusion-pattern`]),"fill-extrusion-height":new Ka(M[`paint_fill-extrusion`][`fill-extrusion-height`]),"fill-extrusion-base":new Ka(M[`paint_fill-extrusion`][`fill-extrusion-base`]),"fill-extrusion-vertical-gradient":new Q(M[`paint_fill-extrusion`][`fill-extrusion-vertical-gradient`])})}};class ql extends $a{constructor(e,t){super(e,Kl,t)}createBucket(e){return new Vl(e)}queryRadius(){return ic(this.paint.get(`fill-extrusion-translate`))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:r,geometry:i,transform:a,pixelsToTileUnits:o,pixelPosMatrix:s}){let c=ac(e,this.paint.get(`fill-extrusion-translate`),this.paint.get(`fill-extrusion-translate-anchor`),-a.bearingInRadians,o),l=this.paint.get(`fill-extrusion-height`).evaluate(t,r),u=this.paint.get(`fill-extrusion-base`).evaluate(t,r),d=function(e,t){let r=[];for(let i of e){let e=[i.x,i.y,0,1];C(e,e,t),r.push(new n(e[0]/e[3],e[1]/e[3]))}return r}(c,s),f=function(e,t,r,i){let a=[],o=[],s=i[8]*t,c=i[9]*t,l=i[10]*t,u=i[11]*t,d=i[8]*r,f=i[9]*r,p=i[10]*r,m=i[11]*r;for(let t of e){let e=[],r=[];for(let a of t){let t=a.x,o=a.y,h=i[0]*t+i[4]*o+i[12],g=i[1]*t+i[5]*o+i[13],_=i[2]*t+i[6]*o+i[14],v=i[3]*t+i[7]*o+i[15],y=_+l,b=v+u,x=h+d,S=g+f,C=_+p,w=v+m,T=new n((h+s)/b,(g+c)/b);T.z=y/b,e.push(T);let E=new n(x/w,S/w);E.z=C/w,r.push(E)}a.push(e),o.push(r)}return[a,o]}(i,u,l,s);return function(e,t,n){let r=1/0;Js(n,t)&&(r=Yl(n,t[0]));for(let i=0;i<t.length;i++){let a=t[i],o=e[i];for(let e=0;e<a.length-1;e++){let t=a[e],i=[t,a[e+1],o[e+1],o[e],t];Ks(n,i)&&(r=Math.min(r,Yl(n,i)))}}return r!==1/0&&r}(f[0],f[1],d)}}function Jl(e,t){return e.x*t.x+e.y*t.y}function Yl(e,t){if(e.length===1){let n=0,r=t[n++],i;for(;!i||r.equals(i);)if(i=t[n++],!i)return 1/0;for(;n<t.length;n++){let a=t[n],o=e[0],s=i.sub(r),c=a.sub(r),l=o.sub(r),u=Jl(s,s),d=Jl(s,c),f=Jl(c,c),p=Jl(l,s),m=Jl(l,c),h=u*f-d*d,g=(f*p-d*m)/h,_=(u*m-d*p)/h,v=r.z*(1-g-_)+i.z*g+a.z*_;if(isFinite(v))return v}return 1/0}{let e=1/0;for(let n of t)e=Math.min(e,n.z);return e}}let Xl=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Zl{static from(e){if(!(e instanceof ArrayBuffer))throw Error(`Data must be an instance of ArrayBuffer.`);let[t,n]=new Uint8Array(e,0,2);if(t!==219)throw Error(`Data does not appear to be in a KDBush format.`);let r=n>>4;if(r!==1)throw Error(`Got v${r} data when expected v1.`);let i=Xl[15&n];if(!i)throw Error(`Unrecognized array type.`);let[a]=new Uint16Array(e,2,1),[o]=new Uint32Array(e,4,1);return new Zl(o,a,i,e)}constructor(e,t=64,n=Float64Array,r){if(isNaN(e)||e<0)throw Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=n,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;let i=Xl.indexOf(this.ArrayType),a=2*e*this.ArrayType.BYTES_PER_ELEMENT,o=e*this.IndexArrayType.BYTES_PER_ELEMENT,s=(8-o%8)%8;if(i<0)throw Error(`Unexpected typed array class: ${n}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+o+s,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+a+o+s),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+o+s,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){let n=this._pos>>1;return this.ids[n]=n,this.coords[this._pos++]=e,this.coords[this._pos++]=t,n}finish(){let e=this._pos>>1;if(e!==this.numItems)throw Error(`Added ${e} items when expected ${this.numItems}.`);return Ql(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,n,r){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:i,coords:a,nodeSize:o}=this,s=[0,i.length-1,0],c=[];for(;s.length;){let l=s.pop()||0,u=s.pop()||0,d=s.pop()||0;if(u-d<=o){for(let o=d;o<=u;o++){let s=a[2*o],l=a[2*o+1];s>=e&&s<=n&&l>=t&&l<=r&&c.push(i[o])}continue}let f=d+u>>1,p=a[2*f],m=a[2*f+1];p>=e&&p<=n&&m>=t&&m<=r&&c.push(i[f]),(l===0?e<=p:t<=m)&&(s.push(d),s.push(f-1),s.push(1-l)),(l===0?n>=p:r>=m)&&(s.push(f+1),s.push(u),s.push(1-l))}return c}within(e,t,n){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:r,coords:i,nodeSize:a}=this,o=[0,r.length-1,0],s=[],c=n*n;for(;o.length;){let l=o.pop()||0,u=o.pop()||0,d=o.pop()||0;if(u-d<=a){for(let n=d;n<=u;n++)nu(i[2*n],i[2*n+1],e,t)<=c&&s.push(r[n]);continue}let f=d+u>>1,p=i[2*f],m=i[2*f+1];nu(p,m,e,t)<=c&&s.push(r[f]),(l===0?e-n<=p:t-n<=m)&&(o.push(d),o.push(f-1),o.push(1-l)),(l===0?e+n>=p:t+n>=m)&&(o.push(f+1),o.push(u),o.push(1-l))}return s}}function Ql(e,t,n,r,i,a){if(i-r<=n)return;let o=r+i>>1;$l(e,t,o,r,i,a),Ql(e,t,n,r,o-1,1-a),Ql(e,t,n,o+1,i,1-a)}function $l(e,t,n,r,i,a){for(;i>r;){if(i-r>600){let o=i-r+1,s=n-r+1,c=Math.log(o),l=.5*Math.exp(2*c/3),u=.5*Math.sqrt(c*l*(o-l)/o)*(s-o/2<0?-1:1);$l(e,t,n,Math.max(r,Math.floor(n-s*l/o+u)),Math.min(i,Math.floor(n+(o-s)*l/o+u)),a)}let o=t[2*n+a],s=r,c=i;for(eu(e,t,r,n),t[2*i+a]>o&&eu(e,t,r,i);s<c;){for(eu(e,t,s,c),s++,c--;t[2*s+a]<o;)s++;for(;t[2*c+a]>o;)c--}t[2*r+a]===o?eu(e,t,r,c):(c++,eu(e,t,c,i)),c<=n&&(r=c+1),n<=c&&(i=c-1)}}function eu(e,t,n,r){tu(e,n,r),tu(t,2*n,2*r),tu(t,2*n+1,2*r+1)}function tu(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function nu(e,t,n,r){let i=e-n,a=t-r;return i*i+a*a}function ru(e,t,n,r){let i=r,a=t+(n-t>>1),o,s=n-t,c=e[t],l=e[t+1],u=e[n],d=e[n+1];for(let r=t+3;r<n;r+=3){let t=iu(e[r],e[r+1],c,l,u,d);if(t>i)o=r,i=t;else if(t===i){let e=Math.abs(r-a);e<s&&(o=r,s=e)}}i>r&&(o-t>3&&ru(e,t,o,r),e[o+2]=i,n-o>3&&ru(e,o,n,r))}function iu(e,t,n,r,i,a){let o=i-n,s=a-r;if(o!==0||s!==0){let c=((e-n)*o+(t-r)*s)/(o*o+s*s);c>1?(n=i,r=a):c>0&&(n+=o*c,r+=s*c)}return o=e-n,s=t-r,o*o+s*s}function au(e,t,n,r){let i={type:t,geom:n},a={id:e??null,type:i.type,geometry:i.geom,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};switch(i.type){case`Point`:case`MultiPoint`:su(a,i.geom);break;case`LineString`:su(a,i.geom.points);break;case`Polygon`:su(a,i.geom[0].points);break;case`MultiLineString`:for(let e of i.geom)su(a,e.points);break;case`MultiPolygon`:for(let e of i.geom)su(a,e[0].points)}return a}function ou(e){e.points.length>64&&(e.points=new Float64Array(e.points))}function su(e,t){for(let n=0;n<t.length;n+=3)e.minX=Math.min(e.minX,t[n]),e.minY=Math.min(e.minY,t[n+1]),e.maxX=Math.max(e.maxX,t[n]),e.maxY=Math.max(e.maxY,t[n+1])}function cu(e,t){let n=[];switch(e.type){case`FeatureCollection`:for(let r=0;r<e.features.length;r++)lu(n,e.features[r],t,r);break;case`Feature`:lu(n,e,t);break;default:lu(n,{geometry:e,properties:void 0},t)}return n}function lu(e,t,n,r){if(!t.geometry)return;if(t.geometry.type===`GeometryCollection`)return void function(e,t,n,r,i){for(let a of n.geometries)lu(e,{id:t.id,geometry:a,properties:t.properties},r,i)}(e,t,t.geometry,n,r);if(!t.geometry.coordinates?.length)return;let i=function(e,t,n){return t.promoteId?e.properties?.[t.promoteId]:t.generateId?n||0:e.id}(t,n,r),a=(n.tolerance/((1<<n.maxZoom)*n.extent))**2;switch(t.geometry.type){case`Point`:(function(e,t,n,r){let i=[];i.push(fu(n.coordinates[0]),pu(n.coordinates[1]),0),e.push(au(t,`Point`,i,r))})(e,i,t.geometry,t.properties);return;case`MultiPoint`:(function(e,t,n,r){let i=[];for(let e of n.coordinates)i.push(fu(e[0]),pu(e[1]),0);e.push(au(t,`MultiPoint`,i,r))})(e,i,t.geometry,t.properties);return;case`LineString`:(function(e,t,n,r,i){let a={points:[]};uu(n.coordinates,a,r,!1),e.push(au(t,`LineString`,a,i))})(e,i,t.geometry,a,t.properties);return;case`MultiLineString`:(function(e,t,n,r,i,a){if(i.lineMetrics)for(let i of n.coordinates){let n={points:[]};uu(i,n,r,!1),e.push(au(t,`LineString`,n,a))}else{let i=[];du(n.coordinates,i,r,!1),e.push(au(t,`MultiLineString`,i,a))}})(e,i,t.geometry,a,n,t.properties);return;case`Polygon`:(function(e,t,n,r,i){let a=[];du(n.coordinates,a,r,!0),e.push(au(t,`Polygon`,a,i))})(e,i,t.geometry,a,t.properties);return;case`MultiPolygon`:(function(e,t,n,r,i){let a=[];for(let e of n.coordinates){let t=[];du(e,t,r,!0),a.push(t)}e.push(au(t,`MultiPolygon`,a,i))})(e,i,t.geometry,a,t.properties);return;default:throw Error(`Input data is not a valid GeoJSON object.`)}}function uu(e,t,n,r){let i,a,o=0;for(let n=0;n<e.length;n++){let s=fu(e[n][0]),c=pu(e[n][1]);t.points.push(s,c,0),n>0&&(o+=r?(i*c-s*a)/2:Math.sqrt((s-i)**2+(c-a)**2)),i=s,a=c}let s=t.points.length-3;t.points[2]=1,n>0&&ru(t.points,0,s,n),t.points[s+2]=1,ou(t),t.size=Math.abs(o),t.start=0,t.end=t.size}function du(e,t,n,r){for(let i=0;i<e.length;i++){let a={points:[]};uu(e[i],a,n,r),t.push(a)}}function fu(e){return e/360+.5}function pu(e){let t=Math.sin(e*Math.PI/180),n=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return n<0?0:n>1?1:n}function mu(e){let t={type:`Feature`,geometry:hu(e),properties:e.tags};return e.id!=null&&(t.id=e.id),t}function hu(e){let{type:t,geometry:n}=e;switch(t){case`Point`:return{type:t,coordinates:_u(n[0],n[1])};case`MultiPoint`:return{type:t,coordinates:gu(n)};case`LineString`:return{type:t,coordinates:gu(n.points)};case`MultiLineString`:case`Polygon`:return{type:t,coordinates:n.map((e=>gu(e.points)))};case`MultiPolygon`:return{type:t,coordinates:n.map((e=>e.map((e=>gu(e.points)))))}}}function gu(e){let t=[];for(let n=0;n<e.length;n+=3)t.push(_u(e[n],e[n+1]));return t}function _u(e,t){return[vu(e),yu(t)]}function vu(e){return 360*(e-.5)}function yu(e){let t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}var bu;function xu(e,t,n,r,i,a,o,s){if(r/=t,a>=(n/=t)&&o<r)return e;if(o<n||a>=r)return null;let c=[];for(let t of e){let e=i===bu.X?t.minX:t.minY,a=i===bu.X?t.maxX:t.maxY;if(e>=n&&a<r)c.push(t);else if(!(a<n||e>=r))switch(t.type){case`Point`:case`MultiPoint`:Su(t,c,n,r,i);continue;case`LineString`:Cu(t,c,n,r,i,s);continue;case`MultiLineString`:wu(t,c,n,r,i);continue;case`Polygon`:Tu(t,c,n,r,i);continue;case`MultiPolygon`:Eu(t,c,n,r,i);continue}}return c.length?c:null}function Su(e,t,n,r,i){let a=[];(function(e,t,n,r,i){for(let a=0;a<e.length;a+=3){let o=e[a+i];o>=n&&o<=r&&Au(t,e[a],e[a+1],e[a+2])}})(e.geometry,a,n,r,i),a.length&&t.push(au(e.id,a.length===3?`Point`:`MultiPoint`,a,e.tags))}function Cu(e,t,n,r,i,a){let o=[];if(Du(e.geometry,o,n,r,i,!1,a.lineMetrics),o.length)if(a.lineMetrics)for(let n of o)t.push(au(e.id,`LineString`,n,e.tags));else t.push(o.length>1?au(e.id,`MultiLineString`,o,e.tags):au(e.id,`LineString`,o[0],e.tags))}function wu(e,t,n,r,i){let a=[];ku(e.geometry,a,n,r,i,!1),a.length&&t.push(a.length===1?au(e.id,`LineString`,a[0],e.tags):au(e.id,`MultiLineString`,a,e.tags))}function Tu(e,t,n,r,i){let a=[];ku(e.geometry,a,n,r,i,!0),a.length&&t.push(au(e.id,`Polygon`,a,e.tags))}function Eu(e,t,n,r,i){let a=[];for(let t of e.geometry){let e=[];ku(t,e,n,r,i,!0),e.length&&a.push(e)}a.length&&t.push(au(e.id,`MultiPolygon`,a,e.tags))}function Du(e,t,n,r,i,a,o){let s=Ou(e),c=i===bu.X?ju:Mu,l,u,d=e.start;for(let f=0;f<e.points.length-3;f+=3){let p=e.points[f],m=e.points[f+1],h=e.points[f+2],g=e.points[f+3],_=e.points[f+4],v=i===bu.X?p:m,y=i===bu.X?g:_,b=!1;o&&(l=Math.sqrt((p-g)**2+(m-_)**2)),v<n?y>n&&(u=c(s,p,m,g,_,n),o&&(s.start=d+l*u)):v>r?y<r&&(u=c(s,p,m,g,_,r),o&&(s.start=d+l*u)):Au(s.points,p,m,h),y<n&&v>=n&&(u=c(s,p,m,g,_,n),b=!0),y>r&&v<=r&&(u=c(s,p,m,g,_,r),b=!0),!a&&b&&(o&&(s.end=d+l*u),t.push(s),s=Ou(e)),o&&(d+=l)}let f=e.points.length-3,p=e.points[f],m=e.points[f+1],h=i===bu.X?p:m;h>=n&&h<=r&&Au(s.points,p,m,e.points[f+2]),f=s.points.length-3,a&&f>=3&&(s.points[f]!==s.points[0]||s.points[f+1]!==s.points[1])&&Au(s.points,s.points[0],s.points[1],s.points[2]),s.points.length&&(ou(s),t.push(s))}function Ou(e){return{points:[],size:e.size,start:e.start,end:e.end}}function ku(e,t,n,r,i,a){for(let o of e)Du(o,t,n,r,i,a,!1)}function Au(e,t,n,r){e.push(t,n,r)}function ju(e,t,n,r,i,a){let o=(a-t)/(r-t);return Au(e.points,a,n+(i-n)*o,1),o}function Mu(e,t,n,r,i,a){let o=(a-n)/(i-n);return Au(e.points,t+(r-t)*o,a,1),o}function Nu(e,t){let n=t.buffer/t.extent,r=e,i=xu(e,1,-1-n,n,bu.X,-1,2,t),a=xu(e,1,1-n,2+n,bu.X,-1,2,t);return i||a?(r=xu(e,1,-n,1+n,bu.X,-1,2,t)||[],i&&(r=Pu(i,1).concat(r)),a&&(r=r.concat(Pu(a,-1))),r):r}function Pu(e,t){let n=[];for(let r of e)switch(r.type){case`Point`:case`MultiPoint`:{let e=Fu(r.geometry,t);n.push(au(r.id,r.type,e,r.tags));continue}case`LineString`:{let e=Iu(r.geometry,t);n.push(au(r.id,r.type,e,r.tags));continue}case`MultiLineString`:case`Polygon`:{let e=[];for(let n of r.geometry)e.push(Iu(n,t));n.push(au(r.id,r.type,e,r.tags));continue}case`MultiPolygon`:{let e=[];for(let n of r.geometry){let r=[];for(let e of n)r.push(Iu(e,t));e.push(r)}n.push(au(r.id,r.type,e,r.tags));continue}}return n}function Fu(e,t){let n=[];for(let r=0;r<e.length;r+=3)n.push(e[r]+t,e[r+1],e[r+2]);return n}function Iu(e,t){let n={points:[],size:e.size};e.start!==void 0&&(n.start=e.start,n.end=e.end);for(let r=0;r<e.points.length;r+=3)n.points.push(e.points[r]+t,e.points[r+1],e.points[r+2]);return ou(n),n}function Lu(e,t,n){let r=!!t.newGeometry,i=t.removeAllProperties||t.removeProperties?.length>0||t.addOrUpdateProperties?.length>0;if(r){let r=e[0],a=cu({type:`FeatureCollection`,features:[{type:`Feature`,id:r.id,geometry:t.newGeometry,properties:i?Ru(r.tags,t):r.tags}]},n);return a=Nu(a,n),a}if(i){let n=[];for(let r of e){let e={...r};e.tags=Ru(e.tags,t),n.push(e)}return n}return e}function Ru(e,t){if(t.removeAllProperties)return{};let n={...e||{}};if(t.removeProperties)for(let e of t.removeProperties)delete n[e];if(t.addOrUpdateProperties)for(let{key:e,value:r}of t.addOrUpdateProperties)n[e]=r;return n}(function(e){e[e.X=0]=`X`,e[e.Y=1]=`Y`})(bu||={});let zu={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e};class Bu{constructor(e){this.options=Object.assign(Object.create(zu),e),this.trees=Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[],this.points=[]}load(e){let t=[];for(let n of e){if(!n.geometry)continue;let[e,r]=n.geometry.coordinates,[i,a]=[fu(e),pu(r)];t.push({id:n.id,type:`Point`,geometry:[i,a],tags:n.properties})}this.createIndex(t)}initialize(e){let t=[];for(let n of e)n.type===`Point`&&t.push(n);this.createIndex(t)}updateIndex(e,t,n){this.options=Object.assign(Object.create(zu),n.clusterOptions),this.initialize(e)}createIndex(e){let{log:t,minZoom:n,maxZoom:r}=this.options;t&&console.time(`total time`);let i=`prepare ${e.length} points`;t&&console.time(i),this.points=e;let a=[];for(let t=0;t<e.length;t++){let n=e[t];if(!n?.geometry)continue;let[r,i]=n.geometry;r=Math.fround(r),i=Math.fround(i),a.push(r,i,1/0,t,-1,1),this.options.reduce&&a.push(0)}let o=this.trees[r+1]=this.createTree(a);t&&console.timeEnd(i);for(let e=r;e>=n;e--){let n=Date.now();o=this.trees[e]=this.createTree(this.cluster(o,e)),t&&console.log(`z%d: %d clusters in %dms`,e,o.numItems,Date.now()-n)}t&&console.timeEnd(`total time`)}getClusters(e,t){return this.getClustersInternal(e,t).map((e=>mu(e)))}getClustersInternal(e,t){let n=((e[0]+180)%360+360)%360-180,r=Math.max(-90,Math.min(90,e[1])),i=e[2]===180?180:((e[2]+180)%360+360)%360-180,a=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)n=-180,i=180;else if(n>i){let e=this.getClustersInternal([n,r,180,a],t),o=this.getClustersInternal([-180,r,i,a],t);return e.concat(o)}let o=this.trees[this.limitZoom(t)],s=o.range(fu(n),pu(a),fu(i),pu(r)),c=o.flatData,l=[];for(let e of s){let t=this.stride*e;l.push(c[t+5]>1?Vu(c,t,this.clusterProps):this.points[c[t+3]])}return l}getChildren(e){let t=this.getOriginId(e),n=this.getOriginZoom(e),r=Error(`No cluster with the specified id: `+e),i=this.trees[n];if(!i)throw r;let a=i.flatData;if(t*this.stride>=a.length)throw r;let o=this.options.radius/(this.options.extent*2**(n-1)),s=i.within(a[t*this.stride],a[t*this.stride+1],o),c=[];for(let t of s){let n=t*this.stride;a[n+4]===e&&c.push(a[n+5]>1?Hu(a,n,this.clusterProps):mu(this.points[a[n+3]]))}if(c.length===0)throw r;return c}getLeaves(e,t,n){let r=[];return this.appendLeaves(r,e,t||=10,n||=0,0),r}getTile(e,t,n){let r=this.trees[this.limitZoom(e)];if(!r)return null;let i=2**e,{extent:a,radius:o}=this.options,s=o/a,c=(n-s)/i,l=(n+1+s)/i,u={transformed:!0,features:[],source:null,x:t,y:n,z:e};return this.addTileFeatures(r.range((t-s)/i,c,(t+1+s)/i,l),r.flatData,t,n,i,u),t===0&&this.addTileFeatures(r.range(1-s/i,c,1,l),r.flatData,i,n,i,u),t===i-1&&this.addTileFeatures(r.range(0,c,s/i,l),r.flatData,-1,n,i,u),u}getClusterExpansionZoom(e){return this.getOriginZoom(e)}appendLeaves(e,t,n,r,i){let a=this.getChildren(t);for(let t of a){let a=t.properties;if(a?.cluster?i+a.point_count<=r?i+=a.point_count:i=this.appendLeaves(e,a.cluster_id,n,r,i):i<r?i++:e.push(t),e.length===n)break}return i}createTree(e){let t=new Zl(e.length/this.stride|0,this.options.nodeSize,Float32Array);for(let n=0;n<e.length;n+=this.stride)t.add(e[n],e[n+1]);return t.finish(),t.flatData=e,t.data=null,t}addTileFeatures(e,t,n,r,i,a){for(let o of e){let e=o*this.stride,s=t[e+5]>1,c,l,u;if(s)c=Uu(t,e,this.clusterProps),l=t[e],u=t[e+1];else{let n=this.points[t[e+3]];c=n.tags,[l,u]=n.geometry}let d={type:1,geometry:[[Math.round(this.options.extent*(l*i-n)),Math.round(this.options.extent*(u*i-r))]],tags:c},f;f=s||this.options.generateId?t[e+3]:this.points[t[e+3]].id,f!==void 0&&(d.id=f),a.features.push(d)}}limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}cluster(e,t){let{radius:n,extent:r,reduce:i,minPoints:a}=this.options,o=n/(r*2**t),s=e.flatData,c=[],l=this.stride;for(let n=0;n<s.length;n+=l){if(s[n+2]<=t)continue;s[n+2]=t;let r=s[n],u=s[n+1],d=e.within(s[n],s[n+1],o),f=s[n+5],p=f;for(let e of d){let n=e*l;s[n+2]>t&&(p+=s[n+5])}if(p>f&&p>=a){let e,a=r*f,o=u*f,m=-1,h=(n/l<<5)+(t+1)+this.points.length;for(let r of d){let c=r*l;if(s[c+2]<=t)continue;s[c+2]=t;let u=s[c+5];a+=s[c]*u,o+=s[c+1]*u,s[c+4]=h,i&&(e||(e=this.map(s,n,!0),m=this.clusterProps.length,this.clusterProps.push(e)),i(e,this.map(s,c)))}s[n+4]=h,c.push(a/p,o/p,1/0,h,-1,p),i&&c.push(m)}else{for(let e=0;e<l;e++)c.push(s[n+e]);if(p>1)for(let e of d){let n=e*l;if(!(s[n+2]<=t)){s[n+2]=t;for(let e=0;e<l;e++)c.push(s[n+e])}}}}return c}getOriginId(e){return e-this.points.length>>5}getOriginZoom(e){return(e-this.points.length)%32}map(e,t,n){if(e[t+5]>1){let r=this.clusterProps[e[t+6]];return n?Object.assign({},r):r}let r=this.points[e[t+3]].tags,i=this.options.map(r);return n&&i===r?Object.assign({},i):i}}function Vu(e,t,n){return{id:e[t+3],type:`Point`,tags:Uu(e,t,n),geometry:[e[t],e[t+1]]}}function Hu(e,t,n){return{type:`Feature`,id:e[t+3],properties:Uu(e,t,n),geometry:{type:`Point`,coordinates:[vu(e[t]),yu(e[t+1])]}}}function Uu(e,t,n){let r=e[t+5],i=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+`k`:r,a=e[t+6],o=a===-1?{}:Object.assign({},n[a]);return Object.assign(o,{cluster:!0,cluster_id:e[t+3],point_count:r,point_count_abbreviated:i})}let Wu=`geojsonvt_clip_start`,Gu=`geojsonvt_clip_end`;function $(e,t,n,r,i){let a=t===i.maxZoom?0:i.tolerance/((1<<t)*i.extent),o={transformed:!1,features:[],source:null,x:n,y:r,z:t,minX:2,minY:1,maxX:-1,maxY:0,numPoints:0,numSimplified:0,numFeatures:e.length};for(let t of e)Ku(o,t,a,i);return o}function Ku(e,t,n,r){switch(e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),t.type){case`Point`:case`MultiPoint`:(function(e,t){let n=[];for(let r=0;r<t.geometry.length;r+=3)n.push(t.geometry[r],t.geometry[r+1]),e.numPoints++,e.numSimplified++;if(!n.length)return;let r={type:1,tags:t.tags||null,geometry:n};t.id!==null&&(r.id=t.id),e.features.push(r)})(e,t);return;case`LineString`:(function(e,t,n,r){let i=[];if(qu(i,t.geometry,e,n,!1,!1),!i.length)return;let a=t.tags||null;if(r.lineMetrics){a={};for(let e in t.tags)a[e]=t.tags[e];a[Wu]=t.geometry.start/t.geometry.size,a[Gu]=t.geometry.end/t.geometry.size}let o={type:2,tags:a,geometry:i};t.id!==null&&(o.id=t.id),e.features.push(o)})(e,t,n,r);return;case`MultiLineString`:case`Polygon`:(function(e,t,n){let r=[];for(let i=0;i<t.geometry.length;i++)qu(r,t.geometry[i],e,n,t.type===`Polygon`,i===0);if(!r.length)return;let i={type:t.type===`Polygon`?3:2,tags:t.tags||null,geometry:r};t.id!==null&&(i.id=t.id),e.features.push(i)})(e,t,n);return;case`MultiPolygon`:(function(e,t,n){let r=[];for(let i=0;i<t.geometry.length;i++){let a=t.geometry[i];for(let t=0;t<a.length;t++)qu(r,a[t],e,n,!0,t===0)}if(!r.length)return;let i={type:3,tags:t.tags||null,geometry:r};t.id!==null&&(i.id=t.id),e.features.push(i)})(e,t,n);return}}function qu(e,t,n,r,i,a){let o=r*r;if(r>0&&t.size<(i?o:r))return void(n.numPoints+=t.points.length/3);let s=[];for(let e=0;e<t.points.length;e+=3)(r===0||t.points[e+2]>o)&&(n.numSimplified++,s.push(t.points[e],t.points[e+1])),n.numPoints++;i&&function(e,t){let n=0;for(let t=0,r=e.length,i=r-2;t<r;i=t,t+=2)n+=(e[t]-e[i])*(e[t+1]+e[i+1]);if(n>0===t)for(let t=0,n=e.length;t<n/2;t+=2){let r=e[t],i=e[t+1];e[t]=e[n-2-t],e[t+1]=e[n-1-t],e[n-2-t]=r,e[n-1-t]=i}}(s,a),e.push(s)}function Ju(e,t){if(e.transformed)return e;let n=1<<e.z,r=e.x,i=e.y;for(let a of e.features)a.type===1?Yu(a,t,n,r,i):Xu(a,t,n,r,i);return e.transformed=!0,e}function Yu(e,t,n,r,i){let a=e,o=e.geometry,s=[];for(let e=0;e<o.length;e+=2)s.push(Zu(o[e],o[e+1],t,n,r,i));return a.geometry=s,a}function Xu(e,t,n,r,i){let a=e,o=e.geometry,s=[];for(let e of o){let a=[];for(let o=0;o<e.length;o+=2)a.push(Zu(e[o],e[o+1],t,n,r,i));s.push(a)}return a.geometry=s,a}function Zu(e,t,n,r,i,a){return[Math.round(n*(e*r-i)),Math.round(n*(t*r-a))]}class Qu{constructor(e){this.options=e,this.total=0,this.stats={},this.tiles={},this.tileCoords=[],this.stats={},this.total=0}initialize(e){this.splitTile(e,0,0,0),this.options.debug&&(e.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(e,t,n){n.debug>1&&(console.log(`invalidating tiles`),console.time(`invalidating`)),this.invalidateTiles(t),n.debug>1&&console.timeEnd(`invalidating`);let[r,i,a]=[0,0,0],o=$(e,r,i,a,n);o.source=e;let s=$u(r,i,a);if(this.tiles[s]=o,this.tileCoords.push({z:r,x:i,y:a,id:s}),n.debug){let e=`z${r}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}}getClusterExpansionZoom(e){return null}getChildren(e){return null}getLeaves(e,t,n){return null}getTile(e,t,n){let{extent:r,debug:i}=this.options,a=1<<e,o=$u(e,t=t+a&a-1,n);if(this.tiles[o])return Ju(this.tiles[o],r);i>1&&console.log(`drilling down to z%d-%d-%d`,e,t,n);let s,c=e,l=t,u=n;for(;!s&&c>0;)c--,l>>=1,u>>=1,s=this.tiles[$u(c,l,u)];return s?.source?(i>1&&(console.log(`found parent tile z%d-%d-%d`,c,l,u),console.time(`drilling down`)),this.splitTile(s.source,c,l,u,e,t,n),i>1&&console.timeEnd(`drilling down`),this.tiles[o]?Ju(this.tiles[o],r):null):null}splitTile(e,t,n,r,i,a,o){let s=[e,t,n,r],c=this.options,l=c.debug;for(;s.length;){r=s.pop(),n=s.pop(),t=s.pop(),e=s.pop();let u=1<<t,d=$u(t,n,r),f=this.tiles[d];if(!f&&(l>1&&console.time(`creation`),f=this.tiles[d]=$(e,t,n,r,c),this.tileCoords.push({z:t,x:n,y:r,id:d}),l)){l>1&&(console.log(`tile z%d-%d-%d (features: %d, points: %d, simplified: %d)`,t,n,r,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd(`creation`));let e=`z${t}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}if(f.source=e,i==null){if(t===c.indexMaxZoom||f.numPoints<=c.indexMaxPoints)continue}else{if(t===c.maxZoom||t===i)continue;if(i!=null){let e=i-t;if(n!==a>>e||r!==o>>e)continue}}if(f.source=null,!e.length)continue;l>1&&console.time(`clipping`);let p=.5*c.buffer/c.extent,m=.5-p,h=.5+p,g=1+p,_=null,v=null,y=null,b=null,x=xu(e,u,n-p,n+h,bu.X,f.minX,f.maxX,c),S=xu(e,u,n+m,n+g,bu.X,f.minX,f.maxX,c);x&&(_=xu(x,u,r-p,r+h,bu.Y,f.minY,f.maxY,c),v=xu(x,u,r+m,r+g,bu.Y,f.minY,f.maxY,c)),S&&(y=xu(S,u,r-p,r+h,bu.Y,f.minY,f.maxY,c),b=xu(S,u,r+m,r+g,bu.Y,f.minY,f.maxY,c)),l>1&&console.timeEnd(`clipping`),s.push(_||[],t+1,2*n,2*r),s.push(v||[],t+1,2*n,2*r+1),s.push(y||[],t+1,2*n+1,2*r),s.push(b||[],t+1,2*n+1,2*r+1)}}invalidateTiles(e){if(!e.length)return;let t=this.options,{debug:n}=t,r=1/0,i=-1/0,a=1/0,o=-1/0;for(let t of e)r=Math.min(r,t.minX),i=Math.max(i,t.maxX),a=Math.min(a,t.minY),o=Math.max(o,t.maxY);let s=t.buffer/t.extent,c=new Set;for(let t in this.tiles){let l=this.tiles[t],u=1<<l.z,d=(l.x-s)/u,f=(l.x+1+s)/u,p=(l.y-s)/u,m=(l.y+1+s)/u;if(i<d||r>=f||o<p||a>=m)continue;let h=!1;for(let t of e)if(t.maxX>=d&&t.minX<f&&t.maxY>=p&&t.minY<m){h=!0;break}if(h){if(n){n>1&&console.log(`invalidate tile z%d-%d-%d (features: %d, points: %d, simplified: %d)`,l.z,l.x,l.y,l.numFeatures,l.numPoints,l.numSimplified);let e=`z${l.z}`;this.stats[e]=(this.stats[e]||0)-1,this.total--}delete this.tiles[t],c.add(t)}}c.size&&(this.tileCoords=this.tileCoords.filter((e=>!c.has(e.id))))}}function $u(e,t,n){return 32*((1<<e)*n+t)+e}let ed={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,updateable:!1,cluster:!1,clusterOptions:zu,debug:0},{members:td}=oo([{name:`a_pos_normal`,components:2,type:`Int16`},{name:`a_data`,components:4,type:`Uint8`}],4),{members:nd}=oo([{name:`a_uv_x`,components:1,type:`Float32`},{name:`a_split_index`,components:1,type:`Float32`}]),rd=Math.cos(Math.PI/180*37.5),id=2**14/.5;class ad{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={};for(let e of this.layers)this.gradients[e.id]={};this.layoutVertexArray=new Yo,this.layoutVertexArray2=new Xo,this.indexArray=new is,this.programConfigurations=new Is(e.layers,e.zoom),this.segments=new ss,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,n){this.hasDependencies=Bc(`line`,this.layers,t)||this.hasLineDasharray(this.layers);let r=this.layers[0].layout.get(`line-sort-key`),i=!r.isConstant(),a=[];for(let{feature:t,id:o,index:s,sourceLayerIndex:c}of e){let e=this.layers[0]._featureFilter.needGeometry,l=Hs(t,e);if(!this.layers[0]._featureFilter.filter(new Fa(this.zoom),l,n))continue;let u=i?r.evaluate(l,{},n):void 0,d={id:o,properties:t.properties,type:t.type,sourceLayerIndex:c,index:s,geometry:e?l.geometry:Vs(t),patterns:{},dashes:{},sortKey:u};a.push(d)}i&&a.sort(((e,t)=>e.sortKey-t.sortKey));for(let r of a){let{geometry:i,index:a,sourceLayerIndex:o}=r;this.hasDependencies?(Bc(`line`,this.layers,t)?Vc(`line`,this.layers,r,{zoom:this.zoom},t):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,r,this.zoom,t),this.patternFeatures.push(r)):this.addFeature(r,i,a,n,{},{},t.subdivisionGranularity),t.featureIndex.insert(e[a].feature,i,a,o,this.index)}}update(e,t,n,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:n,dashPositions:r})}addFeatures(e,t,n,r){for(let i of this.patternFeatures)this.addFeature(i,i.geometry,i.index,t,n,r,e.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,nd)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,td),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&Object.hasOwn(e.properties,Wu)&&Object.hasOwn(e.properties,Gu))return{start:+e.properties[Wu],end:+e.properties[Gu]}}addFeature(e,t,n,r,i,a,o){let s=this.layers[0].layout,c=s.get(`line-join`).evaluate(e,{}),l=s.get(`line-cap`).evaluate(e,{}),u=s.get(`line-miter-limit`).evaluate(e,{}),d=s.get(`line-round-limit`).evaluate(e,{});this.lineClips=this.lineFeatureClips(e);for(let n of t)this.addLine(n,e,c,l,u,d,r,o);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,{imagePositions:i,dashPositions:a,canonical:r})}addLine(e,t,n,r,i,a,o,s){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=yl(e,o?s.line.getGranularityForZoomLevel(o.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t<e.length-1;t++)this.totalDistance+=e[t].dist(e[t+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}let c=jl.types[t.type]===`Polygon`,l=e.length;for(;l>=2&&e[l-1].equals(e[l-2]);)l--;let u=0;for(;u<l-1&&e[u].equals(e[u+1]);)u++;if(l<(c?3:2))return;n===`bevel`&&(i=1.05);let d=this.overscaling<=16?122880/(512*this.overscaling):0,f=this.segments.prepareSegment(10*l,this.layoutVertexArray,this.indexArray),p,m,h,g,_;this.e1=this.e2=-1,c&&(p=e[l-2],_=e[u].sub(p)._unit()._perp());for(let t=u;t<l;t++){if(h=t===l-1?c?e[u+1]:void 0:e[t+1],h&&e[t].equals(h))continue;_&&(g=_),p&&(m=p),p=e[t],_=h?h.sub(p)._unit()._perp():g,g||=_;let o=g.add(_);o.x===0&&o.y===0||o._unit();let s=g.x*_.x+g.y*_.y,v=o.x*_.x+o.y*_.y,y=v===0?1/0:1/v,b=2*Math.sqrt(2-2*v),x=v<rd&&m&&h,S=g.x*_.y-g.y*_.x>0;if(x&&t>u){let e=p.dist(m);if(e>2*d){let t=p.sub(p.sub(m)._mult(d/e)._round());this.updateDistance(m,t),this.addCurrentVertex(t,g,0,0,f),m=t}}let C=m&&h,w=C?n:c?`butt`:r;if(C&&w===`round`&&(y<a?w=`miter`:y<=2&&(w=`fakeround`)),w===`miter`&&y>i&&(w=`bevel`),w===`bevel`&&(y>2&&(w=`flipbevel`),y<i&&(w=`miter`)),m&&this.updateDistance(m,p),w===`miter`)o._mult(y),this.addCurrentVertex(p,o,0,0,f);else if(w===`flipbevel`){if(y>100)o=_.mult(-1);else{let e=y*g.add(_).mag()/g.sub(_).mag();o._perp()._mult(e*(S?-1:1))}this.addCurrentVertex(p,o,0,0,f),this.addCurrentVertex(p,o.mult(-1),0,0,f)}else if(w===`bevel`||w===`fakeround`){let e=-Math.sqrt(y*y-1),t=S?e:0,n=S?0:e;if(m&&this.addCurrentVertex(p,g,t,n,f),w===`fakeround`){let e=Math.round(180*b/Math.PI/20);for(let t=1;t<e;t++){let n=t/e;if(n!==.5){let e=n-.5;n+=n*e*(n-1)*((1.0904+s*(s*(3.55645-1.43519*s)-3.2452))*e*e+(.848013+s*(.215638*s-1.06021)))}let r=_.sub(g)._mult(n)._add(g)._unit()._mult(S?-1:1);this.addHalfVertex(p,r.x,r.y,!1,S,0,f)}}h&&this.addCurrentVertex(p,_,-t,-n,f)}else if(w===`butt`)this.addCurrentVertex(p,o,0,0,f);else if(w===`square`){let e=m?1:-1;this.addCurrentVertex(p,o,e,e,f)}else w===`round`&&(m&&(this.addCurrentVertex(p,g,0,0,f),this.addCurrentVertex(p,g,1,1,f,!0)),h&&(this.addCurrentVertex(p,_,-1,-1,f,!0),this.addCurrentVertex(p,_,0,0,f)));if(x&&t<l-1){let e=p.dist(h);if(e>2*d){let t=p.add(h.sub(p)._mult(d/e)._round());this.updateDistance(p,t),this.addCurrentVertex(t,_,0,0,f),p=t}}}}addCurrentVertex(e,t,n,r,i,a=!1){let o=t.y*r-t.x,s=-t.y-t.x*r;this.addHalfVertex(e,t.x+t.y*n,t.y-t.x*n,a,!1,n,i),this.addHalfVertex(e,o,s,a,!0,-r,i),this.distance>id/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,t,n,r,i,a))}addHalfVertex({x:e,y:t},n,r,i,a,o,s){let c=.5*(this.lineClips?this.scaledDistance*(id-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+ +!!i,(t<<1)+ +!!a,Math.round(63*n)+128,Math.round(63*r)+128,1+(o===0?0:o<0?-1:1)|(63&c)<<2,c>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);let l=s.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,l,this.e2),s.primitiveLength++),a?this.e2=l:this.e1=l}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}hasLineDasharray(e){for(let t of e){let e=t.paint.get(`line-dasharray`);if(e&&!e.isConstant())return!0}return!1}addLineDashDependencies(e,t,n,r){for(let i of e){let e=i.paint.get(`line-dasharray`);if(!e||e.value.kind===`constant`)continue;let a=i.layout.get(`line-cap`).evaluate(t,{})===`round`,o={dasharray:e.value.evaluate({zoom:n-1},t,{}),round:a},s={dasharray:e.value.evaluate({zoom:n},t,{}),round:a},c={dasharray:e.value.evaluate({zoom:n+1},t,{}),round:a},l=`${o.dasharray.join(`,`)},${o.round}`,u=`${s.dasharray.join(`,`)},${s.round}`,d=`${c.dasharray.join(`,`)},${c.round}`;r.dashDependencies[l]=o,r.dashDependencies[u]=s,r.dashDependencies[d]=c,t.dashes[i.id]={min:l,mid:u,max:d}}}}let od,sd;X(`LineBucket`,ad,{omit:[`layers`,`patternFeatures`]});var cd={get paint(){return sd||=new Xa({"line-opacity":new Ka(M.paint_line[`line-opacity`]),"line-color":new Ka(M.paint_line[`line-color`]),"line-translate":new Q(M.paint_line[`line-translate`]),"line-translate-anchor":new Q(M.paint_line[`line-translate-anchor`]),"line-width":new Ka(M.paint_line[`line-width`]),"line-gap-width":new Ka(M.paint_line[`line-gap-width`]),"line-offset":new Ka(M.paint_line[`line-offset`]),"line-blur":new Ka(M.paint_line[`line-blur`]),"line-dasharray":new qa(M.paint_line[`line-dasharray`]),"line-pattern":new qa(M.paint_line[`line-pattern`]),"line-gradient":new Ya(M.paint_line[`line-gradient`])})},get layout(){return od||=new Xa({"line-cap":new Ka(M.layout_line[`line-cap`]),"line-join":new Ka(M.layout_line[`line-join`]),"line-miter-limit":new Ka(M.layout_line[`line-miter-limit`]),"line-round-limit":new Ka(M.layout_line[`line-round-limit`]),"line-sort-key":new Ka(M.layout_line[`line-sort-key`])})}};class ld extends Ka{possiblyEvaluate(e,t){return t=new Fa(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,n,r){return t=oe({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,n,r)}}let ud;class dd extends $a{constructor(e,t){super(e,cd,t),this.gradientVersion=0,ud||(ud=new ld(cd.paint.properties[`line-width`].specification),ud.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if(e===`line-gradient`){let e=this.gradientExpression();this.stepInterpolant=!!function(e){return e._styleExpression!==void 0}(e)&&e._styleExpression.expression instanceof Sn,this.gradientVersion=(this.gradientVersion+1)%(2**53-1)}}gradientExpression(){return this._transitionablePaint._values[`line-gradient`].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values[`line-floorwidth`]=ud.possiblyEvaluate(this._transitioningPaint._values[`line-width`].value,e)}createBucket(e){return new ad(e)}queryRadius(e){let t=e,n=fd(rc(`line-width`,this,t),rc(`line-gap-width`,this,t)),r=rc(`line-offset`,this,t);return n/2+Math.abs(r)+ic(this.paint.get(`line-translate`))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:r,geometry:i,transform:a,pixelsToTileUnits:o}){let s=ac(e,this.paint.get(`line-translate`),this.paint.get(`line-translate-anchor`),-a.bearingInRadians,o),c=o/2*fd(this.paint.get(`line-width`).evaluate(t,r),this.paint.get(`line-gap-width`).evaluate(t,r)),l=this.paint.get(`line-offset`).evaluate(t,r);return l&&(i=function(e,t){let r=[];for(let i of e){let e=oc(i),a=[];for(let r=0;r<e.length;r++){let i=e[r],o=e[r-1],s=e[r+1],c=r===0?new n(0,0):i.sub(o)._unit()._perp(),l=r===e.length-1?new n(0,0):s.sub(i)._unit()._perp(),u=c._add(l)._unit(),d=u.x*l.x+u.y*l.y;d!==0&&u._mult(1/d),a.push(u._mult(t)._add(i))}r.push(a)}return r}(i,l*o)),function(e,t,n){for(let r of t){if(e.length>=3){for(let t of r)if(tc(e,t))return!0}if(Ys(e,r,n))return!0}return!1}(s,i,c)}isTileClipped(){return!0}}function fd(e,t){return t>0?t+2*e:e}let pd=oo([{name:`a_pos_offset`,components:4,type:`Int16`},{name:`a_data`,components:4,type:`Uint16`},{name:`a_pixeloffset`,components:4,type:`Int16`}],4),md=oo([{name:`a_projected_pos`,components:3,type:`Float32`}],4);oo([{name:`a_fade_opacity`,components:1,type:`Uint32`}],4);let hd=oo([{name:`a_placed`,components:2,type:`Uint8`},{name:`a_shift`,components:2,type:`Float32`},{name:`a_box_real`,components:2,type:`Int16`}]);oo([{type:`Int16`,name:`anchorPointX`},{type:`Int16`,name:`anchorPointY`},{type:`Int16`,name:`x1`},{type:`Int16`,name:`y1`},{type:`Int16`,name:`x2`},{type:`Int16`,name:`y2`},{type:`Uint32`,name:`featureIndex`},{type:`Uint16`,name:`sourceLayerIndex`},{type:`Uint16`,name:`bucketIndex`}]);let gd=oo([{name:`a_pos`,components:2,type:`Int16`},{name:`a_anchor_pos`,components:2,type:`Int16`},{name:`a_extrude`,components:2,type:`Int16`}],4),_d=oo([{name:`a_pos`,components:2,type:`Float32`},{name:`a_radius`,components:1,type:`Float32`},{name:`a_flags`,components:2,type:`Int16`}],4);function vd(e,t,n){let r=t.layout.get(`text-transform`).evaluate(n,{});return r===`uppercase`?e=e.toLocaleUpperCase():r===`lowercase`&&(e=e.toLocaleLowerCase()),Pa.applyArabicShaping&&(e=Pa.applyArabicShaping(e)),e}function yd(e,t,n){for(let r of e.sections)r.text=vd(r.text,t,n);return e}oo([{name:`triangle`,components:3,type:`Uint16`}]),oo([{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`}]),oo([{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`}]),oo([{type:`Float32`,name:`offsetX`}]),oo([{type:`Int16`,name:`x`},{type:`Int16`,name:`y`},{type:`Int16`,name:`tileUnitDistanceFromAnchor`}]),oo([{type:`Uint16`,name:`textAnchor`},{type:`Float32`,components:2,name:`textOffset`}]);var bd=24;let xd={"!":`︕`,"#":`#`,$:`$`,"%":`%`,"&":`&`,"(":`︵`,")":`︶`,"*":`*`,"+":`+`,",":`︐`,"-":`︲`,".":`・`,"/":`/`,":":`︓`,";":`︔`,"<":`︿`,"=":`=`,">":`﹀`,"?":`︖`,"@":`@`,"[":`﹇`,"\\":`\`,"]":`﹈`,"^":`^`,_:`︳`,"`":```,"{":`︷`,"|":`―`,"}":`︸`,"~":`~`,"¢":`¢`,"£":`£`,"¥":`¥`,"¦":`¦`,"¬":`¬`,"¯":` ̄`,"–":`︲`,"—":`︱`,"‘":`﹃`,"’":`﹄`,"“":`﹁`,"”":`﹂`,"…":`︙`,"⋯":`︙`,"‧":`・`,"₩":`₩`,"、":`︑`,"。":`︒`,"〈":`︿`,"〉":`﹀`,"《":`︽`,"》":`︾`,"「":`﹁`,"」":`﹂`,"『":`﹃`,"』":`﹄`,"【":`︻`,"】":`︼`,"〔":`︹`,"〕":`︺`,"〖":`︗`,"〗":`︘`,"!":`︕`,"(":`︵`,")":`︶`,",":`︐`,"-":`︲`,".":`・`,":":`︓`,";":`︔`,"<":`︿`,">":`﹀`,"?":`︖`,"[":`﹇`,"]":`﹈`,"_":`︳`,"{":`︷`,"|":`―`,"}":`︸`,"⦅":`︵`,"⦆":`︶`,"。":`︒`,"「":`﹁`,"」":`﹂`},Sd={10:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},Cd={40:!0};function wd(e,t,n,r,i,a){if(`fontStack`in t){let r=n[t.fontStack]?.[e];return r?r.metrics.advance*t.scale+i:0}{let e=r[t.imageName];return e?e.displaySize[0]*t.scale*bd/a+i:0}}function Td(e,t,n,r){let i=(e-t)**2;return r?e<t?i/2:2*i:i+Math.abs(n)*n}function Ed(e,t,n){let r=0;return e===10&&(r-=1e4),n&&(r+=150),e!==40&&e!==65288||(r+=50),t!==41&&t!==65289||(r+=50),r}function Dd(e,t,n,r,i,a){let o=null,s=Td(t,n,i,a);for(let e of r){let r=Td(t-e.x,n,i,a)+e.badness;r<=s&&(o=e,s=r)}return{index:e,x:t,priorBreak:o,badness:s}}function Od(e){return e?Od(e.priorBreak).concat(e.index):[]}class kd{constructor(e=``,t=[],n=[]){this.text=e,this.sections=t,this.sectionIndex=n,this.imageSectionID=null}static fromFeature(e,t){let n=new kd;for(let r of e.sections)r.image?n.addImageSection(r):n.addTextSection(r,t);return n}length(){return[...this.text].length}getSection(e){return this.sections[this.sectionIndex[e]]}getSectionIndex(e){return this.sectionIndex[e]}verticalizePunctuation(){this.text=function(e){let t=``,n={premature:!0,value:void 0},r=e[Symbol.iterator](),i=r.next(),a=e[Symbol.iterator]();a.next();let o=a.next();for(;!i.done;)t+=!o.done&&ka(o.value.codePointAt(0))&&!xd[o.value]||!n.premature&&ka(n.value.codePointAt(0))&&!xd[n.value]||!xd[i.value]?i.value:xd[i.value],n={value:i.value,premature:!1},i=r.next(),o=a.next();return t}(this.text)}hasZeroWidthSpaces(){return this.text.includes(`​`)}trim(){let e=this.text.match(/^\s*/),t=e?e[0].length:0,n=this.text.match(/\S\s*$/),r=n?n[0].length-1:0;this.text=this.text.substring(t,this.text.length-r),this.sectionIndex=this.sectionIndex.slice(t,this.sectionIndex.length-r)}substring(e,t){let n=[...this.text].slice(e,t).join(``),r=this.sectionIndex.slice(e,t);return new kd(n,this.sections,r)}toCodeUnitIndex(e){return[...this.text].slice(0,e).join(``).length}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((e,t)=>Math.max(e,this.sections[t].scale)),0)}getMaxImageSize(e){let t=0,n=0;for(let r=0;r<this.length();r++){let i=this.getSection(r);if(`imageName`in i){let r=e[i.imageName];if(!r)continue;let a=r.displaySize;t=Math.max(t,a[0]),n=Math.max(n,a[1])}}return{maxImageWidth:t,maxImageHeight:n}}addTextSection(e,t){this.text+=e.text,this.sections.push({scale:e.scale||1,verticalAlign:e.verticalAlign||`bottom`,fontStack:e.fontStack||t});let n=this.sections.length-1;this.sectionIndex.push(...[...e.text].map((()=>n)))}addImageSection(e){let t=e.image?e.image.name:``;if(t.length===0)return void fe(`Can't add FormattedSection with an empty image.`);let n=this.getNextImageSectionCharCode();n?(this.text+=String.fromCharCode(n),this.sections.push({scale:1,verticalAlign:e.verticalAlign||`bottom`,imageName:t}),this.sectionIndex.push(this.sections.length-1)):fe(`Reached maximum number of images 6401`)}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(e,t,n,r,i){let a=[],o=this.determineAverageLineWidth(e,t,n,r,i),s=this.hasZeroWidthSpaces(),c=0,l=0,u=this.text[Symbol.iterator](),d=u.next(),f=this.text[Symbol.iterator]();f.next();let p=f.next(),m=this.text[Symbol.iterator]();m.next(),m.next();let h=m.next();for(;!d.done;){let t=this.getSection(l),g=d.value.codePointAt(0);if(Ca(g)||(c+=wd(g,t,n,r,e,i)),!p.done){let e=xa(g),n=p.value.codePointAt(0);(Sd[g]||e||`imageName`in t||!h.done&&Cd[n])&&a.push(Dd(l+1,c,o,a,Ed(g,n,e&&s),!1))}l++,d=u.next(),p=f.next(),h=m.next()}return Od(Dd(this.length(),c,o,a,0,!0))}determineAverageLineWidth(e,t,n,r,i){let a=0,o=0;for(let t of this.text){let s=this.getSection(o);a+=wd(t.codePointAt(0),s,n,r,e,i),o++}return a/Math.max(1,Math.ceil(a/t))}}let Ad=4294967296,jd=1/Ad,Md=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`);class Nd{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,t,n=this.length){for(;this.pos<n;){let n=this.readVarint(),r=n>>3,i=this.pos;this.type=7&n,e(r,t,this),this.pos===i&&this.skip(n)}return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){let e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){let e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){let e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Ad;return this.pos+=8,e}readSFixed64(){let e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Ad;return this.pos+=8,e}readFloat(){let e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){let e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){let t=this.buf,n,r;return r=t[this.pos++],n=127&r,r<128?n:(r=t[this.pos++],n|=(127&r)<<7,r<128?n:(r=t[this.pos++],n|=(127&r)<<14,r<128?n:(r=t[this.pos++],n|=(127&r)<<21,r<128?n:(r=t[this.pos],n|=(15&r)<<28,function(e,t,n){let r=n.buf,i,a;if(a=r[n.pos++],i=(112&a)>>4,a<128||(a=r[n.pos++],i|=(127&a)<<3,a<128)||(a=r[n.pos++],i|=(127&a)<<10,a<128)||(a=r[n.pos++],i|=(127&a)<<17,a<128)||(a=r[n.pos++],i|=(127&a)<<24,a<128)||(a=r[n.pos++],i|=(1&a)<<31,a<128))return Pd(e,i,t);throw Error(`Expected varint not more than 10 bytes`)}(n,e,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){let e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return!!this.readVarint()}readString(){let e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&Md?Md.decode(this.buf.subarray(t,e)):function(e,t,n){let r=``,i=t;for(;i<n;){let t=e[i],a,o,s,c=null,l=t>239?4:t>223?3:t>191?2:1;if(i+l>n)break;l===1?t<128&&(c=t):l===2?(a=e[i+1],(192&a)==128&&(c=(31&t)<<6|63&a,c<=127&&(c=null))):l===3?(a=e[i+1],o=e[i+2],(192&a)==128&&(192&o)==128&&(c=(15&t)<<12|(63&a)<<6|63&o,(c<=2047||c>=55296&&c<=57343)&&(c=null))):l===4&&(a=e[i+1],o=e[i+2],s=e[i+3],(192&a)==128&&(192&o)==128&&(192&s)==128&&(c=(15&t)<<18|(63&a)<<12|(63&o)<<6|63&s,(c<=65535||c>=1114112)&&(c=null))),c===null?(c=65533,l=1):c>65535&&(c-=65536,r+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),r+=String.fromCharCode(c),i+=l}return r}(this.buf,t,e)}readBytes(){let e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){let n=this.readPackedEnd();for(;this.pos<n;)e.push(this.readVarint(t));return e}readPackedSVarint(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSVarint());return e}readPackedBoolean(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readBoolean());return e}readPackedFloat(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFloat());return e}readPackedDouble(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readDouble());return e}readPackedFixed32(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed32());return e}readPackedSFixed32(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed32());return e}readPackedFixed64(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed64());return e}readPackedSFixed64(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed64());return e}readPackedEnd(){return this.type===2?this.readVarint()+this.pos:this.pos+1}skip(e){let t=7&e;if(t===0)for(;this.buf[this.pos++]>127;);else if(t===2)this.pos=this.readVarint()+this.pos;else if(t===5)this.pos+=4;else{if(t!==1)throw Error(`Unimplemented type: ${t}`);this.pos+=8}}writeTag(e,t){this.writeVarint(e<<3|t)}realloc(e){let t=this.length||16;for(;t<this.pos+e;)t*=2;if(t!==this.length){let e=new Uint8Array(t);e.set(this.buf),this.buf=e,this.dataView=new DataView(e.buffer),this.length=t}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(e){this.realloc(4),this.dataView.setInt32(this.pos,e,!0),this.pos+=4}writeSFixed32(e){this.realloc(4),this.dataView.setInt32(this.pos,e,!0),this.pos+=4}writeFixed64(e){this.realloc(8),this.dataView.setInt32(this.pos,-1&e,!0),this.dataView.setInt32(this.pos+4,Math.floor(e*jd),!0),this.pos+=8}writeSFixed64(e){this.realloc(8),this.dataView.setInt32(this.pos,-1&e,!0),this.dataView.setInt32(this.pos+4,Math.floor(e*jd),!0),this.pos+=8}writeVarint(e){(e=+e||0)>268435455||e<0?function(e,t){let n,r;if(e>=0?(n=e%4294967296|0,r=e/4294967296|0):(n=~(-e%4294967296),r=~(-e/4294967296),4294967295^n?n=n+1|0:(n=0,r=r+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw Error(`Given varint doesn't fit into 10 bytes`);t.realloc(10),function(e,t,n){n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,n.buf[n.pos]=127&(e>>>=7)}(n,0,t),function(e,t){let n=(7&e)<<4;t.buf[t.pos++]|=n|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))))}(r,t)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))}writeSVarint(e){this.writeVarint(e<0?2*-e-1:2*e)}writeBoolean(e){this.writeVarint(+e)}writeString(e){e=String(e),this.realloc(4*e.length),this.pos++;let t=this.pos;this.pos=function(e,t,n){for(let r,i,a=0;a<t.length;a++){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!i){r>56319||a+1===t.length?(e[n++]=239,e[n++]=191,e[n++]=189):i=r;continue}if(r<56320){e[n++]=239,e[n++]=191,e[n++]=189,i=r;continue}r=i-55296<<10|r-56320|65536,i=null}else i&&=(e[n++]=239,e[n++]=191,e[n++]=189,null);r<128?e[n++]=r:(r<2048?e[n++]=r>>6|192:(r<65536?e[n++]=r>>12|224:(e[n++]=r>>18|240,e[n++]=r>>12&63|128),e[n++]=r>>6&63|128),e[n++]=63&r|128)}return n}(this.buf,e,this.pos);let n=this.pos-t;n>=128&&Fd(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){let t=e.length;this.writeVarint(t),this.realloc(t);for(let n=0;n<t;n++)this.buf[this.pos++]=e[n]}writeRawMessage(e,t){this.pos++;let n=this.pos;e(t,this);let r=this.pos-n;r>=128&&Fd(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r}writeMessage(e,t,n){this.writeTag(e,2),this.writeRawMessage(t,n)}writePackedVarint(e,t){t.length&&this.writeMessage(e,Id,t)}writePackedSVarint(e,t){t.length&&this.writeMessage(e,Ld,t)}writePackedBoolean(e,t){t.length&&this.writeMessage(e,Bd,t)}writePackedFloat(e,t){t.length&&this.writeMessage(e,Rd,t)}writePackedDouble(e,t){t.length&&this.writeMessage(e,zd,t)}writePackedFixed32(e,t){t.length&&this.writeMessage(e,Vd,t)}writePackedSFixed32(e,t){t.length&&this.writeMessage(e,Hd,t)}writePackedFixed64(e,t){t.length&&this.writeMessage(e,Ud,t)}writePackedSFixed64(e,t){t.length&&this.writeMessage(e,Wd,t)}writeBytesField(e,t){this.writeTag(e,2),this.writeBytes(t)}writeFixed32Field(e,t){this.writeTag(e,5),this.writeFixed32(t)}writeSFixed32Field(e,t){this.writeTag(e,5),this.writeSFixed32(t)}writeFixed64Field(e,t){this.writeTag(e,1),this.writeFixed64(t)}writeSFixed64Field(e,t){this.writeTag(e,1),this.writeSFixed64(t)}writeVarintField(e,t){this.writeTag(e,0),this.writeVarint(t)}writeSVarintField(e,t){this.writeTag(e,0),this.writeSVarint(t)}writeStringField(e,t){this.writeTag(e,2),this.writeString(t)}writeFloatField(e,t){this.writeTag(e,5),this.writeFloat(t)}writeDoubleField(e,t){this.writeTag(e,1),this.writeDouble(t)}writeBooleanField(e,t){this.writeVarintField(e,+t)}}function Pd(e,t,n){return n?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function Fd(e,t,n){let r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));n.realloc(r);for(let t=n.pos-1;t>=e;t--)n.buf[t+r]=n.buf[t]}function Id(e,t){for(let n=0;n<e.length;n++)t.writeVarint(e[n])}function Ld(e,t){for(let n=0;n<e.length;n++)t.writeSVarint(e[n])}function Rd(e,t){for(let n=0;n<e.length;n++)t.writeFloat(e[n])}function zd(e,t){for(let n=0;n<e.length;n++)t.writeDouble(e[n])}function Bd(e,t){for(let n=0;n<e.length;n++)t.writeBoolean(e[n])}function Vd(e,t){for(let n=0;n<e.length;n++)t.writeFixed32(e[n])}function Hd(e,t){for(let n=0;n<e.length;n++)t.writeSFixed32(e[n])}function Ud(e,t){for(let n=0;n<e.length;n++)t.writeFixed64(e[n])}function Wd(e,t){for(let n=0;n<e.length;n++)t.writeSFixed64(e[n])}function Gd(e,t,n){e===1&&n.readMessage(Kd,t)}function Kd(e,t,n){if(e===3){let{id:e,bitmap:r,width:i,height:a,left:o,top:s,advance:c}=n.readMessage(qd,{});t.push({id:e,bitmap:new Cc({width:i+6,height:a+6},r),metrics:{width:i,height:a,left:o,top:s,advance:c}})}}function qd(e,t,n){e===1?t.id=n.readVarint():e===2?t.bitmap=n.readBytes():e===3?t.width=n.readVarint():e===4?t.height=n.readVarint():e===5?t.left=n.readSVarint():e===6?t.top=n.readSVarint():e===7&&(t.advance=n.readVarint())}function Jd(e){let t=0,n=0;for(let r of e)t+=r.w*r.h,n=Math.max(n,r.w);e.sort(((e,t)=>t.h-e.h));let r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),n),h:1/0}],i=0,a=0;for(let t of e)for(let e=r.length-1;e>=0;e--){let n=r[e];if(!(t.w>n.w||t.h>n.h)){if(t.x=n.x,t.y=n.y,a=Math.max(a,t.y+t.h),i=Math.max(i,t.x+t.w),t.w===n.w&&t.h===n.h){let t=r.pop();t&&e<r.length&&(r[e]=t)}else t.h===n.h?(n.x+=t.w,n.w-=t.w):t.w===n.w?(n.y+=t.h,n.h-=t.h):(r.push({x:n.x+t.w,y:n.y,w:n.w-t.w,h:t.h}),n.y+=t.h,n.h-=t.h);break}}return{w:i,h:a,fill:t/(i*a)||0}}class Yd{constructor(e,{pixelRatio:t,version:n,stretchX:r,stretchY:i,content:a,textFitWidth:o,textFitHeight:s}){this.paddedRect=e,this.pixelRatio=t,this.stretchX=r,this.stretchY=i,this.content=a,this.version=n,this.textFitWidth=o,this.textFitHeight=s}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class Xd{constructor(e,t){let n={},r={};this.haveRenderCallbacks=[];let i=[];this.addImages(e,n,i),this.addImages(t,r,i);let{w:a,h:o}=Jd(i),s=new wc({width:a||1,height:o||1});for(let t in e){let r=e[t],i=n[t].paddedRect;wc.copy(r.data,s,{x:0,y:0},{x:i.x+1,y:i.y+1},r.data)}for(let e in t){let n=t[e],i=r[e].paddedRect,a=i.x+1,o=i.y+1,c=n.data.width,l=n.data.height;wc.copy(n.data,s,{x:0,y:0},{x:a,y:o},n.data),wc.copy(n.data,s,{x:0,y:l-1},{x:a,y:o-1},{width:c,height:1}),wc.copy(n.data,s,{x:0,y:0},{x:a,y:o+l},{width:c,height:1}),wc.copy(n.data,s,{x:c-1,y:0},{x:a-1,y:o},{width:1,height:l}),wc.copy(n.data,s,{x:0,y:0},{x:a+c,y:o},{width:1,height:l})}this.image=s,this.iconPositions=n,this.patternPositions=r}addImages(e,t,n){for(let r in e){let i=e[r],a={x:0,y:0,w:i.data.width+2,h:i.data.height+2};n.push(a),t[r]=new Yd(a,i),i.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(e,t){e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(let n in e.updatedImages)this.patchUpdatedImage(this.iconPositions[n],e.getImage(n),t),this.patchUpdatedImage(this.patternPositions[n],e.getImage(n),t)}patchUpdatedImage(e,t,n){if(!e||!t||e.version===t.version)return;e.version=t.version;let[r,i]=e.tl;n.update(t.data,void 0,{x:r,y:i})}}var Zd;function Qd(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=kd.fromFeature(t,a),_;f===e.ax.vertical&&g.verticalizePunctuation();let v=g.determineLineBreaks(u,o,n,i,m),{processBidirectionalText:y,processStyledBidirectionalText:b}=Pa;if(y&&g.sections.length===1){_=[],v=v.map((e=>g.toCodeUnitIndex(e)));let e=y(g.toString(),v);for(let t of e){let e=[...t].map((()=>0));_.push(new kd(t,g.sections,e))}}else if(b){_=[],v=v.map((e=>g.toCodeUnitIndex(e)));let e=0,t=[];for(let n of g.text)t.push(...Array(n.length).fill(g.sectionIndex[e])),e++;let n=b(g.text,t,v);for(let e of n){let t=[],n=``;for(let r of e[0])t.push(e[1][n.length]),n+=r;_.push(new kd(e[0],g.sections,t))}}else _=function(e,t){let n=[],r=0;for(let i of t)n.push(e.substring(r,i)),r=i;return r<e.length()&&n.push(e.substring(r,e.length())),n}(g,v);let x=[],S={positionedLines:x,text:g.toString(),top:d[1],bottom:d[1],left:d[0],right:d[0],writingMode:f,iconsInText:!1,verticalizable:!1};return function(e,t,n,r,i,a,o,s,c,l,u,d){let f=0,p=0,m=0,h=0,g=s===`right`?1:s===`left`?0:.5,_=bd/d,v=0;for(let o of i){o.trim();let i=o.getMaxScale(),s={positionedGlyphs:[],lineOffset:0};e.positionedLines[v]=s;let d=s.positionedGlyphs,y=0;if(!o.length()){p+=a,++v;continue}let b=ef(r,o,_),x=0;for(let a of o.text){let s=o.getSection(x),m=a.codePointAt(0),h=nf(c,u,m),g={glyph:m,imageName:null,x:f,y:p+-17,vertical:h,scale:1,fontStack:``,sectionIndex:o.getSectionIndex(x),metrics:null,rect:null},v;if(`fontStack`in s){if(v=rf(s,m,h,b,t,n),!v)continue;g.fontStack=s.fontStack}else{if(e.iconsInText=!0,s.scale*=_,v=af(s,h,i,b,r),!v)continue;y=Math.max(y,v.imageOffset),g.imageName=s.imageName}let{rect:S,metrics:C,baselineOffset:w}=v;g.y+=w,g.scale=s.scale,g.metrics=C,g.rect=S,d.push(g),h?(e.verticalizable=!0,f+=(`imageName`in s?C.advance:bd)*s.scale+l):f+=C.advance*s.scale+l,x++}d.length!==0&&(m=Math.max(f-l,m),of(d,0,d.length-1,g)),f=0,s.lineOffset=Math.max(y,(i-1)*bd);let S=a*i+y;p+=S,h=Math.max(S,h),++v}let{horizontalAlign:y,verticalAlign:b}=$d(o);(function(e,t,n,r,i,a,o,s,c){let l=(t-n)*i,u=0;u=a===o?-r*c*o+.5*o:-s*r- -17;for(let t of e)for(let e of t.positionedGlyphs)e.x+=l,e.y+=u})(e.positionedLines,g,y,b,m,h,a,p,i.length),e.top+=-b*p,e.bottom=e.top+p,e.left+=-y*m,e.right=e.left+m}(S,n,r,i,_,s,c,l,f,u,p,h),!function(e){for(let t of e)if(t.positionedGlyphs.length!==0)return!1;return!0}(x)&&S}function $d(e){let t=.5,n=.5;switch(e){case`right`:case`top-right`:case`bottom-right`:t=1;break;case`left`:case`top-left`:case`bottom-left`:t=0}switch(e){case`bottom`:case`bottom-right`:case`bottom-left`:n=1;break;case`top`:case`top-right`:case`top-left`:n=0}return{horizontalAlign:t,verticalAlign:n}}function ef(e,t,n){let r=t.getMaxScale()*bd,{maxImageWidth:i,maxImageHeight:a}=t.getMaxImageSize(e),o=Math.max(r,a*n);return{verticalLineContentWidth:Math.max(r,i*n),horizontalLineContentHeight:o}}function tf(e){switch(e){case`top`:return 0;case`center`:return .5;default:return 1}}function nf(t,n,r){return!(t===e.ax.horizontal||!n&&!Sa(r)||n&&(Ca(r)||(i=r,/\p{sc=Arab}/u.test(String.fromCodePoint(i)))));var i}function rf(e,t,n,r,i,a){let o=function(e,t,n,r){if(e?.rect)return e;let i=t[n.fontStack]?.[r];return i?{rect:null,metrics:i.metrics}:null}(a[e.fontStack]?.[t],i,e,t);if(o===null)return null;let s;if(n)s=r.verticalLineContentWidth-e.scale*bd;else{let t=tf(e.verticalAlign);s=(r.horizontalLineContentHeight-e.scale*bd)*t}return{rect:o.rect,metrics:o.metrics,baselineOffset:s}}function af(e,t,n,r,i){let a=i[e.imageName];if(!a)return null;let o=a.paddedRect,s=a.displaySize,c={width:s[0],height:s[1],left:1,top:-3,advance:t?s[1]:s[0]},l;if(t)l=r.verticalLineContentWidth-s[1]*e.scale;else{let t=tf(e.verticalAlign);l=(r.horizontalLineContentHeight-s[1]*e.scale)*t}return{rect:o,metrics:c,baselineOffset:l,imageOffset:(t?s[0]:s[1])*e.scale-bd*n}}function of(e,t,n,r){if(r===0)return;let i=e[n],a=(e[n].x+i.metrics.advance*i.scale)*r;for(let r=t;r<=n;r++)e[r].x-=a}function sf(e,t,n){let{horizontalAlign:r,verticalAlign:i}=$d(n),a=t[0]-e.displaySize[0]*r,o=t[1]-e.displaySize[1]*i;return{image:e,top:o,bottom:o+e.displaySize[1],left:a,right:a+e.displaySize[0]}}function cf(e){let t=e.left,n=e.top,r=e.right-t,i=e.bottom-n,a=e.image.textFitWidth??`stretchOrShrink`,o=e.image.textFitHeight??`stretchOrShrink`,s=(e.image.content[2]-e.image.content[0])/(e.image.content[3]-e.image.content[1]);if(o===`proportional`){if(a===`stretchOnly`&&r/i<s||a===`proportional`){let e=Math.ceil(i*s);t*=e/r,r=e}}else if(a===`proportional`&&o===`stretchOnly`&&s!==0&&r/i>s){let e=Math.ceil(r/s);n*=e/i,i=e}return{x1:t,y1:n,x2:t+r,y2:n+i}}function lf(e,t,n,r,i,a){let o=e.image,s;if(o.content){let e=o.content,t=o.pixelRatio||1;s=[e[0]/t,e[1]/t,o.displaySize[0]-e[2]/t,o.displaySize[1]-e[3]/t]}let c=t.left*a,l=t.right*a,u,d,f,p;n===`width`||n===`both`?(p=i[0]+c-r[3],d=i[0]+l+r[1]):(p=i[0]+(c+l-o.displaySize[0])/2,d=p+o.displaySize[0]);let m=t.top*a,h=t.bottom*a;return n===`height`||n===`both`?(u=i[1]+m-r[0],f=i[1]+h+r[2]):(u=i[1]+(m+h-o.displaySize[1])/2,f=u+o.displaySize[1]),{image:o,top:u,right:d,bottom:f,left:p,collisionPadding:s}}X(`ImagePosition`,Yd),X(`ImageAtlas`,Xd),e.ax=void 0,(Zd=e.ax||={})[Zd.none=0]=`none`,Zd[Zd.horizontal=1]=`horizontal`,Zd[Zd.vertical=2]=`vertical`,Zd[Zd.horizontalOnly=3]=`horizontalOnly`;let uf=32640;function df(e,t){let{expression:n}=t;if(n.kind===`constant`)return{kind:`constant`,layoutSize:n.evaluate(new Fa(e+1))};if(n.kind===`source`)return{kind:`source`};{let{zoomStops:t,interpolationType:r}=n,i=0;for(;i<t.length&&t[i]<=e;)i++;i=Math.max(0,i-1);let a=i;for(;a<t.length&&t[a]<e+1;)a++;a=Math.min(t.length-1,a);let o=t[i],s=t[a];return n.kind===`composite`?{kind:`composite`,minZoom:o,maxZoom:s,interpolationType:r}:{kind:`camera`,minZoom:o,maxZoom:s,minSize:n.evaluate(new Fa(o)),maxSize:n.evaluate(new Fa(s)),interpolationType:r}}}function ff(e,t,n){let r=`never`,i=e.get(t);return i?r=i:e.get(n)&&(r=`always`),r}let pf=[{name:`a_fade_opacity`,components:1,type:`Uint8`,offset:0}];function mf(e,t,n,r,i,a,o,s,c,l,u,d,f){let p=s?Math.min(uf,Math.round(s[0])):0,m=s?Math.min(uf,Math.round(s[1])):0;e.emplaceBack(t,n,Math.round(32*r),Math.round(32*i),a,o,(p<<1)+ +!!c,m,16*l,16*u,256*d,256*f)}function hf(e,t,n){e.emplaceBack(t.x,t.y,n),e.emplaceBack(t.x,t.y,n),e.emplaceBack(t.x,t.y,n),e.emplaceBack(t.x,t.y,n)}function gf(e){for(let t of e.sections)if(Na(t.text))return!0;return!1}class _f{constructor(e){this.layoutVertexArray=new $o,this.indexArray=new is,this.programConfigurations=e,this.segments=new ss,this.dynamicLayoutVertexArray=new es,this.opacityVertexArray=new ts,this.hasVisibleVertices=!1,this.placedSymbolArray=new Io}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(e,t,n,r){this.isEmpty()||(n&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,pd.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,md.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,pf,!0),this.opacityVertexBuffer.itemSize=1),(n||r)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}X(`SymbolBuffers`,_f);class vf{constructor(e,t,n){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new n,this.segments=new ss,this.collisionVertexArray=new rs}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,hd.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}X(`CollisionBuffers`,vf);class yf{constructor(t){this.collisionBoxArray=t.collisionBoxArray,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.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasDependencies=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];let n=this.layers[0]._unevaluatedLayout._values;this.textSizeData=df(this.zoom,n[`text-size`]),this.iconSizeData=df(this.zoom,n[`icon-size`]);let r=this.layers[0].layout,i=r.get(`symbol-sort-key`),a=r.get(`symbol-z-order`);this.canOverlap=ff(r,`text-overlap`,`text-allow-overlap`)!==`never`||ff(r,`icon-overlap`,`icon-allow-overlap`)!==`never`||r.get(`text-ignore-placement`)||r.get(`icon-ignore-placement`),this.sortFeaturesByKey=a!==`viewport-y`&&!i.isConstant(),this.sortFeaturesByY=(a===`viewport-y`||a===`auto`&&!this.sortFeaturesByKey)&&this.canOverlap,r.get(`symbol-placement`)===`point`&&(this.writingModes=r.get(`text-writing-mode`).map((t=>e.ax[t]))),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.sourceID=t.sourceID}createArrays(){this.text=new _f(new Is(this.layers,this.zoom,(e=>e.startsWith(`text`)))),this.icon=new _f(new Is(this.layers,this.zoom,(e=>e.startsWith(`icon`)))),this.glyphOffsetArray=new zo,this.lineVertexArray=new Bo,this.symbolInstances=new Ro,this.textAnchorOffsets=new Ho}calculateGlyphDependencies(e,t,n,r,i){for(let a of e)if(t[a.codePointAt(0)]=!0,(n||r)&&i){let e=xd[a];e&&(t[e.codePointAt(0)]=!0)}}populate(t,n,r){let i=this.layers[0],a=i.layout,o=a.get(`text-font`),s=a.get(`text-field`),c=a.get(`icon-image`),l=(s.value.kind!==`constant`||s.value.value instanceof qt&&!s.value.value.isEmpty()||s.value.value.toString().length>0)&&(o.value.kind!==`constant`||o.value.value.length>0),u=c.value.kind!==`constant`||!!c.value.value||Object.keys(c.parameters).length>0,d=a.get(`symbol-sort-key`);if(this.features=[],!l&&!u)return;let f=n.iconDependencies,p=n.glyphDependencies,m=n.availableImages,h=new Fa(this.zoom);for(let{feature:n,id:s,index:c,sourceLayerIndex:g}of t){let t=i._featureFilter.needGeometry,_=Hs(n,t);if(!i._featureFilter.filter(h,_,r))continue;let v,y;if(t||(_.geometry=Vs(n)),l){let e=i.getValueAndResolveTokens(`text-field`,_,r,m),t=qt.factory(e);this.hasRTLText||=gf(t),(!this.hasRTLText||Pa.getRTLTextPluginStatus()===`unavailable`||this.hasRTLText&&Pa.isParsed())&&(v=yd(t,i,_))}if(u){let e=i.getValueAndResolveTokens(`icon-image`,_,r,m);y=e instanceof en?e:en.fromString(e)}if(!v&&!y)continue;let b=this.sortFeaturesByKey?d.evaluate(_,{},r):void 0;if(this.features.push({id:s,text:v,icon:y,index:c,sourceLayerIndex:g,geometry:_.geometry,properties:n.properties,type:jl.types[n.type],sortKey:b}),y&&(f[y.name]=!0),v){let t=o.evaluate(_,{},r).join(`,`),n=a.get(`text-rotation-alignment`)!==`viewport`&&a.get(`symbol-placement`)!==`point`;this.allowVerticalPlacement=this.writingModes?.includes(e.ax.vertical);for(let e of v.sections)if(e.image)f[e.image.name]=!0;else{let r=wa(v.toString()),i=e.fontStack||t;p[i]||(p[i]={}),this.calculateGlyphDependencies(e.text,p[i],n,this.allowVerticalPlacement,r)}}}a.get(`symbol-placement`)===`line`&&(this.features=function(e){let t={},n={},r=[],i=0;function a(t){r.push(e[t]),i++}function o(e,t,i){let a=n[e];return delete n[e],n[t]=a,r[a].geometry[0].pop(),r[a].geometry[0]=r[a].geometry[0].concat(i[0]),a}function s(e,n,i){let a=t[n];return delete t[n],t[e]=a,r[a].geometry[0].shift(),r[a].geometry[0]=i[0].concat(r[a].geometry[0]),a}function c(e,t,n){let r=n?t[0][t[0].length-1]:t[0][0];return`${e}:${r.x}:${r.y}`}for(let l=0;l<e.length;l++){let u=e[l],d=u.geometry,f=u.text?u.text.toString():null;if(!f){a(l);continue}let p=c(f,d),m=c(f,d,!0);if(p in n&&m in t&&n[p]!==t[m]){let e=s(p,m,d),i=o(p,m,r[e].geometry);delete t[p],delete n[m],n[c(f,r[i].geometry,!0)]=i,r[e].geometry=null}else p in n?o(p,m,d):m in t?s(p,m,d):(a(l),t[p]=i-1,n[m]=i-1)}return r.filter((e=>e.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((e,t)=>e.sortKey-t.sortKey))}update(e,t,n){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:n}),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:n}))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){let n=this.lineVertexArray.length;if(e.segment!==void 0){let n=e.dist(t[e.segment+1]),r=e.dist(t[e.segment]),i={};for(let r=e.segment+1;r<t.length;r++)i[r]={x:t[r].x,y:t[r].y,tileUnitDistanceFromAnchor:n},r<t.length-1&&(n+=t[r+1].dist(t[r]));for(let n=e.segment||0;n>=0;n--)i[n]={x:t[n].x,y:t[n].y,tileUnitDistanceFromAnchor:r},n>0&&(r+=t[n-1].dist(t[n]));for(let e=0;e<t.length;e++){let t=i[e];this.lineVertexArray.emplaceBack(t.x,t.y,t.tileUnitDistanceFromAnchor)}}return{lineStartIndex:n,lineLength:this.lineVertexArray.length-n}}addSymbols(t,n,r,i,a,o,s,c,l,u,d,f){let p=t.indexArray,m=t.layoutVertexArray,h=t.segments.prepareSegment(4*n.length,m,p,this.canOverlap?o.sortKey:void 0),g=this.glyphOffsetArray.length,_=h.vertexLength,v=this.allowVerticalPlacement&&s===e.ax.vertical?Math.PI/2:0,y=o.text&&o.text.sections;for(let e=0;e<n.length;e++){let{tl:i,tr:a,bl:s,br:l,tex:u,pixelOffsetTL:d,pixelOffsetBR:g,minFontScaleX:_,minFontScaleY:b,glyphOffset:x,isSDF:S,sectionIndex:C}=n[e],w=h.vertexLength,T=x[1];mf(m,c.x,c.y,i.x,T+i.y,u.x,u.y,r,S,d.x,d.y,_,b),mf(m,c.x,c.y,a.x,T+a.y,u.x+u.w,u.y,r,S,g.x,d.y,_,b),mf(m,c.x,c.y,s.x,T+s.y,u.x,u.y+u.h,r,S,d.x,g.y,_,b),mf(m,c.x,c.y,l.x,T+l.y,u.x+u.w,u.y+u.h,r,S,g.x,g.y,_,b),hf(t.dynamicLayoutVertexArray,c,v),p.emplaceBack(w,w+2,w+1),p.emplaceBack(w+1,w+2,w+3),h.vertexLength+=4,h.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(x[0]),e!==n.length-1&&C===n[e+1].sectionIndex||t.programConfigurations.populatePaintArrays(m.length,o,o.index,{imagePositions:{},canonical:f,formattedSection:y?.[C]})}t.placedSymbolArray.emplaceBack(c.x,c.y,g,this.glyphOffsetArray.length-g,_,l,u,c.segment,r?r[0]:0,r?r[1]:0,i[0],i[1],s,0,!1,0,d)}_addCollisionDebugVertex(e,t,n,r,i,a){return t.emplaceBack(0,0),e.emplaceBack(n.x,n.y,r,i,Math.round(a.x),Math.round(a.y))}addCollisionDebugVertices(e,t,r,i,a,o,s){let c=a.segments.prepareSegment(4,a.layoutVertexArray,a.indexArray),l=c.vertexLength,u=a.layoutVertexArray,d=a.collisionVertexArray,f=s.anchorX,p=s.anchorY;this._addCollisionDebugVertex(u,d,o,f,p,new n(e,t)),this._addCollisionDebugVertex(u,d,o,f,p,new n(r,t)),this._addCollisionDebugVertex(u,d,o,f,p,new n(r,i)),this._addCollisionDebugVertex(u,d,o,f,p,new n(e,i)),c.vertexLength+=4;let m=a.indexArray;m.emplaceBack(l,l+1),m.emplaceBack(l+1,l+2),m.emplaceBack(l+2,l+3),m.emplaceBack(l+3,l),c.primitiveLength+=4}addDebugCollisionBoxes(e,t,n,r){for(let i=e;i<t;i++){let e=this.collisionBoxArray.get(i);this.addCollisionDebugVertices(e.x1,e.y1,e.x2,e.y2,r?this.textCollisionBox:this.iconCollisionBox,e.anchorPoint,n)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new vf(ns,gd.members,as),this.iconCollisionBox=new vf(ns,gd.members,as);for(let e=0;e<this.symbolInstances.length;e++){let t=this.symbolInstances.get(e);this.addDebugCollisionBoxes(t.textBoxStartIndex,t.textBoxEndIndex,t,!0),this.addDebugCollisionBoxes(t.verticalTextBoxStartIndex,t.verticalTextBoxEndIndex,t,!0),this.addDebugCollisionBoxes(t.iconBoxStartIndex,t.iconBoxEndIndex,t,!1),this.addDebugCollisionBoxes(t.verticalIconBoxStartIndex,t.verticalIconBoxEndIndex,t,!1)}}_deserializeCollisionBoxesForSymbol(e,t,n,r,i,a,o,s,c){let l={};for(let r=t;r<n;r++){let t=e.get(r);l.textBox={x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,anchorPointX:t.anchorPointX,anchorPointY:t.anchorPointY},l.textFeatureIndex=t.featureIndex;break}for(let t=r;t<i;t++){let n=e.get(t);l.verticalTextBox={x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,anchorPointX:n.anchorPointX,anchorPointY:n.anchorPointY},l.verticalTextFeatureIndex=n.featureIndex;break}for(let t=a;t<o;t++){let n=e.get(t);l.iconBox={x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,anchorPointX:n.anchorPointX,anchorPointY:n.anchorPointY},l.iconFeatureIndex=n.featureIndex;break}for(let t=s;t<c;t++){let n=e.get(t);l.verticalIconBox={x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,anchorPointX:n.anchorPointX,anchorPointY:n.anchorPointY},l.verticalIconFeatureIndex=n.featureIndex;break}return l}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let t=0;t<this.symbolInstances.length;t++){let n=this.symbolInstances.get(t);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,n.textBoxStartIndex,n.textBoxEndIndex,n.verticalTextBoxStartIndex,n.verticalTextBoxEndIndex,n.iconBoxStartIndex,n.iconBoxEndIndex,n.verticalIconBoxStartIndex,n.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,t){let n=e.placedSymbolArray.get(t),r=n.vertexStartIndex+4*n.numGlyphs;for(let t=n.vertexStartIndex;t<r;t+=4)e.indexArray.emplaceBack(t,t+2,t+1),e.indexArray.emplaceBack(t+1,t+2,t+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;let t=Math.sin(e),n=Math.cos(e),r=[],i=[],a=[];for(let e=0;e<this.symbolInstances.length;++e){a.push(e);let o=this.symbolInstances.get(e);r.push(0|Math.round(t*o.anchorX+n*o.anchorY)),i.push(o.featureIndex)}return a.sort(((e,t)=>r[e]-r[t]||i[t]-i[e])),a}addToSortKeyRanges(e,t){let n=this.sortKeyRanges[this.sortKeyRanges.length-1];n?.sortKey===t?n.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(let e of this.symbolInstanceIndexes){let t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex);let n=[t.rightJustifiedTextSymbolIndex,t.centerJustifiedTextSymbolIndex,t.leftJustifiedTextSymbolIndex];for(let e=0;e<n.length;e++){let t=n[e];t>=0&&n.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t)}t.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,t.verticalPlacedTextSymbolIndex),t.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.placedIconSymbolIndex),t.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let bf,xf;X(`SymbolBucket`,yf,{omit:[`layers`,`collisionBoxArray`,`features`,`compareText`]}),yf.MAX_GLYPHS=65535,yf.addDynamicAttributes=hf;var Sf={get paint(){return xf||=new Xa({"icon-opacity":new Ka(M.paint_symbol[`icon-opacity`]),"icon-color":new Ka(M.paint_symbol[`icon-color`]),"icon-halo-color":new Ka(M.paint_symbol[`icon-halo-color`]),"icon-halo-width":new Ka(M.paint_symbol[`icon-halo-width`]),"icon-halo-blur":new Ka(M.paint_symbol[`icon-halo-blur`]),"icon-translate":new Q(M.paint_symbol[`icon-translate`]),"icon-translate-anchor":new Q(M.paint_symbol[`icon-translate-anchor`]),"text-opacity":new Ka(M.paint_symbol[`text-opacity`]),"text-color":new Ka(M.paint_symbol[`text-color`],{runtimeType:rt,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new Ka(M.paint_symbol[`text-halo-color`]),"text-halo-width":new Ka(M.paint_symbol[`text-halo-width`]),"text-halo-blur":new Ka(M.paint_symbol[`text-halo-blur`]),"text-translate":new Q(M.paint_symbol[`text-translate`]),"text-translate-anchor":new Q(M.paint_symbol[`text-translate-anchor`])})},get layout(){return bf||=new Xa({"symbol-placement":new Q(M.layout_symbol[`symbol-placement`]),"symbol-spacing":new Q(M.layout_symbol[`symbol-spacing`]),"symbol-avoid-edges":new Q(M.layout_symbol[`symbol-avoid-edges`]),"symbol-sort-key":new Ka(M.layout_symbol[`symbol-sort-key`]),"symbol-z-order":new Q(M.layout_symbol[`symbol-z-order`]),"icon-allow-overlap":new Q(M.layout_symbol[`icon-allow-overlap`]),"icon-overlap":new Q(M.layout_symbol[`icon-overlap`]),"icon-ignore-placement":new Q(M.layout_symbol[`icon-ignore-placement`]),"icon-optional":new Q(M.layout_symbol[`icon-optional`]),"icon-rotation-alignment":new Q(M.layout_symbol[`icon-rotation-alignment`]),"icon-size":new Ka(M.layout_symbol[`icon-size`]),"icon-text-fit":new Q(M.layout_symbol[`icon-text-fit`]),"icon-text-fit-padding":new Q(M.layout_symbol[`icon-text-fit-padding`]),"icon-image":new Ka(M.layout_symbol[`icon-image`]),"icon-rotate":new Ka(M.layout_symbol[`icon-rotate`]),"icon-padding":new Ka(M.layout_symbol[`icon-padding`]),"icon-keep-upright":new Q(M.layout_symbol[`icon-keep-upright`]),"icon-offset":new Ka(M.layout_symbol[`icon-offset`]),"icon-anchor":new Ka(M.layout_symbol[`icon-anchor`]),"icon-pitch-alignment":new Q(M.layout_symbol[`icon-pitch-alignment`]),"text-pitch-alignment":new Q(M.layout_symbol[`text-pitch-alignment`]),"text-rotation-alignment":new Q(M.layout_symbol[`text-rotation-alignment`]),"text-field":new Ka(M.layout_symbol[`text-field`]),"text-font":new Ka(M.layout_symbol[`text-font`]),"text-size":new Ka(M.layout_symbol[`text-size`]),"text-max-width":new Ka(M.layout_symbol[`text-max-width`]),"text-line-height":new Q(M.layout_symbol[`text-line-height`]),"text-letter-spacing":new Ka(M.layout_symbol[`text-letter-spacing`]),"text-justify":new Ka(M.layout_symbol[`text-justify`]),"text-radial-offset":new Ka(M.layout_symbol[`text-radial-offset`]),"text-variable-anchor":new Q(M.layout_symbol[`text-variable-anchor`]),"text-variable-anchor-offset":new Ka(M.layout_symbol[`text-variable-anchor-offset`]),"text-anchor":new Ka(M.layout_symbol[`text-anchor`]),"text-max-angle":new Q(M.layout_symbol[`text-max-angle`]),"text-writing-mode":new Q(M.layout_symbol[`text-writing-mode`]),"text-rotate":new Ka(M.layout_symbol[`text-rotate`]),"text-padding":new Q(M.layout_symbol[`text-padding`]),"text-keep-upright":new Q(M.layout_symbol[`text-keep-upright`]),"text-transform":new Ka(M.layout_symbol[`text-transform`]),"text-offset":new Ka(M.layout_symbol[`text-offset`]),"text-allow-overlap":new Q(M.layout_symbol[`text-allow-overlap`]),"text-overlap":new Q(M.layout_symbol[`text-overlap`]),"text-ignore-placement":new Q(M.layout_symbol[`text-ignore-placement`]),"text-optional":new Q(M.layout_symbol[`text-optional`])})}};class Cf{constructor(e){if(e.property.overrides===void 0)throw Error(`overrides must be provided to instantiate FormatSectionOverride class`);this.type=e.property.overrides?e.property.overrides.runtimeType:et,this.defaultValue=e}evaluate(e){if(e.formattedSection){let t=this.defaultValue.property.overrides;if(t?.hasOverride(e.formattedSection))return t.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}X(`FormatSectionOverride`,Cf,{omit:[`defaultValue`]});class wf extends $a{constructor(e,t){super(e,Sf,t)}recalculate(e,t){if(super.recalculate(e,t),this.layout.get(`icon-rotation-alignment`)===`auto`&&(this.layout._values[`icon-rotation-alignment`]=this.layout.get(`symbol-placement`)===`point`?`viewport`:`map`),this.layout.get(`text-rotation-alignment`)===`auto`&&(this.layout._values[`text-rotation-alignment`]=this.layout.get(`symbol-placement`)===`point`?`viewport`:`map`),this.layout.get(`text-pitch-alignment`)===`auto`&&(this.layout._values[`text-pitch-alignment`]=this.layout.get(`text-rotation-alignment`)===`map`?`map`:`viewport`),this.layout.get(`icon-pitch-alignment`)===`auto`&&(this.layout._values[`icon-pitch-alignment`]=this.layout.get(`icon-rotation-alignment`)),this.layout.get(`symbol-placement`)===`point`){let e=this.layout.get(`text-writing-mode`);if(e){let t=[];for(let n of e)t.includes(n)||t.push(n);this.layout._values[`text-writing-mode`]=t}else this.layout._values[`text-writing-mode`]=[`horizontal`]}this._setPaintOverrides()}getValueAndResolveTokens(e,t,n,r){let i=this.layout.get(e).evaluate(t,{},n,r),a=this._unevaluatedLayout._values[e];return a.isDataDriven()||q(a.value)||!i?i:function(e,t){return t.replace(/{([^{}]+)}/g,((t,n)=>e&&n in e?String(e[n]):``))}(t.properties,i)}createBucket(e){return new yf(e)}queryRadius(){return 0}queryIntersectsFeature(){throw Error(`Should take a different path in FeatureIndex`)}_setPaintOverrides(){for(let e of Sf.paint.overridableProperties){if(!wf.hasPaintOverride(this.layout,e))continue;let t=this.paint.get(e),n=new ci(new Cf(t),t.property.specification),r=null;r=t.value.kind===`constant`||t.value.kind===`source`?new ui(`source`,n):new J(`composite`,n,t.value.zoomStops),this.paint._values[e]=new Wa(t.property,r,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,n){return!(!this.layout||t.isDataDriven()||n.isDataDriven())&&wf.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){let n=e.get(`text-field`),r=Sf.paint.properties[t],i=!1,a=e=>{for(let t of e)if(r.overrides?.hasOverride(t))return void(i=!0)};if(n.value.kind===`constant`&&n.value.value instanceof qt)a(n.value.value.sections);else if(n.value.kind===`source`||n.value.kind===`composite`){let e=t=>{i||(t instanceof z&&an(t.value)===ct?a(t.value.sections):t instanceof Bn?a(t.sections):t.eachChild(e))},t=n.value;t._styleExpression&&e(t._styleExpression.expression)}return i}}let Tf;var Ef={get paint(){return Tf||=new Xa({"background-color":new Q(M.paint_background[`background-color`]),"background-pattern":new Ja(M.paint_background[`background-pattern`]),"background-opacity":new Q(M.paint_background[`background-opacity`])})}};class Df extends $a{constructor(e,t){super(e,Ef,t)}}class Of extends $a{constructor(e,t){super(e,{},t),this.onAdd=e=>{this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)},this.onRemove=e=>{this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)},this.implementation=e}is3D(){return this.implementation.renderingMode===`3d`}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw Error(`Custom layers cannot be serialized`)}}class kf{constructor(e){this._methodToThrottle=e,this._triggered=!1,this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()}}trigger(){var e;this._triggered||(this._triggered=!0,(e=this._channel)==null||e.port1.postMessage(!0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}let Af={once:!0},jf=6371008.8;class Mf{constructor(e,t){if(isNaN(e)||isNaN(t))throw Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw Error(`Invalid LngLat latitude value: must be between -90 and 90`)}wrap(){return new Mf(ae(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){let t=Math.PI/180,n=this.lat*t,r=e.lat*t,i=Math.sin(n)*Math.sin(r)+Math.cos(n)*Math.cos(r)*Math.cos((e.lng-this.lng)*t);return jf*Math.acos(Math.min(i,1))}static convert(e){if(e instanceof Mf)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new Mf(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e==`object`&&e)return new Mf(Number(`lng`in e?e.lng:e.lon),Number(e.lat));throw Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}let Nf=2*Math.PI*jf;function Pf(e){return Nf*Math.cos(e*Math.PI/180)}function Ff(e){return(180+e)/360}function If(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Lf(e,t){return e/Pf(t)}function Rf(e){return 360*e-180}function zf(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function Bf(e,t){return e*Pf(zf(t))}class Vf{constructor(e,t,n=0){this.x=+e,this.y=+t,this.z=+n}static fromLngLat(e,t=0){let n=Mf.convert(e);return new Vf(Ff(n.lng),If(n.lat),Lf(t,n.lat))}toLngLat(){return new Mf(Rf(this.x),zf(this.y))}toAltitude(){return Bf(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Nf*(e=zf(this.y),1/Math.cos(e*Math.PI/180));var e}}function Hf(e,t,n){var r=2*Math.PI*6378137/256/2**n;return[e*r-2*Math.PI*6378137/2,t*r-2*Math.PI*6378137/2]}class Uf{constructor(e,t,n){if(!function(e,t,n){return!(e<0||e>25||n<0||n>=2**e||t<0||t>=2**e)}(e,t,n))throw Error(`x=${t}, y=${n}, z=${e} outside of bounds. 0<=x<${2**e}, 0<=y<${2**e} 0<=z<=25 `);this.z=e,this.x=t,this.y=n,this.key=Kf(0,e,e,t,n)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t,n){let r=(a=this.y,o=this.z,s=Hf(256*(i=this.x),256*(a=2**o-a-1),o),c=Hf(256*(i+1),256*(a+1),o),s[0]+`,`+s[1]+`,`+c[0]+`,`+c[1]);var i,a,o,s,c;let l=function(e,t,n){let r=``;for(let i=e;i>0;i--){let e=1<<i-1;r+=(t&e?1:0)+(n&e?2:0)}return r}(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace(/{prefix}/g,(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String(n===`tms`?2**this.z-this.y-1:this.y)).replace(/{ratio}/g,t>1?`@2x`:``).replace(/{quadkey}/g,l).replace(/{bbox-epsg-3857}/g,r)}isChildOf(e){let t=this.z-e.z;return t>0&&e.x===this.x>>t&&e.y===this.y>>t}getTilePoint(e){let t=2**this.z;return new n((e.x*t-this.x)*O,(e.y*t-this.y)*O)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Wf{constructor(e,t){this.wrap=e,this.canonical=t,this.key=Kf(e,t.z,t.z,t.x,t.y)}}class Gf{constructor(e,t,n,r,i){if(this.terrainRttPosMatrix32f=null,e<n)throw Error(`overscaledZ should be >= z; overscaledZ = ${e}; z = ${n}`);this.overscaledZ=e,this.wrap=t,this.canonical=new Uf(n,+r,+i),this.key=Kf(t,e,n,r,i)}clone(){return new Gf(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){if(e>this.overscaledZ)throw Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);let t=this.canonical.z-e;return e>this.canonical.z?new Gf(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Gf(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(e,t){if(e>this.overscaledZ)throw Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);let n=this.canonical.z-e;return e>this.canonical.z?Kf(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y):Kf(this.wrap*+t,e,e,this.canonical.x>>n,this.canonical.y>>n)}isChildOf(e){if(e.wrap!==this.wrap||this.overscaledZ-e.overscaledZ<=0)return!1;if(e.overscaledZ===0)return this.overscaledZ>0;let t=this.canonical.z-e.canonical.z;return!(t<0)&&e.canonical.x===this.canonical.x>>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new Gf(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];let t=this.canonical.z+1,n=2*this.canonical.x,r=2*this.canonical.y;return[new Gf(t,this.wrap,t,n,r),new Gf(t,this.wrap,t,n+1,r),new Gf(t,this.wrap,t,n,r+1),new Gf(t,this.wrap,t,n+1,r+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new Gf(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new Gf(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return 2**(this.overscaledZ-this.canonical.z)}toUnwrapped(){return new Wf(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(e){return this.canonical.getTilePoint(new Vf(e.x-this.wrap,e.y))}normalizeCoordinates(e,t,n=8192){if(e>=0&&e<n&&t>=0&&t<n)return{tileID:this,x:e,y:t};let r=Math.floor(e/n),i=Math.floor(t/n),a=e-r*n,o=t-i*n,s=this.canonical.z,c=1<<s,l=this.canonical.y+i;if(l<0||l>=c)return null;let u=this.canonical.x+r,d=this.wrap;return u<0?(d-=Math.ceil(-u/c),u=(u%c+c)%c):u>=c&&(d+=Math.floor(u/c),u%=c),{tileID:new Gf(this.overscaledZ,d,s,u,l),x:a,y:o}}}function Kf(e,t,n,r,i){(e*=2)<0&&(e=-1*e-1);let a=1<<n;return(a*a*e+a*i+r).toString(36)+n.toString(36)+t.toString(36)}X(`CanonicalTileID`,Uf),X(`OverscaledTileID`,Gf,{omit:[`terrainRttPosMatrix32f`]});class qf{constructor(){this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0}extend(e){return this.minX=Math.min(this.minX,e.x),this.minY=Math.min(this.minY,e.y),this.maxX=Math.max(this.maxX,e.x),this.maxY=Math.max(this.maxY,e.y),this}expandBy(e){return this.minX-=e,this.minY-=e,this.maxX+=e,this.maxY+=e,(this.minX>this.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(e){return this.expandBy(-e)}map(e){let t=new qf;return t.extend(e(new n(this.minX,this.minY))),t.extend(e(new n(this.maxX,this.minY))),t.extend(e(new n(this.minX,this.maxY))),t.extend(e(new n(this.maxX,this.maxY))),t}static fromPoints(e){let t=new qf;for(let n of e)t.extend(n);return t}contains(e){return e.x>=this.minX&&e.x<=this.maxX&&e.y>=this.minY&&e.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(e){return!this.empty()&&!e.empty()&&e.minX>=this.minX&&e.maxX<=this.maxX&&e.minY>=this.minY&&e.maxY<=this.maxY}intersects(e){return!this.empty()&&!e.empty()&&e.minX<=this.maxX&&e.maxX>=this.minX&&e.minY<=this.maxY&&e.maxY>=this.minY}}class Jf{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t<e.length;t++){let n=e[t];this._stringToNumber[n]=t,this._numberToString[t]=n}}encode(e){return this._stringToNumber[e]}decode(e){if(e>=this._numberToString.length)throw Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class Yf{constructor(e,t,n,r,i){this.type=`Feature`,this._vectorTileFeature=e,this._x=n,this._y=r,this._z=t,this.properties=e.properties,this.id=i}projectPoint(e,t,n,r){return[360*(e.x+t)/r-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+n)/r)*Math.PI))-90]}projectLine(e,t,n,r){return e.map((e=>this.projectPoint(e,t,n,r)))}get geometry(){if(this._geometry)return this._geometry;let e=this._vectorTileFeature,t=e.extent*2**this._z,n=e.extent*this._x,r=e.extent*this._y,i=e.loadGeometry();switch(e.type){case 1:{let e=[];for(let t of i)e.push(t[0]);let a=this.projectLine(e,n,r,t);this._geometry=e.length===1?{type:`Point`,coordinates:a[0]}:{type:`MultiPoint`,coordinates:a};break}case 2:{let e=i.map((e=>this.projectLine(e,n,r,t)));this._geometry=e.length===1?{type:`LineString`,coordinates:e[0]}:{type:`MultiLineString`,coordinates:e};break}case 3:{let e=Nl(i),a=[];for(let i of e)a.push(i.map((e=>this.projectLine(e,n,r,t))));this._geometry=a.length===1?{type:`Polygon`,coordinates:a[0]}:{type:`MultiPolygon`,coordinates:a};break}default:throw Error(`unknown feature type: ${e.type}`)}return this._geometry}set geometry(e){this._geometry=e}toJSON(){let e={geometry:this.geometry};for(let t in this)t!==`_geometry`&&t!==`_vectorTileFeature`&&t!==`_x`&&t!==`_y`&&t!==`_z`&&(e[t]=this[t]);return e}}class Xf{constructor(e,t,n){this._name=e,this.dataBuffer=t,typeof n==`number`?this._size=n:(this.nullabilityBuffer=n,this._size=n.size())}getValue(e){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(e)?null:this.getValueFromBuffer(e)}has(e){return this.nullabilityBuffer?.get(e)||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}}class Zf extends Xf{}class Qf extends Zf{getValueFromBuffer(e){return this.dataBuffer[e]}}class $f extends Zf{getValueFromBuffer(e){return this.dataBuffer[e]}}class ep extends Xf{constructor(e,t,n,r){super(e,t,r),this.delta=n}}class tp extends ep{constructor(e,t,n,r){super(e,Int32Array.of(t),n,r)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}}class np extends Xf{constructor(e,t,n,r){super(e,r?Int32Array.of(t):Uint32Array.of(t),n)}getValueFromBuffer(e){return this.dataBuffer[0]}}class rp{constructor(e,t,n,r,i=4096){this._name=e,this._geometryVector=t,this._idVector=n,this._propertyVectors=r,this._extent=i}get name(){return this._name}get idVector(){return this._idVector}get geometryVector(){return this._geometryVector}get propertyVectors(){return this._propertyVectors}getPropertyVector(e){return this.propertyVectorsMap||=new Map(this._propertyVectors.map((e=>[e.name,e]))),this.propertyVectorsMap.get(e)}get numFeatures(){return this.geometryVector.numGeometries}get extent(){return this._extent}getFeatures(){let e=[],t=this.geometryVector.getGeometries();for(let n=0;n<this.numFeatures;n++){let r;if(this.idVector){let e=this.idVector.getValue(n);r=this.containsMaxSafeIntegerValues(this.idVector)&&e!==null?Number(e):e}let i={coordinates:t[n],type:this.geometryVector.geometryType(n)},a={};for(let e of this.propertyVectors){if(!e)continue;let t=e.name,r=e.getValue(n);r!==null&&(a[t]=r)}e.push({id:r,geometry:i,properties:a})}return e}containsMaxSafeIntegerValues(e){return e instanceof Qf||e instanceof np||e instanceof tp||e instanceof $f}}class ip{constructor(e){this.value=e}get(){return this.value}set(e){this.value=e}increment(){return this.value++}add(e){this.value+=e}}var ap,op;(function(e){e.NONE=`NONE`,e.DELTA=`DELTA`,e.COMPONENTWISE_DELTA=`COMPONENTWISE_DELTA`,e.RLE=`RLE`,e.MORTON=`MORTON`,e.PDE=`PDE`})(ap||={}),function(e){e.NONE=`NONE`,e.FAST_PFOR=`FAST_PFOR`,e.VARINT=`VARINT`,e.ALP=`ALP`}(op||={});let sp=new Uint32Array(33);sp[0]=0;for(let e=1;e<=32;e++)sp[e]=e===32?4294967295:4294967295>>>32-e;let cp=sp;function lp(e,t){return e-e%t}function up(e){let t=e>>>0;return((255&t)<<24|(65280&t)<<8|t>>>8&65280|t>>>24&255)>>>0}let dp=function(){let e=lp(65536,256);return e===0?256:e}(),fp=3*dp/256+dp|0;function pp(){let e=new Uint8Array(fp);return{dataToBePacked:Array(33),dataPointers:new Int32Array(33),byteContainer:e,byteContainerI32:new Int32Array(e.buffer,e.byteOffset,e.byteLength>>>2),exceptionSizes:new Int32Array(33)}}function mp(e,t,n,r,i){switch(i){case 1:(function(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0;n[i++]=t>>>0&1,n[i++]=t>>>1&1,n[i++]=t>>>2&1,n[i++]=t>>>3&1,n[i++]=t>>>4&1,n[i++]=t>>>5&1,n[i++]=t>>>6&1,n[i++]=t>>>7&1,n[i++]=t>>>8&1,n[i++]=t>>>9&1,n[i++]=t>>>10&1,n[i++]=t>>>11&1,n[i++]=t>>>12&1,n[i++]=t>>>13&1,n[i++]=t>>>14&1,n[i++]=t>>>15&1,n[i++]=t>>>16&1,n[i++]=t>>>17&1,n[i++]=t>>>18&1,n[i++]=t>>>19&1,n[i++]=t>>>20&1,n[i++]=t>>>21&1,n[i++]=t>>>22&1,n[i++]=t>>>23&1,n[i++]=t>>>24&1,n[i++]=t>>>25&1,n[i++]=t>>>26&1,n[i++]=t>>>27&1,n[i++]=t>>>28&1,n[i++]=t>>>29&1,n[i++]=t>>>30&1,n[i++]=t>>>31&1}})(e,t,n,r);break;case 2:(function(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0,r=e[a++]>>>0;n[i++]=t>>>0&3,n[i++]=t>>>2&3,n[i++]=t>>>4&3,n[i++]=t>>>6&3,n[i++]=t>>>8&3,n[i++]=t>>>10&3,n[i++]=t>>>12&3,n[i++]=t>>>14&3,n[i++]=t>>>16&3,n[i++]=t>>>18&3,n[i++]=t>>>20&3,n[i++]=t>>>22&3,n[i++]=t>>>24&3,n[i++]=t>>>26&3,n[i++]=t>>>28&3,n[i++]=t>>>30&3,n[i++]=r>>>0&3,n[i++]=r>>>2&3,n[i++]=r>>>4&3,n[i++]=r>>>6&3,n[i++]=r>>>8&3,n[i++]=r>>>10&3,n[i++]=r>>>12&3,n[i++]=r>>>14&3,n[i++]=r>>>16&3,n[i++]=r>>>18&3,n[i++]=r>>>20&3,n[i++]=r>>>22&3,n[i++]=r>>>24&3,n[i++]=r>>>26&3,n[i++]=r>>>28&3,n[i++]=r>>>30&3}})(e,t,n,r);break;case 3:(function(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0,r=e[a++]>>>0,o=e[a++]>>>0;n[i++]=t>>>0&7,n[i++]=t>>>3&7,n[i++]=t>>>6&7,n[i++]=t>>>9&7,n[i++]=t>>>12&7,n[i++]=t>>>15&7,n[i++]=t>>>18&7,n[i++]=t>>>21&7,n[i++]=t>>>24&7,n[i++]=t>>>27&7,n[i++]=7&(t>>>30|(1&r)<<2),n[i++]=r>>>1&7,n[i++]=r>>>4&7,n[i++]=r>>>7&7,n[i++]=r>>>10&7,n[i++]=r>>>13&7,n[i++]=r>>>16&7,n[i++]=r>>>19&7,n[i++]=r>>>22&7,n[i++]=r>>>25&7,n[i++]=r>>>28&7,n[i++]=7&(r>>>31|(3&o)<<1),n[i++]=o>>>2&7,n[i++]=o>>>5&7,n[i++]=o>>>8&7,n[i++]=o>>>11&7,n[i++]=o>>>14&7,n[i++]=o>>>17&7,n[i++]=o>>>20&7,n[i++]=o>>>23&7,n[i++]=o>>>26&7,n[i++]=o>>>29&7}})(e,t,n,r);break;case 4:(function(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0,r=e[a++]>>>0,o=e[a++]>>>0,s=e[a++]>>>0;n[i++]=t>>>0&15,n[i++]=t>>>4&15,n[i++]=t>>>8&15,n[i++]=t>>>12&15,n[i++]=t>>>16&15,n[i++]=t>>>20&15,n[i++]=t>>>24&15,n[i++]=t>>>28&15,n[i++]=r>>>0&15,n[i++]=r>>>4&15,n[i++]=r>>>8&15,n[i++]=r>>>12&15,n[i++]=r>>>16&15,n[i++]=r>>>20&15,n[i++]=r>>>24&15,n[i++]=r>>>28&15,n[i++]=o>>>0&15,n[i++]=o>>>4&15,n[i++]=o>>>8&15,n[i++]=o>>>12&15,n[i++]=o>>>16&15,n[i++]=o>>>20&15,n[i++]=o>>>24&15,n[i++]=o>>>28&15,n[i++]=s>>>0&15,n[i++]=s>>>4&15,n[i++]=s>>>8&15,n[i++]=s>>>12&15,n[i++]=s>>>16&15,n[i++]=s>>>20&15,n[i++]=s>>>24&15,n[i++]=s>>>28&15}})(e,t,n,r);break;case 5:(function(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0,r=e[a++]>>>0,o=e[a++]>>>0,s=e[a++]>>>0,c=e[a++]>>>0;n[i++]=t>>>0&31,n[i++]=t>>>5&31,n[i++]=t>>>10&31,n[i++]=t>>>15&31,n[i++]=t>>>20&31,n[i++]=t>>>25&31,n[i++]=31&(t>>>30|(7&r)<<2),n[i++]=r>>>3&31,n[i++]=r>>>8&31,n[i++]=r>>>13&31,n[i++]=r>>>18&31,n[i++]=r>>>23&31,n[i++]=31&(r>>>28|(1&o)<<4),n[i++]=o>>>1&31,n[i++]=o>>>6&31,n[i++]=o>>>11&31,n[i++]=o>>>16&31,n[i++]=o>>>21&31,n[i++]=o>>>26&31,n[i++]=31&(o>>>31|(15&s)<<1),n[i++]=s>>>4&31,n[i++]=s>>>9&31,n[i++]=s>>>14&31,n[i++]=s>>>19&31,n[i++]=s>>>24&31,n[i++]=31&(s>>>29|(3&c)<<3),n[i++]=c>>>2&31,n[i++]=c>>>7&31,n[i++]=c>>>12&31,n[i++]=c>>>17&31,n[i++]=c>>>22&31,n[i++]=c>>>27&31}})(e,t,n,r);break;case 6:(function(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0,r=e[a++]>>>0,o=e[a++]>>>0,s=e[a++]>>>0,c=e[a++]>>>0,l=e[a++]>>>0;n[i++]=t>>>0&63,n[i++]=t>>>6&63,n[i++]=t>>>12&63,n[i++]=t>>>18&63,n[i++]=t>>>24&63,n[i++]=63&(t>>>30|(15&r)<<2),n[i++]=r>>>4&63,n[i++]=r>>>10&63,n[i++]=r>>>16&63,n[i++]=r>>>22&63,n[i++]=63&(r>>>28|(3&o)<<4),n[i++]=o>>>2&63,n[i++]=o>>>8&63,n[i++]=o>>>14&63,n[i++]=o>>>20&63,n[i++]=o>>>26&63,n[i++]=s>>>0&63,n[i++]=s>>>6&63,n[i++]=s>>>12&63,n[i++]=s>>>18&63,n[i++]=s>>>24&63,n[i++]=63&(s>>>30|(15&c)<<2),n[i++]=c>>>4&63,n[i++]=c>>>10&63,n[i++]=c>>>16&63,n[i++]=c>>>22&63,n[i++]=63&(c>>>28|(3&l)<<4),n[i++]=l>>>2&63,n[i++]=l>>>8&63,n[i++]=l>>>14&63,n[i++]=l>>>20&63,n[i++]=l>>>26&63}})(e,t,n,r);break;case 7:(function(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0,r=e[a++]>>>0,o=e[a++]>>>0,s=e[a++]>>>0,c=e[a++]>>>0,l=e[a++]>>>0,u=e[a++]>>>0;n[i++]=t>>>0&127,n[i++]=t>>>7&127,n[i++]=t>>>14&127,n[i++]=t>>>21&127,n[i++]=127&(t>>>28|(7&r)<<4),n[i++]=r>>>3&127,n[i++]=r>>>10&127,n[i++]=r>>>17&127,n[i++]=r>>>24&127,n[i++]=127&(r>>>31|(63&o)<<1),n[i++]=o>>>6&127,n[i++]=o>>>13&127,n[i++]=o>>>20&127,n[i++]=127&(o>>>27|(3&s)<<5),n[i++]=s>>>2&127,n[i++]=s>>>9&127,n[i++]=s>>>16&127,n[i++]=s>>>23&127,n[i++]=127&(s>>>30|(31&c)<<2),n[i++]=c>>>5&127,n[i++]=c>>>12&127,n[i++]=c>>>19&127,n[i++]=127&(c>>>26|(1&l)<<6),n[i++]=l>>>1&127,n[i++]=l>>>8&127,n[i++]=l>>>15&127,n[i++]=l>>>22&127,n[i++]=127&(l>>>29|(15&u)<<3),n[i++]=u>>>4&127,n[i++]=u>>>11&127,n[i++]=u>>>18&127,n[i++]=u>>>25&127}})(e,t,n,r);break;case 8:(function(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0,r=e[a++]>>>0,o=e[a++]>>>0,s=e[a++]>>>0,c=e[a++]>>>0,l=e[a++]>>>0,u=e[a++]>>>0,d=e[a++]>>>0;n[i++]=t>>>0&255,n[i++]=t>>>8&255,n[i++]=t>>>16&255,n[i++]=t>>>24&255,n[i++]=r>>>0&255,n[i++]=r>>>8&255,n[i++]=r>>>16&255,n[i++]=r>>>24&255,n[i++]=o>>>0&255,n[i++]=o>>>8&255,n[i++]=o>>>16&255,n[i++]=o>>>24&255,n[i++]=s>>>0&255,n[i++]=s>>>8&255,n[i++]=s>>>16&255,n[i++]=s>>>24&255,n[i++]=c>>>0&255,n[i++]=c>>>8&255,n[i++]=c>>>16&255,n[i++]=c>>>24&255,n[i++]=l>>>0&255,n[i++]=l>>>8&255,n[i++]=l>>>16&255,n[i++]=l>>>24&255,n[i++]=u>>>0&255,n[i++]=u>>>8&255,n[i++]=u>>>16&255,n[i++]=u>>>24&255,n[i++]=d>>>0&255,n[i++]=d>>>8&255,n[i++]=d>>>16&255,n[i++]=d>>>24&255}})(e,t,n,r);break;case 16:(function(e,t,n,r){let i=r,a=t;for(let t=0;t<128;t++){let t=e[a++]>>>0;n[i++]=65535&t,n[i++]=t>>>16&65535}})(e,t,n,r);break;default:(function(e,t,n,r,i){let a=cp[i]>>>0,o=t,s=0,c=e[o]>>>0,l=r;for(let t=0;t<8;t++){for(let t=0;t<32;t++)if(s+i<=32)n[l+t]=c>>>s&a,s+=i,s===32&&(s=0,o++,t!==31&&(c=e[o]>>>0));else{let r=32-s,u=c>>>s;o++,c=e[o]>>>0;let d=i-r;n[l+t]=(u|(c&-1>>>32-d>>>0)<<r)&a,s=d}l+=32,s=0,t<7&&(c=e[o]>>>0)}})(e,t,n,r,i)}return t+(i<<3)|0}function hp(e,t,n,r){if(n+2>t)throw Error(`FastPFOR decode: byteContainer underflow at block=${r} (need 2 bytes for [bitWidth, exceptionCount], bytePos=${n}, byteSize=${t})`);let i=e[n++],a=e[n++];if(i>32)throw Error(`FastPFOR decode: invalid bitWidth=${i} at block=${r} (expected 0..32). This likely indicates corrupted or truncated input.`);return{bitWidth:i,exceptionCount:a,bytePosIn:n}}function gp(e,t,n,r,i,a,o,s,c){let{maxBits:l,exceptionBitWidth:u,bytePosIn:d}=function(e,t,n,r,i,a){if(n+1>t)throw Error(`FastPFOR decode: exception header underflow at block=${a} (need 1 byte for maxBits, bytePos=${n}, byteSize=${t})`);let o=e[n++];if(o<r||o>32)throw Error(`FastPFOR decode: invalid maxBits=${o} at block=${a} (bitWidth=${r}, expected ${r}..32)`);let s=o-r|0;if(s<1||s>32)throw Error(`FastPFOR decode: invalid exceptionBitWidth=${s} at block=${a} (bitWidth=${r}, maxBits=${o})`);if(n+i>t)throw Error(`FastPFOR decode: exception positions underflow at block=${a} (need=${i}, have=${t-n})`);return{maxBits:o,exceptionBitWidth:s,bytePosIn:n}}(i,a,o,n,r,c);if(o=d,u===1){let a=1<<n;for(let n=0;n<r;n=n+1|0)e[i[o++]+t|0]|=a;return o}let f=s.dataToBePacked[u];if(!f)throw Error(`FastPFOR decode: missing exception stream for exceptionBitWidth=${u} (bitWidth=${n}, maxBits=${l}) at block ${c}`);let p=s.dataPointers,m=0|p[u],h=0|s.exceptionSizes[u];if(m+r>h)throw Error(`FastPFOR decode: exception stream overflow for exceptionBitWidth=${u} (ptr=${m}, need ${r}, size=${h}) at block ${c}`);for(let a=0;a<r;a=a+1|0){let r=i[o++],a=0|f[m++];e[r+t|0]|=a<<n}return p[u]=m,o}function _p(e,t,n,r,i,a){let o=0|n,s=0|e[o];if(s<=0||o+s>e.length-1)throw Error(`FastPFOR decode: invalid whereMeta=${s} at pageStart=${o} (expected > 0 and pageStart+whereMeta < encoded.length=${e.length})`);let c=o+1|0,l=o+s|0,u=e[l]>>>0,d=u+3>>>2,f=l+1,p=f+d;if(p>=e.length)throw Error(`FastPFOR decode: invalid byteSize=${u} (metaInts=${d}, pageStart=${o}, packedEnd=${l}, byteContainerStart=${f}) causes bitmapPos=${p} out of bounds (encoded.length=${e.length})`);let m=function(e,t,n,r){r.byteContainer.length<n&&(r.byteContainer=new Uint8Array(2*n),r.byteContainerI32=void 0);let i=r.byteContainer,a=n>>>2;if(3&i.byteOffset)for(let n=0;n<a;n=n+1|0){let r=0|e[t+n|0],a=n<<2;i[a]=255&r,i[a+1|0]=r>>>8&255,i[a+2|0]=r>>>16&255,i[a+3|0]=r>>>24&255}else{let n=r.byteContainerI32;(!n||n.buffer!==i.buffer||n.byteOffset!==i.byteOffset||n.length<a)&&(n=r.byteContainerI32=new Int32Array(i.buffer,i.byteOffset,i.byteLength>>>2)),n.set(e.subarray(t,t+a))}let o=3&n;if(o>0){let n=0|e[t+a|0],r=a<<2;for(let e=0;e<o;e=e+1|0)i[r+e|0]=n>>>(e<<3)&255}return i}(e,f,u,a),h=u,g=function(e,t,n){let r=0|e[t++],i=n.dataToBePacked;for(let a=2;a<=32;a=a+1|0){if(!(r>>>a-1&1))continue;if(t>=e.length)throw Error(`FastPFOR decode: truncated exception stream header (bitWidth=${a}, streamWordIndex=${t}, needWords=1, availableWords=${e.length-t}, encodedWords=${e.length})`);let o=e[t++]>>>0,s=lp(o+31,32),c=o*a+31>>>5;if(t+c>e.length)throw Error(`FastPFOR decode: truncated exception stream (bitWidth=${a}, size=${o}, streamWordIndex=${t}, needWords=${c}, availableWords=${e.length-t}, encodedWords=${e.length})`);let l=i[a];(!l||l.length<s)&&(l=i[a]=new Uint32Array(s));let u=0;for(;u<o;u=u+32|0)vp(e,t,l,u,a),t=t+a|0;t=t-((u-o|0)*a>>>5)|0,n.exceptionSizes[a]=o}return t}(e,p,a);return a.dataPointers.fill(0),function(e,t,n,r,i,a,o,s,c,l){let u=0|n,d=0;for(let t=0;t<o;t=t+1|0){let n=hp(s,c,d,t);d=n.bytePosIn;let r=n.bitWidth,o=n.exceptionCount,f=a+t*256|0;switch(r){case 0:i.fill(0,f,f+256);break;case 32:for(let t=0;t<256;t=t+1|0)i[f+t|0]=0|e[u+t|0];u=u+256|0;break;default:u=mp(e,u,i,f,r)}o>0&&(d=gp(i,f,r,o,s,c,d,l,t))}if(u!==r)throw Error(`FastPFOR decode: packed region mismatch (pageStart=${t}, packedStart=${n}, consumedPackedEnd=${u}, expectedPackedEnd=${r}, packedWords=${r-n}, encoded.length=${e.length})`)}(e,o,c,l,t,0|r,i/256|0,m,h,a),g}function vp(e,t,n,r,i){switch(i){case 2:(function(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0;n[i++]=a>>>0&3,n[i++]=a>>>2&3,n[i++]=a>>>4&3,n[i++]=a>>>6&3,n[i++]=a>>>8&3,n[i++]=a>>>10&3,n[i++]=a>>>12&3,n[i++]=a>>>14&3,n[i++]=a>>>16&3,n[i++]=a>>>18&3,n[i++]=a>>>20&3,n[i++]=a>>>22&3,n[i++]=a>>>24&3,n[i++]=a>>>26&3,n[i++]=a>>>28&3,n[i++]=a>>>30&3,n[i++]=o>>>0&3,n[i++]=o>>>2&3,n[i++]=o>>>4&3,n[i++]=o>>>6&3,n[i++]=o>>>8&3,n[i++]=o>>>10&3,n[i++]=o>>>12&3,n[i++]=o>>>14&3,n[i++]=o>>>16&3,n[i++]=o>>>18&3,n[i++]=o>>>20&3,n[i++]=o>>>22&3,n[i++]=o>>>24&3,n[i++]=o>>>26&3,n[i++]=o>>>28&3,n[i]=o>>>30&3})(e,t,n,r);return;case 3:(function(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0;n[i++]=a>>>0&7,n[i++]=a>>>3&7,n[i++]=a>>>6&7,n[i++]=a>>>9&7,n[i++]=a>>>12&7,n[i++]=a>>>15&7,n[i++]=a>>>18&7,n[i++]=a>>>21&7,n[i++]=a>>>24&7,n[i++]=a>>>27&7,n[i++]=7&(a>>>30|(1&o)<<2),n[i++]=o>>>1&7,n[i++]=o>>>4&7,n[i++]=o>>>7&7,n[i++]=o>>>10&7,n[i++]=o>>>13&7,n[i++]=o>>>16&7,n[i++]=o>>>19&7,n[i++]=o>>>22&7,n[i++]=o>>>25&7,n[i++]=o>>>28&7,n[i++]=7&(o>>>31|(3&s)<<1),n[i++]=s>>>2&7,n[i++]=s>>>5&7,n[i++]=s>>>8&7,n[i++]=s>>>11&7,n[i++]=s>>>14&7,n[i++]=s>>>17&7,n[i++]=s>>>20&7,n[i++]=s>>>23&7,n[i++]=s>>>26&7,n[i]=s>>>29&7})(e,t,n,r);return;case 4:(function(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0;n[i++]=a>>>0&15,n[i++]=a>>>4&15,n[i++]=a>>>8&15,n[i++]=a>>>12&15,n[i++]=a>>>16&15,n[i++]=a>>>20&15,n[i++]=a>>>24&15,n[i++]=a>>>28&15,n[i++]=o>>>0&15,n[i++]=o>>>4&15,n[i++]=o>>>8&15,n[i++]=o>>>12&15,n[i++]=o>>>16&15,n[i++]=o>>>20&15,n[i++]=o>>>24&15,n[i++]=o>>>28&15,n[i++]=s>>>0&15,n[i++]=s>>>4&15,n[i++]=s>>>8&15,n[i++]=s>>>12&15,n[i++]=s>>>16&15,n[i++]=s>>>20&15,n[i++]=s>>>24&15,n[i++]=s>>>28&15,n[i++]=c>>>0&15,n[i++]=c>>>4&15,n[i++]=c>>>8&15,n[i++]=c>>>12&15,n[i++]=c>>>16&15,n[i++]=c>>>20&15,n[i++]=c>>>24&15,n[i]=c>>>28&15})(e,t,n,r);return;case 5:(function(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0;n[i++]=a>>>0&31,n[i++]=a>>>5&31,n[i++]=a>>>10&31,n[i++]=a>>>15&31,n[i++]=a>>>20&31,n[i++]=a>>>25&31,n[i++]=31&(a>>>30|(7&o)<<2),n[i++]=o>>>3&31,n[i++]=o>>>8&31,n[i++]=o>>>13&31,n[i++]=o>>>18&31,n[i++]=o>>>23&31,n[i++]=31&(o>>>28|(1&s)<<4),n[i++]=s>>>1&31,n[i++]=s>>>6&31,n[i++]=s>>>11&31,n[i++]=s>>>16&31,n[i++]=s>>>21&31,n[i++]=s>>>26&31,n[i++]=31&(s>>>31|(15&c)<<1),n[i++]=c>>>4&31,n[i++]=c>>>9&31,n[i++]=c>>>14&31,n[i++]=c>>>19&31,n[i++]=c>>>24&31,n[i++]=31&(c>>>29|(3&l)<<3),n[i++]=l>>>2&31,n[i++]=l>>>7&31,n[i++]=l>>>12&31,n[i++]=l>>>17&31,n[i++]=l>>>22&31,n[i]=l>>>27&31})(e,t,n,r);return;case 6:(function(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0;n[i++]=a>>>0&63,n[i++]=a>>>6&63,n[i++]=a>>>12&63,n[i++]=a>>>18&63,n[i++]=a>>>24&63,n[i++]=63&(a>>>30|(15&o)<<2),n[i++]=o>>>4&63,n[i++]=o>>>10&63,n[i++]=o>>>16&63,n[i++]=o>>>22&63,n[i++]=63&(o>>>28|(3&s)<<4),n[i++]=s>>>2&63,n[i++]=s>>>8&63,n[i++]=s>>>14&63,n[i++]=s>>>20&63,n[i++]=s>>>26&63,n[i++]=c>>>0&63,n[i++]=c>>>6&63,n[i++]=c>>>12&63,n[i++]=c>>>18&63,n[i++]=c>>>24&63,n[i++]=63&(c>>>30|(15&l)<<2),n[i++]=l>>>4&63,n[i++]=l>>>10&63,n[i++]=l>>>16&63,n[i++]=l>>>22&63,n[i++]=63&(l>>>28|(3&u)<<4),n[i++]=u>>>2&63,n[i++]=u>>>8&63,n[i++]=u>>>14&63,n[i++]=u>>>20&63,n[i]=u>>>26&63})(e,t,n,r);return;case 7:(function(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0,d=e[t+6]>>>0;n[i++]=a>>>0&127,n[i++]=a>>>7&127,n[i++]=a>>>14&127,n[i++]=a>>>21&127,n[i++]=127&(a>>>28|(7&o)<<4),n[i++]=o>>>3&127,n[i++]=o>>>10&127,n[i++]=o>>>17&127,n[i++]=o>>>24&127,n[i++]=127&(o>>>31|(63&s)<<1),n[i++]=s>>>6&127,n[i++]=s>>>13&127,n[i++]=s>>>20&127,n[i++]=127&(s>>>27|(3&c)<<5),n[i++]=c>>>2&127,n[i++]=c>>>9&127,n[i++]=c>>>16&127,n[i++]=c>>>23&127,n[i++]=127&(c>>>30|(31&l)<<2),n[i++]=l>>>5&127,n[i++]=l>>>12&127,n[i++]=l>>>19&127,n[i++]=127&(l>>>26|(1&u)<<6),n[i++]=u>>>1&127,n[i++]=u>>>8&127,n[i++]=u>>>15&127,n[i++]=u>>>22&127,n[i++]=127&(u>>>29|(15&d)<<3),n[i++]=d>>>4&127,n[i++]=d>>>11&127,n[i++]=d>>>18&127,n[i]=d>>>25&127})(e,t,n,r);return;case 8:(function(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0,d=e[t+6]>>>0,f=e[t+7]>>>0;n[i++]=a>>>0&255,n[i++]=a>>>8&255,n[i++]=a>>>16&255,n[i++]=a>>>24&255,n[i++]=o>>>0&255,n[i++]=o>>>8&255,n[i++]=o>>>16&255,n[i++]=o>>>24&255,n[i++]=s>>>0&255,n[i++]=s>>>8&255,n[i++]=s>>>16&255,n[i++]=s>>>24&255,n[i++]=c>>>0&255,n[i++]=c>>>8&255,n[i++]=c>>>16&255,n[i++]=c>>>24&255,n[i++]=l>>>0&255,n[i++]=l>>>8&255,n[i++]=l>>>16&255,n[i++]=l>>>24&255,n[i++]=u>>>0&255,n[i++]=u>>>8&255,n[i++]=u>>>16&255,n[i++]=u>>>24&255,n[i++]=d>>>0&255,n[i++]=d>>>8&255,n[i++]=d>>>16&255,n[i++]=d>>>24&255,n[i++]=f>>>0&255,n[i++]=f>>>8&255,n[i++]=f>>>16&255,n[i]=f>>>24&255})(e,t,n,r);return;case 9:(function(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0,d=e[t+6]>>>0,f=e[t+7]>>>0,p=e[t+8]>>>0;n[i++]=a>>>0&511,n[i++]=a>>>9&511,n[i++]=a>>>18&511,n[i++]=511&(a>>>27|(15&o)<<5),n[i++]=o>>>4&511,n[i++]=o>>>13&511,n[i++]=o>>>22&511,n[i++]=511&(o>>>31|(255&s)<<1),n[i++]=s>>>8&511,n[i++]=s>>>17&511,n[i++]=511&(s>>>26|(7&c)<<6),n[i++]=c>>>3&511,n[i++]=c>>>12&511,n[i++]=c>>>21&511,n[i++]=511&(c>>>30|(127&l)<<2),n[i++]=l>>>7&511,n[i++]=l>>>16&511,n[i++]=511&(l>>>25|(3&u)<<7),n[i++]=u>>>2&511,n[i++]=u>>>11&511,n[i++]=u>>>20&511,n[i++]=511&(u>>>29|(63&d)<<3),n[i++]=d>>>6&511,n[i++]=d>>>15&511,n[i++]=511&(d>>>24|(1&f)<<8),n[i++]=f>>>1&511,n[i++]=f>>>10&511,n[i++]=f>>>19&511,n[i++]=511&(f>>>28|(31&p)<<4),n[i++]=p>>>5&511,n[i++]=p>>>14&511,n[i]=p>>>23&511})(e,t,n,r);return;case 10:(function(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0,d=e[t+6]>>>0,f=e[t+7]>>>0,p=e[t+8]>>>0,m=e[t+9]>>>0;n[i++]=a>>>0&1023,n[i++]=a>>>10&1023,n[i++]=a>>>20&1023,n[i++]=1023&(a>>>30|(255&o)<<2),n[i++]=o>>>8&1023,n[i++]=o>>>18&1023,n[i++]=1023&(o>>>28|(63&s)<<4),n[i++]=s>>>6&1023,n[i++]=s>>>16&1023,n[i++]=1023&(s>>>26|(15&c)<<6),n[i++]=c>>>4&1023,n[i++]=c>>>14&1023,n[i++]=1023&(c>>>24|(3&l)<<8),n[i++]=l>>>2&1023,n[i++]=l>>>12&1023,n[i++]=l>>>22&1023,n[i++]=u>>>0&1023,n[i++]=u>>>10&1023,n[i++]=u>>>20&1023,n[i++]=1023&(u>>>30|(255&d)<<2),n[i++]=d>>>8&1023,n[i++]=d>>>18&1023,n[i++]=1023&(d>>>28|(63&f)<<4),n[i++]=f>>>6&1023,n[i++]=f>>>16&1023,n[i++]=1023&(f>>>26|(15&p)<<6),n[i++]=p>>>4&1023,n[i++]=p>>>14&1023,n[i++]=1023&(p>>>24|(3&m)<<8),n[i++]=m>>>2&1023,n[i++]=m>>>12&1023,n[i]=m>>>22&1023})(e,t,n,r);return;case 11:(function(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0,d=e[t+6]>>>0,f=e[t+7]>>>0,p=e[t+8]>>>0,m=e[t+9]>>>0,h=e[t+10]>>>0;n[i++]=a>>>0&2047,n[i++]=a>>>11&2047,n[i++]=2047&(a>>>22|(1&o)<<10),n[i++]=o>>>1&2047,n[i++]=o>>>12&2047,n[i++]=2047&(o>>>23|(3&s)<<9),n[i++]=s>>>2&2047,n[i++]=s>>>13&2047,n[i++]=2047&(s>>>24|(7&c)<<8),n[i++]=c>>>3&2047,n[i++]=c>>>14&2047,n[i++]=2047&(c>>>25|(15&l)<<7),n[i++]=l>>>4&2047,n[i++]=l>>>15&2047,n[i++]=2047&(l>>>26|(31&u)<<6),n[i++]=u>>>5&2047,n[i++]=u>>>16&2047,n[i++]=2047&(u>>>27|(63&d)<<5),n[i++]=d>>>6&2047,n[i++]=d>>>17&2047,n[i++]=2047&(d>>>28|(127&f)<<4),n[i++]=f>>>7&2047,n[i++]=f>>>18&2047,n[i++]=2047&(f>>>29|(255&p)<<3),n[i++]=p>>>8&2047,n[i++]=p>>>19&2047,n[i++]=2047&(p>>>30|(511&m)<<2),n[i++]=m>>>9&2047,n[i++]=m>>>20&2047,n[i++]=2047&(m>>>31|(1023&h)<<1),n[i++]=h>>>10&2047,n[i]=h>>>21&2047})(e,t,n,r);return;case 12:(function(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0,d=e[t+6]>>>0,f=e[t+7]>>>0,p=e[t+8]>>>0,m=e[t+9]>>>0,h=e[t+10]>>>0,g=e[t+11]>>>0;n[i++]=a>>>0&4095,n[i++]=a>>>12&4095,n[i++]=4095&(a>>>24|(15&o)<<8),n[i++]=o>>>4&4095,n[i++]=o>>>16&4095,n[i++]=4095&(o>>>28|(255&s)<<4),n[i++]=s>>>8&4095,n[i++]=s>>>20&4095,n[i++]=c>>>0&4095,n[i++]=c>>>12&4095,n[i++]=4095&(c>>>24|(15&l)<<8),n[i++]=l>>>4&4095,n[i++]=l>>>16&4095,n[i++]=4095&(l>>>28|(255&u)<<4),n[i++]=u>>>8&4095,n[i++]=u>>>20&4095,n[i++]=d>>>0&4095,n[i++]=d>>>12&4095,n[i++]=4095&(d>>>24|(15&f)<<8),n[i++]=f>>>4&4095,n[i++]=f>>>16&4095,n[i++]=4095&(f>>>28|(255&p)<<4),n[i++]=p>>>8&4095,n[i++]=p>>>20&4095,n[i++]=m>>>0&4095,n[i++]=m>>>12&4095,n[i++]=4095&(m>>>24|(15&h)<<8),n[i++]=h>>>4&4095,n[i++]=h>>>16&4095,n[i++]=4095&(h>>>28|(255&g)<<4),n[i++]=g>>>8&4095,n[i]=g>>>20&4095})(e,t,n,r);return;case 16:(function(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0,d=e[t+6]>>>0,f=e[t+7]>>>0,p=e[t+8]>>>0,m=e[t+9]>>>0,h=e[t+10]>>>0,g=e[t+11]>>>0,_=e[t+12]>>>0,v=e[t+13]>>>0,y=e[t+14]>>>0,b=e[t+15]>>>0;n[i++]=a>>>0&65535,n[i++]=a>>>16&65535,n[i++]=o>>>0&65535,n[i++]=o>>>16&65535,n[i++]=s>>>0&65535,n[i++]=s>>>16&65535,n[i++]=c>>>0&65535,n[i++]=c>>>16&65535,n[i++]=l>>>0&65535,n[i++]=l>>>16&65535,n[i++]=u>>>0&65535,n[i++]=u>>>16&65535,n[i++]=d>>>0&65535,n[i++]=d>>>16&65535,n[i++]=f>>>0&65535,n[i++]=f>>>16&65535,n[i++]=p>>>0&65535,n[i++]=p>>>16&65535,n[i++]=m>>>0&65535,n[i++]=m>>>16&65535,n[i++]=h>>>0&65535,n[i++]=h>>>16&65535,n[i++]=g>>>0&65535,n[i++]=g>>>16&65535,n[i++]=_>>>0&65535,n[i++]=_>>>16&65535,n[i++]=v>>>0&65535,n[i++]=v>>>16&65535,n[i++]=y>>>0&65535,n[i++]=y>>>16&65535,n[i++]=b>>>0&65535,n[i]=b>>>16&65535})(e,t,n,r);return;case 32:for(let i=0;i<32;i=i+1|0)n[r+i|0]=0|e[t+i|0];return}let a=cp[i]>>>0,o=t,s=0,c=e[o]>>>0;for(let t=0;t<32;t++)if(s+i<=32)n[r+t]=c>>>s&a,s+=i,s===32&&(s=0,o++,t!==31&&(c=e[o]>>>0));else{let l=32-s,u=c>>>s;o++,c=e[o]>>>0,n[r+t]=(u|(c&cp[i-l]>>>0)<<l)&a,s=i-l}}function yp(e,t,n){let r=new Uint32Array(n),i=0,a=t.get();for(let t=0;t<r.length;t++){let t=e[a++],n=127&t;t<128||(t=e[a++],n|=(127&t)<<7,t<128||(t=e[a++],n|=(127&t)<<14,t<128||(t=e[a++],n|=(127&t)<<21,t<128||(t=e[a++],n|=(15&t)<<28)))),r[i++]=n}return t.set(a),r}function bp(e,t,n){let r=new BigUint64Array(n);for(let n=0;n<r.length;n++)r[n]=xp(e,t);return r}function xp(e,t){let n=0n,r=0,i=t.get();for(;i<e.length;){let t=e[i++];if(n|=BigInt(127&t)<<BigInt(r),!(128&t))break;if(r+=7,r>=64)throw Error(`Varint too long`)}return t.set(i),n}function Sp(e,t){let n,r;return r=e[t.get()],t.increment(),n=127&r,r<128?n:(r=e[t.get()],t.increment(),n|=(127&r)<<7,r<128?n:(r=e[t.get()],t.increment(),n|=(127&r)<<14,r<128?n:(r=e[t.get()],t.increment(),n|=(127&r)<<21,r<128?n:(r=e[t.get()],n|=(15&r)<<28,function(e,t,n){let r,i;if(i=t[n.get()],n.increment(),r=(112&i)>>4,i<128||(i=t[n.get()],n.increment(),r|=(127&i)<<3,i<128)||(i=t[n.get()],n.increment(),r|=(127&i)<<10,i<128)||(i=t[n.get()],n.increment(),r|=(127&i)<<17,i<128)||(i=t[n.get()],n.increment(),r|=(127&i)<<24,i<128)||(i=t[n.get()],n.increment(),r|=(1&i)<<31,i<128))return 4294967296*r+(e>>>0);throw Error(`Expected varint not more than 10 bytes`)}(n,e,t)))))}function Cp(e){return e>>>1^-(1&e)}function wp(e){return e>>1n^-(1n&e)}function Tp(e){return e%2==1?(e+1)/-2:e/2}function Ep(e,t,n){if(n===void 0){n=0;for(let r=0;r<t;r++)n+=e[r]}let r=new Uint32Array(n),i=0;for(let n=0;n<t;n++){let a=e[n];r.fill(e[n+t],i,i+a),i+=a}return r}function Dp(e,t,n){if(n===void 0){n=0;for(let r=0;r<t;r++)n+=Number(e[r])}let r=new BigUint64Array(n),i=0;for(let n=0;n<t;n++){let a=Number(e[n]);r.fill(e[n+t],i,i+a),i+=a}return r}function Op(e,t,n){let r=new Float64Array(n),i=0;for(let n=0;n<t;n++){let a=e[n];r.fill(e[n+t],i,i+a),i+=a}return r}function kp(e){let t=new Int32Array(e.length);t[0]=Cp(e[0]);let n=e.length/4*4,r=1;if(n>=4)for(;r<n-4;r+=4){let n=e[r+1],i=e[r+2],a=e[r+3];t[r]=Cp(e[r])+t[r-1],t[r+1]=Cp(n)+t[r],t[r+2]=Cp(i)+t[r+1],t[r+3]=Cp(a)+t[r+2]}for(;r!==e.length;++r)t[r]=Cp(e[r])+t[r-1];return t}function Ap(e){let t=new BigInt64Array(e.length);t[0]=wp(e[0]);let n=e.length/4*4,r=1;if(n>=4)for(;r<n-4;r+=4){let n=e[r+1],i=e[r+2],a=e[r+3];t[r]=wp(e[r])+t[r-1],t[r+1]=wp(n)+t[r],t[r+2]=wp(i)+t[r+1],t[r+3]=wp(a)+t[r+2]}for(;r!==t.length;++r)t[r]=wp(e[r])+t[r-1];return t}function jp(e){let t=e.length/4*4,n=1;if(t>=4)for(let r=e[0];n<t-4;n+=4)r=e[n]+=r,r=e[n+1]+=r,r=e[n+2]+=r,r=e[n+3]+=r;for(;n!==e.length;)e[n]+=e[n-1],++n}var Mp,Np,Pp,Fp,Ip,Lp,Rp,zp;function Bp(e,t){let n=function(e,t){let n=e[t.get()],r=Object.values(Mp)[n>>4],i=null;switch(r){case Mp.DATA:i={dictionaryType:Object.values(Np)[15&n]};break;case Mp.OFFSET:i={offsetType:Object.values(Pp)[15&n]};break;case Mp.LENGTH:i={lengthType:Object.values(Fp)[15&n]}}t.increment();let a=e[t.get()],o=Object.values(ap)[a>>5],s=Object.values(ap)[a>>2&7],c=Object.values(op)[3&a];t.increment();let l=yp(e,t,2),u=l[0];return{physicalStreamType:r,logicalStreamType:i,logicalLevelTechnique1:o,logicalLevelTechnique2:s,physicalLevelTechnique:c,numValues:u,byteLength:l[1],decompressedCount:u}}(e,t);return n.logicalLevelTechnique1===ap.MORTON?function(e,t,n){let r=yp(t,n,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:e.decompressedCount,numBits:r[0],coordinateShift:r[1]}}(n,e,t):ap.RLE!==n.logicalLevelTechnique1&&ap.RLE!==n.logicalLevelTechnique2||op.NONE===n.physicalLevelTechnique?n:function(e,t,n){let r=yp(t,n,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:r[1],runs:r[0],numRleValues:r[1]}}(n,e,t)}(function(e){e.PRESENT=`PRESENT`,e.DATA=`DATA`,e.OFFSET=`OFFSET`,e.LENGTH=`LENGTH`})(Mp||={}),function(e){e.NONE=`NONE`,e.SINGLE=`SINGLE`,e.SHARED=`SHARED`,e.VERTEX=`VERTEX`,e.MORTON=`MORTON`,e.FSST=`FSST`}(Np||={}),function(e){e.VERTEX=`VERTEX`,e.INDEX=`INDEX`,e.STRING=`STRING`,e.KEY=`KEY`}(Pp||={}),function(e){e.VAR_BINARY=`VAR_BINARY`,e.GEOMETRIES=`GEOMETRIES`,e.PARTS=`PARTS`,e.RINGS=`RINGS`,e.TRIANGLES=`TRIANGLES`,e.SYMBOL=`SYMBOL`,e.DICTIONARY=`DICTIONARY`}(Fp||={}),function(e){e[e.FLAT=0]=`FLAT`,e[e.CONST=1]=`CONST`,e[e.SEQUENCE=2]=`SEQUENCE`,e[e.DICTIONARY=3]=`DICTIONARY`,e[e.FSST_DICTIONARY=4]=`FSST_DICTIONARY`}(Ip||={});class Vp{constructor(e,t){this.values=e,this._size=t}get(e){let t=Math.floor(e/8);return(this.values[t]>>e%8&1)==1}set(e,t){let n=Math.floor(e/8);this.values[n]=this.values[n]|!!t<<e%8}getInt(e){let t=Math.floor(e/8);return this.values[t]>>e%8&1}size(){return this._size}getBuffer(){return this.values}}function Hp(e,t,n){if(!t)return e;let r=t.size(),i=new e.constructor(r),a=0;for(let o=0;o<r;o++)i[o]=t.get(o)?e[a++]:n;return i}function Up(e,t,n,r,i){return function(e,t,n,r){let i;switch(t.logicalLevelTechnique1){case ap.DELTA:if(t.logicalLevelTechnique2===ap.RLE){let n=t;if(!r)return function(e,t,n){let r=new Int32Array(n),i=0,a=0;for(let n=0;n<t;n++){let o=e[n],s=Cp(e[n+t]);for(let e=0;e<o;e++)a+=s,r[i++]=a}return r}(e,n.runs,n.numRleValues);i=kp(e=Ep(e,n.runs,n.numRleValues))}else i=kp(e);break;case ap.RLE:i=function(e,t,n){if(n===void 0){n=0;for(let r=0;r<t;r++)n+=e[r]}let r=new Int32Array(n),i=0;for(let n=0;n<t;n++){let a=e[n],o=e[n+t];o=Cp(o),r.fill(o,i,i+a),i+=a}return r}(e,t.runs,t.numRleValues);break;case ap.MORTON:jp(e),i=new Int32Array(e);break;case ap.COMPONENTWISE_DELTA:i=function(e){if(e.length<2)return new Int32Array(e);let t=new Int32Array(e.length);t[0]=Cp(e[0]),t[1]=Cp(e[1]);let n=e.length/4*4,r=2;if(n>=4)for(;r<n-4;r+=4){let n=e[r+1],i=e[r+2],a=e[r+3];t[r]=Cp(e[r])+t[r-2],t[r+1]=Cp(n)+t[r-1],t[r+2]=Cp(i)+t[r],t[r+3]=Cp(a)+t[r+1]}for(;r!==e.length;r+=2)t[r]=Cp(e[r])+t[r-2],t[r+1]=Cp(e[r+1])+t[r-1];return t}(e);break;case ap.NONE:i=function(e){let t=new Int32Array(e.length);for(let n=0;n<e.length;n++)t[n]=Cp(e[n]);return t}(e);break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return r?Hp(i,r,0):i}(Kp(e,t,n),n,0,i)}function Wp(e,t,n,r,i){return function(e,t,n,r){let i;switch(t.logicalLevelTechnique1){case ap.DELTA:i=function(e){let t=new Uint32Array(e.length);t[0]=Cp(e[0])>>>0;for(let n=1;n<e.length;n++)t[n]=t[n-1]+Cp(e[n])>>>0;return t}(t.logicalLevelTechnique2===ap.RLE?Ep(e,t.runs,t.numRleValues):e);break;case ap.RLE:i=Ep(e,t.runs,t.numRleValues);break;case ap.MORTON:jp(e),i=e;break;case ap.COMPONENTWISE_DELTA:i=function(e){if(e.length<2)return new Uint32Array(e);let t=new Uint32Array(e.length);t[0]=Cp(e[0])>>>0,t[1]=Cp(e[1])>>>0;for(let n=2;n<e.length;n+=2)t[n]=t[n-2]+Cp(e[n])>>>0,t[n+1]=t[n-1]+Cp(e[n+1])>>>0;return t}(e);break;case ap.NONE:i=e;break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return r?Hp(i,r,0):i}(Kp(e,t,n),n,0,i)}function Gp(e,t,n){return function(e,t){if(t.logicalLevelTechnique1===ap.DELTA&&t.logicalLevelTechnique2===ap.NONE)return function(e){let t=new Int32Array(e.length+1);t[0]=0,t[1]=Cp(e[0]);let n=t[1];for(let r=2;r!==t.length;++r)n+=Cp(e[r-1]),t[r]=t[r-1]+n;return new Uint32Array(t)}(e);if(t.logicalLevelTechnique1===ap.RLE&&t.logicalLevelTechnique2===ap.NONE)return function(e,t,n){let r=new Uint32Array(n+1);r[0]=0;let i=1,a=r[0];for(let n=0;n<t;n++){let o=e[n],s=e[n+t];for(let e=i;e<i+o;e++)r[e]=s+a,a=r[e];i+=o}return r}(e,t.runs,t.numRleValues);if(t.logicalLevelTechnique1===ap.NONE&&t.logicalLevelTechnique2===ap.NONE){(function(e){let t=0;for(let n=0;n<e.length;n++)e[n]+=t,t=e[n]})(e);let n=new Uint32Array(t.numValues+1);return n[0]=0,n.set(e,1),n}if(t.logicalLevelTechnique1===ap.DELTA&&t.logicalLevelTechnique2===ap.RLE){let n=function(e,t,n){let r=new Int32Array(n+1);r[0]=0;let i=1,a=r[0];for(let n=0;n<t;n++){let o=e[n],s=e[n+t];s=Cp(s);for(let e=i;e<i+o;e++)r[e]=s+a,a=r[e];i+=o}return r}(e,t.runs,t.numRleValues);return jp(n),new Uint32Array(n)}throw Error(`Only delta encoding is supported for transforming length to offset streams yet.`)}(Kp(e,t,n),n)}function Kp(e,t,n){let r=n.physicalLevelTechnique;switch(r){case op.FAST_PFOR:return function(e,t,n,r){return function(e,t,n,r,i){let a=r.get();if(3&n)throw Error(`FastPFOR: invalid encodedByteLength=${n} at offset=${a} (encodedBytes.length=${e.length}; expected a multiple of 4 bytes for an int32 big-endian word stream)`);let o=n>>>2,s=function(e,t){if(t<=e.encodedWords.length)return e.encodedWords;let n=new Uint32Array(Math.max(16,2*t));return e.encodedWords=n,n}(i,o);(function(e,t,n,r){if(t<0||n<0||t+n>e.length)throw RangeError(`decodeBigEndianInt32sInto: out of bounds (offset=${t}, byteLength=${n}, bytes.length=${e.length})`);let i=Math.floor(n/4),a=n%4!=0,o=a?i+1:i;if(r.length<o)throw RangeError(`decodeBigEndianInt32sInto: out.length=${r.length} < ${o}`);if(i>0){let n=e.byteOffset+t;if(3&n)for(let n=0;n<i;n++){let i=t+4*n;r[n]=e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3]}else{let t=new Uint32Array(e.buffer,n,i);for(let e=0;e<i;e++)r[e]=0|up(t[e])}}if(a){let a=t+4*i,o=n-4*i,s=0;for(let t=0;t<o;t++)s|=e[a+t]<<24-8*t;r[i]=0|s}})(e,a,n,s);let c=function(e,t,n){let r=0,i=0,a=new Uint32Array(t),o=n??pp();if(e.length>0){let t=0|e[r];if(r=r+1|0,255&t)throw Error(`FastPFOR decode: invalid alignedLength=${t} (expected multiple of 256)`);if(i+t>a.length)throw Error(`FastPFOR decode: output buffer too small (outPos=${i}, alignedLength=${t}, out.length=${a.length})`);r=function(e,t,n,r,i,a){let o=r+lp(i,256),s=r,c=n;for(;s!==o;){let n=Math.min(dp,o-s);c=_p(e,t,c,s,n,a),s=s+n|0}return c}(e,a,r,i,t,o),i=i+t|0}return function(e,t,n,r,i,a){if(a===0)return t;let o=0,s=t,c=t+n,l=i,u=i,d=i+a,f=0,p=0;for(;s<c&&u<d;){let t=e[s]>>>o&255;if(o+=8,s+=o>>>5,o&=31,f|=(127&t)<<p,128&t)r[u++]=0|f,f=0,p=0;else if(p+=7,p>28)throw Error(`FastPFOR VByte: unterminated value (expected MSB=1 terminator within 5 bytes; shift=${p}, partial=${f}, decoded=${u-l}/${a}, inPos=${s}, inEnd=${c})`)}if(u!==d)throw Error(`FastPFOR VByte: truncated stream (decoded=${u-l}, expected=${a}, consumedWords=${s-t}/${n}, vbyteStart=${t}, vbyteEnd=${c})`)}(e,r,e.length-r|0,a,i,t-i|0),a}(s.subarray(0,o),t,i.decoderWorkspace);return r.add(n),c}(e,t,n,r,function(e=16){if(e<0)throw RangeError(`initialEncodedWordCapacity must be >= 0, got ${e}`);let t=Math.max(16,0|e);return{encodedWords:new Uint32Array(t),decoderWorkspace:pp()}}(n>>>2))}(e,n.numValues,n.byteLength,t);case op.VARINT:return yp(e,t,n.numValues);case op.NONE:{let r=t.get();t.add(n.byteLength);let i=e.subarray(r,t.get());return new Uint32Array(i)}default:throw Error(`Specified physicalLevelTechnique ${r} is not supported (yet).`)}}function qp(e,t,n){let r=Kp(e,t,n);return r.length===1?r[0]:function(e){return e[1]}(r)}function Jp(e,t,n){return function(e){if(e.length===2){let t=Cp(e[1]);return[t,t]}return[Cp(e[2]),Cp(e[3])]}(Kp(e,t,n))}function Yp(e,t,n){return function(e){if(e.length===2){let t=wp(e[1]);return[t,t]}return[wp(e[2]),wp(e[3])]}(bp(e,t,n.numValues))}function Xp(e,t,n,r){return function(e,t,n){let r;switch(t.logicalLevelTechnique1){case ap.DELTA:r=function(e){let t=new BigUint64Array(e.length);t[0]=BigInt.asUintN(64,wp(e[0]));for(let n=1;n<e.length;n++)t[n]=BigInt.asUintN(64,t[n-1]+wp(e[n]));return t}(t.logicalLevelTechnique2===ap.RLE?Dp(e,t.runs,t.numRleValues):e);break;case ap.RLE:r=Dp(e,t.runs,t.numRleValues);break;case ap.NONE:r=e;break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return n?Hp(r,n,0n):r}(bp(e,t,n.numValues),n,r)}function Zp(e,t,n){let r=bp(e,t,n.numValues);return r.length===1?r[0]:function(e){return e[1]}(r)}function Qp(e,t,n,r,i=`int32`){let a=e.logicalLevelTechnique1;if(a===ap.RLE)return e.runs===1?Ip.CONST:Ip.FLAT;if(a!==ap.DELTA||e.logicalLevelTechnique2!==ap.RLE)return e.numValues===1?Ip.CONST:Ip.FLAT;let o=t instanceof Vp?t.size():t;if(e.numRleValues!==o)return Ip.FLAT;if(e.runs===1)return Ip.SEQUENCE;if(e.runs!==2)return e.numValues===1?Ip.CONST:Ip.FLAT;let s=r.get();if(e.physicalLevelTechnique===op.VARINT)return function(e,t,n){let r=new ip(t.get());if(n===`int64`){let t=bp(e,r,4);return t[2]===2n&&t[3]===2n}let i=yp(e,r,4);return i[2]===2&&i[3]===2}(n,r,i)?Ip.SEQUENCE:e.numValues===1?Ip.CONST:Ip.FLAT;let c=r.get(),l=new Int32Array(n.buffer,n.byteOffset+c,4);return r.set(s),l[2]===2&&l[3]===2?Ip.SEQUENCE:e.numValues===1?Ip.CONST:Ip.FLAT}class $p extends Zf{getValueFromBuffer(e){return this.dataBuffer[e]}}class em extends ep{constructor(e,t,n,r){super(e,BigInt64Array.of(t),n,r)}getValueFromBuffer(e){return this.dataBuffer[0]+BigInt(e)*this.delta}}function tm(e,t,n){return{x:nm(e,t)-n,y:nm(e>>1,t)-n}}function nm(e,t){let n=0;for(let r=0;r<t;r++)n|=(e&1<<2*r)>>r;return n}function rm(e,t,r,i,a,o,s){return e===zp.MORTON?function(e,t,r,i,a,o){let s=Array(a?i+1:i);for(let a=0;a<i;a++){let i=tm(e[t[r+a]],o.numBits,o.coordinateShift);s[a]=new n(i.x,i.y)}return a&&(s[s.length-1]=s[0]),s}(t,r,i,a,o,s):function(e,t,r,i,a){let o=Array(a?i+1:i);for(let a=0;a<2*i;a+=2){let i=2*t[r+a/2];o[a/2]=new n(e[i],e[i+1])}return a&&(o[o.length-1]=o[0]),o}(t,r,i,a,o)}function im(e,t,r,i){let a=Array(i?r+1:r);for(let i=0;i<2*r;i+=2)a[i/2]=new n(e[t+i],e[t+i+1]);return i&&(a[a.length-1]=a[0]),a}(function(e){e[e.POINT=0]=`POINT`,e[e.LINESTRING=1]=`LINESTRING`,e[e.POLYGON=2]=`POLYGON`,e[e.MULTIPOINT=3]=`MULTIPOINT`,e[e.MULTILINESTRING=4]=`MULTILINESTRING`,e[e.MULTIPOLYGON=5]=`MULTIPOLYGON`})(Lp||={}),function(e){e[e.POINT=0]=`POINT`,e[e.LINESTRING=1]=`LINESTRING`,e[e.POLYGON=2]=`POLYGON`}(Rp||={}),function(e){e[e.MORTON=0]=`MORTON`,e[e.VEC_2=1]=`VEC_2`,e[e.VEC_3=2]=`VEC_3`}(zp||={});class am{constructor(e,t,n,r,i){this._vertexBufferType=e,this._topologyVector=t,this._vertexOffsets=n,this._vertexBuffer=r,this._mortonSettings=i}get vertexBufferType(){return this._vertexBufferType}get topologyVector(){return this._topologyVector}get vertexOffsets(){return this._vertexOffsets}get vertexBuffer(){return this._vertexBuffer}getSimpleEncodedVertex(e){let t=this.vertexOffsets?2*this.vertexOffsets[e]:2*e;return[this.vertexBuffer[t],this.vertexBuffer[t+1]]}getVertex(e){if(this.vertexOffsets&&this.mortonSettings){let t=tm(this.vertexBuffer[this.vertexOffsets[e]],this.mortonSettings.numBits,this.mortonSettings.coordinateShift);return[t.x,t.y]}let t=this.vertexOffsets?2*this.vertexOffsets[e]:2*e;return[this.vertexBuffer[t],this.vertexBuffer[t+1]]}getGeometries(){return function(e){let t=Array(e.numGeometries),r=1,i=1,a=1,o=0,s=0,c=0,l=e.mortonSettings,u=e.topologyVector,d=u.geometryOffsets,f=u.partOffsets,p=u.ringOffsets,m=e.vertexOffsets,h=!m||m.length===0,g=e.containsPolygonGeometry(),_=e.vertexBuffer;for(let u=0;u<e.numGeometries;u++)switch(e.geometryType(u)){case Lp.POINT:{let u,g;if(h)u=_[s++],g=_[s++];else if(e.vertexBufferType===zp.MORTON){let e=tm(_[m[c++]],l.numBits,l.coordinateShift);u=e.x,g=e.y}else{let e=2*m[c++];u=_[e],g=_[e+1]}t[o++]=[[new n(u,g)]],d&&a++,f&&r++,p&&i++}break;case Lp.MULTIPOINT:{let e=d[a]-d[a-1];a++;let l=Array(e);if(h)for(let t=0;t<e;t++){let e=_[s++],r=_[s++];l[t]=new n(e,r)}else for(let t=0;t<e;t++){let e=2*m[c++];l[t]=new n(_[e],_[e+1])}t[o++]=l.map((e=>[e])),r+=e,i+=e}break;case Lp.LINESTRING:{let n,u;g?(n=p[i]-p[i-1],i++):n=f[r]-f[r-1],r++,h?(u=im(_,s,n,!1),s+=2*n):(u=rm(e.vertexBufferType,_,m,c,n,!1,l),c+=n),t[o++]=[u],d&&a++}break;case Lp.POLYGON:{let n=f[r]-f[r-1];r++;let u=Array(n-1),g,v=p[i]-p[i-1];if(i++,h){g=im(_,s,v,!0),s+=2*v;for(let e=0;e<u.length;e++)v=p[i]-p[i-1],i++,u[e]=im(_,s,v,!0),s+=2*v}else{g=rm(e.vertexBufferType,_,m,c,v,!0,l),c+=v;for(let t=0;t<u.length;t++)v=p[i]-p[i-1],i++,u[t]=rm(e.vertexBufferType,_,m,c,v,!0,l),c+=v}t[o++]=[g].concat(u),d&&a++}break;case Lp.MULTILINESTRING:{let n=d[a]-d[a-1];a++;let u=Array(n);for(let t=0;t<n;t++){let n;g?(n=p[i]-p[i-1],i++):n=f[r]-f[r-1],r++,h?(u[t]=im(_,s,n,!1),s+=2*n):(u[t]=rm(e.vertexBufferType,_,m,c,n,!1,l),c+=n)}t[o++]=u}break;case Lp.MULTIPOLYGON:{let n=d[a]-d[a-1];a++;let u=Array(n);for(let t=0;t<n;t++){let n=f[r]-f[r-1],a;r++;let o=Array(n-1),d=p[i]-p[i-1];i++,h?(a=im(_,s,d,!0),s+=2*d):(a=rm(e.vertexBufferType,_,m,c,d,!0,l),c+=d);for(let t=0;t<o.length;t++){let n=p[i]-p[i-1];i++,h?(o[t]=im(_,s,n,!0),s+=2*n):(o[t]=rm(e.vertexBufferType,_,m,c,n,!0,l),c+=n)}u[t]=[a].concat(o)}t[o++]=u.flat()}break;default:throw Error(`The specified geometry type is currently not supported.`)}return t}(this)}get mortonSettings(){return this._mortonSettings}}class om extends am{constructor(e,t,n,r,i,a,o){super(n,r,i,a,o),this._numGeometries=e,this._geometryType=t}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsPolygonGeometry(){return this._geometryType===Lp.POLYGON||this._geometryType===Lp.MULTIPOLYGON}containsSingleGeometryType(){return!0}}class sm extends am{constructor(e,t,n,r,i,a){super(e,n,r,i,a),this._geometryTypes=t}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsPolygonGeometry(){for(let e=0;e<this.numGeometries;e++)if(this.geometryType(e)===Lp.POLYGON||this.geometryType(e)===Lp.MULTIPOLYGON)return!0;return!1}containsSingleGeometryType(){return!1}}class cm{constructor(e,t,n,r){this._triangleOffsets=e,this._indexBuffer=t,this._vertexBuffer=n,this._topologyVector=r}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 e=Array(this.numGeometries),t=this._topologyVector,r=t.partOffsets,i=t.ringOffsets,a=t.geometryOffsets,o=0,s=1,c=1,l=1;for(let t=0;t<this.numGeometries;t++)switch(this.geometryType(t)){case Lp.POLYGON:{let u=r[s]-r[s-1];s++;let d=[];for(let e=0;e<u;e++){let e=i[c]-i[c-1];c++;let t=[];for(let r=0;r<e;r++){let e=this._vertexBuffer[o++],r=this._vertexBuffer[o++];t.push(new n(e,r))}t.length>0&&t.push(t[0]),d.push(t)}e[t]=d,a&&l++}break;case Lp.MULTIPOLYGON:{let u=a[l]-a[l-1];l++;let d=[];for(let e=0;e<u;e++){let e=r[s]-r[s-1];s++;for(let t=0;t<e;t++){let e=i[c]-i[c-1];c++;let t=[];for(let r=0;r<e;r++){let e=this._vertexBuffer[o++],r=this._vertexBuffer[o++];t.push(new n(e,r))}t.length>0&&t.push(t[0]),d.push(t)}}e[t]=d}}return e}[Symbol.iterator](){return null}}function lm(e,t,n,r,i,a){return new um(e,t,n,r,i,a)}class um extends cm{constructor(e,t,n,r,i,a){super(n,r,i,a),this._numGeometries=e,this._geometryType=t}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}}function dm(e,t,n,r,i){return new fm(e,t,n,r,i)}class fm extends cm{constructor(e,t,n,r,i){super(t,n,r,i),this._geometryTypes=e}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}}function pm(e,t,n,r,i){let a=Bp(e,n),o,s,c,l;if(Qp(a,r,e,n)===Ip.CONST){let i=qp(e,n,a),u,d,f,p;for(let r=0;r<t-1;r++){let t=Bp(e,n);switch(t.physicalStreamType){case Mp.LENGTH:switch(t.logicalStreamType.lengthType){case Fp.GEOMETRIES:u=Gp(e,n,t);break;case Fp.PARTS:d=Gp(e,n,t);break;case Fp.RINGS:f=Gp(e,n,t);break;case Fp.TRIANGLES:p=Gp(e,n,t)}break;case Mp.OFFSET:switch(t.logicalStreamType.offsetType){case Pp.VERTEX:o=Wp(e,n,t);break;case Pp.INDEX:l=Wp(e,n,t)}break;case Mp.DATA:Np.VERTEX===t.logicalStreamType.dictionaryType?s=Up(e,n,t):(c={numBits:t.numBits,coordinateShift:t.coordinateShift},s=Wp(e,n,t))}}return l?u!==void 0||d!==void 0?lm(r,i,p,l,s,{geometryOffsets:u,partOffsets:d,ringOffsets:f}):lm(r,i,p,l,s):c===void 0?function(e,t,n,r,i){return new om(e,t,zp.VEC_2,n,r,i)}(r,i,{geometryOffsets:u,partOffsets:d,ringOffsets:f},o,s):function(e,t,n,r,i,a){return new om(e,t,zp.MORTON,n,r,i,a)}(r,i,{geometryOffsets:u,partOffsets:d,ringOffsets:f},o,s,c)}let u=Wp(e,n,a),d,f,p,m,h,g,_;for(let r=0;r<t-1;r++){let t=Bp(e,n);switch(t.physicalStreamType){case Mp.LENGTH:switch(t.logicalStreamType.lengthType){case Fp.GEOMETRIES:d=Wp(e,n,t);break;case Fp.PARTS:f=Wp(e,n,t);break;case Fp.RINGS:p=Wp(e,n,t);break;case Fp.TRIANGLES:m=Gp(e,n,t)}break;case Mp.OFFSET:switch(t.logicalStreamType.offsetType){case Pp.VERTEX:o=Wp(e,n,t);break;case Pp.INDEX:l=Wp(e,n,t)}break;case Mp.DATA:Np.VERTEX===t.logicalStreamType.dictionaryType?s=Up(e,n,t):(c={numBits:t.numBits,coordinateShift:t.coordinateShift},s=Wp(e,n,t))}}return d?(h=mm(u,d,2),f&&p?(g=hm(u,h,f,!1),_=function(e,t,n,r){let i=new Uint32Array(n[n.length-1]+1),a=0;i[0]=a;let o=1,s=1,c=0;for(let l=0;l<e.length;l++){let u=e[l],d=t[l+1]-t[l];if(u!==0&&u!==3)for(let e=0;e<d;e++){let e=n[o]-n[o-1];o++;for(let t=0;t<e;t++)a=i[s++]=a+r[c++]}else for(let e=0;e<d;e++)i[s++]=++a,o++}return i}(u,h,g,p)):f&&(g=function(e,t,n){let r=new Uint32Array(t[t.length-1]+1),i=0;r[0]=i;let a=1,o=0;for(let s=0;s<e.length;s++){let c=e[s],l=t[s+1]-t[s];if(c===4||c===1)for(let e=0;e<l;e++)i=r[a++]=i+n[o++];else for(let e=0;e<l;e++)r[a++]=++i}return r}(u,h,f))):f&&p?(g=mm(u,f,1),_=hm(u,g,p,!0)):f&&(g=mm(u,f,0)),l&&!g?dm(u,m,l,s):l?dm(u,m,l,s,{geometryOffsets:h,partOffsets:g,ringOffsets:_}):c===void 0?function(e,t,n,r){return new sm(zp.VEC_2,e,t,n,r)}(u,{geometryOffsets:h,partOffsets:g,ringOffsets:_},o,s):function(e,t,n,r,i){return new sm(zp.MORTON,e,t,n,r,i)}(u,{geometryOffsets:h,partOffsets:g,ringOffsets:_},o,s,c)}function mm(e,t,n){let r=new Uint32Array(e.length+1),i=0;r[0]=i;let a=0;for(let o=0;o<e.length;o++)i=r[o+1]=i+(e[o]>n?t[a++]:1);return r}function hm(e,t,n,r){let i=new Uint32Array(t[t.length-1]+1),a=0;i[0]=a;let o=1,s=0;for(let c=0;c<e.length;c++){let l=e[c],u=t[c+1]-t[c];if(l===5||l===2||r&&(l===4||l===1))for(let e=0;e<u;e++)a=i[o++]=a+n[s++];else for(let e=0;e<u;e++)i[o++]=++a}return i}class gm extends Xf{constructor(e,t,n){super(e,t.getBuffer(),n),this.dataVector=t}getValueFromBuffer(e){return this.dataVector.get(e)}}class _m extends Zf{getValueFromBuffer(e){return this.dataBuffer[e]}}class vm extends Xf{constructor(e,t,n,r){super(e,r?BigInt64Array.of(t):BigUint64Array.of(t),n)}getValueFromBuffer(e){return this.dataBuffer[0]}}function ym(e,t,n,r,i){let a=function(e,t,n,r){let i=new Uint8Array(t),a=0,o=r.get()+n;for(;a<t&&!(r.get()>=o);){let n=e[r.increment()];if(n<=127){let o=n+3,s=e[r.increment()],c=Math.min(a+o,t);i.fill(s,a,c),a=c}else{let o=256-n;for(let n=0;n<o&&a<t;n++)i[a++]=e[r.increment()]}}return r.set(o),i}(e,Math.ceil(t/8),n,r);return i?function(e,t,n){if(!n)return e;let r=n.size(),i=new Vp(e,t),a=new Vp(new Uint8Array(Math.ceil(r/8)),r),o=0;for(let e=0;e<r;e++){let t=!!n.get(e)&&i.get(o++);a.set(e,t)}return a.getBuffer()}(a,t,i):a}let bm=new TextDecoder;function xm(e,t,n){return n-t>=12?bm.decode(e.subarray(t,n)):function(e,t,n){let r=``,i=t;for(;i<n;){let t=e[i],a,o,s,c=null,l=t>239?4:t>223?3:t>191?2:1;if(i+l>n)break;l===1?t<128&&(c=t):l===2?(a=e[i+1],(192&a)==128&&(c=(31&t)<<6|63&a,c<=127&&(c=null))):l===3?(a=e[i+1],o=e[i+2],(192&a)==128&&(192&o)==128&&(c=(15&t)<<12|(63&a)<<6|63&o,(c<=2047||c>=55296&&c<=57343)&&(c=null))):l===4&&(a=e[i+1],o=e[i+2],s=e[i+3],(192&a)==128&&(192&o)==128&&(192&s)==128&&(c=(15&t)<<18|(63&a)<<12|(63&o)<<6|63&s,(c<=65535||c>=1114112)&&(c=null))),c===null?(c=65533,l=1):c>65535&&(c-=65536,r+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),r+=String.fromCharCode(c),i+=l}return r}(e,t,n)}class Sm extends Xf{constructor(e,t,n,r){super(e,n,r),this.offsetBuffer=t}}class Cm extends Sm{constructor(e,t,n,r){super(e,t,n,r??t.length-1)}getValueFromBuffer(e){return xm(this.dataBuffer,this.offsetBuffer[e],this.offsetBuffer[e+1])}}class wm extends Sm{constructor(e,t,n,r,i){super(e,n,r,i??t.length),this.indexBuffer=t,this.indexBuffer=t}getValueFromBuffer(e){let t=this.indexBuffer[e];return xm(this.dataBuffer,this.offsetBuffer[t],this.offsetBuffer[t+1])}}class Tm extends Sm{constructor(e,t,n,r,i,a,o){super(e,n,r,o),this.indexBuffer=t,this.symbolOffsetBuffer=i,this.symbolTableBuffer=a}getValueFromBuffer(e){this.decodedDictionary??=(this.symbolLengthBuffer??=this.offsetToLengthBuffer(this.symbolOffsetBuffer),function(e,t,n){let r=[],i=Array(t.length).fill(0);for(let e=1;e<t.length;e++)i[e]=i[e-1]+t[e-1];for(let a=0;a<n.length;a++)if(n[a]===255)r.push(n[++a]);else{let o=t[n[a]],s=i[n[a]];for(let t=0;t<o;t++)r.push(e[s+t])}return new Uint8Array(r)}(this.symbolTableBuffer,this.symbolLengthBuffer,this.dataBuffer));let t=this.indexBuffer[e];return xm(this.decodedDictionary,this.offsetBuffer[t],this.offsetBuffer[t+1])}offsetToLengthBuffer(e){let t=new Uint32Array(e.length-1),n=e[0];for(let r=1;r<e.length;r++){let i=e[r];t[r-1]=i-n,n=i}return t}}function Em(e,t,n,r,i,a){return n.type===`scalarType`?function(e,t,n,r,i,a){let o=null;if(e===0)return null;if(a.nullable){let e=Bp(t,n),r=e.numValues,i=n.get(),a=ym(t,r,e.byteLength,n);n.set(i+e.byteLength),o=new Vp(a,e.numValues)}let s=o??r;switch(i.physicalType){case 4:case 3:return function(e,t,n,r,i){let a=Bp(e,t),o=Qp(a,i,e,t),s=r.physicalType===3;if(o===Ip.FLAT){let r=Dm(i)?i:void 0,o=s?Up(e,t,a,0,r):Wp(e,t,a,0,r);return new Qf(n.name,o,i)}if(o===Ip.SEQUENCE){let r=Jp(e,t,a);return new tp(n.name,r[0],r[1],a.numRleValues)}let c=s?function(e,t,n){let r=Kp(e,t,n);return r.length===1?Cp(r[0]):function(e){return Cp(e[1])}(r)}(e,t,a):qp(e,t,a);return new np(n.name,c,i,s)}(t,n,a,i,s);case 9:return function(e,t,n,r,i){let a=null,o=null,s=null,c=null,l=null,u=i??null,d=null,f=null;for(let e=0;e<r;e++){let e=Bp(t,n);switch(e.physicalStreamType){case Mp.PRESENT:{let r=new Vp(ym(t,e.numValues,e.byteLength,n),e.numValues);u=i??r;break}case Mp.OFFSET:o=Wp(t,n,e,0,u);break;case Mp.LENGTH:{let r=Gp(t,n,e);Fp.DICTIONARY===e.logicalStreamType.lengthType?a=r:Fp.SYMBOL===e.logicalStreamType.lengthType?c=r:d=r;break}case Mp.DATA:{let r=t.subarray(n.get(),n.get()+e.byteLength);n.add(e.byteLength);let i=e.logicalStreamType.dictionaryType;Np.FSST===i?l=r:Np.SINGLE===i||Np.SHARED===i?s=r:Np.NONE===i&&(f=r);break}}}return function(e,t,n,r,i,a,o){return t?new Tm(e,n,r,i,a,t,o):null}(e,l,o,a,s,c,u)??function(e,t,n,r,i){return t?i?new wm(e,n,r,t,i):new wm(e,n,r,t):null}(e,s,o,a,u)??function(e,t,n,r,i){if(!t||!n)return null;if(r)return i?new wm(e,r,t,n,i):new wm(e,r,t,n);if(i&&i.size()!==t.length-1){let r=new Uint32Array(i.size()),a=0;for(let e=0;e<i.size();e++)r[e]=i.get(e)?a++:0;return new wm(e,r,t,n,i)}return i?new Cm(e,t,n,i):new Cm(e,t,n)}(e,d,f,o,u)}(a.name,t,n,a.nullable?e-1:e,o);case 0:return function(e,t,n,r,i){let a=Bp(e,t),o=a.numValues,s=t.get(),c=Dm(i)?i:void 0,l=ym(e,o,a.byteLength,t,c);t.set(s+a.byteLength);let u=new Vp(l,o);return new gm(n.name,u,i)}(t,n,a,0,s);case 6:case 5:return function(e,t,n,r,i){let a=Bp(e,t),o=Qp(a,r,e,t,`int64`),s=i.physicalType===5;if(o===Ip.FLAT){let i=Dm(r)?r:void 0,o=s?function(e,t,n,r){return function(e,t,n){let r;switch(t.logicalLevelTechnique1){case ap.DELTA:if(t.logicalLevelTechnique2===ap.RLE){let i=t;if(!n)return function(e,t,n){let r=new BigInt64Array(n),i=0,a=0n;for(let n=0;n<t;n++){let o=Number(e[n]),s=wp(e[n+t]);for(let e=0;e<o;e++)a+=s,r[i++]=a}return r}(e,i.runs,i.numRleValues);r=Ap(e=Dp(e,i.runs,i.numRleValues))}else r=Ap(e);break;case ap.RLE:r=function(e,t,n){if(n===void 0){n=0;for(let r=0;r<t;r++)n+=Number(e[r])}let r=new BigInt64Array(n),i=0;for(let n=0;n<t;n++){let a=Number(e[n]),o=e[n+t];o=wp(o),r.fill(o,i,i+a),i+=a}return r}(e,t.runs,t.numRleValues);break;case ap.NONE:r=function(e){let t=new BigInt64Array(e.length);for(let n=0;n<e.length;n++)t[n]=wp(e[n]);return t}(e);break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return n?Hp(r,n,0n):r}(bp(e,t,n.numValues),n,r)}(e,t,a,i):Xp(e,t,a,i);return new $p(n.name,o,r)}if(o===Ip.SEQUENCE){let r=Yp(e,t,a);return new em(n.name,r[0],r[1],a.numRleValues)}let c=s?function(e,t,n){let r=bp(e,t,n.numValues);return r.length===1?wp(r[0]):function(e){return wp(e[1])}(r)}(e,t,a):Zp(e,t,a);return new vm(n.name,c,r,s)}(t,n,a,s,i);case 7:return function(e,t,n,r){let i=Bp(e,t),a=Dm(r)?r:void 0,o=function(e,t,n,r){let i=t.get(),a=i+n*Float32Array.BYTES_PER_ELEMENT,o=new Uint8Array(e.subarray(i,a)).buffer,s=new Float32Array(o);return t.set(a),r?Hp(s,r,0):s}(e,t,i.numValues,a);return new _m(n.name,o,r)}(t,n,a,s);case 8:return function(e,t,n,r){let i=Bp(e,t),a=Dm(r)?r:void 0,o=function(e,t,n,r){let i=t.get(),a=i+n*Float64Array.BYTES_PER_ELEMENT,o=new Uint8Array(e.subarray(i,a)).buffer,s=new Float64Array(o);return t.set(a),r?Hp(s,r,0):s}(e,t,i.numValues,a);return new $f(n.name,o,r)}(t,n,a,s);default:throw Error(`The specified data type for the field is currently not supported: ${i}`)}}(r,e,t,i,n.scalarType,n):r===0?null:function(e,t,n,r){let i=null,a=null,o=null,s=null,c=!1;for(;!c;){let n=Bp(e,t);switch(n.physicalStreamType){case Mp.LENGTH:Fp.DICTIONARY===n.logicalStreamType.lengthType?i=Gp(e,t,n):o=Gp(e,t,n);break;case Mp.DATA:Np.SINGLE===n.logicalStreamType.dictionaryType||Np.SHARED===n.logicalStreamType.dictionaryType?(a=e.subarray(t.get(),t.get()+n.byteLength),c=!0):s=e.subarray(t.get(),t.get()+n.byteLength),t.add(n.byteLength)}}let l=n.complexType.children,u=[],d=0;for(let c of l){let l=yp(e,t,1)[0];if(l===0)continue;let f=c.name?`${n.name}${c.name}`:n.name;if(l!==2||c.type!==`scalarField`||c.scalarField.physicalType!==9)throw Error(`Currently only optional string fields are implemented for a struct.`);let p=Bp(e,t),m=ym(e,p.numValues,p.byteLength,t),h=Bp(e,t),g=Wp(e,t,h,0,h.decompressedCount===r?void 0:new Vp(m,p.numValues));u[d++]=s?new Tm(f,g,i,a,o,s,new Vp(m,p.numValues)):new wm(f,g,i,a,new Vp(m,p.numValues))}return u}(e,t,n,i)}function Dm(e){return e instanceof Vp}function Om(e){switch(e){case 0:case 1:case 2:case 3:{let t={};t.nullable=!!(1&e),t.columnScope=0;let n={type:`logicalType`,logicalType:0};return n.longID=!!(2&e),t.scalarType=n,t.type=`scalarType`,t}case 4:{let e={nullable:!1,columnScope:0};return e.type=`complexType`,e.complexType={type:`physicalType`,physicalType:0},e}case 30:{let e={nullable:!1,columnScope:0};return e.type=`complexType`,e.complexType={type:`physicalType`,physicalType:1},e}default:return function(e){let t;switch(e){case 10:case 11:t=0;break;case 12:case 13:t=1;break;case 14:case 15:t=2;break;case 16:case 17:t=3;break;case 18:case 19:t=4;break;case 20:case 21:t=5;break;case 22:case 23:t=6;break;case 24:case 25:t=7;break;case 26:case 27:t=8;break;case 28:case 29:t=9;break;default:return null}let n={};n.nullable=!!(1&e),n.columnScope=0;let r={type:`physicalType`};return r.physicalType=t,n.type=`scalarType`,n.scalarType=r,n}(e)}}function km(e){return e>=10}function Am(e){return e===30}function jm(e){if(e.type===`scalarType`){let t=e.scalarType;if(t.type===`physicalType`)switch(t.physicalType){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:default:return!1;case 9:return!0}if(t.type===`logicalType`)return!1}else if(e.type===`complexType`){let t=e.complexType;if(t.type===`physicalType`)switch(t.physicalType){case 0:case 1:return!0;default:return!1}}return console.warn(`Unexpected column type in hasStreamCount`,e),!1}function Mm(e){return e.type===`complexType`&&e.complexType?.type===`physicalType`&&e.complexType.physicalType===0}let Nm=new TextDecoder;function Pm(e,t){let n=yp(e,t,1)[0];if(n===0)return``;let r=t.get(),i=e.subarray(r,r+n);return t.add(n),Nm.decode(i)}function Fm(e,t){let n=yp(e,t,1)[0]>>>0;if(n<10||n>30)throw Error(`Unsupported field type code ${n}. Supported: 10-29(scalars), 30(STRUCT)`);let r=Om(n);if(km(n)&&(r.name=Pm(e,t)),Am(n)){let n=yp(e,t,1)[0]>>>0;r.complexType.children=Array(n);for(let i=0;i<n;i++)r.complexType.children[i]=Fm(e,t)}return function(e){return{name:e.name,nullable:e.nullable,scalarField:e.scalarType,complexField:e.complexType,type:e.type===`scalarType`?`scalarField`:`complexField`}}(r)}function Im(e,t){let n=yp(e,t,1)[0]>>>0,r=Om(n);if(!r)throw Error(`Unsupported column type code ${n}. Supported: 0-3(ID), 4(GEOMETRY), 10-29(scalars), 30(STRUCT)`);if(km(n)?r.name=Pm(e,t):n>=0&&n<=3?r.name=`id`:n===4&&(r.name=`geometry`),Am(n)){let n=yp(e,t,1)[0]>>>0,i=r.complexType;i.children=Array(n);for(let r=0;r<n;r++)i.children[r]=Fm(e,t)}return r}function Lm(e,t){let n={featureTables:[]},r={};r.name=Pm(e,t);let i=yp(e,t,1)[0]>>>0,a=yp(e,t,1)[0]>>>0;r.columns=Array(a);for(let n=0;n<a;n++)r.columns[n]=Im(e,t);return n.featureTables.push(r),[n,i]}function Rm(e,t,n,r,i,a,o=!1){let s=t.scalarType;if(!s||s.type!==`logicalType`||s.logicalType!==0)throw Error(`ID column must be a logical ID scalar type: ${r}`);let c=s.longID?6:4,l=typeof a==`number`?void 0:a,u=Qp(i,a,e,n,c===6?`int64`:`int32`);if(c===4)switch(u){case Ip.FLAT:return new Qf(r,Wp(e,n,i,0,l),a);case Ip.SEQUENCE:{let t=Jp(e,n,i);return new tp(r,t[0],t[1],i.numRleValues)}case Ip.CONST:return new np(r,qp(e,n,i),a,!1)}switch(u){case Ip.FLAT:return o?new $f(r,function(e,t,n){return function(e,t){switch(t.logicalLevelTechnique1){case ap.DELTA:return t.logicalLevelTechnique2===ap.RLE&&(e=Op(e,t.runs,t.numRleValues)),function(e){e[0]=Tp(e[0]);let t=e.length/4*4,n=1;if(t>=4)for(;n<t-4;n+=4){let t=e[n+1],r=e[n+2],i=e[n+3];e[n]=Tp(e[n])+e[n-1],e[n+1]=Tp(t)+e[n],e[n+2]=Tp(r)+e[n+1],e[n+3]=Tp(i)+e[n+2]}for(;n!==e.length;++n)e[n]=Tp(e[n])+e[n-1]}(e),e;case ap.RLE:return function(e,t){return Op(e,t.runs,t.numRleValues)}(e,t);case ap.NONE:return e;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}}(function(e,t,n){let r=new Float64Array(n);for(let i=0;i<n;i++)r[i]=Sp(e,t);return r}(e,t,n.numValues),n)}(e,n,i),a):new $p(r,Xp(e,n,i,l),a);case Ip.SEQUENCE:{let t=Yp(e,n,i);return new em(r,t[0],t[1],i.numRleValues)}case Ip.CONST:return new vm(r,Zp(e,n,i),a,!1)}throw Error(`Vector type not supported for id column.`)}class zm{constructor(e,t){switch(this._featureData=e,this.properties=this._featureData.properties||{},this._featureData.geometry?.type){case Lp.POINT:case Lp.MULTIPOINT:this.type=1;break;case Lp.LINESTRING:case Lp.MULTILINESTRING:this.type=2;break;case Lp.POLYGON:case Lp.MULTIPOLYGON:this.type=3;break;default:this.type=0}this.extent=t,this.id=Number(this._featureData.id)}loadGeometry(){let e=[];for(let t of this._featureData.geometry.coordinates){let r=[];for(let e of t)r.push(new n(e.x,e.y));e.push(r)}return e}}class Bm{constructor(e){this.features=[],this.featureTable=e,this.name=e.name,this.extent=e.extent,this.version=2,this.features=e.getFeatures(),this.length=this.features.length}feature(e){return new zm(this.features[e],this.extent)}}class Vm{constructor(e){this.layers={};let t=function(e,t,n=!0){let r=new ip(0),i=[];for(;r.get()<e.length;){let t=yp(e,r,1)[0]>>>0,o=r.get()+t;if(o>e.length)throw Error(`Block overruns tile: ${o} > ${e.length}`);if(yp(e,r,1)[0]>>>0!=1){r.set(o);continue}let[s,c]=Lm(e,r),l=s.featureTables[0],u=null,d=null,f=[],p=0;for(let t of l.columns){let i=t.name;if((a=t).type===`scalarType`&&a.scalarType?.type===`logicalType`&&a.scalarType.logicalType===0){let a=null;if(t.nullable){let t=Bp(e,r),n=r.get(),i=ym(e,t.numValues,t.byteLength,r);r.set(n+t.byteLength),a=new Vp(i,t.numValues)}let o=Bp(e,r);p=a?a.size():o.decompressedCount,u=Rm(e,t,r,i,o,a??p,n)}else if(Mm(t)){let t=yp(e,r,1)[0];if(p===0){let t=r.get();p=Bp(e,r).decompressedCount,r.set(t)}d=pm(e,t,r,p)}else{let n=jm(t)?yp(e,r,1)[0]:1;if(n===0)continue;let i=Em(e,r,t,n,p);if(i)if(Array.isArray(i))for(let e of i)f.push(e);else f.push(i)}}let m=new rp(l.name,d,u,f,c);i.push(m),r.set(o)}var a;return i}(new Uint8Array(e));this.layers=t.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:new Bm(t)})),{})}}class Hm{constructor(e,t){this.feature=e,this.type=e.type,this.properties=e.tags?e.tags:{},this.extent=t,`id`in e&&(typeof e.id==`string`?this.id=parseInt(e.id,10):typeof e.id!=`number`||isNaN(e.id)||(this.id=e.id))}loadGeometry(){let e=[],t=this.feature.type===1?[this.feature.geometry]:this.feature.geometry;for(let r of t){let t=[];for(let e of r)t.push(new n(e[0],e[1]));e.push(t)}return e}}let Um=`_geojsonTileLayer`;function Wm(e,t,n=``){t.writeVarintField(15,e.version||1),t.writeStringField(1,e.name||``),t.writeVarintField(5,e.extent||4096);let r={jsonPrefix:n,keys:[],values:[],keycache:{},valuecache:{}};for(let n=0;n<e.length;n++)r.feature=e.feature(n),t.writeMessage(2,Gm,r);let i=r.keys;for(let e of i)t.writeStringField(3,e);let a=r.values;for(let e of a)t.writeMessage(4,Xm,e)}function Gm(e,t){if(!e.feature)return;let n=e.feature;n.id!==void 0&&t.writeVarintField(1,n.id),t.writeMessage(2,Km,e),t.writeVarintField(3,n.type),t.writeMessage(4,Ym,n)}function Km(e,t){for(let n in e.feature?.properties){let r=e.feature.properties[n],i=e.keycache[n];if(r==null)continue;i===void 0&&(e.keys.push(n),i=e.keys.length-1,e.keycache[n]=i),t.writeVarint(i),typeof r!=`string`&&typeof r!=`boolean`&&typeof r!=`number`&&(r=e.jsonPrefix+JSON.stringify(r));let a=typeof r+`:`+r,o=e.valuecache[a];o===void 0&&(e.values.push(r),o=e.values.length-1,e.valuecache[a]=o),t.writeVarint(o)}}function qm(e,t){return(t<<3)+(7&e)}function Jm(e){return e<<1^e>>31}function Ym(e,t){let n=e.loadGeometry(),r=e.type,i=0,a=0;for(let o of n){let n=1;r===1&&(n=o.length),t.writeVarint(qm(1,n));let s=r===3?o.length-1:o.length;for(let e=0;e<s;e++){e===1&&r!==1&&t.writeVarint(qm(2,s-1));let n=o[e].x-i,c=o[e].y-a;t.writeVarint(Jm(n)),t.writeVarint(Jm(c)),i+=n,a+=c}e.type===3&&t.writeVarint(qm(7,1))}}function Xm(e,t){let n=typeof e;n===`string`?t.writeStringField(1,e):n===`boolean`?t.writeBooleanField(7,e):n===`number`&&(e%1==0?e<0?t.writeSVarintField(6,e):t.writeVarintField(5,e):t.writeDoubleField(3,e))}class Zm{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new ma(O,16,0),this.grid3D=new ma(O,16,0),this.featureIndexArray=new Wo,this.promoteId=t}insert(e,t,n,r,i,a){let o=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(n,r,i);let s=a?this.grid3D:this.grid;for(let e of t){let t=[1/0,1/0,-1/0,-1/0];for(let n of e)t[0]=Math.min(t[0],n.x),t[1]=Math.min(t[1],n.y),t[2]=Math.max(t[2],n.x),t[3]=Math.max(t[3],n.y);t[0]<O&&t[1]<O&&t[2]>=0&&t[3]>=0&&s.insert(o,t[0],t[1],t[2],t[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=this.encoding===`mlt`?new Vm(this.rawTileData).layers:new Ll(new Nd(this.rawTileData)).layers,this.sourceLayerCoder=new Jf(this.vtLayers?Object.keys(this.vtLayers).sort():[Um])),this.vtLayers}query(e,t,r,i){this.loadVTLayers();let a=e.params,o=O/e.tileSize/e.scale,s=vi(a.filter,a.globalState),c=e.queryGeometry,l=e.queryPadding*o,u=qf.fromPoints(c),d=this.grid.query(u.minX-l,u.minY-l,u.maxX+l,u.maxY+l),f=qf.fromPoints(e.cameraQueryGeometry).expandBy(l),p=this.grid3D.query(f.minX,f.minY,f.maxX,f.maxY,((t,r,i,a)=>function(e,t,r,i,a){for(let n of e)if(t<=n.x&&r<=n.y&&i>=n.x&&a>=n.y)return!0;let o=[new n(t,r),new n(t,a),new n(i,a),new n(i,r)];if(e.length>2){for(let t of o)if(tc(e,t))return!0}for(let t=0;t<e.length-1;t++)if(nc(e[t],e[t+1],o))return!0;return!1}(e.cameraQueryGeometry,t-l,r-l,i+l,a+l)));for(let e of p)d.push(e);d.sort($m);let m={},h;for(let n of d){if(n===h)continue;h=n;let l=this.featureIndexArray.get(n),u=null;this.loadMatchingFeature(m,l.bucketIndex,l.sourceLayerIndex,l.featureIndex,s,a.layers,a.availableImages,t,r,i,((t,n,r)=>(u||=Vs(t),n.queryIntersectsFeature({queryGeometry:c,feature:t,featureState:r,geometry:u,zoom:this.z,transform:e.transform,pixelsToTileUnits:o,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation}))))}return m}loadMatchingFeature(e,t,n,r,i,a,o,s,c,l,u){let d=this.bucketLayerIDs[t];if(a&&!d.some((e=>a.has(e))))return;let f=this.sourceLayerCoder.decode(n),p=this.vtLayers[f].feature(r);if(i.needGeometry){let e=Hs(p,!0);if(!i.filter(new Fa(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!i.filter(new Fa(this.tileID.overscaledZ),p))return;let m=this.getId(p,f);for(let t of d){if(a&&!a.has(t))continue;let n=s[t];if(!n)continue;let i={};m&&l&&(i=l.getState(n.sourceLayer||Um,m));let d=oe({},c[t]);d.paint=Qm(d.paint,n.paint,p,i,o),d.layout=Qm(d.layout,n.layout,p,i,o);let f=!u||u(p,n,i);if(!f)continue;let h=new Yf(p,this.z,this.x,this.y,m);h.layer=d;let g=e[t];g===void 0&&(g=e[t]=[]),g.push({featureIndex:r,feature:h,intersectionZ:f})}}lookupSymbolFeatures(e,t,n,r,i,a,o,s){let c={};this.loadVTLayers();let l=vi(i.filterSpec,i.globalState);for(let i of e)this.loadMatchingFeature(c,n,r,i,l,a,o,s,t);return c}hasLayer(e){for(let t of this.bucketLayerIDs)for(let n of t)if(e===n)return!0;return!1}getId(e,t){var n;let r=e.id;return this.promoteId&&(r=e.properties[typeof this.promoteId==`string`?this.promoteId:this.promoteId[t]],typeof r==`boolean`&&(r=Number(r)),r===void 0&&(n=e.properties)!=null&&n.cluster&&this.promoteId&&(r=Number(e.properties.cluster_id))),r}}function Qm(e,t,n,r,i){return ce(e,((e,a)=>{let o=t instanceof Ga?t.get(a):null;return o?.evaluate?o.evaluate(n,r,i):o}))}function $m(e,t){return t-e}function eh(e,t,r,i,a){let o=[];for(let s of e){let e;for(let c=0;c<s.length-1;c++){let l=s[c],u=s[c+1];l.x<t&&u.x<t||(l.x<t?l=new n(t,l.y+(t-l.x)/(u.x-l.x)*(u.y-l.y))._round():u.x<t&&(u=new n(t,l.y+(t-l.x)/(u.x-l.x)*(u.y-l.y))._round()),l.y<r&&u.y<r||(l.y<r?l=new n(l.x+(r-l.y)/(u.y-l.y)*(u.x-l.x),r)._round():u.y<r&&(u=new n(l.x+(r-l.y)/(u.y-l.y)*(u.x-l.x),r)._round()),l.x>=i&&u.x>=i||(l.x>=i?l=new n(i,l.y+(i-l.x)/(u.x-l.x)*(u.y-l.y))._round():u.x>=i&&(u=new n(i,l.y+(i-l.x)/(u.x-l.x)*(u.y-l.y))._round()),l.y>=a&&u.y>=a||(l.y>=a?l=new n(l.x+(a-l.y)/(u.y-l.y)*(u.x-l.x),a)._round():u.y>=a&&(u=new n(l.x+(a-l.y)/(u.y-l.y)*(u.x-l.x),a)._round()),e&&l.equals(e[e.length-1])||(e=[l],o.push(e)),e.push(u)))))}}return o}function th(e,t,n,r,i){switch(t){case 1:return function(e,t,n,r){let i=[];for(let a of e)for(let e of a){let a=r===0?e.x:e.y;a>=t&&a<=n&&i.push([e])}return i}(e,n,r,i);case 2:return rh(e,n,r,i,!1);case 3:return rh(e,n,r,i,!0)}return[]}function nh(e,t,r,i,a){let o=i===0?ih:ah,s=[],c=[];for(let n=0;n<e.length-1;n++){let l=e[n],u=e[n+1],d=i===0?l.x:l.y,f=i===0?u.x:u.y,p=!1;d<t?f>t&&s.push(o(l,u,t)):d>r?f<r&&s.push(o(l,u,r)):s.push(l),f<t&&d>=t&&(s.push(o(l,u,t)),p=!0),f>r&&d<=r&&(s.push(o(l,u,r)),p=!0),!a&&p&&(c.push(s),s=[])}let l=e.length-1,u=i===0?e[l].x:e[l].y;return u>=t&&u<=r&&s.push(e[l]),a&&s.length>0&&!s[0].equals(s[s.length-1])&&s.push(new n(s[0].x,s[0].y)),s.length>0&&c.push(s),c}function rh(e,t,n,r,i){let a=[];for(let o of e){let e=nh(o,t,n,r,i);e.length>0&&a.push(...e)}return a}function ih(e,t,r){return new n(r,e.y+(r-e.x)/(t.x-e.x)*(t.y-e.y))}function ah(e,t,r){return new n(e.x+(r-e.y)/(t.y-e.y)*(t.x-e.x),r)}X(`FeatureIndex`,Zm,{omit:[`rawTileData`,`sourceLayerCoder`]});class oh extends n{constructor(e,t,n,r){super(e,t),this.angle=n,r!==void 0&&(this.segment=r)}clone(){return new oh(this.x,this.y,this.angle,this.segment)}}function sh(e,t,n,r,i){if(t.segment===void 0||n===0)return!0;let a=t,o=t.segment+1,s=0;for(;s>-n/2;){if(o--,o<0)return!1;s-=e[o].dist(a),a=e[o]}s+=e[o].dist(e[o+1]),o++;let c=[],l=0;for(;s<n/2;){let t=e[o],n=e[o+1];if(!n)return!1;let a=e[o-1].angleTo(t)-t.angleTo(n);for(a=Math.abs((a+3*Math.PI)%(2*Math.PI)-Math.PI),c.push({distance:s,angleDelta:a}),l+=a;s-c[0].distance>r;)l-=c.shift().angleDelta;if(l>i)return!1;o++,s+=t.dist(n)}return!0}function ch(e){let t=0;for(let n=0;n<e.length-1;n++)t+=e[n].dist(e[n+1]);return t}function lh(e,t,n){return e?.6*t*n:0}function uh(e,t){return Math.max(e?e.right-e.left:0,t?t.right-t.left:0)}function dh(e,t,n,r,i,a){let o=lh(n,i,a),s=uh(n,r)*a,c=0,l=ch(e)/2;for(let n=0;n<e.length-1;n++){let r=e[n],i=e[n+1],a=r.dist(i);if(c+a>l){let u=(l-c)/a,d=new oh(Dn.number(r.x,i.x,u),Dn.number(r.y,i.y,u),i.angleTo(r),n);return d._round(),!o||sh(e,d,s,o,t)?d:void 0}c+=a}}function fh(e,t,n,r,i,a,o,s,c){let l=lh(r,a,o),u=uh(r,i),d=u*o,f=e[0].x===0||e[0].x===c||e[0].y===0||e[0].y===c;return t-d<t/4&&(t=d+t/4),ph(e,f?t/2*s%t:(u/2+2*a)*o*s%t,t,l,n,d,f,!1,c)}function ph(e,t,n,r,i,a,o,s,c){let l=a/2,u=ch(e),d=0,f=t-n,p=[];for(let t=0;t<e.length-1;t++){let o=e[t],s=e[t+1],m=o.dist(s),h=s.angleTo(o);for(;f+n<d+m;){f+=n;let g=(f-d)/m,_=Dn.number(o.x,s.x,g),v=Dn.number(o.y,s.y,g);if(_>=0&&_<c&&v>=0&&v<c&&f-l>=0&&f+l<=u){let n=new oh(_,v,h,t);n._round(),r&&!sh(e,n,a,r,i)||p.push(n)}}d+=m}return s||p.length||o||(p=ph(e,d/2,n,r,i,a,o,!0,c)),p}function mh(e,t,r,i){let a=[],o=e.image,s=o.pixelRatio,c=o.paddedRect.w-2,l=o.paddedRect.h-2,u={x1:e.left,y1:e.top,x2:e.right,y2:e.bottom},d=o.stretchX||[[0,c]],f=o.stretchY||[[0,l]],p=(e,t)=>e+t[1]-t[0],m=d.reduce(p,0),h=f.reduce(p,0),g=c-m,_=l-h,v=0,y=m,b=0,x=h,S=0,C=g,w=0,T=_;if(o.content&&i){let t=o.content,n=t[2]-t[0],r=t[3]-t[1];(o.textFitWidth||o.textFitHeight)&&(u=cf(e)),v=hh(d,0,t[0]),b=hh(f,0,t[1]),y=hh(d,t[0],t[2]),x=hh(f,t[1],t[3]),S=t[0]-v,w=t[1]-b,C=n-y,T=r-x}let E=u.x1,D=u.y1,O=u.x2-E,k=u.y2-D,A=(e,i,a,c)=>{let l=_h(e.stretch-v,y,O,E),u=vh(e.fixed-S,C,e.stretch,m),d=_h(i.stretch-b,x,k,D),f=vh(i.fixed-w,T,i.stretch,h),p=_h(a.stretch-v,y,O,E),g=vh(a.fixed-S,C,a.stretch,m),_=_h(c.stretch-b,x,k,D),A=vh(c.fixed-w,T,c.stretch,h),ee=new n(l,d),te=new n(p,d),j=new n(p,_),ne=new n(l,_),re=new n(u/s,f/s),ie=new n(g/s,A/s),ae=t*Math.PI/180;if(ae){let e=Math.sin(ae),t=Math.cos(ae),n=[t,-e,e,t];ee._matMult(n),te._matMult(n),ne._matMult(n),j._matMult(n)}let oe=e.stretch+e.fixed,se=i.stretch+i.fixed;return{tl:ee,tr:te,bl:ne,br:j,tex:{x:o.paddedRect.x+1+oe,y:o.paddedRect.y+1+se,w:a.stretch+a.fixed-oe,h:c.stretch+c.fixed-se},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:re,pixelOffsetBR:ie,minFontScaleX:C/s/O,minFontScaleY:T/s/k,isSDF:r}};if(i&&(o.stretchX||o.stretchY)){let e=gh(d,g,m),t=gh(f,_,h);for(let n=0;n<e.length-1;n++){let r=e[n],i=e[n+1];for(let e=0;e<t.length-1;e++)a.push(A(r,t[e],i,t[e+1]))}}else a.push(A({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:c+1},{fixed:0,stretch:l+1}));return a}function hh(e,t,n){let r=0;for(let i of e)r+=Math.max(t,Math.min(n,i[1]))-Math.max(t,Math.min(n,i[0]));return r}function gh(e,t,n){let r=[{fixed:-1,stretch:0}];for(let[t,n]of e){let e=r[r.length-1];r.push({fixed:t-e.stretch,stretch:e.stretch}),r.push({fixed:t-e.stretch,stretch:e.stretch+(n-t)})}return r.push({fixed:t+1,stretch:n}),r}function _h(e,t,n,r){return e/t*n+r}function vh(e,t,n,r){return e-t*n/r}X(`Anchor`,oh);class yh{constructor(e,t,r,i,a,o,s,c,l,u){if(this.boxStartIndex=e.length,l){let e=o.top,t=o.bottom,n=o.collisionPadding;n&&(e-=n[1],t+=n[3]);let r=t-e;r>0&&(r=Math.max(10,r),this.circleDiameter=r)}else{let l=o.image?.content&&(o.image.textFitWidth||o.image.textFitHeight)?cf(o):{x1:o.left,y1:o.top,x2:o.right,y2:o.bottom};l.y1=l.y1*s-c[0],l.y2=l.y2*s+c[2],l.x1=l.x1*s-c[3],l.x2=l.x2*s+c[1];let d=o.collisionPadding;if(d&&(l.x1-=d[0]*s,l.y1-=d[1]*s,l.x2+=d[2]*s,l.y2+=d[3]*s),u){let e=new n(l.x1,l.y1),t=new n(l.x2,l.y1),r=new n(l.x1,l.y2),i=new n(l.x2,l.y2),a=u*Math.PI/180;e._rotate(a),t._rotate(a),r._rotate(a),i._rotate(a),l.x1=Math.min(e.x,t.x,r.x,i.x),l.x2=Math.max(e.x,t.x,r.x,i.x),l.y1=Math.min(e.y,t.y,r.y,i.y),l.y2=Math.max(e.y,t.y,r.y,i.y)}e.emplaceBack(t.x,t.y,l.x1,l.y1,l.x2,l.y2,r,i,a)}this.boxEndIndex=e.length}}class bh{constructor(e=[],t=(e,t)=>e<t?-1:+(e>t)){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;let e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){let{data:t,compare:n}=this,r=t[e];for(;e>0;){let i=e-1>>1,a=t[i];if(n(r,a)>=0)break;t[e]=a,e=i}t[e]=r}_down(e){let{data:t,compare:n}=this,r=this.length>>1,i=t[e];for(;e<r;){let r=1+(e<<1),a=r+1;if(a<this.length&&n(t[a],t[r])<0&&(r=a),n(t[r],i)>=0)break;t[e]=t[r],e=r}t[e]=i}}function xh(e,t=1){let r=qf.fromPoints(e[0]),i=Math.min(r.width(),r.height()),a=i/2,o=new bh([],Sh),{minX:s,minY:c,maxX:l,maxY:u}=r;if(i===0)return new n(s,c);for(let t=s;t<l;t+=i)for(let n=c;n<u;n+=i)o.push(new Ch(t+a,n+a,a,e));let d=function(e){let t=0,n=0,r=0,i=e[0];for(let e=0,a=i.length,o=a-1;e<a;o=e++){let a=i[e],s=i[o],c=a.x*s.y-s.x*a.y;n+=(a.x+s.x)*c,r+=(a.y+s.y)*c,t+=3*c}return new Ch(n/t,r/t,0,e)}(e),f=d;for(;o.length;){let n=o.pop();(n.d>f.d||!f.d)&&(f=n),n.max-f.d<=t||(a=n.h/2,o.push(new Ch(n.p.x-a,n.p.y-a,a,e)),o.push(new Ch(n.p.x+a,n.p.y-a,a,e)),o.push(new Ch(n.p.x-a,n.p.y+a,a,e)),o.push(new Ch(n.p.x+a,n.p.y+a,a,e)))}return d.d>0&&f.d-d.d<=t?d.p:f.p}function Sh(e,t){return t.max-e.max}class Ch{constructor(e,t,r,i){this.p=new n(e,t),this.h=r,this.d=function(e,t){let n=!1,r=1/0;for(let i of t)for(let t=0,a=i.length,o=a-1;t<a;o=t++){let a=i[t],s=i[o];a.y>e.y!=s.y>e.y&&e.x<(s.x-a.x)*(e.y-a.y)/(s.y-a.y)+a.x&&(n=!n),r=Math.min(r,$s(e,a,s))}return(n?1:-1)*Math.sqrt(r)}(this.p,i),this.max=this.d+this.h*Math.SQRT2}}var wh;e.aM=void 0,(wh=e.aM||={})[wh.center=1]=`center`,wh[wh.left=2]=`left`,wh[wh.right=3]=`right`,wh[wh.top=4]=`top`,wh[wh.bottom=5]=`bottom`,wh[wh[`top-left`]=6]=`top-left`,wh[wh[`top-right`]=7]=`top-right`,wh[wh[`bottom-left`]=8]=`bottom-left`,wh[wh[`bottom-right`]=9]=`bottom-right`;let Th=1/0;function Eh(e,t){return t[1]===Th?function(e,t){let n=0,r=0;t<0&&(t=0);let i=t/Math.SQRT2;switch(e){case`top-right`:case`top-left`:r=i-7;break;case`bottom-right`:case`bottom-left`:r=7-i;break;case`bottom`:r=7-t;break;case`top`:r=t-7}switch(e){case`top-right`:case`bottom-right`:n=-i;break;case`top-left`:case`bottom-left`:n=i;break;case`left`:n=t;break;case`right`:n=-t}return[n,r]}(e,t[0]):function(e,t,n){let r=0,i=0;switch(t=Math.abs(t),n=Math.abs(n),e){case`top-right`:case`top-left`:case`top`:i=n-7;break;case`bottom-right`:case`bottom-left`:case`bottom`:i=7-n}switch(e){case`top-right`:case`bottom-right`:case`right`:r=-t;break;case`top-left`:case`bottom-left`:case`left`:r=t}return[r,i]}(e,t[0],t[1])}function Dh(e,t,n){let r=e.layout,i=r.get(`text-variable-anchor-offset`)?.evaluate(t,{},n);if(i){let e=i.values,t=[];for(let n=0;n<e.length;n+=2){let r=t[n]=e[n],i=e[n+1].map((e=>e*bd));r.startsWith(`top`)?i[1]-=7:r.startsWith(`bottom`)&&(i[1]+=7),t[n+1]=i}return new $t(t)}let a=r.get(`text-variable-anchor`);if(a){let i;i=e._unevaluatedLayout.getValue(`text-radial-offset`)===void 0?r.get(`text-offset`).evaluate(t,{},n).map((e=>e*bd)):[r.get(`text-radial-offset`).evaluate(t,{},n)*bd,Th];let o=[];for(let e of a)o.push(e,Eh(e,i));return new $t(o)}return null}function Oh(e){switch(e){case`right`:case`top-right`:case`bottom-right`:return`right`;case`left`:case`top-left`:case`bottom-left`:return`left`}return`center`}function kh(t,n,r,i,a,o,s,c,l,u,d,f){let p=o.textMaxSize.evaluate(n,{});p===void 0&&(p=s);let m=t.layers[0].layout,h=m.get(`icon-offset`).evaluate(n,{},d),g=jh(r.horizontal),_=s/24,v=t.tilePixelRatio*_,y=t.tilePixelRatio*p/24,b=t.tilePixelRatio*c,x=t.tilePixelRatio*m.get(`symbol-spacing`),S=m.get(`text-padding`)*t.tilePixelRatio,C=function(e,t,n,r=1){let i=e.get(`icon-padding`).evaluate(t,{},n)?.values;return[i[0]*r,i[1]*r,i[2]*r,i[3]*r]}(m,n,d,t.tilePixelRatio),w=m.get(`text-max-angle`)/180*Math.PI,T=m.get(`text-rotation-alignment`)!==`viewport`&&m.get(`symbol-placement`)!==`point`,E=m.get(`icon-rotation-alignment`)===`map`&&m.get(`symbol-placement`)!==`point`,D=m.get(`symbol-placement`),k=x/2,A=m.get(`icon-text-fit`),ee;i&&A!==`none`&&(t.allowVerticalPlacement&&r.vertical&&(ee=lf(i,r.vertical,A,m.get(`icon-text-fit-padding`),h,_)),g&&(i=lf(i,g,A,m.get(`icon-text-fit-padding`),h,_)));let te=d?f.line.getGranularityForZoomLevel(d.z):1,j=(c,f)=>{f.x<0||f.x>=O||f.y<0||f.y>=O||function(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T){let E=t.addToLineVertexArray(n,r),D,O,k,A,ee=0,te=0,j=0,ne=0,re=-1,ie=-1,ae={},oe=_s(``);if(t.allowVerticalPlacement&&i.vertical){let e=c.layout.get(`text-rotate`).evaluate(x,{},w)+90;k=new yh(l,n,u,d,f,i.vertical,p,m,h,e),s&&(A=new yh(l,n,u,d,f,s,_,v,h,e))}if(a){let r=c.layout.get(`icon-rotate`).evaluate(x,{}),i=c.layout.get(`icon-text-fit`)!==`none`,o=mh(a,r,C,i),p=s?mh(s,r,C,i):void 0;O=new yh(l,n,u,d,f,a,_,v,!1,r),ee=4*o.length;let m=t.iconSizeData,h=null;m.kind===`source`?(h=[128*c.layout.get(`icon-size`).evaluate(x,{})],h[0]>uf&&fe(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):m.kind===`composite`&&(h=[128*S.compositeIconSizes[0].evaluate(x,{},w),128*S.compositeIconSizes[1].evaluate(x,{},w)],(h[0]>uf||h[1]>uf)&&fe(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),t.addSymbols(t.icon,o,h,b,y,x,e.ax.none,n,E.lineStartIndex,E.lineLength,-1,w),re=t.icon.placedSymbolArray.length-1,p&&(te=4*p.length,t.addSymbols(t.icon,p,h,b,y,x,e.ax.vertical,n,E.lineStartIndex,E.lineLength,-1,w),ie=t.icon.placedSymbolArray.length-1)}let se=Object.keys(i.horizontal);for(let r of se){let a=i.horizontal[r];D||=(oe=_s(a.text),new yh(l,n,u,d,f,a,p,m,h,c.layout.get(`text-rotate`).evaluate(x,{},w)));let s=a.positionedLines.length===1;if(j+=Ah(t,n,a,o,c,h,x,g,E,i.vertical?e.ax.horizontal:e.ax.horizontalOnly,s?se:[r],ae,re,S,w),s)break}i.vertical&&(ne+=Ah(t,n,i.vertical,o,c,h,x,g,E,e.ax.vertical,[`vertical`],ae,ie,S,w));let ce=D?D.boxStartIndex:t.collisionBoxArray.length,le=D?D.boxEndIndex:t.collisionBoxArray.length,ue=k?k.boxStartIndex:t.collisionBoxArray.length,de=k?k.boxEndIndex:t.collisionBoxArray.length,pe=O?O.boxStartIndex:t.collisionBoxArray.length,me=O?O.boxEndIndex:t.collisionBoxArray.length,he=A?A.boxStartIndex:t.collisionBoxArray.length,ge=A?A.boxEndIndex:t.collisionBoxArray.length,_e=-1,ve=(e,t)=>e?.circleDiameter?Math.max(e.circleDiameter,t):t;_e=ve(D,_e),_e=ve(k,_e),_e=ve(O,_e),_e=ve(A,_e);let ye=+(_e>-1);ye&&(_e*=T/bd),t.glyphOffsetArray.length>=yf.MAX_GLYPHS&&fe(`Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907`),x.sortKey!==void 0&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey);let be=Dh(c,x,w),[xe,Se]=function(t,n){let r=t.length,i=n?.values;if(i?.length>0)for(let n=0;n<i.length;n+=2){let r=i[n+1];t.emplaceBack(e.aM[i[n]],r[0],r[1])}return[r,t.length]}(t.textAnchorOffsets,be);t.symbolInstances.emplaceBack(n.x,n.y,ae.right>=0?ae.right:-1,ae.center>=0?ae.center:-1,ae.left>=0?ae.left:-1,ae.vertical||-1,re,ie,oe,ce,le,ue,de,pe,me,he,ge,u,j,ne,ee,te,ye,0,p,_e,xe,Se)}(t,f,c,r,i,a,ee,t.layers[0],t.collisionBoxArray,n.index,n.sourceLayerIndex,t.index,v,[S,S,S,S],T,l,b,C,E,h,n,o,u,d,s)};if(D===`line`)for(let e of eh(n.geometry,0,0,O,O)){let n=yl(e,te),a=fh(n,x,w,r.vertical||g,i,24,y,t.overscaling,O);for(let e of a)g&&Mh(t,g.text,k,e)||j(n,e)}else if(D===`line-center`){for(let e of n.geometry)if(e.length>1){let t=yl(e,te),n=dh(t,w,r.vertical||g,i,24,y);n&&j(t,n)}}else if(n.type===`Polygon`)for(let e of dr(n.geometry,0)){let t=xh(e,16);j(yl(e[0],te,!0),new oh(t.x,t.y,0))}else if(n.type===`LineString`)for(let e of n.geometry){let t=yl(e,te);j(t,new oh(t[0].x,t[0].y,0))}else if(n.type===`Point`)for(let e of n.geometry)for(let t of e)j([t],new oh(t.x,t.y,0))}function Ah(e,t,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=function(e,t,r,i,a,o,s,c){let l=i.layout.get(`text-rotate`).evaluate(o,{})*Math.PI/180,u=[];for(let e of t.positionedLines)for(let i of e.positionedGlyphs){if(!i.rect)continue;let o=i.rect||{},d=4,f=!0,p=1,m=0,h=(a||c)&&i.vertical,g=i.metrics.advance*i.scale/2;if(c&&t.verticalizable&&(m=e.lineOffset/2-(i.imageName?-(bd-i.metrics.width*i.scale)/2:(i.scale-1)*bd)),i.imageName){let e=s[i.imageName];f=e.sdf,p=e.pixelRatio,d=1/p}let _=a?[i.x+g,i.y]:[0,0],v=a?[0,0]:[i.x+g+r[0],i.y+r[1]-m],y=[0,0];h&&(y=v,v=[0,0]);let b=i.metrics.isDoubleResolution?2:1,x=(i.metrics.left-d)*i.scale-g+v[0],S=(-i.metrics.top-d)*i.scale+v[1],C=x+o.w/b*i.scale/p,w=S+o.h/b*i.scale/p,T=new n(x,S),E=new n(C,S),D=new n(x,w),O=new n(C,w);if(h){let e=new n(-g,g- -17),t=-Math.PI/2,r=12-g,a=new n(22-r,-(i.imageName?r:0)),o=new n(...y);T._rotateAround(t,e)._add(a)._add(o),E._rotateAround(t,e)._add(a)._add(o),D._rotateAround(t,e)._add(a)._add(o),O._rotateAround(t,e)._add(a)._add(o)}if(l){let e=Math.sin(l),t=Math.cos(l),n=[t,-e,e,t];T._matMult(n),E._matMult(n),D._matMult(n),O._matMult(n)}let k=new n(0,0),A=new n(0,0);u.push({tl:T,tr:E,bl:D,br:O,tex:o,writingMode:t.writingMode,glyphOffset:_,sectionIndex:i.sectionIndex,isSDF:f,pixelOffsetTL:k,pixelOffsetBR:A,minFontScaleX:0,minFontScaleY:0})}return u}(0,r,c,a,o,s,i,e.allowVerticalPlacement),_=e.textSizeData,v=null;_.kind===`source`?(v=[128*a.layout.get(`text-size`).evaluate(s,{})],v[0]>uf&&fe(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):_.kind===`composite`&&(v=[128*m.compositeTextSizes[0].evaluate(s,{},h),128*m.compositeTextSizes[1].evaluate(s,{},h)],(v[0]>uf||v[1]>uf)&&fe(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,g,v,c,o,s,u,t,l.lineStartIndex,l.lineLength,p,h);for(let t of d)f[t]=e.text.placedSymbolArray.length-1;return 4*g.length}function jh(e){for(let t in e)return e[t];return null}function Mh(e,t,n,r){let i=e.compareText;if(t in i){let e=i[t];for(let t=e.length-1;t>=0;t--)if(r.dist(e[t])<n)return!0}else i[t]=[];return i[t].push(r),!1}e.$=Oe,e.A=f,e.B=La,e.C=pa,e.D=Q,e.E=Ve,e.F=ca,e.G=function([e,t,n]){return t+=90,t*=Math.PI/180,n*=Math.PI/180,{x:e*Math.cos(t)*Math.sin(n),y:e*Math.sin(t)*Math.sin(n),z:e*Math.cos(n)}},e.H=Dn,e.I=Yd,e.J=Fa,e.K=ua,e.L=function(e){if(he==null){let t=e.navigator?e.navigator.userAgent:null;he=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match(`Safari`)&&!t.match(`Chrome`)))}return he},e.M=Me,e.N=class{constructor(e,t){this.target=e,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new kf((()=>this.process())),this.subscription=xe(this.target,`message`,(e=>this.receive(e)),!1),this.globalScope=me(self)?e:window}registerMessageHandler(e,t){this.messageHandlers[e]=t}unregisterMessageHandler(e){delete this.messageHandlers[e]}sendAsync(e,t){return new Promise(((n,r)=>{let i=Math.round(0xde0b6b3a7640000*Math.random()).toString(36).substring(0,10),a=t?xe(t.signal,`abort`,(()=>{a?.unsubscribe(),delete this.resolveRejects[i];let t={id:i,type:`<cancel>`,origin:location.origin,targetMapId:e.targetMapId,sourceMapId:this.mapId};this.target.postMessage(t)}),Af):null;this.resolveRejects[i]={resolve:e=>{a?.unsubscribe(),n(e)},reject:e=>{a?.unsubscribe(),r(e)}};let o=[],s=Object.assign(Object.assign({},e),{id:i,sourceMapId:this.mapId,origin:location.origin,data:Z(e.data,o)});this.target.postMessage(s,{transfer:o})}))}receive(e){let t=e.data,n=t.id,r=[`file://`,`resource://android`,`null`],i=[t.origin,location.origin],a=t.origin===location.origin,o=i.some((e=>r.includes(e)));if((a||o)&&(!t.targetMapId||this.mapId===t.targetMapId)){if(t.type===`<cancel>`){delete this.tasks[n];let e=this.abortControllers[n];delete this.abortControllers[n],e&&e.abort();return}if(me(self)||t.mustQueue)return this.tasks[n]=t,this.taskQueue.push(n),void this.invoker.trigger();this.processTask(n,t)}}process(){if(this.taskQueue.length===0)return;let e=this.taskQueue.shift(),t=this.tasks[e];delete this.tasks[e],this.taskQueue.length>0&&this.invoker.trigger(),t&&this.processTask(e,t)}processTask(e,n){return t(this,void 0,void 0,(function*(){if(n.type===`<response>`){let t=this.resolveRejects[e];if(delete this.resolveRejects[e],!t)return;n.error?t.reject(A(ya(n.error))):t.resolve(ya(n.data));return}if(!this.messageHandlers[n.type])return void this.completeTask(e,Error(`Could not find a registered handler for ${n.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(`, `)}`));let t=ya(n.data),r=new AbortController;this.abortControllers[e]=r;try{let i=yield this.messageHandlers[n.type](n.sourceMapId,t,r);this.completeTask(e,null,i)}catch(t){this.completeTask(e,A(t))}}))}completeTask(e,t,n){let r=[];delete this.abortControllers[e];let i={id:e,type:`<response>`,sourceMapId:this.mapId,origin:location.origin,error:t?Z(t):null,data:Z(n,r)};this.target.postMessage(i,{transfer:r})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},e.O=function(){var e=new f(16);return f!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e},e.P=n,e.Q=function(e,t,n){var r,i,a,o,s,c,l,u,d,f,p,m,h=n[0],g=n[1],_=n[2];return t===e?(e[12]=t[0]*h+t[4]*g+t[8]*_+t[12],e[13]=t[1]*h+t[5]*g+t[9]*_+t[13],e[14]=t[2]*h+t[6]*g+t[10]*_+t[14],e[15]=t[3]*h+t[7]*g+t[11]*_+t[15]):(i=t[1],a=t[2],o=t[3],s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11],e[0]=r=t[0],e[1]=i,e[2]=a,e[3]=o,e[4]=s,e[5]=c,e[6]=l,e[7]=u,e[8]=d,e[9]=f,e[10]=p,e[11]=m,e[12]=r*h+s*g+d*_+t[12],e[13]=i*h+c*g+f*_+t[13],e[14]=a*h+l*g+p*_+t[14],e[15]=o*h+u*g+m*_+t[15]),e},e.R=wc,e.S=function(e,t,n){var r=n[0],i=n[1],a=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*a,e[9]=t[9]*a,e[10]=t[10]*a,e[11]=t[11]*a,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},e.T=Fc,e.U=function(e,t,n){var r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11],h=t[12],g=t[13],_=t[14],v=t[15],y=n[0],b=n[1],x=n[2],S=n[3];return e[0]=y*r+b*s+x*d+S*h,e[1]=y*i+b*c+x*f+S*g,e[2]=y*a+b*l+x*p+S*_,e[3]=y*o+b*u+x*m+S*v,e[4]=(y=n[4])*r+(b=n[5])*s+(x=n[6])*d+(S=n[7])*h,e[5]=y*i+b*c+x*f+S*g,e[6]=y*a+b*l+x*p+S*_,e[7]=y*o+b*u+x*m+S*v,e[8]=(y=n[8])*r+(b=n[9])*s+(x=n[10])*d+(S=n[11])*h,e[9]=y*i+b*c+x*f+S*g,e[10]=y*a+b*l+x*p+S*_,e[11]=y*o+b*u+x*m+S*v,e[12]=(y=n[12])*r+(b=n[13])*s+(x=n[14])*d+(S=n[15])*h,e[13]=y*i+b*c+x*f+S*g,e[14]=y*a+b*l+x*p+S*_,e[15]=y*o+b*u+x*m+S*v,e},e.V=function(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n},e.W=Mf,e.X=ae,e.Y=If,e.Z=Ff,e._=t,e.a=De,e.a$=function(e){var t=new f(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},e.a0=l,e.a1=u,e.a2=ve,e.a3=Gf,e.a4=Rf,e.a5=zf,e.a6=O,e.a7=Vf,e.a8=qf,e.a9=25,e.aA=function(e){var t=e[0],n=e[1];return Math.sqrt(t*t+n*n)},e.aB=function(e){return e[0]=0,e[1]=0,e},e.aC=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e},e.aD=hf,e.aE=C,e.aF=function(e,t,r,i){let a=t.y-e.y,o=t.x-e.x,s=i.y-r.y,c=i.x-r.x,l=s*o-c*a;if(l===0)return null;let u=(c*(e.y-r.y)-s*(e.x-r.x))/l;return new n(e.x+u*o,e.y+u*a)},e.aG=eh,e.aH=Ks,e.aI=function(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e)t=Math.min(t,a.x),n=Math.min(n,a.y),r=Math.max(r,a.x),i=Math.max(i,a.y);return[t,n,r,i]},e.aJ=bd,e.aK=k,e.aL=function(e,t,n,r,i=!1){if(!n[0]&&!n[1])return[0,0];let a=i?r===`map`?-e.bearingInRadians:0:r===`viewport`?e.bearingInRadians:0;if(a){let e=Math.sin(a),t=Math.cos(a);n=[n[0]*t-n[1]*e,n[0]*e+n[1]*t]}return[i?n[0]:k(t,n[0],e.zoom),i?n[1]:k(t,n[1],e.zoom)]},e.aN=ff,e.aO=Oh,e.aP=$d,e.aQ=e=>e.type===`symbol`,e.aR=Zl,e.aS=oo,e.aT=ml,e.aU=Go,e.aV=ss,e.aW=is,e.aX=Ce,e.aY=Bf,e.aZ=y,e.a_=v,e.aa=Uf,e.ab=e=>{let t=window.document.createElement(`video`);return t.muted=!0,new Promise((n=>{t.onloadstart=()=>{n(t)};for(let n of e){let e=window.document.createElement(`source`);Ie(n)||(t.crossOrigin=`Anonymous`),e.src=n,t.appendChild(e)}}))},e.ac=F,e.ad=function(){return se++},e.ae=Po,e.af=yf,e.ag=Um,e.ah=vi,e.ai=Hs,e.aj=Yf,e.ak=function(e){let t={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((e,n,r,i)=>{let a=r||i;return t[n]=!a||a.toLowerCase(),``})),t[`max-age`]){let e=parseInt(t[`max-age`],10);isNaN(e)?delete t[`max-age`]:t[`max-age`]=e}return t},e.al=ie,e.am=85.051129,e.an=Se,e.ao=function(e){return 2**e},e.ap=m,e.aq=Lf,e.ar=function(e){return Math.log(e)/Math.LN2},e.as=function(e){var t=e[0],n=e[1];return t*t+n*n},e.at=function(e){if(!e.length)return new Set;let t=Math.max(...e.map((e=>e.canonical.z))),n=1/0,r=-1/0,i=1/0,a=-1/0,o=[];for(let s of e){let{x:e,y:c,z:l}=s.canonical,u=2**(t-l),d=e*u,f=c*u;o.push({id:s,x:d,y:f}),d<n&&(n=d),d>r&&(r=d),f<i&&(i=f),f>a&&(a=f)}let s=new Set;for(let e of o)e.x!==n&&e.x!==r&&e.y!==i&&e.y!==a||s.add(e.id);return s},e.au=function(e,t){let n=Math.abs(2*e.wrap)-+(e.wrap<0),r=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-n||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x},e.av=class{constructor(e,t){this.max=e,this.onRemove=t,this.reset()}reset(){for(let e in this.data)for(let t of this.data[e])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}add(e,t,n){let r=e.wrapped().key;this.data[r]===void 0&&(this.data[r]=[]);let i={value:t,timeout:void 0};if(n!==void 0&&(i.timeout=setTimeout((()=>{this.remove(e,i)}),n)),this.data[r].push(i),this.order.push(r),this.order.length>this.max){let e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){let t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),this.data[e].length===0&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){let t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;let n=e.wrapped().key,r=t===void 0?0:this.data[n].indexOf(t),i=this.data[n][r];return this.data[n].splice(r,1),i.timeout&&clearTimeout(i.timeout),this.data[n].length===0&&delete this.data[n],this.onRemove(i.value),this.order.splice(this.order.indexOf(n),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){let e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){let t=[];for(let n in this.data)for(let r of this.data[n])e(r.value)||t.push(r);for(let e of t)this.remove(e.value.tileID,e)}},e.aw=function(e,t){let n=0,r=0;if(e.kind===`constant`)r=e.layoutSize;else if(e.kind!==`source`){let{interpolationType:i,minZoom:a,maxZoom:o}=e,s=i?ie(Tn.interpolationFactor(i,t,a,o),0,1):0;e.kind===`camera`?r=Dn.number(e.minSize,e.maxSize,s):n=s}return{uSizeT:n,uSize:r}},e.ay=function(e,{uSize:t,uSizeT:n},{lowerSize:r,upperSize:i}){return e.kind===`source`?r/128:e.kind===`composite`?Dn.number(r/128,i/128,n):t},e.az=E,e.b=ge,e.b$=Ts,e.b0=function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e},e.b1=function(e,t){var n=t[0],r=t[1],i=t[2],a=n*n+r*r+i*i;return a>0&&(a=1/Math.sqrt(a)),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a,e},e.b2=b,e.b3=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},e.b4=function(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e[3]=t[3]*n[3],e},e.b5=g,e.b6=function(e,t,n){let r=t[0]*n[0]+t[1]*n[1]+t[2]*n[2];return r===0?null:(-(e[0]*n[0]+e[1]*n[1]+e[2]*n[2])-n[3])/r},e.b7=S,e.b8=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e},e.b9=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]},e.bA=T,e.bB=function(e,t,n){var r=n[0],i=n[1],a=n[2],o=n[3],s=t[0],c=t[1],l=t[2],u=i*l-a*c,d=a*s-r*l,f=r*c-i*s;return e[0]=s+o*(u+=u)+i*(f+=f)-a*(d+=d),e[1]=c+o*d+a*u-r*f,e[2]=l+o*f+r*d-i*u,e},e.bC=function(e,t,n){let r=(i=[e[0],e[1],e[2],t[0],t[1],t[2],n[0],n[1],n[2]])[0]*((u=i[8])*(o=i[4])-(s=i[5])*(l=i[7]))+i[1]*(-u*(a=i[3])+s*(c=i[6]))+i[2]*(l*a-o*c);var i,a,o,s,c,l,u;if(r===0)return null;let d=b([],[t[0],t[1],t[2]],[n[0],n[1],n[2]]),f=b([],[n[0],n[1],n[2]],[e[0],e[1],e[2]]),p=b([],[e[0],e[1],e[2]],[t[0],t[1],t[2]]),m=y([],d,-e[3]);return v(m,m,y([],f,-t[3])),v(m,m,y([],p,-n[3])),y(m,m,1/r),m},e.bD=jf,e.bE=function(){return new Float64Array(4)},e.bF=function(e,t,n,r){var i=[],a=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],a[0]=i[0]*Math.cos(r)-i[1]*Math.sin(r),a[1]=i[0]*Math.sin(r)+i[1]*Math.cos(r),a[2]=i[2],e[0]=a[0]+n[0],e[1]=a[1]+n[1],e[2]=a[2]+n[2],e},e.bG=function(e,t,n,r){var i=[],a=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],a[0]=i[0],a[1]=i[1]*Math.cos(r)-i[2]*Math.sin(r),a[2]=i[1]*Math.sin(r)+i[2]*Math.cos(r),e[0]=a[0]+n[0],e[1]=a[1]+n[1],e[2]=a[2]+n[2],e},e.bH=function(e,t,n,r){var i=[],a=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],a[0]=i[2]*Math.sin(r)+i[0]*Math.cos(r),a[1]=i[1],a[2]=i[2]*Math.cos(r)-i[0]*Math.sin(r),e[0]=a[0]+n[0],e[1]=a[1]+n[1],e[2]=a[2]+n[2],e},e.bI=function(e,t,n){var r=Math.sin(n),i=Math.cos(n),a=t[0],o=t[1],s=t[2],c=t[3],l=t[8],u=t[9],d=t[10],f=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=a*i-l*r,e[1]=o*i-u*r,e[2]=s*i-d*r,e[3]=c*i-f*r,e[8]=a*r+l*i,e[9]=o*r+u*i,e[10]=s*r+d*i,e[11]=c*r+f*i,e},e.bJ=function(e,t){let n=ee(e,360),r=ee(t,360),i=r-n,a=r>n?i-360:i+360;return Math.abs(i)<Math.abs(a)?i:a},e.bK=function(e){return e[0]=0,e[1]=0,e[2]=0,e},e.bL=function(e,t,n,r){let i=Math.sqrt(e*e+t*t),a=Math.sqrt(n*n+r*r);e/=i,t/=i,n/=a,r/=a;let o=Math.acos(e*n+t*r);return-t*n+e*r>0?o:-o},e.bM=function(e,t){let n=ee(e,2*Math.PI),r=ee(t,2*Math.PI);return Math.min(Math.abs(n-r),Math.abs(n-r+2*Math.PI),Math.abs(n-r-2*Math.PI))},e.bN=function(){let e={},t=M.$version;for(let n in M.$root){let r=M.$root[n];if(r.required){let i=null;i=n===`version`?t:r.type===`array`?[]:{},i!=null&&(e[n]=i)}}return e},e.bO=Pe,e.bP=ba,e.bQ=function e(t,n){if(Array.isArray(t)){if(!Array.isArray(n)||t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!e(t[r],n[r]))return!1;return!0}if(typeof t==`object`&&t&&n!==null){if(typeof n!=`object`||Object.keys(t).length!==Object.keys(n).length)return!1;for(let r in t)if(!e(t[r],n[r]))return!1;return!0}return t===n},e.bR=ke,e.bS=function(e){e=e.slice();let t=Object.create(null);for(let n=0;n<e.length;n++)t[e[n].id]=e[n];for(let n=0;n<e.length;n++)`ref`in e[n]&&(e[n]=Ue(e[n],t[e[n].ref]));return e},e.bT=function(e,t){if(e.type===`custom`)return new Of(e,t);switch(e.type){case`background`:return new Df(e,t);case`circle`:return new gc(e,t);case`color-relief`:return new Rc(e,t);case`fill`:return new Dl(e,t);case`fill-extrusion`:return new ql(e,t);case`heatmap`:return new Oc(e,t);case`hillshade`:return new jc(e,t);case`line`:return new dd(e,t);case`raster`:return new no(e,t);case`symbol`:return new wf(e,t)}},e.bU=e=>e.type===`raster`,e.bV=ue,e.bW=function(e,t){if(!e)return[{command:`setStyle`,args:[t]}];let n=[];try{if(!N(e.version,t.version))return[{command:`setStyle`,args:[t]}];N(e.center,t.center)||n.push({command:`setCenter`,args:[t.center]}),N(e.state,t.state)||n.push({command:`setGlobalState`,args:[t.state]}),N(e.centerAltitude,t.centerAltitude)||n.push({command:`setCenterAltitude`,args:[t.centerAltitude]}),N(e.zoom,t.zoom)||n.push({command:`setZoom`,args:[t.zoom]}),N(e.bearing,t.bearing)||n.push({command:`setBearing`,args:[t.bearing]}),N(e.pitch,t.pitch)||n.push({command:`setPitch`,args:[t.pitch]}),N(e.roll,t.roll)||n.push({command:`setRoll`,args:[t.roll]}),N(e.sprite,t.sprite)||n.push({command:`setSprite`,args:[t.sprite]}),N(e.glyphs,t.glyphs)||n.push({command:`setGlyphs`,args:[t.glyphs]}),N(e.transition,t.transition)||n.push({command:`setTransition`,args:[t.transition]}),N(e.light,t.light)||n.push({command:`setLight`,args:[t.light]}),N(e.terrain,t.terrain)||n.push({command:`setTerrain`,args:[t.terrain]}),N(e.sky,t.sky)||n.push({command:`setSky`,args:[t.sky]}),N(e.projection,t.projection)||n.push({command:`setProjection`,args:[t.projection]});let r={},i=[];(function(e,t,n,r){let i;for(i in t||={},e||={})Object.prototype.hasOwnProperty.call(e,i)&&(Object.prototype.hasOwnProperty.call(t,i)||Ge(i,n,r));for(i in t)Object.prototype.hasOwnProperty.call(t,i)&&(Object.prototype.hasOwnProperty.call(e,i)?N(e[i],t[i])||(e[i].type===`geojson`&&t[i].type===`geojson`&&qe(e,t,i)?P(n,{command:`setGeoJSONSourceData`,args:[i,t[i].data]}):Ke(i,t,n,r)):We(i,t,n))})(e.sources,t.sources,i,r);let a=[];e.layers&&e.layers.forEach((e=>{`source`in e&&r[e.source]?n.push({command:`removeLayer`,args:[e.id]}):a.push(e)})),n=n.concat(i),function(e,t,n){t||=[];let r=(e||=[]).map(Ye),i=t.map(Ye),a=e.reduce(Xe,{}),o=t.reduce(Xe,{}),s=r.slice(),c=Object.create(null),l,u,d,f,p;for(let e=0,t=0;e<r.length;e++)l=r[e],Object.prototype.hasOwnProperty.call(o,l)?t++:(P(n,{command:`removeLayer`,args:[l]}),s.splice(s.indexOf(l,t),1));for(let e=0,t=0;e<i.length;e++)l=i[i.length-1-e],s[s.length-1-e]!==l&&(Object.prototype.hasOwnProperty.call(a,l)?(P(n,{command:`removeLayer`,args:[l]}),s.splice(s.lastIndexOf(l,s.length-t),1)):t++,f=s[s.length-e],P(n,{command:`addLayer`,args:[o[l],f]}),s.splice(s.length-e,0,l),c[l]=!0);for(let e=0;e<i.length;e++)if(l=i[e],u=a[l],d=o[l],!c[l]&&!N(u,d))if(N(u.source,d.source)&&N(u[`source-layer`],d[`source-layer`])&&N(u.type,d.type)){for(p in Je(u.layout,d.layout,n,l,null,`setLayoutProperty`),Je(u.paint,d.paint,n,l,null,`setPaintProperty`),N(u.filter,d.filter)||P(n,{command:`setFilter`,args:[l,d.filter]}),N(u.minzoom,d.minzoom)&&N(u.maxzoom,d.maxzoom)||P(n,{command:`setLayerZoomRange`,args:[l,d.minzoom,d.maxzoom]}),u)Object.prototype.hasOwnProperty.call(u,p)&&p!==`layout`&&p!==`paint`&&p!==`filter`&&p!==`metadata`&&p!==`minzoom`&&p!==`maxzoom`&&(p.indexOf(`paint.`)===0?Je(u[p],d[p],n,l,p.slice(6),`setPaintProperty`):N(u[p],d[p])||P(n,{command:`setLayerProperty`,args:[l,p,d[p]]}));for(p in d)Object.prototype.hasOwnProperty.call(d,p)&&!Object.prototype.hasOwnProperty.call(u,p)&&p!==`layout`&&p!==`paint`&&p!==`filter`&&p!==`metadata`&&p!==`minzoom`&&p!==`maxzoom`&&(p.indexOf(`paint.`)===0?Je(u[p],d[p],n,l,p.slice(6),`setPaintProperty`):N(u[p],d[p])||P(n,{command:`setLayerProperty`,args:[l,p,d[p]]}))}else P(n,{command:`removeLayer`,args:[l]}),f=s[s.lastIndexOf(l)+1],P(n,{command:`addLayer`,args:[d,f]})}(a,t.layers,n)}catch(e){console.warn(`Unable to compute style diff:`,e),n=[{command:`setStyle`,args:[t]}]}return n},e.bX=function(e){let t=[],n=e.id;return n===void 0&&t.push({message:`layers.${n}: missing required property "id"`}),e.render===void 0&&t.push({message:`layers.${n}: missing required method "render"`}),e.renderingMode&&e.renderingMode!==`2d`&&e.renderingMode!==`3d`&&t.push({message:`layers.${n}: property "renderingMode" must be either "2d" or "3d"`}),t},e.bY=ce,e.bZ=le,e.b_=class extends Ss{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1i(this.location,e))}},e.ba=Wf,e.bb=Kf,e.bc=function(e,t,n,r,i){var a=1/Math.tan(t/2);if(e[0]=a/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,i!=null&&i!==1/0){var o=1/(r-i);e[10]=(i+r)*o,e[14]=2*i*r*o}else e[10]=-1,e[14]=-2*r;return e},e.bd=function(e){var t=new f(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},e.be=function(e,t,n){var r=Math.sin(n),i=Math.cos(n),a=t[0],o=t[1],s=t[2],c=t[3],l=t[4],u=t[5],d=t[6],f=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=a*i+l*r,e[1]=o*i+u*r,e[2]=s*i+d*r,e[3]=c*i+f*r,e[4]=l*i-a*r,e[5]=u*i-o*r,e[6]=d*i-s*r,e[7]=f*i-c*r,e},e.bf=function(e,t,n){var r=Math.sin(n),i=Math.cos(n),a=t[4],o=t[5],s=t[6],c=t[7],l=t[8],u=t[9],d=t[10],f=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=a*i+l*r,e[5]=o*i+u*r,e[6]=s*i+d*r,e[7]=c*i+f*r,e[8]=l*i-a*r,e[9]=u*i-o*r,e[10]=d*i-s*r,e[11]=f*i-c*r,e},e.bg=function(e,t){var n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14],_=t[15],v=n*s-r*o,y=n*c-i*o,b=n*l-a*o,x=r*c-i*s,S=r*l-a*s,C=i*l-a*c,w=u*h-d*m,T=u*g-f*m,E=u*_-p*m,D=d*g-f*h,O=d*_-p*h,k=f*_-p*g,A=v*k-y*O+b*D+x*E-S*T+C*w;return A?(e[0]=(s*k-c*O+l*D)*(A=1/A),e[1]=(i*O-r*k-a*D)*A,e[2]=(h*C-g*S+_*x)*A,e[3]=(f*S-d*C-p*x)*A,e[4]=(c*E-o*k-l*T)*A,e[5]=(n*k-i*E+a*T)*A,e[6]=(g*b-m*C-_*y)*A,e[7]=(u*C-f*b+p*y)*A,e[8]=(o*O-s*E+l*w)*A,e[9]=(r*E-n*O-a*w)*A,e[10]=(m*S-h*b+_*v)*A,e[11]=(d*b-u*S-p*v)*A,e[12]=(s*T-o*D-c*w)*A,e[13]=(n*D-r*T+i*w)*A,e[14]=(h*y-m*x-g*v)*A,e[15]=(u*x-d*y+f*v)*A,e):null},e.bh=function(){let e=new Float32Array(16);return m(e),e},e.bi=function(){let e=new Float64Array(16);return m(e),e},e.bj=function(){return new Float64Array(16)},e.bk=function(e,t,n){let r=new Float64Array(4);return T(r,e,t-90,n),r},e.bl=function(e,t,n,r){var i,a,o,s,c,l=t[0],u=t[1],f=t[2],p=t[3],m=n[0],h=n[1],g=n[2],_=n[3];return(a=l*m+u*h+f*g+p*_)<0&&(a=-a,m=-m,h=-h,g=-g,_=-_),1-a>d?(i=Math.acos(a),o=Math.sin(i),s=Math.sin((1-r)*i)/o,c=Math.sin(r*i)/o):(s=1-r,c=r),e[0]=s*l+c*m,e[1]=s*u+c*h,e[2]=s*f+c*g,e[3]=s*p+c*_,e},e.bm=function(e){let t=new Float64Array(9);var n,r,i,a,o,s,c,l,u,d=(i=(r=e)[0])*(c=i+i),f=(a=r[1])*c,p,m=(o=r[2])*c,h=o*(l=a+a),g,_=(s=r[3])*c,v=s*l,y=s*(u=o+o);(n=t)[0]=1-(p=a*l)-(g=o*u),n[3]=f-y,n[6]=m+v,n[1]=f+y,n[4]=1-d-g,n[7]=h-_,n[2]=m-v,n[5]=h+_,n[8]=1-d-p;let b=Ce(-Math.asin(ie(t[2],-1,1))),x,S;return Math.hypot(t[5],t[8])<.001?(x=0,S=-Ce(Math.atan2(t[3],t[4]))):(x=Ce(t[5]===0&&t[8]===0?0:Math.atan2(t[5],t[8])),S=Ce(t[1]===0&&t[0]===0?0:Math.atan2(t[1],t[0]))),{roll:x,pitch:b+90,bearing:S}},e.bn=function(e,t){return e.roll==t.roll&&e.pitch==t.pitch&&e.bearing==t.bearing},e.bo=Ut,e.bp=Cs,e.bq=hl,e.br=gl,e.bs=pl,e.bt=te,e.bu=j,e.bv=tn,e.bw=function(e,t,n,r,i){return te(r,i,ie((e-t)/(n-t),0,1))},e.bx=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e},e.by=ee,e.bz=function(){return new Float64Array(3)},e.c=Ae,e.c$=li,e.c0=class extends Ss{constructor(e,t){super(e,t),this.current=Es}set(e){if(e[12]!==this.current[12]||e[0]!==this.current[0])return this.current=e,void this.gl.uniformMatrix4fv(this.location,!1,e);for(let t=1;t<16;t++)if(e[t]!==this.current[t]){this.current=e,this.gl.uniformMatrix4fv(this.location,!1,e);break}}},e.c1=ws,e.c2=class extends Ss{constructor(e,t){super(e,t),this.current=[0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]||(this.current=e,this.gl.uniform3f(this.location,e[0],e[1],e[2]))}},e.c3=class extends Ss{constructor(e,t){super(e,t),this.current=[0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]||(this.current=e,this.gl.uniform2f(this.location,e[0],e[1]))}},e.c4=p,e.c5=function(e,t){var n=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=n,e[2]=0,e[3]=-n,e[4]=r,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},e.c6=function(e,t,n){var r=t[0],i=t[1],a=t[2];return e[0]=r*n[0]+i*n[3]+a*n[6],e[1]=r*n[1]+i*n[4]+a*n[7],e[2]=r*n[2]+i*n[5]+a*n[8],e},e.c7=function(e,t,n,r,i,a,o){var s=1/(t-n),c=1/(r-i),l=1/(a-o);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*c,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+n)*s,e[13]=(i+r)*c,e[14]=(o+a)*l,e[15]=1,e},e.c8=class extends Ss{constructor(e,t){super(e,t),this.current=[]}set(e){if(e!=this.current){this.current=e;let t=new Float32Array(4*e.length);for(let n=0;n<e.length;n++)t[4*n]=e[n].r,t[4*n+1]=e[n].g,t[4*n+2]=e[n].b,t[4*n+3]=e[n].a;this.gl.uniform4fv(this.location,t)}}},e.c9=class extends Ss{constructor(e,t){super(e,t),this.current=[]}set(e){if(e!=this.current){this.current=e;let t=new Float32Array(e);this.gl.uniform1fv(this.location,t)}}},e.cA=function(e,t){return we[t]&&`touches`in e},e.cB=function(e){return we[e]||Te[e]},e.cC=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[4]*i+n[12],e[1]=n[1]*r+n[5]*i+n[13],e},e.cD=function(e,t){let{x:n,y:r}=Vf.fromLngLat(t);return!(e<0||e>25||r<0||r>=1||n<0||n>=1)},e.cE=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},e.cF=class extends lo{},e.cG=Ne,e.cH=function(e,t){Ae.REGISTERED_PROTOCOLS[e]=t},e.cI=function(e){delete Ae.REGISTERED_PROTOCOLS[e]},e.cJ=function(e,t){let n={};for(let r=0;r<e.length;r++){let i=t&&t[e[r].id]||Ei(e[r]);t&&(t[e[r].id]=i);let a=n[i];a||=n[i]=[],a.push(e[r])}let r=[];for(let e in n)r.push(n[e]);return r},e.cK=X,e.cL=Jf,e.cM=Zm,e.cN=Xd,e.cO=function(t){var n;t.bucket.createArrays(),t.bucket.tilePixelRatio=O/(512*t.bucket.overscaling),t.bucket.compareText={},t.bucket.iconsNeedLinear=!1;let r=t.bucket.layers[0],i=r.layout,a=r._unevaluatedLayout._values,o={layoutIconSize:a[`icon-size`].possiblyEvaluate(new Fa(t.bucket.zoom+1),t.canonical),layoutTextSize:a[`text-size`].possiblyEvaluate(new Fa(t.bucket.zoom+1),t.canonical),textMaxSize:a[`text-size`].possiblyEvaluate(new Fa(18))};if(t.bucket.textSizeData.kind===`composite`){let{minZoom:e,maxZoom:n}=t.bucket.textSizeData;o.compositeTextSizes=[a[`text-size`].possiblyEvaluate(new Fa(e),t.canonical),a[`text-size`].possiblyEvaluate(new Fa(n),t.canonical)]}if(t.bucket.iconSizeData.kind===`composite`){let{minZoom:e,maxZoom:n}=t.bucket.iconSizeData;o.compositeIconSizes=[a[`icon-size`].possiblyEvaluate(new Fa(e),t.canonical),a[`icon-size`].possiblyEvaluate(new Fa(n),t.canonical)]}let s=i.get(`text-line-height`)*bd,c=i.get(`text-rotation-alignment`)!==`viewport`&&i.get(`symbol-placement`)!==`point`,l=i.get(`text-keep-upright`),u=i.get(`text-size`);for(let a of t.bucket.features){let d=i.get(`text-font`).evaluate(a,{},t.canonical).join(`,`),f=u.evaluate(a,{},t.canonical),p=o.layoutTextSize.evaluate(a,{},t.canonical),m=o.layoutIconSize.evaluate(a,{},t.canonical),h={horizontal:{},vertical:void 0},g=a.text,_,v=[0,0];if(g){let n=g.toString(),o=i.get(`text-letter-spacing`).evaluate(a,{},t.canonical)*bd,u=Ta(n)?o:0,m=i.get(`text-anchor`).evaluate(a,{},t.canonical),_=Dh(r,a,t.canonical);if(!_){let e=i.get(`text-radial-offset`).evaluate(a,{},t.canonical);v=e?Eh(m,[e*bd,Th]):i.get(`text-offset`).evaluate(a,{},t.canonical).map((e=>e*bd))}let y=c?`center`:i.get(`text-justify`).evaluate(a,{},t.canonical),b=i.get(`symbol-placement`)===`point`?i.get(`text-max-width`).evaluate(a,{},t.canonical)*bd:1/0,x=()=>{t.bucket.allowVerticalPlacement&&wa(n)&&(h.vertical=Qd(g,t.glyphMap,t.glyphPositions,t.imagePositions,d,b,s,m,`left`,u,v,e.ax.vertical,!0,p,f))};if(!c&&_){let n=new Set;if(y===`auto`)for(let e=0;e<_.values.length;e+=2)n.add(Oh(_.values[e]));else n.add(y);let r=!1;for(let i of n)if(!h.horizontal[i])if(r)h.horizontal[i]=h.horizontal[0];else{let n=Qd(g,t.glyphMap,t.glyphPositions,t.imagePositions,d,b,s,`center`,i,u,v,e.ax.horizontal,!1,p,f);n&&(h.horizontal[i]=n,r=n.positionedLines.length===1)}x()}else{y===`auto`&&(y=Oh(m));let r=Qd(g,t.glyphMap,t.glyphPositions,t.imagePositions,d,b,s,m,y,u,v,e.ax.horizontal,!1,p,f);r&&(h.horizontal[y]=r),x(),wa(n)&&c&&l&&(h.vertical=Qd(g,t.glyphMap,t.glyphPositions,t.imagePositions,d,b,s,m,y,u,v,e.ax.vertical,!1,p,f))}}let y=!1;if(a.icon?.name){let e=t.imageMap[a.icon.name];e&&(_=sf(t.imagePositions[a.icon.name],i.get(`icon-offset`).evaluate(a,{},t.canonical),i.get(`icon-anchor`).evaluate(a,{},t.canonical)),y=!!e.sdf,t.bucket.sdfIcons===void 0?t.bucket.sdfIcons=y:t.bucket.sdfIcons!==y&&fe(`Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer`),(e.pixelRatio!==t.bucket.pixelRatio||i.get(`icon-rotate`).constantOr(1)!==0)&&(t.bucket.iconsNeedLinear=!0))}let b=jh(h.horizontal)||h.vertical;(n=t.bucket).iconsInText||(n.iconsInText=!!b&&b.iconsInText),(b||_)&&kh(t.bucket,a,h,_,t.imageMap,o,p,m,v,y,t.canonical,t.subdivisionGranularity)}t.showCollisionBoxes&&t.bucket.generateCollisionDebugBuffers()},e.cP=Cl,e.cQ=Vl,e.cR=ad,e.cS=function(e,t=``){let n=new Nd;return function(e,t,n=``){for(let r in e.layers)t.writeMessage(3,((e,t)=>Wm(e,t,n)),e.layers[r])}(e,n,t),n.finish()},e.cT=function(e,t,n,r,i,a){let o=th(e,t,n,i,0);return o=th(o,t,r,a,1),o},e.cU=class{constructor(e){this.maxEntries=e,this.map=new Map}get(e){let t=this.map.get(e);return t!==void 0&&(this.map.delete(e),this.map.set(e,t)),t}set(e,t){if(this.map.has(e))this.map.delete(e);else if(this.map.size>=this.maxEntries){let e=this.map.keys().next().value;this.map.delete(e)}this.map.set(e,t)}clear(){this.map.clear()}},e.cV=Ll,e.cW=Nd,e.cX=Vm,e.cY=function(e,n,r,i,a){return t(this,void 0,void 0,(function*(){if(u())try{return yield ve(e,n,r,i,a)}catch{}return function(e,t,n,r,i){let a=e.width,o=e.height;ye&&be||(ye=new OffscreenCanvas(a,o),be=ye.getContext(`2d`,{willReadFrequently:!0})),ye.width=a,ye.height=o,be.drawImage(e,0,0,a,o);let s=be.getImageData(t,n,r,i);return be.clearRect(0,0,a,o),s.data}(e,n,r,i,a)}))},e.cZ=Ic,e.c_=class{constructor(e,t){this.layers={[Um]:this},this.name=Um,this.version=t?t.version:1,this.extent=t?t.extent:4096,this.length=e.length,this.features=e}feature(e){return new Hm(this.features[e],this.extent)}},e.ca=class extends So{},e.cb=_d,e.cc=class extends wo{},e.cd=Dc,e.ce=function(e){return e<=1?1:2**Math.ceil(Math.log(e)/Math.LN2)},e.cf=Ec,e.cg=function(e,t,n){var r=t[0],i=t[1],a=t[2],o=n[3]*r+n[7]*i+n[11]*a+n[15];return e[0]=(n[0]*r+n[4]*i+n[8]*a+n[12])/(o||=1),e[1]=(n[1]*r+n[5]*i+n[9]*a+n[13])/o,e[2]=(n[2]*r+n[6]*i+n[10]*a+n[14])/o,e},e.ch=class extends uo{},e.ci=class extends jo{},e.cj=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]},e.ck=function(e,t){var n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=e[6],l=e[7],u=e[8],f=e[9],p=e[10],m=e[11],h=e[12],g=e[13],_=e[14],v=e[15],y=t[0],b=t[1],x=t[2],S=t[3],C=t[4],w=t[5],T=t[6],E=t[7],D=t[8],O=t[9],k=t[10],A=t[11],ee=t[12],te=t[13],j=t[14],ne=t[15];return Math.abs(n-y)<=d*Math.max(1,Math.abs(n),Math.abs(y))&&Math.abs(r-b)<=d*Math.max(1,Math.abs(r),Math.abs(b))&&Math.abs(i-x)<=d*Math.max(1,Math.abs(i),Math.abs(x))&&Math.abs(a-S)<=d*Math.max(1,Math.abs(a),Math.abs(S))&&Math.abs(o-C)<=d*Math.max(1,Math.abs(o),Math.abs(C))&&Math.abs(s-w)<=d*Math.max(1,Math.abs(s),Math.abs(w))&&Math.abs(c-T)<=d*Math.max(1,Math.abs(c),Math.abs(T))&&Math.abs(l-E)<=d*Math.max(1,Math.abs(l),Math.abs(E))&&Math.abs(u-D)<=d*Math.max(1,Math.abs(u),Math.abs(D))&&Math.abs(f-O)<=d*Math.max(1,Math.abs(f),Math.abs(O))&&Math.abs(p-k)<=d*Math.max(1,Math.abs(p),Math.abs(k))&&Math.abs(m-A)<=d*Math.max(1,Math.abs(m),Math.abs(A))&&Math.abs(h-ee)<=d*Math.max(1,Math.abs(h),Math.abs(ee))&&Math.abs(g-te)<=d*Math.max(1,Math.abs(g),Math.abs(te))&&Math.abs(_-j)<=d*Math.max(1,Math.abs(_),Math.abs(j))&&Math.abs(v-ne)<=d*Math.max(1,Math.abs(v),Math.abs(ne))},e.cl=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},e.cm=e=>e.type===`circle`,e.cn=e=>e.type===`heatmap`,e.co=e=>e.type===`line`,e.cp=e=>e.type===`fill`,e.cq=e=>e.type===`fill-extrusion`,e.cr=e=>e.type===`hillshade`,e.cs=e=>e.type===`color-relief`,e.ct=e=>e.type===`background`,e.cu=e=>e.type===`custom`,e.cv=ne,e.cw=function(e,t,n){if(t<=0)return e;let r=1/t;return n===void 0||Math.abs(n)<1e-10?Math.round(e*r)/r:(n>0?Math.ceil(e*r-1e-9):Math.floor(e*r+1e-10))/r},e.cx=function(e,t,n){let r=D(t.x-n.x,t.y-n.y),i=D(e.x-n.x,e.y-n.y);var a,o;return Ce(Math.atan2(r[0]*i[1]-r[1]*i[0],(a=r)[0]*(o=i)[0]+a[1]*o[1]))},e.cy=re,e.cz=function(e,t){if(!Te[t])return!1;let n=(e?.target)?.ownerDocument?.defaultView||window;return e instanceof n.MouseEvent||e instanceof n.WheelEvent},e.d=A,e.d0=class{constructor(e,t){let n=(t=this.options=Object.assign({},ed,t)).debug;if(n&&console.time(`preprocess data`),t.maxZoom<0||t.maxZoom>24)throw Error(`maxZoom should be in the 0-24 range`);if(t.promoteId&&t.generateId)throw Error(`promoteId and generateId cannot be used together.`);let r=cu(e,t);n&&(console.timeEnd(`preprocess data`),console.log(`index: maxZoom: %d, maxPoints: %d`,t.indexMaxZoom,t.indexMaxPoints),console.time(`generate tiles`)),r=Nu(r,t),t.updateable&&(this.source=r),this.initializeIndex(r,t)}initializeIndex(e,t){this.tileIndex=t.cluster?new Bu(t.clusterOptions):new Qu(t),e.length&&this.tileIndex.initialize(e)}getTile(e,t,n){return t=+t,n=+n,(e=+e)<0||e>24?null:this.tileIndex.getTile(e,t,n)}updateData(e,t){let n=this.options;if(!n.updateable)throw Error("to update tile geojson `updateable` option must be set to true");let{affected:r,source:i}=function(e,t,n){let r=function(e,t){return e?{removeAll:e.removeAll,remove:new Set(e.remove||[]),add:new Map(e.add?.map((e=>[t.promoteId?e.properties[t.promoteId]:e.id,e]))),update:new Map(e.update?.map((e=>[e.id,e])))}:{remove:new Set,add:new Map,update:new Map}}(t,n),i=[];if(r.removeAll&&(i=e,e=[]),r.remove.size||r.add.size){let t=[];for(let n of e)(r.remove.has(n.id)||r.add.has(n.id))&&t.push(n);if(t.length){i.push(...t);let n=new Set(t.map((e=>e.id)));e=e.filter((e=>!n.has(e.id)))}if(r.add.size){let t=cu({type:`FeatureCollection`,features:Array.from(r.add.values())},n);t=Nu(t,n),i.push(...t),e.push(...t)}}if(r.update.size){let t=new Map,a=[];for(let n of e)r.update.has(n.id)?t.set(n.id,[...t.get(n.id)||[],n]):a.push(n);for(let[e,o]of r.update){let r=t.get(e);if(!r||r.length===0)continue;let s=Lu(r,o,n);i.push(...r,...s),a.push(...s)}e=a}return{affected:i,source:e}}(this.source,e,n);t&&({affected:r,source:i}=this.filterUpdate(i,r,t)),r.length&&(this.source=i,this.tileIndex.updateIndex(i,r,n))}filterUpdate(e,t,n){let r=new Set;for(let i of e)i.id!=null&&(n(mu(i))||(t.push(i),r.add(i.id)));return{affected:t,source:e=e.filter((e=>!r.has(e.id)))}}getData(){if(!this.options.updateable)throw Error("to retrieve data the `updateable` option must be set to true");return{type:`FeatureCollection`,features:this.source.map((e=>mu(e)))}}updateClusterOptions(e,t){let n=this.options.cluster;this.options.cluster=e,this.options.clusterOptions=t,n==e?this.tileIndex.updateIndex(this.source,[],this.options):this.initializeIndex(this.source,this.options)}getClusterExpansionZoom(e){return this.tileIndex.getClusterExpansionZoom(e)}getClusterChildren(e){return this.tileIndex.getChildren(e)}getClusterLeaves(e,t,n){return this.tileIndex.getLeaves(e,t,n)}},e.d1=Pa,e.e=oe,e.f=Ie,e.g=je,e.h=e=>t(void 0,void 0,void 0,(function*(){if(e.byteLength===0)return createImageBitmap(new ImageData(1,1));let t=new Blob([new Uint8Array(e)],{type:`image/png`});try{return createImageBitmap(t)}catch(e){throw Error(`Could not load image because of ${A(e).message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})),e.i=me,e.j=e=>new Promise(((t,n)=>{let r=new Image;r.onload=()=>{t(r),URL.revokeObjectURL(r.src),r.onload=null,window.requestAnimationFrame((()=>r.src=_e))},r.onerror=()=>n(Error(`Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`));let i=new Blob([new Uint8Array(e)],{type:`image/png`});r.src=e.byteLength?URL.createObjectURL(i):_e})),e.k=(e,t)=>Fe(oe(e,{type:`json`}),t),e.l=Be,e.m=Fe,e.n=ze,e.o=(e,t)=>Fe(oe(e,{type:`arrayBuffer`}),t),e.p=Jd,e.q=function(e){return new Nd(e).readFields(Gd,[])},e.r=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.s=xe,e.t=Cc,e.u=Xa,e.v=sa,e.w=fe,e.x=M,e.y=Ba,e.z=la})),n(`worker`,[`./shared`],(function(e){class t{constructor(e,t){this.keyCache={},e&&this.replace(e,t)}replace(e,t){this._layerConfigs={},this._layers={},this.update(e,[],t)}update(t,n,r){for(let n of t){this._layerConfigs[n.id]=n;let t=this._layers[n.id]=e.bT(n,r);t._featureFilter=e.ah(t.filter,r),this.keyCache[n.id]&&delete this.keyCache[n.id]}for(let e of n)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};let i=e.cJ(Object.values(this._layerConfigs),this.keyCache);for(let t of i){let n=t.map((e=>this._layers[e.id])),r=n[0];if(r.isHidden())continue;let i=r.source||``,a=this.familiesBySource[i];a||=this.familiesBySource[i]={};let o=r.sourceLayer||e.ag,s=a[o];s||=a[o]=[],s.push(n)}}}class n{constructor(t){let n={},r=[];for(let e in t){let i=t[e],a=n[e]={};for(let e in i){let t=i[+e];if(!t||t.bitmap.width===0||t.bitmap.height===0)continue;let n={x:0,y:0,w:t.bitmap.width+2,h:t.bitmap.height+2};r.push(n),a[e]={rect:n,metrics:t.metrics}}}let{w:i,h:a}=e.p(r),o=new e.t({width:i||1,height:a||1});for(let r in t){let i=t[r];for(let t in i){let a=i[+t];if(!a||a.bitmap.width===0||a.bitmap.height===0)continue;let s=n[r][t].rect;e.t.copy(a.bitmap,o,{x:0,y:0},{x:s.x+1,y:s.y+1},a.bitmap)}}this.image=o,this.positions=n}}e.cK(`GlyphAtlas`,n);class r{constructor(t){this.tileID=new e.a3(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.uid=t.uid,this.zoom=t.zoom,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.inFlightDependencies=[]}parse(t,r,a,o,s){return e._(this,void 0,void 0,(function*(){this.status=`parsing`,this.data=t,this.collisionBoxArray=new e.ae;let c=new e.cL(Object.keys(t.layers).sort()),l=new e.cM(this.tileID,this.promoteId);l.bucketLayerIDs=[];let u={},d={featureIndex:l,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:a,subdivisionGranularity:s},f=r.familiesBySource[this.source];for(let n in f){let r=t.layers[n];if(!r)continue;r.version===1&&e.w(`Vector tile source "${this.source}" layer "${n}" does not use vector tile spec v2 and therefore may have some rendering errors.`);let o=c.encode(n),s=[];for(let e=0;e<r.length;e++){let t=r.feature(e),i=l.getId(t,n);s.push({feature:t,id:i,index:e,sourceLayerIndex:o})}for(let t of f[n]){let n=t[0];n.source!==this.source&&e.w(`layer.source = ${n.source} does not equal this.source = ${this.source}`),n.isHidden(this.zoom,!0)||(i(t,this.zoom,a),(u[n.id]=n.createBucket({index:l.bucketLayerIDs.length,layers:t,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:o,sourceID:this.source})).populate(s,d,this.tileID.canonical),l.bucketLayerIDs.push(t.map((e=>e.id))))}}let p=e.bY(d.glyphDependencies,(e=>Object.keys(e).map(Number)));for(let e of this.inFlightDependencies)e?.abort();this.inFlightDependencies=[];let m=Promise.resolve({});if(Object.keys(p).length){let e=new AbortController;this.inFlightDependencies.push(e),m=o.sendAsync({type:`GG`,data:{stacks:p,source:this.source,tileID:this.tileID,type:`glyphs`}},e)}let h=Object.keys(d.iconDependencies),g=Promise.resolve({});if(h.length){let e=new AbortController;this.inFlightDependencies.push(e),g=o.sendAsync({type:`GI`,data:{icons:h,source:this.source,tileID:this.tileID,type:`icons`}},e)}let _=Object.keys(d.patternDependencies),v=Promise.resolve({});if(_.length){let e=new AbortController;this.inFlightDependencies.push(e),v=o.sendAsync({type:`GI`,data:{icons:_,source:this.source,tileID:this.tileID,type:`patterns`}},e)}let y=d.dashDependencies,b=Promise.resolve({});if(Object.keys(y).length){let e=new AbortController;this.inFlightDependencies.push(e),b=o.sendAsync({type:`GDA`,data:{dashes:y}},e)}let[x,S,C,w]=yield Promise.all([m,g,v,b]),T=new n(x),E=new e.cN(S,C);for(let t in u){let n=u[t];n instanceof e.af?(i(n.layers,this.zoom,a),e.cO({bucket:n,glyphMap:x,glyphPositions:T.positions,imageMap:S,imagePositions:E.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:d.subdivisionGranularity})):n.hasDependencies&&(n instanceof e.cP||n instanceof e.cQ||n instanceof e.cR)&&(i(n.layers,this.zoom,a),n.addFeatures(d,this.tileID.canonical,E.patternPositions,w))}return this.status=`done`,{buckets:Object.values(u).filter((e=>!e.isEmpty())),featureIndex:l,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:T.image,imageAtlas:E,dashPositions:w,glyphMap:this.returnDependencies?x:null,iconMap:this.returnDependencies?S:null,glyphPositions:this.returnDependencies?T.positions:null}}))}}function i(t,n,r){let i=new e.J(n);for(let e of t)e.recalculate(i,r)}class a{constructor(){this.loading={},this.loaded={},this.parsing={}}startLoading(e,t){this.loading[e]=t}finishLoading(e){delete this.loading[e]}abort(e){let t=this.loading[e];t!=null&&t.abort&&(t.abort.abort(),delete this.loading[e])}setParsing(e,t){this.parsing[e]=t}consumeParsing(e){let t=this.parsing[e];if(t)return delete this.parsing[e],t}clearParsing(e){delete this.parsing[e]}markLoaded(e,t){this.loaded[e]=t}getLoaded(e){let t=this.loaded[e];if(t)return t}removeLoaded(e){delete this.loaded[e]}clearLoaded(){this.loaded={}}}class o{constructor(e){this.start=`${e}#start`,this.end=`${e}#end`,this.measure=e,performance.mark(this.start)}finish(){performance.mark(this.end);let e=performance.getEntriesByName(this.measure);return e.length===0&&(performance.measure(this.measure,this.start,this.end),e=performance.getEntriesByName(this.measure),performance.clearMarks(this.start),performance.clearMarks(this.end),performance.clearMeasures(this.measure)),e}}class s{constructor(e,t,n,r,i){this.type=e,this.properties=n||{},this.extent=i,this.pointsArray=t,this.id=r}loadGeometry(){return this.pointsArray.map((t=>t.map((t=>new e.P(t.x,t.y)))))}}class c{constructor(e,t,n){this.version=2,this._myFeatures=e,this.name=t,this.length=e.length,this.extent=n}feature(e){return this._myFeatures[e]}}class l{constructor(){this.layers={}}addLayer(e){this.layers[e.name]=e}}function u(t){let n=e.cS(t);return n.byteOffset===0&&n.byteLength===n.buffer.byteLength||(n=new Uint8Array(n)),{vectorTile:t,rawData:n.buffer}}function d(t,n,r){let{extent:i}=t,a=2**(r.z-n.z),o=(r.x-n.x*a)*i,l=(r.y-n.y*a)*i,u=[];for(let n=0;n<t.length;n++){let r=t.feature(n),c=r.loadGeometry();for(let e of c)for(let t of e)t.x=t.x*a-o,t.y=t.y*a-l;c=e.cT(c,r.type,-128,-128,i+128,i+128),c.length!==0&&u.push(new s(r.type,c,r.properties,r.id,i))}return new c(u,t.name,i)}class f{constructor(t,n,r){this.actor=t,this.layerIndex=n,this.availableImages=r,this.tileState=new a,this.overzoomedTileResultCache=new e.cU(1e3)}loadVectorTile(t,n){try{return{vectorTile:t.encoding===`mlt`?new e.cX(n):new e.cV(new e.cW(n)),rawData:n}}catch(r){let i=new Uint8Array(n),a=`Unable to parse the tile at ${t.request.url}, `;throw a+=i[0]===31&&i[1]===139?`please make sure the data is not gzipped and that you have configured the relevant header in the server`:`got error: ${e.d(r).message}`,Error(a)}}loadTile(t){return e._(this,void 0,void 0,(function*(){let{uid:n,overzoomParameters:i}=t;i&&(t.request=i.overzoomRequest);let a=this._startRequestTiming(t),o=new r(t);this.tileState.startLoading(n,o);let s=new AbortController;o.abort=s;try{let r=yield e.o(t.request,s);if(t.etag&&t.etag===r.etag)return this.tileState.finishLoading(n),this._getEtagUnmodifiedResult(r,a);let c=this.loadVectorTile(t,r.data);if(this.tileState.finishLoading(n),!c)return null;let{vectorTile:l,rawData:u}=c;i&&({vectorTile:l,rawData:u}=this._getOverzoomTile(t,l));let d=this._getExpiryData(r),f=this._finishRequestTiming(a);o.vectorTile=l,this.tileState.markLoaded(n,o);let p={rawData:u,cacheControl:d,resourceTiming:f};this.tileState.setParsing(n,p);try{return yield this._parseWorkerTile(o,t,p)}finally{this.tileState.clearParsing(n)}}catch(e){throw this.tileState.finishLoading(n),o.status=`done`,this.tileState.markLoaded(n,o),e}}))}_getEtagUnmodifiedResult(t,n){let r=this._getExpiryData(t),i=this._finishRequestTiming(n);return e.e({etagUnmodified:!0},r,i)}_parseWorkerTile(t,n,r){return e._(this,void 0,void 0,(function*(){let i=yield t.parse(t.vectorTile,this.layerIndex,this.availableImages,this.actor,n.subdivisionGranularity);if(r){let{rawData:t,cacheControl:a,resourceTiming:o}=r;i=e.e({rawTileData:t.slice(0),encoding:n.encoding},i,a,o)}return i}))}_getExpiryData({expires:e,cacheControl:t,etag:n}){let r={};return e&&(r.expires=e),t&&(r.cacheControl=t),n&&(r.etag=n),r}_startRequestTiming(e){if(e.request?.collectResourceTiming)return new o(e.request.url)}_finishRequestTiming(e){let t=e?.finish();return t?{resourceTiming:JSON.parse(JSON.stringify(t))}:{}}_getOverzoomTile(e,t){let{tileID:n,source:r,overzoomParameters:i}=e,{maxZoomTileID:a}=i,o=`${a.key}_${n.key}_${e.request?.url}`,s=this.overzoomedTileResultCache.get(o);if(s)return s;let c=new l,f=this.layerIndex.familiesBySource[r];for(let e in f){let r=t.layers[e];if(!r)continue;let i=d(r,a,n.canonical);i.length>0&&c.addLayer(i)}let p=u(c);return this.overzoomedTileResultCache.set(o,p),p}reloadTile(t){return e._(this,void 0,void 0,(function*(){let e=t.uid,n=this.tileState.getLoaded(e);if(!n)throw Error(`Should not be trying to reload a tile that was never loaded or has been removed`);if(n.showCollisionBoxes=t.showCollisionBoxes,n.status===`parsing`){let r=this.tileState.consumeParsing(e);return yield this._parseWorkerTile(n,t,r)}if(n.status===`done`&&n.vectorTile)return yield this._parseWorkerTile(n,t)}))}abortTile(t){return e._(this,void 0,void 0,(function*(){this.tileState.abort(t.uid)}))}removeTile(t){return e._(this,void 0,void 0,(function*(){this.tileState.removeLoaded(t.uid)}))}}class p{constructor(){this.loaded={}}loadTile(t){return e._(this,void 0,void 0,(function*(){let{uid:n,encoding:r,rawImageData:i,redFactor:a,greenFactor:o,blueFactor:s,baseShift:c}=t,l=i.width+2,u=i.height+2,d=e.b(i)?new e.R({width:l,height:u},yield e.cY(i,-1,-1,l,u)):i,f=new e.cZ(n,d,r,a,o,s,c);return this.loaded||={},this.loaded[n]=f,f}))}removeTile(e){let t=this.loaded,n=e.uid;t!=null&&t[n]&&delete t[n]}}class m{constructor(e,t,n,r=h){this.actor=e,this.layerIndex=t,this.availableImages=n,this.tileState=new a,this._createGeoJSONIndex=r}loadVectorTile(t){if(!this._geoJSONIndex)throw Error(`Unable to parse the data into a cluster or geojson`);let{z:n,x:r,y:i}=t.tileID.canonical,a=this._geoJSONIndex.getTile(n,r,i);return a?u(new e.c_(a.features,{version:2,extent:e.a6})):null}loadTile(t){return e._(this,void 0,void 0,(function*(){let{uid:e}=t,n=new r(t);n.abort=new AbortController;try{let r=this.loadVectorTile(t);if(!r)return null;let{vectorTile:i,rawData:a}=r;n.vectorTile=i,this.tileState.markLoaded(e,n);let o={rawData:a};this.tileState.setParsing(e,o);try{return yield this._parseWorkerTile(n,t,o)}finally{this.tileState.clearParsing(e)}}catch(t){throw n.status=`done`,this.tileState.markLoaded(e,n),t}}))}_reloadLoadedTile(t){return e._(this,void 0,void 0,(function*(){let e=t.uid,n=this.tileState.getLoaded(e);if(!n)throw Error(`Should not be trying to reload a tile that was never loaded or has been removed`);if(n.showCollisionBoxes=t.showCollisionBoxes,n.status===`parsing`){let r=this.tileState.consumeParsing(e);return yield this._parseWorkerTile(n,t,r)}if(n.status===`done`&&n.vectorTile)return yield this._parseWorkerTile(n,t)}))}_parseWorkerTile(t,n,r){return e._(this,void 0,void 0,(function*(){let i=yield t.parse(t.vectorTile,this.layerIndex,this.availableImages,this.actor,n.subdivisionGranularity);if(r){let{rawData:t}=r;i=e.e({rawTileData:t.slice(0),encoding:`mvt`},i)}return i}))}abortTile(t){return e._(this,void 0,void 0,(function*(){this.tileState.abort(t.uid)}))}removeTile(t){return e._(this,void 0,void 0,(function*(){this.tileState.removeLoaded(t.uid)}))}loadData(t){return e._(this,void 0,void 0,(function*(){var n;(n=this._pendingRequest)==null||n.abort();let r=this._startRequestTiming(t);this._pendingRequest=new AbortController;try{yield this.loadAndProcessGeoJSON(t,this._pendingRequest),delete this._pendingRequest,this.tileState.clearLoaded();let e={};return t.request&&(e.data=t.data),this._finishRequestTiming(r,t,e),e}catch(t){if(delete this._pendingRequest,!e.$(t))throw t;return{abandoned:!0}}}))}_startRequestTiming(e){if(e.request?.collectResourceTiming)return new o(e.request.url)}_finishRequestTiming(e,t,n){let r=e?.finish();r&&(n.resourceTiming={[t.source]:JSON.parse(JSON.stringify(r))})}reloadTile(e){return this.tileState.getLoaded(e.uid)?this._reloadLoadedTile(e):this.loadTile(e)}loadAndProcessGeoJSON(t,n){return e._(this,void 0,void 0,(function*(){if(t.request&&(t.data=(yield e.k(t.request,n)).data),t.data)return t.data=this._filterGeoJSON(t.data,t.filter),void(this._geoJSONIndex=this._createGeoJSONIndex(t.data,t));if(t.dataDiff)return this._geoJSONIndex??=this._createGeoJSONIndex({type:`FeatureCollection`,features:[]},t),void this._geoJSONIndex.updateData(t.dataDiff,this._getFilterPredicate(t.filter));if(t.updateCluster&&this._geoJSONIndex.updateClusterOptions(t.geojsonVtOptions.cluster,g(t)),this._geoJSONIndex==null)throw Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`)}))}_filterGeoJSON(e,t){if(e.type!==`FeatureCollection`)return e;let n=this._getFilterPredicate(t);return n?{type:`FeatureCollection`,features:e.features.filter((e=>n(e)))}:e}_getFilterPredicate(t){if(typeof t!=`boolean`&&!t?.length)return;let n=e.c$(t,{type:`boolean`,"property-type":`data-driven`,overridable:!1,transition:!1});if(n.result===`error`)throw Error(n.value.map((e=>`${e.key}: ${e.message}`)).join(`, `));return e=>n.value.evaluate({zoom:0},e)}removeSource(t){return e._(this,void 0,void 0,(function*(){var e;(e=this._pendingRequest)==null||e.abort()}))}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getClusterChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getClusterLeaves(e.clusterId,e.limit,e.offset)}}function h(t,n){let r=e.e(n.geojsonVtOptions||{},{updateable:!0,clusterOptions:g(n)});return new e.d0(t,r)}function g({geojsonVtOptions:t,clusterProperties:n}){if(!n||!t.clusterOptions)return t.clusterOptions;let r={},i={},a={accumulated:null,zoom:0},o={properties:null},s=Object.keys(n);for(let t of s){let[a,o]=n[t],s=e.c$(o),c=e.c$(typeof a==`string`?[a,[`accumulated`],[`get`,t]]:a);r[t]=s.value,i[t]=c.value}return t.clusterOptions.map=e=>{o.properties=e;let t={};for(let e of s)t[e]=r[e].evaluate(a,o);return t},t.clusterOptions.reduce=(e,t)=>{o.properties=t;for(let t of s)a.accumulated=e[t],e[t]=i[t].evaluate(a,o)},t.clusterOptions}class _{constructor(t){this.self=t,this.actor=new e.N(t),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=new Map,this.self.registerWorkerSource=(e,t)=>{if(this.externalWorkerSourceTypes[e])throw Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=t},this.self.addProtocol=e.cH,this.self.removeProtocol=e.cI,this.self.registerRTLTextPlugin=t=>{e.d1.setMethods(t)},this.self.makeRequest=e.m,this.actor.registerMessageHandler(`LDT`,((e,t)=>this._getDEMWorkerSource(e,t.source).loadTile(t))),this.actor.registerMessageHandler(`RDT`,((t,n)=>e._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(t,n.source).removeTile(n)})))),this.actor.registerMessageHandler(`GCEZ`,((t,n)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,n.type,n.source).getClusterExpansionZoom(n)})))),this.actor.registerMessageHandler(`GCC`,((t,n)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,n.type,n.source).getClusterChildren(n)})))),this.actor.registerMessageHandler(`GCL`,((t,n)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,n.type,n.source).getClusterLeaves(n)})))),this.actor.registerMessageHandler(`LD`,((e,t)=>this._getWorkerSource(e,t.type,t.source).loadData(t))),this.actor.registerMessageHandler(`LT`,((e,t)=>this._getWorkerSource(e,t.type,t.source).loadTile(t))),this.actor.registerMessageHandler(`RT`,((e,t)=>this._getWorkerSource(e,t.type,t.source).reloadTile(t))),this.actor.registerMessageHandler(`AT`,((e,t)=>this._getWorkerSource(e,t.type,t.source).abortTile(t))),this.actor.registerMessageHandler(`RMT`,((e,t)=>this._getWorkerSource(e,t.type,t.source).removeTile(t))),this.actor.registerMessageHandler(`RS`,((t,n)=>e._(this,void 0,void 0,(function*(){if(!this.workerSources[t]?.[n.type]?.[n.source])return;let e=this.workerSources[t][n.type][n.source];delete this.workerSources[t][n.type][n.source],e.removeSource!==void 0&&e.removeSource(n)})))),this.actor.registerMessageHandler(`RM`,(t=>e._(this,void 0,void 0,(function*(){delete this.layerIndexes[t],delete this.availableImages[t],delete this.workerSources[t],delete this.demWorkerSources[t],this.globalStates.delete(t)})))),this.actor.registerMessageHandler(`SR`,((t,n)=>e._(this,void 0,void 0,(function*(){this.referrer=n})))),this.actor.registerMessageHandler(`SRPS`,((e,t)=>this._syncRTLPluginState(e,t))),this.actor.registerMessageHandler(`IS`,((t,n)=>e._(this,void 0,void 0,(function*(){this.self.importScripts(n)})))),this.actor.registerMessageHandler(`SI`,((e,t)=>this._setImages(e,t))),this.actor.registerMessageHandler(`UL`,((t,n)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(t).update(n.layers,n.removedIds,this._getGlobalState(t))})))),this.actor.registerMessageHandler(`UGS`,((t,n)=>e._(this,void 0,void 0,(function*(){let e=this._getGlobalState(t);for(let t in n)e[t]=n[t]})))),this.actor.registerMessageHandler(`SL`,((t,n)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(t).replace(n,this._getGlobalState(t))}))))}_getGlobalState(e){let t=this.globalStates.get(e);return t||(t={},this.globalStates.set(e,t)),t}_setImages(t,n){return e._(this,void 0,void 0,(function*(){this.availableImages[t]=n;for(let e in this.workerSources[t]){let r=this.workerSources[t][e];for(let e in r)r[e].availableImages=n}}))}_syncRTLPluginState(t,n){return e._(this,void 0,void 0,(function*(){return yield e.d1.syncState(n,this.self.importScripts)}))}_getAvailableImages(e){let t=this.availableImages[e];return t||=[],t}_getLayerIndex(e){let n=this.layerIndexes[e];return n||=this.layerIndexes[e]=new t,n}_getWorkerSource(e,t,n){var r,i;if((r=this.workerSources)[e]||(r[e]={}),(i=this.workerSources[e])[t]||(i[t]={}),!this.workerSources[e][t][n]){let r={sendAsync:(t,n)=>(t.targetMapId=e,this.actor.sendAsync(t,n))};switch(t){case`vector`:this.workerSources[e][t][n]=new f(r,this._getLayerIndex(e),this._getAvailableImages(e));break;case`geojson`:this.workerSources[e][t][n]=new m(r,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][t][n]=new this.externalWorkerSourceTypes[t](r,this._getLayerIndex(e),this._getAvailableImages(e))}}return this.workerSources[e][t][n]}_getDEMWorkerSource(e,t){var n,r;return(n=this.demWorkerSources)[e]||(n[e]={}),(r=this.demWorkerSources[e])[t]||(r[t]=new p),this.demWorkerSources[e][t]}}return e.i(self)&&(self.worker=new _(self)),_})),n(`index`,[`exports`,`./shared`],(function(e,t){var n=`5.24.0`;function r(){var e=new t.A(4);return t.A!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let i,a,o,s={frame(e,n,r,i){let a=i||window,o=a.requestAnimationFrame((e=>{s(),n(e)})),{unsubscribe:s}=t.s(e.signal,`abort`,(()=>{s(),a.cancelAnimationFrame(o),r(new t.a(e.signal.reason))}),!1)},frameAsync(e,t){return new Promise(((n,r)=>{this.frame(e,n,r,t)}))},getImageData(e,t=0){return this.getImageCanvasContext(e).getImageData(-t,-t,e.width+2*t,e.height+2*t)},getImageCanvasContext(e){let t=window.document.createElement(`canvas`),n=t.getContext(`2d`,{willReadFrequently:!0});if(!n)throw Error(`failed to create canvas 2d context`);return t.width=e.width,t.height=e.height,n.drawImage(e,0,0,e.width,e.height),n},resolveURL:e=>(i||=document.createElement(`a`),i.href=e,i.href),hardwareConcurrency:typeof navigator<`u`&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return o===void 0?!!matchMedia&&(a??=matchMedia(`(prefers-reduced-motion: reduce)`),a.matches):o},set prefersReducedMotion(e){o=e}},c=new class{constructor(){this._frozenAt=null}getCurrentTime(){return this._frozenAt===null?performance.now():this._frozenAt}setNow(e){this._frozenAt=e}restoreNow(){this._frozenAt=null}isFrozen(){return this._frozenAt!==null}};function l(){return c.getCurrentTime()}var u;class d{static create(e,t,n){let r=window.document.createElement(e);return t!==void 0&&(r.className=t),n&&n.appendChild(r),r}static createNS(e,t){return window.document.createElementNS(e,t)}static disableDrag(){d.docStyle&&d.selectProp&&(d.userSelect=d.docStyle[d.selectProp],d.docStyle[d.selectProp]=`none`)}static enableDrag(){d.docStyle&&d.selectProp&&(d.docStyle[d.selectProp]=d.userSelect)}static suppressClickInternal(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener(`click`,d.suppressClickInternal,!0)}static suppressClick(){window.addEventListener(`click`,d.suppressClickInternal,!0),window.setTimeout((()=>{window.removeEventListener(`click`,d.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,n,r){let i=n.boundingClientRect;return new t.P((r.clientX-i.left)/n.x-e.clientLeft,(r.clientY-i.top)/n.y-e.clientTop)}static mousePos(e,t){let n=d.getScale(e);return d.getPoint(e,n,t)}static touchPos(e,t){let n=[],r=d.getScale(e);for(let i of t)n.push(d.getPoint(e,r,i));return n}static sanitize(e){let t=new DOMParser().parseFromString(e,`text/html`).body||document.createElement(`body`),n=t.querySelectorAll(`script`);for(let e of n)e.remove();return d.clean(t),t.innerHTML}static isPossiblyDangerous(e,t){let n=t.replace(/\s+/g,``).toLowerCase();return!(![`src`,`href`,`xlink:href`].includes(e)||!n.includes(`javascript:`)&&!n.includes(`data:`))||!!e.startsWith(`on`)||void 0}static clean(e){let t=e.children;for(let e of t)d.removeAttributes(e),d.clean(e)}static removeAttributes(e){for(let{name:t,value:n}of e.attributes)d.isPossiblyDangerous(t,n)&&e.removeAttribute(t)}}d.docStyle=typeof window<`u`&&window.document?.documentElement.style,d.selectProp=!d.docStyle||`userSelect`in d.docStyle?`userSelect`:`webkitUserSelect`,function(e){let n,r,i,a;e.resetRequestQueue=()=>{n=[],r=0,i=0,a={}},e.addThrottleControl=e=>{let t=i++;return a[t]=e,t},e.removeThrottleControl=e=>{delete a[e],s()},e.getImage=(e,r,i=!0)=>new Promise(((a,o)=>{e.headers||={},e.headers.accept=`image/webp,*/*`,t.e(e,{type:`image`}),n.push({abortController:r,requestParameters:e,supportImageRefresh:i,state:`queued`,onError:e=>{o(e)},onSuccess:e=>{a(e)}}),s()}));let o=e=>t._(this,void 0,void 0,(function*(){e.state=`running`;let{requestParameters:n,supportImageRefresh:i,onError:a,onSuccess:o,abortController:l}=e,u=!1===i&&!t.i(self)&&!t.g(n.url)&&(!n.headers||Object.keys(n.headers).reduce(((e,t)=>e&&t===`accept`),!0));r++;let d=u?c(n,l):t.m(n,l);try{let n=yield d;delete e.abortController,e.state=`completed`,n.data instanceof HTMLImageElement||t.b(n.data)?o(n):n.data&&o({data:yield(f=n.data,typeof createImageBitmap==`function`?t.h(f):t.j(f)),cacheControl:n.cacheControl,expires:n.expires})}catch(n){delete e.abortController,a(t.d(n))}finally{r--,s()}var f})),s=()=>{let e=(()=>{for(let e of Object.keys(a))if(a[e]())return!0;return!1})()?t.c.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:t.c.MAX_PARALLEL_IMAGE_REQUESTS;for(let t=r;t<e&&n.length>0;t++){let e=n.shift();e.abortController.signal.aborted?t--:o(e)}},c=(e,n)=>new Promise(((r,i)=>{let a=new Image,o=e.url,s=e.credentials;s&&s===`include`?a.crossOrigin=`use-credentials`:(s&&s===`same-origin`||!t.f(o))&&(a.crossOrigin=`anonymous`),n.signal.addEventListener(`abort`,(()=>{a.src=``,i(new t.a(n.signal.reason))})),a.fetchPriority=`high`,a.onload=()=>{a.onerror=a.onload=null,r({data:a})},a.onerror=()=>{a.onerror=a.onload=null,n.signal.aborted||i(Error(`Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))},a.src=o}))}(u||={}),u.resetRequestQueue();class f{constructor(e){this._transformRequestFn=e??null}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function p(e){let t=[];if(typeof e==`string`)t.push({id:`default`,url:e});else if(e&&e.length>0){let n=[];for(let{id:r,url:i}of e){let e=`${r}${i}`;n.includes(e)||(n.push(e),t.push({id:r,url:i}))}}return t}function m(e,t,n){try{let r=new URL(e);return r.pathname+=`${t}${n}`,r.toString()}catch{throw Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function h(e){let{userImage:t}=e;return!(!t?.render||!t.render()||(e.data.replace(new Uint8Array(t.data.buffer)),0))}class g extends t.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.R({width:1,height:1}),this.dirty=!0}destroy(){this.atlasTexture&&=(this.atlasTexture.destroy(),null);for(let e of Object.keys(this.images))this.removeImage(e);this.patterns={},this.atlasImage=new t.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(let{ids:e,promiseResolve:t}of this.requestors)t(this._getImagesForIds(e));this.requestors=[]}}getImage(e){let n=this.images[e];if(n&&!n.data&&n.spriteData){let e=n.spriteData;n.data=new t.R({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),n.spriteData=null}return n}addImage(e,t){if(this.images[e])throw Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,t)&&(this.images[e]=t)}_validate(e,n){let r=!0,i=n.data||n.spriteData;return this._validateStretch(n.stretchX,i?.width)||(this.fire(new t.l(Error(`Image "${e}" has invalid "stretchX" value`))),r=!1),this._validateStretch(n.stretchY,i?.height)||(this.fire(new t.l(Error(`Image "${e}" has invalid "stretchY" value`))),r=!1),this._validateContent(n.content,n)||(this.fire(new t.l(Error(`Image "${e}" has invalid "content" value`))),r=!1),r}_validateStretch(e,t){if(!e)return!0;let n=0;for(let r of e){if(r[0]<n||r[1]<r[0]||t<r[1])return!1;n=r[1]}return!0}_validateContent(e,t){if(!e)return!0;if(e.length!==4)return!1;let n=t.spriteData,r=n?.width||t.data.width,i=n?.height||t.data.height;return!(e[0]<0||r<e[0]||e[1]<0||i<e[1]||e[2]<0||r<e[2]||e[3]<0||i<e[3]||e[2]<e[0]||!(e[3]>=e[1]))}updateImage(e,t,n=!0){let r=this.getImage(e);if(n&&(r.data.width!==t.data.width||r.data.height!==t.data.height))throw Error(`size mismatch between old image (${r.data.width}x${r.data.height}) and new image (${t.data.width}x${t.data.height}).`);t.version=r.version+1,this.images[e]=t,this.updatedImages[e]=!0}removeImage(e){var t;let n=this.images[e];delete this.images[e],delete this.patterns[e],(t=n.userImage)!=null&&t.onRemove&&n.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(e){return new Promise(((t,n)=>{let r=!0;if(!this.isLoaded())for(let t of e)this.images[t]||(r=!1);this.isLoaded()||r?t(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:t})}))}_getImagesForIds(e){let n={};for(let r of e){let e=this.getImage(r);e||=(this.fire(new t.n(`styleimagemissing`,{id:r})),this.getImage(r)),e?n[r]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,textFitWidth:e.textFitWidth,textFitHeight:e.textFitHeight,hasRenderCallback:!!e.userImage?.render}:t.w(`Image "${r}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}return n}getPixelSize(){let{width:e,height:t}=this.atlasImage;return{width:e,height:t}}getPattern(e){let n=this.patterns[e],r=this.getImage(e);if(!r)return null;if(n&&n.position.version===r.version)return n.position;if(n)n.position.version=r.version;else{let n={w:r.data.width+2,h:r.data.height+2,x:0,y:0},i=new t.I(n,r);this.patterns[e]={bin:n,position:i}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){let n=e.gl;this.atlasTexture?this.dirty&&=(this.atlasTexture.update(this.atlasImage),!1):this.atlasTexture=new t.T(e,this.atlasImage,n.RGBA),this.atlasTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}_updatePatternAtlas(){let e=[];for(let t in this.patterns)e.push(this.patterns[t].bin);let{w:n,h:r}=t.p(e),i=this.atlasImage;i.resize({width:n||1,height:r||1});for(let e in this.patterns){let{bin:n}=this.patterns[e],r=n.x+1,a=n.y+1,o=this.getImage(e).data,s=o.width,c=o.height;t.R.copy(o,i,{x:0,y:0},{x:r,y:a},{width:s,height:c}),t.R.copy(o,i,{x:0,y:c-1},{x:r,y:a-1},{width:s,height:1}),t.R.copy(o,i,{x:0,y:0},{x:r,y:a+c},{width:s,height:1}),t.R.copy(o,i,{x:s-1,y:0},{x:r-1,y:a},{width:1,height:c}),t.R.copy(o,i,{x:0,y:0},{x:r+s,y:a},{width:1,height:c})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(let n of e){if(this.callbackDispatchedThisFrame[n])continue;this.callbackDispatchedThisFrame[n]=!0;let e=this.getImage(n);e||t.w(`Image with ID: "${n}" was not found`),h(e)&&this.updateImage(n,e)}}cloneImages(){let e={};for(let t in this.images){let n=this.images[t];e[t]=Object.assign(Object.assign({},n),{data:n.data?n.data.clone():null})}return e}}let _=0x56bc75e2d63100000,v=new Float64Array(256);for(let e=0;e<256;e++){let t=.5-(e/255)**(1/2.2);v[e]=t*Math.abs(t)}function y(e,t,n,r,i,a,o,s,c){for(let l=t;l<t+r;l++)b(e,n*a+l,a,i,o,s,c);for(let l=n;l<n+i;l++)b(e,l*a+t,1,r,o,s,c)}function b(e,t,n,r,i,a,o){a[0]=0,o[0]=-0x56bc75e2d63100000,o[1]=_,i[0]=e[t];for(let s=1,c=0,l=0;s<r;s++){i[s]=e[t+s*n];let r=s*s;do{let e=a[c];l=(i[s]-i[e]+r-e*e)/(s-e)/2}while(l<=o[c]&&--c>-1);c++,a[c]=s,o[c]=l,o[c+1]=_}for(let s=0,c=0;s<r;s++){for(;o[c+1]<s;)c++;let r=a[c],l=s-r;e[t+s*n]=i[r]+l*l}}v[255]=-0x56bc75e2d63100000;let x=t.v.layout_symbol[`text-font`].default.join(`,`);class S{constructor(e,t,n){this.requestManager=e,this.localIdeographFontFamily=t,this.entries={},this.lang=n}setURL(e){this.url=e}getGlyphs(e){return t._(this,void 0,void 0,(function*(){let t=[];for(let n in e)for(let r of e[n])t.push(this._getAndCacheGlyphsPromise(n,r));let n=yield Promise.all(t),r={};for(let{stack:e,id:t,glyph:i}of n)r[e]||(r[e]={}),r[e][t]=i&&{id:i.id,bitmap:i.bitmap.clone(),metrics:i.metrics};return r}))}_getAndCacheGlyphsPromise(e,n){return t._(this,void 0,void 0,(function*(){var t;(t=this.entries)[e]??(t[e]={glyphs:{},requests:{},ranges:{}});let r=this.entries[e],i=r.glyphs[n];return i===void 0?!this.url||this._charUsesLocalIdeographFontFamily(n)?(i=r.glyphs[n]=this._drawGlyph(r,e,n),{stack:e,id:n,glyph:i}):yield this._downloadAndCacheRangePromise(e,n):{stack:e,id:n,glyph:i}}))}_downloadAndCacheRangePromise(e,n){return t._(this,void 0,void 0,(function*(){var r;let i=this.entries[e],a=Math.floor(n/256);if(i.ranges[a])return{stack:e,id:n,glyph:null};(r=i.requests)[a]||(r[a]=S.loadGlyphRange(e,a,this.url,this.requestManager));try{let t=yield i.requests[a];for(let e in t)i.glyphs[+e]=t[+e];return i.ranges[a]=!0,{stack:e,id:n,glyph:t[n]||null}}catch(r){let o=i.glyphs[n]=this._drawGlyph(i,e,n);return this._warnOnMissingGlyphRange(o,a,n,t.d(r)),{stack:e,id:n,glyph:o}}}))}_warnOnMissingGlyphRange(e,n,r,i){let a=256*n,o=a+255,s=r.toString(16).padStart(4,`0`).toUpperCase();t.w(`Unable to load glyph range ${n}, ${a}-${o}. Rendering codepoint U+${s} locally instead. ${i}`)}_charUsesLocalIdeographFontFamily(e){return!!this.localIdeographFontFamily&&t.r(e)}_drawGlyph(e,n,r){let i=n===x&&this.localIdeographFontFamily!==``&&this._charUsesLocalIdeographFontFamily(r),a=i?`ideographTinySDF`:`tinySDF`;e[a]||(e[a]=this._createTinySDF(i?this.localIdeographFontFamily:n));let o=e[a].draw(String.fromCodePoint(r)),s=/^\p{gc=Cf}+$/u.test(String.fromCodePoint(r));return{id:r,bitmap:new t.t({width:o.width||60,height:o.height||60},o.data),metrics:{width:s?0:o.glyphWidth/2||24,height:o.glyphHeight/2||24,left:o.glyphLeft/2+.5||0,top:o.glyphTop/2-27.5||-8,advance:s?0:o.glyphAdvance/2||24,isDoubleResolution:!0}}}_createTinySDF(e){let t=e?e.split(`,`):[];t.push(`sans-serif`);let n=t.map((e=>/[-\w]+/.test(e)?e:`'${CSS.escape(e)}'`)).join(`,`);return new S.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:n,fontWeight:this._fontWeight(t[0]),fontStyle:this._fontStyle(t[0]),lang:this.lang})}_fontStyle(e){return/italic/i.test(e)?`italic`:/oblique/i.test(e)?`oblique`:`normal`}_fontWeight(e){let t={thin:100,hairline:100,"extra light":200,"ultra light":200,light:300,normal:400,regular:400,medium:500,semibold:600,demibold:600,bold:700,"extra bold":800,"ultra bold":800,black:900,heavy:900,"extra black":950,"ultra black":950},n;for(let[r,i]of Object.entries(t))RegExp(`\\b${r}\\b`,`i`).test(e)&&(n=`${i}`);return n}destroy(){for(let e in this.entries){let t=this.entries[e];t.tinySDF=null,t.ideographTinySDF=null,t.glyphs={},t.requests={},t.ranges={}}this.entries={}}}S.loadGlyphRange=function(e,n,r,i){return t._(this,void 0,void 0,(function*(){let a=256*n,o=a+255,s=yield i.transformRequest(r.replace(`{fontstack}`,e).replace(`{range}`,`${a}-${o}`),`Glyphs`),c=yield t.o(s,new AbortController);if(!c?.data)throw Error(`Could not load glyph range. range: ${n}, ${a}-${o}`);let l={};for(let e of t.q(c.data))l[e.id]=e;return l}))},S.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:n=8,cutoff:r=.25,fontFamily:i=`sans-serif`,fontWeight:a=`normal`,fontStyle:o=`normal`,lang:s=null}={}){this.buffer=t,this.radius=n,this.cutoff=r,this.lang=s;let c=this.size=e+4*t,l=this._createCanvas(c),u=this.ctx=l.getContext(`2d`,{willReadFrequently:!0});u.font=`${o} ${a} ${e}px ${i}`,u.textBaseline=`alphabetic`,u.textAlign=`left`,u.fillStyle=`black`,this.gridOuter=new Float64Array(c*c),this.gridInner=new Float64Array(c*c),this.f=new Float64Array(c),this.z=new Float64Array(c+1),this.v=new Uint16Array(c)}_createCanvas(e){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:n,actualBoundingBoxDescent:r,actualBoundingBoxLeft:i,actualBoundingBoxRight:a}=this.ctx.measureText(e),o=Math.ceil(n),s=Math.floor(i),c=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(a)-s)),l=Math.max(0,Math.min(this.size-this.buffer,o+Math.ceil(r))),u=c+2*this.buffer,d=l+2*this.buffer,f=Math.max(u*d,0),p=new Uint8ClampedArray(f),m={data:p,width:u,height:d,glyphWidth:c,glyphHeight:l,glyphTop:o,glyphLeft:s,glyphAdvance:t};if(c===0||l===0)return m;let{ctx:h,buffer:g,gridInner:b,gridOuter:x}=this;this.lang&&(h.lang=this.lang),h.clearRect(g,g,c,l),h.fillText(e,g-s,g+o);let S=h.getImageData(g,g,c,l);x.fill(_,0,f),b.fill(0,0,f);let C=3;for(let e=0;e<l;e++){let t=(e+g)*u+g;for(let e=0;e<c;e++,C+=4,t++){let e=S.data[C];if(e===0)continue;let n=v[e];x[t]=Math.max(0,n),b[t]=Math.max(0,-n)}}y(x,0,0,u,d,u,this.f,this.v,this.z),y(b,g,g,c,l,u,this.f,this.v,this.z);let w=255/this.radius,T=255*(1-this.cutoff);for(let e=0;e<f;e++){let t=Math.sqrt(x[e])-Math.sqrt(b[e]);p[e]=Math.round(T-w*t)}return m}};class C{constructor(){this.specification=t.x.light.position}possiblyEvaluate(e,n){return t.G(e.expression.evaluate(n))}interpolate(e,n,r){return{x:t.H.number(e.x,n.x,r),y:t.H.number(e.y,n.y,r),z:t.H.number(e.z,n.z,r)}}}let w;class T extends t.E{constructor(e){super(),w||=new t.u({anchor:new t.D(t.x.light.anchor),position:new C,color:new t.D(t.x.light.color),intensity:new t.D(t.x.light.intensity)}),this._transitionable=new t.y(w,void 0),this.setLight(e),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,n={}){if(!this._validate(t.z,e,n))for(let n in e){let r=e[n];n.endsWith(t.B)?this._transitionable.setTransition(n.slice(0,-t.B.length),r):this._transitionable.setValue(n,r)}}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,n,r){return!1!==r?.validate&&t.C(this,e.call(t.F,{value:n,style:{glyphs:!0,sprite:!0},styleSpec:t.x}))}}let E=new t.u({"sky-color":new t.D(t.x.sky[`sky-color`]),"horizon-color":new t.D(t.x.sky[`horizon-color`]),"fog-color":new t.D(t.x.sky[`fog-color`]),"fog-ground-blend":new t.D(t.x.sky[`fog-ground-blend`]),"horizon-fog-blend":new t.D(t.x.sky[`horizon-fog-blend`]),"sky-horizon-blend":new t.D(t.x.sky[`sky-horizon-blend`]),"atmosphere-blend":new t.D(t.x.sky[`atmosphere-blend`])});class D extends t.E{constructor(e){super(),this._transitionable=new t.y(E,void 0),this.setSky(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new t.J(0))}setSky(e,n={}){if(!this._validate(t.K,e,n)){e||={"sky-color":`transparent`,"horizon-color":`transparent`,"fog-color":`transparent`,"fog-ground-blend":1,"atmosphere-blend":0};for(let n in e){let r=e[n];n.endsWith(t.B)?this._transitionable.setTransition(n.slice(0,-t.B.length),r):this._transitionable.setValue(n,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,n,r={}){return!1!==r?.validate&&t.C(this,e.call(t.F,t.e({value:n,style:{glyphs:!0,sprite:!0},styleSpec:t.x})))}calculateFogBlendOpacity(e){return e<60?0:e<70?(e-60)/10:1}}class O{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){var n;let r=e.join(`,`)+String(t);return(n=this.dashEntry)[r]||(n[r]=this.addDash(e,t)),this.dashEntry[r]}getDashRanges(e,t,n){let r=[],i=e.length%2==1?-e[e.length-1]*n:0,a=e[0]*n,o=!0;r.push({left:i,right:a,isDash:o,zeroLength:e[0]===0});let s=e[0];for(let t=1;t<e.length;t++){o=!o;let c=e[t];i=s*n,s+=c,a=s*n,r.push({left:i,right:a,isDash:o,zeroLength:c===0})}return r}addRoundDash(e,t,n){let r=t/2;for(let t=-n;t<=n;t++){let i=this.width*(this.nextRow+n+t),a=0,o=e[a];for(let s=0;s<this.width;s++){s/o.right>1&&(o=e[++a]);let c=Math.abs(s-o.left),l=Math.abs(s-o.right),u=Math.min(c,l),d,f=t/n*(r+1);if(o.isDash){let e=r-Math.abs(f);d=Math.sqrt(u*u+e*e)}else d=r-Math.sqrt(u*u+f*f);this.data[i+s]=Math.max(0,Math.min(255,d+128))}}}addRegularDash(e){for(let t=e.length-1;t>=0;--t){let n=e[t],r=e[t+1];n.zeroLength?e.splice(t,1):r&&r.isDash===n.isDash&&(r.left=n.left,e.splice(t,1))}let t=e[0],n=e[e.length-1];t.isDash===n.isDash&&(t.left=n.left-this.width,n.right=t.right+this.width);let r=this.width*this.nextRow,i=0,a=e[i];for(let t=0;t<this.width;t++){t/a.right>1&&(a=e[++i]);let n=Math.abs(t-a.left),o=Math.abs(t-a.right),s=Math.min(n,o);this.data[r+t]=Math.max(0,Math.min(255,(a.isDash?s:-s)+128))}}addDash(e,n){let r=n?7:0,i=2*r+1;if(this.nextRow+i>this.height)return t.w(`LineAtlas out of space`),null;let a=0;for(let t of e)a+=t;if(a!==0){let t=this.width/a,i=this.getDashRanges(e,this.width,t);n?this.addRoundDash(i,t,r):this.addRegularDash(i)}let o={y:this.nextRow+r,height:2*r,width:a};return this.nextRow+=i,this.dirty=!0,o}bind(e){let t=e.gl;this.texture?(t.bindTexture(t.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,t.texSubImage2D(t.TEXTURE_2D,0,0,0,this.width,this.height,t.ALPHA,t.UNSIGNED_BYTE,this.data))):(this.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texImage2D(t.TEXTURE_2D,0,t.ALPHA,this.width,this.height,0,t.ALPHA,t.UNSIGNED_BYTE,this.data))}}let k=`maplibre_preloaded_worker_pool`;class A{constructor(){this.active={}}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length<A.workerCount;)this.workers.push(new Worker(t.c.WORKER_URL));return this.active[e]=!0,this.workers.slice()}release(e){if(delete this.active[e],this.numActive()===0){for(let e of this.workers)e.terminate();this.workers=null}}isPreloaded(){return!!this.active[k]}numActive(){return Object.keys(this.active).length}}let ee=Math.floor(s.hardwareConcurrency/2),te,j;function ne(){return te||=new A,te}A.workerCount=t.L(globalThis)?Math.max(Math.min(ee,3),1):1;class re{constructor(e,n){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=n;let r=this.workerPool.acquire(n);for(let e=0;e<r.length;e++){let i=new t.N(r[e],n);i.name=`Worker ${e}`,this.actors.push(i)}if(!this.actors.length)throw Error(`No actors found`)}broadcast(e,t){let n=[];for(let r of this.actors)n.push(r.sendAsync({type:e,data:t}));return Promise.all(n)}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(e=!0){for(let e of this.actors)e.remove();this.actors=[],e&&this.workerPool.release(this.id)}registerMessageHandler(e,t){for(let n of this.actors)n.registerMessageHandler(e,t)}unregisterMessageHandler(e){for(let t of this.actors)t.unregisterMessageHandler(e)}}function ie(){return j||(j=new re(ne(),t.M),j.registerMessageHandler(`GR`,((e,n,r)=>t.m(n,r)))),j}function ae(e,n){let r=t.O();return t.Q(r,r,[1,1,0]),t.S(r,r,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?t.U(r,r,e.calculatePosMatrix(n.toUnwrapped())):r}function oe(e,t,n,r,i,a,o){let s=function(e,t,n){if(e)for(let r of e){let e=t[r];if(e?.source===n&&e.type===`fill-extrusion`)return!0}else for(let e in t){let r=t[e];if(r.source===n&&r.type===`fill-extrusion`)return!0}return!1}(i?.layers??null,t,e.id),c=a.maxPitchScaleFactor(),l=e.tilesIn(r,c,s);l.sort(se);let u=[];for(let r of l)u.push({wrappedTileID:r.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(t,n,e.getState(),r.queryGeometry,r.cameraQueryGeometry,r.scale,i,a,c,ae(a,r.tileID),o?(e,t)=>o(r.tileID,e,t):void 0)});return function(e,t){for(let n in e)for(let r of e[n])ce(r,t);return e}(function(e){let t={},n={};for(let{queryResults:r,wrappedTileID:i}of e){n[i]||(n[i]={});let e=n[i];for(let n in r){let i=r[n];e[n]||(e[n]={});let a=e[n];t[n]||(t[n]=[]);for(let e of i)a[e.featureIndex]||(a[e.featureIndex]=!0,t[n].push(e))}}return t}(u),e)}function se(e,t){let n=e.tileID,r=t.tileID;return n.overscaledZ-r.overscaledZ||n.canonical.y-r.canonical.y||n.wrap-r.wrap||n.canonical.x-r.canonical.x}function ce(e,t){let n=e.feature,r=t.getFeatureState(n.layer[`source-layer`],n.id);n.source=n.layer.source,n.layer[`source-layer`]&&(n.sourceLayer=n.layer[`source-layer`]),n.state=r}function le(e,n,r,i){return t._(this,void 0,void 0,(function*(){let a=e;if(e.url?a=(yield t.k(yield n.transformRequest(e.url,`Source`),r)).data:yield s.frameAsync(r,i),!a)return null;let o=t.V(t.e(a,e),[`tiles`,`minzoom`,`maxzoom`,`attribution`,`bounds`,`scheme`,`tileSize`,`encoding`]);return`vector_layers`in a&&a.vector_layers&&(o.vectorLayerIds=a.vector_layers.map((e=>e.id))),o}))}class ue{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):Array.isArray(e)&&(e.length===4?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1])))}setNorthEast(e){return this._ne=e instanceof t.W?new t.W(e.lng,e.lat):t.W.convert(e),this}setSouthWest(e){return this._sw=e instanceof t.W?new t.W(e.lng,e.lat):t.W.convert(e),this}extend(e){let n=this._sw,r=this._ne,i,a;if(e instanceof t.W)i=e,a=e;else{if(!(e instanceof ue))return Array.isArray(e)?e.length===4||e.every(Array.isArray)?this.extend(ue.convert(e)):this.extend(t.W.convert(e)):e&&(`lng`in e||`lon`in e)&&`lat`in e?this.extend(t.W.convert(e)):this;if(i=e._sw,a=e._ne,!i||!a)return this}return n||r?(n.lng=Math.min(i.lng,n.lng),n.lat=Math.min(i.lat,n.lat),r.lng=Math.max(a.lng,r.lng),r.lat=Math.max(a.lat,r.lat)):(this._sw=new t.W(i.lng,i.lat),this._ne=new t.W(a.lng,a.lat)),this}getCenter(){return new t.W((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new t.W(this.getWest(),this.getNorth())}getSouthEast(){return new t.W(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(e){let{lng:n,lat:r}=t.W.convert(e),i=this._sw.lng<=n&&n<=this._ne.lng;return this._sw.lng>this._ne.lng&&(i=this._sw.lng>=n&&n>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&i}intersects(e){if(!((e=ue.convert(e)).getNorth()>=this.getSouth()&&e.getSouth()<=this.getNorth()))return!1;let n=Math.abs(this.getEast()-this.getWest()),r=Math.abs(e.getEast()-e.getWest());if(n>=360||r>=360)return!0;let i=t.X(this.getWest(),-180,180),a=t.X(this.getEast(),-180,180),o=t.X(e.getWest(),-180,180),s=t.X(e.getEast(),-180,180),c=i>a,l=o>s;return!(!c||!l)||(c?s>=i||o<=a:l?a>=o||i<=s:o<=a&&s>=i)}static convert(e){return e instanceof ue?e:e&&new ue(e)}static fromLngLat(e,n=0){let r=360*n/40075017,i=r/Math.cos(Math.PI/180*e.lat);return new ue(new t.W(e.lng-i,e.lat-r),new t.W(e.lng+i,e.lat+r))}adjustAntiMeridian(){let e=new t.W(this._sw.lng,this._sw.lat),n=new t.W(this._ne.lng,this._ne.lat);return new ue(e,e.lng>n.lng?new t.W(n.lng+360,n.lat):n)}}class de{constructor(e,t,n){this.bounds=ue.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=n||24}validateBounds(e){return Array.isArray(e)&&e.length===4?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){let n=2**e.z,r=Math.floor(t.Z(this.bounds.getWest())*n),i=Math.floor(t.Y(this.bounds.getNorth())*n),a=Math.ceil(t.Z(this.bounds.getEast())*n),o=Math.ceil(t.Y(this.bounds.getSouth())*n);return e.x>=r&&e.x<a&&e.y>=i&&e.y<o}}class fe extends t.E{constructor(e,n,r,i){if(super(),this.id=e,this.dispatcher=r,this.type=`vector`,this.minzoom=0,this.maxzoom=22,this.scheme=`xyz`,this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,t.e(this,t.V(n,[`url`,`scheme`,`tileSize`,`promoteId`,`encoding`])),this._options=t.e({type:`vector`},n),this._collectResourceTiming=n.collectResourceTiming,this.tileSize!==512)throw Error(`vector tile sources must have a tileSize of 512`);this.setEventedParent(i)}load(){return t._(this,arguments,void 0,(function*(e=!1){this._loaded=!1,this.fire(new t.n(`dataloading`,{dataType:`source`})),this._tileJSONRequest=new AbortController;try{let n=yield le(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,n&&(t.e(this,n),n.bounds&&(this.tileBounds=new de(n.bounds,this.minzoom,this.maxzoom)),this.fire(new t.n(`data`,{dataType:`source`,sourceDataType:`metadata`})),this.fire(new t.n(`data`,{dataType:`source`,sourceDataType:`content`,sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,t.$(e)||this.fire(new t.l(t.d(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._options.tiles=e})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e})),this}onRemove(){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null)}serialize(){return t.e({},this._options)}loadTile(e){return t._(this,void 0,void 0,(function*(){let t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),n={request:yield 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:yield this._getOverzoomParameters(e),etag:e.etag};n.request.collectResourceTiming=this._collectResourceTiming;let r=`RT`;if(e.actor&&e.state!==`expired`){if(e.state===`loading`)return new Promise(((t,n)=>{e.reloadPromise={resolve:t,reject:n}}))}else e.actor=this.dispatcher.getActor(),r=`LT`;e.abortController=new AbortController;try{let t=yield e.actor.sendAsync({type:r,data:n},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,t);let i={};return t!=null&&t.etagUnmodified&&(i.unmodified=!0),i}catch(t){if(delete e.abortController,e.aborted)return;if(t&&t.status!==404)throw t;this._afterTileLoadWorkerResponse(e,null)}}))}_getOverzoomParameters(e){return t._(this,void 0,void 0,(function*(){if(e.tileID.canonical.z<=this.maxzoom||this.map._zoomLevelsToOverscale===void 0)return;let t=e.tileID.scaledTo(this.maxzoom).canonical,n=t.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:t,overzoomRequest:yield this.map._requestManager.transformRequest(n,`Tile`)}}))}_afterTileLoadWorkerResponse(e,t){if(t!=null&&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)}}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&(yield e.actor.sendAsync({type:`AT`,data:{uid:e.uid,type:this.type,source:this.id}}))}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.unloadVectorData(),e.actor&&(yield e.actor.sendAsync({type:`RMT`,data:{uid:e.uid,type:this.type,source:this.id}}))}))}hasTransition(){return!1}}class pe extends t.E{constructor(e,n,r,i){super(),this.id=e,this.dispatcher=r,this.setEventedParent(i),this.type=`raster`,this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme=`xyz`,this.tileSize=512,this._loaded=!1,this._options=t.e({type:`raster`},n),t.e(this,t.V(n,[`url`,`scheme`,`tileSize`]))}load(){return t._(this,arguments,void 0,(function*(e=!1){this._loaded=!1,this.fire(new t.n(`dataloading`,{dataType:`source`})),this._tileJSONRequest=new AbortController;try{let n=yield le(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,n&&(t.e(this,n),n.bounds&&(this.tileBounds=new de(n.bounds,this.minzoom,this.maxzoom)),this.fire(new t.n(`data`,{dataType:`source`,sourceDataType:`metadata`})),this.fire(new t.n(`data`,{dataType:`source`,sourceDataType:`content`,sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,t.$(e)||this.fire(new t.l(t.d(e)))}}))}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null)}setSourceProperty(e){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null),e(),this.load(!0)}setTiles(e){return this.setSourceProperty((()=>{this._options.tiles=e})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e})),this}serialize(){return t.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return t._(this,void 0,void 0,(function*(){let n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{let r=yield u.getImage(yield this.map._requestManager.transformRequest(n,`Tile`),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state=`unloaded`);if(r?.data){this.map._refreshExpiredTiles&&(r.cacheControl||r.expires)&&e.setExpiryData({cacheControl:r.cacheControl,expires:r.expires});let n=this.map.painter.context,i=n.gl,a=r.data;e.texture=this.map.painter.getTileTexture(a.width),e.texture?e.texture.update(a,{useMipmap:!0}):(e.texture=new t.T(n,a,i.RGBA,{useMipmap:!0}),e.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE,i.LINEAR_MIPMAP_NEAREST)),e.state=`loaded`}}catch(t){if(delete e.abortController,e.aborted)e.state=`unloaded`;else if(t)throw e.state=`errored`,t}}))}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)}))}hasTransition(){return!1}}class me extends pe{constructor(e,n,r,i){super(e,n,r,i),this.type=`raster-dem`,this.maxzoom=22,this._options=t.e({type:`raster-dem`},n),this.encoding=n.encoding||`mapbox`,this.redFactor=n.redFactor,this.greenFactor=n.greenFactor,this.blueFactor=n.blueFactor,this.baseShift=n.baseShift}loadTile(e){return t._(this,void 0,void 0,(function*(){let n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r=yield this.map._requestManager.transformRequest(n,`Tile`);e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{let n=yield u.getImage(r,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state=`unloaded`);if(n?.data){let r=n.data;this.map._refreshExpiredTiles&&(n.cacheControl||n.expires)&&e.setExpiryData({cacheControl:n.cacheControl,expires:n.expires});let i=t.b(r)&&t.a0()?r:yield this.readImageNow(r),a={type:this.type,uid:e.uid,source:this.id,rawImageData:i,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(e.actor&&e.state!==`expired`&&e.state!==`reloading`)return;e.actor&&e.state!==`expired`||(e.actor=this.dispatcher.getActor()),e.dem=yield e.actor.sendAsync({type:`LDT`,data:a}),e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state=`loaded`}}catch(t){if(delete e.abortController,e.aborted)e.state=`unloaded`;else if(t)throw e.state=`errored`,t}}))}readImageNow(e){return t._(this,void 0,void 0,(function*(){if(typeof VideoFrame<`u`&&t.a1()){let n=e.width+2,r=e.height+2;try{return new t.R({width:n,height:r},yield t.a2(e,-1,-1,n,r))}catch{}}return s.getImageData(e,1)}))}_getNeighboringTiles(e){let n=e.canonical,r=2**n.z,i=(n.x-1+r)%r,a=n.x===0?e.wrap-1:e.wrap,o=(n.x+1+r)%r,s=n.x+1===r?e.wrap+1:e.wrap,c={};return c[new t.a3(e.overscaledZ,a,n.z,i,n.y).key]={backfilled:!1},c[new t.a3(e.overscaledZ,s,n.z,o,n.y).key]={backfilled:!1},n.y>0&&(c[new t.a3(e.overscaledZ,a,n.z,i,n.y-1).key]={backfilled:!1},c[new t.a3(e.overscaledZ,e.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},c[new t.a3(e.overscaledZ,s,n.z,o,n.y-1).key]={backfilled:!1}),n.y+1<r&&(c[new t.a3(e.overscaledZ,a,n.z,i,n.y+1).key]={backfilled:!1},c[new t.a3(e.overscaledZ,e.wrap,n.z,n.x,n.y+1).key]={backfilled:!1},c[new t.a3(e.overscaledZ,s,n.z,o,n.y+1).key]={backfilled:!1}),c}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.demTexture&&this.map.painter.saveTileTexture(e.demTexture),e.fbo&&(e.fbo.destroy(),delete e.fbo),e.dem&&delete e.dem,delete e.neighboringTiles,e.state=`unloaded`,e.actor&&(yield e.actor.sendAsync({type:`RDT`,data:{type:this.type,uid:e.uid,source:this.id}}))}))}}function he(e,t){return t?e.properties[t]:e.id}function ge(e,t){let n={id:e.id};if(t.removeAllProperties&&(delete e.removeProperties,delete e.addOrUpdateProperties,delete t.removeProperties),t.removeProperties)for(let n of t.removeProperties){let t=e.addOrUpdateProperties.findIndex((e=>e.key===n));t>-1&&e.addOrUpdateProperties.splice(t,1)}return(e.removeAllProperties||t.removeAllProperties)&&(n.removeAllProperties=!0),(e.removeProperties||t.removeProperties)&&(n.removeProperties=[...e.removeProperties||[],...t.removeProperties||[]]),(e.addOrUpdateProperties||t.addOrUpdateProperties)&&(n.addOrUpdateProperties=[...e.addOrUpdateProperties||[],...t.addOrUpdateProperties||[]]),(e.newGeometry||t.newGeometry)&&(n.newGeometry=t.newGeometry||e.newGeometry),n}function _e(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 ve(e){return e&&e.length!==0?typeof e[0]==`number`?[e]:e.flatMap((e=>ve(e))):[]}function ye(e){return e.type===`GeometryCollection`?e.geometries.flatMap((e=>ye(e))):ve(e.coordinates)}function be(e){let t=new ue,n;switch(e.type){case`FeatureCollection`:n=e.features.flatMap((e=>ye(e.geometry)));break;case`Feature`:n=ye(e.geometry);break;default:n=ye(e)}if(n.length===0)return t;for(let e of n){let[n,r]=e;t.extend([n,r])}return t}class xe extends t.E{constructor(e,n,r,i){super(),this.id=e,this.type=`geojson`,this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._isUpdatingWorker=!1,this._pendingWorkerUpdate={data:n.data},this.actor=r.getActor(),this.setEventedParent(i),this._data=typeof n.data==`string`?{url:n.data}:{geojson:n.data},this._options=t.e({},n),this._collectResourceTiming=n.collectResourceTiming,n.maxzoom!==void 0&&(this.maxzoom=n.maxzoom),n.type&&(this.type=n.type),n.attribution&&(this.attribution=n.attribution),this.promoteId=n.promoteId,n.clusterMaxZoom!==void 0&&this.maxzoom<=n.clusterMaxZoom&&t.w(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${n.clusterMaxZoom}".`),this.workerOptions=t.e({source:this.id,geojsonVtOptions:{buffer:this._pixelsToTileUnits(n.buffer===void 0?128:n.buffer),tolerance:this._pixelsToTileUnits(n.tolerance===void 0?.375:n.tolerance),extent:t.a6,maxZoom:this.maxzoom,lineMetrics:n.lineMetrics||!1,generateId:n.generateId||!1,promoteId:typeof n.promoteId==`string`?n.promoteId:void 0,cluster:n.cluster||!1,clusterOptions:{maxZoom:this._getClusterMaxZoom(n.clusterMaxZoom),minPoints:Math.max(2,n.clusterMinPoints||2),extent:t.a6,radius:this._pixelsToTileUnits(n.clusterRadius||50),log:!1,generateId:n.generateId||!1}},clusterProperties:n.clusterProperties,filter:n.filter},n.workerOptions)}_hasPendingWorkerUpdate(){return this._pendingWorkerUpdate.data!==void 0||this._pendingWorkerUpdate.diff!==void 0||this._pendingWorkerUpdate.updateCluster}_pixelsToTileUnits(e){return e*(t.a6/this.tileSize)}_getClusterMaxZoom(e){let n=e?Math.round(e):this.maxzoom-1;return Number.isInteger(e)||e===void 0||t.w(`Integer expected for option 'clusterMaxZoom': provided value "${e}" rounded to "${n}"`),n}load(){return t._(this,void 0,void 0,(function*(){yield this._updateWorkerData()}))}onAdd(e){this.map=e,this.load()}setData(e,t){this._data=typeof e==`string`?{url:e}:{geojson:e},this._pendingWorkerUpdate={data:e};let n=this._updateWorkerData();return t?n:this}updateData(e,t){this._pendingWorkerUpdate.diff=function(e,t){if(!e)return t||{};if(!t)return e||{};let n=_e(e),r=_e(t);(function(e,t){t.removeAll&&(e.add.clear(),e.update.clear(),e.remove.clear(),t.remove.clear());for(let n of t.remove)e.add.delete(n),e.update.delete(n);for(let[n,r]of t.update){let i=e.update.get(n);i&&(t.update.set(n,ge(i,r)),e.update.delete(n))}})(n,r);let i={};if((n.removeAll||r.removeAll)&&(i.removeAll=!0),i.remove=new Set([...n.remove,...r.remove]),i.add=new Map([...n.add,...r.add]),i.update=new Map([...n.update,...r.update]),i.remove.size&&i.add.size)for(let e of i.add.keys())i.remove.delete(e);return 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}(i)}(this._pendingWorkerUpdate.diff,e);let n=this._updateWorkerData();return t?n:this}getData(){return t._(this,void 0,void 0,(function*(){return this._data.url&&(yield this.once(`data`)),this._data.geojson?this._data.geojson:{type:`FeatureCollection`,features:Array.from(this._data.updateable.values())}}))}getBounds(){return t._(this,void 0,void 0,(function*(){return be(yield this.getData())}))}setClusterOptions(e){return this.workerOptions.geojsonVtOptions.cluster=e.cluster,e.clusterRadius!==void 0&&(this.workerOptions.geojsonVtOptions.clusterOptions.radius=this._pixelsToTileUnits(e.clusterRadius)),e.clusterMaxZoom!==void 0&&(this.workerOptions.geojsonVtOptions.clusterOptions.maxZoom=this._getClusterMaxZoom(e.clusterMaxZoom)),this._pendingWorkerUpdate.updateCluster=!0,this._updateWorkerData(),this}getClusterExpansionZoom(e){return this.actor.sendAsync({type:`GCEZ`,data:{type:this.type,clusterId:e,source:this.id}})}getClusterChildren(e){return this.actor.sendAsync({type:`GCC`,data:{type:this.type,clusterId:e,source:this.id}})}getClusterLeaves(e,t,n){return this.actor.sendAsync({type:`GCL`,data:{type:this.type,source:this.id,clusterId:e,limit:t,offset:n}})}_updateWorkerData(){return t._(this,void 0,void 0,(function*(){if(this._isUpdatingWorker)return;if(!this._hasPendingWorkerUpdate())return void t.w(`No pending worker updates for GeoJSONSource ${this.id}.`);let{data:e,diff:n,updateCluster:r}=this._pendingWorkerUpdate,i=this._getLoadGeoJSONParameters(e,n,r);e===void 0?n?this._pendingWorkerUpdate.diff=void 0:r&&(this._pendingWorkerUpdate.updateCluster=void 0):this._pendingWorkerUpdate.data=void 0,yield this._dispatchWorkerUpdate(i)}))}_getLoadGeoJSONParameters(e,n,r){return t._(this,void 0,void 0,(function*(){let i=t.e({type:this.type},this.workerOptions);return typeof e==`string`?(i.request=yield this.map._requestManager.transformRequest(s.resolveURL(e),`Source`),i.request.collectResourceTiming=this._collectResourceTiming,i):e===void 0?n?(i.dataDiff=n,i):r?(i.updateCluster=!0,i):void 0:(i.data=e,i)}))}_dispatchWorkerUpdate(e){return t._(this,void 0,void 0,(function*(){this._isUpdatingWorker=!0,this.fire(new t.n(`dataloading`,{dataType:`source`}));try{let n=yield e,r=yield this.actor.sendAsync({type:`LD`,data:n});if(this._isUpdatingWorker=!1,this._removed||r.abandoned)return void this.fire(new t.n(`dataabort`,{dataType:`source`}));r.data&&(this._data={geojson:r.data});let i=this._applyDiffToSource(n.dataDiff),a=this._getShouldReloadTileOptions(i),o={dataType:`source`};this._applyResourceTiming(o,r),this.fire(new t.n(`data`,Object.assign(Object.assign({},o),{sourceDataType:`metadata`}))),this.fire(new t.n(`data`,Object.assign(Object.assign({},o),{sourceDataType:`content`,shouldReloadTileOptions:a})))}catch(e){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new t.n(`dataabort`,{dataType:`source`}));this.fire(new t.l(t.d(e)))}finally{this._hasPendingWorkerUpdate()&&this._updateWorkerData()}}))}_applyResourceTiming(e,n){if(!this._collectResourceTiming)return;let r=n.resourceTiming?.[this.id];if(!r)return;let i=r.slice(0);i!=null&&i.length&&t.e(e,{resourceTiming:i})}_applyDiffToSource(e){if(!e)return;let t=typeof this.promoteId==`string`?this.promoteId:void 0;if(!this._data.url&&!this._data.updateable){let e=function(e,t){let n=new Map;if(e==null||e.type==null)return n;if(e.type===`Feature`){let r=he(e,t);return r==null?void 0:(n.set(r,e),n)}if(e.type===`FeatureCollection`){let r=new Set;for(let i of e.features){let e=he(i,t);if(e==null||r.has(e))return;r.add(e),n.set(e,i)}return n}}(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 n=function(e,t,n){let r=[];if(t.removeAll)e.clear();else if(t.remove)for(let n of t.remove){let t=e.get(n);t&&(r.push(t.geometry),e.delete(n))}if(t.add)for(let i of t.add){let t=he(i,n);if(t==null)continue;let a=e.get(t);a&&r.push(a.geometry),r.push(i.geometry),e.set(t,i)}if(t.update)for(let n of t.update){let t=e.get(n.id);if(!t)continue;let i=!!n.newGeometry,a=n.removeAllProperties||n.removeProperties?.length>0||n.addOrUpdateProperties?.length>0;if(!i&&!a)continue;r.push(t.geometry);let o=Object.assign({},t);if(e.set(n.id,o),i&&(r.push(n.newGeometry),o.geometry=n.newGeometry),a){if(o.properties=n.removeAllProperties?{}:Object.assign({},o.properties||{}),n.removeProperties)for(let e of n.removeProperties)delete o.properties[e];if(n.addOrUpdateProperties)for(let{key:e,value:t}of n.addOrUpdateProperties)o.properties[e]=t}}return r}(this._data.updateable,e,t);return e.removeAll||this._options.cluster?void 0:n}_getShouldReloadTileOptions(e){if(e)return{affectedBounds:e.filter(Boolean).map((e=>be(e)))}}shouldReloadTile(e,{affectedBounds:n}){if(e.state===`loading`)return!0;if(e.state===`unloaded`)return!1;let{buffer:r,extent:i}=this.workerOptions.geojsonVtOptions,a=function({x:e,y:n,z:r},i=0){let a=t.a4((e-i)/2**r),o=t.a5((n+1+i)/2**r),s=t.a4((e+1+i)/2**r),c=t.a5((n-i)/2**r);return new ue([a,o],[s,c])}(e.tileID.canonical,r/i);for(let e of n)if(a.intersects(e))return!0;return!1}loaded(){return!this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}loadTile(e){return t._(this,void 0,void 0,(function*(){let t=e.actor?`RT`:`LT`;e.actor=this.actor;let n={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};e.abortController=new AbortController;let r=yield this.actor.sendAsync({type:t,data:n},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(r,this.map.painter,t===`RT`)}))}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.unloadVectorData(),yield this.actor.sendAsync({type:`RMT`,data:{uid:e.uid,type:this.type,source:this.id}})}))}onRemove(){this._removed=!0,this.actor.sendAsync({type:`RS`,data:{type:this.type,source:this.id}})}serialize(){return t.e({},this._options,{type:this.type,data:this._data.updateable?{type:`FeatureCollection`,features:Array.from(this._data.updateable.values())}:this._data.url||this._data.geojson})}hasTransition(){return!1}}class Se extends t.E{constructor(e,t,n,r){super(),this.flippedWindingOrder=!1,this.id=e,this.dispatcher=n,this.coordinates=t.coordinates,this.type=`image`,this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=t}load(e){return t._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new t.n(`dataloading`,{dataType:`source`})),this.url=this.options.url,this._request=new AbortController;try{let t=yield u.getImage(yield this.map._requestManager.transformRequest(this.url,`Image`),this._request);this._request=null,this._loaded=!0,t!=null&&t.data&&(this.image=t.data,e&&(this.coordinates=e),this._finishLoading())}catch(e){this._request=null,this._loaded=!0,t.$(e)||this.fire(new t.l(t.d(e)))}}))}loaded(){return this._loaded}updateImage(e){return e.url?(this._request&&=(this._request.abort(),null),this.options.url=e.url,this.load(e.coordinates).finally((()=>this.texture=null)),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.n(`data`,{dataType:`source`,sourceDataType:`metadata`})))}onAdd(e){this.map=e,this.load()}onRemove(){this._request&&=(this._request.abort(),null)}setCoordinates(e){this.coordinates=e;let n=e.map(t.a7.fromLngLat);var r;return this.tileID=function(e){let n=t.a8.fromPoints(e),r=n.width(),i=n.height(),a=Math.max(0,Math.floor(-Math.log(Math.max(r,i))/Math.LN2)),o=2**a;return new t.aa(a,Math.floor((n.minX+n.maxX)/2*o),Math.floor((n.minY+n.maxY)/2*o))}(n),this.terrainTileRanges=this._getOverlappingTileRanges(n),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=n.map((e=>this.tileID.getTilePoint(e)._round())),this.flippedWindingOrder=((r=this.tileCoords)[1].x-r[0].x)*(r[2].y-r[0].y)-(r[1].y-r[0].y)*(r[2].x-r[0].x)<0,this.fire(new t.n(`data`,{dataType:`source`,sourceDataType:`content`})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;let e=this.map.painter.context,n=e.gl;this.texture||(this.texture=new t.T(e,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let r=!1;for(let e in this.tiles){let t=this.tiles[e];t.state!==`loaded`&&(t.state=`loaded`,t.texture=this.texture,r=!0)}r&&this.fire(new t.n(`data`,{dataType:`source`,sourceDataType:`idle`,sourceId:this.id}))}loadTile(e){return t._(this,void 0,void 0,(function*(){this.tileID?.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state=`errored`}))}serialize(){return{type:`image`,url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(e){let{minX:n,minY:r,maxX:i,maxY:a}=t.a8.fromPoints(e),o={};for(let e=0;e<=t.a9;e++){let t=2**e,s=Math.floor(n*t),c=Math.floor(r*t),l=Math.floor(i*t),u=Math.floor(a*t),d=(s%t+t)%t,f=l%t;o[e]={minWrap:Math.floor(s/t),maxWrap:Math.floor(l/t),minTileXWrapped:d,maxTileXWrapped:f,minTileY:c,maxTileY:u}}return o}}class Ce extends Se{constructor(e,t,n,r){super(e,t,n,r),this._onPlayingHandler=()=>{var e;(e=this.map)==null||e.triggerRepaint()},this.roundZoom=!0,this.type=`video`,this.options=t}load(){return t._(this,void 0,void 0,(function*(){this._loaded=!1;let e=this.options;this.urls=[];for(let t of e.urls)this.urls.push((yield this.map._requestManager.transformRequest(t,`Source`)).url);try{let e=yield t.ab(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 t.l(t.d(e)))}}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){let n=this.video.seekable;e<n.start(0)||e>n.end(0)?this.fire(new t.l(new t.ac(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}onRemove(){super.onRemove(),this.video&&(this.video.removeEventListener(`playing`,this._onPlayingHandler),this.video.pause())}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;let e=this.map.painter.context,n=e.gl;this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new t.T(e,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let r=!1;for(let e in this.tiles){let t=this.tiles[e];t.state!==`loaded`&&(t.state=`loaded`,t.texture=this.texture,r=!0)}r&&this.fire(new t.n(`data`,{dataType:`source`,sourceDataType:`idle`,sourceId:this.id}))}serialize(){return{type:`video`,urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class we extends Se{constructor(e,n,r,i){super(e,n,r,i),n.coordinates?Array.isArray(n.coordinates)&&n.coordinates.length===4&&!n.coordinates.some((e=>!Array.isArray(e)||e.length!==2||e.some((e=>typeof e!=`number`))))||this.fire(new t.l(new t.ac(`sources.${e}`,null,`"coordinates" property must be an array of 4 longitude/latitude array pairs`))):this.fire(new t.l(new t.ac(`sources.${e}`,null,`missing required property "coordinates"`))),n.animate&&typeof n.animate!=`boolean`&&this.fire(new t.l(new t.ac(`sources.${e}`,null,`optional "animate" property must be a boolean value`))),n.canvas?typeof n.canvas==`string`||n.canvas instanceof HTMLCanvasElement||this.fire(new t.l(new t.ac(`sources.${e}`,null,`"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance`))):this.fire(new t.l(new t.ac(`sources.${e}`,null,`missing required property "canvas"`))),this.options=n,this.animate=n.animate===void 0||n.animate}load(){return t._(this,void 0,void 0,(function*(){this._loaded=!0,this.canvas||=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.l(Error(`Canvas dimensions cannot be less than or equal to zero.`))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&=(this.prepare(),!1)},this._finishLoading())}))}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;let n=this.map.painter.context,r=n.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new t.T(n,this.canvas,r.RGBA,{premultiply:!0}),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE));let i=!1;for(let e in this.tiles){let t=this.tiles[e];t.state!==`loaded`&&(t.state=`loaded`,t.texture=this.texture,i=!0)}i&&this.fire(new t.n(`data`,{dataType:`source`,sourceDataType:`idle`,sourceId:this.id}))}serialize(){return{type:`canvas`,animate:this.animate,canvas:this.options.canvas,coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(let e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}}let Te={},Ee=e=>{switch(e){case`geojson`:return xe;case`image`:return Se;case`raster`:return pe;case`raster-dem`:return me;case`vector`:return fe;case`video`:return Ce;case`canvas`:return we}return Te[e]},De=`RTLPluginLoaded`;class Oe extends t.E{constructor(){super(...arguments),this.status=`unavailable`,this.url=null,this.dispatcher=ie()}_syncState(e){return this.status=e,this.dispatcher.broadcast(`SRPS`,{pluginStatus:e,pluginURL:this.url}).catch((e=>{throw this.status=`error`,e}))}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status=`unavailable`,this.url=null}setRTLTextPlugin(e){return t._(this,arguments,void 0,(function*(e,t=!1){if(this.url)throw Error(`setRTLTextPlugin cannot be called multiple times.`);if(this.url=s.resolveURL(e),!this.url)throw Error(`requested url ${e} is invalid`);if(this.status===`unavailable`){if(!t)return this._requestImport();this.status=`deferred`,this._syncState(this.status)}else if(this.status===`requested`)return this._requestImport()}))}_requestImport(){return t._(this,void 0,void 0,(function*(){yield this._syncState(`loading`),this.status=`loaded`,this.fire(new t.n(De))}))}lazyLoad(){this.status===`unavailable`?this.status=`requested`:this.status===`deferred`&&this._requestImport()}}let ke=null;function Ae(){return ke||=new Oe,ke}var je,Me;(function(e){e[e.Base=0]=`Base`,e[e.Parent=1]=`Parent`})(je||={}),function(e){e[e.Departing=0]=`Departing`,e[e.Incoming=1]=`Incoming`}(Me||={});class Ne{constructor(e,n){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=e,this.uid=t.ad(),this.uses=0,this.tileSize=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttFingerprint={},this.expiredRequestCount=0,this.state=`loading`}isRenderable(e){return this.hasData()&&(!this.fadeEndTime||this.fadeOpacity>0)&&(e||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:e,fadingDirection:t,fadingParentID:n,fadeEndTime:r}){this.resetFadeLogic(),this.fadingRole=e,this.fadingDirection=t,this.fadingParentID=n,this.fadeEndTime=r}setSelfFadeLogic(e){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=e}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=l(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return this.state===`errored`||this.state===`loaded`||this.state===`reloading`}clearTextures(e){this.demTexture&&e.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(e,n,r){if(!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 n={};if(!t)return n;for(let r of e){let e=r.layerIds.map((e=>t.getLayer(e))).filter(Boolean);if(e.length!==0){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((t=>e.filter((e=>e.id===t))[0])));for(let t of e)n[t.id]=r}}return n}(e.buckets,n?.style),this.hasSymbolBuckets=!1;for(let e in this.buckets){let n=this.buckets[e];if(n instanceof t.af){if(this.hasSymbolBuckets=!0,!r)break;n.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(let e in this.buckets){let n=this.buckets[e];if(n instanceof t.af&&n.hasRTLText){this.hasRTLText=!0,Ae().lazyLoad();break}}this.queryPadding=0;for(let e in this.buckets){let t=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,n.style.getLayer(e).queryRadius(t))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),this.dashPositions=e.dashPositions}else this.collisionBoxArray=new t.ae;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 t in this.buckets){let n=this.buckets[t];n.uploadPending()&&n.upload(e)}let n=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new t.T(e,this.imageAtlas.image,n.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&=(this.glyphAtlasTexture=new t.T(e,this.glyphAtlasImage,n.ALPHA),null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,n,r,i,a,o,s,c,l,u){return this.latestFeatureIndex?.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:i,scale:a,tileSize:this.tileSize,pixelPosMatrix:l,transform:s,params:o,queryPadding:this.queryPadding*c,getElevation:u},e,t,n):{}}querySourceFeatures(e,n){let r=this.latestFeatureIndex;if(!r?.rawTileData)return;let i=r.loadVTLayers(),a=n?.sourceLayer?n.sourceLayer:``,o=i[t.ag]||i[a];if(!o)return;let s=t.ah(n?.filter,n?.globalState),{z:c,x:l,y:u}=this.tileID.canonical,d={z:c,x:l,y:u};for(let n=0;n<o.length;n++){let i=o.feature(n);if(s.needGeometry){let e=t.ai(i,!0);if(!s.filter(new t.J(this.tileID.overscaledZ),e,this.tileID.canonical))continue}else if(!s.filter(new t.J(this.tileID.overscaledZ),i))continue;let f=r.getId(i,a),p=new t.aj(i,c,l,u,f);p.tile=d,e.push(p)}}hasData(){return this.state===`loaded`||this.state===`reloading`||this.state===`expired`}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){let n=this.expirationTime;if(e.cacheControl){let n=t.ak(e.cacheControl);n[`max-age`]&&(this.expirationTime=Date.now()+1e3*n[`max-age`])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){let e=Date.now(),t=!1;if(this.expirationTime>e)t=!1;else if(n)if(this.expirationTime<n)t=!0;else{let r=this.expirationTime-n;r?this.expirationTime=e+Math.max(r,3e4):t=!0}else t=!0;t?(this.expiredRequestCount++,this.state=`expired`):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-new Date().getTime(),2**31-1)}setFeatureState(e,n){if(!this.latestFeatureIndex?.rawTileData||Object.keys(e).length===0)return;let r=this.latestFeatureIndex.loadVTLayers();for(let i in this.buckets){if(!n.style.hasLayer(i))continue;let a=this.buckets[i],o=a.layers[0].sourceLayer||t.ag,s=r[o],c=e[o];if(!s||!c||Object.keys(c).length===0)continue;a.update(c,s,this.imageAtlas?.patternPositions||{},this.dashPositions||{});let l=(n?.style)?.getLayer(i);l&&(this.queryPadding=Math.max(this.queryPadding,l.queryRadius(a)))}}holdingForSymbolFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<l()}clearSymbolFadeHold(){this.symbolFadeHoldUntil=void 0}setSymbolHoldDuration(e){this.symbolFadeHoldUntil=l()+e}setDependencies(e,t){let n={};for(let e of t)n[e]=!0;this.dependencies[e]=n}hasDependency(e,t){for(let n of e){let e=this.dependencies[n];if(e){for(let n of t)if(e[n])return!0}}return!1}}class Pe{constructor(){this.state={},this.stateChanges={},this.deletedStates={},this.revision=0}updateState(e,n,r){var i,a;let o=String(n);if((i=this.stateChanges)[e]||(i[e]={}),(a=this.stateChanges[e])[o]||(a[o]={}),t.e(this.stateChanges[e][o],r),this.deletedStates[e]===null){this.deletedStates[e]={};for(let t in this.state[e])t!==o&&(this.deletedStates[e][t]=null)}else if(this.deletedStates[e]?.[o]===null){this.deletedStates[e][o]={};for(let t in this.state[e][o])r[t]||(this.deletedStates[e][o][t]=null)}else for(let t in r)this.deletedStates[e]?.[o]?.[t]===null&&delete this.deletedStates[e][o][t]}removeFeatureState(e,t,n){var r,i;if(this.deletedStates[e]===null)return;let a=String(t);if((r=this.deletedStates)[e]||(r[e]={}),n&&t!==void 0)this.deletedStates[e][a]!==null&&((i=this.deletedStates[e])[a]||(i[a]={}),this.deletedStates[e][a][n]=null);else if(t!==void 0)if(this.stateChanges[e]?.[a])for(n in this.deletedStates[e][a]={},this.stateChanges[e][a])this.deletedStates[e][a][n]=null;else this.deletedStates[e][a]=null;else this.deletedStates[e]=null}getState(e,n){let r=String(n),i=t.e({},(this.state[e]||{})[r],(this.stateChanges[e]||{})[r]);if(this.deletedStates[e]===null)return{};if(this.deletedStates[e]){let t=this.deletedStates[e][n];if(t===null)return{};for(let e in t)delete i[e]}return i}initializeTileState(e,t){e.setFeatureState(this.state,t)}coalesceChanges(e,n){var r,i,a;let o={};for(let e in this.stateChanges){(r=this.state)[e]||(r[e]={});let n={};for(let r in this.stateChanges[e])(i=this.state[e])[r]||(i[r]={}),t.e(this.state[e][r],this.stateChanges[e][r]),n[r]=this.state[e][r];o[e]=n}for(let e in this.deletedStates){(a=this.state)[e]||(a[e]={});let n={};if(this.deletedStates[e]===null)for(let t in this.state[e])n[t]={},this.state[e][t]={};else for(let t in this.deletedStates[e]){if(this.deletedStates[e][t]===null)this.state[e][t]={};else for(let n of Object.keys(this.deletedStates[e][t]))delete this.state[e][t][n];n[t]=this.state[e][t]}o[e]||(o[e]={}),t.e(o[e],n)}this.stateChanges={},this.deletedStates={},Object.keys(o).length!==0&&(this.revision++,e.setFeatureState(o,n))}}let Fe=89.25;function Ie(e,n){let r=t.al(n.lat,-t.am,t.am);return new t.P(t.Z(n.lng)*e,t.Y(r)*e)}function Le(e,n){return new t.a7(n.x/e,n.y/e).toLngLat()}function Re(e){return e.cameraToCenterDistance*Math.min(.85*Math.tan(t.an(90-e.pitch)),Math.tan(t.an(Fe-e.pitch)))}function ze(e,n){let r=e.canonical,i=n/t.ao(r.z),a=r.x+2**r.z*e.wrap,o=t.ap(new Float64Array(16));return t.Q(o,o,[a*i,r.y*i,0]),t.S(o,o,[i/t.a6,i/t.a6,1]),o}function Be(e,n,r,i,a){let o=t.a7.fromLngLat(e,n),s=a*t.aq(1,e.lat),{x:c,y:l,z:u}=Ve(r,i);return new t.a7(o.x+s*-c,o.y+s*-l,o.z+s*-u)}function Ve(e,n){let r=t.an(e),i=t.an(n),a=Math.cos(-r),o=Math.sin(r);return{x:o*Math.sin(i),y:-o*Math.cos(i),z:a}}function M(e,t,n){let r=t.intersectsFrustum(e);if(!n||r===0)return r;let i=t.intersectsPlane(n);return i===0?0:r===2&&i===2?2:1}function He(e,t,n){let r=0,i=(n-t)/10;for(let a=0;a<10;a++)r+=i*Math.cos(t+(a+.5)/10*(n-t))**+e;return r}function Ue(e,n){return function(r,i,a,o,s){let c=2*((e-1)/t.ar(Math.cos(t.an(Fe-s))/Math.cos(t.an(Fe)))-1),l=Math.acos(a/o),u=2*He(c-1,0,t.an(s/2)),d=Math.min(t.an(Fe),l+t.an(s/2)),f=He(c-1,Math.min(d,l-t.an(s/2)),d),p=Math.atan(i/a),m=Math.hypot(i,a),h=r;return h+=t.ar(o/m/Math.max(.5,Math.cos(t.an(s/2)))),h+=c*t.ar(Math.cos(p))/2,h-=t.ar(Math.max(1,f/u/n))/2,h}}let N=Ue(9.314,3);function P(e,n){let r=(n.roundZoom?Math.round:Math.floor)(e.zoom+t.ar(e.tileSize/n.tileSize));return Math.max(0,r)}function We(e,n){let r=e.getCameraFrustum(),i=e.getClippingPlane(),a=e.screenPointToMercatorCoordinate(e.getCameraPoint()),o=t.a7.fromLngLat(e.center,e.elevation);a.z=o.z+Math.cos(e.pitchInRadians)*e.cameraToCenterDistance/e.worldSize;let s=e.getCoveringTilesDetailsProvider(),c=s.allowVariableZoom(e,n),l=P(e,n),u=n.minzoom||0,d=n.maxzoom===void 0?e.maxZoom:n.maxzoom,f=Math.min(Math.max(0,l),d),p=2**f,m=[p*a.x,p*a.y,0],h=[p*o.x,p*o.y,0],g=Math.hypot(o.x-a.x,o.y-a.y),_=Math.abs(o.z-a.z),v=Math.hypot(g,_),y=e=>({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),b=[],x=[];if(e.renderWorldCopies&&s.allowWorldCopies())for(let e=1;e<=3;e++)b.push(y(-e)),b.push(y(e));for(b.push(y(0));b.length>0;){let p=b.pop(),g=p.x,y=p.y,S=p.fullyVisible,C={x:g,y,z:p.zoom},w=s.getTileBoundingVolume(C,p.wrap,e.elevation,n);if(!S){let e=M(r,w,i);if(e===0)continue;S=e===2}let T=s.distanceToTile2d(a.x,a.y,C,w),E=l;c&&(E=(n.calculateTileZoom||N)(e.zoom+t.ar(e.tileSize/n.tileSize),T,_,v,e.fov)),E=(n.roundZoom?Math.round:Math.floor)(E),E=Math.max(0,E);let D=Math.min(E,d);if(p.wrap=s.getWrap(o,C,p.wrap),p.zoom>=D){if(p.zoom<u)continue;let e=f-p.zoom,r=m[0]-.5-(g<<e),i=m[1]-.5-(y<<e),a=n.reparseOverscaled?Math.max(p.zoom,E):p.zoom;x.push({tileID:new t.a3(p.zoom===d?a:p.zoom,p.wrap,p.zoom,g,y),distanceSq:t.as([h[0]-.5-g,h[1]-.5-y]),tileDistanceToCamera:Math.sqrt(r*r+i*i)})}else for(let e=0;e<4;e++)b.push({zoom:p.zoom+1,x:(g<<1)+e%2,y:(y<<1)+(e>>1),wrap:p.wrap,fullyVisible:S})}return x.sort(((e,t)=>e.distanceSq-t.distanceSq)).map((e=>e.tileID))}let Ge=t.a8.fromPoints([new t.P(0,0),new t.P(t.a6,t.a6)]);function Ke(e){return e===`raster`||e===`image`||e===`video`}function qe(e,t,n,r,i,a,o){if(!t.hasData())return!1;let{tileID:s,fadingRole:c,fadingDirection:l,fadingParentID:u}=t;if(c===je.Base&&l===Me.Incoming&&u)return n[u.key]=u,!0;let d=Math.max(s.overscaledZ-i,a);for(let i=s.overscaledZ-1;i>=d;i--){let a=s.scaledTo(i),c=e.getLoadedTile(a);if(c)return t.setCrossFadeLogic({fadingRole:je.Base,fadingDirection:Me.Incoming,fadingParentID:c.tileID,fadeEndTime:r+o}),c.setCrossFadeLogic({fadingRole:je.Parent,fadingDirection:Me.Departing,fadeEndTime:r+o}),n[a.key]=a,!0}return!1}function Je(e,t,n,r,i,a){if(!t.hasData())return!1;let o=t.tileID.children(i),s=Ye(e,t,o,n,r,i,a);if(s)return!0;for(let c of o)Ye(e,t,c.children(i),n,r,i,a)&&(s=!0);return s}function Ye(e,t,n,r,i,a,o){if(n[0].overscaledZ>=a)return!1;let s=!1;for(let a of n){let n=e.getLoadedTile(a);if(!n)continue;let{fadingRole:c,fadingDirection:l,fadingParentID:u}=n;c===je.Base&&l===Me.Departing&&u||(n.setCrossFadeLogic({fadingRole:je.Base,fadingDirection:Me.Departing,fadingParentID:t.tileID,fadeEndTime:i+o}),t.setCrossFadeLogic({fadingRole:je.Parent,fadingDirection:Me.Incoming,fadeEndTime:i+o})),r[a.key]=a,s=!0}return s}function Xe(e,t,n,r){let i=e.tileID;return!!e.selfFading||!e.hasData()&&!!t.has(i)&&(e.setSelfFadeLogic(n+r),!0)}function F(e,t){var n;e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0;let r=t.tileID.canonical.x-e.tileID.canonical.x,i=t.tileID.canonical.y-e.tileID.canonical.y,a=2**e.tileID.canonical.z,o=t.tileID.key;r===0&&i===0||Math.abs(i)>1||(Math.abs(r)>1&&(Math.abs(r+a)===1?r+=a:Math.abs(r-a)===1&&(r-=a)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,r,i),(n=e.neighboringTiles)!=null&&n[o]&&(e.neighboringTiles[o].backfilled=!0)))}class Ze{constructor(){this._tiles={}}handleWrapJump(e){let t={};for(let n in this._tiles){let r=this._tiles[n];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+e),t[r.tileID.key]=r}this._tiles=t}setFeatureState(e,t){for(let n in this._tiles)this._tiles[n].setFeatureState(e,t)}getAllTiles(){return Object.values(this._tiles)}getAllIds(e=!1){return e?Object.values(this._tiles).map((e=>e.tileID)).sort(t.au).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,n){let r=[];for(let e of this.getAllIds())this.isIdRenderable(e,n)&&r.push(this.getTileById(e));return n?r.sort(((n,r)=>{let i=n.tileID,a=r.tileID,o=new t.P(i.canonical.x,i.canonical.y)._rotate(-e),s=new t.P(a.canonical.x,a.canonical.y)._rotate(-e);return i.overscaledZ-a.overscaledZ||s.y-o.y||s.x-o.x})).map((e=>e.tileID.key)):r.map((e=>e.tileID)).sort(t.au).map((e=>e.key))}}class Qe extends t.E{constructor(e,n,r){super(),this.id=e,this.dispatcher=r,this.on(`data`,(e=>{this._dataHandler(e)})),this.on(`dataloading`,(()=>{this._sourceErrored=!1})),this.on(`error`,(()=>{this._sourceErrored=this._source.loaded()})),this._source=((e,t,n,r)=>{let i=new(Ee(t.type))(e,t,n,r);if(i.id!==e)throw Error(`Expected Source id to be ${e} instead of ${i.id}`);return i})(e,n,r,this),this._inViewTiles=new Ze,this._outOfViewCache=new t.av(0,(e=>this._unloadTile(e))),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new Pe,this._didEmitContent=!1,this._updated=!1}onAdd(e){var t;this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,(t=this._source)!=null&&t.onAdd&&this._source.onAdd(e)}onRemove(e){var t;for(let e of this._inViewTiles.getAllTiles())e.unloadVectorData();this.clearTiles(),(t=this._source)!=null&&t.onRemove&&this._source.onRemove(e),this._inViewTiles=new Ze}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;if(!(this.used===void 0&&this.usedForTerrain===void 0||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(let e of this._inViewTiles.getAllTiles())if(e.state!==`loaded`&&e.state!==`errored`)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)}_loadTile(e,n,r){return t._(this,void 0,void 0,(function*(){try{let t=yield this._source.loadTile(e);this._tileLoaded(e,n,r,t)}catch(n){e.state=`errored`,n.status===404?this.update(this.transform,this.terrain):this._source.fire(new t.l(t.d(n),{tile:e}))}}))}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e)}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new t.n(`dataabort`,{tile:e,coord:e.tileID,dataType:`source`}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._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 n=this.getLoadedTile(e.scaledTo(t));if(n)return this._inViewTiles.isIdRenderable(n.tileID.key)}return!1}reload(e,t=void 0){if(this._paused)this._shouldReloadOnResume=!0;else{this._outOfViewCache.reset();for(let n of this._inViewTiles.getAllIds()){let r=this._inViewTiles.getTileById(n);t&&!this._source.shouldReloadTile(r,t)||(e?this._reloadTile(n,`expired`):r.state!==`errored`&&this._reloadTile(n,`reloading`))}}}_reloadTile(e,n){return t._(this,void 0,void 0,(function*(){let t=this._inViewTiles.getTileById(e);t&&(t.state!==`loading`&&(t.state=n),yield this._loadTile(t,e,n))}))}_tileLoaded(e,n,r,i){e.timeAdded=l(),e.selfFading&&(e.fadeEndTime=e.timeAdded+this._rasterFadeDuration),r===`expired`&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(n,e),i!=null&&i.unmodified||(this.getSource().type===`raster-dem`&&e.dem&&function(e,t){var n;let r=t.getRenderableIds();for(let i of r){if(!e.neighboringTiles?.[i])continue;let r=t.getTileById(i);e.neighboringTiles[i].backfilled||F(e,r),(n=r.neighboringTiles?.[e.tileID.key])!=null&&n.backfilled||F(r,e)}}(e,this._inViewTiles),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new t.n(`data`,{dataType:`source`,tile:e,coord:e.tileID})))}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._inViewTiles.getTileById(e)}_retainLoadedChildren(e,t){let n=this._getLoadedDescendents(t),r=new Set;for(let i of t){let t=n[i.key];if(!t?.length){r.add(i);continue}let a=i.overscaledZ+Qe.maxOverzooming,o=t.filter((e=>e.tileID.overscaledZ<=a));if(!o.length){r.add(i);continue}let s=Math.min(...o.map((e=>e.tileID.overscaledZ))),c=o.filter((e=>e.tileID.overscaledZ===s)).map((e=>e.tileID));for(let t of c)e[t.key]=t;this._areDescendentsComplete(c,s,i.overscaledZ)||r.add(i)}return r}_getLoadedDescendents(e){var t;let n={};for(let r of this._inViewTiles.getAllTiles().filter((e=>e.hasData())))for(let i of e)r.tileID.isChildOf(i)&&(n[t=i.key]||(n[t]=[]),n[i.key].push(r));return n}_areDescendentsComplete(e,t,n){return e.length===1&&e[0].isOverscaled()?e[0].overscaledZ===t:4**(t-n)===e.length}getLoadedTile(e){return this._inViewTiles.getLoadedTile(e)}updateCacheSize(e){let n=Math.ceil(e.width/this._source.tileSize)+1,r=Math.ceil(e.height/this._source.tileSize)+1,i=Math.floor(n*r*(this._maxTileCacheZoomLevels===null?t.c.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),a=typeof this._maxTileCacheSize==`number`?Math.min(this._maxTileCacheSize,i):i;this._outOfViewCache.setMaxSize(a)}handleWrapJump(e){let t=Math.round((e-(this._prevLng===void 0?e:this._prevLng))/360);this._prevLng=e,t&&(this._inViewTiles.handleWrapJump(t),this._resetTileReloadTimers())}update(e,n){if(!this._sourceLoaded||this._paused)return;let r;this.transform=e,this.terrain=n,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?r=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new t.a3(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(r=We(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.type===`vector`&&this.map._zoomLevelsToOverscale!==void 0?e.maxZoom-this.map._zoomLevelsToOverscale:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:n,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(r=r.filter((e=>this._source.hasTile(e))))):r=[],this.usedForTerrain&&(r=this._addTerrainIdealTiles(r));let i=r.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,i&&this.fire(new t.n(`data`,{sourceDataType:`idle`,dataType:`source`,sourceId:this.id}));let a=P(e,this._source),o=this._updateRetainedTiles(r,a),s=Ke(this._source.type);s&&this._rasterFadeDuration>0&&!n&&function(e,n,r,i,a,o,s){let c=l(),u=t.at(n);for(let t of n){let n=e.getTileById(t.key);n.fadingDirection!==Me.Departing&&n.fadeOpacity!==0||n.resetFadeLogic(),qe(e,n,r,c,i,a,s)||Je(e,n,r,c,o,s)||Xe(n,u,c,s)||n.resetFadeLogic()}}(this._inViewTiles,r,o,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),s?this._cleanUpRasterTiles(o):this._cleanUpVectorTiles(o)}_cleanUpRasterTiles(e){for(let t of this._inViewTiles.getAllIds())e[t]||this._removeTile(t)}_cleanUpVectorTiles(e){for(let t of this._inViewTiles.getAllIds()){let n=this._inViewTiles.getTileById(t);e[t]?n.clearSymbolFadeHold():n.hasSymbolBuckets?n.holdingForSymbolFade()?n.symbolFadeFinished()&&this._removeTile(t):n.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(t)}}_addTerrainIdealTiles(e){let t=[];for(let n of e)if(n.canonical.z>this._source.minzoom){let e=n.scaledTo(n.canonical.z-1);t.push(e);let r=n.scaledTo(Math.max(this._source.minzoom,Math.min(n.canonical.z,5)));t.push(r)}return e.concat(t)}releaseSymbolFadeTiles(){for(let e of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(e).holdingForSymbolFade()&&this._removeTile(e)}_updateRetainedTiles(e,t){let n=new Set;for(let t of e)this._addTile(t).hasData()||n.add(t);let r=e.reduce(((e,t)=>(e[t.key]=t,e)),{}),i=this._retainLoadedChildren(r,n),a={},o=Math.max(t-Qe.maxUnderzooming,this._source.minzoom);for(let e of i){let t=this._inViewTiles.getTileById(e.key),n=t?.wasRequested();for(let i=e.overscaledZ-1;i>=o;--i){let o=e.scaledTo(i);if(a[o.key])break;if(a[o.key]=!0,t=this.getTile(o),!t&&n&&(t=this._addTile(o)),t){let e=t.hasData();if((e||!this.map?.cancelPendingTileRequestsWhileZooming||n)&&(r[o.key]=o),n=t.wasRequested(),e)break}}}return r}_addTile(e){let n=this._inViewTiles.getTileById(e.key);if(n)return n;n=this._outOfViewCache.getAndRemove(e),n&&(n.resetFadeLogic(),this._setTileReloadTimer(e.key,n),n.tileID=e,this._state.initializeTileState(n,this.map?this.map.painter:null));let r=n;return n||(n=new Ne(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(n,e.key,n.state)),n.uses++,this._inViewTiles.setTile(e.key,n),r||this._source.fire(new t.n(`dataloading`,{tile:n,coord:n.tileID,dataType:`source`})),n}_setTileReloadTimer(e,t){this._clearTileReloadTimer(e);let n=t.getExpiryTimeout();n&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,`expired`),delete this._timers[e]}),n))}_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 n=this._inViewTiles.getTileById(t);(this._inViewTiles.isIdRenderable(t)||n.state==`errored`)&&e.some((e=>e.equals(n.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()&&t.state!==`reloading`?this._outOfViewCache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))))}_dataHandler(e){e.dataType===`source`&&(e.sourceDataType===`metadata`?this._sourceLoaded=!0:e.sourceDataType===`content`&&this._sourceLoaded&&!this._paused&&(this.reload(e.sourceDataChanged,e.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(let e of this._inViewTiles.getAllIds())this._removeTile(e);this._outOfViewCache.reset()}tilesIn(e,n,r){let i=[],a=this.transform;if(!a)return i;let o=a.getCoveringTilesDetailsProvider().allowWorldCopies(),s=r?a.getCameraQueryGeometry(e):e,c=e=>a.screenPointToMercatorCoordinate(e,this.terrain),l=this.transformBbox(e,c,!o),u=this.transformBbox(s,c,!o),d=this.getIds(),f=t.a8.fromPoints(u);for(let e of d){let r=this._inViewTiles.getTileById(e);if(r.holdingForSymbolFade())continue;let s=o?[r.tileID]:[r.tileID.unwrapTo(-1),r.tileID.unwrapTo(0)],c=2**(a.zoom-r.tileID.overscaledZ),d=n*r.queryPadding*t.a6/r.tileSize/c;for(let e of s){let n=f.map((n=>e.getTilePoint(new t.a7(n.x,n.y))));if(n.expandBy(d),n.intersects(Ge)){let t=l.map((t=>e.getTilePoint(t))),n=u.map((t=>e.getTilePoint(t)));i.push({tile:r,tileID:o?e:e.unwrapTo(0),queryGeometry:t,cameraQueryGeometry:n,scale:c})}}}return i}transformBbox(e,n,r){let i=e.map(n);if(r){let r=t.a8.fromPoints(e);r.shrinkBy(.001*Math.min(r.width(),r.height()));let a=r.map(n);t.a8.fromPoints(i).covers(a)||(i=i.map((e=>e.x>.5?new t.a7(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()||Ke(this._source.type)&&function(e,t){if(t<=0)return!1;let n=l();for(let t of e.getAllTiles())if(t.fadeEndTime>=n)return!0;return!1}(this._inViewTiles,this._rasterFadeDuration)}setRasterFadeDuration(e){this._rasterFadeDuration=e}setFeatureState(e,n,r){e||=t.ag,this._state.updateState(e,n,r)}removeFeatureState(e,n,r){e||=t.ag,this._state.removeFeatureState(e,n,r)}getFeatureState(e,n){return e||=t.ag,this._state.getState(e,n)}setDependencies(e,t,n){let r=this._inViewTiles.getTileById(e);r&&r.setDependencies(t,n)}reloadTilesForDependencies(e,t){for(let n of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(n).hasDependency(e,t)&&this._reloadTile(n,`reloading`);this._outOfViewCache.filter((n=>!n.hasDependency(e,t)))}areTilesLoaded(){for(let e of this._inViewTiles.getAllTiles())if(e.state!==`loaded`&&e.state!==`errored`)return!1;return!0}}Qe.maxUnderzooming=10,Qe.maxOverzooming=3;class $e{constructor(e,t){this.reset(e,t)}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e<this.points.length;e++)this._distances[e]=this._distances[e-1]+this.points[e].dist(this.points[e-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(t||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(e){if(this.points.length===1)return this.points[0];e=t.al(e,0,1);let n=1,r=this._distances[n],i=e*this.paddedLength+this.padding;for(;r<i&&n<this._distances.length;)r=this._distances[++n];let a=n-1,o=this._distances[a],s=r-o,c=s>0?(i-o)/s:0;return this.points[a].mult(1-c).add(this.points[n].mult(c))}}function et(e,t){let n=!0;return e===`always`||e!==`never`&&t!==`never`||(n=!1),n}class I{constructor(e,t,n){let r=this.boxCells=[],i=this.circleCells=[];this.xCellCount=Math.ceil(e/n),this.yCellCount=Math.ceil(t/n);for(let e=0;e<this.xCellCount*this.yCellCount;e++)r.push([]),i.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=e,this.height=t,this.xScale=this.xCellCount/e,this.yScale=this.yCellCount/t,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,t,n,r,i){this._forEachCell(t,n,r,i,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(t),this.bboxes.push(n),this.bboxes.push(r),this.bboxes.push(i)}insertCircle(e,t,n,r){this._forEachCell(t-r,n-r,t+r,n+r,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(t),this.circles.push(n),this.circles.push(r)}_insertBoxCell(e,t,n,r,i,a){this.boxCells[i].push(a)}_insertCircleCell(e,t,n,r,i,a){this.circleCells[i].push(a)}_query(e,t,n,r,i,a,o){if(n<0||e>this.width||r<0||t>this.height)return[];let s=[];if(e<=0&&t<=0&&this.width<=n&&this.height<=r){if(i)return[{key:null,x1:e,y1:t,x2:n,y2:r}];for(let e=0;e<this.boxKeys.length;e++)s.push({key:this.boxKeys[e],x1:this.bboxes[4*e],y1:this.bboxes[4*e+1],x2:this.bboxes[4*e+2],y2:this.bboxes[4*e+3]});for(let e=0;e<this.circleKeys.length;e++){let t=this.circles[3*e],n=this.circles[3*e+1],r=this.circles[3*e+2];s.push({key:this.circleKeys[e],x1:t-r,y1:n-r,x2:t+r,y2:n+r})}}else this._forEachCell(e,t,n,r,this._queryCell,s,{hitTest:i,overlapMode:a,seenUids:{box:{},circle:{}}},o);return s}query(e,t,n,r){return this._query(e,t,n,r,!1,null)}hitTest(e,t,n,r,i,a){return this._query(e,t,n,r,!0,i,a).length>0}hitTestCircle(e,t,n,r,i){let a=e-n,o=e+n,s=t-n,c=t+n;if(o<0||a>this.width||c<0||s>this.height)return!1;let l=[];return this._forEachCell(a,s,o,c,this._queryCellCircle,l,{hitTest:!0,overlapMode:r,circle:{x:e,y:t,radius:n},seenUids:{box:{},circle:{}}},i),l.length>0}_queryCell(e,t,n,r,i,a,o,s){let{seenUids:c,hitTest:l,overlapMode:u}=o,d=this.boxCells[i],f=1e-6;if(d!==null){let i=this.bboxes;for(let o of d)if(!c.box[o]){c.box[o]=!0;let d=4*o,p=this.boxKeys[o];if(e<=i[d+2]+f&&t<=i[d+3]+f&&n>=i[d+0]-f&&r>=i[d+1]-f&&(!s||s(p))&&(!l||!et(u,p.overlapMode))&&(a.push({key:p,x1:i[d],y1:i[d+1],x2:i[d+2],y2:i[d+3]}),l))return!0}}let p=this.circleCells[i];if(p!==null){let i=this.circles;for(let o of p)if(!c.circle[o]){c.circle[o]=!0;let d=3*o,f=this.circleKeys[o];if(this._circleAndRectCollide(i[d],i[d+1],i[d+2],e,t,n,r)&&(!s||s(f))&&(!l||!et(u,f.overlapMode))){let e=i[d],t=i[d+1],n=i[d+2];if(a.push({key:f,x1:e-n,y1:t-n,x2:e+n,y2:t+n}),l)return!0}}}return!1}_queryCellCircle(e,t,n,r,i,a,o,s){let{circle:c,seenUids:l,overlapMode:u}=o,d=this.boxCells[i];if(d!==null){let e=this.bboxes;for(let t of d)if(!l.box[t]){l.box[t]=!0;let n=4*t,r=this.boxKeys[t];if(this._circleAndRectCollide(c.x,c.y,c.radius,e[n+0],e[n+1],e[n+2],e[n+3])&&(!s||s(r))&&!et(u,r.overlapMode))return a.push(!0),!0}}let f=this.circleCells[i];if(f!==null){let e=this.circles;for(let t of f)if(!l.circle[t]){l.circle[t]=!0;let n=3*t,r=this.circleKeys[t];if(this._circlesCollide(e[n],e[n+1],e[n+2],c.x,c.y,c.radius)&&(!s||s(r))&&!et(u,r.overlapMode))return a.push(!0),!0}}}_forEachCell(e,t,n,r,i,a,o,s){let c=this._convertToXCellCoord(e),l=this._convertToYCellCoord(t),u=this._convertToXCellCoord(n),d=this._convertToYCellCoord(r);for(let f=c;f<=u;f++)for(let c=l;c<=d;c++)if(i.call(this,e,t,n,r,this.xCellCount*c+f,a,o,s))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,n,r,i,a){let o=r-e,s=i-t,c=n+a;return c*c>o*o+s*s}_circleAndRectCollide(e,t,n,r,i,a,o){let s=(a-r)/2,c=Math.abs(e-(r+s));if(c>s+n)return!1;let l=(o-i)/2,u=Math.abs(t-(i+l));if(u>l+n)return!1;if(c<=s||u<=l)return!0;let d=c-s,f=u-l;return d*d+f*f<=n*n}}function tt(e,t){let n=1/(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]),r=1/(t[8]*t[8]+t[9]*t[9]+t[10]*t[10]),i=t[0]*n,a=t[4]*n,o=t[8]*r,s=t[1]*n,c=t[5]*n,l=t[9]*r,u=t[2]*n,d=t[6]*n,f=t[10]*r;e[0]=i,e[1]=a,e[2]=o,e[4]=s,e[5]=c,e[6]=l,e[8]=u,e[9]=d,e[10]=f;let p=t[12],m=t[13],h=t[14];return e[12]=-i*p-s*m-u*h,e[13]=-a*p-c*m-d*h,e[14]=-o*p-l*m-f*h,e[3]=0,e[7]=0,e[11]=0,e[15]=1,e}let nt=t.O();function rt(e,n,i){let a=t.O();if(!e){let{vecSouth:e,vecEast:t}=at(n),i=r();i[0]=t[0],i[1]=t[1],i[2]=e[0],i[3]=e[1],o=i,(f=(c=(s=i)[0])*(d=s[3])-(u=s[2])*(l=s[1]))&&(o[0]=d*(f=1/f),o[1]=-l*f,o[2]=-u*f,o[3]=c*f),a[0]=i[0],a[1]=i[1],a[4]=i[2],a[5]=i[3]}var o,s,c,l,u,d,f;return t.S(a,a,[1/i,1/i,1]),a}function it(e,n,r,i){if(e){let e=t.O();if(!n){let{vecSouth:t,vecEast:n}=at(r);e[0]=n[0],e[1]=n[1],e[4]=t[0],e[5]=t[1]}return t.S(e,e,[i,i,1]),e}return r.pixelsToClipSpaceMatrix}function at(e){let n=Math.cos(e.rollInRadians),r=Math.sin(e.rollInRadians),i=Math.cos(e.pitchInRadians),a=Math.cos(e.bearingInRadians),o=Math.sin(e.bearingInRadians),s=t.az();s[0]=-a*i*r-o*n,s[1]=-o*i*r+a*n;let c=t.aA(s);c<1e-9?t.aB(s):t.aC(s,s,1/c);let l=t.az();l[0]=a*i*n-o*r,l[1]=o*i*n+a*r;let u=t.aA(l);return u<1e-9?t.aB(l):t.aC(l,l,1/u),{vecEast:l,vecSouth:s}}function ot(e,n,r,i){let a;i?(a=[e,n,i(e,n),1],t.aE(a,a,r)):(a=[e,n,0,1],Ct(a,a,r));let o=a[3];return{point:new t.P(a[0]/o,a[1]/o),signedDistanceFromCamera:o,isOccluded:!1}}function st(e,t){return .5+e/t*.5}function ct(e,t){return e.x>=-t[0]&&e.x<=t[0]&&e.y>=-t[1]&&e.y<=t[1]}function lt(e,n,r,i,a,o,s,c,l,u,d,f,p){let m=r?e.textSizeData:e.iconSizeData,h=t.aw(m,n.transform.zoom),g=[256/n.width*2+1,256/n.height*2+1],_=r?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;_.clear();let v=e.lineVertexArray,y=r?e.text.placedSymbolArray:e.icon.placedSymbolArray,b=n.transform.width/n.transform.height,x=!1;for(let r=0;r<y.length;r++){let S=y.get(r);if(S.hidden||S.writingMode===t.ax.vertical&&!x){St(S.numGlyphs,_);continue}x=!1;let C=new t.P(S.anchorX,S.anchorY),w={getElevation:p,pitchedLabelPlaneMatrix:i,lineVertexArray:v,pitchWithMap:o,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:n.transform,tileAnchorPoint:C,unwrappedTileID:l,width:u,height:d,translation:f},T=_t(S.anchorX,S.anchorY,w);if(!ct(T.point,g)){St(S.numGlyphs,_);continue}let E=st(n.transform.cameraToCenterDistance,T.signedDistanceFromCamera),D=t.ay(m,h,S),O=o?D*n.transform.getPitchedTextCorrection(S.anchorX,S.anchorY,l)/E:D*E,k=ft({projectionContext:w,pitchedLabelPlaneMatrixInverse:a,symbol:S,fontSize:O,flip:!1,keepUpright:s,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:_,aspectRatio:b,rotateToLine:c});x=k.useVertical,(k.notEnoughRoom||x||k.needsFlipping&&ft({projectionContext:w,pitchedLabelPlaneMatrixInverse:a,symbol:S,fontSize:O,flip:!0,keepUpright:s,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:_,aspectRatio:b,rotateToLine:c}).notEnoughRoom)&&St(S.numGlyphs,_)}r?e.text.dynamicLayoutVertexBuffer.updateData(_):e.icon.dynamicLayoutVertexBuffer.updateData(_)}function ut(e,t,n,r,i,a,o,s){let c=a.glyphStartIndex+a.numGlyphs,l=a.lineStartIndex,u=a.lineStartIndex+a.lineLength,d=t.getoffsetX(a.glyphStartIndex),f=t.getoffsetX(c-1),p=bt(e*d,n,r,i,a.segment,l,u,s,o);if(!p)return null;let m=bt(e*f,n,r,i,a.segment,l,u,s,o);return m?s.projectionCache.anyProjectionOccluded?null:{first:p,last:m}:null}function dt(e,n,r,i){return e===t.ax.horizontal&&Math.abs(r.y-n.y)>Math.abs(r.x-n.x)*i?{useVertical:!0}:(e===t.ax.vertical?n.y<r.y:n.x>r.x)?{needsFlipping:!0}:null}function ft(e){let{projectionContext:n,pitchedLabelPlaneMatrixInverse:r,symbol:i,fontSize:a,flip:o,keepUpright:s,glyphOffsetArray:c,dynamicLayoutVertexArray:l,aspectRatio:u,rotateToLine:d}=e,f=a/24,p=i.lineOffsetX*f,m=i.lineOffsetY*f,h;if(i.numGlyphs>1){let e=i.glyphStartIndex+i.numGlyphs,t=i.lineStartIndex,a=i.lineStartIndex+i.lineLength,l=ut(f,c,p,m,o,i,d,n);if(!l)return{notEnoughRoom:!0};let g=gt(l.first.point.x,l.first.point.y,n,r),_=gt(l.last.point.x,l.last.point.y,n,r);if(s&&!o){let e=dt(i.writingMode,g,_,u);if(e)return e}h=[l.first];for(let r=i.glyphStartIndex+1;r<e-1;r++){let e=bt(f*c.getoffsetX(r),p,m,o,i.segment,t,a,n,d);if(!e)return{notEnoughRoom:!0};h.push(e)}h.push(l.last)}else{if(s&&!o){let e=ht(n.tileAnchorPoint.x,n.tileAnchorPoint.y,n).point,a=i.lineStartIndex+i.segment+1,o=new t.P(n.lineVertexArray.getx(a),n.lineVertexArray.gety(a)),s=ht(o.x,o.y,n),c=s.signedDistanceFromCamera>0?s.point:pt(n.tileAnchorPoint,o,e,1,n),l=gt(e.x,e.y,n,r),d=gt(c.x,c.y,n,r),f=dt(i.writingMode,l,d,u);if(f)return f}let e=bt(f*c.getoffsetX(i.glyphStartIndex),p,m,o,i.segment,i.lineStartIndex,i.lineStartIndex+i.lineLength,n,d);if(!e||n.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};h=[e]}for(let e of h)t.aD(l,e.point,e.angle);return{}}function pt(e,t,n,r,i){let a=e.add(e.sub(t)._unit()),o=ht(a.x,a.y,i).point,s=n.sub(o);return n.add(s._mult(r/s.mag()))}function mt(e,n,r){let i=n.projectionCache;if(i.projections[e])return i.projections[e];let a=new t.P(n.lineVertexArray.getx(e),n.lineVertexArray.gety(e)),o=ht(a.x,a.y,n);if(o.signedDistanceFromCamera>0)return i.projections[e]=o.point,i.anyProjectionOccluded||=o.isOccluded,o.point;let s=e-r.direction;return pt(r.distanceFromAnchor===0?n.tileAnchorPoint:new t.P(n.lineVertexArray.getx(s),n.lineVertexArray.gety(s)),a,r.previousVertex,r.absOffsetX-r.distanceFromAnchor+1,n)}function ht(e,t,n){let r=e+n.translation[0],i=t+n.translation[1],a;return n.pitchWithMap?(a=ot(r,i,n.pitchedLabelPlaneMatrix,n.getElevation),a.isOccluded=!1):(a=n.transform.projectTileCoordinates(r,i,n.unwrappedTileID,n.getElevation),a.point.x=(.5*a.point.x+.5)*n.width,a.point.y=(.5*-a.point.y+.5)*n.height),a}function gt(e,n,r,i){if(r.pitchWithMap){let a=[e,n,0,1];return t.aE(a,a,i),r.transform.projectTileCoordinates(a[0]/a[3],a[1]/a[3],r.unwrappedTileID,r.getElevation).point}return{x:e/r.width*2-1,y:1-n/r.height*2}}function _t(e,t,n){return n.transform.projectTileCoordinates(e,t,n.unwrappedTileID,n.getElevation)}function vt(e,t,n){return e._unit()._perp()._mult(t*n)}function yt(e,n,r,i,a,o,s,c,l){if(c.projectionCache.offsets[e])return c.projectionCache.offsets[e];let u=r.add(n);if(e+l.direction<i||e+l.direction>=a)return c.projectionCache.offsets[e]=u,u;let d=mt(e+l.direction,c,l),f=vt(d.sub(r),s,l.direction),p=r.add(f),m=d.add(f);return c.projectionCache.offsets[e]=t.aF(o,u,p,m)||u,c.projectionCache.offsets[e]}function bt(e,t,n,r,i,a,o,s,c){let l=r?e-t:e+t,u=l>0?1:-1,d=0;r&&(u*=-1,d=Math.PI),u<0&&(d+=Math.PI);let f,p=u>0?a+i:a+i+1;s.projectionCache.cachedAnchorPoint?f=s.projectionCache.cachedAnchorPoint:(f=ht(s.tileAnchorPoint.x,s.tileAnchorPoint.y,s).point,s.projectionCache.cachedAnchorPoint=f);let m,h,g=f,_=f,v=0,y=0,b=Math.abs(l),x=[],S;for(;v+y<=b;){if(p+=u,p<a||p>=o)return null;v+=y,_=g,h=m;let e={absOffsetX:b,direction:u,distanceFromAnchor:v,previousVertex:_};if(g=mt(p,s,e),n===0)x.push(_),S=g.sub(_);else{let t,r=g.sub(_);t=r.mag()===0?vt(mt(p+u,s,e).sub(g),n,u):vt(r,n,u),h||=_.add(t),m=yt(p,t,g,a,o,h,n,s,e),x.push(h),S=m.sub(h)}y=S.mag()}let C=S._mult((b-v)/y)._add(h||_),w=d+Math.atan2(g.y-_.y,g.x-_.x);return x.push(C),{point:C,angle:c?w:0,path:x}}let xt=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function St(e,t){for(let n=0;n<e;n++){let e=t.length;t.resize(e+4),t.float32.set(xt,3*e)}}function Ct(e,t,n){let r=t[0],i=t[1];return e[0]=n[0]*r+n[4]*i+n[12],e[1]=n[1]*r+n[5]*i+n[13],e[3]=n[3]*r+n[7]*i+n[15],e}class wt{constructor(e,t=new I(e.width+200,e.height+200,25),n=new I(e.width+200,e.height+200,25)){this.transform=e,this.grid=t,this.ignoredGrid=n,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,n,r,i,a,o,s,c,l,u,d){let f=this.projectAndGetPerspectiveRatio(e.anchorPointX+s[0],e.anchorPointY+s[1],i,l,d),p=n*f.perspectiveRatio,m;if(a||o)m=this._projectCollisionBox(e,p,r,i,a,o,s,f,l,u,d);else{let t=f.x+(u?u.x*p:0),n=f.y+(u?u.y*p:0);m={allPointsOccluded:!1,box:[t+e.x1*p,n+e.y1*p,t+e.x2*p,n+e.y2*p]}}let[h,g,_,v]=m.box,y=a?m.allPointsOccluded:f.isOccluded,b=y;return b||=f.perspectiveRatio<this.perspectiveRatioCutoff,b||=!this.isInsideGrid(h,g,_,v),b||t!==`always`&&this.grid.hitTest(h,g,_,v,t,c)?{box:[h,g,_,v],placeable:!1,offscreen:!1,occluded:y}:{box:[h,g,_,v],placeable:!0,offscreen:this.isOffscreen(h,g,_,v),occluded:y}}placeCollisionCircles(e,n,r,i,a,o,s,c,l,u,d,f,p,m){let h=[],g=new t.P(n.anchorX,n.anchorY),_=this.getPerspectiveRatio(g.x,g.y,o,m),v=(l?a*this.transform.getPitchedTextCorrection(n.anchorX,n.anchorY,o)/_:a*_)/t.aJ,y={getElevation:m,pitchedLabelPlaneMatrix:s,lineVertexArray:r,pitchWithMap:l,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:this.transform,tileAnchorPoint:g,unwrappedTileID:o,width:this.transform.width,height:this.transform.height,translation:p},b=ut(v,i,n.lineOffsetX*v,n.lineOffsetY*v,!1,n,!1,y),x=!1,S=!1,C=!0;if(b){let n=.5*d*_+f,r=new t.P(-100,-100),i=new t.P(this.screenRightBoundary,this.screenBottomBoundary),a=new $e,o=b.first,s=b.last,p=[];for(let e=o.path.length-1;e>=1;e--)p.push(o.path[e]);for(let e=1;e<s.path.length;e++)p.push(s.path[e]);let m=2.5*n;if(l){let e=this.projectPathToScreenSpace(p,y);p=e.some((e=>e.signedDistanceFromCamera<=0))?[]:e.map((e=>e.point))}let g=[];if(p.length>0){let e=p[0].clone(),n=p[0].clone();for(let t=1;t<p.length;t++)e.x=Math.min(e.x,p[t].x),e.y=Math.min(e.y,p[t].y),n.x=Math.max(n.x,p[t].x),n.y=Math.max(n.y,p[t].y);g=e.x>=r.x&&n.x<=i.x&&e.y>=r.y&&n.y<=i.y?[p]:n.x<r.x||e.x>i.x||n.y<r.y||e.y>i.y?[]:t.aG([p],r.x,r.y,i.x,i.y)}for(let t of g){a.reset(t,.25*n);let r=0;r=a.length<=.5*n?1:Math.ceil(a.paddedLength/m)+1;for(let t=0;t<r;t++){let i=t/Math.max(r-1,1),o=a.lerp(i),s=o.x+100,l=o.y+100;h.push(s,l,n,0);let d=s-n,f=l-n,p=s+n,m=l+n;if(C&&=this.isOffscreen(d,f,p,m),S||=this.isInsideGrid(d,f,p,m),e!==`always`&&this.grid.hitTestCircle(s,l,n,e,u)&&(x=!0,!c))return{circles:[],offscreen:!1,collisionDetected:x}}}}return{circles:!c&&x||!S||_<this.perspectiveRatioCutoff?[]:h,offscreen:C,collisionDetected:x}}projectPathToScreenSpace(e,t){return function(e){let t=0,n=0,r=0,i=0;for(let a=0;a<e.length;a++)e[a].isOccluded?(r=a+1,i=0):(i++,i>n&&(n=i,t=r));return e.slice(t,t+n)}(function(e,t){let n=nt;return function(e,t){let n=1/(t[0]*t[5]-t[1]*t[4]);e[0]=t[5]*n,e[1]=-t[1]*n,e[2]=0,e[3]=0,e[4]=-t[4]*n,e[5]=t[0]*n,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]}(n,t.pitchedLabelPlaneMatrix),e.map((e=>{let r=ot(e.x,e.y,n,t.getElevation),i=t.transform.projectTileCoordinates(r.point.x,r.point.y,t.unwrappedTileID,t.getElevation);return i.point.x=(.5*i.point.x+.5)*t.width,i.point.y=(.5*-i.point.y+.5)*t.height,i}))}(e,t))}queryRenderedSymbols(e){if(e.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};let n=[],r=new t.a8;for(let i of e){let e=new t.P(i.x+100,i.y+100);r.extend(e),n.push(e)}let{minX:i,minY:a,maxX:o,maxY:s}=r,c=this.grid.query(i,a,o,s).concat(this.ignoredGrid.query(i,a,o,s)),l={},u={};for(let e of c){let r=e.key;if(l[r.bucketInstanceId]===void 0&&(l[r.bucketInstanceId]={}),l[r.bucketInstanceId][r.featureIndex])continue;let i=[new t.P(e.x1,e.y1),new t.P(e.x2,e.y1),new t.P(e.x2,e.y2),new t.P(e.x1,e.y2)];t.aH(n,i)&&(l[r.bucketInstanceId][r.featureIndex]=!0,u[r.bucketInstanceId]===void 0&&(u[r.bucketInstanceId]=[]),u[r.bucketInstanceId].push(r.featureIndex))}return u}insertCollisionBox(e,t,n,r,i,a){(n?this.ignoredGrid:this.grid).insert({bucketInstanceId:r,featureIndex:i,collisionGroupID:a,overlapMode:t},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,n,r,i,a){let o=n?this.ignoredGrid:this.grid,s={bucketInstanceId:r,featureIndex:i,collisionGroupID:a,overlapMode:t};for(let t=0;t<e.length;t+=4)o.insertCircle(s,e[t],e[t+1],e[t+2])}projectAndGetPerspectiveRatio(e,n,r,i,a){if(a){let r;i?(r=[e,n,i(e,n),1],t.aE(r,r,a)):(r=[e,n,0,1],Ct(r,r,a));let o=r[3];return{x:(r[0]/o+1)/2*this.transform.width+100,y:(-r[1]/o+1)/2*this.transform.height+100,perspectiveRatio:.5+this.transform.cameraToCenterDistance/o*.5,isOccluded:!1,signedDistanceFromCamera:o}}{let t=this.transform.projectTileCoordinates(e,n,r,i);return{x:(t.point.x+1)/2*this.transform.width+100,y:(1-t.point.y)/2*this.transform.height+100,perspectiveRatio:.5+this.transform.cameraToCenterDistance/t.signedDistanceFromCamera*.5,isOccluded:t.isOccluded,signedDistanceFromCamera:t.signedDistanceFromCamera}}}getPerspectiveRatio(e,t,n,r){let i=this.transform.projectTileCoordinates(e,t,n,r);return .5+this.transform.cameraToCenterDistance/i.signedDistanceFromCamera*.5}isOffscreen(e,t,n,r){return n<100||e>=this.screenRightBoundary||r<100||t>this.screenBottomBoundary}isInsideGrid(e,t,n,r){return n>=0&&e<this.gridRightBoundary&&r>=0&&t<this.gridBottomBoundary}getViewportMatrix(){let e=t.ap([]);return t.Q(e,e,[-100,-100,0]),e}_projectCollisionBox(e,n,r,i,a,o,s,c,l,u,d){let f=1,p=0,m=0,h=1,g=e.anchorPointX+s[0],_=e.anchorPointY+s[1];if(o&&!a){let e=this.projectAndGetPerspectiveRatio(g+1,_,i,l,d),t=e.x-c.x,n=Math.atan((e.y-c.y)/t)+(t<0?Math.PI:0),r=Math.sin(n),a=Math.cos(n);f=a,p=r,m=-r,h=a}else if(!o&&a){let e=at(this.transform);f=e.vecEast[0],p=e.vecEast[1],m=e.vecSouth[0],h=e.vecSouth[1]}let v=c.x,y=c.y,b=n;a&&(v=g,y=_,b=2**-(this.transform.zoom-r.overscaledZ),b*=this.transform.getPitchedTextCorrection(g,_,i),u||(b*=t.al(.5+c.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4))),u&&(v+=f*u.x*b+m*u.y*b,y+=p*u.x*b+h*u.y*b);let x=e.x1*b,S=e.x2*b,C=(x+S)/2,w=e.y1*b,T=e.y2*b,E=(w+T)/2,D=[{offsetX:x,offsetY:w},{offsetX:C,offsetY:w},{offsetX:S,offsetY:w},{offsetX:S,offsetY:E},{offsetX:S,offsetY:T},{offsetX:C,offsetY:T},{offsetX:x,offsetY:T},{offsetX:x,offsetY:E}],O=[];for(let{offsetX:e,offsetY:n}of D)O.push(new t.P(v+f*e+m*n,y+p*e+h*n));let k=!1;if(a){let e=O.map((e=>this.projectAndGetPerspectiveRatio(e.x,e.y,i,l,d)));k=e.some((e=>!e.isOccluded)),O=e.map((e=>new t.P(e.x,e.y)))}else k=!0;return{box:t.aI(O),allPointsOccluded:!k}}}class Tt{constructor(e,t,n,r){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):r&&n?1:0,this.placed=n}isHidden(){return this.opacity===0&&!this.placed}}class Et{constructor(e,t,n,r,i){this.text=new Tt(e?e.text:null,t,n,i),this.icon=new Tt(e?e.icon:null,t,r,i)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Dt{constructor(e,t,n){this.text=e,this.icon=t,this.skipFade=n}}class R{constructor(e,t,n,r,i){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=n,this.bucketIndex=r,this.tileID=i}}class Ot{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 kt(e,n,r,i,a){let{horizontalAlign:o,verticalAlign:s}=t.aP(e);return new t.P(-(o-.5)*n+i[0]*a,-(s-.5)*r+i[1]*a)}class At{constructor(e,t,n,r,i){this.transform=e.clone(),this.terrain=t,this.collisionIndex=new wt(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=n,this.retainedQueryData={},this.collisionGroups=new Ot(r),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=i,i&&(i.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){let t=this.terrain;return t?(n,r)=>t.getElevation(e,n,r):null}getBucketParts(e,n,r,i){let a=r.getBucket(n),o=r.latestFeatureIndex;if(!a||!o||n.id!==a.layerIds[0])return;let s=r.collisionBoxArray,c=a.layers[0].layout,l=a.layers[0].paint,u=2**(this.transform.zoom-r.tileID.overscaledZ),d=r.tileSize/t.a6,f=r.tileID.toUnwrapped(),p=c.get(`text-rotation-alignment`)===`map`,m=t.aK(r,1,this.transform.zoom),h=t.aL(this.collisionIndex.transform,r,l.get(`text-translate`),l.get(`text-translate-anchor`)),g=t.aL(this.collisionIndex.transform,r,l.get(`icon-translate`),l.get(`icon-translate-anchor`)),_=rt(p,this.transform,m);this.retainedQueryData[a.bucketInstanceId]=new R(a.bucketInstanceId,o,a.sourceLayerIndex,a.index,r.tileID);let v={bucket:a,layout:c,translationText:h,translationIcon:g,unwrappedTileID:f,pitchedLabelPlaneMatrix:_,scale:u,textPixelRatio:d,holdingForFade:r.holdingForSymbolFade(),collisionBoxArray:s,partiallyEvaluatedTextSize:t.aw(a.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(i)for(let t of a.sortKeyRanges){let{sortKey:n,symbolInstanceStart:r,symbolInstanceEnd:i}=t;e.push({sortKey:n,symbolInstanceStart:r,symbolInstanceEnd:i,parameters:v})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:v})}attemptAnchorPlacement(e,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b){var x,S;let C=t.aM[e.textAnchor],w=[e.textOffset0,e.textOffset1],T=kt(C,r,i,w,a),E=this.collisionIndex.placeCollisionBox(n,f,c,l,u,s,o,g,d.predicate,y,T,b);if((!v||this.collisionIndex.placeCollisionBox(v,f,c,l,u,s,o,_,d.predicate,y,T,b).placeable)&&E.placeable){let e;if((x=this.prevPlacement)!=null&&x.variableOffsets[p.crossTileID]&&(S=this.prevPlacement?.placements[p.crossTileID])!=null&&S.text&&(e=this.prevPlacement.variableOffsets[p.crossTileID].anchor),p.crossTileID===0)throw Error(`symbolInstance.crossTileID can't be 0`);return this.variableOffsets[p.crossTileID]={textOffset:w,width:r,height:i,anchor:C,textBoxScale:a,prevAnchor:e},this.markUsedJustification(m,C,p,h),m.allowVerticalPlacement&&(this.markUsedOrientation(m,h,p),this.placedOrientations[p.crossTileID]=h),{shift:T,placedGlyphBoxes:E}}}placeLayerBucketPart(e,n,r){let{bucket:i,layout:a,translationText:o,translationIcon:s,unwrappedTileID:c,pitchedLabelPlaneMatrix:l,textPixelRatio:u,holdingForFade:d,collisionBoxArray:f,partiallyEvaluatedTextSize:p,collisionGroup:m}=e.parameters,h=a.get(`text-optional`),g=a.get(`icon-optional`),_=t.aN(a,`text-overlap`,`text-allow-overlap`),v=_===`always`,y=t.aN(a,`icon-overlap`,`icon-allow-overlap`),b=y===`always`,x=a.get(`text-rotation-alignment`)===`map`,S=a.get(`text-pitch-alignment`)===`map`,C=a.get(`icon-text-fit`)!==`none`,w=a.get(`symbol-z-order`)===`viewport-y`,T=v&&(b||!i.hasIconData()||g),E=b&&(v||!i.hasTextData()||h);!i.collisionArrays&&f&&i.deserializeCollisionBoxes(f);let D=this.retainedQueryData[i.bucketInstanceId].tileID,O=this._getTerrainElevationFunc(D),k=this.transform.getFastPathSimpleProjectionMatrix(D),A=(e,f,b)=>{if(n[e.crossTileID])return;if(d)return void(this.placements[e.crossTileID]=new Dt(!1,!1,!1));let w=!1,A=!1,ee=!0,te=null,j={box:null,placeable:!1,offscreen:null,occluded:!1},ne={placeable:!1},re=null,ie=null,ae=null,oe=0,se=0,ce=0;f.textFeatureIndex?oe=f.textFeatureIndex:e.useRuntimeCollisionCircles&&(oe=e.featureIndex),f.verticalTextFeatureIndex&&(se=f.verticalTextFeatureIndex);let le=f.textBox;if(le){let n=n=>{let r=t.ax.horizontal;if(i.allowVerticalPlacement&&!n&&this.prevPlacement){let t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,r=t,this.markUsedOrientation(i,r,e))}return r},a=(n,r)=>{if(i.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&f.verticalTextBox){for(let e of i.writingModes)if(e===t.ax.vertical?(j=r(),ne=j):j=n(),j?.placeable)break}else j=n()},l=e.textAnchorOffsetStartIndex,d=e.textAnchorOffsetEndIndex;if(d===l){let r=(t,n)=>{let r=this.collisionIndex.placeCollisionBox(t,_,u,D,c,S,x,o,m.predicate,O,void 0,k);return r!=null&&r.placeable&&(this.markUsedOrientation(i,n,e),this.placedOrientations[e.crossTileID]=n),r};a((()=>r(le,t.ax.horizontal)),(()=>{let n=f.verticalTextBox;return i.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&n?r(n,t.ax.vertical):{box:null,offscreen:null}})),n(j?.placeable)}else{let p=t.aM[this.prevPlacement?.variableOffsets[e.crossTileID]?.anchor],h=(t,n,a)=>{let f=t.x2-t.x1,h=t.y2-t.y1,g=e.textBoxScale,v=C&&y===`never`?n:null,b=null,T=_===`never`?1:2,E=`never`;p&&T++;for(let n=0;n<T;n++){for(let n=l;n<d;n++){let r=i.textAnchorOffsets.get(n);if(p&&r.textAnchor!==p)continue;let l=this.attemptAnchorPlacement(r,t,f,h,g,x,S,u,D,c,m,E,e,i,a,o,s,v,O);if(l&&(b=l.placedGlyphBoxes,b?.placeable))return w=!0,te=l.shift,b}p?p=null:E=_}return r&&!b&&(b={box:this.collisionIndex.placeCollisionBox(le,`always`,u,D,c,S,x,o,m.predicate,O,void 0,k).box,offscreen:!1,placeable:!1,occluded:!1}),b};a((()=>h(le,f.iconBox,t.ax.horizontal)),(()=>{let n=f.verticalTextBox;return i.allowVerticalPlacement&&!j?.placeable&&e.numVerticalGlyphVertices>0&&n?h(n,f.verticalIconBox,t.ax.vertical):{box:null,occluded:!0,offscreen:null}})),j&&(w=j.placeable,ee=j.offscreen);let g=n(j?.placeable);if(!w&&this.prevPlacement){let t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(i,t.anchor,e,g))}}}if(re=j,w=re?.placeable,ee=re?.offscreen,e.useRuntimeCollisionCircles&&e.centerJustifiedTextSymbolIndex>=0){let n=i.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),s=t.ay(i.textSizeData,p,n),u=a.get(`text-padding`);ie=this.collisionIndex.placeCollisionCircles(_,n,i.lineVertexArray,i.glyphOffsetArray,s,c,l,r,S,m.predicate,e.collisionCircleDiameter,u,o,O),ie.circles.length&&ie.collisionDetected&&!r&&t.w(`Collisions detected, but collision boxes are not shown`),w=v||ie.circles.length>0&&!ie.collisionDetected,ee&&=ie.offscreen}if(f.iconFeatureIndex&&(ce=f.iconFeatureIndex),f.iconBox){let e=e=>this.collisionIndex.placeCollisionBox(e,y,u,D,c,S,x,s,m.predicate,O,C&&te?te:void 0,k);ne&&ne.placeable&&f.verticalIconBox?(ae=e(f.verticalIconBox),A=ae.placeable):(ae=e(f.iconBox),A=ae.placeable),ee&&=ae.offscreen}let ue=h||e.numHorizontalGlyphVertices===0&&e.numVerticalGlyphVertices===0,de=g||e.numIconVertices===0;ue||de?de?ue||(A&&=w):w=A&&w:A=w=A&&w;let fe=A&&ae.placeable;if(w&&re.placeable&&this.collisionIndex.insertCollisionBox(re.box,_,a.get(`text-ignore-placement`),i.bucketInstanceId,ne&&ne.placeable&&se?se:oe,m.ID),fe&&this.collisionIndex.insertCollisionBox(ae.box,y,a.get(`icon-ignore-placement`),i.bucketInstanceId,ce,m.ID),ie&&w&&this.collisionIndex.insertCollisionCircles(ie.circles,_,a.get(`text-ignore-placement`),i.bucketInstanceId,oe,m.ID),r&&this.storeCollisionData(i.bucketInstanceId,b,f,re,ae,ie),e.crossTileID===0)throw Error(`symbolInstance.crossTileID can't be 0`);if(i.bucketInstanceId===0)throw Error(`bucket.bucketInstanceId can't be 0`);this.placements[e.crossTileID]=new Dt((w||T)&&!re?.occluded,(A||E)&&!ae?.occluded,ee||i.justReloaded),n[e.crossTileID]=!0};if(w){if(e.symbolInstanceStart!==0)throw Error(`bucket.bucketInstanceId should be 0`);let t=i.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=t.length-1;e>=0;--e){let n=t[e];A(i.symbolInstances.get(n),i.collisionArrays[n],n)}}else for(let t=e.symbolInstanceStart;t<e.symbolInstanceEnd;t++)A(i.symbolInstances.get(t),i.collisionArrays[t],t);i.justReloaded=!1}storeCollisionData(e,t,n,r,i,a){if(n.textBox||n.iconBox){let a,o;this.collisionBoxArrays.has(e)?a=this.collisionBoxArrays.get(e):(a=new Map,this.collisionBoxArrays.set(e,a)),a.has(t)?o=a.get(t):(o={text:null,icon:null},a.set(t,o)),n.textBox&&(o.text=r.box),n.iconBox&&(o.icon=i.box)}if(a){let t=this.collisionCircleArrays[e];t===void 0&&(t=this.collisionCircleArrays[e]=[]);for(let e=0;e<a.circles.length;e+=4)t.push(a.circles[e+0]-100),t.push(a.circles[e+1]-100),t.push(a.circles[e+2]),t.push(+!!a.collisionDetected)}}markUsedJustification(e,n,r,i){let a;a=i===t.ax.vertical?r.verticalPlacedTextSymbolIndex:{left:r.leftJustifiedTextSymbolIndex,center:r.centerJustifiedTextSymbolIndex,right:r.rightJustifiedTextSymbolIndex}[t.aO(n)];let o=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex,r.verticalPlacedTextSymbolIndex];for(let t of o)t>=0&&(e.text.placedSymbolArray.get(t).crossTileID=a>=0&&t!==a?0:r.crossTileID)}markUsedOrientation(e,n,r){let i=n===t.ax.horizontal||n===t.ax.horizontalOnly?n:0,a=n===t.ax.vertical?n:0,o=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];for(let t of o)e.text.placedSymbolArray.get(t).placedOrientation=i;r.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).placedOrientation=a)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;let t=this.prevPlacement,n=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;let r=t?t.symbolFadeChange(e):1,i=t?t.opacities:{},a=t?t.variableOffsets:{},o=t?t.placedOrientations:{};for(let e in this.placements){let t=this.placements[e],a=i[e];a?(this.opacities[e]=new Et(a,r,t.text,t.icon),n||=t.text!==a.text.placed,n||=t.icon!==a.icon.placed):(this.opacities[e]=new Et(null,r,t.text,t.icon,t.skipFade),n||=t.text||t.icon)}for(let e in i){let t=i[e];if(!this.opacities[e]){let i=new Et(t,r,!1,!1);i.isHidden()||(this.opacities[e]=i,n||=t.text.placed,n||=t.icon.placed)}}for(let e in a)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=a[e]);for(let e in o)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=o[e]);if(t&&t.lastPlacementChangeTime===void 0)throw Error(`Last placement time for previous placement is not defined`);n?this.lastPlacementChangeTime=e:typeof this.lastPlacementChangeTime!=`number`&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){let n={};for(let r of t){let t=r.getBucket(e);t&&r.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,r.tileID,n,r.collisionBoxArray)}}updateBucketOpacities(e,n,r,i){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();let a=e.layers[0],o=a.layout,s=new Et(null,0,!1,!1,!0),c=o.get(`text-allow-overlap`),l=o.get(`icon-allow-overlap`),u=a._unevaluatedLayout.hasValue(`text-variable-anchor`)||a._unevaluatedLayout.hasValue(`text-variable-anchor-offset`),d=o.get(`text-rotation-alignment`)===`map`,f=o.get(`text-pitch-alignment`)===`map`,p=o.get(`icon-text-fit`)!==`none`,m=new Et(null,0,c&&(l||!e.hasIconData()||o.get(`icon-optional`)),l&&(c||!e.hasTextData()||o.get(`text-optional`)),!0);!e.collisionArrays&&i&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(i);let h=(e,t,n)=>{for(let r=0;r<t/4;r++)e.opacityVertexArray.emplaceBack(n);e.hasVisibleVertices||=n!==Lt},g=this.collisionBoxArrays.get(e.bucketInstanceId);for(let n=0;n<e.symbolInstances.length;n++){let i=e.symbolInstances.get(n),{numHorizontalGlyphVertices:a,numVerticalGlyphVertices:o,crossTileID:c}=i,l=this.opacities[c];r[c]?l=s:l||(l=m,this.opacities[c]=l),r[c]=!0;let _=i.numIconVertices>0,v=this.placedOrientations[i.crossTileID],y=v===t.ax.vertical,b=v===t.ax.horizontal||v===t.ax.horizontalOnly;if(a>0||o>0){let t=It(l.text);h(e.text,a,y?Lt:t),h(e.text,o,b?Lt:t);let n=l.text.isHidden(),r=[i.rightJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.leftJustifiedTextSymbolIndex];for(let t of r)t>=0&&(e.text.placedSymbolArray.get(t).hidden=n||y?1:0);i.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(i.verticalPlacedTextSymbolIndex).hidden=n||b?1:0);let s=this.variableOffsets[i.crossTileID];s&&this.markUsedJustification(e,s.anchor,i,v);let c=this.placedOrientations[i.crossTileID];c&&(this.markUsedJustification(e,`left`,i,c),this.markUsedOrientation(e,c,i))}if(_){let t=It(l.icon),n=!(p&&i.verticalPlacedIconSymbolIndex&&y);i.placedIconSymbolIndex>=0&&(h(e.icon,i.numIconVertices,n?t:Lt),e.icon.placedSymbolArray.get(i.placedIconSymbolIndex).hidden=l.icon.isHidden()),i.verticalPlacedIconSymbolIndex>=0&&(h(e.icon,i.numVerticalIconVertices,n?Lt:t),e.icon.placedSymbolArray.get(i.verticalPlacedIconSymbolIndex).hidden=l.icon.isHidden())}let x=g?.has(n)?g.get(n):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){let r=e.collisionArrays[n];if(r){let n=new t.P(0,0);if(r.textBox||r.verticalTextBox){let t=!0;if(u){let e=this.variableOffsets[c];e?(n=kt(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),d&&n._rotate(f?-this.transform.bearingInRadians:this.transform.bearingInRadians)):t=!1}if(r.textBox||r.verticalTextBox){let i;r.textBox&&(i=y),r.verticalTextBox&&(i=b),jt(e.textCollisionBox.collisionVertexArray,l.text.placed,!t||i,x.text,n.x,n.y)}}if(r.iconBox||r.verticalIconBox){let t=!!(!b&&r.verticalIconBox),i;r.iconBox&&(i=t),r.verticalIconBox&&(i=!t),jt(e.iconCollisionBox.collisionVertexArray,l.icon.placed,i,x.icon,p?n.x:0,p?n.y:0)}}}}if(e.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.bucketInstanceId])}symbolFadeChange(e){return this.fadeDuration===0?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(e,t){let n=this.zoomAtLastRecencyCheck===t?1-this.zoomAdjustment(t):1;return this.zoomAtLastRecencyCheck=t,this.commitTime+this.fadeDuration*n>e}setStale(){this.stale=!0}}function jt(e,t,n,r,i,a){r&&r.length!==0||(r=[0,0,0,0]);let o=r[0]-100,s=r[1]-100,c=r[2]-100,l=r[3]-100;e.emplaceBack(+!!t,+!!n,i||0,a||0,o,s),e.emplaceBack(+!!t,+!!n,i||0,a||0,c,s),e.emplaceBack(+!!t,+!!n,i||0,a||0,c,l),e.emplaceBack(+!!t,+!!n,i||0,a||0,o,l)}let Mt=2**25,Nt=2**24,Pt=2**17,Ft=2**16;function It(e){if(e.opacity===0&&!e.placed)return 0;if(e.opacity===1&&e.placed)return 4294967295;let t=+!!e.placed,n=Math.floor(127*e.opacity);return n*Mt+t*Nt+n*Pt+t*Ft+n*512+t*256+n*2+t}let Lt=0;class Rt{constructor(e){this._sortAcrossTiles=e.layout.get(`symbol-z-order`)!==`viewport-y`&&!e.layout.get(`symbol-sort-key`).isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,t,n,r,i){let a=this._bucketParts;for(;this._currentTileIndex<e.length;)if(t.getBucketParts(a,r,e[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,i())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,a.sort(((e,t)=>e.sortKey-t.sortKey)));this._currentPartIndex<a.length;)if(t.placeLayerBucketPart(a[this._currentPartIndex],this._seenCrossTileIDs,n),this._currentPartIndex++,i())return!0;return!1}}class zt{constructor(e,t,n,r,i,a,o,s){this.placement=new At(e,t,a,o,s),this._currentPlacementIndex=n.length-1,this._forceFullPlacement=r,this._showCollisionBoxes=i,this._done=!1}isDone(){return this._done}continuePlacement(e,n,r){let i=l(),a=()=>!this._forceFullPlacement&&l()-i>2;for(;this._currentPlacementIndex>=0;){let i=n[e[this._currentPlacementIndex]],o=this.placement.collisionIndex.transform.zoom;if(t.aQ(i)&&i.layout&&(!i.minzoom||i.minzoom<=o)&&(!i.maxzoom||i.maxzoom>o)){if(this._inProgressLayer||=new Rt(i),this._inProgressLayer.continuePlacement(r[i.source],this.placement,this._showCollisionBoxes,i,a))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}let Bt=512/t.a6/2;class Vt{constructor(e,n,r){this.tileID=e,this.bucketInstanceId=r,this._symbolsByKey={};let i=new Map;for(let e=0;e<n.length;e++){let t=n.get(e),r=t.key,a=i.get(r);a?a.push(t):i.set(r,[t])}for(let[e,n]of i){let r={positions:n.map((e=>({x:Math.floor(e.anchorX*Bt),y:Math.floor(e.anchorY*Bt)}))),crossTileIDs:n.map((e=>e.crossTileID))};if(r.positions.length>128){let e=new t.aR(r.positions.length,16,Uint16Array);for(let{x:t,y:n}of r.positions)e.add(t,n);e.finish(),delete r.positions,r.index=e}this._symbolsByKey[e]=r}}getScaledCoordinates(e,n){let{x:r,y:i,z:a}=this.tileID.canonical,{x:o,y:s,z:c}=n.canonical,l=Bt/2**(c-a),u=(s*t.a6+e.anchorY)*l,d=i*t.a6*Bt;return{x:Math.floor((o*t.a6+e.anchorX)*l-r*t.a6*Bt),y:Math.floor(u-d)}}findMatches(e,t,n){let r=this.tileID.canonical.z<t.canonical.z?1:2**(this.tileID.canonical.z-t.canonical.z);for(let i=0;i<e.length;i++){let a=e.get(i);if(a.crossTileID)continue;let o=this._symbolsByKey[a.key];if(!o)continue;let s=this.getScaledCoordinates(a,t);if(o.index){let e=o.index.range(s.x-r,s.y-r,s.x+r,s.y+r).sort();for(let t of e){let e=o.crossTileIDs[t];if(!n[e]){n[e]=!0,a.crossTileID=e;break}}}else if(o.positions)for(let e=0;e<o.positions.length;e++){let t=o.positions[e],i=o.crossTileIDs[e];if(Math.abs(t.x-s.x)<=r&&Math.abs(t.y-s.y)<=r&&!n[i]){n[i]=!0,a.crossTileID=i;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map((({crossTileIDs:e})=>e))}}class Ht{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Ut{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){let t=Math.round((e-this.lng)/360);if(t!==0)for(let e in this.indexes){let n=this.indexes[e],r={};for(let e in n){let i=n[e];i.tileID=i.tileID.unwrapTo(i.tileID.wrap+t),r[i.tileID.key]=i}this.indexes[e]=r}this.lng=e}addBucket(e,t,n){var r,i;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 e=0;e<t.symbolInstances.length;e++)t.symbolInstances.get(e).crossTileID=0;(r=this.usedCrossTileIDs)[i=e.overscaledZ]||(r[i]={});let a=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 i=r[n];i.tileID.isChildOf(e)&&i.findMatches(t.symbolInstances,e,a)}else{let i=r[e.scaledTo(Number(n)).key];i&&i.findMatches(t.symbolInstances,e,a)}}for(let e=0;e<t.symbolInstances.length;e++){let r=t.symbolInstances.get(e);r.crossTileID||(r.crossTileID=n.generate(),a[r.crossTileID]=!0)}return this.indexes[e.overscaledZ]===void 0&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new Vt(e,t.symbolInstances,t.bucketInstanceId),!0}removeBucketCrossTileIDs(e,t){for(let n of t.getCrossTileIDsLists())for(let t of n)delete this.usedCrossTileIDs[e][t]}removeStaleBuckets(e){let t=!1;for(let n in this.indexes){let r=this.indexes[n];for(let i in r)e[r[i].bucketInstanceId]||(this.removeBucketCrossTileIDs(n,r[i]),delete r[i],t=!0)}return t}}class Wt{constructor(){this.layerIndexes={},this.crossTileIDs=new Ht,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,t,n){let r=this.layerIndexes[e.id];r===void 0&&(r=this.layerIndexes[e.id]=new Ut);let i=!1,a={};r.handleWrapJump(n);for(let n of t){let t=n.getBucket(e);e.id===t?.layerIds[0]&&(t.bucketInstanceId||=(this.maxBucketInstanceId+=1,this.maxBucketInstanceId),r.addBucket(n.tileID,t,this.crossTileIDs)&&(i=!0),a[t.bucketInstanceId]=!0)}return r.removeStaleBuckets(a)&&(i=!0),i}pruneUnusedLayers(e){let t={};for(let n of e)t[n]=!0;for(let e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}var Gt=`void main() {fragColor=vec4(1.0);}`;let Kt={prelude:qt(`#ifdef GL_ES
4
+ precision mediump float;
5
+ #else
6
+ #if !defined(lowp)
7
+ #define lowp
8
+ #endif
9
+ #if !defined(mediump)
10
+ #define mediump
11
+ #endif
12
+ #if !defined(highp)
13
+ #define highp
14
+ #endif
15
+ #endif
16
+ out highp vec4 fragColor;`,`#ifdef GL_ES
17
+ precision highp float;
18
+ #else
19
+ #if !defined(lowp)
20
+ #define lowp
21
+ #endif
22
+ #if !defined(mediump)
23
+ #define mediump
24
+ #endif
25
+ #if !defined(highp)
26
+ #define highp
27
+ #endif
28
+ #endif
29
+ vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0
30
+ );}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
31
+ );}
32
+ #ifdef TERRAIN3D
33
+ uniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;
34
+ #endif
35
+ const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {
36
+ #ifdef TERRAIN3D
37
+ highp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));
38
+ #else
39
+ return 1.0;
40
+ #endif
41
+ }float calculate_visibility(vec4 pos) {
42
+ #ifdef TERRAIN3D
43
+ vec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;
44
+ #else
45
+ return 1.0;
46
+ #endif
47
+ }float ele(vec2 pos) {
48
+ #ifdef TERRAIN3D
49
+ vec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;
50
+ #else
51
+ return 0.0;
52
+ #endif
53
+ }float get_elevation(vec2 pos) {
54
+ #ifdef TERRAIN3D
55
+ #ifdef GLOBE
56
+ if ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}
57
+ #endif
58
+ vec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;
59
+ #else
60
+ return 0.0;
61
+ #endif
62
+ }const float PI=3.141592653589793;uniform mat4 u_projection_matrix;`),projectionMercator:qt(``,`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:qt(``,`#define GLOBE_RADIUS 6371008.8
63
+ uniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos
64
+ );}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY);
65
+ if (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len
66
+ );if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}`),background:qt(`uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;
67
+ #ifdef OVERDRAW_INSPECTOR
68
+ fragColor=vec4(1.0);
69
+ #endif
70
+ }`,`in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}`),backgroundPattern:qt(`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;
71
+ #ifdef OVERDRAW_INSPECTOR
72
+ fragColor=vec4(1.0);
73
+ #endif
74
+ }`,`uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}`),circle:qt(`in vec3 v_data;in float v_visibility;
75
+ #pragma mapbox: define highp vec4 color
76
+ #pragma mapbox: define mediump float radius
77
+ #pragma mapbox: define lowp float blur
78
+ #pragma mapbox: define lowp float opacity
79
+ #pragma mapbox: define highp vec4 stroke_color
80
+ #pragma mapbox: define mediump float stroke_width
81
+ #pragma mapbox: define lowp float stroke_opacity
82
+ void main() {
83
+ #pragma mapbox: initialize highp vec4 color
84
+ #pragma mapbox: initialize mediump float radius
85
+ #pragma mapbox: initialize lowp float blur
86
+ #pragma mapbox: initialize lowp float opacity
87
+ #pragma mapbox: initialize highp vec4 stroke_color
88
+ #pragma mapbox: initialize mediump float stroke_width
89
+ #pragma mapbox: initialize lowp float stroke_opacity
90
+ vec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}
91
+ #ifdef OVERDRAW_INSPECTOR
92
+ fragColor=vec4(1.0);
93
+ #endif
94
+ }`,`uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out vec3 v_data;out float v_visibility;
95
+ #pragma mapbox: define highp vec4 color
96
+ #pragma mapbox: define mediump float radius
97
+ #pragma mapbox: define lowp float blur
98
+ #pragma mapbox: define lowp float opacity
99
+ #pragma mapbox: define highp vec4 stroke_color
100
+ #pragma mapbox: define mediump float stroke_width
101
+ #pragma mapbox: define lowp float stroke_opacity
102
+ void main(void) {
103
+ #pragma mapbox: initialize highp vec4 color
104
+ #pragma mapbox: initialize mediump float radius
105
+ #pragma mapbox: initialize lowp float blur
106
+ #pragma mapbox: initialize lowp float opacity
107
+ #pragma mapbox: initialize highp vec4 stroke_color
108
+ #pragma mapbox: initialize mediump float stroke_width
109
+ #pragma mapbox: initialize lowp float stroke_opacity
110
+ vec2 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {
111
+ #ifdef GLOBE
112
+ vec3 center_vector=projectToSphere(circle_center);
113
+ #endif
114
+ float angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {
115
+ #ifdef GLOBE
116
+ vec4 projected_center=interpolateProjection(circle_center,center_vector,ele);
117
+ #else
118
+ vec4 projected_center=projectTileWithElevation(circle_center,ele);
119
+ #endif
120
+ corner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}
121
+ #ifdef GLOBE
122
+ vec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);
123
+ #else
124
+ gl_Position=projectTileWithElevation(corner_position,ele);
125
+ #endif
126
+ } 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:qt(Gt,`in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}`),heatmap:qt(`uniform highp float u_intensity;in vec2 v_extrude;
127
+ #pragma mapbox: define highp float weight
128
+ #define GAUSS_COEF 0.3989422804014327
129
+ void main() {
130
+ #pragma mapbox: initialize highp float weight
131
+ float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);
132
+ #ifdef OVERDRAW_INSPECTOR
133
+ fragColor=vec4(1.0);
134
+ #endif
135
+ }`,`uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out vec2 v_extrude;
136
+ #pragma mapbox: define highp float weight
137
+ #pragma mapbox: define mediump float radius
138
+ const highp float ZERO=1.0/255.0/16.0;
139
+ #define GAUSS_COEF 0.3989422804014327
140
+ void main(void) {
141
+ #pragma mapbox: initialize highp float weight
142
+ #pragma mapbox: initialize mediump float radius
143
+ vec2 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 circle_center=floor(pos_raw/8.0);
144
+ #ifdef GLOBE
145
+ vec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);
146
+ #else
147
+ gl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));
148
+ #endif
149
+ }`),heatmapTexture:qt(`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;
150
+ #ifdef OVERDRAW_INSPECTOR
151
+ fragColor=vec4(0.0);
152
+ #endif
153
+ }`,`uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}`),collisionBox:qt(`in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}`,`in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}`),collisionCircle:qt(`in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);fragColor=color*alpha*opacity_t;}`,`in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}`),colorRelief:qt(`#ifdef GL_ES
154
+ precision highp float;
155
+ #endif
156
+ uniform sampler2D u_image;uniform vec4 u_unpack;uniform sampler2D u_elevation_stops;uniform sampler2D u_color_stops;uniform int u_color_ramp_size;uniform float u_opacity;in vec2 v_pos;float getElevation(vec2 coord) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}float getElevationStop(int stop) {float x=(float(stop)+0.5)/float(u_color_ramp_size);vec4 data=texture(u_elevation_stops,vec2(x,0))*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {float el=getElevation(v_pos);int r=(u_color_ramp_size-1);int l=0;float el_l=getElevationStop(l);float el_r=getElevationStop(r);while(r-l > 1){int m=(r+l)/2;float el_m=getElevationStop(m);if(el < el_m){r=m;el_r=el_m;}else
157
+ {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));
158
+ #ifdef OVERDRAW_INSPECTOR
159
+ fragColor=vec4(1.0);
160
+ #endif
161
+ }`,`uniform vec2 u_dimension;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_pos/8192.0)*scale+epsilon;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}`),debug:qt(`uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}`,`in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}`),depth:qt(Gt,`in vec2 a_pos;void main() {
162
+ #ifdef GLOBE
163
+ gl_Position=projectTileFor3D(a_pos,0.0);
164
+ #else
165
+ gl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);
166
+ #endif
167
+ }`),fill:qt(`#pragma mapbox: define highp vec4 color
168
+ #pragma mapbox: define lowp float opacity
169
+ void main() {
170
+ #pragma mapbox: initialize highp vec4 color
171
+ #pragma mapbox: initialize lowp float opacity
172
+ fragColor=color*opacity;
173
+ #ifdef OVERDRAW_INSPECTOR
174
+ fragColor=vec4(1.0);
175
+ #endif
176
+ }`,`uniform vec2 u_fill_translate;in vec2 a_pos;
177
+ #pragma mapbox: define highp vec4 color
178
+ #pragma mapbox: define lowp float opacity
179
+ void main() {
180
+ #pragma mapbox: initialize highp vec4 color
181
+ #pragma mapbox: initialize lowp float opacity
182
+ gl_Position=projectTile(a_pos+u_fill_translate,a_pos);}`),fillOutline:qt(`in vec2 v_pos;
183
+ #ifdef GLOBE
184
+ in float v_depth;
185
+ #endif
186
+ #pragma mapbox: define highp vec4 outline_color
187
+ #pragma mapbox: define lowp float opacity
188
+ void main() {
189
+ #pragma mapbox: initialize highp vec4 outline_color
190
+ #pragma mapbox: initialize lowp float opacity
191
+ float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);
192
+ #ifdef GLOBE
193
+ if (v_depth > 1.0) {discard;}
194
+ #endif
195
+ #ifdef OVERDRAW_INSPECTOR
196
+ fragColor=vec4(1.0);
197
+ #endif
198
+ }`,`uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;
199
+ #ifdef GLOBE
200
+ out float v_depth;
201
+ #endif
202
+ #pragma mapbox: define highp vec4 outline_color
203
+ #pragma mapbox: define lowp float opacity
204
+ void main() {
205
+ #pragma mapbox: initialize highp vec4 outline_color
206
+ #pragma mapbox: initialize lowp float opacity
207
+ gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
208
+ #ifdef GLOBE
209
+ v_depth=gl_Position.z/gl_Position.w;
210
+ #endif
211
+ }`),fillOutlinePattern:qt(`uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;
212
+ #ifdef GLOBE
213
+ in float v_depth;
214
+ #endif
215
+ #pragma mapbox: define lowp float opacity
216
+ #pragma mapbox: define lowp vec4 pattern_from
217
+ #pragma mapbox: define lowp vec4 pattern_to
218
+ void main() {
219
+ #pragma mapbox: initialize lowp float opacity
220
+ #pragma mapbox: initialize mediump vec4 pattern_from
221
+ #pragma mapbox: initialize mediump vec4 pattern_to
222
+ vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;
223
+ #ifdef GLOBE
224
+ if (v_depth > 1.0) {discard;}
225
+ #endif
226
+ #ifdef OVERDRAW_INSPECTOR
227
+ fragColor=vec4(1.0);
228
+ #endif
229
+ }`,`uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;
230
+ #ifdef GLOBE
231
+ out float v_depth;
232
+ #endif
233
+ #pragma mapbox: define lowp float opacity
234
+ #pragma mapbox: define lowp vec4 pattern_from
235
+ #pragma mapbox: define lowp vec4 pattern_to
236
+ #pragma mapbox: define lowp float pixel_ratio_from
237
+ #pragma mapbox: define lowp float pixel_ratio_to
238
+ void main() {
239
+ #pragma mapbox: initialize lowp float opacity
240
+ #pragma mapbox: initialize mediump vec4 pattern_from
241
+ #pragma mapbox: initialize mediump vec4 pattern_to
242
+ #pragma mapbox: initialize lowp float pixel_ratio_from
243
+ #pragma mapbox: initialize lowp float pixel_ratio_to
244
+ 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;
245
+ #ifdef GLOBE
246
+ v_depth=gl_Position.z/gl_Position.w;
247
+ #endif
248
+ }`),fillPattern:qt(`#ifdef GL_ES
249
+ precision highp float;
250
+ #endif
251
+ uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;
252
+ #pragma mapbox: define lowp float opacity
253
+ #pragma mapbox: define lowp vec4 pattern_from
254
+ #pragma mapbox: define lowp vec4 pattern_to
255
+ void main() {
256
+ #pragma mapbox: initialize lowp float opacity
257
+ #pragma mapbox: initialize mediump vec4 pattern_from
258
+ #pragma mapbox: initialize mediump vec4 pattern_to
259
+ vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;
260
+ #ifdef OVERDRAW_INSPECTOR
261
+ fragColor=vec4(1.0);
262
+ #endif
263
+ }`,`uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;
264
+ #pragma mapbox: define lowp float opacity
265
+ #pragma mapbox: define lowp vec4 pattern_from
266
+ #pragma mapbox: define lowp vec4 pattern_to
267
+ #pragma mapbox: define lowp float pixel_ratio_from
268
+ #pragma mapbox: define lowp float pixel_ratio_to
269
+ void main() {
270
+ #pragma mapbox: initialize lowp float opacity
271
+ #pragma mapbox: initialize mediump vec4 pattern_from
272
+ #pragma mapbox: initialize mediump vec4 pattern_to
273
+ #pragma mapbox: initialize lowp float pixel_ratio_from
274
+ #pragma mapbox: initialize lowp float pixel_ratio_to
275
+ 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:qt(`in vec4 v_color;void main() {fragColor=v_color;
276
+ #ifdef OVERDRAW_INSPECTOR
277
+ fragColor=vec4(1.0);
278
+ #endif
279
+ }`,`uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed;
280
+ #ifdef TERRAIN3D
281
+ in vec2 a_centroid;
282
+ #endif
283
+ out vec4 v_color;
284
+ #pragma mapbox: define highp float base
285
+ #pragma mapbox: define highp float height
286
+ #pragma mapbox: define highp vec4 color
287
+ void main() {
288
+ #pragma mapbox: initialize highp float base
289
+ #pragma mapbox: initialize highp float height
290
+ #pragma mapbox: initialize highp vec4 color
291
+ vec3 normal=a_normal_ed.xyz;
292
+ #ifdef TERRAIN3D
293
+ float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);
294
+ #else
295
+ float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
296
+ #endif
297
+ base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;
298
+ #ifdef GLOBE
299
+ vec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);
300
+ #else
301
+ gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);
302
+ #endif
303
+ float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);
304
+ #ifdef GLOBE
305
+ mat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);
306
+ #endif
307
+ directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}`),fillExtrusionPattern:qt(`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;
308
+ #pragma mapbox: define lowp float base
309
+ #pragma mapbox: define lowp float height
310
+ #pragma mapbox: define lowp vec4 pattern_from
311
+ #pragma mapbox: define lowp vec4 pattern_to
312
+ #pragma mapbox: define lowp float pixel_ratio_from
313
+ #pragma mapbox: define lowp float pixel_ratio_to
314
+ void main() {
315
+ #pragma mapbox: initialize lowp float base
316
+ #pragma mapbox: initialize lowp float height
317
+ #pragma mapbox: initialize mediump vec4 pattern_from
318
+ #pragma mapbox: initialize mediump vec4 pattern_to
319
+ #pragma mapbox: initialize lowp float pixel_ratio_from
320
+ #pragma mapbox: initialize lowp float pixel_ratio_to
321
+ vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;
322
+ #ifdef OVERDRAW_INSPECTOR
323
+ fragColor=vec4(1.0);
324
+ #endif
325
+ }`,`uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed;
326
+ #ifdef TERRAIN3D
327
+ in vec2 a_centroid;
328
+ #endif
329
+ #ifdef GLOBE
330
+ out vec3 v_sphere_pos;
331
+ #endif
332
+ out vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;
333
+ #pragma mapbox: define lowp float base
334
+ #pragma mapbox: define lowp float height
335
+ #pragma mapbox: define lowp vec4 pattern_from
336
+ #pragma mapbox: define lowp vec4 pattern_to
337
+ #pragma mapbox: define lowp float pixel_ratio_from
338
+ #pragma mapbox: define lowp float pixel_ratio_to
339
+ void main() {
340
+ #pragma mapbox: initialize lowp float base
341
+ #pragma mapbox: initialize lowp float height
342
+ #pragma mapbox: initialize mediump vec4 pattern_from
343
+ #pragma mapbox: initialize mediump vec4 pattern_to
344
+ #pragma mapbox: initialize lowp float pixel_ratio_from
345
+ #pragma mapbox: initialize lowp float pixel_ratio_to
346
+ vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;
347
+ #ifdef TERRAIN3D
348
+ float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);
349
+ #else
350
+ float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
351
+ #endif
352
+ base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;
353
+ #ifdef GLOBE
354
+ vec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);
355
+ #else
356
+ gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);
357
+ #endif
358
+ vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0
359
+ ? a_pos
360
+ : 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:qt(`#ifdef GL_ES
361
+ precision highp float;
362
+ #endif
363
+ uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {vec2 epsilon=1.0/u_dimension;float tileSize=u_dimension.x-2.0;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0);
364
+ #ifdef OVERDRAW_INSPECTOR
365
+ fragColor=vec4(1.0);
366
+ #endif
367
+ }`,`uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}`),hillshade:qt(`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];
368
+ #define PI 3.141592653589793
369
+ #define STANDARD 0
370
+ #define COMBINED 1
371
+ #define IGOR 2
372
+ #define MULTIDIRECTIONAL 3
373
+ #define BASIC 4
374
+ float get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else
375
+ {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
376
+ {fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec4 pixel=texture(u_image,v_pos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);}
377
+ #ifdef OVERDRAW_INSPECTOR
378
+ fragColor=vec4(1.0);
379
+ #endif
380
+ }`,`uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}`),line:qt(`uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;
381
+ #ifdef GLOBE
382
+ in float v_depth;
383
+ #endif
384
+ #pragma mapbox: define highp vec4 color
385
+ #pragma mapbox: define lowp float blur
386
+ #pragma mapbox: define lowp float opacity
387
+ void main() {
388
+ #pragma mapbox: initialize highp vec4 color
389
+ #pragma mapbox: initialize lowp float blur
390
+ #pragma mapbox: initialize lowp float opacity
391
+ 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);
392
+ #ifdef GLOBE
393
+ if (v_depth > 1.0) {discard;}
394
+ #endif
395
+ #ifdef OVERDRAW_INSPECTOR
396
+ fragColor=vec4(1.0);
397
+ #endif
398
+ }`,`
399
+ #define scale 0.015873016
400
+ in vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;
401
+ #ifdef GLOBE
402
+ out float v_depth;
403
+ #endif
404
+ #pragma mapbox: define highp vec4 color
405
+ #pragma mapbox: define lowp float blur
406
+ #pragma mapbox: define lowp float opacity
407
+ #pragma mapbox: define mediump float gapwidth
408
+ #pragma mapbox: define lowp float offset
409
+ #pragma mapbox: define mediump float width
410
+ void main() {
411
+ #pragma mapbox: initialize highp vec4 color
412
+ #pragma mapbox: initialize lowp float blur
413
+ #pragma mapbox: initialize lowp float opacity
414
+ #pragma mapbox: initialize mediump float gapwidth
415
+ #pragma mapbox: initialize lowp float offset
416
+ #pragma mapbox: initialize mediump float width
417
+ float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
418
+ #ifdef GLOBE
419
+ v_depth=gl_Position.z/gl_Position.w;
420
+ #endif
421
+ #ifdef TERRAIN3D
422
+ v_gamma_scale=1.0;
423
+ #else
424
+ float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
425
+ #endif
426
+ v_width2=vec2(outset,inset);}`),lineGradient:qt(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;
427
+ #ifdef GLOBE
428
+ in float v_depth;
429
+ #endif
430
+ #pragma mapbox: define lowp float blur
431
+ #pragma mapbox: define lowp float opacity
432
+ void main() {
433
+ #pragma mapbox: initialize lowp float blur
434
+ #pragma mapbox: initialize lowp float opacity
435
+ 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);
436
+ #ifdef GLOBE
437
+ if (v_depth > 1.0) {discard;}
438
+ #endif
439
+ #ifdef OVERDRAW_INSPECTOR
440
+ fragColor=vec4(1.0);
441
+ #endif
442
+ }`,`
443
+ #define scale 0.015873016
444
+ in vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;
445
+ #ifdef GLOBE
446
+ out float v_depth;
447
+ #endif
448
+ #pragma mapbox: define lowp float blur
449
+ #pragma mapbox: define lowp float opacity
450
+ #pragma mapbox: define mediump float gapwidth
451
+ #pragma mapbox: define lowp float offset
452
+ #pragma mapbox: define mediump float width
453
+ void main() {
454
+ #pragma mapbox: initialize lowp float blur
455
+ #pragma mapbox: initialize lowp float opacity
456
+ #pragma mapbox: initialize mediump float gapwidth
457
+ #pragma mapbox: initialize lowp float offset
458
+ #pragma mapbox: initialize mediump float width
459
+ float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
460
+ #ifdef GLOBE
461
+ v_depth=gl_Position.z/gl_Position.w;
462
+ #endif
463
+ #ifdef TERRAIN3D
464
+ v_gamma_scale=1.0;
465
+ #else
466
+ float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
467
+ #endif
468
+ v_width2=vec2(outset,inset);}`),linePattern:qt(`#ifdef GL_ES
469
+ precision highp float;
470
+ #endif
471
+ uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;
472
+ #ifdef GLOBE
473
+ in float v_depth;
474
+ #endif
475
+ #pragma mapbox: define lowp vec4 pattern_from
476
+ #pragma mapbox: define lowp vec4 pattern_to
477
+ #pragma mapbox: define lowp float pixel_ratio_from
478
+ #pragma mapbox: define lowp float pixel_ratio_to
479
+ #pragma mapbox: define lowp float blur
480
+ #pragma mapbox: define lowp float opacity
481
+ void main() {
482
+ #pragma mapbox: initialize mediump vec4 pattern_from
483
+ #pragma mapbox: initialize mediump vec4 pattern_to
484
+ #pragma mapbox: initialize lowp float pixel_ratio_from
485
+ #pragma mapbox: initialize lowp float pixel_ratio_to
486
+ #pragma mapbox: initialize lowp float blur
487
+ #pragma mapbox: initialize lowp float opacity
488
+ 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;
489
+ #ifdef GLOBE
490
+ if (v_depth > 1.0) {discard;}
491
+ #endif
492
+ #ifdef OVERDRAW_INSPECTOR
493
+ fragColor=vec4(1.0);
494
+ #endif
495
+ }`,`
496
+ #define scale 0.015873016
497
+ #define LINE_DISTANCE_SCALE 2.0
498
+ in vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;
499
+ #ifdef GLOBE
500
+ out float v_depth;
501
+ #endif
502
+ #pragma mapbox: define lowp float blur
503
+ #pragma mapbox: define lowp float opacity
504
+ #pragma mapbox: define lowp float offset
505
+ #pragma mapbox: define mediump float gapwidth
506
+ #pragma mapbox: define mediump float width
507
+ #pragma mapbox: define lowp float floorwidth
508
+ #pragma mapbox: define lowp vec4 pattern_from
509
+ #pragma mapbox: define lowp vec4 pattern_to
510
+ #pragma mapbox: define lowp float pixel_ratio_from
511
+ #pragma mapbox: define lowp float pixel_ratio_to
512
+ void main() {
513
+ #pragma mapbox: initialize lowp float blur
514
+ #pragma mapbox: initialize lowp float opacity
515
+ #pragma mapbox: initialize lowp float offset
516
+ #pragma mapbox: initialize mediump float gapwidth
517
+ #pragma mapbox: initialize mediump float width
518
+ #pragma mapbox: initialize lowp float floorwidth
519
+ #pragma mapbox: initialize mediump vec4 pattern_from
520
+ #pragma mapbox: initialize mediump vec4 pattern_to
521
+ #pragma mapbox: initialize lowp float pixel_ratio_from
522
+ #pragma mapbox: initialize lowp float pixel_ratio_to
523
+ float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
524
+ #ifdef GLOBE
525
+ v_depth=gl_Position.z/gl_Position.w;
526
+ #endif
527
+ #ifdef TERRAIN3D
528
+ v_gamma_scale=1.0;
529
+ #else
530
+ float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
531
+ #endif
532
+ v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}`),lineSDF:qt(`uniform lowp float u_device_pixel_ratio;uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;
533
+ #ifdef GLOBE
534
+ in float v_depth;
535
+ #endif
536
+ #pragma mapbox: define highp vec4 color
537
+ #pragma mapbox: define lowp float blur
538
+ #pragma mapbox: define lowp float opacity
539
+ #pragma mapbox: define mediump float width
540
+ #pragma mapbox: define lowp float floorwidth
541
+ #pragma mapbox: define mediump vec4 dasharray_from
542
+ #pragma mapbox: define mediump vec4 dasharray_to
543
+ void main() {
544
+ #pragma mapbox: initialize highp vec4 color
545
+ #pragma mapbox: initialize lowp float blur
546
+ #pragma mapbox: initialize lowp float opacity
547
+ #pragma mapbox: initialize mediump float width
548
+ #pragma mapbox: initialize lowp float floorwidth
549
+ #pragma mapbox: initialize mediump vec4 dasharray_from
550
+ #pragma mapbox: initialize mediump vec4 dasharray_to
551
+ 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);
552
+ #ifdef GLOBE
553
+ if (v_depth > 1.0) {discard;}
554
+ #endif
555
+ #ifdef OVERDRAW_INSPECTOR
556
+ fragColor=vec4(1.0);
557
+ #endif
558
+ }`,`
559
+ #define scale 0.015873016
560
+ #define LINE_DISTANCE_SCALE 2.0
561
+ in vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;
562
+ #ifdef GLOBE
563
+ out float v_depth;
564
+ #endif
565
+ #pragma mapbox: define highp vec4 color
566
+ #pragma mapbox: define lowp float blur
567
+ #pragma mapbox: define lowp float opacity
568
+ #pragma mapbox: define mediump float gapwidth
569
+ #pragma mapbox: define lowp float offset
570
+ #pragma mapbox: define mediump float width
571
+ #pragma mapbox: define lowp float floorwidth
572
+ #pragma mapbox: define mediump vec4 dasharray_from
573
+ #pragma mapbox: define mediump vec4 dasharray_to
574
+ void main() {
575
+ #pragma mapbox: initialize highp vec4 color
576
+ #pragma mapbox: initialize lowp float blur
577
+ #pragma mapbox: initialize lowp float opacity
578
+ #pragma mapbox: initialize mediump float gapwidth
579
+ #pragma mapbox: initialize lowp float offset
580
+ #pragma mapbox: initialize mediump float width
581
+ #pragma mapbox: initialize lowp float floorwidth
582
+ #pragma mapbox: initialize mediump vec4 dasharray_from
583
+ #pragma mapbox: initialize mediump vec4 dasharray_to
584
+ float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
585
+ #ifdef GLOBE
586
+ v_depth=gl_Position.z/gl_Position.w;
587
+ #endif
588
+ #ifdef TERRAIN3D
589
+ v_gamma_scale=1.0;
590
+ #else
591
+ float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
592
+ #endif
593
+ float 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:qt(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv;
594
+ #ifdef GLOBE
595
+ in float v_depth;
596
+ #endif
597
+ #pragma mapbox: define lowp float blur
598
+ #pragma mapbox: define lowp float opacity
599
+ #pragma mapbox: define mediump float width
600
+ #pragma mapbox: define lowp float floorwidth
601
+ #pragma mapbox: define mediump vec4 dasharray_from
602
+ #pragma mapbox: define mediump vec4 dasharray_to
603
+ void main() {
604
+ #pragma mapbox: initialize lowp float blur
605
+ #pragma mapbox: initialize lowp float opacity
606
+ #pragma mapbox: initialize mediump float width
607
+ #pragma mapbox: initialize lowp float floorwidth
608
+ #pragma mapbox: initialize mediump vec4 dasharray_from
609
+ #pragma mapbox: initialize mediump vec4 dasharray_to
610
+ 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);
611
+ #ifdef GLOBE
612
+ if (v_depth > 1.0) {discard;}
613
+ #endif
614
+ #ifdef OVERDRAW_INSPECTOR
615
+ fragColor=vec4(1.0);
616
+ #endif
617
+ }`,`
618
+ #define scale 0.015873016
619
+ #define LINE_DISTANCE_SCALE 2.0
620
+ in vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b;
621
+ #ifdef GLOBE
622
+ out float v_depth;
623
+ #endif
624
+ #pragma mapbox: define lowp float blur
625
+ #pragma mapbox: define lowp float opacity
626
+ #pragma mapbox: define mediump float gapwidth
627
+ #pragma mapbox: define lowp float offset
628
+ #pragma mapbox: define mediump float width
629
+ #pragma mapbox: define lowp float floorwidth
630
+ #pragma mapbox: define mediump vec4 dasharray_from
631
+ #pragma mapbox: define mediump vec4 dasharray_to
632
+ void main() {
633
+ #pragma mapbox: initialize lowp float blur
634
+ #pragma mapbox: initialize lowp float opacity
635
+ #pragma mapbox: initialize mediump float gapwidth
636
+ #pragma mapbox: initialize lowp float offset
637
+ #pragma mapbox: initialize mediump float width
638
+ #pragma mapbox: initialize lowp float floorwidth
639
+ #pragma mapbox: initialize mediump vec4 dasharray_from
640
+ #pragma mapbox: initialize mediump vec4 dasharray_to
641
+ float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;float texel_height=1.0/u_image_height;float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
642
+ #ifdef GLOBE
643
+ v_depth=gl_Position.z/gl_Position.w;
644
+ #endif
645
+ #ifdef TERRAIN3D
646
+ v_gamma_scale=1.0;
647
+ #else
648
+ float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
649
+ #endif
650
+ float u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}`),raster:qt(`uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture(u_image0,v_pos0);vec4 color1=texture(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);
651
+ #ifdef OVERDRAW_INSPECTOR
652
+ fragColor=vec4(1.0);
653
+ #endif
654
+ }`,`uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;
655
+ #ifdef GLOBE
656
+ if (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}
657
+ #endif
658
+ v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}`),symbolIcon:qt(`uniform sampler2D u_texture;in vec2 v_tex;in float v_total_opacity;void main() {fragColor=texture(u_texture,v_tex)*v_total_opacity;
659
+ #ifdef OVERDRAW_INSPECTOR
660
+ fragColor=vec4(1.0);
661
+ #endif
662
+ }`,`in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out float v_total_opacity;
663
+ #pragma mapbox: define lowp float opacity
664
+ void main() {
665
+ #pragma mapbox: initialize lowp float opacity
666
+ vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_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 ?
667
+ camera_to_anchor_distance/u_camera_to_center_distance :
668
+ u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;
669
+ #ifdef GLOBE
670
+ if(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}
671
+ #endif
672
+ vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;}`),symbolSDF:qt(`#define SDF_PX 8.0
673
+ uniform bool u_is_halo;uniform bool u_is_plain;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1;
674
+ #pragma mapbox: define highp vec4 fill_color
675
+ #pragma mapbox: define highp vec4 halo_color
676
+ #pragma mapbox: define lowp float halo_width
677
+ #pragma mapbox: define lowp float halo_blur
678
+ void main() {
679
+ #pragma mapbox: initialize highp vec4 fill_color
680
+ #pragma mapbox: initialize highp vec4 halo_color
681
+ #pragma mapbox: initialize lowp float halo_width
682
+ #pragma mapbox: initialize lowp float halo_blur
683
+ float EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float 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;}
684
+ #ifdef OVERDRAW_INSPECTOR
685
+ fragColor=vec4(1.0);
686
+ #endif
687
+ }`,`in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_data0;out vec3 v_data1;
688
+ #pragma mapbox: define highp vec4 fill_color
689
+ #pragma mapbox: define highp vec4 halo_color
690
+ #pragma mapbox: define lowp float opacity
691
+ #pragma mapbox: define lowp float halo_width
692
+ #pragma mapbox: define lowp float halo_blur
693
+ void main() {
694
+ #pragma mapbox: initialize highp vec4 fill_color
695
+ #pragma mapbox: initialize highp vec4 halo_color
696
+ #pragma mapbox: initialize lowp float opacity
697
+ #pragma mapbox: initialize lowp float halo_width
698
+ #pragma mapbox: initialize lowp float halo_blur
699
+ vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy/16.0;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));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 ?
700
+ camera_to_anchor_distance/u_camera_to_center_distance :
701
+ u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;
702
+ #ifdef GLOBE
703
+ if(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}
704
+ #endif
705
+ vec4 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:qt(`#define SDF_PX 8.0
706
+ #define SDF 1.0
707
+ #define ICON 0.0
708
+ uniform bool u_is_halo;uniform bool u_is_text;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;in vec4 v_data0;in vec4 v_data1;
709
+ #pragma mapbox: define highp vec4 fill_color
710
+ #pragma mapbox: define highp vec4 halo_color
711
+ #pragma mapbox: define lowp float halo_width
712
+ #pragma mapbox: define lowp float halo_blur
713
+ void main() {
714
+ #pragma mapbox: initialize highp vec4 fill_color
715
+ #pragma mapbox: initialize highp vec4 halo_color
716
+ #pragma mapbox: initialize lowp float halo_width
717
+ #pragma mapbox: initialize lowp float halo_blur
718
+ float total_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;fragColor=texture(u_texture_icon,tex_icon)*total_opacity;
719
+ #ifdef OVERDRAW_INSPECTOR
720
+ fragColor=vec4(1.0);
721
+ #endif
722
+ return;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;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;}
723
+ #ifdef OVERDRAW_INSPECTOR
724
+ fragColor=vec4(1.0);
725
+ #endif
726
+ }`,`in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec4 v_data0;out vec4 v_data1;
727
+ #pragma mapbox: define highp vec4 fill_color
728
+ #pragma mapbox: define highp vec4 halo_color
729
+ #pragma mapbox: define lowp float opacity
730
+ #pragma mapbox: define lowp float halo_width
731
+ #pragma mapbox: define lowp float halo_blur
732
+ void main() {
733
+ #pragma mapbox: initialize highp vec4 fill_color
734
+ #pragma mapbox: initialize highp vec4 halo_color
735
+ #pragma mapbox: initialize lowp float opacity
736
+ #pragma mapbox: initialize lowp float halo_width
737
+ #pragma mapbox: initialize lowp float halo_blur
738
+ vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));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 ?
739
+ camera_to_anchor_distance/u_camera_to_center_distance :
740
+ u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;
741
+ #ifdef GLOBE
742
+ if(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}
743
+ #endif
744
+ vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,total_opacity,is_sdf);}`),terrain:qt(`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;}}`,`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:qt(`in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}`,`in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}`),terrainCoords:qt(`precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}`,`in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}`),projectionErrorMeasurement:qt(`in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}`,`in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}`),atmosphere:qt(`#ifdef GL_ES
745
+ precision highp float;
746
+ #endif
747
+ in vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758
748
+ );color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}`,`in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}`),sky:qt(`uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}`,`in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}`)};function qt(e,t){let n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=t.match(/in ([\w]+) ([\w]+)/g),i=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),a=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=a?a.concat(i):i,s={};return{fragmentSource:e=e.replace(n,((e,t,n,r,i)=>(s[i]=!0,t===`define`?`\n#ifndef HAS_UNIFORM_u_${i}\nin ${n} ${r} ${i};\n#else\nuniform ${n} ${r} u_${i};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${i}\n ${n} ${r} ${i} = u_${i};\n#endif\n`))),vertexSource:t=t.replace(n,((e,t,n,r,i)=>{let a=r===`float`?`vec2`:`vec4`,o=i.match(/color/)?`color`:a;return s[i]?t===`define`?`\n#ifndef HAS_UNIFORM_u_${i}\nuniform lowp float u_${i}_t;\nin ${n} ${a} a_${i};\nout ${n} ${r} ${i};\n#else\nuniform ${n} ${r} u_${i};\n#endif\n`:o===`vec4`?`\n#ifndef HAS_UNIFORM_u_${i}\n ${i} = a_${i};\n#else\n ${n} ${r} ${i} = u_${i};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${i}\n ${i} = unpack_mix_${o}(a_${i}, u_${i}_t);\n#else\n ${n} ${r} ${i} = u_${i};\n#endif\n`:t===`define`?`\n#ifndef HAS_UNIFORM_u_${i}\nuniform lowp float u_${i}_t;\nin ${n} ${a} a_${i};\n#else\nuniform ${n} ${r} u_${i};\n#endif\n`:o===`vec4`?`\n#ifndef HAS_UNIFORM_u_${i}\n ${n} ${r} ${i} = a_${i};\n#else\n ${n} ${r} ${i} = u_${i};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${i}\n ${n} ${r} ${i} = unpack_mix_${o}(a_${i}, u_${i}_t);\n#else\n ${n} ${r} ${i} = u_${i};\n#endif\n`})),staticAttributes:r,staticUniforms:o}}class Jt{constructor(e,t,n){this.vertexBuffer=e,this.indexBuffer=t,this.segments=n}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var Yt=t.aS([{name:`a_pos`,type:`Int16`,components:2}]);let Xt=`#define PROJECTION_MERCATOR`,Zt=`mercator`;class Qt{constructor(){this._cachedMesh=null}get name(){return`mercator`}get useSubdivision(){return!1}get shaderVariantName(){return Zt}get shaderDefine(){return Xt}get shaderPreludeCode(){return Kt.projectionMercator}get vertexShaderPreludeCode(){return Kt.projectionMercator.vertexSource}get subdivisionGranularity(){return t.aT.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,n,r,i,a){if(this._cachedMesh)return this._cachedMesh;let o=new t.aU;o.emplaceBack(0,0),o.emplaceBack(t.a6,0),o.emplaceBack(0,t.a6),o.emplaceBack(t.a6,t.a6);let s=e.createVertexBuffer(o,Yt.members),c=t.aV.simpleSegment(0,0,4,2),l=new t.aW;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3);let u=e.createIndexBuffer(l);return this._cachedMesh=new Jt(s,u,c),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(e){}}class $t{constructor(e=0,t=0,n=0,r=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(n)||n<0||isNaN(r)||r<0)throw Error(`Invalid value for edge-insets, top, bottom, left and right must all be numbers`);this.top=e,this.bottom=t,this.left=n,this.right=r}interpolate(e,n,r){return n.top!=null&&e.top!=null&&(this.top=t.H.number(e.top,n.top,r)),n.bottom!=null&&e.bottom!=null&&(this.bottom=t.H.number(e.bottom,n.bottom,r)),n.left!=null&&e.left!=null&&(this.left=t.H.number(e.left,n.left,r)),n.right!=null&&e.right!=null&&(this.right=t.H.number(e.right,n.right,r)),this}getCenter(e,n){let r=t.al((this.left+e-this.right)/2,0,e),i=t.al((this.top+n-this.bottom)/2,0,n);return new t.P(r,i)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new $t(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function en(e,t){if(!e.renderWorldCopies||e.lngRange)return;let n=t.lng-e.center.lng;t.lng+=n>180?-360:n<-180?360:0}function tn(e){return Math.max(0,Math.floor(e))}class nn{constructor(e,n){this.applyConstrain=(e,t)=>this._constrainOverride===null?this._callbacks.defaultConstrain(e,t):this._constrainOverride(e,t),this._callbacks=e,this._tileSize=512,this._renderWorldCopies=n?.renderWorldCopies===void 0||!!n?.renderWorldCopies,this._minZoom=n?.minZoom||0,this._maxZoom=n?.maxZoom||22,this._minPitch=n?.minPitch==null?0:n?.minPitch,this._maxPitch=n?.maxPitch==null?60:n?.maxPitch,this._constrainOverride=n?.constrainOverride??null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new t.W(0,0),this._elevation=0,this._zoom=0,this._tileZoom=tn(this._zoom),this._scale=t.ao(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new $t,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(e,n,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=tn(this._zoom),this._scale=t.ao(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 $t(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,n&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)))}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){e===void 0?e=!0:e===null&&(e=!1),this._renderWorldCopies=e}get constrainOverride(){return this._constrainOverride}setConstrainOverride(e){e===void 0&&(e=null),this._constrainOverride!==e&&(this._constrainOverride=e,this.constrainInternal(),this._calcMatrices())}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new t.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){let n=t.X(e,-180,180)*Math.PI/180;var i,a,o,s,c,l,u,d,f;this._bearingInRadians!==n&&(this._unmodified=!1,this._bearingInRadians=n,this._calcMatrices(),this._rotationMatrix=r(),i=this._rotationMatrix,o=-this._bearingInRadians,s=(a=this._rotationMatrix)[0],c=a[1],l=a[2],u=a[3],d=Math.sin(o),f=Math.cos(o),i[0]=s*f+l*d,i[1]=c*f+u*d,i[2]=s*-d+l*f,i[3]=c*-d+u*f)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){let n=t.al(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==n&&(this._unmodified=!1,this._pitchInRadians=n,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){let t=e/180*Math.PI;this._rollInRadians!==t&&(this._unmodified=!1,this._rollInRadians=t,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return t.aX(this._fovInRadians)}setFov(e){e=t.al(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=t.an(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){let n=this.applyConstrain(this._center,e).zoom;this._zoom!==n&&(this._unmodified=!1,this._zoom=n,this._tileZoom=Math.max(0,Math.floor(n)),this._scale=t.ao(n),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,n){this._unmodified=!1,this._edgeInsets.interpolate(e,t,n),this.constrainInternal(),this._calcMatrices()}resize(e,t,n=!0){this._width=e,this._height=t,n&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){return this._latRange?.length!==2||this._lngRange?.length!==2?null:new ue([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=[-t.am,t.am])}getCameraQueryGeometry(e,n){if(n.length===1)return[n[0],e];{let{minX:r,minY:i,maxX:a,maxY:o}=t.a8.fromPoints(n).extend(e);return[new t.P(r,i),new t.P(a,i),new t.P(a,o),new t.P(r,o),new t.P(r,i)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;let e=this._unmodified,{center:t,zoom:n}=this.applyConstrain(this.center,this.zoom);this.setCenter(t),this.setZoom(n),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=t.ap(new Float64Array(16));t.S(e,e,[this._width/2,-this._height/2,1]),t.Q(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=t.ap(new Float64Array(16)),t.S(e,e,[1,-1,1]),t.Q(e,e,[-1,-1,0]),t.S(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,n,r,i){let a=r===void 0?this.bearing:r,o=i=i===void 0?this.pitch:i,{distanceToCenter:s,clampedElevation:c}=this._distanceToCenterFromAltElevationPitch(n,this.elevation,o),{x:l,y:u}=Ve(o,a),d=t.a7.fromLngLat(e,n),f,p,m=t.aY(1,d.y),h=0;do{if(h+=1,h>10)break;p=s/m,f=new t.a7(d.x+l*p,d.y+u*p),m=1/f.meterInMercatorCoordinateUnits()}while(Math.abs(s-p*m)>1e-12);return{center:f.toLngLat(),elevation:c,zoom:t.ar(this.height/2/Math.tan(this.fovInRadians/2)/p/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;let n=1/this.worldSize,r=t.aq(1,this.center.lat)*this.worldSize,i=t.a7.fromLngLat(this.center,this.elevation),a=i.x/n,o=i.y/n,s=i.z/n,c=this.pitch,l=this.bearing,{x:u,y:d,z:f}=Ve(c,l),p=this.cameraToCenterDistance,m=a+p*-u,h=o+p*-d,g=s+p*f,{distanceToCenter:_,clampedElevation:v}=this._distanceToCenterFromAltElevationPitch(g/r,e,c),y=_*r,b=new t.a7((m+u*y)*n,(h+d*y)*n,0).toLngLat(),x=t.aq(1,b.lat),S=t.ar(this.height/2/Math.tan(this.fovInRadians/2)/_/x/this.tileSize);this._elevation=v,this._center=b,this.setZoom(S)}_distanceToCenterFromAltElevationPitch(e,n,r){let i=-Math.cos(t.an(r)),a=e-n,o,s=n;return i*a>=0||Math.abs(i)<.1?(o=1e4,s=e+o*i):o=-a/i,{distanceToCenter:o,clampedElevation:s}}getCameraPoint(){let e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.P(e*Math.sin(this.rollInRadians),e*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){let e=t.aq(1,this.center.lat)*this.worldSize;return Be(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return[0,0,1,1];let n=e.canonical.z>=0?1<<e.canonical.z:2**e.canonical.z;return[e.canonical.x/n,e.canonical.y/n,1/n/t.a6,1/n/t.a6]}}class rn{constructor(e,n){this.min=e,this.max=n,this.center=t.aZ([],t.a_([],this.min,this.max),.5)}quadrant(e){let n=[e%2==0,e<2],r=t.a$(this.min),i=t.a$(this.max);for(let e=0;e<n.length;e++)r[e]=n[e]?this.min[e]:this.center[e],i[e]=n[e]?this.center[e]:this.max[e];return i[2]=this.max[2],new rn(r,i)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}intersectsFrustum(e){let t=!0;for(let n of e.planes){let e=this.intersectsPlane(n);if(e===0)return 0;e===1&&(t=!1)}return t?2:e.aabb.min[0]>this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]<this.min[0]||e.aabb.max[1]<this.min[1]||e.aabb.max[2]<this.min[2]?0:1}intersectsPlane(e){let t=e[3],n=e[3];for(let r=0;r<3;r++)e[r]>0?(t+=e[r]*this.min[r],n+=e[r]*this.max[r]):(n+=e[r]*this.min[r],t+=e[r]*this.max[r]);return t>=0?2:n<0?0:1}}class an{distanceToTile2d(e,t,n,r){let i=r,a=i.distanceX([e,t]),o=i.distanceY([e,t]);return Math.hypot(a,o)}getWrap(e,t,n){return n}getTileBoundingVolume(e,n,r,i){let a=0,o=0;if(i?.terrain){let s=new t.a3(e.z,n,e.z,e.x,e.y),c=i.terrain.getMinMaxElevation(s);a=c.minElevation??Math.min(0,r),o=c.maxElevation??Math.max(0,r)}let s=1<<e.z;return new rn([n+e.x/s,e.y/s,a],[n+(e.x+1)/s,(e.y+1)/s,o])}allowVariableZoom(e,n){let r=e.fov*(Math.abs(Math.cos(e.rollInRadians))*e.height+Math.abs(Math.sin(e.rollInRadians))*e.width)/e.height,i=t.al(78.5-r/2,0,60);return!!n.terrain||e.pitch>i}allowWorldCopies(){return!0}prepareNextFrame(){}}class on{constructor(e,t,n){this.points=e,this.planes=t,this.aabb=n}static fromInvProjectionMatrix(e,n=1,r=0,i,a){let o=a?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],s=2**r,c=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((r=>function(e,n,r,i){let a=t.aE([],e,n),o=1/a[3]/r*i;return t.b4(a,a,[o,o,1/a[3],o])}(r,e,n,s)));i&&function(e,n,r,i){let a=i?4:0,o=i?0:4,s=0,c=[],l=[];for(let n=0;n<4;n++){let r=t.b0([],e[n+o],e[n+a]),i=t.b5(r);t.aZ(r,r,1/i),c.push(i),l.push(r)}for(let n=0;n<4;n++){let i=t.b6(e[n+a],l[n],r);s=i!==null&&i>=0?Math.max(s,i):Math.max(s,c[n])}let u=function(e,n){let r=t.b0([],e[n[0]],e[n[1]]),i=t.b0([],e[n[2]],e[n[1]]),a=[0,0,0,0];return t.b1(a,t.b2([],r,i)),a[3]=-t.b3(a,e[n[0]]),a}(e,n),d=function(e,n){let r=t.b7(e),i=t.b8([],e,1/r),a=t.b0([],n,t.aZ([],i,t.b3(n,i))),o=t.b7(a);if(o>0){let e=Math.sqrt(1-i[3]*i[3]),r=t.aZ([],i,-i[3]),s=t.a_([],r,t.aZ([],a,e/o));return t.b9(n,s)}return null}(r,u);if(d!==null){let e=d/t.b3(l[0],u);s=Math.min(s,e)}for(let t=0;t<4;t++){let n=Math.min(s,c[t]);e[t+o]=[e[t+a][0]+l[t][0]*n,e[t+a][1]+l[t][1]*n,e[t+a][2]+l[t][2]*n,1]}}(c,o[0],i,a);let l=o.map((e=>{let n=t.b0([],c[e[0]],c[e[1]]),r=t.b0([],c[e[2]],c[e[1]]),i=t.b1([],t.b2([],n,r)),a=-t.b3(i,c[e[1]]);return i.concat(a)})),u=[1/0,1/0,1/0],d=[-1/0,-1/0,-1/0];for(let e of c)for(let t=0;t<3;t++)u[t]=Math.min(u[t],e[t]),d[t]=Math.max(d[t],e[t]);return new on(c,l,new rn(u,d))}}class z{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,n){this._helper.interpolatePadding(e,t,n)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,n=!0){this._helper.resize(e,t,n)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,t){}constructor(e){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(e,n)=>{n=t.al(+n,this.minZoom,this.maxZoom);let r={center:new t.W(e.lng,e.lat),zoom:n},i=this._helper._lngRange;!this._helper._renderWorldCopies&&i===null&&(i=[-179.9999999999,179.9999999999]);let a=this.tileSize*t.ao(r.zoom),o=0,s=a,c=0,l=a,u=0,d=0,{x:f,y:p}=this.size;if(this._helper._latRange){let e=this._helper._latRange;o=t.Y(e[1])*a,s=t.Y(e[0])*a,s-o<p&&(u=p/(s-o))}i&&(c=t.X(t.Z(i[0])*a,0,a),l=t.X(t.Z(i[1])*a,0,a),l<c&&(l+=a),l-c<f&&(d=f/(l-c)));let{x:m,y:h}=Ie(a,e),g,_,v=Math.max(d||0,u||0);if(v)return r.center=Le(a,new t.P(d?(l+c)/2:m,u?(s+o)/2:h)).wrap(),r.zoom+=t.ar(v),r;if(this._helper._latRange){let e=p/2;h-e<o&&(_=o+e),h+e>s&&(_=s-e)}if(i){let e=(c+l)/2,n=m;this._helper._renderWorldCopies&&(n=t.X(m,e-a/2,e+a/2));let r=f/2;n-r<c&&(g=c+r),n+r>l&&(g=l-r)}return(g!==void 0||_!==void 0)&&(r.center=Le(a,new t.P(g??m,_??h)).wrap()),r},this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new nn({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._coveringTilesDetailsProvider=new an}clone(){let e=new z;return e.apply(this,!1),e}apply(e,t,n){this._helper.apply(e,t,n)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){let n=[new t.ba(0,e)];if(this._helper._renderWorldCopies){let r=this.screenPointToMercatorCoordinate(new t.P(0,0)),i=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,0)),a=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,this._helper._height)),o=this.screenPointToMercatorCoordinate(new t.P(0,this._helper._height)),s=Math.floor(Math.min(r.x,i.x,a.x,o.x)),c=Math.floor(Math.max(r.x,i.x,a.x,o.x));for(let r=s-1;r<=c+1;r++)r!==0&&n.push(new t.ba(r,e))}return n}getCameraFrustum(){return on.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){let t=this.screenPointToLocation(this.centerPoint,e),n=e?e.getElevationForLngLatZoom(t,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(n)}setLocationAtPoint(e,n){let r=t.aq(this.elevation,this.center.lat),i=this.screenPointToMercatorCoordinateAtZ(n,r),a=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,r),o=t.a7.fromLngLat(e),s=new t.a7(o.x-(i.x-a.x),o.y-(i.y-a.y));this.setCenter(s?.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,n){return n?this.coordinatePoint(t.a7.fromLngLat(e),n.getElevationForLngLat(e,this),this._pixelMatrix3D):this.coordinatePoint(t.a7.fromLngLat(e))}screenPointToLocation(e,t){return this.screenPointToMercatorCoordinate(e,t)?.toLngLat()}screenPointToMercatorCoordinate(e,t){if(t){let n=t.pointCoordinate(e);if(n!=null)return n}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,n){let r=n||0,i=[e.x,e.y,0,1],a=[e.x,e.y,1,1];t.aE(i,i,this._pixelMatrixInverse),t.aE(a,a,this._pixelMatrixInverse);let o=i[3],s=a[3],c=i[1]/o,l=a[1]/s,u=i[2]/o,d=a[2]/s,f=u===d?0:(r-u)/(d-u);return new t.a7(t.H.number(i[0]/o,a[0]/s,f)/this.worldSize,t.H.number(c,l,f)/this.worldSize,r)}coordinatePoint(e,n=0,r=this._pixelMatrix){let i=[e.x*this.worldSize,e.y*this.worldSize,n,1];return t.aE(i,i,r),new t.P(i[0]/i[3],i[1]/i[3])}getBounds(){let e=Math.max(0,this._helper._height/2-Re(this));return new ue().extend(this.screenPointToLocation(new t.P(0,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new t.P(0,this._helper._height)))}isPointOnMapSurface(e,t){return t?t.pointCoordinate(e)!=null:e.y>this.height/2-Re(this)}calculatePosMatrix(e,n=!1,r){let i=e.key??t.bb(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),a=n?this._alignedPosMatrixCache:this._posMatrixCache;if(a.has(i)){let e=a.get(i);return r?e.f32:e.f64}let o=ze(e,this.worldSize);t.U(o,n?this._alignedProjMatrix:this._viewProjMatrix,o);let s={f64:o,f32:new Float32Array(o)};return a.set(i,s),r?s.f32:s.f64}calculateFogMatrix(e){let n=e.key,r=this._fogMatrixCacheF32;if(r.has(n))return r.get(n);let i=ze(e,this.worldSize);return t.U(i,this._fogMatrix,i),r.set(n,new Float32Array(i)),r.get(n)}calculateCenterFromCameraLngLatAlt(e,t,n,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,n,r)}_calculateNearFarZIfNeeded(e,n,r){if(!this._helper.autoCalculateNearFarZ)return;let i=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),a=e-i*this._helper._pixelPerMeter/Math.cos(n),o=i<0?a:e,s=Math.PI/2+this.pitchInRadians,c=t.an(this.fov)*(Math.abs(Math.cos(t.an(this.roll)))*this.height+Math.abs(Math.sin(t.an(this.roll)))*this.width)/this.height*(.5+r.y/this.height),l=Math.sin(c)*o/Math.sin(t.al(Math.PI-s-c,.01,Math.PI-.01)),u=Re(this),d=Math.atan(u/this._helper.cameraToCenterDistance),f=t.an(.75),p=d>f?2*d*(.5+r.y/(2*u)):f,m=Math.sin(p)*o/Math.sin(t.al(Math.PI-s-p,.01,Math.PI-.01)),h=Math.min(l,m);this._helper._farZ=1.01*(Math.cos(Math.PI/2-n)*h+o),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;let e=this.centerOffset,n=Ie(this.worldSize,this.center),r=n.x,i=n.y;this._helper._pixelPerMeter=t.aq(1,this.center.lat)*this.worldSize;let a=t.an(Math.min(this.pitch,Fe)),o=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(a)),s;var c,l;this._calculateNearFarZIfNeeded(o,a,e),s=new Float64Array(16),t.bc(s,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),(c=this._invProjMatrix)[0]=1/(l=s)[0],c[1]=0,c[2]=0,c[3]=0,c[4]=0,c[5]=1/l[5],c[6]=0,c[7]=0,c[8]=0,c[9]=0,c[10]=0,c[11]=1/l[14],c[12]=0,c[13]=0,c[14]=-1,c[15]=l[10]/l[14],s[8]=2*-e.x/this._helper._width,s[9]=2*e.y/this._helper._height,this._projectionMatrix=t.bd(s),t.S(s,s,[1,-1,1]),t.Q(s,s,[0,0,-this._helper.cameraToCenterDistance]),t.be(s,s,-this.rollInRadians),t.bf(s,s,this.pitchInRadians),t.be(s,s,-this.bearingInRadians),t.Q(s,s,[-r,-i,0]),this._mercatorMatrix=t.S([],s,[this.worldSize,this.worldSize,this.worldSize]),t.S(s,s,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=t.U(new Float64Array(16),this.clipSpaceToPixelsMatrix,s),t.Q(s,s,[0,0,-this.elevation]),this._viewProjMatrix=s,this._invViewProjMatrix=t.bg([],s);let u=[0,0,-1,1];t.aE(u,u,this._invViewProjMatrix),this._cameraPosition=[u[0]/u[3],u[1]/u[3],u[2]/u[3]],this._fogMatrix=new Float64Array(16),t.bc(this._fogMatrix,this.fovInRadians,this.width/this.height,o,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,t.S(this._fogMatrix,this._fogMatrix,[1,-1,1]),t.Q(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),t.be(this._fogMatrix,this._fogMatrix,-this.rollInRadians),t.bf(this._fogMatrix,this._fogMatrix,this.pitchInRadians),t.be(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),t.Q(this._fogMatrix,this._fogMatrix,[-r,-i,0]),t.S(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),t.Q(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=t.U(new Float64Array(16),this.clipSpaceToPixelsMatrix,s);let d=this._helper._width%2/2,f=this._helper._height%2/2,p=Math.cos(this.bearingInRadians),m=Math.sin(-this.bearingInRadians),h=r-Math.round(r)+p*d+m*f,g=i-Math.round(i)+p*f+m*d,_=new Float64Array(s);if(t.Q(_,_,[h>.5?h-1:h,g>.5?g-1:g,0]),this._alignedProjMatrix=_,s=t.bg(new Float64Array(16),this._pixelMatrix),!s)throw Error(`failed to invert matrix`);this._pixelMatrixInverse=s,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;let e=this.screenPointToMercatorCoordinate(new t.P(0,0)),n=[e.x*this.worldSize,e.y*this.worldSize,0,1];return t.aE(n,n,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){let e=t.aq(1,this.center.lat)*this.worldSize;return Be(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,n){let r=t.a7.fromLngLat(e),i=[r.x*this.worldSize,r.y*this.worldSize,n,1];return t.aE(i,i,this._viewProjMatrix),i[2]/i[3]}getProjectionData(e){let{overscaledTileID:n,aligned:r,applyTerrainMatrix:i}=e,a=this._helper.getMercatorTileCoordinates(n),o=n?this.calculatePosMatrix(n,r,!0):null,s;return s=n?.terrainRttPosMatrix32f&&i?n.terrainRttPosMatrix32f:o||t.bh(),{mainMatrix:s,tileMercatorCoords:a,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:s}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,t,n){return 1}transformLightDirection(e){return t.a$(e)}getRayDirectionFromPixel(e){throw Error(`Not implemented.`)}projectTileCoordinates(e,n,r,i){let a=this.calculatePosMatrix(r),o;i?(o=[e,n,i(e,n),1],t.aE(o,o,a)):(o=[e,n,0,1],Ct(o,o,a));let s=o[3];return{point:new t.P(o[0]/s,o[1]/s),signedDistanceFromCamera:s,isOccluded:!1}}populateCache(e){for(let t of e)this.calculatePosMatrix(t)}getMatrixForModel(e,n){let r=t.a7.fromLngLat(e,n),i=r.meterInMercatorCoordinateUnits(),a=t.bi();return t.Q(a,a,[r.x,r.y,r.z]),t.be(a,a,Math.PI),t.bf(a,a,Math.PI/2),t.S(a,a,[-i,i,i]),a}getProjectionDataForCustomLayer(e=!0){let n=new t.a3(0,0,0,0,0),r=this.getProjectionData({overscaledTileID:n,applyGlobeMatrix:e}),i=ze(n,this.worldSize);t.U(i,this._viewProjMatrix,i),r.tileMercatorCoords=[0,0,1,1];let a=[t.a6,t.a6,this.worldSize/this._helper.pixelsPerMeter],o=t.bj();return t.S(o,i,a),r.fallbackMatrix=o,r.mainMatrix=o,r}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function sn(){t.w(`Map cannot fit within canvas with the given bounds, padding, and/or offset.`)}function B(e){if(e.useSlerp)if(e.k<1){let n=t.bk(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),r=t.bk(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),i=new Float64Array(4);t.bl(i,n,r,e.k);let a=t.bm(i);e.tr.setRoll(a.roll),e.tr.setPitch(a.pitch),e.tr.setBearing(a.bearing)}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(t.H.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(t.H.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(t.H.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k))}function cn(e,n,r,i,a){let o=a.padding,s=Ie(a.worldSize,r.getNorthWest()),c=Ie(a.worldSize,r.getNorthEast()),l=Ie(a.worldSize,r.getSouthEast()),u=Ie(a.worldSize,r.getSouthWest()),d=t.an(-i),f=s.rotate(d),p=c.rotate(d),m=l.rotate(d),h=u.rotate(d),g=new t.P(Math.max(f.x,p.x,h.x,m.x),Math.max(f.y,p.y,h.y,m.y)),_=new t.P(Math.min(f.x,p.x,h.x,m.x),Math.min(f.y,p.y,h.y,m.y)),v=g.sub(_),y=(a.width-(o.left+o.right+n.left+n.right))/v.x,b=(a.height-(o.top+o.bottom+n.top+n.bottom))/v.y;if(b<0||y<0)return void sn();let x=Math.min(t.ar(a.scale*Math.min(y,b)),e.maxZoom),S=t.P.convert(e.offset),C=new t.P((n.left-n.right)/2,(n.top-n.bottom)/2).rotate(t.an(i)),w=S.add(C).mult(a.scale/t.ao(x));return{center:Le(a.worldSize,s.add(l).div(2).sub(w)),zoom:x,bearing:i}}class ln{get useGlobeControls(){return!1}handlePanInertia(e,t){let n=e.mag(),r=Math.abs(Re(t));return{easingOffset:e.mult(Math.min(.75*r/n,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,n){e.around.distSqr(t.centerPoint)<.01||t.setLocationAtPoint(n,e.around)}cameraForBoxAndBearing(e,t,n,r,i){return cn(e,t,n,r,i)}handleJumpToCenterZoom(e,n){e.zoom!==(n.zoom===void 0?e.zoom:+n.zoom)&&e.setZoom(+n.zoom),n.center!==void 0&&e.setCenter(t.W.convert(n.center))}handleEaseTo(e,n){let r=e.zoom,i=e.padding,a={roll:e.roll,pitch:e.pitch,bearing:e.bearing},o={roll:n.roll===void 0?e.roll:n.roll,pitch:n.pitch===void 0?e.pitch:n.pitch,bearing:n.bearing===void 0?e.bearing:n.bearing},s=n.zoom!==void 0,c=!e.isPaddingEqual(n.padding),l=!1,u=s?+n.zoom:e.zoom,d=e.centerPoint.add(n.offsetAsPoint),f=e.screenPointToLocation(d),{center:p,zoom:m}=e.applyConstrain(t.W.convert(n.center||f),u??r);en(e,p);let h=Ie(e.worldSize,f),g=Ie(e.worldSize,p).sub(h),_=t.ao(m-r);return l=m!==r,{easeFunc:s=>{if(l&&e.setZoom(t.H.number(r,m,s)),t.bn(a,o)||B({startEulerAngles:a,endEulerAngles:o,tr:e,k:s,useSlerp:a.roll!=o.roll}),c&&(e.interpolatePadding(i,n.padding,s),d=e.centerPoint.add(n.offsetAsPoint)),n.around)e.setLocationAtPoint(n.around,n.aroundPoint);else{let n=t.ao(e.zoom-r),i=(m>r?Math.min(2,_):Math.max(.5,_))**(1-s),a=Le(e.worldSize,h.add(g.mult(s*i)).mult(n));e.setLocationAtPoint(e.renderWorldCopies?a.wrap():a,d)}},isZooming:l,elevationCenter:p}}handleFlyTo(e,n){let r=n.zoom!==void 0,i=e.zoom,a=e.applyConstrain(t.W.convert(n.center||n.locationAtOffset),r?+n.zoom:i),o=a.center,s=a.zoom;en(e,o);let c=Ie(e.worldSize,n.locationAtOffset),l=Ie(e.worldSize,o).sub(c),u=l.mag(),d=t.ao(s-i),f;if(n.minZoom!==void 0){let r=Math.min(+n.minZoom,i,s),a=e.applyConstrain(o,r).zoom;f=t.ao(a-i)}return{easeFunc:(n,r,a,u)=>{e.setZoom(n===1?s:i+t.ar(r));let d=n===1?o:Le(e.worldSize,c.add(l.mult(a)).mult(r));e.setLocationAtPoint(e.renderWorldCopies?d.wrap():d,u)},scaleOfZoom:d,targetCenter:o,scaleOfMinZoom:f,pixelPathLength:u}}}class un{constructor(e,t,n){this.blendFunction=e,this.blendColor=t,this.mask=n}}un.Replace=[1,0],un.disabled=new un(un.Replace,t.bo.transparent,[!1,!1,!1,!1]),un.unblended=new un(un.Replace,t.bo.transparent,[!0,!0,!0,!0]),un.alphaBlended=new un([1,771],t.bo.transparent,[!0,!0,!0,!0]);let dn=2305;class fn{constructor(e,t,n){this.enable=e,this.mode=t,this.frontFace=n}}fn.disabled=new fn(!1,1029,dn),fn.backCCW=new fn(!0,1029,dn),fn.frontCCW=new fn(!0,1028,dn);class pn{constructor(e,t,n){this.func=e,this.mask=t,this.range=n}}pn.ReadOnly=!1,pn.ReadWrite=!0,pn.disabled=new pn(519,pn.ReadOnly,[0,1]);let mn=7680;class hn{constructor(e,t,n,r,i,a){this.test=e,this.ref=t,this.mask=n,this.fail=r,this.depthFail=i,this.pass=a}}function gn(e){return typeof WebGL2RenderingContext<`u`&&e instanceof WebGL2RenderingContext}hn.disabled=new hn({func:519,mask:0},0,0,mn,mn,mn);class _n{get awaitingQuery(){return!!this._readbackQueue}constructor(e){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=e;let n=e.context,r=n.gl;this._texFormat=r.RGBA,this._texType=r.UNSIGNED_BYTE;let i=new t.aU;i.emplaceBack(-1,-1),i.emplaceBack(2,-1),i.emplaceBack(-1,2);let a=new t.aW;a.emplaceBack(0,1,2),this._fullscreenTriangle=new Jt(n.createVertexBuffer(i,Yt.members),n.createIndexBuffer(a),t.aV.simpleSegment(0,0,i.length,a.length)),this._resultBuffer=new Uint8Array(4),n.activeTexture.set(r.TEXTURE1);let o=r.createTexture();r.bindTexture(r.TEXTURE_2D,o),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texImage2D(r.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=n.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(o),gn(r)&&(this._pbo=r.createBuffer(),r.bindBuffer(r.PIXEL_PACK_BUFFER,this._pbo),r.bufferData(r.PIXEL_PACK_BUFFER,4,r.STREAM_READ),r.bindBuffer(r.PIXEL_PACK_BUFFER,null))}destroy(){let e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(e,t){let n=this._updateCount;return this._readbackQueue?n>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():n>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,t),this._updateCount++,this._measuredError}_bindFramebuffer(){let e=this._cachedRenderContext.context,t=e.gl;e.activeTexture.set(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(e,n){let r=this._cachedRenderContext.context,i=r.gl;if(this._bindFramebuffer(),r.viewport.set([0,0,this._texWidth,this._texHeight]),r.clear({color:t.bo.transparent}),this._cachedRenderContext.useProgram(`projectionErrorMeasurement`).draw(r,i.TRIANGLES,pn.disabled,hn.disabled,un.unblended,fn.disabled,((e,t)=>({u_input:e,u_output_expected:t}))(e,n),null,null,`$clipping`,this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&gn(i)){i.bindBuffer(i.PIXEL_PACK_BUFFER,this._pbo),i.readBuffer(i.COLOR_ATTACHMENT0),i.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),i.bindBuffer(i.PIXEL_PACK_BUFFER,null);let e=i.fenceSync(i.SYNC_GPU_COMMANDS_COMPLETE,0);i.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:e}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){let e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&gn(e)){let n=e.clientWaitSync(this._readbackQueue.sync,0,0);if(n===e.WAIT_FAILED)return t.w(`WebGL2 clientWaitSync failed.`),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(n===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=_n._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(e){let t=0;return t+=e[0]/256,t+=e[1]/65536,t+=e[2]/16777216,e[3]<127&&(t=-t),t/128}}let vn=t.a6/128;function yn(e,n){let r=e.granularity===void 0?1:Math.max(e.granularity,1),i=r+(e.generateBorders?2:0),a=r+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),o=i+1,s=a+1,c=e.generateBorders?-1:0,l=e.generateBorders||e.extendToNorthPole?-1:0,u=r+ +!!e.generateBorders,d=r+(e.generateBorders||e.extendToSouthPole?1:0),f=o*s,p=i*a*6,m=o*s>65536;if(m&&n===`16bit`)throw Error(`Granularity is too large and meshes would not fit inside 16 bit vertex indices.`);let h=m||n===`32bit`,g=new Int16Array(2*f),_=0;for(let n=l;n<=d;n++)for(let i=c;i<=u;i++){let a=i/r*t.a6;i===-1&&(a=-vn),i===r+1&&(a=t.a6+vn);let o=n/r*t.a6;n===-1&&(o=e.extendToNorthPole?t.bq:-vn),n===r+1&&(o=e.extendToSouthPole?t.br:t.a6+vn),g[_++]=a,g[_++]=o}let v=h?new Uint32Array(p):new Uint16Array(p),y=0;for(let e=0;e<a;e++)for(let t=0;t<i;t++){let n=t+1+e*o,r=t+(e+1)*o,i=t+1+(e+1)*o;v[y++]=t+e*o,v[y++]=r,v[y++]=n,v[y++]=n,v[y++]=r,v[y++]=i}return{vertices:g.buffer.slice(0),indices:v.buffer.slice(0),uses32bitIndices:h}}let bn=new t.aT({fill:new t.bs(128,2),line:new t.bs(512,0),tile:new t.bs(128,32),stencil:new t.bs(128,1),circle:3});class xn{constructor(){this._tileMeshCache={},this._errorCorrectionUsable=0,this._errorMeasurementLastValue=0,this._errorCorrectionPreviousValue=0,this._errorMeasurementLastChangeTime=-1e3}get name(){return`vertical-perspective`}get transitionState(){return 1}get useSubdivision(){return!0}get shaderVariantName(){return`globe`}get shaderDefine(){return`#define GLOBE`}get shaderPreludeCode(){return Kt.projectionGlobe}get vertexShaderPreludeCode(){return Kt.projectionMercator.vertexSource}get subdivisionGranularity(){return bn}get useGlobeControls(){return!0}get latitudeErrorCorrectionRadians(){return this._errorCorrectionUsable}destroy(){this._errorMeasurement&&this._errorMeasurement.destroy()}updateGPUdependent(e){this._errorMeasurement||=new _n(e);let n=t.Y(this._errorQueryLatitudeDegrees),r=2*Math.atan(Math.exp(Math.PI-n*Math.PI*2))-.5*Math.PI,i=this._errorMeasurement.updateErrorLoop(n,r),a=l();i!==this._errorMeasurementLastValue&&(this._errorCorrectionPreviousValue=this._errorCorrectionUsable,this._errorMeasurementLastValue=i,this._errorMeasurementLastChangeTime=a);let o=Math.min(Math.max((a-this._errorMeasurementLastChangeTime)/1e3/.5,0),1);this._errorCorrectionUsable=t.bt(this._errorCorrectionPreviousValue,-this._errorMeasurementLastValue,t.bu(o))}_getMeshKey(e){return`${e.granularity.toString(36)}_${e.generateBorders?`b`:``}${e.extendToNorthPole?`n`:``}${e.extendToSouthPole?`s`:``}`}getMeshFromTileID(e,t,n,r,i){let a=(i===`stencil`?bn.stencil:bn.tile).getGranularityForZoomLevel(t.z);return this._getMesh(e,{granularity:a,generateBorders:n,extendToNorthPole:t.y===0&&r,extendToSouthPole:t.y===(1<<t.z)-1&&r})}_getMesh(e,n){let r=this._getMeshKey(n);if(r in this._tileMeshCache)return this._tileMeshCache[r];let i=function(e,n){let r=yn(n,`16bit`),i=t.aU.deserialize({arrayBuffer:r.vertices,length:r.vertices.byteLength/2/2}),a=t.aW.deserialize({arrayBuffer:r.indices,length:r.indices.byteLength/2/3});return new Jt(e.createVertexBuffer(i,Yt.members),e.createIndexBuffer(a),t.aV.simpleSegment(0,0,i.length,a.length))}(e,n);return this._tileMeshCache[r]=i,i}recalculate(e){}hasTransition(){let e=l(),t=!1;return t||=(e-this._errorMeasurementLastChangeTime)/1e3<.7,t||=this._errorMeasurement?.awaitingQuery,t}setErrorQueryLatitudeDegrees(e){this._errorQueryLatitudeDegrees=e}}let Sn=new t.u({type:new t.D(t.x.projection.type)});class V extends t.E{constructor(e){super(),this._transitionable=new t.y(Sn,void 0),this.setProjection(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new t.J(0)),this._mercatorProjection=new Qt,this._verticalPerspectiveProjection=new xn}get transitionState(){let e=this.properties.get(`type`);if(typeof e==`string`&&e===`mercator`)return 0;if(typeof e==`string`&&e===`vertical-perspective`)return 1;if(e instanceof t.bv){if(e.from===`vertical-perspective`&&e.to===`mercator`)return 1-e.transition;if(e.from===`mercator`&&e.to===`vertical-perspective`)return e.transition}return 1}get useGlobeRendering(){return this.transitionState>0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return`globe`}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e)}getMeshFromTileID(e,t,n,r,i){return this.currentProjection.getMeshFromTileID(e,t,n,r,i)}setProjection(e){this._transitionable.setValue(`type`,e?.type||`mercator`)}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}setErrorQueryLatitudeDegrees(e){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(e),this._mercatorProjection.setErrorQueryLatitudeDegrees(e)}}function Cn(e){let t=Tn(e.worldSize,e.center.lat);return 2*Math.PI*t}function H(e,n,r,i,a){let o=1/(1<<a),s=n/t.a6*o+i*o,c=t.by((e/t.a6*o+r*o)*Math.PI*2+Math.PI,2*Math.PI),l=2*Math.atan(Math.exp(Math.PI-s*Math.PI*2))-.5*Math.PI,u=Math.cos(l),d=new Float64Array(3);return d[0]=Math.sin(c)*u,d[1]=Math.sin(l),d[2]=Math.cos(c)*u,d}function wn(e){return function(e,t){let n=Math.cos(t),r=new Float64Array(3);return r[0]=Math.sin(e)*n,r[1]=Math.sin(t),r[2]=Math.cos(e)*n,r}(e.lng*Math.PI/180,e.lat*Math.PI/180)}function Tn(e,t){return e/(2*Math.PI)/Math.cos(t*Math.PI/180)}function En(e){let n=Math.asin(e[1])/Math.PI*180,r=Math.sqrt(e[0]*e[0]+e[2]*e[2]);if(r>1e-6){let i=e[0]/r,a=Math.acos(e[2]/r),o=(i>0?a:-a)/Math.PI*180;return new t.W(t.X(o,-180,180),n)}return new t.W(0,n)}function Dn(e){return Math.cos(e*Math.PI/180)}function On(e,n){let r=Dn(e),i=Dn(n);return t.ar(i/r)}function kn(e,n){let r=e.rotate(n.bearingInRadians),i=n.zoom+On(n.center.lat,0),a=t.bt(1/Dn(n.center.lat),1/Dn(Math.min(Math.abs(n.center.lat),60)),t.bw(i,7,3,0,1)),o=360/Cn({worldSize:n.worldSize,center:{lat:n.center.lat}});return new t.W(n.center.lng-r.x*o*a,t.al(n.center.lat+r.y*o,-t.am,t.am))}function An(e){let t=.5*e,n=Math.sin(t),r=Math.cos(t);return Math.log(n+r)-Math.log(r-n)}function jn(e,n,r,i){let a=e.lat+r*i;if(Math.abs(r)>1){let o=(Math.sign(e.lat+r)===Math.sign(e.lat)?Math.abs(e.lat):-Math.abs(e.lat))*Math.PI/180,s=Math.abs(e.lat+r)*Math.PI/180,c=An(o+i*(s-o)),l=An(o),u=An(s);return new t.W(e.lng+n*((c-l)/(u-l)),a)}return new t.W(e.lng+n*i,a)}class Mn{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=e}swapBuffers(){if(!this._hadAnyChanges)return;let e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(e,t,n,r){let i=`${e.z}_${e.x}_${e.y}_${r?.terrain?`t`:``}`,a=this._cache.get(i);if(a)return a;let o=this._cachePrevious.get(i);if(o)return this._cache.set(i,o),o;let s=this._boundingVolumeFactory(e,t,n,r);return this._cache.set(i,s),this._hadAnyChanges=!0,s}}class Nn{constructor(e,t,n,r){this.min=n,this.max=r,this.points=e,this.planes=t}static fromAabb(e,t){let n=[];for(let r=0;r<8;r++)n.push([1&~r?e[0]:t[0],(r>>1&1)==1?t[1]:e[1],(r>>2&1)==1?t[2]:e[2]]);return new Nn(n,[[-1,0,0,t[0]],[1,0,0,-e[0]],[0,-1,0,t[1]],[0,1,0,-e[1]],[0,0,-1,t[2]],[0,0,1,-e[2]]],e,t)}static fromCenterSizeAngles(e,n,r){let i=t.bA([],r[0],r[1],r[2]),a=t.bB([],[n[0],0,0],i),o=t.bB([],[0,n[1],0],i),s=t.bB([],[0,0,n[2]],i),c=[...e],l=[...e];for(let t=0;t<8;t++)for(let n=0;n<3;n++){let r=e[n]+a[n]*(1&~t?-1:1)+o[n]*((t>>1&1)==1?1:-1)+s[n]*((t>>2&1)==1?1:-1);c[n]=Math.min(c[n],r),l[n]=Math.max(l[n],r)}let u=[];for(let n=0;n<8;n++){let r=[...e];t.a_(r,r,t.aZ([],a,1&~n?-1:1)),t.a_(r,r,t.aZ([],o,(n>>1&1)==1?1:-1)),t.a_(r,r,t.aZ([],s,(n>>2&1)==1?1:-1)),u.push(r)}return new Nn(u,[[...a,-t.b3(a,u[0])],[...o,-t.b3(o,u[0])],[...s,-t.b3(s,u[0])],[-a[0],-a[1],-a[2],-t.b3(a,u[7])],[-o[0],-o[1],-o[2],-t.b3(o,u[7])],[-s[0],-s[1],-s[2],-t.b3(s,u[7])]],c,l)}intersectsFrustum(e){let t=!0,n=this.points.length,r=this.planes.length,i=e.planes.length,a=e.points.length;for(let r=0;r<i;r++){let i=e.planes[r],a=0;for(let e=0;e<n;e++){let t=this.points[e];i[0]*t[0]+i[1]*t[1]+i[2]*t[2]+i[3]>=0&&a++}if(a===0)return 0;a<n&&(t=!1)}if(t)return 2;for(let t=0;t<r;t++){let n=this.planes[t],r=0;for(let t=0;t<a;t++){let i=e.points[t];n[0]*i[0]+n[1]*i[1]+n[2]*i[2]+n[3]>=0&&r++}if(r===0)return 0}return 1}intersectsPlane(e){let t=this.points.length,n=0;for(let r=0;r<t;r++){let t=this.points[r];e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]>=0&&n++}return n===t?2:n===0?0:1}}function Pn(e,t,n){let r=e-t;return r<0?-r:Math.max(0,r-n)}function Fn(e,t,n,r,i){let a=e-n,o;return o=a<0?Math.min(-a,1+a-i):a>i?Math.min(Math.max(a-i,0),1-a):0,Math.max(o,Pn(t,r,i))}class In{constructor(){this._boundingVolumeCache=new Mn(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,t,n,r){let i=1<<n.z,a=1/i,o=n.x/i,s=n.y/i,c=2;return c=Math.min(c,Fn(e,t,o,s,a)),c=Math.min(c,Fn(e,t,o+.5,-s-a,a)),c=Math.min(c,Fn(e,t,o+.5,2-s-a,a)),c}getWrap(e,t,n){let r=1<<t.z,i=1/r,a=t.x/r,o=Pn(e.x,a,i),s=Pn(e.x,a-1,i),c=Pn(e.x,a+1,i),l=Math.min(o,s,c);return l===c?1:l===s?-1:0}allowVariableZoom(e,t){return P(e,t)>4}allowWorldCopies(){return!1}getTileBoundingVolume(e,t,n,r){return this._boundingVolumeCache.getTileBoundingVolume(e,t,n,r)}_computeTileBoundingVolume(e,n,r,i){let a=0,o=0;if(i?.terrain){let s=new t.a3(e.z,n,e.z,e.x,e.y),c=i.terrain.getMinMaxElevation(s);a=c.minElevation??Math.min(0,r),o=c.maxElevation??Math.max(0,r)}if(a/=t.bD,o/=t.bD,a+=1,o+=1,e.z<=0)return Nn.fromAabb([-o,-o,-o],[o,o,o]);if(e.z===1)return Nn.fromAabb([e.x===0?-o:0,e.y===0?0:-o,-o],[e.x===0?0:o,e.y===0?o:0,o]);{let n=[H(0,0,e.x,e.y,e.z),H(t.a6,0,e.x,e.y,e.z),H(t.a6,t.a6,e.x,e.y,e.z),H(0,t.a6,e.x,e.y,e.z)],r=[];for(let e of n)r.push(t.aZ([],e,o));if(o!==a)for(let e of n)r.push(t.aZ([],e,a));e.y===0&&r.push([0,1,0]),e.y===(1<<e.z)-1&&r.push([0,-1,0]);let i=[1,1,1],s=[-1,-1,-1];for(let e of r)for(let t=0;t<3;t++)i[t]=Math.min(i[t],e[t]),s[t]=Math.max(s[t],e[t]);let c=H(t.a6/2,t.a6/2,e.x,e.y,e.z),l=t.b2([],[0,1,0],c);t.b1(l,l);let u=t.b2([],c,l);t.b1(u,u);let d=t.b2([],n[2],n[1]);t.b1(d,d);let f=t.b2([],n[0],n[3]);t.b1(f,f),r.push(t.aZ([],c,o)),e.y>=(1<<e.z)/2&&r.push(t.aZ([],H(t.a6/2,0,e.x,e.y,e.z),o)),e.y<(1<<e.z)/2&&r.push(t.aZ([],H(t.a6/2,t.a6,e.x,e.y,e.z),o));let p=Ln(c,r),m=Ln(u,r),h=[-c[0],-c[1],-c[2],p.max],g=[c[0],c[1],c[2],-p.min],_=[-u[0],-u[1],-u[2],m.max],v=[u[0],u[1],u[2],-m.min],y=[...d,0],b=[...f,0],x=[];return e.y===0?x.push(t.bC(b,y,h),t.bC(b,y,g)):x.push(t.bC(_,y,h),t.bC(_,y,g),t.bC(_,b,h),t.bC(_,b,g)),e.y===(1<<e.z)-1?x.push(t.bC(b,y,h),t.bC(b,y,g)):x.push(t.bC(v,y,h),t.bC(v,y,g),t.bC(v,b,h),t.bC(v,b,g)),new Nn(x,[h,g,_,v,y,b],i,s)}}}function Ln(e,n){let r=1/0,i=-1/0;for(let a of n){let n=t.b3(e,a);r=Math.min(r,n),i=Math.max(i,n)}return{min:r,max:i}}class Rn{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,n){this._helper.interpolatePadding(e,t,n)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t){this._helper.resize(e,t)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}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=t.bE(),this._projectionMatrix=t.bi(),this._globeViewProjMatrix32f=t.bh(),this._globeViewProjMatrixNoCorrection=t.bi(),this._globeViewProjMatrixNoCorrectionInverted=t.bi(),this._globeProjMatrixInverted=t.bi(),this._cameraPosition=t.bz(),this._globeLatitudeErrorCorrectionRadians=0,this.defaultConstrain=(e,n)=>{let r=t.al(e.lat,-t.am,t.am),i=t.al(+n,this.minZoom+On(0,r),this.maxZoom);return{center:new t.W(e.lng,r),zoom:i}},this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new nn({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._coveringTilesDetailsProvider=new In}clone(){let e=new Rn;return e.apply(this,!1),e}apply(e,t,n){this._globeLatitudeErrorCorrectionRadians=n||0,this._helper.apply(e,t)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){let e=t.bz();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){let{overscaledTileID:t,applyGlobeMatrix:n}=e,r=this._helper.getMercatorTileCoordinates(t);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:r,clippingPlane:this._cachedClippingPlane,projectionTransition:+!!n,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){let n=this.pitchInRadians,r=this.cameraToCenterDistance/e,i=Math.sin(n)*r,a=Math.cos(n)*r+1,o=1/Math.sqrt(i*i+a*a)*1,s=-i,c=a,l=Math.sqrt(s*s+c*c);s/=l,c/=l;let u=[0,s,c];t.bF(u,u,[0,0,0],-this.bearingInRadians),t.bG(u,u,[0,0,0],-1*this.center.lat*Math.PI/180),t.bH(u,u,[0,0,0],this.center.lng*Math.PI/180);let d=1/t.b5(u);return t.aZ(u,u,d),[...u,-o*d]}isLocationOccluded(e){return!this.isSurfacePointVisible(wn(e))}transformLightDirection(e){let n=this._helper._center.lng*Math.PI/180,r=this._helper._center.lat*Math.PI/180,i=Math.cos(r),a=[Math.sin(n)*i,Math.sin(r),Math.cos(n)*i],o=[a[2],0,-a[0]],s=[0,0,0];t.b2(s,o,a),t.b1(o,o),t.b1(s,s);let c=[0,0,0];return t.b1(c,[o[0]*e[0]+s[0]*e[1]+a[0]*e[2],o[1]*e[0]+s[1]*e[1]+a[1]*e[2],o[2]*e[0]+s[2]*e[1]+a[2]*e[2]]),c}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,n,r){let i=function(e,n,r){let i=1/(1<<r.z);return new t.a7(e/t.a6*i+r.x*i,n/t.a6*i+r.y*i)}(e,n,r.canonical),a=(o=i.y,[t.by(i.x*Math.PI*2+Math.PI,2*Math.PI),2*Math.atan(Math.exp(Math.PI-o*Math.PI*2))-.5*Math.PI]);var o;return this.getCircleRadiusCorrection()/Math.cos(a[1])}projectTileCoordinates(e,n,r,i){let a=r.canonical,o=H(e,n,a.x,a.y,a.z),s=1+(i?i(e,n):0)/t.bD,c=[o[0]*s,o[1]*s,o[2]*s,1];t.aE(c,c,this._globeViewProjMatrixNoCorrection);let l=this._cachedClippingPlane,u=l[0]*o[0]+l[1]*o[1]+l[2]*o[2]+l[3]<0;return{point:new t.P(c[0]/c[3],c[1]/c[3]),signedDistanceFromCamera:c[3],isOccluded:u}}_calcMatrices(){if(!this._helper._width||!this._helper._height)return;let e=Tn(this.worldSize,this.center.lat),n=t.bj(),r=t.bj();this._helper.autoCalculateNearFarZ&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+2*e),t.bc(n,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);let i=this.centerOffset;n[8]=2*-i.x/this._helper._width,n[9]=2*i.y/this._helper._height,this._projectionMatrix=t.bd(n),this._globeProjMatrixInverted=t.bj(),t.bg(this._globeProjMatrixInverted,n),t.Q(n,n,[0,0,-this.cameraToCenterDistance]),t.be(n,n,this.rollInRadians),t.bf(n,n,-this.pitchInRadians),t.be(n,n,this.bearingInRadians),t.Q(n,n,[0,0,-e]);let a=t.bz();a[0]=e,a[1]=e,a[2]=e,t.bf(r,n,this.center.lat*Math.PI/180),t.bI(r,r,-this.center.lng*Math.PI/180),t.S(r,r,a),this._globeViewProjMatrixNoCorrection=r,t.bf(n,n,this.center.lat*Math.PI/180-this._globeLatitudeErrorCorrectionRadians),t.bI(n,n,-this.center.lng*Math.PI/180),t.S(n,n,a),this._globeViewProjMatrix32f=new Float32Array(n),this._globeViewProjMatrixNoCorrectionInverted=t.bj(),t.bg(this._globeViewProjMatrixNoCorrectionInverted,r);let o=t.bz();this._cameraPosition=t.bz(),this._cameraPosition[2]=this.cameraToCenterDistance/e,t.bF(this._cameraPosition,this._cameraPosition,o,-this.rollInRadians),t.bG(this._cameraPosition,this._cameraPosition,o,this.pitchInRadians),t.bF(this._cameraPosition,this._cameraPosition,o,-this.bearingInRadians),t.a_(this._cameraPosition,this._cameraPosition,[0,0,1]),t.bG(this._cameraPosition,this._cameraPosition,o,-this.center.lat*Math.PI/180),t.bH(this._cameraPosition,this._cameraPosition,o,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(e);let s=t.bd(this._globeViewProjMatrixNoCorrectionInverted);t.S(s,s,[1,1,-1]),this._cachedFrustum=on.fromInvProjectionMatrix(s,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(e){t.w(`calculateFogMatrix is not supported on globe projection.`);let n=t.bj();return t.ap(n),n}getVisibleUnwrappedCoordinates(e){return[new t.ba(0,e)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){e&&t.w(`terrain is not fully supported on vertical perspective projection.`),this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,n){if(!this._globeViewProjMatrixNoCorrection)return 1;let r=wn(e);t.aZ(r,r,1+n/t.bD);let i=t.bE();return t.aE(i,[r[0],r[1],r[2],1],this._globeViewProjMatrixNoCorrection),i[2]/i[3]}populateCache(e){}getBounds(){let e=.5*this.width,n=.5*this.height,r=[new t.P(0,0),new t.P(e,0),new t.P(this.width,0),new t.P(this.width,n),new t.P(this.width,this.height),new t.P(e,this.height),new t.P(0,this.height),new t.P(0,n)],i=[];for(let e of r)i.push(this.unprojectScreenPoint(e));let a=0,o=0,s=0,c=0,l=this.center;for(let e of i){let n=t.bJ(l.lng,e.lng),r=t.bJ(l.lat,e.lat);n<o&&(o=n),n>a&&(a=n),r<c&&(c=r),r>s&&(s=r)}let u=[l.lng+o,l.lat+c,l.lng+a,l.lat+s];return this.isSurfacePointOnScreen([0,1,0])&&(u[3]=90,u[0]=-180,u[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(u[1]=-90,u[0]=-180,u[2]=180),new ue(u)}calculateCenterFromCameraLngLatAlt(e,t,n,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,n,r)}setLocationAtPoint(e,n){let r=wn(this.unprojectScreenPoint(n)),i=wn(e),a=t.bz();t.bK(a);let o=t.bz();t.bH(o,r,a,-this.center.lng*Math.PI/180),t.bG(o,o,a,this.center.lat*Math.PI/180);let s=i[0]*i[0]+i[2]*i[2],c=o[0]*o[0];if(s<c)return;let l=Math.sqrt(s-c),u=-l,d=t.bL(i[0],i[2],o[0],l),f=t.bL(i[0],i[2],o[0],u),p=t.bz();t.bH(p,i,a,-d);let m=t.bL(p[1],p[2],o[1],o[2]),h=t.bz();t.bH(h,i,a,-f);let g=t.bL(h[1],h[2],o[1],o[2]),_=.5*Math.PI,v=m>=-_&&m<=_,y=g>=-_&&g<=_,b,x;if(v&&y){let e=this.center.lng*Math.PI/180,n=this.center.lat*Math.PI/180;t.bM(d,e)+t.bM(m,n)<t.bM(f,e)+t.bM(g,n)?(b=d,x=m):(b=f,x=g)}else if(v)b=d,x=m;else{if(!y)return;b=f,x=g}let S=b/Math.PI*180,C=x/Math.PI*180,w=this.center.lat;this.setCenter(new t.W(S,t.al(C,-90,90))),this.setZoom(this.zoom+On(w,this.center.lat))}locationToScreenPoint(e,n){let r=wn(e);if(n){let i=n.getElevationForLngLatZoom(e,this._helper._tileZoom);t.aZ(r,r,1+i/t.bD)}return this._projectSurfacePointToScreen(r)}_projectSurfacePointToScreen(e){let n=t.bE();return t.aE(n,[...e,1],this._globeViewProjMatrixNoCorrection),n[0]/=n[3],n[1]/=n[3],new t.P((.5*n[0]+.5)*this.width,(.5*-n[1]+.5)*this.height)}screenPointToMercatorCoordinate(e,n){if(n){let t=n.pointCoordinate(e);if(t)return t}return t.a7.fromLngLat(this.unprojectScreenPoint(e))}screenPointToLocation(e,t){return this.screenPointToMercatorCoordinate(e,t)?.toLngLat()}isPointOnMapSurface(e,t){let n=this._cameraPosition,r=this.getRayDirectionFromPixel(e);return!!this.rayPlanetIntersection(n,r)}getRayDirectionFromPixel(e){let n=t.bE();n[0]=e.x/this.width*2-1,n[1]=-1*(e.y/this.height*2-1),n[2]=1,n[3]=1,t.aE(n,n,this._globeViewProjMatrixNoCorrectionInverted),n[0]/=n[3],n[1]/=n[3],n[2]/=n[3];let r=t.bz();r[0]=n[0]-this._cameraPosition[0],r[1]=n[1]-this._cameraPosition[1],r[2]=n[2]-this._cameraPosition[2];let i=t.bz();return t.b1(i,r),i}isSurfacePointVisible(e){let t=this._cachedClippingPlane;return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]>=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return!1;let n=t.bE();return t.aE(n,[...e,1],this._globeViewProjMatrixNoCorrection),n[0]/=n[3],n[1]/=n[3],n[2]/=n[3],n[0]>-1&&n[0]<1&&n[1]>-1&&n[1]<1&&n[2]>-1&&n[2]<1}rayPlanetIntersection(e,n){let r=t.b3(e,n),i=t.bz(),a=t.bz();t.aZ(a,n,r),t.b0(i,e,a);let o=1-t.b3(i,i);if(o<0)return null;let s=t.b3(e,e)-1,c=-r+(r<0?1:-1)*Math.sqrt(o),l=s/c,u=c;return{tMin:Math.min(l,u),tMax:Math.max(l,u)}}unprojectScreenPoint(e){let n=this._cameraPosition,r=this.getRayDirectionFromPixel(e),i=this.rayPlanetIntersection(n,r);if(i){let e=t.bz();t.a_(e,n,[r[0]*i.tMin,r[1]*i.tMin,r[2]*i.tMin]);let a=t.bz();return t.b1(a,e),En(a)}let a=this._cachedClippingPlane,o=a[0]*r[0]+a[1]*r[1]+a[2]*r[2],s=-t.b9(a,n)/o,c=t.bz();if(s>0)t.a_(c,n,[r[0]*s,r[1]*s,r[2]*s]);else{let e=t.bz();t.a_(e,n,[2*r[0],2*r[1],2*r[2]]);let i=t.b9(this._cachedClippingPlane,e);t.b0(c,e,[this._cachedClippingPlane[0]*i,this._cachedClippingPlane[1]*i,this._cachedClippingPlane[2]*i])}let l=function(e){let n=t.bz();return n[0]=e[0]*-e[3],n[1]=e[1]*-e[3],n[2]=e[2]*-e[3],{center:n,radius:Math.sqrt(1-e[3]*e[3])}}(a);return En(function(e,n,r){let i=t.bz();t.b0(i,r,e);let a=t.bz();return t.bx(a,e,i,n/t.b7(i)),a}(l.center,l.radius,c))}getMatrixForModel(e,n){let r=t.W.convert(e),i=1/t.bD,a=t.bi();return t.bI(a,a,r.lng/180*Math.PI),t.bf(a,a,-r.lat/180*Math.PI),t.Q(a,a,[0,0,1+n/t.bD]),t.bf(a,a,.5*Math.PI),t.S(a,a,[i,i,i]),a}getProjectionDataForCustomLayer(e=!0){let n=this.getProjectionData({overscaledTileID:new t.a3(0,0,0,0,0),applyGlobeMatrix:e});return n.tileMercatorCoords=[0,0,1,1],n}getFastPathSimpleProjectionMatrix(e){}}class zn{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,n){this._helper.interpolatePadding(e,t,n)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,n=!0){this._helper.resize(e,t,n)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e,t){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=t,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(e){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this.defaultConstrain=(e,t)=>this.currentTransform.defaultConstrain(e,t),this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new nn({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._globeness=1,this._mercatorTransform=new z,this._verticalPerspectiveTransform=new Rn}clone(){let e=new zn;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this,!1),e}apply(e,t){this._helper.apply(e,t),this._mercatorTransform.apply(this,!1),this._verticalPerspectiveTransform.apply(this,!1,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){let t=this._mercatorTransform.getProjectionData(e),n=this._verticalPerspectiveTransform.getProjectionData(e);return{mainMatrix:this.isGlobeRendering?n.mainMatrix:t.mainMatrix,clippingPlane:n.clippingPlane,tileMercatorCoords:n.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:t.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return t.bt(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return t.bt(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,n,r){let i=this._mercatorTransform.getPitchedTextCorrection(e,n,r),a=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,n,r);return t.bt(i,a,this._globeness)}projectTileCoordinates(e,t,n,r){return this.currentTransform.projectTileCoordinates(e,t,n,r)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,!1,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,t){return this.currentTransform.lngLatToCameraDepth(e,t)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(e,t,n,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,n,r)}setLocationAtPoint(e,t){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,t),void this.apply(this._mercatorTransform,!1);this._verticalPerspectiveTransform.setLocationAtPoint(e,t),this.apply(this._verticalPerspectiveTransform,!1)}locationToScreenPoint(e,t){return this.currentTransform.locationToScreenPoint(e,t)}screenPointToMercatorCoordinate(e,t){return this.currentTransform.screenPointToMercatorCoordinate(e,t)}screenPointToLocation(e,t){return this.currentTransform.screenPointToLocation(e,t)}isPointOnMapSurface(e,t){return this.currentTransform.isPointOnMapSurface(e,t)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,t){return this.currentTransform.getMatrixForModel(e,t)}getProjectionDataForCustomLayer(e=!0){let t=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return t;let n=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return n.fallbackMatrix=t.mainMatrix,n}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class Bn{get useGlobeControls(){return!0}handlePanInertia(e,n){let r=kn(e,n);return Math.abs(r.lng-n.center.lng)>180&&(r.lng=n.center.lng+179.5*Math.sign(r.lng-n.center.lng)),{easingCenter:r,easingOffset:new t.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,n){let r=e.around,i=n.screenPointToLocation(r);e.bearingDelta&&n.setBearing(n.bearing+e.bearingDelta),e.pitchDelta&&n.setPitch(n.pitch+e.pitchDelta),e.rollDelta&&n.setRoll(n.roll+e.rollDelta);let a=n.zoom;e.zoomDelta&&n.setZoom(n.zoom+e.zoomDelta);let o=n.zoom-a;if(o===0)return;let s=t.bJ(n.center.lng,i.lng),c=s/(Math.abs(s/180)+1),l=t.bJ(n.center.lat,i.lat),u=n.getRayDirectionFromPixel(r),d=n.cameraPosition,f=-1*t.b3(d,u),p=t.bz();t.a_(p,d,[u[0]*f,u[1]*f,u[2]*f]);let m=t.b5(p)-1,h=Math.exp(.5*-Math.max(m-.3,0)),g=Tn(n.worldSize,n.center.lat)/Math.min(n.width,n.height),_=t.bw(g,.9,.5,1,.25),v=(1-t.ao(-o))*Math.min(h,_),y=n.center.lat,b=n.zoom,x=new t.W(n.center.lng+c*v,t.al(n.center.lat+l*v,-t.am,t.am));n.setLocationAtPoint(i,r);let S=n.center,C=t.bw(Math.abs(s),45,85,0,1),w=t.bw(g,.75,.35,0,1),T=Math.max(C,w)**.25,E=t.bJ(S.lng,x.lng),D=t.bJ(S.lat,x.lat);n.setCenter(new t.W(S.lng+E*T,S.lat+D*T).wrap()),n.setZoom(b+On(y,n.center.lat))}handleMapControlsPan(e,t,n){if(!e.panDelta)return;let r=t.center.lat,i=t.zoom;t.setCenter(kn(e.panDelta,t).wrap()),t.setZoom(i+On(r,t.center.lat))}cameraForBoxAndBearing(e,n,r,i,a){let o=cn(e,n,r,i,a),s=n.left/a.width*2-1,c=(a.width-n.right)/a.width*2-1,l=n.top/a.height*-2+1,u=(a.height-n.bottom)/a.height*-2+1,d=t.bJ(r.getWest(),r.getEast())<0,f=d?r.getEast():r.getWest(),p=d?r.getWest():r.getEast(),m=Math.max(r.getNorth(),r.getSouth()),h=Math.min(r.getNorth(),r.getSouth()),g=f+.5*t.bJ(f,p),_=m+.5*t.bJ(m,h),v=a.clone();v.setCenter(o.center),v.setBearing(o.bearing),v.setPitch(0),v.setRoll(0),v.setZoom(o.zoom);let y=v.modelViewProjectionMatrix,b=[wn(r.getNorthWest()),wn(r.getNorthEast()),wn(r.getSouthWest()),wn(r.getSouthEast()),wn(new t.W(p,_)),wn(new t.W(f,_)),wn(new t.W(g,m)),wn(new t.W(g,h))],x=wn(o.center),S=1/0;for(let e of b)s<0&&(S=Bn.getLesserNonNegativeNonNull(S,Bn.solveVectorScale(e,x,y,`x`,s))),c>0&&(S=Bn.getLesserNonNegativeNonNull(S,Bn.solveVectorScale(e,x,y,`x`,c))),l>0&&(S=Bn.getLesserNonNegativeNonNull(S,Bn.solveVectorScale(e,x,y,`y`,l))),u<0&&(S=Bn.getLesserNonNegativeNonNull(S,Bn.solveVectorScale(e,x,y,`y`,u)));if(Number.isFinite(S)&&S!==0)return o.zoom=Math.min(v.zoom+t.ar(S),e.maxZoom),o;sn()}handleJumpToCenterZoom(e,n){let r=e.center.lat,i=e.applyConstrain(n.center?t.W.convert(n.center):e.center,e.zoom).center;e.setCenter(i.wrap());let a=n.zoom===void 0?e.zoom+On(r,i.lat):+n.zoom;e.zoom!==a&&e.setZoom(a)}handleEaseTo(e,n){let r=e.zoom,i=e.center,a=e.padding,o={roll:e.roll,pitch:e.pitch,bearing:e.bearing},s={roll:n.roll===void 0?e.roll:n.roll,pitch:n.pitch===void 0?e.pitch:n.pitch,bearing:n.bearing===void 0?e.bearing:n.bearing},c=n.zoom!==void 0,l=!e.isPaddingEqual(n.padding),u=!1,d=n.center?t.W.convert(n.center):i,f=e.applyConstrain(d,r).center;en(e,f);let p=e.clone();p.setCenter(f),p.setZoom(c?+n.zoom:r+On(i.lat,d.lat)),p.setBearing(n.bearing);let m=new t.P(t.al(e.centerPoint.x+n.offsetAsPoint.x,0,e.width),t.al(e.centerPoint.y+n.offsetAsPoint.y,0,e.height));p.setLocationAtPoint(f,m);let h=(n.offset&&n.offsetAsPoint.mag())>0?p.center:f,g=c?+n.zoom:r+On(i.lat,h.lat),_=r+On(i.lat,0),v=g+On(h.lat,0),y=t.bJ(i.lng,h.lng),b=t.bJ(i.lat,h.lat),x=t.ao(v-_);return u=g!==r,{easeFunc:r=>{if(t.bn(o,s)||B({startEulerAngles:o,endEulerAngles:s,tr:e,k:r,useSlerp:o.roll!=s.roll}),l&&e.interpolatePadding(a,n.padding,r),n.around)t.w(`Easing around a point is not supported under globe projection.`),e.setLocationAtPoint(n.around,n.aroundPoint);else{let t=jn(i,y,b,r*(v>_?Math.min(2,x):Math.max(.5,x))**(1-r));e.setCenter(t.wrap())}if(u){let n=t.H.number(_,v,r)+On(0,e.center.lat);e.setZoom(n)}},isZooming:u,elevationCenter:h}}handleFlyTo(e,n){let r=n.zoom!==void 0,i=e.center,a=e.zoom,o=e.padding,s=!e.isPaddingEqual(n.padding),c=e.applyConstrain(t.W.convert(n.center||n.locationAtOffset),a).center,l=r?+n.zoom:e.zoom+On(e.center.lat,c.lat),u=e.clone();u.setCenter(c),u.setZoom(l),u.setBearing(n.bearing);let d=new t.P(t.al(e.centerPoint.x+n.offsetAsPoint.x,0,e.width),t.al(e.centerPoint.y+n.offsetAsPoint.y,0,e.height));u.setLocationAtPoint(c,d);let f=u.center;en(e,f);let p=function(e,n,r){let i=wn(n),a=wn(r),o=t.b3(i,a),s=Math.acos(o),c=Cn(e);return s/(2*Math.PI)*c}(e,i,f),m=a+On(i.lat,0),h=l+On(f.lat,0),g=t.ao(h-m),_;if(typeof n.minZoom==`number`){let r=+n.minZoom+On(f.lat,0),i=Math.min(r,m,h)+On(0,f.lat),a=e.applyConstrain(f,i).zoom+On(f.lat,0);_=t.ao(a-m)}let v=t.bJ(i.lng,f.lng),y=t.bJ(i.lat,f.lat);return{easeFunc:(r,a,c,u)=>{let d=jn(i,v,y,c);s&&e.interpolatePadding(o,n.padding,r);let p=r===1?f:d;e.setCenter(p.wrap());let h=m+t.ar(a);e.setZoom(r===1?l:h+On(0,p.lat))},scaleOfZoom:g,targetCenter:f,scaleOfMinZoom:_,pixelPathLength:p}}static solveVectorScale(e,t,n,r,i){let a=r===`x`?[n[0],n[4],n[8],n[12]]:[n[1],n[5],n[9],n[13]],o=[n[3],n[7],n[11],n[15]],s=e[0]*a[0]+e[1]*a[1]+e[2]*a[2],c=e[0]*o[0]+e[1]*o[1]+e[2]*o[2],l=t[0]*a[0]+t[1]*a[1]+t[2]*a[2],u=t[0]*o[0]+t[1]*o[1]+t[2]*o[2];return l+i*c===s+i*u||o[3]*(s-l)+a[3]*(u-c)+s*u==l*c?null:(l+a[3]-i*u-i*o[3])/(l-s-i*u+i*c)}static getLesserNonNegativeNonNull(e,t){return t!==null&&t>=0&&t<e?t:e}}class Vn{constructor(e){this._globe=e,this._mercatorCameraHelper=new ln,this._verticalPerspectiveCameraHelper=new Bn}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,n){this.currentHelper.handleMapControlsPan(e,t,n)}cameraForBoxAndBearing(e,t,n,r,i){return this.currentHelper.cameraForBoxAndBearing(e,t,n,r,i)}handleJumpToCenterZoom(e,t){this.currentHelper.handleJumpToCenterZoom(e,t)}handleEaseTo(e,t){return this.currentHelper.handleEaseTo(e,t)}handleFlyTo(e,t){return this.currentHelper.handleFlyTo(e,t)}}let Hn=(e,n)=>t.C(e,n?.filter((e=>e.identifier!==`source.canvas`))),Un=t.bN();class Wn extends t.E{constructor(e,n={}){super(),this._rtlPluginLoaded=()=>{for(let e in this.tileManagers){let t=this.tileManagers[e].getSource().type;t!==`vector`&&t!==`geojson`||this.tileManagers[e].reload()}},this.map=e,this.dispatcher=new re(ne(),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 g,this.imageManager.setEventedParent(this);let r=e._container?.lang||typeof document<`u`&&document.documentElement?.lang||void 0;this.glyphManager=new S(e._requestManager,n.localIdeographFontFamily,r),this.lineAtlas=new O(256,512),this.crossTileSymbolIndex=new Wt,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast(`SR`,t.bO()),Ae().on(De,this._rtlPluginLoaded),this.on(`data`,(e=>{if(e.dataType!==`source`||e.sourceDataType!==`metadata`)return;let t=this.tileManagers[e.sourceId];if(!t)return;let n=t.getSource();if(n?.vectorLayerIds)for(let e in this._layers){let t=this._layers[e];t.source===n.id&&this._validateLayer(t)}}))}_setInitialValues(){this._spritesImagesIds={},this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new t.bP,this._availableImages=[],this._globalState={},this._serializedLayers={},this.stylesheet=null,this.light=null,this.sky=null,this.projection&&(this.projection.destroy(),delete this.projection),this._loaded=!1,this._changed=!1,this._updatedLayers={},this._updatedSources={},this._changedImages={},this._glyphsDidChange=!1,this._updatedPaintProps={},this._layerOrderChanged=!1,this.crossTileSymbolIndex=new(this.crossTileSymbolIndex?.constructor||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(e,n){this._checkLoaded();let r=n===null?this.stylesheet.state?.[e]?.default??null:n;if(t.bQ(r,this._globalState[e]))return this;this._globalState[e]=r,this._applyGlobalStateChanges([e])}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();let n=[];for(let r in e)!t.bQ(this._globalState[r],e[r].default)&&(n.push(r),this._globalState[r]=e[r].default);this._applyGlobalStateChanges(n)}_applyGlobalStateChanges(e){if(e.length===0)return;let t=new Set,n={};for(let r of e){n[r]=this._globalState[r];for(let e in this._layers){let n=this._layers[e],i=n.getLayoutAffectingGlobalStateRefs(),a=n.getPaintAffectingGlobalStateRefs(),o=n.getVisibilityAffectingGlobalStateRefs();if(i.has(r)&&t.add(n.source),a.has(r))for(let{name:e,value:t}of a.get(r))this._updatePaintProperty(n,e,t);o!=null&&o.has(r)&&(n.recalculateVisibility(),this._updateLayer(n))}}this.dispatcher.broadcast(`UGS`,n);for(let e in this.tileManagers)t.has(e)&&(this._reloadSource(e),this._changed=!0)}loadURL(e){return t._(this,arguments,void 0,(function*(e,n={},r){this.fire(new t.n(`dataloading`,{dataType:`style`})),n.validate=typeof n.validate!=`boolean`||n.validate,this._loadStyleRequest=new AbortController;let i=this._loadStyleRequest;try{let a=yield this.map._requestManager.transformRequest(e,`Style`);t.bR(i.signal);let o=yield t.k(a,i);this._loadStyleRequest===i&&(this._loadStyleRequest=null),this._load(o.data,n,r)}catch(e){this._loadStyleRequest===i&&(this._loadStyleRequest=null),e&&!i.signal.aborted&&this.fire(new t.l(t.d(e)))}}))}loadJSON(e,n={},r){this.fire(new t.n(`dataloading`,{dataType:`style`})),this._frameRequest=new AbortController,s.frameAsync(this._frameRequest,this.map._ownerWindow).then((()=>{this._frameRequest=null,n.validate=!1!==n.validate,this._load(e,n,r)})).catch((()=>{}))}loadEmpty(){this.fire(new t.n(`dataloading`,{dataType:`style`})),this._load(Un,{validate:!1})}_load(e,n,r){let i=n.transformStyle?n.transformStyle(r,e):e;if(!n.validate||!Hn(this,t.F(i))){i=Object.assign({},i),this._loaded=!0,this.stylesheet=i;for(let e in i.sources)this.addSource(e,i.sources[e],{validate:!1});i.sprite?this._loadSprite(i.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(i.glyphs),this._createLayers(),this.light=new T(this.stylesheet.light),this._setProjectionInternal(this.stylesheet.projection?.type||`mercator`),this.sky=new D(this.stylesheet.sky),this.map.setTerrain(this.stylesheet.terrain??null),this.fire(new t.n(`data`,{dataType:`style`})),this.fire(new t.n(`style.load`))}}_createLayers(){let e=t.bS(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 n of e){let e=t.bT(n,this._globalState);if(e.setEventedParent(this,{layer:{id:n.id}}),this._layers[n.id]=e,t.bU(e)&&this.tileManagers[e.source]){let t=n.paint?.[`raster-fade-duration`]??e.paint.get(`raster-fade-duration`);this.tileManagers[e.source].setRasterFadeDuration(t)}}}_loadSprite(e,n=!1,r=void 0){this.imageManager.setLoaded(!1);let i=new AbortController,a;this._spriteRequest=i,function(e,n,r,i){return t._(this,void 0,void 0,(function*(){let a=p(e),o=r>1?`@2x`:``,c={},l={};for(let{id:e,url:r}of a){let a=yield n.transformRequest(m(r,o,`.json`),`SpriteJSON`);c[e]=t.k(a,i);let s=yield n.transformRequest(m(r,o,`.png`),`SpriteImage`);l[e]=u.getImage(s,i)}return yield Promise.all([...Object.values(c),...Object.values(l)]),function(e,n){return t._(this,void 0,void 0,(function*(){let t={};for(let r in e){t[r]={};let i=s.getImageCanvasContext((yield n[r]).data),a=(yield e[r]).data;for(let e in a){let{width:n,height:o,x:s,y:c,sdf:l,pixelRatio:u,stretchX:d,stretchY:f,content:p,textFitWidth:m,textFitHeight:h}=a[e];t[r][e]={data:null,pixelRatio:u,sdf:l,stretchX:d,stretchY:f,content:p,textFitWidth:m,textFitHeight:h,spriteData:{width:n,height:o,x:s,y:c,context:i}}}}return t}))}(c,l)}))}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((e=>{if(this._spriteRequest=null,e)for(let t in e){this._spritesImagesIds[t]=[];let r=this._spritesImagesIds[t]?this._spritesImagesIds[t].filter((t=>!(t in e))):[];for(let e of r)this.imageManager.removeImage(e),this._changedImages[e]=!0;for(let r in e[t]){let i=t==="default"?r:`${t}:${r}`;this._spritesImagesIds[t].push(i),i in this.imageManager.images?this.imageManager.updateImage(i,e[t][r],!1):this.imageManager.addImage(i,e[t][r]),n&&(this._changedImages[i]=!0)}}})).catch((e=>{this._spriteRequest=null,a=e,i.signal.aborted||this.fire(new t.l(a))})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),n&&(this._changed=!0),this.dispatcher.broadcast(`SI`,this._availableImages),this.fire(new t.n(`data`,{dataType:`style`})),r&&r(a)}))}_unloadSprite(){for(let e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast(`SI`,this._availableImages),this.fire(new t.n(`data`,{dataType:`style`}))}_validateLayer(e){let n=this.tileManagers[e.source];if(!n)return;let r=e.sourceLayer;if(!r)return;let i=n.getSource();(i.type===`geojson`||i.vectorLayerIds&&!i.vectorLayerIds.includes(r))&&this.fire(new t.l(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,n=!1){let r=this._serializedAllLayers();if(!e||e.length===0)return Object.values(n?t.bV(r):r);let i=[];for(let a of e)if(r[a]){let e=n?t.bV(r[a]):r[a];i.push(e)}return i}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};let t=Object.keys(this._layers);for(let n of t){let t=this._layers[n];t.type!==`custom`&&(e[n]=t.serialize())}return e}hasTransitions(){if(this.light?.hasTransition()||this.sky?.hasTransition()||this.projection?.hasTransition())return!0;for(let e in this.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 n=this._changed;if(n){let t=Object.keys(this._updatedLayers),n=Object.keys(this._removedLayers);(t.length||n.length)&&this._updateWorkerLayers(t,n);for(let e in this._updatedSources){let t=this._updatedSources[e];if(t===`reload`)this._reloadSource(e);else{if(t!==`clear`)throw Error(`Invalid action ${t}`);this._clearSource(e)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(let t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}let r={};for(let e in this.tileManagers){let t=this.tileManagers[e];r[e]=t.used,t.used=!1}for(let t of this._order){let n=this._layers[t];n.recalculate(e,this._availableImages),!n.isHidden(e.zoom)&&n.source&&(this.tileManagers[n.source].used=!0)}for(let e in r){let n=this.tileManagers[e];!!r[e]!=!!n.used&&n.fire(new t.n(`data`,{sourceDataType:`visibility`,dataType:`source`,sourceId:e}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,n&&this.fire(new t.n(`data`,{dataType:`style`}))}_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,n={}){var r;this._checkLoaded();let i=this.serialize();if(e=n.transformStyle?n.transformStyle(i,e):e,((r=n.validate)==null||r)&&Hn(this,t.F(e)))return!1;(e=t.bV(e)).layers=t.bS(e.layers);let a=t.bW(i,e),o=this._getOperationsToPerform(a);if(o.unimplemented.length>0)throw Error(`Unimplemented: ${o.unimplemented.join(`, `)}.`);if(o.operations.length===0)return!1;for(let e of o.operations)e();return this.stylesheet=e,this._serializedLayers=null,this.fire(new t.n(`style.load`,{style:this})),!0}_getOperationsToPerform(e){let t=[],n=[];for(let r of e)switch(r.command){case`setCenter`:case`setZoom`:case`setBearing`:case`setPitch`:case`setRoll`:continue;case`addLayer`:t.push((()=>this.addLayer.apply(this,r.args)));break;case`removeLayer`:t.push((()=>this.removeLayer.apply(this,r.args)));break;case`setPaintProperty`:t.push((()=>this.setPaintProperty.apply(this,r.args)));break;case`setLayoutProperty`:t.push((()=>this.setLayoutProperty.apply(this,r.args)));break;case`setFilter`:t.push((()=>this.setFilter.apply(this,r.args)));break;case`addSource`:t.push((()=>this.addSource.apply(this,r.args)));break;case`removeSource`:t.push((()=>this.removeSource.apply(this,r.args)));break;case`setLayerZoomRange`:t.push((()=>this.setLayerZoomRange.apply(this,r.args)));break;case`setLight`:t.push((()=>this.setLight.apply(this,r.args)));break;case`setGeoJSONSourceData`:t.push((()=>this.setGeoJSONSourceData.apply(this,r.args)));break;case`setGlyphs`:t.push((()=>this.setGlyphs.apply(this,r.args)));break;case`setSprite`:t.push((()=>this.setSprite.apply(this,r.args)));break;case`setTerrain`:t.push((()=>this.map.setTerrain.apply(this,r.args)));break;case`setSky`:t.push((()=>this.setSky.apply(this,r.args)));break;case`setProjection`:this.setProjection.apply(this,r.args);break;case`setGlobalState`:t.push((()=>this.setGlobalState.apply(this,r.args)));break;case`setTransition`:t.push((()=>{}));break;default:n.push(r.command)}return{operations:t,unimplemented:n}}addImage(e,n){if(this.getImage(e))return this.fire(new t.l(Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,n),this._afterImageUpdated(e)}updateImage(e,t){this.imageManager.updateImage(e,t)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new t.l(Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e)}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast(`SI`,this._availableImages),this.fire(new t.n(`data`,{dataType:`style`}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,n,r={}){var i;if(this._checkLoaded(),this.tileManagers[e]!==void 0)throw Error(`Source "${e}" already exists.`);if(!n.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(`, `)}.`);if([`vector`,`raster`,`geojson`,`video`,`image`].includes(n.type)&&this._validate(t.F.source,`sources.${e}`,n,null,r))return;(i=this.map)!=null&&i._collectResourceTiming&&(n.collectResourceTiming=!0);let a=this.tileManagers[e]=new Qe(e,n,this.dispatcher);a.style=this,a.setEventedParent(this,(()=>({isSourceLoaded:a.loaded(),source:a.serialize(),sourceId:e}))),a.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),this.tileManagers[e]===void 0)throw Error(`There is no source with this ID=${e}`);for(let n in this._layers)if(this._layers[n].source===e)return this.fire(new t.l(Error(`Source "${e}" cannot be removed while layer "${n}" is using it.`)));let n=this.tileManagers[e];delete this.tileManagers[e],delete this._updatedSources[e],n.fire(new t.n(`data`,{sourceDataType:`metadata`,dataType:`source`,sourceId:e})),n.setEventedParent(null),n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,t){if(this._checkLoaded(),this.tileManagers[e]===void 0)throw Error(`There is no source with this ID=${e}`);let n=this.tileManagers[e].getSource();if(n.type!==`geojson`)throw Error(`geojsonSource.type is ${n.type}, which is !== 'geojson`);n.setData(t),this._changed=!0}getSource(e){return this.tileManagers[e]?.getSource()}addLayer(e,n,r={}){this._checkLoaded();let i=e.id;if(this.getLayer(i))return void this.fire(new t.l(Error(`Layer "${i}" already exists on this map.`)));let a;if(e.type===`custom`){if(Hn(this,t.bX(e)))return;a=t.bT(e,this._globalState)}else{if(`source`in e&&typeof e.source==`object`&&(this.addSource(i,e.source),e=t.bV(e),e=t.e(e,{source:i})),this._validate(t.F.layer,`layers.${i}`,e,{arrayIndex:-1},r))return;a=t.bT(e,this._globalState),this._validateLayer(a),a.setEventedParent(this,{layer:{id:i}})}let o=n?this._order.indexOf(n):this._order.length;if(n&&o===-1)this.fire(new t.l(Error(`Cannot add layer "${i}" before non-existing layer "${n}".`)));else{if(this._order.splice(o,0,i),this._layerOrderChanged=!0,this._layers[i]=a,this._removedLayers[i]&&a.source&&a.type!==`custom`){let e=this._removedLayers[i];delete this._removedLayers[i],e.type===a.type?(this._updatedSources[a.source]=`reload`,this.tileManagers[a.source].pause()):this._updatedSources[a.source]=`clear`}this._updateLayer(a),a.onAdd&&a.onAdd(this.map)}}moveLayer(e,n){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new t.l(Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===n)return;let r=this._order.indexOf(e);this._order.splice(r,1);let i=n?this._order.indexOf(n):this._order.length;n&&i===-1?this.fire(new t.l(Error(`Cannot move layer "${e}" before non-existing layer "${n}".`))):(this._order.splice(i,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();let n=this._layers[e];if(!n)return void this.fire(new t.l(Error(`Cannot remove non-existing layer "${e}".`)));n.setEventedParent(null);let r=this._order.indexOf(e);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=n,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],n.onRemove&&n.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,n,r){this._checkLoaded();let i=this.getLayer(e);i?i.minzoom===n&&i.maxzoom===r||(n!=null&&(i.minzoom=n),r!=null&&(i.maxzoom=r),this._updateLayer(i)):this.fire(new t.l(Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,n,r={}){this._checkLoaded();let i=this.getLayer(e);if(i){if(!t.bQ(i.filter,n))return n==null?(i.setFilter(void 0),void this._updateLayer(i)):void(this._validate(t.F.filter,`layers.${i.id}.filter`,n,null,r)||(i.setFilter(t.bV(n)),this._updateLayer(i)))}else this.fire(new t.l(Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return t.bV(this.getLayer(e).filter)}setLayoutProperty(e,n,r,i={}){this._checkLoaded();let a=this.getLayer(e);a?t.bQ(a.getLayoutProperty(n),r)||(a.setLayoutProperty(n,r,i),this._updateLayer(a)):this.fire(new t.l(Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,n){let r=this.getLayer(e);if(r)return r.getLayoutProperty(n);this.fire(new t.l(Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,n,r,i={}){this._checkLoaded();let a=this.getLayer(e);a?t.bQ(a.getPaintProperty(n),r)||this._updatePaintProperty(a,n,r,i):this.fire(new t.l(Error(`Cannot style non-existing layer "${e}".`)))}_updatePaintProperty(e,n,r,i={}){e.setPaintProperty(n,r,i)&&this._updateLayer(e),t.bU(e)&&n===`raster-fade-duration`&&this.tileManagers[e.source].setRasterFadeDuration(r),this._changed=!0,this._updatedPaintProps[e.id]=!0,this._serializedLayers=null}getPaintProperty(e,t){return this.getLayer(e).getPaintProperty(t)}setFeatureState(e,n){this._checkLoaded();let r=e.source,i=e.sourceLayer,a=this.tileManagers[r];if(a===void 0)return void this.fire(new t.l(Error(`The source '${r}' does not exist in the map's style.`)));let o=a.getSource().type;o===`geojson`&&i?this.fire(new t.l(Error(`GeoJSON sources cannot have a sourceLayer parameter.`))):o!==`vector`||i?(e.id===void 0&&this.fire(new t.l(Error(`The feature id parameter must be provided.`))),a.setFeatureState(i,e.id,n)):this.fire(new t.l(Error(`The sourceLayer parameter must be provided for vector source types.`)))}removeFeatureState(e,n){this._checkLoaded();let r=e.source,i=this.tileManagers[r];if(i===void 0)return void this.fire(new t.l(Error(`The source '${r}' does not exist in the map's style.`)));let a=i.getSource().type,o=a===`vector`?e.sourceLayer:void 0;a!==`vector`||o?n&&typeof e.id!=`string`&&typeof e.id!=`number`?this.fire(new t.l(Error(`A feature id is required to remove its specific state property.`))):i.removeFeatureState(o,e.id,n):this.fire(new t.l(Error(`The sourceLayer parameter must be provided for vector source types.`)))}getFeatureState(e){this._checkLoaded();let n=e.source,r=e.sourceLayer,i=this.tileManagers[n];if(i!==void 0)return i.getSource().type!==`vector`||r?(e.id===void 0&&this.fire(new t.l(Error(`The feature id parameter must be provided.`))),i.getFeatureState(r,e.id)):void this.fire(new t.l(Error(`The sourceLayer parameter must be provided for vector source types.`)));this.fire(new t.l(Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return t.e({duration:300,delay:0},this.stylesheet?.transition)}serialize(){if(!this._loaded)return;let e=t.bY(this.tileManagers,(e=>e.serialize())),n=this._serializeByIds(this._order,!0),r=this.map.getTerrain()||void 0,i=this.stylesheet;return t.bZ({version:i.version,name:i.name,metadata:i.metadata,light:i.light,sky:i.sky,center:i.center,zoom:i.zoom,bearing:i.bearing,pitch:i.pitch,sprite:i.sprite,glyphs:i.glyphs,transition:i.transition,projection:i.projection,sources:e,layers:n,terrain:r},(e=>e!==void 0))}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&this.tileManagers[e.source].getSource().type!==`raster`&&(this._updatedSources[e.source]=`reload`,this.tileManagers[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){let t=e=>this._layers[e].type===`fill-extrusion`,n={},r=[];for(let i=this._order.length-1;i>=0;i--){let a=this._order[i];if(t(a)){n[a]=i;for(let t of e){let e=t[a];if(e)for(let t of e)r.push(t)}}}r.sort(((e,t)=>t.intersectionZ-e.intersectionZ));let i=[];for(let a=this._order.length-1;a>=0;a--){let o=this._order[a];if(t(o))for(let e=r.length-1;e>=0;e--){let t=r[e].feature;if(n[t.layer.id]<a)break;i.push(t),r.pop()}else for(let t of e){let e=t[o];if(e)for(let t of e)i.push(t.feature)}}return i}queryRenderedFeatures(e,n,r){n!=null&&n.filter&&this._validate(t.F.filter,`queryRenderedFeatures.filter`,n.filter,null,n);let i={};if(n?.layers){if(!(Array.isArray(n.layers)||n.layers instanceof Set))return this.fire(new t.l(Error(`parameters.layers must be an Array or a Set of strings`))),[];for(let e of n.layers){let n=this._layers[e];if(!n)return this.fire(new t.l(Error(`The layer '${e}' does not exist in the map's style and cannot be queried for features.`))),[];i[n.source]=!0}}let a=[];n.availableImages=this._availableImages;let o=this._serializedAllLayers(),s=n.layers instanceof Set?n.layers:Array.isArray(n.layers)?new Set(n.layers):null,c=Object.assign(Object.assign({},n),{layers:s,globalState:this._globalState});for(let t in this.tileManagers)n.layers&&!i[t]||a.push(oe(this.tileManagers[t],this._layers,o,e,c,r,this.map.terrain?(e,t,n)=>this.map.terrain.getElevation(e,t,n):void 0));return this.placement&&a.push(function(e,t,n,r,i,a,o){let s={},c=a.queryRenderedSymbols(r),l=[];for(let e of Object.keys(c).map(Number))l.push(o[e]);l.sort(se);for(let n of l){let r=n.featureIndex.lookupSymbolFeatures(c[n.bucketInstanceId],t,n.bucketIndex,n.sourceLayerIndex,{filterSpec:i.filter,globalState:i.globalState},i.layers,i.availableImages,e);for(let e in r){s[e]||(s[e]=[]);let t=r[e];t.sort(((e,t)=>{let r=n.featureSortOrder;if(r){let n=r.indexOf(e.featureIndex);return r.indexOf(t.featureIndex)-n}return t.featureIndex-e.featureIndex}));for(let n of t)s[e].push(n)}}return function(e,t,n){for(let r in e)for(let i of e[r])ce(i,n[t[r].source]);return e}(s,e,n)}(this._layers,o,this.tileManagers,e,c,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(a)}querySourceFeatures(e,n){n!=null&&n.filter&&this._validate(t.F.filter,`querySourceFeatures.filter`,n.filter,null,n);let r=this.tileManagers[e];return r?function(e,t){let n=e.getRenderableIds().map((t=>e.getTileByID(t))),r=[],i={};for(let e of n){let n=e.tileID.canonical.key;i[n]||(i[n]=!0,e.querySourceFeatures(r,t))}return r}(r,n?Object.assign(Object.assign({},n),{globalState:this._globalState}):{globalState:this._globalState}):[]}getLight(){return this.light.getLight()}setLight(e,n={}){this._checkLoaded();let r=this.light.getLight(),i=!1;for(let n in e)if(!t.bQ(e[n],r[n])){i=!0;break}if(!i)return;let a={now:l(),transition:t.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(e,n),this.light.updateTransitions(a)}getProjection(){return this.stylesheet?.projection}setProjection(e){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,n={}){this._checkLoaded();let r=this.getSky(),i=!1;if(!e&&!r)return;if(e&&!r)i=!0;else if(!e&&r)i=!0;else for(let n in e)if(!t.bQ(e[n],r[n])){i=!0;break}if(!i)return;let a={now:l(),transition:t.e({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=e,this.sky.setSky(e,n),this.sky.updateTransitions(a)}_setProjectionInternal(e){let n=function(e,n){let r={constrainOverride:n};if(Array.isArray(e)){let t=new V({type:e});return{projection:t,transform:new zn(r),cameraHelper:new Vn(t)}}switch(e){case`mercator`:return{projection:new Qt,transform:new z(r),cameraHelper:new ln};case`globe`:{let e=new V({type:[`interpolate`,[`linear`],[`zoom`],11,`vertical-perspective`,12,`mercator`]});return{projection:e,transform:new zn(r),cameraHelper:new Vn(e)}}case`vertical-perspective`:return{projection:new xn,transform:new Rn(r),cameraHelper:new Bn};default:return t.w(`Unknown projection name: ${e}. Falling back to mercator projection.`),{projection:new Qt,transform:new z(r),cameraHelper:new ln}}}(e,this.map.transformConstrain);this.projection=n.projection,this.map.migrateProjection(n.transform,n.cameraHelper);for(let e in this.tileManagers)this.tileManagers[e].reload()}_validate(e,n,r,i,a={}){return!1!==a?.validate&&Hn(this,e.call(t.F,t.e({key:n,style:this.serialize(),value:r,styleSpec:t.x},i)))}_remove(e=!0){this._frameRequest&&=(this._frameRequest.abort(),null),this._loadStyleRequest&&=(this._loadStyleRequest.abort(),null),this._spriteRequest&&=(this._spriteRequest.abort(),null),Ae().off(De,this._rtlPluginLoaded);for(let e in this._layers)this._layers[e].setEventedParent(null);for(let e in this.tileManagers){let t=this.tileManagers[e];t.setEventedParent(null),t.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),e&&this.dispatcher.broadcast(`RM`,void 0),this.dispatcher.remove(e)}_clearSource(e){this.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)}_updatePlacement(e,t,n,r,i=!1){let a=!1,o=!1,s={};for(let t of this._order){let n=this._layers[t];if(n.type!==`symbol`)continue;if(!s[n.source]){let e=this.tileManagers[n.source];s[n.source]=e.getRenderableIds(!0).map((t=>e.getTileByID(t))).sort(((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)))}let r=this.crossTileSymbolIndex.addLayer(n,s[n.source],e.center.lng);a||=r}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),i||=this._layerOrderChanged||n===0,(i||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(l(),e.zoom))&&(this.pauseablePlacement=new zt(e,this.map.terrain,this._order,i,t,n,r,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,s),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(l()),o=!0),a&&this.pauseablePlacement.placement.setStale()),o||a)for(let e of this._order){let t=this._layers[e];t.type===`symbol`&&this.placement.updateLayerOpacities(t,s[t.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(l())}_releaseSymbolFadeTiles(){for(let e in this.tileManagers)this.tileManagers[e].releaseSymbolFadeTiles()}getImages(e,n){return t._(this,void 0,void 0,(function*(){let e=yield this.imageManager.getImages(n.icons);this._updateTilesForChangedImages();let t=this.tileManagers[n.source];return t&&t.setDependencies(n.tileID.key,n.type,n.icons),e}))}getGlyphs(e,n){return t._(this,void 0,void 0,(function*(){let e=yield this.glyphManager.getGlyphs(n.stacks),t=this.tileManagers[n.source];return t&&t.setDependencies(n.tileID.key,n.type,[``]),e}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,n={}){this._checkLoaded(),e&&this._validate(t.F.glyphs,`glyphs`,e,null,n)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}getDashes(e,n){return t._(this,void 0,void 0,(function*(){let e={};for(let[t,r]of Object.entries(n.dashes))e[t]=this.lineAtlas.getDash(r.dasharray,r.round);return e}))}addSprite(e,n,r={},i){this._checkLoaded();let a=[{id:e,url:n}],o=[...p(this.stylesheet.sprite),...a];this._validate(t.F.sprite,`sprite`,o,null,r)||(this.stylesheet.sprite=o,this._loadSprite(a,!0,i))}removeSprite(e){this._checkLoaded();let n=p(this.stylesheet.sprite);if(n.find((t=>t.id===e))){if(this._spritesImagesIds[e])for(let t of this._spritesImagesIds[e])this.imageManager.removeImage(t),this._changedImages[t]=!0;n.splice(n.findIndex((t=>t.id===e)),1),this.stylesheet.sprite=n.length>0?n:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast(`SI`,this._availableImages),this.fire(new t.n(`data`,{dataType:`style`}))}else this.fire(new t.l(Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return p(this.stylesheet.sprite)}setSprite(e,n={},r){this._checkLoaded(),e&&this._validate(t.F.sprite,`sprite`,e,null,n)||(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._availableImages=[],this._spritesImagesIds={}),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={}}}var U=t.aS([{name:`a_pos`,type:`Int16`,components:2},{name:`a_texture_pos`,type:`Int16`,components:2}]);class Gn{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,t,n,r,i,a,o,s,c){this.context=e;let l=this.boundPaintVertexBuffers.length!==r.length;for(let e=0;!l&&e<r.length;e++)this.boundPaintVertexBuffers[e]!==r[e]&&(l=!0);!this.vao||this.boundProgram!==t||this.boundLayoutVertexBuffer!==n||l||this.boundIndexBuffer!==i||this.boundVertexOffset!==a||this.boundDynamicVertexBuffer!==o||this.boundDynamicVertexBuffer2!==s||this.boundDynamicVertexBuffer3!==c?this.freshBind(t,n,r,i,a,o,s,c):(e.bindVertexArray.set(this.vao),o&&o.bind(),i!=null&&i.dynamicDraw&&i.bind(),s&&s.bind(),c&&c.bind())}freshBind(e,t,n,r,i,a,o,s){let c=e.numAttributes,l=this.context,u=l.gl;this.vao&&this.destroy(),this.vao=l.createVertexArray(),l.bindVertexArray.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=t,this.boundPaintVertexBuffers=n,this.boundIndexBuffer=r,this.boundVertexOffset=i,this.boundDynamicVertexBuffer=a,this.boundDynamicVertexBuffer2=o,this.boundDynamicVertexBuffer3=s,t.enableAttributes(u,e);for(let t of n)t.enableAttributes(u,e);a&&a.enableAttributes(u,e),o&&o.enableAttributes(u,e),s&&s.enableAttributes(u,e),t.bind(),t.setVertexAttribPointers(u,e,i);for(let t of n)t.bind(),t.setVertexAttribPointers(u,e,i);a&&(a.bind(),a.setVertexAttribPointers(u,e,i)),r&&r.bind(),o&&(o.bind(),o.setVertexAttribPointers(u,e,i)),s&&(s.bind(),s.setVertexAttribPointers(u,e,i)),l.currentNumAttributes=c}destroy(){this.vao&&=(this.context.deleteVertexArray(this.vao),null)}}let Kn=(e,n,r,i,a)=>({u_texture:0,u_ele_delta:e,u_fog_matrix:n,u_fog_color:r?r.properties.get(`fog-color`):t.bo.white,u_fog_ground_blend:r?r.properties.get(`fog-ground-blend`):1,u_fog_ground_blend_opacity:a?0:r?r.calculateFogBlendOpacity(i):0,u_horizon_color:r?r.properties.get(`horizon-color`):t.bo.white,u_horizon_fog_blend:r?r.properties.get(`horizon-fog-blend`):1,u_is_globe_mode:+!!a}),qn={mainMatrix:`u_projection_matrix`,tileMercatorCoords:`u_projection_tile_mercator_coords`,clippingPlane:`u_projection_clipping_plane`,projectionTransition:`u_projection_transition`,fallbackMatrix:`u_projection_fallback_matrix`};function Jn(e){let t=[];for(let n of e){if(n===null)continue;let e=n.split(` `);t.push(e.pop())}return t}class Yn{constructor(e,n,r,i,a,o,s,c,l=[]){let u=e.gl;this.program=u.createProgram();let d=Jn(n.staticAttributes),f=r?r.getBinderAttributes():[],p=d.concat(f),m=Kt.prelude.staticUniforms?Jn(Kt.prelude.staticUniforms):[],h=s.staticUniforms?Jn(s.staticUniforms):[],g=n.staticUniforms?Jn(n.staticUniforms):[],_=r?r.getBinderUniforms():[],v=m.concat(h).concat(g).concat(_),y=[];for(let e of v)y.includes(e)||y.push(e);let b=r?r.defines():[];gn(u)&&b.unshift(`#version 300 es`),a&&b.push(`#define OVERDRAW_INSPECTOR;`),o&&b.push(`#define TERRAIN3D;`),c&&b.push(c),l&&b.push(...l);let x=b.concat(Kt.prelude.fragmentSource,s.fragmentSource,n.fragmentSource).join(`
749
+ `),S=b.concat(Kt.prelude.vertexSource,s.vertexSource,n.vertexSource).join(`
750
+ `);gn(u)||(x=function(e){return e.replace(/\bin\s/g,`varying `).replace(`out highp vec4 fragColor;`,``).replace(/fragColor/g,`gl_FragColor`).replace(/texture\(/g,`texture2D(`)}(x),S=function(e){return e.replace(/\bin\s/g,`attribute `).replace(/\bout\s/g,`varying `).replace(/texture\(/g,`texture2D(`)}(S));let C=u.createShader(u.FRAGMENT_SHADER);if(u.isContextLost())return void(this.failedToCreate=!0);if(u.shaderSource(C,x),u.compileShader(C),!u.getShaderParameter(C,u.COMPILE_STATUS))throw Error(`Could not compile fragment shader: ${u.getShaderInfoLog(C)}`);u.attachShader(this.program,C);let w=u.createShader(u.VERTEX_SHADER);if(u.isContextLost())return void(this.failedToCreate=!0);if(u.shaderSource(w,S),u.compileShader(w),!u.getShaderParameter(w,u.COMPILE_STATUS))throw Error(`Could not compile vertex shader: ${u.getShaderInfoLog(w)}`);u.attachShader(this.program,w),this.attributes={};let T={};this.numAttributes=p.length;for(let e=0;e<this.numAttributes;e++)p[e]&&(u.bindAttribLocation(this.program,e,p[e]),this.attributes[p[e]]=e);if(u.linkProgram(this.program),!u.getProgramParameter(this.program,u.LINK_STATUS))throw Error(`Program failed to link: ${u.getProgramInfoLog(this.program)}`);u.deleteShader(w),u.deleteShader(C);for(let e of y)if(e&&!T[e]){let t=u.getUniformLocation(this.program,e);t&&(T[e]=t)}this.fixedUniforms=i(e,T),this.terrainUniforms=((e,n)=>({u_depth:new t.b_(e,n.u_depth),u_terrain:new t.b_(e,n.u_terrain),u_terrain_dim:new t.bp(e,n.u_terrain_dim),u_terrain_matrix:new t.c0(e,n.u_terrain_matrix),u_terrain_unpack:new t.c1(e,n.u_terrain_unpack),u_terrain_exaggeration:new t.bp(e,n.u_terrain_exaggeration)}))(e,T),this.projectionUniforms=((e,n)=>({u_projection_matrix:new t.c0(e,n.u_projection_matrix),u_projection_tile_mercator_coords:new t.c1(e,n.u_projection_tile_mercator_coords),u_projection_clipping_plane:new t.c1(e,n.u_projection_clipping_plane),u_projection_transition:new t.bp(e,n.u_projection_transition),u_projection_fallback_matrix:new t.c0(e,n.u_projection_fallback_matrix)}))(e,T),this.binderUniforms=r?r.getUniforms(e,T):[]}draw(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v){var y;let b=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(n),e.setStencilMode(r),e.setColorMode(i),e.setCullFace(a),s){e.activeTexture.set(b.TEXTURE2),b.bindTexture(b.TEXTURE_2D,s.depthTexture),e.activeTexture.set(b.TEXTURE3),b.bindTexture(b.TEXTURE_2D,s.texture);for(let e in this.terrainUniforms)this.terrainUniforms[e].set(s[e])}if(c)for(let e in c)this.projectionUniforms[qn[e]].set(c[e]);if(o)for(let e in this.fixedUniforms)this.fixedUniforms[e].set(o[e]);h&&h.setUniforms(e,this.binderUniforms,p,{zoom:m});let x=0;switch(t){case b.LINES:x=2;break;case b.TRIANGLES:x=3;break;case b.LINE_STRIP:x=1}for(let n of f.get())n.vaos||={},(y=n.vaos)[l]||(y[l]=new Gn),n.vaos[l].bind(e,this,u,h?h.getPaintVertexBuffers():[],d,n.vertexOffset,g,_,v),b.drawElements(t,n.primitiveLength*x,b.UNSIGNED_SHORT,n.primitiveOffset*x*2)}}function Xn(e,n,r){let i=1/t.aK(r,1,n.transform.tileZoom),a=2**r.tileID.overscaledZ,o=r.tileSize*2**n.transform.tileZoom/a,s=o*(r.tileID.canonical.x+r.tileID.wrap*a),c=o*r.tileID.canonical.y;return{u_image:0,u_texsize:r.imageAtlasTexture.size,u_scale:[i,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[s>>16,c>>16],u_pixel_coord_lower:[65535&s,65535&c]}}let Zn=(e,n,r,i)=>{let a=e.style.light,o=a.properties.get(`position`),s=[o.x,o.y,o.z],c=t.c4();a.properties.get(`anchor`)===`viewport`&&t.c5(c,e.transform.bearingInRadians),t.c6(s,s,c);let l=e.transform.transformLightDirection(s),u=a.properties.get(`color`);return{u_lightpos:s,u_lightpos_globe:l,u_lightintensity:a.properties.get(`intensity`),u_lightcolor:[u.r,u.g,u.b],u_vertical_gradient:+n,u_opacity:r,u_fill_translate:i}},Qn=(e,n,r,i,a,o,s)=>t.e(Zn(e,n,r,i),Xn(o,e,s),{u_height_factor:-(2**a.overscaledZ)/s.tileSize/8}),$n=(e,n,r,i)=>t.e(Xn(n,e,r),{u_fill_translate:i}),er=(e,t)=>({u_world:e,u_fill_translate:t}),tr=(e,n,r,i,a)=>t.e($n(e,n,r,a),{u_world:i}),nr=(e,n,r,i,a)=>{let o=e.transform,s,c,l=0;if(r.paint.get(`circle-pitch-alignment`)===`map`){let e=t.aK(n,1,o.zoom);s=!0,c=[e,e],l=e/(t.a6*2**n.tileID.overscaledZ)*2*Math.PI*a}else s=!1,c=o.pixelsToGLUnits;return{u_camera_to_center_distance:o.cameraToCenterDistance,u_scale_with_map:+(r.paint.get(`circle-pitch-scale`)===`map`),u_pitch_with_map:+s,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:c,u_globe_extrude_scale:l,u_translate:i}},rr=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),ir=e=>({u_viewport_size:[e.width,e.height]}),ar=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),or=(e,n,r,i)=>{let a=t.aK(e,1,n)/(t.a6*2**e.tileID.overscaledZ)*2*Math.PI*i;return{u_extrude_scale:t.aK(e,1,n),u_intensity:r,u_globe_extrude_scale:a}},sr=(e,n,r,i)=>{let a=t.O();t.c7(a,0,e.width,e.height,0,0,1);let o=e.context.gl;return{u_matrix:a,u_world:[o.drawingBufferWidth,o.drawingBufferHeight],u_image:r,u_color_ramp:i,u_opacity:n.paint.get(`heatmap-opacity`)}},cr=(e,t,n)=>{let r=n.paint.get(`hillshade-accent-color`),i;switch(n.paint.get(`hillshade-method`)){case`basic`:i=4;break;case`combined`:i=1;break;case`igor`:i=2;break;case`multidirectional`:i=3;break;default:i=0}let a=n.getIlluminationProperties();for(let t=0;t<a.directionRadians.length;t++)n.paint.get(`hillshade-illumination-anchor`)===`viewport`&&(a.directionRadians[t]+=e.transform.bearingInRadians);return{u_image:0,u_latrange:ur(0,t.tileID),u_exaggeration:n.paint.get(`hillshade-exaggeration`),u_altitudes:a.altitudeRadians,u_azimuths:a.directionRadians,u_accent:r,u_method:i,u_highlights:a.highlightColor,u_shadows:a.shadowColor}},lr=(e,n)=>{let r=n.stride,i=t.O();return t.c7(i,0,t.a6,-t.a6,0,0,1),t.Q(i,i,[0,-t.a6,0]),{u_matrix:i,u_image:1,u_dimension:[r,r],u_zoom:e.overscaledZ,u_unpack:n.getUnpackVector()}};function ur(e,n){let r=2**n.canonical.z,i=n.canonical.y;return[new t.a7(0,i/r).toLngLat().lat,new t.a7(0,(i+1)/r).toLngLat().lat]}let dr=(e,t,n=0)=>({u_image:0,u_unpack:t.getUnpackVector(),u_dimension:[t.stride,t.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:n,u_opacity:e.paint.get(`color-relief-opacity`)}),fr=(e,n,r,i)=>{let a=e.transform;return{u_translation:vr(e,n,r),u_ratio:i/t.aK(n,1,a.zoom),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]]}},pr=(e,n,r,i,a)=>t.e(fr(e,n,r,i),{u_image:0,u_image_height:a}),mr=(e,n,r,i,a)=>{let o=e.transform,s=_r(n,o);return{u_translation:vr(e,n,r),u_texsize:n.imageAtlasTexture.size,u_ratio:i/t.aK(n,1,o.zoom),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[s,a.fromScale,a.toScale],u_fade:a.t,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},hr=(e,n,r,i,a)=>{let o=_r(n,e.transform);return t.e(fr(e,n,r,i),{u_tileratio:o,u_crossfade_from:a.fromScale,u_crossfade_to:a.toScale,u_image:0,u_mix:a.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})},gr=(e,n,r,i,a,o)=>{let s=_r(n,e.transform);return t.e(fr(e,n,r,i),{u_image:0,u_image_height:o,u_tileratio:s,u_crossfade_from:a.fromScale,u_crossfade_to:a.toScale,u_image_dash:1,u_mix:a.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})};function _r(e,n){return 1/t.aK(e,1,n.tileZoom)}function vr(e,n,r){return t.aL(e.transform,n,r.paint.get(`line-translate`),r.paint.get(`line-translate-anchor`))}let yr=(e,t,n,r,i)=>{return{u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,u_fade_t:n.mix,u_opacity:n.opacity*r.paint.get(`raster-opacity`),u_image0:0,u_image1:1,u_brightness_low:r.paint.get(`raster-brightness-min`),u_brightness_high:r.paint.get(`raster-brightness-max`),u_saturation_factor:(o=r.paint.get(`raster-saturation`),o>0?1-1/(1.001-o):-o),u_contrast_factor:(a=r.paint.get(`raster-contrast`),a>0?1/(1-a):1+a),u_spin_weights:br(r.paint.get(`raster-hue-rotate`)),u_coords_top:[i[0].x,i[0].y,i[1].x,i[1].y],u_coords_bottom:[i[3].x,i[3].y,i[2].x,i[2].y]};var a,o};function br(e){e*=Math.PI/180;let t=Math.sin(e),n=Math.cos(e);return[(2*n+1)/3,(-Math.sqrt(3)*t-n+1)/3,(Math.sqrt(3)*t-n+1)/3]}let xr=(e,t,n,r,i,a,o,s,c,l,u,d,f)=>{let p=o.transform;return{u_is_size_zoom_constant:+(e===`constant`||e===`source`),u_is_size_feature_constant:+(e===`constant`||e===`camera`),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:p.cameraToCenterDistance,u_pitch:p.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:p.width/p.height,u_fade_change:o.options.fadeDuration?o.symbolFadeChange:1,u_label_plane_matrix:s,u_coord_matrix:c,u_is_text:+u,u_pitch_with_map:+r,u_is_along_line:i,u_is_variable_anchor:a,u_texsize:d,u_texture:0,u_translation:l,u_pitched_scale:f}},Sr=(e,n,r,i,a,o,s,c,l,u,d,f,p,m)=>{let h=s.transform;return t.e(xr(e,n,r,i,a,o,s,c,l,u,d,f,m),{u_gamma_scale:i?Math.cos(h.pitch*Math.PI/180)*h.cameraToCenterDistance:1,u_device_pixel_ratio:s.pixelRatio,u_is_halo:+!!p,u_is_plain:1})},Cr=(e,n,r,i,a,o,s,c,l,u,d,f,p)=>t.e(Sr(e,n,r,i,a,o,s,c,l,u,!0,d,!0,p),{u_texsize_icon:f,u_texture_icon:1}),wr=(e,t)=>({u_opacity:e,u_color:t}),Tr=(e,n,r,i,a)=>t.e(function(e,n,r,i){let a=r.imageManager.getPattern(e.from.toString()),o=r.imageManager.getPattern(e.to.toString()),{width:s,height:c}=r.imageManager.getPixelSize(),l=2**i.tileID.overscaledZ,u=i.tileSize*2**r.transform.tileZoom/l,d=u*(i.tileID.canonical.x+i.tileID.wrap*l),f=u*i.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:a.tl,u_pattern_br_a:a.br,u_pattern_tl_b:o.tl,u_pattern_br_b:o.br,u_texsize:[s,c],u_mix:n.t,u_pattern_size_a:a.displaySize,u_pattern_size_b:o.displaySize,u_scale_a:n.fromScale,u_scale_b:n.toScale,u_tile_units_to_pixels:1/t.aK(i,1,r.transform.tileZoom),u_pixel_coord_upper:[d>>16,f>>16],u_pixel_coord_lower:[65535&d,65535&f]}}(r,a,n,i),{u_opacity:e}),Er=(e,t)=>{},Dr={fillExtrusion:(e,n)=>({u_lightpos:new t.c2(e,n.u_lightpos),u_lightpos_globe:new t.c2(e,n.u_lightpos_globe),u_lightintensity:new t.bp(e,n.u_lightintensity),u_lightcolor:new t.c2(e,n.u_lightcolor),u_vertical_gradient:new t.bp(e,n.u_vertical_gradient),u_opacity:new t.bp(e,n.u_opacity),u_fill_translate:new t.c3(e,n.u_fill_translate)}),fillExtrusionPattern:(e,n)=>({u_lightpos:new t.c2(e,n.u_lightpos),u_lightpos_globe:new t.c2(e,n.u_lightpos_globe),u_lightintensity:new t.bp(e,n.u_lightintensity),u_lightcolor:new t.c2(e,n.u_lightcolor),u_vertical_gradient:new t.bp(e,n.u_vertical_gradient),u_height_factor:new t.bp(e,n.u_height_factor),u_opacity:new t.bp(e,n.u_opacity),u_fill_translate:new t.c3(e,n.u_fill_translate),u_image:new t.b_(e,n.u_image),u_texsize:new t.c3(e,n.u_texsize),u_pixel_coord_upper:new t.c3(e,n.u_pixel_coord_upper),u_pixel_coord_lower:new t.c3(e,n.u_pixel_coord_lower),u_scale:new t.c2(e,n.u_scale),u_fade:new t.bp(e,n.u_fade)}),fill:(e,n)=>({u_fill_translate:new t.c3(e,n.u_fill_translate)}),fillPattern:(e,n)=>({u_image:new t.b_(e,n.u_image),u_texsize:new t.c3(e,n.u_texsize),u_pixel_coord_upper:new t.c3(e,n.u_pixel_coord_upper),u_pixel_coord_lower:new t.c3(e,n.u_pixel_coord_lower),u_scale:new t.c2(e,n.u_scale),u_fade:new t.bp(e,n.u_fade),u_fill_translate:new t.c3(e,n.u_fill_translate)}),fillOutline:(e,n)=>({u_world:new t.c3(e,n.u_world),u_fill_translate:new t.c3(e,n.u_fill_translate)}),fillOutlinePattern:(e,n)=>({u_world:new t.c3(e,n.u_world),u_image:new t.b_(e,n.u_image),u_texsize:new t.c3(e,n.u_texsize),u_pixel_coord_upper:new t.c3(e,n.u_pixel_coord_upper),u_pixel_coord_lower:new t.c3(e,n.u_pixel_coord_lower),u_scale:new t.c2(e,n.u_scale),u_fade:new t.bp(e,n.u_fade),u_fill_translate:new t.c3(e,n.u_fill_translate)}),circle:(e,n)=>({u_camera_to_center_distance:new t.bp(e,n.u_camera_to_center_distance),u_scale_with_map:new t.b_(e,n.u_scale_with_map),u_pitch_with_map:new t.b_(e,n.u_pitch_with_map),u_extrude_scale:new t.c3(e,n.u_extrude_scale),u_device_pixel_ratio:new t.bp(e,n.u_device_pixel_ratio),u_globe_extrude_scale:new t.bp(e,n.u_globe_extrude_scale),u_translate:new t.c3(e,n.u_translate)}),collisionBox:(e,n)=>({u_pixel_extrude_scale:new t.c3(e,n.u_pixel_extrude_scale)}),collisionCircle:(e,n)=>({u_viewport_size:new t.c3(e,n.u_viewport_size)}),debug:(e,n)=>({u_color:new t.b$(e,n.u_color),u_overlay:new t.b_(e,n.u_overlay),u_overlay_scale:new t.bp(e,n.u_overlay_scale)}),depth:Er,clippingMask:Er,heatmap:(e,n)=>({u_extrude_scale:new t.bp(e,n.u_extrude_scale),u_intensity:new t.bp(e,n.u_intensity),u_globe_extrude_scale:new t.bp(e,n.u_globe_extrude_scale)}),heatmapTexture:(e,n)=>({u_matrix:new t.c0(e,n.u_matrix),u_world:new t.c3(e,n.u_world),u_image:new t.b_(e,n.u_image),u_color_ramp:new t.b_(e,n.u_color_ramp),u_opacity:new t.bp(e,n.u_opacity)}),hillshade:(e,n)=>({u_image:new t.b_(e,n.u_image),u_latrange:new t.c3(e,n.u_latrange),u_exaggeration:new t.bp(e,n.u_exaggeration),u_altitudes:new t.c9(e,n.u_altitudes),u_azimuths:new t.c9(e,n.u_azimuths),u_accent:new t.b$(e,n.u_accent),u_method:new t.b_(e,n.u_method),u_shadows:new t.c8(e,n.u_shadows),u_highlights:new t.c8(e,n.u_highlights)}),hillshadePrepare:(e,n)=>({u_matrix:new t.c0(e,n.u_matrix),u_image:new t.b_(e,n.u_image),u_dimension:new t.c3(e,n.u_dimension),u_zoom:new t.bp(e,n.u_zoom),u_unpack:new t.c1(e,n.u_unpack)}),colorRelief:(e,n)=>({u_image:new t.b_(e,n.u_image),u_unpack:new t.c1(e,n.u_unpack),u_dimension:new t.c3(e,n.u_dimension),u_elevation_stops:new t.b_(e,n.u_elevation_stops),u_color_stops:new t.b_(e,n.u_color_stops),u_color_ramp_size:new t.b_(e,n.u_color_ramp_size),u_opacity:new t.bp(e,n.u_opacity)}),line:(e,n)=>({u_translation:new t.c3(e,n.u_translation),u_ratio:new t.bp(e,n.u_ratio),u_device_pixel_ratio:new t.bp(e,n.u_device_pixel_ratio),u_units_to_pixels:new t.c3(e,n.u_units_to_pixels)}),lineGradient:(e,n)=>({u_translation:new t.c3(e,n.u_translation),u_ratio:new t.bp(e,n.u_ratio),u_device_pixel_ratio:new t.bp(e,n.u_device_pixel_ratio),u_units_to_pixels:new t.c3(e,n.u_units_to_pixels),u_image:new t.b_(e,n.u_image),u_image_height:new t.bp(e,n.u_image_height)}),linePattern:(e,n)=>({u_translation:new t.c3(e,n.u_translation),u_texsize:new t.c3(e,n.u_texsize),u_ratio:new t.bp(e,n.u_ratio),u_device_pixel_ratio:new t.bp(e,n.u_device_pixel_ratio),u_image:new t.b_(e,n.u_image),u_units_to_pixels:new t.c3(e,n.u_units_to_pixels),u_scale:new t.c2(e,n.u_scale),u_fade:new t.bp(e,n.u_fade)}),lineSDF:(e,n)=>({u_translation:new t.c3(e,n.u_translation),u_ratio:new t.bp(e,n.u_ratio),u_device_pixel_ratio:new t.bp(e,n.u_device_pixel_ratio),u_units_to_pixels:new t.c3(e,n.u_units_to_pixels),u_image:new t.b_(e,n.u_image),u_mix:new t.bp(e,n.u_mix),u_tileratio:new t.bp(e,n.u_tileratio),u_crossfade_from:new t.bp(e,n.u_crossfade_from),u_crossfade_to:new t.bp(e,n.u_crossfade_to),u_lineatlas_width:new t.bp(e,n.u_lineatlas_width),u_lineatlas_height:new t.bp(e,n.u_lineatlas_height)}),lineGradientSDF:(e,n)=>({u_translation:new t.c3(e,n.u_translation),u_ratio:new t.bp(e,n.u_ratio),u_device_pixel_ratio:new t.bp(e,n.u_device_pixel_ratio),u_units_to_pixels:new t.c3(e,n.u_units_to_pixels),u_image:new t.b_(e,n.u_image),u_image_height:new t.bp(e,n.u_image_height),u_tileratio:new t.bp(e,n.u_tileratio),u_crossfade_from:new t.bp(e,n.u_crossfade_from),u_crossfade_to:new t.bp(e,n.u_crossfade_to),u_image_dash:new t.b_(e,n.u_image_dash),u_mix:new t.bp(e,n.u_mix),u_lineatlas_width:new t.bp(e,n.u_lineatlas_width),u_lineatlas_height:new t.bp(e,n.u_lineatlas_height)}),raster:(e,n)=>({u_tl_parent:new t.c3(e,n.u_tl_parent),u_scale_parent:new t.bp(e,n.u_scale_parent),u_buffer_scale:new t.bp(e,n.u_buffer_scale),u_fade_t:new t.bp(e,n.u_fade_t),u_opacity:new t.bp(e,n.u_opacity),u_image0:new t.b_(e,n.u_image0),u_image1:new t.b_(e,n.u_image1),u_brightness_low:new t.bp(e,n.u_brightness_low),u_brightness_high:new t.bp(e,n.u_brightness_high),u_saturation_factor:new t.bp(e,n.u_saturation_factor),u_contrast_factor:new t.bp(e,n.u_contrast_factor),u_spin_weights:new t.c2(e,n.u_spin_weights),u_coords_top:new t.c1(e,n.u_coords_top),u_coords_bottom:new t.c1(e,n.u_coords_bottom)}),symbolIcon:(e,n)=>({u_is_size_zoom_constant:new t.b_(e,n.u_is_size_zoom_constant),u_is_size_feature_constant:new t.b_(e,n.u_is_size_feature_constant),u_size_t:new t.bp(e,n.u_size_t),u_size:new t.bp(e,n.u_size),u_camera_to_center_distance:new t.bp(e,n.u_camera_to_center_distance),u_pitch:new t.bp(e,n.u_pitch),u_rotate_symbol:new t.b_(e,n.u_rotate_symbol),u_aspect_ratio:new t.bp(e,n.u_aspect_ratio),u_fade_change:new t.bp(e,n.u_fade_change),u_label_plane_matrix:new t.c0(e,n.u_label_plane_matrix),u_coord_matrix:new t.c0(e,n.u_coord_matrix),u_is_text:new t.b_(e,n.u_is_text),u_pitch_with_map:new t.b_(e,n.u_pitch_with_map),u_is_along_line:new t.b_(e,n.u_is_along_line),u_is_variable_anchor:new t.b_(e,n.u_is_variable_anchor),u_texsize:new t.c3(e,n.u_texsize),u_texture:new t.b_(e,n.u_texture),u_translation:new t.c3(e,n.u_translation),u_pitched_scale:new t.bp(e,n.u_pitched_scale)}),symbolSDF:(e,n)=>({u_is_size_zoom_constant:new t.b_(e,n.u_is_size_zoom_constant),u_is_size_feature_constant:new t.b_(e,n.u_is_size_feature_constant),u_size_t:new t.bp(e,n.u_size_t),u_size:new t.bp(e,n.u_size),u_camera_to_center_distance:new t.bp(e,n.u_camera_to_center_distance),u_pitch:new t.bp(e,n.u_pitch),u_rotate_symbol:new t.b_(e,n.u_rotate_symbol),u_aspect_ratio:new t.bp(e,n.u_aspect_ratio),u_fade_change:new t.bp(e,n.u_fade_change),u_label_plane_matrix:new t.c0(e,n.u_label_plane_matrix),u_coord_matrix:new t.c0(e,n.u_coord_matrix),u_is_text:new t.b_(e,n.u_is_text),u_pitch_with_map:new t.b_(e,n.u_pitch_with_map),u_is_along_line:new t.b_(e,n.u_is_along_line),u_is_variable_anchor:new t.b_(e,n.u_is_variable_anchor),u_texsize:new t.c3(e,n.u_texsize),u_texture:new t.b_(e,n.u_texture),u_gamma_scale:new t.bp(e,n.u_gamma_scale),u_device_pixel_ratio:new t.bp(e,n.u_device_pixel_ratio),u_is_halo:new t.b_(e,n.u_is_halo),u_is_plain:new t.b_(e,n.u_is_plain),u_translation:new t.c3(e,n.u_translation),u_pitched_scale:new t.bp(e,n.u_pitched_scale)}),symbolTextAndIcon:(e,n)=>({u_is_size_zoom_constant:new t.b_(e,n.u_is_size_zoom_constant),u_is_size_feature_constant:new t.b_(e,n.u_is_size_feature_constant),u_size_t:new t.bp(e,n.u_size_t),u_size:new t.bp(e,n.u_size),u_camera_to_center_distance:new t.bp(e,n.u_camera_to_center_distance),u_pitch:new t.bp(e,n.u_pitch),u_rotate_symbol:new t.b_(e,n.u_rotate_symbol),u_aspect_ratio:new t.bp(e,n.u_aspect_ratio),u_fade_change:new t.bp(e,n.u_fade_change),u_label_plane_matrix:new t.c0(e,n.u_label_plane_matrix),u_coord_matrix:new t.c0(e,n.u_coord_matrix),u_is_text:new t.b_(e,n.u_is_text),u_pitch_with_map:new t.b_(e,n.u_pitch_with_map),u_is_along_line:new t.b_(e,n.u_is_along_line),u_is_variable_anchor:new t.b_(e,n.u_is_variable_anchor),u_texsize:new t.c3(e,n.u_texsize),u_texsize_icon:new t.c3(e,n.u_texsize_icon),u_texture:new t.b_(e,n.u_texture),u_texture_icon:new t.b_(e,n.u_texture_icon),u_gamma_scale:new t.bp(e,n.u_gamma_scale),u_device_pixel_ratio:new t.bp(e,n.u_device_pixel_ratio),u_is_halo:new t.b_(e,n.u_is_halo),u_translation:new t.c3(e,n.u_translation),u_pitched_scale:new t.bp(e,n.u_pitched_scale)}),background:(e,n)=>({u_opacity:new t.bp(e,n.u_opacity),u_color:new t.b$(e,n.u_color)}),backgroundPattern:(e,n)=>({u_opacity:new t.bp(e,n.u_opacity),u_image:new t.b_(e,n.u_image),u_pattern_tl_a:new t.c3(e,n.u_pattern_tl_a),u_pattern_br_a:new t.c3(e,n.u_pattern_br_a),u_pattern_tl_b:new t.c3(e,n.u_pattern_tl_b),u_pattern_br_b:new t.c3(e,n.u_pattern_br_b),u_texsize:new t.c3(e,n.u_texsize),u_mix:new t.bp(e,n.u_mix),u_pattern_size_a:new t.c3(e,n.u_pattern_size_a),u_pattern_size_b:new t.c3(e,n.u_pattern_size_b),u_scale_a:new t.bp(e,n.u_scale_a),u_scale_b:new t.bp(e,n.u_scale_b),u_pixel_coord_upper:new t.c3(e,n.u_pixel_coord_upper),u_pixel_coord_lower:new t.c3(e,n.u_pixel_coord_lower),u_tile_units_to_pixels:new t.bp(e,n.u_tile_units_to_pixels)}),terrain:(e,n)=>({u_texture:new t.b_(e,n.u_texture),u_ele_delta:new t.bp(e,n.u_ele_delta),u_fog_matrix:new t.c0(e,n.u_fog_matrix),u_fog_color:new t.b$(e,n.u_fog_color),u_fog_ground_blend:new t.bp(e,n.u_fog_ground_blend),u_fog_ground_blend_opacity:new t.bp(e,n.u_fog_ground_blend_opacity),u_horizon_color:new t.b$(e,n.u_horizon_color),u_horizon_fog_blend:new t.bp(e,n.u_horizon_fog_blend),u_is_globe_mode:new t.bp(e,n.u_is_globe_mode)}),terrainDepth:(e,n)=>({u_ele_delta:new t.bp(e,n.u_ele_delta)}),terrainCoords:(e,n)=>({u_texture:new t.b_(e,n.u_texture),u_terrain_coords_id:new t.bp(e,n.u_terrain_coords_id),u_ele_delta:new t.bp(e,n.u_ele_delta)}),projectionErrorMeasurement:(e,n)=>({u_input:new t.bp(e,n.u_input),u_output_expected:new t.bp(e,n.u_output_expected)}),atmosphere:(e,n)=>({u_sun_pos:new t.c2(e,n.u_sun_pos),u_atmosphere_blend:new t.bp(e,n.u_atmosphere_blend),u_globe_position:new t.c2(e,n.u_globe_position),u_globe_radius:new t.bp(e,n.u_globe_radius),u_inv_proj_matrix:new t.c0(e,n.u_inv_proj_matrix)}),sky:(e,n)=>({u_sky_color:new t.b$(e,n.u_sky_color),u_horizon_color:new t.b$(e,n.u_horizon_color),u_horizon:new t.c3(e,n.u_horizon),u_horizon_normal:new t.c3(e,n.u_horizon_normal),u_sky_horizon_blend:new t.bp(e,n.u_sky_horizon_blend),u_sky_blend:new t.bp(e,n.u_sky_blend)})};class Or{constructor(e,t,n){this.context=e;let r=e.gl;this.buffer=r.createBuffer(),this.dynamicDraw=!!n,this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||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(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}let kr={Int8:`BYTE`,Uint8:`UNSIGNED_BYTE`,Int16:`SHORT`,Uint16:`UNSIGNED_SHORT`,Int32:`INT`,Uint32:`UNSIGNED_INT`,Float32:`FLOAT`};class Ar{constructor(e,t,n,r){this.length=t.length,this.attributes=n,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.context=e;let i=e.gl;this.buffer=i.createBuffer(),e.bindVertexBuffer.set(this.buffer),i.bufferData(i.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?i.DYNAMIC_DRAW:i.STATIC_DRAW),this.dynamicDraw||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 n of this.attributes){let r=t.attributes[n.name];r!==void 0&&e.enableVertexAttribArray(r)}}setVertexAttribPointers(e,t,n){for(let r of this.attributes){let i=t.attributes[r.name];i!==void 0&&e.vertexAttribPointer(i,r.components,e[kr[r.type]],!1,this.itemSize,r.offset+this.itemSize*(n||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class jr{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class W extends jr{getDefault(){return t.bo.transparent}set(e){let t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class Mr extends jr{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class Nr extends jr{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class Pr extends jr{getDefault(){return[!0,!0,!0,!0]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class Fr extends jr{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class Ir extends jr{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class Lr extends jr{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){let t=this.current;(e.func!==t.func||e.ref!==t.ref||e.mask!==t.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1)}}class Rr extends jr{getDefault(){let e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1)}}class zr extends jr{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1}}class Br extends jr{getDefault(){return[0,1]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1)}}class Vr extends jr{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),this.current=e,this.dirty=!1}}class Hr extends jr{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class Ur extends jr{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.BLEND):t.disable(t.BLEND),this.current=e,this.dirty=!1}}class Wr extends jr{getDefault(){let e=this.gl;return[e.ONE,e.ZERO]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.blendFunc(e[0],e[1]),this.current=e,this.dirty=!1)}}class Gr extends jr{getDefault(){return t.bo.transparent}set(e){let t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class Kr extends jr{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquation(e),this.current=e,this.dirty=!1)}}class qr extends jr{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),this.current=e,this.dirty=!1}}class Jr extends jr{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class Yr extends jr{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}class Xr extends jr{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}}class Zr extends jr{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class G extends jr{getDefault(){let e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class Qr extends jr{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e),this.current=e,this.dirty=!1}}class $r extends jr{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindRenderbuffer(t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class ei extends jr{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindTexture(t.TEXTURE_2D,e),this.current=e,this.dirty=!1}}class ti extends jr{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class ni extends jr{getDefault(){return null}set(e){let t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class ri extends jr{getDefault(){return null}set(e){var t;if(e===this.current&&!this.dirty)return;let n=this.gl;gn(n)?n.bindVertexArray(e):(t=n.getExtension(`OES_vertex_array_object`))==null||t.bindVertexArrayOES(e),this.current=e,this.dirty=!1}}class ii extends jr{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.pixelStorei(t.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}}class K extends jr{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}}class ai extends jr{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}}class oi extends jr{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}}class si extends oi{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class ci extends oi{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class q extends oi{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}let li=`Framebuffer is not complete`;class ui{constructor(e,t,n,r,i){this.context=e,this.width=t,this.height=n;let a=e.gl,o=this.framebuffer=a.createFramebuffer();if(this.colorAttachment=new si(e,o),r)this.depthAttachment=i?new q(e,o):new ci(e,o);else if(i)throw Error(`Stencil cannot be set without depth`);if(a.checkFramebufferStatus(a.FRAMEBUFFER)!==a.FRAMEBUFFER_COMPLETE)throw Error(li)}destroy(){let e=this.context.gl,t=this.colorAttachment.get();if(t&&e.deleteTexture(t),this.depthAttachment){let t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t)}e.deleteFramebuffer(this.framebuffer)}}class J{constructor(e){if(this.gl=e,this.clearColor=new W(this),this.clearDepth=new Mr(this),this.clearStencil=new Nr(this),this.colorMask=new Pr(this),this.depthMask=new Fr(this),this.stencilMask=new Ir(this),this.stencilFunc=new Lr(this),this.stencilOp=new Rr(this),this.stencilTest=new zr(this),this.depthRange=new Br(this),this.depthTest=new Vr(this),this.depthFunc=new Hr(this),this.blend=new Ur(this),this.blendFunc=new Wr(this),this.blendColor=new Gr(this),this.blendEquation=new Kr(this),this.cullFace=new qr(this),this.cullFaceSide=new Jr(this),this.frontFace=new Yr(this),this.program=new Xr(this),this.activeTexture=new Zr(this),this.viewport=new G(this),this.bindFramebuffer=new Qr(this),this.bindRenderbuffer=new $r(this),this.bindTexture=new ei(this),this.bindVertexBuffer=new ti(this),this.bindElementBuffer=new ni(this),this.bindVertexArray=new ri(this),this.pixelStoreUnpack=new ii(this),this.pixelStoreUnpackPremultiplyAlpha=new K(this),this.pixelStoreUnpackFlipY=new ai(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),gn(e)){this.HALF_FLOAT=e.HALF_FLOAT;let t=e.getExtension(`EXT_color_buffer_half_float`);this.RGBA16F=e.RGBA16F??t?.RGBA16F_EXT,this.RGB16F=e.RGB16F??t?.RGB16F_EXT,e.getExtension(`EXT_color_buffer_float`)}else{e.getExtension(`EXT_color_buffer_half_float`),e.getExtension(`OES_texture_half_float_linear`);let t=e.getExtension(`OES_texture_half_float`);this.HALF_FLOAT=t?.HALF_FLOAT_OES}}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(e,t){return new Or(this,e,t)}createVertexBuffer(e,t,n){return new Ar(this,e,t,n)}createRenderbuffer(e,t,n){let r=this.gl,i=r.createRenderbuffer();return this.bindRenderbuffer.set(i),r.renderbufferStorage(r.RENDERBUFFER,e,t,n),this.bindRenderbuffer.set(null),i}createFramebuffer(e,t,n,r){return new ui(this,e,t,n,r)}clear({color:e,depth:t,stencil:n}){let r=this.gl,i=0;e&&(i|=r.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!0,!0,!0,!0])),t!==void 0&&(i|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),n!==void 0&&(i|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(n),this.stencilMask.set(255)),r.clear(i)}setCullFace(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1)}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1)}setColorMode(e){t.bQ(e.blendFunction,un.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 gn(this.gl)?this.gl.createVertexArray():this.gl.getExtension(`OES_vertex_array_object`)?.createVertexArrayOES()}deleteVertexArray(e){var t;gn(this.gl)?this.gl.deleteVertexArray(e):(t=this.gl.getExtension(`OES_vertex_array_object`))==null||t.deleteVertexArrayOES(e)}unbindVAO(){this.bindVertexArray.set(null)}}let di;function fi(e,n,r,i,a){let o=e.context,s=e.transform,c=o.gl,l=e.useProgram(`collisionBox`),u=[],d=0,f=0;for(let t of i){let i=n.getTile(t).getBucket(r);if(!i)continue;let p=a?i.textCollisionBox:i.iconCollisionBox,m=i.collisionCircleArray;m.length>0&&(u.push({circleArray:m,circleOffset:f,coord:t}),d+=m.length/4,f=d),p&&l.draw(o,c.LINES,pn.disabled,hn.disabled,e.colorModeForRenderPass(),fn.disabled,rr(e.transform),e.style.map.terrain?.getTerrainData(t),s.getProjectionData({overscaledTileID:t,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),r.id,p.layoutVertexBuffer,p.indexBuffer,p.segments,null,e.transform.zoom,null,null,p.collisionVertexBuffer)}if(!a||!u.length)return;let p=e.useProgram(`collisionCircle`),m=new t.ca;m.resize(4*d),m._trim();let h=0;for(let e of u)for(let t=0;t<e.circleArray.length/4;t++){let n=4*t,r=e.circleArray[n+0],i=e.circleArray[n+1],a=e.circleArray[n+2],o=e.circleArray[n+3];m.emplace(h++,r,i,a,o,0),m.emplace(h++,r,i,a,o,1),m.emplace(h++,r,i,a,o,2),m.emplace(h++,r,i,a,o,3)}(!di||di.length<2*d)&&(di=function(e){let n=2*e,r=new t.cc;r.resize(n),r._trim();for(let e=0;e<n;e++){let t=6*e;r.uint16[t+0]=4*e+0,r.uint16[t+1]=4*e+1,r.uint16[t+2]=4*e+2,r.uint16[t+3]=4*e+2,r.uint16[t+4]=4*e+3,r.uint16[t+5]=4*e+0}return r}(d));let g=o.createIndexBuffer(di,!0),_=o.createVertexBuffer(m,t.cb.members,!0);for(let n of u){let i=ir(e.transform);p.draw(o,c.TRIANGLES,pn.disabled,hn.disabled,e.colorModeForRenderPass(),fn.disabled,i,e.style.map.terrain?.getTerrainData(n.coord),null,r.id,_,g,t.aV.simpleSegment(0,2*n.circleOffset,n.circleArray.length,n.circleArray.length/2),null,e.transform.zoom,null,null,null)}_.destroy(),g.destroy()}let pi=t.ap(new Float32Array(16));function mi(e,n,r,i,a,o){let{horizontalAlign:s,verticalAlign:c}=t.aP(e);return new t.P((-(s-.5)*n/a+i[0])*o,(-(c-.5)*r/a+i[1])*o)}function hi(e,n,r,i,a,o){let s=n.tileAnchorPoint.add(new t.P(n.translation[0],n.translation[1]));if(n.pitchWithMap){let e=i.mult(o);r||(e=e.rotate(-a));let t=s.add(e);return ot(t.x,t.y,n.pitchedLabelPlaneMatrix,n.getElevation).point}if(r){let t=ht(n.tileAnchorPoint.x+1,n.tileAnchorPoint.y,n).point.sub(e),r=Math.atan(t.y/t.x)+(t.x<0?Math.PI:0);return e.add(i.rotate(r))}return e.add(i)}function gi(e,n,r,i,a,o,s,c,l,u,d,f){let p=e.text.placedSymbolArray,m=e.text.dynamicLayoutVertexArray,h=e.icon.dynamicLayoutVertexArray,g={};m.clear();for(let h=0;h<p.length;h++){let _=p.get(h),v=_.hidden||!_.crossTileID||e.allowVerticalPlacement&&!_.placedOrientation?null:i[_.crossTileID];if(v){let i=new t.P(_.anchorX,_.anchorY),p={getElevation:f,width:a.width,height:a.height,pitchedLabelPlaneMatrix:o,pitchWithMap:r,transform:a,tileAnchorPoint:i,translation:u,unwrappedTileID:d},h=r?_t(i.x,i.y,p):ht(i.x,i.y,p),y=st(a.cameraToCenterDistance,h.signedDistanceFromCamera),b=t.ay(e.textSizeData,c,_)*y/t.aJ;r&&(b*=e.tilePixelRatio/s);let{width:x,height:S,anchor:C,textOffset:w,textBoxScale:T}=v,E=mi(C,x,S,w,T,b),D=a.getPitchedTextCorrection(i.x+u[0],i.y+u[1],d),O=hi(h.point,p,n,E,-a.bearingInRadians,D),k=e.allowVerticalPlacement&&_.placedOrientation===t.ax.vertical?Math.PI/2:0;for(let e=0;e<_.numGlyphs;e++)t.aD(m,O,k);l&&_.associatedIconIndex>=0&&(g[_.associatedIconIndex]={shiftedAnchor:O,angle:k})}else St(_.numGlyphs,m)}if(l){h.clear();let n=e.icon.placedSymbolArray;for(let e=0;e<n.length;e++){let r=n.get(e);if(r.hidden)St(r.numGlyphs,h);else{let n=g[e];if(n)for(let e=0;e<r.numGlyphs;e++)t.aD(h,n.shiftedAnchor,n.angle);else St(r.numGlyphs,h)}}e.icon.dynamicLayoutVertexBuffer.updateData(h)}e.text.dynamicLayoutVertexBuffer.updateData(m)}function _i(e,t,n){return n.iconsInText&&t?`symbolTextAndIcon`:e?`symbolSDF`:`symbolIcon`}function vi(e,n,r,i,a,o,s,c,l,u,d,f,p){let m=e.context,h=m.gl,g=e.transform,_=c===`map`,v=l===`map`,y=c!==`viewport`&&r.layout.get(`symbol-placement`)!==`point`,b=_&&!v&&!y,x=!r.layout.get(`symbol-sort-key`).isConstant(),S=!1,C=e.getDepthModeForSublayer(0,pn.ReadOnly),w=r._unevaluatedLayout.hasValue(`text-variable-anchor`)||r._unevaluatedLayout.hasValue(`text-variable-anchor-offset`),T=[],E=g.getCircleRadiusCorrection();for(let c of i){let i=n.getTile(c),l=i.getBucket(r);if(!l)continue;let d=a?l.text:l.icon;if(!d?.segments.get().length||!d.hasVisibleVertices)continue;let f=d.programConfigurations.get(r.id),m=a||l.sdfIcons,C=a?l.textSizeData:l.iconSizeData,D=v||g.pitch!==0,O=e.useProgram(_i(m,a,l),f),k=t.aw(C,g.zoom),A=e.style.map.terrain?.getTerrainData(c),ee,te,j,ne,re=[0,0],ie=null;if(a)te=i.glyphAtlasTexture,j=h.LINEAR,ee=i.glyphAtlasTexture.size,l.iconsInText&&(re=i.imageAtlasTexture.size,ie=i.imageAtlasTexture,ne=D||e.options.rotating||e.options.zooming||C.kind===`composite`||C.kind===`camera`?h.LINEAR:h.NEAREST);else{let t=r.layout.get(`icon-size`).constantOr(0)!==1||l.iconsNeedLinear;te=i.imageAtlasTexture,j=m||e.options.rotating||e.options.zooming||t||D?h.LINEAR:h.NEAREST,ee=i.imageAtlasTexture.size}let ae=t.aK(i,1,e.transform.zoom),oe=rt(_,e.transform,ae),se=it(v,_,e.transform,ae),ce=t.aL(g,i,o,s),le=g.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!p,applyTerrainMatrix:!0}),ue=w&&l.hasTextData(),de=r.layout.get(`icon-text-fit`)!==`none`&&ue&&l.hasIconData();if(y){let n=t.O();tt(n,oe);let i=e.style.map.terrain?(t,n)=>e.style.map.terrain.getElevation(c,t,n):null;lt(l,e,a,oe,n,v,u,r.layout.get(`text-rotation-alignment`)===`map`,c.toUnwrapped(),g.width,g.height,ce,i)}let fe=a&&w||de,pe=y||fe?pi:v?oe:e.transform.clipSpaceToPixelsMatrix,me=m&&r.paint.get(a?`text-halo-width`:`icon-halo-width`).constantOr(1)!==0,he;he=m?l.iconsInText?Cr(C.kind,k,b,v,y,fe,e,pe,se,ce,ee,re,E):Sr(C.kind,k,b,v,y,fe,e,pe,se,ce,a,ee,me,E):xr(C.kind,k,b,v,y,fe,e,pe,se,ce,a,ee,E);let ge={program:O,buffers:d,uniformValues:he,projectionData:le,atlasTexture:te,atlasTextureIcon:ie,atlasInterpolation:j,atlasInterpolationIcon:ne,isSDF:m,hasHalo:me};if(x&&l.canOverlap){S=!0;let e=d.segments.get();for(let n of e)T.push({segments:new t.aV([n]),sortKey:n.sortKey,state:ge,terrainData:A})}else T.push({segments:d.segments,sortKey:0,state:ge,terrainData:A})}S&&T.sort(((e,t)=>e.sortKey-t.sortKey));let D=r.paint.get(a?`text-halo-width`:`icon-halo-width`).constantOr(null)??1/0,O=r.layout.get(`text-letter-spacing`).constantOr(0)*t.aJ<0||D>1;for(let t of T){let n=t.state;m.activeTexture.set(h.TEXTURE0),n.atlasTexture.bind(n.atlasInterpolation,h.CLAMP_TO_EDGE),n.atlasTextureIcon&&(m.activeTexture.set(h.TEXTURE1),n.atlasTextureIcon&&n.atlasTextureIcon.bind(n.atlasInterpolationIcon,h.CLAMP_TO_EDGE));let i=n.isSDF&&n.hasHalo;if(i){let i=n.uniformValues;i.u_is_halo=1,O&&(i.u_is_plain=0,yi(n.buffers,t.segments,r,e,n.program,C,d,f,i,n.projectionData,t.terrainData),i.u_is_halo=0,i.u_is_plain=1)}yi(n.buffers,t.segments,r,e,n.program,C,d,f,n.uniformValues,n.projectionData,t.terrainData),i&&!O&&(n.uniformValues.u_is_halo=0)}}function yi(e,t,n,r,i,a,o,s,c,l,u){let d=r.context;i.draw(d,d.gl.TRIANGLES,a,o,s,fn.backCCW,c,u,l,n.id,e.layoutVertexBuffer,e.indexBuffer,t,n.paint,r.transform.zoom,e.programConfigurations.get(n.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function Y(e,n,r,i,a){let o=e.context,s=o.gl,c=hn.disabled,l=new un([s.ONE,s.ONE],t.bo.transparent,[!0,!0,!0,!0]),u=n.getBucket(r);if(!u)return;let d=i.key,f=r.heatmapFbos.get(d);f||(f=xi(o,n.tileSize,n.tileSize),r.heatmapFbos.set(d,f)),o.bindFramebuffer.set(f.framebuffer),o.viewport.set([0,0,n.tileSize,n.tileSize]),o.clear({color:t.bo.transparent});let p=u.programConfigurations.get(r.id),m=e.useProgram(`heatmap`,p,!a),h=e.transform.getProjectionData({overscaledTileID:n.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),g=e.style.map.terrain.getTerrainData(i);m.draw(o,s.TRIANGLES,pn.disabled,c,l,fn.disabled,or(n,e.transform.zoom,r.paint.get(`heatmap-intensity`),1),g,h,r.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,r.paint,e.transform.zoom,p)}function bi(e,t,n,r,i){let a=e.context,o=a.gl,s=e.transform;a.setColorMode(e.colorModeForRenderPass());let c=Si(a,t),l=n.key,u=t.heatmapFbos.get(l);if(!u)return;a.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,u.colorAttachment.get()),a.activeTexture.set(o.TEXTURE1),c.bind(o.LINEAR,o.CLAMP_TO_EDGE);let d=s.getProjectionData({overscaledTileID:n,applyTerrainMatrix:i,applyGlobeMatrix:!r});e.useProgram(`heatmapTexture`).draw(a,o.TRIANGLES,pn.disabled,hn.disabled,e.colorModeForRenderPass(),fn.disabled,sr(e,t,0,1),null,d,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,s.zoom),u.destroy(),t.heatmapFbos.delete(l)}function xi(e,t,n){let r=e.gl,i=r.createTexture();r.bindTexture(r.TEXTURE_2D,i),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR);let a=e.HALF_FLOAT??r.UNSIGNED_BYTE,o=e.RGBA16F??r.RGBA;r.texImage2D(r.TEXTURE_2D,0,o,t,n,0,r.RGBA,a,null);let s=e.createFramebuffer(t,n,!1,!1);return s.colorAttachment.set(i),s}function Si(e,n){return n.colorRampTexture||=new t.T(e,n.colorRamp,e.gl.RGBA),n.colorRampTexture}function Ci(e,n,r,i,a,o,s,c){let l=256;if(a.stepInterpolant){let i=n.getSource().maxzoom,a=s.canonical.z===i?Math.ceil(1<<e.transform.maxZoom-s.canonical.z):1;l=t.al(t.ce(o.maxLineLength/t.a6*1024*a),256,r.maxTextureSize)}return c.gradient=t.cf({expression:a.gradientExpression(),evaluationKey:`lineProgress`,resolution:l,image:c.gradient||void 0,clips:o.lineClipsArray}),c.texture?c.texture.update(c.gradient):c.texture=new t.T(r,c.gradient,i.RGBA),c.version=a.gradientVersion,c.texture}function wi(e,t,n,r,i){e.activeTexture.set(t.TEXTURE0),n.imageAtlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE),r.updatePaintBuffers(i)}function Ti(e,t,n,r,i,a){(i||e.lineAtlas.dirty)&&(t.activeTexture.set(n.TEXTURE0),e.lineAtlas.bind(t)),r.updatePaintBuffers(a)}function Ei(e,t,n,r,i,a,o){let s=a.gradients[i.id],c=s.texture;i.gradientVersion!==s.version&&(c=Ci(e,t,n,r,i,a,o,s)),n.activeTexture.set(r.TEXTURE0),c.bind(i.stepInterpolant?r.NEAREST:r.LINEAR,r.CLAMP_TO_EDGE)}function Di(e,t,n,r,i,a,o,s,c){let l=a.gradients[i.id],u=l.texture;i.gradientVersion!==l.version&&(u=Ci(e,t,n,r,i,a,o,l)),n.activeTexture.set(r.TEXTURE0),u.bind(i.stepInterpolant?r.NEAREST:r.LINEAR,r.CLAMP_TO_EDGE),n.activeTexture.set(r.TEXTURE1),e.lineAtlas.bind(n),s.updatePaintBuffers(c)}function Oi(e,t,n,r,i){if(!n||!r?.imageAtlas)return;let a=r.imageAtlas.patternPositions,o=a[n.to.toString()],s=a[n.from.toString()];if(!o&&s&&(o=s),!s&&o&&(s=o),!o||!s){let e=i.getPaintProperty(t);o=a[e],s=a[e]}o&&s&&e.setConstantPatternPositions(o,s)}function ki(e,n,r,i,a,o,s,c){let l=e.context.gl,u=`fill-pattern`,d=r.paint.get(u),f=d?.constantOr(1),p=r.getCrossfadeParameters(),m,h,g,_,v,y=e.transform,b=r.paint.get(`fill-translate`),x=r.paint.get(`fill-translate-anchor`);s?(h=f&&!r.getPaintProperty(`fill-outline-color`)?`fillOutlinePattern`:`fillOutline`,m=l.LINES):(h=f?`fillPattern`:`fill`,m=l.TRIANGLES);let S=d.constantOr(null);for(let d of i){let i=n.getTile(d);if(f&&!i.patternsLoaded())continue;let C=i.getBucket(r);if(!C)continue;let w=C.programConfigurations.get(r.id),T=e.useProgram(h,w),E=e.style.map.terrain?.getTerrainData(d);f&&(e.context.activeTexture.set(l.TEXTURE0),i.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),w.updatePaintBuffers(p)),Oi(w,u,S,i,r);let D=y.getProjectionData({overscaledTileID:d,applyGlobeMatrix:!c,applyTerrainMatrix:!0}),O=t.aL(y,i,b,x);if(s){_=C.indexBuffer2,v=C.segments2;let t=[l.drawingBufferWidth,l.drawingBufferHeight];g=h===`fillOutlinePattern`&&f?tr(e,p,i,t,O):er(t,O)}else _=C.indexBuffer,v=C.segments,g=f?$n(e,p,i,O):{u_fill_translate:O};let k=e.stencilModeForClipping(d);T.draw(e.context,m,a,k,o,fn.backCCW,g,E,D,r.id,C.layoutVertexBuffer,_,v,r.paint,e.transform.zoom,w)}}function Ai(e,n,r,i,a,o,s,c){let l=e.context,u=l.gl,d=`fill-extrusion-pattern`,f=r.paint.get(d),p=f.constantOr(1),m=r.getCrossfadeParameters(),h=r.paint.get(`fill-extrusion-opacity`),g=f.constantOr(null),_=e.transform;for(let f of i){let i=n.getTile(f),v=i.getBucket(r);if(!v)continue;let y=e.style.map.terrain?.getTerrainData(f),b=v.programConfigurations.get(r.id),x=e.useProgram(p?`fillExtrusionPattern`:`fillExtrusion`,b);p&&(e.context.activeTexture.set(u.TEXTURE0),i.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),b.updatePaintBuffers(m));let S=_.getProjectionData({overscaledTileID:f,applyGlobeMatrix:!c,applyTerrainMatrix:!0});Oi(b,d,g,i,r);let C=t.aL(_,i,r.paint.get(`fill-extrusion-translate`),r.paint.get(`fill-extrusion-translate-anchor`)),w=r.paint.get(`fill-extrusion-vertical-gradient`),T=p?Qn(e,w,h,C,f,m,i):Zn(e,w,h,C);x.draw(l,l.gl.TRIANGLES,a,o,s,fn.backCCW,T,y,S,r.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,r.paint,e.transform.zoom,b,e.style.map.terrain&&v.centroidVertexBuffer)}}function ji(e,t,n,r,i,a,o,s,c){let l=e.style.projection,u=e.context,d=e.transform,f=u.gl,p=[`#define NUM_ILLUMINATION_SOURCES ${n.paint.get(`hillshade-highlight-color`).values.length}`],m=e.useProgram(`hillshade`,null,!1,p),h=!e.options.moving;for(let p of r){let r=t.getTile(p),g=r.fbo;if(!g)continue;let _=l.getMeshFromTileID(u,p.canonical,s,!0,`raster`),v=e.style.map.terrain?.getTerrainData(p);u.activeTexture.set(f.TEXTURE0),f.bindTexture(f.TEXTURE_2D,g.colorAttachment.get());let y=d.getProjectionData({overscaledTileID:p,aligned:h,applyGlobeMatrix:!c,applyTerrainMatrix:!0});m.draw(u,f.TRIANGLES,a,i[p.overscaledZ],o,fn.backCCW,cr(e,r,n),v,y,n.id,_.vertexBuffer,_.indexBuffer,_.segments)}}let Mi=0;function Ni(e,n,r,i,a,o,s,c,l){let u=e.style.projection,d=e.context,f=e.transform,p=d.gl,m=e.useProgram(`colorRelief`),h=!e.options.moving,g=r.paint.get(`resampling`)===`nearest`?p.NEAREST:p.LINEAR,_=!0,v=0;for(let y of i){let i=n.getTile(y),b=i.dem;if(_){Mi||=p.getParameter(p.MAX_TEXTURE_SIZE);let e=Mi,{elevationTexture:t,colorTexture:n}=r.getColorRampTextures(d,e,b.getUnpackVector());d.activeTexture.set(p.TEXTURE1),t.bind(p.NEAREST,p.CLAMP_TO_EDGE),d.activeTexture.set(p.TEXTURE4),n.bind(p.LINEAR,p.CLAMP_TO_EDGE),_=!1,v=t.size[0]}if(!b?.data)continue;let x=b.stride,S=b.getPixels();if(d.activeTexture.set(p.TEXTURE0),d.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture||=e.getTileTexture(x),i.demTexture){let e=i.demTexture;e.update(S,{premultiply:!1}),e.bind(g,p.CLAMP_TO_EDGE)}else i.demTexture=new t.T(d,S,p.RGBA,{premultiply:!1}),i.demTexture.bind(g,p.CLAMP_TO_EDGE);let C=u.getMeshFromTileID(d,y.canonical,c,!0,`raster`),w=e.style.map.terrain?.getTerrainData(y),T=f.getProjectionData({overscaledTileID:y,aligned:h,applyGlobeMatrix:!l,applyTerrainMatrix:!0});m.draw(d,p.TRIANGLES,o,a[y.overscaledZ],s,fn.backCCW,dr(r,i.dem,v),w,T,r.id,C.vertexBuffer,C.indexBuffer,C.segments)}}let Pi=[new t.P(0,0),new t.P(t.a6,0),new t.P(t.a6,t.a6),new t.P(0,t.a6)];function Fi(e,t,n,r,i,a,o,s,c=!1,l=!1){let u=r[r.length-1].overscaledZ,d=e.context,f=d.gl,p=e.useProgram(`raster`),m=e.transform,h=e.style.projection,g=e.colorModeForRenderPass(),_=!e.options.moving,v=n.paint.get(`raster-opacity`),y=n.paint.get(`resampling`)===`nearest`||n.paint.get(`raster-resampling`)===`nearest`?f.NEAREST:f.LINEAR,b=n.paint.get(`raster-fade-duration`),x=!!e.style.map.terrain;for(let S of r){let r=e.getDepthModeForSublayer(S.overscaledZ-u,v===1?pn.ReadWrite:pn.ReadOnly,f.LESS),C=t.getTile(S);d.activeTexture.set(f.TEXTURE0),C.texture.bind(y,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST),d.activeTexture.set(f.TEXTURE1);let{parentTile:w,parentScaleBy:T,parentTopLeft:E,fadeValues:D}=Ii(C,t,b,x);C.fadeOpacity=D.tileOpacity,w?(w.fadeOpacity=D.parentTileOpacity,w.texture.bind(y,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST)):C.texture.bind(y,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST),C.texture.useMipmap&&d.extTextureFilterAnisotropic&&e.transform.pitch>e.options.anisotropicFilterPitch&&f.texParameterf(f.TEXTURE_2D,d.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,d.extTextureFilterAnisotropicMax);let O=e.style.map.terrain?.getTerrainData(S),k=m.getProjectionData({overscaledTileID:S,aligned:_,applyGlobeMatrix:!l,applyTerrainMatrix:!0}),A=yr(E,T,D.fadeMix,n,s),ee=h.getMeshFromTileID(d,S.canonical,a,o,`raster`);p.draw(d,f.TRIANGLES,r,i?i[S.overscaledZ]:hn.disabled,g,c?fn.frontCCW:fn.backCCW,A,O,k,n.id,ee.vertexBuffer,ee.indexBuffer,ee.segments)}}function Ii(e,n,r,i){let a={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(r===0||i)return a;if(e.fadingParentID){let i=n.getLoadedTile(e.fadingParentID);if(!i)return a;let o=2**(i.tileID.overscaledZ-e.tileID.overscaledZ);return{parentTile:i,parentScaleBy:o,parentTopLeft:[e.tileID.canonical.x*o%1,e.tileID.canonical.y*o%1],fadeValues:function(e,n,r){let i=l(),a=(i-n.timeAdded)/r,o=e.fadingDirection===Me.Incoming,s=t.al((i-e.timeAdded)/r,0,1),c=t.al(1-a,0,1),u=o?s:c;return{tileOpacity:u,parentTileOpacity:o?c:s,fadeMix:{opacity:1,mix:1-u}}}(e,i,r)}}return e.selfFading?{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:function(e,n){let r=(l()-e.timeAdded)/n,i=t.al(r,0,1);return{tileOpacity:i,fadeMix:{opacity:i,mix:0}}}(e,r)}:a}let Li=new t.bo(1,0,0,1),Ri=new t.bo(0,1,0,1),zi=new t.bo(0,0,1,1),Bi=new t.bo(1,0,1,1),Vi=new t.bo(0,1,1,1);function Hi(e,t,n,r){Wi(e,0,t+n/2,e.transform.width,n,r)}function Ui(e,t,n,r){Wi(e,t-n/2,0,n,e.transform.height,r)}function Wi(e,t,n,r,i,a){let o=e.context,s=o.gl;s.enable(s.SCISSOR_TEST),s.scissor(t*e.pixelRatio,n*e.pixelRatio,r*e.pixelRatio,i*e.pixelRatio),o.clear({color:a}),s.disable(s.SCISSOR_TEST)}function Gi(e,n,r){let i=e.context,a=i.gl,o=e.useProgram(`debug`),s=pn.disabled,c=hn.disabled,l=e.colorModeForRenderPass(),u=`$debug`,d=e.style.map.terrain?.getTerrainData(r);i.activeTexture.set(a.TEXTURE0);let f=n.getTileByID(r.key).latestRawTileData,p=Math.floor((f?.byteLength||0)/1024),m=n.getTile(r).tileSize,h=512/Math.min(m,512)*(r.overscaledZ/e.transform.zoom)*.5,g=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(g+=` => ${r.overscaledZ}`),function(e,t){e.initDebugOverlayCanvas();let n=e.debugOverlayCanvas,r=e.context.gl,i=e.debugOverlayCanvas.getContext(`2d`);i.clearRect(0,0,n.width,n.height),i.shadowColor=`white`,i.shadowBlur=2,i.lineWidth=1.5,i.strokeStyle=`white`,i.textBaseline=`top`,i.font=`bold 36px Open Sans, sans-serif`,i.fillText(t,5,5),i.strokeText(t,5,5),e.debugOverlayTexture.update(n),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(e,`${g} ${p}kB`);let _=e.transform.getProjectionData({overscaledTileID:r,applyGlobeMatrix:!0,applyTerrainMatrix:!0});o.draw(i,a.TRIANGLES,s,c,un.alphaBlended,fn.disabled,ar(t.bo.transparent,h),null,_,u,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),o.draw(i,a.LINE_STRIP,s,c,l,fn.disabled,ar(t.bo.red),d,_,u,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function Ki(e,t,n,r){let{isRenderingGlobe:i}=r,a=e.context,o=a.gl,s=e.transform,c=e.colorModeForRenderPass(),l=e.getDepthModeFor3D(),u=e.useProgram(`terrain`);a.bindFramebuffer.set(null),a.viewport.set([0,0,e.width,e.height]);for(let r of n){let n=t.getTerrainMesh(r.tileID),d=e.renderToTexture.getTexture(r),f=t.getTerrainData(r.tileID);a.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,d.texture);let p=Kn(t.getMeshFrameDelta(s.zoom),s.calculateFogMatrix(r.tileID.toUnwrapped()),e.style.sky,s.pitch,i),m=s.getProjectionData({overscaledTileID:r.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});u.draw(a,o.TRIANGLES,l,hn.disabled,c,fn.backCCW,p,f,m,`terrain`,n.vertexBuffer,n.indexBuffer,n.segments)}}function qi(e,n){if(!n.mesh){let r=new t.aU;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(1,1),r.emplaceBack(-1,1);let i=new t.aW;i.emplaceBack(0,1,2),i.emplaceBack(0,2,3),n.mesh=new Jt(e.createVertexBuffer(r,Yt.members),e.createIndexBuffer(i),t.aV.simpleSegment(0,0,r.length,i.length))}return n.mesh}let Ji={symbol:function(e,n,r,i,a,o){if(e.renderPass!==`translucent`)return;let{isRenderingToTexture:s}=o,c=hn.disabled,l=e.colorModeForRenderPass();(r._unevaluatedLayout.hasValue(`text-variable-anchor`)||r._unevaluatedLayout.hasValue(`text-variable-anchor-offset`))&&function(e,n,r,i,a,o,s,c,l){let u=n.transform,d=n.style.map.terrain,f=a===`map`,p=o===`map`;for(let a of e){let e=i.getTile(a),o=e.getBucket(r);if(!(o?.text)?.segments.get().length)continue;let m=t.aw(o.textSizeData,u.zoom),h=t.aK(e,1,n.transform.zoom),g=rt(f,n.transform,h),_=r.layout.get(`icon-text-fit`)!==`none`&&o.hasIconData();if(m){let n=2**(u.zoom-e.tileID.overscaledZ),r=d?(e,t)=>d.getElevation(a,e,t):null;gi(o,f,p,l,u,g,n,m,_,t.aL(u,e,s,c),a.toUnwrapped(),r)}}}(i,e,r,n,r.layout.get(`text-rotation-alignment`),r.layout.get(`text-pitch-alignment`),r.paint.get(`text-translate`),r.paint.get(`text-translate-anchor`),a),r.paint.get(`icon-opacity`).constantOr(1)!==0&&vi(e,n,r,i,!1,r.paint.get(`icon-translate`),r.paint.get(`icon-translate-anchor`),r.layout.get(`icon-rotation-alignment`),r.layout.get(`icon-pitch-alignment`),r.layout.get(`icon-keep-upright`),c,l,s),r.paint.get(`text-opacity`).constantOr(1)!==0&&vi(e,n,r,i,!0,r.paint.get(`text-translate`),r.paint.get(`text-translate-anchor`),r.layout.get(`text-rotation-alignment`),r.layout.get(`text-pitch-alignment`),r.layout.get(`text-keep-upright`),c,l,s),n.map.showCollisionBoxes&&(fi(e,n,r,i,!0),fi(e,n,r,i,!1))},circle:function(e,n,r,i,a){if(e.renderPass!==`translucent`)return;let{isRenderingToTexture:o}=a,s=r.paint.get(`circle-opacity`),c=r.paint.get(`circle-stroke-width`),l=r.paint.get(`circle-stroke-opacity`),u=!r.layout.get(`circle-sort-key`).isConstant();if(s.constantOr(1)===0&&(c.constantOr(1)===0||l.constantOr(1)===0))return;let d=e.context,f=d.gl,p=e.transform,m=e.getDepthModeForSublayer(0,pn.ReadOnly),h=hn.disabled,g=e.colorModeForRenderPass(),_=[],v=p.getCircleRadiusCorrection();for(let a of i){let i=n.getTile(a),s=i.getBucket(r);if(!s)continue;let c=r.paint.get(`circle-translate`),l=r.paint.get(`circle-translate-anchor`),d=t.aL(p,i,c,l),f=s.programConfigurations.get(r.id),m=e.useProgram(`circle`,f),h=s.layoutVertexBuffer,g=s.indexBuffer,y=e.style.map.terrain?.getTerrainData(a),b={programConfiguration:f,program:m,layoutVertexBuffer:h,indexBuffer:g,uniformValues:nr(e,i,r,d,v),terrainData:y,projectionData:p.getProjectionData({overscaledTileID:a,applyGlobeMatrix:!o,applyTerrainMatrix:!0})};if(u){let e=s.segments.get();for(let n of e)_.push({segments:new t.aV([n]),sortKey:n.sortKey,state:b})}else _.push({segments:s.segments,sortKey:0,state:b})}u&&_.sort(((e,t)=>e.sortKey-t.sortKey));for(let t of _){let{programConfiguration:n,program:i,layoutVertexBuffer:a,indexBuffer:o,uniformValues:s,terrainData:c,projectionData:l}=t.state;i.draw(d,f.TRIANGLES,m,h,g,fn.backCCW,s,c,l,r.id,a,o,t.segments,r.paint,e.transform.zoom,n)}},heatmap:function(e,n,r,i,a){if(r.paint.get(`heatmap-opacity`)===0)return;let o=e.context,{isRenderingToTexture:s,isRenderingGlobe:c}=a;if(e.style.map.terrain){for(let t of i){let i=n.getTile(t);n.hasRenderableParent(t)||(e.renderPass===`offscreen`?Y(e,i,r,t,c):e.renderPass===`translucent`&&bi(e,r,t,s,c))}o.viewport.set([0,0,e.width,e.height])}else e.renderPass===`offscreen`?function(e,n,r,i){let a=e.context,o=a.gl,s=e.transform,c=hn.disabled,l=new un([o.ONE,o.ONE],t.bo.transparent,[!0,!0,!0,!0]);(function(e,n,r){let i=e.gl;e.activeTexture.set(i.TEXTURE1),e.viewport.set([0,0,n.width/4,n.height/4]);let a=r.heatmapFbos.get(t.cd);a?(i.bindTexture(i.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer)):(a=xi(e,n.width/4,n.height/4),r.heatmapFbos.set(t.cd,a))})(a,e,r),a.clear({color:t.bo.transparent});for(let t of i){if(n.hasRenderableParent(t))continue;let i=n.getTile(t),u=i.getBucket(r);if(!u)continue;let d=u.programConfigurations.get(r.id),f=e.useProgram(`heatmap`,d),p=s.getProjectionData({overscaledTileID:t,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),m=s.getCircleRadiusCorrection();f.draw(a,o.TRIANGLES,pn.disabled,c,l,fn.backCCW,or(i,s.zoom,r.paint.get(`heatmap-intensity`),m),null,p,r.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,r.paint,s.zoom,d)}a.viewport.set([0,0,e.width,e.height])}(e,n,r,i):e.renderPass===`translucent`&&function(e,n){let r=e.context,i=r.gl;r.setColorMode(e.colorModeForRenderPass());let a=n.heatmapFbos.get(t.cd);a&&(r.activeTexture.set(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,a.colorAttachment.get()),r.activeTexture.set(i.TEXTURE1),Si(r,n).bind(i.LINEAR,i.CLAMP_TO_EDGE),e.useProgram(`heatmapTexture`).draw(r,i.TRIANGLES,pn.disabled,hn.disabled,e.colorModeForRenderPass(),fn.disabled,sr(e,n,0,1),null,null,n.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,n.paint,e.transform.zoom))}(e,r)},line:function(e,t,n,r,i){if(e.renderPass!==`translucent`)return;let{isRenderingToTexture:a}=i,o=n.paint.get(`line-opacity`),s=n.paint.get(`line-width`);if(o.constantOr(1)===0||s.constantOr(1)===0)return;let c=e.getDepthModeForSublayer(0,pn.ReadOnly),l=e.colorModeForRenderPass(),u=n.paint.get(`line-dasharray`),d=u.constantOr(1),f=n.paint.get(`line-pattern`),p=f.constantOr(1),m=n.paint.get(`line-gradient`),h=n.getCrossfadeParameters(),g;g=p?`linePattern`:d&&m?`lineGradientSDF`:d?`lineSDF`:m?`lineGradient`:`line`;let _=e.context,v=_.gl,y=e.transform,b=!0;for(let i of r){let r=t.getTile(i);if(p&&!r.patternsLoaded())continue;let o=r.getBucket(n);if(!o)continue;let s=o.programConfigurations.get(n.id),x=e.context.program.get(),S=e.useProgram(g,s),C=b||S.program!==x,w=e.style.map.terrain?.getTerrainData(i),T=f.constantOr(null),E=u?.constantOr(null);if(T&&r.imageAtlas){let e=r.imageAtlas,t=e.patternPositions[T.to.toString()],n=e.patternPositions[T.from.toString()];t&&n&&s.setConstantPatternPositions(t,n)}else if(E){let t=n.layout.get(`line-cap`).constantOr(null)===`round`,r=e.lineAtlas.getDash(E.to,t),i=e.lineAtlas.getDash(E.from,t);s.setConstantDashPositions(r,i)}let D=y.getProjectionData({overscaledTileID:i,applyGlobeMatrix:!a,applyTerrainMatrix:!0}),O=y.getPixelScale(),k;p?(k=mr(e,r,n,O,h),wi(_,v,r,s,h)):d&&m?(k=gr(e,r,n,O,h,o.lineClipsArray.length),Di(e,t,_,v,n,o,i,s,h)):d?(k=hr(e,r,n,O,h),Ti(e,_,v,s,C,h)):m?(k=pr(e,r,n,O,o.lineClipsArray.length),Ei(e,t,_,v,n,o,i)):k=fr(e,r,n,O);let A=e.stencilModeForClipping(i);S.draw(_,v.TRIANGLES,c,A,l,fn.disabled,k,w,D,n.id,o.layoutVertexBuffer,o.indexBuffer,o.segments,n.paint,e.transform.zoom,s,o.layoutVertexBuffer2),b=!1}},fill:function(e,n,r,i,a){let o=r.paint.get(`fill-color`),s=r.paint.get(`fill-opacity`);if(s.constantOr(1)===0)return;let{isRenderingToTexture:c}=a,l=e.colorModeForRenderPass(),u=r.paint.get(`fill-pattern`),d=e.opaquePassEnabledForLayer()&&!u.constantOr(1)&&o.constantOr(t.bo.transparent).a===1&&s.constantOr(0)===1?`opaque`:`translucent`;e.renderPass===d&&ki(e,n,r,i,e.getDepthModeForSublayer(1,e.renderPass===`opaque`?pn.ReadWrite:pn.ReadOnly),l,!1,c),e.renderPass===`translucent`&&r.paint.get(`fill-antialias`)&&ki(e,n,r,i,e.getDepthModeForSublayer(r.getPaintProperty(`fill-outline-color`)?2:0,pn.ReadOnly),l,!0,c)},fillExtrusion:function(e,t,n,r,i){let a=n.paint.get(`fill-extrusion-opacity`);if(a===0)return;let{isRenderingToTexture:o}=i;if(e.renderPass===`translucent`){let i=new pn(e.context.gl.LEQUAL,pn.ReadWrite,e.depthRangeFor3D);if(a!==1||n.paint.get(`fill-extrusion-pattern`).constantOr(1))Ai(e,t,n,r,i,hn.disabled,un.disabled,o),Ai(e,t,n,r,i,e.stencilModeFor3D(),e.colorModeForRenderPass(),o);else{let a=e.colorModeForRenderPass();Ai(e,t,n,r,i,hn.disabled,a,o)}}},hillshade:function(e,n,r,i,a){if(e.renderPass!==`offscreen`&&e.renderPass!==`translucent`)return;let{isRenderingToTexture:o}=a,s=e.context,c=e.style.projection.useSubdivision,l=e.getDepthModeForSublayer(0,pn.ReadOnly),u=e.colorModeForRenderPass();if(e.renderPass===`offscreen`)(function(e,n,r,i,a,o,s){let c=e.context,l=c.gl,u=i.paint.get(`resampling`)===`nearest`?l.NEAREST:l.LINEAR;for(let d of r){let r=n.getTile(d),f=r.dem;if(!f?.data||!r.needsHillshadePrepare)continue;let p=f.dim,m=f.stride,h=f.getPixels();if(c.activeTexture.set(l.TEXTURE1),c.pixelStoreUnpackPremultiplyAlpha.set(!1),r.demTexture||=e.getTileTexture(m),r.demTexture){let e=r.demTexture;e.update(h,{premultiply:!1}),e.bind(l.NEAREST,l.CLAMP_TO_EDGE)}else r.demTexture=new t.T(c,h,l.RGBA,{premultiply:!1}),r.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);c.activeTexture.set(l.TEXTURE0);let g=r.fbo;if(!g){let e=new t.T(c,{width:p,height:p,data:null},l.RGBA);e.bind(u,l.CLAMP_TO_EDGE),g=r.fbo=c.createFramebuffer(p,p,!0,!1),g.colorAttachment.set(e.texture)}c.bindFramebuffer.set(g.framebuffer),c.viewport.set([0,0,p,p]),e.useProgram(`hillshadePrepare`).draw(c,l.TRIANGLES,a,o,s,fn.disabled,lr(r.tileID,f),null,null,i.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments),r.needsHillshadePrepare=!1}})(e,n,i,r,l,hn.disabled,u),s.viewport.set([0,0,e.width,e.height]);else if(e.renderPass===`translucent`)if(c){let[t,a,s]=e.stencilConfigForOverlapTwoPass(i);ji(e,n,r,s,t,l,u,!1,o),ji(e,n,r,s,a,l,u,!0,o)}else{let[t,a]=e.getStencilConfigForOverlapAndUpdateStencilID(i);ji(e,n,r,a,t,l,u,!1,o)}},colorRelief:function(e,t,n,r,i){if(e.renderPass!==`translucent`||!r.length)return;let{isRenderingToTexture:a}=i,o=e.style.projection.useSubdivision,s=e.getDepthModeForSublayer(0,pn.ReadOnly),c=e.colorModeForRenderPass();if(o){let[i,o,l]=e.stencilConfigForOverlapTwoPass(r);Ni(e,t,n,l,i,s,c,!1,a),Ni(e,t,n,l,o,s,c,!0,a)}else{let[i,o]=e.getStencilConfigForOverlapAndUpdateStencilID(r);Ni(e,t,n,o,i,s,c,!1,a)}},raster:function(e,t,n,r,i){if(e.renderPass!==`translucent`||n.paint.get(`raster-opacity`)===0||!r.length)return;let{isRenderingToTexture:a}=i,o=t.getSource(),s=e.style.projection.useSubdivision;if(o instanceof Se)Fi(e,t,n,r,null,!1,!1,o.tileCoords,o.flippedWindingOrder,a);else if(s){let[i,o,s]=e.stencilConfigForOverlapTwoPass(r);Fi(e,t,n,s,i,!1,!0,Pi,!1,a),Fi(e,t,n,s,o,!0,!0,Pi,!1,a)}else{let[i,o]=e.getStencilConfigForOverlapAndUpdateStencilID(r);Fi(e,t,n,o,i,!1,!0,Pi,!1,a)}},background:function(e,t,n,r,i){let a=n.paint.get(`background-color`),o=n.paint.get(`background-opacity`);if(o===0)return;let{isRenderingToTexture:s}=i,c=e.context,l=c.gl,u=e.style.projection,d=e.transform,f=d.tileSize,p=n.paint.get(`background-pattern`);if(e.isPatternMissing(p))return;let m=!p&&a.a===1&&o===1&&e.opaquePassEnabledForLayer()?`opaque`:`translucent`;if(e.renderPass!==m)return;let h=hn.disabled,g=e.getDepthModeForSublayer(0,m===`opaque`?pn.ReadWrite:pn.ReadOnly),_=e.colorModeForRenderPass(),v=e.useProgram(p?`backgroundPattern`:`background`),y=r||We(d,{tileSize:f,terrain:e.style.map.terrain});p&&(c.activeTexture.set(l.TEXTURE0),e.imageManager.bind(e.context));let b=n.getCrossfadeParameters();for(let t of y){let r=d.getProjectionData({overscaledTileID:t,applyGlobeMatrix:!s,applyTerrainMatrix:!0}),i=p?Tr(o,e,p,{tileID:t,tileSize:f},b):wr(o,a),m=e.style.map.terrain?.getTerrainData(t),y=u.getMeshFromTileID(c,t.canonical,!1,!0,`raster`);v.draw(c,l.TRIANGLES,g,h,_,fn.backCCW,i,m,r,n.id,y.vertexBuffer,y.indexBuffer,y.segments)}},sky:function(e,t){let n=e.context,r=n.gl,i=((e,t,n)=>{let r=Math.cos(t.rollInRadians),i=Math.sin(t.rollInRadians),a=Re(t),o=t.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:e.properties.get(`sky-color`),u_horizon_color:e.properties.get(`horizon-color`),u_horizon:[(t.width/2-a*i)*n,(t.height/2+a*r)*n],u_horizon_normal:[-i,r],u_sky_horizon_blend:e.properties.get(`sky-horizon-blend`)*t.height/2*n,u_sky_blend:o}})(t,e.style.map.transform,e.pixelRatio),a=new pn(r.LEQUAL,pn.ReadWrite,[0,1]),o=hn.disabled,s=e.colorModeForRenderPass(),c=e.useProgram(`sky`),l=qi(n,t);c.draw(n,r.TRIANGLES,a,o,s,fn.disabled,i,null,void 0,`sky`,l.vertexBuffer,l.indexBuffer,l.segments)},atmosphere:function(e,n,r){let i=e.context,a=i.gl,o=e.useProgram(`atmosphere`),s=new pn(a.LEQUAL,pn.ReadOnly,[0,1]),c=e.transform,l=function(e,n){let r=e.properties.get(`position`),i=[-r.x,-r.y,-r.z],a=t.ap(new Float64Array(16));return e.properties.get(`anchor`)===`map`&&(t.be(a,a,n.rollInRadians),t.bf(a,a,-n.pitchInRadians),t.be(a,a,n.bearingInRadians),t.bf(a,a,n.center.lat*Math.PI/180),t.bI(a,a,-n.center.lng*Math.PI/180)),t.cg(i,i,a),i}(r,e.transform),u=c.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),d=n.properties.get(`atmosphere-blend`)*u.projectionTransition;if(d===0)return;let f=Tn(c.worldSize,c.center.lat),p=c.inverseProjectionMatrix,m=new Float64Array(4);m[3]=1,t.aE(m,m,c.modelViewProjectionMatrix),m[0]/=m[3],m[1]/=m[3],m[2]/=m[3],m[3]=1,t.aE(m,m,p),m[0]/=m[3],m[1]/=m[3],m[2]/=m[3],m[3]=1;let h=((e,t,n,r,i)=>({u_sun_pos:e,u_atmosphere_blend:t,u_globe_position:n,u_globe_radius:r,u_inv_proj_matrix:i}))(l,d,[m[0],m[1],m[2]],f,p),g=qi(i,n);o.draw(i,a.TRIANGLES,s,hn.disabled,un.alphaBlended,fn.disabled,h,null,null,`atmosphere`,g.vertexBuffer,g.indexBuffer,g.segments)},custom:function(e,t,n,r){let{isRenderingGlobe:i}=r,a=e.context,o=n.implementation,s=e.style.projection,c=e.transform,l=c.getProjectionDataForCustomLayer(i),u={farZ:c.farZ,nearZ:c.nearZ,fov:c.fov*Math.PI/180,modelViewProjectionMatrix:c.modelViewProjectionMatrix,projectionMatrix:c.projectionMatrix,shaderData:{variantName:s.shaderVariantName,vertexShaderPrelude:`const float PI = 3.141592653589793;\nuniform mat4 u_projection_matrix;\n${s.shaderPreludeCode.vertexSource}`,define:s.shaderDefine},defaultProjectionData:l},d=o.renderingMode?o.renderingMode:`2d`;if(e.renderPass===`offscreen`){let t=o.prerender;t&&(e.setCustomLayerDefaults(),a.setColorMode(e.colorModeForRenderPass()),t.call(o,a.gl,u),a.setDirty(),e.setBaseState())}else if(e.renderPass===`translucent`){e.setCustomLayerDefaults(),a.setColorMode(e.colorModeForRenderPass()),a.setStencilMode(hn.disabled);let t=d===`3d`?e.getDepthModeFor3D():e.getDepthModeForSublayer(0,pn.ReadOnly);a.setDepthMode(t),o.render(a.gl,u),a.setDirty(),e.setBaseState(),a.bindFramebuffer.set(null)}},debug:function(e,t,n){for(let r of n)Gi(e,t,r)},debugPadding:function(e){let t=e.transform.padding;Hi(e,e.transform.height-(t.top||0),3,Li),Hi(e,t.bottom||0,3,Ri),Ui(e,t.left||0,3,zi),Ui(e,e.transform.width-(t.right||0),3,Bi);let n=e.transform.centerPoint;(function(e,t,n,r){Wi(e,t-1,n-10,2,20,r),Wi(e,t-10,n-1,20,2,r)})(e,n.x,e.transform.height-n.y,Vi)},terrainDepth:function(e,n){let r=e.context,i=r.gl,a=e.transform,o=un.unblended,s=new pn(i.LEQUAL,pn.ReadWrite,[0,1]),c=n.tileManager.getRenderableTiles(),l=e.useProgram(`terrainDepth`);r.bindFramebuffer.set(n.getFramebuffer(`depth`).framebuffer),r.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),r.clear({color:t.bo.transparent,depth:1});for(let e of c){let t=n.getTerrainMesh(e.tileID),c=n.getTerrainData(e.tileID),u=a.getProjectionData({overscaledTileID:e.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),d={u_ele_delta:n.getMeshFrameDelta(a.zoom)};l.draw(r,i.TRIANGLES,s,hn.disabled,o,fn.backCCW,d,c,u,`terrain`,t.vertexBuffer,t.indexBuffer,t.segments)}r.bindFramebuffer.set(null),r.viewport.set([0,0,e.width,e.height])},terrainCoords:function(e,n){let r=e.context,i=r.gl,a=e.transform,o=un.unblended,s=new pn(i.LEQUAL,pn.ReadWrite,[0,1]),c=n.getCoordsTexture(),l=n.tileManager.getRenderableTiles(),u=e.useProgram(`terrainCoords`);r.bindFramebuffer.set(n.getFramebuffer(`coords`).framebuffer),r.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),r.clear({color:t.bo.transparent,depth:1}),n.coordsIndex=[];for(let e of l){let t=n.getTerrainMesh(e.tileID),l=n.getTerrainData(e.tileID);r.activeTexture.set(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,c.texture);let d={u_terrain_coords_id:(255-n.coordsIndex.length)/255,u_texture:0,u_ele_delta:n.getMeshFrameDelta(a.zoom)},f=a.getProjectionData({overscaledTileID:e.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});u.draw(r,i.TRIANGLES,s,hn.disabled,o,fn.backCCW,d,l,f,`terrain`,t.vertexBuffer,t.indexBuffer,t.segments),n.coordsIndex.push(e.tileID.key)}r.bindFramebuffer.set(null),r.viewport.set([0,0,e.width,e.height])}};class Yi{constructor(e,n){this.drawFunctions=Ji,this.context=new J(e),this.transform=n,this._tileTextures={},this.terrainFacilitator={depthDirty:!0,coordsDirty:!1,matrix:t.ap(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Qe.maxOverzooming+Qe.maxUnderzooming+1,this.depthEpsilon=1/2**16,this.crossTileSymbolIndex=new Wt}resize(e,t,n){if(this.width=Math.floor(e*n),this.height=Math.floor(t*n),this.pixelRatio=n,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let e of this.style._order)this.style._layers[e].resize()}setup(){let e=this.context,n=new t.aU;n.emplaceBack(0,0),n.emplaceBack(t.a6,0),n.emplaceBack(0,t.a6),n.emplaceBack(t.a6,t.a6),this.tileExtentBuffer=e.createVertexBuffer(n,Yt.members),this.tileExtentSegments=t.aV.simpleSegment(0,0,4,2);let r=new t.aU;r.emplaceBack(0,0),r.emplaceBack(t.a6,0),r.emplaceBack(0,t.a6),r.emplaceBack(t.a6,t.a6),this.debugBuffer=e.createVertexBuffer(r,Yt.members),this.debugSegments=t.aV.simpleSegment(0,0,4,5);let i=new t.ch;i.emplaceBack(0,0,0,0),i.emplaceBack(t.a6,0,t.a6,0),i.emplaceBack(0,t.a6,0,t.a6),i.emplaceBack(t.a6,t.a6,t.a6,t.a6),this.rasterBoundsBuffer=e.createVertexBuffer(i,U.members),this.rasterBoundsSegments=t.aV.simpleSegment(0,0,4,2);let a=new t.aU;a.emplaceBack(0,0),a.emplaceBack(t.a6,0),a.emplaceBack(0,t.a6),a.emplaceBack(t.a6,t.a6),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(a,Yt.members),this.rasterBoundsSegmentsPosOnly=t.aV.simpleSegment(0,0,4,5);let o=new t.aU;o.emplaceBack(0,0),o.emplaceBack(1,0),o.emplaceBack(0,1),o.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(o,Yt.members),this.viewportSegments=t.aV.simpleSegment(0,0,4,2);let s=new t.ci;s.emplaceBack(0),s.emplaceBack(1),s.emplaceBack(3),s.emplaceBack(2),s.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(s);let c=new t.aW;c.emplaceBack(1,0,2),c.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(c);let l=this.context.gl;this.stencilClearMode=new hn({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.tileExtentMesh=new Jt(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){let e=this.context,n=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;let r=t.O();t.c7(r,0,this.width,this.height,0,0,1),t.S(r,r,[n.drawingBufferWidth,n.drawingBufferHeight,0]);let i={mainMatrix:r,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:r};this.useProgram(`clippingMask`,null,!0).draw(e,n.TRIANGLES,pn.disabled,this.stencilClearMode,un.disabled,fn.disabled,null,null,i,`$clipping`,this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,t,n){if(this.currentStencilSource===e.source||!e.isTileClipped()||!t?.length)return;this.currentStencilSource=e.source,this.nextStencilID+t.length>256&&this.clearStencil();let r=this.context;r.setColorMode(un.disabled),r.setDepthMode(pn.disabled);let i={};for(let e of t)i[e.key]=this.nextStencilID++;this._renderTileMasks(i,t,n,!0),this._renderTileMasks(i,t,n,!1),this._tileClippingMaskIDs=i}_renderTileMasks(e,t,n,r){let i=this.context,a=i.gl,o=this.style.projection,s=this.transform,c=this.useProgram(`clippingMask`);for(let l of t){let t=e[l.key],u=this.style.map.terrain?.getTerrainData(l),d=o.getMeshFromTileID(this.context,l.canonical,r,!0,`stencil`),f=s.getProjectionData({overscaledTileID:l,applyGlobeMatrix:!n,applyTerrainMatrix:!0});c.draw(i,a.TRIANGLES,pn.disabled,new hn({func:a.ALWAYS,mask:0},t,255,a.KEEP,a.KEEP,a.REPLACE),un.disabled,n?fn.disabled:fn.backCCW,null,u,f,`$clipping`,d.vertexBuffer,d.indexBuffer,d.segments)}}_renderTilesDepthBuffer(){let e=this.context,t=e.gl,n=this.style.projection,r=this.transform,i=this.useProgram(`depth`),a=this.getDepthModeFor3D(),o=We(r,{tileSize:r.tileSize});for(let s of o){let o=this.style.map.terrain?.getTerrainData(s),c=n.getMeshFromTileID(this.context,s.canonical,!0,!0,`raster`),l=r.getProjectionData({overscaledTileID:s,applyGlobeMatrix:!0,applyTerrainMatrix:!0});i.draw(e,t.TRIANGLES,a,hn.disabled,un.disabled,fn.backCCW,null,o,l,`$clipping`,c.vertexBuffer,c.indexBuffer,c.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let e=this.nextStencilID++,t=this.context.gl;return new hn({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){let t=this.context.gl;return new hn({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){let t=this.context.gl,n=e.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),r=n[n.length-1].overscaledZ,i=n[0].overscaledZ-r+1;if(i>1){this.currentStencilSource=void 0,this.nextStencilID+i>256&&this.clearStencil();let e={};for(let n=0;n<i;n++)e[n+r]=new hn({func:t.GEQUAL,mask:255},n+this.nextStencilID,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID+=i,[e,n]}return[{[r]:hn.disabled},n]}stencilConfigForOverlapTwoPass(e){let t=this.context.gl,n=e.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),r=n[n.length-1].overscaledZ,i=n[0].overscaledZ-r+1;if(this.clearStencil(),i>1){let e={},a={};for(let n=0;n<i;n++)e[n+r]=new hn({func:t.GREATER,mask:255},i+1+n,255,t.KEEP,t.KEEP,t.REPLACE),a[n+r]=new hn({func:t.GREATER,mask:255},1+n,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID=2*i+1,[e,a,n]}return this.nextStencilID=3,[{[r]:new hn({func:t.GREATER,mask:255},2,255,t.KEEP,t.KEEP,t.REPLACE)},{[r]:new hn({func:t.GREATER,mask:255},1,255,t.KEEP,t.KEEP,t.REPLACE)},n]}colorModeForRenderPass(){let e=this.context.gl;if(this._showOverdrawInspector){let n=1/8;return new un([e.CONSTANT_COLOR,e.ONE],new t.bo(n,n,n,0),[!0,!0,!0,!0])}return this.renderPass===`opaque`?un.unblended:un.alphaBlended}getDepthModeForSublayer(e,t,n){if(!this.opaquePassEnabledForLayer())return pn.disabled;let r=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new pn(n||this.context.gl.LEQUAL,t,[r,r])}getDepthModeFor3D(){return new pn(this.context.gl.LEQUAL,pn.ReadWrite,this.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(e,n){var r;this.style=e,this.options=n,this.lineAtlas=e.lineAtlas,this.imageManager=e.imageManager,this.glyphManager=e.glyphManager,this.symbolFadeChange=e.placement.symbolFadeChange(l()),this.imageManager.beginFrame();let i=this.style._order,a=this.style.tileManagers,o={},s={},c={},u={isRenderingToTexture:!1,isRenderingGlobe:e.projection?.transitionState>0};for(let e in a){let t=a[e];t.used&&t.prepare(this.context),o[e]=t.getVisibleCoordinates(!1),s[e]=o[e].slice().reverse(),c[e]=t.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let e=0;e<i.length;e++)if(this.style._layers[i[e]].is3D()){this.opaquePassCutoff=e;break}this.maybeDrawDepth(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass=`offscreen`;for(let e of i){let t=this.style._layers[e];if(!t.hasOffscreenPass()||t.isHidden(this.transform.zoom))continue;let n=s[t.source];(t.type===`custom`||n.length)&&this.renderLayer(this,a[t.source],t,n,u)}if((r=this.style.projection)==null||r.updateGPUdependent({context:this.context,useProgram:e=>this.useProgram(e)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:n.showOverdrawInspector?t.bo.black:t.bo.transparent,depth:1}),this.clearStencil(),this.style.sky&&this.drawFunctions.sky(this,this.style.sky),this._showOverdrawInspector=n.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass=`opaque`,this.currentLayer=i.length-1;this.currentLayer>=0;this.currentLayer--){let e=this.style._layers[i[this.currentLayer]],t=a[e.source],n=o[e.source];this._renderTileClippingMasks(e,n,!1),this.renderLayer(this,t,e,n,u)}this.renderPass=`translucent`;let d=!1;for(this.currentLayer=0;this.currentLayer<i.length;this.currentLayer++){let e=this.style._layers[i[this.currentLayer]],t=a[e.source];if(this.renderToTexture?.renderLayer(e,u))continue;this.opaquePassEnabledForLayer()||d||(d=!0,u.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());let n=(e.type===`symbol`?c:s)[e.source];this._renderTileClippingMasks(e,o[e.source],!!this.renderToTexture),this.renderLayer(this,t,e,n,u)}if(u.isRenderingGlobe&&this.drawFunctions.atmosphere(this,this.style.sky,this.style.light),this.options.showTileBoundaries){let e=function(e,t){let n=null,r=Object.values(e._layers).flatMap((n=>n.source&&!n.isHidden(t)?[e.tileManagers[n.source]]:[])),i=r.filter((e=>e.getSource().type===`vector`)),a=r.filter((e=>e.getSource().type!==`vector`)),o=e=>{(!n||n.getSource().maxzoom<e.getSource().maxzoom)&&(n=e)};for(let e of i)o(e);if(!n)for(let e of a)o(e);return n}(this.style,this.transform.zoom);e&&this.drawFunctions.debug(this,e,e.getVisibleCoordinates())}this.options.showPadding&&this.drawFunctions.debugPadding(this),this.context.setDefault()}maybeDrawDepth(e){if(!this.style?.map?.terrain)return;let n=this.terrainFacilitator.matrix,r=this.transform.modelViewProjectionMatrix,i=this.terrainFacilitator.depthDirty;i||=e?!t.cj(n,r):!t.ck(n,r),i||=this.style.map.terrain.tileManager.anyTilesAfterTime(this.terrainFacilitator.renderTime),i&&(t.cl(n,r),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.depthDirty=!1,this.terrainFacilitator.coordsDirty=!0,this.drawFunctions.terrainDepth(this,this.style.map.terrain))}maybeDrawCoords(){var e;(e=this.style?.map)!=null&&e.terrain&&this.terrainFacilitator.coordsDirty&&(this.terrainFacilitator.coordsDirty=!1,this.drawFunctions.terrainCoords(this,this.style.map.terrain))}renderLayer(e,n,r,i,a){if(r.isHidden(this.transform.zoom)||r.type!==`background`&&r.type!==`custom`&&!(i||[]).length)return;this.id=r.id;let o=this.drawFunctions;t.aQ(r)?o.symbol(e,n,r,i,this.style.placement.variableOffsets,a):t.cm(r)?o.circle(e,n,r,i,a):t.cn(r)?o.heatmap(e,n,r,i,a):t.co(r)?o.line(e,n,r,i,a):t.cp(r)?o.fill(e,n,r,i,a):t.cq(r)?o.fillExtrusion(e,n,r,i,a):t.cr(r)?o.hillshade(e,n,r,i,a):t.cs(r)?o.colorRelief(e,n,r,i,a):t.bU(r)?o.raster(e,n,r,i,a):t.ct(r)?o.background(e,n,r,i,a):t.cu(r)&&o.custom(e,n,r,a)}saveTileTexture(e){let t=this._tileTextures[e.size[0]];t?t.length<Yi.MAX_TEXTURE_POOL_SIZE_PER_BUCKET?t.push(e):e.destroy():this._tileTextures[e.size[0]]=[e]}getTileTexture(e){let t=this._tileTextures[e];return t&&t.length>0?t.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;let t=this.imageManager.getPattern(e.from.toString()),n=this.imageManager.getPattern(e.to.toString());return!t||!n}useProgram(e,t,n=!1,r=[]){var i;this.cache||={};let a=!!this.style.map.terrain,o=this.style.projection,s=n?Kt.projectionMercator:o.shaderPreludeCode,c=n?Xt:o.shaderDefine,l=e+(t?t.cacheKey:``)+`/${n?Zt:o.shaderVariantName}`+(this._showOverdrawInspector?`/overdraw`:``)+(a?`/terrain`:``)+(r?`/${r.join(`/`)}`:``);return(i=this.cache)[l]||(i[l]=new Yn(this.context,Kt[e],t,Dr[e],this._showOverdrawInspector,a,s,c,r)),this.cache[l]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){let e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas??(this.debugOverlayCanvas=document.createElement(`canvas`),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new t.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){var e,t;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={}}if(this.tileExtentBuffer&&this.tileExtentBuffer.destroy(),this.debugBuffer&&this.debugBuffer.destroy(),this.rasterBoundsBuffer&&this.rasterBoundsBuffer.destroy(),this.rasterBoundsBufferPosOnly&&this.rasterBoundsBufferPosOnly.destroy(),this.viewportBuffer&&this.viewportBuffer.destroy(),this.tileBorderIndexBuffer&&this.tileBorderIndexBuffer.destroy(),this.quadTriangleIndexBuffer&&this.quadTriangleIndexBuffer.destroy(),this.tileExtentMesh&&((e=this.tileExtentMesh.vertexBuffer)==null||e.destroy()),this.tileExtentMesh&&((t=this.tileExtentMesh.indexBuffer)==null||t.destroy()),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.cache){for(let e in this.cache){let t=this.cache[e];t!=null&&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}}function Xi(e,t){let n,r=!1,i=null,a=()=>{i=null,r&&=(e(...n),i=setTimeout(a,t),!1)};return(...e)=>(r=!0,n=e,i||a(),i)}Yi.MAX_TEXTURE_POOL_SIZE_PER_BUCKET=50;class Zi{constructor(e){this._getCurrentHash=()=>{let e=window.location.hash.replace(`#`,``);if(this._hashName){let t,n=e.split(`&`).map((e=>e.split(`=`)));for(let e of n)e[0]===this._hashName&&(t=e);return(t&&t[1]||``).split(`/`)}return e.split(`/`)},this._onHashChange=()=>{let e=this._getCurrentHash();if(!this._isValidHash(e))return!1;let t=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(e[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:t,pitch:+(e[4]||0)}),!0},this._updateHashUnthrottled=()=>{let e=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,e)},this._removeHash=()=>{let e=this._getCurrentHash();if(e.length===0)return;let t=e.join(`/`),n=t;n.split(`&`).length>0&&(n=n.split(`&`)[0]),this._hashName&&(n=`${this._hashName}=${t}`);let r=window.location.hash.replace(n,``);r.startsWith(`#&`)?r=r.slice(0,1)+r.slice(2):r===`#`&&(r=``);let i=window.location.href.replace(/(#.+)?$/,r);i=i.replace(`&&`,`&`),window.history.replaceState(window.history.state,null,i)},this._updateHash=Xi(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,addEventListener(`hashchange`,this._onHashChange,!1),this._map.on(`moveend`,this._updateHash),this}remove(){return removeEventListener(`hashchange`,this._onHashChange,!1),this._map.off(`moveend`,this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){let t=this._map.getCenter(),n=Math.round(100*this._map.getZoom())/100,r=10**Math.ceil((n*Math.LN2+Math.log(512/360/.5))/Math.LN10),i=Math.round(t.lng*r)/r,a=Math.round(t.lat*r)/r,o=this._map.getBearing(),s=this._map.getPitch(),c=``;if(c+=e?`/${i}/${a}/${n}`:`${n}/${a}/${i}`,(o||s)&&(c+=`/`+Math.round(10*o)/10),s&&(c+=`/${Math.round(s)}`),this._hashName){let e=this._hashName,t=!1,n=window.location.hash.slice(1).split(`&`).map((n=>{let r=n.split(`=`)[0];return r===e?(t=!0,`${r}=${c}`):n})).filter((e=>e));return t||n.push(`${e}=${c}`),`#${n.join(`&`)}`}return`#${c}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return!1;try{new t.W(+e[2],+e[1])}catch{return!1}let n=+e[0],r=+(e[3]||0),i=+(e[4]||0);return n>=this._map.getMinZoom()&&n<=this._map.getMaxZoom()&&r>=-180&&r<=180&&i>=this._map.getMinPitch()&&i<=this._map.getMaxPitch()}}let Qi={linearity:.3,easing:t.cv(0,0,.3,1)},$i=t.e({deceleration:2500,maxSpeed:1400},Qi),ea=t.e({deceleration:20,maxSpeed:1400},Qi),ta=t.e({deceleration:1e3,maxSpeed:360},Qi),na=t.e({deceleration:1e3,maxSpeed:90},Qi),ra=t.e({deceleration:1e3,maxSpeed:360},Qi);class ia{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:l(),settings:e})}_drainInertiaBuffer(){let e=this._inertiaBuffer,t=l();for(;e.length>0&&t-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;let n={zoom:0,bearing:0,pitch:0,roll:0,pan:new t.P(0,0),pinchAround:void 0,around:void 0};for(let{settings:e}of this._inertiaBuffer)n.zoom+=e.zoomDelta||0,n.bearing+=e.bearingDelta||0,n.pitch+=e.pitchDelta||0,n.roll+=e.rollDelta||0,e.panDelta&&n.pan._add(e.panDelta),e.around&&(n.around=e.around),e.pinchAround&&(n.pinchAround=e.pinchAround);let r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,i={};if(n.pan.mag()){let a=oa(n.pan.mag(),r,t.e({},$i,e||{})),o=n.pan.mult(a.amount/n.pan.mag()),s=this._map.cameraHelper.handlePanInertia(o,this._map.transform);i.center=s.easingCenter,i.offset=s.easingOffset,aa(i,a)}if(n.zoom){let e=oa(n.zoom,r,ea);i.zoom=t.cw(this._map.transform.zoom+e.amount,this._map.getZoomSnap(),e.amount),aa(i,e)}if(n.bearing){let e=oa(n.bearing,r,ta);i.bearing=this._map.transform.bearing+t.al(e.amount,-179,179),aa(i,e)}if(n.pitch){let e=oa(n.pitch,r,na);i.pitch=this._map.transform.pitch+e.amount,aa(i,e)}if(n.roll){let e=oa(n.roll,r,ra);i.roll=this._map.transform.roll+t.al(e.amount,-179,179),aa(i,e)}if(i.zoom||i.bearing){let e=n.pinchAround===void 0?n.around:n.pinchAround;i.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),t.e(i,{noMoveStart:!0})}}function aa(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing)}function oa(e,n,r){let{maxSpeed:i,linearity:a,deceleration:o}=r,s=t.al(e*a/(n/1e3),-i,i),c=Math.abs(s)/(o*a);return{easing:r.easing,duration:1e3*c,amount:c/2*s}}class sa extends t.n{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,r,i={}){r=r instanceof MouseEvent?r:new MouseEvent(e,r);let a=d.mousePos(n.getCanvas(),r),o=n.unproject(a);super(e,t.e({point:a,lngLat:o,originalEvent:r},i)),this._defaultPrevented=!1,this.target=n}}class ca extends t.n{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,r){let i=e===`touchend`?r.changedTouches:r.touches,a=d.touchPos(n.getCanvasContainer(),i),o=a.map((e=>n.unproject(e))),s=a.reduce(((e,t,n,r)=>e.add(t.div(r.length))),new t.P(0,0));super(e,{points:a,point:s,lngLats:o,lngLat:n.unproject(s),originalEvent:r}),this._defaultPrevented=!1}}class la extends t.n{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,n){super(e,{originalEvent:n}),this._defaultPrevented=!1}}class ua{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new la(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new sa(e.type,this._map,e))}mouseup(e){this._map.fire(new sa(e.type,this._map,e))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this._map.fire(new sa(e.type,this._map,e))}dblclick(e){return this._firePreventable(new sa(e.type,this._map,e))}mouseover(e){this._map.fire(new sa(e.type,this._map,e))}mouseout(e){this._map.fire(new sa(e.type,this._map,e))}touchstart(e){return this._firePreventable(new ca(e.type,this._map,e))}touchmove(e){this._map.fire(new ca(e.type,this._map,e))}touchend(e){this._map.fire(new ca(e.type,this._map,e))}touchcancel(e){this._map.fire(new ca(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class da{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new sa(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new sa(`contextmenu`,this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new sa(e.type,this._map,e)),this._map.listens(`contextmenu`)&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class fa{constructor(e){this._map=e}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this._map.terrain)}}class pa{constructor(e,t){this._map=e,this._tr=new fa(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1,t.boxZoom&&typeof t.boxZoom==`object`&&(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&&e.button===0&&(d.disableDrag(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;let n=t;if(this._lastPos.equals(n)||!this._box&&n.dist(this._startPos)<this._clickTolerance)return;let r=this._startPos;this._lastPos=n,this._box||(this._box=d.create(`div`,`maplibregl-boxzoom`,this._container),this._container.classList.add(`maplibregl-crosshair`),this._fireEvent(`boxzoomstart`,e));let i=Math.min(r.x,n.x),a=Math.max(r.x,n.x),o=Math.min(r.y,n.y),s=Math.max(r.y,n.y);this._box.style.transform=`translate(${i}px,${o}px)`,this._box.style.width=a-i+`px`,this._box.style.height=s-o+`px`}mouseupWindow(e,n){if(!this._active||e.button!==0)return;let r=this._startPos,i=n;if(this.reset(),d.suppressClick(),r.x!==i.x||r.y!==i.y)return this._map.fire(new t.n(`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&&e.keyCode===27&&(this.reset(),this._fireEvent(`boxzoomcancel`,e))}reset(){this._active=!1,this._container.classList.remove(`maplibregl-crosshair`),this._box&&=(this._box.remove(),null),d.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,n){return this._map.fire(new t.n(e,{originalEvent:n}))}}function ma(e,t){if(e.length!==t.length)throw Error(`The number of touches and points are not equal - touches ${e.length}, points ${t.length}`);let n={};for(let r=0;r<e.length;r++)n[e[r].identifier]=t[r];return n}class ha{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(e,n,r){(this.centroid||r.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=e.timeStamp),r.length===this.numTouches&&(this.centroid=function(e){let n=new t.P(0,0);for(let t of e)n._add(t);return n.div(e.length)}(n),this.touches=ma(r,n)))}touchmove(e,t,n){if(this.aborted||!this.centroid)return;let r=ma(n,t);for(let e in this.touches){let t=r[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0)}}touchend(e,t,n){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),n.length===0){let e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class X{constructor(e){this.singleTap=new ha(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,t,n){this.singleTap.touchstart(e,t,n)}touchmove(e,t,n){this.singleTap.touchmove(e,t,n)}touchend(e,t,n){let r=this.singleTap.touchend(e,t,n);if(r){let t=e.timeStamp-this.lastTime<500,n=!this.lastTap||this.lastTap.dist(r)<30;if(t&&n||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class ga{constructor(e){this._tr=new fa(e),this._zoomIn=new X({numTouches:1,numTaps:2}),this._zoomOut=new X({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,n){this._zoomIn.touchstart(e,t,n),this._zoomOut.touchstart(e,t,n)}touchmove(e,t,n){this._zoomIn.touchmove(e,t,n),this._zoomOut.touchmove(e,t,n)}touchend(e,n,r){let i=this._zoomIn.touchend(e,n,r),a=this._zoomOut.touchend(e,n,r),o=this._tr;return i?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:n=>n.easeTo({duration:300,zoom:t.cw(o.zoom+1,n.getZoomSnap()),around:o.unproject(i)},{originalEvent:e})}):a?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:n=>n.easeTo({duration:300,zoom:t.cw(o.zoom-1,n.getZoomSnap()),around:o.unproject(a)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class _a{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){let t=this._moveFunction(...e);if(t.bearingDelta||t.pitchDelta||t.rollDelta||t.around||t.panDelta)return this._active=!0,t}dragStart(e,t){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(t)?t[0]:t,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,t){if(!this.isEnabled())return;let n=this._lastPoint;if(!n)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);let r=Array.isArray(t)?t[0]:t;return!this._moved&&r.dist(n)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=r,this._move(n,r))}dragEnd(e){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(e)&&(this._moved&&d.suppressClick(),this.reset(e))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}let va={0:1,2:2};class Z{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 n=va[t];return e.buttons===void 0||(e.buttons&n)!==n}(e,this._eventButton)}isValidEndEvent(e){return e.button===this._eventButton}}class ya{constructor(){this._firstTouch=void 0}_isOneFingerTouch(e){return e.targetTouches.length===1}_isSameTouchEvent(e){return e.targetTouches[0].identifier===this._firstTouch}startMove(e){this._firstTouch=e.targetTouches[0].identifier}endMove(e){delete this._firstTouch}isValidStartEvent(e){return this._isOneFingerTouch(e)}isValidMoveEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}isValidEndEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}}class ba{constructor(e=new Z({checkCorrectEvent:()=>!0}),t=new ya){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=t}_executeRelevantHandler(e,t,n){return e instanceof MouseEvent?t(e):typeof TouchEvent<`u`&&e instanceof TouchEvent?n(e):void 0}startMove(e){this._executeRelevantHandler(e,(e=>{this.mouseMoveStateManager.startMove(e)}),(e=>{this.oneFingerTouchMoveStateManager.startMove(e)}))}endMove(e){this._executeRelevantHandler(e,(e=>{this.mouseMoveStateManager.endMove(e)}),(e=>{this.oneFingerTouchMoveStateManager.endMove(e)}))}isValidStartEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidStartEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidStartEvent(e)))}isValidMoveEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidMoveEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(e)))}isValidEndEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidEndEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidEndEvent(e)))}}let xa=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault()}};class Sa{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._map=t,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new t.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,t,n){return this._calculateTransform(e,t,n)}touchmove(e,t,n){if(this._active){if(!this._shouldBePrevented(n.length))return e.preventDefault(),this._calculateTransform(e,t,n);this._map.cooperativeGestures.notifyGestureBlocked(`touch_pan`,e)}}touchend(e,t,n){this._calculateTransform(e,t,n),this._active&&this._shouldBePrevented(n.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,n,r){r.length>0&&(this._active=!0);let i=ma(r,n),a=new t.P(0,0),o=new t.P(0,0),s=0;for(let e in i){let t=i[e],n=this._touches[e];n&&(a._add(t),o._add(t.sub(n)),s++,i[e]=t)}if(this._touches=i,this._shouldBePrevented(s)||!o.mag())return;let c=o.div(s);return this._sum._add(c),this._sum.mag()<this._clickTolerance?void 0:{around:a.div(s),panDelta:c}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ca{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(e,t,n){this._firstTwoTouches||n.length<2||(this._firstTwoTouches=[n[0].identifier,n[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,n){if(!this._firstTwoTouches)return;e.preventDefault();let[r,i]=this._firstTwoTouches,a=wa(n,t,r),o=wa(n,t,i);if(!a||!o)return;let s=this._aroundCenter?null:a.add(o).div(2);return this._move([a,o],s,e)}touchend(e,t,n){if(!this._firstTwoTouches)return;let[r,i]=this._firstTwoTouches,a=wa(n,t,r),o=wa(n,t,i);a&&o||(this._active&&d.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&e.around===`center`}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}}function wa(e,t,n){for(let r=0;r<e.length;r++)if(e[r].identifier===n)return t[r]}function Ta(e,t){return Math.log(e/t)/Math.LN2}class Ea extends Ca{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 n=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(Math.abs(Ta(this._distance,this._startDistance))<this._zoomThreshold))return this._active=!0,{zoomDelta:Ta(this._distance,n)*this._zoomRate,pinchAround:t}}}function Da(e,t){return 180*e.angleWith(t)/Math.PI}class Oa extends Ca{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1])}_move(e,t,n){let r=this._vector;if(this._vector=e[0].sub(e[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Da(this._vector,r),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());let t=25/(Math.PI*this._minDiameter)*360,n=Da(e,this._startVector);return Math.abs(n)<t}}function ka(e){return Math.abs(e.y)>Math.abs(e.x)}class Aa extends Ca{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,t,n){super.touchstart(e,t,n),this._currentTouchCount=n.length}_start(e){this._lastPoints=e,ka(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,n){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;let r=e[0].sub(this._lastPoints[0]),i=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(r,i,n.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(r.y+i.y)/2*-.5}):void 0}gestureBeginsVertically(e,t,n){if(this._valid!==void 0)return this._valid;let r=e.mag()>=2,i=t.mag()>=2;if(!r&&!i)return;if(!r||!i)return this._firstMove===void 0&&(this._firstMove=n),n-this._firstMove<100&&void 0;let a=e.y>0==t.y>0;return ka(e)&&ka(t)&&a}}let ja={panStep:100,bearingStep:15,pitchStep:10};class Ma{constructor(e){this._tr=new fa(e);let t=ja;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let n=0,r=0,i=0,a=0,o=0;switch(e.keyCode){case 61:case 107:case 171:case 187:n=1;break;case 189:case 109:case 173:n=-1;break;case 37:e.shiftKey?r=-1:(e.preventDefault(),a=-1);break;case 39:e.shiftKey?r=1:(e.preventDefault(),a=1);break;case 38:e.shiftKey?i=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?i=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(r=0,i=0),{cameraAnimation:s=>{let c=this._tr;s.easeTo({duration:300,easeId:`keyboardHandler`,easing:Na,zoom:n?t.cw(c.zoom+n*(e.shiftKey?2:1),s.getZoomSnap()):c.zoom,bearing:c.bearing+r*this._bearingStep,pitch:c.pitch+i*this._pitchStep,offset:[-a*this._panStep,-o*this._panStep],center:c.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 Na(e){return e*(2-e)}let Pa=4.000244140625;class Fa{constructor(e,t){this._onTimeout=e=>{this._type=`wheel`,this._delta-=this._lastValue,this._active||this._start(e)},this._map=e,this._tr=new fa(e),this._triggerRenderFrame=t,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&e.around===`center`)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return!!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked(`wheel_zoom`,e);let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY,n=l(),r=n-(this._lastWheelEventTime||0);this._lastWheelEventTime=n,t!==0&&t%Pa==0?this._type=`wheel`:t!==0&&Math.abs(t)<4?this._type=`trackpad`:r>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(r*t)<200?`trackpad`:`wheel`,this._timeout&&(clearTimeout(this._timeout),this._timeout=null,t+=this._lastValue)),e.shiftKey&&t&&(t/=4),this._type&&(this._lastWheelEvent=e,this._delta-=t,this._active||this._start(e)),e.preventDefault()}_start(e){if(!this._delta)return;this._needsRerender=!1,this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);let n=d.mousePos(this._map.getCanvas(),e),r=this._tr;this._aroundPoint=this._aroundCenter?r.transform.locationToScreenPoint(t.W.convert(r.center)):n,this._needsRerender||(this._needsRerender=!0,this._triggerRenderFrame())}renderFrame(){if(!this._needsRerender||(this._needsRerender=!1,!this.isActive()))return;let e=this._tr.transform;if(typeof this._lastExpectedZoom==`number`){let t=e.zoom-this._lastExpectedZoom;typeof this._startZoom==`number`&&(this._startZoom+=t),typeof this._targetZoom==`number`&&(this._targetZoom+=t)}if(this._delta!==0){let n=this._type===`wheel`&&Math.abs(this._delta)>Pa?this._wheelZoomRate:this._defaultZoomRate,r=2/(1+Math.exp(-Math.abs(this._delta*n)));this._delta<0&&r!==0&&(r=1/r);let i=typeof this._targetZoom==`number`?t.ao(this._targetZoom):e.scale,a=e.applyConstrain(e.getCameraLngLat(),t.ar(i*r)).zoom,o=this._map.getZoomSnap();if(this._type===`wheel`&&o>0){let n=t.cw(e.zoom,o);this._targetZoom=t.cw(a,o,a-n)}else this._targetZoom=a;this._type===`wheel`&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}let n=typeof this._targetZoom==`number`?this._targetZoom:e.zoom,r=this._startZoom,i=this._easing,a,o=!1;if(this._type===`wheel`&&r&&i){let e=l()-this._lastWheelEventTime,s=Math.min((e+5)/200,1),c=i(s);a=t.H.number(r,n,c),s<1?this._needsRerender=!0:o=!0}else a=n,o=!0;return this._active=!0,o&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout}),200)),this._lastExpectedZoom=a,{noInertia:!0,needsRenderFrame:!o,zoomDelta:a-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let n=t.cy;if(this._prevEase){let e=this._prevEase,r=(l()-e.start)/e.duration,i=e.easing(r+.01)-e.easing(r),a=.27/Math.sqrt(i*i+1e-4)*.01,o=Math.sqrt(.0729-a*a);n=t.cv(a,o,.25,1)}return this._prevEase={start:l(),duration:e,easing:n},n}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Ia{constructor(e,t){this._clickZoom=e,this._tapZoom=t}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class La{constructor(e){this._tr=new fa(e),this.reset()}reset(){this._active=!1}dblclick(e,n){return e.preventDefault(),{cameraAnimation:r=>{r.easeTo({duration:300,zoom:t.cw(this._tr.zoom+(e.shiftKey?-1:1),r.getZoomSnap()),around:this._tr.unproject(n)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ra{constructor(){this._tap=new X({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,n){if(!this._swipePoint)if(this._tapTime){let r=t[0],i=e.timeStamp-this._tapTime<500,a=this._tapPoint.dist(r)<30;i&&a?n.length>0&&(this._swipePoint=r,this._swipeTouch=n[0].identifier):this.reset()}else this._tap.touchstart(e,t,n)}touchmove(e,t,n){if(this._tapTime){if(this._swipePoint){if(n[0].identifier!==this._swipeTouch)return;let r=t[0],i=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:i/128*this._zoomRate}}}else this._tap.touchmove(e,t,n)}touchend(e,t,n){if(this._tapTime)this._swipePoint&&n.length===0&&this.reset();else{let r=this._tap.touchend(e,t,n);r&&(this._tapTime=e.timeStamp,this._tapPoint=r)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class za{constructor(e,t,n){this._el=e,this._mousePan=t,this._touchPan=n}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add(`maplibregl-touch-drag-pan`)}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove(`maplibregl-touch-drag-pan`)}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Ba{constructor(e,t,n,r){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=t,this._mousePitch=n,this._mouseRoll=r}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class Va{constructor(e,t,n,r){this._el=e,this._touchZoom=t,this._touchRotate=n,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add(`maplibregl-touch-zoom-rotate`)}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove(`maplibregl-touch-zoom-rotate`)}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}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()}}class Ha{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=d.create(`div`,`maplibregl-cooperative-gesture-screen`,e);let t=this._map._getUIString(`CooperativeGesturesHandler.WindowsHelpText`);this._bypassKey===`metaKey`&&(t=this._map._getUIString(`CooperativeGesturesHandler.MacHelpText`));let n=this._map._getUIString(`CooperativeGesturesHandler.MobileHelpText`),r=document.createElement(`div`);r.className=`maplibregl-desktop-message`,r.textContent=t,this._container.appendChild(r);let i=document.createElement(`div`);i.className=`maplibregl-mobile-message`,i.textContent=n,this._container.appendChild(i),this._container.setAttribute(`aria-hidden`,`true`)}_destroyUI(){this._container&&(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,n){this._enabled&&(this._map.fire(new t.n(`cooperativegestureprevented`,{gestureType:e,originalEvent:n})),this._container.classList.add(`maplibregl-show`),setTimeout((()=>{this._container.classList.remove(`maplibregl-show`)}),100))}}let Ua=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class Wa extends t.n{}function Ga(e){return e.panDelta?.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class Q{get _ownerDocument(){return this._el?.ownerDocument||document}get _ownerWindow(){return this._el?.ownerDocument?.defaultView||window}constructor(e,n){this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`)},this.handleEvent=(e,n)=>{if(e.type===`blur`)return void this.stop(!0);this._updatingCamera=!0;let r=e.type===`renderFrame`?void 0:e,i={needsRenderFrame:!1},a={},o={};for(let{handlerName:s,handler:c,allowed:l}of this._handlers){if(!c.isEnabled())continue;let u;if(this._blockedByActive(o,l,s))c.reset();else if(c[n||e.type]){if(t.cz(e,n||e.type)){let t=d.mousePos(this._map.getCanvas(),e);u=c[n||e.type](e,t)}else if(t.cA(e,n||e.type)){let t=this._getMapTouches(e.touches),r=d.touchPos(this._map.getCanvas(),t);u=c[n||e.type](e,r,t)}else t.cB(n||e.type)||(u=c[n||e.type](e));this.mergeHandlerResult(i,a,u,s,r),u!=null&&u.needsRenderFrame&&this._triggerRenderFrame()}(u||c.isActive())&&(o[s]=c)}let s={};for(let e in this._previousActiveHandlers)o[e]||(s[e]=r);this._previousActiveHandlers=o,(Object.keys(s).length||Ga(i))&&(this._changes.push([i,a,s]),this._triggerRenderFrame()),(Object.keys(o).length||Ga(i))&&this._map._stop(!0),this._updatingCamera=!1;let{cameraAnimation:c}=i;c&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],c(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new ia(e),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(n);let r=this._el;this._listeners=[[r,`touchstart`,{passive:!0}],[r,`touchmove`,{passive:!1}],[r,`touchend`,void 0],[r,`touchcancel`,void 0],[r,`mousedown`,void 0],[r,`mousemove`,void 0],[r,`mouseup`,void 0],[this._ownerDocument,`mousemove`,{capture:!0}],[this._ownerDocument,`mouseup`,void 0],[r,`mouseover`,void 0],[r,`mouseout`,void 0],[r,`dblclick`,void 0],[r,`click`,void 0],[r,`keydown`,{capture:!1}],[r,`keyup`,void 0],[r,`wheel`,{passive:!1}],[r,`contextmenu`,void 0],[this._ownerWindow,`blur`,void 0]];for(let[e,t,n]of this._listeners)e.addEventListener(t,e===this._ownerDocument?this.handleWindowEvent:this.handleEvent,n)}destroy(){for(let[e,t,n]of this._listeners)e.removeEventListener(t,e===this._ownerDocument?this.handleWindowEvent:this.handleEvent,n)}_addDefaultHandlers(e){let n=this._map,r=n.getCanvasContainer();this._add(`mapEvent`,new ua(n,e));let i=n.boxZoom=new pa(n,e);this._add(`boxZoom`,i),e.interactive&&e.boxZoom&&i.enable();let a=n.cooperativeGestures=new Ha(n,e.cooperativeGestures);this._add(`cooperativeGestures`,a),e.cooperativeGestures&&a.enable();let o=new ga(n),s=new La(n);n.doubleClickZoom=new Ia(s,o),this._add(`tapZoom`,o),this._add(`clickZoom`,s),e.interactive&&e.doubleClickZoom&&n.doubleClickZoom.enable();let c=new Ra;this._add(`tapDragZoom`,c);let l=n.touchPitch=new Aa(n);this._add(`touchPitch`,l),e.interactive&&e.touchPitch&&n.touchPitch.enable(e.touchPitch);let u=()=>n.project(n.getCenter()),d=function({enable:e,clickTolerance:n,aroundCenter:r=!0,minPixelCenterThreshold:i=100,rotateDegreesPerPixelMoved:a=.8},o){return new _a({clickTolerance:n,move:(e,n)=>{let s=o();if(r&&Math.abs(s.y-e.y)>i)return{bearingDelta:t.cx(new t.P(e.x,n.y),n,s)};let c=(n.x-e.x)*a;return r&&n.y<s.y&&(c=-c),{bearingDelta:c}},moveStateManager:new Z({checkCorrectEvent:e=>e.button===0&&e.ctrlKey||e.button===2&&!e.ctrlKey}),enable:e,assignEvents:xa})}(e,u),f=function({enable:e,clickTolerance:t,pitchDegreesPerPixelMoved:n=-.5}){return new _a({clickTolerance:t,move:(e,t)=>({pitchDelta:(t.y-e.y)*n}),moveStateManager:new Z({checkCorrectEvent:e=>e.button===0&&e.ctrlKey||e.button===2}),enable:e,assignEvents:xa})}(e),p=function({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:n=.3},r){return new _a({clickTolerance:t,move:(e,t)=>{let i=r(),a=(t.x-e.x)*n;return t.y<i.y&&(a=-a),{rollDelta:a}},moveStateManager:new Z({checkCorrectEvent:e=>e.button===2&&e.ctrlKey}),enable:e,assignEvents:xa})}(e,u);n.dragRotate=new Ba(e,d,f,p),this._add(`mouseRotate`,d,[`mousePitch`]),this._add(`mousePitch`,f,[`mouseRotate`,`mouseRoll`]),this._add(`mouseRoll`,p,[`mousePitch`]),e.interactive&&e.dragRotate&&n.dragRotate.enable();let m=function({enable:e,clickTolerance:t}){return new _a({clickTolerance:t,move:(e,t)=>({around:t,panDelta:t.sub(e)}),activateOnStart:!0,moveStateManager:new Z({checkCorrectEvent:e=>e.button===0&&!e.ctrlKey}),enable:e,assignEvents:xa})}(e),h=new Sa(e,n);n.dragPan=new za(r,m,h),this._add(`mousePan`,m),this._add(`touchPan`,h,[`touchZoom`,`touchRotate`]),e.interactive&&e.dragPan&&n.dragPan.enable(e.dragPan);let g=new Oa,_=new Ea;n.touchZoomRotate=new Va(r,_,g,c),this._add(`touchRotate`,g,[`touchPan`,`touchZoom`]),this._add(`touchZoom`,_,[`touchPan`,`touchRotate`]),e.interactive&&e.touchZoomRotate&&n.touchZoomRotate.enable(e.touchZoomRotate),this._add(`blockableMapEvent`,new da(n));let v=n.scrollZoom=new Fa(n,(()=>this._triggerRenderFrame()));this._add(`scrollZoom`,v,[`mousePan`]),e.interactive&&e.scrollZoom&&n.scrollZoom.enable(e.scrollZoom);let y=n.keyboard=new Ma(n);this._add(`keyboard`,y),e.interactive&&e.keyboard&&n.keyboard.enable()}_add(e,t,n){this._handlers.push({handlerName:e,handler:t,allowed:n}),this._handlersById[e]=t}stop(e){if(!this._updatingCamera){for(let{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(let{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Ua(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,t,n){for(let r in e)if(r!==n&&!t?.includes(r))return!0;return!1}_getMapTouches(e){let t=[];for(let n of e)this._el.contains(n.target)&&t.push(n);return t}mergeHandlerResult(e,n,r,i,a){if(!r)return;t.e(e,r);let o={handlerName:i,originalEvent:r.originalEvent||a};r.zoomDelta!==void 0&&(n.zoom=o),r.panDelta!==void 0&&(n.drag=o),r.rollDelta!==void 0&&(n.roll=o),r.pitchDelta!==void 0&&(n.pitch=o),r.bearingDelta!==void 0&&(n.rotate=o)}_applyChanges(){let e={},n={},r={};for(let[i,a,o]of this._changes)i.panDelta&&(e.panDelta=(e.panDelta||new t.P(0,0))._add(i.panDelta)),i.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+i.zoomDelta),i.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+i.bearingDelta),i.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+i.pitchDelta),i.rollDelta&&(e.rollDelta=(e.rollDelta||0)+i.rollDelta),i.around!==void 0&&(e.around=i.around),i.pinchAround!==void 0&&(e.pinchAround=i.pinchAround),i.noInertia&&(e.noInertia=i.noInertia),t.e(n,a),t.e(r,o);this._updateMapTransform(e,n,r),this._changes=[]}_updateMapTransform(e,t,n){let r=this._map,i=r._getTransformForUpdate(),a=r.terrain;if(!(Ga(e)||a&&this._terrainMovement))return void this._fireEvents(t,n,!0);r._stop(!0);let{panDelta:o,zoomDelta:s,bearingDelta:c,pitchDelta:l,rollDelta:u,around:d,pinchAround:f}=e;f!==void 0&&(d=f),d||=r.transform.centerPoint,a&&!i.isPointOnMapSurface(d)&&(d=i.centerPoint);let p={panDelta:o,zoomDelta:s,rollDelta:u,pitchDelta:l,bearingDelta:c,around:d};this._map.cameraHelper.useGlobeControls&&!i.isPointOnMapSurface(d)&&(d=i.centerPoint);let m=d.distSqr(i.centerPoint)<.01?i.center:i.screenPointToLocation(o?d.sub(o):d);this._handleMapControls({terrain:a,tr:i,deltasForHelper:p,preZoomAroundLoc:m,combinedEventsInProgress:t,panDelta:o}),r._applyUpdatedTransform(i),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,n,!0)}_handleMapControls({terrain:e,tr:t,deltasForHelper:n,preZoomAroundLoc:r,combinedEventsInProgress:i,panDelta:a}){let o=this._map.cameraHelper;if(o.handleMapControlsRollPitchBearingZoom(n,t),e)return o.useGlobeControls?(this._terrainMovement||!i.drag&&!i.zoom||(this._terrainMovement=!0,this._map._elevationFreeze=!0),void o.handleMapControlsPan(n,t,r)):this._terrainMovement||!i.drag&&!i.zoom?void(i.drag&&this._terrainMovement&&a?t.setCenter(t.screenPointToLocation(t.centerPoint.sub(a))):o.handleMapControlsPan(n,t,r)):(this._terrainMovement=!0,this._map._elevationFreeze=!0,void o.handleMapControlsPan(n,t,r));o.handleMapControlsPan(n,t,r)}_fireEvents(e,n,r){let i=Ua(this._eventsInProgress),a=Ua(e),o={};for(let t in e){let{originalEvent:n}=e[t];this._eventsInProgress[t]||(o[`${t}start`]=n),this._eventsInProgress[t]=e[t]}!i&&a&&this._fireEvent(`movestart`,a.originalEvent);for(let e in o)this._fireEvent(e,o[e]);a&&this._fireEvent(`move`,a.originalEvent);for(let t in e){let{originalEvent:n}=e[t];this._fireEvent(t,n)}let c={},l;for(let e in this._eventsInProgress){let{handlerName:t,originalEvent:r}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=n[t]||r,c[`${e}end`]=l)}for(let e in c)this._fireEvent(e,c[e]);let u=Ua(this._eventsInProgress),d=(i||a)&&!u;if(d&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;let e=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&e.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(e)}if(r&&d){this._updatingCamera=!0;let e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),n=e=>e!==0&&-this._bearingSnap<e&&e<this._bearingSnap;!e||!e.essential&&s.prefersReducedMotion?(this._map.fire(new t.n(`moveend`,{originalEvent:l})),n(this._map.getBearing())&&this._map.resetNorth()):(n(e.bearing||this._map.getBearing())&&(e.bearing=0),e.freezeElevation=!0,this._map.easeTo(e,{originalEvent:l})),this._updatingCamera=!1}}_fireEvent(e,n){this._map.fire(new t.n(e,n?{originalEvent:n}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((e=>{delete this._frameId,this.handleEvent(new Wa(`renderFrame`,{timeStamp:e})),this._applyChanges()}))}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class Ka extends t.E{constructor(e,t,n){super(),this._renderFrameCallback=()=>{let e=Math.min((l()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=n.bearingSnap,this._zoomSnap=n.zoomSnap,this.cameraHelper=t,this.on(`moveend`,(()=>{delete this._requestedCameraState}))}migrateProjection(e,t){e.apply(this.transform,!0),this.transform=e,this.cameraHelper=t}getCenter(){return new t.W(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,t){return this.jumpTo({elevation:e},t),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,n,r){return e=t.P.convert(e).mult(-1),this.panTo(this.transform.center,t.e({offset:e},n),r)}panTo(e,n,r){return this.easeTo(t.e({center:e},n),r)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,n,r){return this.easeTo(t.e({zoom:e},n),r)}zoomIn(e,n){return this.zoomTo(t.cw(this.getZoom()+1,this._zoomSnap),e,n),this}zoomOut(e,n){return this.zoomTo(t.cw(this.getZoom()-1,this._zoomSnap),e,n),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,n){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new t.n(`movestart`,n)).fire(new t.n(`move`,n)).fire(new t.n(`moveend`,n))),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,n,r){return this.easeTo(t.e({bearing:e},n),r)}resetNorth(e,n){return this.rotateTo(0,t.e({duration:1e3},e),n),this}resetNorthPitch(e,n){return this.easeTo(t.e({bearing:0,pitch:0,roll:0,duration:1e3},e),n),this}snapToNorth(e,t){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(e,t):this}getPitch(){return this.transform.pitch}setPitch(e,t){return this.jumpTo({pitch:e},t),this}getRoll(){return this.transform.roll}setRoll(e,t){return this.jumpTo({roll:e},t),this}cameraForBounds(e,t){e=ue.convert(e).adjustAntiMeridian();let n=t?.bearing||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),n,t)}_cameraForBoxAndBearing(e,n,r,i){let a={top:0,bottom:0,right:0,left:0};if(typeof(i=t.e({padding:a,offset:[0,0],maxZoom:this.transform.maxZoom},i)).padding==`number`){let e=i.padding;i.padding={top:e,bottom:e,right:e,left:e}}let o=t.e(a,i.padding);i.padding=o;let s=this.transform,c=new ue(e,n),l=this.cameraHelper.cameraForBoxAndBearing(i,o,c,r,s);return l&&this._zoomSnap&&(l.zoom=t.cw(l.zoom,this._zoomSnap,-1)),l}fitBounds(e,t,n){return this._fitInternal(this.cameraForBounds(e,t),t,n)}fitScreenCoordinates(e,n,r,i,a){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(t.P.convert(e)),this.transform.screenPointToLocation(t.P.convert(n)),r,i),i,a)}_fitInternal(e,n,r){return e?(delete(n=t.e(e,n)).padding,n.linear?this.easeTo(n,r):this.flyTo(n,r)):this}jumpTo(e,n){this.stop(),`zoom`in e&&this._zoomSnap&&(e.zoom=t.cw(e.zoom,this._zoomSnap));let r=this._getTransformForUpdate(),i=!1,a=!1,o=!1,s=r.zoom;this.terrain&&r.setElevation(this.terrain.getElevationForLngLatZoom(e.center?t.W.convert(e.center):r.center,e.zoom||r.tileZoom)),this.cameraHelper.handleJumpToCenterZoom(r,e);let c=r.zoom!==s;return`elevation`in e&&r.elevation!==+e.elevation&&r.setElevation(+e.elevation),`bearing`in e&&r.bearing!==+e.bearing&&(i=!0,r.setBearing(+e.bearing)),`pitch`in e&&r.pitch!==+e.pitch&&(a=!0,r.setPitch(+e.pitch)),`roll`in e&&r.roll!==+e.roll&&(o=!0,r.setRoll(+e.roll)),e.padding==null||r.isPaddingEqual(e.padding)||r.setPadding(e.padding),this._applyUpdatedTransform(r),this.fire(new t.n(`movestart`,n)).fire(new t.n(`move`,n)),c&&this.fire(new t.n(`zoomstart`,n)).fire(new t.n(`zoom`,n)).fire(new t.n(`zoomend`,n)),i&&this.fire(new t.n(`rotatestart`,n)).fire(new t.n(`rotate`,n)).fire(new t.n(`rotateend`,n)),a&&this.fire(new t.n(`pitchstart`,n)).fire(new t.n(`pitch`,n)).fire(new t.n(`pitchend`,n)),o&&this.fire(new t.n(`rollstart`,n)).fire(new t.n(`roll`,n)).fire(new t.n(`rollend`,n)),this.fire(new t.n(`moveend`,n))}calculateCameraOptionsFromTo(e,n,r,i=0){let a=t.a7.fromLngLat(e,n),o=t.a7.fromLngLat(r,i),s=o.x-a.x,c=o.y-a.y,l=o.z-a.z,u=Math.hypot(s,c,l);if(u===0)throw Error(`Can't calculate camera options with same From and To`);let d=Math.hypot(s,c),f=t.ar(this.transform.cameraToCenterDistance/u/this.transform.tileSize),p=180*Math.atan2(s,-c)/Math.PI,m=180*Math.acos(d/u)/Math.PI;return m=l<0?90-m:90+m,{center:o.toLngLat(),elevation:i,zoom:f,pitch:m,bearing:p}}calculateCameraOptionsFromCameraLngLatAltRotation(e,t,n,r,i){let a=this.transform.calculateCenterFromCameraLngLatAlt(e,t,n,r);return{center:a.center,elevation:a.elevation,zoom:a.zoom,bearing:n,pitch:r,roll:i}}easeTo(e,n){this._stop(!1,e.easeId),`zoom`in(e=t.e({offset:[0,0],duration:500,easing:t.cy},e))&&this._zoomSnap&&(e.zoom=t.cw(e.zoom,this._zoomSnap)),(!1===e.animate||!e.essential&&s.prefersReducedMotion)&&(e.duration=0);let r=this._getTransformForUpdate(),i=this.getBearing(),a=r.pitch,o=r.roll,c=`bearing`in e?this._normalizeBearing(e.bearing,i):i,l=`pitch`in e?+e.pitch:a,u=`roll`in e?this._normalizeBearing(e.roll,o):o,d=`padding`in e?e.padding:r.padding,f=t.P.convert(e.offset),p,m;e.around&&(p=t.W.convert(e.around),m=r.locationToScreenPoint(p));let h={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},g=this.cameraHelper.handleEaseTo(r,{bearing:c,pitch:l,roll:u,padding:d,around:p,aroundPoint:m,offsetAsPoint:f,offset:e.offset,zoom:e.zoom,center:e.center});return this._rotating||=i!==c,this._pitching||=l!==a,this._rolling||=u!==o,this._padding=!r.isPaddingEqual(d),this._zooming||=g.isZooming,this._easeId=e.easeId,this._prepareEase(n,e.noMoveStart,h),this.terrain&&this._prepareElevation(g.elevationCenter),this._ease((t=>{g.easeFunc(t),this.terrain&&!e.freezeElevation&&this._updateElevation(t),this._applyUpdatedTransform(r),this._fireMoveEvents(n)}),(t=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(n,t)}),e),this}_prepareEase(e,n,r={}){this._moving=!0,n||r.moving||this.fire(new t.n(`movestart`,e)),this._zooming&&!r.zooming&&this.fire(new t.n(`zoomstart`,e)),this._rotating&&!r.rotating&&this.fire(new t.n(`rotatestart`,e)),this._pitching&&!r.pitching&&this.fire(new t.n(`pitchstart`,e)),this._rolling&&!r.rolling&&this.fire(new t.n(`rollstart`,e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(e){this._elevationStart!==void 0&&this._elevationCenter!==void 0||this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));let n=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&n!==this._elevationTarget){let t=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(t-(n-(t*e+this._elevationStart))/(1-e)),this._elevationTarget=n}this.transform.setElevation(t.H.number(this._elevationStart,this._elevationTarget,e))}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||=this.transform.clone(),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return{};let t=e.getCameraLngLat(),n=e.getCameraAltitude(),r=this.terrain?this.terrain.getElevationForLngLatZoom(t,e.zoom):0;if(n<r){let n=this.calculateCameraOptionsFromTo(t,r,e.center,e.elevation);return{pitch:n.pitch,zoom:n.zoom}}return{}}_applyUpdatedTransform(e){let t=[];if(t.push((e=>this._elevateCameraIfInsideTerrain(e))),this.transformCameraUpdate&&t.push((e=>this.transformCameraUpdate(e))),!t.length)return;let n=e.clone();for(let e of t){let t=n.clone(),{center:r,zoom:i,roll:a,pitch:o,bearing:s,elevation:c}=e(t);r&&t.setCenter(r),c!==void 0&&t.setElevation(c),i!==void 0&&t.setZoom(i),a!==void 0&&t.setRoll(a),o!==void 0&&t.setPitch(o),s!==void 0&&t.setBearing(s),n.apply(t,!1)}this.transform.apply(n,!1)}_fireMoveEvents(e){this.fire(new t.n(`move`,e)),this._zooming&&this.fire(new t.n(`zoom`,e)),this._rotating&&this.fire(new t.n(`rotate`,e)),this._pitching&&this.fire(new t.n(`pitch`,e)),this._rolling&&this.fire(new t.n(`roll`,e))}_afterEase(e,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId;let r=this._zooming,i=this._rotating,a=this._pitching,o=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,r&&this.fire(new t.n(`zoomend`,e)),i&&this.fire(new t.n(`rotateend`,e)),a&&this.fire(new t.n(`pitchend`,e)),o&&this.fire(new t.n(`rollend`,e)),this.fire(new t.n(`moveend`,e))}flyTo(e,n){if(!e.essential&&s.prefersReducedMotion){let r=t.V(e,[`center`,`zoom`,`bearing`,`pitch`,`roll`,`elevation`,`padding`]);return this.jumpTo(r,n)}this.stop(),`zoom`in(e=t.e({offset:[0,0],speed:1.2,curve:1.42,easing:t.cy},e))&&this._zoomSnap&&(e.zoom=t.cw(e.zoom,this._zoomSnap));let r=this._getTransformForUpdate(),i=r.bearing,a=r.pitch,o=r.roll,c=r.padding,l=`bearing`in e?this._normalizeBearing(e.bearing,i):i,u=`pitch`in e?+e.pitch:a,d=`roll`in e?this._normalizeBearing(e.roll,o):o,f=`padding`in e?e.padding:r.padding,p=t.P.convert(e.offset),m=r.centerPoint.add(p),h=r.screenPointToLocation(m),g=this.cameraHelper.handleFlyTo(r,{bearing:l,pitch:u,roll:d,padding:f,locationAtOffset:h,offsetAsPoint:p,center:e.center,minZoom:e.minZoom,zoom:e.zoom}),_=e.curve,v=Math.max(r.width,r.height),y=v/g.scaleOfZoom,b=g.pixelPathLength;typeof g.scaleOfMinZoom==`number`&&(_=Math.sqrt(v/g.scaleOfMinZoom/b*2));let x=_*_;function S(e){let t=(y*y-v*v+(e?-1:1)*x*x*b*b)/(2*(e?y:v)*x*b);return Math.log(Math.sqrt(t*t+1)-t)}function C(e){return(Math.exp(e)-Math.exp(-e))/2}function w(e){return(Math.exp(e)+Math.exp(-e))/2}let T=S(!1),E=function(e){return w(T)/w(T+_*e)},D=function(e){return v*((w(T)*(C(t=T+_*e)/w(t))-C(T))/x)/b;var t},O=(S(!0)-T)/_;if(Math.abs(b)<2e-6||!isFinite(O)){if(Math.abs(v-y)<1e-6)return this.easeTo(e,n);let t=y<v?-1:1;O=Math.abs(Math.log(y/v))/_,D=()=>0,E=e=>Math.exp(t*_*e)}return e.duration=`duration`in e?+e.duration:1e3*O/(`screenSpeed`in e?+e.screenSpeed/_:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=i!==l,this._pitching=u!==a,this._rolling=d!==o,this._padding=!r.isPaddingEqual(f),this._prepareEase(n,!1),this.terrain&&this._prepareElevation(g.targetCenter),this._ease((s=>{let h=s*O,_=1/E(h),v=D(h);this._rotating&&r.setBearing(t.H.number(i,l,s)),this._pitching&&r.setPitch(t.H.number(a,u,s)),this._rolling&&r.setRoll(t.H.number(o,d,s)),this._padding&&(r.interpolatePadding(c,f,s),m=r.centerPoint.add(p)),g.easeFunc(s,_,v,m),this.terrain&&!e.freezeElevation&&this._updateElevation(s),this._applyUpdatedTransform(r),this._fireMoveEvents(n)}),(()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(n)}),e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,t){var n;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){let e=this._onEaseEnd;delete this._onEaseEnd,e.call(this,t)}return e||(n=this.handlers)==null||n.stop(!1),this}_ease(e,t,n){!1===n.animate||n.duration===0?(e(1),t()):(this._easeStart=l(),this._easeOptions=n,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,n){e=t.X(e,-180,180);let r=Math.abs(e-n);return Math.abs(e-360-n)<r&&(e-=360),Math.abs(e+360-n)<r&&(e+=360),e}queryTerrainElevation(e){return this.terrain?this.terrain.getElevationForLngLat(t.W.convert(e),this.transform):null}}let qa={compact:!0,customAttribution:`<a href="https://maplibre.org/" target="_blank">MapLibre</a>`};class Ja{constructor(e=qa){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||e.sourceDataType!==`metadata`&&e.sourceDataType!==`visibility`&&e.dataType!==`style`&&e.type!==`terrain`||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute(`open`,``):this._container.classList.contains(`maplibregl-compact`)||this._container.classList.contains(`maplibregl-attrib-empty`)||(this._container.setAttribute(`open`,``),this._container.classList.add(`maplibregl-compact`,`maplibregl-compact-show`)):(this._container.setAttribute(`open`,``),this._container.classList.contains(`maplibregl-compact`)&&this._container.classList.remove(`maplibregl-compact`,`maplibregl-compact-show`))},this._updateCompactMinimize=()=>{this._container.classList.contains(`maplibregl-compact`)&&this._container.classList.contains(`maplibregl-compact-show`)&&this._container.classList.remove(`maplibregl-compact-show`)},this.options=e}getDefaultPosition(){return`bottom-right`}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=d.create(`details`,`maplibregl-ctrl maplibregl-ctrl-attrib`),this._compactButton=d.create(`summary`,`maplibregl-ctrl-attrib-button`,this._container),this._compactButton.addEventListener(`click`,this._toggleAttribution),this._setElementTitle(this._compactButton,`ToggleAttribution`),this._innerContainer=d.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 n=this._map._getUIString(`AttributionControl.${t}`);e.title=n,e.setAttribute(`aria-label`,n)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map((e=>typeof e==`string`?e:``))):typeof this.options.customAttribution==`string`&&e.push(this.options.customAttribution)),this._map.style.stylesheet){let e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}let t=this._map.style.tileManagers;for(let n in t){let r=t[n];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,n)=>{for(let r=n+1;r<e.length;r++)if(e[r].includes(t))return!1;return!0}));let n=e.join(` | `);n!==this._attribHTML&&(this._attribHTML=n,e.length?(this._innerContainer.innerHTML=d.sanitize(n),this._container.classList.remove(`maplibregl-attrib-empty`)):this._container.classList.add(`maplibregl-attrib-empty`),this._updateCompact(),this._editLink=null)}}class Ya{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=d.create(`div`,`maplibregl-ctrl`);let t=d.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}}class Xa{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){let t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){let t=this._currentlyRunning,n=t?this._queue.concat(t):this._queue;for(let t of n)if(t.id===e)return void(t.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw Error(`Attempting to run(), but is already running.`);let t=this._currentlyRunning=this._queue;this._queue=[];for(let n of t)if(!n.cancelled&&(n.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Za=t.aS([{name:`a_pos3d`,type:`Int16`,components:3}]);class Qa extends t.E{constructor(e){super(),this._lastTilesetChange=l(),this.tileManager=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null}getSource(){return this.tileManager._source}update(e,n){this.tileManager.update(e,n),this._renderableTilesKeys=[];let r={};for(let i of We(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n,calculateTileZoom:this.tileManager._source.calculateTileZoom}))r[i.key]=!0,this._renderableTilesKeys.push(i.key),this._tiles[i.key]||(i.terrainRttPosMatrix32f=new Float64Array(16),t.c7(i.terrainRttPosMatrix32f,0,t.a6,t.a6,0,0,1),this._tiles[i.key]=new Ne(i,this.tileSize),this._lastTilesetChange=l());for(let e in this._tiles)r[e]||delete this._tiles[e]}freeRtt(e){for(let t in this._tiles){let n=this._tiles[t];(!e||n.tileID.equals(e)||n.tileID.isChildOf(e)||e.isChildOf(n.tileID))&&(n.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map((e=>this.getTileByID(e)))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,t){return t?this._getTerrainCoordsForTileRanges(e,t):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){let n={};for(let r of this._renderableTilesKeys){let i=this._tiles[r].tileID,a=e.clone(),o=t.bj();if(i.canonical.equals(e.canonical))t.c7(o,0,t.a6,t.a6,0,0,1);else if(i.canonical.isChildOf(e.canonical)){let n=i.canonical.z-e.canonical.z,r=i.canonical.x-(i.canonical.x>>n<<n),a=i.canonical.y-(i.canonical.y>>n<<n),s=t.a6>>n;t.c7(o,0,s,s,0,0,1),t.Q(o,o,[-r*s,-a*s,0])}else{if(!e.canonical.isChildOf(i.canonical))continue;{let n=e.canonical.z-i.canonical.z,r=e.canonical.x-(e.canonical.x>>n<<n),a=e.canonical.y-(e.canonical.y>>n<<n),s=t.a6>>n;t.c7(o,0,t.a6,t.a6,0,0,1),t.Q(o,o,[r*s,a*s,0]),t.S(o,o,[1/2**n,1/2**n,0])}}a.terrainRttPosMatrix32f=new Float32Array(o),n[r]=a}return n}_getTerrainCoordsForTileRanges(e,n){let r={};for(let i of this._renderableTilesKeys){let a=this._tiles[i].tileID;if(!this._isWithinTileRanges(a,n))continue;let o=e.clone(),s=t.bj();if(a.canonical.z===e.canonical.z){let n=e.canonical.x-a.canonical.x+e.wrap*(1<<e.canonical.z),r=e.canonical.y-a.canonical.y;t.c7(s,0,t.a6,t.a6,0,0,1),t.Q(s,s,[n*t.a6,r*t.a6,0])}else if(a.canonical.z>e.canonical.z){let n=a.canonical.z-e.canonical.z,r=a.canonical.x-(a.canonical.x>>n<<n)+e.wrap*(1<<a.canonical.z),i=a.canonical.y-(a.canonical.y>>n<<n),o=e.canonical.x-(a.canonical.x>>n),c=e.canonical.y-(a.canonical.y>>n),l=t.a6>>n;t.c7(s,0,l,l,0,0,1),t.Q(s,s,[-r*l+o*t.a6,-i*l+c*t.a6,0])}else{let n=e.canonical.z-a.canonical.z,r=e.canonical.x-(e.canonical.x>>n<<n)+e.wrap*(1<<e.canonical.z),i=e.canonical.y-(e.canonical.y>>n<<n),o=(e.canonical.x>>n)-a.canonical.x,c=(e.canonical.y>>n)-a.canonical.y,l=t.a6<<n;t.c7(s,0,l,l,0,0,1),t.Q(s,s,[r*t.a6+o*l,i*t.a6+c*l,0])}o.terrainRttPosMatrix32f=new Float32Array(s),r[i]=o}return r}getSourceTile(e,t){var n,r;let i=this.tileManager._source,a=e.overscaledZ-this.deltaZoom;if(a>i.maxzoom&&(a=i.maxzoom),a<i.minzoom)return;(n=this._sourceTileCache)[r=e.key]||(n[r]=e.scaledTo(a).key);let o=this.findTileInCaches(this._sourceTileCache[e.key]);if(!o?.dem&&t)for(;a>=i.minzoom&&!o?.dem;)o=this.findTileInCaches(e.scaledTo(a--).key);return o}findTileInCaches(e){let t=this.tileManager.getTileByID(e);return t||(t=this.tileManager._outOfViewCache.getByKey(e),t)}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,t){let n=t[e.canonical.z];return!!n&&(e.wrap>n.minWrap||e.wrap<n.maxWrap||e.canonical.x>=n.minTileXWrapped&&e.canonical.x<=n.maxTileXWrapped&&e.canonical.y>=n.minTileY&&e.canonical.y<=n.maxTileY)}}class $a{constructor(e,t,n){this._meshCache={},this.painter=e,this.tileManager=new Qa(t),this.options=n,this.exaggeration=typeof n.exaggeration==`number`?n.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}destroy(){this._fbo&&=(this._fbo.destroy(),null),this._fboCoordsTexture&&=(this._fboCoordsTexture.destroy(),null),this._fboDepthTexture&&=(this._fboDepthTexture.destroy(),null),this._emptyDemTexture&&=(this._emptyDemTexture.destroy(),null),this._emptyDepthTexture&&=(this._emptyDepthTexture.destroy(),null),this._coordsTexture&&=(this._coordsTexture.destroy(),null);for(let e in this._meshCache)this._meshCache[e].destroy();this._meshCache={},this.tileManager.destruct()}getDEMElevation(e,n,r,i=t.a6){let a=e.normalizeCoordinates(n,r,i);if(!a)return 0;let o=this.getTerrainData(a.tileID),s=o.tile?.dem;if(!s)return 0;let c=t.cC([],[a.x/i*t.a6,a.y/i*t.a6],o.u_terrain_matrix),l=[c[0]*s.dim,c[1]*s.dim],u=Math.floor(l[0]),d=Math.floor(l[1]),f=l[0]-u,p=l[1]-d;return s.get(u,d)*(1-f)*(1-p)+s.get(u+1,d)*f*(1-p)+s.get(u,d+1)*(1-f)*p+s.get(u+1,d+1)*f*p}getElevationForLngLatZoom(e,n){if(!t.cD(n,e.wrap()))return 0;let{tileID:r,mercatorX:i,mercatorY:a}=this._getOverscaledTileIDFromLngLatZoom(e,n);return this.getElevation(r,i%t.a6,a%t.a6,t.a6)}getElevationForLngLat(e,t){let n=We(t,{maxzoom:this.tileManager.maxzoom,minzoom:this.tileManager.minzoom,tileSize:512,terrain:this}),r=0;for(let e of n)e.canonical.z>r&&(r=Math.min(e.canonical.z,this.tileManager.maxzoom));return this.getElevationForLngLatZoom(e,r)}getElevation(e,n,r,i=t.a6){return this.getDEMElevation(e,n,r,i)*this.exaggeration}getTerrainData(e){if(!this._emptyDemTexture){let e=this.painter.context,n=new t.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new t.T(e,n,e.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new t.T(e,new t.R({width:1,height:1}),e.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=t.ap([])}let n=this.tileManager.getSourceTile(e,!0);if(n?.dem&&(!n.demTexture||n.needsTerrainPrepare)){let e=this.painter.context;n.demTexture=this.painter.getTileTexture(n.dem.stride),n.demTexture?n.demTexture.update(n.dem.getPixels(),{premultiply:!1}):n.demTexture=new t.T(e,n.dem.getPixels(),e.gl.RGBA,{premultiply:!1}),n.demTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),n.needsTerrainPrepare=!1}let r=n&&n.toString()+n.tileID.key+e.key;if(r&&!this._demMatrixCache[r]){let i=this.tileManager.getSource().maxzoom,a=e.canonical.z-n.tileID.canonical.z;e.overscaledZ>e.canonical.z&&(e.canonical.z>=i?a=e.canonical.z-i:t.w(`cannot calculate elevation if elevation maxzoom > source.maxzoom`));let o=e.canonical.x-(e.canonical.x>>a<<a),s=e.canonical.y-(e.canonical.y>>a<<a),c=t.cE(new Float64Array(16),[1/(t.a6<<a),1/(t.a6<<a),0]);t.Q(c,c,[o*t.a6,s*t.a6,0]),this._demMatrixCache[r]={matrix:c,coord:e}}return{u_depth:2,u_terrain:3,u_terrain_dim:n?.dem?.dim||1,u_terrain_matrix:r?this._demMatrixCache[r].matrix:this._emptyDemMatrix,u_terrain_unpack:(n?.dem)?.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(n?.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:n}}getFramebuffer(e){let n=this.painter,r=n.width/devicePixelRatio,i=n.height/devicePixelRatio;return!this._fbo||this._fbo.width===r&&this._fbo.height===i||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new t.T(n.context,{width:r,height:i,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new t.T(n.context,{width:r,height:i,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=n.context.createFramebuffer(r,i,!0,!1),this._fbo.depthAttachment.set(n.context.createRenderbuffer(n.context.gl.DEPTH_COMPONENT16,r,i))),this._fbo.colorAttachment.set(e===`coords`?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){let e=this.painter.context;if(this._coordsTexture)return this._coordsTexture;let n=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let e=0,t=0;e<this._coordsTextureSize;e++)for(let r=0;r<this._coordsTextureSize;r++,t+=4)n[t+0]=255&r,n[t+1]=255&e,n[t+2]=r>>8<<4|e>>8,n[t+3]=0;let r=new t.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(n.buffer)),i=new t.T(e,r,e.gl.RGBA,{premultiply:!1});return i.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=i,i}pointCoordinate(e){this.painter.maybeDrawDepth(!0),this.painter.maybeDrawCoords();let n=new Uint8Array(4),r=this.painter.context,i=r.gl,a=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),o=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),s=Math.round(this.painter.height/devicePixelRatio);r.bindFramebuffer.set(this.getFramebuffer(`coords`).framebuffer),i.readPixels(a,s-o-1,1,1,i.RGBA,i.UNSIGNED_BYTE,n),r.bindFramebuffer.set(null);let c=n[0]+(n[2]>>4<<8),l=n[1]+((15&n[2])<<8),u=this.coordsIndex[255-n[3]],d=u&&this.tileManager.getTileByID(u);if(!d)return null;let f=this._coordsTextureSize,p=(1<<d.tileID.canonical.z)*f;return new t.a7((d.tileID.canonical.x*f+c)/p+d.tileID.wrap,(d.tileID.canonical.y*f+l)/p,this.getElevation(d.tileID,c,l,f))}depthAtPoint(e){let t=new Uint8Array(4),n=this.painter.context,r=n.gl;return n.bindFramebuffer.set(this.getFramebuffer(`depth`).framebuffer),r.readPixels(e.x,this.painter.height/devicePixelRatio-e.y-1,1,1,r.RGBA,r.UNSIGNED_BYTE,t),n.bindFramebuffer.set(null),(t[0]/16777216+t[1]/65536+t[2]/256+t[3])/256}getTerrainMesh(e){let n=this.painter.style.projection?.transitionState>0,r=n&&e.canonical.y===0,i=n&&e.canonical.y===(1<<e.canonical.z)-1,a=`m_${r?`n`:``}_${i?`s`:``}`;if(this._meshCache[a])return this._meshCache[a];let o=this.painter.context,s=new t.cF,c=new t.aW,l=this.meshSize,u=t.a6/l,d=l*l;for(let e=0;e<=l;e++)for(let t=0;t<=l;t++)s.emplaceBack(t*u,e*u,0);for(let e=0;e<d;e+=l+1)for(let t=0;t<l;t++)c.emplaceBack(t+e,l+t+e+1,l+t+e+2),c.emplaceBack(t+e,l+t+e+2,t+e+1);let f=s.length,p=f+(l+1),m=(l+1)*l,h=r?t.bq:0,g=+!r,_=i?t.br:t.a6,v=+!i;for(let e=0;e<=l;e++)s.emplaceBack(e*u,h,g);for(let e=0;e<=l;e++)s.emplaceBack(e*u,_,v);for(let e=0;e<l;e++)c.emplaceBack(m+e,p+e,p+e+1),c.emplaceBack(m+e,p+e+1,m+e+1),c.emplaceBack(0+e,f+e+1,f+e),c.emplaceBack(0+e,0+e+1,f+e+1);let y=s.length,b=y+2*(l+1);for(let e of[0,1])for(let n=0;n<=l;n++)for(let r of[0,1])s.emplaceBack(e*t.a6,n*u,r);for(let e=0;e<2*l;e+=2)c.emplaceBack(y+e,y+e+1,y+e+3),c.emplaceBack(y+e,y+e+3,y+e+2),c.emplaceBack(b+e,b+e+3,b+e+1),c.emplaceBack(b+e,b+e+2,b+e+3);let x=new Jt(o.createVertexBuffer(s,Za.members),o.createIndexBuffer(c),t.aV.simpleSegment(0,0,s.length,c.length));return this._meshCache[a]=x,x}getMeshFrameDelta(e){return 2*Math.PI*t.bD/2**Math.max(e,0)/5}getMinTileElevationForLngLatZoom(e,n){if(!t.cD(n,e.wrap()))return 0;let{tileID:r}=this._getOverscaledTileIDFromLngLatZoom(e,n);return this.getMinMaxElevation(r).minElevation??0}getMinMaxElevation(e){let t=this.getTerrainData(e).tile,n={minElevation:null,maxElevation:null};return t!=null&&t.dem&&(n.minElevation=t.dem.min*this.exaggeration,n.maxElevation=t.dem.max*this.exaggeration),n}_getOverscaledTileIDFromLngLatZoom(e,n){let r=t.a7.fromLngLat(e.wrap()),i=(1<<n)*t.a6,a=r.x*i,o=r.y*i,s=Math.floor(a/t.a6),c=Math.floor(o/t.a6);return{tileID:new t.a3(n,0,n,s,c),mercatorX:a,mercatorY:o}}}class eo{constructor(e,t,n){this._context=e,this._size=t,this._tileSize=n,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(let e of this._objects)e.texture.destroy(),e.fbo.destroy()}_createObject(e){let n=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),r=new t.T(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return r.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),this._context.extTextureFilterAnisotropic&&this._context.gl.texParameterf(this._context.gl.TEXTURE_2D,this._context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this._context.extTextureFilterAnisotropicMax),n.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),n.colorAttachment.set(r.texture),{id:e,fbo:n,texture:r,stamp:-1,inUse:!1}}getObjectForId(e){return this._objects[e]}useObject(e){e.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter((t=>e.id!==t)),this._recentlyUsed.push(e.id)}stampObject(e){e.stamp=++this._stamp}getOrCreateFreeObject(){for(let e of this._recentlyUsed)if(!this._objects[e].inUse)return this._objects[e];if(this._objects.length>=this._size)throw Error(`No free RenderPool available, call freeAllObjects() required!`);let e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1}freeAllObjects(){for(let e of this._objects)this.freeObject(e)}isFull(){return!(this._objects.length<this._size)&&!1===this._objects.some((e=>!e.inUse))}}let to={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class no{constructor(e,t){this.painter=e,this.terrain=t,this.pool=new eo(e.context,30,t.tileManager.tileSize*t.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,t){var n;this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=e._order.filter((n=>!e._layers[n].isHidden(t))),this._coordsAscending={};for(let t in e.tileManagers){this._coordsAscending[t]={};let r=e.tileManagers[t].getVisibleCoordinates(),i=e.tileManagers[t].getSource(),a=i instanceof Se?i.terrainTileRanges:null;for(let e of r){let r=this.terrain.tileManager.getTerrainCoords(e,a);for(let e in r)(n=this._coordsAscending[t])[e]||(n[e]=[]),this._coordsAscending[t][e].push(r[e])}}this._rttFingerprints={};for(let t of e._order){let n=e._layers[t],r=n.source;if(to[n.type]&&!this._rttFingerprints[r]){this._rttFingerprints[r]={};let t=e.tileManagers[r]?.getState().revision??0;for(let e in this._coordsAscending[r])this._rttFingerprints[r][e]=`${this._coordsAscending[r][e].map((e=>e.key)).sort().join()}#${t}`}}for(let e of this._renderableTiles)for(let t in this._rttFingerprints){let n=this._rttFingerprints[t][e.tileID.key];n&&n!==e.rttFingerprint[t]&&(e.rtt=[])}}renderLayer(e,n){if(e.isHidden(this.painter.transform.zoom))return!1;let r=Object.assign(Object.assign({},n),{isRenderingToTexture:!0}),i=e.type,a=this.painter,o=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(to[i]&&(this._prevType&&to[this._prevType]||this._stacks.push([]),this._prevType=i,this._stacks[this._stacks.length-1].push(e.id),!o))return!0;if(to[this._prevType]||to[i]&&o){this._prevType=i;let e=this._stacks.length-1,n=this._stacks[e]||[];for(let i of this._renderableTiles){if(this.pool.isFull()&&(Ki(this.painter,this.terrain,this._rttTiles,r),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(i),i.rtt[e]){let t=this.pool.getObjectForId(i.rtt[e].id);if(t.stamp===i.rtt[e].stamp){this.pool.useObject(t);continue}}let o=this.pool.getOrCreateFreeObject();this.pool.useObject(o),this.pool.stampObject(o),i.rtt[e]={id:o.id,stamp:o.stamp},a.context.bindFramebuffer.set(o.fbo.framebuffer),a.context.clear({color:t.bo.transparent,stencil:0}),a.currentStencilSource=void 0;for(let e of n){let t=a.style._layers[e],n=t.source?this._coordsAscending[t.source][i.tileID.key]:[i.tileID];a.context.viewport.set([0,0,o.fbo.width,o.fbo.height]),a._renderTileClippingMasks(t,n,!0),a.renderLayer(a,a.style.tileManagers[t.source],t,n,r),t.source&&(i.rttFingerprint[t.source]=this._rttFingerprints[t.source][i.tileID.key])}}return Ki(this.painter,this.terrain,this._rttTiles,r),this._rttTiles=[],this.pool.freeAllObjects(),to[i]}return!1}}let ro={"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`},io=n,ao={hash:!1,interactive:!0,bearingSnap:7,zoomSnap:0,attributionControl:qa,maplibreLogo:!1,refreshExpiredTiles:!0,canvasContextAttributes:{antialias:!1,preserveDrawingBuffer:!1,powerPreference:`high-performance`,failIfMajorPerformanceCaveat:!1,desynchronized:!1,contextType:void 0},scrollZoom:!0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,trackResize:!0,center:[0,0],elevation:0,zoom:0,bearing:0,pitch:0,roll:0,renderWorldCopies:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:t.c.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,transformConstrain:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:`sans-serif`,pitchWithRotate:!0,rollEnabled:!1,reduceMotion:void 0,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0,experimentalZoomLevelsToOverscale:void 0,anisotropicFilterPitch:20},oo=class extends Ka{get _ownerWindow(){return this._container?.ownerDocument?.defaultView||window}constructor(e){var n;let r=Object.assign(Object.assign(Object.assign({},ao),e),{canvasContextAttributes:Object.assign(Object.assign({},ao.canvasContextAttributes),e.canvasContextAttributes)});if(r.minZoom!=null&&r.maxZoom!=null&&r.minZoom>r.maxZoom)throw Error(`maxZoom must be greater than or equal to minZoom`);if(r.minPitch!=null&&r.maxPitch!=null&&r.minPitch>r.maxPitch)throw Error(`maxPitch must be greater than or equal to minPitch`);if(r.minPitch!=null&&r.minPitch<0)throw Error(`minPitch must be greater than or equal to 0`);if(r.maxPitch!=null&&r.maxPitch>180)throw Error(`maxPitch must be less than or equal to 180`);let i=new z,a=new ln;r.minZoom!==void 0&&i.setMinZoom(r.minZoom),r.maxZoom!==void 0&&i.setMaxZoom(r.maxZoom),r.minPitch!==void 0&&i.setMinPitch(r.minPitch),r.maxPitch!==void 0&&i.setMaxPitch(r.maxPitch),r.renderWorldCopies!==void 0&&i.setRenderWorldCopies(r.renderWorldCopies),r.transformConstrain!==null&&i.setConstrainOverride(r.transformConstrain),super(i,a,{bearingSnap:r.bearingSnap,zoomSnap:r.zoomSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Xa,this._controls=[],this._mapId=t.ad(),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(e.type===`custom`&&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 t.n(`webglcontextlost`,{originalEvent:e}))}else this.fire(new t.n(`webglcontextlost`,{originalEvent:e}))},this._contextRestored=e=>{this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&this.style&&(this.style.imageManager.images=this._lostContextStyle.images),this._lostContextStyle={style:null,images:null},this._setupPainter(),this.resize(),this._update(),this._resizeInternal(),this.fire(new t.n(`webglcontextrestored`,{originalEvent:e}))},this._onMapScroll=e=>{if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=r.interactive,this._maxTileCacheSize=r.maxTileCacheSize,this._maxTileCacheZoomLevels=r.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},r.canvasContextAttributes),this._trackResize=!0===r.trackResize,this._bearingSnap=r.bearingSnap,this._zoomSnap=r.zoomSnap,this._centerClampedToGround=r.centerClampedToGround,this._refreshExpiredTiles=!0===r.refreshExpiredTiles,this._fadeDuration=r.fadeDuration,this._crossSourceCollisions=!0===r.crossSourceCollisions,this._collectResourceTiming=!0===r.collectResourceTiming,this._locale=Object.assign(Object.assign({},ro),r.locale),this._clickTolerance=r.clickTolerance,this._overridePixelRatio=r.pixelRatio,this._maxCanvasSize=r.maxCanvasSize,this._zoomLevelsToOverscale=r.experimentalZoomLevelsToOverscale,this.transformCameraUpdate=r.transformCameraUpdate,this.transformConstrain=r.transformConstrain,this.cancelPendingTileRequestsWhileZooming=!0===r.cancelPendingTileRequestsWhileZooming,this.setAnisotropicFilterPitch(r.anisotropicFilterPitch),r.reduceMotion!==void 0&&(s.prefersReducedMotion=r.reduceMotion),this._imageQueueHandle=u.addThrottleControl((()=>this.isMoving())),this._requestManager=new f(r.transformRequest),this._container=this._resolveContainer(r.container),r.maxBounds&&this.setMaxBounds(r.maxBounds),this._setupContainer(),this._setupPainter(),this.on(`move`,(()=>this._update(!1))),this.on(`moveend`,(()=>this._update(!1))),this.on(`zoom`,(()=>this._update(!0))),this.on(`terrain`,(()=>{this.painter.terrainFacilitator.depthDirty=!0,this._update(!0)})),this.once(`idle`,(()=>this._idleTriggered=!0)),typeof window<`u`&&(this._ownerWindow.addEventListener(`online`,this._onWindowOnline,!1),this._setupResizeObserver()),this.handlers=new Q(this,r),this._hash=r.hash?new Zi(typeof r.hash==`string`&&r.hash||void 0).addTo(this):void 0,(n=this._hash)!=null&&n._onHashChange()||(this.jumpTo({center:r.center,elevation:r.elevation,zoom:r.zoom,bearing:r.bearing,pitch:r.pitch,roll:r.roll}),r.bounds&&(this.resize(),this.fitBounds(r.bounds,t.e({},r.fitBoundsOptions,{duration:0}))));let o=typeof r.style==`string`||r.style?.projection?.type!==`globe`;this.resize(null,o),this._localIdeographFontFamily=r.localIdeographFontFamily,this._validateStyle=r.validateStyle,r.style&&this.setStyle(r.style,{localIdeographFontFamily:r.localIdeographFontFamily}),r.attributionControl&&this.addControl(new Ja(typeof r.attributionControl==`boolean`?void 0:r.attributionControl)),r.maplibreLogo&&this.addControl(new Ya,r.logoPosition),this.on(`style.load`,(()=>{if(o||this._resizeTransform(),this.transform.unmodified){let e=t.V(this.style.stylesheet,[`center`,`zoom`,`bearing`,`pitch`,`roll`]);this.jumpTo(e)}})),this.on(`data`,(e=>{this._update(e.dataType===`style`),this.fire(new t.n(`${e.dataType}data`,e))})),this.on(`dataloading`,(e=>{this.fire(new t.n(`${e.dataType}dataloading`,e))})),this.on(`dataabort`,(e=>{this.fire(new t.n(`sourcedataabort`,e))}))}_getMapId(){return this._mapId}setGlobalStateProperty(e,t){return this.style.setGlobalStateProperty(e,t),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(e,n){if(n===void 0&&(n=e.getDefaultPosition?e.getDefaultPosition():`top-right`),!e?.onAdd)return this.fire(new t.l(Error(`Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.`)));let r=e.onAdd(this);this._controls.push(e);let i=this._controlPositions[n];return n.includes(`bottom`)?i.insertBefore(r,i.firstChild):i.appendChild(r),this}removeControl(e){if(!e?.onRemove)return this.fire(new t.l(Error(`Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.`)));let n=this._controls.indexOf(e);return n>-1&&this._controls.splice(n,1),e.onRemove(this),this}hasControl(e){return this._controls.includes(e)}coveringTiles(e){return We(this.transform,e)}calculateCameraOptionsFromTo(e,t,n,r){return r==null&&this.terrain&&(r=this.terrain.getElevationForLngLat(n,this.transform)),super.calculateCameraOptionsFromTo(e,t,n,r)}resize(e,n=!0){if(this._lostContextStyle.style!==null)return this;this._resizeInternal(n);let r=!this._moving;return r&&(this.stop(),this.fire(new t.n(`movestart`,e)).fire(new t.n(`move`,e))),this.fire(new t.n(`resize`,e)),r&&this.fire(new t.n(`moveend`,e)),this}_resizeInternal(e=!0){let[t,n]=this._containerDimensions(),r=this._getClampedPixelRatio(t,n);if(this._resizeCanvas(t,n,r),this.painter.resize(t,n,r),this.painter.overLimit()){let e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];let r=this._getClampedPixelRatio(t,n);this._resizeCanvas(t,n,r),this.painter.resize(t,n,r)}this._resizeTransform(e)}_resizeTransform(e=!0){var t;let[n,r]=this._containerDimensions();this.transform.resize(n,r,e),(t=this._requestedCameraState)==null||t.resize(n,r,e)}_getClampedPixelRatio(e,t){let{0:n,1:r}=this._maxCanvasSize,i=this.getPixelRatio(),a=e*i,o=t*i;return Math.min(a>n?n/a:1,o>r?r/o:1)*i}getPixelRatio(){return this._overridePixelRatio??devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(e){return this.transform.setMaxBounds(ue.convert(e)),this._update()}setMinZoom(e){if((e??=-2)>=-2&&e<=this.transform.maxZoom){let n=this.transform.zoom,r=this._getTransformForUpdate();return r.setMinZoom(e),this._applyUpdatedTransform(r),this._update(),n!==this.transform.zoom&&this.fire(new t.n(`zoomstart`)).fire(new t.n(`zoom`)).fire(new t.n(`zoomend`)).fire(new t.n(`movestart`)).fire(new t.n(`move`)).fire(new t.n(`moveend`)),this}throw Error(`minZoom must be between -2 and the current maxZoom, inclusive`)}getMinZoom(){return this.transform.minZoom}setMaxZoom(e){if((e??=22)>=this.transform.minZoom){let n=this.transform.zoom,r=this._getTransformForUpdate();return r.setMaxZoom(e),this._applyUpdatedTransform(r),this._update(),n!==this.transform.zoom&&this.fire(new t.n(`zoomstart`)).fire(new t.n(`zoom`)).fire(new t.n(`zoomend`)).fire(new t.n(`movestart`)).fire(new t.n(`move`)).fire(new t.n(`moveend`)),this}throw Error(`maxZoom must be greater than the current minZoom`)}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e??=0)<0)throw Error(`minPitch must be greater than or equal to 0`);if(e>=0&&e<=this.transform.maxPitch){let n=this.transform.pitch,r=this._getTransformForUpdate();return r.setMinPitch(e),this._applyUpdatedTransform(r),this._update(),n!==this.transform.pitch&&this.fire(new t.n(`pitchstart`)).fire(new t.n(`pitch`)).fire(new t.n(`pitchend`)).fire(new t.n(`movestart`)).fire(new t.n(`move`)).fire(new t.n(`moveend`)),this}throw Error(`minPitch must be between 0 and the current maxPitch, inclusive`)}getMinPitch(){return this.transform.minPitch}setMaxPitch(e){if((e??=60)>180)throw Error(`maxPitch must be less than or equal to 180`);if(e>=this.transform.minPitch){let n=this.transform.pitch,r=this._getTransformForUpdate();return r.setMaxPitch(e),this._applyUpdatedTransform(r),this._update(),n!==this.transform.pitch&&this.fire(new t.n(`pitchstart`)).fire(new t.n(`pitch`)).fire(new t.n(`pitchend`)).fire(new t.n(`movestart`)).fire(new t.n(`move`)).fire(new t.n(`moveend`)),this}throw Error(`maxPitch must be greater than the current minPitch`)}getMaxPitch(){return this.transform.maxPitch}getAnisotropicFilterPitch(){return this._anisotropicFilterPitch}setAnisotropicFilterPitch(e){if((e??=20)>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.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.setRenderWorldCopies(e),this._update()}setTransformConstrain(e){return this.transform.setConstrainOverride(e),this._update()}project(e){return this.transform.locationToScreenPoint(t.W.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this.terrain)}isMoving(){return this._moving||this.handlers?.isMoving()}isZooming(){return this._zooming||this.handlers?.isZooming()}isRotating(){return this._rotating||this.handlers?.isRotating()}_createDelegatedListener(e,t,n){if(e===`mouseenter`||e===`mouseover`){let r=!1;return{layers:t,listener:n,delegates:{mousemove:i=>{let a=t.filter((e=>this.getLayer(e))),o=a.length===0?[]:this.queryRenderedFeatures(i.point,{layers:a});o.length?r||(r=!0,n.call(this,new sa(e,this,i.originalEvent,{features:o}))):r=!1},mouseout:()=>{r=!1}}}}if(e===`mouseleave`||e===`mouseout`){let r=!1;return{layers:t,listener:n,delegates:{mousemove:i=>{let a=t.filter((e=>this.getLayer(e)));(a.length===0?[]:this.queryRenderedFeatures(i.point,{layers:a})).length?r=!0:r&&(r=!1,n.call(this,new sa(e,this,i.originalEvent)))},mouseout:t=>{r&&(r=!1,n.call(this,new sa(e,this,t.originalEvent)))}}}}{let r=e=>{let r=t.filter((e=>this.getLayer(e))),i=r.length===0?[]:this.queryRenderedFeatures(e.point,{layers:r});i.length&&(e.features=i,n.call(this,e),delete e.features)};return{layers:t,listener:n,delegates:{[e]:r}}}}_saveDelegatedListener(e,t){var n;this._delegatedListeners||={},(n=this._delegatedListeners)[e]||(n[e]=[]),this._delegatedListeners[e].push(t)}_removeDelegatedListener(e,t,n){if(!this._delegatedListeners?.[e])return;let r=this._delegatedListeners[e];for(let e=0;e<r.length;e++){let i=r[e];if(i.listener===n&&i.layers.length===t.length&&i.layers.every((e=>t.includes(e)))){for(let e in i.delegates)this.off(e,i.delegates[e]);r.splice(e,1);return}}}on(e,t,n){if(n===void 0)return super.on(e,t);let r=typeof t==`string`?[t]:t,i=this._createDelegatedListener(e,r,n);this._saveDelegatedListener(e,i);for(let e in i.delegates)this.on(e,i.delegates[e]);return{unsubscribe:()=>{this._removeDelegatedListener(e,r,n)}}}once(e,t,n){if(n===void 0)return super.once(e,t);let r=typeof t==`string`?[t]:t,i=this._createDelegatedListener(e,r,n);for(let t in i.delegates){let a=i.delegates[t];i.delegates[t]=(...t)=>{this._removeDelegatedListener(e,r,n),a(...t)}}this._saveDelegatedListener(e,i);for(let e in i.delegates)this.once(e,i.delegates[e]);return this}off(e,t,n){return n===void 0?super.off(e,t):(this._removeDelegatedListener(e,typeof t==`string`?[t]:t,n),this)}queryRenderedFeatures(e,n){if(!this.style)return[];let r,i=e instanceof t.P||Array.isArray(e),a=i?e:[[0,0],[this.transform.width,this.transform.height]];if(n||=(i?{}:e)||{},a instanceof t.P||typeof a[0]==`number`)r=[t.P.convert(a)];else{let e=t.P.convert(a[0]),n=t.P.convert(a[1]);r=[e,new t.P(n.x,e.y),n,new t.P(e.x,n.y),e]}return this.style.queryRenderedFeatures(r,n,this.transform)}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}setStyle(e,n){return!1!==(n=t.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},n)).diff&&n.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,n),this):(this._localIdeographFontFamily=n.localIdeographFontFamily,this._updateStyle(e,n))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){let t=this._locale[e];if(t==null)throw Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){var n,r;if((n=this._diffStyleRequest)==null||n.abort(),this._diffStyleRequest=null,t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once(`style.load`,(()=>this._updateStyle(e,t)));let i=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new Wn(this,t||{}),this.style.setEventedParent(this,{style:this.style}),typeof e==`string`?this.style.loadURL(e,t,i):this.style.loadJSON(e,t,i),this):(this._frameRequest&&=(this._frameRequest.abort(),null),(r=this.style?.projection)==null||r.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Wn(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(e,n){return t._(this,void 0,void 0,(function*(){var r;if((r=this._diffStyleRequest)==null||r.abort(),typeof e==`string`){let r=e;this._diffStyleRequest=new AbortController;let i=this._diffStyleRequest;try{let e=yield this._requestManager.transformRequest(r,`Style`);if(i.signal.aborted)return void(this._diffStyleRequest=null);let a=yield t.k(e,i);this._diffStyleRequest=null,this._updateDiff(a.data,n)}catch(e){this._diffStyleRequest=null,t.$(e)||this.fire(new t.l(t.d(e)))}}else typeof e==`object`&&(this._diffStyleRequest=null,this._updateDiff(e,n))}))}_updateDiff(e,n){try{this.style.setState(e,n)&&this._update(!0)}catch(r){t.w(`Unable to perform style diff: ${t.d(r).message}. Rebuilding the style from scratch.`),this._updateStyle(e,n)}}getStyle(){if(this.style)return this.style.serialize()}_getStyleAndImages(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){if(this.style)return this.style.loaded();t.w(`There is no style added to the map.`)}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){let n=this.style?.tileManagers[e];if(n!==void 0)return n.loaded();this.fire(new t.l(Error(`There is no tile manager with ID '${e}'`)))}setTerrain(e){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off(`data`,this._terrainDataCallback),e){let n=this.style.tileManagers[e.source];if(!n)throw Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);this.terrain===null&&n.reload();for(let n in this.style._layers){let r=this.style._layers[n];r.type===`hillshade`&&r.source===e.source&&t.w(`You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.`),r.type===`color-relief`&&r.source===e.source&&t.w(`You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.`)}this.terrain=new $a(this.painter,n,e),this.painter.renderToTexture=new no(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=t=>{t.dataType===`style`?this.terrain.tileManager.freeRtt():t.dataType===`source`&&t.tile&&(t.sourceId!==e.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),t.source?.type===`image`?this.terrain.tileManager.freeRtt():this.terrain.tileManager.freeRtt(t.tile.tileID))},this.style.on(`data`,this._terrainDataCallback)}else this.terrain&&this.terrain.destroy(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new t.n(`terrain`,{terrain:e})),this}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,n){if(n){let r=this.getSource(n);if(!r)throw Error(`There is no source with ID "${n}", cannot set LOD parameters`);r.calculateTileZoom=Ue(Math.max(1,e),Math.max(1,t))}else for(let n in this.style.tileManagers)this.style.tileManagers[n].getSource().calculateTileZoom=Ue(Math.max(1,e),Math.max(1,t));return this._update(!0),this}refreshTiles(e,n){let r=this.style.tileManagers[e];if(!r)throw Error(`There is no tile manager with ID "${e}", cannot refresh tile`);n===void 0?r.reload(!0):r.refreshTiles(n.map((e=>new t.aa(e.z,e.x,e.y))))}addImage(e,n,r={}){let{pixelRatio:i=1,sdf:a=!1,stretchX:o,stretchY:c,content:l,textFitWidth:u,textFitHeight:d}=r;if(this._lazyInitEmptyStyle(),!(n instanceof HTMLImageElement||t.b(n))){if(n.width===void 0||n.height===void 0)return this.fire(new t.l(Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{let{width:r,height:s,data:f}=n,p=n;return this.style.addImage(e,{data:new t.R({width:r,height:s},new Uint8Array(f)),pixelRatio:i,stretchX:o,stretchY:c,content:l,textFitWidth:u,textFitHeight:d,sdf:a,version:0,userImage:p}),p.onAdd&&p.onAdd(this,e),this}}{let{width:r,height:f,data:p}=s.getImageData(n);this.style.addImage(e,{data:new t.R({width:r,height:f},p),pixelRatio:i,stretchX:o,stretchY:c,content:l,textFitWidth:u,textFitHeight:d,sdf:a,version:0})}}updateImage(e,n){let r=this.style.getImage(e);if(!r)return this.fire(new t.l(Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let{width:i,height:a,data:o}=n instanceof HTMLImageElement||t.b(n)?s.getImageData(n):n;if(i===void 0||a===void 0)return this.fire(new t.l(Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(i!==r.data.width||a!==r.data.height)return this.fire(new t.l(Error(`The width and height of the updated image must be that same as the previous version of the image`)));let c=!(n instanceof HTMLImageElement||t.b(n));return r.data.replace(o,c),this.style.updateImage(e,r),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new t.l(Error(`Missing required image id`))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(e){return t._(this,void 0,void 0,(function*(){return u.getImage(yield this._requestManager.transformRequest(e,`Image`),new AbortController)}))}listImages(){return this.style.listImages()}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(e,t,n){return this.style.setLayerZoomRange(e,t,n),this._update(!0)}setFilter(e,t,n={}){return this.style.setFilter(e,t,n),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,n,r={}){return this.style.setPaintProperty(e,t,n,r),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,n,r={}){return this.style.setLayoutProperty(e,t,n,r),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setGlyphs(e,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(e,t,n={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,t,n,(e=>{e||this._update(!0)})),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,t,(e=>{e||this._update(!0)})),this}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]}_setupResizeObserver(){let e=!1,t=Xi((e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw())}),50),n=this._ownerWindow.ResizeObserver??ResizeObserver;this._resizeObserver=new n((n=>{e?t(n):e=!0})),this._resizeObserver.observe(this._container)}_resolveContainer(e){if(typeof e==`string`){let t=document.getElementById(e);if(!t)throw Error(`Container '${e}' not found.`);return t}if(e instanceof HTMLElement||e&&typeof e==`object`&&e.nodeType===1)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=d.create(`div`,`maplibregl-canvas-container`,e);this._interactive&&t.classList.add(`maplibregl-interactive`),this._canvas=d.create(`canvas`,`maplibregl-canvas`,t),this._canvas.addEventListener(`webglcontextlost`,this._contextLost,!1),this._canvas.addEventListener(`webglcontextrestored`,this._contextRestored,!1),this._canvas.setAttribute(`tabindex`,this._interactive?`0`:`-1`),this._canvas.setAttribute(`aria-label`,this._getUIString(`Map.Title`)),this._canvas.setAttribute(`role`,`region`);let n=this._containerDimensions(),r=this._getClampedPixelRatio(n[0],n[1]);this._resizeCanvas(n[0],n[1],r);let i=this._controlContainer=d.create(`div`,`maplibregl-control-container`,e),a=this._controlPositions={};for(let e of[`top-left`,`top-right`,`bottom-left`,`bottom-right`])a[e]=d.create(`div`,`maplibregl-ctrl-${e} `,i);this._container.addEventListener(`scroll`,this._onMapScroll,!1)}_resizeCanvas(e,t,n){this._canvas.width=Math.floor(n*e),this._canvas.height=Math.floor(n*t),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`}_setupPainter(){let e=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0}),t=null;this._canvas.addEventListener(`webglcontextcreationerror`,(n=>{t={requestedAttributes:e},n&&(t.statusMessage=n.statusMessage,t.type=n.type)}),{once:!0});let n=null;if(n=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,e):this._canvas.getContext(`webgl2`,e)||this._canvas.getContext(`webgl`,e),!n){let e=`Failed to initialize WebGL`;throw t?(t.message=e,Error(JSON.stringify(t))):Error(e)}this.painter=new Yi(n,this.transform)}migrateProjection(e,n){super.migrateProjection(e,n),this.painter.transform=e,this.fire(new t.n(`projectiontransition`,{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){var n;let r=this._idleTriggered?this._fadeDuration:0,i=this.style.projection?.transitionState>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let a=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;let e=this.transform.zoom,n=l();this.style.zoomHistory.update(e,n);let i=new t.J(e,{now:n,fadeDuration:r,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),o=i.crossFadingFactor();o===1&&o===this._crossFadingFactor||(a=!0,this._crossFadingFactor=o),this.style.update(i)}let o=this.style.projection?.transitionState>0!==i;(n=this.style.projection)==null||n.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(this.style.projection?.transitionState,this.style.projection?.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||o)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.tileManager.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style?._updatePlacement(this.transform,this.showCollisionBoxes,r,this._crossSourceCollisions,o),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:r,showPadding:this.showPadding,anisotropicFilterPitch:this.getAnisotropicFilterPitch()}),this.fire(new t.n(`render`)),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new t.n(`load`))),this.style&&(this.style.hasTransitions()||a)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let s=this._sourcesDirty||this._styleDirty||this._placementDirty;return s||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new t.n(`idle`)),!this._loaded||this._fullyLoaded||s||(this._fullyLoaded=!0),this}redraw(){return this.style&&(this._frameRequest&&=(this._frameRequest.abort(),null),this._render(0)),this}remove(){var e,n;this._hash&&this._hash.remove();for(let e of this._controls)e.onRemove(this);this._controls=[],this._frameRequest&&=(this._frameRequest.abort(),null),this._renderTaskQueue.clear(),(e=this._diffStyleRequest)==null||e.abort(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),typeof window<`u`&&this._ownerWindow.removeEventListener(`online`,this._onWindowOnline,!1),u.removeThrottleControl(this._imageQueueHandle),(n=this._resizeObserver)==null||n.disconnect();let r=this.painter.context.gl.getExtension(`WEBGL_lose_context`);r!=null&&r.loseContext&&r.loseContext(),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`),this._removed=!0,this.fire(new t.n(`remove`))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,s.frame(this._frameRequest,(e=>{this._frameRequest=null;try{this._render(e)}catch(e){if(!t.$(e)&&!function(e){return e.message===li}(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 io}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}},so={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};class co{constructor(e,n,r=!1){this.mousedown=e=>{this.startMove(e,d.mousePos(this.element,e)),window.addEventListener(`mousemove`,this.mousemove),window.addEventListener(`mouseup`,this.mouseup)},this.mousemove=e=>{this.move(e,d.mousePos(this.element,e))},this.mouseup=e=>{this._rotatePitchHandler.dragEnd(e),this.offTemp()},this.touchstart=e=>{e.targetTouches.length===1?(this._startPos=this._lastPos=d.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=>{e.targetTouches.length===1?(this._lastPos=d.touchPos(this.element,e.targetTouches)[0],this.move(e,this._lastPos)):this.reset()},this.touchend=e=>{e.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),delete this._startPos,delete this._lastPos,this.offTemp()},this.reset=()=>{this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=n;let i=new ba;this._rotatePitchHandler=new _a({clickTolerance:3,move:(e,i)=>{let a=n.getBoundingClientRect(),o=new t.P((a.bottom-a.top)/2,(a.right-a.left)/2);return{bearingDelta:t.cx(new t.P(e.x,i.y),i,o),pitchDelta:r?-.5*(i.y-e.y):void 0}},moveStateManager:i,enable:!0,assignEvents:()=>{}}),this.map=e,n.addEventListener(`mousedown`,this.mousedown),n.addEventListener(`touchstart`,this.touchstart,{passive:!1}),n.addEventListener(`touchcancel`,this.reset)}startMove(e,t){this._rotatePitchHandler.dragStart(e,t),d.disableDrag()}move(e,t){let n=this.map,{bearingDelta:r,pitchDelta:i}=this._rotatePitchHandler.dragMove(e,t)||{};r&&n.setBearing(n.getBearing()+r),i&&n.setPitch(n.getPitch()+i)}off(){let e=this.element;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(){d.enableDrag(),window.removeEventListener(`mousemove`,this.mousemove),window.removeEventListener(`mouseup`,this.mouseup),window.removeEventListener(`touchmove`,this.touchmove),window.removeEventListener(`touchend`,this.touchend)}}let lo;function uo(e,n,r,i=!1){if(i||!r.getCoveringTilesDetailsProvider().allowWorldCopies())return e?.wrap();let a=new t.W(e.lng,e.lat);if(e=new t.W(e.lng,e.lat),n){let i=new t.W(e.lng-360,e.lat),a=new t.W(e.lng+360,e.lat),o=r.locationToScreenPoint(e).distSqr(n);r.locationToScreenPoint(i).distSqr(n)<o?e=i:r.locationToScreenPoint(a).distSqr(n)<o&&(e=a)}for(;Math.abs(e.lng-r.center.lng)>180;){let t=r.locationToScreenPoint(e);if(t.x>=0&&t.y>=0&&t.x<=r.width&&t.y<=r.height)break;e.lng>r.center.lng?e.lng-=360:e.lng+=360}return e.lng!==a.lng&&r.isPointOnMapSurface(r.locationToScreenPoint(e))?e:a}let fo={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 po(e,t,n){let r=e.classList;for(let e in fo)r.remove(`maplibregl-${n}-anchor-${e}`);r.add(`maplibregl-${n}-anchor-${t}`)}class mo extends t.E{constructor(e){if(super(),this._onClick=e=>{this.fire(new t.n(`click`,{originalEvent:e}))},this._onKeyPress=e=>{e.code!==`Space`&&e.code!==`Enter`||this.togglePopup()},this._onMapClick=e=>{let t=e.originalEvent.target,n=this._element;this._popup&&(t===n||n.contains(t))&&this.togglePopup()},this._update=e=>{if(!this._map)return;let t=this._map.loaded()&&!this._map.isMoving();(e?.type===`terrain`||e?.type===`render`&&!t)&&this._map.once(`render`,this._update),this._lngLat=uo(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let n=``;this._rotationAlignment===`viewport`||this._rotationAlignment===`auto`?n=`rotateZ(${this._rotation}deg)`:this._rotationAlignment===`map`&&(n=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let r=``;this._pitchAlignment===`viewport`||this._pitchAlignment===`auto`?r=`rotateX(0deg)`:this._pitchAlignment===`map`&&(r=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||e&&e.type!==`moveend`||(this._pos=this._pos.round()),this._element.style.transform=`${fo[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${r} ${n}`,s.frameAsync(new AbortController,this._map._ownerWindow).then((()=>{this._updateOpacity(e?.type===`moveend`)})).catch((()=>{}))},this._onMove=e=>{if(!this._isDragging){let t=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=t}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents=`none`,this._state===`pending`&&(this._state=`active`,this.fire(new t.n(`dragstart`))),this.fire(new t.n(`drag`)))},this._onUp=()=>{this._element.style.pointerEvents=`auto`,this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off(`mousemove`,this._onMove),this._map.off(`touchmove`,this._onMove),this._state===`active`&&this.fire(new t.n(`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||`#3FB1CE`,this._scale=e?.scale||1,this._draggable=e?.draggable||!1,this._clickTolerance=e?.clickTolerance||0,this._subpixelPositioning=e?.subpixelPositioning||!1,this._isDragging=!1,this._state=`inactive`,this._rotation=e?.rotation||0,this._rotationAlignment=e?.rotationAlignment||`auto`,this._pitchAlignment=e?.pitchAlignment&&e.pitchAlignment!==`auto`?e.pitchAlignment:this._rotationAlignment,this.setOpacity(e?.opacity,e?.opacityWhenCovered),e?.element)this._element=e.element,this._offset=t.P.convert(e?.offset||[0,0]);else{this._defaultMarker=!0,this._element=d.create(`div`);let n=d.createNS(`http://www.w3.org/2000/svg`,`svg`);n.setAttributeNS(null,`display`,`block`),n.setAttributeNS(null,`height`,`41px`),n.setAttributeNS(null,`width`,`27px`),n.setAttributeNS(null,`viewBox`,`0 0 27 41`);let r=d.createNS(`http://www.w3.org/2000/svg`,`g`);r.setAttributeNS(null,`stroke`,`none`),r.setAttributeNS(null,`stroke-width`,`1`),r.setAttributeNS(null,`fill`,`none`),r.setAttributeNS(null,`fill-rule`,`evenodd`);let i=d.createNS(`http://www.w3.org/2000/svg`,`g`);i.setAttributeNS(null,`fill-rule`,`nonzero`);let a=d.createNS(`http://www.w3.org/2000/svg`,`g`);a.setAttributeNS(null,`transform`,`translate(3.0, 29.0)`),a.setAttributeNS(null,`fill`,`#000000`);for(let e of[{rx:`10.5`,ry:`5.25002273`},{rx:`10.5`,ry:`5.25002273`},{rx:`9.5`,ry:`4.77275007`},{rx:`8.5`,ry:`4.29549936`},{rx:`7.5`,ry:`3.81822308`},{rx:`6.5`,ry:`3.34094679`},{rx:`5.5`,ry:`2.86367051`},{rx:`4.5`,ry:`2.38636864`}]){let t=d.createNS(`http://www.w3.org/2000/svg`,`ellipse`);t.setAttributeNS(null,`opacity`,`0.04`),t.setAttributeNS(null,`cx`,`10.5`),t.setAttributeNS(null,`cy`,`5.80029008`),t.setAttributeNS(null,`rx`,e.rx),t.setAttributeNS(null,`ry`,e.ry),a.appendChild(t)}let o=d.createNS(`http://www.w3.org/2000/svg`,`g`);o.setAttributeNS(null,`fill`,this._color);let s=d.createNS(`http://www.w3.org/2000/svg`,`path`);s.setAttributeNS(null,`d`,`M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z`),o.appendChild(s);let c=d.createNS(`http://www.w3.org/2000/svg`,`g`);c.setAttributeNS(null,`opacity`,`0.25`),c.setAttributeNS(null,`fill`,`#000000`);let l=d.createNS(`http://www.w3.org/2000/svg`,`path`);l.setAttributeNS(null,`d`,`M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z`),c.appendChild(l);let u=d.createNS(`http://www.w3.org/2000/svg`,`g`);u.setAttributeNS(null,`transform`,`translate(6.0, 7.0)`),u.setAttributeNS(null,`fill`,`#FFFFFF`);let f=d.createNS(`http://www.w3.org/2000/svg`,`g`);f.setAttributeNS(null,`transform`,`translate(8.0, 8.0)`);let p=d.createNS(`http://www.w3.org/2000/svg`,`circle`);p.setAttributeNS(null,`fill`,`#000000`),p.setAttributeNS(null,`opacity`,`0.25`),p.setAttributeNS(null,`cx`,`5.5`),p.setAttributeNS(null,`cy`,`5.5`),p.setAttributeNS(null,`r`,`5.4999962`);let m=d.createNS(`http://www.w3.org/2000/svg`,`circle`);m.setAttributeNS(null,`fill`,`#FFFFFF`),m.setAttributeNS(null,`cx`,`5.5`),m.setAttributeNS(null,`cy`,`5.5`),m.setAttributeNS(null,`r`,`5.4999962`),f.appendChild(p),f.appendChild(m),i.appendChild(a),i.appendChild(o),i.appendChild(c),i.appendChild(u),i.appendChild(f),n.appendChild(i),n.setAttributeNS(null,`height`,41*this._scale+`px`),n.setAttributeNS(null,`width`,27*this._scale+`px`),this._element.appendChild(n),this._offset=t.P.convert(e?.offset||[0,-14])}if(this._element.classList.add(`maplibregl-marker`),this._element.addEventListener(`dragstart`,(e=>{e.preventDefault()})),this._element.addEventListener(`mousedown`,(e=>{e.preventDefault()})),po(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._element.hasAttribute(`aria-label`)||this._element.setAttribute(`aria-label`,e._getUIString(`Marker.Title`)),this._element.hasAttribute(`role`)||this._element.setAttribute(`role`,`button`),e.getCanvasContainer().appendChild(this._element),e.on(`move`,this._update),e.on(`moveend`,this._update),e.on(`terrain`,this._update),e.on(`projectiontransition`,this._update),this._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.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.W.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener(`keypress`,this._onKeyPress),this._originalTabIndex||this._element.removeAttribute(`tabindex`)),e){if(!(`offset`in e.options)){let t=38.1,n=13.5,r=13.5/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[r,-1*(t-n+r)],"bottom-right":[-r,-1*(t-n+r)],left:[n,-1*(t-n)],right:[-13.5,-1*(t-n)]}:this._offset}this._popup=e,this._originalTabIndex=this._element.getAttribute(`tabindex`),this._originalTabIndex||this._element.setAttribute(`tabindex`,`0`),this._element.addEventListener(`keypress`,this._onKeyPress)}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){let e=this._popup;return this._element.style.opacity===this._opacityWhenCovered||e&&(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map))),this}_updateOpacity(e=!1){var n;let r=this._map?.terrain,i=this._map.transform.isLocationOccluded(this._lngLat);if(!r||i){let e=i?this._opacityWhenCovered:this._opacity;this._element.style.opacity!==e&&(this._element.style.opacity=e,this._element.classList.toggle(`maplibregl-marker-covered`,i));return}if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null}),100)}let a=this._map,o=a.terrain.depthAtPoint(this._pos),s=a.terrain.getElevationForLngLat(this._lngLat,a.transform);if(a.transform.lngLatToCameraDepth(this._lngLat,s)-o<.006)return this._element.style.opacity=this._opacity,void this._element.classList.remove(`maplibregl-marker-covered`);let c=-this._offset.y/a.transform.pixelsPerMeter,l=Math.sin(a.getPitch()*Math.PI/180)*c,u=a.terrain.depthAtPoint(new t.P(this._pos.x,this._pos.y-this._offset.y)),d=a.transform.lngLatToCameraDepth(this._lngLat,s+l)-u>.006;(n=this._popup)!=null&&n.isOpen()&&d&&this._popup.remove(),this._element.style.opacity=d?this._opacityWhenCovered:this._opacity,this._element.classList.toggle(`maplibregl-marker-covered`,d)}getOffset(){return this._offset}setOffset(e){return this._offset=t.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e)}removeClassName(e){this._element.classList.remove(e)}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on(`mousedown`,this._addDragHandler),this._map.on(`touchstart`,this._addDragHandler)):(this._map.off(`mousedown`,this._addDragHandler),this._map.off(`touchstart`,this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||`auto`,this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&e!==`auto`?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,t){return(this._opacity===void 0||e===void 0&&t===void 0)&&(this._opacity=`1`,this._opacityWhenCovered=`0.2`),e!==void 0&&(this._opacity=String(e)),t!==void 0&&(this._opacityWhenCovered=String(t)),this._map&&this._updateOpacity(!0),this}}let ho={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0},go=0,_o=!1,vo={maxWidth:100,unit:`metric`};function yo(e,t,n){let r=n?.maxWidth||100,i=e._container.clientHeight/2,a=e._container.clientWidth/2,o=e.unproject([a-r/2,i]),s=e.unproject([a+r/2,i]),c=Math.round(e.project(s).x-e.project(o).x),l=Math.min(r,c,e._container.clientWidth),u=o.distanceTo(s);if(n?.unit===`imperial`){let n=3.2808*u;n>5280?bo(t,l,n/5280,e._getUIString(`ScaleControl.Miles`)):bo(t,l,n,e._getUIString(`ScaleControl.Feet`))}else n?.unit===`nautical`?bo(t,l,u/1852,e._getUIString(`ScaleControl.NauticalMiles`)):u>=1e3?bo(t,l,u/1e3,e._getUIString(`ScaleControl.Kilometers`)):bo(t,l,u,e._getUIString(`ScaleControl.Meters`))}function bo(e,t,n,r){let i=function(e){let t=10**(`${Math.floor(e)}`.length-1),n=e/t;return n=n>=10?10:n>=5?5:n>=3?3:n>=2?2:n>=1?1:function(e){let t=10**Math.ceil(-Math.log(e)/Math.LN10);return Math.round(e*t)/t}(n),t*n}(n);e.style.width=i/n*t+`px`,e.innerHTML=`${i}&nbsp;${r}`}let xo={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:``,maxWidth:`240px`,subpixelPositioning:!1,locationOccludedOpacity:void 0,padding:void 0},So=[`a[href]`,`[tabindex]:not([tabindex='-1'])`,`[contenteditable]:not([contenteditable='false'])`,`button:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`].join(`, `);function Co(e){if(e){if(typeof e==`number`){let n=Math.round(Math.abs(e)/Math.SQRT2);return{center:new t.P(0,0),top:new t.P(0,e),"top-left":new t.P(n,n),"top-right":new t.P(-n,n),bottom:new t.P(0,-e),"bottom-left":new t.P(n,-n),"bottom-right":new t.P(-n,-n),left:new t.P(e,0),right:new t.P(-e,0)}}if(e instanceof t.P||Array.isArray(e)){let n=t.P.convert(e);return{center:n,top:n,"top-left":n,"top-right":n,bottom:n,"bottom-left":n,"bottom-right":n,left:n,right:n}}return{center:t.P.convert(e.center||[0,0]),top:t.P.convert(e.top||[0,0]),"top-left":t.P.convert(e[`top-left`]||[0,0]),"top-right":t.P.convert(e[`top-right`]||[0,0]),bottom:t.P.convert(e.bottom||[0,0]),"bottom-left":t.P.convert(e[`bottom-left`]||[0,0]),"bottom-right":t.P.convert(e[`bottom-right`]||[0,0]),left:t.P.convert(e.left||[0,0]),right:t.P.convert(e.right||[0,0])}}return Co(new t.P(0,0))}let wo=n;e.AJAXError=t.cG,e.EXTENT=t.a6,e.Event=t.n,e.Evented=t.E,e.LngLat=t.W,e.MercatorCoordinate=t.a7,e.Point=t.P,e.addProtocol=t.cH,e.config=t.c,e.removeProtocol=t.cI,e.AttributionControl=Ja,e.BoxZoomHandler=pa,e.CanvasSource=we,e.CooperativeGesturesHandler=Ha,e.DoubleClickZoomHandler=Ia,e.DragPanHandler=za,e.DragRotateHandler=Ba,e.EdgeInsets=$t,e.FullscreenControl=class extends t.E{constructor(e={}){var n;super(),this._onFullscreenChange=()=>{let e=window.document.fullscreenElement||window.document.webkitFullscreenElement;for(;e?.shadowRoot?.fullscreenElement;)e=e.shadowRoot.fullscreenElement;e===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,this._pseudo=(n=e.pseudo)!=null&&n,e!=null&&e.container&&(e.container instanceof HTMLElement?this._container=e.container:t.w(`Full screen control 'container' must be a DOM element.`)),`onfullscreenchange`in document?this._fullscreenchange=`fullscreenchange`:`onmozfullscreenchange`in document?this._fullscreenchange=`mozfullscreenchange`:`onwebkitfullscreenchange`in document?this._fullscreenchange=`webkitfullscreenchange`:`onmsfullscreenchange`in document&&(this._fullscreenchange=`MSFullscreenChange`)}onAdd(e){return this._map=e,this._container||=this._map.getContainer(),this._controlContainer=d.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._setupUI(),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){let e=this._fullscreenButton=d.create(`button`,`maplibregl-ctrl-fullscreen`,this._controlContainer);d.create(`span`,`maplibregl-ctrl-icon`,e).setAttribute(`aria-hidden`,`true`),e.type=`button`,this._updateTitle(),this._fullscreenButton.addEventListener(`click`,this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){let e=this._getTitle();this._fullscreenButton.setAttribute(`aria-label`,e),this._fullscreenButton.title=e}_getTitle(){return this._map._getUIString(this._isFullscreen()?`FullscreenControl.Exit`:`FullscreenControl.Enter`)}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle(`maplibregl-ctrl-shrink`),this._fullscreenButton.classList.toggle(`maplibregl-ctrl-fullscreen`),this._updateTitle(),this._fullscreen?(this.fire(new t.n(`fullscreenstart`)),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new t.n(`fullscreenend`)),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){this._pseudo?this._togglePseudoFullScreen():window.document.exitFullscreen?window.document.exitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._pseudo?this._togglePseudoFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle(`maplibregl-pseudo-fullscreen`),this._handleFullscreenChange(),this._map.resize()}},e.GeoJSONSource=xe,e.GeolocateControl=class extends t.E{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new t.n(`outofmaxbounds`,e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case`WAITING_ACTIVE`:case`ACTIVE_LOCK`:case`ACTIVE_ERROR`:this._watchState=`ACTIVE_LOCK`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active-error`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active`);break;case`BACKGROUND`:case`BACKGROUND_ERROR`:this._watchState=`BACKGROUND`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background-error`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-background`);break;default:throw Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&this._watchState!==`OFF`&&this._updateMarker(e),this.options.trackUserLocation&&this._watchState!==`ACTIVE_LOCK`||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove(`maplibregl-user-location-dot-stale`),this.fire(new t.n(`geolocate`,e)),this._finish()}},this._updateCamera=e=>{let n=new t.W(e.coords.longitude,e.coords.latitude),r=e.coords.accuracy,i=this._map.getBearing(),a=t.e({bearing:i},this.options.fitBoundsOptions),o=ue.fromLngLat(n,r);this._map.fitBounds(o,a,{geolocateSource:!0})},this._updateMarker=e=>{if(e){let n=new t.W(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=e.coords.accuracy,this._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=e=>{if(this._map){if(e.code===1){this._watchState=`OFF`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active-error`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background-error`),this._geolocateButton.disabled=!0;let e=this._map._getUIString(`GeolocateControl.LocationNotAvailable`);this._geolocateButton.title=e,this._geolocateButton.setAttribute(`aria-label`,e),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(e.code===3&&_o)return;this._setErrorState()}this._watchState!==`OFF`&&this.options.showUserLocation&&this._dotElement.classList.add(`maplibregl-user-location-dot-stale`),this.fire(new t.n(`error`,e)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._onMoveStart=e=>{if(!this._map)return;let n=e?.[0]instanceof ResizeObserverEntry;e.geolocateSource||this._watchState!==`ACTIVE_LOCK`||n||this._map.isZooming()||(this._watchState=`BACKGROUND`,this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-background`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this.fire(new t.n(`trackuserlocationend`)),this.fire(new t.n(`userlocationlostfocus`)))},this._setupUI=()=>{this._map&&(this._container.addEventListener(`contextmenu`,(e=>{e.preventDefault()})),this._geolocateButton=d.create(`button`,`maplibregl-ctrl-geolocate`,this._container),d.create(`span`,`maplibregl-ctrl-icon`,this._geolocateButton).setAttribute(`aria-hidden`,`true`),this._geolocateButton.type=`button`,this._geolocateButton.disabled=!0)},this._finishSetupUI=e=>{if(this._map){if(!1===e){t.w(`Geolocation support is not available so the GeolocateControl will be disabled.`);let e=this._map._getUIString(`GeolocateControl.LocationNotAvailable`);this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute(`aria-label`,e)}else{let e=this._map._getUIString(`GeolocateControl.FindMyLocation`);this._geolocateButton.disabled=!1,this._geolocateButton.title=e,this._geolocateButton.setAttribute(`aria-label`,e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute(`aria-pressed`,`false`),this._watchState=`OFF`),this.options.showUserLocation&&(this._dotElement=d.create(`div`,`maplibregl-user-location-dot`),this._userLocationDotMarker=new mo({element:this._dotElement}),this._circleElement=d.create(`div`,`maplibregl-user-location-accuracy-circle`),this._accuracyCircleMarker=new mo({element:this._circleElement,pitchAlignment:`map`}),this.options.trackUserLocation&&(this._watchState=`OFF`),this._map.on(`zoom`,this._onUpdate),this._map.on(`move`,this._onUpdate),this._map.on(`rotate`,this._onUpdate),this._map.on(`pitch`,this._onUpdate)),this._geolocateButton.addEventListener(`click`,(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on(`movestart`,this._onMoveStart)}},this.options=t.e({},ho,e)}onAdd(e){return this._map=e,this._container=d.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._setupUI(),function(){return t._(this,arguments,void 0,(function*(e=!1){if(lo!==void 0&&!e)return lo;if(window.navigator.permissions===void 0)return lo=!!window.navigator.geolocation,lo;try{lo=(yield window.navigator.permissions.query({name:`geolocation`})).state!==`denied`}catch{lo=!!window.navigator.geolocation}return lo}))}().then((e=>this._finishSetupUI(e))),this._container}onRemove(){this._geolocationWatchID!==void 0&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off(`movestart`,this._onMoveStart),this._map.off(`zoom`,this._onUpdate),this._map.off(`move`,this._onUpdate),this._map.off(`rotate`,this._onUpdate),this._map.off(`pitch`,this._onUpdate),this._map=void 0,go=0,_o=!1}_isOutOfMapMaxBounds(e){let t=this._map.getMaxBounds(),n=e.coords;return t&&(n.longitude<t.getWest()||n.longitude>t.getEast()||n.latitude<t.getSouth()||n.latitude>t.getNorth())}_setErrorState(){switch(this._watchState){case`WAITING_ACTIVE`:this._watchState=`ACTIVE_ERROR`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active-error`);break;case`ACTIVE_LOCK`:this._watchState=`ACTIVE_ERROR`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active-error`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-waiting`);break;case`BACKGROUND`:this._watchState=`BACKGROUND_ERROR`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-background-error`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-waiting`);break;case`ACTIVE_ERROR`:case`BACKGROUND_ERROR`:case`OFF`:case void 0:break;default:throw Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadiusIfNeeded(){let e=this._userLocationDotMarker.getLngLat();if(!(this.options.showUserLocation&&this.options.showAccuracyCircle&&this._accuracy&&e))return;let t=this._map.project(e),n=this._map.unproject([t.x+100,t.y]),r=e.distanceTo(n)/100,i=2*this._accuracy/r;this._circleElement.style.width=`${i.toFixed(2)}px`,this._circleElement.style.height=`${i.toFixed(2)}px`}trigger(){if(!this._setup)return t.w(`Geolocate control triggered before added to a map`),!1;if(this.options.trackUserLocation){switch(this._watchState){case`OFF`:this._watchState=`WAITING_ACTIVE`,this.fire(new t.n(`trackuserlocationstart`));break;case`WAITING_ACTIVE`:case`ACTIVE_LOCK`:case`ACTIVE_ERROR`:case`BACKGROUND_ERROR`:go--,_o=!1,this._watchState=`OFF`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active-error`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background-error`),this.fire(new t.n(`trackuserlocationend`));break;case`BACKGROUND`:this._watchState=`ACTIVE_LOCK`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background`),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new t.n(`trackuserlocationstart`)),this.fire(new t.n(`userlocationfocus`));break;default:throw Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case`WAITING_ACTIVE`:this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active`);break;case`ACTIVE_LOCK`:this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active`);break;case`OFF`:break;default:throw Error(`Unexpected watchState ${this._watchState}`)}if(this._watchState===`OFF`&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let e;this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.setAttribute(`aria-pressed`,`true`),go++,go>1?(e={maximumAge:6e5,timeout:0},_o=!0):(e=this.options.positionOptions,_o=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.setAttribute(`aria-pressed`,`false`),this.options.showUserLocation&&this._updateMarker(null)}},e.GlobeControl=class{constructor(){this._toggleProjection=()=>{let e=this._map.getProjection()?.type;this._map.setProjection(e!==`mercator`&&e?{type:`mercator`}:{type:`globe`}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{this._globeButton.classList.remove(`maplibregl-ctrl-globe`),this._globeButton.classList.remove(`maplibregl-ctrl-globe-enabled`),this._map.getProjection()?.type===`globe`?(this._globeButton.classList.add(`maplibregl-ctrl-globe-enabled`),this._globeButton.title=this._map._getUIString(`GlobeControl.Disable`)):(this._globeButton.classList.add(`maplibregl-ctrl-globe`),this._globeButton.title=this._map._getUIString(`GlobeControl.Enable`))}}onAdd(e){return this._map=e,this._container=d.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._globeButton=d.create(`button`,`maplibregl-ctrl-globe`,this._container),d.create(`span`,`maplibregl-ctrl-icon`,this._globeButton).setAttribute(`aria-hidden`,`true`),this._globeButton.type=`button`,this._globeButton.addEventListener(`click`,this._toggleProjection),this._updateGlobeIcon(),this._map.on(`styledata`,this._updateGlobeIcon),this._map.on(`projectiontransition`,this._updateGlobeIcon),this._container}onRemove(){this._container.remove(),this._map.off(`styledata`,this._updateGlobeIcon),this._map.off(`projectiontransition`,this._updateGlobeIcon),this._globeButton.removeEventListener(`click`,this._toggleProjection),this._map=void 0}},e.Hash=Zi,e.ImageSource=Se,e.KeyboardHandler=Ma,e.LngLatBounds=ue,e.LogoControl=Ya,e.Map=oo,e.MapLibreMap=oo,e.MapMouseEvent=sa,e.MapTouchEvent=ca,e.MapWheelEvent=la,e.Marker=mo,e.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{let e=this._map.getZoom(),t=e===this._map.getMaxZoom(),n=e===this._map.getMinZoom();this._zoomInButton.disabled=t,this._zoomOutButton.disabled=n,this._zoomInButton.setAttribute(`aria-disabled`,t.toString()),this._zoomOutButton.setAttribute(`aria-disabled`,n.toString())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.cos(this._map.transform.pitchInRadians)**.5}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.cos(this._map.transform.pitchInRadians)**.5}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(e,t)=>{let n=this._map._getUIString(`NavigationControl.${t}`);e.title=n,e.setAttribute(`aria-label`,n)},this.options=t.e({},so,e),this._container=d.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}))),d.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}))),d.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=d.create(`span`,`maplibregl-ctrl-icon`,this._compass),this._compassIcon.setAttribute(`aria-hidden`,`true`))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,`ZoomIn`),this._setButtonTitle(this._zoomOutButton,`ZoomOut`),this._map.on(`zoom`,this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,`ResetBearing`),this.options.visualizePitch&&this._map.on(`pitch`,this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on(`roll`,this._rotateCompassArrow),this._map.on(`rotate`,this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new co(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){this._container.remove(),this.options.showZoom&&this._map.off(`zoom`,this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off(`pitch`,this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off(`roll`,this._rotateCompassArrow),this._map.off(`rotate`,this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(e,t){let n=d.create(`button`,e,this._container);return n.type=`button`,n.addEventListener(`click`,t),n}},e.Popup=class extends t.E{constructor(e){super(),this._updateOpacity=()=>{this.options.locationOccludedOpacity!==void 0&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:``)},this.remove=()=>(this._content&&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 t.n(`close`))),this),this._update=e=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=d.create(`div`,`maplibregl-popup`,this._map.getContainer()),this._tip=d.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`)}let t;if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=uo(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),e&&`point`in e&&e.point&&(t=e.point),this._trackPointer&&!t)return;let n=this._flatPos=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&t?t:this._map.transform.locationToScreenPoint(this._lngLat));let r=this.options.anchor,i=Co(this.options.offset);if(!r){let e=this._container.offsetWidth,t=this._container.offsetHeight,a=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),o;o=n.y+i.bottom.y<t+a.top?[`top`]:n.y>this._map.transform.height-t-a.bottom?[`bottom`]:[],n.x<e/2+a.left?o.push(`left`):n.x>this._map.transform.width-e/2-a.right&&o.push(`right`),r=o.length===0?`bottom`:o.join(`-`)}let a=n.add(i[r]);this.options.subpixelPositioning||(a=a.round()),this._container.style.transform=`${fo[r]} translate(${a.x}px,${a.y}px)`,po(this._container,r,`popup`),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=t.e(Object.create(xo),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 t.n(`open`)),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.W.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=document.createDocumentFragment(),n=document.createElement(`body`),r;for(n.innerHTML=e;r=n.firstChild,r;)t.appendChild(r);return this.setDOMContent(t)}getMaxWidth(){return this._container?.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=d.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=d.create(`button`,`maplibregl-popup-close-button`,this._content),this._closeButton.type=`button`,this._closeButton.innerHTML=`&#215;`,this._closeButton.addEventListener(`click`,this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;let e=this._container.querySelector(So);e&&e.focus()}},e.RasterDEMTileSource=me,e.RasterTileSource=pe,e.ScaleControl=class{constructor(e){this._onMove=()=>{yo(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,yo(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},vo),e)}getDefaultPosition(){return`bottom-left`}onAdd(e){return this._map=e,this._container=d.create(`div`,`maplibregl-ctrl maplibregl-ctrl-scale`,e.getContainer()),this._map.on(`move`,this._onMove),this._onMove(),this._container}onRemove(){this._container.remove(),this._map.off(`move`,this._onMove),this._map=void 0}},e.ScrollZoomHandler=Fa,e.Style=Wn,e.TerrainControl=class{constructor(e){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove(`maplibregl-ctrl-terrain`),this._terrainButton.classList.remove(`maplibregl-ctrl-terrain-enabled`),this._map.terrain?(this._terrainButton.classList.add(`maplibregl-ctrl-terrain-enabled`),this._terrainButton.title=this._map._getUIString(`TerrainControl.Disable`)):(this._terrainButton.classList.add(`maplibregl-ctrl-terrain`),this._terrainButton.title=this._map._getUIString(`TerrainControl.Enable`))},this.options=e}onAdd(e){return this._map=e,this._container=d.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._terrainButton=d.create(`button`,`maplibregl-ctrl-terrain`,this._container),d.create(`span`,`maplibregl-ctrl-icon`,this._terrainButton).setAttribute(`aria-hidden`,`true`),this._terrainButton.type=`button`,this._terrainButton.addEventListener(`click`,this._toggleTerrain),this._updateTerrainIcon(),this._map.on(`terrain`,this._updateTerrainIcon),this._container}onRemove(){this._container.remove(),this._map.off(`terrain`,this._updateTerrainIcon),this._map=void 0}},e.TwoFingersTouchPitchHandler=Aa,e.TwoFingersTouchRotateHandler=Oa,e.TwoFingersTouchZoomHandler=Ea,e.TwoFingersTouchZoomRotateHandler=Va,e.VectorTileSource=fe,e.VideoSource=Ce,e.addSourceType=(e,n)=>t._(void 0,void 0,void 0,(function*(){if(Ee(e))throw Error(`A source type called "${e}" already exists.`);((e,t)=>{Te[e]=t})(e,n)})),e.clearPrewarmedResources=function(){let e=te;e&&(e.isPreloaded()&&e.numActive()===1?(e.release(k),te=null):console.warn(`Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()`))},e.createTileMesh=yn,e.getGlobalDispatcher=ie,e.getMaxParallelImageRequests=function(){return t.c.MAX_PARALLEL_IMAGE_REQUESTS},e.getRTLTextPluginStatus=function(){return Ae().getRTLTextPluginStatus()},e.getVersion=function(){return wo},e.getWorkerCount=function(){return A.workerCount},e.getWorkerUrl=function(){return t.c.WORKER_URL},e.importScriptInWorkers=function(e){return ie().broadcast(`IS`,e)},e.isTimeFrozen=function(){return c.isFrozen()},e.now=l,e.prewarm=function(){ne().acquire(k)},e.restoreNow=function(){c.restoreNow()},e.setMaxParallelImageRequests=function(e){t.c.MAX_PARALLEL_IMAGE_REQUESTS=e},e.setNow=function(e){c.setNow(e)},e.setRTLTextPlugin=function(e,t){return Ae().setRTLTextPlugin(e,t)},e.setWorkerCount=function(e){A.workerCount=e},e.setWorkerUrl=function(e){t.c.WORKER_URL=e}})),e}))}))(),1),Lf=Uint8Array,Rf=Uint16Array,zf=Int32Array,Bf=new Lf([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Vf=new Lf([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Hf=new Lf([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Uf=function(e,t){for(var n=new Rf(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new zf(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)i[a]=a-n[r]<<5|r;return{b:n,r:i}},Wf=Uf(Bf,2),Gf=Wf.b,Kf=Wf.r;Gf[28]=258,Kf[258]=28;var qf=Uf(Vf,0),Jf=qf.b;qf.r;for(var Yf=new Rf(32768),Xf=0;Xf<32768;++Xf){var Zf=(Xf&43690)>>1|(Xf&21845)<<1;Zf=(Zf&52428)>>2|(Zf&13107)<<2,Zf=(Zf&61680)>>4|(Zf&3855)<<4,Yf[Xf]=((Zf&65280)>>8|(Zf&255)<<8)>>1}for(var Qf=(function(e,t,n){for(var r=e.length,i=0,a=new Rf(t);i<r;++i)e[i]&&++a[e[i]-1];var o=new Rf(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(n){s=new Rf(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=o[e[i]-1]++<<u,f=d|(1<<u)-1;d<=f;++d)s[Yf[d]>>c]=l}else for(s=new Rf(r),i=0;i<r;++i)e[i]&&(s[i]=Yf[o[e[i]-1]++]>>15-e[i]);return s}),$f=new Lf(288),Xf=0;Xf<144;++Xf)$f[Xf]=8;for(var Xf=144;Xf<256;++Xf)$f[Xf]=9;for(var Xf=256;Xf<280;++Xf)$f[Xf]=7;for(var Xf=280;Xf<288;++Xf)$f[Xf]=8;for(var ep=new Lf(32),Xf=0;Xf<32;++Xf)ep[Xf]=5;var tp=Qf($f,9,1),np=Qf(ep,5,1),rp=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},ip=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},ap=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},op=function(e){return(e+7)/8|0},sp=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new Lf(e.subarray(t,n))},cp=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],lp=function(e,t,n){var r=Error(t||cp[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,lp),!n)throw r;return r},up=function(e,t,n,r){var i=e.length,a=r?r.length:0;if(!i||t.f&&!t.l)return n||new Lf(0);var o=!n,s=o||t.i!=2,c=t.i;o&&(n=new Lf(i*3));var l=function(e){var t=n.length;if(e>t){var r=new Lf(Math.max(t*2,e));r.set(n),n=r}},u=t.f||0,d=t.p||0,f=t.b||0,p=t.l,m=t.d,h=t.m,g=t.n,_=i*8;do{if(!p){u=ip(e,d,1);var v=ip(e,d+1,3);if(d+=3,!v){var y=op(d)+4,b=e[y-4]|e[y-3]<<8,x=y+b;if(x>i){c&&lp(0);break}s&&l(f+b),n.set(e.subarray(y,x),f),t.b=f+=b,t.p=d=x*8,t.f=u;continue}else if(v==1)p=tp,m=np,h=9,g=5;else if(v==2){var S=ip(e,d,31)+257,C=ip(e,d+10,15)+4,w=S+ip(e,d+5,31)+1;d+=14;for(var T=new Lf(w),E=new Lf(19),D=0;D<C;++D)E[Hf[D]]=ip(e,d+D*3,7);d+=C*3;for(var O=rp(E),k=(1<<O)-1,A=Qf(E,O,1),D=0;D<w;){var ee=A[ip(e,d,k)];d+=ee&15;var y=ee>>4;if(y<16)T[D++]=y;else{var te=0,j=0;for(y==16?(j=3+ip(e,d,3),d+=2,te=T[D-1]):y==17?(j=3+ip(e,d,7),d+=3):y==18&&(j=11+ip(e,d,127),d+=7);j--;)T[D++]=te}}var ne=T.subarray(0,S),re=T.subarray(S);h=rp(ne),g=rp(re),p=Qf(ne,h,1),m=Qf(re,g,1)}else lp(1);if(d>_){c&&lp(0);break}}s&&l(f+131072);for(var ie=(1<<h)-1,ae=(1<<g)-1,oe=d;;oe=d){var te=p[ap(e,d)&ie],se=te>>4;if(d+=te&15,d>_){c&&lp(0);break}if(te||lp(2),se<256)n[f++]=se;else if(se==256){oe=d,p=null;break}else{var ce=se-254;if(se>264){var D=se-257,le=Bf[D];ce=ip(e,d,(1<<le)-1)+Gf[D],d+=le}var ue=m[ap(e,d)&ae],de=ue>>4;ue||lp(3),d+=ue&15;var re=Jf[de];if(de>3){var le=Vf[de];re+=ap(e,d)&(1<<le)-1,d+=le}if(d>_){c&&lp(0);break}s&&l(f+131072);var fe=f+ce;if(f<re){var pe=a-re,me=Math.min(re,fe);for(pe+f<0&&lp(3);f<me;++f)n[f]=r[pe+f]}for(;f<fe;++f)n[f]=n[f-re]}}t.l=p,t.p=oe,t.b=f,t.f=u,p&&(u=1,t.m=h,t.d=m,t.n=g)}while(!u);return f!=n.length&&o?sp(n,0,f):n.subarray(0,f)},dp=new Lf(0),fp=function(e){(e[0]!=31||e[1]!=139||e[2]!=8)&&lp(6,`invalid gzip data`);var t=e[3],n=10;t&4&&(n+=(e[10]|e[11]<<8)+2);for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!e[n++]);return n+(t&2)},pp=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},mp=function(e,t){return((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&lp(6,`invalid zlib data`),(e[1]>>5&1)==+!t&&lp(6,`invalid zlib data: `+(e[1]&32?`need`:`unexpected`)+` dictionary`),(e[1]>>3&4)+2};function hp(e,t){return up(e,{i:2},t&&t.out,t&&t.dictionary)}function gp(e,t){var n=fp(e);return n+8>e.length&&lp(6,`invalid gzip data`),up(e.subarray(n,-8),{i:2},t&&t.out||new Lf(pp(e)),t&&t.dictionary)}function _p(e,t){return up(e.subarray(mp(e,t&&t.dictionary),-4),{i:2},t&&t.out,t&&t.dictionary)}function vp(e,t){return e[0]==31&&e[1]==139&&e[2]==8?gp(e,t):(e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31?hp(e,t):_p(e,t)}var yp=typeof TextDecoder<`u`&&new TextDecoder;try{yp.decode(dp,{stream:!0})}catch{}var bp=Object.defineProperty,xp=Math.pow,Sp=(e,t)=>bp(e,`name`,{value:t,configurable:!0}),Cp=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});Sp((e,t)=>{let n=!1,r=``;return new(L.GridLayer.extend({createTile:Sp((t,i)=>{let a=document.createElement(`img`),o=new AbortController,s=o.signal;return a.cancel=()=>{o.abort()},n||=(e.getHeader().then(e=>{e.tileType===1||e.tileType===6?console.error(`Error: archive contains vector tiles, but leafletRasterLayer is for displaying raster tiles. See https://github.com/protomaps/PMTiles/tree/main/js for details.`):e.tileType===2?r=`image/png`:e.tileType===3?r=`image/jpeg`:e.tileType===4?r=`image/webp`:e.tileType===5&&(r=`image/avif`)}),!0),e.getZxy(t.z,t.x,t.y,s).then(e=>{if(e){let t=new Blob([e.data],{type:r});a.src=window.URL.createObjectURL(t)}else a.style.display=`none`;a.cancel=void 0,i(void 0,a)}).catch(e=>{if(e.name!==`AbortError`)throw e}),a},`createTile`),_removeTile:Sp(function(e){let t=this._tiles[e];t&&(t.el.cancel&&t.el.cancel(),t.el.src&&window.URL.revokeObjectURL(t.el.src),t.el.width=0,t.el.height=0,t.el.deleted=!0,L.DomUtil.remove(t.el),delete this._tiles[e],this.fire(`tileunload`,{tile:t.el,coords:this._keyToTileCoords(e)}))},`_removeTile`)}))(t)},`leafletRasterLayer`);var wp=Sp(e=>(t,n)=>{if(n instanceof AbortController)return e(t,n);let r=new AbortController;return e(t,r).then(e=>n(void 0,e.data,e.cacheControl||``,e.expires||``),e=>n(e)).catch(e=>n(e)),{cancel:Sp(()=>r.abort(),`cancel`)}},`v3compat`),Tp=class{constructor(e){this.tilev4=Sp((e,t)=>Cp(this,null,function*(){if(e.type===`json`){let n=e.url.substr(10),r=this.tiles.get(n);if(r||(r=new Qp(n),this.tiles.set(n,r)),this.metadata){let n=yield r.getTileJson(e.url);return t.signal.throwIfAborted(),{data:n}}let i=yield r.getHeader();return t.signal.throwIfAborted(),(i.minLon>=i.maxLon||i.minLat>=i.maxLat)&&console.error(`Bounds of PMTiles archive ${i.minLon},${i.minLat},${i.maxLon},${i.maxLat} are not valid.`),{data:{tiles:[`${e.url}/{z}/{x}/{y}`],minzoom:i.minZoom,maxzoom:i.maxZoom,bounds:[i.minLon,i.minLat,i.maxLon,i.maxLat]}}}let n=new RegExp(/pmtiles:\/\/(.+)\/(\d+)\/(\d+)\/(\d+)/),r=e.url.match(n);if(!r)throw Error(`Invalid PMTiles protocol URL`);let i=r[1],a=this.tiles.get(i);a||(a=new Qp(i),this.tiles.set(i,a));let o=r[2],s=r[3],c=r[4],l=yield a?.getZxy(+o,+s,+c,t.signal);if(t.signal.throwIfAborted(),l)return{data:new Uint8Array(l.data),cacheControl:l.cacheControl,expires:l.expires};let u=yield a.getHeader();if(u.tileType===1||u.tileType===6){if(this.errorOnMissingTile)throw Error(`Tile not found.`);return{data:new Uint8Array}}return{data:null}}),`tilev4`),this.tile=wp(this.tilev4),this.tiles=new Map,this.metadata=e?.metadata||!1,this.errorOnMissingTile=e?.errorOnMissingTile||!1}add(e){this.tiles.set(e.source.getKey(),e)}get(e){return this.tiles.get(e)}};Sp(Tp,`Protocol`);var Ep=Tp;function Dp(e,t){return(t>>>0)*4294967296+(e>>>0)}Sp(Dp,`toNum`);function Op(e,t){let n=t.buf,r=n[t.pos++],i=(r&112)>>4;if(r<128||(r=n[t.pos++],i|=(r&127)<<3,r<128)||(r=n[t.pos++],i|=(r&127)<<10,r<128)||(r=n[t.pos++],i|=(r&127)<<17,r<128)||(r=n[t.pos++],i|=(r&127)<<24,r<128)||(r=n[t.pos++],i|=(r&1)<<31,r<128))return Dp(e,i);throw Error(`Expected varint not more than 10 bytes`)}Sp(Op,`readVarintRemainder`);function kp(e){let t=e.buf,n=t[e.pos++],r=n&127;return n<128||(n=t[e.pos++],r|=(n&127)<<7,n<128)||(n=t[e.pos++],r|=(n&127)<<14,n<128)||(n=t[e.pos++],r|=(n&127)<<21,n<128)?r:(n=t[e.pos],r|=(n&15)<<28,Op(r,e))}Sp(kp,`readVarint`);function Ap(e,t,n,r,i){return i===0?r===0?[n,t]:[e-1-n,e-1-t]:[t,n]}Sp(Ap,`rotate`);function jp(e,t,n){if(e>26)throw Error(`Tile zoom level exceeds max safe number limit (26)`);if(t>=1<<e||n>=1<<e)throw Error(`tile x/y outside zoom level bounds`);let r=((1<<e)*(1<<e)-1)/3,i=e-1,[a,o]=[t,n];for(let e=1<<i;e>0;e>>=1){let t=a&e,n=o&e;r+=(3*t^n)*(1<<i),[a,o]=Ap(e,a,o,t,n),i--}return r}Sp(jp,`zxyToTileId`);function Mp(e){let t=3*e+1;return t<4294967296?31-Math.clz32(t):63-Math.clz32(t/4294967296)}Sp(Mp,`tileIdToZ`);function Np(e){let t=Mp(e)>>1;if(t>26)throw Error(`Tile zoom level exceeds max safe number limit (26)`);let n=e-((1<<t)*(1<<t)-1)/3,r=0,i=0,a=1<<t;for(let e=1;e<a;e<<=1){let t=e&n/2,a=e&(n^t);[r,i]=Ap(e,r,i,t,a),n/=2,r+=t,i+=a}return[t,r,i]}Sp(Np,`tileIdToZxy`);var Pp=(e=>(e[e.Unknown=0]=`Unknown`,e[e.None=1]=`None`,e[e.Gzip=2]=`Gzip`,e[e.Brotli=3]=`Brotli`,e[e.Zstd=4]=`Zstd`,e))(Pp||{});function Fp(e,t){return Cp(this,null,function*(){if(t===1||t===0)return e;if(t===2){if(globalThis.DecompressionStream===void 0)return vp(new Uint8Array(e));let t=new Response(e).body;if(!t)throw Error(`Failed to read response stream`);let n=t.pipeThrough(new globalThis.DecompressionStream(`gzip`));return new Response(n).arrayBuffer()}throw Error(`Compression method not supported`)})}Sp(Fp,`defaultDecompress`);var Ip=(e=>(e[e.Unknown=0]=`Unknown`,e[e.Mvt=1]=`Mvt`,e[e.Png=2]=`Png`,e[e.Jpeg=3]=`Jpeg`,e[e.Webp=4]=`Webp`,e[e.Avif=5]=`Avif`,e[e.Mlt=6]=`Mlt`,e))(Ip||{});function Lp(e){return e===1?`.mvt`:e===2?`.png`:e===3?`.jpg`:e===4?`.webp`:e===5?`.avif`:e===6?`.mlt`:``}Sp(Lp,`tileTypeExt`);var Rp=127;function zp(e,t){let n=0,r=e.length-1;for(;n<=r;){let i=r+n>>1,a=t-e[i].tileId;if(a>0)n=i+1;else if(a<0)r=i-1;else return e[i]}return r>=0&&(e[r].runLength===0||t-e[r].tileId<e[r].runLength)?e[r]:null}Sp(zp,`findTile`),Sp(class{constructor(e){this.file=e}getKey(){return this.file.name}getBytes(e,t){return Cp(this,null,function*(){return{data:yield this.file.slice(e,e+t).arrayBuffer()}})}},`FileSource`);var Bp=class{constructor(e,t=new Headers,n=void 0){this.url=e,this.customHeaders=t,this.credentials=n,this.mustReload=!1;let r=``;`navigator`in globalThis&&(r=globalThis.navigator?.userAgent??``);let i=r.indexOf(`Windows`)>-1,a=/Chrome|Chromium|Edg|OPR|Brave/.test(r);this.chromeWindowsNoCache=!1,i&&a&&(this.chromeWindowsNoCache=!0)}getKey(){return this.url}setHeaders(e){this.customHeaders=e}getBytes(e,t,n,r){return Cp(this,null,function*(){let i,a;n?a=n:(i=new AbortController,a=i.signal);let o=new Headers(this.customHeaders);o.set(`range`,`bytes=${e}-${e+t-1}`);let s;this.mustReload?s=`reload`:this.chromeWindowsNoCache&&(s=`no-store`);let c=yield fetch(this.url,{signal:a,cache:s,headers:o,credentials:this.credentials});if(e===0&&c.status===416){let e=c.headers.get(`Content-Range`);if(!e||!e.startsWith(`bytes */`))throw Error(`Missing content-length on 416 response`);let t=+e.substr(8);o.set(`range`,`bytes=0-${t-1}`),c=yield fetch(this.url,{signal:a,cache:`reload`,headers:o,credentials:this.credentials})}let l=c.headers.get(`Etag`);if(l!=null&&l.startsWith(`W/`)&&(l=null),c.status===416||r&&l&&l!==r)throw this.mustReload=!0,new Kp(`Server returned non-matching ETag ${r} after one retry. Check browser extensions and servers for issues that may affect correct ETag headers.`);if(c.status>=300)throw Error(`Bad response code: ${c.status}`);let u=c.headers.get(`Content-Length`);if(c.status===200&&(!u||+u>t))throw i&&i.abort(),Error(`Server returned no content-length header or content-length exceeding request. Check that your storage backend supports HTTP Byte Serving.`);return{data:yield c.arrayBuffer(),etag:l||void 0,cacheControl:c.headers.get(`Cache-Control`)||void 0,expires:c.headers.get(`Expires`)||void 0}})}};Sp(Bp,`FetchSource`);var Vp=Bp;function Hp(e,t){let n=e.getUint32(t+4,!0),r=e.getUint32(t+0,!0);return n*xp(2,32)+r}Sp(Hp,`getUint64`);function Up(e,t){let n=new DataView(e),r=n.getUint8(7);if(r>3)throw Error(`Archive is spec version ${r} but this library supports up to spec version 3`);return{specVersion:r,rootDirectoryOffset:Hp(n,8),rootDirectoryLength:Hp(n,16),jsonMetadataOffset:Hp(n,24),jsonMetadataLength:Hp(n,32),leafDirectoryOffset:Hp(n,40),leafDirectoryLength:Hp(n,48),tileDataOffset:Hp(n,56),tileDataLength:Hp(n,64),numAddressedTiles:Hp(n,72),numTileEntries:Hp(n,80),numTileContents:Hp(n,88),clustered:n.getUint8(96)===1,internalCompression:n.getUint8(97),tileCompression:n.getUint8(98),tileType:n.getUint8(99),minZoom:n.getUint8(100),maxZoom:n.getUint8(101),minLon:n.getInt32(102,!0)/1e7,minLat:n.getInt32(106,!0)/1e7,maxLon:n.getInt32(110,!0)/1e7,maxLat:n.getInt32(114,!0)/1e7,centerZoom:n.getUint8(118),centerLon:n.getInt32(119,!0)/1e7,centerLat:n.getInt32(123,!0)/1e7,etag:t}}Sp(Up,`bytesToHeader`);function Wp(e){let t={buf:new Uint8Array(e),pos:0},n=kp(t),r=[],i=0;for(let e=0;e<n;e++){let e=kp(t);r.push({tileId:i+e,offset:0,length:0,runLength:1}),i+=e}for(let e=0;e<n;e++)r[e].runLength=kp(t);for(let e=0;e<n;e++)r[e].length=kp(t);for(let e=0;e<n;e++){let n=kp(t);n===0&&e>0?r[e].offset=r[e-1].offset+r[e-1].length:r[e].offset=n-1}return r}Sp(Wp,`deserializeIndex`);var Gp=class extends Error{};Sp(Gp,`EtagMismatch`);var Kp=Gp;function qp(e,t){return Cp(this,null,function*(){let n=yield e.getBytes(0,16384);if(new DataView(n.data).getUint16(0,!0)!==19792)throw Error(`Wrong magic number for PMTiles archive`);let r=Up(n.data.slice(0,Rp),n.etag),i=n.data.slice(r.rootDirectoryOffset,r.rootDirectoryOffset+r.rootDirectoryLength),a=`${e.getKey()}|${r.etag||``}|${r.rootDirectoryOffset}|${r.rootDirectoryLength}`,o=Wp(yield t(i,r.internalCompression));return[r,[a,o.length,o]]})}Sp(qp,`getHeaderAndRoot`);function Jp(e,t,n,r,i){return Cp(this,null,function*(){let a=Wp(yield t((yield e.getBytes(n,r,void 0,i.etag)).data,i.internalCompression));if(a.length===0)throw Error(`Empty directory is invalid`);return a})}Sp(Jp,`getDirectory`),Sp(class{constructor(e=100,t=!0,n=Fp){this.cache=new Map,this.maxCacheEntries=e,this.counter=1,this.decompress=n}getHeader(e){return Cp(this,null,function*(){let t=e.getKey(),n=this.cache.get(t);if(n)return n.lastUsed=this.counter++,n.data;let r=yield qp(e,this.decompress);return r[1]&&this.cache.set(r[1][0],{lastUsed:this.counter++,data:r[1][2]}),this.cache.set(t,{lastUsed:this.counter++,data:r[0]}),this.prune(),r[0]})}getDirectory(e,t,n,r){return Cp(this,null,function*(){let i=`${e.getKey()}|${r.etag||``}|${t}|${n}`,a=this.cache.get(i);if(a)return a.lastUsed=this.counter++,a.data;let o=yield Jp(e,this.decompress,t,n,r);return this.cache.set(i,{lastUsed:this.counter++,data:o}),this.prune(),o})}prune(){if(this.cache.size>this.maxCacheEntries){let e=1/0,t;this.cache.forEach((n,r)=>{n.lastUsed<e&&(e=n.lastUsed,t=r)}),t&&this.cache.delete(t)}}invalidate(e){return Cp(this,null,function*(){this.cache.delete(e.getKey())})}},`ResolvedValueCache`);var Yp=class{constructor(e=100,t=!0,n=Fp){this.cache=new Map,this.invalidations=new Map,this.maxCacheEntries=e,this.counter=1,this.decompress=n}getHeader(e){return Cp(this,null,function*(){let t=e.getKey(),n=this.cache.get(t);if(n)return n.lastUsed=this.counter++,yield n.data;let r=new Promise((t,n)=>{qp(e,this.decompress).then(e=>{e[1]&&this.cache.set(e[1][0],{lastUsed:this.counter++,data:Promise.resolve(e[1][2])}),t(e[0]),this.prune()}).catch(e=>{n(e)})});return this.cache.set(t,{lastUsed:this.counter++,data:r}),r})}getDirectory(e,t,n,r){return Cp(this,null,function*(){let i=`${e.getKey()}|${r.etag||``}|${t}|${n}`,a=this.cache.get(i);if(a)return a.lastUsed=this.counter++,yield a.data;let o=new Promise((i,a)=>{Jp(e,this.decompress,t,n,r).then(e=>{i(e),this.prune()}).catch(e=>{a(e)})});return this.cache.set(i,{lastUsed:this.counter++,data:o}),o})}prune(){if(this.cache.size>=this.maxCacheEntries){let e=1/0,t;this.cache.forEach((n,r)=>{n.lastUsed<e&&(e=n.lastUsed,t=r)}),t&&this.cache.delete(t)}}invalidate(e){return Cp(this,null,function*(){let t=e.getKey();if(this.invalidations.get(t))return yield this.invalidations.get(t);this.cache.delete(e.getKey());let n=new Promise((n,r)=>{this.getHeader(e).then(e=>{n(),this.invalidations.delete(t)}).catch(e=>{r(e)})});this.invalidations.set(t,n)})}};Sp(Yp,`SharedPromiseCache`);var Xp=Yp,Zp=class{constructor(e,t,n){typeof e==`string`?this.source=new Vp(e):this.source=e,n?this.decompress=n:this.decompress=Fp,t?this.cache=t:this.cache=new Xp}getHeader(){return Cp(this,null,function*(){return yield this.cache.getHeader(this.source)})}getZxyAttempt(e,t,n,r){return Cp(this,null,function*(){let i=jp(e,t,n),a=yield this.cache.getHeader(this.source);if(e<a.minZoom||e>a.maxZoom)return;let o=a.rootDirectoryOffset,s=a.rootDirectoryLength;for(let e=0;e<=3;e++){let e=zp(yield this.cache.getDirectory(this.source,o,s,a),i);if(e){if(e.runLength>0){let t=yield this.source.getBytes(a.tileDataOffset+e.offset,e.length,r,a.etag);return{data:yield this.decompress(t.data,a.tileCompression),cacheControl:t.cacheControl,expires:t.expires}}o=a.leafDirectoryOffset+e.offset,s=e.length}else return}throw Error(`Maximum directory depth exceeded`)})}getZxy(e,t,n,r){return Cp(this,null,function*(){try{return yield this.getZxyAttempt(e,t,n,r)}catch(i){if(i instanceof Kp)return this.cache.invalidate(this.source),yield this.getZxyAttempt(e,t,n,r);throw i}})}getMetadataAttempt(){return Cp(this,null,function*(){let e=yield this.cache.getHeader(this.source),t=yield this.source.getBytes(e.jsonMetadataOffset,e.jsonMetadataLength,void 0,e.etag),n=yield this.decompress(t.data,e.internalCompression),r=new TextDecoder(`utf-8`);return JSON.parse(r.decode(n))})}getMetadata(){return Cp(this,null,function*(){try{return yield this.getMetadataAttempt()}catch(e){if(e instanceof Kp)return this.cache.invalidate(this.source),yield this.getMetadataAttempt();throw e}})}getTileJson(e){return Cp(this,null,function*(){let t=yield this.getHeader(),n=yield this.getMetadata();return{tilejson:`3.0.0`,scheme:`xyz`,tiles:[`${e}/{z}/{x}/{y}${Lp(t.tileType)}`],vector_layers:n.vector_layers,attribution:n.attribution,description:n.description,name:n.name,version:n.version,bounds:[t.minLon,t.minLat,t.maxLon,t.maxLat],center:[t.centerLon,t.centerLat,t.centerZoom],minzoom:t.minZoom,maxzoom:t.maxZoom}})}};Sp(Zp,`PMTiles`);var Qp=Zp;function $p(e,t){return t?.aborted===!0||e instanceof DOMException&&e.name===`AbortError`}function em(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}function tm(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onerror=()=>n(e.error),e.onabort=()=>n(e.error)})}function nm(e,t,n,r){let i;return()=>{if(!i){let a=new Promise((i,a)=>{let o=e.open(t,n);o.onupgradeneeded=()=>r(o.result),o.onsuccess=()=>{let e=o.result;e.onversionchange=()=>e.close(),i(e)},o.onerror=()=>a(o.error),o.onblocked=()=>a(Error(`indexedDB open blocked`))});i=a,a.catch(()=>{i===a&&(i=void 0)})}return i}}function rm(e,t,n,r){let i=nm(e,t,1,r);return{run:(e,t)=>i().then(r=>new Promise((i,a)=>{let o=t(r.transaction(n,e).objectStore(n));o.onsuccess=()=>i(o.result),o.onerror=()=>a(o.error)}))}}function im(e){let t=!1,n=n=>{t=!0,e?.(n)};return{read:async(e,r)=>{if(t)return r();try{return await e()}catch(e){return n(e),r()}},write:async(e,r)=>{if(await r(),!t)try{await e()}catch(e){n(e)}}}}var am=`values`,om=`meta`,sm=48;function cm(e){let t=new Map;return{get:async e=>t.get(e),put:async(e,n,r)=>{t.set(e,{value:n,expires:r})},prune:async n=>{for(let[e,r]of t)r.expires<=n&&t.delete(e);if(t.size>e){let n=[...t.entries()].sort((e,t)=>e[1].expires-t[1].expires);for(let[r]of n.slice(0,t.size-e))t.delete(r)}}}}function lm(e,t={}){let n=t.maxEntries??sm,r=`factory`in t?t.factory:globalThis.indexedDB;if(!r)return cm(n);let i=cm(n),a=im(t=>{console.warn(`Persistence for "${e}" degraded to memory for this session.`,t)}),o=nm(r,e,1,e=>{e.createObjectStore(am),e.createObjectStore(om)});return{get:e=>a.read(async()=>{let t=(await o()).transaction([am,om],`readonly`),n=t.objectStore(om).get(e),r=t.objectStore(am).get(e),[i,a]=await Promise.all([em(n),em(r)]);if(!(i===void 0||a===void 0))return{value:a,expires:i}},()=>i.get(e)),put:(e,t,n)=>a.write(async()=>{let r=(await o()).transaction([am,om],`readwrite`);r.objectStore(am).put(t,e),r.objectStore(om).put(n,e),await tm(r)},()=>i.put(e,t,n)),prune:e=>a.write(async()=>{let t=await o(),r=t.transaction(om,`readonly`),i=r.objectStore(om).getAll(),a=r.objectStore(om).getAllKeys(),[s,c]=await Promise.all([em(i),em(a)]),l=c.map((e,t)=>({key:String(e),expires:s[t]})),u=l.filter(t=>t.expires<=e).map(e=>e.key),d=l.filter(t=>t.expires>e).sort((e,t)=>e.expires-t.expires),f=d.length>n?d.slice(0,d.length-n).map(e=>e.key):[],p=[...u,...f];if(p.length===0)return;let m=t.transaction([am,om],`readwrite`);for(let e of p)m.objectStore(am).delete(e),m.objectStore(om).delete(e);await tm(m)},()=>i.prune(e))}}var um=class{#e=new Map;#t;#n;constructor(e,t=1/0){this.#t=e,this.#n=t}get(e,t){let n=this.#e.get(e);if(n){if(n.expires<=t){this.#e.delete(e);return}return n.value}}put(e,t,n){this.#r(e,t,n+this.#n,n)}putAt(e,t,n,r){this.#r(e,t,n,r)}#r(e,t,n,r){for(let[e,t]of this.#e)t.expires<=r&&this.#e.delete(e);for(this.#e.delete(e),this.#e.set(e,{value:t,expires:n});this.#e.size>this.#t;){let e=this.#e.keys().next().value;if(e===void 0)break;this.#e.delete(e)}}},dm=`binnacle`,fm=`track-points`,pm=2e4;function mm(e=1/0){let t=[];return{all:async()=>t.slice(),append:async n=>{t.push(n),t.length>e&&t.splice(0,t.length-e)},clear:async()=>{t=[]}}}function hm(e=globalThis.indexedDB){if(!e)return mm();let t=mm(pm),{run:n}=rm(e,dm,fm,e=>e.createObjectStore(fm,{autoIncrement:!0})),r=im(()=>{console.warn(`Track persistence "${dm}" degraded to memory for this session.`)});return{all:()=>r.read(()=>n(`readonly`,e=>e.getAll()),()=>t.all()),append:e=>r.write(()=>n(`readwrite`,t=>t.add(e)),()=>t.append(e)),clear:()=>r.write(()=>n(`readwrite`,e=>e.clear()),()=>t.clear())}}var gm=`binnacle-pmtiles-blocks`,_m=`blocks`,vm=`meta`,ym=`archives`,bm=64*1024,xm=256*1024*1024,Sm=30*jc,Cm=16*1024*1024,wm=16;function Tm(e,t){return`${e}\n${t}`}function Em(e,t){let n=new Map,r=new Map,i=0,a=e=>{let t=n.get(e);t&&(n.delete(e),i-=t.size)},o=()=>{if(i<=e)return;let t=[...n.entries()].sort((e,t)=>e[1].lastAccess-t[1].lastAccess);for(let[n]of t){if(i<=e)break;a(n)}};return{getBlocks:async(e,t)=>{let r=new Map;for(let i of t){let t=n.get(Tm(e,i));t&&r.set(i,t.data)}return r},putBlocks:async(e,t,r)=>{for(let[o,s]of t){let t=Tm(e,o);a(t),n.set(t,{data:s,size:s.byteLength,lastAccess:r}),i+=s.byteLength}o()},touch:async(e,t,r)=>{for(let i of t){let t=n.get(Tm(e,i));t&&(t.lastAccess=r)}},getValidator:async e=>r.get(e),setValidator:async(e,t)=>{r.set(e,t)},purgeArchive:async e=>{let t=`${e}\n`;for(let e of n.keys())e.startsWith(t)&&a(e);r.delete(e)},prune:async e=>{for(let[r,i]of n)e-i.lastAccess>=t&&a(r);o()}}}function Dm(e={}){let t=e.maxBytes??xm,n=e.ttlMs??Sm,r=e.memoryMaxBytes??Cm,i=`factory`in e?e.factory:globalThis.indexedDB,a=Em(r,n);if(!i)return a;let o=im(e=>{console.warn(`[charts] block cache fell back to memory; cached chart areas are limited to this session`,e)}),s=nm(i,gm,1,e=>{e.createObjectStore(_m),e.createObjectStore(vm),e.createObjectStore(ym)});return{getBlocks:(e,t)=>o.read(async()=>{let n=(await s()).transaction(_m,`readonly`).objectStore(_m),r=await Promise.all(t.map(t=>em(n.get(Tm(e,t))))),i=new Map;return t.forEach((e,t)=>{let n=r[t];n&&i.set(e,n)}),i},()=>a.getBlocks(e,t)),putBlocks:(e,t,n)=>o.write(async()=>{let r=(await s()).transaction([_m,vm],`readwrite`);for(let[i,a]of t){let t={size:a.byteLength,lastAccess:n};r.objectStore(_m).put(a,Tm(e,i)),r.objectStore(vm).put(t,Tm(e,i))}await tm(r)},()=>a.putBlocks(e,t,n)),touch:(e,t,n)=>o.write(async()=>{let r=(await s()).transaction(vm,`readwrite`),i=r.objectStore(vm);for(let r of t){let t=Tm(e,r),a=i.get(t);a.onsuccess=()=>{let e=a.result;e&&i.put({size:e.size,lastAccess:n},t)}}await tm(r)},()=>a.touch(e,t,n)),getValidator:e=>o.read(async()=>em((await s()).transaction(ym,`readonly`).objectStore(ym).get(e)),()=>a.getValidator(e)),setValidator:(e,t)=>o.write(async()=>{let n=(await s()).transaction(ym,`readwrite`);n.objectStore(ym).put(t,e),await tm(n)},()=>a.setValidator(e,t)),purgeArchive:e=>o.write(async()=>{let t=await s(),n=`${e}\n`,r=t.transaction([_m,vm,ym],`readwrite`),i=r.objectStore(vm),a=r.objectStore(_m),o=i.getAllKeys();o.onsuccess=()=>{for(let e of o.result.map(String).filter(e=>e.startsWith(n)))a.delete(e),i.delete(e);r.objectStore(ym).delete(e)},await tm(r)},()=>a.purgeArchive(e)),prune:e=>o.write(async()=>{let r=await s(),i=r.transaction(vm,`readonly`).objectStore(vm),a=i.getAll(),o=i.getAllKeys(),[c,l]=await Promise.all([em(a),em(o)]),u=l.map((e,t)=>({key:String(e),...c[t]})),d=u.filter(t=>e-t.lastAccess>=n),f=u.filter(t=>e-t.lastAccess<n).sort((e,t)=>e.lastAccess-t.lastAccess),p=f.reduce((e,t)=>e+t.size,0),m=[];for(let e of f){if(p<=t)break;m.push(e.key),p-=e.size}let h=[...d.map(e=>e.key),...m];if(h.length===0)return;let g=r.transaction([_m,vm],`readwrite`);for(let e of h)g.objectStore(_m).delete(e),g.objectStore(vm).delete(e);await tm(g)},()=>a.prune(e))}}function Om(e){let t=[];for(let n of e){let e=t[t.length-1];e&&n===e.start+e.count?e.count+=1:t.push({start:n,count:1})}return t}var km=class{#e;#t;#n;#r;#i;#a=0;#o;#s=!1;constructor(e,t,n={}){this.#e=e,this.#t=t,this.#n=n.blockSize??bm,this.#r=n.pruneEvery??wm,this.#i=n.now??Date.now}getKey(){return this.#e.getKey()}async getBytes(e,t,n,r){let i=this.#n,a=this.#e.getKey(),o=Math.floor(e/i),s=Math.floor((e+t-1)/i),c=[];for(let e=o;e<=s;e++)c.push(e);let l=await this.#t.getBlocks(a,c),u=new Map,d,f;if(o===0)try{let e=await this.#e.getBytes(0,i,n,r);if(e.etag!==void 0){let t=await this.#t.getValidator(a);t!==void 0&&t!==e.etag&&(await this.#t.purgeArchive(a),l.clear()),t!==e.etag&&await this.#t.setValidator(a,e.etag),this.#o=e.etag,this.#s=!0}u.set(0,e.data),l.set(0,e.data),d=e.cacheControl,f=e.expires}catch(e){if(!l.has(0)||$p(e,n))throw e}let p=1/0;for(let[e,t]of l)t.byteLength<i&&(p=Math.min(p,e));let m=Om(c.filter(e=>!l.has(e)&&e<p));(await Promise.all(m.map(e=>this.#e.getBytes(e.start*i,e.count*i,n,r)))).forEach((e,t)=>{let n=m[t];for(let t=0;t<n.count;t++){let r=t*i;if(r>=e.data.byteLength)break;let a=e.data.slice(r,Math.min(r+i,e.data.byteLength));u.set(n.start+t,a),l.set(n.start+t,a)}d??=e.cacheControl,f??=e.expires});let h=this.#i();u.size>0&&(await this.#t.putBlocks(a,u,h),this.#a+=u.size,this.#a>=this.#r&&(this.#a=0,this.#t.prune(h)));let g=c.filter(e=>l.has(e)&&!u.has(e));return g.length>0&&this.#t.touch(a,g,h),{data:this.#c(l,o,s,e,t),etag:await this.#l(a),cacheControl:d,expires:f}}#c(e,t,n,r,i){let a=this.#n,o=r-t*a,s=new Uint8Array(i),c=0;for(let r=t;r<=n;r++){let n=e.get(r);if(!n)break;let l=(r-t)*a,u=Math.max(o,l),d=Math.min(o+i,l+n.byteLength);if(d<=u||(s.set(new Uint8Array(n,u-l,d-u),u-o),c=d-o,n.byteLength<a))break}return c===i?s.buffer:s.buffer.slice(0,c)}async#l(e){if(this.#s)return this.#o;let t=await this.#t.getValidator(e);return t!==void 0&&(this.#o=t,this.#s=!0),t}},Am,jm=2,Mm=[200,500],Nm=class{#e;constructor(e){this.#e=e}getKey(){return this.#e}async getBytes(e,t,n){let r={Range:`bytes=${e}-${e+t-1}`};for(let e=0;;e++){let t;try{t=await fetch(this.#e,{signal:n,cache:`no-store`,headers:r})}catch(t){if($p(t,n)||e>=jm)throw t;await this.#t(e,n);continue}if(t.status<300){let e=t.headers.get(`ETag`)??void 0;return e?.startsWith(`W/`)&&(e=void 0),{data:await t.arrayBuffer(),etag:e,cacheControl:t.headers.get(`Cache-Control`)??void 0,expires:t.headers.get(`Expires`)??void 0}}if(t.status>=500&&e<jm){await this.#t(e,n);continue}throw Error(`PMTiles fetch failed: ${t.status} for ${this.#e}`)}}#t(e,t){let n=Mm[e]??Mm[Mm.length-1];return new Promise((e,r)=>{let i=setTimeout(e,n);t?.addEventListener(`abort`,()=>{clearTimeout(i),r(new DOMException(`Aborted`,`AbortError`))},{once:!0})})}};function Pm(){Am||(Am=new Ep,If.default.addProtocol(`pmtiles`,Am.tile))}var Fm;function Im(e){let t=new Nm(e);return e.startsWith(`blob:`)?t:(Fm??=Dm(),new km(t,Fm))}function Lm(e){Am||Pm(),!Am?.get(e)&&Am?.add(new Qp(Im(e)))}function Rm(e){Am?.tiles.delete(e),Fm?.purgeArchive(e)}var zm=1,Bm={fill:`fill-opacity`,line:`line-opacity`,raster:`raster-opacity`};function Vm(e){return Bm[e]}function Hm(e,t,n=`basemap`){let r=Nf(e,t),i=Object.keys(r.sources),a=r.layers.map(e=>({id:e.id,type:e.type,minzoom:e.minzoom??0,themePaint:e.metadata?.[_f]})),o=a.map(e=>e.id),s=i[0],c=i.flatMap(e=>{let t=r.sources[e];return`url`in t&&typeof t.url==`string`&&t.url.startsWith(`pmtiles://`)?[t.url.slice(vf.length)]:[]}),l,u=e=>{let t=e.getSource(s)?.maxzoom;if(t===void 0)return!1;for(let n of a)e.getLayer(n.id)&&e.setLayerZoomRange(n.id,n.minzoom,t+zm);return!0};return{id:bf(e.identifier),title:e.name,band:n,supportsOpacity:!0,layerIds:o,add(e){for(let e of c)Lm(e);for(let t of i)e.map.getSource(t)||e.map.addSource(t,r.sources[t]);for(let t of r.layers)e.map.getLayer(t.id)||e.map.addLayer(t,e.beforeIdFor(n));if(!s)return;l&&=(e.map.off(`sourcedata`,l),void 0);let t=()=>e.map.isSourceLoaded(s)&&u(e.map);if(!t()){let n=r=>{r.sourceId===s&&r.isSourceLoaded&&t()&&(e.map.off(`sourcedata`,n),l===n&&(l=void 0))};l=n,e.map.on(`sourcedata`,n)}},remove(e){l&&=(e.map.off(`sourcedata`,l),void 0),Ff(e.map,o,i);for(let e of c)Rm(e)},setVisible(e,t){Pf(e.map,o,t)},setOpacity(e,t){for(let n of a){let r=Vm(n.type);r&&e.map.setPaintProperty(n.id,r,t)}},applyTheme(e,t){for(let n of a){if(n.type===`raster`){gf(e.map,n.id,t);continue}if(!n.themePaint)continue;let r=n.type===`line`?`line-color`:`fill-color`;e.map.setPaintProperty(n.id,r,t[n.themePaint])}}}}var Um={r:0,g:0,b:0,a:128};function Wm(e){return`rgba(${e.r}, ${e.g}, ${e.b}, ${(e.a/255).toFixed(3)})`}function Gm(){return{type:`FeatureCollection`,features:[]}}function Km(e){return{type:`FeatureCollection`,features:e}}function qm(e,t,n){return Jm(e,(e,r,i)=>n(e,r,i)?t:null)}function Jm(e,t){let n=new Uint8ClampedArray(e*e*4),r=e/2;for(let i=0;i<e;i+=1)for(let a=0;a<e;a+=1){let o=t(a,i,r);if(!o)continue;let s=(i*e+a)*4;n[s]=o.r,n[s+1]=o.g,n[s+2]=o.b,n[s+3]=o.a}return new ImageData(n,e,e)}var Ym=[`basemap`,`bathymetry`,`weather`,`safety`,`traffic`,`track`,`routes`,`vessel`,`overlay-top`];function Xm(e){return`__z__${e}`}function Zm(e){for(let t of Ym){let n=Xm(t);e.getLayer(n)||e.addLayer({id:n,type:`background`,layout:{visibility:`none`}})}}function Qm(e){let t=Ym[Ym.indexOf(e)+1];return t?Xm(t):void 0}var $m=new Map(Ym.map((e,t)=>[e,t])),eh=class{#e;#t=new Map;#n=new Map;#r;#i;#a;#o;#s;#c;#l;constructor(e,t={}){this.#e=e,this.#r=t.saved??{},this.#i=t.onChange,this.#a=t.savedOrder?[...t.savedOrder]:[],this.#o=t.onOrderChange,this.#s=new Set(t.pinned??[]),this.#c=t.exclusive??[]}async register(e){await this.#u(e),this.#m()}async registerAll(e){for(let t of e)await this.#u(t);this.#m()}async#u(e){if(this.#t.has(e.id))throw Error(`duplicate overlay id: ${e.id}`);this.#t.set(e.id,e);let t=this.#r[e.id],n=t?{visible:!!t.visible,opacity:Number.isFinite(t.opacity)?Math.max(0,Math.min(1,t.opacity)):1}:{visible:e.defaultVisible??!0,opacity:e.defaultOpacity??1},r=this.#n.get(e.id)??n;r.visible&&this.#c.find(t=>t.includes(e.id))?.some(t=>t!==e.id&&this.#n.get(t)?.visible)&&(r.visible=!1),this.#n.set(e.id,r),await e.add(this.#e),e.setVisible(this.#e,r.visible),e.setOpacity?.(this.#e,r.opacity),this.#l&&e.applyTheme?.(this.#e,this.#l)}unregister(e){let t=this.#t.get(e);t&&(t.remove(this.#e),this.#t.delete(e),this.#n.delete(e),this.#a.includes(e)&&(this.#a=this.#a.filter(t=>t!==e),this.#o?.([...this.#a])),this.#d())}toggle(e,t){let n=this.#t.get(e),r=this.#n.get(e);if(!(!n||!r)){if(t){let t=this.#c.find(t=>t.includes(e));for(let n of t??[]){if(n===e)continue;let t=this.#t.get(n),r=this.#n.get(n);t&&r?.visible&&(r.visible=!1,t.setVisible(this.#e,!1))}}if(r.visible=t,n.setVisible(this.#e,t),!t)for(let[t,n]of this.#t){if(n.parent!==e)continue;let r=this.#n.get(t);r?.visible&&(r.visible=!1,n.setVisible(this.#e,!1))}this.#d()}}setOpacity(e,t){let n=this.#t.get(e),r=this.#n.get(e);!n||!r||(r.opacity=t,n.setOpacity?.(this.#e,t),this.#d())}reorder(e,t){if(this.#s.has(e)||!this.#t.has(e)||this.#f(e))return;let n=this.#p().filter(e=>!this.#s.has(e)&&!this.#f(e)).reverse(),r=n.indexOf(e);n.splice(r,1);let i=Math.max(0,Math.min(t,n.length));n.splice(i,0,e),this.#a=n.reverse(),this.#m(),this.#o?.([...this.#a])}applySnapshot(e,t){for(let[t,n]of this.#t){let r=e[t],i=this.#n.get(t);if(!r||!i)continue;r.visible!==i.visible&&(i.visible=r.visible,n.setVisible(this.#e,r.visible));let a=Number.isFinite(r.opacity)?Math.max(0,Math.min(1,r.opacity)):1;a!==i.opacity&&(i.opacity=a,n.setOpacity?.(this.#e,a))}this.#a=[...t],this.#m(),this.#d(),this.#o?.([...this.#a])}#d(){if(!this.#i)return;let e={};for(let[t,n]of this.#n)e[t]={visible:n.visible,opacity:n.opacity};this.#i(e)}#f(e){return this.#t.get(e)?.parent!==void 0}#p(){let e=e=>$m.get(this.#t.get(e)?.band??`basemap`)??0,t=[...this.#t.keys()].filter(e=>!this.#s.has(e)),n=new Set(t.filter(e=>!this.#f(e))),r=this.#a.filter(e=>n.has(e));for(let t of n){if(r.includes(t))continue;let n=e(t),i=r.findIndex(t=>e(t)>n);i<0&&(i=r.length),r.splice(i,0,t)}for(let e of t){let t=this.#t.get(e)?.parent;if(t===void 0)continue;let n=r.indexOf(t);n>=0?r.splice(n+1,0,e):r.push(e)}let i=[...this.#s].filter(e=>this.#t.has(e));return[...r,...i]}#m(){if(!this.#a.length&&!this.#s.size)return;let e=[];for(let t of this.#p()){let n=this.#t.get(t);if(n)for(let t of n.layerIds)this.#e.map.getLayer(t)&&e.push(t)}let t=Xm(`overlay-top`),n=this.#e.map.getLayer(t)?t:void 0;for(let t=e.length-1;t>=0;t--)this.#e.map.moveLayer(e[t],n),n=e[t]}applyTheme(e){this.#l=e;for(let t of this.#t.values())t.applyTheme?.(this.#e,e)}async reattachAll(){Zm(this.#e.map);for(let[e,t]of this.#t){let n=this.#n.get(e)??{visible:!0,opacity:1};t.reset?.(),await(t.reattach??t.add).call(t,this.#e),t.setVisible(this.#e,n.visible),t.setOpacity?.(this.#e,n.opacity),this.#l&&t.applyTheme?.(this.#e,this.#l)}this.#m()}layers(){return this.#p().reverse().flatMap(e=>{let t=this.#t.get(e);if(!t)return[];let n=this.#n.get(e)??{visible:!0,opacity:1};return[{id:e,title:t.title,visible:n.visible,opacity:n.opacity,supportsOpacity:t.supportsOpacity,pinned:this.#s.has(e),band:t.band,parent:t.parent,group:t.group,category:t.category}]})}};function th(e,t,n,r=1){e.hasImage(t)?e.updateImage(t,n):e.addImage(t,n,{pixelRatio:r})}function nh(e){let{minLon:t,minLat:n,maxLon:r,maxLat:i}=e;if([t,n,r,i].every(Number.isFinite)&&!(t>=r||n>=i))return[t,n,r,i]}function rh(e){if(typeof e!=`object`||!e)return;let t=e.vector_layers;if(!Array.isArray(t))return;let n=[];for(let e of t){let t=e?.id;typeof t==`string`&&n.push(t)}return n.length>0?n:void 0}function ih(e){if(typeof e!=`object`||!e)return;let t=e.name;return typeof t==`string`&&t.length>0?t:void 0}function ah(e,t){return{name:ih(t),kind:e.tileType===Ip.Mvt||e.tileType===Ip.Mlt?`vector`:`raster`,bounds:nh(e),minzoom:e.minZoom,maxzoom:e.maxZoom,vectorLayers:rh(t)}}async function oh(e){let t=new Qp(Im(e)),n=await t.getHeader(),r;try{r=await t.getMetadata()}catch{r=void 0}return ah(n,r)}var sh=`streaming-`,ch=e=>`${sh}${e}`,lh=e=>`${sh}${e}-layer`,uh=(e,t,n=``)=>`${e}?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&LAYERS=${t}&CRS=EPSG:3857&BBOX={bbox-epsg-3857}&WIDTH=256&HEIGHT=256&FORMAT=image/png&TRANSPARENT=true&STYLES=${n}`,dh=e=>`${e}/export?bbox={bbox-epsg-3857}&bboxSR=3857&imageSR=3857&size=256,256&dpi=96&format=png32&transparent=true&f=image`;function fh(e,t){let n=ch(e.id),r=lh(e.id);return{id:e.id,title:e.title,band:t,parent:e.parent,group:e.group,category:e.category,supportsOpacity:!0,defaultVisible:e.defaultVisible??!1,defaultOpacity:e.defaultOpacity??1,layerIds:[r],add(i){if(!i.map.getSource(n)){let t={type:`raster`,tiles:[...e.tiles],tileSize:e.tileSize??256,attribution:e.attribution};e.minzoom!==void 0&&(t.minzoom=e.minzoom),e.maxzoom!==void 0&&(t.maxzoom=e.maxzoom),e.bounds&&(t.bounds=e.bounds),i.map.addSource(n,t)}if(!i.map.getLayer(r)){let e={id:r,type:`raster`,source:n};i.map.addLayer(e,i.beforeIdFor(t))}},remove(e){Ff(e.map,[r],[n])},setVisible(e,t){Pf(e.map,[r],t)},setOpacity(e,t){e.map.setPaintProperty(r,`raster-opacity`,t)},applyTheme(e,t){gf(e.map,r,t)}}}function ph(e){function t(t){t.map.getSource(e.sourceId)?.setData(e.features())}return{id:e.id,title:e.title,band:e.band,supportsOpacity:!0,layerIds:[e.layerId],add(t){if(th(t.map,e.iconId,e.iconImage(e.defaultColor),e.pixelRatio??1),!t.map.getSource(e.sourceId)){let n={type:`geojson`,data:e.features()};t.map.addSource(e.sourceId,n)}if(!t.map.getLayer(e.layerId)){let n={id:e.layerId,type:`symbol`,source:e.sourceId,layout:{"icon-image":e.iconId,"icon-rotate":[`get`,`heading`],"icon-rotation-alignment":`map`,"icon-allow-overlap":!0,"icon-ignore-placement":!0}};t.map.addLayer(n,t.beforeIdFor(e.band))}},sync(n){e.beforeSync?.(),e.shouldRefresh()&&t(n)},applyTheme(t,n){let r=e.iconImage(e.paintColor(n));th(t.map,e.iconId,r,e.pixelRatio??1)},setVisible(t,n){Pf(t.map,[e.layerId],n)},setOpacity(t,n){t.map.setPaintProperty(e.layerId,`icon-opacity`,n)},remove(t){Ff(t.map,[e.layerId],[e.sourceId]),t.map.hasImage(e.iconId)&&t.map.removeImage(e.iconId)}}}var mh=`https://tiles.openfreemap.org/styles/liberty`,hh=`https://tiles.openfreemap.org/fonts/{fontstack}/{range}.pbf`;function gh(){return mh}function _h(){return{version:8,name:`binnacle-offline-fallback`,glyphs:hh,sources:{},layers:[{id:`background`,type:`background`,paint:{"background-color":hf(`day`).water}}]}}var vh=[yf,`binnacle-`,sh];function yh(e){try{return e.getStyle().layers??[]}catch{return[]}}function bh(e){return yh(e).filter(e=>!vh.some(t=>e.id.startsWith(t)))}function xh(e){switch(e){case`fill`:return`fill-color`;case`line`:return`line-color`;case`fill-extrusion`:return`fill-extrusion-color`;default:return null}}function Sh(e,t,n){switch(e){case`water`:case`waterway`:return n.water;case`park`:case`landcover`:return n.landcover;case`landuse`:case`building`:return n.land;case`boundary`:return n.boundary;case`transportation`:return n.road;case`aeroway`:return t===`line`?n.road:n.land;default:return null}}function Ch(e,t){if(e.type===`background`)return{property:`background-color`,color:t.background};if(e.type===`symbol`)return{property:`text-color`,color:t.label};let n=xh(e.type);if(!n)return null;let r=Sh(e[`source-layer`],e.type,t);return r?{property:n,color:r}:null}function wh(e,t){for(let n of bh(e)){let r=Ch(n,t);if(r)try{e.setPaintProperty(n.id,r.property,r.color),n.type===`fill`&&e.setPaintProperty(n.id,`fill-pattern`,void 0),n.type===`symbol`&&e.setPaintProperty(n.id,`text-halo-color`,t.background)}catch{}}}function Th(e,t){let n=t.theme===`night-red`?0:1;for(let t of bh(e))if(!(t.type!==`symbol`||!t.layout?.[`icon-image`]))try{e.setPaintProperty(t.id,`icon-opacity`,n)}catch{}}function Eh(e,t){let n=[];for(let r of bh(e)){let i=Ch(r,t);if(!i)continue;let a=r.type===`fill`,o;try{o=e.getPaintProperty(r.id,i.property)}catch{continue}let s=r.type===`symbol`,c={id:r.id,property:i.property,color:o,isFill:a,isSymbol:s};if(s)try{c.halo=e.getPaintProperty(r.id,`text-halo-color`)}catch{}if(a)try{c.pattern=e.getPaintProperty(r.id,`fill-pattern`)}catch{}n.push(c)}return n}function Dh(e,t){for(let n of t)try{e.setPaintProperty(n.id,n.property,n.color),n.isSymbol&&e.setPaintProperty(n.id,`text-halo-color`,n.halo),n.isFill&&e.setPaintProperty(n.id,`fill-pattern`,n.pattern)}catch{}}var Oh=[0,30],kh=2,Ah=250,jh=500,Mh=10;function Nh(e){let t;try{let n=e.view?[e.view.lon,e.view.lat]:e.defaultCenter??Oh,r=e.view?e.view.zoom:e.defaultZoom??kh;t=new If.default.Map({container:e.container,style:gh(),center:n,zoom:Math.min(r,e.maxZoom??1/0),minZoom:e.minZoom,maxZoom:e.maxZoom,attributionControl:{compact:!0}})}catch(e){return console.error(`Map failed to initialize`,e),{destroy:()=>{}}}let n=t,r=!1,i=()=>{},a=!1;n.once(`styledata`,()=>{a=!0}),n.on(`error`,()=>{a||r||(a=!0,console.info(`[map] the base map style is unreachable; starting on the offline fallback base. Cached charts and overlays still load.`),n.setStyle(_h()))}),n.on(`styleimagemissing`,e=>{n.hasImage(e.id)||n.addImage(e.id,{width:1,height:1,data:new Uint8Array(4)})});let o=new ResizeObserver(()=>n.resize());o.observe(e.container);let s=!1,c=()=>{s||(s=!0,requestAnimationFrame(()=>{if(s=!1,r)return;let t=n.getCenter();e.onView?.({lat:t.lat,lon:t.lng,zoom:n.getZoom()})}))};n.on(`move`,c),e.onUserPan&&n.on(`dragstart`,()=>e.onUserPan?.()),e.onClick&&n.on(`click`,t=>e.onClick?.({lng:t.lngLat.lng,lat:t.lngLat.lat}));let l=()=>{};if(e.onContextMenu){let t=e.onContextMenu;n.on(`contextmenu`,e=>{l(),t({lng:e.lngLat.lng,lat:e.lngLat.lat,x:e.point.x,y:e.point.y})});let r=n.getCanvas(),i=0,a=0,o=0;l=()=>{i&&=(clearTimeout(i),0)},r.addEventListener(`pointerdown`,e=>{e.pointerType===`touch`&&(l(),a=e.clientX,o=e.clientY,i=window.setTimeout(()=>{i=0;let e=r.getBoundingClientRect(),s=a-e.left,c=o-e.top,l=n.unproject([s,c]);t({lng:l.lng,lat:l.lat,x:s,y:c})},jh))}),r.addEventListener(`pointermove`,e=>{i&&Math.hypot(e.clientX-a,e.clientY-o)>Mh&&l()}),r.addEventListener(`pointerup`,l),r.addEventListener(`pointercancel`,l)}return n.on(`load`,()=>{c();let t={map:n,beforeIdFor:Qm};Zm(n);let a=new eh(t,e.managerOptions),o=Eh(n,hf(`day`));Promise.resolve(e.onLoad({map:n,ctx:t,manager:a,recolor:e=>{let t=hf(e);e===`day`?Dh(n,o):wh(n,t),Th(n,t),a.applyTheme(t)},isDestroyed:()=>r,runTick:e=>{i();let a=()=>{if(!r)for(let n of e)n.sync(t)};n.on(`render`,a);let o=0,s=()=>{o||=window.setInterval(a,Ah)},c=()=>{o&&=(clearInterval(o),0)},l=()=>{document.hidden?c():(s(),a())};document.addEventListener(`visibilitychange`,l),document.hidden||s(),a(),i=()=>{n.off(`render`,a),c(),document.removeEventListener(`visibilitychange`,l),i=()=>{}}}})).catch(e=>console.error(`map onLoad failed`,e))}),{destroy:()=>{r=!0,l(),i(),o.disconnect(),n.remove()}}}var Ph=.8,Fh=.2126,Ih=.7152,Lh=.0722;function Rh(e){for(let t=0;t<e.length;t+=4)e[t]=Math.round(Fh*e[t]+Ih*e[t+1]+Lh*e[t+2]),e[t+1]=0,e[t+2]=0,e[t+3]=Math.round(e[t+3]*Ph)}var zh=24,Bh=128;function Vh(e,t,n,r){return r?[e/2-r[0]*n,t/2-r[1]*n]:[0,0]}var Hh=async(e,t,n)=>{if(typeof document>`u`||typeof Image>`u`)return null;try{let r=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`,i=new Image;await new Promise((e,t)=>{i.onload=()=>e(),i.onerror=()=>t(Error(`svg decode failed`)),i.src=r});let a=i.naturalWidth||zh,o=i.naturalHeight||zh,s=Bh/Math.max(a,o),c=Math.min(t,s),l=Math.max(1,Math.round(a*c*2)),u=Math.max(1,Math.round(o*c*2)),d=document.createElement(`canvas`);d.width=l,d.height=u;let f=d.getContext(`2d`);if(!f)return null;f.drawImage(i,0,0,l,u);let p=f.getImageData(0,0,l,u);return n.theme===`night-red`&&Rh(p.data),{image:p,cssWidth:l/2,cssHeight:u/2,scale:c}}catch{return null}};function Uh(e){return`binnacle-symbol-${e}`}var Wh=class{#e=new Map;#t=hf(`day`);#n;constructor(e){this.#n=e}entry(e){let t=this.#e.get(e);return t?.status===`ready`?t.entry:void 0}status(e){return this.#e.get(e)?.status}ensure(e,t,n){this.#t=n;let r=this.#e.get(t.uuid);if(r?.status===`failed`)return Promise.resolve(!1);if(r?.status===`loading`)return r.promise;if(r?.status===`ready`&&e.hasImage(Uh(t.uuid)))return Promise.resolve(!0);let i=this.#i(e,t);return this.#e.set(t.uuid,{status:`loading`,symbol:t,promise:i}),i}retheme(e,t){this.#t=t;for(let t of this.#e.values())t.status===`ready`&&this.#a(e,t.symbol)}#r=!1;async#i(e,t){let n=await this.#a(e,t);return n||(this.#e.set(t.uuid,{status:`failed`}),this.#r||(this.#r=!0,console.info(`[symbols] a provided symbol failed to load; built-in icons are used where that happens`))),n}async#a(e,t){let n=await this.#n.svgText(t);if(!n)return!1;let r=this.#t,i=await this.#n.rasterize(n,t.scale??1,r);if(!i)return!1;let a=Uh(t.uuid);return th(e,a,i.image,2),this.#e.set(t.uuid,{status:`ready`,symbol:t,entry:{iconId:a,offset:Vh(i.cssWidth,i.cssHeight,i.scale,t.anchor)}}),r.theme===this.#t.theme?!0:this.#a(e,t)}},Gh=Symbol(`ambiguous`),Kh=class{#e=[];rasterize;#t;#n;#r=new Map;#i=new Map;#a=new Map;constructor(e,t,n=[],r=Hh){this.#t=e,this.#n=t,this.rasterize=r,this.setSymbols(n)}setAuth(e){this.#n=e}setSymbols(e){this.#e=e,this.#r.clear(),this.#i.clear();for(let t of e)for(let e of t.aliases){this.#r.set(e,t);let n=e.slice(e.indexOf(`:`)+1),r=this.#i.get(n);r&&r!==t?this.#i.set(n,Gh):this.#i.set(n,t)}}resolve(e,t){let n=this.#s(e);if(n&&!(t&&n.roles.length>0&&!n.roles.includes(t)))return n}get symbols(){return this.#e}forRole(e){return this.#e.filter(t=>t.roles.includes(e))}createIconRegistry(){return new Wh(this)}svgText(e){let t=this.#a.get(e.uuid);if(t)return t;let n=/^https?:/.test(e.url)?e.url:`${this.#t}${e.url}`,r=this.#o(n);return this.#a.set(e.uuid,r),r.then(t=>{t===void 0&&this.#a.delete(e.uuid)}).catch(()=>this.#a.delete(e.uuid)),r}async#o(e){try{let t=await fetch(e,hc(gu(this.#n)));if(!t.ok)return;let n=await t.text();return n.includes(`<svg`)?n:void 0}catch{return}}#s(e){if(e.startsWith(`default:`))return;if(e.includes(`:`))return this.#r.get(e);let t=this.#i.get(e);return t===Gh?void 0:t}},qh=class{#e=z(`idle`);get status(){return W(this.#e)}set status(e){B(this.#e,e,!0)}#t=z(void 0);get tide(){return W(this.#t)}set tide(e){B(this.#t,e,!0)}#n=z(void 0);get current(){return W(this.#n)}set current(e){B(this.#n,e,!0)}#r=z(void 0);get source(){return W(this.#r)}set source(e){B(this.#r,e,!0)}setLoading(){this.status=`loading`}setReadings(e,t,n){this.tide=e,this.current=t,this.source=e?n:void 0,this.status=e?`ready`:`no-coverage`}setNoCoverage(){this.tide=void 0,this.current=void 0,this.source=void 0,this.status=`no-coverage`}setError(){this.status=`error`}},Jh=5*kc;function Yh(e,t,n,r,i,a){if(!e)return{append:!0,gap:!1};if(i-(t??e.t)>Jh)return{append:!0,gap:!0};let o=i-e.t,s=fd(e.lat,e.lon,n,r);return o>=a.intervalSeconds*1e3&&s>=a.minMeters?{append:!0,gap:!1}:{append:!1,gap:!1}}function Xh(e){if(e.length===0)return{distanceMeters:0,durationSeconds:0,avgSog:0,maxSog:0};let t=0,n=0;for(let r=0;r<e.length;r+=1){let i=e[r];i.sog>n&&(n=i.sog);let a=e[r-1];a&&!i.gap&&(t+=fd(a.lat,a.lon,i.lat,i.lon))}let r=(e[e.length-1].t-e[0].t)/1e3,i=r>0?t/r:0;return{distanceMeters:t,durationSeconds:r,avgSog:i,maxSog:n}}var Zh=class{#e=z(fn([]));get points(){return W(this.#e)}set points(e){B(this.#e,e,!0)}#t=z(!1);get paused(){return W(this.#t)}set paused(e){B(this.#t,e,!0)}#n=R(()=>Xh(this.points));get stats(){return W(this.#n)}set stats(e){B(this.#n,e)}#r;#i;#a=!1;#o;constructor(e,t){this.#r=e,this.#i=t,this.#s()}async#s(){let e=await this.#i.all();e.length>0&&(this.points=[...e,...this.points])}consider(e,t,n,r=Date.now()){let i=this.#o;if(this.#o=r,this.paused){this.#a=!0;return}let a=this.points[this.points.length-1],o=Yh(a,i,e,t,r,this.#r.value);if(!o.append)return;let s={lat:e,lon:t,t:r,sog:n};(o.gap||this.#a)&&(s.gap=!0),this.#a=!1,this.points.push(s),this.#i.append(s)}pause(){this.paused=!0}resume(){this.paused=!1,this.#a=!0}clear(){this.points=[],this.#a=!1,this.#i.clear()}};function Qh(e){return[e.lon,e.lat]}function $h(e){let t=[],n=[];for(let r of e)r.gap&&n.length>0&&(t.push(n),n=[]),n.push(r);return n.length>0&&t.push(n),t}var eg=`/signalk/v1/unitpreferences/active`,tg=`/signalk/v1/applicationData/user/unitpreferences/1.0.0`,ng=`/signalk/v1/unitpreferences/presets`;function rg(e){let t=e?.categories;if(!t)return;let n=t.length?.targetUnit??t.depth?.targetUnit;if(n===`foot`)return`imperial`;if(n===`m`)return`metric`;let r=t.temperature?.targetUnit;if(r===`F`)return`imperial`;if(r===`C`||r===`K`)return`metric`}var ig=class{#e;#t=z(void 0);#n;constructor(e=new Ol(`binnacle:units`,`metric`)){this.#e=e}get mode(){return W(this.#t)??this.#e.value}get source(){return W(this.#t)===void 0?`local`:`server`}get localSetting(){return this.#e}async syncFromServer(e,t){e!==this.#n&&(B(this.#t,void 0),this.#n=e);let n=await _c(`${e}${tg}`,{credentials:`include`},t);if(typeof n?.activePreset==`string`&&n.activePreset){let r=rg(await _c(`${e}${ng}/${encodeURIComponent(n.activePreset)}`,void 0,t));if(r){B(this.#t,r,!0);return}}let r=await _c(`${e}${eg}`,void 0,t),i=rg(r);i?B(this.#t,i,!0):r&&console.info(`[units] the server unit preset was fetched but not recognized; using the local setting`)}};function ag(e){if(!e||typeof e!=`object`)return!1;let t=e;if(typeof t.id!=`string`||typeof t.name!=`string`||t.kind!==`vector`&&t.kind!==`raster`)return!1;let n=t.origin;if(!n||typeof n!=`object`)return!1;let r=n;return!(r.type!==`url`||typeof r.url!=`string`||t.bounds!==void 0&&(!Array.isArray(t.bounds)||t.bounds.length!==4||!t.bounds.every(bc)))}function og(e,t){let n=e.kind!==`raster`;return{identifier:e.id,name:e.name,type:n?`tileJSON`:`tilelayer`,format:n?`mvt`:`png`,url:t,...e.bounds?{bounds:e.bounds}:{},...e.minzoom===void 0?{}:{minzoom:e.minzoom},...e.maxzoom===void 0?{}:{maxzoom:e.maxzoom},...e.layers?{layers:e.layers}:{}}}function sg(e){return`${e.minzoom??0} to ${e.maxzoom??e.minzoom??0}`}function cg(e){try{let t=new URL(e).pathname;return t.slice(t.lastIndexOf(`/`)+1).replace(/\.pmtiles$/i,``)||e}catch{return e}}var lg=class{#e=z(fn([]));get sources(){return W(this.#e)}set sources(e){B(this.#e,e,!0)}#t;#n;#r;#i;constructor(e,t,n,r,i){this.sources=e.filter(ag),this.#t=t,this.#n=n,this.#r=r,this.#i=i}async stageUrl(e){let t=await oh(e);return{source:{id:vc(),name:t.name??cg(e),kind:t.kind,origin:{type:`url`,url:e},bounds:t.bounds,minzoom:t.minzoom,maxzoom:t.maxzoom,layers:t.vectorLayers}}}commit(e,t){let n={...e.source,name:t.trim()||e.source.name};this.sources=[...this.sources,n],this.#t(this.sources),this.#n?.(n)}rename(e,t){let n=this.sources.findIndex(t=>t.id===e);if(n<0)return;let r={...this.sources[n],name:t};this.sources=this.sources.with(n,r),this.#t(this.sources),this.#i?.(r)}remove(e){let t=this.sources.find(t=>t.id===e);t&&(this.#r?.(t),this.sources=this.sources.filter(t=>t.id!==e),this.#t(this.sources))}},ug=1e4,dg=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t;for(let t of[$.position,$.speedOverGround,$.courseOverGroundTrue,$.headingTrue,$.depthBelowTransducer,$.windSpeedApparent,$.outsidePressure])e.cell(t)}get sogMps(){return ic(this.#r($.speedOverGround))}get cogRad(){return ic(this.#r($.courseOverGroundTrue))}get headingRad(){return ic(this.#r($.headingTrue))}get depthMeters(){return ic(this.#r($.depthBelowTransducer))}get windSpeedApparentMps(){return ic(this.#r($.windSpeedApparent))}get outsidePressurePa(){return ic(this.#r($.outsidePressure))}get position(){let e=this.#r($.position);return Zs(e)?e:void 0}#n=R(()=>{if(!this.#t)return!1;let e=this.#e.cell($.position).epoch;return e===0?!1:this.#t.now-e>ug});get positionStale(){return W(this.#n)}#r(e){return this.#e.cell(e).value}};function fg(e){return{name:e.name,...e.description?{description:e.description}:{},feature:{type:`Feature`,geometry:{type:`Point`,coordinates:nc(e.position)},properties:{}}}}function pg(e,t){if(!t||typeof t!=`object`)return;let n=t,r=n.feature?.geometry;if(r?.type!==`Point`||!ec(r.coordinates))return;let i=vu(n.description);return{id:e,name:vu(n.name)??e,position:tc(r.coordinates),...i?{description:i}:{}}}var mg=class{#e=z(fn([]));get waypoints(){return W(this.#e)}set waypoints(e){B(this.#e,e,!0)}#t=z(0);get version(){return W(this.#t)}set version(e){B(this.#t,e,!0)}setWaypoints(e){this.waypoints=e,this.version+=1}};function hg(e){let[t,n,r,i]=Ys(e);return{west:t,south:n,east:r,north:i}}function gg(e,t){let n=Math.max(1e-6,e.east-e.west)/Math.max(1e-6,e.north-e.south),r=Math.max(2,Math.round(Math.sqrt(t/n))),i=Math.max(2,Math.floor(t/r));return{lats:_g(e.south,e.north,r),lons:_g(e.west,e.east,i)}}function _g(e,t,n){let r=(t-e)/(n-1);return Array.from({length:n},(t,n)=>e+n*r)}function vg(e,t,n,r){let i=bg(e.lons,n),a=bg(e.lats,r);if(!i||!a)return;let o=e.lons.length,s=t[a.i*o+i.i],c=t[a.i*o+i.i+1],l=t[(a.i+1)*o+i.i],u=t[(a.i+1)*o+i.i+1];return yc(yc(s,c,i.f),yc(l,u,i.f),a.f)}function yg(e,t){let n=0,r=e.length-2;for(;n<r;){let i=n+r>>>1;t<=e[i+1]?r=i:n=i+1}let i=e[n+1]-e[n]||1;return{i:n,f:(t-e[n])/i}}function bg(e,t){if(!(t<e[0]||t>e[e.length-1]))return yg(e,t)}function xg(e,t){return xc(e,e=>e,t)}function Sg(e,t){let n=e.times;if(n.length===0||t<=n[0])return{lo:0,hi:0,frac:0};if(t>=n[n.length-1])return{lo:n.length-1,hi:n.length-1,frac:0};let{i:r,f:i}=yg(n,t);return{lo:r,hi:r+1,frac:i}}var Cg=class{#e=z(void 0);get grid(){return W(this.#e)}set grid(e){B(this.#e,e,!0)}#t=z(`idle`);get status(){return W(this.#t)}set status(e){B(this.#t,e,!0)}#n=z(void 0);get bbox(){return W(this.#n)}set bbox(e){B(this.#n,e,!0)}#r=z(0);get selectedTime(){return W(this.#r)}set selectedTime(e){B(this.#r,e,!0)}#i=z(void 0);get radar(){return W(this.#i)}set radar(e){B(this.#i,e,!0)}#a=R(()=>this.grid?Sg(this.grid,this.selectedTime):{lo:0,hi:0,frac:0});get bracket(){return W(this.#a)}set bracket(e){B(this.#a,e)}setStatus(e){this.status=e}setGrid(e,t=Date.now()){this.grid=e,this.status=`ready`;let n=e.times[0],r=e.times[e.times.length-1];n!==void 0&&(this.selectedTime<n||this.selectedTime>r)&&(this.selectedTime=xg(e.times,t)??n)}setSelectedTime(e){this.selectedTime=e}setRadar(e){this.radar=e}};function wg(e){let t=e-1;return t*t*t+1}function Tg(e){let t=typeof e==`string`&&e.match(/^\s*(-?[\d.]+)([^\s]*)\s*$/);return t?[parseFloat(t[1]),t[2]||`px`]:[e,`px`]}function Eg(e,{delay:t=0,duration:n=400,easing:r=wg,x:i=0,y:a=0,opacity:o=0}={}){let s=getComputedStyle(e),c=+s.opacity,l=s.transform===`none`?``:s.transform,u=c*(1-o),[d,f]=Tg(i),[p,m]=Tg(a);return{delay:t,duration:n,easing:r,css:(e,t)=>`
751
+ transform: ${l} translate(${(1-e)*d}${f}, ${(1-e)*p}${m});
752
+ opacity: ${c-u*t}`}}function Dg(e,{delay:t=0,duration:n=400,easing:r=wg,start:i=0,opacity:a=0}={}){let o=getComputedStyle(e),s=+o.opacity,c=o.transform===`none`?``:o.transform,l=1-i,u=s*(1-a);return{delay:t,duration:n,easing:r,css:(e,t)=>`
753
+ transform: ${c} scale(${1-l*t});
754
+ opacity: ${s-u*t}
755
+ `}}var Og=[];function kg(e){if(e.key!==`Escape`||e.defaultPrevented)return;let t=Og[Og.length-1];t&&(e.preventDefault(),t.close())}function Ag(e){let t={close:e};return Og.push(t),Og.length===1&&window.addEventListener(`keydown`,kg,!0),()=>{let e=Og.indexOf(t);e>=0&&Og.splice(e,1),Og.length===0&&window.removeEventListener(`keydown`,kg,!0)}}var jg=(e,t)=>{let n=t,r=document.activeElement instanceof HTMLElement?document.activeElement:null,i=Ag(()=>n());return e.focus({preventScroll:!0}),{update(e){n=e},destroy(){i();let t=document.activeElement;(e.contains(t)||t===document.body||t===null)&&r?.focus()}}},Mg=e=>{e.focus({preventScroll:!0})};function Ng(e){return e.key===`Tab`}var Pg=(e,t)=>{function n(e){t?.(e)}return e.addEventListener(`keydown`,n),{update(e){t=e},destroy(){e.removeEventListener(`keydown`,n)}}},Fg=(e,t)=>{let n=()=>[...e.querySelectorAll(t)];n()[0]?.focus({preventScroll:!0});function r(e){if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let t=n();if(t.length===0)return;e.preventDefault();let r=e.key===`ArrowDown`,i=t.indexOf(document.activeElement),a;a=i<0?r?0:t.length-1:r?i+1:i-1+t.length,t[a%t.length]?.focus()}return e.addEventListener(`keydown`,r),{destroy(){e.removeEventListener(`keydown`,r)}}},Ig=`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`,Lg=e=>{function t(t){if(!Ng(t))return;let n=Array.from(e.querySelectorAll(Ig));if(n.length===0)return;let r=n[0],i=n[n.length-1],a=document.activeElement;t.shiftKey&&(a===r||!e.contains(a))?(t.preventDefault(),i.focus()):!t.shiftKey&&(a===i||!e.contains(a))&&(t.preventDefault(),r.focus())}return e.addEventListener(`keydown`,t),{destroy(){e.removeEventListener(`keydown`,t)}}},Rg=K(`<button type="button" class="overlay-backdrop anchored-menu-backdrop svelte-cghis9"></button> <div role="group"><!></div>`,1);function zg(e,t){$e(t,!0);let n=Na(t,`surfaceRef`,15);zn(()=>{if(t.open)return Ag(t.onClose)});var r=ci(),i=Cn(r),a=e=>{var r=Rg(),i=Cn(r),a=H(i,2);Mi(V(a),()=>t.children),N(a),Oa(a,e=>n(e),()=>n()),Gi(a,(e,t)=>Pg?.(e,t),()=>t.onKeydown),U(()=>{Z(i,`aria-label`,t.backdropLabel),ta(a,1,Yi(t.surfaceClass?`anchored-menu-surface ${t.surfaceClass}`:`anchored-menu-surface`),`svelte-cghis9`),Z(a,`aria-label`,t.ariaLabel),Z(a,`id`,t.id)}),G(`click`,i,function(...e){t.onClose?.apply(this,e)}),Hi(3,a,()=>Dg,()=>({start:.92,duration:Sc()?0:140,opacity:.5})),q(e,r)};Y(i,e=>{t.open&&e(a)}),q(e,r),et()}Qr([`click`]);var Bg=5e3,Vg=class{#e=z(!1);#t;get armed(){return W(this.#e)}tap(){return W(this.#e)?(this.disarm(),!0):(B(this.#e,!0),this.#t=setTimeout(()=>{B(this.#e,!1)},Bg),!1)}disarm(){this.#t!==void 0&&clearTimeout(this.#t),this.#t=void 0,B(this.#e,!1)}};function Hg(e){return typeof document>`u`?Promise.resolve(void 0):new Promise(t=>{let n=document.createElement(`input`);n.type=`file`,n.accept=e,n.addEventListener(`cancel`,()=>t(void 0),{once:!0}),n.addEventListener(`change`,()=>t(n.files?.[0]?.text()??void 0),{once:!0}),n.click()})}var Ug=K(`<div class="confirm svelte-trya07" role="group"><span class="confirm-text svelte-trya07"> </span> <div class="panel-controls"><button type="button" class="btn btn-danger"> </button> <button type="button" class="btn">Cancel</button></div></div>`);function Wg(e,t){let n=Na(t,`confirmLabel`,3,`Delete`);var r=Ug(),i=V(r),a=V(i,!0);N(i);var o=H(i,2),s=V(o),c=V(s,!0);N(s);var l=H(s,2);Gi(l,e=>Mg?.(e)),N(o),N(r),U(()=>{Z(r,`aria-label`,t.question),J(a,t.question),J(c,n())}),G(`click`,s,function(...e){t.onConfirm?.apply(this,e)}),G(`click`,l,function(...e){t.onCancel?.apply(this,e)}),q(e,r)}Qr([`click`]);function Gg(e){return`${e} ${new Date().toISOString().slice(0,10)}`}function Kg(e){let t=Gg(e),n=window.prompt(`Save ${e.toLowerCase()} as`,t);if(n!==null)return n.trim()||t}function qg(e,t){let n=window.prompt(`Rename ${e.toLowerCase()} to`,t);if(n!==null)return n.trim()||void 0}var Jg=K(`<p class="empty"> </p>`),Yg=K(`<li><!></li>`),Xg=K(`<ul></ul>`),Zg=K(`<div class="saved"><span class="caps-label"> </span> <!></div>`);function Qg(e,t){$e(t,!0);var n=Zg(),r=V(n),i=V(r,!0);N(r);var a=H(r,2),o=e=>{var n=Jg(),r=V(n,!0);N(n),U(()=>J(r,t.empty)),q(e,n)},s=e=>{var n=Xg();Ei(n,21,()=>t.items,e=>t.key(e),(e,n)=>{var r=Yg();let i;Mi(V(r),()=>t.card,()=>W(n)),N(r),U(e=>i=ta(r,1,``,null,i,e),[()=>({active:t.isActive?.(W(n))})]),q(e,r)}),N(n),U(()=>Z(n,`aria-label`,t.ariaLabel)),q(e,n)};Y(a,e=>{t.items.length===0?e(o):e(s,-1)}),N(n),U(()=>J(i,t.heading)),q(e,n),et()}var $g=K(`<button type="button" class="icon-btn icon-btn--accent"><!></button>`),e_=K(`<span class="subtitle svelte-1r83pwj"> </span>`),t_=K(`<button type="button" class="panel-minimize"><!></button>`),n_=K(`<footer class="panel-footer svelte-1r83pwj"><!></footer>`),r_=K(`<aside tabindex="-1"><header><!> <div class="heading svelte-1r83pwj"><h2 class="panel-title"> </h2> <!></div> <!> <!> <button type="button" class="panel-close"><!></button></header> <div><!></div> <!></aside>`);function i_(e,t){$e(t,!0);let n=Sc(),r=Na(t,`dock`,3,`left`),i=Na(t,`bodyFlex`,3,!1),a=Na(t,`closeLabel`,3,`Close`),o=Na(t,`backLabel`,3,`Back to menu`);var s=r_(),c=V(s);let l;var u=V(c),d=e=>{var n=$g();Ja(V(n),{size:20,"aria-hidden":`true`}),N(n),U(()=>{Z(n,`aria-label`,o()),Z(n,`title`,o())}),G(`click`,n,function(...e){t.onBack?.apply(this,e)}),q(e,n)};Y(u,e=>{t.onBack&&e(d)});var f=H(u,2),p=V(f),m=V(p,!0);N(p);var h=H(p,2),g=e=>{var n=e_(),r=V(n,!0);N(n),U(()=>J(r,t.subtitle)),q(e,n)};Y(h,e=>{t.subtitle&&e(g)}),N(f);var _=H(f,2);Mi(_,()=>t.headerExtra??x);var v=H(_,2),y=e=>{var n=t_(),r=V(n),i=e=>{uo(e,{size:18,"aria-hidden":`true`})},a=e=>{io(e,{size:18,"aria-hidden":`true`})};Y(r,e=>{t.minimize.collapsed?e(i):e(a,-1)}),N(n),U(()=>{Z(n,`aria-label`,t.minimize.collapsed?`Expand panel`:`Minimize panel`),Z(n,`aria-expanded`,!t.minimize.collapsed),Z(n,`title`,t.minimize.collapsed?`Expand panel`:`Minimize panel`)}),G(`click`,n,function(...e){t.minimize.onToggle?.apply(this,e)}),q(e,n)};Y(v,e=>{t.minimize&&e(y)});var b=H(v,2);Vs(V(b),{size:18,"aria-hidden":`true`}),N(b),N(c);var S=H(c,2);let C;Mi(V(S),()=>t.children),N(S);var w=H(S,2),T=e=>{var n=n_();Mi(V(n),()=>t.footer),N(n),q(e,n)};Y(w,e=>{t.footer&&e(T)}),N(s),Gi(s,(e,t)=>jg?.(e,t),()=>t.onClose),U(()=>{ta(s,1,`slide-over slide-over--dock-${r()??``}`,`svelte-1r83pwj`),Z(s,`aria-label`,t.ariaLabel??t.title),l=ta(c,1,`panel-header svelte-1r83pwj`,null,l,{"panel-header--stacked":t.subtitle}),J(m,t.title),Z(b,`aria-label`,a()),Z(b,`title`,a()),C=ta(S,1,`panel-body`,null,C,{"panel-body--flex":i(),"panel-body--collapsed":t.minimize?.collapsed})}),G(`click`,b,function(...e){t.onClose?.apply(this,e)}),Hi(3,s,()=>Eg,()=>({x:r()===`right`?24:-24,duration:n?0:180,opacity:.3})),q(e,s),et()}Qr([`click`]);var a_=[`day`,`dusk`,`night-red`],o_=`binnacle:theme`;function s_(e){return typeof e==`string`&&a_.includes(e)}var c_=class{#e=z(`day`);get theme(){return W(this.#e)}set theme(e){B(this.#e,e,!0)}#t;#n;constructor(e,t,n=()=>{}){this.#t=t,this.#n=n,s_(e)&&(this.theme=e),this.#t(this.theme)}set(e){this.theme=e,this.#t(e),this.#n(e)}cycle(){let e=a_[(a_.indexOf(this.theme)+1)%a_.length];this.set(e)}};function l_(e){return new c_(u_(),t=>{typeof document<`u`&&(document.documentElement.dataset.theme=t),e?.(t)},d_)}function u_(){try{return typeof localStorage<`u`?localStorage.getItem(o_):null}catch{return null}}function d_(e){try{typeof localStorage<`u`&&localStorage.setItem(o_,e)}catch{}}var f_=K(`<span class="unit svelte-1m6vgzo"> </span>`),p_=K(`<label class="field svelte-1m6vgzo"><span class="name svelte-1m6vgzo"> </span> <input class="input svelte-1m6vgzo" type="number"/> <!></label>`);function m_(e,t){$e(t,!0);let n=Na(t,`step`,3,`any`),r=Na(t,`inputWidth`,3,`5.5rem`);function i(e){let n=e.currentTarget,r=Number(n.value);Number.isFinite(r)&&t.onCommit(r),jr().then(()=>{n.value=String(t.value)})}var a=p_(),o=V(a),s=V(o,!0);N(o);var c=H(o,2);X(c);let l;var u=H(c,2),d=e=>{var n=f_(),r=V(n,!0);N(n),U(()=>J(r,t.unit)),q(e,n)};Y(u,e=>{t.unit&&e(d)}),N(a),U(e=>{J(s,t.label),Z(c,`min`,t.min),Z(c,`max`,t.max),Z(c,`step`,n()),ga(c,e),Z(c,`aria-label`,t.ariaLabel??(t.unit?`${t.label} in ${t.unit}`:t.label)),l=ra(c,``,l,{"inline-size":r()})},[()=>String(t.value)]),G(`change`,c,i),q(e,a),et()}Qr([`change`]);var h_=K(`<button type="button" class="icon-btn"><!></button>`);function g_(e,t){var n=h_(),r=V(n),i=e=>{To(e,{size:18,"aria-hidden":`true`})},a=e=>{Co(e,{size:18,"aria-hidden":`true`})};Y(r,e=>{t.shown?e(i):e(a,-1)}),N(n),U(()=>{Z(n,`aria-pressed`,t.shown),Z(n,`aria-label`,t.shown?`Hide on chart`:`Show on chart`),Z(n,`title`,t.shown?`Hide on chart`:`Show on chart`)}),G(`click`,n,function(...e){t.onToggle?.apply(this,e)}),q(e,n)}Qr([`click`]);function __(e,t){let n=bc(e)?e:void 0,r=bc(t)?t:void 0;return n===void 0&&r===void 0?0:n===void 0?1:r===void 0?-1:n-r}function v_(e,t,n,r){let i=new Map;for(let e of n)i.set(e.id,e);let a=e.map(e=>{let n=i.get(e.id);return{id:e.id,label:sd(e.name,e.id),position:e.position,rangeMeters:t?fd(t.latitude,t.longitude,e.position.latitude,e.position.longitude):void 0,bearingRad:t?bd(t,e.position):void 0,sogMps:e.sogMps,cpaMeters:e.cpaMeters??n?.cpaMeters,tcpaSeconds:e.tcpaSeconds??n?.tcpaSeconds,severity:n?.severity}});return r===`name`?a.sort((e,t)=>e.label.localeCompare(t.label)):r===`cpa`?a.sort((e,t)=>__(e.cpaMeters,t.cpaMeters)):a.sort((e,t)=>__(e.rangeMeters,t.rangeMeters)),a}var y_=K(`<button type="button"> </button>`),b_=K(`<p class="muted-note">No AIS targets.</p>`),x_=K(`<span class="metric svelte-10s9s8v">CPA <b class="svelte-10s9s8v"> </b> nm</span>`),S_=K(`<span class="metric svelte-10s9s8v">TCPA <b class="svelte-10s9s8v"> </b> min</span>`),C_=K(`<li><button type="button" class="target svelte-10s9s8v"><span> </span> <span class="metrics svelte-10s9s8v"><span class="metric svelte-10s9s8v">Range <b class="svelte-10s9s8v"> </b></span> <span class="metric svelte-10s9s8v">Brg <b class="svelte-10s9s8v"> </b>&deg;T</span> <span class="metric svelte-10s9s8v">SOG <b class="svelte-10s9s8v"> </b> kn</span> <!> <!></span></button></li>`),w_=K(`<ul class="targets svelte-10s9s8v"></ul>`),T_=K(`<section class="ais-list svelte-10s9s8v"><div class="sort svelte-10s9s8v"><span class="caps-label">Sort by</span> <div class="segmented" role="group" aria-label="Sort targets by"></div></div> <!></section>`);function E_(e,t){$e(t,!0);let n=z(`range`),r=[{id:`range`,label:`Range`},{id:`cpa`,label:`CPA`},{id:`name`,label:`Name`}],i=R(()=>v_(t.aisTargets.list(),t.vessel.position,t.collision.assessment.contacts,W(n)));i_(e,{title:`AIS targets`,get subtitle(){return`${W(i).length??``} tracked`},get onClose(){return t.onClose},get onBack(){return t.onBack},children:(e,a)=>{var o=T_(),s=V(o),c=H(V(s),2);Ei(c,21,()=>r,e=>e.id,(e,t)=>{var r=y_();let i;var a=V(r,!0);N(r),U(()=>{i=ta(r,1,`btn`,null,i,{"is-on":W(n)===W(t).id}),Z(r,`aria-pressed`,W(n)===W(t).id),J(a,W(t).label)}),G(`click`,r,()=>B(n,W(t).id,!0)),q(e,r)}),N(c),N(s);var l=H(s,2),u=e=>{q(e,b_())},d=e=>{var n=w_();Ei(n,21,()=>W(i),e=>e.id,(e,n)=>{var r=C_(),i=V(r),a=V(i);let o;var s=V(a,!0);N(a);var c=H(a,2),l=V(c),u=H(V(l)),d=V(u,!0);N(u),N(l);var f=H(l,2),p=H(V(f)),m=V(p,!0);N(p),P(),N(f);var h=H(f,2),g=H(V(h)),_=V(g,!0);N(g),P(),N(h);var v=H(h,2),y=e=>{var t=x_(),r=H(V(t)),i=V(r,!0);N(r),P(),N(t),U(e=>J(i,e),[()=>hl(W(n).cpaMeters)]),q(e,t)};Y(v,e=>{W(n).cpaMeters!==void 0&&e(y)});var b=H(v,2),x=e=>{var t=S_(),r=H(V(t)),i=V(r,!0);N(r),P(),N(t),U(e=>J(i,e),[()=>gl(W(n).tcpaSeconds,1)]),q(e,t)};Y(b,e=>{W(n).tcpaSeconds!==void 0&&e(x)}),N(c),N(i),N(r),U((e,t,r)=>{Z(i,`title`,`Show ${W(n).label??``} on the chart`),o=ta(a,1,`name svelte-10s9s8v`,null,o,{danger:W(n).severity===`danger`,warning:W(n).severity===`warning`}),J(s,W(n).label),J(d,e),J(m,t),J(_,r)},[()=>ml(W(n).rangeMeters,t.units.mode),()=>Bc(W(n).bearingRad),()=>zc(W(n).sogMps)]),G(`click`,i,()=>t.onLocate(W(n).position)),q(e,r)}),N(n),q(e,n)};Y(l,e=>{W(i).length===0?e(u):e(d,-1)}),N(o),q(e,o)},$$slots:{default:!0}}),et()}Qr([`click`]);var D_=K(`<dt>Depth</dt> <dd><span class="num"> </span><span class="unit"> </span></dd>`,1),O_=K(`<button type="button" class="btn btn-danger"><!> Raise anchor</button>`),k_=K(`<button type="button" class="btn btn-primary"><!> Drop anchor here</button>`),A_=K(`<div class="panel-controls"><!></div>`),j_=K(`<p class="hint svelte-17wyh8o">Waiting for a GPS fix to drop the anchor at.</p>`),M_=K(`<p class="hint svelte-17wyh8o">Drag the anchor marker on the chart to correct the drop point.</p>`),N_=K(`<p class="alert-note" role="alert"> </p>`),P_=K(`<section class="anchor-watch svelte-17wyh8o"><p role="status"> </p> <dl class="stat-grid"><dt>Distance</dt> <dd><span class="num"> </span><span class="unit"> </span></dd> <dt>Radius</dt> <dd><span class="num"> </span><span class="unit"> </span></dd> <!></dl> <!> <button type="button" class="btn btn-ghost"><!> Set from current distance</button> <!> <!> <!> <!></section>`);function F_(e,t){$e(t,!0);let n=R(()=>t.anchor.watching),r=R(()=>t.anchor.distanceMeters),i=R(()=>t.units.mode),a=R(()=>tl(W(i))),o=R(()=>{let e=t.anchor.radiusMeters??t.anchor.preferredRadiusMeters;return Math.round(W(i)===`imperial`?Qc(e)??0:e)}),s=R(()=>W(i)===`imperial`?Math.round(Qc(10)??0):10),c=R(()=>nl(W(r),W(i),0)),l=R(()=>W(n)?nl(t.anchor.radiusMeters,W(i),0):`--`),u=R(()=>nl(t.vessel.depthMeters,W(i),1)),d=R(()=>`Set the radius to the current distance plus a ${nl(15,W(i),0)} ${W(a)} margin`),f={server:`Watching on the server. The alarm keeps running when Binnacle is closed.`,client:`Watching in this browser only. Keep Binnacle open for the alarm.`,off:`No anchor down.`},p=R(()=>t.anchor.dragging?`Dragging: the boat is outside the watch radius.`:f[t.anchor.mode]);function m(e){let n=W(i)===`imperial`?$c(e):e;t.onSetRadius(Math.max(10,n))}let h=z(!1);zn(()=>{!W(n)&&W(h)&&B(h,!1)});function g(){W(r)!=null&&t.onSetRadius(Td(W(r)))}i_(e,{title:`Anchor watch`,get onClose(){return t.onClose},get onBack(){return t.onBack},children:(e,f)=>{var _=P_(),v=V(_);let y;var b=V(v,!0);N(v);var x=H(v,2),S=H(V(x),2),C=V(S),w=V(C,!0);N(C);var T=H(C),E=V(T,!0);N(T),N(S);var D=H(S,4),O=V(D),k=V(O,!0);N(O);var A=H(O),ee=V(A,!0);N(A),N(D);var te=H(D,2),j=e=>{var t=D_(),n=H(Cn(t),2),r=V(n),i=V(r,!0);N(r);var o=H(r),s=V(o,!0);N(o),N(n),U(()=>{J(i,W(u)),J(s,W(a))}),q(e,t)};Y(te,e=>{t.vessel.depthMeters!==void 0&&e(j)}),N(x);var ne=H(x,2);{let e=R(()=>W(i)===`imperial`?`feet`:`meters`);m_(ne,{label:`Watch radius`,get unit(){return W(a)},get min(){return W(s)},step:1,get ariaLabel(){return`Watch radius in ${W(e)??``}`},get value(){return W(o)},onCommit:m})}var re=H(ne,2);ho(V(re),{size:16,"aria-hidden":`true`}),P(),N(re);var ie=H(re,2),ae=e=>{Wg(e,{question:`Raise the anchor and end the watch?`,confirmLabel:`Raise`,onConfirm:()=>{B(h,!1),t.onRaise()},onCancel:()=>{B(h,!1)}})},oe=e=>{var r=A_(),i=V(r),a=e=>{var t=O_();Ga(V(t),{size:16,"aria-hidden":`true`}),P(),N(t),G(`click`,t,()=>{B(h,!0)}),q(e,t)},o=e=>{var n=k_();Ga(V(n),{size:16,"aria-hidden":`true`}),P(),N(n),U(()=>n.disabled=!t.vessel.position),G(`click`,n,function(...e){t.onDrop?.apply(this,e)}),q(e,n)};Y(i,e=>{W(n)?e(a):e(o,-1)}),N(r),q(e,r)};Y(ie,e=>{W(n)&&W(h)?e(ae):e(oe,-1)});var se=H(ie,2),ce=e=>{q(e,j_())};Y(se,e=>{!W(n)&&!t.vessel.position&&e(ce)});var le=H(se,2),ue=e=>{q(e,M_())};Y(le,e=>{W(n)&&e(ue)});var de=H(le,2),fe=e=>{var n=N_(),r=V(n,!0);N(n),U(()=>J(r,t.error)),q(e,n)};Y(de,e=>{t.error&&e(fe)}),N(_),U(()=>{y=ta(v,1,`status svelte-17wyh8o`,null,y,{"status--alarm":t.anchor.dragging}),J(b,W(p)),J(w,W(c)),J(E,W(a)),J(k,W(l)),J(ee,W(a)),re.disabled=!W(n)||W(r)==null,Z(re,`title`,W(d))}),G(`click`,re,g),q(e,_)},$$slots:{default:!0}}),et()}Qr([`click`]);var I_=K(`<span class="note ack-tag">Acknowledged</span>`),L_=K(`<div class="actions actions--safety"><button type="button" class="ack">Acknowledge</button> <button type="button" class="ack ack--warning"> </button></div>`),R_=K(`<aside aria-label="Anchor alarm"><div class="head"><span class="title">Anchor dragging</span> <!></div> <div class="row"><span class="metric">Off anchor <b> </b> </span> <span class="metric">Radius <b> </b> </span></div></aside>`);function z_(e,t){$e(t,!0);let n=new Vg;Fa(()=>n.disarm());function r(){n.tap()&&t.onRaise()}var i=ci(),a=Cn(i),o=e=>{var i=R_();let a;var o=V(i),s=H(V(o),2),c=e=>{q(e,I_())},l=e=>{var i=L_(),a=V(i),o=H(a,2),s=V(o,!0);N(o),N(i),U(()=>J(s,n.armed?`Confirm raise?`:`Raise anchor`)),G(`click`,a,()=>t.anchor.acknowledge()),G(`click`,o,r),q(e,i)};Y(s,e=>{t.anchor.acknowledged?e(c):e(l,-1)}),N(o);var u=H(o,2),d=V(u),f=H(V(d)),p=V(f,!0);N(f);var m=H(f);N(d);var h=H(d,2),g=H(V(h)),_=V(g,!0);N(g);var v=H(g);N(h),N(u),N(i),U((e,n,r,o)=>{a=ta(i,1,`bottom-strip bottom-strip--alarm`,null,a,{"is-ack":t.anchor.acknowledged}),J(p,e),J(m,` ${n??``}`),J(_,r),J(v,` ${o??``}`)},[()=>nl(t.anchor.distanceMeters,t.units.mode,0),()=>tl(t.units.mode),()=>nl(t.anchor.radiusMeters,t.units.mode,0),()=>tl(t.units.mode)]),q(e,i)};Y(a,e=>{t.anchor.dragging&&e(o)}),q(e,i),et()}Qr([`click`]);var B_={frequency:660,beepMs:150,gapMs:100,beeps:3,periodMs:1600,volume:.18},V_=`binnacle-anchor-shapes`,H_=`binnacle-anchor-point`,U_=`binnacle-anchor-swing-fill`,W_=`binnacle-anchor-swing-ring`,G_=`binnacle-anchor-rode`,K_=`binnacle-anchor-marker`,q_=`routes`,J_=[U_,W_,G_,K_],Y_=`anchor-watch`,X_=.1;function Z_(e){return[`case`,[`get`,`dragging`],e.danger,e.select]}function Q_(e,t,n,r){let i=[];return e&&t!==void 0&&i.push({type:`Feature`,geometry:{type:`Polygon`,coordinates:[ud(e.latitude,e.longitude,t)]},properties:{dragging:r}}),e&&n&&i.push({type:`Feature`,geometry:{type:`LineString`,coordinates:[[e.longitude,e.latitude],[n.longitude,n.latitude]]},properties:{dragging:r,rode:!0}}),Km(i)}function $_(e,t){return e?Km([{type:`Feature`,geometry:{type:`Point`,coordinates:[e.longitude,e.latitude]},properties:{dragging:t}}]):Gm()}function ev(e,t,n){let r=hf(`day`),i=1,a,o=!1,s,c,l,u=!1,d=!1,f=e=>{a={latitude:e.lngLat.lat,longitude:e.lngLat.lng},o=!0};return{id:Y_,title:`Anchor watch`,band:q_,supportsOpacity:!0,layerIds:J_,add(e){let{map:t}=e,s=e.beforeIdFor(q_);if(!t.getSource(V_)){let e={type:`geojson`,data:Gm()};t.addSource(V_,e)}if(!t.getSource(H_)){let e={type:`geojson`,data:Gm()};t.addSource(H_,e)}if(!t.getLayer(U_)){let e={id:U_,type:`fill`,source:V_,filter:[`!`,[`has`,`rode`]],paint:{"fill-color":Z_(r),"fill-opacity":X_*i}};t.addLayer(e,s)}if(!t.getLayer(W_)){let e={id:W_,type:`line`,source:V_,filter:[`!`,[`has`,`rode`]],paint:{"line-color":Z_(r),"line-width":[`case`,[`get`,`dragging`],3,2]}};t.addLayer(e,s)}if(!t.getLayer(G_)){let e={id:G_,type:`line`,source:V_,filter:[`has`,`rode`],paint:{"line-color":Z_(r),"line-width":1.5,"line-dasharray":[1,2]}};t.addLayer(e,s)}if(!t.getLayer(K_)){let e={id:K_,type:`circle`,source:H_,paint:{"circle-radius":7,"circle-color":Z_(r),"circle-stroke-color":r.markerGlyph,"circle-stroke-width":1.5}};t.addLayer(e,s)}if(o=!0,!n||d)return;d=!0;let c=n;function l(e){t.off(`mousemove`,f),t.off(`touchmove`,f),t.off(`touchcancel`,u);let n=a??{latitude:e.lngLat.lat,longitude:e.lngLat.lng};a=void 0,o=!0,c(n)}function u(){t.off(`mousemove`,f),t.off(`touchmove`,f),t.off(`touchend`,l),a=void 0,o=!0}t.on(`mousedown`,K_,e=>{e.preventDefault(),t.on(`mousemove`,f),t.once(`mouseup`,l)}),t.on(`touchstart`,K_,e=>{e.points.length===1&&(e.preventDefault(),t.on(`touchmove`,f),t.once(`touchend`,l),t.once(`touchcancel`,u))}),t.on(`mouseenter`,K_,()=>{t.getCanvas().style.cursor=`move`}),t.on(`mouseleave`,K_,()=>{t.getCanvas().style.cursor=``})},sync(n){let r=a??e.position,i=t.position,d=e.radiusMeters,f=e.dragging;!o&&r===s&&i===c&&d===l&&f===u||(o=!1,s=r,c=i,l=d,u=f,n.map.getSource(V_)?.setData(Q_(r,d,i,f)),n.map.getSource(H_)?.setData($_(r,f)))},setVisible(e,t){Pf(e.map,J_,t)},setOpacity(e,t){i=t,e.map.setPaintProperty(U_,`fill-opacity`,X_*i),e.map.setPaintProperty(W_,`line-opacity`,i),e.map.setPaintProperty(G_,`line-opacity`,i),e.map.setPaintProperty(K_,`circle-opacity`,i),e.map.setPaintProperty(K_,`circle-stroke-opacity`,i)},applyTheme(e,t){r=t,e.map.setPaintProperty(U_,`fill-color`,Z_(r)),e.map.setPaintProperty(W_,`line-color`,Z_(r)),e.map.setPaintProperty(G_,`line-color`,Z_(r)),e.map.setPaintProperty(K_,`circle-color`,Z_(r)),e.map.setPaintProperty(K_,`circle-stroke-color`,r.markerGlyph)},remove(e){Ff(e.map,J_,[V_,H_])}}}var tv=`/plugins/anchoralarm`;async function nv(e,t,n){try{let r=n===void 0?{method:`POST`}:{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)};return(await fetch(e,hc(gu(t,r)))).ok}catch{return!1}}function rv(e,t,n){return nv(`${e}${tv}/dropAnchor`,t,{radius:n})}function iv(e,t,n){return nv(`${e}${tv}/setRadius`,t,{radius:n})}function av(e,t){return nv(`${e}${tv}/raiseAnchor`,t)}function ov(e,t,n){return Cu(`${e}/signalk/v1/api/vessels/self/navigation/anchor/position`,t,{value:{latitude:n.latitude,longitude:n.longitude}})}var sv=`/signalk/v2/api/vessels/self/navigation/anchor`;function cv(e,t){return nv(`${e}${sv}/drop`,t)}function lv(e,t){return nv(`${e}${sv}/raise`,t)}function uv(e,t,n){return nv(`${e}${sv}/radius`,t,{value:n})}function dv(e,t,n,r){return nv(`${e}${sv}/reposition`,t,{rodeLength:n,anchorDepth:r})}function fv(e,t,n){return n.standardApiAvailable?{kind:`standard`,async drop(n){return await cv(e,t)?(await uv(e,t,n),!0):!1},raise:()=>lv(e,t),setRadius:n=>uv(e,t,n),setPosition:n=>ov(e,t,n),reposition:(n,r)=>dv(e,t,n,r)}:{kind:`plugin`,drop:n=>rv(e,t,n),raise:()=>av(e,t),setRadius:n=>iv(e,t,n),setPosition:n=>ov(e,t,n)}}var pv=K(`<div class="auth-banner svelte-1s059lv" role="status" aria-live="polite">Requesting access as <strong> </strong>. Approve it in Signal K under Security,
756
+ then Access Requests, and this connects on its own. Grant <strong>read and write</strong>:
757
+ routes, waypoints, tracks, course control, alarms, and profiles all save to the server. <a class="btn btn-ghost btn-pill svelte-1s059lv" target="_blank" rel="noopener noreferrer">Approve in Signal K</a></div>`),mv=K(`<div class="auth-banner denied svelte-1s059lv" role="alert">Access was denied. <button type="button" class="btn btn-ghost btn-pill svelte-1s059lv">Request again</button></div>`);function hv(e,t){$e(t,!0);var n=ci(),r=Cn(n),i=e=>{var n=pv(),r=H(V(n)),i=V(r,!0);N(r);var a=H(r,4);N(n),U(()=>{J(i,t.auth.clientId),Z(a,`href`,t.requestsUrl)}),q(e,n)},a=e=>{var n=mv(),r=H(V(n));N(n),G(`click`,r,()=>t.auth.requestAccess()),q(e,n)};Y(r,e=>{t.auth.status===`requesting`?e(i):t.auth.status===`denied`&&e(a,1)}),q(e,n),et()}Qr([`click`]);var gv=`/signalk/v2/api/resources/charts`,_v=`/signalk/v1/api/resources/charts`;function vv(e,t){return bu(e,[gv,_v],t,(e,t)=>t,(e,t)=>console.warn(`[charts] ${e} returned ${t}`))}function yv(e,t,n){return Cu(`${e}${gv}/${encodeURIComponent(n.identifier)}`,t,n)}function bv(e,t,n){return wu(`${e}${gv}/${encodeURIComponent(n)}`,t)}var xv=K(`<div class="svelte-1tsxii8"><dt class="svelte-1tsxii8"> </dt> <dd class="svelte-1tsxii8"> </dd></div>`),Sv=K(`<dl class="spec-list svelte-1tsxii8"></dl>`);function Cv(e,t){var n=Sv();Ei(n,21,()=>t.rows,e=>e.label,(e,t)=>{var n=xv(),r=V(n),i=V(r,!0);N(r);var a=H(r,2),o=V(a,!0);N(a),N(n),U(()=>{J(i,W(t).label),J(o,W(t).value)}),q(e,n)}),N(n),q(e,n)}function wv(e){return{type:{label:`Type`,value:e.kind===`vector`?`Vector`:`Raster`},zoom:{label:`Zoom`,value:sg(e)}}}var Tv=K(`<div class="review svelte-y8hb2y" role="group" aria-label="Review imported chart"><span class="field-label caps-label svelte-y8hb2y">Review and save</span> <label class="name-field svelte-y8hb2y"><span class="caps-label">Name</span> <input class="input" type="text"/></label> <!> <div class="panel-controls"><button type="button" class="btn btn-primary">Save chart</button> <button type="button" class="btn">Cancel</button></div></div>`),Ev=K(`<div class="field svelte-y8hb2y"><span class="field-label caps-label svelte-y8hb2y" id="add-chart-url-label"><!> From a URL</span> <div class="url-row svelte-y8hb2y"><input class="input url svelte-y8hb2y" type="url" placeholder="https://.../chart.pmtiles" aria-labelledby="add-chart-url-label"/> <button type="button" class="btn btn-ghost">Add</button></div> <p class="hint svelte-y8hb2y">For chart files on the server, install the signalk-pmtiles-plugin and drop files in its
758
+ charts folder; they appear here automatically.</p></div>`),Dv=K(`<p class="status svelte-y8hb2y"> </p>`),Ov=K(`<p class="alert-note" role="alert"> </p>`),kv=K(`<button type="button" class="btn btn-ghost">Close</button>`),Av=K(`<div class="add-form svelte-y8hb2y"><!> <!> <!></div>`);function jv(e,t){$e(t,!0);let n=z(``),r=z(!1),i=z(void 0),a=z(void 0),o=z(``),s=R(()=>{if(!W(a))return[];let e=wv(W(a).source);return[e.type,e.zoom,{label:`Stored`,value:`This device, and shared to the server`}]});async function c(e,t){B(r,!0),B(i,void 0);try{await e()}catch(e){B(i,e instanceof Error?e.message:t,!0)}finally{B(r,!1)}}function l(){let e=W(n).trim();e&&c(async()=>{let n=await t.userCharts.stageUrl(e);B(a,n,!0),B(o,n.source.name,!0)},`Could not read that chart.`)}function u(){let e=W(a);e&&c(async()=>{t.userCharts.commit(e,W(o)),B(a,void 0),B(o,``),t.onDone()},`Could not add that chart.`)}function d(){B(a,void 0),B(o,``),B(i,void 0)}var f=Av(),p=V(f),m=e=>{var t=Tv(),n=H(V(t),2),i=H(V(n),2);X(i),Gi(i,e=>Mg?.(e)),Hn(()=>wa(i,()=>W(o),e=>B(o,e))),N(n);var a=H(n,2);Cv(a,{get rows(){return W(s)}});var c=H(a,2),l=V(c),f=H(l,2);N(c),N(t),U(e=>{i.disabled=W(r),l.disabled=e,f.disabled=W(r)},[()=>W(r)||!W(o).trim()]),G(`click`,l,u),G(`click`,f,d),q(e,t)},h=e=>{var t=Ev(),i=V(t);No(V(i),{size:14,"aria-hidden":`true`}),P(),N(i);var a=H(i,2),o=V(a);X(o);var s=H(o,2);N(a),P(2),N(t),U(e=>{o.disabled=W(r),s.disabled=e},[()=>W(r)||!W(n).trim()]),wa(o,()=>W(n),e=>B(n,e)),G(`click`,s,l),q(e,t)};Y(p,e=>{W(a)?e(m):e(h,-1)});var g=H(p,2),_=e=>{var t=Dv(),n=V(t,!0);N(t),U(()=>J(n,W(a)?`Saving chart...`:`Reading chart...`)),q(e,t)},v=e=>{var t=Ov(),n=V(t,!0);N(t),U(()=>J(n,W(i))),q(e,t)};Y(g,e=>{W(r)?e(_):W(i)&&e(v,1)});var y=H(g,2),b=e=>{var n=kv();U(()=>n.disabled=W(r)),G(`click`,n,function(...e){t.onDone?.apply(this,e)}),q(e,n)};Y(y,e=>{W(a)||e(b)}),N(f),q(e,f),et()}Qr([`click`]);var Mv=K(`<label><input type="checkbox" class="svelte-ld9zxu"/> <span class="title svelte-ld9zxu"> </span></label>`);function Nv(e,t){$e(t,!0);let n=Na(t,`disabled`,3,!1);var r=Mv();let i;var a=V(r);X(a);var o=H(a,2),s=V(o,!0);N(o),N(r),U(()=>{i=ta(r,1,`layer-toggle svelte-ld9zxu`,null,i,{disabled:n()}),_a(a,t.visible),a.disabled=n(),Z(o,`title`,t.title),J(s,t.title)}),G(`change`,a,e=>t.onToggle(e.currentTarget.checked)),q(e,r),et()}Qr([`change`]);var Pv=K(`<button type="button" class="icon-btn handle svelte-f54a5u" aria-keyshortcuts="ArrowUp ArrowDown"><!></button>`),Fv=K(`<button type="button" class="icon-btn"><!></button>`),Iv=K(`<div class="opacity-line svelte-f54a5u"><span class="lbl svelte-f54a5u">Opacity</span> <input class="opacity range svelte-f54a5u" type="range" min="0.15" max="1" step="0.05"/> <span class="opacity-val svelte-f54a5u"> </span></div>`),Lv=K(`<div class="facet-line svelte-f54a5u"><!></div>`),Rv=K(`<div class="facet-row svelte-f54a5u"><!> <div class="facet-stack svelte-f54a5u"><div class="facet-line svelte-f54a5u"><!> <!></div> <!> <!></div></div>`),zv=K(`<div class="row-main svelte-f54a5u"><!> <!> <!></div> <!>`,1),Bv=K(`<li><!></li>`);function Vv(e,t){$e(t,!0);let n=e=>{var n=Pv();Do(V(n),{size:18,"aria-hidden":`true`}),N(n),U(()=>Z(n,`aria-label`,`Move ${W(s)}, position ${t.index+1} of ${t.count}`)),G(`pointerdown`,n,function(...e){t.onHandlePointerDown?.apply(this,e)}),G(`keydown`,n,function(...e){t.onHandleKeydown?.apply(this,e)}),q(e,n)},r=e=>{var n=ci(),r=Cn(n),i=e=>{var n=Fv();ss(V(n),{size:18,"aria-hidden":`true`}),N(n),U(()=>Z(n,`aria-label`,`Manage ${t.item.title}`)),G(`click`,n,function(...e){t.onManage?.apply(this,e)}),q(e,n)};Y(r,e=>{t.onManage&&e(i)}),q(e,n)},i=e=>{var n=ci(),r=Cn(n),i=e=>{var n=Iv(),r=H(V(n),2);X(r);var i=H(r,2),a=V(i);N(i),N(n),U(()=>{ga(r,t.item.opacity),Z(r,`aria-label`,`${t.item.title} opacity`),J(a,`${W(o)??``}%`)}),G(`input`,r,e=>t.view.setOpacity(t.item.id,Number(e.currentTarget.value))),q(e,n)};Y(r,e=>{t.item.supportsOpacity&&t.item.visible&&e(i)}),q(e,n)},a=Na(t,`subLayers`,19,()=>[]),o=R(()=>Math.round(t.item.opacity*100)),s=R(()=>t.groupTitle??t.item.title);var c=Bv();let l;var u=V(c),d=e=>{var o=Rv(),s=V(o);n(s);var c=H(s,2),l=V(c),u=V(l);Nv(u,{get title(){return t.item.title},get visible(){return t.item.visible},onToggle:e=>t.view.toggle(t.item.id,e)}),r(H(u,2)),N(l);var d=H(l,2);Ei(d,17,a,e=>e.id,(e,n)=>{var r=Lv(),i=V(r);{let e=R(()=>!t.item.visible);Nv(i,{get title(){return W(n).title},get visible(){return W(n).visible},get disabled(){return W(e)},onToggle:e=>t.view.toggle(W(n).id,e)})}N(r),q(e,r)}),i(H(d,2)),N(c),N(o),q(e,o)},f=e=>{var a=zv(),o=Cn(a),s=V(o);n(s);var c=H(s,2);Nv(c,{get title(){return t.item.title},get visible(){return t.item.visible},onToggle:e=>t.view.toggle(t.item.id,e)}),r(H(c,2)),N(o),i(H(o,2)),q(e,a)};Y(u,e=>{a().length>0?e(d):e(f,-1)}),N(c),U(()=>{l=ta(c,1,`row svelte-f54a5u`,null,l,{dragging:t.dragging,"drop-before":t.dropBefore,"drop-after":t.dropAfter}),Z(c,`aria-label`,t.groupTitle),Z(c,`data-layer-row`,t.item.id)}),q(e,c),et()}Qr([`pointerdown`,`keydown`,`click`,`input`]);var Hv=[{id:`mine`,title:`My routes and tracks`,defaultOpen:!0},{id:`live`,title:`Traffic and live data`,defaultOpen:!0},{id:`nav-aids`,title:`Navigation aids`,defaultOpen:!1},{id:`areas`,title:`Areas and boundaries`,defaultOpen:!1},{id:`ocean`,title:`Ocean conditions`,defaultOpen:!1},{id:`charts`,title:`Charts and depth`,defaultOpen:!1}],Uv=new Set(Hv.map(e=>e.id)),Wv=new Map(Hv.map(e=>[e.id,e.title])),Gv=Hv.map(e=>e.id),Kv=Object.fromEntries(Hv.map(e=>[e.id,e.defaultOpen]));function qv(e){return e.category&&Uv.has(e.category)?e.category:e.band===`basemap`||e.band===`bathymetry`?`charts`:e.band===`weather`?`ocean`:e.band===`traffic`?`live`:`mine`}function Jv(e){let t=qv(e);return{id:t,title:Wv.get(t)??``}}function Yv(e,t,n){let r=e.findIndex(e=>e.id===t);if(r<0)return n;let i=Jv(e[r]).id,a=-1,o=-1,s=0;for(let n of e)n.id!==t&&(Jv(n).id===i&&(a<0&&(a=s),o=s),s++);return a<0?r:Math.max(a,Math.min(n,o+1))}var Xv=K(`<div class="confirm svelte-1shuvj5"><!></div>`),Zv=K(`<button type="button" class="btn btn-danger"><!> Delete chart</button>`),Qv=K(`<div class="detail svelte-1shuvj5"><header class="svelte-1shuvj5"><button type="button" class="icon-btn icon-btn--accent" aria-label="Back to layers"><!></button> <h3 class="panel-title panel-title--sub">Chart detail</h3></header> <label class="name-field svelte-1shuvj5"><span class="caps-label">Name</span> <input class="input" type="text"/></label> <!> <!></div>`);function $v(e,t){$e(t,!0);let n=z(!1),r=z(``),i=R(()=>wv(t.source)),a=R(()=>[W(i).type,{label:`Source`,value:t.source.origin.url},W(i).zoom,{label:`Bounds`,value:s(t.source.bounds)}]);zn(()=>{B(r,t.source.name,!0)});function o(){let e=W(r).trim();e&&e!==t.source.name&&t.userCharts.rename(t.source.id,e)}function s(e){if(!e)return`Unknown`;let t=e=>e.toFixed(2);return`${t(e[1])}, ${t(e[0])} to ${t(e[3])}, ${t(e[2])}`}function c(){let{id:e}=t.source;t.onBack(),t.userCharts.remove(e)}var l=Qv(),u=V(l),d=V(u);Ja(V(d),{size:20,"aria-hidden":`true`}),N(d),P(2),N(u);var f=H(u,2),p=H(V(f),2);X(p),N(f);var m=H(f,2);Cv(m,{get rows(){return W(a)}});var h=H(m,2),g=e=>{var t=Xv();Wg(V(t),{question:`Delete this chart?`,onConfirm:c,onCancel:()=>B(n,!1)}),N(t),q(e,t)},_=e=>{var t=Zv();Ds(V(t),{size:16,"aria-hidden":`true`}),P(),N(t),G(`click`,t,()=>B(n,!0)),q(e,t)};Y(h,e=>{W(n)?e(g):e(_,-1)}),N(l),G(`click`,d,function(...e){t.onBack?.apply(this,e)}),Zr(`blur`,p,o),G(`keydown`,p,e=>{e.key===`Enter`&&e.currentTarget.blur()}),wa(p,()=>W(r),e=>B(r,e)),q(e,l),et()}Qr([`click`,`keydown`]);var ey=K(`<p class="muted-note">No layers</p>`),ty=K(`<li class="pinned-row svelte-1k55jex"><span class="pin svelte-1k55jex" aria-hidden="true"><!></span> <span class="title svelte-1k55jex"> </span> <span class="caps-label">On top</span></li>`),ny=K(`<ul class="pinned-list svelte-1k55jex"></ul>`),ry=K(`<li class="facet-group-label caps-label svelte-1k55jex" aria-hidden="true"> </li>`),iy=K(`<!> <!>`,1),ay=K(`<li class="category svelte-1k55jex"><h3 class="category-head svelte-1k55jex"><button type="button" class="category-toggle svelte-1k55jex"><!> <span class="category-title caps-label svelte-1k55jex"> </span> <span class="category-count svelte-1k55jex" aria-hidden="true"> </span></button></h3> <ul class="category-rows svelte-1k55jex"></ul></li>`),oy=K(`<!> <ul class="rows svelte-1k55jex"></ul>`,1),sy=K(`<button type="button" class="btn"><!> Add a chart</button>`),cy=K(`<div class="add-chart-area svelte-1k55jex"><!></div>`),ly=K(`<div class="visually-hidden" aria-live="polite"> </div> <!>`,1);function uy(e,t){$e(t,!0);let n=R(()=>t.view.items.filter(e=>e.pinned)),r=R(()=>t.view.items.filter(e=>!e.pinned&&!e.parent)),i=R(()=>{let e=new Map;for(let n of t.view.items){if(!n.parent)continue;let t=e.get(n.parent);t?t.push(n):e.set(n.parent,[n])}return e}),a=R(()=>{let e=new Map;return W(r).forEach((t,n)=>{let r=Jv(t),i=e.get(r.id);i?i.rows.push({item:t,i:n}):e.set(r.id,{title:r.title,rows:[{item:t,i:n}]})}),Gv.flatMap(t=>{let n=e.get(t);return n?[{id:t,title:n.title,rows:n.rows}]:[]})});function o(e){return t.categoriesOpen?.value[e]??Kv[e]??!0}function s(e){t.categoriesOpen&&t.categoriesOpen.set({...t.categoriesOpen.value,[e]:!o(e)})}let c=R(()=>new Map((t.userCharts?.sources??[]).map(e=>[bf(e.id),e.id]))),l=z(!1),u=z(void 0),d=R(()=>W(u)?t.userCharts?.sources.find(e=>e.id===W(u)):void 0),f=z(void 0),p=z(null),m=z(null),h=R(()=>W(p)===null?W(r):W(r).filter(e=>e.id!==W(p)));function g(e){return W(r).findIndex(t=>t.id===e)}function _(e){if(W(p)===null||W(m)===null||e===W(p))return{before:!1,after:!1};let t=W(h).findIndex(t=>t.id===e);return t<0?{before:!1,after:!1}:W(m)===W(h).length?{before:!1,after:t===W(h).length-1}:{before:t===W(m),after:!1}}function v(e,n){if(n.button!==0&&n.pointerType===`mouse`)return;n.preventDefault(),B(p,e,!0),B(m,g(e),!0);let i=n.currentTarget;i.setPointerCapture(n.pointerId);let a=()=>W(f)?[...W(f).querySelectorAll(`[data-layer-row]`)].filter(t=>t.dataset.layerRow!==e).map(e=>{let t=e.getBoundingClientRect();return t.top+t.height/2}):[],o=a(),s=t=>{let n=o.length;for(let e=0;e<o.length;e++)if(t<o[e]){n=e;break}return Yv(W(r),e,n)},c=new AbortController,{signal:l}=c;W(f)?.addEventListener(`scroll`,()=>{o=a()},{signal:l,passive:!0});let u=e=>{c.abort(),i.releasePointerCapture(n.pointerId),e&&W(p)!==null&&W(m)!==null&&t.view.reorder(W(p),W(m)),B(p,null),B(m,null)};i.addEventListener(`pointermove`,e=>{B(m,s(e.clientY),!0)},{signal:l}),i.addEventListener(`pointerup`,()=>u(!0),{signal:l}),i.addEventListener(`pointercancel`,()=>u(!1),{signal:l})}let y=z(``);function b(e,n){let i=g(e);if(i<0)return;let a=i;if(n.key===`ArrowUp`)a=i-1;else if(n.key===`ArrowDown`)a=i+1;else return;if(n.preventDefault(),a<0||a>=W(r).length||(a=Yv(W(r),e,a),a===i))return;let o=W(r)[i]?.title??`Layer`;t.view.reorder(e,a),B(y,`Moved ${o} to position ${a+1} of ${W(r).length}.`),requestAnimationFrame(()=>{(W(f)?.querySelector(`[data-layer-row="${CSS.escape(e)}"] .handle`))?.focus()})}{let m=R(()=>W(d)?void 0:t.onBack);i_(e,{title:`Layers and charts`,closeLabel:`Close layers and charts`,get onClose(){return t.onClose},get onBack(){return W(m)},children:(e,m)=>{var h=ly(),g=Cn(h),x=V(g,!0);N(g);var S=H(g,2),C=e=>{var n=ci();xi(Cn(n),()=>W(d).id,e=>{$v(e,{get source(){return W(d)},get userCharts(){return t.userCharts},onBack:()=>B(u,void 0)})}),q(e,n)},w=e=>{var d=iy(),m=Cn(d),h=e=>{q(e,ey())},g=e=>{var l=oy(),d=Cn(l),m=e=>{var t=ny();Ei(t,21,()=>W(n),e=>e.id,(e,t)=>{var n=ty(),r=V(n);qo(V(r),{size:16}),N(r);var i=H(r,2),a=V(i,!0);N(i),P(2),N(n),U(()=>{Z(i,`title`,W(t).title),J(a,W(t).title)}),q(e,n)}),N(t),q(e,t)};Y(d,e=>{W(n).length>0&&e(m)});var h=H(d,2);Ei(h,21,()=>W(a),e=>e.id,(e,n)=>{let a=R(()=>o(W(n).id)),l=R(()=>`layer-cat-${W(n).id}`);var d=ay(),f=V(d),m=V(f),h=V(m);{let e=R(()=>W(a)?`chev chev-open`:`chev`);co(h,{get class(){return W(e)},size:16,"aria-hidden":`true`})}var g=H(h,2),y=V(g,!0);N(g);var x=H(g,2),S=V(x,!0);N(x),N(m),N(f);var C=H(f,2);Ei(C,23,()=>W(n).rows,({item:e,i:t})=>e.id,(e,a,o)=>{let s=()=>W(a).item,l=()=>W(a).i,d=R(()=>_(s().id)),f=R(()=>W(c).get(s().id)),m=R(()=>W(n).rows[W(o)-1]?.item);var h=iy(),g=Cn(h),y=e=>{var t=ry(),n=V(t,!0);N(t),U(()=>J(n,s().group.title)),q(e,t)};Y(g,e=>{s().group&&s().group.id!==W(m)?.group?.id&&e(y)});var x=H(g,2);{let e=R(()=>s().group?.title),n=R(()=>W(i).get(s().id)??[]),a=R(()=>W(p)===s().id),o=R(()=>W(f)?()=>B(u,W(f),!0):void 0);Vv(x,{get item(){return s()},get view(){return t.view},get index(){return l()},get count(){return W(r).length},get groupTitle(){return W(e)},get subLayers(){return W(n)},get dragging(){return W(a)},get dropBefore(){return W(d).before},get dropAfter(){return W(d).after},onHandlePointerDown:e=>v(s().id,e),onHandleKeydown:e=>b(s().id,e),get onManage(){return W(o)}})}q(e,h)}),N(C),N(d),U(()=>{Z(m,`aria-expanded`,W(a)),Z(m,`aria-controls`,W(l)),J(y,W(n).title),J(S,W(n).rows.length),Z(C,`id`,W(l)),Z(C,`hidden`,!W(a))}),G(`click`,m,()=>s(W(n).id)),q(e,d)}),N(h),Oa(h,e=>B(f,e),()=>W(f)),q(e,l)};Y(m,e=>{t.view.items.length===0?e(h):e(g,-1)});var y=H(m,2),x=e=>{var n=cy(),r=V(n),i=e=>{jv(e,{get userCharts(){return t.userCharts},onDone:()=>B(l,!1)})},a=e=>{var t=sy();Zo(V(t),{size:16,"aria-hidden":`true`}),P(),N(t),G(`click`,t,()=>B(l,!0)),q(e,t)};Y(r,e=>{W(l)?e(i):e(a,-1)}),N(n),q(e,n)};Y(y,e=>{t.userCharts&&e(x)}),q(e,d)};Y(S,e=>{W(d)&&t.userCharts?e(C):e(w,-1)}),U(()=>J(x,W(y))),q(e,h)},$$slots:{default:!0}})}et()}Qr([`click`]);var dy=class{#e=z(fn([]));get items(){return W(this.#e)}set items(e){B(this.#e,e,!0)}#t;constructor(e){this.#t=e}refresh(){this.items=this.#t.layers()}toggle(e,t){this.#t.toggle(e,t),this.refresh()}setOpacity(e,t){this.#t.setOpacity(e,t);let n=this.items.find(t=>t.id===e);n&&(n.opacity=t)}reorder(e,t){let n=this.items.filter(e=>!e.pinned&&!e.parent);this.#t.reorder(e,Yv(n,e,t)),this.refresh()}};function fy(e){if(e.dangerCpaMeters===0||e.dangerTcpaSeconds===0)return`A danger threshold of 0 disables the danger alarm.`;if(e.dangerCpaMeters>e.warningCpaMeters||e.dangerTcpaSeconds>e.warningTcpaSeconds)return`Danger thresholds usually sit at or inside the warning thresholds; check these values.`}var py=K(`<p class="alert-note" role="alert"> </p>`),my=K(`<span class="alert-time svelte-1epvc8d"> </span>`),hy=K(`<span class="flag-tag svelte-1epvc8d">Silenced</span>`),gy=K(`<button type="button" class="btn btn-ghost">Silence</button>`),_y=K(`<span class="flag-tag svelte-1epvc8d">Acknowledged</span>`),vy=K(`<button type="button" class="btn btn-ghost">Acknowledge</button>`),yy=K(`<div class="alert-row svelte-1epvc8d"><span> </span> <div class="alert-main svelte-1epvc8d"><span class="alert-message svelte-1epvc8d"> </span> <!></div> <div class="alert-actions svelte-1epvc8d"><!> <!></div></div>`),by=K(`<p class="muted-note">No active alerts.</p>`),xy=K(`<p class="muted-note"> </p>`),Sy=K(`<p class="muted-note caution-note svelte-1epvc8d" role="status"> </p>`),Cy=K(`<div class="alarms svelte-1epvc8d"><!> <section class="alerts svelte-1epvc8d" aria-label="Active alerts"><span class="caps-label">Active alerts</span> <!></section> <section class="mutes svelte-1epvc8d" aria-label="Mutes"><span class="caps-label">Mutes</span> <button type="button"><!> <span>Mute collision alarm</span></button> <!> <button type="button"><!> <span>Mute arrival alarm</span></button></section> <section class="thresholds svelte-1epvc8d" aria-label="Collision thresholds"><span class="caps-label">Collision thresholds</span> <div class="group svelte-1epvc8d"><span class="group-title caps-label danger svelte-1epvc8d">Danger</span> <!> <!></div> <div class="group svelte-1epvc8d"><span class="group-title caps-label warning svelte-1epvc8d">Warning</span> <!> <!></div> <!> <button type="button" class="btn btn-ghost reset svelte-1epvc8d">Reset to defaults</button></section></div>`);function wy(e,t){$e(t,!0);let n=R(()=>t.thresholds.value),r=R(()=>t.notifications.list()),i=e=>e.message||e.path.replace(/^notifications\./,``),a=e=>{let t=e.timestamp?Date.parse(e.timestamp):NaN;return Number.isFinite(t)?Cl(t):void 0},o=e=>e.id!==void 0&&e.state!==`emergency`&&e.canSilence!==!1&&!e.silenced&&!e.acknowledged,s=e=>e.id!==void 0&&e.canAcknowledge!==!1&&!e.acknowledged;function c(e,n){!Number.isFinite(n)||n<0||t.thresholds.set({...t.thresholds.value,[e]:Uc(n)})}function l(e,n){!Number.isFinite(n)||n<0||t.thresholds.set({...t.thresholds.value,[e]:n*60})}let u=e=>Number(hl(e)),d=e=>Number(gl(e)),f=R(()=>fy(W(n)));i_(e,{title:`Alarms`,closeLabel:`Close alarms panel`,get onClose(){return t.onClose},get onBack(){return t.onBack},children:(e,p)=>{var m=Cy(),h=V(m),g=e=>{var n=py(),r=V(n,!0);N(n),U(()=>J(r,t.error)),q(e,n)};Y(h,e=>{t.error&&e(g)});var _=H(h,2);Ei(H(V(_),2),17,()=>W(r),e=>e.path,(e,n)=>{let r=R(()=>a(W(n)));var c=yy(),l=V(c),u=V(l,!0);N(l);var d=H(l,2),f=V(d),p=V(f,!0);N(f);var m=H(f,2),h=e=>{var t=my(),n=V(t,!0);N(t),U(()=>J(n,W(r))),q(e,t)};Y(m,e=>{W(r)&&e(h)}),N(d);var g=H(d,2),_=V(g),v=e=>{q(e,hy())},y=e=>{var r=gy();G(`click`,r,()=>t.onSilence(W(n))),q(e,r)},b=R(()=>t.onSilence&&o(W(n)));Y(_,e=>{W(n).silenced?e(v):W(b)&&e(y,1)});var x=H(_,2),S=e=>{q(e,_y())},C=e=>{var r=vy();G(`click`,r,()=>t.onAcknowledge(W(n))),q(e,r)},w=R(()=>t.onAcknowledge&&s(W(n)));Y(x,e=>{W(n).acknowledged?e(S):W(w)&&e(C,1)}),N(g),N(c),U(e=>{ta(l,1,`state-tag ${W(n).state??``}`,`svelte-1epvc8d`),J(u,W(n).state),J(p,e)},[()=>i(W(n))]),q(e,c)},e=>{q(e,by())}),N(_);var v=H(_,2),y=H(V(v),2);let b;var x=V(y),S=e=>{Xa(e,{size:18,"aria-hidden":`true`})},C=e=>{Qa(e,{size:18,"aria-hidden":`true`})};Y(x,e=>{t.collisionMuted?e(S):e(C,-1)}),P(2),N(y);var w=H(y,2),T=e=>{var n=xy(),r=V(n);N(n),U(()=>J(r,`Auto re-arms in ${t.collisionMuteRemainingMin??``} min`)),q(e,n)};Y(w,e=>{t.collisionMuted&&t.collisionMuteRemainingMin!==void 0&&e(T)});var E=H(w,2);let D;var O=V(E),k=e=>{Xa(e,{size:18,"aria-hidden":`true`})},A=e=>{Qa(e,{size:18,"aria-hidden":`true`})};Y(O,e=>{t.arrivalMuted?e(k):e(A,-1)}),P(2),N(E),N(v);var ee=H(v,2),te=H(V(ee),2),j=H(V(te),2);{let e=R(()=>u(W(n).dangerCpaMeters));m_(j,{label:`CPA`,unit:`nm`,min:0,step:.05,ariaLabel:`Danger CPA`,get value(){return W(e)},onCommit:e=>c(`dangerCpaMeters`,e)})}var ne=H(j,2);{let e=R(()=>d(W(n).dangerTcpaSeconds));m_(ne,{label:`TCPA`,unit:`min`,min:0,step:1,ariaLabel:`Danger TCPA`,get value(){return W(e)},onCommit:e=>l(`dangerTcpaSeconds`,e)})}N(te);var re=H(te,2),ie=H(V(re),2);{let e=R(()=>u(W(n).warningCpaMeters));m_(ie,{label:`CPA`,unit:`nm`,min:0,step:.05,ariaLabel:`Warning CPA`,get value(){return W(e)},onCommit:e=>c(`warningCpaMeters`,e)})}var ae=H(ie,2);{let e=R(()=>d(W(n).warningTcpaSeconds));m_(ae,{label:`TCPA`,unit:`min`,min:0,step:1,ariaLabel:`Warning TCPA`,get value(){return W(e)},onCommit:e=>l(`warningTcpaSeconds`,e)})}N(re);var oe=H(re,2),se=e=>{var t=Sy(),n=V(t,!0);N(t),U(()=>J(n,W(f))),q(e,t)};Y(oe,e=>{W(f)&&e(se)});var ce=H(oe,2);N(ee),N(m),U(()=>{b=ta(y,1,`btn mute-row svelte-1epvc8d`,null,b,{"is-on":t.collisionMuted}),Z(y,`aria-pressed`,t.collisionMuted),D=ta(E,1,`btn mute-row svelte-1epvc8d`,null,D,{"is-on":t.arrivalMuted}),Z(E,`aria-pressed`,t.arrivalMuted)}),G(`click`,y,function(...e){t.onToggleCollisionMute?.apply(this,e)}),G(`click`,E,function(...e){t.onToggleArrivalMute?.apply(this,e)}),G(`click`,ce,()=>t.thresholds.set({...Nl})),q(e,m)},$$slots:{default:!0}}),et()}Qr([`click`]);var Ty=10*kc,Ey=class{#e;#t;#n=z(0);constructor(e,t=Ty){this.#e=e,this.#t=t}get active(){return this.#e.now<W(this.#n)}get remainingMs(){return Math.max(0,W(this.#n)-this.#e.now)}mute(){B(this.#n,this.#e.now+this.#t)}unmute(){B(this.#n,0)}toggle(){this.active?this.unmute():this.mute()}},Dy=`notifications.navigation.collision`;function Oy(e){let t=e.contacts[0];if(!t)return{state:`normal`,method:[],message:`No collision risk`};let n=sd(t.name,t.id),r=hl(t.cpaMeters),i=gl(t.tcpaSeconds),a=e.worst===`danger`;return{state:a?`alarm`:`warn`,method:a?[`visual`,`sound`]:[`visual`],message:`Collision ${e.worst}: ${n} CPA ${r} nm, TCPA ${i} min`}}var ky=class{#e;#t;#n=!1;constructor(e){this.#e=(t,n)=>e.publish(t,n)}update(e){let t=Oy(e),n=e.contacts[0],r=t.state;if(n){let e=Math.round(n.cpaMeters/100),i=Math.round(n.tcpaSeconds/60);r=`${t.state}|${n.id}|${e}|${i}`}r!==this.#t&&(this.#t=r,!(t.state===`normal`&&!this.#n)&&(this.#n=t.state!==`normal`,this.#e(Dy,t)))}},Ay=`binnacle-collision`,jy=`binnacle-collision-ring`,My={danger:20,warning:16},Ny={danger:3,warning:2},Py=`collision`;function Fy(e){return Km(e.map(e=>({type:`Feature`,geometry:{type:`Point`,coordinates:[e.position.longitude,e.position.latitude]},properties:{severity:e.severity}})))}function Iy(e){return[`match`,[`get`,`severity`],`danger`,e.danger,`warning`,e.warning,e.warning]}function Ly(e){let t;return{id:Py,title:`Collision risk`,band:`safety`,supportsOpacity:!1,layerIds:[jy],add(n){t=void 0;let r=e.assessment.contacts;if(!n.map.getSource(Ay)){let e={type:`geojson`,data:Fy(r)};n.map.addSource(Ay,e)}if(!n.map.getLayer(jy)){let e={id:jy,type:`circle`,source:Ay,paint:{"circle-radius":[`match`,[`get`,`severity`],`danger`,My.danger,`warning`,My.warning,My.warning],"circle-color":`rgba(0, 0, 0, 0)`,"circle-stroke-width":[`match`,[`get`,`severity`],`danger`,Ny.danger,`warning`,Ny.warning,Ny.warning],"circle-stroke-color":Iy(hf(`day`))}};n.map.addLayer(e,n.beforeIdFor(`safety`))}t=r},sync(n){let r=e.assessment.contacts;r!==t&&(t=r,n.map.getSource(Ay)?.setData(Fy(r)))},applyTheme(e,t){e.map.setPaintProperty(jy,`circle-stroke-color`,Iy(t))},setVisible(e,t){Pf(e.map,[jy],t)},remove(e){Ff(e.map,[jy],[Ay])}}}var Ry=K(`<span class="note ack-tag">Acknowledged</span>`),zy=K(`<span class="note">computing locally</span>`),By=K(`<div class="actions actions--safety"><button type="button" class="ack svelte-1xtn712">Mute</button> <button type="button" class="ack">Acknowledge</button></div>`),Vy=K(`<li><span class="name svelte-1xtn712"> </span> <span class="metric">CPA <b> </b> nm</span> <span class="metric">TCPA <b> </b> min</span></li>`),Hy=K(`<p class="more svelte-1xtn712"> </p>`),Uy=K(`<aside><div class="head"><span class="title"> </span> <!> <!> <!></div> <ul class="list svelte-1xtn712"></ul> <!></aside>`);function Wy(e,t){$e(t,!0);let n=R(()=>t.collision.assessment.contacts),r=R(()=>W(n).slice(0,4)),i=R(()=>Math.max(0,W(n).length-4)),a=R(()=>W(n).some(e=>e.source===`computed`)),o=R(()=>W(n)[0]?.severity===`danger`),s=R(()=>t.collision.suppressed&&!t.collision.escalating);var c=ci(),l=Cn(c),u=e=>{var n=Uy();let c;var l=V(n),u=V(l),d=V(u,!0);N(u);var f=H(u,2),p=e=>{q(e,Ry())};Y(f,e=>{W(s)&&e(p)});var m=H(f,2),h=e=>{q(e,zy())};Y(m,e=>{W(a)&&e(h)});var g=H(m,2),_=e=>{var n=By(),r=V(n),i=H(r,2);N(n),U(()=>Z(r,`aria-pressed`,t.muted)),G(`click`,r,function(...e){t.onToggleMute?.apply(this,e)}),G(`click`,i,()=>t.collision.acknowledge()),q(e,n)};Y(g,e=>{W(s)||e(_)}),N(l);var v=H(l,2);Ei(v,21,()=>W(r),e=>e.id,(e,t)=>{var n=Vy(),r=V(n),i=V(r,!0);N(r);var a=H(r,2),o=H(V(a)),s=V(o,!0);N(o),P(),N(a);var c=H(a,2),l=H(V(c)),u=V(l,!0);N(l),P(),N(c),N(n),U((e,r,a)=>{ta(n,1,`row ${W(t).severity??``}`,`svelte-1xtn712`),J(i,e),J(s,r),J(u,a)},[()=>sd(W(t).name,W(t).id),()=>hl(W(t).cpaMeters),()=>gl(W(t).tcpaSeconds,1)]),q(e,n)}),N(v);var y=H(v,2),b=e=>{var t=Hy(),n=V(t);N(t),U(()=>J(n,`+${W(i)??``} more`)),q(e,t)};Y(y,e=>{W(i)>0&&e(b)}),N(n),U(()=>{c=ta(n,1,`bottom-strip ${W(o)?`bottom-strip--alarm`:`bottom-strip--warning`}`,`svelte-1xtn712`,c,{"is-ack":W(s)}),Z(n,`aria-label`,W(o)?`Collision danger`:`Collision warning`),J(d,W(o)?`Danger`:`Caution`)}),q(e,n)};Y(l,e=>{W(n).length>0&&e(u)}),q(e,c),et()}Qr([`click`]);var Gy={frequency:880,beepMs:140,gapMs:90,beeps:2,periodMs:1200,volume:.18};function Ky(){if(typeof window>`u`)return;let e=window.AudioContext??window.webkitAudioContext;return e?new e:void 0}var qy=class{#e;#t;#n;#r=!1;prime(){let e=this.#i();e&&e.state===`suspended`&&e.resume()}start(e){if(this.#t!==void 0&&this.#n?.frequency===e.frequency&&this.#n?.periodMs===e.periodMs)return;this.stop();let t=this.#i();if(!t){this.#r||=(console.warn(`Audible alarm unavailable: no Web Audio context; alerts remain visual only.`),!0);return}t.state===`suspended`&&t.resume(),this.#n=e,this.#a(t,e),this.#t=setInterval(()=>this.#a(t,e),e.periodMs)}stop(){this.#t!==void 0&&clearInterval(this.#t),this.#t=void 0,this.#n=void 0}#i(){return this.#e||=Ky(),this.#e}#a(e,t){e.state===`suspended`&&e.resume();let n=(t.beepMs+t.gapMs)/1e3;for(let r=0;r<t.beeps;r+=1)this.#o(e,t,e.currentTime+r*n)}#o(e,t,n){let r=e.createOscillator(),i=e.createGain();r.type=`square`,r.frequency.value=t.frequency;let a=t.beepMs/1e3;i.gain.setValueAtTime(0,n),i.gain.linearRampToValueAtTime(t.volume,n+.012),i.gain.setValueAtTime(t.volume,n+a-.02),i.gain.linearRampToValueAtTime(0,n+a),r.connect(i).connect(e.destination),r.start(n),r.stop(n+a)}},Jy=class{#e;#t;#n=!1;constructor(e,t=new qy){this.#t=e,this.#e=t}prime(){this.#e.prime()}update(e){e!==this.#n&&(this.#n=e,e?this.#e.start(this.#t):this.#e.stop())}stop(){this.#n=!1,this.#e.stop()}},Yy=class{#e;constructor(e){this.#e=new Jy(Gy,e)}prime(){this.#e.prime()}update(e,t,n,r=!1,i=!1){this.#e.update(e===`danger`&&(r||!t&&!n&&!i))}stop(){this.#e.stop()}},Xy=K(`<span class="note">Tap the chart to set points</span>`),Zy=K(`<span class="metric">Total <b> </b></span>`),Qy=K(`<div class="row"><span class="metric">Leg <b> </b></span> <span class="metric">Bearing <b> </b>&deg;T</span> <!></div>`),$y=K(`<aside class="bottom-strip bottom-strip--accent" aria-label="Measure"><div class="head"><span class="title">Measure</span> <!> <div class="actions"><button type="button" class="ack">Undo</button> <button type="button" class="ack">Clear</button> <button type="button" class="ack">Done</button></div></div> <!></aside>`);function eb(e,t){$e(t,!0),zn(()=>{if(t.measure.active)return Ag(()=>t.measure.stop())});var n=ci(),r=Cn(n),i=e=>{var n=$y(),r=V(n),i=H(V(r),2),a=e=>{q(e,Xy())};Y(i,e=>{t.measure.points.length===0&&e(a)});var o=H(i,2),s=V(o),c=H(s,2),l=H(c,2);N(o),N(r);var u=H(r,2),d=e=>{var n=Qy(),r=V(n),i=H(V(r)),a=V(i,!0);N(i),N(r);var o=H(r,2),s=H(V(o)),c=V(s,!0);N(s),P(),N(o);var l=H(o,2),u=e=>{var n=Zy(),r=H(V(n)),i=V(r,!0);N(r),N(n),U(e=>J(i,e),[()=>ml(t.measure.totalMeters,t.units.mode)]),q(e,n)};Y(l,e=>{t.measure.legs.length>1&&e(u)}),N(n),U((e,t)=>{J(a,e),J(c,t)},[()=>ml(t.measure.lastLeg.distanceMeters,t.units.mode),()=>Bc(t.measure.lastLeg.bearingRad)]),q(e,n)};Y(u,e=>{t.measure.lastLeg&&e(d)}),N(n),U(()=>{s.disabled=t.measure.points.length===0,c.disabled=t.measure.points.length===0}),G(`click`,s,()=>t.measure.undo()),G(`click`,c,()=>t.measure.clear()),G(`click`,l,()=>t.measure.stop()),q(e,n)};Y(r,e=>{t.measure.active&&e(i)}),q(e,n),et()}Qr([`click`]);var tb=`binnacle-measure`,nb=`binnacle-measure-line`,rb=`binnacle-measure-vertex`,ib=`binnacle-measure-label`,ab=[nb,rb,ib];function ob(e,t){let n=e.points;if(n.length===0)return Gm();let r=n.map(e=>[e.longitude,e.latitude]),i=r.map((n,i)=>({type:`Feature`,geometry:{type:`Point`,coordinates:n},properties:i===r.length-1&&r.length>1?{label:ml(e.totalMeters,t)}:{}}));return r.length>1&&i.push({type:`Feature`,geometry:{type:`LineString`,coordinates:r},properties:{line:!0}}),{type:`FeatureCollection`,features:i}}function sb(e,t){let n=hf(`day`),r,i;return{id:`measure`,title:`Measure`,band:`routes`,supportsOpacity:!0,layerIds:ab,add(e){let{map:t}=e,i=e.beforeIdFor(`routes`);if(!t.getSource(tb)){let e={type:`geojson`,data:Gm()};t.addSource(tb,e)}if(!t.getLayer(nb)){let e={id:nb,type:`line`,source:tb,filter:[`has`,`line`],layout:{"line-cap":`round`,"line-join":`round`},paint:{"line-color":n.select,"line-width":2,"line-dasharray":[2,2]}};t.addLayer(e,i)}if(!t.getLayer(rb)){let e={id:rb,type:`circle`,source:tb,filter:[`!`,[`has`,`line`]],paint:{"circle-radius":5,"circle-color":n.select,"circle-stroke-color":n.markerGlyph,"circle-stroke-width":1.5}};t.addLayer(e,i)}if(!t.getLayer(ib)){let e={id:ib,type:`symbol`,source:tb,filter:[`has`,`label`],layout:{"text-field":[`get`,`label`],"text-font":[`Noto Sans Regular`],"text-size":12,"text-offset":[0,1.3],"text-optional":!0},paint:{"text-color":n.select,"text-halo-color":n.background,"text-halo-width":1.5}};t.addLayer(e,i)}r=void 0},sync(n){let a=e.points,o=t.mode;a===r&&o===i||(r=a,i=o,n.map.getSource(tb)?.setData(ob(e,o)))},setVisible(e,t){Pf(e.map,ab,t)},setOpacity(e,t){e.map.setPaintProperty(nb,`line-opacity`,t),e.map.setPaintProperty(rb,`circle-opacity`,t),e.map.setPaintProperty(rb,`circle-stroke-opacity`,t),e.map.setPaintProperty(ib,`text-opacity`,t)},applyTheme(e,t){n=t,e.map.setPaintProperty(nb,`line-color`,n.select),e.map.setPaintProperty(rb,`circle-color`,n.select),e.map.setPaintProperty(rb,`circle-stroke-color`,n.markerGlyph),e.map.setPaintProperty(ib,`text-color`,n.select),e.map.setPaintProperty(ib,`text-halo-color`,n.background)},remove(e){Ff(e.map,ab,[tb])}}}var cb=K(`<span class="muted-note">No options</span>`),lb=K(`<div class="group-label caps-label svelte-1xvdgg7" aria-hidden="true"> </div>`),ub=K(`<button type="button"><!> <span class="tile-label svelte-1xvdgg7"> </span></button>`),db=K(`<section class="group svelte-1xvdgg7" role="group"><!> <div class="tiles svelte-1xvdgg7"></div></section>`),fb=K(`<button type="button" aria-haspopup="dialog"><!></button> <!>`,1);function pb(e,t){$e(t,!0);let n=Na(t,`items`,19,()=>[]),r=Na(t,`label`,3,`Menu`),i=z(void 0),a=z(void 0),o=R(()=>{let e=[];for(let t of n()){let n=t.group??``,r=e.at(-1);r&&r.label===n?r.items.push(t):e.push({label:n,items:[t]})}return e});function s(e=!1){t.onOpenChange(!1),e&&W(i)?.focus()}function c(e){e.disabled||(e.onSelect(),s(!0))}zn(()=>{t.open&&W(a)?.querySelector(`.tile:not([disabled])`)?.focus()});function l(e){if(Ng(e)){e.preventDefault(),s(!0);return}let t=[...W(a)?.querySelectorAll(`.tile:not([disabled])`)??[]];if(t.length===0)return;let n=Math.max(0,t.indexOf(document.activeElement));e.key===`ArrowRight`||e.key===`ArrowDown`?(e.preventDefault(),t[(n+1)%t.length]?.focus()):e.key===`ArrowLeft`||e.key===`ArrowUp`?(e.preventDefault(),t[(n-1+t.length)%t.length]?.focus()):e.key===`Home`?(e.preventDefault(),t[0]?.focus()):e.key===`End`&&(e.preventDefault(),t.at(-1)?.focus())}var u=fb(),d=Cn(u);let f;zo(V(d),{size:20,"aria-hidden":`true`}),N(d),Oa(d,e=>B(i,e),()=>W(i)),zg(H(d,2),{get open(){return t.open},onClose:()=>s(!0),backdropLabel:`Close menu`,surfaceClass:`launcher`,get ariaLabel(){return r()},id:`app-menu-launcher`,onKeydown:l,get surfaceRef(){return W(a)},set surfaceRef(e){B(a,e,!0)},children:e=>{var t=ci(),r=Cn(t),i=e=>{q(e,cb())},a=e=>{var t=ci();Ei(Cn(t),17,()=>W(o),Si,(e,t)=>{var n=db(),r=V(n),i=e=>{var n=lb(),r=V(n,!0);N(n),U(()=>J(r,W(t).label)),q(e,n)};Y(r,e=>{W(t).label&&e(i)});var a=H(r,2);Ei(a,21,()=>W(t).items,e=>e.id,(e,t)=>{var n=ub();let r;var i=V(n),a=e=>{let n=R(()=>W(t).icon);var r=ci();Ni(Cn(r),()=>W(n),(e,t)=>{t(e,{size:22,"aria-hidden":`true`})}),q(e,r)};Y(i,e=>{W(t).icon&&e(a)});var o=H(i,2),s=V(o,!0);N(o),N(n),U(()=>{r=ta(n,1,`tile svelte-1xvdgg7`,null,r,{"is-on":W(t).pressed===!0}),Z(n,`aria-pressed`,W(t).pressed===void 0?void 0:W(t).pressed),n.disabled=W(t).disabled,J(s,W(t).label)}),G(`click`,n,()=>c(W(t))),q(e,n)}),N(a),N(n),U(()=>Z(n,`aria-label`,W(t).label||void 0)),q(e,n)}),q(e,t)};Y(r,e=>{n().length===0?e(i):e(a,-1)}),q(e,t)},$$slots:{default:!0}}),U(()=>{f=ta(d,1,`icon-pill`,null,f,{"is-on":t.open}),Z(d,`aria-expanded`,t.open),Z(d,`aria-controls`,t.open?`app-menu-launcher`:void 0),Z(d,`aria-label`,r()),Z(d,`title`,r())}),G(`click`,d,()=>t.onOpenChange(!t.open)),q(e,u),et()}Qr([`click`]);var mb=K(`<p class="fix svelte-kue2a4" aria-hidden="true"> <br/> </p>`),hb=K(`<p class="fix no-fix svelte-kue2a4">No GPS fix. The alarm will sound without a position.</p>`),gb=K(`<div class="mob-modal svelte-kue2a4"><div class="mob-dialog svelte-kue2a4" role="alertdialog" aria-modal="true" aria-labelledby="mob-confirm-title" aria-describedby="mob-confirm-desc"><header class="head svelte-kue2a4"><!> <h2 id="mob-confirm-title" class="svelte-kue2a4">Man overboard</h2></header> <p id="mob-confirm-desc" class="desc svelte-kue2a4">Marks the spot where MOB was pressed and sounds the alarm on every station.</p> <!> <div class="actions svelte-kue2a4"><button type="button" class="btn svelte-kue2a4">Cancel <span aria-hidden="true"> </span></button> <button type="button" class="btn confirm svelte-kue2a4"><!> Mark man overboard</button></div></div></div>`);function _b(e,t){$e(t,!0);let n=z(15);Pa(()=>{let e=setInterval(()=>{B(n,W(n)-1),W(n)<=0&&t.onTimeout()},1e3);return()=>clearInterval(e)});function r(){navigator.vibrate?.(200),t.onConfirm()}var i=gb(),a=V(i),o=V(a);jo(V(o),{size:28,"aria-hidden":`true`}),P(2),N(o);var s=H(o,4),c=e=>{var n=mb(),r=V(n),i=H(r,2);N(n),U((e,t,n)=>{J(r,`Captured ${e??``}`),J(i,` ${t??``} ${n??``}`)},[()=>Cl(t.mark.epochMs,{seconds:!0}),()=>uc(t.mark.position.latitude),()=>dc(t.mark.position.longitude)]),q(e,n)},l=e=>{q(e,hb())};Y(s,e=>{t.mark?.position?e(c):e(l,-1)});var u=H(s,2),d=V(u),f=H(V(d)),p=V(f);N(f),N(d);var m=H(d,2);jo(V(m),{size:20,"aria-hidden":`true`}),P(),N(m),Gi(m,e=>Mg?.(e)),N(u),N(a),Gi(a,(e,t)=>jg?.(e,t),()=>t.onCancel),Gi(a,e=>Lg?.(e)),N(i),U(()=>J(p,`(${W(n)??``}s)`)),G(`click`,d,function(...e){t.onCancel?.apply(this,e)}),G(`click`,m,r),q(e,i),et()}Qr([`click`]);var vb=K(`<button type="button"><!> MOB</button> <!>`,1);function yb(e,t){$e(t,!0);let n=z(!1),r=z(void 0),i=kc;function a(){let e=t.mob.position;if(e){t.onLocate(e);return}let a=W(r)?.position?t.mob.captureAgeMs(W(r)):void 0;(a===void 0||a>=i)&&B(r,t.mob.capture(),!0),B(n,!0)}function o(){B(n,!1),t.onTrigger(W(r)),B(r,void 0)}function s(){B(n,!1),B(r,void 0)}function c(){B(n,!1),W(r)?.position||B(r,void 0)}var l=vb(),u=Cn(l);let d;jo(V(u),{size:16,"aria-hidden":`true`}),P(),N(u);var f=H(u,2),p=e=>{_b(e,{get mark(){return W(r)},onConfirm:o,onCancel:s,onTimeout:c})};Y(f,e=>{W(n)&&e(p)}),U(()=>{d=ta(u,1,`btn btn-pill mob-btn svelte-1nkawfk`,null,d,{"is-on":t.mob.active}),Z(u,`aria-pressed`,t.mob.active),Z(u,`aria-haspopup`,t.mob.position?void 0:`dialog`),Z(u,`aria-label`,t.mob.position?`Fly to the man overboard mark`:`Mark man overboard here`),Z(u,`title`,t.mob.position?`Fly to the MOB mark`:`Mark man overboard at the boat position (asks to confirm)`)}),G(`click`,u,a),q(e,l),et()}Qr([`click`]);function bb(e){let t=Math.floor(e),n=(t%60).toString().padStart(2,`0`),r=Math.floor(t/60)%60,i=Math.floor(t/3600);return i>0?`${i}:${r.toString().padStart(2,`0`)}:${n}`:`${r}:${n}`}var xb=K(`<span class="note ack-tag">Acknowledged</span>`),Sb=K(`<button type="button" class="ack">Acknowledge</button>`),Cb=K(`<span class="metric">Elapsed <b> </b></span>`),wb=K(`<span class="metric">Marked <b> </b></span>`),Tb=K(`<aside class="bottom-strip bottom-strip--alarm" aria-label="Man overboard"><div class="head"><span class="title">Man overboard</span> <!> <div class="actions"><button type="button" class="ack">Steer to MOB</button> <!> <button type="button" class="ack ack--warning"> </button></div></div> <div class="row"><span class="metric">Bearing <b> </b>&deg;T</span> <span class="metric">Range <b> </b></span> <!> <!></div></aside>`);function Eb(e,t){$e(t,!0);let n=new Vg;Fa(()=>n.disarm());function r(){n.tap()&&t.onCancel()}var i=ci(),a=Cn(i),o=e=>{var i=Tb(),a=V(i),o=H(V(a),2),s=e=>{q(e,xb())};Y(o,e=>{t.mob.acknowledged&&e(s)});var c=H(o,2),l=V(c),u=H(l,2),d=e=>{var n=Sb();G(`click`,n,()=>t.mob.acknowledge()),q(e,n)};Y(u,e=>{t.mob.acknowledged||e(d)});var f=H(u,2),p=V(f,!0);N(f),N(c),N(a);var m=H(a,2),h=V(m),g=H(V(h)),_=V(g,!0);N(g),P(),N(h);var v=H(h,2),y=H(V(v)),b=V(y,!0);N(y),N(v);var x=H(v,2),S=e=>{var n=Cb(),r=H(V(n)),i=V(r,!0);N(r),N(n),U(e=>J(i,e),[()=>bb(t.mob.elapsedSeconds)]),q(e,n)};Y(x,e=>{t.mob.elapsedSeconds!==void 0&&e(S)});var C=H(x,2),w=e=>{var n=wb(),r=H(V(n)),i=V(r,!0);N(r),N(n),U(e=>J(i,e),[()=>Cl(t.mob.markEpochMs,{seconds:!0})]),q(e,n)};Y(C,e=>{t.mob.markEpochMs!==void 0&&e(w)}),N(m),N(i),U((e,r)=>{l.disabled=!t.mob.position,J(p,n.armed?`Confirm cancel?`:`Cancel`),J(_,e),J(b,r)},[()=>Bc(t.mob.bearingRad),()=>ml(t.mob.distanceMeters,t.units.mode)]),G(`click`,l,function(...e){t.onSteer?.apply(this,e)}),G(`click`,f,r),q(e,i)};Y(a,e=>{t.mob.active&&e(o)}),q(e,i),et()}Qr([`click`]);var Db={frequency:950,beepMs:120,gapMs:80,beeps:4,periodMs:1100,volume:.2};function Ob(e){return{state:`emergency`,method:[`visual`,`sound`],message:e?`Man overboard at ${uc(e.latitude)} ${dc(e.longitude)}`:`Man overboard, no position fix`,...e?{position:e}:{}}}function kb(){return{state:`normal`,method:[],message:`Man overboard cleared`}}var Ab=`binnacle-mob`,jb=`binnacle-mob-line`,Mb=`binnacle-mob-marker`,Nb=`binnacle-mob-label`,Pb=[jb,Mb,Nb];function Fb(e,t){if(!e)return Gm();let n=[{type:`Feature`,geometry:{type:`Point`,coordinates:[e.longitude,e.latitude]},properties:{}}];return t&&n.push({type:`Feature`,geometry:{type:`LineString`,coordinates:[[t.longitude,t.latitude],[e.longitude,e.latitude]]},properties:{line:!0}}),Km(n)}function Ib(e,t){let n=hf(`day`),r,i,a=!1;return{id:`mob`,title:`Man overboard`,band:`vessel`,supportsOpacity:!1,layerIds:Pb,add(e){let{map:t}=e,r=e.beforeIdFor(`vessel`);if(!t.getSource(Ab)){let e={type:`geojson`,data:Gm()};t.addSource(Ab,e)}if(!t.getLayer(jb)){let e={id:jb,type:`line`,source:Ab,filter:[`has`,`line`],paint:{"line-color":n.danger,"line-width":2}};t.addLayer(e,r)}if(!t.getLayer(Mb)){let e={id:Mb,type:`circle`,source:Ab,filter:[`!`,[`has`,`line`]],paint:{"circle-radius":9,"circle-color":n.danger,"circle-stroke-color":n.markerGlyph,"circle-stroke-width":2}};t.addLayer(e,r)}if(!t.getLayer(Nb)){let e={id:Nb,type:`symbol`,source:Ab,filter:[`!`,[`has`,`line`]],layout:{"text-field":`MOB`,"text-font":[`Noto Sans Regular`],"text-size":12,"text-offset":[0,1.4],"text-optional":!0},paint:{"text-color":n.danger,"text-halo-color":n.background,"text-halo-width":1.5}};t.addLayer(e,r)}a=!0},sync(n){let o=e.position,s=t.position;!a&&o===r&&s===i||(a=!1,r=o,i=s,n.map.getSource(Ab)?.setData(Fb(o,s)))},setVisible(e,t){Pf(e.map,Pb,t)},applyTheme(e,t){n=t,e.map.setPaintProperty(jb,`line-color`,n.danger),e.map.setPaintProperty(Mb,`circle-color`,n.danger),e.map.setPaintProperty(Mb,`circle-stroke-color`,n.markerGlyph),e.map.setPaintProperty(Nb,`text-color`,n.danger),e.map.setPaintProperty(Nb,`text-halo-color`,n.background)},remove(e){Ff(e.map,Pb,[Ab])}}}var Lb={frequency:520,beepMs:180,gapMs:120,beeps:2,periodMs:2500,volume:.14},Rb=K(`<span class="note svelte-q2yqul">computing locally</span>`),zb=K(`<div class="skip-group svelte-q2yqul"><button type="button" class="skip svelte-q2yqul" aria-label="Previous waypoint" title="Previous waypoint"><!></button> <button type="button" class="skip svelte-q2yqul" aria-label="Next waypoint" title="Next waypoint"><!></button></div>`),Bb=K(`<span class="cdi svelte-q2yqul" aria-hidden="true"><span class="cdi-center svelte-q2yqul"></span> <span></span></span>`),Vb=K(`<span class="steer svelte-q2yqul"> </span>`),Hb=K(`<span class="metric">RTE <b> </b> nm</span> <span class="metric">ETA <b> </b></span>`,1),Ub=K(`<aside class="bottom-strip bottom-strip--accent" aria-label="Active route"><div class="head"><span class="title">To</span> <span class="name svelte-q2yqul" aria-live="polite"> </span> <!> <!> <button type="button" class="ack" aria-label="Stop navigation">Stop</button></div> <div class="row"><span class="metric">DTW <b> </b> nm</span> <span class="metric">BTW <b> </b>&deg;T</span> <span class="metric">XTE <!> <!> <b> </b> nm</span> <span class="metric">VMG <b> </b> kn</span> <span class="metric">TTG <b> </b></span> <!></div></aside>`);function Wb(e,t){$e(t,!0);let n=R(()=>{let e=wd(t.guidance.crossTrackErrorMeters??NaN);return e===null?null:e===`port`?`L`:`R`}),r=Uc(.2),i=R(()=>{let e=t.guidance.crossTrackErrorMeters;if(e==null)return null;let n=wd(e);if(n===null)return{pos:0,pegged:!1};let i=Math.min(1,Math.abs(e)/r);return{pos:n===`starboard`?i:-i,pegged:i>=1}}),a=R(()=>Kc(t.guidance.distanceToNextMeters)),o=R(()=>Bc(t.guidance.bearingToNextRad)),s=R(()=>Kc(t.guidance.crossTrackErrorMeters==null?void 0:Math.abs(t.guidance.crossTrackErrorMeters))),c=R(()=>t.guidance.activePointIndex!=null&&t.guidance.activePointIndex>0),l=R(()=>!t.guidance.isLastPoint),u=R(()=>zc(t.guidance.velocityMadeGoodMps)),d=R(()=>t.guidance.timeToGoSeconds==null?`--`:El(t.guidance.timeToGoSeconds)),f=R(()=>Kc(t.routeProgress?.distanceToGoMeters)),p=R(()=>{if(!t.routeProgress)return`--`;let e=t.guidance.isLastPoint?t.guidance.estimatedTimeOfArrivalIso:void 0;if(e){let t=new Date(e).getTime();if(!Number.isNaN(t))return Cl(t)}let n=t.routeProgress.timeToGoSeconds;return n==null?`--`:Cl(Date.now()+n*1e3)});var m=ci(),h=Cn(m),g=e=>{var r=Ub(),m=V(r),h=H(V(m),2),g=V(h,!0);N(h);var _=H(h,2),v=e=>{q(e,Rb())};Y(_,e=>{t.guidance.source===`computed`&&e(v)});var y=H(_,2),b=e=>{var n=zb(),r=V(n);ls(V(r),{size:15,"aria-hidden":`true`}),N(r);var i=H(r,2);ds(V(i),{size:15,"aria-hidden":`true`}),N(i),N(n),U(()=>{r.disabled=!W(c),i.disabled=!W(l)}),G(`click`,r,()=>t.onSkip(-1)),G(`click`,i,()=>t.onSkip(1)),q(e,n)};Y(y,e=>{t.onSkip&&e(b)});var x=H(y,2);N(m);var S=H(m,2),C=V(S),w=H(V(C)),T=V(w,!0);N(w),P(),N(C);var E=H(C,2),D=H(V(E)),O=V(D,!0);N(D),P(),N(E);var k=H(E,2),A=H(V(k)),ee=e=>{var t=Bb(),n=H(V(t),2);let r;N(t),U(()=>{r=ta(n,1,`cdi-needle svelte-q2yqul`,null,r,{pegged:W(i).pegged}),ra(n,`inset-inline-start: calc(50% + ${W(i).pos*45}%)`)}),q(e,t)};Y(A,e=>{W(i)&&e(ee)});var te=H(A,2),j=e=>{var t=Vb(),r=V(t,!0);N(t),U(()=>J(r,W(n))),q(e,t)};Y(te,e=>{W(n)&&e(j)});var ne=H(te,2),re=V(ne,!0);N(ne),P(),N(k);var ie=H(k,2),ae=H(V(ie)),oe=V(ae,!0);N(ae),P(),N(ie);var se=H(ie,2),ce=H(V(se)),le=V(ce,!0);N(ce),N(se);var ue=H(se,2),de=e=>{var t=Hb(),n=Cn(t),r=H(V(n)),i=V(r,!0);N(r),P(),N(n);var a=H(n,2),o=H(V(a)),s=V(o,!0);N(o),N(a),U(()=>{J(i,W(f)),J(s,W(p))}),q(e,t)};Y(ue,e=>{t.routeProgress&&e(de)}),N(S),N(r),U(()=>{J(g,t.guidance.nextPointName??`--`),J(T,W(a)),J(O,W(o)),J(re,W(s)),J(oe,W(u)),J(le,W(d))}),G(`click`,x,function(...e){t.onStop?.apply(this,e)}),q(e,r)};Y(h,e=>{t.guidance.active&&e(g)}),q(e,m),et()}Qr([`click`]);var Gb=[`text`,`measure`,`count`,`availability`,`flag`,`rating`,`link`,`note`],Kb=`/signalk/v2/api/resources/notes`,qb=`/signalk/v1/api/resources/notes`;function Jb(e){return e.replace(/<[^>]*>/g,` `).replace(/\s+/g,` `).trim()}function Yb(e){try{let t=new URL(e);if(t.protocol===`http:`||t.protocol===`https:`)return t.toString()}catch{}}function Xb(e){return Gb.includes(e)}function Zb(e){if(!e||typeof e!=`object`)return;let t=e,n=vu(t.label);if(n===void 0)return;let r=t.value;if(typeof r!=`string`&&typeof r!=`number`&&typeof r!=`boolean`)return;let i={label:n,value:r};Xb(t.kind)&&(i.kind=t.kind);let a=vu(t.unit);return a!==void 0&&(i.unit=a),i.unit!==void 0&&i.kind===void 0&&(i.kind=`measure`),i}function Qb(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n,r=vu(e.title);if(r===void 0||!Array.isArray(e.items))continue;let i=e.items.map(Zb).filter(e=>e!==void 0);i.length!==0&&t.push({id:vu(e.id)??r,title:r,items:i})}return t.length>0?t:void 0}async function $b(e,t,n){try{let r=await fetch(e,hc(gu(t)));if(!r.ok)return;let i=_u(await r.json());if(!i)return;let a=i,o=a.properties??{},s=o.crowsNest,c={id:n,name:vu(a.name)??vu(a.title)??n,type:typeof s?.type==`string`?s.type:void 0,attribution:vu(o.attribution),sources:yu(o.sources),url:vu(a.url)},l=s?.schemaVersion===1?Qb(s.sections):void 0;return l?c.sections=l:c.fallbackText=Jb(vu(a.description)??``)||void 0,c}catch(t){console.warn(`[notes] detail fetch failed: ${e}`,t);return}}async function ex(e,t,n){if(!n)return;let r=`/${encodeURIComponent(n)}`;return await $b(`${e}${Kb}${r}`,t,n)??await $b(`${e}${qb}${r}`,t,n)}var tx=64;function nx(e,t){let n=new Map,r=new Map;return{load(i){let a=n.get(i);if(a)return Promise.resolve(a);let o=r.get(i);if(o)return o;let s=ex(e,t,i).then(e=>{if(e){if(n.size>=tx){let e=n.keys().next().value;e!==void 0&&n.delete(e)}n.set(i,e)}return e}).finally(()=>{r.delete(i)});return r.set(i,s),s}}}var rx={feature:0,light:1,depth:2,dockage:2,navigation:3,fuel:4,structure:5,mooring:6,daymark:6,contact:7,signals:7,amenities:8,services:9,retail:10,quality:11,remarks:12,notes:12,information:12,business:16,review:17,featuredReview:18,source:20},ix=13;function ax(e){return e.map((e,t)=>({section:e,index:t,rank:rx[e.id]??ix})).sort((e,t)=>e.rank-t.rank||e.index-t.index).map(e=>e.section)}var ox=new Set([`notes`,`note`,`information`,`remark`,`remarks`]);function sx(e,t){let n=e.trim().toLowerCase();return n===t.trim().toLowerCase()||ox.has(n)}function cx(e,t){return t===`flag`&&e.trim().toLowerCase()===`dangerous`}var lx={anchorage:`anchorage`,anchor_berth:`anchorage`,mooring:`anchorage`,marina:`marina`,harbour:`marina`,yacht_club:`marina`,fuel:`fuel`,fuel_station:`fuel`,water:`services`,water_tap:`services`,pumpout:`services`,provisions:`services`,electricity:`services`,repairs:`services`,chandler:`services`,business:`services`,inlet:`inlet`,hazard:`hazard`,obstruction:`hazard`,rock:`hazard`,wreck:`hazard`,beacon_isolated_danger:`hazard`,buoy_isolated_danger:`hazard`,"navigation-structure":`navaid`,beacon_cardinal:`navaid`,beacon_lateral:`navaid`,beacon_safe_water:`navaid`,beacon_special_purpose:`navaid`,buoy_cardinal:`navaid`,buoy_lateral:`navaid`,buoy_safe_water:`navaid`,buoy_special_purpose:`navaid`,light_float:`navaid`,light_major:`navaid`,light_minor:`navaid`,light_vessel:`navaid`,bridge:`bridge`,boatramp:`ramp`,dam:`structure`,lock:`structure`,lock_basin:`structure`,ferry:`structure`},ux=[[`fuel`,`fuel`],[`anchor`,`anchorage`],[`mooring`,`anchorage`],[`marina`,`marina`],[`harbour`,`marina`],[`harbor`,`marina`],[`yacht`,`marina`],[`wreck`,`hazard`],[`rock`,`hazard`],[`obstruction`,`hazard`],[`hazard`,`hazard`],[`danger`,`hazard`],[`buoy`,`navaid`],[`beacon`,`navaid`],[`light`,`navaid`],[`navigation`,`navaid`],[`inlet`,`inlet`],[`pumpout`,`services`],[`pump_out`,`services`],[`water`,`services`],[`provision`,`services`],[`grocery`,`services`],[`repair`,`services`],[`chandler`,`services`],[`business`,`services`],[`bridge`,`bridge`],[`ramp`,`ramp`],[`lock`,`structure`],[`dam`,`structure`],[`ferry`,`structure`]],dx={anchorage:`Anchorage`,marina:`Marina`,fuel:`Fuel`,services:`Services`,inlet:`Inlet`,ramp:`Boat ramp`,bridge:`Bridge`,hazard:`Hazard`,navaid:`Navigation aid`,structure:`Structure`,generic:`Point of interest`},fx=Object.keys(dx);function px(e){if(!e)return`generic`;let t=e.toLowerCase(),n=lx[t];if(n)return n;for(let[e,n]of ux)if(t.includes(e))return n;return`generic`}function mx(e){return dx[e]}function hx(e){return`binnacle-poi-${e}`}var gx={hazard:100,navaid:90,inlet:70,anchorage:60,marina:55,fuel:50,services:40,ramp:30,bridge:25,structure:20,generic:0};function _x(e){return gx[e]}var vx={Marina:`marina`,Anchorage:`anchorage`,Hazard:`hazard`,Business:`services`,BoatRamp:`ramp`,Bridge:`bridge`,Dam:`structure`,Lock:`structure`,Ferry:`structure`,Inlet:`inlet`,Navigational:`navaid`};function yx(e){return e?vx[e]:void 0}var bx=K(`<span> </span>`),xx=K(`<a class="source-link svelte-1emjs18" target="_blank" rel="noopener noreferrer">View source <span class="visually-hidden">(opens in a new tab)</span> <!></a>`),Sx=K(`<!> <!> <!>`,1),Cx=K(`<p class="status svelte-1emjs18" role="status">Loading...</p>`),wx=K(`<p class="status svelte-1emjs18" role="alert">Could not load detail.</p> <button type="button" class="btn btn-ghost">Retry</button>`,1),Tx=K(`<div class="alert-note alert svelte-1emjs18"> </div>`),Ex=K(`<dt class="svelte-1emjs18"> </dt>`),Dx=K(`<div class="note-item svelte-1emjs18"><!> <dd class="prose svelte-1emjs18"> </dd></div>`),Ox=K(`<span class="badge svelte-1emjs18"> </span>`),kx=K(`<a target="_blank" rel="noopener noreferrer">Open link<span class="visually-hidden">(opens in a new tab)</span></a>`),Ax=K(`<span class="rating svelte-1emjs18" role="img"></span>`),jx=K(`<div class="item svelte-1emjs18"><dt class="svelte-1emjs18"> </dt> <dd class="svelte-1emjs18"><!></dd></div>`),Mx=K(`<section class="svelte-1emjs18"><h3 class="caps-label svelte-1emjs18"> </h3> <!> <dl class="svelte-1emjs18"></dl></section>`),Nx=K(`<p class="prose svelte-1emjs18"> </p>`),Px=K(`<p class="status svelte-1emjs18" role="status">No additional detail</p>`),Fx=K(`<div class="body svelte-1emjs18"><!></div>`);function Ix(e,t){$e(t,!0);let n=e=>{var t=Sx(),n=Cn(t),r=e=>{var t=bx(),n=V(t,!0);N(t),U(()=>J(n,W(u))),q(e,t)};Y(n,e=>{W(u)&&e(r)});var i=H(n,2),a=e=>{var t=bx(),n=V(t,!0);N(t),U(e=>J(n,e),[()=>W(d).join(`, `)]),q(e,t)};Y(i,e=>{W(d).length>0&&e(a)});var o=H(i,2),s=e=>{var t=xx();xo(H(V(t),3),{size:14,"aria-hidden":`true`}),N(t),U(()=>Z(t,`href`,W(f))),q(e,t)};Y(o,e=>{W(f)&&e(s)}),q(e,t)},r=z(void 0),i=z(!0),a=z(!1),o=z(0),s=R(()=>({id:t.selection.id,attempt:W(o)}));zn(()=>{let{id:e}=W(s),n=!0;return B(i,!0),B(a,!1),B(r,void 0),t.load(e).then(e=>{n&&(e?B(r,e,!0):B(a,!0),B(i,!1))}).catch(()=>{n&&(B(a,!0),B(i,!1))}),()=>{n=!1}});let c=[1,2,3,4,5],l=R(()=>W(r)?.sections?ax(W(r).sections):void 0),u=R(()=>W(r)?.attribution??t.selection.attribution),d=R(()=>(W(r)?.sources??[]).filter(e=>e!==W(u))),f=R(()=>Yb(W(r)?.url??t.selection.url??``)),p=R(()=>!!(W(u)||W(d).length||W(f)));function m(e){return e.unit?`${e.value} ${e.unit}`:String(e.value)}{let s=R(()=>mx(t.selection.category)),u=R(()=>W(p)?n:void 0);i_(e,{dock:`right`,get title(){return t.selection.name},get subtitle(){return W(s)},ariaLabel:`Point of interest detail`,closeLabel:`Close detail`,get onClose(){return t.onClose},get footer(){return W(u)},children:(e,t)=>{var n=Fx(),s=V(n),u=e=>{q(e,Cx())},d=e=>{var t=wx();G(`click`,H(Cn(t),2),()=>B(o,W(o)+1)),q(e,t)},f=e=>{var t=ci();Ei(Cn(t),17,()=>W(l),e=>e.id,(e,t)=>{let n=R(()=>W(t).items.find(e=>cx(e.label,e.kind))),r=R(()=>W(t).items.filter(e=>!cx(e.label,e.kind)));var i=Mx(),a=V(i),o=V(a,!0);N(a);var s=H(a,2),l=e=>{var t=Tx(),r=V(t,!0);N(t),U(()=>{Z(t,`data-danger`,W(n).value===!0),J(r,W(n).value===!0?`Dangerous to navigation`:`Not a danger to navigation`)}),q(e,t)};Y(s,e=>{W(n)&&e(l)});var u=H(s,2);Ei(u,23,()=>W(r),(e,t)=>e.label+t,(e,n)=>{let r=R(()=>W(n).kind===`link`&&typeof W(n).value==`string`?Yb(W(n).value):void 0);var i=ci(),a=Cn(i),o=e=>{var r=Dx(),i=V(r),a=e=>{var t=Ex(),r=V(t,!0);N(t),U(()=>J(r,W(n).label)),q(e,t)},o=R(()=>!sx(W(n).label,W(t).title));Y(i,e=>{W(o)&&e(a)});var s=H(i,2),c=V(s,!0);N(s),N(r),U(()=>J(c,W(n).value)),q(e,r)},s=e=>{var t=jx(),i=V(t),a=V(i,!0);N(i);var o=H(i,2),s=V(o),l=e=>{var t=Ox(),r=V(t,!0);N(t),U(e=>{Z(t,`data-value`,e),J(r,W(n).value)},[()=>String(W(n).value).toLowerCase()]),q(e,t)},u=e=>{var t=Ox(),r=V(t,!0);N(t),U(()=>{Z(t,`data-value`,W(n).value===!0?`yes`:`no`),J(r,W(n).value===!0?`Yes`:`No`)}),q(e,t)},d=e=>{var t=kx();U(()=>Z(t,`href`,W(r))),q(e,t)},f=e=>{let t=R(()=>Number(W(n).value)),r=R(()=>Math.round(W(t)));var i=Ax();Ei(i,20,()=>c,e=>e,(e,t)=>{{let n=R(()=>t<=W(r)?`currentColor`:`none`);xs(e,{size:14,get fill(){return W(n)},"aria-hidden":`true`})}}),N(i),U(()=>Z(i,`aria-label`,`Rating ${W(t)} of 5`)),q(e,i)},p=R(()=>W(n).kind===`rating`&&Number.isFinite(Number(W(n).value))),h=e=>{var t=si();U(e=>J(t,e),[()=>m(W(n))]),q(e,t)},g=e=>{var t=si();U(()=>J(t,W(n).value)),q(e,t)};Y(s,e=>{W(n).kind===`availability`?e(l):W(n).kind===`flag`?e(u,1):W(r)?e(d,2):W(p)?e(f,3):W(n).kind===`measure`?e(h,4):e(g,-1)}),N(o),N(t),U(()=>J(a,W(n).label)),q(e,t)};Y(a,e=>{W(n).kind===`note`?e(o):e(s,-1)}),q(e,i)}),N(u),N(i),U(()=>J(o,W(t).title)),q(e,i)}),q(e,t)},p=e=>{var t=Nx(),n=V(t,!0);N(t),U(()=>J(n,W(r).fallbackText)),q(e,t)},h=e=>{q(e,Px())};Y(s,e=>{W(i)?e(u):W(a)?e(d,1):W(l)?e(f,2):W(r)?.fallbackText?e(p,3):e(h,-1)}),N(n),q(e,n)},$$slots:{default:!0}})}et()}Qr([`click`]);var Lx={anchorage:`<path d="M12 6v16"/><path d="m19 13 2-1a9 9 0 0 1-18 0l2 1"/><path d="M9 11h6"/><circle cx="12" cy="4" r="2"/>`,marina:`<path d="M10 2v15"/><path d="M7 22a4 4 0 0 1-4-4 1 1 0 0 1 1-1h16a1 1 0 0 1 1 1 4 4 0 0 1-4 4z"/><path d="M9.159 2.46a1 1 0 0 1 1.521-.193l9.977 8.98A1 1 0 0 1 20 13H4a1 1 0 0 1-.824-1.567z"/>`,fuel:`<line x1="3" x2="15" y1="22" y2="22"/><line x1="4" x2="14" y1="9" y2="9"/><path d="M14 22V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v18"/><path d="M14 13h2a2 2 0 0 1 2 2v2a2 2 0 0 0 2 2 2 2 0 0 0 2-2V9.83a2 2 0 0 0-.59-1.42L18 5"/>`,services:`<path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/>`,inlet:`<path d="M2 6c.6.5 1.2 1 2.5 1C7 7 7 5 9.5 5c2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1"/><path d="M2 12c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1"/><path d="M2 18c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1"/>`,ramp:`<path d="M6 4 14 13"/><path d="M10 4 18 13"/><path d="M3 19c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 1.3 0 1.9-.5 2.5-1"/>`,bridge:`<path d="M4 20V7"/><path d="M20 20V7"/><path d="M4 7c4 8 12 8 16 0"/><path d="M3 14h18"/><path d="M9 14v-2.3"/><path d="M15 14v-2.3"/>`,hazard:`<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/>`,navaid:`<path d="M12 2 16 7 12 12 8 7Z"/><path d="M12 12v9"/><path d="M8 21h8"/>`,structure:`<path d="M10 18v-7"/><path d="M11.119 2.205a2 2 0 0 1 1.762 0l7.84 3.846A.5.5 0 0 1 20.5 7h-17a.5.5 0 0 1-.22-.949z"/><path d="M14 18v-7"/><path d="M18 18v-7"/><path d="M3 22h18"/>`,generic:`<path d="M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0"/><circle cx="12" cy="10" r="3"/>`};function Rx(e,t){return e===`hazard`?t.danger:e===`navaid`?t.warning:t.note}function zx(e,t){return[`<svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 30 30">`,`<circle cx="15" cy="15" r="14" fill="${Rx(e,t)}"/>`,`<g transform="translate(3,3)" fill="none" stroke="${t.markerGlyph}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,Lx[e],`</g></svg>`].join(``)}var Bx=60;async function Vx(e){if(typeof document>`u`||typeof Image>`u`)return null;try{let t=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`,n=new Image(Bx,Bx);await new Promise((e,r)=>{n.onload=()=>e(),n.onerror=()=>r(Error(`svg decode failed`)),n.src=t});let r=document.createElement(`canvas`);r.width=Bx,r.height=Bx;let i=r.getContext(`2d`);return i?(i.drawImage(n,0,0,Bx,Bx),i.getImageData(0,0,Bx,Bx)):null}catch{return null}}async function Hx(e,t){await Promise.all(fx.map(async n=>{let r=await Vx(zx(n,t));r&&th(e,hx(n),r,2)}))}function Ux(e){let t=e.toLowerCase(),n=t.match(/(\d+)[a-z]?\b/),r=n?Number(n[1])%2==0?`starboard`:`port`:`none`;return/lighthouse/.test(t)?{kind:`lighthouse`,side:`none`}:/daybeacon/.test(t)?{kind:`daybeacon`,side:r}:/buoy/.test(t)?{kind:`buoy`,side:r}:/\blight\b|pierhead|breakwater|entrance light|channel light/.test(t)?{kind:`light`,side:`none`}:{kind:`generic`,side:`none`}}function Wx({kind:e,side:t}){switch(e){case`generic`:return hx(`navaid`);case`lighthouse`:return`binnacle-navaid-lighthouse`;case`light`:return`binnacle-navaid-light`;default:return`binnacle-navaid-${e}-${t}`}}var Gx=[{kind:`light`,side:`none`},{kind:`lighthouse`,side:`none`},{kind:`buoy`,side:`starboard`},{kind:`buoy`,side:`port`},{kind:`buoy`,side:`none`},{kind:`daybeacon`,side:`starboard`},{kind:`daybeacon`,side:`port`},{kind:`daybeacon`,side:`none`}];function Kx(e,t){return e===`starboard`?t.navStarboard:e===`port`?t.navPort:t.note}function qx(e,t){let n=Kx(e.side,t);switch(e.kind){case`light`:return[`<circle cx="9" cy="23" r="2.2" fill="${t.navLight}"/>`,`<path d="M9 23 C 9 14 14 9 23 7 C 16 12 13 16 12 23 Z" fill="${t.navLight}"/>`].join(``);case`lighthouse`:return[`<path d="M11 26 L12.5 13 L17.5 13 L19 26 Z" fill="${t.note}"/>`,`<rect x="12.5" y="8" width="5" height="5" fill="${t.navLight}"/>`,`<path d="M15 8 L15 4 M12 7 L8 5 M18 7 L22 5" stroke="${t.navLight}"/>`].join(``);case`buoy`:return e.side===`starboard`?`<path d="M15 9 L20 22 L10 22 Z" fill="${n}"/><line x1="15" y1="22" x2="15" y2="26"/>`:e.side===`port`?`<rect x="10" y="10" width="10" height="12" rx="1" fill="${n}"/><line x1="15" y1="22" x2="15" y2="26"/>`:`<circle cx="15" cy="15" r="7" fill="${n}"/><line x1="15" y1="22" x2="15" y2="26"/>`;default:return e.side===`port`?`<line x1="15" y1="26" x2="15" y2="15"/><rect x="9.5" y="5" width="11" height="10" fill="${n}"/>`:`<line x1="15" y1="26" x2="15" y2="14"/><path d="M15 4 L21 14 L9 14 Z" fill="${n}"/>`}}function Jx(e,t){return[`<svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 30 30" fill="none" `,`stroke="${t.markerGlyph}" stroke-width="1.3" stroke-linejoin="round" stroke-linecap="round">`,qx(e,t),`</svg>`].join(``)}async function Yx(e,t){await Promise.all(Gx.map(async n=>{let r=await Vx(Jx(n,t));r&&th(e,Wx(n),r,2)}))}var Xx=5*kc,Zx=.5;function Qx(e,t=Zx){return Ks(e,t)}function $x(e){return e.join(`,`)}var eS=class{#e=[];get(e,t,n=!1){let r;for(let i=this.#e.length-1;i>=0;i--){let a=this.#e[i];if(qs(a.bbox,e)){if(a.expires>t)return a.notes;n&&!r&&(r=a.notes)}}return r}put(e,t,n){this.#e.push({bbox:e,notes:t,expires:n+Xx}),this.#e=this.#e.filter(e=>e.expires>n).slice(-12)}},tS=`/signalk/v2/api/resources/notes`;function nS(e,t){if(!t||typeof t!=`object`)return;let n=t,r=n.position?.latitude,i=n.position?.longitude;if(typeof r!=`number`||typeof i!=`number`)return;let a=n.properties??{};return{id:e,name:vu(n.name)??vu(n.title)??e,position:{latitude:r,longitude:i},category:yx(typeof a.crowsNest?.type==`string`?a.crowsNest.type:void 0)??px(vu(a.skIcon)),skIcon:vu(a.skIcon),url:vu(n.url),source:vu(a.source),attribution:vu(a.attribution)}}function rS(e,t,n){return bu(e,[`${tS}?${new URLSearchParams({bbox:JSON.stringify(n)})}`],t,nS)}var iS=`binnacle-notes`,aS=`binnacle-notes-symbol`,oS=`binnacle-notes-cluster-ring`,sS=`binnacle-notes-cluster-icon`,cS=`binnacle-notes-cluster-count`,lS=`binnacle-notes-selected`,uS=`binnacle-notes-selected`,dS=`binnacle-notes-selected-casing`,fS=Wm(Um),pS=[dS,uS,oS,sS,cS,aS],mS=[sS,oS],hS=9,gS=11,_S=44,vS=3e4,yS=7*jc,bS=24,xS=[`match`,[`get`,`maxRank`],...fx.filter(e=>e!==`generic`).flatMap(e=>[_x(e),hx(e)]),hx(`generic`)];function SS(e){return e.category===`navaid`?Wx(Ux(e.name)):hx(e.category)}var CS=[0,0];function wS(e){if(e.size===0)return CS;let t=[`match`,[`get`,`icon`]];for(let[n,r]of e)t.push(n,[`literal`,r]);return t.push([`literal`,CS]),t}function TS(e,t){let n=new Map;return{data:Km(e.map(e=>{let r=t(e);return r&&(r.offset[0]!==0||r.offset[1]!==0)&&n.set(r.iconId,r.offset),{type:`Feature`,geometry:{type:`Point`,coordinates:[e.position.longitude,e.position.latitude]},properties:{id:e.id,name:e.name,category:e.category,rank:_x(e.category),icon:r?.iconId??SS(e),url:e.url??``,source:e.source??``,attribution:e.attribution??``}}})),iconOffset:wS(n)}}var ES=Gm();function DS(e,t,n,r,i={}){let a=i.isOnline??(()=>!0),o=i.persist??lm(`binnacle-notes`,{maxEntries:bS}),s=new eS,c=new Set,l,u,d,f,p=()=>{u=void 0},m=!1,h=0,g=!0,_,v,y,b,x,S=r?.createIconRegistry(),C=new Map,w=hf(`day`);function T(e){if(!S||!r||!e.skIcon)return;let t=r.resolve(e.skIcon,`note`);if(!t)return;let n=S.entry(t.uuid);if(n)return n;S.status(t.uuid)!==`failed`&&C.set(t.uuid,t)}function E(e,t){if(!S||C.size===0)return;let n=[...C.values()];C.clear();for(let r of n)S.ensure(e.map,r,w).then(n=>{!n||l!==t||(l=void 0,O(e,t))}).catch(()=>void 0)}function D(e,t){e.map.getSource(iS)?.setData(t)}function O(e,t){if(t===l)return;l=t;let{data:n,iconOffset:r}=TS(t,T);D(e,n),e.map.getLayer(aS)&&e.map.setLayoutProperty(aS,`icon-offset`,r),E(e,t)}async function k(n,r){if(!c.has(n)){let e=Date.now(),t=await o.get(n);if(t&&t.expires>e)return c.add(n),o.prune(e),t.value}let i=await rS(e,t,r);if(i){c.add(n);let e=Date.now();await o.put(n,i,e+yS),o.prune(e)}return i}function A(e){l!==void 0&&(l=void 0,D(e,ES))}function ee(e,t){let n=e.map.getSource(lS);if(n){if(t?.geometry.type!==`Point`){n.setData(ES);return}n.setData(Km([{type:`Feature`,geometry:t.geometry,properties:{}}]))}}return{id:`notes`,title:`Points of interest`,band:`routes`,supportsOpacity:!0,layerIds:pS,async add(e){let t=e.beforeIdFor(`routes`);if(!e.map.getSource(iS)){let t={type:`geojson`,data:ES,cluster:!0,clusterMaxZoom:gS,clusterRadius:_S,clusterProperties:{maxRank:[`max`,[`get`,`rank`]]}};e.map.addSource(iS,t)}if(e.map.getSource(lS)||e.map.addSource(lS,{type:`geojson`,data:ES}),!e.map.getLayer(dS)){let n={id:dS,type:`circle`,source:lS,minzoom:hS,paint:{"circle-radius":15,"circle-color":`rgba(0,0,0,0)`,"circle-stroke-color":fS,"circle-stroke-width":5}};e.map.addLayer(n,t)}if(!e.map.getLayer(uS)){let n={id:uS,type:`circle`,source:lS,minzoom:hS,paint:{"circle-radius":15,"circle-color":`rgba(0,0,0,0)`,"circle-stroke-color":w.select,"circle-stroke-width":3}};e.map.addLayer(n,t)}if(!e.map.getLayer(oS)){let n={id:oS,type:`circle`,source:iS,filter:[`has`,`point_count`],minzoom:hS,paint:{"circle-radius":[`step`,[`get`,`point_count`],18,10,22,50,28],"circle-color":`rgba(0,0,0,0)`,"circle-stroke-color":w.markerGlyph,"circle-stroke-width":2.5,"circle-stroke-opacity":.9}};e.map.addLayer(n,t)}if(!e.map.getLayer(sS)){let n={id:sS,type:`symbol`,source:iS,filter:[`has`,`point_count`],minzoom:hS,layout:{"icon-image":xS,"icon-size":.85,"icon-allow-overlap":!0}};e.map.addLayer(n,t)}if(!e.map.getLayer(cS)){let n={id:cS,type:`symbol`,source:iS,filter:[`has`,`point_count`],minzoom:hS,layout:{"text-field":[`get`,`point_count_abbreviated`],"text-font":[`Noto Sans Regular`],"text-size":11,"text-offset":[1.2,-1.2],"text-allow-overlap":!0},paint:{"text-color":w.markerGlyph,"text-halo-color":w.note,"text-halo-width":2.4}};e.map.addLayer(n,t)}if(!e.map.getLayer(aS)){let n={id:aS,type:`symbol`,source:iS,filter:[`!`,[`has`,`point_count`]],layout:{"icon-image":[`get`,`icon`],"icon-size":[`interpolate`,[`linear`],[`zoom`],9,.6,14,.9],"icon-offset":[0,0],"icon-allow-overlap":!0,"text-field":[`get`,`name`],"text-font":[`Noto Sans Regular`],"text-size":11,"text-offset":[0,1.1],"text-anchor":`top`,"text-optional":!0,"text-max-width":9,"text-padding":6},paint:{"text-color":w.note,"text-halo-color":w.background,"text-halo-width":1.2},minzoom:hS};e.map.addLayer(n,t)}v=t=>{let r=t.features?.[0];if(!r)return;let i=r.properties??{},a=String(i.id??``);if(!a)return;let o=String(i.category??``),s=fx.includes(o)?o:`generic`;ee(e,r),n?.({id:a,name:String(i.name??`Point of interest`),category:s,attribution:vu(i.attribution)??vu(i.source),url:vu(i.url)})},y=t=>{let n=t.features?.[0],r=n?.properties?.cluster_id;if(typeof r!=`number`||n?.geometry.type!==`Point`)return;let i=e.map.getSource(iS);if(!i)return;let a=n.geometry.coordinates;i.getClusterExpansionZoom(r).then(t=>{e.map.easeTo({center:a,zoom:t})})},b=()=>{e.map.getCanvas().style.cursor=`pointer`},x=()=>{e.map.getCanvas().style.cursor=``},e.map.on(`click`,aS,v),e.map.on(`mouseenter`,aS,b),e.map.on(`mouseleave`,aS,x),e.map.on(`click`,oS,y);for(let t of mS)e.map.on(`mouseenter`,t,b),e.map.on(`mouseleave`,t,x);await Promise.all([Hx(e.map,w),Yx(e.map,w)])},sync(e){if(!g)return;let t=e.map.getZoom(),n=e.map.getCenter();if(t===u&&n.lng===d&&n.lat===f)return;if(u=t,d=n.lng,f=n.lat,t<hS){A(e);return}let r=Ys(e.map.getBounds()),i=s.get(r,Date.now(),!a());if(i){O(e,i);return}if(m)return;if(Date.now()<h){p();return}m=!0;let o=Qx(r);k($x(o),o).then(t=>{if(!t){h=Date.now()+vS,p();return}s.put(o,t,Date.now()),O(e,t),qs(o,Ys(e.map.getBounds()))||p()}).finally(()=>{m=!1})},deselect(e){ee(e,void 0)},applyTheme(e,t){w=t,g?(Hx(e.map,t),Yx(e.map,t),S?.retheme(e.map,t)):_=t,e.map.setPaintProperty(aS,`text-color`,t.note),e.map.setPaintProperty(aS,`text-halo-color`,t.background),e.map.setPaintProperty(oS,`circle-stroke-color`,t.markerGlyph),e.map.setPaintProperty(cS,`text-color`,t.markerGlyph),e.map.setPaintProperty(cS,`text-halo-color`,t.note),e.map.setPaintProperty(uS,`circle-stroke-color`,t.select)},setVisible(e,t){if(g=t,Pf(e.map,pS,t),t&&_){let t=_;_=void 0,Hx(e.map,t),Yx(e.map,t),S?.retheme(e.map,t)}},setOpacity(e,t){e.map.setPaintProperty(aS,`icon-opacity`,t),e.map.setPaintProperty(aS,`text-opacity`,t),e.map.setPaintProperty(sS,`icon-opacity`,t),e.map.setPaintProperty(oS,`circle-stroke-opacity`,t*.9),e.map.setPaintProperty(cS,`text-opacity`,t),e.map.setPaintProperty(dS,`circle-stroke-opacity`,t),e.map.setPaintProperty(uS,`circle-stroke-opacity`,t)},remove(e){v&&e.map.off(`click`,aS,v),b&&e.map.off(`mouseenter`,aS,b),x&&e.map.off(`mouseleave`,aS,x),y&&e.map.off(`click`,oS,y);for(let t of mS)b&&e.map.off(`mouseenter`,t,b),x&&e.map.off(`mouseleave`,t,x);Ff(e.map,pS,[iS,lS])}}}var OS=K(`<span class="dot svelte-bpfkuq" aria-hidden="true"></span>`),kS=K(`<button type="button" title="Profiles"><!> <span class="name svelte-bpfkuq"> </span> <!></button>`);function AS(e,t){$e(t,!0);let n=R(()=>t.active?.name??`No profile`),r=R(()=>t.active?`Profile ${t.active.name}${t.isDirty?`, edited`:``}, open profiles`:`No profile, open profiles`);var i=kS();let a;var o=V(i);Fs(o,{size:16,"aria-hidden":`true`});var s=H(o,2),c=V(s,!0);N(s);var l=H(s,2),u=e=>{q(e,OS())};Y(l,e=>{t.isDirty&&e(u)}),N(i),U(()=>{a=ta(i,1,`btn btn-pill switcher svelte-bpfkuq`,null,a,{"no-profile":!t.active}),Z(i,`aria-label`,W(r)),J(c,W(n))}),G(`click`,i,function(...e){t.onClick?.apply(this,e)}),q(e,i),et()}Qr([`click`]);var jS=a_;function MS(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function NS(e){return MS(e)?bc(e.dangerCpaMeters)&&bc(e.dangerTcpaSeconds)&&bc(e.warningCpaMeters)&&bc(e.warningTcpaSeconds):!1}function PS(e){return MS(e)?bc(e.intervalSeconds)&&bc(e.minMeters)&&(e.colorMode===`speed`||e.colorMode===`solid`):!1}function FS(e){return!(!MS(e)||typeof e.theme!=`string`||!jS.includes(e.theme)||!MS(e.layers)||!MS(e.layerCategories)||!MS(e.weatherLayers)||!Array.isArray(e.layerOrder)||!e.layerOrder.every(e=>typeof e==`string`)||!NS(e.thresholds)||!PS(e.trackSettings)||!bc(e.planningSpeedKn)||typeof e.arrivalMuted!=`boolean`||e.units!==void 0&&e.units!==`metric`&&e.units!==`imperial`||e.mode!==void 0&&typeof e.mode!=`string`)}function IS(e){if(MS(e)){if(MS(e.settings))return FS(e.settings)?{name:typeof e.name==`string`&&e.name?e.name:`Imported profile`,settings:e.settings}:void 0;if(FS(e))return{name:`Imported profile`,settings:e}}}function LS(e){let t;try{t=JSON.parse(e)}catch{return[]}let n;n=Array.isArray(t)?t:MS(t)&&Array.isArray(t.profiles)?t.profiles:[t];let r=[];for(let e of n){let t=IS(e);t&&r.push(t)}return r}function RS(e){let t=JSON.stringify(e,null,2);pc(`${e.name||`profile`}.binnacle-profile.json`,t,`application/json`)}var zS=K(`<p class="alert-note" role="status"> </p>`),BS=K(`<span class="caps-label tag svelte-1nocxik">Default</span>`),VS=K(`<span class="badge">Active</span>`),HS=K(`<p class="dirty caps-label svelte-1nocxik">Unsaved changes</p>`),US=K(`<button type="button" class="icon-btn" aria-label="Apply this profile" title="Apply"><!></button>`),WS=K(`<button type="button" class="icon-btn" aria-label="Save changes to this profile" title="Save changes"><!></button>`),GS=K(`<button type="button" class="icon-btn" aria-label="Set as default profile" title="Set as default"><!></button>`),KS=K(`<div class="actions"><!> <!> <button type="button" class="icon-btn" aria-label="Rename profile" title="Rename"><!></button> <!> <button type="button" class="icon-btn" aria-label="Export JSON" title="Export JSON"><!></button> <button type="button" class="icon-btn icon-btn--danger" aria-label="Delete profile" title="Delete"><!></button></div>`),qS=K(`<div class="card-head"><span class="name"> </span> <!> <!></div> <!> <!>`,1),JS=K(`<div class="panel-controls"><button type="button" class="btn btn-primary btn--grow"><!> Save current as profile</button> <button type="button" class="btn"><!> Import JSON</button></div> <!> <!>`,1);function YS(e,t){$e(t,!0);function n(){let e=Kg(`Profile`);e!==void 0&&t.onSaveNew(e)}let r=z(void 0);async function i(){let e=await Hg(`.json,application/json`);if(e===void 0)return;let n=LS(e);if(n.length===0){B(r,`No valid profiles in that file.`);return}B(r,void 0),t.onImport(n)}let a=z(void 0);function o(e){B(a,void 0),t.onRemove(e)}function s(e){let n=qg(`Profile`,e.name);n!==void 0&&t.onRename(e.id,n)}i_(e,{title:`Profiles`,bodyFlex:!0,closeLabel:`Close profiles panel`,get onClose(){return t.onClose},get onBack(){return t.onBack},children:(e,c)=>{var l=JS(),u=Cn(l),d=V(u);as(V(d),{size:16,"aria-hidden":`true`}),P(),N(d);var f=H(d,2);Ns(V(f),{size:16,"aria-hidden":`true`}),P(),N(f),N(u);var p=H(u,2),m=e=>{var t=zS(),n=V(t,!0);N(t),U(()=>J(n,W(r))),q(e,t)};Y(p,e=>{W(r)&&e(m)}),Qg(H(p,2),{heading:`Saved profiles`,get items(){return t.profiles},empty:`No profiles yet`,key:e=>e.id,isActive:e=>e.id===t.activeId,card:(e,n=x)=>{let r=R(()=>n().id===t.activeId),i=R(()=>n().id===t.defaultId);var c=qS(),l=Cn(c),u=V(l),d=V(u,!0);N(u);var f=H(u,2),p=e=>{q(e,BS())};Y(f,e=>{W(i)&&e(p)});var m=H(f,2),h=e=>{q(e,VS())};Y(m,e=>{W(r)&&e(h)}),N(l);var g=H(l,2),_=e=>{q(e,HS())};Y(g,e=>{W(r)&&t.isDirty&&e(_)});var v=H(g,2),y=e=>{Wg(e,{question:`Delete this profile on every synced device?`,onConfirm:()=>o(n().id),onCancel:()=>B(a,void 0)})},b=e=>{var o=KS(),c=V(o),l=e=>{var r=US();no(V(r),{size:18,"aria-hidden":`true`}),N(r),G(`click`,r,()=>t.onApply(n().id)),q(e,r)};Y(c,e=>{W(r)||e(l)});var u=H(c,2),d=e=>{var r=WS();as(V(r),{size:18,"aria-hidden":`true`}),N(r),U(()=>r.disabled=!t.isDirty),G(`click`,r,()=>t.onUpdate(n().id)),q(e,r)};Y(u,e=>{W(r)&&e(d)});var f=H(u,2);_s(V(f),{size:18,"aria-hidden":`true`}),N(f);var p=H(f,2),m=e=>{var r=GS();xs(V(r),{size:18,"aria-hidden":`true`}),N(r),G(`click`,r,()=>t.onSetDefault(n().id)),q(e,r)};Y(p,e=>{W(i)||e(m)});var h=H(p,2);_o(V(h),{size:18,"aria-hidden":`true`}),N(h);var g=H(h,2);Ds(V(g),{size:18,"aria-hidden":`true`}),N(g),N(o),G(`click`,f,()=>s(n())),G(`click`,h,()=>t.onExport(n().id)),G(`click`,g,()=>B(a,n().id,!0)),q(e,o)};Y(v,e=>{W(a)===n().id?e(y):e(b,-1)}),U(()=>J(d,n().name)),q(e,c)},$$slots:{card:!0}}),G(`click`,d,n),G(`click`,f,i),q(e,l)},$$slots:{default:!0}}),et()}Qr([`click`]);function XS(e){let t=Object.values({theme:{read:()=>({theme:e.theme.theme}),write:t=>e.theme.set(t.theme),track:()=>void e.theme.theme},layers:{read:()=>({layers:{...e.layers.value}}),write:t=>e.layers.set(t.layers),track:()=>void e.layers.value},layerOrder:{read:()=>({layerOrder:[...e.layerOrder.value]}),write:t=>e.layerOrder.set(t.layerOrder),track:()=>void e.layerOrder.value},layerCategories:{read:()=>({layerCategories:{...e.layerCategories.value}}),write:t=>e.layerCategories.set(t.layerCategories),track:()=>void e.layerCategories.value},weatherLayers:{read:()=>({weatherLayers:{...e.weatherLayers.value}}),write:t=>e.weatherLayers.set(t.weatherLayers),track:()=>void e.weatherLayers.value},thresholds:{read:()=>({thresholds:{...e.thresholds.value}}),write:t=>e.thresholds.set(t.thresholds),track:()=>void e.thresholds.value},trackSettings:{read:()=>({trackSettings:{...e.trackSettings.value}}),write:t=>e.trackSettings.set(t.trackSettings),track:()=>void e.trackSettings.value},planningSpeedKn:{read:()=>({planningSpeedKn:e.planningSpeedKn.value}),write:t=>e.planningSpeedKn.set(t.planningSpeedKn),track:()=>void e.planningSpeedKn.value},arrivalMuted:{read:()=>({arrivalMuted:e.arrivalMuted.value}),write:t=>e.arrivalMuted.set(t.arrivalMuted),track:()=>void e.arrivalMuted.value},units:{read:()=>({units:e.unitsLocal.value}),write:t=>{t.units&&e.unitsLocal.set(t.units)},track:()=>void e.unitsLocal.value}});return{capture:()=>Object.assign({},...t.map(e=>e.read())),apply:e=>{for(let n of t)n.write(e)},track:()=>{for(let e of t)e.track()}}}function ZS(e,t){let n=Date.now(),r=(e,t,r)=>({id:e,name:t,settings:r,createdAt:n,updatedAt:n});e.seed([r(`binnacle-seed-coastal-day`,`Coastal day`,{...t,theme:`day`}),r(`binnacle-seed-night-passage`,`Night passage`,{...t,theme:`night-red`}),r(`binnacle-seed-at-anchor`,`At anchor`,{...t,theme:`dusk`})])}var QS=`/signalk/v2/api/vessels/self/navigation/course`;function $S(e,t,n,r=0,i=!1){return Cu(`${e}${QS}/activeRoute`,t,{href:n,pointIndex:r,reverse:i})}function eC(e,t,n){return Cu(`${e}${QS}/destination`,t,{position:n})}function tC(e,t,n){return Cu(`${e}${QS}/activeRoute/nextPoint`,t,{value:n})}function nC(e,t){return wu(`${e}${QS}`,t)}function rC(e){if(!e)return;let t=e.activeRoute?.href?.split(`/`).pop();return t?{routeId:decodeURIComponent(t)}:e.nextPoint?.position?{goto:!0}:{}}async function iC(e,t){let n=n=>_c(`${e}${QS}${n}`,gu(t)),[r,i]=await Promise.all([n(``),n(`/calcValues`)]);return{info:r,calc:i}}var aC={land:0,shallow:1,hazard:2,fuel:3,other:4};function oC(e){return[...e].sort((e,t)=>aC[e.kind]-aC[t.kind])}function sC(e){let t=[],n=[],r=new Map;for(let i of oC(e))if(i.kind===`hazard`){let e=r.get(i.leg);e===void 0&&(e=new Map,r.set(i.leg,e)),e.set(i.message,(e.get(i.message)??0)+1)}else aC[i.kind]<aC.hazard?t.push({kind:i.kind,message:i.message}):n.push({kind:i.kind,message:i.message});let i=Array.from(r,([e,t])=>cC(e,t));return[...t,...i,...n]}function cC(e,t){let n=0;for(let e of t.values())n+=e;if(n===1){let[e]=t.keys();return{kind:`hazard`,message:e}}let r=e===void 0?`near the route`:`near leg ${e+1}`,i=Array.from(t,([e,t])=>{let n=dC(e);return t>1?`${n} ×${t}`:n});return{kind:`hazard`,message:`${n} charted hazards ${r}, verify on the chart`,detail:i}}var lC=/^Charted /,uC=/ within the leg corridor$/;function dC(e){let t=e.replace(lC,``).replace(uC,``);return t===``||t===e?e:Cc(t)}function fC(e,t){let n=rl(t),r=e=>Math.round(il(e,t)),i=[`needs ~${r(e.neededL)} ${n}`];bc(e.aboardL)&&i.push(`~${r(e.aboardL)} ${n} aboard`),bc(e.marginPct)&&i.push(`${Math.round(e.marginPct)}% margin`);let a=`Fuel: ${i.join(`, `)}.`;return e.derateNote?`${a} ${e.derateNote}`:a}var pC={"<":`&lt;`,">":`&gt;`,"&":`&amp;`,"'":`&apos;`,'"':`&quot;`},mC={amp:`&`,lt:`<`,gt:`>`,apos:`'`,quot:`"`};function hC(e){return e.replace(/[<>&'"]/g,e=>pC[e])}function gC(e){return e.replace(/&(#x[0-9a-fA-F]+|#[0-9]+|amp|lt|gt|apos|quot);/g,(e,t)=>{if(t[0]===`#`){let n=t[1]===`x`?Number.parseInt(t.slice(2),16):Number.parseInt(t.slice(1),10);return n>=0&&n<=1114111?String.fromCodePoint(n):e}return mC[t]})}var _C=/<(?:\w+:)?rte\b[^>]*>([\s\S]*?)<\/(?:\w+:)?rte>/gi,vC=/<(?:\w+:)?rtept\b([^>]*?)(?:\/>|>([\s\S]*?)<\/(?:\w+:)?rtept>)/gi,yC=/<(?:\w+:)?name\b[^>]*>([\s\S]*?)<\/(?:\w+:)?name>/i,bC=/\blat\s*=\s*["']([^"']*)["']/i,xC=/\blon\s*=\s*["']([^"']*)["']/i;function SC(e,t){let n=e.match(t);return n?Number.parseFloat(n[1]):NaN}function CC(e){let t=[];for(let n of e.matchAll(vC)){let e=SC(n[1],bC),r=SC(n[1],xC);if(!Qs(e)||!$s(r))continue;let i=n[2]?.match(yC),a=i?gC(i[1]).trim():``;t.push(a?{position:{latitude:e,longitude:r},name:a}:{position:{latitude:e,longitude:r}})}return t}function wC(e){let t=[];for(let n of e.matchAll(_C)){let e=n[1],r=CC(e);if(r.length<2)continue;let i=e.search(/<(?:\w+:)?rtept\b/i),a=(i>=0?e.slice(0,i):e).match(yC),o=a?gC(a[1]).trim():``;t.push({id:vc(),name:o||`Imported route ${t.length+1}`,waypoints:r})}return t}var TC=`/plugins/signalk-crows-nest/api/route-draft`,EC=`signalk-crows-nest`,DC=`0.10.0`,OC=new Set([`budget`,`no-route`,`model-error`,`timeout`,`unreachable`,`unauthorized`,`bad-request`,`cancelled`]);function kC(e){return typeof e==`string`&&OC.has(e)}function AC(e){return e.replace(/^v/i,``).split(`.`).map(e=>{let t=Number.parseInt(e,10);return Number.isFinite(t)?t:0})}function jC(e,t){let[n=0,r=0,i=0]=AC(e),[a=0,o=0,s=0]=AC(t);return n===a?r===o?i-s:r-o:n-a}function MC(e){if(!e)return!1;let t=e.get(EC);return t?jC(t,DC)>=0:!1}var NC=60,PC=55e3,FC=new Set([`land`,`shallow`,`hazard`,`fuel`,`other`]);function IC(e){return typeof e==`string`&&FC.has(e)}function LC(e){if(!Array.isArray(e)||e.length<2)return;let t=[];for(let n of e){if(!n||typeof n!=`object`)return;let e=n;if(`lat`in e||`lng`in e||`lon`in e||!Qs(e.latitude)||!$s(e.longitude))return;t.push({position:{latitude:e.latitude,longitude:e.longitude},...typeof e.name==`string`?{name:e.name}:{}})}return t}function RC(e,t){if(!Array.isArray(e))return[];let n=[];for(let r of e){if(!r||typeof r!=`object`)continue;let e=r;!IC(e.kind)||typeof e.message!=`string`||typeof e.wp==`number`&&(e.wp<0||e.wp>=t)||typeof e.leg==`number`&&(e.leg<0||e.leg>=t-1)||n.push({kind:e.kind,message:e.message,...typeof e.wp==`number`?{wp:e.wp}:{},...typeof e.leg==`number`?{leg:e.leg}:{}})}return n}function zC(e){if(!e||typeof e!=`object`)return;let t=e;if(bc(t.neededL))return{neededL:t.neededL,...bc(t.aboardL)?{aboardL:t.aboardL}:{},...bc(t.marginPct)?{marginPct:t.marginPct}:{},...typeof t.derateNote==`string`?{derateNote:t.derateNote}:{}}}function BC(e){if(!e||typeof e!=`object`)return;let t=e.name;return typeof t==`string`?{name:t}:void 0}async function VC(e,t,n,r){let i=AbortSignal.timeout(PC),a;if(typeof AbortSignal.any==`function`)a=r?AbortSignal.any([i,r]):i;else{let e=new AbortController,t=()=>e.abort();for(let e of r?[i,r]:[i])e.aborted?t():e.addEventListener(`abort`,t,{once:!0});a=e.signal}let o;try{o=await fetch(`${e}${TC}`,gu(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n),signal:a}))}catch(e){if(e instanceof DOMException){if(e.name===`TimeoutError`)return{ok:!1,error:`timeout`,message:e.message};if(e.name===`AbortError`)return{ok:!1,error:`cancelled`,message:`cancelled`}}return{ok:!1,error:`unreachable`,message:String(e)}}if(!o.ok){if(o.status===401||o.status===403)return{ok:!1,error:`unauthorized`,message:`HTTP ${o.status}`};let e=o.status>=500?`unreachable`:`bad-request`;try{let t=await o.json();t.ok===!1&&kC(t.error)&&(e=t.error)}catch{}return{ok:!1,error:e,message:`HTTP ${o.status}`}}let s;try{s=await o.json()}catch{return{ok:!1,error:`unreachable`,message:`invalid JSON in response`}}if(!s||typeof s!=`object`)return{ok:!1,error:`unreachable`,message:`unexpected response shape`};let c=s;if(c.ok===!1){let e=kC(c.error)?c.error:`model-error`;return{ok:!1,error:e,message:typeof c.message==`string`?c.message:e}}let l=LC(c.waypoints);if(!l)return{ok:!1,error:`no-route`,message:`response waypoints failed shape validation`};if(l.length>NC)return{ok:!1,error:`no-route`,message:`drafted route has ${l.length} waypoints, over the ${NC} limit`};let u=RC(c.flags,l.length),d=zC(c.fuel),f=BC(c.destination);return{ok:!0,route:{waypoints:l,note:typeof c.note==`string`?c.note:``,...typeof c.name==`string`?{name:c.name}:{},...f?{destination:f}:{},...c.confidence===`high`||c.confidence===`low`?{confidence:c.confidence}:{},...d?{fuel:d}:{},...u.length>0?{flags:u}:{}},optimized:c.optimized===!0}}var HC=K(`<p class="alert-note" role="alert"> </p>`),UC=K(`<p class="muted-note">Drafting...</p>`),WC=K(`<textarea class="input draft-prompt svelte-813ore" placeholder="Describe your passage, e.g. 'from here to Avalon, stay 3 nm off the coast'"></textarea> <!> <!> <div class="panel-controls"><button type="button" class="btn btn-primary btn--grow">Draft</button></div>`,1),GC=K(`<div class="draft-control svelte-813ore"><button type="button" class="btn btn--grow">Draft a route with AI</button> <!></div>`),KC=K(`<div class="panel-controls"><button type="button" class="btn btn-primary btn--grow"><!> Save</button> <button type="button" class="btn"><!> Cancel</button></div>`),qC=K(`<p class="alert-note" role="alert">The model flagged this draft as low confidence. Scrutinize every leg with extra care.</p>`),JC=K(`<p class="muted-note"> </p>`),YC=K(`<li> </li>`),XC=K(`<ul class="draft-hazards svelte-813ore"></ul>`),ZC=K(`<li class="alert-note"> <!></li>`),QC=K(`<ul class="draft-flags svelte-813ore"></ul>`),$C=K(`<p class="alert-note" role="alert"><!> Check every leg against the chart and save only what you have verified. This AI draft is
759
+ checked leg by leg against charted and modeled marine data that varies by region and does
760
+ not cover depth everywhere. Read each flag below with its stated source and datum. It is
761
+ advisory and online, it is not a substitute for the chart, and the absence of a flag is
762
+ not proof of clear water.</p> <!> <!> <!> <!> <!>`,1),ew=K(`<input id="optimize-constraint-input" class="input" type="text" placeholder="stay 3 nm off" aria-label="Optimize constraint"/>`),tw=K(`<p class="muted-note">Optimizing...</p>`),nw=K(`<p class="muted-note">No safer or shorter route found. Your route is unchanged.</p>`),rw=K(`<div class="optimize svelte-813ore"><button type="button" class="btn btn--grow" aria-label="Optimize this route with AI"><!> Optimize route</button> <button type="button" class="btn" aria-controls="optimize-constraint-input">Add a constraint</button></div> <!> <!> <!> <!>`,1),iw=K(`<li><button type="button"><span class="leg-no svelte-813ore"> </span> <span class="leg-dist num svelte-813ore"> </span> <span class="leg-brg num svelte-813ore"> </span> <span class="leg-time num svelte-813ore"> </span></button></li>`),aw=K(`<ol class="legs svelte-813ore" aria-label="Legs"></ol>`),ow=K(`<div class="draft-save svelte-813ore"><input type="text" class="input" aria-label="Route name" placeholder="Route name"/> <!></div>`),sw=K(`<div class="editing svelte-813ore" role="group" aria-label="Route under edit"><!> <!> <dl class="stat-grid"><dt>Waypoints</dt> <dd><span class="num"> </span><span class="unit"></span></dd> <dt>Distance</dt> <dd><span class="num"> </span> <span class="unit">nm</span></dd> <dt>Time</dt> <dd><span class="num"> </span> <span class="unit"> </span></dd></dl> <!> <!> <p class="muted-note">Tap the chart to add waypoints. Drag a point to move it, tap a midpoint to insert one.</p> <!></div>`),cw=K(`<span class="badge">Active</span>`),lw=K(`<button type="button" class="icon-btn icon-btn--accent" aria-label="Stop navigation" title="Stop navigation"><!></button>`),uw=K(`<button type="button" class="icon-btn" aria-label="Activate route" title="Activate route"><!></button>`),dw=K(`<div class="actions"><!> <button type="button" class="icon-btn" aria-label="Edit route" title="Edit"><!></button> <button type="button" class="icon-btn" aria-label="Reverse route" title="Save a reversed copy"><!></button> <button type="button" class="icon-btn" aria-label="Export route as GPX" title="Export GPX"><!></button> <!> <button type="button" class="icon-btn icon-btn--danger" aria-label="Delete route" title="Delete"><!></button></div>`),fw=K(`<div class="card-head"><button type="button" class="name" title="Go to this route on the chart"> </button> <!></div> <dl class="card-stats svelte-813ore"><dt class="caps-label">Distance</dt> <dd><span class="num"> </span> nm</dd> <dt class="caps-label">Waypoints</dt> <dd><span class="num"> </span></dd></dl> <!>`,1),pw=K(`<!> <div class="panel-controls"><button type="button" class="btn btn-primary btn--grow"><!> New route</button> <button type="button" class="btn"><!> Import GPX</button></div> <!> <!> <!>`,1);function mw(e,t){$e(t,!0);function n(){let e=Kg(`Route`);e!==void 0&&t.onSave(e)}let r=z(void 0);function i(e){B(r,void 0),t.onDelete(e)}async function a(){let e=await Hg(`.gpx,application/gpx+xml`);e!==void 0&&t.onImportGpx(e)}let o=R(()=>t.routes.map(e=>({route:e,distanceNm:Wc(af(e.waypoints))}))),s=R(()=>Nc(Math.max(0,t.planningSpeed.value??0))),c=R(()=>{let e=0;return cf(t.working?.waypoints??[]).map(t=>(e+=t.distanceMeters,{...t,cumulativeMeters:e}))}),l=R(()=>t.working?.waypoints.length??0),u=R(()=>new Set(uf(t.highlight,W(l)))),d=R(()=>W(c).at(-1)?.cumulativeMeters??0),f=R(()=>Wc(W(d))),p=R(()=>{let e=Cd(W(d),W(s));return e==null?null:Tl(e)}),m=z(!1),h=!1;zn(()=>{let e=t.working!==void 0;e&&!h&&B(m,!1),h=e});let g=z(!1),_=z(``),v=R(()=>W(_).trim()),y=z(!1),b=z(!1),S=z(``),C=z(``),w=!1;zn(()=>{t.draft&&!w&&B(C,t.draft.name,!0),w=t.draft!==void 0}),zn(()=>{t.draft===void 0&&(B(g,!1),B(_,``),B(y,!1),B(C,``),B(b,!1),B(S,``))});{let l=R(()=>t.draft?void 0:{collapsed:W(m),onToggle:()=>B(m,!W(m))});i_(e,{title:`Routes`,bodyFlex:!0,closeLabel:`Close routes panel`,get minimize(){return W(l)},get onClose(){return t.onClose},get onBack(){return t.onBack},children:(e,l)=>{var d=pw(),m=Cn(d),h=e=>{var n=HC(),r=V(n,!0);N(n),U(()=>J(r,t.error)),q(e,n)};Y(m,e=>{t.error&&e(h)});var w=H(m,2),T=V(w);Zo(V(T),{size:16,"aria-hidden":`true`}),P(),N(T);var E=H(T,2);Ns(V(E),{size:16,"aria-hidden":`true`}),P(),N(E),N(w);var D=H(w,2),O=e=>{var n=GC(),r=V(n),i=H(r,2),a=e=>{var n=WC(),r=Cn(n);kn(r),Z(r,`rows`,3);var i=H(r,2),a=e=>{var n=HC(),r=V(n,!0);N(n),U(()=>J(r,t.draftError)),q(e,n)};Y(i,e=>{t.draftError&&e(a)});var o=H(i,2),s=e=>{q(e,UC())};Y(o,e=>{t.draftLoading&&e(s)});var c=H(o,2),l=V(c);N(c),U(()=>{r.disabled=t.draftLoading,l.disabled=t.draftLoading||W(v)===``}),wa(r,()=>W(_),e=>B(_,e)),G(`click`,l,()=>{t.onDraft(W(v))}),q(e,n)};Y(i,e=>{W(g)&&e(a)}),N(n),U(()=>Z(r,`aria-expanded`,W(g))),G(`click`,r,()=>B(g,!W(g))),q(e,n)};Y(D,e=>{t.draftAvailable&&t.working===void 0&&e(O)});var k=H(D,2),A=e=>{var r=sw();{let e=(e,n=x,r=x)=>{var i=KC(),a=V(i);as(V(a),{size:16,"aria-hidden":`true`}),P(),N(a);var o=H(a,2);Vs(V(o),{size:16,"aria-hidden":`true`}),P(),N(o),N(i),U(()=>a.disabled=r()),G(`click`,a,function(...e){n()?.apply(this,e)}),G(`click`,o,()=>t.optimizeDraft?t.onCancelDraft():t.onCancelEdit()),q(e,i)};var i=V(r),a=e=>{var n=$C(),r=Cn(n),i=V(r),a=e=>{q(e,si(`Not chart-verified. The AI moved your waypoints to find safer water.`))},o=e=>{q(e,si(`Not chart-verified.`))};Y(i,e=>{t.draft.source===`optimize`?e(a):e(o,-1)}),P(),N(r);var s=H(r,2),c=e=>{q(e,qC())};Y(s,e=>{t.draft.confidence===`low`&&e(c)});var l=H(s,2),u=e=>{var n=JC(),r=V(n);N(n),U(()=>J(r,`Read as: ${t.draft.destination??``}`)),q(e,n)};Y(l,e=>{t.draft.destination&&e(u)});var d=H(l,2),f=e=>{var n=JC(),r=V(n,!0);N(n),U(()=>J(r,t.draft.note)),q(e,n)};Y(d,e=>{t.draft.note&&e(f)});var p=H(d,2),m=e=>{var n=JC(),r=V(n,!0);N(n),U(()=>J(r,t.draft.fuel)),q(e,n)};Y(p,e=>{t.draft.fuel&&e(m)});var h=H(p,2),g=e=>{var n=QC();Ei(n,21,()=>t.draft.flags,Si,(e,t)=>{var n=ZC(),r=V(n),i=H(r),a=e=>{var n=XC();Ei(n,21,()=>W(t).detail,Si,(e,t)=>{var n=YC(),r=V(n,!0);N(n),U(()=>J(r,W(t))),q(e,n)}),N(n),q(e,n)};Y(i,e=>{W(t).detail&&e(a)}),N(n),U(()=>J(r,`${W(t).message??``} `)),q(e,n)}),N(n),q(e,n)};Y(h,e=>{t.draft.flags&&t.draft.flags.length>0&&e(g)}),q(e,n)};Y(i,e=>{t.draft&&e(a)});var o=H(i,2),l=e=>{let n=R(()=>t.working.waypoints.length),r=R(()=>W(n)>25);var i=rw(),a=Cn(i),o=V(a);ps(V(o),{size:16,"aria-hidden":`true`}),P(),N(o);var s=H(o,2);N(a);var c=H(a,2),l=e=>{var t=ew();X(t),wa(t,()=>W(S),e=>B(S,e)),q(e,t)};Y(c,e=>{W(b)&&e(l)});var u=H(c,2),d=e=>{var t=JC(),n=V(t);N(t),U(()=>J(n,`Simplify the route to optimize it: the limit is 25 waypoints.`)),q(e,t)};Y(u,e=>{W(r)&&e(d)});var f=H(u,2),p=e=>{q(e,tw())};Y(f,e=>{t.draftLoading&&e(p)});var m=H(f,2),h=e=>{q(e,nw())};Y(m,e=>{t.optimizeUnchanged&&e(h)}),U(()=>{o.disabled=t.draftLoading||W(n)<2||W(r),Z(s,`aria-expanded`,W(b)),s.disabled=t.draftLoading}),G(`click`,o,()=>t.onOptimize(W(S).trim())),G(`click`,s,()=>B(b,!W(b))),q(e,i)};Y(o,e=>{t.draftAvailable&&t.draft===void 0&&e(l)});var d=H(o,2),m=H(V(d),2),h=V(m),g=V(h,!0);N(h),P(),N(m);var _=H(m,4),v=V(_),w=V(v,!0);N(v),P(2),N(_);var T=H(_,4),E=V(T),D=V(E,!0);N(E);var O=H(E,2),k=V(O,!0);N(O),N(T),N(d);var A=H(d,2);m_(A,{label:`Plan speed`,unit:`kn`,get value(){return t.planningSpeed.value},min:0,step:.5,inputWidth:`4rem`,onCommit:e=>t.planningSpeed.set(Math.max(0,e))});var ee=H(A,2),te=e=>{var n=aw();Ei(n,21,()=>W(c),e=>e.fromIndex,(e,n)=>{let r=R(()=>Cd(W(n).cumulativeMeters,W(s)));var i=iw(),a=V(i);let o;var c=V(a),l=V(c,!0);N(c);var d=H(c,2),f=V(d);N(d);var p=H(d,2),m=V(p);N(p);var h=H(p,2),g=V(h,!0);N(h),N(a),N(i),U((e,t,r,i,s)=>{o=ta(a,1,`leg-row svelte-813ore`,null,o,e),Z(a,`aria-pressed`,t),Z(a,`aria-label`,`Highlight leg ${W(n).fromIndex+1}`),J(l,W(n).fromIndex+1),J(f,`${r??``} nm`),J(m,`${i??``}°T`),J(g,s)},[()=>({"is-on":W(u).has(W(n).fromIndex)}),()=>W(u).has(W(n).fromIndex),()=>Wc(W(n).distanceMeters),()=>Bc(W(n).bearingRad),()=>W(r)==null?`--`:El(W(r))]),G(`click`,a,()=>t.onHighlightLeg(W(n).fromIndex)),q(e,i)}),N(n),q(e,n)};Y(ee,e=>{W(c).length>0&&e(te)});var j=H(ee,4),ne=n=>{var r=ow(),i=V(r);X(i);var a=H(i,2),o=e=>{Wg(e,{question:`I checked every leg. Save this route?`,onConfirm:()=>{B(y,!1),t.onSave(W(C).trim()||t.draft.name)},onCancel:()=>B(y,!1)})},s=n=>{e(n,()=>()=>B(y,!0),()=>t.working.waypoints.length<2)};Y(a,e=>{W(y)?e(o):e(s,-1)}),N(r),wa(i,()=>W(C),e=>B(C,e)),q(n,r)},re=r=>{e(r,()=>n,()=>t.working.waypoints.length<2)};Y(j,e=>{t.draft?e(ne):e(re,-1)}),N(r),U(()=>{J(g,t.working.waypoints.length),J(w,W(f)),J(D,W(p)?W(p).value:`--`),J(k,W(p)?W(p).unit:``)})}q(e,r)};Y(k,e=>{t.working&&e(A)}),Qg(H(k,2),{heading:`Saved routes`,get items(){return W(o)},empty:`No routes yet`,key:({route:e})=>e.id,isActive:({route:e})=>e.id===t.activeId,card:(e,n)=>{let a=()=>n?.().route,o=()=>n?.().distanceNm;var s=fw(),c=Cn(s),l=V(c),u=V(l,!0);N(l);var d=H(l,2),f=e=>{q(e,cw())};Y(d,e=>{a().id===t.activeId&&e(f)}),N(c);var p=H(c,2),m=H(V(p),2),h=V(m),g=V(h,!0);N(h),P(),N(m);var _=H(m,4),v=V(_),y=V(v,!0);N(v),N(_),N(p);var b=H(p,2),x=e=>{{let n=R(()=>a().id===t.activeId?`Delete this route and stop navigating?`:`Delete this route?`);Wg(e,{get question(){return W(n)},onConfirm:()=>i(a().id),onCancel:()=>B(r,void 0)})}},S=e=>{var n=dw(),i=V(n);{let e=R(()=>t.shownIds.has(a().id));g_(i,{get shown(){return W(e)},onToggle:()=>t.onToggleShown(a().id,!t.shownIds.has(a().id))})}var o=H(i,2);_s(V(o),{size:18,"aria-hidden":`true`}),N(o);var s=H(o,2);Ka(V(s),{size:18,"aria-hidden":`true`}),N(s);var c=H(s,2);_o(V(c),{size:18,"aria-hidden":`true`}),N(c);var l=H(c,2),u=e=>{var n=lw();ys(V(n),{size:18,"aria-hidden":`true`}),N(n),G(`click`,n,function(...e){t.onStop?.apply(this,e)}),q(e,n)},d=e=>{var n=uw();Uo(V(n),{size:18,"aria-hidden":`true`}),N(n),U(()=>n.disabled=t.working!==void 0),G(`click`,n,()=>t.onActivate(a().id)),q(e,n)};Y(l,e=>{a().id===t.activeId?e(u):e(d,-1)});var f=H(l,2);Ds(V(f),{size:18,"aria-hidden":`true`}),N(f),N(n),U(()=>o.disabled=t.working!==void 0),G(`click`,o,()=>t.onEditRoute(a().id)),G(`click`,s,()=>t.onReverse(a().id)),G(`click`,c,()=>t.onExportGpx(a().id)),G(`click`,f,()=>B(r,a().id,!0)),q(e,n)};Y(b,e=>{W(r)===a().id?e(x):e(S,-1)}),U(()=>{J(u,a().name),J(g,o()),J(y,a().waypoints.length)}),G(`click`,l,()=>t.onLocate(a().id)),q(e,s)},$$slots:{card:!0}}),U(()=>T.disabled=t.working!==void 0),G(`click`,T,function(...e){t.onNew?.apply(this,e)}),G(`click`,E,a),q(e,d)},$$slots:{default:!0}})}et()}Qr([`click`]);function hw(e){let t=e.waypoints.map((e,t)=>{let n=hC(e.name??`${t+1}`);return` <rtept lat="${e.position.latitude}" lon="${e.position.longitude}"><name>${n}</name></rtept>`}).join(`
763
+ `);return`<?xml version="1.0" encoding="UTF-8"?>
764
+ <gpx version="1.1" creator="Binnacle" xmlns="http://www.topografix.com/GPX/1/1">
765
+ <rte>
766
+ <name>${hC(e.name)}</name>
767
+ ${t}
768
+ </rte>
769
+ </gpx>
770
+ `}function gw(e){pc(`${e.name||`route`}.gpx`,hw(e),`application/gpx+xml`)}var _w=`/signalk/v2/api/resources/routes`,vw=`/signalk/v1/api/resources/routes`;function yw(e,t){return bu(e,[_w,vw],t,rf)}function bw(e){return`/resources/routes/${encodeURIComponent(e)}`}function xw(e,t,n){return Cu(`${e}${_w}/${encodeURIComponent(n.id)}`,t,nf(n))}function Sw(e,t,n){return wu(`${e}${_w}/${encodeURIComponent(n)}`,t)}var Cw=K(`<span class="glyph svelte-15g5e41"><!></span>`),ww=K(`<button type="button" class="icon-pill"><!></button>`);function Tw(e,t){$e(t,!0);let n={day:Cs,dusk:Ts,"night-red":Vo},r={day:`Day theme`,dusk:`Dusk theme`,"night-red":`Night theme`},i=R(()=>n[t.controller.theme]),a=R(()=>r[t.controller.theme]);var o=ww();xi(V(o),()=>t.controller.theme,e=>{var t=Cw();Ni(V(t),()=>W(i),(e,t)=>{t(e,{size:20,"aria-hidden":`true`})}),N(t),Hi(1,t,()=>Dg,()=>({start:.5,duration:Sc()?0:200})),q(e,t)}),N(o),U(()=>{Z(o,`aria-label`,`Switch theme (currently ${W(a)})`),Z(o,`title`,W(a))}),G(`click`,o,()=>t.controller.cycle()),q(e,o),et()}Qr([`click`]);var Ew=`tides`,Dw=`/signalk/v2/api/resources/tides`,Ow=48,kw=`Local tides (signalk-tides)`;function Aw(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`string`){let t=Number.parseFloat(e);if(Number.isFinite(t))return t}}function jw(e){let t=e.type??e.label;if(typeof t==`string`){let e=t.toLowerCase();if(e===`high`)return`high`;if(e===`low`)return`low`}if(e.high===!0)return`high`;if(e.low===!0)return`low`}function Mw(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n,r=jw(e),i=Aw(e.value??e.level),a=typeof e.time==`string`?Date.parse(e.time):NaN;!r||i===void 0||!Number.isFinite(a)||t.push({timeMs:a,heightMeters:i,kind:r})}return t.sort((e,t)=>e.timeMs-t.timeMs)}function Nw(e,t,n){let r=e&&typeof e==`object`?e:{},i=r.position&&typeof r.position==`object`?r.position:void 0,a=Aw(r.latitude??i?.latitude),o=Aw(r.longitude??i?.longitude);return{id:typeof r.id==`string`&&r.id.length>0?r.id:Ew,name:typeof r.name==`string`&&r.name.length>0?r.name:kw,latitude:a??t,longitude:o??n}}function Pw(e,t,n,r){if(!e||typeof e!=`object`||Array.isArray(e))return;let i=e,a=new Date(r),o=Date.UTC(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate()),s=o+Ow*Ac,c=Mw(i.extremes).filter(e=>e.timeMs>=o&&e.timeMs<=s);if(c.length===0)return;let l=Nw(i.station,t,n);return{station:l,distanceMeters:fd(t,n,l.latitude,l.longitude),events:c}}async function Fw(e,t,n={}){try{let r=await fetch(`${n.origin??``}${Dw}`,hc(gu(n.token)));return r.ok?Pw(await r.json(),e,t,n.now?.()??Date.now()):void 0}catch{return}}function Iw(e){return`${e.toFixed(2)} m`}function Lw(e){return`${(Qc(e)??0).toFixed(1)} ft`}function Rw(e,t){return t===`imperial`?Lw(e):Iw(e)}function zw(e,t){return t===`imperial`?Iw(e):Lw(e)}function Bw(e){return`${Gc(e)} kn`}function Vw(e,t){let n=t===`imperial`?e/Xc:e/1e3,r=pl(t);return n<1?`<1 ${r}`:`${Math.round(n)} ${r}`}function Hw(e){return e===`signalk-tides`?`Predictions from the signalk-tides plugin.`:e===`noaa-coops`?`Predictions from NOAA CO-OPS.`:``}function Uw(e,t){return e.filter(e=>e.timeMs>=t)}function Ww(e,t){return e.find(e=>e.timeMs>=t&&e.kind!==`slack`)}function Gw(e){if(e.length===0)return[];let t=e[0].timeMs,n=e[e.length-1].timeMs-t||1,r=e[0].heightMeters,i=r;for(let t of e)t.heightMeters<r?r=t.heightMeters:t.heightMeters>i&&(i=t.heightMeters);let a=i-r||1;return e.map(e=>({x:(e.timeMs-t)/n,y:(e.heightMeters-r)/a}))}function Kw(e,t){if(e.length===0)return;let n=e[0].timeMs,r=e[e.length-1].timeMs;if(!(t<n||t>r))return(t-n)/(r-n||1)}var qw=K(`<button type="button">Show stations on chart</button>`),Jw=K(`<p class="muted-note" role="status">Finding nearby tide stations...</p>`),Yw=K(`<p class="muted-note" role="status">No tide station nearby. NOAA tide predictions cover US waters only.</p>`),Xw=K(`<span class="num svelte-1bve9ga"> </span> `,1),Zw=K(`<span class="num svelte-1bve9ga">--</span>`),Qw=oi(`<line class="now svelte-1bve9ga" y1="0"></line>`),$w=oi(`<svg class="curve svelte-1bve9ga" aria-hidden="true"><path class="curve-line svelte-1bve9ga" fill="none"></path><!></svg>`),eT=K(`<div class="current svelte-1bve9ga"><span class="caps-label">Tidal current</span> <span class="name svelte-1bve9ga"> </span> <dl class="stats svelte-1bve9ga"><dt class="svelte-1bve9ga"> </dt> <dd class="svelte-1bve9ga"><!></dd></dl></div>`),tT=K(`<p class="muted-note stale svelte-1bve9ga" role="status">Showing the last update; the latest refresh did not reach NOAA.</p>`),nT=K(`<p class="muted-note source-note svelte-1bve9ga"> </p>`),rT=K(`<div class="station svelte-1bve9ga"><span class="name svelte-1bve9ga"> </span> <span class="dist caps-label svelte-1bve9ga"> </span></div> <dl class="stats svelte-1bve9ga"><dt class="svelte-1bve9ga">Next high</dt> <dd class="svelte-1bve9ga"><!></dd> <dt class="svelte-1bve9ga">Next low</dt> <dd class="svelte-1bve9ga"><!></dd></dl> <!> <!> <!> <!> <p class="footnote svelte-1bve9ga">Heights above MLLW, times in the device's local time.</p>`,1),iT=K(`<p class="muted-note stale svelte-1bve9ga" role="status">Could not load tide predictions. Check the connection.</p>`),aT=K(`<p class="muted-note" role="status">Pan to a US coast to see tide predictions.</p>`),oT=K(`<!> <!>`,1);function sT(e,t){$e(t,!0);let n=Na(t,`stationsShown`,3,!1),r=R(()=>t.store.tide),i=R(()=>t.store.current),a=R(()=>W(r)?Vw(W(r).distanceMeters,t.units.mode):``),o=new sc(6e4);Fa(()=>o.dispose());let s=R(()=>W(r)?Uw(W(r).events,o.now):[]),c=R(()=>W(s).find(e=>e.kind===`high`)),l=R(()=>W(s).find(e=>e.kind===`low`)),u=R(()=>W(r)?Gw(W(r).events):[]),d=R(()=>W(r)?Kw(W(r).events,o.now):void 0),f=R(()=>W(i)?Ww(W(i).events,o.now):void 0),p=R(()=>Hw(t.store.source)),m=R(()=>W(f)?`${Bw(W(f).velocityMps)}${W(f).directionRad===void 0?``:`, ${Math.round(W(f).directionRad/Oc)}°`}`:``);function h(e){if(e.length===0)return``;let t=e=>e.x*240,n=e=>(1-e.y)*52+4,r=`M ${t(e[0]).toFixed(1)} ${n(e[0]).toFixed(1)}`;for(let i=1;i<e.length;i++){let a=e[i-1],o=e[i],s=(t(a)+t(o))/2,c=(n(a)+n(o))/2;r+=` Q ${t(a).toFixed(1)} ${n(a).toFixed(1)} ${s.toFixed(1)} ${c.toFixed(1)}`}let i=e[e.length-1];return r+=` L ${t(i).toFixed(1)} ${n(i).toFixed(1)}`,r}i_(e,{title:`Tides`,get onClose(){return t.onClose},get onBack(){return t.onBack},children:(e,o)=>{var s=oT(),g=Cn(s),_=e=>{var r=qw();let i;U(()=>{i=ta(r,1,`btn stations svelte-1bve9ga`,null,i,{"is-on":n()}),Z(r,`aria-pressed`,n())}),G(`click`,r,()=>t.onToggleStations(!n())),q(e,r)};Y(g,e=>{t.onToggleStations&&e(_)});var v=H(g,2),y=e=>{q(e,Jw())},b=e=>{q(e,Yw())},x=e=>{var n=rT(),o=Cn(n),s=V(o),g=V(s,!0);N(s);var _=H(s,2),v=V(_);N(_),N(o);var y=H(o,2),b=H(V(y),2),x=V(b),S=e=>{var n=Xw(),r=Cn(n),i=V(r,!0);N(r);var a=H(r);U((e,t,n)=>{J(i,e),J(a,`,
771
+ ${t??``}
772
+ (${n??``})`)},[()=>Cl(W(c).timeMs),()=>Rw(W(c).heightMeters,t.units.mode),()=>zw(W(c).heightMeters,t.units.mode)]),q(e,n)},C=e=>{q(e,Zw())};Y(x,e=>{W(c)?e(S):e(C,-1)}),N(b);var w=H(b,4),T=V(w),E=e=>{var n=Xw(),r=Cn(n),i=V(r,!0);N(r);var a=H(r);U((e,t,n)=>{J(i,e),J(a,`,
773
+ ${t??``}
774
+ (${n??``})`)},[()=>Cl(W(l).timeMs),()=>Rw(W(l).heightMeters,t.units.mode),()=>zw(W(l).heightMeters,t.units.mode)]),q(e,n)},D=e=>{q(e,Zw())};Y(T,e=>{W(l)?e(E):e(D,-1)}),N(w),N(y);var O=H(y,2),k=e=>{var t=$w();Z(t,`viewBox`,`0 0 240 60`);var n=V(t),r=H(n),i=e=>{var t=Qw();Z(t,`y2`,60),U(()=>{Z(t,`x1`,W(d)*240),Z(t,`x2`,W(d)*240)}),q(e,t)};Y(r,e=>{W(d)!==void 0&&e(i)}),N(t),U(e=>Z(n,`d`,e),[()=>h(W(u))]),q(e,t)};Y(O,e=>{W(u).length>1&&e(k)});var A=H(O,2),ee=e=>{var t=eT(),n=H(V(t),2),r=V(n,!0);N(n);var a=H(n,2),o=V(a),s=V(o);N(o);var c=H(o,2),l=V(c),u=e=>{var t=Xw(),n=Cn(t),r=V(n,!0);N(n);var i=H(n);U(e=>{J(r,e),J(i,`, ${W(m)??``}`)},[()=>Cl(W(f).timeMs)]),q(e,t)},d=e=>{q(e,Zw())};Y(l,e=>{W(f)?e(u):e(d,-1)}),N(c),N(a),N(t),U(()=>{Z(n,`title`,W(i).station.name),J(r,W(i).station.name),J(s,`Next ${W(f)?.kind===`ebb`?`ebb`:`flood`}`)}),q(e,t)};Y(A,e=>{W(i)&&e(ee)});var te=H(A,2),j=e=>{q(e,tT())};Y(te,e=>{t.store.status===`error`&&e(j)});var ne=H(te,2),re=e=>{var t=nT(),n=V(t,!0);N(t),U(()=>J(n,W(p))),q(e,t)};Y(ne,e=>{W(p)&&e(re)}),P(2),U(()=>{Z(s,`title`,W(r).station.name),J(g,W(r).station.name),J(v,`${W(a)??``} away`)}),q(e,n)},S=e=>{q(e,iT())},C=e=>{q(e,aT())};Y(v,e=>{!W(r)&&t.store.status===`loading`?e(y):t.store.status===`no-coverage`?e(b,1):W(r)?e(x,2):t.store.status===`error`?e(S,3):e(C,-1)}),q(e,s)},$$slots:{default:!0}}),et()}Qr([`click`]);var cT=`https://api.tidesandcurrents.noaa.gov/mdapi/prod/webapi/stations.json`,lT=`https://api.tidesandcurrents.noaa.gov/api/prod/datagetter`,uT=48;function dT(e){return new Date(`${e.replace(` `,`T`)}Z`).getTime()}function fT(e,t=``){let n=new Date(e),r=String(n.getUTCMonth()+1).padStart(2,`0`),i=String(n.getUTCDate()).padStart(2,`0`);return`${n.getUTCFullYear()}${t}${r}${t}${i}`}async function pT(e){let t=await fetch(e,hc());if(!t.ok)throw Error(`CO-OPS ${t.status}`);let n=await t.json();if(n&&typeof n==`object`&&`error`in n)throw Error(`CO-OPS error response`);return n}async function mT(e){return((await pT(`${cT}?type=${e}`)).stations??[]).map(e=>({id:e.id,name:e.name,latitude:e.lat,longitude:e.lng}))}function hT(){return mT(`tidepredictions`)}function gT(){return mT(`currentpredictions`)}async function _T(e){return((await pT(`${lT}?product=predictions&interval=hilo&datum=MLLW&units=metric&time_zone=gmt&format=json&begin_date=${fT(Date.now())}&range=${uT}&station=${e}`)).predictions??[]).flatMap(e=>{let t=dT(e.t),n=Number.parseFloat(e.v);return!bc(t)||!bc(n)?[]:[{timeMs:t,heightMeters:n,kind:e.type===`H`?`high`:`low`}]})}async function vT(e){return((await pT(`${lT}?product=currents_predictions&units=metric&time_zone=gmt&format=json&begin_date=${fT(Date.now())}&range=${uT}&interval=MAX_SLACK&station=${e}`)).current_predictions?.cp??[]).flatMap(e=>{let t=dT(e.Time);if(!bc(t)||!bc(e.Velocity_Major))return[];let n=e.Type===`flood`?`flood`:e.Type===`ebb`?`ebb`:`slack`,r=n===`flood`?e.meanFloodDir:n===`ebb`?e.meanEbbDir:void 0,i=r===void 0?void 0:r*Oc;return[{timeMs:t,velocityMps:Math.abs(e.Velocity_Major)/100,directionRad:i,kind:n}]})}function yT(e,t,n,r,i){return e.map(e=>({station:e,distanceMeters:fd(t,n,e.latitude,e.longitude)})).filter(e=>e.distanceMeters<=i).sort((e,t)=>e.distanceMeters-t.distanceMeters).slice(0,r)}var bT=1e5,xT=6e4,ST=6,CT=jc,wT=5*kc,TT=24,ET=3e3,DT=7*jc,OT=56,kT=`stations:tide`,AT=`stations:current`;function jT(e){let t=new Date(e);return Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())+jc+2*jc}var MT={tideStations:hT,currentStations:gT,tideEvents:_T,currentEvents:vT,now:()=>Date.now(),persist:lm(`binnacle-tides-data`,{maxEntries:OT}),pluginAvailable:()=>!1,pluginTides:(e,t)=>Fw(e,t)},NT=e=>fT(e,`-`);function PT(e={}){let t={...MT,...e},n,r,i=0,a=new um(TT),o=new um(TT),s=0,c=!1,l,u,d;async function f(e){if(n&&r&&e-i<CT)return;if(!n||!r){let[a,o]=await Promise.all([t.persist.get(kT),t.persist.get(AT)]);if(a&&a.expires>e&&o&&o.expires>e){n=a.value,r=o.value,i=e,t.persist.prune(e);return}}let[a,o]=await Promise.all([t.tideStations(),t.currentStations()]);n=a,r=o,i=e,await Promise.all([t.persist.put(kT,a,e+DT),t.persist.put(AT,o,e+DT)]),t.persist.prune(e)}async function p(e,n,r,i,a,o){let s=e.get(i,a);if(s&&s.day===o)return s.events;let c=`${n}:${i}:${o}`,l=await t.persist.get(c);if(l&&l.expires>a){let n=l.value;return e.put(i,{events:n,day:o},a),t.persist.prune(a),n}let u=await r(i);return e.put(i,{events:u,day:o},a),await t.persist.put(c,u,jT(a)),t.persist.prune(a),u}async function m(e,n,i,a){let s=yT(r??[],e,n,ST,xT);for(let e of s){let n=await p(o,`current`,t.currentEvents,e.station.id,i,a);if(n.length>0)return{station:e.station,distanceMeters:e.distanceMeters,events:n}}}async function h(e,t,n,r){try{return await f(n),await m(e,t,n,r)}catch{return}}return{async load(e,r,i){let o=t.now();if(!(c||o<s)&&!((e.status===`ready`||e.status===`no-coverage`)&&l!==void 0&&u!==void 0&&NT(o)===d&&fd(l,u,r,i)<ET)){c=!0,e.setLoading();try{let s=NT(o);if(t.pluginAvailable()){let n=`plugin:${oc(r)},${oc(i)}:${s}`,a=await t.pluginTides(r,i).catch(()=>void 0),c=a!==void 0;if(!a){let e=await t.persist.get(n);if(e&&e.expires>o){let n=e.value;a={...n,distanceMeters:fd(r,i,n.station.latitude,n.station.longitude)},t.persist.prune(o)}}if(a&&a.distanceMeters<=bT){l=r,u=i,d=s,c&&(await t.persist.put(n,a,jT(o)),t.persist.prune(o));let f=await h(r,i,o,s);e.setReadings(a,f,`signalk-tides`);return}}await f(o),l=r,u=i,d=s;let c=yT(n??[],r,i,1,bT)[0];if(!c){e.setNoCoverage();return}let[g,_]=await Promise.all([p(a,`tide`,t.tideEvents,c.station.id,o,s),m(r,i,o,s)]),v={station:c.station,distanceMeters:c.distanceMeters,events:g};e.setReadings(v,_,`noaa-coops`)}catch{s=t.now()+wT,e.setError()}finally{c=!1}}}}}var FT=`binnacle-tides`,IT=`binnacle-tides-circle`,LT=`binnacle-tides-label`,RT=[IT,LT],zT=Gm();function BT(e,t,n){let r=Uw(e.events,t)[0];if(!r)return e.station.name;let i=r.kind===`high`?`High`:`Low`;return`${e.station.name}\n${i} ${Rw(r.heightMeters,n)} ${Cl(r.timeMs)}`}function VT(e,t){let n=Ww(e.events,t);if(!n)return e.station.name;let r=n.kind===`flood`?`Flood`:`Ebb`;return`${e.station.name}\n${r} ${Bw(n.velocityMps)} ${Cl(n.timeMs)}`}function HT(e,t,n,r){let i=[];return e&&i.push({type:`Feature`,geometry:{type:`Point`,coordinates:[e.station.longitude,e.station.latitude]},properties:{label:BT(e,n,r)}}),t&&i.push({type:`Feature`,geometry:{type:`Point`,coordinates:[t.station.longitude,t.station.latitude]},properties:{label:VT(t,n)}}),{type:`FeatureCollection`,features:i}}function UT(e,t){let n,r,i=!1,a=-1,o;return{id:`tides`,title:`Tide stations`,band:`safety`,category:`live`,supportsOpacity:!0,defaultVisible:!1,layerIds:RT,reset(){i=!1,n=void 0,r=void 0,a=-1,o=void 0},add(e){let t=hf(`day`),n=e.beforeIdFor(`safety`);if(!e.map.getSource(FT)){let t={type:`geojson`,data:zT};e.map.addSource(FT,t)}let r={id:IT,type:`circle`,source:FT,paint:{"circle-radius":6,"circle-color":t.tide,"circle-stroke-color":t.background,"circle-stroke-width":2}};e.map.getLayer(IT)||e.map.addLayer(r,n);let i={id:LT,type:`symbol`,source:FT,layout:{"text-field":[`get`,`label`],"text-font":[`Noto Sans Regular`],"text-size":11,"text-offset":[0,1.1],"text-anchor":`top`,"text-optional":!0,"text-max-width":12},paint:{"text-color":t.tide,"text-halo-color":t.background,"text-halo-width":1.2}};e.map.getLayer(LT)||e.map.addLayer(i,n)},sync(s){let c=e.tide,l=e.current,u=t.mode,d=Date.now(),f=Math.floor(d/kc);i&&c===n&&l===r&&f===a&&u===o||(i=!0,n=c,r=l,a=f,o=u,s.map.getSource(FT)?.setData(HT(c,l,d,u)))},setVisible(e,t){let n=t?`visible`:`none`;for(let t of RT)e.map.setLayoutProperty(t,`visibility`,n)},setOpacity(e,t){e.map.setPaintProperty(IT,`circle-opacity`,t),e.map.setPaintProperty(IT,`circle-stroke-opacity`,t),e.map.setPaintProperty(LT,`text-opacity`,t)},applyTheme(e,t){e.map.setPaintProperty(IT,`circle-color`,t.tide),e.map.setPaintProperty(IT,`circle-stroke-color`,t.background),e.map.setPaintProperty(LT,`text-color`,t.tide),e.map.setPaintProperty(LT,`text-halo-color`,t.background)},remove(e){for(let t of RT)e.map.getLayer(t)&&e.map.removeLayer(t);e.map.getSource(FT)&&e.map.removeSource(FT)}}}var WT=`binnacle-track-history`,GT=`binnacle-track-history-line`,KT=`track`,qT=2,JT=.6,YT=[2,2],XT=1440*60,ZT=60,QT=Ac/4,$T=900;function eE(e,t,n,r={fetchValues:ku,now:Date.now}){let i=hf(`day`),a=!0,o=!1,s=0;function c(e,t){e.map.getSource(WT)?.setData(t)}function l(e){let t=[],n=[],r;for(let i of e){let e=i[1];if(!Zs(e))continue;let a=Date.parse(i[0])/1e3;Number.isFinite(a)&&(r!==void 0&&a-r>$T&&(n.length>1&&t.push(n),n=[]),n.push([e.longitude,e.latitude]),r=a)}return n.length>1&&t.push(n),{type:`FeatureCollection`,features:t.map(e=>({type:`Feature`,geometry:{type:`LineString`,coordinates:e},properties:{}}))}}async function u(i){let a=n();if(!(!a||a.ids.length===0||o)){o=!0;try{let n=await r.fetchValues(e,t,a,{paths:[$.position],durationSeconds:XT,resolutionSeconds:ZT});n&&c(i,l(n.values.rows)),s=r.now()+QT}finally{o=!1}}}return{id:`track-history`,title:`Track history (24 h)`,band:KT,supportsOpacity:!0,defaultVisible:!1,layerIds:[GT],add(e){if(s=0,!e.map.getSource(WT)){let t={type:`geojson`,data:Gm()};e.map.addSource(WT,t)}if(!e.map.getLayer(GT)){let t={id:GT,type:`line`,source:WT,layout:{"line-cap":`round`,"line-join":`round`},paint:{"line-color":i.trackSolid,"line-width":qT,"line-opacity":JT,"line-dasharray":YT}};e.map.addLayer(t,e.beforeIdFor(KT))}},sync(e){if(!a)return;let t=r.now();t<s||(s=t+QT,u(e))},setVisible(e,t){a=t,e.map.getLayer(GT)&&e.map.setLayoutProperty(GT,`visibility`,t?`visible`:`none`),t&&(s=0)},setOpacity(e,t){e.map.getLayer(GT)&&e.map.setPaintProperty(GT,`line-opacity`,JT*t)},applyTheme(e,t){i=t,e.map.getLayer(GT)&&e.map.setPaintProperty(GT,`line-color`,i.trackSolid)},remove(e){e.map.getLayer(GT)&&e.map.removeLayer(GT),e.map.getSource(WT)&&e.map.removeSource(WT)}}}function tE(e,t,n){let r=n.lon-t.lon,i=n.lat-t.lat,a=r*r+i*i;if(a===0)return Math.hypot(e.lon-t.lon,e.lat-t.lat);let o=((e.lon-t.lon)*r+(e.lat-t.lat)*i)/a;return Math.hypot(e.lon-(t.lon+o*r),e.lat-(t.lat+o*i))}function nE(e,t){let n=e.length;if(n<=2)return e;let r=Array(n).fill(!1);r[0]=!0,r[n-1]=!0;let i=[[0,n-1]];for(;i.length>0;){let[n,a]=i.pop(),o=0,s=-1;for(let t=n+1;t<a;t+=1){let r=tE(e[t],e[n],e[a]);r>o&&(o=r,s=t)}o>t&&s!==-1&&(r[s]=!0,i.push([n,s]),i.push([s,a]))}let a=[];for(let t=0;t<n;t+=1)r[t]&&a.push(e[t]);return a}function rE(e,t){if(e.length<=2)return e.slice();let n=[];for(let r of $h(e))n.push(...nE(r,t));return n}function iE(e){let t=[];for(let n=1;n<e.length;n+=1){let r=e[n];if(r.gap)continue;let i=e[n-1];t.push({type:`Feature`,geometry:{type:`LineString`,coordinates:[Qh(i),Qh(r)]},properties:{sog:r.sog}})}return{type:`FeatureCollection`,features:t}}var aE=`binnacle-track-active`,oE=`binnacle-track-active-line`,sE=`binnacle-track-saved`,cE=`binnacle-track-saved-line`,lE=`track`,uE=8e-5,dE=4096,fE=2.5,pE=5,mE={features:()=>Gm(),version:()=>0};function hE(e,t){return t===`solid`?e.trackSolid:[`interpolate`,[`linear`],[`get`,`sog`],0,e.trackSlow,fE,e.trackMid,pE,e.trackFast]}function gE(e,t,n=mE){let r=hf(`day`),i=-1,a,o,s=-1,c=[],l=0;function u(){c=[],l=0}function d(e){return c.length>0?c.slice(0,-1).concat(e):e}function f(){let t=e.points;l>t.length&&u();let n=t.slice(l),r=rE(n,uE);if(n.length<=dE||r.length<3)return d(r);let i=Math.floor(n.length/2),a=1,o=0,s=!1,f=0;for(let e=1;e<r.length-1;e+=1){for(;n[f]!==r[e];)f+=1;if(s&&f>i)break;a=e,o=f,s=!0}let p=r.slice(0,a+1);return c=c.length>0?c.slice(0,-1).concat(p):p,l+=o,d(rE(t.slice(l),uE))}function p(e){e.map.getSource(aE)?.setData(iE(f()))}return{id:`track`,title:`Tracks`,band:lE,supportsOpacity:!0,layerIds:[cE,oE],add(e){i=-1,a=void 0,o=void 0,s=-1,u();let n=e.beforeIdFor(lE),c={type:`geojson`,data:Gm()};e.map.addSource(aE,c),e.map.addSource(sE,{type:`geojson`,data:Gm()});let l={id:cE,type:`line`,source:sE,layout:{"line-cap":`round`,"line-join":`round`},paint:{"line-color":r.trackSolid,"line-width":2}};e.map.addLayer(l,n);let d={id:oE,type:`line`,source:aE,layout:{"line-cap":`round`,"line-join":`round`},paint:{"line-color":hE(r,t.value.colorMode),"line-width":3}};e.map.addLayer(d,n)},sync(c){let l=t.value.colorMode,u=e.points,d=u[u.length-1]?.t;(u.length!==i||d!==a)&&(i=u.length,a=d,p(c)),l!==o&&(o=l,c.map.setPaintProperty(oE,`line-color`,hE(r,l)));let f=n.version();f!==s&&(s=f,c.map.getSource(sE)?.setData(n.features()))},applyTheme(e,n){r=n,e.map.setPaintProperty(oE,`line-color`,hE(r,t.value.colorMode)),e.map.setPaintProperty(cE,`line-color`,r.trackSolid)},setVisible(e,t){Pf(e.map,[oE,cE],t)},setOpacity(e,t){e.map.setPaintProperty(oE,`line-opacity`,t),e.map.setPaintProperty(cE,`line-opacity`,t)},remove(e){Ff(e.map,[oE,cE],[aE,sE])}}}var _E=100;function vE(e,t,n=_E){let r=rE(e,n/md).map(e=>({position:{latitude:e.lat,longitude:e.lon}}));return{id:vc(),name:t,waypoints:r}}var yE=K(`<p class="alert-note" role="alert"> </p>`),bE=K(`<button type="button" class="btn"><!> Resume</button>`),xE=K(`<button type="button" class="btn"><!> Pause</button>`),SE=K(`<div class="actions"><!> <button type="button" class="icon-btn" aria-label="Export GeoJSON" title="Export GeoJSON"><!></button> <button type="button" class="icon-btn icon-btn--danger" aria-label="Delete track" title="Delete"><!></button></div>`),CE=K(`<div class="card-head"><span class="name"> </span></div> <dl class="card-stats"><dt class="caps-label">Distance</dt> <dd><span class="num"> </span> nm</dd> <dt class="caps-label">Duration</dt> <dd><span class="num"> </span></dd></dl> <!>`,1),wE=K(`<!> <div class="panel-controls"><!> <button type="button" class="btn btn-primary"><!> Save</button> <button type="button" class="btn btn-danger"><!> Clear</button></div> <!> <div class="color-mode segmented svelte-1td1uw4" role="group" aria-label="Track color"><button type="button">Speed</button> <button type="button">Solid</button></div> <div class="panel-controls"><button type="button" class="btn"><!> Save as route</button> <button type="button" class="btn"><!> Navigate home</button></div> <dl class="stat-grid"><dt>Distance</dt> <dd><span class="num"> </span> <span class="unit">nm</span></dd> <dt>Duration</dt> <dd><span class="num"> </span> <span class="unit"></span></dd> <dt>Avg</dt> <dd><span class="num"> </span> <span class="unit">kn</span></dd> <dt>Max</dt> <dd><span class="num"> </span> <span class="unit">kn</span></dd></dl> <!>`,1);function TE(e,t){$e(t,!0);let n=R(()=>t.recorder.stats),r=R(()=>t.settings.value.colorMode),i=R(()=>t.recorder.points.length>0),a=R(()=>t.saved.map(e=>({track:e,distanceNm:e.distanceMeters==null?`--`:Wc(e.distanceMeters),durationText:e.durationSeconds==null?`--`:El(e.durationSeconds)})));function o(){let e=Kg(`Track`);e!==void 0&&t.onSave(e)}function s(){let e=Kg(`Route`);e!==void 0&&t.onSaveAsRoute(e)}let c=z(!1);function l(){B(c,!1),t.recorder.clear()}let u=z(void 0);function d(e){B(u,void 0),t.onDelete(e)}function f(e){t.settings.set({...t.settings.value,colorMode:e})}i_(e,{title:`Tracks`,bodyFlex:!0,get onClose(){return t.onClose},get onBack(){return t.onBack},children:(e,p)=>{var m=wE(),h=Cn(m),g=e=>{var n=yE(),r=V(n,!0);N(n),U(()=>J(r,t.error)),q(e,n)};Y(h,e=>{t.error&&e(g)});var _=H(h,2),v=V(_),y=e=>{var n=bE();Yo(V(n),{size:16,"aria-hidden":`true`}),P(),N(n),G(`click`,n,()=>t.recorder.resume()),q(e,n)},b=e=>{var n=xE();Go(V(n),{size:16,"aria-hidden":`true`}),P(),N(n),G(`click`,n,()=>t.recorder.pause()),q(e,n)};Y(v,e=>{t.recorder.paused?e(y):e(b,-1)});var x=H(v,2);as(V(x),{size:16,"aria-hidden":`true`}),P(),N(x);var S=H(x,2);yo(V(S),{size:16,"aria-hidden":`true`}),P(),N(S),N(_);var C=H(_,2),w=e=>{Wg(e,{question:`Discard the current track? This cannot be undone.`,confirmLabel:`Discard`,onConfirm:l,onCancel:()=>B(c,!1)})};Y(C,e=>{W(c)&&e(w)});var T=H(C,2),E=V(T);let D;var O=H(E,2);let k;N(T);var A=H(T,2),ee=V(A);ts(V(ee),{size:16,"aria-hidden":`true`}),P(),N(ee);var te=H(ee,2);js(V(te),{size:16,"aria-hidden":`true`}),P(),N(te),N(A);var j=H(A,2),ne=H(V(j),2),re=V(ne),ie=V(re,!0);N(re),P(2),N(ne);var ae=H(ne,4),oe=V(ae),se=V(oe,!0);N(oe),P(2),N(ae);var ce=H(ae,4),le=V(ce),ue=V(le,!0);N(le),P(2),N(ce);var de=H(ce,4),fe=V(de),pe=V(fe,!0);N(fe),P(2),N(de),N(j),Qg(H(j,2),{heading:`Saved tracks`,get items(){return W(a)},empty:`None saved yet`,key:({track:e})=>e.id,card:(e,n)=>{let r=()=>n?.().track,i=()=>n?.().distanceNm,a=()=>n?.().durationText;var o=CE(),s=Cn(o),c=V(s),l=V(c,!0);N(c),N(s);var f=H(s,2),p=H(V(f),2),m=V(p),h=V(m,!0);N(m),P(),N(p);var g=H(p,4),_=V(g),v=V(_,!0);N(_),N(g),N(f);var y=H(f,2),b=e=>{Wg(e,{question:`Delete this track?`,onConfirm:()=>d(r().id),onCancel:()=>B(u,void 0)})},x=e=>{var n=SE(),i=V(n);{let e=R(()=>t.shown.has(r().id));g_(i,{get shown(){return W(e)},onToggle:()=>t.onToggleSaved(r().id)})}var a=H(i,2);_o(V(a),{size:18,"aria-hidden":`true`}),N(a);var o=H(a,2);Ds(V(o),{size:18,"aria-hidden":`true`}),N(o),N(n),G(`click`,a,()=>t.onExport(r())),G(`click`,o,()=>B(u,r().id,!0)),q(e,n)};Y(y,e=>{W(u)===r().id?e(b):e(x,-1)}),U(()=>{Z(c,`title`,r().name),J(l,r().name),J(h,i()),J(v,a())}),q(e,o)},$$slots:{card:!0}}),U((e,n,i,a)=>{x.disabled=t.recorder.points.length<2,S.disabled=t.recorder.points.length===0,D=ta(E,1,`btn svelte-1td1uw4`,null,D,{"is-on":W(r)===`speed`}),Z(E,`aria-pressed`,W(r)===`speed`),k=ta(O,1,`btn svelte-1td1uw4`,null,k,{"is-on":W(r)===`solid`}),Z(O,`aria-pressed`,W(r)===`solid`),ee.disabled=t.recorder.points.length<2,te.disabled=t.recorder.points.length<2,J(ie,e),J(se,n),J(ue,i),J(pe,a)},[()=>W(i)?Wc(W(n).distanceMeters):`--`,()=>W(i)?El(W(n).durationSeconds):`--`,()=>W(i)?Gc(W(n).avgSog):`--`,()=>W(i)?Gc(W(n).maxSog):`--`]),G(`click`,x,o),G(`click`,S,()=>B(c,!0)),G(`click`,E,()=>f(`speed`)),G(`click`,O,()=>f(`solid`)),G(`click`,ee,s),G(`click`,te,function(...e){t.onTrackHome?.apply(this,e)}),q(e,m)},$$slots:{default:!0}}),et()}Qr([`click`]);function EE(e){return $h(e).map(e=>e.map(Qh)).filter(e=>e.length>=2)}function DE(e,t){return{type:`Feature`,geometry:{type:`MultiLineString`,coordinates:EE(t)},properties:{name:e,source:`binnacle`}}}function OE(e,t){return JSON.stringify(DE(e,t),null,2)}function kE(e,t){pc(`${e||`track`}.geojson`,OE(e,t),`application/geo+json`)}function AE(e,t){let n=[];for(let r of e)if(t.has(r.id))for(let e of r.points)e.length<2||n.push({type:`Feature`,geometry:{type:`LineString`,coordinates:e.map(Qh)},properties:{id:r.id}});return{type:`FeatureCollection`,features:n}}var jE=`/signalk/v2/api/resources/tracks`,ME=`/signalk/v1/api/resources/tracks`;function NE(e){if(!e||typeof e!=`object`)return;let t=e;if(t.geometry&&typeof t.geometry==`object`)return t.geometry;if(t.feature?.geometry&&typeof t.feature.geometry==`object`)return t.feature.geometry;if(t.type===`MultiLineString`||t.type===`LineString`)return t}function PE(e){if(!Array.isArray(e))return[];let t=[];for(let n of e)ec(n)&&t.push({lat:n[1],lon:n[0],t:0,sog:0});return t}function FE(e){if(e.type===`MultiLineString`&&Array.isArray(e.coordinates))return e.coordinates.map(PE).filter(e=>e.length>=2);if(e.type===`LineString`){let t=PE(e.coordinates);return t.length>=2?[t]:[]}return[]}function IE(e,t){if(e&&typeof e==`object`){let t=e;if(typeof t.properties?.name==`string`&&t.properties.name)return t.properties.name;if(typeof t.name==`string`&&t.name)return t.name}return t}function LE(e,t){if(!e||typeof e!=`object`)return;let n=e,r=n.properties?.[t]??n.feature?.properties?.[t];return bc(r)?r:void 0}function RE(e,t){let n=NE(t);if(!n)return;let r=FE(n);if(r.length!==0)return{id:e,name:IE(t,e),points:r,distanceMeters:LE(t,`distance`),durationSeconds:LE(t,`timespan`)}}async function zE(e,t){return await bu(e,[jE,ME],t,RE)??[]}function BE(e,t,n,r,i){let a=Xh(i),o=DE(r,i),s={...o,properties:{...o.properties,distance:a.distanceMeters,timespan:a.durationSeconds}};return Cu(`${e}${jE}/${encodeURIComponent(n)}`,t,s)}function VE(e,t,n){return wu(`${e}${jE}/${encodeURIComponent(n)}`,t)}var HE=[{key:`depth`,path:$.depthBelowTransducer,aggregate:`average`,label:`Depth`},{key:`wind`,path:$.windSpeedApparent,aggregate:`max`,label:`Wind (apparent)`},{key:`pressure`,path:$.outsidePressure,aggregate:`average`,label:`Pressure`},{key:`sog`,path:$.speedOverGround,aggregate:`average`,label:`Speed`}],UE=3e4,WE=Math.ceil(jc/UE),GE=class{#e=[];#t=new Map;#n;#r=z(0);constructor(){for(let e of HE)this.#t.set(e.key,[])}get version(){return W(this.#r)}start(e,t=Date.now){this.stop();let n=()=>this.record(e(),t());return n(),this.#n=setInterval(n,UE),()=>this.stop()}stop(){this.#n!==void 0&&clearInterval(this.#n),this.#n=void 0}record(e,t){this.#e.push(t/1e3);for(let t of HE){let n=e[t.key];this.#t.get(t.key)?.push(typeof n==`number`&&Number.isFinite(n)?n:null)}if(this.#e.length>WE){let e=this.#e.length-WE;this.#e.splice(0,e);for(let t of this.#t.values())t.splice(0,e)}B(this.#r,W(this.#r)+1)}series(e){return{times:this.#e,values:this.#t.get(e)??[]}}},KE=1440*60;async function qE(e,t,n,r={fetchValues:ku}){let i=await r.fetchValues(e,t,n,{paths:HE.map(e=>`${e.path}:${e.aggregate}`),durationSeconds:KE,resolutionSeconds:300});if(i)return{series:JE(i.values),provider:i.provider}}function JE(e){let t=new Map;for(let n of HE){let r=e.columns.findIndex(e=>e.path===n.path&&e.method===n.aggregate),i=r>=0?r:e.columns.findIndex(e=>e.path===n.path);if(i<0){t.set(n.key,{times:[],values:[]});continue}let a=[],o=[];for(let t of e.rows){let e=Date.parse(t[0]);if(!Number.isFinite(e))continue;let n=t[i+1];a.push(e/1e3),o.push(typeof n==`number`&&Number.isFinite(n)?n:null)}t.set(n.key,{times:a,values:o})}return t}var YE=`modulepreload`,XE=function(e){return`/signalk-binnacle/`+e},ZE={},QE=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=XE(t,n),t in ZE)return;ZE[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:YE,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},$E=K(`<div class="trends svelte-12py63w"><p class="muted-note" role="status"> </p> <!></div>`);function eD(e,t){$e(t,!0);let n=R(()=>(t.providers?.ids.length??0)>0),r=z(void 0),i=z(!1),a=z(!1),o=0;zn(()=>{if(!t.providers?.ids.length)return;let e=++o;B(i,!0),B(a,!1),qE(t.origin,t.token,t.providers).then(t=>{e===o&&(B(r,t,!0),B(i,!1),B(a,t===void 0))}).catch(()=>{e===o&&(B(r,void 0),B(i,!1),B(a,!0))})});let s=R(()=>(t.recorder.version,e=>t.recorder.series(e))),c=R(()=>W(r)?.series?W(r).provider?`Last 24 hours, from ${W(r).provider}`:`Last 24 hours`:W(i)?`Loading the last 24 hours...`:W(n)&&W(a)?`History query failed; showing this session only.`:`This session only. A history provider on the server (for example signalk-questdb or signalk-to-influxdb2) unlocks the full 24 hour view.`);i_(e,{title:`Trends`,closeLabel:`Close trends panel`,get onClose(){return t.onClose},get onBack(){return t.onBack},children:(e,n)=>{var i=$E(),a=V(i),o=V(a,!0);N(a),yi(H(a,2),()=>QE(()=>import(`./TrendCharts-CiUGeOLI.js`),__vite__mapDeps([0,1])),null,(e,n)=>{var i=ci(),a=Cn(i);{let e=R(()=>W(r)?.series);Ni(a,()=>W(n).default,(n,r)=>{r(n,{get history(){return W(e)},get sessionSeries(){return W(s)},get mode(){return t.mode},get theme(){return t.theme}})})}q(e,i)}),N(i),U(()=>J(o,W(c))),q(e,i)},$$slots:{default:!0}}),et()}var tD=K(`<p class="alert-note" role="alert"> </p>`),nD=K(`<p class="description svelte-zf0nie"> </p>`),rD=K(`<button type="button" class="icon-btn" aria-label="Go to waypoint" title="Go to"><!></button>`),iD=K(`<div class="actions"><!> <button type="button" class="icon-btn" aria-label="Rename waypoint" title="Rename"><!></button> <button type="button" class="icon-btn icon-btn--danger" aria-label="Delete waypoint" title="Delete"><!></button></div>`),aD=K(`<div class="card-head"><button type="button" class="name" title="Show this waypoint on the chart"> </button></div> <dl class="card-stats"><dt class="caps-label">Position</dt> <dd><span class="num"> </span></dd></dl> <!> <!>`,1),oD=K(`<!> <p class="muted-note">Drop waypoints from a long press on the chart.</p> <!>`,1);function sD(e,t){$e(t,!0);function n(e){let n=qg(`Waypoint`,e.name);n!==void 0&&t.onRename(e.id,n)}let r=z(void 0);function i(e){B(r,void 0),t.onDelete(e)}i_(e,{title:`Waypoints`,closeLabel:`Close waypoints panel`,bodyFlex:!0,get onClose(){return t.onClose},get onBack(){return t.onBack},children:(e,a)=>{var o=oD(),s=Cn(o),c=e=>{var n=tD(),r=V(n,!0);N(n),U(()=>J(r,t.error)),q(e,n)};Y(s,e=>{t.error&&e(c)}),Qg(H(s,4),{heading:`Saved waypoints`,get items(){return t.waypoints},empty:`No waypoints yet`,key:e=>e.id,card:(e,a=x)=>{var o=aD(),s=Cn(o),c=V(s),l=V(c,!0);N(c),N(s);var u=H(s,2),d=H(V(u),2),f=V(d),p=V(f);N(f),N(d),N(u);var m=H(u,2),h=e=>{var t=nD(),n=V(t,!0);N(t),U(()=>J(n,a().description)),q(e,t)};Y(m,e=>{a().description&&e(h)});var g=H(m,2),_=e=>{Wg(e,{question:`Delete this waypoint?`,onConfirm:()=>i(a().id),onCancel:()=>B(r,void 0)})},v=e=>{var i=iD(),o=V(i),s=e=>{var n=rD();Uo(V(n),{size:18,"aria-hidden":`true`}),N(n),G(`click`,n,()=>t.onGoTo(a())),q(e,n)};Y(o,e=>{t.onGoTo&&e(s)});var c=H(o,2);_s(V(c),{size:18,"aria-hidden":`true`}),N(c);var l=H(c,2);Ds(V(l),{size:18,"aria-hidden":`true`}),N(l),N(i),G(`click`,c,()=>n(a())),G(`click`,l,()=>B(r,a().id,!0)),q(e,i)};Y(g,e=>{W(r)===a().id?e(_):e(v,-1)}),U((e,t)=>{J(l,a().name),J(p,`${e??``}
775
+ ${t??``}`)},[()=>uc(a().position.latitude),()=>dc(a().position.longitude)]),G(`click`,c,()=>t.onLocate(a())),q(e,o)},$$slots:{card:!0}}),q(e,o)},$$slots:{default:!0}}),et()}Qr([`click`]);var cD=`binnacle-waypoints`,lD=`binnacle-waypoint-marker`,uD=`binnacle-waypoint-symbol`,dD=`binnacle-waypoint-label`,fD=`routes`;function pD(e){return{type:`FeatureCollection`,features:e.map(e=>({type:`Feature`,geometry:{type:`Point`,coordinates:nc(e.position)},properties:{name:e.name}}))}}function mD(e,t){let n=hf(`day`),r=-1,i=t?.resolve(`waypoint`,`waypoint`),a=i?t?.createIconRegistry():void 0,o=[lD,uD,dD],s=!0,c=!1,l;function u(e){if(!i||e.map.getLayer(uD))return;let t={id:uD,type:`symbol`,source:cD,layout:{"icon-image":Uh(i.uuid),"icon-allow-overlap":!0,visibility:`none`}};e.map.addLayer(t,l)}function d(e){Pf(e.map,[lD],s&&!c),e.map.getLayer(uD)&&Pf(e.map,[uD],s&&c)}async function f(e){if(!a||!i)return;let t=await a.ensure(e.map,i,n).catch(()=>!1),r=a.entry(i.uuid);!t||!r||!e.map.getLayer(uD)||(e.map.setLayoutProperty(uD,`icon-offset`,r.offset),c=!0,d(e))}return{id:`waypoints`,title:`Waypoints`,band:fD,supportsOpacity:!0,layerIds:o,add(e){r=-1,c=!1;let t=e.beforeIdFor(fD);if(l=t,!e.map.getSource(cD)){let t={type:`geojson`,data:Gm()};e.map.addSource(cD,t)}if(!e.map.getLayer(lD)){let r={id:lD,type:`circle`,source:cD,paint:{"circle-radius":5,"circle-color":n.waypoint,"circle-stroke-color":n.markerGlyph,"circle-stroke-width":1.5}};e.map.addLayer(r,t)}if(u(e),!e.map.getLayer(dD)){let r={id:dD,type:`symbol`,source:cD,layout:{"text-field":[`get`,`name`],"text-font":[`Noto Sans Regular`],"text-size":11,"text-offset":[.8,0],"text-anchor":`left`,"text-optional":!0,"text-max-width":12},paint:{"text-color":n.label,"text-halo-color":n.background,"text-halo-width":1.5}};e.map.addLayer(r,t)}i&&f(e)},sync(n){!i&&t&&(i=t.resolve(`waypoint`,`waypoint`),i&&(a=t.createIconRegistry(),u(n),f(n))),e.version!==r&&(r=e.version,n.map.getSource(cD)?.setData(pD(e.waypoints)))},setVisible(e,t){s=t,Pf(e.map,[dD],s),d(e)},setOpacity(e,t){e.map.setPaintProperty(lD,`circle-opacity`,t),e.map.setPaintProperty(lD,`circle-stroke-opacity`,t),e.map.getLayer(uD)&&e.map.setPaintProperty(uD,`icon-opacity`,t),e.map.setPaintProperty(dD,`text-opacity`,t)},applyTheme(e,t){n=t,e.map.setPaintProperty(lD,`circle-color`,n.waypoint),e.map.setPaintProperty(lD,`circle-stroke-color`,n.markerGlyph),e.map.setPaintProperty(dD,`text-color`,n.label),e.map.setPaintProperty(dD,`text-halo-color`,n.background),a?.retheme(e.map,t)},remove(e){Ff(e.map,o,[cD])}}}var hD=`/signalk/v2/api/resources/waypoints`,gD=`/signalk/v1/api/resources/waypoints`;function _D(e,t){return bu(e,[hD,gD],t,pg)}function vD(e,t,n){return Cu(`${e}${hD}/${encodeURIComponent(n.id)}`,t,fg(n))}function yD(e,t,n){return wu(`${e}${hD}/${encodeURIComponent(n)}`,t)}function bD(e,t){return(n,r)=>xD(r===`night-red`?t:e,n)}function xD(e,t){if(Number.isNaN(t)||t<=e[0][0])return e[0][1];for(let n=0;n<e.length-1;n+=1){let[r,i]=e[n],[a,o]=e[n+1];if(t<=a){let e=(t-r)/(a-r||1);return[i[0]+(o[0]-i[0])*e,i[1]+(o[1]-i[1])*e,i[2]+(o[2]-i[2])*e,i[3]+(o[3]-i[3])*e]}}return e[e.length-1][1]}function SD([e,t,n,r]){return`rgba(${Math.round(e*255)}, ${Math.round(t*255)}, ${Math.round(n*255)}, ${r.toFixed(2)})`}var CD=bD([[0,[.7,.71,.74,0]],[.3,[.58,.59,.62,.32]],[1,[.42,.43,.46,.62]]],[[0,[.24,.05,.04,0]],[1,[.38,.08,.06,.4]]]);function wD(e,t,n,r){if(!t||t.length===0)return;let i=e.lons.length,a=e.lats.length,o=t[n.lo]??[],s=t[n.hi]??o,c=new Uint8ClampedArray(i*a*4);for(let e=0;e<a;e+=1){let t=a-1-e;for(let a=0;a<i;a+=1){let l=t*i+a,[u,d,f,p]=r(yc(o[l],s[l],n.frac)),m=(e*i+a)*4;c[m]=u*255,c[m+1]=d*255,c[m+2]=f*255,c[m+3]=p*255}}return{data:c,width:i,height:a}}function TD(e,t,n){return wD(e,e.cloudCover,t,e=>CD(e,n))}function ED(){return document.createElement(`canvas`)}var DD=[[0,1e-4],[1e-4,1e-4],[1e-4,0],[0,0]];function OD(e,t,n=ED){let{id:r,title:i,sourceId:a,layerId:o,defaultOpacity:s,fieldRgba:c}=t,l=n(),u=`day`,d,f=NaN,p,m=0,h=!1;function g(e){let t=e.getSource(a);if(typeof t?.play!=`function`||typeof t.pause!=`function`||(t.play(),m=2,h))return;h=!0;let n=()=>{if(--m,m>0){requestAnimationFrame(n);return}h=!1,e.getSource(a)?.pause?.()};requestAnimationFrame(n)}function _(){let t=e.grid,n=t?c(t,e.bracket,u):void 0,r=l.getContext(`2d`);if(!r)return;if(!n){l.width=1,l.height=1,r.clearRect(0,0,1,1);return}l.width=n.width,l.height=n.height;let i=r.createImageData(n.width,n.height);i.data.set(n.data),r.putImageData(i,0,0)}function v(){let t=e.grid;if(!t||t.lons.length===0||t.lats.length===0)return;let n=t.lons[0],r=t.lons[t.lons.length-1],i=t.lats[0],a=t.lats[t.lats.length-1];return[[n,a],[r,a],[r,i],[n,i]]}return{id:r,title:i,band:`weather`,supportsOpacity:!0,defaultVisible:!1,defaultOpacity:s,layerIds:[o],add(e){if(!e.map.getSource(a)){let t={type:`canvas`,canvas:l,coordinates:DD,animate:!1};e.map.addSource(a,t)}if(!e.map.getLayer(o)){let t={id:o,type:`raster`,source:a,paint:{"raster-opacity":1,"raster-resampling":`linear`,"raster-fade-duration":0}};e.map.addLayer(t,e.beforeIdFor(`weather`))}},reset(){d=void 0,f=NaN,p=void 0},sync(t){let n=e.grid;if(n===d&&e.selectedTime===f&&u===p)return;d=n,f=e.selectedTime,p=u,_();let r=v(),i=t.map.getSource(a);r&&i?.setCoordinates(r),g(t.map)},remove(e){e.map.getLayer(o)&&e.map.removeLayer(o),e.map.getSource(a)&&e.map.removeSource(a)},setVisible(e,t){e.map.setLayoutProperty(o,`visibility`,t?`visible`:`none`)},setOpacity(e,t){e.map.setPaintProperty(o,`raster-opacity`,t)},applyTheme(e,t){u=t.theme,p=void 0}}}var kD={wind:`weather-wind`,pressure:`weather-pressure`,waves:`weather-waves`,precip:`weather-precip`,cloud:`weather-cloud`,radar:`weather-radar`},AD=[kD.waves,kD.precip,kD.cloud,kD.radar],jD=new Set(AD),MD=`Open-Meteo`;function ND(e,t){return OD(e,{id:kD.cloud,title:`Cloud`,sourceId:`binnacle-weather-cloud-field`,layerId:`binnacle-weather-cloud-field-layer`,defaultOpacity:.5,fieldRgba:TD},t)}var PD=bD([[0,[.4,.7,.95,0]],[.2,[.4,.7,.95,.4]],[1,[.2,.5,.9,.5]],[2.5,[.24,.75,.45,.55]],[5,[.9,.85,.25,.6]],[10,[.94,.55,.22,.65]],[20,[.86,.26,.22,.7]],[40,[.6,.2,.6,.75]]],[[0,[.28,.03,.02,0]],[1,[.42,.05,.03,.4]],[10,[.6,.08,.04,.58]],[40,[.82,.12,.06,.72]]]),FD={day:{line:`rgba(70, 90, 110, 0.85)`,label:`rgba(40, 55, 70, 1)`,halo:`rgba(255, 255, 255, 0.9)`},dusk:{line:`rgba(150, 165, 185, 0.8)`,label:`rgba(205, 215, 230, 1)`,halo:`rgba(10, 14, 22, 0.9)`},"night-red":{line:`rgba(150, 30, 22, 0.85)`,label:`rgba(190, 40, 28, 1)`,halo:`rgba(0, 0, 0, 0.95)`}};function ID(e){return FD[e]}var LD=6,RD=[[],[[`d`,`a`]],[[`a`,`b`]],[[`d`,`b`]],[[`b`,`c`]],[[`d`,`a`],[`b`,`c`]],[[`a`,`c`]],[[`d`,`c`]],[[`c`,`d`]],[[`c`,`a`]],[[`a`,`b`],[`c`,`d`]],[[`c`,`b`]],[[`d`,`b`]],[[`a`,`b`]],[[`d`,`a`]],[]];function zD(e,t,n=4){let r=[],i=[],a=e.pressureMsl;if(!a||a.length===0)return UD(r,i);let o=e.lons.length,s=e.lats.length,c=a[t.lo]??[],l=a[t.hi]??c,u=new Float64Array(o*s),d=1/0,f=-1/0;for(let e=0;e<u.length;e+=1){let n=yc(c[e],l[e],t.frac)/100;u[e]=n,!Number.isNaN(n)&&(n<d&&(d=n),n>f&&(f=n))}if(!Number.isFinite(d)||!Number.isFinite(f))return UD(r,i);let p=new Map;for(let t=Math.ceil(d/n)*n;t<=f;t+=n)for(let n=0;n<s-1;n+=1)for(let a=0;a<o-1;a+=1){let s=u[n*o+a],c=u[n*o+a+1],l=u[(n+1)*o+a+1],d=u[(n+1)*o+a];if(Number.isNaN(s)||Number.isNaN(c)||Number.isNaN(l)||Number.isNaN(d))continue;let f=s>=t|(c>=t?2:0)|(l>=t?4:0)|(d>=t?8:0);if(f===0||f===15)continue;let m=e.lons[a],h=e.lons[a+1],g=e.lats[n],_=e.lats[n+1],v=e=>{switch(e){case`a`:return[yc(m,h,BD(s,c,t)),g];case`b`:return[h,yc(g,_,BD(c,l,t))];case`c`:return[yc(h,m,BD(l,d,t)),_];default:return[m,yc(_,g,BD(d,s,t))]}};for(let[e,n]of RD[f]){let a=v(e),o=v(n);r.push(VD(a,o,t));let s=p.get(t)??0;s%LD===0&&i.push(HD([(a[0]+o[0])/2,(a[1]+o[1])/2],t)),p.set(t,s+1)}}return UD(r,i)}function BD(e,t,n){let r=t-e;return r===0?.5:(n-e)/r}function VD(e,t,n){return{type:`Feature`,geometry:{type:`LineString`,coordinates:[e,t]},properties:{pressureHpa:n}}}function HD(e,t){return{type:`Feature`,geometry:{type:`Point`,coordinates:e},properties:{pressureHpa:t}}}function UD(e,t){return{lines:{type:`FeatureCollection`,features:e},labels:{type:`FeatureCollection`,features:t}}}var WD=[[0,[.2,.6,.75,0]],[.5,[.2,.6,.75,.45]],[1.5,[.24,.75,.45,.5]],[2.5,[.9,.85,.25,.55]],[4,[.94,.55,.22,.6]],[6,[.86,.26,.22,.62]],[9,[.7,.2,.5,.65]]],GD=[[0,[.28,.03,.02,0]],[1.5,[.45,.05,.03,.45]],[4,[.62,.08,.04,.55]],[9,[.8,.11,.05,.62]]],KD={day:`rgba(20, 35, 50, 0.85)`,dusk:`rgba(210, 220, 235, 0.85)`,"night-red":`rgba(200, 50, 35, 0.9)`},qD=bD(WD,GD);function JD(e){return KD[e]}var YD=[[0,[.16,.66,.79,0]],[3,[.16,.66,.79,.9]],[7,[.22,.77,.41,.9]],[12,[.9,.85,.23,.9]],[18,[.94,.54,.23,.95]],[26,[.88,.28,.23,1]]],XD=[[0,[.3,.04,.03,0]],[7,[.5,.06,.04,.85]],[18,[.68,.09,.05,.95]],[26,[.85,.13,.07,1]]],ZD=[0,3,7,12,18,26],QD=new Map;function $D(e){let t=QD.get(e);if(t)return t;let n=[`interpolate`,[`linear`],[`get`,`speed`],...ZD.flatMap(t=>[t,SD(eO(t,e))])];return QD.set(e,n),n}var eO=bD(YD,XD),tO=[0,10,20,30,40,50].map(Nc),nO=[.5,1,2,4,6,9],rO=[.2,1,2.5,10,25,40],iO=[.25,.5,.75,1];function aO([e,t,n]){return SD([e,t,n,1])}function oO(e,t,n,r,i){let a=n[0],o=n[n.length-1],s=o-a||1;return{id:e,title:t,gradient:`linear-gradient(to right, ${n.map(e=>`${aO(r(e))} ${Math.round((e-a)/s*100)}%`).join(`, `)})`,lowLabel:i(a),highLabel:i(o)}}function sO(e,t,n){switch(e){case kD.wind:return oO(e,`Wind (kn)`,tO,e=>eO(e,t),e=>zc(e,0));case kD.pressure:return{id:e,title:`Pressure`,swatches:[{color:ID(t).line,label:`isobars, 4 hPa`}]};case kD.waves:return oO(e,`Waves (${tl(n)})`,nO,e=>qD(e,t),e=>nl(e,n,n===`imperial`?0:1));case kD.precip:return oO(e,`Rain (${dl(n)})`,rO,e=>PD(e,t),e=>fl(e,n));case kD.cloud:return oO(e,`Cloud (%)`,iO,e=>CD(e,t),e=>Rc(e*100,0));case kD.radar:return{id:e,title:`Rain radar`,swatches:t===`night-red`?[{color:`rgb(90, 26, 20)`,label:`light`},{color:`rgb(140, 36, 26)`,label:`moderate`},{color:`rgb(190, 50, 36)`,label:`heavy`},{color:`rgb(240, 80, 60)`,label:`intense`}]:[{color:`rgb(120, 160, 230)`,label:`light`},{color:`rgb(60, 170, 90)`,label:`moderate`},{color:`rgb(230, 200, 60)`,label:`heavy`},{color:`rgb(220, 70, 60)`,label:`intense`}],note:`radar with short-term nowcast, regional resolution`};default:return}}function cO(e,t,n){return wD(e,e.precipitation,t,e=>PD(e,n))}function lO(e,t){return OD(e,{id:kD.precip,title:`Precipitation`,sourceId:`binnacle-weather-precip-field`,layerId:`binnacle-weather-precip-field-layer`,defaultOpacity:.7,fieldRgba:cO},t)}var uO=`binnacle-weather-pressure`,dO=`binnacle-weather-pressure-labels`,fO=`binnacle-weather-pressure-line`,pO=`binnacle-weather-pressure-label`;function mO(e){let t,n=NaN;return{id:kD.pressure,title:`Pressure`,band:`weather`,supportsOpacity:!0,defaultVisible:!1,layerIds:[fO,pO],reset(){t=void 0,n=NaN},add(e){let t=ID(`day`);if(!e.map.getSource(uO)){let t={type:`geojson`,data:Gm()};e.map.addSource(uO,t)}if(!e.map.getSource(dO)){let t={type:`geojson`,data:Gm()};e.map.addSource(dO,t)}if(!e.map.getLayer(fO)){let n={id:fO,type:`line`,source:uO,layout:{"line-cap":`round`,"line-join":`round`},paint:{"line-color":t.line,"line-width":1.2,"line-opacity":1}};e.map.addLayer(n,e.beforeIdFor(`weather`))}if(!e.map.getLayer(pO)){let n={id:pO,type:`symbol`,source:dO,layout:{"text-field":[`to-string`,[`get`,`pressureHpa`]],"text-font":[`Noto Sans Regular`],"text-size":11,"symbol-placement":`point`,"text-allow-overlap":!1},paint:{"text-color":t.label,"text-halo-color":t.halo,"text-halo-width":1.4,"text-opacity":1}};e.map.addLayer(n,e.beforeIdFor(`weather`))}},sync(r){let i=e.grid;if(i===t&&e.selectedTime===n)return;t=i,n=e.selectedTime;let a=r.map.getSource(uO),o=r.map.getSource(dO);if(!i){a?.setData(Gm()),o?.setData(Gm());return}let{lines:s,labels:c}=zD(i,e.bracket);a?.setData(s),o?.setData(c)},remove(e){e.map.getLayer(pO)&&e.map.removeLayer(pO),e.map.getLayer(fO)&&e.map.removeLayer(fO),e.map.getSource(dO)&&e.map.removeSource(dO),e.map.getSource(uO)&&e.map.removeSource(uO)},setVisible(e,t){let n=t?`visible`:`none`;e.map.setLayoutProperty(fO,`visibility`,n),e.map.setLayoutProperty(pO,`visibility`,n)},setOpacity(e,t){e.map.setPaintProperty(fO,`line-opacity`,t),e.map.setPaintProperty(pO,`text-opacity`,t)},applyTheme(e,t){let n=ID(t.theme);e.map.setPaintProperty(fO,`line-color`,n.line),e.map.setPaintProperty(pO,`text-color`,n.label),e.map.setPaintProperty(pO,`text-halo-color`,n.halo)}}}var hO=2,gO=`1_1`;function _O(e,t){return`${e}${t}/256/{z}/{x}/{y}/${hO}/${gO}.png`}var vO=`binnacle-weather-radar`,yO=`binnacle-weather-radar-layer`,bO=600,xO=1600,SO=.85;function CO(e,t){return e!==0&&Math.abs(e-t)>36e5}function wO(e,t=()=>performance.now(),n=()=>Date.now(),r){let i,a=0,o=0,s=!1,c=SO,l,u=Sc();function d(){return s&&!CO(e.selectedTime,n())}function f(e){e.map.getLayer(yO)&&e.map.setLayoutProperty(yO,`visibility`,d()?`visible`:`none`)}function p(t){let n=e.radar,i=n?.frames??[];if(!n||i.length===0)return;let o=i[Math.min(a,i.length-1)],s=_O(n.host,o.path);r?.(o.time);let u=t.map.getSource(vO);if(u)u.setTiles([s]);else{let e={type:`raster`,tiles:[s],tileSize:256,maxzoom:7,attribution:`RainViewer`};t.map.addSource(vO,e)}if(!t.map.getLayer(yO)){let e={id:yO,type:`raster`,source:vO,layout:{visibility:d()?`visible`:`none`},paint:{"raster-opacity":c}};t.map.addLayer(e,t.beforeIdFor(`weather`)),l&&m(t,l)}}function m(e,t){gf(e.map,yO,t)}return{id:kD.radar,title:`Rain radar`,band:`weather`,supportsOpacity:!0,defaultVisible:!1,defaultOpacity:SO,layerIds:[yO],add(){},reset(){i=void 0},sync(n){let r=e.radar,s=r?.frames??[];if(r!==i){i=r,a=Math.max(0,s.length-1),r&&s.length>0&&p(n),o=t();return}if(f(n),!d()||!n.map.getLayer(yO)||!r||s.length<2||u)return;let c=a===s.length-1?xO:bO,l=t();l-o<c||(o=l,a=(a+1)%s.length,p(n))},remove(e){e.map.getLayer(yO)&&e.map.removeLayer(yO),e.map.getSource(vO)&&e.map.removeSource(vO)},setVisible(e,t){s=t,e.map.getLayer(yO)?f(e):t&&p(e)},setOpacity(e,t){c=t,e.map.getLayer(yO)&&e.map.setPaintProperty(yO,`raster-opacity`,t)},applyTheme(e,t){l=t,e.map.getLayer(yO)&&m(e,t)}}}var TO=`/signalk/v2/api/weather`,EO=90*kc,DO=(...e)=>globalThis.fetch(...e);async function OO(e,t,n=DO){let r=await _c(`${e}${TO}/_providers`,gu(t),n);if(r!==void 0)return _u(r)}function kO(e){if(!e)return;let t=Object.entries(e).filter(e=>!!e[1]&&typeof e[1]==`object`);if(t.length===0)return;let[n,r]=t.find(([,e])=>e.isDefault)??t[0];return r.name??MO(n)}var AO=/^(signalk-|sk-)/,jO=/[-_]+/;function MO(e){let t=e.replace(AO,``).split(jO).filter(Boolean);return t.length===0?e:t.map(Cc).join(` `)}function NO(e,t,n,r,i){let a=new URLSearchParams({lat:String(n),lon:String(r)});return i!==void 0&&a.set(`count`,String(i)),`${e}${TO}/${t}?${a.toString()}`}async function PO(e,t,n,r,i=DO){let a=await RO(NO(e,`observations`,t,n),r,i);if(!(!a||a.length===0))return xc(a,FO,2**53-1)??a[0]}var FO=e=>Date.parse(e.date);async function IO(e,t,n,r,i,a=DO){return RO(NO(e,`forecasts/point`,t,n,r),i,a)}async function LO(e,t,n,r,i=DO){let a=await _c(NO(e,`warnings`,t,n),gu(r),i);if(a!==void 0)return Array.isArray(a)?a:void 0}async function RO(e,t,n){let r=await _c(e,gu(t),n);if(r!==void 0){if(Array.isArray(r))return r;if(r&&typeof r==`object`)return[r]}}function zO(e){return{timeMs:Date.parse(e.date),windMs:e.wind?.speedTrue,fromRad:e.wind?.directionTrue,gustMs:e.wind?.gust,pressurePa:e.outside?.pressure,pressureTendency:e.outside?.pressureTendency,airTempK:e.outside?.temperature,cloudFraction:e.outside?.cloudCover,waveHeightM:e.water?.waveSignificantHeight,wavePeriodS:e.water?.wavePeriod,waveFromRad:e.water?.waveDirection,swellHeightM:e.water?.swellHeight,swellPeriodS:e.water?.swellPeriod,swellFromRad:e.water?.swellDirection,visibilityM:e.outside?.horizontalVisibility,waterTempK:e.water?.temperature,precipitationMm:e.outside?.precipitationVolume,precipIsRate:!1}}function BO(e){let t=e.wind?.speedTrue,n=e.wind?.directionTrue;if(!(t===void 0||n===void 0))return{speedMs:t,fromRad:n,gustMs:e.wind?.gust,pressurePa:e.outside?.pressure,waveHeightM:e.water?.waveSignificantHeight,wavePeriodS:e.water?.wavePeriod,waveFromRad:e.water?.waveDirection,precipitationMm:e.outside?.precipitationVolume,precipIsRate:!1,cloudCoverFraction:e.outside?.cloudCover}}function VO(e,t){return xc(e,FO,t)}var HO=3*Ac;function UO(e,t){let n=VO(e,t);if(!n)return;let r=Date.parse(e[0]?.date??``),i=Date.parse(e[1]?.date??``),a=!Number.isNaN(r)&&!Number.isNaN(i)&&i>r?i-r:HO;return Math.abs(Date.parse(n.date)-t)<=a?n:void 0}function WO(e,t){return Math.min(t.end,Math.max(t.start,e))}function GO(e,t,n){return WO(e+t*n.stepMs,n)}function KO(e,t){let n=e+t.stepMs;return n>t.end?t.start:n}var qO=Ac,JO=8,YO=12;function XO(e,t,n){return`${e}:${oc(t)},${oc(n)}`}var ZO={observations:PO,forecasts:IO,warnings:LO,now:()=>Date.now(),persist:lm(`binnacle-weather-point`,{maxEntries:JO})};function QO(e={}){let t={...ZO,...e};return{async load(e,n,r,i,a){let o=t.now(),s=XO(n,r,i),[c,l,u]=await Promise.all([t.observations(e,r,i,a),t.forecasts(e,r,i,YO,a),t.warnings(e,r,i,a)]);if(c||l){let e={fetchedAt:o,obs:c,series:l,warnings:u};return await t.persist.put(s,e,o+qO),t.persist.prune(o),e}let d=await t.persist.get(s);return d&&d.expires>o?(t.persist.prune(o),u?{...d.value,warnings:u}:d.value):{fetchedAt:o,warnings:u}}}}function $O(e,t){return e?dl(t):t===`imperial`?`in`:`mm`}function ek(e,t,n,r){return tk(e,t,n,{lo:r,hi:r,frac:0})}function tk(e,t,n,r){let{lo:i,hi:a,frac:o}=r,s=vg(e,e.windU[i],t,n),c=vg(e,e.windV[i],t,n);if(s===void 0||c===void 0)return;let l=ok(s,vg(e,e.windU[a],t,n),o),u=ok(c,vg(e,e.windV[a],t,n),o),d=Math.hypot(l,u),f=(Math.atan2(-l,-u)+2*Math.PI)%(2*Math.PI),p=r=>sk(ak(e,r,i,t,n),ak(e,r,a,t,n),o);return{speedMs:d,fromRad:f,gustMs:p(e.windGust),pressurePa:p(e.pressureMsl),waveHeightM:p(e.waveHeight),wavePeriodS:p(e.wavePeriod),waveFromRad:ck(ak(e,e.waveDirection,i,t,n),ak(e,e.waveDirection,a,t,n),o),precipitationMm:p(e.precipitation),precipIsRate:!0,cloudCoverFraction:p(e.cloudCover)}}var nk=3*Ac;function rk(e,t,n,r){let i=r-nk;if(e.times.length===0||i<e.times[0])return;let a=ik(e,t,n,Sg(e,r)),o=ik(e,t,n,Sg(e,i));if(!(a===void 0||o===void 0))return a-o}function ik(e,t,n,r){return sk(ak(e,e.pressureMsl,r.lo,t,n),ak(e,e.pressureMsl,r.hi,t,n),r.frac)}function ak(e,t,n,r,i){let a=t?.[n];return a?.length?lk(vg(e,a,r,i)):void 0}function ok(e,t,n){return t===void 0||Number.isNaN(t)?e:yc(e,t,n)}function sk(e,t,n){return e!==void 0&&t!==void 0?yc(e,t,n):e??t}function ck(e,t,n){if(e!==void 0&&t!==void 0){let r=yc(Math.sin(e),Math.sin(t),n),i=yc(Math.cos(e),Math.cos(t),n);return(Math.atan2(r,i)+2*Math.PI)%(2*Math.PI)}return e??t}function lk(e){return e===void 0||Number.isNaN(e)?void 0:e}var uk=K(`<p class="muted-note" role="status">Waiting for a vessel position.</p>`),dk=K(`<li class="warning svelte-raos6e"><!> <span class="svelte-raos6e"><b> </b> <span class="warning-meta svelte-raos6e"> </span></span></li>`),fk=K(`<ul class="warnings svelte-raos6e" role="alert"></ul>`),pk=K(`<p class="muted-note">Warnings unavailable without a weather provider.</p>`),mk=K(`<div class="svelte-raos6e"><dt class="svelte-raos6e">Gust</dt> <dd class="svelte-raos6e"><b class="svelte-raos6e"> </b> kn</dd></div>`),hk=K(`<span class="trend svelte-raos6e"> </span>`),gk=K(`<div class="svelte-raos6e"><dt class="svelte-raos6e">Pressure</dt> <dd class="svelte-raos6e"><b class="svelte-raos6e"> </b> <!></dd></div>`),_k=K(`<div class="svelte-raos6e"><dt class="svelte-raos6e">Air</dt> <dd class="svelte-raos6e"><b class="svelte-raos6e"> </b> </dd></div>`),vk=K(`<div class="svelte-raos6e"><dt class="svelte-raos6e">Water</dt> <dd class="svelte-raos6e"><b class="svelte-raos6e"> </b> </dd></div>`),yk=K(`<div class="svelte-raos6e"><dt class="svelte-raos6e">Visibility</dt> <dd class="svelte-raos6e"><b class="svelte-raos6e"> </b></dd></div>`),bk=K(`<div class="svelte-raos6e"><dt class="svelte-raos6e">Cloud</dt> <dd class="svelte-raos6e"><b class="svelte-raos6e"> </b>%</dd></div>`),xk=K(`/ <b class="svelte-raos6e"> </b> s`,1),Sk=K(`<div class="svelte-raos6e"><dt class="svelte-raos6e">Waves</dt> <dd class="svelte-raos6e"><b class="svelte-raos6e"> </b> <!> <!></dd></div>`),Ck=K(`<div class="svelte-raos6e"><dt class="svelte-raos6e">Swell</dt> <dd class="svelte-raos6e"><b class="svelte-raos6e"> </b> <!> <!></dd></div>`),wk=K(`<div class="svelte-raos6e"><dt class="svelte-raos6e">Rain</dt> <dd class="svelte-raos6e"><b class="svelte-raos6e"> </b> </dd></div>`),Tk=K(`<p class="cond-when svelte-raos6e"> </p> <dl class="now svelte-raos6e"><div class="svelte-raos6e"><dt class="svelte-raos6e">Wind</dt> <dd class="svelte-raos6e"><b class="svelte-raos6e"> </b> </dd></div> <!> <!> <!> <!> <!> <!> <!> <!> <!></dl>`,1),Ek=K(`<p class="muted-note" role="status">Loading conditions.</p>`),Dk=K(`<p class="muted-note" role="status">Turn on a weather layer to load conditions.</p>`),Ok=K(`<p class="muted-note" role="status">No conditions for this point.</p>`),kk=K(`<span class="f-rain svelte-raos6e"><b class="svelte-raos6e"> </b> </span>`),Ak=K(`<li class="svelte-raos6e"><span class="f-time svelte-raos6e"> </span> <span class="f-wind svelte-raos6e"><b class="svelte-raos6e"> </b> </span> <!></li>`),jk=K(`<p class="caps-label forecast-head svelte-raos6e"> </p> <ul class="forecast svelte-raos6e"></ul>`,1),Mk=K(`<!> <!> <!>`,1),Nk=K(`<section class="conditions svelte-raos6e" aria-label="Conditions at the vessel"><header class="cond-head svelte-raos6e"><span class="caps-label">Here</span> <span class="cond-source svelte-raos6e"> </span></header> <!></section>`);function Pk(e,t){$e(t,!0);let n=e=>zc(e,0),r=e=>Rc(e===void 0?void 0:e*100,0),i=6*Ac,a=QO(),o=z(!1),s=z(void 0),c=z(void 0),l=z(fn([])),u=0,d=R(()=>t.providerName??`Open-Meteo`),f=R(()=>t.position?`${t.position.latitude.toFixed(3)},${t.position.longitude.toFixed(3)}`:``),p=R(()=>W(f)?W(f).split(`,`).map(Number):void 0);zn(()=>{let e=W(p),n=t.providerName;if(!e||!n){m();return}let[r,i]=e;h(n,r,i)});function m(){u+=1,B(s,void 0),B(c,void 0),B(l,[],!0),B(o,!1)}async function h(e,n,r){let i=++u;B(o,!0);let d=await a.load(t.origin,e,n,r,t.token);i===u&&(B(s,d.obs,!0),B(c,d.series,!0),d.warnings&&B(l,d.warnings,!0),B(o,!1))}let g=R(()=>t.store.grid?t.store.selectedTime:Date.now()),_=R(()=>{if(t.providerName){if(Math.abs(W(g)-Date.now())<EO&&W(s))return{cond:zO(W(s)),observed:!0};if(W(c)){let e=UO(W(c),W(g));if(e)return{cond:zO(e),observed:!1}}}});function v(e,t){return{timeMs:t,windMs:e.speedMs,fromRad:e.fromRad,gustMs:e.gustMs,pressurePa:e.pressurePa,cloudFraction:e.cloudCoverFraction,waveHeightM:e.waveHeightM,wavePeriodS:e.wavePeriodS,waveFromRad:e.waveFromRad,precipitationMm:e.precipitationMm,precipIsRate:e.precipIsRate}}let y=R(()=>{if(!W(p)||!t.store.grid)return;let[e,n]=W(p),r=tk(t.store.grid,n,e,t.store.bracket);return r?v(r,t.store.selectedTime):void 0}),b=R(()=>W(_)?.cond??W(y)),x=R(()=>W(_)?.observed??!1),S=R(()=>{let e=W(_)?.cond.pressureTendency;if(e)return e;if(!W(p)||!t.store.grid)return;let[n,r]=W(p),i=rk(t.store.grid,r,n,W(g));if(i===void 0)return;let a=i/100,o=nk/Ac;return Math.abs(a)<.5?`steady`:`${a>0?`rising`:`falling`} ${t.units.mode===`imperial`?ul(Math.abs(i),`imperial`):Rc(Math.abs(a),1)} ${cl(t.units.mode)}/${o} h`}),C=R(()=>W(c)?.map(zO)),w=R(()=>{if(t.providerName&&W(C)){let e=W(C).filter(e=>!Number.isNaN(e.timeMs)&&e.timeMs>=W(g)).slice(0,6);if(e.length>0)return e}if(!W(p))return[];let[e,n]=W(p);return E(e,n)}),T=R(()=>W(w).length>0?Math.max(1,Math.round((W(w)[W(w).length-1].timeMs-W(g))/Ac)):0);function E(e,n){let r=t.store.grid;if(!r)return[];let a=[],o=-1/0;for(let s=0;s<r.times.length&&a.length<6;s++){let c=r.times[s];if(c<t.store.selectedTime||c-o<i)continue;let l=ek(r,n,e,s);l&&(a.push(v(l,c)),o=c)}return a}let D=/hurricane|typhoon/,O=/storm/,k=/gale/,A=/small craft/;function ee(e){let t=e.toLowerCase();return D.test(t)?0:O.test(t)?1:k.test(t)?2:A.test(t)?3:4}let te=R(()=>W(l).slice().sort((e,t)=>ee(e.type)-ee(t.type))),j=Bc,ne=e=>ul(e,t.units.mode),re=e=>sl(e,t.units.mode),ie=e=>nl(e,t.units.mode),ae=e=>fl(e,t.units.mode);function oe(e){return wl(e,{minute:!1})}let se=e=>wl(e,{zone:!0}),ce=e=>wl(Date.parse(e));var le=Nk(),ue=V(le),de=H(V(ue),2),fe=V(de,!0);N(de),N(ue);var pe=H(ue,2),me=e=>{q(e,uk())},he=e=>{var i=Mk(),a=Cn(i),s=e=>{var t=fk();Ei(t,21,()=>W(te),e=>e.startTime+e.type,(e,t)=>{let n=R(()=>ce(W(t).endTime));var r=dk(),i=V(r);ks(i,{size:14,"aria-hidden":`true`});var a=H(i,2),o=V(a),s=V(o,!0);N(o);var c=H(o),l=H(c),u=V(l);N(l),N(a),N(r),U(()=>{J(s,W(t).type),J(c,` ${W(t).details??``} `),J(u,`${W(t).source??``}${W(n)?` · until ${W(n)}`:``}`)}),q(e,r)}),N(t),q(e,t)},c=e=>{q(e,pk())};Y(a,e=>{W(te).length>0?e(s):t.providerName||e(c,1)});var l=H(a,2),u=e=>{var i=Tk(),a=Cn(i),o=V(a);N(a);var s=H(a,2),c=V(s),l=H(V(c),2),u=V(l),d=V(u,!0);N(u);var f=H(u);N(l),N(c);var p=H(c,2),m=e=>{var t=mk(),r=H(V(t),2),i=V(r),a=V(i,!0);N(i),P(),N(r),N(t),U(e=>J(a,e),[()=>n(W(b).gustMs)]),q(e,t)};Y(p,e=>{W(b).gustMs!==void 0&&e(m)});var h=H(p,2),g=e=>{var n=gk(),r=H(V(n),2),i=V(r),a=V(i,!0);N(i);var o=H(i),s=H(o),c=e=>{var t=hk(),n=V(t,!0);N(t),U(()=>J(n,W(S))),q(e,t)};Y(s,e=>{W(S)&&e(c)}),N(r),N(n),U((e,t)=>{J(a,e),J(o,` ${t??``} `)},[()=>ne(W(b).pressurePa),()=>cl(t.units.mode)]),q(e,n)};Y(h,e=>{W(b).pressurePa!==void 0&&e(g)});var _=H(h,2),v=e=>{var n=_k(),r=H(V(n),2),i=V(r),a=V(i,!0);N(i);var o=H(i,1,!0);N(r),N(n),U((e,t)=>{J(a,e),J(o,t)},[()=>re(W(b).airTempK),()=>al(t.units.mode)]),q(e,n)};Y(_,e=>{W(b).airTempK!==void 0&&e(v)});var y=H(_,2),C=e=>{var n=vk(),r=H(V(n),2),i=V(r),a=V(i,!0);N(i);var o=H(i,1,!0);N(r),N(n),U((e,t)=>{J(a,e),J(o,t)},[()=>re(W(b).waterTempK),()=>al(t.units.mode)]),q(e,n)};Y(y,e=>{W(b).waterTempK!==void 0&&e(C)});var w=H(y,2),T=e=>{var n=yk(),r=H(V(n),2),i=V(r),a=V(i,!0);N(i),N(r),N(n),U(e=>J(a,e),[()=>ml(W(b).visibilityM,t.units.mode)]),q(e,n)};Y(w,e=>{W(b).visibilityM!==void 0&&e(T)});var E=H(w,2),D=e=>{var t=bk(),n=H(V(t),2),i=V(n),a=V(i,!0);N(i),P(),N(n),N(t),U(e=>J(a,e),[()=>r(W(b).cloudFraction)]),q(e,t)};Y(E,e=>{W(b).cloudFraction!==void 0&&e(D)});var O=H(E,2),k=e=>{var n=Sk(),r=H(V(n),2),i=V(r),a=V(i,!0);N(i);var o=H(i),s=H(o),c=e=>{var t=xk(),n=H(Cn(t)),r=V(n,!0);N(n),P(),U(e=>J(r,e),[()=>Rc(W(b).wavePeriodS,1)]),q(e,t)};Y(s,e=>{W(b).wavePeriodS!==void 0&&e(c)});var l=H(s,2),u=e=>{var t=si();U(e=>J(t,`from ${e??``}°T`),[()=>j(W(b).waveFromRad)]),q(e,t)};Y(l,e=>{W(b).waveFromRad!==void 0&&e(u)}),N(r),N(n),U((e,t)=>{J(a,e),J(o,` ${t??``} `)},[()=>ie(W(b).waveHeightM),()=>tl(t.units.mode)]),q(e,n)};Y(O,e=>{W(b).waveHeightM!==void 0&&e(k)});var A=H(O,2),ee=e=>{var n=Ck(),r=H(V(n),2),i=V(r),a=V(i,!0);N(i);var o=H(i),s=H(o),c=e=>{var t=xk(),n=H(Cn(t)),r=V(n,!0);N(n),P(),U(e=>J(r,e),[()=>Rc(W(b).swellPeriodS,1)]),q(e,t)};Y(s,e=>{W(b).swellPeriodS!==void 0&&e(c)});var l=H(s,2),u=e=>{var t=si();U(e=>J(t,`from ${e??``}°T`),[()=>j(W(b).swellFromRad)]),q(e,t)};Y(l,e=>{W(b).swellFromRad!==void 0&&e(u)}),N(r),N(n),U((e,t)=>{J(a,e),J(o,` ${t??``} `)},[()=>ie(W(b).swellHeightM),()=>tl(t.units.mode)]),q(e,n)};Y(A,e=>{W(b).swellHeightM!==void 0&&e(ee)});var te=H(A,2),oe=e=>{var n=wk(),r=H(V(n),2),i=V(r),a=V(i,!0);N(i);var o=H(i);N(r),N(n),U((e,t)=>{J(a,e),J(o,` ${t??``}`)},[()=>ae(W(b).precipitationMm),()=>$O(W(b).precipIsRate,t.units.mode)]),q(e,n)};Y(te,e=>{W(b).precipitationMm!==void 0&&W(b).precipitationMm>=.1&&e(oe)}),N(s),U((e,t,n)=>{J(o,`${W(x)?`Observed`:`Forecast`}
776
+ · ${e??``}`),J(d,t),J(f,` kn from ${n??``}°T`)},[()=>se(W(b).timeMs),()=>n(W(b).windMs),()=>j(W(b).fromRad)]),q(e,i)},d=e=>{q(e,Ek())},f=e=>{q(e,Dk())},p=e=>{q(e,Ok())};Y(l,e=>{W(b)?e(u):W(o)?e(d,1):!t.providerName&&!t.store.grid?e(f,2):e(p,-1)});var m=H(l,2),h=e=>{var r=jk(),i=Cn(r),a=V(i);N(i);var o=H(i,2);Ei(o,21,()=>W(w),e=>e.timeMs,(e,r)=>{var i=Ak(),a=V(i),o=V(a,!0);N(a);var s=H(a,2),c=V(s),l=V(c,!0);N(c);var u=H(c);N(s);var d=H(s,2),f=e=>{var n=kk(),i=V(n),a=V(i,!0);N(i);var o=H(i);N(n),U((e,t)=>{J(a,e),J(o,` ${t??``}`)},[()=>ae(W(r).precipitationMm),()=>$O(W(r).precipIsRate,t.units.mode)]),q(e,n)};Y(d,e=>{W(r).precipitationMm!==void 0&&W(r).precipitationMm>=.1&&e(f)}),N(i),U((e,t,n)=>{J(o,e),J(l,t),J(u,` kn from ${n??``}°T`)},[()=>oe(W(r).timeMs),()=>n(W(r).windMs),()=>j(W(r).fromRad)]),q(e,i)}),N(o),U(()=>J(a,`Forecast · next ${W(T)??``} h`)),q(e,r)};Y(m,e=>{W(w).length>0&&e(h)}),q(e,i)};Y(pe,e=>{t.position?e(he,-1):e(me)}),N(le),U(()=>J(fe,W(d))),q(e,le),et()}function Fk(e,t,n,r){let i=e.lons.length,a=i>1?Math.abs(e.lons[1]-e.lons[0]):1,o=e.lats.length>1?Math.abs(e.lats[1]-e.lats[0]):1,s=Math.min(a,o)*n,c=[];for(let n=0;n<e.lats.length;n+=t)for(let a=0;a<i;a+=t){let t=r(n*i+a);if(!t)continue;let o=e.lons[a],l=e.lats[n];c.push({type:`Feature`,geometry:{type:`LineString`,coordinates:[[o,l],[o+t.u*s,l+t.v*s]]},properties:t.props})}return{type:`FeatureCollection`,features:c}}var Ik=2,Lk=.5;function Rk(e,t){let n=e.waveDirection,r=e.waveHeight;if(!n||!r)return Gm();let i=n[t.lo]??[],a=n[t.hi]??i,o=r[t.lo]??[],s=r[t.hi]??o;return Fk(e,Ik,Lk,e=>{let n=yc(i[e],a[e],t.frac),r=yc(o[e],s[e],t.frac);if(!(Number.isNaN(n)||Number.isNaN(r)))return{u:-Math.sin(n),v:-Math.cos(n),props:{}}})}function zk(e,t,n){return wD(e,e.waveHeight,t,e=>qD(e,n))}var Bk=`binnacle-weather-waves-field`,Vk=`binnacle-weather-waves-field-layer`,Hk=`binnacle-weather-waves-arrows`,Uk=`binnacle-weather-waves-arrow-layer`;function Wk(e,t){let n=OD(e,{id:kD.waves,title:`Waves`,sourceId:Bk,layerId:Vk,defaultOpacity:.7,fieldRgba:zk},t),r,i=NaN;return{id:n.id,title:n.title,band:`weather`,supportsOpacity:!0,defaultVisible:!1,layerIds:[Vk,Uk],add(e){if(n.add(e),!e.map.getSource(Hk)){let t={type:`geojson`,data:Gm()};e.map.addSource(Hk,t)}if(!e.map.getLayer(Uk)){let t={id:Uk,type:`line`,source:Hk,layout:{"line-cap":`round`},paint:{"line-color":JD(`day`),"line-width":1.5,"line-opacity":1}};e.map.addLayer(t,e.beforeIdFor(`weather`))}},reset(){n.reset?.(),r=void 0,i=NaN},sync(t){n.sync(t);let a=e.grid;a===r&&e.selectedTime===i||(r=a,i=e.selectedTime,t.map.getSource(Hk)?.setData(a?Rk(a,e.bracket):Gm()))},remove(e){e.map.getLayer(Uk)&&e.map.removeLayer(Uk),e.map.getSource(Hk)&&e.map.removeSource(Hk),n.remove(e)},setVisible(e,t){n.setVisible(e,t),e.map.setLayoutProperty(Uk,`visibility`,t?`visible`:`none`)},setOpacity(e,t){n.setOpacity?.(e,t),e.map.setPaintProperty(Uk,`line-opacity`,t)},applyTheme(e,t){n.applyTheme?.(e,t),e.map.setPaintProperty(Uk,`line-color`,JD(t.theme))}}}var Gk=`https://api.rainviewer.com/public/weather-maps.json`;async function Kk(e=globalThis.fetch.bind(globalThis)){let t=await _c(Gk,{credentials:`omit`},e);if(t===void 0||!t.host||!t.radar)return;let n=[...t.radar.past??[],...t.radar.nowcast??[]].map(e=>({time:e.time*1e3,path:e.path})).sort((e,t)=>e.time-t.time);if(n.length!==0)return{host:t.host,frames:n}}var qk=`https://api.open-meteo.com/v1/forecast`,Jk=`https://marine-api.open-meteo.com/v1/marine`,Yk=200,Xk=15e3;async function Zk(e,t,n,r,i,a){let{lats:o,lons:s}=gg(r,i.maxCells),c=[];for(let e of o)for(let t of s)c.push({lat:e,lon:t});try{let r=$k(c,Yk),l=await Promise.all(r.map(r=>a(Qk(e,r,t,n,i),hc({credentials:`omit`},Xk)))),u=[];for(let e of l){if(!e.ok)return;let t=await e.json();for(let e of Array.isArray(t)?t:[t])u.push(e)}return{locs:u,lats:o,lons:s}}catch{return}}function Qk(e,t,n,r,i){return`${e}?${new URLSearchParams({latitude:t.map(e=>e.lat.toFixed(4)).join(`,`),longitude:t.map(e=>e.lon.toFixed(4)).join(`,`),hourly:n,forecast_days:String(i.forecastDays),timeformat:`unixtime`,...r})}`}function $k(e,t){let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}function eA(e,t,n=NaN){return Array.from({length:e},()=>Array(t).fill(n))}async function tA(e,t,n=globalThis.fetch.bind(globalThis)){let r=await Zk(qk,`wind_speed_10m,wind_direction_10m,wind_gusts_10m,pressure_msl,precipitation,cloud_cover`,{wind_speed_unit:`ms`},e,t,n);return r?nA(r.locs,r.lats,r.lons):void 0}function nA(e,t,n){let r=e[0]?.hourly;if(!r?.time||r.time.length===0)return;let i=r.time.map(e=>Number(e)*1e3),a=i.length,o=t.length*n.length;if(e.length!==o)return;let s=eA(a,o,0),c=eA(a,o,0),l=eA(a,o),u=eA(a,o),d=eA(a,o),f=eA(a,o);for(let t=0;t<o;t+=1){let n=e[t]?.hourly,r=n?.wind_speed_10m??[],i=n?.wind_direction_10m??[],o=n?.wind_gusts_10m??[],p=n?.pressure_msl??[],m=n?.precipitation??[],h=n?.cloud_cover??[];for(let e=0;e<a;e+=1){let n=r[e]??0,a=(i[e]??0)*Oc;s[e][t]=-n*Math.sin(a),c[e][t]=-n*Math.cos(a);let g=o[e];g!==void 0&&(l[e][t]=g);let _=p[e];_!==void 0&&(u[e][t]=_*100);let v=m[e];v!==void 0&&(d[e][t]=v);let y=h[e];y!==void 0&&(f[e][t]=y/100)}}return{lats:t,lons:n,times:i,windU:s,windV:c,windGust:l,pressureMsl:u,precipitation:d,cloudCover:f}}async function rA(e,t,n=globalThis.fetch.bind(globalThis)){let r=await Zk(Jk,`wave_height,wave_direction,wave_period`,{cell_selection:`sea`},e,t,n);return r?iA(r.locs,r.lats.length*r.lons.length):void 0}function iA(e,t){let n=e[0]?.hourly;if(!n?.time||n.time.length===0||e.length!==t)return;let r=n.time.length,i=eA(r,t),a=eA(r,t),o=eA(r,t);for(let n=0;n<t;n+=1){let t=e[n]?.hourly,s=t?.wave_height??[],c=t?.wave_direction??[],l=t?.wave_period??[];for(let e=0;e<r;e+=1){i[e][n]=s[e]??NaN;let t=c[e];a[e][n]=t===void 0?NaN:t*Oc,o[e][n]=l[e]??NaN}}return{waveHeight:i,waveDirection:a,wavePeriod:o}}function aA(e,t){return t.waveHeight.length===e.windU.length?{...e,waveHeight:t.waveHeight,waveDirection:t.waveDirection,wavePeriod:t.wavePeriod}:e}var oA=Ac,sA=5*kc,cA=.25,lA=16,uA=kc,dA=e=>Math.round(e/cA)*cA;function fA(e,t,n){return[dA(e.west),dA(e.south),dA(e.east),dA(e.north),t.maxCells,t.forecastDays,n?`m`:`-`].join(`:`)}var pA={forecast:tA,marine:rA,radar:Kk,now:()=>Date.now(),persist:lm(`binnacle-weather`,{maxEntries:lA})};function mA(e={}){let t={...pA,...e},n=new um(lA,oA),r,i=0,a=0,o=0;async function s(e,n,r,i){let o=r&&i>=a,[s,c]=await Promise.all([t.forecast(e,n),o?t.marine(e,n):Promise.resolve(void 0)]);if(o&&!c&&(a=t.now()+uA),!s)return{grid:void 0,partial:!1};let l=r&&!c,u={...c?aA(s,c):s,fetchedAt:i};return l&&(u.partialWaves=!0),{grid:u,partial:l}}return{async load(e,a,c,l){let u=++o;e.setStatus(`loading`);let d=t.now(),f=fA(a,c,l.waves),p=async()=>{let e=n.get(f,d);if(e)return{grid:e,partial:!1,fromNetwork:!1};let r=await t.persist.get(f);return r&&r.expires>d?(n.putAt(f,r.value,r.expires,d),t.persist.prune(d),{grid:r.value,partial:!1,fromNetwork:!1}):d<i?{grid:void 0,partial:!1,fromNetwork:!1}:{...await s(a,c,l.waves,d),fromNetwork:!0}},m;m=l.radar?r&&r.expires>d?Promise.resolve(r.data):t.radar().then(e=>(e&&(r={data:e,expires:d+sA}),e)):Promise.resolve(void 0);let[{grid:h,partial:g,fromNetwork:_},v]=await Promise.all([p(),m]),y=()=>u!==o;h?(y()||e.setGrid(h,d),!g&&_&&(n.put(f,h,d),await t.persist.put(f,h,d+oA),t.persist.prune(d))):(_&&(i=d+uA),y()||e.setStatus(e.grid?`stale`:`error`)),v&&!y()&&e.setRadar(v)}}}var hA=.5,gA=.4,_A=1;function vA(e,t){let n=e.windU[t.lo]??[],r=e.windU[t.hi]??[],i=e.windV[t.lo]??[],a=e.windV[t.hi]??[];return Fk(e,_A,gA,e=>{let o=yc(n[e],r[e],t.frac),s=yc(i[e],a[e],t.frac),c=Math.hypot(o,s);if(c>=hA)return{u:o/c,v:s/c,props:{speed:c}}})}function yA(e){let t=new Uint8Array(256*4);for(let n=0;n<256;n+=1){let[r,i,a,o]=eO(n/255*26,e),s=n*4;t[s]=Math.round(r*255),t[s+1]=Math.round(i*255),t[s+2]=Math.round(a*255),t[s+3]=Math.round(o*255)}return t}function bA(e,t){let n=e.windU[t.lo],r=e.windV[t.lo];if(!n||!r||n.length===0)return;let i=e.windU[t.hi]??n,a=e.windV[t.hi]??r,o=e.lons.length,s=e.lats.length,c=new Float32Array(o*s),l=new Float32Array(o*s),u=1/0,d=-1/0,f=1/0,p=-1/0;for(let e=0;e<o*s;e+=1){let o=yc(n[e],i[e],t.frac),s=yc(r[e],a[e],t.frac);c[e]=o,l[e]=s,Number.isNaN(o)||(u=Math.min(u,o),d=Math.max(d,o)),Number.isNaN(s)||(f=Math.min(f,s),p=Math.max(p,s))}u>d&&(u=-1,d=1),f>p&&(f=-1,p=1);let m=d-u||1,h=p-f||1,g=new Uint8Array(o*s*4);for(let e=0;e<o*s;e+=1){let t=e*4,n=Number.isNaN(c[e])||Number.isNaN(l[e]);g[t]=n?0:Math.round((c[e]-u)/m*255),g[t+1]=n?0:Math.round((l[e]-f)/h*255),g[t+3]=n?0:255}return{data:g,width:o,height:s,uMin:u,uMax:d,vMin:f,vMax:p,west:e.lons[0],south:e.lats[0],east:e.lons[o-1],north:e.lats[s-1]}}var xA=`
777
+ precision mediump float;
778
+ attribute vec2 a_pos;
779
+ varying vec2 v_tex_pos;
780
+ void main() {
781
+ v_tex_pos = a_pos;
782
+ gl_Position = vec4(1.0 - 2.0 * a_pos, 0.0, 1.0);
783
+ }`,SA=`
784
+ precision mediump float;
785
+ uniform sampler2D u_screen;
786
+ uniform float u_opacity;
787
+ varying vec2 v_tex_pos;
788
+ void main() {
789
+ vec4 color = texture2D(u_screen, 1.0 - v_tex_pos);
790
+ gl_FragColor = vec4(floor(255.0 * color * u_opacity) / 255.0);
791
+ }`,CA=`
792
+ precision highp float;
793
+ uniform sampler2D u_particles;
794
+ uniform sampler2D u_wind;
795
+ uniform vec2 u_wind_min;
796
+ uniform vec2 u_wind_max;
797
+ uniform float u_rand_seed;
798
+ uniform float u_speed_factor;
799
+ uniform float u_drop_rate;
800
+ uniform float u_drop_rate_bump;
801
+ varying vec2 v_tex_pos;
802
+
803
+ const vec3 rand_constants = vec3(12.9898, 78.233, 4375.85453);
804
+ float rand(const vec2 co) {
805
+ float t = dot(rand_constants.xy, co);
806
+ return fract(sin(t) * (rand_constants.z + t));
807
+ }
808
+
809
+ void main() {
810
+ vec4 color = texture2D(u_particles, v_tex_pos);
811
+ vec2 pos = vec2(color.r / 255.0 + color.b, color.g / 255.0 + color.a);
812
+ vec4 w = texture2D(u_wind, pos);
813
+ vec2 velocity = w.a < 0.5 ? vec2(0.0) : mix(u_wind_min, u_wind_max, w.rg);
814
+ float speed_t = length(velocity) / length(u_wind_max);
815
+ vec2 offset = velocity * u_speed_factor;
816
+ pos = fract(1.0 + pos + offset);
817
+ vec2 seed = (pos + v_tex_pos) * u_rand_seed;
818
+ float drop_rate = u_drop_rate + speed_t * u_drop_rate_bump;
819
+ float drop = step(1.0 - drop_rate, rand(seed));
820
+ float reset = max(drop, w.a < 0.5 ? 1.0 : 0.0);
821
+ vec2 random_pos = vec2(rand(seed + 1.3), rand(seed + 2.1));
822
+ pos = mix(pos, random_pos, reset);
823
+ gl_FragColor = vec4(fract(pos * 255.0), floor(pos * 255.0) / 255.0);
824
+ }`,wA=`
825
+ precision mediump float;
826
+ attribute float a_index;
827
+ uniform sampler2D u_particles;
828
+ uniform sampler2D u_wind;
829
+ uniform vec2 u_wind_min;
830
+ uniform vec2 u_wind_max;
831
+ uniform float u_speed_max;
832
+ uniform float u_particles_res;
833
+ uniform mat4 u_matrix;
834
+ uniform vec4 u_bounds;
835
+ varying float v_speed_t;
836
+ const float PI = 3.141592653589793;
837
+ void main() {
838
+ vec4 color = texture2D(u_particles, vec2(
839
+ fract(a_index / u_particles_res),
840
+ floor(a_index / u_particles_res) / u_particles_res));
841
+ vec2 pos = vec2(color.r / 255.0 + color.b, color.g / 255.0 + color.a);
842
+ vec4 w = texture2D(u_wind, pos);
843
+ vec2 velocity = w.a < 0.5 ? vec2(0.0) : mix(u_wind_min, u_wind_max, w.rg);
844
+ v_speed_t = length(velocity) / u_speed_max;
845
+ float lon = mix(u_bounds.x, u_bounds.z, pos.x);
846
+ float lat = mix(u_bounds.y, u_bounds.w, pos.y);
847
+ float mx = (lon + 180.0) / 360.0;
848
+ float my = (180.0 - (180.0 / PI) * log(tan(PI / 4.0 + lat * PI / 360.0))) / 360.0;
849
+ gl_Position = u_matrix * vec4(mx, my, 0.0, 1.0);
850
+ gl_PointSize = 1.5;
851
+ }`,TA=`
852
+ precision mediump float;
853
+ uniform sampler2D u_color_ramp;
854
+ varying float v_speed_t;
855
+ void main() {
856
+ gl_FragColor = texture2D(u_color_ramp, vec2(clamp(v_speed_t, 0.0, 1.0), 0.5));
857
+ }`;function EA(e,t,n){let r=e.createShader(t);if(!r)throw Error(`createShader failed`);if(e.shaderSource(r,n),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS))throw Error(e.getShaderInfoLog(r)??`shader compile failed`);return r}function DA(e,t,n){let r=e.createProgram();if(!r)throw Error(`createProgram failed`);let i=EA(e,e.VERTEX_SHADER,t),a=EA(e,e.FRAGMENT_SHADER,n);if(e.attachShader(r,i),e.attachShader(r,a),e.linkProgram(r),!e.getProgramParameter(r,e.LINK_STATUS))throw Error(e.getProgramInfoLog(r)??`program link failed`);return e.detachShader(r,i),e.detachShader(r,a),e.deleteShader(i),e.deleteShader(a),r}function OA(e,t,n,r,i){let a=e.createTexture();if(!a)throw Error(`createTexture failed`);return e.bindTexture(e.TEXTURE_2D,a),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,t),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,r,i,0,e.RGBA,e.UNSIGNED_BYTE,n),e.bindTexture(e.TEXTURE_2D,null),a}function kA(e,t){let n=e.createBuffer();if(!n)throw Error(`createBuffer failed`);return e.bindBuffer(e.ARRAY_BUFFER,n),e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW),n}var AA;function jA(){if(AA!==void 0)return AA;let e=null;try{let t=document.createElement(`canvas`);if(e=t.getContext(`webgl`)??t.getContext(`experimental-webgl`),!e)return AA=!1,AA;DA(e,xA,CA),DA(e,wA,TA),AA=!0}catch{AA=!1}finally{e?.getExtension(`WEBGL_lose_context`)?.loseContext()}return AA}var MA=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h;#g;#_;#v=0;#y=0;#b;#x;#S;#C;#w;#T;#E=1;constructor(e,t={}){this.#e=e,this.#b=t.resolution??90,this.#x=this.#b*this.#b,this.#S=t.speedFactor??8e-4,this.#C=t.dropRate??.003,this.#w=t.dropRateBump??.01,this.#T=t.fadeOpacity??.96,this.#D()}#D(){let e=this.#e;this.#t=DA(e,xA,CA),this.#n=DA(e,wA,TA),this.#r=DA(e,xA,SA),this.#i={aPos:e.getAttribLocation(this.#r,`a_pos`),uScreen:e.getUniformLocation(this.#r,`u_screen`),uOpacity:e.getUniformLocation(this.#r,`u_opacity`)},this.#a={aPos:e.getAttribLocation(this.#t,`a_pos`),uParticles:e.getUniformLocation(this.#t,`u_particles`),uWind:e.getUniformLocation(this.#t,`u_wind`),uWindMin:e.getUniformLocation(this.#t,`u_wind_min`),uWindMax:e.getUniformLocation(this.#t,`u_wind_max`),uRandSeed:e.getUniformLocation(this.#t,`u_rand_seed`),uSpeedFactor:e.getUniformLocation(this.#t,`u_speed_factor`),uDropRate:e.getUniformLocation(this.#t,`u_drop_rate`),uDropRateBump:e.getUniformLocation(this.#t,`u_drop_rate_bump`)},this.#o={aIndex:e.getAttribLocation(this.#n,`a_index`),uParticles:e.getUniformLocation(this.#n,`u_particles`),uWind:e.getUniformLocation(this.#n,`u_wind`),uColorRamp:e.getUniformLocation(this.#n,`u_color_ramp`),uParticlesRes:e.getUniformLocation(this.#n,`u_particles_res`),uMatrix:e.getUniformLocation(this.#n,`u_matrix`),uWindMin:e.getUniformLocation(this.#n,`u_wind_min`),uWindMax:e.getUniformLocation(this.#n,`u_wind_max`),uSpeedMax:e.getUniformLocation(this.#n,`u_speed_max`),uBounds:e.getUniformLocation(this.#n,`u_bounds`)},this.#s=kA(e,new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]));let t=new Float32Array(this.#x);for(let e=0;e<this.#x;e+=1)t[e]=e;this.#c=kA(e,t);let n=e.createFramebuffer();if(!n)throw Error(`createFramebuffer failed`);this.#l=n,this.#u=OA(e,e.LINEAR,null,256,1);let r=this.#O();this.#m=OA(e,e.NEAREST,r,this.#b,this.#b),this.#h=OA(e,e.NEAREST,r,this.#b,this.#b),this.#g=OA(e,e.NEAREST,null,1,1),this.#_=OA(e,e.NEAREST,null,1,1),this.#d=void 0,this.#v=0,this.#y=0}reinit(){this.#D(),this.#p&&this.setTheme(this.#p),this.#f&&this.setWind(this.#f)}#O(){let e=new Uint8Array(this.#x*4);for(let t=0;t<e.length;t+=1)e[t]=Math.floor(Math.random()*256);return e}setWind(e){this.#f=e;let t=this.#e;this.#d&&t.deleteTexture(this.#d),this.#d=OA(t,t.LINEAR,e.data,e.width,e.height)}setTheme(e){this.#p=e;let t=this.#e;t.bindTexture(t.TEXTURE_2D,this.#u),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,256,1,0,t.RGBA,t.UNSIGNED_BYTE,e),t.bindTexture(t.TEXTURE_2D,null)}setOpacity(e){this.#E=e}#k(e,t){if(e===this.#v&&t===this.#y)return;let n=this.#e;n.deleteTexture(this.#g),n.deleteTexture(this.#_);let r=new Uint8Array(e*t*4);this.#g=OA(n,n.NEAREST,r,e,t),this.#_=OA(n,n.NEAREST,r,e,t),this.#v=e,this.#y=t}#A(e,t,n){let r=this.#e;r.bindBuffer(r.ARRAY_BUFFER,e),r.enableVertexAttribArray(t),r.vertexAttribPointer(t,n,r.FLOAT,!1,0,0)}#j(e,t){let n=this.#e,r=this.#i;n.useProgram(this.#r),this.#A(this.#s,r.aPos,2),n.activeTexture(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,e),n.uniform1i(r.uScreen,0),n.uniform1f(r.uOpacity,t),n.drawArrays(n.TRIANGLES,0,6)}#M(){let e=this.#e;if(!this.#d||!this.#f)return;let t=this.#a;e.bindFramebuffer(e.FRAMEBUFFER,this.#l),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,this.#h,0),e.viewport(0,0,this.#b,this.#b),e.useProgram(this.#t),this.#A(this.#s,t.aPos,2),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,this.#m),e.uniform1i(t.uParticles,0),e.activeTexture(e.TEXTURE1),e.bindTexture(e.TEXTURE_2D,this.#d),e.uniform1i(t.uWind,1),e.uniform2f(t.uWindMin,this.#f.uMin,this.#f.vMin),e.uniform2f(t.uWindMax,this.#f.uMax,this.#f.vMax),e.uniform1f(t.uRandSeed,Math.random()),e.uniform1f(t.uSpeedFactor,this.#S),e.uniform1f(t.uDropRate,this.#C),e.uniform1f(t.uDropRateBump,this.#w),e.drawArrays(e.TRIANGLES,0,6);let n=this.#m;this.#m=this.#h,this.#h=n}#N(e){let t=this.#e;if(!this.#d||!this.#f)return;let n=this.#o;t.useProgram(this.#n),this.#A(this.#c,n.aIndex,1),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,this.#m),t.uniform1i(n.uParticles,0),t.activeTexture(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this.#d),t.uniform1i(n.uWind,1),t.activeTexture(t.TEXTURE2),t.bindTexture(t.TEXTURE_2D,this.#u),t.uniform1i(n.uColorRamp,2),t.uniform1f(n.uParticlesRes,this.#b),t.uniformMatrix4fv(n.uMatrix,!1,e),t.uniform2f(n.uWindMin,this.#f.uMin,this.#f.vMin),t.uniform2f(n.uWindMax,this.#f.uMax,this.#f.vMax),t.uniform1f(n.uSpeedMax,26),t.uniform4f(n.uBounds,this.#f.west,this.#f.south,this.#f.east,this.#f.north),t.drawArrays(t.POINTS,0,this.#x)}render(e,t,n,r){let i=this.#e;if(!this.#d||!this.#f)return;this.#k(t,n),i.disable(i.DEPTH_TEST),i.disable(i.STENCIL_TEST),this.#M(),i.bindFramebuffer(i.FRAMEBUFFER,this.#l),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,this.#_,0),i.viewport(0,0,t,n),r?(i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT)):this.#j(this.#g,this.#T),i.enable(i.BLEND),i.blendFunc(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA),this.#N(e),i.disable(i.BLEND),i.bindFramebuffer(i.FRAMEBUFFER,null),i.enable(i.BLEND),i.blendFunc(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA),this.#j(this.#_,this.#E),i.disable(i.BLEND);let a=this.#g;this.#g=this.#_,this.#_=a}blit(e,t){let n=this.#e;!this.#d||!this.#f||(this.#k(e,t),n.disable(n.DEPTH_TEST),n.disable(n.STENCIL_TEST),n.bindFramebuffer(n.FRAMEBUFFER,null),n.enable(n.BLEND),n.blendFunc(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA),this.#j(this.#g,this.#E),n.disable(n.BLEND))}dispose(){let e=this.#e;e.deleteProgram(this.#t),e.deleteProgram(this.#n),e.deleteProgram(this.#r),e.deleteBuffer(this.#s),e.deleteBuffer(this.#c),e.deleteFramebuffer(this.#l),e.deleteTexture(this.#u),e.deleteTexture(this.#m),e.deleteTexture(this.#h),e.deleteTexture(this.#g),e.deleteTexture(this.#_),this.#d&&e.deleteTexture(this.#d)}},NA=`binnacle-weather-wind`,PA=`binnacle-weather-wind-line`,FA=`binnacle-weather-wind-particles`,IA=40;function LA(e){return Array.isArray(e)?e:e.defaultProjectionData?.mainMatrix??[]}function RA(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function zA(e){let t=jA()&&!Sc(),n=`day`,r=1,i=!1,a,o=NaN,s,c=[],l=0,u=()=>{};function d(e){return $D(e)}function f(e){if(!e.map.getSource(NA)){let t={type:`geojson`,data:Gm()};e.map.addSource(NA,t)}if(!e.map.getLayer(PA)){let t={id:PA,type:`line`,source:NA,layout:{"line-cap":`round`,visibility:i?`visible`:`none`},paint:{"line-color":d(n),"line-width":2,"line-opacity":r}};e.map.addLayer(t,e.beforeIdFor(`weather`))}}function p(t){let n=e.grid;t.map.getSource(NA)?.setData(n?vA(n,e.bracket):Gm())}function m(){if(!s)return;let t=e.grid,n=t?bA(t,e.bracket):void 0;n&&s.setWind(n)}function h(e){let t=!1,a=e.map.getCanvas(),o=e=>{e.preventDefault(),t=!0},d=()=>{t=!1;try{s?.reinit()}catch(t){console.warn(`[wind] particle reinit failed, using arrows`,t),s?.dispose(),s=void 0,f(e),p(e)}},h=()=>{!document.hidden&&i&&s&&!t&&e.map.triggerRepaint()},g={id:FA,type:`custom`,onAdd(t,i){a.addEventListener(`webglcontextlost`,o),a.addEventListener(`webglcontextrestored`,d),document.addEventListener(`visibilitychange`,h),u=()=>{a.removeEventListener(`webglcontextlost`,o),a.removeEventListener(`webglcontextrestored`,d),document.removeEventListener(`visibilitychange`,h),u=()=>{}};try{s=new MA(i),s.setTheme(yA(n)),s.setOpacity(r),m()}catch(t){console.warn(`[wind] particle init failed, using arrows`,t),s=void 0,f(e),p(e)}},render(n,r){if(!s||!i||t)return;let a=LA(r);if(a.length<16)return;let o=!RA(a,c);c=a.slice();let u=n.drawingBufferWidth,d=n.drawingBufferHeight,f=performance.now();o||f-l>=IA?(l=f,s.render(a,u,d,o)):s.blit(u,d),document.hidden||e.map.triggerRepaint()},onRemove(){u(),s?.dispose(),s=void 0}};e.map.addLayer(g,e.beforeIdFor(`weather`))}return{id:kD.wind,title:`Wind`,band:`weather`,supportsOpacity:!0,defaultVisible:!1,layerIds:[FA,PA],add(e){t?h(e):f(e)},reset(){a=void 0,o=NaN},sync(t){let n=e.grid;n===a&&e.selectedTime===o||(a=n,o=e.selectedTime,m(),!s&&t.map.getLayer(PA)&&p(t))},remove(e){e.map.getLayer(FA)&&e.map.removeLayer(FA),e.map.getLayer(PA)&&e.map.removeLayer(PA),e.map.getSource(NA)&&e.map.removeSource(NA)},setVisible(e,t){i=t,e.map.getLayer(PA)&&e.map.setLayoutProperty(PA,`visibility`,t?`visible`:`none`),t&&e.map.triggerRepaint()},setOpacity(e,t){r=t,s?.setOpacity(t),e.map.getLayer(PA)&&e.map.setPaintProperty(PA,`line-opacity`,t)},applyTheme(e,t){n=t.theme,s?.setTheme(yA(n)),e.map.getLayer(PA)&&e.map.setPaintProperty(PA,`line-color`,d(n))}}}var BA=class{#e=z(fn(typeof navigator>`u`?!0:navigator.onLine));get online(){return W(this.#e)}set online(e){B(this.#e,e,!0)}#t;constructor(){if(typeof window>`u`)return;let e=()=>{this.online=!0},t=()=>{this.online=!1};window.addEventListener(`online`,e),window.addEventListener(`offline`,t),this.#t=()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,t)}}dispose(){this.#t?.(),this.#t=void 0}},VA=`false`,HA=`false`,UA=VA===`true`,WA=HA===`true`;function GA(e={}){let{immediate:t=!1,onNeedReload:n,onNeedRefresh:r,onOfflineReady:i,onRegistered:a,onRegisteredSW:o,onRegisterError:s}=e,c,l,u,d=async(e=!0)=>{await l,UA||u?.()};async function f(){if(`serviceWorker`in navigator){if(c=await QE(async()=>{let{Workbox:e}=await import(`./workbox-window.prod.es5-Bd17z0YL.js`);return{Workbox:e}},[]).then(({Workbox:e})=>new e(`/signalk-binnacle/sw.js`,{scope:`/signalk-binnacle/`,type:`classic`})).catch(e=>{s?.(e)}),!c)return;if(u=()=>{c?.messageSkipWaiting()},!WA)if(UA)c.addEventListener(`activated`,e=>{(e.isUpdate||e.isExternal)&&(n?n():window.location.reload())}),c.addEventListener(`installed`,e=>{e.isUpdate||i?.()});else{let e=!1,t=()=>{e=!0,c?.addEventListener(`controlling`,e=>{e.isUpdate&&(n?n():window.location.reload())}),r?.()};c.addEventListener(`installed`,n=>{n.isUpdate===void 0?n.isExternal===void 0?!e&&i?.():n.isExternal?t():!e&&i?.():n.isUpdate||i?.()}),c.addEventListener(`waiting`,t)}c.register({immediate:t}).then(e=>{o?o(`/signalk-binnacle/sw.js`,e):a?.(e)}).catch(e=>{s?.(e)})}}return l=f(),d}function KA(){typeof caches>`u`||caches.delete(`binnacle-pmtiles`).catch(()=>{})}function qA(e){KA(),navigator.storage?.persist?.().catch(()=>void 0);let t=GA({onNeedRefresh:()=>e?.(),onRegisterError:e=>{let t=e instanceof Error?e.message:String(e);if(/certificate|ssl/i.test(t)){console.info(`[pwa] Offline caching is off: this browser does not trust the server certificate. Install the Signal K server certificate as a trusted root to enable offline use.`);return}console.warn(`[pwa] service worker registration failed`,e)}});return{update:()=>void t(!0)}}var JA=`binnacle-ais-icon`,YA=28,XA=2.6,ZA=Um;function QA(e){return Jm(YA,(t,n,r)=>{let i=n/XA,a=Math.abs(t-r);if(n>3&&Math.abs(a-i)<=1.4&&a<=i+1.4||n>=YA-3&&a<=i)return e;let o=n>2&&Math.abs(a-i)<=2.4&&a<=i+2.4,s=n>=YA-4&&a<=i+1;return o||s?ZA:null})}var $A=`binnacle-ais`,ej=`binnacle-ais-symbol`,tj=hf(`day`).aisTarget;function nj(e,t){let n=-1;function r(){return{type:`FeatureCollection`,features:e.list().map(e=>({type:`Feature`,geometry:{type:`Point`,coordinates:[e.position.longitude,e.position.latitude]},properties:{id:e.id,name:e.name??``,heading:Fc(e.headingRad,e.cogRad)}}))}}function i(){let e=t.aisVersion;return e===n?!1:(n=e,!0)}return ph({id:`ais`,title:`AIS targets`,band:`traffic`,sourceId:$A,layerId:ej,iconId:JA,iconImage:QA,defaultColor:tj,paintColor:e=>e.aisTarget,features:r,shouldRefresh:i})}var rj=`/signalk/v1/api/tracks`;function ij([e,t,n,r]){return`${t},${e},${r},${n}`}function aj(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(!Array.isArray(n))return;let[e,r]=n;if(typeof e!=`number`||typeof r!=`number`)return;t.push([e,r])}return t}function oj(e){if(!e||typeof e!=`object`)return[];let{coordinates:t}=e;if(!Array.isArray(t))return[];let n=[];for(let e of t){let t=aj(e);t&&t.length>=2&&n.push(t)}return n}async function sj(e,t,n){try{let r=await fetch(`${e}${rj}?bbox=${ij(n)}`,hc(gu(t)));if(!r.ok)return;let i=_u(await r.json());if(!i)return;let a=[];for(let[e,t]of Object.entries(i))for(let n of oj(t))a.push({context:e,line:n});return a}catch{return}}var cj=`binnacle-ais-trails`,lj=`binnacle-ais-trails-line`,uj=`traffic`,dj=.45,fj=1.5,pj=400,mj=3e4,hj=4,gj=.5;function _j(e,t,n,r){let i=hf(`day`),a=!0,o=!1,s=0,c=0,l,u=0,d,f,p,m=``;function h(e,t){e.map.getSource(cj)?.setData(t)}function g(e,t){let n=r?.(),i=n?t.filter(e=>e.context!==n):t,a=``;for(let e of i)a+=`${e.context};${e.line.length};${e.line[0]};${e.line[e.line.length-1]}|`;a!==m&&(m=a,h(e,Km(i.map(e=>({type:`Feature`,geometry:{type:`LineString`,coordinates:e.line},properties:{context:e.context}})))))}function _(e){m!==``&&(m=``,h(e,Gm()))}return{id:`ais-trails`,title:`AIS trails`,band:uj,supportsOpacity:!0,layerIds:[lj],add(e){if(m=``,l=void 0,c=0,d=void 0,f=void 0,p=void 0,!e.map.getSource(cj)){let t={type:`geojson`,data:Gm()};e.map.addSource(cj,t)}if(!e.map.getLayer(lj)){let t={id:lj,type:`line`,source:cj,layout:{"line-cap":`round`,"line-join":`round`},paint:{"line-color":Wm(i.aisTarget),"line-width":fj,"line-opacity":dj}};e.map.addLayer(t,e.beforeIdFor(uj))}},sync(r){if(!a)return;if(!n()){_(r);return}let i=Date.now(),m=r.map.getZoom(),h=r.map.getCenter();if(m!==d||h.lng!==f||h.lat!==p){d=m,f=h.lng,p=h.lat,u=i;return}if(i-u<pj||o)return;let v=Ys(r.map.getBounds());if(i<c&&l&&qs(l,v))return;o=!0,c=i+mj;let y=Ks(v,gj);l=y,sj(e,t,y).then(e=>{if(e){s=0,g(r,e);return}s+=1,s>=hj&&_(r)}).finally(()=>{o=!1})},applyTheme(e,t){i=t,e.map.setPaintProperty(lj,`line-color`,Wm(i.aisTarget))},setVisible(e,t){a=t,Pf(e.map,[lj],t)},setOpacity(e,t){e.map.setPaintProperty(lj,`line-opacity`,t*dj)},remove(e){Ff(e.map,[lj],[cj])}}}var vj=`binnacle-ais-vectors`,yj=`binnacle-ais-vectors-line`,bj=`traffic`,xj=10,Sj=60,Cj=.25,wj=.8,Tj=2;function Ej(e){return[`match`,[`get`,`severity`],`danger`,e.danger,`warning`,e.warning,Wm(e.aisTarget)]}function Dj(e,t){let n=[];for(let r of e){if(r.cogRad===void 0)continue;let e=r.sogMps??0;if(e<Cj)continue;let i=e*xj*Sj,a=[r.position.longitude,r.position.latitude],o=dd(r.position.latitude,r.position.longitude,r.cogRad,i);n.push({type:`Feature`,geometry:{type:`LineString`,coordinates:[a,o]},properties:{severity:t.get(r.id)??`clear`}})}return n}function Oj(e,t){let n=hf(`day`),r=!0,i=-1,a,o=new Map;return{id:`ais-vectors`,title:`AIS course vectors`,band:bj,supportsOpacity:!0,layerIds:[yj],add(e){if(i=-1,a=void 0,!e.map.getSource(vj)){let t={type:`geojson`,data:Gm()};e.map.addSource(vj,t)}if(!e.map.getLayer(yj)){let t={id:yj,type:`line`,source:vj,layout:{"line-cap":`round`,"line-join":`round`},paint:{"line-color":Ej(n),"line-width":Tj,"line-opacity":wj}};e.map.addLayer(t,e.beforeIdFor(bj))}},sync(n){if(!r)return;let s=e.version,c=t().contacts;if(!(s===i&&c===a)){i=s,a=c,o.clear();for(let e of c)o.set(e.id,e.severity);n.map.getSource(vj)?.setData(Km(Dj(e.list(),o)))}},applyTheme(e,t){n=t,e.map.setPaintProperty(yj,`line-color`,Ej(n))},setVisible(e,t){r=t,Pf(e.map,[yj],t)},setOpacity(e,t){e.map.setPaintProperty(yj,`line-opacity`,t*wj)},remove(e){Ff(e.map,[yj],[vj])}}}var kj=`https://geo.vliz.be/geoserver/MarineRegions/wms`,Aj=`Flanders Marine Institute (VLIZ), marineregions.org, CC-BY`,jj=[{id:`bound-eez`,title:`Maritime boundaries`,tiles:[uh(kj,`eez_boundaries`)],attribution:Aj,category:`areas`},{id:`bound-12nm`,title:`Territorial sea (12 nm)`,tiles:[uh(kj,`eez_12nm`)],attribution:Aj,category:`areas`}];function Mj(e){return fh(e,`safety`)}function Nj(e){return fh(e,`bathymetry`)}var Pj=`https://gis.charttools.noaa.gov/arcgis/rest/services/MCS/NOAAChartDisplay/MapServer/exts/MaritimeChartService/WMSServer`,Fj=(e,t,n,r={})=>({id:e,title:t,tiles:[uh(Pj,n)],minzoom:0,maxzoom:18,bounds:[-180,-15,180,75],attribution:`NOAA Office of Coast Survey, Electronic Navigational Charts (ENC)`,parent:r.parent,group:r.group}),Ij={id:`noaa-enc`,title:`NOAA ENC (US)`},Lj=`https://ows.emodnet-bathymetry.eu/wms`,Rj={id:`emodnet`,title:`EMODnet (Europe)`},zj=[-73.125,5.625,45,90],Bj=`EMODnet Bathymetry Consortium (2022): EMODnet Digital Bathymetry (DTM)`,Vj=`https://nowcoast.noaa.gov/geoserver/bluetopo/wms`,Hj={id:`bluetopo`,title:`BlueTopo (US)`},Uj=[-138,-53.876,17.046,59.55],Wj=`NOAA Office of Coast Survey, BlueTopo / National Bathymetric Source`,Gj=[{id:`depth-gebco`,title:`GEBCO bathymetry (global)`,tiles:[uh(`https://wms.gebco.net/mapserv`,`GEBCO_LATEST`)],minzoom:0,maxzoom:12,attribution:`GEBCO_2024 Grid, GEBCO Compilation Group (2024)`},{id:`depth-emodnet`,title:`Bathymetry`,tiles:[uh(Lj,`emodnet:mean_multicolour`)],minzoom:0,maxzoom:12,bounds:zj,attribution:Bj,group:Rj},{id:`depth-emodnet-quality`,title:`Quality index`,tiles:[uh(Lj,`emodnet:quality_index`,`quality_index_combined`)],minzoom:0,maxzoom:12,bounds:zj,attribution:Bj,parent:`depth-emodnet`,group:Rj},{id:`depth-bluetopo`,title:`Bathymetry`,tiles:[`https://nowcoast.noaa.gov/geoserver/gwc/service/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&LAYER=bluetopo:bathymetry&STYLE=&TILEMATRIXSET=EPSG:3857&TILEMATRIX=EPSG:3857:{z}&TILEROW={y}&TILECOL={x}&FORMAT=image/png8`],tileSize:512,minzoom:0,maxzoom:16,bounds:Uj,attribution:Wj,group:Hj},{id:`depth-bluetopo-uncertainty`,title:`Uncertainty`,tiles:[uh(Vj,`bathymetry`,`nbs_uncertainty`)],minzoom:0,maxzoom:16,bounds:Uj,attribution:Wj,parent:`depth-bluetopo`,group:Hj},Fj(`depth-noaa-enc`,`Base chart`,`0,1,2,3,4,5,6,7,10`,{group:Ij}),Fj(`depth-noaa-enc-quality`,`Data quality (ZOC)`,`8,9`,{parent:`depth-noaa-enc`,group:Ij})],Kj=`https://ows.emodnet-humanactivities.eu/wms`,qj={id:`emodnet-mpa`,title:`Protected areas (EU)`},Jj=[{id:`mpa-emodnet`,title:`Marine protected areas`,tiles:[uh(Kj,`marineprotectedareas`)],attribution:`EMODnet Human Activities`,group:qj,category:`areas`},{id:`mpa-natura2000`,title:`Natura 2000`,tiles:[uh(Kj,`natura2000areas`)],attribution:`EMODnet Human Activities`,parent:`mpa-emodnet`,group:qj},{id:`mpa-noaa`,title:`NOAA MPA inventory (US)`,tiles:[dh(`https://gis.charttools.noaa.gov/arcgis/rest/services/survey_priorities2_national/MPA_Inventory_Separates/MapServer`)],bounds:[-180,15,-60,75],attribution:`NOAA National Marine Protected Areas Center`,category:`areas`}];function Yj(e){return fh(e,`safety`)}function Xj(){return new Date(Date.now()-jc).toISOString().slice(0,10)}var Zj=`https://gibs.earthdata.nasa.gov/wmts/epsg3857/best`,Qj=(e,t)=>`${Zj}/${e}/default/${t}/GoogleMapsCompatible_Level7/{z}/{y}/{x}.png`;function $j(){let e=Xj();return[{id:`gibs-sst`,title:`Sea-surface temperature`,tiles:[Qj(`GHRSST_L4_MUR_Sea_Surface_Temperature`,e)],minzoom:0,maxzoom:7,defaultOpacity:.7,attribution:`NASA EOSDIS GIBS; GHRSST L4 MUR (JPL PO.DAAC)`},{id:`gibs-sea-ice`,title:`Sea ice concentration`,tiles:[Qj(`GHRSST_L4_MUR_Sea_Ice_Concentration`,e)],minzoom:0,maxzoom:7,defaultOpacity:.7,attribution:`NASA EOSDIS GIBS; GHRSST L4 MUR (JPL PO.DAAC)`}]}function eM(e){return fh(e,`weather`)}var tM=`binnacle-course-line-src`,nM=`binnacle-course-point-src`,rM=`binnacle-course-line`,iM=`binnacle-course-point`,aM=`routes`,oM=[rM,iM],sM=3,cM=6,lM=1.5;function uM(e,t){let n=hf(`day`),r=``;function i(e,t){e.map.getSource(tM)?.setData(t)}function a(e,t){e.map.getSource(nM)?.setData(t)}function o(e){r!==``&&(r=``,i(e,Gm()),a(e,Gm()))}return{id:`course`,title:`Course`,band:aM,supportsOpacity:!0,defaultVisible:!0,layerIds:oM,add(e){r=``;let t=e.beforeIdFor(aM);for(let t of[tM,nM])e.map.getSource(t)||e.map.addSource(t,{type:`geojson`,data:Gm()});if(!e.map.getLayer(rM)){let r={id:rM,type:`line`,source:tM,layout:{"line-cap":`round`,"line-join":`round`},paint:{"line-color":n.select,"line-width":sM,"line-dasharray":[2,1]}};e.map.addLayer(r,t)}if(!e.map.getLayer(iM)){let r={id:iM,type:`circle`,source:nM,paint:{"circle-radius":cM,"circle-color":n.select,"circle-stroke-color":Wm(Um),"circle-stroke-width":lM}};e.map.addLayer(r,t)}},sync(n){if(!e.active){o(n);return}let s=e.nextPosition,c=t.position;if(!s||!c){o(n);return}let l=`${c.longitude},${c.latitude}|${s.longitude},${s.latitude}`;if(l===r)return;r=l;let u=nc(c),d=nc(s);i(n,Km([{type:`Feature`,geometry:{type:`LineString`,coordinates:[u,d]},properties:{}}])),a(n,Km([{type:`Feature`,geometry:{type:`Point`,coordinates:d},properties:{}}]))},applyTheme(e,t){n=t,e.map.setPaintProperty(rM,`line-color`,n.select),e.map.setPaintProperty(iM,`circle-color`,n.select)},setVisible(e,t){Pf(e.map,oM,t)},setOpacity(e,t){e.map.setPaintProperty(rM,`line-opacity`,t),e.map.setPaintProperty(iM,`circle-opacity`,t),e.map.setPaintProperty(iM,`circle-stroke-opacity`,t)},remove(e){Ff(e.map,oM,[tM,nM])}}}function dM(e,t,n){let r=[];for(let i of e)t.has(i.id)&&(i.waypoints.length<2||r.push({type:`Feature`,geometry:{type:`LineString`,coordinates:i.waypoints.map(e=>nc(e.position))},properties:{id:i.id,active:i.id===n}}));return{type:`FeatureCollection`,features:r}}function fM(e,t){let n=[];for(let r of e)t.has(r.id)&&n.push(...sf(r.waypoints,{id:r.id}));return{type:`FeatureCollection`,features:n}}function pM(e,t,n){return{id:e,type:`circle`,source:t,paint:{"circle-radius":4,"circle-color":n.note,"circle-stroke-color":n.markerGlyph,"circle-stroke-width":1}}}function mM(e,t,n){return{id:e,type:`symbol`,source:t,layout:{"text-field":[`get`,`name`],"text-font":[`Noto Sans Regular`],"text-size":11,"text-offset":[0,1.1],"text-optional":!0},paint:{"text-color":n.label,"text-halo-color":n.background,"text-halo-width":1.5}}}function hM(e,t,n,r){e.setPaintProperty(t,`circle-color`,r.note),e.setPaintProperty(t,`circle-stroke-color`,r.markerGlyph),e.setPaintProperty(n,`text-color`,r.label),e.setPaintProperty(n,`text-halo-color`,r.background)}var gM=`binnacle-route-lines`,_M=`binnacle-route-line-casing`,vM=`binnacle-route-line`,yM=`binnacle-route-waypoints`,bM=`binnacle-route-waypoint`,xM=`binnacle-route-waypoint-label`,SM=`routes`,CM=[_M,vM,bM,xM];function wM(e){return[`case`,[`get`,`active`],e.select,e.note]}var TM=[`case`,[`get`,`active`],3,2],EM=[`case`,[`get`,`active`],5,4],DM=Wm(Um);function OM(e){let t=hf(`day`),n=-1;return{id:`routes`,title:`Routes`,band:SM,supportsOpacity:!0,layerIds:CM,add(e){n=-1;let r=e.beforeIdFor(SM);if(!e.map.getSource(gM)){let t={type:`geojson`,data:Gm()};e.map.addSource(gM,t)}if(!e.map.getSource(yM)){let t={type:`geojson`,data:Gm()};e.map.addSource(yM,t)}if(!e.map.getLayer(_M)){let t={id:_M,type:`line`,source:gM,layout:{"line-cap":`round`,"line-join":`round`},paint:{"line-color":DM,"line-width":EM}};e.map.addLayer(t,r)}if(!e.map.getLayer(vM)){let n={id:vM,type:`line`,source:gM,layout:{"line-cap":`round`,"line-join":`round`},paint:{"line-color":wM(t),"line-width":TM,"line-dasharray":[2,1]}};e.map.addLayer(n,r)}e.map.getLayer(bM)||e.map.addLayer(pM(bM,yM,t),r),e.map.getLayer(xM)||e.map.addLayer(mM(xM,yM,t),r)},sync(t){e.version!==n&&(n=e.version,t.map.getSource(gM)?.setData(dM(e.routes,e.shownIds,e.activeId)),t.map.getSource(yM)?.setData(fM(e.routes,e.shownIds)))},setVisible(e,t){Pf(e.map,CM,t)},setOpacity(e,t){e.map.setPaintProperty(_M,`line-opacity`,t),e.map.setPaintProperty(vM,`line-opacity`,t),e.map.setPaintProperty(bM,`circle-opacity`,t),e.map.setPaintProperty(xM,`text-opacity`,t)},applyTheme(e,n){t=n,e.map.setPaintProperty(vM,`line-color`,wM(t)),hM(e.map,bM,xM,t)},remove(e){Ff(e.map,CM,[gM,yM])}}}var kM=`binnacle-working-wpt`,AM=`binnacle-working-wpt`,jM=`binnacle-working-wpt-label`,MM=`binnacle-working-hl-seg`,NM=`binnacle-working-hl-seg`,PM=`binnacle-working-hl-dot`,FM=`binnacle-working-hl-halo`,IM=`binnacle-working-hl-ring`,LM=`routes`,RM=[AM,jM,NM,FM,IM],zM=10;function BM(e,t){let n=hf(t),r=-1,i,a,o,s=(e,t,n)=>{e.map.getSource(t)?.setData(n)};return{add(e){r=-1,i=void 0,a=void 0,o=e;let t=e.beforeIdFor(LM);for(let t of[kM,MM,PM])e.map.getSource(t)||e.map.addSource(t,{type:`geojson`,data:Gm()});if(e.map.getLayer(AM)||e.map.addLayer(pM(AM,kM,n),t),e.map.getLayer(jM)||e.map.addLayer(mM(jM,kM,n),t),!e.map.getLayer(NM)){let r={id:NM,type:`line`,source:MM,layout:{"line-cap":`round`,"line-join":`round`},paint:{"line-color":n.routeHighlight,"line-width":5}};e.map.addLayer(r,t)}e.map.getLayer(FM)||e.map.addLayer({id:FM,type:`circle`,source:PM,paint:{"circle-radius":12,"circle-color":n.select,"circle-opacity":.16}},t),e.map.getLayer(IM)||e.map.addLayer({id:IM,type:`circle`,source:PM,paint:{"circle-radius":7,"circle-color":n.select,"circle-stroke-color":n.markerGlyph,"circle-stroke-width":2}},t)},sync(t){if(e.editVersion===r)return;r=e.editVersion;let n=e.working,o=e.highlight,c=n!==i,l=o!==a;if(i=n,a=o,!n){if(c)for(let e of[kM,MM,PM])s(t,e,Gm());return}if(c&&s(t,kM,Km(sf(n.waypoints))),c||l){let e=df(n,o);s(t,MM,e.segments),s(t,PM,e.dots)}},setTheme(e){n=hf(e);let t=o?.map;t?.getLayer(AM)&&(hM(t,AM,jM,n),t.setPaintProperty(NM,`line-color`,n.routeHighlight),t.setPaintProperty(FM,`circle-color`,n.select),t.setPaintProperty(IM,`circle-color`,n.select),t.setPaintProperty(IM,`circle-stroke-color`,n.markerGlyph))},raise(e){let t=e.beforeIdFor(LM);for(let n of RM)e.map.getLayer(n)&&e.map.moveLayer(n,t)},hitTestWaypoint(e){let t=o?.map;if(!t?.getLayer(AM))return;let n=t.queryRenderedFeatures([[e.x-zM,e.y-zM],[e.x+zM,e.y+zM]],{layers:[AM]}),r=n.length>0?Number(n[0].properties?.index):NaN;return Number.isInteger(r)?r:void 0}}}var VM=[{id:`seamark`,title:`OpenSeaMap seamarks`,tiles:[`https://tiles.openseamap.org/seamark/{z}/{x}/{y}.png`],minzoom:0,maxzoom:18,attribution:`© OpenSeaMap contributors, ODbL`,category:`nav-aids`}];function HM(e){return fh(e,`safety`)}var UM=`binnacle-vessel`,WM=80,GM=64;function KM(e,t=e.a){return`rgba(${e.r}, ${e.g}, ${e.b}, ${(t/255).toFixed(3)})`}function qM(e,t){return{r:Math.round(e.r*t),g:Math.round(e.g*t),b:Math.round(e.b*t),a:e.a}}function JM(e){if(typeof document<`u`){let t=document.createElement(`canvas`);t.width=WM,t.height=WM;let n=t.getContext(`2d`);if(n)return YM(n,e)}return ZM(e)}function YM(e,t){let n=KM(qM(t,.5));return e.clearRect(0,0,WM,WM),e.scale(WM/GM,WM/GM),e.beginPath(),e.moveTo(32,4),e.quadraticCurveTo(44,24,43,44),e.quadraticCurveTo(42,53,38,57),e.lineTo(26,57),e.quadraticCurveTo(22,53,21,44),e.quadraticCurveTo(20,24,32,4),e.closePath(),e.fillStyle=KM(t),e.fill(),e.lineJoin=`round`,e.lineCap=`round`,e.lineWidth=2.5,e.strokeStyle=n,e.stroke(),e.getImageData(0,0,WM,WM)}var XM=2.4;function ZM(e){return qm(WM,e,(e,t,n)=>{let r=t/XM;return t>6&&Math.abs(e-n)<=r})}var QM=`binnacle-own-vessel`,$M=`binnacle-own-vessel-symbol`,eN=hf(`day`).ownVessel,tN=`own-vessel`;function nN(e){let t,n,r,i=()=>Fc(e.headingRad,e.cogRad);function a(){let t=e.position;return t?{type:`FeatureCollection`,features:[{type:`Feature`,geometry:{type:`Point`,coordinates:[t.longitude,t.latitude]},properties:{heading:i()}}]}:Gm()}function o(){let a=e.position,o=a?.longitude,s=a?.latitude,c=a?i():void 0;return o===t&&s===n&&c===r?!1:(t=o,n=s,r=c,!0)}return ph({id:tN,title:`Own vessel`,band:`vessel`,sourceId:QM,layerId:$M,iconId:UM,iconImage:JM,pixelRatio:2,defaultColor:eN,paintColor:e=>e.ownVessel,features:a,shouldRefresh:o})}var rN=K(`<button type="button" role="menuitem" class="item svelte-1pcb8yh"><!> Drop waypoint</button>`),iN=K(`<button type="button" role="menuitem" class="item svelte-1pcb8yh"><!> Measure from here</button>`),aN=K(`<button type="button" class="overlay-backdrop" aria-label="Dismiss menu"></button> <div class="menu svelte-1pcb8yh" role="menu" aria-label="Chart actions" tabindex="-1"><button type="button" role="menuitem" class="item svelte-1pcb8yh"><!> Go to here</button> <button type="button" role="menuitem" class="item svelte-1pcb8yh"><!> Start a route here</button> <!> <!></div>`,1);function oN(e,t){$e(t,!0),zn(()=>Ag(()=>t.onClose()));let n=R(()=>Math.min(Math.max(t.x,108),Math.max(108,t.width-200/2-8))),r=R(()=>2+ +!!t.onDropWaypoint+ +!!t.onMeasureFrom),i=R(()=>W(r)*44+4),a=R(()=>t.y>W(i)+16||t.y>t.height/2),o=R(()=>W(a)?t.y-8:t.y+8);var s=aN(),c=Cn(s),l=H(c,2),u=V(l);Uo(V(u),{size:16,"aria-hidden":`true`}),P(),N(u);var d=H(u,2);ts(V(d),{size:16,"aria-hidden":`true`}),P(),N(d);var f=H(d,2),p=e=>{var n=rN();Lo(V(n),{size:16,"aria-hidden":`true`}),P(),N(n),G(`click`,n,function(...e){t.onDropWaypoint?.apply(this,e)}),q(e,n)};Y(f,e=>{t.onDropWaypoint&&e(p)});var m=H(f,2),h=e=>{var n=iN();rs(V(n),{size:16,"aria-hidden":`true`}),P(),N(n),G(`click`,n,function(...e){t.onMeasureFrom?.apply(this,e)}),q(e,n)};Y(m,e=>{t.onMeasureFrom&&e(h)}),N(l),Gi(l,(e,t)=>Fg?.(e,t),()=>`[role="menuitem"]`),U(()=>ra(l,`left: ${W(n)??``}px; top: ${W(o)??``}px; inline-size: 200px; transform: translate(-50%, ${W(a)?`-100%`:`0`});`)),G(`click`,c,function(...e){t.onClose?.apply(this,e)}),G(`click`,u,function(...e){t.onGoToHere?.apply(this,e)}),G(`click`,d,function(...e){t.onStartRoute?.apply(this,e)}),q(e,s),et()}Qr([`click`]);var sN=K(`<div class="chart-canvas svelte-1mqhhzl"><!></div>`);function cN(e,t){$e(t,!0);let n,r,i,a,o=0,s=z(void 0);zn(()=>{i?.setTheme(t.theme),a?.setTheme(t.theme)}),Pm(),Pa(()=>{r=Nh({container:n,view:t.initialView,managerOptions:{saved:t.savedLayers,onChange:t.onLayersChange,savedOrder:t.savedOrder,onOrderChange:t.onOrderChange,pinned:[Py,`mob`,tN]},onView:e=>t.onViewChange?.(e),onUserPan:()=>t.onUserPan?.(),onContextMenu:e=>{!t.onGoToHere||t.routeStore.working||B(s,{x:e.x,y:e.y,lat:e.lat,lon:e.lng,width:n.clientWidth,height:n.clientHeight},!0)},onLoad:async({map:e,ctx:n,manager:r,recolor:c,isDestroyed:l,runTick:u})=>{e.on(`movestart`,()=>{B(s,void 0)}),e.on(`click`,e=>{!t.measure.active||t.routeStore.working||t.measure.add({latitude:e.lngLat.lat,longitude:e.lngLat.lng})}),e.on(`click`,e=>{if(!t.routeStore.working)return;let n=a?.hitTestWaypoint(e.point);n===void 0?t.routeStore.clearHighlight():t.routeStore.setHighlight({kind:`waypoint`,index:n})});let d=zu(),f=new Set((t.userCharts?.sources??[]).map(e=>e.id)),p=(await vv(d,t.chartsToken)??[]).filter(e=>!f.has(e.identifier));if(l())return;let m=DS(d,t.chartsToken,t.onNoteSelect,t.symbols,{isOnline:t.isOnline??(()=>!0)}),h=[UT(t.tides,t.units),ev(t.anchor,t.vessel,t.onAnchorMoved),sb(t.measure,t.units),OM(t.routeStore),uM(t.guidance,t.vessel),mD(t.waypoints,t.symbols),m,_j(d,t.chartsToken,t.aisTrailsAvailable??(()=>!1),()=>t.store.selfContext),Oj(t.aisTargets,()=>t.collision.assessment),nj(t.aisTargets,t.store),Ly(t.collision),Ib(t.mob,t.vessel),eE(d,t.chartsToken,t.historyProviders??(()=>void 0)),gE(t.recorder,t.trackSettings,t.savedTracks),nN(t.vessel)];if(await r.registerAll([...p.map(e=>Hm(e,d)),...Gj.map(e=>Nj(e)),...$j().map(e=>eM(e)),...jj.map(e=>Mj(e)),...Jj.map(e=>Yj(e)),...VM.map(e=>HM(e)),...h]),l())return;let g=n.beforeIdFor(`routes`),_,v=()=>(_??=QE(async()=>{let{createRouteEditor:e}=await import(`./route-edit-B05i0oxQ.js`);return{createRouteEditor:e}},[]).then(({createRouteEditor:n})=>{if(!l())return i=n({map:e,beforeId:g,theme:t.theme,onChange:e=>{let n=t.routeStore.working;n&&t.routeStore.setWorking({...n,waypoints:e})},onUserEdit:()=>t.onRouteEdited?.()}),i}).catch(e=>{console.error(`Route editor failed to load`,e),_=void 0,t.onRouteEditorError?.()}),_),y=new dy(r);y.refresh(),t.onReady?.(y),t.onUserChartsReady?.({register:async e=>{l()||(await r.register(Hm(e,d,`bathymetry`)),y.refresh())},unregister:e=>{r.unregister(bf(e)),y.refresh()}}),t.onMapReady?.(c),t.onCommandsReady?.({centerOnVessel:()=>{let n=t.vessel.position;if(!n)return;let r=e.getZoom();e.flyTo({center:[n.longitude,n.latitude],zoom:r<12?14:r,...Sc()?{duration:0}:{}})},recenterOnVessel:(t,n)=>{e.setCenter([n,t])},flyTo:(t,n)=>{let r=e.getZoom();e.flyTo({center:[n,t],zoom:r<11?12:r,...Sc()?{duration:0}:{}})},fitBounds:t=>{let n=Ws(t);n&&e.fitBounds(n,{padding:40,maxZoom:16,duration:Sc()?0:800})},getBounds:()=>Ys(e.getBounds()),clearNoteSelection:()=>m.deselect(n),startRouteEdit:(e,t)=>{let r=++o;v().then(i=>{r===o&&(i?.start(e,t),a?.raise(n))})},stopRouteEdit:()=>{o+=1,i?.stop()},applyLayers:(e,i)=>{r.applySnapshot(e,i),y.refresh(),t.routeStore.working&&a?.raise(n)}}),a=BM(t.routeStore,t.theme),a.add(n),u([...h,a])}})}),Fa(()=>r?.destroy());var c=sN(),l=V(c),u=e=>{let n=R(()=>W(s));{let r=R(()=>t.onDropWaypoint?()=>{t.onDropWaypoint({latitude:W(n).lat,longitude:W(n).lon}),B(s,void 0)}:void 0),i=R(()=>t.onMeasureFrom?()=>{t.onMeasureFrom({latitude:W(n).lat,longitude:W(n).lon}),B(s,void 0)}:void 0);oN(e,{get x(){return W(n).x},get y(){return W(n).y},get width(){return W(n).width},get height(){return W(n).height},onGoToHere:()=>{t.onGoToHere?.({latitude:W(n).lat,longitude:W(n).lon}),B(s,void 0)},onStartRoute:()=>{t.onStartRoute?.({latitude:W(n).lat,longitude:W(n).lon}),B(s,void 0)},get onDropWaypoint(){return W(r)},get onMeasureFrom(){return W(i)},onClose:()=>{B(s,void 0)}})}};Y(l,e=>{W(s)&&e(u)}),N(c),Oa(c,e=>n=e,()=>n),q(e,c),et()}var lN=K(`<button type="button"><span> </span> <!></button>`),uN=K(`<p class="caps-label svelte-1jistm7"> </p> <!>`,1),dN=K(`<p class="provenance muted-note svelte-1jistm7"> </p>`),fN=K(`<div class="rows svelte-1jistm7"><!> <!></div>`);function pN(e,t){$e(t,!0);let n=R(()=>[{label:`Area fill`,items:t.fills},{label:`Overlays`,items:t.overlays}].filter(e=>e.items.length>0));zg(e,{open:!0,get onClose(){return t.onClose},backdropLabel:`Close weather layers`,surfaceClass:`weather-menu`,ariaLabel:`Weather layers`,children:e=>{var r=fN(),i=V(r);Ei(i,17,()=>W(n),e=>e.label,(e,n)=>{var r=uN(),i=Cn(r),a=V(i,!0);N(i),Ei(H(i,2),17,()=>W(n).items,e=>e.id,(e,n)=>{var r=lN();let i;var a=V(r),o=V(a,!0);N(a);var s=H(a,2),c=e=>{no(e,{size:16,"aria-hidden":`true`})};Y(s,e=>{W(n).visible&&e(c)}),N(r),U(()=>{i=ta(r,1,`menu-row svelte-1jistm7`,null,i,{"is-on":W(n).visible}),Z(r,`aria-pressed`,W(n).visible),J(o,W(n).title)}),G(`click`,r,()=>t.onToggle(W(n).id,!W(n).visible)),q(e,r)}),U(()=>J(a,W(n).label)),q(e,r)});var a=H(i,2),o=e=>{var n=dN(),r=V(n,!0);N(n),U(()=>J(r,t.provenance)),q(e,n)};Y(a,e=>{t.provenance&&e(o)}),N(r),Gi(r,(e,t)=>Fg?.(e,t),()=>`.menu-row`),q(e,r)},$$slots:{default:!0}}),et()}Qr([`click`]);var mN=K(`<button type="button" class="icon-btn icon-btn--accent" aria-label="Back to menu" title="Back to menu"><!></button>`),hN=K(`<span class="layer-count svelte-qluf4r" aria-hidden="true"> </span>`),gN=K(`<div id="weather-layer-menu"><!></div>`),_N=K(`gust <b class="svelte-qluf4r"> </b> kn`,1),vN=K(`&middot; <b class="svelte-qluf4r"> </b> `,1),yN=K(`/ <b class="svelte-qluf4r"> </b> s`,1),bN=K(`from <b class="svelte-qluf4r"> </b>&deg;T`,1),xN=K(`&middot; waves <b class="svelte-qluf4r"> </b> <!> <!>`,1),SN=K(`&middot; rain <b class="svelte-qluf4r"> </b> `,1),CN=K(`<span class="readout-source svelte-qluf4r"> </span>`),wN=K(`<span class="readout-line">Wind <b class="svelte-qluf4r"> </b> kn from <b class="svelte-qluf4r"> </b>&deg;T <!> <!> <!> <!></span> <!> <button type="button" class="readout-close svelte-qluf4r" aria-label="Dismiss readout"><!></button>`,1),TN=K(`<span class="readout-line">Fetching conditions</span>`),EN=K(`<div class="conditions-slot svelte-qluf4r" id="weather-conditions" role="region" aria-label="Conditions and forecast"><!></div>`),DN=K(`<p class="hint svelte-qluf4r">Open the layers menu, upper left, to load weather for this area.</p>`),ON=K(`<span class="now-tick svelte-qluf4r" aria-hidden="true"></span>`),kN=K(`<div class="scrubber svelte-qluf4r" role="group" aria-label="Forecast playback"><button type="button" class="icon-btn step svelte-qluf4r" aria-label="Earlier"><!></button> <button type="button" class="icon-btn step svelte-qluf4r"><!></button> <button type="button" class="icon-btn step svelte-qluf4r" aria-label="Later"><!></button> <span class="track-wrap svelte-qluf4r"><input class="track range svelte-qluf4r" type="range" aria-label="Forecast time"/> <!></span> <span class="time svelte-qluf4r"> </span> <span class="visually-hidden" role="status"> </span></div>`),AN=K(`<span class="legend-scale svelte-qluf4r"><span class="legend-end svelte-qluf4r"> </span> <span class="legend-bar svelte-qluf4r"></span> <span class="legend-end svelte-qluf4r"> </span></span>`),jN=K(`<span class="legend-swatch svelte-qluf4r"><span class="legend-chip svelte-qluf4r"></span> </span>`),MN=K(`<span class="legend-swatches svelte-qluf4r"></span>`),NN=K(`<span class="legend-note svelte-qluf4r"> </span>`),PN=K(`<div class="legend-row svelte-qluf4r"><span class="legend-title caps-label svelte-qluf4r"> </span> <!> <!></div>`),FN=K(`<div class="legend svelte-qluf4r" role="group" aria-label="Weather legend"></div>`),IN=K(`<p class="provenance svelte-qluf4r"> </p>`),LN=K(`<section class="weather-panel svelte-qluf4r" id="weather-panel" aria-label="Weather" tabindex="-1"><header class="panel-header panel-head svelte-qluf4r"><!> <h2 class="panel-title svelte-qluf4r">Weather</h2> <button type="button">Here <!></button> <button type="button" class="panel-close" aria-label="Close weather"><!></button></header> <div class="panel-map svelte-qluf4r"><div class="map svelte-qluf4r"></div> <button type="button" aria-haspopup="true" title="Weather layers"><!> <!></button> <!> <div class="map-notes svelte-qluf4r"><div role="status"><!></div> <div role="status"> </div></div> <!> <!></div> <footer class="panel-foot svelte-qluf4r"><!> <!> <!></footer></section>`);function RN(e,t){$e(t,!0);let n=Na(t,`online`,3,!0),r=3*Ac,i=new sc(kc),a,o,s=zu(),c=!1,l=new AbortController,u,d,f=z(void 0),p=z(!1),m=z(!1),h=()=>{B(m,!1)},g=z(``),_=!1,v,y=z(!1),b,x,S=z(void 0),C=z(void 0),w=z(!1),T,E=0,D=R(()=>W(f)?.items??[]),O=R(()=>W(D).filter(e=>jD.has(e.id))),k=R(()=>W(D).filter(e=>!jD.has(e.id))),A=R(()=>W(D).filter(e=>e.visible).length),ee=R(()=>t.store.grid?.fetchedAt?`${MD} · fetched ${Cl(t.store.grid.fetchedAt)}`:void 0),te=R(()=>W(D).some(e=>e.id===kD.waves&&e.visible)),j=R(()=>W(D).some(e=>e.id===kD.radar&&e.visible)),ne=e=>W(D).some(t=>t.id===e&&t.visible),re=R(()=>W(te)&&!!t.store.grid?.partialWaves),ie=R(()=>{let e=W(re)?` (waves unavailable)`:``;switch(t.store.status){case`loading`:return t.store.grid?``:`Loading forecast`;case`error`:return`Weather unavailable: offline or rate limited`;case`stale`:{let n=t.store.grid?.fetchedAt,r=n===void 0?void 0:Math.round((i.now-n)/kc);return r===void 0?`Showing last forecast${e}`:`Showing forecast fetched ${r} min ago${e}`}default:return e?`Showing forecast${e}`:``}}),ae=R(()=>CO(t.store.selectedTime,i.now)),oe=z(void 0),se=R(()=>{if(W(ae))return`shows now only, hidden while the slider is off now`;if(!n())return`cached radar (offline), not live`;if(W(oe)===void 0)return`radar with short-term nowcast, regional resolution`;let e=Math.round((W(oe)-i.now)/kc);return`frame ${e===0?`now`:e>0?`+${e} min (nowcast)`:`${e} min`} · short-term nowcast`}),ce=R(()=>W(D).filter(e=>e.visible).map(e=>sO(e.id,t.theme,t.units.mode)).filter(e=>e!==void 0)),le=R(()=>t.store.grid&&t.store.grid.times.length>0?{start:t.store.grid.times[0],end:t.store.grid.times[t.store.grid.times.length-1],stepMs:r}:void 0),ue=R(()=>t.store.grid?wl(t.store.selectedTime,{zone:!0}):``),de=R(()=>t.store.selectedTime<i.now-r/2?`Past`:`Forecast`),fe=R(()=>{if(!W(le)||W(le).end<=W(le).start)return;let e=(i.now-W(le).start)/(W(le).end-W(le).start);return e>=0&&e<=1?e:void 0});function pe(e){me(),W(le)&&t.store.setSelectedTime(WO(e,W(le)))}function me(){B(y,!1),b&&clearInterval(b),b=void 0}function he(){if(W(y)||!W(le)){me();return}B(y,!0),b=setInterval(()=>W(le)&&t.store.setSelectedTime(KO(t.store.selectedTime,W(le))),700)}let ge={maxCells:200,forecastDays:5};function _e(){x&&clearTimeout(x),x=setTimeout(()=>{!u||W(A)===0||t.loader.load(t.store,u(),ge,{waves:W(te),radar:W(j)})},400)}let ve=8e3,ye=!1;function be(){T&&clearTimeout(T),T=void 0}function xe(e,t){be(),B(S,e,!0),B(C,e?t:void 0,!0),e&&!ye&&(T=setTimeout(Se,ve))}function Se(){be(),B(S,void 0),B(C,void 0),B(w,!1)}function Ce(){ye=!0,be()}function we(){ye=!1,W(S)&&!T&&(T=setTimeout(Se,ve))}async function Te(e,n){let r=++E,i=W(A)>0&&t.store.grid?tk(t.store.grid,e,n,t.store.bracket):void 0;if(!t.providerName){xe(i,i?MD:void 0);return}i?xe(i,MD):B(w,!0);let a=await De(n,e);c||r!==E||(B(w,!1),a?xe(a,t.providerName):i||Se())}let Ee=e=>W(C)===`Open-Meteo`?ne(e):!0;async function De(e,n){let r=t.store.selectedTime;if(Math.abs(r-Date.now())<EO){let r=await PO(s,e,n,t.token),i=r&&BO(r);if(i)return i}let i=await IO(s,e,n,48,t.token),a=i&&UO(i,r);return a?BO(a):void 0}function Oe(e){let t=!1;zn(()=>{e()&&!t?(t=!0,_e()):e()||(t=!1)})}Oe(()=>W(te)),Oe(()=>W(j)),zn(()=>{W(A)>0&&!t.store.grid&&_e()}),zn(()=>{d?.(t.theme)}),Pa(()=>{o=Nh({container:a,view:t.initialView,defaultZoom:3,minZoom:1,maxZoom:7,managerOptions:{saved:t.savedLayers,onChange:t.onLayersChange,exclusive:[AD]},onClick:e=>void Te(e.lng,e.lat),onLoad:async({map:e,manager:n,recolor:r,isDestroyed:i,runTick:a})=>{let o=[Wk(t.store),lO(t.store),ND(t.store),wO(t.store,void 0,void 0,e=>B(oe,e,!0)),zA(t.store),mO(t.store)];if(await n.registerAll(o),i())return;let s=new dy(n);s.refresh(),B(f,s,!0),!i()&&(t.onLayersReady?.(e=>{n.applySnapshot(e,[]),s.refresh()}),d=r,d(t.theme),u=()=>hg(e.getBounds()),e.on(`moveend`,_e),e.on(`zoomend`,()=>{_||e.getZoom()<6.95||(_=!0,B(g,`Zoom is capped at the weather data resolution`),v=setTimeout(()=>B(g,``),5e3))}),e.getCanvas().addEventListener(`keydown`,t=>{if(t.key!==`Enter`)return;let n=e.getCenter();Te(n.lng,n.lat)},{signal:l.signal}),a(o))}})}),Fa(()=>{c=!0,i.dispose(),x&&clearTimeout(x),T&&clearTimeout(T),v&&clearTimeout(v),me(),l.abort(),o?.destroy()});var ke=LN(),Ae=V(ke),je=V(Ae),Me=e=>{var n=mN();Ja(V(n),{size:20,"aria-hidden":`true`}),N(n),G(`click`,n,function(...e){t.onBack?.apply(this,e)}),q(e,n)};Y(je,e=>{t.onBack&&e(Me)});var Ne=H(je,4);let Pe;var Fe=H(V(Ne)),Ie=e=>{uo(e,{size:14,"aria-hidden":`true`})},Le=e=>{io(e,{size:14,"aria-hidden":`true`})};Y(Fe,e=>{W(p)?e(Ie):e(Le,-1)}),N(Ne);var Re=H(Ne,2);Vs(V(Re),{size:18,"aria-hidden":`true`}),N(Re),N(Ae);var ze=H(Ae,2),Be=V(ze);Oa(Be,e=>a=e,()=>a);var Ve=H(Be,2);let M;var He=V(Ve);ko(He,{size:20,"aria-hidden":`true`});var Ue=H(He,2),We=e=>{var t=hN(),n=V(t,!0);N(t),U(()=>J(n,W(A))),q(e,t)};Y(Ue,e=>{W(A)>0&&e(We)}),N(Ve);var Ge=H(Ve,2),Ke=e=>{var t=gN();pN(V(t),{get fills(){return W(O)},get overlays(){return W(k)},get provenance(){return W(ee)},onToggle:(e,t)=>W(f)?.toggle(e,t),onClose:h}),N(t),q(e,t)};Y(Ge,e=>{W(m)&&e(Ke)});var qe=H(Ge,2),Je=V(qe);let Ye;var Xe=V(Je),F=e=>{var n=wN(),r=Cn(n),i=H(V(r)),a=V(i,!0);N(i);var o=H(i,2),s=V(o,!0);N(o);var c=H(o,2),l=e=>{var t=_N(),n=H(Cn(t)),r=V(n,!0);N(n),P(),U(e=>J(r,e),[()=>zc(W(S).gustMs,0)]),q(e,t)};Y(c,e=>{W(S).gustMs!==void 0&&e(l)});var u=H(c,2),d=e=>{var n=vN(),r=H(Cn(n)),i=V(r,!0);N(r);var a=H(r);U((e,t)=>{J(i,e),J(a,` ${t??``}`)},[()=>ul(W(S).pressurePa,t.units.mode),()=>cl(t.units.mode)]),q(e,n)},f=R(()=>Ee(kD.pressure)&&W(S).pressurePa!==void 0);Y(u,e=>{W(f)&&e(d)});var p=H(u,2),m=e=>{var n=xN(),r=H(Cn(n)),i=V(r,!0);N(r);var a=H(r),o=H(a),s=e=>{var t=yN(),n=H(Cn(t)),r=V(n,!0);N(n),P(),U(e=>J(r,e),[()=>Rc(W(S).wavePeriodS,1)]),q(e,t)};Y(o,e=>{W(S).wavePeriodS!==void 0&&e(s)});var c=H(o,2),l=e=>{var t=bN(),n=H(Cn(t)),r=V(n,!0);N(n),P(),U(e=>J(r,e),[()=>Bc(W(S).waveFromRad)]),q(e,t)};Y(c,e=>{W(S).waveFromRad!==void 0&&e(l)}),U((e,t)=>{J(i,e),J(a,` ${t??``} `)},[()=>nl(W(S).waveHeightM,t.units.mode),()=>tl(t.units.mode)]),q(e,n)},h=R(()=>Ee(kD.waves)&&W(S).waveHeightM!==void 0);Y(p,e=>{W(h)&&e(m)});var g=H(p,2),_=e=>{var n=SN(),r=H(Cn(n)),i=V(r,!0);N(r);var a=H(r);U((e,t)=>{J(i,e),J(a,` ${t??``}`)},[()=>fl(W(S).precipitationMm,t.units.mode),()=>$O(W(S).precipIsRate,t.units.mode)]),q(e,n)},v=R(()=>(Ee(kD.precip)||Ee(kD.radar))&&W(S).precipitationMm!==void 0&&W(S).precipitationMm>=.1);Y(g,e=>{W(v)&&e(_)}),N(r);var y=H(r,2),b=e=>{var t=CN(),n=V(t,!0);N(t),U(()=>J(n,W(C))),q(e,t)};Y(y,e=>{W(C)&&e(b)});var x=H(y,2);Vs(V(x),{size:14,"aria-hidden":`true`}),N(x),U((e,t)=>{J(a,e),J(s,t)},[()=>zc(W(S).speedMs,0),()=>Bc(W(S).fromRad)]),G(`click`,x,Se),q(e,n)},Ze=e=>{q(e,TN())};Y(Xe,e=>{W(S)?e(F):W(w)&&e(Ze,1)}),N(Je);var Qe=H(Je,2);let I;var tt=V(Qe,!0);N(Qe),N(qe);var nt=H(qe,2),rt=e=>{var n=EN();Pk(V(n),{get origin(){return s},get token(){return t.token},get providerName(){return t.providerName},get position(){return t.position},get store(){return t.store},get units(){return t.units}}),N(n),q(e,n)};Y(nt,e=>{W(p)&&e(rt)});var it=H(nt,2),at=e=>{q(e,DN())};Y(it,e=>{W(A)===0&&e(at)}),N(ze);var ot=H(ze,2),st=V(ot),ct=e=>{var n=kN(),r=V(n);oo(V(r),{size:16,"aria-hidden":`true`}),N(r);var i=H(r,2),a=V(i),o=e=>{Go(e,{size:16,"aria-hidden":`true`})},s=e=>{Yo(e,{size:16,"aria-hidden":`true`})};Y(a,e=>{W(y)?e(o):e(s,-1)}),N(i);var c=H(i,2);co(V(c),{size:16,"aria-hidden":`true`}),N(c);var l=H(c,2),u=V(l);X(u);var d=H(u,2),f=e=>{var t=ON();U(()=>ra(t,`inset-inline-start: ${W(fe)*100}%`)),q(e,t)};Y(d,e=>{W(fe)!==void 0&&e(f)}),N(l);var p=H(l,2),m=V(p);N(p);var h=H(p,2),g=V(h,!0);N(h),N(n),U(()=>{Z(i,`aria-label`,W(y)?`Pause`:`Play`),Z(u,`min`,W(le).start),Z(u,`max`,W(le).end),Z(u,`step`,W(le).stepMs),ga(u,t.store.selectedTime),Z(u,`aria-valuetext`,`${W(de)??``} ${W(ue)??``}`),J(m,`${W(de)??``} · ${W(ue)??``}`),J(g,W(y)?``:W(ue))}),G(`click`,r,()=>pe(GO(t.store.selectedTime,-1,W(le)))),G(`click`,i,he),G(`click`,c,()=>pe(GO(t.store.selectedTime,1,W(le)))),G(`input`,u,e=>pe(Number(e.currentTarget.value))),q(e,n)};Y(st,e=>{W(le)&&e(ct)});var lt=H(st,2),ut=e=>{var t=FN();Ei(t,21,()=>W(ce),e=>e.id,(e,t)=>{var n=PN(),r=V(n),i=V(r,!0);N(r);var a=H(r,2),o=e=>{var n=AN(),r=V(n),i=V(r,!0);N(r);var a=H(r,2),o=H(a,2),s=V(o,!0);N(o),N(n),U(()=>{J(i,W(t).lowLabel),ra(a,`background:${W(t).gradient??``}`),J(s,W(t).highLabel)}),q(e,n)},s=e=>{var n=MN();Ei(n,21,()=>W(t).swatches,e=>e.label,(e,t)=>{var n=jN(),r=V(n),i=H(r);N(n),U(()=>{ra(r,`background:${W(t).color??``}`),J(i,` ${W(t).label??``}`)}),q(e,n)}),N(n),q(e,n)};Y(a,e=>{W(t).gradient?e(o):W(t).swatches&&e(s,1)});var c=H(a,2),l=e=>{var n=NN(),r=V(n,!0);N(n),U(()=>J(r,W(t).id===kD.radar?W(se):W(t).note)),q(e,n)};Y(c,e=>{W(t).note&&e(l)}),N(n),U(()=>J(i,W(t).title)),q(e,n)}),N(t),q(e,t)};Y(lt,e=>{W(ce).length>0&&e(ut)});var dt=H(lt,2),ft=e=>{var t=IN(),n=V(t,!0);N(t),U(()=>J(n,W(ee))),q(e,t)};Y(dt,e=>{W(ee)&&e(ft)}),N(ot),N(ke),Gi(ke,(e,t)=>jg?.(e,t),()=>t.onClose),U(()=>{Pe=ta(Ne,1,`btn btn-pill btn-compact here-btn svelte-qluf4r`,null,Pe,{"is-on":W(p)}),Z(Ne,`aria-expanded`,W(p)),Z(Ne,`aria-controls`,W(p)?`weather-conditions`:void 0),M=ta(Ve,1,`icon-pill layer-trigger svelte-qluf4r`,null,M,{"is-on":W(m)||W(A)>0}),Z(Ve,`aria-expanded`,W(m)),Z(Ve,`aria-controls`,W(m)?`weather-layer-menu`:void 0),Z(Ve,`aria-label`,W(A)>0?`Weather layers, ${W(A)} on`:`Weather layers`),Ye=ta(Je,1,`map-note map-note--readout svelte-qluf4r`,null,Ye,{show:!!W(S)||W(w)}),I=ta(Qe,1,`map-note map-note--status svelte-qluf4r`,null,I,{show:!!W(ie)||!!W(g)}),J(tt,W(ie)||W(g))}),G(`click`,Ne,()=>B(p,!W(p))),G(`click`,Re,function(...e){t.onClose?.apply(this,e)}),G(`click`,Ve,()=>B(m,!W(m))),Zr(`pointerenter`,Je,Ce),Zr(`pointerleave`,Je,we),G(`focusin`,Je,Ce),G(`focusout`,Je,we),Hi(3,ke,()=>Eg,()=>({y:20,duration:Sc()?0:180,opacity:.3})),q(e,ke),et()}Qr([`click`,`focusin`,`focusout`,`input`]);var zN=K(`<button type="button" class="btn btn-warning btn-pill" aria-pressed="true"><!> </button>`),BN=K(`<button type="button" class="btn btn-primary btn-pill">Update</button>`),VN=K(`<div class="arrival-banner svelte-1hicyxm" role="status"> </div>`),HN=K(`<div class="note-panel-slot svelte-1hicyxm"><!></div>`),UN=K(`<div class="panel-slot svelte-1hicyxm" id="layers-panel"><!></div>`),WN=K(`<div class="panel-slot svelte-1hicyxm"><!></div>`),GN=K(`<span class="readout fix-lost svelte-1hicyxm" role="alert" aria-live="assertive">Data link failed, reload</span>`),KN=K(`<span class="readout offline svelte-1hicyxm" role="status" aria-live="polite">Offline</span>`),qN=K(`<span class="readout fix-lost svelte-1hicyxm" role="status" aria-live="polite">No GPS fix</span>`),JN=K(`<span class="readout lookout svelte-1hicyxm" title="AIS targets the lookout is tracking">AIS <b class="svelte-1hicyxm"> </b></span>`),YN=K(`Anchor <b class="svelte-1hicyxm">no GPS</b>`,1),XN=K(`Anchor <b class="svelte-1hicyxm"> </b>/<b class="svelte-1hicyxm"> </b> `,1),ZN=K(`<span role="status"><!></span>`),QN=K(`<main class="binnacle-shell svelte-1hicyxm"><div class="visually-hidden" role="alert" aria-live="assertive" aria-atomic="true"> </div> <div class="visually-hidden" role="alert" aria-live="assertive" aria-atomic="true"> </div> <div class="visually-hidden" role="alert" aria-live="assertive" aria-atomic="true"> </div> <div class="visually-hidden" aria-live="polite" aria-atomic="true"> </div> <header class="topbar svelte-1hicyxm"><span class="topbar-start svelte-1hicyxm"><!> <span class="brand svelte-1hicyxm">Binnacle <span class="version svelte-1hicyxm"></span></span></span> <!> <span class="topbar-actions svelte-1hicyxm"><!> <!> <!> <!></span></header> <section class="chart-host svelte-1hicyxm" aria-label="Chart"><!> <div class="banner-slot svelte-1hicyxm"><!></div> <!> <div><!> <!> <!> <!> <!></div> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!></section> <footer class="status-strip svelte-1hicyxm"><div class="strip-start svelte-1hicyxm"><span role="status" aria-live="polite"><span class="conn-dot svelte-1hicyxm" aria-hidden="true"></span> <span class="visually-hidden"> </span></span> <!> <!> <!> <!> <!> <span class="readout svelte-1hicyxm">SOG <b class="svelte-1hicyxm"> </b> kn</span> <span class="readout svelte-1hicyxm">COG <b class="svelte-1hicyxm"> </b>&deg;T</span></div> <div class="strip-center svelte-1hicyxm"><button type="button" class="btn btn-pill" aria-label="Center on boat" title="Center on boat"><!> Center</button> <button type="button" aria-label="Follow boat"><!> Follow</button> <button type="button" aria-haspopup="dialog"><!> Charts</button> <button type="button" aria-haspopup="dialog"><!> Forecast</button></div> <div class="center-cluster svelte-1hicyxm"><span class="readout svelte-1hicyxm">View</span> <span class="readout svelte-1hicyxm"><b class="svelte-1hicyxm"> </b></span> <span class="readout svelte-1hicyxm"><b class="svelte-1hicyxm"> </b></span> <span class="readout svelte-1hicyxm">z<b class="svelte-1hicyxm"> </b></span></div></footer></main>`);function $N(e,t){$e(t,!0);let n=zu(),r=new Ju,i=new sc,a=new dg(r,i),o=new ad(r),s=hu(),c=new Bl(n),l=new BA,u=Pl(),d=new zd(a,o,u,()=>E.watching),f=new Yy,p=new Ey(i),m=z(void 0),h=z(void 0),g=R(()=>W(m)?.apis.has(`notifications`)??!1);function _(e,t){s.publish({context:Vu,updates:[{values:[{path:e,value:t}]}]})}let v,y=new ky({publish:async(e,t)=>{if(!W(g)){_(e,t);return}if(t.state===`normal`){if(v){let r=await Fu(n,W(De),v);v=void 0,r||_(e,t)}return}if(v){let r=await Pu(n,W(De),v,{state:t.state,message:t.message});if(r===`updated`)return;if(r===`failed`){_(e,t);return}v=void 0}v=await Nu(n,W(De),{state:t.state,message:t.message,path:`navigation.collision`,includePosition:!0,includeCreatedAt:!0}),v||_(e,t)}});function b(){p.toggle(),p.active&&v&&(B(S,void 0),Iu(n,W(De),v).then(e=>{e||B(S,`Could not silence the alert boat-wide. Other stations may still sound.`)}))}let x=new Yd(r),S=z(void 0);function C(e,t,r){e.id&&(B(S,void 0),t(n,W(De),e.id).then(e=>{e||B(S,r,!0)}))}function w(e){C(e,Iu,`Could not silence the alert. Check the connection and access.`)}function T(e){C(e,Lu,`Could not acknowledge the alert. Check the connection and access.`)}let E=new kd(r,a),D=new Jy(B_),O=new Kd(r,a,i),k=new Jy(Db),A=new Wd,ee=Ml(),te=new Zh(ee,hm()),j=new pf,ne=new Ud(r,a),re=new Jy(Lb),ie=new Ol(`binnacle:arrival-muted`,!1),ae=new Ol(`binnacle:planning-speed-kn`,5),oe=R(()=>{let e=ne.activePointIndex,t=ne.activePointTotal,n=ne.distanceToNextMeters,r=j.activeId;if(r==null||e==null||t==null||n==null||t-e<=1)return;let i=j.routes.find(e=>e.id===r);if(i)return n+of(i.waypoints,e)}),se=R(()=>{let e=W(oe);if(e==null)return;let t=a.sogMps;return{distanceToGoMeters:e,timeToGoSeconds:t==null?void 0:Cd(e,t)}}),ce=new qh,le=PT({pluginAvailable:()=>W(m)?.plugins.has(`tides`)??!1,pluginTides:(e,t)=>Fw(e,t,{origin:n,token:W(De)})}),ue=new Cg,de=mA(),fe=z(!1),pe=z(void 0),me=new Ol(`binnacle:weather-layers`,{[kD.wind]:{visible:!0,opacity:1},[kD.waves]:{visible:!0,opacity:.7}}),he=z(fn([])),ge=z(fn(new Set)),_e=0,ve={version:()=>_e,features:()=>AE(W(he),W(ge))},ye=z(void 0),be=z(null),xe=z(!1),Se=()=>{B(be,null)},Ce=()=>{B(be,null),B(xe,!0)},we=z(!1),Te=e=>{B(be,e,!0),W(we)&&B(Oe,void 0)},Ee,De=z(void 0),Oe=z(void 0),ke=z(void 0),Ae=z(void 0),je=z(!1),Me=qA(()=>B(je,!0)),Ne=l_(e=>Ee?.(e)),Pe=Al(),Fe=kl(Pe.value)?Pe.value:void 0,Ie=new Ol(`binnacle:layers`,{}),Le=new Ol(`binnacle:layer-order`,[]),Re=new Ol(`binnacle:layer-categories`,{}),ze=new ig,Be=new GE,Ve=new mg,M=new Kh(n,void 0),He=z(void 0);async function Ue(){let e=await _D(n,W(De));if(e){Ve.setWaypoints(e);return}Ve.waypoints.length===0&&B(He,`Could not load waypoints. Check the connection.`)}async function We(e){B(He,void 0);let t=Kg(`Waypoint`);if(t===void 0)return;let r={id:vc(),name:t,position:e};if(!await vD(n,W(De),r)){B(He,`Could not save the waypoint. Check the connection and write access.`),B(be,`waypoints`);return}await Ue()}async function Ge(e,t){B(He,void 0);let r=Ve.waypoints.find(t=>t.id===e);if(r){if(!await vD(n,W(De),{...r,name:t})){B(He,`Could not rename the waypoint.`);return}await Ue()}}async function Ke(e){if(B(He,void 0),!await yD(n,W(De),e)){B(He,`Could not delete the waypoint.`);return}await Ue()}let qe=new $d,Je=!1,Ye=z(void 0);zn(()=>{W(fe)||B(Ye,void 0)});let Xe=XS({theme:Ne,layers:Ie,layerOrder:Le,layerCategories:Re,weatherLayers:me,thresholds:u,trackSettings:ee,planningSpeedKn:ae,arrivalMuted:ie,unitsLocal:ze.localSetting});function F(){return Xe.capture()}function Ze(e){Je=!0,Xe.apply(e),W(gt)?.applyLayers(e.layers,e.layerOrder),W(Ye)?.(e.weatherLayers),jr().then(()=>{Je=!1})}let Qe=!1;zn(()=>{if(Xe.track(),!Qe){Qe=!0;return}Je||Pr(()=>qe.markDirty())}),!qe.loadedFromStorage&&qe.profiles.length===0&&ZS(qe,F());let I=!1;zn(()=>{if(I||c.status!==`authenticated`||!c.token)return;let e=new tf(n,c.token);qe.syncWithServer(e).then(e=>{e&&(I=!0)})});function tt(e){let t=qe.profiles.find(t=>t.id===e);t&&(Ze(t.settings),qe.setActive(e))}let nt=!1;zn(()=>{nt||(nt=!0,qe.defaultId&&qe.activeId===void 0&&tt(qe.defaultId))});function rt(e){let t=qe.save(e,F());qe.setActive(t.id)}function it(e){let t=qe.profiles.find(t=>t.id===e);t&&RS(t)}function at(e){for(let t of e)qe.save(t.name,t.settings)}let ot=new Ol(`binnacle:user-charts`,[]);function st(e){W(De)&&yv(n,W(De),og(e,e.origin.url)).then(t=>{t||console.warn(`User chart "${e.id}" did not sync to the server.`)})}function ct(e){dt.delete(e)&&W(ut)?.unregister(e)}let lt=new lg(ot.value,e=>ot.set(e),e=>{e.bounds&&W(gt)?.fitBounds(e.bounds),st(e)},e=>{W(De)&&bv(n,W(De),e.id)},e=>{ct(e.id),st(e)}),ut=z(void 0),dt=new Set,ft=R(()=>(Ie.value.tides?.visible??!1)||W(be)===`tides`),pt;function mt(e){B(Ae,e,!0),pt&&clearTimeout(pt),pt=setTimeout(()=>{Pe.set(e),W(ft)&&le.load(ce,e.lat,e.lon)},400)}function ht(){let e=W(Ae)??Fe;e&&le.load(ce,e.lat,e.lon)}zn(()=>{W(ft)&&Pr(ht)});let gt=z(void 0),_t=z(!1);function vt(e,t){let n=Ie.value[e];if(n?.visible===t)return;let r=n?{...n,visible:t}:{visible:t,opacity:1},i={...Ie.value,[e]:r};Ie.set(i),W(gt)?.applyLayers(i,Le.value)}function yt(){vt(`measure`,!0),A.start()}let bt=R(()=>[{id:`routes`,label:`Routes`,icon:ts,group:`Navigate`,disabled:!W(gt),onSelect:()=>Te(`routes`)},{id:`tracks`,label:`Tracks`,icon:hs,group:`Navigate`,onSelect:()=>Te(`tracks`)},{id:`waypoints`,label:`Waypoints`,icon:Lo,group:`Navigate`,onSelect:()=>Te(`waypoints`)},{id:`measure`,label:`Measure`,icon:rs,group:`Navigate`,pressed:A.active,onSelect:yt},{id:`layers`,label:`Layers and charts`,icon:ko,group:`Navigate`,disabled:!W(ye),onSelect:()=>Te(`layers`)},{id:`forecast`,label:`Forecast`,icon:po,group:`Conditions`,pressed:W(fe),onSelect:()=>B(fe,!W(fe))},{id:`tides`,label:`Tides`,icon:zs,group:`Conditions`,onSelect:()=>{Te(`tides`),ht()}},{id:`trends`,label:`Trends`,icon:eo,group:`Conditions`,onSelect:()=>Te(`trends`)},{id:`ais`,label:`AIS targets`,icon:$o,group:`Safety`,onSelect:()=>Te(`ais`)},{id:`anchor`,label:`Anchor watch`,icon:Ga,group:`Safety`,onSelect:()=>Te(`anchor`)},{id:`alarms`,label:`Alarms`,icon:Qa,group:`Safety`,onSelect:()=>Te(`alarms`)},{id:`profiles`,label:`Profiles`,icon:Fs,group:`Settings`,onSelect:()=>Te(`profiles`)}]);zn(()=>{f.update(d.assessment.worst,d.suppressed,p.active,d.escalating,E.watching)}),zn(()=>o.startPruning());let xt=R(()=>{let{contacts:e}=d.assessment;if(d.suppressed||e.length===0)return``;let t=e[0],n=sd(t.name,t.id),r=e.length;return`${t.severity===`warning`?`Collision warning`:`Collision danger`}: ${r} ${r===1?`contact`:`contacts`}, nearest ${n}, CPA ${hl(t.cpaMeters)} nautical miles in ${gl(t.tcpaSeconds,1)} minutes.`}),St=R(()=>p.active?`Collision alarm muted.`:``),Ct=R(()=>Math.max(1,Math.ceil(p.remainingMs/6e4)));zn(()=>{y.update(d.assessment)}),zn(()=>{E.updateFix()}),zn(()=>{D.update(E.dragging&&!E.acknowledged)});let wt=R(()=>{if(E.degraded)return`Anchor watch degraded: no GPS fix, so drag detection has stopped.`;if(!E.dragging||E.acknowledged)return``;let e=E.distanceMeters,t=E.radiusMeters;return`Anchor alarm: the boat is dragging${e==null?``:` ${Math.round(e)} meters from the anchor`}${t==null?``:`, watch radius ${Math.round(t)} meters`}.`});zn(()=>{k.update(O.active&&!O.acknowledged)});let Tt=R(()=>{if(!O.active||O.acknowledged)return``;let e=O.distanceMeters;return`Man overboard${e==null?``:`, range ${Math.round(e)} meters`}. Steer back to the mark.`});function Et(e){s.publish({context:Vu,updates:[{values:[{path:$.mobNotification,value:e}]}]})}let Dt;function Ot(e){let t=O.trigger(e);W(g)?(Dt=Ru(n,W(De),`Man overboard`),Dt.then(e=>{e||Et(Ob(t.position))})):Et(Ob(t.position)),t.position&&W(gt)?.flyTo(t.position.latitude,t.position.longitude)}function kt(){O.cancel();let e=Dt;Dt=void 0,e?e.then(async e=>{e&&await Fu(n,W(De),e)||Et(kb())}):Et(kb())}function At(){let e=O.position;e&&Gn(e)}let jt=z(void 0),Mt=R(()=>fv(n,W(De),{standardApiAvailable:W(m)?.apis.has(`anchor`)??!1}));async function Nt(){B(jt,void 0);let e=a.position;if(!e)return;let t=E.preferredRadiusMeters;await W(Mt).drop(t)||(W(Mt).kind===`standard`&&B(jt,`Could not drop the anchor on the server. Check the connection.`),E.dropLocal(e,t))}async function Pt(e,t,n){if(B(jt,void 0),E.mode!==`server`){n();return}await e()||B(jt,`Could not ${t} on the server. Check the connection.`)}function Ft(){return Pt(()=>W(Mt).raise(),`raise the anchor`,()=>E.raiseLocal())}function It(e){return E.rememberRadius(e),Pt(()=>W(Mt).setRadius(e),`set the radius`,()=>E.setRadiusLocal(e))}function Lt(e){return Pt(()=>W(Mt).setPosition(e),`move the anchor`,()=>E.movePositionLocal(e))}zn(()=>{let e=a.position;e&&te.consider(e.latitude,e.longitude,a.sogMps??0)}),zn(()=>{let e=W(gt),t=a.position;W(_t)&&t&&e?.recenterOnVessel(t.latitude,t.longitude)}),zn(()=>{let e=W(ut),t=lt.sources;if(!e)return;let n=new Set(t.map(e=>e.id));for(let e of dt)n.has(e)||ct(e);for(let n of t)dt.has(n.id)||(dt.add(n.id),Rt(n,e))});async function Rt(e,t){try{await t.register(og(e,e.origin.url))}catch(t){console.error(`User chart overlay failed to register`,t),dt.delete(e.id);return}if(!dt.has(e.id)){t.unregister(e.id);return}Ee?.(Ne.theme)}function zt(){_e+=1}async function Bt(){B(he,await zE(n,W(De)),!0),zt()}let Vt=z(void 0);async function Ht(e){if(te.points.length<2)return;B(Vt,void 0);let t=vc();if(!await BE(n,W(De),t,e,te.points)){B(Vt,`Could not save the track. Check the connection and access.`);return}te.clear(),B(ge,new Set(W(ge)).add(t),!0),await Bt()}async function Ut(e){if(B(Vt,void 0),!await VE(n,W(De),e)){B(Vt,`Could not delete the track. Check the connection and access.`);return}let t=new Set(W(ge));t.delete(e),B(ge,t,!0),await Bt()}function Wt(e){let t=new Set(W(ge));t.has(e)?t.delete(e):t.add(e),B(ge,t,!0),zt()}function Gt(e){let t=[];e.points.forEach((e,n)=>{e.forEach((e,r)=>{t.push(r===0&&n>0?{...e,gap:!0}:e)})}),kE(e.name,t)}async function Kt(){let e=await yw(n,W(De));if(e){j.setRoutes(e);return}j.routes.length===0&&Jt(`Could not load routes. Check the connection.`)}let qt=z(void 0);function Jt(e){B(qt,e,!0)}function Yt(){B(qt,void 0)}let Xt=z(!1),Zt=R(()=>j.activeId!==void 0||W(Xt)),Qt=!1;zn(()=>{let e=ne.active;!e&&Qt&&W(Zt)&&(j.setActive(void 0),B(Xt,!1)),Qt=e});async function $t(){return await nC(n,W(De))?(j.setActive(void 0),B(Xt,!1),ne.clear(),re.stop(),!0):!1}function en(e){W(gt)?.flyTo(e.latitude,e.longitude)}function tn(e){let t=j.routes.find(t=>t.id===e)?.waypoints[0]?.position;t&&W(gt)?.flyTo(t.latitude,t.longitude)}function nn(e,t){j.toggleShown(e,t),t&&tn(e)}let rn=R(()=>MC(W(m)?.plugins)),an=z(!1),on=z(void 0),sn=z(void 0),cn,ln=0,un=z(void 0),dn=z(!1),pn={budget:`The daily AI budget is used up. Try again later, or raise the cap in the route-drafting plugin.`,"no-route":`The AI could not draft a usable route for that. Try rephrasing, or a shorter passage.`,"model-error":`The AI returned an unusable response. Try again, or rephrase the request.`,timeout:`The draft timed out. Check the connection and try again.`,unreachable:`Could not reach the route-drafting plugin. Check it is installed and the server is reachable.`,unauthorized:`AI route drafting needs a Signal K admin session. Sign in to the server as an administrator.`,"bad-request":`The draft request was rejected. Try rephrasing the passage.`},mn={...pn,"no-route":`The optimized route came back unusable or too detailed. Simplify the route and try again.`,"bad-request":`The drawn route could not be optimized. Simplify it and try again.`},hn=Uc(.05);function gn(){cn?.abort(),cn=void 0,ln++,B(an,!1),B(on,void 0),B(sn,void 0),B(un,void 0),B(dn,!1)}let _n=.5;function vn({latitude:e,longitude:t}){return Gs([t-_n,e-_n,t+_n,e+_n])}async function yn(e){cn?.abort();let t=new AbortController;cn=t;let r=++ln;B(an,!0);let i;try{i=await VC(n,W(De),e,t.signal)}catch{return r===ln?(B(an,!1),{ok:!1,error:`model-error`,message:`unexpected`}):void 0}if(r===ln)return B(an,!1),i}function bn(e,t,n){let r={id:n,name:e.name??``,waypoints:e.waypoints};j.setWorking(r),W(gt)?.startRouteEdit(r);let i=Xs(e.waypoints.map(e=>e.position));i&&W(gt)?.fitBounds(Ks(i,.15)),B(sn,{name:r.name,destination:e.destination?.name,note:e.note===``?void 0:e.note,fuel:e.fuel?fC(e.fuel,ze.mode):void 0,confidence:e.confidence,flags:e.flags?sC(e.flags):void 0,source:t},!0)}function xn(e){let t=j.highlight;if(t?.kind===`leg`&&t.index===e){j.clearHighlight();return}j.setHighlight({kind:`leg`,index:e});let n=j.working?.waypoints,r=n?.[e],i=n?.[e+1];if(!r||!i)return;let a=W(gt)?.getBounds();if(a&&Js(a,r.position)&&Js(a,i.position))return;let o=Xs([r.position,i.position]);o&&W(gt)?.fitBounds(Ks(o,.3))}async function Sn(e){Yt(),B(on,void 0);let t=a.position;if(!t){B(on,`No vessel position yet. Wait for a GPS fix before drafting.`);return}if(a.positionStale){B(on,`Vessel position is stale. Wait for a fresh GPS fix before drafting.`);return}let n=await yn({prompt:e,from:t,bounds:W(gt)?.getBounds()??vn(t),units:ze.mode});if(n){if(!n.ok){n.error!==`cancelled`&&B(on,pn[n.error],!0);return}bn(n.route,`draft`,vc())}}async function wn(e){Yt();let t=j.working;if(!t||t.waypoints.length<2)return;let n=t.waypoints.map(e=>e.position),r=a.position&&!a.positionStale?a.position:n[0],i=Xs(n),o=i?Ks(i,.25):vn(n[0]);B(un,t,!0),B(dn,!1);let s=await yn({route:n,prompt:e,from:r,bounds:o,units:ze.mode});if(s){if(!s.ok){s.error!==`cancelled`&&Jt(mn[s.error]),B(un,void 0);return}if(!s.optimized){Jt(`This route-drafting plugin version cannot optimize a route. Update the plugin.`),B(un,void 0);return}if(pd(n,s.route.waypoints.map(e=>e.position),hn)){B(dn,!0),B(un,void 0);return}bn(s.route,`optimize`,t.id)}}function Tn(e){Yt(),gn(),j.setWorking({id:vc(),name:``,waypoints:[]}),W(gt)?.startRouteEdit(void 0,e)}function En(e){Te(`routes`),Tn(e)}function Dn(e){let t=j.routes.find(t=>t.id===e);t&&(j.setWorking(t),W(gt)?.startRouteEdit(t),tn(e))}async function On(e){Yt();let t=j.working;if(!t||t.waypoints.length<2)return;let r={...t,name:e.trim()||Gg(`Route`)};if(!await xw(n,W(De),r)){Jt(`Could not save the route. It is kept under edit so you can retry.`),j.setWorking(r);return}W(gt)?.stopRouteEdit(),j.setWorking(void 0),gn(),j.toggleShown(r.id,!0),await Kt()}function kn(){let e=W(un);gn(),e&&(j.setWorking(e),W(gt)?.startRouteEdit(e))}function An(){W(gt)?.stopRouteEdit(),j.setWorking(void 0),gn()}function jn(){An(),Yt(),Se()}function Mn(){An(),Yt(),Ce()}function Nn(){W(sn)===void 0&&!W(an)&&W(un)===void 0&&!W(dn)||gn()}async function Pn(){let e=Date.now(),{info:t,calc:r}=await iC(n,W(De));ne.seed(t,r,e);let i=rC(t);i&&(i.routeId?(j.activeId!==i.routeId&&(j.setActive(i.routeId),j.toggleShown(i.routeId,!0)),B(Xt,!1)):i.goto&&(j.setActive(void 0),B(Xt,!0)))}async function Fn(e){if(Yt(),e===j.activeId&&!await $t()){Jt(`Could not stop the active route, so it was not deleted.`);return}if(!await Sw(n,W(De),e)){Jt(`Could not delete the route.`);return}j.toggleShown(e,!1),await Kt()}async function In(e){if(Yt(),!await $S(n,W(De),bw(e))){Jt(`Could not activate the route. Check the connection.`);return}j.setActive(e),B(Xt,!1),j.toggleShown(e,!0),tn(e),await Pn()}async function Ln(){Yt(),await $t()||Jt(`Could not stop the active route. Check the connection.`)}function Rn(e){tC(n,W(De),e).then(e=>{e||Jt(`Could not skip the waypoint. Check the connection.`)})}async function Bn(e){if(Yt(),te.points.length<2)return;let t=vE(te.points,e);if(!await xw(n,W(De),t)){Jt(`Could not save the track as a route.`);return}await Kt(),j.toggleShown(t.id,!0)}async function Vn(){if(Yt(),te.points.length<2)return;let e=vE(te.points,`Track home`);if(e.waypoints.reverse(),!await xw(n,W(De),e)){Jt(`Could not build the route home.`);return}if(await Kt(),!await $S(n,W(De),bw(e.id))){Jt(`Could not start navigating home.`);return}j.setActive(e.id),B(Xt,!1),j.toggleShown(e.id,!0),await Pn()}async function Hn(e){Yt();let t=j.routes.find(t=>t.id===e);if(!t)return;let r=ff(t);if(!await xw(n,W(De),r)){Jt(`Could not reverse the route.`);return}await Kt(),j.toggleShown(r.id,!0)}function Un(e){let t=j.routes.find(t=>t.id===e);t&&gw(t)}async function Wn(e){Yt();let t=wC(e);if(t.length===0){Jt(`No routes found in that GPX file.`);return}let r=[];for(let e of t)await xw(n,W(De),e)&&r.push(e.id);if(r.length===0){Jt(`Could not save the imported route.`);return}r.length<t.length&&Jt(`Imported ${r.length} of ${t.length} routes; the rest did not save.`),await Kt();for(let e of r)j.toggleShown(e,!0)}async function Gn(e){if(Yt(),!await eC(n,W(De),e)){Jt(`Could not set the destination. Check the connection.`);return}j.setActive(void 0),B(Xt,!0),await Pn()}let Kn=z(void 0),qn,Jn=!1;zn(()=>{let e=ne.arrived&&W(Zt);re.update(e&&!ie.value),e&&!Jn&&(B(Kn,ne.nextPointName??`destination`,!0),qn&&clearTimeout(qn),qn=setTimeout(()=>{B(Kn,void 0)},8e3),j.activeId!==void 0&&!ne.isLastPoint&&tC(n,W(De),1).then(e=>{e||Jt(`Could not advance to the next waypoint.`)})),Jn=e});function Yn(){B(Oe,void 0),W(gt)?.clearNoteSelection()}let Xn=e=>{B(Oe,e,!0),W(we)&&e&&B(be,null)},Zn=()=>{f.prime(),re.prime(),D.prime(),k.prime()},Qn={open:`Connected`,connecting:`Connecting`,reconnecting:`Reconnecting`,closed:`Not connected`},$n=R(()=>Qn[r.connection.phase]),er=R(()=>r.connection.phase===`reconnecting`||r.connection.phase===`closed`),tr=R(()=>a.positionStale),nr=l.online;zn(()=>{let e=l.online,t=W(er);e&&!nr&&t&&s.reconnect(),nr=e});let rr=R(()=>o.list().length),ir=`${n}/admin/#/security/access/requests`,ar=!1,or=z(!1);zn(()=>{ar||c.status!==`authenticated`&&c.status!==`unsecured`||(ar=!0,lr(c.token??void 0).catch(e=>{console.error(`Signal K stream failed to connect`,e),B(or,!0)}))});let sr=!1,cr;zn(()=>{let e=r.connection.phase,t=e===`open`&&cr!==`open`&&sr;cr=e,e===`open`&&(sr=!0),t&&(Kt(),Ue(),ur(c.token??void 0),ze.syncFromServer(n),Pn())});async function lr(e){B(De,e,!0),B(ke,nx(n,e),!0),await s.connect(Bu(e),e=>r.applyFrame(e)),await s.raw.subscribe([{path:$.headingTrue,policy:`instant`,minPeriod:200},{path:$.position,policy:`instant`,minPeriod:1e3},{path:$.courseOverGroundTrue,policy:`instant`,minPeriod:1e3},{path:$.speedOverGround,policy:`instant`,minPeriod:1e3},{path:$.courseNextPoint,policy:`instant`,minPeriod:1e3},{path:$.coursePreviousPoint,policy:`instant`,minPeriod:1e3},{path:$.courseActiveRoute,policy:`instant`,minPeriod:1e3},{path:$.courseArrivalCircle,policy:`instant`,minPeriod:1e3},{path:$.courseCalcValues,policy:`instant`,minPeriod:1e3},{path:$.depthBelowTransducer,policy:`instant`,minPeriod:1e3},{path:$.windSpeedApparent,policy:`instant`,minPeriod:1e3},{path:$.outsidePressure,policy:`instant`,minPeriod:5e3},{path:$.anchorPosition,policy:`instant`,minPeriod:1e3},{path:$.anchorMaxRadius,policy:`instant`,minPeriod:1e3},{path:$.allNotifications,policy:`instant`,minPeriod:1e3},{path:$.position,context:Hu,policy:`fixed`,period:5e3},{path:$.courseOverGroundTrue,context:Hu,policy:`fixed`,period:5e3},{path:$.speedOverGround,context:Hu,policy:`fixed`,period:5e3},{path:$.headingTrue,context:Hu,policy:`fixed`,period:5e3},{path:$.name,context:Hu,policy:`fixed`,period:5e3},{path:$.aisShipType,context:Hu,policy:`fixed`,period:5e3},{path:$.closestApproach,context:Hu,policy:`fixed`,period:5e3}]),await Promise.all([Bt(),Kt(),Ue(),Pn()])}async function ur(e){let t=await OO(n,e);t!==void 0&&B(pe,kO(t),!0)}zn(()=>{c.status!==`authenticated`&&c.status!==`unsecured`||(ur(c.token??void 0),ze.syncFromServer(n),Tu(n,c.token??void 0).then(e=>{e&&B(m,e,!0)}),Du(n,c.token??void 0).then(e=>{e&&B(h,e,!0)}),M.setAuth(c.token??void 0),ed(n,c.token??void 0).then(e=>{e&&M.setSymbols(e)}))}),Pa(()=>{Be.start(()=>({depth:a.depthMeters,wind:a.windSpeedApparentMps,pressure:a.outsidePressurePa,sog:a.sogMps})),window.addEventListener(`pointerdown`,Zn,{once:!0}),c.watch(),c.probe();let e=window.matchMedia(`(max-width: 600px)`),t=()=>{B(we,e.matches,!0)};return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)}),Fa(()=>{Be.stop(),pt&&clearTimeout(pt),qn&&clearTimeout(qn),window.removeEventListener(`pointerdown`,Zn),f.stop(),D.stop(),k.stop(),re.stop(),c.stop(),l.dispose(),i.dispose(),s.disconnect()});var dr=QN(),fr=V(dr),pr=V(fr,!0);N(fr);var mr=H(fr,2),hr=V(mr,!0);N(mr);var gr=H(mr,2),_r=V(gr,!0);N(gr);var vr=H(gr,2),yr=V(vr,!0);N(vr);var br=H(vr,2),xr=V(br),Sr=V(xr);pb(Sr,{get items(){return W(bt)},get open(){return W(xe)},onOpenChange:e=>B(xe,e,!0)});var Cr=H(Sr,2),wr=H(V(Cr));wr.textContent=`v0.7.0`,N(Cr),N(xr);var Tr=H(xr,2);yb(Tr,{get mob(){return O},onTrigger:Ot,onLocate:en});var Er=H(Tr,2),Dr=V(Er),Or=e=>{var t=zN(),n=V(t);Ls(n,{size:16,"aria-hidden":`true`});var r=H(n);N(t),U(()=>{Z(t,`aria-label`,`Collision alarm muted, ${W(Ct)??``} minutes left, tap to unmute`),Z(t,`title`,`Collision alarm muted, ${W(Ct)??``} min left, tap to unmute`),J(r,` Muted ${W(Ct)??``}m`)}),G(`click`,t,()=>p.unmute()),q(e,t)};Y(Dr,e=>{p.active&&e(Or)});var kr=H(Dr,2),Ar=e=>{var t=BN();G(`click`,t,()=>Me.update()),q(e,t)};Y(kr,e=>{W(je)&&e(Ar)});var Mr=H(kr,2);AS(Mr,{get active(){return qe.active},get isDirty(){return qe.isDirty},onClick:()=>Te(`profiles`)}),Tw(H(Mr,2),{get controller(){return Ne}}),N(Er),N(br);var Nr=H(br,2),Fr=V(Nr);cN(Fr,{get units(){return ze},get waypoints(){return Ve},get symbols(){return M},onDropWaypoint:e=>void We(e),aisTrailsAvailable:()=>W(m)?.plugins.has(`tracks`)??!1,isOnline:()=>l.online,historyProviders:()=>W(h),get store(){return r},get vessel(){return a},get aisTargets(){return o},get anchor(){return E},get mob(){return O},get measure(){return A},get collision(){return d},get guidance(){return ne},get recorder(){return te},get routeStore(){return j},get tides(){return ce},get theme(){return Ne.theme},get trackSettings(){return ee},get savedTracks(){return ve},get userCharts(){return lt},get chartsToken(){return W(De)},get initialView(){return Fe},get savedLayers(){return Ie.value},onLayersChange:e=>Ie.set(e),get savedOrder(){return Le.value},onOrderChange:e=>Le.set(e),onReady:e=>B(ye,e,!0),onMapReady:e=>{Ee=e,e(Ne.theme)},onCommandsReady:e=>B(gt,e,!0),onUserChartsReady:e=>B(ut,e,!0),onViewChange:mt,onNoteSelect:Xn,onUserPan:()=>B(_t,!1),onGoToHere:Gn,onStartRoute:En,onMeasureFrom:e=>{yt(),A.add(e)},onRouteEditorError:()=>Jt(`Could not load the route editor. Check the connection and try again.`),onRouteEdited:Nn,onAnchorMoved:e=>void Lt(e)});var Ir=H(Fr,2);hv(V(Ir),{get auth(){return c},get requestsUrl(){return ir}}),N(Ir);var Lr=H(Ir,2),Rr=e=>{var t=VN(),n=V(t);N(t),U(()=>J(n,`Arrived at ${W(Kn)??``}`)),q(e,t)};Y(Lr,e=>{W(Kn)&&e(Rr)});var zr=H(Lr,2);let Br;var Vr=V(zr);{let e=R(()=>j.activeId===void 0?void 0:Rn);Wb(Vr,{get guidance(){return ne},get routeProgress(){return W(se)},onStop:Ln,get onSkip(){return W(e)}})}var Hr=H(Vr,2);eb(Hr,{get measure(){return A},get units(){return ze}});var Ur=H(Hr,2);z_(Ur,{get anchor(){return E},get units(){return ze},onRaise:()=>void Ft()});var Wr=H(Ur,2);Wy(Wr,{get collision(){return d},get muted(){return p.active},onToggleMute:b}),Eb(H(Wr,2),{get mob(){return O},get units(){return ze},onSteer:At,onCancel:kt}),N(zr);var Gr=H(zr,2),Kr=e=>{var t=HN();Ix(V(t),{get selection(){return W(Oe)},get load(){return W(ke).load},onClose:Yn}),N(t),q(e,t)};Y(Gr,e=>{W(Oe)&&W(ke)&&e(Kr)});var qr=H(Gr,2),Jr=e=>{var t=UN();uy(V(t),{get view(){return W(ye)},get userCharts(){return lt},get categoriesOpen(){return Re},onClose:Se,onBack:Ce}),N(t),q(e,t)};Y(qr,e=>{W(be)===`layers`&&W(ye)&&e(Jr)});var Yr=H(qr,2),Xr=e=>{var t=WN(),n=V(t);{let e=R(()=>W(un)!==void 0);mw(n,{get routes(){return j.routes},get shownIds(){return j.shownIds},get working(){return j.working},get activeId(){return j.activeId},get highlight(){return j.highlight},onHighlightLeg:xn,get error(){return W(qt)},onNew:Tn,onEditRoute:Dn,onSave:On,onCancelEdit:An,onToggleShown:nn,onLocate:tn,onActivate:In,onStop:Ln,onReverse:Hn,onExportGpx:Un,onImportGpx:Wn,get planningSpeed(){return ae},onDelete:Fn,get draftAvailable(){return W(rn)},get draftLoading(){return W(an)},get draftError(){return W(on)},onDraft:Sn,get draft(){return W(sn)},onOptimize:wn,onCancelDraft:kn,get optimizeDraft(){return W(e)},get optimizeUnchanged(){return W(dn)},onClose:jn,onBack:Mn})}N(t),q(e,t)};Y(Yr,e=>{W(be)===`routes`&&e(Xr)});var Zr=H(Yr,2),Qr=e=>{var t=WN();TE(V(t),{get recorder(){return te},get settings(){return ee},get saved(){return W(he)},get shown(){return W(ge)},onSave:Ht,onSaveAsRoute:Bn,onTrackHome:Vn,onDelete:Ut,onToggleSaved:Wt,onExport:Gt,get error(){return W(Vt)},onClose:Se,onBack:Ce}),N(t),q(e,t)};Y(Zr,e=>{W(be)===`tracks`&&e(Qr)});var $r=H(Zr,2),ei=e=>{var t=WN();sD(V(t),{get waypoints(){return Ve.waypoints},get error(){return W(He)},onLocate:e=>en(e.position),onGoTo:e=>void Gn(e.position),onRename:(e,t)=>void Ge(e,t),onDelete:e=>void Ke(e),onClose:Se,onBack:Ce}),N(t),q(e,t)};Y($r,e=>{W(be)===`waypoints`&&e(ei)});var ti=H($r,2),ni=e=>{var t=WN(),n=V(t);{let e=R(()=>Ie.value.tides?.visible??!1);sT(n,{get store(){return ce},get units(){return ze},get stationsShown(){return W(e)},onToggleStations:e=>vt(`tides`,e),onClose:Se,onBack:Ce})}N(t),q(e,t)};Y(ti,e=>{W(be)===`tides`&&e(ni)});var ri=H(ti,2),ii=e=>{var t=WN();eD(V(t),{get origin(){return n},get token(){return W(De)},get providers(){return W(h)},get recorder(){return Be},get mode(){return ze.mode},get theme(){return Ne.theme},onClose:Se,onBack:Ce}),N(t),q(e,t)};Y(ri,e=>{W(be)===`trends`&&e(ii)});var K=H(ri,2),ai=e=>{var t=WN();E_(V(t),{get units(){return ze},get aisTargets(){return o},get vessel(){return a},get collision(){return d},onLocate:en,onClose:Se,onBack:Ce}),N(t),q(e,t)};Y(K,e=>{W(be)===`ais`&&e(ai)});var oi=H(K,2),si=e=>{var t=WN();F_(V(t),{get units(){return ze},get anchor(){return E},get vessel(){return a},get error(){return W(jt)},onDrop:()=>void Nt(),onRaise:()=>void Ft(),onSetRadius:e=>void It(e),onClose:Se,onBack:Ce}),N(t),q(e,t)};Y(oi,e=>{W(be)===`anchor`&&e(si)});var ci=H(oi,2),li=e=>{var t=WN(),n=V(t);{let e=R(()=>p.active?W(Ct):void 0),t=R(()=>W(g)?w:void 0),r=R(()=>W(g)?T:void 0);wy(n,{get thresholds(){return u},get collisionMuted(){return p.active},get collisionMuteRemainingMin(){return W(e)},onToggleCollisionMute:b,get arrivalMuted(){return ie.value},onToggleArrivalMute:()=>ie.set(!ie.value),get notifications(){return x},get error(){return W(S)},get onSilence(){return W(t)},get onAcknowledge(){return W(r)},onClose:Se,onBack:Ce})}N(t),q(e,t)};Y(ci,e=>{W(be)===`alarms`&&e(li)});var ui=H(ci,2),di=e=>{var t=WN();YS(V(t),{get profiles(){return qe.profiles},get activeId(){return qe.activeId},get defaultId(){return qe.defaultId},get isDirty(){return qe.isDirty},onApply:tt,onSaveNew:rt,onUpdate:e=>{qe.update(e,F()),qe.clearDirty()},onRename:(e,t)=>qe.rename(e,t),onRemove:e=>qe.remove(e),onSetDefault:e=>qe.setDefault(e),onExport:it,onImport:at,onClose:Se,onBack:Ce}),N(t),q(e,t)};Y(ui,e=>{W(be)===`profiles`&&e(di)});var fi=H(ui,2),pi=e=>{{let t=R(()=>W(Ae)??Fe);RN(e,{get store(){return ue},get units(){return ze},get loader(){return de},get theme(){return Ne.theme},get initialView(){return W(t)},get savedLayers(){return me.value},onLayersChange:e=>me.set(e),onLayersReady:e=>B(Ye,e,!0),get token(){return W(De)},get providerName(){return W(pe)},get position(){return a.position},get online(){return l.online},onClose:()=>B(fe,!1),onBack:()=>{B(fe,!1),B(xe,!0)}})}};Y(fi,e=>{W(fe)&&e(pi)}),N(Nr);var mi=H(Nr,2),hi=V(mi),gi=V(hi);let _i;var vi=H(V(gi),2),yi=V(vi,!0);N(vi),N(gi);var bi=H(gi,2),xi=e=>{q(e,GN())};Y(bi,e=>{W(or)&&e(xi)});var Si=H(bi,2),Ci=e=>{q(e,KN())};Y(Si,e=>{l.online||e(Ci)});var wi=H(Si,2),Ti=e=>{q(e,qN())};Y(wi,e=>{W(tr)&&e(Ti)});var Ei=H(wi,2),Di=e=>{var t=JN(),n=H(V(t)),r=V(n,!0);N(n),N(t),U(()=>J(r,W(rr))),q(e,t)};Y(Ei,e=>{r.connection.phase===`open`&&e(Di)});var Oi=H(Ei,2),ki=e=>{var t=ZN();let n;var r=V(t),i=e=>{var t=YN();P(),q(e,t)},a=e=>{var t=XN(),n=H(Cn(t)),r=V(n,!0);N(n);var i=H(n,2),a=V(i,!0);N(i);var o=H(i);U((e,t,n)=>{J(r,e),J(a,t),J(o,` ${n??``}`)},[()=>nl(E.distanceMeters,ze.mode,0),()=>nl(E.radiusMeters,ze.mode,0),()=>tl(ze.mode)]),q(e,t)};Y(r,e=>{E.fixLost?e(i):e(a,-1)}),N(t),U(()=>{n=ta(t,1,`readout anchor-chip svelte-1hicyxm`,null,n,{"anchor-chip--alarm":E.dragging||E.fixLost}),Z(t,`title`,E.fixLost?`Anchor watch: no GPS fix, drag detection degraded`:`Anchor watch: distance from the anchor over the watch radius`)}),q(e,t)};Y(Oi,e=>{E.watching&&e(ki)});var Ai=H(Oi,2),ji=H(V(Ai)),Mi=V(ji,!0);N(ji),P(),N(Ai);var Ni=H(Ai,2),Pi=H(V(Ni)),Fi=V(Pi,!0);N(Pi),P(),N(Ni),N(hi);var Ii=H(hi,2),Li=V(Ii);Fo(V(Li),{size:16,"aria-hidden":`true`}),P(),N(Li);var Ri=H(Li,2);let zi;Uo(V(Ri),{size:16,"aria-hidden":`true`}),P(),N(Ri);var Bi=H(Ri,2);let Vi;ko(V(Bi),{size:16,"aria-hidden":`true`}),P(),N(Bi);var Hi=H(Bi,2);let Ui;po(V(Hi),{size:16,"aria-hidden":`true`}),P(),N(Hi),N(Ii);var Wi=H(Ii,2),Gi=H(V(Wi),2),Ki=V(Gi),qi=V(Ki,!0);N(Ki),N(Gi);var Ji=H(Gi,2),Yi=V(Ji),Xi=V(Yi,!0);N(Yi),N(Ji);var Zi=H(Ji,2),Qi=H(V(Zi)),$i=V(Qi,!0);N(Qi),N(Zi),N(Wi),N(mi),N(dr),U((e,t,n,r,i)=>{J(pr,W(xt)),J(hr,W(wt)),J(_r,W(Tt)),J(yr,W(St)),Br=ta(zr,1,`bottom-stack svelte-1hicyxm`,null,Br,{"above-weather":W(fe)}),_i=ta(gi,1,`conn svelte-1hicyxm`,null,_i,{"conn--down":W(er)}),Z(gi,`title`,W($n)),J(yi,W($n)),J(Mi,e),J(Fi,t),zi=ta(Ri,1,`btn btn-pill`,null,zi,{"is-on":W(_t)}),Z(Ri,`aria-pressed`,W(_t)),Z(Ri,`title`,W(_t)?`Stop following`:`Follow boat`),Vi=ta(Bi,1,`btn btn-pill`,null,Vi,{"is-on":W(be)===`layers`}),Z(Bi,`aria-expanded`,W(ye)?W(be)===`layers`:void 0),Z(Bi,`aria-controls`,W(be)===`layers`?`layers-panel`:void 0),Z(Bi,`title`,W(ye)?`Layers and charts`:`Layers and charts (chart is loading)`),Bi.disabled=!W(ye),Ui=ta(Hi,1,`btn btn-pill`,null,Ui,{"is-on":W(fe)}),Z(Hi,`aria-expanded`,W(fe)),Z(Hi,`aria-controls`,W(fe)?`weather-panel`:void 0),J(qi,n),J(Xi,r),J($i,i)},[()=>zc(W(tr)?void 0:a.sogMps),()=>Bc(W(tr)?void 0:a.cogRad),()=>uc(W(Ae)?.lat),()=>dc(W(Ae)?.lon),()=>Rc(W(Ae)?.zoom,1)]),G(`click`,Li,()=>W(gt)?.centerOnVessel()),G(`click`,Ri,()=>B(_t,!W(_t))),G(`click`,Bi,()=>W(be)===`layers`?Se():Te(`layers`)),G(`click`,Hi,()=>B(fe,!W(fe))),q(e,dr),et()}Qr([`click`]);var eP=document.getElementById(`app`);if(!eP)throw Error(`Missing #app mount element`);di($N,{target:eP});export{N as A,V as C,R as D,z as E,et as O,zn as S,B as T,J as _,Mc as a,W as b,ll as c,tc as d,rc as f,Y as g,Ei as h,tl as i,$e as k,ec as l,Z as m,hf as n,Qc as o,Oa as p,Rc as r,cl as s,HE as t,nc as u,q as v,H as w,U as x,K as y};