winga-chart-plotter-signalk 0.8.0 → 0.9.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.
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{t as n}from"./maplibre-gl-TciDBW6i.js";(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)}})(),typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`);var r={},i=Symbol(`uninitialized`),a=`http://www.w3.org/1999/xhtml`,o=`http://www.w3.org/2000/svg`,s=`http://www.w3.org/1998/Math/MathML`,c=Array.isArray,l=Array.prototype.indexOf,u=Array.prototype.includes,d=Array.from,f=Object.defineProperty,p=Object.getOwnPropertyDescriptor,m=Object.getOwnPropertyDescriptors,h=Object.prototype,g=Array.prototype,_=Object.getPrototypeOf,v=Object.isExtensible,y=()=>{};function b(e){for(var t=0;t<e.length;t++)e[t]()}function x(){var e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function S(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 C=1024,w=2048,T=4096,E=8192,ee=16384,te=32768,ne=1<<25,D=65536,O=1<<19,k=1<<20,re=1<<25,ie=65536,ae=1<<21,oe=1<<22,se=1<<23,ce=Symbol(`$state`),le=Symbol(``),ue=Symbol(`attributes`),de=Symbol(`class`),fe=Symbol(`style`),pe=Symbol(`text`),me=Symbol(`form reset`),he=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"},ge=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`);function _e(e){throw Error(`https://svelte.dev/e/lifecycle_outside_component`)}function ve(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function ye(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function be(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function xe(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function Se(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function Ce(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function we(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function Te(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function Ee(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function De(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}function Oe(){console.warn(`https://svelte.dev/e/derived_inert`)}function ke(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function Ae(){console.warn(`https://svelte.dev/e/select_multiple_invalid_value`)}function je(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var A=!1;function Me(e){A=e}var j;function Ne(e){if(e===null)throw ke(),r;return j=e}function Pe(){return Ne(vn(j))}function M(e){if(A){if(vn(j)!==null)throw ke(),r;j=e}}function Fe(e=1){if(A){for(var t=e,n=j;t--;)n=vn(n);j=n}}function Ie(e=!0){for(var t=0,n=j;;){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=vn(n);e&&n.remove(),n=i}}function Le(e){if(!e||e.nodeType!==8)throw ke(),r;return e.data}function Re(e){return e===this.v}function ze(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function Be(e){return!ze(e,this.v)}var Ve=!1,He=!1,N=null;function Ue(e){N=e}function We(e,t=!1,n){N={p:N,i:!1,c:null,e:null,s:e,x:null,r:B,l:He&&!t?{s:null,u:null,$:[]}:null}}function Ge(e){var t=N,n=t.e;if(n!==null){t.e=null;for(var r of n)Pn(r)}return e!==void 0&&(t.x=e),t.i=!0,N=t.p,e??{}}function Ke(){return!He||N!==null&&N.l===null}var qe=[];function Je(){var e=qe;qe=[],b(e)}function Ye(e){if(qe.length===0&&!_t){var t=qe;queueMicrotask(()=>{t===qe&&Je()})}qe.push(e)}function Xe(){for(;qe.length>0;)Je()}function Ze(e){var t=B;if(t===null)return z.f|=se,e;if(!(t.f&32768)&&!(t.f&4))throw e;Qe(e,t)}function Qe(e,t){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 $e=~(w|T|C);function et(e,t){e.f=e.f&$e|t}function tt(e){e.f&512||e.deps===null?et(e,C):et(e,T)}function nt(e){if(e!==null)for(let t of e)!(t.f&2)||!(t.f&65536)||(t.f^=ie,nt(t.deps))}function rt(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),nt(e.deps),et(e,C)}function it(e,t,n){if(e==null)return t(void 0),n&&n(void 0),y;let r=Er(()=>e.subscribe(t,n));return r.unsubscribe?()=>r.unsubscribe():r}var at=[];function ot(e,t=y){let n=null,r=new Set;function i(t){if(ze(e,t)&&(e=t,n)){let t=!at.length;for(let t of r)t[1](),at.push(t,e);if(t){for(let e=0;e<at.length;e+=2)at[e][0](at[e+1]);at.length=0}}}function a(t){i(t(e))}function o(o,s=y){let c=[o,s];return r.add(c),r.size===1&&(n=t(i,a)||y),o(e),()=>{r.delete(c),r.size===0&&n&&(n(),n=null)}}return{set:i,update:a,subscribe:o}}function st(e){let t;return it(e,e=>t=e)(),t}var ct=!1,lt=Symbol(`unmounted`);function ut(e,t,n){let r=n[t]??={store:null,source:tn(void 0),unsubscribe:y};if(r.store!==e&&!(lt in n))if(r.unsubscribe(),r.store=e??null,e==null)r.source.v=void 0,r.unsubscribe=y;else{var i=!0;r.unsubscribe=it(e,e=>{i?r.source.v=e:I(r.source,e)}),i=!1}return e&< in n?st(e):V(r.source)}function dt(){let e={};function t(){Mn(()=>{for(var t in e)e[t].unsubscribe();f(e,lt,{enumerable:!1,value:!0})})}return[e,t]}var ft=null,pt=null,P=null,mt=null,ht=null,gt=null,_t=!1,vt=!1,yt=null,bt=null,xt=0,St=1,Ct=class e{id=St++;#e=!1;linked=!0;#t=null;#n=null;async_deriveds=new Map;current=new Map;previous=new Map;unblocked=new Set;#r=new Set;#i=new Set;#a=new Set;#o=0;#s=new Map;#c=null;#l=[];#u=[];#d=new Set;#f=new Set;#p=new Map;#m=new Set;is_fork=!1;#h=!1;#g(){if(this.is_fork)return!0;for(let n of this.#s.keys()){for(var e=n,t=!1;e.parent!==null;){if(this.#p.has(e)){t=!0;break}e=e.parent}if(!t)return!0}return!1}skip_effect(e){this.#p.has(e)||this.#p.set(e,{d:[],m:[]}),this.#m.delete(e)}unskip_effect(e,t=e=>this.schedule(e)){var n=this.#p.get(e);if(n){this.#p.delete(e);for(var r of n.d)et(r,w),t(r);for(r of n.m)et(r,T),t(r)}this.#m.add(e)}#_(){if(this.#e=!0,xt++>1e3&&(this.#w(),Tt()),!this.#g()){for(let e of this.#d)this.#f.delete(e),et(e,w),this.schedule(e);for(let e of this.#f)et(e,T),this.schedule(e)}let t=this.#l;this.#l=[],this.apply();var n=yt=[],r=[],i=bt=[];for(let e of t)try{this.#v(e,n,r)}catch(t){throw Mt(e),t}if(P=null,i.length>0){var a=e.ensure();for(let e of i)a.schedule(e)}if(yt=null,bt=null,this.#g()){this.#x(r),this.#x(n);for(let[e,t]of this.#p)jt(e,t);i.length>0&&P.#_();return}let o=this.#y();if(o){o.#b(this);return}this.#d.clear(),this.#f.clear();for(let e of this.#r)e(this);this.#r.clear(),mt=this,Dt(r),Dt(n),mt=null,this.#c?.resolve();var s=P;if(this.linked&&this.#o===0&&this.#w(),Ve&&!this.linked&&(this.#S(),P=s),this.#l.length>0){s===null&&(s=this,this.#C());let e=s;e.#l.push(...this.#l.filter(t=>!e.#l.includes(t)))}s!==null&&s.#_()}#v(e,t,n){e.f^=C;for(var r=e.first;r!==null;){var i=r.f,a=(i&96)!=0;if(!(a&&i&1024||i&8192||this.#p.has(r))&&r.fn!==null){a?r.f^=C:i&4?t.push(r):Ve&&i&16777224?n.push(r):_r(r)&&(i&16&&this.#f.add(r),Sr(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}}}#y(){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}#b(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)}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.#f.delete(i),et(i,w),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#w(),P=this,this.#_()}#x(e){for(var t=0;t<e.length;t+=1)rt(e[t],this.#d,this.#f)}capture(e,t,n=!1){e.v!==i&&!this.previous.has(e)&&this.previous.set(e,e.v),e.f&8388608||(this.current.set(e,[t,n]),ht?.set(e,t)),this.is_fork||(e.v=t)}activate(){P=this}deactivate(){P=null,ht=null}flush(){try{vt=!0,P=this,this.#_()}finally{xt=0,gt=null,yt=null,bt=null,vt=!1,P=null,ht=null,Qt.clear()}}discard(){for(let e of this.#i)e(this);this.#i.clear(),this.#a.clear(),this.#w()}register_created_effect(e){this.#u.push(e)}#S(){this.#w();for(let l=ft;l!==null;l=l.#n){var e=l.id<this.id,t=[];for(let[r,[i,a]]of this.current){if(l.current.has(r)){var n=l.current.get(r)[0];if(e&&i!==n)l.current.set(r,[i,a]);else continue}t.push(r)}if(e)for(let[e,t]of this.async_deriveds){let n=l.async_deriveds.get(e);n&&t.promise.then(n.resolve)}if(l.#e){var r=[...l.current.keys()].filter(e=>!this.current.has(e));if(r.length===0)e&&l.discard();else if(t.length>0){if(e)for(let e of this.#m)l.unskip_effect(e,e=>{e.f&4194320?l.schedule(e):l.#x([e])});l.activate();var i=new Set,a=new Map;for(var o of t)Ot(o,r,i,a);a=new Map;var s=[...l.current.keys()].filter(e=>this.current.has(e)?this.current.get(e)[0]!==e.v:!0);if(s.length>0)for(let e of this.#u)!(e.f&155648)&&kt(e,s,a)&&(e.f&4194320?(et(e,w),l.schedule(e)):l.#d.add(e));if(l.#l.length>0&&!l.#h){l.apply();for(var c of l.#l)l.#v(c,[],[]);l.#l=[]}l.deactivate()}}}}increment(e,t){if(this.#o+=1,e){let e=this.#s.get(t)??0;this.#s.set(t,e+1)}}decrement(e,t){if(--this.#o,e){let e=this.#s.get(t)??0;e===1?this.#s.delete(t):this.#s.set(t,e-1)}this.#h||(this.#h=!0,Ye(()=>{this.#h=!1,this.linked&&this.flush()}))}transfer_effects(e,t){for(let t of e)this.#d.add(t);for(let e of t)this.#f.add(e);e.clear(),t.clear()}oncommit(e){this.#r.add(e)}ondiscard(e){this.#i.add(e)}on_fork_commit(e){this.#a.add(e)}run_fork_commit_callbacks(){for(let e of this.#a)e(this);this.#a.clear()}settled(){return(this.#c??=x()).promise}static ensure(){if(P===null){let t=P=new e;t.#C(),!vt&&!_t&&Ye(()=>{t.#e||t.flush()})}return P}apply(){if(!Ve||!this.is_fork&&this.#t===null&&this.#n===null){ht=null;return}ht=new Map;for(let[e,[t]]of this.current)ht.set(e,t);for(let t=ft;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)ht.has(e)||ht.set(e,n)}}schedule(e){if(gt=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(yt!==null&&t===B&&(Ve||(z===null||!(z.f&2))&&!ct))return;if(n&96){if(!(n&1024))return;t.f^=C}}this.#l.push(t)}#C(){pt===null?ft=pt=this:(pt.#n=this,this.#t=pt),pt=this}#w(){var e=this.#t,t=this.#n;e===null?ft=t:e.#n=t,t===null?pt=e:t.#t=e,this.linked=!1}};function wt(e){var t=_t;_t=!0;try{var n;for(e&&(P!==null&&!P.is_fork&&P.flush(),n=e());;){if(Xe(),P===null)return n;P.flush()}}finally{_t=t}}function Tt(){try{Ce()}catch(e){Qe(e,gt)}}var Et=null;function Dt(e){var t=e.length;if(t!==0){for(var n=0;n<t;){var r=e[n++];if(!(r.f&24576)&&_r(r)&&(Et=new Set,Sr(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&qn(r),Et?.size>0)){Qt.clear();for(let e of Et){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)Et.has(n)&&(Et.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||Sr(n)}}Et.clear()}}Et=null}}function Ot(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?Ot(i,t,n,r):e&4194320&&!(e&2048)&&kt(i,t,r)&&(et(i,w),At(i))}}function kt(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(u.call(t,r))return!0;if(r.f&2&&kt(r,t,n))return n.set(r,!0),!0}return n.set(e,!1),!1}function At(e){P.schedule(e)}function jt(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),et(e,C);for(var n=e.first;n!==null;)jt(n,t),n=n.next}}function Mt(e){et(e,C);for(var t=e.first;t!==null;)Mt(t),t=t.next}function Nt(e){let t=0,n=en(0),r;return()=>{jn()&&(V(n),Rn(()=>(t===0&&(r=Er(()=>e(()=>on(n)))),t+=1,()=>{Ye(()=>{--t,t===0&&(r?.(),r=void 0,on(n))})})))}}var Pt=D|O;function Ft(e,t,n,r){new It(e,t,n,r)}var It=class{parent;is_pending=!1;transform_error;#e;#t=A?j: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=Nt(()=>(this.#m=en(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=B;t.b=this,t.f|=128,n(e)},this.parent=B.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=Bn(()=>{if(A){let e=this.#t;Pe();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()},Pt),A&&(this.#e=j)}#g(){try{this.#a=Vn(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed;t&&(this.#s=Vn(()=>{t(this.#e,()=>e,()=>()=>{})}))}#v(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=Vn(()=>e(this.#e)),Ye(()=>{var e=this.#c=document.createDocumentFragment(),t=gn();e.append(t),this.#a=this.#x(()=>Vn(()=>this.#r(t))),this.#u===0&&(this.#e.before(e),this.#c=null,Jn(this.#o,()=>{this.#o=null}),this.#b(P))}))}#y(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=Vn(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();Qn(this.#a,e);let t=this.#n.pending;this.#o=Vn(()=>t(this.#e))}else this.#b(P)}catch(e){this.error(e)}}#b(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){rt(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=B,n=z,r=N;ar(this.#i),ir(this.#i),Ue(this.#i.ctx);try{return Ct.ensure(),e()}catch(e){return Ze(e),null}finally{ar(t),ir(n),Ue(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&&Jn(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,Ye(()=>{this.#d=!1,this.#m&&nn(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),V(this.#m)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;P?.is_fork?(this.#a&&P.skip_effect(this.#a),this.#o&&P.skip_effect(this.#o),this.#s&&P.skip_effect(this.#s),P.on_fork_commit(()=>{this.#C(e)})):this.#C(e)}#C(e){this.#a&&=(Gn(this.#a),null),this.#o&&=(Gn(this.#o),null),this.#s&&=(Gn(this.#s),null),A&&(Ne(this.#t),Fe(),Ne(Ie()));var t=this.#n.onerror;let n=this.#n.failed;var r=!1,i=!1;let a=()=>{if(r){je();return}r=!0,i&&De(),this.#s!==null&&Jn(this.#s,()=>{this.#s=null}),this.#x(()=>{this.#y()})},o=e=>{try{i=!0,t?.(e,a),i=!1}catch(e){Qe(e,this.#i&&this.#i.parent)}n&&(this.#s=this.#x(()=>{try{return Vn(()=>{var t=B;t.b=this,t.f|=128,n(this.#e,()=>e,()=>a)})}catch(e){return Qe(e,this.#i.parent),null}}))};Ye(()=>{var t;try{t=this.transform_error(e)}catch(e){Qe(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(o,e=>Qe(e,this.#i&&this.#i.parent)):o(t)})}};function Lt(e,t,n,r){let i=Ke()?Vt:Gt;var a=e.filter(e=>!e.settled);if(n.length===0&&a.length===0){r(t.map(i));return}var o=B,s=Rt(),c=a.length===1?a[0].promise:a.length>1?Promise.all(a.map(e=>e.promise)):null;function l(e){if(!(o.f&16384)){s();try{r(e)}catch(e){Qe(e,o)}zt()}}var u=Bt();if(n.length===0){c.then(()=>l(t.map(i))).finally(u);return}function d(){Promise.all(n.map(e=>Ut(e))).then(e=>l([...t.map(i),...e])).catch(e=>Qe(e,o)).finally(u)}c?c.then(()=>{s(),d(),zt()}):d()}function Rt(){var e=B,t=z,n=N,r=P;return function(i=!0){ar(e),ir(t),Ue(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function zt(e=!0){ar(null),ir(null),Ue(null),e&&P?.deactivate()}function Bt(){var e=B,t=e.b,n=P,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 Vt(e){var t=2|w;return B!==null&&(B.f|=O),{ctx:N,deps:null,effects:null,equals:Re,f:t,fn:e,reactions:null,rv:0,v:i,wv:0,parent:B,ac:null}}var Ht=Symbol(`obsolete`);function Ut(e,t,n){let r=B;r===null&&ve();var a=void 0,o=en(i),s=!z,c=new Set;return Ln(()=>{var t=B,n=x();a=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==he&&n.reject(e)}).finally(zt)}catch(e){n.reject(e),zt()}var i=P;if(s){if(t.f&32768)var l=Bt();if(r.b.is_rendered())i.async_deriveds.get(t)?.reject(Ht);else for(let e of c.values())e.reject(Ht);c.add(n),i.async_deriveds.set(t,n)}let u=(e,t=void 0)=>{l?.(),c.delete(n),t!==Ht&&(i.activate(),t?(o.f|=se,nn(o,t)):(o.f&8388608&&(o.f^=se),nn(o,e)),i.deactivate())};n.promise.then(u,e=>u(null,e||`unknown`))}),Mn(()=>{for(let e of c)e.reject(Ht)}),new Promise(e=>{function t(n){function r(){n===a?e(o):t(a)}n.then(r,r)}t(a)})}function Wt(e){let t=Vt(e);return Ve||sr(t),t}function Gt(e){let t=Vt(e);return t.equals=Be,t}function Kt(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n<t.length;n+=1)Gn(t[n])}}function qt(e){var t,n=B,r=e.parent;if(!tr&&r!==null&&e.v!==i&&r.f&24576)return Oe(),e.v;ar(r);try{e.f&=~ie,Kt(e),t=yr(e)}finally{ar(n)}return t}function Jt(e){var t=qt(e);if(!e.equals(t)&&(e.wv=gr(),(!P?.is_fork||e.deps===null)&&(P===null?e.v=t:(P.capture(e,t,!0),mt?.capture(e,t,!0)),e.deps===null))){et(e,C);return}tr||(ht===null?tt(e):(jn()||P?.is_fork)&&ht.set(e,t))}function Yt(e){if(e.effects!==null)for(let t of e.effects)(t.teardown||t.ac)&&(t.teardown?.(),t.ac?.abort(he),t.fn!==null&&(t.teardown=y),t.ac=null,xr(t,0),Un(t))}function Xt(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&t.fn!==null&&Sr(t)}var Zt=new Set,Qt=new Map,$t=!1;function en(e,t){return{f:0,v:e,reactions:null,equals:Re,rv:0,wv:0}}function F(e,t){let n=en(e,t);return sr(n),n}function tn(e,t=!1,n=!0){let r=en(e);return t||(r.equals=Be),He&&n&&N!==null&&N.l!==null&&(N.l.s??=[]).push(r),r}function I(e,t,n=!1){return z!==null&&(!rr||z.f&131072)&&Ke()&&z.f&4325394&&(or===null||!u.call(or,e))&&Ee(),nn(e,n?cn(t):t,bt)}function nn(e,t,n=null){if(!e.equals(t)){Qt.set(e,tr?t:e.v);var r=Ct.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&&qt(t),ht===null&&tt(t)}e.wv=gr(),sn(e,w,n),Ke()&&B!==null&&B.f&1024&&!(B.f&96)&&(ur===null?dr([e]):ur.push(e)),!r.is_fork&&Zt.size>0&&!$t&&rn()}return t}function rn(){$t=!1;for(let e of Zt){e.f&1024&&et(e,T);let t;try{t=_r(e)}catch{t=!0}t&&Sr(e)}Zt.clear()}function an(e,t=1){var n=V(e),r=t===1?n++:n--;return I(e,n),r}function on(e){I(e,e.v+1)}function sn(e,t,n){var r=e.reactions;if(r!==null)for(var i=Ke(),a=r.length,o=0;o<a;o++){var s=r[o],c=s.f;if(!(!i&&s===B)){var l=(c&w)===0;if(l&&et(s,t),c&131072)Zt.add(s);else if(c&2){var u=s;ht?.delete(u),c&65536||(c&512&&(B===null||!(B.f&2097152))&&(s.f|=ie),sn(u,T,n))}else if(l){var d=s;c&16&&Et!==null&&Et.add(d),n===null?At(d):n.push(d)}}}}function cn(e){if(typeof e!=`object`||!e||ce in e)return e;let t=_(e);if(t!==h&&t!==g)return e;var n=new Map,r=c(e),a=F(0),o=null,s=mr,l=e=>{if(mr===s)return e();var t=z,n=mr;ir(null),hr(s);var r=e();return ir(t),hr(n),r};return r&&n.set(`length`,F(e.length,o)),new Proxy(e,{defineProperty(e,t,r){(!(`value`in r)||r.configurable===!1||r.enumerable===!1||r.writable===!1)&&we();var i=n.get(t);return i===void 0?l(()=>{var e=F(r.value,o);return n.set(t,e),e}):I(i,r.value,!0),!0},deleteProperty(e,t){var r=n.get(t);if(r===void 0){if(t in e){let e=l(()=>F(i,o));n.set(t,e),on(a)}}else I(r,i),on(a);return!0},get(t,r,a){if(r===ce)return e;var s=n.get(r),c=r in t;if(s===void 0&&(!c||p(t,r)?.writable)&&(s=l(()=>F(cn(c?t[r]:i),o)),n.set(r,s)),s!==void 0){var u=V(s);return u===i?void 0:u}return Reflect.get(t,r,a)},getOwnPropertyDescriptor(e,t){var r=Reflect.getOwnPropertyDescriptor(e,t);if(r&&`value`in r){var a=n.get(t);a&&(r.value=V(a))}else if(r===void 0){var o=n.get(t),s=o?.v;if(o!==void 0&&s!==i)return{enumerable:!0,configurable:!0,value:s,writable:!0}}return r},has(e,t){if(t===ce)return!0;var r=n.get(t),a=r!==void 0&&r.v!==i||Reflect.has(e,t);return(r!==void 0||B!==null&&(!a||p(e,t)?.writable))&&(r===void 0&&(r=l(()=>F(a?cn(e[t]):i,o)),n.set(t,r)),V(r)===i)?!1:a},set(e,t,s,c){var u=n.get(t),d=t in e;if(r&&t===`length`)for(var f=s;f<u.v;f+=1){var m=n.get(f+``);m===void 0?f in e&&(m=l(()=>F(i,o)),n.set(f+``,m)):I(m,i)}if(u===void 0)(!d||p(e,t)?.writable)&&(u=l(()=>F(void 0,o)),I(u,cn(s)),n.set(t,u));else{d=u.v!==i;var h=l(()=>cn(s));I(u,h)}var g=Reflect.getOwnPropertyDescriptor(e,t);if(g?.set&&g.set.call(c,s),!d){if(r&&typeof t==`string`){var _=n.get(`length`),v=Number(t);Number.isInteger(v)&&v>=_.v&&I(_,v+1)}on(a)}return!0},ownKeys(e){V(a);var t=Reflect.ownKeys(e).filter(e=>{var t=n.get(e);return t===void 0||t.v!==i});for(var[r,o]of n)o.v!==i&&!(r in e)&&t.push(r);return t},setPrototypeOf(){Te()}})}function ln(e){try{if(typeof e==`object`&&e&&ce in e)return e[ce]}catch{}return e}function un(e,t){return Object.is(ln(e),ln(t))}new Set([`copyWithin`,`fill`,`pop`,`push`,`reverse`,`shift`,`sort`,`splice`,`unshift`]);var dn,fn,pn,mn;function hn(){if(dn===void 0){dn=window,fn=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;pn=p(t,`firstChild`).get,mn=p(t,`nextSibling`).get,v(e)&&(e[de]=void 0,e[ue]=null,e[fe]=void 0,e.__e=void 0),v(n)&&(n[pe]=void 0)}}function gn(e=``){return document.createTextNode(e)}function _n(e){return pn.call(e)}function vn(e){return mn.call(e)}function L(e,t){if(!A)return _n(e);var n=_n(j);if(n===null)n=j.appendChild(gn());else if(t&&n.nodeType!==3){var r=gn();return n?.before(r),Ne(r),r}return t&&Cn(n),Ne(n),n}function yn(e,t=!1){if(!A){var n=_n(e);return n instanceof Comment&&n.data===``?vn(n):n}if(t){if(j?.nodeType!==3){var r=gn();return j?.before(r),Ne(r),r}Cn(j)}return j}function R(e,t=1,n=!1){let r=A?j:e;for(var i;t--;)i=r,r=vn(r);if(!A)return r;if(n){if(r?.nodeType!==3){var a=gn();return r===null?i?.after(a):r.before(a),Ne(a),a}Cn(r)}return Ne(r),r}function bn(e){e.textContent=``}function xn(){return!Ve||Et!==null?!1:(B.f&te)!==0}function Sn(e,t,n){let r=n?{is:n}:void 0;return document.createElementNS(t??`http://www.w3.org/1999/xhtml`,e,r)}function Cn(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}var wn=!1;function Tn(){wn||(wn=!0,document.addEventListener(`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let t of e.target.elements)t[me]?.()})},{capture:!0}))}function En(e){var t=z,n=B;ir(null),ar(null);try{return e()}finally{ir(t),ar(n)}}function Dn(e,t,n,r=n){e.addEventListener(t,()=>En(n));let i=e[me];i?e[me]=()=>{i(),r(!0)}:e[me]=()=>r(!0),Tn()}function On(e){B===null&&(z===null&&Se(e),xe()),tr&&be(e)}function kn(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function An(e,t){var n=B;n!==null&&n.f&8192&&(e|=E);var r={ctx:N,deps:null,nodes:null,f:e|w|512,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};P?.register_created_effect(r);var i=r;if(e&4)yt===null?Ct.ensure().schedule(r):yt.push(r);else if(t!==null){try{Sr(r)}catch(e){throw Gn(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|=D))}if(i!==null&&(i.parent=n,n!==null&&kn(i,n),z!==null&&z.f&2&&!(e&64))){var a=z;(a.effects??=[]).push(i)}return r}function jn(){return z!==null&&!rr}function Mn(e){let t=An(8,null);return et(t,C),t.teardown=e,t}function Nn(e){On(`$effect`);var t=B.f;if(!z&&t&32&&!(t&32768)){var n=N;(n.e??=[]).push(e)}else return Pn(e)}function Pn(e){return An(4|k,e)}function Fn(e){Ct.ensure();let t=An(64|O,e);return(e={})=>new Promise(n=>{e.outro?Jn(t,()=>{Gn(t),n(void 0)}):(Gn(t),n(void 0))})}function In(e){return An(4,e)}function Ln(e){return An(oe|O,e)}function Rn(e,t=0){return An(8|t,e)}function zn(e,t=[],n=[],r=[]){Lt(r,t,n,t=>{An(8,()=>e(...t.map(V)))})}function Bn(e,t=0){return An(16|t,e)}function Vn(e){return An(32|O,e)}function Hn(e){var t=e.teardown;if(t!==null){let e=tr,n=z;nr(!0),ir(null);try{t.call(null)}finally{nr(e),ir(n)}}}function Un(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&En(()=>{e.abort(he)});var r=n.next;n.f&64?n.parent=null:Gn(n,t),n=r}}function Wn(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||Gn(t),t=n}}function Gn(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(Kn(e.nodes.start,e.nodes.end),n=!0),et(e,ne),Un(e,t&&!n),xr(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();Hn(e),e.f^=ne,e.f|=ee;var i=e.parent;i!==null&&i.first!==null&&qn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function Kn(e,t){for(;e!==null;){var n=e===t?null:vn(e);e.remove(),e=n}}function qn(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 Jn(e,t,n=!0){var r=[];Yn(e,r,!0);var i=()=>{n&&Gn(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function Yn(e,t,n){if(!(e.f&8192)){e.f^=E;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;Yn(i,t,o?n:!1)}i=a}}}function Xn(e){Zn(e,!0)}function Zn(e,t){if(e.f&8192){e.f^=E,e.f&1024||(et(e,w),Ct.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=(n.f&65536)!=0||(n.f&32)!=0;Zn(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 Qn(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:vn(n);t.append(n),n=i}}var $n=null,er=!1,tr=!1;function nr(e){tr=e}var z=null,rr=!1;function ir(e){z=e}var B=null;function ar(e){B=e}var or=null;function sr(e){z!==null&&(!Ve||z.f&2)&&(or===null?or=[e]:or.push(e))}var cr=null,lr=0,ur=null;function dr(e){ur=e}var fr=1,pr=0,mr=pr;function hr(e){mr=e}function gr(){return++fr}function _r(e){var t=e.f;if(t&2048)return!0;if(t&2&&(e.f&=~ie),t&4096){for(var n=e.deps,r=n.length,i=0;i<r;i++){var a=n[i];if(_r(a)&&Jt(a),a.wv>e.wv)return!0}t&512&&ht===null&&et(e,C)}return!1}function vr(e,t,n=!0){var r=e.reactions;if(r!==null&&!(!Ve&&or!==null&&u.call(or,e)))for(var i=0;i<r.length;i++){var a=r[i];a.f&2?vr(a,t,!1):t===a&&(n?et(a,w):a.f&1024&&et(a,T),At(a))}}function yr(e){var t=cr,n=lr,r=ur,i=z,a=or,o=N,s=rr,c=mr,l=e.f;cr=null,lr=0,ur=null,z=l&96?null:e,or=null,Ue(e.ctx),rr=!1,mr=++pr,e.ac!==null&&(En(()=>{e.ac.abort(he)}),e.ac=null);try{e.f|=ae;var u=e.fn,d=u();e.f|=te;var f=e.deps,p=P?.is_fork;if(cr!==null){var m;if(p||xr(e,lr),f!==null&&lr>0)for(f.length=lr+cr.length,m=0;m<cr.length;m++)f[lr+m]=cr[m];else e.deps=f=cr;if(jn()&&e.f&512)for(m=lr;m<f.length;m++)(f[m].reactions??=[]).push(e)}else !p&&f!==null&&lr<f.length&&(xr(e,lr),f.length=lr);if(Ke()&&ur!==null&&!rr&&f!==null&&!(e.f&6146))for(m=0;m<ur.length;m++)vr(ur[m],e);if(i!==null&&i!==e){if(pr++,i.deps!==null)for(let e=0;e<n;e+=1)i.deps[e].rv=pr;if(t!==null)for(let e of t)e.rv=pr;ur!==null&&(r===null?r=ur:r.push(...ur))}return e.f&8388608&&(e.f^=se),d}catch(e){return Ze(e)}finally{e.f^=ae,cr=t,lr=n,ur=r,z=i,or=a,Ue(o),rr=s,mr=c}}function br(e,t){let n=t.reactions;if(n!==null){var r=l.call(n,e);if(r!==-1){var a=n.length-1;a===0?n=t.reactions=null:(n[r]=n[a],n.pop())}}if(n===null&&t.f&2&&(cr===null||!u.call(cr,t))){var o=t;o.f&512&&(o.f^=512,o.f&=~ie),o.v!==i&&tt(o),Yt(o),xr(o,0)}}function xr(e,t){var n=e.deps;if(n!==null)for(var r=t;r<n.length;r++)br(e,n[r])}function Sr(e){var t=e.f;if(!(t&16384)){et(e,C);var n=B,r=er;B=e,er=!0;try{t&16777232?Wn(e):Un(e),Hn(e);var i=yr(e);e.teardown=typeof i==`function`?i:null,e.wv=fr}finally{er=r,B=n}}}async function Cr(){if(Ve)return new Promise(e=>{requestAnimationFrame(()=>e()),setTimeout(()=>e())});await Promise.resolve(),wt()}function V(e){var t=(e.f&2)!=0;if($n?.add(e),z!==null&&!rr&&!(B!==null&&B.f&16384)&&(or===null||!u.call(or,e))){var n=z.deps;if(z.f&2097152)e.rv<pr&&(e.rv=pr,cr===null&&n!==null&&n[lr]===e?lr++:cr===null?cr=[e]:cr.push(e));else{z.deps??=[],u.call(z.deps,e)||z.deps.push(e);var r=e.reactions;r===null?e.reactions=[z]:u.call(r,z)||r.push(z)}}if(tr&&Qt.has(e))return Qt.get(e);if(t){var i=e;if(tr){var a=i.v;return(!(i.f&1024)&&i.reactions!==null||Tr(i))&&(a=qt(i)),Qt.set(i,a),a}var o=(i.f&512)==0&&!rr&&z!==null&&(er||(z.f&512)!=0),s=(i.f&te)===0;_r(i)&&(o&&(i.f|=512),Jt(i)),o&&!s&&(Xt(i),wr(i))}if(ht?.has(e))return ht.get(e);if(e.f&8388608)throw e.v;return e.v}function wr(e){if(e.f|=512,e.deps!==null)for(let t of e.deps)(t.reactions??=[]).push(e),t.f&2&&!(t.f&512)&&(Xt(t),wr(t))}function Tr(e){if(e.v===i)return!0;if(e.deps===null)return!1;for(let t of e.deps)if(Qt.has(t)||t.f&2&&Tr(t))return!0;return!1}function Er(e){var t=rr;try{return rr=!0,e()}finally{rr=t}}var Dr=Symbol(`events`),Or=new Set,kr=new Set;function H(e,t,n){(t[Dr]??={})[e]=n}function Ar(e){for(var t=0;t<e.length;t++)Or.add(e[t]);for(var n of kr)n(e)}var jr=null;function Mr(e){var t=this,n=t.ownerDocument,r=e.type,i=e.composedPath?.()||[],a=i[0]||e.target;jr=e;var o=0,s=jr===e&&e[Dr];if(s){var c=i.indexOf(s);if(c!==-1&&(t===document||t===window)){e[Dr]=t;return}var l=i.indexOf(t);if(l===-1)return;c<=l&&(o=c)}if(a=i[o]||e.target,a!==t){f(e,`currentTarget`,{configurable:!0,get(){return a||n}});var u=z,d=B;ir(null),ar(null);try{for(var p,m=[];a!==null;){var h=a.assignedSlot||a.parentNode||a.host||null;try{var g=a[Dr]?.[r];g!=null&&(!a.disabled||e.target===a)&&g.call(a,e)}catch(e){p?m.push(e):p=e}if(e.cancelBubble||h===t||h===null)break;a=h}if(p){for(let e of m)queueMicrotask(()=>{throw e});throw p}}finally{e[Dr]=t,delete e.currentTarget,ir(u),ar(d)}}}var Nr=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function Pr(e){return Nr?.createHTML(e)??e}function Fr(e){var t=Sn(`template`);return t.innerHTML=Pr(e.replaceAll(`<!>`,`<!---->`)),t.content}function Ir(e,t){var n=B;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function U(e,t){var n=(t&1)!=0,r=(t&2)!=0,i,a=!e.startsWith(`<!>`);return()=>{if(A)return Ir(j,null),j;i===void 0&&(i=Fr(a?e:`<!>`+e),n||(i=_n(i)));var t=r||fn?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=_n(t),s=t.lastChild;Ir(o,s)}else Ir(t,t);return t}}function Lr(){if(A)return Ir(j,null),j;var e=document.createDocumentFragment(),t=document.createComment(``),n=gn();return e.append(t,n),Ir(t,n),e}function W(e,t){if(A){var n=B;(!(n.f&32768)||n.nodes.end===null)&&(n.nodes.end=j),Pe();return}e!==null&&e.before(t)}[...`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(`.`)];var Rr=[`touchstart`,`touchmove`];function zr(e){return Rr.includes(e)}function Br(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e[pe]??=e.nodeValue)&&(e[pe]=n,e.nodeValue=`${n}`)}function Vr(e,t){return Ur(e,t)}var Hr=new Map;function Ur(e,{target:t,anchor:n,props:i={},events:a,context:o,intro:s=!0,transformError:c}){hn();var l=void 0,u=Fn(()=>{var s=n??t.appendChild(gn());Ft(s,{pending:()=>{}},t=>{We({});var n=N;if(o&&(n.c=o),a&&(i.$$events=a),A&&Ir(t,null),l=e(t,i)||{},A&&(B.nodes.end=j,j===null||j.nodeType!==8||j.data!==`]`))throw ke(),r;Ge()},c);var u=new Set,f=e=>{for(var n=0;n<e.length;n++){var r=e[n];if(!u.has(r)){u.add(r);var i=zr(r);for(let e of[t,document]){var a=Hr.get(e);a===void 0&&(a=new Map,Hr.set(e,a));var o=a.get(r);o===void 0?(e.addEventListener(r,Mr,{passive:i}),a.set(r,1)):a.set(r,o+1)}}}};return f(d(Or)),kr.add(f),()=>{for(var e of u)for(let n of[t,document]){var r=Hr.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,Mr),r.delete(e),r.size===0&&Hr.delete(n)):r.set(e,i)}kr.delete(f),s!==n&&s.parentNode?.removeChild(s)}});return Wr.set(l,u),l}var Wr=new WeakMap,Gr=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)Xn(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(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&&(Gn(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();Qn(r,t),t.append(gn()),this.#n.set(e,{effect:r,fragment:t})}else Gn(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),Jn(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)||(Gn(n.effect),this.#n.delete(e))};ensure(e,t){var n=P,r=xn();if(t&&!this.#t.has(e)&&!this.#n.has(e))if(r){var i=document.createDocumentFragment(),a=gn();i.append(a),this.#n.set(e,{effect:Vn(()=>t(a)),fragment:i})}else this.#t.set(e,Vn(()=>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 A&&(this.anchor=j),this.#a(n)}};function Kr(e){N===null&&_e(`onMount`),He&&N.l!==null?Jr(N).m.push(e):Nn(()=>{let t=Er(e);if(typeof t==`function`)return t})}function qr(e){N===null&&_e(`onDestroy`),Kr(()=>()=>Er(e))}function Jr(e){var t=e.l;return t.u??={a:[],b:[],m:[]}}function Yr(e,t,n=!1){var r;A&&(r=j,Pe());var i=new Gr(e),a=n?D:0;function o(e,t){if(A){var n=Le(r);if(e!==parseInt(n.substring(1))){var a=Ie();Ne(a),i.anchor=a,Me(!1),i.ensure(e,t),Me(!0);return}}i.ensure(e,t)}Bn(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}function Xr(e,t,n){for(var r=[],i=t.length,a,o=t.length,s=0;s<i;s++){let n=t[s];Jn(n,()=>{if(a){if(a.pending.delete(n),a.done.add(n),a.pending.size===0){var t=e.outrogroups;Zr(e,d(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;bn(u),u.append(l),e.items.clear()}Zr(e,t,!c)}else a={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(a)}function Zr(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|=re,Qn(a,document.createDocumentFragment())):Gn(t[i],n)}}var Qr;function $r(e,t,n,r,i,a=null){var o=e,s=new Map;if(t&4){var l=e;o=A?Ne(_n(l)):l.appendChild(gn())}A&&Pe();var u=null,f=Gt(()=>{var e=n();return c(e)?e:e==null?[]:d(e)}),p,m=new Map,h=!0;function g(e){v.effect.f&16384||(v.pending.delete(e),v.fallback=u,ti(v,p,o,t,r),u!==null&&(p.length===0?u.f&33554432?(u.f^=re,ri(u,null,o)):Xn(u):Jn(u,()=>{u=null})))}function _(e){v.pending.delete(e)}var v={effect:Bn(()=>{p=V(f);var e=p.length;let c=!1;A&&Le(o)===`[!`!=(e===0)&&(o=Ie(),Ne(o),Me(!1),c=!0);for(var l=new Set,d=P,v=xn(),y=0;y<e;y+=1){A&&j.nodeType===8&&j.data===`]`&&(o=j,c=!0,Me(!1));var b=p[y],x=r(b,y),S=h?null:s.get(x);S?(S.v&&nn(S.v,b),S.i&&nn(S.i,y),v&&d.unskip_effect(S.e)):(S=ni(s,h?o:Qr??=gn(),b,x,y,i,t,n),h||(S.e.f|=re),s.set(x,S)),l.add(x)}if(e===0&&a&&!u&&(h?u=Vn(()=>a(o)):(u=Vn(()=>a(Qr??=gn())),u.f|=re)),e>l.size&&ye(``,``,``),A&&e>0&&Ne(Ie()),!h)if(m.set(d,l),v){for(let[e,t]of s)l.has(e)||d.skip_effect(t.e);d.oncommit(g),d.ondiscard(_)}else g(d);c&&Me(!0),V(f)}),flags:t,items:s,pending:m,outrogroups:null,fallback:u};h=!1,A&&(o=j)}function ei(e){for(;e!==null&&!(e.f&32);)e=e.next;return e}function ti(e,t,n,r,i){var a=(r&8)!=0,o=t.length,s=e.items,c=ei(e.effect.first),l,u=null,f,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(),(f??=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&&(Xn(_),a&&(_.nodes?.a?.unfix(),(f??=new Set).delete(_))),_.f&33554432)if(_.f^=re,_===c)ri(_,null,n);else{var y=u?u.next:c;_===e.effect.last&&(e.effect.last=_.prev),_.prev&&(_.prev.next=_.next),_.next&&(_.next.prev=_.prev),ii(e,u,_),ii(e,_,y),ri(_,y,n),u=_,p=[],m=[],c=ei(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)ri(p[x],b,n);for(x=0;x<m.length;x+=1)l.delete(m[x]);ii(e,S.prev,C.next),ii(e,u,S),ii(e,C,b),c=b,u=C,--v,p=[],m=[]}else l.delete(_),ri(_,c,n),ii(e,_.prev,_.next),ii(e,_,u===null?e.effect.first:u.next),ii(e,u,_),u=_;continue}for(p=[],m=[];c!==null&&c!==_;)(l??=new Set).add(c),m.push(c),c=ei(c.next);if(c===null)continue}_.f&33554432||p.push(_),u=_,c=ei(_.next)}if(e.outrogroups!==null){for(let t of e.outrogroups)t.pending.size===0&&(Zr(e,d(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=ei(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()}Xr(e,w,E)}}a&&Ye(()=>{if(f!==void 0)for(_ of f)_.nodes?.a?.apply()})}function ni(e,t,n,r,i,a,o,s){var c=o&1?o&16?en(n):tn(n,!1,!1):null,l=o&2?en(i):null;return{v:c,i:l,e:Vn(()=>(a(t,c??n,l??i,s),()=>{e.delete(r)}))}}function ri(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=vn(r);if(a.before(r),r===i)return;r=o}}function ii(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function ai(e,t,n=!1,i=!1,a=!1,c=!1){var l=e,u=``;if(n){var d=e;A&&(l=Ne(_n(d)))}zn(()=>{var e=B;if(u===(u=t()??``)){A&&Pe();return}if(n&&!A){e.nodes=null,d.innerHTML=u,u!==``&&Ir(_n(d),d.lastChild);return}if(e.nodes!==null&&(Kn(e.nodes.start,e.nodes.end),e.nodes=null),u!==``){if(A){for(var c=j.data,f=Pe(),p=f;f!==null&&(f.nodeType!==8||f.data!==``);)p=f,f=vn(f);if(f===null)throw ke(),r;Ir(j,p),l=Ne(f);return}var m=Sn(i?`svg`:a?`math`:`template`,i?o:a?s:void 0);m.innerHTML=u;var h=i||a?m:m.content;if(Ir(_n(h),h.lastChild),i||a)for(;_n(h);)l.before(_n(h));else l.before(h)}})}var oi=[...`
|
|
2
|
-
\r\f\xA0\v`];function
|
|
3
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function G(e,t,n){return(t=
|
|
4
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function
|
|
5
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Gi(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function K(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Gi(Object(n),!0).forEach(function(t){G(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Gi(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ki(e,t){return Fi(e)||Hi(e,t)||Zi(e,t)||Ui()}function qi(e){return Ii(e)||Vi(e)||Zi(e)||Wi()}function Ji(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Yi(e){var t=Ji(e,`string`);return typeof t==`symbol`?t:t+``}function Xi(e){"@babel/helpers - typeof";return Xi=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Xi(e)}function Zi(e,t){if(e){if(typeof e==`string`)return Pi(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Pi(e,t):void 0}}var Qi=function(){},$i={},ea={},ta=null,na={mark:Qi,measure:Qi};try{typeof window<`u`&&($i=window),typeof document<`u`&&(ea=document),typeof MutationObserver<`u`&&(ta=MutationObserver),typeof performance<`u`&&(na=performance)}catch{}var ra=($i.navigator||{}).userAgent,ia=ra===void 0?``:ra,aa=$i,oa=ea,sa=ta,ca=na;aa.document;var la=!!oa.documentElement&&!!oa.head&&typeof oa.addEventListener==`function`&&typeof oa.createElement==`function`,ua=~ia.indexOf(`MSIE`)||~ia.indexOf(`Trident/`),da,fa=/fa(k|kd|s|r|l|t|d|dr|dl|dt|b|slr|slpr|wsb|tl|ns|nds|es|gt|jr|jfr|jdr|usb|ufsb|udsb|cr|ss|sr|sl|st|sds|sdr|sdl|sdt)?[\-\ ]/,pa=/Font ?Awesome ?([567 ]*)(Solid|Regular|Light|Thin|Duotone|Brands|Free|Pro|Sharp Duotone|Sharp|Kit|Notdog Duo|Notdog|Chisel|Etch|Graphite|Thumbprint|Jelly Fill|Jelly Duo|Jelly|Utility|Utility Fill|Utility Duo|Slab Press|Slab|Whiteboard)?.*/i,ma={classic:{fa:`solid`,fas:`solid`,"fa-solid":`solid`,far:`regular`,"fa-regular":`regular`,fal:`light`,"fa-light":`light`,fat:`thin`,"fa-thin":`thin`,fab:`brands`,"fa-brands":`brands`},duotone:{fa:`solid`,fad:`solid`,"fa-solid":`solid`,"fa-duotone":`solid`,fadr:`regular`,"fa-regular":`regular`,fadl:`light`,"fa-light":`light`,fadt:`thin`,"fa-thin":`thin`},sharp:{fa:`solid`,fass:`solid`,"fa-solid":`solid`,fasr:`regular`,"fa-regular":`regular`,fasl:`light`,"fa-light":`light`,fast:`thin`,"fa-thin":`thin`},"sharp-duotone":{fa:`solid`,fasds:`solid`,"fa-solid":`solid`,fasdr:`regular`,"fa-regular":`regular`,fasdl:`light`,"fa-light":`light`,fasdt:`thin`,"fa-thin":`thin`},slab:{"fa-regular":`regular`,faslr:`regular`},"slab-press":{"fa-regular":`regular`,faslpr:`regular`},thumbprint:{"fa-light":`light`,fatl:`light`},whiteboard:{"fa-semibold":`semibold`,fawsb:`semibold`},notdog:{"fa-solid":`solid`,fans:`solid`},"notdog-duo":{"fa-solid":`solid`,fands:`solid`},etch:{"fa-solid":`solid`,faes:`solid`},graphite:{"fa-thin":`thin`,fagt:`thin`},jelly:{"fa-regular":`regular`,fajr:`regular`},"jelly-fill":{"fa-regular":`regular`,fajfr:`regular`},"jelly-duo":{"fa-regular":`regular`,fajdr:`regular`},chisel:{"fa-regular":`regular`,facr:`regular`},utility:{"fa-semibold":`semibold`,fausb:`semibold`},"utility-duo":{"fa-semibold":`semibold`,faudsb:`semibold`},"utility-fill":{"fa-semibold":`semibold`,faufsb:`semibold`}},ha={GROUP:`duotone-group`,SWAP_OPACITY:`swap-opacity`,PRIMARY:`primary`,SECONDARY:`secondary`},ga=[`fa-classic`,`fa-duotone`,`fa-sharp`,`fa-sharp-duotone`,`fa-thumbprint`,`fa-whiteboard`,`fa-notdog`,`fa-notdog-duo`,`fa-chisel`,`fa-etch`,`fa-graphite`,`fa-jelly`,`fa-jelly-fill`,`fa-jelly-duo`,`fa-slab`,`fa-slab-press`,`fa-utility`,`fa-utility-duo`,`fa-utility-fill`],_a=`classic`,va=`duotone`,ya=`sharp`,ba=`sharp-duotone`,xa=`chisel`,Sa=`etch`,Ca=`graphite`,wa=`jelly`,Ta=`jelly-duo`,Ea=`jelly-fill`,Da=`notdog`,Oa=`notdog-duo`,ka=`slab`,Aa=`slab-press`,ja=`thumbprint`,Ma=`utility`,Na=`utility-duo`,Pa=`utility-fill`,Fa=`whiteboard`,Ia=`Classic`,La=`Duotone`,Ra=`Sharp`,za=`Sharp Duotone`,Ba=`Chisel`,Va=`Etch`,Ha=`Graphite`,Ua=`Jelly`,Wa=`Jelly Duo`,Ga=`Jelly Fill`,Ka=`Notdog`,qa=`Notdog Duo`,Ja=`Slab`,Ya=`Slab Press`,Xa=`Thumbprint`,Za=`Utility`,Qa=`Utility Duo`,$a=`Utility Fill`,eo=`Whiteboard`,to=[_a,va,ya,ba,xa,Sa,Ca,wa,Ta,Ea,Da,Oa,ka,Aa,ja,Ma,Na,Pa,Fa];da={},G(G(G(G(G(G(G(G(G(G(da,_a,Ia),va,La),ya,Ra),ba,za),xa,Ba),Sa,Va),Ca,Ha),wa,Ua),Ta,Wa),Ea,Ga),G(G(G(G(G(G(G(G(G(da,Da,Ka),Oa,qa),ka,Ja),Aa,Ya),ja,Xa),Ma,Za),Na,Qa),Pa,$a),Fa,eo);var no={classic:{900:`fas`,400:`far`,normal:`far`,300:`fal`,100:`fat`},duotone:{900:`fad`,400:`fadr`,300:`fadl`,100:`fadt`},sharp:{900:`fass`,400:`fasr`,300:`fasl`,100:`fast`},"sharp-duotone":{900:`fasds`,400:`fasdr`,300:`fasdl`,100:`fasdt`},slab:{400:`faslr`},"slab-press":{400:`faslpr`},whiteboard:{600:`fawsb`},thumbprint:{300:`fatl`},notdog:{900:`fans`},"notdog-duo":{900:`fands`},etch:{900:`faes`},graphite:{100:`fagt`},chisel:{400:`facr`},jelly:{400:`fajr`},"jelly-fill":{400:`fajfr`},"jelly-duo":{400:`fajdr`},utility:{600:`fausb`},"utility-duo":{600:`faudsb`},"utility-fill":{600:`faufsb`}},ro={"Font Awesome 7 Free":{900:`fas`,400:`far`},"Font Awesome 7 Pro":{900:`fas`,400:`far`,normal:`far`,300:`fal`,100:`fat`},"Font Awesome 7 Brands":{400:`fab`,normal:`fab`},"Font Awesome 7 Duotone":{900:`fad`,400:`fadr`,normal:`fadr`,300:`fadl`,100:`fadt`},"Font Awesome 7 Sharp":{900:`fass`,400:`fasr`,normal:`fasr`,300:`fasl`,100:`fast`},"Font Awesome 7 Sharp Duotone":{900:`fasds`,400:`fasdr`,normal:`fasdr`,300:`fasdl`,100:`fasdt`},"Font Awesome 7 Jelly":{400:`fajr`,normal:`fajr`},"Font Awesome 7 Jelly Fill":{400:`fajfr`,normal:`fajfr`},"Font Awesome 7 Jelly Duo":{400:`fajdr`,normal:`fajdr`},"Font Awesome 7 Slab":{400:`faslr`,normal:`faslr`},"Font Awesome 7 Slab Press":{400:`faslpr`,normal:`faslpr`},"Font Awesome 7 Thumbprint":{300:`fatl`,normal:`fatl`},"Font Awesome 7 Notdog":{900:`fans`,normal:`fans`},"Font Awesome 7 Notdog Duo":{900:`fands`,normal:`fands`},"Font Awesome 7 Etch":{900:`faes`,normal:`faes`},"Font Awesome 7 Graphite":{100:`fagt`,normal:`fagt`},"Font Awesome 7 Chisel":{400:`facr`,normal:`facr`},"Font Awesome 7 Whiteboard":{600:`fawsb`,normal:`fawsb`},"Font Awesome 7 Utility":{600:`fausb`,normal:`fausb`},"Font Awesome 7 Utility Duo":{600:`faudsb`,normal:`faudsb`},"Font Awesome 7 Utility Fill":{600:`faufsb`,normal:`faufsb`}},io=new Map([[`classic`,{defaultShortPrefixId:`fas`,defaultStyleId:`solid`,styleIds:[`solid`,`regular`,`light`,`thin`,`brands`],futureStyleIds:[],defaultFontWeight:900}],[`duotone`,{defaultShortPrefixId:`fad`,defaultStyleId:`solid`,styleIds:[`solid`,`regular`,`light`,`thin`],futureStyleIds:[],defaultFontWeight:900}],[`sharp`,{defaultShortPrefixId:`fass`,defaultStyleId:`solid`,styleIds:[`solid`,`regular`,`light`,`thin`],futureStyleIds:[],defaultFontWeight:900}],[`sharp-duotone`,{defaultShortPrefixId:`fasds`,defaultStyleId:`solid`,styleIds:[`solid`,`regular`,`light`,`thin`],futureStyleIds:[],defaultFontWeight:900}],[`chisel`,{defaultShortPrefixId:`facr`,defaultStyleId:`regular`,styleIds:[`regular`],futureStyleIds:[],defaultFontWeight:400}],[`etch`,{defaultShortPrefixId:`faes`,defaultStyleId:`solid`,styleIds:[`solid`],futureStyleIds:[],defaultFontWeight:900}],[`graphite`,{defaultShortPrefixId:`fagt`,defaultStyleId:`thin`,styleIds:[`thin`],futureStyleIds:[],defaultFontWeight:100}],[`jelly`,{defaultShortPrefixId:`fajr`,defaultStyleId:`regular`,styleIds:[`regular`],futureStyleIds:[],defaultFontWeight:400}],[`jelly-duo`,{defaultShortPrefixId:`fajdr`,defaultStyleId:`regular`,styleIds:[`regular`],futureStyleIds:[],defaultFontWeight:400}],[`jelly-fill`,{defaultShortPrefixId:`fajfr`,defaultStyleId:`regular`,styleIds:[`regular`],futureStyleIds:[],defaultFontWeight:400}],[`notdog`,{defaultShortPrefixId:`fans`,defaultStyleId:`solid`,styleIds:[`solid`],futureStyleIds:[],defaultFontWeight:900}],[`notdog-duo`,{defaultShortPrefixId:`fands`,defaultStyleId:`solid`,styleIds:[`solid`],futureStyleIds:[],defaultFontWeight:900}],[`slab`,{defaultShortPrefixId:`faslr`,defaultStyleId:`regular`,styleIds:[`regular`],futureStyleIds:[],defaultFontWeight:400}],[`slab-press`,{defaultShortPrefixId:`faslpr`,defaultStyleId:`regular`,styleIds:[`regular`],futureStyleIds:[],defaultFontWeight:400}],[`thumbprint`,{defaultShortPrefixId:`fatl`,defaultStyleId:`light`,styleIds:[`light`],futureStyleIds:[],defaultFontWeight:300}],[`utility`,{defaultShortPrefixId:`fausb`,defaultStyleId:`semibold`,styleIds:[`semibold`],futureStyleIds:[],defaultFontWeight:600}],[`utility-duo`,{defaultShortPrefixId:`faudsb`,defaultStyleId:`semibold`,styleIds:[`semibold`],futureStyleIds:[],defaultFontWeight:600}],[`utility-fill`,{defaultShortPrefixId:`faufsb`,defaultStyleId:`semibold`,styleIds:[`semibold`],futureStyleIds:[],defaultFontWeight:600}],[`whiteboard`,{defaultShortPrefixId:`fawsb`,defaultStyleId:`semibold`,styleIds:[`semibold`],futureStyleIds:[],defaultFontWeight:600}]]),ao={chisel:{regular:`facr`},classic:{brands:`fab`,light:`fal`,regular:`far`,solid:`fas`,thin:`fat`},duotone:{light:`fadl`,regular:`fadr`,solid:`fad`,thin:`fadt`},etch:{solid:`faes`},graphite:{thin:`fagt`},jelly:{regular:`fajr`},"jelly-duo":{regular:`fajdr`},"jelly-fill":{regular:`fajfr`},notdog:{solid:`fans`},"notdog-duo":{solid:`fands`},sharp:{light:`fasl`,regular:`fasr`,solid:`fass`,thin:`fast`},"sharp-duotone":{light:`fasdl`,regular:`fasdr`,solid:`fasds`,thin:`fasdt`},slab:{regular:`faslr`},"slab-press":{regular:`faslpr`},thumbprint:{light:`fatl`},utility:{semibold:`fausb`},"utility-duo":{semibold:`faudsb`},"utility-fill":{semibold:`faufsb`},whiteboard:{semibold:`fawsb`}},oo=[`fak`,`fa-kit`,`fakd`,`fa-kit-duotone`],so={kit:{fak:`kit`,"fa-kit":`kit`},"kit-duotone":{fakd:`kit-duotone`,"fa-kit-duotone":`kit-duotone`}},co=[`kit`];G(G({},`kit`,`Kit`),`kit-duotone`,`Kit Duotone`);var lo={kit:{"fa-kit":`fak`},"kit-duotone":{"fa-kit-duotone":`fakd`}},uo={"Font Awesome Kit":{400:`fak`,normal:`fak`},"Font Awesome Kit Duotone":{400:`fakd`,normal:`fakd`}},fo={kit:{fak:`fa-kit`},"kit-duotone":{fakd:`fa-kit-duotone`}},po={kit:{kit:`fak`},"kit-duotone":{"kit-duotone":`fakd`}},mo,ho={GROUP:`duotone-group`,SWAP_OPACITY:`swap-opacity`,PRIMARY:`primary`,SECONDARY:`secondary`},go=[`fa-classic`,`fa-duotone`,`fa-sharp`,`fa-sharp-duotone`,`fa-thumbprint`,`fa-whiteboard`,`fa-notdog`,`fa-notdog-duo`,`fa-chisel`,`fa-etch`,`fa-graphite`,`fa-jelly`,`fa-jelly-fill`,`fa-jelly-duo`,`fa-slab`,`fa-slab-press`,`fa-utility`,`fa-utility-duo`,`fa-utility-fill`];mo={},G(G(G(G(G(G(G(G(G(G(mo,`classic`,`Classic`),`duotone`,`Duotone`),`sharp`,`Sharp`),`sharp-duotone`,`Sharp Duotone`),`chisel`,`Chisel`),`etch`,`Etch`),`graphite`,`Graphite`),`jelly`,`Jelly`),`jelly-duo`,`Jelly Duo`),`jelly-fill`,`Jelly Fill`),G(G(G(G(G(G(G(G(G(mo,`notdog`,`Notdog`),`notdog-duo`,`Notdog Duo`),`slab`,`Slab`),`slab-press`,`Slab Press`),`thumbprint`,`Thumbprint`),`utility`,`Utility`),`utility-duo`,`Utility Duo`),`utility-fill`,`Utility Fill`),`whiteboard`,`Whiteboard`),G(G({},`kit`,`Kit`),`kit-duotone`,`Kit Duotone`);var _o={classic:{"fa-brands":`fab`,"fa-duotone":`fad`,"fa-light":`fal`,"fa-regular":`far`,"fa-solid":`fas`,"fa-thin":`fat`},duotone:{"fa-regular":`fadr`,"fa-light":`fadl`,"fa-thin":`fadt`},sharp:{"fa-solid":`fass`,"fa-regular":`fasr`,"fa-light":`fasl`,"fa-thin":`fast`},"sharp-duotone":{"fa-solid":`fasds`,"fa-regular":`fasdr`,"fa-light":`fasdl`,"fa-thin":`fasdt`},slab:{"fa-regular":`faslr`},"slab-press":{"fa-regular":`faslpr`},whiteboard:{"fa-semibold":`fawsb`},thumbprint:{"fa-light":`fatl`},notdog:{"fa-solid":`fans`},"notdog-duo":{"fa-solid":`fands`},etch:{"fa-solid":`faes`},graphite:{"fa-thin":`fagt`},jelly:{"fa-regular":`fajr`},"jelly-fill":{"fa-regular":`fajfr`},"jelly-duo":{"fa-regular":`fajdr`},chisel:{"fa-regular":`facr`},utility:{"fa-semibold":`fausb`},"utility-duo":{"fa-semibold":`faudsb`},"utility-fill":{"fa-semibold":`faufsb`}},vo={classic:[`fas`,`far`,`fal`,`fat`,`fad`],duotone:[`fadr`,`fadl`,`fadt`],sharp:[`fass`,`fasr`,`fasl`,`fast`],"sharp-duotone":[`fasds`,`fasdr`,`fasdl`,`fasdt`],slab:[`faslr`],"slab-press":[`faslpr`],whiteboard:[`fawsb`],thumbprint:[`fatl`],notdog:[`fans`],"notdog-duo":[`fands`],etch:[`faes`],graphite:[`fagt`],jelly:[`fajr`],"jelly-fill":[`fajfr`],"jelly-duo":[`fajdr`],chisel:[`facr`],utility:[`fausb`],"utility-duo":[`faudsb`],"utility-fill":[`faufsb`]},yo={classic:{fab:`fa-brands`,fad:`fa-duotone`,fal:`fa-light`,far:`fa-regular`,fas:`fa-solid`,fat:`fa-thin`},duotone:{fadr:`fa-regular`,fadl:`fa-light`,fadt:`fa-thin`},sharp:{fass:`fa-solid`,fasr:`fa-regular`,fasl:`fa-light`,fast:`fa-thin`},"sharp-duotone":{fasds:`fa-solid`,fasdr:`fa-regular`,fasdl:`fa-light`,fasdt:`fa-thin`},slab:{faslr:`fa-regular`},"slab-press":{faslpr:`fa-regular`},whiteboard:{fawsb:`fa-semibold`},thumbprint:{fatl:`fa-light`},notdog:{fans:`fa-solid`},"notdog-duo":{fands:`fa-solid`},etch:{faes:`fa-solid`},graphite:{fagt:`fa-thin`},jelly:{fajr:`fa-regular`},"jelly-fill":{fajfr:`fa-regular`},"jelly-duo":{fajdr:`fa-regular`},chisel:{facr:`fa-regular`},utility:{fausb:`fa-semibold`},"utility-duo":{faudsb:`fa-semibold`},"utility-fill":{faufsb:`fa-semibold`}},bo=`fa.fas.far.fal.fat.fad.fadr.fadl.fadt.fab.fass.fasr.fasl.fast.fasds.fasdr.fasdl.fasdt.faslr.faslpr.fawsb.fatl.fans.fands.faes.fagt.fajr.fajfr.fajdr.facr.fausb.faudsb.faufsb`.split(`.`).concat(go,[`fa-solid`,`fa-regular`,`fa-light`,`fa-thin`,`fa-duotone`,`fa-brands`,`fa-semibold`]),xo=[`solid`,`regular`,`light`,`thin`,`duotone`,`brands`,`semibold`],So=[1,2,3,4,5,6,7,8,9,10],Co=So.concat([11,12,13,14,15,16,17,18,19,20]),wo=[].concat(qi(Object.keys(vo)),xo,[`aw`,`fw`,`pull-left`,`pull-right`],[`2xs`,`xs`,`sm`,`lg`,`xl`,`2xl`,`beat`,`border`,`fade`,`beat-fade`,`bounce`,`flip-both`,`flip-horizontal`,`flip-vertical`,`flip`,`inverse`,`layers`,`layers-bottom-left`,`layers-bottom-right`,`layers-counter`,`layers-text`,`layers-top-left`,`layers-top-right`,`li`,`pull-end`,`pull-start`,`pulse`,`rotate-180`,`rotate-270`,`rotate-90`,`rotate-by`,`shake`,`spin-pulse`,`spin-reverse`,`spin`,`stack-1x`,`stack-2x`,`stack`,`ul`,`width-auto`,`width-fixed`,ho.GROUP,ho.SWAP_OPACITY,ho.PRIMARY,ho.SECONDARY],So.map(function(e){return`${e}x`}),Co.map(function(e){return`w-${e}`})),To={"Font Awesome 5 Free":{900:`fas`,400:`far`},"Font Awesome 5 Pro":{900:`fas`,400:`far`,normal:`far`,300:`fal`},"Font Awesome 5 Brands":{400:`fab`,normal:`fab`},"Font Awesome 5 Duotone":{900:`fad`}},Eo=`___FONT_AWESOME___`,Do=16,Oo=`fa`,ko=`svg-inline--fa`,Ao=`data-fa-i2svg`,jo=`data-fa-pseudo-element`,Mo=`data-fa-pseudo-element-pending`,No=`data-prefix`,Po=`data-icon`,Fo=`fontawesome-i2svg`,Io=`async`,Lo=[`HTML`,`HEAD`,`STYLE`,`SCRIPT`],Ro=[`::before`,`::after`,`:before`,`:after`],zo=function(){try{return!0}catch{return!1}}();function Bo(e){return new Proxy(e,{get:function(e,t){return t in e?e[t]:e[_a]}})}var Vo=K({},ma);Vo[_a]=K(K(K(K({},{"fa-duotone":`duotone`}),ma[_a]),so.kit),so[`kit-duotone`]);var Ho=Bo(Vo),Uo=K({},ao);Uo[_a]=K(K(K(K({},{duotone:`fad`}),Uo[_a]),po.kit),po[`kit-duotone`]);var Wo=Bo(Uo),Go=K({},yo);Go[_a]=K(K({},Go[_a]),fo.kit);var Ko=Bo(Go),qo=K({},_o);qo[_a]=K(K({},qo[_a]),lo.kit),Bo(qo);var Jo=fa,Yo=`fa-layers-text`,Xo=pa;Bo(K({},no));var Zo=[`class`,`data-prefix`,`data-icon`,`data-fa-transform`,`data-fa-mask`],Qo=ha,$o=[].concat(qi(co),qi(wo)),es=aa.FontAwesomeConfig||{};function ts(e){var t=oa.querySelector(`script[`+e+`]`);if(t)return t.getAttribute(e)}function ns(e){return e===``?!0:e===`false`?!1:e===`true`?!0:e}oa&&typeof oa.querySelector==`function`&&[[`data-family-prefix`,`familyPrefix`],[`data-css-prefix`,`cssPrefix`],[`data-family-default`,`familyDefault`],[`data-style-default`,`styleDefault`],[`data-replacement-class`,`replacementClass`],[`data-auto-replace-svg`,`autoReplaceSvg`],[`data-auto-add-css`,`autoAddCss`],[`data-search-pseudo-elements`,`searchPseudoElements`],[`data-search-pseudo-elements-warnings`,`searchPseudoElementsWarnings`],[`data-search-pseudo-elements-full-scan`,`searchPseudoElementsFullScan`],[`data-observe-mutations`,`observeMutations`],[`data-mutate-approach`,`mutateApproach`],[`data-keep-original-source`,`keepOriginalSource`],[`data-measure-performance`,`measurePerformance`],[`data-show-missing-icons`,`showMissingIcons`]].forEach(function(e){var t=Ki(e,2),n=t[0],r=t[1],i=ns(ts(n));i!=null&&(es[r]=i)});var rs={styleDefault:`solid`,familyDefault:_a,cssPrefix:Oo,replacementClass:ko,autoReplaceSvg:!0,autoAddCss:!0,searchPseudoElements:!1,searchPseudoElementsWarnings:!0,searchPseudoElementsFullScan:!1,observeMutations:!0,mutateApproach:`async`,keepOriginalSource:!0,measurePerformance:!1,showMissingIcons:!0};es.familyPrefix&&(es.cssPrefix=es.familyPrefix);var is=K(K({},rs),es);is.autoReplaceSvg||(is.observeMutations=!1);var q={};Object.keys(rs).forEach(function(e){Object.defineProperty(q,e,{enumerable:!0,set:function(t){is[e]=t,as.forEach(function(e){return e(q)})},get:function(){return is[e]}})}),Object.defineProperty(q,"familyPrefix",{enumerable:!0,set:function(e){is.cssPrefix=e,as.forEach(function(e){return e(q)})},get:function(){return is.cssPrefix}}),aa.FontAwesomeConfig=q;var as=[];function os(e){return as.push(e),function(){as.splice(as.indexOf(e),1)}}var ss=Do,cs={size:16,x:0,y:0,rotate:0,flipX:!1,flipY:!1};function ls(e){if(!(!e||!la)){var t=oa.createElement(`style`);t.setAttribute(`type`,`text/css`),t.innerHTML=e;for(var n=oa.head.childNodes,r=null,i=n.length-1;i>-1;i--){var a=n[i],o=(a.tagName||``).toUpperCase();[`STYLE`,`LINK`].indexOf(o)>-1&&(r=a)}return oa.head.insertBefore(t,r),e}}var us=`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`;function ds(){for(var e=12,t=``;e-- >0;)t+=us[Math.random()*62|0];return t}function fs(e){for(var t=[],n=(e||[]).length>>>0;n--;)t[n]=e[n];return t}function ps(e){return e.classList?fs(e.classList):(e.getAttribute(`class`)||``).split(` `).filter(function(e){return e})}function ms(e){return`${e}`.replace(/&/g,`&`).replace(/"/g,`"`).replace(/'/g,`'`).replace(/</g,`<`).replace(/>/g,`>`)}function hs(e){return Object.keys(e||{}).reduce(function(t,n){return t+`${n}="${ms(e[n])}" `},``).trim()}function gs(e){return Object.keys(e||{}).reduce(function(t,n){return t+`${n}: ${e[n].trim()};`},``)}function _s(e){return e.size!==cs.size||e.x!==cs.x||e.y!==cs.y||e.rotate!==cs.rotate||e.flipX||e.flipY}function vs(e){var t=e.transform,n=e.containerWidth,r=e.iconWidth;return{outer:{transform:`translate(${n/2} 256)`},inner:{transform:`${`translate(${t.x*32}, ${t.y*32}) `} ${`scale(${t.size/16*(t.flipX?-1:1)}, ${t.size/16*(t.flipY?-1:1)}) `} ${`rotate(${t.rotate} 0 0)`}`},path:{transform:`translate(${r/2*-1} -256)`}}}function ys(e){var t=e.transform,n=e.width,r=n===void 0?Do:n,i=e.height,a=i===void 0?Do:i,o=e.startCentered,s=o===void 0?!1:o,c=``;return s&&ua?c+=`translate(${t.x/ss-r/2}em, ${t.y/ss-a/2}em) `:s?c+=`translate(calc(-50% + ${t.x/ss}em), calc(-50% + ${t.y/ss}em)) `:c+=`translate(${t.x/ss}em, ${t.y/ss}em) `,c+=`scale(${t.size/ss*(t.flipX?-1:1)}, ${t.size/ss*(t.flipY?-1:1)}) `,c+=`rotate(${t.rotate}deg) `,c}var bs=`:root, :host {
|
|
1
|
+
import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{t as n}from"./maplibre-gl-TciDBW6i.js";(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)}})(),typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`);var r={},i=Symbol(`uninitialized`),a=`http://www.w3.org/1999/xhtml`,o=`http://www.w3.org/2000/svg`,s=`http://www.w3.org/1998/Math/MathML`,c=Array.isArray,l=Array.prototype.indexOf,u=Array.prototype.includes,d=Array.from,f=Object.defineProperty,p=Object.getOwnPropertyDescriptor,m=Object.getOwnPropertyDescriptors,h=Object.prototype,g=Array.prototype,_=Object.getPrototypeOf,v=Object.isExtensible,y=()=>{};function b(e){for(var t=0;t<e.length;t++)e[t]()}function x(){var e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function S(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 C=1024,w=2048,T=4096,E=8192,ee=16384,te=32768,ne=1<<25,D=65536,O=1<<19,k=1<<20,re=1<<25,ie=65536,ae=1<<21,oe=1<<22,se=1<<23,ce=Symbol(`$state`),le=Symbol(`legacy props`),ue=Symbol(``),de=Symbol(`attributes`),fe=Symbol(`class`),pe=Symbol(`style`),me=Symbol(`text`),A=Symbol(`form reset`),he=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"},ge=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`);function _e(e){throw Error(`https://svelte.dev/e/lifecycle_outside_component`)}function ve(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function ye(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function be(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function xe(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function Se(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function Ce(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function we(e){throw Error(`https://svelte.dev/e/props_invalid_value`)}function Te(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function Ee(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function De(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function Oe(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}function ke(){console.warn(`https://svelte.dev/e/derived_inert`)}function Ae(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function je(){console.warn(`https://svelte.dev/e/select_multiple_invalid_value`)}function Me(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var j=!1;function Ne(e){j=e}var M;function Pe(e){if(e===null)throw Ae(),r;return M=e}function Fe(){return Pe(Sn(M))}function N(e){if(j){if(Sn(M)!==null)throw Ae(),r;M=e}}function Ie(e=1){if(j){for(var t=e,n=M;t--;)n=Sn(n);M=n}}function Le(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 Re(e){if(!e||e.nodeType!==8)throw Ae(),r;return e.data}function ze(e){return e===this.v}function Be(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function Ve(e){return!Be(e,this.v)}var He=!1,Ue=!1,We=null;function Ge(e){We=e}function Ke(e,t=!1,n){We={p:We,i:!1,c:null,e:null,s:e,x:null,r:B,l:Ue&&!t?{s:null,u:null,$:[]}:null}}function qe(e){var t=We,n=t.e;if(n!==null){t.e=null;for(var r of n)Rn(r)}return e!==void 0&&(t.x=e),t.i=!0,We=t.p,e??{}}function Je(){return!Ue||We!==null&&We.l===null}var Ye=[];function Xe(){var e=Ye;Ye=[],b(e)}function Ze(e){if(Ye.length===0&&!xt){var t=Ye;queueMicrotask(()=>{t===Ye&&Xe()})}Ye.push(e)}function Qe(){for(;Ye.length>0;)Xe()}function $e(e){var t=B;if(t===null)return z.f|=se,e;if(!(t.f&32768)&&!(t.f&4))throw e;et(e,t)}function et(e,t){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 tt=~(w|T|C);function nt(e,t){e.f=e.f&tt|t}function rt(e){e.f&512||e.deps===null?nt(e,C):nt(e,T)}function it(e){if(e!==null)for(let t of e)!(t.f&2)||!(t.f&65536)||(t.f^=ie,it(t.deps))}function at(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),it(e.deps),nt(e,C)}function ot(e,t,n){if(e==null)return t(void 0),n&&n(void 0),y;let r=Ar(()=>e.subscribe(t,n));return r.unsubscribe?()=>r.unsubscribe():r}var st=[];function ct(e,t=y){let n=null,r=new Set;function i(t){if(Be(e,t)&&(e=t,n)){let t=!st.length;for(let t of r)t[1](),st.push(t,e);if(t){for(let e=0;e<st.length;e+=2)st[e][0](st[e+1]);st.length=0}}}function a(t){i(t(e))}function o(o,s=y){let c=[o,s];return r.add(c),r.size===1&&(n=t(i,a)||y),o(e),()=>{r.delete(c),r.size===0&&n&&(n(),n=null)}}return{set:i,update:a,subscribe:o}}function lt(e){let t;return ot(e,e=>t=e)(),t}var ut=!1,dt=!1,ft=Symbol(`unmounted`);function pt(e,t,n){let r=n[t]??={store:null,source:on(void 0),unsubscribe:y};if(r.store!==e&&!(ft in n))if(r.unsubscribe(),r.store=e??null,e==null)r.source.v=void 0,r.unsubscribe=y;else{var i=!0;r.unsubscribe=ot(e,e=>{i?r.source.v=e:I(r.source,e)}),i=!1}return e&&ft in n?lt(e):V(r.source)}function mt(){let e={};function t(){In(()=>{for(var t in e)e[t].unsubscribe();f(e,ft,{enumerable:!1,value:!0})})}return[e,t]}function ht(e){var t=dt;try{return dt=!1,[e(),dt]}finally{dt=t}}var gt=null,_t=null,P=null,vt=null,yt=null,bt=null,xt=!1,St=!1,Ct=null,wt=null,Tt=0,Et=1,Dt=class e{id=Et++;#e=!1;linked=!0;#t=null;#n=null;async_deriveds=new Map;current=new Map;previous=new Map;unblocked=new Set;#r=new Set;#i=new Set;#a=new Set;#o=0;#s=new Map;#c=null;#l=[];#u=[];#d=new Set;#f=new Set;#p=new Map;#m=new Set;is_fork=!1;#h=!1;#g(){if(this.is_fork)return!0;for(let n of this.#s.keys()){for(var e=n,t=!1;e.parent!==null;){if(this.#p.has(e)){t=!0;break}e=e.parent}if(!t)return!0}return!1}skip_effect(e){this.#p.has(e)||this.#p.set(e,{d:[],m:[]}),this.#m.delete(e)}unskip_effect(e,t=e=>this.schedule(e)){var n=this.#p.get(e);if(n){this.#p.delete(e);for(var r of n.d)nt(r,w),t(r);for(r of n.m)nt(r,T),t(r)}this.#m.add(e)}#_(){if(this.#e=!0,Tt++>1e3&&(this.#w(),kt()),!this.#g()){for(let e of this.#d)this.#f.delete(e),nt(e,w),this.schedule(e);for(let e of this.#f)nt(e,T),this.schedule(e)}let t=this.#l;this.#l=[],this.apply();var n=Ct=[],r=[],i=wt=[];for(let e of t)try{this.#v(e,n,r)}catch(t){throw It(e),t}if(P=null,i.length>0){var a=e.ensure();for(let e of i)a.schedule(e)}if(Ct=null,wt=null,this.#g()){this.#x(r),this.#x(n);for(let[e,t]of this.#p)Ft(e,t);i.length>0&&P.#_();return}let o=this.#y();if(o){o.#b(this);return}this.#d.clear(),this.#f.clear();for(let e of this.#r)e(this);this.#r.clear(),vt=this,jt(r),jt(n),vt=null,this.#c?.resolve();var s=P;if(this.linked&&this.#o===0&&this.#w(),He&&!this.linked&&(this.#S(),P=s),this.#l.length>0){s===null&&(s=this,this.#C());let e=s;e.#l.push(...this.#l.filter(t=>!e.#l.includes(t)))}s!==null&&s.#_()}#v(e,t,n){e.f^=C;for(var r=e.first;r!==null;){var i=r.f,a=(i&96)!=0;if(!(a&&i&1024||i&8192||this.#p.has(r))&&r.fn!==null){a?r.f^=C:i&4?t.push(r):He&&i&16777224?n.push(r):xr(r)&&(i&16&&this.#f.add(r),Er(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}}}#y(){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}#b(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)}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.#f.delete(i),nt(i,w),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#w(),P=this,this.#_()}#x(e){for(var t=0;t<e.length;t+=1)at(e[t],this.#d,this.#f)}capture(e,t,n=!1){e.v!==i&&!this.previous.has(e)&&this.previous.set(e,e.v),e.f&8388608||(this.current.set(e,[t,n]),yt?.set(e,t)),this.is_fork||(e.v=t)}activate(){P=this}deactivate(){P=null,yt=null}flush(){try{St=!0,P=this,this.#_()}finally{Tt=0,bt=null,Ct=null,wt=null,St=!1,P=null,yt=null,nn.clear()}}discard(){for(let e of this.#i)e(this);this.#i.clear(),this.#a.clear(),this.#w()}register_created_effect(e){this.#u.push(e)}#S(){this.#w();for(let l=gt;l!==null;l=l.#n){var e=l.id<this.id,t=[];for(let[r,[i,a]]of this.current){if(l.current.has(r)){var n=l.current.get(r)[0];if(e&&i!==n)l.current.set(r,[i,a]);else continue}t.push(r)}if(e)for(let[e,t]of this.async_deriveds){let n=l.async_deriveds.get(e);n&&t.promise.then(n.resolve)}if(l.#e){var r=[...l.current.keys()].filter(e=>!this.current.has(e));if(r.length===0)e&&l.discard();else if(t.length>0){if(e)for(let e of this.#m)l.unskip_effect(e,e=>{e.f&4194320?l.schedule(e):l.#x([e])});l.activate();var i=new Set,a=new Map;for(var o of t)Mt(o,r,i,a);a=new Map;var s=[...l.current.keys()].filter(e=>this.current.has(e)?this.current.get(e)[0]!==e.v:!0);if(s.length>0)for(let e of this.#u)!(e.f&155648)&&Nt(e,s,a)&&(e.f&4194320?(nt(e,w),l.schedule(e)):l.#d.add(e));if(l.#l.length>0&&!l.#h){l.apply();for(var c of l.#l)l.#v(c,[],[]);l.#l=[]}l.deactivate()}}}}increment(e,t){if(this.#o+=1,e){let e=this.#s.get(t)??0;this.#s.set(t,e+1)}}decrement(e,t){if(--this.#o,e){let e=this.#s.get(t)??0;e===1?this.#s.delete(t):this.#s.set(t,e-1)}this.#h||(this.#h=!0,Ze(()=>{this.#h=!1,this.linked&&this.flush()}))}transfer_effects(e,t){for(let t of e)this.#d.add(t);for(let e of t)this.#f.add(e);e.clear(),t.clear()}oncommit(e){this.#r.add(e)}ondiscard(e){this.#i.add(e)}on_fork_commit(e){this.#a.add(e)}run_fork_commit_callbacks(){for(let e of this.#a)e(this);this.#a.clear()}settled(){return(this.#c??=x()).promise}static ensure(){if(P===null){let t=P=new e;t.#C(),!St&&!xt&&Ze(()=>{t.#e||t.flush()})}return P}apply(){if(!He||!this.is_fork&&this.#t===null&&this.#n===null){yt=null;return}yt=new Map;for(let[e,[t]]of this.current)yt.set(e,t);for(let t=gt;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)yt.has(e)||yt.set(e,n)}}schedule(e){if(bt=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(Ct!==null&&t===B&&(He||(z===null||!(z.f&2))&&!ut))return;if(n&96){if(!(n&1024))return;t.f^=C}}this.#l.push(t)}#C(){_t===null?gt=_t=this:(_t.#n=this,this.#t=_t),_t=this}#w(){var e=this.#t,t=this.#n;e===null?gt=t:e.#n=t,t===null?_t=e:t.#t=e,this.linked=!1}};function Ot(e){var t=xt;xt=!0;try{var n;for(e&&(P!==null&&!P.is_fork&&P.flush(),n=e());;){if(Qe(),P===null)return n;P.flush()}}finally{xt=t}}function kt(){try{Ce()}catch(e){et(e,bt)}}var At=null;function jt(e){var t=e.length;if(t!==0){for(var n=0;n<t;){var r=e[n++];if(!(r.f&24576)&&xr(r)&&(At=new Set,Er(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&Zn(r),At?.size>0)){nn.clear();for(let e of At){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)At.has(n)&&(At.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||Er(n)}}At.clear()}}At=null}}function Mt(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?Mt(i,t,n,r):e&4194320&&!(e&2048)&&Nt(i,t,r)&&(nt(i,w),Pt(i))}}function Nt(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(u.call(t,r))return!0;if(r.f&2&&Nt(r,t,n))return n.set(r,!0),!0}return n.set(e,!1),!1}function Pt(e){P.schedule(e)}function Ft(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),nt(e,C);for(var n=e.first;n!==null;)Ft(n,t),n=n.next}}function It(e){nt(e,C);for(var t=e.first;t!==null;)It(t),t=t.next}function Lt(e){let t=0,n=an(0),r;return()=>{Fn()&&(V(n),Hn(()=>(t===0&&(r=Ar(()=>e(()=>un(n)))),t+=1,()=>{Ze(()=>{--t,t===0&&(r?.(),r=void 0,un(n))})})))}}var Rt=D|O;function zt(e,t,n,r){new Bt(e,t,n,r)}var Bt=class{parent;is_pending=!1;transform_error;#e;#t=j?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=Lt(()=>(this.#m=an(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=B;t.b=this,t.f|=128,n(e)},this.parent=B.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=Wn(()=>{if(j){let e=this.#t;Fe();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()},Rt),j&&(this.#e=M)}#g(){try{this.#a=Gn(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed;t&&(this.#s=Gn(()=>{t(this.#e,()=>e,()=>()=>{})}))}#v(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=Gn(()=>e(this.#e)),Ze(()=>{var e=this.#c=document.createDocumentFragment(),t=bn();e.append(t),this.#a=this.#x(()=>Gn(()=>this.#r(t))),this.#u===0&&(this.#e.before(e),this.#c=null,Qn(this.#o,()=>{this.#o=null}),this.#b(P))}))}#y(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=Gn(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();nr(this.#a,e);let t=this.#n.pending;this.#o=Gn(()=>t(this.#e))}else this.#b(P)}catch(e){this.error(e)}}#b(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){at(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=B,n=z,r=We;lr(this.#i),cr(this.#i),Ge(this.#i.ctx);try{return Dt.ensure(),e()}catch(e){return $e(e),null}finally{lr(t),cr(n),Ge(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&&Qn(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,Ze(()=>{this.#d=!1,this.#m&&sn(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),V(this.#m)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;P?.is_fork?(this.#a&&P.skip_effect(this.#a),this.#o&&P.skip_effect(this.#o),this.#s&&P.skip_effect(this.#s),P.on_fork_commit(()=>{this.#C(e)})):this.#C(e)}#C(e){this.#a&&=(Yn(this.#a),null),this.#o&&=(Yn(this.#o),null),this.#s&&=(Yn(this.#s),null),j&&(Pe(this.#t),Ie(),Pe(Le()));var t=this.#n.onerror;let n=this.#n.failed;var r=!1,i=!1;let a=()=>{if(r){Me();return}r=!0,i&&Oe(),this.#s!==null&&Qn(this.#s,()=>{this.#s=null}),this.#x(()=>{this.#y()})},o=e=>{try{i=!0,t?.(e,a),i=!1}catch(e){et(e,this.#i&&this.#i.parent)}n&&(this.#s=this.#x(()=>{try{return Gn(()=>{var t=B;t.b=this,t.f|=128,n(this.#e,()=>e,()=>a)})}catch(e){return et(e,this.#i.parent),null}}))};Ze(()=>{var t;try{t=this.transform_error(e)}catch(e){et(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(o,e=>et(e,this.#i&&this.#i.parent)):o(t)})}};function Vt(e,t,n,r){let i=Je()?Gt:Yt;var a=e.filter(e=>!e.settled);if(n.length===0&&a.length===0){r(t.map(i));return}var o=B,s=Ht(),c=a.length===1?a[0].promise:a.length>1?Promise.all(a.map(e=>e.promise)):null;function l(e){if(!(o.f&16384)){s();try{r(e)}catch(e){et(e,o)}Ut()}}var u=Wt();if(n.length===0){c.then(()=>l(t.map(i))).finally(u);return}function d(){Promise.all(n.map(e=>qt(e))).then(e=>l([...t.map(i),...e])).catch(e=>et(e,o)).finally(u)}c?c.then(()=>{s(),d(),Ut()}):d()}function Ht(){var e=B,t=z,n=We,r=P;return function(i=!0){lr(e),cr(t),Ge(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function Ut(e=!0){lr(null),cr(null),Ge(null),e&&P?.deactivate()}function Wt(){var e=B,t=e.b,n=P,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 Gt(e){var t=2|w;return B!==null&&(B.f|=O),{ctx:We,deps:null,effects:null,equals:ze,f:t,fn:e,reactions:null,rv:0,v:i,wv:0,parent:B,ac:null}}var Kt=Symbol(`obsolete`);function qt(e,t,n){let r=B;r===null&&ve();var a=void 0,o=an(i),s=!z,c=new Set;return Vn(()=>{var t=B,n=x();a=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==he&&n.reject(e)}).finally(Ut)}catch(e){n.reject(e),Ut()}var i=P;if(s){if(t.f&32768)var l=Wt();if(r.b.is_rendered())i.async_deriveds.get(t)?.reject(Kt);else for(let e of c.values())e.reject(Kt);c.add(n),i.async_deriveds.set(t,n)}let u=(e,t=void 0)=>{l?.(),c.delete(n),t!==Kt&&(i.activate(),t?(o.f|=se,sn(o,t)):(o.f&8388608&&(o.f^=se),sn(o,e)),i.deactivate())};n.promise.then(u,e=>u(null,e||`unknown`))}),In(()=>{for(let e of c)e.reject(Kt)}),new Promise(e=>{function t(n){function r(){n===a?e(o):t(a)}n.then(r,r)}t(a)})}function Jt(e){let t=Gt(e);return He||dr(t),t}function Yt(e){let t=Gt(e);return t.equals=Ve,t}function Xt(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n<t.length;n+=1)Yn(t[n])}}function Zt(e){var t,n=B,r=e.parent;if(!ar&&r!==null&&e.v!==i&&r.f&24576)return ke(),e.v;lr(r);try{e.f&=~ie,Xt(e),t=Cr(e)}finally{lr(n)}return t}function Qt(e){var t=Zt(e);if(!e.equals(t)&&(e.wv=br(),(!P?.is_fork||e.deps===null)&&(P===null?e.v=t:(P.capture(e,t,!0),vt?.capture(e,t,!0)),e.deps===null))){nt(e,C);return}ar||(yt===null?rt(e):(Fn()||P?.is_fork)&&yt.set(e,t))}function $t(e){if(e.effects!==null)for(let t of e.effects)(t.teardown||t.ac)&&(t.teardown?.(),t.ac?.abort(he),t.fn!==null&&(t.teardown=y),t.ac=null,Tr(t,0),qn(t))}function en(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&t.fn!==null&&Er(t)}var tn=new Set,nn=new Map,rn=!1;function an(e,t){return{f:0,v:e,reactions:null,equals:ze,rv:0,wv:0}}function F(e,t){let n=an(e,t);return dr(n),n}function on(e,t=!1,n=!0){let r=an(e);return t||(r.equals=Ve),Ue&&n&&We!==null&&We.l!==null&&(We.l.s??=[]).push(r),r}function I(e,t,n=!1){return z!==null&&(!sr||z.f&131072)&&Je()&&z.f&4325394&&(ur===null||!u.call(ur,e))&&De(),sn(e,n?fn(t):t,wt)}function sn(e,t,n=null){if(!e.equals(t)){nn.set(e,ar?t:e.v);var r=Dt.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&&Zt(t),yt===null&&rt(t)}e.wv=br(),dn(e,w,n),Je()&&B!==null&&B.f&1024&&!(B.f&96)&&(mr===null?hr([e]):mr.push(e)),!r.is_fork&&tn.size>0&&!rn&&cn()}return t}function cn(){rn=!1;for(let e of tn){e.f&1024&&nt(e,T);let t;try{t=xr(e)}catch{t=!0}t&&Er(e)}tn.clear()}function ln(e,t=1){var n=V(e),r=t===1?n++:n--;return I(e,n),r}function un(e){I(e,e.v+1)}function dn(e,t,n){var r=e.reactions;if(r!==null)for(var i=Je(),a=r.length,o=0;o<a;o++){var s=r[o],c=s.f;if(!(!i&&s===B)){var l=(c&w)===0;if(l&&nt(s,t),c&131072)tn.add(s);else if(c&2){var u=s;yt?.delete(u),c&65536||(c&512&&(B===null||!(B.f&2097152))&&(s.f|=ie),dn(u,T,n))}else if(l){var d=s;c&16&&At!==null&&At.add(d),n===null?Pt(d):n.push(d)}}}}function fn(e){if(typeof e!=`object`||!e||ce in e)return e;let t=_(e);if(t!==h&&t!==g)return e;var n=new Map,r=c(e),a=F(0),o=null,s=vr,l=e=>{if(vr===s)return e();var t=z,n=vr;cr(null),yr(s);var r=e();return cr(t),yr(n),r};return r&&n.set(`length`,F(e.length,o)),new Proxy(e,{defineProperty(e,t,r){(!(`value`in r)||r.configurable===!1||r.enumerable===!1||r.writable===!1)&&Te();var i=n.get(t);return i===void 0?l(()=>{var e=F(r.value,o);return n.set(t,e),e}):I(i,r.value,!0),!0},deleteProperty(e,t){var r=n.get(t);if(r===void 0){if(t in e){let e=l(()=>F(i,o));n.set(t,e),un(a)}}else I(r,i),un(a);return!0},get(t,r,a){if(r===ce)return e;var s=n.get(r),c=r in t;if(s===void 0&&(!c||p(t,r)?.writable)&&(s=l(()=>F(fn(c?t[r]:i),o)),n.set(r,s)),s!==void 0){var u=V(s);return u===i?void 0:u}return Reflect.get(t,r,a)},getOwnPropertyDescriptor(e,t){var r=Reflect.getOwnPropertyDescriptor(e,t);if(r&&`value`in r){var a=n.get(t);a&&(r.value=V(a))}else if(r===void 0){var o=n.get(t),s=o?.v;if(o!==void 0&&s!==i)return{enumerable:!0,configurable:!0,value:s,writable:!0}}return r},has(e,t){if(t===ce)return!0;var r=n.get(t),a=r!==void 0&&r.v!==i||Reflect.has(e,t);return(r!==void 0||B!==null&&(!a||p(e,t)?.writable))&&(r===void 0&&(r=l(()=>F(a?fn(e[t]):i,o)),n.set(t,r)),V(r)===i)?!1:a},set(e,t,s,c){var u=n.get(t),d=t in e;if(r&&t===`length`)for(var f=s;f<u.v;f+=1){var m=n.get(f+``);m===void 0?f in e&&(m=l(()=>F(i,o)),n.set(f+``,m)):I(m,i)}if(u===void 0)(!d||p(e,t)?.writable)&&(u=l(()=>F(void 0,o)),I(u,fn(s)),n.set(t,u));else{d=u.v!==i;var h=l(()=>fn(s));I(u,h)}var g=Reflect.getOwnPropertyDescriptor(e,t);if(g?.set&&g.set.call(c,s),!d){if(r&&typeof t==`string`){var _=n.get(`length`),v=Number(t);Number.isInteger(v)&&v>=_.v&&I(_,v+1)}un(a)}return!0},ownKeys(e){V(a);var t=Reflect.ownKeys(e).filter(e=>{var t=n.get(e);return t===void 0||t.v!==i});for(var[r,o]of n)o.v!==i&&!(r in e)&&t.push(r);return t},setPrototypeOf(){Ee()}})}function pn(e){try{if(typeof e==`object`&&e&&ce in e)return e[ce]}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=p(t,`firstChild`).get,vn=p(t,`nextSibling`).get,v(e)&&(e[fe]=void 0,e[de]=null,e[pe]=void 0,e.__e=void 0),v(n)&&(n[me]=void 0)}}function bn(e=``){return document.createTextNode(e)}function xn(e){return _n.call(e)}function Sn(e){return vn.call(e)}function L(e,t){if(!j)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),Pe(r),r}return t&&Dn(n),Pe(n),n}function Cn(e,t=!1){if(!j){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),Pe(r),r}Dn(M)}return M}function R(e,t=1,n=!1){let r=j?M:e;for(var i;t--;)i=r,r=Sn(r);if(!j)return r;if(n){if(r?.nodeType!==3){var a=bn();return r===null?i?.after(a):r.before(a),Pe(a),a}Dn(r)}return Pe(r),r}function wn(e){e.textContent=``}function Tn(){return!He||At!==null?!1:(B.f&te)!==0}function En(e,t,n){let r=n?{is:n}:void 0;return document.createElementNS(t??`http://www.w3.org/1999/xhtml`,e,r)}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}var On=!1;function kn(){On||(On=!0,document.addEventListener(`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let t of e.target.elements)t[A]?.()})},{capture:!0}))}function An(e){var t=z,n=B;cr(null),lr(null);try{return e()}finally{cr(t),lr(n)}}function jn(e,t,n,r=n){e.addEventListener(t,()=>An(n));let i=e[A];i?e[A]=()=>{i(),r(!0)}:e[A]=()=>r(!0),kn()}function Mn(e){B===null&&(z===null&&Se(e),xe()),ar&&be(e)}function Nn(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function Pn(e,t){var n=B;n!==null&&n.f&8192&&(e|=E);var r={ctx:We,deps:null,nodes:null,f:e|w|512,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};P?.register_created_effect(r);var i=r;if(e&4)Ct===null?Dt.ensure().schedule(r):Ct.push(r);else if(t!==null){try{Er(r)}catch(e){throw Yn(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|=D))}if(i!==null&&(i.parent=n,n!==null&&Nn(i,n),z!==null&&z.f&2&&!(e&64))){var a=z;(a.effects??=[]).push(i)}return r}function Fn(){return z!==null&&!sr}function In(e){let t=Pn(8,null);return nt(t,C),t.teardown=e,t}function Ln(e){Mn(`$effect`);var t=B.f;if(!z&&t&32&&!(t&32768)){var n=We;(n.e??=[]).push(e)}else return Rn(e)}function Rn(e){return Pn(4|k,e)}function zn(e){Dt.ensure();let t=Pn(64|O,e);return(e={})=>new Promise(n=>{e.outro?Qn(t,()=>{Yn(t),n(void 0)}):(Yn(t),n(void 0))})}function Bn(e){return Pn(4,e)}function Vn(e){return Pn(oe|O,e)}function Hn(e,t=0){return Pn(8|t,e)}function Un(e,t=[],n=[],r=[]){Vt(r,t,n,t=>{Pn(8,()=>e(...t.map(V)))})}function Wn(e,t=0){return Pn(16|t,e)}function Gn(e){return Pn(32|O,e)}function Kn(e){var t=e.teardown;if(t!==null){let e=ar,n=z;or(!0),cr(null);try{t.call(null)}finally{or(e),cr(n)}}}function qn(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&An(()=>{e.abort(he)});var r=n.next;n.f&64?n.parent=null:Yn(n,t),n=r}}function Jn(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||Yn(t),t=n}}function Yn(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(Xn(e.nodes.start,e.nodes.end),n=!0),nt(e,ne),qn(e,t&&!n),Tr(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();Kn(e),e.f^=ne,e.f|=ee;var i=e.parent;i!==null&&i.first!==null&&Zn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function Xn(e,t){for(;e!==null;){var n=e===t?null:Sn(e);e.remove(),e=n}}function Zn(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 Qn(e,t,n=!0){var r=[];$n(e,r,!0);var i=()=>{n&&Yn(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function $n(e,t,n){if(!(e.f&8192)){e.f^=E;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;$n(i,t,o?n:!1)}i=a}}}function er(e){tr(e,!0)}function tr(e,t){if(e.f&8192){e.f^=E,e.f&1024||(nt(e,w),Dt.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=(n.f&65536)!=0||(n.f&32)!=0;tr(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 nr(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 rr=null,ir=!1,ar=!1;function or(e){ar=e}var z=null,sr=!1;function cr(e){z=e}var B=null;function lr(e){B=e}var ur=null;function dr(e){z!==null&&(!He||z.f&2)&&(ur===null?ur=[e]:ur.push(e))}var fr=null,pr=0,mr=null;function hr(e){mr=e}var gr=1,_r=0,vr=_r;function yr(e){vr=e}function br(){return++gr}function xr(e){var t=e.f;if(t&2048)return!0;if(t&2&&(e.f&=~ie),t&4096){for(var n=e.deps,r=n.length,i=0;i<r;i++){var a=n[i];if(xr(a)&&Qt(a),a.wv>e.wv)return!0}t&512&&yt===null&&nt(e,C)}return!1}function Sr(e,t,n=!0){var r=e.reactions;if(r!==null&&!(!He&&ur!==null&&u.call(ur,e)))for(var i=0;i<r.length;i++){var a=r[i];a.f&2?Sr(a,t,!1):t===a&&(n?nt(a,w):a.f&1024&&nt(a,T),Pt(a))}}function Cr(e){var t=fr,n=pr,r=mr,i=z,a=ur,o=We,s=sr,c=vr,l=e.f;fr=null,pr=0,mr=null,z=l&96?null:e,ur=null,Ge(e.ctx),sr=!1,vr=++_r,e.ac!==null&&(An(()=>{e.ac.abort(he)}),e.ac=null);try{e.f|=ae;var u=e.fn,d=u();e.f|=te;var f=e.deps,p=P?.is_fork;if(fr!==null){var m;if(p||Tr(e,pr),f!==null&&pr>0)for(f.length=pr+fr.length,m=0;m<fr.length;m++)f[pr+m]=fr[m];else e.deps=f=fr;if(Fn()&&e.f&512)for(m=pr;m<f.length;m++)(f[m].reactions??=[]).push(e)}else !p&&f!==null&&pr<f.length&&(Tr(e,pr),f.length=pr);if(Je()&&mr!==null&&!sr&&f!==null&&!(e.f&6146))for(m=0;m<mr.length;m++)Sr(mr[m],e);if(i!==null&&i!==e){if(_r++,i.deps!==null)for(let e=0;e<n;e+=1)i.deps[e].rv=_r;if(t!==null)for(let e of t)e.rv=_r;mr!==null&&(r===null?r=mr:r.push(...mr))}return e.f&8388608&&(e.f^=se),d}catch(e){return $e(e)}finally{e.f^=ae,fr=t,pr=n,mr=r,z=i,ur=a,Ge(o),sr=s,vr=c}}function wr(e,t){let n=t.reactions;if(n!==null){var r=l.call(n,e);if(r!==-1){var a=n.length-1;a===0?n=t.reactions=null:(n[r]=n[a],n.pop())}}if(n===null&&t.f&2&&(fr===null||!u.call(fr,t))){var o=t;o.f&512&&(o.f^=512,o.f&=~ie),o.v!==i&&rt(o),$t(o),Tr(o,0)}}function Tr(e,t){var n=e.deps;if(n!==null)for(var r=t;r<n.length;r++)wr(e,n[r])}function Er(e){var t=e.f;if(!(t&16384)){nt(e,C);var n=B,r=ir;B=e,ir=!0;try{t&16777232?Jn(e):qn(e),Kn(e);var i=Cr(e);e.teardown=typeof i==`function`?i:null,e.wv=gr}finally{ir=r,B=n}}}async function Dr(){if(He)return new Promise(e=>{requestAnimationFrame(()=>e()),setTimeout(()=>e())});await Promise.resolve(),Ot()}function V(e){var t=(e.f&2)!=0;if(rr?.add(e),z!==null&&!sr&&!(B!==null&&B.f&16384)&&(ur===null||!u.call(ur,e))){var n=z.deps;if(z.f&2097152)e.rv<_r&&(e.rv=_r,fr===null&&n!==null&&n[pr]===e?pr++:fr===null?fr=[e]:fr.push(e));else{z.deps??=[],u.call(z.deps,e)||z.deps.push(e);var r=e.reactions;r===null?e.reactions=[z]:u.call(r,z)||r.push(z)}}if(ar&&nn.has(e))return nn.get(e);if(t){var i=e;if(ar){var a=i.v;return(!(i.f&1024)&&i.reactions!==null||kr(i))&&(a=Zt(i)),nn.set(i,a),a}var o=(i.f&512)==0&&!sr&&z!==null&&(ir||(z.f&512)!=0),s=(i.f&te)===0;xr(i)&&(o&&(i.f|=512),Qt(i)),o&&!s&&(en(i),Or(i))}if(yt?.has(e))return yt.get(e);if(e.f&8388608)throw e.v;return e.v}function Or(e){if(e.f|=512,e.deps!==null)for(let t of e.deps)(t.reactions??=[]).push(e),t.f&2&&!(t.f&512)&&(en(t),Or(t))}function kr(e){if(e.v===i)return!0;if(e.deps===null)return!1;for(let t of e.deps)if(nn.has(t)||t.f&2&&kr(t))return!0;return!1}function Ar(e){var t=sr;try{return sr=!0,e()}finally{sr=t}}var jr=Symbol(`events`),Mr=new Set,Nr=new Set;function Pr(e,t,n,r={}){function i(e){if(r.capture||Rr.call(t,e),!e.cancelBubble)return An(()=>n?.call(this,e))}return e.startsWith(`pointer`)||e.startsWith(`touch`)||e===`wheel`?Ze(()=>{t.addEventListener(e,i,r)}):t.addEventListener(e,i,r),i}function Fr(e,t,n,r,i){var a={capture:r,passive:i},o=Pr(e,t,n,a);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&In(()=>{t.removeEventListener(e,o,a)})}function H(e,t,n){(t[jr]??={})[e]=n}function Ir(e){for(var t=0;t<e.length;t++)Mr.add(e[t]);for(var n of Nr)n(e)}var Lr=null;function Rr(e){var t=this,n=t.ownerDocument,r=e.type,i=e.composedPath?.()||[],a=i[0]||e.target;Lr=e;var o=0,s=Lr===e&&e[jr];if(s){var c=i.indexOf(s);if(c!==-1&&(t===document||t===window)){e[jr]=t;return}var l=i.indexOf(t);if(l===-1)return;c<=l&&(o=c)}if(a=i[o]||e.target,a!==t){f(e,`currentTarget`,{configurable:!0,get(){return a||n}});var u=z,d=B;cr(null),lr(null);try{for(var p,m=[];a!==null;){var h=a.assignedSlot||a.parentNode||a.host||null;try{var g=a[jr]?.[r];g!=null&&(!a.disabled||e.target===a)&&g.call(a,e)}catch(e){p?m.push(e):p=e}if(e.cancelBubble||h===t||h===null)break;a=h}if(p){for(let e of m)queueMicrotask(()=>{throw e});throw p}}finally{e[jr]=t,delete e.currentTarget,cr(u),lr(d)}}}var zr=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function Br(e){return zr?.createHTML(e)??e}function Vr(e){var t=En(`template`);return t.innerHTML=Br(e.replaceAll(`<!>`,`<!---->`)),t.content}function Hr(e,t){var n=B;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function U(e,t){var n=(t&1)!=0,r=(t&2)!=0,i,a=!e.startsWith(`<!>`);return()=>{if(j)return Hr(M,null),M;i===void 0&&(i=Vr(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;Hr(o,s)}else Hr(t,t);return t}}function Ur(){if(j)return Hr(M,null),M;var e=document.createDocumentFragment(),t=document.createComment(``),n=bn();return e.append(t,n),Hr(t,n),e}function W(e,t){if(j){var n=B;(!(n.f&32768)||n.nodes.end===null)&&(n.nodes.end=M),Fe();return}e!==null&&e.before(t)}[...`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(`.`)];var Wr=[`touchstart`,`touchmove`];function Gr(e){return Wr.includes(e)}function Kr(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e[me]??=e.nodeValue)&&(e[me]=n,e.nodeValue=`${n}`)}function qr(e,t){return Yr(e,t)}var Jr=new Map;function Yr(e,{target:t,anchor:n,props:i={},events:a,context:o,intro:s=!0,transformError:c}){yn();var l=void 0,u=zn(()=>{var s=n??t.appendChild(bn());zt(s,{pending:()=>{}},t=>{Ke({});var n=We;if(o&&(n.c=o),a&&(i.$$events=a),j&&Hr(t,null),l=e(t,i)||{},j&&(B.nodes.end=M,M===null||M.nodeType!==8||M.data!==`]`))throw Ae(),r;qe()},c);var u=new Set,f=e=>{for(var n=0;n<e.length;n++){var r=e[n];if(!u.has(r)){u.add(r);var i=Gr(r);for(let e of[t,document]){var a=Jr.get(e);a===void 0&&(a=new Map,Jr.set(e,a));var o=a.get(r);o===void 0?(e.addEventListener(r,Rr,{passive:i}),a.set(r,1)):a.set(r,o+1)}}}};return f(d(Mr)),Nr.add(f),()=>{for(var e of u)for(let n of[t,document]){var r=Jr.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,Rr),r.delete(e),r.size===0&&Jr.delete(n)):r.set(e,i)}Nr.delete(f),s!==n&&s.parentNode?.removeChild(s)}});return Xr.set(l,u),l}var Xr=new WeakMap,Zr=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)er(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(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&&(Yn(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();nr(r,t),t.append(bn()),this.#n.set(e,{effect:r,fragment:t})}else Yn(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),Qn(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)||(Yn(n.effect),this.#n.delete(e))};ensure(e,t){var n=P,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:Gn(()=>t(a)),fragment:i})}else this.#t.set(e,Gn(()=>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 j&&(this.anchor=M),this.#a(n)}};function Qr(e){We===null&&_e(`onMount`),Ue&&We.l!==null?ei(We).m.push(e):Ln(()=>{let t=Ar(e);if(typeof t==`function`)return t})}function $r(e){We===null&&_e(`onDestroy`),Qr(()=>()=>Ar(e))}function ei(e){var t=e.l;return t.u??={a:[],b:[],m:[]}}function ti(e,t,n=!1){var r;j&&(r=M,Fe());var i=new Zr(e),a=n?D:0;function o(e,t){if(j){var n=Re(r);if(e!==parseInt(n.substring(1))){var a=Le();Pe(a),i.anchor=a,Ne(!1),i.ensure(e,t),Ne(!0);return}}i.ensure(e,t)}Wn(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}function ni(e,t,n){for(var r=[],i=t.length,a,o=t.length,s=0;s<i;s++){let n=t[s];Qn(n,()=>{if(a){if(a.pending.delete(n),a.done.add(n),a.pending.size===0){var t=e.outrogroups;ri(e,d(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()}ri(e,t,!c)}else a={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(a)}function ri(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|=re,nr(a,document.createDocumentFragment())):Yn(t[i],n)}}var ii;function ai(e,t,n,r,i,a=null){var o=e,s=new Map;if(t&4){var l=e;o=j?Pe(xn(l)):l.appendChild(bn())}j&&Fe();var u=null,f=Yt(()=>{var e=n();return c(e)?e:e==null?[]:d(e)}),p,m=new Map,h=!0;function g(e){v.effect.f&16384||(v.pending.delete(e),v.fallback=u,si(v,p,o,t,r),u!==null&&(p.length===0?u.f&33554432?(u.f^=re,li(u,null,o)):er(u):Qn(u,()=>{u=null})))}function _(e){v.pending.delete(e)}var v={effect:Wn(()=>{p=V(f);var e=p.length;let c=!1;j&&Re(o)===`[!`!=(e===0)&&(o=Le(),Pe(o),Ne(!1),c=!0);for(var l=new Set,d=P,v=Tn(),y=0;y<e;y+=1){j&&M.nodeType===8&&M.data===`]`&&(o=M,c=!0,Ne(!1));var b=p[y],x=r(b,y),S=h?null:s.get(x);S?(S.v&&sn(S.v,b),S.i&&sn(S.i,y),v&&d.unskip_effect(S.e)):(S=ci(s,h?o:ii??=bn(),b,x,y,i,t,n),h||(S.e.f|=re),s.set(x,S)),l.add(x)}if(e===0&&a&&!u&&(h?u=Gn(()=>a(o)):(u=Gn(()=>a(ii??=bn())),u.f|=re)),e>l.size&&ye(``,``,``),j&&e>0&&Pe(Le()),!h)if(m.set(d,l),v){for(let[e,t]of s)l.has(e)||d.skip_effect(t.e);d.oncommit(g),d.ondiscard(_)}else g(d);c&&Ne(!0),V(f)}),flags:t,items:s,pending:m,outrogroups:null,fallback:u};h=!1,j&&(o=M)}function oi(e){for(;e!==null&&!(e.f&32);)e=e.next;return e}function si(e,t,n,r,i){var a=(r&8)!=0,o=t.length,s=e.items,c=oi(e.effect.first),l,u=null,f,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(),(f??=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&&(er(_),a&&(_.nodes?.a?.unfix(),(f??=new Set).delete(_))),_.f&33554432)if(_.f^=re,_===c)li(_,null,n);else{var y=u?u.next:c;_===e.effect.last&&(e.effect.last=_.prev),_.prev&&(_.prev.next=_.next),_.next&&(_.next.prev=_.prev),ui(e,u,_),ui(e,_,y),li(_,y,n),u=_,p=[],m=[],c=oi(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)li(p[x],b,n);for(x=0;x<m.length;x+=1)l.delete(m[x]);ui(e,S.prev,C.next),ui(e,u,S),ui(e,C,b),c=b,u=C,--v,p=[],m=[]}else l.delete(_),li(_,c,n),ui(e,_.prev,_.next),ui(e,_,u===null?e.effect.first:u.next),ui(e,u,_),u=_;continue}for(p=[],m=[];c!==null&&c!==_;)(l??=new Set).add(c),m.push(c),c=oi(c.next);if(c===null)continue}_.f&33554432||p.push(_),u=_,c=oi(_.next)}if(e.outrogroups!==null){for(let t of e.outrogroups)t.pending.size===0&&(ri(e,d(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=oi(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()}ni(e,w,E)}}a&&Ze(()=>{if(f!==void 0)for(_ of f)_.nodes?.a?.apply()})}function ci(e,t,n,r,i,a,o,s){var c=o&1?o&16?an(n):on(n,!1,!1):null,l=o&2?an(i):null;return{v:c,i:l,e:Gn(()=>(a(t,c??n,l??i,s),()=>{e.delete(r)}))}}function li(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 ui(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function di(e,t,n=!1,i=!1,a=!1,c=!1){var l=e,u=``;if(n){var d=e;j&&(l=Pe(xn(d)))}Un(()=>{var e=B;if(u===(u=t()??``)){j&&Fe();return}if(n&&!j){e.nodes=null,d.innerHTML=u,u!==``&&Hr(xn(d),d.lastChild);return}if(e.nodes!==null&&(Xn(e.nodes.start,e.nodes.end),e.nodes=null),u!==``){if(j){for(var c=M.data,f=Fe(),p=f;f!==null&&(f.nodeType!==8||f.data!==``);)p=f,f=Sn(f);if(f===null)throw Ae(),r;Hr(M,p),l=Pe(f);return}var m=En(i?`svg`:a?`math`:`template`,i?o:a?s:void 0);m.innerHTML=u;var h=i||a?m:m.content;if(Hr(xn(h),h.lastChild),i||a)for(;xn(h);)l.before(xn(h));else l.before(h)}})}var fi=[...`
|
|
2
|
+
\r\f\xA0\v`];function pi(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||fi.includes(r[o-1]))&&(s===r.length||fi.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function mi(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 hi(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function gi(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(hi)),i&&c.push(...Object.keys(i).map(hi));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=hi(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+=mi(r)),i&&(n+=mi(i,!0)),n=n.trim(),n===``?null:n}return e==null?null:String(e)}function _i(e,t,n,r,i,a){var o=e[fe];if(j||o!==n||o===void 0){var s=pi(n,r,a);(!j||s!==e.getAttribute(`class`))&&(s==null?e.removeAttribute(`class`):t?e.className=s:e.setAttribute(`class`,s)),e[fe]=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 vi(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 yi(e,t,n,r){var i=e[pe];if(j||i!==t){var a=gi(t,r);(!j||a!==e.getAttribute(`style`))&&(a==null?e.removeAttribute(`style`):e.style.cssText=a),e[pe]=t}else r&&(Array.isArray(r)?(vi(e,n?.[0],r[0]),vi(e,n?.[1],r[1],`important`)):vi(e,n,r));return r}function bi(e,t,n=!1){if(e.multiple){if(t==null)return;if(!c(t))return je();for(var r of e.options)r.selected=t.includes(Ci(r));return}for(r of e.options)if(mn(Ci(r),t)){r.selected=!0;return}(!n||t!==void 0)&&(e.selectedIndex=-1)}function xi(e){var t=new MutationObserver(()=>{bi(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`]}),In(()=>{t.disconnect()})}function Si(e,t,n=t){var r=new WeakSet,i=!0;jn(e,`change`,t=>{var i=t?`[selected]`:`:checked`,a;if(e.multiple)a=[].map.call(e.querySelectorAll(i),Ci);else{var o=e.querySelector(i)??e.querySelector(`option:not([disabled])`);a=o&&Ci(o)}n(a),e.__value=a,P!==null&&r.add(P)}),Bn(()=>{var a=t();if(e===document.activeElement){var o=He?vt:P;if(r.has(o))return}if(bi(e,a,i),i&&a===void 0){var s=e.querySelector(`:checked`);s!==null&&(a=Ci(s),n(a))}e.__value=a,i=!1}),xi(e)}function Ci(e){return`__value`in e?e.__value:e.value}var wi=Symbol(`is custom element`),Ti=Symbol(`is html`),Ei=ge?`link`:`LINK`,Di=ge?`progress`:`PROGRESS`;function Oi(e){if(j){var t=!1,n=()=>{if(!t){if(t=!0,e.hasAttribute(`value`)){var n=e.value;ji(e,`value`,null),e.value=n}if(e.hasAttribute(`checked`)){var r=e.checked;ji(e,`checked`,null),e.checked=r}}};e[A]=n,Ze(n),kn()}}function ki(e,t){var n=Mi(e);n.value===(n.value=t??void 0)||e.value===t&&(t!==0||e.nodeName!==Di)||(e.value=t??``)}function Ai(e,t){var n=Mi(e);n.checked!==(n.checked=t??void 0)&&(e.checked=t)}function ji(e,t,n,r){var i=Mi(e);j&&(i[t]=e.getAttribute(t),t===`src`||t===`srcset`||t===`href`&&e.nodeName===Ei)||i[t]!==(i[t]=n)&&(t===`loading`&&(e[ue]=n),n==null?e.removeAttribute(t):typeof n!=`string`&&Pi(e).includes(t)?e[t]=n:e.setAttribute(t,n))}function Mi(e){return e[de]??={[wi]:e.nodeName.includes(`-`),[Ti]:e.namespaceURI===a}}var Ni=new Map;function Pi(e){var t=e.getAttribute(`is`)||e.nodeName,n=Ni.get(t);if(n)return n;Ni.set(t,n=[]);for(var r,i=e,a=Element.prototype;a!==i;){for(var o in r=m(i),r)r[o].set&&o!==`innerHTML`&&o!==`textContent`&&o!==`innerText`&&n.push(o);i=_(i)}return n}function Fi(e,t,n=t){var r=new WeakSet;jn(e,`input`,async i=>{var a=i?e.defaultValue:e.value;if(a=Ii(e)?Li(a):a,n(a),P!==null&&r.add(P),await Dr(),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))}}}),(j&&e.defaultValue!==e.value||Ar(t)==null&&e.value)&&(n(Ii(e)?Li(e.value):e.value),P!==null&&r.add(P)),Hn(()=>{var n=t();if(e===document.activeElement){var i=He?vt:P;if(r.has(i))return}Ii(e)&&n===Li(e.value)||e.type===`date`&&!n&&!e.value||n!==e.value&&(e.value=n??``)})}function Ii(e){var t=e.type;return t===`number`||t===`range`}function Li(e){return e===``?null:+e}function Ri(e,t){return e===t||e?.[ce]===t}function zi(e={},t,n,r){var i=We.r,a=B;return Bn(()=>{var o,s;return Hn(()=>{o=s,s=r?.()||[],Ar(()=>{Ri(n(...s),e)||(t(e,...s),o&&Ri(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&&Ri(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c?.()}}}),e}function Bi(e,t,n,r){var i=!Ue||(n&2)!=0,a=(n&8)!=0,o=(n&16)!=0,s=r,c=!0,l=void 0,u=()=>o&&i?(l??=Gt(r),V(l)):(c&&(c=!1,s=o?Ar(r):r),s);let d;if(a){var f=ce in e||le in e;d=p(e,t)?.set??(f&&t in e?n=>e[t]=n:void 0)}var m,h=!1;a?[m,h]=ht(()=>e[t]):m=e[t],m===void 0&&r!==void 0&&(m=u(),d&&(i&&we(t),d(m)));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?Gt:Yt)(()=>(v=!1,g()));a&&V(y);var b=B;return(function(e,t){if(arguments.length>0){let n=t?V(y):i&&a?fn(e):e;return I(y,n),v=!0,s!==void 0&&(s=n),e}return ar&&v||b.f&16384?y.v:V(y)})}function Vi(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Hi(e){if(Array.isArray(e))return e}function Ui(e){if(Array.isArray(e))return Vi(e)}function Wi(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Gi(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,na(r.key),r)}}function Ki(e,t,n){return t&&Gi(e.prototype,t),n&&Gi(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function qi(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=ia(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
3
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function G(e,t,n){return(t=na(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ji(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function Yi(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Xi(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
4
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Zi(){throw TypeError(`Invalid attempt to spread non-iterable instance.
|
|
5
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Qi(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function K(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Qi(Object(n),!0).forEach(function(t){G(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Qi(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function $i(e,t){return Hi(e)||Yi(e,t)||ia(e,t)||Xi()}function ea(e){return Ui(e)||Ji(e)||ia(e)||Zi()}function ta(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function na(e){var t=ta(e,`string`);return typeof t==`symbol`?t:t+``}function ra(e){"@babel/helpers - typeof";return ra=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},ra(e)}function ia(e,t){if(e){if(typeof e==`string`)return Vi(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Vi(e,t):void 0}}var aa=function(){},oa={},sa={},ca=null,la={mark:aa,measure:aa};try{typeof window<`u`&&(oa=window),typeof document<`u`&&(sa=document),typeof MutationObserver<`u`&&(ca=MutationObserver),typeof performance<`u`&&(la=performance)}catch{}var ua=(oa.navigator||{}).userAgent,da=ua===void 0?``:ua,fa=oa,pa=sa,ma=ca,ha=la;fa.document;var ga=!!pa.documentElement&&!!pa.head&&typeof pa.addEventListener==`function`&&typeof pa.createElement==`function`,_a=~da.indexOf(`MSIE`)||~da.indexOf(`Trident/`),va,ya=/fa(k|kd|s|r|l|t|d|dr|dl|dt|b|slr|slpr|wsb|tl|ns|nds|es|gt|jr|jfr|jdr|usb|ufsb|udsb|cr|ss|sr|sl|st|sds|sdr|sdl|sdt)?[\-\ ]/,ba=/Font ?Awesome ?([567 ]*)(Solid|Regular|Light|Thin|Duotone|Brands|Free|Pro|Sharp Duotone|Sharp|Kit|Notdog Duo|Notdog|Chisel|Etch|Graphite|Thumbprint|Jelly Fill|Jelly Duo|Jelly|Utility|Utility Fill|Utility Duo|Slab Press|Slab|Whiteboard)?.*/i,xa={classic:{fa:`solid`,fas:`solid`,"fa-solid":`solid`,far:`regular`,"fa-regular":`regular`,fal:`light`,"fa-light":`light`,fat:`thin`,"fa-thin":`thin`,fab:`brands`,"fa-brands":`brands`},duotone:{fa:`solid`,fad:`solid`,"fa-solid":`solid`,"fa-duotone":`solid`,fadr:`regular`,"fa-regular":`regular`,fadl:`light`,"fa-light":`light`,fadt:`thin`,"fa-thin":`thin`},sharp:{fa:`solid`,fass:`solid`,"fa-solid":`solid`,fasr:`regular`,"fa-regular":`regular`,fasl:`light`,"fa-light":`light`,fast:`thin`,"fa-thin":`thin`},"sharp-duotone":{fa:`solid`,fasds:`solid`,"fa-solid":`solid`,fasdr:`regular`,"fa-regular":`regular`,fasdl:`light`,"fa-light":`light`,fasdt:`thin`,"fa-thin":`thin`},slab:{"fa-regular":`regular`,faslr:`regular`},"slab-press":{"fa-regular":`regular`,faslpr:`regular`},thumbprint:{"fa-light":`light`,fatl:`light`},whiteboard:{"fa-semibold":`semibold`,fawsb:`semibold`},notdog:{"fa-solid":`solid`,fans:`solid`},"notdog-duo":{"fa-solid":`solid`,fands:`solid`},etch:{"fa-solid":`solid`,faes:`solid`},graphite:{"fa-thin":`thin`,fagt:`thin`},jelly:{"fa-regular":`regular`,fajr:`regular`},"jelly-fill":{"fa-regular":`regular`,fajfr:`regular`},"jelly-duo":{"fa-regular":`regular`,fajdr:`regular`},chisel:{"fa-regular":`regular`,facr:`regular`},utility:{"fa-semibold":`semibold`,fausb:`semibold`},"utility-duo":{"fa-semibold":`semibold`,faudsb:`semibold`},"utility-fill":{"fa-semibold":`semibold`,faufsb:`semibold`}},Sa={GROUP:`duotone-group`,SWAP_OPACITY:`swap-opacity`,PRIMARY:`primary`,SECONDARY:`secondary`},Ca=[`fa-classic`,`fa-duotone`,`fa-sharp`,`fa-sharp-duotone`,`fa-thumbprint`,`fa-whiteboard`,`fa-notdog`,`fa-notdog-duo`,`fa-chisel`,`fa-etch`,`fa-graphite`,`fa-jelly`,`fa-jelly-fill`,`fa-jelly-duo`,`fa-slab`,`fa-slab-press`,`fa-utility`,`fa-utility-duo`,`fa-utility-fill`],wa=`classic`,Ta=`duotone`,Ea=`sharp`,Da=`sharp-duotone`,Oa=`chisel`,ka=`etch`,Aa=`graphite`,ja=`jelly`,Ma=`jelly-duo`,Na=`jelly-fill`,Pa=`notdog`,Fa=`notdog-duo`,Ia=`slab`,La=`slab-press`,Ra=`thumbprint`,za=`utility`,Ba=`utility-duo`,Va=`utility-fill`,Ha=`whiteboard`,Ua=`Classic`,Wa=`Duotone`,Ga=`Sharp`,Ka=`Sharp Duotone`,qa=`Chisel`,Ja=`Etch`,Ya=`Graphite`,Xa=`Jelly`,Za=`Jelly Duo`,Qa=`Jelly Fill`,$a=`Notdog`,eo=`Notdog Duo`,to=`Slab`,no=`Slab Press`,ro=`Thumbprint`,io=`Utility`,ao=`Utility Duo`,oo=`Utility Fill`,so=`Whiteboard`,co=[wa,Ta,Ea,Da,Oa,ka,Aa,ja,Ma,Na,Pa,Fa,Ia,La,Ra,za,Ba,Va,Ha];va={},G(G(G(G(G(G(G(G(G(G(va,wa,Ua),Ta,Wa),Ea,Ga),Da,Ka),Oa,qa),ka,Ja),Aa,Ya),ja,Xa),Ma,Za),Na,Qa),G(G(G(G(G(G(G(G(G(va,Pa,$a),Fa,eo),Ia,to),La,no),Ra,ro),za,io),Ba,ao),Va,oo),Ha,so);var lo={classic:{900:`fas`,400:`far`,normal:`far`,300:`fal`,100:`fat`},duotone:{900:`fad`,400:`fadr`,300:`fadl`,100:`fadt`},sharp:{900:`fass`,400:`fasr`,300:`fasl`,100:`fast`},"sharp-duotone":{900:`fasds`,400:`fasdr`,300:`fasdl`,100:`fasdt`},slab:{400:`faslr`},"slab-press":{400:`faslpr`},whiteboard:{600:`fawsb`},thumbprint:{300:`fatl`},notdog:{900:`fans`},"notdog-duo":{900:`fands`},etch:{900:`faes`},graphite:{100:`fagt`},chisel:{400:`facr`},jelly:{400:`fajr`},"jelly-fill":{400:`fajfr`},"jelly-duo":{400:`fajdr`},utility:{600:`fausb`},"utility-duo":{600:`faudsb`},"utility-fill":{600:`faufsb`}},uo={"Font Awesome 7 Free":{900:`fas`,400:`far`},"Font Awesome 7 Pro":{900:`fas`,400:`far`,normal:`far`,300:`fal`,100:`fat`},"Font Awesome 7 Brands":{400:`fab`,normal:`fab`},"Font Awesome 7 Duotone":{900:`fad`,400:`fadr`,normal:`fadr`,300:`fadl`,100:`fadt`},"Font Awesome 7 Sharp":{900:`fass`,400:`fasr`,normal:`fasr`,300:`fasl`,100:`fast`},"Font Awesome 7 Sharp Duotone":{900:`fasds`,400:`fasdr`,normal:`fasdr`,300:`fasdl`,100:`fasdt`},"Font Awesome 7 Jelly":{400:`fajr`,normal:`fajr`},"Font Awesome 7 Jelly Fill":{400:`fajfr`,normal:`fajfr`},"Font Awesome 7 Jelly Duo":{400:`fajdr`,normal:`fajdr`},"Font Awesome 7 Slab":{400:`faslr`,normal:`faslr`},"Font Awesome 7 Slab Press":{400:`faslpr`,normal:`faslpr`},"Font Awesome 7 Thumbprint":{300:`fatl`,normal:`fatl`},"Font Awesome 7 Notdog":{900:`fans`,normal:`fans`},"Font Awesome 7 Notdog Duo":{900:`fands`,normal:`fands`},"Font Awesome 7 Etch":{900:`faes`,normal:`faes`},"Font Awesome 7 Graphite":{100:`fagt`,normal:`fagt`},"Font Awesome 7 Chisel":{400:`facr`,normal:`facr`},"Font Awesome 7 Whiteboard":{600:`fawsb`,normal:`fawsb`},"Font Awesome 7 Utility":{600:`fausb`,normal:`fausb`},"Font Awesome 7 Utility Duo":{600:`faudsb`,normal:`faudsb`},"Font Awesome 7 Utility Fill":{600:`faufsb`,normal:`faufsb`}},fo=new Map([[`classic`,{defaultShortPrefixId:`fas`,defaultStyleId:`solid`,styleIds:[`solid`,`regular`,`light`,`thin`,`brands`],futureStyleIds:[],defaultFontWeight:900}],[`duotone`,{defaultShortPrefixId:`fad`,defaultStyleId:`solid`,styleIds:[`solid`,`regular`,`light`,`thin`],futureStyleIds:[],defaultFontWeight:900}],[`sharp`,{defaultShortPrefixId:`fass`,defaultStyleId:`solid`,styleIds:[`solid`,`regular`,`light`,`thin`],futureStyleIds:[],defaultFontWeight:900}],[`sharp-duotone`,{defaultShortPrefixId:`fasds`,defaultStyleId:`solid`,styleIds:[`solid`,`regular`,`light`,`thin`],futureStyleIds:[],defaultFontWeight:900}],[`chisel`,{defaultShortPrefixId:`facr`,defaultStyleId:`regular`,styleIds:[`regular`],futureStyleIds:[],defaultFontWeight:400}],[`etch`,{defaultShortPrefixId:`faes`,defaultStyleId:`solid`,styleIds:[`solid`],futureStyleIds:[],defaultFontWeight:900}],[`graphite`,{defaultShortPrefixId:`fagt`,defaultStyleId:`thin`,styleIds:[`thin`],futureStyleIds:[],defaultFontWeight:100}],[`jelly`,{defaultShortPrefixId:`fajr`,defaultStyleId:`regular`,styleIds:[`regular`],futureStyleIds:[],defaultFontWeight:400}],[`jelly-duo`,{defaultShortPrefixId:`fajdr`,defaultStyleId:`regular`,styleIds:[`regular`],futureStyleIds:[],defaultFontWeight:400}],[`jelly-fill`,{defaultShortPrefixId:`fajfr`,defaultStyleId:`regular`,styleIds:[`regular`],futureStyleIds:[],defaultFontWeight:400}],[`notdog`,{defaultShortPrefixId:`fans`,defaultStyleId:`solid`,styleIds:[`solid`],futureStyleIds:[],defaultFontWeight:900}],[`notdog-duo`,{defaultShortPrefixId:`fands`,defaultStyleId:`solid`,styleIds:[`solid`],futureStyleIds:[],defaultFontWeight:900}],[`slab`,{defaultShortPrefixId:`faslr`,defaultStyleId:`regular`,styleIds:[`regular`],futureStyleIds:[],defaultFontWeight:400}],[`slab-press`,{defaultShortPrefixId:`faslpr`,defaultStyleId:`regular`,styleIds:[`regular`],futureStyleIds:[],defaultFontWeight:400}],[`thumbprint`,{defaultShortPrefixId:`fatl`,defaultStyleId:`light`,styleIds:[`light`],futureStyleIds:[],defaultFontWeight:300}],[`utility`,{defaultShortPrefixId:`fausb`,defaultStyleId:`semibold`,styleIds:[`semibold`],futureStyleIds:[],defaultFontWeight:600}],[`utility-duo`,{defaultShortPrefixId:`faudsb`,defaultStyleId:`semibold`,styleIds:[`semibold`],futureStyleIds:[],defaultFontWeight:600}],[`utility-fill`,{defaultShortPrefixId:`faufsb`,defaultStyleId:`semibold`,styleIds:[`semibold`],futureStyleIds:[],defaultFontWeight:600}],[`whiteboard`,{defaultShortPrefixId:`fawsb`,defaultStyleId:`semibold`,styleIds:[`semibold`],futureStyleIds:[],defaultFontWeight:600}]]),po={chisel:{regular:`facr`},classic:{brands:`fab`,light:`fal`,regular:`far`,solid:`fas`,thin:`fat`},duotone:{light:`fadl`,regular:`fadr`,solid:`fad`,thin:`fadt`},etch:{solid:`faes`},graphite:{thin:`fagt`},jelly:{regular:`fajr`},"jelly-duo":{regular:`fajdr`},"jelly-fill":{regular:`fajfr`},notdog:{solid:`fans`},"notdog-duo":{solid:`fands`},sharp:{light:`fasl`,regular:`fasr`,solid:`fass`,thin:`fast`},"sharp-duotone":{light:`fasdl`,regular:`fasdr`,solid:`fasds`,thin:`fasdt`},slab:{regular:`faslr`},"slab-press":{regular:`faslpr`},thumbprint:{light:`fatl`},utility:{semibold:`fausb`},"utility-duo":{semibold:`faudsb`},"utility-fill":{semibold:`faufsb`},whiteboard:{semibold:`fawsb`}},mo=[`fak`,`fa-kit`,`fakd`,`fa-kit-duotone`],ho={kit:{fak:`kit`,"fa-kit":`kit`},"kit-duotone":{fakd:`kit-duotone`,"fa-kit-duotone":`kit-duotone`}},go=[`kit`];G(G({},`kit`,`Kit`),`kit-duotone`,`Kit Duotone`);var _o={kit:{"fa-kit":`fak`},"kit-duotone":{"fa-kit-duotone":`fakd`}},vo={"Font Awesome Kit":{400:`fak`,normal:`fak`},"Font Awesome Kit Duotone":{400:`fakd`,normal:`fakd`}},yo={kit:{fak:`fa-kit`},"kit-duotone":{fakd:`fa-kit-duotone`}},bo={kit:{kit:`fak`},"kit-duotone":{"kit-duotone":`fakd`}},xo,So={GROUP:`duotone-group`,SWAP_OPACITY:`swap-opacity`,PRIMARY:`primary`,SECONDARY:`secondary`},Co=[`fa-classic`,`fa-duotone`,`fa-sharp`,`fa-sharp-duotone`,`fa-thumbprint`,`fa-whiteboard`,`fa-notdog`,`fa-notdog-duo`,`fa-chisel`,`fa-etch`,`fa-graphite`,`fa-jelly`,`fa-jelly-fill`,`fa-jelly-duo`,`fa-slab`,`fa-slab-press`,`fa-utility`,`fa-utility-duo`,`fa-utility-fill`];xo={},G(G(G(G(G(G(G(G(G(G(xo,`classic`,`Classic`),`duotone`,`Duotone`),`sharp`,`Sharp`),`sharp-duotone`,`Sharp Duotone`),`chisel`,`Chisel`),`etch`,`Etch`),`graphite`,`Graphite`),`jelly`,`Jelly`),`jelly-duo`,`Jelly Duo`),`jelly-fill`,`Jelly Fill`),G(G(G(G(G(G(G(G(G(xo,`notdog`,`Notdog`),`notdog-duo`,`Notdog Duo`),`slab`,`Slab`),`slab-press`,`Slab Press`),`thumbprint`,`Thumbprint`),`utility`,`Utility`),`utility-duo`,`Utility Duo`),`utility-fill`,`Utility Fill`),`whiteboard`,`Whiteboard`),G(G({},`kit`,`Kit`),`kit-duotone`,`Kit Duotone`);var wo={classic:{"fa-brands":`fab`,"fa-duotone":`fad`,"fa-light":`fal`,"fa-regular":`far`,"fa-solid":`fas`,"fa-thin":`fat`},duotone:{"fa-regular":`fadr`,"fa-light":`fadl`,"fa-thin":`fadt`},sharp:{"fa-solid":`fass`,"fa-regular":`fasr`,"fa-light":`fasl`,"fa-thin":`fast`},"sharp-duotone":{"fa-solid":`fasds`,"fa-regular":`fasdr`,"fa-light":`fasdl`,"fa-thin":`fasdt`},slab:{"fa-regular":`faslr`},"slab-press":{"fa-regular":`faslpr`},whiteboard:{"fa-semibold":`fawsb`},thumbprint:{"fa-light":`fatl`},notdog:{"fa-solid":`fans`},"notdog-duo":{"fa-solid":`fands`},etch:{"fa-solid":`faes`},graphite:{"fa-thin":`fagt`},jelly:{"fa-regular":`fajr`},"jelly-fill":{"fa-regular":`fajfr`},"jelly-duo":{"fa-regular":`fajdr`},chisel:{"fa-regular":`facr`},utility:{"fa-semibold":`fausb`},"utility-duo":{"fa-semibold":`faudsb`},"utility-fill":{"fa-semibold":`faufsb`}},To={classic:[`fas`,`far`,`fal`,`fat`,`fad`],duotone:[`fadr`,`fadl`,`fadt`],sharp:[`fass`,`fasr`,`fasl`,`fast`],"sharp-duotone":[`fasds`,`fasdr`,`fasdl`,`fasdt`],slab:[`faslr`],"slab-press":[`faslpr`],whiteboard:[`fawsb`],thumbprint:[`fatl`],notdog:[`fans`],"notdog-duo":[`fands`],etch:[`faes`],graphite:[`fagt`],jelly:[`fajr`],"jelly-fill":[`fajfr`],"jelly-duo":[`fajdr`],chisel:[`facr`],utility:[`fausb`],"utility-duo":[`faudsb`],"utility-fill":[`faufsb`]},Eo={classic:{fab:`fa-brands`,fad:`fa-duotone`,fal:`fa-light`,far:`fa-regular`,fas:`fa-solid`,fat:`fa-thin`},duotone:{fadr:`fa-regular`,fadl:`fa-light`,fadt:`fa-thin`},sharp:{fass:`fa-solid`,fasr:`fa-regular`,fasl:`fa-light`,fast:`fa-thin`},"sharp-duotone":{fasds:`fa-solid`,fasdr:`fa-regular`,fasdl:`fa-light`,fasdt:`fa-thin`},slab:{faslr:`fa-regular`},"slab-press":{faslpr:`fa-regular`},whiteboard:{fawsb:`fa-semibold`},thumbprint:{fatl:`fa-light`},notdog:{fans:`fa-solid`},"notdog-duo":{fands:`fa-solid`},etch:{faes:`fa-solid`},graphite:{fagt:`fa-thin`},jelly:{fajr:`fa-regular`},"jelly-fill":{fajfr:`fa-regular`},"jelly-duo":{fajdr:`fa-regular`},chisel:{facr:`fa-regular`},utility:{fausb:`fa-semibold`},"utility-duo":{faudsb:`fa-semibold`},"utility-fill":{faufsb:`fa-semibold`}},Do=`fa.fas.far.fal.fat.fad.fadr.fadl.fadt.fab.fass.fasr.fasl.fast.fasds.fasdr.fasdl.fasdt.faslr.faslpr.fawsb.fatl.fans.fands.faes.fagt.fajr.fajfr.fajdr.facr.fausb.faudsb.faufsb`.split(`.`).concat(Co,[`fa-solid`,`fa-regular`,`fa-light`,`fa-thin`,`fa-duotone`,`fa-brands`,`fa-semibold`]),Oo=[`solid`,`regular`,`light`,`thin`,`duotone`,`brands`,`semibold`],ko=[1,2,3,4,5,6,7,8,9,10],Ao=ko.concat([11,12,13,14,15,16,17,18,19,20]),jo=[].concat(ea(Object.keys(To)),Oo,[`aw`,`fw`,`pull-left`,`pull-right`],[`2xs`,`xs`,`sm`,`lg`,`xl`,`2xl`,`beat`,`border`,`fade`,`beat-fade`,`bounce`,`flip-both`,`flip-horizontal`,`flip-vertical`,`flip`,`inverse`,`layers`,`layers-bottom-left`,`layers-bottom-right`,`layers-counter`,`layers-text`,`layers-top-left`,`layers-top-right`,`li`,`pull-end`,`pull-start`,`pulse`,`rotate-180`,`rotate-270`,`rotate-90`,`rotate-by`,`shake`,`spin-pulse`,`spin-reverse`,`spin`,`stack-1x`,`stack-2x`,`stack`,`ul`,`width-auto`,`width-fixed`,So.GROUP,So.SWAP_OPACITY,So.PRIMARY,So.SECONDARY],ko.map(function(e){return`${e}x`}),Ao.map(function(e){return`w-${e}`})),Mo={"Font Awesome 5 Free":{900:`fas`,400:`far`},"Font Awesome 5 Pro":{900:`fas`,400:`far`,normal:`far`,300:`fal`},"Font Awesome 5 Brands":{400:`fab`,normal:`fab`},"Font Awesome 5 Duotone":{900:`fad`}},No=`___FONT_AWESOME___`,Po=16,Fo=`fa`,Io=`svg-inline--fa`,Lo=`data-fa-i2svg`,Ro=`data-fa-pseudo-element`,zo=`data-fa-pseudo-element-pending`,Bo=`data-prefix`,Vo=`data-icon`,Ho=`fontawesome-i2svg`,Uo=`async`,Wo=[`HTML`,`HEAD`,`STYLE`,`SCRIPT`],Go=[`::before`,`::after`,`:before`,`:after`],Ko=function(){try{return!0}catch{return!1}}();function qo(e){return new Proxy(e,{get:function(e,t){return t in e?e[t]:e[wa]}})}var Jo=K({},xa);Jo[wa]=K(K(K(K({},{"fa-duotone":`duotone`}),xa[wa]),ho.kit),ho[`kit-duotone`]);var Yo=qo(Jo),Xo=K({},po);Xo[wa]=K(K(K(K({},{duotone:`fad`}),Xo[wa]),bo.kit),bo[`kit-duotone`]);var Zo=qo(Xo),Qo=K({},Eo);Qo[wa]=K(K({},Qo[wa]),yo.kit);var $o=qo(Qo),es=K({},wo);es[wa]=K(K({},es[wa]),_o.kit),qo(es);var ts=ya,ns=`fa-layers-text`,rs=ba;qo(K({},lo));var is=[`class`,`data-prefix`,`data-icon`,`data-fa-transform`,`data-fa-mask`],as=Sa,os=[].concat(ea(go),ea(jo)),ss=fa.FontAwesomeConfig||{};function cs(e){var t=pa.querySelector(`script[`+e+`]`);if(t)return t.getAttribute(e)}function ls(e){return e===``?!0:e===`false`?!1:e===`true`?!0:e}pa&&typeof pa.querySelector==`function`&&[[`data-family-prefix`,`familyPrefix`],[`data-css-prefix`,`cssPrefix`],[`data-family-default`,`familyDefault`],[`data-style-default`,`styleDefault`],[`data-replacement-class`,`replacementClass`],[`data-auto-replace-svg`,`autoReplaceSvg`],[`data-auto-add-css`,`autoAddCss`],[`data-search-pseudo-elements`,`searchPseudoElements`],[`data-search-pseudo-elements-warnings`,`searchPseudoElementsWarnings`],[`data-search-pseudo-elements-full-scan`,`searchPseudoElementsFullScan`],[`data-observe-mutations`,`observeMutations`],[`data-mutate-approach`,`mutateApproach`],[`data-keep-original-source`,`keepOriginalSource`],[`data-measure-performance`,`measurePerformance`],[`data-show-missing-icons`,`showMissingIcons`]].forEach(function(e){var t=$i(e,2),n=t[0],r=t[1],i=ls(cs(n));i!=null&&(ss[r]=i)});var us={styleDefault:`solid`,familyDefault:wa,cssPrefix:Fo,replacementClass:Io,autoReplaceSvg:!0,autoAddCss:!0,searchPseudoElements:!1,searchPseudoElementsWarnings:!0,searchPseudoElementsFullScan:!1,observeMutations:!0,mutateApproach:`async`,keepOriginalSource:!0,measurePerformance:!1,showMissingIcons:!0};ss.familyPrefix&&(ss.cssPrefix=ss.familyPrefix);var ds=K(K({},us),ss);ds.autoReplaceSvg||(ds.observeMutations=!1);var q={};Object.keys(us).forEach(function(e){Object.defineProperty(q,e,{enumerable:!0,set:function(t){ds[e]=t,fs.forEach(function(e){return e(q)})},get:function(){return ds[e]}})}),Object.defineProperty(q,"familyPrefix",{enumerable:!0,set:function(e){ds.cssPrefix=e,fs.forEach(function(e){return e(q)})},get:function(){return ds.cssPrefix}}),fa.FontAwesomeConfig=q;var fs=[];function ps(e){return fs.push(e),function(){fs.splice(fs.indexOf(e),1)}}var ms=Po,hs={size:16,x:0,y:0,rotate:0,flipX:!1,flipY:!1};function gs(e){if(!(!e||!ga)){var t=pa.createElement(`style`);t.setAttribute(`type`,`text/css`),t.innerHTML=e;for(var n=pa.head.childNodes,r=null,i=n.length-1;i>-1;i--){var a=n[i],o=(a.tagName||``).toUpperCase();[`STYLE`,`LINK`].indexOf(o)>-1&&(r=a)}return pa.head.insertBefore(t,r),e}}var _s=`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`;function vs(){for(var e=12,t=``;e-- >0;)t+=_s[Math.random()*62|0];return t}function ys(e){for(var t=[],n=(e||[]).length>>>0;n--;)t[n]=e[n];return t}function bs(e){return e.classList?ys(e.classList):(e.getAttribute(`class`)||``).split(` `).filter(function(e){return e})}function xs(e){return`${e}`.replace(/&/g,`&`).replace(/"/g,`"`).replace(/'/g,`'`).replace(/</g,`<`).replace(/>/g,`>`)}function Ss(e){return Object.keys(e||{}).reduce(function(t,n){return t+`${n}="${xs(e[n])}" `},``).trim()}function Cs(e){return Object.keys(e||{}).reduce(function(t,n){return t+`${n}: ${e[n].trim()};`},``)}function ws(e){return e.size!==hs.size||e.x!==hs.x||e.y!==hs.y||e.rotate!==hs.rotate||e.flipX||e.flipY}function Ts(e){var t=e.transform,n=e.containerWidth,r=e.iconWidth;return{outer:{transform:`translate(${n/2} 256)`},inner:{transform:`${`translate(${t.x*32}, ${t.y*32}) `} ${`scale(${t.size/16*(t.flipX?-1:1)}, ${t.size/16*(t.flipY?-1:1)}) `} ${`rotate(${t.rotate} 0 0)`}`},path:{transform:`translate(${r/2*-1} -256)`}}}function Es(e){var t=e.transform,n=e.width,r=n===void 0?Po:n,i=e.height,a=i===void 0?Po:i,o=e.startCentered,s=o===void 0?!1:o,c=``;return s&&_a?c+=`translate(${t.x/ms-r/2}em, ${t.y/ms-a/2}em) `:s?c+=`translate(calc(-50% + ${t.x/ms}em), calc(-50% + ${t.y/ms}em)) `:c+=`translate(${t.x/ms}em, ${t.y/ms}em) `,c+=`scale(${t.size/ms*(t.flipX?-1:1)}, ${t.size/ms*(t.flipY?-1:1)}) `,c+=`rotate(${t.rotate}deg) `,c}var Ds=`:root, :host {
|
|
6
6
|
--fa-font-solid: normal 900 1em/1 'Font Awesome 7 Free';
|
|
7
7
|
--fa-font-regular: normal 400 1em/1 'Font Awesome 7 Free';
|
|
8
8
|
--fa-font-light: normal 300 1em/1 'Font Awesome 7 Pro';
|
|
@@ -553,18 +553,18 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
553
553
|
margin: auto;
|
|
554
554
|
position: absolute;
|
|
555
555
|
z-index: var(--fa-stack-z-index, auto);
|
|
556
|
-
}`;function xs(){var e=Oo,t=ko,n=q.cssPrefix,r=q.replacementClass,i=bs;if(n!==e||r!==t){var a=RegExp(`\\.${e}\\-`,`g`),o=RegExp(`\\--${e}\\-`,`g`),s=RegExp(`\\.${t}`,`g`);i=i.replace(a,`.${n}-`).replace(o,`--${n}-`).replace(s,`.${r}`)}return i}var Ss=!1;function Cs(){q.autoAddCss&&!Ss&&(ls(xs()),Ss=!0)}var ws={mixout:function(){return{dom:{css:xs,insertCss:Cs}}},hooks:function(){return{beforeDOMElementCreation:function(){Cs()},beforeI2svg:function(){Cs()}}}},Ts=aa||{};Ts[Eo]||(Ts[Eo]={}),Ts[Eo].styles||(Ts[Eo].styles={}),Ts[Eo].hooks||(Ts[Eo].hooks={}),Ts[Eo].shims||(Ts[Eo].shims=[]);var Es=Ts[Eo],Ds=[],Os=function(){oa.removeEventListener(`DOMContentLoaded`,Os),ks=1,Ds.map(function(e){return e()})},ks=!1;la&&(ks=(oa.documentElement.doScroll?/^loaded|^c/:/^loaded|^i|^c/).test(oa.readyState),ks||oa.addEventListener(`DOMContentLoaded`,Os));function As(e){la&&(ks?setTimeout(e,0):Ds.push(e))}function js(e){var t=e.tag,n=e.attributes,r=n===void 0?{}:n,i=e.children,a=i===void 0?[]:i;return typeof e==`string`?ms(e):`<${t} ${hs(r)}>${a.map(js).join(``)}</${t}>`}function Ms(e,t,n){if(e&&e[t]&&e[t][n])return{prefix:t,iconName:n,icon:e[t][n]}}var Ns=function(e,t){return function(n,r,i,a){return e.call(t,n,r,i,a)}},Ps=function(e,t,n,r){var i=Object.keys(e),a=i.length,o=r===void 0?t:Ns(t,r),s,c,l;for(n===void 0?(s=1,l=e[i[0]]):(s=0,l=n);s<a;s++)c=i[s],l=o(l,e[c],c,e);return l};function Fs(e){return qi(e).length===1?e.codePointAt(0).toString(16):null}function Is(e){return Object.keys(e).reduce(function(t,n){var r=e[n];return r.icon?t[r.iconName]=r.icon:t[n]=r,t},{})}function Ls(e,t){var n=(arguments.length>2&&arguments[2]!==void 0?arguments[2]:{}).skipHooks,r=n===void 0?!1:n,i=Is(t);typeof Es.hooks.addPack==`function`&&!r?Es.hooks.addPack(e,Is(t)):Es.styles[e]=K(K({},Es.styles[e]||{}),i),e===`fas`&&Ls(`fa`,t)}var Rs=Es.styles,zs=Es.shims,Bs=Object.keys(Ko),Vs=Bs.reduce(function(e,t){return e[t]=Object.keys(Ko[t]),e},{}),Hs=null,Us={},Ws={},Gs={},Ks={},qs={};function Js(e){return~$o.indexOf(e)}function Ys(e,t){var n=t.split(`-`),r=n[0],i=n.slice(1).join(`-`);return r===e&&i!==``&&!Js(i)?i:null}var Xs=function(){var e=function(e){return Ps(Rs,function(t,n,r){return t[r]=Ps(n,e,{}),t},{})};Us=e(function(e,t,n){return t[3]&&(e[t[3]]=n),t[2]&&t[2].filter(function(e){return typeof e==`number`}).forEach(function(t){e[t.toString(16)]=n}),e}),Ws=e(function(e,t,n){return e[n]=n,t[2]&&t[2].filter(function(e){return typeof e==`string`}).forEach(function(t){e[t]=n}),e}),qs=e(function(e,t,n){var r=t[2];return e[n]=n,r.forEach(function(t){e[t]=n}),e});var t=`far`in Rs||q.autoFetchSvg,n=Ps(zs,function(e,n){var r=n[0],i=n[1],a=n[2];return i===`far`&&!t&&(i=`fas`),typeof r==`string`&&(e.names[r]={prefix:i,iconName:a}),typeof r==`number`&&(e.unicodes[r.toString(16)]={prefix:i,iconName:a}),e},{names:{},unicodes:{}});Gs=n.names,Ks=n.unicodes,Hs=ac(q.styleDefault,{family:q.familyDefault})};os(function(e){Hs=ac(e.styleDefault,{family:q.familyDefault})}),Xs();function Zs(e,t){return(Us[e]||{})[t]}function Qs(e,t){return(Ws[e]||{})[t]}function $s(e,t){return(qs[e]||{})[t]}function ec(e){return Gs[e]||{prefix:null,iconName:null}}function tc(e){var t=Ks[e],n=Zs(`fas`,e);return t||(n?{prefix:`fas`,iconName:n}:null)||{prefix:null,iconName:null}}function nc(){return Hs}var rc=function(){return{prefix:null,iconName:null,rest:[]}};function ic(e){var t=_a,n=Bs.reduce(function(e,t){return e[t]=`${q.cssPrefix}-${t}`,e},{});return to.forEach(function(r){(e.includes(n[r])||e.some(function(e){return Vs[r].includes(e)}))&&(t=r)}),t}function ac(e){var t=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}).family,n=t===void 0?_a:t,r=Ho[n][e];if(n===va&&!e)return`fad`;var i=Wo[n][e]||Wo[n][r],a=e in Es.styles?e:null;return i||a||null}function oc(e){var t=[],n=null;return e.forEach(function(e){var r=Ys(q.cssPrefix,e);r?n=r:e&&t.push(e)}),{iconName:n,rest:t}}function sc(e){return e.sort().filter(function(e,t,n){return n.indexOf(e)===t})}var cc=bo.concat(oo);function lc(e){var t=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}).skipLookups,n=t===void 0?!1:t,r=null,i=sc(e.filter(function(e){return cc.includes(e)})),a=sc(e.filter(function(e){return!cc.includes(e)})),o=Ki(i.filter(function(e){return r=e,!ga.includes(e)}),1)[0],s=o===void 0?null:o,c=ic(i),l=K(K({},oc(a)),{},{prefix:ac(s,{family:c})});return K(K(K({},l),pc({values:e,family:c,styles:Rs,config:q,canonical:l,givenPrefix:r})),uc(n,r,l))}function uc(e,t,n){var r=n.prefix,i=n.iconName;if(e||!r||!i)return{prefix:r,iconName:i};var a=t===`fa`?ec(i):{},o=$s(r,i);return i=a.iconName||o||i,r=a.prefix||r,r===`far`&&!Rs.far&&Rs.fas&&!q.autoFetchSvg&&(r=`fas`),{prefix:r,iconName:i}}var dc=to.filter(function(e){return e!==_a||e!==va}),fc=Object.keys(yo).filter(function(e){return e!==_a}).map(function(e){return Object.keys(yo[e])}).flat();function pc(e){var t=e.values,n=e.family,r=e.canonical,i=e.givenPrefix,a=i===void 0?``:i,o=e.styles,s=o===void 0?{}:o,c=e.config,l=c===void 0?{}:c,u=n===va,d=t.includes(`fa-duotone`)||t.includes(`fad`),f=l.familyDefault===`duotone`,p=r.prefix===`fad`||r.prefix===`fa-duotone`;return!u&&(d||f||p)&&(r.prefix=`fad`),(t.includes(`fa-brands`)||t.includes(`fab`))&&(r.prefix=`fab`),!r.prefix&&dc.includes(n)&&(Object.keys(s).find(function(e){return fc.includes(e)})||l.autoFetchSvg)&&(r.prefix=io.get(n).defaultShortPrefixId,r.iconName=$s(r.prefix,r.iconName)||r.iconName),(r.prefix===`fa`||a===`fa`)&&(r.prefix=nc()||`fas`),r}var mc=function(){function e(){Li(this,e),this.definitions={}}return zi(e,[{key:`add`,value:function(){var e=this,t=[...arguments].reduce(this._pullDefinitions,{});Object.keys(t).forEach(function(n){e.definitions[n]=K(K({},e.definitions[n]||{}),t[n]),Ls(n,t[n]);var r=Ko[_a][n];r&&Ls(r,t[n]),Xs()})}},{key:`reset`,value:function(){this.definitions={}}},{key:`_pullDefinitions`,value:function(e,t){var n=t.prefix&&t.iconName&&t.icon?{0:t}:t;return Object.keys(n).map(function(t){var r=n[t],i=r.prefix,a=r.iconName,o=r.icon,s=o[2];e[i]||(e[i]={}),s.length>0&&s.forEach(function(t){typeof t==`string`&&(e[i][t]=o)}),e[i][a]=o}),e}}])}(),hc=[],gc={},_c={},vc=Object.keys(_c);function yc(e,t){var n=t.mixoutsTo;return hc=e,gc={},Object.keys(_c).forEach(function(e){vc.indexOf(e)===-1&&delete _c[e]}),hc.forEach(function(e){var t=e.mixout?e.mixout():{};if(Object.keys(t).forEach(function(e){typeof t[e]==`function`&&(n[e]=t[e]),Xi(t[e])===`object`&&Object.keys(t[e]).forEach(function(r){n[e]||(n[e]={}),n[e][r]=t[e][r]})}),e.hooks){var r=e.hooks();Object.keys(r).forEach(function(e){gc[e]||(gc[e]=[]),gc[e].push(r[e])})}e.provides&&e.provides(_c)}),n}function bc(e,t){var n=[...arguments].slice(2);return(gc[e]||[]).forEach(function(e){t=e.apply(null,[t].concat(n))}),t}function xc(e){var t=[...arguments].slice(1);(gc[e]||[]).forEach(function(e){e.apply(null,t)})}function Sc(){var e=arguments[0],t=Array.prototype.slice.call(arguments,1);return _c[e]?_c[e].apply(null,t):void 0}function Cc(e){e.prefix===`fa`&&(e.prefix=`fas`);var t=e.iconName,n=e.prefix||nc();if(t)return t=$s(n,t)||t,Ms(wc.definitions,n,t)||Ms(Es.styles,n,t)}var wc=new mc,Tc={noAuto:function(){q.autoReplaceSvg=!1,q.observeMutations=!1,xc(`noAuto`)},config:q,dom:{i2svg:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return la?(xc(`beforeI2svg`,e),Sc(`pseudoElements2svg`,e),Sc(`i2svg`,e)):Promise.reject(Error(`Operation requires a DOM of some kind.`))},watch:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.autoReplaceSvgRoot;q.autoReplaceSvg===!1&&(q.autoReplaceSvg=!0),q.observeMutations=!0,As(function(){Ec({autoReplaceSvgRoot:t}),xc(`watch`,e)})}},parse:{icon:function(e){if(e===null)return null;if(Xi(e)===`object`&&e.prefix&&e.iconName)return{prefix:e.prefix,iconName:$s(e.prefix,e.iconName)||e.iconName};if(Array.isArray(e)&&e.length===2){var t=e[1].indexOf(`fa-`)===0?e[1].slice(3):e[1],n=ac(e[0]);return{prefix:n,iconName:$s(n,t)||t}}if(typeof e==`string`&&(e.indexOf(`${q.cssPrefix}-`)>-1||e.match(Jo))){var r=lc(e.split(` `),{skipLookups:!0});return{prefix:r.prefix||nc(),iconName:$s(r.prefix,r.iconName)||r.iconName}}if(typeof e==`string`){var i=nc();return{prefix:i,iconName:$s(i,e)||e}}}},library:wc,findIconDefinition:Cc,toHtml:js},Ec=function(){var e=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}).autoReplaceSvgRoot,t=e===void 0?oa:e;(Object.keys(Es.styles).length>0||q.autoFetchSvg)&&la&&q.autoReplaceSvg&&Tc.dom.i2svg({node:t})};function Dc(e,t){return Object.defineProperty(e,"abstract",{get:t}),Object.defineProperty(e,"html",{get:function(){return e.abstract.map(function(e){return js(e)})}}),Object.defineProperty(e,"node",{get:function(){if(la){var t=oa.createElement(`div`);return t.innerHTML=e.html,t.children}}}),e}function Oc(e){var t=e.children,n=e.main,r=e.mask,i=e.attributes,a=e.styles,o=e.transform;if(_s(o)&&n.found&&!r.found){var s={x:n.width/n.height/2,y:.5};i.style=gs(K(K({},a),{},{"transform-origin":`${s.x+o.x/16}em ${s.y+o.y/16}em`}))}return[{tag:`svg`,attributes:i,children:t}]}function kc(e){var t=e.prefix,n=e.iconName,r=e.children,i=e.attributes,a=e.symbol,o=a===!0?`${t}-${q.cssPrefix}-${n}`:a;return[{tag:`svg`,attributes:{style:`display: none;`},children:[{tag:`symbol`,attributes:K(K({},i),{},{id:o}),children:r}]}]}function Ac(e){return[`aria-label`,`aria-labelledby`,`title`,`role`].some(function(t){return t in e})}function jc(e){var t=e.icons,n=t.main,r=t.mask,i=e.prefix,a=e.iconName,o=e.transform,s=e.symbol,c=e.maskId,l=e.extra,u=e.watchable,d=u===void 0?!1:u,f=r.found?r:n,p=f.width,m=f.height,h=[q.replacementClass,a?`${q.cssPrefix}-${a}`:``].filter(function(e){return l.classes.indexOf(e)===-1}).filter(function(e){return e!==``||!!e}).concat(l.classes).join(` `),g={children:[],attributes:K(K({},l.attributes),{},{"data-prefix":i,"data-icon":a,class:h,role:l.attributes.role||`img`,viewBox:`0 0 ${p} ${m}`})};!Ac(l.attributes)&&!l.attributes[`aria-hidden`]&&(g.attributes[`aria-hidden`]=`true`),d&&(g.attributes[Ao]=``);var _=K(K({},g),{},{prefix:i,iconName:a,main:n,mask:r,maskId:c,transform:o,symbol:s,styles:K({},l.styles)}),v=r.found&&n.found?Sc(`generateAbstractMask`,_)||{children:[],attributes:{}}:Sc(`generateAbstractIcon`,_)||{children:[],attributes:{}},y=v.children,b=v.attributes;return _.children=y,_.attributes=b,s?kc(_):Oc(_)}function Mc(e){var t=e.content,n=e.width,r=e.height,i=e.transform,a=e.extra,o=e.watchable,s=o===void 0?!1:o,c=K(K({},a.attributes),{},{class:a.classes.join(` `)});s&&(c[Ao]=``);var l=K({},a.styles);_s(i)&&(l.transform=ys({transform:i,startCentered:!0,width:n,height:r}),l[`-webkit-transform`]=l.transform);var u=gs(l);u.length>0&&(c.style=u);var d=[];return d.push({tag:`span`,attributes:c,children:[t]}),d}function Nc(e){var t=e.content,n=e.extra,r=K(K({},n.attributes),{},{class:n.classes.join(` `)}),i=gs(n.styles);i.length>0&&(r.style=i);var a=[];return a.push({tag:`span`,attributes:r,children:[t]}),a}var Pc=Es.styles;function Fc(e){var t=e[0],n=e[1],r=Ki(e.slice(4),1)[0],i=null;return i=Array.isArray(r)?{tag:`g`,attributes:{class:`${q.cssPrefix}-${Qo.GROUP}`},children:[{tag:`path`,attributes:{class:`${q.cssPrefix}-${Qo.SECONDARY}`,fill:`currentColor`,d:r[0]}},{tag:`path`,attributes:{class:`${q.cssPrefix}-${Qo.PRIMARY}`,fill:`currentColor`,d:r[1]}}]}:{tag:`path`,attributes:{fill:`currentColor`,d:r}},{found:!0,width:t,height:n,icon:i}}var Ic={found:!1,width:512,height:512};function Lc(e,t){!zo&&!q.showMissingIcons&&e&&console.error(`Icon with name "${e}" and prefix "${t}" is missing.`)}function Rc(e,t){var n=t;return t===`fa`&&q.styleDefault!==null&&(t=nc()),new Promise(function(r,i){if(n===`fa`){var a=ec(e)||{};e=a.iconName||e,t=a.prefix||t}if(e&&t&&Pc[t]&&Pc[t][e]){var o=Pc[t][e];return r(Fc(o))}Lc(e,t),r(K(K({},Ic),{},{icon:q.showMissingIcons&&e&&Sc(`missingIconAbstract`)||{}}))})}var zc=function(){},Bc=q.measurePerformance&&ca&&ca.mark&&ca.measure?ca:{mark:zc,measure:zc},Vc=`FA "7.2.0"`,Hc=function(e){return Bc.mark(`${Vc} ${e} begins`),function(){return Uc(e)}},Uc=function(e){Bc.mark(`${Vc} ${e} ends`),Bc.measure(`${Vc} ${e}`,`${Vc} ${e} begins`,`${Vc} ${e} ends`)},Wc={begin:Hc,end:Uc},Gc=function(){};function Kc(e){return typeof(e.getAttribute?e.getAttribute(Ao):null)==`string`}function qc(e){var t=e.getAttribute?e.getAttribute(No):null,n=e.getAttribute?e.getAttribute(Po):null;return t&&n}function Jc(e){return e&&e.classList&&e.classList.contains&&e.classList.contains(q.replacementClass)}function Yc(){return q.autoReplaceSvg===!0?el.replace:el[q.autoReplaceSvg]||el.replace}function Xc(e){return oa.createElementNS(`http://www.w3.org/2000/svg`,e)}function Zc(e){return oa.createElement(e)}function Qc(e){var t=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}).ceFn,n=t===void 0?e.tag===`svg`?Xc:Zc:t;if(typeof e==`string`)return oa.createTextNode(e);var r=n(e.tag);return Object.keys(e.attributes||[]).forEach(function(t){r.setAttribute(t,e.attributes[t])}),(e.children||[]).forEach(function(e){r.appendChild(Qc(e,{ceFn:n}))}),r}function $c(e){var t=` ${e.outerHTML} `;return t=`${t}Font Awesome fontawesome.com `,t}var el={replace:function(e){var t=e[0];if(t.parentNode)if(e[1].forEach(function(e){t.parentNode.insertBefore(Qc(e),t)}),t.getAttribute(Ao)===null&&q.keepOriginalSource){var n=oa.createComment($c(t));t.parentNode.replaceChild(n,t)}else t.remove()},nest:function(e){var t=e[0],n=e[1];if(~ps(t).indexOf(q.replacementClass))return el.replace(e);var r=RegExp(`${q.cssPrefix}-.*`);if(delete n[0].attributes.id,n[0].attributes.class){var i=n[0].attributes.class.split(` `).reduce(function(e,t){return t===q.replacementClass||t.match(r)?e.toSvg.push(t):e.toNode.push(t),e},{toNode:[],toSvg:[]});n[0].attributes.class=i.toSvg.join(` `),i.toNode.length===0?t.removeAttribute(`class`):t.setAttribute(`class`,i.toNode.join(` `))}var a=n.map(function(e){return js(e)}).join(`
|
|
557
|
-
`);t.setAttribute(
|
|
558
|
-
`),e.removeAttribute(n),r()}).catch(i)}else r()}else r()})}function
|
|
559
|
-
If it declares any Font Awesome CSS pseudo-elements, they will not be rendered as SVG icons. Add crossorigin="anonymous" to the <link>, enable searchPseudoElementsFullScan for slower but more thorough DOM parsing, or suppress this warning by setting searchPseudoElementsWarnings to false.`)}}}catch(e){i.e(e)}finally{i.f()}if(!r.size)return;var p=Array.from(r).join(`, `);try{n=e.querySelectorAll(p)}catch{}}return new Promise(function(e,t){var r=fs(n).filter(Fl).map(Pl),i=Wc.begin(`searchPseudoElements`);il(),Promise.all(r).then(function(){i(),al(),e()}).catch(function(){i(),al(),t()})})}}var zl={hooks:function(){return{mutationObserverCallbacks:function(e){return e.pseudoElementsCallback=Rl,e}}},provides:function(e){e.pseudoElements2svg=function(e){var t=e.node,n=t===void 0?oa:t;q.searchPseudoElements&&Rl(n)}}},Bl=!1,Vl={mixout:function(){return{dom:{unwatch:function(){il(),Bl=!0}}}},hooks:function(){return{bootstrap:function(){sl(bc(`mutationObserverCallbacks`,{}))},noAuto:function(){cl()},watch:function(e){var t=e.observeMutationsRoot;Bl?al():sl(bc(`mutationObserverCallbacks`,{observeMutationsRoot:t}))}}}},Hl=function(e){return e.toLowerCase().split(` `).reduce(function(e,t){var n=t.toLowerCase().split(`-`),r=n[0],i=n.slice(1).join(`-`);if(r&&i===`h`)return e.flipX=!0,e;if(r&&i===`v`)return e.flipY=!0,e;if(i=parseFloat(i),isNaN(i))return e;switch(r){case`grow`:e.size+=i;break;case`shrink`:e.size-=i;break;case`left`:e.x-=i;break;case`right`:e.x+=i;break;case`up`:e.y-=i;break;case`down`:e.y+=i;break;case`rotate`:e.rotate+=i;break}return e},{size:16,x:0,y:0,flipX:!1,flipY:!1,rotate:0})},Ul={mixout:function(){return{parse:{transform:function(e){return Hl(e)}}}},hooks:function(){return{parseNodeAttributes:function(e,t){var n=t.getAttribute(`data-fa-transform`);return n&&(e.transform=Hl(n)),e}}},provides:function(e){e.generateAbstractTransformGrouping=function(e){var t=e.main,n=e.transform,r=e.containerWidth,i=e.iconWidth,a={outer:{transform:`translate(${r/2} 256)`},inner:{transform:`${`translate(${n.x*32}, ${n.y*32}) `} ${`scale(${n.size/16*(n.flipX?-1:1)}, ${n.size/16*(n.flipY?-1:1)}) `} ${`rotate(${n.rotate} 0 0)`}`},path:{transform:`translate(${i/2*-1} -256)`}};return{tag:`g`,attributes:K({},a.outer),children:[{tag:`g`,attributes:K({},a.inner),children:[{tag:t.icon.tag,children:t.icon.children,attributes:K(K({},t.icon.attributes),a.path)}]}]}}}},Wl={x:0,y:0,width:`100%`,height:`100%`};function Gl(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return e.attributes&&(e.attributes.fill||t)&&(e.attributes.fill=`black`),e}function Kl(e){return e.tag===`g`?e.children:[e]}yc([ws,xl,Sl,Cl,wl,zl,Vl,Ul,{hooks:function(){return{parseNodeAttributes:function(e,t){var n=t.getAttribute(`data-fa-mask`),r=n?lc(n.split(` `).map(function(e){return e.trim()})):rc();return r.prefix||=nc(),e.mask=r,e.maskId=t.getAttribute(`data-fa-mask-id`),e}}},provides:function(e){e.generateAbstractMask=function(e){var t=e.children,n=e.attributes,r=e.main,i=e.mask,a=e.maskId,o=e.transform,s=r.width,c=r.icon,l=i.width,u=i.icon,d=vs({transform:o,containerWidth:l,iconWidth:s}),f={tag:`rect`,attributes:K(K({},Wl),{},{fill:`white`})},p=c.children?{children:c.children.map(Gl)}:{},m={tag:`g`,attributes:K({},d.inner),children:[Gl(K({tag:c.tag,attributes:K(K({},c.attributes),d.path)},p))]},h={tag:`g`,attributes:K({},d.outer),children:[m]},g=`mask-${a||ds()}`,_=`clip-${a||ds()}`,v={tag:`mask`,attributes:K(K({},Wl),{},{id:g,maskUnits:`userSpaceOnUse`,maskContentUnits:`userSpaceOnUse`}),children:[f,h]},y={tag:`defs`,children:[{tag:`clipPath`,attributes:{id:_},children:Kl(u)},v]};return t.push(y,{tag:`rect`,attributes:K({fill:`currentColor`,"clip-path":`url(#${_})`,mask:`url(#${g})`},Wl)}),{children:t,attributes:n}}}},{provides:function(e){var t=!1;aa.matchMedia&&(t=aa.matchMedia(`(prefers-reduced-motion: reduce)`).matches),e.missingIconAbstract=function(){var e=[],n={fill:`currentColor`},r={attributeType:`XML`,repeatCount:`indefinite`,dur:`2s`};e.push({tag:`path`,attributes:K(K({},n),{},{d:`M156.5,447.7l-12.6,29.5c-18.7-9.5-35.9-21.2-51.5-34.9l22.7-22.7C127.6,430.5,141.5,440,156.5,447.7z M40.6,272H8.5 c1.4,21.2,5.4,41.7,11.7,61.1L50,321.2C45.1,305.5,41.8,289,40.6,272z M40.6,240c1.4-18.8,5.2-37,11.1-54.1l-29.5-12.6 C14.7,194.3,10,216.7,8.5,240H40.6z M64.3,156.5c7.8-14.9,17.2-28.8,28.1-41.5L69.7,92.3c-13.7,15.6-25.5,32.8-34.9,51.5 L64.3,156.5z M397,419.6c-13.9,12-29.4,22.3-46.1,30.4l11.9,29.8c20.7-9.9,39.8-22.6,56.9-37.6L397,419.6z M115,92.4 c13.9-12,29.4-22.3,46.1-30.4l-11.9-29.8c-20.7,9.9-39.8,22.6-56.8,37.6L115,92.4z M447.7,355.5c-7.8,14.9-17.2,28.8-28.1,41.5 l22.7,22.7c13.7-15.6,25.5-32.9,34.9-51.5L447.7,355.5z M471.4,272c-1.4,18.8-5.2,37-11.1,54.1l29.5,12.6 c7.5-21.1,12.2-43.5,13.6-66.8H471.4z M321.2,462c-15.7,5-32.2,8.2-49.2,9.4v32.1c21.2-1.4,41.7-5.4,61.1-11.7L321.2,462z M240,471.4c-18.8-1.4-37-5.2-54.1-11.1l-12.6,29.5c21.1,7.5,43.5,12.2,66.8,13.6V471.4z M462,190.8c5,15.7,8.2,32.2,9.4,49.2h32.1 c-1.4-21.2-5.4-41.7-11.7-61.1L462,190.8z M92.4,397c-12-13.9-22.3-29.4-30.4-46.1l-29.8,11.9c9.9,20.7,22.6,39.8,37.6,56.9 L92.4,397z M272,40.6c18.8,1.4,36.9,5.2,54.1,11.1l12.6-29.5C317.7,14.7,295.3,10,272,8.5V40.6z M190.8,50 c15.7-5,32.2-8.2,49.2-9.4V8.5c-21.2,1.4-41.7,5.4-61.1,11.7L190.8,50z M442.3,92.3L419.6,115c12,13.9,22.3,29.4,30.5,46.1 l29.8-11.9C470,128.5,457.3,109.4,442.3,92.3z M397,92.4l22.7-22.7c-15.6-13.7-32.8-25.5-51.5-34.9l-12.6,29.5 C370.4,72.1,384.4,81.5,397,92.4z`})});var i=K(K({},r),{},{attributeName:`opacity`}),a={tag:`circle`,attributes:K(K({},n),{},{cx:`256`,cy:`364`,r:`28`}),children:[]};return t||a.children.push({tag:`animate`,attributes:K(K({},r),{},{attributeName:`r`,values:`28;14;28;28;14;28;`})},{tag:`animate`,attributes:K(K({},i),{},{values:`1;0;1;1;0;1;`})}),e.push(a),e.push({tag:`path`,attributes:K(K({},n),{},{opacity:`1`,d:`M263.7,312h-16c-6.6,0-12-5.4-12-12c0-71,77.4-63.9,77.4-107.8c0-20-17.8-40.2-57.4-40.2c-29.1,0-44.3,9.6-59.2,28.7 c-3.9,5-11.1,6-16.2,2.4l-13.1-9.2c-5.6-3.9-6.9-11.8-2.6-17.2c21.2-27.2,46.4-44.7,91.2-44.7c52.3,0,97.4,29.8,97.4,80.2 c0,67.6-77.4,63.5-77.4,107.8C275.7,306.6,270.3,312,263.7,312z`}),children:t?[]:[{tag:`animate`,attributes:K(K({},i),{},{values:`1;0;0;0;0;1;`})}]}),t||e.push({tag:`path`,attributes:K(K({},n),{},{opacity:`0`,d:`M232.5,134.5l7,168c0.3,6.4,5.6,11.5,12,11.5h9c6.4,0,11.7-5.1,12-11.5l7-168c0.3-6.8-5.2-12.5-12-12.5h-23 C237.7,122,232.2,127.7,232.5,134.5z`}),children:[{tag:`animate`,attributes:K(K({},i),{},{values:`0;0;1;1;0;0;`})}]}),{tag:`g`,attributes:{class:`missing`},children:e}}}},{hooks:function(){return{parseNodeAttributes:function(e,t){var n=t.getAttribute(`data-fa-symbol`);return e.symbol=n===null?!1:n===``?!0:n,e}}}}],{mixoutsTo:Tc}),Tc.noAuto,Tc.config,Tc.library,Tc.dom,Tc.parse,Tc.findIconDefinition,Tc.toHtml;var ql=Tc.icon;Tc.layer,Tc.text,Tc.counter;function Jl(e,t){We(t,!0);let n=Wt(()=>ql(t.icon).html[0]);var r=Lr();ai(yn(r),()=>V(n)),W(e,r),Ge()}var Yl={prefix:`fas`,iconName:`expand`,icon:[448,512,[],`f065`,`M32 32C14.3 32 0 46.3 0 64l0 96c0 17.7 14.3 32 32 32s32-14.3 32-32l0-64 64 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 32zM64 352c0-17.7-14.3-32-32-32S0 334.3 0 352l0 96c0 17.7 14.3 32 32 32l96 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-64 0 0-64zM320 32c-17.7 0-32 14.3-32 32s14.3 32 32 32l64 0 0 64c0 17.7 14.3 32 32 32s32-14.3 32-32l0-96c0-17.7-14.3-32-32-32l-96 0zM448 352c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 64-64 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l96 0c17.7 0 32-14.3 32-32l0-96z`]},Xl={prefix:`fas`,iconName:`map`,icon:[512,512,[128506,62072],`f279`,`M512 48c0-11.1-5.7-21.4-15.2-27.2s-21.2-6.4-31.1-1.4L349.5 77.5 170.1 17.6c-8.1-2.7-16.8-2.1-24.4 1.7l-128 64C6.8 88.8 0 99.9 0 112L0 464c0 11.1 5.7 21.4 15.2 27.2s21.2 6.4 31.1 1.4l116.1-58.1 179.4 59.8c8.1 2.7 16.8 2.1 24.4-1.7l128-64c10.8-5.4 17.7-16.5 17.7-28.6l0-352zM192 376.9l0-284.5 128 42.7 0 284.5-128-42.7z`]},Zl={prefix:`fas`,iconName:`gear`,icon:[512,512,[9881,`cog`],`f013`,`M195.1 9.5C198.1-5.3 211.2-16 226.4-16l59.8 0c15.2 0 28.3 10.7 31.3 25.5L332 79.5c14.1 6 27.3 13.7 39.3 22.8l67.8-22.5c14.4-4.8 30.2 1.2 37.8 14.4l29.9 51.8c7.6 13.2 4.9 29.8-6.5 39.9L447 233.3c.9 7.4 1.3 15 1.3 22.7s-.5 15.3-1.3 22.7l53.4 47.5c11.4 10.1 14 26.8 6.5 39.9l-29.9 51.8c-7.6 13.1-23.4 19.2-37.8 14.4l-67.8-22.5c-12.1 9.1-25.3 16.7-39.3 22.8l-14.4 69.9c-3.1 14.9-16.2 25.5-31.3 25.5l-59.8 0c-15.2 0-28.3-10.7-31.3-25.5l-14.4-69.9c-14.1-6-27.2-13.7-39.3-22.8L73.5 432.3c-14.4 4.8-30.2-1.2-37.8-14.4L5.8 366.1c-7.6-13.2-4.9-29.8 6.5-39.9l53.4-47.5c-.9-7.4-1.3-15-1.3-22.7s.5-15.3 1.3-22.7L12.3 185.8c-11.4-10.1-14-26.8-6.5-39.9L35.7 94.1c7.6-13.2 23.4-19.2 37.8-14.4l67.8 22.5c12.1-9.1 25.3-16.7 39.3-22.8L195.1 9.5zM256.3 336a80 80 0 1 0 -.6-160 80 80 0 1 0 .6 160z`]},Ql={prefix:`fas`,iconName:`ruler`,icon:[576,512,[128207],`f545`,`M209.1 516.2c-18.7 18.7-49.1 18.7-67.9 0L28.1 403.1c-18.7-18.7-18.7-49.1 0-67.9l17-17 73.5 73.5c9.4 9.4 24.6 9.4 33.9 0s9.4-24.6 0-33.9l-73.5-73.5 33.9-33.9 50.9 50.9c9.4 9.4 24.6 9.4 33.9 0s9.4-24.6 0-33.9l-50.9-50.9 33.9-33.9 73.5 73.5c9.4 9.4 24.6 9.4 33.9 0s9.4-24.6 0-33.9l-73.5-73.5 33.9-33.9 50.9 50.9c9.4 9.4 24.6 9.4 33.9 0s9.4-24.6 0-33.9l-50.9-50.9 33.9-33.9 73.5 73.5c9.4 9.4 24.6 9.4 33.9 0s9.4-24.6 0-33.9l-73.5-73.5 17-17c18.7-18.7 49.1-18.7 67.9 0L548.5 108.9c18.7 18.7 18.7 49.1 0 67.9L209.1 516.2z`]},$l={prefix:`fas`,iconName:`globe`,icon:[512,512,[127760],`f0ac`,`M351.9 280l-190.9 0c2.9 64.5 17.2 123.9 37.5 167.4 11.4 24.5 23.7 41.8 35.1 52.4 11.2 10.5 18.9 12.2 22.9 12.2s11.7-1.7 22.9-12.2c11.4-10.6 23.7-28 35.1-52.4 20.3-43.5 34.6-102.9 37.5-167.4zM160.9 232l190.9 0C349 167.5 334.7 108.1 314.4 64.6 303 40.2 290.7 22.8 279.3 12.2 268.1 1.7 260.4 0 256.4 0s-11.7 1.7-22.9 12.2c-11.4 10.6-23.7 28-35.1 52.4-20.3 43.5-34.6 102.9-37.5 167.4zm-48 0C116.4 146.4 138.5 66.9 170.8 14.7 78.7 47.3 10.9 131.2 1.5 232l111.4 0zM1.5 280c9.4 100.8 77.2 184.7 169.3 217.3-32.3-52.2-54.4-131.7-57.9-217.3L1.5 280zm398.4 0c-3.5 85.6-25.6 165.1-57.9 217.3 92.1-32.7 159.9-116.5 169.3-217.3l-111.4 0zm111.4-48C501.9 131.2 434.1 47.3 342 14.7 374.3 66.9 396.4 146.4 399.9 232l111.4 0z`]},eu={prefix:`fas`,iconName:`compress`,icon:[448,512,[],`f066`,`M160 64c0-17.7-14.3-32-32-32S96 46.3 96 64l0 64-64 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l96 0c17.7 0 32-14.3 32-32l0-96zM32 320c-17.7 0-32 14.3-32 32s14.3 32 32 32l64 0 0 64c0 17.7 14.3 32 32 32s32-14.3 32-32l0-96c0-17.7-14.3-32-32-32l-96 0zM352 64c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 96c0 17.7 14.3 32 32 32l96 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-64 0 0-64zM320 320c-17.7 0-32 14.3-32 32l0 96c0 17.7 14.3 32 32 32s32-14.3 32-32l0-64 64 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-96 0z`]},tu={prefix:`fas`,iconName:`location-crosshairs`,icon:[576,512,[`location`],`f601`,`M288-16c17.7 0 32 14.3 32 32l0 18.3c98.1 14 175.7 91.6 189.7 189.7l18.3 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-18.3 0c-14 98.1-91.6 175.7-189.7 189.7l0 18.3c0 17.7-14.3 32-32 32s-32-14.3-32-32l0-18.3C157.9 463.7 80.3 386.1 66.3 288L48 288c-17.7 0-32-14.3-32-32s14.3-32 32-32l18.3 0C80.3 125.9 157.9 48.3 256 34.3L256 16c0-17.7 14.3-32 32-32zM128 256a160 160 0 1 0 320 0 160 160 0 1 0 -320 0zm160-96a96 96 0 1 1 0 192 96 96 0 1 1 0-192z`]},nu={prefix:`fas`,iconName:`layer-group`,icon:[512,512,[],`f5fd`,`M232.5 5.2c14.9-6.9 32.1-6.9 47 0l218.6 101c8.5 3.9 13.9 12.4 13.9 21.8s-5.4 17.9-13.9 21.8l-218.6 101c-14.9 6.9-32.1 6.9-47 0L13.9 149.8C5.4 145.8 0 137.3 0 128s5.4-17.9 13.9-21.8L232.5 5.2zM48.1 218.4l164.3 75.9c27.7 12.8 59.6 12.8 87.3 0l164.3-75.9 34.1 15.8c8.5 3.9 13.9 12.4 13.9 21.8s-5.4 17.9-13.9 21.8l-218.6 101c-14.9 6.9-32.1 6.9-47 0L13.9 277.8C5.4 273.8 0 265.3 0 256s5.4-17.9 13.9-21.8l34.1-15.8zM13.9 362.2l34.1-15.8 164.3 75.9c27.7 12.8 59.6 12.8 87.3 0l164.3-75.9 34.1 15.8c8.5 3.9 13.9 12.4 13.9 21.8s-5.4 17.9-13.9 21.8l-218.6 101c-14.9 6.9-32.1 6.9-47 0L13.9 405.8C5.4 401.8 0 393.3 0 384s5.4-17.9 13.9-21.8z`]},ru=t(n()),iu=ot({position:null,cog:null,sog:null,heading:null}),au=`signalk-chart-settings`,ou={...cu(),useGeoLocation:!1,targetFps:60,appearance:{vesselColor:`#2563eb`,vesselSize:24,heading:{color:`#ffffff`,width:2,style:`solid`,lengthUnit:`nm`,lengthValue:.2},cog:{color:`#f59e0b`,width:2,style:`dashed`,lengthUnit:`min`,lengthValue:3},gc:{color:`#22c55e`,width:2,style:`dashed`,lengthUnit:`min`,lengthValue:3},ais:{vesselColor:`#f59e0b`,vesselSize:16,cog:{color:`#f59e0b`,width:1.5,style:`dashed`,lengthMinutes:3}},ruler:{color:`#ffdc32`,width:2},route:{bearing:{color:`#ff6d00`,width:2,style:`dashed`},segment:{color:`#e040fb`,width:2.5,style:`solid`},remaining:{color:`#e040fb`,width:2,style:`dashed`}}}},su=`/signalk/v1/stream?subscribe=self`;function cu(){let e=window.location,t=parseInt(e.port||(e.protocol===`https:`?`443`:`80`));return{signalkProtocol:e.protocol===`https:`?`wss`:`ws`,signalkHost:e.hostname,signalkPort:t}}function lu(){try{let e=localStorage.getItem(au);if(e){let t=JSON.parse(e);if(typeof t==`object`&&t){let e=t;return{...ou,...e,useGeoLocation:typeof e.useGeoLocation==`boolean`?e.useGeoLocation:ou.useGeoLocation,targetFps:typeof e.targetFps==`number`&&e.targetFps>0?e.targetFps:ou.targetFps,appearance:{...ou.appearance,...e.appearance??{},heading:{...ou.appearance.heading,...e.appearance?.heading??{}},cog:{...ou.appearance.cog,...e.appearance?.cog??{}},gc:{...ou.appearance.gc,...e.appearance?.gc??{}},ais:{...ou.appearance.ais,...e.appearance?.ais??{},cog:{...ou.appearance.ais.cog,...e.appearance?.ais?.cog??{}}},ruler:{...ou.appearance.ruler,...e.appearance?.ruler??{}},route:{bearing:{...ou.appearance.route.bearing,...e.appearance?.route?.bearing??{}},segment:{...ou.appearance.route.segment,...e.appearance?.route?.segment??{}},remaining:{...ou.appearance.route.remaining,...e.appearance?.route?.remaining??{}}}}}}}}catch{}return structuredClone(ou)}function uu(){let e=cn(lu()),t=F(null);return{get protocol(){return e.signalkProtocol},get host(){return e.signalkHost},get port(){return e.signalkPort},get useGeoLocation(){return e.useGeoLocation},get geoError(){return V(t)},get appearance(){return e.appearance},get targetFps(){return e.targetFps},get signalkUrl(){return`${e.signalkProtocol}://${e.signalkHost}:${String(e.signalkPort)}${su}`},get signalkHttpUrl(){return`${e.signalkProtocol===`wss`?`https`:`http`}://${e.signalkHost}:${String(e.signalkPort)}`},apply(n){n.signalkProtocol!==void 0&&(e.signalkProtocol=n.signalkProtocol),n.signalkHost!==void 0&&(e.signalkHost=n.signalkHost),n.signalkPort!==void 0&&(e.signalkPort=n.signalkPort),n.useGeoLocation!==void 0&&(e.useGeoLocation=n.useGeoLocation,n.useGeoLocation&&I(t,null)),n.appearance!==void 0&&(e.appearance=n.appearance),n.targetFps!==void 0&&(e.targetFps=n.targetFps),localStorage.setItem(au,JSON.stringify(e))},setGeoError(e){I(t,e,!0)},setTargetFps(t){e.targetFps=t,localStorage.setItem(au,JSON.stringify(e))}}}var J=uu();function du(){let e=F(0);return{get value(){return V(e)},set(t){I(e,t,!0)}}}var fu=du();function pu(){let e=F(!1);return{get following(){return V(e)},set following(t){I(e,t,!0)}}}var mu=pu(),hu=[`north`,`cog`,`heading`,`course`],gu={north:`N`,cog:`COG`,heading:`HDG`,course:`BRG`,manual:`MAN`};function _u(){let e=F(`north`),t=F(`north`);function n(e,t,n){return e===`heading`?t:e===`course`?n:!0}return{get mode(){return V(e)},get resumeMode(){return V(t)},get label(){return gu[V(e)]},setManual(){V(e)!==`manual`&&(I(t,V(e),!0),I(e,`manual`))},toggle(r,i){if(V(e)===`manual`){I(e,V(t),!0);return}let a=V(e),o=hu.indexOf(a);for(let t=1;t<=hu.length;t++){let a=hu[(o+t)%hu.length];if(n(a,r,i)){I(e,a,!0);return}}}}}var vu=_u(),yu=[`forEach`,`isDisjointFrom`,`isSubsetOf`,`isSupersetOf`],bu=[`difference`,`intersection`,`symmetricDifference`,`union`],xu=!1,Su=class e extends Set{#e=new Map;#t=F(0);#n=F(0);#r=mr||-1;constructor(e){if(super(),e){for(var t of e)super.add(t);this.#n.v=super.size}xu||this.#a()}#i(e){return mr===this.#r?F(e):en(e)}#a(){xu=!0;var t=e.prototype,n=Set.prototype;for(let e of yu)t[e]=function(...t){return V(this.#t),n[e].apply(this,t)};for(let r of bu)t[r]=function(...t){return V(this.#t),new e(n[r].apply(this,t))}}has(e){var t=super.has(e),n=this.#e,r=n.get(e);if(r===void 0){if(!t)return V(this.#t),!1;r=this.#i(!0),n.set(e,r)}return V(r),t}add(e){return super.has(e)||(super.add(e),I(this.#n,super.size),on(this.#t)),this}delete(e){var t=super.delete(e),n=this.#e,r=n.get(e);return r!==void 0&&(n.delete(e),I(r,!1)),t&&(I(this.#n,super.size),on(this.#t)),t}clear(){if(super.size!==0){super.clear();var e=this.#e;for(var t of e.values())I(t,!1);e.clear(),I(this.#n,0),on(this.#t)}}keys(){return this.values()}values(){return V(this.#t),super.values()}entries(){return V(this.#t),super.entries()}[Symbol.iterator](){return this.keys()}get size(){return V(this.#n)}},Cu=class extends Map{#e=new Map;#t=F(0);#n=F(0);#r=mr||-1;constructor(e){if(super(),e){for(var[t,n]of e)super.set(t,n);this.#n.v=super.size}}#i(e){return mr===this.#r?F(e):en(e)}has(e){var t=this.#e,n=t.get(e);if(n===void 0)if(super.has(e))n=this.#i(0),t.set(e,n);else return V(this.#t),!1;return V(n),!0}forEach(e,t){this.#a(),super.forEach(e,t)}get(e){var t=this.#e,n=t.get(e);if(n===void 0)if(super.has(e))n=this.#i(0),t.set(e,n);else{V(this.#t);return}return V(n),super.get(e)}set(e,t){var n=this.#e,r=n.get(e),i=super.get(e),a=super.set(e,t),o=this.#t;if(r===void 0)r=this.#i(0),n.set(e,r),I(this.#n,super.size),on(o);else if(i!==t){on(r);var s=o.reactions===null?null:new Set(o.reactions);(s===null||!r.reactions?.every(e=>s.has(e)))&&on(o)}return a}delete(e){var t=this.#e,n=t.get(e),r=super.delete(e);return n!==void 0&&(t.delete(e),I(n,-1)),r&&(I(this.#n,super.size),on(this.#t)),r}clear(){if(super.size!==0){super.clear();var e=this.#e;I(this.#n,0);for(var t of e.values())I(t,-1);on(this.#t),e.clear()}}#a(){V(this.#t);var e=this.#e;if(this.#n.v!==e.size){for(var t of super.keys())if(!e.has(t)){var n=this.#i(0);e.set(t,n)}}for([,n]of this.#e)V(n)}keys(){return V(this.#t),super.keys()}values(){return this.#a(),super.values()}entries(){return this.#a(),super.entries()}[Symbol.iterator](){return this.entries()}get size(){return V(this.#n),super.size}};function wu(e,t){if(!e.url)return null;let n=e.url.startsWith(`/`)?`${t}${e.url}`:e.url;if(e.type===`WMS`){let t=e.layers?.join(`,`)??``,r=Tu(e.format),i=e.wmsVersion??`1.3.0`,a=i.startsWith(`1.1`)?`SRS`:`CRS`;return`${n}${n.includes(`?`)?`&`:`?`}SERVICE=WMS&VERSION=${i}&REQUEST=GetMap&${a}=EPSG:3857&BBOX={bbox-epsg-3857}&WIDTH=256&HEIGHT=256&LAYERS=${encodeURIComponent(t)}&STYLES=&FORMAT=${encodeURIComponent(r)}&TRANSPARENT=TRUE`}if(e.type===`WMTS`){if(!n.includes(`{z}`)){let t=e.layers?.[0]??``,r=Tu(e.format);return`${n}${n.includes(`?`)?`&`:`?`}SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&LAYER=${encodeURIComponent(t)}&TILEMATRIXSET=EPSG:3857&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=${encodeURIComponent(r)}`}return n}return n}function Tu(e){switch(e.toLowerCase()){case`png`:return`image/png`;case`jpg`:case`jpeg`:return`image/jpeg`;case`pbf`:return`application/vnd.mapbox-vector-tile`;case`webp`:return`image/webp`;default:return`image/${e}`}}async function Eu(e){let t=await fetch(`${e}/signalk/v2/api/resources/charts`);if(!t.ok)throw Error(`Charts API error: ${String(t.status)} ${t.statusText}`);return t.json()}async function Du(e){let t=await fetch(`${e}/signalk/v1/api/vessels`);if(!t.ok)return new Map;let n=await t.json(),r=new Map;for(let[e,t]of Object.entries(n)){let n=t.design,i={};t.name&&(i.name=t.name),t.port&&(i.port=t.port),t.flag&&(i.flag=t.flag),t.communication?.callsignVhf&&(i.callsign=t.communication.callsignVhf),t.communication?.callsignHf&&(i.callsignHf=t.communication.callsignHf),t.communication?.skipperName&&(i.skipperName=t.communication.skipperName),t.navigation?.state?.value&&(i.navState=t.navigation.state.value),n?.aisShipType?.value?.name&&(i.shipType=n.aisShipType.value.name),n?.length?.value?.overall!==void 0&&(i.lengthM=n.length.value.overall),typeof n?.beam?.value==`number`&&(i.beamM=n.beam.value);let a=n?.draft?.value?.current??n?.draft?.value?.maximum;a!==void 0&&(i.draftM=a),typeof n?.airHeight?.value==`number`&&(i.airHeightM=n.airHeight.value),r.set(e,i)}return r}async function Ou(e,t){let n=e.replace(/\/+$/,``),r=[`${n}${n.includes(`?`)?`&`:`?`}SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetCapabilities`,`${n}/WMTSCapabilities.xml`,`${n}/1.0.0/WMTSCapabilities.xml`],i=[];for(let n of r)try{let r=await fetch(n,{signal:AbortSignal.timeout(3e4)});if(!r.ok){i.push(`${n} → ${r.status}`);continue}let a=await r.text(),o=new DOMParser().parseFromString(a,`text/xml`);if(!o.querySelector(`Capabilities, WMT_MS_Capabilities`)){i.push(`${n} → not a WMTS capabilities document`);continue}return ku(o,e,t)}catch(e){i.push(`${n} → ${String(e)}`)}throw Error(`WMTS GetCapabilities failed:\n${i.join(`
|
|
560
|
-
`)}`)}function ku(e,t,n){let r=ju(e);if(r.size===0)throw Error(`No EPSG:3857 / WebMercatorQuad tile matrix sets`);let i=Array.from(e.querySelectorAll(`Contents > Layer`));if(i.length===0)throw Error(`No layers in capabilities document`);let a=i.map(e=>({id:Pu(e,`Identifier`)??``,title:Pu(e,`Title`)??Pu(e,`Identifier`)??``})),o=Mu(i,r,n);return Au(t,t.includes(`?`)?`&`:`?`,o,r,a)}function Au(e,t,n,r,i){let a=Pu(n,`Identifier`)??``,o=Pu(n,`Format`)??`image/png`,s=Nu(n,r),c=n.querySelector(`ResourceURL[resourceType="tile"]`);return c?{tileUrlTemplate:(c.getAttribute(`template`)??``).replace(/\{TileMatrixSet\}/g,s).replace(/\{TileMatrix\}/g,`{z}`).replace(/\{TileRow\}/g,`{y}`).replace(/\{TileCol\}/g,`{x}`),layerName:a,tileMatrixSet:s,format:o,availableLayers:i}:{tileUrlTemplate:`${e}${t}SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&LAYER=${encodeURIComponent(a)}&TILEMATRIXSET=${encodeURIComponent(s)}&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=${encodeURIComponent(o)}`,layerName:a,tileMatrixSet:s,format:o,availableLayers:i}}function ju(e){let t=new Set;for(let n of e.querySelectorAll(`Contents > TileMatrixSet`)){let e=Pu(n,`Identifier`)??``,r=Pu(n,`SupportedCRS`)??``;(e===`WebMercatorQuad`||e===`GoogleMapsCompatible`||r.includes(`3857`)||r.includes(`900913`))&&t.add(e)}return t}function Mu(e,t,n){if(n){let t=e.find(e=>Pu(e,`Identifier`)===n);if(t)return t}for(let n of e)for(let e of n.querySelectorAll(`TileMatrixSetLink > TileMatrixSet`))if(t.has(e.textContent??``))return n;return e[0]}function Nu(e,t){for(let n of e.querySelectorAll(`TileMatrixSetLink > TileMatrixSet`)){let e=n.textContent??``;if(t.has(e))return e}return t.values().next().value??`WebMercatorQuad`}function Pu(e,t){return e.querySelector(t)?.textContent??null}function Fu(e,t){return Ou(e,t)}function Iu(e,t){return Ou(e,t)}var Lu=`chart-wmts-overrides`,Ru=`chart-wmts-layer-sel`,zu=`chart-selected`;function Bu(e){try{let t=localStorage.getItem(e);if(t)return new Map(JSON.parse(t))}catch{}return new Map}function Vu(){try{let e=localStorage.getItem(zu);if(e)return new Set(JSON.parse(e))}catch{}return new Set}function Hu(e,t){localStorage.setItem(e,JSON.stringify([...t]))}function Uu(){let e=F(cn({})),t=new Su,n=Vu(),r=F(!1),i=F(null),a=``,o=new Cu,s=new Su,c=Bu(Lu),l=new Cu,u=new Cu,d=new Su,f=Bu(Ru);return{get available(){return V(e)},get selected(){return t},get loading(){return V(r)},get error(){return V(i)},get wmtsFailed(){return s},visibleLayers(e){return d.has(e)?l.get(e)??[]:u.get(e)??l.get(e)??[]},hasFilter(e){return(u.get(e)?.length??0)>0},isShowingAll(e){return d.has(e)},toggleShowAll(e){d.has(e)?d.delete(e):d.add(e)},needsManualUrl(t){let n=V(e)[t];return!!n&&n.type===`WMTS`&&s.has(t)&&!c.has(t)},getOverride(e){return c.get(e)??``},getLayerSel(e){return f.get(e)??``},setOverride(e,t){t.trim()?c.set(e,t.trim()):c.delete(e),Hu(Lu,c),s.delete(e),s.add(e)},async selectLayer(t,n){let r=V(e)[t];if(!r||r.type!==`WMTS`)return;let i=r.url&&r.url.startsWith(`/`)?`${a}${r.url}`:r.url??``;try{let e=await Iu(i,n);o.set(t,e.tileUrlTemplate),l.set(t,e.availableLayers),f.set(t,e.layerName),Hu(Ru,f)}catch(e){console.warn(`[charts] WMTS layer switch failed for ${t}:`,e)}},tileUrl(e){return e.type===`WMTS`?c.get(e.identifier)??o.get(e.identifier)??``:wu(e,a)??``},styleUrl(e){return e.style?e.style.startsWith(`/`)?`${a}${e.style}`:e.style:null},async load(d){a=d,I(r,!0),I(i,null);try{I(e,await Eu(d),!0);for(let r of n)r in V(e)&&t.add(r);n.clear();let r=Object.values(V(e)).filter(e=>e.type===`WMTS`&&!c.has(e.identifier)).map(async e=>{let t=e.url&&e.url.startsWith(`/`)?`${d}${e.url}`:e.url??``;if(!t){s.add(e.identifier);return}let n=f.get(e.identifier)??e.layers?.[0];try{let r=await Fu(t,n);if(o.set(e.identifier,r.tileUrlTemplate),l.set(e.identifier,r.availableLayers),e.layers&&e.layers.length>0){let t=new Map(r.availableLayers.map(e=>[e.id,e])),n=e.layers.map(e=>t.get(e)).filter(Boolean);n.length>0&&u.set(e.identifier,n)}f.has(e.identifier)||f.set(e.identifier,r.layerName)}catch{s.add(e.identifier)}});await Promise.allSettled(r)}catch(e){I(i,String(e),!0)}finally{I(r,!1)}},toggle(e){t.has(e)?t.delete(e):t.add(e),localStorage.setItem(zu,JSON.stringify([...t]))}}}var Y=Uu(),Wu=[{id:`osm`,name:`OpenStreetMap`},{id:`seamarks`,name:`OpenSeaMap`}],Gu=`base-layers-enabled`;function Ku(){try{let e=localStorage.getItem(Gu);if(e)return JSON.parse(e)}catch{}return Wu.map(e=>e.id)}function qu(){let e=new Su(Ku());return{get enabled(){return e},toggle(t){e.has(t)?e.delete(t):e.add(t),localStorage.setItem(Gu,JSON.stringify([...e]))}}}var Ju=qu();function Yu(){let e=F(null),t=F(cn([])),n=new Map,r=F(0);return{get hotData(){return V(e)},get ids(){return V(t)},get coldMap(){return n},get coldVersion(){return V(r)},get count(){return V(t).length},updateBinary(r,i,a){I(e,new Float64Array(r),!0),I(t,i,!0);for(let e of a){let t=n.get(e.id);n.set(e.id,{...t,id:e.id,name:e.name??t?.name,mmsi:e.mmsi??t?.mmsi})}},setInfoCache(e){for(let[t,r]of e){let e=n.get(t)??{id:t};n.set(t,{...e,name:r.name??e.name,callsign:r.callsign??e.callsign,callsignHf:r.callsignHf??e.callsignHf,skipperName:r.skipperName??e.skipperName,port:r.port??e.port,flag:r.flag??e.flag,shipType:r.shipType??e.shipType,navState:r.navState??e.navState,lengthM:r.lengthM??e.lengthM,beamM:r.beamM??e.beamM,draftM:r.draftM??e.draftM,airHeightM:r.airHeightM??e.airHeightM})}an(r)},getTarget(r){if(!V(e)||r<0||r>=V(t).length)return null;let i=r*7,a=V(t)[r],o=n.get(a),s=V(e)[i+0],c=V(e)[i+1],l=V(e)[i+2],u=V(e)[i+3],d=V(e)[i+4],f=V(e)[i+5],p=V(e)[i+6];return{id:a,mmsi:o?.mmsi,name:o?.name,position:{longitude:s,latitude:c},cog:isNaN(l)?void 0:l,sog:isNaN(u)?void 0:u,heading:isNaN(d)?void 0:d,rot:isNaN(f)?void 0:f,lastPositionUpdateMs:Date.now()-p*1e3,shipType:o?.shipType,navState:o?.navState,callsign:o?.callsign,callsignHf:o?.callsignHf,skipperName:o?.skipperName,port:o?.port,flag:o?.flag,lengthM:o?.lengthM,beamM:o?.beamM,draftM:o?.draftM,airHeightM:o?.airHeightM}}}}var Xu=Yu();function Zu(e,t){if(!e)throw Error(t||`loader assertion failed.`)}var Qu={self:typeof self<`u`&&self,window:typeof window<`u`&&window,global:typeof global<`u`&&global,document:typeof document<`u`&&document};Qu.self||Qu.window||Qu.global,Qu.window||Qu.self||Qu.global,Qu.global||Qu.self||Qu.window,Qu.document;var $u=!!(typeof process!=`object`||String(process)!==`[object process]`||process.browser),ed=typeof process<`u`&&process.version&&/v([0-9]*)/.exec(process.version);ed&&parseFloat(ed[1]);var td=globalThis;globalThis.document;var nd=globalThis.process||{};globalThis.console;var rd=globalThis.navigator||{};function id(e){if(typeof window<`u`&&window.process?.type===`renderer`||typeof process<`u`&&process.versions?.electron)return!0;let t=typeof navigator<`u`&&navigator.userAgent,n=e||t;return!!(n&&n.indexOf(`Electron`)>=0)}function ad(){return!(typeof process==`object`&&String(process)===`[object process]`&&!process?.browser)||id()}function od(e){return!e&&!ad()?`Node`:id(e)?`Electron`:(e||rd.userAgent||``).indexOf(`Edge`)>-1?`Edge`:globalThis.chrome?`Chrome`:globalThis.safari?`Safari`:globalThis.mozInnerScreenX?`Firefox`:`Unknown`}var sd=`4.1.1`;function cd(e,t){if(!e)throw Error(t||`Assertion failed`)}function ld(e){if(!e)return 0;let t;switch(typeof e){case`number`:t=e;break;case`object`:t=e.logLevel||e.priority||0;break;default:return 0}return cd(Number.isFinite(t)&&t>=0),t}function ud(e){let{logLevel:t,message:n}=e;e.logLevel=ld(t);let r=e.args?Array.from(e.args):[];for(;r.length&&r.shift()!==n;);switch(typeof t){case`string`:case`function`:n!==void 0&&r.unshift(n),e.message=t;break;case`object`:Object.assign(e,t);break;default:}typeof e.message==`function`&&(e.message=e.message());let i=typeof e.message;return cd(i===`string`||i===`object`),Object.assign(e,{args:r},e.opts)}var dd=()=>{},fd=class{constructor({level:e=0}={}){this.userData={},this._onceCache=new Set,this._level=e}set level(e){this.setLevel(e)}get level(){return this.getLevel()}setLevel(e){return this._level=e,this}getLevel(){return this._level}warn(e,...t){return this._log(`warn`,0,e,t,{once:!0})}error(e,...t){return this._log(`error`,0,e,t)}log(e,t,...n){return this._log(`log`,e,t,n)}info(e,t,...n){return this._log(`info`,e,t,n)}once(e,t,...n){return this._log(`once`,e,t,n,{once:!0})}_log(e,t,n,r,i={}){let a=ud({logLevel:t,message:n,args:this._buildArgs(t,n,r),opts:i});return this._createLogFunction(e,a,i)}_buildArgs(e,t,n){return[e,t,...n]}_createLogFunction(e,t,n){if(!this._shouldLog(t.logLevel))return dd;let r=this._getOnceTag(n.tag??t.tag??t.message);if((n.once||t.once)&&r!==void 0){if(this._onceCache.has(r))return dd;this._onceCache.add(r)}return this._emit(e,t)}_shouldLog(e){return this.getLevel()>=ld(e)}_getOnceTag(e){if(e!==void 0)try{return typeof e==`string`?e:String(e)}catch{return}}};function pd(e){try{let t=window[e],n=`__storage_test__`;return t.setItem(n,n),t.removeItem(n),t}catch{return null}}var md=class{constructor(e,t,n=`sessionStorage`){this.storage=pd(n),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}}_loadConfiguration(){let e={};if(this.storage){let t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}};function hd(e){let t;return t=e<10?`${e.toFixed(2)}ms`:e<100?`${e.toFixed(1)}ms`:e<1e3?`${e.toFixed(0)}ms`:`${(e/1e3).toFixed(2)}s`,t}function gd(e,t=8){let n=Math.max(t-e.length,0);return`${` `.repeat(n)}${e}`}var _d;(function(e){e[e.BLACK=30]=`BLACK`,e[e.RED=31]=`RED`,e[e.GREEN=32]=`GREEN`,e[e.YELLOW=33]=`YELLOW`,e[e.BLUE=34]=`BLUE`,e[e.MAGENTA=35]=`MAGENTA`,e[e.CYAN=36]=`CYAN`,e[e.WHITE=37]=`WHITE`,e[e.BRIGHT_BLACK=90]=`BRIGHT_BLACK`,e[e.BRIGHT_RED=91]=`BRIGHT_RED`,e[e.BRIGHT_GREEN=92]=`BRIGHT_GREEN`,e[e.BRIGHT_YELLOW=93]=`BRIGHT_YELLOW`,e[e.BRIGHT_BLUE=94]=`BRIGHT_BLUE`,e[e.BRIGHT_MAGENTA=95]=`BRIGHT_MAGENTA`,e[e.BRIGHT_CYAN=96]=`BRIGHT_CYAN`,e[e.BRIGHT_WHITE=97]=`BRIGHT_WHITE`})(_d||={});var vd=10;function yd(e){return typeof e==`string`?(e=e.toUpperCase(),_d[e]||_d.WHITE):e}function bd(e,t,n){return!ad&&typeof e==`string`&&(t&&(e=`\u001b[${yd(t)}m${e}\u001b[39m`),n&&(e=`\u001b[${yd(n)+vd}m${e}\u001b[49m`)),e}function xd(e,t=[`constructor`]){let n=Object.getOwnPropertyNames(Object.getPrototypeOf(e)),r=e;for(let i of n){let n=r[i];typeof n==`function`&&(t.find(e=>i===e)||(r[i]=n.bind(e)))}}function Sd(){let e;if(ad()&&td.performance)e=td?.performance?.now?.();else if(`hrtime`in nd){let t=nd?.hrtime?.();e=t[0]*1e3+t[1]/1e6}else e=Date.now();return e}var Cd={debug:ad()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},wd={enabled:!0,level:0},Td=class extends fd{constructor({id:e}={id:``}){super({level:0}),this.VERSION=sd,this._startTs=Sd(),this._deltaTs=Sd(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new md(`__probe-${this.id}__`,{[this.id]:wd}),this.timeStamp(`${this.id} started`),xd(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((Sd()-this._startTs).toPrecision(10))}getDelta(){return Number((Sd()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._updateConfiguration({enabled:e}),this}setLevel(e){return this._updateConfiguration({level:e}),this}get(e){return this._getConfiguration()[e]}set(e,t){this._updateConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){if(!e)throw Error(t||`Assertion failed`)}warn(e,...t){return this._log(`warn`,0,e,t,{method:Cd.warn,once:!0})}error(e,...t){return this._log(`error`,0,e,t,{method:Cd.error})}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed \
|
|
561
|
-
in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t,...n){return this._log(`log`,e,t,n,{method:
|
|
556
|
+
}`;function Os(){var e=Fo,t=Io,n=q.cssPrefix,r=q.replacementClass,i=Ds;if(n!==e||r!==t){var a=RegExp(`\\.${e}\\-`,`g`),o=RegExp(`\\--${e}\\-`,`g`),s=RegExp(`\\.${t}`,`g`);i=i.replace(a,`.${n}-`).replace(o,`--${n}-`).replace(s,`.${r}`)}return i}var ks=!1;function As(){q.autoAddCss&&!ks&&(gs(Os()),ks=!0)}var js={mixout:function(){return{dom:{css:Os,insertCss:As}}},hooks:function(){return{beforeDOMElementCreation:function(){As()},beforeI2svg:function(){As()}}}},Ms=fa||{};Ms[No]||(Ms[No]={}),Ms[No].styles||(Ms[No].styles={}),Ms[No].hooks||(Ms[No].hooks={}),Ms[No].shims||(Ms[No].shims=[]);var Ns=Ms[No],Ps=[],Fs=function(){pa.removeEventListener(`DOMContentLoaded`,Fs),Is=1,Ps.map(function(e){return e()})},Is=!1;ga&&(Is=(pa.documentElement.doScroll?/^loaded|^c/:/^loaded|^i|^c/).test(pa.readyState),Is||pa.addEventListener(`DOMContentLoaded`,Fs));function Ls(e){ga&&(Is?setTimeout(e,0):Ps.push(e))}function Rs(e){var t=e.tag,n=e.attributes,r=n===void 0?{}:n,i=e.children,a=i===void 0?[]:i;return typeof e==`string`?xs(e):`<${t} ${Ss(r)}>${a.map(Rs).join(``)}</${t}>`}function zs(e,t,n){if(e&&e[t]&&e[t][n])return{prefix:t,iconName:n,icon:e[t][n]}}var Bs=function(e,t){return function(n,r,i,a){return e.call(t,n,r,i,a)}},Vs=function(e,t,n,r){var i=Object.keys(e),a=i.length,o=r===void 0?t:Bs(t,r),s,c,l;for(n===void 0?(s=1,l=e[i[0]]):(s=0,l=n);s<a;s++)c=i[s],l=o(l,e[c],c,e);return l};function Hs(e){return ea(e).length===1?e.codePointAt(0).toString(16):null}function Us(e){return Object.keys(e).reduce(function(t,n){var r=e[n];return r.icon?t[r.iconName]=r.icon:t[n]=r,t},{})}function Ws(e,t){var n=(arguments.length>2&&arguments[2]!==void 0?arguments[2]:{}).skipHooks,r=n===void 0?!1:n,i=Us(t);typeof Ns.hooks.addPack==`function`&&!r?Ns.hooks.addPack(e,Us(t)):Ns.styles[e]=K(K({},Ns.styles[e]||{}),i),e===`fas`&&Ws(`fa`,t)}var Gs=Ns.styles,Ks=Ns.shims,qs=Object.keys($o),Js=qs.reduce(function(e,t){return e[t]=Object.keys($o[t]),e},{}),Ys=null,Xs={},Zs={},Qs={},$s={},ec={};function tc(e){return~os.indexOf(e)}function nc(e,t){var n=t.split(`-`),r=n[0],i=n.slice(1).join(`-`);return r===e&&i!==``&&!tc(i)?i:null}var rc=function(){var e=function(e){return Vs(Gs,function(t,n,r){return t[r]=Vs(n,e,{}),t},{})};Xs=e(function(e,t,n){return t[3]&&(e[t[3]]=n),t[2]&&t[2].filter(function(e){return typeof e==`number`}).forEach(function(t){e[t.toString(16)]=n}),e}),Zs=e(function(e,t,n){return e[n]=n,t[2]&&t[2].filter(function(e){return typeof e==`string`}).forEach(function(t){e[t]=n}),e}),ec=e(function(e,t,n){var r=t[2];return e[n]=n,r.forEach(function(t){e[t]=n}),e});var t=`far`in Gs||q.autoFetchSvg,n=Vs(Ks,function(e,n){var r=n[0],i=n[1],a=n[2];return i===`far`&&!t&&(i=`fas`),typeof r==`string`&&(e.names[r]={prefix:i,iconName:a}),typeof r==`number`&&(e.unicodes[r.toString(16)]={prefix:i,iconName:a}),e},{names:{},unicodes:{}});Qs=n.names,$s=n.unicodes,Ys=fc(q.styleDefault,{family:q.familyDefault})};ps(function(e){Ys=fc(e.styleDefault,{family:q.familyDefault})}),rc();function ic(e,t){return(Xs[e]||{})[t]}function ac(e,t){return(Zs[e]||{})[t]}function oc(e,t){return(ec[e]||{})[t]}function sc(e){return Qs[e]||{prefix:null,iconName:null}}function cc(e){var t=$s[e],n=ic(`fas`,e);return t||(n?{prefix:`fas`,iconName:n}:null)||{prefix:null,iconName:null}}function lc(){return Ys}var uc=function(){return{prefix:null,iconName:null,rest:[]}};function dc(e){var t=wa,n=qs.reduce(function(e,t){return e[t]=`${q.cssPrefix}-${t}`,e},{});return co.forEach(function(r){(e.includes(n[r])||e.some(function(e){return Js[r].includes(e)}))&&(t=r)}),t}function fc(e){var t=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}).family,n=t===void 0?wa:t,r=Yo[n][e];if(n===Ta&&!e)return`fad`;var i=Zo[n][e]||Zo[n][r],a=e in Ns.styles?e:null;return i||a||null}function pc(e){var t=[],n=null;return e.forEach(function(e){var r=nc(q.cssPrefix,e);r?n=r:e&&t.push(e)}),{iconName:n,rest:t}}function mc(e){return e.sort().filter(function(e,t,n){return n.indexOf(e)===t})}var hc=Do.concat(mo);function gc(e){var t=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}).skipLookups,n=t===void 0?!1:t,r=null,i=mc(e.filter(function(e){return hc.includes(e)})),a=mc(e.filter(function(e){return!hc.includes(e)})),o=$i(i.filter(function(e){return r=e,!Ca.includes(e)}),1)[0],s=o===void 0?null:o,c=dc(i),l=K(K({},pc(a)),{},{prefix:fc(s,{family:c})});return K(K(K({},l),bc({values:e,family:c,styles:Gs,config:q,canonical:l,givenPrefix:r})),_c(n,r,l))}function _c(e,t,n){var r=n.prefix,i=n.iconName;if(e||!r||!i)return{prefix:r,iconName:i};var a=t===`fa`?sc(i):{},o=oc(r,i);return i=a.iconName||o||i,r=a.prefix||r,r===`far`&&!Gs.far&&Gs.fas&&!q.autoFetchSvg&&(r=`fas`),{prefix:r,iconName:i}}var vc=co.filter(function(e){return e!==wa||e!==Ta}),yc=Object.keys(Eo).filter(function(e){return e!==wa}).map(function(e){return Object.keys(Eo[e])}).flat();function bc(e){var t=e.values,n=e.family,r=e.canonical,i=e.givenPrefix,a=i===void 0?``:i,o=e.styles,s=o===void 0?{}:o,c=e.config,l=c===void 0?{}:c,u=n===Ta,d=t.includes(`fa-duotone`)||t.includes(`fad`),f=l.familyDefault===`duotone`,p=r.prefix===`fad`||r.prefix===`fa-duotone`;return!u&&(d||f||p)&&(r.prefix=`fad`),(t.includes(`fa-brands`)||t.includes(`fab`))&&(r.prefix=`fab`),!r.prefix&&vc.includes(n)&&(Object.keys(s).find(function(e){return yc.includes(e)})||l.autoFetchSvg)&&(r.prefix=fo.get(n).defaultShortPrefixId,r.iconName=oc(r.prefix,r.iconName)||r.iconName),(r.prefix===`fa`||a===`fa`)&&(r.prefix=lc()||`fas`),r}var xc=function(){function e(){Wi(this,e),this.definitions={}}return Ki(e,[{key:`add`,value:function(){var e=this,t=[...arguments].reduce(this._pullDefinitions,{});Object.keys(t).forEach(function(n){e.definitions[n]=K(K({},e.definitions[n]||{}),t[n]),Ws(n,t[n]);var r=$o[wa][n];r&&Ws(r,t[n]),rc()})}},{key:`reset`,value:function(){this.definitions={}}},{key:`_pullDefinitions`,value:function(e,t){var n=t.prefix&&t.iconName&&t.icon?{0:t}:t;return Object.keys(n).map(function(t){var r=n[t],i=r.prefix,a=r.iconName,o=r.icon,s=o[2];e[i]||(e[i]={}),s.length>0&&s.forEach(function(t){typeof t==`string`&&(e[i][t]=o)}),e[i][a]=o}),e}}])}(),Sc=[],Cc={},wc={},Tc=Object.keys(wc);function Ec(e,t){var n=t.mixoutsTo;return Sc=e,Cc={},Object.keys(wc).forEach(function(e){Tc.indexOf(e)===-1&&delete wc[e]}),Sc.forEach(function(e){var t=e.mixout?e.mixout():{};if(Object.keys(t).forEach(function(e){typeof t[e]==`function`&&(n[e]=t[e]),ra(t[e])===`object`&&Object.keys(t[e]).forEach(function(r){n[e]||(n[e]={}),n[e][r]=t[e][r]})}),e.hooks){var r=e.hooks();Object.keys(r).forEach(function(e){Cc[e]||(Cc[e]=[]),Cc[e].push(r[e])})}e.provides&&e.provides(wc)}),n}function Dc(e,t){var n=[...arguments].slice(2);return(Cc[e]||[]).forEach(function(e){t=e.apply(null,[t].concat(n))}),t}function Oc(e){var t=[...arguments].slice(1);(Cc[e]||[]).forEach(function(e){e.apply(null,t)})}function kc(){var e=arguments[0],t=Array.prototype.slice.call(arguments,1);return wc[e]?wc[e].apply(null,t):void 0}function Ac(e){e.prefix===`fa`&&(e.prefix=`fas`);var t=e.iconName,n=e.prefix||lc();if(t)return t=oc(n,t)||t,zs(jc.definitions,n,t)||zs(Ns.styles,n,t)}var jc=new xc,Mc={noAuto:function(){q.autoReplaceSvg=!1,q.observeMutations=!1,Oc(`noAuto`)},config:q,dom:{i2svg:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return ga?(Oc(`beforeI2svg`,e),kc(`pseudoElements2svg`,e),kc(`i2svg`,e)):Promise.reject(Error(`Operation requires a DOM of some kind.`))},watch:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.autoReplaceSvgRoot;q.autoReplaceSvg===!1&&(q.autoReplaceSvg=!0),q.observeMutations=!0,Ls(function(){Nc({autoReplaceSvgRoot:t}),Oc(`watch`,e)})}},parse:{icon:function(e){if(e===null)return null;if(ra(e)===`object`&&e.prefix&&e.iconName)return{prefix:e.prefix,iconName:oc(e.prefix,e.iconName)||e.iconName};if(Array.isArray(e)&&e.length===2){var t=e[1].indexOf(`fa-`)===0?e[1].slice(3):e[1],n=fc(e[0]);return{prefix:n,iconName:oc(n,t)||t}}if(typeof e==`string`&&(e.indexOf(`${q.cssPrefix}-`)>-1||e.match(ts))){var r=gc(e.split(` `),{skipLookups:!0});return{prefix:r.prefix||lc(),iconName:oc(r.prefix,r.iconName)||r.iconName}}if(typeof e==`string`){var i=lc();return{prefix:i,iconName:oc(i,e)||e}}}},library:jc,findIconDefinition:Ac,toHtml:Rs},Nc=function(){var e=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}).autoReplaceSvgRoot,t=e===void 0?pa:e;(Object.keys(Ns.styles).length>0||q.autoFetchSvg)&&ga&&q.autoReplaceSvg&&Mc.dom.i2svg({node:t})};function Pc(e,t){return Object.defineProperty(e,"abstract",{get:t}),Object.defineProperty(e,"html",{get:function(){return e.abstract.map(function(e){return Rs(e)})}}),Object.defineProperty(e,"node",{get:function(){if(ga){var t=pa.createElement(`div`);return t.innerHTML=e.html,t.children}}}),e}function Fc(e){var t=e.children,n=e.main,r=e.mask,i=e.attributes,a=e.styles,o=e.transform;if(ws(o)&&n.found&&!r.found){var s={x:n.width/n.height/2,y:.5};i.style=Cs(K(K({},a),{},{"transform-origin":`${s.x+o.x/16}em ${s.y+o.y/16}em`}))}return[{tag:`svg`,attributes:i,children:t}]}function Ic(e){var t=e.prefix,n=e.iconName,r=e.children,i=e.attributes,a=e.symbol,o=a===!0?`${t}-${q.cssPrefix}-${n}`:a;return[{tag:`svg`,attributes:{style:`display: none;`},children:[{tag:`symbol`,attributes:K(K({},i),{},{id:o}),children:r}]}]}function Lc(e){return[`aria-label`,`aria-labelledby`,`title`,`role`].some(function(t){return t in e})}function Rc(e){var t=e.icons,n=t.main,r=t.mask,i=e.prefix,a=e.iconName,o=e.transform,s=e.symbol,c=e.maskId,l=e.extra,u=e.watchable,d=u===void 0?!1:u,f=r.found?r:n,p=f.width,m=f.height,h=[q.replacementClass,a?`${q.cssPrefix}-${a}`:``].filter(function(e){return l.classes.indexOf(e)===-1}).filter(function(e){return e!==``||!!e}).concat(l.classes).join(` `),g={children:[],attributes:K(K({},l.attributes),{},{"data-prefix":i,"data-icon":a,class:h,role:l.attributes.role||`img`,viewBox:`0 0 ${p} ${m}`})};!Lc(l.attributes)&&!l.attributes[`aria-hidden`]&&(g.attributes[`aria-hidden`]=`true`),d&&(g.attributes[Lo]=``);var _=K(K({},g),{},{prefix:i,iconName:a,main:n,mask:r,maskId:c,transform:o,symbol:s,styles:K({},l.styles)}),v=r.found&&n.found?kc(`generateAbstractMask`,_)||{children:[],attributes:{}}:kc(`generateAbstractIcon`,_)||{children:[],attributes:{}},y=v.children,b=v.attributes;return _.children=y,_.attributes=b,s?Ic(_):Fc(_)}function zc(e){var t=e.content,n=e.width,r=e.height,i=e.transform,a=e.extra,o=e.watchable,s=o===void 0?!1:o,c=K(K({},a.attributes),{},{class:a.classes.join(` `)});s&&(c[Lo]=``);var l=K({},a.styles);ws(i)&&(l.transform=Es({transform:i,startCentered:!0,width:n,height:r}),l[`-webkit-transform`]=l.transform);var u=Cs(l);u.length>0&&(c.style=u);var d=[];return d.push({tag:`span`,attributes:c,children:[t]}),d}function Bc(e){var t=e.content,n=e.extra,r=K(K({},n.attributes),{},{class:n.classes.join(` `)}),i=Cs(n.styles);i.length>0&&(r.style=i);var a=[];return a.push({tag:`span`,attributes:r,children:[t]}),a}var Vc=Ns.styles;function Hc(e){var t=e[0],n=e[1],r=$i(e.slice(4),1)[0],i=null;return i=Array.isArray(r)?{tag:`g`,attributes:{class:`${q.cssPrefix}-${as.GROUP}`},children:[{tag:`path`,attributes:{class:`${q.cssPrefix}-${as.SECONDARY}`,fill:`currentColor`,d:r[0]}},{tag:`path`,attributes:{class:`${q.cssPrefix}-${as.PRIMARY}`,fill:`currentColor`,d:r[1]}}]}:{tag:`path`,attributes:{fill:`currentColor`,d:r}},{found:!0,width:t,height:n,icon:i}}var Uc={found:!1,width:512,height:512};function Wc(e,t){!Ko&&!q.showMissingIcons&&e&&console.error(`Icon with name "${e}" and prefix "${t}" is missing.`)}function Gc(e,t){var n=t;return t===`fa`&&q.styleDefault!==null&&(t=lc()),new Promise(function(r,i){if(n===`fa`){var a=sc(e)||{};e=a.iconName||e,t=a.prefix||t}if(e&&t&&Vc[t]&&Vc[t][e]){var o=Vc[t][e];return r(Hc(o))}Wc(e,t),r(K(K({},Uc),{},{icon:q.showMissingIcons&&e&&kc(`missingIconAbstract`)||{}}))})}var Kc=function(){},qc=q.measurePerformance&&ha&&ha.mark&&ha.measure?ha:{mark:Kc,measure:Kc},Jc=`FA "7.2.0"`,Yc=function(e){return qc.mark(`${Jc} ${e} begins`),function(){return Xc(e)}},Xc=function(e){qc.mark(`${Jc} ${e} ends`),qc.measure(`${Jc} ${e}`,`${Jc} ${e} begins`,`${Jc} ${e} ends`)},Zc={begin:Yc,end:Xc},Qc=function(){};function $c(e){return typeof(e.getAttribute?e.getAttribute(Lo):null)==`string`}function el(e){var t=e.getAttribute?e.getAttribute(Bo):null,n=e.getAttribute?e.getAttribute(Vo):null;return t&&n}function tl(e){return e&&e.classList&&e.classList.contains&&e.classList.contains(q.replacementClass)}function nl(){return q.autoReplaceSvg===!0?sl.replace:sl[q.autoReplaceSvg]||sl.replace}function rl(e){return pa.createElementNS(`http://www.w3.org/2000/svg`,e)}function il(e){return pa.createElement(e)}function al(e){var t=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}).ceFn,n=t===void 0?e.tag===`svg`?rl:il:t;if(typeof e==`string`)return pa.createTextNode(e);var r=n(e.tag);return Object.keys(e.attributes||[]).forEach(function(t){r.setAttribute(t,e.attributes[t])}),(e.children||[]).forEach(function(e){r.appendChild(al(e,{ceFn:n}))}),r}function ol(e){var t=` ${e.outerHTML} `;return t=`${t}Font Awesome fontawesome.com `,t}var sl={replace:function(e){var t=e[0];if(t.parentNode)if(e[1].forEach(function(e){t.parentNode.insertBefore(al(e),t)}),t.getAttribute(Lo)===null&&q.keepOriginalSource){var n=pa.createComment(ol(t));t.parentNode.replaceChild(n,t)}else t.remove()},nest:function(e){var t=e[0],n=e[1];if(~bs(t).indexOf(q.replacementClass))return sl.replace(e);var r=RegExp(`${q.cssPrefix}-.*`);if(delete n[0].attributes.id,n[0].attributes.class){var i=n[0].attributes.class.split(` `).reduce(function(e,t){return t===q.replacementClass||t.match(r)?e.toSvg.push(t):e.toNode.push(t),e},{toNode:[],toSvg:[]});n[0].attributes.class=i.toSvg.join(` `),i.toNode.length===0?t.removeAttribute(`class`):t.setAttribute(`class`,i.toNode.join(` `))}var a=n.map(function(e){return Rs(e)}).join(`
|
|
557
|
+
`);t.setAttribute(Lo,``),t.innerHTML=a}};function cl(e){e()}function ll(e,t){var n=typeof t==`function`?t:Qc;if(e.length===0)n();else{var r=cl;q.mutateApproach===Uo&&(r=fa.requestAnimationFrame||cl),r(function(){var t=nl(),r=Zc.begin(`mutate`);e.map(t),r(),n()})}}var ul=!1;function dl(){ul=!0}function fl(){ul=!1}var pl=null;function ml(e){if(ma&&q.observeMutations){var t=e.treeCallback,n=t===void 0?Qc:t,r=e.nodeCallback,i=r===void 0?Qc:r,a=e.pseudoElementsCallback,o=a===void 0?Qc:a,s=e.observeMutationsRoot,c=s===void 0?pa:s;pl=new ma(function(e){if(!ul){var t=lc();ys(e).forEach(function(e){if(e.type===`childList`&&e.addedNodes.length>0&&!$c(e.addedNodes[0])&&(q.searchPseudoElements&&o(e.target),n(e.target)),e.type===`attributes`&&e.target.parentNode&&q.searchPseudoElements&&o([e.target],!0),e.type===`attributes`&&$c(e.target)&&~is.indexOf(e.attributeName))if(e.attributeName===`class`&&el(e.target)){var r=gc(bs(e.target)),a=r.prefix,s=r.iconName;e.target.setAttribute(Bo,a||t),s&&e.target.setAttribute(Vo,s)}else tl(e.target)&&i(e.target)})}}),ga&&pl.observe(c,{childList:!0,attributes:!0,characterData:!0,subtree:!0})}}function hl(){pl&&pl.disconnect()}function gl(e){var t=e.getAttribute(`style`),n=[];return t&&(n=t.split(`;`).reduce(function(e,t){var n=t.split(`:`),r=n[0],i=n.slice(1);return r&&i.length>0&&(e[r]=i.join(`:`).trim()),e},{})),n}function _l(e){var t=e.getAttribute(`data-prefix`),n=e.getAttribute(`data-icon`),r=e.innerText===void 0?``:e.innerText.trim(),i=gc(bs(e));return i.prefix||=lc(),t&&n&&(i.prefix=t,i.iconName=n),i.iconName&&i.prefix?i:(i.prefix&&r.length>0&&(i.iconName=ac(i.prefix,e.innerText)||ic(i.prefix,Hs(e.innerText))),!i.iconName&&q.autoFetchSvg&&e.firstChild&&e.firstChild.nodeType===Node.TEXT_NODE&&(i.iconName=e.firstChild.data),i)}function vl(e){return ys(e.attributes).reduce(function(e,t){return e.name!==`class`&&e.name!==`style`&&(e[t.name]=t.value),e},{})}function yl(){return{iconName:null,prefix:null,transform:hs,symbol:!1,mask:{iconName:null,prefix:null,rest:[]},maskId:null,extra:{classes:[],styles:{},attributes:{}}}}function bl(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{styleParser:!0},n=_l(e),r=n.iconName,i=n.prefix,a=n.rest,o=vl(e),s=Dc(`parseNodeAttributes`,{},e);return K({iconName:r,prefix:i,transform:hs,mask:{iconName:null,prefix:null,rest:[]},maskId:null,symbol:!1,extra:{classes:a,styles:t.styleParser?gl(e):[],attributes:o}},s)}var xl=Ns.styles;function Sl(e){var t=q.autoReplaceSvg===`nest`?bl(e,{styleParser:!1}):bl(e);return~t.extra.classes.indexOf(ns)?kc(`generateLayersText`,e,t):kc(`generateSvgReplacementMutation`,e,t)}function Cl(){return[].concat(ea(mo),ea(Do))}function wl(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(!ga)return Promise.resolve();var n=pa.documentElement.classList,r=function(e){return n.add(`${Ho}-${e}`)},i=function(e){return n.remove(`${Ho}-${e}`)},a=q.autoFetchSvg?Cl():Ca.concat(Object.keys(xl));a.includes(`fa`)||a.push(`fa`);var o=[`.${ns}:not([${Lo}])`].concat(a.map(function(e){return`.${e}:not([${Lo}])`})).join(`, `);if(o.length===0)return Promise.resolve();var s=[];try{s=ys(e.querySelectorAll(o))}catch{}if(s.length>0)r(`pending`),i(`complete`);else return Promise.resolve();var c=Zc.begin(`onTree`),l=s.reduce(function(e,t){try{var n=Sl(t);n&&e.push(n)}catch(e){Ko||e.name===`MissingIcon`&&console.error(e)}return e},[]);return new Promise(function(e,n){Promise.all(l).then(function(n){ll(n,function(){r(`active`),r(`complete`),i(`pending`),typeof t==`function`&&t(),c(),e()})}).catch(function(e){c(),n(e)})})}function Tl(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;Sl(e).then(function(e){e&&ll([e],t)})}function El(e){return function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=(t||{}).icon?t:Ac(t||{}),i=n.mask;return i&&=(i||{}).icon?i:Ac(i||{}),e(r,K(K({},n),{},{mask:i}))}}var Dl=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.transform,r=n===void 0?hs:n,i=t.symbol,a=i===void 0?!1:i,o=t.mask,s=o===void 0?null:o,c=t.maskId,l=c===void 0?null:c,u=t.classes,d=u===void 0?[]:u,f=t.attributes,p=f===void 0?{}:f,m=t.styles,h=m===void 0?{}:m;if(e){var g=e.prefix,_=e.iconName,v=e.icon;return Pc(K({type:`icon`},e),function(){return Oc(`beforeDOMElementCreation`,{iconDefinition:e,params:t}),Rc({icons:{main:Hc(v),mask:s?Hc(s.icon):{found:!1,width:null,height:null,icon:{}}},prefix:g,iconName:_,transform:K(K({},hs),r),symbol:a,maskId:l,extra:{attributes:p,styles:h,classes:d}})})}},Ol={mixout:function(){return{icon:El(Dl)}},hooks:function(){return{mutationObserverCallbacks:function(e){return e.treeCallback=wl,e.nodeCallback=Tl,e}}},provides:function(e){e.i2svg=function(e){var t=e.node,n=t===void 0?pa:t,r=e.callback;return wl(n,r===void 0?function(){}:r)},e.generateSvgReplacementMutation=function(e,t){var n=t.iconName,r=t.prefix,i=t.transform,a=t.symbol,o=t.mask,s=t.maskId,c=t.extra;return new Promise(function(t,l){Promise.all([Gc(n,r),o.iconName?Gc(o.iconName,o.prefix):Promise.resolve({found:!1,width:512,height:512,icon:{}})]).then(function(o){var l=$i(o,2),u=l[0],d=l[1];t([e,Rc({icons:{main:u,mask:d},prefix:r,iconName:n,transform:i,symbol:a,maskId:s,extra:c,watchable:!0})])}).catch(l)})},e.generateAbstractIcon=function(e){var t=e.children,n=e.attributes,r=e.main,i=e.transform,a=e.styles,o=Cs(a);o.length>0&&(n.style=o);var s;return ws(i)&&(s=kc(`generateAbstractTransformGrouping`,{main:r,transform:i,containerWidth:r.width,iconWidth:r.width})),t.push(s||r.icon),{children:t,attributes:n}}}},kl={mixout:function(){return{layer:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.classes,r=n===void 0?[]:n;return Pc({type:`layer`},function(){Oc(`beforeDOMElementCreation`,{assembler:e,params:t});var n=[];return e(function(e){Array.isArray(e)?e.map(function(e){n=n.concat(e.abstract)}):n=n.concat(e.abstract)}),[{tag:`span`,attributes:{class:[`${q.cssPrefix}-layers`].concat(ea(r)).join(` `)},children:n}]})}}}},Al={mixout:function(){return{counter:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.title,r=n===void 0?null:n,i=t.classes,a=i===void 0?[]:i,o=t.attributes,s=o===void 0?{}:o,c=t.styles,l=c===void 0?{}:c;return Pc({type:`counter`,content:e},function(){return Oc(`beforeDOMElementCreation`,{content:e,params:t}),Bc({content:e.toString(),title:r,extra:{attributes:s,styles:l,classes:[`${q.cssPrefix}-layers-counter`].concat(ea(a))}})})}}}},jl={mixout:function(){return{text:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.transform,r=n===void 0?hs:n,i=t.classes,a=i===void 0?[]:i,o=t.attributes,s=o===void 0?{}:o,c=t.styles,l=c===void 0?{}:c;return Pc({type:`text`,content:e},function(){return Oc(`beforeDOMElementCreation`,{content:e,params:t}),zc({content:e,transform:K(K({},hs),r),extra:{attributes:s,styles:l,classes:[`${q.cssPrefix}-layers-text`].concat(ea(a))}})})}}},provides:function(e){e.generateLayersText=function(e,t){var n=t.transform,r=t.extra,i=null,a=null;if(_a){var o=parseInt(getComputedStyle(e).fontSize,10),s=e.getBoundingClientRect();i=s.width/o,a=s.height/o}return Promise.resolve([e,zc({content:e.innerHTML,width:i,height:a,transform:n,extra:r,watchable:!0})])}}},Ml=RegExp(`"`,`ug`),Nl=[1105920,1112319],Pl=K(K(K(K({},{FontAwesome:{normal:`fas`,400:`fas`}}),uo),Mo),vo),Fl=Object.keys(Pl).reduce(function(e,t){return e[t.toLowerCase()]=Pl[t],e},{}),Il=Object.keys(Fl).reduce(function(e,t){var n=Fl[t];return e[t]=n[900]||ea(Object.entries(n))[0][1],e},{});function Ll(e){return Hs(ea(e.replace(Ml,``))[0]||``)}function Rl(e){var t=e.getPropertyValue(`font-feature-settings`).includes(`ss01`),n=e.getPropertyValue(`content`).replace(Ml,``),r=n.codePointAt(0),i=r>=Nl[0]&&r<=Nl[1],a=n.length===2?n[0]===n[1]:!1;return i||a||t}function zl(e,t){var n=e.replace(/^['"]|['"]$/g,``).toLowerCase(),r=parseInt(t),i=isNaN(r)?`normal`:r;return(Fl[n]||{})[i]||Il[n]}function Bl(e,t){var n=`${zo}${t.replace(`:`,`-`)}`;return new Promise(function(r,i){if(e.getAttribute(n)!==null)return r();var a=ys(e.children).filter(function(e){return e.getAttribute(Ro)===t})[0],o=fa.getComputedStyle(e,t),s=o.getPropertyValue(`font-family`),c=s.match(rs),l=o.getPropertyValue(`font-weight`),u=o.getPropertyValue(`content`);if(a&&!c)return e.removeChild(a),r();if(c&&u!==`none`&&u!==``){var d=o.getPropertyValue(`content`),f=zl(s,l),p=Ll(d),m=c[0].startsWith(`FontAwesome`),h=Rl(o),g=ic(f,p),_=g;if(m){var v=cc(p);v.iconName&&v.prefix&&(g=v.iconName,f=v.prefix)}if(g&&!h&&(!a||a.getAttribute(Bo)!==f||a.getAttribute(Vo)!==_)){e.setAttribute(n,_),a&&e.removeChild(a);var y=yl(),b=y.extra;b.attributes[Ro]=t,Gc(g,f).then(function(i){var a=Rc(K(K({},y),{},{icons:{main:i,mask:uc()},prefix:f,iconName:_,extra:b,watchable:!0})),o=pa.createElementNS(`http://www.w3.org/2000/svg`,`svg`);t===`::before`?e.insertBefore(o,e.firstChild):e.appendChild(o),o.outerHTML=a.map(function(e){return Rs(e)}).join(`
|
|
558
|
+
`),e.removeAttribute(n),r()}).catch(i)}else r()}else r()})}function Vl(e){return Promise.all([Bl(e,`::before`),Bl(e,`::after`)])}function Hl(e){return e.parentNode!==document.head&&!~Wo.indexOf(e.tagName.toUpperCase())&&!e.getAttribute(Ro)&&(!e.parentNode||e.parentNode.tagName!==`svg`)}var Ul=function(e){return!!e&&Go.some(function(t){return e.includes(t)})},Wl=function(e){if(!e)return[];var t=new Set,n=e.split(/,(?![^()]*\))/).map(function(e){return e.trim()});n=n.flatMap(function(e){return e.includes(`(`)?e:e.split(`,`).map(function(e){return e.trim()})});var r=qi(n),i;try{for(r.s();!(i=r.n()).done;){var a=i.value;if(Ul(a)){var o=Go.reduce(function(e,t){return e.replace(t,``)},a);o!==``&&o!==`*`&&t.add(o)}}}catch(e){r.e(e)}finally{r.f()}return t};function Gl(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(ga){var n;if(t)n=e;else if(q.searchPseudoElementsFullScan)n=e.querySelectorAll(`*`);else{var r=new Set,i=qi(document.styleSheets),a;try{for(i.s();!(a=i.n()).done;){var o=a.value;try{var s=qi(o.cssRules),c;try{for(s.s();!(c=s.n()).done;){var l=c.value,u=qi(Wl(l.selectorText)),d;try{for(u.s();!(d=u.n()).done;){var f=d.value;r.add(f)}}catch(e){u.e(e)}finally{u.f()}}}catch(e){s.e(e)}finally{s.f()}}catch(e){q.searchPseudoElementsWarnings&&console.warn(`Font Awesome: cannot parse stylesheet: ${o.href} (${e.message})
|
|
559
|
+
If it declares any Font Awesome CSS pseudo-elements, they will not be rendered as SVG icons. Add crossorigin="anonymous" to the <link>, enable searchPseudoElementsFullScan for slower but more thorough DOM parsing, or suppress this warning by setting searchPseudoElementsWarnings to false.`)}}}catch(e){i.e(e)}finally{i.f()}if(!r.size)return;var p=Array.from(r).join(`, `);try{n=e.querySelectorAll(p)}catch{}}return new Promise(function(e,t){var r=ys(n).filter(Hl).map(Vl),i=Zc.begin(`searchPseudoElements`);dl(),Promise.all(r).then(function(){i(),fl(),e()}).catch(function(){i(),fl(),t()})})}}var Kl={hooks:function(){return{mutationObserverCallbacks:function(e){return e.pseudoElementsCallback=Gl,e}}},provides:function(e){e.pseudoElements2svg=function(e){var t=e.node,n=t===void 0?pa:t;q.searchPseudoElements&&Gl(n)}}},ql=!1,Jl={mixout:function(){return{dom:{unwatch:function(){dl(),ql=!0}}}},hooks:function(){return{bootstrap:function(){ml(Dc(`mutationObserverCallbacks`,{}))},noAuto:function(){hl()},watch:function(e){var t=e.observeMutationsRoot;ql?fl():ml(Dc(`mutationObserverCallbacks`,{observeMutationsRoot:t}))}}}},Yl=function(e){return e.toLowerCase().split(` `).reduce(function(e,t){var n=t.toLowerCase().split(`-`),r=n[0],i=n.slice(1).join(`-`);if(r&&i===`h`)return e.flipX=!0,e;if(r&&i===`v`)return e.flipY=!0,e;if(i=parseFloat(i),isNaN(i))return e;switch(r){case`grow`:e.size+=i;break;case`shrink`:e.size-=i;break;case`left`:e.x-=i;break;case`right`:e.x+=i;break;case`up`:e.y-=i;break;case`down`:e.y+=i;break;case`rotate`:e.rotate+=i;break}return e},{size:16,x:0,y:0,flipX:!1,flipY:!1,rotate:0})},Xl={mixout:function(){return{parse:{transform:function(e){return Yl(e)}}}},hooks:function(){return{parseNodeAttributes:function(e,t){var n=t.getAttribute(`data-fa-transform`);return n&&(e.transform=Yl(n)),e}}},provides:function(e){e.generateAbstractTransformGrouping=function(e){var t=e.main,n=e.transform,r=e.containerWidth,i=e.iconWidth,a={outer:{transform:`translate(${r/2} 256)`},inner:{transform:`${`translate(${n.x*32}, ${n.y*32}) `} ${`scale(${n.size/16*(n.flipX?-1:1)}, ${n.size/16*(n.flipY?-1:1)}) `} ${`rotate(${n.rotate} 0 0)`}`},path:{transform:`translate(${i/2*-1} -256)`}};return{tag:`g`,attributes:K({},a.outer),children:[{tag:`g`,attributes:K({},a.inner),children:[{tag:t.icon.tag,children:t.icon.children,attributes:K(K({},t.icon.attributes),a.path)}]}]}}}},Zl={x:0,y:0,width:`100%`,height:`100%`};function Ql(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return e.attributes&&(e.attributes.fill||t)&&(e.attributes.fill=`black`),e}function $l(e){return e.tag===`g`?e.children:[e]}Ec([js,Ol,kl,Al,jl,Kl,Jl,Xl,{hooks:function(){return{parseNodeAttributes:function(e,t){var n=t.getAttribute(`data-fa-mask`),r=n?gc(n.split(` `).map(function(e){return e.trim()})):uc();return r.prefix||=lc(),e.mask=r,e.maskId=t.getAttribute(`data-fa-mask-id`),e}}},provides:function(e){e.generateAbstractMask=function(e){var t=e.children,n=e.attributes,r=e.main,i=e.mask,a=e.maskId,o=e.transform,s=r.width,c=r.icon,l=i.width,u=i.icon,d=Ts({transform:o,containerWidth:l,iconWidth:s}),f={tag:`rect`,attributes:K(K({},Zl),{},{fill:`white`})},p=c.children?{children:c.children.map(Ql)}:{},m={tag:`g`,attributes:K({},d.inner),children:[Ql(K({tag:c.tag,attributes:K(K({},c.attributes),d.path)},p))]},h={tag:`g`,attributes:K({},d.outer),children:[m]},g=`mask-${a||vs()}`,_=`clip-${a||vs()}`,v={tag:`mask`,attributes:K(K({},Zl),{},{id:g,maskUnits:`userSpaceOnUse`,maskContentUnits:`userSpaceOnUse`}),children:[f,h]},y={tag:`defs`,children:[{tag:`clipPath`,attributes:{id:_},children:$l(u)},v]};return t.push(y,{tag:`rect`,attributes:K({fill:`currentColor`,"clip-path":`url(#${_})`,mask:`url(#${g})`},Zl)}),{children:t,attributes:n}}}},{provides:function(e){var t=!1;fa.matchMedia&&(t=fa.matchMedia(`(prefers-reduced-motion: reduce)`).matches),e.missingIconAbstract=function(){var e=[],n={fill:`currentColor`},r={attributeType:`XML`,repeatCount:`indefinite`,dur:`2s`};e.push({tag:`path`,attributes:K(K({},n),{},{d:`M156.5,447.7l-12.6,29.5c-18.7-9.5-35.9-21.2-51.5-34.9l22.7-22.7C127.6,430.5,141.5,440,156.5,447.7z M40.6,272H8.5 c1.4,21.2,5.4,41.7,11.7,61.1L50,321.2C45.1,305.5,41.8,289,40.6,272z M40.6,240c1.4-18.8,5.2-37,11.1-54.1l-29.5-12.6 C14.7,194.3,10,216.7,8.5,240H40.6z M64.3,156.5c7.8-14.9,17.2-28.8,28.1-41.5L69.7,92.3c-13.7,15.6-25.5,32.8-34.9,51.5 L64.3,156.5z M397,419.6c-13.9,12-29.4,22.3-46.1,30.4l11.9,29.8c20.7-9.9,39.8-22.6,56.9-37.6L397,419.6z M115,92.4 c13.9-12,29.4-22.3,46.1-30.4l-11.9-29.8c-20.7,9.9-39.8,22.6-56.8,37.6L115,92.4z M447.7,355.5c-7.8,14.9-17.2,28.8-28.1,41.5 l22.7,22.7c13.7-15.6,25.5-32.9,34.9-51.5L447.7,355.5z M471.4,272c-1.4,18.8-5.2,37-11.1,54.1l29.5,12.6 c7.5-21.1,12.2-43.5,13.6-66.8H471.4z M321.2,462c-15.7,5-32.2,8.2-49.2,9.4v32.1c21.2-1.4,41.7-5.4,61.1-11.7L321.2,462z M240,471.4c-18.8-1.4-37-5.2-54.1-11.1l-12.6,29.5c21.1,7.5,43.5,12.2,66.8,13.6V471.4z M462,190.8c5,15.7,8.2,32.2,9.4,49.2h32.1 c-1.4-21.2-5.4-41.7-11.7-61.1L462,190.8z M92.4,397c-12-13.9-22.3-29.4-30.4-46.1l-29.8,11.9c9.9,20.7,22.6,39.8,37.6,56.9 L92.4,397z M272,40.6c18.8,1.4,36.9,5.2,54.1,11.1l12.6-29.5C317.7,14.7,295.3,10,272,8.5V40.6z M190.8,50 c15.7-5,32.2-8.2,49.2-9.4V8.5c-21.2,1.4-41.7,5.4-61.1,11.7L190.8,50z M442.3,92.3L419.6,115c12,13.9,22.3,29.4,30.5,46.1 l29.8-11.9C470,128.5,457.3,109.4,442.3,92.3z M397,92.4l22.7-22.7c-15.6-13.7-32.8-25.5-51.5-34.9l-12.6,29.5 C370.4,72.1,384.4,81.5,397,92.4z`})});var i=K(K({},r),{},{attributeName:`opacity`}),a={tag:`circle`,attributes:K(K({},n),{},{cx:`256`,cy:`364`,r:`28`}),children:[]};return t||a.children.push({tag:`animate`,attributes:K(K({},r),{},{attributeName:`r`,values:`28;14;28;28;14;28;`})},{tag:`animate`,attributes:K(K({},i),{},{values:`1;0;1;1;0;1;`})}),e.push(a),e.push({tag:`path`,attributes:K(K({},n),{},{opacity:`1`,d:`M263.7,312h-16c-6.6,0-12-5.4-12-12c0-71,77.4-63.9,77.4-107.8c0-20-17.8-40.2-57.4-40.2c-29.1,0-44.3,9.6-59.2,28.7 c-3.9,5-11.1,6-16.2,2.4l-13.1-9.2c-5.6-3.9-6.9-11.8-2.6-17.2c21.2-27.2,46.4-44.7,91.2-44.7c52.3,0,97.4,29.8,97.4,80.2 c0,67.6-77.4,63.5-77.4,107.8C275.7,306.6,270.3,312,263.7,312z`}),children:t?[]:[{tag:`animate`,attributes:K(K({},i),{},{values:`1;0;0;0;0;1;`})}]}),t||e.push({tag:`path`,attributes:K(K({},n),{},{opacity:`0`,d:`M232.5,134.5l7,168c0.3,6.4,5.6,11.5,12,11.5h9c6.4,0,11.7-5.1,12-11.5l7-168c0.3-6.8-5.2-12.5-12-12.5h-23 C237.7,122,232.2,127.7,232.5,134.5z`}),children:[{tag:`animate`,attributes:K(K({},i),{},{values:`0;0;1;1;0;0;`})}]}),{tag:`g`,attributes:{class:`missing`},children:e}}}},{hooks:function(){return{parseNodeAttributes:function(e,t){var n=t.getAttribute(`data-fa-symbol`);return e.symbol=n===null?!1:n===``?!0:n,e}}}}],{mixoutsTo:Mc}),Mc.noAuto,Mc.config,Mc.library,Mc.dom,Mc.parse,Mc.findIconDefinition,Mc.toHtml;var eu=Mc.icon;Mc.layer,Mc.text,Mc.counter;function tu(e,t){Ke(t,!0);let n=Jt(()=>eu(t.icon).html[0]);var r=Ur();di(Cn(r),()=>V(n)),W(e,r),qe()}var nu={prefix:`fas`,iconName:`expand`,icon:[448,512,[],`f065`,`M32 32C14.3 32 0 46.3 0 64l0 96c0 17.7 14.3 32 32 32s32-14.3 32-32l0-64 64 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 32zM64 352c0-17.7-14.3-32-32-32S0 334.3 0 352l0 96c0 17.7 14.3 32 32 32l96 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-64 0 0-64zM320 32c-17.7 0-32 14.3-32 32s14.3 32 32 32l64 0 0 64c0 17.7 14.3 32 32 32s32-14.3 32-32l0-96c0-17.7-14.3-32-32-32l-96 0zM448 352c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 64-64 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l96 0c17.7 0 32-14.3 32-32l0-96z`]},ru={prefix:`fas`,iconName:`map`,icon:[512,512,[128506,62072],`f279`,`M512 48c0-11.1-5.7-21.4-15.2-27.2s-21.2-6.4-31.1-1.4L349.5 77.5 170.1 17.6c-8.1-2.7-16.8-2.1-24.4 1.7l-128 64C6.8 88.8 0 99.9 0 112L0 464c0 11.1 5.7 21.4 15.2 27.2s21.2 6.4 31.1 1.4l116.1-58.1 179.4 59.8c8.1 2.7 16.8 2.1 24.4-1.7l128-64c10.8-5.4 17.7-16.5 17.7-28.6l0-352zM192 376.9l0-284.5 128 42.7 0 284.5-128-42.7z`]},iu={prefix:`fas`,iconName:`gear`,icon:[512,512,[9881,`cog`],`f013`,`M195.1 9.5C198.1-5.3 211.2-16 226.4-16l59.8 0c15.2 0 28.3 10.7 31.3 25.5L332 79.5c14.1 6 27.3 13.7 39.3 22.8l67.8-22.5c14.4-4.8 30.2 1.2 37.8 14.4l29.9 51.8c7.6 13.2 4.9 29.8-6.5 39.9L447 233.3c.9 7.4 1.3 15 1.3 22.7s-.5 15.3-1.3 22.7l53.4 47.5c11.4 10.1 14 26.8 6.5 39.9l-29.9 51.8c-7.6 13.1-23.4 19.2-37.8 14.4l-67.8-22.5c-12.1 9.1-25.3 16.7-39.3 22.8l-14.4 69.9c-3.1 14.9-16.2 25.5-31.3 25.5l-59.8 0c-15.2 0-28.3-10.7-31.3-25.5l-14.4-69.9c-14.1-6-27.2-13.7-39.3-22.8L73.5 432.3c-14.4 4.8-30.2-1.2-37.8-14.4L5.8 366.1c-7.6-13.2-4.9-29.8 6.5-39.9l53.4-47.5c-.9-7.4-1.3-15-1.3-22.7s.5-15.3 1.3-22.7L12.3 185.8c-11.4-10.1-14-26.8-6.5-39.9L35.7 94.1c7.6-13.2 23.4-19.2 37.8-14.4l67.8 22.5c12.1-9.1 25.3-16.7 39.3-22.8L195.1 9.5zM256.3 336a80 80 0 1 0 -.6-160 80 80 0 1 0 .6 160z`]},au={prefix:`fas`,iconName:`ruler`,icon:[576,512,[128207],`f545`,`M209.1 516.2c-18.7 18.7-49.1 18.7-67.9 0L28.1 403.1c-18.7-18.7-18.7-49.1 0-67.9l17-17 73.5 73.5c9.4 9.4 24.6 9.4 33.9 0s9.4-24.6 0-33.9l-73.5-73.5 33.9-33.9 50.9 50.9c9.4 9.4 24.6 9.4 33.9 0s9.4-24.6 0-33.9l-50.9-50.9 33.9-33.9 73.5 73.5c9.4 9.4 24.6 9.4 33.9 0s9.4-24.6 0-33.9l-73.5-73.5 33.9-33.9 50.9 50.9c9.4 9.4 24.6 9.4 33.9 0s9.4-24.6 0-33.9l-50.9-50.9 33.9-33.9 73.5 73.5c9.4 9.4 24.6 9.4 33.9 0s9.4-24.6 0-33.9l-73.5-73.5 17-17c18.7-18.7 49.1-18.7 67.9 0L548.5 108.9c18.7 18.7 18.7 49.1 0 67.9L209.1 516.2z`]},ou={prefix:`fas`,iconName:`globe`,icon:[512,512,[127760],`f0ac`,`M351.9 280l-190.9 0c2.9 64.5 17.2 123.9 37.5 167.4 11.4 24.5 23.7 41.8 35.1 52.4 11.2 10.5 18.9 12.2 22.9 12.2s11.7-1.7 22.9-12.2c11.4-10.6 23.7-28 35.1-52.4 20.3-43.5 34.6-102.9 37.5-167.4zM160.9 232l190.9 0C349 167.5 334.7 108.1 314.4 64.6 303 40.2 290.7 22.8 279.3 12.2 268.1 1.7 260.4 0 256.4 0s-11.7 1.7-22.9 12.2c-11.4 10.6-23.7 28-35.1 52.4-20.3 43.5-34.6 102.9-37.5 167.4zm-48 0C116.4 146.4 138.5 66.9 170.8 14.7 78.7 47.3 10.9 131.2 1.5 232l111.4 0zM1.5 280c9.4 100.8 77.2 184.7 169.3 217.3-32.3-52.2-54.4-131.7-57.9-217.3L1.5 280zm398.4 0c-3.5 85.6-25.6 165.1-57.9 217.3 92.1-32.7 159.9-116.5 169.3-217.3l-111.4 0zm111.4-48C501.9 131.2 434.1 47.3 342 14.7 374.3 66.9 396.4 146.4 399.9 232l111.4 0z`]},su={prefix:`fas`,iconName:`compress`,icon:[448,512,[],`f066`,`M160 64c0-17.7-14.3-32-32-32S96 46.3 96 64l0 64-64 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l96 0c17.7 0 32-14.3 32-32l0-96zM32 320c-17.7 0-32 14.3-32 32s14.3 32 32 32l64 0 0 64c0 17.7 14.3 32 32 32s32-14.3 32-32l0-96c0-17.7-14.3-32-32-32l-96 0zM352 64c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 96c0 17.7 14.3 32 32 32l96 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-64 0 0-64zM320 320c-17.7 0-32 14.3-32 32l0 96c0 17.7 14.3 32 32 32s32-14.3 32-32l0-64 64 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-96 0z`]},cu={prefix:`fas`,iconName:`location-crosshairs`,icon:[576,512,[`location`],`f601`,`M288-16c17.7 0 32 14.3 32 32l0 18.3c98.1 14 175.7 91.6 189.7 189.7l18.3 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-18.3 0c-14 98.1-91.6 175.7-189.7 189.7l0 18.3c0 17.7-14.3 32-32 32s-32-14.3-32-32l0-18.3C157.9 463.7 80.3 386.1 66.3 288L48 288c-17.7 0-32-14.3-32-32s14.3-32 32-32l18.3 0C80.3 125.9 157.9 48.3 256 34.3L256 16c0-17.7 14.3-32 32-32zM128 256a160 160 0 1 0 320 0 160 160 0 1 0 -320 0zm160-96a96 96 0 1 1 0 192 96 96 0 1 1 0-192z`]},lu={prefix:`fas`,iconName:`layer-group`,icon:[512,512,[],`f5fd`,`M232.5 5.2c14.9-6.9 32.1-6.9 47 0l218.6 101c8.5 3.9 13.9 12.4 13.9 21.8s-5.4 17.9-13.9 21.8l-218.6 101c-14.9 6.9-32.1 6.9-47 0L13.9 149.8C5.4 145.8 0 137.3 0 128s5.4-17.9 13.9-21.8L232.5 5.2zM48.1 218.4l164.3 75.9c27.7 12.8 59.6 12.8 87.3 0l164.3-75.9 34.1 15.8c8.5 3.9 13.9 12.4 13.9 21.8s-5.4 17.9-13.9 21.8l-218.6 101c-14.9 6.9-32.1 6.9-47 0L13.9 277.8C5.4 273.8 0 265.3 0 256s5.4-17.9 13.9-21.8l34.1-15.8zM13.9 362.2l34.1-15.8 164.3 75.9c27.7 12.8 59.6 12.8 87.3 0l164.3-75.9 34.1 15.8c8.5 3.9 13.9 12.4 13.9 21.8s-5.4 17.9-13.9 21.8l-218.6 101c-14.9 6.9-32.1 6.9-47 0L13.9 405.8C5.4 401.8 0 393.3 0 384s5.4-17.9 13.9-21.8z`]},uu=t(n()),du=ct({position:null,cog:null,sog:null,heading:null}),fu=`signalk-chart-settings`,pu={...hu(),useGeoLocation:!1,targetFps:60,appearance:{vesselColor:`#2563eb`,vesselSize:24,heading:{color:`#ffffff`,width:2,style:`solid`,lengthUnit:`nm`,lengthValue:.2},cog:{color:`#f59e0b`,width:2,style:`dashed`,lengthUnit:`min`,lengthValue:3},gc:{color:`#22c55e`,width:2,style:`dashed`,lengthUnit:`min`,lengthValue:3},ais:{vesselColor:`#f59e0b`,vesselSize:16,cog:{color:`#f59e0b`,width:1.5,style:`dashed`,lengthMinutes:3}},ruler:{color:`#ffdc32`,width:2},route:{bearing:{color:`#ff6d00`,width:2,style:`dashed`},segment:{color:`#e040fb`,width:2.5,style:`solid`},remaining:{color:`#e040fb`,width:2,style:`dashed`}}}},mu=`/signalk/v1/stream?subscribe=self`;function hu(){let e=window.location,t=parseInt(e.port||(e.protocol===`https:`?`443`:`80`));return{signalkProtocol:e.protocol===`https:`?`wss`:`ws`,signalkHost:e.hostname,signalkPort:t}}function gu(){try{let e=localStorage.getItem(fu);if(e){let t=JSON.parse(e);if(typeof t==`object`&&t){let e=t;return{...pu,...e,useGeoLocation:typeof e.useGeoLocation==`boolean`?e.useGeoLocation:pu.useGeoLocation,targetFps:typeof e.targetFps==`number`&&e.targetFps>0?e.targetFps:pu.targetFps,appearance:{...pu.appearance,...e.appearance??{},heading:{...pu.appearance.heading,...e.appearance?.heading??{}},cog:{...pu.appearance.cog,...e.appearance?.cog??{}},gc:{...pu.appearance.gc,...e.appearance?.gc??{}},ais:{...pu.appearance.ais,...e.appearance?.ais??{},cog:{...pu.appearance.ais.cog,...e.appearance?.ais?.cog??{}}},ruler:{...pu.appearance.ruler,...e.appearance?.ruler??{}},route:{bearing:{...pu.appearance.route.bearing,...e.appearance?.route?.bearing??{}},segment:{...pu.appearance.route.segment,...e.appearance?.route?.segment??{}},remaining:{...pu.appearance.route.remaining,...e.appearance?.route?.remaining??{}}}}}}}}catch{}return structuredClone(pu)}function _u(){let e=fn(gu()),t=F(null);return{get protocol(){return e.signalkProtocol},get host(){return e.signalkHost},get port(){return e.signalkPort},get useGeoLocation(){return e.useGeoLocation},get geoError(){return V(t)},get appearance(){return e.appearance},get targetFps(){return e.targetFps},get signalkUrl(){return`${e.signalkProtocol}://${e.signalkHost}:${String(e.signalkPort)}${mu}`},get signalkHttpUrl(){return`${e.signalkProtocol===`wss`?`https`:`http`}://${e.signalkHost}:${String(e.signalkPort)}`},apply(n){n.signalkProtocol!==void 0&&(e.signalkProtocol=n.signalkProtocol),n.signalkHost!==void 0&&(e.signalkHost=n.signalkHost),n.signalkPort!==void 0&&(e.signalkPort=n.signalkPort),n.useGeoLocation!==void 0&&(e.useGeoLocation=n.useGeoLocation,n.useGeoLocation&&I(t,null)),n.appearance!==void 0&&(e.appearance=n.appearance),n.targetFps!==void 0&&(e.targetFps=n.targetFps),localStorage.setItem(fu,JSON.stringify(e))},setGeoError(e){I(t,e,!0)},setTargetFps(t){e.targetFps=t,localStorage.setItem(fu,JSON.stringify(e))}}}var J=_u();function vu(){let e=F(0);return{get value(){return V(e)},set(t){I(e,t,!0)}}}var yu=vu();function bu(){let e=F(!1);return{get following(){return V(e)},set following(t){I(e,t,!0)}}}var xu=bu(),Su=[`north`,`cog`,`heading`,`course`],Cu={north:`N`,cog:`COG`,heading:`HDG`,course:`BRG`,manual:`MAN`};function wu(){let e=F(`north`),t=F(`north`);function n(e,t,n){return e===`heading`?t:e===`course`?n:!0}return{get mode(){return V(e)},get resumeMode(){return V(t)},get label(){return Cu[V(e)]},setManual(){V(e)!==`manual`&&(I(t,V(e),!0),I(e,`manual`))},toggle(r,i){if(V(e)===`manual`){I(e,V(t),!0);return}let a=V(e),o=Su.indexOf(a);for(let t=1;t<=Su.length;t++){let a=Su[(o+t)%Su.length];if(n(a,r,i)){I(e,a,!0);return}}}}}var Tu=wu(),Eu=[`forEach`,`isDisjointFrom`,`isSubsetOf`,`isSupersetOf`],Du=[`difference`,`intersection`,`symmetricDifference`,`union`],Ou=!1,ku=class e extends Set{#e=new Map;#t=F(0);#n=F(0);#r=vr||-1;constructor(e){if(super(),e){for(var t of e)super.add(t);this.#n.v=super.size}Ou||this.#a()}#i(e){return vr===this.#r?F(e):an(e)}#a(){Ou=!0;var t=e.prototype,n=Set.prototype;for(let e of Eu)t[e]=function(...t){return V(this.#t),n[e].apply(this,t)};for(let r of Du)t[r]=function(...t){return V(this.#t),new e(n[r].apply(this,t))}}has(e){var t=super.has(e),n=this.#e,r=n.get(e);if(r===void 0){if(!t)return V(this.#t),!1;r=this.#i(!0),n.set(e,r)}return V(r),t}add(e){return super.has(e)||(super.add(e),I(this.#n,super.size),un(this.#t)),this}delete(e){var t=super.delete(e),n=this.#e,r=n.get(e);return r!==void 0&&(n.delete(e),I(r,!1)),t&&(I(this.#n,super.size),un(this.#t)),t}clear(){if(super.size!==0){super.clear();var e=this.#e;for(var t of e.values())I(t,!1);e.clear(),I(this.#n,0),un(this.#t)}}keys(){return this.values()}values(){return V(this.#t),super.values()}entries(){return V(this.#t),super.entries()}[Symbol.iterator](){return this.keys()}get size(){return V(this.#n)}},Au=class extends Map{#e=new Map;#t=F(0);#n=F(0);#r=vr||-1;constructor(e){if(super(),e){for(var[t,n]of e)super.set(t,n);this.#n.v=super.size}}#i(e){return vr===this.#r?F(e):an(e)}has(e){var t=this.#e,n=t.get(e);if(n===void 0)if(super.has(e))n=this.#i(0),t.set(e,n);else return V(this.#t),!1;return V(n),!0}forEach(e,t){this.#a(),super.forEach(e,t)}get(e){var t=this.#e,n=t.get(e);if(n===void 0)if(super.has(e))n=this.#i(0),t.set(e,n);else{V(this.#t);return}return V(n),super.get(e)}set(e,t){var n=this.#e,r=n.get(e),i=super.get(e),a=super.set(e,t),o=this.#t;if(r===void 0)r=this.#i(0),n.set(e,r),I(this.#n,super.size),un(o);else if(i!==t){un(r);var s=o.reactions===null?null:new Set(o.reactions);(s===null||!r.reactions?.every(e=>s.has(e)))&&un(o)}return a}delete(e){var t=this.#e,n=t.get(e),r=super.delete(e);return n!==void 0&&(t.delete(e),I(n,-1)),r&&(I(this.#n,super.size),un(this.#t)),r}clear(){if(super.size!==0){super.clear();var e=this.#e;I(this.#n,0);for(var t of e.values())I(t,-1);un(this.#t),e.clear()}}#a(){V(this.#t);var e=this.#e;if(this.#n.v!==e.size){for(var t of super.keys())if(!e.has(t)){var n=this.#i(0);e.set(t,n)}}for([,n]of this.#e)V(n)}keys(){return V(this.#t),super.keys()}values(){return this.#a(),super.values()}entries(){return this.#a(),super.entries()}[Symbol.iterator](){return this.entries()}get size(){return V(this.#n),super.size}};function ju(e,t){if(!e.url)return null;let n=e.url.startsWith(`/`)?`${t}${e.url}`:e.url;if(e.type===`WMS`){let t=e.layers?.join(`,`)??``,r=Mu(e.format),i=e.wmsVersion??`1.3.0`,a=i.startsWith(`1.1`)?`SRS`:`CRS`;return`${n}${n.includes(`?`)?`&`:`?`}SERVICE=WMS&VERSION=${i}&REQUEST=GetMap&${a}=EPSG:3857&BBOX={bbox-epsg-3857}&WIDTH=256&HEIGHT=256&LAYERS=${encodeURIComponent(t)}&STYLES=&FORMAT=${encodeURIComponent(r)}&TRANSPARENT=TRUE`}if(e.type===`WMTS`){if(!n.includes(`{z}`)){let t=e.layers?.[0]??``,r=Mu(e.format);return`${n}${n.includes(`?`)?`&`:`?`}SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&LAYER=${encodeURIComponent(t)}&TILEMATRIXSET=EPSG:3857&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=${encodeURIComponent(r)}`}return n}return n}function Mu(e){switch(e.toLowerCase()){case`png`:return`image/png`;case`jpg`:case`jpeg`:return`image/jpeg`;case`pbf`:return`application/vnd.mapbox-vector-tile`;case`webp`:return`image/webp`;default:return`image/${e}`}}async function Nu(e){let t=await fetch(`${e}/signalk/v2/api/resources/charts`);if(!t.ok)throw Error(`Charts API error: ${String(t.status)} ${t.statusText}`);return t.json()}async function Pu(e){let t=await fetch(`${e}/signalk/v1/api/vessels`);if(!t.ok)return new Map;let n=await t.json(),r=new Map;for(let[e,t]of Object.entries(n)){let n=t.design,i={};t.name&&(i.name=t.name),t.port&&(i.port=t.port),t.flag&&(i.flag=t.flag),t.communication?.callsignVhf&&(i.callsign=t.communication.callsignVhf),t.communication?.callsignHf&&(i.callsignHf=t.communication.callsignHf),t.communication?.skipperName&&(i.skipperName=t.communication.skipperName),t.navigation?.state?.value&&(i.navState=t.navigation.state.value),n?.aisShipType?.value?.name&&(i.shipType=n.aisShipType.value.name),n?.length?.value?.overall!==void 0&&(i.lengthM=n.length.value.overall),typeof n?.beam?.value==`number`&&(i.beamM=n.beam.value);let a=n?.draft?.value?.current??n?.draft?.value?.maximum;a!==void 0&&(i.draftM=a),typeof n?.airHeight?.value==`number`&&(i.airHeightM=n.airHeight.value),r.set(e,i)}return r}async function Fu(e,t){let n=e.replace(/\/+$/,``),r=[`${n}${n.includes(`?`)?`&`:`?`}SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetCapabilities`,`${n}/WMTSCapabilities.xml`,`${n}/1.0.0/WMTSCapabilities.xml`],i=[];for(let n of r)try{let r=await fetch(n,{signal:AbortSignal.timeout(3e4)});if(!r.ok){i.push(`${n} → ${r.status}`);continue}let a=await r.text(),o=new DOMParser().parseFromString(a,`text/xml`);if(!o.querySelector(`Capabilities, WMT_MS_Capabilities`)){i.push(`${n} → not a WMTS capabilities document`);continue}return Iu(o,e,t)}catch(e){i.push(`${n} → ${String(e)}`)}throw Error(`WMTS GetCapabilities failed:\n${i.join(`
|
|
560
|
+
`)}`)}function Iu(e,t,n){let r=Ru(e);if(r.size===0)throw Error(`No EPSG:3857 / WebMercatorQuad tile matrix sets`);let i=Array.from(e.querySelectorAll(`Contents > Layer`));if(i.length===0)throw Error(`No layers in capabilities document`);let a=i.map(e=>({id:Vu(e,`Identifier`)??``,title:Vu(e,`Title`)??Vu(e,`Identifier`)??``})),o=zu(i,r,n);return Lu(t,t.includes(`?`)?`&`:`?`,o,r,a)}function Lu(e,t,n,r,i){let a=Vu(n,`Identifier`)??``,o=Vu(n,`Format`)??`image/png`,s=Bu(n,r),c=n.querySelector(`ResourceURL[resourceType="tile"]`);return c?{tileUrlTemplate:(c.getAttribute(`template`)??``).replace(/\{TileMatrixSet\}/g,s).replace(/\{TileMatrix\}/g,`{z}`).replace(/\{TileRow\}/g,`{y}`).replace(/\{TileCol\}/g,`{x}`),layerName:a,tileMatrixSet:s,format:o,availableLayers:i}:{tileUrlTemplate:`${e}${t}SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&LAYER=${encodeURIComponent(a)}&TILEMATRIXSET=${encodeURIComponent(s)}&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=${encodeURIComponent(o)}`,layerName:a,tileMatrixSet:s,format:o,availableLayers:i}}function Ru(e){let t=new Set;for(let n of e.querySelectorAll(`Contents > TileMatrixSet`)){let e=Vu(n,`Identifier`)??``,r=Vu(n,`SupportedCRS`)??``;(e===`WebMercatorQuad`||e===`GoogleMapsCompatible`||r.includes(`3857`)||r.includes(`900913`))&&t.add(e)}return t}function zu(e,t,n){if(n){let t=e.find(e=>Vu(e,`Identifier`)===n);if(t)return t}for(let n of e)for(let e of n.querySelectorAll(`TileMatrixSetLink > TileMatrixSet`))if(t.has(e.textContent??``))return n;return e[0]}function Bu(e,t){for(let n of e.querySelectorAll(`TileMatrixSetLink > TileMatrixSet`)){let e=n.textContent??``;if(t.has(e))return e}return t.values().next().value??`WebMercatorQuad`}function Vu(e,t){return e.querySelector(t)?.textContent??null}function Hu(e,t){return Fu(e,t)}function Uu(e,t){return Fu(e,t)}var Wu=`chart-wmts-overrides`,Gu=`chart-wmts-layer-sel`,Ku=`chart-selected`;function qu(e){try{let t=localStorage.getItem(e);if(t)return new Map(JSON.parse(t))}catch{}return new Map}function Ju(){try{let e=localStorage.getItem(Ku);if(e)return new Set(JSON.parse(e))}catch{}return new Set}function Yu(e,t){localStorage.setItem(e,JSON.stringify([...t]))}function Xu(){let e=F(fn({})),t=new ku,n=Ju(),r=F(!1),i=F(null),a=``,o=new Au,s=new ku,c=qu(Wu),l=new Au,u=new Au,d=new ku,f=qu(Gu);return{get available(){return V(e)},get selected(){return t},get loading(){return V(r)},get error(){return V(i)},get wmtsFailed(){return s},visibleLayers(e){return d.has(e)?l.get(e)??[]:u.get(e)??l.get(e)??[]},hasFilter(e){return(u.get(e)?.length??0)>0},isShowingAll(e){return d.has(e)},toggleShowAll(e){d.has(e)?d.delete(e):d.add(e)},needsManualUrl(t){let n=V(e)[t];return!!n&&n.type===`WMTS`&&s.has(t)&&!c.has(t)},getOverride(e){return c.get(e)??``},getLayerSel(e){return f.get(e)??``},setOverride(e,t){t.trim()?c.set(e,t.trim()):c.delete(e),Yu(Wu,c),s.delete(e),s.add(e)},async selectLayer(t,n){let r=V(e)[t];if(!r||r.type!==`WMTS`)return;let i=r.url&&r.url.startsWith(`/`)?`${a}${r.url}`:r.url??``;try{let e=await Uu(i,n);o.set(t,e.tileUrlTemplate),l.set(t,e.availableLayers),f.set(t,e.layerName),Yu(Gu,f)}catch(e){console.warn(`[charts] WMTS layer switch failed for ${t}:`,e)}},tileUrl(e){return e.type===`WMTS`?c.get(e.identifier)??o.get(e.identifier)??``:ju(e,a)??``},styleUrl(e){return e.style?e.style.startsWith(`/`)?`${a}${e.style}`:e.style:null},async load(d){a=d,I(r,!0),I(i,null);try{I(e,await Nu(d),!0);for(let r of n)r in V(e)&&t.add(r);n.clear();let r=Object.values(V(e)).filter(e=>e.type===`WMTS`&&!c.has(e.identifier)).map(async e=>{let t=e.url&&e.url.startsWith(`/`)?`${d}${e.url}`:e.url??``;if(!t){s.add(e.identifier);return}let n=f.get(e.identifier)??e.layers?.[0];try{let r=await Hu(t,n);if(o.set(e.identifier,r.tileUrlTemplate),l.set(e.identifier,r.availableLayers),e.layers&&e.layers.length>0){let t=new Map(r.availableLayers.map(e=>[e.id,e])),n=e.layers.map(e=>t.get(e)).filter(Boolean);n.length>0&&u.set(e.identifier,n)}f.has(e.identifier)||f.set(e.identifier,r.layerName)}catch{s.add(e.identifier)}});await Promise.allSettled(r)}catch(e){I(i,String(e),!0)}finally{I(r,!1)}},toggle(e){t.has(e)?t.delete(e):t.add(e),localStorage.setItem(Ku,JSON.stringify([...t]))}}}var Y=Xu(),Zu=[{id:`osm`,name:`OpenStreetMap`},{id:`seamarks`,name:`OpenSeaMap`}],Qu=`base-layers-enabled`;function $u(){try{let e=localStorage.getItem(Qu);if(e)return JSON.parse(e)}catch{}return Zu.map(e=>e.id)}function ed(){let e=new ku($u());return{get enabled(){return e},toggle(t){e.has(t)?e.delete(t):e.add(t),localStorage.setItem(Qu,JSON.stringify([...e]))}}}var td=ed();function nd(){let e=F(null),t=F(fn([])),n=new Map,r=F(0);return{get hotData(){return V(e)},get ids(){return V(t)},get coldMap(){return n},get coldVersion(){return V(r)},get count(){return V(t).length},updateBinary(r,i,a){I(e,new Float64Array(r),!0),I(t,i,!0);for(let e of a){let t=n.get(e.id);n.set(e.id,{...t,id:e.id,name:e.name??t?.name,mmsi:e.mmsi??t?.mmsi})}},setInfoCache(e){for(let[t,r]of e){let e=n.get(t)??{id:t};n.set(t,{...e,name:r.name??e.name,callsign:r.callsign??e.callsign,callsignHf:r.callsignHf??e.callsignHf,skipperName:r.skipperName??e.skipperName,port:r.port??e.port,flag:r.flag??e.flag,shipType:r.shipType??e.shipType,navState:r.navState??e.navState,lengthM:r.lengthM??e.lengthM,beamM:r.beamM??e.beamM,draftM:r.draftM??e.draftM,airHeightM:r.airHeightM??e.airHeightM})}ln(r)},getTarget(r){if(!V(e)||r<0||r>=V(t).length)return null;let i=r*7,a=V(t)[r],o=n.get(a),s=V(e)[i+0],c=V(e)[i+1],l=V(e)[i+2],u=V(e)[i+3],d=V(e)[i+4],f=V(e)[i+5],p=V(e)[i+6];return{id:a,mmsi:o?.mmsi,name:o?.name,position:{longitude:s,latitude:c},cog:isNaN(l)?void 0:l,sog:isNaN(u)?void 0:u,heading:isNaN(d)?void 0:d,rot:isNaN(f)?void 0:f,lastPositionUpdateMs:Date.now()-p*1e3,shipType:o?.shipType,navState:o?.navState,callsign:o?.callsign,callsignHf:o?.callsignHf,skipperName:o?.skipperName,port:o?.port,flag:o?.flag,lengthM:o?.lengthM,beamM:o?.beamM,draftM:o?.draftM,airHeightM:o?.airHeightM}}}}var rd=nd();function id(e,t){if(!e)throw Error(t||`loader assertion failed.`)}var ad={self:typeof self<`u`&&self,window:typeof window<`u`&&window,global:typeof global<`u`&&global,document:typeof document<`u`&&document};ad.self||ad.window||ad.global,ad.window||ad.self||ad.global,ad.global||ad.self||ad.window,ad.document;var od=!!(typeof process!=`object`||String(process)!==`[object process]`||process.browser),sd=typeof process<`u`&&process.version&&/v([0-9]*)/.exec(process.version);sd&&parseFloat(sd[1]);var cd=globalThis;globalThis.document;var ld=globalThis.process||{};globalThis.console;var ud=globalThis.navigator||{};function dd(e){if(typeof window<`u`&&window.process?.type===`renderer`||typeof process<`u`&&process.versions?.electron)return!0;let t=typeof navigator<`u`&&navigator.userAgent,n=e||t;return!!(n&&n.indexOf(`Electron`)>=0)}function fd(){return!(typeof process==`object`&&String(process)===`[object process]`&&!process?.browser)||dd()}function pd(e){return!e&&!fd()?`Node`:dd(e)?`Electron`:(e||ud.userAgent||``).indexOf(`Edge`)>-1?`Edge`:globalThis.chrome?`Chrome`:globalThis.safari?`Safari`:globalThis.mozInnerScreenX?`Firefox`:`Unknown`}var md=`4.1.1`;function hd(e,t){if(!e)throw Error(t||`Assertion failed`)}function gd(e){if(!e)return 0;let t;switch(typeof e){case`number`:t=e;break;case`object`:t=e.logLevel||e.priority||0;break;default:return 0}return hd(Number.isFinite(t)&&t>=0),t}function _d(e){let{logLevel:t,message:n}=e;e.logLevel=gd(t);let r=e.args?Array.from(e.args):[];for(;r.length&&r.shift()!==n;);switch(typeof t){case`string`:case`function`:n!==void 0&&r.unshift(n),e.message=t;break;case`object`:Object.assign(e,t);break;default:}typeof e.message==`function`&&(e.message=e.message());let i=typeof e.message;return hd(i===`string`||i===`object`),Object.assign(e,{args:r},e.opts)}var vd=()=>{},yd=class{constructor({level:e=0}={}){this.userData={},this._onceCache=new Set,this._level=e}set level(e){this.setLevel(e)}get level(){return this.getLevel()}setLevel(e){return this._level=e,this}getLevel(){return this._level}warn(e,...t){return this._log(`warn`,0,e,t,{once:!0})}error(e,...t){return this._log(`error`,0,e,t)}log(e,t,...n){return this._log(`log`,e,t,n)}info(e,t,...n){return this._log(`info`,e,t,n)}once(e,t,...n){return this._log(`once`,e,t,n,{once:!0})}_log(e,t,n,r,i={}){let a=_d({logLevel:t,message:n,args:this._buildArgs(t,n,r),opts:i});return this._createLogFunction(e,a,i)}_buildArgs(e,t,n){return[e,t,...n]}_createLogFunction(e,t,n){if(!this._shouldLog(t.logLevel))return vd;let r=this._getOnceTag(n.tag??t.tag??t.message);if((n.once||t.once)&&r!==void 0){if(this._onceCache.has(r))return vd;this._onceCache.add(r)}return this._emit(e,t)}_shouldLog(e){return this.getLevel()>=gd(e)}_getOnceTag(e){if(e!==void 0)try{return typeof e==`string`?e:String(e)}catch{return}}};function bd(e){try{let t=window[e],n=`__storage_test__`;return t.setItem(n,n),t.removeItem(n),t}catch{return null}}var xd=class{constructor(e,t,n=`sessionStorage`){this.storage=bd(n),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}}_loadConfiguration(){let e={};if(this.storage){let t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}};function Sd(e){let t;return t=e<10?`${e.toFixed(2)}ms`:e<100?`${e.toFixed(1)}ms`:e<1e3?`${e.toFixed(0)}ms`:`${(e/1e3).toFixed(2)}s`,t}function Cd(e,t=8){let n=Math.max(t-e.length,0);return`${` `.repeat(n)}${e}`}var wd;(function(e){e[e.BLACK=30]=`BLACK`,e[e.RED=31]=`RED`,e[e.GREEN=32]=`GREEN`,e[e.YELLOW=33]=`YELLOW`,e[e.BLUE=34]=`BLUE`,e[e.MAGENTA=35]=`MAGENTA`,e[e.CYAN=36]=`CYAN`,e[e.WHITE=37]=`WHITE`,e[e.BRIGHT_BLACK=90]=`BRIGHT_BLACK`,e[e.BRIGHT_RED=91]=`BRIGHT_RED`,e[e.BRIGHT_GREEN=92]=`BRIGHT_GREEN`,e[e.BRIGHT_YELLOW=93]=`BRIGHT_YELLOW`,e[e.BRIGHT_BLUE=94]=`BRIGHT_BLUE`,e[e.BRIGHT_MAGENTA=95]=`BRIGHT_MAGENTA`,e[e.BRIGHT_CYAN=96]=`BRIGHT_CYAN`,e[e.BRIGHT_WHITE=97]=`BRIGHT_WHITE`})(wd||={});var Td=10;function Ed(e){return typeof e==`string`?(e=e.toUpperCase(),wd[e]||wd.WHITE):e}function Dd(e,t,n){return!fd&&typeof e==`string`&&(t&&(e=`\u001b[${Ed(t)}m${e}\u001b[39m`),n&&(e=`\u001b[${Ed(n)+Td}m${e}\u001b[49m`)),e}function Od(e,t=[`constructor`]){let n=Object.getOwnPropertyNames(Object.getPrototypeOf(e)),r=e;for(let i of n){let n=r[i];typeof n==`function`&&(t.find(e=>i===e)||(r[i]=n.bind(e)))}}function kd(){let e;if(fd()&&cd.performance)e=cd?.performance?.now?.();else if(`hrtime`in ld){let t=ld?.hrtime?.();e=t[0]*1e3+t[1]/1e6}else e=Date.now();return e}var Ad={debug:fd()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},jd={enabled:!0,level:0},Md=class extends yd{constructor({id:e}={id:``}){super({level:0}),this.VERSION=md,this._startTs=kd(),this._deltaTs=kd(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new xd(`__probe-${this.id}__`,{[this.id]:jd}),this.timeStamp(`${this.id} started`),Od(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((kd()-this._startTs).toPrecision(10))}getDelta(){return Number((kd()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._updateConfiguration({enabled:e}),this}setLevel(e){return this._updateConfiguration({level:e}),this}get(e){return this._getConfiguration()[e]}set(e,t){this._updateConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){if(!e)throw Error(t||`Assertion failed`)}warn(e,...t){return this._log(`warn`,0,e,t,{method:Ad.warn,once:!0})}error(e,...t){return this._log(`error`,0,e,t,{method:Ad.error})}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed \
|
|
561
|
+
in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t,...n){return this._log(`log`,e,t,n,{method:Ad.log,time:!0,once:!0})}log(e,t,...n){return this._log(`log`,e,t,n,{method:Ad.debug})}info(e,t,...n){return this._log(`info`,e,t,n,{method:console.info})}once(e,t,...n){return this._log(`once`,e,t,n,{method:Ad.debug||Ad.info,once:!0})}table(e,t,n){return t?this._log(`table`,e,t,n&&[n]||[],{method:console.table||vd,tag:Pd(t)}):vd}time(e,t){return this._log(`time`,e,t,[],{method:console.time?console.time:console.info})}timeEnd(e,t){return this._log(`time`,e,t,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(e,t){return this._log(`time`,e,t,[],{method:console.timeStamp||vd})}group(e,t,n={collapsed:!1}){let r=(n.collapsed?console.groupCollapsed:console.group)||console.info;return this._log(`group`,e,t,[],{method:r})}groupCollapsed(e,t,n={}){return this.group(e,t,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._log(`groupEnd`,e,``,[],{method:console.groupEnd||vd})}withGroup(e,t,n){this.group(e,t)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&super._shouldLog(e)}_emit(e,t){let n=t.method;hd(n),t.total=this.getTotal(),t.delta=this.getDelta(),this._deltaTs=kd();let r=Nd(this.id,t.message,t);return n.bind(console,r,...t.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(jd),this._storage.config[this.id]}_updateConfiguration(e){let t=this._storage.config[this.id]||{...jd};this._storage.setConfiguration({[this.id]:{...t,...e}})}};Md.VERSION=md;function Nd(e,t,n){if(typeof t==`string`){let r=n.time?Cd(Sd(n.total)):``;t=n.time?`${e}: ${r} ${t}`:`${e}: ${t}`,t=Dd(t,n.color,n.background)}return t}function Pd(e){for(let t in e)for(let n in e[t])return n||`untitled`;return`empty`}var Fd=`v4.4.2`;function Id(){let e=new Md({id:`loaders.gl`});return globalThis.loaders||={},globalThis.loaders.log=e,globalThis.loaders.version=Fd,globalThis.probe||={},globalThis.probe.loaders=e,e}var Ld=Id(),Rd=e=>typeof e==`boolean`,zd=e=>typeof e==`function`,Bd=e=>typeof e==`object`&&!!e,Vd=e=>Bd(e)&&e.constructor==={}.constructor,Hd=e=>typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer,Ud=e=>Bd(e)&&typeof e.byteLength==`number`&&typeof e.slice==`function`,Wd=e=>!!e&&zd(e[Symbol.iterator]),Gd=e=>!!e&&zd(e[Symbol.asyncIterator]),Kd=e=>typeof Response<`u`&&e instanceof Response||Bd(e)&&zd(e.arrayBuffer)&&zd(e.text)&&zd(e.json),qd=e=>typeof Blob<`u`&&e instanceof Blob,Jd=e=>typeof ReadableStream<`u`&&e instanceof ReadableStream||Bd(e)&&zd(e.tee)&&zd(e.cancel)&&zd(e.getReader),Yd=e=>Bd(e)&&zd(e.read)&&zd(e.pipe)&&Rd(e.readable),Xd=e=>Jd(e)||Yd(e);function Zd(e,t){return Qd(e||{},t)}function Qd(e,t,n=0){if(n>3)return t;let r={...e};for(let[e,i]of Object.entries(t))i&&typeof i==`object`&&!Array.isArray(i)?r[e]=Qd(r[e]||{},t[e],n+1):r[e]=t[e];return r}var $d=`latest`;function ef(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version=`4.4.2`),globalThis._loadersgl_.version}var tf=ef();function nf(e,t){if(!e)throw Error(t||`loaders.gl assertion failed.`)}var rf={self:typeof self<`u`&&self,window:typeof window<`u`&&window,global:typeof global<`u`&&global,document:typeof document<`u`&&document};rf.self||rf.window||rf.global,rf.window||rf.self||rf.global,rf.global||rf.self||rf.window,rf.document;var af=typeof process!=`object`||String(process)!==`[object process]`||process.browser,of=typeof window<`u`&&window.orientation!==void 0,sf=typeof process<`u`&&process.version&&/v([0-9]*)/.exec(process.version);sf&&parseFloat(sf[1]);var cf=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,t){this.name=e,this.workerThread=t,this.result=new Promise((e,t)=>{this._resolve=e,this._reject=t})}postMessage(e,t){this.workerThread.postMessage({source:`loaders.gl`,type:e,payload:t})}done(e){nf(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){nf(this.isRunning),this.isRunning=!1,this._reject(e)}},lf=class{terminate(){}},uf=new Map;function df(e){nf(e.source&&!e.url||!e.source&&e.url);let t=uf.get(e.source||e.url);return t||(e.url&&(t=ff(e.url),uf.set(e.url,t)),e.source&&(t=pf(e.source),uf.set(e.source,t))),nf(t),t}function ff(e){return e.startsWith(`http`)?pf(mf(e)):e}function pf(e){let t=new Blob([e],{type:`application/javascript`});return URL.createObjectURL(t)}function mf(e){return`\
|
|
562
562
|
try {
|
|
563
563
|
importScripts('${e}');
|
|
564
564
|
} catch (error) {
|
|
565
565
|
console.error(error);
|
|
566
566
|
throw error;
|
|
567
|
-
}`}function cf(e,t=!0,n){let r=n||new Set;if(e){if(lf(e))r.add(e);else if(lf(e.buffer))r.add(e.buffer);else if(!ArrayBuffer.isView(e)&&t&&typeof e==`object`)for(let n in e)cf(e[n],t,r)}return n===void 0?Array.from(r):[]}function lf(e){return e?e instanceof ArrayBuffer||typeof MessagePort<`u`&&e instanceof MessagePort||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas:!1}var uf=()=>{},df=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL=``;static isSupported(){return typeof Worker<`u`&&Zd||tf!==void 0&&!Zd}constructor(e){let{name:t,source:n,url:r}=e;Yd(n||r),this.name=t,this.source=n,this.url=r,this.onMessage=uf,this.onError=e=>console.log(e),this.worker=Zd?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=uf,this.onError=uf,this.worker.terminate(),this.terminated=!0}get isRunning(){return!!this.onMessage}postMessage(e,t){t||=cf(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t=`Failed to load `;return t+=`worker ${this.name} from ${this.url}. `,e.message&&(t+=`${e.message} in `),e.lineno&&(t+=`:${e.lineno}:${e.colno}`),Error(t)}_createBrowserWorker(){this._loadableURL=rf({source:this.source,url:this.url});let e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=e=>{e.data?this.onMessage(e.data):this.onError(Error(`No data received`))},e.onerror=e=>{this.onError(this._getErrorFromErrorEvent(e)),this.terminated=!0},e.onmessageerror=e=>console.error(e),e}_createNodeWorker(){let e;if(this.url)e=new tf(this.url.includes(`:/`)||this.url.startsWith(`/`)?this.url:`./${this.url}`,{eval:!1,type:this.url.endsWith(`.ts`)||this.url.endsWith(`.mjs`)?`module`:`commonjs`});else if(this.source)e=new tf(this.source,{eval:!0});else throw Error(`no worker`);return e.on(`message`,e=>{this.onMessage(e)}),e.on(`error`,e=>{this.onError(e)}),e.on(`exit`,e=>{}),e}},ff=class{name=`unnamed`;source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return df.isSupported()}constructor(e){this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},e.name!==void 0&&(this.name=e.name),e.maxConcurrency!==void 0&&(this.maxConcurrency=e.maxConcurrency),e.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=e.maxMobileConcurrency),e.reuseWorkers!==void 0&&(this.reuseWorkers=e.reuseWorkers),e.onDebug!==void 0&&(this.onDebug=e.onDebug)}async startJob(e,t=(e,t,n)=>e.done(n),n=(e,t)=>e.error(t)){let r=new Promise(r=>(this.jobQueue.push({name:e,onMessage:t,onError:n,onStart:r}),this));return this._startQueuedJob(),await r}async _startQueuedJob(){if(!this.jobQueue.length)return;let e=this._getAvailableWorker();if(!e)return;let t=this.jobQueue.shift();if(t){this.onDebug({message:`Starting job`,name:t.name,workerThread:e,backlog:this.jobQueue.length});let n=new ef(t.name,e);e.onMessage=e=>t.onMessage(n,e.type,e.payload),e.onError=e=>t.onError(n,e),t.onStart(n);try{await n.result}catch(e){console.error(`Worker exception: ${e}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!Zd||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){return this.idleQueue.length>0?this.idleQueue.shift()||null:this.count<this._getMaxConcurrency()?(this.count++,new df({name:`${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`,source:this.source,url:this.url})):null}_getMaxConcurrency(){return Qd?this.maxMobileConcurrency:this.maxConcurrency}},pf={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}},mf=class e{props;workerPools=new Map;static _workerFarm;static isSupported(){return df.isSupported()}static getWorkerFarm(t={}){return e._workerFarm=e._workerFarm||new e({}),e._workerFarm.setProps(t),e._workerFarm}constructor(e){this.props={...pf},this.setProps(e),this.workerPools=new Map}destroy(){for(let e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(let e of this.workerPools.values())e.setProps(this._getWorkerPoolProps())}getWorkerPool(e){let{name:t,source:n,url:r}=e,i=this.workerPools.get(t);return i||(i=new ff({name:t,source:n,url:r}),i.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,i)),i}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}};function hf(e,t={}){let n=t[e.id]||{},r=Zd?`${e.id}-worker.js`:`${e.id}-worker-node.js`,i=n.workerUrl;if(!i&&e.id===`compression`&&(i=t.workerUrl),(t._workerType||t?.core?._workerType)===`test`&&(i=Zd?`modules/${e.module}/dist/${r}`:`modules/${e.module}/src/workers/${e.id}-worker-node.ts`),!i){let t=e.version;t===`latest`&&(t=Kd);let n=t?`@${t}`:``;i=`https://unpkg.com/@loaders.gl/${e.module}${n}/dist/${r}`}return Yd(i),i}function gf(e,t=Jd){Yd(e,`no worker provided`);let n=e.version;return!(!t||!n)}function _f(e,t){if(!mf.isSupported())return!1;let n=t?._nodeWorkers??t?.core?._nodeWorkers;if(!Zd&&!n)return!1;let r=t?.worker??t?.core?.worker;return!!(e.worker&&r)}async function vf(e,t,n,r,i){let a=e.id,o=hf(e,n),s=mf.getWorkerFarm(n?.core).getWorkerPool({name:a,url:o});n=JSON.parse(JSON.stringify(n)),r=JSON.parse(JSON.stringify(r||{}));let c=await s.startJob(`process-on-worker`,yf.bind(null,i));return c.postMessage(`process`,{input:t,options:n,context:r}),await(await c.result).result}async function yf(e,t,n,r){switch(n){case`done`:t.done(r);break;case`error`:t.error(Error(r.error));break;case`process`:let{id:i,input:a,options:o}=r;try{let n=await e(a,o);t.postMessage(`done`,{id:i,result:n})}catch(e){let n=e instanceof Error?e.message:`unknown error`;t.postMessage(`error`,{id:i,error:n})}break;default:console.warn(`parse-with-worker unknown message ${n}`)}}function bf(e,t,n){if(n||=e.byteLength,e.byteLength<n||t.byteLength<n)return!1;let r=new Uint8Array(e),i=new Uint8Array(t);for(let e=0;e<r.length;++e)if(r[e]!==i[e])return!1;return!0}function xf(...e){return Sf(e)}function Sf(e){let t=e.map(e=>e instanceof ArrayBuffer?new Uint8Array(e):e),n=t.reduce((e,t)=>e+t.byteLength,0),r=new Uint8Array(n),i=0;for(let e of t)r.set(e,i),i+=e.byteLength;return r.buffer}async function Cf(e){let t=[];for await(let n of e)t.push(wf(n));return xf(...t)}function wf(e){if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e)){let{buffer:t,byteOffset:n,byteLength:r}=e;return Tf(t,n,r)}return Tf(e)}function Tf(e,t=0,n=e.byteLength-t){let r=new Uint8Array(e,t,n),i=new Uint8Array(r.length);return i.set(r),i.buffer}function Ef(){let e;if(typeof window<`u`&&window.performance)e=window.performance.now();else if(typeof process<`u`&&process.hrtime){let t=process.hrtime();e=t[0]*1e3+t[1]/1e6}else e=Date.now();return e}var Df=class{constructor(e,t){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=t,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=Ef(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Ef()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}},Of=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t=`count`){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let t of Object.values(this.stats))e(t)}getTable(){let e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(e=>this._getOrCreate(e))}_getOrCreate(e){let{name:t,type:n}=e,r=this.stats[t];return r||(r=e instanceof Df?e:new Df(t,n),this.stats[t]=r),r}},kf=``,Af={};function jf(e){for(let t in Af)if(e.startsWith(t)){let n=Af[t];e=e.replace(t,n)}return!e.startsWith(`http://`)&&!e.startsWith(`https://`)&&(e=`${kf}${e}`),e}function Mf(e){return e}function Nf(e){return e&&typeof e==`object`&&e.isBuffer}function Pf(e){if(Nf(e))return Mf(e);if(e instanceof ArrayBuffer)return e;if(Fd(e))return If(e);if(ArrayBuffer.isView(e)){let t=e.buffer;return e.byteOffset===0&&e.byteLength===e.buffer.byteLength?t:t.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(typeof e==`string`){let t=e;return new TextEncoder().encode(t).buffer}if(e&&typeof e==`object`&&e._toArrayBuffer)return e._toArrayBuffer();throw Error(`toArrayBuffer`)}function Ff(e){if(e instanceof ArrayBuffer)return e;if(Fd(e))return If(e);let{buffer:t,byteOffset:n,byteLength:r}=e;return t instanceof ArrayBuffer&&n===0&&r===t.byteLength?t:If(t,n,r)}function If(e,t=0,n=e.byteLength-t){let r=new Uint8Array(e,t,n),i=new Uint8Array(r.length);return i.set(r),i.buffer}function Lf(e){return ArrayBuffer.isView(e)?e:new Uint8Array(e)}function Rf(e){let t=e?e.lastIndexOf(`/`):-1;return t>=0?e.substr(t+1):e}function zf(e){let t=e?e.lastIndexOf(`/`):-1;return t>=0?e.substr(0,t):``}var Bf=class extends Error{constructor(e,t){super(e),this.reason=t.reason,this.url=t.url,this.response=t.response}reason;url;response},Vf=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,Hf=/^([-\w.]+\/[-\w.+]+)/;function Uf(e,t){return e.toLowerCase()===t.toLowerCase()}function Wf(e){let t=Hf.exec(e);return t?t[1]:e}function Gf(e){let t=Vf.exec(e);return t?t[1]:``}var Kf=/\?.*/;function qf(e){let t=e.match(Kf);return t&&t[0]}function Jf(e){return e.replace(Kf,``)}function Yf(e){if(e.length<50)return e;let t=e.slice(e.length-15);return`${e.substr(0,32)}...${t}`}function Xf(e){return zd(e)?e.url:Bd(e)?(`name`in e?e.name:``)||``:typeof e==`string`?e:``}function Zf(e){if(zd(e)){let t=e.headers.get(`content-type`)||``,n=Jf(e.url);return Wf(t)||Gf(n)}return Bd(e)?e.type||``:typeof e==`string`?Gf(e):``}function Qf(e){return zd(e)?e.headers[`content-length`]||-1:Bd(e)?e.size:typeof e==`string`?e.length:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:-1}async function $f(e){if(zd(e))return e;let t={},n=Qf(e);n>=0&&(t[`content-length`]=String(n));let r=Xf(e),i=Zf(e);i&&(t[`content-type`]=i);let a=await np(e);a&&(t[`x-first-bytes`]=a),typeof e==`string`&&(e=new TextEncoder().encode(e));let o=new Response(e,{headers:t});return Object.defineProperty(o,"url",{value:r}),o}async function ep(e){if(!e.ok)throw await tp(e)}async function tp(e){let t=Yf(e.url),n=`Failed to fetch resource (${e.status}) ${e.statusText}: ${t}`;n=n.length>100?`${n.slice(0,100)}...`:n;let r={reason:e.statusText,url:e.url,response:e};try{let t=e.headers.get(`Content-Type`);r.reason=!e.bodyUsed&&t?.includes(`application/json`)?await e.json():await e.text()}catch{}return new Bf(n,r)}async function np(e){if(typeof e==`string`)return`data:,${e.slice(0,5)}`;if(e instanceof Blob){let t=e.slice(0,5);return await new Promise(e=>{let n=new FileReader;n.onload=t=>e(t?.target?.result),n.readAsDataURL(t)})}return e instanceof ArrayBuffer?`data:base64,${rp(e.slice(0,5))}`:null}function rp(e){let t=``,n=new Uint8Array(e);for(let e=0;e<n.byteLength;e++)t+=String.fromCharCode(n[e]);return btoa(t)}function ip(e){return!ap(e)&&!op(e)}function ap(e){return e.startsWith(`http:`)||e.startsWith(`https:`)}function op(e){return e.startsWith(`data:`)}async function sp(e,t){if(typeof e==`string`){let n=jf(e);return ip(n)&&globalThis.loaders?.fetchNode?globalThis.loaders?.fetchNode(n,t):await fetch(n,t)}return await $f(e)}var cp=new Td({id:`loaders.gl`}),lp=class{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}},up={core:{baseUrl:void 0,fetch:null,mimeType:void 0,fallbackMimeType:void 0,ignoreRegisteredLoaders:void 0,nothrow:!1,log:new class{console;constructor(){this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}},useLocalLibraries:!1,CDN:`https://unpkg.com/@loaders.gl`,worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:$u,_nodeWorkers:!1,_workerType:``,limit:0,_limitMB:0,batchSize:`auto`,batchDebounceMs:0,metadata:!1,transforms:[]}},dp={baseUri:`core.baseUrl`,fetch:`core.fetch`,mimeType:`core.mimeType`,fallbackMimeType:`core.fallbackMimeType`,ignoreRegisteredLoaders:`core.ignoreRegisteredLoaders`,nothrow:`core.nothrow`,log:`core.log`,useLocalLibraries:`core.useLocalLibraries`,CDN:`core.CDN`,worker:`core.worker`,maxConcurrency:`core.maxConcurrency`,maxMobileConcurrency:`core.maxMobileConcurrency`,reuseWorkers:`core.reuseWorkers`,_nodeWorkers:`core.nodeWorkers`,_workerType:`core._workerType`,_worker:`core._workerType`,limit:`core.limit`,_limitMB:`core._limitMB`,batchSize:`core.batchSize`,batchDebounceMs:`core.batchDebounceMs`,metadata:`core.metadata`,transforms:`core.transforms`,throws:`nothrow`,dataType:`(no longer used)`,uri:`core.baseUrl`,method:`core.fetch.method`,headers:`core.fetch.headers`,body:`core.fetch.body`,mode:`core.fetch.mode`,credentials:`core.fetch.credentials`,cache:`core.fetch.cache`,redirect:`core.fetch.redirect`,referrer:`core.fetch.referrer`,referrerPolicy:`core.fetch.referrerPolicy`,integrity:`core.fetch.integrity`,keepalive:`core.fetch.keepalive`,signal:`core.fetch.signal`},fp=[`baseUrl`,`fetch`,`mimeType`,`fallbackMimeType`,`ignoreRegisteredLoaders`,`nothrow`,`log`,`useLocalLibraries`,`CDN`,`worker`,`maxConcurrency`,`maxMobileConcurrency`,`reuseWorkers`,`_nodeWorkers`,`_workerType`,`limit`,`_limitMB`,`batchSize`,`batchDebounceMs`,`metadata`,`transforms`];function pp(){globalThis.loaders=globalThis.loaders||{};let{loaders:e}=globalThis;return e._state||={},e._state}function mp(){let e=pp();return e.globalOptions=e.globalOptions||{...up,core:{...up.core}},gp(e.globalOptions)}function hp(e,t,n,r){return n||=[],n=Array.isArray(n)?n:[n],_p(e,n),gp(bp(t,e,r))}function gp(e){let t=Cp(e);wp(t);for(let e of fp)t.core&&t.core[e]!==void 0&&delete t[e];return t.core&&t.core._workerType!==void 0&&delete t._worker,t}function _p(e,t){vp(e,null,up,dp,t);for(let n of t){let r=e&&e[n.id]||{},i=n.options&&n.options[n.id]||{},a=n.deprecatedOptions&&n.deprecatedOptions[n.id]||{};vp(r,n.id,i,a,t)}}function vp(e,t,n,r,i){let a=t||`Top level`,o=t?`${t}.`:``;for(let s in e){let c=!t&&Nd(e[s]),l=s===`baseUri`&&!t,u=s===`workerUrl`&&t;if(!(s in n)&&!l&&!u){if(s in r)cp.level>0&&cp.warn(`${a} loader option \'${o}${s}\' no longer supported, use \'${r[s]}\'`)();else if(!c&&cp.level>0){let e=yp(s,i);cp.warn(`${a} loader option \'${o}${s}\' not recognized. ${e}`)()}}}}function yp(e,t){let n=e.toLowerCase(),r=``;for(let i of t)for(let t in i.options){if(e===t)return`Did you mean \'${i.id}.${t}\'?`;let a=t.toLowerCase();(n.startsWith(a)||a.startsWith(n))&&(r||=`Did you mean \'${i.id}.${t}\'?`)}return r}function bp(e,t,n){let r=e.options||{},i={...r};return r.core&&(i.core={...r.core}),wp(i),i.core?.log===null&&(i.core={...i.core,log:new lp}),xp(i,gp(mp())),xp(i,gp(t)),Sp(i,n),Tp(i),i}function xp(e,t){for(let n in t)if(n in t){let r=t[n];Pd(r)&&Pd(e[n])?e[n]={...e[n],...t[n]}:e[n]=t[n]}}function Sp(e,t){t&&e.core?.baseUrl===void 0&&(e.core||={},e.core.baseUrl=zf(Jf(t)))}function Cp(e){let t={...e};return e.core&&(t.core={...e.core}),t}function wp(e){e.baseUri!==void 0&&(e.core||={},e.core.baseUrl===void 0&&(e.core.baseUrl=e.baseUri));for(let t of fp)if(e[t]!==void 0){let n=e.core=e.core||{};n[t]===void 0&&(n[t]=e[t])}let t=e._worker;t!==void 0&&(e.core||={},e.core._workerType===void 0&&(e.core._workerType=t))}function Tp(e){let t=e.core;if(t)for(let n of fp)t[n]!==void 0&&(e[n]=t[n])}function Ep(e){return e?(Array.isArray(e)&&(e=e[0]),Array.isArray(e?.extensions)):!1}function Dp(e){Zu(e,`null loader`),Zu(Ep(e),`invalid loader`);let t;return Array.isArray(e)&&(t=e[1],e=e[0],e={...e,options:{...e.options,...t}}),(e?.parseTextSync||e?.parseText)&&(e.text=!0),e.text||(e.binary=!0),e}var Op=()=>{let e=pp();return e.loaderRegistry=e.loaderRegistry||[],e.loaderRegistry};function kp(e){let t=Op();e=Array.isArray(e)?e:[e];for(let n of e){let e=Dp(n);t.find(t=>e===t)||t.unshift(e)}}function Ap(){return Op()}var jp=/\.([^.]+)$/;async function Mp(e,t=[],n,r){if(!Ip(e))return null;let i=gp(n||{});if(i.core||={},e instanceof Response&&Np(e)){let n=Pp(await e.clone().text(),t,{...i,core:{...i.core,nothrow:!0}},r);if(n)return n}let a=Pp(e,t,{...i,core:{...i.core,nothrow:!0}},r);if(a)return a;if(Bd(e)&&(e=await e.slice(0,10).arrayBuffer(),a=Pp(e,t,i,r)),!a&&e instanceof Response&&Np(e)&&(a=Pp(await e.clone().text(),t,i,r)),!a&&!i.core.nothrow)throw Error(Lp(e));return a}function Np(e){let t=Zf(e);return!!(t&&(t.startsWith(`text/`)||t===`application/json`||t.endsWith(`+json`)))}function Pp(e,t=[],n,r){if(!Ip(e))return null;let i=gp(n||{});if(i.core||={},t&&!Array.isArray(t))return Dp(t);let a=[];t&&(a=a.concat(t)),i.core.ignoreRegisteredLoaders||a.push(...Ap()),Rp(a);let o=Fp(e,a,i,r);if(!o&&!i.core.nothrow)throw Error(Lp(e));return o}function Fp(e,t,n,r){let i=Xf(e),a=Zf(e),o=Jf(i)||r?.url,s=null,c=``;return n?.core?.mimeType&&(s=Vp(t,n?.core?.mimeType),c=`match forced by supplied MIME type ${n?.core?.mimeType}`),s||=zp(t,o),c||=s?`matched url ${o}`:``,s||=Vp(t,a),c||=s?`matched MIME type ${a}`:``,s||=Hp(t,e),c||=s?`matched initial data ${Kp(e)}`:``,n?.core?.fallbackMimeType&&(s||=Vp(t,n?.core?.fallbackMimeType),c||=s?`matched fallback MIME type ${a}`:``),c&&Ad.log(1,`selectLoader selected ${s?.name}: ${c}.`),s}function Ip(e){return!(e instanceof Response&&e.status===204)}function Lp(e){let t=Xf(e),n=Zf(e),r=`No valid loader found (`;r+=t?`${Rf(t)}, `:`no url provided, `,r+=`MIME type: ${n?`"${n}"`:`not provided`}, `;let i=e?Kp(e):``;return r+=i?` first bytes: "${i}"`:`first bytes: not available`,r+=`)`,r}function Rp(e){for(let t of e)Dp(t)}function zp(e,t){let n=t&&jp.exec(t),r=n&&n[1];return r?Bp(e,r):null}function Bp(e,t){t=t.toLowerCase();for(let n of e)for(let e of n.extensions)if(e.toLowerCase()===t)return n;return null}function Vp(e,t){for(let n of e)if(n.mimeTypes?.some(e=>Uf(t,e))||Uf(t,`application/x.${n.id}`))return n;return null}function Hp(e,t){if(!t)return null;for(let n of e)if(typeof t==`string`){if(Up(t,n))return n}else if(ArrayBuffer.isView(t)){if(Wp(t.buffer,t.byteOffset,n))return n}else if(t instanceof ArrayBuffer&&Wp(t,0,n))return n;return null}function Up(e,t){return t.testText?t.testText(e):(Array.isArray(t.tests)?t.tests:[t.tests]).some(t=>e.startsWith(t))}function Wp(e,t,n){return(Array.isArray(n.tests)?n.tests:[n.tests]).some(r=>Gp(e,t,n,r))}function Gp(e,t,n,r){if(Id(r))return bf(r,e,r.byteLength);switch(typeof r){case`function`:return r(Ff(e));case`string`:return r===qp(e,t,r.length);default:return!1}}function Kp(e,t=5){return typeof e==`string`?e.slice(0,t):ArrayBuffer.isView(e)?qp(e.buffer,e.byteOffset,t):e instanceof ArrayBuffer?qp(e,0,t):``}function qp(e,t,n){if(e.byteLength<t+n)return``;let r=new DataView(e),i=``;for(let e=0;e<n;e++)i+=String.fromCharCode(r.getUint8(t+e));return i}var Jp=256*1024;function*Yp(e,t){let n=t?.chunkSize||Jp,r=0,i=new TextEncoder;for(;r<e.length;){let t=Math.min(e.length-r,n),a=e.slice(r,r+t);r+=t,yield Ff(i.encode(a))}}var Xp=256*1024;function*Zp(e,t={}){let{chunkSize:n=Xp}=t,r=0;for(;r<e.byteLength;){let t=Math.min(e.byteLength-r,n),i=new ArrayBuffer(t),a=new Uint8Array(e,r,t);new Uint8Array(i).set(a),r+=t,yield i}}var Qp=1024*1024;async function*$p(e,t){let n=t?.chunkSize||Qp,r=0;for(;r<e.size;){let t=r+n,i=await e.slice(r,t).arrayBuffer();r=t,yield i}}function em(e,t){return $u?tm(e,t):nm(e,t)}async function*tm(e,t){let n=e.getReader(),r;try{for(;;){let e=r||n.read();t?._streamReadAhead&&(r=n.read());let{done:i,value:a}=await e;if(i)return;yield Pf(a)}}catch{n.releaseLock()}}async function*nm(e,t){for await(let t of e)yield Pf(t)}function rm(e,t){if(typeof e==`string`)return Yp(e,t);if(e instanceof ArrayBuffer)return Zp(e,t);if(Bd(e))return $p(e,t);if(Ud(e))return em(e,t);if(zd(e)){let n=e.body;if(!n)throw Error(`Readable stream not available on Response`);return em(n,t)}throw Error(`makeIterator`)}var im=`Cannot convert supplied data type`;function am(e,t,n){if(t.text&&typeof e==`string`)return e;if(Nf(e)&&(e=e.buffer),Id(e)){let n=Lf(e);return t.text&&!t.binary?new TextDecoder(`utf8`).decode(n):Pf(n)}throw Error(im)}async function om(e,t,n){if(typeof e==`string`||Id(e))return am(e,t,n);if(Bd(e)&&(e=await $f(e)),zd(e))return await ep(e),t.binary?await e.arrayBuffer():await e.text();if(Ud(e)&&(e=rm(e,n)),Ld(e)||Rd(e))return Cf(e);throw Error(im)}function sm(e,t){let n=mp(),r=e||n,i=r.fetch??r.core?.fetch;return typeof i==`function`?i:Nd(i)?e=>sp(e,i):t?.fetch?t?.fetch:sp}function cm(e,t,n){if(n)return n;let r={fetch:sm(t,e),...e};if(r.url){let e=Jf(r.url);r.baseUrl=e,r.queryString=qf(r.url),r.filename=Rf(e),r.baseUrl=zf(e)}return Array.isArray(r.loaders)||(r.loaders=null),r}function lm(e,t){if(e&&!Array.isArray(e))return e;let n;if(e&&(n=Array.isArray(e)?e:[e]),t&&t.loaders){let e=Array.isArray(t.loaders)?t.loaders:[t.loaders];n=n?[...n,...e]:e}return n&&n.length?n:void 0}async function um(e,t,n,r){t&&!Array.isArray(t)&&!Ep(t)&&(r=void 0,n=t,t=void 0),e=await e,n||={};let i=Xf(e),a=lm(t,r),o=await Mp(e,a,n);if(!o)return null;let s=hp(n,o,a,i);return r=cm({url:i,_parse:um,loaders:a},s,r||null),await dm(o,e,s,r)}async function dm(e,t,n,r){if(gf(e),n=Wd(e.options,n),zd(t)){let{ok:e,redirected:n,status:i,statusText:a,type:o,url:s}=t;r.response={headers:Object.fromEntries(t.headers.entries()),ok:e,redirected:n,status:i,statusText:a,type:o,url:s}}t=await om(t,e,n);let i=e;if(i.parseTextSync&&typeof t==`string`)return i.parseTextSync(t,n,r);if(_f(e,n))return await vf(e,t,n,r,um);if(i.parseText&&typeof t==`string`)return await i.parseText(t,n,r);if(i.parse)return await i.parse(t,n,r);throw Yd(!i.parseSync),Error(`${e.id} loader - no parser found and worker is disabled`)}function fm(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function pm(e){return Array.isArray(e)?e.length===0||typeof e[0]==`number`:!1}function mm(e){return fm(e)||pm(e)}async function hm(e,t,n,r){let i,a;!Array.isArray(t)&&!Ep(t)?(i=[],a=t,r=void 0):(i=t,a=n);let o=sm(a),s=e;return typeof e==`string`&&(s=await o(e)),Bd(e)&&(s=await o(e)),typeof e==`string`&&(gp(a||{}).core?.baseUrl||(a={...a,core:{...a?.core,baseUrl:e}})),await um(s,i,a)}var gm=`4.4.2`,_m=globalThis.loaders?.parseImageNode,vm=typeof Image<`u`,ym=typeof ImageBitmap<`u`,bm=$u?!0:!!_m;function xm(e){switch(e){case`auto`:return ym||vm||bm;case`imagebitmap`:return ym;case`image`:return vm;case`data`:return bm;default:throw Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}function Sm(){if(ym)return`imagebitmap`;if(vm)return`image`;if(bm)return`data`;throw Error(`Install '@loaders.gl/polyfills' to parse images under Node.js`)}function Cm(e){let t=Tm(e);if(!t)throw Error(`Not an image`);return t}function wm(e){switch(Cm(e)){case`data`:return e;case`image`:case`imagebitmap`:let t=document.createElement(`canvas`),n=t.getContext(`2d`);if(!n)throw Error(`getImageData`);return t.width=e.width,t.height=e.height,n.drawImage(e,0,0),n.getImageData(0,0,e.width,e.height);default:throw Error(`getImageData`)}}function Tm(e){return typeof ImageBitmap<`u`&&e instanceof ImageBitmap?`imagebitmap`:typeof Image<`u`&&e instanceof Image?`image`:e&&typeof e==`object`&&e.data&&e.width&&e.height?`data`:null}var Em=/^data:image\/svg\+xml/,Dm=/\.svg((\?|#).*)?$/;function Om(e){return e&&(Em.test(e)||Dm.test(e))}function km(e,t){if(Om(t)){let t=new TextDecoder().decode(e);try{typeof unescape==`function`&&typeof encodeURIComponent==`function`&&(t=unescape(encodeURIComponent(t)))}catch(e){throw Error(e.message)}return`data:image/svg+xml;base64,${btoa(t)}`}return Am(e,t)}function Am(e,t){if(Om(t))throw Error(`SVG cannot be parsed directly to imagebitmap`);return new Blob([new Uint8Array(e)])}async function jm(e,t,n){let r=km(e,n),i=self.URL||self.webkitURL,a=typeof r!=`string`&&i.createObjectURL(r);try{return await Mm(a||r,t)}finally{a&&i.revokeObjectURL(a)}}async function Mm(e,t){let n=new Image;return n.src=e,t.image&&t.image.decode&&n.decode?(await n.decode(),n):await new Promise((e,t)=>{try{n.onload=()=>e(n),n.onerror=e=>{let n=e instanceof Error?e.message:`error`;t(Error(n))}}catch(e){t(e)}})}var Nm=!0;async function Pm(e,t,n){let r;r=Om(n)?await jm(e,t,n):Am(e,n);let i=t&&t.imagebitmap;return await Fm(r,i)}async function Fm(e,t=null){if((Im(t)||!Nm)&&(t=null),t)try{return await createImageBitmap(e,t)}catch(e){console.warn(e),Nm=!1}return await createImageBitmap(e)}function Im(e){if(!e)return!0;for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}function Lm(e){return!Vm(e,`ftyp`,4)||!(e[8]&96)?null:Rm(e)}function Rm(e){switch(zm(e,8,12).replace(`\0`,` `).trim()){case`avif`:case`avis`:return{extension:`avif`,mimeType:`image/avif`};default:return null}}function zm(e,t,n){return String.fromCharCode(...e.slice(t,n))}function Bm(e){return[...e].map(e=>e.charCodeAt(0))}function Vm(e,t,n=0){let r=Bm(t);for(let t=0;t<r.length;++t)if(r[t]!==e[t+n])return!1;return!0}var Hm=!1,Um=!0;function Wm(e){let t=Zm(e);return Km(t)||Ym(t)||qm(t)||Jm(t)||Gm(t)}function Gm(e){let t=Lm(new Uint8Array(e instanceof DataView?e.buffer:e));return t?{mimeType:t.mimeType,width:0,height:0}:null}function Km(e){let t=Zm(e);return t.byteLength>=24&&t.getUint32(0,Hm)===2303741511?{mimeType:`image/png`,width:t.getUint32(16,Hm),height:t.getUint32(20,Hm)}:null}function qm(e){let t=Zm(e);return t.byteLength>=10&&t.getUint32(0,Hm)===1195984440?{mimeType:`image/gif`,width:t.getUint16(6,Um),height:t.getUint16(8,Um)}:null}function Jm(e){let t=Zm(e);return t.byteLength>=14&&t.getUint16(0,Hm)===16973&&t.getUint32(2,Um)===t.byteLength?{mimeType:`image/bmp`,width:t.getUint32(18,Um),height:t.getUint32(22,Um)}:null}function Ym(e){let t=Zm(e);if(!(t.byteLength>=3&&t.getUint16(0,Hm)===65496&&t.getUint8(2)===255))return null;let{tableMarkers:n,sofMarkers:r}=Xm(),i=2;for(;i+9<t.byteLength;){let e=t.getUint16(i,Hm);if(r.has(e))return{mimeType:`image/jpeg`,height:t.getUint16(i+5,Hm),width:t.getUint16(i+7,Hm)};if(!n.has(e))return null;i+=2,i+=t.getUint16(i,Hm)}return null}function Xm(){let e=new Set([65499,65476,65484,65501,65534]);for(let t=65504;t<65520;++t)e.add(t);return{tableMarkers:e,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function Zm(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw Error(`toDataView`)}async function Qm(e,t){let{mimeType:n}=Wm(e)||{},r=globalThis.loaders?.parseImageNode;return Zu(r),await r(e,n)}async function $m(e,t,n){t||={};let r=(t.image||{}).type||`auto`,{url:i}=n||{},a=eh(r),o;switch(a){case`imagebitmap`:o=await Pm(e,t,i);break;case`image`:o=await jm(e,t,i);break;case`data`:o=await Qm(e,t);break;default:Zu(!1)}return r===`data`&&(o=wm(o)),o}function eh(e){switch(e){case`auto`:case`data`:return Sm();default:return xm(e),e}}var th={dataType:null,batchType:null,id:`image`,module:`images`,name:`Images`,version:gm,mimeTypes:[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/avif`,`image/bmp`,`image/vnd.microsoft.icon`,`image/svg+xml`],extensions:[`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`ico`,`svg`,`avif`],parse:$m,tests:[e=>!!Wm(new DataView(e))],options:{image:{type:`auto`,decode:!0}}},X=new Td({id:`deck`}),nh={};function rh(e){nh=e}function ih(e,t,n,r){X.level>0&&nh[e]&&nh[e].call(null,t,n,r)}function ah(e){let t=e[0],n=e[e.length-1];return t===`{`&&n===`}`||t===`[`&&n===`]`}var oh={dataType:null,batchType:null,id:`JSON`,name:`JSON`,module:``,version:``,options:{},extensions:[`json`,`geojson`],mimeTypes:[`application/json`,`application/geo+json`],testText:ah,parseTextSync:JSON.parse};function sh(){let e=`9.3.2`,t=globalThis.deck&&globalThis.deck.VERSION;if(t&&t!==e)throw Error(`deck.gl - multiple versions detected: ${t} vs ${e}`);return t||(X.log(1,`deck.gl ${e}`)(),globalThis.deck={...globalThis.deck,VERSION:e,version:e,log:X,_registerLoggers:rh},kp([oh,[th,{imagebitmap:{premultiplyAlpha:`none`}}]])),e}var ch=sh();function lh(e,t){if(!e){let e=Error(t||`shadertools: assertion failed.`);throw Error.captureStackTrace?.(e,lh),e}}var uh={number:{type:`number`,validate(e,t){return Number.isFinite(e)&&typeof t==`object`&&(t.max===void 0||e<=t.max)&&(t.min===void 0||e>=t.min)}},array:{type:`array`,validate(e,t){return Array.isArray(e)||ArrayBuffer.isView(e)}}};function dh(e){let t={};for(let[n,r]of Object.entries(e))t[n]=fh(r);return t}function fh(e){let t=ph(e);if(t!==`object`)return{value:e,...uh[t],type:t};if(typeof e==`object`)return e?e.type===void 0?e.value===void 0?{type:`object`,value:e}:(t=ph(e.value),{...e,...uh[t],type:t}):{...e,...uh[e.type],type:e.type}:{type:`object`,value:null};throw Error(`props`)}function ph(e){return Array.isArray(e)||ArrayBuffer.isView(e)?`array`:typeof e}var mh={vertex:`#ifdef MODULE_LOGDEPTH
|
|
567
|
+
}`}function hf(e,t=!0,n){let r=n||new Set;if(e){if(gf(e))r.add(e);else if(gf(e.buffer))r.add(e.buffer);else if(!ArrayBuffer.isView(e)&&t&&typeof e==`object`)for(let n in e)hf(e[n],t,r)}return n===void 0?Array.from(r):[]}function gf(e){return e?e instanceof ArrayBuffer||typeof MessagePort<`u`&&e instanceof MessagePort||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas:!1}var _f=()=>{},vf=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL=``;static isSupported(){return typeof Worker<`u`&&af||lf!==void 0&&!af}constructor(e){let{name:t,source:n,url:r}=e;nf(n||r),this.name=t,this.source=n,this.url=r,this.onMessage=_f,this.onError=e=>console.log(e),this.worker=af?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=_f,this.onError=_f,this.worker.terminate(),this.terminated=!0}get isRunning(){return!!this.onMessage}postMessage(e,t){t||=hf(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t=`Failed to load `;return t+=`worker ${this.name} from ${this.url}. `,e.message&&(t+=`${e.message} in `),e.lineno&&(t+=`:${e.lineno}:${e.colno}`),Error(t)}_createBrowserWorker(){this._loadableURL=df({source:this.source,url:this.url});let e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=e=>{e.data?this.onMessage(e.data):this.onError(Error(`No data received`))},e.onerror=e=>{this.onError(this._getErrorFromErrorEvent(e)),this.terminated=!0},e.onmessageerror=e=>console.error(e),e}_createNodeWorker(){let e;if(this.url)e=new lf(this.url.includes(`:/`)||this.url.startsWith(`/`)?this.url:`./${this.url}`,{eval:!1,type:this.url.endsWith(`.ts`)||this.url.endsWith(`.mjs`)?`module`:`commonjs`});else if(this.source)e=new lf(this.source,{eval:!0});else throw Error(`no worker`);return e.on(`message`,e=>{this.onMessage(e)}),e.on(`error`,e=>{this.onError(e)}),e.on(`exit`,e=>{}),e}},yf=class{name=`unnamed`;source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return vf.isSupported()}constructor(e){this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},e.name!==void 0&&(this.name=e.name),e.maxConcurrency!==void 0&&(this.maxConcurrency=e.maxConcurrency),e.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=e.maxMobileConcurrency),e.reuseWorkers!==void 0&&(this.reuseWorkers=e.reuseWorkers),e.onDebug!==void 0&&(this.onDebug=e.onDebug)}async startJob(e,t=(e,t,n)=>e.done(n),n=(e,t)=>e.error(t)){let r=new Promise(r=>(this.jobQueue.push({name:e,onMessage:t,onError:n,onStart:r}),this));return this._startQueuedJob(),await r}async _startQueuedJob(){if(!this.jobQueue.length)return;let e=this._getAvailableWorker();if(!e)return;let t=this.jobQueue.shift();if(t){this.onDebug({message:`Starting job`,name:t.name,workerThread:e,backlog:this.jobQueue.length});let n=new cf(t.name,e);e.onMessage=e=>t.onMessage(n,e.type,e.payload),e.onError=e=>t.onError(n,e),t.onStart(n);try{await n.result}catch(e){console.error(`Worker exception: ${e}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!af||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){return this.idleQueue.length>0?this.idleQueue.shift()||null:this.count<this._getMaxConcurrency()?(this.count++,new vf({name:`${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`,source:this.source,url:this.url})):null}_getMaxConcurrency(){return of?this.maxMobileConcurrency:this.maxConcurrency}},bf={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}},xf=class e{props;workerPools=new Map;static _workerFarm;static isSupported(){return vf.isSupported()}static getWorkerFarm(t={}){return e._workerFarm=e._workerFarm||new e({}),e._workerFarm.setProps(t),e._workerFarm}constructor(e){this.props={...bf},this.setProps(e),this.workerPools=new Map}destroy(){for(let e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(let e of this.workerPools.values())e.setProps(this._getWorkerPoolProps())}getWorkerPool(e){let{name:t,source:n,url:r}=e,i=this.workerPools.get(t);return i||(i=new yf({name:t,source:n,url:r}),i.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,i)),i}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}};function Sf(e,t={}){let n=t[e.id]||{},r=af?`${e.id}-worker.js`:`${e.id}-worker-node.js`,i=n.workerUrl;if(!i&&e.id===`compression`&&(i=t.workerUrl),(t._workerType||t?.core?._workerType)===`test`&&(i=af?`modules/${e.module}/dist/${r}`:`modules/${e.module}/src/workers/${e.id}-worker-node.ts`),!i){let t=e.version;t===`latest`&&(t=$d);let n=t?`@${t}`:``;i=`https://unpkg.com/@loaders.gl/${e.module}${n}/dist/${r}`}return nf(i),i}function Cf(e,t=tf){nf(e,`no worker provided`);let n=e.version;return!(!t||!n)}function wf(e,t){if(!xf.isSupported())return!1;let n=t?._nodeWorkers??t?.core?._nodeWorkers;if(!af&&!n)return!1;let r=t?.worker??t?.core?.worker;return!!(e.worker&&r)}async function Tf(e,t,n,r,i){let a=e.id,o=Sf(e,n),s=xf.getWorkerFarm(n?.core).getWorkerPool({name:a,url:o});n=JSON.parse(JSON.stringify(n)),r=JSON.parse(JSON.stringify(r||{}));let c=await s.startJob(`process-on-worker`,Ef.bind(null,i));return c.postMessage(`process`,{input:t,options:n,context:r}),await(await c.result).result}async function Ef(e,t,n,r){switch(n){case`done`:t.done(r);break;case`error`:t.error(Error(r.error));break;case`process`:let{id:i,input:a,options:o}=r;try{let n=await e(a,o);t.postMessage(`done`,{id:i,result:n})}catch(e){let n=e instanceof Error?e.message:`unknown error`;t.postMessage(`error`,{id:i,error:n})}break;default:console.warn(`parse-with-worker unknown message ${n}`)}}function Df(e,t,n){if(n||=e.byteLength,e.byteLength<n||t.byteLength<n)return!1;let r=new Uint8Array(e),i=new Uint8Array(t);for(let e=0;e<r.length;++e)if(r[e]!==i[e])return!1;return!0}function Of(...e){return kf(e)}function kf(e){let t=e.map(e=>e instanceof ArrayBuffer?new Uint8Array(e):e),n=t.reduce((e,t)=>e+t.byteLength,0),r=new Uint8Array(n),i=0;for(let e of t)r.set(e,i),i+=e.byteLength;return r.buffer}async function Af(e){let t=[];for await(let n of e)t.push(jf(n));return Of(...t)}function jf(e){if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e)){let{buffer:t,byteOffset:n,byteLength:r}=e;return Mf(t,n,r)}return Mf(e)}function Mf(e,t=0,n=e.byteLength-t){let r=new Uint8Array(e,t,n),i=new Uint8Array(r.length);return i.set(r),i.buffer}function Nf(){let e;if(typeof window<`u`&&window.performance)e=window.performance.now();else if(typeof process<`u`&&process.hrtime){let t=process.hrtime();e=t[0]*1e3+t[1]/1e6}else e=Date.now();return e}var Pf=class{constructor(e,t){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=t,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=Nf(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Nf()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}},Ff=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t=`count`){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let t of Object.values(this.stats))e(t)}getTable(){let e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(e=>this._getOrCreate(e))}_getOrCreate(e){let{name:t,type:n}=e,r=this.stats[t];return r||(r=e instanceof Pf?e:new Pf(t,n),this.stats[t]=r),r}},If=``,Lf={};function Rf(e){for(let t in Lf)if(e.startsWith(t)){let n=Lf[t];e=e.replace(t,n)}return!e.startsWith(`http://`)&&!e.startsWith(`https://`)&&(e=`${If}${e}`),e}function zf(e){return e}function Bf(e){return e&&typeof e==`object`&&e.isBuffer}function Vf(e){if(Bf(e))return zf(e);if(e instanceof ArrayBuffer)return e;if(Hd(e))return Uf(e);if(ArrayBuffer.isView(e)){let t=e.buffer;return e.byteOffset===0&&e.byteLength===e.buffer.byteLength?t:t.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(typeof e==`string`){let t=e;return new TextEncoder().encode(t).buffer}if(e&&typeof e==`object`&&e._toArrayBuffer)return e._toArrayBuffer();throw Error(`toArrayBuffer`)}function Hf(e){if(e instanceof ArrayBuffer)return e;if(Hd(e))return Uf(e);let{buffer:t,byteOffset:n,byteLength:r}=e;return t instanceof ArrayBuffer&&n===0&&r===t.byteLength?t:Uf(t,n,r)}function Uf(e,t=0,n=e.byteLength-t){let r=new Uint8Array(e,t,n),i=new Uint8Array(r.length);return i.set(r),i.buffer}function Wf(e){return ArrayBuffer.isView(e)?e:new Uint8Array(e)}function Gf(e){let t=e?e.lastIndexOf(`/`):-1;return t>=0?e.substr(t+1):e}function Kf(e){let t=e?e.lastIndexOf(`/`):-1;return t>=0?e.substr(0,t):``}var qf=class extends Error{constructor(e,t){super(e),this.reason=t.reason,this.url=t.url,this.response=t.response}reason;url;response},Jf=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,Yf=/^([-\w.]+\/[-\w.+]+)/;function Xf(e,t){return e.toLowerCase()===t.toLowerCase()}function Zf(e){let t=Yf.exec(e);return t?t[1]:e}function Qf(e){let t=Jf.exec(e);return t?t[1]:``}var $f=/\?.*/;function ep(e){let t=e.match($f);return t&&t[0]}function tp(e){return e.replace($f,``)}function np(e){if(e.length<50)return e;let t=e.slice(e.length-15);return`${e.substr(0,32)}...${t}`}function rp(e){return Kd(e)?e.url:qd(e)?(`name`in e?e.name:``)||``:typeof e==`string`?e:``}function ip(e){if(Kd(e)){let t=e.headers.get(`content-type`)||``,n=tp(e.url);return Zf(t)||Qf(n)}return qd(e)?e.type||``:typeof e==`string`?Qf(e):``}function ap(e){return Kd(e)?e.headers[`content-length`]||-1:qd(e)?e.size:typeof e==`string`?e.length:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:-1}async function op(e){if(Kd(e))return e;let t={},n=ap(e);n>=0&&(t[`content-length`]=String(n));let r=rp(e),i=ip(e);i&&(t[`content-type`]=i);let a=await lp(e);a&&(t[`x-first-bytes`]=a),typeof e==`string`&&(e=new TextEncoder().encode(e));let o=new Response(e,{headers:t});return Object.defineProperty(o,"url",{value:r}),o}async function sp(e){if(!e.ok)throw await cp(e)}async function cp(e){let t=np(e.url),n=`Failed to fetch resource (${e.status}) ${e.statusText}: ${t}`;n=n.length>100?`${n.slice(0,100)}...`:n;let r={reason:e.statusText,url:e.url,response:e};try{let t=e.headers.get(`Content-Type`);r.reason=!e.bodyUsed&&t?.includes(`application/json`)?await e.json():await e.text()}catch{}return new qf(n,r)}async function lp(e){if(typeof e==`string`)return`data:,${e.slice(0,5)}`;if(e instanceof Blob){let t=e.slice(0,5);return await new Promise(e=>{let n=new FileReader;n.onload=t=>e(t?.target?.result),n.readAsDataURL(t)})}return e instanceof ArrayBuffer?`data:base64,${up(e.slice(0,5))}`:null}function up(e){let t=``,n=new Uint8Array(e);for(let e=0;e<n.byteLength;e++)t+=String.fromCharCode(n[e]);return btoa(t)}function dp(e){return!fp(e)&&!pp(e)}function fp(e){return e.startsWith(`http:`)||e.startsWith(`https:`)}function pp(e){return e.startsWith(`data:`)}async function mp(e,t){if(typeof e==`string`){let n=Rf(e);return dp(n)&&globalThis.loaders?.fetchNode?globalThis.loaders?.fetchNode(n,t):await fetch(n,t)}return await op(e)}var hp=new Md({id:`loaders.gl`}),gp=class{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}},_p={core:{baseUrl:void 0,fetch:null,mimeType:void 0,fallbackMimeType:void 0,ignoreRegisteredLoaders:void 0,nothrow:!1,log:new class{console;constructor(){this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}},useLocalLibraries:!1,CDN:`https://unpkg.com/@loaders.gl`,worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:od,_nodeWorkers:!1,_workerType:``,limit:0,_limitMB:0,batchSize:`auto`,batchDebounceMs:0,metadata:!1,transforms:[]}},vp={baseUri:`core.baseUrl`,fetch:`core.fetch`,mimeType:`core.mimeType`,fallbackMimeType:`core.fallbackMimeType`,ignoreRegisteredLoaders:`core.ignoreRegisteredLoaders`,nothrow:`core.nothrow`,log:`core.log`,useLocalLibraries:`core.useLocalLibraries`,CDN:`core.CDN`,worker:`core.worker`,maxConcurrency:`core.maxConcurrency`,maxMobileConcurrency:`core.maxMobileConcurrency`,reuseWorkers:`core.reuseWorkers`,_nodeWorkers:`core.nodeWorkers`,_workerType:`core._workerType`,_worker:`core._workerType`,limit:`core.limit`,_limitMB:`core._limitMB`,batchSize:`core.batchSize`,batchDebounceMs:`core.batchDebounceMs`,metadata:`core.metadata`,transforms:`core.transforms`,throws:`nothrow`,dataType:`(no longer used)`,uri:`core.baseUrl`,method:`core.fetch.method`,headers:`core.fetch.headers`,body:`core.fetch.body`,mode:`core.fetch.mode`,credentials:`core.fetch.credentials`,cache:`core.fetch.cache`,redirect:`core.fetch.redirect`,referrer:`core.fetch.referrer`,referrerPolicy:`core.fetch.referrerPolicy`,integrity:`core.fetch.integrity`,keepalive:`core.fetch.keepalive`,signal:`core.fetch.signal`},yp=[`baseUrl`,`fetch`,`mimeType`,`fallbackMimeType`,`ignoreRegisteredLoaders`,`nothrow`,`log`,`useLocalLibraries`,`CDN`,`worker`,`maxConcurrency`,`maxMobileConcurrency`,`reuseWorkers`,`_nodeWorkers`,`_workerType`,`limit`,`_limitMB`,`batchSize`,`batchDebounceMs`,`metadata`,`transforms`];function bp(){globalThis.loaders=globalThis.loaders||{};let{loaders:e}=globalThis;return e._state||={},e._state}function xp(){let e=bp();return e.globalOptions=e.globalOptions||{..._p,core:{..._p.core}},Cp(e.globalOptions)}function Sp(e,t,n,r){return n||=[],n=Array.isArray(n)?n:[n],wp(e,n),Cp(Dp(t,e,r))}function Cp(e){let t=Ap(e);jp(t);for(let e of yp)t.core&&t.core[e]!==void 0&&delete t[e];return t.core&&t.core._workerType!==void 0&&delete t._worker,t}function wp(e,t){Tp(e,null,_p,vp,t);for(let n of t){let r=e&&e[n.id]||{},i=n.options&&n.options[n.id]||{},a=n.deprecatedOptions&&n.deprecatedOptions[n.id]||{};Tp(r,n.id,i,a,t)}}function Tp(e,t,n,r,i){let a=t||`Top level`,o=t?`${t}.`:``;for(let s in e){let c=!t&&Bd(e[s]),l=s===`baseUri`&&!t,u=s===`workerUrl`&&t;if(!(s in n)&&!l&&!u){if(s in r)hp.level>0&&hp.warn(`${a} loader option \'${o}${s}\' no longer supported, use \'${r[s]}\'`)();else if(!c&&hp.level>0){let e=Ep(s,i);hp.warn(`${a} loader option \'${o}${s}\' not recognized. ${e}`)()}}}}function Ep(e,t){let n=e.toLowerCase(),r=``;for(let i of t)for(let t in i.options){if(e===t)return`Did you mean \'${i.id}.${t}\'?`;let a=t.toLowerCase();(n.startsWith(a)||a.startsWith(n))&&(r||=`Did you mean \'${i.id}.${t}\'?`)}return r}function Dp(e,t,n){let r=e.options||{},i={...r};return r.core&&(i.core={...r.core}),jp(i),i.core?.log===null&&(i.core={...i.core,log:new gp}),Op(i,Cp(xp())),Op(i,Cp(t)),kp(i,n),Mp(i),i}function Op(e,t){for(let n in t)if(n in t){let r=t[n];Vd(r)&&Vd(e[n])?e[n]={...e[n],...t[n]}:e[n]=t[n]}}function kp(e,t){t&&e.core?.baseUrl===void 0&&(e.core||={},e.core.baseUrl=Kf(tp(t)))}function Ap(e){let t={...e};return e.core&&(t.core={...e.core}),t}function jp(e){e.baseUri!==void 0&&(e.core||={},e.core.baseUrl===void 0&&(e.core.baseUrl=e.baseUri));for(let t of yp)if(e[t]!==void 0){let n=e.core=e.core||{};n[t]===void 0&&(n[t]=e[t])}let t=e._worker;t!==void 0&&(e.core||={},e.core._workerType===void 0&&(e.core._workerType=t))}function Mp(e){let t=e.core;if(t)for(let n of yp)t[n]!==void 0&&(e[n]=t[n])}function Np(e){return e?(Array.isArray(e)&&(e=e[0]),Array.isArray(e?.extensions)):!1}function Pp(e){id(e,`null loader`),id(Np(e),`invalid loader`);let t;return Array.isArray(e)&&(t=e[1],e=e[0],e={...e,options:{...e.options,...t}}),(e?.parseTextSync||e?.parseText)&&(e.text=!0),e.text||(e.binary=!0),e}var Fp=()=>{let e=bp();return e.loaderRegistry=e.loaderRegistry||[],e.loaderRegistry};function Ip(e){let t=Fp();e=Array.isArray(e)?e:[e];for(let n of e){let e=Pp(n);t.find(t=>e===t)||t.unshift(e)}}function Lp(){return Fp()}var Rp=/\.([^.]+)$/;async function zp(e,t=[],n,r){if(!Up(e))return null;let i=Cp(n||{});if(i.core||={},e instanceof Response&&Bp(e)){let n=Vp(await e.clone().text(),t,{...i,core:{...i.core,nothrow:!0}},r);if(n)return n}let a=Vp(e,t,{...i,core:{...i.core,nothrow:!0}},r);if(a)return a;if(qd(e)&&(e=await e.slice(0,10).arrayBuffer(),a=Vp(e,t,i,r)),!a&&e instanceof Response&&Bp(e)&&(a=Vp(await e.clone().text(),t,i,r)),!a&&!i.core.nothrow)throw Error(Wp(e));return a}function Bp(e){let t=ip(e);return!!(t&&(t.startsWith(`text/`)||t===`application/json`||t.endsWith(`+json`)))}function Vp(e,t=[],n,r){if(!Up(e))return null;let i=Cp(n||{});if(i.core||={},t&&!Array.isArray(t))return Pp(t);let a=[];t&&(a=a.concat(t)),i.core.ignoreRegisteredLoaders||a.push(...Lp()),Gp(a);let o=Hp(e,a,i,r);if(!o&&!i.core.nothrow)throw Error(Wp(e));return o}function Hp(e,t,n,r){let i=rp(e),a=ip(e),o=tp(i)||r?.url,s=null,c=``;return n?.core?.mimeType&&(s=Jp(t,n?.core?.mimeType),c=`match forced by supplied MIME type ${n?.core?.mimeType}`),s||=Kp(t,o),c||=s?`matched url ${o}`:``,s||=Jp(t,a),c||=s?`matched MIME type ${a}`:``,s||=Yp(t,e),c||=s?`matched initial data ${$p(e)}`:``,n?.core?.fallbackMimeType&&(s||=Jp(t,n?.core?.fallbackMimeType),c||=s?`matched fallback MIME type ${a}`:``),c&&Ld.log(1,`selectLoader selected ${s?.name}: ${c}.`),s}function Up(e){return!(e instanceof Response&&e.status===204)}function Wp(e){let t=rp(e),n=ip(e),r=`No valid loader found (`;r+=t?`${Gf(t)}, `:`no url provided, `,r+=`MIME type: ${n?`"${n}"`:`not provided`}, `;let i=e?$p(e):``;return r+=i?` first bytes: "${i}"`:`first bytes: not available`,r+=`)`,r}function Gp(e){for(let t of e)Pp(t)}function Kp(e,t){let n=t&&Rp.exec(t),r=n&&n[1];return r?qp(e,r):null}function qp(e,t){t=t.toLowerCase();for(let n of e)for(let e of n.extensions)if(e.toLowerCase()===t)return n;return null}function Jp(e,t){for(let n of e)if(n.mimeTypes?.some(e=>Xf(t,e))||Xf(t,`application/x.${n.id}`))return n;return null}function Yp(e,t){if(!t)return null;for(let n of e)if(typeof t==`string`){if(Xp(t,n))return n}else if(ArrayBuffer.isView(t)){if(Zp(t.buffer,t.byteOffset,n))return n}else if(t instanceof ArrayBuffer&&Zp(t,0,n))return n;return null}function Xp(e,t){return t.testText?t.testText(e):(Array.isArray(t.tests)?t.tests:[t.tests]).some(t=>e.startsWith(t))}function Zp(e,t,n){return(Array.isArray(n.tests)?n.tests:[n.tests]).some(r=>Qp(e,t,n,r))}function Qp(e,t,n,r){if(Ud(r))return Df(r,e,r.byteLength);switch(typeof r){case`function`:return r(Hf(e));case`string`:return r===em(e,t,r.length);default:return!1}}function $p(e,t=5){return typeof e==`string`?e.slice(0,t):ArrayBuffer.isView(e)?em(e.buffer,e.byteOffset,t):e instanceof ArrayBuffer?em(e,0,t):``}function em(e,t,n){if(e.byteLength<t+n)return``;let r=new DataView(e),i=``;for(let e=0;e<n;e++)i+=String.fromCharCode(r.getUint8(t+e));return i}var tm=256*1024;function*nm(e,t){let n=t?.chunkSize||tm,r=0,i=new TextEncoder;for(;r<e.length;){let t=Math.min(e.length-r,n),a=e.slice(r,r+t);r+=t,yield Hf(i.encode(a))}}var rm=256*1024;function*im(e,t={}){let{chunkSize:n=rm}=t,r=0;for(;r<e.byteLength;){let t=Math.min(e.byteLength-r,n),i=new ArrayBuffer(t),a=new Uint8Array(e,r,t);new Uint8Array(i).set(a),r+=t,yield i}}var am=1024*1024;async function*om(e,t){let n=t?.chunkSize||am,r=0;for(;r<e.size;){let t=r+n,i=await e.slice(r,t).arrayBuffer();r=t,yield i}}function sm(e,t){return od?cm(e,t):lm(e,t)}async function*cm(e,t){let n=e.getReader(),r;try{for(;;){let e=r||n.read();t?._streamReadAhead&&(r=n.read());let{done:i,value:a}=await e;if(i)return;yield Vf(a)}}catch{n.releaseLock()}}async function*lm(e,t){for await(let t of e)yield Vf(t)}function um(e,t){if(typeof e==`string`)return nm(e,t);if(e instanceof ArrayBuffer)return im(e,t);if(qd(e))return om(e,t);if(Xd(e))return sm(e,t);if(Kd(e)){let n=e.body;if(!n)throw Error(`Readable stream not available on Response`);return sm(n,t)}throw Error(`makeIterator`)}var dm=`Cannot convert supplied data type`;function fm(e,t,n){if(t.text&&typeof e==`string`)return e;if(Bf(e)&&(e=e.buffer),Ud(e)){let n=Wf(e);return t.text&&!t.binary?new TextDecoder(`utf8`).decode(n):Vf(n)}throw Error(dm)}async function pm(e,t,n){if(typeof e==`string`||Ud(e))return fm(e,t,n);if(qd(e)&&(e=await op(e)),Kd(e))return await sp(e),t.binary?await e.arrayBuffer():await e.text();if(Xd(e)&&(e=um(e,n)),Wd(e)||Gd(e))return Af(e);throw Error(dm)}function mm(e,t){let n=xp(),r=e||n,i=r.fetch??r.core?.fetch;return typeof i==`function`?i:Bd(i)?e=>mp(e,i):t?.fetch?t?.fetch:mp}function hm(e,t,n){if(n)return n;let r={fetch:mm(t,e),...e};if(r.url){let e=tp(r.url);r.baseUrl=e,r.queryString=ep(r.url),r.filename=Gf(e),r.baseUrl=Kf(e)}return Array.isArray(r.loaders)||(r.loaders=null),r}function gm(e,t){if(e&&!Array.isArray(e))return e;let n;if(e&&(n=Array.isArray(e)?e:[e]),t&&t.loaders){let e=Array.isArray(t.loaders)?t.loaders:[t.loaders];n=n?[...n,...e]:e}return n&&n.length?n:void 0}async function _m(e,t,n,r){t&&!Array.isArray(t)&&!Np(t)&&(r=void 0,n=t,t=void 0),e=await e,n||={};let i=rp(e),a=gm(t,r),o=await zp(e,a,n);if(!o)return null;let s=Sp(n,o,a,i);return r=hm({url:i,_parse:_m,loaders:a},s,r||null),await vm(o,e,s,r)}async function vm(e,t,n,r){if(Cf(e),n=Zd(e.options,n),Kd(t)){let{ok:e,redirected:n,status:i,statusText:a,type:o,url:s}=t;r.response={headers:Object.fromEntries(t.headers.entries()),ok:e,redirected:n,status:i,statusText:a,type:o,url:s}}t=await pm(t,e,n);let i=e;if(i.parseTextSync&&typeof t==`string`)return i.parseTextSync(t,n,r);if(wf(e,n))return await Tf(e,t,n,r,_m);if(i.parseText&&typeof t==`string`)return await i.parseText(t,n,r);if(i.parse)return await i.parse(t,n,r);throw nf(!i.parseSync),Error(`${e.id} loader - no parser found and worker is disabled`)}function ym(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function bm(e){return Array.isArray(e)?e.length===0||typeof e[0]==`number`:!1}function xm(e){return ym(e)||bm(e)}async function Sm(e,t,n,r){let i,a;!Array.isArray(t)&&!Np(t)?(i=[],a=t,r=void 0):(i=t,a=n);let o=mm(a),s=e;return typeof e==`string`&&(s=await o(e)),qd(e)&&(s=await o(e)),typeof e==`string`&&(Cp(a||{}).core?.baseUrl||(a={...a,core:{...a?.core,baseUrl:e}})),await _m(s,i,a)}var Cm=`4.4.2`,wm=globalThis.loaders?.parseImageNode,Tm=typeof Image<`u`,Em=typeof ImageBitmap<`u`,Dm=od?!0:!!wm;function Om(e){switch(e){case`auto`:return Em||Tm||Dm;case`imagebitmap`:return Em;case`image`:return Tm;case`data`:return Dm;default:throw Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}function km(){if(Em)return`imagebitmap`;if(Tm)return`image`;if(Dm)return`data`;throw Error(`Install '@loaders.gl/polyfills' to parse images under Node.js`)}function Am(e){let t=Mm(e);if(!t)throw Error(`Not an image`);return t}function jm(e){switch(Am(e)){case`data`:return e;case`image`:case`imagebitmap`:let t=document.createElement(`canvas`),n=t.getContext(`2d`);if(!n)throw Error(`getImageData`);return t.width=e.width,t.height=e.height,n.drawImage(e,0,0),n.getImageData(0,0,e.width,e.height);default:throw Error(`getImageData`)}}function Mm(e){return typeof ImageBitmap<`u`&&e instanceof ImageBitmap?`imagebitmap`:typeof Image<`u`&&e instanceof Image?`image`:e&&typeof e==`object`&&e.data&&e.width&&e.height?`data`:null}var Nm=/^data:image\/svg\+xml/,Pm=/\.svg((\?|#).*)?$/;function Fm(e){return e&&(Nm.test(e)||Pm.test(e))}function Im(e,t){if(Fm(t)){let t=new TextDecoder().decode(e);try{typeof unescape==`function`&&typeof encodeURIComponent==`function`&&(t=unescape(encodeURIComponent(t)))}catch(e){throw Error(e.message)}return`data:image/svg+xml;base64,${btoa(t)}`}return Lm(e,t)}function Lm(e,t){if(Fm(t))throw Error(`SVG cannot be parsed directly to imagebitmap`);return new Blob([new Uint8Array(e)])}async function Rm(e,t,n){let r=Im(e,n),i=self.URL||self.webkitURL,a=typeof r!=`string`&&i.createObjectURL(r);try{return await zm(a||r,t)}finally{a&&i.revokeObjectURL(a)}}async function zm(e,t){let n=new Image;return n.src=e,t.image&&t.image.decode&&n.decode?(await n.decode(),n):await new Promise((e,t)=>{try{n.onload=()=>e(n),n.onerror=e=>{let n=e instanceof Error?e.message:`error`;t(Error(n))}}catch(e){t(e)}})}var Bm=!0;async function Vm(e,t,n){let r;r=Fm(n)?await Rm(e,t,n):Lm(e,n);let i=t&&t.imagebitmap;return await Hm(r,i)}async function Hm(e,t=null){if((Um(t)||!Bm)&&(t=null),t)try{return await createImageBitmap(e,t)}catch(e){console.warn(e),Bm=!1}return await createImageBitmap(e)}function Um(e){if(!e)return!0;for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}function Wm(e){return!Jm(e,`ftyp`,4)||!(e[8]&96)?null:Gm(e)}function Gm(e){switch(Km(e,8,12).replace(`\0`,` `).trim()){case`avif`:case`avis`:return{extension:`avif`,mimeType:`image/avif`};default:return null}}function Km(e,t,n){return String.fromCharCode(...e.slice(t,n))}function qm(e){return[...e].map(e=>e.charCodeAt(0))}function Jm(e,t,n=0){let r=qm(t);for(let t=0;t<r.length;++t)if(r[t]!==e[t+n])return!1;return!0}var Ym=!1,Xm=!0;function Zm(e){let t=ih(e);return $m(t)||nh(t)||eh(t)||th(t)||Qm(t)}function Qm(e){let t=Wm(new Uint8Array(e instanceof DataView?e.buffer:e));return t?{mimeType:t.mimeType,width:0,height:0}:null}function $m(e){let t=ih(e);return t.byteLength>=24&&t.getUint32(0,Ym)===2303741511?{mimeType:`image/png`,width:t.getUint32(16,Ym),height:t.getUint32(20,Ym)}:null}function eh(e){let t=ih(e);return t.byteLength>=10&&t.getUint32(0,Ym)===1195984440?{mimeType:`image/gif`,width:t.getUint16(6,Xm),height:t.getUint16(8,Xm)}:null}function th(e){let t=ih(e);return t.byteLength>=14&&t.getUint16(0,Ym)===16973&&t.getUint32(2,Xm)===t.byteLength?{mimeType:`image/bmp`,width:t.getUint32(18,Xm),height:t.getUint32(22,Xm)}:null}function nh(e){let t=ih(e);if(!(t.byteLength>=3&&t.getUint16(0,Ym)===65496&&t.getUint8(2)===255))return null;let{tableMarkers:n,sofMarkers:r}=rh(),i=2;for(;i+9<t.byteLength;){let e=t.getUint16(i,Ym);if(r.has(e))return{mimeType:`image/jpeg`,height:t.getUint16(i+5,Ym),width:t.getUint16(i+7,Ym)};if(!n.has(e))return null;i+=2,i+=t.getUint16(i,Ym)}return null}function rh(){let e=new Set([65499,65476,65484,65501,65534]);for(let t=65504;t<65520;++t)e.add(t);return{tableMarkers:e,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function ih(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw Error(`toDataView`)}async function ah(e,t){let{mimeType:n}=Zm(e)||{},r=globalThis.loaders?.parseImageNode;return id(r),await r(e,n)}async function oh(e,t,n){t||={};let r=(t.image||{}).type||`auto`,{url:i}=n||{},a=sh(r),o;switch(a){case`imagebitmap`:o=await Vm(e,t,i);break;case`image`:o=await Rm(e,t,i);break;case`data`:o=await ah(e,t);break;default:id(!1)}return r===`data`&&(o=jm(o)),o}function sh(e){switch(e){case`auto`:case`data`:return km();default:return Om(e),e}}var ch={dataType:null,batchType:null,id:`image`,module:`images`,name:`Images`,version:Cm,mimeTypes:[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/avif`,`image/bmp`,`image/vnd.microsoft.icon`,`image/svg+xml`],extensions:[`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`ico`,`svg`,`avif`],parse:oh,tests:[e=>!!Zm(new DataView(e))],options:{image:{type:`auto`,decode:!0}}},X=new Md({id:`deck`}),lh={};function uh(e){lh=e}function dh(e,t,n,r){X.level>0&&lh[e]&&lh[e].call(null,t,n,r)}function fh(e){let t=e[0],n=e[e.length-1];return t===`{`&&n===`}`||t===`[`&&n===`]`}var ph={dataType:null,batchType:null,id:`JSON`,name:`JSON`,module:``,version:``,options:{},extensions:[`json`,`geojson`],mimeTypes:[`application/json`,`application/geo+json`],testText:fh,parseTextSync:JSON.parse};function mh(){let e=`9.3.2`,t=globalThis.deck&&globalThis.deck.VERSION;if(t&&t!==e)throw Error(`deck.gl - multiple versions detected: ${t} vs ${e}`);return t||(X.log(1,`deck.gl ${e}`)(),globalThis.deck={...globalThis.deck,VERSION:e,version:e,log:X,_registerLoggers:uh},Ip([ph,[ch,{imagebitmap:{premultiplyAlpha:`none`}}]])),e}var hh=mh();function gh(e,t){if(!e){let e=Error(t||`shadertools: assertion failed.`);throw Error.captureStackTrace?.(e,gh),e}}var _h={number:{type:`number`,validate(e,t){return Number.isFinite(e)&&typeof t==`object`&&(t.max===void 0||e<=t.max)&&(t.min===void 0||e>=t.min)}},array:{type:`array`,validate(e,t){return Array.isArray(e)||ArrayBuffer.isView(e)}}};function vh(e){let t={};for(let[n,r]of Object.entries(e))t[n]=yh(r);return t}function yh(e){let t=bh(e);if(t!==`object`)return{value:e,..._h[t],type:t};if(typeof e==`object`)return e?e.type===void 0?e.value===void 0?{type:`object`,value:e}:(t=bh(e.value),{...e,..._h[t],type:t}):{...e,..._h[e.type],type:e.type}:{type:`object`,value:null};throw Error(`props`)}function bh(e){return Array.isArray(e)||ArrayBuffer.isView(e)?`array`:typeof e}var xh={vertex:`#ifdef MODULE_LOGDEPTH
|
|
568
568
|
logdepth_adjustPosition(gl_Position);
|
|
569
569
|
#endif
|
|
570
570
|
`,fragment:`#ifdef MODULE_MATERIAL
|
|
@@ -587,9 +587,9 @@ try {
|
|
|
587
587
|
#ifdef MODULE_LOGDEPTH
|
|
588
588
|
logdepth_setFragDepth();
|
|
589
589
|
#endif
|
|
590
|
-
`},
|
|
591
|
-
`)}\n`;switch(t){case`vs:#decl`:i&&(e=e.replace(
|
|
592
|
-
`)){let n=e.replace(/\/\/.*$/,``).trim();if(!n||n.startsWith(`#`))continue;let r=t===`wgsl`?n.match(/^([A-Za-z0-9_]+)\s*:/):n.match(
|
|
590
|
+
`},Sh=/void\s+main\s*\([^)]*\)\s*\{\n?/,Ch=/}\n?[^{}]*$/,wh=[],Th=`__LUMA_INJECT_DECLARATIONS__`;function Eh(e){let t={vertex:{},fragment:{}};for(let n in e){let r=e[n],i=Dh(n);typeof r==`string`&&(r={order:0,injection:r}),t[i][n]=r}return t}function Dh(e){let t=e.slice(0,2);switch(t){case`vs`:return`vertex`;case`fs`:return`fragment`;default:throw Error(t)}}function Oh(e,t,n,r=!1){let i=t===`vertex`;for(let t in n){let r=n[t];r.sort((e,t)=>e.order-t.order),wh.length=r.length;for(let e=0,t=r.length;e<t;++e)wh[e]=r[e].injection;let a=`${wh.join(`
|
|
591
|
+
`)}\n`;switch(t){case`vs:#decl`:i&&(e=e.replace(Th,a));break;case`vs:#main-start`:i&&(e=e.replace(Sh,e=>e+a));break;case`vs:#main-end`:i&&(e=e.replace(Ch,e=>a+e));break;case`fs:#decl`:i||(e=e.replace(Th,a));break;case`fs:#main-start`:i||(e=e.replace(Sh,e=>e+a));break;case`fs:#main-end`:i||(e=e.replace(Ch,e=>a+e));break;default:e=e.replace(t,e=>e+a)}}return e=e.replace(Th,``),r&&(e=e.replace(/\}\s*$/,e=>e+xh[t])),e}function kh(e){e.map(e=>Ah(e))}function Ah(e){if(e.instance)return;kh(e.dependencies||[]);let{propTypes:t={},deprecations:n=[],inject:r={}}=e,i={normalizedInjections:Eh(r),parsedDeprecations:Mh(n)};t&&(i.propValidators=vh(t)),e.instance=i;let a={};t&&(a=Object.entries(t).reduce((e,[t,n])=>{let r=n?.value;return r&&(e[t]=r),e},{})),e.defaultUniforms={...e.defaultUniforms,...a}}function jh(e,t,n){e.deprecations?.forEach(e=>{e.regex?.test(t)&&(e.deprecated?n.deprecated(e.old,e.new)():n.removed(e.old,e.new)())})}function Mh(e){return e.forEach(e=>{switch(e.type){case`function`:e.regex=RegExp(`\\b${e.old}\\(`);break;default:e.regex=RegExp(`${e.type} ${e.old};`)}}),e}function Nh(e){kh(e);let t={},n={};Ph({modules:e,level:0,moduleMap:t,moduleDepth:n});let r=Object.keys(n).sort((e,t)=>n[t]-n[e]).map(e=>t[e]);return kh(r),r}function Ph(e){let{modules:t,level:n,moduleMap:r,moduleDepth:i}=e;if(n>=5)throw Error(`Possible loop in shader dependency graph`);for(let e of t)r[e.name]=e,(i[e.name]===void 0||i[e.name]<n)&&(i[e.name]=n);for(let e of t)e.dependencies&&Ph({modules:e.dependencies,level:n+1,moduleMap:r,moduleDepth:i})}var Fh=/^(?:uniform\s+)?(?:(?:lowp|mediump|highp)\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/,Ih=/((?:layout\s*\([^)]*\)\s*)*)uniform\s+([A-Za-z_][A-Za-z0-9_]*)\s*\{([\s\S]*?)\}\s*([A-Za-z_][A-Za-z0-9_]*)?\s*;/g;function Lh(e){return`${e.name}Uniforms`}function Rh(e,t){let n=t===`wgsl`?e.source:t===`vertex`?e.vs:e.fs;if(!n)return null;let r=Lh(e);return Uh(n,t===`wgsl`?`wgsl`:`glsl`,r)}function zh(e,t){let n=Object.keys(e.uniformTypes||{});if(!n.length)return null;let r=Rh(e,t);return r?{moduleName:e.name,uniformBlockName:Lh(e),stage:t,expectedUniformNames:n,actualUniformNames:r,matches:Kh(n,r)}:null}function Bh(e,t,n={}){let r=zh(e,t);if(!r||r.matches)return r;let i=qh(r);return n.log?.error?.(i,r)(),n.throwOnError!==!1&&gh(!1,i),r}function Vh(e){let t=[],n=Jh(e);for(let e of n.matchAll(Ih)){let n=e[1]?.trim()||null;t.push({blockName:e[2],body:e[3],instanceName:e[4]||null,layoutQualifier:n,hasLayoutQualifier:!!n,isStd140:!!(n&&/\blayout\s*\([^)]*\bstd140\b[^)]*\)/.exec(n))})}return t}function Hh(e,t,n,r){let i=Vh(e).filter(e=>!e.isStd140),a=new Set;for(let e of i){if(a.has(e.blockName))continue;a.add(e.blockName);let i=r?.label?`${r.label} `:``,o=e.hasLayoutQualifier?`declares ${Yh(e.layoutQualifier)} instead of layout(std140)`:`does not declare layout(std140)`,s=`${i}${t} shader uniform block ${e.blockName} ${o}. luma.gl host-side shader block packing assumes explicit layout(std140) for GLSL uniform blocks. Add \`layout(std140)\` to the block declaration.`;n?.warn?.(s,e)()}return i}function Uh(e,t,n){let r=t===`wgsl`?Wh(e,n):Gh(e,n);if(!r)return null;let i=[];for(let e of r.split(`
|
|
592
|
+
`)){let n=e.replace(/\/\/.*$/,``).trim();if(!n||n.startsWith(`#`))continue;let r=t===`wgsl`?n.match(/^([A-Za-z0-9_]+)\s*:/):n.match(Fh);r&&i.push(r[1])}return i}function Wh(e,t){let n=RegExp(`\\bstruct\\s+${t}\\b`,`m`).exec(e);if(!n)return null;let r=e.indexOf(`{`,n.index);if(r<0)return null;let i=0;for(let t=r;t<e.length;t++){let n=e[t];if(n===`{`){i++;continue}if(n===`}`&&(i--,i===0))return e.slice(r+1,t)}return null}function Gh(e,t){return Vh(e).find(e=>e.blockName===t)?.body||null}function Kh(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function qh(e){let{expectedUniformNames:t,actualUniformNames:n}=e,r=t.filter(e=>!n.includes(e)),i=n.filter(e=>!t.includes(e)),a=[`Expected ${t.length} fields, found ${n.length}.`],o=Xh(t,n);return o&&a.push(o),r.length&&a.push(`Missing from shader block (${r.length}): ${Zh(r)}.`),i.length&&a.push(`Unexpected in shader block (${i.length}): ${Zh(i)}.`),t.length<=12&&n.length<=12&&(r.length||i.length)&&(a.push(`Expected: ${t.join(`, `)}.`),a.push(`Actual: ${n.join(`, `)}.`)),`${e.moduleName}: ${e.stage} shader uniform block ${e.uniformBlockName} does not match module.uniformTypes. ${a.join(` `)}`}function Jh(e){return e.replace(/\/\*[\s\S]*?\*\//g,``).replace(/\/\/.*$/gm,``)}function Yh(e){return e.replace(/\s+/g,` `).trim()}function Xh(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return`First mismatch at field ${r+1}: expected ${e[r]}, found ${t[r]}.`;return e.length>t.length?`Shader block ends after field ${t.length}; expected next field ${e[t.length]}.`:t.length>e.length?`Shader block has extra field ${t.length}: ${t[e.length]}.`:null}function Zh(e,t=8){if(e.length<=t)return e.join(`, `);let n=e.length-t;return`${e.slice(0,t).join(`, `)}, ... (${n} more)`}function Qh(e){switch(e?.gpu.toLowerCase()){case`apple`:return`#define APPLE_GPU
|
|
593
593
|
// Apple optimizes away the calculation necessary for emulated fp64
|
|
594
594
|
#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
|
|
595
595
|
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
|
|
@@ -613,12 +613,12 @@ try {
|
|
|
613
613
|
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
|
|
614
614
|
// If the GPU doesn't have full 32 bits precision, will causes overflow
|
|
615
615
|
#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
|
|
616
|
-
`}}function
|
|
617
|
-
`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,`textureLod(`],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,`texture(`]],
|
|
618
|
-
`}return n}function
|
|
616
|
+
`}}function $h(e,t){if(Number(e.match(/^#version[ \t]+(\d+)/m)?.[1]||100)!==300)throw Error(`luma.gl v9 only supports GLSL 3.00 shader sources`);switch(t){case`vertex`:return e=rg(e,tg),e;case`fragment`:return e=rg(e,ng),e;default:throw Error(t)}}var eg=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es
|
|
617
|
+
`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,`textureLod(`],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,`texture(`]],tg=[...eg,[ig(`attribute`),`in $1`],[ig(`varying`),`out $1`]],ng=[...eg,[ig(`varying`),`in $1`]];function rg(e,t){for(let[n,r]of t)e=e.replace(n,r);return e}function ig(e){return RegExp(`\\b${e}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,`g`)}function ag(e,t){let n=``;for(let r in e){let i=e[r];if(n+=`void ${i.signature} {\n`,i.header&&(n+=` ${i.header}`),t[r]){let e=t[r];e.sort((e,t)=>e.order-t.order);for(let t of e)n+=` ${t.injection}\n`}i.footer&&(n+=` ${i.footer}`),n+=`}
|
|
618
|
+
`}return n}function og(e){let t={vertex:{},fragment:{}};for(let n of e){let e,r;typeof n==`string`?(e={},r=n):(e=n,r=e.hook),r=r.trim();let[i,a]=r.split(`:`),o=r.replace(/\(.+/,``),s=Object.assign(e,{signature:a});switch(i){case`vs`:t.vertex[o]=s;break;case`fs`:t.fragment[o]=s;break;default:throw Error(i)}}return t}function sg(e,t){return{name:cg(e,t),language:`glsl`,version:lg(e)}}function cg(e,t=`unnamed`){let n=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(e);return n?n[1]:t}function lg(e){let t=100,n=e.match(/[^\s]+/g);if(n&&n.length>=2&&n[0]===`#version`){let e=parseInt(n[1],10);Number.isFinite(e)&&(t=e)}if(t!==100&&t!==300)throw Error(`Invalid GLSL version ${t}`);return t}var ug=`(?:var<\\s*(uniform|storage(?:\\s*,\\s*[A-Za-z_][A-Za-z0-9_]*)?)\\s*>|var)\\s+([A-Za-z_][A-Za-z0-9_]*)`,dg=`\\s*`,fg=[RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${dg}@group\\(\\s*(\\d+)\\s*\\)${dg}${ug}`,`g`),RegExp(`@group\\(\\s*(\\d+)\\s*\\)${dg}@binding\\(\\s*(auto|\\d+)\\s*\\)${dg}${ug}`,`g`)],pg=[RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${dg}@group\\(\\s*(\\d+)\\s*\\)${dg}${ug}`,`g`),RegExp(`@group\\(\\s*(\\d+)\\s*\\)${dg}@binding\\(\\s*(auto|\\d+)\\s*\\)${dg}${ug}`,`g`)],mg=[RegExp(`@binding\\(\\s*(\\d+)\\s*\\)${dg}@group\\(\\s*(\\d+)\\s*\\)${dg}${ug}`,`g`),RegExp(`@group\\(\\s*(\\d+)\\s*\\)${dg}@binding\\(\\s*(\\d+)\\s*\\)${dg}${ug}`,`g`)],hg=[RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${ug}`,`g`),RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)\\s*${ug}`,`g`),RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${ug}`,`g`),RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${ug}`,`g`)];function gg(e){let t=e.split(``),n=0,r=0,i=!1,a=!1,o=!1;for(;n<e.length;){let s=e[n],c=e[n+1];if(a){o?o=!1:s===`\\`?o=!0:s===`"`&&(a=!1),n++;continue}if(i){s===`
|
|
619
619
|
`||s===`\r`?i=!1:t[n]=` `,n++;continue}if(r>0){if(s===`/`&&c===`*`){t[n]=` `,t[n+1]=` `,r++,n+=2;continue}if(s===`*`&&c===`/`){t[n]=` `,t[n+1]=` `,r--,n+=2;continue}s!==`
|
|
620
|
-
`&&s!==`\r`&&(t[n]=` `),n++;continue}if(s===`"`){a=!0,n++;continue}if(s===`/`&&c===`/`){t[n]=` `,t[n+1]=` `,i=!0,n+=2;continue}if(s===`/`&&c===`*`){t[n]=` `,t[n+1]=` `,r=1,n+=2;continue}n++}return t.join(``)}function
|
|
621
|
-
`;function
|
|
620
|
+
`&&s!==`\r`&&(t[n]=` `),n++;continue}if(s===`"`){a=!0,n++;continue}if(s===`/`&&c===`/`){t[n]=` `,t[n+1]=` `,i=!0,n+=2;continue}if(s===`/`&&c===`*`){t[n]=` `,t[n+1]=` `,r=1,n+=2;continue}n++}return t.join(``)}function _g(e,t){let n=gg(e),r=[];for(let i of t){i.lastIndex=0;let a;for(a=i.exec(n);a;){let o=i===t[0],s=a.index,c=a[0].length;r.push({match:e.slice(s,s+c),index:s,length:c,bindingToken:a[o?1:2],groupToken:a[o?2:1],accessDeclaration:a[3]?.trim(),name:a[4]}),a=i.exec(n)}}return r.sort((e,t)=>e.index-t.index)}function vg(e,t,n){let r=_g(e,t);if(!r.length)return e;let i=``,a=0;for(let t of r)i+=e.slice(a,t.index),i+=n(t),a=t.index+t.length;return i+=e.slice(a),i}function yg(e){return/@binding\(\s*auto\s*\)/.test(gg(e))}function bg(e,t){return _g(e,t===fg||t===pg?hg:t).find(e=>e.bindingToken===`auto`)}var xg=[RegExp(`@binding\\(\\s*(\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${ug}\\s*:\\s*([^;]+);`,`g`),RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(\\d+)\\s*\\)\\s*${ug}\\s*:\\s*([^;]+);`,`g`)];function Sg(e,t=[]){let n=gg(e),r=new Map;for(let e of t)r.set(wg(e.name,e.group,e.location),e.moduleName);let i=[];for(let e of xg){e.lastIndex=0;let t;for(t=e.exec(n);t;){let a=e===xg[0],o=Number(t[a?1:2]),s=Number(t[a?2:1]),c=t[3]?.trim(),l=t[4],u=t[5].trim(),d=r.get(wg(l,s,o));i.push(Cg({name:l,group:s,binding:o,owner:d?`module`:`application`,moduleName:d,accessDeclaration:c,resourceType:u})),t=e.exec(n)}}return i.sort((e,t)=>e.group===t.group?e.binding===t.binding?e.name.localeCompare(t.name):e.binding-t.binding:e.group-t.group)}function Cg(e){let t={name:e.name,group:e.group,binding:e.binding,owner:e.owner,kind:`unknown`,moduleName:e.moduleName,resourceType:e.resourceType};if(e.accessDeclaration){let n=e.accessDeclaration.split(`,`).map(e=>e.trim());if(n[0]===`uniform`)return{...t,kind:`uniform`,access:`uniform`};if(n[0]===`storage`){let e=n[1]||`read_write`;return{...t,kind:e===`read`?`read-only-storage`:`storage`,access:e}}}return e.resourceType===`sampler`||e.resourceType===`sampler_comparison`?{...t,kind:`sampler`,samplerKind:e.resourceType===`sampler_comparison`?`comparison`:`filtering`}:e.resourceType.startsWith(`texture_storage_`)?{...t,kind:`storage-texture`,access:Dg(e.resourceType),viewDimension:Tg(e.resourceType)}:e.resourceType.startsWith(`texture_`)?{...t,kind:`texture`,viewDimension:Tg(e.resourceType),sampleType:Eg(e.resourceType),multisampled:e.resourceType.startsWith(`texture_multisampled_`)}:t}function wg(e,t,n){return`${t}:${n}:${e}`}function Tg(e){if(e.includes(`cube_array`))return`cube-array`;if(e.includes(`2d_array`))return`2d-array`;if(e.includes(`cube`))return`cube`;if(e.includes(`3d`))return`3d`;if(e.includes(`2d`))return`2d`;if(e.includes(`1d`))return`1d`}function Eg(e){if(e.startsWith(`texture_depth_`))return`depth`;if(e.includes(`<i32>`))return`sint`;if(e.includes(`<u32>`))return`uint`;if(e.includes(`<f32>`))return`float`}function Dg(e){return/,\s*([A-Za-z_][A-Za-z0-9_]*)\s*>$/.exec(e)?.[1]}var Og=`\n\n${Th}\n`,kg=100,Ag=`precision highp float;
|
|
621
|
+
`;function jg(e){let t=Nh(e.modules||[]),{source:n,bindingAssignments:r}=Ng(e.platformInfo,{...e,source:e.source,stage:`vertex`,modules:t});return{source:n,getUniforms:Fg(t),bindingAssignments:r,bindingTable:Sg(n,r)}}function Mg(e){let{vs:t,fs:n}=e,r=Nh(e.modules||[]);return{vs:Pg(e.platformInfo,{...e,source:t,stage:`vertex`,modules:r}),fs:Pg(e.platformInfo,{...e,source:n,stage:`fragment`,modules:r}),getUniforms:Fg(r)}}function Ng(e,t){let{source:n,stage:r,modules:i,hookFunctions:a=[],inject:o={},log:s}=t;gh(typeof n==`string`,`shader source must be a string`);let c=n,l=``,u=og(a),d={},f={},p={};for(let e in o){let t=typeof o[e]==`string`?{injection:o[e],order:0}:o[e],n=/^(v|f)s:(#)?([\w-]+)$/.exec(e);if(n){let r=n[2],i=n[3];r?i===`decl`?f[e]=[t]:p[e]=[t]:d[e]=[t]}else p[e]=[t]}let m=i,h=zg(c),g=Rg(h.source),_=Ug(m,t._bindingRegistry,g),v=[];for(let e of m){s&&jh(e,c,s);let n=Bg(Lg(e,`wgsl`,s),e,{usedBindingsByGroup:g,bindingRegistry:t._bindingRegistry,reservedBindingKeysByGroup:_});v.push(...n.bindingAssignments);let i=n.source;l+=i;let a=e.injections?.[r]||{};for(let e in a){let t=/^(v|f)s:#([\w-]+)$/.exec(e);if(t){let n=t[2]===`decl`?f:p;n[e]=n[e]||[],n[e].push(a[e])}else d[e]=d[e]||[],d[e].push(a[e])}}return l+=Og,l=Oh(l,r,f),l+=ag(u[r],d),l+=Qg(v),l+=h.source,l=Oh(l,r,p),Zg(l),{source:l,bindingAssignments:v}}function Pg(e,t){let{source:n,stage:r,language:i=`glsl`,modules:a,defines:o={},hookFunctions:s=[],inject:c={},prologue:l=!0,log:u}=t;gh(typeof n==`string`,`shader source must be a string`);let d=i===`glsl`?sg(n).version:-1,f=e.shaderLanguageVersion,p=d===100?`#version 100`:`#version 300 es`,m=n.split(`
|
|
622
622
|
`).slice(1).join(`
|
|
623
623
|
`),h={};a.forEach(e=>{Object.assign(h,e.defines)}),Object.assign(h,o);let g=``;switch(i){case`wgsl`:break;case`glsl`:g=l?`\
|
|
624
624
|
${p}
|
|
@@ -626,32 +626,32 @@ ${p}
|
|
|
626
626
|
// ----- PROLOGUE -------------------------
|
|
627
627
|
${`#define SHADER_TYPE_${r.toUpperCase()}`}
|
|
628
628
|
|
|
629
|
-
${
|
|
630
|
-
${r===`fragment`?
|
|
629
|
+
${Qh(e)}
|
|
630
|
+
${r===`fragment`?Ag:``}
|
|
631
631
|
|
|
632
632
|
// ----- APPLICATION DEFINES -------------------------
|
|
633
633
|
|
|
634
|
-
${
|
|
634
|
+
${Ig(h)}
|
|
635
635
|
|
|
636
636
|
`:`${p}
|
|
637
|
-
`;break}let _
|
|
637
|
+
`;break}let _=og(s),v={},y={},b={};for(let e in c){let t=typeof c[e]==`string`?{injection:c[e],order:0}:c[e],n=/^(v|f)s:(#)?([\w-]+)$/.exec(e);if(n){let r=n[2],i=n[3];r?i===`decl`?y[e]=[t]:b[e]=[t]:v[e]=[t]}else b[e]=[t]}for(let e of a){u&&jh(e,m,u);let t=Lg(e,r,u);g+=t;let n=e.instance?.normalizedInjections[r]||{};for(let e in n){let t=/^(v|f)s:#([\w-]+)$/.exec(e);if(t){let r=t[2]===`decl`?y:b;r[e]=r[e]||[],r[e].push(n[e])}else v[e]=v[e]||[],v[e].push(n[e])}}return g+=`// ----- MAIN SHADER SOURCE -------------------------`,g+=Og,g=Oh(g,r,y),g+=ag(_[r],v),g+=m,g=Oh(g,r,b),i===`glsl`&&d!==f&&(g=$h(g,r)),i===`glsl`&&Hh(g,r,u),g.trim()}function Fg(e){return function(t){let n={};for(let r of e){let e=r.getUniforms?.(t,n);Object.assign(n,e)}return n}}function Ig(e={}){let t=``;for(let n in e){let r=e[n];(r||Number.isFinite(r))&&(t+=`#define ${n.toUpperCase()} ${e[n]}\n`)}return t}function Lg(e,t,n){let r;switch(t){case`vertex`:r=e.vs||``;break;case`fragment`:r=e.fs||``;break;case`wgsl`:r=e.source||``;break;default:gh(!1)}if(!e.name)throw Error(`Shader module must have a name`);Bh(e,t,{log:n});let i=e.name.toUpperCase().replace(/[^0-9a-z]/gi,`_`),a=`\
|
|
638
638
|
// ----- MODULE ${e.name} ---------------
|
|
639
639
|
|
|
640
|
-
`;return t!==`wgsl`&&(a+=`#define MODULE_${i}\n`),a+=`${r}\n`,a}function
|
|
640
|
+
`;return t!==`wgsl`&&(a+=`#define MODULE_${i}\n`),a+=`${r}\n`,a}function Rg(e){let t=new Map;for(let n of _g(e,mg)){let e=Number(n.bindingToken),r=Number(n.groupToken);Kg(r,e,n.name),Jg(t,r,e,`application binding "${n.name}"`)}return t}function zg(e){let t=_g(e,pg),n=new Map;for(let e of t){if(e.bindingToken===`auto`)continue;let t=Number(e.bindingToken),r=Number(e.groupToken);Kg(r,t,e.name),Jg(n,r,t,`application binding "${e.name}"`)}let r={sawSupportedBindingDeclaration:t.length>0},i=vg(e,pg,e=>Hg(e,n,r));if(yg(e)&&!r.sawSupportedBindingDeclaration)throw Error(`Unsupported @binding(auto) declaration form in application WGSL. Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.`);return{source:i}}function Bg(e,t,n){let r=[],i={sawSupportedBindingDeclaration:_g(e,fg).length>0,nextHintedBindingLocation:typeof t.firstBindingSlot==`number`?t.firstBindingSlot:null},a=vg(e,fg,e=>Vg(e,{module:t,context:n,bindingAssignments:r,relocationState:i}));if(yg(e)&&!i.sawSupportedBindingDeclaration)throw Error(`Unsupported @binding(auto) declaration form in module "${t.name}". Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.`);return{source:a,bindingAssignments:r}}function Vg(e,t){let{module:n,context:r,bindingAssignments:i,relocationState:a}=t,{match:o,bindingToken:s,groupToken:c,name:l}=e,u=Number(c);if(s===`auto`){let e=$g(u,n.name,l),t=r.bindingRegistry?.get(e),s=t===void 0?a.nextHintedBindingLocation===null?Yg(u,r.usedBindingsByGroup):Yg(u,r.usedBindingsByGroup,a.nextHintedBindingLocation):t;return qg(n.name,u,s,l),t!==void 0&&Wg(r.reservedBindingKeysByGroup,u,s,e)?(i.push({moduleName:n.name,name:l,group:u,location:s}),o.replace(/@binding\(\s*auto\s*\)/,`@binding(${s})`)):(Jg(r.usedBindingsByGroup,u,s,`module "${n.name}" binding "${l}"`),r.bindingRegistry?.set(e,s),i.push({moduleName:n.name,name:l,group:u,location:s}),a.nextHintedBindingLocation!==null&&t===void 0&&(a.nextHintedBindingLocation=s+1),o.replace(/@binding\(\s*auto\s*\)/,`@binding(${s})`))}let d=Number(s);return qg(n.name,u,d,l),Jg(r.usedBindingsByGroup,u,d,`module "${n.name}" binding "${l}"`),i.push({moduleName:n.name,name:l,group:u,location:d}),o}function Hg(e,t,n){let{match:r,bindingToken:i,groupToken:a,name:o}=e,s=Number(a);if(i===`auto`){let e=Xg(s,t);return Kg(s,e,o),Jg(t,s,e,`application binding "${o}"`),r.replace(/@binding\(\s*auto\s*\)/,`@binding(${e})`)}return n.sawSupportedBindingDeclaration=!0,r}function Ug(e,t,n){let r=new Map;if(!t)return r;for(let i of e)for(let e of Gg(i)){let a=$g(e.group,i.name,e.name),o=t.get(a);if(o!==void 0){let t=r.get(e.group)||new Map,i=t.get(o);if(i&&i!==a)throw Error(`Duplicate WGSL binding reservation for modules "${i}" and "${a}": group ${e.group}, binding ${o}.`);Jg(n,e.group,o,`registered module binding "${a}"`),t.set(o,a),r.set(e.group,t)}}return r}function Wg(e,t,n,r){let i=e.get(t);if(!i)return!1;let a=i.get(n);if(!a)return!1;if(a!==r)throw Error(`Registered module binding "${r}" collided with "${a}": group ${t}, binding ${n}.`);return!0}function Gg(e){let t=[],n=e.source||``;for(let e of _g(n,fg))t.push({name:e.name,group:Number(e.groupToken)});return t}function Kg(e,t,n){if(e===0&&t>=kg)throw Error(`Application binding "${n}" in group 0 uses reserved binding ${t}. Application-owned explicit group-0 bindings must stay below ${kg}.`)}function qg(e,t,n,r){if(t===0&&n<kg)throw Error(`Module "${e}" binding "${r}" in group 0 uses reserved application binding ${n}. Module-owned explicit group-0 bindings must be ${kg} or higher.`)}function Jg(e,t,n,r){let i=e.get(t)||new Set;if(i.has(n))throw Error(`Duplicate WGSL binding assignment for ${r}: group ${t}, binding ${n}.`);i.add(n),e.set(t,i)}function Yg(e,t,n){let r=t.get(e)||new Set,i=n??(e===0?kg:r.size>0?Math.max(...r)+1:0);for(;r.has(i);)i++;return i}function Xg(e,t){let n=t.get(e)||new Set,r=0;for(;n.has(r);)r++;return r}function Zg(e){let t=bg(e,fg);if(!t)return;let n=e_(e,t.index);throw n?Error(`Unresolved @binding(auto) for module "${n}" binding "${t.name}" remained in assembled WGSL source.`):t_(e,t.index)?Error(`Unresolved @binding(auto) for application binding "${t.name}" remained in assembled WGSL source.`):Error(`Unresolved @binding(auto) remained in assembled WGSL source near "${n_(t.match)}".`)}function Qg(e){if(e.length===0)return``;let t=`// ----- MODULE WGSL BINDING ASSIGNMENTS ---------------
|
|
641
641
|
`;for(let n of e)t+=`// ${n.moduleName}.${n.name} -> @group(${n.group}) @binding(${n.location})\n`;return t+=`
|
|
642
|
-
`,t}function
|
|
643
|
-
`),r=[],i=[],a=!0;for(let e of n){let n=e.match(
|
|
644
|
-
`)}var
|
|
642
|
+
`,t}function $g(e,t,n){return`${e}:${t}:${n}`}function e_(e,t){let n=/^\/\/ ----- MODULE ([^\n]+) ---------------$/gm,r,i;for(i=n.exec(e);i&&i.index<=t;)r=i[1],i=n.exec(e);return r}function t_(e,t){let n=e.indexOf(Og);return n>=0?t>n:!0}function n_(e){return e.replace(/\s+/g,` `).trim()}var r_=`([a-zA-Z_][a-zA-Z0-9_]*)`,i_=RegExp(`^\\s*\\#\\s*ifdef\\s*${r_}\\s*$`),a_=RegExp(`^\\s*\\#\\s*ifndef\\s*${r_}\\s*(?:\\/\\/.*)?$`),o_=/^\s*\#\s*else\s*(?:\/\/.*)?$/,s_=/^\s*\#\s*endif\s*$/,c_=RegExp(`^\\s*\\#\\s*ifdef\\s*${r_}\\s*(?:\\/\\/.*)?$`),l_=/^\s*\#\s*endif\s*(?:\/\/.*)?$/;function u_(e,t){let n=e.split(`
|
|
643
|
+
`),r=[],i=[],a=!0;for(let e of n){let n=e.match(c_)||e.match(i_),o=e.match(a_),s=e.match(o_),c=e.match(l_)||e.match(s_);if(n||o){let e=(n||o)?.[1],r=!!t?.defines?.[e],s=n?r:!r,c=a&&s;i.push({parentActive:a,branchTaken:s,active:c}),a=c}else if(s){let e=i[i.length-1];if(!e)throw Error(`Encountered #else without matching #ifdef or #ifndef`);e.active=e.parentActive&&!e.branchTaken,e.branchTaken=!0,a=e.active}else c?(i.pop(),a=i.length?i[i.length-1].active:!0):a&&r.push(e)}if(i.length>0)throw Error(`Unterminated conditional block in shader source`);return r.join(`
|
|
644
|
+
`)}var d_=class e{static defaultShaderAssembler;_hookFunctions=[];_defaultModules=[];_wgslBindingRegistry=new Map;static getDefaultShaderAssembler(){return e.defaultShaderAssembler=e.defaultShaderAssembler||new e,e.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(t=>t.name===(typeof e==`string`?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){let t=typeof e==`string`?e:e.name;this._defaultModules=this._defaultModules.filter(e=>e.name!==t)}addShaderHook(e,t){t&&(e=Object.assign(t,{hook:e})),this._hookFunctions.push(e)}assembleWGSLShader(e){let t=this._getModuleList(e.modules),n=this._hookFunctions,{source:r,getUniforms:i,bindingAssignments:a}=jg({...e,source:e.source,_bindingRegistry:this._wgslBindingRegistry,modules:t,hookFunctions:n}),o={...t.reduce((e,t)=>(Object.assign(e,t.defines),e),{}),...e.defines},s=e.platformInfo.shaderLanguage===`wgsl`?u_(r,{defines:o}):r;return{source:s,getUniforms:i,modules:t,bindingAssignments:a,bindingTable:Sg(s,a)}}assembleGLSLShaderPair(e){let t=this._getModuleList(e.modules),n=this._hookFunctions;return{...Mg({...e,vs:e.vs,fs:e.fs,modules:t,hookFunctions:n}),modules:t}}_getModuleList(e=[]){let t=Array(this._defaultModules.length+e.length),n={},r=0;for(let e=0,i=this._defaultModules.length;e<i;++e){let i=this._defaultModules[e],a=i.name;t[r++]=i,n[a]=!0}for(let i=0,a=e.length;i<a;++i){let a=e[i],o=a.name;n[o]||(t[r++]=a,n[o]=!0)}return t.length=r,kh(t),t}},f_=`#version 300 es
|
|
645
645
|
out vec4 transform_output;
|
|
646
646
|
void main() {
|
|
647
647
|
transform_output = vec4(0);
|
|
648
|
-
}`;function
|
|
648
|
+
}`;function p_(e){let{input:t,inputChannels:n,output:r}=e||{};if(!t)return f_;if(!n)throw Error(`inputChannels`);return`\
|
|
649
649
|
#version 300 es
|
|
650
|
-
in ${
|
|
650
|
+
in ${m_(n)} ${t};
|
|
651
651
|
out vec4 ${r};
|
|
652
652
|
void main() {
|
|
653
|
-
${r} = ${
|
|
654
|
-
}`}function s_(e){switch(e){case 1:return`float`;case 2:return`vec2`;case 3:return`vec3`;case 4:return`vec4`;default:throw Error(`invalid channels: ${e}`)}}function c_(e,t){switch(t){case 1:return`vec4(${e}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${e}, 0.0, 1.0)`;case 3:return`vec4(${e}, 1.0)`;case 4:return e;default:throw Error(`invalid channels: ${t}`)}}1/Math.PI*180,1/180*Math.PI,globalThis.mathgl=globalThis.mathgl||{config:{EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1}};var l_=globalThis.mathgl.config;function u_(e,{precision:t=l_.precision}={}){return e=h_(e),`${parseFloat(e.toPrecision(t))}`}function d_(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function f_(e,t,n){return __(e,e=>Math.max(t,Math.min(n,e)))}function p_(e,t,n){return d_(e)?e.map((e,r)=>p_(e,t[r],n)):n*t+(1-n)*e}function m_(e,t,n){let r=l_.EPSILON;n&&(l_.EPSILON=n);try{if(e===t)return!0;if(d_(e)&&d_(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!m_(e[n],t[n]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):typeof e==`number`&&typeof t==`number`?Math.abs(e-t)<=l_.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{l_.EPSILON=r}}function h_(e){return Math.round(e/l_.EPSILON)*l_.EPSILON}function g_(e){return e.clone?e.clone():Array(e.length)}function __(e,t,n){if(d_(e)){let r=e;n||=g_(r);for(let i=0;i<n.length&&i<r.length;++i){let r=typeof e==`number`?e:e[i];n[i]=t(r,i,n)}return n}return t(e)}var v_=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,t=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=e[n+t];return this.check()}toArray(e=[],t=0){for(let n=0;n<this.ELEMENTS;++n)e[t+n]=this[n];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:d_(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(l_)}formatString(e){let t=``;for(let n=0;n<this.ELEMENTS;++n)t+=(n>0?`, `:``)+u_(this[n],e);return`${e.printTypes?this.constructor.name:``}[${t}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(!m_(this[t],e[t]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(this[t]!==e[t])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,t,n){if(n===void 0)return this.lerp(this,e,t);for(let r=0;r<this.ELEMENTS;++r){let i=e[r],a=typeof t==`number`?t:t[r];this[r]=i+n*(a-i)}return this.check()}min(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.min(e[t],this[t]);return this.check()}max(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.max(e[t],this[t]);return this.check()}clamp(e,t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e[n]),t[n]);return this.check()}add(...e){for(let t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]+=t[e];return this.check()}subtract(...e){for(let t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]-=t[e];return this.check()}scale(e){if(typeof e==`number`)for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;else for(let t=0;t<this.ELEMENTS&&t<e.length;++t)this[t]*=e[t];return this.check()}multiplyByScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}check(){if(l_.debug&&!this.validate())throw Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let t=0;t<this.ELEMENTS;++t)e&&=Number.isFinite(this[t]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=e;return this.check()}addScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e),t);return this.check()}get elements(){return this}};function y_(e,t){if(e.length!==t)return!1;for(let t=0;t<e.length;++t)if(!Number.isFinite(e[t]))return!1;return!0}function b_(e){if(!Number.isFinite(e))throw Error(`Invalid number ${JSON.stringify(e)}`);return e}function x_(e,t,n=``){if(l_.debug&&!y_(e,t))throw Error(`math.gl: ${n} some fields set to invalid numbers'`);return e}function S_(e,t){if(!e)throw Error(`math.gl assertion ${t}`)}var C_=class extends v_{get x(){return this[0]}set x(e){this[0]=b_(e)}get y(){return this[1]}set y(e){this[1]=b_(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let t=0;t<this.ELEMENTS;++t)e+=this[t]*this[t];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let t=0;for(let n=0;n<this.ELEMENTS;++n){let r=this[n]-e[n];t+=r*r}return b_(t)}dot(e){let t=0;for(let n=0;n<this.ELEMENTS;++n)t+=this[n]*e[n];return b_(t)}normalize(){let e=this.magnitude();if(e!==0)for(let t=0;t<this.ELEMENTS;++t)this[t]/=e;return this.check()}multiply(...e){for(let t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]*=t[e];return this.check()}divide(...e){for(let t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]/=t[e];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return S_(e>=0&&e<this.ELEMENTS,`index is out of range`),b_(this[e])}setComponent(e,t){return S_(e>=0&&e<this.ELEMENTS,`index is out of range`),this[e]=t,this.check()}addVectors(e,t){return this.copy(e).add(t)}subVectors(e,t){return this.copy(e).subtract(t)}multiplyVectors(e,t){return this.copy(e).multiply(t)}addScaledVector(e,t){return this.add(new this.constructor(e).multiplyScalar(t))}},w_=typeof Float32Array<`u`?Float32Array:Array;Math.PI/180;function T_(){let e=new w_(2);return w_!=Float32Array&&(e[0]=0,e[1]=0),e}function E_(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e}function D_(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e}function O_(e,t){return e[0]=-t[0],e[1]=-t[1],e}function k_(e,t,n,r){let i=t[0],a=t[1];return e[0]=i+r*(n[0]-i),e[1]=a+r*(n[1]-a),e}function A_(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}var j_=D_;(function(){let e=T_();return function(t,n,r,i,a,o){let s,c;for(n||=2,r||=0,c=i?Math.min(i*n+r,t.length):t.length,s=r;s<c;s+=n)e[0]=t[s],e[1]=t[s+1],a(e,e,o),t[s]=e[0],t[s+1]=e[1];return t}})();function M_(e,t,n){let r=t[0],i=t[1],a=n[3]*r+n[7]*i||1;return e[0]=(n[0]*r+n[4]*i)/a,e[1]=(n[1]*r+n[5]*i)/a,e}function N_(e,t,n){let r=t[0],i=t[1],a=t[2],o=n[3]*r+n[7]*i+n[11]*a||1;return e[0]=(n[0]*r+n[4]*i+n[8]*a)/o,e[1]=(n[1]*r+n[5]*i+n[9]*a)/o,e[2]=(n[2]*r+n[6]*i+n[10]*a)/o,e}function P_(e,t,n){let r=t[0],i=t[1];return e[0]=n[0]*r+n[2]*i,e[1]=n[1]*r+n[3]*i,e[2]=t[2],e}function F_(){let e=new w_(3);return w_!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function I_(e){let t=e[0],n=e[1],r=e[2];return Math.sqrt(t*t+n*n+r*r)}function L_(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e}function R_(e,t){let n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2];return Math.sqrt(n*n+r*r+i*i)}function z_(e){let t=e[0],n=e[1],r=e[2];return t*t+n*n+r*r}function B_(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function V_(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function H_(e,t,n){let 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}function U_(e,t,n,r){let i=t[0],a=t[1],o=t[2];return e[0]=i+r*(n[0]-i),e[1]=a+r*(n[1]-a),e[2]=o+r*(n[2]-o),e}function W_(e,t,n){let r=t[0],i=t[1],a=t[2],o=n[3]*r+n[7]*i+n[11]*a+n[15];return o||=1,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}function G_(e,t,n){let 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}function K_(e,t,n){let 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,p=i*f-a*d,m=a*u-r*f,h=r*d-i*u,g=o*2;return u*=g,d*=g,f*=g,p*=2,m*=2,h*=2,e[0]=s+u+p,e[1]=c+d+m,e[2]=l+f+h,e}function q_(e,t,n,r){let 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}function J_(e,t,n,r){let 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}function Y_(e,t,n,r){let 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}function X_(e,t){let n=e[0],r=e[1],i=e[2],a=t[0],o=t[1],s=t[2],c=Math.sqrt((n*n+r*r+i*i)*(a*a+o*o+s*s)),l=c&&V_(e,t)/c;return Math.acos(Math.min(Math.max(l,-1),1))}var Z_=L_,Q_=R_,$_=I_,ev=z_;(function(){let e=F_();return function(t,n,r,i,a,o){let s,c;for(n||=3,r||=0,c=i?Math.min(i*n+r,t.length):t.length,s=r;s<c;s+=n)e[0]=t[s],e[1]=t[s+1],e[2]=t[s+2],a(e,e,o),t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2];return t}})();var tv=[0,0,0],nv,rv=class e extends C_{static get ZERO(){return nv||(nv=new e(0,0,0),Object.freeze(nv)),nv}constructor(e=0,t=0,n=0){super(-0,-0,-0),arguments.length===1&&d_(e)?this.copy(e):(l_.debug&&(b_(e),b_(t),b_(n)),this[0]=e,this[1]=t,this[2]=n)}set(e,t,n){return this[0]=e,this[1]=t,this[2]=n,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return l_.debug&&(b_(e.x),b_(e.y),b_(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=b_(e)}angle(e){return X_(this,e)}cross(e){return H_(this,this,e),this.check()}rotateX({radians:e,origin:t=tv}){return q_(this,this,t,e),this.check()}rotateY({radians:e,origin:t=tv}){return J_(this,this,t,e),this.check()}rotateZ({radians:e,origin:t=tv}){return Y_(this,this,t,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return W_(this,this,e),this.check()}transformAsVector(e){return N_(this,this,e),this.check()}transformByMatrix3(e){return G_(this,this,e),this.check()}transformByMatrix2(e){return P_(this,this,e),this.check()}transformByQuaternion(e){return K_(this,this,e),this.check()}},iv=class extends v_{toString(){let e=`[`;if(l_.printRowMajor){e+=`row-major:`;for(let t=0;t<this.RANK;++t)for(let n=0;n<this.RANK;++n)e+=` ${this[n*this.RANK+t]}`}else{e+=`column-major:`;for(let t=0;t<this.ELEMENTS;++t)e+=` ${this[t]}`}return e+=`]`,e}getElementIndex(e,t){return t*this.RANK+e}getElement(e,t){return this[t*this.RANK+e]}setElement(e,t,n){return this[t*this.RANK+e]=b_(n),this}getColumn(e,t=Array(this.RANK).fill(-0)){let n=e*this.RANK;for(let e=0;e<this.RANK;++e)t[e]=this[n+e];return t}setColumn(e,t){let n=e*this.RANK;for(let e=0;e<this.RANK;++e)this[n+e]=t[e];return this}};function av(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 ov(e,t){if(e===t){let n=t[1],r=t[2],i=t[3],a=t[6],o=t[7],s=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=a,e[11]=t[14],e[12]=i,e[13]=o,e[14]=s}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function sv(e,t){let 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,ee=d*g-f*h,te=d*_-p*h,ne=f*_-p*g,D=v*ne-y*te+b*ee+x*E-S*T+C*w;return D?(D=1/D,e[0]=(s*ne-c*te+l*ee)*D,e[1]=(i*te-r*ne-a*ee)*D,e[2]=(h*C-g*S+_*x)*D,e[3]=(f*S-d*C-p*x)*D,e[4]=(c*E-o*ne-l*T)*D,e[5]=(n*ne-i*E+a*T)*D,e[6]=(g*b-m*C-_*y)*D,e[7]=(u*C-f*b+p*y)*D,e[8]=(o*te-s*E+l*w)*D,e[9]=(r*E-n*te-a*w)*D,e[10]=(m*S-h*b+_*v)*D,e[11]=(d*b-u*S-p*v)*D,e[12]=(s*T-o*ee-c*w)*D,e[13]=(n*ee-r*T+i*w)*D,e[14]=(h*y-m*x-g*v)*D,e[15]=(u*x-d*y+f*v)*D,e):null}function cv(e){let t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=t*o-n*a,v=t*s-r*a,y=n*s-r*o,b=l*m-u*p,x=l*h-d*p,S=u*h-d*m,C=t*S-n*x+r*b,w=a*S-o*x+s*b,T=l*y-u*v+d*_,E=p*y-m*v+h*_;return c*C-i*w+g*T-f*E}function lv(e,t,n){let 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,y=n[4],b=n[5],x=n[6],S=n[7],e[4]=y*r+b*s+x*d+S*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,y=n[8],b=n[9],x=n[10],S=n[11],e[8]=y*r+b*s+x*d+S*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,y=n[12],b=n[13],x=n[14],S=n[15],e[12]=y*r+b*s+x*d+S*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}function uv(e,t,n){let r=n[0],i=n[1],a=n[2],o,s,c,l,u,d,f,p,m,h,g,_;return t===e?(e[12]=t[0]*r+t[4]*i+t[8]*a+t[12],e[13]=t[1]*r+t[5]*i+t[9]*a+t[13],e[14]=t[2]*r+t[6]*i+t[10]*a+t[14],e[15]=t[3]*r+t[7]*i+t[11]*a+t[15]):(o=t[0],s=t[1],c=t[2],l=t[3],u=t[4],d=t[5],f=t[6],p=t[7],m=t[8],h=t[9],g=t[10],_=t[11],e[0]=o,e[1]=s,e[2]=c,e[3]=l,e[4]=u,e[5]=d,e[6]=f,e[7]=p,e[8]=m,e[9]=h,e[10]=g,e[11]=_,e[12]=o*r+u*i+m*a+t[12],e[13]=s*r+d*i+h*a+t[13],e[14]=c*r+f*i+g*a+t[14],e[15]=l*r+p*i+_*a+t[15]),e}function dv(e,t,n){let 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}function fv(e,t,n,r){let i=r[0],a=r[1],o=r[2],s=Math.sqrt(i*i+a*a+o*o),c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,ee,te,ne,D,O;return s<1e-6?null:(s=1/s,i*=s,a*=s,o*=s,l=Math.sin(n),c=Math.cos(n),u=1-c,d=t[0],f=t[1],p=t[2],m=t[3],h=t[4],g=t[5],_=t[6],v=t[7],y=t[8],b=t[9],x=t[10],S=t[11],C=i*i*u+c,w=a*i*u+o*l,T=o*i*u-a*l,E=i*a*u-o*l,ee=a*a*u+c,te=o*a*u+i*l,ne=i*o*u+a*l,D=a*o*u-i*l,O=o*o*u+c,e[0]=d*C+h*w+y*T,e[1]=f*C+g*w+b*T,e[2]=p*C+_*w+x*T,e[3]=m*C+v*w+S*T,e[4]=d*E+h*ee+y*te,e[5]=f*E+g*ee+b*te,e[6]=p*E+_*ee+x*te,e[7]=m*E+v*ee+S*te,e[8]=d*ne+h*D+y*O,e[9]=f*ne+g*D+b*O,e[10]=p*ne+_*D+x*O,e[11]=m*ne+v*D+S*O,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function pv(e,t,n){let 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}function mv(e,t,n){let 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}function hv(e,t,n){let 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}function gv(e,t){let n=t[0],r=t[1],i=t[2],a=t[3],o=n+n,s=r+r,c=i+i,l=n*o,u=r*o,d=r*s,f=i*o,p=i*s,m=i*c,h=a*o,g=a*s,_=a*c;return e[0]=1-d-m,e[1]=u+_,e[2]=f-g,e[3]=0,e[4]=u-_,e[5]=1-l-m,e[6]=p+h,e[7]=0,e[8]=f+g,e[9]=p-h,e[10]=1-l-d,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function _v(e,t,n,r,i,a,o){let s=1/(n-t),c=1/(i-r),l=1/(a-o);return e[0]=a*2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a*2*c,e[6]=0,e[7]=0,e[8]=(n+t)*s,e[9]=(i+r)*c,e[10]=(o+a)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*a*2*l,e[15]=0,e}function vv(e,t,n,r,i){let 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){let t=1/(r-i);e[10]=(i+r)*t,e[14]=2*i*r*t}else e[10]=-1,e[14]=-2*r;return e}var yv=vv;function bv(e,t,n,r,i,a,o){let 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}var xv=bv;function Sv(e,t,n,r){let i,a,o,s,c,l,u,d,f,p,m=t[0],h=t[1],g=t[2],_=r[0],v=r[1],y=r[2],b=n[0],x=n[1],S=n[2];return Math.abs(m-b)<1e-6&&Math.abs(h-x)<1e-6&&Math.abs(g-S)<1e-6?av(e):(d=m-b,f=h-x,p=g-S,i=1/Math.sqrt(d*d+f*f+p*p),d*=i,f*=i,p*=i,a=v*p-y*f,o=y*d-_*p,s=_*f-v*d,i=Math.sqrt(a*a+o*o+s*s),i?(i=1/i,a*=i,o*=i,s*=i):(a=0,o=0,s=0),c=f*s-p*o,l=p*a-d*s,u=d*o-f*a,i=Math.sqrt(c*c+l*l+u*u),i?(i=1/i,c*=i,l*=i,u*=i):(c=0,l=0,u=0),e[0]=a,e[1]=c,e[2]=d,e[3]=0,e[4]=o,e[5]=l,e[6]=f,e[7]=0,e[8]=s,e[9]=u,e[10]=p,e[11]=0,e[12]=-(a*m+o*h+s*g),e[13]=-(c*m+l*h+u*g),e[14]=-(d*m+f*h+p*g),e[15]=1,e)}function Cv(){let e=new w_(4);return w_!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function wv(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}function Tv(e,t,n){let 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(){let e=Cv();return function(t,n,r,i,a,o){let s,c;for(n||=4,r||=0,c=i?Math.min(i*n+r,t.length):t.length,s=r;s<c;s+=n)e[0]=t[s],e[1]=t[s+1],e[2]=t[s+2],e[3]=t[s+3],a(e,e,o),t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2],t[s+3]=e[3];return t}})();var Ev;(function(e){e[e.COL0ROW0=0]=`COL0ROW0`,e[e.COL0ROW1=1]=`COL0ROW1`,e[e.COL0ROW2=2]=`COL0ROW2`,e[e.COL0ROW3=3]=`COL0ROW3`,e[e.COL1ROW0=4]=`COL1ROW0`,e[e.COL1ROW1=5]=`COL1ROW1`,e[e.COL1ROW2=6]=`COL1ROW2`,e[e.COL1ROW3=7]=`COL1ROW3`,e[e.COL2ROW0=8]=`COL2ROW0`,e[e.COL2ROW1=9]=`COL2ROW1`,e[e.COL2ROW2=10]=`COL2ROW2`,e[e.COL2ROW3=11]=`COL2ROW3`,e[e.COL3ROW0=12]=`COL3ROW0`,e[e.COL3ROW1=13]=`COL3ROW1`,e[e.COL3ROW2=14]=`COL3ROW2`,e[e.COL3ROW3=15]=`COL3ROW3`})(Ev||={});var Dv=45*Math.PI/180,Ov=1,kv=.1,Av=500,jv=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),Mv=class extends iv{static get IDENTITY(){return Iv()}static get ZERO(){return Fv()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Ev}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){return this[0]=e,this[1]=t,this[2]=n,this[3]=r,this[4]=i,this[5]=a,this[6]=o,this[7]=s,this[8]=c,this[9]=l,this[10]=u,this[11]=d,this[12]=f,this[13]=p,this[14]=m,this[15]=h,this.check()}setRowMajor(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){return this[0]=e,this[1]=i,this[2]=c,this[3]=f,this[4]=t,this[5]=a,this[6]=l,this[7]=p,this[8]=n,this[9]=o,this[10]=u,this[11]=m,this[12]=r,this[13]=s,this[14]=d,this[15]=h,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(jv)}fromObject(e){return this.check()}fromQuaternion(e){return gv(this,e),this.check()}frustum(e){let{left:t,right:n,bottom:r,top:i,near:a=kv,far:o=Av}=e;return o===1/0?Rv(this,t,n,r,i,a):_v(this,t,n,r,i,a,o),this.check()}lookAt(e){let{eye:t,center:n=[0,0,0],up:r=[0,1,0]}=e;return Sv(this,t,n,r),this.check()}ortho(e){let{left:t,right:n,bottom:r,top:i,near:a=kv,far:o=Av}=e;return xv(this,t,n,r,i,a,o),this.check()}orthographic(e){let{fovy:t=Dv,aspect:n=Ov,focalDistance:r=1,near:i=kv,far:a=Av}=e;Lv(t);let o=t/2,s=r*Math.tan(o),c=s*n;return this.ortho({left:-c,right:c,bottom:-s,top:s,near:i,far:a})}perspective(e){let{fovy:t=45*Math.PI/180,aspect:n=1,near:r=.1,far:i=500}=e;return Lv(t),yv(this,t,n,r,i),this.check()}determinant(){return cv(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,t){e||=[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],t||=[-0,-0,-0];let n=this.getScale(t),r=1/n[0],i=1/n[1],a=1/n[2];return e[0]=this[0]*r,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=0,e[4]=this[4]*r,e[5]=this[5]*i,e[6]=this[6]*a,e[7]=0,e[8]=this[8]*r,e[9]=this[9]*i,e[10]=this[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,t){e||=[-0,-0,-0,-0,-0,-0,-0,-0,-0],t||=[-0,-0,-0];let n=this.getScale(t),r=1/n[0],i=1/n[1],a=1/n[2];return e[0]=this[0]*r,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=this[4]*r,e[4]=this[5]*i,e[5]=this[6]*a,e[6]=this[8]*r,e[7]=this[9]*i,e[8]=this[10]*a,e}transpose(){return ov(this,this),this.check()}invert(){return sv(this,this),this.check()}multiplyLeft(e){return lv(this,e,this),this.check()}multiplyRight(e){return lv(this,this,e),this.check()}rotateX(e){return pv(this,this,e),this.check()}rotateY(e){return mv(this,this,e),this.check()}rotateZ(e){return hv(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,t){return fv(this,this,e,t),this.check()}scale(e){return dv(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return uv(this,this,e),this.check()}transform(e,t){return e.length===4?(t=Tv(t||[-0,-0,-0,-0],e,this),x_(t,4),t):this.transformAsPoint(e,t)}transformAsPoint(e,t){let{length:n}=e,r;switch(n){case 2:r=A_(t||[-0,-0],e,this);break;case 3:r=W_(t||[-0,-0,-0],e,this);break;default:throw Error(`Illegal vector`)}return x_(r,e.length),r}transformAsVector(e,t){let n;switch(e.length){case 2:n=M_(t||[-0,-0],e,this);break;case 3:n=N_(t||[-0,-0,-0],e,this);break;default:throw Error(`Illegal vector`)}return x_(n,e.length),n}transformPoint(e,t){return this.transformAsPoint(e,t)}transformVector(e,t){return this.transformAsPoint(e,t)}transformDirection(e,t){return this.transformAsVector(e,t)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,t,n){return this.identity().translate([e,t,n])}},Nv,Pv;function Fv(){return Nv||(Nv=new Mv([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Nv)),Nv}function Iv(){return Pv||(Pv=new Mv,Object.freeze(Pv)),Pv}function Lv(e){if(e>Math.PI*2)throw Error(`expected radians`)}function Rv(e,t,n,r,i,a){let o=2*a/(n-t),s=2*a/(i-r),c=(n+t)/(n-t),l=(i+r)/(i-r),u=-2*a;return e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=c,e[9]=l,e[10]=-1,e[11]=-1,e[12]=0,e[13]=0,e[14]=u,e[15]=0,e}function zv(e,t=[],n=0){let r=Math.fround(e),i=e-r;return t[n]=r,t[n+1]=i,t}function Bv(e){return e-Math.fround(e)}function Vv(e){let t=new Float32Array(32);for(let n=0;n<4;++n)for(let r=0;r<4;++r){let i=n*4+r;zv(e[r*4+n],t,i*2)}return t}function Hv(e,t=!0){return e??t}function Uv(e=[0,0,0],t=!0){return t?e.map(e=>e/255):[...e]}function Wv(e,t=!0){let n=Uv(e.slice(0,3),t),r=Number.isFinite(e[3]),i=r?e[3]:1;return[n[0],n[1],n[2],t&&r?i/255:i]}var Gv={name:`fp32`,vs:`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
|
|
653
|
+
${r} = ${h_(t,n)};
|
|
654
|
+
}`}function m_(e){switch(e){case 1:return`float`;case 2:return`vec2`;case 3:return`vec3`;case 4:return`vec4`;default:throw Error(`invalid channels: ${e}`)}}function h_(e,t){switch(t){case 1:return`vec4(${e}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${e}, 0.0, 1.0)`;case 3:return`vec4(${e}, 1.0)`;case 4:return e;default:throw Error(`invalid channels: ${t}`)}}1/Math.PI*180,1/180*Math.PI,globalThis.mathgl=globalThis.mathgl||{config:{EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1}};var g_=globalThis.mathgl.config;function __(e,{precision:t=g_.precision}={}){return e=S_(e),`${parseFloat(e.toPrecision(t))}`}function v_(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function y_(e,t,n){return w_(e,e=>Math.max(t,Math.min(n,e)))}function b_(e,t,n){return v_(e)?e.map((e,r)=>b_(e,t[r],n)):n*t+(1-n)*e}function x_(e,t,n){let r=g_.EPSILON;n&&(g_.EPSILON=n);try{if(e===t)return!0;if(v_(e)&&v_(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!x_(e[n],t[n]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):typeof e==`number`&&typeof t==`number`?Math.abs(e-t)<=g_.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{g_.EPSILON=r}}function S_(e){return Math.round(e/g_.EPSILON)*g_.EPSILON}function C_(e){return e.clone?e.clone():Array(e.length)}function w_(e,t,n){if(v_(e)){let r=e;n||=C_(r);for(let i=0;i<n.length&&i<r.length;++i){let r=typeof e==`number`?e:e[i];n[i]=t(r,i,n)}return n}return t(e)}var T_=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,t=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=e[n+t];return this.check()}toArray(e=[],t=0){for(let n=0;n<this.ELEMENTS;++n)e[t+n]=this[n];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:v_(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(g_)}formatString(e){let t=``;for(let n=0;n<this.ELEMENTS;++n)t+=(n>0?`, `:``)+__(this[n],e);return`${e.printTypes?this.constructor.name:``}[${t}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(!x_(this[t],e[t]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(this[t]!==e[t])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,t,n){if(n===void 0)return this.lerp(this,e,t);for(let r=0;r<this.ELEMENTS;++r){let i=e[r],a=typeof t==`number`?t:t[r];this[r]=i+n*(a-i)}return this.check()}min(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.min(e[t],this[t]);return this.check()}max(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.max(e[t],this[t]);return this.check()}clamp(e,t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e[n]),t[n]);return this.check()}add(...e){for(let t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]+=t[e];return this.check()}subtract(...e){for(let t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]-=t[e];return this.check()}scale(e){if(typeof e==`number`)for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;else for(let t=0;t<this.ELEMENTS&&t<e.length;++t)this[t]*=e[t];return this.check()}multiplyByScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}check(){if(g_.debug&&!this.validate())throw Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let t=0;t<this.ELEMENTS;++t)e&&=Number.isFinite(this[t]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=e;return this.check()}addScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e),t);return this.check()}get elements(){return this}};function E_(e,t){if(e.length!==t)return!1;for(let t=0;t<e.length;++t)if(!Number.isFinite(e[t]))return!1;return!0}function D_(e){if(!Number.isFinite(e))throw Error(`Invalid number ${JSON.stringify(e)}`);return e}function O_(e,t,n=``){if(g_.debug&&!E_(e,t))throw Error(`math.gl: ${n} some fields set to invalid numbers'`);return e}function k_(e,t){if(!e)throw Error(`math.gl assertion ${t}`)}var A_=class extends T_{get x(){return this[0]}set x(e){this[0]=D_(e)}get y(){return this[1]}set y(e){this[1]=D_(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let t=0;t<this.ELEMENTS;++t)e+=this[t]*this[t];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let t=0;for(let n=0;n<this.ELEMENTS;++n){let r=this[n]-e[n];t+=r*r}return D_(t)}dot(e){let t=0;for(let n=0;n<this.ELEMENTS;++n)t+=this[n]*e[n];return D_(t)}normalize(){let e=this.magnitude();if(e!==0)for(let t=0;t<this.ELEMENTS;++t)this[t]/=e;return this.check()}multiply(...e){for(let t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]*=t[e];return this.check()}divide(...e){for(let t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]/=t[e];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return k_(e>=0&&e<this.ELEMENTS,`index is out of range`),D_(this[e])}setComponent(e,t){return k_(e>=0&&e<this.ELEMENTS,`index is out of range`),this[e]=t,this.check()}addVectors(e,t){return this.copy(e).add(t)}subVectors(e,t){return this.copy(e).subtract(t)}multiplyVectors(e,t){return this.copy(e).multiply(t)}addScaledVector(e,t){return this.add(new this.constructor(e).multiplyScalar(t))}},j_=typeof Float32Array<`u`?Float32Array:Array;Math.PI/180;function M_(){let e=new j_(2);return j_!=Float32Array&&(e[0]=0,e[1]=0),e}function N_(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e}function P_(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e}function F_(e,t){return e[0]=-t[0],e[1]=-t[1],e}function I_(e,t,n,r){let i=t[0],a=t[1];return e[0]=i+r*(n[0]-i),e[1]=a+r*(n[1]-a),e}function L_(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}var R_=P_;(function(){let e=M_();return function(t,n,r,i,a,o){let s,c;for(n||=2,r||=0,c=i?Math.min(i*n+r,t.length):t.length,s=r;s<c;s+=n)e[0]=t[s],e[1]=t[s+1],a(e,e,o),t[s]=e[0],t[s+1]=e[1];return t}})();function z_(e,t,n){let r=t[0],i=t[1],a=n[3]*r+n[7]*i||1;return e[0]=(n[0]*r+n[4]*i)/a,e[1]=(n[1]*r+n[5]*i)/a,e}function B_(e,t,n){let r=t[0],i=t[1],a=t[2],o=n[3]*r+n[7]*i+n[11]*a||1;return e[0]=(n[0]*r+n[4]*i+n[8]*a)/o,e[1]=(n[1]*r+n[5]*i+n[9]*a)/o,e[2]=(n[2]*r+n[6]*i+n[10]*a)/o,e}function V_(e,t,n){let r=t[0],i=t[1];return e[0]=n[0]*r+n[2]*i,e[1]=n[1]*r+n[3]*i,e[2]=t[2],e}function H_(){let e=new j_(3);return j_!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function U_(e){let t=e[0],n=e[1],r=e[2];return Math.sqrt(t*t+n*n+r*r)}function W_(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e}function G_(e,t){let n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2];return Math.sqrt(n*n+r*r+i*i)}function K_(e){let t=e[0],n=e[1],r=e[2];return t*t+n*n+r*r}function q_(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function J_(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Y_(e,t,n){let 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}function X_(e,t,n,r){let i=t[0],a=t[1],o=t[2];return e[0]=i+r*(n[0]-i),e[1]=a+r*(n[1]-a),e[2]=o+r*(n[2]-o),e}function Z_(e,t,n){let r=t[0],i=t[1],a=t[2],o=n[3]*r+n[7]*i+n[11]*a+n[15];return o||=1,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}function Q_(e,t,n){let 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}function $_(e,t,n){let 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,p=i*f-a*d,m=a*u-r*f,h=r*d-i*u,g=o*2;return u*=g,d*=g,f*=g,p*=2,m*=2,h*=2,e[0]=s+u+p,e[1]=c+d+m,e[2]=l+f+h,e}function ev(e,t,n,r){let 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}function tv(e,t,n,r){let 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}function nv(e,t,n,r){let 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}function rv(e,t){let n=e[0],r=e[1],i=e[2],a=t[0],o=t[1],s=t[2],c=Math.sqrt((n*n+r*r+i*i)*(a*a+o*o+s*s)),l=c&&J_(e,t)/c;return Math.acos(Math.min(Math.max(l,-1),1))}var iv=W_,av=G_,ov=U_,sv=K_;(function(){let e=H_();return function(t,n,r,i,a,o){let s,c;for(n||=3,r||=0,c=i?Math.min(i*n+r,t.length):t.length,s=r;s<c;s+=n)e[0]=t[s],e[1]=t[s+1],e[2]=t[s+2],a(e,e,o),t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2];return t}})();var cv=[0,0,0],lv,uv=class e extends A_{static get ZERO(){return lv||(lv=new e(0,0,0),Object.freeze(lv)),lv}constructor(e=0,t=0,n=0){super(-0,-0,-0),arguments.length===1&&v_(e)?this.copy(e):(g_.debug&&(D_(e),D_(t),D_(n)),this[0]=e,this[1]=t,this[2]=n)}set(e,t,n){return this[0]=e,this[1]=t,this[2]=n,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return g_.debug&&(D_(e.x),D_(e.y),D_(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=D_(e)}angle(e){return rv(this,e)}cross(e){return Y_(this,this,e),this.check()}rotateX({radians:e,origin:t=cv}){return ev(this,this,t,e),this.check()}rotateY({radians:e,origin:t=cv}){return tv(this,this,t,e),this.check()}rotateZ({radians:e,origin:t=cv}){return nv(this,this,t,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return Z_(this,this,e),this.check()}transformAsVector(e){return B_(this,this,e),this.check()}transformByMatrix3(e){return Q_(this,this,e),this.check()}transformByMatrix2(e){return V_(this,this,e),this.check()}transformByQuaternion(e){return $_(this,this,e),this.check()}},dv=class extends T_{toString(){let e=`[`;if(g_.printRowMajor){e+=`row-major:`;for(let t=0;t<this.RANK;++t)for(let n=0;n<this.RANK;++n)e+=` ${this[n*this.RANK+t]}`}else{e+=`column-major:`;for(let t=0;t<this.ELEMENTS;++t)e+=` ${this[t]}`}return e+=`]`,e}getElementIndex(e,t){return t*this.RANK+e}getElement(e,t){return this[t*this.RANK+e]}setElement(e,t,n){return this[t*this.RANK+e]=D_(n),this}getColumn(e,t=Array(this.RANK).fill(-0)){let n=e*this.RANK;for(let e=0;e<this.RANK;++e)t[e]=this[n+e];return t}setColumn(e,t){let n=e*this.RANK;for(let e=0;e<this.RANK;++e)this[n+e]=t[e];return this}};function fv(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 pv(e,t){if(e===t){let n=t[1],r=t[2],i=t[3],a=t[6],o=t[7],s=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=a,e[11]=t[14],e[12]=i,e[13]=o,e[14]=s}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function mv(e,t){let 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,ee=d*g-f*h,te=d*_-p*h,ne=f*_-p*g,D=v*ne-y*te+b*ee+x*E-S*T+C*w;return D?(D=1/D,e[0]=(s*ne-c*te+l*ee)*D,e[1]=(i*te-r*ne-a*ee)*D,e[2]=(h*C-g*S+_*x)*D,e[3]=(f*S-d*C-p*x)*D,e[4]=(c*E-o*ne-l*T)*D,e[5]=(n*ne-i*E+a*T)*D,e[6]=(g*b-m*C-_*y)*D,e[7]=(u*C-f*b+p*y)*D,e[8]=(o*te-s*E+l*w)*D,e[9]=(r*E-n*te-a*w)*D,e[10]=(m*S-h*b+_*v)*D,e[11]=(d*b-u*S-p*v)*D,e[12]=(s*T-o*ee-c*w)*D,e[13]=(n*ee-r*T+i*w)*D,e[14]=(h*y-m*x-g*v)*D,e[15]=(u*x-d*y+f*v)*D,e):null}function hv(e){let t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=t*o-n*a,v=t*s-r*a,y=n*s-r*o,b=l*m-u*p,x=l*h-d*p,S=u*h-d*m,C=t*S-n*x+r*b,w=a*S-o*x+s*b,T=l*y-u*v+d*_,E=p*y-m*v+h*_;return c*C-i*w+g*T-f*E}function gv(e,t,n){let 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,y=n[4],b=n[5],x=n[6],S=n[7],e[4]=y*r+b*s+x*d+S*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,y=n[8],b=n[9],x=n[10],S=n[11],e[8]=y*r+b*s+x*d+S*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,y=n[12],b=n[13],x=n[14],S=n[15],e[12]=y*r+b*s+x*d+S*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}function _v(e,t,n){let r=n[0],i=n[1],a=n[2],o,s,c,l,u,d,f,p,m,h,g,_;return t===e?(e[12]=t[0]*r+t[4]*i+t[8]*a+t[12],e[13]=t[1]*r+t[5]*i+t[9]*a+t[13],e[14]=t[2]*r+t[6]*i+t[10]*a+t[14],e[15]=t[3]*r+t[7]*i+t[11]*a+t[15]):(o=t[0],s=t[1],c=t[2],l=t[3],u=t[4],d=t[5],f=t[6],p=t[7],m=t[8],h=t[9],g=t[10],_=t[11],e[0]=o,e[1]=s,e[2]=c,e[3]=l,e[4]=u,e[5]=d,e[6]=f,e[7]=p,e[8]=m,e[9]=h,e[10]=g,e[11]=_,e[12]=o*r+u*i+m*a+t[12],e[13]=s*r+d*i+h*a+t[13],e[14]=c*r+f*i+g*a+t[14],e[15]=l*r+p*i+_*a+t[15]),e}function vv(e,t,n){let 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}function yv(e,t,n,r){let i=r[0],a=r[1],o=r[2],s=Math.sqrt(i*i+a*a+o*o),c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,ee,te,ne,D,O;return s<1e-6?null:(s=1/s,i*=s,a*=s,o*=s,l=Math.sin(n),c=Math.cos(n),u=1-c,d=t[0],f=t[1],p=t[2],m=t[3],h=t[4],g=t[5],_=t[6],v=t[7],y=t[8],b=t[9],x=t[10],S=t[11],C=i*i*u+c,w=a*i*u+o*l,T=o*i*u-a*l,E=i*a*u-o*l,ee=a*a*u+c,te=o*a*u+i*l,ne=i*o*u+a*l,D=a*o*u-i*l,O=o*o*u+c,e[0]=d*C+h*w+y*T,e[1]=f*C+g*w+b*T,e[2]=p*C+_*w+x*T,e[3]=m*C+v*w+S*T,e[4]=d*E+h*ee+y*te,e[5]=f*E+g*ee+b*te,e[6]=p*E+_*ee+x*te,e[7]=m*E+v*ee+S*te,e[8]=d*ne+h*D+y*O,e[9]=f*ne+g*D+b*O,e[10]=p*ne+_*D+x*O,e[11]=m*ne+v*D+S*O,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function bv(e,t,n){let 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}function xv(e,t,n){let 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}function Sv(e,t,n){let 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}function Cv(e,t){let n=t[0],r=t[1],i=t[2],a=t[3],o=n+n,s=r+r,c=i+i,l=n*o,u=r*o,d=r*s,f=i*o,p=i*s,m=i*c,h=a*o,g=a*s,_=a*c;return e[0]=1-d-m,e[1]=u+_,e[2]=f-g,e[3]=0,e[4]=u-_,e[5]=1-l-m,e[6]=p+h,e[7]=0,e[8]=f+g,e[9]=p-h,e[10]=1-l-d,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function wv(e,t,n,r,i,a,o){let s=1/(n-t),c=1/(i-r),l=1/(a-o);return e[0]=a*2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a*2*c,e[6]=0,e[7]=0,e[8]=(n+t)*s,e[9]=(i+r)*c,e[10]=(o+a)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*a*2*l,e[15]=0,e}function Tv(e,t,n,r,i){let 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){let t=1/(r-i);e[10]=(i+r)*t,e[14]=2*i*r*t}else e[10]=-1,e[14]=-2*r;return e}var Ev=Tv;function Dv(e,t,n,r,i,a,o){let 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}var Ov=Dv;function kv(e,t,n,r){let i,a,o,s,c,l,u,d,f,p,m=t[0],h=t[1],g=t[2],_=r[0],v=r[1],y=r[2],b=n[0],x=n[1],S=n[2];return Math.abs(m-b)<1e-6&&Math.abs(h-x)<1e-6&&Math.abs(g-S)<1e-6?fv(e):(d=m-b,f=h-x,p=g-S,i=1/Math.sqrt(d*d+f*f+p*p),d*=i,f*=i,p*=i,a=v*p-y*f,o=y*d-_*p,s=_*f-v*d,i=Math.sqrt(a*a+o*o+s*s),i?(i=1/i,a*=i,o*=i,s*=i):(a=0,o=0,s=0),c=f*s-p*o,l=p*a-d*s,u=d*o-f*a,i=Math.sqrt(c*c+l*l+u*u),i?(i=1/i,c*=i,l*=i,u*=i):(c=0,l=0,u=0),e[0]=a,e[1]=c,e[2]=d,e[3]=0,e[4]=o,e[5]=l,e[6]=f,e[7]=0,e[8]=s,e[9]=u,e[10]=p,e[11]=0,e[12]=-(a*m+o*h+s*g),e[13]=-(c*m+l*h+u*g),e[14]=-(d*m+f*h+p*g),e[15]=1,e)}function Av(){let e=new j_(4);return j_!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function jv(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}function Mv(e,t,n){let 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(){let e=Av();return function(t,n,r,i,a,o){let s,c;for(n||=4,r||=0,c=i?Math.min(i*n+r,t.length):t.length,s=r;s<c;s+=n)e[0]=t[s],e[1]=t[s+1],e[2]=t[s+2],e[3]=t[s+3],a(e,e,o),t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2],t[s+3]=e[3];return t}})();var Nv;(function(e){e[e.COL0ROW0=0]=`COL0ROW0`,e[e.COL0ROW1=1]=`COL0ROW1`,e[e.COL0ROW2=2]=`COL0ROW2`,e[e.COL0ROW3=3]=`COL0ROW3`,e[e.COL1ROW0=4]=`COL1ROW0`,e[e.COL1ROW1=5]=`COL1ROW1`,e[e.COL1ROW2=6]=`COL1ROW2`,e[e.COL1ROW3=7]=`COL1ROW3`,e[e.COL2ROW0=8]=`COL2ROW0`,e[e.COL2ROW1=9]=`COL2ROW1`,e[e.COL2ROW2=10]=`COL2ROW2`,e[e.COL2ROW3=11]=`COL2ROW3`,e[e.COL3ROW0=12]=`COL3ROW0`,e[e.COL3ROW1=13]=`COL3ROW1`,e[e.COL3ROW2=14]=`COL3ROW2`,e[e.COL3ROW3=15]=`COL3ROW3`})(Nv||={});var Pv=45*Math.PI/180,Fv=1,Iv=.1,Lv=500,Rv=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),zv=class extends dv{static get IDENTITY(){return Uv()}static get ZERO(){return Hv()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Nv}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){return this[0]=e,this[1]=t,this[2]=n,this[3]=r,this[4]=i,this[5]=a,this[6]=o,this[7]=s,this[8]=c,this[9]=l,this[10]=u,this[11]=d,this[12]=f,this[13]=p,this[14]=m,this[15]=h,this.check()}setRowMajor(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){return this[0]=e,this[1]=i,this[2]=c,this[3]=f,this[4]=t,this[5]=a,this[6]=l,this[7]=p,this[8]=n,this[9]=o,this[10]=u,this[11]=m,this[12]=r,this[13]=s,this[14]=d,this[15]=h,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(Rv)}fromObject(e){return this.check()}fromQuaternion(e){return Cv(this,e),this.check()}frustum(e){let{left:t,right:n,bottom:r,top:i,near:a=Iv,far:o=Lv}=e;return o===1/0?Gv(this,t,n,r,i,a):wv(this,t,n,r,i,a,o),this.check()}lookAt(e){let{eye:t,center:n=[0,0,0],up:r=[0,1,0]}=e;return kv(this,t,n,r),this.check()}ortho(e){let{left:t,right:n,bottom:r,top:i,near:a=Iv,far:o=Lv}=e;return Ov(this,t,n,r,i,a,o),this.check()}orthographic(e){let{fovy:t=Pv,aspect:n=Fv,focalDistance:r=1,near:i=Iv,far:a=Lv}=e;Wv(t);let o=t/2,s=r*Math.tan(o),c=s*n;return this.ortho({left:-c,right:c,bottom:-s,top:s,near:i,far:a})}perspective(e){let{fovy:t=45*Math.PI/180,aspect:n=1,near:r=.1,far:i=500}=e;return Wv(t),Ev(this,t,n,r,i),this.check()}determinant(){return hv(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,t){e||=[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],t||=[-0,-0,-0];let n=this.getScale(t),r=1/n[0],i=1/n[1],a=1/n[2];return e[0]=this[0]*r,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=0,e[4]=this[4]*r,e[5]=this[5]*i,e[6]=this[6]*a,e[7]=0,e[8]=this[8]*r,e[9]=this[9]*i,e[10]=this[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,t){e||=[-0,-0,-0,-0,-0,-0,-0,-0,-0],t||=[-0,-0,-0];let n=this.getScale(t),r=1/n[0],i=1/n[1],a=1/n[2];return e[0]=this[0]*r,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=this[4]*r,e[4]=this[5]*i,e[5]=this[6]*a,e[6]=this[8]*r,e[7]=this[9]*i,e[8]=this[10]*a,e}transpose(){return pv(this,this),this.check()}invert(){return mv(this,this),this.check()}multiplyLeft(e){return gv(this,e,this),this.check()}multiplyRight(e){return gv(this,this,e),this.check()}rotateX(e){return bv(this,this,e),this.check()}rotateY(e){return xv(this,this,e),this.check()}rotateZ(e){return Sv(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,t){return yv(this,this,e,t),this.check()}scale(e){return vv(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return _v(this,this,e),this.check()}transform(e,t){return e.length===4?(t=Mv(t||[-0,-0,-0,-0],e,this),O_(t,4),t):this.transformAsPoint(e,t)}transformAsPoint(e,t){let{length:n}=e,r;switch(n){case 2:r=L_(t||[-0,-0],e,this);break;case 3:r=Z_(t||[-0,-0,-0],e,this);break;default:throw Error(`Illegal vector`)}return O_(r,e.length),r}transformAsVector(e,t){let n;switch(e.length){case 2:n=z_(t||[-0,-0],e,this);break;case 3:n=B_(t||[-0,-0,-0],e,this);break;default:throw Error(`Illegal vector`)}return O_(n,e.length),n}transformPoint(e,t){return this.transformAsPoint(e,t)}transformVector(e,t){return this.transformAsPoint(e,t)}transformDirection(e,t){return this.transformAsVector(e,t)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,t,n){return this.identity().translate([e,t,n])}},Bv,Vv;function Hv(){return Bv||(Bv=new zv([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Bv)),Bv}function Uv(){return Vv||(Vv=new zv,Object.freeze(Vv)),Vv}function Wv(e){if(e>Math.PI*2)throw Error(`expected radians`)}function Gv(e,t,n,r,i,a){let o=2*a/(n-t),s=2*a/(i-r),c=(n+t)/(n-t),l=(i+r)/(i-r),u=-2*a;return e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=c,e[9]=l,e[10]=-1,e[11]=-1,e[12]=0,e[13]=0,e[14]=u,e[15]=0,e}function Kv(e,t=[],n=0){let r=Math.fround(e),i=e-r;return t[n]=r,t[n+1]=i,t}function qv(e){return e-Math.fround(e)}function Jv(e){let t=new Float32Array(32);for(let n=0;n<4;++n)for(let r=0;r<4;++r){let i=n*4+r;Kv(e[r*4+n],t,i*2)}return t}function Yv(e,t=!0){return e??t}function Xv(e=[0,0,0],t=!0){return t?e.map(e=>e/255):[...e]}function Zv(e,t=!0){let n=Xv(e.slice(0,3),t),r=Number.isFinite(e[3]),i=r?e[3]:1;return[n[0],n[1],n[2],t&&r?i/255:i]}var Qv={name:`fp32`,vs:`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
|
|
655
655
|
|
|
656
656
|
// All these functions are for substituting tan() function from Intel GPU only
|
|
657
657
|
const float TWO_PI = 6.2831854820251465;
|
|
@@ -801,7 +801,7 @@ float tan_fp32(float a) {
|
|
|
801
801
|
return tan(a);
|
|
802
802
|
#endif
|
|
803
803
|
}
|
|
804
|
-
`}
|
|
804
|
+
`},$v=`
|
|
805
805
|
layout(std140) uniform fp64arithmeticUniforms {
|
|
806
806
|
uniform float ONE;
|
|
807
807
|
uniform float SPLIT;
|
|
@@ -1000,7 +1000,7 @@ vec2 sqrt_fp64(vec2 a) {
|
|
|
1000
1000
|
return sum_fp64(vec2(yn, 0.0), prod);
|
|
1001
1001
|
#endif
|
|
1002
1002
|
}
|
|
1003
|
-
`,
|
|
1003
|
+
`,ey={name:`fp64arithmetic`,source:`struct Fp64ArithmeticUniforms {
|
|
1004
1004
|
ONE: f32,
|
|
1005
1005
|
SPLIT: f32,
|
|
1006
1006
|
};
|
|
@@ -1206,7 +1206,7 @@ fn sqrt_fp64(a: vec2f) -> vec2f {
|
|
|
1206
1206
|
return sum_fp64(vec2f(yn, 0.0), prod);
|
|
1207
1207
|
#endif
|
|
1208
1208
|
}
|
|
1209
|
-
`,fs
|
|
1209
|
+
`,fs:$v,vs:$v,defaultUniforms:{ONE:1,SPLIT:4097},uniformTypes:{ONE:`f32`,SPLIT:`f32`},fp64ify:Kv,fp64LowPart:qv,fp64ifyMatrix4:Jv},ty={props:{},uniforms:{},name:`picking`,uniformTypes:{isActive:`f32`,isAttribute:`f32`,isHighlightActive:`f32`,useByteColors:`f32`,highlightedObjectColor:`vec3<f32>`,highlightColor:`vec4<f32>`},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useByteColors:!0,highlightedObjectColor:[0,0,0],highlightColor:[0,1,1,1]},vs:`layout(std140) uniform pickingUniforms {
|
|
1210
1210
|
float isActive;
|
|
1211
1211
|
float isAttribute;
|
|
1212
1212
|
float isHighlightActive;
|
|
@@ -1333,33 +1333,33 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
1333
1333
|
vec4 highlightColor = picking_filterHighlightColor(color);
|
|
1334
1334
|
return picking_filterPickingColor(highlightColor);
|
|
1335
1335
|
}
|
|
1336
|
-
`,getUniforms:Yv};function Yv(e={},t){let n={},r=Hv(e.useByteColors,!0);return e.highlightedObjectColor===void 0||(e.highlightedObjectColor===null?n.isHighlightActive=!1:(n.isHighlightActive=!0,n.highlightedObjectColor=e.highlightedObjectColor.slice(0,3))),e.highlightColor&&(n.highlightColor=Wv(e.highlightColor,r)),e.isActive!==void 0&&(n.isActive=!!e.isActive,n.isAttribute=!!e.isAttribute),e.useByteColors!==void 0&&(n.useByteColors=!!e.useByteColors),n}var Xv=`GPU Time and Memory`,Zv=[`Adapter`,`GPU`,`GPU Type`,`GPU Backend`,`Frame Rate`,`CPU Time`,`GPU Time`,`GPU Memory`,`Buffer Memory`,`Texture Memory`,`Referenced Buffer Memory`,`Referenced Texture Memory`,`Swap Chain Texture`],Qv=new WeakMap,$v=new WeakMap,ey=new class{stats=new Map;getStats(e){return this.get(e)}get(e){this.stats.has(e)||this.stats.set(e,new Of({id:e}));let t=this.stats.get(e);return e===Xv&&ty(t,Zv),t}};function ty(e,t){let n=e.stats,r=!1;for(let i of t)n[i]||(e.get(i),r=!0);let i=Object.keys(n).length,a=Qv.get(e);if(!r&&a?.orderedStatNames===t&&a.statCount===i)return;let o={},s=$v.get(t);s||(s=new Set(t),$v.set(t,s));for(let e of t)n[e]&&(o[e]=n[e]);for(let[e,t]of Object.entries(n))s.has(e)||(o[e]=t);for(let e of Object.keys(n))delete n[e];Object.assign(n,o),Qv.set(e,{orderedStatNames:t,statCount:i})}var Z=new Td({id:`luma.gl`}),ny={};function ry(e=`id`){return ny[e]=ny[e]||1,`${e}-${ny[e]++}`}var iy=`cpu-hotspot-profiler`,ay=`GPU Resource Counts`,oy=`Resource Counts`,sy=`GPU Time and Memory`,cy=[`Resources`,`Buffers`,`Textures`,`Samplers`,`TextureViews`,`Framebuffers`,`QuerySets`,`Shaders`,`RenderPipelines`,`ComputePipelines`,`PipelineLayouts`,`VertexArrays`,`RenderPasss`,`ComputePasss`,`CommandEncoders`,`CommandBuffers`],ly=[`Resources`,`Buffers`,`Textures`,`Samplers`,`TextureViews`,`Framebuffers`,`QuerySets`,`Shaders`,`RenderPipelines`,`SharedRenderPipelines`,`ComputePipelines`,`PipelineLayouts`,`VertexArrays`,`RenderPasss`,`ComputePasss`,`CommandEncoders`,`CommandBuffers`],uy=cy.flatMap(e=>[`${e} Created`,`${e} Active`]),dy=ly.flatMap(e=>[`${e} Created`,`${e} Active`]),fy=new WeakMap,py=new WeakMap,Q=class{static defaultProps={id:`undefined`,handle:void 0,userData:void 0};toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}id;props;userData={};_device;destroyed=!1;allocatedBytes=0;allocatedBytesName=null;_attachedResources=new Set;constructor(e,t,n){if(!e)throw Error(`no device`);this._device=e,this.props=my(t,n);let r=this.props.id===`undefined`?ry(this[Symbol.toStringTag]):this.props.id;this.props.id=r,this.id=r,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyed||this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(let e of this._attachedResources)e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyed||=(this.destroyAttachedResources(),this.removeStats(),!0)}removeStats(){let e=_y(this._device),t=e?vy():0,n=[this._device.statsManager.getStats(ay),this._device.statsManager.getStats(oy)],r=gy(this._device);for(let e of n)hy(e,r);let i=this.getStatsName();for(let e of n)e.get(`Resources Active`).decrementCount(),e.get(`${i}s Active`).decrementCount();e&&(e.statsBookkeepingCalls=(e.statsBookkeepingCalls||0)+1,e.statsBookkeepingTimeMs=(e.statsBookkeepingTimeMs||0)+(vy()-t))}trackAllocatedMemory(e,t=this.getStatsName()){let n=_y(this._device),r=n?vy():0,i=this._device.statsManager.getStats(sy);this.allocatedBytes>0&&this.allocatedBytesName&&(i.get(`GPU Memory`).subtractCount(this.allocatedBytes),i.get(`${this.allocatedBytesName} Memory`).subtractCount(this.allocatedBytes)),i.get(`GPU Memory`).addCount(e),i.get(`${t} Memory`).addCount(e),n&&(n.statsBookkeepingCalls=(n.statsBookkeepingCalls||0)+1,n.statsBookkeepingTimeMs=(n.statsBookkeepingTimeMs||0)+(vy()-r)),this.allocatedBytes=e,this.allocatedBytesName=t}trackReferencedMemory(e,t=this.getStatsName()){this.trackAllocatedMemory(e,`Referenced ${t}`)}trackDeallocatedMemory(e=this.getStatsName()){if(this.allocatedBytes===0){this.allocatedBytesName=null;return}let t=_y(this._device),n=t?vy():0,r=this._device.statsManager.getStats(sy);r.get(`GPU Memory`).subtractCount(this.allocatedBytes),r.get(`${this.allocatedBytesName||e} Memory`).subtractCount(this.allocatedBytes),t&&(t.statsBookkeepingCalls=(t.statsBookkeepingCalls||0)+1,t.statsBookkeepingTimeMs=(t.statsBookkeepingTimeMs||0)+(vy()-n)),this.allocatedBytes=0,this.allocatedBytesName=null}trackDeallocatedReferencedMemory(e=this.getStatsName()){this.trackDeallocatedMemory(`Referenced ${e}`)}addStats(){let e=this.getStatsName(),t=_y(this._device),n=t?vy():0,r=[this._device.statsManager.getStats(ay),this._device.statsManager.getStats(oy)],i=gy(this._device);for(let e of r)hy(e,i);for(let t of r)t.get(`Resources Created`).incrementCount(),t.get(`Resources Active`).incrementCount(),t.get(`${e}s Created`).incrementCount(),t.get(`${e}s Active`).incrementCount();t&&(t.statsBookkeepingCalls=(t.statsBookkeepingCalls||0)+1,t.statsBookkeepingTimeMs=(t.statsBookkeepingTimeMs||0)+(vy()-n)),yy(this._device,e)}getStatsName(){return by(this)}};function my(e,t){let n={...t};for(let t in e)e[t]!==void 0&&(n[t]=e[t]);return n}function hy(e,t){let n=e.stats,r=!1;for(let i of t)n[i]||(e.get(i),r=!0);let i=Object.keys(n).length,a=fy.get(e);if(!r&&a?.orderedStatNames===t&&a.statCount===i)return;let o={},s=py.get(t);s||(s=new Set(t),py.set(t,s));for(let e of t)n[e]&&(o[e]=n[e]);for(let[e,t]of Object.entries(n))s.has(e)||(o[e]=t);for(let e of Object.keys(n))delete n[e];Object.assign(n,o),fy.set(e,{orderedStatNames:t,statCount:i})}function gy(e){return e.type===`webgl`?dy:uy}function _y(e){let t=e.userData[iy];return t?.enabled?t:null}function vy(){return globalThis.performance?.now?.()??Date.now()}function yy(e,t){let n=_y(e);if(!(!n||!n.activeDefaultFramebufferAcquireDepth))switch(n.transientCanvasResourceCreates=(n.transientCanvasResourceCreates||0)+1,t){case`Texture`:n.transientCanvasTextureCreates=(n.transientCanvasTextureCreates||0)+1;break;case`TextureView`:n.transientCanvasTextureViewCreates=(n.transientCanvasTextureViewCreates||0)+1;break;case`Sampler`:n.transientCanvasSamplerCreates=(n.transientCanvasSamplerCreates||0)+1;break;case`Framebuffer`:n.transientCanvasFramebufferCreates=(n.transientCanvasFramebufferCreates||0)+1;break;default:break}}function by(e){let t=Object.getPrototypeOf(e);for(;t;){let n=Object.getPrototypeOf(t);if(!n||n===Q.prototype)return xy(t)||e[Symbol.toStringTag]||e.constructor.name;t=n}return e[Symbol.toStringTag]||e.constructor.name}function xy(e){let t=Object.getOwnPropertyDescriptor(e,Symbol.toStringTag);return typeof t?.get==`function`?t.get.call(e):typeof t?.value==`string`?t.value:null}var Sy=class e extends Q{static INDEX=16;static VERTEX=32;static UNIFORM=64;static STORAGE=128;static INDIRECT=256;static QUERY_RESOLVE=512;static MAP_READ=1;static MAP_WRITE=2;static COPY_SRC=4;static COPY_DST=8;get[Symbol.toStringTag](){return`Buffer`}usage;indexType;updateTimestamp;constructor(t,n){let r={...n};(n.usage||0)&e.INDEX&&!n.indexType&&(n.data instanceof Uint32Array?r.indexType=`uint32`:n.data instanceof Uint16Array?r.indexType=`uint16`:n.data instanceof Uint8Array&&(r.indexType=`uint8`)),delete r.data,super(t,r,e.defaultProps),this.usage=r.usage||0,this.indexType=r.indexType,this.updateTimestamp=t.incrementTimestamp()}clone(e){return this.device.createBuffer({...this.props,...e})}static DEBUG_DATA_MAX_LENGTH=32;debugData=new ArrayBuffer(0);_setDebugData(t,n,r){let i=null,a;ArrayBuffer.isView(t)?(i=t,a=t.buffer):a=t;let o=Math.min(t?t.byteLength:r,e.DEBUG_DATA_MAX_LENGTH);if(a===null)this.debugData=new ArrayBuffer(o);else{let e=Math.min(i?.byteOffset||0,a.byteLength),t=Math.max(0,a.byteLength-e),n=Math.min(o,t);this.debugData=new Uint8Array(a,e,n).slice().buffer}}static defaultProps={...Q.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:`uint16`,onMapped:void 0}},Cy=new class{getDataTypeInfo(e){let[t,n,r]=wy[e],i=e.includes(`norm`);return{signedType:t,primitiveType:n,byteLength:r,normalized:i,integer:!i&&!e.startsWith(`float`),signed:e.startsWith(`s`)}}getNormalizedDataType(e){let t=e;switch(t){case`uint8`:return`unorm8`;case`sint8`:return`snorm8`;case`uint16`:return`unorm16`;case`sint16`:return`snorm16`;default:return t}}alignTo(e,t){switch(t){case 1:return e;case 2:return e+e%2;default:return e+(4-e%4)%4}}getDataType(e){let t=ArrayBuffer.isView(e)?e.constructor:e;if(t===Uint8ClampedArray)return`uint8`;let n=Object.values(wy).find(e=>t===e[4]);if(!n)throw Error(t.name);return n[0]}getTypedArrayConstructor(e){let[,,,,t]=wy[e];return t}},wy={uint8:[`uint8`,`u32`,1,!1,Uint8Array],sint8:[`sint8`,`i32`,1,!1,Int8Array],unorm8:[`uint8`,`f32`,1,!0,Uint8Array],snorm8:[`sint8`,`f32`,1,!0,Int8Array],uint16:[`uint16`,`u32`,2,!1,Uint16Array],sint16:[`sint16`,`i32`,2,!1,Int16Array],unorm16:[`uint16`,`u32`,2,!0,Uint16Array],snorm16:[`sint16`,`i32`,2,!0,Int16Array],float16:[`float16`,`f16`,2,!1,Uint16Array],float32:[`float32`,`f32`,4,!1,Float32Array],uint32:[`uint32`,`u32`,4,!1,Uint32Array],sint32:[`sint32`,`i32`,4,!1,Int32Array]},Ty=new class{getVertexFormatInfo(e){let t;e.endsWith(`-webgl`)&&(e.replace(`-webgl`,``),t=!0);let[n,r]=e.split(`x`),i=n,a=r?parseInt(r):1,o=Cy.getDataTypeInfo(i),s={type:i,components:a,byteLength:o.byteLength*a,integer:o.integer,signed:o.signed,normalized:o.normalized};return t&&(s.webglOnly=!0),s}makeVertexFormat(e,t,n){let r=n?Cy.getNormalizedDataType(e):e;switch(r){case`unorm8`:return t===1?`unorm8`:t===3?`unorm8x3-webgl`:`${r}x${t}`;case`snorm8`:return t===1?`snorm8`:t===3?`snorm8x3-webgl`:`${r}x${t}`;case`uint8`:case`sint8`:if(t===1||t===3)throw Error(`size: ${t}`);return`${r}x${t}`;case`uint16`:return t===1?`uint16`:t===3?`uint16x3-webgl`:`${r}x${t}`;case`sint16`:return t===1?`sint16`:t===3?`sint16x3-webgl`:`${r}x${t}`;case`unorm16`:return t===1?`unorm16`:t===3?`unorm16x3-webgl`:`${r}x${t}`;case`snorm16`:return t===1?`snorm16`:t===3?`snorm16x3-webgl`:`${r}x${t}`;case`float16`:if(t===1||t===3)throw Error(`size: ${t}`);return`${r}x${t}`;default:return t===1?r:`${r}x${t}`}}getVertexFormatFromAttribute(e,t,n){if(!t||t>4)throw Error(`size ${t}`);let r=t,i=Cy.getDataType(e);return this.makeVertexFormat(i,r,n)}getCompatibleVertexFormat(e){let t;switch(e.primitiveType){case`f32`:t=`float32`;break;case`i32`:t=`sint32`;break;case`u32`:t=`uint32`;break;case`f16`:return e.components<=2?`float16x2`:`float16x4`}return e.components===1?t:`${t}x${e.components}`}},Ey=`texture-compression-bc`,Dy=`texture-compression-astc`,Oy=`texture-compression-etc2`,ky=`texture-compression-etc1-webgl`,Ay=`texture-compression-pvrtc-webgl`,jy=`texture-compression-atc-webgl`,My=`float32-renderable-webgl`,Ny=`float16-renderable-webgl`,Py=`rgb9e5ufloat-renderable-webgl`,Fy=`snorm8-renderable-webgl`,Iy=`norm16-webgl`,Ly=`norm16-renderable-webgl`,Ry=`snorm16-renderable-webgl`,zy=`float32-filterable`,By=`float16-filterable-webgl`;function Vy(e){let t=Gy[e];if(!t)throw Error(`Unsupported texture format ${e}`);return t}function Hy(){return Gy}var Uy={r8unorm:{},rg8unorm:{},"rgb8unorm-webgl":{},rgba8unorm:{},"rgba8unorm-srgb":{},r8snorm:{render:Fy},rg8snorm:{render:Fy},"rgb8snorm-webgl":{},rgba8snorm:{render:Fy},r8uint:{},rg8uint:{},rgba8uint:{},r8sint:{},rg8sint:{},rgba8sint:{},bgra8unorm:{},"bgra8unorm-srgb":{},r16unorm:{f:Iy,render:Ly},rg16unorm:{f:Iy,render:Ly},"rgb16unorm-webgl":{f:Iy,render:!1},rgba16unorm:{f:Iy,render:Ly},r16snorm:{f:Iy,render:Ry},rg16snorm:{f:Iy,render:Ry},"rgb16snorm-webgl":{f:Iy,render:!1},rgba16snorm:{f:Iy,render:Ry},r16uint:{},rg16uint:{},rgba16uint:{},r16sint:{},rg16sint:{},rgba16sint:{},r16float:{render:Ny,filter:`float16-filterable-webgl`},rg16float:{render:Ny,filter:By},rgba16float:{render:Ny,filter:By},r32uint:{},rg32uint:{},rgba32uint:{},r32sint:{},rg32sint:{},rgba32sint:{},r32float:{render:My,filter:zy},rg32float:{render:!1,filter:zy},"rgb32float-webgl":{render:My,filter:zy},rgba32float:{render:My,filter:zy},"rgba4unorm-webgl":{channels:`rgba`,bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:`rgb`,bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:`rgba`,bitsPerChannel:[5,5,5,1],packed:!0},rgb9e5ufloat:{channels:`rgb`,packed:!0,render:Py},rg11b10ufloat:{channels:`rgb`,bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:My},rgb10a2unorm:{channels:`rgba`,bitsPerChannel:[10,10,10,2],packed:!0,p:1},rgb10a2uint:{channels:`rgba`,bitsPerChannel:[10,10,10,2],packed:!0,p:1},stencil8:{attachment:`stencil`,bitsPerChannel:[8,0,0,0],dataType:`uint8`},depth16unorm:{attachment:`depth`,bitsPerChannel:[16,0,0,0],dataType:`uint16`},depth24plus:{attachment:`depth`,bitsPerChannel:[24,0,0,0],dataType:`uint32`},depth32float:{attachment:`depth`,bitsPerChannel:[32,0,0,0],dataType:`float32`},"depth24plus-stencil8":{attachment:`depth-stencil`,bitsPerChannel:[24,8,0,0],packed:!0},"depth32float-stencil8":{attachment:`depth-stencil`,bitsPerChannel:[32,8,0,0],packed:!0}},Wy={"bc1-rgb-unorm-webgl":{f:Ey},"bc1-rgb-unorm-srgb-webgl":{f:Ey},"bc1-rgba-unorm":{f:Ey},"bc1-rgba-unorm-srgb":{f:Ey},"bc2-rgba-unorm":{f:Ey},"bc2-rgba-unorm-srgb":{f:Ey},"bc3-rgba-unorm":{f:Ey},"bc3-rgba-unorm-srgb":{f:Ey},"bc4-r-unorm":{f:Ey},"bc4-r-snorm":{f:Ey},"bc5-rg-unorm":{f:Ey},"bc5-rg-snorm":{f:Ey},"bc6h-rgb-ufloat":{f:Ey},"bc6h-rgb-float":{f:Ey},"bc7-rgba-unorm":{f:Ey},"bc7-rgba-unorm-srgb":{f:Ey},"etc2-rgb8unorm":{f:Oy},"etc2-rgb8unorm-srgb":{f:Oy},"etc2-rgb8a1unorm":{f:Oy},"etc2-rgb8a1unorm-srgb":{f:Oy},"etc2-rgba8unorm":{f:Oy},"etc2-rgba8unorm-srgb":{f:Oy},"eac-r11unorm":{f:Oy},"eac-r11snorm":{f:Oy},"eac-rg11unorm":{f:Oy},"eac-rg11snorm":{f:Oy},"astc-4x4-unorm":{f:Dy},"astc-4x4-unorm-srgb":{f:Dy},"astc-5x4-unorm":{f:Dy},"astc-5x4-unorm-srgb":{f:Dy},"astc-5x5-unorm":{f:Dy},"astc-5x5-unorm-srgb":{f:Dy},"astc-6x5-unorm":{f:Dy},"astc-6x5-unorm-srgb":{f:Dy},"astc-6x6-unorm":{f:Dy},"astc-6x6-unorm-srgb":{f:Dy},"astc-8x5-unorm":{f:Dy},"astc-8x5-unorm-srgb":{f:Dy},"astc-8x6-unorm":{f:Dy},"astc-8x6-unorm-srgb":{f:Dy},"astc-8x8-unorm":{f:Dy},"astc-8x8-unorm-srgb":{f:Dy},"astc-10x5-unorm":{f:Dy},"astc-10x5-unorm-srgb":{f:Dy},"astc-10x6-unorm":{f:Dy},"astc-10x6-unorm-srgb":{f:Dy},"astc-10x8-unorm":{f:Dy},"astc-10x8-unorm-srgb":{f:Dy},"astc-10x10-unorm":{f:Dy},"astc-10x10-unorm-srgb":{f:Dy},"astc-12x10-unorm":{f:Dy},"astc-12x10-unorm-srgb":{f:Dy},"astc-12x12-unorm":{f:Dy},"astc-12x12-unorm-srgb":{f:Dy},"pvrtc-rgb4unorm-webgl":{f:Ay},"pvrtc-rgba4unorm-webgl":{f:Ay},"pvrtc-rgb2unorm-webgl":{f:Ay},"pvrtc-rgba2unorm-webgl":{f:Ay},"etc1-rbg-unorm-webgl":{f:ky},"atc-rgb-unorm-webgl":{f:jy},"atc-rgba-unorm-webgl":{f:jy},"atc-rgbai-unorm-webgl":{f:jy}},Gy={...Uy,...Wy},Ky=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,qy=[`rgb`,`rgba`,`bgra`],Jy=[`depth`,`stencil`],Yy=[`bc1`,`bc2`,`bc3`,`bc4`,`bc5`,`bc6`,`bc7`,`etc1`,`etc2`,`eac`,`atc`,`astc`,`pvrtc`],Xy=new class{isColor(e){return qy.some(t=>e.startsWith(t))}isDepthStencil(e){return Jy.some(t=>e.startsWith(t))}isCompressed(e){return Yy.some(t=>e.startsWith(t))}getInfo(e){return $y(e)}getCapabilities(e){return Qy(e)}computeMemoryLayout(e){return Zy(e)}};function Zy({format:e,width:t,height:n,depth:r,byteAlignment:i}){let{bytesPerPixel:a,bytesPerBlock:o=a,blockWidth:s=1,blockHeight:c=1,compressed:l=!1}=Xy.getInfo(e),u=l?Math.ceil(t/s):t,d=l?Math.ceil(n/c):n,f=u*o,p=Math.ceil(f/i)*i,m=d,h=p*m*r;return{bytesPerPixel:a,bytesPerRow:p,rowsPerImage:m,depthOrArrayLayers:r,bytesPerImage:p*m,byteLength:h}}function Qy(e){let t=Vy(e),n={format:e,create:t.f??!0,render:t.render??!0,filter:t.filter??!0,blend:t.blend??!0,store:t.store??!0},r=$y(e),i=e.startsWith(`depth`)||e.startsWith(`stencil`),a=r?.signed,o=r?.integer,s=r?.webgl,c=!!r?.compressed;return n.render&&=!i&&!c,n.filter&&=!i&&!a&&!o&&!s,n}function $y(e){let t=eb(e);if(Xy.isCompressed(e)){t.channels=`rgb`,t.components=3,t.bytesPerPixel=1,t.srgb=!1,t.compressed=!0,t.bytesPerBlock=nb(e);let n=tb(e);n&&(t.blockWidth=n.blockWidth,t.blockHeight=n.blockHeight)}let n=t.packed?null:Ky.exec(e);if(n){let[,r,i,a,o,s]=n,c=`${a}${i}`,l=Cy.getDataTypeInfo(c),u=l.byteLength*8,d=r?.length??1,f=[u,d>=2?u:0,d>=3?u:0,d>=4?u:0];t={format:e,attachment:t.attachment,dataType:l.signedType,components:d,channels:r,integer:l.integer,signed:l.signed,normalized:l.normalized,bitsPerChannel:f,bytesPerPixel:l.byteLength*d,packed:t.packed,srgb:t.srgb},s===`-webgl`&&(t.webgl=!0),o===`-srgb`&&(t.srgb=!0)}return e.endsWith(`-webgl`)&&(t.webgl=!0),e.endsWith(`-srgb`)&&(t.srgb=!0),t}function eb(e){let t=Vy(e),n=t.bytesPerPixel||1,r=t.bitsPerChannel||[8,8,8,8];return delete t.bitsPerChannel,delete t.bytesPerPixel,delete t.f,delete t.render,delete t.filter,delete t.blend,delete t.store,{...t,format:e,attachment:t.attachment||`color`,channels:t.channels||`r`,components:t.components||t.channels?.length||1,bytesPerPixel:n,bitsPerChannel:r,dataType:t.dataType||`uint8`,srgb:t.srgb??!1,packed:t.packed??!1,webgl:t.webgl??!1,integer:t.integer??!1,signed:t.signed??!1,normalized:t.normalized??!1,compressed:t.compressed??!1}}function tb(e){let t=/.*-(\d+)x(\d+)-.*/.exec(e);if(t){let[,e,n]=t;return{blockWidth:Number(e),blockHeight:Number(n)}}return e.startsWith(`bc`)||e.startsWith(`etc1`)||e.startsWith(`etc2`)||e.startsWith(`eac`)||e.startsWith(`atc`)||e.startsWith(`pvrtc-rgb4`)||e.startsWith(`pvrtc-rgba4`)?{blockWidth:4,blockHeight:4}:e.startsWith(`pvrtc-rgb2`)||e.startsWith(`pvrtc-rgba2`)?{blockWidth:8,blockHeight:4}:null}function nb(e){return e.startsWith(`bc1`)||e.startsWith(`bc4`)||e.startsWith(`etc1`)||e.startsWith(`etc2-rgb8`)||e.startsWith(`etc2-rgb8a1`)||e.startsWith(`eac-r11`)||e===`atc-rgb-unorm-webgl`?8:e.startsWith(`bc2`)||e.startsWith(`bc3`)||e.startsWith(`bc5`)||e.startsWith(`bc6h`)||e.startsWith(`bc7`)||e.startsWith(`etc2-rgba8`)||e.startsWith(`eac-rg11`)||e.startsWith(`astc`)||e===`atc-rgba-unorm-webgl`||e===`atc-rgbai-unorm-webgl`?16:e.startsWith(`pvrtc`)?8:16}function rb(e){return typeof ImageData<`u`&&e instanceof ImageData||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLVideoElement<`u`&&e instanceof HTMLVideoElement||typeof VideoFrame<`u`&&e instanceof VideoFrame||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas}function ib(e){if(typeof ImageData<`u`&&e instanceof ImageData||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas)return{width:e.width,height:e.height};if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement)return{width:e.naturalWidth,height:e.naturalHeight};if(typeof HTMLVideoElement<`u`&&e instanceof HTMLVideoElement)return{width:e.videoWidth,height:e.videoHeight};if(typeof VideoFrame<`u`&&e instanceof VideoFrame)return{width:e.displayWidth,height:e.displayHeight};throw Error(`Unknown image type`)}var ab=class{};function ob(e,t){return[sb(e),...t.map(sb).filter(e=>e!==void 0)].filter(e=>e!==void 0)}function sb(e){if(e!==void 0){if(e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e;if(e instanceof Error)return e.message;if(Array.isArray(e))return e.map(sb);if(typeof e==`object`){if(cb(e)){let t=String(e);if(t!==`[object Object]`)return t}return lb(e)?ub(e):e.constructor?.name||`Object`}return String(e)}}function cb(e){return`toString`in e&&typeof e.toString==`function`&&e.toString!==Object.prototype.toString}function lb(e){return`message`in e&&`type`in e}function ub(e){let t=typeof e.type==`string`?e.type:`message`,n=typeof e.message==`string`?e.message:``,r=typeof e.lineNum==`number`?e.lineNum:null,i=typeof e.linePos==`number`?e.linePos:null;return`${t}${r!==null&&i!==null?` @ ${r}:${i}`:r===null?``:` @ ${r}`}: ${n}`.trim()}var db=class{features;disabledFeatures;constructor(e=[],t){this.features=new Set(e),this.disabledFeatures=t||{}}*[Symbol.iterator](){yield*this.features}has(e){return!this.disabledFeatures?.[e]&&this.features.has(e)}},fb=class e{static defaultProps={id:null,powerPreference:`high-performance`,failIfMajorPerformanceCaveat:!1,createCanvasContext:void 0,webgl:{},onError:(e,t)=>{},onResize:(e,t)=>{let[n,r]=e.getDevicePixelSize();Z.log(1,`${e} resized => ${n}x${r}px`)()},onPositionChange:(e,t)=>{let[n,r]=e.getPosition();Z.log(1,`${e} repositioned => ${n},${r}`)()},onVisibilityChange:e=>Z.log(1,`${e} Visibility changed ${e.isVisible}`)(),onDevicePixelRatioChange:(e,t)=>Z.log(1,`${e} DPR changed ${t.oldRatio} => ${e.devicePixelRatio}`)(),debug:mb(),debugGPUTime:!1,debugShaders:Z.get(`debug-shaders`)||void 0,debugFramebuffers:!!Z.get(`debug-framebuffers`),debugFactories:!!Z.get(`debug-factories`),debugWebGL:!!Z.get(`debug-webgl`),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_requestMaxLimits:!0,_cacheShaders:!0,_destroyShaders:!1,_cachePipelines:!0,_sharePipelines:!0,_destroyPipelines:!1,_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0};get[Symbol.toStringTag](){return`Device`}toString(){return`Device(${this.id})`}id;props;userData={};statsManager=ey;_factories={};timestamp=0;_reused=!1;_moduleData={};_textureCaps={};_debugGPUTimeQuery=null;constructor(t){this.props={...e.defaultProps,...t},this.id=this.props.id||ry(this[Symbol.toStringTag].toLowerCase())}getVertexFormatInfo(e){return Ty.getVertexFormatInfo(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return Xy.getInfo(e)}getTextureFormatCapabilities(e){let t=this._textureCaps[e];if(!t){let n=this._getDeviceTextureFormatCapabilities(e);t=this._getDeviceSpecificTextureFormatCapabilities(n),this._textureCaps[e]=t}return t}getMipLevelCount(e,t,n=1){return 1+Math.floor(Math.log2(Math.max(e,t,n)))}isExternalImage(e){return rb(e)}getExternalImageSize(e){return ib(e)}isTextureFormatSupported(e){return this.getTextureFormatCapabilities(e).create}isTextureFormatFilterable(e){return this.getTextureFormatCapabilities(e).filter}isTextureFormatRenderable(e){return this.getTextureFormatCapabilities(e).render}isTextureFormatCompressed(e){return Xy.isCompressed(e)}getSupportedCompressedTextureFormats(){let e=[];for(let t of Object.keys(Hy()))this.isTextureFormatCompressed(t)&&this.isTextureFormatSupported(t)&&e.push(t);return e}pushDebugGroup(e){this.commandEncoder.pushDebugGroup(e)}popDebugGroup(){this.commandEncoder?.popDebugGroup()}insertDebugMarker(e){this.commandEncoder?.insertDebugMarker(e)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(e,t,...n){if(!this.props.onError(e,t)){let r=ob(t,n);return Z.error(this.type===`webgl`?`%cWebGL`:`%cWebGPU`,`color: white; background: red; padding: 2px 6px; border-radius: 3px;`,e.message,...r)}return()=>{}}debug(){if(this.props.debug)debugger;else Z.once(0,`'Type luma.log.set({debug: true}) in console to enable debug breakpoints',
|
|
1337
|
-
or create a device with the 'debug: true' prop.`)()}getDefaultCanvasContext(){if(!this.canvasContext)throw Error(`Device has no default CanvasContext. See props.createCanvasContext`);return this.canvasContext}createFence(){throw Error(`createFence() not implemented`)}beginRenderPass(e){return this.commandEncoder.beginRenderPass(e)}beginComputePass(e){return this.commandEncoder.beginComputePass(e)}generateMipmapsWebGPU(e){throw Error(`not implemented`)}_createSharedRenderPipelineWebGL(e){throw Error(`_createSharedRenderPipelineWebGL() not implemented`)}_createBindGroupLayoutWebGPU(e,t){throw Error(`_createBindGroupLayoutWebGPU() not implemented`)}_createBindGroupWebGPU(e,t,n,r,i){throw Error(`_createBindGroupWebGPU() not implemented`)}_supportsDebugGPUTime(){return this.features.has(`timestamp-query`)&&!!(this.props.debug||this.props.debugGPUTime)}_enableDebugGPUTime(e=256){if(!this._supportsDebugGPUTime())return null;if(this._debugGPUTimeQuery)return this._debugGPUTimeQuery;try{this._debugGPUTimeQuery=this.createQuerySet({type:`timestamp`,count:e}),this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id,timeProfilingQuerySet:this._debugGPUTimeQuery})}catch{this._debugGPUTimeQuery=null}return this._debugGPUTimeQuery}_disableDebugGPUTime(){this._debugGPUTimeQuery&&=(this.commandEncoder.getTimeProfilingQuerySet()===this._debugGPUTimeQuery&&(this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id})),this._debugGPUTimeQuery.destroy(),null)}_isDebugGPUTimeEnabled(){return this._debugGPUTimeQuery!==null}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,t){throw Error(`not implemented`)}readPixelsToBufferWebGL(e,t){throw Error(`not implemented`)}setParametersWebGL(e){throw Error(`not implemented`)}getParametersWebGL(e){throw Error(`not implemented`)}withParametersWebGL(e,t){throw Error(`not implemented`)}clearWebGL(e){throw Error(`not implemented`)}resetWebGL(){throw Error(`not implemented`)}getModuleData(e){return this._moduleData[e]||={},this._moduleData[e]}static _getCanvasContextProps(e){return e.createCanvasContext===!0?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){let t=Xy.getCapabilities(e),n=e=>(typeof e==`string`?this.features.has(e):e)??!0,r=n(t.create);return{format:e,create:r,render:r&&n(t.render),filter:r&&n(t.filter),blend:r&&n(t.blend),store:r&&n(t.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let t={...e};if((e.usage||0)&Sy.INDEX&&(e.indexType||(e.data instanceof Uint32Array?t.indexType=`uint32`:e.data instanceof Uint16Array?t.indexType=`uint16`:e.data instanceof Uint8Array&&(t.data=new Uint16Array(e.data),t.indexType=`uint16`)),!t.indexType))throw Error(`indices buffer content must be of type uint16 or uint32`);return t}};function pb(e,t){return e==null?t===void 0?!1:t!==`production`:!!e}function mb(){return pb(Z.get(`debug`),hb())}function hb(){let e=globalThis.process;if(e?.env)return e.env.NODE_ENV}var gb=`set luma.log.level=1 (or higher) to trace rendering`,_b="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",vb=new class e{static defaultProps={...fb.defaultProps,type:`best-available`,adapters:void 0,waitForPageLoad:!0};stats=ey;log=Z;VERSION=`9.3.3`;spector;preregisteredAdapters=new Map;constructor(){if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw Z.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),Z.error(`'yarn why @luma.gl/core' can help identify the source of the conflict`)(),Error(`luma.gl - multiple versions detected: see console log`);Z.error(`This version of luma.gl has already been initialized`)()}Z.log(1,`${this.VERSION} - ${gb}`)(),globalThis.luma=this}async createDevice(t={}){let n={...e.defaultProps,...t},r=this.selectAdapter(n.type,n.adapters);if(!r)throw Error(_b);return n.waitForPageLoad&&await r.pageLoaded,await r.create(n)}async attachDevice(e,t){let n=this._getTypeFromHandle(e,t.adapters),r=n&&this.selectAdapter(n,t.adapters);if(!r)throw Error(_b);return await r?.attach?.(e,t)}registerAdapters(e){for(let t of e)this.preregisteredAdapters.set(t.type,t)}getSupportedAdapters(e=[]){let t=this._getAdapterMap(e);return Array.from(t).map(([,e])=>e).filter(e=>e.isSupported?.()).map(e=>e.type)}getBestAvailableAdapterType(e=[]){let t=[`webgpu`,`webgl`,`null`],n=this._getAdapterMap(e);for(let e of t)if(n.get(e)?.isSupported?.())return e;return null}selectAdapter(e,t=[]){let n=e;e===`best-available`&&(n=this.getBestAvailableAdapterType(t));let r=this._getAdapterMap(t);return n&&r.get(n)||null}enforceWebGL2(e=!0,t=[]){let n=this._getAdapterMap(t).get(`webgl`);n||Z.warn(`enforceWebGL2: webgl adapter not found`)(),n?.enforceWebGL2?.(e)}setDefaultDeviceProps(t){Object.assign(e.defaultProps,t)}_getAdapterMap(e=[]){let t=new Map(this.preregisteredAdapters);for(let n of e)t.set(n.type,n);return t}_getTypeFromHandle(e,t=[]){return e instanceof WebGL2RenderingContext?`webgl`:typeof GPUDevice<`u`&&e instanceof GPUDevice||e?.queue?`webgpu`:e===null?`null`:(e instanceof WebGLRenderingContext?Z.warn(`WebGL1 is not supported`,e)():Z.warn(`Unknown handle type`,e)(),null)}},yb=class{get pageLoaded(){return Cb()}},bb=ad()&&typeof document<`u`,xb=()=>bb&&document.readyState===`complete`,Sb=null;function Cb(){return Sb||=xb()||typeof window>`u`?Promise.resolve():new Promise(e=>window.addEventListener(`load`,()=>e())),Sb}var wb=class{props;_resizeObserver;_intersectionObserver;_observeDevicePixelRatioTimeout=null;_observeDevicePixelRatioMediaQuery=null;_handleDevicePixelRatioChange=()=>this._refreshDevicePixelRatio();_trackPositionInterval=null;_started=!1;get started(){return this._started}constructor(e){this.props=e}start(){if(!(this._started||!this.props.canvas)){this._started=!0,this._intersectionObserver||=new IntersectionObserver(e=>this.props.onIntersection(e)),this._resizeObserver||=new ResizeObserver(e=>this.props.onResize(e)),this._intersectionObserver.observe(this.props.canvas);try{this._resizeObserver.observe(this.props.canvas,{box:`device-pixel-content-box`})}catch{this._resizeObserver.observe(this.props.canvas,{box:`content-box`})}this._observeDevicePixelRatioTimeout=setTimeout(()=>this._refreshDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}}stop(){this._started&&(this._started=!1,this._observeDevicePixelRatioTimeout&&=(clearTimeout(this._observeDevicePixelRatioTimeout),null),this._observeDevicePixelRatioMediaQuery&&=(this._observeDevicePixelRatioMediaQuery.removeEventListener(`change`,this._handleDevicePixelRatioChange),null),this._trackPositionInterval&&=(clearInterval(this._trackPositionInterval),null),this._resizeObserver?.disconnect(),this._intersectionObserver?.disconnect())}_refreshDevicePixelRatio(){this._started&&(this.props.onDevicePixelRatioChange(),this._observeDevicePixelRatioMediaQuery?.removeEventListener(`change`,this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this._observeDevicePixelRatioMediaQuery.addEventListener(`change`,this._handleDevicePixelRatioChange,{once:!0}))}_trackPosition(e=100){this._trackPositionInterval||=setInterval(()=>{this._started?this.props.onPositionChange():this._trackPositionInterval&&=(clearInterval(this._trackPositionInterval),null)},e)}};function Tb(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function Eb(e,t){if(!e){let e=Error(t??`luma.gl assertion failed.`);throw Error.captureStackTrace?.(e,Eb),e}}function Db(e,t){return Eb(e,t),e}var Ob=class e{static isHTMLCanvas(e){return typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement}static isOffscreenCanvas(e){return typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas}static defaultProps={id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,alphaMode:`opaque`,colorSpace:`srgb`,trackPosition:!1};id;props;canvas;htmlCanvas;offscreenCanvas;type;initialized;isInitialized=!1;isVisible=!0;cssWidth;cssHeight;devicePixelRatio;devicePixelWidth;devicePixelHeight;drawingBufferWidth;drawingBufferHeight;_initializedResolvers=Tb();_canvasObserver;_position=[0,0];destroyed=!1;_needsDrawingBufferResize=!0;toString(){return`${this[Symbol.toStringTag]}(${this.id})`}constructor(t){this.props={...e.defaultProps,...t},t=this.props,this.initialized=this._initializedResolvers.promise,ad()?t.canvas?typeof t.canvas==`string`?this.canvas=Ab(t.canvas):this.canvas=t.canvas:this.canvas=jb(t):this.canvas={width:t.width||1,height:t.height||1},e.isHTMLCanvas(this.canvas)?(this.id=t.id||this.canvas.id,this.type=`html-canvas`,this.htmlCanvas=this.canvas):e.isOffscreenCanvas(this.canvas)?(this.id=t.id||`offscreen-canvas`,this.type=`offscreen-canvas`,this.offscreenCanvas=this.canvas):(this.id=t.id||`node-canvas-context`,this.type=`node`),this.cssWidth=this.htmlCanvas?.clientWidth||this.canvas.width,this.cssHeight=this.htmlCanvas?.clientHeight||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],this._canvasObserver=new wb({canvas:this.htmlCanvas,trackPosition:this.props.trackPosition,onResize:e=>this._handleResize(e),onIntersection:e=>this._handleIntersection(e),onDevicePixelRatioChange:()=>this._observeDevicePixelRatio(),onPositionChange:()=>this.updatePosition()})}destroy(){this.destroyed||(this.destroyed=!0,this._stopObservers(),this.device=null)}setProps(e){return`useDevicePixels`in e&&(this.props.useDevicePixels=e.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCurrentFramebuffer(e){return this._resizeDrawingBufferIfNeeded(),this._getCurrentFramebuffer(e)}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){let e=this.device.limits.maxTextureDimension2D;return[e,e]}setDrawingBufferSize(e,t){e=Math.floor(e),t=Math.floor(t),!(this.drawingBufferWidth===e&&this.drawingBufferHeight===t)&&(this.drawingBufferWidth=e,this.drawingBufferHeight=t,this._needsDrawingBufferResize=!0)}getDevicePixelRatio(){return typeof window<`u`&&window.devicePixelRatio||1}cssToDevicePixels(e,t=!0){let n=this.cssToDeviceRatio(),[r,i]=this.getDrawingBufferSize();return Mb(e,n,r,i,t)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){let[e,t]=this.getDrawingBufferSize();return e>0&&t>0?e/t:1}cssToDeviceRatio(){try{let[e]=this.getDrawingBufferSize(),[t]=this.getCSSSize();return t?e/t:1}catch{return 1}}resize(e){this.setDrawingBufferSize(e.width,e.height)}_setAutoCreatedCanvasId(e){this.htmlCanvas?.id===`lumagl-auto-created-canvas`&&(this.htmlCanvas.id=e)}_startObservers(){this.destroyed||this._canvasObserver.start()}_stopObservers(){this._canvasObserver.stop()}_handleIntersection(e){if(this.destroyed)return;let t=e.find(e=>e.target===this.canvas);if(!t)return;let n=t.isIntersecting;this.isVisible!==n&&(this.isVisible=n,this.device.props.onVisibilityChange(this))}_handleResize(e){if(this.destroyed)return;let t=e.find(e=>e.target===this.canvas);if(!t)return;let n=Db(t.contentBoxSize?.[0]);this.cssWidth=n.inlineSize,this.cssHeight=n.blockSize;let r=this.getDevicePixelSize(),i=t.devicePixelContentBoxSize?.[0]?.inlineSize||n.inlineSize*devicePixelRatio,a=t.devicePixelContentBoxSize?.[0]?.blockSize||n.blockSize*devicePixelRatio,[o,s]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(i,o)),this.devicePixelHeight=Math.max(1,Math.min(a,s)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:r})}_updateDrawingBufferSize(){if(this.props.autoResize)if(typeof this.props.useDevicePixels==`number`){let e=this.props.useDevicePixels;this.setDrawingBufferSize(this.cssWidth*e,this.cssHeight*e)}else this.props.useDevicePixels?this.setDrawingBufferSize(this.devicePixelWidth,this.devicePixelHeight):this.setDrawingBufferSize(this.cssWidth,this.cssHeight);this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_resizeDrawingBufferIfNeeded(){this._needsDrawingBufferResize&&(this._needsDrawingBufferResize=!1,(this.drawingBufferWidth!==this.canvas.width||this.drawingBufferHeight!==this.canvas.height)&&(this.canvas.width=this.drawingBufferWidth,this.canvas.height=this.drawingBufferHeight,this._configureDevice()))}_observeDevicePixelRatio(){if(this.destroyed||!this._canvasObserver.started)return;let e=this.devicePixelRatio;this.devicePixelRatio=window.devicePixelRatio,this.updatePosition(),this.device.props.onDevicePixelRatioChange?.(this,{oldRatio:e})}updatePosition(){if(this.destroyed)return;let e=this.htmlCanvas?.getBoundingClientRect();if(e){let t=[e.left,e.top];if(this._position??=t,t[0]!==this._position[0]||t[1]!==this._position[1]){let e=this._position;this._position=t,this.device.props.onPositionChange?.(this,{oldPosition:e})}}}};function kb(e){if(typeof e==`string`){let t=document.getElementById(e);if(!t)throw Error(`${e} is not an HTML element`);return t}return e||document.body}function Ab(e){let t=document.getElementById(e);if(!Ob.isHTMLCanvas(t))throw Error(`Object is not a canvas element`);return t}function jb(e){let{width:t,height:n}=e,r=document.createElement(`canvas`);r.id=ry(`lumagl-auto-created-canvas`),r.width=t||1,r.height=n||1,r.style.width=Number.isFinite(t)?`${t}px`:`100%`,r.style.height=Number.isFinite(n)?`${n}px`:`100%`,e?.visible||(r.style.visibility=`hidden`);let i=kb(e?.container||null);return i.insertBefore(r,i.firstChild),r}function Mb(e,t,n,r,i){let a=e,o=Nb(a[0],t,n),s=Pb(a[1],t,r,i),c=Nb(a[0]+1,t,n),l=c===n-1?c:c-1;c=Pb(a[1]+1,t,r,i);let u;return i?(c=c===0?c:c+1,u=s,s=c):u=c===r-1?c:c-1,{x:o,y:s,width:Math.max(l-o+1,1),height:Math.max(u-s+1,1)}}function Nb(e,t,n){return Math.min(Math.round(e*t),n-1)}function Pb(e,t,n,r){return r?Math.max(0,n-1-Math.round(e*t)):Math.min(Math.round(e*t),n-1)}var Fb=class extends Ob{static defaultProps=Ob.defaultProps},Ib=class extends Ob{},Lb=class e extends Q{static defaultProps={...Q.defaultProps,type:`color-sampler`,addressModeU:`clamp-to-edge`,addressModeV:`clamp-to-edge`,addressModeW:`clamp-to-edge`,magFilter:`nearest`,minFilter:`nearest`,mipmapFilter:`none`,lodMinClamp:0,lodMaxClamp:32,compare:`less-equal`,maxAnisotropy:1};get[Symbol.toStringTag](){return`Sampler`}constructor(t,n){n=e.normalizeProps(t,n),super(t,n,e.defaultProps)}static normalizeProps(e,t){return t}},Rb={"1d":`1d`,"2d":`2d`,"2d-array":`2d`,cube:`2d`,"cube-array":`2d`,"3d":`3d`},zb=class e extends Q{static SAMPLE=4;static STORAGE=8;static RENDER=16;static COPY_SRC=1;static COPY_DST=2;static TEXTURE=4;static RENDER_ATTACHMENT=16;dimension;baseDimension;format;width;height;depth;mipLevels;samples;byteAlignment;ready=Promise.resolve(this);isReady=!0;updateTimestamp;get[Symbol.toStringTag](){return`Texture`}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}constructor(t,n,r){if(n=e.normalizeProps(t,n),super(t,n,e.defaultProps),this.dimension=this.props.dimension,this.baseDimension=Rb[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,this.samples=this.props.samples||1,this.dimension===`cube`&&(this.depth=6),this.props.width===void 0||this.props.height===void 0)if(t.isExternalImage(n.data)){let e=t.getExternalImageSize(n.data);this.width=e?.width||1,this.height=e?.height||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&Z.warn(`${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`)();this.byteAlignment=r?.byteAlignment||1,this.updateTimestamp=t.incrementTimestamp()}clone(e){return this.device.createTexture({...this.props,...e})}setSampler(e){this.sampler=e instanceof Lb?e:this.device.createSampler(e)}copyImageData(e){let{data:t,depth:n,...r}=e;this.writeData(t,{...r,depthOrArrayLayers:r.depthOrArrayLayers??n})}computeMemoryLayout(e={}){let{width:t=this.width,height:n=this.height,depthOrArrayLayers:r=this.depth}=this._normalizeTextureReadOptions(e),{format:i,byteAlignment:a}=this;return Xy.computeMemoryLayout({format:i,width:t,height:n,depth:r,byteAlignment:a})}readBuffer(e,t){throw Error(`readBuffer not implemented`)}readDataAsync(e){throw Error(`readBuffer not implemented`)}writeBuffer(e,t){throw Error(`readBuffer not implemented`)}writeData(e,t){throw Error(`readBuffer not implemented`)}readDataSyncWebGL(e){throw Error(`readDataSyncWebGL not available`)}generateMipmapsWebGL(){throw Error(`generateMipmapsWebGL not available`)}static normalizeProps(e,t){let n={...t},{width:r,height:i}=n;return typeof r==`number`&&(n.width=Math.max(1,Math.ceil(r))),typeof i==`number`&&(n.height=Math.max(1,Math.ceil(i))),n}_initializeData(e){this.device.isExternalImage(e)?this.copyExternalImage({image:e,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:`all`,colorSpace:`srgb`,premultipliedAlpha:!1,flipY:!1}):e&&this.copyImageData({data:e,mipLevel:0,x:0,y:0,z:0,aspect:`all`})}_normalizeCopyImageDataOptions(e){let{data:t,depth:n,...r}=e,i=this._normalizeTextureWriteOptions({...r,depthOrArrayLayers:r.depthOrArrayLayers??n});return{data:t,depth:i.depthOrArrayLayers,...i}}_normalizeCopyExternalImageOptions(t){let n=e._omitUndefined(t),r=n.mipLevel??0,i=this._getMipLevelSize(r),a=this.device.getExternalImageSize(t.image),o={...e.defaultCopyExternalImageOptions,...i,...a,...n};return o.width=Math.min(o.width,i.width-o.x),o.height=Math.min(o.height,i.height-o.y),o.depth=Math.min(o.depth,i.depthOrArrayLayers-o.z),o}_normalizeTextureReadOptions(t){let n=e._omitUndefined(t),r=n.mipLevel??0,i=this._getMipLevelSize(r),a={...e.defaultTextureReadOptions,...i,...n};return a.width=Math.min(a.width,i.width-a.x),a.height=Math.min(a.height,i.height-a.y),a.depthOrArrayLayers=Math.min(a.depthOrArrayLayers,i.depthOrArrayLayers-a.z),a}_getSupportedColorReadOptions(e){let t=this._normalizeTextureReadOptions(e),n=Xy.getInfo(this.format);switch(this._validateColorReadAspect(t),this._validateColorReadFormat(n),this.dimension){case`2d`:case`cube`:case`cube-array`:case`2d-array`:case`3d`:return t;default:throw Error(`${this} color readback does not support ${this.dimension} textures`)}}_validateColorReadAspect(e){if(e.aspect!==`all`)throw Error(`${this} color readback only supports aspect 'all'`)}_validateColorReadFormat(e){if(e.compressed)throw Error(`${this} color readback does not support compressed formats (${this.format})`);switch(e.attachment){case`color`:return;case`depth`:throw Error(`${this} color readback does not support depth formats (${this.format})`);case`stencil`:throw Error(`${this} color readback does not support stencil formats (${this.format})`);case`depth-stencil`:throw Error(`${this} color readback does not support depth-stencil formats (${this.format})`);default:throw Error(`${this} color readback does not support format ${this.format}`)}}_normalizeTextureWriteOptions(t){let n=e._omitUndefined(t),r=n.mipLevel??0,i=this._getMipLevelSize(r),a={...e.defaultTextureWriteOptions,...i,...n};a.width=Math.min(a.width,i.width-a.x),a.height=Math.min(a.height,i.height-a.y),a.depthOrArrayLayers=Math.min(a.depthOrArrayLayers,i.depthOrArrayLayers-a.z);let o=Xy.computeMemoryLayout({format:this.format,width:a.width,height:a.height,depth:a.depthOrArrayLayers,byteAlignment:this.byteAlignment}),s=o.bytesPerPixel*a.width;if(a.bytesPerRow=n.bytesPerRow??o.bytesPerRow,a.rowsPerImage=n.rowsPerImage??a.height,a.bytesPerRow<s)throw Error(`bytesPerRow (${a.bytesPerRow}) must be at least ${s} for ${this.format}`);if(a.rowsPerImage<a.height)throw Error(`rowsPerImage (${a.rowsPerImage}) must be at least ${a.height} for ${this.format}`);let c=this.device.getTextureFormatInfo(this.format).bytesPerPixel;if(c&&a.bytesPerRow%c!==0)throw Error(`bytesPerRow (${a.bytesPerRow}) must be a multiple of bytesPerPixel (${c}) for ${this.format}`);return a}_getMipLevelSize(e){return{width:Math.max(1,this.width>>e),height:this.baseDimension===`1d`?1:Math.max(1,this.height>>e),depthOrArrayLayers:this.dimension===`3d`?Math.max(1,this.depth>>e):this.depth}}getAllocatedByteLength(){let e=0;for(let t=0;t<this.mipLevels;t++){let{width:n,height:r,depthOrArrayLayers:i}=this._getMipLevelSize(t);e+=Xy.computeMemoryLayout({format:this.format,width:n,height:r,depth:i,byteAlignment:1}).byteLength}return e*this.samples}static _omitUndefined(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}static defaultProps={...Q.defaultProps,data:null,dimension:`2d`,format:`rgba8unorm`,usage:e.SAMPLE|e.RENDER|e.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0};static defaultCopyDataOptions={data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,width:void 0,height:void 0,depthOrArrayLayers:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:`all`};static defaultCopyExternalImageOptions={image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:`all`,colorSpace:`srgb`,premultipliedAlpha:!1,flipY:!1};static defaultTextureReadOptions={x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:`all`};static defaultTextureWriteOptions={byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:`all`}},Bb=class e extends Q{get[Symbol.toStringTag](){return`TextureView`}constructor(t,n){super(t,n,e.defaultProps)}static defaultProps={...Q.defaultProps,format:void 0,dimension:void 0,aspect:`all`,baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0}};function Vb(e,t,n){let r=``,i=t.split(/\r?\n/),a=e.slice().sort((e,t)=>e.lineNum-t.lineNum);switch(n?.showSourceCode||`no`){case`all`:let t=0;for(let e=1;e<=i.length;e++){let o=i[e-1],s=a[t];for(o&&s&&(r+=Wb(o,e,n));a.length>t&&s.lineNum===e;){let e=a[t++];e&&(r+=Hb(e,i,e.lineNum,{...n,inlineSource:!1}))}}for(;a.length>t;){let e=a[t++];e&&(r+=Hb(e,[],0,{...n,inlineSource:!1}))}return r;case`issues`:case`no`:for(let t of e)r+=Hb(t,i,t.lineNum,{inlineSource:n?.showSourceCode!==`no`});return r}}function Hb(e,t,n,r){if(r?.inlineSource)return`
|
|
1338
|
-
${
|
|
1336
|
+
`,getUniforms:ny};function ny(e={},t){let n={},r=Yv(e.useByteColors,!0);return e.highlightedObjectColor===void 0||(e.highlightedObjectColor===null?n.isHighlightActive=!1:(n.isHighlightActive=!0,n.highlightedObjectColor=e.highlightedObjectColor.slice(0,3))),e.highlightColor&&(n.highlightColor=Zv(e.highlightColor,r)),e.isActive!==void 0&&(n.isActive=!!e.isActive,n.isAttribute=!!e.isAttribute),e.useByteColors!==void 0&&(n.useByteColors=!!e.useByteColors),n}var ry=`GPU Time and Memory`,iy=[`Adapter`,`GPU`,`GPU Type`,`GPU Backend`,`Frame Rate`,`CPU Time`,`GPU Time`,`GPU Memory`,`Buffer Memory`,`Texture Memory`,`Referenced Buffer Memory`,`Referenced Texture Memory`,`Swap Chain Texture`],ay=new WeakMap,oy=new WeakMap,sy=new class{stats=new Map;getStats(e){return this.get(e)}get(e){this.stats.has(e)||this.stats.set(e,new Ff({id:e}));let t=this.stats.get(e);return e===ry&&cy(t,iy),t}};function cy(e,t){let n=e.stats,r=!1;for(let i of t)n[i]||(e.get(i),r=!0);let i=Object.keys(n).length,a=ay.get(e);if(!r&&a?.orderedStatNames===t&&a.statCount===i)return;let o={},s=oy.get(t);s||(s=new Set(t),oy.set(t,s));for(let e of t)n[e]&&(o[e]=n[e]);for(let[e,t]of Object.entries(n))s.has(e)||(o[e]=t);for(let e of Object.keys(n))delete n[e];Object.assign(n,o),ay.set(e,{orderedStatNames:t,statCount:i})}var Z=new Md({id:`luma.gl`}),ly={};function uy(e=`id`){return ly[e]=ly[e]||1,`${e}-${ly[e]++}`}var dy=`cpu-hotspot-profiler`,fy=`GPU Resource Counts`,py=`Resource Counts`,my=`GPU Time and Memory`,hy=[`Resources`,`Buffers`,`Textures`,`Samplers`,`TextureViews`,`Framebuffers`,`QuerySets`,`Shaders`,`RenderPipelines`,`ComputePipelines`,`PipelineLayouts`,`VertexArrays`,`RenderPasss`,`ComputePasss`,`CommandEncoders`,`CommandBuffers`],gy=[`Resources`,`Buffers`,`Textures`,`Samplers`,`TextureViews`,`Framebuffers`,`QuerySets`,`Shaders`,`RenderPipelines`,`SharedRenderPipelines`,`ComputePipelines`,`PipelineLayouts`,`VertexArrays`,`RenderPasss`,`ComputePasss`,`CommandEncoders`,`CommandBuffers`],_y=hy.flatMap(e=>[`${e} Created`,`${e} Active`]),vy=gy.flatMap(e=>[`${e} Created`,`${e} Active`]),yy=new WeakMap,by=new WeakMap,Q=class{static defaultProps={id:`undefined`,handle:void 0,userData:void 0};toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}id;props;userData={};_device;destroyed=!1;allocatedBytes=0;allocatedBytesName=null;_attachedResources=new Set;constructor(e,t,n){if(!e)throw Error(`no device`);this._device=e,this.props=xy(t,n);let r=this.props.id===`undefined`?uy(this[Symbol.toStringTag]):this.props.id;this.props.id=r,this.id=r,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyed||this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(let e of this._attachedResources)e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyed||=(this.destroyAttachedResources(),this.removeStats(),!0)}removeStats(){let e=wy(this._device),t=e?Ty():0,n=[this._device.statsManager.getStats(fy),this._device.statsManager.getStats(py)],r=Cy(this._device);for(let e of n)Sy(e,r);let i=this.getStatsName();for(let e of n)e.get(`Resources Active`).decrementCount(),e.get(`${i}s Active`).decrementCount();e&&(e.statsBookkeepingCalls=(e.statsBookkeepingCalls||0)+1,e.statsBookkeepingTimeMs=(e.statsBookkeepingTimeMs||0)+(Ty()-t))}trackAllocatedMemory(e,t=this.getStatsName()){let n=wy(this._device),r=n?Ty():0,i=this._device.statsManager.getStats(my);this.allocatedBytes>0&&this.allocatedBytesName&&(i.get(`GPU Memory`).subtractCount(this.allocatedBytes),i.get(`${this.allocatedBytesName} Memory`).subtractCount(this.allocatedBytes)),i.get(`GPU Memory`).addCount(e),i.get(`${t} Memory`).addCount(e),n&&(n.statsBookkeepingCalls=(n.statsBookkeepingCalls||0)+1,n.statsBookkeepingTimeMs=(n.statsBookkeepingTimeMs||0)+(Ty()-r)),this.allocatedBytes=e,this.allocatedBytesName=t}trackReferencedMemory(e,t=this.getStatsName()){this.trackAllocatedMemory(e,`Referenced ${t}`)}trackDeallocatedMemory(e=this.getStatsName()){if(this.allocatedBytes===0){this.allocatedBytesName=null;return}let t=wy(this._device),n=t?Ty():0,r=this._device.statsManager.getStats(my);r.get(`GPU Memory`).subtractCount(this.allocatedBytes),r.get(`${this.allocatedBytesName||e} Memory`).subtractCount(this.allocatedBytes),t&&(t.statsBookkeepingCalls=(t.statsBookkeepingCalls||0)+1,t.statsBookkeepingTimeMs=(t.statsBookkeepingTimeMs||0)+(Ty()-n)),this.allocatedBytes=0,this.allocatedBytesName=null}trackDeallocatedReferencedMemory(e=this.getStatsName()){this.trackDeallocatedMemory(`Referenced ${e}`)}addStats(){let e=this.getStatsName(),t=wy(this._device),n=t?Ty():0,r=[this._device.statsManager.getStats(fy),this._device.statsManager.getStats(py)],i=Cy(this._device);for(let e of r)Sy(e,i);for(let t of r)t.get(`Resources Created`).incrementCount(),t.get(`Resources Active`).incrementCount(),t.get(`${e}s Created`).incrementCount(),t.get(`${e}s Active`).incrementCount();t&&(t.statsBookkeepingCalls=(t.statsBookkeepingCalls||0)+1,t.statsBookkeepingTimeMs=(t.statsBookkeepingTimeMs||0)+(Ty()-n)),Ey(this._device,e)}getStatsName(){return Dy(this)}};function xy(e,t){let n={...t};for(let t in e)e[t]!==void 0&&(n[t]=e[t]);return n}function Sy(e,t){let n=e.stats,r=!1;for(let i of t)n[i]||(e.get(i),r=!0);let i=Object.keys(n).length,a=yy.get(e);if(!r&&a?.orderedStatNames===t&&a.statCount===i)return;let o={},s=by.get(t);s||(s=new Set(t),by.set(t,s));for(let e of t)n[e]&&(o[e]=n[e]);for(let[e,t]of Object.entries(n))s.has(e)||(o[e]=t);for(let e of Object.keys(n))delete n[e];Object.assign(n,o),yy.set(e,{orderedStatNames:t,statCount:i})}function Cy(e){return e.type===`webgl`?vy:_y}function wy(e){let t=e.userData[dy];return t?.enabled?t:null}function Ty(){return globalThis.performance?.now?.()??Date.now()}function Ey(e,t){let n=wy(e);if(!(!n||!n.activeDefaultFramebufferAcquireDepth))switch(n.transientCanvasResourceCreates=(n.transientCanvasResourceCreates||0)+1,t){case`Texture`:n.transientCanvasTextureCreates=(n.transientCanvasTextureCreates||0)+1;break;case`TextureView`:n.transientCanvasTextureViewCreates=(n.transientCanvasTextureViewCreates||0)+1;break;case`Sampler`:n.transientCanvasSamplerCreates=(n.transientCanvasSamplerCreates||0)+1;break;case`Framebuffer`:n.transientCanvasFramebufferCreates=(n.transientCanvasFramebufferCreates||0)+1;break;default:break}}function Dy(e){let t=Object.getPrototypeOf(e);for(;t;){let n=Object.getPrototypeOf(t);if(!n||n===Q.prototype)return Oy(t)||e[Symbol.toStringTag]||e.constructor.name;t=n}return e[Symbol.toStringTag]||e.constructor.name}function Oy(e){let t=Object.getOwnPropertyDescriptor(e,Symbol.toStringTag);return typeof t?.get==`function`?t.get.call(e):typeof t?.value==`string`?t.value:null}var ky=class e extends Q{static INDEX=16;static VERTEX=32;static UNIFORM=64;static STORAGE=128;static INDIRECT=256;static QUERY_RESOLVE=512;static MAP_READ=1;static MAP_WRITE=2;static COPY_SRC=4;static COPY_DST=8;get[Symbol.toStringTag](){return`Buffer`}usage;indexType;updateTimestamp;constructor(t,n){let r={...n};(n.usage||0)&e.INDEX&&!n.indexType&&(n.data instanceof Uint32Array?r.indexType=`uint32`:n.data instanceof Uint16Array?r.indexType=`uint16`:n.data instanceof Uint8Array&&(r.indexType=`uint8`)),delete r.data,super(t,r,e.defaultProps),this.usage=r.usage||0,this.indexType=r.indexType,this.updateTimestamp=t.incrementTimestamp()}clone(e){return this.device.createBuffer({...this.props,...e})}static DEBUG_DATA_MAX_LENGTH=32;debugData=new ArrayBuffer(0);_setDebugData(t,n,r){let i=null,a;ArrayBuffer.isView(t)?(i=t,a=t.buffer):a=t;let o=Math.min(t?t.byteLength:r,e.DEBUG_DATA_MAX_LENGTH);if(a===null)this.debugData=new ArrayBuffer(o);else{let e=Math.min(i?.byteOffset||0,a.byteLength),t=Math.max(0,a.byteLength-e),n=Math.min(o,t);this.debugData=new Uint8Array(a,e,n).slice().buffer}}static defaultProps={...Q.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:`uint16`,onMapped:void 0}},Ay=new class{getDataTypeInfo(e){let[t,n,r]=jy[e],i=e.includes(`norm`);return{signedType:t,primitiveType:n,byteLength:r,normalized:i,integer:!i&&!e.startsWith(`float`),signed:e.startsWith(`s`)}}getNormalizedDataType(e){let t=e;switch(t){case`uint8`:return`unorm8`;case`sint8`:return`snorm8`;case`uint16`:return`unorm16`;case`sint16`:return`snorm16`;default:return t}}alignTo(e,t){switch(t){case 1:return e;case 2:return e+e%2;default:return e+(4-e%4)%4}}getDataType(e){let t=ArrayBuffer.isView(e)?e.constructor:e;if(t===Uint8ClampedArray)return`uint8`;let n=Object.values(jy).find(e=>t===e[4]);if(!n)throw Error(t.name);return n[0]}getTypedArrayConstructor(e){let[,,,,t]=jy[e];return t}},jy={uint8:[`uint8`,`u32`,1,!1,Uint8Array],sint8:[`sint8`,`i32`,1,!1,Int8Array],unorm8:[`uint8`,`f32`,1,!0,Uint8Array],snorm8:[`sint8`,`f32`,1,!0,Int8Array],uint16:[`uint16`,`u32`,2,!1,Uint16Array],sint16:[`sint16`,`i32`,2,!1,Int16Array],unorm16:[`uint16`,`u32`,2,!0,Uint16Array],snorm16:[`sint16`,`i32`,2,!0,Int16Array],float16:[`float16`,`f16`,2,!1,Uint16Array],float32:[`float32`,`f32`,4,!1,Float32Array],uint32:[`uint32`,`u32`,4,!1,Uint32Array],sint32:[`sint32`,`i32`,4,!1,Int32Array]},My=new class{getVertexFormatInfo(e){let t;e.endsWith(`-webgl`)&&(e.replace(`-webgl`,``),t=!0);let[n,r]=e.split(`x`),i=n,a=r?parseInt(r):1,o=Ay.getDataTypeInfo(i),s={type:i,components:a,byteLength:o.byteLength*a,integer:o.integer,signed:o.signed,normalized:o.normalized};return t&&(s.webglOnly=!0),s}makeVertexFormat(e,t,n){let r=n?Ay.getNormalizedDataType(e):e;switch(r){case`unorm8`:return t===1?`unorm8`:t===3?`unorm8x3-webgl`:`${r}x${t}`;case`snorm8`:return t===1?`snorm8`:t===3?`snorm8x3-webgl`:`${r}x${t}`;case`uint8`:case`sint8`:if(t===1||t===3)throw Error(`size: ${t}`);return`${r}x${t}`;case`uint16`:return t===1?`uint16`:t===3?`uint16x3-webgl`:`${r}x${t}`;case`sint16`:return t===1?`sint16`:t===3?`sint16x3-webgl`:`${r}x${t}`;case`unorm16`:return t===1?`unorm16`:t===3?`unorm16x3-webgl`:`${r}x${t}`;case`snorm16`:return t===1?`snorm16`:t===3?`snorm16x3-webgl`:`${r}x${t}`;case`float16`:if(t===1||t===3)throw Error(`size: ${t}`);return`${r}x${t}`;default:return t===1?r:`${r}x${t}`}}getVertexFormatFromAttribute(e,t,n){if(!t||t>4)throw Error(`size ${t}`);let r=t,i=Ay.getDataType(e);return this.makeVertexFormat(i,r,n)}getCompatibleVertexFormat(e){let t;switch(e.primitiveType){case`f32`:t=`float32`;break;case`i32`:t=`sint32`;break;case`u32`:t=`uint32`;break;case`f16`:return e.components<=2?`float16x2`:`float16x4`}return e.components===1?t:`${t}x${e.components}`}},Ny=`texture-compression-bc`,Py=`texture-compression-astc`,Fy=`texture-compression-etc2`,Iy=`texture-compression-etc1-webgl`,Ly=`texture-compression-pvrtc-webgl`,Ry=`texture-compression-atc-webgl`,zy=`float32-renderable-webgl`,By=`float16-renderable-webgl`,Vy=`rgb9e5ufloat-renderable-webgl`,Hy=`snorm8-renderable-webgl`,Uy=`norm16-webgl`,Wy=`norm16-renderable-webgl`,Gy=`snorm16-renderable-webgl`,Ky=`float32-filterable`,qy=`float16-filterable-webgl`;function Jy(e){let t=Qy[e];if(!t)throw Error(`Unsupported texture format ${e}`);return t}function Yy(){return Qy}var Xy={r8unorm:{},rg8unorm:{},"rgb8unorm-webgl":{},rgba8unorm:{},"rgba8unorm-srgb":{},r8snorm:{render:Hy},rg8snorm:{render:Hy},"rgb8snorm-webgl":{},rgba8snorm:{render:Hy},r8uint:{},rg8uint:{},rgba8uint:{},r8sint:{},rg8sint:{},rgba8sint:{},bgra8unorm:{},"bgra8unorm-srgb":{},r16unorm:{f:Uy,render:Wy},rg16unorm:{f:Uy,render:Wy},"rgb16unorm-webgl":{f:Uy,render:!1},rgba16unorm:{f:Uy,render:Wy},r16snorm:{f:Uy,render:Gy},rg16snorm:{f:Uy,render:Gy},"rgb16snorm-webgl":{f:Uy,render:!1},rgba16snorm:{f:Uy,render:Gy},r16uint:{},rg16uint:{},rgba16uint:{},r16sint:{},rg16sint:{},rgba16sint:{},r16float:{render:By,filter:`float16-filterable-webgl`},rg16float:{render:By,filter:qy},rgba16float:{render:By,filter:qy},r32uint:{},rg32uint:{},rgba32uint:{},r32sint:{},rg32sint:{},rgba32sint:{},r32float:{render:zy,filter:Ky},rg32float:{render:!1,filter:Ky},"rgb32float-webgl":{render:zy,filter:Ky},rgba32float:{render:zy,filter:Ky},"rgba4unorm-webgl":{channels:`rgba`,bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:`rgb`,bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:`rgba`,bitsPerChannel:[5,5,5,1],packed:!0},rgb9e5ufloat:{channels:`rgb`,packed:!0,render:Vy},rg11b10ufloat:{channels:`rgb`,bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:zy},rgb10a2unorm:{channels:`rgba`,bitsPerChannel:[10,10,10,2],packed:!0,p:1},rgb10a2uint:{channels:`rgba`,bitsPerChannel:[10,10,10,2],packed:!0,p:1},stencil8:{attachment:`stencil`,bitsPerChannel:[8,0,0,0],dataType:`uint8`},depth16unorm:{attachment:`depth`,bitsPerChannel:[16,0,0,0],dataType:`uint16`},depth24plus:{attachment:`depth`,bitsPerChannel:[24,0,0,0],dataType:`uint32`},depth32float:{attachment:`depth`,bitsPerChannel:[32,0,0,0],dataType:`float32`},"depth24plus-stencil8":{attachment:`depth-stencil`,bitsPerChannel:[24,8,0,0],packed:!0},"depth32float-stencil8":{attachment:`depth-stencil`,bitsPerChannel:[32,8,0,0],packed:!0}},Zy={"bc1-rgb-unorm-webgl":{f:Ny},"bc1-rgb-unorm-srgb-webgl":{f:Ny},"bc1-rgba-unorm":{f:Ny},"bc1-rgba-unorm-srgb":{f:Ny},"bc2-rgba-unorm":{f:Ny},"bc2-rgba-unorm-srgb":{f:Ny},"bc3-rgba-unorm":{f:Ny},"bc3-rgba-unorm-srgb":{f:Ny},"bc4-r-unorm":{f:Ny},"bc4-r-snorm":{f:Ny},"bc5-rg-unorm":{f:Ny},"bc5-rg-snorm":{f:Ny},"bc6h-rgb-ufloat":{f:Ny},"bc6h-rgb-float":{f:Ny},"bc7-rgba-unorm":{f:Ny},"bc7-rgba-unorm-srgb":{f:Ny},"etc2-rgb8unorm":{f:Fy},"etc2-rgb8unorm-srgb":{f:Fy},"etc2-rgb8a1unorm":{f:Fy},"etc2-rgb8a1unorm-srgb":{f:Fy},"etc2-rgba8unorm":{f:Fy},"etc2-rgba8unorm-srgb":{f:Fy},"eac-r11unorm":{f:Fy},"eac-r11snorm":{f:Fy},"eac-rg11unorm":{f:Fy},"eac-rg11snorm":{f:Fy},"astc-4x4-unorm":{f:Py},"astc-4x4-unorm-srgb":{f:Py},"astc-5x4-unorm":{f:Py},"astc-5x4-unorm-srgb":{f:Py},"astc-5x5-unorm":{f:Py},"astc-5x5-unorm-srgb":{f:Py},"astc-6x5-unorm":{f:Py},"astc-6x5-unorm-srgb":{f:Py},"astc-6x6-unorm":{f:Py},"astc-6x6-unorm-srgb":{f:Py},"astc-8x5-unorm":{f:Py},"astc-8x5-unorm-srgb":{f:Py},"astc-8x6-unorm":{f:Py},"astc-8x6-unorm-srgb":{f:Py},"astc-8x8-unorm":{f:Py},"astc-8x8-unorm-srgb":{f:Py},"astc-10x5-unorm":{f:Py},"astc-10x5-unorm-srgb":{f:Py},"astc-10x6-unorm":{f:Py},"astc-10x6-unorm-srgb":{f:Py},"astc-10x8-unorm":{f:Py},"astc-10x8-unorm-srgb":{f:Py},"astc-10x10-unorm":{f:Py},"astc-10x10-unorm-srgb":{f:Py},"astc-12x10-unorm":{f:Py},"astc-12x10-unorm-srgb":{f:Py},"astc-12x12-unorm":{f:Py},"astc-12x12-unorm-srgb":{f:Py},"pvrtc-rgb4unorm-webgl":{f:Ly},"pvrtc-rgba4unorm-webgl":{f:Ly},"pvrtc-rgb2unorm-webgl":{f:Ly},"pvrtc-rgba2unorm-webgl":{f:Ly},"etc1-rbg-unorm-webgl":{f:Iy},"atc-rgb-unorm-webgl":{f:Ry},"atc-rgba-unorm-webgl":{f:Ry},"atc-rgbai-unorm-webgl":{f:Ry}},Qy={...Xy,...Zy},$y=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,eb=[`rgb`,`rgba`,`bgra`],tb=[`depth`,`stencil`],nb=[`bc1`,`bc2`,`bc3`,`bc4`,`bc5`,`bc6`,`bc7`,`etc1`,`etc2`,`eac`,`atc`,`astc`,`pvrtc`],rb=new class{isColor(e){return eb.some(t=>e.startsWith(t))}isDepthStencil(e){return tb.some(t=>e.startsWith(t))}isCompressed(e){return nb.some(t=>e.startsWith(t))}getInfo(e){return ob(e)}getCapabilities(e){return ab(e)}computeMemoryLayout(e){return ib(e)}};function ib({format:e,width:t,height:n,depth:r,byteAlignment:i}){let{bytesPerPixel:a,bytesPerBlock:o=a,blockWidth:s=1,blockHeight:c=1,compressed:l=!1}=rb.getInfo(e),u=l?Math.ceil(t/s):t,d=l?Math.ceil(n/c):n,f=u*o,p=Math.ceil(f/i)*i,m=d,h=p*m*r;return{bytesPerPixel:a,bytesPerRow:p,rowsPerImage:m,depthOrArrayLayers:r,bytesPerImage:p*m,byteLength:h}}function ab(e){let t=Jy(e),n={format:e,create:t.f??!0,render:t.render??!0,filter:t.filter??!0,blend:t.blend??!0,store:t.store??!0},r=ob(e),i=e.startsWith(`depth`)||e.startsWith(`stencil`),a=r?.signed,o=r?.integer,s=r?.webgl,c=!!r?.compressed;return n.render&&=!i&&!c,n.filter&&=!i&&!a&&!o&&!s,n}function ob(e){let t=sb(e);if(rb.isCompressed(e)){t.channels=`rgb`,t.components=3,t.bytesPerPixel=1,t.srgb=!1,t.compressed=!0,t.bytesPerBlock=lb(e);let n=cb(e);n&&(t.blockWidth=n.blockWidth,t.blockHeight=n.blockHeight)}let n=t.packed?null:$y.exec(e);if(n){let[,r,i,a,o,s]=n,c=`${a}${i}`,l=Ay.getDataTypeInfo(c),u=l.byteLength*8,d=r?.length??1,f=[u,d>=2?u:0,d>=3?u:0,d>=4?u:0];t={format:e,attachment:t.attachment,dataType:l.signedType,components:d,channels:r,integer:l.integer,signed:l.signed,normalized:l.normalized,bitsPerChannel:f,bytesPerPixel:l.byteLength*d,packed:t.packed,srgb:t.srgb},s===`-webgl`&&(t.webgl=!0),o===`-srgb`&&(t.srgb=!0)}return e.endsWith(`-webgl`)&&(t.webgl=!0),e.endsWith(`-srgb`)&&(t.srgb=!0),t}function sb(e){let t=Jy(e),n=t.bytesPerPixel||1,r=t.bitsPerChannel||[8,8,8,8];return delete t.bitsPerChannel,delete t.bytesPerPixel,delete t.f,delete t.render,delete t.filter,delete t.blend,delete t.store,{...t,format:e,attachment:t.attachment||`color`,channels:t.channels||`r`,components:t.components||t.channels?.length||1,bytesPerPixel:n,bitsPerChannel:r,dataType:t.dataType||`uint8`,srgb:t.srgb??!1,packed:t.packed??!1,webgl:t.webgl??!1,integer:t.integer??!1,signed:t.signed??!1,normalized:t.normalized??!1,compressed:t.compressed??!1}}function cb(e){let t=/.*-(\d+)x(\d+)-.*/.exec(e);if(t){let[,e,n]=t;return{blockWidth:Number(e),blockHeight:Number(n)}}return e.startsWith(`bc`)||e.startsWith(`etc1`)||e.startsWith(`etc2`)||e.startsWith(`eac`)||e.startsWith(`atc`)||e.startsWith(`pvrtc-rgb4`)||e.startsWith(`pvrtc-rgba4`)?{blockWidth:4,blockHeight:4}:e.startsWith(`pvrtc-rgb2`)||e.startsWith(`pvrtc-rgba2`)?{blockWidth:8,blockHeight:4}:null}function lb(e){return e.startsWith(`bc1`)||e.startsWith(`bc4`)||e.startsWith(`etc1`)||e.startsWith(`etc2-rgb8`)||e.startsWith(`etc2-rgb8a1`)||e.startsWith(`eac-r11`)||e===`atc-rgb-unorm-webgl`?8:e.startsWith(`bc2`)||e.startsWith(`bc3`)||e.startsWith(`bc5`)||e.startsWith(`bc6h`)||e.startsWith(`bc7`)||e.startsWith(`etc2-rgba8`)||e.startsWith(`eac-rg11`)||e.startsWith(`astc`)||e===`atc-rgba-unorm-webgl`||e===`atc-rgbai-unorm-webgl`?16:e.startsWith(`pvrtc`)?8:16}function ub(e){return typeof ImageData<`u`&&e instanceof ImageData||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLVideoElement<`u`&&e instanceof HTMLVideoElement||typeof VideoFrame<`u`&&e instanceof VideoFrame||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas}function db(e){if(typeof ImageData<`u`&&e instanceof ImageData||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas)return{width:e.width,height:e.height};if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement)return{width:e.naturalWidth,height:e.naturalHeight};if(typeof HTMLVideoElement<`u`&&e instanceof HTMLVideoElement)return{width:e.videoWidth,height:e.videoHeight};if(typeof VideoFrame<`u`&&e instanceof VideoFrame)return{width:e.displayWidth,height:e.displayHeight};throw Error(`Unknown image type`)}var fb=class{};function pb(e,t){return[mb(e),...t.map(mb).filter(e=>e!==void 0)].filter(e=>e!==void 0)}function mb(e){if(e!==void 0){if(e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e;if(e instanceof Error)return e.message;if(Array.isArray(e))return e.map(mb);if(typeof e==`object`){if(hb(e)){let t=String(e);if(t!==`[object Object]`)return t}return gb(e)?_b(e):e.constructor?.name||`Object`}return String(e)}}function hb(e){return`toString`in e&&typeof e.toString==`function`&&e.toString!==Object.prototype.toString}function gb(e){return`message`in e&&`type`in e}function _b(e){let t=typeof e.type==`string`?e.type:`message`,n=typeof e.message==`string`?e.message:``,r=typeof e.lineNum==`number`?e.lineNum:null,i=typeof e.linePos==`number`?e.linePos:null;return`${t}${r!==null&&i!==null?` @ ${r}:${i}`:r===null?``:` @ ${r}`}: ${n}`.trim()}var vb=class{features;disabledFeatures;constructor(e=[],t){this.features=new Set(e),this.disabledFeatures=t||{}}*[Symbol.iterator](){yield*this.features}has(e){return!this.disabledFeatures?.[e]&&this.features.has(e)}},yb=class e{static defaultProps={id:null,powerPreference:`high-performance`,failIfMajorPerformanceCaveat:!1,createCanvasContext:void 0,webgl:{},onError:(e,t)=>{},onResize:(e,t)=>{let[n,r]=e.getDevicePixelSize();Z.log(1,`${e} resized => ${n}x${r}px`)()},onPositionChange:(e,t)=>{let[n,r]=e.getPosition();Z.log(1,`${e} repositioned => ${n},${r}`)()},onVisibilityChange:e=>Z.log(1,`${e} Visibility changed ${e.isVisible}`)(),onDevicePixelRatioChange:(e,t)=>Z.log(1,`${e} DPR changed ${t.oldRatio} => ${e.devicePixelRatio}`)(),debug:xb(),debugGPUTime:!1,debugShaders:Z.get(`debug-shaders`)||void 0,debugFramebuffers:!!Z.get(`debug-framebuffers`),debugFactories:!!Z.get(`debug-factories`),debugWebGL:!!Z.get(`debug-webgl`),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_requestMaxLimits:!0,_cacheShaders:!0,_destroyShaders:!1,_cachePipelines:!0,_sharePipelines:!0,_destroyPipelines:!1,_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0};get[Symbol.toStringTag](){return`Device`}toString(){return`Device(${this.id})`}id;props;userData={};statsManager=sy;_factories={};timestamp=0;_reused=!1;_moduleData={};_textureCaps={};_debugGPUTimeQuery=null;constructor(t){this.props={...e.defaultProps,...t},this.id=this.props.id||uy(this[Symbol.toStringTag].toLowerCase())}getVertexFormatInfo(e){return My.getVertexFormatInfo(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return rb.getInfo(e)}getTextureFormatCapabilities(e){let t=this._textureCaps[e];if(!t){let n=this._getDeviceTextureFormatCapabilities(e);t=this._getDeviceSpecificTextureFormatCapabilities(n),this._textureCaps[e]=t}return t}getMipLevelCount(e,t,n=1){return 1+Math.floor(Math.log2(Math.max(e,t,n)))}isExternalImage(e){return ub(e)}getExternalImageSize(e){return db(e)}isTextureFormatSupported(e){return this.getTextureFormatCapabilities(e).create}isTextureFormatFilterable(e){return this.getTextureFormatCapabilities(e).filter}isTextureFormatRenderable(e){return this.getTextureFormatCapabilities(e).render}isTextureFormatCompressed(e){return rb.isCompressed(e)}getSupportedCompressedTextureFormats(){let e=[];for(let t of Object.keys(Yy()))this.isTextureFormatCompressed(t)&&this.isTextureFormatSupported(t)&&e.push(t);return e}pushDebugGroup(e){this.commandEncoder.pushDebugGroup(e)}popDebugGroup(){this.commandEncoder?.popDebugGroup()}insertDebugMarker(e){this.commandEncoder?.insertDebugMarker(e)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(e,t,...n){if(!this.props.onError(e,t)){let r=pb(t,n);return Z.error(this.type===`webgl`?`%cWebGL`:`%cWebGPU`,`color: white; background: red; padding: 2px 6px; border-radius: 3px;`,e.message,...r)}return()=>{}}debug(){if(this.props.debug)debugger;else Z.once(0,`'Type luma.log.set({debug: true}) in console to enable debug breakpoints',
|
|
1337
|
+
or create a device with the 'debug: true' prop.`)()}getDefaultCanvasContext(){if(!this.canvasContext)throw Error(`Device has no default CanvasContext. See props.createCanvasContext`);return this.canvasContext}createFence(){throw Error(`createFence() not implemented`)}beginRenderPass(e){return this.commandEncoder.beginRenderPass(e)}beginComputePass(e){return this.commandEncoder.beginComputePass(e)}generateMipmapsWebGPU(e){throw Error(`not implemented`)}_createSharedRenderPipelineWebGL(e){throw Error(`_createSharedRenderPipelineWebGL() not implemented`)}_createBindGroupLayoutWebGPU(e,t){throw Error(`_createBindGroupLayoutWebGPU() not implemented`)}_createBindGroupWebGPU(e,t,n,r,i){throw Error(`_createBindGroupWebGPU() not implemented`)}_supportsDebugGPUTime(){return this.features.has(`timestamp-query`)&&!!(this.props.debug||this.props.debugGPUTime)}_enableDebugGPUTime(e=256){if(!this._supportsDebugGPUTime())return null;if(this._debugGPUTimeQuery)return this._debugGPUTimeQuery;try{this._debugGPUTimeQuery=this.createQuerySet({type:`timestamp`,count:e}),this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id,timeProfilingQuerySet:this._debugGPUTimeQuery})}catch{this._debugGPUTimeQuery=null}return this._debugGPUTimeQuery}_disableDebugGPUTime(){this._debugGPUTimeQuery&&=(this.commandEncoder.getTimeProfilingQuerySet()===this._debugGPUTimeQuery&&(this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id})),this._debugGPUTimeQuery.destroy(),null)}_isDebugGPUTimeEnabled(){return this._debugGPUTimeQuery!==null}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,t){throw Error(`not implemented`)}readPixelsToBufferWebGL(e,t){throw Error(`not implemented`)}setParametersWebGL(e){throw Error(`not implemented`)}getParametersWebGL(e){throw Error(`not implemented`)}withParametersWebGL(e,t){throw Error(`not implemented`)}clearWebGL(e){throw Error(`not implemented`)}resetWebGL(){throw Error(`not implemented`)}getModuleData(e){return this._moduleData[e]||={},this._moduleData[e]}static _getCanvasContextProps(e){return e.createCanvasContext===!0?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){let t=rb.getCapabilities(e),n=e=>(typeof e==`string`?this.features.has(e):e)??!0,r=n(t.create);return{format:e,create:r,render:r&&n(t.render),filter:r&&n(t.filter),blend:r&&n(t.blend),store:r&&n(t.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let t={...e};if((e.usage||0)&ky.INDEX&&(e.indexType||(e.data instanceof Uint32Array?t.indexType=`uint32`:e.data instanceof Uint16Array?t.indexType=`uint16`:e.data instanceof Uint8Array&&(t.data=new Uint16Array(e.data),t.indexType=`uint16`)),!t.indexType))throw Error(`indices buffer content must be of type uint16 or uint32`);return t}};function bb(e,t){return e==null?t===void 0?!1:t!==`production`:!!e}function xb(){return bb(Z.get(`debug`),Sb())}function Sb(){let e=globalThis.process;if(e?.env)return e.env.NODE_ENV}var Cb=`set luma.log.level=1 (or higher) to trace rendering`,wb="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",Tb=new class e{static defaultProps={...yb.defaultProps,type:`best-available`,adapters:void 0,waitForPageLoad:!0};stats=sy;log=Z;VERSION=`9.3.3`;spector;preregisteredAdapters=new Map;constructor(){if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw Z.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),Z.error(`'yarn why @luma.gl/core' can help identify the source of the conflict`)(),Error(`luma.gl - multiple versions detected: see console log`);Z.error(`This version of luma.gl has already been initialized`)()}Z.log(1,`${this.VERSION} - ${Cb}`)(),globalThis.luma=this}async createDevice(t={}){let n={...e.defaultProps,...t},r=this.selectAdapter(n.type,n.adapters);if(!r)throw Error(wb);return n.waitForPageLoad&&await r.pageLoaded,await r.create(n)}async attachDevice(e,t){let n=this._getTypeFromHandle(e,t.adapters),r=n&&this.selectAdapter(n,t.adapters);if(!r)throw Error(wb);return await r?.attach?.(e,t)}registerAdapters(e){for(let t of e)this.preregisteredAdapters.set(t.type,t)}getSupportedAdapters(e=[]){let t=this._getAdapterMap(e);return Array.from(t).map(([,e])=>e).filter(e=>e.isSupported?.()).map(e=>e.type)}getBestAvailableAdapterType(e=[]){let t=[`webgpu`,`webgl`,`null`],n=this._getAdapterMap(e);for(let e of t)if(n.get(e)?.isSupported?.())return e;return null}selectAdapter(e,t=[]){let n=e;e===`best-available`&&(n=this.getBestAvailableAdapterType(t));let r=this._getAdapterMap(t);return n&&r.get(n)||null}enforceWebGL2(e=!0,t=[]){let n=this._getAdapterMap(t).get(`webgl`);n||Z.warn(`enforceWebGL2: webgl adapter not found`)(),n?.enforceWebGL2?.(e)}setDefaultDeviceProps(t){Object.assign(e.defaultProps,t)}_getAdapterMap(e=[]){let t=new Map(this.preregisteredAdapters);for(let n of e)t.set(n.type,n);return t}_getTypeFromHandle(e,t=[]){return e instanceof WebGL2RenderingContext?`webgl`:typeof GPUDevice<`u`&&e instanceof GPUDevice||e?.queue?`webgpu`:e===null?`null`:(e instanceof WebGLRenderingContext?Z.warn(`WebGL1 is not supported`,e)():Z.warn(`Unknown handle type`,e)(),null)}},Eb=class{get pageLoaded(){return Ab()}},Db=fd()&&typeof document<`u`,Ob=()=>Db&&document.readyState===`complete`,kb=null;function Ab(){return kb||=Ob()||typeof window>`u`?Promise.resolve():new Promise(e=>window.addEventListener(`load`,()=>e())),kb}var jb=class{props;_resizeObserver;_intersectionObserver;_observeDevicePixelRatioTimeout=null;_observeDevicePixelRatioMediaQuery=null;_handleDevicePixelRatioChange=()=>this._refreshDevicePixelRatio();_trackPositionInterval=null;_started=!1;get started(){return this._started}constructor(e){this.props=e}start(){if(!(this._started||!this.props.canvas)){this._started=!0,this._intersectionObserver||=new IntersectionObserver(e=>this.props.onIntersection(e)),this._resizeObserver||=new ResizeObserver(e=>this.props.onResize(e)),this._intersectionObserver.observe(this.props.canvas);try{this._resizeObserver.observe(this.props.canvas,{box:`device-pixel-content-box`})}catch{this._resizeObserver.observe(this.props.canvas,{box:`content-box`})}this._observeDevicePixelRatioTimeout=setTimeout(()=>this._refreshDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}}stop(){this._started&&(this._started=!1,this._observeDevicePixelRatioTimeout&&=(clearTimeout(this._observeDevicePixelRatioTimeout),null),this._observeDevicePixelRatioMediaQuery&&=(this._observeDevicePixelRatioMediaQuery.removeEventListener(`change`,this._handleDevicePixelRatioChange),null),this._trackPositionInterval&&=(clearInterval(this._trackPositionInterval),null),this._resizeObserver?.disconnect(),this._intersectionObserver?.disconnect())}_refreshDevicePixelRatio(){this._started&&(this.props.onDevicePixelRatioChange(),this._observeDevicePixelRatioMediaQuery?.removeEventListener(`change`,this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this._observeDevicePixelRatioMediaQuery.addEventListener(`change`,this._handleDevicePixelRatioChange,{once:!0}))}_trackPosition(e=100){this._trackPositionInterval||=setInterval(()=>{this._started?this.props.onPositionChange():this._trackPositionInterval&&=(clearInterval(this._trackPositionInterval),null)},e)}};function Mb(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function Nb(e,t){if(!e){let e=Error(t??`luma.gl assertion failed.`);throw Error.captureStackTrace?.(e,Nb),e}}function Pb(e,t){return Nb(e,t),e}var Fb=class e{static isHTMLCanvas(e){return typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement}static isOffscreenCanvas(e){return typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas}static defaultProps={id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,alphaMode:`opaque`,colorSpace:`srgb`,trackPosition:!1};id;props;canvas;htmlCanvas;offscreenCanvas;type;initialized;isInitialized=!1;isVisible=!0;cssWidth;cssHeight;devicePixelRatio;devicePixelWidth;devicePixelHeight;drawingBufferWidth;drawingBufferHeight;_initializedResolvers=Mb();_canvasObserver;_position=[0,0];destroyed=!1;_needsDrawingBufferResize=!0;toString(){return`${this[Symbol.toStringTag]}(${this.id})`}constructor(t){this.props={...e.defaultProps,...t},t=this.props,this.initialized=this._initializedResolvers.promise,fd()?t.canvas?typeof t.canvas==`string`?this.canvas=Lb(t.canvas):this.canvas=t.canvas:this.canvas=Rb(t):this.canvas={width:t.width||1,height:t.height||1},e.isHTMLCanvas(this.canvas)?(this.id=t.id||this.canvas.id,this.type=`html-canvas`,this.htmlCanvas=this.canvas):e.isOffscreenCanvas(this.canvas)?(this.id=t.id||`offscreen-canvas`,this.type=`offscreen-canvas`,this.offscreenCanvas=this.canvas):(this.id=t.id||`node-canvas-context`,this.type=`node`),this.cssWidth=this.htmlCanvas?.clientWidth||this.canvas.width,this.cssHeight=this.htmlCanvas?.clientHeight||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],this._canvasObserver=new jb({canvas:this.htmlCanvas,trackPosition:this.props.trackPosition,onResize:e=>this._handleResize(e),onIntersection:e=>this._handleIntersection(e),onDevicePixelRatioChange:()=>this._observeDevicePixelRatio(),onPositionChange:()=>this.updatePosition()})}destroy(){this.destroyed||(this.destroyed=!0,this._stopObservers(),this.device=null)}setProps(e){return`useDevicePixels`in e&&(this.props.useDevicePixels=e.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCurrentFramebuffer(e){return this._resizeDrawingBufferIfNeeded(),this._getCurrentFramebuffer(e)}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){let e=this.device.limits.maxTextureDimension2D;return[e,e]}setDrawingBufferSize(e,t){e=Math.floor(e),t=Math.floor(t),!(this.drawingBufferWidth===e&&this.drawingBufferHeight===t)&&(this.drawingBufferWidth=e,this.drawingBufferHeight=t,this._needsDrawingBufferResize=!0)}getDevicePixelRatio(){return typeof window<`u`&&window.devicePixelRatio||1}cssToDevicePixels(e,t=!0){let n=this.cssToDeviceRatio(),[r,i]=this.getDrawingBufferSize();return zb(e,n,r,i,t)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){let[e,t]=this.getDrawingBufferSize();return e>0&&t>0?e/t:1}cssToDeviceRatio(){try{let[e]=this.getDrawingBufferSize(),[t]=this.getCSSSize();return t?e/t:1}catch{return 1}}resize(e){this.setDrawingBufferSize(e.width,e.height)}_setAutoCreatedCanvasId(e){this.htmlCanvas?.id===`lumagl-auto-created-canvas`&&(this.htmlCanvas.id=e)}_startObservers(){this.destroyed||this._canvasObserver.start()}_stopObservers(){this._canvasObserver.stop()}_handleIntersection(e){if(this.destroyed)return;let t=e.find(e=>e.target===this.canvas);if(!t)return;let n=t.isIntersecting;this.isVisible!==n&&(this.isVisible=n,this.device.props.onVisibilityChange(this))}_handleResize(e){if(this.destroyed)return;let t=e.find(e=>e.target===this.canvas);if(!t)return;let n=Pb(t.contentBoxSize?.[0]);this.cssWidth=n.inlineSize,this.cssHeight=n.blockSize;let r=this.getDevicePixelSize(),i=t.devicePixelContentBoxSize?.[0]?.inlineSize||n.inlineSize*devicePixelRatio,a=t.devicePixelContentBoxSize?.[0]?.blockSize||n.blockSize*devicePixelRatio,[o,s]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(i,o)),this.devicePixelHeight=Math.max(1,Math.min(a,s)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:r})}_updateDrawingBufferSize(){if(this.props.autoResize)if(typeof this.props.useDevicePixels==`number`){let e=this.props.useDevicePixels;this.setDrawingBufferSize(this.cssWidth*e,this.cssHeight*e)}else this.props.useDevicePixels?this.setDrawingBufferSize(this.devicePixelWidth,this.devicePixelHeight):this.setDrawingBufferSize(this.cssWidth,this.cssHeight);this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_resizeDrawingBufferIfNeeded(){this._needsDrawingBufferResize&&(this._needsDrawingBufferResize=!1,(this.drawingBufferWidth!==this.canvas.width||this.drawingBufferHeight!==this.canvas.height)&&(this.canvas.width=this.drawingBufferWidth,this.canvas.height=this.drawingBufferHeight,this._configureDevice()))}_observeDevicePixelRatio(){if(this.destroyed||!this._canvasObserver.started)return;let e=this.devicePixelRatio;this.devicePixelRatio=window.devicePixelRatio,this.updatePosition(),this.device.props.onDevicePixelRatioChange?.(this,{oldRatio:e})}updatePosition(){if(this.destroyed)return;let e=this.htmlCanvas?.getBoundingClientRect();if(e){let t=[e.left,e.top];if(this._position??=t,t[0]!==this._position[0]||t[1]!==this._position[1]){let e=this._position;this._position=t,this.device.props.onPositionChange?.(this,{oldPosition:e})}}}};function Ib(e){if(typeof e==`string`){let t=document.getElementById(e);if(!t)throw Error(`${e} is not an HTML element`);return t}return e||document.body}function Lb(e){let t=document.getElementById(e);if(!Fb.isHTMLCanvas(t))throw Error(`Object is not a canvas element`);return t}function Rb(e){let{width:t,height:n}=e,r=document.createElement(`canvas`);r.id=uy(`lumagl-auto-created-canvas`),r.width=t||1,r.height=n||1,r.style.width=Number.isFinite(t)?`${t}px`:`100%`,r.style.height=Number.isFinite(n)?`${n}px`:`100%`,e?.visible||(r.style.visibility=`hidden`);let i=Ib(e?.container||null);return i.insertBefore(r,i.firstChild),r}function zb(e,t,n,r,i){let a=e,o=Bb(a[0],t,n),s=Vb(a[1],t,r,i),c=Bb(a[0]+1,t,n),l=c===n-1?c:c-1;c=Vb(a[1]+1,t,r,i);let u;return i?(c=c===0?c:c+1,u=s,s=c):u=c===r-1?c:c-1,{x:o,y:s,width:Math.max(l-o+1,1),height:Math.max(u-s+1,1)}}function Bb(e,t,n){return Math.min(Math.round(e*t),n-1)}function Vb(e,t,n,r){return r?Math.max(0,n-1-Math.round(e*t)):Math.min(Math.round(e*t),n-1)}var Hb=class extends Fb{static defaultProps=Fb.defaultProps},Ub=class extends Fb{},Wb=class e extends Q{static defaultProps={...Q.defaultProps,type:`color-sampler`,addressModeU:`clamp-to-edge`,addressModeV:`clamp-to-edge`,addressModeW:`clamp-to-edge`,magFilter:`nearest`,minFilter:`nearest`,mipmapFilter:`none`,lodMinClamp:0,lodMaxClamp:32,compare:`less-equal`,maxAnisotropy:1};get[Symbol.toStringTag](){return`Sampler`}constructor(t,n){n=e.normalizeProps(t,n),super(t,n,e.defaultProps)}static normalizeProps(e,t){return t}},Gb={"1d":`1d`,"2d":`2d`,"2d-array":`2d`,cube:`2d`,"cube-array":`2d`,"3d":`3d`},Kb=class e extends Q{static SAMPLE=4;static STORAGE=8;static RENDER=16;static COPY_SRC=1;static COPY_DST=2;static TEXTURE=4;static RENDER_ATTACHMENT=16;dimension;baseDimension;format;width;height;depth;mipLevels;samples;byteAlignment;ready=Promise.resolve(this);isReady=!0;updateTimestamp;get[Symbol.toStringTag](){return`Texture`}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}constructor(t,n,r){if(n=e.normalizeProps(t,n),super(t,n,e.defaultProps),this.dimension=this.props.dimension,this.baseDimension=Gb[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,this.samples=this.props.samples||1,this.dimension===`cube`&&(this.depth=6),this.props.width===void 0||this.props.height===void 0)if(t.isExternalImage(n.data)){let e=t.getExternalImageSize(n.data);this.width=e?.width||1,this.height=e?.height||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&Z.warn(`${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`)();this.byteAlignment=r?.byteAlignment||1,this.updateTimestamp=t.incrementTimestamp()}clone(e){return this.device.createTexture({...this.props,...e})}setSampler(e){this.sampler=e instanceof Wb?e:this.device.createSampler(e)}copyImageData(e){let{data:t,depth:n,...r}=e;this.writeData(t,{...r,depthOrArrayLayers:r.depthOrArrayLayers??n})}computeMemoryLayout(e={}){let{width:t=this.width,height:n=this.height,depthOrArrayLayers:r=this.depth}=this._normalizeTextureReadOptions(e),{format:i,byteAlignment:a}=this;return rb.computeMemoryLayout({format:i,width:t,height:n,depth:r,byteAlignment:a})}readBuffer(e,t){throw Error(`readBuffer not implemented`)}readDataAsync(e){throw Error(`readBuffer not implemented`)}writeBuffer(e,t){throw Error(`readBuffer not implemented`)}writeData(e,t){throw Error(`readBuffer not implemented`)}readDataSyncWebGL(e){throw Error(`readDataSyncWebGL not available`)}generateMipmapsWebGL(){throw Error(`generateMipmapsWebGL not available`)}static normalizeProps(e,t){let n={...t},{width:r,height:i}=n;return typeof r==`number`&&(n.width=Math.max(1,Math.ceil(r))),typeof i==`number`&&(n.height=Math.max(1,Math.ceil(i))),n}_initializeData(e){this.device.isExternalImage(e)?this.copyExternalImage({image:e,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:`all`,colorSpace:`srgb`,premultipliedAlpha:!1,flipY:!1}):e&&this.copyImageData({data:e,mipLevel:0,x:0,y:0,z:0,aspect:`all`})}_normalizeCopyImageDataOptions(e){let{data:t,depth:n,...r}=e,i=this._normalizeTextureWriteOptions({...r,depthOrArrayLayers:r.depthOrArrayLayers??n});return{data:t,depth:i.depthOrArrayLayers,...i}}_normalizeCopyExternalImageOptions(t){let n=e._omitUndefined(t),r=n.mipLevel??0,i=this._getMipLevelSize(r),a=this.device.getExternalImageSize(t.image),o={...e.defaultCopyExternalImageOptions,...i,...a,...n};return o.width=Math.min(o.width,i.width-o.x),o.height=Math.min(o.height,i.height-o.y),o.depth=Math.min(o.depth,i.depthOrArrayLayers-o.z),o}_normalizeTextureReadOptions(t){let n=e._omitUndefined(t),r=n.mipLevel??0,i=this._getMipLevelSize(r),a={...e.defaultTextureReadOptions,...i,...n};return a.width=Math.min(a.width,i.width-a.x),a.height=Math.min(a.height,i.height-a.y),a.depthOrArrayLayers=Math.min(a.depthOrArrayLayers,i.depthOrArrayLayers-a.z),a}_getSupportedColorReadOptions(e){let t=this._normalizeTextureReadOptions(e),n=rb.getInfo(this.format);switch(this._validateColorReadAspect(t),this._validateColorReadFormat(n),this.dimension){case`2d`:case`cube`:case`cube-array`:case`2d-array`:case`3d`:return t;default:throw Error(`${this} color readback does not support ${this.dimension} textures`)}}_validateColorReadAspect(e){if(e.aspect!==`all`)throw Error(`${this} color readback only supports aspect 'all'`)}_validateColorReadFormat(e){if(e.compressed)throw Error(`${this} color readback does not support compressed formats (${this.format})`);switch(e.attachment){case`color`:return;case`depth`:throw Error(`${this} color readback does not support depth formats (${this.format})`);case`stencil`:throw Error(`${this} color readback does not support stencil formats (${this.format})`);case`depth-stencil`:throw Error(`${this} color readback does not support depth-stencil formats (${this.format})`);default:throw Error(`${this} color readback does not support format ${this.format}`)}}_normalizeTextureWriteOptions(t){let n=e._omitUndefined(t),r=n.mipLevel??0,i=this._getMipLevelSize(r),a={...e.defaultTextureWriteOptions,...i,...n};a.width=Math.min(a.width,i.width-a.x),a.height=Math.min(a.height,i.height-a.y),a.depthOrArrayLayers=Math.min(a.depthOrArrayLayers,i.depthOrArrayLayers-a.z);let o=rb.computeMemoryLayout({format:this.format,width:a.width,height:a.height,depth:a.depthOrArrayLayers,byteAlignment:this.byteAlignment}),s=o.bytesPerPixel*a.width;if(a.bytesPerRow=n.bytesPerRow??o.bytesPerRow,a.rowsPerImage=n.rowsPerImage??a.height,a.bytesPerRow<s)throw Error(`bytesPerRow (${a.bytesPerRow}) must be at least ${s} for ${this.format}`);if(a.rowsPerImage<a.height)throw Error(`rowsPerImage (${a.rowsPerImage}) must be at least ${a.height} for ${this.format}`);let c=this.device.getTextureFormatInfo(this.format).bytesPerPixel;if(c&&a.bytesPerRow%c!==0)throw Error(`bytesPerRow (${a.bytesPerRow}) must be a multiple of bytesPerPixel (${c}) for ${this.format}`);return a}_getMipLevelSize(e){return{width:Math.max(1,this.width>>e),height:this.baseDimension===`1d`?1:Math.max(1,this.height>>e),depthOrArrayLayers:this.dimension===`3d`?Math.max(1,this.depth>>e):this.depth}}getAllocatedByteLength(){let e=0;for(let t=0;t<this.mipLevels;t++){let{width:n,height:r,depthOrArrayLayers:i}=this._getMipLevelSize(t);e+=rb.computeMemoryLayout({format:this.format,width:n,height:r,depth:i,byteAlignment:1}).byteLength}return e*this.samples}static _omitUndefined(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}static defaultProps={...Q.defaultProps,data:null,dimension:`2d`,format:`rgba8unorm`,usage:e.SAMPLE|e.RENDER|e.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0};static defaultCopyDataOptions={data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,width:void 0,height:void 0,depthOrArrayLayers:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:`all`};static defaultCopyExternalImageOptions={image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:`all`,colorSpace:`srgb`,premultipliedAlpha:!1,flipY:!1};static defaultTextureReadOptions={x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:`all`};static defaultTextureWriteOptions={byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:`all`}},qb=class e extends Q{get[Symbol.toStringTag](){return`TextureView`}constructor(t,n){super(t,n,e.defaultProps)}static defaultProps={...Q.defaultProps,format:void 0,dimension:void 0,aspect:`all`,baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0}};function Jb(e,t,n){let r=``,i=t.split(/\r?\n/),a=e.slice().sort((e,t)=>e.lineNum-t.lineNum);switch(n?.showSourceCode||`no`){case`all`:let t=0;for(let e=1;e<=i.length;e++){let o=i[e-1],s=a[t];for(o&&s&&(r+=Zb(o,e,n));a.length>t&&s.lineNum===e;){let e=a[t++];e&&(r+=Yb(e,i,e.lineNum,{...n,inlineSource:!1}))}}for(;a.length>t;){let e=a[t++];e&&(r+=Yb(e,[],0,{...n,inlineSource:!1}))}return r;case`issues`:case`no`:for(let t of e)r+=Yb(t,i,t.lineNum,{inlineSource:n?.showSourceCode!==`no`});return r}}function Yb(e,t,n,r){if(r?.inlineSource)return`
|
|
1338
|
+
${Xb(t,n)}${e.linePos>0?`${` `.repeat(e.linePos+5)}^^^\n`:``}${e.type.toUpperCase()}: ${e.message}
|
|
1339
1339
|
|
|
1340
|
-
`;let i=e.type===`error`?`red`:`orange`;return r?.html?`<div class='luma-compiler-log-${e.type}' style="color:${i};"><b> ${e.type.toUpperCase()}: ${e.message}</b></div>`:`${e.type.toUpperCase()}: ${e.message}`}function
|
|
1341
|
-
`}`}function
|
|
1340
|
+
`;let i=e.type===`error`?`red`:`orange`;return r?.html?`<div class='luma-compiler-log-${e.type}' style="color:${i};"><b> ${e.type.toUpperCase()}: ${e.message}</b></div>`:`${e.type.toUpperCase()}: ${e.message}`}function Xb(e,t,n){let r=``;for(let i=t-2;i<=t;i++){let a=e[i-1];a!==void 0&&(r+=Zb(a,t,n))}return r}function Zb(e,t,n){let r=n?.html?$b(e):e;return`${Qb(String(t),4)}: ${r}${n?.html?`<br/>`:`
|
|
1341
|
+
`}`}function Qb(e,t){let n=``;for(let r=e.length;r<t;++r)n+=` `;return n+e}function $b(e){return e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`).replaceAll(`"`,`"`).replaceAll(`'`,`'`)}var ex=class e extends Q{get[Symbol.toStringTag](){return`Shader`}stage;source;compilationStatus=`pending`;constructor(t,n){n={...n,debugShaders:n.debugShaders||t.props.debugShaders||`errors`},super(t,{id:tx(n),...n},e.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(){let e=this.props.debugShaders;switch(e){case`never`:return;case`errors`:if(this.compilationStatus===`success`)return;break;case`warnings`:case`always`:break}let t=await this.getCompilationInfo();e===`warnings`&&t?.length===0||this._displayShaderLog(t,this.id)}_displayShaderLog(e,t){if(typeof document>`u`||!document?.createElement)return;let n=t,r=`${this.stage} shader "${n}"`,i=Jb(e,this.source,{showSourceCode:`all`,html:!0}),a=this.getTranslatedSource(),o=document.createElement(`div`);o.innerHTML=`\
|
|
1342
1342
|
<h1>Compilation error in ${r}</h1>
|
|
1343
1343
|
<div style="display:flex;position:fixed;top:10px;right:20px;gap:2px;">
|
|
1344
1344
|
<button id="copy">Copy source</button><br/>
|
|
1345
1345
|
<button id="close">Close</button>
|
|
1346
1346
|
</div>
|
|
1347
|
-
<code><pre>${i}</pre></code>`,a&&(o.innerHTML+=`<br /><h1>Translated Source</h1><br /><br /><code><pre>${a}</pre></code>`),o.style.top=`0`,o.style.left=`0`,o.style.background=`white`,o.style.position=`fixed`,o.style.zIndex=`9999`,o.style.maxWidth=`100vw`,o.style.maxHeight=`100vh`,o.style.overflowY=`auto`,document.body.appendChild(o),o.querySelector(`.luma-compiler-log-error`)?.scrollIntoView(),o.querySelector(`button#close`).onclick=()=>{o.remove()},o.querySelector(`button#copy`).onclick=()=>{navigator.clipboard.writeText(this.source)}}static defaultProps={...Q.defaultProps,language:`auto`,stage:void 0,source:``,sourceMap:null,entryPoint:`main`,debugShaders:void 0}};function Jb(e){return Yb(e.source)||e.id||ry(`unnamed ${e.stage}-shader`)}function Yb(e,t=`unnamed`){return/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(e)?.[1]??t}var Xb=class e extends Q{get[Symbol.toStringTag](){return`Framebuffer`}width;height;constructor(t,n={}){super(t,n,e.defaultProps),this.width=this.props.width,this.height=this.props.height}clone(e){let t=this.colorAttachments.map(t=>t.texture.clone(e)),n=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(e);return this.device.createFramebuffer({...this.props,...e,colorAttachments:t,depthStencilAttachment:n})}resize(e){let t=!e;if(e){let[n,r]=Array.isArray(e)?e:[e.width,e.height];t=t||r!==this.height||n!==this.width,this.width=n,this.height=r}t&&(Z.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw Error(`Framebuffer has noattachments`);this.colorAttachments=this.props.colorAttachments.map((e,t)=>{if(typeof e==`string`){let n=this.createColorTexture(e,t);return this.attachResource(n),n.view}return e instanceof zb?e.view:e});let e=this.props.depthStencilAttachment;if(e)if(typeof e==`string`){let t=this.createDepthStencilTexture(e);this.attachResource(t),this.depthStencilAttachment=t.view}else e instanceof zb?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e,t){return this.device.createTexture({id:`${this.id}-color-attachment-${t}`,usage:zb.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height,sampler:{magFilter:`linear`,minFilter:`linear`}})}createDepthStencilTexture(e){return this.device.createTexture({id:`${this.id}-depth-stencil-attachment`,usage:zb.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,t){if(this.colorAttachments.forEach((n,r)=>{let i=n.texture.clone({width:e,height:t});this.destroyAttachedResource(n),this.colorAttachments[r]=i.view,this.attachResource(i.view)}),this.depthStencilAttachment){let n=this.depthStencilAttachment.texture.clone({width:e,height:t});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=n.view,this.attachResource(n)}this.updateAttachments()}static defaultProps={...Q.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null}},Zb=class e extends Q{get[Symbol.toStringTag](){return`RenderPipeline`}shaderLayout;bufferLayout;linkStatus=`pending`;hash=``;sharedRenderPipeline=null;get isPending(){return this.linkStatus===`pending`||this.vs.compilationStatus===`pending`||this.fs?.compilationStatus===`pending`}get isErrored(){return this.linkStatus===`error`||this.vs.compilationStatus===`error`||this.fs?.compilationStatus===`error`}constructor(t,n){super(t,n,e.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[],this.sharedRenderPipeline=this.props._sharedRenderPipeline||null}static defaultProps={...Q.defaultProps,vs:null,vertexEntryPoint:`vertexMain`,vsConstants:{},fs:null,fragmentEntryPoint:`fragmentMain`,fsConstants:{},shaderLayout:null,bufferLayout:[],topology:`triangle-list`,colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},varyings:void 0,bufferMode:void 0,disableWarnings:!1,_sharedRenderPipeline:void 0,bindings:void 0,bindGroups:void 0}},Qb=class extends Q{get[Symbol.toStringTag](){return`SharedRenderPipeline`}constructor(e,t){super(e,t,{...Q.defaultProps,handle:void 0,vs:void 0,fs:void 0,varyings:void 0,bufferMode:void 0})}},$b=class e extends Q{get[Symbol.toStringTag](){return`ComputePipeline`}hash=``;shaderLayout;constructor(t,n){super(t,n,e.defaultProps),this.shaderLayout=n.shaderLayout}static defaultProps={...Q.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0}},ex=class e{static defaultProps={...Zb.defaultProps};static getDefaultPipelineFactory(t){let n=t.getModuleData(`@luma.gl/core`);return n.defaultPipelineFactory||=new e(t),n.defaultPipelineFactory}device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};_sharedRenderPipelineCache={};get[Symbol.toStringTag](){return`PipelineFactory`}toString(){return`PipelineFactory(${this.device.id})`}constructor(e){this.device=e}createRenderPipeline(e){if(!this.device.props._cachePipelines)return this.device.createRenderPipeline(e);let t={...Zb.defaultProps,...e},n=this._renderPipelineCache,r=this._hashRenderPipeline(t),i=n[r]?.resource;if(i)n[r].useCount++,this.device.props.debugFactories&&Z.log(3,`${this}: ${n[r].resource} reused, count=${n[r].useCount}, (id=${e.id})`)();else{let e=this.device.type===`webgl`&&this.device.props._sharePipelines?this.createSharedRenderPipeline(t):void 0;i=this.device.createRenderPipeline({...t,id:t.id?`${t.id}-cached`:ry(`unnamed-cached`),_sharedRenderPipeline:e}),i.hash=r,n[r]={resource:i,useCount:1},this.device.props.debugFactories&&Z.log(3,`${this}: ${i} created, count=${n[r].useCount}`)()}return i}createComputePipeline(e){if(!this.device.props._cachePipelines)return this.device.createComputePipeline(e);let t={...$b.defaultProps,...e},n=this._computePipelineCache,r=this._hashComputePipeline(t),i=n[r]?.resource;return i?(n[r].useCount++,this.device.props.debugFactories&&Z.log(3,`${this}: ${n[r].resource} reused, count=${n[r].useCount}, (id=${e.id})`)()):(i=this.device.createComputePipeline({...t,id:t.id?`${t.id}-cached`:void 0}),i.hash=r,n[r]={resource:i,useCount:1},this.device.props.debugFactories&&Z.log(3,`${this}: ${i} created, count=${n[r].useCount}`)()),i}release(e){if(!this.device.props._cachePipelines){e.destroy();return}let t=this._getCache(e),n=e.hash;t[n].useCount--,t[n].useCount===0?(this._destroyPipeline(e),this.device.props.debugFactories&&Z.log(3,`${this}: ${e} released and destroyed`)()):t[n].useCount<0?(Z.error(`${this}: ${e} released, useCount < 0, resetting`)(),t[n].useCount=0):this.device.props.debugFactories&&Z.log(3,`${this}: ${e} released, count=${t[n].useCount}`)()}createSharedRenderPipeline(e){let t=this._hashSharedRenderPipeline(e),n=this._sharedRenderPipelineCache[t];return n||(n={resource:this.device._createSharedRenderPipelineWebGL(e),useCount:0},this._sharedRenderPipelineCache[t]=n),n.useCount++,n.resource}releaseSharedRenderPipeline(e){if(!e.sharedRenderPipeline)return;let t=this._hashSharedRenderPipeline(e.sharedRenderPipeline.props),n=this._sharedRenderPipelineCache[t];n&&(n.useCount--,n.useCount===0&&(n.resource.destroy(),delete this._sharedRenderPipelineCache[t]))}_destroyPipeline(e){let t=this._getCache(e);return this.device.props._destroyPipelines?(delete t[e.hash],e.destroy(),e instanceof Zb&&this.releaseSharedRenderPipeline(e),!0):!1}_getCache(e){let t;if(e instanceof $b&&(t=this._computePipelineCache),e instanceof Zb&&(t=this._renderPipelineCache),!t)throw Error(`${this}`);if(!t[e.hash])throw Error(`${this}: ${e} matched incorrect entry`);return t}_hashComputePipeline(e){let{type:t}=this.device;return`${t}/C/${this._getHash(e.shader.source)}SL${this._getHash(JSON.stringify(e.shaderLayout))}`}_hashRenderPipeline(e){let t=e.vs?this._getHash(e.vs.source):0,n=e.fs?this._getHash(e.fs.source):0,r=this._getWebGLVaryingHash(e),i=this._getHash(JSON.stringify(e.shaderLayout)),a=this._getHash(JSON.stringify(e.bufferLayout)),{type:o}=this.device;switch(o){case`webgl`:let s=this._getHash(JSON.stringify(e.parameters));return`${o}/R/${t}/${n}V${r}T${e.topology}P${s}SL${i}BL${a}`;default:let c=this._getHash(JSON.stringify({vertexEntryPoint:e.vertexEntryPoint,fragmentEntryPoint:e.fragmentEntryPoint})),l=this._getHash(JSON.stringify(e.parameters)),u=this._getWebGPUAttachmentHash(e);return`${o}/R/${t}/${n}V${r}T${e.topology}EP${c}P${l}SL${i}BL${a}A${u}`}}_hashSharedRenderPipeline(e){return`webgl/S/${e.vs?this._getHash(e.vs.source):0}/${e.fs?this._getHash(e.fs.source):0}V${this._getWebGLVaryingHash(e)}`}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}_getWebGLVaryingHash(e){let{varyings:t=[],bufferMode:n=null}=e;return this._getHash(JSON.stringify({varyings:t,bufferMode:n}))}_getWebGPUAttachmentHash(e){let t=e.colorAttachmentFormats??[this.device.preferredColorFormat],n=e.parameters?.depthWriteEnabled?e.depthStencilAttachmentFormat||this.device.preferredDepthFormat:null;return this._getHash(JSON.stringify({colorAttachmentFormats:t,depthStencilAttachmentFormat:n}))}},tx=class e{static defaultProps={...qb.defaultProps};static getDefaultShaderFactory(t){let n=t.getModuleData(`@luma.gl/core`);return n.defaultShaderFactory||=new e(t),n.defaultShaderFactory}device;_cache={};get[Symbol.toStringTag](){return`ShaderFactory`}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}constructor(e){this.device=e}createShader(e){if(!this.device.props._cacheShaders)return this.device.createShader(e);let t=this._hashShader(e),n=this._cache[t];if(n)n.useCount++,this.device.props.debugFactories&&Z.log(3,`${this}: Reusing shader ${n.resource.id} count=${n.useCount}`)();else{let r=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[t]=n={resource:r,useCount:1},this.device.props.debugFactories&&Z.log(3,`${this}: Created new shader ${r.id}`)()}return n.resource}release(e){if(!this.device.props._cacheShaders){e.destroy();return}let t=this._hashShader(e),n=this._cache[t];if(n)if(n.useCount--,n.useCount===0)this.device.props._destroyShaders&&(delete this._cache[t],n.resource.destroy(),this.device.props.debugFactories&&Z.log(3,`${this}: Releasing shader ${e.id}, destroyed`)());else if(n.useCount<0)throw Error(`ShaderFactory: Shader ${e.id} released too many times`);else this.device.props.debugFactories&&Z.log(3,`${this}: Releasing shader ${e.id} count=${n.useCount}`)()}_hashShader(e){return`${e.stage}:${e.source}`}};function nx(e,t,n){let r=e.bindings.find(e=>e.name===t||`${e.name.toLocaleLowerCase()}uniforms`===t.toLocaleLowerCase());return!r&&!n?.ignoreWarnings&&Z.warn(`Binding ${t} not set: Not found in shader layout.`)(),r||null}function rx(e,t){if(!t)return{};if(ax(t))return Object.fromEntries(Object.entries(t).map(([e,t])=>[Number(e),{...t}]));let n={};for(let[r,i]of Object.entries(t)){let t=nx(e,r)?.group??0;n[t]||={},n[t][r]=i}return n}function ix(e){let t={};for(let n of Object.values(e))Object.assign(t,n);return t}function ax(e){let t=Object.keys(e);return t.length>0&&t.every(e=>/^\d+$/.test(e))}var ox=class e extends Q{static defaultClearColor=[0,0,0,1];static defaultClearDepth=1;static defaultClearStencil=0;get[Symbol.toStringTag](){return`RenderPass`}constructor(t,n){n=e.normalizeProps(t,n),super(t,n,e.defaultProps)}static normalizeProps(e,t){return t}static defaultProps={...Q.defaultProps,framebuffer:null,parameters:void 0,clearColor:e.defaultClearColor,clearColors:void 0,clearDepth:e.defaultClearDepth,clearStencil:e.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0}},sx=class e extends Q{get[Symbol.toStringTag](){return`CommandEncoder`}_timeProfilingQuerySet=null;_timeProfilingSlotCount=0;_gpuTimeMs;constructor(t,n){super(t,n,e.defaultProps),this._timeProfilingQuerySet=n.timeProfilingQuerySet??null,this._timeProfilingSlotCount=0,this._gpuTimeMs=void 0}async resolveTimeProfilingQuerySet(){if(this._gpuTimeMs=void 0,!this._timeProfilingQuerySet)return;let e=Math.floor(this._timeProfilingSlotCount/2);if(e<=0)return;let t=e*2,n=await this._timeProfilingQuerySet.readResults({firstQuery:0,queryCount:t}),r=0n;for(let e=0;e<t;e+=2)r+=n[e+1]-n[e];this._gpuTimeMs=Number(r)/1e6}getTimeProfilingSlotCount(){return this._timeProfilingSlotCount}getTimeProfilingQuerySet(){return this._timeProfilingQuerySet}_applyTimeProfilingToPassProps(e){let t=e||{};if(!this._supportsTimestampQueries()||!this._timeProfilingQuerySet||t.timestampQuerySet!==void 0||t.beginTimestampIndex!==void 0||t.endTimestampIndex!==void 0)return t;let n=this._timeProfilingSlotCount;return n+1>=this._timeProfilingQuerySet.props.count?t:(this._timeProfilingSlotCount+=2,{...t,timestampQuerySet:this._timeProfilingQuerySet,beginTimestampIndex:n,endTimestampIndex:n+1})}_supportsTimestampQueries(){return this.device.features.has(`timestamp-query`)}static defaultProps={...Q.defaultProps,measureExecutionTime:void 0,timeProfilingQuerySet:void 0}},cx=class e extends Q{get[Symbol.toStringTag](){return`CommandBuffer`}constructor(t,n){super(t,n,e.defaultProps)}static defaultProps={...Q.defaultProps}};function lx(e){let t=vx[mx(e)];if(!t)throw Error(`Unsupported variable shader type: ${e}`);return t}function ux(e){let t=_x[px(e)];if(!t)throw Error(`Unsupported attribute shader type: ${e}`);let[n,r]=t,i=n===`i32`||n===`u32`,a=n!==`u32`;return{primitiveType:n,components:r,byteLength:gx[n]*r,integer:i,signed:a}}var dx=class{getVariableShaderTypeInfo(e){return lx(e)}getAttributeShaderTypeInfo(e){return ux(e)}makeShaderAttributeType(e,t){return fx(e,t)}resolveAttributeShaderTypeAlias(e){return px(e)}resolveVariableShaderTypeAlias(e){return mx(e)}};function fx(e,t){return t===1?e:`vec${t}<${e}>`}function px(e){return yx[e]||e}function mx(e){return bx[e]||e}var hx=new dx,gx={f32:4,f16:2,i32:4,u32:4},_x={f32:[`f32`,1],"vec2<f32>":[`f32`,2],"vec3<f32>":[`f32`,3],"vec4<f32>":[`f32`,4],f16:[`f16`,1],"vec2<f16>":[`f16`,2],"vec3<f16>":[`f16`,3],"vec4<f16>":[`f16`,4],i32:[`i32`,1],"vec2<i32>":[`i32`,2],"vec3<i32>":[`i32`,3],"vec4<i32>":[`i32`,4],u32:[`u32`,1],"vec2<u32>":[`u32`,2],"vec3<u32>":[`u32`,3],"vec4<u32>":[`u32`,4]},vx={f32:{type:`f32`,components:1},f16:{type:`f16`,components:1},i32:{type:`i32`,components:1},u32:{type:`u32`,components:1},"vec2<f32>":{type:`f32`,components:2},"vec3<f32>":{type:`f32`,components:3},"vec4<f32>":{type:`f32`,components:4},"vec2<f16>":{type:`f16`,components:2},"vec3<f16>":{type:`f16`,components:3},"vec4<f16>":{type:`f16`,components:4},"vec2<i32>":{type:`i32`,components:2},"vec3<i32>":{type:`i32`,components:3},"vec4<i32>":{type:`i32`,components:4},"vec2<u32>":{type:`u32`,components:2},"vec3<u32>":{type:`u32`,components:3},"vec4<u32>":{type:`u32`,components:4},"mat2x2<f32>":{type:`f32`,components:4},"mat2x3<f32>":{type:`f32`,components:6},"mat2x4<f32>":{type:`f32`,components:8},"mat3x2<f32>":{type:`f32`,components:6},"mat3x3<f32>":{type:`f32`,components:9},"mat3x4<f32>":{type:`f32`,components:12},"mat4x2<f32>":{type:`f32`,components:8},"mat4x3<f32>":{type:`f32`,components:12},"mat4x4<f32>":{type:`f32`,components:16},"mat2x2<f16>":{type:`f16`,components:4},"mat2x3<f16>":{type:`f16`,components:6},"mat2x4<f16>":{type:`f16`,components:8},"mat3x2<f16>":{type:`f16`,components:6},"mat3x3<f16>":{type:`f16`,components:9},"mat3x4<f16>":{type:`f16`,components:12},"mat4x2<f16>":{type:`f16`,components:8},"mat4x3<f16>":{type:`f16`,components:12},"mat4x4<f16>":{type:`f16`,components:16},"mat2x2<i32>":{type:`i32`,components:4},"mat2x3<i32>":{type:`i32`,components:6},"mat2x4<i32>":{type:`i32`,components:8},"mat3x2<i32>":{type:`i32`,components:6},"mat3x3<i32>":{type:`i32`,components:9},"mat3x4<i32>":{type:`i32`,components:12},"mat4x2<i32>":{type:`i32`,components:8},"mat4x3<i32>":{type:`i32`,components:12},"mat4x4<i32>":{type:`i32`,components:16},"mat2x2<u32>":{type:`u32`,components:4},"mat2x3<u32>":{type:`u32`,components:6},"mat2x4<u32>":{type:`u32`,components:8},"mat3x2<u32>":{type:`u32`,components:6},"mat3x3<u32>":{type:`u32`,components:9},"mat3x4<u32>":{type:`u32`,components:12},"mat4x2<u32>":{type:`u32`,components:8},"mat4x3<u32>":{type:`u32`,components:12},"mat4x4<u32>":{type:`u32`,components:16}},yx={vec2i:`vec2<i32>`,vec3i:`vec3<i32>`,vec4i:`vec4<i32>`,vec2u:`vec2<u32>`,vec3u:`vec3<u32>`,vec4u:`vec4<u32>`,vec2f:`vec2<f32>`,vec3f:`vec3<f32>`,vec4f:`vec4<f32>`,vec2h:`vec2<f16>`,vec3h:`vec3<f16>`,vec4h:`vec4<f16>`},bx={vec2i:`vec2<i32>`,vec3i:`vec3<i32>`,vec4i:`vec4<i32>`,vec2u:`vec2<u32>`,vec3u:`vec3<u32>`,vec4u:`vec4<u32>`,vec2f:`vec2<f32>`,vec3f:`vec3<f32>`,vec4f:`vec4<f32>`,vec2h:`vec2<f16>`,vec3h:`vec3<f16>`,vec4h:`vec4<f16>`,mat2x2f:`mat2x2<f32>`,mat2x3f:`mat2x3<f32>`,mat2x4f:`mat2x4<f32>`,mat3x2f:`mat3x2<f32>`,mat3x3f:`mat3x3<f32>`,mat3x4f:`mat3x4<f32>`,mat4x2f:`mat4x2<f32>`,mat4x3f:`mat4x3<f32>`,mat4x4f:`mat4x4<f32>`,mat2x2i:`mat2x2<i32>`,mat2x3i:`mat2x3<i32>`,mat2x4i:`mat2x4<i32>`,mat3x2i:`mat3x2<i32>`,mat3x3i:`mat3x3<i32>`,mat3x4i:`mat3x4<i32>`,mat4x2i:`mat4x2<i32>`,mat4x3i:`mat4x3<i32>`,mat4x4i:`mat4x4<i32>`,mat2x2u:`mat2x2<u32>`,mat2x3u:`mat2x3<u32>`,mat2x4u:`mat2x4<u32>`,mat3x2u:`mat3x2<u32>`,mat3x3u:`mat3x3<u32>`,mat3x4u:`mat3x4<u32>`,mat4x2u:`mat4x2<u32>`,mat4x3u:`mat4x3<u32>`,mat4x4u:`mat4x4<u32>`,mat2x2h:`mat2x2<f16>`,mat2x3h:`mat2x3<f16>`,mat2x4h:`mat2x4<f16>`,mat3x2h:`mat3x2<f16>`,mat3x3h:`mat3x3<f16>`,mat3x4h:`mat3x4<f16>`,mat4x2h:`mat4x2<f16>`,mat4x3h:`mat4x3<f16>`,mat4x4h:`mat4x4<f16>`};function xx(e,t){let n={};for(let r of e.attributes){let i=Cx(e,t,r.name);i&&(n[r.name]=i)}return n}function Sx(e,t,n=16){let r=xx(e,t),i=Array(n).fill(null);for(let e of Object.values(r))i[e.location]=e;return i}function Cx(e,t,n){let r=wx(e,n),i=Tx(t,n);if(!r)return null;let a=hx.getAttributeShaderTypeInfo(r.type),o=Ty.getCompatibleVertexFormat(a),s=i?.vertexFormat||o,c=Ty.getVertexFormatInfo(s);return{attributeName:i?.attributeName||r.name,bufferName:i?.bufferName||r.name,location:r.location,shaderType:r.type,primitiveType:a.primitiveType,shaderComponents:a.components,vertexFormat:s,bufferDataType:c.type,bufferComponents:c.components,normalized:c.normalized,integer:a.integer,stepMode:i?.stepMode||r.stepMode||`vertex`,byteOffset:i?.byteOffset||0,byteStride:i?.byteStride||0}}function wx(e,t){let n=e.attributes.find(e=>e.name===t);return n||Z.warn(`shader layout attribute "${t}" not present in shader`),n||null}function Tx(e,t){Ex(e);let n=Dx(e,t);return n||(n=Ox(e,t),n)?n:(Z.warn(`layout for attribute "${t}" not present in buffer layout`),null)}function Ex(e){for(let t of e)(t.attributes&&t.format||!t.attributes&&!t.format)&&Z.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function Dx(e,t){for(let n of e)if(n.format&&n.name===t)return{attributeName:n.name,bufferName:t,stepMode:n.stepMode,vertexFormat:n.format,byteOffset:0,byteStride:n.byteStride||0};return null}function Ox(e,t){for(let n of e){let e=n.byteStride;if(typeof n.byteStride!=`number`)for(let t of n.attributes||[]){let n=Ty.getVertexFormatInfo(t.format);e+=n.byteLength}let r=n.attributes?.find(e=>e.attribute===t);if(r)return{attributeName:r.attribute,bufferName:n.name,stepMode:n.stepMode,vertexFormat:r.format,byteOffset:r.byteOffset,byteStride:e}}return null}var kx=class e extends Q{static defaultProps={...Q.defaultProps,shaderLayout:void 0,bufferLayout:[]};get[Symbol.toStringTag](){return`VertexArray`}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(t,n){super(t,n,e.defaultProps),this.maxVertexAttributes=t.limits.maxVertexAttributes,this.attributes=Array(this.maxVertexAttributes).fill(null),this.attributeInfos=Sx(n.shaderLayout,n.bufferLayout,this.maxVertexAttributes)}setConstantWebGL(e,t){this.device.reportError(Error(`constant attributes not supported`),this)()}},Ax=class e extends Q{static defaultProps={...Q.defaultProps,layout:void 0,buffers:{}};get[Symbol.toStringTag](){return`TransformFeedback`}constructor(t,n){super(t,n,e.defaultProps)}},jx=class e extends Q{get[Symbol.toStringTag](){return`QuerySet`}constructor(t,n){super(t,n,e.defaultProps)}static defaultProps={...Q.defaultProps,type:void 0,count:void 0}},Mx=class e extends Q{static defaultProps={...Q.defaultProps};get[Symbol.toStringTag](){return`Fence`}constructor(t,n={}){super(t,n,e.defaultProps)}};function Nx(e,t){switch(t){case 1:return e;case 2:return e+e%2;default:return e+(4-e%4)%4}}function Px(e){let[,,,,t]=Fx[e];return t}var Fx={uint8:[`uint8`,`u32`,1,!1,Uint8Array],sint8:[`sint8`,`i32`,1,!1,Int8Array],unorm8:[`uint8`,`f32`,1,!0,Uint8Array],snorm8:[`sint8`,`f32`,1,!0,Int8Array],uint16:[`uint16`,`u32`,2,!1,Uint16Array],sint16:[`sint16`,`i32`,2,!1,Int16Array],unorm16:[`uint16`,`u32`,2,!0,Uint16Array],snorm16:[`sint16`,`i32`,2,!0,Int16Array],float16:[`float16`,`f16`,2,!1,Uint16Array],float32:[`float32`,`f32`,4,!1,Float32Array],uint32:[`uint32`,`u32`,4,!1,Uint32Array],sint32:[`sint32`,`i32`,4,!1,Int32Array]};function Ix(e,t={}){let n={...e},r=t.layout??`std140`,i={},a=0;for(let[e,t]of Object.entries(n))a=zx(i,e,t,a,r);return a=Nx(a,Vx(n,r)),{layout:r,byteLength:a*4,uniformTypes:n,fields:i}}function Lx(e,t){let n=mx(e),r=lx(n),i=/^mat(\d)x(\d)<.+>$/.exec(n);if(i){let e=Number(i[1]),a=Number(i[2]),o=Hx(a,n,r.type,t),s=Gx(o.size,o.alignment,t);return{alignment:o.alignment,size:e*s,components:e*a,columns:e,rows:a,columnStride:s,shaderType:n,type:r.type}}let a=/^vec(\d)<.+>$/.exec(n);return a?Hx(Number(a[1]),n,r.type,t):{alignment:1,size:1,components:1,columns:1,rows:1,columnStride:1,shaderType:n,type:r.type}}function Rx(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function zx(e,t,n,r,i){if(typeof n==`string`){let a=Lx(n,i),o=Nx(r,a.alignment);return e[t]={offset:o,...a},o+a.size}if(Array.isArray(n)){if(Array.isArray(n[0]))throw Error(`Nested arrays are not supported for ${t}`);let a=n[0],o=n[1],s=Ux(a,i),c=Nx(r,Vx(n,i));for(let n=0;n<o;n++)zx(e,`${t}[${n}]`,a,c+n*s,i);return c+s*o}if(Rx(n)){let a=Vx(n,i),o=Nx(r,a);for(let[r,a]of Object.entries(n))o=zx(e,`${t}.${r}`,a,o,i);return Nx(o,a)}throw Error(`Unsupported CompositeShaderType for ${t}`)}function Bx(e,t){if(typeof e==`string`)return Lx(e,t).size;if(Array.isArray(e)){let n=e[0],r=e[1];if(Array.isArray(n))throw Error(`Nested arrays are not supported`);return Ux(n,t)*r}let n=0;for(let r of Object.values(e)){let e=r;n=Nx(n,Vx(e,t)),n+=Bx(e,t)}return Nx(n,Vx(e,t))}function Vx(e,t){if(typeof e==`string`)return Lx(e,t).alignment;if(Array.isArray(e)){let n=e[0],r=Vx(n,t);return Kx(t)?Math.max(r,4):r}let n=1;for(let r of Object.values(e)){let e=Vx(r,t);n=Math.max(n,e)}return qx(t)?Math.max(n,4):n}function Hx(e,t,n,r){return{alignment:e===2?2:4,size:e===3?3:e,components:e,columns:1,rows:e,columnStride:e===3?3:e,shaderType:t,type:n}}function Ux(e,t){return Wx(Bx(e,t),Vx(e,t),t)}function Wx(e,t,n){return Nx(e,Kx(n)?4:t)}function Gx(e,t,n){return n===`std140`?4:Nx(e,t)}function Kx(e){return e===`std140`||e===`wgsl-uniform`}function qx(e){return e===`std140`||e===`wgsl-uniform`}var Jx;function Yx(e){return(!Jx||Jx.byteLength<e)&&(Jx=new ArrayBuffer(e)),Jx}function Xx(e,t){return new e(Yx(e.BYTES_PER_ELEMENT*t),0,t)}function Zx(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Qx(e){return Array.isArray(e)?e.length===0||typeof e[0]==`number`:Zx(e)}var $x=class{layout;constructor(e){this.layout=e}has(e){return!!this.layout.fields[e]}get(e){let t=this.layout.fields[e];return t?{offset:t.offset,size:t.size}:void 0}getFlatUniformValues(e){let t={};for(let[n,r]of Object.entries(e)){let e=this.layout.uniformTypes[n];e?this._flattenCompositeValue(t,n,e,r):this.layout.fields[n]&&(t[n]=r)}return t}getData(e){let t=Yx(this.layout.byteLength);new Uint8Array(t,0,this.layout.byteLength).fill(0);let n={i32:new Int32Array(t),u32:new Uint32Array(t),f32:new Float32Array(t),f16:new Uint16Array(t)},r=this.getFlatUniformValues(e);for(let[e,t]of Object.entries(r))this._writeLeafValue(n,e,t);return new Uint8Array(t,0,this.layout.byteLength)}_flattenCompositeValue(e,t,n,r){if(r!==void 0){if(typeof n==`string`||this.layout.fields[t]){e[t]=r;return}if(Array.isArray(n)){let i=n[0],a=n[1];if(Array.isArray(i))throw Error(`Nested arrays are not supported for ${t}`);if(typeof i==`string`&&Qx(r)){this._flattenPackedArray(e,t,i,a,r);return}if(!Array.isArray(r)){Z.warn(`Unsupported uniform array value for ${t}:`,r)();return}for(let n=0;n<Math.min(r.length,a);n++){let a=r[n];a!==void 0&&this._flattenCompositeValue(e,`${t}[${n}]`,i,a)}return}if(Rx(n)&&eS(r)){for(let[i,a]of Object.entries(r)){if(a===void 0)continue;let r=`${t}.${i}`;this._flattenCompositeValue(e,r,n[i],a)}return}Z.warn(`Unsupported uniform value for ${t}:`,r)()}}_flattenPackedArray(e,t,n,r,i){let a=i,o=Lx(n,this.layout.layout).components;for(let n=0;n<r;n++){let r=n*o;if(r>=a.length)break;o===1?e[`${t}[${n}]`]=Number(a[r]):e[`${t}[${n}]`]=tS(i,r,r+o)}}_writeLeafValue(e,t,n){let r=this.layout.fields[t];if(!r){Z.warn(`Uniform ${t} not found in layout`)();return}let{type:i,components:a,columns:o,rows:s,offset:c,columnStride:l}=r,u=e[i];if(a===1){u[c]=Number(n);return}let d=n;if(o===1){for(let e=0;e<a;e++)u[c+e]=Number(d[e]??0);return}let f=0;for(let e=0;e<o;e++){let t=c+e*l;for(let e=0;e<s;e++)u[t+e]=Number(d[f++]??0)}}};function eS(e){return!!e&&typeof e==`object`&&!Array.isArray(e)&&!ArrayBuffer.isView(e)}function tS(e,t,n){return Array.prototype.slice.call(e,t,n)}var nS=128;function rS(e,t,n=16){if(e===t)return!0;let r=e,i=t;if(!Qx(r)||!Qx(i)||r.length!==i.length)return!1;let a=Math.min(n,nS);if(r.length>a)return!1;for(let e=0;e<r.length;++e)if(i[e]!==r[e])return!1;return!0}function iS(e){return Qx(e)?e.slice():e}var aS=class{name;uniforms={};modifiedUniforms={};modified=!0;bindingLayout={};needsRedraw=`initialized`;constructor(e){if(this.name=e?.name||`unnamed`,e?.name&&e?.shaderLayout){let t=e?.shaderLayout.bindings?.find(t=>t.type===`uniform`&&t.name===e?.name);if(!t)throw Error(e?.name);let n=t;for(let e of n.uniforms||[])this.bindingLayout[e.name]=e}}setUniforms(e){for(let[t,n]of Object.entries(e))this._setUniform(t,n),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${t}=${n}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){rS(this.uniforms[e],t)||(this.uniforms[e]=iS(t),this.modifiedUniforms[e]=!0,this.modified=!0)}},oS=1024,sS=class{device;uniformBlocks=new Map;shaderBlockLayouts=new Map;shaderBlockWriters=new Map;uniformBuffers=new Map;constructor(e,t){this.device=e;for(let[n,r]of Object.entries(t)){let t=n,i=Ix(r.uniformTypes??{},{layout:r.layout??cS(e)}),a=new $x(i);this.shaderBlockLayouts.set(t,i),this.shaderBlockWriters.set(t,a);let o=new aS({name:n});o.setUniforms(a.getFlatUniformValues(r.defaultUniforms||{})),this.uniformBlocks.set(t,o)}}destroy(){for(let e of this.uniformBuffers.values())e.destroy()}setUniforms(e){for(let[t,n]of Object.entries(e)){let e=t,r=this.shaderBlockWriters.get(e)?.getFlatUniformValues(n||{});this.uniformBlocks.get(e)?.setUniforms(r||{})}this.updateUniformBuffers()}getUniformBufferByteLength(e){let t=this.shaderBlockLayouts.get(e)?.byteLength||0;return Math.max(t,oS)}getUniformBufferData(e){let t=this.uniformBlocks.get(e)?.getAllUniforms()||{};return this.shaderBlockWriters.get(e)?.getData(t)||new Uint8Array}createUniformBuffer(e,t){t&&this.setUniforms(t);let n=this.getUniformBufferByteLength(e),r=this.device.createBuffer({usage:Sy.UNIFORM|Sy.COPY_DST,byteLength:n}),i=this.getUniformBufferData(e);return r.write(i),r}getManagedUniformBuffer(e){if(!this.uniformBuffers.get(e)){let t=this.getUniformBufferByteLength(e),n=this.device.createBuffer({usage:Sy.UNIFORM|Sy.COPY_DST,byteLength:t});this.uniformBuffers.set(e,n)}return this.uniformBuffers.get(e)}updateUniformBuffers(){let e=!1;for(let t of this.uniformBlocks.keys()){let n=this.updateUniformBuffer(t);e||=n}return e&&Z.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){let t=this.uniformBlocks.get(e),n=this.uniformBuffers.get(e),r=!1;if(n&&t?.needsRedraw){r||=t.needsRedraw;let i=this.getUniformBufferData(e);n=this.uniformBuffers.get(e),n?.write(i);let a=this.uniformBlocks.get(e)?.getAllUniforms();Z.log(4,`Writing to uniform buffer ${String(e)}`,i,a)()}return r}};function cS(e){return e.type===`webgpu`?`wgsl-uniform`:`std140`}var lS=`struct LayerUniforms {
|
|
1347
|
+
<code><pre>${i}</pre></code>`,a&&(o.innerHTML+=`<br /><h1>Translated Source</h1><br /><br /><code><pre>${a}</pre></code>`),o.style.top=`0`,o.style.left=`0`,o.style.background=`white`,o.style.position=`fixed`,o.style.zIndex=`9999`,o.style.maxWidth=`100vw`,o.style.maxHeight=`100vh`,o.style.overflowY=`auto`,document.body.appendChild(o),o.querySelector(`.luma-compiler-log-error`)?.scrollIntoView(),o.querySelector(`button#close`).onclick=()=>{o.remove()},o.querySelector(`button#copy`).onclick=()=>{navigator.clipboard.writeText(this.source)}}static defaultProps={...Q.defaultProps,language:`auto`,stage:void 0,source:``,sourceMap:null,entryPoint:`main`,debugShaders:void 0}};function tx(e){return nx(e.source)||e.id||uy(`unnamed ${e.stage}-shader`)}function nx(e,t=`unnamed`){return/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(e)?.[1]??t}var rx=class e extends Q{get[Symbol.toStringTag](){return`Framebuffer`}width;height;constructor(t,n={}){super(t,n,e.defaultProps),this.width=this.props.width,this.height=this.props.height}clone(e){let t=this.colorAttachments.map(t=>t.texture.clone(e)),n=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(e);return this.device.createFramebuffer({...this.props,...e,colorAttachments:t,depthStencilAttachment:n})}resize(e){let t=!e;if(e){let[n,r]=Array.isArray(e)?e:[e.width,e.height];t=t||r!==this.height||n!==this.width,this.width=n,this.height=r}t&&(Z.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw Error(`Framebuffer has noattachments`);this.colorAttachments=this.props.colorAttachments.map((e,t)=>{if(typeof e==`string`){let n=this.createColorTexture(e,t);return this.attachResource(n),n.view}return e instanceof Kb?e.view:e});let e=this.props.depthStencilAttachment;if(e)if(typeof e==`string`){let t=this.createDepthStencilTexture(e);this.attachResource(t),this.depthStencilAttachment=t.view}else e instanceof Kb?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e,t){return this.device.createTexture({id:`${this.id}-color-attachment-${t}`,usage:Kb.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height,sampler:{magFilter:`linear`,minFilter:`linear`}})}createDepthStencilTexture(e){return this.device.createTexture({id:`${this.id}-depth-stencil-attachment`,usage:Kb.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,t){if(this.colorAttachments.forEach((n,r)=>{let i=n.texture.clone({width:e,height:t});this.destroyAttachedResource(n),this.colorAttachments[r]=i.view,this.attachResource(i.view)}),this.depthStencilAttachment){let n=this.depthStencilAttachment.texture.clone({width:e,height:t});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=n.view,this.attachResource(n)}this.updateAttachments()}static defaultProps={...Q.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null}},ix=class e extends Q{get[Symbol.toStringTag](){return`RenderPipeline`}shaderLayout;bufferLayout;linkStatus=`pending`;hash=``;sharedRenderPipeline=null;get isPending(){return this.linkStatus===`pending`||this.vs.compilationStatus===`pending`||this.fs?.compilationStatus===`pending`}get isErrored(){return this.linkStatus===`error`||this.vs.compilationStatus===`error`||this.fs?.compilationStatus===`error`}constructor(t,n){super(t,n,e.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[],this.sharedRenderPipeline=this.props._sharedRenderPipeline||null}static defaultProps={...Q.defaultProps,vs:null,vertexEntryPoint:`vertexMain`,vsConstants:{},fs:null,fragmentEntryPoint:`fragmentMain`,fsConstants:{},shaderLayout:null,bufferLayout:[],topology:`triangle-list`,colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},varyings:void 0,bufferMode:void 0,disableWarnings:!1,_sharedRenderPipeline:void 0,bindings:void 0,bindGroups:void 0}},ax=class extends Q{get[Symbol.toStringTag](){return`SharedRenderPipeline`}constructor(e,t){super(e,t,{...Q.defaultProps,handle:void 0,vs:void 0,fs:void 0,varyings:void 0,bufferMode:void 0})}},ox=class e extends Q{get[Symbol.toStringTag](){return`ComputePipeline`}hash=``;shaderLayout;constructor(t,n){super(t,n,e.defaultProps),this.shaderLayout=n.shaderLayout}static defaultProps={...Q.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0}},sx=class e{static defaultProps={...ix.defaultProps};static getDefaultPipelineFactory(t){let n=t.getModuleData(`@luma.gl/core`);return n.defaultPipelineFactory||=new e(t),n.defaultPipelineFactory}device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};_sharedRenderPipelineCache={};get[Symbol.toStringTag](){return`PipelineFactory`}toString(){return`PipelineFactory(${this.device.id})`}constructor(e){this.device=e}createRenderPipeline(e){if(!this.device.props._cachePipelines)return this.device.createRenderPipeline(e);let t={...ix.defaultProps,...e},n=this._renderPipelineCache,r=this._hashRenderPipeline(t),i=n[r]?.resource;if(i)n[r].useCount++,this.device.props.debugFactories&&Z.log(3,`${this}: ${n[r].resource} reused, count=${n[r].useCount}, (id=${e.id})`)();else{let e=this.device.type===`webgl`&&this.device.props._sharePipelines?this.createSharedRenderPipeline(t):void 0;i=this.device.createRenderPipeline({...t,id:t.id?`${t.id}-cached`:uy(`unnamed-cached`),_sharedRenderPipeline:e}),i.hash=r,n[r]={resource:i,useCount:1},this.device.props.debugFactories&&Z.log(3,`${this}: ${i} created, count=${n[r].useCount}`)()}return i}createComputePipeline(e){if(!this.device.props._cachePipelines)return this.device.createComputePipeline(e);let t={...ox.defaultProps,...e},n=this._computePipelineCache,r=this._hashComputePipeline(t),i=n[r]?.resource;return i?(n[r].useCount++,this.device.props.debugFactories&&Z.log(3,`${this}: ${n[r].resource} reused, count=${n[r].useCount}, (id=${e.id})`)()):(i=this.device.createComputePipeline({...t,id:t.id?`${t.id}-cached`:void 0}),i.hash=r,n[r]={resource:i,useCount:1},this.device.props.debugFactories&&Z.log(3,`${this}: ${i} created, count=${n[r].useCount}`)()),i}release(e){if(!this.device.props._cachePipelines){e.destroy();return}let t=this._getCache(e),n=e.hash;t[n].useCount--,t[n].useCount===0?(this._destroyPipeline(e),this.device.props.debugFactories&&Z.log(3,`${this}: ${e} released and destroyed`)()):t[n].useCount<0?(Z.error(`${this}: ${e} released, useCount < 0, resetting`)(),t[n].useCount=0):this.device.props.debugFactories&&Z.log(3,`${this}: ${e} released, count=${t[n].useCount}`)()}createSharedRenderPipeline(e){let t=this._hashSharedRenderPipeline(e),n=this._sharedRenderPipelineCache[t];return n||(n={resource:this.device._createSharedRenderPipelineWebGL(e),useCount:0},this._sharedRenderPipelineCache[t]=n),n.useCount++,n.resource}releaseSharedRenderPipeline(e){if(!e.sharedRenderPipeline)return;let t=this._hashSharedRenderPipeline(e.sharedRenderPipeline.props),n=this._sharedRenderPipelineCache[t];n&&(n.useCount--,n.useCount===0&&(n.resource.destroy(),delete this._sharedRenderPipelineCache[t]))}_destroyPipeline(e){let t=this._getCache(e);return this.device.props._destroyPipelines?(delete t[e.hash],e.destroy(),e instanceof ix&&this.releaseSharedRenderPipeline(e),!0):!1}_getCache(e){let t;if(e instanceof ox&&(t=this._computePipelineCache),e instanceof ix&&(t=this._renderPipelineCache),!t)throw Error(`${this}`);if(!t[e.hash])throw Error(`${this}: ${e} matched incorrect entry`);return t}_hashComputePipeline(e){let{type:t}=this.device;return`${t}/C/${this._getHash(e.shader.source)}SL${this._getHash(JSON.stringify(e.shaderLayout))}`}_hashRenderPipeline(e){let t=e.vs?this._getHash(e.vs.source):0,n=e.fs?this._getHash(e.fs.source):0,r=this._getWebGLVaryingHash(e),i=this._getHash(JSON.stringify(e.shaderLayout)),a=this._getHash(JSON.stringify(e.bufferLayout)),{type:o}=this.device;switch(o){case`webgl`:let s=this._getHash(JSON.stringify(e.parameters));return`${o}/R/${t}/${n}V${r}T${e.topology}P${s}SL${i}BL${a}`;default:let c=this._getHash(JSON.stringify({vertexEntryPoint:e.vertexEntryPoint,fragmentEntryPoint:e.fragmentEntryPoint})),l=this._getHash(JSON.stringify(e.parameters)),u=this._getWebGPUAttachmentHash(e);return`${o}/R/${t}/${n}V${r}T${e.topology}EP${c}P${l}SL${i}BL${a}A${u}`}}_hashSharedRenderPipeline(e){return`webgl/S/${e.vs?this._getHash(e.vs.source):0}/${e.fs?this._getHash(e.fs.source):0}V${this._getWebGLVaryingHash(e)}`}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}_getWebGLVaryingHash(e){let{varyings:t=[],bufferMode:n=null}=e;return this._getHash(JSON.stringify({varyings:t,bufferMode:n}))}_getWebGPUAttachmentHash(e){let t=e.colorAttachmentFormats??[this.device.preferredColorFormat],n=e.parameters?.depthWriteEnabled?e.depthStencilAttachmentFormat||this.device.preferredDepthFormat:null;return this._getHash(JSON.stringify({colorAttachmentFormats:t,depthStencilAttachmentFormat:n}))}},cx=class e{static defaultProps={...ex.defaultProps};static getDefaultShaderFactory(t){let n=t.getModuleData(`@luma.gl/core`);return n.defaultShaderFactory||=new e(t),n.defaultShaderFactory}device;_cache={};get[Symbol.toStringTag](){return`ShaderFactory`}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}constructor(e){this.device=e}createShader(e){if(!this.device.props._cacheShaders)return this.device.createShader(e);let t=this._hashShader(e),n=this._cache[t];if(n)n.useCount++,this.device.props.debugFactories&&Z.log(3,`${this}: Reusing shader ${n.resource.id} count=${n.useCount}`)();else{let r=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[t]=n={resource:r,useCount:1},this.device.props.debugFactories&&Z.log(3,`${this}: Created new shader ${r.id}`)()}return n.resource}release(e){if(!this.device.props._cacheShaders){e.destroy();return}let t=this._hashShader(e),n=this._cache[t];if(n)if(n.useCount--,n.useCount===0)this.device.props._destroyShaders&&(delete this._cache[t],n.resource.destroy(),this.device.props.debugFactories&&Z.log(3,`${this}: Releasing shader ${e.id}, destroyed`)());else if(n.useCount<0)throw Error(`ShaderFactory: Shader ${e.id} released too many times`);else this.device.props.debugFactories&&Z.log(3,`${this}: Releasing shader ${e.id} count=${n.useCount}`)()}_hashShader(e){return`${e.stage}:${e.source}`}};function lx(e,t,n){let r=e.bindings.find(e=>e.name===t||`${e.name.toLocaleLowerCase()}uniforms`===t.toLocaleLowerCase());return!r&&!n?.ignoreWarnings&&Z.warn(`Binding ${t} not set: Not found in shader layout.`)(),r||null}function ux(e,t){if(!t)return{};if(fx(t))return Object.fromEntries(Object.entries(t).map(([e,t])=>[Number(e),{...t}]));let n={};for(let[r,i]of Object.entries(t)){let t=lx(e,r)?.group??0;n[t]||={},n[t][r]=i}return n}function dx(e){let t={};for(let n of Object.values(e))Object.assign(t,n);return t}function fx(e){let t=Object.keys(e);return t.length>0&&t.every(e=>/^\d+$/.test(e))}var px=class e extends Q{static defaultClearColor=[0,0,0,1];static defaultClearDepth=1;static defaultClearStencil=0;get[Symbol.toStringTag](){return`RenderPass`}constructor(t,n){n=e.normalizeProps(t,n),super(t,n,e.defaultProps)}static normalizeProps(e,t){return t}static defaultProps={...Q.defaultProps,framebuffer:null,parameters:void 0,clearColor:e.defaultClearColor,clearColors:void 0,clearDepth:e.defaultClearDepth,clearStencil:e.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0}},mx=class e extends Q{get[Symbol.toStringTag](){return`CommandEncoder`}_timeProfilingQuerySet=null;_timeProfilingSlotCount=0;_gpuTimeMs;constructor(t,n){super(t,n,e.defaultProps),this._timeProfilingQuerySet=n.timeProfilingQuerySet??null,this._timeProfilingSlotCount=0,this._gpuTimeMs=void 0}async resolveTimeProfilingQuerySet(){if(this._gpuTimeMs=void 0,!this._timeProfilingQuerySet)return;let e=Math.floor(this._timeProfilingSlotCount/2);if(e<=0)return;let t=e*2,n=await this._timeProfilingQuerySet.readResults({firstQuery:0,queryCount:t}),r=0n;for(let e=0;e<t;e+=2)r+=n[e+1]-n[e];this._gpuTimeMs=Number(r)/1e6}getTimeProfilingSlotCount(){return this._timeProfilingSlotCount}getTimeProfilingQuerySet(){return this._timeProfilingQuerySet}_applyTimeProfilingToPassProps(e){let t=e||{};if(!this._supportsTimestampQueries()||!this._timeProfilingQuerySet||t.timestampQuerySet!==void 0||t.beginTimestampIndex!==void 0||t.endTimestampIndex!==void 0)return t;let n=this._timeProfilingSlotCount;return n+1>=this._timeProfilingQuerySet.props.count?t:(this._timeProfilingSlotCount+=2,{...t,timestampQuerySet:this._timeProfilingQuerySet,beginTimestampIndex:n,endTimestampIndex:n+1})}_supportsTimestampQueries(){return this.device.features.has(`timestamp-query`)}static defaultProps={...Q.defaultProps,measureExecutionTime:void 0,timeProfilingQuerySet:void 0}},hx=class e extends Q{get[Symbol.toStringTag](){return`CommandBuffer`}constructor(t,n){super(t,n,e.defaultProps)}static defaultProps={...Q.defaultProps}};function gx(e){let t=Tx[xx(e)];if(!t)throw Error(`Unsupported variable shader type: ${e}`);return t}function _x(e){let t=wx[bx(e)];if(!t)throw Error(`Unsupported attribute shader type: ${e}`);let[n,r]=t,i=n===`i32`||n===`u32`,a=n!==`u32`;return{primitiveType:n,components:r,byteLength:Cx[n]*r,integer:i,signed:a}}var vx=class{getVariableShaderTypeInfo(e){return gx(e)}getAttributeShaderTypeInfo(e){return _x(e)}makeShaderAttributeType(e,t){return yx(e,t)}resolveAttributeShaderTypeAlias(e){return bx(e)}resolveVariableShaderTypeAlias(e){return xx(e)}};function yx(e,t){return t===1?e:`vec${t}<${e}>`}function bx(e){return Ex[e]||e}function xx(e){return Dx[e]||e}var Sx=new vx,Cx={f32:4,f16:2,i32:4,u32:4},wx={f32:[`f32`,1],"vec2<f32>":[`f32`,2],"vec3<f32>":[`f32`,3],"vec4<f32>":[`f32`,4],f16:[`f16`,1],"vec2<f16>":[`f16`,2],"vec3<f16>":[`f16`,3],"vec4<f16>":[`f16`,4],i32:[`i32`,1],"vec2<i32>":[`i32`,2],"vec3<i32>":[`i32`,3],"vec4<i32>":[`i32`,4],u32:[`u32`,1],"vec2<u32>":[`u32`,2],"vec3<u32>":[`u32`,3],"vec4<u32>":[`u32`,4]},Tx={f32:{type:`f32`,components:1},f16:{type:`f16`,components:1},i32:{type:`i32`,components:1},u32:{type:`u32`,components:1},"vec2<f32>":{type:`f32`,components:2},"vec3<f32>":{type:`f32`,components:3},"vec4<f32>":{type:`f32`,components:4},"vec2<f16>":{type:`f16`,components:2},"vec3<f16>":{type:`f16`,components:3},"vec4<f16>":{type:`f16`,components:4},"vec2<i32>":{type:`i32`,components:2},"vec3<i32>":{type:`i32`,components:3},"vec4<i32>":{type:`i32`,components:4},"vec2<u32>":{type:`u32`,components:2},"vec3<u32>":{type:`u32`,components:3},"vec4<u32>":{type:`u32`,components:4},"mat2x2<f32>":{type:`f32`,components:4},"mat2x3<f32>":{type:`f32`,components:6},"mat2x4<f32>":{type:`f32`,components:8},"mat3x2<f32>":{type:`f32`,components:6},"mat3x3<f32>":{type:`f32`,components:9},"mat3x4<f32>":{type:`f32`,components:12},"mat4x2<f32>":{type:`f32`,components:8},"mat4x3<f32>":{type:`f32`,components:12},"mat4x4<f32>":{type:`f32`,components:16},"mat2x2<f16>":{type:`f16`,components:4},"mat2x3<f16>":{type:`f16`,components:6},"mat2x4<f16>":{type:`f16`,components:8},"mat3x2<f16>":{type:`f16`,components:6},"mat3x3<f16>":{type:`f16`,components:9},"mat3x4<f16>":{type:`f16`,components:12},"mat4x2<f16>":{type:`f16`,components:8},"mat4x3<f16>":{type:`f16`,components:12},"mat4x4<f16>":{type:`f16`,components:16},"mat2x2<i32>":{type:`i32`,components:4},"mat2x3<i32>":{type:`i32`,components:6},"mat2x4<i32>":{type:`i32`,components:8},"mat3x2<i32>":{type:`i32`,components:6},"mat3x3<i32>":{type:`i32`,components:9},"mat3x4<i32>":{type:`i32`,components:12},"mat4x2<i32>":{type:`i32`,components:8},"mat4x3<i32>":{type:`i32`,components:12},"mat4x4<i32>":{type:`i32`,components:16},"mat2x2<u32>":{type:`u32`,components:4},"mat2x3<u32>":{type:`u32`,components:6},"mat2x4<u32>":{type:`u32`,components:8},"mat3x2<u32>":{type:`u32`,components:6},"mat3x3<u32>":{type:`u32`,components:9},"mat3x4<u32>":{type:`u32`,components:12},"mat4x2<u32>":{type:`u32`,components:8},"mat4x3<u32>":{type:`u32`,components:12},"mat4x4<u32>":{type:`u32`,components:16}},Ex={vec2i:`vec2<i32>`,vec3i:`vec3<i32>`,vec4i:`vec4<i32>`,vec2u:`vec2<u32>`,vec3u:`vec3<u32>`,vec4u:`vec4<u32>`,vec2f:`vec2<f32>`,vec3f:`vec3<f32>`,vec4f:`vec4<f32>`,vec2h:`vec2<f16>`,vec3h:`vec3<f16>`,vec4h:`vec4<f16>`},Dx={vec2i:`vec2<i32>`,vec3i:`vec3<i32>`,vec4i:`vec4<i32>`,vec2u:`vec2<u32>`,vec3u:`vec3<u32>`,vec4u:`vec4<u32>`,vec2f:`vec2<f32>`,vec3f:`vec3<f32>`,vec4f:`vec4<f32>`,vec2h:`vec2<f16>`,vec3h:`vec3<f16>`,vec4h:`vec4<f16>`,mat2x2f:`mat2x2<f32>`,mat2x3f:`mat2x3<f32>`,mat2x4f:`mat2x4<f32>`,mat3x2f:`mat3x2<f32>`,mat3x3f:`mat3x3<f32>`,mat3x4f:`mat3x4<f32>`,mat4x2f:`mat4x2<f32>`,mat4x3f:`mat4x3<f32>`,mat4x4f:`mat4x4<f32>`,mat2x2i:`mat2x2<i32>`,mat2x3i:`mat2x3<i32>`,mat2x4i:`mat2x4<i32>`,mat3x2i:`mat3x2<i32>`,mat3x3i:`mat3x3<i32>`,mat3x4i:`mat3x4<i32>`,mat4x2i:`mat4x2<i32>`,mat4x3i:`mat4x3<i32>`,mat4x4i:`mat4x4<i32>`,mat2x2u:`mat2x2<u32>`,mat2x3u:`mat2x3<u32>`,mat2x4u:`mat2x4<u32>`,mat3x2u:`mat3x2<u32>`,mat3x3u:`mat3x3<u32>`,mat3x4u:`mat3x4<u32>`,mat4x2u:`mat4x2<u32>`,mat4x3u:`mat4x3<u32>`,mat4x4u:`mat4x4<u32>`,mat2x2h:`mat2x2<f16>`,mat2x3h:`mat2x3<f16>`,mat2x4h:`mat2x4<f16>`,mat3x2h:`mat3x2<f16>`,mat3x3h:`mat3x3<f16>`,mat3x4h:`mat3x4<f16>`,mat4x2h:`mat4x2<f16>`,mat4x3h:`mat4x3<f16>`,mat4x4h:`mat4x4<f16>`};function Ox(e,t){let n={};for(let r of e.attributes){let i=Ax(e,t,r.name);i&&(n[r.name]=i)}return n}function kx(e,t,n=16){let r=Ox(e,t),i=Array(n).fill(null);for(let e of Object.values(r))i[e.location]=e;return i}function Ax(e,t,n){let r=jx(e,n),i=Mx(t,n);if(!r)return null;let a=Sx.getAttributeShaderTypeInfo(r.type),o=My.getCompatibleVertexFormat(a),s=i?.vertexFormat||o,c=My.getVertexFormatInfo(s);return{attributeName:i?.attributeName||r.name,bufferName:i?.bufferName||r.name,location:r.location,shaderType:r.type,primitiveType:a.primitiveType,shaderComponents:a.components,vertexFormat:s,bufferDataType:c.type,bufferComponents:c.components,normalized:c.normalized,integer:a.integer,stepMode:i?.stepMode||r.stepMode||`vertex`,byteOffset:i?.byteOffset||0,byteStride:i?.byteStride||0}}function jx(e,t){let n=e.attributes.find(e=>e.name===t);return n||Z.warn(`shader layout attribute "${t}" not present in shader`),n||null}function Mx(e,t){Nx(e);let n=Px(e,t);return n||(n=Fx(e,t),n)?n:(Z.warn(`layout for attribute "${t}" not present in buffer layout`),null)}function Nx(e){for(let t of e)(t.attributes&&t.format||!t.attributes&&!t.format)&&Z.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function Px(e,t){for(let n of e)if(n.format&&n.name===t)return{attributeName:n.name,bufferName:t,stepMode:n.stepMode,vertexFormat:n.format,byteOffset:0,byteStride:n.byteStride||0};return null}function Fx(e,t){for(let n of e){let e=n.byteStride;if(typeof n.byteStride!=`number`)for(let t of n.attributes||[]){let n=My.getVertexFormatInfo(t.format);e+=n.byteLength}let r=n.attributes?.find(e=>e.attribute===t);if(r)return{attributeName:r.attribute,bufferName:n.name,stepMode:n.stepMode,vertexFormat:r.format,byteOffset:r.byteOffset,byteStride:e}}return null}var Ix=class e extends Q{static defaultProps={...Q.defaultProps,shaderLayout:void 0,bufferLayout:[]};get[Symbol.toStringTag](){return`VertexArray`}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(t,n){super(t,n,e.defaultProps),this.maxVertexAttributes=t.limits.maxVertexAttributes,this.attributes=Array(this.maxVertexAttributes).fill(null),this.attributeInfos=kx(n.shaderLayout,n.bufferLayout,this.maxVertexAttributes)}setConstantWebGL(e,t){this.device.reportError(Error(`constant attributes not supported`),this)()}},Lx=class e extends Q{static defaultProps={...Q.defaultProps,layout:void 0,buffers:{}};get[Symbol.toStringTag](){return`TransformFeedback`}constructor(t,n){super(t,n,e.defaultProps)}},Rx=class e extends Q{get[Symbol.toStringTag](){return`QuerySet`}constructor(t,n){super(t,n,e.defaultProps)}static defaultProps={...Q.defaultProps,type:void 0,count:void 0}},zx=class e extends Q{static defaultProps={...Q.defaultProps};get[Symbol.toStringTag](){return`Fence`}constructor(t,n={}){super(t,n,e.defaultProps)}};function Bx(e,t){switch(t){case 1:return e;case 2:return e+e%2;default:return e+(4-e%4)%4}}function Vx(e){let[,,,,t]=Hx[e];return t}var Hx={uint8:[`uint8`,`u32`,1,!1,Uint8Array],sint8:[`sint8`,`i32`,1,!1,Int8Array],unorm8:[`uint8`,`f32`,1,!0,Uint8Array],snorm8:[`sint8`,`f32`,1,!0,Int8Array],uint16:[`uint16`,`u32`,2,!1,Uint16Array],sint16:[`sint16`,`i32`,2,!1,Int16Array],unorm16:[`uint16`,`u32`,2,!0,Uint16Array],snorm16:[`sint16`,`i32`,2,!0,Int16Array],float16:[`float16`,`f16`,2,!1,Uint16Array],float32:[`float32`,`f32`,4,!1,Float32Array],uint32:[`uint32`,`u32`,4,!1,Uint32Array],sint32:[`sint32`,`i32`,4,!1,Int32Array]};function Ux(e,t={}){let n={...e},r=t.layout??`std140`,i={},a=0;for(let[e,t]of Object.entries(n))a=Kx(i,e,t,a,r);return a=Bx(a,Jx(n,r)),{layout:r,byteLength:a*4,uniformTypes:n,fields:i}}function Wx(e,t){let n=xx(e),r=gx(n),i=/^mat(\d)x(\d)<.+>$/.exec(n);if(i){let e=Number(i[1]),a=Number(i[2]),o=Yx(a,n,r.type,t),s=Qx(o.size,o.alignment,t);return{alignment:o.alignment,size:e*s,components:e*a,columns:e,rows:a,columnStride:s,shaderType:n,type:r.type}}let a=/^vec(\d)<.+>$/.exec(n);return a?Yx(Number(a[1]),n,r.type,t):{alignment:1,size:1,components:1,columns:1,rows:1,columnStride:1,shaderType:n,type:r.type}}function Gx(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Kx(e,t,n,r,i){if(typeof n==`string`){let a=Wx(n,i),o=Bx(r,a.alignment);return e[t]={offset:o,...a},o+a.size}if(Array.isArray(n)){if(Array.isArray(n[0]))throw Error(`Nested arrays are not supported for ${t}`);let a=n[0],o=n[1],s=Xx(a,i),c=Bx(r,Jx(n,i));for(let n=0;n<o;n++)Kx(e,`${t}[${n}]`,a,c+n*s,i);return c+s*o}if(Gx(n)){let a=Jx(n,i),o=Bx(r,a);for(let[r,a]of Object.entries(n))o=Kx(e,`${t}.${r}`,a,o,i);return Bx(o,a)}throw Error(`Unsupported CompositeShaderType for ${t}`)}function qx(e,t){if(typeof e==`string`)return Wx(e,t).size;if(Array.isArray(e)){let n=e[0],r=e[1];if(Array.isArray(n))throw Error(`Nested arrays are not supported`);return Xx(n,t)*r}let n=0;for(let r of Object.values(e)){let e=r;n=Bx(n,Jx(e,t)),n+=qx(e,t)}return Bx(n,Jx(e,t))}function Jx(e,t){if(typeof e==`string`)return Wx(e,t).alignment;if(Array.isArray(e)){let n=e[0],r=Jx(n,t);return $x(t)?Math.max(r,4):r}let n=1;for(let r of Object.values(e)){let e=Jx(r,t);n=Math.max(n,e)}return eS(t)?Math.max(n,4):n}function Yx(e,t,n,r){return{alignment:e===2?2:4,size:e===3?3:e,components:e,columns:1,rows:e,columnStride:e===3?3:e,shaderType:t,type:n}}function Xx(e,t){return Zx(qx(e,t),Jx(e,t),t)}function Zx(e,t,n){return Bx(e,$x(n)?4:t)}function Qx(e,t,n){return n===`std140`?4:Bx(e,t)}function $x(e){return e===`std140`||e===`wgsl-uniform`}function eS(e){return e===`std140`||e===`wgsl-uniform`}var tS;function nS(e){return(!tS||tS.byteLength<e)&&(tS=new ArrayBuffer(e)),tS}function rS(e,t){return new e(nS(e.BYTES_PER_ELEMENT*t),0,t)}function iS(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function aS(e){return Array.isArray(e)?e.length===0||typeof e[0]==`number`:iS(e)}var oS=class{layout;constructor(e){this.layout=e}has(e){return!!this.layout.fields[e]}get(e){let t=this.layout.fields[e];return t?{offset:t.offset,size:t.size}:void 0}getFlatUniformValues(e){let t={};for(let[n,r]of Object.entries(e)){let e=this.layout.uniformTypes[n];e?this._flattenCompositeValue(t,n,e,r):this.layout.fields[n]&&(t[n]=r)}return t}getData(e){let t=nS(this.layout.byteLength);new Uint8Array(t,0,this.layout.byteLength).fill(0);let n={i32:new Int32Array(t),u32:new Uint32Array(t),f32:new Float32Array(t),f16:new Uint16Array(t)},r=this.getFlatUniformValues(e);for(let[e,t]of Object.entries(r))this._writeLeafValue(n,e,t);return new Uint8Array(t,0,this.layout.byteLength)}_flattenCompositeValue(e,t,n,r){if(r!==void 0){if(typeof n==`string`||this.layout.fields[t]){e[t]=r;return}if(Array.isArray(n)){let i=n[0],a=n[1];if(Array.isArray(i))throw Error(`Nested arrays are not supported for ${t}`);if(typeof i==`string`&&aS(r)){this._flattenPackedArray(e,t,i,a,r);return}if(!Array.isArray(r)){Z.warn(`Unsupported uniform array value for ${t}:`,r)();return}for(let n=0;n<Math.min(r.length,a);n++){let a=r[n];a!==void 0&&this._flattenCompositeValue(e,`${t}[${n}]`,i,a)}return}if(Gx(n)&&sS(r)){for(let[i,a]of Object.entries(r)){if(a===void 0)continue;let r=`${t}.${i}`;this._flattenCompositeValue(e,r,n[i],a)}return}Z.warn(`Unsupported uniform value for ${t}:`,r)()}}_flattenPackedArray(e,t,n,r,i){let a=i,o=Wx(n,this.layout.layout).components;for(let n=0;n<r;n++){let r=n*o;if(r>=a.length)break;o===1?e[`${t}[${n}]`]=Number(a[r]):e[`${t}[${n}]`]=cS(i,r,r+o)}}_writeLeafValue(e,t,n){let r=this.layout.fields[t];if(!r){Z.warn(`Uniform ${t} not found in layout`)();return}let{type:i,components:a,columns:o,rows:s,offset:c,columnStride:l}=r,u=e[i];if(a===1){u[c]=Number(n);return}let d=n;if(o===1){for(let e=0;e<a;e++)u[c+e]=Number(d[e]??0);return}let f=0;for(let e=0;e<o;e++){let t=c+e*l;for(let e=0;e<s;e++)u[t+e]=Number(d[f++]??0)}}};function sS(e){return!!e&&typeof e==`object`&&!Array.isArray(e)&&!ArrayBuffer.isView(e)}function cS(e,t,n){return Array.prototype.slice.call(e,t,n)}var lS=128;function uS(e,t,n=16){if(e===t)return!0;let r=e,i=t;if(!aS(r)||!aS(i)||r.length!==i.length)return!1;let a=Math.min(n,lS);if(r.length>a)return!1;for(let e=0;e<r.length;++e)if(i[e]!==r[e])return!1;return!0}function dS(e){return aS(e)?e.slice():e}var fS=class{name;uniforms={};modifiedUniforms={};modified=!0;bindingLayout={};needsRedraw=`initialized`;constructor(e){if(this.name=e?.name||`unnamed`,e?.name&&e?.shaderLayout){let t=e?.shaderLayout.bindings?.find(t=>t.type===`uniform`&&t.name===e?.name);if(!t)throw Error(e?.name);let n=t;for(let e of n.uniforms||[])this.bindingLayout[e.name]=e}}setUniforms(e){for(let[t,n]of Object.entries(e))this._setUniform(t,n),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${t}=${n}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){uS(this.uniforms[e],t)||(this.uniforms[e]=dS(t),this.modifiedUniforms[e]=!0,this.modified=!0)}},pS=1024,mS=class{device;uniformBlocks=new Map;shaderBlockLayouts=new Map;shaderBlockWriters=new Map;uniformBuffers=new Map;constructor(e,t){this.device=e;for(let[n,r]of Object.entries(t)){let t=n,i=Ux(r.uniformTypes??{},{layout:r.layout??hS(e)}),a=new oS(i);this.shaderBlockLayouts.set(t,i),this.shaderBlockWriters.set(t,a);let o=new fS({name:n});o.setUniforms(a.getFlatUniformValues(r.defaultUniforms||{})),this.uniformBlocks.set(t,o)}}destroy(){for(let e of this.uniformBuffers.values())e.destroy()}setUniforms(e){for(let[t,n]of Object.entries(e)){let e=t,r=this.shaderBlockWriters.get(e)?.getFlatUniformValues(n||{});this.uniformBlocks.get(e)?.setUniforms(r||{})}this.updateUniformBuffers()}getUniformBufferByteLength(e){let t=this.shaderBlockLayouts.get(e)?.byteLength||0;return Math.max(t,pS)}getUniformBufferData(e){let t=this.uniformBlocks.get(e)?.getAllUniforms()||{};return this.shaderBlockWriters.get(e)?.getData(t)||new Uint8Array}createUniformBuffer(e,t){t&&this.setUniforms(t);let n=this.getUniformBufferByteLength(e),r=this.device.createBuffer({usage:ky.UNIFORM|ky.COPY_DST,byteLength:n}),i=this.getUniformBufferData(e);return r.write(i),r}getManagedUniformBuffer(e){if(!this.uniformBuffers.get(e)){let t=this.getUniformBufferByteLength(e),n=this.device.createBuffer({usage:ky.UNIFORM|ky.COPY_DST,byteLength:t});this.uniformBuffers.set(e,n)}return this.uniformBuffers.get(e)}updateUniformBuffers(){let e=!1;for(let t of this.uniformBlocks.keys()){let n=this.updateUniformBuffer(t);e||=n}return e&&Z.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){let t=this.uniformBlocks.get(e),n=this.uniformBuffers.get(e),r=!1;if(n&&t?.needsRedraw){r||=t.needsRedraw;let i=this.getUniformBufferData(e);n=this.uniformBuffers.get(e),n?.write(i);let a=this.uniformBlocks.get(e)?.getAllUniforms();Z.log(4,`Writing to uniform buffer ${String(e)}`,i,a)()}return r}};function hS(e){return e.type===`webgpu`?`wgsl-uniform`:`std140`}var gS=`struct LayerUniforms {
|
|
1348
1348
|
opacity: f32,
|
|
1349
1349
|
};
|
|
1350
1350
|
|
|
1351
1351
|
@group(0) @binding(auto)
|
|
1352
1352
|
var<uniform> layer: LayerUniforms;
|
|
1353
|
-
`,
|
|
1353
|
+
`,_S=`layout(std140) uniform layerUniforms {
|
|
1354
1354
|
uniform float opacity;
|
|
1355
1355
|
} layer;
|
|
1356
|
-
`,
|
|
1356
|
+
`,vS={name:`layer`,source:gS,vs:_S,fs:_S,getUniforms:e=>({opacity:e.opacity**(1/2.2)}),uniformTypes:{opacity:`f32`}},yS={name:`color`,dependencies:[],source:`
|
|
1357
1357
|
|
|
1358
1358
|
@must_use
|
|
1359
1359
|
fn deckgl_premultiplied_alpha(fragColor: vec4<f32>) -> vec4<f32> {
|
|
1360
1360
|
return vec4(fragColor.rgb * fragColor.a, fragColor.a);
|
|
1361
1361
|
};
|
|
1362
|
-
`,getUniforms:e=>({})},
|
|
1362
|
+
`,getUniforms:e=>({})},bS=`const SMOOTH_EDGE_RADIUS: f32 = 0.5;
|
|
1363
1363
|
|
|
1364
1364
|
struct VertexGeometry {
|
|
1365
1365
|
position: vec4<f32>,
|
|
@@ -1388,8 +1388,8 @@ var<private> fragmentGeometry: FragmentGeometry;
|
|
|
1388
1388
|
fn smoothedge(edge: f32, x: f32) -> f32 {
|
|
1389
1389
|
return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);
|
|
1390
1390
|
}
|
|
1391
|
-
`,
|
|
1392
|
-
${
|
|
1391
|
+
`,xS=`#define SMOOTH_EDGE_RADIUS 0.5`,SS={name:`geometry`,source:bS,vs:`\
|
|
1392
|
+
${xS}
|
|
1393
1393
|
|
|
1394
1394
|
struct VertexGeometry {
|
|
1395
1395
|
vec4 position;
|
|
@@ -1407,7 +1407,7 @@ struct VertexGeometry {
|
|
|
1407
1407
|
vec3(0.0)
|
|
1408
1408
|
);
|
|
1409
1409
|
`,fs:`\
|
|
1410
|
-
${
|
|
1410
|
+
${xS}
|
|
1411
1411
|
|
|
1412
1412
|
struct FragmentGeometry {
|
|
1413
1413
|
vec2 uv;
|
|
@@ -1416,11 +1416,11 @@ struct FragmentGeometry {
|
|
|
1416
1416
|
float smoothedge(float edge, float x) {
|
|
1417
1417
|
return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);
|
|
1418
1418
|
}
|
|
1419
|
-
`},gS;(function(e){e[e.Start=1]=`Start`,e[e.Move=2]=`Move`,e[e.End=4]=`End`,e[e.Cancel=8]=`Cancel`})(gS||={});var _S;(function(e){e[e.None=0]=`None`,e[e.Left=1]=`Left`,e[e.Right=2]=`Right`,e[e.Up=4]=`Up`,e[e.Down=8]=`Down`,e[e.Horizontal=3]=`Horizontal`,e[e.Vertical=12]=`Vertical`,e[e.All=15]=`All`})(_S||={});var $;(function(e){e[e.Possible=1]=`Possible`,e[e.Began=2]=`Began`,e[e.Changed=4]=`Changed`,e[e.Ended=8]=`Ended`,e[e.Recognized=8]=`Recognized`,e[e.Cancelled=16]=`Cancelled`,e[e.Failed=32]=`Failed`})($||={});var vS=`auto`,yS=`manipulation`,bS=`none`,xS=`pan-x`,SS=`pan-y`;function CS(e){if(e.includes(`none`))return bS;let t=e.includes(xS),n=e.includes(SS);return t&&n?bS:t||n?t?xS:SS:e.includes(`manipulation`)?yS:vS}var wS=class{constructor(e,t){this.actions=``,this.manager=e,this.set(t)}set(e){e===`compute`&&(e=this.compute()),this.manager.element&&(this.manager.element.style.touchAction=e,this.actions=e)}update(){this.set(this.manager.options.touchAction)}compute(){let e=[];for(let t of this.manager.recognizers)t.options.enable&&(e=e.concat(t.getTouchAction()));return CS(e.join(` `))}};function TS(e){return e.trim().split(/\s+/g)}function ES(e,t,n){if(e)for(let r of TS(t))e.addEventListener(r,n,!1)}function DS(e,t,n){if(e)for(let r of TS(t))e.removeEventListener(r,n,!1)}function OS(e){return(e.ownerDocument||e).defaultView}function kS(e,t){let n=e;for(;n;){if(n===t)return!0;n=n.parentNode}return!1}function AS(e){let t=e.length;if(t===1)return{x:Math.round(e[0].clientX),y:Math.round(e[0].clientY)};let n=0,r=0,i=0;for(;i<t;)n+=e[i].clientX,r+=e[i].clientY,i++;return{x:Math.round(n/t),y:Math.round(r/t)}}function jS(e){let t=[],n=0;for(;n<e.pointers.length;)t[n]={clientX:Math.round(e.pointers[n].clientX),clientY:Math.round(e.pointers[n].clientY)},n++;return{timeStamp:Date.now(),pointers:t,center:AS(t),deltaX:e.deltaX,deltaY:e.deltaY}}function MS(e,t){let n=t.x-e.x,r=t.y-e.y;return Math.sqrt(n*n+r*r)}function NS(e,t){let n=t.clientX-e.clientX,r=t.clientY-e.clientY;return Math.sqrt(n*n+r*r)}function PS(e,t){let n=t.x-e.x,r=t.y-e.y;return Math.atan2(r,n)*180/Math.PI}function FS(e,t){let n=t.clientX-e.clientX,r=t.clientY-e.clientY;return Math.atan2(r,n)*180/Math.PI}function IS(e,t){return e===t?_S.None:Math.abs(e)>=Math.abs(t)?e<0?_S.Left:_S.Right:t<0?_S.Up:_S.Down}function LS(e,t){let n=t.center,r=e.offsetDelta,i=e.prevDelta,a=e.prevInput;return(t.eventType===gS.Start||a?.eventType===gS.End)&&(i=e.prevDelta={x:a?.deltaX||0,y:a?.deltaY||0},r=e.offsetDelta={x:n.x,y:n.y}),{deltaX:i.x+(n.x-r.x),deltaY:i.y+(n.y-r.y)}}function RS(e,t,n){return{x:t/e||0,y:n/e||0}}function zS(e,t){return NS(t[0],t[1])/NS(e[0],e[1])}function BS(e,t){return FS(t[1],t[0])-FS(e[1],e[0])}function VS(e,t){let n=e.lastInterval||t,r=t.timeStamp-n.timeStamp,i,a,o,s;if(t.eventType!==gS.Cancel&&(r>25||n.velocity===void 0)){let c=t.deltaX-n.deltaX,l=t.deltaY-n.deltaY,u=RS(r,c,l);a=u.x,o=u.y,i=Math.abs(u.x)>Math.abs(u.y)?u.x:u.y,s=IS(c,l),e.lastInterval=t}else i=n.velocity,a=n.velocityX,o=n.velocityY,s=n.direction;t.velocity=i,t.velocityX=a,t.velocityY=o,t.direction=s}function HS(e,t){let{session:n}=e,{pointers:r}=t,{length:i}=r;n.firstInput||=jS(t),i>1&&!n.firstMultiple?n.firstMultiple=jS(t):i===1&&(n.firstMultiple=!1);let{firstInput:a,firstMultiple:o}=n,s=o?o.center:a.center,c=t.center=AS(r);t.timeStamp=Date.now(),t.deltaTime=t.timeStamp-a.timeStamp,t.angle=PS(s,c),t.distance=MS(s,c);let{deltaX:l,deltaY:u}=LS(n,t);t.deltaX=l,t.deltaY=u,t.offsetDirection=IS(t.deltaX,t.deltaY);let d=RS(t.deltaTime,t.deltaX,t.deltaY);t.overallVelocityX=d.x,t.overallVelocityY=d.y,t.overallVelocity=Math.abs(d.x)>Math.abs(d.y)?d.x:d.y,t.scale=o?zS(o.pointers,r):1,t.rotation=o?BS(o.pointers,r):0,t.maxPointers=n.prevInput?t.pointers.length>n.prevInput.maxPointers?t.pointers.length:n.prevInput.maxPointers:t.pointers.length;let f=e.element;return kS(t.srcEvent.target,f)&&(f=t.srcEvent.target),t.target=f,VS(n,t),t}function US(e,t,n){let r=n.pointers.length,i=n.changedPointers.length,a=t&gS.Start&&r-i===0,o=t&(gS.End|gS.Cancel)&&r-i===0;n.isFirst=!!a,n.isFinal=!!o,a&&(e.session={}),n.eventType=t;let s=HS(e,n);e.emit(`hammer.input`,s),e.recognize(s),e.session.prevInput=s}var WS=class{constructor(e){this.evEl=``,this.evWin=``,this.evTarget=``,this.domHandler=e=>{this.manager.options.enable&&this.handler(e)},this.manager=e,this.element=e.element,this.target=e.options.inputTarget||e.element}callback(e,t){US(this.manager,e,t)}init(){ES(this.element,this.evEl,this.domHandler),ES(this.target,this.evTarget,this.domHandler),ES(OS(this.element),this.evWin,this.domHandler)}destroy(){DS(this.element,this.evEl,this.domHandler),DS(this.target,this.evTarget,this.domHandler),DS(OS(this.element),this.evWin,this.domHandler)}},GS={pointerdown:gS.Start,pointermove:gS.Move,pointerup:gS.End,pointercancel:gS.Cancel,pointerout:gS.Cancel},KS=`pointerdown`,qS=`pointermove pointerup pointercancel`,JS=class extends WS{constructor(e){super(e),this.evEl=KS,this.evWin=qS,this.store=this.manager.session.pointerEvents=[],this.init()}handler(e){let{store:t}=this,n=!1,r=GS[e.type],i=e.pointerType,a=i===`touch`,o=t.findIndex(t=>t.pointerId===e.pointerId);r&gS.Start&&(e.buttons||a)?o<0&&(t.push(e),o=t.length-1):r&(gS.End|gS.Cancel)&&(n=!0),!(o<0)&&(t[o]=e,this.callback(r,{pointers:t,changedPointers:[e],eventType:r,pointerType:i,srcEvent:e}),n&&t.splice(o,1))}},YS=[``,`webkit`,`Moz`,`MS`,`ms`,`o`];function XS(e,t){let n=t[0].toUpperCase()+t.slice(1);for(let r of YS){let i=r?r+n:t;if(i in e)return i}}var ZS=1,QS=2,$S={touchAction:`compute`,enable:!0,inputTarget:null,cssProps:{userSelect:`none`,userDrag:`none`,touchCallout:`none`,tapHighlightColor:`rgba(0,0,0,0)`}},eC=class{constructor(e,t){this.options={...$S,...t,cssProps:{...$S.cssProps,...t.cssProps},inputTarget:t.inputTarget||e},this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=e,this.input=new JS(this),this.touchAction=new wS(this,this.options.touchAction),this.toggleCssProps(!0)}set(e){return Object.assign(this.options,e),e.touchAction&&this.touchAction.update(),e.inputTarget&&(this.input.destroy(),this.input.target=e.inputTarget,this.input.init()),this}stop(e){this.session.stopped=e?QS:ZS}recognize(e){let{session:t}=this;if(t.stopped)return;this.session.prevented&&e.srcEvent.preventDefault();let n,{recognizers:r}=this,{curRecognizer:i}=t;(!i||i&&i.state&$.Recognized)&&(i=t.curRecognizer=null);let a=0;for(;a<r.length;)n=r[a],t.stopped!==QS&&(!i||n===i||n.canRecognizeWith(i))?n.recognize(e):n.reset(),!i&&n.state&($.Began|$.Changed|$.Ended)&&(i=t.curRecognizer=n),a++}get(e){let{recognizers:t}=this;for(let n=0;n<t.length;n++)if(t[n].options.event===e)return t[n];return null}add(e){if(Array.isArray(e)){for(let t of e)this.add(t);return this}let t=this.get(e.options.event);return t&&this.remove(t),this.recognizers.push(e),e.manager=this,this.touchAction.update(),e}remove(e){if(Array.isArray(e)){for(let t of e)this.remove(t);return this}let t=typeof e==`string`?this.get(e):e;if(t){let{recognizers:e}=this,n=e.indexOf(t);n!==-1&&(e.splice(n,1),this.touchAction.update())}return this}on(e,t){if(!e||!t)return;let{handlers:n}=this;for(let r of TS(e))n[r]=n[r]||[],n[r].push(t)}off(e,t){if(!e)return;let{handlers:n}=this;for(let r of TS(e))t?n[r]&&n[r].splice(n[r].indexOf(t),1):delete n[r]}emit(e,t){let n=this.handlers[e]&&this.handlers[e].slice();if(!n||!n.length)return;let r=t;r.type=e,r.preventDefault=function(){t.srcEvent.preventDefault()};let i=0;for(;i<n.length;)n[i](r),i++}destroy(){this.toggleCssProps(!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}toggleCssProps(e){let{element:t}=this;if(t){for(let[n,r]of Object.entries(this.options.cssProps)){let i=XS(t.style,n);e?(this.oldCssProps[i]=t.style[i],t.style[i]=r):t.style[i]=this.oldCssProps[i]||``}e||(this.oldCssProps={})}}},tC=1;function nC(){return tC++}function rC(e){return e&$.Cancelled?`cancel`:e&$.Ended?`end`:e&$.Changed?`move`:e&$.Began?`start`:``}var iC=class{constructor(e){this.options=e,this.id=nC(),this.state=$.Possible,this.simultaneous={},this.requireFail=[]}set(e){return Object.assign(this.options,e),this.manager.touchAction.update(),this}recognizeWith(e){if(Array.isArray(e)){for(let t of e)this.recognizeWith(t);return this}let t;if(typeof e==`string`){if(t=this.manager.get(e),!t)throw Error(`Cannot find recognizer ${e}`)}else t=e;let{simultaneous:n}=this;return n[t.id]||(n[t.id]=t,t.recognizeWith(this)),this}dropRecognizeWith(e){if(Array.isArray(e)){for(let t of e)this.dropRecognizeWith(t);return this}let t;return t=typeof e==`string`?this.manager.get(e):e,t&&delete this.simultaneous[t.id],this}requireFailure(e){if(Array.isArray(e)){for(let t of e)this.requireFailure(t);return this}let t;if(typeof e==`string`){if(t=this.manager.get(e),!t)throw Error(`Cannot find recognizer ${e}`)}else t=e;let{requireFail:n}=this;return n.indexOf(t)===-1&&(n.push(t),t.requireFailure(this)),this}dropRequireFailure(e){if(Array.isArray(e)){for(let t of e)this.dropRequireFailure(t);return this}let t;if(t=typeof e==`string`?this.manager.get(e):e,t){let e=this.requireFail.indexOf(t);e>-1&&this.requireFail.splice(e,1)}return this}hasRequireFailures(){return!!this.requireFail.find(e=>e.options.enable)}canRecognizeWith(e){return!!this.simultaneous[e.id]}emit(e){if(!e)return;let{state:t}=this;t<$.Ended&&this.manager.emit(this.options.event+rC(t),e),this.manager.emit(this.options.event,e),e.additionalEvent&&this.manager.emit(e.additionalEvent,e),t>=$.Ended&&this.manager.emit(this.options.event+rC(t),e)}tryEmit(e){this.canEmit()?this.emit(e):this.state=$.Failed}canEmit(){let e=0;for(;e<this.requireFail.length;){if(!(this.requireFail[e].state&($.Failed|$.Possible)))return!1;e++}return!0}recognize(e){let t={...e};if(!this.options.enable){this.reset(),this.state=$.Failed;return}this.state&($.Recognized|$.Cancelled|$.Failed)&&(this.state=$.Possible),this.state=this.process(t),this.state&($.Began|$.Changed|$.Ended|$.Cancelled)&&this.tryEmit(t)}getEventNames(){return[this.options.event]}reset(){}},aC=class extends iC{attrTest(e){let t=this.options.pointers;return t===0||e.pointers.length===t}process(e){let{state:t}=this,{eventType:n}=e,r=t&($.Began|$.Changed),i=this.attrTest(e);return r&&(n&gS.Cancel||!i)?t|$.Cancelled:r||i?n&gS.End?t|$.Ended:t&$.Began?t|$.Changed:$.Began:$.Failed}},oC=class extends iC{constructor(e={}){super({enable:!0,event:`tap`,pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10,...e}),this.pTime=null,this.pCenter=null,this._timer=null,this._input=null,this.count=0}getTouchAction(){return[yS]}process(e){let{options:t}=this,n=e.pointers.length===t.pointers,r=e.distance<t.threshold,i=e.deltaTime<t.time;if(this.reset(),e.eventType&gS.Start&&this.count===0)return this.failTimeout();if(r&&i&&n){if(e.eventType!==gS.End)return this.failTimeout();let n=this.pTime?e.timeStamp-this.pTime<t.interval:!0,r=!this.pCenter||MS(this.pCenter,e.center)<t.posThreshold;if(this.pTime=e.timeStamp,this.pCenter=e.center,!r||!n?this.count=1:this.count+=1,this._input=e,this.count%t.taps===0)return this.hasRequireFailures()?(this._timer=setTimeout(()=>{this.state=$.Recognized,this.tryEmit(this._input)},t.interval),$.Began):$.Recognized}return $.Failed}failTimeout(){return this._timer=setTimeout(()=>{this.state=$.Failed},this.options.interval),$.Failed}reset(){clearTimeout(this._timer)}emit(e){this.state===$.Recognized&&(e.tapCount=this.count,this.manager.emit(this.options.event,e))}},sC=[``,`start`,`move`,`end`,`cancel`,`up`,`down`,`left`,`right`],cC=class extends aC{constructor(e={}){super({enable:!0,pointers:1,event:`pan`,threshold:10,direction:_S.All,...e}),this.pX=null,this.pY=null}getTouchAction(){let{options:{direction:e}}=this,t=[];return e&_S.Horizontal&&t.push(SS),e&_S.Vertical&&t.push(xS),t}getEventNames(){return sC.map(e=>this.options.event+e)}directionTest(e){let{options:t}=this,n=!0,{distance:r}=e,{direction:i}=e,a=e.deltaX,o=e.deltaY;return i&t.direction||(t.direction&_S.Horizontal?(i=a===0?_S.None:a<0?_S.Left:_S.Right,n=a!==this.pX,r=Math.abs(e.deltaX)):(i=o===0?_S.None:o<0?_S.Up:_S.Down,n=o!==this.pY,r=Math.abs(e.deltaY))),e.direction=i,n&&r>t.threshold&&!!(i&t.direction)}attrTest(e){return super.attrTest(e)&&(!!(this.state&$.Began)||!(this.state&$.Began)&&this.directionTest(e))}emit(e){this.pX=e.deltaX,this.pY=e.deltaY;let t=_S[e.direction].toLowerCase();t&&(e.additionalEvent=this.options.event+t),super.emit(e)}},lC=[``,`start`,`move`,`end`,`cancel`,`in`,`out`],uC=class extends aC{constructor(e={}){super({enable:!0,event:`pinch`,threshold:0,pointers:2,...e})}getTouchAction(){return[bS]}getEventNames(){return lC.map(e=>this.options.event+e)}attrTest(e){return super.attrTest(e)&&(Math.abs(e.scale-1)>this.options.threshold||!!(this.state&$.Began))}emit(e){if(e.scale!==1){let t=e.scale<1?`in`:`out`;e.additionalEvent=this.options.event+t}super.emit(e)}},dC=class{constructor(e,t,n){this.element=e,this.callback=t,this.options=n}},fC=typeof navigator<`u`&&navigator.userAgent?navigator.userAgent.toLowerCase():``;typeof window<`u`||global;var pC=fC.indexOf(`firefox`)!==-1,mC=4.000244140625,hC=40,gC=.25,_C=class extends dC{constructor(e,t,n){super(e,t,{enable:!0,...n}),this.handleEvent=e=>{if(!this.options.enable)return;let t=e.deltaY;globalThis.WheelEvent&&(pC&&e.deltaMode===globalThis.WheelEvent.DOM_DELTA_PIXEL&&(t/=globalThis.devicePixelRatio),e.deltaMode===globalThis.WheelEvent.DOM_DELTA_LINE&&(t*=hC)),t!==0&&t%mC===0&&(t=Math.floor(t/mC)),e.shiftKey&&t&&(t*=gC),this.callback({type:`wheel`,center:{x:e.clientX,y:e.clientY},delta:-t,srcEvent:e,pointerType:`mouse`,target:e.target})},e.addEventListener(`wheel`,this.handleEvent,{passive:!1})}destroy(){this.element.removeEventListener(`wheel`,this.handleEvent)}enableEventType(e,t){e===`wheel`&&(this.options.enable=t)}},vC=[`mousedown`,`mousemove`,`mouseup`,`mouseover`,`mouseout`,`mouseleave`],yC=class extends dC{constructor(e,t,n){super(e,t,{enable:!0,...n}),this.handleEvent=e=>{this.handleOverEvent(e),this.handleOutEvent(e),this.handleEnterEvent(e),this.handleLeaveEvent(e),this.handleMoveEvent(e)},this.pressed=!1;let{enable:r}=this.options;this.enableMoveEvent=r,this.enableLeaveEvent=r,this.enableEnterEvent=r,this.enableOutEvent=r,this.enableOverEvent=r,vC.forEach(t=>e.addEventListener(t,this.handleEvent))}destroy(){vC.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,t){switch(e){case`pointermove`:this.enableMoveEvent=t;break;case`pointerover`:this.enableOverEvent=t;break;case`pointerout`:this.enableOutEvent=t;break;case`pointerenter`:this.enableEnterEvent=t;break;case`pointerleave`:this.enableLeaveEvent=t;break;default:}}handleOverEvent(e){this.enableOverEvent&&e.type===`mouseover`&&this._emit(`pointerover`,e)}handleOutEvent(e){this.enableOutEvent&&e.type===`mouseout`&&this._emit(`pointerout`,e)}handleEnterEvent(e){this.enableEnterEvent&&e.type===`mouseenter`&&this._emit(`pointerenter`,e)}handleLeaveEvent(e){this.enableLeaveEvent&&e.type===`mouseleave`&&this._emit(`pointerleave`,e)}handleMoveEvent(e){if(this.enableMoveEvent)switch(e.type){case`mousedown`:e.button>=0&&(this.pressed=!0);break;case`mousemove`:e.buttons===0&&(this.pressed=!1),this.pressed||this._emit(`pointermove`,e);break;case`mouseup`:this.pressed=!1;break;default:}}_emit(e,t){this.callback({type:e,center:{x:t.clientX,y:t.clientY},srcEvent:t,pointerType:`mouse`,target:t.target})}},bC=[`keydown`,`keyup`],xC=class extends dC{constructor(e,t,n){super(e,t,{enable:!0,tabIndex:0,...n}),this.handleEvent=e=>{let t=e.target||e.srcElement;t.tagName===`INPUT`&&t.type===`text`||t.tagName===`TEXTAREA`||(this.enableDownEvent&&e.type===`keydown`&&this.callback({type:`keydown`,srcEvent:e,key:e.key,target:e.target}),this.enableUpEvent&&e.type===`keyup`&&this.callback({type:`keyup`,srcEvent:e,key:e.key,target:e.target}))},this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,e.tabIndex=this.options.tabIndex,e.style.outline=`none`,bC.forEach(t=>e.addEventListener(t,this.handleEvent))}destroy(){bC.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,t){e===`keydown`&&(this.enableDownEvent=t),e===`keyup`&&(this.enableUpEvent=t)}},SC=class extends dC{constructor(e,t,n){super(e,t,n),this.handleEvent=e=>{this.options.enable&&this.callback({type:`contextmenu`,center:{x:e.clientX,y:e.clientY},srcEvent:e,pointerType:`mouse`,target:e.target})},e.addEventListener(`contextmenu`,this.handleEvent)}destroy(){this.element.removeEventListener(`contextmenu`,this.handleEvent)}enableEventType(e,t){e===`contextmenu`&&(this.options.enable=t)}},CC=1,wC=2,TC=4,EC={pointerdown:CC,pointermove:wC,pointerup:TC,mousedown:CC,mousemove:wC,mouseup:TC},DC=0,OC=1,kC=2,AC=1,jC=2,MC=4;function NC(e){let t=EC[e.srcEvent.type];if(!t)return null;let{buttons:n,button:r}=e.srcEvent,i=!1,a=!1,o=!1;return t===wC?(i=!!(n&AC),a=!!(n&MC),o=!!(n&jC)):(i=r===DC,a=r===OC,o=r===kC),{leftButton:i,middleButton:a,rightButton:o}}function PC(e,t){let n=e.center;if(!n)return null;let r=t.getBoundingClientRect(),i=r.width/t.offsetWidth||1,a=r.height/t.offsetHeight||1;return{center:n,offsetCenter:{x:(n.x-r.left-t.clientLeft)/i,y:(n.y-r.top-t.clientTop)/a}}}var FC={srcElement:`root`,priority:0},IC=class{constructor(e,t){this.handleEvent=e=>{if(this.isEmpty())return;let t=this._normalizeEvent(e),n=e.srcEvent.target;for(;n&&n!==t.rootElement;){if(this._emit(t,n),t.handled)return;n=n.parentNode}this._emit(t,`root`)},this.eventManager=e,this.recognizerName=t,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(e,t,n,r=!1,i=!1){let{handlers:a,handlersByElement:o}=this,s={...FC,...n},c=o.get(s.srcElement);c||(c=[],o.set(s.srcElement,c));let l={type:e,handler:t,srcElement:s.srcElement,priority:s.priority};r&&(l.once=!0),i&&(l.passive=!0),a.push(l),this._active=this._active||!l.passive;let u=c.length-1;for(;u>=0&&!(c[u].priority>=l.priority);)u--;c.splice(u+1,0,l)}remove(e,t){let{handlers:n,handlersByElement:r}=this;for(let i=n.length-1;i>=0;i--){let a=n[i];if(a.type===e&&a.handler===t){n.splice(i,1);let e=r.get(a.srcElement);e.splice(e.indexOf(a),1),e.length===0&&r.delete(a.srcElement)}}this._active=n.some(e=>!e.passive)}_emit(e,t){let n=this.handlersByElement.get(t);if(n){let t=!1,r=()=>{e.handled=!0},i=()=>{e.handled=!0,t=!0},a=[];for(let o=0;o<n.length;o++){let{type:s,handler:c,once:l}=n[o];if(c({...e,type:s,stopPropagation:r,stopImmediatePropagation:i}),l&&a.push(n[o]),t)break}for(let e=0;e<a.length;e++){let{type:t,handler:n}=a[e];this.remove(t,n)}}}_normalizeEvent(e){let t=this.eventManager.getElement();return{...e,...NC(e),...PC(e,t),preventDefault:()=>{e.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:t}}};function LC(e){if(`recognizer`in e)return e;let t,n=Array.isArray(e)?[...e]:[e];return t=typeof n[0]==`function`?new(n.shift())(n.shift()||{}):n.shift(),{recognizer:t,recognizeWith:typeof n[0]==`string`?[n[0]]:n[0],requireFailure:typeof n[1]==`string`?[n[1]]:n[1]}}var RC=class{constructor(e=null,t={}){if(this._onBasicInput=e=>{this.manager.emit(e.srcEvent.type,e)},this._onOtherEvent=e=>{this.manager.emit(e.type,e)},this.options={recognizers:[],events:{},touchAction:`compute`,tabIndex:0,cssProps:{},...t},this.events=new Map,this.element=e,e){this.manager=new eC(e,this.options);for(let e of this.options.recognizers){let{recognizer:t,recognizeWith:n,requireFailure:r}=LC(e);this.manager.add(t),n&&t.recognizeWith(n),r&&t.requireFailure(r)}this.manager.on(`hammer.input`,this._onBasicInput),this.wheelInput=new _C(e,this._onOtherEvent,{enable:!1}),this.moveInput=new yC(e,this._onOtherEvent,{enable:!1}),this.keyInput=new xC(e,this._onOtherEvent,{enable:!1,tabIndex:t.tabIndex}),this.contextmenuInput=new SC(e,this._onOtherEvent,{enable:!1}),this.on(this.options.events)}}getElement(){return this.element}destroy(){this.element&&(this.wheelInput.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy())}on(e,t,n){this._addEventHandler(e,t,n,!1)}once(e,t,n){this._addEventHandler(e,t,n,!0)}watch(e,t,n){this._addEventHandler(e,t,n,!1,!0)}off(e,t){this._removeEventHandler(e,t)}_toggleRecognizer(e,t){let{manager:n}=this;if(!n)return;let r=n.get(e);r&&(r.set({enable:t}),n.touchAction.update()),this.wheelInput?.enableEventType(e,t),this.moveInput?.enableEventType(e,t),this.keyInput?.enableEventType(e,t),this.contextmenuInput?.enableEventType(e,t)}_addEventHandler(e,t,n,r,i){if(typeof e!=`string`){n=t;for(let[t,a]of Object.entries(e))this._addEventHandler(t,a,n,r,i);return}let{manager:a,events:o}=this;if(!a)return;let s=o.get(e);if(!s){let t=this._getRecognizerName(e)||e;s=new IC(this,t),o.set(e,s),a&&a.on(e,s.handleEvent)}s.add(e,t,n,r,i),s.isEmpty()||this._toggleRecognizer(s.recognizerName,!0)}_removeEventHandler(e,t){if(typeof e!=`string`){for(let[t,n]of Object.entries(e))this._removeEventHandler(t,n);return}let{events:n}=this,r=n.get(e);if(r&&(r.remove(e,t),r.isEmpty())){let{recognizerName:e}=r,t=!1;for(let r of n.values())if(r.recognizerName===e&&!r.isEmpty()){t=!0;break}t||this._toggleRecognizer(e,!1)}}_getRecognizerName(e){return this.manager.recognizers.find(t=>t.getEventNames().includes(e))?.options.event}},zC={DEFAULT:`default`,LNGLAT:`lnglat`,METER_OFFSETS:`meter-offsets`,LNGLAT_OFFSETS:`lnglat-offsets`,CARTESIAN:`cartesian`};Object.defineProperty(zC,"IDENTITY",{get:()=>(X.deprecated(`COORDINATE_SYSTEM.IDENTITY`,`COORDINATE_SYSTEM.CARTESIAN`)(),zC.CARTESIAN)});var BC={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},VC={common:0,meters:1,pixels:2},HC={click:`onClick`,dblclick:`onClick`,panstart:`onDragStart`,panmove:`onDrag`,panend:`onDragEnd`},UC={multipan:[cC,{threshold:10,direction:_S.Vertical,pointers:2}],pinch:[uC,{},null,[`multipan`]],pan:[cC,{threshold:1},[`pinch`],[`multipan`]],dblclick:[oC,{event:`dblclick`,taps:2}],click:[oC,{event:`click`},null,[`dblclick`]]};function WC(e,t){if(e===t)return!0;if(Array.isArray(e)){let n=e.length;if(!t||t.length!==n)return!1;for(let r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}return!1}function GC(e){let t={},n;return r=>{for(let i in r)if(!WC(r[i],t[i])){n=e(r),t=r;break}return n}}var KC=[0,0,0,0],qC=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],JC=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],YC=[0,0,0],XC=[0,0,0],ZC={default:-1,cartesian:0,lnglat:1,"meter-offsets":2,"lnglat-offsets":3};function QC(e){let t=ZC[e];if(t===void 0)throw Error(`Invalid coordinateSystem: ${e}`);return t}var $C=GC(rw);function ew(e,t,n=XC){n.length<3&&(n=[n[0],n[1],0]);let r=n,i,a=!0;switch(i=t===`lnglat-offsets`||t===`meter-offsets`?n:e.isGeospatial?[Math.fround(e.longitude),Math.fround(e.latitude),0]:null,e.projectionMode){case BC.WEB_MERCATOR:(t===`lnglat`||t===`cartesian`)&&(i=[0,0,0],a=!1);break;case BC.WEB_MERCATOR_AUTO_OFFSET:t===`lnglat`?r=i:t===`cartesian`&&(r=[Math.fround(e.center[0]),Math.fround(e.center[1]),0],i=e.unprojectPosition(r),r[0]-=n[0],r[1]-=n[1],r[2]-=n[2]);break;case BC.IDENTITY:r=e.position.map(Math.fround),r[2]=r[2]||0;break;case BC.GLOBE:a=!1,i=null;break;default:a=!1}return{geospatialOrigin:i,shaderCoordinateOrigin:r,offsetMode:a}}function tw(e,t,n){let{viewMatrixUncentered:r,projectionMatrix:i}=e,{viewMatrix:a,viewProjectionMatrix:o}=e,s=KC,c=KC,l=e.cameraPosition,{geospatialOrigin:u,shaderCoordinateOrigin:d,offsetMode:f}=ew(e,t,n);return f&&(c=e.projectPosition(u||d),l=[l[0]-c[0],l[1]-c[1],l[2]-c[2]],c[3]=1,s=Tv([],c,o),a=r||a,o=lv([],i,a),o=lv([],o,qC)),{viewMatrix:a,viewProjectionMatrix:o,projectionCenter:s,originCommon:c,cameraPosCommon:l,shaderCoordinateOrigin:d,geospatialOrigin:u}}function nw({viewport:e,devicePixelRatio:t=1,modelMatrix:n=null,coordinateSystem:r=`default`,coordinateOrigin:i=XC,autoWrapLongitude:a=!1}){r===`default`&&(r=e.isGeospatial?`lnglat`:`cartesian`);let o=$C({viewport:e,devicePixelRatio:t,coordinateSystem:r,coordinateOrigin:i});return o.wrapLongitude=a,o.modelMatrix=n||JC,o}function rw({viewport:e,devicePixelRatio:t,coordinateSystem:n,coordinateOrigin:r}){let{projectionCenter:i,viewProjectionMatrix:a,originCommon:o,cameraPosCommon:s,shaderCoordinateOrigin:c,geospatialOrigin:l}=tw(e,n,r),u=e.getDistanceScales(),d=[e.width*t,e.height*t],f=Tv([],[0,0,-e.focalDistance,1],e.projectionMatrix)[3]||1,p={coordinateSystem:QC(n),projectionMode:e.projectionMode,coordinateOrigin:c,commonOrigin:o.slice(0,3),center:i,pseudoMeters:!!e._pseudoMeters,viewportSize:d,devicePixelRatio:t,focalDistance:f,commonUnitsPerMeter:u.unitsPerMeter,commonUnitsPerWorldUnit:u.unitsPerMeter,commonUnitsPerWorldUnit2:YC,scale:e.scale,wrapLongitude:!1,viewProjectionMatrix:a,modelMatrix:JC,cameraPosition:s};if(l){let t=e.getDistanceScales(l);switch(n){case`meter-offsets`:p.commonUnitsPerWorldUnit=t.unitsPerMeter,p.commonUnitsPerWorldUnit2=t.unitsPerMeter2;break;case`lnglat`:case`lnglat-offsets`:e._pseudoMeters||(p.commonUnitsPerMeter=t.unitsPerMeter),p.commonUnitsPerWorldUnit=t.unitsPerDegree,p.commonUnitsPerWorldUnit2=t.unitsPerDegree2;break;case`cartesian`:p.commonUnitsPerWorldUnit=[1,1,t.unitsPerMeter[2]],p.commonUnitsPerWorldUnit2=[0,0,t.unitsPerMeter2[2]];break;default:break}}return p}var iw=`\
|
|
1419
|
+
`},CS;(function(e){e[e.Start=1]=`Start`,e[e.Move=2]=`Move`,e[e.End=4]=`End`,e[e.Cancel=8]=`Cancel`})(CS||={});var wS;(function(e){e[e.None=0]=`None`,e[e.Left=1]=`Left`,e[e.Right=2]=`Right`,e[e.Up=4]=`Up`,e[e.Down=8]=`Down`,e[e.Horizontal=3]=`Horizontal`,e[e.Vertical=12]=`Vertical`,e[e.All=15]=`All`})(wS||={});var $;(function(e){e[e.Possible=1]=`Possible`,e[e.Began=2]=`Began`,e[e.Changed=4]=`Changed`,e[e.Ended=8]=`Ended`,e[e.Recognized=8]=`Recognized`,e[e.Cancelled=16]=`Cancelled`,e[e.Failed=32]=`Failed`})($||={});var TS=`auto`,ES=`manipulation`,DS=`none`,OS=`pan-x`,kS=`pan-y`;function AS(e){if(e.includes(`none`))return DS;let t=e.includes(OS),n=e.includes(kS);return t&&n?DS:t||n?t?OS:kS:e.includes(`manipulation`)?ES:TS}var jS=class{constructor(e,t){this.actions=``,this.manager=e,this.set(t)}set(e){e===`compute`&&(e=this.compute()),this.manager.element&&(this.manager.element.style.touchAction=e,this.actions=e)}update(){this.set(this.manager.options.touchAction)}compute(){let e=[];for(let t of this.manager.recognizers)t.options.enable&&(e=e.concat(t.getTouchAction()));return AS(e.join(` `))}};function MS(e){return e.trim().split(/\s+/g)}function NS(e,t,n){if(e)for(let r of MS(t))e.addEventListener(r,n,!1)}function PS(e,t,n){if(e)for(let r of MS(t))e.removeEventListener(r,n,!1)}function FS(e){return(e.ownerDocument||e).defaultView}function IS(e,t){let n=e;for(;n;){if(n===t)return!0;n=n.parentNode}return!1}function LS(e){let t=e.length;if(t===1)return{x:Math.round(e[0].clientX),y:Math.round(e[0].clientY)};let n=0,r=0,i=0;for(;i<t;)n+=e[i].clientX,r+=e[i].clientY,i++;return{x:Math.round(n/t),y:Math.round(r/t)}}function RS(e){let t=[],n=0;for(;n<e.pointers.length;)t[n]={clientX:Math.round(e.pointers[n].clientX),clientY:Math.round(e.pointers[n].clientY)},n++;return{timeStamp:Date.now(),pointers:t,center:LS(t),deltaX:e.deltaX,deltaY:e.deltaY}}function zS(e,t){let n=t.x-e.x,r=t.y-e.y;return Math.sqrt(n*n+r*r)}function BS(e,t){let n=t.clientX-e.clientX,r=t.clientY-e.clientY;return Math.sqrt(n*n+r*r)}function VS(e,t){let n=t.x-e.x,r=t.y-e.y;return Math.atan2(r,n)*180/Math.PI}function HS(e,t){let n=t.clientX-e.clientX,r=t.clientY-e.clientY;return Math.atan2(r,n)*180/Math.PI}function US(e,t){return e===t?wS.None:Math.abs(e)>=Math.abs(t)?e<0?wS.Left:wS.Right:t<0?wS.Up:wS.Down}function WS(e,t){let n=t.center,r=e.offsetDelta,i=e.prevDelta,a=e.prevInput;return(t.eventType===CS.Start||a?.eventType===CS.End)&&(i=e.prevDelta={x:a?.deltaX||0,y:a?.deltaY||0},r=e.offsetDelta={x:n.x,y:n.y}),{deltaX:i.x+(n.x-r.x),deltaY:i.y+(n.y-r.y)}}function GS(e,t,n){return{x:t/e||0,y:n/e||0}}function KS(e,t){return BS(t[0],t[1])/BS(e[0],e[1])}function qS(e,t){return HS(t[1],t[0])-HS(e[1],e[0])}function JS(e,t){let n=e.lastInterval||t,r=t.timeStamp-n.timeStamp,i,a,o,s;if(t.eventType!==CS.Cancel&&(r>25||n.velocity===void 0)){let c=t.deltaX-n.deltaX,l=t.deltaY-n.deltaY,u=GS(r,c,l);a=u.x,o=u.y,i=Math.abs(u.x)>Math.abs(u.y)?u.x:u.y,s=US(c,l),e.lastInterval=t}else i=n.velocity,a=n.velocityX,o=n.velocityY,s=n.direction;t.velocity=i,t.velocityX=a,t.velocityY=o,t.direction=s}function YS(e,t){let{session:n}=e,{pointers:r}=t,{length:i}=r;n.firstInput||=RS(t),i>1&&!n.firstMultiple?n.firstMultiple=RS(t):i===1&&(n.firstMultiple=!1);let{firstInput:a,firstMultiple:o}=n,s=o?o.center:a.center,c=t.center=LS(r);t.timeStamp=Date.now(),t.deltaTime=t.timeStamp-a.timeStamp,t.angle=VS(s,c),t.distance=zS(s,c);let{deltaX:l,deltaY:u}=WS(n,t);t.deltaX=l,t.deltaY=u,t.offsetDirection=US(t.deltaX,t.deltaY);let d=GS(t.deltaTime,t.deltaX,t.deltaY);t.overallVelocityX=d.x,t.overallVelocityY=d.y,t.overallVelocity=Math.abs(d.x)>Math.abs(d.y)?d.x:d.y,t.scale=o?KS(o.pointers,r):1,t.rotation=o?qS(o.pointers,r):0,t.maxPointers=n.prevInput?t.pointers.length>n.prevInput.maxPointers?t.pointers.length:n.prevInput.maxPointers:t.pointers.length;let f=e.element;return IS(t.srcEvent.target,f)&&(f=t.srcEvent.target),t.target=f,JS(n,t),t}function XS(e,t,n){let r=n.pointers.length,i=n.changedPointers.length,a=t&CS.Start&&r-i===0,o=t&(CS.End|CS.Cancel)&&r-i===0;n.isFirst=!!a,n.isFinal=!!o,a&&(e.session={}),n.eventType=t;let s=YS(e,n);e.emit(`hammer.input`,s),e.recognize(s),e.session.prevInput=s}var ZS=class{constructor(e){this.evEl=``,this.evWin=``,this.evTarget=``,this.domHandler=e=>{this.manager.options.enable&&this.handler(e)},this.manager=e,this.element=e.element,this.target=e.options.inputTarget||e.element}callback(e,t){XS(this.manager,e,t)}init(){NS(this.element,this.evEl,this.domHandler),NS(this.target,this.evTarget,this.domHandler),NS(FS(this.element),this.evWin,this.domHandler)}destroy(){PS(this.element,this.evEl,this.domHandler),PS(this.target,this.evTarget,this.domHandler),PS(FS(this.element),this.evWin,this.domHandler)}},QS={pointerdown:CS.Start,pointermove:CS.Move,pointerup:CS.End,pointercancel:CS.Cancel,pointerout:CS.Cancel},$S=`pointerdown`,eC=`pointermove pointerup pointercancel`,tC=class extends ZS{constructor(e){super(e),this.evEl=$S,this.evWin=eC,this.store=this.manager.session.pointerEvents=[],this.init()}handler(e){let{store:t}=this,n=!1,r=QS[e.type],i=e.pointerType,a=i===`touch`,o=t.findIndex(t=>t.pointerId===e.pointerId);r&CS.Start&&(e.buttons||a)?o<0&&(t.push(e),o=t.length-1):r&(CS.End|CS.Cancel)&&(n=!0),!(o<0)&&(t[o]=e,this.callback(r,{pointers:t,changedPointers:[e],eventType:r,pointerType:i,srcEvent:e}),n&&t.splice(o,1))}},nC=[``,`webkit`,`Moz`,`MS`,`ms`,`o`];function rC(e,t){let n=t[0].toUpperCase()+t.slice(1);for(let r of nC){let i=r?r+n:t;if(i in e)return i}}var iC=1,aC=2,oC={touchAction:`compute`,enable:!0,inputTarget:null,cssProps:{userSelect:`none`,userDrag:`none`,touchCallout:`none`,tapHighlightColor:`rgba(0,0,0,0)`}},sC=class{constructor(e,t){this.options={...oC,...t,cssProps:{...oC.cssProps,...t.cssProps},inputTarget:t.inputTarget||e},this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=e,this.input=new tC(this),this.touchAction=new jS(this,this.options.touchAction),this.toggleCssProps(!0)}set(e){return Object.assign(this.options,e),e.touchAction&&this.touchAction.update(),e.inputTarget&&(this.input.destroy(),this.input.target=e.inputTarget,this.input.init()),this}stop(e){this.session.stopped=e?aC:iC}recognize(e){let{session:t}=this;if(t.stopped)return;this.session.prevented&&e.srcEvent.preventDefault();let n,{recognizers:r}=this,{curRecognizer:i}=t;(!i||i&&i.state&$.Recognized)&&(i=t.curRecognizer=null);let a=0;for(;a<r.length;)n=r[a],t.stopped!==aC&&(!i||n===i||n.canRecognizeWith(i))?n.recognize(e):n.reset(),!i&&n.state&($.Began|$.Changed|$.Ended)&&(i=t.curRecognizer=n),a++}get(e){let{recognizers:t}=this;for(let n=0;n<t.length;n++)if(t[n].options.event===e)return t[n];return null}add(e){if(Array.isArray(e)){for(let t of e)this.add(t);return this}let t=this.get(e.options.event);return t&&this.remove(t),this.recognizers.push(e),e.manager=this,this.touchAction.update(),e}remove(e){if(Array.isArray(e)){for(let t of e)this.remove(t);return this}let t=typeof e==`string`?this.get(e):e;if(t){let{recognizers:e}=this,n=e.indexOf(t);n!==-1&&(e.splice(n,1),this.touchAction.update())}return this}on(e,t){if(!e||!t)return;let{handlers:n}=this;for(let r of MS(e))n[r]=n[r]||[],n[r].push(t)}off(e,t){if(!e)return;let{handlers:n}=this;for(let r of MS(e))t?n[r]&&n[r].splice(n[r].indexOf(t),1):delete n[r]}emit(e,t){let n=this.handlers[e]&&this.handlers[e].slice();if(!n||!n.length)return;let r=t;r.type=e,r.preventDefault=function(){t.srcEvent.preventDefault()};let i=0;for(;i<n.length;)n[i](r),i++}destroy(){this.toggleCssProps(!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}toggleCssProps(e){let{element:t}=this;if(t){for(let[n,r]of Object.entries(this.options.cssProps)){let i=rC(t.style,n);e?(this.oldCssProps[i]=t.style[i],t.style[i]=r):t.style[i]=this.oldCssProps[i]||``}e||(this.oldCssProps={})}}},cC=1;function lC(){return cC++}function uC(e){return e&$.Cancelled?`cancel`:e&$.Ended?`end`:e&$.Changed?`move`:e&$.Began?`start`:``}var dC=class{constructor(e){this.options=e,this.id=lC(),this.state=$.Possible,this.simultaneous={},this.requireFail=[]}set(e){return Object.assign(this.options,e),this.manager.touchAction.update(),this}recognizeWith(e){if(Array.isArray(e)){for(let t of e)this.recognizeWith(t);return this}let t;if(typeof e==`string`){if(t=this.manager.get(e),!t)throw Error(`Cannot find recognizer ${e}`)}else t=e;let{simultaneous:n}=this;return n[t.id]||(n[t.id]=t,t.recognizeWith(this)),this}dropRecognizeWith(e){if(Array.isArray(e)){for(let t of e)this.dropRecognizeWith(t);return this}let t;return t=typeof e==`string`?this.manager.get(e):e,t&&delete this.simultaneous[t.id],this}requireFailure(e){if(Array.isArray(e)){for(let t of e)this.requireFailure(t);return this}let t;if(typeof e==`string`){if(t=this.manager.get(e),!t)throw Error(`Cannot find recognizer ${e}`)}else t=e;let{requireFail:n}=this;return n.indexOf(t)===-1&&(n.push(t),t.requireFailure(this)),this}dropRequireFailure(e){if(Array.isArray(e)){for(let t of e)this.dropRequireFailure(t);return this}let t;if(t=typeof e==`string`?this.manager.get(e):e,t){let e=this.requireFail.indexOf(t);e>-1&&this.requireFail.splice(e,1)}return this}hasRequireFailures(){return!!this.requireFail.find(e=>e.options.enable)}canRecognizeWith(e){return!!this.simultaneous[e.id]}emit(e){if(!e)return;let{state:t}=this;t<$.Ended&&this.manager.emit(this.options.event+uC(t),e),this.manager.emit(this.options.event,e),e.additionalEvent&&this.manager.emit(e.additionalEvent,e),t>=$.Ended&&this.manager.emit(this.options.event+uC(t),e)}tryEmit(e){this.canEmit()?this.emit(e):this.state=$.Failed}canEmit(){let e=0;for(;e<this.requireFail.length;){if(!(this.requireFail[e].state&($.Failed|$.Possible)))return!1;e++}return!0}recognize(e){let t={...e};if(!this.options.enable){this.reset(),this.state=$.Failed;return}this.state&($.Recognized|$.Cancelled|$.Failed)&&(this.state=$.Possible),this.state=this.process(t),this.state&($.Began|$.Changed|$.Ended|$.Cancelled)&&this.tryEmit(t)}getEventNames(){return[this.options.event]}reset(){}},fC=class extends dC{attrTest(e){let t=this.options.pointers;return t===0||e.pointers.length===t}process(e){let{state:t}=this,{eventType:n}=e,r=t&($.Began|$.Changed),i=this.attrTest(e);return r&&(n&CS.Cancel||!i)?t|$.Cancelled:r||i?n&CS.End?t|$.Ended:t&$.Began?t|$.Changed:$.Began:$.Failed}},pC=class extends dC{constructor(e={}){super({enable:!0,event:`tap`,pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10,...e}),this.pTime=null,this.pCenter=null,this._timer=null,this._input=null,this.count=0}getTouchAction(){return[ES]}process(e){let{options:t}=this,n=e.pointers.length===t.pointers,r=e.distance<t.threshold,i=e.deltaTime<t.time;if(this.reset(),e.eventType&CS.Start&&this.count===0)return this.failTimeout();if(r&&i&&n){if(e.eventType!==CS.End)return this.failTimeout();let n=this.pTime?e.timeStamp-this.pTime<t.interval:!0,r=!this.pCenter||zS(this.pCenter,e.center)<t.posThreshold;if(this.pTime=e.timeStamp,this.pCenter=e.center,!r||!n?this.count=1:this.count+=1,this._input=e,this.count%t.taps===0)return this.hasRequireFailures()?(this._timer=setTimeout(()=>{this.state=$.Recognized,this.tryEmit(this._input)},t.interval),$.Began):$.Recognized}return $.Failed}failTimeout(){return this._timer=setTimeout(()=>{this.state=$.Failed},this.options.interval),$.Failed}reset(){clearTimeout(this._timer)}emit(e){this.state===$.Recognized&&(e.tapCount=this.count,this.manager.emit(this.options.event,e))}},mC=[``,`start`,`move`,`end`,`cancel`,`up`,`down`,`left`,`right`],hC=class extends fC{constructor(e={}){super({enable:!0,pointers:1,event:`pan`,threshold:10,direction:wS.All,...e}),this.pX=null,this.pY=null}getTouchAction(){let{options:{direction:e}}=this,t=[];return e&wS.Horizontal&&t.push(kS),e&wS.Vertical&&t.push(OS),t}getEventNames(){return mC.map(e=>this.options.event+e)}directionTest(e){let{options:t}=this,n=!0,{distance:r}=e,{direction:i}=e,a=e.deltaX,o=e.deltaY;return i&t.direction||(t.direction&wS.Horizontal?(i=a===0?wS.None:a<0?wS.Left:wS.Right,n=a!==this.pX,r=Math.abs(e.deltaX)):(i=o===0?wS.None:o<0?wS.Up:wS.Down,n=o!==this.pY,r=Math.abs(e.deltaY))),e.direction=i,n&&r>t.threshold&&!!(i&t.direction)}attrTest(e){return super.attrTest(e)&&(!!(this.state&$.Began)||!(this.state&$.Began)&&this.directionTest(e))}emit(e){this.pX=e.deltaX,this.pY=e.deltaY;let t=wS[e.direction].toLowerCase();t&&(e.additionalEvent=this.options.event+t),super.emit(e)}},gC=[``,`start`,`move`,`end`,`cancel`,`in`,`out`],_C=class extends fC{constructor(e={}){super({enable:!0,event:`pinch`,threshold:0,pointers:2,...e})}getTouchAction(){return[DS]}getEventNames(){return gC.map(e=>this.options.event+e)}attrTest(e){return super.attrTest(e)&&(Math.abs(e.scale-1)>this.options.threshold||!!(this.state&$.Began))}emit(e){if(e.scale!==1){let t=e.scale<1?`in`:`out`;e.additionalEvent=this.options.event+t}super.emit(e)}},vC=class{constructor(e,t,n){this.element=e,this.callback=t,this.options=n}},yC=typeof navigator<`u`&&navigator.userAgent?navigator.userAgent.toLowerCase():``;typeof window<`u`||global;var bC=yC.indexOf(`firefox`)!==-1,xC=4.000244140625,SC=40,CC=.25,wC=class extends vC{constructor(e,t,n){super(e,t,{enable:!0,...n}),this.handleEvent=e=>{if(!this.options.enable)return;let t=e.deltaY;globalThis.WheelEvent&&(bC&&e.deltaMode===globalThis.WheelEvent.DOM_DELTA_PIXEL&&(t/=globalThis.devicePixelRatio),e.deltaMode===globalThis.WheelEvent.DOM_DELTA_LINE&&(t*=SC)),t!==0&&t%xC===0&&(t=Math.floor(t/xC)),e.shiftKey&&t&&(t*=CC),this.callback({type:`wheel`,center:{x:e.clientX,y:e.clientY},delta:-t,srcEvent:e,pointerType:`mouse`,target:e.target})},e.addEventListener(`wheel`,this.handleEvent,{passive:!1})}destroy(){this.element.removeEventListener(`wheel`,this.handleEvent)}enableEventType(e,t){e===`wheel`&&(this.options.enable=t)}},TC=[`mousedown`,`mousemove`,`mouseup`,`mouseover`,`mouseout`,`mouseleave`],EC=class extends vC{constructor(e,t,n){super(e,t,{enable:!0,...n}),this.handleEvent=e=>{this.handleOverEvent(e),this.handleOutEvent(e),this.handleEnterEvent(e),this.handleLeaveEvent(e),this.handleMoveEvent(e)},this.pressed=!1;let{enable:r}=this.options;this.enableMoveEvent=r,this.enableLeaveEvent=r,this.enableEnterEvent=r,this.enableOutEvent=r,this.enableOverEvent=r,TC.forEach(t=>e.addEventListener(t,this.handleEvent))}destroy(){TC.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,t){switch(e){case`pointermove`:this.enableMoveEvent=t;break;case`pointerover`:this.enableOverEvent=t;break;case`pointerout`:this.enableOutEvent=t;break;case`pointerenter`:this.enableEnterEvent=t;break;case`pointerleave`:this.enableLeaveEvent=t;break;default:}}handleOverEvent(e){this.enableOverEvent&&e.type===`mouseover`&&this._emit(`pointerover`,e)}handleOutEvent(e){this.enableOutEvent&&e.type===`mouseout`&&this._emit(`pointerout`,e)}handleEnterEvent(e){this.enableEnterEvent&&e.type===`mouseenter`&&this._emit(`pointerenter`,e)}handleLeaveEvent(e){this.enableLeaveEvent&&e.type===`mouseleave`&&this._emit(`pointerleave`,e)}handleMoveEvent(e){if(this.enableMoveEvent)switch(e.type){case`mousedown`:e.button>=0&&(this.pressed=!0);break;case`mousemove`:e.buttons===0&&(this.pressed=!1),this.pressed||this._emit(`pointermove`,e);break;case`mouseup`:this.pressed=!1;break;default:}}_emit(e,t){this.callback({type:e,center:{x:t.clientX,y:t.clientY},srcEvent:t,pointerType:`mouse`,target:t.target})}},DC=[`keydown`,`keyup`],OC=class extends vC{constructor(e,t,n){super(e,t,{enable:!0,tabIndex:0,...n}),this.handleEvent=e=>{let t=e.target||e.srcElement;t.tagName===`INPUT`&&t.type===`text`||t.tagName===`TEXTAREA`||(this.enableDownEvent&&e.type===`keydown`&&this.callback({type:`keydown`,srcEvent:e,key:e.key,target:e.target}),this.enableUpEvent&&e.type===`keyup`&&this.callback({type:`keyup`,srcEvent:e,key:e.key,target:e.target}))},this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,e.tabIndex=this.options.tabIndex,e.style.outline=`none`,DC.forEach(t=>e.addEventListener(t,this.handleEvent))}destroy(){DC.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,t){e===`keydown`&&(this.enableDownEvent=t),e===`keyup`&&(this.enableUpEvent=t)}},kC=class extends vC{constructor(e,t,n){super(e,t,n),this.handleEvent=e=>{this.options.enable&&this.callback({type:`contextmenu`,center:{x:e.clientX,y:e.clientY},srcEvent:e,pointerType:`mouse`,target:e.target})},e.addEventListener(`contextmenu`,this.handleEvent)}destroy(){this.element.removeEventListener(`contextmenu`,this.handleEvent)}enableEventType(e,t){e===`contextmenu`&&(this.options.enable=t)}},AC=1,jC=2,MC=4,NC={pointerdown:AC,pointermove:jC,pointerup:MC,mousedown:AC,mousemove:jC,mouseup:MC},PC=0,FC=1,IC=2,LC=1,RC=2,zC=4;function BC(e){let t=NC[e.srcEvent.type];if(!t)return null;let{buttons:n,button:r}=e.srcEvent,i=!1,a=!1,o=!1;return t===jC?(i=!!(n&LC),a=!!(n&zC),o=!!(n&RC)):(i=r===PC,a=r===FC,o=r===IC),{leftButton:i,middleButton:a,rightButton:o}}function VC(e,t){let n=e.center;if(!n)return null;let r=t.getBoundingClientRect(),i=r.width/t.offsetWidth||1,a=r.height/t.offsetHeight||1;return{center:n,offsetCenter:{x:(n.x-r.left-t.clientLeft)/i,y:(n.y-r.top-t.clientTop)/a}}}var HC={srcElement:`root`,priority:0},UC=class{constructor(e,t){this.handleEvent=e=>{if(this.isEmpty())return;let t=this._normalizeEvent(e),n=e.srcEvent.target;for(;n&&n!==t.rootElement;){if(this._emit(t,n),t.handled)return;n=n.parentNode}this._emit(t,`root`)},this.eventManager=e,this.recognizerName=t,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(e,t,n,r=!1,i=!1){let{handlers:a,handlersByElement:o}=this,s={...HC,...n},c=o.get(s.srcElement);c||(c=[],o.set(s.srcElement,c));let l={type:e,handler:t,srcElement:s.srcElement,priority:s.priority};r&&(l.once=!0),i&&(l.passive=!0),a.push(l),this._active=this._active||!l.passive;let u=c.length-1;for(;u>=0&&!(c[u].priority>=l.priority);)u--;c.splice(u+1,0,l)}remove(e,t){let{handlers:n,handlersByElement:r}=this;for(let i=n.length-1;i>=0;i--){let a=n[i];if(a.type===e&&a.handler===t){n.splice(i,1);let e=r.get(a.srcElement);e.splice(e.indexOf(a),1),e.length===0&&r.delete(a.srcElement)}}this._active=n.some(e=>!e.passive)}_emit(e,t){let n=this.handlersByElement.get(t);if(n){let t=!1,r=()=>{e.handled=!0},i=()=>{e.handled=!0,t=!0},a=[];for(let o=0;o<n.length;o++){let{type:s,handler:c,once:l}=n[o];if(c({...e,type:s,stopPropagation:r,stopImmediatePropagation:i}),l&&a.push(n[o]),t)break}for(let e=0;e<a.length;e++){let{type:t,handler:n}=a[e];this.remove(t,n)}}}_normalizeEvent(e){let t=this.eventManager.getElement();return{...e,...BC(e),...VC(e,t),preventDefault:()=>{e.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:t}}};function WC(e){if(`recognizer`in e)return e;let t,n=Array.isArray(e)?[...e]:[e];return t=typeof n[0]==`function`?new(n.shift())(n.shift()||{}):n.shift(),{recognizer:t,recognizeWith:typeof n[0]==`string`?[n[0]]:n[0],requireFailure:typeof n[1]==`string`?[n[1]]:n[1]}}var GC=class{constructor(e=null,t={}){if(this._onBasicInput=e=>{this.manager.emit(e.srcEvent.type,e)},this._onOtherEvent=e=>{this.manager.emit(e.type,e)},this.options={recognizers:[],events:{},touchAction:`compute`,tabIndex:0,cssProps:{},...t},this.events=new Map,this.element=e,e){this.manager=new sC(e,this.options);for(let e of this.options.recognizers){let{recognizer:t,recognizeWith:n,requireFailure:r}=WC(e);this.manager.add(t),n&&t.recognizeWith(n),r&&t.requireFailure(r)}this.manager.on(`hammer.input`,this._onBasicInput),this.wheelInput=new wC(e,this._onOtherEvent,{enable:!1}),this.moveInput=new EC(e,this._onOtherEvent,{enable:!1}),this.keyInput=new OC(e,this._onOtherEvent,{enable:!1,tabIndex:t.tabIndex}),this.contextmenuInput=new kC(e,this._onOtherEvent,{enable:!1}),this.on(this.options.events)}}getElement(){return this.element}destroy(){this.element&&(this.wheelInput.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy())}on(e,t,n){this._addEventHandler(e,t,n,!1)}once(e,t,n){this._addEventHandler(e,t,n,!0)}watch(e,t,n){this._addEventHandler(e,t,n,!1,!0)}off(e,t){this._removeEventHandler(e,t)}_toggleRecognizer(e,t){let{manager:n}=this;if(!n)return;let r=n.get(e);r&&(r.set({enable:t}),n.touchAction.update()),this.wheelInput?.enableEventType(e,t),this.moveInput?.enableEventType(e,t),this.keyInput?.enableEventType(e,t),this.contextmenuInput?.enableEventType(e,t)}_addEventHandler(e,t,n,r,i){if(typeof e!=`string`){n=t;for(let[t,a]of Object.entries(e))this._addEventHandler(t,a,n,r,i);return}let{manager:a,events:o}=this;if(!a)return;let s=o.get(e);if(!s){let t=this._getRecognizerName(e)||e;s=new UC(this,t),o.set(e,s),a&&a.on(e,s.handleEvent)}s.add(e,t,n,r,i),s.isEmpty()||this._toggleRecognizer(s.recognizerName,!0)}_removeEventHandler(e,t){if(typeof e!=`string`){for(let[t,n]of Object.entries(e))this._removeEventHandler(t,n);return}let{events:n}=this,r=n.get(e);if(r&&(r.remove(e,t),r.isEmpty())){let{recognizerName:e}=r,t=!1;for(let r of n.values())if(r.recognizerName===e&&!r.isEmpty()){t=!0;break}t||this._toggleRecognizer(e,!1)}}_getRecognizerName(e){return this.manager.recognizers.find(t=>t.getEventNames().includes(e))?.options.event}},KC={DEFAULT:`default`,LNGLAT:`lnglat`,METER_OFFSETS:`meter-offsets`,LNGLAT_OFFSETS:`lnglat-offsets`,CARTESIAN:`cartesian`};Object.defineProperty(KC,"IDENTITY",{get:()=>(X.deprecated(`COORDINATE_SYSTEM.IDENTITY`,`COORDINATE_SYSTEM.CARTESIAN`)(),KC.CARTESIAN)});var qC={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},JC={common:0,meters:1,pixels:2},YC={click:`onClick`,dblclick:`onClick`,panstart:`onDragStart`,panmove:`onDrag`,panend:`onDragEnd`},XC={multipan:[hC,{threshold:10,direction:wS.Vertical,pointers:2}],pinch:[_C,{},null,[`multipan`]],pan:[hC,{threshold:1},[`pinch`],[`multipan`]],dblclick:[pC,{event:`dblclick`,taps:2}],click:[pC,{event:`click`},null,[`dblclick`]]};function ZC(e,t){if(e===t)return!0;if(Array.isArray(e)){let n=e.length;if(!t||t.length!==n)return!1;for(let r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}return!1}function QC(e){let t={},n;return r=>{for(let i in r)if(!ZC(r[i],t[i])){n=e(r),t=r;break}return n}}var $C=[0,0,0,0],ew=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],tw=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],nw=[0,0,0],rw=[0,0,0],iw={default:-1,cartesian:0,lnglat:1,"meter-offsets":2,"lnglat-offsets":3};function aw(e){let t=iw[e];if(t===void 0)throw Error(`Invalid coordinateSystem: ${e}`);return t}var ow=QC(uw);function sw(e,t,n=rw){n.length<3&&(n=[n[0],n[1],0]);let r=n,i,a=!0;switch(i=t===`lnglat-offsets`||t===`meter-offsets`?n:e.isGeospatial?[Math.fround(e.longitude),Math.fround(e.latitude),0]:null,e.projectionMode){case qC.WEB_MERCATOR:(t===`lnglat`||t===`cartesian`)&&(i=[0,0,0],a=!1);break;case qC.WEB_MERCATOR_AUTO_OFFSET:t===`lnglat`?r=i:t===`cartesian`&&(r=[Math.fround(e.center[0]),Math.fround(e.center[1]),0],i=e.unprojectPosition(r),r[0]-=n[0],r[1]-=n[1],r[2]-=n[2]);break;case qC.IDENTITY:r=e.position.map(Math.fround),r[2]=r[2]||0;break;case qC.GLOBE:a=!1,i=null;break;default:a=!1}return{geospatialOrigin:i,shaderCoordinateOrigin:r,offsetMode:a}}function cw(e,t,n){let{viewMatrixUncentered:r,projectionMatrix:i}=e,{viewMatrix:a,viewProjectionMatrix:o}=e,s=$C,c=$C,l=e.cameraPosition,{geospatialOrigin:u,shaderCoordinateOrigin:d,offsetMode:f}=sw(e,t,n);return f&&(c=e.projectPosition(u||d),l=[l[0]-c[0],l[1]-c[1],l[2]-c[2]],c[3]=1,s=Mv([],c,o),a=r||a,o=gv([],i,a),o=gv([],o,ew)),{viewMatrix:a,viewProjectionMatrix:o,projectionCenter:s,originCommon:c,cameraPosCommon:l,shaderCoordinateOrigin:d,geospatialOrigin:u}}function lw({viewport:e,devicePixelRatio:t=1,modelMatrix:n=null,coordinateSystem:r=`default`,coordinateOrigin:i=rw,autoWrapLongitude:a=!1}){r===`default`&&(r=e.isGeospatial?`lnglat`:`cartesian`);let o=ow({viewport:e,devicePixelRatio:t,coordinateSystem:r,coordinateOrigin:i});return o.wrapLongitude=a,o.modelMatrix=n||tw,o}function uw({viewport:e,devicePixelRatio:t,coordinateSystem:n,coordinateOrigin:r}){let{projectionCenter:i,viewProjectionMatrix:a,originCommon:o,cameraPosCommon:s,shaderCoordinateOrigin:c,geospatialOrigin:l}=cw(e,n,r),u=e.getDistanceScales(),d=[e.width*t,e.height*t],f=Mv([],[0,0,-e.focalDistance,1],e.projectionMatrix)[3]||1,p={coordinateSystem:aw(n),projectionMode:e.projectionMode,coordinateOrigin:c,commonOrigin:o.slice(0,3),center:i,pseudoMeters:!!e._pseudoMeters,viewportSize:d,devicePixelRatio:t,focalDistance:f,commonUnitsPerMeter:u.unitsPerMeter,commonUnitsPerWorldUnit:u.unitsPerMeter,commonUnitsPerWorldUnit2:nw,scale:e.scale,wrapLongitude:!1,viewProjectionMatrix:a,modelMatrix:tw,cameraPosition:s};if(l){let t=e.getDistanceScales(l);switch(n){case`meter-offsets`:p.commonUnitsPerWorldUnit=t.unitsPerMeter,p.commonUnitsPerWorldUnit2=t.unitsPerMeter2;break;case`lnglat`:case`lnglat-offsets`:e._pseudoMeters||(p.commonUnitsPerMeter=t.unitsPerMeter),p.commonUnitsPerWorldUnit=t.unitsPerDegree,p.commonUnitsPerWorldUnit2=t.unitsPerDegree2;break;case`cartesian`:p.commonUnitsPerWorldUnit=[1,1,t.unitsPerMeter[2]],p.commonUnitsPerWorldUnit2=[0,0,t.unitsPerMeter2[2]];break;default:break}}return p}var dw=`\
|
|
1420
1420
|
${`\
|
|
1421
|
-
${[`default`,`lnglat`,`meter-offsets`,`lnglat-offsets`,`cartesian`].map(e=>`const COORDINATE_SYSTEM_${e.toUpperCase().replaceAll(`-`,`_`)}: i32 = ${
|
|
1422
|
-
${Object.keys(
|
|
1423
|
-
${Object.keys(
|
|
1421
|
+
${[`default`,`lnglat`,`meter-offsets`,`lnglat-offsets`,`cartesian`].map(e=>`const COORDINATE_SYSTEM_${e.toUpperCase().replaceAll(`-`,`_`)}: i32 = ${aw(e)};`).join(``)}
|
|
1422
|
+
${Object.keys(qC).map(e=>`const PROJECTION_MODE_${e}: i32 = ${qC[e]};`).join(``)}
|
|
1423
|
+
${Object.keys(JC).map(e=>`const UNIT_${e.toUpperCase()}: i32 = ${JC[e]};`).join(``)}
|
|
1424
1424
|
|
|
1425
1425
|
const TILE_SIZE: f32 = 512.0;
|
|
1426
1426
|
const PI: f32 = 3.1415926536;
|
|
@@ -1699,10 +1699,10 @@ fn project_pixel_size_float(pixels: f32) -> f32 {
|
|
|
1699
1699
|
fn project_pixel_size_vec2(pixels: vec2<f32>) -> vec2<f32> {
|
|
1700
1700
|
return pixels / project.scale;
|
|
1701
1701
|
}
|
|
1702
|
-
`,
|
|
1703
|
-
${[`default`,`lnglat`,`meter-offsets`,`lnglat-offsets`,`cartesian`].map(e=>`const int COORDINATE_SYSTEM_${e.toUpperCase().replaceAll(`-`,`_`)} = ${
|
|
1704
|
-
${Object.keys(
|
|
1705
|
-
${Object.keys(
|
|
1702
|
+
`,fw=`\
|
|
1703
|
+
${[`default`,`lnglat`,`meter-offsets`,`lnglat-offsets`,`cartesian`].map(e=>`const int COORDINATE_SYSTEM_${e.toUpperCase().replaceAll(`-`,`_`)} = ${aw(e)};`).join(``)}
|
|
1704
|
+
${Object.keys(qC).map(e=>`const int PROJECTION_MODE_${e} = ${qC[e]};`).join(``)}
|
|
1705
|
+
${Object.keys(JC).map(e=>`const int UNIT_${e.toUpperCase()} = ${JC[e]};`).join(``)}
|
|
1706
1706
|
layout(std140) uniform projectUniforms {
|
|
1707
1707
|
bool wrapLongitude;
|
|
1708
1708
|
int coordinateSystem;
|
|
@@ -1894,7 +1894,7 @@ return pixels / project.scale;
|
|
|
1894
1894
|
vec2 project_pixel_size(vec2 pixels) {
|
|
1895
1895
|
return pixels / project.scale;
|
|
1896
1896
|
}
|
|
1897
|
-
`,
|
|
1897
|
+
`,pw={};function mw(e=pw){return`viewport`in e?lw(e):{}}var hw={name:`project`,dependencies:[Qv,SS],source:dw,vs:fw,getUniforms:mw,uniformTypes:{wrapLongitude:`f32`,coordinateSystem:`i32`,commonUnitsPerMeter:`vec3<f32>`,projectionMode:`i32`,scale:`f32`,commonUnitsPerWorldUnit:`vec3<f32>`,commonUnitsPerWorldUnit2:`vec3<f32>`,center:`vec4<f32>`,modelMatrix:`mat4x4<f32>`,viewProjectionMatrix:`mat4x4<f32>`,viewportSize:`vec2<f32>`,devicePixelRatio:`f32`,focalDistance:`f32`,cameraPosition:`vec3<f32>`,coordinateOrigin:`vec3<f32>`,commonOrigin:`vec3<f32>`,pseudoMeters:`f32`}},gw={name:`project32`,dependencies:[hw],source:`// Define a structure to hold both the clip-space position and the common position.
|
|
1898
1898
|
struct ProjectResult {
|
|
1899
1899
|
clipPosition: vec4<f32>,
|
|
1900
1900
|
commonPosition: vec4<f32>,
|
|
@@ -1957,7 +1957,7 @@ vec4 project_position_to_clipspace(
|
|
|
1957
1957
|
vec4 commonPosition;
|
|
1958
1958
|
return project_position_to_clipspace(position, position64Low, offset, commonPosition);
|
|
1959
1959
|
}
|
|
1960
|
-
`};function
|
|
1960
|
+
`};function _w(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function vw(e,t){let n=Mv([],t,e);return jv(n,n,1/n[3]),n}function yw(e,t,n){return e<t?t:e>n?n:e}function bw(e){return Math.log(e)*Math.LOG2E}var xw=Math.log2||bw;function Sw(e,t){if(!e)throw Error(t||`@math.gl/web-mercator: assertion failed.`)}var Cw=Math.PI,ww=Cw/4,Tw=Cw/180,Ew=180/Cw,Dw=512,Ow=4003e4,kw=85.051129,Aw=1.5;function jw(e){return xw(e)}function Mw(e){let[t,n]=e;Sw(Number.isFinite(t)),Sw(Number.isFinite(n)&&n>=-90&&n<=90,`invalid latitude`);let r=t*Tw,i=n*Tw;return[Dw*(r+Cw)/(2*Cw),Dw*(Cw+Math.log(Math.tan(ww+i*.5)))/(2*Cw)]}function Nw(e){let[t,n]=e,r=t/Dw*(2*Cw)-Cw,i=2*(Math.atan(Math.exp(n/Dw*(2*Cw)-Cw))-ww);return[r*Ew,i*Ew]}function Pw(e){let{latitude:t}=e;return Sw(Number.isFinite(t)),jw(Ow*Math.cos(t*Tw))-9}function Fw(e){let t=Math.cos(e*Tw);return Dw/Ow/t}function Iw(e){let{latitude:t,longitude:n,highPrecision:r=!1}=e;Sw(Number.isFinite(t)&&Number.isFinite(n));let i=Dw,a=Math.cos(t*Tw),o=i/360,s=o/a,c=i/Ow/a,l={unitsPerMeter:[c,c,c],metersPerUnit:[1/c,1/c,1/c],unitsPerDegree:[o,s,c],degreesPerUnit:[1/o,1/s,1/c]};if(r){let e=Tw*Math.tan(t*Tw)/a,n=o*e/2,r=i/Ow*e,u=r/s*c;l.unitsPerDegree2=[0,n,r],l.unitsPerMeter2=[u,0,u]}return l}function Lw(e,t){let[n,r,i]=e,[a,o,s]=t,{unitsPerMeter:c,unitsPerMeter2:l}=Iw({longitude:n,latitude:r,highPrecision:!0}),u=Mw(e);u[0]+=a*(c[0]+l[0]*o),u[1]+=o*(c[1]+l[1]*o);let d=Nw(u),f=(i||0)+(s||0);return Number.isFinite(i)||Number.isFinite(s)?[d[0],d[1],f]:d}function Rw(e){let{height:t,pitch:n,bearing:r,altitude:i,scale:a,center:o}=e,s=_w();_v(s,s,[0,0,-i]),bv(s,s,-n*Tw),Sv(s,s,r*Tw);let c=a/t;return vv(s,s,[c,c,c]),o&&_v(s,s,q_([],o)),s}function zw(e){let{width:t,height:n,altitude:r,pitch:i=0,offset:a,center:o,scale:s,nearZMultiplier:c=1,farZMultiplier:l=1}=e,{fovy:u=Bw(Aw)}=e;r!==void 0&&(u=Bw(r));let d=u*Tw,f=i*Tw,p=Vw(u),m=p;o&&(m+=o[2]*s/Math.cos(f)/n);let h=d*(.5+(a?a[1]:0)/n),g=Math.sin(h)*m/Math.sin(yw(Math.PI/2-f-h,.01,Math.PI-.01)),_=Math.sin(f)*g+m,v=m*10,y=Math.min(_*l,v);return{fov:d,aspect:t/n,focalDistance:p,near:c,far:y}}function Bw(e){return 2*Math.atan(.5/e)*Ew}function Vw(e){return .5/Math.tan(.5*e*Tw)}function Hw(e,t){let[n,r,i=0]=e;return Sw(Number.isFinite(n)&&Number.isFinite(r)&&Number.isFinite(i)),vw(t,[n,r,i,1])}function Uw(e,t,n=0){let[r,i,a]=e;if(Sw(Number.isFinite(r)&&Number.isFinite(i),`invalid pixel coordinate`),Number.isFinite(a))return vw(t,[r,i,a,1]);let o=vw(t,[r,i,0,1]),s=vw(t,[r,i,1,1]),c=o[2],l=s[2];return I_([],o,s,c===l?0:((n||0)-c)/(l-c))}function Ww(e){let{width:t,height:n,bounds:r,minExtent:i=0,maxZoom:a=24,offset:o=[0,0]}=e,[[s,c],[l,u]]=r,d=Gw(e.padding),f=Mw([s,yw(u,-kw,kw)]),p=Mw([l,yw(c,-kw,kw)]),m=[Math.max(Math.abs(p[0]-f[0]),i),Math.max(Math.abs(p[1]-f[1]),i)],h=[t-d.left-d.right-Math.abs(o[0])*2,n-d.top-d.bottom-Math.abs(o[1])*2];Sw(h[0]>0&&h[1]>0);let g=h[0]/m[0],_=h[1]/m[1],v=(d.right-d.left)/2/g,y=(d.top-d.bottom)/2/_,b=Nw([(p[0]+f[0])/2+v,(p[1]+f[1])/2+y]),x=Math.min(a,xw(Math.abs(Math.min(g,_))));return Sw(Number.isFinite(x)),{longitude:b[0],latitude:b[1],zoom:x}}function Gw(e=0){return typeof e==`number`?{top:e,bottom:e,left:e,right:e}:(Sw(Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&Number.isFinite(e.left)&&Number.isFinite(e.right)),e)}var Kw=Math.PI/180;function qw(e,t=0){let{width:n,height:r,unproject:i}=e,a={targetZ:t},o=i([0,r],a),s=i([n,r],a),c,l;return(e.fovy?.5*e.fovy*Kw:Math.atan(.5/e.altitude))>(90-e.pitch)*Kw-.01?(c=Jw(e,0,t),l=Jw(e,n,t)):(c=i([0,0],a),l=i([n,0],a)),[o,s,l,c]}function Jw(e,t,n){let{pixelUnprojectionMatrix:r}=e,i=vw(r,[t,0,1,1]),a=vw(r,[t,e.height,1,1]),o=Nw(I_([],i,a,(n*e.distanceScales.unitsPerMeter[2]-i[2])/(a[2]-i[2])));return o.push(n),o}var Yw=`
|
|
1961
1961
|
layout(std140) uniform shadowUniforms {
|
|
1962
1962
|
bool drawShadowMap;
|
|
1963
1963
|
bool useShadowMap;
|
|
@@ -1969,8 +1969,8 @@ layout(std140) uniform shadowUniforms {
|
|
|
1969
1969
|
vec4 projectCenter0;
|
|
1970
1970
|
vec4 projectCenter1;
|
|
1971
1971
|
} shadow;
|
|
1972
|
-
`,
|
|
1973
|
-
${
|
|
1972
|
+
`,Xw=`
|
|
1973
|
+
${Yw}
|
|
1974
1974
|
|
|
1975
1975
|
const int max_lights = 2;
|
|
1976
1976
|
|
|
@@ -1998,8 +1998,8 @@ vec4 shadow_setVertexPosition(vec4 position_commonspace) {
|
|
|
1998
1998
|
return gl_Position;
|
|
1999
1999
|
}
|
|
2000
2000
|
|
|
2001
|
-
`,
|
|
2002
|
-
${
|
|
2001
|
+
`,Zw=`
|
|
2002
|
+
${Yw}
|
|
2003
2003
|
|
|
2004
2004
|
const int max_lights = 2;
|
|
2005
2005
|
uniform sampler2D shadow_uShadowMap0;
|
|
@@ -2041,11 +2041,11 @@ vec4 shadow_filterShadowColor(vec4 color) {
|
|
|
2041
2041
|
return color;
|
|
2042
2042
|
}
|
|
2043
2043
|
|
|
2044
|
-
`,
|
|
2044
|
+
`,Qw=QC(rT),$w=QC(iT),eT=[0,0,0,1],tT=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0];function nT(e,t){let[n,r,i]=e,a=Uw([n,r,i],t);return Number.isFinite(i)?a:[a[0],a[1],0]}function rT({viewport:e,center:t}){return new zv(e.viewProjectionMatrix).invert().transform(t)}function iT({viewport:e,shadowMatrices:t}){let n=[],r=e.pixelUnprojectionMatrix,i=e.isGeospatial?void 0:1,a=[[0,0,i],[e.width,0,i],[0,e.height,i],[e.width,e.height,i],[0,0,-1],[e.width,0,-1],[0,e.height,-1],[e.width,e.height,-1]].map(e=>nT(e,r));for(let r of t){let t=r.clone().translate(new uv(e.center).negate()),i=a.map(e=>t.transform(e)),o=new zv().ortho({left:Math.min(...i.map(e=>e[0])),right:Math.max(...i.map(e=>e[0])),bottom:Math.min(...i.map(e=>e[1])),top:Math.max(...i.map(e=>e[1])),near:Math.min(...i.map(e=>-e[2])),far:Math.max(...i.map(e=>-e[2]))});n.push(o.multiplyRight(r))}return n}function aT(e){let{shadowEnabled:t=!0,project:n}=e;if(!t||!n||!e.shadowMatrices||!e.shadowMatrices.length)return{drawShadowMap:!1,useShadowMap:!1,shadow_uShadowMap0:e.dummyShadowMap,shadow_uShadowMap1:e.dummyShadowMap};let r=hw.getUniforms(n),i=Qw({viewport:n.viewport,center:r.center}),a=[],o=$w({shadowMatrices:e.shadowMatrices,viewport:n.viewport}).slice();for(let t=0;t<e.shadowMatrices.length;t++){let e=o[t],s=e.clone().translate(new uv(n.viewport.center).negate());r.coordinateSystem===aw(`lnglat`)&&r.projectionMode===qC.WEB_MERCATOR?(o[t]=s,a[t]=i):(o[t]=e.clone().multiplyRight(tT),a[t]=s.transform(i))}let s={drawShadowMap:!!e.drawToShadowMap,useShadowMap:e.shadowMaps?e.shadowMaps.length>0:!1,color:e.shadowColor||eT,lightId:e.shadowLightId||0,lightCount:e.shadowMatrices.length,shadow_uShadowMap0:e.dummyShadowMap,shadow_uShadowMap1:e.dummyShadowMap};for(let e=0;e<o.length;e++)s[`viewProjectionMatrix${e}`]=o[e],s[`projectCenter${e}`]=a[e];for(let t=0;t<2;t++)s[`shadow_uShadowMap${t}`]=e.shadowMaps&&e.shadowMaps[t]||e.dummyShadowMap;return s}var oT={name:`shadow`,dependencies:[hw],vs:Xw,fs:Zw,inject:{"vs:DECKGL_FILTER_GL_POSITION":`
|
|
2045
2045
|
position = shadow_setVertexPosition(geometry.position);
|
|
2046
2046
|
`,"fs:DECKGL_FILTER_COLOR":`
|
|
2047
2047
|
color = shadow_filterShadowColor(color);
|
|
2048
|
-
`},getUniforms:
|
|
2048
|
+
`},getUniforms:aT,uniformTypes:{drawShadowMap:`f32`,useShadowMap:`f32`,color:`vec4<f32>`,lightId:`i32`,lightCount:`f32`,viewProjectionMatrix0:`mat4x4<f32>`,viewProjectionMatrix1:`mat4x4<f32>`,projectCenter0:`vec4<f32>`,projectCenter1:`vec4<f32>`}},sT=`struct pickingUniforms {
|
|
2049
2049
|
isActive: f32,
|
|
2050
2050
|
isAttribute: f32,
|
|
2051
2051
|
isHighlightActive: f32,
|
|
@@ -2071,7 +2071,7 @@ fn picking_isColorZero(color: vec3<f32>) -> bool {
|
|
|
2071
2071
|
fn picking_isColorValid(color: vec3<f32>) -> bool {
|
|
2072
2072
|
return dot(color, vec3<f32>(1.0)) > 0.00001;
|
|
2073
2073
|
}
|
|
2074
|
-
`,
|
|
2074
|
+
`,cT={...ty,source:sT,defaultUniforms:{...ty.defaultUniforms,useByteColors:!0},inject:{"vs:DECKGL_FILTER_GL_POSITION":`
|
|
2075
2075
|
// for picking depth values
|
|
2076
2076
|
picking_setPickingAttribute(position.z / position.w);
|
|
2077
2077
|
`,"vs:DECKGL_FILTER_COLOR":`
|
|
@@ -2082,12 +2082,12 @@ fn picking_isColorValid(color: vec3<f32>) -> bool {
|
|
|
2082
2082
|
|
|
2083
2083
|
// use picking color if rendering to picking FBO.
|
|
2084
2084
|
color = picking_filterPickingColor(color);
|
|
2085
|
-
`}}},nT=[hS],rT=[`vs:DECKGL_FILTER_SIZE(inout vec3 size, VertexGeometry geometry)`,`vs:DECKGL_FILTER_GL_POSITION(inout vec4 position, VertexGeometry geometry)`,`vs:DECKGL_FILTER_COLOR(inout vec4 color, VertexGeometry geometry)`,`fs:DECKGL_FILTER_COLOR(inout vec4 color, FragmentGeometry geometry)`],iT=[];function aT(e){let t=i_.getDefaultShaderAssembler();for(let e of nT)t.addDefaultModule(e);t._hookFunctions.length=0;let n=e===`glsl`?rT:iT;for(let e of n)t.addShaderHook(e);return t}var oT=[255,255,255],sT=1,cT=0,lT=class{constructor(e={}){this.type=`ambient`;let{color:t=oT}=e,{intensity:n=sT}=e;this.id=e.id||`ambient-${cT++}`,this.color=t,this.intensity=n}},uT=[255,255,255],dT=1,fT=[0,0,-1],pT=0,mT=class{constructor(e={}){this.type=`directional`;let{color:t=uT}=e,{intensity:n=dT}=e,{direction:r=fT}=e,{_shadow:i=!1}=e;this.id=e.id||`directional-${pT++}`,this.color=t,this.intensity=n,this.type=`directional`,this.direction=new rv(r).normalize().toArray(),this.shadow=i}getProjectedLight(e){return this}},hT=class{constructor(e,t={id:`pass`}){let{id:n}=t;this.id=n,this.device=e,this.props={...t}}setProps(e){Object.assign(this.props,e)}render(e){}cleanup(){}},gT={depthWriteEnabled:!0,depthCompare:`less-equal`,blendColorOperation:`add`,blendColorSrcFactor:`src-alpha`,blendColorDstFactor:`one`,blendAlphaOperation:`add`,blendAlphaSrcFactor:`one-minus-dst-alpha`,blendAlphaDstFactor:`one`},_T=class extends hT{constructor(){super(...arguments),this._lastRenderIndex=-1}render(e){this._render(e)}_render(e){let t=this.device.canvasContext,n=e.target??t.getCurrentFramebuffer(),[r,i]=t.getDrawingBufferSize(),a=e.clearCanvas??!0,o=e.clearColor??(a?[0,0,0,0]:!1),s=a?1:!1,c=a?0:!1,l=e.colorMask??15,u={viewport:[0,0,r,i]};e.colorMask&&(u.colorMask=l),e.scissorRect&&(u.scissorRect=e.scissorRect);let d=this.device.beginRenderPass({framebuffer:n,parameters:u,clearColor:o,clearDepth:s,clearStencil:c});try{return this._drawLayers(d,e)}finally{d.end(),this.device.submit()}}_drawLayers(e,t){let{target:n,shaderModuleProps:r,viewports:i,views:a,onViewportActive:o,clearStack:s=!0}=t;t.pass=t.pass||`unknown`,s&&(this._lastRenderIndex=-1);let c=[];for(let s of i){let i=a&&a[s.id];o?.(s);let l=this._getDrawLayerParams(s,t),u=s.subViewports||[s];for(let a of u){let o=this._drawLayersInViewport(e,{target:n,shaderModuleProps:r,viewport:a,view:i,pass:t.pass,layers:t.layers},l);c.push(o)}}return c}_getDrawLayerParams(e,{layers:t,pass:n,isPicking:r=!1,layerFilter:i,cullRect:a,effects:o,shaderModuleProps:s},c=!1){let l=[],u=vT(this._lastRenderIndex+1),d={layer:t[0],viewport:e,isPicking:r,renderPass:n,cullRect:a},f={};for(let r=0;r<t.length;r++){let a=t[r],p=this._shouldDrawLayer(a,d,i,f),m={shouldDrawLayer:p};p&&!c&&(m.shouldDrawLayer=!0,m.layerRenderIndex=u(a,p),m.shaderModuleProps=this._getShaderModuleProps(a,o,n,s),m.layerParameters={...a.context.device.type===`webgpu`?gT:null,...a.context.deck?.props.parameters,...this.getLayerParameters(a,r,e)}),l[r]=m}return l}_drawLayersInViewport(e,{layers:t,shaderModuleProps:n,pass:r,target:i,viewport:a,view:o},s){let c=yT(this.device,{shaderModuleProps:n,target:i,viewport:a});if(o){let{clear:e,clearColor:t,clearDepth:n,clearStencil:r}=o.props;if(e){let e=[0,0,0,0],a=1,o=0;Array.isArray(t)?e=[...t.slice(0,3),t[3]||255].map(e=>e/255):t===!1&&(e=!1),n!==void 0&&(a=n),r!==void 0&&(o=r),this.device.beginRenderPass({framebuffer:i,parameters:{viewport:c,scissorRect:c},clearColor:e,clearDepth:a,clearStencil:o}).end()}}let l={totalCount:t.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:c});for(let n=0;n<t.length;n++){let i=t[n],o=s[n],{shouldDrawLayer:c}=o;if(c&&i.props.pickable&&l.pickableCount++,i.isComposite&&l.compositeCount++,i.isDrawable&&o.shouldDrawLayer){let{layerRenderIndex:t,shaderModuleProps:n,layerParameters:s}=o;l.visibleCount++,this._lastRenderIndex=Math.max(this._lastRenderIndex,t),n.project&&(n.project.viewport=a),i.context.renderPass=e;try{i._drawLayer({renderPass:e,shaderModuleProps:n,uniforms:{layerIndex:t},parameters:s})}catch(e){i.raiseError(e,`drawing ${i} to ${r}`)}}}return l}shouldDrawLayer(e){return!0}getShaderModuleProps(e,t,n){return null}getLayerParameters(e,t,n){return e.props.parameters}_shouldDrawLayer(e,t,n,r){if(!(e.props.visible&&this.shouldDrawLayer(e)))return!1;t.layer=e;let i=e.parent;for(;i;){if(!i.props.visible||!i.filterSubLayer(t))return!1;t.layer=i,i=i.parent}if(n){let e=t.layer.id;if(e in r||(r[e]=n(t)),!r[e])return!1}return e.activateViewport(t.viewport),!0}_getShaderModuleProps(e,t,n,r){let i=this.device.canvasContext.cssToDeviceRatio(),a=e.internalState?.propsInTransition||e.props,o={layer:a,picking:{isActive:!1},project:{viewport:e.context.viewport,devicePixelRatio:i,modelMatrix:a.modelMatrix,coordinateSystem:a.coordinateSystem,coordinateOrigin:a.coordinateOrigin,autoWrapLongitude:e.wrapLongitude}};if(t)for(let n of t)bT(o,n.getShaderModuleProps?.(e,o));return bT(o,this.getShaderModuleProps(e,t,o),r)}};function vT(e=0,t={}){let n={},r=(i,a)=>{let o=i.props._offset,s=i.id,c=i.parent&&i.parent.id,l;if(c&&!(c in t)&&r(i.parent,!1),c in n){let e=n[c]=n[c]||vT(t[c],t);l=e(i,a),n[s]=e}else Number.isFinite(o)?(l=o+(t[c]||0),n[s]=null):l=e;return a&&l>=e&&(e=l+1),t[s]=l,l};return r}function yT(e,{shaderModuleProps:t,target:n,viewport:r}){let i=t?.project?.devicePixelRatio??e.canvasContext.cssToDeviceRatio(),[,a]=e.canvasContext.getDrawingBufferSize(),o=n?n.height:a,s=r;return[s.x*i,o-(s.y+s.height)*i,s.width*i,s.height*i]}function bT(e,...t){for(let n of t)if(n)for(let t in n)e[t]?Object.assign(e[t],n[t]):e[t]=n[t];return e}var xT=class extends _T{constructor(e,t){super(e,t);let n=e.createTexture({format:`rgba8unorm`,width:1,height:1,sampler:{minFilter:`linear`,magFilter:`linear`,addressModeU:`clamp-to-edge`,addressModeV:`clamp-to-edge`}}),r=e.createTexture({format:`depth16unorm`,width:1,height:1});this.fbo=e.createFramebuffer({id:`shadowmap`,width:1,height:1,colorAttachments:[n],depthStencilAttachment:r})}delete(){this.fbo&&=(this.fbo.destroy(),null)}getShadowMap(){return this.fbo.colorAttachments[0].texture}render(e){let t=this.fbo,n=this.device.canvasContext.cssToDeviceRatio(),r=e.viewports[0],i=r.width*n,a=r.height*n,o=[1,1,1,1];(i!==t.width||a!==t.height)&&t.resize({width:i,height:a}),super.render({...e,clearColor:o,target:t,pass:`shadow`})}getLayerParameters(e,t,n){return{...e.props.parameters,blend:!1,depthWriteEnabled:!0,depthCompare:`less-equal`}}shouldDrawLayer(e){return e.props.shadowEnabled!==!1}getShaderModuleProps(e,t,n){return{shadow:{project:n.project,drawToShadowMap:!0}}}},ST={color:[255,255,255],intensity:1},CT=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],wT=[0,0,0,200/255],TT=class{constructor(e={}){this.id=`lighting-effect`,this.shadowColor=wT,this.shadow=!1,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;let{device:t,deck:n}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(t),n._addDefaultShaderModule($w),this.dummyShadowMap=t.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=void 0,this.directionalLights=[],this.pointLights=[];for(let t in e){let n=e[t];switch(n.type){case`ambient`:this.ambientLight=n;break;case`directional`:this.directionalLights.push(n);break;case`point`:this.pointLights.push(n);break;default:}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(e=>e.shadow),this.context&&this.setup(this.context),this.props=e}preRender({layers:e,layerFilter:t,viewports:n,onViewportActive:r,views:i}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let a=0;a<this.shadowPasses.length;a++)this.shadowPasses[a].render({layers:e,layerFilter:t,viewports:n,onViewportActive:r,views:i,shaderModuleProps:{shadow:{shadowLightId:a,dummyShadowMap:this.dummyShadowMap,shadowMatrices:this.shadowMatrices}}})}}getShaderModuleProps(e,t){let n=this.shadow?{project:t.project,shadowMaps:this.shadowPasses.map(e=>e.getShadowMap()),dummyShadowMap:this.dummyShadowMap,shadowColor:this.shadowColor,shadowMatrices:this.shadowMatrices}:{},r={enabled:!0,lights:this._getLights(e)},i=e.props.material;return{shadow:n,lighting:r,phongMaterial:i,gouraudMaterial:i}}cleanup(e){for(let e of this.shadowPasses)e.delete();this.shadowPasses.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,e.deck._removeDefaultShaderModule($w))}_calculateMatrices(){let e=[];for(let t of this.directionalLights){let n=new Mv().lookAt({eye:new rv(t.direction).negate()});e.push(n)}return e}_createShadowPasses(e){for(let t=0;t<this.directionalLights.length;t++){let n=new xT(e);this.shadowPasses[t]=n}}_applyDefaultLights(){let{ambientLight:e,pointLights:t,directionalLights:n}=this;!e&&t.length===0&&n.length===0&&(this.ambientLight=new lT(ST),this.directionalLights.push(new mT(CT[0]),new mT(CT[1])))}_getLights(e){let t=[];this.ambientLight&&t.push(this.ambientLight);for(let n of this.pointLights)t.push(n.getProjectedLight({layer:e}));for(let n of this.directionalLights)t.push(n.getProjectedLight({layer:e}));return t}},ET=new class{constructor(e={}){this._pool=[],this.opts={overAlloc:2,poolSize:100},this.setOptions(e)}setOptions(e){Object.assign(this.opts,e)}allocate(e,t,{size:n=1,type:r,padding:i=0,copy:a=!1,initialize:o=!1,maxCount:s}){let c=r||e&&e.constructor||Float32Array,l=t*n+i;if(ArrayBuffer.isView(e)){if(l<=e.length)return e;if(l*e.BYTES_PER_ELEMENT<=e.buffer.byteLength)return new c(e.buffer,0,l)}let u=1/0;s&&(u=s*n+i);let d=this._allocate(c,l,o,u);return e&&a?d.set(e):o||d.fill(0,0,4),this._release(e),d}release(e){this._release(e)}_allocate(e,t,n,r){let i=Math.max(Math.ceil(t*this.opts.overAlloc),1);i>r&&(i=r);let a=this._pool,o=e.BYTES_PER_ELEMENT*i,s=a.findIndex(e=>e.byteLength>=o);if(s>=0){let t=new e(a.splice(s,1)[0],0,i);return n&&t.fill(0),t}return new e(i)}_release(e){if(!ArrayBuffer.isView(e))return;let t=this._pool,{buffer:n}=e,{byteLength:r}=n,i=t.findIndex(e=>e.byteLength>=r);i<0?t.push(n):(i>0||t.length<this.opts.poolSize)&&t.splice(i,0,n),t.length>this.opts.poolSize&&t.shift()}};function DT(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function OT(e,t){let n=e%t;return n<0?t+n:n}function kT(e){return[e[12],e[13],e[14]]}function AT(e){return{left:MT(e[3]+e[0],e[7]+e[4],e[11]+e[8],e[15]+e[12]),right:MT(e[3]-e[0],e[7]-e[4],e[11]-e[8],e[15]-e[12]),bottom:MT(e[3]+e[1],e[7]+e[5],e[11]+e[9],e[15]+e[13]),top:MT(e[3]-e[1],e[7]-e[5],e[11]-e[9],e[15]-e[13]),near:MT(e[3]+e[2],e[7]+e[6],e[11]+e[10],e[15]+e[14]),far:MT(e[3]-e[2],e[7]-e[6],e[11]-e[10],e[15]-e[14])}}var jT=new rv;function MT(e,t,n,r){jT.set(e,t,n);let i=jT.len();return{distance:r/i,normal:new rv(-e/i,-t/i,-n/i)}}function NT(e){return e-Math.fround(e)}var PT;function FT(e,t){let{size:n=1,startIndex:r=0}=t,i=t.endIndex===void 0?e.length:t.endIndex,a=(i-r)/n;PT=ET.allocate(PT,a,{type:Float32Array,size:n*2});let o=r,s=0;for(;o<i;){for(let t=0;t<n;t++){let r=e[o++];PT[s+t]=r,PT[s+t+n]=NT(r)}s+=n*2}return PT.subarray(0,a*n*2)}function IT(e){let t=null,n=!1;for(let r of e)r&&(t?(n||=(t=[[t[0][0],t[0][1]],[t[1][0],t[1][1]]],!0),t[0][0]=Math.min(t[0][0],r[0][0]),t[0][1]=Math.min(t[0][1],r[0][1]),t[1][0]=Math.max(t[1][0],r[1][0]),t[1][1]=Math.max(t[1][1],r[1][1])):t=r);return t}var LT=Math.PI/180,RT=DT(),zT=[0,0,0],BT={unitsPerMeter:[1,1,1],metersPerUnit:[1,1,1]};function VT({width:e,height:t,orthographic:n,fovyRadians:r,focalDistance:i,padding:a,near:o,far:s}){let c=e/t,l=n?new Mv().orthographic({fovy:r,aspect:c,focalDistance:i,near:o,far:s}):new Mv().perspective({fovy:r,aspect:c,near:o,far:s});if(a){let{left:n=0,right:r=0,top:i=0,bottom:o=0}=a,s=f_((n+e-r)/2,0,e)-e/2,c=f_((i+t-o)/2,0,t)-t/2;l[8]-=s*2/e,l[9]+=c*2/t}return l}var HT=class e{constructor(e={}){this._frustumPlanes={},this.id=e.id||this.constructor.displayName||`viewport`,this.x=e.x||0,this.y=e.y||0,this.width=e.width||1,this.height=e.height||1,this.zoom=e.zoom||0,this.padding=e.padding,this.distanceScales=e.distanceScales||BT,this.focalDistance=e.focalDistance||1,this.position=e.position||zT,this.modelMatrix=e.modelMatrix||null;let{longitude:t,latitude:n}=e;this.isGeospatial=Number.isFinite(n)&&Number.isFinite(t),this._initProps(e),this._initMatrices(e),this.equals=this.equals.bind(this),this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.projectPosition=this.projectPosition.bind(this),this.unprojectPosition=this.unprojectPosition.bind(this),this.projectFlat=this.projectFlat.bind(this),this.unprojectFlat=this.unprojectFlat.bind(this)}get subViewports(){return null}get metersPerPixel(){return this.distanceScales.metersPerUnit[2]/this.scale}get projectionMode(){return this.isGeospatial?this.zoom<12?BC.WEB_MERCATOR:BC.WEB_MERCATOR_AUTO_OFFSET:BC.IDENTITY}equals(t){return t instanceof e?this===t?!0:t.width===this.width&&t.height===this.height&&t.scale===this.scale&&m_(t.projectionMatrix,this.projectionMatrix)&&m_(t.viewMatrix,this.viewMatrix):!1}project(e,{topLeft:t=!0}={}){let n=Fw(this.projectPosition(e),this.pixelProjectionMatrix),[r,i]=n,a=t?i:this.height-i;return e.length===2?[r,a]:[r,a,n[2]]}unproject(e,{topLeft:t=!0,targetZ:n}={}){let[r,i,a]=e,o=t?i:this.height-i,s=n&&n*this.distanceScales.unitsPerMeter[2],c=Iw([r,o,a],this.pixelUnprojectionMatrix,s),[l,u,d]=this.unprojectPosition(c);return Number.isFinite(a)?[l,u,d]:Number.isFinite(n)?[l,u,n]:[l,u]}projectPosition(e){let[t,n]=this.projectFlat(e);return[t,n,(e[2]||0)*this.distanceScales.unitsPerMeter[2]]}unprojectPosition(e){let[t,n]=this.unprojectFlat(e);return[t,n,(e[2]||0)*this.distanceScales.metersPerUnit[2]]}projectFlat(e){if(this.isGeospatial){let t=Tw(e);return t[1]=f_(t[1],-318,830),t}return e}unprojectFlat(e){return this.isGeospatial?Ew(e):e}getBounds(e={}){let t={targetZ:e.z||0},n=this.unproject([0,0],t),r=this.unproject([this.width,0],t),i=this.unproject([0,this.height],t),a=this.unproject([this.width,this.height],t);return[Math.min(n[0],r[0],i[0],a[0]),Math.min(n[1],r[1],i[1],a[1]),Math.max(n[0],r[0],i[0],a[0]),Math.max(n[1],r[1],i[1],a[1])]}getDistanceScales(e){return e&&this.isGeospatial?kw({longitude:e[0],latitude:e[1],highPrecision:!0}):this.distanceScales}containsPixel({x:e,y:t,width:n=1,height:r=1}){return e<this.x+this.width&&this.x<e+n&&t<this.y+this.height&&this.y<t+r}getFrustumPlanes(){return this._frustumPlanes.near||Object.assign(this._frustumPlanes,AT(this.viewProjectionMatrix)),this._frustumPlanes}panByPosition(e,t,n){return null}_initProps(e){let t=e.longitude,n=e.latitude;this.isGeospatial&&(Number.isFinite(e.zoom)||(this.zoom=Dw({latitude:n})+Math.log2(this.focalDistance)),this.distanceScales=e.distanceScales||kw({latitude:n,longitude:t}));let r=2**this.zoom;this.scale=r;let{position:i,modelMatrix:a}=e,o=zT;if(i&&(o=a?new Mv(a).transformAsVector(i,[]):i),this.isGeospatial){let e=this.projectPosition([t,n,0]);this.center=new rv(o).scale(this.distanceScales.unitsPerMeter).add(e)}else this.center=this.projectPosition(o)}_initMatrices(e){let{viewMatrix:t=RT,projectionMatrix:n=null,orthographic:r=!1,fovyRadians:i,fovy:a=75,near:o=.1,far:s=1e3,padding:c=null,focalDistance:l=1}=e;this.viewMatrixUncentered=t,this.viewMatrix=new Mv().multiplyRight(t).translate(new rv(this.center).negate()),this.projectionMatrix=n||VT({width:this.width,height:this.height,orthographic:r,fovyRadians:i||a*LT,focalDistance:l,padding:c,near:o,far:s});let u=DT();lv(u,u,this.projectionMatrix),lv(u,u,this.viewMatrix),this.viewProjectionMatrix=u,this.viewMatrixInverse=sv([],this.viewMatrix)||this.viewMatrix,this.cameraPosition=kT(this.viewMatrixInverse);let d=DT(),f=DT();dv(d,d,[this.width/2,-this.height/2,1]),uv(d,d,[1,-1,0]),lv(f,d,this.viewProjectionMatrix),this.pixelProjectionMatrix=f,this.pixelUnprojectionMatrix=sv(DT(),this.pixelProjectionMatrix),this.pixelUnprojectionMatrix||X.warn(`Pixel project matrix not invertible`)()}};HT.displayName=`Viewport`;var UT=class e extends HT{constructor(e={}){let{latitude:t=0,longitude:n=0,zoom:r=0,pitch:i=0,bearing:a=0,nearZMultiplier:o=.1,farZMultiplier:s=1.01,nearZ:c,farZ:l,orthographic:u=!1,projectionMatrix:d,repeat:f=!1,worldOffset:p=0,position:m,padding:h,legacyMeterSizes:g=!1}=e,{width:_,height:v,altitude:y=1.5}=e,b=2**r;_||=1,v||=1;let x,S=null;if(d)y=d[5]/2,x=Nw(y);else{e.fovy?(x=e.fovy,y=Pw(x)):x=Nw(y);let n;if(h){let{top:e=0,bottom:t=0}=h;n=[0,f_((e+v-t)/2,0,v)-v/2]}S=Mw({width:_,height:v,scale:b,center:m&&[0,0,m[2]*Ow(t)],offset:n,pitch:i,fovy:x,nearZMultiplier:o,farZMultiplier:s}),Number.isFinite(c)&&(S.near=c),Number.isFinite(l)&&(S.far=l)}let C=jw({height:v,pitch:i,bearing:a,scale:b,altitude:y});p&&(C=new Mv().translate([512*p,0,0]).multiplyLeft(C)),super({...e,width:_,height:v,viewMatrix:C,longitude:n,latitude:t,zoom:r,...S,fovy:x,focalDistance:y}),this.latitude=t,this.longitude=n,this.zoom=r,this.pitch=i,this.bearing=a,this.altitude=y,this.fovy=x,this.orthographic=u,this._subViewports=f?[]:null,this._pseudoMeters=g,Object.freeze(this)}get subViewports(){if(this._subViewports&&!this._subViewports.length){let t=this.getBounds(),n=Math.floor((t[0]+180)/360),r=Math.ceil((t[2]-180)/360);for(let t=n;t<=r;t++){let n=t?new e({...this,worldOffset:t}):this;this._subViewports.push(n)}}return this._subViewports}projectPosition(e){if(this._pseudoMeters)return super.projectPosition(e);let[t,n]=this.projectFlat(e);return[t,n,(e[2]||0)*Ow(e[1])]}unprojectPosition(e){if(this._pseudoMeters)return super.unprojectPosition(e);let[t,n]=this.unprojectFlat(e);return[t,n,(e[2]||0)/Ow(n)]}addMetersToLngLat(e,t){return Aw(e,t)}panByPosition(e,t,n){let r=Iw(t,this.pixelUnprojectionMatrix),i=E_([],this.projectFlat(e),O_([],r)),a=E_([],this.center,i),[o,s]=this.unprojectFlat(a);return{longitude:o,latitude:s}}panByPosition3D(e,t){let n=e[2]||0,r=j_([],e,this.unproject(t,{targetZ:n}));return{longitude:this.longitude+r[0],latitude:this.latitude+r[1]}}getBounds(e={}){let t=Bw(this,e.z||0);return[Math.min(t[0][0],t[1][0],t[2][0],t[3][0]),Math.min(t[0][1],t[1][1],t[2][1],t[3][1]),Math.max(t[0][0],t[1][0],t[2][0],t[3][0]),Math.max(t[0][1],t[1][1],t[2][1],t[3][1])]}fitBounds(t,n={}){let{width:r,height:i}=this,{longitude:a,latitude:o,zoom:s}=Lw({width:r,height:i,bounds:t,...n});return new e({width:r,height:i,longitude:a,latitude:o,zoom:s})}};UT.displayName=`WebMercatorViewport`;var WT=[0,0,0];function GT(e,t,n=!1){let r=t.projectPosition(e);if(n&&t instanceof UT){let[n,i,a=0]=e;r[2]=a*t.getDistanceScales([n,i]).unitsPerMeter[2]}return r}function KT(e){let{viewport:t,modelMatrix:n,coordinateOrigin:r}=e,{coordinateSystem:i,fromCoordinateSystem:a,fromCoordinateOrigin:o}=e;return i===`default`&&(i=t.isGeospatial?`lnglat`:`cartesian`),a===void 0?a=i:a===`default`&&(a=t.isGeospatial?`lnglat`:`cartesian`),o===void 0&&(o=r),{viewport:t,coordinateSystem:i,coordinateOrigin:r,modelMatrix:n,fromCoordinateSystem:a,fromCoordinateOrigin:o}}function qT(e,{viewport:t,modelMatrix:n,coordinateSystem:r,coordinateOrigin:i,offsetMode:a}){let[o,s,c=0]=e;switch(n&&([o,s,c]=Tv([],[o,s,c,1],n)),r){case`default`:return qT(e,{viewport:t,modelMatrix:n,coordinateSystem:t.isGeospatial?`lnglat`:`cartesian`,coordinateOrigin:i,offsetMode:a});case`lnglat`:return GT([o,s,c],t,a);case`lnglat-offsets`:return GT([o+i[0],s+i[1],c+(i[2]||0)],t,a);case`meter-offsets`:return GT(Aw(i,[o,s,c]),t,a);case`cartesian`:return t.isGeospatial?[o+i[0],s+i[1],c+i[2]]:t.projectPosition([o,s,c]);default:throw Error(`Invalid coordinateSystem: ${r}`)}}function JT(e,t){let{viewport:n,coordinateSystem:r,coordinateOrigin:i,modelMatrix:a,fromCoordinateSystem:o,fromCoordinateOrigin:s}=KT(t),{autoOffset:c=!0}=t,{geospatialOrigin:l=WT,shaderCoordinateOrigin:u=WT,offsetMode:d=!1}=c?ew(n,r,i):{},f=qT(e,{viewport:n,modelMatrix:a,coordinateSystem:o,coordinateOrigin:s,offsetMode:d});return d&&Z_(f,f,n.projectPosition(l||u)),f}var YT=1,XT=1,ZT=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(e){let{delay:t=0,duration:n=1/0,rate:r=1,repeat:i=1}=e,a=YT++,o={time:0,delay:t,duration:n,rate:r,repeat:i};return this._setChannelTime(o,this.time),this.channels.set(a,o),a}removeChannel(e){this.channels.delete(e);for(let[t,n]of this.animations)n.channel===e&&this.detachAnimation(t)}isFinished(e){let t=this.channels.get(e);return t===void 0?!1:this.time>=t.delay+t.duration*t.repeat}getTime(e){if(e===void 0)return this.time;let t=this.channels.get(e);return t===void 0?-1:t.time}setTime(e){this.time=Math.max(0,e);let t=this.channels.values();for(let e of t)this._setChannelTime(e,this.time);let n=this.animations.values();for(let e of n){let{animation:t,channel:n}=e;t.setTime(this.getTime(n))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,t){let n=XT++;return this.animations.set(n,{animation:e,channel:t}),e.setTime(this.getTime(t)),n}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,t){let n=t-e.delay;n>=e.duration*e.repeat?e.time=e.duration*e.rate:(e.time=Math.max(0,n)%e.duration,e.time*=e.rate)}};function QT(e){let t=typeof window<`u`?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame:null;return t?t.call(window,e):setTimeout(()=>e(typeof performance<`u`?performance.now():Date.now()),1e3/60)}function $T(e){let t=typeof window<`u`?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame:null;if(t){t.call(window,e);return}clearTimeout(e)}var eE=0,tE=`Animation Loop`,nE=class e{static defaultAnimationLoopProps={device:null,onAddHTML:()=>``,onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:e=>console.error(e),stats:void 0,autoResizeViewport:!1};device=null;canvas=null;props;animationProps=null;timeline=null;stats;sharedStats;cpuTime;gpuTime;frameRate;display;_needsRedraw=`initialized`;_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;_error=null;_lastFrameTime=0;constructor(t){if(this.props={...e.defaultAnimationLoopProps,...t},t=this.props,!t.device)throw Error(`No device provided`);this.stats=t.stats||new Of({id:`animation-loop-${eE++}`}),this.sharedStats=vb.stats.get(tE),this.frameRate=this.stats.get(`Frame Rate`),this.frameRate.setSampleSize(1),this.cpuTime=this.stats.get(`CPU Time`),this.gpuTime=this.stats.get(`GPU Time`),this.setProps({autoResizeViewport:t.autoResizeViewport}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null),this.device?._disableDebugGPUTime()}delete(){this.destroy()}reportError(e){this.props.onError(e),this._error=e}setNeedsRedraw(e){return this._needsRedraw=this._needsRedraw||e,this}needsRedraw(){let e=this._needsRedraw;return this._needsRedraw=!1,e}setProps(e){return`autoResizeViewport`in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),this}async start(){if(this._running)return this;this._running=!0;try{if(!this._initialized){if(this._initialized=!0,await this._initDevice(),this._initialize(),!this._running)return null;await this.props.onInitialize(this._getAnimationProps())}return this._running?(this._cancelAnimationFrame(),this._requestAnimationFrame(),this):null}catch(e){let t=e instanceof Error?e:Error(`Unknown error`);throw this.props.onError(t),t}}stop(){return this._running&&(this.animationProps&&!this._error&&this.props.onFinalize(this.animationProps),this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1,this._lastFrameTime=0),this}redraw(e){return this.device?.isLost||this._error?this:(this._beginFrameTimers(e),this._setupFrame(),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&=(this._resolveNextFrame(this),this._nextFramePromise=null,null),this._endFrameTimers(),this)}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw(`waitForRender`),this._nextFramePromise||=new Promise(e=>{this._resolveNextFrame=e}),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw(`toDataURL`),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw Error(`OffscreenCanvas`)}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeViewport(),this.device?._enableDebugGPUTime()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){this._running&&(this._animationFrameId=QT(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&($T(this._animationFrameId),this._animationFrameId=null)}_animationFrame(e){this._running&&(this.redraw(e),this._requestAnimationFrame())}_renderFrame(e){if(this.display){this.display._renderFrame(e);return}this.props.onRender(this._getAnimationProps()),this.device?.submit()}_clearNeedsRedraw(){this._needsRedraw=!1}_setupFrame(){this._resizeViewport()}_initializeAnimationProps(){let e=this.device?.getDefaultCanvasContext();if(!this.device||!e)throw Error(`loop`);let t=e?.canvas,n=e.props.useDevicePixels;this.animationProps={animationLoop:this,device:this.device,canvasContext:e,canvas:t,useDevicePixels:n,timeline:this.timeline,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw Error(`animationProps`);return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;let{width:e,height:t,aspect:n}=this._getSizeAndAspect();(e!==this.animationProps.width||t!==this.animationProps.height)&&this.setNeedsRedraw(`drawing buffer resized`),n!==this.animationProps.aspect&&this.setNeedsRedraw(`drawing buffer aspect changed`),this.animationProps.width=e,this.animationProps.height=t,this.animationProps.aspect=n,this.animationProps.needsRedraw=this._needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw Error(`No device provided`);this.canvas=this.device.getDefaultCanvasContext().canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){let e=document.createElement(`div`);document.body.appendChild(e),e.style.position=`relative`;let t=document.createElement(`div`);t.style.position=`absolute`,t.style.left=`10px`,t.style.bottom=`10px`,t.style.width=`300px`,t.style.background=`white`,this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(t);let n=this.props.onAddHTML(t);n&&(t.innerHTML=n)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[e,t]=this.device.getDefaultCanvasContext().getDrawingBufferSize();return{width:e,height:t,aspect:e>0&&t>0?e/t:1}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_beginFrameTimers(e){let t=e??(typeof performance<`u`?performance.now():Date.now());if(this._lastFrameTime){let e=t-this._lastFrameTime;e>0&&this.frameRate.addTime(e)}this._lastFrameTime=t,this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeStart()}_endFrameTimers(){this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeEnd(),this._updateSharedStats()}_consumeEncodedGpuTime(){if(!this.device)return;let e=this.device.commandEncoder._gpuTimeMs;e!==void 0&&(this.gpuTime.addTime(e),this.device.commandEncoder._gpuTimeMs=void 0)}_updateSharedStats(){if(this.stats!==this.sharedStats){for(let e of Object.keys(this.sharedStats.stats))this.stats.stats[e]||delete this.sharedStats.stats[e];this.stats.forEach(e=>{let t=this.sharedStats.get(e.name,e.type);t.sampleSize=e.sampleSize,t.time=e.time,t.count=e.count,t.samples=e.samples,t.lastTiming=e.lastTiming,t.lastSampleTime=e.lastSampleTime,t.lastSampleCount=e.lastSampleCount,t._count=e._count,t._time=e._time,t._samples=e._samples,t._startTime=e._startTime,t._timerPending=e._timerPending})}}_startEventHandling(){this.canvas&&(this.canvas.addEventListener(`mousemove`,this._onMousemove.bind(this)),this.canvas.addEventListener(`mouseleave`,this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}},rE={};function iE(e=`id`){return rE[e]=rE[e]||1,`${e}-${rE[e]++}`}var aE=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){if(this.id=e.id||iE(`geometry`),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&!(this.indices.usage&Sy.INDEX))throw Error(`Index buffer must have INDEX usage`)}destroy(){this.indices?.destroy();for(let e of Object.values(this.attributes))e.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(e){return e.byteLength/12}};function oE(e,t){if(t instanceof aE)return t;let n=sE(e,t),{attributes:r,bufferLayout:i}=cE(e,t);return new aE({topology:t.topology||`triangle-list`,bufferLayout:i,vertexCount:t.vertexCount,indices:n,attributes:r})}function sE(e,t){if(!t.indices)return;let n=t.indices.value;return e.createBuffer({usage:Sy.INDEX,data:n})}function cE(e,t){let n=[],r={};for(let[i,a]of Object.entries(t.attributes)){let t=i;switch(i){case`POSITION`:t=`positions`;break;case`NORMAL`:t=`normals`;break;case`TEXCOORD_0`:t=`texCoords`;break;case`TEXCOORD_1`:t=`texCoords1`;break;case`COLOR_0`:t=`colors`;break}if(a){r[t]=e.createBuffer({data:a.value,id:`${i}-buffer`});let{value:o,size:s,normalized:c}=a;if(s===void 0)throw Error(`Attribute ${i} is missing a size`);n.push({name:t,format:Ty.getVertexFormatFromAttribute(o,s,c)})}}return{attributes:r,bufferLayout:n,vertexCount:t._calculateVertexCount(t.attributes,t.indices)}}function lE(e,t){let n={},r=`Values`;if(e.attributes.length===0&&!e.varyings?.length)return{"No attributes or varyings":{[r]:`N/A`}};for(let t of e.attributes)if(t){let e=`${t.location} ${t.name}: ${t.type}`;n[`in ${e}`]={[r]:t.stepMode||`vertex`}}for(let t of e.varyings||[]){let e=`${t.location} ${t.name}`;n[`out ${e}`]={[r]:JSON.stringify(t)}}return n}var uE=`__debugFramebufferState`,dE=8;function fE(e,t,n){if(e.device.type!==`webgl`)return;let r=hE(e.device);if(!r.flushing){if(_E(e)){pE(e,n,r);return}t&&gE(t)&&t.handle!==null&&(r.queuedFramebuffers.includes(t)||r.queuedFramebuffers.push(t))}}function pE(e,t,n){if(n.queuedFramebuffers.length===0)return;let{gl:r}=e.device,i=r.getParameter(36010),a=r.getParameter(36006),[o,s]=e.device.getDefaultCanvasContext().getDrawingBufferSize(),c=vE(t.top,dE),l=vE(t.left,dE);n.flushing=!0;try{for(let e of n.queuedFramebuffers){let[n,i,a,u,d]=mE({framebuffer:e,targetWidth:o,targetHeight:s,topPx:c,leftPx:l,minimap:t.minimap});r.bindFramebuffer(36008,e.handle),r.bindFramebuffer(36009,null),r.blitFramebuffer(0,0,e.width,e.height,n,i,a,u,16384,9728),c+=d+dE}}finally{r.bindFramebuffer(36008,i),r.bindFramebuffer(36009,a),n.flushing=!1}}function mE(e){let{framebuffer:t,targetWidth:n,targetHeight:r,topPx:i,leftPx:a,minimap:o}=e,s=o?Math.max(Math.floor(n/4),1):n,c=o?Math.max(Math.floor(r/4),1):r,l=Math.min(s/t.width,c/t.height),u=Math.max(Math.floor(t.width*l),1),d=Math.max(Math.floor(t.height*l),1),f=a,p=Math.max(r-i-d,0);return[f,p,f+u,p+d,d]}function hE(e){return e.userData[uE]||={flushing:!1,queuedFramebuffers:[]},e.userData[uE]}function gE(e){return`colorAttachments`in e}function _E(e){let t=e.props.framebuffer;return!t||t.handle===null}function vE(e,t){if(!e)return t;let n=Number.parseInt(e,10);return Number.isFinite(n)?n:t}function yE(e,t,n){if(e===t)return!0;if(!n||!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!yE(e[r],t[r],n-1))return!1;return!0}if(Array.isArray(t))return!1;if(typeof e==`object`&&typeof t==`object`){let r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;for(let i of r)if(!t.hasOwnProperty(i)||!yE(e[i],t[i],n-1))return!1;return!0}return!1}var bE=class{bufferLayouts;constructor(e){this.bufferLayouts=e}getBufferLayout(e){return this.bufferLayouts.find(t=>t.name===e)||null}getAttributeNamesForBuffer(e){return e.attributes?e.attributes?.map(e=>e.attribute):[e.name]}mergeBufferLayouts(e,t){let n=[...e];for(let e of t){let t=n.findIndex(t=>t.name===e.name);t<0?n.push(e):n[t]=e}return n}getBufferIndex(e){let t=this.bufferLayouts.findIndex(t=>t.name===e);return t===-1&&Z.warn(`BufferLayout: Missing buffer for "${e}".`)(),t}};function xE(e,t){let n=1/0;for(let r of e){let e=t[r];e!==void 0&&(n=Math.min(n,e))}return n}function SE(e,t){let n=Object.fromEntries(e.attributes.map(e=>[e.name,e.location])),r=t.slice();return r.sort((e,t)=>{let r=e.attributes?e.attributes.map(e=>e.attribute):[e.name],i=t.attributes?t.attributes.map(e=>e.attribute):[t.name];return xE(r,n)-xE(i,n)}),r}function CE(e,t){if(!e||!t.some(e=>e.bindingLayout?.length))return e;let n={...e,bindings:e.bindings.map(e=>({...e}))};`attributes`in(e||{})&&(n.attributes=e?.attributes||[]);for(let e of t)for(let t of e.bindingLayout||[])for(let e of TE(t.name)){let r=n.bindings.find(t=>t.name===e);r?.group===0&&(r.group=t.group)}return n}function wE(e){return!!(e.uniformTypes&&!EE(e.uniformTypes))}function TE(e){let t=new Set([e,`${e}Uniforms`]);return e.endsWith(`Uniforms`)||t.add(`${e}Sampler`),[...t]}function EE(e){for(let t in e)return!1;return!0}function DE(e){return mm(e)||typeof e==`number`||typeof e==`boolean`}function OE(e,t={}){let n={bindings:{},uniforms:{}};return Object.keys(e).forEach(r=>{let i=e[r];Object.prototype.hasOwnProperty.call(t,r)||DE(i)?n.uniforms[r]=i:n.bindings[r]=i}),n}var kE=class{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;constructor(e,t){Object.assign(this.options,t);let n=Eh(Object.values(e).filter(FE));for(let t of n)e[t.name]=t;Z.log(1,`Creating ShaderInputs with modules`,Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(let[t,n]of Object.entries(e))n&&(this._addModule(n),n.name&&t!==n.name&&!this.options.disableWarnings&&Z.warn(`Module name: ${t} vs ${n.name}`)())}destroy(){}setProps(e){for(let t of Object.keys(e)){let n=t,r=e[n]||{},i=this.modules[n];if(!i)this.options.disableWarnings||Z.warn(`Module ${t} not found`)();else{let e=this.moduleUniforms[n],t=this.moduleBindings[n],{uniforms:a,bindings:o}=OE(i.getUniforms?.(r,e)||r,i.uniformTypes);this.moduleUniforms[n]=AE(e,a,i.uniformTypes),this.moduleBindings[n]={...t,...o}}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindingValues(){let e={};for(let t of Object.values(this.moduleBindings))Object.assign(e,t);return e}getDebugTable(){let e={};for(let[t,n]of Object.entries(this.moduleUniforms))for(let[r,i]of Object.entries(n))e[`${t}.${r}`]={type:this.modules[t].uniformTypes?.[r],value:String(i)};return e}_addModule(e){let t=e.name;this.moduleUniforms[t]=AE({},e.defaultUniforms||{},e.uniformTypes),this.moduleBindings[t]={}}};function AE(e={},t={},n={}){let r={...e};for(let[i,a]of Object.entries(t))a!==void 0&&(r[i]=jE(e[i],a,n[i]));return r}function jE(e,t,n){if(!n||typeof n==`string`)return ME(t);if(Array.isArray(n)){if(NE(t)||!Array.isArray(t))return ME(t);let r=Array.isArray(e)&&!NE(e)?[...e]:[],i=r.slice();for(let e=0;e<t.length;e++){let a=t[e];a!==void 0&&(i[e]=jE(r[e],a,n[0]))}return i}if(!PE(t))return ME(t);let r=n,i=PE(e)?e:{},a={...i};for(let[e,n]of Object.entries(t))n!==void 0&&(a[e]=jE(i[e],n,r[e]));return a}function ME(e){return ArrayBuffer.isView(e)?Array.prototype.slice.call(e):Array.isArray(e)?NE(e)?e.slice():e.map(e=>e===void 0?void 0:ME(e)):PE(e)?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t===void 0?void 0:ME(t)])):e}function NE(e){return ArrayBuffer.isView(e)||Array.isArray(e)&&(e.length===0||typeof e[0]==`number`)}function PE(e){return!!e&&typeof e==`object`&&!Array.isArray(e)&&!ArrayBuffer.isView(e)}function FE(e){return!!e?.dependencies}var IE={"+X":0,"-X":1,"+Y":2,"-Y":3,"+Z":4,"-Z":5};function LE(e){return e?Array.isArray(e)?e[0]??null:e:null}function RE(e){let{dimension:t,data:n}=e;if(!n)return null;switch(t){case`1d`:{let e=LE(n);if(!e)return null;let{width:t}=zE(e);return{width:t,height:1}}case`2d`:{let e=LE(n);return e?zE(e):null}case`3d`:case`2d-array`:{if(!Array.isArray(n)||n.length===0)return null;let e=LE(n[0]);return e?zE(e):null}case`cube`:{let e=Object.keys(n)[0]??null;if(!e)return null;let t=n[e],r=LE(t);return r?zE(r):null}case`cube-array`:{if(!Array.isArray(n)||n.length===0)return null;let e=n[0],t=Object.keys(e)[0]??null;if(!t)return null;let r=LE(e[t]);return r?zE(r):null}default:return null}}function zE(e){if(rb(e))return ib(e);if(typeof e==`object`&&`width`in e&&`height`in e)return{width:e.width,height:e.height};throw Error(`Unsupported mip-level data`)}function BE(e){return typeof e==`object`&&!!e&&`data`in e&&`width`in e&&`height`in e}function VE(e){return ArrayBuffer.isView(e)}function HE(e){let{textureFormat:t,format:n}=e;if(t&&n&&t!==n)throw Error(`Conflicting texture formats "${t}" and "${n}" provided for the same mip level`);return t??n}function UE(e){let t=IE[e];if(t===void 0)throw Error(`Invalid cube face: ${e}`);return t}function WE(e,t){return 6*e+UE(t)}function GE(e){throw Error(`setTexture1DData not supported in WebGL.`)}function KE(e){return Array.isArray(e)?e:[e]}function qE(e,t,n,r){let i=KE(t),a=e,o=[];for(let e=0;e<i.length;e++){let t=i[e];if(rb(t))o.push({type:`external-image`,image:t,z:a,mipLevel:e});else if(BE(t))o.push({type:`texture-data`,data:t,textureFormat:HE(t),z:a,mipLevel:e});else if(VE(t)&&n)o.push({type:`texture-data`,data:{data:t,width:Math.max(1,n.width>>e),height:Math.max(1,n.height>>e),...r?{format:r}:{}},textureFormat:r,z:a,mipLevel:e});else throw Error(`Unsupported 2D mip-level payload`)}return o}function JE(e){let t=[];for(let n=0;n<e.length;n++)t.push(...qE(n,e[n]));return t}function YE(e){let t=[];for(let n=0;n<e.length;n++)t.push(...qE(n,e[n]));return t}function XE(e){let t=[];for(let[n,r]of Object.entries(e)){let e=UE(n);t.push(...qE(e,r))}return t}function ZE(e){let t=[];return e.forEach((e,n)=>{for(let[r,i]of Object.entries(e)){let e=WE(n,r);t.push(...qE(e,i))}}),t}var QE=class e{device;id;props;_texture=null;_sampler=null;_view=null;ready;isReady=!1;destroyed=!1;resolveReady=()=>{};rejectReady=()=>{};get texture(){if(!this._texture)throw Error(`Texture not initialized yet`);return this._texture}get sampler(){if(!this._sampler)throw Error(`Sampler not initialized yet`);return this._sampler}get view(){if(!this._view)throw Error(`View not initialized yet`);return this._view}get[Symbol.toStringTag](){return`DynamicTexture`}toString(){let e=this._texture?.width??this.props.width??`?`,t=this._texture?.height??this.props.height??`?`;return`DynamicTexture:"${this.id}":${e}x${t}px:(${this.isReady?`ready`:`loading...`})`}constructor(t,n){this.device=t;let r=iE(`dynamic-texture`),i=n;this.props={...e.defaultProps,id:r,...n,data:null},this.id=this.props.id,this.ready=new Promise((e,t)=>{this.resolveReady=e,this.rejectReady=t}),this.initAsync(i)}async initAsync(e){try{let t=await this._loadAllData(e);this._checkNotDestroyed();let n=t.data?$E({...t,width:e.width,height:e.height,format:e.format}):[],r=`format`in e&&e.format!==void 0,i=`usage`in e&&e.usage!==void 0,a=this.props.width&&this.props.height?{width:this.props.width,height:this.props.height}:RE(t)||{width:this.props.width||1,height:this.props.height||1};if(!a||a.width<=0||a.height<=0)throw Error(`${this} size could not be determined or was zero`);let o=eD(this.device,n,a,{format:r?e.format:void 0}),s=o.format??this.props.format,c={...this.props,...a,format:s,mipLevels:1,data:void 0};this.device.isTextureFormatCompressed(s)&&!i&&(c.usage=zb.SAMPLE|zb.COPY_DST);let l=this.props.mipmaps&&!o.hasExplicitMipChain&&!this.device.isTextureFormatCompressed(s);if(this.device.type===`webgpu`&&l){let e=this.props.dimension===`3d`?zb.SAMPLE|zb.STORAGE|zb.COPY_DST|zb.COPY_SRC:zb.SAMPLE|zb.RENDER|zb.COPY_DST|zb.COPY_SRC;c.usage|=e}let u=this.device.getMipLevelCount(c.width,c.height),d=o.hasExplicitMipChain?o.mipLevels:this.props.mipLevels===`auto`?u:Math.max(1,Math.min(u,this.props.mipLevels??1)),f={...c,mipLevels:d};this._texture=this.device.createTexture(f),this._sampler=this.texture.sampler,this._view=this.texture.view,o.subresources.length&&this._setTextureSubresources(o.subresources),this.props.mipmaps&&!o.hasExplicitMipChain&&!l&&Z.warn(`${this} skipping auto-generated mipmaps for compressed texture format`)(),l&&this.generateMipmaps(),this.isReady=!0,this.resolveReady(this.texture),Z.info(0,`${this} created`)()}catch(e){let t=e instanceof Error?e:Error(String(e));this.rejectReady(t)}}destroy(){this._texture&&(this._texture.destroy(),this._texture=null,this._sampler=null,this._view=null),this.destroyed=!0}generateMipmaps(){this.device.type===`webgl`?this.texture.generateMipmapsWebGL():this.device.type===`webgpu`?this.device.generateMipmapsWebGPU(this.texture):Z.warn(`${this} mipmaps not supported on ${this.device.type}`)}setSampler(e={}){this._checkReady();let t=e instanceof Lb?e:this.device.createSampler(e);this.texture.setSampler(t),this._sampler=t}async readBuffer(e={}){this.isReady||await this.ready;let t=e.width??this.texture.width,n=e.height??this.texture.height,r=e.depthOrArrayLayers??this.texture.depth,i=this.texture.computeMemoryLayout({width:t,height:n,depthOrArrayLayers:r}),a=this.device.createBuffer({byteLength:i.byteLength,usage:Sy.COPY_DST|Sy.MAP_READ});this.texture.readBuffer({...e,width:t,height:n,depthOrArrayLayers:r},a);let o=this.device.createFence();return await o.signaled,o.destroy(),a}async readAsync(e={}){this.isReady||await this.ready;let t=e.width??this.texture.width,n=e.height??this.texture.height,r=e.depthOrArrayLayers??this.texture.depth,i=this.texture.computeMemoryLayout({width:t,height:n,depthOrArrayLayers:r}),a=await this.readBuffer(e),o=await a.readAsync(0,i.byteLength);return a.destroy(),o.buffer}resize(e){if(this._checkReady(),e.width===this.texture.width&&e.height===this.texture.height)return!1;let t=this.texture;return this._texture=t.clone(e),this._sampler=this.texture.sampler,this._view=this.texture.view,t.destroy(),Z.info(`${this} resized`),!0}getCubeFaceIndex(e){let t=IE[e];if(t===void 0)throw Error(`Invalid cube face: ${e}`);return t}getCubeArrayFaceIndex(e,t){return 6*e+this.getCubeFaceIndex(t)}setTexture1DData(e){if(this._checkReady(),this.texture.props.dimension!==`1d`)throw Error(`${this} is not 1d`);let t=GE(e);this._setTextureSubresources(t)}setTexture2DData(e,t=0){if(this._checkReady(),this.texture.props.dimension!==`2d`)throw Error(`${this} is not 2d`);let n=qE(t,e);this._setTextureSubresources(n)}setTexture3DData(e){if(this.texture.props.dimension!==`3d`)throw Error(`${this} is not 3d`);let t=JE(e);this._setTextureSubresources(t)}setTextureArrayData(e){if(this.texture.props.dimension!==`2d-array`)throw Error(`${this} is not 2d-array`);let t=YE(e);this._setTextureSubresources(t)}setTextureCubeData(e){if(this.texture.props.dimension!==`cube`)throw Error(`${this} is not cube`);let t=XE(e);this._setTextureSubresources(t)}setTextureCubeArrayData(e){if(this.texture.props.dimension!==`cube-array`)throw Error(`${this} is not cube-array`);let t=ZE(e);this._setTextureSubresources(t)}_setTextureSubresources(e){for(let t of e){let{z:e,mipLevel:n}=t;switch(t.type){case`external-image`:let{image:r,flipY:i}=t;this.texture.copyExternalImage({image:r,z:e,mipLevel:n,flipY:i});break;case`texture-data`:let{data:a,textureFormat:o}=t;if(o&&o!==this.texture.format)throw Error(`${this} mip level ${n} uses format "${o}" but texture format is "${this.texture.format}"`);this.texture.writeData(a.data,{x:0,y:0,z:e,width:a.width,height:a.height,depthOrArrayLayers:1,mipLevel:n});break;default:throw Error(`Unsupported 2D mip-level payload`)}}}async _loadAllData(e){let t=await iD(e.data);return{dimension:e.dimension??`2d`,data:t??null}}_checkNotDestroyed(){this.destroyed&&Z.warn(`${this} already destroyed`)}_checkReady(){this.isReady||Z.warn(`${this} Cannot perform this operation before ready`)}static defaultProps={...zb.defaultProps,dimension:`2d`,data:null,mipmaps:!1}};function $E(e){if(!e.data)return[];let t=e.width&&e.height?{width:e.width,height:e.height}:void 0,n=`format`in e?e.format:void 0;switch(e.dimension){case`1d`:return GE(e.data);case`2d`:return qE(0,e.data,t,n);case`3d`:return JE(e.data);case`2d-array`:return YE(e.data);case`cube`:return XE(e.data);case`cube-array`:return ZE(e.data);default:throw Error(`Unhandled dimension ${e.dimension}`)}}function eD(e,t,n,r){if(t.length===0)return{subresources:t,mipLevels:1,format:r.format,hasExplicitMipChain:!1};let i=new Map;for(let e of t){let t=i.get(e.z)??[];t.push(e),i.set(e.z,t)}let a=t.some(e=>e.mipLevel>0),o=r.format,s=1/0,c=[];for(let[t,r]of i){let i=[...r].sort((e,t)=>e.mipLevel-t.mipLevel),a=i[0];if(!a||a.mipLevel!==0)throw Error(`DynamicTexture: slice ${t} is missing mip level 0`);let l=nD(e,a);if(l.width!==n.width||l.height!==n.height)throw Error(`DynamicTexture: slice ${t} base level dimensions ${l.width}x${l.height} do not match expected ${n.width}x${n.height}`);let u=tD(a);if(u){if(o&&o!==u)throw Error(`DynamicTexture: slice ${t} base level format "${u}" does not match texture format "${o}"`);o=u}let d=o&&e.isTextureFormatCompressed(o)?rD(e,l.width,l.height,o):e.getMipLevelCount(l.width,l.height),f=0;for(let t=0;t<i.length;t++){let n=i[t];if(!n||n.mipLevel!==t||t>=d)break;let r=nD(e,n),a=Math.max(1,l.width>>t),s=Math.max(1,l.height>>t);if(r.width!==a||r.height!==s)break;let u=tD(n);if(u&&(o||=u,u!==o))break;f++,c.push(n)}s=Math.min(s,f)}let l=Number.isFinite(s)?Math.max(1,s):1;return{subresources:c.filter(e=>e.mipLevel<l),mipLevels:l,format:o,hasExplicitMipChain:a}}function tD(e){if(e.type===`texture-data`)return e.textureFormat??HE(e.data)}function nD(e,t){switch(t.type){case`external-image`:return e.getExternalImageSize(t.image);case`texture-data`:return{width:t.data.width,height:t.data.height};default:throw Error(`Unsupported texture subresource`)}}function rD(e,t,n,r){let{blockWidth:i=1,blockHeight:a=1}=e.getTextureFormatInfo(r),o=1;for(let e=1;;e++){let r=Math.max(1,t>>e),s=Math.max(1,n>>e);if(r<i||s<a)break;o++}return o}async function iD(e){if(e=await e,Array.isArray(e))return await Promise.all(e.map(iD));if(e&&typeof e==`object`&&e.constructor===Object){let t=e,n=await Promise.all(Object.values(t).map(iD)),r=Object.keys(t),i={};for(let e=0;e<r.length;e++)i[r[e]]=n[e];return i}return e}var aD=2,oD=1e4,sD=`render pipeline initialization failed`,cD=class e{static defaultProps={...Zb.defaultProps,source:void 0,vs:null,fs:null,id:`unnamed`,handle:void 0,userData:{},defines:{},modules:[],geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},bindings:{},uniforms:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,material:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:i_.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0};device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};vertexArray;transformFeedback=null;pipeline;shaderInputs;material=null;_uniformStore;_attributeInfos={};_gpuGeometry=null;props;_pipelineNeedsUpdate=`newly created`;_needsRedraw=`initializing`;_destroyed=!1;_lastDrawTimestamp=-1;_bindingTable=[];get[Symbol.toStringTag](){return`Model`}toString(){return`Model(${this.id})`}constructor(t,n){this.props={...e.defaultProps,...n},n=this.props,this.id=n.id||iE(`model`),this.device=t,Object.assign(this.userData,n.userData),this.material=n.material||null;let r=Object.fromEntries(this.props.modules?.map(e=>[e.name,e])||[]),i=n.shaderInputs||new kE(r,{disableWarnings:this.props.disableWarnings});this.setShaderInputs(i);let a=lD(t),o=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];if(this.props.shaderLayout=CE(this.props.shaderLayout,o)||null,this.device.type===`webgpu`&&this.props.source){let{source:e,getUniforms:n,bindingTable:r}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:a,...this.props,modules:o});this.source=e,this._getModuleUniforms=n,this._bindingTable=r;let i=t.getShaderLayout?.(this.source);this.props.shaderLayout=CE(this.props.shaderLayout||i||null,o)||null}else{let{vs:e,fs:t,getUniforms:n}=this.props.shaderAssembler.assembleGLSLShaderPair({platformInfo:a,...this.props,modules:o});this.vs=e,this.fs=t,this._getModuleUniforms=n,this._bindingTable=[]}this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,n.geometry&&this.setGeometry(n.geometry),this.pipelineFactory=n.pipelineFactory||ex.getDefaultPipelineFactory(this.device),this.shaderFactory=n.shaderFactory||tx.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=t.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),`isInstanced`in n&&(this.isInstanced=n.isInstanced),n.instanceCount&&this.setInstanceCount(n.instanceCount),n.vertexCount&&this.setVertexCount(n.vertexCount),n.indexBuffer&&this.setIndexBuffer(n.indexBuffer),n.attributes&&this.setAttributes(n.attributes),n.constantAttributes&&this.setConstantAttributes(n.constantAttributes),n.bindings&&this.setBindings(n.bindings),n.transformFeedback&&(this.transformFeedback=n.transformFeedback)}destroy(){this._destroyed||=(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.pipeline.fs!==this.pipeline.vs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw(`contents of bound textures or buffers updated`);let e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||=e}getBindingDebugTable(){return this._bindingTable}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){let t=this._areBindingsLoading();if(t)return Z.info(aD,`>>> DRAWING ABORTED ${this.id}: ${t} not loaded`)(),!1;try{e.pushDebugGroup(`${this}.predraw(${e})`),this.predraw()}finally{e.popDebugGroup()}let n,r=this.pipeline.isErrored;try{if(e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline(),r=this.pipeline.isErrored,r)Z.info(aD,`>>> DRAWING ABORTED ${this.id}: ${sD}`)(),n=!1;else{let t=this._getBindings(),r=this._getBindGroups(),{indexBuffer:i}=this.vertexArray,a=i?i.byteLength/(i.indexType===`uint32`?4:2):void 0;n=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:a,transformFeedback:this.transformFeedback||void 0,bindings:t,bindGroups:r,_bindGroupCacheKeys:this._getBindGroupCacheKeys(),uniforms:this.props.uniforms,parameters:this.parameters,topology:this.topology})}}finally{e.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(e),n?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):r?this._needsRedraw=sD:this._needsRedraw=`waiting for resource initialization`,n}setGeometry(e){this._gpuGeometry?.destroy();let t=e&&oE(this.device,e);if(t){this.setTopology(t.topology||`triangle-list`);let e=new bE(this.bufferLayout);this.bufferLayout=e.mergeBufferLayouts(t.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(t)}this._gpuGeometry=t}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate(`topology`))}setBufferLayout(e){let t=new bE(this.bufferLayout);this.bufferLayout=this._gpuGeometry?t.mergeBufferLayouts(e,this._gpuGeometry.bufferLayout):e,this._setPipelineNeedsUpdate(`bufferLayout`),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(e){yE(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate(`parameters`))}setInstanceCount(e){this.instanceCount=e,this.isInstanced===void 0&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw(`instanceCount`)}setVertexCount(e){this.vertexCount=e,this.setNeedsRedraw(`vertexCount`)}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new sS(this.device,this.shaderInputs.modules);for(let[e,t]of Object.entries(this.shaderInputs.modules))if(wE(t)&&!this.material?.ownsModule(e)){let t=this._uniformStore.getManagedUniformBuffer(e);this.bindings[`${e}Uniforms`]=t}this.setNeedsRedraw(`shaderInputs`)}setMaterial(e){this.material=e,this.setNeedsRedraw(`material`)}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setBindings(this._getNonMaterialBindings(this.shaderInputs.getBindingValues())),this.setNeedsRedraw(`shaderInputs`)}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw(`bindings`)}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw(`transformFeedback`)}setIndexBuffer(e){this.vertexArray.setIndexBuffer(e),this.setNeedsRedraw(`indexBuffer`)}setAttributes(e,t){let n=t?.disableWarnings??this.props.disableWarnings;e.indices&&Z.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=SE(this.pipeline.shaderLayout,this.bufferLayout);let r=new bE(this.bufferLayout);for(let[t,i]of Object.entries(e)){let e=r.getBufferLayout(t);if(!e){n||Z.warn(`Model(${this.id}): Missing layout for buffer "${t}".`)();continue}let a=r.getAttributeNamesForBuffer(e),o=!1;for(let e of a){let t=this._attributeInfos[e];if(t){let e=this.device.type===`webgpu`?r.getBufferIndex(t.bufferName):t.location;this.vertexArray.setBuffer(e,i),o=!0}}!o&&!n&&Z.warn(`Model(${this.id}): Ignoring buffer "${i.id}" for unknown attribute "${t}"`)()}this.setNeedsRedraw(`attributes`)}setConstantAttributes(e,t){for(let[n,r]of Object.entries(e)){let e=this._attributeInfos[n];e?this.vertexArray.setConstantWebGL(e.location,r):(t?.disableWarnings??this.props.disableWarnings)||Z.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${n}"`)()}this.setNeedsRedraw(`constants`)}_areBindingsLoading(){for(let e of Object.values(this.bindings))if(e instanceof QE&&!e.isReady)return e.id;for(let e of Object.values(this.material?.bindings||{}))if(e instanceof QE&&!e.isReady)return e.id;return!1}_getBindings(){let e={};for(let[t,n]of Object.entries(this.bindings))n instanceof QE?n.isReady&&(e[t]=n.texture):e[t]=n;return e}_getBindGroups(){let e=this.pipeline?.shaderLayout||this.props.shaderLayout||{bindings:[]},t=e.bindings.length?rx(e,this._getBindings()):{0:this._getBindings()};if(!this.material)return t;for(let[e,n]of Object.entries(this.material.getBindingsByGroup())){let r=Number(e);t[r]={...t[r]||{},...n}}return t}_getBindGroupCacheKeys(){let e=this.material?.getBindGroupCacheKey(3);return e?{3:e}:{}}_getBindingsUpdateTimestamp(){let e=0;for(let t of Object.values(this.bindings))t instanceof Bb?e=Math.max(e,t.texture.updateTimestamp):t instanceof Sy||t instanceof zb?e=Math.max(e,t.updateTimestamp):t instanceof QE?e=t.texture?Math.max(e,t.texture.updateTimestamp):1/0:t instanceof Lb||(e=Math.max(e,t.buffer.updateTimestamp));return Math.max(e,this.material?.getBindingsUpdateTimestamp()||0)}_setGeometryAttributes(e){let t={...e.attributes};for(let[e]of Object.entries(t))!this.pipeline.shaderLayout.attributes.find(t=>t.name===e)&&e!==`positions`&&delete t[e];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(t,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw(`geometry attributes`)}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||=e,this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,t=null;this.pipeline&&(Z.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,t=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let n=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:`vertex`,source:this.source||this.vs,debugShaders:this.props.debugShaders}),r=null;this.source?r=n:this.fs&&(r=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:`fragment`,source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bindings:void 0,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,bindGroups:this._getBindGroups(),vs:n,fs:r}),this._attributeInfos=xx(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),t&&t!==e&&this.shaderFactory.release(t)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=Z.level>3?0:oD;Z.level<2||Date.now()-this._lastLogTime<e||(this._lastLogTime=Date.now(),this._logOpen=!0,Z.group(aD,`>>> DRAWING MODEL ${this.id}`,{collapsed:Z.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=lE(this.pipeline.shaderLayout,this.id);Z.table(aD,e)();let t=this.shaderInputs.getDebugTable();Z.table(aD,t)();let n=this._getAttributeDebugTable();Z.table(aD,this._attributeInfos)(),Z.table(aD,n)(),Z.groupEnd(aD)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){let t=this.device.props.debugFramebuffers;if(this._drawCount++,!t)return;let n=e.props.framebuffer;fE(e,n,{id:n?.id||`${this.id}-framebuffer`,minimap:!0})}_getAttributeDebugTable(){let e={};for(let[t,n]of Object.entries(this._attributeInfos)){let r=this.vertexArray.attributes[n.location];e[n.location]={name:t,type:n.shaderType,values:r?this._getBufferOrConstantValues(r,n.bufferDataType):`null`}}if(this.vertexArray.indexBuffer){let{indexBuffer:t}=this.vertexArray,n=t.indexType===`uint32`?new Uint32Array(t.debugData):new Uint16Array(t.debugData);e.indices={name:`indices`,type:t.indexType,values:n.toString()}}return e}_getBufferOrConstantValues(e,t){let n=Cy.getTypedArrayConstructor(t);return(e instanceof Sy?new n(e.debugData):e).toString()}_getNonMaterialBindings(e){if(!this.material)return e;let t={};for(let[n,r]of Object.entries(e))this.material.ownsBinding(n)||(t[n]=r);return t}};function lD(e){return{type:e.type,shaderLanguage:e.info.shadingLanguage,shaderLanguageVersion:e.info.shadingLanguageVersion,gpu:e.info.gpu,features:e.features}}var uD=class e{device;model;transformFeedback;static defaultProps={...cD.defaultProps,outputs:void 0,feedbackBuffers:void 0};static isSupported(e){return e?.info?.type===`webgl`}constructor(t,n=e.defaultProps){if(!e.isSupported(t))throw Error(`BufferTransform not yet implemented on WebGPU`);this.device=t,this.model=new cD(this.device,{id:n.id||`buffer-transform-model`,fs:n.fs||o_(),topology:n.topology||`point-list`,varyings:n.outputs||n.varyings,...n}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:n.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback),Object.seal(this)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(e){e?.inputBuffers&&this.model.setAttributes(e.inputBuffers),e?.outputBuffers&&this.transformFeedback.setBuffers(e.outputBuffers);let t=this.device.beginRenderPass(e);this.model.draw(t),t.end()}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){let t=this.getBuffer(e);if(!t)throw Error(`BufferTransform#getBuffer`);if(t instanceof Sy)return t.readAsync();let{buffer:n,byteOffset:r=0,byteLength:i=n.byteLength}=t;return n.readAsync(r,i)}},dD=class{id;topology;vertexCount;indices;attributes;userData={};constructor(e){let{attributes:t={},indices:n=null,vertexCount:r=null}=e;this.id=e.id||iE(`geometry`),this.topology=e.topology,n&&(this.indices=ArrayBuffer.isView(n)?{value:n,size:1}:n),this.attributes={};for(let[e,n]of Object.entries(t)){let t=ArrayBuffer.isView(n)?{value:n}:n;if(!ArrayBuffer.isView(t.value))throw Error(`${this._print(e)}: must be typed array or object with value as typed array`);if((e===`POSITION`||e===`positions`)&&!t.size&&(t.size=3),e===`indices`){if(this.indices)throw Error(`Multiple indices detected`);this.indices=t}else this.attributes[e]=t}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=r||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,t){return this}_calculateVertexCount(e,t){if(t)return t.value.length;let n=1/0;for(let t of Object.values(e)){let{value:e,size:r,constant:i}=t;!i&&e&&r!==void 0&&r>=1&&(n=Math.min(n,e.length/r))}return n}},fD={blendColorOperation:`add`,blendColorSrcFactor:`one`,blendColorDstFactor:`zero`,blendAlphaOperation:`add`,blendAlphaSrcFactor:`constant`,blendAlphaDstFactor:`zero`},pD=class extends _T{constructor(){super(...arguments),this._colorEncoderState=null}render(e){return`pickingFBO`in e?this._drawPickingBuffer(e):{decodePickingColor:null,stats:super._render(e)}}_drawPickingBuffer({layers:e,layerFilter:t,views:n,viewports:r,onViewportActive:i,pickingFBO:a,deviceRect:{x:o,y:s,width:c,height:l},cullRect:u,effects:d,pass:f=`picking`,pickZ:p,shaderModuleProps:m,clearColor:h}){this.pickZ=p;let g=this._resetColorEncoder(p),_=[o,s,c,l],v=super._render({target:a,layers:e,layerFilter:t,views:n,viewports:r,onViewportActive:i,cullRect:u,effects:d?.filter(e=>e.useInPicking),pass:f,isPicking:!0,shaderModuleProps:m,clearColor:h??[0,0,0,0],colorMask:15,scissorRect:_});return this._colorEncoderState=null,{decodePickingColor:g&&hD.bind(null,g),stats:v}}shouldDrawLayer(e){let{pickable:t,operation:n}=e.props;return t&&n.includes(`draw`)||n.includes(`terrain`)||n.includes(`mask`)}getShaderModuleProps(e,t,n){return{picking:{isActive:1,isAttribute:this.pickZ},lighting:{enabled:!1}}}getLayerParameters(e,t,n){let r={...e.props.parameters},{pickable:i,operation:a}=e.props;return this._colorEncoderState?i&&a.includes(`draw`)?(Object.assign(r,fD),r.blend=!0,this.device.type===`webgpu`?r.blendConstant=mD(this._colorEncoderState,e,n):r.blendColor=mD(this._colorEncoderState,e,n),a.includes(`terrain`)&&e.state?._hasPickingCover&&(r.blendAlphaSrcFactor=`one`)):a.includes(`terrain`)&&(r.blend=!1):r.blend=!1,r}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}};function mD(e,t,n){let{byLayer:r,byAlpha:i}=e,a,o=r.get(t);return o?(o.viewports.push(n),a=o.a):(a=r.size+1,a<=255?(o={a,layer:t,viewports:[n]},r.set(t,o),i[a]=o):(X.warn(`Too many pickable layers, only picking the first 255`)(),a=0)),[0,0,0,a/255]}function hD(e,t){let n=e.byAlpha[t[3]];return n&&{pickedLayer:n.layer,pickedViewports:n.viewports,pickedObjectIndex:n.layer.decodePickingColor(t)}}var gD={NO_STATE:`Awaiting state`,MATCHED:`Matched. State transferred from previous layer`,INITIALIZED:`Initialized`,AWAITING_GC:`Discarded. Awaiting garbage collection`,AWAITING_FINALIZATION:`No longer matched. Awaiting garbage collection`,FINALIZED:`Finalized! Awaiting garbage collection`},_D=Symbol.for(`component`),vD=Symbol.for(`propTypes`),yD=Symbol.for(`deprecatedProps`),bD=Symbol.for(`asyncPropDefaults`),xD=Symbol.for(`asyncPropOriginal`),SD=Symbol.for(`asyncPropResolved`);function CD(e,t=()=>!0){return Array.isArray(e)?wD(e,t,[]):t(e)?[e]:[]}function wD(e,t,n){let r=-1;for(;++r<e.length;){let i=e[r];Array.isArray(i)?wD(i,t,n):t(i)&&n.push(i)}return n}function TD({target:e,source:t,start:n=0,count:r=1}){let i=t.length,a=r*i,o=0;for(let r=n;o<i;o++)e[r++]=t[o];for(;o<a;)o<a-o?(e.copyWithin(n+o,n,n+o),o*=2):(e.copyWithin(n+o,n,n+a-o),o=a);return e}var ED=class{constructor(e,t,n){this._loadCount=0,this._subscribers=new Set,this.id=e,this.context=n,this.setData(t)}subscribe(e){this._subscribers.add(e)}unsubscribe(e){this._subscribers.delete(e)}inUse(){return this._subscribers.size>0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(e,t){if(e===this._data&&!t)return;this._data=e;let n=++this._loadCount,r=e;typeof e==`string`&&(r=hm(e)),r instanceof Promise?(this.isLoaded=!1,this._loader=r.then(e=>{this._loadCount===n&&(this.isLoaded=!0,this._error=void 0,this._content=e)}).catch(e=>{this._loadCount===n&&(this.isLoaded=!0,this._error=e||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=e);for(let e of this._subscribers)e.onChange(this.getData())}},DD=class{constructor(e){this.protocol=e.protocol||`resource://`,this._context={device:e.device,gl:e.device?.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(e){return e.startsWith(this.protocol)?!0:e in this._resources}add({resourceId:e,data:t,forceUpdate:n=!1,persistent:r=!0}){let i=this._resources[e];i?i.setData(t,n):(i=new ED(e,t,this._context),this._resources[e]=i),i.persistent=r}remove(e){let t=this._resources[e];t&&(t.delete(),delete this._resources[e])}unsubscribe({consumerId:e}){let t=this._consumers[e];if(t){for(let e in t){let n=t[e],r=this._resources[n.resourceId];r&&r.unsubscribe(n)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:t,consumerId:n,requestId:r=`default`}){let{_resources:i,protocol:a}=this;e.startsWith(a)&&(e=e.replace(a,``),i[e]||this.add({resourceId:e,data:null,persistent:!1}));let o=i[e];if(this._track(n,r,o,t),o)return o.getData()}prune(){this._pruneRequest||=setTimeout(()=>this._prune(),0)}finalize(){for(let e in this._resources)this._resources[e].delete()}_track(e,t,n,r){let i=this._consumers,a=i[e]=i[e]||{},o=a[t],s=o&&o.resourceId&&this._resources[o.resourceId];s&&(s.unsubscribe(o),this.prune()),n&&(o?(o.onChange=r,o.resourceId=n.id):o={onChange:r,resourceId:n.id},a[t]=o,n.subscribe(o))}_prune(){this._pruneRequest=null;for(let e of Object.keys(this._resources)){let t=this._resources[e];!t.persistent&&!t.inUse()&&(t.delete(),delete this._resources[e])}}},OD=`layerManager.setLayers`,kD=`layerManager.activateViewport`,AD=class{constructor(e,t){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=e=>{ih(kD,this,e),e&&(this.context.viewport=e)};let{deck:n,stats:r,viewport:i,timeline:a}=t||{};this.layers=[],this.resourceManager=new DD({device:e,protocol:`deck://`}),this.context={mousePosition:null,userData:{},layerManager:this,device:e,gl:e?.gl,deck:n,shaderAssembler:aT(e?.info?.shadingLanguage||`glsl`),defaultShaderModules:[dS],renderPass:void 0,stats:r||new Of({id:`deck.gl`}),viewport:i||new HT({id:`DEFAULT-INITIAL-VIEWPORT`}),timeline:a||new ZT,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(let e of this.layers)this._finalizeLayer(e)}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);for(let n of this.layers){let r=n.getNeedsRedraw(e);t||=r}return t}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?`layers changed`:this._defaultShaderModulesChanged?`shader modules changed`:this._needsUpdate}setNeedsRedraw(e){this._needsRedraw=this._needsRedraw||e}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e}getLayers({layerIds:e}={}){return e?this.layers.filter(t=>e.find(e=>t.id.indexOf(e)===0)):this.layers}setProps(e){`debug`in e&&(this._debug=e.debug),`userData`in e&&(this.context.userData=e.userData),`layers`in e&&(this._nextLayers=e.layers),`onError`in e&&(this.context.onError=e.onError)}setLayers(e,t){ih(OD,this,t,e),this._lastRenderedLayers=e;let n=CD(e,Boolean);for(let e of n)e.context=this.context;this._updateLayers(this.layers,n)}updateLayers(){let e=this.needsUpdate();e&&(this.setNeedsRedraw(`updating layers: ${e}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,e)),this._nextLayers=null}addDefaultShaderModule(e){let{defaultShaderModules:t}=this.context;t.find(t=>t.name===e.name)||(t.push(e),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(e){let{defaultShaderModules:t}=this.context,n=t.findIndex(t=>t.name===e.name);n>=0&&(t.splice(n,1),this._defaultShaderModulesChanged=!0)}_handleError(e,t,n){n.raiseError(t,`${e} of ${n}`)}_updateLayers(e,t){let n={};for(let t of e)n[t.id]?X.warn(`Multiple old layers with same id ${t.id}`)():n[t.id]=t;if(this._defaultShaderModulesChanged){for(let t of e)t.setNeedsUpdate(),t.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}let r=[];this._updateSublayersRecursively(t,n,r),this._finalizeOldLayers(n);let i=!1;for(let e of r)if(e.hasUniformTransition()){i=`Uniform transition in ${e}`;break}this._needsUpdate=i,this.layers=r}_updateSublayersRecursively(e,t,n){for(let r of e){r.context=this.context;let e=t[r.id];e===null&&X.warn(`Multiple new layers with same id ${r.id}`)(),t[r.id]=null;let i=null;try{this._debug&&e!==r&&r.validateProps(),e?(this._transferLayerState(e,r),this._updateLayer(r)):this._initializeLayer(r),n.push(r),i=r.isComposite?r.getSubLayers():null}catch(e){this._handleError(`matching`,e,r)}i&&this._updateSublayersRecursively(i,t,n)}}_finalizeOldLayers(e){for(let t in e){let n=e[t];n&&this._finalizeLayer(n)}}_initializeLayer(e){try{e._initialize(),e.lifecycle=gD.INITIALIZED}catch(t){this._handleError(`initialization`,t,e)}}_transferLayerState(e,t){t._transferState(e),t.lifecycle=gD.MATCHED,t!==e&&(e.lifecycle=gD.AWAITING_GC)}_updateLayer(e){try{e._update()}catch(t){this._handleError(`update`,t,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||`finalized ${e}`,e.lifecycle=gD.AWAITING_FINALIZATION;try{e._finalize(),e.lifecycle=gD.FINALIZED}catch(t){this._handleError(`finalization`,t,e)}}};function jD(e,t,n){if(e===t)return!0;if(!n||!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!jD(e[r],t[r],n-1))return!1;return!0}if(Array.isArray(t))return!1;if(typeof e==`object`&&typeof t==`object`){let r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;for(let i of r)if(!t.hasOwnProperty(i)||!jD(e[i],t[i],n-1))return!1;return!0}return!1}var MD=class{constructor(e){this.views=[],this.width=100,this.height=100,this.viewState={},this.controllers={},this.timeline=e.timeline,this._viewports=[],this._viewportMap={},this._isUpdating=!1,this._needsRedraw=`First render`,this._needsUpdate=`Initialize`,this._eventManager=e.eventManager,this._eventCallbacks={onViewStateChange:e.onViewStateChange,onInteractionStateChange:e.onInteractionStateChange},this._pickPosition=e.pickPosition,Object.seal(this),this.setProps(e)}finalize(){for(let e in this.controllers){let t=this.controllers[e];t&&t.finalize()}this.controllers={}}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e,this._needsRedraw=this._needsRedraw||e}updateViewStates(){for(let e in this.controllers){let t=this.controllers[e];t&&t.updateTransition()}}getViewports(e){return e?this._viewports.filter(t=>t.containsPixel(e)):this._viewports}getViews(){let e={};return this.views.forEach(t=>{e[t.id]=t}),e}getView(e){return this.views.find(t=>t.id===e)}getViewState(e){let t=typeof e==`string`?this.getView(e):e,n=t&&this.viewState[t.getViewStateId()]||this.viewState;return t?t.filterViewState(n):n}getViewport(e){return this._viewportMap[e]}unproject(e,t){let n=this.getViewports(),r={x:e[0],y:e[1]};for(let i=n.length-1;i>=0;--i){let a=n[i];if(a.containsPixel(r)){let n=e.slice();return n[0]-=a.x,n[1]-=a.y,a.unproject(n,t)}}return null}setProps(e){e.views&&this._setViews(e.views),e.viewState&&this._setViewState(e.viewState),(`width`in e||`height`in e)&&this._setSize(e.width,e.height),`pickPosition`in e&&(this._pickPosition=e.pickPosition),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(e,t){(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.setNeedsUpdate(`Size changed`))}_setViews(e){e=CD(e,Boolean),this._diffViews(e,this.views)&&this.setNeedsUpdate(`views changed`),this.views=e}_setViewState(e){e?(jD(e,this.viewState,3)||this.setNeedsUpdate(`viewState changed`),this.viewState=e):X.warn("missing `viewState` or `initialViewState`")()}_createController(e,t){let n=t.type;return new n({timeline:this.timeline,eventManager:this._eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:t=>this.getView(e.id)?.makeViewport({viewState:t,width:this.width,height:this.height}),pickPosition:this._pickPosition})}_updateController(e,t,n,r){let i=e.controller;if(i&&n){let a={...t,...i,id:e.id,x:n.x,y:n.y,width:n.width,height:n.height};return(!r||r.constructor!==i.type)&&(r=this._createController(e,a)),r&&r.setProps(a),r}return null}_rebuildViewports(){let{views:e}=this,t=this.controllers;this._viewports=[],this.controllers={};let n=!1;for(let r=e.length;r--;){let i=e[r],a=this.getViewState(i),o=i.makeViewport({viewState:a,width:this.width,height:this.height}),s=t[i.id],c=!!i.controller;c&&!s&&(n=!0),(n||!c)&&s&&(s.finalize(),s=null),this.controllers[i.id]=this._updateController(i,a,o,s),o&&this._viewports.unshift(o)}for(let e in t){let n=t[e];n&&!this.controllers[e]&&n.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(e=>{e.id&&(this._viewportMap[e.id]=this._viewportMap[e.id]||e)})}_diffViews(e,t){return e.length===t.length?e.some((n,r)=>!e[r].equals(t[r])):!0}},ND=/^(?:\d+\.?\d*|\.\d+)$/;function PD(e){switch(typeof e){case`number`:if(!Number.isFinite(e))throw Error(`Could not parse position string ${e}`);return{type:`literal`,value:e};case`string`:try{return new RD(LD(e)).parseExpression()}catch(t){let n=t instanceof Error?t.message:String(t);throw Error(`Could not parse position string ${e}: ${n}`)}default:throw Error(`Could not parse position string ${e}`)}}function FD(e,t){switch(e.type){case`literal`:return e.value;case`percentage`:return Math.round(e.value*t);case`binary`:let n=FD(e.left,t),r=FD(e.right,t);return e.operator===`+`?n+r:n-r;default:throw Error(`Unknown layout expression type`)}}function ID(e,t){return FD(e,t)}function LD(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(/\s/.test(r)){n++;continue}if(r===`+`||r===`-`||r===`(`||r===`)`||r===`%`){t.push({type:`symbol`,value:r}),n++;continue}if(zD(r)||r===`.`){let i=n,a=r===`.`;for(n++;n<e.length;){let t=e[n];if(zD(t)){n++;continue}if(t===`.`&&!a){a=!0,n++;continue}break}let o=e.slice(i,n);if(!ND.test(o))throw Error(`Invalid number token`);t.push({type:`number`,value:parseFloat(o)});continue}if(BD(r)){let r=n;for(;n<e.length&&BD(e[n]);)n++;let i=e.slice(r,n).toLowerCase();t.push({type:`word`,value:i});continue}throw Error(`Invalid token in position string`)}return t}var RD=class{constructor(e){this.index=0,this.tokens=e}parseExpression(){let e=this.parseBinaryExpression();if(this.index<this.tokens.length)throw Error(`Unexpected token at end of expression`);return e}parseBinaryExpression(){let e=this.parseFactor(),t=this.peek();for(;VD(t);){this.index++;let n=this.parseFactor();e={type:`binary`,operator:t.value,left:e,right:n},t=this.peek()}return e}parseFactor(){let e=this.peek();if(!e)throw Error(`Unexpected end of expression`);if(e.type===`symbol`&&e.value===`+`)return this.index++,this.parseFactor();if(e.type===`symbol`&&e.value===`-`)return this.index++,{type:`binary`,operator:`-`,left:{type:`literal`,value:0},right:this.parseFactor()};if(e.type===`symbol`&&e.value===`(`){this.index++;let e=this.parseBinaryExpression();if(!this.consumeSymbol(`)`))throw Error(`Missing closing parenthesis`);return e}if(e.type===`word`&&e.value===`calc`){if(this.index++,!this.consumeSymbol(`(`))throw Error(`Missing opening parenthesis after calc`);let e=this.parseBinaryExpression();if(!this.consumeSymbol(`)`))throw Error(`Missing closing parenthesis`);return e}if(e.type===`number`){this.index++;let t=e.value,n=this.peek();return n&&n.type===`symbol`&&n.value===`%`?(this.index++,{type:`percentage`,value:t/100}):(n&&n.type===`word`&&n.value===`px`&&this.index++,{type:`literal`,value:t})}throw Error(`Unexpected token in expression`)}consumeSymbol(e){let t=this.peek();return t&&t.type===`symbol`&&t.value===e?(this.index++,!0):!1}peek(){return this.tokens[this.index]||null}};function zD(e){return e>=`0`&&e<=`9`}function BD(e){return e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`}function VD(e){return!!(e&&e.type===`symbol`&&(e.value===`+`||e.value===`-`))}function HD(e,t){let n={...e};for(let e in t)e!==`id`&&(Array.isArray(n[e])&&Array.isArray(t[e])?n[e]=UD(n[e],t[e]):n[e]=t[e]);return n}function UD(e,t){e=e.slice();for(let n=0;n<t.length;n++){let r=t[n];Number.isFinite(r)&&(e[n]=r)}return e}var WD=class{constructor(e){let{id:t,x:n=0,y:r=0,width:i=`100%`,height:a=`100%`,padding:o=null}=e;this.id=t||this.constructor.displayName||`view`,this.props={...e,id:this.id},this._x=PD(n),this._y=PD(r),this._width=PD(i),this._height=PD(a),this._padding=o&&{left:PD(o.left||0),right:PD(o.right||0),top:PD(o.top||0),bottom:PD(o.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(e){return this===e?!0:this.constructor===e.constructor&&jD(this.props,e.props,2)}clone(e){let t=this.constructor;return new t({...this.props,...e})}makeViewport({width:e,height:t,viewState:n}){n=this.filterViewState(n);let r=this.getDimensions({width:e,height:t});return!r.height||!r.width?null:new(this.getViewportType(n))({...n,...this.props,...r})}getViewStateId(){let{viewState:e}=this.props;return typeof e==`string`?e:e?.id||this.id}filterViewState(e){return this.props.viewState&&typeof this.props.viewState==`object`?this.props.viewState.id?HD(e,this.props.viewState):this.props.viewState:e}getDimensions({width:e,height:t}){let n={x:ID(this._x,e),y:ID(this._y,t),width:ID(this._width,e),height:ID(this._height,t)};return this._padding&&(n.padding={left:ID(this._padding.left,e),top:ID(this._padding.top,t),right:ID(this._padding.right,e),bottom:ID(this._padding.bottom,t)}),n}get controller(){let e=this.props.controller;return e?e===!0?{type:this.ControllerType}:typeof e==`function`?{type:e}:{type:this.ControllerType,...e}:null}},GD=class{constructor(e){this._inProgress=!1,this._handle=null,this.time=0,this.settings={duration:0},this._timeline=e}get inProgress(){return this._inProgress}start(e){this.cancel(),this.settings=e,this._inProgress=!0,this.settings.onStart?.(this)}end(){this._inProgress&&(this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1,this.settings.onEnd?.(this))}cancel(){this._inProgress&&=(this.settings.onInterrupt?.(this),this._timeline.removeChannel(this._handle),this._handle=null,!1)}update(){if(!this._inProgress)return!1;if(this._handle===null){let{_timeline:e,settings:t}=this;this._handle=e.addChannel({delay:e.getTime(),duration:t.duration})}return this.time=this._timeline.getTime(this._handle),this._onUpdate(),this.settings.onUpdate?.(this),this._timeline.isFinished(this._handle)&&this.end(),!0}_onUpdate(){}},KD=()=>{},qD={BREAK:1,SNAP_TO_END:2,IGNORE:3},JD=e=>e,YD=qD.BREAK,XD=class{constructor(e){this._onTransitionUpdate=e=>{let{time:t,settings:{interpolator:n,startProps:r,endProps:i,duration:a,easing:o}}=e,s=o(t/a),c=n.interpolateProps(r,i,s);this.propsInTransition=this.getControllerState({...this.props,...c}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new GD(e.timeline),this.onViewStateChange=e.onViewStateChange||KD,this.onStateChange=e.onStateChange||KD}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(e){let t=!1,n=this.props;if(this.props=e,!n||this._shouldIgnoreViewportChange(n,e))return!1;if(this._isTransitionEnabled(e)){let r=n;if(this.transition.inProgress){let{interruption:e,endProps:t}=this.transition.settings;r={...n,...e===qD.SNAP_TO_END?t:this.propsInTransition||n}}this._triggerTransition(r,e),t=!0}else this.transition.cancel();return t}updateTransition(){this.transition.update()}_isTransitionEnabled(e){let{transitionDuration:t,transitionInterpolator:n}=e;return(t>0||t===`auto`)&&!!n}_isUpdateDueToCurrentTransition(e){return this.transition.inProgress&&this.propsInTransition?this.transition.settings.interpolator.arePropsEqual(e,this.propsInTransition):!1}_shouldIgnoreViewportChange(e,t){return this.transition.inProgress?this.transition.settings.interruption===qD.IGNORE||this._isUpdateDueToCurrentTransition(t):this._isTransitionEnabled(t)?t.transitionInterpolator.arePropsEqual(e,t):!0}_triggerTransition(e,t){let n=this.getControllerState(e),r=this.getControllerState(t).shortestPathFrom(n),i=t.transitionInterpolator,a=i.getDuration?i.getDuration(e,t):t.transitionDuration;if(a===0)return;let o=i.initializeProps(e,r);this.propsInTransition={};let s={duration:a,easing:t.transitionEasing||JD,interpolator:i,interruption:t.transitionInterruption||YD,startProps:o.start,endProps:o.end,onStart:t.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(t.onTransitionInterrupt),onEnd:this._onTransitionEnd(t.onTransitionEnd)};this.transition.start(s),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(e){return t=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),e?.(t)}}};function ZD(e,t){if(!e)throw Error(t||`deck.gl: assertion failed.`)}var QD=class{constructor(e){let{compare:t,extract:n,required:r}=e;this._propsToCompare=t,this._propsToExtract=n||t,this._requiredProps=r}arePropsEqual(e,t){for(let n of this._propsToCompare)if(!(n in e)||!(n in t)||!m_(e[n],t[n]))return!1;return!0}initializeProps(e,t){let n={},r={};for(let i of this._propsToExtract)(i in e||i in t)&&(n[i]=e[i],r[i]=t[i]);return this._checkRequiredProps(n),this._checkRequiredProps(r),{start:n,end:r}}getDuration(e,t){return t.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(t=>{let n=e[t];ZD(Number.isFinite(n)||Array.isArray(n),`${t} is required for transition`)})}},$D=Math.PI/180,eO=180/Math.PI,tO=6370972;function nO(){let e=256/tO,t=Math.PI/180*256;return{unitsPerMeter:[e,e,e],unitsPerMeter2:[0,0,0],metersPerUnit:[1/e,1/e,1/e],unitsPerDegree:[t,t,e],unitsPerDegree2:[0,0,0],degreesPerUnit:[1/t,1/t,1/e]}}var rO=class extends HT{constructor(e={}){let{longitude:t=0,zoom:n=0,bearing:r=0,pitch:i=0,nearZMultiplier:a=.5,farZMultiplier:o=1,resolution:s=10}=e,{latitude:c=0,height:l,altitude:u=1.5,fovy:d}=e;c=Math.max(Math.min(c,Sw),-Sw),l||=1,d?u=Pw(d):d=Nw(u);let f=2**(n-iO(c)),p=e.nearZ??a,m=e.farZ??(u+256*2*f/l)*o,h=r*$D,g=i*$D,_=Math.sin(h),v=Math.cos(h),y=Math.sin(g),b=Math.cos(g),x=new Mv().lookAt({eye:[-_*y*u,-b*u,-v*y*u],up:[_*b,-y,v*b]});x.rotateX(c*$D),x.rotateZ(-t*$D),x.scale(f/l),super({...e,height:l,viewMatrix:x,longitude:t,latitude:c,zoom:n,distanceScales:nO(),fovy:d,focalDistance:u,near:p,far:m}),this.scale=f,this.latitude=c,this.longitude=t,this.fovy=d,this.resolution=s}get projectionMode(){return BC.GLOBE}getDistanceScales(){return this.distanceScales}getBounds(e={}){let t={targetZ:e.z||0},n=this.unproject([0,this.height/2],t),r=this.unproject([this.width/2,0],t),i=this.unproject([this.width,this.height/2],t),a=this.unproject([this.width/2,this.height],t);return i[0]<this.longitude&&(i[0]+=360),n[0]>this.longitude&&(n[0]-=360),[Math.min(n[0],i[0],r[0],a[0]),Math.min(n[1],i[1],r[1],a[1]),Math.max(n[0],i[0],r[0],a[0]),Math.max(n[1],i[1],r[1],a[1])]}unproject(e,{topLeft:t=!0,targetZ:n}={}){let[r,i,a]=e,o=t?i:this.height-i,{pixelUnprojectionMatrix:s}=this,c;if(Number.isFinite(a))c=aO(s,[r,o,a,1]);else{let e=aO(s,[r,o,-1,1]),t=aO(s,[r,o,1,1]),i=((n||0)/tO+1)*256,a=ev(Z_([],e,t)),l=ev(e),u=ev(t),d=4*((4*l*u-(a-l-u)**2)/16)/a;c=U_([],e,t,(Math.sqrt(l-d)-Math.sqrt(Math.max(0,i*i-d)))/Math.sqrt(a))}let[l,u,d]=this.unprojectPosition(c);return Number.isFinite(a)?[l,u,d]:Number.isFinite(n)?[l,u,n]:[l,u]}projectPosition(e){let[t,n,r=0]=e,i=t*$D,a=n*$D,o=Math.cos(a),s=(r/tO+1)*256;return[Math.sin(i)*o*s,-Math.cos(i)*o*s,Math.sin(a)*s]}unprojectPosition(e){let[t,n,r]=e,i=$_(e),a=Math.asin(r/i);return[Math.atan2(t,-n)*eO,a*eO,(i/256-1)*tO]}projectFlat(e){return e}unprojectFlat(e){return e}panByPosition([e,t,n],r,i){let a=.25/2**(this.zoom-iO(this.latitude)),o=e+a*(i[0]-r[0]),s=t-a*(i[1]-r[1]);s=Math.max(Math.min(s,Sw),-Sw);let c={longitude:o,latitude:s,zoom:n-iO(t)};return c.zoom+=iO(c.latitude),c}};rO.displayName=`GlobeViewport`;function iO(e){let t=Math.PI*Math.cos(e*Math.PI/180);return Math.log2(t)}function aO(e,t){let n=Tv([],t,e);return wv(n,n,1/n[3]),n}var oO=[`longitude`,`latitude`,`zoom`,`bearing`,`pitch`],sO=[`longitude`,`latitude`,`zoom`],cO=class extends QD{constructor(e={}){let t=Array.isArray(e)?e:e.transitionProps,n=Array.isArray(e)?{}:e;n.transitionProps=Array.isArray(t)?{compare:t,required:t}:t||{compare:oO,required:sO},super(n.transitionProps),this.opts=n}initializeProps(e,t){let n=super.initializeProps(e,t),{makeViewport:r,around:i}=this.opts;if(r&&i)if(r(e)instanceof rO)X.warn(`around not supported in GlobeView`)();else{let a=r(e),o=r(t),s=a.unproject(i);n.start.around=i,Object.assign(n.end,{around:o.project(s),aroundPosition:s,width:t.width,height:t.height})}return n}interpolateProps(e,t,n){let r={};for(let i of this._propsToExtract)r[i]=p_(e[i]||0,t[i]||0,n);if(t.aroundPosition&&this.opts.makeViewport){let i=this.opts.makeViewport({...t,...r});Object.assign(r,i.panByPosition(t.aroundPosition,p_(e.around,t.around,n)))}return r}},lO={transitionDuration:0},uO=300,dO=e=>1-(1-e)*(1-e),fO={WHEEL:[`wheel`],PAN:[`panstart`,`panmove`,`panend`],PINCH:[`pinchstart`,`pinchmove`,`pinchend`],MULTI_PAN:[`multipanstart`,`multipanmove`,`multipanend`],DOUBLE_CLICK:[`dblclick`],KEYBOARD:[`keydown`]},pO={},mO=class{constructor(e){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this.invertPan=!1,this.dragMode=`rotate`,this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.keyboard=!0,this.transitionManager=new XD({...e,getControllerState:e=>new this.ControllerState(e),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=e.eventManager,this.onViewStateChange=e.onViewStateChange||(()=>{}),this.onStateChange=e.onStateChange||(()=>{}),this.makeViewport=e.makeViewport,this.pickPosition=e.pickPosition}set events(e){this.toggleEvents(this._customEvents,!1),this.toggleEvents(e,!0),this._customEvents=e,this.props&&this.setProps(this.props)}finalize(){for(let e in this._events)this._events[e]&&this.eventManager?.off(e,this.handleEvent);this.transitionManager.finalize()}handleEvent(e){this._controllerState=void 0;let t=this._eventStartBlocked;switch(e.type){case`panstart`:return t?!1:this._onPanStart(e);case`panmove`:return this._onPan(e);case`panend`:return this._onPanEnd(e);case`pinchstart`:return t?!1:this._onPinchStart(e);case`pinchmove`:return this._onPinch(e);case`pinchend`:return this._onPinchEnd(e);case`multipanstart`:return t?!1:this._onMultiPanStart(e);case`multipanmove`:return this._onMultiPan(e);case`multipanend`:return this._onMultiPanEnd(e);case`dblclick`:return this._onDoubleClick(e);case`wheel`:return this._onWheel(e);case`keydown`:return this._onKeyDown(e);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(e){let{x:t,y:n}=this.props,{offsetCenter:r}=e;return[r.x-t,r.y-n]}isPointInBounds(e,t){let{width:n,height:r}=this.props;if(t&&t.handled)return!1;let i=e[0]>=0&&e[0]<=n&&e[1]>=0&&e[1]<=r;return i&&t&&t.stopPropagation(),i}isFunctionKeyPressed(e){let{srcEvent:t}=e;return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(e){let t=setTimeout(()=>{this._eventStartBlocked===t&&(this._eventStartBlocked=null)},e);this._eventStartBlocked=t}setProps(e){e.dragMode&&(this.dragMode=e.dragMode);let t=this.props;this.props=e,`transitionInterpolator`in e||(e.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(e);let{inertia:n}=e;this.inertia=Number.isFinite(n)?n:n===!0?uO:0;let{scrollZoom:r=!0,dragPan:i=!0,dragRotate:a=!0,doubleClickZoom:o=!0,touchZoom:s=!0,touchRotate:c=!1,keyboard:l=!0}=e,u=!!this.onViewStateChange;if(this.toggleEvents(fO.WHEEL,u&&r),this.toggleEvents(fO.PAN,u),this.toggleEvents(fO.PINCH,u&&(s||c)),this.toggleEvents(fO.MULTI_PAN,u&&c),this.toggleEvents(fO.DOUBLE_CLICK,u&&o),this.toggleEvents(fO.KEYBOARD,u&&l),this.scrollZoom=r,this.dragPan=i,this.dragRotate=a,this.doubleClickZoom=o,this.touchZoom=s,this.touchRotate=c,this.keyboard=l,(!t||t.height!==e.height||t.width!==e.width||t.maxBounds!==e.maxBounds)&&e.maxBounds){let t=new this.ControllerState({...e,makeViewport:this.makeViewport}),n=t.getViewportProps();Object.keys(n).some(t=>!jD(n[t],e[t],1))&&this.updateViewport(t)}}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(e,t){this.eventManager&&e.forEach(e=>{this._events[e]!==t&&(this._events[e]=t,t?this.eventManager.on(e,this.handleEvent):this.eventManager.off(e,this.handleEvent))})}updateViewport(e,t=null,n={}){let r={...e.getViewportProps(),...t},i=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(n),i){let e=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:r,interactionState:this._interactionState,oldViewState:e,viewId:this.props.id})}}_onTransition(e){this.onViewStateChange({...e,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(e){Object.assign(this._interactionState,e),this.onStateChange(this._interactionState)}_onPanStart(e){let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let n=this.isFunctionKeyPressed(e)||e.rightButton||!1;(this.invertPan||this.dragMode===`pan`)&&(n=!n);let r=this.controllerState[n?`panStart`:`rotateStart`]({pos:t});return this._panMove=n,this.updateViewport(r,lO,{isDragging:!0}),!0}_onPan(e){return this.isDragging()?this._panMove?this._onPanMove(e):this._onPanRotate(e):!1}_onPanEnd(e){return this.isDragging()?this._panMove?this._onPanMoveEnd(e):this._onPanRotateEnd(e):!1}_onPanMove(e){if(!this.dragPan)return!1;let t=this.getCenter(e),n=this.controllerState.pan({pos:t});return this.updateViewport(n,lO,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){let{inertia:t}=this;if(this.dragPan&&t&&e.velocity){let n=this.getCenter(e),r=[n[0]+e.velocityX*t/2,n[1]+e.velocityY*t/2],i=this.controllerState.pan({pos:r}).panEnd();this.updateViewport(i,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:dO},{isDragging:!1,isPanning:!0})}else{let e=this.controllerState.panEnd();this.updateViewport(e,null,{isDragging:!1,isPanning:!1})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;let t=this.getCenter(e),n=this.controllerState.rotate({pos:t});return this.updateViewport(n,lO,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){let{inertia:t}=this;if(this.dragRotate&&t&&e.velocity){let n=this.getCenter(e),r=[n[0]+e.velocityX*t/2,n[1]+e.velocityY*t/2],i=this.controllerState.rotate({pos:r}).rotateEnd();this.updateViewport(i,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:dO},{isDragging:!1,isRotating:!0})}else{let e=this.controllerState.rotateEnd();this.updateViewport(e,null,{isDragging:!1,isRotating:!1})}return!0}_onWheel(e){if(!this.scrollZoom)return!1;let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;e.srcEvent.preventDefault();let{speed:n=.01,smooth:r=!1}=this.scrollZoom===!0?{}:this.scrollZoom,{delta:i}=e,a=2/(1+Math.exp(-Math.abs(i*n)));i<0&&a!==0&&(a=1/a);let o=r?{...this._getTransitionProps({around:t}),transitionDuration:250}:lO,s=this.controllerState.zoom({pos:t,scale:a});return this.updateViewport(s,o,{isZooming:!0,isPanning:!0}),r||this._setInteractionState({isZooming:!1,isPanning:!1}),!0}_onMultiPanStart(e){let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let n=this.controllerState.rotateStart({pos:t});return this.updateViewport(n,lO,{isDragging:!0}),!0}_onMultiPan(e){if(!this.touchRotate||!this.isDragging())return!1;let t=this.getCenter(e);t[0]-=e.deltaX;let n=this.controllerState.rotate({pos:t});return this.updateViewport(n,lO,{isDragging:!0,isRotating:!0}),!0}_onMultiPanEnd(e){if(!this.isDragging())return!1;let{inertia:t}=this;if(this.touchRotate&&t&&e.velocityY){let n=this.getCenter(e),r=[n[0],n[1]+=e.velocityY*t/2],i=this.controllerState.rotate({pos:r});this.updateViewport(i,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:dO},{isDragging:!1,isRotating:!0}),this.blockEvents(t)}else{let e=this.controllerState.rotateEnd();this.updateViewport(e,null,{isDragging:!1,isRotating:!1})}return!0}_onPinchStart(e){let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let n=this.controllerState.zoomStart({pos:t}).rotateStart({pos:t});return pO._startPinchRotation=e.rotation,pO._lastPinchEvent=e,this.updateViewport(n,lO,{isDragging:!0}),!0}_onPinch(e){if(!this.touchZoom&&!this.touchRotate||!this.isDragging())return!1;let t=this.controllerState;if(this.touchZoom){let{scale:n}=e,r=this.getCenter(e);t=t.zoom({pos:r,scale:n})}if(this.touchRotate){let{rotation:n}=e;t=t.rotate({deltaAngleX:pO._startPinchRotation-n})}return this.updateViewport(t,lO,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),pO._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;let{inertia:t}=this,{_lastPinchEvent:n}=pO;if(this.touchZoom&&t&&n&&e.scale!==n.scale){let r=this.getCenter(e),i=this.controllerState.rotateEnd(),a=Math.log2(e.scale),o=2**(a+(a-Math.log2(n.scale))/(e.deltaTime-n.deltaTime)*t/2);i=i.zoom({pos:r,scale:o}).zoomEnd(),this.updateViewport(i,{...this._getTransitionProps({around:r}),transitionDuration:t,transitionEasing:dO},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(t)}else{let e=this.controllerState.zoomEnd().rotateEnd();this.updateViewport(e,null,{isDragging:!1,isPanning:!1,isZooming:!1,isRotating:!1})}return pO._startPinchRotation=null,pO._lastPinchEvent=null,!0}_onDoubleClick(e){if(!this.doubleClickZoom)return!1;let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let n=this.isFunctionKeyPressed(e),r=this.controllerState.zoom({pos:t,scale:n?.5:2});return this.updateViewport(r,this._getTransitionProps({around:t}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onKeyDown(e){if(!this.keyboard)return!1;let t=this.isFunctionKeyPressed(e),{zoomSpeed:n,moveSpeed:r,rotateSpeedX:i,rotateSpeedY:a}=this.keyboard===!0?{}:this.keyboard,{controllerState:o}=this,s,c={};switch(e.srcEvent.code){case`Minus`:s=t?o.zoomOut(n).zoomOut(n):o.zoomOut(n),c.isZooming=!0;break;case`Equal`:s=t?o.zoomIn(n).zoomIn(n):o.zoomIn(n),c.isZooming=!0;break;case`ArrowLeft`:t?(s=o.rotateLeft(i),c.isRotating=!0):(s=o.moveLeft(r),c.isPanning=!0);break;case`ArrowRight`:t?(s=o.rotateRight(i),c.isRotating=!0):(s=o.moveRight(r),c.isPanning=!0);break;case`ArrowUp`:t?(s=o.rotateUp(a),c.isRotating=!0):(s=o.moveUp(r),c.isPanning=!0);break;case`ArrowDown`:t?(s=o.rotateDown(a),c.isRotating=!0):(s=o.moveDown(r),c.isPanning=!0);break;default:return!1}return this.updateViewport(s,this._getTransitionProps(),c),!0}_getTransitionProps(e){let{transition:t}=this;return!t||!t.transitionInterpolator?lO:e?{...t,transitionInterpolator:new cO({...e,...t.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:t}},hO=class{constructor(e,t,n){this.makeViewport=n,this._viewportProps=this.applyConstraints(e),this._state=t}getViewportProps(){return this._viewportProps}getState(){return this._state}},gO=5,_O=1.2,vO=512,yO=[[-1/0,-90],[1/0,90]];function bO([e,t]){if(Math.abs(t)>90&&(t=Math.sign(t)*90),Number.isFinite(e)){let[n,r]=Tw([e,t]);return[n,f_(r,0,vO)]}let[,n]=Tw([0,t]);return[e,f_(n,0,vO)]}var xO=class extends hO{constructor(e){let{width:t,height:n,latitude:r,longitude:i,zoom:a,bearing:o=0,pitch:s=0,altitude:c=1.5,position:l=[0,0,0],maxZoom:u=20,minZoom:d=0,maxPitch:f=60,minPitch:p=0,startPanLngLat:m,startZoomLngLat:h,startRotatePos:g,startRotateLngLat:_,startBearing:v,startPitch:y,startZoom:b,normalize:x=!0}=e;ZD(Number.isFinite(i)),ZD(Number.isFinite(r)),ZD(Number.isFinite(a));let S=e.maxBounds||(x?yO:null);super({width:t,height:n,latitude:r,longitude:i,zoom:a,bearing:o,pitch:s,altitude:c,maxZoom:u,minZoom:d,maxPitch:f,minPitch:p,normalize:x,position:l,maxBounds:S},{startPanLngLat:m,startZoomLngLat:h,startRotatePos:g,startRotateLngLat:_,startBearing:v,startPitch:y,startZoom:b},e.makeViewport),this.getAltitude=e.getAltitude}panStart({pos:e}){return this._getUpdatedState({startPanLngLat:this._unproject(e)})}pan({pos:e,startPos:t}){let n=this.getState().startPanLngLat||this._unproject(t);if(!n)return this;let r=this.makeViewport(this.getViewportProps()).panByPosition(n,e);return this._getUpdatedState(r)}panEnd(){return this._getUpdatedState({startPanLngLat:null})}rotateStart({pos:e}){let t=this.getAltitude?.(e);return this._getUpdatedState({startRotatePos:e,startRotateLngLat:t===void 0?void 0:this._unproject3D(e,t),startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:t=0,deltaAngleY:n=0}){let{startRotatePos:r,startRotateLngLat:i,startBearing:a,startPitch:o}=this.getState();if(!r||a===void 0||o===void 0)return this;let s;if(s=e?this._getNewRotation(e,r,o,a):{bearing:a+t,pitch:o+n},i){let e=this.makeViewport({...this.getViewportProps(),...s}),t=`panByPosition3D`in e?`panByPosition3D`:`panByPosition`;return this._getUpdatedState({...s,...e[t](i,r)})}return this._getUpdatedState(s)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startRotateLngLat:null,startBearing:null,startPitch:null})}zoomStart({pos:e}){return this._getUpdatedState({startZoomLngLat:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:t,scale:n}){let{startZoom:r,startZoomLngLat:i}=this.getState();if(i||=(r=this.getViewportProps().zoom,this._unproject(t)||this._unproject(e)),!i)return this;let a=this._constrainZoom(r+Math.log2(n)),o=this.makeViewport({...this.getViewportProps(),zoom:a});return this._getUpdatedState({zoom:a,...o.panByPosition(i,e)})}zoomEnd(){return this._getUpdatedState({startZoomLngLat:null,startZoom:null})}zoomIn(e=2){return this._zoomFromCenter(e)}zoomOut(e=2){return this._zoomFromCenter(1/e)}moveLeft(e=100){return this._panFromCenter([e,0])}moveRight(e=100){return this._panFromCenter([-e,0])}moveUp(e=100){return this._panFromCenter([0,e])}moveDown(e=100){return this._panFromCenter([0,-e])}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}shortestPathFrom(e){let t=e.getViewportProps(),n={...this.getViewportProps()},{bearing:r,longitude:i}=n;return Math.abs(r-t.bearing)>180&&(n.bearing=r<0?r+360:r-360),Math.abs(i-t.longitude)>180&&(n.longitude=i<0?i+360:i-360),n}applyConstraints(e){let{maxPitch:t,minPitch:n,pitch:r,longitude:i,bearing:a,normalize:o,maxBounds:s}=e;if(o&&((i<-180||i>180)&&(e.longitude=OT(i+180,360)-180),(a<-180||a>180)&&(e.bearing=OT(a+180,360)-180)),e.pitch=f_(r,n,t),e.zoom=this._constrainZoom(e.zoom,e),s){let t=bO(s[0]),n=bO(s[1]),r=2**e.zoom,i=e.width/2/r,a=e.height/2/r,[o,c]=Ew([t[0]+i,t[1]+a]),[l,u]=Ew([n[0]-i,n[1]-a]);e.longitude=f_(e.longitude,o,l),e.latitude=f_(e.latitude,c,u)}return e}_constrainZoom(e,t){t||=this.getViewportProps();let{maxZoom:n,maxBounds:r}=t,i=r!==null&&t.width>0&&t.height>0,{minZoom:a}=t;if(i){let e=bO(r[0]),i=bO(r[1]),o=i[0]-e[0],s=i[1]-e[1];Number.isFinite(o)&&o>0&&(a=Math.max(a,Math.log2(t.width/o))),Number.isFinite(s)&&s>0&&(a=Math.max(a,Math.log2(t.height/s))),a>n&&(a=n)}return f_(e,a,n)}_zoomFromCenter(e){let{width:t,height:n}=this.getViewportProps();return this.zoom({pos:[t/2,n/2],scale:e})}_panFromCenter(e){let{width:t,height:n}=this.getViewportProps();return this.pan({startPos:[t/2,n/2],pos:[t/2+e[0],n/2+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}_unproject(e){let t=this.makeViewport(this.getViewportProps());return e&&t.unproject(e)}_unproject3D(e,t){return this.makeViewport(this.getViewportProps()).unproject(e,{targetZ:t})}_getNewRotation(e,t,n,r){let i=e[0]-t[0],a=e[1]-t[1],o=e[1],s=t[1],{width:c,height:l}=this.getViewportProps(),u=i/c,d=0;a>0?Math.abs(l-s)>gO&&(d=a/(s-l)*_O):a<0&&s>gO&&(d=1-o/s),d=f_(d,-1,1);let{minPitch:f,maxPitch:p}=this.getViewportProps(),m=r+180*u,h=n;return d>0?h=n+d*(p-n):d<0&&(h=n-d*(f-n)),{pitch:h,bearing:m}}},SO=class extends mO{constructor(){super(...arguments),this.ControllerState=xO,this.transition={transitionDuration:300,transitionInterpolator:new cO({transitionProps:{compare:[`longitude`,`latitude`,`zoom`,`bearing`,`pitch`,`position`],required:[`longitude`,`latitude`,`zoom`]}})},this.dragMode=`pan`,this.rotationPivot=`center`,this._getAltitude=e=>{if(this.rotationPivot===`2d`)return 0;if(this.rotationPivot===`3d`&&this.pickPosition){let{x:t,y:n}=this.props,r=this.pickPosition(t+e[0],n+e[1]);if(r&&r.coordinate&&r.coordinate.length>=3)return r.coordinate[2]}}}setProps(e){`rotationPivot`in e&&(this.rotationPivot=e.rotationPivot||`center`),e.getAltitude=this._getAltitude,e.position=e.position||[0,0,0],e.maxBounds=e.maxBounds||(e.normalize===!1?null:yO),super.setProps(e)}updateViewport(e,t=null,n={}){let r=e.getState();n.isDragging&&r.startRotateLngLat?n={...n,rotationPivotPosition:r.startRotateLngLat}:n.isDragging===!1&&(n={...n,rotationPivotPosition:void 0}),super.updateViewport(e,t,n)}},CO=class extends WD{constructor(e={}){super(e)}getViewportType(){return UT}get ControllerType(){return SO}};CO.displayName=`MapView`;var wO=new TT;function TO(e,t){return(e.order??1/0)-(t.order??1/0)}var EO=class{constructor(e){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=e,this._needsRedraw=`Initial render`,this._setEffects([])}addDefaultEffect(e){let t=this._defaultEffects;if(!t.find(t=>t.id===e.id)){let n=t.findIndex(t=>TO(t,e)>0);n<0?t.push(e):t.splice(n,0,e),e.setup(this._context),this._setEffects(this.effects)}}setProps(e){`effects`in e&&(jD(e.effects,this.effects,1)||this._setEffects(e.effects))}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}getEffects(){return this._resolvedEffects}_setEffects(e){let t={};for(let e of this.effects)t[e.id]=e;let n=[];for(let r of e){let e=t[r.id],i=r;e&&e!==r?e.setProps?(e.setProps(r.props),i=e):e.cleanup(this._context):e||r.setup(this._context),n.push(i),delete t[r.id]}for(let e in t)t[e].cleanup(this._context);this.effects=n,this._resolvedEffects=n.concat(this._defaultEffects),e.some(e=>e instanceof TT)||this._resolvedEffects.push(wO),this._needsRedraw=`effects changed`}finalize(){for(let e of this._resolvedEffects)e.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}},DO=class extends _T{shouldDrawLayer(e){let{operation:t}=e.props;return t.includes(`draw`)||t.includes(`terrain`)}render(e){return this._render(e)}},OO=`deckRenderer.renderLayers`,kO=class{constructor(e,t={}){this.device=e,this.stats=t.stats,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new DO(e),this.pickLayersPass=new pD(e),this.renderCount=0,this._needsRedraw=`Initial render`,this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(e){this.layerFilter!==e.layerFilter&&(this.layerFilter=e.layerFilter,this._needsRedraw=`layerFilter changed`),this.drawPickingColors!==e.drawPickingColors&&(this.drawPickingColors=e.drawPickingColors,this._needsRedraw=`drawPickingColors changed`)}renderLayers(e){if(!e.viewports.length)return;let t=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,n={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e};n.effects&&this._preRender(n.effects,n);let r=this.lastPostProcessEffect?this.renderBuffers[0]:n.target;this.lastPostProcessEffect&&(n.clearColor=[0,0,0,0],n.clearCanvas=!0);let i=t.render({...n,target:r}),a=`stats`in i?i.stats:i;n.effects&&(this.lastPostProcessEffect&&(n.clearCanvas=e.clearCanvas===void 0?!0:e.clearCanvas),this._postRender(n.effects,n)),this.renderCount++,ih(OO,this,a,e),this._updateStats(a)}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}finalize(){let{renderBuffers:e}=this;for(let t of e)t.delete();e.length=0}_updateStats(e){if(!this.stats)return;let t=0;for(let{visibleCount:n}of e)t+=n;this.stats.get(`Layers rendered`).addCount(t)}_preRender(e,t){this.lastPostProcessEffect=null,t.preRenderStats=t.preRenderStats||{};for(let n of e)t.preRenderStats[n.id]=n.preRender(t),n.postRender&&(this.lastPostProcessEffect=n.id);this.lastPostProcessEffect&&this._resizeRenderBuffers()}_resizeRenderBuffers(){let{renderBuffers:e}=this,t=this.device.canvasContext.getDrawingBufferSize(),[n,r]=t;e.length===0&&[0,1].map(t=>{let i=this.device.createTexture({sampler:{minFilter:`linear`,magFilter:`linear`},width:n,height:r});e.push(this.device.createFramebuffer({id:`deck-renderbuffer-${t}`,colorAttachments:[i]}))});for(let n of e)n.resize(t)}_postRender(e,t){let{renderBuffers:n}=this,r={...t,inputBuffer:n[0],swapBuffer:n[1]};for(let i of e)if(i.postRender){r.target=i.id===this.lastPostProcessEffect?t.target:void 0;let e=i.postRender(r);r.inputBuffer=e,r.swapBuffer=e===n[0]?n[1]:n[0]}}},AO={pickedColor:null,pickedObjectIndex:-1};function jO({pickedColors:e,decodePickingColor:t,deviceX:n,deviceY:r,deviceRadius:i,deviceRect:a}){let{x:o,y:s,width:c,height:l}=a,u=i*i,d=-1,f=0;for(let t=0;t<l;t++){let i=t+s-r,a=i*i;if(a>u)f+=4*c;else for(let t=0;t<c;t++){if(e[f+3]-1>=0){let e=t+o-n,r=e*e+a;r<=u&&(u=r,d=f)}f+=4}}if(d>=0){let n=e.slice(d,d+4),r=t(n);if(r){let e=Math.floor(d/4/c),t=d/4-e*c;return{...r,pickedColor:n,pickedX:o+t,pickedY:s+e}}X.error(`Picked non-existent layer. Is picking buffer corrupt?`)()}return AO}function MO({pickedColors:e,decodePickingColor:t}){let n=new Map;if(e){for(let r=0;r<e.length;r+=4)if(e[r+3]-1>=0){let i=e.slice(r,r+4),a=i.join(`,`);if(!n.has(a)){let e=t(i);e?n.set(a,{...e,color:i}):X.error(`Picked non-existent layer. Is picking buffer corrupt?`)()}}}return Array.from(n.values())}function NO({pickInfo:e,viewports:t,pixelRatio:n,x:r,y:i,z:a}){let o=t[0];t.length>1&&(o=IO(e?.pickedViewports||t,{x:r,y:i}));let s;if(o){let e=[r-o.x,i-o.y];a!==void 0&&(e[2]=a),s=o.unproject(e)}return{color:null,layer:null,viewport:o,index:-1,picked:!1,x:r,y:i,pixel:[r,i],coordinate:s,devicePixel:e&&`pickedX`in e?[e.pickedX,e.pickedY]:void 0,pixelRatio:n}}function PO(e){let{pickInfo:t,lastPickedInfo:n,mode:r,layers:i}=e,{pickedColor:a,pickedLayer:o,pickedObjectIndex:s}=t,c=o?[o]:[];if(r===`hover`){let e=n.index,t=n.layerId,r=o?o.props.id:null;if(r!==t||s!==e){if(r!==t){let e=i.find(e=>e.props.id===t);e&&c.unshift(e)}n.layerId=r,n.index=s,n.info=null}}let l=NO(e),u=new Map;return u.set(null,l),c.forEach(e=>{let t={...l};e===o&&(t.color=a,t.index=s,t.picked=!0),t=FO({layer:e,info:t,mode:r});let i=t.layer;e===o&&r===`hover`&&(n.info=t),u.set(i.id,t),r===`hover`&&i.updateAutoHighlight(t)}),u}function FO({layer:e,info:t,mode:n}){for(;e&&t;){let r=t.layer||null;t.sourceLayer=r,t.layer=e,t=e.getPickingInfo({info:t,mode:n,sourceLayer:r}),e=e.parent}return t}function IO(e,t){for(let n=e.length-1;n>=0;n--){let r=e[n];if(r.containsPixel(t))return r}return e[0]}var LO=class{constructor(e,t={}){this._pickable=!0,this.device=e,this.stats=t.stats,this.pickLayersPass=new pD(e),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(e){`layerFilter`in e&&(this.layerFilter=e.layerFilter),`_pickable`in e&&(this._pickable=e._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}pickObjectAsync(e){return this._pickClosestObjectAsync(e)}pickObjectsAsync(e){return this._pickVisibleObjectsAsync(e)}pickObject(e){return this._pickClosestObject(e)}pickObjects(e){return this._pickVisibleObjects(e)}getLastPickedObject({x:e,y:t,layers:n,viewports:r},i=this.lastPickedInfo.info){let a=i&&i.layer&&i.layer.id,o=i&&i.viewport&&i.viewport.id,s=a?n.find(e=>e.id===a):null,c=o&&r.find(e=>e.id===o)||r[0],l={x:e,y:t,viewport:c,coordinate:c&&c.unproject([e-c.x,t-c.y]),layer:s};return{...i,...l}}_resizeBuffer(){if(!this.pickingFBO){let e=this.device.createTexture({format:`rgba8unorm`,width:1,height:1,usage:zb.RENDER_ATTACHMENT|zb.COPY_SRC});if(this.pickingFBO=this.device.createFramebuffer({colorAttachments:[e],depthStencilAttachment:`depth16unorm`}),this.device.isTextureFormatRenderable(`rgba32float`)){let e=this.device.createTexture({format:`rgba32float`,width:1,height:1,usage:zb.RENDER_ATTACHMENT|zb.COPY_SRC}),t=this.device.createFramebuffer({colorAttachments:[e],depthStencilAttachment:`depth16unorm`});this.depthFBO=t}}let{canvas:e}=this.device.getDefaultCanvasContext();this.pickingFBO?.resize({width:e.width,height:e.height}),this.depthFBO?.resize({width:e.width,height:e.height})}_getPickable(e){if(this._pickable===!1)return null;let t=e.filter(e=>this.pickLayersPass.shouldDrawLayer(e)&&!e.isComposite);return t.length?t:null}async _pickClosestObjectAsync({layers:e,views:t,viewports:n,x:r,y:i,radius:a=0,depth:o=1,mode:s=`query`,unproject3D:c,onViewportActive:l,effects:u}){let d=this.device.canvasContext.cssToDeviceRatio(),f=this._getPickable(e);if(!f||n.length===0)return{result:[],emptyInfo:NO({viewports:n,x:r,y:i,pixelRatio:d})};this._resizeBuffer();let p=this.device.canvasContext.cssToDevicePixels([r,i],!0),m=[p.x+Math.floor(p.width/2),p.y+Math.floor(p.height/2)],h=Math.round(a*d),{width:g,height:_}=this.pickingFBO,v=this._getPickingRect({deviceX:m[0],deviceY:m[1],deviceRadius:h,deviceWidth:g,deviceHeight:_}),y={x:r-a,y:i-a,width:a*2+1,height:a*2+1},b,x=[],S=new Set;for(let e=0;e<o;e++){let a;a=v?jO({...await this._drawAndSampleAsync({layers:f,views:t,viewports:n,onViewportActive:l,deviceRect:v,cullRect:y,effects:u,pass:`picking:${s}`}),deviceX:m[0],deviceY:m[1],deviceRadius:h,deviceRect:v}):{pickedColor:null,pickedObjectIndex:-1};let p,g=this._getDepthLayers(a,f,c);if(g.length>0){let{pickedColors:e}=await this._drawAndSampleAsync({layers:g,views:t,viewports:n,onViewportActive:l,deviceRect:{x:a.pickedX??m[0],y:a.pickedY??m[1],width:1,height:1},cullRect:y,effects:u,pass:`picking:${s}:z`},!0);e[3]&&(p=e[0])}a.pickedLayer&&e+1<o&&(S.add(a.pickedLayer),a.pickedLayer.disablePickingIndex(a.pickedObjectIndex)),b=PO({pickInfo:a,lastPickedInfo:this.lastPickedInfo,mode:s,layers:f,viewports:n,x:r,y:i,z:p,pixelRatio:d});for(let e of b.values())e.layer&&x.push(e);if(!a.pickedColor)break}for(let e of S)e.restorePickingColors();return{result:x,emptyInfo:b.get(null)}}_pickClosestObject({layers:e,views:t,viewports:n,x:r,y:i,radius:a=0,depth:o=1,mode:s=`query`,unproject3D:c,onViewportActive:l,effects:u}){let d=this.device.canvasContext.cssToDeviceRatio(),f=this._getPickable(e);if(!f||n.length===0)return{result:[],emptyInfo:NO({viewports:n,x:r,y:i,pixelRatio:d})};this._resizeBuffer();let p=this.device.canvasContext.cssToDevicePixels([r,i],!0),m=[p.x+Math.floor(p.width/2),p.y+Math.floor(p.height/2)],h=Math.round(a*d),{width:g,height:_}=this.pickingFBO,v=this._getPickingRect({deviceX:m[0],deviceY:m[1],deviceRadius:h,deviceWidth:g,deviceHeight:_}),y={x:r-a,y:i-a,width:a*2+1,height:a*2+1},b,x=[],S=new Set;for(let e=0;e<o;e++){let a;a=v?jO({...this._drawAndSample({layers:f,views:t,viewports:n,onViewportActive:l,deviceRect:v,cullRect:y,effects:u,pass:`picking:${s}`}),deviceX:m[0],deviceY:m[1],deviceRadius:h,deviceRect:v}):{pickedColor:null,pickedObjectIndex:-1};let p,g=this._getDepthLayers(a,f,c);if(g.length>0){let{pickedColors:e}=this._drawAndSample({layers:g,views:t,viewports:n,onViewportActive:l,deviceRect:{x:a.pickedX??m[0],y:a.pickedY??m[1],width:1,height:1},cullRect:y,effects:u,pass:`picking:${s}:z`},!0);e[3]&&(p=e[0])}a.pickedLayer&&e+1<o&&(S.add(a.pickedLayer),a.pickedLayer.disablePickingIndex(a.pickedObjectIndex)),b=PO({pickInfo:a,lastPickedInfo:this.lastPickedInfo,mode:s,layers:f,viewports:n,x:r,y:i,z:p,pixelRatio:d});for(let e of b.values())e.layer&&x.push(e);if(!a.pickedColor)break}for(let e of S)e.restorePickingColors();return{result:x,emptyInfo:b.get(null)}}async _pickVisibleObjectsAsync({layers:e,views:t,viewports:n,x:r,y:i,width:a=1,height:o=1,mode:s=`query`,maxObjects:c=null,onViewportActive:l,effects:u}){let d=this._getPickable(e);if(!d||n.length===0)return[];this._resizeBuffer();let f=this.device.canvasContext.cssToDeviceRatio(),p=this.device.canvasContext.cssToDevicePixels([r,i],!0),m=p.x,h=p.y+p.height,g=this.device.canvasContext.cssToDevicePixels([r+a,i+o],!0),_=g.x+g.width,v=g.y,y={x:m,y:v,width:_-m,height:h-v},b=MO(await this._drawAndSampleAsync({layers:d,views:t,viewports:n,onViewportActive:l,deviceRect:y,cullRect:{x:r,y:i,width:a,height:o},effects:u,pass:`picking:${s}`})),x=new Map,S=[],C=Number.isFinite(c);for(let e=0;e<b.length&&!(C&&S.length>=c);e++){let t=b[e],n={color:t.pickedColor,layer:null,index:t.pickedObjectIndex,picked:!0,x:r,y:i,pixelRatio:f};n=FO({layer:t.pickedLayer,info:n,mode:s});let a=n.layer.id;x.has(a)||x.set(a,new Set);let o=x.get(a),c=n.object??n.index;o.has(c)||(o.add(c),S.push(n))}return S}_pickVisibleObjects({layers:e,views:t,viewports:n,x:r,y:i,width:a=1,height:o=1,mode:s=`query`,maxObjects:c=null,onViewportActive:l,effects:u}){let d=this._getPickable(e);if(!d||n.length===0)return[];this._resizeBuffer();let f=this.device.canvasContext.cssToDeviceRatio(),p=this.device.canvasContext.cssToDevicePixels([r,i],!0),m=p.x,h=p.y+p.height,g=this.device.canvasContext.cssToDevicePixels([r+a,i+o],!0),_=g.x+g.width,v=g.y,y={x:m,y:v,width:_-m,height:h-v},b=MO(this._drawAndSample({layers:d,views:t,viewports:n,onViewportActive:l,deviceRect:y,cullRect:{x:r,y:i,width:a,height:o},effects:u,pass:`picking:${s}`})),x=new Map,S=[],C=Number.isFinite(c);for(let e=0;e<b.length&&!(C&&S.length>=c);e++){let t=b[e],n={color:t.pickedColor,layer:null,index:t.pickedObjectIndex,picked:!0,x:r,y:i,pixelRatio:f};n=FO({layer:t.pickedLayer,info:n,mode:s});let a=n.layer.id;x.has(a)||x.set(a,new Set);let o=x.get(a),c=n.object??n.index;o.has(c)||(o.add(c),S.push(n))}return S}async _drawAndSampleAsync({layers:e,views:t,viewports:n,onViewportActive:r,deviceRect:i,cullRect:a,effects:o,pass:s},c=!1){let l=c?this.depthFBO:this.pickingFBO,u={layers:e,layerFilter:this.layerFilter,views:t,viewports:n,onViewportActive:r,pickingFBO:l,deviceRect:i,cullRect:a,effects:o,pass:s,pickZ:c,preRenderStats:{},isPicking:!0};for(let e of o)e.useInPicking&&(u.preRenderStats[e.id]=e.preRender(u));let{decodePickingColor:d,stats:f}=this.pickLayersPass.render(u);this._updateStats(f);let{x:p,y:m,width:h,height:g}=i,_=l.colorAttachments[0]?.texture;if(!_)throw Error(`Picking framebuffer color attachment is missing`);let v=await this._readTextureDataAsync(_,{x:p,y:m,width:h,height:g},c?Float32Array:Uint8Array);if(!c){let e=!1;for(let t=3;t<v.length;t+=4)if(v[t]!==0){e=!0;break}!e&&v.length>0&&X.warn(`Async pick readback returned only zero alpha values`,{deviceRect:i,bytes:Array.from(v.subarray(0,Math.min(v.length,16)))})()}return{pickedColors:v,decodePickingColor:d}}async _readTextureDataAsync(e,t,n){let{width:r,height:i}=t,a=e.computeMemoryLayout(t),o=this.device.createBuffer({byteLength:a.byteLength,usage:Sy.COPY_DST|Sy.MAP_READ});try{e.readBuffer(t,o);let s=await o.readAsync(0,a.byteLength),c=n.BYTES_PER_ELEMENT;if(a.bytesPerRow%c!==0)throw Error(`Texture readback row stride ${a.bytesPerRow} is not aligned to ${c}-byte elements.`);let l=new n(s.buffer,s.byteOffset,a.byteLength/c),u=r*4,d=a.bytesPerRow/c;if(d<u)throw Error(`Texture readback row stride ${d} is smaller than packed row length ${u}.`);let f=new n(r*i*4);for(let e=0;e<i;e++){let t=e*d;f.set(l.subarray(t,t+u),e*u)}return f}finally{o.destroy()}}_drawAndSample({layers:e,views:t,viewports:n,onViewportActive:r,deviceRect:i,cullRect:a,effects:o,pass:s},c=!1){let l=c?this.depthFBO:this.pickingFBO,u={layers:e,layerFilter:this.layerFilter,views:t,viewports:n,onViewportActive:r,pickingFBO:l,deviceRect:i,cullRect:a,effects:o,pass:s,pickZ:c,preRenderStats:{},isPicking:!0};for(let e of o)e.useInPicking&&(u.preRenderStats[e.id]=e.preRender(u));let{decodePickingColor:d,stats:f}=this.pickLayersPass.render(u);this._updateStats(f);let{x:p,y:m,width:h,height:g}=i,_=new(c?Float32Array:Uint8Array)(h*g*4);return this.device.readPixelsToArrayWebGL(l,{sourceX:p,sourceY:m,sourceWidth:h,sourceHeight:g,target:_}),{pickedColors:_,decodePickingColor:d}}_updateStats(e){if(!this.stats)return;let t=0;for(let{visibleCount:n}of e)t+=n;this.stats.get(`Layers picked`).addCount(t)}_getDepthLayers(e,t,n){if(!n||!this.depthFBO)return[];let{pickedLayer:r}=e,i=r?.state?.terrainDrawMode===`drape`;return r&&!i?[r]:t.filter(e=>e.props.operation.includes(`terrain`))}_getPickingRect({deviceX:e,deviceY:t,deviceRadius:n,deviceWidth:r,deviceHeight:i}){let a=Math.max(0,e-n),o=Math.max(0,t-n),s=Math.min(r,e+n+1)-a,c=Math.min(i,t+n+1)-o;return s<=0||c<=0?null:{x:a,y:o,width:s,height:c}}},RO={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0},fill:{top:0,left:0,bottom:0,right:0}},zO=`top-left`,BO=`root`,VO=class{constructor({deck:e,parentElement:t}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=e,t?.classList.add(`deck-widget-container`),this.parentElement=t}getWidgets(){return this.resolvedWidgets}setProps(e){if(e.widgets&&!jD(e.widgets,this.widgets,1)){let t=e.widgets.filter(Boolean);this._setWidgets(t)}}finalize(){for(let e of this.getWidgets())this._removeWidget(e);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(let e in this.containers)this.containers[e].remove()}addDefault(e){this.defaultWidgets.find(t=>t.id===e.id)||(this._addWidget(e),this.defaultWidgets.push(e),this._setWidgets(this.widgets))}onRedraw({viewports:e,layers:t}){let n=e.reduce((e,t)=>(e[t.id]=t,e),{});for(let r of this.getWidgets()){let{viewId:i}=r;if(i){let e=n[i];e&&(r.onViewportChange&&r.onViewportChange(e),r.onRedraw?.({viewports:[e],layers:t}))}else{if(r.onViewportChange)for(let t of e)r.onViewportChange(t);r.onRedraw?.({viewports:e,layers:t})}}this.lastViewports=n,this._updateContainers()}onHover(e,t){for(let n of this.getWidgets()){let{viewId:r}=n;(!r||r===e.viewport?.id)&&n.onHover?.(e,t)}}onEvent(e,t){let n=HC[t.type];if(n)for(let r of this.getWidgets()){let{viewId:i}=r;(!i||i===e.viewport?.id)&&r[n]?.(e,t)}}_setWidgets(e){let t={};for(let e of this.resolvedWidgets)t[e.id]=e;this.resolvedWidgets.length=0;for(let e of this.defaultWidgets)t[e.id]=null,this.resolvedWidgets.push(e);for(let n of e){let e=t[n.id];e?e.viewId!==n.viewId||e.placement!==n.placement?(this._removeWidget(e),this._addWidget(n)):n!==e&&(e.setProps(n.props),n=e):this._addWidget(n),t[n.id]=null,this.resolvedWidgets.push(n)}for(let e in t){let n=t[e];n&&this._removeWidget(n)}this.widgets=e}_addWidget(e){let{viewId:t=null,placement:n=zO}=e,r=e.props._container??t;e.widgetManager=this,e.deck=this.deck,e.rootElement=e._onAdd({deck:this.deck,viewId:t}),e.rootElement&&this._getContainer(r,n).append(e.rootElement),e.updateHTML()}_removeWidget(e){e.onRemove?.(),e.rootElement&&e.rootElement.remove(),e.rootElement=void 0,e.deck=void 0,e.widgetManager=void 0}_getContainer(e,t){if(e&&typeof e!=`string`)return e;let n=e||BO,r=this.containers[n];r||(r=document.createElement(`div`),r.style.pointerEvents=`none`,r.style.position=`absolute`,r.style.overflow=`hidden`,this.parentElement?.append(r),this.containers[n]=r);let i=r.querySelector(`.${t}`);return i||(i=globalThis.document.createElement(`div`),i.className=t,i.style.position=`absolute`,i.style.zIndex=`2`,Object.assign(i.style,RO[t]),r.append(i)),i}_updateContainers(){let e=this.deck.width,t=this.deck.height;for(let n in this.containers){let r=this.lastViewports[n]||null,i=n===BO||r,a=this.containers[n];i?(a.style.display=`block`,a.style.left=`${r?r.x:0}px`,a.style.top=`${r?r.y:0}px`,a.style.width=`${r?r.width:e}px`,a.style.height=`${r?r.height:t}px`):a.style.display=`none`}}};function HO(e,t){t&&Object.entries(t).map(([t,n])=>{t.startsWith(`--`)?e.style.setProperty(t,n):e.style[t]=n})}function UO(e,t){t&&Object.keys(t).map(t=>{t.startsWith(`--`)?e.style.removeProperty(t):e.style[t]=``})}var WO=class{constructor(e){this.viewId=null,this.props={...this.constructor.defaultProps,...e},this.id=this.props.id}setProps(e){let t=this.props,n=this.rootElement;n&&t.className!==e.className&&(t.className&&n.classList.remove(t.className),e.className&&n.classList.add(e.className)),n&&!jD(t.style,e.style,1)&&(UO(n,t.style),HO(n,e.style)),Object.assign(this.props,e),this.updateHTML()}updateHTML(){this.rootElement&&this.onRenderHTML(this.rootElement)}get viewIds(){return this.viewId?[this.viewId]:this.deck?.getViews().map(e=>e.id)??[]}getViewState(e){return this.deck?.viewManager?.getViewState(e)||{}}setViewState(e,t){this.deck?._onViewStateChange({viewId:e,viewState:t,interactionState:{}})}onCreateRootElement(){let e=[`deck-widget`,this.className,this.props.className],t=document.createElement(`div`);return e.filter(e=>typeof e==`string`&&e.length>0).forEach(e=>t.classList.add(e)),HO(t,this.props.style),t}_onAdd(e){return this.onAdd(e)??this.onCreateRootElement()}onAdd(e){}onRemove(){}onViewportChange(e){}onRedraw(e){}onHover(e,t){}onClick(e,t){}onDrag(e,t){}onDragStart(e,t){}onDragEnd(e,t){}};WO.defaultProps={id:`widget`,style:{},_container:null,className:``};var GO={zIndex:`1`,position:`absolute`,pointerEvents:`none`,color:`#a0a7b4`,backgroundColor:`#29323c`,padding:`10px`,top:`0`,left:`0`,display:`none`},KO=class extends WO{constructor(e={}){super(e),this.id=`default-tooltip`,this.placement=`fill`,this.className=`deck-tooltip`,this.isVisible=!1,this.setProps(e)}onCreateRootElement(){let e=document.createElement(`div`);return e.className=this.className,Object.assign(e.style,GO),e}onRenderHTML(e){}onViewportChange(e){this.isVisible&&e.id===this.lastViewport?.id&&!e.equals(this.lastViewport)&&this.setTooltip(null),this.lastViewport=e}onHover(e){let{deck:t}=this,n=t&&t.props.getTooltip;if(!n)return;let r=n(e);this.setTooltip(r,e.x,e.y)}setTooltip(e,t,n){let r=this.rootElement;if(r){if(typeof e==`string`)r.innerText=e;else if(e)e.text&&(r.innerText=e.text),e.html&&(r.innerHTML=e.html),e.className&&(r.className=e.className);else{this.isVisible=!1,r.style.display=`none`;return}this.isVisible=!0,r.style.display=`block`,r.style.transform=`translate(${t}px, ${n}px)`,e&&typeof e==`object`&&`style`in e&&Object.assign(r.style,e.style)}}};KO.defaultProps={...WO.defaultProps};var qO;(function(e){e[e.DEPTH_BUFFER_BIT=256]=`DEPTH_BUFFER_BIT`,e[e.STENCIL_BUFFER_BIT=1024]=`STENCIL_BUFFER_BIT`,e[e.COLOR_BUFFER_BIT=16384]=`COLOR_BUFFER_BIT`,e[e.POINTS=0]=`POINTS`,e[e.LINES=1]=`LINES`,e[e.LINE_LOOP=2]=`LINE_LOOP`,e[e.LINE_STRIP=3]=`LINE_STRIP`,e[e.TRIANGLES=4]=`TRIANGLES`,e[e.TRIANGLE_STRIP=5]=`TRIANGLE_STRIP`,e[e.TRIANGLE_FAN=6]=`TRIANGLE_FAN`,e[e.ZERO=0]=`ZERO`,e[e.ONE=1]=`ONE`,e[e.SRC_COLOR=768]=`SRC_COLOR`,e[e.ONE_MINUS_SRC_COLOR=769]=`ONE_MINUS_SRC_COLOR`,e[e.SRC_ALPHA=770]=`SRC_ALPHA`,e[e.ONE_MINUS_SRC_ALPHA=771]=`ONE_MINUS_SRC_ALPHA`,e[e.DST_ALPHA=772]=`DST_ALPHA`,e[e.ONE_MINUS_DST_ALPHA=773]=`ONE_MINUS_DST_ALPHA`,e[e.DST_COLOR=774]=`DST_COLOR`,e[e.ONE_MINUS_DST_COLOR=775]=`ONE_MINUS_DST_COLOR`,e[e.SRC_ALPHA_SATURATE=776]=`SRC_ALPHA_SATURATE`,e[e.CONSTANT_COLOR=32769]=`CONSTANT_COLOR`,e[e.ONE_MINUS_CONSTANT_COLOR=32770]=`ONE_MINUS_CONSTANT_COLOR`,e[e.CONSTANT_ALPHA=32771]=`CONSTANT_ALPHA`,e[e.ONE_MINUS_CONSTANT_ALPHA=32772]=`ONE_MINUS_CONSTANT_ALPHA`,e[e.FUNC_ADD=32774]=`FUNC_ADD`,e[e.FUNC_SUBTRACT=32778]=`FUNC_SUBTRACT`,e[e.FUNC_REVERSE_SUBTRACT=32779]=`FUNC_REVERSE_SUBTRACT`,e[e.BLEND_EQUATION=32777]=`BLEND_EQUATION`,e[e.BLEND_EQUATION_RGB=32777]=`BLEND_EQUATION_RGB`,e[e.BLEND_EQUATION_ALPHA=34877]=`BLEND_EQUATION_ALPHA`,e[e.BLEND_DST_RGB=32968]=`BLEND_DST_RGB`,e[e.BLEND_SRC_RGB=32969]=`BLEND_SRC_RGB`,e[e.BLEND_DST_ALPHA=32970]=`BLEND_DST_ALPHA`,e[e.BLEND_SRC_ALPHA=32971]=`BLEND_SRC_ALPHA`,e[e.BLEND_COLOR=32773]=`BLEND_COLOR`,e[e.ARRAY_BUFFER_BINDING=34964]=`ARRAY_BUFFER_BINDING`,e[e.ELEMENT_ARRAY_BUFFER_BINDING=34965]=`ELEMENT_ARRAY_BUFFER_BINDING`,e[e.LINE_WIDTH=2849]=`LINE_WIDTH`,e[e.ALIASED_POINT_SIZE_RANGE=33901]=`ALIASED_POINT_SIZE_RANGE`,e[e.ALIASED_LINE_WIDTH_RANGE=33902]=`ALIASED_LINE_WIDTH_RANGE`,e[e.CULL_FACE_MODE=2885]=`CULL_FACE_MODE`,e[e.FRONT_FACE=2886]=`FRONT_FACE`,e[e.DEPTH_RANGE=2928]=`DEPTH_RANGE`,e[e.DEPTH_WRITEMASK=2930]=`DEPTH_WRITEMASK`,e[e.DEPTH_CLEAR_VALUE=2931]=`DEPTH_CLEAR_VALUE`,e[e.DEPTH_FUNC=2932]=`DEPTH_FUNC`,e[e.STENCIL_CLEAR_VALUE=2961]=`STENCIL_CLEAR_VALUE`,e[e.STENCIL_FUNC=2962]=`STENCIL_FUNC`,e[e.STENCIL_FAIL=2964]=`STENCIL_FAIL`,e[e.STENCIL_PASS_DEPTH_FAIL=2965]=`STENCIL_PASS_DEPTH_FAIL`,e[e.STENCIL_PASS_DEPTH_PASS=2966]=`STENCIL_PASS_DEPTH_PASS`,e[e.STENCIL_REF=2967]=`STENCIL_REF`,e[e.STENCIL_VALUE_MASK=2963]=`STENCIL_VALUE_MASK`,e[e.STENCIL_WRITEMASK=2968]=`STENCIL_WRITEMASK`,e[e.STENCIL_BACK_FUNC=34816]=`STENCIL_BACK_FUNC`,e[e.STENCIL_BACK_FAIL=34817]=`STENCIL_BACK_FAIL`,e[e.STENCIL_BACK_PASS_DEPTH_FAIL=34818]=`STENCIL_BACK_PASS_DEPTH_FAIL`,e[e.STENCIL_BACK_PASS_DEPTH_PASS=34819]=`STENCIL_BACK_PASS_DEPTH_PASS`,e[e.STENCIL_BACK_REF=36003]=`STENCIL_BACK_REF`,e[e.STENCIL_BACK_VALUE_MASK=36004]=`STENCIL_BACK_VALUE_MASK`,e[e.STENCIL_BACK_WRITEMASK=36005]=`STENCIL_BACK_WRITEMASK`,e[e.VIEWPORT=2978]=`VIEWPORT`,e[e.SCISSOR_BOX=3088]=`SCISSOR_BOX`,e[e.COLOR_CLEAR_VALUE=3106]=`COLOR_CLEAR_VALUE`,e[e.COLOR_WRITEMASK=3107]=`COLOR_WRITEMASK`,e[e.UNPACK_ALIGNMENT=3317]=`UNPACK_ALIGNMENT`,e[e.PACK_ALIGNMENT=3333]=`PACK_ALIGNMENT`,e[e.MAX_TEXTURE_SIZE=3379]=`MAX_TEXTURE_SIZE`,e[e.MAX_VIEWPORT_DIMS=3386]=`MAX_VIEWPORT_DIMS`,e[e.SUBPIXEL_BITS=3408]=`SUBPIXEL_BITS`,e[e.RED_BITS=3410]=`RED_BITS`,e[e.GREEN_BITS=3411]=`GREEN_BITS`,e[e.BLUE_BITS=3412]=`BLUE_BITS`,e[e.ALPHA_BITS=3413]=`ALPHA_BITS`,e[e.DEPTH_BITS=3414]=`DEPTH_BITS`,e[e.STENCIL_BITS=3415]=`STENCIL_BITS`,e[e.POLYGON_OFFSET_UNITS=10752]=`POLYGON_OFFSET_UNITS`,e[e.POLYGON_OFFSET_FACTOR=32824]=`POLYGON_OFFSET_FACTOR`,e[e.TEXTURE_BINDING_2D=32873]=`TEXTURE_BINDING_2D`,e[e.SAMPLE_BUFFERS=32936]=`SAMPLE_BUFFERS`,e[e.SAMPLES=32937]=`SAMPLES`,e[e.SAMPLE_COVERAGE_VALUE=32938]=`SAMPLE_COVERAGE_VALUE`,e[e.SAMPLE_COVERAGE_INVERT=32939]=`SAMPLE_COVERAGE_INVERT`,e[e.COMPRESSED_TEXTURE_FORMATS=34467]=`COMPRESSED_TEXTURE_FORMATS`,e[e.VENDOR=7936]=`VENDOR`,e[e.RENDERER=7937]=`RENDERER`,e[e.VERSION=7938]=`VERSION`,e[e.IMPLEMENTATION_COLOR_READ_TYPE=35738]=`IMPLEMENTATION_COLOR_READ_TYPE`,e[e.IMPLEMENTATION_COLOR_READ_FORMAT=35739]=`IMPLEMENTATION_COLOR_READ_FORMAT`,e[e.BROWSER_DEFAULT_WEBGL=37444]=`BROWSER_DEFAULT_WEBGL`,e[e.STATIC_DRAW=35044]=`STATIC_DRAW`,e[e.STREAM_DRAW=35040]=`STREAM_DRAW`,e[e.DYNAMIC_DRAW=35048]=`DYNAMIC_DRAW`,e[e.ARRAY_BUFFER=34962]=`ARRAY_BUFFER`,e[e.ELEMENT_ARRAY_BUFFER=34963]=`ELEMENT_ARRAY_BUFFER`,e[e.BUFFER_SIZE=34660]=`BUFFER_SIZE`,e[e.BUFFER_USAGE=34661]=`BUFFER_USAGE`,e[e.CURRENT_VERTEX_ATTRIB=34342]=`CURRENT_VERTEX_ATTRIB`,e[e.VERTEX_ATTRIB_ARRAY_ENABLED=34338]=`VERTEX_ATTRIB_ARRAY_ENABLED`,e[e.VERTEX_ATTRIB_ARRAY_SIZE=34339]=`VERTEX_ATTRIB_ARRAY_SIZE`,e[e.VERTEX_ATTRIB_ARRAY_STRIDE=34340]=`VERTEX_ATTRIB_ARRAY_STRIDE`,e[e.VERTEX_ATTRIB_ARRAY_TYPE=34341]=`VERTEX_ATTRIB_ARRAY_TYPE`,e[e.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]=`VERTEX_ATTRIB_ARRAY_NORMALIZED`,e[e.VERTEX_ATTRIB_ARRAY_POINTER=34373]=`VERTEX_ATTRIB_ARRAY_POINTER`,e[e.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]=`VERTEX_ATTRIB_ARRAY_BUFFER_BINDING`,e[e.CULL_FACE=2884]=`CULL_FACE`,e[e.FRONT=1028]=`FRONT`,e[e.BACK=1029]=`BACK`,e[e.FRONT_AND_BACK=1032]=`FRONT_AND_BACK`,e[e.BLEND=3042]=`BLEND`,e[e.DEPTH_TEST=2929]=`DEPTH_TEST`,e[e.DITHER=3024]=`DITHER`,e[e.POLYGON_OFFSET_FILL=32823]=`POLYGON_OFFSET_FILL`,e[e.SAMPLE_ALPHA_TO_COVERAGE=32926]=`SAMPLE_ALPHA_TO_COVERAGE`,e[e.SAMPLE_COVERAGE=32928]=`SAMPLE_COVERAGE`,e[e.SCISSOR_TEST=3089]=`SCISSOR_TEST`,e[e.STENCIL_TEST=2960]=`STENCIL_TEST`,e[e.NO_ERROR=0]=`NO_ERROR`,e[e.INVALID_ENUM=1280]=`INVALID_ENUM`,e[e.INVALID_VALUE=1281]=`INVALID_VALUE`,e[e.INVALID_OPERATION=1282]=`INVALID_OPERATION`,e[e.OUT_OF_MEMORY=1285]=`OUT_OF_MEMORY`,e[e.CONTEXT_LOST_WEBGL=37442]=`CONTEXT_LOST_WEBGL`,e[e.CW=2304]=`CW`,e[e.CCW=2305]=`CCW`,e[e.DONT_CARE=4352]=`DONT_CARE`,e[e.FASTEST=4353]=`FASTEST`,e[e.NICEST=4354]=`NICEST`,e[e.GENERATE_MIPMAP_HINT=33170]=`GENERATE_MIPMAP_HINT`,e[e.BYTE=5120]=`BYTE`,e[e.UNSIGNED_BYTE=5121]=`UNSIGNED_BYTE`,e[e.SHORT=5122]=`SHORT`,e[e.UNSIGNED_SHORT=5123]=`UNSIGNED_SHORT`,e[e.INT=5124]=`INT`,e[e.UNSIGNED_INT=5125]=`UNSIGNED_INT`,e[e.FLOAT=5126]=`FLOAT`,e[e.DOUBLE=5130]=`DOUBLE`,e[e.DEPTH_COMPONENT=6402]=`DEPTH_COMPONENT`,e[e.ALPHA=6406]=`ALPHA`,e[e.RGB=6407]=`RGB`,e[e.RGBA=6408]=`RGBA`,e[e.LUMINANCE=6409]=`LUMINANCE`,e[e.LUMINANCE_ALPHA=6410]=`LUMINANCE_ALPHA`,e[e.UNSIGNED_SHORT_4_4_4_4=32819]=`UNSIGNED_SHORT_4_4_4_4`,e[e.UNSIGNED_SHORT_5_5_5_1=32820]=`UNSIGNED_SHORT_5_5_5_1`,e[e.UNSIGNED_SHORT_5_6_5=33635]=`UNSIGNED_SHORT_5_6_5`,e[e.FRAGMENT_SHADER=35632]=`FRAGMENT_SHADER`,e[e.VERTEX_SHADER=35633]=`VERTEX_SHADER`,e[e.COMPILE_STATUS=35713]=`COMPILE_STATUS`,e[e.DELETE_STATUS=35712]=`DELETE_STATUS`,e[e.LINK_STATUS=35714]=`LINK_STATUS`,e[e.VALIDATE_STATUS=35715]=`VALIDATE_STATUS`,e[e.ATTACHED_SHADERS=35717]=`ATTACHED_SHADERS`,e[e.ACTIVE_ATTRIBUTES=35721]=`ACTIVE_ATTRIBUTES`,e[e.ACTIVE_UNIFORMS=35718]=`ACTIVE_UNIFORMS`,e[e.MAX_VERTEX_ATTRIBS=34921]=`MAX_VERTEX_ATTRIBS`,e[e.MAX_VERTEX_UNIFORM_VECTORS=36347]=`MAX_VERTEX_UNIFORM_VECTORS`,e[e.MAX_VARYING_VECTORS=36348]=`MAX_VARYING_VECTORS`,e[e.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]=`MAX_COMBINED_TEXTURE_IMAGE_UNITS`,e[e.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]=`MAX_VERTEX_TEXTURE_IMAGE_UNITS`,e[e.MAX_TEXTURE_IMAGE_UNITS=34930]=`MAX_TEXTURE_IMAGE_UNITS`,e[e.MAX_FRAGMENT_UNIFORM_VECTORS=36349]=`MAX_FRAGMENT_UNIFORM_VECTORS`,e[e.SHADER_TYPE=35663]=`SHADER_TYPE`,e[e.SHADING_LANGUAGE_VERSION=35724]=`SHADING_LANGUAGE_VERSION`,e[e.CURRENT_PROGRAM=35725]=`CURRENT_PROGRAM`,e[e.NEVER=512]=`NEVER`,e[e.LESS=513]=`LESS`,e[e.EQUAL=514]=`EQUAL`,e[e.LEQUAL=515]=`LEQUAL`,e[e.GREATER=516]=`GREATER`,e[e.NOTEQUAL=517]=`NOTEQUAL`,e[e.GEQUAL=518]=`GEQUAL`,e[e.ALWAYS=519]=`ALWAYS`,e[e.KEEP=7680]=`KEEP`,e[e.REPLACE=7681]=`REPLACE`,e[e.INCR=7682]=`INCR`,e[e.DECR=7683]=`DECR`,e[e.INVERT=5386]=`INVERT`,e[e.INCR_WRAP=34055]=`INCR_WRAP`,e[e.DECR_WRAP=34056]=`DECR_WRAP`,e[e.NEAREST=9728]=`NEAREST`,e[e.LINEAR=9729]=`LINEAR`,e[e.NEAREST_MIPMAP_NEAREST=9984]=`NEAREST_MIPMAP_NEAREST`,e[e.LINEAR_MIPMAP_NEAREST=9985]=`LINEAR_MIPMAP_NEAREST`,e[e.NEAREST_MIPMAP_LINEAR=9986]=`NEAREST_MIPMAP_LINEAR`,e[e.LINEAR_MIPMAP_LINEAR=9987]=`LINEAR_MIPMAP_LINEAR`,e[e.TEXTURE_MAG_FILTER=10240]=`TEXTURE_MAG_FILTER`,e[e.TEXTURE_MIN_FILTER=10241]=`TEXTURE_MIN_FILTER`,e[e.TEXTURE_WRAP_S=10242]=`TEXTURE_WRAP_S`,e[e.TEXTURE_WRAP_T=10243]=`TEXTURE_WRAP_T`,e[e.TEXTURE_2D=3553]=`TEXTURE_2D`,e[e.TEXTURE=5890]=`TEXTURE`,e[e.TEXTURE_CUBE_MAP=34067]=`TEXTURE_CUBE_MAP`,e[e.TEXTURE_BINDING_CUBE_MAP=34068]=`TEXTURE_BINDING_CUBE_MAP`,e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]=`TEXTURE_CUBE_MAP_POSITIVE_X`,e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]=`TEXTURE_CUBE_MAP_NEGATIVE_X`,e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]=`TEXTURE_CUBE_MAP_POSITIVE_Y`,e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]=`TEXTURE_CUBE_MAP_NEGATIVE_Y`,e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]=`TEXTURE_CUBE_MAP_POSITIVE_Z`,e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]=`TEXTURE_CUBE_MAP_NEGATIVE_Z`,e[e.MAX_CUBE_MAP_TEXTURE_SIZE=34076]=`MAX_CUBE_MAP_TEXTURE_SIZE`,e[e.TEXTURE0=33984]=`TEXTURE0`,e[e.ACTIVE_TEXTURE=34016]=`ACTIVE_TEXTURE`,e[e.REPEAT=10497]=`REPEAT`,e[e.CLAMP_TO_EDGE=33071]=`CLAMP_TO_EDGE`,e[e.MIRRORED_REPEAT=33648]=`MIRRORED_REPEAT`,e[e.TEXTURE_WIDTH=4096]=`TEXTURE_WIDTH`,e[e.TEXTURE_HEIGHT=4097]=`TEXTURE_HEIGHT`,e[e.FLOAT_VEC2=35664]=`FLOAT_VEC2`,e[e.FLOAT_VEC3=35665]=`FLOAT_VEC3`,e[e.FLOAT_VEC4=35666]=`FLOAT_VEC4`,e[e.INT_VEC2=35667]=`INT_VEC2`,e[e.INT_VEC3=35668]=`INT_VEC3`,e[e.INT_VEC4=35669]=`INT_VEC4`,e[e.BOOL=35670]=`BOOL`,e[e.BOOL_VEC2=35671]=`BOOL_VEC2`,e[e.BOOL_VEC3=35672]=`BOOL_VEC3`,e[e.BOOL_VEC4=35673]=`BOOL_VEC4`,e[e.FLOAT_MAT2=35674]=`FLOAT_MAT2`,e[e.FLOAT_MAT3=35675]=`FLOAT_MAT3`,e[e.FLOAT_MAT4=35676]=`FLOAT_MAT4`,e[e.SAMPLER_2D=35678]=`SAMPLER_2D`,e[e.SAMPLER_CUBE=35680]=`SAMPLER_CUBE`,e[e.LOW_FLOAT=36336]=`LOW_FLOAT`,e[e.MEDIUM_FLOAT=36337]=`MEDIUM_FLOAT`,e[e.HIGH_FLOAT=36338]=`HIGH_FLOAT`,e[e.LOW_INT=36339]=`LOW_INT`,e[e.MEDIUM_INT=36340]=`MEDIUM_INT`,e[e.HIGH_INT=36341]=`HIGH_INT`,e[e.FRAMEBUFFER=36160]=`FRAMEBUFFER`,e[e.RENDERBUFFER=36161]=`RENDERBUFFER`,e[e.RGBA4=32854]=`RGBA4`,e[e.RGB5_A1=32855]=`RGB5_A1`,e[e.RGB565=36194]=`RGB565`,e[e.DEPTH_COMPONENT16=33189]=`DEPTH_COMPONENT16`,e[e.STENCIL_INDEX=6401]=`STENCIL_INDEX`,e[e.STENCIL_INDEX8=36168]=`STENCIL_INDEX8`,e[e.DEPTH_STENCIL=34041]=`DEPTH_STENCIL`,e[e.RENDERBUFFER_WIDTH=36162]=`RENDERBUFFER_WIDTH`,e[e.RENDERBUFFER_HEIGHT=36163]=`RENDERBUFFER_HEIGHT`,e[e.RENDERBUFFER_INTERNAL_FORMAT=36164]=`RENDERBUFFER_INTERNAL_FORMAT`,e[e.RENDERBUFFER_RED_SIZE=36176]=`RENDERBUFFER_RED_SIZE`,e[e.RENDERBUFFER_GREEN_SIZE=36177]=`RENDERBUFFER_GREEN_SIZE`,e[e.RENDERBUFFER_BLUE_SIZE=36178]=`RENDERBUFFER_BLUE_SIZE`,e[e.RENDERBUFFER_ALPHA_SIZE=36179]=`RENDERBUFFER_ALPHA_SIZE`,e[e.RENDERBUFFER_DEPTH_SIZE=36180]=`RENDERBUFFER_DEPTH_SIZE`,e[e.RENDERBUFFER_STENCIL_SIZE=36181]=`RENDERBUFFER_STENCIL_SIZE`,e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]=`FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE`,e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]=`FRAMEBUFFER_ATTACHMENT_OBJECT_NAME`,e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]=`FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL`,e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]=`FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE`,e[e.COLOR_ATTACHMENT0=36064]=`COLOR_ATTACHMENT0`,e[e.DEPTH_ATTACHMENT=36096]=`DEPTH_ATTACHMENT`,e[e.STENCIL_ATTACHMENT=36128]=`STENCIL_ATTACHMENT`,e[e.DEPTH_STENCIL_ATTACHMENT=33306]=`DEPTH_STENCIL_ATTACHMENT`,e[e.NONE=0]=`NONE`,e[e.FRAMEBUFFER_COMPLETE=36053]=`FRAMEBUFFER_COMPLETE`,e[e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]=`FRAMEBUFFER_INCOMPLETE_ATTACHMENT`,e[e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]=`FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT`,e[e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]=`FRAMEBUFFER_INCOMPLETE_DIMENSIONS`,e[e.FRAMEBUFFER_UNSUPPORTED=36061]=`FRAMEBUFFER_UNSUPPORTED`,e[e.FRAMEBUFFER_BINDING=36006]=`FRAMEBUFFER_BINDING`,e[e.RENDERBUFFER_BINDING=36007]=`RENDERBUFFER_BINDING`,e[e.READ_FRAMEBUFFER=36008]=`READ_FRAMEBUFFER`,e[e.DRAW_FRAMEBUFFER=36009]=`DRAW_FRAMEBUFFER`,e[e.MAX_RENDERBUFFER_SIZE=34024]=`MAX_RENDERBUFFER_SIZE`,e[e.INVALID_FRAMEBUFFER_OPERATION=1286]=`INVALID_FRAMEBUFFER_OPERATION`,e[e.UNPACK_FLIP_Y_WEBGL=37440]=`UNPACK_FLIP_Y_WEBGL`,e[e.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]=`UNPACK_PREMULTIPLY_ALPHA_WEBGL`,e[e.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]=`UNPACK_COLORSPACE_CONVERSION_WEBGL`,e[e.READ_BUFFER=3074]=`READ_BUFFER`,e[e.UNPACK_ROW_LENGTH=3314]=`UNPACK_ROW_LENGTH`,e[e.UNPACK_SKIP_ROWS=3315]=`UNPACK_SKIP_ROWS`,e[e.UNPACK_SKIP_PIXELS=3316]=`UNPACK_SKIP_PIXELS`,e[e.PACK_ROW_LENGTH=3330]=`PACK_ROW_LENGTH`,e[e.PACK_SKIP_ROWS=3331]=`PACK_SKIP_ROWS`,e[e.PACK_SKIP_PIXELS=3332]=`PACK_SKIP_PIXELS`,e[e.TEXTURE_BINDING_3D=32874]=`TEXTURE_BINDING_3D`,e[e.UNPACK_SKIP_IMAGES=32877]=`UNPACK_SKIP_IMAGES`,e[e.UNPACK_IMAGE_HEIGHT=32878]=`UNPACK_IMAGE_HEIGHT`,e[e.MAX_3D_TEXTURE_SIZE=32883]=`MAX_3D_TEXTURE_SIZE`,e[e.MAX_ELEMENTS_VERTICES=33e3]=`MAX_ELEMENTS_VERTICES`,e[e.MAX_ELEMENTS_INDICES=33001]=`MAX_ELEMENTS_INDICES`,e[e.MAX_TEXTURE_LOD_BIAS=34045]=`MAX_TEXTURE_LOD_BIAS`,e[e.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]=`MAX_FRAGMENT_UNIFORM_COMPONENTS`,e[e.MAX_VERTEX_UNIFORM_COMPONENTS=35658]=`MAX_VERTEX_UNIFORM_COMPONENTS`,e[e.MAX_ARRAY_TEXTURE_LAYERS=35071]=`MAX_ARRAY_TEXTURE_LAYERS`,e[e.MIN_PROGRAM_TEXEL_OFFSET=35076]=`MIN_PROGRAM_TEXEL_OFFSET`,e[e.MAX_PROGRAM_TEXEL_OFFSET=35077]=`MAX_PROGRAM_TEXEL_OFFSET`,e[e.MAX_VARYING_COMPONENTS=35659]=`MAX_VARYING_COMPONENTS`,e[e.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]=`FRAGMENT_SHADER_DERIVATIVE_HINT`,e[e.RASTERIZER_DISCARD=35977]=`RASTERIZER_DISCARD`,e[e.VERTEX_ARRAY_BINDING=34229]=`VERTEX_ARRAY_BINDING`,e[e.MAX_VERTEX_OUTPUT_COMPONENTS=37154]=`MAX_VERTEX_OUTPUT_COMPONENTS`,e[e.MAX_FRAGMENT_INPUT_COMPONENTS=37157]=`MAX_FRAGMENT_INPUT_COMPONENTS`,e[e.MAX_SERVER_WAIT_TIMEOUT=37137]=`MAX_SERVER_WAIT_TIMEOUT`,e[e.MAX_ELEMENT_INDEX=36203]=`MAX_ELEMENT_INDEX`,e[e.RED=6403]=`RED`,e[e.RGB8=32849]=`RGB8`,e[e.RGBA8=32856]=`RGBA8`,e[e.RGB10_A2=32857]=`RGB10_A2`,e[e.TEXTURE_3D=32879]=`TEXTURE_3D`,e[e.TEXTURE_WRAP_R=32882]=`TEXTURE_WRAP_R`,e[e.TEXTURE_MIN_LOD=33082]=`TEXTURE_MIN_LOD`,e[e.TEXTURE_MAX_LOD=33083]=`TEXTURE_MAX_LOD`,e[e.TEXTURE_BASE_LEVEL=33084]=`TEXTURE_BASE_LEVEL`,e[e.TEXTURE_MAX_LEVEL=33085]=`TEXTURE_MAX_LEVEL`,e[e.TEXTURE_COMPARE_MODE=34892]=`TEXTURE_COMPARE_MODE`,e[e.TEXTURE_COMPARE_FUNC=34893]=`TEXTURE_COMPARE_FUNC`,e[e.SRGB=35904]=`SRGB`,e[e.SRGB8=35905]=`SRGB8`,e[e.SRGB8_ALPHA8=35907]=`SRGB8_ALPHA8`,e[e.COMPARE_REF_TO_TEXTURE=34894]=`COMPARE_REF_TO_TEXTURE`,e[e.RGBA32F=34836]=`RGBA32F`,e[e.RGB32F=34837]=`RGB32F`,e[e.RGBA16F=34842]=`RGBA16F`,e[e.RGB16F=34843]=`RGB16F`,e[e.TEXTURE_2D_ARRAY=35866]=`TEXTURE_2D_ARRAY`,e[e.TEXTURE_BINDING_2D_ARRAY=35869]=`TEXTURE_BINDING_2D_ARRAY`,e[e.R11F_G11F_B10F=35898]=`R11F_G11F_B10F`,e[e.RGB9_E5=35901]=`RGB9_E5`,e[e.RGBA32UI=36208]=`RGBA32UI`,e[e.RGB32UI=36209]=`RGB32UI`,e[e.RGBA16UI=36214]=`RGBA16UI`,e[e.RGB16UI=36215]=`RGB16UI`,e[e.RGBA8UI=36220]=`RGBA8UI`,e[e.RGB8UI=36221]=`RGB8UI`,e[e.RGBA32I=36226]=`RGBA32I`,e[e.RGB32I=36227]=`RGB32I`,e[e.RGBA16I=36232]=`RGBA16I`,e[e.RGB16I=36233]=`RGB16I`,e[e.RGBA8I=36238]=`RGBA8I`,e[e.RGB8I=36239]=`RGB8I`,e[e.RED_INTEGER=36244]=`RED_INTEGER`,e[e.RGB_INTEGER=36248]=`RGB_INTEGER`,e[e.RGBA_INTEGER=36249]=`RGBA_INTEGER`,e[e.R8=33321]=`R8`,e[e.RG8=33323]=`RG8`,e[e.R16F=33325]=`R16F`,e[e.R32F=33326]=`R32F`,e[e.RG16F=33327]=`RG16F`,e[e.RG32F=33328]=`RG32F`,e[e.R8I=33329]=`R8I`,e[e.R8UI=33330]=`R8UI`,e[e.R16I=33331]=`R16I`,e[e.R16UI=33332]=`R16UI`,e[e.R32I=33333]=`R32I`,e[e.R32UI=33334]=`R32UI`,e[e.RG8I=33335]=`RG8I`,e[e.RG8UI=33336]=`RG8UI`,e[e.RG16I=33337]=`RG16I`,e[e.RG16UI=33338]=`RG16UI`,e[e.RG32I=33339]=`RG32I`,e[e.RG32UI=33340]=`RG32UI`,e[e.R8_SNORM=36756]=`R8_SNORM`,e[e.RG8_SNORM=36757]=`RG8_SNORM`,e[e.RGB8_SNORM=36758]=`RGB8_SNORM`,e[e.RGBA8_SNORM=36759]=`RGBA8_SNORM`,e[e.RGB10_A2UI=36975]=`RGB10_A2UI`,e[e.TEXTURE_IMMUTABLE_FORMAT=37167]=`TEXTURE_IMMUTABLE_FORMAT`,e[e.TEXTURE_IMMUTABLE_LEVELS=33503]=`TEXTURE_IMMUTABLE_LEVELS`,e[e.UNSIGNED_INT_2_10_10_10_REV=33640]=`UNSIGNED_INT_2_10_10_10_REV`,e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]=`UNSIGNED_INT_10F_11F_11F_REV`,e[e.UNSIGNED_INT_5_9_9_9_REV=35902]=`UNSIGNED_INT_5_9_9_9_REV`,e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]=`FLOAT_32_UNSIGNED_INT_24_8_REV`,e[e.UNSIGNED_INT_24_8=34042]=`UNSIGNED_INT_24_8`,e[e.HALF_FLOAT=5131]=`HALF_FLOAT`,e[e.RG=33319]=`RG`,e[e.RG_INTEGER=33320]=`RG_INTEGER`,e[e.INT_2_10_10_10_REV=36255]=`INT_2_10_10_10_REV`,e[e.CURRENT_QUERY=34917]=`CURRENT_QUERY`,e[e.QUERY_RESULT=34918]=`QUERY_RESULT`,e[e.QUERY_RESULT_AVAILABLE=34919]=`QUERY_RESULT_AVAILABLE`,e[e.ANY_SAMPLES_PASSED=35887]=`ANY_SAMPLES_PASSED`,e[e.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]=`ANY_SAMPLES_PASSED_CONSERVATIVE`,e[e.MAX_DRAW_BUFFERS=34852]=`MAX_DRAW_BUFFERS`,e[e.DRAW_BUFFER0=34853]=`DRAW_BUFFER0`,e[e.DRAW_BUFFER1=34854]=`DRAW_BUFFER1`,e[e.DRAW_BUFFER2=34855]=`DRAW_BUFFER2`,e[e.DRAW_BUFFER3=34856]=`DRAW_BUFFER3`,e[e.DRAW_BUFFER4=34857]=`DRAW_BUFFER4`,e[e.DRAW_BUFFER5=34858]=`DRAW_BUFFER5`,e[e.DRAW_BUFFER6=34859]=`DRAW_BUFFER6`,e[e.DRAW_BUFFER7=34860]=`DRAW_BUFFER7`,e[e.DRAW_BUFFER8=34861]=`DRAW_BUFFER8`,e[e.DRAW_BUFFER9=34862]=`DRAW_BUFFER9`,e[e.DRAW_BUFFER10=34863]=`DRAW_BUFFER10`,e[e.DRAW_BUFFER11=34864]=`DRAW_BUFFER11`,e[e.DRAW_BUFFER12=34865]=`DRAW_BUFFER12`,e[e.DRAW_BUFFER13=34866]=`DRAW_BUFFER13`,e[e.DRAW_BUFFER14=34867]=`DRAW_BUFFER14`,e[e.DRAW_BUFFER15=34868]=`DRAW_BUFFER15`,e[e.MAX_COLOR_ATTACHMENTS=36063]=`MAX_COLOR_ATTACHMENTS`,e[e.COLOR_ATTACHMENT1=36065]=`COLOR_ATTACHMENT1`,e[e.COLOR_ATTACHMENT2=36066]=`COLOR_ATTACHMENT2`,e[e.COLOR_ATTACHMENT3=36067]=`COLOR_ATTACHMENT3`,e[e.COLOR_ATTACHMENT4=36068]=`COLOR_ATTACHMENT4`,e[e.COLOR_ATTACHMENT5=36069]=`COLOR_ATTACHMENT5`,e[e.COLOR_ATTACHMENT6=36070]=`COLOR_ATTACHMENT6`,e[e.COLOR_ATTACHMENT7=36071]=`COLOR_ATTACHMENT7`,e[e.COLOR_ATTACHMENT8=36072]=`COLOR_ATTACHMENT8`,e[e.COLOR_ATTACHMENT9=36073]=`COLOR_ATTACHMENT9`,e[e.COLOR_ATTACHMENT10=36074]=`COLOR_ATTACHMENT10`,e[e.COLOR_ATTACHMENT11=36075]=`COLOR_ATTACHMENT11`,e[e.COLOR_ATTACHMENT12=36076]=`COLOR_ATTACHMENT12`,e[e.COLOR_ATTACHMENT13=36077]=`COLOR_ATTACHMENT13`,e[e.COLOR_ATTACHMENT14=36078]=`COLOR_ATTACHMENT14`,e[e.COLOR_ATTACHMENT15=36079]=`COLOR_ATTACHMENT15`,e[e.SAMPLER_3D=35679]=`SAMPLER_3D`,e[e.SAMPLER_2D_SHADOW=35682]=`SAMPLER_2D_SHADOW`,e[e.SAMPLER_2D_ARRAY=36289]=`SAMPLER_2D_ARRAY`,e[e.SAMPLER_2D_ARRAY_SHADOW=36292]=`SAMPLER_2D_ARRAY_SHADOW`,e[e.SAMPLER_CUBE_SHADOW=36293]=`SAMPLER_CUBE_SHADOW`,e[e.INT_SAMPLER_2D=36298]=`INT_SAMPLER_2D`,e[e.INT_SAMPLER_3D=36299]=`INT_SAMPLER_3D`,e[e.INT_SAMPLER_CUBE=36300]=`INT_SAMPLER_CUBE`,e[e.INT_SAMPLER_2D_ARRAY=36303]=`INT_SAMPLER_2D_ARRAY`,e[e.UNSIGNED_INT_SAMPLER_2D=36306]=`UNSIGNED_INT_SAMPLER_2D`,e[e.UNSIGNED_INT_SAMPLER_3D=36307]=`UNSIGNED_INT_SAMPLER_3D`,e[e.UNSIGNED_INT_SAMPLER_CUBE=36308]=`UNSIGNED_INT_SAMPLER_CUBE`,e[e.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]=`UNSIGNED_INT_SAMPLER_2D_ARRAY`,e[e.MAX_SAMPLES=36183]=`MAX_SAMPLES`,e[e.SAMPLER_BINDING=35097]=`SAMPLER_BINDING`,e[e.PIXEL_PACK_BUFFER=35051]=`PIXEL_PACK_BUFFER`,e[e.PIXEL_UNPACK_BUFFER=35052]=`PIXEL_UNPACK_BUFFER`,e[e.PIXEL_PACK_BUFFER_BINDING=35053]=`PIXEL_PACK_BUFFER_BINDING`,e[e.PIXEL_UNPACK_BUFFER_BINDING=35055]=`PIXEL_UNPACK_BUFFER_BINDING`,e[e.COPY_READ_BUFFER=36662]=`COPY_READ_BUFFER`,e[e.COPY_WRITE_BUFFER=36663]=`COPY_WRITE_BUFFER`,e[e.COPY_READ_BUFFER_BINDING=36662]=`COPY_READ_BUFFER_BINDING`,e[e.COPY_WRITE_BUFFER_BINDING=36663]=`COPY_WRITE_BUFFER_BINDING`,e[e.FLOAT_MAT2x3=35685]=`FLOAT_MAT2x3`,e[e.FLOAT_MAT2x4=35686]=`FLOAT_MAT2x4`,e[e.FLOAT_MAT3x2=35687]=`FLOAT_MAT3x2`,e[e.FLOAT_MAT3x4=35688]=`FLOAT_MAT3x4`,e[e.FLOAT_MAT4x2=35689]=`FLOAT_MAT4x2`,e[e.FLOAT_MAT4x3=35690]=`FLOAT_MAT4x3`,e[e.UNSIGNED_INT_VEC2=36294]=`UNSIGNED_INT_VEC2`,e[e.UNSIGNED_INT_VEC3=36295]=`UNSIGNED_INT_VEC3`,e[e.UNSIGNED_INT_VEC4=36296]=`UNSIGNED_INT_VEC4`,e[e.UNSIGNED_NORMALIZED=35863]=`UNSIGNED_NORMALIZED`,e[e.SIGNED_NORMALIZED=36764]=`SIGNED_NORMALIZED`,e[e.VERTEX_ATTRIB_ARRAY_INTEGER=35069]=`VERTEX_ATTRIB_ARRAY_INTEGER`,e[e.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]=`VERTEX_ATTRIB_ARRAY_DIVISOR`,e[e.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]=`TRANSFORM_FEEDBACK_BUFFER_MODE`,e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]=`MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS`,e[e.TRANSFORM_FEEDBACK_VARYINGS=35971]=`TRANSFORM_FEEDBACK_VARYINGS`,e[e.TRANSFORM_FEEDBACK_BUFFER_START=35972]=`TRANSFORM_FEEDBACK_BUFFER_START`,e[e.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]=`TRANSFORM_FEEDBACK_BUFFER_SIZE`,e[e.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]=`TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN`,e[e.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]=`MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS`,e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]=`MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS`,e[e.INTERLEAVED_ATTRIBS=35980]=`INTERLEAVED_ATTRIBS`,e[e.SEPARATE_ATTRIBS=35981]=`SEPARATE_ATTRIBS`,e[e.TRANSFORM_FEEDBACK_BUFFER=35982]=`TRANSFORM_FEEDBACK_BUFFER`,e[e.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]=`TRANSFORM_FEEDBACK_BUFFER_BINDING`,e[e.TRANSFORM_FEEDBACK=36386]=`TRANSFORM_FEEDBACK`,e[e.TRANSFORM_FEEDBACK_PAUSED=36387]=`TRANSFORM_FEEDBACK_PAUSED`,e[e.TRANSFORM_FEEDBACK_ACTIVE=36388]=`TRANSFORM_FEEDBACK_ACTIVE`,e[e.TRANSFORM_FEEDBACK_BINDING=36389]=`TRANSFORM_FEEDBACK_BINDING`,e[e.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]=`FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING`,e[e.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]=`FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE`,e[e.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]=`FRAMEBUFFER_ATTACHMENT_RED_SIZE`,e[e.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]=`FRAMEBUFFER_ATTACHMENT_GREEN_SIZE`,e[e.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]=`FRAMEBUFFER_ATTACHMENT_BLUE_SIZE`,e[e.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]=`FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE`,e[e.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]=`FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE`,e[e.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]=`FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE`,e[e.FRAMEBUFFER_DEFAULT=33304]=`FRAMEBUFFER_DEFAULT`,e[e.DEPTH24_STENCIL8=35056]=`DEPTH24_STENCIL8`,e[e.DRAW_FRAMEBUFFER_BINDING=36006]=`DRAW_FRAMEBUFFER_BINDING`,e[e.READ_FRAMEBUFFER_BINDING=36010]=`READ_FRAMEBUFFER_BINDING`,e[e.RENDERBUFFER_SAMPLES=36011]=`RENDERBUFFER_SAMPLES`,e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]=`FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER`,e[e.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]=`FRAMEBUFFER_INCOMPLETE_MULTISAMPLE`,e[e.UNIFORM_BUFFER=35345]=`UNIFORM_BUFFER`,e[e.UNIFORM_BUFFER_BINDING=35368]=`UNIFORM_BUFFER_BINDING`,e[e.UNIFORM_BUFFER_START=35369]=`UNIFORM_BUFFER_START`,e[e.UNIFORM_BUFFER_SIZE=35370]=`UNIFORM_BUFFER_SIZE`,e[e.MAX_VERTEX_UNIFORM_BLOCKS=35371]=`MAX_VERTEX_UNIFORM_BLOCKS`,e[e.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]=`MAX_FRAGMENT_UNIFORM_BLOCKS`,e[e.MAX_COMBINED_UNIFORM_BLOCKS=35374]=`MAX_COMBINED_UNIFORM_BLOCKS`,e[e.MAX_UNIFORM_BUFFER_BINDINGS=35375]=`MAX_UNIFORM_BUFFER_BINDINGS`,e[e.MAX_UNIFORM_BLOCK_SIZE=35376]=`MAX_UNIFORM_BLOCK_SIZE`,e[e.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]=`MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS`,e[e.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]=`MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS`,e[e.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]=`UNIFORM_BUFFER_OFFSET_ALIGNMENT`,e[e.ACTIVE_UNIFORM_BLOCKS=35382]=`ACTIVE_UNIFORM_BLOCKS`,e[e.UNIFORM_TYPE=35383]=`UNIFORM_TYPE`,e[e.UNIFORM_SIZE=35384]=`UNIFORM_SIZE`,e[e.UNIFORM_BLOCK_INDEX=35386]=`UNIFORM_BLOCK_INDEX`,e[e.UNIFORM_OFFSET=35387]=`UNIFORM_OFFSET`,e[e.UNIFORM_ARRAY_STRIDE=35388]=`UNIFORM_ARRAY_STRIDE`,e[e.UNIFORM_MATRIX_STRIDE=35389]=`UNIFORM_MATRIX_STRIDE`,e[e.UNIFORM_IS_ROW_MAJOR=35390]=`UNIFORM_IS_ROW_MAJOR`,e[e.UNIFORM_BLOCK_BINDING=35391]=`UNIFORM_BLOCK_BINDING`,e[e.UNIFORM_BLOCK_DATA_SIZE=35392]=`UNIFORM_BLOCK_DATA_SIZE`,e[e.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]=`UNIFORM_BLOCK_ACTIVE_UNIFORMS`,e[e.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]=`UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES`,e[e.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]=`UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER`,e[e.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]=`UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER`,e[e.OBJECT_TYPE=37138]=`OBJECT_TYPE`,e[e.SYNC_CONDITION=37139]=`SYNC_CONDITION`,e[e.SYNC_STATUS=37140]=`SYNC_STATUS`,e[e.SYNC_FLAGS=37141]=`SYNC_FLAGS`,e[e.SYNC_FENCE=37142]=`SYNC_FENCE`,e[e.SYNC_GPU_COMMANDS_COMPLETE=37143]=`SYNC_GPU_COMMANDS_COMPLETE`,e[e.UNSIGNALED=37144]=`UNSIGNALED`,e[e.SIGNALED=37145]=`SIGNALED`,e[e.ALREADY_SIGNALED=37146]=`ALREADY_SIGNALED`,e[e.TIMEOUT_EXPIRED=37147]=`TIMEOUT_EXPIRED`,e[e.CONDITION_SATISFIED=37148]=`CONDITION_SATISFIED`,e[e.WAIT_FAILED=37149]=`WAIT_FAILED`,e[e.SYNC_FLUSH_COMMANDS_BIT=1]=`SYNC_FLUSH_COMMANDS_BIT`,e[e.COLOR=6144]=`COLOR`,e[e.DEPTH=6145]=`DEPTH`,e[e.STENCIL=6146]=`STENCIL`,e[e.MIN=32775]=`MIN`,e[e.MAX=32776]=`MAX`,e[e.DEPTH_COMPONENT24=33190]=`DEPTH_COMPONENT24`,e[e.STREAM_READ=35041]=`STREAM_READ`,e[e.STREAM_COPY=35042]=`STREAM_COPY`,e[e.STATIC_READ=35045]=`STATIC_READ`,e[e.STATIC_COPY=35046]=`STATIC_COPY`,e[e.DYNAMIC_READ=35049]=`DYNAMIC_READ`,e[e.DYNAMIC_COPY=35050]=`DYNAMIC_COPY`,e[e.DEPTH_COMPONENT32F=36012]=`DEPTH_COMPONENT32F`,e[e.DEPTH32F_STENCIL8=36013]=`DEPTH32F_STENCIL8`,e[e.INVALID_INDEX=4294967295]=`INVALID_INDEX`,e[e.TIMEOUT_IGNORED=-1]=`TIMEOUT_IGNORED`,e[e.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]=`MAX_CLIENT_WAIT_TIMEOUT_WEBGL`,e[e.UNMASKED_VENDOR_WEBGL=37445]=`UNMASKED_VENDOR_WEBGL`,e[e.UNMASKED_RENDERER_WEBGL=37446]=`UNMASKED_RENDERER_WEBGL`,e[e.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]=`MAX_TEXTURE_MAX_ANISOTROPY_EXT`,e[e.TEXTURE_MAX_ANISOTROPY_EXT=34046]=`TEXTURE_MAX_ANISOTROPY_EXT`,e[e.R16_EXT=33322]=`R16_EXT`,e[e.RG16_EXT=33324]=`RG16_EXT`,e[e.RGB16_EXT=32852]=`RGB16_EXT`,e[e.RGBA16_EXT=32859]=`RGBA16_EXT`,e[e.R16_SNORM_EXT=36760]=`R16_SNORM_EXT`,e[e.RG16_SNORM_EXT=36761]=`RG16_SNORM_EXT`,e[e.RGB16_SNORM_EXT=36762]=`RGB16_SNORM_EXT`,e[e.RGBA16_SNORM_EXT=36763]=`RGBA16_SNORM_EXT`,e[e.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]=`COMPRESSED_RGB_S3TC_DXT1_EXT`,e[e.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]=`COMPRESSED_RGBA_S3TC_DXT1_EXT`,e[e.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]=`COMPRESSED_RGBA_S3TC_DXT3_EXT`,e[e.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]=`COMPRESSED_RGBA_S3TC_DXT5_EXT`,e[e.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]=`COMPRESSED_SRGB_S3TC_DXT1_EXT`,e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]=`COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT`,e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]=`COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT`,e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]=`COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT`,e[e.COMPRESSED_RED_RGTC1_EXT=36283]=`COMPRESSED_RED_RGTC1_EXT`,e[e.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]=`COMPRESSED_SIGNED_RED_RGTC1_EXT`,e[e.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]=`COMPRESSED_RED_GREEN_RGTC2_EXT`,e[e.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]=`COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT`,e[e.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]=`COMPRESSED_RGBA_BPTC_UNORM_EXT`,e[e.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]=`COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT`,e[e.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]=`COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT`,e[e.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]=`COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT`,e[e.COMPRESSED_R11_EAC=37488]=`COMPRESSED_R11_EAC`,e[e.COMPRESSED_SIGNED_R11_EAC=37489]=`COMPRESSED_SIGNED_R11_EAC`,e[e.COMPRESSED_RG11_EAC=37490]=`COMPRESSED_RG11_EAC`,e[e.COMPRESSED_SIGNED_RG11_EAC=37491]=`COMPRESSED_SIGNED_RG11_EAC`,e[e.COMPRESSED_RGB8_ETC2=37492]=`COMPRESSED_RGB8_ETC2`,e[e.COMPRESSED_RGBA8_ETC2_EAC=37493]=`COMPRESSED_RGBA8_ETC2_EAC`,e[e.COMPRESSED_SRGB8_ETC2=37494]=`COMPRESSED_SRGB8_ETC2`,e[e.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]=`COMPRESSED_SRGB8_ALPHA8_ETC2_EAC`,e[e.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]=`COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2`,e[e.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]=`COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2`,e[e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]=`COMPRESSED_RGB_PVRTC_4BPPV1_IMG`,e[e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]=`COMPRESSED_RGBA_PVRTC_4BPPV1_IMG`,e[e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]=`COMPRESSED_RGB_PVRTC_2BPPV1_IMG`,e[e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]=`COMPRESSED_RGBA_PVRTC_2BPPV1_IMG`,e[e.COMPRESSED_RGB_ETC1_WEBGL=36196]=`COMPRESSED_RGB_ETC1_WEBGL`,e[e.COMPRESSED_RGB_ATC_WEBGL=35986]=`COMPRESSED_RGB_ATC_WEBGL`,e[e.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]=`COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL`,e[e.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]=`COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL`,e[e.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]=`COMPRESSED_RGBA_ASTC_4x4_KHR`,e[e.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]=`COMPRESSED_RGBA_ASTC_5x4_KHR`,e[e.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]=`COMPRESSED_RGBA_ASTC_5x5_KHR`,e[e.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]=`COMPRESSED_RGBA_ASTC_6x5_KHR`,e[e.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]=`COMPRESSED_RGBA_ASTC_6x6_KHR`,e[e.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]=`COMPRESSED_RGBA_ASTC_8x5_KHR`,e[e.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]=`COMPRESSED_RGBA_ASTC_8x6_KHR`,e[e.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]=`COMPRESSED_RGBA_ASTC_8x8_KHR`,e[e.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]=`COMPRESSED_RGBA_ASTC_10x5_KHR`,e[e.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]=`COMPRESSED_RGBA_ASTC_10x6_KHR`,e[e.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]=`COMPRESSED_RGBA_ASTC_10x8_KHR`,e[e.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]=`COMPRESSED_RGBA_ASTC_10x10_KHR`,e[e.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]=`COMPRESSED_RGBA_ASTC_12x10_KHR`,e[e.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]=`COMPRESSED_RGBA_ASTC_12x12_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]=`COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]=`COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]=`COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]=`COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]=`COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]=`COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]=`COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]=`COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]=`COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]=`COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]=`COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]=`COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]=`COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]=`COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR`,e[e.QUERY_COUNTER_BITS_EXT=34916]=`QUERY_COUNTER_BITS_EXT`,e[e.CURRENT_QUERY_EXT=34917]=`CURRENT_QUERY_EXT`,e[e.QUERY_RESULT_EXT=34918]=`QUERY_RESULT_EXT`,e[e.QUERY_RESULT_AVAILABLE_EXT=34919]=`QUERY_RESULT_AVAILABLE_EXT`,e[e.TIME_ELAPSED_EXT=35007]=`TIME_ELAPSED_EXT`,e[e.TIMESTAMP_EXT=36392]=`TIMESTAMP_EXT`,e[e.GPU_DISJOINT_EXT=36795]=`GPU_DISJOINT_EXT`,e[e.COMPLETION_STATUS_KHR=37297]=`COMPLETION_STATUS_KHR`,e[e.DEPTH_CLAMP_EXT=34383]=`DEPTH_CLAMP_EXT`,e[e.FIRST_VERTEX_CONVENTION_WEBGL=36429]=`FIRST_VERTEX_CONVENTION_WEBGL`,e[e.LAST_VERTEX_CONVENTION_WEBGL=36430]=`LAST_VERTEX_CONVENTION_WEBGL`,e[e.PROVOKING_VERTEX_WEBL=36431]=`PROVOKING_VERTEX_WEBL`,e[e.POLYGON_MODE_WEBGL=2880]=`POLYGON_MODE_WEBGL`,e[e.POLYGON_OFFSET_LINE_WEBGL=10754]=`POLYGON_OFFSET_LINE_WEBGL`,e[e.LINE_WEBGL=6913]=`LINE_WEBGL`,e[e.FILL_WEBGL=6914]=`FILL_WEBGL`,e[e.MAX_CLIP_DISTANCES_WEBGL=3378]=`MAX_CLIP_DISTANCES_WEBGL`,e[e.MAX_CULL_DISTANCES_WEBGL=33529]=`MAX_CULL_DISTANCES_WEBGL`,e[e.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]=`MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL`,e[e.CLIP_DISTANCE0_WEBGL=12288]=`CLIP_DISTANCE0_WEBGL`,e[e.CLIP_DISTANCE1_WEBGL=12289]=`CLIP_DISTANCE1_WEBGL`,e[e.CLIP_DISTANCE2_WEBGL=12290]=`CLIP_DISTANCE2_WEBGL`,e[e.CLIP_DISTANCE3_WEBGL=12291]=`CLIP_DISTANCE3_WEBGL`,e[e.CLIP_DISTANCE4_WEBGL=12292]=`CLIP_DISTANCE4_WEBGL`,e[e.CLIP_DISTANCE5_WEBGL=12293]=`CLIP_DISTANCE5_WEBGL`,e[e.CLIP_DISTANCE6_WEBGL=12294]=`CLIP_DISTANCE6_WEBGL`,e[e.CLIP_DISTANCE7_WEBGL=12295]=`CLIP_DISTANCE7_WEBGL`,e[e.POLYGON_OFFSET_CLAMP_EXT=36379]=`POLYGON_OFFSET_CLAMP_EXT`,e[e.LOWER_LEFT_EXT=36001]=`LOWER_LEFT_EXT`,e[e.UPPER_LEFT_EXT=36002]=`UPPER_LEFT_EXT`,e[e.NEGATIVE_ONE_TO_ONE_EXT=37726]=`NEGATIVE_ONE_TO_ONE_EXT`,e[e.ZERO_TO_ONE_EXT=37727]=`ZERO_TO_ONE_EXT`,e[e.CLIP_ORIGIN_EXT=37724]=`CLIP_ORIGIN_EXT`,e[e.CLIP_DEPTH_MODE_EXT=37725]=`CLIP_DEPTH_MODE_EXT`,e[e.SRC1_COLOR_WEBGL=35065]=`SRC1_COLOR_WEBGL`,e[e.SRC1_ALPHA_WEBGL=34185]=`SRC1_ALPHA_WEBGL`,e[e.ONE_MINUS_SRC1_COLOR_WEBGL=35066]=`ONE_MINUS_SRC1_COLOR_WEBGL`,e[e.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]=`ONE_MINUS_SRC1_ALPHA_WEBGL`,e[e.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]=`MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL`,e[e.MIRROR_CLAMP_TO_EDGE_EXT=34627]=`MIRROR_CLAMP_TO_EDGE_EXT`})(qO||={});var JO={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},YO=e=>({drawBuffersWEBGL(t){return e.drawBuffers(t)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),XO=e=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return e.createVertexArray()},deleteVertexArrayOES(t){return e.deleteVertexArray(t)},isVertexArrayOES(t){return e.isVertexArray(t)},bindVertexArrayOES(t){return e.bindVertexArray(t)}}),ZO=e=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...t){return e.drawArraysInstanced(...t)},drawElementsInstancedANGLE(...t){return e.drawElementsInstanced(...t)},vertexAttribDivisorANGLE(...t){return e.vertexAttribDivisor(...t)}});function QO(e=!0){let t=HTMLCanvasElement.prototype;if(!e&&t.originalGetContext){t.getContext=t.originalGetContext,t.originalGetContext=void 0;return}t.originalGetContext=t.getContext,t.getContext=function(e,t){if(e===`webgl`||e===`experimental-webgl`){let e=this.originalGetContext(`webgl2`,t);return e instanceof HTMLElement&&$O(e),e}return this.originalGetContext(e,t)}}function $O(e){e.getExtension(`EXT_color_buffer_float`);let t={...JO,WEBGL_disjoint_timer_query:e.getExtension(`EXT_disjoint_timer_query_webgl2`),WEBGL_draw_buffers:YO(e),OES_vertex_array_object:XO(e),ANGLE_instanced_arrays:ZO(e)},n=e.getExtension;e.getExtension=function(r){return n.call(e,r)||(r in t?t[r]:null)};let r=e.getSupportedExtensions;e.getSupportedExtensions=function(){return(r.apply(e)||[])?.concat(Object.keys(t))}}async function ek(e,t){let n=document.getElementsByTagName(`head`)[0];if(!n)throw Error(`loadScript`);let r=document.createElement(`script`);return r.setAttribute(`type`,`text/javascript`),r.setAttribute(`src`,e),t&&(r.id=t),new Promise((t,i)=>{r.onload=t,r.onerror=t=>i(Error(`Unable to load script '${e}': ${t}`)),n.appendChild(r)})}function tk(e){let t=e.luma||{_polyfilled:!1,extensions:{},softwareRenderer:!1};return t._polyfilled??=!1,t.extensions||={},e.luma=t,t}var nk=1,rk=null,ik=!1,ak={debugSpectorJS:Z.get(`debug-spectorjs`),debugSpectorJSUrl:`https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js`,gl:void 0};async function ok(e){if(!globalThis.SPECTOR)try{await ek(e.debugSpectorJSUrl||ak.debugSpectorJSUrl)}catch(e){Z.warn(String(e))}}function sk(e){if(e={...ak,...e},!e.debugSpectorJS)return null;if(!rk&&globalThis.SPECTOR&&!globalThis.luma?.spector){Z.probe(nk,"SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();let{Spector:e}=globalThis.SPECTOR;rk=new e,globalThis.luma&&(globalThis.luma.spector=rk)}if(!rk)return null;if(ik||(ik=!0,rk.spyCanvases(),rk?.onCaptureStarted.add(e=>Z.info(`Spector capture started:`,e)()),rk?.onCapture.add(e=>{Z.info(`Spector capture complete:`,e)(),rk?.getResultUI(),rk?.resultView.display(),rk?.resultView.addCapture(e)})),e.gl){let t=e.gl,n=tk(t),r=n.device;rk?.startCapture(e.gl,500),n.device=r,new Promise(e=>setTimeout(e,2e3)).then(e=>{Z.info(`Spector capture stopped after 2 seconds`)(),rk?.stopCapture()})}return rk}var ck=`https://unpkg.com/webgl-debug@2.0.1/index.js`;function lk(e){return e.luma=e.luma||{},e.luma}async function uk(){ad()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await ek(ck))}function dk(e,t={}){return t.debugWebGL||t.traceWebGL?pk(e,t):fk(e)}function fk(e){let t=lk(e);return t.realContext?t.realContext:e}function pk(e,t){if(!globalThis.WebGLDebugUtils)return Z.warn(`webgl-debug not loaded`)(),e;let n=lk(e);if(n.debugContext)return n.debugContext;globalThis.WebGLDebugUtils.init({...qO,...e});let r=globalThis.WebGLDebugUtils.makeDebugContext(e,hk.bind(null,t),gk.bind(null,t));for(let e in qO)!(e in r)&&typeof qO[e]==`number`&&(r[e]=qO[e]);class i{}Object.setPrototypeOf(r,Object.getPrototypeOf(e)),Object.setPrototypeOf(i,r);let a=Object.create(i);return n.realContext=e,n.debugContext=a,a.luma=n,a.debug=!0,a}function mk(e,t){t=Array.from(t).map(e=>e===void 0?`undefined`:e);let n=globalThis.WebGLDebugUtils.glFunctionArgsToString(e,t);return n=`${n.slice(0,100)}${n.length>100?`...`:``}`,`gl.${e}(${n})`}function hk(e,t,n,r){r=Array.from(r).map(e=>e===void 0?`undefined`:e);let i=`${globalThis.WebGLDebugUtils.glEnumToString(t)} in gl.${n}(${globalThis.WebGLDebugUtils.glFunctionArgsToString(n,r)})`;throw Z.error(`%cWebGL`,`color: white; background: red; padding: 2px 6px; border-radius: 3px;`,i)(),Error(i)}function gk(e,t,n){let r=``;e.traceWebGL&&Z.level>=1&&(r=mk(t,n),Z.info(1,`%cWebGL`,`color: white; background: blue; padding: 2px 6px; border-radius: 3px;`,r)());for(let e of n)e===void 0&&(r||=mk(t,n))}var _k=`modulepreload`,vk=function(e,t){return new URL(e,t).href},yk={},bk=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=vk(t,n),t in yk)return;yk[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`:_k,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)})},xk=1,Sk=class extends yb{type=`webgl`;constructor(){super(),fb.defaultProps={...fb.defaultProps,...ak}}enforceWebGL2(e){QO(e)}isSupported(){return typeof WebGL2RenderingContext<`u`}isDeviceHandle(e){return typeof WebGL2RenderingContext<`u`&&e instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<`u`&&e instanceof WebGLRenderingContext&&Z.warn(`WebGL1 is not supported`,e)(),!1)}async attach(e,t={}){let{WebGLDevice:n}=await bk(async()=>{let{WebGLDevice:e}=await Promise.resolve().then(()=>dM);return{WebGLDevice:e}},void 0,import.meta.url);if(e instanceof n)return e;let r=n.getDeviceFromContext(e);if(r)return r;if(!Ck(e))throw Error(`Invalid WebGL2RenderingContext`);let i=t.createCanvasContext===!0?{}:t.createCanvasContext;return new n({...t,_handle:e,createCanvasContext:{canvas:e.canvas,autoResize:!1,...i}})}async create(e={}){let{WebGLDevice:t}=await bk(async()=>{let{WebGLDevice:e}=await Promise.resolve().then(()=>dM);return{WebGLDevice:e}},void 0,import.meta.url),n=[];(e.debugWebGL||e.debug)&&n.push(uk()),e.debugSpectorJS&&n.push(ok(e));let r=await Promise.allSettled(n);for(let e of r)e.status===`rejected`&&Z.error(`Failed to initialize debug libraries ${e.reason}`)();try{let n=new t(e);Z.groupCollapsed(xk,`WebGLDevice ${n.id} created`)();let r=`\
|
|
2085
|
+
`}}},lT=[SS],uT=[`vs:DECKGL_FILTER_SIZE(inout vec3 size, VertexGeometry geometry)`,`vs:DECKGL_FILTER_GL_POSITION(inout vec4 position, VertexGeometry geometry)`,`vs:DECKGL_FILTER_COLOR(inout vec4 color, VertexGeometry geometry)`,`fs:DECKGL_FILTER_COLOR(inout vec4 color, FragmentGeometry geometry)`],dT=[];function fT(e){let t=d_.getDefaultShaderAssembler();for(let e of lT)t.addDefaultModule(e);t._hookFunctions.length=0;let n=e===`glsl`?uT:dT;for(let e of n)t.addShaderHook(e);return t}var pT=[255,255,255],mT=1,hT=0,gT=class{constructor(e={}){this.type=`ambient`;let{color:t=pT}=e,{intensity:n=mT}=e;this.id=e.id||`ambient-${hT++}`,this.color=t,this.intensity=n}},_T=[255,255,255],vT=1,yT=[0,0,-1],bT=0,xT=class{constructor(e={}){this.type=`directional`;let{color:t=_T}=e,{intensity:n=vT}=e,{direction:r=yT}=e,{_shadow:i=!1}=e;this.id=e.id||`directional-${bT++}`,this.color=t,this.intensity=n,this.type=`directional`,this.direction=new uv(r).normalize().toArray(),this.shadow=i}getProjectedLight(e){return this}},ST=class{constructor(e,t={id:`pass`}){let{id:n}=t;this.id=n,this.device=e,this.props={...t}}setProps(e){Object.assign(this.props,e)}render(e){}cleanup(){}},CT={depthWriteEnabled:!0,depthCompare:`less-equal`,blendColorOperation:`add`,blendColorSrcFactor:`src-alpha`,blendColorDstFactor:`one`,blendAlphaOperation:`add`,blendAlphaSrcFactor:`one-minus-dst-alpha`,blendAlphaDstFactor:`one`},wT=class extends ST{constructor(){super(...arguments),this._lastRenderIndex=-1}render(e){this._render(e)}_render(e){let t=this.device.canvasContext,n=e.target??t.getCurrentFramebuffer(),[r,i]=t.getDrawingBufferSize(),a=e.clearCanvas??!0,o=e.clearColor??(a?[0,0,0,0]:!1),s=a?1:!1,c=a?0:!1,l=e.colorMask??15,u={viewport:[0,0,r,i]};e.colorMask&&(u.colorMask=l),e.scissorRect&&(u.scissorRect=e.scissorRect);let d=this.device.beginRenderPass({framebuffer:n,parameters:u,clearColor:o,clearDepth:s,clearStencil:c});try{return this._drawLayers(d,e)}finally{d.end(),this.device.submit()}}_drawLayers(e,t){let{target:n,shaderModuleProps:r,viewports:i,views:a,onViewportActive:o,clearStack:s=!0}=t;t.pass=t.pass||`unknown`,s&&(this._lastRenderIndex=-1);let c=[];for(let s of i){let i=a&&a[s.id];o?.(s);let l=this._getDrawLayerParams(s,t),u=s.subViewports||[s];for(let a of u){let o=this._drawLayersInViewport(e,{target:n,shaderModuleProps:r,viewport:a,view:i,pass:t.pass,layers:t.layers},l);c.push(o)}}return c}_getDrawLayerParams(e,{layers:t,pass:n,isPicking:r=!1,layerFilter:i,cullRect:a,effects:o,shaderModuleProps:s},c=!1){let l=[],u=TT(this._lastRenderIndex+1),d={layer:t[0],viewport:e,isPicking:r,renderPass:n,cullRect:a},f={};for(let r=0;r<t.length;r++){let a=t[r],p=this._shouldDrawLayer(a,d,i,f),m={shouldDrawLayer:p};p&&!c&&(m.shouldDrawLayer=!0,m.layerRenderIndex=u(a,p),m.shaderModuleProps=this._getShaderModuleProps(a,o,n,s),m.layerParameters={...a.context.device.type===`webgpu`?CT:null,...a.context.deck?.props.parameters,...this.getLayerParameters(a,r,e)}),l[r]=m}return l}_drawLayersInViewport(e,{layers:t,shaderModuleProps:n,pass:r,target:i,viewport:a,view:o},s){let c=ET(this.device,{shaderModuleProps:n,target:i,viewport:a});if(o){let{clear:e,clearColor:t,clearDepth:n,clearStencil:r}=o.props;if(e){let e=[0,0,0,0],a=1,o=0;Array.isArray(t)?e=[...t.slice(0,3),t[3]||255].map(e=>e/255):t===!1&&(e=!1),n!==void 0&&(a=n),r!==void 0&&(o=r),this.device.beginRenderPass({framebuffer:i,parameters:{viewport:c,scissorRect:c},clearColor:e,clearDepth:a,clearStencil:o}).end()}}let l={totalCount:t.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:c});for(let n=0;n<t.length;n++){let i=t[n],o=s[n],{shouldDrawLayer:c}=o;if(c&&i.props.pickable&&l.pickableCount++,i.isComposite&&l.compositeCount++,i.isDrawable&&o.shouldDrawLayer){let{layerRenderIndex:t,shaderModuleProps:n,layerParameters:s}=o;l.visibleCount++,this._lastRenderIndex=Math.max(this._lastRenderIndex,t),n.project&&(n.project.viewport=a),i.context.renderPass=e;try{i._drawLayer({renderPass:e,shaderModuleProps:n,uniforms:{layerIndex:t},parameters:s})}catch(e){i.raiseError(e,`drawing ${i} to ${r}`)}}}return l}shouldDrawLayer(e){return!0}getShaderModuleProps(e,t,n){return null}getLayerParameters(e,t,n){return e.props.parameters}_shouldDrawLayer(e,t,n,r){if(!(e.props.visible&&this.shouldDrawLayer(e)))return!1;t.layer=e;let i=e.parent;for(;i;){if(!i.props.visible||!i.filterSubLayer(t))return!1;t.layer=i,i=i.parent}if(n){let e=t.layer.id;if(e in r||(r[e]=n(t)),!r[e])return!1}return e.activateViewport(t.viewport),!0}_getShaderModuleProps(e,t,n,r){let i=this.device.canvasContext.cssToDeviceRatio(),a=e.internalState?.propsInTransition||e.props,o={layer:a,picking:{isActive:!1},project:{viewport:e.context.viewport,devicePixelRatio:i,modelMatrix:a.modelMatrix,coordinateSystem:a.coordinateSystem,coordinateOrigin:a.coordinateOrigin,autoWrapLongitude:e.wrapLongitude}};if(t)for(let n of t)DT(o,n.getShaderModuleProps?.(e,o));return DT(o,this.getShaderModuleProps(e,t,o),r)}};function TT(e=0,t={}){let n={},r=(i,a)=>{let o=i.props._offset,s=i.id,c=i.parent&&i.parent.id,l;if(c&&!(c in t)&&r(i.parent,!1),c in n){let e=n[c]=n[c]||TT(t[c],t);l=e(i,a),n[s]=e}else Number.isFinite(o)?(l=o+(t[c]||0),n[s]=null):l=e;return a&&l>=e&&(e=l+1),t[s]=l,l};return r}function ET(e,{shaderModuleProps:t,target:n,viewport:r}){let i=t?.project?.devicePixelRatio??e.canvasContext.cssToDeviceRatio(),[,a]=e.canvasContext.getDrawingBufferSize(),o=n?n.height:a,s=r;return[s.x*i,o-(s.y+s.height)*i,s.width*i,s.height*i]}function DT(e,...t){for(let n of t)if(n)for(let t in n)e[t]?Object.assign(e[t],n[t]):e[t]=n[t];return e}var OT=class extends wT{constructor(e,t){super(e,t);let n=e.createTexture({format:`rgba8unorm`,width:1,height:1,sampler:{minFilter:`linear`,magFilter:`linear`,addressModeU:`clamp-to-edge`,addressModeV:`clamp-to-edge`}}),r=e.createTexture({format:`depth16unorm`,width:1,height:1});this.fbo=e.createFramebuffer({id:`shadowmap`,width:1,height:1,colorAttachments:[n],depthStencilAttachment:r})}delete(){this.fbo&&=(this.fbo.destroy(),null)}getShadowMap(){return this.fbo.colorAttachments[0].texture}render(e){let t=this.fbo,n=this.device.canvasContext.cssToDeviceRatio(),r=e.viewports[0],i=r.width*n,a=r.height*n,o=[1,1,1,1];(i!==t.width||a!==t.height)&&t.resize({width:i,height:a}),super.render({...e,clearColor:o,target:t,pass:`shadow`})}getLayerParameters(e,t,n){return{...e.props.parameters,blend:!1,depthWriteEnabled:!0,depthCompare:`less-equal`}}shouldDrawLayer(e){return e.props.shadowEnabled!==!1}getShaderModuleProps(e,t,n){return{shadow:{project:n.project,drawToShadowMap:!0}}}},kT={color:[255,255,255],intensity:1},AT=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],jT=[0,0,0,200/255],MT=class{constructor(e={}){this.id=`lighting-effect`,this.shadowColor=jT,this.shadow=!1,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;let{device:t,deck:n}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(t),n._addDefaultShaderModule(oT),this.dummyShadowMap=t.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=void 0,this.directionalLights=[],this.pointLights=[];for(let t in e){let n=e[t];switch(n.type){case`ambient`:this.ambientLight=n;break;case`directional`:this.directionalLights.push(n);break;case`point`:this.pointLights.push(n);break;default:}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(e=>e.shadow),this.context&&this.setup(this.context),this.props=e}preRender({layers:e,layerFilter:t,viewports:n,onViewportActive:r,views:i}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let a=0;a<this.shadowPasses.length;a++)this.shadowPasses[a].render({layers:e,layerFilter:t,viewports:n,onViewportActive:r,views:i,shaderModuleProps:{shadow:{shadowLightId:a,dummyShadowMap:this.dummyShadowMap,shadowMatrices:this.shadowMatrices}}})}}getShaderModuleProps(e,t){let n=this.shadow?{project:t.project,shadowMaps:this.shadowPasses.map(e=>e.getShadowMap()),dummyShadowMap:this.dummyShadowMap,shadowColor:this.shadowColor,shadowMatrices:this.shadowMatrices}:{},r={enabled:!0,lights:this._getLights(e)},i=e.props.material;return{shadow:n,lighting:r,phongMaterial:i,gouraudMaterial:i}}cleanup(e){for(let e of this.shadowPasses)e.delete();this.shadowPasses.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,e.deck._removeDefaultShaderModule(oT))}_calculateMatrices(){let e=[];for(let t of this.directionalLights){let n=new zv().lookAt({eye:new uv(t.direction).negate()});e.push(n)}return e}_createShadowPasses(e){for(let t=0;t<this.directionalLights.length;t++){let n=new OT(e);this.shadowPasses[t]=n}}_applyDefaultLights(){let{ambientLight:e,pointLights:t,directionalLights:n}=this;!e&&t.length===0&&n.length===0&&(this.ambientLight=new gT(kT),this.directionalLights.push(new xT(AT[0]),new xT(AT[1])))}_getLights(e){let t=[];this.ambientLight&&t.push(this.ambientLight);for(let n of this.pointLights)t.push(n.getProjectedLight({layer:e}));for(let n of this.directionalLights)t.push(n.getProjectedLight({layer:e}));return t}},NT=new class{constructor(e={}){this._pool=[],this.opts={overAlloc:2,poolSize:100},this.setOptions(e)}setOptions(e){Object.assign(this.opts,e)}allocate(e,t,{size:n=1,type:r,padding:i=0,copy:a=!1,initialize:o=!1,maxCount:s}){let c=r||e&&e.constructor||Float32Array,l=t*n+i;if(ArrayBuffer.isView(e)){if(l<=e.length)return e;if(l*e.BYTES_PER_ELEMENT<=e.buffer.byteLength)return new c(e.buffer,0,l)}let u=1/0;s&&(u=s*n+i);let d=this._allocate(c,l,o,u);return e&&a?d.set(e):o||d.fill(0,0,4),this._release(e),d}release(e){this._release(e)}_allocate(e,t,n,r){let i=Math.max(Math.ceil(t*this.opts.overAlloc),1);i>r&&(i=r);let a=this._pool,o=e.BYTES_PER_ELEMENT*i,s=a.findIndex(e=>e.byteLength>=o);if(s>=0){let t=new e(a.splice(s,1)[0],0,i);return n&&t.fill(0),t}return new e(i)}_release(e){if(!ArrayBuffer.isView(e))return;let t=this._pool,{buffer:n}=e,{byteLength:r}=n,i=t.findIndex(e=>e.byteLength>=r);i<0?t.push(n):(i>0||t.length<this.opts.poolSize)&&t.splice(i,0,n),t.length>this.opts.poolSize&&t.shift()}};function PT(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function FT(e,t){let n=e%t;return n<0?t+n:n}function IT(e){return[e[12],e[13],e[14]]}function LT(e){return{left:zT(e[3]+e[0],e[7]+e[4],e[11]+e[8],e[15]+e[12]),right:zT(e[3]-e[0],e[7]-e[4],e[11]-e[8],e[15]-e[12]),bottom:zT(e[3]+e[1],e[7]+e[5],e[11]+e[9],e[15]+e[13]),top:zT(e[3]-e[1],e[7]-e[5],e[11]-e[9],e[15]-e[13]),near:zT(e[3]+e[2],e[7]+e[6],e[11]+e[10],e[15]+e[14]),far:zT(e[3]-e[2],e[7]-e[6],e[11]-e[10],e[15]-e[14])}}var RT=new uv;function zT(e,t,n,r){RT.set(e,t,n);let i=RT.len();return{distance:r/i,normal:new uv(-e/i,-t/i,-n/i)}}function BT(e){return e-Math.fround(e)}var VT;function HT(e,t){let{size:n=1,startIndex:r=0}=t,i=t.endIndex===void 0?e.length:t.endIndex,a=(i-r)/n;VT=NT.allocate(VT,a,{type:Float32Array,size:n*2});let o=r,s=0;for(;o<i;){for(let t=0;t<n;t++){let r=e[o++];VT[s+t]=r,VT[s+t+n]=BT(r)}s+=n*2}return VT.subarray(0,a*n*2)}function UT(e){let t=null,n=!1;for(let r of e)r&&(t?(n||=(t=[[t[0][0],t[0][1]],[t[1][0],t[1][1]]],!0),t[0][0]=Math.min(t[0][0],r[0][0]),t[0][1]=Math.min(t[0][1],r[0][1]),t[1][0]=Math.max(t[1][0],r[1][0]),t[1][1]=Math.max(t[1][1],r[1][1])):t=r);return t}var WT=Math.PI/180,GT=PT(),KT=[0,0,0],qT={unitsPerMeter:[1,1,1],metersPerUnit:[1,1,1]};function JT({width:e,height:t,orthographic:n,fovyRadians:r,focalDistance:i,padding:a,near:o,far:s}){let c=e/t,l=n?new zv().orthographic({fovy:r,aspect:c,focalDistance:i,near:o,far:s}):new zv().perspective({fovy:r,aspect:c,near:o,far:s});if(a){let{left:n=0,right:r=0,top:i=0,bottom:o=0}=a,s=y_((n+e-r)/2,0,e)-e/2,c=y_((i+t-o)/2,0,t)-t/2;l[8]-=s*2/e,l[9]+=c*2/t}return l}var YT=class e{constructor(e={}){this._frustumPlanes={},this.id=e.id||this.constructor.displayName||`viewport`,this.x=e.x||0,this.y=e.y||0,this.width=e.width||1,this.height=e.height||1,this.zoom=e.zoom||0,this.padding=e.padding,this.distanceScales=e.distanceScales||qT,this.focalDistance=e.focalDistance||1,this.position=e.position||KT,this.modelMatrix=e.modelMatrix||null;let{longitude:t,latitude:n}=e;this.isGeospatial=Number.isFinite(n)&&Number.isFinite(t),this._initProps(e),this._initMatrices(e),this.equals=this.equals.bind(this),this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.projectPosition=this.projectPosition.bind(this),this.unprojectPosition=this.unprojectPosition.bind(this),this.projectFlat=this.projectFlat.bind(this),this.unprojectFlat=this.unprojectFlat.bind(this)}get subViewports(){return null}get metersPerPixel(){return this.distanceScales.metersPerUnit[2]/this.scale}get projectionMode(){return this.isGeospatial?this.zoom<12?qC.WEB_MERCATOR:qC.WEB_MERCATOR_AUTO_OFFSET:qC.IDENTITY}equals(t){return t instanceof e?this===t?!0:t.width===this.width&&t.height===this.height&&t.scale===this.scale&&x_(t.projectionMatrix,this.projectionMatrix)&&x_(t.viewMatrix,this.viewMatrix):!1}project(e,{topLeft:t=!0}={}){let n=Hw(this.projectPosition(e),this.pixelProjectionMatrix),[r,i]=n,a=t?i:this.height-i;return e.length===2?[r,a]:[r,a,n[2]]}unproject(e,{topLeft:t=!0,targetZ:n}={}){let[r,i,a]=e,o=t?i:this.height-i,s=n&&n*this.distanceScales.unitsPerMeter[2],c=Uw([r,o,a],this.pixelUnprojectionMatrix,s),[l,u,d]=this.unprojectPosition(c);return Number.isFinite(a)?[l,u,d]:Number.isFinite(n)?[l,u,n]:[l,u]}projectPosition(e){let[t,n]=this.projectFlat(e);return[t,n,(e[2]||0)*this.distanceScales.unitsPerMeter[2]]}unprojectPosition(e){let[t,n]=this.unprojectFlat(e);return[t,n,(e[2]||0)*this.distanceScales.metersPerUnit[2]]}projectFlat(e){if(this.isGeospatial){let t=Mw(e);return t[1]=y_(t[1],-318,830),t}return e}unprojectFlat(e){return this.isGeospatial?Nw(e):e}getBounds(e={}){let t={targetZ:e.z||0},n=this.unproject([0,0],t),r=this.unproject([this.width,0],t),i=this.unproject([0,this.height],t),a=this.unproject([this.width,this.height],t);return[Math.min(n[0],r[0],i[0],a[0]),Math.min(n[1],r[1],i[1],a[1]),Math.max(n[0],r[0],i[0],a[0]),Math.max(n[1],r[1],i[1],a[1])]}getDistanceScales(e){return e&&this.isGeospatial?Iw({longitude:e[0],latitude:e[1],highPrecision:!0}):this.distanceScales}containsPixel({x:e,y:t,width:n=1,height:r=1}){return e<this.x+this.width&&this.x<e+n&&t<this.y+this.height&&this.y<t+r}getFrustumPlanes(){return this._frustumPlanes.near||Object.assign(this._frustumPlanes,LT(this.viewProjectionMatrix)),this._frustumPlanes}panByPosition(e,t,n){return null}_initProps(e){let t=e.longitude,n=e.latitude;this.isGeospatial&&(Number.isFinite(e.zoom)||(this.zoom=Pw({latitude:n})+Math.log2(this.focalDistance)),this.distanceScales=e.distanceScales||Iw({latitude:n,longitude:t}));let r=2**this.zoom;this.scale=r;let{position:i,modelMatrix:a}=e,o=KT;if(i&&(o=a?new zv(a).transformAsVector(i,[]):i),this.isGeospatial){let e=this.projectPosition([t,n,0]);this.center=new uv(o).scale(this.distanceScales.unitsPerMeter).add(e)}else this.center=this.projectPosition(o)}_initMatrices(e){let{viewMatrix:t=GT,projectionMatrix:n=null,orthographic:r=!1,fovyRadians:i,fovy:a=75,near:o=.1,far:s=1e3,padding:c=null,focalDistance:l=1}=e;this.viewMatrixUncentered=t,this.viewMatrix=new zv().multiplyRight(t).translate(new uv(this.center).negate()),this.projectionMatrix=n||JT({width:this.width,height:this.height,orthographic:r,fovyRadians:i||a*WT,focalDistance:l,padding:c,near:o,far:s});let u=PT();gv(u,u,this.projectionMatrix),gv(u,u,this.viewMatrix),this.viewProjectionMatrix=u,this.viewMatrixInverse=mv([],this.viewMatrix)||this.viewMatrix,this.cameraPosition=IT(this.viewMatrixInverse);let d=PT(),f=PT();vv(d,d,[this.width/2,-this.height/2,1]),_v(d,d,[1,-1,0]),gv(f,d,this.viewProjectionMatrix),this.pixelProjectionMatrix=f,this.pixelUnprojectionMatrix=mv(PT(),this.pixelProjectionMatrix),this.pixelUnprojectionMatrix||X.warn(`Pixel project matrix not invertible`)()}};YT.displayName=`Viewport`;var XT=class e extends YT{constructor(e={}){let{latitude:t=0,longitude:n=0,zoom:r=0,pitch:i=0,bearing:a=0,nearZMultiplier:o=.1,farZMultiplier:s=1.01,nearZ:c,farZ:l,orthographic:u=!1,projectionMatrix:d,repeat:f=!1,worldOffset:p=0,position:m,padding:h,legacyMeterSizes:g=!1}=e,{width:_,height:v,altitude:y=1.5}=e,b=2**r;_||=1,v||=1;let x,S=null;if(d)y=d[5]/2,x=Bw(y);else{e.fovy?(x=e.fovy,y=Vw(x)):x=Bw(y);let n;if(h){let{top:e=0,bottom:t=0}=h;n=[0,y_((e+v-t)/2,0,v)-v/2]}S=zw({width:_,height:v,scale:b,center:m&&[0,0,m[2]*Fw(t)],offset:n,pitch:i,fovy:x,nearZMultiplier:o,farZMultiplier:s}),Number.isFinite(c)&&(S.near=c),Number.isFinite(l)&&(S.far=l)}let C=Rw({height:v,pitch:i,bearing:a,scale:b,altitude:y});p&&(C=new zv().translate([512*p,0,0]).multiplyLeft(C)),super({...e,width:_,height:v,viewMatrix:C,longitude:n,latitude:t,zoom:r,...S,fovy:x,focalDistance:y}),this.latitude=t,this.longitude=n,this.zoom=r,this.pitch=i,this.bearing=a,this.altitude=y,this.fovy=x,this.orthographic=u,this._subViewports=f?[]:null,this._pseudoMeters=g,Object.freeze(this)}get subViewports(){if(this._subViewports&&!this._subViewports.length){let t=this.getBounds(),n=Math.floor((t[0]+180)/360),r=Math.ceil((t[2]-180)/360);for(let t=n;t<=r;t++){let n=t?new e({...this,worldOffset:t}):this;this._subViewports.push(n)}}return this._subViewports}projectPosition(e){if(this._pseudoMeters)return super.projectPosition(e);let[t,n]=this.projectFlat(e);return[t,n,(e[2]||0)*Fw(e[1])]}unprojectPosition(e){if(this._pseudoMeters)return super.unprojectPosition(e);let[t,n]=this.unprojectFlat(e);return[t,n,(e[2]||0)/Fw(n)]}addMetersToLngLat(e,t){return Lw(e,t)}panByPosition(e,t,n){let r=Uw(t,this.pixelUnprojectionMatrix),i=N_([],this.projectFlat(e),F_([],r)),a=N_([],this.center,i),[o,s]=this.unprojectFlat(a);return{longitude:o,latitude:s}}panByPosition3D(e,t){let n=e[2]||0,r=R_([],e,this.unproject(t,{targetZ:n}));return{longitude:this.longitude+r[0],latitude:this.latitude+r[1]}}getBounds(e={}){let t=qw(this,e.z||0);return[Math.min(t[0][0],t[1][0],t[2][0],t[3][0]),Math.min(t[0][1],t[1][1],t[2][1],t[3][1]),Math.max(t[0][0],t[1][0],t[2][0],t[3][0]),Math.max(t[0][1],t[1][1],t[2][1],t[3][1])]}fitBounds(t,n={}){let{width:r,height:i}=this,{longitude:a,latitude:o,zoom:s}=Ww({width:r,height:i,bounds:t,...n});return new e({width:r,height:i,longitude:a,latitude:o,zoom:s})}};XT.displayName=`WebMercatorViewport`;var ZT=[0,0,0];function QT(e,t,n=!1){let r=t.projectPosition(e);if(n&&t instanceof XT){let[n,i,a=0]=e;r[2]=a*t.getDistanceScales([n,i]).unitsPerMeter[2]}return r}function $T(e){let{viewport:t,modelMatrix:n,coordinateOrigin:r}=e,{coordinateSystem:i,fromCoordinateSystem:a,fromCoordinateOrigin:o}=e;return i===`default`&&(i=t.isGeospatial?`lnglat`:`cartesian`),a===void 0?a=i:a===`default`&&(a=t.isGeospatial?`lnglat`:`cartesian`),o===void 0&&(o=r),{viewport:t,coordinateSystem:i,coordinateOrigin:r,modelMatrix:n,fromCoordinateSystem:a,fromCoordinateOrigin:o}}function eE(e,{viewport:t,modelMatrix:n,coordinateSystem:r,coordinateOrigin:i,offsetMode:a}){let[o,s,c=0]=e;switch(n&&([o,s,c]=Mv([],[o,s,c,1],n)),r){case`default`:return eE(e,{viewport:t,modelMatrix:n,coordinateSystem:t.isGeospatial?`lnglat`:`cartesian`,coordinateOrigin:i,offsetMode:a});case`lnglat`:return QT([o,s,c],t,a);case`lnglat-offsets`:return QT([o+i[0],s+i[1],c+(i[2]||0)],t,a);case`meter-offsets`:return QT(Lw(i,[o,s,c]),t,a);case`cartesian`:return t.isGeospatial?[o+i[0],s+i[1],c+i[2]]:t.projectPosition([o,s,c]);default:throw Error(`Invalid coordinateSystem: ${r}`)}}function tE(e,t){let{viewport:n,coordinateSystem:r,coordinateOrigin:i,modelMatrix:a,fromCoordinateSystem:o,fromCoordinateOrigin:s}=$T(t),{autoOffset:c=!0}=t,{geospatialOrigin:l=ZT,shaderCoordinateOrigin:u=ZT,offsetMode:d=!1}=c?sw(n,r,i):{},f=eE(e,{viewport:n,modelMatrix:a,coordinateSystem:o,coordinateOrigin:s,offsetMode:d});return d&&iv(f,f,n.projectPosition(l||u)),f}var nE=1,rE=1,iE=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(e){let{delay:t=0,duration:n=1/0,rate:r=1,repeat:i=1}=e,a=nE++,o={time:0,delay:t,duration:n,rate:r,repeat:i};return this._setChannelTime(o,this.time),this.channels.set(a,o),a}removeChannel(e){this.channels.delete(e);for(let[t,n]of this.animations)n.channel===e&&this.detachAnimation(t)}isFinished(e){let t=this.channels.get(e);return t===void 0?!1:this.time>=t.delay+t.duration*t.repeat}getTime(e){if(e===void 0)return this.time;let t=this.channels.get(e);return t===void 0?-1:t.time}setTime(e){this.time=Math.max(0,e);let t=this.channels.values();for(let e of t)this._setChannelTime(e,this.time);let n=this.animations.values();for(let e of n){let{animation:t,channel:n}=e;t.setTime(this.getTime(n))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,t){let n=rE++;return this.animations.set(n,{animation:e,channel:t}),e.setTime(this.getTime(t)),n}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,t){let n=t-e.delay;n>=e.duration*e.repeat?e.time=e.duration*e.rate:(e.time=Math.max(0,n)%e.duration,e.time*=e.rate)}};function aE(e){let t=typeof window<`u`?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame:null;return t?t.call(window,e):setTimeout(()=>e(typeof performance<`u`?performance.now():Date.now()),1e3/60)}function oE(e){let t=typeof window<`u`?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame:null;if(t){t.call(window,e);return}clearTimeout(e)}var sE=0,cE=`Animation Loop`,lE=class e{static defaultAnimationLoopProps={device:null,onAddHTML:()=>``,onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:e=>console.error(e),stats:void 0,autoResizeViewport:!1};device=null;canvas=null;props;animationProps=null;timeline=null;stats;sharedStats;cpuTime;gpuTime;frameRate;display;_needsRedraw=`initialized`;_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;_error=null;_lastFrameTime=0;constructor(t){if(this.props={...e.defaultAnimationLoopProps,...t},t=this.props,!t.device)throw Error(`No device provided`);this.stats=t.stats||new Ff({id:`animation-loop-${sE++}`}),this.sharedStats=Tb.stats.get(cE),this.frameRate=this.stats.get(`Frame Rate`),this.frameRate.setSampleSize(1),this.cpuTime=this.stats.get(`CPU Time`),this.gpuTime=this.stats.get(`GPU Time`),this.setProps({autoResizeViewport:t.autoResizeViewport}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null),this.device?._disableDebugGPUTime()}delete(){this.destroy()}reportError(e){this.props.onError(e),this._error=e}setNeedsRedraw(e){return this._needsRedraw=this._needsRedraw||e,this}needsRedraw(){let e=this._needsRedraw;return this._needsRedraw=!1,e}setProps(e){return`autoResizeViewport`in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),this}async start(){if(this._running)return this;this._running=!0;try{if(!this._initialized){if(this._initialized=!0,await this._initDevice(),this._initialize(),!this._running)return null;await this.props.onInitialize(this._getAnimationProps())}return this._running?(this._cancelAnimationFrame(),this._requestAnimationFrame(),this):null}catch(e){let t=e instanceof Error?e:Error(`Unknown error`);throw this.props.onError(t),t}}stop(){return this._running&&(this.animationProps&&!this._error&&this.props.onFinalize(this.animationProps),this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1,this._lastFrameTime=0),this}redraw(e){return this.device?.isLost||this._error?this:(this._beginFrameTimers(e),this._setupFrame(),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&=(this._resolveNextFrame(this),this._nextFramePromise=null,null),this._endFrameTimers(),this)}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw(`waitForRender`),this._nextFramePromise||=new Promise(e=>{this._resolveNextFrame=e}),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw(`toDataURL`),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw Error(`OffscreenCanvas`)}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeViewport(),this.device?._enableDebugGPUTime()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){this._running&&(this._animationFrameId=aE(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(oE(this._animationFrameId),this._animationFrameId=null)}_animationFrame(e){this._running&&(this.redraw(e),this._requestAnimationFrame())}_renderFrame(e){if(this.display){this.display._renderFrame(e);return}this.props.onRender(this._getAnimationProps()),this.device?.submit()}_clearNeedsRedraw(){this._needsRedraw=!1}_setupFrame(){this._resizeViewport()}_initializeAnimationProps(){let e=this.device?.getDefaultCanvasContext();if(!this.device||!e)throw Error(`loop`);let t=e?.canvas,n=e.props.useDevicePixels;this.animationProps={animationLoop:this,device:this.device,canvasContext:e,canvas:t,useDevicePixels:n,timeline:this.timeline,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw Error(`animationProps`);return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;let{width:e,height:t,aspect:n}=this._getSizeAndAspect();(e!==this.animationProps.width||t!==this.animationProps.height)&&this.setNeedsRedraw(`drawing buffer resized`),n!==this.animationProps.aspect&&this.setNeedsRedraw(`drawing buffer aspect changed`),this.animationProps.width=e,this.animationProps.height=t,this.animationProps.aspect=n,this.animationProps.needsRedraw=this._needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw Error(`No device provided`);this.canvas=this.device.getDefaultCanvasContext().canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){let e=document.createElement(`div`);document.body.appendChild(e),e.style.position=`relative`;let t=document.createElement(`div`);t.style.position=`absolute`,t.style.left=`10px`,t.style.bottom=`10px`,t.style.width=`300px`,t.style.background=`white`,this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(t);let n=this.props.onAddHTML(t);n&&(t.innerHTML=n)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[e,t]=this.device.getDefaultCanvasContext().getDrawingBufferSize();return{width:e,height:t,aspect:e>0&&t>0?e/t:1}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_beginFrameTimers(e){let t=e??(typeof performance<`u`?performance.now():Date.now());if(this._lastFrameTime){let e=t-this._lastFrameTime;e>0&&this.frameRate.addTime(e)}this._lastFrameTime=t,this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeStart()}_endFrameTimers(){this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeEnd(),this._updateSharedStats()}_consumeEncodedGpuTime(){if(!this.device)return;let e=this.device.commandEncoder._gpuTimeMs;e!==void 0&&(this.gpuTime.addTime(e),this.device.commandEncoder._gpuTimeMs=void 0)}_updateSharedStats(){if(this.stats!==this.sharedStats){for(let e of Object.keys(this.sharedStats.stats))this.stats.stats[e]||delete this.sharedStats.stats[e];this.stats.forEach(e=>{let t=this.sharedStats.get(e.name,e.type);t.sampleSize=e.sampleSize,t.time=e.time,t.count=e.count,t.samples=e.samples,t.lastTiming=e.lastTiming,t.lastSampleTime=e.lastSampleTime,t.lastSampleCount=e.lastSampleCount,t._count=e._count,t._time=e._time,t._samples=e._samples,t._startTime=e._startTime,t._timerPending=e._timerPending})}}_startEventHandling(){this.canvas&&(this.canvas.addEventListener(`mousemove`,this._onMousemove.bind(this)),this.canvas.addEventListener(`mouseleave`,this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}},uE={};function dE(e=`id`){return uE[e]=uE[e]||1,`${e}-${uE[e]++}`}var fE=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){if(this.id=e.id||dE(`geometry`),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&!(this.indices.usage&ky.INDEX))throw Error(`Index buffer must have INDEX usage`)}destroy(){this.indices?.destroy();for(let e of Object.values(this.attributes))e.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(e){return e.byteLength/12}};function pE(e,t){if(t instanceof fE)return t;let n=mE(e,t),{attributes:r,bufferLayout:i}=hE(e,t);return new fE({topology:t.topology||`triangle-list`,bufferLayout:i,vertexCount:t.vertexCount,indices:n,attributes:r})}function mE(e,t){if(!t.indices)return;let n=t.indices.value;return e.createBuffer({usage:ky.INDEX,data:n})}function hE(e,t){let n=[],r={};for(let[i,a]of Object.entries(t.attributes)){let t=i;switch(i){case`POSITION`:t=`positions`;break;case`NORMAL`:t=`normals`;break;case`TEXCOORD_0`:t=`texCoords`;break;case`TEXCOORD_1`:t=`texCoords1`;break;case`COLOR_0`:t=`colors`;break}if(a){r[t]=e.createBuffer({data:a.value,id:`${i}-buffer`});let{value:o,size:s,normalized:c}=a;if(s===void 0)throw Error(`Attribute ${i} is missing a size`);n.push({name:t,format:My.getVertexFormatFromAttribute(o,s,c)})}}return{attributes:r,bufferLayout:n,vertexCount:t._calculateVertexCount(t.attributes,t.indices)}}function gE(e,t){let n={},r=`Values`;if(e.attributes.length===0&&!e.varyings?.length)return{"No attributes or varyings":{[r]:`N/A`}};for(let t of e.attributes)if(t){let e=`${t.location} ${t.name}: ${t.type}`;n[`in ${e}`]={[r]:t.stepMode||`vertex`}}for(let t of e.varyings||[]){let e=`${t.location} ${t.name}`;n[`out ${e}`]={[r]:JSON.stringify(t)}}return n}var _E=`__debugFramebufferState`,vE=8;function yE(e,t,n){if(e.device.type!==`webgl`)return;let r=SE(e.device);if(!r.flushing){if(wE(e)){bE(e,n,r);return}t&&CE(t)&&t.handle!==null&&(r.queuedFramebuffers.includes(t)||r.queuedFramebuffers.push(t))}}function bE(e,t,n){if(n.queuedFramebuffers.length===0)return;let{gl:r}=e.device,i=r.getParameter(36010),a=r.getParameter(36006),[o,s]=e.device.getDefaultCanvasContext().getDrawingBufferSize(),c=TE(t.top,vE),l=TE(t.left,vE);n.flushing=!0;try{for(let e of n.queuedFramebuffers){let[n,i,a,u,d]=xE({framebuffer:e,targetWidth:o,targetHeight:s,topPx:c,leftPx:l,minimap:t.minimap});r.bindFramebuffer(36008,e.handle),r.bindFramebuffer(36009,null),r.blitFramebuffer(0,0,e.width,e.height,n,i,a,u,16384,9728),c+=d+vE}}finally{r.bindFramebuffer(36008,i),r.bindFramebuffer(36009,a),n.flushing=!1}}function xE(e){let{framebuffer:t,targetWidth:n,targetHeight:r,topPx:i,leftPx:a,minimap:o}=e,s=o?Math.max(Math.floor(n/4),1):n,c=o?Math.max(Math.floor(r/4),1):r,l=Math.min(s/t.width,c/t.height),u=Math.max(Math.floor(t.width*l),1),d=Math.max(Math.floor(t.height*l),1),f=a,p=Math.max(r-i-d,0);return[f,p,f+u,p+d,d]}function SE(e){return e.userData[_E]||={flushing:!1,queuedFramebuffers:[]},e.userData[_E]}function CE(e){return`colorAttachments`in e}function wE(e){let t=e.props.framebuffer;return!t||t.handle===null}function TE(e,t){if(!e)return t;let n=Number.parseInt(e,10);return Number.isFinite(n)?n:t}function EE(e,t,n){if(e===t)return!0;if(!n||!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!EE(e[r],t[r],n-1))return!1;return!0}if(Array.isArray(t))return!1;if(typeof e==`object`&&typeof t==`object`){let r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;for(let i of r)if(!t.hasOwnProperty(i)||!EE(e[i],t[i],n-1))return!1;return!0}return!1}var DE=class{bufferLayouts;constructor(e){this.bufferLayouts=e}getBufferLayout(e){return this.bufferLayouts.find(t=>t.name===e)||null}getAttributeNamesForBuffer(e){return e.attributes?e.attributes?.map(e=>e.attribute):[e.name]}mergeBufferLayouts(e,t){let n=[...e];for(let e of t){let t=n.findIndex(t=>t.name===e.name);t<0?n.push(e):n[t]=e}return n}getBufferIndex(e){let t=this.bufferLayouts.findIndex(t=>t.name===e);return t===-1&&Z.warn(`BufferLayout: Missing buffer for "${e}".`)(),t}};function OE(e,t){let n=1/0;for(let r of e){let e=t[r];e!==void 0&&(n=Math.min(n,e))}return n}function kE(e,t){let n=Object.fromEntries(e.attributes.map(e=>[e.name,e.location])),r=t.slice();return r.sort((e,t)=>{let r=e.attributes?e.attributes.map(e=>e.attribute):[e.name],i=t.attributes?t.attributes.map(e=>e.attribute):[t.name];return OE(r,n)-OE(i,n)}),r}function AE(e,t){if(!e||!t.some(e=>e.bindingLayout?.length))return e;let n={...e,bindings:e.bindings.map(e=>({...e}))};`attributes`in(e||{})&&(n.attributes=e?.attributes||[]);for(let e of t)for(let t of e.bindingLayout||[])for(let e of ME(t.name)){let r=n.bindings.find(t=>t.name===e);r?.group===0&&(r.group=t.group)}return n}function jE(e){return!!(e.uniformTypes&&!NE(e.uniformTypes))}function ME(e){let t=new Set([e,`${e}Uniforms`]);return e.endsWith(`Uniforms`)||t.add(`${e}Sampler`),[...t]}function NE(e){for(let t in e)return!1;return!0}function PE(e){return xm(e)||typeof e==`number`||typeof e==`boolean`}function FE(e,t={}){let n={bindings:{},uniforms:{}};return Object.keys(e).forEach(r=>{let i=e[r];Object.prototype.hasOwnProperty.call(t,r)||PE(i)?n.uniforms[r]=i:n.bindings[r]=i}),n}var IE=class{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;constructor(e,t){Object.assign(this.options,t);let n=Nh(Object.values(e).filter(HE));for(let t of n)e[t.name]=t;Z.log(1,`Creating ShaderInputs with modules`,Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(let[t,n]of Object.entries(e))n&&(this._addModule(n),n.name&&t!==n.name&&!this.options.disableWarnings&&Z.warn(`Module name: ${t} vs ${n.name}`)())}destroy(){}setProps(e){for(let t of Object.keys(e)){let n=t,r=e[n]||{},i=this.modules[n];if(!i)this.options.disableWarnings||Z.warn(`Module ${t} not found`)();else{let e=this.moduleUniforms[n],t=this.moduleBindings[n],{uniforms:a,bindings:o}=FE(i.getUniforms?.(r,e)||r,i.uniformTypes);this.moduleUniforms[n]=LE(e,a,i.uniformTypes),this.moduleBindings[n]={...t,...o}}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindingValues(){let e={};for(let t of Object.values(this.moduleBindings))Object.assign(e,t);return e}getDebugTable(){let e={};for(let[t,n]of Object.entries(this.moduleUniforms))for(let[r,i]of Object.entries(n))e[`${t}.${r}`]={type:this.modules[t].uniformTypes?.[r],value:String(i)};return e}_addModule(e){let t=e.name;this.moduleUniforms[t]=LE({},e.defaultUniforms||{},e.uniformTypes),this.moduleBindings[t]={}}};function LE(e={},t={},n={}){let r={...e};for(let[i,a]of Object.entries(t))a!==void 0&&(r[i]=RE(e[i],a,n[i]));return r}function RE(e,t,n){if(!n||typeof n==`string`)return zE(t);if(Array.isArray(n)){if(BE(t)||!Array.isArray(t))return zE(t);let r=Array.isArray(e)&&!BE(e)?[...e]:[],i=r.slice();for(let e=0;e<t.length;e++){let a=t[e];a!==void 0&&(i[e]=RE(r[e],a,n[0]))}return i}if(!VE(t))return zE(t);let r=n,i=VE(e)?e:{},a={...i};for(let[e,n]of Object.entries(t))n!==void 0&&(a[e]=RE(i[e],n,r[e]));return a}function zE(e){return ArrayBuffer.isView(e)?Array.prototype.slice.call(e):Array.isArray(e)?BE(e)?e.slice():e.map(e=>e===void 0?void 0:zE(e)):VE(e)?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t===void 0?void 0:zE(t)])):e}function BE(e){return ArrayBuffer.isView(e)||Array.isArray(e)&&(e.length===0||typeof e[0]==`number`)}function VE(e){return!!e&&typeof e==`object`&&!Array.isArray(e)&&!ArrayBuffer.isView(e)}function HE(e){return!!e?.dependencies}var UE={"+X":0,"-X":1,"+Y":2,"-Y":3,"+Z":4,"-Z":5};function WE(e){return e?Array.isArray(e)?e[0]??null:e:null}function GE(e){let{dimension:t,data:n}=e;if(!n)return null;switch(t){case`1d`:{let e=WE(n);if(!e)return null;let{width:t}=KE(e);return{width:t,height:1}}case`2d`:{let e=WE(n);return e?KE(e):null}case`3d`:case`2d-array`:{if(!Array.isArray(n)||n.length===0)return null;let e=WE(n[0]);return e?KE(e):null}case`cube`:{let e=Object.keys(n)[0]??null;if(!e)return null;let t=n[e],r=WE(t);return r?KE(r):null}case`cube-array`:{if(!Array.isArray(n)||n.length===0)return null;let e=n[0],t=Object.keys(e)[0]??null;if(!t)return null;let r=WE(e[t]);return r?KE(r):null}default:return null}}function KE(e){if(ub(e))return db(e);if(typeof e==`object`&&`width`in e&&`height`in e)return{width:e.width,height:e.height};throw Error(`Unsupported mip-level data`)}function qE(e){return typeof e==`object`&&!!e&&`data`in e&&`width`in e&&`height`in e}function JE(e){return ArrayBuffer.isView(e)}function YE(e){let{textureFormat:t,format:n}=e;if(t&&n&&t!==n)throw Error(`Conflicting texture formats "${t}" and "${n}" provided for the same mip level`);return t??n}function XE(e){let t=UE[e];if(t===void 0)throw Error(`Invalid cube face: ${e}`);return t}function ZE(e,t){return 6*e+XE(t)}function QE(e){throw Error(`setTexture1DData not supported in WebGL.`)}function $E(e){return Array.isArray(e)?e:[e]}function eD(e,t,n,r){let i=$E(t),a=e,o=[];for(let e=0;e<i.length;e++){let t=i[e];if(ub(t))o.push({type:`external-image`,image:t,z:a,mipLevel:e});else if(qE(t))o.push({type:`texture-data`,data:t,textureFormat:YE(t),z:a,mipLevel:e});else if(JE(t)&&n)o.push({type:`texture-data`,data:{data:t,width:Math.max(1,n.width>>e),height:Math.max(1,n.height>>e),...r?{format:r}:{}},textureFormat:r,z:a,mipLevel:e});else throw Error(`Unsupported 2D mip-level payload`)}return o}function tD(e){let t=[];for(let n=0;n<e.length;n++)t.push(...eD(n,e[n]));return t}function nD(e){let t=[];for(let n=0;n<e.length;n++)t.push(...eD(n,e[n]));return t}function rD(e){let t=[];for(let[n,r]of Object.entries(e)){let e=XE(n);t.push(...eD(e,r))}return t}function iD(e){let t=[];return e.forEach((e,n)=>{for(let[r,i]of Object.entries(e)){let e=ZE(n,r);t.push(...eD(e,i))}}),t}var aD=class e{device;id;props;_texture=null;_sampler=null;_view=null;ready;isReady=!1;destroyed=!1;resolveReady=()=>{};rejectReady=()=>{};get texture(){if(!this._texture)throw Error(`Texture not initialized yet`);return this._texture}get sampler(){if(!this._sampler)throw Error(`Sampler not initialized yet`);return this._sampler}get view(){if(!this._view)throw Error(`View not initialized yet`);return this._view}get[Symbol.toStringTag](){return`DynamicTexture`}toString(){let e=this._texture?.width??this.props.width??`?`,t=this._texture?.height??this.props.height??`?`;return`DynamicTexture:"${this.id}":${e}x${t}px:(${this.isReady?`ready`:`loading...`})`}constructor(t,n){this.device=t;let r=dE(`dynamic-texture`),i=n;this.props={...e.defaultProps,id:r,...n,data:null},this.id=this.props.id,this.ready=new Promise((e,t)=>{this.resolveReady=e,this.rejectReady=t}),this.initAsync(i)}async initAsync(e){try{let t=await this._loadAllData(e);this._checkNotDestroyed();let n=t.data?oD({...t,width:e.width,height:e.height,format:e.format}):[],r=`format`in e&&e.format!==void 0,i=`usage`in e&&e.usage!==void 0,a=this.props.width&&this.props.height?{width:this.props.width,height:this.props.height}:GE(t)||{width:this.props.width||1,height:this.props.height||1};if(!a||a.width<=0||a.height<=0)throw Error(`${this} size could not be determined or was zero`);let o=sD(this.device,n,a,{format:r?e.format:void 0}),s=o.format??this.props.format,c={...this.props,...a,format:s,mipLevels:1,data:void 0};this.device.isTextureFormatCompressed(s)&&!i&&(c.usage=Kb.SAMPLE|Kb.COPY_DST);let l=this.props.mipmaps&&!o.hasExplicitMipChain&&!this.device.isTextureFormatCompressed(s);if(this.device.type===`webgpu`&&l){let e=this.props.dimension===`3d`?Kb.SAMPLE|Kb.STORAGE|Kb.COPY_DST|Kb.COPY_SRC:Kb.SAMPLE|Kb.RENDER|Kb.COPY_DST|Kb.COPY_SRC;c.usage|=e}let u=this.device.getMipLevelCount(c.width,c.height),d=o.hasExplicitMipChain?o.mipLevels:this.props.mipLevels===`auto`?u:Math.max(1,Math.min(u,this.props.mipLevels??1)),f={...c,mipLevels:d};this._texture=this.device.createTexture(f),this._sampler=this.texture.sampler,this._view=this.texture.view,o.subresources.length&&this._setTextureSubresources(o.subresources),this.props.mipmaps&&!o.hasExplicitMipChain&&!l&&Z.warn(`${this} skipping auto-generated mipmaps for compressed texture format`)(),l&&this.generateMipmaps(),this.isReady=!0,this.resolveReady(this.texture),Z.info(0,`${this} created`)()}catch(e){let t=e instanceof Error?e:Error(String(e));this.rejectReady(t)}}destroy(){this._texture&&(this._texture.destroy(),this._texture=null,this._sampler=null,this._view=null),this.destroyed=!0}generateMipmaps(){this.device.type===`webgl`?this.texture.generateMipmapsWebGL():this.device.type===`webgpu`?this.device.generateMipmapsWebGPU(this.texture):Z.warn(`${this} mipmaps not supported on ${this.device.type}`)}setSampler(e={}){this._checkReady();let t=e instanceof Wb?e:this.device.createSampler(e);this.texture.setSampler(t),this._sampler=t}async readBuffer(e={}){this.isReady||await this.ready;let t=e.width??this.texture.width,n=e.height??this.texture.height,r=e.depthOrArrayLayers??this.texture.depth,i=this.texture.computeMemoryLayout({width:t,height:n,depthOrArrayLayers:r}),a=this.device.createBuffer({byteLength:i.byteLength,usage:ky.COPY_DST|ky.MAP_READ});this.texture.readBuffer({...e,width:t,height:n,depthOrArrayLayers:r},a);let o=this.device.createFence();return await o.signaled,o.destroy(),a}async readAsync(e={}){this.isReady||await this.ready;let t=e.width??this.texture.width,n=e.height??this.texture.height,r=e.depthOrArrayLayers??this.texture.depth,i=this.texture.computeMemoryLayout({width:t,height:n,depthOrArrayLayers:r}),a=await this.readBuffer(e),o=await a.readAsync(0,i.byteLength);return a.destroy(),o.buffer}resize(e){if(this._checkReady(),e.width===this.texture.width&&e.height===this.texture.height)return!1;let t=this.texture;return this._texture=t.clone(e),this._sampler=this.texture.sampler,this._view=this.texture.view,t.destroy(),Z.info(`${this} resized`),!0}getCubeFaceIndex(e){let t=UE[e];if(t===void 0)throw Error(`Invalid cube face: ${e}`);return t}getCubeArrayFaceIndex(e,t){return 6*e+this.getCubeFaceIndex(t)}setTexture1DData(e){if(this._checkReady(),this.texture.props.dimension!==`1d`)throw Error(`${this} is not 1d`);let t=QE(e);this._setTextureSubresources(t)}setTexture2DData(e,t=0){if(this._checkReady(),this.texture.props.dimension!==`2d`)throw Error(`${this} is not 2d`);let n=eD(t,e);this._setTextureSubresources(n)}setTexture3DData(e){if(this.texture.props.dimension!==`3d`)throw Error(`${this} is not 3d`);let t=tD(e);this._setTextureSubresources(t)}setTextureArrayData(e){if(this.texture.props.dimension!==`2d-array`)throw Error(`${this} is not 2d-array`);let t=nD(e);this._setTextureSubresources(t)}setTextureCubeData(e){if(this.texture.props.dimension!==`cube`)throw Error(`${this} is not cube`);let t=rD(e);this._setTextureSubresources(t)}setTextureCubeArrayData(e){if(this.texture.props.dimension!==`cube-array`)throw Error(`${this} is not cube-array`);let t=iD(e);this._setTextureSubresources(t)}_setTextureSubresources(e){for(let t of e){let{z:e,mipLevel:n}=t;switch(t.type){case`external-image`:let{image:r,flipY:i}=t;this.texture.copyExternalImage({image:r,z:e,mipLevel:n,flipY:i});break;case`texture-data`:let{data:a,textureFormat:o}=t;if(o&&o!==this.texture.format)throw Error(`${this} mip level ${n} uses format "${o}" but texture format is "${this.texture.format}"`);this.texture.writeData(a.data,{x:0,y:0,z:e,width:a.width,height:a.height,depthOrArrayLayers:1,mipLevel:n});break;default:throw Error(`Unsupported 2D mip-level payload`)}}}async _loadAllData(e){let t=await dD(e.data);return{dimension:e.dimension??`2d`,data:t??null}}_checkNotDestroyed(){this.destroyed&&Z.warn(`${this} already destroyed`)}_checkReady(){this.isReady||Z.warn(`${this} Cannot perform this operation before ready`)}static defaultProps={...Kb.defaultProps,dimension:`2d`,data:null,mipmaps:!1}};function oD(e){if(!e.data)return[];let t=e.width&&e.height?{width:e.width,height:e.height}:void 0,n=`format`in e?e.format:void 0;switch(e.dimension){case`1d`:return QE(e.data);case`2d`:return eD(0,e.data,t,n);case`3d`:return tD(e.data);case`2d-array`:return nD(e.data);case`cube`:return rD(e.data);case`cube-array`:return iD(e.data);default:throw Error(`Unhandled dimension ${e.dimension}`)}}function sD(e,t,n,r){if(t.length===0)return{subresources:t,mipLevels:1,format:r.format,hasExplicitMipChain:!1};let i=new Map;for(let e of t){let t=i.get(e.z)??[];t.push(e),i.set(e.z,t)}let a=t.some(e=>e.mipLevel>0),o=r.format,s=1/0,c=[];for(let[t,r]of i){let i=[...r].sort((e,t)=>e.mipLevel-t.mipLevel),a=i[0];if(!a||a.mipLevel!==0)throw Error(`DynamicTexture: slice ${t} is missing mip level 0`);let l=lD(e,a);if(l.width!==n.width||l.height!==n.height)throw Error(`DynamicTexture: slice ${t} base level dimensions ${l.width}x${l.height} do not match expected ${n.width}x${n.height}`);let u=cD(a);if(u){if(o&&o!==u)throw Error(`DynamicTexture: slice ${t} base level format "${u}" does not match texture format "${o}"`);o=u}let d=o&&e.isTextureFormatCompressed(o)?uD(e,l.width,l.height,o):e.getMipLevelCount(l.width,l.height),f=0;for(let t=0;t<i.length;t++){let n=i[t];if(!n||n.mipLevel!==t||t>=d)break;let r=lD(e,n),a=Math.max(1,l.width>>t),s=Math.max(1,l.height>>t);if(r.width!==a||r.height!==s)break;let u=cD(n);if(u&&(o||=u,u!==o))break;f++,c.push(n)}s=Math.min(s,f)}let l=Number.isFinite(s)?Math.max(1,s):1;return{subresources:c.filter(e=>e.mipLevel<l),mipLevels:l,format:o,hasExplicitMipChain:a}}function cD(e){if(e.type===`texture-data`)return e.textureFormat??YE(e.data)}function lD(e,t){switch(t.type){case`external-image`:return e.getExternalImageSize(t.image);case`texture-data`:return{width:t.data.width,height:t.data.height};default:throw Error(`Unsupported texture subresource`)}}function uD(e,t,n,r){let{blockWidth:i=1,blockHeight:a=1}=e.getTextureFormatInfo(r),o=1;for(let e=1;;e++){let r=Math.max(1,t>>e),s=Math.max(1,n>>e);if(r<i||s<a)break;o++}return o}async function dD(e){if(e=await e,Array.isArray(e))return await Promise.all(e.map(dD));if(e&&typeof e==`object`&&e.constructor===Object){let t=e,n=await Promise.all(Object.values(t).map(dD)),r=Object.keys(t),i={};for(let e=0;e<r.length;e++)i[r[e]]=n[e];return i}return e}var fD=2,pD=1e4,mD=`render pipeline initialization failed`,hD=class e{static defaultProps={...ix.defaultProps,source:void 0,vs:null,fs:null,id:`unnamed`,handle:void 0,userData:{},defines:{},modules:[],geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},bindings:{},uniforms:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,material:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:d_.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0};device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};vertexArray;transformFeedback=null;pipeline;shaderInputs;material=null;_uniformStore;_attributeInfos={};_gpuGeometry=null;props;_pipelineNeedsUpdate=`newly created`;_needsRedraw=`initializing`;_destroyed=!1;_lastDrawTimestamp=-1;_bindingTable=[];get[Symbol.toStringTag](){return`Model`}toString(){return`Model(${this.id})`}constructor(t,n){this.props={...e.defaultProps,...n},n=this.props,this.id=n.id||dE(`model`),this.device=t,Object.assign(this.userData,n.userData),this.material=n.material||null;let r=Object.fromEntries(this.props.modules?.map(e=>[e.name,e])||[]),i=n.shaderInputs||new IE(r,{disableWarnings:this.props.disableWarnings});this.setShaderInputs(i);let a=gD(t),o=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];if(this.props.shaderLayout=AE(this.props.shaderLayout,o)||null,this.device.type===`webgpu`&&this.props.source){let{source:e,getUniforms:n,bindingTable:r}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:a,...this.props,modules:o});this.source=e,this._getModuleUniforms=n,this._bindingTable=r;let i=t.getShaderLayout?.(this.source);this.props.shaderLayout=AE(this.props.shaderLayout||i||null,o)||null}else{let{vs:e,fs:t,getUniforms:n}=this.props.shaderAssembler.assembleGLSLShaderPair({platformInfo:a,...this.props,modules:o});this.vs=e,this.fs=t,this._getModuleUniforms=n,this._bindingTable=[]}this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,n.geometry&&this.setGeometry(n.geometry),this.pipelineFactory=n.pipelineFactory||sx.getDefaultPipelineFactory(this.device),this.shaderFactory=n.shaderFactory||cx.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=t.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),`isInstanced`in n&&(this.isInstanced=n.isInstanced),n.instanceCount&&this.setInstanceCount(n.instanceCount),n.vertexCount&&this.setVertexCount(n.vertexCount),n.indexBuffer&&this.setIndexBuffer(n.indexBuffer),n.attributes&&this.setAttributes(n.attributes),n.constantAttributes&&this.setConstantAttributes(n.constantAttributes),n.bindings&&this.setBindings(n.bindings),n.transformFeedback&&(this.transformFeedback=n.transformFeedback)}destroy(){this._destroyed||=(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.pipeline.fs!==this.pipeline.vs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw(`contents of bound textures or buffers updated`);let e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||=e}getBindingDebugTable(){return this._bindingTable}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){let t=this._areBindingsLoading();if(t)return Z.info(fD,`>>> DRAWING ABORTED ${this.id}: ${t} not loaded`)(),!1;try{e.pushDebugGroup(`${this}.predraw(${e})`),this.predraw()}finally{e.popDebugGroup()}let n,r=this.pipeline.isErrored;try{if(e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline(),r=this.pipeline.isErrored,r)Z.info(fD,`>>> DRAWING ABORTED ${this.id}: ${mD}`)(),n=!1;else{let t=this._getBindings(),r=this._getBindGroups(),{indexBuffer:i}=this.vertexArray,a=i?i.byteLength/(i.indexType===`uint32`?4:2):void 0;n=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:a,transformFeedback:this.transformFeedback||void 0,bindings:t,bindGroups:r,_bindGroupCacheKeys:this._getBindGroupCacheKeys(),uniforms:this.props.uniforms,parameters:this.parameters,topology:this.topology})}}finally{e.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(e),n?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):r?this._needsRedraw=mD:this._needsRedraw=`waiting for resource initialization`,n}setGeometry(e){this._gpuGeometry?.destroy();let t=e&&pE(this.device,e);if(t){this.setTopology(t.topology||`triangle-list`);let e=new DE(this.bufferLayout);this.bufferLayout=e.mergeBufferLayouts(t.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(t)}this._gpuGeometry=t}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate(`topology`))}setBufferLayout(e){let t=new DE(this.bufferLayout);this.bufferLayout=this._gpuGeometry?t.mergeBufferLayouts(e,this._gpuGeometry.bufferLayout):e,this._setPipelineNeedsUpdate(`bufferLayout`),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(e){EE(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate(`parameters`))}setInstanceCount(e){this.instanceCount=e,this.isInstanced===void 0&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw(`instanceCount`)}setVertexCount(e){this.vertexCount=e,this.setNeedsRedraw(`vertexCount`)}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new mS(this.device,this.shaderInputs.modules);for(let[e,t]of Object.entries(this.shaderInputs.modules))if(jE(t)&&!this.material?.ownsModule(e)){let t=this._uniformStore.getManagedUniformBuffer(e);this.bindings[`${e}Uniforms`]=t}this.setNeedsRedraw(`shaderInputs`)}setMaterial(e){this.material=e,this.setNeedsRedraw(`material`)}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setBindings(this._getNonMaterialBindings(this.shaderInputs.getBindingValues())),this.setNeedsRedraw(`shaderInputs`)}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw(`bindings`)}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw(`transformFeedback`)}setIndexBuffer(e){this.vertexArray.setIndexBuffer(e),this.setNeedsRedraw(`indexBuffer`)}setAttributes(e,t){let n=t?.disableWarnings??this.props.disableWarnings;e.indices&&Z.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=kE(this.pipeline.shaderLayout,this.bufferLayout);let r=new DE(this.bufferLayout);for(let[t,i]of Object.entries(e)){let e=r.getBufferLayout(t);if(!e){n||Z.warn(`Model(${this.id}): Missing layout for buffer "${t}".`)();continue}let a=r.getAttributeNamesForBuffer(e),o=!1;for(let e of a){let t=this._attributeInfos[e];if(t){let e=this.device.type===`webgpu`?r.getBufferIndex(t.bufferName):t.location;this.vertexArray.setBuffer(e,i),o=!0}}!o&&!n&&Z.warn(`Model(${this.id}): Ignoring buffer "${i.id}" for unknown attribute "${t}"`)()}this.setNeedsRedraw(`attributes`)}setConstantAttributes(e,t){for(let[n,r]of Object.entries(e)){let e=this._attributeInfos[n];e?this.vertexArray.setConstantWebGL(e.location,r):(t?.disableWarnings??this.props.disableWarnings)||Z.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${n}"`)()}this.setNeedsRedraw(`constants`)}_areBindingsLoading(){for(let e of Object.values(this.bindings))if(e instanceof aD&&!e.isReady)return e.id;for(let e of Object.values(this.material?.bindings||{}))if(e instanceof aD&&!e.isReady)return e.id;return!1}_getBindings(){let e={};for(let[t,n]of Object.entries(this.bindings))n instanceof aD?n.isReady&&(e[t]=n.texture):e[t]=n;return e}_getBindGroups(){let e=this.pipeline?.shaderLayout||this.props.shaderLayout||{bindings:[]},t=e.bindings.length?ux(e,this._getBindings()):{0:this._getBindings()};if(!this.material)return t;for(let[e,n]of Object.entries(this.material.getBindingsByGroup())){let r=Number(e);t[r]={...t[r]||{},...n}}return t}_getBindGroupCacheKeys(){let e=this.material?.getBindGroupCacheKey(3);return e?{3:e}:{}}_getBindingsUpdateTimestamp(){let e=0;for(let t of Object.values(this.bindings))t instanceof qb?e=Math.max(e,t.texture.updateTimestamp):t instanceof ky||t instanceof Kb?e=Math.max(e,t.updateTimestamp):t instanceof aD?e=t.texture?Math.max(e,t.texture.updateTimestamp):1/0:t instanceof Wb||(e=Math.max(e,t.buffer.updateTimestamp));return Math.max(e,this.material?.getBindingsUpdateTimestamp()||0)}_setGeometryAttributes(e){let t={...e.attributes};for(let[e]of Object.entries(t))!this.pipeline.shaderLayout.attributes.find(t=>t.name===e)&&e!==`positions`&&delete t[e];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(t,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw(`geometry attributes`)}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||=e,this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,t=null;this.pipeline&&(Z.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,t=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let n=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:`vertex`,source:this.source||this.vs,debugShaders:this.props.debugShaders}),r=null;this.source?r=n:this.fs&&(r=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:`fragment`,source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bindings:void 0,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,bindGroups:this._getBindGroups(),vs:n,fs:r}),this._attributeInfos=Ox(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),t&&t!==e&&this.shaderFactory.release(t)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=Z.level>3?0:pD;Z.level<2||Date.now()-this._lastLogTime<e||(this._lastLogTime=Date.now(),this._logOpen=!0,Z.group(fD,`>>> DRAWING MODEL ${this.id}`,{collapsed:Z.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=gE(this.pipeline.shaderLayout,this.id);Z.table(fD,e)();let t=this.shaderInputs.getDebugTable();Z.table(fD,t)();let n=this._getAttributeDebugTable();Z.table(fD,this._attributeInfos)(),Z.table(fD,n)(),Z.groupEnd(fD)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){let t=this.device.props.debugFramebuffers;if(this._drawCount++,!t)return;let n=e.props.framebuffer;yE(e,n,{id:n?.id||`${this.id}-framebuffer`,minimap:!0})}_getAttributeDebugTable(){let e={};for(let[t,n]of Object.entries(this._attributeInfos)){let r=this.vertexArray.attributes[n.location];e[n.location]={name:t,type:n.shaderType,values:r?this._getBufferOrConstantValues(r,n.bufferDataType):`null`}}if(this.vertexArray.indexBuffer){let{indexBuffer:t}=this.vertexArray,n=t.indexType===`uint32`?new Uint32Array(t.debugData):new Uint16Array(t.debugData);e.indices={name:`indices`,type:t.indexType,values:n.toString()}}return e}_getBufferOrConstantValues(e,t){let n=Ay.getTypedArrayConstructor(t);return(e instanceof ky?new n(e.debugData):e).toString()}_getNonMaterialBindings(e){if(!this.material)return e;let t={};for(let[n,r]of Object.entries(e))this.material.ownsBinding(n)||(t[n]=r);return t}};function gD(e){return{type:e.type,shaderLanguage:e.info.shadingLanguage,shaderLanguageVersion:e.info.shadingLanguageVersion,gpu:e.info.gpu,features:e.features}}var _D=class e{device;model;transformFeedback;static defaultProps={...hD.defaultProps,outputs:void 0,feedbackBuffers:void 0};static isSupported(e){return e?.info?.type===`webgl`}constructor(t,n=e.defaultProps){if(!e.isSupported(t))throw Error(`BufferTransform not yet implemented on WebGPU`);this.device=t,this.model=new hD(this.device,{id:n.id||`buffer-transform-model`,fs:n.fs||p_(),topology:n.topology||`point-list`,varyings:n.outputs||n.varyings,...n}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:n.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback),Object.seal(this)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(e){e?.inputBuffers&&this.model.setAttributes(e.inputBuffers),e?.outputBuffers&&this.transformFeedback.setBuffers(e.outputBuffers);let t=this.device.beginRenderPass(e);this.model.draw(t),t.end()}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){let t=this.getBuffer(e);if(!t)throw Error(`BufferTransform#getBuffer`);if(t instanceof ky)return t.readAsync();let{buffer:n,byteOffset:r=0,byteLength:i=n.byteLength}=t;return n.readAsync(r,i)}},vD=class{id;topology;vertexCount;indices;attributes;userData={};constructor(e){let{attributes:t={},indices:n=null,vertexCount:r=null}=e;this.id=e.id||dE(`geometry`),this.topology=e.topology,n&&(this.indices=ArrayBuffer.isView(n)?{value:n,size:1}:n),this.attributes={};for(let[e,n]of Object.entries(t)){let t=ArrayBuffer.isView(n)?{value:n}:n;if(!ArrayBuffer.isView(t.value))throw Error(`${this._print(e)}: must be typed array or object with value as typed array`);if((e===`POSITION`||e===`positions`)&&!t.size&&(t.size=3),e===`indices`){if(this.indices)throw Error(`Multiple indices detected`);this.indices=t}else this.attributes[e]=t}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=r||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,t){return this}_calculateVertexCount(e,t){if(t)return t.value.length;let n=1/0;for(let t of Object.values(e)){let{value:e,size:r,constant:i}=t;!i&&e&&r!==void 0&&r>=1&&(n=Math.min(n,e.length/r))}return n}},yD={blendColorOperation:`add`,blendColorSrcFactor:`one`,blendColorDstFactor:`zero`,blendAlphaOperation:`add`,blendAlphaSrcFactor:`constant`,blendAlphaDstFactor:`zero`},bD=class extends wT{constructor(){super(...arguments),this._colorEncoderState=null}render(e){return`pickingFBO`in e?this._drawPickingBuffer(e):{decodePickingColor:null,stats:super._render(e)}}_drawPickingBuffer({layers:e,layerFilter:t,views:n,viewports:r,onViewportActive:i,pickingFBO:a,deviceRect:{x:o,y:s,width:c,height:l},cullRect:u,effects:d,pass:f=`picking`,pickZ:p,shaderModuleProps:m,clearColor:h}){this.pickZ=p;let g=this._resetColorEncoder(p),_=[o,s,c,l],v=super._render({target:a,layers:e,layerFilter:t,views:n,viewports:r,onViewportActive:i,cullRect:u,effects:d?.filter(e=>e.useInPicking),pass:f,isPicking:!0,shaderModuleProps:m,clearColor:h??[0,0,0,0],colorMask:15,scissorRect:_});return this._colorEncoderState=null,{decodePickingColor:g&&SD.bind(null,g),stats:v}}shouldDrawLayer(e){let{pickable:t,operation:n}=e.props;return t&&n.includes(`draw`)||n.includes(`terrain`)||n.includes(`mask`)}getShaderModuleProps(e,t,n){return{picking:{isActive:1,isAttribute:this.pickZ},lighting:{enabled:!1}}}getLayerParameters(e,t,n){let r={...e.props.parameters},{pickable:i,operation:a}=e.props;return this._colorEncoderState?i&&a.includes(`draw`)?(Object.assign(r,yD),r.blend=!0,this.device.type===`webgpu`?r.blendConstant=xD(this._colorEncoderState,e,n):r.blendColor=xD(this._colorEncoderState,e,n),a.includes(`terrain`)&&e.state?._hasPickingCover&&(r.blendAlphaSrcFactor=`one`)):a.includes(`terrain`)&&(r.blend=!1):r.blend=!1,r}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}};function xD(e,t,n){let{byLayer:r,byAlpha:i}=e,a,o=r.get(t);return o?(o.viewports.push(n),a=o.a):(a=r.size+1,a<=255?(o={a,layer:t,viewports:[n]},r.set(t,o),i[a]=o):(X.warn(`Too many pickable layers, only picking the first 255`)(),a=0)),[0,0,0,a/255]}function SD(e,t){let n=e.byAlpha[t[3]];return n&&{pickedLayer:n.layer,pickedViewports:n.viewports,pickedObjectIndex:n.layer.decodePickingColor(t)}}var CD={NO_STATE:`Awaiting state`,MATCHED:`Matched. State transferred from previous layer`,INITIALIZED:`Initialized`,AWAITING_GC:`Discarded. Awaiting garbage collection`,AWAITING_FINALIZATION:`No longer matched. Awaiting garbage collection`,FINALIZED:`Finalized! Awaiting garbage collection`},wD=Symbol.for(`component`),TD=Symbol.for(`propTypes`),ED=Symbol.for(`deprecatedProps`),DD=Symbol.for(`asyncPropDefaults`),OD=Symbol.for(`asyncPropOriginal`),kD=Symbol.for(`asyncPropResolved`);function AD(e,t=()=>!0){return Array.isArray(e)?jD(e,t,[]):t(e)?[e]:[]}function jD(e,t,n){let r=-1;for(;++r<e.length;){let i=e[r];Array.isArray(i)?jD(i,t,n):t(i)&&n.push(i)}return n}function MD({target:e,source:t,start:n=0,count:r=1}){let i=t.length,a=r*i,o=0;for(let r=n;o<i;o++)e[r++]=t[o];for(;o<a;)o<a-o?(e.copyWithin(n+o,n,n+o),o*=2):(e.copyWithin(n+o,n,n+a-o),o=a);return e}var ND=class{constructor(e,t,n){this._loadCount=0,this._subscribers=new Set,this.id=e,this.context=n,this.setData(t)}subscribe(e){this._subscribers.add(e)}unsubscribe(e){this._subscribers.delete(e)}inUse(){return this._subscribers.size>0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(e,t){if(e===this._data&&!t)return;this._data=e;let n=++this._loadCount,r=e;typeof e==`string`&&(r=Sm(e)),r instanceof Promise?(this.isLoaded=!1,this._loader=r.then(e=>{this._loadCount===n&&(this.isLoaded=!0,this._error=void 0,this._content=e)}).catch(e=>{this._loadCount===n&&(this.isLoaded=!0,this._error=e||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=e);for(let e of this._subscribers)e.onChange(this.getData())}},PD=class{constructor(e){this.protocol=e.protocol||`resource://`,this._context={device:e.device,gl:e.device?.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(e){return e.startsWith(this.protocol)?!0:e in this._resources}add({resourceId:e,data:t,forceUpdate:n=!1,persistent:r=!0}){let i=this._resources[e];i?i.setData(t,n):(i=new ND(e,t,this._context),this._resources[e]=i),i.persistent=r}remove(e){let t=this._resources[e];t&&(t.delete(),delete this._resources[e])}unsubscribe({consumerId:e}){let t=this._consumers[e];if(t){for(let e in t){let n=t[e],r=this._resources[n.resourceId];r&&r.unsubscribe(n)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:t,consumerId:n,requestId:r=`default`}){let{_resources:i,protocol:a}=this;e.startsWith(a)&&(e=e.replace(a,``),i[e]||this.add({resourceId:e,data:null,persistent:!1}));let o=i[e];if(this._track(n,r,o,t),o)return o.getData()}prune(){this._pruneRequest||=setTimeout(()=>this._prune(),0)}finalize(){for(let e in this._resources)this._resources[e].delete()}_track(e,t,n,r){let i=this._consumers,a=i[e]=i[e]||{},o=a[t],s=o&&o.resourceId&&this._resources[o.resourceId];s&&(s.unsubscribe(o),this.prune()),n&&(o?(o.onChange=r,o.resourceId=n.id):o={onChange:r,resourceId:n.id},a[t]=o,n.subscribe(o))}_prune(){this._pruneRequest=null;for(let e of Object.keys(this._resources)){let t=this._resources[e];!t.persistent&&!t.inUse()&&(t.delete(),delete this._resources[e])}}},FD=`layerManager.setLayers`,ID=`layerManager.activateViewport`,LD=class{constructor(e,t){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=e=>{dh(ID,this,e),e&&(this.context.viewport=e)};let{deck:n,stats:r,viewport:i,timeline:a}=t||{};this.layers=[],this.resourceManager=new PD({device:e,protocol:`deck://`}),this.context={mousePosition:null,userData:{},layerManager:this,device:e,gl:e?.gl,deck:n,shaderAssembler:fT(e?.info?.shadingLanguage||`glsl`),defaultShaderModules:[vS],renderPass:void 0,stats:r||new Ff({id:`deck.gl`}),viewport:i||new YT({id:`DEFAULT-INITIAL-VIEWPORT`}),timeline:a||new iE,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(let e of this.layers)this._finalizeLayer(e)}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);for(let n of this.layers){let r=n.getNeedsRedraw(e);t||=r}return t}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?`layers changed`:this._defaultShaderModulesChanged?`shader modules changed`:this._needsUpdate}setNeedsRedraw(e){this._needsRedraw=this._needsRedraw||e}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e}getLayers({layerIds:e}={}){return e?this.layers.filter(t=>e.find(e=>t.id.indexOf(e)===0)):this.layers}setProps(e){`debug`in e&&(this._debug=e.debug),`userData`in e&&(this.context.userData=e.userData),`layers`in e&&(this._nextLayers=e.layers),`onError`in e&&(this.context.onError=e.onError)}setLayers(e,t){dh(FD,this,t,e),this._lastRenderedLayers=e;let n=AD(e,Boolean);for(let e of n)e.context=this.context;this._updateLayers(this.layers,n)}updateLayers(){let e=this.needsUpdate();e&&(this.setNeedsRedraw(`updating layers: ${e}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,e)),this._nextLayers=null}addDefaultShaderModule(e){let{defaultShaderModules:t}=this.context;t.find(t=>t.name===e.name)||(t.push(e),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(e){let{defaultShaderModules:t}=this.context,n=t.findIndex(t=>t.name===e.name);n>=0&&(t.splice(n,1),this._defaultShaderModulesChanged=!0)}_handleError(e,t,n){n.raiseError(t,`${e} of ${n}`)}_updateLayers(e,t){let n={};for(let t of e)n[t.id]?X.warn(`Multiple old layers with same id ${t.id}`)():n[t.id]=t;if(this._defaultShaderModulesChanged){for(let t of e)t.setNeedsUpdate(),t.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}let r=[];this._updateSublayersRecursively(t,n,r),this._finalizeOldLayers(n);let i=!1;for(let e of r)if(e.hasUniformTransition()){i=`Uniform transition in ${e}`;break}this._needsUpdate=i,this.layers=r}_updateSublayersRecursively(e,t,n){for(let r of e){r.context=this.context;let e=t[r.id];e===null&&X.warn(`Multiple new layers with same id ${r.id}`)(),t[r.id]=null;let i=null;try{this._debug&&e!==r&&r.validateProps(),e?(this._transferLayerState(e,r),this._updateLayer(r)):this._initializeLayer(r),n.push(r),i=r.isComposite?r.getSubLayers():null}catch(e){this._handleError(`matching`,e,r)}i&&this._updateSublayersRecursively(i,t,n)}}_finalizeOldLayers(e){for(let t in e){let n=e[t];n&&this._finalizeLayer(n)}}_initializeLayer(e){try{e._initialize(),e.lifecycle=CD.INITIALIZED}catch(t){this._handleError(`initialization`,t,e)}}_transferLayerState(e,t){t._transferState(e),t.lifecycle=CD.MATCHED,t!==e&&(e.lifecycle=CD.AWAITING_GC)}_updateLayer(e){try{e._update()}catch(t){this._handleError(`update`,t,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||`finalized ${e}`,e.lifecycle=CD.AWAITING_FINALIZATION;try{e._finalize(),e.lifecycle=CD.FINALIZED}catch(t){this._handleError(`finalization`,t,e)}}};function RD(e,t,n){if(e===t)return!0;if(!n||!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!RD(e[r],t[r],n-1))return!1;return!0}if(Array.isArray(t))return!1;if(typeof e==`object`&&typeof t==`object`){let r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;for(let i of r)if(!t.hasOwnProperty(i)||!RD(e[i],t[i],n-1))return!1;return!0}return!1}var zD=class{constructor(e){this.views=[],this.width=100,this.height=100,this.viewState={},this.controllers={},this.timeline=e.timeline,this._viewports=[],this._viewportMap={},this._isUpdating=!1,this._needsRedraw=`First render`,this._needsUpdate=`Initialize`,this._eventManager=e.eventManager,this._eventCallbacks={onViewStateChange:e.onViewStateChange,onInteractionStateChange:e.onInteractionStateChange},this._pickPosition=e.pickPosition,Object.seal(this),this.setProps(e)}finalize(){for(let e in this.controllers){let t=this.controllers[e];t&&t.finalize()}this.controllers={}}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e,this._needsRedraw=this._needsRedraw||e}updateViewStates(){for(let e in this.controllers){let t=this.controllers[e];t&&t.updateTransition()}}getViewports(e){return e?this._viewports.filter(t=>t.containsPixel(e)):this._viewports}getViews(){let e={};return this.views.forEach(t=>{e[t.id]=t}),e}getView(e){return this.views.find(t=>t.id===e)}getViewState(e){let t=typeof e==`string`?this.getView(e):e,n=t&&this.viewState[t.getViewStateId()]||this.viewState;return t?t.filterViewState(n):n}getViewport(e){return this._viewportMap[e]}unproject(e,t){let n=this.getViewports(),r={x:e[0],y:e[1]};for(let i=n.length-1;i>=0;--i){let a=n[i];if(a.containsPixel(r)){let n=e.slice();return n[0]-=a.x,n[1]-=a.y,a.unproject(n,t)}}return null}setProps(e){e.views&&this._setViews(e.views),e.viewState&&this._setViewState(e.viewState),(`width`in e||`height`in e)&&this._setSize(e.width,e.height),`pickPosition`in e&&(this._pickPosition=e.pickPosition),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(e,t){(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.setNeedsUpdate(`Size changed`))}_setViews(e){e=AD(e,Boolean),this._diffViews(e,this.views)&&this.setNeedsUpdate(`views changed`),this.views=e}_setViewState(e){e?(RD(e,this.viewState,3)||this.setNeedsUpdate(`viewState changed`),this.viewState=e):X.warn("missing `viewState` or `initialViewState`")()}_createController(e,t){let n=t.type;return new n({timeline:this.timeline,eventManager:this._eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:t=>this.getView(e.id)?.makeViewport({viewState:t,width:this.width,height:this.height}),pickPosition:this._pickPosition})}_updateController(e,t,n,r){let i=e.controller;if(i&&n){let a={...t,...i,id:e.id,x:n.x,y:n.y,width:n.width,height:n.height};return(!r||r.constructor!==i.type)&&(r=this._createController(e,a)),r&&r.setProps(a),r}return null}_rebuildViewports(){let{views:e}=this,t=this.controllers;this._viewports=[],this.controllers={};let n=!1;for(let r=e.length;r--;){let i=e[r],a=this.getViewState(i),o=i.makeViewport({viewState:a,width:this.width,height:this.height}),s=t[i.id],c=!!i.controller;c&&!s&&(n=!0),(n||!c)&&s&&(s.finalize(),s=null),this.controllers[i.id]=this._updateController(i,a,o,s),o&&this._viewports.unshift(o)}for(let e in t){let n=t[e];n&&!this.controllers[e]&&n.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(e=>{e.id&&(this._viewportMap[e.id]=this._viewportMap[e.id]||e)})}_diffViews(e,t){return e.length===t.length?e.some((n,r)=>!e[r].equals(t[r])):!0}},BD=/^(?:\d+\.?\d*|\.\d+)$/;function VD(e){switch(typeof e){case`number`:if(!Number.isFinite(e))throw Error(`Could not parse position string ${e}`);return{type:`literal`,value:e};case`string`:try{return new GD(WD(e)).parseExpression()}catch(t){let n=t instanceof Error?t.message:String(t);throw Error(`Could not parse position string ${e}: ${n}`)}default:throw Error(`Could not parse position string ${e}`)}}function HD(e,t){switch(e.type){case`literal`:return e.value;case`percentage`:return Math.round(e.value*t);case`binary`:let n=HD(e.left,t),r=HD(e.right,t);return e.operator===`+`?n+r:n-r;default:throw Error(`Unknown layout expression type`)}}function UD(e,t){return HD(e,t)}function WD(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(/\s/.test(r)){n++;continue}if(r===`+`||r===`-`||r===`(`||r===`)`||r===`%`){t.push({type:`symbol`,value:r}),n++;continue}if(KD(r)||r===`.`){let i=n,a=r===`.`;for(n++;n<e.length;){let t=e[n];if(KD(t)){n++;continue}if(t===`.`&&!a){a=!0,n++;continue}break}let o=e.slice(i,n);if(!BD.test(o))throw Error(`Invalid number token`);t.push({type:`number`,value:parseFloat(o)});continue}if(qD(r)){let r=n;for(;n<e.length&&qD(e[n]);)n++;let i=e.slice(r,n).toLowerCase();t.push({type:`word`,value:i});continue}throw Error(`Invalid token in position string`)}return t}var GD=class{constructor(e){this.index=0,this.tokens=e}parseExpression(){let e=this.parseBinaryExpression();if(this.index<this.tokens.length)throw Error(`Unexpected token at end of expression`);return e}parseBinaryExpression(){let e=this.parseFactor(),t=this.peek();for(;JD(t);){this.index++;let n=this.parseFactor();e={type:`binary`,operator:t.value,left:e,right:n},t=this.peek()}return e}parseFactor(){let e=this.peek();if(!e)throw Error(`Unexpected end of expression`);if(e.type===`symbol`&&e.value===`+`)return this.index++,this.parseFactor();if(e.type===`symbol`&&e.value===`-`)return this.index++,{type:`binary`,operator:`-`,left:{type:`literal`,value:0},right:this.parseFactor()};if(e.type===`symbol`&&e.value===`(`){this.index++;let e=this.parseBinaryExpression();if(!this.consumeSymbol(`)`))throw Error(`Missing closing parenthesis`);return e}if(e.type===`word`&&e.value===`calc`){if(this.index++,!this.consumeSymbol(`(`))throw Error(`Missing opening parenthesis after calc`);let e=this.parseBinaryExpression();if(!this.consumeSymbol(`)`))throw Error(`Missing closing parenthesis`);return e}if(e.type===`number`){this.index++;let t=e.value,n=this.peek();return n&&n.type===`symbol`&&n.value===`%`?(this.index++,{type:`percentage`,value:t/100}):(n&&n.type===`word`&&n.value===`px`&&this.index++,{type:`literal`,value:t})}throw Error(`Unexpected token in expression`)}consumeSymbol(e){let t=this.peek();return t&&t.type===`symbol`&&t.value===e?(this.index++,!0):!1}peek(){return this.tokens[this.index]||null}};function KD(e){return e>=`0`&&e<=`9`}function qD(e){return e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`}function JD(e){return!!(e&&e.type===`symbol`&&(e.value===`+`||e.value===`-`))}function YD(e,t){let n={...e};for(let e in t)e!==`id`&&(Array.isArray(n[e])&&Array.isArray(t[e])?n[e]=XD(n[e],t[e]):n[e]=t[e]);return n}function XD(e,t){e=e.slice();for(let n=0;n<t.length;n++){let r=t[n];Number.isFinite(r)&&(e[n]=r)}return e}var ZD=class{constructor(e){let{id:t,x:n=0,y:r=0,width:i=`100%`,height:a=`100%`,padding:o=null}=e;this.id=t||this.constructor.displayName||`view`,this.props={...e,id:this.id},this._x=VD(n),this._y=VD(r),this._width=VD(i),this._height=VD(a),this._padding=o&&{left:VD(o.left||0),right:VD(o.right||0),top:VD(o.top||0),bottom:VD(o.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(e){return this===e?!0:this.constructor===e.constructor&&RD(this.props,e.props,2)}clone(e){let t=this.constructor;return new t({...this.props,...e})}makeViewport({width:e,height:t,viewState:n}){n=this.filterViewState(n);let r=this.getDimensions({width:e,height:t});return!r.height||!r.width?null:new(this.getViewportType(n))({...n,...this.props,...r})}getViewStateId(){let{viewState:e}=this.props;return typeof e==`string`?e:e?.id||this.id}filterViewState(e){return this.props.viewState&&typeof this.props.viewState==`object`?this.props.viewState.id?YD(e,this.props.viewState):this.props.viewState:e}getDimensions({width:e,height:t}){let n={x:UD(this._x,e),y:UD(this._y,t),width:UD(this._width,e),height:UD(this._height,t)};return this._padding&&(n.padding={left:UD(this._padding.left,e),top:UD(this._padding.top,t),right:UD(this._padding.right,e),bottom:UD(this._padding.bottom,t)}),n}get controller(){let e=this.props.controller;return e?e===!0?{type:this.ControllerType}:typeof e==`function`?{type:e}:{type:this.ControllerType,...e}:null}},QD=class{constructor(e){this._inProgress=!1,this._handle=null,this.time=0,this.settings={duration:0},this._timeline=e}get inProgress(){return this._inProgress}start(e){this.cancel(),this.settings=e,this._inProgress=!0,this.settings.onStart?.(this)}end(){this._inProgress&&(this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1,this.settings.onEnd?.(this))}cancel(){this._inProgress&&=(this.settings.onInterrupt?.(this),this._timeline.removeChannel(this._handle),this._handle=null,!1)}update(){if(!this._inProgress)return!1;if(this._handle===null){let{_timeline:e,settings:t}=this;this._handle=e.addChannel({delay:e.getTime(),duration:t.duration})}return this.time=this._timeline.getTime(this._handle),this._onUpdate(),this.settings.onUpdate?.(this),this._timeline.isFinished(this._handle)&&this.end(),!0}_onUpdate(){}},$D=()=>{},eO={BREAK:1,SNAP_TO_END:2,IGNORE:3},tO=e=>e,nO=eO.BREAK,rO=class{constructor(e){this._onTransitionUpdate=e=>{let{time:t,settings:{interpolator:n,startProps:r,endProps:i,duration:a,easing:o}}=e,s=o(t/a),c=n.interpolateProps(r,i,s);this.propsInTransition=this.getControllerState({...this.props,...c}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new QD(e.timeline),this.onViewStateChange=e.onViewStateChange||$D,this.onStateChange=e.onStateChange||$D}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(e){let t=!1,n=this.props;if(this.props=e,!n||this._shouldIgnoreViewportChange(n,e))return!1;if(this._isTransitionEnabled(e)){let r=n;if(this.transition.inProgress){let{interruption:e,endProps:t}=this.transition.settings;r={...n,...e===eO.SNAP_TO_END?t:this.propsInTransition||n}}this._triggerTransition(r,e),t=!0}else this.transition.cancel();return t}updateTransition(){this.transition.update()}_isTransitionEnabled(e){let{transitionDuration:t,transitionInterpolator:n}=e;return(t>0||t===`auto`)&&!!n}_isUpdateDueToCurrentTransition(e){return this.transition.inProgress&&this.propsInTransition?this.transition.settings.interpolator.arePropsEqual(e,this.propsInTransition):!1}_shouldIgnoreViewportChange(e,t){return this.transition.inProgress?this.transition.settings.interruption===eO.IGNORE||this._isUpdateDueToCurrentTransition(t):this._isTransitionEnabled(t)?t.transitionInterpolator.arePropsEqual(e,t):!0}_triggerTransition(e,t){let n=this.getControllerState(e),r=this.getControllerState(t).shortestPathFrom(n),i=t.transitionInterpolator,a=i.getDuration?i.getDuration(e,t):t.transitionDuration;if(a===0)return;let o=i.initializeProps(e,r);this.propsInTransition={};let s={duration:a,easing:t.transitionEasing||tO,interpolator:i,interruption:t.transitionInterruption||nO,startProps:o.start,endProps:o.end,onStart:t.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(t.onTransitionInterrupt),onEnd:this._onTransitionEnd(t.onTransitionEnd)};this.transition.start(s),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(e){return t=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),e?.(t)}}};function iO(e,t){if(!e)throw Error(t||`deck.gl: assertion failed.`)}var aO=class{constructor(e){let{compare:t,extract:n,required:r}=e;this._propsToCompare=t,this._propsToExtract=n||t,this._requiredProps=r}arePropsEqual(e,t){for(let n of this._propsToCompare)if(!(n in e)||!(n in t)||!x_(e[n],t[n]))return!1;return!0}initializeProps(e,t){let n={},r={};for(let i of this._propsToExtract)(i in e||i in t)&&(n[i]=e[i],r[i]=t[i]);return this._checkRequiredProps(n),this._checkRequiredProps(r),{start:n,end:r}}getDuration(e,t){return t.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(t=>{let n=e[t];iO(Number.isFinite(n)||Array.isArray(n),`${t} is required for transition`)})}},oO=Math.PI/180,sO=180/Math.PI,cO=6370972;function lO(){let e=256/cO,t=Math.PI/180*256;return{unitsPerMeter:[e,e,e],unitsPerMeter2:[0,0,0],metersPerUnit:[1/e,1/e,1/e],unitsPerDegree:[t,t,e],unitsPerDegree2:[0,0,0],degreesPerUnit:[1/t,1/t,1/e]}}var uO=class extends YT{constructor(e={}){let{longitude:t=0,zoom:n=0,bearing:r=0,pitch:i=0,nearZMultiplier:a=.5,farZMultiplier:o=1,resolution:s=10}=e,{latitude:c=0,height:l,altitude:u=1.5,fovy:d}=e;c=Math.max(Math.min(c,kw),-kw),l||=1,d?u=Vw(d):d=Bw(u);let f=2**(n-dO(c)),p=e.nearZ??a,m=e.farZ??(u+256*2*f/l)*o,h=r*oO,g=i*oO,_=Math.sin(h),v=Math.cos(h),y=Math.sin(g),b=Math.cos(g),x=new zv().lookAt({eye:[-_*y*u,-b*u,-v*y*u],up:[_*b,-y,v*b]});x.rotateX(c*oO),x.rotateZ(-t*oO),x.scale(f/l),super({...e,height:l,viewMatrix:x,longitude:t,latitude:c,zoom:n,distanceScales:lO(),fovy:d,focalDistance:u,near:p,far:m}),this.scale=f,this.latitude=c,this.longitude=t,this.fovy=d,this.resolution=s}get projectionMode(){return qC.GLOBE}getDistanceScales(){return this.distanceScales}getBounds(e={}){let t={targetZ:e.z||0},n=this.unproject([0,this.height/2],t),r=this.unproject([this.width/2,0],t),i=this.unproject([this.width,this.height/2],t),a=this.unproject([this.width/2,this.height],t);return i[0]<this.longitude&&(i[0]+=360),n[0]>this.longitude&&(n[0]-=360),[Math.min(n[0],i[0],r[0],a[0]),Math.min(n[1],i[1],r[1],a[1]),Math.max(n[0],i[0],r[0],a[0]),Math.max(n[1],i[1],r[1],a[1])]}unproject(e,{topLeft:t=!0,targetZ:n}={}){let[r,i,a]=e,o=t?i:this.height-i,{pixelUnprojectionMatrix:s}=this,c;if(Number.isFinite(a))c=fO(s,[r,o,a,1]);else{let e=fO(s,[r,o,-1,1]),t=fO(s,[r,o,1,1]),i=((n||0)/cO+1)*256,a=sv(iv([],e,t)),l=sv(e),u=sv(t),d=4*((4*l*u-(a-l-u)**2)/16)/a;c=X_([],e,t,(Math.sqrt(l-d)-Math.sqrt(Math.max(0,i*i-d)))/Math.sqrt(a))}let[l,u,d]=this.unprojectPosition(c);return Number.isFinite(a)?[l,u,d]:Number.isFinite(n)?[l,u,n]:[l,u]}projectPosition(e){let[t,n,r=0]=e,i=t*oO,a=n*oO,o=Math.cos(a),s=(r/cO+1)*256;return[Math.sin(i)*o*s,-Math.cos(i)*o*s,Math.sin(a)*s]}unprojectPosition(e){let[t,n,r]=e,i=ov(e),a=Math.asin(r/i);return[Math.atan2(t,-n)*sO,a*sO,(i/256-1)*cO]}projectFlat(e){return e}unprojectFlat(e){return e}panByPosition([e,t,n],r,i){let a=.25/2**(this.zoom-dO(this.latitude)),o=e+a*(i[0]-r[0]),s=t-a*(i[1]-r[1]);s=Math.max(Math.min(s,kw),-kw);let c={longitude:o,latitude:s,zoom:n-dO(t)};return c.zoom+=dO(c.latitude),c}};uO.displayName=`GlobeViewport`;function dO(e){let t=Math.PI*Math.cos(e*Math.PI/180);return Math.log2(t)}function fO(e,t){let n=Mv([],t,e);return jv(n,n,1/n[3]),n}var pO=[`longitude`,`latitude`,`zoom`,`bearing`,`pitch`],mO=[`longitude`,`latitude`,`zoom`],hO=class extends aO{constructor(e={}){let t=Array.isArray(e)?e:e.transitionProps,n=Array.isArray(e)?{}:e;n.transitionProps=Array.isArray(t)?{compare:t,required:t}:t||{compare:pO,required:mO},super(n.transitionProps),this.opts=n}initializeProps(e,t){let n=super.initializeProps(e,t),{makeViewport:r,around:i}=this.opts;if(r&&i)if(r(e)instanceof uO)X.warn(`around not supported in GlobeView`)();else{let a=r(e),o=r(t),s=a.unproject(i);n.start.around=i,Object.assign(n.end,{around:o.project(s),aroundPosition:s,width:t.width,height:t.height})}return n}interpolateProps(e,t,n){let r={};for(let i of this._propsToExtract)r[i]=b_(e[i]||0,t[i]||0,n);if(t.aroundPosition&&this.opts.makeViewport){let i=this.opts.makeViewport({...t,...r});Object.assign(r,i.panByPosition(t.aroundPosition,b_(e.around,t.around,n)))}return r}},gO={transitionDuration:0},_O=300,vO=e=>1-(1-e)*(1-e),yO={WHEEL:[`wheel`],PAN:[`panstart`,`panmove`,`panend`],PINCH:[`pinchstart`,`pinchmove`,`pinchend`],MULTI_PAN:[`multipanstart`,`multipanmove`,`multipanend`],DOUBLE_CLICK:[`dblclick`],KEYBOARD:[`keydown`]},bO={},xO=class{constructor(e){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this.invertPan=!1,this.dragMode=`rotate`,this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.keyboard=!0,this.transitionManager=new rO({...e,getControllerState:e=>new this.ControllerState(e),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=e.eventManager,this.onViewStateChange=e.onViewStateChange||(()=>{}),this.onStateChange=e.onStateChange||(()=>{}),this.makeViewport=e.makeViewport,this.pickPosition=e.pickPosition}set events(e){this.toggleEvents(this._customEvents,!1),this.toggleEvents(e,!0),this._customEvents=e,this.props&&this.setProps(this.props)}finalize(){for(let e in this._events)this._events[e]&&this.eventManager?.off(e,this.handleEvent);this.transitionManager.finalize()}handleEvent(e){this._controllerState=void 0;let t=this._eventStartBlocked;switch(e.type){case`panstart`:return t?!1:this._onPanStart(e);case`panmove`:return this._onPan(e);case`panend`:return this._onPanEnd(e);case`pinchstart`:return t?!1:this._onPinchStart(e);case`pinchmove`:return this._onPinch(e);case`pinchend`:return this._onPinchEnd(e);case`multipanstart`:return t?!1:this._onMultiPanStart(e);case`multipanmove`:return this._onMultiPan(e);case`multipanend`:return this._onMultiPanEnd(e);case`dblclick`:return this._onDoubleClick(e);case`wheel`:return this._onWheel(e);case`keydown`:return this._onKeyDown(e);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(e){let{x:t,y:n}=this.props,{offsetCenter:r}=e;return[r.x-t,r.y-n]}isPointInBounds(e,t){let{width:n,height:r}=this.props;if(t&&t.handled)return!1;let i=e[0]>=0&&e[0]<=n&&e[1]>=0&&e[1]<=r;return i&&t&&t.stopPropagation(),i}isFunctionKeyPressed(e){let{srcEvent:t}=e;return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(e){let t=setTimeout(()=>{this._eventStartBlocked===t&&(this._eventStartBlocked=null)},e);this._eventStartBlocked=t}setProps(e){e.dragMode&&(this.dragMode=e.dragMode);let t=this.props;this.props=e,`transitionInterpolator`in e||(e.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(e);let{inertia:n}=e;this.inertia=Number.isFinite(n)?n:n===!0?_O:0;let{scrollZoom:r=!0,dragPan:i=!0,dragRotate:a=!0,doubleClickZoom:o=!0,touchZoom:s=!0,touchRotate:c=!1,keyboard:l=!0}=e,u=!!this.onViewStateChange;if(this.toggleEvents(yO.WHEEL,u&&r),this.toggleEvents(yO.PAN,u),this.toggleEvents(yO.PINCH,u&&(s||c)),this.toggleEvents(yO.MULTI_PAN,u&&c),this.toggleEvents(yO.DOUBLE_CLICK,u&&o),this.toggleEvents(yO.KEYBOARD,u&&l),this.scrollZoom=r,this.dragPan=i,this.dragRotate=a,this.doubleClickZoom=o,this.touchZoom=s,this.touchRotate=c,this.keyboard=l,(!t||t.height!==e.height||t.width!==e.width||t.maxBounds!==e.maxBounds)&&e.maxBounds){let t=new this.ControllerState({...e,makeViewport:this.makeViewport}),n=t.getViewportProps();Object.keys(n).some(t=>!RD(n[t],e[t],1))&&this.updateViewport(t)}}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(e,t){this.eventManager&&e.forEach(e=>{this._events[e]!==t&&(this._events[e]=t,t?this.eventManager.on(e,this.handleEvent):this.eventManager.off(e,this.handleEvent))})}updateViewport(e,t=null,n={}){let r={...e.getViewportProps(),...t},i=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(n),i){let e=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:r,interactionState:this._interactionState,oldViewState:e,viewId:this.props.id})}}_onTransition(e){this.onViewStateChange({...e,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(e){Object.assign(this._interactionState,e),this.onStateChange(this._interactionState)}_onPanStart(e){let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let n=this.isFunctionKeyPressed(e)||e.rightButton||!1;(this.invertPan||this.dragMode===`pan`)&&(n=!n);let r=this.controllerState[n?`panStart`:`rotateStart`]({pos:t});return this._panMove=n,this.updateViewport(r,gO,{isDragging:!0}),!0}_onPan(e){return this.isDragging()?this._panMove?this._onPanMove(e):this._onPanRotate(e):!1}_onPanEnd(e){return this.isDragging()?this._panMove?this._onPanMoveEnd(e):this._onPanRotateEnd(e):!1}_onPanMove(e){if(!this.dragPan)return!1;let t=this.getCenter(e),n=this.controllerState.pan({pos:t});return this.updateViewport(n,gO,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){let{inertia:t}=this;if(this.dragPan&&t&&e.velocity){let n=this.getCenter(e),r=[n[0]+e.velocityX*t/2,n[1]+e.velocityY*t/2],i=this.controllerState.pan({pos:r}).panEnd();this.updateViewport(i,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:vO},{isDragging:!1,isPanning:!0})}else{let e=this.controllerState.panEnd();this.updateViewport(e,null,{isDragging:!1,isPanning:!1})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;let t=this.getCenter(e),n=this.controllerState.rotate({pos:t});return this.updateViewport(n,gO,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){let{inertia:t}=this;if(this.dragRotate&&t&&e.velocity){let n=this.getCenter(e),r=[n[0]+e.velocityX*t/2,n[1]+e.velocityY*t/2],i=this.controllerState.rotate({pos:r}).rotateEnd();this.updateViewport(i,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:vO},{isDragging:!1,isRotating:!0})}else{let e=this.controllerState.rotateEnd();this.updateViewport(e,null,{isDragging:!1,isRotating:!1})}return!0}_onWheel(e){if(!this.scrollZoom)return!1;let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;e.srcEvent.preventDefault();let{speed:n=.01,smooth:r=!1}=this.scrollZoom===!0?{}:this.scrollZoom,{delta:i}=e,a=2/(1+Math.exp(-Math.abs(i*n)));i<0&&a!==0&&(a=1/a);let o=r?{...this._getTransitionProps({around:t}),transitionDuration:250}:gO,s=this.controllerState.zoom({pos:t,scale:a});return this.updateViewport(s,o,{isZooming:!0,isPanning:!0}),r||this._setInteractionState({isZooming:!1,isPanning:!1}),!0}_onMultiPanStart(e){let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let n=this.controllerState.rotateStart({pos:t});return this.updateViewport(n,gO,{isDragging:!0}),!0}_onMultiPan(e){if(!this.touchRotate||!this.isDragging())return!1;let t=this.getCenter(e);t[0]-=e.deltaX;let n=this.controllerState.rotate({pos:t});return this.updateViewport(n,gO,{isDragging:!0,isRotating:!0}),!0}_onMultiPanEnd(e){if(!this.isDragging())return!1;let{inertia:t}=this;if(this.touchRotate&&t&&e.velocityY){let n=this.getCenter(e),r=[n[0],n[1]+=e.velocityY*t/2],i=this.controllerState.rotate({pos:r});this.updateViewport(i,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:vO},{isDragging:!1,isRotating:!0}),this.blockEvents(t)}else{let e=this.controllerState.rotateEnd();this.updateViewport(e,null,{isDragging:!1,isRotating:!1})}return!0}_onPinchStart(e){let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let n=this.controllerState.zoomStart({pos:t}).rotateStart({pos:t});return bO._startPinchRotation=e.rotation,bO._lastPinchEvent=e,this.updateViewport(n,gO,{isDragging:!0}),!0}_onPinch(e){if(!this.touchZoom&&!this.touchRotate||!this.isDragging())return!1;let t=this.controllerState;if(this.touchZoom){let{scale:n}=e,r=this.getCenter(e);t=t.zoom({pos:r,scale:n})}if(this.touchRotate){let{rotation:n}=e;t=t.rotate({deltaAngleX:bO._startPinchRotation-n})}return this.updateViewport(t,gO,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),bO._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;let{inertia:t}=this,{_lastPinchEvent:n}=bO;if(this.touchZoom&&t&&n&&e.scale!==n.scale){let r=this.getCenter(e),i=this.controllerState.rotateEnd(),a=Math.log2(e.scale),o=2**(a+(a-Math.log2(n.scale))/(e.deltaTime-n.deltaTime)*t/2);i=i.zoom({pos:r,scale:o}).zoomEnd(),this.updateViewport(i,{...this._getTransitionProps({around:r}),transitionDuration:t,transitionEasing:vO},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(t)}else{let e=this.controllerState.zoomEnd().rotateEnd();this.updateViewport(e,null,{isDragging:!1,isPanning:!1,isZooming:!1,isRotating:!1})}return bO._startPinchRotation=null,bO._lastPinchEvent=null,!0}_onDoubleClick(e){if(!this.doubleClickZoom)return!1;let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let n=this.isFunctionKeyPressed(e),r=this.controllerState.zoom({pos:t,scale:n?.5:2});return this.updateViewport(r,this._getTransitionProps({around:t}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onKeyDown(e){if(!this.keyboard)return!1;let t=this.isFunctionKeyPressed(e),{zoomSpeed:n,moveSpeed:r,rotateSpeedX:i,rotateSpeedY:a}=this.keyboard===!0?{}:this.keyboard,{controllerState:o}=this,s,c={};switch(e.srcEvent.code){case`Minus`:s=t?o.zoomOut(n).zoomOut(n):o.zoomOut(n),c.isZooming=!0;break;case`Equal`:s=t?o.zoomIn(n).zoomIn(n):o.zoomIn(n),c.isZooming=!0;break;case`ArrowLeft`:t?(s=o.rotateLeft(i),c.isRotating=!0):(s=o.moveLeft(r),c.isPanning=!0);break;case`ArrowRight`:t?(s=o.rotateRight(i),c.isRotating=!0):(s=o.moveRight(r),c.isPanning=!0);break;case`ArrowUp`:t?(s=o.rotateUp(a),c.isRotating=!0):(s=o.moveUp(r),c.isPanning=!0);break;case`ArrowDown`:t?(s=o.rotateDown(a),c.isRotating=!0):(s=o.moveDown(r),c.isPanning=!0);break;default:return!1}return this.updateViewport(s,this._getTransitionProps(),c),!0}_getTransitionProps(e){let{transition:t}=this;return!t||!t.transitionInterpolator?gO:e?{...t,transitionInterpolator:new hO({...e,...t.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:t}},SO=class{constructor(e,t,n){this.makeViewport=n,this._viewportProps=this.applyConstraints(e),this._state=t}getViewportProps(){return this._viewportProps}getState(){return this._state}},CO=5,wO=1.2,TO=512,EO=[[-1/0,-90],[1/0,90]];function DO([e,t]){if(Math.abs(t)>90&&(t=Math.sign(t)*90),Number.isFinite(e)){let[n,r]=Mw([e,t]);return[n,y_(r,0,TO)]}let[,n]=Mw([0,t]);return[e,y_(n,0,TO)]}var OO=class extends SO{constructor(e){let{width:t,height:n,latitude:r,longitude:i,zoom:a,bearing:o=0,pitch:s=0,altitude:c=1.5,position:l=[0,0,0],maxZoom:u=20,minZoom:d=0,maxPitch:f=60,minPitch:p=0,startPanLngLat:m,startZoomLngLat:h,startRotatePos:g,startRotateLngLat:_,startBearing:v,startPitch:y,startZoom:b,normalize:x=!0}=e;iO(Number.isFinite(i)),iO(Number.isFinite(r)),iO(Number.isFinite(a));let S=e.maxBounds||(x?EO:null);super({width:t,height:n,latitude:r,longitude:i,zoom:a,bearing:o,pitch:s,altitude:c,maxZoom:u,minZoom:d,maxPitch:f,minPitch:p,normalize:x,position:l,maxBounds:S},{startPanLngLat:m,startZoomLngLat:h,startRotatePos:g,startRotateLngLat:_,startBearing:v,startPitch:y,startZoom:b},e.makeViewport),this.getAltitude=e.getAltitude}panStart({pos:e}){return this._getUpdatedState({startPanLngLat:this._unproject(e)})}pan({pos:e,startPos:t}){let n=this.getState().startPanLngLat||this._unproject(t);if(!n)return this;let r=this.makeViewport(this.getViewportProps()).panByPosition(n,e);return this._getUpdatedState(r)}panEnd(){return this._getUpdatedState({startPanLngLat:null})}rotateStart({pos:e}){let t=this.getAltitude?.(e);return this._getUpdatedState({startRotatePos:e,startRotateLngLat:t===void 0?void 0:this._unproject3D(e,t),startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:t=0,deltaAngleY:n=0}){let{startRotatePos:r,startRotateLngLat:i,startBearing:a,startPitch:o}=this.getState();if(!r||a===void 0||o===void 0)return this;let s;if(s=e?this._getNewRotation(e,r,o,a):{bearing:a+t,pitch:o+n},i){let e=this.makeViewport({...this.getViewportProps(),...s}),t=`panByPosition3D`in e?`panByPosition3D`:`panByPosition`;return this._getUpdatedState({...s,...e[t](i,r)})}return this._getUpdatedState(s)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startRotateLngLat:null,startBearing:null,startPitch:null})}zoomStart({pos:e}){return this._getUpdatedState({startZoomLngLat:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:t,scale:n}){let{startZoom:r,startZoomLngLat:i}=this.getState();if(i||=(r=this.getViewportProps().zoom,this._unproject(t)||this._unproject(e)),!i)return this;let a=this._constrainZoom(r+Math.log2(n)),o=this.makeViewport({...this.getViewportProps(),zoom:a});return this._getUpdatedState({zoom:a,...o.panByPosition(i,e)})}zoomEnd(){return this._getUpdatedState({startZoomLngLat:null,startZoom:null})}zoomIn(e=2){return this._zoomFromCenter(e)}zoomOut(e=2){return this._zoomFromCenter(1/e)}moveLeft(e=100){return this._panFromCenter([e,0])}moveRight(e=100){return this._panFromCenter([-e,0])}moveUp(e=100){return this._panFromCenter([0,e])}moveDown(e=100){return this._panFromCenter([0,-e])}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}shortestPathFrom(e){let t=e.getViewportProps(),n={...this.getViewportProps()},{bearing:r,longitude:i}=n;return Math.abs(r-t.bearing)>180&&(n.bearing=r<0?r+360:r-360),Math.abs(i-t.longitude)>180&&(n.longitude=i<0?i+360:i-360),n}applyConstraints(e){let{maxPitch:t,minPitch:n,pitch:r,longitude:i,bearing:a,normalize:o,maxBounds:s}=e;if(o&&((i<-180||i>180)&&(e.longitude=FT(i+180,360)-180),(a<-180||a>180)&&(e.bearing=FT(a+180,360)-180)),e.pitch=y_(r,n,t),e.zoom=this._constrainZoom(e.zoom,e),s){let t=DO(s[0]),n=DO(s[1]),r=2**e.zoom,i=e.width/2/r,a=e.height/2/r,[o,c]=Nw([t[0]+i,t[1]+a]),[l,u]=Nw([n[0]-i,n[1]-a]);e.longitude=y_(e.longitude,o,l),e.latitude=y_(e.latitude,c,u)}return e}_constrainZoom(e,t){t||=this.getViewportProps();let{maxZoom:n,maxBounds:r}=t,i=r!==null&&t.width>0&&t.height>0,{minZoom:a}=t;if(i){let e=DO(r[0]),i=DO(r[1]),o=i[0]-e[0],s=i[1]-e[1];Number.isFinite(o)&&o>0&&(a=Math.max(a,Math.log2(t.width/o))),Number.isFinite(s)&&s>0&&(a=Math.max(a,Math.log2(t.height/s))),a>n&&(a=n)}return y_(e,a,n)}_zoomFromCenter(e){let{width:t,height:n}=this.getViewportProps();return this.zoom({pos:[t/2,n/2],scale:e})}_panFromCenter(e){let{width:t,height:n}=this.getViewportProps();return this.pan({startPos:[t/2,n/2],pos:[t/2+e[0],n/2+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}_unproject(e){let t=this.makeViewport(this.getViewportProps());return e&&t.unproject(e)}_unproject3D(e,t){return this.makeViewport(this.getViewportProps()).unproject(e,{targetZ:t})}_getNewRotation(e,t,n,r){let i=e[0]-t[0],a=e[1]-t[1],o=e[1],s=t[1],{width:c,height:l}=this.getViewportProps(),u=i/c,d=0;a>0?Math.abs(l-s)>CO&&(d=a/(s-l)*wO):a<0&&s>CO&&(d=1-o/s),d=y_(d,-1,1);let{minPitch:f,maxPitch:p}=this.getViewportProps(),m=r+180*u,h=n;return d>0?h=n+d*(p-n):d<0&&(h=n-d*(f-n)),{pitch:h,bearing:m}}},kO=class extends xO{constructor(){super(...arguments),this.ControllerState=OO,this.transition={transitionDuration:300,transitionInterpolator:new hO({transitionProps:{compare:[`longitude`,`latitude`,`zoom`,`bearing`,`pitch`,`position`],required:[`longitude`,`latitude`,`zoom`]}})},this.dragMode=`pan`,this.rotationPivot=`center`,this._getAltitude=e=>{if(this.rotationPivot===`2d`)return 0;if(this.rotationPivot===`3d`&&this.pickPosition){let{x:t,y:n}=this.props,r=this.pickPosition(t+e[0],n+e[1]);if(r&&r.coordinate&&r.coordinate.length>=3)return r.coordinate[2]}}}setProps(e){`rotationPivot`in e&&(this.rotationPivot=e.rotationPivot||`center`),e.getAltitude=this._getAltitude,e.position=e.position||[0,0,0],e.maxBounds=e.maxBounds||(e.normalize===!1?null:EO),super.setProps(e)}updateViewport(e,t=null,n={}){let r=e.getState();n.isDragging&&r.startRotateLngLat?n={...n,rotationPivotPosition:r.startRotateLngLat}:n.isDragging===!1&&(n={...n,rotationPivotPosition:void 0}),super.updateViewport(e,t,n)}},AO=class extends ZD{constructor(e={}){super(e)}getViewportType(){return XT}get ControllerType(){return kO}};AO.displayName=`MapView`;var jO=new MT;function MO(e,t){return(e.order??1/0)-(t.order??1/0)}var NO=class{constructor(e){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=e,this._needsRedraw=`Initial render`,this._setEffects([])}addDefaultEffect(e){let t=this._defaultEffects;if(!t.find(t=>t.id===e.id)){let n=t.findIndex(t=>MO(t,e)>0);n<0?t.push(e):t.splice(n,0,e),e.setup(this._context),this._setEffects(this.effects)}}setProps(e){`effects`in e&&(RD(e.effects,this.effects,1)||this._setEffects(e.effects))}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}getEffects(){return this._resolvedEffects}_setEffects(e){let t={};for(let e of this.effects)t[e.id]=e;let n=[];for(let r of e){let e=t[r.id],i=r;e&&e!==r?e.setProps?(e.setProps(r.props),i=e):e.cleanup(this._context):e||r.setup(this._context),n.push(i),delete t[r.id]}for(let e in t)t[e].cleanup(this._context);this.effects=n,this._resolvedEffects=n.concat(this._defaultEffects),e.some(e=>e instanceof MT)||this._resolvedEffects.push(jO),this._needsRedraw=`effects changed`}finalize(){for(let e of this._resolvedEffects)e.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}},PO=class extends wT{shouldDrawLayer(e){let{operation:t}=e.props;return t.includes(`draw`)||t.includes(`terrain`)}render(e){return this._render(e)}},FO=`deckRenderer.renderLayers`,IO=class{constructor(e,t={}){this.device=e,this.stats=t.stats,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new PO(e),this.pickLayersPass=new bD(e),this.renderCount=0,this._needsRedraw=`Initial render`,this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(e){this.layerFilter!==e.layerFilter&&(this.layerFilter=e.layerFilter,this._needsRedraw=`layerFilter changed`),this.drawPickingColors!==e.drawPickingColors&&(this.drawPickingColors=e.drawPickingColors,this._needsRedraw=`drawPickingColors changed`)}renderLayers(e){if(!e.viewports.length)return;let t=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,n={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e};n.effects&&this._preRender(n.effects,n);let r=this.lastPostProcessEffect?this.renderBuffers[0]:n.target;this.lastPostProcessEffect&&(n.clearColor=[0,0,0,0],n.clearCanvas=!0);let i=t.render({...n,target:r}),a=`stats`in i?i.stats:i;n.effects&&(this.lastPostProcessEffect&&(n.clearCanvas=e.clearCanvas===void 0?!0:e.clearCanvas),this._postRender(n.effects,n)),this.renderCount++,dh(FO,this,a,e),this._updateStats(a)}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}finalize(){let{renderBuffers:e}=this;for(let t of e)t.delete();e.length=0}_updateStats(e){if(!this.stats)return;let t=0;for(let{visibleCount:n}of e)t+=n;this.stats.get(`Layers rendered`).addCount(t)}_preRender(e,t){this.lastPostProcessEffect=null,t.preRenderStats=t.preRenderStats||{};for(let n of e)t.preRenderStats[n.id]=n.preRender(t),n.postRender&&(this.lastPostProcessEffect=n.id);this.lastPostProcessEffect&&this._resizeRenderBuffers()}_resizeRenderBuffers(){let{renderBuffers:e}=this,t=this.device.canvasContext.getDrawingBufferSize(),[n,r]=t;e.length===0&&[0,1].map(t=>{let i=this.device.createTexture({sampler:{minFilter:`linear`,magFilter:`linear`},width:n,height:r});e.push(this.device.createFramebuffer({id:`deck-renderbuffer-${t}`,colorAttachments:[i]}))});for(let n of e)n.resize(t)}_postRender(e,t){let{renderBuffers:n}=this,r={...t,inputBuffer:n[0],swapBuffer:n[1]};for(let i of e)if(i.postRender){r.target=i.id===this.lastPostProcessEffect?t.target:void 0;let e=i.postRender(r);r.inputBuffer=e,r.swapBuffer=e===n[0]?n[1]:n[0]}}},LO={pickedColor:null,pickedObjectIndex:-1};function RO({pickedColors:e,decodePickingColor:t,deviceX:n,deviceY:r,deviceRadius:i,deviceRect:a}){let{x:o,y:s,width:c,height:l}=a,u=i*i,d=-1,f=0;for(let t=0;t<l;t++){let i=t+s-r,a=i*i;if(a>u)f+=4*c;else for(let t=0;t<c;t++){if(e[f+3]-1>=0){let e=t+o-n,r=e*e+a;r<=u&&(u=r,d=f)}f+=4}}if(d>=0){let n=e.slice(d,d+4),r=t(n);if(r){let e=Math.floor(d/4/c),t=d/4-e*c;return{...r,pickedColor:n,pickedX:o+t,pickedY:s+e}}X.error(`Picked non-existent layer. Is picking buffer corrupt?`)()}return LO}function zO({pickedColors:e,decodePickingColor:t}){let n=new Map;if(e){for(let r=0;r<e.length;r+=4)if(e[r+3]-1>=0){let i=e.slice(r,r+4),a=i.join(`,`);if(!n.has(a)){let e=t(i);e?n.set(a,{...e,color:i}):X.error(`Picked non-existent layer. Is picking buffer corrupt?`)()}}}return Array.from(n.values())}function BO({pickInfo:e,viewports:t,pixelRatio:n,x:r,y:i,z:a}){let o=t[0];t.length>1&&(o=UO(e?.pickedViewports||t,{x:r,y:i}));let s;if(o){let e=[r-o.x,i-o.y];a!==void 0&&(e[2]=a),s=o.unproject(e)}return{color:null,layer:null,viewport:o,index:-1,picked:!1,x:r,y:i,pixel:[r,i],coordinate:s,devicePixel:e&&`pickedX`in e?[e.pickedX,e.pickedY]:void 0,pixelRatio:n}}function VO(e){let{pickInfo:t,lastPickedInfo:n,mode:r,layers:i}=e,{pickedColor:a,pickedLayer:o,pickedObjectIndex:s}=t,c=o?[o]:[];if(r===`hover`){let e=n.index,t=n.layerId,r=o?o.props.id:null;if(r!==t||s!==e){if(r!==t){let e=i.find(e=>e.props.id===t);e&&c.unshift(e)}n.layerId=r,n.index=s,n.info=null}}let l=BO(e),u=new Map;return u.set(null,l),c.forEach(e=>{let t={...l};e===o&&(t.color=a,t.index=s,t.picked=!0),t=HO({layer:e,info:t,mode:r});let i=t.layer;e===o&&r===`hover`&&(n.info=t),u.set(i.id,t),r===`hover`&&i.updateAutoHighlight(t)}),u}function HO({layer:e,info:t,mode:n}){for(;e&&t;){let r=t.layer||null;t.sourceLayer=r,t.layer=e,t=e.getPickingInfo({info:t,mode:n,sourceLayer:r}),e=e.parent}return t}function UO(e,t){for(let n=e.length-1;n>=0;n--){let r=e[n];if(r.containsPixel(t))return r}return e[0]}var WO=class{constructor(e,t={}){this._pickable=!0,this.device=e,this.stats=t.stats,this.pickLayersPass=new bD(e),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(e){`layerFilter`in e&&(this.layerFilter=e.layerFilter),`_pickable`in e&&(this._pickable=e._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}pickObjectAsync(e){return this._pickClosestObjectAsync(e)}pickObjectsAsync(e){return this._pickVisibleObjectsAsync(e)}pickObject(e){return this._pickClosestObject(e)}pickObjects(e){return this._pickVisibleObjects(e)}getLastPickedObject({x:e,y:t,layers:n,viewports:r},i=this.lastPickedInfo.info){let a=i&&i.layer&&i.layer.id,o=i&&i.viewport&&i.viewport.id,s=a?n.find(e=>e.id===a):null,c=o&&r.find(e=>e.id===o)||r[0],l={x:e,y:t,viewport:c,coordinate:c&&c.unproject([e-c.x,t-c.y]),layer:s};return{...i,...l}}_resizeBuffer(){if(!this.pickingFBO){let e=this.device.createTexture({format:`rgba8unorm`,width:1,height:1,usage:Kb.RENDER_ATTACHMENT|Kb.COPY_SRC});if(this.pickingFBO=this.device.createFramebuffer({colorAttachments:[e],depthStencilAttachment:`depth16unorm`}),this.device.isTextureFormatRenderable(`rgba32float`)){let e=this.device.createTexture({format:`rgba32float`,width:1,height:1,usage:Kb.RENDER_ATTACHMENT|Kb.COPY_SRC}),t=this.device.createFramebuffer({colorAttachments:[e],depthStencilAttachment:`depth16unorm`});this.depthFBO=t}}let{canvas:e}=this.device.getDefaultCanvasContext();this.pickingFBO?.resize({width:e.width,height:e.height}),this.depthFBO?.resize({width:e.width,height:e.height})}_getPickable(e){if(this._pickable===!1)return null;let t=e.filter(e=>this.pickLayersPass.shouldDrawLayer(e)&&!e.isComposite);return t.length?t:null}async _pickClosestObjectAsync({layers:e,views:t,viewports:n,x:r,y:i,radius:a=0,depth:o=1,mode:s=`query`,unproject3D:c,onViewportActive:l,effects:u}){let d=this.device.canvasContext.cssToDeviceRatio(),f=this._getPickable(e);if(!f||n.length===0)return{result:[],emptyInfo:BO({viewports:n,x:r,y:i,pixelRatio:d})};this._resizeBuffer();let p=this.device.canvasContext.cssToDevicePixels([r,i],!0),m=[p.x+Math.floor(p.width/2),p.y+Math.floor(p.height/2)],h=Math.round(a*d),{width:g,height:_}=this.pickingFBO,v=this._getPickingRect({deviceX:m[0],deviceY:m[1],deviceRadius:h,deviceWidth:g,deviceHeight:_}),y={x:r-a,y:i-a,width:a*2+1,height:a*2+1},b,x=[],S=new Set;for(let e=0;e<o;e++){let a;a=v?RO({...await this._drawAndSampleAsync({layers:f,views:t,viewports:n,onViewportActive:l,deviceRect:v,cullRect:y,effects:u,pass:`picking:${s}`}),deviceX:m[0],deviceY:m[1],deviceRadius:h,deviceRect:v}):{pickedColor:null,pickedObjectIndex:-1};let p,g=this._getDepthLayers(a,f,c);if(g.length>0){let{pickedColors:e}=await this._drawAndSampleAsync({layers:g,views:t,viewports:n,onViewportActive:l,deviceRect:{x:a.pickedX??m[0],y:a.pickedY??m[1],width:1,height:1},cullRect:y,effects:u,pass:`picking:${s}:z`},!0);e[3]&&(p=e[0])}a.pickedLayer&&e+1<o&&(S.add(a.pickedLayer),a.pickedLayer.disablePickingIndex(a.pickedObjectIndex)),b=VO({pickInfo:a,lastPickedInfo:this.lastPickedInfo,mode:s,layers:f,viewports:n,x:r,y:i,z:p,pixelRatio:d});for(let e of b.values())e.layer&&x.push(e);if(!a.pickedColor)break}for(let e of S)e.restorePickingColors();return{result:x,emptyInfo:b.get(null)}}_pickClosestObject({layers:e,views:t,viewports:n,x:r,y:i,radius:a=0,depth:o=1,mode:s=`query`,unproject3D:c,onViewportActive:l,effects:u}){let d=this.device.canvasContext.cssToDeviceRatio(),f=this._getPickable(e);if(!f||n.length===0)return{result:[],emptyInfo:BO({viewports:n,x:r,y:i,pixelRatio:d})};this._resizeBuffer();let p=this.device.canvasContext.cssToDevicePixels([r,i],!0),m=[p.x+Math.floor(p.width/2),p.y+Math.floor(p.height/2)],h=Math.round(a*d),{width:g,height:_}=this.pickingFBO,v=this._getPickingRect({deviceX:m[0],deviceY:m[1],deviceRadius:h,deviceWidth:g,deviceHeight:_}),y={x:r-a,y:i-a,width:a*2+1,height:a*2+1},b,x=[],S=new Set;for(let e=0;e<o;e++){let a;a=v?RO({...this._drawAndSample({layers:f,views:t,viewports:n,onViewportActive:l,deviceRect:v,cullRect:y,effects:u,pass:`picking:${s}`}),deviceX:m[0],deviceY:m[1],deviceRadius:h,deviceRect:v}):{pickedColor:null,pickedObjectIndex:-1};let p,g=this._getDepthLayers(a,f,c);if(g.length>0){let{pickedColors:e}=this._drawAndSample({layers:g,views:t,viewports:n,onViewportActive:l,deviceRect:{x:a.pickedX??m[0],y:a.pickedY??m[1],width:1,height:1},cullRect:y,effects:u,pass:`picking:${s}:z`},!0);e[3]&&(p=e[0])}a.pickedLayer&&e+1<o&&(S.add(a.pickedLayer),a.pickedLayer.disablePickingIndex(a.pickedObjectIndex)),b=VO({pickInfo:a,lastPickedInfo:this.lastPickedInfo,mode:s,layers:f,viewports:n,x:r,y:i,z:p,pixelRatio:d});for(let e of b.values())e.layer&&x.push(e);if(!a.pickedColor)break}for(let e of S)e.restorePickingColors();return{result:x,emptyInfo:b.get(null)}}async _pickVisibleObjectsAsync({layers:e,views:t,viewports:n,x:r,y:i,width:a=1,height:o=1,mode:s=`query`,maxObjects:c=null,onViewportActive:l,effects:u}){let d=this._getPickable(e);if(!d||n.length===0)return[];this._resizeBuffer();let f=this.device.canvasContext.cssToDeviceRatio(),p=this.device.canvasContext.cssToDevicePixels([r,i],!0),m=p.x,h=p.y+p.height,g=this.device.canvasContext.cssToDevicePixels([r+a,i+o],!0),_=g.x+g.width,v=g.y,y={x:m,y:v,width:_-m,height:h-v},b=zO(await this._drawAndSampleAsync({layers:d,views:t,viewports:n,onViewportActive:l,deviceRect:y,cullRect:{x:r,y:i,width:a,height:o},effects:u,pass:`picking:${s}`})),x=new Map,S=[],C=Number.isFinite(c);for(let e=0;e<b.length&&!(C&&S.length>=c);e++){let t=b[e],n={color:t.pickedColor,layer:null,index:t.pickedObjectIndex,picked:!0,x:r,y:i,pixelRatio:f};n=HO({layer:t.pickedLayer,info:n,mode:s});let a=n.layer.id;x.has(a)||x.set(a,new Set);let o=x.get(a),c=n.object??n.index;o.has(c)||(o.add(c),S.push(n))}return S}_pickVisibleObjects({layers:e,views:t,viewports:n,x:r,y:i,width:a=1,height:o=1,mode:s=`query`,maxObjects:c=null,onViewportActive:l,effects:u}){let d=this._getPickable(e);if(!d||n.length===0)return[];this._resizeBuffer();let f=this.device.canvasContext.cssToDeviceRatio(),p=this.device.canvasContext.cssToDevicePixels([r,i],!0),m=p.x,h=p.y+p.height,g=this.device.canvasContext.cssToDevicePixels([r+a,i+o],!0),_=g.x+g.width,v=g.y,y={x:m,y:v,width:_-m,height:h-v},b=zO(this._drawAndSample({layers:d,views:t,viewports:n,onViewportActive:l,deviceRect:y,cullRect:{x:r,y:i,width:a,height:o},effects:u,pass:`picking:${s}`})),x=new Map,S=[],C=Number.isFinite(c);for(let e=0;e<b.length&&!(C&&S.length>=c);e++){let t=b[e],n={color:t.pickedColor,layer:null,index:t.pickedObjectIndex,picked:!0,x:r,y:i,pixelRatio:f};n=HO({layer:t.pickedLayer,info:n,mode:s});let a=n.layer.id;x.has(a)||x.set(a,new Set);let o=x.get(a),c=n.object??n.index;o.has(c)||(o.add(c),S.push(n))}return S}async _drawAndSampleAsync({layers:e,views:t,viewports:n,onViewportActive:r,deviceRect:i,cullRect:a,effects:o,pass:s},c=!1){let l=c?this.depthFBO:this.pickingFBO,u={layers:e,layerFilter:this.layerFilter,views:t,viewports:n,onViewportActive:r,pickingFBO:l,deviceRect:i,cullRect:a,effects:o,pass:s,pickZ:c,preRenderStats:{},isPicking:!0};for(let e of o)e.useInPicking&&(u.preRenderStats[e.id]=e.preRender(u));let{decodePickingColor:d,stats:f}=this.pickLayersPass.render(u);this._updateStats(f);let{x:p,y:m,width:h,height:g}=i,_=l.colorAttachments[0]?.texture;if(!_)throw Error(`Picking framebuffer color attachment is missing`);let v=await this._readTextureDataAsync(_,{x:p,y:m,width:h,height:g},c?Float32Array:Uint8Array);if(!c){let e=!1;for(let t=3;t<v.length;t+=4)if(v[t]!==0){e=!0;break}!e&&v.length>0&&X.warn(`Async pick readback returned only zero alpha values`,{deviceRect:i,bytes:Array.from(v.subarray(0,Math.min(v.length,16)))})()}return{pickedColors:v,decodePickingColor:d}}async _readTextureDataAsync(e,t,n){let{width:r,height:i}=t,a=e.computeMemoryLayout(t),o=this.device.createBuffer({byteLength:a.byteLength,usage:ky.COPY_DST|ky.MAP_READ});try{e.readBuffer(t,o);let s=await o.readAsync(0,a.byteLength),c=n.BYTES_PER_ELEMENT;if(a.bytesPerRow%c!==0)throw Error(`Texture readback row stride ${a.bytesPerRow} is not aligned to ${c}-byte elements.`);let l=new n(s.buffer,s.byteOffset,a.byteLength/c),u=r*4,d=a.bytesPerRow/c;if(d<u)throw Error(`Texture readback row stride ${d} is smaller than packed row length ${u}.`);let f=new n(r*i*4);for(let e=0;e<i;e++){let t=e*d;f.set(l.subarray(t,t+u),e*u)}return f}finally{o.destroy()}}_drawAndSample({layers:e,views:t,viewports:n,onViewportActive:r,deviceRect:i,cullRect:a,effects:o,pass:s},c=!1){let l=c?this.depthFBO:this.pickingFBO,u={layers:e,layerFilter:this.layerFilter,views:t,viewports:n,onViewportActive:r,pickingFBO:l,deviceRect:i,cullRect:a,effects:o,pass:s,pickZ:c,preRenderStats:{},isPicking:!0};for(let e of o)e.useInPicking&&(u.preRenderStats[e.id]=e.preRender(u));let{decodePickingColor:d,stats:f}=this.pickLayersPass.render(u);this._updateStats(f);let{x:p,y:m,width:h,height:g}=i,_=new(c?Float32Array:Uint8Array)(h*g*4);return this.device.readPixelsToArrayWebGL(l,{sourceX:p,sourceY:m,sourceWidth:h,sourceHeight:g,target:_}),{pickedColors:_,decodePickingColor:d}}_updateStats(e){if(!this.stats)return;let t=0;for(let{visibleCount:n}of e)t+=n;this.stats.get(`Layers picked`).addCount(t)}_getDepthLayers(e,t,n){if(!n||!this.depthFBO)return[];let{pickedLayer:r}=e,i=r?.state?.terrainDrawMode===`drape`;return r&&!i?[r]:t.filter(e=>e.props.operation.includes(`terrain`))}_getPickingRect({deviceX:e,deviceY:t,deviceRadius:n,deviceWidth:r,deviceHeight:i}){let a=Math.max(0,e-n),o=Math.max(0,t-n),s=Math.min(r,e+n+1)-a,c=Math.min(i,t+n+1)-o;return s<=0||c<=0?null:{x:a,y:o,width:s,height:c}}},GO={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0},fill:{top:0,left:0,bottom:0,right:0}},KO=`top-left`,qO=`root`,JO=class{constructor({deck:e,parentElement:t}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=e,t?.classList.add(`deck-widget-container`),this.parentElement=t}getWidgets(){return this.resolvedWidgets}setProps(e){if(e.widgets&&!RD(e.widgets,this.widgets,1)){let t=e.widgets.filter(Boolean);this._setWidgets(t)}}finalize(){for(let e of this.getWidgets())this._removeWidget(e);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(let e in this.containers)this.containers[e].remove()}addDefault(e){this.defaultWidgets.find(t=>t.id===e.id)||(this._addWidget(e),this.defaultWidgets.push(e),this._setWidgets(this.widgets))}onRedraw({viewports:e,layers:t}){let n=e.reduce((e,t)=>(e[t.id]=t,e),{});for(let r of this.getWidgets()){let{viewId:i}=r;if(i){let e=n[i];e&&(r.onViewportChange&&r.onViewportChange(e),r.onRedraw?.({viewports:[e],layers:t}))}else{if(r.onViewportChange)for(let t of e)r.onViewportChange(t);r.onRedraw?.({viewports:e,layers:t})}}this.lastViewports=n,this._updateContainers()}onHover(e,t){for(let n of this.getWidgets()){let{viewId:r}=n;(!r||r===e.viewport?.id)&&n.onHover?.(e,t)}}onEvent(e,t){let n=YC[t.type];if(n)for(let r of this.getWidgets()){let{viewId:i}=r;(!i||i===e.viewport?.id)&&r[n]?.(e,t)}}_setWidgets(e){let t={};for(let e of this.resolvedWidgets)t[e.id]=e;this.resolvedWidgets.length=0;for(let e of this.defaultWidgets)t[e.id]=null,this.resolvedWidgets.push(e);for(let n of e){let e=t[n.id];e?e.viewId!==n.viewId||e.placement!==n.placement?(this._removeWidget(e),this._addWidget(n)):n!==e&&(e.setProps(n.props),n=e):this._addWidget(n),t[n.id]=null,this.resolvedWidgets.push(n)}for(let e in t){let n=t[e];n&&this._removeWidget(n)}this.widgets=e}_addWidget(e){let{viewId:t=null,placement:n=KO}=e,r=e.props._container??t;e.widgetManager=this,e.deck=this.deck,e.rootElement=e._onAdd({deck:this.deck,viewId:t}),e.rootElement&&this._getContainer(r,n).append(e.rootElement),e.updateHTML()}_removeWidget(e){e.onRemove?.(),e.rootElement&&e.rootElement.remove(),e.rootElement=void 0,e.deck=void 0,e.widgetManager=void 0}_getContainer(e,t){if(e&&typeof e!=`string`)return e;let n=e||qO,r=this.containers[n];r||(r=document.createElement(`div`),r.style.pointerEvents=`none`,r.style.position=`absolute`,r.style.overflow=`hidden`,this.parentElement?.append(r),this.containers[n]=r);let i=r.querySelector(`.${t}`);return i||(i=globalThis.document.createElement(`div`),i.className=t,i.style.position=`absolute`,i.style.zIndex=`2`,Object.assign(i.style,GO[t]),r.append(i)),i}_updateContainers(){let e=this.deck.width,t=this.deck.height;for(let n in this.containers){let r=this.lastViewports[n]||null,i=n===qO||r,a=this.containers[n];i?(a.style.display=`block`,a.style.left=`${r?r.x:0}px`,a.style.top=`${r?r.y:0}px`,a.style.width=`${r?r.width:e}px`,a.style.height=`${r?r.height:t}px`):a.style.display=`none`}}};function YO(e,t){t&&Object.entries(t).map(([t,n])=>{t.startsWith(`--`)?e.style.setProperty(t,n):e.style[t]=n})}function XO(e,t){t&&Object.keys(t).map(t=>{t.startsWith(`--`)?e.style.removeProperty(t):e.style[t]=``})}var ZO=class{constructor(e){this.viewId=null,this.props={...this.constructor.defaultProps,...e},this.id=this.props.id}setProps(e){let t=this.props,n=this.rootElement;n&&t.className!==e.className&&(t.className&&n.classList.remove(t.className),e.className&&n.classList.add(e.className)),n&&!RD(t.style,e.style,1)&&(XO(n,t.style),YO(n,e.style)),Object.assign(this.props,e),this.updateHTML()}updateHTML(){this.rootElement&&this.onRenderHTML(this.rootElement)}get viewIds(){return this.viewId?[this.viewId]:this.deck?.getViews().map(e=>e.id)??[]}getViewState(e){return this.deck?.viewManager?.getViewState(e)||{}}setViewState(e,t){this.deck?._onViewStateChange({viewId:e,viewState:t,interactionState:{}})}onCreateRootElement(){let e=[`deck-widget`,this.className,this.props.className],t=document.createElement(`div`);return e.filter(e=>typeof e==`string`&&e.length>0).forEach(e=>t.classList.add(e)),YO(t,this.props.style),t}_onAdd(e){return this.onAdd(e)??this.onCreateRootElement()}onAdd(e){}onRemove(){}onViewportChange(e){}onRedraw(e){}onHover(e,t){}onClick(e,t){}onDrag(e,t){}onDragStart(e,t){}onDragEnd(e,t){}};ZO.defaultProps={id:`widget`,style:{},_container:null,className:``};var QO={zIndex:`1`,position:`absolute`,pointerEvents:`none`,color:`#a0a7b4`,backgroundColor:`#29323c`,padding:`10px`,top:`0`,left:`0`,display:`none`},$O=class extends ZO{constructor(e={}){super(e),this.id=`default-tooltip`,this.placement=`fill`,this.className=`deck-tooltip`,this.isVisible=!1,this.setProps(e)}onCreateRootElement(){let e=document.createElement(`div`);return e.className=this.className,Object.assign(e.style,QO),e}onRenderHTML(e){}onViewportChange(e){this.isVisible&&e.id===this.lastViewport?.id&&!e.equals(this.lastViewport)&&this.setTooltip(null),this.lastViewport=e}onHover(e){let{deck:t}=this,n=t&&t.props.getTooltip;if(!n)return;let r=n(e);this.setTooltip(r,e.x,e.y)}setTooltip(e,t,n){let r=this.rootElement;if(r){if(typeof e==`string`)r.innerText=e;else if(e)e.text&&(r.innerText=e.text),e.html&&(r.innerHTML=e.html),e.className&&(r.className=e.className);else{this.isVisible=!1,r.style.display=`none`;return}this.isVisible=!0,r.style.display=`block`,r.style.transform=`translate(${t}px, ${n}px)`,e&&typeof e==`object`&&`style`in e&&Object.assign(r.style,e.style)}}};$O.defaultProps={...ZO.defaultProps};var ek;(function(e){e[e.DEPTH_BUFFER_BIT=256]=`DEPTH_BUFFER_BIT`,e[e.STENCIL_BUFFER_BIT=1024]=`STENCIL_BUFFER_BIT`,e[e.COLOR_BUFFER_BIT=16384]=`COLOR_BUFFER_BIT`,e[e.POINTS=0]=`POINTS`,e[e.LINES=1]=`LINES`,e[e.LINE_LOOP=2]=`LINE_LOOP`,e[e.LINE_STRIP=3]=`LINE_STRIP`,e[e.TRIANGLES=4]=`TRIANGLES`,e[e.TRIANGLE_STRIP=5]=`TRIANGLE_STRIP`,e[e.TRIANGLE_FAN=6]=`TRIANGLE_FAN`,e[e.ZERO=0]=`ZERO`,e[e.ONE=1]=`ONE`,e[e.SRC_COLOR=768]=`SRC_COLOR`,e[e.ONE_MINUS_SRC_COLOR=769]=`ONE_MINUS_SRC_COLOR`,e[e.SRC_ALPHA=770]=`SRC_ALPHA`,e[e.ONE_MINUS_SRC_ALPHA=771]=`ONE_MINUS_SRC_ALPHA`,e[e.DST_ALPHA=772]=`DST_ALPHA`,e[e.ONE_MINUS_DST_ALPHA=773]=`ONE_MINUS_DST_ALPHA`,e[e.DST_COLOR=774]=`DST_COLOR`,e[e.ONE_MINUS_DST_COLOR=775]=`ONE_MINUS_DST_COLOR`,e[e.SRC_ALPHA_SATURATE=776]=`SRC_ALPHA_SATURATE`,e[e.CONSTANT_COLOR=32769]=`CONSTANT_COLOR`,e[e.ONE_MINUS_CONSTANT_COLOR=32770]=`ONE_MINUS_CONSTANT_COLOR`,e[e.CONSTANT_ALPHA=32771]=`CONSTANT_ALPHA`,e[e.ONE_MINUS_CONSTANT_ALPHA=32772]=`ONE_MINUS_CONSTANT_ALPHA`,e[e.FUNC_ADD=32774]=`FUNC_ADD`,e[e.FUNC_SUBTRACT=32778]=`FUNC_SUBTRACT`,e[e.FUNC_REVERSE_SUBTRACT=32779]=`FUNC_REVERSE_SUBTRACT`,e[e.BLEND_EQUATION=32777]=`BLEND_EQUATION`,e[e.BLEND_EQUATION_RGB=32777]=`BLEND_EQUATION_RGB`,e[e.BLEND_EQUATION_ALPHA=34877]=`BLEND_EQUATION_ALPHA`,e[e.BLEND_DST_RGB=32968]=`BLEND_DST_RGB`,e[e.BLEND_SRC_RGB=32969]=`BLEND_SRC_RGB`,e[e.BLEND_DST_ALPHA=32970]=`BLEND_DST_ALPHA`,e[e.BLEND_SRC_ALPHA=32971]=`BLEND_SRC_ALPHA`,e[e.BLEND_COLOR=32773]=`BLEND_COLOR`,e[e.ARRAY_BUFFER_BINDING=34964]=`ARRAY_BUFFER_BINDING`,e[e.ELEMENT_ARRAY_BUFFER_BINDING=34965]=`ELEMENT_ARRAY_BUFFER_BINDING`,e[e.LINE_WIDTH=2849]=`LINE_WIDTH`,e[e.ALIASED_POINT_SIZE_RANGE=33901]=`ALIASED_POINT_SIZE_RANGE`,e[e.ALIASED_LINE_WIDTH_RANGE=33902]=`ALIASED_LINE_WIDTH_RANGE`,e[e.CULL_FACE_MODE=2885]=`CULL_FACE_MODE`,e[e.FRONT_FACE=2886]=`FRONT_FACE`,e[e.DEPTH_RANGE=2928]=`DEPTH_RANGE`,e[e.DEPTH_WRITEMASK=2930]=`DEPTH_WRITEMASK`,e[e.DEPTH_CLEAR_VALUE=2931]=`DEPTH_CLEAR_VALUE`,e[e.DEPTH_FUNC=2932]=`DEPTH_FUNC`,e[e.STENCIL_CLEAR_VALUE=2961]=`STENCIL_CLEAR_VALUE`,e[e.STENCIL_FUNC=2962]=`STENCIL_FUNC`,e[e.STENCIL_FAIL=2964]=`STENCIL_FAIL`,e[e.STENCIL_PASS_DEPTH_FAIL=2965]=`STENCIL_PASS_DEPTH_FAIL`,e[e.STENCIL_PASS_DEPTH_PASS=2966]=`STENCIL_PASS_DEPTH_PASS`,e[e.STENCIL_REF=2967]=`STENCIL_REF`,e[e.STENCIL_VALUE_MASK=2963]=`STENCIL_VALUE_MASK`,e[e.STENCIL_WRITEMASK=2968]=`STENCIL_WRITEMASK`,e[e.STENCIL_BACK_FUNC=34816]=`STENCIL_BACK_FUNC`,e[e.STENCIL_BACK_FAIL=34817]=`STENCIL_BACK_FAIL`,e[e.STENCIL_BACK_PASS_DEPTH_FAIL=34818]=`STENCIL_BACK_PASS_DEPTH_FAIL`,e[e.STENCIL_BACK_PASS_DEPTH_PASS=34819]=`STENCIL_BACK_PASS_DEPTH_PASS`,e[e.STENCIL_BACK_REF=36003]=`STENCIL_BACK_REF`,e[e.STENCIL_BACK_VALUE_MASK=36004]=`STENCIL_BACK_VALUE_MASK`,e[e.STENCIL_BACK_WRITEMASK=36005]=`STENCIL_BACK_WRITEMASK`,e[e.VIEWPORT=2978]=`VIEWPORT`,e[e.SCISSOR_BOX=3088]=`SCISSOR_BOX`,e[e.COLOR_CLEAR_VALUE=3106]=`COLOR_CLEAR_VALUE`,e[e.COLOR_WRITEMASK=3107]=`COLOR_WRITEMASK`,e[e.UNPACK_ALIGNMENT=3317]=`UNPACK_ALIGNMENT`,e[e.PACK_ALIGNMENT=3333]=`PACK_ALIGNMENT`,e[e.MAX_TEXTURE_SIZE=3379]=`MAX_TEXTURE_SIZE`,e[e.MAX_VIEWPORT_DIMS=3386]=`MAX_VIEWPORT_DIMS`,e[e.SUBPIXEL_BITS=3408]=`SUBPIXEL_BITS`,e[e.RED_BITS=3410]=`RED_BITS`,e[e.GREEN_BITS=3411]=`GREEN_BITS`,e[e.BLUE_BITS=3412]=`BLUE_BITS`,e[e.ALPHA_BITS=3413]=`ALPHA_BITS`,e[e.DEPTH_BITS=3414]=`DEPTH_BITS`,e[e.STENCIL_BITS=3415]=`STENCIL_BITS`,e[e.POLYGON_OFFSET_UNITS=10752]=`POLYGON_OFFSET_UNITS`,e[e.POLYGON_OFFSET_FACTOR=32824]=`POLYGON_OFFSET_FACTOR`,e[e.TEXTURE_BINDING_2D=32873]=`TEXTURE_BINDING_2D`,e[e.SAMPLE_BUFFERS=32936]=`SAMPLE_BUFFERS`,e[e.SAMPLES=32937]=`SAMPLES`,e[e.SAMPLE_COVERAGE_VALUE=32938]=`SAMPLE_COVERAGE_VALUE`,e[e.SAMPLE_COVERAGE_INVERT=32939]=`SAMPLE_COVERAGE_INVERT`,e[e.COMPRESSED_TEXTURE_FORMATS=34467]=`COMPRESSED_TEXTURE_FORMATS`,e[e.VENDOR=7936]=`VENDOR`,e[e.RENDERER=7937]=`RENDERER`,e[e.VERSION=7938]=`VERSION`,e[e.IMPLEMENTATION_COLOR_READ_TYPE=35738]=`IMPLEMENTATION_COLOR_READ_TYPE`,e[e.IMPLEMENTATION_COLOR_READ_FORMAT=35739]=`IMPLEMENTATION_COLOR_READ_FORMAT`,e[e.BROWSER_DEFAULT_WEBGL=37444]=`BROWSER_DEFAULT_WEBGL`,e[e.STATIC_DRAW=35044]=`STATIC_DRAW`,e[e.STREAM_DRAW=35040]=`STREAM_DRAW`,e[e.DYNAMIC_DRAW=35048]=`DYNAMIC_DRAW`,e[e.ARRAY_BUFFER=34962]=`ARRAY_BUFFER`,e[e.ELEMENT_ARRAY_BUFFER=34963]=`ELEMENT_ARRAY_BUFFER`,e[e.BUFFER_SIZE=34660]=`BUFFER_SIZE`,e[e.BUFFER_USAGE=34661]=`BUFFER_USAGE`,e[e.CURRENT_VERTEX_ATTRIB=34342]=`CURRENT_VERTEX_ATTRIB`,e[e.VERTEX_ATTRIB_ARRAY_ENABLED=34338]=`VERTEX_ATTRIB_ARRAY_ENABLED`,e[e.VERTEX_ATTRIB_ARRAY_SIZE=34339]=`VERTEX_ATTRIB_ARRAY_SIZE`,e[e.VERTEX_ATTRIB_ARRAY_STRIDE=34340]=`VERTEX_ATTRIB_ARRAY_STRIDE`,e[e.VERTEX_ATTRIB_ARRAY_TYPE=34341]=`VERTEX_ATTRIB_ARRAY_TYPE`,e[e.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]=`VERTEX_ATTRIB_ARRAY_NORMALIZED`,e[e.VERTEX_ATTRIB_ARRAY_POINTER=34373]=`VERTEX_ATTRIB_ARRAY_POINTER`,e[e.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]=`VERTEX_ATTRIB_ARRAY_BUFFER_BINDING`,e[e.CULL_FACE=2884]=`CULL_FACE`,e[e.FRONT=1028]=`FRONT`,e[e.BACK=1029]=`BACK`,e[e.FRONT_AND_BACK=1032]=`FRONT_AND_BACK`,e[e.BLEND=3042]=`BLEND`,e[e.DEPTH_TEST=2929]=`DEPTH_TEST`,e[e.DITHER=3024]=`DITHER`,e[e.POLYGON_OFFSET_FILL=32823]=`POLYGON_OFFSET_FILL`,e[e.SAMPLE_ALPHA_TO_COVERAGE=32926]=`SAMPLE_ALPHA_TO_COVERAGE`,e[e.SAMPLE_COVERAGE=32928]=`SAMPLE_COVERAGE`,e[e.SCISSOR_TEST=3089]=`SCISSOR_TEST`,e[e.STENCIL_TEST=2960]=`STENCIL_TEST`,e[e.NO_ERROR=0]=`NO_ERROR`,e[e.INVALID_ENUM=1280]=`INVALID_ENUM`,e[e.INVALID_VALUE=1281]=`INVALID_VALUE`,e[e.INVALID_OPERATION=1282]=`INVALID_OPERATION`,e[e.OUT_OF_MEMORY=1285]=`OUT_OF_MEMORY`,e[e.CONTEXT_LOST_WEBGL=37442]=`CONTEXT_LOST_WEBGL`,e[e.CW=2304]=`CW`,e[e.CCW=2305]=`CCW`,e[e.DONT_CARE=4352]=`DONT_CARE`,e[e.FASTEST=4353]=`FASTEST`,e[e.NICEST=4354]=`NICEST`,e[e.GENERATE_MIPMAP_HINT=33170]=`GENERATE_MIPMAP_HINT`,e[e.BYTE=5120]=`BYTE`,e[e.UNSIGNED_BYTE=5121]=`UNSIGNED_BYTE`,e[e.SHORT=5122]=`SHORT`,e[e.UNSIGNED_SHORT=5123]=`UNSIGNED_SHORT`,e[e.INT=5124]=`INT`,e[e.UNSIGNED_INT=5125]=`UNSIGNED_INT`,e[e.FLOAT=5126]=`FLOAT`,e[e.DOUBLE=5130]=`DOUBLE`,e[e.DEPTH_COMPONENT=6402]=`DEPTH_COMPONENT`,e[e.ALPHA=6406]=`ALPHA`,e[e.RGB=6407]=`RGB`,e[e.RGBA=6408]=`RGBA`,e[e.LUMINANCE=6409]=`LUMINANCE`,e[e.LUMINANCE_ALPHA=6410]=`LUMINANCE_ALPHA`,e[e.UNSIGNED_SHORT_4_4_4_4=32819]=`UNSIGNED_SHORT_4_4_4_4`,e[e.UNSIGNED_SHORT_5_5_5_1=32820]=`UNSIGNED_SHORT_5_5_5_1`,e[e.UNSIGNED_SHORT_5_6_5=33635]=`UNSIGNED_SHORT_5_6_5`,e[e.FRAGMENT_SHADER=35632]=`FRAGMENT_SHADER`,e[e.VERTEX_SHADER=35633]=`VERTEX_SHADER`,e[e.COMPILE_STATUS=35713]=`COMPILE_STATUS`,e[e.DELETE_STATUS=35712]=`DELETE_STATUS`,e[e.LINK_STATUS=35714]=`LINK_STATUS`,e[e.VALIDATE_STATUS=35715]=`VALIDATE_STATUS`,e[e.ATTACHED_SHADERS=35717]=`ATTACHED_SHADERS`,e[e.ACTIVE_ATTRIBUTES=35721]=`ACTIVE_ATTRIBUTES`,e[e.ACTIVE_UNIFORMS=35718]=`ACTIVE_UNIFORMS`,e[e.MAX_VERTEX_ATTRIBS=34921]=`MAX_VERTEX_ATTRIBS`,e[e.MAX_VERTEX_UNIFORM_VECTORS=36347]=`MAX_VERTEX_UNIFORM_VECTORS`,e[e.MAX_VARYING_VECTORS=36348]=`MAX_VARYING_VECTORS`,e[e.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]=`MAX_COMBINED_TEXTURE_IMAGE_UNITS`,e[e.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]=`MAX_VERTEX_TEXTURE_IMAGE_UNITS`,e[e.MAX_TEXTURE_IMAGE_UNITS=34930]=`MAX_TEXTURE_IMAGE_UNITS`,e[e.MAX_FRAGMENT_UNIFORM_VECTORS=36349]=`MAX_FRAGMENT_UNIFORM_VECTORS`,e[e.SHADER_TYPE=35663]=`SHADER_TYPE`,e[e.SHADING_LANGUAGE_VERSION=35724]=`SHADING_LANGUAGE_VERSION`,e[e.CURRENT_PROGRAM=35725]=`CURRENT_PROGRAM`,e[e.NEVER=512]=`NEVER`,e[e.LESS=513]=`LESS`,e[e.EQUAL=514]=`EQUAL`,e[e.LEQUAL=515]=`LEQUAL`,e[e.GREATER=516]=`GREATER`,e[e.NOTEQUAL=517]=`NOTEQUAL`,e[e.GEQUAL=518]=`GEQUAL`,e[e.ALWAYS=519]=`ALWAYS`,e[e.KEEP=7680]=`KEEP`,e[e.REPLACE=7681]=`REPLACE`,e[e.INCR=7682]=`INCR`,e[e.DECR=7683]=`DECR`,e[e.INVERT=5386]=`INVERT`,e[e.INCR_WRAP=34055]=`INCR_WRAP`,e[e.DECR_WRAP=34056]=`DECR_WRAP`,e[e.NEAREST=9728]=`NEAREST`,e[e.LINEAR=9729]=`LINEAR`,e[e.NEAREST_MIPMAP_NEAREST=9984]=`NEAREST_MIPMAP_NEAREST`,e[e.LINEAR_MIPMAP_NEAREST=9985]=`LINEAR_MIPMAP_NEAREST`,e[e.NEAREST_MIPMAP_LINEAR=9986]=`NEAREST_MIPMAP_LINEAR`,e[e.LINEAR_MIPMAP_LINEAR=9987]=`LINEAR_MIPMAP_LINEAR`,e[e.TEXTURE_MAG_FILTER=10240]=`TEXTURE_MAG_FILTER`,e[e.TEXTURE_MIN_FILTER=10241]=`TEXTURE_MIN_FILTER`,e[e.TEXTURE_WRAP_S=10242]=`TEXTURE_WRAP_S`,e[e.TEXTURE_WRAP_T=10243]=`TEXTURE_WRAP_T`,e[e.TEXTURE_2D=3553]=`TEXTURE_2D`,e[e.TEXTURE=5890]=`TEXTURE`,e[e.TEXTURE_CUBE_MAP=34067]=`TEXTURE_CUBE_MAP`,e[e.TEXTURE_BINDING_CUBE_MAP=34068]=`TEXTURE_BINDING_CUBE_MAP`,e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]=`TEXTURE_CUBE_MAP_POSITIVE_X`,e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]=`TEXTURE_CUBE_MAP_NEGATIVE_X`,e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]=`TEXTURE_CUBE_MAP_POSITIVE_Y`,e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]=`TEXTURE_CUBE_MAP_NEGATIVE_Y`,e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]=`TEXTURE_CUBE_MAP_POSITIVE_Z`,e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]=`TEXTURE_CUBE_MAP_NEGATIVE_Z`,e[e.MAX_CUBE_MAP_TEXTURE_SIZE=34076]=`MAX_CUBE_MAP_TEXTURE_SIZE`,e[e.TEXTURE0=33984]=`TEXTURE0`,e[e.ACTIVE_TEXTURE=34016]=`ACTIVE_TEXTURE`,e[e.REPEAT=10497]=`REPEAT`,e[e.CLAMP_TO_EDGE=33071]=`CLAMP_TO_EDGE`,e[e.MIRRORED_REPEAT=33648]=`MIRRORED_REPEAT`,e[e.TEXTURE_WIDTH=4096]=`TEXTURE_WIDTH`,e[e.TEXTURE_HEIGHT=4097]=`TEXTURE_HEIGHT`,e[e.FLOAT_VEC2=35664]=`FLOAT_VEC2`,e[e.FLOAT_VEC3=35665]=`FLOAT_VEC3`,e[e.FLOAT_VEC4=35666]=`FLOAT_VEC4`,e[e.INT_VEC2=35667]=`INT_VEC2`,e[e.INT_VEC3=35668]=`INT_VEC3`,e[e.INT_VEC4=35669]=`INT_VEC4`,e[e.BOOL=35670]=`BOOL`,e[e.BOOL_VEC2=35671]=`BOOL_VEC2`,e[e.BOOL_VEC3=35672]=`BOOL_VEC3`,e[e.BOOL_VEC4=35673]=`BOOL_VEC4`,e[e.FLOAT_MAT2=35674]=`FLOAT_MAT2`,e[e.FLOAT_MAT3=35675]=`FLOAT_MAT3`,e[e.FLOAT_MAT4=35676]=`FLOAT_MAT4`,e[e.SAMPLER_2D=35678]=`SAMPLER_2D`,e[e.SAMPLER_CUBE=35680]=`SAMPLER_CUBE`,e[e.LOW_FLOAT=36336]=`LOW_FLOAT`,e[e.MEDIUM_FLOAT=36337]=`MEDIUM_FLOAT`,e[e.HIGH_FLOAT=36338]=`HIGH_FLOAT`,e[e.LOW_INT=36339]=`LOW_INT`,e[e.MEDIUM_INT=36340]=`MEDIUM_INT`,e[e.HIGH_INT=36341]=`HIGH_INT`,e[e.FRAMEBUFFER=36160]=`FRAMEBUFFER`,e[e.RENDERBUFFER=36161]=`RENDERBUFFER`,e[e.RGBA4=32854]=`RGBA4`,e[e.RGB5_A1=32855]=`RGB5_A1`,e[e.RGB565=36194]=`RGB565`,e[e.DEPTH_COMPONENT16=33189]=`DEPTH_COMPONENT16`,e[e.STENCIL_INDEX=6401]=`STENCIL_INDEX`,e[e.STENCIL_INDEX8=36168]=`STENCIL_INDEX8`,e[e.DEPTH_STENCIL=34041]=`DEPTH_STENCIL`,e[e.RENDERBUFFER_WIDTH=36162]=`RENDERBUFFER_WIDTH`,e[e.RENDERBUFFER_HEIGHT=36163]=`RENDERBUFFER_HEIGHT`,e[e.RENDERBUFFER_INTERNAL_FORMAT=36164]=`RENDERBUFFER_INTERNAL_FORMAT`,e[e.RENDERBUFFER_RED_SIZE=36176]=`RENDERBUFFER_RED_SIZE`,e[e.RENDERBUFFER_GREEN_SIZE=36177]=`RENDERBUFFER_GREEN_SIZE`,e[e.RENDERBUFFER_BLUE_SIZE=36178]=`RENDERBUFFER_BLUE_SIZE`,e[e.RENDERBUFFER_ALPHA_SIZE=36179]=`RENDERBUFFER_ALPHA_SIZE`,e[e.RENDERBUFFER_DEPTH_SIZE=36180]=`RENDERBUFFER_DEPTH_SIZE`,e[e.RENDERBUFFER_STENCIL_SIZE=36181]=`RENDERBUFFER_STENCIL_SIZE`,e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]=`FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE`,e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]=`FRAMEBUFFER_ATTACHMENT_OBJECT_NAME`,e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]=`FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL`,e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]=`FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE`,e[e.COLOR_ATTACHMENT0=36064]=`COLOR_ATTACHMENT0`,e[e.DEPTH_ATTACHMENT=36096]=`DEPTH_ATTACHMENT`,e[e.STENCIL_ATTACHMENT=36128]=`STENCIL_ATTACHMENT`,e[e.DEPTH_STENCIL_ATTACHMENT=33306]=`DEPTH_STENCIL_ATTACHMENT`,e[e.NONE=0]=`NONE`,e[e.FRAMEBUFFER_COMPLETE=36053]=`FRAMEBUFFER_COMPLETE`,e[e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]=`FRAMEBUFFER_INCOMPLETE_ATTACHMENT`,e[e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]=`FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT`,e[e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]=`FRAMEBUFFER_INCOMPLETE_DIMENSIONS`,e[e.FRAMEBUFFER_UNSUPPORTED=36061]=`FRAMEBUFFER_UNSUPPORTED`,e[e.FRAMEBUFFER_BINDING=36006]=`FRAMEBUFFER_BINDING`,e[e.RENDERBUFFER_BINDING=36007]=`RENDERBUFFER_BINDING`,e[e.READ_FRAMEBUFFER=36008]=`READ_FRAMEBUFFER`,e[e.DRAW_FRAMEBUFFER=36009]=`DRAW_FRAMEBUFFER`,e[e.MAX_RENDERBUFFER_SIZE=34024]=`MAX_RENDERBUFFER_SIZE`,e[e.INVALID_FRAMEBUFFER_OPERATION=1286]=`INVALID_FRAMEBUFFER_OPERATION`,e[e.UNPACK_FLIP_Y_WEBGL=37440]=`UNPACK_FLIP_Y_WEBGL`,e[e.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]=`UNPACK_PREMULTIPLY_ALPHA_WEBGL`,e[e.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]=`UNPACK_COLORSPACE_CONVERSION_WEBGL`,e[e.READ_BUFFER=3074]=`READ_BUFFER`,e[e.UNPACK_ROW_LENGTH=3314]=`UNPACK_ROW_LENGTH`,e[e.UNPACK_SKIP_ROWS=3315]=`UNPACK_SKIP_ROWS`,e[e.UNPACK_SKIP_PIXELS=3316]=`UNPACK_SKIP_PIXELS`,e[e.PACK_ROW_LENGTH=3330]=`PACK_ROW_LENGTH`,e[e.PACK_SKIP_ROWS=3331]=`PACK_SKIP_ROWS`,e[e.PACK_SKIP_PIXELS=3332]=`PACK_SKIP_PIXELS`,e[e.TEXTURE_BINDING_3D=32874]=`TEXTURE_BINDING_3D`,e[e.UNPACK_SKIP_IMAGES=32877]=`UNPACK_SKIP_IMAGES`,e[e.UNPACK_IMAGE_HEIGHT=32878]=`UNPACK_IMAGE_HEIGHT`,e[e.MAX_3D_TEXTURE_SIZE=32883]=`MAX_3D_TEXTURE_SIZE`,e[e.MAX_ELEMENTS_VERTICES=33e3]=`MAX_ELEMENTS_VERTICES`,e[e.MAX_ELEMENTS_INDICES=33001]=`MAX_ELEMENTS_INDICES`,e[e.MAX_TEXTURE_LOD_BIAS=34045]=`MAX_TEXTURE_LOD_BIAS`,e[e.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]=`MAX_FRAGMENT_UNIFORM_COMPONENTS`,e[e.MAX_VERTEX_UNIFORM_COMPONENTS=35658]=`MAX_VERTEX_UNIFORM_COMPONENTS`,e[e.MAX_ARRAY_TEXTURE_LAYERS=35071]=`MAX_ARRAY_TEXTURE_LAYERS`,e[e.MIN_PROGRAM_TEXEL_OFFSET=35076]=`MIN_PROGRAM_TEXEL_OFFSET`,e[e.MAX_PROGRAM_TEXEL_OFFSET=35077]=`MAX_PROGRAM_TEXEL_OFFSET`,e[e.MAX_VARYING_COMPONENTS=35659]=`MAX_VARYING_COMPONENTS`,e[e.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]=`FRAGMENT_SHADER_DERIVATIVE_HINT`,e[e.RASTERIZER_DISCARD=35977]=`RASTERIZER_DISCARD`,e[e.VERTEX_ARRAY_BINDING=34229]=`VERTEX_ARRAY_BINDING`,e[e.MAX_VERTEX_OUTPUT_COMPONENTS=37154]=`MAX_VERTEX_OUTPUT_COMPONENTS`,e[e.MAX_FRAGMENT_INPUT_COMPONENTS=37157]=`MAX_FRAGMENT_INPUT_COMPONENTS`,e[e.MAX_SERVER_WAIT_TIMEOUT=37137]=`MAX_SERVER_WAIT_TIMEOUT`,e[e.MAX_ELEMENT_INDEX=36203]=`MAX_ELEMENT_INDEX`,e[e.RED=6403]=`RED`,e[e.RGB8=32849]=`RGB8`,e[e.RGBA8=32856]=`RGBA8`,e[e.RGB10_A2=32857]=`RGB10_A2`,e[e.TEXTURE_3D=32879]=`TEXTURE_3D`,e[e.TEXTURE_WRAP_R=32882]=`TEXTURE_WRAP_R`,e[e.TEXTURE_MIN_LOD=33082]=`TEXTURE_MIN_LOD`,e[e.TEXTURE_MAX_LOD=33083]=`TEXTURE_MAX_LOD`,e[e.TEXTURE_BASE_LEVEL=33084]=`TEXTURE_BASE_LEVEL`,e[e.TEXTURE_MAX_LEVEL=33085]=`TEXTURE_MAX_LEVEL`,e[e.TEXTURE_COMPARE_MODE=34892]=`TEXTURE_COMPARE_MODE`,e[e.TEXTURE_COMPARE_FUNC=34893]=`TEXTURE_COMPARE_FUNC`,e[e.SRGB=35904]=`SRGB`,e[e.SRGB8=35905]=`SRGB8`,e[e.SRGB8_ALPHA8=35907]=`SRGB8_ALPHA8`,e[e.COMPARE_REF_TO_TEXTURE=34894]=`COMPARE_REF_TO_TEXTURE`,e[e.RGBA32F=34836]=`RGBA32F`,e[e.RGB32F=34837]=`RGB32F`,e[e.RGBA16F=34842]=`RGBA16F`,e[e.RGB16F=34843]=`RGB16F`,e[e.TEXTURE_2D_ARRAY=35866]=`TEXTURE_2D_ARRAY`,e[e.TEXTURE_BINDING_2D_ARRAY=35869]=`TEXTURE_BINDING_2D_ARRAY`,e[e.R11F_G11F_B10F=35898]=`R11F_G11F_B10F`,e[e.RGB9_E5=35901]=`RGB9_E5`,e[e.RGBA32UI=36208]=`RGBA32UI`,e[e.RGB32UI=36209]=`RGB32UI`,e[e.RGBA16UI=36214]=`RGBA16UI`,e[e.RGB16UI=36215]=`RGB16UI`,e[e.RGBA8UI=36220]=`RGBA8UI`,e[e.RGB8UI=36221]=`RGB8UI`,e[e.RGBA32I=36226]=`RGBA32I`,e[e.RGB32I=36227]=`RGB32I`,e[e.RGBA16I=36232]=`RGBA16I`,e[e.RGB16I=36233]=`RGB16I`,e[e.RGBA8I=36238]=`RGBA8I`,e[e.RGB8I=36239]=`RGB8I`,e[e.RED_INTEGER=36244]=`RED_INTEGER`,e[e.RGB_INTEGER=36248]=`RGB_INTEGER`,e[e.RGBA_INTEGER=36249]=`RGBA_INTEGER`,e[e.R8=33321]=`R8`,e[e.RG8=33323]=`RG8`,e[e.R16F=33325]=`R16F`,e[e.R32F=33326]=`R32F`,e[e.RG16F=33327]=`RG16F`,e[e.RG32F=33328]=`RG32F`,e[e.R8I=33329]=`R8I`,e[e.R8UI=33330]=`R8UI`,e[e.R16I=33331]=`R16I`,e[e.R16UI=33332]=`R16UI`,e[e.R32I=33333]=`R32I`,e[e.R32UI=33334]=`R32UI`,e[e.RG8I=33335]=`RG8I`,e[e.RG8UI=33336]=`RG8UI`,e[e.RG16I=33337]=`RG16I`,e[e.RG16UI=33338]=`RG16UI`,e[e.RG32I=33339]=`RG32I`,e[e.RG32UI=33340]=`RG32UI`,e[e.R8_SNORM=36756]=`R8_SNORM`,e[e.RG8_SNORM=36757]=`RG8_SNORM`,e[e.RGB8_SNORM=36758]=`RGB8_SNORM`,e[e.RGBA8_SNORM=36759]=`RGBA8_SNORM`,e[e.RGB10_A2UI=36975]=`RGB10_A2UI`,e[e.TEXTURE_IMMUTABLE_FORMAT=37167]=`TEXTURE_IMMUTABLE_FORMAT`,e[e.TEXTURE_IMMUTABLE_LEVELS=33503]=`TEXTURE_IMMUTABLE_LEVELS`,e[e.UNSIGNED_INT_2_10_10_10_REV=33640]=`UNSIGNED_INT_2_10_10_10_REV`,e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]=`UNSIGNED_INT_10F_11F_11F_REV`,e[e.UNSIGNED_INT_5_9_9_9_REV=35902]=`UNSIGNED_INT_5_9_9_9_REV`,e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]=`FLOAT_32_UNSIGNED_INT_24_8_REV`,e[e.UNSIGNED_INT_24_8=34042]=`UNSIGNED_INT_24_8`,e[e.HALF_FLOAT=5131]=`HALF_FLOAT`,e[e.RG=33319]=`RG`,e[e.RG_INTEGER=33320]=`RG_INTEGER`,e[e.INT_2_10_10_10_REV=36255]=`INT_2_10_10_10_REV`,e[e.CURRENT_QUERY=34917]=`CURRENT_QUERY`,e[e.QUERY_RESULT=34918]=`QUERY_RESULT`,e[e.QUERY_RESULT_AVAILABLE=34919]=`QUERY_RESULT_AVAILABLE`,e[e.ANY_SAMPLES_PASSED=35887]=`ANY_SAMPLES_PASSED`,e[e.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]=`ANY_SAMPLES_PASSED_CONSERVATIVE`,e[e.MAX_DRAW_BUFFERS=34852]=`MAX_DRAW_BUFFERS`,e[e.DRAW_BUFFER0=34853]=`DRAW_BUFFER0`,e[e.DRAW_BUFFER1=34854]=`DRAW_BUFFER1`,e[e.DRAW_BUFFER2=34855]=`DRAW_BUFFER2`,e[e.DRAW_BUFFER3=34856]=`DRAW_BUFFER3`,e[e.DRAW_BUFFER4=34857]=`DRAW_BUFFER4`,e[e.DRAW_BUFFER5=34858]=`DRAW_BUFFER5`,e[e.DRAW_BUFFER6=34859]=`DRAW_BUFFER6`,e[e.DRAW_BUFFER7=34860]=`DRAW_BUFFER7`,e[e.DRAW_BUFFER8=34861]=`DRAW_BUFFER8`,e[e.DRAW_BUFFER9=34862]=`DRAW_BUFFER9`,e[e.DRAW_BUFFER10=34863]=`DRAW_BUFFER10`,e[e.DRAW_BUFFER11=34864]=`DRAW_BUFFER11`,e[e.DRAW_BUFFER12=34865]=`DRAW_BUFFER12`,e[e.DRAW_BUFFER13=34866]=`DRAW_BUFFER13`,e[e.DRAW_BUFFER14=34867]=`DRAW_BUFFER14`,e[e.DRAW_BUFFER15=34868]=`DRAW_BUFFER15`,e[e.MAX_COLOR_ATTACHMENTS=36063]=`MAX_COLOR_ATTACHMENTS`,e[e.COLOR_ATTACHMENT1=36065]=`COLOR_ATTACHMENT1`,e[e.COLOR_ATTACHMENT2=36066]=`COLOR_ATTACHMENT2`,e[e.COLOR_ATTACHMENT3=36067]=`COLOR_ATTACHMENT3`,e[e.COLOR_ATTACHMENT4=36068]=`COLOR_ATTACHMENT4`,e[e.COLOR_ATTACHMENT5=36069]=`COLOR_ATTACHMENT5`,e[e.COLOR_ATTACHMENT6=36070]=`COLOR_ATTACHMENT6`,e[e.COLOR_ATTACHMENT7=36071]=`COLOR_ATTACHMENT7`,e[e.COLOR_ATTACHMENT8=36072]=`COLOR_ATTACHMENT8`,e[e.COLOR_ATTACHMENT9=36073]=`COLOR_ATTACHMENT9`,e[e.COLOR_ATTACHMENT10=36074]=`COLOR_ATTACHMENT10`,e[e.COLOR_ATTACHMENT11=36075]=`COLOR_ATTACHMENT11`,e[e.COLOR_ATTACHMENT12=36076]=`COLOR_ATTACHMENT12`,e[e.COLOR_ATTACHMENT13=36077]=`COLOR_ATTACHMENT13`,e[e.COLOR_ATTACHMENT14=36078]=`COLOR_ATTACHMENT14`,e[e.COLOR_ATTACHMENT15=36079]=`COLOR_ATTACHMENT15`,e[e.SAMPLER_3D=35679]=`SAMPLER_3D`,e[e.SAMPLER_2D_SHADOW=35682]=`SAMPLER_2D_SHADOW`,e[e.SAMPLER_2D_ARRAY=36289]=`SAMPLER_2D_ARRAY`,e[e.SAMPLER_2D_ARRAY_SHADOW=36292]=`SAMPLER_2D_ARRAY_SHADOW`,e[e.SAMPLER_CUBE_SHADOW=36293]=`SAMPLER_CUBE_SHADOW`,e[e.INT_SAMPLER_2D=36298]=`INT_SAMPLER_2D`,e[e.INT_SAMPLER_3D=36299]=`INT_SAMPLER_3D`,e[e.INT_SAMPLER_CUBE=36300]=`INT_SAMPLER_CUBE`,e[e.INT_SAMPLER_2D_ARRAY=36303]=`INT_SAMPLER_2D_ARRAY`,e[e.UNSIGNED_INT_SAMPLER_2D=36306]=`UNSIGNED_INT_SAMPLER_2D`,e[e.UNSIGNED_INT_SAMPLER_3D=36307]=`UNSIGNED_INT_SAMPLER_3D`,e[e.UNSIGNED_INT_SAMPLER_CUBE=36308]=`UNSIGNED_INT_SAMPLER_CUBE`,e[e.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]=`UNSIGNED_INT_SAMPLER_2D_ARRAY`,e[e.MAX_SAMPLES=36183]=`MAX_SAMPLES`,e[e.SAMPLER_BINDING=35097]=`SAMPLER_BINDING`,e[e.PIXEL_PACK_BUFFER=35051]=`PIXEL_PACK_BUFFER`,e[e.PIXEL_UNPACK_BUFFER=35052]=`PIXEL_UNPACK_BUFFER`,e[e.PIXEL_PACK_BUFFER_BINDING=35053]=`PIXEL_PACK_BUFFER_BINDING`,e[e.PIXEL_UNPACK_BUFFER_BINDING=35055]=`PIXEL_UNPACK_BUFFER_BINDING`,e[e.COPY_READ_BUFFER=36662]=`COPY_READ_BUFFER`,e[e.COPY_WRITE_BUFFER=36663]=`COPY_WRITE_BUFFER`,e[e.COPY_READ_BUFFER_BINDING=36662]=`COPY_READ_BUFFER_BINDING`,e[e.COPY_WRITE_BUFFER_BINDING=36663]=`COPY_WRITE_BUFFER_BINDING`,e[e.FLOAT_MAT2x3=35685]=`FLOAT_MAT2x3`,e[e.FLOAT_MAT2x4=35686]=`FLOAT_MAT2x4`,e[e.FLOAT_MAT3x2=35687]=`FLOAT_MAT3x2`,e[e.FLOAT_MAT3x4=35688]=`FLOAT_MAT3x4`,e[e.FLOAT_MAT4x2=35689]=`FLOAT_MAT4x2`,e[e.FLOAT_MAT4x3=35690]=`FLOAT_MAT4x3`,e[e.UNSIGNED_INT_VEC2=36294]=`UNSIGNED_INT_VEC2`,e[e.UNSIGNED_INT_VEC3=36295]=`UNSIGNED_INT_VEC3`,e[e.UNSIGNED_INT_VEC4=36296]=`UNSIGNED_INT_VEC4`,e[e.UNSIGNED_NORMALIZED=35863]=`UNSIGNED_NORMALIZED`,e[e.SIGNED_NORMALIZED=36764]=`SIGNED_NORMALIZED`,e[e.VERTEX_ATTRIB_ARRAY_INTEGER=35069]=`VERTEX_ATTRIB_ARRAY_INTEGER`,e[e.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]=`VERTEX_ATTRIB_ARRAY_DIVISOR`,e[e.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]=`TRANSFORM_FEEDBACK_BUFFER_MODE`,e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]=`MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS`,e[e.TRANSFORM_FEEDBACK_VARYINGS=35971]=`TRANSFORM_FEEDBACK_VARYINGS`,e[e.TRANSFORM_FEEDBACK_BUFFER_START=35972]=`TRANSFORM_FEEDBACK_BUFFER_START`,e[e.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]=`TRANSFORM_FEEDBACK_BUFFER_SIZE`,e[e.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]=`TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN`,e[e.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]=`MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS`,e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]=`MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS`,e[e.INTERLEAVED_ATTRIBS=35980]=`INTERLEAVED_ATTRIBS`,e[e.SEPARATE_ATTRIBS=35981]=`SEPARATE_ATTRIBS`,e[e.TRANSFORM_FEEDBACK_BUFFER=35982]=`TRANSFORM_FEEDBACK_BUFFER`,e[e.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]=`TRANSFORM_FEEDBACK_BUFFER_BINDING`,e[e.TRANSFORM_FEEDBACK=36386]=`TRANSFORM_FEEDBACK`,e[e.TRANSFORM_FEEDBACK_PAUSED=36387]=`TRANSFORM_FEEDBACK_PAUSED`,e[e.TRANSFORM_FEEDBACK_ACTIVE=36388]=`TRANSFORM_FEEDBACK_ACTIVE`,e[e.TRANSFORM_FEEDBACK_BINDING=36389]=`TRANSFORM_FEEDBACK_BINDING`,e[e.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]=`FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING`,e[e.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]=`FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE`,e[e.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]=`FRAMEBUFFER_ATTACHMENT_RED_SIZE`,e[e.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]=`FRAMEBUFFER_ATTACHMENT_GREEN_SIZE`,e[e.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]=`FRAMEBUFFER_ATTACHMENT_BLUE_SIZE`,e[e.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]=`FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE`,e[e.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]=`FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE`,e[e.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]=`FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE`,e[e.FRAMEBUFFER_DEFAULT=33304]=`FRAMEBUFFER_DEFAULT`,e[e.DEPTH24_STENCIL8=35056]=`DEPTH24_STENCIL8`,e[e.DRAW_FRAMEBUFFER_BINDING=36006]=`DRAW_FRAMEBUFFER_BINDING`,e[e.READ_FRAMEBUFFER_BINDING=36010]=`READ_FRAMEBUFFER_BINDING`,e[e.RENDERBUFFER_SAMPLES=36011]=`RENDERBUFFER_SAMPLES`,e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]=`FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER`,e[e.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]=`FRAMEBUFFER_INCOMPLETE_MULTISAMPLE`,e[e.UNIFORM_BUFFER=35345]=`UNIFORM_BUFFER`,e[e.UNIFORM_BUFFER_BINDING=35368]=`UNIFORM_BUFFER_BINDING`,e[e.UNIFORM_BUFFER_START=35369]=`UNIFORM_BUFFER_START`,e[e.UNIFORM_BUFFER_SIZE=35370]=`UNIFORM_BUFFER_SIZE`,e[e.MAX_VERTEX_UNIFORM_BLOCKS=35371]=`MAX_VERTEX_UNIFORM_BLOCKS`,e[e.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]=`MAX_FRAGMENT_UNIFORM_BLOCKS`,e[e.MAX_COMBINED_UNIFORM_BLOCKS=35374]=`MAX_COMBINED_UNIFORM_BLOCKS`,e[e.MAX_UNIFORM_BUFFER_BINDINGS=35375]=`MAX_UNIFORM_BUFFER_BINDINGS`,e[e.MAX_UNIFORM_BLOCK_SIZE=35376]=`MAX_UNIFORM_BLOCK_SIZE`,e[e.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]=`MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS`,e[e.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]=`MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS`,e[e.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]=`UNIFORM_BUFFER_OFFSET_ALIGNMENT`,e[e.ACTIVE_UNIFORM_BLOCKS=35382]=`ACTIVE_UNIFORM_BLOCKS`,e[e.UNIFORM_TYPE=35383]=`UNIFORM_TYPE`,e[e.UNIFORM_SIZE=35384]=`UNIFORM_SIZE`,e[e.UNIFORM_BLOCK_INDEX=35386]=`UNIFORM_BLOCK_INDEX`,e[e.UNIFORM_OFFSET=35387]=`UNIFORM_OFFSET`,e[e.UNIFORM_ARRAY_STRIDE=35388]=`UNIFORM_ARRAY_STRIDE`,e[e.UNIFORM_MATRIX_STRIDE=35389]=`UNIFORM_MATRIX_STRIDE`,e[e.UNIFORM_IS_ROW_MAJOR=35390]=`UNIFORM_IS_ROW_MAJOR`,e[e.UNIFORM_BLOCK_BINDING=35391]=`UNIFORM_BLOCK_BINDING`,e[e.UNIFORM_BLOCK_DATA_SIZE=35392]=`UNIFORM_BLOCK_DATA_SIZE`,e[e.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]=`UNIFORM_BLOCK_ACTIVE_UNIFORMS`,e[e.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]=`UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES`,e[e.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]=`UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER`,e[e.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]=`UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER`,e[e.OBJECT_TYPE=37138]=`OBJECT_TYPE`,e[e.SYNC_CONDITION=37139]=`SYNC_CONDITION`,e[e.SYNC_STATUS=37140]=`SYNC_STATUS`,e[e.SYNC_FLAGS=37141]=`SYNC_FLAGS`,e[e.SYNC_FENCE=37142]=`SYNC_FENCE`,e[e.SYNC_GPU_COMMANDS_COMPLETE=37143]=`SYNC_GPU_COMMANDS_COMPLETE`,e[e.UNSIGNALED=37144]=`UNSIGNALED`,e[e.SIGNALED=37145]=`SIGNALED`,e[e.ALREADY_SIGNALED=37146]=`ALREADY_SIGNALED`,e[e.TIMEOUT_EXPIRED=37147]=`TIMEOUT_EXPIRED`,e[e.CONDITION_SATISFIED=37148]=`CONDITION_SATISFIED`,e[e.WAIT_FAILED=37149]=`WAIT_FAILED`,e[e.SYNC_FLUSH_COMMANDS_BIT=1]=`SYNC_FLUSH_COMMANDS_BIT`,e[e.COLOR=6144]=`COLOR`,e[e.DEPTH=6145]=`DEPTH`,e[e.STENCIL=6146]=`STENCIL`,e[e.MIN=32775]=`MIN`,e[e.MAX=32776]=`MAX`,e[e.DEPTH_COMPONENT24=33190]=`DEPTH_COMPONENT24`,e[e.STREAM_READ=35041]=`STREAM_READ`,e[e.STREAM_COPY=35042]=`STREAM_COPY`,e[e.STATIC_READ=35045]=`STATIC_READ`,e[e.STATIC_COPY=35046]=`STATIC_COPY`,e[e.DYNAMIC_READ=35049]=`DYNAMIC_READ`,e[e.DYNAMIC_COPY=35050]=`DYNAMIC_COPY`,e[e.DEPTH_COMPONENT32F=36012]=`DEPTH_COMPONENT32F`,e[e.DEPTH32F_STENCIL8=36013]=`DEPTH32F_STENCIL8`,e[e.INVALID_INDEX=4294967295]=`INVALID_INDEX`,e[e.TIMEOUT_IGNORED=-1]=`TIMEOUT_IGNORED`,e[e.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]=`MAX_CLIENT_WAIT_TIMEOUT_WEBGL`,e[e.UNMASKED_VENDOR_WEBGL=37445]=`UNMASKED_VENDOR_WEBGL`,e[e.UNMASKED_RENDERER_WEBGL=37446]=`UNMASKED_RENDERER_WEBGL`,e[e.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]=`MAX_TEXTURE_MAX_ANISOTROPY_EXT`,e[e.TEXTURE_MAX_ANISOTROPY_EXT=34046]=`TEXTURE_MAX_ANISOTROPY_EXT`,e[e.R16_EXT=33322]=`R16_EXT`,e[e.RG16_EXT=33324]=`RG16_EXT`,e[e.RGB16_EXT=32852]=`RGB16_EXT`,e[e.RGBA16_EXT=32859]=`RGBA16_EXT`,e[e.R16_SNORM_EXT=36760]=`R16_SNORM_EXT`,e[e.RG16_SNORM_EXT=36761]=`RG16_SNORM_EXT`,e[e.RGB16_SNORM_EXT=36762]=`RGB16_SNORM_EXT`,e[e.RGBA16_SNORM_EXT=36763]=`RGBA16_SNORM_EXT`,e[e.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]=`COMPRESSED_RGB_S3TC_DXT1_EXT`,e[e.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]=`COMPRESSED_RGBA_S3TC_DXT1_EXT`,e[e.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]=`COMPRESSED_RGBA_S3TC_DXT3_EXT`,e[e.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]=`COMPRESSED_RGBA_S3TC_DXT5_EXT`,e[e.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]=`COMPRESSED_SRGB_S3TC_DXT1_EXT`,e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]=`COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT`,e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]=`COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT`,e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]=`COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT`,e[e.COMPRESSED_RED_RGTC1_EXT=36283]=`COMPRESSED_RED_RGTC1_EXT`,e[e.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]=`COMPRESSED_SIGNED_RED_RGTC1_EXT`,e[e.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]=`COMPRESSED_RED_GREEN_RGTC2_EXT`,e[e.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]=`COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT`,e[e.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]=`COMPRESSED_RGBA_BPTC_UNORM_EXT`,e[e.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]=`COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT`,e[e.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]=`COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT`,e[e.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]=`COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT`,e[e.COMPRESSED_R11_EAC=37488]=`COMPRESSED_R11_EAC`,e[e.COMPRESSED_SIGNED_R11_EAC=37489]=`COMPRESSED_SIGNED_R11_EAC`,e[e.COMPRESSED_RG11_EAC=37490]=`COMPRESSED_RG11_EAC`,e[e.COMPRESSED_SIGNED_RG11_EAC=37491]=`COMPRESSED_SIGNED_RG11_EAC`,e[e.COMPRESSED_RGB8_ETC2=37492]=`COMPRESSED_RGB8_ETC2`,e[e.COMPRESSED_RGBA8_ETC2_EAC=37493]=`COMPRESSED_RGBA8_ETC2_EAC`,e[e.COMPRESSED_SRGB8_ETC2=37494]=`COMPRESSED_SRGB8_ETC2`,e[e.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]=`COMPRESSED_SRGB8_ALPHA8_ETC2_EAC`,e[e.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]=`COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2`,e[e.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]=`COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2`,e[e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]=`COMPRESSED_RGB_PVRTC_4BPPV1_IMG`,e[e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]=`COMPRESSED_RGBA_PVRTC_4BPPV1_IMG`,e[e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]=`COMPRESSED_RGB_PVRTC_2BPPV1_IMG`,e[e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]=`COMPRESSED_RGBA_PVRTC_2BPPV1_IMG`,e[e.COMPRESSED_RGB_ETC1_WEBGL=36196]=`COMPRESSED_RGB_ETC1_WEBGL`,e[e.COMPRESSED_RGB_ATC_WEBGL=35986]=`COMPRESSED_RGB_ATC_WEBGL`,e[e.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]=`COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL`,e[e.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]=`COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL`,e[e.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]=`COMPRESSED_RGBA_ASTC_4x4_KHR`,e[e.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]=`COMPRESSED_RGBA_ASTC_5x4_KHR`,e[e.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]=`COMPRESSED_RGBA_ASTC_5x5_KHR`,e[e.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]=`COMPRESSED_RGBA_ASTC_6x5_KHR`,e[e.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]=`COMPRESSED_RGBA_ASTC_6x6_KHR`,e[e.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]=`COMPRESSED_RGBA_ASTC_8x5_KHR`,e[e.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]=`COMPRESSED_RGBA_ASTC_8x6_KHR`,e[e.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]=`COMPRESSED_RGBA_ASTC_8x8_KHR`,e[e.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]=`COMPRESSED_RGBA_ASTC_10x5_KHR`,e[e.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]=`COMPRESSED_RGBA_ASTC_10x6_KHR`,e[e.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]=`COMPRESSED_RGBA_ASTC_10x8_KHR`,e[e.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]=`COMPRESSED_RGBA_ASTC_10x10_KHR`,e[e.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]=`COMPRESSED_RGBA_ASTC_12x10_KHR`,e[e.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]=`COMPRESSED_RGBA_ASTC_12x12_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]=`COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]=`COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]=`COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]=`COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]=`COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]=`COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]=`COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]=`COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]=`COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]=`COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]=`COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]=`COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]=`COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR`,e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]=`COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR`,e[e.QUERY_COUNTER_BITS_EXT=34916]=`QUERY_COUNTER_BITS_EXT`,e[e.CURRENT_QUERY_EXT=34917]=`CURRENT_QUERY_EXT`,e[e.QUERY_RESULT_EXT=34918]=`QUERY_RESULT_EXT`,e[e.QUERY_RESULT_AVAILABLE_EXT=34919]=`QUERY_RESULT_AVAILABLE_EXT`,e[e.TIME_ELAPSED_EXT=35007]=`TIME_ELAPSED_EXT`,e[e.TIMESTAMP_EXT=36392]=`TIMESTAMP_EXT`,e[e.GPU_DISJOINT_EXT=36795]=`GPU_DISJOINT_EXT`,e[e.COMPLETION_STATUS_KHR=37297]=`COMPLETION_STATUS_KHR`,e[e.DEPTH_CLAMP_EXT=34383]=`DEPTH_CLAMP_EXT`,e[e.FIRST_VERTEX_CONVENTION_WEBGL=36429]=`FIRST_VERTEX_CONVENTION_WEBGL`,e[e.LAST_VERTEX_CONVENTION_WEBGL=36430]=`LAST_VERTEX_CONVENTION_WEBGL`,e[e.PROVOKING_VERTEX_WEBL=36431]=`PROVOKING_VERTEX_WEBL`,e[e.POLYGON_MODE_WEBGL=2880]=`POLYGON_MODE_WEBGL`,e[e.POLYGON_OFFSET_LINE_WEBGL=10754]=`POLYGON_OFFSET_LINE_WEBGL`,e[e.LINE_WEBGL=6913]=`LINE_WEBGL`,e[e.FILL_WEBGL=6914]=`FILL_WEBGL`,e[e.MAX_CLIP_DISTANCES_WEBGL=3378]=`MAX_CLIP_DISTANCES_WEBGL`,e[e.MAX_CULL_DISTANCES_WEBGL=33529]=`MAX_CULL_DISTANCES_WEBGL`,e[e.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]=`MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL`,e[e.CLIP_DISTANCE0_WEBGL=12288]=`CLIP_DISTANCE0_WEBGL`,e[e.CLIP_DISTANCE1_WEBGL=12289]=`CLIP_DISTANCE1_WEBGL`,e[e.CLIP_DISTANCE2_WEBGL=12290]=`CLIP_DISTANCE2_WEBGL`,e[e.CLIP_DISTANCE3_WEBGL=12291]=`CLIP_DISTANCE3_WEBGL`,e[e.CLIP_DISTANCE4_WEBGL=12292]=`CLIP_DISTANCE4_WEBGL`,e[e.CLIP_DISTANCE5_WEBGL=12293]=`CLIP_DISTANCE5_WEBGL`,e[e.CLIP_DISTANCE6_WEBGL=12294]=`CLIP_DISTANCE6_WEBGL`,e[e.CLIP_DISTANCE7_WEBGL=12295]=`CLIP_DISTANCE7_WEBGL`,e[e.POLYGON_OFFSET_CLAMP_EXT=36379]=`POLYGON_OFFSET_CLAMP_EXT`,e[e.LOWER_LEFT_EXT=36001]=`LOWER_LEFT_EXT`,e[e.UPPER_LEFT_EXT=36002]=`UPPER_LEFT_EXT`,e[e.NEGATIVE_ONE_TO_ONE_EXT=37726]=`NEGATIVE_ONE_TO_ONE_EXT`,e[e.ZERO_TO_ONE_EXT=37727]=`ZERO_TO_ONE_EXT`,e[e.CLIP_ORIGIN_EXT=37724]=`CLIP_ORIGIN_EXT`,e[e.CLIP_DEPTH_MODE_EXT=37725]=`CLIP_DEPTH_MODE_EXT`,e[e.SRC1_COLOR_WEBGL=35065]=`SRC1_COLOR_WEBGL`,e[e.SRC1_ALPHA_WEBGL=34185]=`SRC1_ALPHA_WEBGL`,e[e.ONE_MINUS_SRC1_COLOR_WEBGL=35066]=`ONE_MINUS_SRC1_COLOR_WEBGL`,e[e.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]=`ONE_MINUS_SRC1_ALPHA_WEBGL`,e[e.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]=`MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL`,e[e.MIRROR_CLAMP_TO_EDGE_EXT=34627]=`MIRROR_CLAMP_TO_EDGE_EXT`})(ek||={});var tk={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},nk=e=>({drawBuffersWEBGL(t){return e.drawBuffers(t)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),rk=e=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return e.createVertexArray()},deleteVertexArrayOES(t){return e.deleteVertexArray(t)},isVertexArrayOES(t){return e.isVertexArray(t)},bindVertexArrayOES(t){return e.bindVertexArray(t)}}),ik=e=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...t){return e.drawArraysInstanced(...t)},drawElementsInstancedANGLE(...t){return e.drawElementsInstanced(...t)},vertexAttribDivisorANGLE(...t){return e.vertexAttribDivisor(...t)}});function ak(e=!0){let t=HTMLCanvasElement.prototype;if(!e&&t.originalGetContext){t.getContext=t.originalGetContext,t.originalGetContext=void 0;return}t.originalGetContext=t.getContext,t.getContext=function(e,t){if(e===`webgl`||e===`experimental-webgl`){let e=this.originalGetContext(`webgl2`,t);return e instanceof HTMLElement&&ok(e),e}return this.originalGetContext(e,t)}}function ok(e){e.getExtension(`EXT_color_buffer_float`);let t={...tk,WEBGL_disjoint_timer_query:e.getExtension(`EXT_disjoint_timer_query_webgl2`),WEBGL_draw_buffers:nk(e),OES_vertex_array_object:rk(e),ANGLE_instanced_arrays:ik(e)},n=e.getExtension;e.getExtension=function(r){return n.call(e,r)||(r in t?t[r]:null)};let r=e.getSupportedExtensions;e.getSupportedExtensions=function(){return(r.apply(e)||[])?.concat(Object.keys(t))}}async function sk(e,t){let n=document.getElementsByTagName(`head`)[0];if(!n)throw Error(`loadScript`);let r=document.createElement(`script`);return r.setAttribute(`type`,`text/javascript`),r.setAttribute(`src`,e),t&&(r.id=t),new Promise((t,i)=>{r.onload=t,r.onerror=t=>i(Error(`Unable to load script '${e}': ${t}`)),n.appendChild(r)})}function ck(e){let t=e.luma||{_polyfilled:!1,extensions:{},softwareRenderer:!1};return t._polyfilled??=!1,t.extensions||={},e.luma=t,t}var lk=1,uk=null,dk=!1,fk={debugSpectorJS:Z.get(`debug-spectorjs`),debugSpectorJSUrl:`https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js`,gl:void 0};async function pk(e){if(!globalThis.SPECTOR)try{await sk(e.debugSpectorJSUrl||fk.debugSpectorJSUrl)}catch(e){Z.warn(String(e))}}function mk(e){if(e={...fk,...e},!e.debugSpectorJS)return null;if(!uk&&globalThis.SPECTOR&&!globalThis.luma?.spector){Z.probe(lk,"SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();let{Spector:e}=globalThis.SPECTOR;uk=new e,globalThis.luma&&(globalThis.luma.spector=uk)}if(!uk)return null;if(dk||(dk=!0,uk.spyCanvases(),uk?.onCaptureStarted.add(e=>Z.info(`Spector capture started:`,e)()),uk?.onCapture.add(e=>{Z.info(`Spector capture complete:`,e)(),uk?.getResultUI(),uk?.resultView.display(),uk?.resultView.addCapture(e)})),e.gl){let t=e.gl,n=ck(t),r=n.device;uk?.startCapture(e.gl,500),n.device=r,new Promise(e=>setTimeout(e,2e3)).then(e=>{Z.info(`Spector capture stopped after 2 seconds`)(),uk?.stopCapture()})}return uk}var hk=`https://unpkg.com/webgl-debug@2.0.1/index.js`;function gk(e){return e.luma=e.luma||{},e.luma}async function _k(){fd()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await sk(hk))}function vk(e,t={}){return t.debugWebGL||t.traceWebGL?bk(e,t):yk(e)}function yk(e){let t=gk(e);return t.realContext?t.realContext:e}function bk(e,t){if(!globalThis.WebGLDebugUtils)return Z.warn(`webgl-debug not loaded`)(),e;let n=gk(e);if(n.debugContext)return n.debugContext;globalThis.WebGLDebugUtils.init({...ek,...e});let r=globalThis.WebGLDebugUtils.makeDebugContext(e,Sk.bind(null,t),Ck.bind(null,t));for(let e in ek)!(e in r)&&typeof ek[e]==`number`&&(r[e]=ek[e]);class i{}Object.setPrototypeOf(r,Object.getPrototypeOf(e)),Object.setPrototypeOf(i,r);let a=Object.create(i);return n.realContext=e,n.debugContext=a,a.luma=n,a.debug=!0,a}function xk(e,t){t=Array.from(t).map(e=>e===void 0?`undefined`:e);let n=globalThis.WebGLDebugUtils.glFunctionArgsToString(e,t);return n=`${n.slice(0,100)}${n.length>100?`...`:``}`,`gl.${e}(${n})`}function Sk(e,t,n,r){r=Array.from(r).map(e=>e===void 0?`undefined`:e);let i=`${globalThis.WebGLDebugUtils.glEnumToString(t)} in gl.${n}(${globalThis.WebGLDebugUtils.glFunctionArgsToString(n,r)})`;throw Z.error(`%cWebGL`,`color: white; background: red; padding: 2px 6px; border-radius: 3px;`,i)(),Error(i)}function Ck(e,t,n){let r=``;e.traceWebGL&&Z.level>=1&&(r=xk(t,n),Z.info(1,`%cWebGL`,`color: white; background: blue; padding: 2px 6px; border-radius: 3px;`,r)());for(let e of n)e===void 0&&(r||=xk(t,n))}var wk=`modulepreload`,Tk=function(e,t){return new URL(e,t).href},Ek={},Dk=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=Tk(t,n),t in Ek)return;Ek[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`:wk,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)})},Ok=1,kk=class extends Eb{type=`webgl`;constructor(){super(),yb.defaultProps={...yb.defaultProps,...fk}}enforceWebGL2(e){ak(e)}isSupported(){return typeof WebGL2RenderingContext<`u`}isDeviceHandle(e){return typeof WebGL2RenderingContext<`u`&&e instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<`u`&&e instanceof WebGLRenderingContext&&Z.warn(`WebGL1 is not supported`,e)(),!1)}async attach(e,t={}){let{WebGLDevice:n}=await Dk(async()=>{let{WebGLDevice:e}=await Promise.resolve().then(()=>vM);return{WebGLDevice:e}},void 0,import.meta.url);if(e instanceof n)return e;let r=n.getDeviceFromContext(e);if(r)return r;if(!Ak(e))throw Error(`Invalid WebGL2RenderingContext`);let i=t.createCanvasContext===!0?{}:t.createCanvasContext;return new n({...t,_handle:e,createCanvasContext:{canvas:e.canvas,autoResize:!1,...i}})}async create(e={}){let{WebGLDevice:t}=await Dk(async()=>{let{WebGLDevice:e}=await Promise.resolve().then(()=>vM);return{WebGLDevice:e}},void 0,import.meta.url),n=[];(e.debugWebGL||e.debug)&&n.push(_k()),e.debugSpectorJS&&n.push(pk(e));let r=await Promise.allSettled(n);for(let e of r)e.status===`rejected`&&Z.error(`Failed to initialize debug libraries ${e.reason}`)();try{let n=new t(e);Z.groupCollapsed(Ok,`WebGLDevice ${n.id} created`)();let r=`\
|
|
2086
2086
|
${n._reused?`Reusing`:`Created`} device with WebGL2 ${n.props.debug?`debug `:``}context: \
|
|
2087
|
-
${n.info.vendor}, ${n.info.renderer} for canvas: ${n.canvasContext.id}`;return Z.probe(xk,r)(),Z.table(xk,n.info)(),n}finally{Z.groupEnd(xk)(),Z.info(xk,`%cWebGL call tracing: luma.log.set('debug-webgl') `,`color: white; background: blue; padding: 2px 6px; border-radius: 3px;`)()}}};function Ck(e){return typeof WebGL2RenderingContext<`u`&&e instanceof WebGL2RenderingContext?!0:!!(e&&typeof e.createVertexArray==`function`)}var wk=new Sk,Tk={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,35725:null,36006:null,36007:null,34229:null,34964:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32926:!1,32928:!1,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],36389:null,36662:null,36663:null,35053:null,35055:null,35723:4352,36010:null,35977:!1,3333:4,3317:4,37440:!1,37441:!1,37443:37444,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},Ek=(e,t,n)=>t?e.enable(n):e.disable(n),Dk=(e,t,n)=>e.hint(n,t),Ok=(e,t,n)=>e.pixelStorei(n,t),kk=(e,t,n)=>{let r=n===36006?36009:36008;return e.bindFramebuffer(r,t)},Ak=(e,t,n)=>{let r={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[n];e.bindBuffer(r,t)};function jk(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}var Mk={3042:Ek,32773:(e,t)=>e.blendColor(...t),32777:`blendEquation`,34877:`blendEquation`,32969:`blendFunc`,32968:`blendFunc`,32971:`blendFunc`,32970:`blendFunc`,3106:(e,t)=>e.clearColor(...t),3107:(e,t)=>e.colorMask(...t),2884:Ek,2885:(e,t)=>e.cullFace(t),2929:Ek,2931:(e,t)=>e.clearDepth(t),2932:(e,t)=>e.depthFunc(t),2928:(e,t)=>e.depthRange(...t),2930:(e,t)=>e.depthMask(t),3024:Ek,35723:Dk,35725:(e,t)=>e.useProgram(t),36007:(e,t)=>e.bindRenderbuffer(36161,t),36389:(e,t)=>e.bindTransformFeedback?.(36386,t),34229:(e,t)=>e.bindVertexArray(t),36006:kk,36010:kk,34964:Ak,36662:Ak,36663:Ak,35053:Ak,35055:Ak,2886:(e,t)=>e.frontFace(t),33170:Dk,2849:(e,t)=>e.lineWidth(t),32823:Ek,32824:`polygonOffset`,10752:`polygonOffset`,35977:Ek,32926:Ek,32928:Ek,32938:`sampleCoverage`,32939:`sampleCoverage`,3089:Ek,3088:(e,t)=>e.scissor(...t),2960:Ek,2961:(e,t)=>e.clearStencil(t),2968:(e,t)=>e.stencilMaskSeparate(1028,t),36005:(e,t)=>e.stencilMaskSeparate(1029,t),2962:`stencilFuncFront`,2967:`stencilFuncFront`,2963:`stencilFuncFront`,34816:`stencilFuncBack`,36003:`stencilFuncBack`,36004:`stencilFuncBack`,2964:`stencilOpFront`,2965:`stencilOpFront`,2966:`stencilOpFront`,34817:`stencilOpBack`,34818:`stencilOpBack`,34819:`stencilOpBack`,2978:(e,t)=>e.viewport(...t),34383:Ek,10754:Ek,12288:Ek,12289:Ek,12290:Ek,12291:Ek,12292:Ek,12293:Ek,12294:Ek,12295:Ek,3333:Ok,3317:Ok,37440:Ok,37441:Ok,37443:Ok,3330:Ok,3332:Ok,3331:Ok,3314:Ok,32878:Ok,3316:Ok,3315:Ok,32877:Ok,framebuffer:(e,t)=>{let n=t&&`handle`in t?t.handle:t;return e.bindFramebuffer(36160,n)},blend:(e,t)=>t?e.enable(3042):e.disable(3042),blendColor:(e,t)=>e.blendColor(...t),blendEquation:(e,t)=>{let n=typeof t==`number`?[t,t]:t;e.blendEquationSeparate(...n)},blendFunc:(e,t)=>{let n=t?.length===2?[...t,...t]:t;e.blendFuncSeparate(...n)},clearColor:(e,t)=>e.clearColor(...t),clearDepth:(e,t)=>e.clearDepth(t),clearStencil:(e,t)=>e.clearStencil(t),colorMask:(e,t)=>e.colorMask(...t),cull:(e,t)=>t?e.enable(2884):e.disable(2884),cullFace:(e,t)=>e.cullFace(t),depthTest:(e,t)=>t?e.enable(2929):e.disable(2929),depthFunc:(e,t)=>e.depthFunc(t),depthMask:(e,t)=>e.depthMask(t),depthRange:(e,t)=>e.depthRange(...t),dither:(e,t)=>t?e.enable(3024):e.disable(3024),derivativeHint:(e,t)=>{e.hint(35723,t)},frontFace:(e,t)=>e.frontFace(t),mipmapHint:(e,t)=>e.hint(33170,t),lineWidth:(e,t)=>e.lineWidth(t),polygonOffsetFill:(e,t)=>t?e.enable(32823):e.disable(32823),polygonOffset:(e,t)=>e.polygonOffset(...t),sampleCoverage:(e,t)=>e.sampleCoverage(t[0],t[1]||!1),scissorTest:(e,t)=>t?e.enable(3089):e.disable(3089),scissor:(e,t)=>e.scissor(...t),stencilTest:(e,t)=>t?e.enable(2960):e.disable(2960),stencilMask:(e,t)=>{t=jk(t)?t:[t,t];let[n,r]=t;e.stencilMaskSeparate(1028,n),e.stencilMaskSeparate(1029,r)},stencilFunc:(e,t)=>{t=jk(t)&&t.length===3?[...t,...t]:t;let[n,r,i,a,o,s]=t;e.stencilFuncSeparate(1028,n,r,i),e.stencilFuncSeparate(1029,a,o,s)},stencilOp:(e,t)=>{t=jk(t)&&t.length===3?[...t,...t]:t;let[n,r,i,a,o,s]=t;e.stencilOpSeparate(1028,n,r,i),e.stencilOpSeparate(1029,a,o,s)},viewport:(e,t)=>e.viewport(...t)};function Nk(e,t,n){return t[e]===void 0?n[e]:t[e]}var Pk={blendEquation:(e,t,n)=>e.blendEquationSeparate(Nk(32777,t,n),Nk(34877,t,n)),blendFunc:(e,t,n)=>e.blendFuncSeparate(Nk(32969,t,n),Nk(32968,t,n),Nk(32971,t,n),Nk(32970,t,n)),polygonOffset:(e,t,n)=>e.polygonOffset(Nk(32824,t,n),Nk(10752,t,n)),sampleCoverage:(e,t,n)=>e.sampleCoverage(Nk(32938,t,n),Nk(32939,t,n)),stencilFuncFront:(e,t,n)=>e.stencilFuncSeparate(1028,Nk(2962,t,n),Nk(2967,t,n),Nk(2963,t,n)),stencilFuncBack:(e,t,n)=>e.stencilFuncSeparate(1029,Nk(34816,t,n),Nk(36003,t,n),Nk(36004,t,n)),stencilOpFront:(e,t,n)=>e.stencilOpSeparate(1028,Nk(2964,t,n),Nk(2965,t,n),Nk(2966,t,n)),stencilOpBack:(e,t,n)=>e.stencilOpSeparate(1029,Nk(34817,t,n),Nk(34818,t,n),Nk(34819,t,n))},Fk={enable:(e,t)=>e({[t]:!0}),disable:(e,t)=>e({[t]:!1}),pixelStorei:(e,t,n)=>e({[t]:n}),hint:(e,t,n)=>e({[t]:n}),useProgram:(e,t)=>e({35725:t}),bindRenderbuffer:(e,t,n)=>e({36007:n}),bindTransformFeedback:(e,t,n)=>e({36389:n}),bindVertexArray:(e,t)=>e({34229:t}),bindFramebuffer:(e,t,n)=>{switch(t){case 36160:return e({36006:n,36010:n});case 36009:return e({36006:n});case 36008:return e({36010:n});default:return null}},bindBuffer:(e,t,n)=>{let r={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[t];return r?e({[r]:n}):{valueChanged:!0}},blendColor:(e,t,n,r,i)=>e({32773:new Float32Array([t,n,r,i])}),blendEquation:(e,t)=>e({32777:t,34877:t}),blendEquationSeparate:(e,t,n)=>e({32777:t,34877:n}),blendFunc:(e,t,n)=>e({32969:t,32968:n,32971:t,32970:n}),blendFuncSeparate:(e,t,n,r,i)=>e({32969:t,32968:n,32971:r,32970:i}),clearColor:(e,t,n,r,i)=>e({3106:new Float32Array([t,n,r,i])}),clearDepth:(e,t)=>e({2931:t}),clearStencil:(e,t)=>e({2961:t}),colorMask:(e,t,n,r,i)=>e({3107:[t,n,r,i]}),cullFace:(e,t)=>e({2885:t}),depthFunc:(e,t)=>e({2932:t}),depthRange:(e,t,n)=>e({2928:new Float32Array([t,n])}),depthMask:(e,t)=>e({2930:t}),frontFace:(e,t)=>e({2886:t}),lineWidth:(e,t)=>e({2849:t}),polygonOffset:(e,t,n)=>e({32824:t,10752:n}),sampleCoverage:(e,t,n)=>e({32938:t,32939:n}),scissor:(e,t,n,r,i)=>e({3088:new Int32Array([t,n,r,i])}),stencilMask:(e,t)=>e({2968:t,36005:t}),stencilMaskSeparate:(e,t,n)=>e({[t===1028?2968:36005]:n}),stencilFunc:(e,t,n,r)=>e({2962:t,2967:n,2963:r,34816:t,36003:n,36004:r}),stencilFuncSeparate:(e,t,n,r,i)=>e({[t===1028?2962:34816]:n,[t===1028?2967:36003]:r,[t===1028?2963:36004]:i}),stencilOp:(e,t,n,r)=>e({2964:t,2965:n,2966:r,34817:t,34818:n,34819:r}),stencilOpSeparate:(e,t,n,r,i)=>e({[t===1028?2964:34817]:n,[t===1028?2965:34818]:r,[t===1028?2966:34819]:i}),viewport:(e,t,n,r,i)=>e({2978:[t,n,r,i]})},Ik=(e,t)=>e.isEnabled(t),Lk={3042:Ik,2884:Ik,2929:Ik,3024:Ik,32823:Ik,32926:Ik,32928:Ik,3089:Ik,2960:Ik,35977:Ik},Rk=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068]);function zk(e,t){if(Hk(t))return;let n={};for(let r in t){let i=Number(r),a=Mk[r];a&&(typeof a==`string`?n[a]=!0:a(e,t[r],i))}let r=e.lumaState?.cache;if(r)for(let i in n){let n=Pk[i];n(e,t,r)}}function Bk(e,t=Tk){if(typeof t==`number`){let n=t,r=Lk[n];return r?r(e,n):e.getParameter(n)}let n=Array.isArray(t)?t:Object.keys(t),r={};for(let t of n){let n=Lk[t];r[t]=n?n(e,Number(t)):e.getParameter(Number(t))}return r}function Vk(e){zk(e,Tk)}function Hk(e){for(let t in e)return!1;return!0}function Uk(e,t){if(e===t)return!0;if(Wk(e)&&Wk(t)&&e.length===t.length){for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}return!1}function Wk(e){return Array.isArray(e)||ArrayBuffer.isView(e)}var Gk=class{static get(e){return e.lumaState}gl;program=null;stateStack=[];enable=!0;cache=null;log;initialized=!1;constructor(e,t){this.gl=e,this.log=t?.log||(()=>{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){let e=this.stateStack[this.stateStack.length-1];zk(this.gl,e),this.stateStack.pop()}trackState(e,t){if(this.cache=t?.copyState?Bk(e):Object.assign({},Tk),this.initialized)throw Error(`WebGLStateTracker`);this.initialized=!0,this.gl.lumaState=this,Jk(e);for(let t in Fk){let n=Fk[t];qk(e,t,n)}Kk(e,`getParameter`),Kk(e,`isEnabled`)}_updateCache(e){let t=!1,n,r=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let i in e){let a=e[i],o=this.cache[i];Uk(a,o)||(t=!0,n=o,r&&!(i in r)&&(r[i]=o),this.cache[i]=a)}return{valueChanged:t,oldValue:n}}};function Kk(e,t){let n=e[t].bind(e);e[t]=function(t){if(t===void 0||Rk.has(t))return n(t);let r=Gk.get(e);return t in r.cache||(r.cache[t]=n(t)),r.enable?r.cache[t]:n(t)},Object.defineProperty(e[t],"name",{value:`${t}-from-cache`,configurable:!1})}function qk(e,t,n){if(!e[t])return;let r=e[t].bind(e);e[t]=function(...t){let{valueChanged:i,oldValue:a}=n(Gk.get(e)._updateCache,...t);return i&&r(...t),a},Object.defineProperty(e[t],"name",{value:`${t}-to-cache`,configurable:!1})}function Jk(e){let t=e.useProgram.bind(e);e.useProgram=function(n){let r=Gk.get(e);r.program!==n&&(t(n),r.program=n)}}function Yk(e,t,n){let r=``,i=e=>{let t=e.statusMessage;t&&(r||=t)};e.addEventListener(`webglcontextcreationerror`,i,!1);let a=n.failIfMajorPerformanceCaveat!==!0,o={preserveDrawingBuffer:!0,...n,failIfMajorPerformanceCaveat:!0},s=null;try{s||=e.getContext(`webgl2`,o),!s&&o.failIfMajorPerformanceCaveat&&(r||="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.");let n=!1;if(!s&&a&&(o.failIfMajorPerformanceCaveat=!1,s=e.getContext(`webgl2`,o),n=!0),s||(s=e.getContext(`webgl`,{}),s&&(s=null,r||=`Your browser only supports WebGL1`)),!s)throw r||=`Your browser does not support WebGL`,Error(`Failed to create WebGL context: ${r}`);let i=tk(s);i.softwareRenderer=n;let{onContextLost:c,onContextRestored:l}=t;return e.addEventListener(`webglcontextlost`,e=>c(e),!1),e.addEventListener(`webglcontextrestored`,e=>l(e),!1),s}finally{e.removeEventListener(`webglcontextcreationerror`,i,!1)}}function Xk(e,t,n){return n[t]===void 0&&(n[t]=e.getExtension(t)||null),n[t]}function Zk(e,t){let n=e.getParameter(7936),r=e.getParameter(7937);Xk(e,`WEBGL_debug_renderer_info`,t);let i=t.WEBGL_debug_renderer_info,a=e.getParameter(i?i.UNMASKED_VENDOR_WEBGL:7936),o=e.getParameter(i?i.UNMASKED_RENDERER_WEBGL:7937),s=a||n,c=o||r,l=e.getParameter(7938),u=Qk(s,c),d=$k(s,c);return{type:`webgl`,gpu:u,gpuType:eA(s,c),gpuBackend:d,vendor:s,renderer:c,version:l,shadingLanguage:`glsl`,shadingLanguageVersion:300}}function Qk(e,t){return/NVIDIA/i.exec(e)||/NVIDIA/i.exec(t)?`nvidia`:/INTEL/i.exec(e)||/INTEL/i.exec(t)?`intel`:/Apple/i.exec(e)||/Apple/i.exec(t)?`apple`:/AMD/i.exec(e)||/AMD/i.exec(t)||/ATI/i.exec(e)||/ATI/i.exec(t)?`amd`:/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t)?`software`:`unknown`}function $k(e,t){return/Metal/i.exec(e)||/Metal/i.exec(t)?`metal`:/ANGLE/i.exec(e)||/ANGLE/i.exec(t)?`opengl`:`unknown`}function eA(e,t){if(/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t))return`cpu`;switch(Qk(e,t)){case`apple`:return tA(e,t)?`integrated`:`unknown`;case`intel`:return`integrated`;case`software`:return`cpu`;case`unknown`:return`unknown`;default:return`discrete`}}function tA(e,t){return/Apple (M\d|A\d|GPU)/i.test(`${e} ${t}`)}function nA(e){switch(e){case`uint8`:return 5121;case`sint8`:return 5120;case`unorm8`:return 5121;case`snorm8`:return 5120;case`uint16`:return 5123;case`sint16`:return 5122;case`unorm16`:return 5123;case`snorm16`:return 5122;case`uint32`:return 5125;case`sint32`:return 5124;case`float16`:return 5131;case`float32`:return 5126}throw Error(String(e))}var rA=`WEBGL_compressed_texture_s3tc`,iA=`WEBGL_compressed_texture_s3tc_srgb`,aA=`EXT_texture_compression_rgtc`,oA=`EXT_texture_compression_bptc`,sA=`WEBGL_compressed_texture_etc`,cA=`WEBGL_compressed_texture_astc`,lA=`WEBGL_compressed_texture_etc1`,uA=`WEBGL_compressed_texture_pvrtc`,dA=`WEBGL_compressed_texture_atc`,fA=`EXT_texture_norm16`,pA=`EXT_render_snorm`,mA=`EXT_color_buffer_float`,hA=`snorm8-renderable-webgl`,gA=`norm16-renderable-webgl`,_A=`snorm16-renderable-webgl`,vA=`float16-renderable-webgl`,yA=`float32-renderable-webgl`,bA=`rgb9e5ufloat-renderable-webgl`,xA={"float32-renderable-webgl":{extensions:[mA]},"float16-renderable-webgl":{extensions:[`EXT_color_buffer_half_float`]},"rgb9e5ufloat-renderable-webgl":{extensions:[`WEBGL_render_shared_exponent`]},"snorm8-renderable-webgl":{extensions:[pA]},"norm16-webgl":{extensions:[fA]},"norm16-renderable-webgl":{features:[`norm16-webgl`]},"snorm16-renderable-webgl":{features:[`norm16-webgl`],extensions:[pA]},"float32-filterable":{extensions:[`OES_texture_float_linear`]},"float16-filterable-webgl":{extensions:[`OES_texture_half_float_linear`]},"texture-filterable-anisotropic-webgl":{extensions:[`EXT_texture_filter_anisotropic`]},"texture-blend-float-webgl":{extensions:[`EXT_float_blend`]},"texture-compression-bc":{extensions:[rA,iA,aA,oA]},"texture-compression-bc5-webgl":{extensions:[aA]},"texture-compression-bc7-webgl":{extensions:[oA]},"texture-compression-etc2":{extensions:[sA]},"texture-compression-astc":{extensions:[cA]},"texture-compression-etc1-webgl":{extensions:[lA]},"texture-compression-pvrtc-webgl":{extensions:[uA]},"texture-compression-atc-webgl":{extensions:[dA]}};function SA(e){return e in xA}function CA(e,t,n){return wA(e,t,n,new Set)}function wA(e,t,n,r){let i=xA[t];if(!i||r.has(t))return!1;r.add(t);let a=(i.features||[]).every(t=>wA(e,t,n,r));return r.delete(t),a?(i.extensions||[]).every(t=>!!Xk(e,t,n)):!1}var TA={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756,r:hA},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757,r:hA},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0,r:vA},r16unorm:{gl:33322,rb:!0,r:gA},r16snorm:{gl:36760,r:_A},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759,r:hA},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0,r:vA},rg16unorm:{gl:33324,r:gA},rg16snorm:{gl:36761,r:_A},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326,r:yA},rgb9e5ufloat:{gl:35901,r:bA},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852,r:!1},"rgb16snorm-webgl":{gl:36762,r:!1},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0,r:yA},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842,r:vA},rgba16unorm:{gl:32859,rb:!0,r:gA},rgba16snorm:{gl:36763,r:_A},"rgb32float-webgl":{gl:34837,x:mA,r:yA,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0,r:yA},stencil8:{gl:36168,rb:!0},depth16unorm:{gl:33189,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,dataFormat:6402,types:[5125]},depth32float:{gl:36012,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth32float-stencil8":{gl:36013,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:rA},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:iA},"bc1-rgba-unorm":{gl:33777,x:rA},"bc1-rgba-unorm-srgb":{gl:35916,x:iA},"bc2-rgba-unorm":{gl:33778,x:rA},"bc2-rgba-unorm-srgb":{gl:35918,x:iA},"bc3-rgba-unorm":{gl:33779,x:rA},"bc3-rgba-unorm-srgb":{gl:35919,x:iA},"bc4-r-unorm":{gl:36283,x:aA},"bc4-r-snorm":{gl:36284,x:aA},"bc5-rg-unorm":{gl:36285,x:aA},"bc5-rg-snorm":{gl:36286,x:aA},"bc6h-rgb-ufloat":{gl:36495,x:oA},"bc6h-rgb-float":{gl:36494,x:oA},"bc7-rgba-unorm":{gl:36492,x:oA},"bc7-rgba-unorm-srgb":{gl:36493,x:oA},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37816},"astc-10x5-unorm-srgb":{gl:37848},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rgb2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}};function EA(e,t,n){let r=t.create,i=TA[t.format];i?.gl===void 0&&(r=!1),i?.x&&(r&&=!!Xk(e,i.x,n)),t.format===`stencil8`&&(r=!1);let a=i?.r===!1?!1:i?.r===void 0||CA(e,i.r,n),o=r&&t.render&&a&&DA(e,t.format,n);return{format:t.format,create:r&&t.create,render:o,filter:r&&t.filter,blend:r&&t.blend,store:r&&t.store}}function DA(e,t,n){let r=TA[t],i=r?.gl;if(i===void 0||r?.x&&!Xk(e,r.x,n))return!1;let a=e.getParameter(32873),o=e.getParameter(36006),s=e.createTexture(),c=e.createFramebuffer();if(!s||!c)return!1;let l=Number(e.getError());for(;l!==0;)l=e.getError();let u=!1;try{if(e.bindTexture(3553,s),e.texStorage2D(3553,1,i,1,1),Number(e.getError())!==0)return!1;e.bindFramebuffer(36160,c),e.framebufferTexture2D(36160,36064,3553,s,0),u=Number(e.checkFramebufferStatus(36160))===36053&&Number(e.getError())===0}finally{e.bindFramebuffer(36160,o),e.deleteFramebuffer(c),e.bindTexture(3553,a),e.deleteTexture(s)}return u}function OA(e){let t=TA[e],n=jA(e),r=Xy.getInfo(e);return r.compressed&&(t.dataFormat=n),{internalFormat:n,format:t?.dataFormat||AA(r.channels,r.integer,r.normalized,n),type:r.dataType?nA(r.dataType):t?.types?.[0]||5121,compressed:r.compressed||!1}}function kA(e){switch(Xy.getInfo(e).attachment){case`depth`:return 36096;case`stencil`:return 36128;case`depth-stencil`:return 33306;default:throw Error(`Not a depth stencil format: ${e}`)}}function AA(e,t,n,r){if(r===6408||r===6407)return r;switch(e){case`r`:return t&&!n?36244:6403;case`rg`:return t&&!n?33320:33319;case`rgb`:return t&&!n?36248:6407;case`rgba`:return t&&!n?36249:6408;case`bgra`:throw Error(`bgra pixels not supported by WebGL`);default:return 6408}}function jA(e){let t=TA[e]?.gl;if(t===void 0)throw Error(`Unsupported texture format ${e}`);return t}var MA={"depth-clip-control":`EXT_depth_clamp`,"timestamp-query":`EXT_disjoint_timer_query_webgl2`,"compilation-status-async-webgl":`KHR_parallel_shader_compile`,"polygon-mode-webgl":`WEBGL_polygon_mode`,"provoking-vertex-webgl":`WEBGL_provoking_vertex`,"shader-clip-cull-distance-webgl":`WEBGL_clip_cull_distance`,"shader-noperspective-interpolation-webgl":`NV_shader_noperspective_interpolation`,"shader-conservative-depth-webgl":`EXT_conservative_depth`},NA=class extends db{gl;extensions;testedFeatures=new Set;constructor(e,t,n){super([],n),this.gl=e,this.extensions=t,Xk(e,`EXT_color_buffer_float`,t)}*[Symbol.iterator](){let e=this.getFeatures();for(let t of e)this.has(t)&&(yield t);return[]}has(e){return this.disabledFeatures?.[e]?!1:(this.testedFeatures.has(e)||(this.testedFeatures.add(e),SA(e)&&CA(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){let e=this.getFeatures().filter(e=>e!==`polygon-mode-webgl`);for(let t of e)this.has(t)}getFeatures(){return[...Object.keys(MA),...Object.keys(xA)]}getWebGLFeature(e){let t=MA[e];return typeof t==`string`?!!Xk(this.gl,t,this.extensions):!!t}},PA=class extends ab{get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderVariables(){return this.getParameter(35659)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(e){super(),this.gl=e}getParameter(e){return this.limits[e]===void 0&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]||0}},FA=class extends Xb{device;gl;handle;colorAttachments=[];depthStencilAttachment=null;constructor(e,t){super(e,t);let n=t.handle===null;this.device=e,this.gl=e.gl,this.handle=this.props.handle||n?this.props.handle:this.gl.createFramebuffer(),n||(e._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),t.handle||(this.autoCreateAttachmentTextures(),this.updateAttachments()))}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&!this.props.handle&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){let e=this.gl.bindFramebuffer(36160,this.handle);for(let e=0;e<this.colorAttachments.length;++e){let t=this.colorAttachments[e];if(t){let n=36064+e;this._attachTextureView(n,t)}}if(this.depthStencilAttachment){let e=kA(this.depthStencilAttachment.props.format);this._attachTextureView(e,this.depthStencilAttachment)}if(this.device.props.debug){let e=this.gl.checkFramebufferStatus(36160);if(e!==36053)throw Error(`Framebuffer ${LA(e)}`)}this.gl.bindFramebuffer(36160,e)}_attachTextureView(e,t){let{gl:n}=this.device,{texture:r}=t,i=t.props.baseMipLevel,a=t.props.baseArrayLayer;switch(n.bindTexture(r.glTarget,r.handle),r.glTarget){case 35866:case 32879:n.framebufferTextureLayer(36160,e,r.handle,i,a);break;case 34067:let t=IA(a);n.framebufferTexture2D(36160,e,t,r.handle,i);break;case 3553:n.framebufferTexture2D(36160,e,3553,r.handle,i);break;default:throw Error(`Illegal texture type`)}n.bindTexture(r.glTarget,null)}resizeAttachments(e,t){if(this.handle===null){this.width=e,this.height=t;return}super.resizeAttachments(e,t)}};function IA(e){return e<34069?e+34069:e}function LA(e){switch(e){case 36053:return`success`;case 36054:return`Mismatched attachments`;case 36055:return`No attachments`;case 36057:return`Height/width mismatch`;case 36061:return`Unsupported or split attachments`;case 36182:return`Samples mismatch`;default:return`${e}`}}var RA=class extends Fb{device;handle=null;_framebuffer=null;get[Symbol.toStringTag](){return`WebGLCanvasContext`}constructor(e,t){super(t),this.device=e,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this._configureDevice()}_configureDevice(){(this.drawingBufferWidth!==this._framebuffer?.width||this.drawingBufferHeight!==this._framebuffer?.height)&&this._framebuffer?.resize([this.drawingBufferWidth,this.drawingBufferHeight])}_getCurrentFramebuffer(){return this._framebuffer||=new FA(this.device,{id:`canvas-context-framebuffer`,handle:null,width:this.drawingBufferWidth,height:this.drawingBufferHeight}),this._framebuffer}},zA=class extends Ib{device;handle=null;context2d;get[Symbol.toStringTag](){return`WebGLPresentationContext`}constructor(e,t={}){super(t),this.device=e;let n=`${this[Symbol.toStringTag]}(${this.id})`;if(!this.device.getDefaultCanvasContext().offscreenCanvas)throw Error(`${n}: WebGL PresentationContext requires the default CanvasContext canvas to be an OffscreenCanvas`);let r=this.canvas.getContext(`2d`);if(!r)throw Error(`${n}: Failed to create 2d presentation context`);this.context2d=r,this._setAutoCreatedCanvasId(`${this.device.id}-presentation-canvas`),this._configureDevice(),this._startObservers()}present(){this._resizeDrawingBufferIfNeeded(),this.device.submit();let e=this.device.getDefaultCanvasContext(),[t,n]=e.getDrawingBufferSize();if(!(this.drawingBufferWidth===0||this.drawingBufferHeight===0||t===0||n===0||e.canvas.width===0||e.canvas.height===0)){if(t!==this.drawingBufferWidth||n!==this.drawingBufferHeight||e.canvas.width!==this.drawingBufferWidth||e.canvas.height!==this.drawingBufferHeight)throw Error(`${this[Symbol.toStringTag]}(${this.id}): Default canvas context size ${t}x${n} does not match presentation size ${this.drawingBufferWidth}x${this.drawingBufferHeight}`);this.context2d.clearRect(0,0,this.drawingBufferWidth,this.drawingBufferHeight),this.context2d.drawImage(e.canvas,0,0)}}_configureDevice(){}_getCurrentFramebuffer(e){let t=this.device.getDefaultCanvasContext();return t.setDrawingBufferSize(this.drawingBufferWidth,this.drawingBufferHeight),t.getCurrentFramebuffer(e)}},BA={};function VA(e=`id`){return BA[e]=BA[e]||1,`${e}-${BA[e]++}`}var HA=class extends Sy{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength=0;bytesUsed=0;constructor(e,t={}){super(e,t),this.device=e,this.gl=this.device.gl;let n=typeof t==`object`?t.handle:void 0;this.handle=n||this.gl.createBuffer(),e._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=UA(this.props.usage),this.glUsage=WA(this.props.usage),this.glIndexType=this.props.indexType===`uint32`?5125:5123,t.data?this._initWithData(t.data,t.byteOffset,t.byteLength):this._initWithByteLength(t.byteLength||0)}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory(`Buffer`):(this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle)),this.destroyed=!0,this.handle=null)}_initWithData(e,t=0,n=e.byteLength+t){let r=this.glTarget;this.gl.bindBuffer(r,this.handle),this.gl.bufferData(r,n,this.glUsage),this.gl.bufferSubData(r,t,e),this.gl.bindBuffer(r,null),this.bytesUsed=n,this.byteLength=n,this._setDebugData(e,t,n),this.props.handle?this.trackReferencedMemory(n,`Buffer`):this.trackAllocatedMemory(n)}_initWithByteLength(e){let t=e;e===0&&(t=new Float32Array);let n=this.glTarget;return this.gl.bindBuffer(n,this.handle),this.gl.bufferData(n,t,this.glUsage),this.gl.bindBuffer(n,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.props.handle?this.trackReferencedMemory(e,`Buffer`):this.trackAllocatedMemory(e),this}write(e,t=0){let n=ArrayBuffer.isView(e)?e:new Uint8Array(e),r=36663;this.gl.bindBuffer(r,this.handle),this.gl.bufferSubData(r,t,n),this.gl.bindBuffer(r,null),this._setDebugData(e,t,e.byteLength)}async mapAndWriteAsync(e,t=0,n=this.byteLength-t){let r=new ArrayBuffer(n);await e(r,`copied`),this.write(r,t)}async readAsync(e=0,t){return this.readSyncWebGL(e,t)}async mapAndReadAsync(e,t=0,n){return await e((await this.readAsync(t,n)).buffer,`copied`)}readSyncWebGL(e=0,t){t??=this.byteLength-e;let n=new Uint8Array(t);return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,n,0,t),this.gl.bindBuffer(36662,null),this._setDebugData(n,e,t),n}};function UA(e){return e&Sy.INDEX?34963:e&Sy.VERTEX?34962:e&Sy.UNIFORM?35345:34962}function WA(e){return e&Sy.INDEX||e&Sy.VERTEX?35044:e&Sy.UNIFORM?35048:35044}function GA(e){let t=e.split(/\r?\n/),n=[];for(let e of t){if(e.length<=1)continue;let t=e.trim(),r=e.split(`:`),i=r[0]?.trim();if(r.length===2){let[e,a]=r;if(!e||!a){n.push({message:t,type:KA(i||`info`),lineNum:0,linePos:0});continue}n.push({message:a.trim(),type:KA(e),lineNum:0,linePos:0});continue}let[a,o,s,...c]=r;if(!a||!o||!s){n.push({message:r.slice(1).join(`:`).trim()||t,type:KA(i||`info`),lineNum:0,linePos:0});continue}let l=parseInt(s,10);Number.isNaN(l)&&(l=0);let u=parseInt(o,10);Number.isNaN(u)&&(u=0),n.push({message:c.join(`:`).trim(),type:KA(a),lineNum:l,linePos:u})}return n}function KA(e){let t=[`warning`,`error`,`info`],n=e.toLowerCase();return t.includes(n)?n:`info`}var qA=class extends qb{device;handle;constructor(e,t){switch(super(e,t),this.device=e,this.props.stage){case`vertex`:this.handle=this.props.handle||this.device.gl.createShader(35633);break;case`fragment`:this.handle=this.props.handle||this.device.gl.createShader(35632);break;default:throw Error(this.props.stage)}e._setWebGLDebugMetadata(this.handle,this,{spector:this.props});let n=this._compile(this.source);n&&typeof n.catch==`function`&&n.catch(()=>{this.compilationStatus=`error`})}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.destroyed=!0)}get asyncCompilationStatus(){return this._waitForCompilationComplete().then(()=>(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let e=this.device.gl.getShaderInfoLog(this.handle);return e?GA(e):[]}getTranslatedSource(){return this.device.getExtension(`WEBGL_debug_shaders`).WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)||null}_compile(e){e=e.startsWith(`#version `)?e:`#version 300 es\n${e}`;let{gl:t}=this.device;if(t.shaderSource(this.handle,e),t.compileShader(this.handle),!this.device.props.debug){this.compilationStatus=`pending`;return}if(!this.device.features.has(`compilation-status-async-webgl`)){if(this._getCompilationStatus(),this.debugShader(),this.compilationStatus===`error`)throw Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);return}return Z.once(1,`Shader compilation is asynchronous`)(),this._waitForCompilationComplete().then(()=>{Z.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()})}async _waitForCompilationComplete(){let e=async e=>await new Promise(t=>setTimeout(t,e));if(!this.device.features.has(`compilation-status-async-webgl`)){await e(10);return}let{gl:t}=this.device;for(;;){if(t.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?`success`:`error`}};function JA(e,t,n,r){if(rj(t))return r(e);let i=e;i.pushState();try{return YA(e,t),zk(i.gl,n),r(e)}finally{i.popState()}}function YA(e,t){let n=e,{gl:r}=n;if(t.cullMode)switch(t.cullMode){case`none`:r.disable(2884);break;case`front`:r.enable(2884),r.cullFace(1028);break;case`back`:r.enable(2884),r.cullFace(1029);break}if(t.frontFace&&r.frontFace(tj(`frontFace`,t.frontFace,{ccw:2305,cw:2304})),t.unclippedDepth&&e.features.has(`depth-clip-control`)&&r.enable(34383),t.depthBias!==void 0&&(r.enable(32823),r.polygonOffset(t.depthBias,t.depthBiasSlopeScale||0)),t.provokingVertex&&e.features.has(`provoking-vertex-webgl`)){let e=n.getExtension(`WEBGL_provoking_vertex`).WEBGL_provoking_vertex,r=tj(`provokingVertex`,t.provokingVertex,{first:36429,last:36430});e?.provokingVertexWEBGL(r)}if((t.polygonMode||t.polygonOffsetLine)&&e.features.has(`polygon-mode-webgl`)){if(t.polygonMode){let e=n.getExtension(`WEBGL_polygon_mode`).WEBGL_polygon_mode,r=tj(`polygonMode`,t.polygonMode,{fill:6914,line:6913});e?.polygonModeWEBGL(1028,r),e?.polygonModeWEBGL(1029,r)}t.polygonOffsetLine&&r.enable(10754)}if(e.features.has(`shader-clip-cull-distance-webgl`)&&(t.clipDistance0&&r.enable(12288),t.clipDistance1&&r.enable(12289),t.clipDistance2&&r.enable(12290),t.clipDistance3&&r.enable(12291),t.clipDistance4&&r.enable(12292),t.clipDistance5&&r.enable(12293),t.clipDistance6&&r.enable(12294),t.clipDistance7&&r.enable(12295)),t.depthWriteEnabled!==void 0&&r.depthMask(nj(`depthWriteEnabled`,t.depthWriteEnabled)),t.depthCompare&&(t.depthCompare===`always`?r.disable(2929):r.enable(2929),r.depthFunc(XA(`depthCompare`,t.depthCompare))),t.clearDepth!==void 0&&r.clearDepth(t.clearDepth),t.stencilWriteMask){let e=t.stencilWriteMask;r.stencilMaskSeparate(1028,e),r.stencilMaskSeparate(1029,e)}if(t.stencilReadMask&&Z.warn(`stencilReadMask not supported under WebGL`),t.stencilCompare){let e=t.stencilReadMask||4294967295,n=XA(`depthCompare`,t.stencilCompare);t.stencilCompare===`always`?r.disable(2960):r.enable(2960),r.stencilFuncSeparate(1028,n,0,e),r.stencilFuncSeparate(1029,n,0,e)}if(t.stencilPassOperation&&t.stencilFailOperation&&t.stencilDepthFailOperation){let e=ZA(`stencilPassOperation`,t.stencilPassOperation),n=ZA(`stencilFailOperation`,t.stencilFailOperation),i=ZA(`stencilDepthFailOperation`,t.stencilDepthFailOperation);r.stencilOpSeparate(1028,n,i,e),r.stencilOpSeparate(1029,n,i,e)}switch(t.blend){case!0:r.enable(3042);break;case!1:r.disable(3042);break;default:}if(t.blendColorOperation||t.blendAlphaOperation){let e=QA(`blendColorOperation`,t.blendColorOperation||`add`),n=QA(`blendAlphaOperation`,t.blendAlphaOperation||`add`);r.blendEquationSeparate(e,n);let i=$A(`blendColorSrcFactor`,t.blendColorSrcFactor||`one`),a=$A(`blendColorDstFactor`,t.blendColorDstFactor||`zero`),o=$A(`blendAlphaSrcFactor`,t.blendAlphaSrcFactor||`one`),s=$A(`blendAlphaDstFactor`,t.blendAlphaDstFactor||`zero`);r.blendFuncSeparate(i,a,o,s)}}function XA(e,t){return tj(e,t,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function ZA(e,t){return tj(e,t,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function QA(e,t){return tj(e,t,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function $A(e,t,n=`color`){return tj(e,t,{one:1,zero:0,src:768,"one-minus-src":769,dst:774,"one-minus-dst":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,constant:n===`color`?32769:32771,"one-minus-constant":n===`color`?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function ej(e,t){return`Illegal parameter ${t} for ${e}`}function tj(e,t,n){if(!(t in n))throw Error(ej(e,t));return n[t]}function nj(e,t){return t}function rj(e){let t=!0;for(let n in e){t=!1;break}return t}function ij(e){let t={};return e.addressModeU&&(t[10242]=aj(e.addressModeU)),e.addressModeV&&(t[10243]=aj(e.addressModeV)),e.addressModeW&&(t[32882]=aj(e.addressModeW)),e.magFilter&&(t[10240]=oj(e.magFilter)),(e.minFilter||e.mipmapFilter)&&(t[10241]=sj(e.minFilter||`linear`,e.mipmapFilter)),e.lodMinClamp!==void 0&&(t[33082]=e.lodMinClamp),e.lodMaxClamp!==void 0&&(t[33083]=e.lodMaxClamp),e.type===`comparison-sampler`&&(t[34892]=34894),e.compare&&(t[34893]=XA(`compare`,e.compare)),e.maxAnisotropy&&(t[34046]=e.maxAnisotropy),t}function aj(e){switch(e){case`clamp-to-edge`:return 33071;case`repeat`:return 10497;case`mirror-repeat`:return 33648}}function oj(e){switch(e){case`nearest`:return 9728;case`linear`:return 9729}}function sj(e,t=`none`){if(!t)return oj(e);switch(t){case`none`:return oj(e);case`nearest`:switch(e){case`nearest`:return 9984;case`linear`:return 9985}break;case`linear`:switch(e){case`nearest`:return 9986;case`linear`:return 9987}}}var cj=class extends Lb{device;handle;parameters;constructor(e,t){super(e,t),this.device=e,this.parameters=ij(t),this.handle=t.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&=(this.device.gl.deleteSampler(this.handle),void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(e){for(let[t,n]of Object.entries(e)){let e=Number(t);switch(e){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,e,n);break;default:this.device.gl.samplerParameteri(this.handle,e,n);break}}}};function lj(e,t,n){if(uj(t))return n(e);let{nocatch:r=!0}=t,i=Gk.get(e);i.push(),zk(e,t);let a;if(r)a=n(e),i.pop();else try{a=n(e)}finally{i.pop()}return a}function uj(e){for(let t in e)return!1;return!0}var dj=class extends Bb{device;gl;handle;texture;constructor(e,t){super(e,{...zb.defaultProps,...t}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=t.texture}};function fj(e){return pj[e]}var pj={5124:`sint32`,5125:`uint32`,5122:`sint16`,5123:`uint16`,5120:`sint8`,5121:`uint8`,5126:`float32`,5131:`float16`,33635:`uint16`,32819:`uint16`,32820:`uint16`,33640:`uint32`,35899:`uint32`,35902:`uint32`,34042:`uint32`,36269:`uint32`},mj=class extends zb{device;gl;handle;sampler=void 0;view;glTarget;glFormat;glType;glInternalFormat;compressed;_textureUnit=0;_framebuffer=null;_framebufferAttachmentKey=null;constructor(e,t){super(e,t,{byteAlignment:1}),this.device=e,this.gl=this.device.gl;let n=OA(this.props.format);this.glTarget=_j(this.props.dimension),this.glInternalFormat=n.internalFormat,this.glFormat=n.format,this.glType=n.type,this.compressed=n.compressed,this.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this.gl.bindTexture(this.glTarget,this.handle);let{dimension:r,width:i,height:a,depth:o,mipLevels:s,glTarget:c,glInternalFormat:l}=this;if(!this.compressed)switch(r){case`2d`:case`cube`:this.gl.texStorage2D(c,s,l,i,a);break;case`2d-array`:case`3d`:this.gl.texStorage3D(c,s,l,i,a,o);break;default:throw Error(r)}this.gl.bindTexture(this.glTarget,null),this._initializeData(t.data),this.props.handle?this.trackReferencedMemory(this.getAllocatedByteLength(),`Texture`):this.trackAllocatedMemory(this.getAllocatedByteLength(),`Texture`),this.setSampler(this.props.sampler),this.view=new dj(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this._framebuffer?.destroy(),this._framebuffer=null,this._framebufferAttachmentKey=null,this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory(`Texture`):(this.gl.deleteTexture(this.handle),this.trackDeallocatedMemory(`Texture`)),this.destroyed=!0)}createView(e){return new dj(this.device,{...e,texture:this})}setSampler(e={}){super.setSampler(e);let t=ij(this.sampler.props);this._setSamplerParameters(t)}copyExternalImage(e){let t=this._normalizeCopyExternalImageOptions(e);if(t.sourceX||t.sourceY)throw Error(`WebGL does not support sourceX/sourceY)`);let{glFormat:n,glType:r}=this,{image:i,depth:a,mipLevel:o,x:s,y:c,z:l,width:u,height:d}=t,f=vj(this.glTarget,this.dimension,l),p=t.flipY?{37440:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),lj(this.gl,p,()=>{switch(this.dimension){case`2d`:case`cube`:this.gl.texSubImage2D(f,o,s,c,u,d,n,r,i);break;case`2d-array`:case`3d`:this.gl.texSubImage3D(f,o,s,c,l,u,d,a,n,r,i);break;default:}}),this.gl.bindTexture(this.glTarget,null),{width:t.width,height:t.height}}copyImageData(e){super.copyImageData(e)}readBuffer(e={},t){if(!t)throw Error(`${this} readBuffer requires a destination buffer`);let n=this._getSupportedColorReadOptions(e),r=e.byteOffset??0,i=this.computeMemoryLayout(n);if(t.byteLength<r+i.byteLength)throw Error(`${this} readBuffer target is too small (${t.byteLength} < ${r+i.byteLength})`);let a=t;this.gl.bindBuffer(35051,a.handle);try{this._readColorTextureLayers(n,i,e=>{this.gl.readPixels(n.x,n.y,n.width,n.height,this.glFormat,this.glType,r+e)})}finally{this.gl.bindBuffer(35051,null)}return t}async readDataAsync(e={}){throw Error(`${this} readDataAsync is deprecated; use readBuffer() with an explicit destination buffer or DynamicTexture.readAsync()`)}writeBuffer(e,t={}){let n=this._normalizeTextureWriteOptions(t),{width:r,height:i,depthOrArrayLayers:a,mipLevel:o,byteOffset:s,x:c,y:l,z:u}=n,{glFormat:d,glType:f,compressed:p}=this,m=vj(this.glTarget,this.dimension,u);if(p)throw Error(`writeBuffer for compressed textures is not implemented in WebGL`);let{bytesPerPixel:h}=this.device.getTextureFormatInfo(this.format),g=h?n.bytesPerRow/h:void 0,_={3317:this.byteAlignment,...g===void 0?{}:{3314:g},32878:n.rowsPerImage};this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,e.handle),lj(this.gl,_,()=>{switch(this.dimension){case`2d`:case`cube`:this.gl.texSubImage2D(m,o,c,l,r,i,d,f,s);break;case`2d-array`:case`3d`:this.gl.texSubImage3D(m,o,c,l,u,r,i,a,d,f,s);break;default:}}),this.gl.bindBuffer(35052,null),this.gl.bindTexture(this.glTarget,null)}writeData(e,t={}){let n=this._normalizeTextureWriteOptions(t),r=ArrayBuffer.isView(e)?e:new Uint8Array(e),{width:i,height:a,depthOrArrayLayers:o,mipLevel:s,x:c,y:l,z:u,byteOffset:d}=n,{glFormat:f,glType:p,compressed:m}=this,h=vj(this.glTarget,this.dimension,u),g;if(!m){let{bytesPerPixel:e}=this.device.getTextureFormatInfo(this.format);e&&(g=n.bytesPerRow/e)}let _=this.compressed?{}:{3317:this.byteAlignment,...g===void 0?{}:{3314:g},32878:n.rowsPerImage},v=gj(r,d),y=m?hj(r,d):r,b=this._getMipLevelSize(s),x=c===0&&l===0&&u===0&&i===b.width&&a===b.height&&o===b.depthOrArrayLayers;this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,null),lj(this.gl,_,()=>{switch(this.dimension){case`2d`:case`cube`:m?x?this.gl.compressedTexImage2D(h,s,f,i,a,0,y):this.gl.compressedTexSubImage2D(h,s,c,l,i,a,f,y):this.gl.texSubImage2D(h,s,c,l,i,a,f,p,r,v);break;case`2d-array`:case`3d`:m?x?this.gl.compressedTexImage3D(h,s,f,i,a,o,0,y):this.gl.compressedTexSubImage3D(h,s,c,l,u,i,a,o,f,y):this.gl.texSubImage3D(h,s,c,l,u,i,a,o,f,p,r,v);break;default:}}),this.gl.bindTexture(this.glTarget,null)}_getRowByteAlignment(e,t){return 1}_getFramebuffer(){return this._framebuffer||=this.device.createFramebuffer({id:`framebuffer-for-${this.id}`,width:this.width,height:this.height,colorAttachments:[this]}),this._framebuffer}readDataSyncWebGL(e={}){let t=this._getSupportedColorReadOptions(e),n=this.computeMemoryLayout(t),r=Px(fj(this.glType)),i=new r(n.byteLength/r.BYTES_PER_ELEMENT);return this._readColorTextureLayers(t,n,e=>{let a=new r(i.buffer,i.byteOffset+e,n.bytesPerImage/r.BYTES_PER_ELEMENT);this.gl.readPixels(t.x,t.y,t.width,t.height,this.glFormat,this.glType,a)}),i.buffer}_readColorTextureLayers(e,t,n){let r=this._getFramebuffer(),i=t.bytesPerRow/t.bytesPerPixel,a={3333:this.byteAlignment,...i===e.width?{}:{3330:i}},o=this.gl.getParameter(3074),s=this.gl.bindFramebuffer(36160,r.handle);try{this.gl.readBuffer(36064),lj(this.gl,a,()=>{for(let i=0;i<e.depthOrArrayLayers;i++)this._attachReadSubresource(r,e.mipLevel,e.z+i),n(i*t.bytesPerImage)})}finally{this.gl.bindFramebuffer(36160,s||null),this.gl.readBuffer(o)}}_attachReadSubresource(e,t,n){let r=`${t}:${n}`;if(this._framebufferAttachmentKey!==r){switch(this.dimension){case`2d`:this.gl.framebufferTexture2D(36160,36064,3553,this.handle,t);break;case`cube`:this.gl.framebufferTexture2D(36160,36064,vj(this.glTarget,this.dimension,n),this.handle,t);break;case`2d-array`:case`3d`:this.gl.framebufferTextureLayer(36160,36064,this.handle,t,n);break;default:throw Error(`${this} color readback does not support ${this.dimension} textures`)}if(this.device.props.debug){let t=Number(this.gl.checkFramebufferStatus(36160));if(t!==36053)throw Error(`${e} incomplete for ${this} readback (${t})`)}this._framebufferAttachmentKey=r}}generateMipmapsWebGL(e){if(!(!(this.device.isTextureFormatRenderable(this.props.format)&&this.device.isTextureFormatFilterable(this.props.format))&&(Z.warn(`${this} is not renderable or filterable, may not be able to generate mipmaps`)(),!e?.force)))try{this.gl.bindTexture(this.glTarget,this.handle),this.gl.generateMipmap(this.glTarget)}catch(e){Z.warn(`Error generating mipmap for ${this}: ${e.message}`)()}finally{this.gl.bindTexture(this.glTarget,null)}}_setSamplerParameters(e){Z.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(e))(),this.gl.bindTexture(this.glTarget,this.handle);for(let[t,n]of Object.entries(e)){let e=Number(t),r=n;switch(e){case 33082:case 33083:this.gl.texParameterf(this.glTarget,e,r);break;case 10240:case 10241:this.gl.texParameteri(this.glTarget,e,r);break;case 10242:case 10243:case 32882:this.gl.texParameteri(this.glTarget,e,r);break;case 34046:this.device.features.has(`texture-filterable-anisotropic-webgl`)&&this.gl.texParameteri(this.glTarget,e,r);break;case 34892:case 34893:this.gl.texParameteri(this.glTarget,e,r);break}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(e){let{gl:t}=this;return e!==void 0&&(this._textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.glTarget,this.handle),e}_unbind(e){let{gl:t}=this;return e!==void 0&&(this._textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.glTarget,null),e}};function hj(e,t=0){return t?new e.constructor(e.buffer,e.byteOffset+t,(e.byteLength-t)/e.BYTES_PER_ELEMENT):e}function gj(e,t){if(t%e.BYTES_PER_ELEMENT!==0)throw Error(`Texture byteOffset ${t} must align to typed array element size ${e.BYTES_PER_ELEMENT}`);return t/e.BYTES_PER_ELEMENT}function _j(e){switch(e){case`1d`:break;case`2d`:return 3553;case`3d`:return 32879;case`cube`:return 34067;case`2d-array`:return 35866;case`cube-array`:break}throw Error(e)}function vj(e,t,n){return t===`cube`?34069+n:e}function yj(e,t,n,r){let i=e,a=r;a===!0&&(a=1),a===!1&&(a=0);let o=typeof a==`number`?[a]:a;switch(n){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof r!=`number`)throw Error(`samplers must be set to integers`);return e.uniform1i(t,r);case 5126:return e.uniform1fv(t,o);case 35664:return e.uniform2fv(t,o);case 35665:return e.uniform3fv(t,o);case 35666:return e.uniform4fv(t,o);case 5124:return e.uniform1iv(t,o);case 35667:return e.uniform2iv(t,o);case 35668:return e.uniform3iv(t,o);case 35669:return e.uniform4iv(t,o);case 35670:return e.uniform1iv(t,o);case 35671:return e.uniform2iv(t,o);case 35672:return e.uniform3iv(t,o);case 35673:return e.uniform4iv(t,o);case 5125:return i.uniform1uiv(t,o,1);case 36294:return i.uniform2uiv(t,o,2);case 36295:return i.uniform3uiv(t,o,3);case 36296:return i.uniform4uiv(t,o,4);case 35674:return e.uniformMatrix2fv(t,!1,o);case 35675:return e.uniformMatrix3fv(t,!1,o);case 35676:return e.uniformMatrix4fv(t,!1,o);case 35685:return i.uniformMatrix2x3fv(t,!1,o);case 35686:return i.uniformMatrix2x4fv(t,!1,o);case 35687:return i.uniformMatrix3x2fv(t,!1,o);case 35688:return i.uniformMatrix3x4fv(t,!1,o);case 35689:return i.uniformMatrix4x2fv(t,!1,o);case 35690:return i.uniformMatrix4x3fv(t,!1,o)}throw Error(`Illegal uniform`)}function bj(e){switch(e){case`point-list`:return 0;case`line-list`:return 1;case`line-strip`:return 3;case`triangle-list`:return 4;case`triangle-strip`:return 5;default:throw Error(e)}}function xj(e){switch(e){case`point-list`:return 0;case`line-list`:return 1;case`line-strip`:return 1;case`triangle-list`:return 4;case`triangle-strip`:return 4;default:throw Error(e)}}var Sj=class extends Zb{device;handle;vs;fs;introspectedLayout;bindings={};uniforms={};varyings=null;_uniformCount=0;_uniformSetters={};get[Symbol.toStringTag](){return`WEBGLRenderPipeline`}constructor(e,t){super(e,t),this.device=e;let n=this.sharedRenderPipeline||this.device._createSharedRenderPipelineWebGL(t);this.sharedRenderPipeline=n,this.handle=n.handle,this.vs=n.vs,this.fs=n.fs,this.linkStatus=n.linkStatus,this.introspectedLayout=n.introspectedLayout,this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.shaderLayout=t.shaderLayout?Cj(this.introspectedLayout,t.shaderLayout):this.introspectedLayout}destroy(){this.destroyed||(this.sharedRenderPipeline&&!this.props._sharedRenderPipeline&&this.sharedRenderPipeline.destroy(),this.destroyResource())}setBindings(e,t){let n=ix(rx(this.shaderLayout,e));for(let[e,r]of Object.entries(n)){let n=wj(this.shaderLayout,e);if(n){switch(r||Z.warn(`Unsetting binding "${e}" in render pipeline "${this.id}"`)(),n.type){case`uniform`:if(!(r instanceof HA)&&!(r.buffer instanceof HA))throw Error(`buffer value`);break;case`texture`:if(!(r instanceof dj||r instanceof mj||r instanceof FA))throw Error(`${this} Bad texture binding for ${e}`);break;case`sampler`:Z.warn(`Ignoring sampler ${e}`)();break;default:throw Error(n.type)}this.bindings[e]=r}else{let n=this.shaderLayout.bindings.map(e=>`"${e.name}"`).join(`, `);t?.disableWarnings||Z.warn(`No binding "${e}" in render pipeline "${this.id}", expected one of ${n}`,r)()}}}draw(e){this._syncLinkStatus();let t=e.bindGroups?ix(e.bindGroups):e.bindings||this.bindings,{renderPass:n,parameters:r=this.props.parameters,topology:i=this.props.topology,vertexArray:a,vertexCount:o,instanceCount:s,isInstanced:c=!1,firstVertex:l=0,transformFeedback:u,uniforms:d=this.uniforms}=e,f=bj(i),p=!!a.indexBuffer,m=a.indexBuffer?.glIndexType;if(this.linkStatus!==`success`)return Z.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable(t))return Z.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(this.handle),a.bindBeforeRender(n),u&&u.begin(this.props.topology),this._applyBindings(t,{disableWarnings:this.props.disableWarnings}),this._applyUniforms(d);let h=n;return JA(this.device,r,h.glParameters,()=>{p&&c?this.device.gl.drawElementsInstanced(f,o||0,m,l,s||0):p?this.device.gl.drawElements(f,o||0,m,l):c?this.device.gl.drawArraysInstanced(f,l,o||0,s||0):this.device.gl.drawArrays(f,l,o||0),u&&u.end()}),a.unbindAfterRender(n),!0}_areTexturesRenderable(e){let t=!0;for(let n of this.shaderLayout.bindings)Tj(e,n.name)||(Z.warn(`Binding ${n.name} not found in ${this.id}`)(),t=!1);return t}_applyBindings(e,t){if(this._syncLinkStatus(),this.linkStatus!==`success`)return;let{gl:n}=this.device;n.useProgram(this.handle);let r=0,i=0;for(let t of this.shaderLayout.bindings){let a=Tj(e,t.name);if(!a)throw Error(`No value for binding ${t.name} in ${this.id}`);switch(t.type){case`uniform`:let{name:e}=t,o=n.getUniformBlockIndex(this.handle,e);if(o===4294967295)throw Error(`Invalid uniform block name ${e}`);if(n.uniformBlockBinding(this.handle,o,i),a instanceof HA)n.bindBufferBase(35345,i,a.handle);else{let e=a;n.bindBufferRange(35345,i,e.buffer.handle,e.offset||0,e.size||e.buffer.byteLength-(e.offset||0))}i+=1;break;case`texture`:if(!(a instanceof dj||a instanceof mj||a instanceof FA))throw Error(`texture`);let s;if(a instanceof dj)s=a.texture;else if(a instanceof mj)s=a;else if(a instanceof FA&&a.colorAttachments[0]instanceof dj)Z.warn(`Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead`)(),s=a.colorAttachments[0].texture;else throw Error(`No texture`);n.activeTexture(33984+r),n.bindTexture(s.glTarget,s.handle),r+=1;break;case`sampler`:break;case`storage`:case`read-only-storage`:throw Error(`binding type '${t.type}' not supported in WebGL`)}}}_applyUniforms(e){for(let t of this.shaderLayout.uniforms||[]){let{name:n,location:r,type:i,textureUnit:a}=t,o=e[n]??a;o!==void 0&&yj(this.device.gl,r,i,o)}}_syncLinkStatus(){this.linkStatus=this.sharedRenderPipeline.linkStatus}};function Cj(e,t){let n={...e,attributes:e.attributes.map(e=>({...e})),bindings:e.bindings.map(e=>({...e}))};for(let e of t?.attributes||[]){let t=n.attributes.find(t=>t.name===e.name);t?(t.type=e.type||t.type,t.stepMode=e.stepMode||t.stepMode):Z.warn(`shader layout attribute ${e.name} not present in shader`)}for(let e of t?.bindings||[]){let t=wj(n,e.name);if(!t){Z.warn(`shader layout binding ${e.name} not present in shader`);continue}Object.assign(t,e)}return n}function wj(e,t){return e.bindings.find(e=>e.name===t||e.name===`${t}Uniforms`||`${e.name}Uniforms`===t)}function Tj(e,t){return e[t]||e[`${t}Uniforms`]||e[t.replace(/Uniforms$/,``)]}function Ej(e){return Mj[e]}function Dj(e){return Aj[e]}function Oj(e){return!!jj[e]}function kj(e){return jj[e]}var Aj={5126:`f32`,35664:`vec2<f32>`,35665:`vec3<f32>`,35666:`vec4<f32>`,5124:`i32`,35667:`vec2<i32>`,35668:`vec3<i32>`,35669:`vec4<i32>`,5125:`u32`,36294:`vec2<u32>`,36295:`vec3<u32>`,36296:`vec4<u32>`,35670:`f32`,35671:`vec2<f32>`,35672:`vec3<f32>`,35673:`vec4<f32>`,35674:`mat2x2<f32>`,35685:`mat2x3<f32>`,35686:`mat2x4<f32>`,35687:`mat3x2<f32>`,35675:`mat3x3<f32>`,35688:`mat3x4<f32>`,35689:`mat4x2<f32>`,35690:`mat4x3<f32>`,35676:`mat4x4<f32>`},jj={35678:{viewDimension:`2d`,sampleType:`float`},35680:{viewDimension:`cube`,sampleType:`float`},35679:{viewDimension:`3d`,sampleType:`float`},35682:{viewDimension:`3d`,sampleType:`depth`},36289:{viewDimension:`2d-array`,sampleType:`float`},36292:{viewDimension:`2d-array`,sampleType:`depth`},36293:{viewDimension:`cube`,sampleType:`float`},36298:{viewDimension:`2d`,sampleType:`sint`},36299:{viewDimension:`3d`,sampleType:`sint`},36300:{viewDimension:`cube`,sampleType:`sint`},36303:{viewDimension:`2d-array`,sampleType:`uint`},36306:{viewDimension:`2d`,sampleType:`uint`},36307:{viewDimension:`3d`,sampleType:`uint`},36308:{viewDimension:`cube`,sampleType:`uint`},36311:{viewDimension:`2d-array`,sampleType:`uint`}},Mj={uint8:5121,sint8:5120,unorm8:5121,snorm8:5120,uint16:5123,sint16:5122,unorm16:5123,snorm16:5122,uint32:5125,sint32:5124,float16:5131,float32:5126};function Nj(e,t){let n={attributes:[],bindings:[]};n.attributes=Pj(e,t);let r=Lj(e,t);for(let e of r){let t=e.uniforms.map(e=>({name:e.name,format:e.format,byteOffset:e.byteOffset,byteStride:e.byteStride,arrayLength:e.arrayLength}));n.bindings.push({type:`uniform`,name:e.name,group:0,location:e.location,visibility:!!e.vertex&(e.fragment?2:0),minBindingSize:e.byteLength,uniforms:t})}let i=Ij(e,t),a=0;for(let e of i)if(Oj(e.type)){let{viewDimension:t,sampleType:r}=kj(e.type);n.bindings.push({type:`texture`,name:e.name,group:0,location:a,viewDimension:t,sampleType:r}),e.textureUnit=a,a+=1}i.length&&(n.uniforms=i);let o=Fj(e,t);return o?.length&&(n.varyings=o),n}function Pj(e,t){let n=[],r=e.getProgramParameter(t,35721);for(let i=0;i<r;i++){let r=e.getActiveAttrib(t,i);if(!r)throw Error(`activeInfo`);let{name:a,type:o}=r,s=e.getAttribLocation(t,a);if(s>=0){let e=Dj(o),t=/instance/i.test(a)?`instance`:`vertex`;n.push({name:a,location:s,stepMode:t,type:e})}}return n.sort((e,t)=>e.location-t.location),n}function Fj(e,t){let n=[],r=e.getProgramParameter(t,35971);for(let i=0;i<r;i++){let r=e.getTransformFeedbackVarying(t,i);if(!r)throw Error(`activeInfo`);let{name:a,type:o,size:s}=r,{type:c,components:l}=lx(Dj(o));n.push({location:i,name:a,type:c,size:s*l})}return n.sort((e,t)=>e.location-t.location),n}function Ij(e,t){let n=[],r=e.getProgramParameter(t,35718);for(let i=0;i<r;i++){let r=e.getActiveUniform(t,i);if(!r)throw Error(`activeInfo`);let{name:a,size:o,type:s}=r,{name:c,isArray:l}=Rj(a),u=e.getUniformLocation(t,c),d={location:u,name:c,size:o,type:s,isArray:l};if(n.push(d),d.size>1)for(let r=0;r<d.size;r++){let i=`${c}[${r}]`;u=e.getUniformLocation(t,i);let a={...d,name:i,location:u};n.push(a)}}return n}function Lj(e,t){let n=(n,r)=>e.getActiveUniformBlockParameter(t,n,r),r=[],i=e.getProgramParameter(t,35382);for(let a=0;a<i;a++){let i={name:e.getActiveUniformBlockName(t,a)||``,location:n(a,35391),byteLength:n(a,35392),vertex:n(a,35396),fragment:n(a,35398),uniformCount:n(a,35394),uniforms:[]},o=n(a,35395)||[],s=e.getActiveUniforms(t,o,35383),c=e.getActiveUniforms(t,o,35384),l=e.getActiveUniforms(t,o,35387),u=e.getActiveUniforms(t,o,35388);for(let n=0;n<i.uniformCount;++n){let r=o[n];if(r!==void 0){let a=e.getActiveUniform(t,r);if(!a)throw Error(`activeInfo`);let o=Dj(s[n]);i.uniforms.push({name:a.name,format:o,type:s[n],arrayLength:c[n],byteOffset:l[n],byteStride:u[n]})}}let d=new Set(i.uniforms.map(e=>e.name.split(`.`)[0]).filter(e=>!!e)),f=i.name.replace(/Uniforms$/,``);if(d.size===1&&!d.has(i.name)&&!d.has(f)){let[e]=d;Z.warn(`Uniform block "${i.name}" uses GLSL instance "${e}". luma.gl binds uniform buffers by block name ("${i.name}") and alias ("${f}"). Prefer matching the instance name to one of those to avoid confusing silent mismatches.`)()}r.push(i)}return r.sort((e,t)=>e.location-t.location),r}function Rj(e){if(e[e.length-1]!==`]`)return{name:e,length:1,isArray:!1};let t=/([^[]*)(\[[0-9]+\])?/.exec(e);return{name:Db(t?.[1],`Failed to parse GLSL uniform name ${e}`),length:+!!t?.[2],isArray:!!t?.[2]}}var zj=4,Bj=class extends Qb{device;handle;vs;fs;introspectedLayout={attributes:[],bindings:[],uniforms:[]};linkStatus=`pending`;constructor(e,t){super(e,t),this.device=e,this.handle=t.handle||this.device.gl.createProgram(),this.vs=t.vs,this.fs=t.fs,t.varyings&&t.varyings.length>0&&this.device.gl.transformFeedbackVaryings(this.handle,t.varyings,t.bufferMode||35981),this._linkShaders(),Z.time(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=Nj(this.device.gl,this.handle),Z.timeEnd(3,`RenderPipeline ${this.id} - shaderLayout introspection`)()}destroy(){this.destroyed||(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.handle.destroyed=!0,this.destroyResource())}async _linkShaders(){let{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),Z.time(zj,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),Z.timeEnd(zj,`linkProgram for ${this.id}`)(),!this.device.features.has(`compilation-status-async-webgl`)){let e=this._getLinkStatus();this._reportLinkStatus(e);return}Z.once(1,`RenderPipeline linking is asynchronous`)(),await this._waitForLinkComplete(),Z.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let t=this._getLinkStatus();this._reportLinkStatus(t)}async _reportLinkStatus(e){switch(e){case`success`:return;default:let t=e===`link-error`?`Link error`:`Validation error`;switch(this.vs.compilationStatus){case`error`:throw this.vs.debugShader(),Error(`${this} ${t} during compilation of ${this.vs}`);case`pending`:await this.vs.asyncCompilationStatus,this.vs.debugShader();break;case`success`:break}switch(this.fs?.compilationStatus){case`error`:throw this.fs.debugShader(),Error(`${this} ${t} during compilation of ${this.fs}`);case`pending`:await this.fs.asyncCompilationStatus,this.fs.debugShader();break;case`success`:break}let n=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(Error(`${t} during ${e}: ${n}`),this)(),this.device.debug()}}_getLinkStatus(){let{gl:e}=this.device;return e.getProgramParameter(this.handle,35714)?(this._initializeSamplerUniforms(),e.validateProgram(this.handle),e.getProgramParameter(this.handle,35715)?(this.linkStatus=`success`,`success`):(this.linkStatus=`error`,`validation-error`)):(this.linkStatus=`error`,`link-error`)}_initializeSamplerUniforms(){let{gl:e}=this.device;e.useProgram(this.handle);let t=0,n=e.getProgramParameter(this.handle,35718);for(let r=0;r<n;r++){let n=e.getActiveUniform(this.handle,r);if(n&&Oj(n.type)){let r=n.name.endsWith(`[0]`),i=r?n.name.slice(0,-3):n.name,a=e.getUniformLocation(this.handle,i);a!==null&&(t=this._assignSamplerUniform(a,n,r,t))}}}_assignSamplerUniform(e,t,n,r){let{gl:i}=this.device;if(n&&t.size>1){let n=Int32Array.from({length:t.size},(e,t)=>r+t);return i.uniform1iv(e,n),r+t.size}return i.uniform1i(e,r),r+1}async _waitForLinkComplete(){let e=async e=>await new Promise(t=>setTimeout(t,e));if(!this.device.features.has(`compilation-status-async-webgl`)){await e(10);return}let{gl:t}=this.device;for(;;){if(t.getProgramParameter(this.handle,37297))return;await e(10)}}},Vj=class extends cx{device;handle=null;commands=[];constructor(e,t={}){super(e,t),this.device=e}_executeCommands(e=this.commands){for(let t of e)switch(t.name){case`copy-buffer-to-buffer`:Hj(this.device,t.options);break;case`copy-buffer-to-texture`:Uj(this.device,t.options);break;case`copy-texture-to-buffer`:Wj(this.device,t.options);break;case`copy-texture-to-texture`:Gj(this.device,t.options);break;default:throw Error(t.name)}}};function Hj(e,t){let n=t.sourceBuffer,r=t.destinationBuffer;e.gl.bindBuffer(36662,n.handle),e.gl.bindBuffer(36663,r.handle),e.gl.copyBufferSubData(36662,36663,t.sourceOffset??0,t.destinationOffset??0,t.size),e.gl.bindBuffer(36662,null),e.gl.bindBuffer(36663,null)}function Uj(e,t){throw Error(`copyBufferToTexture is not supported in WebGL`)}function Wj(e,t){let{sourceTexture:n,mipLevel:r=0,aspect:i=`all`,width:a=t.sourceTexture.width,height:o=t.sourceTexture.height,depthOrArrayLayers:s,origin:c=[0,0,0],destinationBuffer:l,byteOffset:u=0,bytesPerRow:d,rowsPerImage:f}=t;if(n instanceof zb){n.readBuffer({x:c[0]??0,y:c[1]??0,z:c[2]??0,width:a,height:o,depthOrArrayLayers:s,mipLevel:r,aspect:i,byteOffset:u},l);return}if(i!==`all`)throw Error(`aspect not supported in WebGL`);if(r!==0||s!==void 0||d||f)throw Error(`not implemented`);let{framebuffer:p,destroyFramebuffer:m}=Kj(n),h;try{let t=l,n=a||p.width,r=o||p.height,i=OA(Db(p.colorAttachments[0]).texture.props.format),s=i.format,d=i.type;e.gl.bindBuffer(35051,t.handle),h=e.gl.bindFramebuffer(36160,p.handle),e.gl.readPixels(c[0],c[1],n,r,s,d,u)}finally{e.gl.bindBuffer(35051,null),h!==void 0&&e.gl.bindFramebuffer(36160,h),m&&p.destroy()}}function Gj(e,t){let{sourceTexture:n,destinationMipLevel:r=0,origin:i=[0,0],destinationOrigin:a=[0,0,0],destinationTexture:o}=t,{width:s=t.destinationTexture.width,height:c=t.destinationTexture.height}=t,{framebuffer:l,destroyFramebuffer:u}=Kj(n),[d=0,f=0]=i,[p,m,h]=a,g=e.gl.bindFramebuffer(36160,l.handle),_,v;if(o instanceof mj)_=o,s=Number.isFinite(s)?s:_.width,c=Number.isFinite(c)?c:_.height,_._bind(0),v=_.glTarget;else throw Error(`invalid destination`);switch(v){case 3553:case 34067:e.gl.copyTexSubImage2D(v,r,p,m,d,f,s,c);break;case 35866:case 32879:e.gl.copyTexSubImage3D(v,r,p,m,h,d,f,s,c);break;default:}_&&_._unbind(),e.gl.bindFramebuffer(36160,g),u&&l.destroy()}function Kj(e){if(e instanceof zb){let{width:t,height:n,id:r}=e;return{framebuffer:e.device.createFramebuffer({id:`framebuffer-for-${r}`,width:t,height:n,colorAttachments:[e]}),destroyFramebuffer:!0}}return{framebuffer:e,destroyFramebuffer:!1}}var qj=[1,2,4,8],Jj=class extends ox{device;handle=null;glParameters={};constructor(e,t){super(e,t),this.device=e;let n=this.props.framebuffer,r=!n||n.handle===null;r&&e.getDefaultCanvasContext()._resizeDrawingBufferIfNeeded();let i;if(!t?.parameters?.viewport)if(!r&&n){let{width:e,height:t}=n;i=[0,0,e,t]}else{let[t,n]=e.getDefaultCanvasContext().getDrawingBufferSize();i=[0,0,t,n]}if(this.device.pushState(),this.setParameters({viewport:i,...this.props.parameters}),!r&&n?.colorAttachments.length){let e=n.colorAttachments.map((e,t)=>36064+t);this.device.gl.drawBuffers(e)}else r&&this.device.gl.drawBuffers([1029]);this.clear(),this.props.timestampQuerySet&&this.props.beginTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.beginTimestampIndex)}end(){this.destroyed||(this.props.timestampQuerySet&&this.props.endTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.endTimestampIndex),this.device.popState(),this.destroy())}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}setParameters(e={}){let t={...this.glParameters};t.framebuffer=this.props.framebuffer||null,this.props.depthReadOnly&&(t.depthMask=!this.props.depthReadOnly),t.stencilMask=+!this.props.stencilReadOnly,t[35977]=this.props.discard,e.viewport&&(e.viewport.length>=6?(t.viewport=e.viewport.slice(0,4),t.depthRange=[e.viewport[4],e.viewport[5]]):t.viewport=e.viewport),e.scissorRect&&(t.scissorTest=!0,t.scissor=e.scissorRect),e.blendConstant&&(t.blendColor=e.blendConstant),e.stencilReference!==void 0&&(t[2967]=e.stencilReference,t[36003]=e.stencilReference),`colorMask`in e&&(t.colorMask=qj.map(t=>!!(t&e.colorMask))),this.glParameters=t,zk(this.device.gl,t)}beginOcclusionQuery(e){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let e={...this.glParameters},t=0;this.props.clearColors&&this.props.clearColors.forEach((e,t)=>{e&&this.clearColorBuffer(t,e)}),this.props.clearColor!==!1&&this.props.clearColors===void 0&&(t|=16384,e.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(t|=256,e.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(t|=1024,e.clearStencil=this.props.clearStencil),t!==0&&lj(this.device.gl,e,()=>{this.device.gl.clear(t)})}clearColorBuffer(e=0,t=[0,0,0,0]){lj(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,e,t);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,e,t);break;case Float32Array:this.device.gl.clearBufferfv(6144,e,t);break;default:throw Error(`clearColorBuffer: color must be typed array`)}})}},Yj=class extends sx{device;handle=null;commandBuffer;constructor(e,t){super(e,t),this.device=e,this.commandBuffer=new Vj(e,{id:`${this.props.id}-command-buffer`})}destroy(){this.destroyResource()}finish(e){return e?.id&&this.commandBuffer.id!==e.id&&(this.commandBuffer.id=e.id,this.commandBuffer.props.id=e.id),this.destroy(),this.commandBuffer}beginRenderPass(e={}){return new Jj(this.device,this._applyTimeProfilingToPassProps(e))}beginComputePass(e={}){throw Error(`ComputePass not supported in WebGL`)}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:`copy-buffer-to-buffer`,options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:`copy-buffer-to-texture`,options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:`copy-texture-to-buffer`,options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:`copy-texture-to-texture`,options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,t,n){throw Error(`resolveQuerySet is not supported in WebGL`)}writeTimestamp(e,t){e.writeTimestamp(t)}};function Xj(e){let{target:t,source:n,start:r=0,count:i=1}=e,a=n.length,o=i*a,s=0;for(let e=r;s<a;s++)t[e++]=n[s]??0;for(;s<o;)s<o-s?(t.copyWithin(r+s,r,r+s),s*=2):(t.copyWithin(r+s,r,r+o-s),s=o);return e.target}var Zj=class e extends kx{get[Symbol.toStringTag](){return`VertexArray`}device;handle;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return od()===`Chrome`}constructor(e,t){super(e,t),this.device=e,this.handle=this.device.gl.createVertexArray()}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&=(this.device.gl.deleteVertexArray(this.handle),void 0)}setIndexBuffer(e){let t=e;if(t&&t.glTarget!==34963)throw Error(`Use .setBuffer()`);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,t?t.handle:null),this.indexBuffer=t,this.device.gl.bindVertexArray(null)}setBuffer(e,t){let n=t;if(n.glTarget===34963)throw Error(`Use .setIndexBuffer()`);let{size:r,type:i,stride:a,offset:o,normalized:s,integer:c,divisor:l}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,n.handle),c?this.device.gl.vertexAttribIPointer(e,r,i,a,o):this.device.gl.vertexAttribPointer(e,r,i,s,a,o),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,l||0),this.attributes[e]=n,this.device.gl.bindVertexArray(null)}setConstantWebGL(e,t){this._enable(e,!1),this.attributes[e]=t}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let e=0;e<this.maxVertexAttributes;++e){let t=this.attributes[e];ArrayBuffer.isView(t)&&this.device.setConstantAttributeWebGL(e,t)}}_getAccessor(e){let t=this.attributeInfos[e];if(!t)throw Error(`Unknown attribute location ${e}`);let n=nA(t.bufferDataType);return{size:t.bufferComponents,type:n,stride:t.byteStride,offset:t.byteOffset,normalized:t.normalized,integer:t.integer,divisor:+(t.stepMode===`instance`)}}_enable(t,n=!0){let r=e.isConstantAttributeZeroSupported(this.device)||t!==0;(n||r)&&(t=Number(t),this.device.gl.bindVertexArray(this.handle),n?this.device.gl.enableVertexAttribArray(t):this.device.gl.disableVertexAttribArray(t),this.device.gl.bindVertexArray(null))}getConstantBuffer(e,t){let n=Qj(t),r=n.byteLength*e,i=n.length*e;if(this.buffer&&r!==this.buffer.byteLength)throw Error(`Buffer size is immutable, byte length ${r} !== ${this.buffer.byteLength}.`);let a=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:r}),a||=!$j(n,this.bufferValue),a){let e=Xx(t.constructor,i);Xj({target:e,source:n,start:0,count:i}),this.buffer.write(e),this.bufferValue=t}return this.buffer}};function Qj(e){return Array.isArray(e)?new Float32Array(e):e}function $j(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}var eM=class extends Ax{device;gl;handle;layout;buffers={};unusedBuffers={};bindOnUse=!0;_bound=!1;constructor(e,t){super(e,t),this.device=e,this.gl=e.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,t.buffers&&this.setBuffers(t.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(e=`point-list`){this.gl.bindTransformFeedback(36386,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(xj(e))}end(){this.gl.endTransformFeedback(),this.bindOnUse&&this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null)}setBuffers(e){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(let[t,n]of Object.entries(e))this.setBuffer(t,n)})}setBuffer(e,t){let n=this._getVaryingIndex(e),{buffer:r,byteLength:i,byteOffset:a}=this._getBufferRange(t);if(n<0){this.unusedBuffers[e]=r,Z.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[n]={buffer:r,byteLength:i,byteOffset:a},this.bindOnUse||this._bindBuffer(n,r,a,i)}getBuffer(e){if(tM(e))return this.buffers[e]||null;let t=this._getVaryingIndex(e);return this.buffers[t]??null}bind(e=this.handle){if(typeof e!=`function`)return this.gl.bindTransformFeedback(36386,e),this;let t;return this._bound?t=e():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,t=e(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),t}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof HA)return{buffer:e,byteOffset:0,byteLength:e.byteLength};let{buffer:t,byteOffset:n=0,byteLength:r=e.buffer.byteLength}=e;return{buffer:t,byteOffset:n,byteLength:r}}_getVaryingIndex(e){if(tM(e))return Number(e);for(let t of this.layout.varyings||[])if(e===t.name)return t.location;return-1}_bindBuffers(){for(let[e,t]of Object.entries(this.buffers)){let{buffer:n,byteLength:r,byteOffset:i}=this._getBufferRange(t);this._bindBuffer(Number(e),n,i,r)}}_unbindBuffers(){for(let e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,t,n=0,r){let i=t&&t.handle;!i||r===void 0?this.gl.bindBufferBase(35982,e,i):this.gl.bindBufferRange(35982,e,i,n,r)}};function tM(e){return typeof e==`number`?Number.isInteger(e):/^\d+$/.test(e)}var nM=class extends jx{device;handle;_timestampPairs=[];_pendingReads=new Set;_occlusionQuery=null;_occlusionActive=!1;get[Symbol.toStringTag](){return`QuerySet`}constructor(e,t){if(super(e,t),this.device=e,t.type===`timestamp`){if(t.count<2)throw Error(`Timestamp QuerySet requires at least two query slots`);this._timestampPairs=Array(Math.ceil(t.count/2)).fill(null).map(()=>({activeQuery:null,completedQueries:[]})),this.handle=null}else{if(t.count>1)throw Error(`WebGL occlusion QuerySet can only have one value`);let e=this.device.gl.createQuery();if(!e)throw Error(`WebGL query not supported`);this.handle=e}Object.seal(this)}destroy(){if(!this.destroyed){this.handle&&this.device.gl.deleteQuery(this.handle);for(let e of this._timestampPairs){e.activeQuery&&(this._cancelPendingQuery(e.activeQuery),this.device.gl.deleteQuery(e.activeQuery.handle));for(let t of e.completedQueries)this._cancelPendingQuery(t),this.device.gl.deleteQuery(t.handle)}this._occlusionQuery&&(this._cancelPendingQuery(this._occlusionQuery),this.device.gl.deleteQuery(this._occlusionQuery.handle));for(let e of Array.from(this._pendingReads))this._cancelPendingQuery(e);this.destroyResource()}}isResultAvailable(e){return this.props.type===`timestamp`?e===void 0?this._timestampPairs.some((e,t)=>this._isTimestampPairAvailable(t)):this._isTimestampPairAvailable(this._getTimestampPairIndex(e)):this._occlusionQuery?this._pollQueryAvailability(this._occlusionQuery):!1}async readResults(e){let t=e?.firstQuery||0,n=e?.queryCount||this.props.count-t;if(this._validateRange(t,n),this.props.type===`timestamp`){let e=Array(n).fill(0n),r=Math.floor(t/2),i=Math.floor((t+n-1)/2);for(let a=r;a<=i;a++){let r=await this._consumeTimestampPairResult(a),i=a*2,o=i+1;i>=t&&i<t+n&&(e[i-t]=0n),o>=t&&o<t+n&&(e[o-t]=r)}return e}if(!this._occlusionQuery)throw Error(`Occlusion query has not been started`);return[await this._consumeQueryResult(this._occlusionQuery)]}async readTimestampDuration(e,t){if(this.props.type!==`timestamp`)throw Error(`Timestamp durations require a timestamp QuerySet`);if(e<0||t>=this.props.count||t<=e)throw Error(`Timestamp duration range is out of bounds`);if(e%2!=0||t!==e+1)throw Error(`WebGL timestamp durations require adjacent even/odd query indices`);let n=await this._consumeTimestampPairResult(this._getTimestampPairIndex(e));return Number(n)/1e6}beginOcclusionQuery(){if(this.props.type!==`occlusion`)throw Error(`Occlusion queries require an occlusion QuerySet`);if(!this.handle)throw Error(`WebGL occlusion query is not available`);if(this._occlusionActive)throw Error(`Occlusion query is already active`);this.device.gl.beginQuery(35887,this.handle),this._occlusionQuery={handle:this.handle,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null},this._occlusionActive=!0}endOcclusionQuery(){if(!this._occlusionActive)throw Error(`Occlusion query is not active`);this.device.gl.endQuery(35887),this._occlusionActive=!1}writeTimestamp(e){if(this.props.type!==`timestamp`)throw Error(`Timestamp writes require a timestamp QuerySet`);let t=this._getTimestampPairIndex(e),n=this._timestampPairs[t];if(e%2==0){if(n.activeQuery)throw Error(`Timestamp query pair is already active`);let e=this.device.gl.createQuery();if(!e)throw Error(`WebGL query not supported`);let t={handle:e,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null};this.device.gl.beginQuery(35007,e),n.activeQuery=t;return}if(!n.activeQuery)throw Error(`Timestamp query pair was ended before it was started`);this.device.gl.endQuery(35007),n.completedQueries.push(n.activeQuery),n.activeQuery=null}_validateRange(e,t){if(e<0||t<0||e+t>this.props.count)throw Error(`Query read range is out of bounds`)}_getTimestampPairIndex(e){if(e<0||e>=this.props.count)throw Error(`Query index is out of bounds`);return Math.floor(e/2)}_isTimestampPairAvailable(e){let t=this._timestampPairs[e];return!t||t.completedQueries.length===0?!1:this._pollQueryAvailability(t.completedQueries[0])}_pollQueryAvailability(e){if(e.cancelled||this.destroyed)return e.result=0n,!0;if(e.result!==null||e.disjoint)return!0;if(!this.device.gl.getQueryParameter(e.handle,34919))return!1;let t=!!this.device.gl.getParameter(36795);return e.disjoint=t,e.result=t?0n:BigInt(this.device.gl.getQueryParameter(e.handle,34918)),!0}async _consumeTimestampPairResult(e){let t=this._timestampPairs[e];if(!t||t.completedQueries.length===0)throw Error(`Timestamp query pair has no completed result`);let n=t.completedQueries.shift();try{return await this._consumeQueryResult(n)}finally{this.device.gl.deleteQuery(n.handle)}}_consumeQueryResult(e){return e.promise?e.promise:(this._pendingReads.add(e),e.promise=new Promise((t,n)=>{e.resolve=t,e.reject=n;let r=()=>{if(e.pollRequestId=null,e.cancelled||this.destroyed){this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,t(0n);return}if(!this._pollQueryAvailability(e)){e.pollRequestId=this._requestAnimationFrame(r);return}this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,e.disjoint?n(Error(`GPU timestamp query was invalidated by a disjoint event`)):t(e.result||0n)};r()}),e.promise)}_cancelPendingQuery(e){if(this._pendingReads.delete(e),e.cancelled=!0,e.pollRequestId!==null&&(this._cancelAnimationFrame(e.pollRequestId),e.pollRequestId=null),e.resolve){let t=e.resolve;e.promise=null,e.resolve=null,e.reject=null,t(0n)}}_requestAnimationFrame(e){return requestAnimationFrame(e)}_cancelAnimationFrame(e){cancelAnimationFrame(e)}},rM=class extends Mx{device;gl;handle;signaled;_signaled=!1;constructor(e,t={}){super(e,{}),this.device=e,this.gl=e.gl;let n=this.props.handle||this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE,0);if(!n)throw Error(`Failed to create WebGL fence`);this.handle=n,this.signaled=new Promise(e=>{let t=()=>{let n=this.gl.clientWaitSync(this.handle,0,0);n===this.gl.ALREADY_SIGNALED||n===this.gl.CONDITION_SATISFIED?(this._signaled=!0,e()):setTimeout(t,1)};t()})}isSignaled(){if(this._signaled)return!0;let e=this.gl.getSyncParameter(this.handle,this.gl.SYNC_STATUS);return this._signaled=e===this.gl.SIGNALED,this._signaled}destroy(){this.destroyed||this.gl.deleteSync(this.handle)}};function iM(e){switch(e){case 6406:case 33326:case 6403:case 36244:return 1;case 33339:case 33340:case 33328:case 33320:case 33319:return 2;case 6407:case 36248:case 34837:return 3;case 6408:case 36249:case 34836:return 4;default:return 0}}function aM(e){switch(e){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}function oM(e,t){let{sourceX:n=0,sourceY:r=0,sourceAttachment:i=0}=t||{},{target:a=null,sourceWidth:o,sourceHeight:s,sourceDepth:c,sourceFormat:l,sourceType:u}=t||{},{framebuffer:d,deleteFramebuffer:f}=cM(e),{gl:p,handle:m}=d;o||=d.width,s||=d.height;let h=d.colorAttachments[i]?.texture;if(!h)throw Error(`Invalid framebuffer attachment ${i}`);c=h?.depth||1,l||=h?.glFormat||6408,u||=h?.glType||5121,a=uM(a,u,l,o,s,c);let g=Cy.getDataType(a);u||=Ej(g);let _=p.bindFramebuffer(36160,m);return p.readBuffer(36064+i),p.readPixels(n,r,o,s,l,u,a),p.readBuffer(36064),p.bindFramebuffer(36160,_||null),f&&d.destroy(),a}function sM(e,t){let{target:n,sourceX:r=0,sourceY:i=0,sourceFormat:a=6408,targetByteOffset:o=0}=t||{},{sourceWidth:s,sourceHeight:c,sourceType:l}=t||{},{framebuffer:u,deleteFramebuffer:d}=cM(e);s||=u.width,c||=u.height;let f=u;l||=5121;let p=n;if(!p){let e=iM(a),t=aM(l),n=o+s*c*e*t;p=f.device.createBuffer({byteLength:n})}let m=e.device.createCommandEncoder();return m.copyTextureToBuffer({sourceTexture:e,width:s,height:c,origin:[r,i],destinationBuffer:p,byteOffset:o}),m.destroy(),d&&u.destroy(),p}function cM(e){return e instanceof Xb?{framebuffer:e,deleteFramebuffer:!1}:{framebuffer:lM(e),deleteFramebuffer:!0}}function lM(e,t){let{device:n,width:r,height:i,id:a}=e;return n.createFramebuffer({...t,id:`framebuffer-for-${a}`,width:r,height:i,colorAttachments:[e]})}function uM(e,t,n,r,i,a){if(e)return e;t||=5121;let o=fj(t),s=Cy.getTypedArrayConstructor(o),c=iM(n);return new s(r*i*c)}var dM=e({WebGLDevice:()=>fM}),fM=class e extends fb{static getDeviceFromContext(e){return e?e.luma?.device??null:null}type=`webgl`;handle;features;limits;info;canvasContext;preferredColorFormat=`rgba8unorm`;preferredDepthFormat=`depth24plus`;commandEncoder;lost;_resolveContextLost;gl;_constants;extensions;_polyfilled=!1;spectorJS;get[Symbol.toStringTag](){return`WebGLDevice`}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(e){switch(e){case`unorm8x4-bgra`:return!1;default:return!0}}constructor(t){super({...t,id:t.id||VA(`webgl-device`)});let n=fb._getCanvasContextProps(t);if(!n)throw Error(`WebGLDevice requires props.createCanvasContext to be set`);let r=n.canvas?.gl??null,i=e.getDeviceFromContext(r);if(i)throw Error(`WebGL context already attached to device ${i.id}`);this.canvasContext=new RA(this,n),this.lost=new Promise(e=>{this._resolveContextLost=e});let a={...t.webgl};n.alphaMode===`premultiplied`&&(a.premultipliedAlpha=!0),t.powerPreference!==void 0&&(a.powerPreference=t.powerPreference),t.failIfMajorPerformanceCaveat!==void 0&&(a.failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat);let o=this.props._handle||Yk(this.canvasContext.canvas,{onContextLost:e=>this._resolveContextLost?.({reason:`destroyed`,message:`Entered sleep mode, or too many apps or browser tabs are using the GPU.`}),onContextRestored:e=>console.log(`WebGL context restored`)},a);if(!o)throw Error(`WebGL context creation failed`);if(i=e.getDeviceFromContext(o),i){if(t._reuseDevices)return Z.log(1,`Not creating a new Device, instead returning a reference to Device ${i.id} already attached to WebGL context`,i)(),this.canvasContext.destroy(),i._reused=!0,i;throw Error(`WebGL context already attached to device ${i.id}`)}this.handle=o,this.gl=o,this.spectorJS=sk({...this.props,gl:this.handle});let s=tk(this.handle);s.device=this,s.extensions||={},this.extensions=s.extensions,this.info=Zk(this.gl,this.extensions),this.limits=new PA(this.gl),this.features=new NA(this.gl,this.extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new Gk(this.gl,{log:(...e)=>Z.log(1,...e)()}).trackState(this.gl,{copyState:!1}),(t.debug||t.debugWebGL)&&(this.gl=dk(this.gl,{debugWebGL:!0,traceWebGL:t.debugWebGL}),Z.warn(`WebGL debug mode activated. Performance reduced.`)()),t.debugWebGL&&(Z.level=Math.max(Z.level,1)),this.commandEncoder=new Yj(this,{id:`${this}-command-encoder`}),this.canvasContext._startObservers()}destroy(){if(this.commandEncoder?.destroy(),!this.props._reuseDevices&&!this._reused){let e=tk(this.handle);e.device=null}}get isLost(){return this.gl.isContextLost()}createCanvasContext(e){throw Error(`WebGL only supports a single canvas`)}createPresentationContext(e){return new zA(this,e||{})}createBuffer(e){let t=this._normalizeBufferProps(e);return new HA(this,t)}createTexture(e){return new mj(this,e)}createExternalTexture(e){throw Error(`createExternalTexture() not implemented`)}createSampler(e){return new cj(this,e)}createShader(e){return new qA(this,e)}createFramebuffer(e){return new FA(this,e)}createVertexArray(e){return new Zj(this,e)}createTransformFeedback(e){return new eM(this,e)}createQuerySet(e){return new nM(this,e)}createFence(){return new rM(this)}createRenderPipeline(e){return new Sj(this,e)}_createSharedRenderPipelineWebGL(e){return new Bj(this,e)}createComputePipeline(e){throw Error(`ComputePipeline not supported in WebGL`)}createCommandEncoder(e={}){return new Yj(this,e)}submit(e){let t=null;e||({submittedCommandEncoder:t,commandBuffer:e}=this._finalizeDefaultCommandEncoderForSubmit());try{e._executeCommands(),t&&t.resolveTimeProfilingQuerySet().then(()=>{this.commandEncoder._gpuTimeMs=t._gpuTimeMs}).catch(()=>{})}finally{e.destroy()}}_finalizeDefaultCommandEncoderForSubmit(){let e=this.commandEncoder,t=e.finish();return this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:e.props.id,timeProfilingQuerySet:e.getTimeProfilingQuerySet()}),{submittedCommandEncoder:e,commandBuffer:t}}readPixelsToArrayWebGL(e,t){return oM(e,t)}readPixelsToBufferWebGL(e,t){return sM(e,t)}setParametersWebGL(e){zk(this.gl,e)}getParametersWebGL(e){return Bk(this.gl,e)}withParametersWebGL(e,t){return lj(this.gl,e,t)}resetWebGL(){Z.warn(`WebGLDevice.resetWebGL is deprecated, use only for debugging`)(),Vk(this.gl)}_getDeviceSpecificTextureFormatCapabilities(e){return EA(this.gl,e,this.extensions)}loseDevice(){let e=!1,t=this.getExtension(`WEBGL_lose_context`).WEBGL_lose_context;return t&&(e=!0,t.loseContext()),this._resolveContextLost?.({reason:`destroyed`,message:`Application triggered context loss`}),e}pushState(){Gk.get(this.gl).push()}popState(){Gk.get(this.gl).pop()}getGLKey(e,t){let n=Number(e);for(let e in this.gl)if(this.gl[e]===n)return`GL.${e}`;return t?.emptyIfUnknown?``:String(e)}getGLKeys(e){let t={emptyIfUnknown:!0};return Object.entries(e).reduce((e,[n,r])=>(e[`${n}:${this.getGLKey(n,t)}`]=`${r}:${this.getGLKey(r,t)}`,e),{})}setConstantAttributeWebGL(e,t){let n=this.limits.maxVertexAttributes;this._constants=this._constants||Array(n).fill(null);let r=this._constants[e];switch(r&&gM(r,t)&&Z.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=t,t.constructor){case Float32Array:pM(this,e,t);break;case Int32Array:mM(this,e,t);break;case Uint32Array:hM(this,e,t);break;default:throw Error(`constant`)}}getExtension(e){return Xk(this.gl,e,this.extensions),this.extensions}_setWebGLDebugMetadata(e,t,n){e.luma=t,e.__SPECTOR_Metadata={props:n.spector,id:n.spector.id}}};function pM(e,t,n){switch(n.length){case 1:e.gl.vertexAttrib1fv(t,n);break;case 2:e.gl.vertexAttrib2fv(t,n);break;case 3:e.gl.vertexAttrib3fv(t,n);break;case 4:e.gl.vertexAttrib4fv(t,n);break;default:}}function mM(e,t,n){e.gl.vertexAttribI4iv(t,n)}function hM(e,t,n){e.gl.vertexAttribI4uiv(t,n)}function gM(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}function _M(){}var vM={id:``,width:`100%`,height:`100%`,style:null,viewState:null,initialViewState:null,pickingRadius:0,pickAsync:`auto`,layerFilter:null,parameters:{},parent:null,device:null,deviceProps:{},gl:null,canvas:null,layers:[],effects:[],views:null,controller:null,useDevicePixels:!0,touchAction:`none`,eventRecognizerOptions:{},_framebuffer:null,_animate:!1,_pickable:!0,_typedArrayManagerProps:{},_customRender:null,widgets:[],onDeviceInitialized:_M,onWebGLInitialized:_M,onResize:_M,onViewStateChange:_M,onInteractionStateChange:_M,onBeforeRender:_M,onAfterRender:_M,onLoad:_M,onError:e=>X.error(e.message,e.cause)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:({isDragging:e})=>e?`grabbing`:`grab`,getTooltip:null,debug:!1,drawPickingColors:!1},yM=class{constructor(e){this.width=0,this.height=0,this.userData={},this.device=null,this.canvas=null,this.viewManager=null,this.layerManager=null,this.effectManager=null,this.deckRenderer=null,this.deckPicker=null,this.eventManager=null,this.widgetManager=null,this.tooltip=null,this.animationLoop=null,this.cursorState={isHovering:!1,isDragging:!1},this.stats=new Of({id:`deck.gl`}),this.metrics={fps:0,setPropsTime:0,layersCount:0,drawLayersCount:0,updateLayersCount:0,updateAttributesCount:0,updateAttributesTime:0,framesRedrawn:0,pickTime:0,pickCount:0,pickLayersCount:0,gpuTime:0,gpuTimePerFrame:0,cpuTime:0,cpuTimePerFrame:0,bufferMemory:0,textureMemory:0,renderbufferMemory:0,gpuMemory:0},this._metricsCounter=0,this._hoverPickSequence=0,this._pointerDownPickSequence=0,this._needsRedraw=`Initial render`,this._pickRequest={mode:`hover`,x:-1,y:-1,radius:0,event:null,unproject3D:!1},this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this._onPointerMove=e=>{let{_pickRequest:t}=this;if(e.type===`pointerleave`)t.x=-1,t.y=-1,t.radius=0;else if(e.leftButton||e.rightButton)return;else{let n=e.offsetCenter;if(!n)return;t.x=n.x,t.y=n.y,t.radius=this.props.pickingRadius}this.layerManager&&(this.layerManager.context.mousePosition={x:t.x,y:t.y}),t.event=e},this._onEvent=e=>{let t=HC[e.type],n=e.offsetCenter;if(!t||!n||!this.layerManager)return;let r=this.layerManager.getLayers(),i=this._getInternalPickingMode();if(i){if(i===`sync`){let t=e.type===`click`&&this._shouldUnproject3D(r)?this._getFirstPickedInfo(this._pickPointSync(this._getPointPickOptions(n.x,n.y,{unproject3D:!0},r))):this._getLastPointerDownPickingInfo(n.x,n.y,r);this._dispatchPickingEvent(t,e);return}(this._lastPointerDownInfoPromise||Promise.resolve(this._getLastPointerDownPickingInfo(n.x,n.y,r))).then(t=>{this._dispatchPickingEvent(t,e)}).catch(e=>this.props.onError?.(e))}},this._onPointerDown=e=>{let t=e.offsetCenter;if(!t)return;let n=this._getInternalPickingMode();if(!n)return;let r=this.layerManager?.getLayers()||[],i=++this._pointerDownPickSequence;if(n===`sync`){let e=this._pickPointSync({x:t.x,y:t.y,radius:this.props.pickingRadius}),n=this._getFirstPickedInfo(e);this._lastPointerDownInfo=n,this._lastPointerDownInfoPromise=Promise.resolve(n);return}let a=this._pickPointAsync(this._getPointPickOptions(t.x,t.y,{},r)).then(e=>this._getFirstPickedInfo(e)).then(e=>(i===this._pointerDownPickSequence&&(this._lastPointerDownInfo=e),e)).catch(e=>{this.props.onError?.(e);let n=this.deckPicker&&this.viewManager?this._getLastPointerDownPickingInfo(t.x,t.y,r):{};return i===this._pointerDownPickSequence&&(this._lastPointerDownInfo=n),n});this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=a},this.props={...vM,...e},e=this.props,e.viewState&&e.initialViewState&&X.warn("View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.")(),this.viewState=this.props.initialViewState,e.device&&(this.device=e.device);let t=this.device;if(!t&&e.gl){e.gl instanceof WebGLRenderingContext&&X.error(`WebGL1 context not supported.`)();let n=this.props.deviceProps?.onResize;t=wk.attach(e.gl,{_cacheShaders:!0,_cachePipelines:!0,...this.props.deviceProps,onResize:(e,t)=>{let{width:r,height:i}=e.canvas;e.setDrawingBufferSize(r,i),this._needsRedraw=`Canvas resized`,n?.(e,t)}})}t||=this._createDevice(e),this.animationLoop=this._createAnimationLoop(t,e),this.setProps(e),e._typedArrayManagerProps&&ET.setOptions(e._typedArrayManagerProps),this.animationLoop.start()}finalize(){this.animationLoop?.stop(),this.animationLoop?.destroy(),this.animationLoop=null,this._hoverPickSequence++,this._pointerDownPickSequence++,this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this.layerManager?.finalize(),this.layerManager=null,this.viewManager?.finalize(),this.viewManager=null,this.effectManager?.finalize(),this.effectManager=null,this.deckRenderer?.finalize(),this.deckRenderer=null,this.deckPicker?.finalize(),this.deckPicker=null,this.eventManager?.destroy(),this.eventManager=null,this.widgetManager?.finalize(),this.widgetManager=null,!this.props.canvas&&!this.props.device&&!this.props.gl&&this.canvas&&(this.canvas.parentElement?.removeChild(this.canvas),this.canvas=null)}setProps(e){this.stats.get(`setProps Time`).timeStart(),`onLayerHover`in e&&X.removed(`onLayerHover`,`onHover`)(),`onLayerClick`in e&&X.removed(`onLayerClick`,`onClick`)(),e.initialViewState&&!jD(this.props.initialViewState,e.initialViewState,3)&&(this.viewState=e.initialViewState),Object.assign(this.props,e),this._validateInternalPickingMode(),this._setCanvasSize(this.props);let t=Object.create(this.props);Object.assign(t,{views:this._getViews(),width:this.width,height:this.height,viewState:this._getViewState()}),e.device&&e.device.id!==this.device?.id&&(this.animationLoop?.stop(),this.canvas!==e.device.canvasContext?.canvas&&(this.canvas?.remove(),this.eventManager?.destroy(),this.canvas=null),X.log(`recreating animation loop for new device! id=${e.device.id}`)(),this.animationLoop=this._createAnimationLoop(e.device,e),this.animationLoop.start()),this.animationLoop?.setProps(t),e.useDevicePixels!==void 0&&this.device?.canvasContext?.setProps&&this.device.canvasContext.setProps({useDevicePixels:e.useDevicePixels}),this.layerManager&&(this.viewManager.setProps(t),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(t),this.effectManager.setProps(t),this.deckRenderer.setProps(t),this.deckPicker.setProps(t),this.widgetManager.setProps(t)),this.stats.get(`setProps Time`).timeEnd()}needsRedraw(e={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return`Deck._animate`;let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);let n=this.viewManager.needsRedraw(e),r=this.layerManager.needsRedraw(e),i=this.effectManager.needsRedraw(e),a=this.deckRenderer.needsRedraw(e);return t=t||n||r||i||a,t}redraw(e){if(!this.layerManager)return;let t=this.needsRedraw({clearRedrawFlags:!0});t=e||t,t&&(this.stats.get(`Redraw Count`).incrementCount(),this.props._customRender?this.props._customRender(t):this._drawLayers(t))}get isInitialized(){return this.viewManager!==null}getViews(){return ZD(this.viewManager),this.viewManager.views}getView(e){return ZD(this.viewManager),this.viewManager.getView(e)}getViewports(e){return ZD(this.viewManager),this.viewManager.getViewports(e)}getCanvas(){return this.canvas}async pickObjectAsync(e){let t=(await this._pickAsync(`pickObjectAsync`,`pickObject Time`,e)).result;return t.length?t[0]:null}async pickObjectsAsync(e){return await this._pickAsync(`pickObjectsAsync`,`pickObjects Time`,e)}pickObject(e){let t=this._pick(`pickObject`,`pickObject Time`,e).result;return t.length?t[0]:null}pickMultipleObjects(e){return e.depth=e.depth||10,this._pick(`pickObject`,`pickMultipleObjects Time`,e).result}pickObjects(e){return this._pick(`pickObjects`,`pickObjects Time`,e)}_pickPositionForController(e,t){return this._getInternalPickingMode()===`sync`?this.pickObject({x:e,y:t,radius:0,unproject3D:!0}):null}_addResources(e,t=!1){for(let n in e)this.layerManager.resourceManager.add({resourceId:n,data:e[n],forceUpdate:t})}_removeResources(e){for(let t of e)this.layerManager.resourceManager.remove(t)}_addDefaultEffect(e){this.effectManager.addDefaultEffect(e)}_addDefaultShaderModule(e){this.layerManager.addDefaultShaderModule(e)}_removeDefaultShaderModule(e){this.layerManager?.removeDefaultShaderModule(e)}_resolveInternalPickingMode(){let{pickAsync:e}=this.props,t=this.device?.type||this.props.deviceProps?.type;if(e===`auto`)return t===`webgpu`?`async`:`sync`;if(e===`sync`&&t===`webgpu`)throw Error('`pickAsync: "sync"` is not supported when Deck is using a WebGPU device.');return e}_getInternalPickingMode(){try{return this._resolveInternalPickingMode()}catch(e){return this.props.onError?.(e),null}}_validateInternalPickingMode(){this._getInternalPickingMode()}_getFirstPickedInfo({result:e,emptyInfo:t}){return e[0]||t}_shouldUnproject3D(e=this.layerManager?.getLayers()||[]){return e.some(e=>e.props.pickable===`3d`)}_getPointPickOptions(e,t,n={},r=this.layerManager?.getLayers()||[]){return{x:e,y:t,radius:this.props.pickingRadius,unproject3D:this._shouldUnproject3D(r),...n}}_pickPointSync(e){return this._pick(`pickObject`,`pickObject Time`,e)}_pickPointAsync(e){return this._pickAsync(`pickObjectAsync`,`pickObject Time`,e)}_getLastPointerDownPickingInfo(e,t,n=this.layerManager?.getLayers()||[]){return this.deckPicker.getLastPickedObject({x:e,y:t,layers:n,viewports:this.getViewports({x:e,y:t})},this._lastPointerDownInfo)}_applyHoverCallbacks({result:e,emptyInfo:t},n){if(!this.widgetManager)return;this.cursorState.isHovering=e.length>0;let r=t,i=!1;for(let t of e)r=t,i=t.layer?.onHover(t,n)||i;i||(this.props.onHover?.(r,n),this.widgetManager.onHover(r,n))}_dispatchPickingEvent(e,t){if(!this.layerManager||!this.widgetManager)return;let n=HC[t.type];if(!n)return;let{layer:r}=e,i=r&&(r[n]||r.props[n]),a=this.props[n],o=!1;i&&(o=i.call(r,e,t)),o||(a?.(e,t),this.widgetManager.onEvent(e,t))}_pickAsync(e,t,n){ZD(this.deckPicker);let{stats:r}=this;r.get(`Pick Count`).incrementCount(),r.get(t).timeStart();let i=this.deckPicker[e]({layers:this.layerManager.getLayers(n),views:this.viewManager.getViews(),viewports:this.getViewports(n),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...n});return r.get(t).timeEnd(),i}_pick(e,t,n){ZD(this.deckPicker);let{stats:r}=this;r.get(`Pick Count`).incrementCount(),r.get(t).timeStart();let i=this.deckPicker[e]({layers:this.layerManager.getLayers(n),views:this.viewManager.getViews(),viewports:this.getViewports(n),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...n});return r.get(t).timeEnd(),i}_createCanvas(e){let t=e.canvas;return typeof t==`string`&&(t=document.getElementById(t),ZD(t)),t||(t=document.createElement(`canvas`),t.id=e.id||`deckgl-overlay`,e.width&&typeof e.width==`number`&&(t.width=e.width),e.height&&typeof e.height==`number`&&(t.height=e.height),(e.parent||document.body).appendChild(t)),Object.assign(t.style,e.style),t}_setCanvasSize(e){if(!this.canvas)return;let{width:t,height:n}=e;if(t||t===0){let e=Number.isFinite(t)?`${t}px`:t;this.canvas.style.width=e}if(n||n===0){let t=Number.isFinite(n)?`${n}px`:n;this.canvas.style.position=e.style?.position||`absolute`,this.canvas.style.height=t}}_updateCanvasSize(){let{canvas:e}=this;if(!e)return;let t=e.clientWidth??e.width,n=e.clientHeight??e.height;(t!==this.width||n!==this.height)&&(this.width=t,this.height=n,this.viewManager?.setProps({width:t,height:n}),this.layerManager?.activateViewport(this.getViewports()[0]),this.props.onResize({width:t,height:n}))}_createAnimationLoop(e,t){let{gl:n,onError:r}=t;return new nE({device:e,autoResizeDrawingBuffer:!n,autoResizeViewport:!1,onInitialize:e=>this._setDevice(e.device),onRender:this._onRenderFrame.bind(this),onError:r})}_createDevice(e){let t=this.props.deviceProps?.createCanvasContext,n=typeof t==`object`?t:void 0,r={adapters:[],_cacheShaders:!0,_cachePipelines:!0,...e.deviceProps};r.adapters.includes(wk)||r.adapters.push(wk);let i={alphaMode:this.props.deviceProps?.type===`webgpu`?`premultiplied`:void 0},a=this.props.deviceProps?.onResize;return vb.createDevice({_reuseDevices:!0,type:`webgl`,...r,createCanvasContext:{...i,...n,canvas:this._createCanvas(e),useDevicePixels:this.props.useDevicePixels,autoResize:!0},onResize:(e,t)=>{this._needsRedraw=`Canvas resized`,a?.(e,t)}})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){let{views:e}=this.props,t=Array.isArray(e)?e:e?[e]:[new CO({id:`default-view`})];return t.length&&this.props.controller&&(t[0].props.controller=this.props.controller),t}_onContextLost(){let{onError:e}=this.props;this.animationLoop&&e&&e(Error(`WebGL context is lost`))}_pickAndCallback(){let{_pickRequest:e}=this;if(e.event){let t=e.event,n=this.layerManager?.getLayers()||[],r=this._getPointPickOptions(e.x,e.y,{radius:e.radius,mode:e.mode},n),i=this._getInternalPickingMode(),a=++this._hoverPickSequence;if(e.event=null,!i)return;if(i===`sync`){this._applyHoverCallbacks(this._pickPointSync(r),t);return}this._pickPointAsync(r).then(({result:e,emptyInfo:n})=>{a===this._hoverPickSequence&&this._applyHoverCallbacks({result:e,emptyInfo:n},t)}).catch(e=>this.props.onError?.(e))}}_updateCursor(){let e=this.props.parent||this.canvas;e&&(e.style.cursor=this.props.getCursor(this.cursorState))}_setDevice(e){if(this.device=e,this._validateInternalPickingMode(),!this.animationLoop)return;this.canvas||(this.canvas=this.device.canvasContext?.canvas,!this.canvas.isConnected&&this.props.parent&&this.props.parent.insertBefore(this.canvas,this.props.parent.firstChild)),this.device.type===`webgl`&&this.device.setParametersWebGL({blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthTest:!0,depthFunc:515}),this.props.onDeviceInitialized(this.device),this.device.type===`webgl`&&this.props.onWebGLInitialized(this.device.gl);let t=new ZT;t.play(),this.animationLoop.attachTimeline(t);let n=this.props.parent?.querySelector(`.deck-events-root`)||this.canvas;this.eventManager=new RC(n,{touchAction:this.props.touchAction,recognizers:Object.keys(UC).map(e=>{let[t,n,r,i]=UC[e],a=this.props.eventRecognizerOptions?.[e];return{recognizer:new t({...n,...a,event:e}),recognizeWith:r,requestFailure:i}}),events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(let e in HC)this.eventManager.on(e,this._onEvent);this.viewManager=new MD({timeline:t,eventManager:this.eventManager,onViewStateChange:this._onViewStateChange.bind(this),onInteractionStateChange:this._onInteractionStateChange.bind(this),pickPosition:this._pickPositionForController.bind(this),views:this._getViews(),viewState:this._getViewState(),width:this.width,height:this.height});let r=this.viewManager.getViewports()[0];this.layerManager=new AD(this.device,{deck:this,stats:this.stats,viewport:r,timeline:t}),this.effectManager=new EO({deck:this,device:this.device}),this.deckRenderer=new kO(this.device,{stats:this.stats}),this.deckPicker=new LO(this.device,{stats:this.stats});let i=this.props.parent?.querySelector(`.deck-widgets-root`)||this.canvas?.parentElement;this.widgetManager=new VO({deck:this,parentElement:i}),this.widgetManager.addDefault(new KO),this.setProps(this.props),this._updateCanvasSize(),this.props.onLoad()}_drawLayers(e,t){let{device:n,gl:r}=this.layerManager.context;this.props.onBeforeRender({device:n,gl:r});let i={target:this.props._framebuffer,layers:this.layerManager.getLayers(),viewports:this.viewManager.getViewports(),onViewportActive:this.layerManager.activateViewport,views:this.viewManager.getViews(),pass:`screen`,effects:this.effectManager.getEffects(),...t};this.deckRenderer?.renderLayers(i),i.pass===`screen`&&this.widgetManager.onRedraw({viewports:i.viewports,layers:i.layers}),this.props.onAfterRender({device:n,gl:r})}_onRenderFrame(){this._getFrameStats(),this._metricsCounter++%60==0&&(this._getMetrics(),this.stats.reset(),X.table(4,this.metrics)(),this.props._onMetrics&&this.props._onMetrics(this.metrics)),this._updateCanvasSize(),this._updateCursor(),this.layerManager.updateLayers(),this._pickAndCallback(),this.redraw(),this.viewManager&&this.viewManager.updateViewStates()}_onViewStateChange(e){let t=this.props.onViewStateChange(e)||e.viewState;this.viewState&&(this.viewState={...this.viewState,[e.viewId]:t},this.props.viewState||this.viewManager&&this.viewManager.setProps({viewState:this.viewState}))}_onInteractionStateChange(e){this.cursorState.isDragging=e.isDragging||!1,this.props.onInteractionStateChange(e)}_getFrameStats(){let{stats:e}=this;e.get(`frameRate`).timeEnd(),e.get(`frameRate`).timeStart();let t=this.animationLoop.stats;e.get(`GPU Time`).addTime(t.get(`GPU Time`).lastTiming),e.get(`CPU Time`).addTime(t.get(`CPU Time`).lastTiming)}_getMetrics(){let{metrics:e,stats:t}=this;e.fps=t.get(`frameRate`).getHz(),e.setPropsTime=t.get(`setProps Time`).time,e.updateAttributesTime=t.get(`Update Attributes`).time,e.framesRedrawn=t.get(`Redraw Count`).count,e.pickTime=t.get(`pickObject Time`).time+t.get(`pickMultipleObjects Time`).time+t.get(`pickObjects Time`).time,e.pickCount=t.get(`Pick Count`).count,e.layersCount=this.layerManager?.layers.length??0,e.drawLayersCount=t.get(`Layers rendered`).lastSampleCount,e.pickLayersCount=t.get(`Layers picked`).lastSampleCount,e.updateAttributesCount=t.get(`Layers updated`).count,e.updateAttributesCount=t.get(`Attributes updated`).count,e.gpuTime=t.get(`GPU Time`).time,e.cpuTime=t.get(`CPU Time`).time,e.gpuTimePerFrame=t.get(`GPU Time`).getAverageTime(),e.cpuTimePerFrame=t.get(`CPU Time`).getAverageTime();let n=vb.stats.get(`GPU Time and Memory`);e.bufferMemory=n.get(`Buffer Memory`).count,e.textureMemory=n.get(`Texture Memory`).count,e.renderbufferMemory=n.get(`Renderbuffer Memory`).count,e.gpuMemory=n.get(`GPU Memory`).count}};yM.defaultProps=vM,yM.VERSION=ch;function bM(e){switch(e){case`float64`:return Float64Array;case`uint8`:case`unorm8`:return Uint8ClampedArray;default:return Px(e)}}var xM=Cy.getDataType.bind(Cy);function SM(e,t,n){if(t.size>4)return null;let r=n===`webgpu`&&t.type===`uint8`?`unorm8`:t.type;return{attribute:e,format:t.size>1?`${r}x${t.size}`:t.type,byteOffset:t.offset||0}}function CM(e){return e.stride||e.size*e.bytesPerElement}function wM(e,t){return e.type===t.type&&e.size===t.size&&CM(e)===CM(t)&&(e.offset||0)===(t.offset||0)}function TM(e,t){t.offset&&X.removed(`shaderAttribute.offset`,`vertexOffset, elementOffset`)();let n=CM(e),r=t.vertexOffset===void 0?e.vertexOffset||0:t.vertexOffset,i=t.elementOffset||0,a=r*n+i*e.bytesPerElement+(e.offset||0);return{...t,offset:a,stride:n}}function EM(e,t){let n=TM(e,t);return{high:n,low:{...n,offset:n.offset+e.size*4}}}var DM=class{constructor(e,t,n){this._buffer=null,this.device=e,this.id=t.id||``,this.size=t.size||1;let r=t.logicalType||t.type,i=r===`float64`,{defaultValue:a}=t;a=Number.isFinite(a)?[a]:a||Array(this.size).fill(0);let o;o=i?`float32`:!r&&t.isIndexed?`uint32`:r||`float32`;let s=bM(r||o);this.doublePrecision=i,i&&t.fp64===!1&&(s=Float32Array),this.value=null,this.settings={...t,defaultType:s,defaultValue:a,logicalType:r,type:o,normalized:o.includes(`norm`),size:this.size,bytesPerElement:s.BYTES_PER_ELEMENT},this.state={...n,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1}}get isConstant(){return this.state.constant}get buffer(){return this._buffer}get byteOffset(){let e=this.getAccessor();return e.vertexOffset?e.vertexOffset*CM(e):0}get numInstances(){return this.state.numInstances}set numInstances(e){this.state.numInstances=e}delete(){this._buffer&&=(this._buffer.delete(),null),ET.release(this.state.allocatedValue)}getBuffer(){return this.state.constant?null:this.state.externalBuffer||this._buffer}getValue(e=this.id,t=null){let n={};if(this.state.constant){let r=this.value;if(t){let i=TM(this.getAccessor(),t),a=i.offset/r.BYTES_PER_ELEMENT,o=i.size||this.size;n[e]=r.subarray(a,a+o)}else n[e]=r}else n[e]=this.getBuffer();return this.doublePrecision&&(this.value instanceof Float64Array?n[`${e}64Low`]=n[e]:n[`${e}64Low`]=new Float32Array(this.size)),n}_getBufferLayout(e=this.id,t=null){let n=this.getAccessor(),r=[],i={name:this.id,byteStride:CM(n)};if(this.doublePrecision){let i=EM(n,t||{});r.push(SM(e,{...n,...i.high},this.device.type),SM(`${e}64Low`,{...n,...i.low},this.device.type))}else if(t){let i=TM(n,t);r.push(SM(e,{...n,...i},this.device.type))}else r.push(SM(e,n,this.device.type));return i.attributes=r.filter(Boolean),i}setAccessor(e){this.state.bufferAccessor=e}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let e=null;if(this.state.constant&&this.value){let t=Array.from(this.value);e=[t,t]}else{let{value:t,numInstances:n,size:r}=this,i=n*r;if(t&&i&&t.length>=i){let n=Array(r).fill(1/0),a=Array(r).fill(-1/0);for(let e=0;e<i;)for(let i=0;i<r;i++){let r=t[e++];r<n[i]&&(n[i]=r),r>a[i]&&(a[i]=r)}e=[n,a]}}return this.state.bounds=e,e}setData(e){let{state:t}=this,n;n=ArrayBuffer.isView(e)?{value:e}:e instanceof Sy?{buffer:e}:e;let r={...this.settings,...n};if(ArrayBuffer.isView(n.value)){if(!n.type)if(this.doublePrecision&&n.value instanceof Float64Array)r.type=`float32`;else{let e=xM(n.value);r.type=r.normalized?e.replace(`int`,`norm`):e}r.bytesPerElement=n.value.BYTES_PER_ELEMENT,r.stride=CM(r)}if(t.bounds=null,n.constant){let e=n.value;if(e=this._normalizeValue(e,[],0),this.settings.normalized&&(e=this.normalizeConstant(e)),!(!t.constant||!this._areValuesEqual(e,this.value)))return!1;t.externalBuffer=null,t.constant=!0,this.value=ArrayBuffer.isView(e)?e:new Float32Array(e)}else if(n.buffer)t.externalBuffer=n.buffer,t.constant=!1,this.value=n.value||null;else if(n.value){this._checkExternalBuffer(n);let e=n.value;t.externalBuffer=null,t.constant=!1,this.value=e;let{buffer:i}=this,a=CM(r),o=(r.vertexOffset||0)*a;if(this.doublePrecision&&e instanceof Float64Array&&(e=FT(e,r)),this.settings.isIndexed){let t=this.settings.defaultType;e.constructor!==t&&(e=new t(e))}let s=e.byteLength+o+a*2;(!i||i.byteLength<s)&&(i=this._createBuffer(s)),i.write(e,o)}return this.setAccessor(r),!0}updateSubBuffer(e={}){this.state.bounds=null;let t=this.value,{startOffset:n=0,endOffset:r}=e;this.buffer.write(this.doublePrecision&&t instanceof Float64Array?FT(t,{size:this.size,startIndex:n,endIndex:r}):t.subarray(n,r),n*t.BYTES_PER_ELEMENT+this.byteOffset)}allocate(e,t=!1){let{state:n}=this,r=n.allocatedValue,i=ET.allocate(r,e+1,{size:this.size,type:this.settings.defaultType,copy:t});this.value=i;let{byteOffset:a}=this,{buffer:o}=this;return(!o||o.byteLength<i.byteLength+a)&&(o=this._createBuffer(i.byteLength+a),t&&r&&o.write(r instanceof Float64Array?FT(r,this):r,a)),n.allocatedValue=i,n.constant=!1,n.externalBuffer=null,this.setAccessor(this.settings),!0}_checkExternalBuffer(e){let{value:t}=e;if(!ArrayBuffer.isView(t))throw Error(`Attribute ${this.id} value is not TypedArray`);let n=this.settings.defaultType,r=!1;if(this.doublePrecision&&(r=t.BYTES_PER_ELEMENT<4),r)throw Error(`Attribute ${this.id} does not support ${t.constructor.name}`);!(t instanceof n)&&this.settings.normalized&&!(`normalized`in e)&&X.warn(`Attribute ${this.id} is normalized`)()}normalizeConstant(e){switch(this.settings.type){case`snorm8`:return new Float32Array(e).map(e=>(e+128)/255*2-1);case`snorm16`:return new Float32Array(e).map(e=>(e+32768)/65535*2-1);case`unorm8`:return new Float32Array(e).map(e=>e/255);case`unorm16`:return new Float32Array(e).map(e=>e/65535);default:return e}}_normalizeValue(e,t,n){let{defaultValue:r,size:i}=this.settings;if(Number.isFinite(e))return t[n]=e,t;if(!e){let e=i;for(;--e>=0;)t[n+e]=r[e];return t}switch(i){case 4:t[n+3]=Number.isFinite(e[3])?e[3]:r[3];case 3:t[n+2]=Number.isFinite(e[2])?e[2]:r[2];case 2:t[n+1]=Number.isFinite(e[1])?e[1]:r[1];case 1:t[n+0]=Number.isFinite(e[0])?e[0]:r[0];break;default:let a=i;for(;--a>=0;)t[n+a]=Number.isFinite(e[a])?e[a]:r[a]}return t}_areValuesEqual(e,t){if(!e||!t)return!1;let{size:n}=this;for(let r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}_createBuffer(e){this._buffer&&this._buffer.destroy();let{isIndexed:t,type:n}=this.settings;return this._buffer=this.device.createBuffer({...this._buffer?.props,id:this.id,usage:(t?Sy.INDEX:Sy.VERTEX)|Sy.COPY_DST,indexType:t?n:void 0,byteLength:e}),this._buffer}},OM=[],kM=[];function AM(e,t=0,n=1/0){let r=OM,i={index:-1,data:e,target:[]};return e?typeof e[Symbol.iterator]==`function`?r=e:e.length>0&&(kM.length=e.length,r=kM):r=OM,(t>0||Number.isFinite(n))&&(r=(Array.isArray(r)?r:Array.from(r)).slice(t,n),i.index=t-1),{iterable:r,objectInfo:i}}function jM(e){return e&&e[Symbol.asyncIterator]}function MM(e,t){let{size:n,stride:r,offset:i,startIndices:a,nested:o}=t,s=e.BYTES_PER_ELEMENT,c=r?r/s:n,l=i?i/s:0,u=Math.floor((e.length-l)/c);return(t,{index:r,target:i})=>{if(!a){let t=r*c+l;for(let r=0;r<n;r++)i[r]=e[t+r];return i}let s=a[r],d=a[r+1]||u,f;if(o){f=Array(d-s);for(let t=s;t<d;t++){let r=t*c+l;i=Array(n);for(let t=0;t<n;t++)i[t]=e[r+t];f[t-s]=i}}else if(c===n)f=e.subarray(s*n+l,d*n+l);else{f=new e.constructor((d-s)*n);let t=0;for(let r=s;r<d;r++){let i=r*c+l;for(let r=0;r<n;r++)f[t++]=e[i+r]}}return f}}var NM=[],PM=[[0,1/0]];function FM(e,t){if(e===PM||(t[0]<0&&(t[0]=0),t[0]>=t[1]))return e;let n=[],r=e.length,i=0;for(let a=0;a<r;a++){let r=e[a];r[1]<t[0]?(n.push(r),i=a+1):r[0]>t[1]?n.push(r):t=[Math.min(r[0],t[0]),Math.max(r[1],t[1])]}return n.splice(i,0,t),n}var IM={interpolation:{duration:0,easing:e=>e},spring:{stiffness:.05,damping:.5}};function LM(e,t){if(!e)return null;Number.isFinite(e)&&(e={type:`interpolation`,duration:e});let n=e.type||`interpolation`;return{...IM[n],...t,...e,type:n}}var RM=class extends DM{constructor(e,t){super(e,t,{startIndices:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:PM}),this.constant=!1,this.settings.update=t.update||(t.accessor?this._autoUpdater:void 0),Object.seal(this.settings),Object.seal(this.state),this._validateAttributeUpdaters()}get startIndices(){return this.state.startIndices}set startIndices(e){this.state.startIndices=e}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:e=!1}={}){let t=this.state.needsRedraw;return this.state.needsRedraw=t&&!e,t}layoutChanged(){return this.state.layoutChanged}setAccessor(e){var t;(t=this.state).layoutChanged||(t.layoutChanged=!wM(e,this.getAccessor())),super.setAccessor(e)}getUpdateTriggers(){let{accessor:e}=this.settings;return[this.id].concat(typeof e!=`function`&&e||[])}supportsTransition(){return!!this.settings.transition}getTransitionSetting(e){if(!e||!this.supportsTransition())return null;let{accessor:t}=this.settings,n=this.settings.transition;return LM(Array.isArray(t)?e[t.find(t=>e[t])]:e[t],n)}setNeedsUpdate(e=this.id,t){if(this.state.needsUpdate=this.state.needsUpdate||e,this.setNeedsRedraw(e),t){let{startRow:e=0,endRow:n=1/0}=t;this.state.updateRanges=FM(this.state.updateRanges,[e,n])}else this.state.updateRanges=PM}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=NM}setNeedsRedraw(e=this.id){this.state.needsRedraw=this.state.needsRedraw||e}allocate(e){let{state:t,settings:n}=this;return n.noAlloc?!1:n.update?(super.allocate(e,t.updateRanges!==PM),!0):!1}updateBuffer({numInstances:e,data:t,props:n,context:r}){if(!this.needsUpdate())return!1;let{state:{updateRanges:i},settings:{update:a,noAlloc:o}}=this,s=!0;if(a){for(let[o,s]of i)a.call(r,this,{data:t,startRow:o,endRow:s,props:n,numInstances:e});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLength<this.value.byteLength+this.byteOffset)this.constant?this.setConstantValue(r,this.value):this.setData({value:this.value,constant:this.constant}),this.constant=!1;else for(let[t,n]of i){let r=Number.isFinite(t)?this.getVertexOffset(t):0,i=Number.isFinite(n)?this.getVertexOffset(n):o||!Number.isFinite(e)?this.value.length:e*this.size;super.updateSubBuffer({startOffset:r,endOffset:i})}this._checkAttributeArray()}else s=!1;return this.clearNeedsUpdate(),this.setNeedsRedraw(),s}setConstantValue(e,t){if(t===void 0||typeof t==`function`)return!1;let n=this.settings.transform&&e?this.settings.transform.call(e,t):t;return this.device.type===`webgpu`?this.setConstantBufferValue(n,this.numInstances):(this.setData({constant:!0,value:n})&&this.setNeedsRedraw(),this.clearNeedsUpdate(),!0)}setConstantBufferValue(e,t){let n=this.settings.defaultType,r=this._normalizeValue(e,new n(this.size),0);if(this._hasConstantBufferValue(r,t))return this.constant=!1,this.clearNeedsUpdate(),!1;let i=new n(Math.max(t,1)*this.size);for(let e=0;e<i.length;e+=this.size)i.set(r,e);let a=this.setData({value:i});return this.constant=!1,this.clearNeedsUpdate(),a&&this.setNeedsRedraw(),a}_hasConstantBufferValue(e,t){let n=this.value,r=Math.max(t,1)*this.size;if(!ArrayBuffer.isView(n)||n.length!==r||n.length%this.size!==0)return!1;for(let t=0;t<n.length;t+=this.size)for(let r=0;r<this.size;r++)if(n[t+r]!==e[r])return!1;return!0}setExternalBuffer(e){let{state:t}=this;return e?(this.clearNeedsUpdate(),t.lastExternalBuffer===e?!0:(t.lastExternalBuffer=e,this.setNeedsRedraw(),this.setData(e),!0)):(t.lastExternalBuffer=null,!1)}setBinaryValue(e,t=null){let{state:n,settings:r}=this;if(!e)return n.binaryValue=null,n.binaryAccessor=null,!1;if(r.noAlloc)return!1;if(n.binaryValue===e)return this.clearNeedsUpdate(),!0;if(n.binaryValue=e,this.setNeedsRedraw(),r.transform||t!==this.startIndices){ArrayBuffer.isView(e)&&(e={value:e});let i=e;ZD(ArrayBuffer.isView(i.value),`invalid ${r.accessor}`);let a=!!i.size&&i.size!==this.size;return n.binaryAccessor=MM(i.value,{size:i.size||this.size,stride:i.stride,offset:i.offset,startIndices:t,nested:a}),!1}return this.clearNeedsUpdate(),this.setData(e),!0}getVertexOffset(e){let{startIndices:t}=this;return(t?e<t.length?t[e]:this.numInstances:e)*this.size}getValue(){let e=this.settings.shaderAttributes,t=super.getValue();if(!e)return t;for(let n in e)Object.assign(t,super.getValue(n,e[n]));return t}getBufferLayout(e){this.state.layoutChanged=!1;let t=this.settings.shaderAttributes,n=super._getBufferLayout(),{stepMode:r}=this.settings;if(r===`dynamic`?n.stepMode=e?e.isInstanced?`instance`:`vertex`:`instance`:n.stepMode=r??`vertex`,!t)return n;for(let e in t){let r=super._getBufferLayout(e,t[e]);n.attributes.push(...r.attributes)}return n}_autoUpdater(e,{data:t,startRow:n,endRow:r,props:i,numInstances:a}){let{settings:o,state:s,value:c,size:l,startIndices:u}=e,{accessor:d,transform:f}=o,p=s.binaryAccessor||(typeof d==`function`?d:i[d]);ZD(typeof p==`function`,`accessor "${d}" is not a function`);let m=e.getVertexOffset(n),{iterable:h,objectInfo:g}=AM(t,n,r);for(let t of h){g.index++;let n=p(t,g);if(f&&(n=f.call(this,n)),u){let t=(g.index<u.length-1?u[g.index+1]:a)-u[g.index];if(n&&Array.isArray(n[0])){let t=m;for(let r of n)e._normalizeValue(r,c,t),t+=l}else n&&n.length>l?c.set(n,m):(e._normalizeValue(n,g.target,0),TD({target:c,source:g.target,start:m,count:t}));m+=t*l}else e._normalizeValue(n,c,m),m+=l}}_validateAttributeUpdaters(){let{settings:e}=this;if(!(e.noAlloc||typeof e.update==`function`))throw Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){let{value:e}=this,t=Math.min(4,this.size);if(e&&e.length>=t){let n=!0;switch(t){case 4:n&&=Number.isFinite(e[3]);case 3:n&&=Number.isFinite(e[2]);case 2:n&&=Number.isFinite(e[1]);case 1:n&&=Number.isFinite(e[0]);break;default:n=!1}if(!n)throw Error(`Illegal attribute generated for ${this.id}`)}}};function zM(e){let{source:t,target:n,start:r=0,size:i,getData:a}=e,o=e.end||n.length,s=t.length,c=o-r;if(s>c){n.set(t.subarray(0,c),r);return}if(n.set(t,r),!a)return;let l=s;for(;l<c;){let e=a(l,t);for(let t=0;t<i;t++)n[r+l]=e[t]||0,l++}}function BM({source:e,target:t,size:n,getData:r,sourceStartIndices:i,targetStartIndices:a}){if(!i||!a)return zM({source:e,target:t,size:n,getData:r}),t;let o=0,s=0,c=r&&((e,t)=>r(e+s,t)),l=Math.min(i.length,a.length);for(let r=1;r<l;r++){let l=i[r]*n,u=a[r]*n;zM({source:e.subarray(o,l),target:t,start:s,end:u,size:n,getData:c}),o=l,s=u}return s<t.length&&zM({source:[],target:t,start:s,size:n,getData:c}),t}function VM(e){let{device:t,settings:n,value:r}=e,i=new RM(t,n);return i.setData({value:r instanceof Float64Array?new Float64Array:new Float32Array,normalized:n.normalized}),i}function HM(e){switch(e){case 1:return`float`;case 2:return`vec2`;case 3:return`vec3`;case 4:return`vec4`;default:throw Error(`No defined attribute type for size "${e}"`)}}function UM(e){switch(e){case 1:return`float32`;case 2:return`float32x2`;case 3:return`float32x3`;case 4:return`float32x4`;default:throw Error(`invalid type size`)}}function WM(e){e.push(e.shift())}function GM(e,t){let{doublePrecision:n,settings:r,value:i,size:a}=e,o=n&&i instanceof Float64Array?2:1,s=0,{shaderAttributes:c}=e.settings;if(c)for(let e of Object.values(c))s=Math.max(s,e.vertexOffset??0);return(r.noAlloc?i.length:(t+s)*a)*o}function KM({device:e,source:t,target:n}){return(!n||n.byteLength<t.byteLength)&&(n?.destroy(),n=e.createBuffer({byteLength:t.byteLength,usage:t.usage})),n}function qM({device:e,buffer:t,attribute:n,fromLength:r,toLength:i,fromStartIndices:a,getData:o=e=>e}){let s=n.doublePrecision&&n.value instanceof Float64Array?2:1,c=n.size*s,l=n.byteOffset,u=n.settings.bytesPerElement<4?l/n.settings.bytesPerElement*4:l,d=n.startIndices,f=a&&d,p=n.isConstant;if(!f&&t&&r>=i)return t;let m=n.value instanceof Float64Array?Float32Array:n.value.constructor,h=p?n.value:new m(n.getBuffer().readSyncWebGL(l,i*m.BYTES_PER_ELEMENT).buffer);if(n.settings.normalized&&!p){let e=o;o=(t,r)=>n.normalizeConstant(e(t,r))}let g=p?(e,t)=>o(h,t):(e,t)=>o(h.subarray(e+l,e+l+c),t),_=t?new Float32Array(t.readSyncWebGL(u,r*4).buffer):new Float32Array,v=new Float32Array(i);return BM({source:_,target:v,sourceStartIndices:a,targetStartIndices:d,size:c,getData:g}),(!t||t.byteLength<v.byteLength+u)&&(t?.destroy(),t=e.createBuffer({byteLength:v.byteLength+u,usage:35050})),t.write(v,u),t}var JM=class{constructor({device:e,attribute:t,timeline:n}){this.buffers=[],this.currentLength=0,this.device=e,this.transition=new GD(n),this.attribute=t,this.attributeInTransition=VM(t),this.currentStartIndices=t.startIndices}get inProgress(){return this.transition.inProgress}start(e,t,n=1/0){this.settings=e,this.currentStartIndices=this.attribute.startIndices,this.currentLength=GM(this.attribute,t),this.transition.start({...e,duration:n})}update(){let e=this.transition.update();return e&&this.onUpdate(),e}setBuffer(e){this.attributeInTransition.setData({buffer:e,normalized:this.attribute.settings.normalized,value:this.attributeInTransition.value})}cancel(){this.transition.cancel()}delete(){this.cancel();for(let e of this.buffers)e.destroy();this.buffers.length=0}},YM=class extends JM{constructor({device:e,attribute:t,timeline:n}){super({device:e,attribute:t,timeline:n}),this.type=`interpolation`,this.transform=eN(e,t)}start(e,t){let n=this.currentLength,r=this.currentStartIndices;if(super.start(e,t,e.duration),e.duration<=0){this.transition.cancel();return}let{buffers:i,attribute:a}=this;WM(i),i[0]=qM({device:this.device,buffer:i[0],attribute:a,fromLength:n,toLength:this.currentLength,fromStartIndices:r,getData:e.enter}),i[1]=KM({device:this.device,source:i[0],target:i[1]}),this.setBuffer(i[1]);let{transform:o}=this,s=o.model,c=Math.floor(this.currentLength/a.size);$M(a)&&(c/=2),s.setVertexCount(c),a.isConstant?(s.setAttributes({aFrom:i[0]}),s.setConstantAttributes({aTo:a.value})):s.setAttributes({aFrom:i[0],aTo:a.getBuffer()}),o.transformFeedback.setBuffers({vCurrent:i[1]})}onUpdate(){let{duration:e,easing:t}=this.settings,{time:n}=this.transition,r=n/e;t&&(r=t(r));let{model:i}=this.transform,a={time:r};i.shaderInputs.setProps({interpolation:a}),this.transform.run({discard:!0})}delete(){super.delete(),this.transform.destroy()}},XM={name:`interpolation`,vs:`layout(std140) uniform interpolationUniforms {
|
|
2087
|
+
${n.info.vendor}, ${n.info.renderer} for canvas: ${n.canvasContext.id}`;return Z.probe(Ok,r)(),Z.table(Ok,n.info)(),n}finally{Z.groupEnd(Ok)(),Z.info(Ok,`%cWebGL call tracing: luma.log.set('debug-webgl') `,`color: white; background: blue; padding: 2px 6px; border-radius: 3px;`)()}}};function Ak(e){return typeof WebGL2RenderingContext<`u`&&e instanceof WebGL2RenderingContext?!0:!!(e&&typeof e.createVertexArray==`function`)}var jk=new kk,Mk={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,35725:null,36006:null,36007:null,34229:null,34964:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32926:!1,32928:!1,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],36389:null,36662:null,36663:null,35053:null,35055:null,35723:4352,36010:null,35977:!1,3333:4,3317:4,37440:!1,37441:!1,37443:37444,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},Nk=(e,t,n)=>t?e.enable(n):e.disable(n),Pk=(e,t,n)=>e.hint(n,t),Fk=(e,t,n)=>e.pixelStorei(n,t),Ik=(e,t,n)=>{let r=n===36006?36009:36008;return e.bindFramebuffer(r,t)},Lk=(e,t,n)=>{let r={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[n];e.bindBuffer(r,t)};function Rk(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}var zk={3042:Nk,32773:(e,t)=>e.blendColor(...t),32777:`blendEquation`,34877:`blendEquation`,32969:`blendFunc`,32968:`blendFunc`,32971:`blendFunc`,32970:`blendFunc`,3106:(e,t)=>e.clearColor(...t),3107:(e,t)=>e.colorMask(...t),2884:Nk,2885:(e,t)=>e.cullFace(t),2929:Nk,2931:(e,t)=>e.clearDepth(t),2932:(e,t)=>e.depthFunc(t),2928:(e,t)=>e.depthRange(...t),2930:(e,t)=>e.depthMask(t),3024:Nk,35723:Pk,35725:(e,t)=>e.useProgram(t),36007:(e,t)=>e.bindRenderbuffer(36161,t),36389:(e,t)=>e.bindTransformFeedback?.(36386,t),34229:(e,t)=>e.bindVertexArray(t),36006:Ik,36010:Ik,34964:Lk,36662:Lk,36663:Lk,35053:Lk,35055:Lk,2886:(e,t)=>e.frontFace(t),33170:Pk,2849:(e,t)=>e.lineWidth(t),32823:Nk,32824:`polygonOffset`,10752:`polygonOffset`,35977:Nk,32926:Nk,32928:Nk,32938:`sampleCoverage`,32939:`sampleCoverage`,3089:Nk,3088:(e,t)=>e.scissor(...t),2960:Nk,2961:(e,t)=>e.clearStencil(t),2968:(e,t)=>e.stencilMaskSeparate(1028,t),36005:(e,t)=>e.stencilMaskSeparate(1029,t),2962:`stencilFuncFront`,2967:`stencilFuncFront`,2963:`stencilFuncFront`,34816:`stencilFuncBack`,36003:`stencilFuncBack`,36004:`stencilFuncBack`,2964:`stencilOpFront`,2965:`stencilOpFront`,2966:`stencilOpFront`,34817:`stencilOpBack`,34818:`stencilOpBack`,34819:`stencilOpBack`,2978:(e,t)=>e.viewport(...t),34383:Nk,10754:Nk,12288:Nk,12289:Nk,12290:Nk,12291:Nk,12292:Nk,12293:Nk,12294:Nk,12295:Nk,3333:Fk,3317:Fk,37440:Fk,37441:Fk,37443:Fk,3330:Fk,3332:Fk,3331:Fk,3314:Fk,32878:Fk,3316:Fk,3315:Fk,32877:Fk,framebuffer:(e,t)=>{let n=t&&`handle`in t?t.handle:t;return e.bindFramebuffer(36160,n)},blend:(e,t)=>t?e.enable(3042):e.disable(3042),blendColor:(e,t)=>e.blendColor(...t),blendEquation:(e,t)=>{let n=typeof t==`number`?[t,t]:t;e.blendEquationSeparate(...n)},blendFunc:(e,t)=>{let n=t?.length===2?[...t,...t]:t;e.blendFuncSeparate(...n)},clearColor:(e,t)=>e.clearColor(...t),clearDepth:(e,t)=>e.clearDepth(t),clearStencil:(e,t)=>e.clearStencil(t),colorMask:(e,t)=>e.colorMask(...t),cull:(e,t)=>t?e.enable(2884):e.disable(2884),cullFace:(e,t)=>e.cullFace(t),depthTest:(e,t)=>t?e.enable(2929):e.disable(2929),depthFunc:(e,t)=>e.depthFunc(t),depthMask:(e,t)=>e.depthMask(t),depthRange:(e,t)=>e.depthRange(...t),dither:(e,t)=>t?e.enable(3024):e.disable(3024),derivativeHint:(e,t)=>{e.hint(35723,t)},frontFace:(e,t)=>e.frontFace(t),mipmapHint:(e,t)=>e.hint(33170,t),lineWidth:(e,t)=>e.lineWidth(t),polygonOffsetFill:(e,t)=>t?e.enable(32823):e.disable(32823),polygonOffset:(e,t)=>e.polygonOffset(...t),sampleCoverage:(e,t)=>e.sampleCoverage(t[0],t[1]||!1),scissorTest:(e,t)=>t?e.enable(3089):e.disable(3089),scissor:(e,t)=>e.scissor(...t),stencilTest:(e,t)=>t?e.enable(2960):e.disable(2960),stencilMask:(e,t)=>{t=Rk(t)?t:[t,t];let[n,r]=t;e.stencilMaskSeparate(1028,n),e.stencilMaskSeparate(1029,r)},stencilFunc:(e,t)=>{t=Rk(t)&&t.length===3?[...t,...t]:t;let[n,r,i,a,o,s]=t;e.stencilFuncSeparate(1028,n,r,i),e.stencilFuncSeparate(1029,a,o,s)},stencilOp:(e,t)=>{t=Rk(t)&&t.length===3?[...t,...t]:t;let[n,r,i,a,o,s]=t;e.stencilOpSeparate(1028,n,r,i),e.stencilOpSeparate(1029,a,o,s)},viewport:(e,t)=>e.viewport(...t)};function Bk(e,t,n){return t[e]===void 0?n[e]:t[e]}var Vk={blendEquation:(e,t,n)=>e.blendEquationSeparate(Bk(32777,t,n),Bk(34877,t,n)),blendFunc:(e,t,n)=>e.blendFuncSeparate(Bk(32969,t,n),Bk(32968,t,n),Bk(32971,t,n),Bk(32970,t,n)),polygonOffset:(e,t,n)=>e.polygonOffset(Bk(32824,t,n),Bk(10752,t,n)),sampleCoverage:(e,t,n)=>e.sampleCoverage(Bk(32938,t,n),Bk(32939,t,n)),stencilFuncFront:(e,t,n)=>e.stencilFuncSeparate(1028,Bk(2962,t,n),Bk(2967,t,n),Bk(2963,t,n)),stencilFuncBack:(e,t,n)=>e.stencilFuncSeparate(1029,Bk(34816,t,n),Bk(36003,t,n),Bk(36004,t,n)),stencilOpFront:(e,t,n)=>e.stencilOpSeparate(1028,Bk(2964,t,n),Bk(2965,t,n),Bk(2966,t,n)),stencilOpBack:(e,t,n)=>e.stencilOpSeparate(1029,Bk(34817,t,n),Bk(34818,t,n),Bk(34819,t,n))},Hk={enable:(e,t)=>e({[t]:!0}),disable:(e,t)=>e({[t]:!1}),pixelStorei:(e,t,n)=>e({[t]:n}),hint:(e,t,n)=>e({[t]:n}),useProgram:(e,t)=>e({35725:t}),bindRenderbuffer:(e,t,n)=>e({36007:n}),bindTransformFeedback:(e,t,n)=>e({36389:n}),bindVertexArray:(e,t)=>e({34229:t}),bindFramebuffer:(e,t,n)=>{switch(t){case 36160:return e({36006:n,36010:n});case 36009:return e({36006:n});case 36008:return e({36010:n});default:return null}},bindBuffer:(e,t,n)=>{let r={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[t];return r?e({[r]:n}):{valueChanged:!0}},blendColor:(e,t,n,r,i)=>e({32773:new Float32Array([t,n,r,i])}),blendEquation:(e,t)=>e({32777:t,34877:t}),blendEquationSeparate:(e,t,n)=>e({32777:t,34877:n}),blendFunc:(e,t,n)=>e({32969:t,32968:n,32971:t,32970:n}),blendFuncSeparate:(e,t,n,r,i)=>e({32969:t,32968:n,32971:r,32970:i}),clearColor:(e,t,n,r,i)=>e({3106:new Float32Array([t,n,r,i])}),clearDepth:(e,t)=>e({2931:t}),clearStencil:(e,t)=>e({2961:t}),colorMask:(e,t,n,r,i)=>e({3107:[t,n,r,i]}),cullFace:(e,t)=>e({2885:t}),depthFunc:(e,t)=>e({2932:t}),depthRange:(e,t,n)=>e({2928:new Float32Array([t,n])}),depthMask:(e,t)=>e({2930:t}),frontFace:(e,t)=>e({2886:t}),lineWidth:(e,t)=>e({2849:t}),polygonOffset:(e,t,n)=>e({32824:t,10752:n}),sampleCoverage:(e,t,n)=>e({32938:t,32939:n}),scissor:(e,t,n,r,i)=>e({3088:new Int32Array([t,n,r,i])}),stencilMask:(e,t)=>e({2968:t,36005:t}),stencilMaskSeparate:(e,t,n)=>e({[t===1028?2968:36005]:n}),stencilFunc:(e,t,n,r)=>e({2962:t,2967:n,2963:r,34816:t,36003:n,36004:r}),stencilFuncSeparate:(e,t,n,r,i)=>e({[t===1028?2962:34816]:n,[t===1028?2967:36003]:r,[t===1028?2963:36004]:i}),stencilOp:(e,t,n,r)=>e({2964:t,2965:n,2966:r,34817:t,34818:n,34819:r}),stencilOpSeparate:(e,t,n,r,i)=>e({[t===1028?2964:34817]:n,[t===1028?2965:34818]:r,[t===1028?2966:34819]:i}),viewport:(e,t,n,r,i)=>e({2978:[t,n,r,i]})},Uk=(e,t)=>e.isEnabled(t),Wk={3042:Uk,2884:Uk,2929:Uk,3024:Uk,32823:Uk,32926:Uk,32928:Uk,3089:Uk,2960:Uk,35977:Uk},Gk=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068]);function Kk(e,t){if(Yk(t))return;let n={};for(let r in t){let i=Number(r),a=zk[r];a&&(typeof a==`string`?n[a]=!0:a(e,t[r],i))}let r=e.lumaState?.cache;if(r)for(let i in n){let n=Vk[i];n(e,t,r)}}function qk(e,t=Mk){if(typeof t==`number`){let n=t,r=Wk[n];return r?r(e,n):e.getParameter(n)}let n=Array.isArray(t)?t:Object.keys(t),r={};for(let t of n){let n=Wk[t];r[t]=n?n(e,Number(t)):e.getParameter(Number(t))}return r}function Jk(e){Kk(e,Mk)}function Yk(e){for(let t in e)return!1;return!0}function Xk(e,t){if(e===t)return!0;if(Zk(e)&&Zk(t)&&e.length===t.length){for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}return!1}function Zk(e){return Array.isArray(e)||ArrayBuffer.isView(e)}var Qk=class{static get(e){return e.lumaState}gl;program=null;stateStack=[];enable=!0;cache=null;log;initialized=!1;constructor(e,t){this.gl=e,this.log=t?.log||(()=>{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){let e=this.stateStack[this.stateStack.length-1];Kk(this.gl,e),this.stateStack.pop()}trackState(e,t){if(this.cache=t?.copyState?qk(e):Object.assign({},Mk),this.initialized)throw Error(`WebGLStateTracker`);this.initialized=!0,this.gl.lumaState=this,tA(e);for(let t in Hk){let n=Hk[t];eA(e,t,n)}$k(e,`getParameter`),$k(e,`isEnabled`)}_updateCache(e){let t=!1,n,r=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let i in e){let a=e[i],o=this.cache[i];Xk(a,o)||(t=!0,n=o,r&&!(i in r)&&(r[i]=o),this.cache[i]=a)}return{valueChanged:t,oldValue:n}}};function $k(e,t){let n=e[t].bind(e);e[t]=function(t){if(t===void 0||Gk.has(t))return n(t);let r=Qk.get(e);return t in r.cache||(r.cache[t]=n(t)),r.enable?r.cache[t]:n(t)},Object.defineProperty(e[t],"name",{value:`${t}-from-cache`,configurable:!1})}function eA(e,t,n){if(!e[t])return;let r=e[t].bind(e);e[t]=function(...t){let{valueChanged:i,oldValue:a}=n(Qk.get(e)._updateCache,...t);return i&&r(...t),a},Object.defineProperty(e[t],"name",{value:`${t}-to-cache`,configurable:!1})}function tA(e){let t=e.useProgram.bind(e);e.useProgram=function(n){let r=Qk.get(e);r.program!==n&&(t(n),r.program=n)}}function nA(e,t,n){let r=``,i=e=>{let t=e.statusMessage;t&&(r||=t)};e.addEventListener(`webglcontextcreationerror`,i,!1);let a=n.failIfMajorPerformanceCaveat!==!0,o={preserveDrawingBuffer:!0,...n,failIfMajorPerformanceCaveat:!0},s=null;try{s||=e.getContext(`webgl2`,o),!s&&o.failIfMajorPerformanceCaveat&&(r||="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.");let n=!1;if(!s&&a&&(o.failIfMajorPerformanceCaveat=!1,s=e.getContext(`webgl2`,o),n=!0),s||(s=e.getContext(`webgl`,{}),s&&(s=null,r||=`Your browser only supports WebGL1`)),!s)throw r||=`Your browser does not support WebGL`,Error(`Failed to create WebGL context: ${r}`);let i=ck(s);i.softwareRenderer=n;let{onContextLost:c,onContextRestored:l}=t;return e.addEventListener(`webglcontextlost`,e=>c(e),!1),e.addEventListener(`webglcontextrestored`,e=>l(e),!1),s}finally{e.removeEventListener(`webglcontextcreationerror`,i,!1)}}function rA(e,t,n){return n[t]===void 0&&(n[t]=e.getExtension(t)||null),n[t]}function iA(e,t){let n=e.getParameter(7936),r=e.getParameter(7937);rA(e,`WEBGL_debug_renderer_info`,t);let i=t.WEBGL_debug_renderer_info,a=e.getParameter(i?i.UNMASKED_VENDOR_WEBGL:7936),o=e.getParameter(i?i.UNMASKED_RENDERER_WEBGL:7937),s=a||n,c=o||r,l=e.getParameter(7938),u=aA(s,c),d=oA(s,c);return{type:`webgl`,gpu:u,gpuType:sA(s,c),gpuBackend:d,vendor:s,renderer:c,version:l,shadingLanguage:`glsl`,shadingLanguageVersion:300}}function aA(e,t){return/NVIDIA/i.exec(e)||/NVIDIA/i.exec(t)?`nvidia`:/INTEL/i.exec(e)||/INTEL/i.exec(t)?`intel`:/Apple/i.exec(e)||/Apple/i.exec(t)?`apple`:/AMD/i.exec(e)||/AMD/i.exec(t)||/ATI/i.exec(e)||/ATI/i.exec(t)?`amd`:/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t)?`software`:`unknown`}function oA(e,t){return/Metal/i.exec(e)||/Metal/i.exec(t)?`metal`:/ANGLE/i.exec(e)||/ANGLE/i.exec(t)?`opengl`:`unknown`}function sA(e,t){if(/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t))return`cpu`;switch(aA(e,t)){case`apple`:return cA(e,t)?`integrated`:`unknown`;case`intel`:return`integrated`;case`software`:return`cpu`;case`unknown`:return`unknown`;default:return`discrete`}}function cA(e,t){return/Apple (M\d|A\d|GPU)/i.test(`${e} ${t}`)}function lA(e){switch(e){case`uint8`:return 5121;case`sint8`:return 5120;case`unorm8`:return 5121;case`snorm8`:return 5120;case`uint16`:return 5123;case`sint16`:return 5122;case`unorm16`:return 5123;case`snorm16`:return 5122;case`uint32`:return 5125;case`sint32`:return 5124;case`float16`:return 5131;case`float32`:return 5126}throw Error(String(e))}var uA=`WEBGL_compressed_texture_s3tc`,dA=`WEBGL_compressed_texture_s3tc_srgb`,fA=`EXT_texture_compression_rgtc`,pA=`EXT_texture_compression_bptc`,mA=`WEBGL_compressed_texture_etc`,hA=`WEBGL_compressed_texture_astc`,gA=`WEBGL_compressed_texture_etc1`,_A=`WEBGL_compressed_texture_pvrtc`,vA=`WEBGL_compressed_texture_atc`,yA=`EXT_texture_norm16`,bA=`EXT_render_snorm`,xA=`EXT_color_buffer_float`,SA=`snorm8-renderable-webgl`,CA=`norm16-renderable-webgl`,wA=`snorm16-renderable-webgl`,TA=`float16-renderable-webgl`,EA=`float32-renderable-webgl`,DA=`rgb9e5ufloat-renderable-webgl`,OA={"float32-renderable-webgl":{extensions:[xA]},"float16-renderable-webgl":{extensions:[`EXT_color_buffer_half_float`]},"rgb9e5ufloat-renderable-webgl":{extensions:[`WEBGL_render_shared_exponent`]},"snorm8-renderable-webgl":{extensions:[bA]},"norm16-webgl":{extensions:[yA]},"norm16-renderable-webgl":{features:[`norm16-webgl`]},"snorm16-renderable-webgl":{features:[`norm16-webgl`],extensions:[bA]},"float32-filterable":{extensions:[`OES_texture_float_linear`]},"float16-filterable-webgl":{extensions:[`OES_texture_half_float_linear`]},"texture-filterable-anisotropic-webgl":{extensions:[`EXT_texture_filter_anisotropic`]},"texture-blend-float-webgl":{extensions:[`EXT_float_blend`]},"texture-compression-bc":{extensions:[uA,dA,fA,pA]},"texture-compression-bc5-webgl":{extensions:[fA]},"texture-compression-bc7-webgl":{extensions:[pA]},"texture-compression-etc2":{extensions:[mA]},"texture-compression-astc":{extensions:[hA]},"texture-compression-etc1-webgl":{extensions:[gA]},"texture-compression-pvrtc-webgl":{extensions:[_A]},"texture-compression-atc-webgl":{extensions:[vA]}};function kA(e){return e in OA}function AA(e,t,n){return jA(e,t,n,new Set)}function jA(e,t,n,r){let i=OA[t];if(!i||r.has(t))return!1;r.add(t);let a=(i.features||[]).every(t=>jA(e,t,n,r));return r.delete(t),a?(i.extensions||[]).every(t=>!!rA(e,t,n)):!1}var MA={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756,r:SA},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757,r:SA},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0,r:TA},r16unorm:{gl:33322,rb:!0,r:CA},r16snorm:{gl:36760,r:wA},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759,r:SA},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0,r:TA},rg16unorm:{gl:33324,r:CA},rg16snorm:{gl:36761,r:wA},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326,r:EA},rgb9e5ufloat:{gl:35901,r:DA},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852,r:!1},"rgb16snorm-webgl":{gl:36762,r:!1},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0,r:EA},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842,r:TA},rgba16unorm:{gl:32859,rb:!0,r:CA},rgba16snorm:{gl:36763,r:wA},"rgb32float-webgl":{gl:34837,x:xA,r:EA,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0,r:EA},stencil8:{gl:36168,rb:!0},depth16unorm:{gl:33189,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,dataFormat:6402,types:[5125]},depth32float:{gl:36012,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth32float-stencil8":{gl:36013,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:uA},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:dA},"bc1-rgba-unorm":{gl:33777,x:uA},"bc1-rgba-unorm-srgb":{gl:35916,x:dA},"bc2-rgba-unorm":{gl:33778,x:uA},"bc2-rgba-unorm-srgb":{gl:35918,x:dA},"bc3-rgba-unorm":{gl:33779,x:uA},"bc3-rgba-unorm-srgb":{gl:35919,x:dA},"bc4-r-unorm":{gl:36283,x:fA},"bc4-r-snorm":{gl:36284,x:fA},"bc5-rg-unorm":{gl:36285,x:fA},"bc5-rg-snorm":{gl:36286,x:fA},"bc6h-rgb-ufloat":{gl:36495,x:pA},"bc6h-rgb-float":{gl:36494,x:pA},"bc7-rgba-unorm":{gl:36492,x:pA},"bc7-rgba-unorm-srgb":{gl:36493,x:pA},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37816},"astc-10x5-unorm-srgb":{gl:37848},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rgb2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}};function NA(e,t,n){let r=t.create,i=MA[t.format];i?.gl===void 0&&(r=!1),i?.x&&(r&&=!!rA(e,i.x,n)),t.format===`stencil8`&&(r=!1);let a=i?.r===!1?!1:i?.r===void 0||AA(e,i.r,n),o=r&&t.render&&a&&PA(e,t.format,n);return{format:t.format,create:r&&t.create,render:o,filter:r&&t.filter,blend:r&&t.blend,store:r&&t.store}}function PA(e,t,n){let r=MA[t],i=r?.gl;if(i===void 0||r?.x&&!rA(e,r.x,n))return!1;let a=e.getParameter(32873),o=e.getParameter(36006),s=e.createTexture(),c=e.createFramebuffer();if(!s||!c)return!1;let l=Number(e.getError());for(;l!==0;)l=e.getError();let u=!1;try{if(e.bindTexture(3553,s),e.texStorage2D(3553,1,i,1,1),Number(e.getError())!==0)return!1;e.bindFramebuffer(36160,c),e.framebufferTexture2D(36160,36064,3553,s,0),u=Number(e.checkFramebufferStatus(36160))===36053&&Number(e.getError())===0}finally{e.bindFramebuffer(36160,o),e.deleteFramebuffer(c),e.bindTexture(3553,a),e.deleteTexture(s)}return u}function FA(e){let t=MA[e],n=RA(e),r=rb.getInfo(e);return r.compressed&&(t.dataFormat=n),{internalFormat:n,format:t?.dataFormat||LA(r.channels,r.integer,r.normalized,n),type:r.dataType?lA(r.dataType):t?.types?.[0]||5121,compressed:r.compressed||!1}}function IA(e){switch(rb.getInfo(e).attachment){case`depth`:return 36096;case`stencil`:return 36128;case`depth-stencil`:return 33306;default:throw Error(`Not a depth stencil format: ${e}`)}}function LA(e,t,n,r){if(r===6408||r===6407)return r;switch(e){case`r`:return t&&!n?36244:6403;case`rg`:return t&&!n?33320:33319;case`rgb`:return t&&!n?36248:6407;case`rgba`:return t&&!n?36249:6408;case`bgra`:throw Error(`bgra pixels not supported by WebGL`);default:return 6408}}function RA(e){let t=MA[e]?.gl;if(t===void 0)throw Error(`Unsupported texture format ${e}`);return t}var zA={"depth-clip-control":`EXT_depth_clamp`,"timestamp-query":`EXT_disjoint_timer_query_webgl2`,"compilation-status-async-webgl":`KHR_parallel_shader_compile`,"polygon-mode-webgl":`WEBGL_polygon_mode`,"provoking-vertex-webgl":`WEBGL_provoking_vertex`,"shader-clip-cull-distance-webgl":`WEBGL_clip_cull_distance`,"shader-noperspective-interpolation-webgl":`NV_shader_noperspective_interpolation`,"shader-conservative-depth-webgl":`EXT_conservative_depth`},BA=class extends vb{gl;extensions;testedFeatures=new Set;constructor(e,t,n){super([],n),this.gl=e,this.extensions=t,rA(e,`EXT_color_buffer_float`,t)}*[Symbol.iterator](){let e=this.getFeatures();for(let t of e)this.has(t)&&(yield t);return[]}has(e){return this.disabledFeatures?.[e]?!1:(this.testedFeatures.has(e)||(this.testedFeatures.add(e),kA(e)&&AA(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){let e=this.getFeatures().filter(e=>e!==`polygon-mode-webgl`);for(let t of e)this.has(t)}getFeatures(){return[...Object.keys(zA),...Object.keys(OA)]}getWebGLFeature(e){let t=zA[e];return typeof t==`string`?!!rA(this.gl,t,this.extensions):!!t}},VA=class extends fb{get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderVariables(){return this.getParameter(35659)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(e){super(),this.gl=e}getParameter(e){return this.limits[e]===void 0&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]||0}},HA=class extends rx{device;gl;handle;colorAttachments=[];depthStencilAttachment=null;constructor(e,t){super(e,t);let n=t.handle===null;this.device=e,this.gl=e.gl,this.handle=this.props.handle||n?this.props.handle:this.gl.createFramebuffer(),n||(e._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),t.handle||(this.autoCreateAttachmentTextures(),this.updateAttachments()))}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&!this.props.handle&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){let e=this.gl.bindFramebuffer(36160,this.handle);for(let e=0;e<this.colorAttachments.length;++e){let t=this.colorAttachments[e];if(t){let n=36064+e;this._attachTextureView(n,t)}}if(this.depthStencilAttachment){let e=IA(this.depthStencilAttachment.props.format);this._attachTextureView(e,this.depthStencilAttachment)}if(this.device.props.debug){let e=this.gl.checkFramebufferStatus(36160);if(e!==36053)throw Error(`Framebuffer ${WA(e)}`)}this.gl.bindFramebuffer(36160,e)}_attachTextureView(e,t){let{gl:n}=this.device,{texture:r}=t,i=t.props.baseMipLevel,a=t.props.baseArrayLayer;switch(n.bindTexture(r.glTarget,r.handle),r.glTarget){case 35866:case 32879:n.framebufferTextureLayer(36160,e,r.handle,i,a);break;case 34067:let t=UA(a);n.framebufferTexture2D(36160,e,t,r.handle,i);break;case 3553:n.framebufferTexture2D(36160,e,3553,r.handle,i);break;default:throw Error(`Illegal texture type`)}n.bindTexture(r.glTarget,null)}resizeAttachments(e,t){if(this.handle===null){this.width=e,this.height=t;return}super.resizeAttachments(e,t)}};function UA(e){return e<34069?e+34069:e}function WA(e){switch(e){case 36053:return`success`;case 36054:return`Mismatched attachments`;case 36055:return`No attachments`;case 36057:return`Height/width mismatch`;case 36061:return`Unsupported or split attachments`;case 36182:return`Samples mismatch`;default:return`${e}`}}var GA=class extends Hb{device;handle=null;_framebuffer=null;get[Symbol.toStringTag](){return`WebGLCanvasContext`}constructor(e,t){super(t),this.device=e,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this._configureDevice()}_configureDevice(){(this.drawingBufferWidth!==this._framebuffer?.width||this.drawingBufferHeight!==this._framebuffer?.height)&&this._framebuffer?.resize([this.drawingBufferWidth,this.drawingBufferHeight])}_getCurrentFramebuffer(){return this._framebuffer||=new HA(this.device,{id:`canvas-context-framebuffer`,handle:null,width:this.drawingBufferWidth,height:this.drawingBufferHeight}),this._framebuffer}},KA=class extends Ub{device;handle=null;context2d;get[Symbol.toStringTag](){return`WebGLPresentationContext`}constructor(e,t={}){super(t),this.device=e;let n=`${this[Symbol.toStringTag]}(${this.id})`;if(!this.device.getDefaultCanvasContext().offscreenCanvas)throw Error(`${n}: WebGL PresentationContext requires the default CanvasContext canvas to be an OffscreenCanvas`);let r=this.canvas.getContext(`2d`);if(!r)throw Error(`${n}: Failed to create 2d presentation context`);this.context2d=r,this._setAutoCreatedCanvasId(`${this.device.id}-presentation-canvas`),this._configureDevice(),this._startObservers()}present(){this._resizeDrawingBufferIfNeeded(),this.device.submit();let e=this.device.getDefaultCanvasContext(),[t,n]=e.getDrawingBufferSize();if(!(this.drawingBufferWidth===0||this.drawingBufferHeight===0||t===0||n===0||e.canvas.width===0||e.canvas.height===0)){if(t!==this.drawingBufferWidth||n!==this.drawingBufferHeight||e.canvas.width!==this.drawingBufferWidth||e.canvas.height!==this.drawingBufferHeight)throw Error(`${this[Symbol.toStringTag]}(${this.id}): Default canvas context size ${t}x${n} does not match presentation size ${this.drawingBufferWidth}x${this.drawingBufferHeight}`);this.context2d.clearRect(0,0,this.drawingBufferWidth,this.drawingBufferHeight),this.context2d.drawImage(e.canvas,0,0)}}_configureDevice(){}_getCurrentFramebuffer(e){let t=this.device.getDefaultCanvasContext();return t.setDrawingBufferSize(this.drawingBufferWidth,this.drawingBufferHeight),t.getCurrentFramebuffer(e)}},qA={};function JA(e=`id`){return qA[e]=qA[e]||1,`${e}-${qA[e]++}`}var YA=class extends ky{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength=0;bytesUsed=0;constructor(e,t={}){super(e,t),this.device=e,this.gl=this.device.gl;let n=typeof t==`object`?t.handle:void 0;this.handle=n||this.gl.createBuffer(),e._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=XA(this.props.usage),this.glUsage=ZA(this.props.usage),this.glIndexType=this.props.indexType===`uint32`?5125:5123,t.data?this._initWithData(t.data,t.byteOffset,t.byteLength):this._initWithByteLength(t.byteLength||0)}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory(`Buffer`):(this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle)),this.destroyed=!0,this.handle=null)}_initWithData(e,t=0,n=e.byteLength+t){let r=this.glTarget;this.gl.bindBuffer(r,this.handle),this.gl.bufferData(r,n,this.glUsage),this.gl.bufferSubData(r,t,e),this.gl.bindBuffer(r,null),this.bytesUsed=n,this.byteLength=n,this._setDebugData(e,t,n),this.props.handle?this.trackReferencedMemory(n,`Buffer`):this.trackAllocatedMemory(n)}_initWithByteLength(e){let t=e;e===0&&(t=new Float32Array);let n=this.glTarget;return this.gl.bindBuffer(n,this.handle),this.gl.bufferData(n,t,this.glUsage),this.gl.bindBuffer(n,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.props.handle?this.trackReferencedMemory(e,`Buffer`):this.trackAllocatedMemory(e),this}write(e,t=0){let n=ArrayBuffer.isView(e)?e:new Uint8Array(e),r=36663;this.gl.bindBuffer(r,this.handle),this.gl.bufferSubData(r,t,n),this.gl.bindBuffer(r,null),this._setDebugData(e,t,e.byteLength)}async mapAndWriteAsync(e,t=0,n=this.byteLength-t){let r=new ArrayBuffer(n);await e(r,`copied`),this.write(r,t)}async readAsync(e=0,t){return this.readSyncWebGL(e,t)}async mapAndReadAsync(e,t=0,n){return await e((await this.readAsync(t,n)).buffer,`copied`)}readSyncWebGL(e=0,t){t??=this.byteLength-e;let n=new Uint8Array(t);return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,n,0,t),this.gl.bindBuffer(36662,null),this._setDebugData(n,e,t),n}};function XA(e){return e&ky.INDEX?34963:e&ky.VERTEX?34962:e&ky.UNIFORM?35345:34962}function ZA(e){return e&ky.INDEX||e&ky.VERTEX?35044:e&ky.UNIFORM?35048:35044}function QA(e){let t=e.split(/\r?\n/),n=[];for(let e of t){if(e.length<=1)continue;let t=e.trim(),r=e.split(`:`),i=r[0]?.trim();if(r.length===2){let[e,a]=r;if(!e||!a){n.push({message:t,type:$A(i||`info`),lineNum:0,linePos:0});continue}n.push({message:a.trim(),type:$A(e),lineNum:0,linePos:0});continue}let[a,o,s,...c]=r;if(!a||!o||!s){n.push({message:r.slice(1).join(`:`).trim()||t,type:$A(i||`info`),lineNum:0,linePos:0});continue}let l=parseInt(s,10);Number.isNaN(l)&&(l=0);let u=parseInt(o,10);Number.isNaN(u)&&(u=0),n.push({message:c.join(`:`).trim(),type:$A(a),lineNum:l,linePos:u})}return n}function $A(e){let t=[`warning`,`error`,`info`],n=e.toLowerCase();return t.includes(n)?n:`info`}var ej=class extends ex{device;handle;constructor(e,t){switch(super(e,t),this.device=e,this.props.stage){case`vertex`:this.handle=this.props.handle||this.device.gl.createShader(35633);break;case`fragment`:this.handle=this.props.handle||this.device.gl.createShader(35632);break;default:throw Error(this.props.stage)}e._setWebGLDebugMetadata(this.handle,this,{spector:this.props});let n=this._compile(this.source);n&&typeof n.catch==`function`&&n.catch(()=>{this.compilationStatus=`error`})}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.destroyed=!0)}get asyncCompilationStatus(){return this._waitForCompilationComplete().then(()=>(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let e=this.device.gl.getShaderInfoLog(this.handle);return e?QA(e):[]}getTranslatedSource(){return this.device.getExtension(`WEBGL_debug_shaders`).WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)||null}_compile(e){e=e.startsWith(`#version `)?e:`#version 300 es\n${e}`;let{gl:t}=this.device;if(t.shaderSource(this.handle,e),t.compileShader(this.handle),!this.device.props.debug){this.compilationStatus=`pending`;return}if(!this.device.features.has(`compilation-status-async-webgl`)){if(this._getCompilationStatus(),this.debugShader(),this.compilationStatus===`error`)throw Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);return}return Z.once(1,`Shader compilation is asynchronous`)(),this._waitForCompilationComplete().then(()=>{Z.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()})}async _waitForCompilationComplete(){let e=async e=>await new Promise(t=>setTimeout(t,e));if(!this.device.features.has(`compilation-status-async-webgl`)){await e(10);return}let{gl:t}=this.device;for(;;){if(t.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?`success`:`error`}};function tj(e,t,n,r){if(uj(t))return r(e);let i=e;i.pushState();try{return nj(e,t),Kk(i.gl,n),r(e)}finally{i.popState()}}function nj(e,t){let n=e,{gl:r}=n;if(t.cullMode)switch(t.cullMode){case`none`:r.disable(2884);break;case`front`:r.enable(2884),r.cullFace(1028);break;case`back`:r.enable(2884),r.cullFace(1029);break}if(t.frontFace&&r.frontFace(cj(`frontFace`,t.frontFace,{ccw:2305,cw:2304})),t.unclippedDepth&&e.features.has(`depth-clip-control`)&&r.enable(34383),t.depthBias!==void 0&&(r.enable(32823),r.polygonOffset(t.depthBias,t.depthBiasSlopeScale||0)),t.provokingVertex&&e.features.has(`provoking-vertex-webgl`)){let e=n.getExtension(`WEBGL_provoking_vertex`).WEBGL_provoking_vertex,r=cj(`provokingVertex`,t.provokingVertex,{first:36429,last:36430});e?.provokingVertexWEBGL(r)}if((t.polygonMode||t.polygonOffsetLine)&&e.features.has(`polygon-mode-webgl`)){if(t.polygonMode){let e=n.getExtension(`WEBGL_polygon_mode`).WEBGL_polygon_mode,r=cj(`polygonMode`,t.polygonMode,{fill:6914,line:6913});e?.polygonModeWEBGL(1028,r),e?.polygonModeWEBGL(1029,r)}t.polygonOffsetLine&&r.enable(10754)}if(e.features.has(`shader-clip-cull-distance-webgl`)&&(t.clipDistance0&&r.enable(12288),t.clipDistance1&&r.enable(12289),t.clipDistance2&&r.enable(12290),t.clipDistance3&&r.enable(12291),t.clipDistance4&&r.enable(12292),t.clipDistance5&&r.enable(12293),t.clipDistance6&&r.enable(12294),t.clipDistance7&&r.enable(12295)),t.depthWriteEnabled!==void 0&&r.depthMask(lj(`depthWriteEnabled`,t.depthWriteEnabled)),t.depthCompare&&(t.depthCompare===`always`?r.disable(2929):r.enable(2929),r.depthFunc(rj(`depthCompare`,t.depthCompare))),t.clearDepth!==void 0&&r.clearDepth(t.clearDepth),t.stencilWriteMask){let e=t.stencilWriteMask;r.stencilMaskSeparate(1028,e),r.stencilMaskSeparate(1029,e)}if(t.stencilReadMask&&Z.warn(`stencilReadMask not supported under WebGL`),t.stencilCompare){let e=t.stencilReadMask||4294967295,n=rj(`depthCompare`,t.stencilCompare);t.stencilCompare===`always`?r.disable(2960):r.enable(2960),r.stencilFuncSeparate(1028,n,0,e),r.stencilFuncSeparate(1029,n,0,e)}if(t.stencilPassOperation&&t.stencilFailOperation&&t.stencilDepthFailOperation){let e=ij(`stencilPassOperation`,t.stencilPassOperation),n=ij(`stencilFailOperation`,t.stencilFailOperation),i=ij(`stencilDepthFailOperation`,t.stencilDepthFailOperation);r.stencilOpSeparate(1028,n,i,e),r.stencilOpSeparate(1029,n,i,e)}switch(t.blend){case!0:r.enable(3042);break;case!1:r.disable(3042);break;default:}if(t.blendColorOperation||t.blendAlphaOperation){let e=aj(`blendColorOperation`,t.blendColorOperation||`add`),n=aj(`blendAlphaOperation`,t.blendAlphaOperation||`add`);r.blendEquationSeparate(e,n);let i=oj(`blendColorSrcFactor`,t.blendColorSrcFactor||`one`),a=oj(`blendColorDstFactor`,t.blendColorDstFactor||`zero`),o=oj(`blendAlphaSrcFactor`,t.blendAlphaSrcFactor||`one`),s=oj(`blendAlphaDstFactor`,t.blendAlphaDstFactor||`zero`);r.blendFuncSeparate(i,a,o,s)}}function rj(e,t){return cj(e,t,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function ij(e,t){return cj(e,t,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function aj(e,t){return cj(e,t,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function oj(e,t,n=`color`){return cj(e,t,{one:1,zero:0,src:768,"one-minus-src":769,dst:774,"one-minus-dst":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,constant:n===`color`?32769:32771,"one-minus-constant":n===`color`?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function sj(e,t){return`Illegal parameter ${t} for ${e}`}function cj(e,t,n){if(!(t in n))throw Error(sj(e,t));return n[t]}function lj(e,t){return t}function uj(e){let t=!0;for(let n in e){t=!1;break}return t}function dj(e){let t={};return e.addressModeU&&(t[10242]=fj(e.addressModeU)),e.addressModeV&&(t[10243]=fj(e.addressModeV)),e.addressModeW&&(t[32882]=fj(e.addressModeW)),e.magFilter&&(t[10240]=pj(e.magFilter)),(e.minFilter||e.mipmapFilter)&&(t[10241]=mj(e.minFilter||`linear`,e.mipmapFilter)),e.lodMinClamp!==void 0&&(t[33082]=e.lodMinClamp),e.lodMaxClamp!==void 0&&(t[33083]=e.lodMaxClamp),e.type===`comparison-sampler`&&(t[34892]=34894),e.compare&&(t[34893]=rj(`compare`,e.compare)),e.maxAnisotropy&&(t[34046]=e.maxAnisotropy),t}function fj(e){switch(e){case`clamp-to-edge`:return 33071;case`repeat`:return 10497;case`mirror-repeat`:return 33648}}function pj(e){switch(e){case`nearest`:return 9728;case`linear`:return 9729}}function mj(e,t=`none`){if(!t)return pj(e);switch(t){case`none`:return pj(e);case`nearest`:switch(e){case`nearest`:return 9984;case`linear`:return 9985}break;case`linear`:switch(e){case`nearest`:return 9986;case`linear`:return 9987}}}var hj=class extends Wb{device;handle;parameters;constructor(e,t){super(e,t),this.device=e,this.parameters=dj(t),this.handle=t.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&=(this.device.gl.deleteSampler(this.handle),void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(e){for(let[t,n]of Object.entries(e)){let e=Number(t);switch(e){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,e,n);break;default:this.device.gl.samplerParameteri(this.handle,e,n);break}}}};function gj(e,t,n){if(_j(t))return n(e);let{nocatch:r=!0}=t,i=Qk.get(e);i.push(),Kk(e,t);let a;if(r)a=n(e),i.pop();else try{a=n(e)}finally{i.pop()}return a}function _j(e){for(let t in e)return!1;return!0}var vj=class extends qb{device;gl;handle;texture;constructor(e,t){super(e,{...Kb.defaultProps,...t}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=t.texture}};function yj(e){return bj[e]}var bj={5124:`sint32`,5125:`uint32`,5122:`sint16`,5123:`uint16`,5120:`sint8`,5121:`uint8`,5126:`float32`,5131:`float16`,33635:`uint16`,32819:`uint16`,32820:`uint16`,33640:`uint32`,35899:`uint32`,35902:`uint32`,34042:`uint32`,36269:`uint32`},xj=class extends Kb{device;gl;handle;sampler=void 0;view;glTarget;glFormat;glType;glInternalFormat;compressed;_textureUnit=0;_framebuffer=null;_framebufferAttachmentKey=null;constructor(e,t){super(e,t,{byteAlignment:1}),this.device=e,this.gl=this.device.gl;let n=FA(this.props.format);this.glTarget=wj(this.props.dimension),this.glInternalFormat=n.internalFormat,this.glFormat=n.format,this.glType=n.type,this.compressed=n.compressed,this.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this.gl.bindTexture(this.glTarget,this.handle);let{dimension:r,width:i,height:a,depth:o,mipLevels:s,glTarget:c,glInternalFormat:l}=this;if(!this.compressed)switch(r){case`2d`:case`cube`:this.gl.texStorage2D(c,s,l,i,a);break;case`2d-array`:case`3d`:this.gl.texStorage3D(c,s,l,i,a,o);break;default:throw Error(r)}this.gl.bindTexture(this.glTarget,null),this._initializeData(t.data),this.props.handle?this.trackReferencedMemory(this.getAllocatedByteLength(),`Texture`):this.trackAllocatedMemory(this.getAllocatedByteLength(),`Texture`),this.setSampler(this.props.sampler),this.view=new vj(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this._framebuffer?.destroy(),this._framebuffer=null,this._framebufferAttachmentKey=null,this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory(`Texture`):(this.gl.deleteTexture(this.handle),this.trackDeallocatedMemory(`Texture`)),this.destroyed=!0)}createView(e){return new vj(this.device,{...e,texture:this})}setSampler(e={}){super.setSampler(e);let t=dj(this.sampler.props);this._setSamplerParameters(t)}copyExternalImage(e){let t=this._normalizeCopyExternalImageOptions(e);if(t.sourceX||t.sourceY)throw Error(`WebGL does not support sourceX/sourceY)`);let{glFormat:n,glType:r}=this,{image:i,depth:a,mipLevel:o,x:s,y:c,z:l,width:u,height:d}=t,f=Tj(this.glTarget,this.dimension,l),p=t.flipY?{37440:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),gj(this.gl,p,()=>{switch(this.dimension){case`2d`:case`cube`:this.gl.texSubImage2D(f,o,s,c,u,d,n,r,i);break;case`2d-array`:case`3d`:this.gl.texSubImage3D(f,o,s,c,l,u,d,a,n,r,i);break;default:}}),this.gl.bindTexture(this.glTarget,null),{width:t.width,height:t.height}}copyImageData(e){super.copyImageData(e)}readBuffer(e={},t){if(!t)throw Error(`${this} readBuffer requires a destination buffer`);let n=this._getSupportedColorReadOptions(e),r=e.byteOffset??0,i=this.computeMemoryLayout(n);if(t.byteLength<r+i.byteLength)throw Error(`${this} readBuffer target is too small (${t.byteLength} < ${r+i.byteLength})`);let a=t;this.gl.bindBuffer(35051,a.handle);try{this._readColorTextureLayers(n,i,e=>{this.gl.readPixels(n.x,n.y,n.width,n.height,this.glFormat,this.glType,r+e)})}finally{this.gl.bindBuffer(35051,null)}return t}async readDataAsync(e={}){throw Error(`${this} readDataAsync is deprecated; use readBuffer() with an explicit destination buffer or DynamicTexture.readAsync()`)}writeBuffer(e,t={}){let n=this._normalizeTextureWriteOptions(t),{width:r,height:i,depthOrArrayLayers:a,mipLevel:o,byteOffset:s,x:c,y:l,z:u}=n,{glFormat:d,glType:f,compressed:p}=this,m=Tj(this.glTarget,this.dimension,u);if(p)throw Error(`writeBuffer for compressed textures is not implemented in WebGL`);let{bytesPerPixel:h}=this.device.getTextureFormatInfo(this.format),g=h?n.bytesPerRow/h:void 0,_={3317:this.byteAlignment,...g===void 0?{}:{3314:g},32878:n.rowsPerImage};this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,e.handle),gj(this.gl,_,()=>{switch(this.dimension){case`2d`:case`cube`:this.gl.texSubImage2D(m,o,c,l,r,i,d,f,s);break;case`2d-array`:case`3d`:this.gl.texSubImage3D(m,o,c,l,u,r,i,a,d,f,s);break;default:}}),this.gl.bindBuffer(35052,null),this.gl.bindTexture(this.glTarget,null)}writeData(e,t={}){let n=this._normalizeTextureWriteOptions(t),r=ArrayBuffer.isView(e)?e:new Uint8Array(e),{width:i,height:a,depthOrArrayLayers:o,mipLevel:s,x:c,y:l,z:u,byteOffset:d}=n,{glFormat:f,glType:p,compressed:m}=this,h=Tj(this.glTarget,this.dimension,u),g;if(!m){let{bytesPerPixel:e}=this.device.getTextureFormatInfo(this.format);e&&(g=n.bytesPerRow/e)}let _=this.compressed?{}:{3317:this.byteAlignment,...g===void 0?{}:{3314:g},32878:n.rowsPerImage},v=Cj(r,d),y=m?Sj(r,d):r,b=this._getMipLevelSize(s),x=c===0&&l===0&&u===0&&i===b.width&&a===b.height&&o===b.depthOrArrayLayers;this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,null),gj(this.gl,_,()=>{switch(this.dimension){case`2d`:case`cube`:m?x?this.gl.compressedTexImage2D(h,s,f,i,a,0,y):this.gl.compressedTexSubImage2D(h,s,c,l,i,a,f,y):this.gl.texSubImage2D(h,s,c,l,i,a,f,p,r,v);break;case`2d-array`:case`3d`:m?x?this.gl.compressedTexImage3D(h,s,f,i,a,o,0,y):this.gl.compressedTexSubImage3D(h,s,c,l,u,i,a,o,f,y):this.gl.texSubImage3D(h,s,c,l,u,i,a,o,f,p,r,v);break;default:}}),this.gl.bindTexture(this.glTarget,null)}_getRowByteAlignment(e,t){return 1}_getFramebuffer(){return this._framebuffer||=this.device.createFramebuffer({id:`framebuffer-for-${this.id}`,width:this.width,height:this.height,colorAttachments:[this]}),this._framebuffer}readDataSyncWebGL(e={}){let t=this._getSupportedColorReadOptions(e),n=this.computeMemoryLayout(t),r=Vx(yj(this.glType)),i=new r(n.byteLength/r.BYTES_PER_ELEMENT);return this._readColorTextureLayers(t,n,e=>{let a=new r(i.buffer,i.byteOffset+e,n.bytesPerImage/r.BYTES_PER_ELEMENT);this.gl.readPixels(t.x,t.y,t.width,t.height,this.glFormat,this.glType,a)}),i.buffer}_readColorTextureLayers(e,t,n){let r=this._getFramebuffer(),i=t.bytesPerRow/t.bytesPerPixel,a={3333:this.byteAlignment,...i===e.width?{}:{3330:i}},o=this.gl.getParameter(3074),s=this.gl.bindFramebuffer(36160,r.handle);try{this.gl.readBuffer(36064),gj(this.gl,a,()=>{for(let i=0;i<e.depthOrArrayLayers;i++)this._attachReadSubresource(r,e.mipLevel,e.z+i),n(i*t.bytesPerImage)})}finally{this.gl.bindFramebuffer(36160,s||null),this.gl.readBuffer(o)}}_attachReadSubresource(e,t,n){let r=`${t}:${n}`;if(this._framebufferAttachmentKey!==r){switch(this.dimension){case`2d`:this.gl.framebufferTexture2D(36160,36064,3553,this.handle,t);break;case`cube`:this.gl.framebufferTexture2D(36160,36064,Tj(this.glTarget,this.dimension,n),this.handle,t);break;case`2d-array`:case`3d`:this.gl.framebufferTextureLayer(36160,36064,this.handle,t,n);break;default:throw Error(`${this} color readback does not support ${this.dimension} textures`)}if(this.device.props.debug){let t=Number(this.gl.checkFramebufferStatus(36160));if(t!==36053)throw Error(`${e} incomplete for ${this} readback (${t})`)}this._framebufferAttachmentKey=r}}generateMipmapsWebGL(e){if(!(!(this.device.isTextureFormatRenderable(this.props.format)&&this.device.isTextureFormatFilterable(this.props.format))&&(Z.warn(`${this} is not renderable or filterable, may not be able to generate mipmaps`)(),!e?.force)))try{this.gl.bindTexture(this.glTarget,this.handle),this.gl.generateMipmap(this.glTarget)}catch(e){Z.warn(`Error generating mipmap for ${this}: ${e.message}`)()}finally{this.gl.bindTexture(this.glTarget,null)}}_setSamplerParameters(e){Z.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(e))(),this.gl.bindTexture(this.glTarget,this.handle);for(let[t,n]of Object.entries(e)){let e=Number(t),r=n;switch(e){case 33082:case 33083:this.gl.texParameterf(this.glTarget,e,r);break;case 10240:case 10241:this.gl.texParameteri(this.glTarget,e,r);break;case 10242:case 10243:case 32882:this.gl.texParameteri(this.glTarget,e,r);break;case 34046:this.device.features.has(`texture-filterable-anisotropic-webgl`)&&this.gl.texParameteri(this.glTarget,e,r);break;case 34892:case 34893:this.gl.texParameteri(this.glTarget,e,r);break}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(e){let{gl:t}=this;return e!==void 0&&(this._textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.glTarget,this.handle),e}_unbind(e){let{gl:t}=this;return e!==void 0&&(this._textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.glTarget,null),e}};function Sj(e,t=0){return t?new e.constructor(e.buffer,e.byteOffset+t,(e.byteLength-t)/e.BYTES_PER_ELEMENT):e}function Cj(e,t){if(t%e.BYTES_PER_ELEMENT!==0)throw Error(`Texture byteOffset ${t} must align to typed array element size ${e.BYTES_PER_ELEMENT}`);return t/e.BYTES_PER_ELEMENT}function wj(e){switch(e){case`1d`:break;case`2d`:return 3553;case`3d`:return 32879;case`cube`:return 34067;case`2d-array`:return 35866;case`cube-array`:break}throw Error(e)}function Tj(e,t,n){return t===`cube`?34069+n:e}function Ej(e,t,n,r){let i=e,a=r;a===!0&&(a=1),a===!1&&(a=0);let o=typeof a==`number`?[a]:a;switch(n){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof r!=`number`)throw Error(`samplers must be set to integers`);return e.uniform1i(t,r);case 5126:return e.uniform1fv(t,o);case 35664:return e.uniform2fv(t,o);case 35665:return e.uniform3fv(t,o);case 35666:return e.uniform4fv(t,o);case 5124:return e.uniform1iv(t,o);case 35667:return e.uniform2iv(t,o);case 35668:return e.uniform3iv(t,o);case 35669:return e.uniform4iv(t,o);case 35670:return e.uniform1iv(t,o);case 35671:return e.uniform2iv(t,o);case 35672:return e.uniform3iv(t,o);case 35673:return e.uniform4iv(t,o);case 5125:return i.uniform1uiv(t,o,1);case 36294:return i.uniform2uiv(t,o,2);case 36295:return i.uniform3uiv(t,o,3);case 36296:return i.uniform4uiv(t,o,4);case 35674:return e.uniformMatrix2fv(t,!1,o);case 35675:return e.uniformMatrix3fv(t,!1,o);case 35676:return e.uniformMatrix4fv(t,!1,o);case 35685:return i.uniformMatrix2x3fv(t,!1,o);case 35686:return i.uniformMatrix2x4fv(t,!1,o);case 35687:return i.uniformMatrix3x2fv(t,!1,o);case 35688:return i.uniformMatrix3x4fv(t,!1,o);case 35689:return i.uniformMatrix4x2fv(t,!1,o);case 35690:return i.uniformMatrix4x3fv(t,!1,o)}throw Error(`Illegal uniform`)}function Dj(e){switch(e){case`point-list`:return 0;case`line-list`:return 1;case`line-strip`:return 3;case`triangle-list`:return 4;case`triangle-strip`:return 5;default:throw Error(e)}}function Oj(e){switch(e){case`point-list`:return 0;case`line-list`:return 1;case`line-strip`:return 1;case`triangle-list`:return 4;case`triangle-strip`:return 4;default:throw Error(e)}}var kj=class extends ix{device;handle;vs;fs;introspectedLayout;bindings={};uniforms={};varyings=null;_uniformCount=0;_uniformSetters={};get[Symbol.toStringTag](){return`WEBGLRenderPipeline`}constructor(e,t){super(e,t),this.device=e;let n=this.sharedRenderPipeline||this.device._createSharedRenderPipelineWebGL(t);this.sharedRenderPipeline=n,this.handle=n.handle,this.vs=n.vs,this.fs=n.fs,this.linkStatus=n.linkStatus,this.introspectedLayout=n.introspectedLayout,this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.shaderLayout=t.shaderLayout?Aj(this.introspectedLayout,t.shaderLayout):this.introspectedLayout}destroy(){this.destroyed||(this.sharedRenderPipeline&&!this.props._sharedRenderPipeline&&this.sharedRenderPipeline.destroy(),this.destroyResource())}setBindings(e,t){let n=dx(ux(this.shaderLayout,e));for(let[e,r]of Object.entries(n)){let n=jj(this.shaderLayout,e);if(n){switch(r||Z.warn(`Unsetting binding "${e}" in render pipeline "${this.id}"`)(),n.type){case`uniform`:if(!(r instanceof YA)&&!(r.buffer instanceof YA))throw Error(`buffer value`);break;case`texture`:if(!(r instanceof vj||r instanceof xj||r instanceof HA))throw Error(`${this} Bad texture binding for ${e}`);break;case`sampler`:Z.warn(`Ignoring sampler ${e}`)();break;default:throw Error(n.type)}this.bindings[e]=r}else{let n=this.shaderLayout.bindings.map(e=>`"${e.name}"`).join(`, `);t?.disableWarnings||Z.warn(`No binding "${e}" in render pipeline "${this.id}", expected one of ${n}`,r)()}}}draw(e){this._syncLinkStatus();let t=e.bindGroups?dx(e.bindGroups):e.bindings||this.bindings,{renderPass:n,parameters:r=this.props.parameters,topology:i=this.props.topology,vertexArray:a,vertexCount:o,instanceCount:s,isInstanced:c=!1,firstVertex:l=0,transformFeedback:u,uniforms:d=this.uniforms}=e,f=Dj(i),p=!!a.indexBuffer,m=a.indexBuffer?.glIndexType;if(this.linkStatus!==`success`)return Z.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable(t))return Z.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(this.handle),a.bindBeforeRender(n),u&&u.begin(this.props.topology),this._applyBindings(t,{disableWarnings:this.props.disableWarnings}),this._applyUniforms(d);let h=n;return tj(this.device,r,h.glParameters,()=>{p&&c?this.device.gl.drawElementsInstanced(f,o||0,m,l,s||0):p?this.device.gl.drawElements(f,o||0,m,l):c?this.device.gl.drawArraysInstanced(f,l,o||0,s||0):this.device.gl.drawArrays(f,l,o||0),u&&u.end()}),a.unbindAfterRender(n),!0}_areTexturesRenderable(e){let t=!0;for(let n of this.shaderLayout.bindings)Mj(e,n.name)||(Z.warn(`Binding ${n.name} not found in ${this.id}`)(),t=!1);return t}_applyBindings(e,t){if(this._syncLinkStatus(),this.linkStatus!==`success`)return;let{gl:n}=this.device;n.useProgram(this.handle);let r=0,i=0;for(let t of this.shaderLayout.bindings){let a=Mj(e,t.name);if(!a)throw Error(`No value for binding ${t.name} in ${this.id}`);switch(t.type){case`uniform`:let{name:e}=t,o=n.getUniformBlockIndex(this.handle,e);if(o===4294967295)throw Error(`Invalid uniform block name ${e}`);if(n.uniformBlockBinding(this.handle,o,i),a instanceof YA)n.bindBufferBase(35345,i,a.handle);else{let e=a;n.bindBufferRange(35345,i,e.buffer.handle,e.offset||0,e.size||e.buffer.byteLength-(e.offset||0))}i+=1;break;case`texture`:if(!(a instanceof vj||a instanceof xj||a instanceof HA))throw Error(`texture`);let s;if(a instanceof vj)s=a.texture;else if(a instanceof xj)s=a;else if(a instanceof HA&&a.colorAttachments[0]instanceof vj)Z.warn(`Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead`)(),s=a.colorAttachments[0].texture;else throw Error(`No texture`);n.activeTexture(33984+r),n.bindTexture(s.glTarget,s.handle),r+=1;break;case`sampler`:break;case`storage`:case`read-only-storage`:throw Error(`binding type '${t.type}' not supported in WebGL`)}}}_applyUniforms(e){for(let t of this.shaderLayout.uniforms||[]){let{name:n,location:r,type:i,textureUnit:a}=t,o=e[n]??a;o!==void 0&&Ej(this.device.gl,r,i,o)}}_syncLinkStatus(){this.linkStatus=this.sharedRenderPipeline.linkStatus}};function Aj(e,t){let n={...e,attributes:e.attributes.map(e=>({...e})),bindings:e.bindings.map(e=>({...e}))};for(let e of t?.attributes||[]){let t=n.attributes.find(t=>t.name===e.name);t?(t.type=e.type||t.type,t.stepMode=e.stepMode||t.stepMode):Z.warn(`shader layout attribute ${e.name} not present in shader`)}for(let e of t?.bindings||[]){let t=jj(n,e.name);if(!t){Z.warn(`shader layout binding ${e.name} not present in shader`);continue}Object.assign(t,e)}return n}function jj(e,t){return e.bindings.find(e=>e.name===t||e.name===`${t}Uniforms`||`${e.name}Uniforms`===t)}function Mj(e,t){return e[t]||e[`${t}Uniforms`]||e[t.replace(/Uniforms$/,``)]}function Nj(e){return zj[e]}function Pj(e){return Lj[e]}function Fj(e){return!!Rj[e]}function Ij(e){return Rj[e]}var Lj={5126:`f32`,35664:`vec2<f32>`,35665:`vec3<f32>`,35666:`vec4<f32>`,5124:`i32`,35667:`vec2<i32>`,35668:`vec3<i32>`,35669:`vec4<i32>`,5125:`u32`,36294:`vec2<u32>`,36295:`vec3<u32>`,36296:`vec4<u32>`,35670:`f32`,35671:`vec2<f32>`,35672:`vec3<f32>`,35673:`vec4<f32>`,35674:`mat2x2<f32>`,35685:`mat2x3<f32>`,35686:`mat2x4<f32>`,35687:`mat3x2<f32>`,35675:`mat3x3<f32>`,35688:`mat3x4<f32>`,35689:`mat4x2<f32>`,35690:`mat4x3<f32>`,35676:`mat4x4<f32>`},Rj={35678:{viewDimension:`2d`,sampleType:`float`},35680:{viewDimension:`cube`,sampleType:`float`},35679:{viewDimension:`3d`,sampleType:`float`},35682:{viewDimension:`3d`,sampleType:`depth`},36289:{viewDimension:`2d-array`,sampleType:`float`},36292:{viewDimension:`2d-array`,sampleType:`depth`},36293:{viewDimension:`cube`,sampleType:`float`},36298:{viewDimension:`2d`,sampleType:`sint`},36299:{viewDimension:`3d`,sampleType:`sint`},36300:{viewDimension:`cube`,sampleType:`sint`},36303:{viewDimension:`2d-array`,sampleType:`uint`},36306:{viewDimension:`2d`,sampleType:`uint`},36307:{viewDimension:`3d`,sampleType:`uint`},36308:{viewDimension:`cube`,sampleType:`uint`},36311:{viewDimension:`2d-array`,sampleType:`uint`}},zj={uint8:5121,sint8:5120,unorm8:5121,snorm8:5120,uint16:5123,sint16:5122,unorm16:5123,snorm16:5122,uint32:5125,sint32:5124,float16:5131,float32:5126};function Bj(e,t){let n={attributes:[],bindings:[]};n.attributes=Vj(e,t);let r=Wj(e,t);for(let e of r){let t=e.uniforms.map(e=>({name:e.name,format:e.format,byteOffset:e.byteOffset,byteStride:e.byteStride,arrayLength:e.arrayLength}));n.bindings.push({type:`uniform`,name:e.name,group:0,location:e.location,visibility:!!e.vertex&(e.fragment?2:0),minBindingSize:e.byteLength,uniforms:t})}let i=Uj(e,t),a=0;for(let e of i)if(Fj(e.type)){let{viewDimension:t,sampleType:r}=Ij(e.type);n.bindings.push({type:`texture`,name:e.name,group:0,location:a,viewDimension:t,sampleType:r}),e.textureUnit=a,a+=1}i.length&&(n.uniforms=i);let o=Hj(e,t);return o?.length&&(n.varyings=o),n}function Vj(e,t){let n=[],r=e.getProgramParameter(t,35721);for(let i=0;i<r;i++){let r=e.getActiveAttrib(t,i);if(!r)throw Error(`activeInfo`);let{name:a,type:o}=r,s=e.getAttribLocation(t,a);if(s>=0){let e=Pj(o),t=/instance/i.test(a)?`instance`:`vertex`;n.push({name:a,location:s,stepMode:t,type:e})}}return n.sort((e,t)=>e.location-t.location),n}function Hj(e,t){let n=[],r=e.getProgramParameter(t,35971);for(let i=0;i<r;i++){let r=e.getTransformFeedbackVarying(t,i);if(!r)throw Error(`activeInfo`);let{name:a,type:o,size:s}=r,{type:c,components:l}=gx(Pj(o));n.push({location:i,name:a,type:c,size:s*l})}return n.sort((e,t)=>e.location-t.location),n}function Uj(e,t){let n=[],r=e.getProgramParameter(t,35718);for(let i=0;i<r;i++){let r=e.getActiveUniform(t,i);if(!r)throw Error(`activeInfo`);let{name:a,size:o,type:s}=r,{name:c,isArray:l}=Gj(a),u=e.getUniformLocation(t,c),d={location:u,name:c,size:o,type:s,isArray:l};if(n.push(d),d.size>1)for(let r=0;r<d.size;r++){let i=`${c}[${r}]`;u=e.getUniformLocation(t,i);let a={...d,name:i,location:u};n.push(a)}}return n}function Wj(e,t){let n=(n,r)=>e.getActiveUniformBlockParameter(t,n,r),r=[],i=e.getProgramParameter(t,35382);for(let a=0;a<i;a++){let i={name:e.getActiveUniformBlockName(t,a)||``,location:n(a,35391),byteLength:n(a,35392),vertex:n(a,35396),fragment:n(a,35398),uniformCount:n(a,35394),uniforms:[]},o=n(a,35395)||[],s=e.getActiveUniforms(t,o,35383),c=e.getActiveUniforms(t,o,35384),l=e.getActiveUniforms(t,o,35387),u=e.getActiveUniforms(t,o,35388);for(let n=0;n<i.uniformCount;++n){let r=o[n];if(r!==void 0){let a=e.getActiveUniform(t,r);if(!a)throw Error(`activeInfo`);let o=Pj(s[n]);i.uniforms.push({name:a.name,format:o,type:s[n],arrayLength:c[n],byteOffset:l[n],byteStride:u[n]})}}let d=new Set(i.uniforms.map(e=>e.name.split(`.`)[0]).filter(e=>!!e)),f=i.name.replace(/Uniforms$/,``);if(d.size===1&&!d.has(i.name)&&!d.has(f)){let[e]=d;Z.warn(`Uniform block "${i.name}" uses GLSL instance "${e}". luma.gl binds uniform buffers by block name ("${i.name}") and alias ("${f}"). Prefer matching the instance name to one of those to avoid confusing silent mismatches.`)()}r.push(i)}return r.sort((e,t)=>e.location-t.location),r}function Gj(e){if(e[e.length-1]!==`]`)return{name:e,length:1,isArray:!1};let t=/([^[]*)(\[[0-9]+\])?/.exec(e);return{name:Pb(t?.[1],`Failed to parse GLSL uniform name ${e}`),length:+!!t?.[2],isArray:!!t?.[2]}}var Kj=4,qj=class extends ax{device;handle;vs;fs;introspectedLayout={attributes:[],bindings:[],uniforms:[]};linkStatus=`pending`;constructor(e,t){super(e,t),this.device=e,this.handle=t.handle||this.device.gl.createProgram(),this.vs=t.vs,this.fs=t.fs,t.varyings&&t.varyings.length>0&&this.device.gl.transformFeedbackVaryings(this.handle,t.varyings,t.bufferMode||35981),this._linkShaders(),Z.time(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=Bj(this.device.gl,this.handle),Z.timeEnd(3,`RenderPipeline ${this.id} - shaderLayout introspection`)()}destroy(){this.destroyed||(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.handle.destroyed=!0,this.destroyResource())}async _linkShaders(){let{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),Z.time(Kj,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),Z.timeEnd(Kj,`linkProgram for ${this.id}`)(),!this.device.features.has(`compilation-status-async-webgl`)){let e=this._getLinkStatus();this._reportLinkStatus(e);return}Z.once(1,`RenderPipeline linking is asynchronous`)(),await this._waitForLinkComplete(),Z.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let t=this._getLinkStatus();this._reportLinkStatus(t)}async _reportLinkStatus(e){switch(e){case`success`:return;default:let t=e===`link-error`?`Link error`:`Validation error`;switch(this.vs.compilationStatus){case`error`:throw this.vs.debugShader(),Error(`${this} ${t} during compilation of ${this.vs}`);case`pending`:await this.vs.asyncCompilationStatus,this.vs.debugShader();break;case`success`:break}switch(this.fs?.compilationStatus){case`error`:throw this.fs.debugShader(),Error(`${this} ${t} during compilation of ${this.fs}`);case`pending`:await this.fs.asyncCompilationStatus,this.fs.debugShader();break;case`success`:break}let n=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(Error(`${t} during ${e}: ${n}`),this)(),this.device.debug()}}_getLinkStatus(){let{gl:e}=this.device;return e.getProgramParameter(this.handle,35714)?(this._initializeSamplerUniforms(),e.validateProgram(this.handle),e.getProgramParameter(this.handle,35715)?(this.linkStatus=`success`,`success`):(this.linkStatus=`error`,`validation-error`)):(this.linkStatus=`error`,`link-error`)}_initializeSamplerUniforms(){let{gl:e}=this.device;e.useProgram(this.handle);let t=0,n=e.getProgramParameter(this.handle,35718);for(let r=0;r<n;r++){let n=e.getActiveUniform(this.handle,r);if(n&&Fj(n.type)){let r=n.name.endsWith(`[0]`),i=r?n.name.slice(0,-3):n.name,a=e.getUniformLocation(this.handle,i);a!==null&&(t=this._assignSamplerUniform(a,n,r,t))}}}_assignSamplerUniform(e,t,n,r){let{gl:i}=this.device;if(n&&t.size>1){let n=Int32Array.from({length:t.size},(e,t)=>r+t);return i.uniform1iv(e,n),r+t.size}return i.uniform1i(e,r),r+1}async _waitForLinkComplete(){let e=async e=>await new Promise(t=>setTimeout(t,e));if(!this.device.features.has(`compilation-status-async-webgl`)){await e(10);return}let{gl:t}=this.device;for(;;){if(t.getProgramParameter(this.handle,37297))return;await e(10)}}},Jj=class extends hx{device;handle=null;commands=[];constructor(e,t={}){super(e,t),this.device=e}_executeCommands(e=this.commands){for(let t of e)switch(t.name){case`copy-buffer-to-buffer`:Yj(this.device,t.options);break;case`copy-buffer-to-texture`:Xj(this.device,t.options);break;case`copy-texture-to-buffer`:Zj(this.device,t.options);break;case`copy-texture-to-texture`:Qj(this.device,t.options);break;default:throw Error(t.name)}}};function Yj(e,t){let n=t.sourceBuffer,r=t.destinationBuffer;e.gl.bindBuffer(36662,n.handle),e.gl.bindBuffer(36663,r.handle),e.gl.copyBufferSubData(36662,36663,t.sourceOffset??0,t.destinationOffset??0,t.size),e.gl.bindBuffer(36662,null),e.gl.bindBuffer(36663,null)}function Xj(e,t){throw Error(`copyBufferToTexture is not supported in WebGL`)}function Zj(e,t){let{sourceTexture:n,mipLevel:r=0,aspect:i=`all`,width:a=t.sourceTexture.width,height:o=t.sourceTexture.height,depthOrArrayLayers:s,origin:c=[0,0,0],destinationBuffer:l,byteOffset:u=0,bytesPerRow:d,rowsPerImage:f}=t;if(n instanceof Kb){n.readBuffer({x:c[0]??0,y:c[1]??0,z:c[2]??0,width:a,height:o,depthOrArrayLayers:s,mipLevel:r,aspect:i,byteOffset:u},l);return}if(i!==`all`)throw Error(`aspect not supported in WebGL`);if(r!==0||s!==void 0||d||f)throw Error(`not implemented`);let{framebuffer:p,destroyFramebuffer:m}=$j(n),h;try{let t=l,n=a||p.width,r=o||p.height,i=FA(Pb(p.colorAttachments[0]).texture.props.format),s=i.format,d=i.type;e.gl.bindBuffer(35051,t.handle),h=e.gl.bindFramebuffer(36160,p.handle),e.gl.readPixels(c[0],c[1],n,r,s,d,u)}finally{e.gl.bindBuffer(35051,null),h!==void 0&&e.gl.bindFramebuffer(36160,h),m&&p.destroy()}}function Qj(e,t){let{sourceTexture:n,destinationMipLevel:r=0,origin:i=[0,0],destinationOrigin:a=[0,0,0],destinationTexture:o}=t,{width:s=t.destinationTexture.width,height:c=t.destinationTexture.height}=t,{framebuffer:l,destroyFramebuffer:u}=$j(n),[d=0,f=0]=i,[p,m,h]=a,g=e.gl.bindFramebuffer(36160,l.handle),_,v;if(o instanceof xj)_=o,s=Number.isFinite(s)?s:_.width,c=Number.isFinite(c)?c:_.height,_._bind(0),v=_.glTarget;else throw Error(`invalid destination`);switch(v){case 3553:case 34067:e.gl.copyTexSubImage2D(v,r,p,m,d,f,s,c);break;case 35866:case 32879:e.gl.copyTexSubImage3D(v,r,p,m,h,d,f,s,c);break;default:}_&&_._unbind(),e.gl.bindFramebuffer(36160,g),u&&l.destroy()}function $j(e){if(e instanceof Kb){let{width:t,height:n,id:r}=e;return{framebuffer:e.device.createFramebuffer({id:`framebuffer-for-${r}`,width:t,height:n,colorAttachments:[e]}),destroyFramebuffer:!0}}return{framebuffer:e,destroyFramebuffer:!1}}var eM=[1,2,4,8],tM=class extends px{device;handle=null;glParameters={};constructor(e,t){super(e,t),this.device=e;let n=this.props.framebuffer,r=!n||n.handle===null;r&&e.getDefaultCanvasContext()._resizeDrawingBufferIfNeeded();let i;if(!t?.parameters?.viewport)if(!r&&n){let{width:e,height:t}=n;i=[0,0,e,t]}else{let[t,n]=e.getDefaultCanvasContext().getDrawingBufferSize();i=[0,0,t,n]}if(this.device.pushState(),this.setParameters({viewport:i,...this.props.parameters}),!r&&n?.colorAttachments.length){let e=n.colorAttachments.map((e,t)=>36064+t);this.device.gl.drawBuffers(e)}else r&&this.device.gl.drawBuffers([1029]);this.clear(),this.props.timestampQuerySet&&this.props.beginTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.beginTimestampIndex)}end(){this.destroyed||(this.props.timestampQuerySet&&this.props.endTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.endTimestampIndex),this.device.popState(),this.destroy())}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}setParameters(e={}){let t={...this.glParameters};t.framebuffer=this.props.framebuffer||null,this.props.depthReadOnly&&(t.depthMask=!this.props.depthReadOnly),t.stencilMask=+!this.props.stencilReadOnly,t[35977]=this.props.discard,e.viewport&&(e.viewport.length>=6?(t.viewport=e.viewport.slice(0,4),t.depthRange=[e.viewport[4],e.viewport[5]]):t.viewport=e.viewport),e.scissorRect&&(t.scissorTest=!0,t.scissor=e.scissorRect),e.blendConstant&&(t.blendColor=e.blendConstant),e.stencilReference!==void 0&&(t[2967]=e.stencilReference,t[36003]=e.stencilReference),`colorMask`in e&&(t.colorMask=eM.map(t=>!!(t&e.colorMask))),this.glParameters=t,Kk(this.device.gl,t)}beginOcclusionQuery(e){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let e={...this.glParameters},t=0;this.props.clearColors&&this.props.clearColors.forEach((e,t)=>{e&&this.clearColorBuffer(t,e)}),this.props.clearColor!==!1&&this.props.clearColors===void 0&&(t|=16384,e.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(t|=256,e.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(t|=1024,e.clearStencil=this.props.clearStencil),t!==0&&gj(this.device.gl,e,()=>{this.device.gl.clear(t)})}clearColorBuffer(e=0,t=[0,0,0,0]){gj(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,e,t);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,e,t);break;case Float32Array:this.device.gl.clearBufferfv(6144,e,t);break;default:throw Error(`clearColorBuffer: color must be typed array`)}})}},nM=class extends mx{device;handle=null;commandBuffer;constructor(e,t){super(e,t),this.device=e,this.commandBuffer=new Jj(e,{id:`${this.props.id}-command-buffer`})}destroy(){this.destroyResource()}finish(e){return e?.id&&this.commandBuffer.id!==e.id&&(this.commandBuffer.id=e.id,this.commandBuffer.props.id=e.id),this.destroy(),this.commandBuffer}beginRenderPass(e={}){return new tM(this.device,this._applyTimeProfilingToPassProps(e))}beginComputePass(e={}){throw Error(`ComputePass not supported in WebGL`)}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:`copy-buffer-to-buffer`,options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:`copy-buffer-to-texture`,options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:`copy-texture-to-buffer`,options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:`copy-texture-to-texture`,options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,t,n){throw Error(`resolveQuerySet is not supported in WebGL`)}writeTimestamp(e,t){e.writeTimestamp(t)}};function rM(e){let{target:t,source:n,start:r=0,count:i=1}=e,a=n.length,o=i*a,s=0;for(let e=r;s<a;s++)t[e++]=n[s]??0;for(;s<o;)s<o-s?(t.copyWithin(r+s,r,r+s),s*=2):(t.copyWithin(r+s,r,r+o-s),s=o);return e.target}var iM=class e extends Ix{get[Symbol.toStringTag](){return`VertexArray`}device;handle;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return pd()===`Chrome`}constructor(e,t){super(e,t),this.device=e,this.handle=this.device.gl.createVertexArray()}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&=(this.device.gl.deleteVertexArray(this.handle),void 0)}setIndexBuffer(e){let t=e;if(t&&t.glTarget!==34963)throw Error(`Use .setBuffer()`);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,t?t.handle:null),this.indexBuffer=t,this.device.gl.bindVertexArray(null)}setBuffer(e,t){let n=t;if(n.glTarget===34963)throw Error(`Use .setIndexBuffer()`);let{size:r,type:i,stride:a,offset:o,normalized:s,integer:c,divisor:l}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,n.handle),c?this.device.gl.vertexAttribIPointer(e,r,i,a,o):this.device.gl.vertexAttribPointer(e,r,i,s,a,o),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,l||0),this.attributes[e]=n,this.device.gl.bindVertexArray(null)}setConstantWebGL(e,t){this._enable(e,!1),this.attributes[e]=t}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let e=0;e<this.maxVertexAttributes;++e){let t=this.attributes[e];ArrayBuffer.isView(t)&&this.device.setConstantAttributeWebGL(e,t)}}_getAccessor(e){let t=this.attributeInfos[e];if(!t)throw Error(`Unknown attribute location ${e}`);let n=lA(t.bufferDataType);return{size:t.bufferComponents,type:n,stride:t.byteStride,offset:t.byteOffset,normalized:t.normalized,integer:t.integer,divisor:+(t.stepMode===`instance`)}}_enable(t,n=!0){let r=e.isConstantAttributeZeroSupported(this.device)||t!==0;(n||r)&&(t=Number(t),this.device.gl.bindVertexArray(this.handle),n?this.device.gl.enableVertexAttribArray(t):this.device.gl.disableVertexAttribArray(t),this.device.gl.bindVertexArray(null))}getConstantBuffer(e,t){let n=aM(t),r=n.byteLength*e,i=n.length*e;if(this.buffer&&r!==this.buffer.byteLength)throw Error(`Buffer size is immutable, byte length ${r} !== ${this.buffer.byteLength}.`);let a=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:r}),a||=!oM(n,this.bufferValue),a){let e=rS(t.constructor,i);rM({target:e,source:n,start:0,count:i}),this.buffer.write(e),this.bufferValue=t}return this.buffer}};function aM(e){return Array.isArray(e)?new Float32Array(e):e}function oM(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}var sM=class extends Lx{device;gl;handle;layout;buffers={};unusedBuffers={};bindOnUse=!0;_bound=!1;constructor(e,t){super(e,t),this.device=e,this.gl=e.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,t.buffers&&this.setBuffers(t.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(e=`point-list`){this.gl.bindTransformFeedback(36386,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(Oj(e))}end(){this.gl.endTransformFeedback(),this.bindOnUse&&this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null)}setBuffers(e){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(let[t,n]of Object.entries(e))this.setBuffer(t,n)})}setBuffer(e,t){let n=this._getVaryingIndex(e),{buffer:r,byteLength:i,byteOffset:a}=this._getBufferRange(t);if(n<0){this.unusedBuffers[e]=r,Z.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[n]={buffer:r,byteLength:i,byteOffset:a},this.bindOnUse||this._bindBuffer(n,r,a,i)}getBuffer(e){if(cM(e))return this.buffers[e]||null;let t=this._getVaryingIndex(e);return this.buffers[t]??null}bind(e=this.handle){if(typeof e!=`function`)return this.gl.bindTransformFeedback(36386,e),this;let t;return this._bound?t=e():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,t=e(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),t}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof YA)return{buffer:e,byteOffset:0,byteLength:e.byteLength};let{buffer:t,byteOffset:n=0,byteLength:r=e.buffer.byteLength}=e;return{buffer:t,byteOffset:n,byteLength:r}}_getVaryingIndex(e){if(cM(e))return Number(e);for(let t of this.layout.varyings||[])if(e===t.name)return t.location;return-1}_bindBuffers(){for(let[e,t]of Object.entries(this.buffers)){let{buffer:n,byteLength:r,byteOffset:i}=this._getBufferRange(t);this._bindBuffer(Number(e),n,i,r)}}_unbindBuffers(){for(let e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,t,n=0,r){let i=t&&t.handle;!i||r===void 0?this.gl.bindBufferBase(35982,e,i):this.gl.bindBufferRange(35982,e,i,n,r)}};function cM(e){return typeof e==`number`?Number.isInteger(e):/^\d+$/.test(e)}var lM=class extends Rx{device;handle;_timestampPairs=[];_pendingReads=new Set;_occlusionQuery=null;_occlusionActive=!1;get[Symbol.toStringTag](){return`QuerySet`}constructor(e,t){if(super(e,t),this.device=e,t.type===`timestamp`){if(t.count<2)throw Error(`Timestamp QuerySet requires at least two query slots`);this._timestampPairs=Array(Math.ceil(t.count/2)).fill(null).map(()=>({activeQuery:null,completedQueries:[]})),this.handle=null}else{if(t.count>1)throw Error(`WebGL occlusion QuerySet can only have one value`);let e=this.device.gl.createQuery();if(!e)throw Error(`WebGL query not supported`);this.handle=e}Object.seal(this)}destroy(){if(!this.destroyed){this.handle&&this.device.gl.deleteQuery(this.handle);for(let e of this._timestampPairs){e.activeQuery&&(this._cancelPendingQuery(e.activeQuery),this.device.gl.deleteQuery(e.activeQuery.handle));for(let t of e.completedQueries)this._cancelPendingQuery(t),this.device.gl.deleteQuery(t.handle)}this._occlusionQuery&&(this._cancelPendingQuery(this._occlusionQuery),this.device.gl.deleteQuery(this._occlusionQuery.handle));for(let e of Array.from(this._pendingReads))this._cancelPendingQuery(e);this.destroyResource()}}isResultAvailable(e){return this.props.type===`timestamp`?e===void 0?this._timestampPairs.some((e,t)=>this._isTimestampPairAvailable(t)):this._isTimestampPairAvailable(this._getTimestampPairIndex(e)):this._occlusionQuery?this._pollQueryAvailability(this._occlusionQuery):!1}async readResults(e){let t=e?.firstQuery||0,n=e?.queryCount||this.props.count-t;if(this._validateRange(t,n),this.props.type===`timestamp`){let e=Array(n).fill(0n),r=Math.floor(t/2),i=Math.floor((t+n-1)/2);for(let a=r;a<=i;a++){let r=await this._consumeTimestampPairResult(a),i=a*2,o=i+1;i>=t&&i<t+n&&(e[i-t]=0n),o>=t&&o<t+n&&(e[o-t]=r)}return e}if(!this._occlusionQuery)throw Error(`Occlusion query has not been started`);return[await this._consumeQueryResult(this._occlusionQuery)]}async readTimestampDuration(e,t){if(this.props.type!==`timestamp`)throw Error(`Timestamp durations require a timestamp QuerySet`);if(e<0||t>=this.props.count||t<=e)throw Error(`Timestamp duration range is out of bounds`);if(e%2!=0||t!==e+1)throw Error(`WebGL timestamp durations require adjacent even/odd query indices`);let n=await this._consumeTimestampPairResult(this._getTimestampPairIndex(e));return Number(n)/1e6}beginOcclusionQuery(){if(this.props.type!==`occlusion`)throw Error(`Occlusion queries require an occlusion QuerySet`);if(!this.handle)throw Error(`WebGL occlusion query is not available`);if(this._occlusionActive)throw Error(`Occlusion query is already active`);this.device.gl.beginQuery(35887,this.handle),this._occlusionQuery={handle:this.handle,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null},this._occlusionActive=!0}endOcclusionQuery(){if(!this._occlusionActive)throw Error(`Occlusion query is not active`);this.device.gl.endQuery(35887),this._occlusionActive=!1}writeTimestamp(e){if(this.props.type!==`timestamp`)throw Error(`Timestamp writes require a timestamp QuerySet`);let t=this._getTimestampPairIndex(e),n=this._timestampPairs[t];if(e%2==0){if(n.activeQuery)throw Error(`Timestamp query pair is already active`);let e=this.device.gl.createQuery();if(!e)throw Error(`WebGL query not supported`);let t={handle:e,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null};this.device.gl.beginQuery(35007,e),n.activeQuery=t;return}if(!n.activeQuery)throw Error(`Timestamp query pair was ended before it was started`);this.device.gl.endQuery(35007),n.completedQueries.push(n.activeQuery),n.activeQuery=null}_validateRange(e,t){if(e<0||t<0||e+t>this.props.count)throw Error(`Query read range is out of bounds`)}_getTimestampPairIndex(e){if(e<0||e>=this.props.count)throw Error(`Query index is out of bounds`);return Math.floor(e/2)}_isTimestampPairAvailable(e){let t=this._timestampPairs[e];return!t||t.completedQueries.length===0?!1:this._pollQueryAvailability(t.completedQueries[0])}_pollQueryAvailability(e){if(e.cancelled||this.destroyed)return e.result=0n,!0;if(e.result!==null||e.disjoint)return!0;if(!this.device.gl.getQueryParameter(e.handle,34919))return!1;let t=!!this.device.gl.getParameter(36795);return e.disjoint=t,e.result=t?0n:BigInt(this.device.gl.getQueryParameter(e.handle,34918)),!0}async _consumeTimestampPairResult(e){let t=this._timestampPairs[e];if(!t||t.completedQueries.length===0)throw Error(`Timestamp query pair has no completed result`);let n=t.completedQueries.shift();try{return await this._consumeQueryResult(n)}finally{this.device.gl.deleteQuery(n.handle)}}_consumeQueryResult(e){return e.promise?e.promise:(this._pendingReads.add(e),e.promise=new Promise((t,n)=>{e.resolve=t,e.reject=n;let r=()=>{if(e.pollRequestId=null,e.cancelled||this.destroyed){this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,t(0n);return}if(!this._pollQueryAvailability(e)){e.pollRequestId=this._requestAnimationFrame(r);return}this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,e.disjoint?n(Error(`GPU timestamp query was invalidated by a disjoint event`)):t(e.result||0n)};r()}),e.promise)}_cancelPendingQuery(e){if(this._pendingReads.delete(e),e.cancelled=!0,e.pollRequestId!==null&&(this._cancelAnimationFrame(e.pollRequestId),e.pollRequestId=null),e.resolve){let t=e.resolve;e.promise=null,e.resolve=null,e.reject=null,t(0n)}}_requestAnimationFrame(e){return requestAnimationFrame(e)}_cancelAnimationFrame(e){cancelAnimationFrame(e)}},uM=class extends zx{device;gl;handle;signaled;_signaled=!1;constructor(e,t={}){super(e,{}),this.device=e,this.gl=e.gl;let n=this.props.handle||this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE,0);if(!n)throw Error(`Failed to create WebGL fence`);this.handle=n,this.signaled=new Promise(e=>{let t=()=>{let n=this.gl.clientWaitSync(this.handle,0,0);n===this.gl.ALREADY_SIGNALED||n===this.gl.CONDITION_SATISFIED?(this._signaled=!0,e()):setTimeout(t,1)};t()})}isSignaled(){if(this._signaled)return!0;let e=this.gl.getSyncParameter(this.handle,this.gl.SYNC_STATUS);return this._signaled=e===this.gl.SIGNALED,this._signaled}destroy(){this.destroyed||this.gl.deleteSync(this.handle)}};function dM(e){switch(e){case 6406:case 33326:case 6403:case 36244:return 1;case 33339:case 33340:case 33328:case 33320:case 33319:return 2;case 6407:case 36248:case 34837:return 3;case 6408:case 36249:case 34836:return 4;default:return 0}}function fM(e){switch(e){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}function pM(e,t){let{sourceX:n=0,sourceY:r=0,sourceAttachment:i=0}=t||{},{target:a=null,sourceWidth:o,sourceHeight:s,sourceDepth:c,sourceFormat:l,sourceType:u}=t||{},{framebuffer:d,deleteFramebuffer:f}=hM(e),{gl:p,handle:m}=d;o||=d.width,s||=d.height;let h=d.colorAttachments[i]?.texture;if(!h)throw Error(`Invalid framebuffer attachment ${i}`);c=h?.depth||1,l||=h?.glFormat||6408,u||=h?.glType||5121,a=_M(a,u,l,o,s,c);let g=Ay.getDataType(a);u||=Nj(g);let _=p.bindFramebuffer(36160,m);return p.readBuffer(36064+i),p.readPixels(n,r,o,s,l,u,a),p.readBuffer(36064),p.bindFramebuffer(36160,_||null),f&&d.destroy(),a}function mM(e,t){let{target:n,sourceX:r=0,sourceY:i=0,sourceFormat:a=6408,targetByteOffset:o=0}=t||{},{sourceWidth:s,sourceHeight:c,sourceType:l}=t||{},{framebuffer:u,deleteFramebuffer:d}=hM(e);s||=u.width,c||=u.height;let f=u;l||=5121;let p=n;if(!p){let e=dM(a),t=fM(l),n=o+s*c*e*t;p=f.device.createBuffer({byteLength:n})}let m=e.device.createCommandEncoder();return m.copyTextureToBuffer({sourceTexture:e,width:s,height:c,origin:[r,i],destinationBuffer:p,byteOffset:o}),m.destroy(),d&&u.destroy(),p}function hM(e){return e instanceof rx?{framebuffer:e,deleteFramebuffer:!1}:{framebuffer:gM(e),deleteFramebuffer:!0}}function gM(e,t){let{device:n,width:r,height:i,id:a}=e;return n.createFramebuffer({...t,id:`framebuffer-for-${a}`,width:r,height:i,colorAttachments:[e]})}function _M(e,t,n,r,i,a){if(e)return e;t||=5121;let o=yj(t),s=Ay.getTypedArrayConstructor(o),c=dM(n);return new s(r*i*c)}var vM=e({WebGLDevice:()=>yM}),yM=class e extends yb{static getDeviceFromContext(e){return e?e.luma?.device??null:null}type=`webgl`;handle;features;limits;info;canvasContext;preferredColorFormat=`rgba8unorm`;preferredDepthFormat=`depth24plus`;commandEncoder;lost;_resolveContextLost;gl;_constants;extensions;_polyfilled=!1;spectorJS;get[Symbol.toStringTag](){return`WebGLDevice`}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(e){switch(e){case`unorm8x4-bgra`:return!1;default:return!0}}constructor(t){super({...t,id:t.id||JA(`webgl-device`)});let n=yb._getCanvasContextProps(t);if(!n)throw Error(`WebGLDevice requires props.createCanvasContext to be set`);let r=n.canvas?.gl??null,i=e.getDeviceFromContext(r);if(i)throw Error(`WebGL context already attached to device ${i.id}`);this.canvasContext=new GA(this,n),this.lost=new Promise(e=>{this._resolveContextLost=e});let a={...t.webgl};n.alphaMode===`premultiplied`&&(a.premultipliedAlpha=!0),t.powerPreference!==void 0&&(a.powerPreference=t.powerPreference),t.failIfMajorPerformanceCaveat!==void 0&&(a.failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat);let o=this.props._handle||nA(this.canvasContext.canvas,{onContextLost:e=>this._resolveContextLost?.({reason:`destroyed`,message:`Entered sleep mode, or too many apps or browser tabs are using the GPU.`}),onContextRestored:e=>console.log(`WebGL context restored`)},a);if(!o)throw Error(`WebGL context creation failed`);if(i=e.getDeviceFromContext(o),i){if(t._reuseDevices)return Z.log(1,`Not creating a new Device, instead returning a reference to Device ${i.id} already attached to WebGL context`,i)(),this.canvasContext.destroy(),i._reused=!0,i;throw Error(`WebGL context already attached to device ${i.id}`)}this.handle=o,this.gl=o,this.spectorJS=mk({...this.props,gl:this.handle});let s=ck(this.handle);s.device=this,s.extensions||={},this.extensions=s.extensions,this.info=iA(this.gl,this.extensions),this.limits=new VA(this.gl),this.features=new BA(this.gl,this.extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new Qk(this.gl,{log:(...e)=>Z.log(1,...e)()}).trackState(this.gl,{copyState:!1}),(t.debug||t.debugWebGL)&&(this.gl=vk(this.gl,{debugWebGL:!0,traceWebGL:t.debugWebGL}),Z.warn(`WebGL debug mode activated. Performance reduced.`)()),t.debugWebGL&&(Z.level=Math.max(Z.level,1)),this.commandEncoder=new nM(this,{id:`${this}-command-encoder`}),this.canvasContext._startObservers()}destroy(){if(this.commandEncoder?.destroy(),!this.props._reuseDevices&&!this._reused){let e=ck(this.handle);e.device=null}}get isLost(){return this.gl.isContextLost()}createCanvasContext(e){throw Error(`WebGL only supports a single canvas`)}createPresentationContext(e){return new KA(this,e||{})}createBuffer(e){let t=this._normalizeBufferProps(e);return new YA(this,t)}createTexture(e){return new xj(this,e)}createExternalTexture(e){throw Error(`createExternalTexture() not implemented`)}createSampler(e){return new hj(this,e)}createShader(e){return new ej(this,e)}createFramebuffer(e){return new HA(this,e)}createVertexArray(e){return new iM(this,e)}createTransformFeedback(e){return new sM(this,e)}createQuerySet(e){return new lM(this,e)}createFence(){return new uM(this)}createRenderPipeline(e){return new kj(this,e)}_createSharedRenderPipelineWebGL(e){return new qj(this,e)}createComputePipeline(e){throw Error(`ComputePipeline not supported in WebGL`)}createCommandEncoder(e={}){return new nM(this,e)}submit(e){let t=null;e||({submittedCommandEncoder:t,commandBuffer:e}=this._finalizeDefaultCommandEncoderForSubmit());try{e._executeCommands(),t&&t.resolveTimeProfilingQuerySet().then(()=>{this.commandEncoder._gpuTimeMs=t._gpuTimeMs}).catch(()=>{})}finally{e.destroy()}}_finalizeDefaultCommandEncoderForSubmit(){let e=this.commandEncoder,t=e.finish();return this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:e.props.id,timeProfilingQuerySet:e.getTimeProfilingQuerySet()}),{submittedCommandEncoder:e,commandBuffer:t}}readPixelsToArrayWebGL(e,t){return pM(e,t)}readPixelsToBufferWebGL(e,t){return mM(e,t)}setParametersWebGL(e){Kk(this.gl,e)}getParametersWebGL(e){return qk(this.gl,e)}withParametersWebGL(e,t){return gj(this.gl,e,t)}resetWebGL(){Z.warn(`WebGLDevice.resetWebGL is deprecated, use only for debugging`)(),Jk(this.gl)}_getDeviceSpecificTextureFormatCapabilities(e){return NA(this.gl,e,this.extensions)}loseDevice(){let e=!1,t=this.getExtension(`WEBGL_lose_context`).WEBGL_lose_context;return t&&(e=!0,t.loseContext()),this._resolveContextLost?.({reason:`destroyed`,message:`Application triggered context loss`}),e}pushState(){Qk.get(this.gl).push()}popState(){Qk.get(this.gl).pop()}getGLKey(e,t){let n=Number(e);for(let e in this.gl)if(this.gl[e]===n)return`GL.${e}`;return t?.emptyIfUnknown?``:String(e)}getGLKeys(e){let t={emptyIfUnknown:!0};return Object.entries(e).reduce((e,[n,r])=>(e[`${n}:${this.getGLKey(n,t)}`]=`${r}:${this.getGLKey(r,t)}`,e),{})}setConstantAttributeWebGL(e,t){let n=this.limits.maxVertexAttributes;this._constants=this._constants||Array(n).fill(null);let r=this._constants[e];switch(r&&CM(r,t)&&Z.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=t,t.constructor){case Float32Array:bM(this,e,t);break;case Int32Array:xM(this,e,t);break;case Uint32Array:SM(this,e,t);break;default:throw Error(`constant`)}}getExtension(e){return rA(this.gl,e,this.extensions),this.extensions}_setWebGLDebugMetadata(e,t,n){e.luma=t,e.__SPECTOR_Metadata={props:n.spector,id:n.spector.id}}};function bM(e,t,n){switch(n.length){case 1:e.gl.vertexAttrib1fv(t,n);break;case 2:e.gl.vertexAttrib2fv(t,n);break;case 3:e.gl.vertexAttrib3fv(t,n);break;case 4:e.gl.vertexAttrib4fv(t,n);break;default:}}function xM(e,t,n){e.gl.vertexAttribI4iv(t,n)}function SM(e,t,n){e.gl.vertexAttribI4uiv(t,n)}function CM(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}function wM(){}var TM={id:``,width:`100%`,height:`100%`,style:null,viewState:null,initialViewState:null,pickingRadius:0,pickAsync:`auto`,layerFilter:null,parameters:{},parent:null,device:null,deviceProps:{},gl:null,canvas:null,layers:[],effects:[],views:null,controller:null,useDevicePixels:!0,touchAction:`none`,eventRecognizerOptions:{},_framebuffer:null,_animate:!1,_pickable:!0,_typedArrayManagerProps:{},_customRender:null,widgets:[],onDeviceInitialized:wM,onWebGLInitialized:wM,onResize:wM,onViewStateChange:wM,onInteractionStateChange:wM,onBeforeRender:wM,onAfterRender:wM,onLoad:wM,onError:e=>X.error(e.message,e.cause)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:({isDragging:e})=>e?`grabbing`:`grab`,getTooltip:null,debug:!1,drawPickingColors:!1},EM=class{constructor(e){this.width=0,this.height=0,this.userData={},this.device=null,this.canvas=null,this.viewManager=null,this.layerManager=null,this.effectManager=null,this.deckRenderer=null,this.deckPicker=null,this.eventManager=null,this.widgetManager=null,this.tooltip=null,this.animationLoop=null,this.cursorState={isHovering:!1,isDragging:!1},this.stats=new Ff({id:`deck.gl`}),this.metrics={fps:0,setPropsTime:0,layersCount:0,drawLayersCount:0,updateLayersCount:0,updateAttributesCount:0,updateAttributesTime:0,framesRedrawn:0,pickTime:0,pickCount:0,pickLayersCount:0,gpuTime:0,gpuTimePerFrame:0,cpuTime:0,cpuTimePerFrame:0,bufferMemory:0,textureMemory:0,renderbufferMemory:0,gpuMemory:0},this._metricsCounter=0,this._hoverPickSequence=0,this._pointerDownPickSequence=0,this._needsRedraw=`Initial render`,this._pickRequest={mode:`hover`,x:-1,y:-1,radius:0,event:null,unproject3D:!1},this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this._onPointerMove=e=>{let{_pickRequest:t}=this;if(e.type===`pointerleave`)t.x=-1,t.y=-1,t.radius=0;else if(e.leftButton||e.rightButton)return;else{let n=e.offsetCenter;if(!n)return;t.x=n.x,t.y=n.y,t.radius=this.props.pickingRadius}this.layerManager&&(this.layerManager.context.mousePosition={x:t.x,y:t.y}),t.event=e},this._onEvent=e=>{let t=YC[e.type],n=e.offsetCenter;if(!t||!n||!this.layerManager)return;let r=this.layerManager.getLayers(),i=this._getInternalPickingMode();if(i){if(i===`sync`){let t=e.type===`click`&&this._shouldUnproject3D(r)?this._getFirstPickedInfo(this._pickPointSync(this._getPointPickOptions(n.x,n.y,{unproject3D:!0},r))):this._getLastPointerDownPickingInfo(n.x,n.y,r);this._dispatchPickingEvent(t,e);return}(this._lastPointerDownInfoPromise||Promise.resolve(this._getLastPointerDownPickingInfo(n.x,n.y,r))).then(t=>{this._dispatchPickingEvent(t,e)}).catch(e=>this.props.onError?.(e))}},this._onPointerDown=e=>{let t=e.offsetCenter;if(!t)return;let n=this._getInternalPickingMode();if(!n)return;let r=this.layerManager?.getLayers()||[],i=++this._pointerDownPickSequence;if(n===`sync`){let e=this._pickPointSync({x:t.x,y:t.y,radius:this.props.pickingRadius}),n=this._getFirstPickedInfo(e);this._lastPointerDownInfo=n,this._lastPointerDownInfoPromise=Promise.resolve(n);return}let a=this._pickPointAsync(this._getPointPickOptions(t.x,t.y,{},r)).then(e=>this._getFirstPickedInfo(e)).then(e=>(i===this._pointerDownPickSequence&&(this._lastPointerDownInfo=e),e)).catch(e=>{this.props.onError?.(e);let n=this.deckPicker&&this.viewManager?this._getLastPointerDownPickingInfo(t.x,t.y,r):{};return i===this._pointerDownPickSequence&&(this._lastPointerDownInfo=n),n});this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=a},this.props={...TM,...e},e=this.props,e.viewState&&e.initialViewState&&X.warn("View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.")(),this.viewState=this.props.initialViewState,e.device&&(this.device=e.device);let t=this.device;if(!t&&e.gl){e.gl instanceof WebGLRenderingContext&&X.error(`WebGL1 context not supported.`)();let n=this.props.deviceProps?.onResize;t=jk.attach(e.gl,{_cacheShaders:!0,_cachePipelines:!0,...this.props.deviceProps,onResize:(e,t)=>{let{width:r,height:i}=e.canvas;e.setDrawingBufferSize(r,i),this._needsRedraw=`Canvas resized`,n?.(e,t)}})}t||=this._createDevice(e),this.animationLoop=this._createAnimationLoop(t,e),this.setProps(e),e._typedArrayManagerProps&&NT.setOptions(e._typedArrayManagerProps),this.animationLoop.start()}finalize(){this.animationLoop?.stop(),this.animationLoop?.destroy(),this.animationLoop=null,this._hoverPickSequence++,this._pointerDownPickSequence++,this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this.layerManager?.finalize(),this.layerManager=null,this.viewManager?.finalize(),this.viewManager=null,this.effectManager?.finalize(),this.effectManager=null,this.deckRenderer?.finalize(),this.deckRenderer=null,this.deckPicker?.finalize(),this.deckPicker=null,this.eventManager?.destroy(),this.eventManager=null,this.widgetManager?.finalize(),this.widgetManager=null,!this.props.canvas&&!this.props.device&&!this.props.gl&&this.canvas&&(this.canvas.parentElement?.removeChild(this.canvas),this.canvas=null)}setProps(e){this.stats.get(`setProps Time`).timeStart(),`onLayerHover`in e&&X.removed(`onLayerHover`,`onHover`)(),`onLayerClick`in e&&X.removed(`onLayerClick`,`onClick`)(),e.initialViewState&&!RD(this.props.initialViewState,e.initialViewState,3)&&(this.viewState=e.initialViewState),Object.assign(this.props,e),this._validateInternalPickingMode(),this._setCanvasSize(this.props);let t=Object.create(this.props);Object.assign(t,{views:this._getViews(),width:this.width,height:this.height,viewState:this._getViewState()}),e.device&&e.device.id!==this.device?.id&&(this.animationLoop?.stop(),this.canvas!==e.device.canvasContext?.canvas&&(this.canvas?.remove(),this.eventManager?.destroy(),this.canvas=null),X.log(`recreating animation loop for new device! id=${e.device.id}`)(),this.animationLoop=this._createAnimationLoop(e.device,e),this.animationLoop.start()),this.animationLoop?.setProps(t),e.useDevicePixels!==void 0&&this.device?.canvasContext?.setProps&&this.device.canvasContext.setProps({useDevicePixels:e.useDevicePixels}),this.layerManager&&(this.viewManager.setProps(t),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(t),this.effectManager.setProps(t),this.deckRenderer.setProps(t),this.deckPicker.setProps(t),this.widgetManager.setProps(t)),this.stats.get(`setProps Time`).timeEnd()}needsRedraw(e={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return`Deck._animate`;let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);let n=this.viewManager.needsRedraw(e),r=this.layerManager.needsRedraw(e),i=this.effectManager.needsRedraw(e),a=this.deckRenderer.needsRedraw(e);return t=t||n||r||i||a,t}redraw(e){if(!this.layerManager)return;let t=this.needsRedraw({clearRedrawFlags:!0});t=e||t,t&&(this.stats.get(`Redraw Count`).incrementCount(),this.props._customRender?this.props._customRender(t):this._drawLayers(t))}get isInitialized(){return this.viewManager!==null}getViews(){return iO(this.viewManager),this.viewManager.views}getView(e){return iO(this.viewManager),this.viewManager.getView(e)}getViewports(e){return iO(this.viewManager),this.viewManager.getViewports(e)}getCanvas(){return this.canvas}async pickObjectAsync(e){let t=(await this._pickAsync(`pickObjectAsync`,`pickObject Time`,e)).result;return t.length?t[0]:null}async pickObjectsAsync(e){return await this._pickAsync(`pickObjectsAsync`,`pickObjects Time`,e)}pickObject(e){let t=this._pick(`pickObject`,`pickObject Time`,e).result;return t.length?t[0]:null}pickMultipleObjects(e){return e.depth=e.depth||10,this._pick(`pickObject`,`pickMultipleObjects Time`,e).result}pickObjects(e){return this._pick(`pickObjects`,`pickObjects Time`,e)}_pickPositionForController(e,t){return this._getInternalPickingMode()===`sync`?this.pickObject({x:e,y:t,radius:0,unproject3D:!0}):null}_addResources(e,t=!1){for(let n in e)this.layerManager.resourceManager.add({resourceId:n,data:e[n],forceUpdate:t})}_removeResources(e){for(let t of e)this.layerManager.resourceManager.remove(t)}_addDefaultEffect(e){this.effectManager.addDefaultEffect(e)}_addDefaultShaderModule(e){this.layerManager.addDefaultShaderModule(e)}_removeDefaultShaderModule(e){this.layerManager?.removeDefaultShaderModule(e)}_resolveInternalPickingMode(){let{pickAsync:e}=this.props,t=this.device?.type||this.props.deviceProps?.type;if(e===`auto`)return t===`webgpu`?`async`:`sync`;if(e===`sync`&&t===`webgpu`)throw Error('`pickAsync: "sync"` is not supported when Deck is using a WebGPU device.');return e}_getInternalPickingMode(){try{return this._resolveInternalPickingMode()}catch(e){return this.props.onError?.(e),null}}_validateInternalPickingMode(){this._getInternalPickingMode()}_getFirstPickedInfo({result:e,emptyInfo:t}){return e[0]||t}_shouldUnproject3D(e=this.layerManager?.getLayers()||[]){return e.some(e=>e.props.pickable===`3d`)}_getPointPickOptions(e,t,n={},r=this.layerManager?.getLayers()||[]){return{x:e,y:t,radius:this.props.pickingRadius,unproject3D:this._shouldUnproject3D(r),...n}}_pickPointSync(e){return this._pick(`pickObject`,`pickObject Time`,e)}_pickPointAsync(e){return this._pickAsync(`pickObjectAsync`,`pickObject Time`,e)}_getLastPointerDownPickingInfo(e,t,n=this.layerManager?.getLayers()||[]){return this.deckPicker.getLastPickedObject({x:e,y:t,layers:n,viewports:this.getViewports({x:e,y:t})},this._lastPointerDownInfo)}_applyHoverCallbacks({result:e,emptyInfo:t},n){if(!this.widgetManager)return;this.cursorState.isHovering=e.length>0;let r=t,i=!1;for(let t of e)r=t,i=t.layer?.onHover(t,n)||i;i||(this.props.onHover?.(r,n),this.widgetManager.onHover(r,n))}_dispatchPickingEvent(e,t){if(!this.layerManager||!this.widgetManager)return;let n=YC[t.type];if(!n)return;let{layer:r}=e,i=r&&(r[n]||r.props[n]),a=this.props[n],o=!1;i&&(o=i.call(r,e,t)),o||(a?.(e,t),this.widgetManager.onEvent(e,t))}_pickAsync(e,t,n){iO(this.deckPicker);let{stats:r}=this;r.get(`Pick Count`).incrementCount(),r.get(t).timeStart();let i=this.deckPicker[e]({layers:this.layerManager.getLayers(n),views:this.viewManager.getViews(),viewports:this.getViewports(n),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...n});return r.get(t).timeEnd(),i}_pick(e,t,n){iO(this.deckPicker);let{stats:r}=this;r.get(`Pick Count`).incrementCount(),r.get(t).timeStart();let i=this.deckPicker[e]({layers:this.layerManager.getLayers(n),views:this.viewManager.getViews(),viewports:this.getViewports(n),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...n});return r.get(t).timeEnd(),i}_createCanvas(e){let t=e.canvas;return typeof t==`string`&&(t=document.getElementById(t),iO(t)),t||(t=document.createElement(`canvas`),t.id=e.id||`deckgl-overlay`,e.width&&typeof e.width==`number`&&(t.width=e.width),e.height&&typeof e.height==`number`&&(t.height=e.height),(e.parent||document.body).appendChild(t)),Object.assign(t.style,e.style),t}_setCanvasSize(e){if(!this.canvas)return;let{width:t,height:n}=e;if(t||t===0){let e=Number.isFinite(t)?`${t}px`:t;this.canvas.style.width=e}if(n||n===0){let t=Number.isFinite(n)?`${n}px`:n;this.canvas.style.position=e.style?.position||`absolute`,this.canvas.style.height=t}}_updateCanvasSize(){let{canvas:e}=this;if(!e)return;let t=e.clientWidth??e.width,n=e.clientHeight??e.height;(t!==this.width||n!==this.height)&&(this.width=t,this.height=n,this.viewManager?.setProps({width:t,height:n}),this.layerManager?.activateViewport(this.getViewports()[0]),this.props.onResize({width:t,height:n}))}_createAnimationLoop(e,t){let{gl:n,onError:r}=t;return new lE({device:e,autoResizeDrawingBuffer:!n,autoResizeViewport:!1,onInitialize:e=>this._setDevice(e.device),onRender:this._onRenderFrame.bind(this),onError:r})}_createDevice(e){let t=this.props.deviceProps?.createCanvasContext,n=typeof t==`object`?t:void 0,r={adapters:[],_cacheShaders:!0,_cachePipelines:!0,...e.deviceProps};r.adapters.includes(jk)||r.adapters.push(jk);let i={alphaMode:this.props.deviceProps?.type===`webgpu`?`premultiplied`:void 0},a=this.props.deviceProps?.onResize;return Tb.createDevice({_reuseDevices:!0,type:`webgl`,...r,createCanvasContext:{...i,...n,canvas:this._createCanvas(e),useDevicePixels:this.props.useDevicePixels,autoResize:!0},onResize:(e,t)=>{this._needsRedraw=`Canvas resized`,a?.(e,t)}})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){let{views:e}=this.props,t=Array.isArray(e)?e:e?[e]:[new AO({id:`default-view`})];return t.length&&this.props.controller&&(t[0].props.controller=this.props.controller),t}_onContextLost(){let{onError:e}=this.props;this.animationLoop&&e&&e(Error(`WebGL context is lost`))}_pickAndCallback(){let{_pickRequest:e}=this;if(e.event){let t=e.event,n=this.layerManager?.getLayers()||[],r=this._getPointPickOptions(e.x,e.y,{radius:e.radius,mode:e.mode},n),i=this._getInternalPickingMode(),a=++this._hoverPickSequence;if(e.event=null,!i)return;if(i===`sync`){this._applyHoverCallbacks(this._pickPointSync(r),t);return}this._pickPointAsync(r).then(({result:e,emptyInfo:n})=>{a===this._hoverPickSequence&&this._applyHoverCallbacks({result:e,emptyInfo:n},t)}).catch(e=>this.props.onError?.(e))}}_updateCursor(){let e=this.props.parent||this.canvas;e&&(e.style.cursor=this.props.getCursor(this.cursorState))}_setDevice(e){if(this.device=e,this._validateInternalPickingMode(),!this.animationLoop)return;this.canvas||(this.canvas=this.device.canvasContext?.canvas,!this.canvas.isConnected&&this.props.parent&&this.props.parent.insertBefore(this.canvas,this.props.parent.firstChild)),this.device.type===`webgl`&&this.device.setParametersWebGL({blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthTest:!0,depthFunc:515}),this.props.onDeviceInitialized(this.device),this.device.type===`webgl`&&this.props.onWebGLInitialized(this.device.gl);let t=new iE;t.play(),this.animationLoop.attachTimeline(t);let n=this.props.parent?.querySelector(`.deck-events-root`)||this.canvas;this.eventManager=new GC(n,{touchAction:this.props.touchAction,recognizers:Object.keys(XC).map(e=>{let[t,n,r,i]=XC[e],a=this.props.eventRecognizerOptions?.[e];return{recognizer:new t({...n,...a,event:e}),recognizeWith:r,requestFailure:i}}),events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(let e in YC)this.eventManager.on(e,this._onEvent);this.viewManager=new zD({timeline:t,eventManager:this.eventManager,onViewStateChange:this._onViewStateChange.bind(this),onInteractionStateChange:this._onInteractionStateChange.bind(this),pickPosition:this._pickPositionForController.bind(this),views:this._getViews(),viewState:this._getViewState(),width:this.width,height:this.height});let r=this.viewManager.getViewports()[0];this.layerManager=new LD(this.device,{deck:this,stats:this.stats,viewport:r,timeline:t}),this.effectManager=new NO({deck:this,device:this.device}),this.deckRenderer=new IO(this.device,{stats:this.stats}),this.deckPicker=new WO(this.device,{stats:this.stats});let i=this.props.parent?.querySelector(`.deck-widgets-root`)||this.canvas?.parentElement;this.widgetManager=new JO({deck:this,parentElement:i}),this.widgetManager.addDefault(new $O),this.setProps(this.props),this._updateCanvasSize(),this.props.onLoad()}_drawLayers(e,t){let{device:n,gl:r}=this.layerManager.context;this.props.onBeforeRender({device:n,gl:r});let i={target:this.props._framebuffer,layers:this.layerManager.getLayers(),viewports:this.viewManager.getViewports(),onViewportActive:this.layerManager.activateViewport,views:this.viewManager.getViews(),pass:`screen`,effects:this.effectManager.getEffects(),...t};this.deckRenderer?.renderLayers(i),i.pass===`screen`&&this.widgetManager.onRedraw({viewports:i.viewports,layers:i.layers}),this.props.onAfterRender({device:n,gl:r})}_onRenderFrame(){this._getFrameStats(),this._metricsCounter++%60==0&&(this._getMetrics(),this.stats.reset(),X.table(4,this.metrics)(),this.props._onMetrics&&this.props._onMetrics(this.metrics)),this._updateCanvasSize(),this._updateCursor(),this.layerManager.updateLayers(),this._pickAndCallback(),this.redraw(),this.viewManager&&this.viewManager.updateViewStates()}_onViewStateChange(e){let t=this.props.onViewStateChange(e)||e.viewState;this.viewState&&(this.viewState={...this.viewState,[e.viewId]:t},this.props.viewState||this.viewManager&&this.viewManager.setProps({viewState:this.viewState}))}_onInteractionStateChange(e){this.cursorState.isDragging=e.isDragging||!1,this.props.onInteractionStateChange(e)}_getFrameStats(){let{stats:e}=this;e.get(`frameRate`).timeEnd(),e.get(`frameRate`).timeStart();let t=this.animationLoop.stats;e.get(`GPU Time`).addTime(t.get(`GPU Time`).lastTiming),e.get(`CPU Time`).addTime(t.get(`CPU Time`).lastTiming)}_getMetrics(){let{metrics:e,stats:t}=this;e.fps=t.get(`frameRate`).getHz(),e.setPropsTime=t.get(`setProps Time`).time,e.updateAttributesTime=t.get(`Update Attributes`).time,e.framesRedrawn=t.get(`Redraw Count`).count,e.pickTime=t.get(`pickObject Time`).time+t.get(`pickMultipleObjects Time`).time+t.get(`pickObjects Time`).time,e.pickCount=t.get(`Pick Count`).count,e.layersCount=this.layerManager?.layers.length??0,e.drawLayersCount=t.get(`Layers rendered`).lastSampleCount,e.pickLayersCount=t.get(`Layers picked`).lastSampleCount,e.updateAttributesCount=t.get(`Layers updated`).count,e.updateAttributesCount=t.get(`Attributes updated`).count,e.gpuTime=t.get(`GPU Time`).time,e.cpuTime=t.get(`CPU Time`).time,e.gpuTimePerFrame=t.get(`GPU Time`).getAverageTime(),e.cpuTimePerFrame=t.get(`CPU Time`).getAverageTime();let n=Tb.stats.get(`GPU Time and Memory`);e.bufferMemory=n.get(`Buffer Memory`).count,e.textureMemory=n.get(`Texture Memory`).count,e.renderbufferMemory=n.get(`Renderbuffer Memory`).count,e.gpuMemory=n.get(`GPU Memory`).count}};EM.defaultProps=TM,EM.VERSION=hh;function DM(e){switch(e){case`float64`:return Float64Array;case`uint8`:case`unorm8`:return Uint8ClampedArray;default:return Vx(e)}}var OM=Ay.getDataType.bind(Ay);function kM(e,t,n){if(t.size>4)return null;let r=n===`webgpu`&&t.type===`uint8`?`unorm8`:t.type;return{attribute:e,format:t.size>1?`${r}x${t.size}`:t.type,byteOffset:t.offset||0}}function AM(e){return e.stride||e.size*e.bytesPerElement}function jM(e,t){return e.type===t.type&&e.size===t.size&&AM(e)===AM(t)&&(e.offset||0)===(t.offset||0)}function MM(e,t){t.offset&&X.removed(`shaderAttribute.offset`,`vertexOffset, elementOffset`)();let n=AM(e),r=t.vertexOffset===void 0?e.vertexOffset||0:t.vertexOffset,i=t.elementOffset||0,a=r*n+i*e.bytesPerElement+(e.offset||0);return{...t,offset:a,stride:n}}function NM(e,t){let n=MM(e,t);return{high:n,low:{...n,offset:n.offset+e.size*4}}}var PM=class{constructor(e,t,n){this._buffer=null,this.device=e,this.id=t.id||``,this.size=t.size||1;let r=t.logicalType||t.type,i=r===`float64`,{defaultValue:a}=t;a=Number.isFinite(a)?[a]:a||Array(this.size).fill(0);let o;o=i?`float32`:!r&&t.isIndexed?`uint32`:r||`float32`;let s=DM(r||o);this.doublePrecision=i,i&&t.fp64===!1&&(s=Float32Array),this.value=null,this.settings={...t,defaultType:s,defaultValue:a,logicalType:r,type:o,normalized:o.includes(`norm`),size:this.size,bytesPerElement:s.BYTES_PER_ELEMENT},this.state={...n,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1}}get isConstant(){return this.state.constant}get buffer(){return this._buffer}get byteOffset(){let e=this.getAccessor();return e.vertexOffset?e.vertexOffset*AM(e):0}get numInstances(){return this.state.numInstances}set numInstances(e){this.state.numInstances=e}delete(){this._buffer&&=(this._buffer.delete(),null),NT.release(this.state.allocatedValue)}getBuffer(){return this.state.constant?null:this.state.externalBuffer||this._buffer}getValue(e=this.id,t=null){let n={};if(this.state.constant){let r=this.value;if(t){let i=MM(this.getAccessor(),t),a=i.offset/r.BYTES_PER_ELEMENT,o=i.size||this.size;n[e]=r.subarray(a,a+o)}else n[e]=r}else n[e]=this.getBuffer();return this.doublePrecision&&(this.value instanceof Float64Array?n[`${e}64Low`]=n[e]:n[`${e}64Low`]=new Float32Array(this.size)),n}_getBufferLayout(e=this.id,t=null){let n=this.getAccessor(),r=[],i={name:this.id,byteStride:AM(n)};if(this.doublePrecision){let i=NM(n,t||{});r.push(kM(e,{...n,...i.high},this.device.type),kM(`${e}64Low`,{...n,...i.low},this.device.type))}else if(t){let i=MM(n,t);r.push(kM(e,{...n,...i},this.device.type))}else r.push(kM(e,n,this.device.type));return i.attributes=r.filter(Boolean),i}setAccessor(e){this.state.bufferAccessor=e}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let e=null;if(this.state.constant&&this.value){let t=Array.from(this.value);e=[t,t]}else{let{value:t,numInstances:n,size:r}=this,i=n*r;if(t&&i&&t.length>=i){let n=Array(r).fill(1/0),a=Array(r).fill(-1/0);for(let e=0;e<i;)for(let i=0;i<r;i++){let r=t[e++];r<n[i]&&(n[i]=r),r>a[i]&&(a[i]=r)}e=[n,a]}}return this.state.bounds=e,e}setData(e){let{state:t}=this,n;n=ArrayBuffer.isView(e)?{value:e}:e instanceof ky?{buffer:e}:e;let r={...this.settings,...n};if(ArrayBuffer.isView(n.value)){if(!n.type)if(this.doublePrecision&&n.value instanceof Float64Array)r.type=`float32`;else{let e=OM(n.value);r.type=r.normalized?e.replace(`int`,`norm`):e}r.bytesPerElement=n.value.BYTES_PER_ELEMENT,r.stride=AM(r)}if(t.bounds=null,n.constant){let e=n.value;if(e=this._normalizeValue(e,[],0),this.settings.normalized&&(e=this.normalizeConstant(e)),!(!t.constant||!this._areValuesEqual(e,this.value)))return!1;t.externalBuffer=null,t.constant=!0,this.value=ArrayBuffer.isView(e)?e:new Float32Array(e)}else if(n.buffer)t.externalBuffer=n.buffer,t.constant=!1,this.value=n.value||null;else if(n.value){this._checkExternalBuffer(n);let e=n.value;t.externalBuffer=null,t.constant=!1,this.value=e;let{buffer:i}=this,a=AM(r),o=(r.vertexOffset||0)*a;if(this.doublePrecision&&e instanceof Float64Array&&(e=HT(e,r)),this.settings.isIndexed){let t=this.settings.defaultType;e.constructor!==t&&(e=new t(e))}let s=e.byteLength+o+a*2;(!i||i.byteLength<s)&&(i=this._createBuffer(s)),i.write(e,o)}return this.setAccessor(r),!0}updateSubBuffer(e={}){this.state.bounds=null;let t=this.value,{startOffset:n=0,endOffset:r}=e;this.buffer.write(this.doublePrecision&&t instanceof Float64Array?HT(t,{size:this.size,startIndex:n,endIndex:r}):t.subarray(n,r),n*t.BYTES_PER_ELEMENT+this.byteOffset)}allocate(e,t=!1){let{state:n}=this,r=n.allocatedValue,i=NT.allocate(r,e+1,{size:this.size,type:this.settings.defaultType,copy:t});this.value=i;let{byteOffset:a}=this,{buffer:o}=this;return(!o||o.byteLength<i.byteLength+a)&&(o=this._createBuffer(i.byteLength+a),t&&r&&o.write(r instanceof Float64Array?HT(r,this):r,a)),n.allocatedValue=i,n.constant=!1,n.externalBuffer=null,this.setAccessor(this.settings),!0}_checkExternalBuffer(e){let{value:t}=e;if(!ArrayBuffer.isView(t))throw Error(`Attribute ${this.id} value is not TypedArray`);let n=this.settings.defaultType,r=!1;if(this.doublePrecision&&(r=t.BYTES_PER_ELEMENT<4),r)throw Error(`Attribute ${this.id} does not support ${t.constructor.name}`);!(t instanceof n)&&this.settings.normalized&&!(`normalized`in e)&&X.warn(`Attribute ${this.id} is normalized`)()}normalizeConstant(e){switch(this.settings.type){case`snorm8`:return new Float32Array(e).map(e=>(e+128)/255*2-1);case`snorm16`:return new Float32Array(e).map(e=>(e+32768)/65535*2-1);case`unorm8`:return new Float32Array(e).map(e=>e/255);case`unorm16`:return new Float32Array(e).map(e=>e/65535);default:return e}}_normalizeValue(e,t,n){let{defaultValue:r,size:i}=this.settings;if(Number.isFinite(e))return t[n]=e,t;if(!e){let e=i;for(;--e>=0;)t[n+e]=r[e];return t}switch(i){case 4:t[n+3]=Number.isFinite(e[3])?e[3]:r[3];case 3:t[n+2]=Number.isFinite(e[2])?e[2]:r[2];case 2:t[n+1]=Number.isFinite(e[1])?e[1]:r[1];case 1:t[n+0]=Number.isFinite(e[0])?e[0]:r[0];break;default:let a=i;for(;--a>=0;)t[n+a]=Number.isFinite(e[a])?e[a]:r[a]}return t}_areValuesEqual(e,t){if(!e||!t)return!1;let{size:n}=this;for(let r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}_createBuffer(e){this._buffer&&this._buffer.destroy();let{isIndexed:t,type:n}=this.settings;return this._buffer=this.device.createBuffer({...this._buffer?.props,id:this.id,usage:(t?ky.INDEX:ky.VERTEX)|ky.COPY_DST,indexType:t?n:void 0,byteLength:e}),this._buffer}},FM=[],IM=[];function LM(e,t=0,n=1/0){let r=FM,i={index:-1,data:e,target:[]};return e?typeof e[Symbol.iterator]==`function`?r=e:e.length>0&&(IM.length=e.length,r=IM):r=FM,(t>0||Number.isFinite(n))&&(r=(Array.isArray(r)?r:Array.from(r)).slice(t,n),i.index=t-1),{iterable:r,objectInfo:i}}function RM(e){return e&&e[Symbol.asyncIterator]}function zM(e,t){let{size:n,stride:r,offset:i,startIndices:a,nested:o}=t,s=e.BYTES_PER_ELEMENT,c=r?r/s:n,l=i?i/s:0,u=Math.floor((e.length-l)/c);return(t,{index:r,target:i})=>{if(!a){let t=r*c+l;for(let r=0;r<n;r++)i[r]=e[t+r];return i}let s=a[r],d=a[r+1]||u,f;if(o){f=Array(d-s);for(let t=s;t<d;t++){let r=t*c+l;i=Array(n);for(let t=0;t<n;t++)i[t]=e[r+t];f[t-s]=i}}else if(c===n)f=e.subarray(s*n+l,d*n+l);else{f=new e.constructor((d-s)*n);let t=0;for(let r=s;r<d;r++){let i=r*c+l;for(let r=0;r<n;r++)f[t++]=e[i+r]}}return f}}var BM=[],VM=[[0,1/0]];function HM(e,t){if(e===VM||(t[0]<0&&(t[0]=0),t[0]>=t[1]))return e;let n=[],r=e.length,i=0;for(let a=0;a<r;a++){let r=e[a];r[1]<t[0]?(n.push(r),i=a+1):r[0]>t[1]?n.push(r):t=[Math.min(r[0],t[0]),Math.max(r[1],t[1])]}return n.splice(i,0,t),n}var UM={interpolation:{duration:0,easing:e=>e},spring:{stiffness:.05,damping:.5}};function WM(e,t){if(!e)return null;Number.isFinite(e)&&(e={type:`interpolation`,duration:e});let n=e.type||`interpolation`;return{...UM[n],...t,...e,type:n}}var GM=class extends PM{constructor(e,t){super(e,t,{startIndices:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:VM}),this.constant=!1,this.settings.update=t.update||(t.accessor?this._autoUpdater:void 0),Object.seal(this.settings),Object.seal(this.state),this._validateAttributeUpdaters()}get startIndices(){return this.state.startIndices}set startIndices(e){this.state.startIndices=e}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:e=!1}={}){let t=this.state.needsRedraw;return this.state.needsRedraw=t&&!e,t}layoutChanged(){return this.state.layoutChanged}setAccessor(e){var t;(t=this.state).layoutChanged||(t.layoutChanged=!jM(e,this.getAccessor())),super.setAccessor(e)}getUpdateTriggers(){let{accessor:e}=this.settings;return[this.id].concat(typeof e!=`function`&&e||[])}supportsTransition(){return!!this.settings.transition}getTransitionSetting(e){if(!e||!this.supportsTransition())return null;let{accessor:t}=this.settings,n=this.settings.transition;return WM(Array.isArray(t)?e[t.find(t=>e[t])]:e[t],n)}setNeedsUpdate(e=this.id,t){if(this.state.needsUpdate=this.state.needsUpdate||e,this.setNeedsRedraw(e),t){let{startRow:e=0,endRow:n=1/0}=t;this.state.updateRanges=HM(this.state.updateRanges,[e,n])}else this.state.updateRanges=VM}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=BM}setNeedsRedraw(e=this.id){this.state.needsRedraw=this.state.needsRedraw||e}allocate(e){let{state:t,settings:n}=this;return n.noAlloc?!1:n.update?(super.allocate(e,t.updateRanges!==VM),!0):!1}updateBuffer({numInstances:e,data:t,props:n,context:r}){if(!this.needsUpdate())return!1;let{state:{updateRanges:i},settings:{update:a,noAlloc:o}}=this,s=!0;if(a){for(let[o,s]of i)a.call(r,this,{data:t,startRow:o,endRow:s,props:n,numInstances:e});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLength<this.value.byteLength+this.byteOffset)this.constant?this.setConstantValue(r,this.value):this.setData({value:this.value,constant:this.constant}),this.constant=!1;else for(let[t,n]of i){let r=Number.isFinite(t)?this.getVertexOffset(t):0,i=Number.isFinite(n)?this.getVertexOffset(n):o||!Number.isFinite(e)?this.value.length:e*this.size;super.updateSubBuffer({startOffset:r,endOffset:i})}this._checkAttributeArray()}else s=!1;return this.clearNeedsUpdate(),this.setNeedsRedraw(),s}setConstantValue(e,t){if(t===void 0||typeof t==`function`)return!1;let n=this.settings.transform&&e?this.settings.transform.call(e,t):t;return this.device.type===`webgpu`?this.setConstantBufferValue(n,this.numInstances):(this.setData({constant:!0,value:n})&&this.setNeedsRedraw(),this.clearNeedsUpdate(),!0)}setConstantBufferValue(e,t){let n=this.settings.defaultType,r=this._normalizeValue(e,new n(this.size),0);if(this._hasConstantBufferValue(r,t))return this.constant=!1,this.clearNeedsUpdate(),!1;let i=new n(Math.max(t,1)*this.size);for(let e=0;e<i.length;e+=this.size)i.set(r,e);let a=this.setData({value:i});return this.constant=!1,this.clearNeedsUpdate(),a&&this.setNeedsRedraw(),a}_hasConstantBufferValue(e,t){let n=this.value,r=Math.max(t,1)*this.size;if(!ArrayBuffer.isView(n)||n.length!==r||n.length%this.size!==0)return!1;for(let t=0;t<n.length;t+=this.size)for(let r=0;r<this.size;r++)if(n[t+r]!==e[r])return!1;return!0}setExternalBuffer(e){let{state:t}=this;return e?(this.clearNeedsUpdate(),t.lastExternalBuffer===e?!0:(t.lastExternalBuffer=e,this.setNeedsRedraw(),this.setData(e),!0)):(t.lastExternalBuffer=null,!1)}setBinaryValue(e,t=null){let{state:n,settings:r}=this;if(!e)return n.binaryValue=null,n.binaryAccessor=null,!1;if(r.noAlloc)return!1;if(n.binaryValue===e)return this.clearNeedsUpdate(),!0;if(n.binaryValue=e,this.setNeedsRedraw(),r.transform||t!==this.startIndices){ArrayBuffer.isView(e)&&(e={value:e});let i=e;iO(ArrayBuffer.isView(i.value),`invalid ${r.accessor}`);let a=!!i.size&&i.size!==this.size;return n.binaryAccessor=zM(i.value,{size:i.size||this.size,stride:i.stride,offset:i.offset,startIndices:t,nested:a}),!1}return this.clearNeedsUpdate(),this.setData(e),!0}getVertexOffset(e){let{startIndices:t}=this;return(t?e<t.length?t[e]:this.numInstances:e)*this.size}getValue(){let e=this.settings.shaderAttributes,t=super.getValue();if(!e)return t;for(let n in e)Object.assign(t,super.getValue(n,e[n]));return t}getBufferLayout(e){this.state.layoutChanged=!1;let t=this.settings.shaderAttributes,n=super._getBufferLayout(),{stepMode:r}=this.settings;if(r===`dynamic`?n.stepMode=e?e.isInstanced?`instance`:`vertex`:`instance`:n.stepMode=r??`vertex`,!t)return n;for(let e in t){let r=super._getBufferLayout(e,t[e]);n.attributes.push(...r.attributes)}return n}_autoUpdater(e,{data:t,startRow:n,endRow:r,props:i,numInstances:a}){let{settings:o,state:s,value:c,size:l,startIndices:u}=e,{accessor:d,transform:f}=o,p=s.binaryAccessor||(typeof d==`function`?d:i[d]);iO(typeof p==`function`,`accessor "${d}" is not a function`);let m=e.getVertexOffset(n),{iterable:h,objectInfo:g}=LM(t,n,r);for(let t of h){g.index++;let n=p(t,g);if(f&&(n=f.call(this,n)),u){let t=(g.index<u.length-1?u[g.index+1]:a)-u[g.index];if(n&&Array.isArray(n[0])){let t=m;for(let r of n)e._normalizeValue(r,c,t),t+=l}else n&&n.length>l?c.set(n,m):(e._normalizeValue(n,g.target,0),MD({target:c,source:g.target,start:m,count:t}));m+=t*l}else e._normalizeValue(n,c,m),m+=l}}_validateAttributeUpdaters(){let{settings:e}=this;if(!(e.noAlloc||typeof e.update==`function`))throw Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){let{value:e}=this,t=Math.min(4,this.size);if(e&&e.length>=t){let n=!0;switch(t){case 4:n&&=Number.isFinite(e[3]);case 3:n&&=Number.isFinite(e[2]);case 2:n&&=Number.isFinite(e[1]);case 1:n&&=Number.isFinite(e[0]);break;default:n=!1}if(!n)throw Error(`Illegal attribute generated for ${this.id}`)}}};function KM(e){let{source:t,target:n,start:r=0,size:i,getData:a}=e,o=e.end||n.length,s=t.length,c=o-r;if(s>c){n.set(t.subarray(0,c),r);return}if(n.set(t,r),!a)return;let l=s;for(;l<c;){let e=a(l,t);for(let t=0;t<i;t++)n[r+l]=e[t]||0,l++}}function qM({source:e,target:t,size:n,getData:r,sourceStartIndices:i,targetStartIndices:a}){if(!i||!a)return KM({source:e,target:t,size:n,getData:r}),t;let o=0,s=0,c=r&&((e,t)=>r(e+s,t)),l=Math.min(i.length,a.length);for(let r=1;r<l;r++){let l=i[r]*n,u=a[r]*n;KM({source:e.subarray(o,l),target:t,start:s,end:u,size:n,getData:c}),o=l,s=u}return s<t.length&&KM({source:[],target:t,start:s,size:n,getData:c}),t}function JM(e){let{device:t,settings:n,value:r}=e,i=new GM(t,n);return i.setData({value:r instanceof Float64Array?new Float64Array:new Float32Array,normalized:n.normalized}),i}function YM(e){switch(e){case 1:return`float`;case 2:return`vec2`;case 3:return`vec3`;case 4:return`vec4`;default:throw Error(`No defined attribute type for size "${e}"`)}}function XM(e){switch(e){case 1:return`float32`;case 2:return`float32x2`;case 3:return`float32x3`;case 4:return`float32x4`;default:throw Error(`invalid type size`)}}function ZM(e){e.push(e.shift())}function QM(e,t){let{doublePrecision:n,settings:r,value:i,size:a}=e,o=n&&i instanceof Float64Array?2:1,s=0,{shaderAttributes:c}=e.settings;if(c)for(let e of Object.values(c))s=Math.max(s,e.vertexOffset??0);return(r.noAlloc?i.length:(t+s)*a)*o}function $M({device:e,source:t,target:n}){return(!n||n.byteLength<t.byteLength)&&(n?.destroy(),n=e.createBuffer({byteLength:t.byteLength,usage:t.usage})),n}function eN({device:e,buffer:t,attribute:n,fromLength:r,toLength:i,fromStartIndices:a,getData:o=e=>e}){let s=n.doublePrecision&&n.value instanceof Float64Array?2:1,c=n.size*s,l=n.byteOffset,u=n.settings.bytesPerElement<4?l/n.settings.bytesPerElement*4:l,d=n.startIndices,f=a&&d,p=n.isConstant;if(!f&&t&&r>=i)return t;let m=n.value instanceof Float64Array?Float32Array:n.value.constructor,h=p?n.value:new m(n.getBuffer().readSyncWebGL(l,i*m.BYTES_PER_ELEMENT).buffer);if(n.settings.normalized&&!p){let e=o;o=(t,r)=>n.normalizeConstant(e(t,r))}let g=p?(e,t)=>o(h,t):(e,t)=>o(h.subarray(e+l,e+l+c),t),_=t?new Float32Array(t.readSyncWebGL(u,r*4).buffer):new Float32Array,v=new Float32Array(i);return qM({source:_,target:v,sourceStartIndices:a,targetStartIndices:d,size:c,getData:g}),(!t||t.byteLength<v.byteLength+u)&&(t?.destroy(),t=e.createBuffer({byteLength:v.byteLength+u,usage:35050})),t.write(v,u),t}var tN=class{constructor({device:e,attribute:t,timeline:n}){this.buffers=[],this.currentLength=0,this.device=e,this.transition=new QD(n),this.attribute=t,this.attributeInTransition=JM(t),this.currentStartIndices=t.startIndices}get inProgress(){return this.transition.inProgress}start(e,t,n=1/0){this.settings=e,this.currentStartIndices=this.attribute.startIndices,this.currentLength=QM(this.attribute,t),this.transition.start({...e,duration:n})}update(){let e=this.transition.update();return e&&this.onUpdate(),e}setBuffer(e){this.attributeInTransition.setData({buffer:e,normalized:this.attribute.settings.normalized,value:this.attributeInTransition.value})}cancel(){this.transition.cancel()}delete(){this.cancel();for(let e of this.buffers)e.destroy();this.buffers.length=0}},nN=class extends tN{constructor({device:e,attribute:t,timeline:n}){super({device:e,attribute:t,timeline:n}),this.type=`interpolation`,this.transform=sN(e,t)}start(e,t){let n=this.currentLength,r=this.currentStartIndices;if(super.start(e,t,e.duration),e.duration<=0){this.transition.cancel();return}let{buffers:i,attribute:a}=this;ZM(i),i[0]=eN({device:this.device,buffer:i[0],attribute:a,fromLength:n,toLength:this.currentLength,fromStartIndices:r,getData:e.enter}),i[1]=$M({device:this.device,source:i[0],target:i[1]}),this.setBuffer(i[1]);let{transform:o}=this,s=o.model,c=Math.floor(this.currentLength/a.size);oN(a)&&(c/=2),s.setVertexCount(c),a.isConstant?(s.setAttributes({aFrom:i[0]}),s.setConstantAttributes({aTo:a.value})):s.setAttributes({aFrom:i[0],aTo:a.getBuffer()}),o.transformFeedback.setBuffers({vCurrent:i[1]})}onUpdate(){let{duration:e,easing:t}=this.settings,{time:n}=this.transition,r=n/e;t&&(r=t(r));let{model:i}=this.transform,a={time:r};i.shaderInputs.setProps({interpolation:a}),this.transform.run({discard:!0})}delete(){super.delete(),this.transform.destroy()}},rN={name:`interpolation`,vs:`layout(std140) uniform interpolationUniforms {
|
|
2088
2088
|
float time;
|
|
2089
2089
|
} interpolation;
|
|
2090
|
-
`,uniformTypes:{time:`f32`}},
|
|
2090
|
+
`,uniformTypes:{time:`f32`}},iN=`#version 300 es
|
|
2091
2091
|
#define SHADER_NAME interpolation-transition-vertex-shader
|
|
2092
2092
|
|
|
2093
2093
|
in ATTRIBUTE_TYPE aFrom;
|
|
@@ -2098,7 +2098,7 @@ void main(void) {
|
|
|
2098
2098
|
vCurrent = mix(aFrom, aTo, interpolation.time);
|
|
2099
2099
|
gl_Position = vec4(0.0);
|
|
2100
2100
|
}
|
|
2101
|
-
`,
|
|
2101
|
+
`,aN=`#version 300 es
|
|
2102
2102
|
#define SHADER_NAME interpolation-transition-vertex-shader
|
|
2103
2103
|
|
|
2104
2104
|
in ATTRIBUTE_TYPE aFrom;
|
|
@@ -2121,11 +2121,11 @@ void main(void) {
|
|
|
2121
2121
|
}
|
|
2122
2122
|
gl_Position = vec4(0.0);
|
|
2123
2123
|
}
|
|
2124
|
-
`;function
|
|
2124
|
+
`;function oN(e){return e.doublePrecision&&e.value instanceof Float64Array}function sN(e,t){let n=t.size,r=YM(n),i=XM(n),a=t.getBufferLayout();return oN(t)?new _D(e,{vs:aN,bufferLayout:[{name:`aFrom`,byteStride:8*n,attributes:[{attribute:`aFrom`,format:i,byteOffset:0},{attribute:`aFrom64Low`,format:i,byteOffset:4*n}]},{name:`aTo`,byteStride:8*n,attributes:[{attribute:`aTo`,format:i,byteOffset:0},{attribute:`aTo64Low`,format:i,byteOffset:4*n}]}],modules:[ey,rN],defines:{ATTRIBUTE_TYPE:r,ATTRIBUTE_SIZE:n},moduleSettings:{},varyings:[`vCurrent`,`vCurrent64Low`],bufferMode:35980,disableWarnings:!0}):new _D(e,{vs:iN,bufferLayout:[{name:`aFrom`,format:i},{name:`aTo`,format:a.attributes[0].format}],modules:[rN],defines:{ATTRIBUTE_TYPE:r},varyings:[`vCurrent`],disableWarnings:!0})}var cN=class extends tN{constructor({device:e,attribute:t,timeline:n}){super({device:e,attribute:t,timeline:n}),this.type=`spring`,this.texture=pN(e),this.framebuffer=mN(e,this.texture),this.transform=fN(e,t)}start(e,t){let n=this.currentLength,r=this.currentStartIndices;super.start(e,t);let{buffers:i,attribute:a}=this;for(let t=0;t<2;t++)i[t]=eN({device:this.device,buffer:i[t],attribute:a,fromLength:n,toLength:this.currentLength,fromStartIndices:r,getData:e.enter});i[2]=$M({device:this.device,source:i[0],target:i[2]}),this.setBuffer(i[1]);let{model:o}=this.transform;o.setVertexCount(Math.floor(this.currentLength/a.size)),a.isConstant?o.setConstantAttributes({aTo:a.value}):o.setAttributes({aTo:a.getBuffer()})}onUpdate(){let{buffers:e,transform:t,framebuffer:n,transition:r}=this,i=this.settings;t.model.setAttributes({aPrev:e[0],aCur:e[1]}),t.transformFeedback.setBuffers({vNext:e[2]});let a={stiffness:i.stiffness,damping:i.damping};t.model.shaderInputs.setProps({spring:a}),t.run({framebuffer:n,discard:!1,parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]}),ZM(e),this.setBuffer(e[1]),this.device.readPixelsToArrayWebGL(n)[0]>0||r.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}},lN={name:`spring`,vs:`layout(std140) uniform springUniforms {
|
|
2125
2125
|
float damping;
|
|
2126
2126
|
float stiffness;
|
|
2127
2127
|
} spring;
|
|
2128
|
-
`,uniformTypes:{damping:`f32`,stiffness:`f32`}},
|
|
2128
|
+
`,uniformTypes:{damping:`f32`,stiffness:`f32`}},uN=`#version 300 es
|
|
2129
2129
|
#define SHADER_NAME spring-transition-vertex-shader
|
|
2130
2130
|
|
|
2131
2131
|
#define EPSILON 0.00001
|
|
@@ -2152,7 +2152,7 @@ void main(void) {
|
|
|
2152
2152
|
gl_Position = vec4(0, 0, 0, 1);
|
|
2153
2153
|
gl_PointSize = 100.0;
|
|
2154
2154
|
}
|
|
2155
|
-
`,
|
|
2155
|
+
`,dN=`#version 300 es
|
|
2156
2156
|
#define SHADER_NAME spring-transition-is-transitioning-fragment-shader
|
|
2157
2157
|
|
|
2158
2158
|
in float vIsTransitioningFlag;
|
|
@@ -2164,7 +2164,7 @@ void main(void) {
|
|
|
2164
2164
|
discard;
|
|
2165
2165
|
}
|
|
2166
2166
|
fragColor = vec4(1.0);
|
|
2167
|
-
}`;function aN(e,t){let n=HM(t.size),r=UM(t.size);return new uD(e,{vs:rN,fs:iN,bufferLayout:[{name:`aPrev`,format:r},{name:`aCur`,format:r},{name:`aTo`,format:t.getBufferLayout().attributes[0].format}],varyings:[`vNext`],modules:[nN],defines:{ATTRIBUTE_TYPE:n},parameters:{depthCompare:`always`,blendColorOperation:`max`,blendColorSrcFactor:`one`,blendColorDstFactor:`one`,blendAlphaOperation:`max`,blendAlphaSrcFactor:`one`,blendAlphaDstFactor:`one`}})}function oN(e){return e.createTexture({data:new Uint8Array(4),format:`rgba8unorm`,width:1,height:1})}function sN(e,t){return e.createFramebuffer({id:`spring-transition-is-transitioning-framebuffer`,width:1,height:1,colorAttachments:[t]})}var cN={interpolation:YM,spring:tN},lN=class{constructor(e,{id:t,timeline:n}){if(!e)throw Error(`AttributeTransitionManager is constructed without device`);this.id=t,this.device=e,this.timeline=n,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(let e in this.transitions)this._removeTransition(e)}update({attributes:e,transitions:t,numInstances:n}){this.numInstances=n||1;for(let n in e){let r=e[n],i=r.getTransitionSetting(t);i&&this._updateAttribute(n,r,i)}for(let n in this.transitions){let r=e[n];(!r||!r.getTransitionSetting(t))&&this._removeTransition(n)}}hasAttribute(e){let t=this.transitions[e];return t&&t.inProgress}getAttributes(){let e={};for(let t in this.transitions){let n=this.transitions[t];n.inProgress&&(e[t]=n.attributeInTransition)}return e}run(){if(this.numInstances===0)return!1;for(let e in this.transitions)this.transitions[e].update()&&(this.needsRedraw=!0);let e=this.needsRedraw;return this.needsRedraw=!1,e}_removeTransition(e){this.transitions[e].delete(),delete this.transitions[e]}_updateAttribute(e,t,n){let r=this.transitions[e],i=!r||r.type!==n.type;if(i){r&&this._removeTransition(e);let a=cN[n.type];a?this.transitions[e]=new a({attribute:t,timeline:this.timeline,device:this.device}):(X.error(`unsupported transition type '${n.type}'`)(),i=!1)}(i||t.needsRedraw())&&(this.needsRedraw=!0,this.transitions[e].start(n,this.numInstances))}},uN=`attributeManager.invalidate`,dN=`attributeManager.updateStart`,fN=`attributeManager.updateEnd`,pN=`attribute.updateStart`,mN=`attribute.allocate`,hN=`attribute.updateEnd`,gN=class{constructor(e,{id:t=`attribute-manager`,stats:n,timeline:r}={}){this.mergeBoundsMemoized=GC(IT),this.id=t,this.device=e,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=n,this.attributeTransitionManager=new lN(e,{id:`${t}-transitions`,timeline:r}),Object.seal(this)}finalize(){for(let e in this.attributes)this.attributes[e].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(e={clearRedrawFlags:!1}){let t=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!e.clearRedrawFlags,t&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(e){this._add(e)}addInstanced(e){this._add(e,{stepMode:`instance`})}remove(e){for(let t of e)this.attributes[t]!==void 0&&(this.attributes[t].delete(),delete this.attributes[t])}invalidate(e,t){let n=this._invalidateTrigger(e,t);ih(uN,this,e,n)}invalidateAll(e){for(let t in this.attributes)this.attributes[t].setNeedsUpdate(t,e);ih(uN,this,`all`)}update({data:e,numInstances:t,startIndices:n=null,transitions:r,props:i={},buffers:a={},context:o={}}){let s=!1;ih(dN,this),this.stats&&this.stats.get(`Update Attributes`).timeStart();for(let r in this.attributes){let c=this.attributes[r],l=c.settings.accessor;c.startIndices=n,c.numInstances=t,i[r]&&X.removed(`props.${r}`,`data.attributes.${r}`)(),c.setExternalBuffer(a[r])||c.setBinaryValue(typeof l==`string`?a[l]:void 0,e.startIndices)||typeof l==`string`&&!a[l]&&c.setConstantValue(o,i[l])||c.needsUpdate()&&(s=!0,this._updateAttribute({attribute:c,numInstances:t,data:e,props:i,context:o})),this.needsRedraw=this.needsRedraw||c.needsRedraw()}s&&ih(fN,this,t),this.stats&&(this.stats.get(`Update Attributes`).timeEnd(),s&&this.stats.get(`Attributes updated`).incrementCount()),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:t,transitions:r})}updateTransition(){let{attributeTransitionManager:e}=this,t=e.run();return this.needsRedraw=this.needsRedraw||t,t}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(e){let t=e.map(e=>this.attributes[e]?.getBounds());return this.mergeBoundsMemoized(t)}getChangedAttributes(e={clearChangedFlags:!1}){let{attributes:t,attributeTransitionManager:n}=this,r={...n.getAttributes()};for(let i in t){let a=t[i];a.needsRedraw(e)&&!n.hasAttribute(i)&&(r[i]=a)}return r}getBufferLayouts(e){return Object.values(this.getAttributes()).map(t=>t.getBufferLayout(e))}_add(e,t){for(let n in e){let r=e[n],i={...r,id:n,size:r.isIndexed&&1||r.size||1,...t};this.attributes[n]=new RM(this.device,i)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){let e={};for(let t in this.attributes)this.attributes[t].getUpdateTriggers().forEach(n=>{e[n]||(e[n]=[]),e[n].push(t)});this.updateTriggers=e}_invalidateTrigger(e,t){let{attributes:n,updateTriggers:r}=this,i=r[e];return i&&i.forEach(e=>{let r=n[e];r&&r.setNeedsUpdate(r.id,t)}),i}_updateAttribute(e){let{attribute:t,numInstances:n}=e;if(ih(pN,t),t.constant){t.setConstantValue(e.context,t.value);return}t.allocate(n)&&ih(mN,t,n),t.updateBuffer(e)&&(this.needsRedraw=!0,ih(hN,t,n))}},_N=class extends GD{get value(){return this._value}_onUpdate(){let{time:e,settings:{fromValue:t,toValue:n,duration:r,easing:i}}=this,a=i(e/r);this._value=p_(t,n,a)}},vN=1e-5;function yN(e,t,n,r,i){let a=t-e;return(n-t)*i+-a*r+a+t}function bN(e,t,n,r,i){if(Array.isArray(n)){let a=[];for(let o=0;o<n.length;o++)a[o]=yN(e[o],t[o],n[o],r,i);return a}return yN(e,t,n,r,i)}function xN(e,t){if(Array.isArray(e)){let n=0;for(let r=0;r<e.length;r++){let i=e[r]-t[r];n+=i*i}return Math.sqrt(n)}return Math.abs(e-t)}var SN={interpolation:_N,spring:class extends GD{get value(){return this._currValue}_onUpdate(){let{fromValue:e,toValue:t,damping:n,stiffness:r}=this.settings,{_prevValue:i=e,_currValue:a=e}=this,o=bN(i,a,t,n,r),s=xN(o,t),c=xN(o,a);s<vN&&c<vN&&(o=t,this.end()),this._prevValue=a,this._currValue=o}}},CN=class{constructor(e){this.transitions=new Map,this.timeline=e}get active(){return this.transitions.size>0}add(e,t,n,r){let{transitions:i}=this;if(i.has(e)){let n=i.get(e),{value:r=n.settings.fromValue}=n;t=r,this.remove(e)}if(r=LM(r),!r)return;let a=SN[r.type];if(!a){X.error(`unsupported transition type '${r.type}'`)();return}let o=new a(this.timeline);o.start({...r,fromValue:t,toValue:n}),i.set(e,o)}remove(e){let{transitions:t}=this;t.has(e)&&(t.get(e).cancel(),t.delete(e))}update(){let e={};for(let[t,n]of this.transitions)n.update(),e[t]=n.value,n.inProgress||this.remove(t);return e}clear(){for(let e of this.transitions.keys())this.remove(e)}};function wN(e){let t=e[vD];for(let n in t){let r=t[n],{validate:i}=r;if(i&&!i(e[n],r))throw Error(`Invalid prop ${n}: ${e[n]}`)}}function TN(e,t){let n=DN({newProps:e,oldProps:t,propTypes:e[vD],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),r=kN(e,t),i=!1;return r||(i=AN(e,t)),{dataChanged:r,propsChanged:n,updateTriggersChanged:i,extensionsChanged:jN(e,t),transitionsChanged:EN(e,t)}}function EN(e,t){if(!e.transitions)return!1;let n={},r=e[vD],i=!1;for(let a in e.transitions){let o=r[a],s=o&&o.type;(s===`number`||s===`color`||s===`array`)&&ON(e[a],t[a],o)&&(n[a]=!0,i=!0)}return i?n:!1}function DN({newProps:e,oldProps:t,ignoreProps:n={},propTypes:r={},triggerName:i=`props`}){if(t===e)return!1;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return`${i} changed shallowly`;for(let a of Object.keys(e))if(!(a in n)){if(!(a in t))return`${i}.${a} added`;let n=ON(e[a],t[a],r[a]);if(n)return`${i}.${a} ${n}`}for(let a of Object.keys(t))if(!(a in n)){if(!(a in e))return`${i}.${a} dropped`;if(!Object.hasOwnProperty.call(e,a)){let n=ON(e[a],t[a],r[a]);if(n)return`${i}.${a} ${n}`}}return!1}function ON(e,t,n){let r=n&&n.equal;return r&&!r(e,t,n)||!r&&(r=e&&t&&e.equals,r&&!r.call(e,t))?`changed deeply`:!r&&t!==e?`changed shallowly`:null}function kN(e,t){if(t===null)return`oldProps is null, initial diff`;let n=!1,{dataComparator:r,_dataDiff:i}=e;return r?r(e.data,t.data)||(n=`Data comparator detected a change`):e.data!==t.data&&(n=`A new data container was supplied`),n&&i&&(n=i(e.data,t.data)||n),n}function AN(e,t){if(t===null||`all`in e.updateTriggers&&MN(e,t,`all`))return{all:!0};let n={},r=!1;for(let i in e.updateTriggers)i!==`all`&&MN(e,t,i)&&(n[i]=!0,r=!0);return r?n:!1}function jN(e,t){if(t===null)return!0;let n=t.extensions,{extensions:r}=e;if(r===n)return!1;if(!n||!r||r.length!==n.length)return!0;for(let e=0;e<r.length;e++)if(!r[e].equals(n[e]))return!0;return!1}function MN(e,t,n){let r=e.updateTriggers[n];r??={};let i=t.updateTriggers[n];return i??={},DN({oldProps:i,newProps:r,triggerName:n})}var NN=`count(): argument not an object`,PN=`count(): argument not a container`;function FN(e){if(!LN(e))throw Error(NN);if(typeof e.count==`function`)return e.count();if(Number.isFinite(e.size))return e.size;if(Number.isFinite(e.length))return e.length;if(IN(e))return Object.keys(e).length;throw Error(PN)}function IN(e){return typeof e==`object`&&!!e&&e.constructor===Object}function LN(e){return typeof e==`object`&&!!e}function RN(e,t){if(!t)return e;let n={...e,...t};if(`defines`in t&&(n.defines={...e.defines,...t.defines}),`modules`in t&&(n.modules=(e.modules||[]).concat(t.modules),t.modules.some(e=>e.name===`project64`))){let e=n.modules.findIndex(e=>e.name===`project32`);e>=0&&n.modules.splice(e,1)}if(`inject`in t)if(!e.inject)n.inject=t.inject;else{let r={...e.inject};for(let e in t.inject)r[e]=(r[e]||``)+t.inject[e];n.inject=r}return n}var zN={minFilter:`linear`,mipmapFilter:`linear`,magFilter:`linear`,addressModeU:`clamp-to-edge`,addressModeV:`clamp-to-edge`},BN={};function VN(e,t,n,r){if(n instanceof zb)return n;n.constructor&&n.constructor.name!==`Object`&&(n={data:n});let i=null;n.compressed&&(i={minFilter:`linear`,mipmapFilter:n.data.length>1?`nearest`:`linear`});let{width:a,height:o}=n.data,s=t.createTexture({...n,sampler:{...zN,...i,...r},mipLevels:t.getMipLevelCount(a,o)});return t.type===`webgl`?s.generateMipmapsWebGL():t.type===`webgpu`&&t.generateMipmapsWebGPU(s),BN[s.id]=e,s}function HN(e,t){!t||!(t instanceof zb)||BN[t.id]===e&&(t.delete(),delete BN[t.id])}var UN={boolean:{validate(e,t){return!0},equal(e,t,n){return!!e==!!t}},number:{validate(e,t){return Number.isFinite(e)&&(!(`max`in t)||e<=t.max)&&(!(`min`in t)||e>=t.min)}},color:{validate(e,t){return t.optional&&!e||qN(e)&&(e.length===3||e.length===4)},equal(e,t,n){return jD(e,t,1)}},accessor:{validate(e,t){let n=JN(e);return n===`function`||n===JN(t.value)},equal(e,t,n){return typeof t==`function`?!0:jD(e,t,1)}},array:{validate(e,t){return t.optional&&!e||qN(e)},equal(e,t,n){let{compare:r}=n;return r?jD(e,t,Number.isInteger(r)?r:+!!r):e===t}},object:{equal(e,t,n){if(n.ignore)return!0;let{compare:r}=n;return r?jD(e,t,Number.isInteger(r)?r:+!!r):e===t}},function:{validate(e,t){return t.optional&&!e||typeof e==`function`},equal(e,t,n){return!n.compare&&n.ignore!==!1||e===t}},data:{transform:(e,t,n)=>{if(!e)return e;let{dataTransform:r}=n.props;return r?r(e):typeof e.shape==`string`&&e.shape.endsWith(`-table`)&&Array.isArray(e.data)?e.data:e}},image:{transform:(e,t,n)=>{let r=n.context;return!r||!r.device?null:VN(n.id,r.device,e,{...t.parameters,...n.props.textureParameters})},release:(e,t,n)=>{HN(n.id,e)}}};function WN(e){let t={},n={},r={};for(let[i,a]of Object.entries(e)){let e=a?.deprecatedFor;if(e)r[i]=Array.isArray(e)?e:[e];else{let e=GN(i,a);t[i]=e,n[i]=e.value}}return{propTypes:t,defaultProps:n,deprecatedProps:r}}function GN(e,t){switch(JN(t)){case`object`:return KN(e,t);case`array`:return KN(e,{type:`array`,value:t,compare:!1});case`boolean`:return KN(e,{type:`boolean`,value:t});case`number`:return KN(e,{type:`number`,value:t});case`function`:return KN(e,{type:`function`,value:t,compare:!0});default:return{name:e,type:`unknown`,value:t}}}function KN(e,t){return`type`in t?{name:e,...UN[t.type],...t}:`value`in t?{name:e,type:JN(t.value),...t}:{name:e,type:`object`,value:t}}function qN(e){return Array.isArray(e)||ArrayBuffer.isView(e)}function JN(e){return qN(e)?`array`:e===null?`null`:typeof e}function YN(e,t){let n;for(let e=t.length-1;e>=0;e--){let r=t[e];`extensions`in r&&(n=r.extensions)}let r=ZN(e.constructor,n),i=Object.create(r);i[_D]=e,i[xD]={},i[SD]={};for(let e=0;e<t.length;++e){let n=t[e];for(let e in n)i[e]=n[e]}return Object.freeze(i),i}var XN=`_mergedDefaultProps`;function ZN(e,t){if(!(e instanceof sP.constructor))return{};let n=XN;if(t)for(let e of t){let t=e.constructor;t&&(n+=`:${t.extensionName||t.name}`)}return iP(e,n)||(e[n]=QN(e,t||[]))}function QN(e,t){if(!e.prototype)return null;let n=ZN(Object.getPrototypeOf(e)),r=WN(iP(e,`defaultProps`)||{}),i=Object.assign(Object.create(null),n,r.defaultProps),a=Object.assign(Object.create(null),n?.[vD],r.propTypes),o=Object.assign(Object.create(null),n?.[yD],r.deprecatedProps);for(let e of t){let t=ZN(e.constructor);t&&(Object.assign(i,t),Object.assign(a,t[vD]),Object.assign(o,t[yD]))}return $N(i,e),tP(i,a),eP(i,o),i[vD]=a,i[yD]=o,t.length===0&&!rP(e,`_propTypes`)&&(e._propTypes=a),i}function $N(e,t){let n=aP(t);Object.defineProperties(e,{id:{writable:!0,value:n}})}function eP(e,t){for(let n in t)Object.defineProperty(e,n,{enumerable:!1,set(e){let r=`${this.id}: ${n}`;for(let r of t[n])rP(this,r)||(this[r]=e);X.deprecated(r,t[n].join(`/`))()}})}function tP(e,t){let n={},r={};for(let e in t){let i=t[e],{name:a,value:o}=i;i.async&&(n[a]=o,r[a]=nP(a))}e[bD]=n,e[xD]={},Object.defineProperties(e,r)}function nP(e){return{enumerable:!0,set(t){typeof t==`string`||t instanceof Promise||jM(t)?this[xD][e]=t:this[SD][e]=t},get(){if(this[SD]){if(e in this[SD])return this[SD][e]||this[bD][e];if(e in this[xD]){let t=this[_D]&&this[_D].internalState;if(t&&t.hasAsyncProp(e))return t.getAsyncProp(e)||this[bD][e]}}return this[bD][e]}}}function rP(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function iP(e,t){return rP(e,t)&&e[t]}function aP(e){let t=e.componentName;return t||X.warn(`${e.name}.componentName not specified`)(),t||e.name}var oP=0,sP=class{constructor(...e){this.props=YN(this,e),this.id=this.props.id,this.count=oP++}clone(e){let{props:t}=this,n={};for(let e in t[bD])e in t[SD]?n[e]=t[SD][e]:e in t[xD]&&(n[e]=t[xD][e]);return new this.constructor({...t,...n,...e})}};sP.componentName=`Component`,sP.defaultProps={};var cP=Object.freeze({}),lP=class{constructor(e){this.component=e,this.asyncProps={},this.onAsyncPropUpdated=()=>{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(let e in this.asyncProps){let t=this.asyncProps[e];t&&t.type&&t.type.release&&t.type.release(t.resolvedValue,t.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||cP}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(e){return e in this.asyncProps}getAsyncProp(e){let t=this.asyncProps[e];return t&&t.resolvedValue}isAsyncPropLoading(e){if(e){let t=this.asyncProps[e];return!!(t&&t.pendingLoadCount>0&&t.pendingLoadCount!==t.resolvedLoadCount)}for(let e in this.asyncProps)if(this.isAsyncPropLoading(e))return!0;return!1}reloadAsyncProp(e,t){this._watchPromise(e,Promise.resolve(t))}setAsyncProps(e){this.component=e[_D]||this.component;let t=e[SD]||{},n=e[xD]||e,r=e[bD]||{};for(let e in t){let n=t[e];this._createAsyncPropData(e,r[e]),this._updateAsyncProp(e,n),t[e]=this.getAsyncProp(e)}for(let e in n){let t=n[e];this._createAsyncPropData(e,r[e]),this._updateAsyncProp(e,t)}}_fetch(e,t){return null}_onResolve(e,t){}_onError(e,t){}_updateAsyncProp(e,t){if(this._didAsyncInputValueChange(e,t)){if(typeof t==`string`&&(t=this._fetch(e,t)),t instanceof Promise){this._watchPromise(e,t);return}if(jM(t)){this._resolveAsyncIterable(e,t);return}this._setPropValue(e,t)}}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(let e in this.asyncProps)Object.defineProperty(this.oldAsyncProps,e,{enumerable:!0,value:this.oldProps[e]})}}_didAsyncInputValueChange(e,t){let n=this.asyncProps[e];return t===n.resolvedValue||t===n.lastValue?!1:(n.lastValue=t,!0)}_setPropValue(e,t){this._freezeAsyncOldProps();let n=this.asyncProps[e];n&&(t=this._postProcessValue(n,t),n.resolvedValue=t,n.pendingLoadCount++,n.resolvedLoadCount=n.pendingLoadCount)}_setAsyncPropValue(e,t,n){let r=this.asyncProps[e];r&&n>=r.resolvedLoadCount&&t!==void 0&&(this._freezeAsyncOldProps(),r.resolvedValue=t,r.resolvedLoadCount=n,this.onAsyncPropUpdated(e,t))}_watchPromise(e,t){let n=this.asyncProps[e];if(n){n.pendingLoadCount++;let r=n.pendingLoadCount;t.then(t=>{this.component&&(t=this._postProcessValue(n,t),this._setAsyncPropValue(e,t,r),this._onResolve(e,t))}).catch(t=>{this._onError(e,t)})}}async _resolveAsyncIterable(e,t){if(e!==`data`){this._setPropValue(e,t);return}let n=this.asyncProps[e];if(!n)return;n.pendingLoadCount++;let r=n.pendingLoadCount,i=[],a=0;for await(let n of t){if(!this.component)return;let{dataTransform:t}=this.component.props;i=t?t(n,i):i.concat(n),Object.defineProperty(i,"__diff",{enumerable:!1,value:[{startRow:a,endRow:i.length}]}),a=i.length,this._setAsyncPropValue(e,i,r)}this._onResolve(e,i)}_postProcessValue(e,t){let n=e.type;return n&&this.component&&(n.release&&n.release(e.resolvedValue,n,this.component),n.transform)?n.transform(t,n,this.component):t}_createAsyncPropData(e,t){if(!this.asyncProps[e]){let n=this.component&&this.component.props[vD];this.asyncProps[e]={type:n&&n[e],lastValue:null,resolvedValue:t,pendingLoadCount:0,resolvedLoadCount:0}}}},uP=class extends lP{constructor({attributeManager:e,layer:t}){super(t),this.attributeManager=e,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1}get layer(){return this.component}_fetch(e,t){let n=this.layer,r=n?.props.fetch;return r?r(t,{propName:e,layer:n}):super._fetch(e,t)}_onResolve(e,t){let n=this.layer;if(n){let r=n.props.onDataLoad;e===`data`&&r&&r(t,{propName:e,layer:n})}}_onError(e,t){let n=this.layer;n&&n.raiseError(t,`loading ${e} of ${this.layer}`)}},dP=`layer.changeFlag`,fP=`layer.initialize`,pP=`layer.update`,mP=`layer.finalize`,hP=`layer.matched`,gP=2**24-1,_P=Object.freeze([]),vP=GC(({oldViewport:e,viewport:t})=>e.equals(t)),yP=new Uint8ClampedArray,bP={data:{type:`data`,value:_P,async:!0},dataComparator:{type:`function`,value:null,optional:!0},_dataDiff:{type:`function`,value:e=>e&&e.__diff,optional:!0},dataTransform:{type:`function`,value:null,optional:!0},onDataLoad:{type:`function`,value:null,optional:!0},onError:{type:`function`,value:null,optional:!0},fetch:{type:`function`,value:(e,{propName:t,layer:n,loaders:r,loadOptions:i,signal:a})=>{let{resourceManager:o}=n.context;i||=n.getLoadOptions(),r||=n.props.loaders,a&&(i={...i,core:{...i?.core,fetch:{...i?.core?.fetch,signal:a}}});let s=o.contains(e);return!s&&!i&&(o.add({resourceId:e,data:hm(e,r),persistent:!1}),s=!0),s?o.subscribe({resourceId:e,onChange:e=>n.internalState?.reloadAsyncProp(t,e),consumerId:n.id,requestId:t}):hm(e,r,i)}},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:`number`,min:0,max:1,value:1},operation:`draw`,onHover:{type:`function`,value:null,optional:!0},onClick:{type:`function`,value:null,optional:!0},onDragStart:{type:`function`,value:null,optional:!0},onDrag:{type:`function`,value:null,optional:!0},onDragEnd:{type:`function`,value:null,optional:!0},coordinateSystem:`default`,coordinateOrigin:{type:`array`,value:[0,0,0],compare:!0},modelMatrix:{type:`array`,value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:`XYZ`,colorFormat:`RGBA`,parameters:{type:`object`,value:{},optional:!0,compare:2},loadOptions:{type:`object`,value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:`array`,value:[],optional:!0,ignore:!0},getPolygonOffset:{type:`function`,value:({layerIndex:e})=>[0,-e*100]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:`accessor`,value:[0,0,128,128]}},xP=class extends sP{constructor(){super(...arguments),this.internalState=null,this.lifecycle=gD.NO_STATE,this.parent=null}static get componentName(){return Object.prototype.hasOwnProperty.call(this,`layerName`)?this.layerName:``}get root(){let e=this;for(;e.parent;)e=e.parent;return e}toString(){return`${this.constructor.layerName||this.constructor.name}({id: '${this.props.id}'})`}project(e){ZD(this.internalState);let t=this.internalState.viewport||this.context.viewport,[n,r,i]=Fw(qT(e,{viewport:t,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),t.pixelProjectionMatrix);return e.length===2?[n,r]:[n,r,i]}unproject(e){return ZD(this.internalState),(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,t){return ZD(this.internalState),JT(e,{viewport:this.internalState.viewport||this.context.viewport,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...t})}get isComposite(){return!1}get isDrawable(){return!0}setState(e){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,e),this.setNeedsRedraw()}setNeedsRedraw(){this.internalState&&(this.internalState.needsRedraw=!0)}setNeedsUpdate(){this.internalState&&(this.context.layerManager.setNeedsUpdate(String(this)),this.internalState.needsUpdate=!0)}get isLoaded(){return this.internalState?!this.internalState.isAsyncPropLoading():!1}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){let e=this.state;return e&&(e.models||e.model&&[e.model])||[]}setShaderModuleProps(...e){for(let t of this.getModels())t.shaderInputs.setProps(...e)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){let{coordinateSystem:e}=this.props;return e===`default`||e===`lnglat`||e===`cartesian`}onHover(e,t){return this.props.onHover&&this.props.onHover(e,t)||!1}onClick(e,t){return this.props.onClick&&this.props.onClick(e,t)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(e,t=[]){return t[0]=e+1&255,t[1]=e+1>>8&255,t[2]=e+1>>8>>8&255,t}decodePickingColor(e){ZD(e instanceof Uint8Array);let[t,n,r]=e;return t+n*256+r*65536-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&this.state.numInstances!==void 0?this.state.numInstances:FN(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){return this.getAttributeManager()?.getBounds([`positions`,`instancePositions`])}getShaders(e){e=RN(e,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(let t of this.props.extensions)e=RN(e,t.getShaders.call(this,t));return e}shouldUpdateState(e){return e.changeFlags.propsOrDataChanged}updateState(e){let t=this.getAttributeManager(),{dataChanged:n}=e.changeFlags;if(n&&t)if(Array.isArray(n))for(let e of n)t.invalidateAll(e);else t.invalidateAll();if(t){let{props:n}=e,r=this.internalState.hasPickingBuffer,i=Number.isInteger(n.highlightedObjectIndex)||!!n.pickable||n.extensions.some(e=>e.getNeedsPickingBuffer.call(this,e));if(r!==i){this.internalState.hasPickingBuffer=i;let{pickingColors:e,instancePickingColors:n}=t.attributes,r=e||n;r&&(i&&r.constant&&(r.constant=!1,t.invalidate(r.id)),!r.value&&!i&&(r.constant=!0,r.value=[0,0,0]))}}}finalizeState(e){for(let e of this.getModels())e.destroy();let t=this.getAttributeManager();t&&t.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(e){for(let t of this.getModels())t.draw(e.renderPass)}getPickingInfo({info:e,mode:t,sourceLayer:n}){let{index:r}=e;return r>=0&&Array.isArray(this.props.data)&&(e.object=this.props.data[r]),e}raiseError(e,t){t&&(e=Error(`${t}: ${e.message}`,{cause:e})),this.props.onError?.(e)||this.context?.onError?.(e,this)}getNeedsRedraw(e={clearRedrawFlags:!1}){return this._getNeedsRedraw(e)}needsUpdate(){return this.internalState?this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()):!1}hasUniformTransition(){return this.internalState?.uniformTransitions.active||!1}activateViewport(e){if(!this.internalState)return;let t=this.internalState.viewport;this.internalState.viewport=e,(!t||!vP({oldViewport:t,viewport:e}))&&(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(e=`all`){let t=this.getAttributeManager();t&&(e===`all`?t.invalidateAll():t.invalidate(e))}updateAttributes(e){let t=!1;for(let n in e)e[n].layoutChanged()&&(t=!0);for(let n of this.getModels())this._setModelAttributes(n,e,t)}_updateAttributes(){let e=this.getAttributeManager();if(!e)return;let t=this.props,n=this.getNumInstances(),r=this.getStartIndices();e.update({data:t.data,numInstances:n,startIndices:r,props:t,transitions:t.transitions,buffers:t.data.attributes,context:this});let i=e.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(i)}_updateAttributeTransition(){let e=this.getAttributeManager();e&&e.updateTransition()}_updateUniformTransition(){let{uniformTransitions:e}=this.internalState;if(e.active){let t=e.update(),n=Object.create(this.props);for(let e in t)Object.defineProperty(n,e,{value:t[e]});return n}return this.props}calculateInstancePickingColors(e,{numInstances:t}){if(e.constant)return;let n=Math.floor(yP.length/4);if(this.internalState.usesPickingColorCache=!0,n<t){t>gP&&X.warn(`Layer has too many data objects. Picking might not be able to distinguish all objects.`)(),yP=ET.allocate(yP,t,{size:4,copy:!0,maxCount:Math.max(t,gP)});let e=Math.floor(yP.length/4),r=[0,0,0];for(let t=n;t<e;t++)this.encodePickingColor(t,r),yP[t*4+0]=r[0],yP[t*4+1]=r[1],yP[t*4+2]=r[2],yP[t*4+3]=0}e.value=yP.subarray(0,t*4)}_setModelAttributes(e,t,n=!1){if(!Object.keys(t).length)return;if(n){let n=this.getAttributeManager();e.setBufferLayout(n.getBufferLayouts(e)),t=n.getAttributes()}let r=e.userData?.excludeAttributes||{},i={},a={};for(let n in t){if(r[n])continue;let o=t[n].getValue();for(let r in o){let s=o[r];s instanceof Sy?t[n].settings.isIndexed?e.setIndexBuffer(s):i[r]=s:s&&(a[r]=s)}}e.setAttributes(i),e.setConstantAttributes(a)}disablePickingIndex(e){let t=this.props.data;if(!(`attributes`in t)){this._disablePickingIndex(e);return}let{pickingColors:n,instancePickingColors:r}=this.getAttributeManager().attributes,i=n||r,a=i&&t.attributes&&t.attributes[i.id];if(a&&a.value){let n=a.value,r=this.encodePickingColor(e);for(let e=0;e<t.length;e++){let t=i.getVertexOffset(e);n[t]===r[0]&&n[t+1]===r[1]&&n[t+2]===r[2]&&this._disablePickingIndex(e)}}else this._disablePickingIndex(e)}_disablePickingIndex(e){let{pickingColors:t,instancePickingColors:n}=this.getAttributeManager().attributes,r=t||n;if(!r)return;let i=r.getVertexOffset(e),a=r.getVertexOffset(e+1);r.buffer.write(new Uint8Array(a-i),i)}restorePickingColors(){let{pickingColors:e,instancePickingColors:t}=this.getAttributeManager().attributes,n=e||t;n&&(this.internalState.usesPickingColorCache&&n.value.buffer!==yP.buffer&&(n.value=yP.subarray(0,n.value.length)),n.updateSubBuffer({startOffset:0}))}_initialize(){ZD(!this.internalState),ih(fP,this);let e=this._getAttributeManager();e&&e.addInstanced({instancePickingColors:{type:`uint8`,size:4,noAlloc:!0,update:this.calculateInstancePickingColors}}),this.internalState=new uP({attributeManager:e,layer:this}),this._clearChangeFlags(),this.state={},Object.defineProperty(this.state,"attributeManager",{get:()=>(X.deprecated(`layer.state.attributeManager`,`layer.getAttributeManager()`)(),e)}),this.internalState.uniformTransitions=new CN(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(let e of this.props.extensions)e.initializeState.call(this,this.context,e);this.setChangeFlags({dataChanged:`init`,propsChanged:`init`,viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(e){ih(hP,this,this===e);let{state:t,internalState:n}=e;this!==e&&(this.internalState=n,this.state=t,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){let e=this.needsUpdate();if(ih(pP,this,e),!e)return;this.context.stats.get(`Layer updates`).incrementCount();let t=this.props,n=this.context,r=this.internalState,i=n.viewport,a=this._updateUniformTransition();r.propsInTransition=a,n.viewport=r.viewport||i,this.props=a;try{let e=this._getUpdateParams(),t=this.getModels();if(n.device)this.updateState(e);else try{this.updateState(e)}catch{}for(let t of this.props.extensions)t.updateState.call(this,e,t);this.setNeedsRedraw(),this._updateAttributes();let r=this.getModels()[0]!==t[0];this._postUpdate(e,r)}finally{n.viewport=i,this.props=t,this._clearChangeFlags(),r.needsUpdate=!1,r.resetOldProps()}}_finalize(){ih(mP,this),this.finalizeState(this.context);for(let e of this.props.extensions)e.finalizeState.call(this,this.context,e)}_drawLayer({renderPass:e,shaderModuleProps:t=null,uniforms:n={},parameters:r={}}){this._updateAttributeTransition();let i=this.props,a=this.context;this.props=this.internalState.propsInTransition||i;try{t&&this.setShaderModuleProps(t);let{getPolygonOffset:i}=this.props,o=i&&i(n)||[0,0];a.device instanceof fM&&a.device.setParametersWebGL({polygonOffset:o});let s=a.device instanceof fM?null:SP(r);if(CP(this.getModels(),e,r,s),a.device instanceof fM)a.device.withParametersWebGL(r,()=>{let i={renderPass:e,shaderModuleProps:t,uniforms:n,parameters:r,context:a};for(let e of this.props.extensions)e.draw.call(this,i,e);this.draw(i)});else{s?.renderPassParameters&&e.setParameters(s.renderPassParameters);let i={renderPass:e,shaderModuleProps:t,uniforms:n,parameters:r,context:a};for(let e of this.props.extensions)e.draw.call(this,i,e);this.draw(i)}}finally{this.props=i}}getChangeFlags(){return this.internalState?.changeFlags}setChangeFlags(e){if(!this.internalState)return;let{changeFlags:t}=this.internalState;for(let n in e)if(e[n]){let r=!1;switch(n){case`dataChanged`:let i=e[n],a=t[n];i&&Array.isArray(a)&&(t.dataChanged=Array.isArray(i)?a.concat(i):i,r=!0);default:t[n]||(t[n]=e[n],r=!0)}r&&ih(dP,this,n,e)}let n=!!(t.dataChanged||t.updateTriggersChanged||t.propsChanged||t.extensionsChanged);t.propsOrDataChanged=n,t.somethingChanged=n||t.viewportChanged||t.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(e,t){let n=TN(e,t);if(n.updateTriggersChanged)for(let e in n.updateTriggersChanged)n.updateTriggersChanged[e]&&this.invalidateAttribute(e);if(n.transitionsChanged)for(let r in n.transitionsChanged)this.internalState.uniformTransitions.add(r,t[r],e[r],e.transitions?.[r]);return this.setChangeFlags(n)}validateProps(){wN(this.props)}updateAutoHighlight(e){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(e)}_updateAutoHighlight(e){let t={highlightedObjectColor:e.picked?e.color:null},{highlightColor:n}=this.props;e.picked&&typeof n==`function`&&(t.highlightColor=n(e)),this.setShaderModuleProps({picking:t}),this.setNeedsRedraw()}_getAttributeManager(){let e=this.context;return new gN(e.device,{id:this.props.id,stats:e.stats,timeline:e.timeline})}_postUpdate(e,t){let{props:n,oldProps:r}=e,i=this.state.model;i?.isInstanced&&i.setInstanceCount(this.getNumInstances());let{autoHighlight:a,highlightedObjectIndex:o,highlightColor:s}=n;if(t||r.autoHighlight!==a||r.highlightedObjectIndex!==o||r.highlightColor!==s){let e={};Array.isArray(s)&&(e.highlightColor=s),(t||r.autoHighlight!==a||o!==r.highlightedObjectIndex)&&(e.highlightedObjectColor=Number.isFinite(o)&&o>=0?this.encodePickingColor(o):null),this.setShaderModuleProps({picking:e})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(e){if(!this.internalState)return!1;let t=!1;t||=this.internalState.needsRedraw&&this.id;let n=this.getAttributeManager(),r=n?n.getNeedsRedraw(e):!1;if(t||=r,t)for(let e of this.props.extensions)e.onNeedsRedraw.call(this,e);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!e.clearRedrawFlags,t}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}};xP.defaultProps=bP,xP.layerName=`Layer`;function SP(e){let{blendConstant:t,...n}=e;return t?{pipelineParameters:n,renderPassParameters:{blendConstant:t}}:{pipelineParameters:n}}function CP(e,t,n,r){for(let i of e)i.device.type===`webgpu`?(wP(i,t),i.setParameters({...i.parameters,...r?.pipelineParameters})):i.setParameters(n)}function wP(e,t){let n=t.props.framebuffer||(t.framebuffer??null);if(!n)return;let r=n.colorAttachments.map(e=>e?.texture?.format??null),i=n.depthStencilAttachment?.texture?.format,a=e;(!TP(a.props.colorAttachmentFormats,r)||a.props.depthStencilAttachmentFormat!==i)&&(a.props.colorAttachmentFormats=r,a.props.depthStencilAttachmentFormat=i,a._setPipelineNeedsUpdate(`attachment formats`))}function TP(e,t){if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}var EP=`compositeLayer.renderLayers`,DP=class extends xP{get isComposite(){return!0}get isDrawable(){return!1}get isLoaded(){return super.isLoaded&&this.getSubLayers().every(e=>e.isLoaded)}getSubLayers(){return this.internalState&&this.internalState.subLayers||[]}initializeState(e){}setState(e){super.setState(e),this.setNeedsUpdate()}getPickingInfo({info:e}){let{object:t}=e;return t&&t.__source&&t.__source.parent&&t.__source.parent.id===this.id?(e.object=t.__source.object,e.index=t.__source.index,e):e}filterSubLayer(e){return!0}shouldRenderSubLayer(e,t){return t&&t.length}getSubLayerClass(e,t){let{_subLayerProps:n}=this.props;return n&&n[e]&&n[e].type||t}getSubLayerRow(e,t,n){return e.__source={parent:this,object:t,index:n},e}getSubLayerAccessor(e){if(typeof e==`function`){let t={index:-1,data:this.props.data,target:[]};return(n,r)=>n&&n.__source?(t.index=n.__source.index,e(n.__source.object,t)):e(n,r)}return e}getSubLayerProps(e={}){let{opacity:t,pickable:n,visible:r,parameters:i,getPolygonOffset:a,highlightedObjectIndex:o,autoHighlight:s,highlightColor:c,coordinateSystem:l,coordinateOrigin:u,wrapLongitude:d,positionFormat:f,modelMatrix:p,extensions:m,fetch:h,operation:g,_subLayerProps:_}=this.props,v={id:``,updateTriggers:{},opacity:t,pickable:n,visible:r,parameters:i,getPolygonOffset:a,highlightedObjectIndex:o,autoHighlight:s,highlightColor:c,coordinateSystem:l,coordinateOrigin:u,wrapLongitude:d,positionFormat:f,modelMatrix:p,extensions:m,fetch:h,operation:g},y=_&&e.id&&_[e.id],b=y&&y.updateTriggers,x=e.id||`sublayer`;if(y){let t=this.props[vD],n=e.type?e.type._propTypes:{};for(let e in y){let r=n[e]||t[e];r&&r.type===`accessor`&&(y[e]=this.getSubLayerAccessor(y[e]))}}Object.assign(v,e,y),v.id=`${this.props.id}-${x}`,v.updateTriggers={all:this.props.updateTriggers?.all,...e.updateTriggers,...b};for(let e of m){let t=e.getSubLayerProps.call(this,e);t&&Object.assign(v,t,{updateTriggers:Object.assign(v.updateTriggers,t.updateTriggers)})}return v}_updateAutoHighlight(e){for(let t of this.getSubLayers())t.updateAutoHighlight(e)}_getAttributeManager(){return null}_postUpdate(e,t){let n=this.internalState.subLayers,r=!n||this.needsUpdate();r&&(n=CD(this.renderLayers(),Boolean),this.internalState.subLayers=n),ih(EP,this,r,n);for(let e of n)e.parent=this}};DP.layerName=`CompositeLayer`;var OP=Math.PI/180,kP=180/Math.PI;function AP(e,t=0){let n=Math.min(180,e)*OP;return 256*2*Math.sin(n/2)*2**t}function jP(e,t=0){let n=e/2**t;return Math.asin(Math.min(1,n/256/2))*2*kP}var MP=class extends xO{constructor(e){let{startPanPos:t,...n}=e;n.normalize=!1,super(n),t!==void 0&&(this._state.startPanPos=t)}panStart({pos:e}){let{latitude:t,longitude:n,zoom:r}=this.getViewportProps();return this._getUpdatedState({startPanLngLat:[n,t],startPanPos:e,startZoom:r})}pan({pos:e,startPos:t}){let n=this.getState(),r=n.startPanLngLat||this._unproject(t);if(!r)return this;let i=n.startZoom??this.getViewportProps().zoom,a=n.startPanPos||t,o=[r[0],r[1],i],s=this.makeViewport(this.getViewportProps()).panByPosition(o,e,a);return this._getUpdatedState(s)}panEnd(){return this._getUpdatedState({startPanLngLat:null,startPanPos:null,startZoom:null})}zoom({scale:e}){let t=(this.getState().startZoom||this.getViewportProps().zoom)+Math.log2(e);return this._getUpdatedState({zoom:t})}applyConstraints(e){let{longitude:t,latitude:n,maxBounds:r}=e;if(e.zoom=this._constrainZoom(e.zoom,e),(t<-180||t>180)&&(e.longitude=OT(t+180,360)-180),e.latitude=f_(n,-Sw,Sw),r&&(e.longitude=f_(e.longitude,r[0][0],r[1][0]),e.latitude=f_(e.latitude,r[0][1],r[1][1])),r){let t=e.zoom-iO(n),i=r[1][0]-r[0][0],a=r[1][1]-r[0][1];if(a>0&&a<85.051129*2){let n=Math.min(jP(e.height,t),a)/2;e.latitude=f_(e.latitude,r[0][1]+n,r[1][1]-n)}if(i>0&&i<360){let n=Math.min(jP(e.width/Math.cos(e.latitude*OP),t),i)/2;e.longitude=f_(e.longitude,r[0][0]+n,r[1][0]-n)}}return e.latitude!==n&&(e.zoom+=iO(e.latitude)-iO(n)),e}_constrainZoom(e,t){t||=this.getViewportProps();let{latitude:n,maxZoom:r,maxBounds:i}=t,{minZoom:a}=t,o=iO(0),s=iO(n)-o;if(i!==null&&t.width>0&&t.height>0){let e=i[0][1],n=i[1][1],s=Math.sign(e)===Math.sign(n)?Math.min(Math.abs(e),Math.abs(n)):0,c=AP(i[1][0]-i[0][0])*Math.cos(s*OP),l=AP(i[1][1]-i[0][1]);c>0&&(a=Math.max(a,Math.log2(t.width/c)+o)),l>0&&(a=Math.max(a,Math.log2(t.height/l)+o)),a>r&&(a=r)}return f_(e,a+s,r+s)}},NP=class extends mO{constructor(){super(...arguments),this.ControllerState=MP,this.transition={transitionDuration:300,transitionInterpolator:new cO([`longitude`,`latitude`,`zoom`])},this.dragMode=`pan`}setProps(e){super.setProps(e),this.dragRotate=!1,this.touchRotate=!1}},PP=class extends WD{constructor(e={}){super(e)}getViewportType(e){return e.zoom>12?UT:rO}get ControllerType(){return NP}};PP.displayName=`GlobeView`;var FP=class{static get componentName(){return Object.prototype.hasOwnProperty.call(this,`extensionName`)?this.extensionName:``}constructor(e){e&&(this.opts=e)}equals(e){return this===e?!0:this.constructor===e.constructor&&jD(this.opts,e.opts,1)}getShaders(e){return null}getSubLayerProps(e){let{defaultProps:t}=e.constructor,n={updateTriggers:{}};for(let e in t)if(e in this.props){let r=t[e],i=this.props[e];n[e]=i,r&&r.type===`accessor`&&(n.updateTriggers[e]=this.props.updateTriggers[e],typeof i==`function`&&(n[e]=this.getSubLayerAccessor(i)))}return n}initializeState(e,t){}updateState(e,t){}onNeedsRedraw(e){}getNeedsPickingBuffer(e){return!1}draw(e,t){}finalizeState(e,t){}};FP.defaultProps={},FP.extensionName=`LayerExtension`;var IP=class{constructor(e){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;let{attributes:t={}}=e;this.typedArrayManager=ET,this.attributes={},this._attributeDefs=t,this.opts=e,this.updateGeometry(e)}updateGeometry(e){Object.assign(this.opts,e);let{data:t,buffers:n={},getGeometry:r,geometryBuffer:i,positionFormat:a,dataChanged:o,normalize:s=!0}=this.opts;if(this.data=t,this.getGeometry=r,this.positionSize=i&&i.size||(a===`XY`?2:3),this.buffers=n,this.normalize=s,i&&(ZD(t.startIndices),this.getGeometry=this.getGeometryFromBuffer(i),s||(n.vertexPositions=i)),this.geometryBuffer=n.vertexPositions,Array.isArray(o))for(let e of o)this._rebuildGeometry(e);else this._rebuildGeometry()}updatePartialGeometry({startRow:e,endRow:t}){this._rebuildGeometry({startRow:e,endRow:t})}getGeometryFromBuffer(e){let t=e.value||e;return ArrayBuffer.isView(t)?MM(t,{size:this.positionSize,offset:e.offset,stride:e.stride,startIndices:this.data.startIndices}):null}_allocate(e,t){let{attributes:n,buffers:r,_attributeDefs:i,typedArrayManager:a}=this;for(let o in i)if(o in r)a.release(n[o]),n[o]=null;else{let r=i[o];r.copy=t,n[o]=a.allocate(n[o],e,r)}}_forEachGeometry(e,t,n){let{data:r,getGeometry:i}=this,{iterable:a,objectInfo:o}=AM(r,t,n);for(let t of a)o.index++,e(i?i(t,o):null,o.index)}_rebuildGeometry(e){if(!this.data)return;let{indexStarts:t,vertexStarts:n,instanceCount:r}=this,{data:i,geometryBuffer:a}=this,{startRow:o=0,endRow:s=1/0}=e||{},c={};if(e||(t=[0],n=[0]),this.normalize||!a)this._forEachGeometry((e,t)=>{let r=e&&this.normalizeGeometry(e);c[t]=r,n[t+1]=n[t]+(r?this.getGeometrySize(r):0)},o,s),r=n[n.length-1];else if(n=i.startIndices,r=n[i.length]||0,ArrayBuffer.isView(a))r||=a.length/this.positionSize;else if(a instanceof Sy){let e=this.positionSize*4;r||=a.byteLength/e}else if(a.buffer){let e=a.stride||this.positionSize*4;r||=a.buffer.byteLength/e}else if(a.value){let e=a.value,t=a.stride/e.BYTES_PER_ELEMENT||this.positionSize;r||=e.length/t}this._allocate(r,!!e),this.indexStarts=t,this.vertexStarts=n,this.instanceCount=r;let l={};this._forEachGeometry((e,i)=>{let a=c[i]||e;l.vertexStart=n[i],l.indexStart=t[i],l.geometrySize=(i<n.length-1?n[i+1]:r)-n[i],l.geometryIndex=i,this.updateGeometryAttributes(a,l)},o,s),this.vertexCount=t[t.length-1]}},LP=class{constructor(e){ZD(e.id,`id is required`),this.id=e.id,this.type=`custom`,this.renderingMode=e.renderingMode||`3d`,this.slot=e.slot,this.beforeId=e.beforeId,this.map=null}onAdd(e,t){this.map=e}render(e,t){this.map&&JP(this.map.__deck,this.map,this,t)}},RP=`__UNDEFINED__`;function zP(e){return e.props.beforeId?`deck-layer-group-before:${e.props.beforeId}`:e.props.slot?`deck-layer-group-slot:${e.props.slot}`:`deck-layer-group-last`}function BP(e,t,n){if(!e||!e.style||!e.style._loaded)return;let r=CD(n,Boolean);if(t!==n){let n=CD(t,Boolean),i=new Set(n.map(e=>zP(e))),a=new Set(r.map(e=>zP(e)));for(let t of i)a.has(t)||e.getLayer(t)&&e.removeLayer(t)}let i={};for(let t of r){let n=zP(t),r=e.getLayer(n);if(r)i[n]=r.implementation||r;else{let r=new LP({id:n,slot:t.props.slot,beforeId:t.props.beforeId});i[n]=r,e.addLayer(r,t.props.beforeId)}}let a=e.style._order;for(let[t,n]of Object.entries(i)){let r=n.beforeId||RP,i=r===RP?a.length:a.indexOf(r);if(a.indexOf(t)!==i-1){let n=r===RP?void 0:r;e.moveLayer(t,n)}}}var VP=`mapbox`,HP=512,UP=Math.PI/180;function WP({map:e,deck:t}){if(e.__deck)return e.__deck;let n=t.props._customRender,r=t.props.onLoad,i={...t.props,_customRender:()=>{e.triggerRepaint(),n?.(``)}};return i.views||=XP(e),Object.assign(i,{width:null,height:null,touchAction:`unset`,viewState:ZP(e)}),t.isInitialized?GP(t,e):i.onLoad=()=>{r?.(),GP(t,e)},t.setProps(i),e.__deck=t,e.on(`render`,()=>{t.isInitialized&&eF(t,e)}),t}function GP(e,t){let n=()=>{e.isInitialized?tF(e,t):t.off(`move`,n)};t.on(`move`,n)}function KP(e){e.__deck?.finalize(),e.__deck=null}function qP(e,t){let n=t?{depthWriteEnabled:!0,depthCompare:`less-equal`,depthBias:0,blend:!0,blendColorSrcFactor:`src-alpha`,blendColorDstFactor:`one-minus-src-alpha`,blendAlphaSrcFactor:`one`,blendAlphaDstFactor:`one-minus-src-alpha`,blendColorOperation:`add`,blendAlphaOperation:`add`}:{};return YP(e)===`globe`&&(n.cullMode=`back`),n}function JP(e,t,n,r){if(!e.isInitialized)return;let{currentViewport:i}=e.userData,a=!1;i||(i=$P(e,t,r),e.userData.currentViewport=i,a=!0),i&&e._drawLayers(`mapbox-repaint`,{viewports:[i],layerFilter:t=>{if(e.props.layerFilter&&!e.props.layerFilter(t))return!1;let r=t.layer;return r.props.beforeId===n.beforeId&&r.props.slot===n.slot},clearStack:a,clearCanvas:!1})}function YP(e){let t=e.getProjection?.(),n=t?.type||t?.name;if(n===`globe`)return`globe`;if(n&&n!==`mercator`)throw Error(`Unsupported projection`);return`mercator`}function XP(e){return YP(e)===`globe`?new PP({id:VP}):new CO({id:VP})}function ZP(e){let{lng:t,lat:n}=e.getCenter(),r={longitude:(t+540)%360-180,latitude:n,zoom:e.getZoom(),bearing:e.getBearing(),pitch:e.getPitch(),padding:e.getPadding(),repeat:e.getRenderWorldCopies()};return e.getTerrain?.()&&QP(e,r),r}function QP(e,t){if(e.getFreeCameraOptions){let{position:n}=e.getFreeCameraOptions();if(!n||n.z===void 0)return;let r=e.transform.height,{longitude:i,latitude:a,pitch:o}=t,s=n.x*HP,c=(1-n.y)*HP,l=n.z*HP,u=Tw([i,a]),d=s-u[0],f=c-u[1],p=Math.sqrt(d*d+f*f),m=o*UP,h=1.5*r,g=m<.001?h*Math.cos(m)/l:h*Math.sin(m)/p;t.zoom=Math.log2(g),t.position=[0,0,(l-h*Math.cos(m)/g)/Ow(a)]}else typeof e.transform.elevation==`number`&&(t.position=[0,0,e.transform.elevation])}function $P(e,t,n){let r=ZP(t),i=e.getView(`mapbox`)||XP(t);n&&(i.props.nearZMultiplier=.2);let a=n?.nearZ??t.transform._nearZ,o=n?.farZ??t.transform._farZ;return Number.isFinite(a)&&(r.nearZ=a/t.transform.height,r.farZ=o/t.transform.height),i.makeViewport({width:e.width,height:e.height,viewState:r})}function eF(e,t){let n=CD(e.props.layers,Boolean).some(e=>e&&!t.getLayer(zP(e))),r=e.getViewports(),i=r.findIndex(e=>e.id===VP),a=r.length>1||i<0;if(n||a){if(i>=0){r=r.slice();let n=$P(e,t);n?r[i]=n:r.splice(i,1)}e._drawLayers(`mapbox-repaint`,{viewports:r,layerFilter:n=>(!e.props.layerFilter||e.props.layerFilter(n))&&(n.viewport.id!==`mapbox`||!t.getLayer(zP(n.layer))),clearCanvas:!1})}else{let t=e.device,n=t?.gl;e.props.onBeforeRender?.({device:t,gl:n}),e.props.onAfterRender?.({device:t,gl:n})}e.userData.currentViewport=null}function tF(e,t){e.setProps({viewState:ZP(t)}),e.needsRedraw({clearRedrawFlags:!0})}var nF=class{constructor(e){this._handleStyleChange=()=>{this._resolveLayers(this._map,this._deck,this._props.layers,this._props.layers),this._map&&YP(this._map)&&this._deck?.setProps({views:this._getViews(this._map)})},this._updateContainerSize=()=>{if(this._map&&this._container){let{clientWidth:e,clientHeight:t}=this._map.getContainer();Object.assign(this._container.style,{width:`${e}px`,height:`${t}px`})}},this._updateViewState=()=>{let e=this._deck,t=this._map;e&&t&&(e.setProps({views:this._getViews(t),viewState:ZP(t)}),e.isInitialized&&e.redraw())},this._handleMouseEvent=e=>{let t=this._deck;if(!t||!t.isInitialized)return;let n={type:e.type,offsetCenter:e.point,srcEvent:e},r=this._lastMouseDownPoint;switch(!e.point&&r&&(n.deltaX=e.originalEvent.clientX-r.clientX,n.deltaY=e.originalEvent.clientY-r.clientY,n.offsetCenter={x:r.x+n.deltaX,y:r.y+n.deltaY}),n.type){case`mousedown`:t._onPointerDown(n),this._lastMouseDownPoint={...e.point,clientX:e.originalEvent.clientX,clientY:e.originalEvent.clientY};break;case`dragstart`:n.type=`panstart`,t._onEvent(n);break;case`drag`:n.type=`panmove`,t._onEvent(n);break;case`dragend`:n.type=`panend`,t._onEvent(n);break;case`click`:n.tapCount=1,t._onEvent(n);break;case`dblclick`:n.type=`click`,n.tapCount=2,t._onEvent(n);break;case`mousemove`:n.type=`pointermove`,t._onPointerMove(n);break;case`mouseout`:n.type=`pointerleave`,t._onPointerMove(n);break;default:return}};let{interleaved:t=!1}=e;this._interleaved=t,this._props=this.filterProps(e)}filterProps(e){let{interleaved:t=!1,useDevicePixels:n,...r}=e;return!t&&n!==void 0&&(r.useDevicePixels=n),r}setProps(e){this._interleaved&&e.layers&&this._resolveLayers(this._map,this._deck,this._props.layers,e.layers),Object.assign(this._props,this.filterProps(e)),this._deck&&this._map&&this._deck.setProps({...this._props,views:this._getViews(this._map),parameters:{...qP(this._map,this._interleaved),...this._props.parameters}})}onAdd(e){return this._map=e,this._interleaved?this._onAddInterleaved(e):this._onAddOverlaid(e)}_onAddOverlaid(e){let t=document.createElement(`div`);return Object.assign(t.style,{position:`absolute`,left:0,top:0,textAlign:`initial`,pointerEvents:`none`}),this._container=t,this._deck=new yM({...this._props,parent:t,parameters:{...qP(e,!1),...this._props.parameters},views:this._getViews(e),viewState:ZP(e)}),e.on(`resize`,this._updateContainerSize),e.on(`render`,this._updateViewState),e.on(`mousedown`,this._handleMouseEvent),e.on(`dragstart`,this._handleMouseEvent),e.on(`drag`,this._handleMouseEvent),e.on(`dragend`,this._handleMouseEvent),e.on(`mousemove`,this._handleMouseEvent),e.on(`mouseout`,this._handleMouseEvent),e.on(`click`,this._handleMouseEvent),e.on(`dblclick`,this._handleMouseEvent),this._updateContainerSize(),t}_onAddInterleaved(e){let t=e.painter.context.gl;return t instanceof WebGLRenderingContext&&X.warn(`Incompatible basemap library. See: https://deck.gl/docs/api-reference/mapbox/overview#compatibility`)(),this._deck=WP({map:e,deck:new yM({...this._props,views:this._getViews(e),gl:t,parameters:{...qP(e,!0),...this._props.parameters}})}),e.on(`styledata`,this._handleStyleChange),this._resolveLayers(e,this._deck,[],this._props.layers),document.createElement(`div`)}_resolveLayers(e,t,n,r){BP(e,n,r)}onRemove(){let e=this._map;e&&(this._interleaved?this._onRemoveInterleaved(e):this._onRemoveOverlaid(e)),this._deck=void 0,this._map=void 0,this._container=void 0}_onRemoveOverlaid(e){e.off(`resize`,this._updateContainerSize),e.off(`render`,this._updateViewState),e.off(`mousedown`,this._handleMouseEvent),e.off(`dragstart`,this._handleMouseEvent),e.off(`drag`,this._handleMouseEvent),e.off(`dragend`,this._handleMouseEvent),e.off(`mousemove`,this._handleMouseEvent),e.off(`mouseout`,this._handleMouseEvent),e.off(`click`,this._handleMouseEvent),e.off(`dblclick`,this._handleMouseEvent),this._deck?.finalize()}_onRemoveInterleaved(e){e.off(`styledata`,this._handleStyleChange),this._resolveLayers(e,this._deck,this._props.layers,[]),KP(e)}getDefaultPosition(){return`top-left`}pickObject(e){return ZD(this._deck),this._deck.pickObject(e)}pickMultipleObjects(e){return ZD(this._deck),this._deck.pickMultipleObjects(e)}pickObjects(e){return ZD(this._deck),this._deck.pickObjects(e)}finalize(){this._map&&this._map.removeControl(this)}getCanvas(){return this._map?this._interleaved?this._map.getCanvas():this._deck.getCanvas():null}_getViews(e){if(!this._props.views)return XP(e);let t=Array.isArray(this._props.views)?this._props.views:[this._props.views];return t.some(e=>e.id===`mapbox`)?this._props.views:[XP(e),...t]}},rF=`layout(std140) uniform iconUniforms {
|
|
2167
|
+
}`;function fN(e,t){let n=YM(t.size),r=XM(t.size);return new _D(e,{vs:uN,fs:dN,bufferLayout:[{name:`aPrev`,format:r},{name:`aCur`,format:r},{name:`aTo`,format:t.getBufferLayout().attributes[0].format}],varyings:[`vNext`],modules:[lN],defines:{ATTRIBUTE_TYPE:n},parameters:{depthCompare:`always`,blendColorOperation:`max`,blendColorSrcFactor:`one`,blendColorDstFactor:`one`,blendAlphaOperation:`max`,blendAlphaSrcFactor:`one`,blendAlphaDstFactor:`one`}})}function pN(e){return e.createTexture({data:new Uint8Array(4),format:`rgba8unorm`,width:1,height:1})}function mN(e,t){return e.createFramebuffer({id:`spring-transition-is-transitioning-framebuffer`,width:1,height:1,colorAttachments:[t]})}var hN={interpolation:nN,spring:cN},gN=class{constructor(e,{id:t,timeline:n}){if(!e)throw Error(`AttributeTransitionManager is constructed without device`);this.id=t,this.device=e,this.timeline=n,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(let e in this.transitions)this._removeTransition(e)}update({attributes:e,transitions:t,numInstances:n}){this.numInstances=n||1;for(let n in e){let r=e[n],i=r.getTransitionSetting(t);i&&this._updateAttribute(n,r,i)}for(let n in this.transitions){let r=e[n];(!r||!r.getTransitionSetting(t))&&this._removeTransition(n)}}hasAttribute(e){let t=this.transitions[e];return t&&t.inProgress}getAttributes(){let e={};for(let t in this.transitions){let n=this.transitions[t];n.inProgress&&(e[t]=n.attributeInTransition)}return e}run(){if(this.numInstances===0)return!1;for(let e in this.transitions)this.transitions[e].update()&&(this.needsRedraw=!0);let e=this.needsRedraw;return this.needsRedraw=!1,e}_removeTransition(e){this.transitions[e].delete(),delete this.transitions[e]}_updateAttribute(e,t,n){let r=this.transitions[e],i=!r||r.type!==n.type;if(i){r&&this._removeTransition(e);let a=hN[n.type];a?this.transitions[e]=new a({attribute:t,timeline:this.timeline,device:this.device}):(X.error(`unsupported transition type '${n.type}'`)(),i=!1)}(i||t.needsRedraw())&&(this.needsRedraw=!0,this.transitions[e].start(n,this.numInstances))}},_N=`attributeManager.invalidate`,vN=`attributeManager.updateStart`,yN=`attributeManager.updateEnd`,bN=`attribute.updateStart`,xN=`attribute.allocate`,SN=`attribute.updateEnd`,CN=class{constructor(e,{id:t=`attribute-manager`,stats:n,timeline:r}={}){this.mergeBoundsMemoized=QC(UT),this.id=t,this.device=e,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=n,this.attributeTransitionManager=new gN(e,{id:`${t}-transitions`,timeline:r}),Object.seal(this)}finalize(){for(let e in this.attributes)this.attributes[e].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(e={clearRedrawFlags:!1}){let t=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!e.clearRedrawFlags,t&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(e){this._add(e)}addInstanced(e){this._add(e,{stepMode:`instance`})}remove(e){for(let t of e)this.attributes[t]!==void 0&&(this.attributes[t].delete(),delete this.attributes[t])}invalidate(e,t){let n=this._invalidateTrigger(e,t);dh(_N,this,e,n)}invalidateAll(e){for(let t in this.attributes)this.attributes[t].setNeedsUpdate(t,e);dh(_N,this,`all`)}update({data:e,numInstances:t,startIndices:n=null,transitions:r,props:i={},buffers:a={},context:o={}}){let s=!1;dh(vN,this),this.stats&&this.stats.get(`Update Attributes`).timeStart();for(let r in this.attributes){let c=this.attributes[r],l=c.settings.accessor;c.startIndices=n,c.numInstances=t,i[r]&&X.removed(`props.${r}`,`data.attributes.${r}`)(),c.setExternalBuffer(a[r])||c.setBinaryValue(typeof l==`string`?a[l]:void 0,e.startIndices)||typeof l==`string`&&!a[l]&&c.setConstantValue(o,i[l])||c.needsUpdate()&&(s=!0,this._updateAttribute({attribute:c,numInstances:t,data:e,props:i,context:o})),this.needsRedraw=this.needsRedraw||c.needsRedraw()}s&&dh(yN,this,t),this.stats&&(this.stats.get(`Update Attributes`).timeEnd(),s&&this.stats.get(`Attributes updated`).incrementCount()),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:t,transitions:r})}updateTransition(){let{attributeTransitionManager:e}=this,t=e.run();return this.needsRedraw=this.needsRedraw||t,t}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(e){let t=e.map(e=>this.attributes[e]?.getBounds());return this.mergeBoundsMemoized(t)}getChangedAttributes(e={clearChangedFlags:!1}){let{attributes:t,attributeTransitionManager:n}=this,r={...n.getAttributes()};for(let i in t){let a=t[i];a.needsRedraw(e)&&!n.hasAttribute(i)&&(r[i]=a)}return r}getBufferLayouts(e){return Object.values(this.getAttributes()).map(t=>t.getBufferLayout(e))}_add(e,t){for(let n in e){let r=e[n],i={...r,id:n,size:r.isIndexed&&1||r.size||1,...t};this.attributes[n]=new GM(this.device,i)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){let e={};for(let t in this.attributes)this.attributes[t].getUpdateTriggers().forEach(n=>{e[n]||(e[n]=[]),e[n].push(t)});this.updateTriggers=e}_invalidateTrigger(e,t){let{attributes:n,updateTriggers:r}=this,i=r[e];return i&&i.forEach(e=>{let r=n[e];r&&r.setNeedsUpdate(r.id,t)}),i}_updateAttribute(e){let{attribute:t,numInstances:n}=e;if(dh(bN,t),t.constant){t.setConstantValue(e.context,t.value);return}t.allocate(n)&&dh(xN,t,n),t.updateBuffer(e)&&(this.needsRedraw=!0,dh(SN,t,n))}},wN=class extends QD{get value(){return this._value}_onUpdate(){let{time:e,settings:{fromValue:t,toValue:n,duration:r,easing:i}}=this,a=i(e/r);this._value=b_(t,n,a)}},TN=1e-5;function EN(e,t,n,r,i){let a=t-e;return(n-t)*i+-a*r+a+t}function DN(e,t,n,r,i){if(Array.isArray(n)){let a=[];for(let o=0;o<n.length;o++)a[o]=EN(e[o],t[o],n[o],r,i);return a}return EN(e,t,n,r,i)}function ON(e,t){if(Array.isArray(e)){let n=0;for(let r=0;r<e.length;r++){let i=e[r]-t[r];n+=i*i}return Math.sqrt(n)}return Math.abs(e-t)}var kN={interpolation:wN,spring:class extends QD{get value(){return this._currValue}_onUpdate(){let{fromValue:e,toValue:t,damping:n,stiffness:r}=this.settings,{_prevValue:i=e,_currValue:a=e}=this,o=DN(i,a,t,n,r),s=ON(o,t),c=ON(o,a);s<TN&&c<TN&&(o=t,this.end()),this._prevValue=a,this._currValue=o}}},AN=class{constructor(e){this.transitions=new Map,this.timeline=e}get active(){return this.transitions.size>0}add(e,t,n,r){let{transitions:i}=this;if(i.has(e)){let n=i.get(e),{value:r=n.settings.fromValue}=n;t=r,this.remove(e)}if(r=WM(r),!r)return;let a=kN[r.type];if(!a){X.error(`unsupported transition type '${r.type}'`)();return}let o=new a(this.timeline);o.start({...r,fromValue:t,toValue:n}),i.set(e,o)}remove(e){let{transitions:t}=this;t.has(e)&&(t.get(e).cancel(),t.delete(e))}update(){let e={};for(let[t,n]of this.transitions)n.update(),e[t]=n.value,n.inProgress||this.remove(t);return e}clear(){for(let e of this.transitions.keys())this.remove(e)}};function jN(e){let t=e[TD];for(let n in t){let r=t[n],{validate:i}=r;if(i&&!i(e[n],r))throw Error(`Invalid prop ${n}: ${e[n]}`)}}function MN(e,t){let n=PN({newProps:e,oldProps:t,propTypes:e[TD],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),r=IN(e,t),i=!1;return r||(i=LN(e,t)),{dataChanged:r,propsChanged:n,updateTriggersChanged:i,extensionsChanged:RN(e,t),transitionsChanged:NN(e,t)}}function NN(e,t){if(!e.transitions)return!1;let n={},r=e[TD],i=!1;for(let a in e.transitions){let o=r[a],s=o&&o.type;(s===`number`||s===`color`||s===`array`)&&FN(e[a],t[a],o)&&(n[a]=!0,i=!0)}return i?n:!1}function PN({newProps:e,oldProps:t,ignoreProps:n={},propTypes:r={},triggerName:i=`props`}){if(t===e)return!1;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return`${i} changed shallowly`;for(let a of Object.keys(e))if(!(a in n)){if(!(a in t))return`${i}.${a} added`;let n=FN(e[a],t[a],r[a]);if(n)return`${i}.${a} ${n}`}for(let a of Object.keys(t))if(!(a in n)){if(!(a in e))return`${i}.${a} dropped`;if(!Object.hasOwnProperty.call(e,a)){let n=FN(e[a],t[a],r[a]);if(n)return`${i}.${a} ${n}`}}return!1}function FN(e,t,n){let r=n&&n.equal;return r&&!r(e,t,n)||!r&&(r=e&&t&&e.equals,r&&!r.call(e,t))?`changed deeply`:!r&&t!==e?`changed shallowly`:null}function IN(e,t){if(t===null)return`oldProps is null, initial diff`;let n=!1,{dataComparator:r,_dataDiff:i}=e;return r?r(e.data,t.data)||(n=`Data comparator detected a change`):e.data!==t.data&&(n=`A new data container was supplied`),n&&i&&(n=i(e.data,t.data)||n),n}function LN(e,t){if(t===null||`all`in e.updateTriggers&&zN(e,t,`all`))return{all:!0};let n={},r=!1;for(let i in e.updateTriggers)i!==`all`&&zN(e,t,i)&&(n[i]=!0,r=!0);return r?n:!1}function RN(e,t){if(t===null)return!0;let n=t.extensions,{extensions:r}=e;if(r===n)return!1;if(!n||!r||r.length!==n.length)return!0;for(let e=0;e<r.length;e++)if(!r[e].equals(n[e]))return!0;return!1}function zN(e,t,n){let r=e.updateTriggers[n];r??={};let i=t.updateTriggers[n];return i??={},PN({oldProps:i,newProps:r,triggerName:n})}var BN=`count(): argument not an object`,VN=`count(): argument not a container`;function HN(e){if(!WN(e))throw Error(BN);if(typeof e.count==`function`)return e.count();if(Number.isFinite(e.size))return e.size;if(Number.isFinite(e.length))return e.length;if(UN(e))return Object.keys(e).length;throw Error(VN)}function UN(e){return typeof e==`object`&&!!e&&e.constructor===Object}function WN(e){return typeof e==`object`&&!!e}function GN(e,t){if(!t)return e;let n={...e,...t};if(`defines`in t&&(n.defines={...e.defines,...t.defines}),`modules`in t&&(n.modules=(e.modules||[]).concat(t.modules),t.modules.some(e=>e.name===`project64`))){let e=n.modules.findIndex(e=>e.name===`project32`);e>=0&&n.modules.splice(e,1)}if(`inject`in t)if(!e.inject)n.inject=t.inject;else{let r={...e.inject};for(let e in t.inject)r[e]=(r[e]||``)+t.inject[e];n.inject=r}return n}var KN={minFilter:`linear`,mipmapFilter:`linear`,magFilter:`linear`,addressModeU:`clamp-to-edge`,addressModeV:`clamp-to-edge`},qN={};function JN(e,t,n,r){if(n instanceof Kb)return n;n.constructor&&n.constructor.name!==`Object`&&(n={data:n});let i=null;n.compressed&&(i={minFilter:`linear`,mipmapFilter:n.data.length>1?`nearest`:`linear`});let{width:a,height:o}=n.data,s=t.createTexture({...n,sampler:{...KN,...i,...r},mipLevels:t.getMipLevelCount(a,o)});return t.type===`webgl`?s.generateMipmapsWebGL():t.type===`webgpu`&&t.generateMipmapsWebGPU(s),qN[s.id]=e,s}function YN(e,t){!t||!(t instanceof Kb)||qN[t.id]===e&&(t.delete(),delete qN[t.id])}var XN={boolean:{validate(e,t){return!0},equal(e,t,n){return!!e==!!t}},number:{validate(e,t){return Number.isFinite(e)&&(!(`max`in t)||e<=t.max)&&(!(`min`in t)||e>=t.min)}},color:{validate(e,t){return t.optional&&!e||eP(e)&&(e.length===3||e.length===4)},equal(e,t,n){return RD(e,t,1)}},accessor:{validate(e,t){let n=tP(e);return n===`function`||n===tP(t.value)},equal(e,t,n){return typeof t==`function`?!0:RD(e,t,1)}},array:{validate(e,t){return t.optional&&!e||eP(e)},equal(e,t,n){let{compare:r}=n;return r?RD(e,t,Number.isInteger(r)?r:+!!r):e===t}},object:{equal(e,t,n){if(n.ignore)return!0;let{compare:r}=n;return r?RD(e,t,Number.isInteger(r)?r:+!!r):e===t}},function:{validate(e,t){return t.optional&&!e||typeof e==`function`},equal(e,t,n){return!n.compare&&n.ignore!==!1||e===t}},data:{transform:(e,t,n)=>{if(!e)return e;let{dataTransform:r}=n.props;return r?r(e):typeof e.shape==`string`&&e.shape.endsWith(`-table`)&&Array.isArray(e.data)?e.data:e}},image:{transform:(e,t,n)=>{let r=n.context;return!r||!r.device?null:JN(n.id,r.device,e,{...t.parameters,...n.props.textureParameters})},release:(e,t,n)=>{YN(n.id,e)}}};function ZN(e){let t={},n={},r={};for(let[i,a]of Object.entries(e)){let e=a?.deprecatedFor;if(e)r[i]=Array.isArray(e)?e:[e];else{let e=QN(i,a);t[i]=e,n[i]=e.value}}return{propTypes:t,defaultProps:n,deprecatedProps:r}}function QN(e,t){switch(tP(t)){case`object`:return $N(e,t);case`array`:return $N(e,{type:`array`,value:t,compare:!1});case`boolean`:return $N(e,{type:`boolean`,value:t});case`number`:return $N(e,{type:`number`,value:t});case`function`:return $N(e,{type:`function`,value:t,compare:!0});default:return{name:e,type:`unknown`,value:t}}}function $N(e,t){return`type`in t?{name:e,...XN[t.type],...t}:`value`in t?{name:e,type:tP(t.value),...t}:{name:e,type:`object`,value:t}}function eP(e){return Array.isArray(e)||ArrayBuffer.isView(e)}function tP(e){return eP(e)?`array`:e===null?`null`:typeof e}function nP(e,t){let n;for(let e=t.length-1;e>=0;e--){let r=t[e];`extensions`in r&&(n=r.extensions)}let r=iP(e.constructor,n),i=Object.create(r);i[wD]=e,i[OD]={},i[kD]={};for(let e=0;e<t.length;++e){let n=t[e];for(let e in n)i[e]=n[e]}return Object.freeze(i),i}var rP=`_mergedDefaultProps`;function iP(e,t){if(!(e instanceof mP.constructor))return{};let n=rP;if(t)for(let e of t){let t=e.constructor;t&&(n+=`:${t.extensionName||t.name}`)}return dP(e,n)||(e[n]=aP(e,t||[]))}function aP(e,t){if(!e.prototype)return null;let n=iP(Object.getPrototypeOf(e)),r=ZN(dP(e,`defaultProps`)||{}),i=Object.assign(Object.create(null),n,r.defaultProps),a=Object.assign(Object.create(null),n?.[TD],r.propTypes),o=Object.assign(Object.create(null),n?.[ED],r.deprecatedProps);for(let e of t){let t=iP(e.constructor);t&&(Object.assign(i,t),Object.assign(a,t[TD]),Object.assign(o,t[ED]))}return oP(i,e),cP(i,a),sP(i,o),i[TD]=a,i[ED]=o,t.length===0&&!uP(e,`_propTypes`)&&(e._propTypes=a),i}function oP(e,t){let n=fP(t);Object.defineProperties(e,{id:{writable:!0,value:n}})}function sP(e,t){for(let n in t)Object.defineProperty(e,n,{enumerable:!1,set(e){let r=`${this.id}: ${n}`;for(let r of t[n])uP(this,r)||(this[r]=e);X.deprecated(r,t[n].join(`/`))()}})}function cP(e,t){let n={},r={};for(let e in t){let i=t[e],{name:a,value:o}=i;i.async&&(n[a]=o,r[a]=lP(a))}e[DD]=n,e[OD]={},Object.defineProperties(e,r)}function lP(e){return{enumerable:!0,set(t){typeof t==`string`||t instanceof Promise||RM(t)?this[OD][e]=t:this[kD][e]=t},get(){if(this[kD]){if(e in this[kD])return this[kD][e]||this[DD][e];if(e in this[OD]){let t=this[wD]&&this[wD].internalState;if(t&&t.hasAsyncProp(e))return t.getAsyncProp(e)||this[DD][e]}}return this[DD][e]}}}function uP(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function dP(e,t){return uP(e,t)&&e[t]}function fP(e){let t=e.componentName;return t||X.warn(`${e.name}.componentName not specified`)(),t||e.name}var pP=0,mP=class{constructor(...e){this.props=nP(this,e),this.id=this.props.id,this.count=pP++}clone(e){let{props:t}=this,n={};for(let e in t[DD])e in t[kD]?n[e]=t[kD][e]:e in t[OD]&&(n[e]=t[OD][e]);return new this.constructor({...t,...n,...e})}};mP.componentName=`Component`,mP.defaultProps={};var hP=Object.freeze({}),gP=class{constructor(e){this.component=e,this.asyncProps={},this.onAsyncPropUpdated=()=>{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(let e in this.asyncProps){let t=this.asyncProps[e];t&&t.type&&t.type.release&&t.type.release(t.resolvedValue,t.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||hP}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(e){return e in this.asyncProps}getAsyncProp(e){let t=this.asyncProps[e];return t&&t.resolvedValue}isAsyncPropLoading(e){if(e){let t=this.asyncProps[e];return!!(t&&t.pendingLoadCount>0&&t.pendingLoadCount!==t.resolvedLoadCount)}for(let e in this.asyncProps)if(this.isAsyncPropLoading(e))return!0;return!1}reloadAsyncProp(e,t){this._watchPromise(e,Promise.resolve(t))}setAsyncProps(e){this.component=e[wD]||this.component;let t=e[kD]||{},n=e[OD]||e,r=e[DD]||{};for(let e in t){let n=t[e];this._createAsyncPropData(e,r[e]),this._updateAsyncProp(e,n),t[e]=this.getAsyncProp(e)}for(let e in n){let t=n[e];this._createAsyncPropData(e,r[e]),this._updateAsyncProp(e,t)}}_fetch(e,t){return null}_onResolve(e,t){}_onError(e,t){}_updateAsyncProp(e,t){if(this._didAsyncInputValueChange(e,t)){if(typeof t==`string`&&(t=this._fetch(e,t)),t instanceof Promise){this._watchPromise(e,t);return}if(RM(t)){this._resolveAsyncIterable(e,t);return}this._setPropValue(e,t)}}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(let e in this.asyncProps)Object.defineProperty(this.oldAsyncProps,e,{enumerable:!0,value:this.oldProps[e]})}}_didAsyncInputValueChange(e,t){let n=this.asyncProps[e];return t===n.resolvedValue||t===n.lastValue?!1:(n.lastValue=t,!0)}_setPropValue(e,t){this._freezeAsyncOldProps();let n=this.asyncProps[e];n&&(t=this._postProcessValue(n,t),n.resolvedValue=t,n.pendingLoadCount++,n.resolvedLoadCount=n.pendingLoadCount)}_setAsyncPropValue(e,t,n){let r=this.asyncProps[e];r&&n>=r.resolvedLoadCount&&t!==void 0&&(this._freezeAsyncOldProps(),r.resolvedValue=t,r.resolvedLoadCount=n,this.onAsyncPropUpdated(e,t))}_watchPromise(e,t){let n=this.asyncProps[e];if(n){n.pendingLoadCount++;let r=n.pendingLoadCount;t.then(t=>{this.component&&(t=this._postProcessValue(n,t),this._setAsyncPropValue(e,t,r),this._onResolve(e,t))}).catch(t=>{this._onError(e,t)})}}async _resolveAsyncIterable(e,t){if(e!==`data`){this._setPropValue(e,t);return}let n=this.asyncProps[e];if(!n)return;n.pendingLoadCount++;let r=n.pendingLoadCount,i=[],a=0;for await(let n of t){if(!this.component)return;let{dataTransform:t}=this.component.props;i=t?t(n,i):i.concat(n),Object.defineProperty(i,"__diff",{enumerable:!1,value:[{startRow:a,endRow:i.length}]}),a=i.length,this._setAsyncPropValue(e,i,r)}this._onResolve(e,i)}_postProcessValue(e,t){let n=e.type;return n&&this.component&&(n.release&&n.release(e.resolvedValue,n,this.component),n.transform)?n.transform(t,n,this.component):t}_createAsyncPropData(e,t){if(!this.asyncProps[e]){let n=this.component&&this.component.props[TD];this.asyncProps[e]={type:n&&n[e],lastValue:null,resolvedValue:t,pendingLoadCount:0,resolvedLoadCount:0}}}},_P=class extends gP{constructor({attributeManager:e,layer:t}){super(t),this.attributeManager=e,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1}get layer(){return this.component}_fetch(e,t){let n=this.layer,r=n?.props.fetch;return r?r(t,{propName:e,layer:n}):super._fetch(e,t)}_onResolve(e,t){let n=this.layer;if(n){let r=n.props.onDataLoad;e===`data`&&r&&r(t,{propName:e,layer:n})}}_onError(e,t){let n=this.layer;n&&n.raiseError(t,`loading ${e} of ${this.layer}`)}},vP=`layer.changeFlag`,yP=`layer.initialize`,bP=`layer.update`,xP=`layer.finalize`,SP=`layer.matched`,CP=2**24-1,wP=Object.freeze([]),TP=QC(({oldViewport:e,viewport:t})=>e.equals(t)),EP=new Uint8ClampedArray,DP={data:{type:`data`,value:wP,async:!0},dataComparator:{type:`function`,value:null,optional:!0},_dataDiff:{type:`function`,value:e=>e&&e.__diff,optional:!0},dataTransform:{type:`function`,value:null,optional:!0},onDataLoad:{type:`function`,value:null,optional:!0},onError:{type:`function`,value:null,optional:!0},fetch:{type:`function`,value:(e,{propName:t,layer:n,loaders:r,loadOptions:i,signal:a})=>{let{resourceManager:o}=n.context;i||=n.getLoadOptions(),r||=n.props.loaders,a&&(i={...i,core:{...i?.core,fetch:{...i?.core?.fetch,signal:a}}});let s=o.contains(e);return!s&&!i&&(o.add({resourceId:e,data:Sm(e,r),persistent:!1}),s=!0),s?o.subscribe({resourceId:e,onChange:e=>n.internalState?.reloadAsyncProp(t,e),consumerId:n.id,requestId:t}):Sm(e,r,i)}},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:`number`,min:0,max:1,value:1},operation:`draw`,onHover:{type:`function`,value:null,optional:!0},onClick:{type:`function`,value:null,optional:!0},onDragStart:{type:`function`,value:null,optional:!0},onDrag:{type:`function`,value:null,optional:!0},onDragEnd:{type:`function`,value:null,optional:!0},coordinateSystem:`default`,coordinateOrigin:{type:`array`,value:[0,0,0],compare:!0},modelMatrix:{type:`array`,value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:`XYZ`,colorFormat:`RGBA`,parameters:{type:`object`,value:{},optional:!0,compare:2},loadOptions:{type:`object`,value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:`array`,value:[],optional:!0,ignore:!0},getPolygonOffset:{type:`function`,value:({layerIndex:e})=>[0,-e*100]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:`accessor`,value:[0,0,128,128]}},OP=class extends mP{constructor(){super(...arguments),this.internalState=null,this.lifecycle=CD.NO_STATE,this.parent=null}static get componentName(){return Object.prototype.hasOwnProperty.call(this,`layerName`)?this.layerName:``}get root(){let e=this;for(;e.parent;)e=e.parent;return e}toString(){return`${this.constructor.layerName||this.constructor.name}({id: '${this.props.id}'})`}project(e){iO(this.internalState);let t=this.internalState.viewport||this.context.viewport,[n,r,i]=Hw(eE(e,{viewport:t,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),t.pixelProjectionMatrix);return e.length===2?[n,r]:[n,r,i]}unproject(e){return iO(this.internalState),(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,t){return iO(this.internalState),tE(e,{viewport:this.internalState.viewport||this.context.viewport,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...t})}get isComposite(){return!1}get isDrawable(){return!0}setState(e){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,e),this.setNeedsRedraw()}setNeedsRedraw(){this.internalState&&(this.internalState.needsRedraw=!0)}setNeedsUpdate(){this.internalState&&(this.context.layerManager.setNeedsUpdate(String(this)),this.internalState.needsUpdate=!0)}get isLoaded(){return this.internalState?!this.internalState.isAsyncPropLoading():!1}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){let e=this.state;return e&&(e.models||e.model&&[e.model])||[]}setShaderModuleProps(...e){for(let t of this.getModels())t.shaderInputs.setProps(...e)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){let{coordinateSystem:e}=this.props;return e===`default`||e===`lnglat`||e===`cartesian`}onHover(e,t){return this.props.onHover&&this.props.onHover(e,t)||!1}onClick(e,t){return this.props.onClick&&this.props.onClick(e,t)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(e,t=[]){return t[0]=e+1&255,t[1]=e+1>>8&255,t[2]=e+1>>8>>8&255,t}decodePickingColor(e){iO(e instanceof Uint8Array);let[t,n,r]=e;return t+n*256+r*65536-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&this.state.numInstances!==void 0?this.state.numInstances:HN(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){return this.getAttributeManager()?.getBounds([`positions`,`instancePositions`])}getShaders(e){e=GN(e,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(let t of this.props.extensions)e=GN(e,t.getShaders.call(this,t));return e}shouldUpdateState(e){return e.changeFlags.propsOrDataChanged}updateState(e){let t=this.getAttributeManager(),{dataChanged:n}=e.changeFlags;if(n&&t)if(Array.isArray(n))for(let e of n)t.invalidateAll(e);else t.invalidateAll();if(t){let{props:n}=e,r=this.internalState.hasPickingBuffer,i=Number.isInteger(n.highlightedObjectIndex)||!!n.pickable||n.extensions.some(e=>e.getNeedsPickingBuffer.call(this,e));if(r!==i){this.internalState.hasPickingBuffer=i;let{pickingColors:e,instancePickingColors:n}=t.attributes,r=e||n;r&&(i&&r.constant&&(r.constant=!1,t.invalidate(r.id)),!r.value&&!i&&(r.constant=!0,r.value=[0,0,0]))}}}finalizeState(e){for(let e of this.getModels())e.destroy();let t=this.getAttributeManager();t&&t.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(e){for(let t of this.getModels())t.draw(e.renderPass)}getPickingInfo({info:e,mode:t,sourceLayer:n}){let{index:r}=e;return r>=0&&Array.isArray(this.props.data)&&(e.object=this.props.data[r]),e}raiseError(e,t){t&&(e=Error(`${t}: ${e.message}`,{cause:e})),this.props.onError?.(e)||this.context?.onError?.(e,this)}getNeedsRedraw(e={clearRedrawFlags:!1}){return this._getNeedsRedraw(e)}needsUpdate(){return this.internalState?this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()):!1}hasUniformTransition(){return this.internalState?.uniformTransitions.active||!1}activateViewport(e){if(!this.internalState)return;let t=this.internalState.viewport;this.internalState.viewport=e,(!t||!TP({oldViewport:t,viewport:e}))&&(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(e=`all`){let t=this.getAttributeManager();t&&(e===`all`?t.invalidateAll():t.invalidate(e))}updateAttributes(e){let t=!1;for(let n in e)e[n].layoutChanged()&&(t=!0);for(let n of this.getModels())this._setModelAttributes(n,e,t)}_updateAttributes(){let e=this.getAttributeManager();if(!e)return;let t=this.props,n=this.getNumInstances(),r=this.getStartIndices();e.update({data:t.data,numInstances:n,startIndices:r,props:t,transitions:t.transitions,buffers:t.data.attributes,context:this});let i=e.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(i)}_updateAttributeTransition(){let e=this.getAttributeManager();e&&e.updateTransition()}_updateUniformTransition(){let{uniformTransitions:e}=this.internalState;if(e.active){let t=e.update(),n=Object.create(this.props);for(let e in t)Object.defineProperty(n,e,{value:t[e]});return n}return this.props}calculateInstancePickingColors(e,{numInstances:t}){if(e.constant)return;let n=Math.floor(EP.length/4);if(this.internalState.usesPickingColorCache=!0,n<t){t>CP&&X.warn(`Layer has too many data objects. Picking might not be able to distinguish all objects.`)(),EP=NT.allocate(EP,t,{size:4,copy:!0,maxCount:Math.max(t,CP)});let e=Math.floor(EP.length/4),r=[0,0,0];for(let t=n;t<e;t++)this.encodePickingColor(t,r),EP[t*4+0]=r[0],EP[t*4+1]=r[1],EP[t*4+2]=r[2],EP[t*4+3]=0}e.value=EP.subarray(0,t*4)}_setModelAttributes(e,t,n=!1){if(!Object.keys(t).length)return;if(n){let n=this.getAttributeManager();e.setBufferLayout(n.getBufferLayouts(e)),t=n.getAttributes()}let r=e.userData?.excludeAttributes||{},i={},a={};for(let n in t){if(r[n])continue;let o=t[n].getValue();for(let r in o){let s=o[r];s instanceof ky?t[n].settings.isIndexed?e.setIndexBuffer(s):i[r]=s:s&&(a[r]=s)}}e.setAttributes(i),e.setConstantAttributes(a)}disablePickingIndex(e){let t=this.props.data;if(!(`attributes`in t)){this._disablePickingIndex(e);return}let{pickingColors:n,instancePickingColors:r}=this.getAttributeManager().attributes,i=n||r,a=i&&t.attributes&&t.attributes[i.id];if(a&&a.value){let n=a.value,r=this.encodePickingColor(e);for(let e=0;e<t.length;e++){let t=i.getVertexOffset(e);n[t]===r[0]&&n[t+1]===r[1]&&n[t+2]===r[2]&&this._disablePickingIndex(e)}}else this._disablePickingIndex(e)}_disablePickingIndex(e){let{pickingColors:t,instancePickingColors:n}=this.getAttributeManager().attributes,r=t||n;if(!r)return;let i=r.getVertexOffset(e),a=r.getVertexOffset(e+1);r.buffer.write(new Uint8Array(a-i),i)}restorePickingColors(){let{pickingColors:e,instancePickingColors:t}=this.getAttributeManager().attributes,n=e||t;n&&(this.internalState.usesPickingColorCache&&n.value.buffer!==EP.buffer&&(n.value=EP.subarray(0,n.value.length)),n.updateSubBuffer({startOffset:0}))}_initialize(){iO(!this.internalState),dh(yP,this);let e=this._getAttributeManager();e&&e.addInstanced({instancePickingColors:{type:`uint8`,size:4,noAlloc:!0,update:this.calculateInstancePickingColors}}),this.internalState=new _P({attributeManager:e,layer:this}),this._clearChangeFlags(),this.state={},Object.defineProperty(this.state,"attributeManager",{get:()=>(X.deprecated(`layer.state.attributeManager`,`layer.getAttributeManager()`)(),e)}),this.internalState.uniformTransitions=new AN(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(let e of this.props.extensions)e.initializeState.call(this,this.context,e);this.setChangeFlags({dataChanged:`init`,propsChanged:`init`,viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(e){dh(SP,this,this===e);let{state:t,internalState:n}=e;this!==e&&(this.internalState=n,this.state=t,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){let e=this.needsUpdate();if(dh(bP,this,e),!e)return;this.context.stats.get(`Layer updates`).incrementCount();let t=this.props,n=this.context,r=this.internalState,i=n.viewport,a=this._updateUniformTransition();r.propsInTransition=a,n.viewport=r.viewport||i,this.props=a;try{let e=this._getUpdateParams(),t=this.getModels();if(n.device)this.updateState(e);else try{this.updateState(e)}catch{}for(let t of this.props.extensions)t.updateState.call(this,e,t);this.setNeedsRedraw(),this._updateAttributes();let r=this.getModels()[0]!==t[0];this._postUpdate(e,r)}finally{n.viewport=i,this.props=t,this._clearChangeFlags(),r.needsUpdate=!1,r.resetOldProps()}}_finalize(){dh(xP,this),this.finalizeState(this.context);for(let e of this.props.extensions)e.finalizeState.call(this,this.context,e)}_drawLayer({renderPass:e,shaderModuleProps:t=null,uniforms:n={},parameters:r={}}){this._updateAttributeTransition();let i=this.props,a=this.context;this.props=this.internalState.propsInTransition||i;try{t&&this.setShaderModuleProps(t);let{getPolygonOffset:i}=this.props,o=i&&i(n)||[0,0];a.device instanceof yM&&a.device.setParametersWebGL({polygonOffset:o});let s=a.device instanceof yM?null:kP(r);if(AP(this.getModels(),e,r,s),a.device instanceof yM)a.device.withParametersWebGL(r,()=>{let i={renderPass:e,shaderModuleProps:t,uniforms:n,parameters:r,context:a};for(let e of this.props.extensions)e.draw.call(this,i,e);this.draw(i)});else{s?.renderPassParameters&&e.setParameters(s.renderPassParameters);let i={renderPass:e,shaderModuleProps:t,uniforms:n,parameters:r,context:a};for(let e of this.props.extensions)e.draw.call(this,i,e);this.draw(i)}}finally{this.props=i}}getChangeFlags(){return this.internalState?.changeFlags}setChangeFlags(e){if(!this.internalState)return;let{changeFlags:t}=this.internalState;for(let n in e)if(e[n]){let r=!1;switch(n){case`dataChanged`:let i=e[n],a=t[n];i&&Array.isArray(a)&&(t.dataChanged=Array.isArray(i)?a.concat(i):i,r=!0);default:t[n]||(t[n]=e[n],r=!0)}r&&dh(vP,this,n,e)}let n=!!(t.dataChanged||t.updateTriggersChanged||t.propsChanged||t.extensionsChanged);t.propsOrDataChanged=n,t.somethingChanged=n||t.viewportChanged||t.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(e,t){let n=MN(e,t);if(n.updateTriggersChanged)for(let e in n.updateTriggersChanged)n.updateTriggersChanged[e]&&this.invalidateAttribute(e);if(n.transitionsChanged)for(let r in n.transitionsChanged)this.internalState.uniformTransitions.add(r,t[r],e[r],e.transitions?.[r]);return this.setChangeFlags(n)}validateProps(){jN(this.props)}updateAutoHighlight(e){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(e)}_updateAutoHighlight(e){let t={highlightedObjectColor:e.picked?e.color:null},{highlightColor:n}=this.props;e.picked&&typeof n==`function`&&(t.highlightColor=n(e)),this.setShaderModuleProps({picking:t}),this.setNeedsRedraw()}_getAttributeManager(){let e=this.context;return new CN(e.device,{id:this.props.id,stats:e.stats,timeline:e.timeline})}_postUpdate(e,t){let{props:n,oldProps:r}=e,i=this.state.model;i?.isInstanced&&i.setInstanceCount(this.getNumInstances());let{autoHighlight:a,highlightedObjectIndex:o,highlightColor:s}=n;if(t||r.autoHighlight!==a||r.highlightedObjectIndex!==o||r.highlightColor!==s){let e={};Array.isArray(s)&&(e.highlightColor=s),(t||r.autoHighlight!==a||o!==r.highlightedObjectIndex)&&(e.highlightedObjectColor=Number.isFinite(o)&&o>=0?this.encodePickingColor(o):null),this.setShaderModuleProps({picking:e})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(e){if(!this.internalState)return!1;let t=!1;t||=this.internalState.needsRedraw&&this.id;let n=this.getAttributeManager(),r=n?n.getNeedsRedraw(e):!1;if(t||=r,t)for(let e of this.props.extensions)e.onNeedsRedraw.call(this,e);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!e.clearRedrawFlags,t}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}};OP.defaultProps=DP,OP.layerName=`Layer`;function kP(e){let{blendConstant:t,...n}=e;return t?{pipelineParameters:n,renderPassParameters:{blendConstant:t}}:{pipelineParameters:n}}function AP(e,t,n,r){for(let i of e)i.device.type===`webgpu`?(jP(i,t),i.setParameters({...i.parameters,...r?.pipelineParameters})):i.setParameters(n)}function jP(e,t){let n=t.props.framebuffer||(t.framebuffer??null);if(!n)return;let r=n.colorAttachments.map(e=>e?.texture?.format??null),i=n.depthStencilAttachment?.texture?.format,a=e;(!MP(a.props.colorAttachmentFormats,r)||a.props.depthStencilAttachmentFormat!==i)&&(a.props.colorAttachmentFormats=r,a.props.depthStencilAttachmentFormat=i,a._setPipelineNeedsUpdate(`attachment formats`))}function MP(e,t){if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}var NP=`compositeLayer.renderLayers`,PP=class extends OP{get isComposite(){return!0}get isDrawable(){return!1}get isLoaded(){return super.isLoaded&&this.getSubLayers().every(e=>e.isLoaded)}getSubLayers(){return this.internalState&&this.internalState.subLayers||[]}initializeState(e){}setState(e){super.setState(e),this.setNeedsUpdate()}getPickingInfo({info:e}){let{object:t}=e;return t&&t.__source&&t.__source.parent&&t.__source.parent.id===this.id?(e.object=t.__source.object,e.index=t.__source.index,e):e}filterSubLayer(e){return!0}shouldRenderSubLayer(e,t){return t&&t.length}getSubLayerClass(e,t){let{_subLayerProps:n}=this.props;return n&&n[e]&&n[e].type||t}getSubLayerRow(e,t,n){return e.__source={parent:this,object:t,index:n},e}getSubLayerAccessor(e){if(typeof e==`function`){let t={index:-1,data:this.props.data,target:[]};return(n,r)=>n&&n.__source?(t.index=n.__source.index,e(n.__source.object,t)):e(n,r)}return e}getSubLayerProps(e={}){let{opacity:t,pickable:n,visible:r,parameters:i,getPolygonOffset:a,highlightedObjectIndex:o,autoHighlight:s,highlightColor:c,coordinateSystem:l,coordinateOrigin:u,wrapLongitude:d,positionFormat:f,modelMatrix:p,extensions:m,fetch:h,operation:g,_subLayerProps:_}=this.props,v={id:``,updateTriggers:{},opacity:t,pickable:n,visible:r,parameters:i,getPolygonOffset:a,highlightedObjectIndex:o,autoHighlight:s,highlightColor:c,coordinateSystem:l,coordinateOrigin:u,wrapLongitude:d,positionFormat:f,modelMatrix:p,extensions:m,fetch:h,operation:g},y=_&&e.id&&_[e.id],b=y&&y.updateTriggers,x=e.id||`sublayer`;if(y){let t=this.props[TD],n=e.type?e.type._propTypes:{};for(let e in y){let r=n[e]||t[e];r&&r.type===`accessor`&&(y[e]=this.getSubLayerAccessor(y[e]))}}Object.assign(v,e,y),v.id=`${this.props.id}-${x}`,v.updateTriggers={all:this.props.updateTriggers?.all,...e.updateTriggers,...b};for(let e of m){let t=e.getSubLayerProps.call(this,e);t&&Object.assign(v,t,{updateTriggers:Object.assign(v.updateTriggers,t.updateTriggers)})}return v}_updateAutoHighlight(e){for(let t of this.getSubLayers())t.updateAutoHighlight(e)}_getAttributeManager(){return null}_postUpdate(e,t){let n=this.internalState.subLayers,r=!n||this.needsUpdate();r&&(n=AD(this.renderLayers(),Boolean),this.internalState.subLayers=n),dh(NP,this,r,n);for(let e of n)e.parent=this}};PP.layerName=`CompositeLayer`;var FP=Math.PI/180,IP=180/Math.PI;function LP(e,t=0){let n=Math.min(180,e)*FP;return 256*2*Math.sin(n/2)*2**t}function RP(e,t=0){let n=e/2**t;return Math.asin(Math.min(1,n/256/2))*2*IP}var zP=class extends OO{constructor(e){let{startPanPos:t,...n}=e;n.normalize=!1,super(n),t!==void 0&&(this._state.startPanPos=t)}panStart({pos:e}){let{latitude:t,longitude:n,zoom:r}=this.getViewportProps();return this._getUpdatedState({startPanLngLat:[n,t],startPanPos:e,startZoom:r})}pan({pos:e,startPos:t}){let n=this.getState(),r=n.startPanLngLat||this._unproject(t);if(!r)return this;let i=n.startZoom??this.getViewportProps().zoom,a=n.startPanPos||t,o=[r[0],r[1],i],s=this.makeViewport(this.getViewportProps()).panByPosition(o,e,a);return this._getUpdatedState(s)}panEnd(){return this._getUpdatedState({startPanLngLat:null,startPanPos:null,startZoom:null})}zoom({scale:e}){let t=(this.getState().startZoom||this.getViewportProps().zoom)+Math.log2(e);return this._getUpdatedState({zoom:t})}applyConstraints(e){let{longitude:t,latitude:n,maxBounds:r}=e;if(e.zoom=this._constrainZoom(e.zoom,e),(t<-180||t>180)&&(e.longitude=FT(t+180,360)-180),e.latitude=y_(n,-kw,kw),r&&(e.longitude=y_(e.longitude,r[0][0],r[1][0]),e.latitude=y_(e.latitude,r[0][1],r[1][1])),r){let t=e.zoom-dO(n),i=r[1][0]-r[0][0],a=r[1][1]-r[0][1];if(a>0&&a<85.051129*2){let n=Math.min(RP(e.height,t),a)/2;e.latitude=y_(e.latitude,r[0][1]+n,r[1][1]-n)}if(i>0&&i<360){let n=Math.min(RP(e.width/Math.cos(e.latitude*FP),t),i)/2;e.longitude=y_(e.longitude,r[0][0]+n,r[1][0]-n)}}return e.latitude!==n&&(e.zoom+=dO(e.latitude)-dO(n)),e}_constrainZoom(e,t){t||=this.getViewportProps();let{latitude:n,maxZoom:r,maxBounds:i}=t,{minZoom:a}=t,o=dO(0),s=dO(n)-o;if(i!==null&&t.width>0&&t.height>0){let e=i[0][1],n=i[1][1],s=Math.sign(e)===Math.sign(n)?Math.min(Math.abs(e),Math.abs(n)):0,c=LP(i[1][0]-i[0][0])*Math.cos(s*FP),l=LP(i[1][1]-i[0][1]);c>0&&(a=Math.max(a,Math.log2(t.width/c)+o)),l>0&&(a=Math.max(a,Math.log2(t.height/l)+o)),a>r&&(a=r)}return y_(e,a+s,r+s)}},BP=class extends xO{constructor(){super(...arguments),this.ControllerState=zP,this.transition={transitionDuration:300,transitionInterpolator:new hO([`longitude`,`latitude`,`zoom`])},this.dragMode=`pan`}setProps(e){super.setProps(e),this.dragRotate=!1,this.touchRotate=!1}},VP=class extends ZD{constructor(e={}){super(e)}getViewportType(e){return e.zoom>12?XT:uO}get ControllerType(){return BP}};VP.displayName=`GlobeView`;var HP=class{static get componentName(){return Object.prototype.hasOwnProperty.call(this,`extensionName`)?this.extensionName:``}constructor(e){e&&(this.opts=e)}equals(e){return this===e?!0:this.constructor===e.constructor&&RD(this.opts,e.opts,1)}getShaders(e){return null}getSubLayerProps(e){let{defaultProps:t}=e.constructor,n={updateTriggers:{}};for(let e in t)if(e in this.props){let r=t[e],i=this.props[e];n[e]=i,r&&r.type===`accessor`&&(n.updateTriggers[e]=this.props.updateTriggers[e],typeof i==`function`&&(n[e]=this.getSubLayerAccessor(i)))}return n}initializeState(e,t){}updateState(e,t){}onNeedsRedraw(e){}getNeedsPickingBuffer(e){return!1}draw(e,t){}finalizeState(e,t){}};HP.defaultProps={},HP.extensionName=`LayerExtension`;var UP=class{constructor(e){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;let{attributes:t={}}=e;this.typedArrayManager=NT,this.attributes={},this._attributeDefs=t,this.opts=e,this.updateGeometry(e)}updateGeometry(e){Object.assign(this.opts,e);let{data:t,buffers:n={},getGeometry:r,geometryBuffer:i,positionFormat:a,dataChanged:o,normalize:s=!0}=this.opts;if(this.data=t,this.getGeometry=r,this.positionSize=i&&i.size||(a===`XY`?2:3),this.buffers=n,this.normalize=s,i&&(iO(t.startIndices),this.getGeometry=this.getGeometryFromBuffer(i),s||(n.vertexPositions=i)),this.geometryBuffer=n.vertexPositions,Array.isArray(o))for(let e of o)this._rebuildGeometry(e);else this._rebuildGeometry()}updatePartialGeometry({startRow:e,endRow:t}){this._rebuildGeometry({startRow:e,endRow:t})}getGeometryFromBuffer(e){let t=e.value||e;return ArrayBuffer.isView(t)?zM(t,{size:this.positionSize,offset:e.offset,stride:e.stride,startIndices:this.data.startIndices}):null}_allocate(e,t){let{attributes:n,buffers:r,_attributeDefs:i,typedArrayManager:a}=this;for(let o in i)if(o in r)a.release(n[o]),n[o]=null;else{let r=i[o];r.copy=t,n[o]=a.allocate(n[o],e,r)}}_forEachGeometry(e,t,n){let{data:r,getGeometry:i}=this,{iterable:a,objectInfo:o}=LM(r,t,n);for(let t of a)o.index++,e(i?i(t,o):null,o.index)}_rebuildGeometry(e){if(!this.data)return;let{indexStarts:t,vertexStarts:n,instanceCount:r}=this,{data:i,geometryBuffer:a}=this,{startRow:o=0,endRow:s=1/0}=e||{},c={};if(e||(t=[0],n=[0]),this.normalize||!a)this._forEachGeometry((e,t)=>{let r=e&&this.normalizeGeometry(e);c[t]=r,n[t+1]=n[t]+(r?this.getGeometrySize(r):0)},o,s),r=n[n.length-1];else if(n=i.startIndices,r=n[i.length]||0,ArrayBuffer.isView(a))r||=a.length/this.positionSize;else if(a instanceof ky){let e=this.positionSize*4;r||=a.byteLength/e}else if(a.buffer){let e=a.stride||this.positionSize*4;r||=a.buffer.byteLength/e}else if(a.value){let e=a.value,t=a.stride/e.BYTES_PER_ELEMENT||this.positionSize;r||=e.length/t}this._allocate(r,!!e),this.indexStarts=t,this.vertexStarts=n,this.instanceCount=r;let l={};this._forEachGeometry((e,i)=>{let a=c[i]||e;l.vertexStart=n[i],l.indexStart=t[i],l.geometrySize=(i<n.length-1?n[i+1]:r)-n[i],l.geometryIndex=i,this.updateGeometryAttributes(a,l)},o,s),this.vertexCount=t[t.length-1]}},WP=class{constructor(e){iO(e.id,`id is required`),this.id=e.id,this.type=`custom`,this.renderingMode=e.renderingMode||`3d`,this.slot=e.slot,this.beforeId=e.beforeId,this.map=null}onAdd(e,t){this.map=e}render(e,t){this.map&&tF(this.map.__deck,this.map,this,t)}},GP=`__UNDEFINED__`;function KP(e){return e.props.beforeId?`deck-layer-group-before:${e.props.beforeId}`:e.props.slot?`deck-layer-group-slot:${e.props.slot}`:`deck-layer-group-last`}function qP(e,t,n){if(!e||!e.style||!e.style._loaded)return;let r=AD(n,Boolean);if(t!==n){let n=AD(t,Boolean),i=new Set(n.map(e=>KP(e))),a=new Set(r.map(e=>KP(e)));for(let t of i)a.has(t)||e.getLayer(t)&&e.removeLayer(t)}let i={};for(let t of r){let n=KP(t),r=e.getLayer(n);if(r)i[n]=r.implementation||r;else{let r=new WP({id:n,slot:t.props.slot,beforeId:t.props.beforeId});i[n]=r,e.addLayer(r,t.props.beforeId)}}let a=e.style._order;for(let[t,n]of Object.entries(i)){let r=n.beforeId||GP,i=r===GP?a.length:a.indexOf(r);if(a.indexOf(t)!==i-1){let n=r===GP?void 0:r;e.moveLayer(t,n)}}}var JP=`mapbox`,YP=512,XP=Math.PI/180;function ZP({map:e,deck:t}){if(e.__deck)return e.__deck;let n=t.props._customRender,r=t.props.onLoad,i={...t.props,_customRender:()=>{e.triggerRepaint(),n?.(``)}};return i.views||=rF(e),Object.assign(i,{width:null,height:null,touchAction:`unset`,viewState:iF(e)}),t.isInitialized?QP(t,e):i.onLoad=()=>{r?.(),QP(t,e)},t.setProps(i),e.__deck=t,e.on(`render`,()=>{t.isInitialized&&sF(t,e)}),t}function QP(e,t){let n=()=>{e.isInitialized?cF(e,t):t.off(`move`,n)};t.on(`move`,n)}function $P(e){e.__deck?.finalize(),e.__deck=null}function eF(e,t){let n=t?{depthWriteEnabled:!0,depthCompare:`less-equal`,depthBias:0,blend:!0,blendColorSrcFactor:`src-alpha`,blendColorDstFactor:`one-minus-src-alpha`,blendAlphaSrcFactor:`one`,blendAlphaDstFactor:`one-minus-src-alpha`,blendColorOperation:`add`,blendAlphaOperation:`add`}:{};return nF(e)===`globe`&&(n.cullMode=`back`),n}function tF(e,t,n,r){if(!e.isInitialized)return;let{currentViewport:i}=e.userData,a=!1;i||(i=oF(e,t,r),e.userData.currentViewport=i,a=!0),i&&e._drawLayers(`mapbox-repaint`,{viewports:[i],layerFilter:t=>{if(e.props.layerFilter&&!e.props.layerFilter(t))return!1;let r=t.layer;return r.props.beforeId===n.beforeId&&r.props.slot===n.slot},clearStack:a,clearCanvas:!1})}function nF(e){let t=e.getProjection?.(),n=t?.type||t?.name;if(n===`globe`)return`globe`;if(n&&n!==`mercator`)throw Error(`Unsupported projection`);return`mercator`}function rF(e){return nF(e)===`globe`?new VP({id:JP}):new AO({id:JP})}function iF(e){let{lng:t,lat:n}=e.getCenter(),r={longitude:(t+540)%360-180,latitude:n,zoom:e.getZoom(),bearing:e.getBearing(),pitch:e.getPitch(),padding:e.getPadding(),repeat:e.getRenderWorldCopies()};return e.getTerrain?.()&&aF(e,r),r}function aF(e,t){if(e.getFreeCameraOptions){let{position:n}=e.getFreeCameraOptions();if(!n||n.z===void 0)return;let r=e.transform.height,{longitude:i,latitude:a,pitch:o}=t,s=n.x*YP,c=(1-n.y)*YP,l=n.z*YP,u=Mw([i,a]),d=s-u[0],f=c-u[1],p=Math.sqrt(d*d+f*f),m=o*XP,h=1.5*r,g=m<.001?h*Math.cos(m)/l:h*Math.sin(m)/p;t.zoom=Math.log2(g),t.position=[0,0,(l-h*Math.cos(m)/g)/Fw(a)]}else typeof e.transform.elevation==`number`&&(t.position=[0,0,e.transform.elevation])}function oF(e,t,n){let r=iF(t),i=e.getView(`mapbox`)||rF(t);n&&(i.props.nearZMultiplier=.2);let a=n?.nearZ??t.transform._nearZ,o=n?.farZ??t.transform._farZ;return Number.isFinite(a)&&(r.nearZ=a/t.transform.height,r.farZ=o/t.transform.height),i.makeViewport({width:e.width,height:e.height,viewState:r})}function sF(e,t){let n=AD(e.props.layers,Boolean).some(e=>e&&!t.getLayer(KP(e))),r=e.getViewports(),i=r.findIndex(e=>e.id===JP),a=r.length>1||i<0;if(n||a){if(i>=0){r=r.slice();let n=oF(e,t);n?r[i]=n:r.splice(i,1)}e._drawLayers(`mapbox-repaint`,{viewports:r,layerFilter:n=>(!e.props.layerFilter||e.props.layerFilter(n))&&(n.viewport.id!==`mapbox`||!t.getLayer(KP(n.layer))),clearCanvas:!1})}else{let t=e.device,n=t?.gl;e.props.onBeforeRender?.({device:t,gl:n}),e.props.onAfterRender?.({device:t,gl:n})}e.userData.currentViewport=null}function cF(e,t){e.setProps({viewState:iF(t)}),e.needsRedraw({clearRedrawFlags:!0})}var lF=class{constructor(e){this._handleStyleChange=()=>{this._resolveLayers(this._map,this._deck,this._props.layers,this._props.layers),this._map&&nF(this._map)&&this._deck?.setProps({views:this._getViews(this._map)})},this._updateContainerSize=()=>{if(this._map&&this._container){let{clientWidth:e,clientHeight:t}=this._map.getContainer();Object.assign(this._container.style,{width:`${e}px`,height:`${t}px`})}},this._updateViewState=()=>{let e=this._deck,t=this._map;e&&t&&(e.setProps({views:this._getViews(t),viewState:iF(t)}),e.isInitialized&&e.redraw())},this._handleMouseEvent=e=>{let t=this._deck;if(!t||!t.isInitialized)return;let n={type:e.type,offsetCenter:e.point,srcEvent:e},r=this._lastMouseDownPoint;switch(!e.point&&r&&(n.deltaX=e.originalEvent.clientX-r.clientX,n.deltaY=e.originalEvent.clientY-r.clientY,n.offsetCenter={x:r.x+n.deltaX,y:r.y+n.deltaY}),n.type){case`mousedown`:t._onPointerDown(n),this._lastMouseDownPoint={...e.point,clientX:e.originalEvent.clientX,clientY:e.originalEvent.clientY};break;case`dragstart`:n.type=`panstart`,t._onEvent(n);break;case`drag`:n.type=`panmove`,t._onEvent(n);break;case`dragend`:n.type=`panend`,t._onEvent(n);break;case`click`:n.tapCount=1,t._onEvent(n);break;case`dblclick`:n.type=`click`,n.tapCount=2,t._onEvent(n);break;case`mousemove`:n.type=`pointermove`,t._onPointerMove(n);break;case`mouseout`:n.type=`pointerleave`,t._onPointerMove(n);break;default:return}};let{interleaved:t=!1}=e;this._interleaved=t,this._props=this.filterProps(e)}filterProps(e){let{interleaved:t=!1,useDevicePixels:n,...r}=e;return!t&&n!==void 0&&(r.useDevicePixels=n),r}setProps(e){this._interleaved&&e.layers&&this._resolveLayers(this._map,this._deck,this._props.layers,e.layers),Object.assign(this._props,this.filterProps(e)),this._deck&&this._map&&this._deck.setProps({...this._props,views:this._getViews(this._map),parameters:{...eF(this._map,this._interleaved),...this._props.parameters}})}onAdd(e){return this._map=e,this._interleaved?this._onAddInterleaved(e):this._onAddOverlaid(e)}_onAddOverlaid(e){let t=document.createElement(`div`);return Object.assign(t.style,{position:`absolute`,left:0,top:0,textAlign:`initial`,pointerEvents:`none`}),this._container=t,this._deck=new EM({...this._props,parent:t,parameters:{...eF(e,!1),...this._props.parameters},views:this._getViews(e),viewState:iF(e)}),e.on(`resize`,this._updateContainerSize),e.on(`render`,this._updateViewState),e.on(`mousedown`,this._handleMouseEvent),e.on(`dragstart`,this._handleMouseEvent),e.on(`drag`,this._handleMouseEvent),e.on(`dragend`,this._handleMouseEvent),e.on(`mousemove`,this._handleMouseEvent),e.on(`mouseout`,this._handleMouseEvent),e.on(`click`,this._handleMouseEvent),e.on(`dblclick`,this._handleMouseEvent),this._updateContainerSize(),t}_onAddInterleaved(e){let t=e.painter.context.gl;return t instanceof WebGLRenderingContext&&X.warn(`Incompatible basemap library. See: https://deck.gl/docs/api-reference/mapbox/overview#compatibility`)(),this._deck=ZP({map:e,deck:new EM({...this._props,views:this._getViews(e),gl:t,parameters:{...eF(e,!0),...this._props.parameters}})}),e.on(`styledata`,this._handleStyleChange),this._resolveLayers(e,this._deck,[],this._props.layers),document.createElement(`div`)}_resolveLayers(e,t,n,r){qP(e,n,r)}onRemove(){let e=this._map;e&&(this._interleaved?this._onRemoveInterleaved(e):this._onRemoveOverlaid(e)),this._deck=void 0,this._map=void 0,this._container=void 0}_onRemoveOverlaid(e){e.off(`resize`,this._updateContainerSize),e.off(`render`,this._updateViewState),e.off(`mousedown`,this._handleMouseEvent),e.off(`dragstart`,this._handleMouseEvent),e.off(`drag`,this._handleMouseEvent),e.off(`dragend`,this._handleMouseEvent),e.off(`mousemove`,this._handleMouseEvent),e.off(`mouseout`,this._handleMouseEvent),e.off(`click`,this._handleMouseEvent),e.off(`dblclick`,this._handleMouseEvent),this._deck?.finalize()}_onRemoveInterleaved(e){e.off(`styledata`,this._handleStyleChange),this._resolveLayers(e,this._deck,this._props.layers,[]),$P(e)}getDefaultPosition(){return`top-left`}pickObject(e){return iO(this._deck),this._deck.pickObject(e)}pickMultipleObjects(e){return iO(this._deck),this._deck.pickMultipleObjects(e)}pickObjects(e){return iO(this._deck),this._deck.pickObjects(e)}finalize(){this._map&&this._map.removeControl(this)}getCanvas(){return this._map?this._interleaved?this._map.getCanvas():this._deck.getCanvas():null}_getViews(e){if(!this._props.views)return rF(e);let t=Array.isArray(this._props.views)?this._props.views:[this._props.views];return t.some(e=>e.id===`mapbox`)?this._props.views:[rF(e),...t]}},uF=`layout(std140) uniform iconUniforms {
|
|
2168
2168
|
float sizeScale;
|
|
2169
2169
|
vec2 iconsTextureDim;
|
|
2170
2170
|
float sizeBasis;
|
|
@@ -2174,7 +2174,7 @@ void main(void) {
|
|
|
2174
2174
|
highp int sizeUnits;
|
|
2175
2175
|
float alphaCutoff;
|
|
2176
2176
|
} icon;
|
|
2177
|
-
`,
|
|
2177
|
+
`,dF={name:`icon`,vs:uF,fs:uF,uniformTypes:{sizeScale:`f32`,iconsTextureDim:`vec2<f32>`,sizeBasis:`f32`,sizeMinPixels:`f32`,sizeMaxPixels:`f32`,billboard:`f32`,sizeUnits:`i32`,alphaCutoff:`f32`}},fF=`#version 300 es
|
|
2178
2178
|
#define SHADER_NAME icon-layer-vertex-shader
|
|
2179
2179
|
in vec2 positions;
|
|
2180
2180
|
in vec3 instancePositions;
|
|
@@ -2235,7 +2235,7 @@ vColor = instanceColors;
|
|
|
2235
2235
|
DECKGL_FILTER_COLOR(vColor, geometry);
|
|
2236
2236
|
vColorMode = instanceColorModes;
|
|
2237
2237
|
}
|
|
2238
|
-
`,
|
|
2238
|
+
`,pF=`#version 300 es
|
|
2239
2239
|
#define SHADER_NAME icon-layer-fragment-shader
|
|
2240
2240
|
precision highp float;
|
|
2241
2241
|
uniform sampler2D iconsTexture;
|
|
@@ -2255,7 +2255,7 @@ discard;
|
|
|
2255
2255
|
fragColor = vec4(color, a);
|
|
2256
2256
|
DECKGL_FILTER_COLOR(fragColor, geometry);
|
|
2257
2257
|
}
|
|
2258
|
-
`,
|
|
2258
|
+
`,mF=`struct IconUniforms {
|
|
2259
2259
|
sizeScale: f32,
|
|
2260
2260
|
iconsTextureDim: vec2<f32>,
|
|
2261
2261
|
sizeBasis: f32,
|
|
@@ -2404,7 +2404,7 @@ fn fragmentMain(inp: Varyings) -> @location(0) vec4<f32> {
|
|
|
2404
2404
|
|
|
2405
2405
|
return fragColor;
|
|
2406
2406
|
}
|
|
2407
|
-
`,
|
|
2407
|
+
`,hF=1024,gF=4,_F=()=>{},vF={minFilter:`linear`,mipmapFilter:`linear`,magFilter:`linear`,addressModeU:`clamp-to-edge`,addressModeV:`clamp-to-edge`},yF={x:0,y:0,width:0,height:0};function bF(e){return 2**Math.ceil(Math.log2(e))}function xF(e,t,n,r){let i=Math.min(n/t.width,r/t.height),a=Math.floor(t.width*i),o=Math.floor(t.height*i);return i===1?{image:t,width:a,height:o}:(e.canvas.height=o,e.canvas.width=a,e.clearRect(0,0,a,o),e.drawImage(t,0,0,t.width,t.height,0,0,a,o),{image:e.canvas,width:a,height:o})}function SF(e){return e&&(e.id||e.url)}function CF(e){let{device:t}=e;t.type===`webgl`?e.generateMipmapsWebGL():t.type===`webgpu`&&t.generateMipmapsWebGPU(e)}function wF(e,t,n,r){let{width:i,height:a,device:o}=e,s=o.createTexture({format:`rgba8unorm`,width:t,height:n,sampler:r,mipLevels:o.getMipLevelCount(t,n)}),c=o.createCommandEncoder();c.copyTextureToTexture({sourceTexture:e,destinationTexture:s,width:i,height:a});let l=c.finish();return o.submit(l),CF(s),e.destroy(),s}function TF(e,t,n){for(let r=0;r<t.length;r++){let{icon:i,xOffset:a}=t[r],o=SF(i);e[o]={...i,x:a,y:n}}}function EF({icons:e,buffer:t,mapping:n={},xOffset:r=0,yOffset:i=0,rowHeight:a=0,canvasWidth:o}){let s=[];for(let c=0;c<e.length;c++){let l=e[c];if(!n[SF(l)]){let{height:e,width:c}=l;r+c+t>o&&(TF(n,s,i),r=0,i=a+i+t,a=0,s=[]),s.push({icon:l,xOffset:r}),r=r+c+t,a=Math.max(a,e)}}return s.length>0&&TF(n,s,i),{mapping:n,rowHeight:a,xOffset:r,yOffset:i,canvasWidth:o,canvasHeight:bF(a+i+t)}}function DF(e,t,n){if(!e||!t)return null;n||={};let r={},{iterable:i,objectInfo:a}=LM(e);for(let e of i){a.index++;let i=t(e,a),o=SF(i);if(!i)throw Error(`Icon is missing.`);if(!i.url)throw Error(`Icon url is missing.`);!r[o]&&(!n[o]||i.url!==n[o].url)&&(r[o]={...i,source:e,sourceIndex:a.index})}return r}var OF=class{constructor(e,{onUpdate:t=_F,onError:n=_F}){this._loadOptions=null,this._texture=null,this._externalTexture=null,this._mapping={},this._samplerParameters=null,this._pendingCount=0,this._autoPacking=!1,this._xOffset=0,this._yOffset=0,this._rowHeight=0,this._buffer=gF,this._canvasWidth=hF,this._canvasHeight=0,this._canvas=null,this.device=e,this.onUpdate=t,this.onError=n}finalize(){this._texture?.delete()}getTexture(){return this._texture||this._externalTexture}getIconMapping(e){let t=this._autoPacking?SF(e):e;return this._mapping[t]||yF}setProps({loadOptions:e,autoPacking:t,iconAtlas:n,iconMapping:r,textureParameters:i}){e&&(this._loadOptions=e),t!==void 0&&(this._autoPacking=t),r&&(this._mapping=r),n&&(this._texture?.delete(),this._texture=null,this._externalTexture=n),i&&(this._samplerParameters=i)}get isLoaded(){return this._pendingCount===0}packIcons(e,t){if(!this._autoPacking||typeof document>`u`)return;let n=Object.values(DF(e,t,this._mapping)||{});if(n.length>0){let{mapping:e,xOffset:t,yOffset:r,rowHeight:i,canvasHeight:a}=EF({icons:n,buffer:this._buffer,canvasWidth:this._canvasWidth,mapping:this._mapping,rowHeight:this._rowHeight,xOffset:this._xOffset,yOffset:this._yOffset});this._rowHeight=i,this._mapping=e,this._xOffset=t,this._yOffset=r,this._canvasHeight=a,this._texture||=this.device.createTexture({format:`rgba8unorm`,data:null,width:this._canvasWidth,height:this._canvasHeight,sampler:this._samplerParameters||vF,mipLevels:this.device.getMipLevelCount(this._canvasWidth,this._canvasHeight)}),this._texture.height!==this._canvasHeight&&(this._texture=wF(this._texture,this._canvasWidth,this._canvasHeight,this._samplerParameters||vF)),this.onUpdate(!0),this._canvas=this._canvas||document.createElement(`canvas`),this._loadIcons(n)}}_loadIcons(e){let t=this._canvas.getContext(`2d`,{willReadFrequently:!0});for(let n of e)this._pendingCount++,Sm(n.url,this._loadOptions).then(e=>{let r=SF(n),i=this._mapping[r],{x:a,y:o,width:s,height:c}=i,{image:l,width:u,height:d}=xF(t,e,s,c),f=a+(s-u)/2,p=o+(c-d)/2;this._texture?.copyExternalImage({image:l,x:f,y:p,width:u,height:d}),i.x=f,i.y=p,i.width=u,i.height=d,this._texture&&CF(this._texture),this.onUpdate(u!==s||d!==c)}).catch(e=>{this.onError({url:n.url,source:n.source,sourceIndex:n.sourceIndex,loadOptions:this._loadOptions,error:e})}).finally(()=>{this._pendingCount--})}},kF=[0,0,0,255],AF={iconAtlas:{type:`image`,value:null,async:!0},iconMapping:{type:`object`,value:{},async:!0},sizeScale:{type:`number`,value:1,min:0},billboard:!0,sizeUnits:`pixels`,sizeBasis:`height`,sizeMinPixels:{type:`number`,min:0,value:0},sizeMaxPixels:{type:`number`,min:0,value:2**53-1},alphaCutoff:{type:`number`,value:.05,min:0,max:1},getPosition:{type:`accessor`,value:e=>e.position},getIcon:{type:`accessor`,value:e=>e.icon},getColor:{type:`accessor`,value:kF},getSize:{type:`accessor`,value:1},getAngle:{type:`accessor`,value:0},getPixelOffset:{type:`accessor`,value:[0,0]},onIconError:{type:`function`,value:null,optional:!0},textureParameters:{type:`object`,ignore:!0,value:null}},jF=class extends OP{getShaders(){return super.getShaders({vs:fF,fs:pF,source:mF,modules:[gw,yS,cT,dF]})}initializeState(){this.state={iconManager:new OF(this.context.device,{onUpdate:this._onUpdate.bind(this),onError:this._onError.bind(this)})},this.getAttributeManager().addInstanced({instancePositions:{size:3,type:`float64`,fp64:this.use64bitPositions(),transition:!0,accessor:`getPosition`},instanceSizes:{size:1,transition:!0,accessor:`getSize`,defaultValue:1},instanceIconDefs:{size:7,accessor:`getIcon`,transform:this.getInstanceIconDef,shaderAttributes:{instanceOffsets:{size:2,elementOffset:0},instanceIconFrames:{size:4,elementOffset:2},instanceColorModes:{size:1,elementOffset:6}}},instanceColors:{size:this.props.colorFormat.length,type:`unorm8`,transition:!0,accessor:`getColor`,defaultValue:kF},instanceAngles:{size:1,transition:!0,accessor:`getAngle`},instancePixelOffset:{size:2,transition:!0,accessor:`getPixelOffset`}})}updateState(e){super.updateState(e);let{props:t,oldProps:n,changeFlags:r}=e,i=this.getAttributeManager(),{iconAtlas:a,iconMapping:o,data:s,getIcon:c,textureParameters:l}=t,{iconManager:u}=this.state;if(typeof a==`string`)return;let d=a||this.internalState.isAsyncPropLoading(`iconAtlas`);u.setProps({loadOptions:t.loadOptions,autoPacking:!d,iconAtlas:a,iconMapping:d?o:null,textureParameters:l}),d?n.iconMapping!==t.iconMapping&&i.invalidate(`getIcon`):(r.dataChanged||r.updateTriggersChanged&&(r.updateTriggersChanged.all||r.updateTriggersChanged.getIcon))&&u.packIcons(s,c),r.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),i.invalidateAll())}get isLoaded(){return super.isLoaded&&this.state.iconManager.isLoaded}finalizeState(e){super.finalizeState(e),this.state.iconManager.finalize()}draw({uniforms:e}){let{sizeScale:t,sizeBasis:n,sizeMinPixels:r,sizeMaxPixels:i,sizeUnits:a,billboard:o,alphaCutoff:s}=this.props,{iconManager:c}=this.state,l=c.getTexture();if(l){let e=this.state.model,c={iconsTexture:l,iconsTextureDim:[l.width,l.height],sizeUnits:JC[a],sizeScale:t,sizeBasis:+(n===`height`),sizeMinPixels:r,sizeMaxPixels:i,billboard:o,alphaCutoff:s};e.shaderInputs.setProps({icon:c}),e.draw(this.context.renderPass)}}_getModel(){let e=[-1,-1,1,-1,-1,1,1,1];return new hD(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new vD({topology:`triangle-strip`,attributes:{positions:{size:2,value:new Float32Array(e)}}}),isInstanced:!0})}_onUpdate(e){e?(this.getAttributeManager()?.invalidate(`getIcon`),this.setNeedsUpdate()):this.setNeedsRedraw()}_onError(e){let t=this.getCurrentLayer()?.props.onIconError;t?t(e):X.error(e.error.message)()}getInstanceIconDef(e){let{x:t,y:n,width:r,height:i,mask:a,anchorX:o=r/2,anchorY:s=i/2}=this.state.iconManager.getIconMapping(e);return[r/2-o,i/2-s,t,n,r,i,+!!a]}};jF.defaultProps=AF,jF.layerName=`IconLayer`;var MF=`layout(std140) uniform scatterplotUniforms {
|
|
2408
2408
|
float radiusScale;
|
|
2409
2409
|
float radiusMinPixels;
|
|
2410
2410
|
float radiusMaxPixels;
|
|
@@ -2418,7 +2418,7 @@ fn fragmentMain(inp: Varyings) -> @location(0) vec4<f32> {
|
|
|
2418
2418
|
highp int radiusUnits;
|
|
2419
2419
|
highp int lineWidthUnits;
|
|
2420
2420
|
} scatterplot;
|
|
2421
|
-
`,
|
|
2421
|
+
`,NF={name:`scatterplot`,vs:MF,fs:MF,source:``,uniformTypes:{radiusScale:`f32`,radiusMinPixels:`f32`,radiusMaxPixels:`f32`,lineWidthScale:`f32`,lineWidthMinPixels:`f32`,lineWidthMaxPixels:`f32`,stroked:`f32`,filled:`f32`,antialiasing:`f32`,billboard:`f32`,radiusUnits:`i32`,lineWidthUnits:`i32`}},PF=`#version 300 es
|
|
2422
2422
|
#define SHADER_NAME scatterplot-layer-vertex-shader
|
|
2423
2423
|
in vec3 positions;
|
|
2424
2424
|
in vec3 instancePositions;
|
|
@@ -2466,7 +2466,7 @@ DECKGL_FILTER_COLOR(vFillColor, geometry);
|
|
|
2466
2466
|
vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * layer.opacity);
|
|
2467
2467
|
DECKGL_FILTER_COLOR(vLineColor, geometry);
|
|
2468
2468
|
}
|
|
2469
|
-
`,
|
|
2469
|
+
`,FF=`#version 300 es
|
|
2470
2470
|
#define SHADER_NAME scatterplot-layer-fragment-shader
|
|
2471
2471
|
precision highp float;
|
|
2472
2472
|
in vec4 vFillColor;
|
|
@@ -2504,7 +2504,7 @@ fragColor = vFillColor;
|
|
|
2504
2504
|
fragColor.a *= inCircle;
|
|
2505
2505
|
DECKGL_FILTER_COLOR(fragColor, geometry);
|
|
2506
2506
|
}
|
|
2507
|
-
`,
|
|
2507
|
+
`,IF=`// Main shaders
|
|
2508
2508
|
|
|
2509
2509
|
struct ScatterplotUniforms {
|
|
2510
2510
|
radiusScale: f32,
|
|
@@ -2721,7 +2721,7 @@ fn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {
|
|
|
2721
2721
|
return fragColor;
|
|
2722
2722
|
// return vec4<f32>(0, 0, 1, 1);
|
|
2723
2723
|
}
|
|
2724
|
-
`,
|
|
2724
|
+
`,LF=[0,0,0,255],RF={radiusUnits:`meters`,radiusScale:{type:`number`,min:0,value:1},radiusMinPixels:{type:`number`,min:0,value:0},radiusMaxPixels:{type:`number`,min:0,value:2**53-1},lineWidthUnits:`meters`,lineWidthScale:{type:`number`,min:0,value:1},lineWidthMinPixels:{type:`number`,min:0,value:0},lineWidthMaxPixels:{type:`number`,min:0,value:2**53-1},stroked:!1,filled:!0,billboard:!1,antialiasing:!0,getPosition:{type:`accessor`,value:e=>e.position},getRadius:{type:`accessor`,value:1},getFillColor:{type:`accessor`,value:LF},getLineColor:{type:`accessor`,value:LF},getLineWidth:{type:`accessor`,value:1},strokeWidth:{deprecatedFor:`getLineWidth`},outline:{deprecatedFor:`stroked`},getColor:{deprecatedFor:[`getFillColor`,`getLineColor`]}},zF=class extends OP{getShaders(){return super.getShaders({vs:PF,fs:FF,source:IF,modules:[gw,yS,cT,NF]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:`float64`,fp64:this.use64bitPositions(),transition:!0,accessor:`getPosition`},instanceRadius:{size:1,transition:!0,accessor:`getRadius`,defaultValue:1},instanceFillColors:{size:this.props.colorFormat.length,transition:!0,type:`unorm8`,accessor:`getFillColor`,defaultValue:[0,0,0,255]},instanceLineColors:{size:this.props.colorFormat.length,transition:!0,type:`unorm8`,accessor:`getLineColor`,defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:`getLineWidth`,defaultValue:1}})}updateState(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{radiusUnits:t,radiusScale:n,radiusMinPixels:r,radiusMaxPixels:i,stroked:a,filled:o,billboard:s,antialiasing:c,lineWidthUnits:l,lineWidthScale:u,lineWidthMinPixels:d,lineWidthMaxPixels:f}=this.props,p={stroked:a,filled:o,billboard:s,antialiasing:c,radiusUnits:JC[t],radiusScale:n,radiusMinPixels:r,radiusMaxPixels:i,lineWidthUnits:JC[l],lineWidthScale:u,lineWidthMinPixels:d,lineWidthMaxPixels:f},m=this.state.model;m.shaderInputs.setProps({scatterplot:p}),m.draw(this.context.renderPass)}_getModel(){let e=[-1,-1,0,1,-1,0,-1,1,0,1,1,0];return new hD(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new vD({topology:`triangle-strip`,attributes:{positions:{size:3,value:new Float32Array(e)}}}),isInstanced:!0})}};zF.defaultProps=RF,zF.layerName=`ScatterplotLayer`;function BF(e,t){let n=t.length,r=e.length;if(r>0){let i=!0;for(let a=0;a<n;a++)if(e[r-n+a]!==t[a]){i=!1;break}if(i)return!1}for(let i=0;i<n;i++)e[r+i]=t[i];return!0}function VF(e,t){let n=t.length;for(let r=0;r<n;r++)e[r]=t[r]}function HF(e,t,n,r,i=[]){let a=r+t*n;for(let t=0;t<n;t++)i[t]=e[a+t];return i}function UF(e,t,n,r,i=[]){let a,o;if(n&8)a=(r[3]-e[1])/(t[1]-e[1]),o=3;else if(n&4)a=(r[1]-e[1])/(t[1]-e[1]),o=1;else if(n&2)a=(r[2]-e[0])/(t[0]-e[0]),o=2;else if(n&1)a=(r[0]-e[0])/(t[0]-e[0]),o=0;else return null;for(let n=0;n<e.length;n++)i[n]=(o&1)===n?r[o]:a*(t[n]-e[n])+e[n];return i}function WF(e,t){let n=0;return e[0]<t[0]?n|=1:e[0]>t[2]&&(n|=2),e[1]<t[1]?n|=4:e[1]>t[3]&&(n|=8),n}function GF(e,t){let{size:n=2,broken:r=!1,gridResolution:i=10,gridOffset:a=[0,0],startIndex:o=0,endIndex:s=e.length}=t||{},c=(s-o)/n,l=[],u=[l],d=HF(e,0,n,o),f,p,m=KF(d,i,a,[]),h=[];BF(l,d);for(let t=1;t<c;t++){for(f=HF(e,t,n,o,f),p=WF(f,m);p;){UF(d,f,p,m,h);let e=WF(h,m);e&&(UF(d,h,e,m,h),p=e),BF(l,h),VF(d,h),qF(m,i,p),r&&l.length>n&&(l=[],u.push(l),BF(l,d)),p=WF(f,m)}BF(l,f),VF(d,f)}return r?u:u[0]}function KF(e,t,n,r){let i=Math.floor((e[0]-n[0])/t)*t+n[0],a=Math.floor((e[1]-n[1])/t)*t+n[1];return r[0]=i,r[1]=a,r[2]=i+t,r[3]=a+t,r}function qF(e,t,n){n&8?(e[1]+=t,e[3]+=t):n&4?(e[1]-=t,e[3]-=t):n&2?(e[0]+=t,e[2]+=t):n&1&&(e[0]-=t,e[2]-=t)}function JF(e,t){let{size:n=2,startIndex:r=0,endIndex:i=e.length,normalize:a=!0}=t||{},o=e.slice(r,i);YF(o,n,0,i-r);let s=GF(o,{size:n,broken:!0,gridResolution:360,gridOffset:[-180,-180]});if(a)for(let e of s)XF(e,n);return s}function YF(e,t,n,r){let i=e[0],a;for(let o=n;o<r;o+=t){a=e[o];let t=a-i;(t>180||t<-180)&&(a-=Math.round(t/360)*360),e[o]=i=a}}function XF(e,t){let n,r=e.length/t;for(let i=0;i<r&&(n=e[i*t],(n+180)%360==0);i++);let i=-Math.round(n/360)*360;if(i!==0)for(let n=0;n<r;n++)e[n*t]+=i}function ZF(e,t,n,r){let i;if(Array.isArray(e[0])){let n=e.length*t;i=Array(n);for(let n=0;n<e.length;n++)for(let r=0;r<t;r++)i[n*t+r]=e[n][r]||0}else i=e;return n?GF(i,{size:t,gridResolution:n}):r?JF(i,{size:t}):i}var QF=1,$F=2,eI=4,tI=class extends UP{constructor(e){super({...e,attributes:{positions:{size:3,padding:18,initialize:!0,type:e.fp64?Float64Array:Float32Array},segmentTypes:{size:1,type:Uint8ClampedArray}}})}get(e){return this.attributes[e]}getGeometryFromBuffer(e){return this.normalize?super.getGeometryFromBuffer(e):null}normalizeGeometry(e){return this.normalize?ZF(e,this.positionSize,this.opts.resolution,this.opts.wrapLongitude):e}getGeometrySize(e){if(nI(e)){let t=0;for(let n of e)t+=this.getGeometrySize(n);return t}let t=this.getPathLength(e);return t<2?0:this.isClosed(e)?t<3?0:t+2:t}updateGeometryAttributes(e,t){if(t.geometrySize!==0)if(e&&nI(e))for(let n of e){let e=this.getGeometrySize(n);t.geometrySize=e,this.updateGeometryAttributes(n,t),t.vertexStart+=e}else this._updateSegmentTypes(e,t),this._updatePositions(e,t)}_updateSegmentTypes(e,t){let n=this.attributes.segmentTypes,r=e?this.isClosed(e):!1,{vertexStart:i,geometrySize:a}=t;n.fill(0,i,i+a),r?(n[i]=eI,n[i+a-2]=eI):(n[i]+=QF,n[i+a-2]+=$F),n[i+a-1]=eI}_updatePositions(e,t){let{positions:n}=this.attributes;if(!n||!e)return;let{vertexStart:r,geometrySize:i}=t,a=[,,,];for(let t=r,o=0;o<i;t++,o++)this.getPointOnPath(e,o,a),n[t*3]=a[0],n[t*3+1]=a[1],n[t*3+2]=a[2]}getPathLength(e){return e.length/this.positionSize}getPointOnPath(e,t,n=[]){let{positionSize:r}=this;t*r>=e.length&&(t+=1-e.length/r);let i=t*r;return n[0]=e[i],n[1]=e[i+1],n[2]=r===3&&e[i+2]||0,n}isClosed(e){if(!this.normalize)return!!this.opts.loop;let{positionSize:t}=this,n=e.length-t;return e[0]===e[n]&&e[1]===e[n+1]&&(t===2||e[2]===e[n+2])}};function nI(e){return Array.isArray(e[0])}var rI=`layout(std140) uniform pathUniforms {
|
|
2725
2725
|
float widthScale;
|
|
2726
2726
|
float widthMinPixels;
|
|
2727
2727
|
float widthMaxPixels;
|
|
@@ -2731,7 +2731,7 @@ fn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {
|
|
|
2731
2731
|
bool billboard;
|
|
2732
2732
|
highp int widthUnits;
|
|
2733
2733
|
} path;
|
|
2734
|
-
`,
|
|
2734
|
+
`,iI={name:`path`,vs:rI,fs:rI,uniformTypes:{widthScale:`f32`,widthMinPixels:`f32`,widthMaxPixels:`f32`,jointType:`f32`,capType:`f32`,miterLimit:`f32`,billboard:`f32`,widthUnits:`i32`}},aI=`#version 300 es
|
|
2735
2735
|
#define SHADER_NAME path-layer-vertex-shader
|
|
2736
2736
|
in vec2 positions;
|
|
2737
2737
|
in float instanceTypes;
|
|
@@ -2876,7 +2876,7 @@ DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
|
|
|
2876
2876
|
}
|
|
2877
2877
|
DECKGL_FILTER_COLOR(vColor, geometry);
|
|
2878
2878
|
}
|
|
2879
|
-
|
|
2879
|
+
`,oI=`#version 300 es
|
|
2880
2880
|
#define SHADER_NAME path-layer-fragment-shader
|
|
2881
2881
|
precision highp float;
|
|
2882
2882
|
in vec4 vColor;
|
|
@@ -2899,14 +2899,14 @@ discard;
|
|
|
2899
2899
|
fragColor = vColor;
|
|
2900
2900
|
DECKGL_FILTER_COLOR(fragColor, geometry);
|
|
2901
2901
|
}
|
|
2902
|
-
`,
|
|
2902
|
+
`,sI=[0,0,0,255],cI={widthUnits:`meters`,widthScale:{type:`number`,min:0,value:1},widthMinPixels:{type:`number`,min:0,value:0},widthMaxPixels:{type:`number`,min:0,value:2**53-1},jointRounded:!1,capRounded:!1,miterLimit:{type:`number`,min:0,value:4},billboard:!1,_pathType:null,getPath:{type:`accessor`,value:e=>e.path},getColor:{type:`accessor`,value:sI},getWidth:{type:`accessor`,value:1},rounded:{deprecatedFor:[`jointRounded`,`capRounded`]}},lI={enter:(e,t)=>t.length?t.subarray(t.length-e.length):e},uI=class extends OP{getShaders(){return super.getShaders({vs:aI,fs:oI,modules:[gw,cT,iI]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds([`vertexPositions`])}initializeState(){this.getAttributeManager().addInstanced({vertexPositions:{size:3,vertexOffset:1,type:`float64`,fp64:this.use64bitPositions(),transition:lI,accessor:`getPath`,update:this.calculatePositions,noAlloc:!0,shaderAttributes:{instanceLeftPositions:{vertexOffset:0},instanceStartPositions:{vertexOffset:1},instanceEndPositions:{vertexOffset:2},instanceRightPositions:{vertexOffset:3}}},instanceTypes:{size:1,type:`uint8`,update:this.calculateSegmentTypes,noAlloc:!0},instanceStrokeWidths:{size:1,accessor:`getWidth`,transition:lI,defaultValue:1},instanceColors:{size:this.props.colorFormat.length,type:`unorm8`,accessor:`getColor`,transition:lI,defaultValue:sI},instancePickingColors:{size:4,type:`uint8`,accessor:(e,{index:t,target:n})=>this.encodePickingColor(e&&e.__source?e.__source.index:t,n)}}),this.setState({pathTesselator:new tI({fp64:this.use64bitPositions()})})}updateState(e){super.updateState(e);let{props:t,changeFlags:n}=e,r=this.getAttributeManager();if(n.dataChanged||n.updateTriggersChanged&&(n.updateTriggersChanged.all||n.updateTriggersChanged.getPath)){let{pathTesselator:e}=this.state,i=t.data.attributes||{};e.updateGeometry({data:t.data,geometryBuffer:i.getPath,buffers:i,normalize:!t._pathType,loop:t._pathType===`loop`,getGeometry:t.getPath,positionFormat:t.positionFormat,wrapLongitude:t.wrapLongitude,resolution:this.context.viewport.resolution,dataChanged:n.dataChanged}),this.setState({numInstances:e.instanceCount,startIndices:e.vertexStarts}),n.dataChanged||r.invalidateAll()}n.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),r.invalidateAll())}getPickingInfo(e){let t=super.getPickingInfo(e),{index:n}=t,r=this.props.data;return r[0]&&r[0].__source&&(t.object=r.find(e=>e.__source.index===n)),t}disablePickingIndex(e){let t=this.props.data;if(t[0]&&t[0].__source)for(let n=0;n<t.length;n++)t[n].__source.index===e&&this._disablePickingIndex(n);else super.disablePickingIndex(e)}draw({uniforms:e}){let{jointRounded:t,capRounded:n,billboard:r,miterLimit:i,widthUnits:a,widthScale:o,widthMinPixels:s,widthMaxPixels:c}=this.props,l=this.state.model,u={jointType:Number(t),capType:Number(n),billboard:r,widthUnits:JC[a],widthScale:o,miterLimit:i,widthMinPixels:s,widthMaxPixels:c};l.shaderInputs.setProps({path:u}),l.draw(this.context.renderPass)}_getModel(){let e=[0,1,2,1,4,2,1,3,4,3,5,4],t=[0,0,0,-1,0,1,1,-1,1,1,1,0];return new hD(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new vD({topology:`triangle-list`,attributes:{indices:new Uint16Array(e),positions:{value:new Float32Array(t),size:2}}}),isInstanced:!0})}calculatePositions(e){let{pathTesselator:t}=this.state;e.startIndices=t.vertexStarts,e.value=t.get(`positions`)}calculateSegmentTypes(e){let{pathTesselator:t}=this.state;e.startIndices=t.vertexStarts,e.value=t.get(`segmentTypes`)}};uI.defaultProps=cI,uI.layerName=`PathLayer`;var dI=`layout(std140) uniform sdfUniforms {
|
|
2903
2903
|
float gamma;
|
|
2904
2904
|
bool enabled;
|
|
2905
2905
|
float buffer;
|
|
2906
2906
|
float outlineBuffer;
|
|
2907
2907
|
vec4 outlineColor;
|
|
2908
2908
|
} sdf;
|
|
2909
|
-
`,
|
|
2909
|
+
`,fI={name:`sdf`,vs:dI,fs:dI,uniformTypes:{gamma:`f32`,enabled:`f32`,buffer:`f32`,outlineBuffer:`f32`,outlineColor:`vec4<f32>`}},pI={none:0,start:1,center:2,end:3},mI={name:`text`,vs:`\
|
|
2910
2910
|
layout(std140) uniform textUniforms {
|
|
2911
2911
|
highp vec2 cutoffPixels;
|
|
2912
2912
|
highp ivec2 align;
|
|
@@ -2914,10 +2914,10 @@ layout(std140) uniform textUniforms {
|
|
|
2914
2914
|
bool flipY;
|
|
2915
2915
|
} text;
|
|
2916
2916
|
|
|
2917
|
-
#define ALIGN_MODE_START ${
|
|
2918
|
-
#define ALIGN_MODE_CENTER ${
|
|
2919
|
-
#define ALIGN_MODE_END ${
|
|
2920
|
-
`,getUniforms:({contentCutoffPixels:e=[0,0],contentAlignHorizontal:t=`none`,contentAlignVertical:n=`none`,fontSize:r,viewport:i})=>({cutoffPixels:e,align:[
|
|
2917
|
+
#define ALIGN_MODE_START ${pI.start}
|
|
2918
|
+
#define ALIGN_MODE_CENTER ${pI.center}
|
|
2919
|
+
#define ALIGN_MODE_END ${pI.end}
|
|
2920
|
+
`,getUniforms:({contentCutoffPixels:e=[0,0],contentAlignHorizontal:t=`none`,contentAlignVertical:n=`none`,fontSize:r,viewport:i})=>({cutoffPixels:e,align:[pI[t],pI[n]],fontSize:r,flipY:i?.flipY??!1}),uniformTypes:{cutoffPixels:`vec2<f32>`,align:`vec2<i32>`,fontSize:`f32`,flipY:`f32`}},hI=`#version 300 es
|
|
2921
2921
|
#define SHADER_NAME multi-icon-layer-vertex-shader
|
|
2922
2922
|
in vec2 positions;
|
|
2923
2923
|
in vec3 instancePositions;
|
|
@@ -3041,7 +3041,7 @@ vColor = instanceColors;
|
|
|
3041
3041
|
DECKGL_FILTER_COLOR(vColor, geometry);
|
|
3042
3042
|
vColorMode = instanceColorModes;
|
|
3043
3043
|
}
|
|
3044
|
-
`,
|
|
3044
|
+
`,gI=`#version 300 es
|
|
3045
3045
|
#define SHADER_NAME multi-icon-layer-fragment-shader
|
|
3046
3046
|
precision highp float;
|
|
3047
3047
|
uniform sampler2D iconsTexture;
|
|
@@ -3072,9 +3072,9 @@ fragColor = vec4(color.rgb, a * layer.opacity);
|
|
|
3072
3072
|
}
|
|
3073
3073
|
DECKGL_FILTER_COLOR(fragColor, geometry);
|
|
3074
3074
|
}
|
|
3075
|
-
`,
|
|
3076
|
-
`||e===s)&&(_=e),_>g){let e=d?
|
|
3077
|
-
`&&(c[g]=0,l[g]=0,u[g]=0,g++)}return f[1]=m*n,{x:c,y:l,rowWidth:u,size:f}}function
|
|
3075
|
+
`,_I=192/256,vI={getIconOffsets:{type:`accessor`,value:e=>e.offsets},getContentBox:{type:`accessor`,value:[0,0,-1,-1]},fontSize:1,alphaCutoff:.001,smoothing:.1,outlineWidth:0,outlineColor:{type:`color`,value:[0,0,0,255]},contentCutoffPixels:{type:`array`,value:[0,0]},contentAlignHorizontal:`none`,contentAlignVertical:`none`},yI=class extends jF{getShaders(){let e=super.getShaders();return{...e,modules:[...e.modules,mI,fI],vs:hI,fs:gI}}initializeState(){super.initializeState();let e=this.getAttributeManager(),t=e.attributes.instanceIconDefs;t.settings.update=this.calculateInstanceIconDefs,e.addInstanced({instancePickingColors:{type:`uint8`,size:4,accessor:(e,{index:t,target:n})=>this.encodePickingColor(t,n)},instanceClipRect:{size:4,accessor:`getContentBox`,defaultValue:[0,0,-1,-1]}})}updateState(e){super.updateState(e);let{props:t,oldProps:n,changeFlags:r}=e,{outlineColor:i}=t;if(r.updateTriggersChanged&&(r.updateTriggersChanged.getIcon||r.updateTriggersChanged.getIconOffsets)&&this.getAttributeManager().invalidate(`instanceIconDefs`),i!==n.outlineColor){let e=[i[0]/255,i[1]/255,i[2]/255,(i[3]??255)/255];this.setState({outlineColor:e})}!t.sdf&&t.outlineWidth&&X.warn(`${this.id}: fontSettings.sdf is required to render outline`)()}draw(e){let{sdf:t,smoothing:n,fontSize:r,outlineWidth:i,contentCutoffPixels:a,contentAlignHorizontal:o,contentAlignVertical:s}=this.props,{outlineColor:c}=this.state,l=i?Math.max(n,_I*(1-i)):-1,u=this.state.model,d={buffer:_I,outlineBuffer:l,gamma:n,enabled:!!t,outlineColor:c},f={contentCutoffPixels:a,contentAlignHorizontal:o,contentAlignVertical:s,fontSize:r,viewport:this.context.viewport};if(u.shaderInputs.setProps({sdf:d,text:f}),super.draw(e),t&&i){let{iconManager:e}=this.state;e.getTexture()&&(u.shaderInputs.setProps({sdf:{...d,outlineBuffer:_I}}),u.draw(this.context.renderPass))}}calculateInstanceIconDefs(e,{startRow:t,endRow:n}){let{data:r,getIcon:i,getIconOffsets:a}=this.props,o=e.getVertexOffset(t),s=e.value,{iterable:c,objectInfo:l}=LM(r,t,n);for(let t of c){l.index++;let n=i(t,l),r=a(t,l);if(n){let t=0;for(let i of Array.from(n)){let n=super.getInstanceIconDef(i);n[0]=r[t*2],n[1]+=r[t*2+1],n[6]=1,s.set(n,o),o+=e.size,t++}}}}};yI.defaultProps=vI,yI.layerName=`MultiIconLayer`;var bI=0x56bc75e2d63100000,xI=new Float64Array(256);for(let e=0;e<256;e++){let t=.5-(e/255)**(1/2.2);xI[e]=t*Math.abs(t)}xI[255]=-0x56bc75e2d63100000;var SI=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+t*4,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:_,gridOuter:v}=this;this.lang&&(h.lang=this.lang),h.clearRect(g,g,c,l),h.fillText(e,g-s,g+o);let y=h.getImageData(g,g,c,l);v.fill(bI,0,f),_.fill(0,0,f);let b=3;for(let e=0;e<l;e++){let t=(e+g)*u+g;for(let e=0;e<c;e++,b+=4,t++){let e=y.data[b];if(e===0)continue;let n=xI[e];v[t]=Math.max(0,n),_[t]=Math.max(0,-n)}}CI(v,0,0,u,d,u,this.f,this.v,this.z);let x=Math.min(g,1);CI(_,g-x,g-x,c+2*x,l+2*x,u,this.f,this.v,this.z);let S=255/this.radius,C=255*(1-this.cutoff);for(let e=0;e<f;e++){let t=Math.sqrt(v[e])-Math.sqrt(_[e]);p[e]=Math.round(C-S*t)}return m}};function CI(e,t,n,r,i,a,o,s,c){for(let l=t;l<t+r;l++)wI(e,n*a+l,a,i,o,s,c);for(let l=n;l<n+i;l++)wI(e,l*a+t,1,r,o,s,c)}function wI(e,t,n,r,i,a,o){a[0]=0,o[0]=-0x56bc75e2d63100000,o[1]=bI,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]=bI}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}}var TI=32,EI=[];function DI(e){return 2**Math.ceil(Math.log2(e))}function OI({characterSet:e,measureText:t,buffer:n,maxCanvasWidth:r,mapping:i={},xOffset:a=0,yOffsetMin:o=0,yOffsetMax:s=0}){let c=a,l=o,u=s;for(let a of e)if(!i[a]){let{advance:e,width:o,ascent:s,descent:d}=t(a),f=s+d;c+o+n*2>r&&(c=0,l=u),i[a]={x:c+n,y:l+n,width:o,height:f,advance:e,anchorX:o/2,anchorY:s},c+=o+n*2,u=Math.max(u,l+f+n*2)}return{mapping:i,xOffset:c,yOffsetMin:l,yOffsetMax:u,canvasHeight:DI(u)}}function kI(e,t,n,r){let i=0;for(let a=t;a<n;a++){let t=e[a];i+=r[t]?.advance||0}return i}function AI(e,t,n,r,i,a){let o=t,s=0;for(let c=t;c<n;c++){let t=kI(e,c,c+1,i);s+t>r&&(o<c&&a.push(c),o=c,s=0),s+=t}return s}function jI(e,t,n,r,i,a){let o=t,s=t,c=t,l=0;for(let u=t;u<n;u++)if((e[u]===` `||e[u+1]===` `||u+1===n)&&(c=u+1),c>s){let t=kI(e,s,c,i);l+t>r&&(o<s&&(a.push(s),o=s,l=0),t>r&&(t=AI(e,s,c,r,i,a),o=a[a.length-1])),s=c,l+=t}return l}function MI(e,t,n,r,i=0,a){a===void 0&&(a=e.length);let o=[];return t===`break-all`?AI(e,i,a,n,r,o):jI(e,i,a,n,r,o),o}function NI(e,t,n,r,i,a){let o=0,s=0;for(let i=t;i<n;i++){let t=r[e[i]];t&&(s=Math.max(s,t.height))}for(let a=t;a<n;a++){let t=e[a],n=r[t];n?(i[a]=o+n.anchorX,o+=n.advance):(X.warn(`Missing character: ${t} (${t.codePointAt(0)})`)(),i[a]=o,o+=TI)}a[0]=o,a[1]=s}function PI(e,t,n,r,i,a){let o=Array.from(e),s=o.length,c=Array(s),l=Array(s),u=Array(s),d=(r===`break-word`||r===`break-all`)&&isFinite(i)&&i>0,f=[0,0],p=[0,0],m=0,h=t+n/2,g=0,_=0;for(let e=0;e<=s;e++){let t=o[e];if((t===`
|
|
3076
|
+
`||e===s)&&(_=e),_>g){let e=d?MI(o,r,i,a,g,_):EI;for(let t=0;t<=e.length;t++){let r=t===0?g:e[t-1],i=t<e.length?e[t]:_;NI(o,r,i,a,c,p);for(let e=r;e<i;e++)l[e]=h,u[e]=p[0];m++,h+=n,f[0]=Math.max(f[0],p[0])}g=_}t===`
|
|
3077
|
+
`&&(c[g]=0,l[g]=0,u[g]=0,g++)}return f[1]=m*n,{x:c,y:l,rowWidth:u,size:f}}function FI({value:e,length:t,stride:n,offset:r,startIndices:i,characterSet:a}){let o=e.BYTES_PER_ELEMENT,s=n?n/o:1,c=r?r/o:0,l=i[t]||Math.ceil((e.length-c)/s),u=a&&new Set,d=Array(t),f=e;if(s>1||c>0){let t=e.constructor;f=new t(l);for(let t=0;t<l;t++)f[t]=e[t*s+c]}for(let e=0;e<t;e++){let t=i[e],n=i[e+1]||l,r=f.subarray(t,n);d[e]=String.fromCodePoint.apply(null,r),u&&r.forEach(u.add,u)}if(u)for(let e of u)a.add(String.fromCodePoint(e));return{texts:d,characterCount:l}}var II=class{constructor(e=5){this._cache={},this._order=[],this.limit=e}get(e){let t=this._cache[e];return t&&(this._deleteOrder(e),this._appendOrder(e)),t}set(e,t){this._cache[e]?(this.delete(e),this._cache[e]=t,this._appendOrder(e)):(Object.keys(this._cache).length===this.limit&&this.delete(this._order[0]),this._cache[e]=t,this._appendOrder(e))}delete(e){this._cache[e]&&(delete this._cache[e],this._deleteOrder(e))}_deleteOrder(e){let t=this._order.indexOf(e);t>=0&&this._order.splice(t,1)}_appendOrder(e){this._order.push(e)}};function LI(){let e=[];for(let t=32;t<128;t++)e.push(String.fromCharCode(t));return e}var RI={fontFamily:`Monaco, monospace`,fontWeight:`normal`,characterSet:LI(),fontSize:64,buffer:4,sdf:!1,cutoff:.25,radius:12,smoothing:.1},zI=1024,BI=.9,VI=.3,HI=3,UI=new II(HI);function WI(e,t){let n;n=typeof t==`string`?new Set(Array.from(t)):new Set(t);let r=UI.get(e);if(!r)return n;for(let e in r.mapping)n.has(e)&&n.delete(e);return n}function GI(e,t){for(let n=0;n<e.length;n++)t.data[4*n+3]=e[n]}function KI(e,t,n,r){e.font=`${r} ${n}px ${t}`,e.fillStyle=`#000`,e.textBaseline=`alphabetic`,e.textAlign=`left`}function qI(e,t,n){if(n===void 0){let n=e.measureText(`A`);return n.fontBoundingBoxAscent?{advance:0,width:0,ascent:Math.ceil(n.fontBoundingBoxAscent),descent:Math.ceil(n.fontBoundingBoxDescent)}:{advance:0,width:0,ascent:t*BI,descent:t*VI}}let r=e.measureText(n);return r.actualBoundingBoxAscent?{advance:r.width,width:Math.ceil(r.actualBoundingBoxRight-r.actualBoundingBoxLeft),ascent:Math.ceil(r.actualBoundingBoxAscent),descent:Math.ceil(r.actualBoundingBoxDescent)}:{advance:r.width,width:r.width,ascent:t*BI,descent:t*VI}}function JI(e){X.assert(Number.isFinite(e)&&e>=HI,`Invalid cache limit`),UI=new II(e)}var YI=class{constructor(){this.props={...RI}}get atlas(){return this._atlas}get mapping(){return this._atlas&&this._atlas.mapping}setProps(e={}){Object.assign(this.props,e),e._getFontRenderer&&(this._getFontRenderer=e._getFontRenderer),this._key=this._getKey();let t=WI(this._key,this.props.characterSet),n=UI.get(this._key);if(n&&t.size===0){this._atlas!==n&&(this._atlas=n);return}let r=this._generateFontAtlas(t,n);this._atlas=r,UI.set(this._key,r)}_generateFontAtlas(e,t){let{fontFamily:n,fontWeight:r,fontSize:i,buffer:a,sdf:o,radius:s,cutoff:c}=this.props,l=t&&t.data;l||(l=document.createElement(`canvas`),l.width=zI);let u=l.getContext(`2d`,{willReadFrequently:!0});KI(u,n,i,r);let d=e=>qI(u,i,e),f;this._getFontRenderer?f=this._getFontRenderer(this.props):o&&(f={measure:d,draw:XI(this.props)});let{mapping:p,canvasHeight:m,xOffset:h,yOffsetMin:g,yOffsetMax:_}=OI({measureText:e=>f?f.measure(e):d(e),buffer:a,characterSet:e,maxCanvasWidth:zI,...t&&{mapping:t.mapping,xOffset:t.xOffset,yOffsetMin:t.yOffsetMin,yOffsetMax:t.yOffsetMax}});if(l.height!==m){let e=l.height>0?u.getImageData(0,0,l.width,l.height):null;l.height=m,e&&u.putImageData(e,0,0)}if(KI(u,n,i,r),f)for(let t of e){let e=p[t],{data:n,left:r=0,top:i=0}=f.draw(t),a=e.x-r,o=e.y-i,s=Math.max(0,Math.round(a)),c=Math.max(0,Math.round(o)),d=Math.min(n.width,l.width-s),m=Math.min(n.height,l.height-c);u.putImageData(n,s,c,0,0,d,m),e.x+=s-a,e.y+=c-o}else for(let t of e){let e=p[t];u.fillText(t,e.x,e.y+e.anchorY)}let v=f?f.measure():d();return{baselineOffset:(v.ascent-v.descent)/2,xOffset:h,yOffsetMin:g,yOffsetMax:_,mapping:p,data:l,width:l.width,height:l.height}}_getKey(){let{fontFamily:e,fontWeight:t,fontSize:n,buffer:r,sdf:i,radius:a,cutoff:o}=this.props;return i?`${e} ${t} ${n} ${r} ${a} ${o}`:`${e} ${t} ${n} ${r}`}};function XI({fontSize:e,buffer:t,radius:n,cutoff:r,fontFamily:i,fontWeight:a}){let o=new SI({fontSize:e,buffer:t,radius:n,cutoff:r,fontFamily:i,fontWeight:`${a}`});return e=>{let{data:n,width:r,height:i}=o.draw(e),a=new ImageData(r,i);return GI(n,a),{data:a,left:t,top:t}}}var ZI=`layout(std140) uniform textBackgroundUniforms {
|
|
3078
3078
|
bool billboard;
|
|
3079
3079
|
float sizeScale;
|
|
3080
3080
|
float sizeMinPixels;
|
|
@@ -3084,7 +3084,7 @@ DECKGL_FILTER_COLOR(fragColor, geometry);
|
|
|
3084
3084
|
highp int sizeUnits;
|
|
3085
3085
|
bool stroked;
|
|
3086
3086
|
} textBackground;
|
|
3087
|
-
`,
|
|
3087
|
+
`,QI={name:`textBackground`,vs:ZI,fs:ZI,uniformTypes:{billboard:`f32`,sizeScale:`f32`,sizeMinPixels:`f32`,sizeMaxPixels:`f32`,borderRadius:`vec4<f32>`,padding:`vec4<f32>`,sizeUnits:`i32`,stroked:`f32`}},$I=`#version 300 es
|
|
3088
3088
|
#define SHADER_NAME text-background-layer-vertex-shader
|
|
3089
3089
|
in vec2 positions;
|
|
3090
3090
|
in vec3 instancePositions;
|
|
@@ -3159,7 +3159,7 @@ DECKGL_FILTER_COLOR(vFillColor, geometry);
|
|
|
3159
3159
|
vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * layer.opacity);
|
|
3160
3160
|
DECKGL_FILTER_COLOR(vLineColor, geometry);
|
|
3161
3161
|
}
|
|
3162
|
-
`,
|
|
3162
|
+
`,eL=`#version 300 es
|
|
3163
3163
|
#define SHADER_NAME text-background-layer-fragment-shader
|
|
3164
3164
|
precision highp float;
|
|
3165
3165
|
in vec4 vFillColor;
|
|
@@ -3212,7 +3212,7 @@ fragColor = vFillColor;
|
|
|
3212
3212
|
}
|
|
3213
3213
|
DECKGL_FILTER_COLOR(fragColor, geometry);
|
|
3214
3214
|
}
|
|
3215
|
-
`,
|
|
3215
|
+
`,tL={billboard:!0,sizeScale:1,sizeUnits:`pixels`,sizeMinPixels:0,sizeMaxPixels:2**53-1,fontSize:1,borderRadius:{type:`object`,value:0},padding:{type:`array`,value:[0,0,0,0]},getPosition:{type:`accessor`,value:e=>e.position},getSize:{type:`accessor`,value:1},getAngle:{type:`accessor`,value:0},getPixelOffset:{type:`accessor`,value:[0,0]},getBoundingRect:{type:`accessor`,value:[0,0,0,0]},getClipRect:{type:`accessor`,value:[0,0,-1,-1]},getFillColor:{type:`accessor`,value:[0,0,0,255]},getLineColor:{type:`accessor`,value:[0,0,0,255]},getLineWidth:{type:`accessor`,value:1}},nL=class extends OP{getShaders(){return super.getShaders({vs:$I,fs:eL,modules:[gw,cT,QI,mI]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:`float64`,fp64:this.use64bitPositions(),transition:!0,accessor:`getPosition`},instanceSizes:{size:1,transition:!0,accessor:`getSize`,defaultValue:1},instanceAngles:{size:1,transition:!0,accessor:`getAngle`},instanceRects:{size:4,accessor:`getBoundingRect`},instanceClipRect:{size:4,accessor:`getClipRect`,defaultValue:[0,0,-1,-1]},instancePixelOffsets:{size:2,transition:!0,accessor:`getPixelOffset`},instanceFillColors:{size:4,transition:!0,type:`unorm8`,accessor:`getFillColor`,defaultValue:[0,0,0,255]},instanceLineColors:{size:4,transition:!0,type:`unorm8`,accessor:`getLineColor`,defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:`getLineWidth`,defaultValue:1}})}updateState(e){super.updateState(e);let{changeFlags:t}=e;t.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{billboard:t,sizeScale:n,sizeUnits:r,sizeMinPixels:i,sizeMaxPixels:a,getLineWidth:o,fontSize:s}=this.props,{padding:c,borderRadius:l}=this.props;c.length<4&&(c=[c[0],c[1],c[0],c[1]]),Array.isArray(l)||(l=[l,l,l,l]);let u=this.state.model,d={billboard:t,stroked:!!o,borderRadius:l,padding:c,sizeUnits:JC[r],sizeScale:n,sizeMinPixels:i,sizeMaxPixels:a},f={fontSize:s,viewport:this.context.viewport};u.shaderInputs.setProps({textBackground:d,text:f}),u.draw(this.context.renderPass)}_getModel(){let e=[0,0,1,0,0,1,1,1];return new hD(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new vD({topology:`triangle-strip`,vertexCount:4,attributes:{positions:{size:2,value:new Float32Array(e)}}}),isInstanced:!0})}};nL.defaultProps=tL,nL.layerName=`TextBackgroundLayer`;var rL={start:1,middle:0,end:-1},iL={top:1,center:0,bottom:-1},aL=[0,0,0,255],oL={billboard:!0,sizeScale:1,sizeUnits:`pixels`,sizeMinPixels:0,sizeMaxPixels:2**53-1,background:!1,getBackgroundColor:{type:`accessor`,value:[255,255,255,255]},getBorderColor:{type:`accessor`,value:aL},getBorderWidth:{type:`accessor`,value:0},backgroundBorderRadius:{type:`object`,value:0},backgroundPadding:{type:`array`,value:[0,0,0,0]},characterSet:{type:`object`,value:RI.characterSet},fontFamily:RI.fontFamily,fontWeight:RI.fontWeight,lineHeight:1,outlineWidth:{type:`number`,value:0,min:0},outlineColor:{type:`color`,value:aL},fontSettings:{type:`object`,value:{},compare:1},wordBreak:`break-word`,maxWidth:{type:`number`,value:-1},contentCutoffPixels:{type:`array`,value:[0,0]},contentAlignHorizontal:`none`,contentAlignVertical:`none`,getText:{type:`accessor`,value:e=>e.text},getPosition:{type:`accessor`,value:e=>e.position},getColor:{type:`accessor`,value:aL},getSize:{type:`accessor`,value:32},getAngle:{type:`accessor`,value:0},getTextAnchor:{type:`accessor`,value:`middle`},getAlignmentBaseline:{type:`accessor`,value:`center`},getPixelOffset:{type:`accessor`,value:[0,0]},getContentBox:{type:`accessor`,value:[0,0,-1,-1]},backgroundColor:{deprecatedFor:[`background`,`getBackgroundColor`]}},sL=class extends PP{constructor(){super(...arguments),this.getBoundingRect=(e,t)=>{let{size:[n,r]}=this.transformParagraph(e,t),{getTextAnchor:i,getAlignmentBaseline:a}=this.props,o=rL[typeof i==`function`?i(e,t):i],s=iL[typeof a==`function`?a(e,t):a];return[(o-1)*n/2,(s-1)*r/2,n,r]},this.getIconOffsets=(e,t)=>{let{getTextAnchor:n,getAlignmentBaseline:r}=this.props,{x:i,y:a,rowWidth:o,size:[,s]}=this.transformParagraph(e,t),c=rL[typeof n==`function`?n(e,t):n],l=iL[typeof r==`function`?r(e,t):r],u=i.length,d=Array(u*2),f=0;for(let e=0;e<u;e++)d[f++]=(c-1)*o[e]/2+i[e],d[f++]=(l-1)*s/2+a[e];return d}}initializeState(){this.state={styleVersion:0,fontAtlasManager:new YI},this.props.maxWidth>0&&X.once(1,`v8.9 breaking change: TextLayer maxWidth is now relative to text size`)()}updateState(e){let{props:t,oldProps:n,changeFlags:r}=e;(r.dataChanged||r.updateTriggersChanged&&(r.updateTriggersChanged.all||r.updateTriggersChanged.getText))&&this._updateText(),(this._updateFontAtlas()||t.lineHeight!==n.lineHeight||t.wordBreak!==n.wordBreak||t.maxWidth!==n.maxWidth)&&this.setState({styleVersion:this.state.styleVersion+1})}getPickingInfo({info:e}){return e.object=e.index>=0?this.props.data[e.index]:null,e}_updateFontAtlas(){let{fontSettings:e,fontFamily:t,fontWeight:n,_getFontRenderer:r}=this.props,{fontAtlasManager:i,characterSet:a}=this.state,o={...e,characterSet:a,fontFamily:t,fontWeight:n,_getFontRenderer:r};if(!i.mapping)return i.setProps(o),!0;for(let e in o)if(o[e]!==i.props[e])return i.setProps(o),!0;return!1}_updateText(){let{data:e,characterSet:t}=this.props,n=e.attributes?.getText,{getText:r}=this.props,i=e.startIndices,a,o=t===`auto`&&new Set;if(n&&i){let{texts:t,characterCount:s}=FI({...ArrayBuffer.isView(n)?{value:n}:n,length:e.length,startIndices:i,characterSet:o});a=s,r=(e,{index:n})=>t[n]}else{let{iterable:t,objectInfo:n}=LM(e);i=[0],a=0;for(let e of t){n.index++;let t=Array.from(r(e,n)||``);o&&t.forEach(o.add,o),a+=t.length,i.push(a)}}this.setState({getText:r,startIndices:i,numInstances:a,characterSet:o||t})}transformParagraph(e,t){let{fontAtlasManager:n}=this.state,r=n.mapping,{baselineOffset:i}=n.atlas,{fontSize:a}=n.props,o=this.state.getText,{wordBreak:s,lineHeight:c,maxWidth:l}=this.props;return PI(o(e,t)||``,i,c*a,s,l*a,r)}renderLayers(){let{startIndices:e,numInstances:t,getText:n,fontAtlasManager:{atlas:r,mapping:i},styleVersion:a}=this.state,{data:o,_dataDiff:s,getPosition:c,getColor:l,getSize:u,getAngle:d,getPixelOffset:f,getBackgroundColor:p,getBorderColor:m,getBorderWidth:h,getContentBox:g,backgroundBorderRadius:_,backgroundPadding:v,background:y,billboard:b,fontSettings:x,outlineWidth:S,outlineColor:C,sizeScale:w,sizeUnits:T,sizeMinPixels:E,sizeMaxPixels:ee,contentCutoffPixels:te,contentAlignHorizontal:ne,contentAlignVertical:D,transitions:O,updateTriggers:k}=this.props,re=this.getSubLayerClass(`characters`,yI),ie=this.getSubLayerClass(`background`,nL),{fontSize:ae}=this.state.fontAtlasManager.props;return[y&&new ie({getFillColor:p,getLineColor:m,getLineWidth:h,borderRadius:_,padding:v,getPosition:c,getSize:u,getAngle:d,getPixelOffset:f,getClipRect:g,billboard:b,sizeScale:w,sizeUnits:T,sizeMinPixels:E,sizeMaxPixels:ee,fontSize:ae,transitions:O&&{getPosition:O.getPosition,getAngle:O.getAngle,getSize:O.getSize,getFillColor:O.getBackgroundColor,getLineColor:O.getBorderColor,getLineWidth:O.getBorderWidth,getPixelOffset:O.getPixelOffset}},this.getSubLayerProps({id:`background`,updateTriggers:{getPosition:k.getPosition,getAngle:k.getAngle,getSize:k.getSize,getFillColor:k.getBackgroundColor,getLineColor:k.getBorderColor,getLineWidth:k.getBorderWidth,getPixelOffset:k.getPixelOffset,getBoundingRect:{getText:k.getText,getTextAnchor:k.getTextAnchor,getAlignmentBaseline:k.getAlignmentBaseline,styleVersion:a}}}),{data:o.attributes&&o.attributes.background?{length:o.length,attributes:o.attributes.background}:o,_dataDiff:s,autoHighlight:!1,getBoundingRect:this.getBoundingRect}),new re({sdf:x.sdf,smoothing:Number.isFinite(x.smoothing)?x.smoothing:RI.smoothing,outlineWidth:S/(x.radius||RI.radius),outlineColor:C,iconAtlas:r,iconMapping:i,getPosition:c,getColor:l,getSize:u,getAngle:d,getPixelOffset:f,getContentBox:g,billboard:b,sizeScale:w,sizeUnits:T,sizeMinPixels:E,sizeMaxPixels:ee,fontSize:ae,contentCutoffPixels:te,contentAlignHorizontal:ne,contentAlignVertical:D,transitions:O&&{getPosition:O.getPosition,getAngle:O.getAngle,getColor:O.getColor,getSize:O.getSize,getPixelOffset:O.getPixelOffset,getContentBox:O.getContentBox}},this.getSubLayerProps({id:`characters`,updateTriggers:{all:k.getText,getPosition:k.getPosition,getAngle:k.getAngle,getColor:k.getColor,getSize:k.getSize,getPixelOffset:k.getPixelOffset,getContentBox:k.getContentBox,getIconOffsets:{getTextAnchor:k.getTextAnchor,getAlignmentBaseline:k.getAlignmentBaseline,styleVersion:a}}}),{data:o,_dataDiff:s,startIndices:e,numInstances:t,getIconOffsets:this.getIconOffsets,getIcon:n})]}static set fontAtlasCacheLimit(e){JI(e)}};sL.defaultProps=oL,sL.layerName=`TextLayer`;var cL={inject:{"vs:#decl":`
|
|
3216
3216
|
in vec2 instanceDashArrays;
|
|
3217
3217
|
#ifdef HIGH_PRECISION_DASH
|
|
3218
3218
|
in float instanceDashOffsets;
|
|
@@ -3264,7 +3264,7 @@ discard;
|
|
|
3264
3264
|
}
|
|
3265
3265
|
}
|
|
3266
3266
|
}
|
|
3267
|
-
`}},
|
|
3267
|
+
`}},lL={inject:{"vs:#decl":`
|
|
3268
3268
|
in vec2 instanceDashArrays;
|
|
3269
3269
|
out vec2 vDashArray;
|
|
3270
3270
|
`,"vs:#main-end":`
|
|
@@ -3306,7 +3306,7 @@ fragColor = vec4(vFillColor.rgb, vFillColor.a * alphaFactor);
|
|
|
3306
3306
|
fragColor = picking_filterPickingColor(fragColor);
|
|
3307
3307
|
fragColor = picking_filterHighlightColor(fragColor);
|
|
3308
3308
|
}
|
|
3309
|
-
`}},
|
|
3309
|
+
`}},uL={inject:{"vs:#decl":`
|
|
3310
3310
|
in vec2 instanceDashArrays;
|
|
3311
3311
|
out vec2 vDashArray;
|
|
3312
3312
|
`,"vs:#main-end":`
|
|
@@ -3428,7 +3428,7 @@ fragColor = vec4(vFillColor.rgb, vFillColor.a * alphaFactor);
|
|
|
3428
3428
|
fragColor = picking_filterPickingColor(fragColor);
|
|
3429
3429
|
fragColor = picking_filterHighlightColor(fragColor);
|
|
3430
3430
|
}
|
|
3431
|
-
`}},
|
|
3431
|
+
`}},dL={inject:{"vs:#decl":`
|
|
3432
3432
|
in float instanceOffsets;
|
|
3433
3433
|
`,"vs:DECKGL_FILTER_SIZE":`
|
|
3434
3434
|
float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;
|
|
@@ -3445,13 +3445,13 @@ isInside = step(-1.0, vPathPosition.x) * step(vPathPosition.x, 1.0);
|
|
|
3445
3445
|
if (isInside == 0.0) {
|
|
3446
3446
|
discard;
|
|
3447
3447
|
}
|
|
3448
|
-
`}},
|
|
3448
|
+
`}},fL={getDashArray:{type:`accessor`,value:[0,0]},getOffset:{type:`accessor`,value:0},dashJustified:!1,dashGapPickable:!1},pL=class extends HP{constructor({dash:e=!1,offset:t=!1,highPrecisionDash:n=!1}={}){super({dash:e||n,offset:t,highPrecisionDash:n})}getLayerType(e){if(`pathTesselator`in e.state)return`path`;let t=e.constructor.layerName;return t===`ScatterplotLayer`?`scatterplot`:t===`TextBackgroundLayer`?`textBackground`:null}isEnabled(e){return this.getLayerType(e)!==null}getShaders(e){let t=e.getLayerType(this);if(!t)return null;if(t===`scatterplot`||t===`textBackground`)return e.opts.dash?{modules:[{name:`pathStyle`,inject:t===`scatterplot`?lL.inject:uL.inject,uniformTypes:{dashGapPickable:`i32`}}]}:null;let n={},r={};e.opts.dash&&(n=GN(n,cL),e.opts.highPrecisionDash&&(r.HIGH_PRECISION_DASH=!0)),e.opts.offset&&(n=GN(n,dL));let{inject:i}=n;return{modules:[{name:`pathStyle`,inject:i,uniformTypes:{dashAlignMode:`f32`,dashGapPickable:`i32`}}],defines:r}}initializeState(e,t){let n=this.getAttributeManager(),r=t.getLayerType(this);!n||!r||(t.opts.dash&&n.addInstanced({instanceDashArrays:{size:2,accessor:`getDashArray`},...r===`path`&&t.opts.highPrecisionDash?{instanceDashOffsets:{size:1,accessor:`getPath`,transform:t.getDashOffsets.bind(this)}}:{}}),r===`path`&&t.opts.offset&&n.addInstanced({instanceOffsets:{size:1,accessor:`getOffset`}}))}updateState(e,t){if(t.isEnabled(this)&&t.opts.dash){let e=t.getLayerType(this);if(e===`scatterplot`||e===`textBackground`){let e={dashGapPickable:!!this.props.dashGapPickable};this.setShaderModuleProps({pathStyle:e})}else{let e={dashAlignMode:+!!this.props.dashJustified,dashGapPickable:!!this.props.dashGapPickable};this.setShaderModuleProps({pathStyle:e})}}}getDashOffsets(e){let t=[0],n=this.props.positionFormat===`XY`?2:3,r=Array.isArray(e[0]),i=r?e.length:e.length/n,a,o;for(let s=0;s<i-1;s++)a=r?e[s]:e.slice(s*n,s*n+n),a=this.projectPosition(a),s>0&&(t[s]=t[s-1]+av(o,a)),o=a;return t[i-1]=0,t}};pL.defaultProps=fL,pL.extensionName=`PathStyleExtension`;function mL(e,t,n,r){let i=t*Math.PI/180,a=r*Math.PI/180,o=(n-e)*Math.PI/180,s=Math.sin(o)*Math.cos(a),c=Math.cos(i)*Math.sin(a)-Math.sin(i)*Math.cos(a)*Math.cos(o);return(Math.atan2(s,c)*180/Math.PI+360)%360}function hL(e,t,n,r){let i=t*Math.PI/180,a=r*Math.PI/180,o=(r-t)*Math.PI/180,s=(n-e)*Math.PI/180,c=Math.sin(o/2)**2+Math.cos(i)*Math.cos(a)*Math.sin(s/2)**2;return 2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c))*3440.065}function gL(e,t,n,r,i=64){let a=t*Math.PI/180,o=e*Math.PI/180,s=r*Math.PI/180,c=n*Math.PI/180,l=2*Math.asin(Math.sqrt(Math.sin((s-a)/2)**2+Math.cos(a)*Math.cos(s)*Math.sin((c-o)/2)**2));if(l<1e-10)return[[e,t],[n,r]];let u=[],d=o;for(let e=0;e<=i;e++){let t=e/i,n=Math.sin((1-t)*l)/Math.sin(l),r=Math.sin(t*l)/Math.sin(l),f=n*Math.cos(a)*Math.cos(o)+r*Math.cos(s)*Math.cos(c),p=n*Math.cos(a)*Math.sin(o)+r*Math.cos(s)*Math.sin(c),m=n*Math.sin(a)+r*Math.sin(s),h=Math.atan2(m,Math.sqrt(f*f+p*p)),g=Math.atan2(p,f)-d,_=d+g-Math.round(g/(2*Math.PI))*2*Math.PI;d=_,u.push([_*180/Math.PI,h*180/Math.PI])}return u}function _L(e){return mL(e.a.lon,e.a.lat,e.b.lon,e.b.lat).toFixed(0).padStart(3,`0`)+`° T`}function vL(e){let t=hL(e.a.lon,e.a.lat,e.b.lon,e.b.lat);return(t<10?t.toFixed(2):t.toFixed(1))+` NM`}function yL(){return Math.random().toString(36).slice(2,9)}function bL(){let e=F(fn([]));return{get rulers(){return V(e)},add(t,n,r,i){I(e,[...V(e),{id:yL(),a:{lon:t,lat:n},b:{lon:r,lat:i}}],!0)},remove(t){I(e,V(e).filter(e=>e.id!==t),!0)},moveEndpoint(t,n,r,i){I(e,V(e).map(e=>{if(e.id!==t)return e;let a={lon:r,lat:i};return{...e,[n]:a}}),!0)},snapEndpoint(t,n,r,i,a){I(e,V(e).map(e=>{if(e.id!==t)return e;let o=r?{lon:i,lat:a,snapId:r}:{lon:i,lat:a};return{...e,[n]:o}}),!0)},syncSnapped(t){let n=new Map(t.map(e=>[e.id,e])),r=!1,i=V(e).map(e=>{let{a:t,b:i}=e;if(t.snapId){let e=n.get(t.snapId);e?.position&&(e.position.longitude!==t.lon||e.position.latitude!==t.lat)&&(t={...t,lon:e.position.longitude,lat:e.position.latitude},r=!0)}if(i.snapId){let e=n.get(i.snapId);e?.position&&(e.position.longitude!==i.lon||e.position.latitude!==i.lat)&&(i={...i,lon:e.position.longitude,lat:e.position.latitude},r=!0)}return r?{...e,a:t,b:i}:e});r&&I(e,i,!0)}}}var xL=bL(),SL=F(null),CL=F(null),wL=F(null),TL=F(null),EL=F(0),DL=F(!1),OL=F(null),kL=F(!1),AL=F(null);async function jL(e,t){let n;n=t.startsWith(`http`)?t:`${e}/signalk/v2/api${t.startsWith(`/signalk/v2/api`)||t.startsWith(`/signalk/v1/api`)?t.slice(15):t.startsWith(`/v1/api`)?t.slice(7):t}`,console.debug(`[route] fetching geometry from`,n);let r=await fetch(n);if(!r.ok)throw Error(`Route fetch failed: ${r.status} ${r.statusText}`);let i=await r.json();if(console.debug(`[route] REST response keys:`,Object.keys(i??{}),`type:`,i?.type,`featureType:`,i?.feature?.type),i?.feature?.geometry?.type===`LineString`)return i.feature;if(i?.type===`Feature`&&i?.geometry?.type===`LineString`)return i;if(i?.type===`FeatureCollection`){let e=i.features.find(e=>e.geometry?.type===`LineString`);if(e)return e}return console.warn(`[route] unrecognised route REST response format:`,JSON.stringify(i).slice(0,300)),null}function ML(){return{get nextPoint(){return V(SL)},get previousPoint(){return V(CL)},get activeHref(){return V(wL)},get routeName(){return V(TL)},get pointIndex(){return V(EL)},get reverse(){return V(DL)},get geometry(){return V(OL)},get loading(){return V(kL)},get error(){return V(AL)},update(e,t){I(SL,t?.nextPoint??null,!0),I(CL,t?.previousPoint??null,!0);let n=t?.activeRoute,r=n?.href??null;console.debug(`[route] update — nextPoint:`,!!V(SL),`prevPoint:`,!!V(CL),`href:`,r),n&&(I(TL,n.name??null,!0),I(EL,n.pointIndex,!0),I(DL,n.reverse,!0)),r!==V(wL)&&(I(wL,r,!0),I(OL,null),I(AL,null),r?(I(kL,!0),jL(e,r).then(e=>{I(OL,e,!0),I(kL,!1),console.debug(`[route] geometry loaded:`,!!e)}).catch(e=>{I(AL,String(e),!0),I(kL,!1),console.warn(`[route] fetch error:`,e)})):I(kL,!1))},clear(){I(SL,I(CL,I(wL,I(TL,I(OL,I(AL,null),!0),!0),!0),!0),!0),I(EL,0),I(DL,I(kL,!1),!0)}}}var NL=ML(),PL={"Open Sans Regular":`Roboto Regular`,"Open Sans Bold":`Roboto Bold`,"Open Sans SemiBold":`Roboto Medium`,"Open Sans Italic":`Roboto Italic`,"Open Sans Bold Italic":`Roboto Bold`,"Arial Unicode MS Regular":`Roboto Regular`,"Arial Unicode MS Bold":`Roboto Bold`,"Arial Unicode MS":`Roboto Regular`};function FL(e){if(typeof e==`string`)return PL[e]??e;if(Array.isArray(e))return e.map(FL);if(typeof e==`object`&&e){let t={};for(let[n,r]of Object.entries(e))t[n]=FL(r);return t}return e}async function IL(e){let t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch style ${e}: ${t.status} ${t.statusText}`);let n=FL(await t.json()),r=n.schema,i=new Map;if(r)for(let[e,t]of Object.entries(r))i.set(e,t.default);let a=RL(n,i),o=a.sources,s=new Set;if(o)for(let[e,t]of Object.entries(o))typeof t.url==`string`&&t.url.startsWith(`mapbox://`)&&(s.add(e),delete o[e]);return Array.isArray(a.layers)&&(a.layers=a.layers.filter(e=>e.type!==`slot`&&!s.has(e.source))),a}var LL=new Set([`pitch`,`distance-from-center`]);function RL(e,t){if(!Array.isArray(e)){if(typeof e==`object`&&e){let n={};for(let[r,i]of Object.entries(e))n[r]=RL(i,t);return n}return e}let n=e[0];return n===`config`&&e.length===2&&typeof e[1]==`string`?t.has(e[1])?t.get(e[1]):null:typeof n==`string`&&LL.has(n)&&e.length===1?0:zL(e.map(e=>RL(e,t)))}function zL(e){let t=e[0];if(typeof t!=`string`)return e;if(t.includes(` `)&&e.every(e=>typeof e==`string`))return[`literal`,e];if(e.length<2)return e;let n=e.slice(1);if(n.every(e=>typeof e==`number`)){let r=n;switch(t){case`*`:return r.reduce((e,t)=>e*t);case`/`:return r.length===2&&r[1]!==0?r[0]/r[1]:e;case`+`:return r.reduce((e,t)=>e+t);case`-`:return r.length===2?r[0]-r[1]:e;case`^`:return r.length===2?r[0]**+r[1]:e;case`min`:return Math.min(...r);case`max`:return Math.max(...r);case`abs`:return r.length===1?Math.abs(r[0]):e;case`ceil`:return r.length===1?Math.ceil(r[0]):e;case`floor`:return r.length===1?Math.floor(r[0]):e;case`round`:return r.length===1?Math.round(r[0]):e}}if(t===`coalesce`){let e=n.find(e=>e!=null);if(e!==void 0)return e}if(t===`step`){let t=[...e];for(let e=2;e<t.length;e+=2)t[e]=BL(t[e]);return t}if(t===`match`){let t=[...e];for(let e=3;e<t.length-1;e+=2)t[e]=BL(t[e]);return t[t.length-1]=BL(t[t.length-1]),t}if(t===`case`){let t=[...e];for(let e=2;e<t.length-1;e+=2)t[e]=BL(t[e]);return t[t.length-1]=BL(t[t.length-1]),t}return e}function BL(e){return Array.isArray(e)&&e.length>0&&e.every(e=>typeof e==`string`)&&typeof e[0]==`string`&&e[0].includes(` `)?[`literal`,e]:e}var VL=`uniform aisHullUniforms {
|
|
3449
3449
|
float timeSinceUpload;
|
|
3450
3450
|
float zoom;
|
|
3451
3451
|
float settingsIconSize;
|
|
3452
3452
|
float opacity;
|
|
3453
3453
|
} aisHull;
|
|
3454
|
-
`,
|
|
3454
|
+
`,HL={name:`aisHull`,vs:VL,fs:VL,uniformTypes:{timeSinceUpload:`f32`,zoom:`f32`,settingsIconSize:`f32`,opacity:`f32`}},UL=`#version 300 es
|
|
3455
3455
|
#define SHADER_NAME ais-hull-layer-vertex-shader
|
|
3456
3456
|
|
|
3457
3457
|
in vec3 positions; // hull vertex in local space (X=sb, Y=bow, unit [-1,1])
|
|
@@ -3564,7 +3564,7 @@ void main(void) {
|
|
|
3564
3564
|
geometry.pickingColor = instancePickingColors;
|
|
3565
3565
|
DECKGL_FILTER_COLOR(vColor, geometry);
|
|
3566
3566
|
}
|
|
3567
|
-
`,
|
|
3567
|
+
`,WL=`#version 300 es
|
|
3568
3568
|
precision highp float;
|
|
3569
3569
|
#define SHADER_NAME ais-hull-layer-fragment-shader
|
|
3570
3570
|
|
|
@@ -3575,7 +3575,7 @@ void main(void) {
|
|
|
3575
3575
|
fragColor = vColor;
|
|
3576
3576
|
DECKGL_FILTER_COLOR(fragColor, geometry);
|
|
3577
3577
|
}
|
|
3578
|
-
`,
|
|
3578
|
+
`,GL=new Float32Array([0,1,0,1,.6,0,1,-1,0,0,1,0,1,-1,0,-1,-1,0,0,1,0,-1,-1,0,-1,.6,0]),KL=9,qL={getPosition:{type:`accessor`,value:[0,0]},getSog:{type:`accessor`,value:0},getCog:{type:`accessor`,value:0},getHeading:{type:`accessor`,value:0},getRot:{type:`accessor`,value:0},getAgeAtUpload:{type:`accessor`,value:0},getLength:{type:`accessor`,value:50},getBeam:{type:`accessor`,value:10},getColor:{type:`accessor`,value:[0,100,200,220]},uploadTimestamp:0,selfAnimate:!1,settingsIconSize:1,opacity:1},JL=class extends OP{static layerName=`AisHullLayer`;static defaultProps=qL;getShaders(){return super.getShaders({vs:UL,fs:WL,modules:[gw,cT,HL]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:`float64`,fp64:this.use64bitPositions(),transition:!0,accessor:`getPosition`,defaultValue:[0,0,0]},instanceSog:{size:1,accessor:`getSog`,defaultValue:0},instanceCog:{size:1,accessor:`getCog`,defaultValue:0},instanceHeading:{size:1,accessor:`getHeading`,defaultValue:0},instanceRot:{size:1,accessor:`getRot`,defaultValue:0},instanceAgeAtUpload:{size:1,accessor:`getAgeAtUpload`,defaultValue:0},instanceLength:{size:1,accessor:`getLength`,defaultValue:50},instanceBeam:{size:1,accessor:`getBeam`,defaultValue:10},instanceColor:{size:4,type:`unorm8`,accessor:`getColor`,defaultValue:[0,100,200,220]}})}updateState(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll()),e.changeFlags.propsChanged&&this.setNeedsRedraw()}draw({uniforms:e}){let{uploadTimestamp:t,selfAnimate:n,settingsIconSize:r,opacity:i}=this.props,a=n?Math.max(0,(Date.now()-(t??0))/1e3):0,o=this.context.viewport.zoom,s=this.state.model;s.shaderInputs.setProps({aisHull:{timeSinceUpload:a,zoom:o,settingsIconSize:r??1,opacity:i??1}}),s.draw(this.context.renderPass),n&&this.setNeedsRedraw()}_getModel(){return new hD(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new vD({topology:`triangle-list`,attributes:{positions:{size:3,value:GL}},vertexCount:KL}),isInstanced:!0})}};function YL(e){let t=[[0,1],[1,.6],[1,-1],[-1,-1],[-1,.6]],n=[];for(let r=0;r<t.length;r++){let[i,a]=t[r],[o,s]=t[(r+1)%t.length];n.push(...iR(i,a,o,s,e))}return $L(n)}var XL=YL(.05),ZL=`#version 300 es
|
|
3579
3579
|
#define SHADER_NAME ais-hull-decoration-vertex-shader
|
|
3580
3580
|
|
|
3581
3581
|
in vec3 positions;
|
|
@@ -3636,7 +3636,7 @@ void main(void) {
|
|
|
3636
3636
|
float t01 = clamp((aisHull.zoom - transitionZoom + 1.0) / 2.0, 0.0, 1.0);
|
|
3637
3637
|
vOpacity = t01;
|
|
3638
3638
|
}
|
|
3639
|
-
`,
|
|
3639
|
+
`,QL=`#version 300 es
|
|
3640
3640
|
precision highp float;
|
|
3641
3641
|
#define SHADER_NAME ais-hull-decoration-fragment-shader
|
|
3642
3642
|
|
|
@@ -3647,13 +3647,87 @@ void main(void) {
|
|
|
3647
3647
|
fragColor = vec4(0.0, 0.0, 0.0, vOpacity);
|
|
3648
3648
|
DECKGL_FILTER_COLOR(fragColor, geometry);
|
|
3649
3649
|
}
|
|
3650
|
-
`;function
|
|
3650
|
+
`;function $L(e){return{positions:new Float32Array(e),vertexCount:e.length/3}}function eR(e,t,n,r){let i=[];for(let a=0;a<r;a++){let o=a/r*2*Math.PI,s=(a+1)/r*2*Math.PI;i.push(e,t,0,e+n*Math.sin(o),t+n*Math.cos(o),0,e+n*Math.sin(s),t+n*Math.cos(s),0)}return i}function tR(e,t,n,r){return[e,t,0,n,t,0,n,r,0,e,t,0,n,r,0,e,r,0]}function nR(e,t,n){let r=[];for(let i=0;i<n;i++){let a=i/n*2*Math.PI,o=(i+1)/n*2*Math.PI;r.push(e*Math.sin(a),e*Math.cos(a),0,t*Math.sin(a),t*Math.cos(a),0,t*Math.sin(o),t*Math.cos(o),0,e*Math.sin(a),e*Math.cos(a),0,t*Math.sin(o),t*Math.cos(o),0,e*Math.sin(o),e*Math.cos(o),0)}return r}function rR(e,t,n,r){return[e,t,0,e,t+r,0,e+n,t,0,e,t,0,e+n,t,0,e,t-r,0,e,t,0,e,t-r,0,e-n,t,0,e,t,0,e-n,t,0,e,t+r,0]}function iR(e,t,n,r,i){let a=n-e,o=r-t,s=Math.sqrt(a*a+o*o),c=-o/s*i,l=a/s*i;return[e+c,t+l,0,e-c,t-l,0,n-c,r-l,0,e+c,t+l,0,n-c,r-l,0,n+c,r+l,0]}function aR(e,t,n,r,i,a,o){let s=[];for(let c=0;c<o;c++){let l=c/o,u=(c+1)/o,d=(i+(a-i)*l)*Math.PI/180,f=(i+(a-i)*u)*Math.PI/180,p=Math.sin(d),m=Math.cos(d),h=Math.sin(f),g=Math.cos(f);s.push(e+n*p,t+n*m,0,e+r*p,t+r*m,0,e+r*h,t+r*g,0,e+n*p,t+n*m,0,e+r*h,t+r*g,0,e+n*h,t+n*g,0)}return s}var oR=$L(eR(0,.65,.12,8)),sR=$L([...tR(-1.35,-.55,-1.1,.22),...tR(1.1,-.55,1.35,.22)]),cR=$L(nR(1.3,1.5,16)),lR=$L([...iR(-.8,0,-1.5,-.5,.055),...iR(.8,0,1.5,-.5,.055),...aR(0,.3,1.62,1.78,242,118,18)]),uR=$L([...eR(0,.45,.1,10),...eR(0,.12,.1,10)]),dR=$L([...eR(0,.55,.09,10),...rR(0,.15,.13,.13),...eR(0,-.25,.09,10)]),fR=$L([...tR(-1.35,-.85,-1.1,.85),...tR(1.1,-.85,1.35,.85)]),pR={getPosition:{type:`accessor`,value:[0,0]},getSog:{type:`accessor`,value:0},getCog:{type:`accessor`,value:0},getHeading:{type:`accessor`,value:0},getRot:{type:`accessor`,value:0},getAgeAtUpload:{type:`accessor`,value:0},getLength:{type:`accessor`,value:50},getBeam:{type:`accessor`,value:10},uploadTimestamp:0,selfAnimate:!1,settingsIconSize:1,decoration:{type:`object`,value:oR}},mR=class extends OP{static layerName=`AisHullDecorationLayer`;static defaultProps=pR;getShaders(){return super.getShaders({vs:ZL,fs:QL,modules:[gw,HL]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:`float64`,fp64:this.use64bitPositions(),transition:!0,accessor:`getPosition`,defaultValue:[0,0,0]},instanceSog:{size:1,accessor:`getSog`,defaultValue:0},instanceCog:{size:1,accessor:`getCog`,defaultValue:0},instanceHeading:{size:1,accessor:`getHeading`,defaultValue:0},instanceRot:{size:1,accessor:`getRot`,defaultValue:0},instanceAgeAtUpload:{size:1,accessor:`getAgeAtUpload`,defaultValue:0},instanceLength:{size:1,accessor:`getLength`,defaultValue:50},instanceBeam:{size:1,accessor:`getBeam`,defaultValue:10}})}updateState(e){super.updateState(e),(e.changeFlags.extensionsChanged||e.changeFlags.propsChanged&&e.oldProps.decoration!==e.props.decoration)&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll()),e.changeFlags.propsChanged&&this.setNeedsRedraw()}draw({uniforms:e}){let{uploadTimestamp:t,selfAnimate:n,settingsIconSize:r}=this.props,i=n?Math.max(0,(Date.now()-(t??0))/1e3):0,a=this.context.viewport.zoom,o=this.state.model;o.shaderInputs.setProps({aisHull:{timeSinceUpload:i,zoom:a,settingsIconSize:r??1,opacity:1}}),o.draw(this.context.renderPass),n&&this.setNeedsRedraw()}_getModel(){let{positions:e,vertexCount:t}=this.props.decoration;return new hD(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new vD({topology:`triangle-list`,attributes:{positions:{size:3,value:e}},vertexCount:t}),isInstanced:!0})}},hR=`#version 300 es
|
|
3651
|
+
#define SHADER_NAME ais-hull-border-vertex-shader
|
|
3652
|
+
|
|
3653
|
+
in vec3 positions;
|
|
3654
|
+
in vec3 instancePositions;
|
|
3655
|
+
in vec3 instancePositions64Low;
|
|
3656
|
+
in float instanceSog;
|
|
3657
|
+
in float instanceCog;
|
|
3658
|
+
in float instanceHeading;
|
|
3659
|
+
in float instanceRot;
|
|
3660
|
+
in float instanceAgeAtUpload;
|
|
3661
|
+
in float instanceLength;
|
|
3662
|
+
in float instanceBeam;
|
|
3663
|
+
in vec4 instanceBorderColor; // unorm8 RGBA
|
|
3664
|
+
|
|
3665
|
+
out vec4 vColor;
|
|
3666
|
+
|
|
3667
|
+
void main(void) {
|
|
3668
|
+
float dt = min(instanceAgeAtUpload + aisHull.timeSinceUpload, 180.0);
|
|
3669
|
+
|
|
3670
|
+
float dEast, dNorth;
|
|
3671
|
+
if (abs(instanceRot) > 1e-4) {
|
|
3672
|
+
float cogEnd = instanceCog + instanceRot * dt;
|
|
3673
|
+
float R = instanceSog / instanceRot;
|
|
3674
|
+
dEast = R * (cos(instanceCog) - cos(cogEnd));
|
|
3675
|
+
dNorth = R * (sin(cogEnd) - sin(instanceCog));
|
|
3676
|
+
} else {
|
|
3677
|
+
dEast = instanceSog * dt * sin(instanceCog);
|
|
3678
|
+
dNorth = instanceSog * dt * cos(instanceCog);
|
|
3679
|
+
}
|
|
3680
|
+
|
|
3681
|
+
float safelen = max(instanceLength, 1.0);
|
|
3682
|
+
float safebeam = max(instanceBeam, 1.0);
|
|
3683
|
+
float localX = positions.x * safebeam * 0.5;
|
|
3684
|
+
float localY = positions.y * safelen * 0.5;
|
|
3685
|
+
|
|
3686
|
+
float heading = instanceHeading + instanceRot * dt;
|
|
3687
|
+
float sinH = sin(heading);
|
|
3688
|
+
float cosH = cos(heading);
|
|
3689
|
+
float hullEast = localY * sinH + localX * cosH;
|
|
3690
|
+
float hullNorth = localY * cosH - localX * sinH;
|
|
3691
|
+
|
|
3692
|
+
geometry.worldPosition = instancePositions;
|
|
3693
|
+
vec3 offset = project_size(vec3(dEast + hullEast, dNorth + hullNorth, 0.0));
|
|
3694
|
+
|
|
3695
|
+
vec4 worldPos;
|
|
3696
|
+
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset, worldPos);
|
|
3697
|
+
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
|
|
3698
|
+
|
|
3699
|
+
if (project.projectionMode == PROJECTION_MODE_GLOBE &&
|
|
3700
|
+
dot(worldPos.xyz, project.cameraPosition) < 0.0) {
|
|
3701
|
+
gl_Position = vec4(0.0, 0.0, -2.0, 1.0);
|
|
3702
|
+
}
|
|
3703
|
+
|
|
3704
|
+
// Same cross-fade as AisHullLayer — border fades in with the hull.
|
|
3705
|
+
float lat_rad = instancePositions.y * radians(1.0);
|
|
3706
|
+
float transitionZoom = log2(
|
|
3707
|
+
aisHull.settingsIconSize * 64.0 * 40075016.686 * cos(lat_rad) / (safelen * 256.0)
|
|
3708
|
+
);
|
|
3709
|
+
float t01 = clamp((aisHull.zoom - transitionZoom + 1.0) / 2.0, 0.0, 1.0);
|
|
3710
|
+
|
|
3711
|
+
vColor = vec4(instanceBorderColor.rgb, instanceBorderColor.a * t01 * aisHull.opacity);
|
|
3712
|
+
}
|
|
3713
|
+
`,gR=`#version 300 es
|
|
3714
|
+
precision highp float;
|
|
3715
|
+
#define SHADER_NAME ais-hull-border-fragment-shader
|
|
3716
|
+
|
|
3717
|
+
in vec4 vColor;
|
|
3718
|
+
out vec4 fragColor;
|
|
3719
|
+
|
|
3720
|
+
void main(void) {
|
|
3721
|
+
fragColor = vColor;
|
|
3722
|
+
DECKGL_FILTER_COLOR(fragColor, geometry);
|
|
3723
|
+
}
|
|
3724
|
+
`,_R={getPosition:{type:`accessor`,value:[0,0]},getSog:{type:`accessor`,value:0},getCog:{type:`accessor`,value:0},getHeading:{type:`accessor`,value:0},getRot:{type:`accessor`,value:0},getAgeAtUpload:{type:`accessor`,value:0},getLength:{type:`accessor`,value:50},getBeam:{type:`accessor`,value:10},getBorderColor:{type:`accessor`,value:[0,0,0,200]},uploadTimestamp:0,selfAnimate:!1,settingsIconSize:1,opacity:1},vR=class extends OP{static layerName=`AisHullBorderLayer`;static defaultProps=_R;getShaders(){return super.getShaders({vs:hR,fs:gR,modules:[gw,HL]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:`float64`,fp64:this.use64bitPositions(),transition:!0,accessor:`getPosition`,defaultValue:[0,0,0]},instanceSog:{size:1,accessor:`getSog`,defaultValue:0},instanceCog:{size:1,accessor:`getCog`,defaultValue:0},instanceHeading:{size:1,accessor:`getHeading`,defaultValue:0},instanceRot:{size:1,accessor:`getRot`,defaultValue:0},instanceAgeAtUpload:{size:1,accessor:`getAgeAtUpload`,defaultValue:0},instanceLength:{size:1,accessor:`getLength`,defaultValue:50},instanceBeam:{size:1,accessor:`getBeam`,defaultValue:10},instanceBorderColor:{size:4,type:`unorm8`,accessor:`getBorderColor`,defaultValue:[0,0,0,200]}})}updateState(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll()),e.changeFlags.propsChanged&&this.setNeedsRedraw()}draw({uniforms:e}){let{uploadTimestamp:t,selfAnimate:n,settingsIconSize:r,opacity:i}=this.props,a=n?Math.max(0,(Date.now()-(t??0))/1e3):0,o=this.context.viewport.zoom,s=this.state.model;s.shaderInputs.setProps({aisHull:{timeSinceUpload:a,zoom:o,settingsIconSize:r??1,opacity:i??1}}),s.draw(this.context.renderPass),n&&this.setNeedsRedraw()}_getModel(){let{positions:e,vertexCount:t}=XL;return new hD(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new vD({topology:`triangle-list`,attributes:{positions:{size:3,value:e}},vertexCount:t}),isInstanced:!0})}},yR=`uniform aisIconUniforms {
|
|
3651
3725
|
float timeSinceUpload;
|
|
3652
3726
|
float zoom;
|
|
3653
3727
|
float settingsIconSize;
|
|
3654
3728
|
float opacity;
|
|
3655
3729
|
} aisIcon;
|
|
3656
|
-
`,
|
|
3730
|
+
`,bR={name:`aisIcon`,vs:yR,fs:yR,uniformTypes:{timeSinceUpload:`f32`,zoom:`f32`,settingsIconSize:`f32`,opacity:`f32`}},xR=`#version 300 es
|
|
3657
3731
|
#define SHADER_NAME ais-icon-layer-vertex-shader
|
|
3658
3732
|
|
|
3659
3733
|
// Per-vertex: arrow mesh in local space (bow = +Y, starboard = +X, range [-1, 1])
|
|
@@ -3781,7 +3855,7 @@ void main(void) {
|
|
|
3781
3855
|
geometry.pickingColor = instancePickingColors;
|
|
3782
3856
|
DECKGL_FILTER_COLOR(vColor, geometry);
|
|
3783
3857
|
}
|
|
3784
|
-
`,
|
|
3858
|
+
`,SR=`#version 300 es
|
|
3785
3859
|
precision highp float;
|
|
3786
3860
|
#define SHADER_NAME ais-icon-layer-fragment-shader
|
|
3787
3861
|
|
|
@@ -3792,10 +3866,16 @@ void main(void) {
|
|
|
3792
3866
|
fragColor = vColor;
|
|
3793
3867
|
DECKGL_FILTER_COLOR(fragColor, geometry);
|
|
3794
3868
|
}
|
|
3795
|
-
`,uR=[0,1,0,.5,.333,0,.5,-.75,0,0,1,0,.5,-.75,0,0,-.5,0,0,1,0,0,-.5,0,-.5,-.75,0,0,1,0,-.5,-.75,0,-.5,.333,0];function dR(e,t,n,r){let i=[];for(let a=0;a<r;a++){let o=a/r*2*Math.PI,s=(a+1)/r*2*Math.PI;i.push(e,t,0,e+n*Math.sin(o),t+n*Math.cos(o),0,e+n*Math.sin(s),t+n*Math.cos(s),0)}return i}function fR(e,t,n,r){return[e,t,0,n,t,0,n,r,0,e,t,0,n,r,0,e,r,0]}function pR(e,t,n,r,i){let a=n-e,o=r-t,s=Math.sqrt(a*a+o*o),c=-o/s*i,l=a/s*i;return[e+c,t+l,0,e-c,t-l,0,n-c,r-l,0,e+c,t+l,0,n-c,r-l,0,n+c,r+l,0]}function mR(e,t,n,r){return[e,t,0,e,t+r,0,e+n,t,0,e,t,0,e+n,t,0,e,t-r,0,e,t,0,e,t-r,0,e-n,t,0,e,t,0,e-n,t,0,e,t+r,0]}function hR(e,t,n,r){let i=[];for(let a=0;a<r;a++){let o=-Math.PI/2+Math.PI*a/r,s=-Math.PI/2+Math.PI*(a+1)/r;i.push(e,t,0,e+n*Math.sin(o),t+n*Math.cos(o),0,e+n*Math.sin(s),t+n*Math.cos(s),0)}return i}function gR(e,t,n,r,i,a,o){let s=[];for(let c=0;c<o;c++){let l=(i+(a-i)*(c/o))*Math.PI/180,u=(i+(a-i)*((c+1)/o))*Math.PI/180,d=Math.sin(l),f=Math.cos(l),p=Math.sin(u),m=Math.cos(u);s.push(e+n*d,t+n*f,0,e+r*d,t+r*f,0,e+r*p,t+r*m,0,e+n*d,t+n*f,0,e+r*p,t+r*m,0,e+n*p,t+n*m,0)}return s}function _R(e,t=[]){let n=e.length/3,r=t.length/3,i=n+r;return{positions:new Float32Array([...e,...t,...e,...t]),isOutline:new Float32Array([...Array(i).fill(1),...Array(i).fill(0)]),isIndicator:new Float32Array([...Array(i).fill(0),...Array(n).fill(0),...Array(r).fill(1)]),vertexCount:i*2}}var vR=_R(uR),yR=_R([],dR(0,.65,.18,8)),bR=(()=>{let e=1.55,t=1.35,n=[];for(let r=0;r<16;r++){let i=r/16*2*Math.PI,a=(r+1)/16*2*Math.PI;n.push(t*Math.sin(i),t*Math.cos(i),0,e*Math.sin(i),e*Math.cos(i),0,e*Math.sin(a),e*Math.cos(a),0,t*Math.sin(i),t*Math.cos(i),0,e*Math.sin(a),e*Math.cos(a),0,t*Math.sin(a),t*Math.cos(a),0)}return _R([],n)})(),xR=_R([],[...fR(-1.38,-.55,-1.13,.22),...fR(1.13,-.55,1.38,.22)]),SR=_R([],[...pR(-.8,0,-1.5,-.5,.08),...pR(.8,0,1.5,-.5,.08),...gR(0,.3,1.6,1.78,242,118,14)]),CR=_R([],[...dR(0,.45,.15,10),...dR(0,.1,.15,10)]),wR=_R([],[...dR(0,.57,.13,10),...mR(0,.15,.17,.17),...dR(0,-.28,.13,10)]),TR=_R([],[...fR(-1,-.8,-.75,.85),...fR(.75,-.8,1,.85)]),ER=_R(dR(0,0,1.1,16),[...dR(0,.62,.2,12),...pR(-.19,.32,-.78,.5,.08),...pR(.19,.32,.78,.5,.08),...fR(-.15,-.3,.15,.32),...hR(-.42,-.55,.18,8),...hR(.42,-.55,.18,8),...fR(-.83,-.8,.83,-.55)]),DR={getPosition:{type:`accessor`,value:[0,0]},getSog:{type:`accessor`,value:0},getCog:{type:`accessor`,value:0},getHeading:{type:`accessor`,value:0},getRot:{type:`accessor`,value:0},getAgeAtUpload:{type:`accessor`,value:0},getLength:{type:`accessor`,value:0},getColor:{type:`accessor`,value:[255,255,255,255]},uploadTimestamp:0,selfAnimate:!1,settingsIconSize:1,opacity:1},OR=class extends xP{static layerName=`AisIconLayer`;static defaultProps=DR;getShaders(){return super.getShaders({vs:cR,fs:lR,modules:[lw,tT,sR]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:`float64`,fp64:this.use64bitPositions(),transition:!0,accessor:`getPosition`,defaultValue:[0,0,0]},instanceSog:{size:1,accessor:`getSog`,defaultValue:0},instanceCog:{size:1,accessor:`getCog`,defaultValue:0},instanceHeading:{size:1,accessor:`getHeading`,defaultValue:0},instanceRot:{size:1,accessor:`getRot`,defaultValue:0},instanceAgeAtUpload:{size:1,accessor:`getAgeAtUpload`,defaultValue:0},instanceLength:{size:1,accessor:`getLength`,defaultValue:0},instanceColor:{size:4,type:`unorm8`,accessor:`getColor`,defaultValue:[255,255,255,255]}})}updateState(e){super.updateState(e),(e.changeFlags.extensionsChanged||e.props.iconGeometry!==e.oldProps.iconGeometry)&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll()),e.changeFlags.propsChanged&&this.setNeedsRedraw()}draw({uniforms:e}){let{uploadTimestamp:t,selfAnimate:n,settingsIconSize:r,opacity:i}=this.props,a=n?Math.max(0,(Date.now()-(t??0))/1e3):0,o=this.context.viewport.zoom,s=this.state.model;s.shaderInputs.setProps({aisIcon:{timeSinceUpload:a,zoom:o,settingsIconSize:r??1,opacity:i??1}}),s.draw(this.context.renderPass),n&&this.setNeedsRedraw()}_getModel(){let e=this.props.iconGeometry??vR;return new cD(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new dD({topology:`triangle-list`,attributes:{positions:{size:3,value:e.positions},aIsOutline:{size:1,value:e.isOutline},aIsIndicator:{size:1,value:e.isIndicator}},vertexCount:e.vertexCount}),isInstanced:!0})}};function kR(e,t,n,r,i,a,o){let s=(o-a)/1e3;if(s===0||r<.01)return[e,t];let c,l;if(Math.abs(i)>1e-4){let e=n+i*s,t=r/i;c=t*(Math.cos(n)-Math.cos(e)),l=t*(Math.sin(e)-Math.sin(n))}else c=r*s*Math.sin(n),l=r*s*Math.cos(n);let u=111320*Math.cos(t*Math.PI/180);return[e+c/u,t+l/111320]}function AR(e,t,n){let r=t/2,i=t/2,a=t/32;e.beginPath(),e.moveTo(r,i-12*a),e.lineTo(r+8*a,i-4*a),e.lineTo(r+8*a,i+9*a),e.lineTo(r,i+6*a),e.lineTo(r-8*a,i+9*a),e.lineTo(r-8*a,i-4*a),e.closePath(),e.fillStyle=n,e.fill(),e.strokeStyle=`#ffffff`,e.lineWidth=1.5*a,e.lineJoin=`round`,e.stroke()}function jR(e,t){let n=document.createElement(`canvas`);n.width=e,n.height=e;let r=n.getContext(`2d`);if(!r)throw Error(`Could not get 2D canvas context`);return AR(r,e,t),n}function MR(e,t){return jR(e,t).getContext(`2d`).getImageData(0,0,e,e)}var NR=U(`<div class="ruler-popup svelte-c20cna"><button class="ruler-popup-remove svelte-c20cna">Remove</button></div>`),PR=U(`<div style="width: 100%; height: 100%;"></div> <div class="projection-picker svelte-c20cna"><button> </button> <button class="proj-btn svelte-c20cna"><!></button> <button class="proj-btn svelte-c20cna"><!></button></div> <button aria-label="Reset to North-Up"><svg width="44" height="44" viewBox="0 0 44 44" aria-hidden="true"><circle cx="22" cy="22" r="21" fill="rgba(0,0,0,0.72)" stroke="rgba(255,255,255,0.18)" stroke-width="1" class="svelte-c20cna"></circle><g><polygon points="22,5 17,23 22,20 27,23" fill="#e53e3e"></polygon><polygon points="22,39 17,21 22,24 27,21" fill="rgba(200,200,200,0.75)"></polygon></g><text x="22" y="15.5" text-anchor="middle" font-size="7" font-family="system-ui,sans-serif" fill="rgba(255,255,255,0.55)">N</text></svg></button> <!>`,1);function FR(e,t){We(t,!0);let n=()=>ut(iu,`$vesselState`,r),[r,i]=dt(),a={version:8,projection:{type:`mercator`},sources:{"osm-tiles":{type:`raster`,tiles:[`https://tile.openstreetmap.org/{z}/{x}/{y}.png`],tileSize:256,attribution:`© OpenStreetMap contributors`},openseamap:{type:`raster`,tiles:[`https://tiles.openseamap.org/seamark/{z}/{x}/{y}.png`],tileSize:256}},layers:[{id:`osm`,type:`raster`,source:`osm-tiles`},{id:`seamarks`,type:`raster`,source:`openseamap`}]},o,s,c=F(!!document.fullscreenElement),l=()=>{};function u(){document.fullscreenElement?document.exitFullscreen().catch(()=>{}):document.documentElement.requestFullscreen().catch(()=>{})}function d(){if(mu.following){mu.following=!1;return}mu.following=!0}let f=F(!1),p=F(10),m=F(0),h=F(`mercator`),g=null,_=!1,v=!1,y=null,b=null,x=0,S=null,C=null;function w(e){if(e!==`globe`&&V(h)===`globe`){let e=s?.style?.projection?._verticalPerspectiveProjection;e&&(g=e._errorCorrectionUsable)}if(I(h,e,!0),s?.setProjection({type:e}),e===`globe`&&g!==null){let e=s?.style?.projection?._verticalPerspectiveProjection;e&&(e._errorCorrectionUsable=g,e._errorCorrectionPreviousValue=g,e._errorMeasurementLastValue=-g),_=!0,requestAnimationFrame(()=>{if(!_)return;_=!1;let e=s?.style?.projection?._verticalPerspectiveProjection;e?._errorMeasurement&&g!==null&&(e._errorMeasurement._measuredError=-g,e._errorMeasurementLastValue=-g,e._errorMeasurementLastChangeTime=performance.now()-1e4)})}else _=!1}let T=`vessel`,E=`vessel-cog`,ee=`vessel-hdg`,te=`vessel-gc`,ne=`ais-targets`,D=`route-lines`,O=`route-waypoints`,k={type:`FeatureCollection`,features:[]},re=new Map,ie=null;function ae(e,t){let n=Math.max(1,t);switch(e){case`dashed`:return[5,3];case`dotted`:return[n,3];case`dash-dot`:return[5,3,1,3];default:return null}}function oe(e,t,n,r){let i=r/6371e3,a=t*Math.PI/180,o=a+i*Math.cos(n),s=Math.log(Math.tan(o/2+Math.PI/4)/Math.tan(a/2+Math.PI/4)),c=Math.abs(s)>1e-10?(o-a)/s:Math.cos(a);return[(e*Math.PI/180+i*Math.sin(n)/c)*180/Math.PI,o*180/Math.PI]}function se(e,t,n,r){let i=t*Math.PI/180,a=Math.cos(n);if(Math.abs(a)>1e-10){let e=((a>0?85*Math.PI/180:-(85*Math.PI)/180)-i)/a*6371e3;e>0&&e<r&&(r=e)}let o=[],s=e*Math.PI/180;for(let i=0;i<=256;i++){let[a,c]=oe(e,t,n,i/256*r),l=a*Math.PI/180-s,u=s+l-Math.round(l/(2*Math.PI))*2*Math.PI;s=u,o.push([u*180/Math.PI,c])}return o}function ce(e,t,n,r){let i=t*Math.PI/180,a=e*Math.PI/180,o=[],s=a;for(let e=0;e<=256;e++){let t=e/256*r/6371e3,c=Math.asin(Math.sin(i)*Math.cos(t)+Math.cos(i)*Math.sin(t)*Math.cos(n)),l=a+Math.atan2(Math.sin(n)*Math.sin(t)*Math.cos(i),Math.cos(t)-Math.sin(i)*Math.sin(c))-s,u=s+l-Math.round(l/(2*Math.PI))*2*Math.PI;s=u,o.push([u*180/Math.PI,c*180/Math.PI])}return o}function le(e,t=255){let n=e.replace(`#`,``),r=parseInt(n.slice(0,2),16),i=parseInt(n.slice(2,4),16),a=parseInt(n.slice(4,6),16);return[isNaN(r)?0:r,isNaN(i)?0:i,isNaN(a)?0:a,t]}function ue(e,t){let n=Math.max(1,t);switch(e){case`dashed`:return[6*n,3*n];case`dotted`:return[n,2*n];case`dash-dot`:return[6*n,2*n];default:return[0,0]}}function de(){if(!s)return;let e=o.clientWidth,t=o.clientHeight,n=e/2,r=t*.75,i=e/8,a=s.unproject([n-i,r]),c=s.unproject([n+i,r]);mL.add(a.lng,a.lat,c.lng,c.lat)}let fe=null,pe=!1,me=F(null);function he(e){e!==pe&&(pe=e,o.style.cursor=e?`grab`:``,e?s?.dragPan.disable():fe||s?.dragPan.enable())}function ge(e){if(!xe||!s)return;let t=o.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top,i=xe.pickObject({x:n,y:r,radius:14,layerIds:[`ruler-labels`]});if(i?.object){let t=i.object;I(me,{rulerId:t.ruler.id,x:e.clientX,y:e.clientY},!0),e.stopPropagation();return}if(V(me)){I(me,null);return}let a=xe.pickObject({x:n,y:r,radius:10,layerIds:[`ruler-handles`]});if(!a?.object)return;let c=a.object;fe={rulerId:c.rulerId,endpoint:c.endpoint},s.dragPan.disable(),o.style.cursor=`grabbing`,o.setPointerCapture(e.pointerId),e.stopPropagation()}function _e(e){if(!s)return;let t=o.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;if(!fe){xe&&he(!!xe.pickObject({x:n,y:r,radius:10,layerIds:[`ruler-handles`]})?.object);return}let i=s.unproject([n,r]);mL.moveEndpoint(fe.rulerId,fe.endpoint,i.lng,i.lat),e.stopPropagation()}function ve(e){if(!fe||!s)return;let t=o.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top,i=s.unproject([n,r]),a,c=i.lng,l=i.lat;for(let e of be){let t=s.project([e.position.longitude,e.position.latitude]);if(Math.hypot(t.x-n,t.y-r)<ye){a=e.id,c=e.position.longitude,l=e.position.latitude;break}}mL.snapEndpoint(fe.rulerId,fe.endpoint,a,c,l),fe=null,o.style.cursor=pe?`grab`:``,pe||s.dragPan.enable(),o.releasePointerCapture(e.pointerId)}let ye=24,be=[],xe=null,Se=null,Ce=[],we=0,Te=[],Ee=[];function De(){xe?.setProps({layers:[...Te,...Ee]})}let Oe=0,ke=null,Ae=[];Nn(()=>{J.targetFps,cancelAnimationFrame(Oe),clearTimeout(Oe),Ae.length=0,fu.set(0),ke?.()}),Kr(()=>{s=new ru.default.Map({container:o,style:a,center:[10.75,59.91],zoom:10,maxPitch:85,bearingSnap:0}),s.addControl(new ru.default.NavigationControl({showCompass:!1}),`top-right`),s.addControl(new ru.default.ScaleControl({unit:`nautical`}),`bottom-left`),xe=new nF({layers:[],interleaved:!1,parameters:{depthCompare:`always`,cullMode:`none`}}),s.addControl(xe),De();function e(){let e=performance.now();Ae.push(e);let n=e-3e3;for(;Ae.length>2&&Ae[0]<n;)Ae.shift();if(Ae.length>=2){let e=Ae[Ae.length-1]-Ae[0];fu.set((Ae.length-1)/(e/1e3))}if(xe!==null){let e=Date.now(),t=st(iu).position;{let n=e,r=[];if(Se&&Ce.length>0){let e=Se,t=Ce,i=t.length;for(let a=0;a<i;a++){let i=e[a*7+0],o=e[a*7+1];r.push({id:t[a],position:{longitude:i,latitude:o}});let s=e[a*7+2],c=e[a*7+3];if(!isNaN(s)&&!isNaN(c)&&c>.1){let l=e[a*7+5],u=we-e[a*7+6]*1e3,[d,f]=kR(i,o,s,c,isNaN(l)?0:l,u,n);r.push({id:t[a]+`:ghost`,position:{longitude:d,latitude:f}})}}}t&&r.push({id:`own-vessel`,position:{longitude:t.longitude,latitude:t.latitude}}),be=r,mL.syncSnapped(be)}let n=mL.rulers;if(n.length>0){let e=J.appearance.ruler.color,t=J.appearance.ruler.width;function r(e,t){let n=parseInt(e.replace(`#`,``),16);return[n>>16&255,n>>8&255,n&255,Math.round(t*255)]}let i=r(e,.87),a=r(e,.9),o=n.flatMap(e=>{if(s){let t=s.project([e.a.lon,e.a.lat]),n=s.project([e.b.lon,e.b.lat]);if(Math.hypot(n.x-t.x,n.y-t.y)<100)return[]}let t=lL(e.a.lon,e.a.lat,e.b.lon,e.b.lat),n=t[Math.floor(t.length/2)];return[{ruler:e,lon:n[0],lat:n[1]}]}),c=n.flatMap(e=>[{rulerId:e.id,endpoint:`a`,lon:e.a.lon,lat:e.a.lat,snapId:e.a.snapId},{rulerId:e.id,endpoint:`b`,lon:e.b.lon,lat:e.b.lat,snapId:e.b.snapId}]);Ee=[new rI({id:`ruler-line`,data:n.map(e=>({ruler:e})),getPath:e=>lL(e.ruler.a.lon,e.ruler.a.lat,e.ruler.b.lon,e.ruler.b.lat),getColor:()=>i,getWidth:t,widthUnits:`pixels`,widthMinPixels:1,pickable:!1,updateTriggers:{getPath:[n]}}),new MF({id:`ruler-handles`,data:c,getPosition:e=>[e.lon,e.lat,0],getRadius:7,radiusUnits:`pixels`,getFillColor:e=>e.snapId?[255,100,50,230]:a,getLineColor:[255,255,255,180],lineWidthUnits:`pixels`,getLineWidth:1.5,stroked:!0,pickable:!0,updateTriggers:{getPosition:[n],getFillColor:[n,e]}}),new eL({id:`ruler-labels`,data:o,getText:e=>`${uL(e.ruler)} · ${dL(e.ruler)}`,getPosition:e=>[e.lon,e.lat,0],getSize:13,getColor:[255,240,180,230],getBackgroundColor:[0,0,0,160],background:!0,backgroundPadding:[4,2,4,2],getTextAnchor:`middle`,getAlignmentBaseline:`center`,fontFamily:`monospace`,characterSet:[...`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 °·.,'-/T`],pickable:!0,updateTriggers:{getText:[n],getPosition:[n]}})],De()}else Ee.length>0&&(Ee=[],I(me,null),De())}t()}function t(){let t=1e3/J.targetFps;Oe=t<=17?requestAnimationFrame(e):setTimeout(e,t)}ke=t,t(),o.addEventListener(`pointerdown`,ge,{capture:!0}),o.addEventListener(`pointermove`,_e,{capture:!0}),o.addEventListener(`pointerup`,ve,{capture:!0}),o.addEventListener(`pointercancel`,ve,{capture:!0}),l=()=>{I(c,!!document.fullscreenElement)},document.addEventListener(`fullscreenchange`,l),s.on(`zoom`,()=>{I(p,s?.getZoom()??V(p),!0)}),s.on(`rotate`,()=>{I(m,s?.getBearing()??V(m),!0)}),s.on(`movestart`,e=>{e.originalEvent&&(v=!0)}),s.on(`moveend`,()=>{v=!1}),s.on(`dragstart`,()=>{fe||(mu.following=!1)}),s.on(`rotatestart`,e=>{e.originalEvent&&vu.setManual()}),s.on(`click`,e=>{if(!xe)return;let{x:t,y:n}=e.point,r=xe.pickMultipleObjects({x:t,y:n,radius:5,layerIds:[`ais-confirmed-icon`,`ais-hull-ghost`,`ais-hull-confirmed`,`ais-ghost-icon`,`ais-mob-icon`]}),i=new Set,a=[];for(let e of r){let t=e.object;t!=null&&(i.has(t)||(i.add(t),e.coordinate&&a.push({idx:t,coordinate:e.coordinate})))}if(a.length===0)return;let o=a[0].coordinate;if(a.length===1){let e=Xu.getTarget(a[0].idx);if(!e?.position)return;j(o,e);return}Ne(o,a.map(e=>e.idx))}),s.on(`style.load`,()=>{let e=s;if(!e)return;let t=J.appearance;e.hasImage(`vessel-icon`)||e.addImage(`vessel-icon`,{width:64,height:64,data:MR(64,t.vesselColor).data}),e.getSource(T)||e.addSource(T,{type:`geojson`,data:k}),e.getSource(E)||e.addSource(E,{type:`geojson`,data:k}),e.getSource(ee)||e.addSource(ee,{type:`geojson`,data:k}),e.getSource(te)||e.addSource(te,{type:`geojson`,data:k}),e.getSource(ne)||e.addSource(ne,{type:`geojson`,data:k}),e.getSource(D)||e.addSource(D,{type:`geojson`,data:k}),e.getSource(O)||e.addSource(O,{type:`geojson`,data:k}),e.getLayer(`vessel-gc-line`)||e.addLayer({id:`vessel-gc-line`,type:`line`,source:te,paint:{"line-color":t.gc.color,"line-width":t.gc.width,...ae(t.gc.style,t.gc.width)!==null&&{"line-dasharray":ae(t.gc.style,t.gc.width)}}}),e.getLayer(`ais-label`)||e.addLayer({id:`ais-label`,type:`symbol`,source:ne,layout:{"text-field":[`get`,`label`],"text-font":[`Roboto Regular`],"text-size":10,"text-anchor":`top`,"text-offset":[0,.8],"text-optional":!0},paint:{"text-color":J.appearance.ais.vesselColor,"text-halo-color":`#000`,"text-halo-width":1}}),e.getLayer(`vessel-cog-line`)||e.addLayer({id:`vessel-cog-line`,type:`line`,source:E,paint:{"line-color":t.cog.color,"line-width":t.cog.width,...ae(t.cog.style,t.cog.width)!==null&&{"line-dasharray":ae(t.cog.style,t.cog.width)}}}),e.getLayer(`vessel-hdg-line`)||e.addLayer({id:`vessel-hdg-line`,type:`line`,source:ee,paint:{"line-color":t.heading.color,"line-width":t.heading.width}}),e.getLayer(`vessel-icon`)||e.addLayer({id:`vessel-icon`,type:`symbol`,source:T,layout:{"icon-image":`vessel-icon`,"icon-size":t.vesselSize/64,"icon-rotate":[`get`,`bearing_deg`],"icon-rotation-alignment":`map`,"icon-allow-overlap":!0,"icon-ignore-placement":!0}}),e.getLayer(`route-full`)||e.addLayer({id:`route-full`,type:`line`,source:D,filter:[`==`,[`get`,`kind`],`full`],paint:{"line-color":`#e040fb`,"line-width":2,"line-dasharray":[6,4],"line-opacity":.65}},`vessel-gc-line`),e.getLayer(`route-leg`)||e.addLayer({id:`route-leg`,type:`line`,source:D,filter:[`==`,[`get`,`kind`],`leg`],paint:{"line-color":`#e040fb`,"line-width":2.5}},`vessel-gc-line`),e.getLayer(`route-bearing`)||e.addLayer({id:`route-bearing`,type:`line`,source:D,filter:[`==`,[`get`,`kind`],`bearing`],paint:{"line-color":`#ff6d00`,"line-width":2,"line-dasharray":[4,3]}},`vessel-gc-line`),e.getLayer(`route-waypoints`)||e.addLayer({id:`route-waypoints`,type:`circle`,source:O,paint:{"circle-radius":[`match`,[`get`,`wtype`],`next`,7,5],"circle-color":[`match`,[`get`,`wtype`],`next`,`#e040fb`,`#9c27b0`],"circle-opacity":.9,"circle-stroke-color":`#fff`,"circle-stroke-width":1.5}},`vessel-icon`),I(p,s.getZoom(),!0),I(m,s.getBearing(),!0),I(f,!0)}),s.on(`webglcontextlost`,()=>{console.warn(`[map] WebGL context lost`),I(f,!1),re.clear(),ie=null}),s.on(`webglcontextrestored`,()=>{console.info(`[map] WebGL context restored`)}),s.on(`error`,e=>{console.error(`[map] error`,e.error??e)})}),qr(()=>{cancelAnimationFrame(Oe),clearTimeout(Oe),xe?.finalize(),document.removeEventListener(`fullscreenchange`,l),o.removeEventListener(`pointerdown`,ge,{capture:!0}),o.removeEventListener(`pointermove`,_e,{capture:!0}),o.removeEventListener(`pointerup`,ve,{capture:!0}),o.removeEventListener(`pointercancel`,ve,{capture:!0}),s?.remove()});function je(e){let t=(e,t,n=``)=>`<tr><td>${e}</td><td><b>${t===null?`<span style="opacity:0.4">—</span>`:`${String(t)}${n}`}</b></td></tr>`,n=e.rot===void 0?null:e.rot*180/Math.PI*60,r=n===null?null:`${n>0?`▶ `:n<0?`◀ `:``}${Math.abs(n).toFixed(1)}°/min`,i=e.mmsi?`<div class="ais-links">
|
|
3869
|
+
`,CR=[0,1,0,.5,.333,0,.5,-.75,0,0,1,0,.5,-.75,0,0,-.5,0,0,1,0,0,-.5,0,-.5,-.75,0,0,1,0,-.5,-.75,0,-.5,.333,0];function wR(e,t,n,r){let i=[];for(let a=0;a<r;a++){let o=a/r*2*Math.PI,s=(a+1)/r*2*Math.PI;i.push(e,t,0,e+n*Math.sin(o),t+n*Math.cos(o),0,e+n*Math.sin(s),t+n*Math.cos(s),0)}return i}function TR(e,t,n,r){return[e,t,0,n,t,0,n,r,0,e,t,0,n,r,0,e,r,0]}function ER(e,t,n,r,i){let a=n-e,o=r-t,s=Math.sqrt(a*a+o*o),c=-o/s*i,l=a/s*i;return[e+c,t+l,0,e-c,t-l,0,n-c,r-l,0,e+c,t+l,0,n-c,r-l,0,n+c,r+l,0]}function DR(e,t,n,r){return[e,t,0,e,t+r,0,e+n,t,0,e,t,0,e+n,t,0,e,t-r,0,e,t,0,e,t-r,0,e-n,t,0,e,t,0,e-n,t,0,e,t+r,0]}function OR(e,t,n,r){let i=[];for(let a=0;a<r;a++){let o=-Math.PI/2+Math.PI*a/r,s=-Math.PI/2+Math.PI*(a+1)/r;i.push(e,t,0,e+n*Math.sin(o),t+n*Math.cos(o),0,e+n*Math.sin(s),t+n*Math.cos(s),0)}return i}function kR(e,t,n,r,i,a,o){let s=[];for(let c=0;c<o;c++){let l=(i+(a-i)*(c/o))*Math.PI/180,u=(i+(a-i)*((c+1)/o))*Math.PI/180,d=Math.sin(l),f=Math.cos(l),p=Math.sin(u),m=Math.cos(u);s.push(e+n*d,t+n*f,0,e+r*d,t+r*f,0,e+r*p,t+r*m,0,e+n*d,t+n*f,0,e+r*p,t+r*m,0,e+n*p,t+n*m,0)}return s}function AR(e,t=[]){let n=e.length/3,r=t.length/3,i=n+r;return{positions:new Float32Array([...e,...t,...e,...t]),isOutline:new Float32Array([...Array(i).fill(1),...Array(i).fill(0)]),isIndicator:new Float32Array([...Array(i).fill(0),...Array(n).fill(0),...Array(r).fill(1)]),vertexCount:i*2}}var jR=AR(CR),MR=AR([],wR(0,.65,.18,8)),NR=(()=>{let e=1.55,t=1.35,n=[];for(let r=0;r<16;r++){let i=r/16*2*Math.PI,a=(r+1)/16*2*Math.PI;n.push(t*Math.sin(i),t*Math.cos(i),0,e*Math.sin(i),e*Math.cos(i),0,e*Math.sin(a),e*Math.cos(a),0,t*Math.sin(i),t*Math.cos(i),0,e*Math.sin(a),e*Math.cos(a),0,t*Math.sin(a),t*Math.cos(a),0)}return AR([],n)})(),PR=AR([],[...TR(-1.38,-.55,-1.13,.22),...TR(1.13,-.55,1.38,.22)]),FR=AR([],[...ER(-.8,0,-1.5,-.5,.08),...ER(.8,0,1.5,-.5,.08),...kR(0,.3,1.6,1.78,242,118,14)]),IR=AR([],[...wR(0,.45,.15,10),...wR(0,.1,.15,10)]),LR=AR([],[...wR(0,.57,.13,10),...DR(0,.15,.17,.17),...wR(0,-.28,.13,10)]),RR=AR([],[...TR(-1,-.8,-.75,.85),...TR(.75,-.8,1,.85)]),zR=AR(wR(0,0,1.1,16),[...wR(0,.62,.2,12),...ER(-.19,.32,-.78,.5,.08),...ER(.19,.32,.78,.5,.08),...TR(-.15,-.3,.15,.32),...OR(-.42,-.55,.18,8),...OR(.42,-.55,.18,8),...TR(-.83,-.8,.83,-.55)]),BR={getPosition:{type:`accessor`,value:[0,0]},getSog:{type:`accessor`,value:0},getCog:{type:`accessor`,value:0},getHeading:{type:`accessor`,value:0},getRot:{type:`accessor`,value:0},getAgeAtUpload:{type:`accessor`,value:0},getLength:{type:`accessor`,value:0},getColor:{type:`accessor`,value:[255,255,255,255]},uploadTimestamp:0,selfAnimate:!1,settingsIconSize:1,opacity:1},VR=class extends OP{static layerName=`AisIconLayer`;static defaultProps=BR;getShaders(){return super.getShaders({vs:xR,fs:SR,modules:[gw,cT,bR]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:`float64`,fp64:this.use64bitPositions(),transition:!0,accessor:`getPosition`,defaultValue:[0,0,0]},instanceSog:{size:1,accessor:`getSog`,defaultValue:0},instanceCog:{size:1,accessor:`getCog`,defaultValue:0},instanceHeading:{size:1,accessor:`getHeading`,defaultValue:0},instanceRot:{size:1,accessor:`getRot`,defaultValue:0},instanceAgeAtUpload:{size:1,accessor:`getAgeAtUpload`,defaultValue:0},instanceLength:{size:1,accessor:`getLength`,defaultValue:0},instanceColor:{size:4,type:`unorm8`,accessor:`getColor`,defaultValue:[255,255,255,255]}})}updateState(e){super.updateState(e),(e.changeFlags.extensionsChanged||e.props.iconGeometry!==e.oldProps.iconGeometry)&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll()),e.changeFlags.propsChanged&&this.setNeedsRedraw()}draw({uniforms:e}){let{uploadTimestamp:t,selfAnimate:n,settingsIconSize:r,opacity:i}=this.props,a=n?Math.max(0,(Date.now()-(t??0))/1e3):0,o=this.context.viewport.zoom,s=this.state.model;s.shaderInputs.setProps({aisIcon:{timeSinceUpload:a,zoom:o,settingsIconSize:r??1,opacity:i??1}}),s.draw(this.context.renderPass),n&&this.setNeedsRedraw()}_getModel(){let e=this.props.iconGeometry??jR;return new hD(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new vD({topology:`triangle-list`,attributes:{positions:{size:3,value:e.positions},aIsOutline:{size:1,value:e.isOutline},aIsIndicator:{size:1,value:e.isIndicator}},vertexCount:e.vertexCount}),isInstanced:!0})}};function HR(e,t,n,r,i,a,o){let s=(o-a)/1e3;if(s===0||r<.01)return[e,t];let c,l;if(Math.abs(i)>1e-4){let e=n+i*s,t=r/i;c=t*(Math.cos(n)-Math.cos(e)),l=t*(Math.sin(e)-Math.sin(n))}else c=r*s*Math.sin(n),l=r*s*Math.cos(n);let u=111320*Math.cos(t*Math.PI/180);return[e+c/u,t+l/111320]}function UR(e,t,n){let r=t/2,i=t/2,a=t/32;e.beginPath(),e.moveTo(r,i-12*a),e.lineTo(r+8*a,i-4*a),e.lineTo(r+8*a,i+9*a),e.lineTo(r,i+6*a),e.lineTo(r-8*a,i+9*a),e.lineTo(r-8*a,i-4*a),e.closePath(),e.fillStyle=n,e.fill(),e.strokeStyle=`#ffffff`,e.lineWidth=1.5*a,e.lineJoin=`round`,e.stroke()}function WR(e,t){let n=document.createElement(`canvas`);n.width=e,n.height=e;let r=n.getContext(`2d`);if(!r)throw Error(`Could not get 2D canvas context`);return UR(r,e,t),n}function GR(e,t){return WR(e,t).getContext(`2d`).getImageData(0,0,e,e)}var KR=U(`<div class="ruler-popup svelte-c20cna"><button class="ruler-popup-remove svelte-c20cna">Remove</button></div>`),qR=U(`<div style="width: 100%; height: 100%;"></div> <div class="projection-picker svelte-c20cna"><button> </button> <button class="proj-btn svelte-c20cna"><!></button> <button class="proj-btn svelte-c20cna"><!></button></div> <button aria-label="Reset to North-Up"><svg width="44" height="44" viewBox="0 0 44 44" aria-hidden="true"><circle cx="22" cy="22" r="21" fill="rgba(0,0,0,0.72)" stroke="rgba(255,255,255,0.18)" stroke-width="1" class="svelte-c20cna"></circle><g><polygon points="22,5 17,23 22,20 27,23" fill="#e53e3e"></polygon><polygon points="22,39 17,21 22,24 27,21" fill="rgba(200,200,200,0.75)"></polygon></g><text x="22" y="15.5" text-anchor="middle" font-size="7" font-family="system-ui,sans-serif" fill="rgba(255,255,255,0.55)">N</text></svg></button> <!>`,1);function JR(e,t){Ke(t,!0);let n=()=>pt(du,`$vesselState`,r),[r,i]=mt(),a=Bi(t,`openSettings`,3,e=>{}),o={version:8,projection:{type:`mercator`},sources:{"osm-tiles":{type:`raster`,tiles:[`https://tile.openstreetmap.org/{z}/{x}/{y}.png`],tileSize:256,attribution:`© OpenStreetMap contributors`},openseamap:{type:`raster`,tiles:[`https://tiles.openseamap.org/seamark/{z}/{x}/{y}.png`],tileSize:256}},layers:[{id:`osm`,type:`raster`,source:`osm-tiles`},{id:`seamarks`,type:`raster`,source:`openseamap`}]},s,c,l=F(!!document.fullscreenElement),u=()=>{};function d(){document.fullscreenElement?document.exitFullscreen().catch(()=>{}):document.documentElement.requestFullscreen().catch(()=>{})}function f(){if(xu.following){xu.following=!1;return}xu.following=!0}let p=F(!1),m=F(10),h=F(0),g=F(`mercator`),_=null,v=!1,y=!1,b=null,x=null,S=0,C=null,w=null;function T(e){if(e!==`globe`&&V(g)===`globe`){let e=c?.style?.projection?._verticalPerspectiveProjection;e&&(_=e._errorCorrectionUsable)}if(I(g,e,!0),c?.setProjection({type:e}),e===`globe`&&_!==null){let e=c?.style?.projection?._verticalPerspectiveProjection;e&&(e._errorCorrectionUsable=_,e._errorCorrectionPreviousValue=_,e._errorMeasurementLastValue=-_),v=!0,requestAnimationFrame(()=>{if(!v)return;v=!1;let e=c?.style?.projection?._verticalPerspectiveProjection;e?._errorMeasurement&&_!==null&&(e._errorMeasurement._measuredError=-_,e._errorMeasurementLastValue=-_,e._errorMeasurementLastChangeTime=performance.now()-1e4)})}else v=!1}let E=`vessel`,ee=`vessel-cog`,te=`vessel-hdg`,ne=`vessel-gc`,D=`ais-targets`,O=`route-lines`,k=`route-waypoints`,re={type:`FeatureCollection`,features:[]},ie=new Map,ae=null;function oe(e,t){let n=Math.max(1,t);switch(e){case`dashed`:return[5,3];case`dotted`:return[n,3];case`dash-dot`:return[5,3,1,3];default:return null}}function se(e,t,n,r){let i=r/6371e3,a=t*Math.PI/180,o=a+i*Math.cos(n),s=Math.log(Math.tan(o/2+Math.PI/4)/Math.tan(a/2+Math.PI/4)),c=Math.abs(s)>1e-10?(o-a)/s:Math.cos(a);return[(e*Math.PI/180+i*Math.sin(n)/c)*180/Math.PI,o*180/Math.PI]}function ce(e,t,n,r){let i=t*Math.PI/180,a=Math.cos(n);if(Math.abs(a)>1e-10){let e=((a>0?85*Math.PI/180:-(85*Math.PI)/180)-i)/a*6371e3;e>0&&e<r&&(r=e)}let o=[],s=e*Math.PI/180;for(let i=0;i<=256;i++){let[a,c]=se(e,t,n,i/256*r),l=a*Math.PI/180-s,u=s+l-Math.round(l/(2*Math.PI))*2*Math.PI;s=u,o.push([u*180/Math.PI,c])}return o}function le(e,t,n,r){let i=t*Math.PI/180,a=e*Math.PI/180,o=[],s=a;for(let e=0;e<=256;e++){let t=e/256*r/6371e3,c=Math.asin(Math.sin(i)*Math.cos(t)+Math.cos(i)*Math.sin(t)*Math.cos(n)),l=a+Math.atan2(Math.sin(n)*Math.sin(t)*Math.cos(i),Math.cos(t)-Math.sin(i)*Math.sin(c))-s,u=s+l-Math.round(l/(2*Math.PI))*2*Math.PI;s=u,o.push([u*180/Math.PI,c*180/Math.PI])}return o}function ue(e,t=255){let n=e.replace(`#`,``),r=parseInt(n.slice(0,2),16),i=parseInt(n.slice(2,4),16),a=parseInt(n.slice(4,6),16);return[isNaN(r)?0:r,isNaN(i)?0:i,isNaN(a)?0:a,t]}function de(e,t){let n=Math.max(1,t);switch(e){case`dashed`:return[6*n,3*n];case`dotted`:return[n,2*n];case`dash-dot`:return[6*n,2*n];default:return[0,0]}}function fe(){if(!c)return;let e=s.clientWidth,t=s.clientHeight,n=e/2,r=t*.75,i=e/8,a=c.unproject([n-i,r]),o=c.unproject([n+i,r]);xL.add(a.lng,a.lat,o.lng,o.lat)}let pe=null,me=!1,A=F(null);function he(e){e!==me&&(me=e,s.style.cursor=e?`grab`:``,e?c?.dragPan.disable():pe||c?.dragPan.enable())}function ge(e){if(!xe||!c)return;let t=s.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top,i=xe.pickObject({x:n,y:r,radius:14,layerIds:[`ruler-labels`]});if(i?.object){let t=i.object;I(A,{rulerId:t.ruler.id,x:e.clientX,y:e.clientY},!0),e.stopPropagation();return}if(V(A)){I(A,null);return}let a=xe.pickObject({x:n,y:r,radius:10,layerIds:[`ruler-handles`]});if(!a?.object)return;let o=a.object;pe={rulerId:o.rulerId,endpoint:o.endpoint},c.dragPan.disable(),s.style.cursor=`grabbing`,s.setPointerCapture(e.pointerId),e.stopPropagation()}function _e(e){if(!c)return;let t=s.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;if(!pe){xe&&he(!!xe.pickObject({x:n,y:r,radius:10,layerIds:[`ruler-handles`]})?.object);return}let i=c.unproject([n,r]);xL.moveEndpoint(pe.rulerId,pe.endpoint,i.lng,i.lat),e.stopPropagation()}function ve(e){if(!pe||!c)return;let t=s.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top,i=c.unproject([n,r]),a,o=i.lng,l=i.lat;for(let e of be){let t=c.project([e.position.longitude,e.position.latitude]);if(Math.hypot(t.x-n,t.y-r)<ye){a=e.id,o=e.position.longitude,l=e.position.latitude;break}}xL.snapEndpoint(pe.rulerId,pe.endpoint,a,o,l),pe=null,s.style.cursor=me?`grab`:``,me||c.dragPan.enable(),s.releasePointerCapture(e.pointerId)}let ye=24,be=[],xe=null,Se=null,Ce=[],we=0,Te=[],Ee=[];function De(){xe?.setProps({layers:[...Te,...Ee]})}let Oe=0,ke=null,Ae=[];Ln(()=>{J.targetFps,cancelAnimationFrame(Oe),clearTimeout(Oe),Ae.length=0,yu.set(0),ke?.()}),Qr(()=>{c=new uu.default.Map({container:s,style:o,center:[10.75,59.91],zoom:10,maxPitch:85,bearingSnap:0}),c.addControl(new uu.default.NavigationControl({showCompass:!1}),`top-right`),c.addControl(new uu.default.ScaleControl({unit:`nautical`}),`bottom-left`),xe=new lF({layers:[],interleaved:!1,parameters:{depthCompare:`always`,cullMode:`none`}}),c.addControl(xe),De();function e(){let e=performance.now();Ae.push(e);let n=e-3e3;for(;Ae.length>2&&Ae[0]<n;)Ae.shift();if(Ae.length>=2){let e=Ae[Ae.length-1]-Ae[0];yu.set((Ae.length-1)/(e/1e3))}if(xe!==null){let e=Date.now(),t=lt(du).position;{let n=e,r=[];if(Se&&Ce.length>0){let e=Se,t=Ce,i=t.length;for(let a=0;a<i;a++){let i=e[a*7+0],o=e[a*7+1];r.push({id:t[a],position:{longitude:i,latitude:o}});let s=e[a*7+2],c=e[a*7+3];if(!isNaN(s)&&!isNaN(c)&&c>.1){let l=e[a*7+5],u=we-e[a*7+6]*1e3,[d,f]=HR(i,o,s,c,isNaN(l)?0:l,u,n);r.push({id:t[a]+`:ghost`,position:{longitude:d,latitude:f}})}}}t&&r.push({id:`own-vessel`,position:{longitude:t.longitude,latitude:t.latitude}}),be=r,xL.syncSnapped(be)}let n=xL.rulers;if(n.length>0){let e=J.appearance.ruler.color,t=J.appearance.ruler.width;function r(e,t){let n=parseInt(e.replace(`#`,``),16);return[n>>16&255,n>>8&255,n&255,Math.round(t*255)]}let i=r(e,.87),a=r(e,.9),o=n.flatMap(e=>{if(c){let t=c.project([e.a.lon,e.a.lat]),n=c.project([e.b.lon,e.b.lat]);if(Math.hypot(n.x-t.x,n.y-t.y)<100)return[]}let t=gL(e.a.lon,e.a.lat,e.b.lon,e.b.lat),n=t[Math.floor(t.length/2)];return[{ruler:e,lon:n[0],lat:n[1]}]}),s=n.flatMap(e=>[{rulerId:e.id,endpoint:`a`,lon:e.a.lon,lat:e.a.lat,snapId:e.a.snapId},{rulerId:e.id,endpoint:`b`,lon:e.b.lon,lat:e.b.lat,snapId:e.b.snapId}]);Ee=[new uI({id:`ruler-line`,data:n.map(e=>({ruler:e})),getPath:e=>gL(e.ruler.a.lon,e.ruler.a.lat,e.ruler.b.lon,e.ruler.b.lat),getColor:()=>i,getWidth:t,widthUnits:`pixels`,widthMinPixels:1,pickable:!1,updateTriggers:{getPath:[n]}}),new zF({id:`ruler-handles`,data:s,getPosition:e=>[e.lon,e.lat,0],getRadius:7,radiusUnits:`pixels`,getFillColor:e=>e.snapId?[255,100,50,230]:a,getLineColor:[255,255,255,180],lineWidthUnits:`pixels`,getLineWidth:1.5,stroked:!0,pickable:!0,updateTriggers:{getPosition:[n],getFillColor:[n,e]}}),new sL({id:`ruler-labels`,data:o,getText:e=>`${_L(e.ruler)} · ${vL(e.ruler)}`,getPosition:e=>[e.lon,e.lat,0],getSize:13,getColor:[255,240,180,230],getBackgroundColor:[0,0,0,160],background:!0,backgroundPadding:[4,2,4,2],getTextAnchor:`middle`,getAlignmentBaseline:`center`,fontFamily:`monospace`,characterSet:[...`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 °·.,'-/T`],pickable:!0,updateTriggers:{getText:[n],getPosition:[n]}})],De()}else Ee.length>0&&(Ee=[],I(A,null),De())}t()}function t(){let t=1e3/J.targetFps;Oe=t<=17?requestAnimationFrame(e):setTimeout(e,t)}ke=t,t(),s.addEventListener(`pointerdown`,ge,{capture:!0}),s.addEventListener(`pointermove`,_e,{capture:!0}),s.addEventListener(`pointerup`,ve,{capture:!0}),s.addEventListener(`pointercancel`,ve,{capture:!0}),u=()=>{I(l,!!document.fullscreenElement)},document.addEventListener(`fullscreenchange`,u),c.on(`zoom`,()=>{I(m,c?.getZoom()??V(m),!0)}),c.on(`rotate`,()=>{I(h,c?.getBearing()??V(h),!0)}),c.on(`movestart`,e=>{e.originalEvent&&(y=!0)}),c.on(`moveend`,()=>{y=!1}),c.on(`dragstart`,()=>{pe||(xu.following=!1)}),c.on(`rotatestart`,e=>{e.originalEvent&&Tu.setManual()}),c.on(`click`,`vessel-icon`,e=>{e.preventDefault();let t=e.lngLat,n=new uu.default.Popup({closeButton:!1,offset:14,className:`vessel-self-popup`}).setLngLat(t).setHTML(`<button class="vessel-self-settings-btn">Own vessel settings</button>`).addTo(c);n.getElement().addEventListener(`click`,e=>{e.target.closest(`.vessel-self-settings-btn`)&&(n.remove(),a()(`vessel`))})}),c.on(`mouseenter`,`vessel-icon`,()=>{c&&(c.getCanvas().style.cursor=`pointer`)}),c.on(`mouseleave`,`vessel-icon`,()=>{c&&(c.getCanvas().style.cursor=``)});let n=[`route-full`,`route-leg`,`route-bearing`,`route-waypoints`];c.on(`click`,n,e=>{if(c?.queryRenderedFeatures(e.point,{layers:[`vessel-icon`]}).length)return;let t=NL.routeName,n=`
|
|
3870
|
+
<div class="ais-popup">
|
|
3871
|
+
${t?`<div class="ais-popup-title">${t}</div>`:``}
|
|
3872
|
+
<div class="ais-links" style="margin-top:0">
|
|
3873
|
+
<button class="popup-settings-btn" data-settings="routes">Route settings</button>
|
|
3874
|
+
</div>
|
|
3875
|
+
</div>`,r=new uu.default.Popup({closeButton:!1,offset:10,maxWidth:`220px`}).setLngLat(e.lngLat).setHTML(n).addTo(c);r.getElement().addEventListener(`click`,e=>{let t=e.target.closest(`[data-settings]`);t&&(r.remove(),a()(t.dataset.settings))})});for(let e of n)c.on(`mouseenter`,e,()=>{c&&(c.getCanvas().style.cursor=`pointer`)}),c.on(`mouseleave`,e,()=>{c&&(c.getCanvas().style.cursor=``)});c.on(`click`,e=>{if(c?.queryRenderedFeatures(e.point,{layers:[`vessel-icon`]}).length||!xe)return;let{x:t,y:n}=e.point,r=xe.pickMultipleObjects({x:t,y:n,radius:5,layerIds:[`ais-confirmed-icon`,`ais-hull-ghost`,`ais-hull-confirmed`,`ais-ghost-icon`,`ais-mob-icon`]}),i=new Set,a=[];for(let e of r){let t=e.object;t!=null&&(i.has(t)||(i.add(t),e.coordinate&&a.push({idx:t,coordinate:e.coordinate})))}if(a.length===0)return;let o=a[0].coordinate;if(a.length===1){let e=rd.getTarget(a[0].idx);if(!e?.position)return;Ne(o,e);return}M(o,a.map(e=>e.idx))}),c.on(`style.load`,()=>{let e=c;if(!e)return;let t=J.appearance;e.hasImage(`vessel-icon`)||e.addImage(`vessel-icon`,{width:64,height:64,data:GR(64,t.vesselColor).data}),e.getSource(E)||e.addSource(E,{type:`geojson`,data:re}),e.getSource(ee)||e.addSource(ee,{type:`geojson`,data:re}),e.getSource(te)||e.addSource(te,{type:`geojson`,data:re}),e.getSource(ne)||e.addSource(ne,{type:`geojson`,data:re}),e.getSource(D)||e.addSource(D,{type:`geojson`,data:re}),e.getSource(O)||e.addSource(O,{type:`geojson`,data:re}),e.getSource(k)||e.addSource(k,{type:`geojson`,data:re}),e.getLayer(`vessel-gc-line`)||e.addLayer({id:`vessel-gc-line`,type:`line`,source:ne,paint:{"line-color":t.gc.color,"line-width":t.gc.width,...oe(t.gc.style,t.gc.width)!==null&&{"line-dasharray":oe(t.gc.style,t.gc.width)}}}),e.getLayer(`ais-label`)||e.addLayer({id:`ais-label`,type:`symbol`,source:D,layout:{"text-field":[`get`,`label`],"text-font":[`Roboto Regular`],"text-size":10,"text-anchor":`top`,"text-offset":[0,.8],"text-optional":!0},paint:{"text-color":J.appearance.ais.vesselColor,"text-halo-color":`#000`,"text-halo-width":1}}),e.getLayer(`vessel-cog-line`)||e.addLayer({id:`vessel-cog-line`,type:`line`,source:ee,paint:{"line-color":t.cog.color,"line-width":t.cog.width,...oe(t.cog.style,t.cog.width)!==null&&{"line-dasharray":oe(t.cog.style,t.cog.width)}}}),e.getLayer(`vessel-hdg-line`)||e.addLayer({id:`vessel-hdg-line`,type:`line`,source:te,paint:{"line-color":t.heading.color,"line-width":t.heading.width}}),e.getLayer(`vessel-icon`)||e.addLayer({id:`vessel-icon`,type:`symbol`,source:E,layout:{"icon-image":`vessel-icon`,"icon-size":t.vesselSize/64,"icon-rotate":[`get`,`bearing_deg`],"icon-rotation-alignment":`map`,"icon-allow-overlap":!0,"icon-ignore-placement":!0}}),e.getLayer(`route-full`)||e.addLayer({id:`route-full`,type:`line`,source:O,filter:[`==`,[`get`,`kind`],`full`],paint:{"line-color":`#e040fb`,"line-width":2,"line-dasharray":[6,4],"line-opacity":.65}},`vessel-gc-line`),e.getLayer(`route-leg`)||e.addLayer({id:`route-leg`,type:`line`,source:O,filter:[`==`,[`get`,`kind`],`leg`],paint:{"line-color":`#e040fb`,"line-width":2.5}},`vessel-gc-line`),e.getLayer(`route-bearing`)||e.addLayer({id:`route-bearing`,type:`line`,source:O,filter:[`==`,[`get`,`kind`],`bearing`],paint:{"line-color":`#ff6d00`,"line-width":2,"line-dasharray":[4,3]}},`vessel-gc-line`),e.getLayer(`route-waypoints`)||e.addLayer({id:`route-waypoints`,type:`circle`,source:k,paint:{"circle-radius":[`match`,[`get`,`wtype`],`next`,7,5],"circle-color":[`match`,[`get`,`wtype`],`next`,`#e040fb`,`#9c27b0`],"circle-opacity":.9,"circle-stroke-color":`#fff`,"circle-stroke-width":1.5}},`vessel-icon`),I(m,c.getZoom(),!0),I(h,c.getBearing(),!0),I(p,!0)}),c.on(`webglcontextlost`,()=>{console.warn(`[map] WebGL context lost`),I(p,!1),ie.clear(),ae=null}),c.on(`webglcontextrestored`,()=>{console.info(`[map] WebGL context restored`)}),c.on(`error`,e=>{console.error(`[map] error`,e.error??e)})}),$r(()=>{cancelAnimationFrame(Oe),clearTimeout(Oe),xe?.finalize(),document.removeEventListener(`fullscreenchange`,u),s.removeEventListener(`pointerdown`,ge,{capture:!0}),s.removeEventListener(`pointermove`,_e,{capture:!0}),s.removeEventListener(`pointerup`,ve,{capture:!0}),s.removeEventListener(`pointercancel`,ve,{capture:!0}),c?.remove()});function je(e){let t=(e,t,n=``)=>`<tr><td>${e}</td><td><b>${t===null?`<span style="opacity:0.4">—</span>`:`${String(t)}${n}`}</b></td></tr>`,n=e.rot===void 0?null:e.rot*180/Math.PI*60,r=n===null?null:`${n>0?`▶ `:n<0?`◀ `:``}${Math.abs(n).toFixed(1)}°/min`,i=e.mmsi?`<div class="ais-links">
|
|
3796
3876
|
<a href="https://www.vesselfinder.com/vessels/details/${e.mmsi}" target="_blank" rel="noopener">VesselFinder</a>
|
|
3797
3877
|
<a href="https://www.myshiptracking.com/?mmsi=${e.mmsi}" target="_blank" rel="noopener">MyShipTracking</a>
|
|
3798
|
-
</div>`:``,a=e.position?.longitude,o=e.position?.latitude,s=e.lastPositionUpdateMs,c=new Date(s).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),l=
|
|
3878
|
+
</div>`:``,a=e.position?.longitude,o=e.position?.latitude,s=e.lastPositionUpdateMs,c=new Date(s).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),l=j(s);return`
|
|
3799
3879
|
<div class="ais-popup">
|
|
3800
3880
|
<div class="ais-popup-title">${e.name??e.mmsi??`Unknown vessel`}</div>
|
|
3801
3881
|
<table>
|
|
@@ -3821,11 +3901,14 @@ void main(void) {
|
|
|
3821
3901
|
${t(`Air height`,e.airHeightM??null,` m`)}
|
|
3822
3902
|
</table>
|
|
3823
3903
|
${i}
|
|
3824
|
-
|
|
3904
|
+
<div class="ais-links" style="margin-top:6px">
|
|
3905
|
+
<button class="popup-settings-btn" data-settings="ais">AIS settings</button>
|
|
3906
|
+
</div>
|
|
3907
|
+
</div>`}let Me=null;function j(e){let t=Math.round((Date.now()-e)/1e3);return t<60?`${t}s ago`:t<3600?`${Math.floor(t/60)}m ${t%60}s ago`:`${Math.floor(t/3600)}h ${Math.floor(t%3600/60)}m ago`}function Ne(e,t){if(!t.position)return!1;Me!==null&&(clearInterval(Me),Me=null);let n=new uu.default.Popup({closeButton:!0,maxWidth:`280px`}).setLngLat(e).setHTML(je(t)).addTo(c);return Me=setInterval(()=>{let e=document.getElementById(`ais-age`);if(!e){clearInterval(Me),Me=null;return}e.textContent=`(${j(Number(e.dataset.posms))})`},1e3),n.on(`close`,()=>{Me!==null&&(clearInterval(Me),Me=null)}),n.getElement().addEventListener(`click`,e=>{let t=e.target.closest(`[data-settings]`);t&&(n.remove(),a()(t.dataset.settings))}),!0}function M(e,t){let n=t.map(e=>({idx:e,target:rd.getTarget(e)})).filter(e=>e.target?.position!=null);if(n.length===0)return;if(n.length===1){Ne(e,n[0].target);return}let r=`
|
|
3825
3908
|
<div class="ais-disambig">
|
|
3826
3909
|
<div class="ais-popup-title">Multiple vessels</div>
|
|
3827
3910
|
<ul class="ais-disambig-list">${n.map(({idx:e,target:t})=>`<li class="ais-disambig-item" data-idx="${e}">${t.name??t.mmsi??`Unknown vessel`}</li>`).join(``)}</ul>
|
|
3828
|
-
</div>`,i=new ru.default.Popup({closeButton:!0,maxWidth:`220px`}).setLngLat(e).setHTML(r).addTo(s);i.getElement().addEventListener(`click`,t=>{let n=t.target.closest(`[data-idx]`);if(!n)return;let r=Number(n.dataset.idx),a=Xu.getTarget(r);a?.position&&(i.remove(),j(e,a))})}Nn(()=>{if(!s||!V(f))return;let e=s,t=Y.selected,n=Y.available,r=Object.values(n).find(e=>t.has(e.identifier)&&!!e.style),i=r?Y.styleUrl(r):null;if(i!==ie){I(f,!1),re.clear(),ie=i,i?kL(i).then(t=>e.setStyle(t,{diff:!1})).catch(e=>{console.error(`[map] Failed to load style`,i,e),ie=null,I(f,!0)}):e.setStyle(a,{diff:!1});return}for(let r of Object.keys(n)){if(t.has(r)&&!n[r].style)continue;let i=`chart-layer-${r}`,a=`chart-${r}`;e.getLayer(i)&&e.removeLayer(i),e.getSource(a)&&e.removeSource(a),re.delete(r)}for(let[r,i]of Object.entries(n)){if(!t.has(r)||i.style)continue;let n=Y.tileUrl(i);if(!n)continue;let a=`chart-${r}`,o=`chart-layer-${r}`;if(re.get(r)!==n&&(e.getLayer(o)&&e.removeLayer(o),e.getSource(a)&&e.removeSource(a),re.set(r,n)),!e.getSource(a)){let t=n.includes(`{-y}`),r=t?n.replace(`{-y}`,`{y}`):n;i.format===`pbf`?e.addSource(a,{type:`vector`,tiles:[r]}):e.addSource(a,{type:`raster`,tiles:[r],tileSize:256,scheme:t?`tms`:`xyz`,minzoom:i.minzoom??0,maxzoom:i.maxzoom??22})}if(!e.getLayer(o))if(i.format===`pbf`){let t=i.layers?.[0]??r;e.addLayer({id:o,type:`fill`,source:a,"source-layer":t},`vessel-gc-line`)}else e.addLayer({id:o,type:`raster`,source:a},`vessel-gc-line`)}}),Nn(()=>{if(!s||!V(f))return;let e=Ju.enabled;for(let t of Wu)s.getLayer(t.id)&&s.setLayoutProperty(t.id,`visibility`,e.has(t.id)?`visible`:`none`)}),Nn(()=>{if(!s||!V(f))return;let e=MR(64,J.appearance.vesselColor);s.updateImage(`vessel-icon`,{width:64,height:64,data:e.data})}),Nn(()=>{!s||!V(f)||s.setPaintProperty(`ais-label`,`text-color`,J.appearance.ais.vesselColor)}),Nn(()=>{if(!s||!V(f))return;let e=s.getSource(ne);if(!(e instanceof ru.default.GeoJSONSource))return;let t=Xu.hotData,n=Xu.ids,r=Xu.coldMap;Xu.coldVersion;let i=[];if(t&&n.length>0)for(let e=0;e<n.length;e++)i.push({type:`Feature`,geometry:{type:`Point`,coordinates:[t[e*7+0],t[e*7+1]]},properties:{label:r.get(n[e])?.name??``}});let a=()=>{x=Date.now(),e.setData({type:`FeatureCollection`,features:i}),window.__mapDiag&&window.__mapDiag.aisLabels++};C=a;let o=1e3-(Date.now()-x);o<=0?(S!==null&&(clearTimeout(S),S=null),a(),C=null):S===null&&(S=setTimeout(()=>{S=null,C?.(),C=null},o))}),Nn(()=>{let e=Xu.hotData,t=Xu.ids,n=Xu.coldMap;Xu.coldVersion;let r=J.appearance.ais,i=r.vesselSize/64,a=Date.now(),o=r.cog.color,s=r.cog.width,c=r.cog.style,l=r.cog.lengthMinutes;if(!e||t.length===0){Te=[],De(),Se=null,Ce=[],we=0;return}let u=t.length,d=[],f=[],p=[],m=[],h=[],g=[],_=[],v=[],y=[],b=[],x=[],S=[],C=[],w=[],T=[],E=[],ee=[],te=[],ne=[];for(let r=0;r<u;r++){let i=n.get(t[r]),a=i?.navState?.toLowerCase()??``;if(a.includes(`sart`)||a.includes(`transponder`)){S.push(r);continue}d.push(r);let o=e[r*7+3],s=e[r*7+2];!isNaN(s)&&!isNaN(o)&&o>.1&&(f.push(r),p.push(r));let c=e[r*7+4],l=!isNaN(c)&&(i?.lengthM??0)>0&&(i?.beamM??0)>0;l&&m.push(r),a.includes(`aground`)?(g.push(r),l&&w.push(r)):a.includes(`anchor`)?(h.push(r),l&&C.push(r)):a.includes(`moor`)?(_.push(r),l&&T.push(r)):a.includes(`fishing`)?(v.push(r),l&&E.push(r)):a.includes(`command`)?(y.push(r),l&&ee.push(r)):a.includes(`restrict`)?(b.push(r),l&&te.push(r)):a.includes(`draught`)&&(x.push(r),l&&ne.push(r))}Se=e,Ce=t,we=a;let D=le(r.vesselColor,220),O=le(r.vesselColor,130),k=t=>[e[t*7+0],e[t*7+1],0],re=t=>{let n=e[t*7+3];return isNaN(n)?0:n},ie=t=>{let n=e[t*7+2];return isNaN(n)?0:n},ae=t=>{let n=e[t*7+4];if(!isNaN(n))return n;let r=e[t*7+2];return isNaN(r)?0:r},oe=t=>{let n=e[t*7+4];return isNaN(n)?0:n},se=t=>{let n=e[t*7+5];return isNaN(n)?0:n},ce=t=>e[t*7+6],de=(e,r)=>n.get(t[e])?.lengthM??r,fe=(e,r)=>n.get(t[e])?.beamM??r,pe=new Set(m),me=e=>pe.has(e)?de(e,0):0,he=f.length>0?new OR({id:`ais-ghost-icon`,data:f,getPosition:k,getSog:re,getCog:ie,getHeading:ae,getRot:se,getAgeAtUpload:ce,getLength:me,getColor:O,uploadTimestamp:a,selfAnimate:!0,settingsIconSize:i,pickable:!0}):null,ge=new OR({id:`ais-confirmed-icon`,data:d,getPosition:k,getSog:()=>0,getCog:()=>0,getHeading:ae,getRot:()=>0,getAgeAtUpload:()=>0,getLength:me,getColor:D,uploadTimestamp:a,selfAnimate:!1,settingsIconSize:i,pickable:!0}),_e=h.length>0?new OR({id:`ais-anchored-icon`,data:h,getPosition:k,getSog:()=>0,getCog:()=>0,getHeading:ae,getRot:()=>0,getAgeAtUpload:()=>0,getLength:me,getColor:D,uploadTimestamp:a,selfAnimate:!1,settingsIconSize:i,iconGeometry:yR,pickable:!1}):null,ve=_.length>0?new OR({id:`ais-moored-icon`,data:_,getPosition:k,getSog:()=>0,getCog:()=>0,getHeading:ae,getRot:()=>0,getAgeAtUpload:()=>0,getLength:me,getColor:D,uploadTimestamp:a,selfAnimate:!1,settingsIconSize:i,iconGeometry:xR,pickable:!1}):null,ye=g.length>0?new OR({id:`ais-aground-icon`,data:g,getPosition:k,getSog:()=>0,getCog:()=>0,getHeading:ae,getRot:()=>0,getAgeAtUpload:()=>0,getLength:me,getColor:D,uploadTimestamp:a,selfAnimate:!1,settingsIconSize:i,iconGeometry:bR,pickable:!1}):null,be=v.length>0?new OR({id:`ais-fishing-icon`,data:v,getPosition:k,getSog:()=>0,getCog:()=>0,getHeading:ae,getRot:()=>0,getAgeAtUpload:()=>0,getLength:me,getColor:D,uploadTimestamp:a,selfAnimate:!1,settingsIconSize:i,iconGeometry:SR,pickable:!1}):null,xe=y.length>0?new OR({id:`ais-nuc-icon`,data:y,getPosition:k,getSog:()=>0,getCog:()=>0,getHeading:ae,getRot:()=>0,getAgeAtUpload:()=>0,getLength:me,getColor:D,uploadTimestamp:a,selfAnimate:!1,settingsIconSize:i,iconGeometry:CR,pickable:!1}):null,Ee=b.length>0?new OR({id:`ais-restricted-icon`,data:b,getPosition:k,getSog:()=>0,getCog:()=>0,getHeading:ae,getRot:()=>0,getAgeAtUpload:()=>0,getLength:me,getColor:D,uploadTimestamp:a,selfAnimate:!1,settingsIconSize:i,iconGeometry:wR,pickable:!1}):null,Oe=x.length>0?new OR({id:`ais-draught-icon`,data:x,getPosition:k,getSog:()=>0,getCog:()=>0,getHeading:ae,getRot:()=>0,getAgeAtUpload:()=>0,getLength:me,getColor:D,uploadTimestamp:a,selfAnimate:!1,settingsIconSize:i,iconGeometry:TR,pickable:!1}):null,ke=S.length>0?new OR({id:`ais-mob-icon`,data:S,getPosition:k,getSog:()=>0,getCog:()=>0,getHeading:()=>0,getRot:()=>0,getAgeAtUpload:()=>0,getLength:()=>0,getColor:()=>[255,40,40,220],uploadTimestamp:a,selfAnimate:!1,settingsIconSize:i,iconGeometry:ER,pickable:!0}):null,Ae=m.length>0?new VL({id:`ais-hull-ghost`,data:m,getPosition:k,getSog:re,getCog:ie,getHeading:oe,getRot:se,getAgeAtUpload:ce,getLength:e=>de(e,50),getBeam:e=>fe(e,10),getColor:D,uploadTimestamp:a,selfAnimate:!0,settingsIconSize:i,opacity:.75,pickable:!0}):null,je=m.length>0?new VL({id:`ais-hull-confirmed`,data:m,getPosition:k,getSog:()=>0,getCog:()=>0,getHeading:oe,getRot:()=>0,getAgeAtUpload:()=>0,getLength:e=>de(e,50),getBeam:e=>fe(e,10),getColor:D,uploadTimestamp:a,selfAnimate:!1,settingsIconSize:i,opacity:1,pickable:!0}):null,A=(e,t,n,r)=>t.length>0?new aR({id:e,data:t,getPosition:k,getSog:r?re:()=>0,getCog:r?ie:()=>0,getHeading:oe,getRot:r?se:()=>0,getAgeAtUpload:r?ce:()=>0,getLength:e=>de(e,50),getBeam:e=>fe(e,10),uploadTimestamp:a,selfAnimate:r,settingsIconSize:i,decoration:n}):null,Me=A(`ais-anchored-hull`,C,ZL,!1),j=A(`ais-moored-hull`,T,QL,!1),Ne=A(`ais-aground-hull`,w,$L,!1),Pe=A(`ais-fishing-hull`,E,eR,!1),M=A(`ais-nuc-hull`,ee,tR,!1),Fe=A(`ais-restricted-hull`,te,nR,!1),Ie=A(`ais-draught-hull`,ne,rR,!1),Le=A(`ais-anchored-hull-ghost`,C,ZL,!0),Re=A(`ais-moored-hull-ghost`,T,QL,!0),ze=A(`ais-aground-hull-ghost`,w,$L,!0),Be=A(`ais-fishing-hull-ghost`,E,eR,!0),Ve=A(`ais-nuc-hull-ghost`,ee,tR,!0),He=A(`ais-restricted-hull-ghost`,te,nR,!0),N=A(`ais-draught-hull-ghost`,ne,rR,!0);Te=[...je?[je]:[],...Me?[Me]:[],...j?[j]:[],...Ne?[Ne]:[],...Pe?[Pe]:[],...M?[M]:[],...Fe?[Fe]:[],...Ie?[Ie]:[],...Ae?[Ae]:[],...Le?[Le]:[],...Re?[Re]:[],...ze?[ze]:[],...Be?[Be]:[],...Ve?[Ve]:[],...He?[He]:[],...N?[N]:[],new rI({id:`ais-cog`,data:p,getPath:t=>{let n=e[t*7+0],r=e[t*7+1],i=e[t*7+2],a=e[t*7+3],o=e[t*7+5],s=l*60,c=isNaN(o)?0:o;if(Math.abs(c)<1e-4){let[e,t]=kR(n,r,i,isNaN(a)?0:a,0,0,s*1e3);return[[n,r],[e,t]]}let u=2*Math.PI/Math.abs(c),d=Math.min(s,u);return Array.from({length:25},(e,t)=>{let[o,s]=kR(n,r,i,isNaN(a)?0:a,c,0,d*t/24*1e3);return[o,s]})},getColor:()=>le(o,200),getWidth:s,getDashArray:ue(c,s),widthUnits:`pixels`,widthMinPixels:1,pickable:!1,extensions:[new oL({dash:!0})],updateTriggers:{getPath:[l],getColor:[o],getWidth:[s],getDashArray:[c,s]}}),...he?[he]:[],ge,..._e?[_e]:[],...ye?[ye]:[],...ve?[ve]:[],...be?[be]:[],...xe?[xe]:[],...Ee?[Ee]:[],...Oe?[Oe]:[],...ke?[ke]:[]],De()}),Nn(()=>{let e=J.appearance,t=n(),r=V(p);if(!s||!V(f)||(s.setPaintProperty(`vessel-gc-line`,`line-color`,e.gc.color),s.setPaintProperty(`vessel-gc-line`,`line-width`,e.gc.width),s.setPaintProperty(`vessel-gc-line`,`line-dasharray`,ae(e.gc.style,e.gc.width)??void 0),s.setPaintProperty(`vessel-cog-line`,`line-color`,e.cog.color),s.setPaintProperty(`vessel-cog-line`,`line-width`,e.cog.width),s.setPaintProperty(`vessel-cog-line`,`line-dasharray`,ae(e.cog.style,e.cog.width)??void 0),s.setPaintProperty(`vessel-hdg-line`,`line-color`,e.heading.color),s.setPaintProperty(`vessel-hdg-line`,`line-width`,e.heading.width),s.setPaintProperty(`vessel-hdg-line`,`line-dasharray`,ae(e.heading.style,e.heading.width)??void 0),s.setLayoutProperty(`vessel-icon`,`icon-size`,e.vesselSize/64),!t.position))return;let{longitude:i,latitude:a}=t.position;function o(e,t){if(e.lengthUnit===`nm`)return e.lengthValue*1852;if(e.lengthUnit===`min`)return t===null?0:e.lengthValue*60*t;let n=Math.cos(a*Math.PI/180)*40075016.686/(512*2**r);return e.lengthValue*n}let c=t.heading??t.cog??null,l=c===null?0:c*180/Math.PI,u={type:`FeatureCollection`,features:[{type:`Feature`,geometry:{type:`Point`,coordinates:[i,a]},properties:{bearing_deg:l}}]},d=t.cog===null?k:{type:`FeatureCollection`,features:[{type:`Feature`,geometry:{type:`LineString`,coordinates:se(i,a,t.cog,o(e.cog,t.sog))},properties:{}}]},m=t.cog===null?k:{type:`FeatureCollection`,features:[{type:`Feature`,geometry:{type:`LineString`,coordinates:ce(i,a,t.cog,o(e.gc,t.sog))},properties:{}}]},g=t.heading===null?k:{type:`FeatureCollection`,features:[{type:`Feature`,geometry:{type:`LineString`,coordinates:(V(h)===`globe`?ce:se)(i,a,t.heading,o(e.heading,t.sog))},properties:{}}]},_=s;b=()=>{let e=_.getSource(T),t=_.getSource(E),n=_.getSource(te),r=_.getSource(ee);e instanceof ru.default.GeoJSONSource&&t instanceof ru.default.GeoJSONSource&&n instanceof ru.default.GeoJSONSource&&r instanceof ru.default.GeoJSONSource&&(e.setData(u),t.setData(d),n.setData(m),r.setData(g),window.__mapDiag&&window.__mapDiag.ownVessel++)},y===null&&(y=requestAnimationFrame(()=>{y=null,b?.(),b=null}))}),Nn(()=>{let e=EL.geometry,t=EL.nextPoint,r=EL.previousPoint,i=n().position,a=J.appearance.route;if(!s||!V(f))return;let o=s.getSource(D),c=s.getSource(O);if(!(o instanceof ru.default.GeoJSONSource)||!(c instanceof ru.default.GeoJSONSource))return;s.setPaintProperty(`route-full`,`line-color`,a.remaining.color),s.setPaintProperty(`route-full`,`line-width`,a.remaining.width),s.setPaintProperty(`route-full`,`line-dasharray`,ae(a.remaining.style,a.remaining.width)??void 0),s.setPaintProperty(`route-leg`,`line-color`,a.segment.color),s.setPaintProperty(`route-leg`,`line-width`,a.segment.width),s.setPaintProperty(`route-leg`,`line-dasharray`,ae(a.segment.style,a.segment.width)??void 0),s.setPaintProperty(`route-bearing`,`line-color`,a.bearing.color),s.setPaintProperty(`route-bearing`,`line-width`,a.bearing.width),s.setPaintProperty(`route-bearing`,`line-dasharray`,ae(a.bearing.style,a.bearing.width)??void 0);let l=[];e&&l.push({type:`Feature`,geometry:e.geometry,properties:{kind:`full`}}),t&&r&&l.push({type:`Feature`,geometry:{type:`LineString`,coordinates:[[r.longitude,r.latitude],[t.longitude,t.latitude]]},properties:{kind:`leg`}}),t&&i&&l.push({type:`Feature`,geometry:{type:`LineString`,coordinates:[[i.longitude,i.latitude],[t.longitude,t.latitude]]},properties:{kind:`bearing`}}),o.setData({type:`FeatureCollection`,features:l});let u=[];t&&u.push({type:`Feature`,geometry:{type:`Point`,coordinates:[t.longitude,t.latitude]},properties:{wtype:`next`}}),r&&u.push({type:`Feature`,geometry:{type:`Point`,coordinates:[r.longitude,r.latitude]},properties:{wtype:`prev`}}),c.setData({type:`FeatureCollection`,features:u})}),Nn(()=>{if(!s)return;let e=n(),t=e.position,r=vu.mode,i;if(r===`north`?i=0:r===`cog`&&e.cog!==null?i=e.cog*180/Math.PI:r===`heading`&&e.heading!==null&&(i=e.heading*180/Math.PI),t&&mu.following){let e=s.getCenter(),n=Math.hypot(e.lng-t.longitude,e.lat-t.latitude),r=i===void 0?{}:{bearing:i};n>1?s.flyTo({center:[t.longitude,t.latitude],speed:1.5,...r}):s.easeTo({center:[t.longitude,t.latitude],duration:1e3,...r})}else i!==void 0&&!v&&s.easeTo({bearing:i,duration:300})});var Pe={flyToVessel:d,addRuler:de},Fe=PR(),Ie=yn(Fe);Ni(Ie,e=>o=e,()=>o);var Le=R(Ie,2),Re=L(Le);let ze;var Be=L(Re,!0);M(Re);var Ve=R(Re,2),He=L(Ve);{let e=Wt(()=>V(h)===`mercator`?$l:Xl);Jl(He,{get icon(){return V(e)}})}M(Ve);var N=R(Ve,2),Ue=L(N);{let e=Wt(()=>V(c)?eu:Yl);Jl(Ue,{get icon(){return V(e)}})}M(N),M(Le);var Ke=R(Le,2);let qe;var Je=L(Ke),Ye=R(L(Je)),Xe=R(Ye);M(Je),M(Ke);var Ze=R(Ke,2),Qe=e=>{var t=NR(),n=L(t);M(t),zn(()=>pi(t,`left: ${V(me).x??``}px; top: ${V(me).y??``}px;`)),H(`pointerdown`,t,e=>e.stopPropagation()),H(`click`,n,()=>{V(me)&&(mL.remove(V(me).rulerId),I(me,null))}),W(e,t)};Yr(Ze,e=>{V(me)&&e(Qe)}),zn((e,t)=>{ze=di(Re,1,`proj-btn svelte-c20cna`,null,ze,{"proj-btn--manual":vu.mode===`manual`}),Ti(Re,`title`,`Rotation mode: ${vu.label??``}`),Br(Be,vu.label),Ti(Ve,`title`,`Switch to ${V(h)===`mercator`?`Globe`:`Mercator`}`),Ti(N,`title`,V(c)?`Exit fullscreen`:`Enter fullscreen`),qe=di(Ke,1,`north-indicator svelte-c20cna`,null,qe,e),Ti(Ke,`title`,`Tap to reset to North-Up (bearing ${t??``}°)`),Ti(Ye,`transform`,`rotate(${-V(m)}, 22, 22)`),Ti(Xe,`transform`,`rotate(${-V(m)}, 22, 22)`)},[()=>({"north-indicator--visible":Math.abs(V(m))>.5}),()=>V(m).toFixed(1)]),H(`click`,Re,()=>vu.toggle(n().heading!==null,!1)),H(`click`,Ve,()=>{w(V(h)===`mercator`?`globe`:`mercator`)}),H(`click`,N,u),H(`click`,Ke,()=>s?.easeTo({bearing:0,duration:300})),W(e,Fe);var $e=Ge(Pe);return i(),$e}Ar([`click`,`pointerdown`]);var IR=U(`<p class="geo-error-note svelte-1u3w06f"> </p>`),LR=U(`<p class="section-title svelte-1u3w06f">Signal K server</p> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Protocol</label> <div class="field svelte-1u3w06f"><select class="svelte-1u3w06f"><option>ws://</option><option>wss://</option></select></div></div> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Host</label> <div class="field svelte-1u3w06f"><input type="text" placeholder="192.168.1.1" style="flex:1; font-family: monospace;" class="svelte-1u3w06f"/></div></div> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Port</label> <div class="field svelte-1u3w06f"><input type="number" min="1" max="65535" class="svelte-1u3w06f"/></div></div> <p class="hint svelte-1u3w06f"> </p> <p class="section-title svelte-1u3w06f">Position source</p> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Browser GPS</label> <div class="field svelte-1u3w06f"><label class="toggle svelte-1u3w06f"><input type="checkbox" class="svelte-1u3w06f"/> <span class="toggle-track svelte-1u3w06f"><span class="toggle-thumb svelte-1u3w06f"></span></span></label> <span class="toggle-label svelte-1u3w06f">Use device GPS instead of Signal K position</span></div></div> <!>`,1),RR=U(`<p class="section-title svelte-1u3w06f"> </p>`),zR=U(`<div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Color</label> <div class="field svelte-1u3w06f"><input type="color" class="svelte-1u3w06f"/></div></div> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Width</label> <div class="field svelte-1u3w06f"><input type="number" min="1" max="8" step="0.5" class="svelte-1u3w06f"/> <span class="unit svelte-1u3w06f">px</span></div></div> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Style</label> <div class="field svelte-1u3w06f"><select class="svelte-1u3w06f"><option>Solid</option><option>Dashed</option><option>Dotted</option><option>Dash-dot</option></select></div></div> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Length</label> <div class="field svelte-1u3w06f"><input type="number" min="0" step="0.1" style="width:72px" class="svelte-1u3w06f"/> <select class="svelte-1u3w06f"><option>nm</option><option>min at SOG</option><option>px</option></select></div></div> <!>`,1),BR=U(`<p class="section-title svelte-1u3w06f">Icon</p> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Color</label> <div class="field svelte-1u3w06f"><input type="color" class="svelte-1u3w06f"/></div></div> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Size</label> <div class="field svelte-1u3w06f"><input type="number" min="8" max="64" step="2" class="svelte-1u3w06f"/> <span class="unit svelte-1u3w06f">px</span></div></div> <p class="section-title svelte-1u3w06f">Heading predictor</p> <!>`,1),VR=U(`<p class="section-title svelte-1u3w06f">Icon</p> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Color</label> <div class="field svelte-1u3w06f"><input type="color" class="svelte-1u3w06f"/></div></div> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Size</label> <div class="field svelte-1u3w06f"><input type="number" min="8" max="48" step="2" class="svelte-1u3w06f"/> <span class="unit svelte-1u3w06f">px</span></div></div> <p class="section-title svelte-1u3w06f">COG line</p> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Color</label> <div class="field svelte-1u3w06f"><input type="color" class="svelte-1u3w06f"/></div></div> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Width</label> <div class="field svelte-1u3w06f"><input type="number" min="1" max="8" step="0.5" class="svelte-1u3w06f"/> <span class="unit svelte-1u3w06f">px</span></div></div> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Style</label> <div class="field svelte-1u3w06f"><select class="svelte-1u3w06f"><option>Solid</option><option>Dashed</option><option>Dotted</option><option>Dash-dot</option></select></div></div> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Length</label> <div class="field svelte-1u3w06f"><input type="number" min="1" max="60" step="1" class="svelte-1u3w06f"/> <span class="unit svelte-1u3w06f">min</span></div></div> <p class="section-title svelte-1u3w06f">Performance</p> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Frame rate</label> <div class="fps-field svelte-1u3w06f"><input type="range" class="fps-slider svelte-1u3w06f" min="0" max="1000"/> <span class="fps-target svelte-1u3w06f"> </span> <span class="fps-actual svelte-1u3w06f"> </span></div></div>`,1),HR=U(`<p class="section-title svelte-1u3w06f"> </p>`),UR=U(`<div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Color</label> <div class="field svelte-1u3w06f"><input type="color" class="svelte-1u3w06f"/></div></div> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Width</label> <div class="field svelte-1u3w06f"><input type="number" min="1" max="8" step="0.5" class="svelte-1u3w06f"/> <span class="unit svelte-1u3w06f">px</span></div></div> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Style</label> <div class="field svelte-1u3w06f"><select class="svelte-1u3w06f"><option>Solid</option><option>Dashed</option><option>Dotted</option><option>Dash-dot</option></select></div></div> <!>`,1),WR=U(`<p class="section-title svelte-1u3w06f">Bearing to waypoint</p> <!> <p class="section-title svelte-1u3w06f">Ruler</p> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Color</label> <input type="color" class="svelte-1u3w06f"/></div> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Width</label> <div class="field svelte-1u3w06f"><input type="number" min="1" max="8" step="0.5" class="svelte-1u3w06f"/> <span class="unit svelte-1u3w06f">px</span></div></div>`,1),GR=U(`<div class="about svelte-1u3w06f"><img src="./icon-192.png" alt="Winga logo" class="about-logo svelte-1u3w06f"/> <p class="about-name svelte-1u3w06f">Winga Chart Plotter</p> <p class="about-version svelte-1u3w06f"> <span class="about-commit svelte-1u3w06f"></span></p> <p class="about-desc svelte-1u3w06f">A sea chart plotting application for Signal K.</p> <div class="about-links svelte-1u3w06f"><a href="https://github.com/daniel-freiermuth/winga-chart-plotter" target="_blank" rel="noopener" class="svelte-1u3w06f">GitHub</a></div></div>`),KR=U(`<button class="btn btn-cancel svelte-1u3w06f">Cancel</button> <button class="btn btn-save svelte-1u3w06f">Save & reconnect</button>`,1),qR=U(`<button class="btn btn-save svelte-1u3w06f">Close</button>`),JR=U(`<button class="btn btn-cancel svelte-1u3w06f">Cancel</button> <button class="btn btn-save svelte-1u3w06f">Close</button>`,1),YR=U(`<div class="backdrop svelte-1u3w06f"></div> <div class="modal svelte-1u3w06f"><h2 class="svelte-1u3w06f">Settings</h2> <div class="tabs svelte-1u3w06f"><button>Connection</button> <button>Own vessel</button> <button>AIS</button> <button>Routes</button> <button>About</button></div> <!> <!> <!> <!> <!> <div class="actions svelte-1u3w06f"><!></div></div>`,1),XR=U(`<button title="Settings" class="gear-btn svelte-1u3w06f"><!></button> <!>`,1);function ZR(e,t){We(t,!0);let n=F(!1),r=F(`connection`),i=F(cn({protocol:J.protocol,host:J.host,port:J.port})),a=``;function o(e){return Math.round((Math.log10(e)+1)/(Math.log10(60)+1)*1e3)}function s(e){let t=10**(-1+e/1e3*(Math.log10(60)+1));return t>=10?Math.round(t):Math.round(t*10)/10}function c(e){return e>=10?`${Math.round(e)} fps`:e>=1?`${e.toFixed(1)} fps`:`every ${Math.round(1/e)}s`}function l(e){return e<=0?``:e>=10?`${Math.round(e)} fps`:`${e.toFixed(1)} fps`}function u(){I(i,{protocol:J.protocol,host:J.host,port:J.port},!0),a=JSON.stringify({appearance:J.appearance,targetFps:J.targetFps}),I(r,`connection`),I(n,!0)}function d(){J.apply({signalkProtocol:V(i).protocol,signalkHost:V(i).host,signalkPort:V(i).port,useGeoLocation:J.useGeoLocation,appearance:J.appearance,targetFps:J.targetFps}),I(n,!1)}function f(){let e=JSON.parse(a);J.apply({signalkProtocol:J.protocol,signalkHost:J.host,signalkPort:J.port,useGeoLocation:J.useGeoLocation,appearance:e.appearance,targetFps:e.targetFps}),I(n,!1)}function p(){I(n,!1)}function m(){J.apply({signalkProtocol:J.protocol,signalkHost:J.host,signalkPort:J.port,useGeoLocation:J.useGeoLocation,appearance:J.appearance,targetFps:J.targetFps})}var h=XR(),g=yn(h);Jl(L(g),{get icon(){return Zl}}),M(g);var _=R(g,2),v=e=>{var t=YR(),n=yn(t),a=R(n,2),u=R(L(a),2),h=L(u);let g;var _=R(h,2);let v;var y=R(_,2);let b;var x=R(y,2);let S;var C=R(x,2);let w;M(u);var T=R(u,2),E=e=>{var t=LR(),n=R(yn(t),2),r=R(L(n),2),a=L(r),o=L(a);o.value=o.__value=`ws`;var s=R(o);s.value=s.__value=`wss`,M(a),M(r),M(n);var c=R(n,2),l=R(L(c),2),u=L(l);Si(u),M(l),M(c);var d=R(c,2),f=R(L(d),2),p=L(f);Si(p),M(f),M(d);var m=R(d,2),h=L(m);M(m);var g=R(m,4),_=R(L(g),2),v=L(_),y=L(v);Si(y),Fe(2),M(v),Fe(2),M(_),M(g);var b=R(g,2),x=e=>{var t=IR(),n=L(t);M(t),zn(()=>Br(n,`⚠ ${J.geoError??``}`)),W(e,t)};Yr(b,e=>{J.geoError&&!J.useGeoLocation&&e(x)}),zn(()=>{Br(h,`→ ${V(i).protocol??``}://${V(i).host??``}:${V(i).port??``}/signalk/v1/stream?subscribe=self`),wi(y,J.useGeoLocation)}),gi(a,()=>V(i).protocol,e=>V(i).protocol=e),ki(u,()=>V(i).host,e=>V(i).host=e),ki(p,()=>V(i).port,e=>V(i).port=e),H(`change`,y,e=>{let t=e.target.checked;t&&`geolocation`in navigator&&navigator.geolocation.getCurrentPosition(()=>{},()=>{}),t&&typeof window.DeviceOrientationEvent.requestPermission==`function`&&window.DeviceOrientationEvent.requestPermission().then(e=>{e!==`granted`&&J.setGeoError(`Compass access denied — heading unavailable`)}).catch(()=>{}),J.apply({useGeoLocation:t})}),W(e,t)};Yr(T,e=>{V(r)===`connection`&&e(E)});var ee=R(T,2),te=e=>{var t=BR(),n=R(yn(t),2),r=R(L(n),2),i=L(r);Si(i),M(r),M(n);var a=R(n,2),o=R(L(a),2),s=L(o);Si(s),Fe(2),M(o),M(a),$r(R(a,4),16,()=>[{key:`heading`,nextTitle:`Rhumb line (COG) predictor`},{key:`cog`,nextTitle:`Great circle (GC) predictor`},{key:`gc`,nextTitle:null}],({key:e,nextTitle:t})=>e,(e,t)=>{let n=()=>t.key,r=()=>t.nextTitle,i=Wt(()=>n()===`heading`?J.appearance.heading:n()===`cog`?J.appearance.cog:J.appearance.gc);var a=zR(),o=yn(a),s=R(L(o),2),c=L(s);Si(c),M(s),M(o);var l=R(o,2),u=R(L(l),2),d=L(u);Si(d),Fe(2),M(u),M(l);var f=R(l,2),p=R(L(f),2),h=L(p),g=L(h);g.value=g.__value=`solid`;var _=R(g);_.value=_.__value=`dashed`;var v=R(_);v.value=v.__value=`dotted`;var y=R(v);y.value=y.__value=`dash-dot`,M(h),M(p),M(f);var b=R(f,2),x=R(L(b),2),S=L(x);Si(S);var C=R(S,2),w=L(C);w.value=w.__value=`nm`;var T=R(w);T.value=T.__value=`min`;var E=R(T);E.value=E.__value=`px`,M(C),M(x),M(b);var ee=R(b,2),te=e=>{var t=RR(),n=L(t,!0);M(t),zn(()=>Br(n,r())),W(e,t)};Yr(ee,e=>{r()&&e(te)}),H(`input`,c,m),ki(c,()=>V(i).color,e=>V(i).color=e),H(`input`,d,m),ki(d,()=>V(i).width,e=>V(i).width=e),H(`change`,h,m),gi(h,()=>V(i).style,e=>V(i).style=e),H(`input`,S,m),ki(S,()=>V(i).lengthValue,e=>V(i).lengthValue=e),H(`change`,C,m),gi(C,()=>V(i).lengthUnit,e=>V(i).lengthUnit=e),W(e,a)}),H(`input`,i,m),ki(i,()=>J.appearance.vesselColor,e=>J.appearance.vesselColor=e),H(`input`,s,m),ki(s,()=>J.appearance.vesselSize,e=>J.appearance.vesselSize=e),W(e,t)};Yr(ee,e=>{V(r)===`vessel`&&e(te)});var ne=R(ee,2),D=e=>{var t=VR(),n=R(yn(t),2),r=R(L(n),2),i=L(r);Si(i),M(r),M(n);var a=R(n,2),u=R(L(a),2),d=L(u);Si(d),Fe(2),M(u),M(a);var f=R(a,4),p=R(L(f),2),h=L(p);Si(h),M(p),M(f);var g=R(f,2),_=R(L(g),2),v=L(_);Si(v),Fe(2),M(_),M(g);var y=R(g,2),b=R(L(y),2),x=L(b),S=L(x);S.value=S.__value=`solid`;var C=R(S);C.value=C.__value=`dashed`;var w=R(C);w.value=w.__value=`dotted`;var T=R(w);T.value=T.__value=`dash-dot`,M(x),M(b),M(y);var E=R(y,2),ee=R(L(E),2),te=L(ee);Si(te),Fe(2),M(ee),M(E);var ne=R(E,4),D=R(L(ne),2),O=L(D);Si(O);var k=R(O,2),re=L(k,!0);M(k);var ie=R(k,2),ae=L(ie,!0);M(ie),M(D),M(ne),zn((e,t,n)=>{Ci(O,e),Br(re,t),Br(ae,n)},[()=>o(J.targetFps),()=>c(J.targetFps),()=>l(fu.value)]),H(`input`,i,m),ki(i,()=>J.appearance.ais.vesselColor,e=>J.appearance.ais.vesselColor=e),H(`input`,d,m),ki(d,()=>J.appearance.ais.vesselSize,e=>J.appearance.ais.vesselSize=e),H(`input`,h,m),ki(h,()=>J.appearance.ais.cog.color,e=>J.appearance.ais.cog.color=e),H(`input`,v,m),ki(v,()=>J.appearance.ais.cog.width,e=>J.appearance.ais.cog.width=e),H(`change`,x,m),gi(x,()=>J.appearance.ais.cog.style,e=>J.appearance.ais.cog.style=e),H(`input`,te,m),ki(te,()=>J.appearance.ais.cog.lengthMinutes,e=>J.appearance.ais.cog.lengthMinutes=e),H(`input`,O,e=>J.setTargetFps(s(+e.target.value))),W(e,t)};Yr(ne,e=>{V(r)===`ais`&&e(D)});var O=R(ne,2),k=e=>{var t=WR(),n=R(yn(t),2);$r(n,16,()=>[{key:`bearing`,nextTitle:`Active segment`},{key:`segment`,nextTitle:`Remaining route`},{key:`remaining`,nextTitle:null}],({key:e,nextTitle:t})=>e,(e,t)=>{let n=()=>t.key,r=()=>t.nextTitle,i=Wt(()=>n()===`bearing`?J.appearance.route.bearing:n()===`segment`?J.appearance.route.segment:J.appearance.route.remaining);var a=UR(),o=yn(a),s=R(L(o),2),c=L(s);Si(c),M(s),M(o);var l=R(o,2),u=R(L(l),2),d=L(u);Si(d),Fe(2),M(u),M(l);var f=R(l,2),p=R(L(f),2),h=L(p),g=L(h);g.value=g.__value=`solid`;var _=R(g);_.value=_.__value=`dashed`;var v=R(_);v.value=v.__value=`dotted`;var y=R(v);y.value=y.__value=`dash-dot`,M(h),M(p),M(f);var b=R(f,2),x=e=>{var t=HR(),n=L(t,!0);M(t),zn(()=>Br(n,r())),W(e,t)};Yr(b,e=>{r()&&e(x)}),H(`input`,c,m),ki(c,()=>V(i).color,e=>V(i).color=e),H(`input`,d,m),ki(d,()=>V(i).width,e=>V(i).width=e),H(`change`,h,m),gi(h,()=>V(i).style,e=>V(i).style=e),W(e,a)});var r=R(n,4),i=R(L(r),2);Si(i),M(r);var a=R(r,2),o=R(L(a),2),s=L(o);Si(s),Fe(2),M(o),M(a),H(`input`,i,m),ki(i,()=>J.appearance.ruler.color,e=>J.appearance.ruler.color=e),H(`input`,s,m),ki(s,()=>J.appearance.ruler.width,e=>J.appearance.ruler.width=e),W(e,t)};Yr(O,e=>{V(r)===`routes`&&e(k)});var re=R(O,2),ie=e=>{var t=GR(),n=R(L(t),4),r=L(n);r.nodeValue=`v0.8.0 `;var i=R(r);i.textContent=`#3ecafa6`,M(n),Fe(4),M(t),W(e,t)};Yr(re,e=>{V(r)===`about`&&e(ie)});var ae=R(re,2),oe=L(ae),se=e=>{var t=KR(),n=yn(t),r=R(n,2);H(`click`,n,f),H(`click`,r,d),W(e,t)},ce=e=>{var t=qR();H(`click`,t,p),W(e,t)},le=e=>{var t=JR(),n=yn(t),r=R(n,2);H(`click`,n,f),H(`click`,r,p),W(e,t)};Yr(oe,e=>{V(r)===`connection`?e(se):V(r)===`about`?e(ce,1):e(le,-1)}),M(ae),M(a),zn(()=>{g=di(h,1,`tab svelte-1u3w06f`,null,g,{active:V(r)===`connection`}),v=di(_,1,`tab svelte-1u3w06f`,null,v,{active:V(r)===`vessel`}),b=di(y,1,`tab svelte-1u3w06f`,null,b,{active:V(r)===`ais`}),S=di(x,1,`tab svelte-1u3w06f`,null,S,{active:V(r)===`routes`}),w=di(C,1,`tab svelte-1u3w06f`,null,w,{active:V(r)===`about`})}),H(`click`,n,p),H(`click`,h,()=>I(r,`connection`)),H(`click`,_,()=>I(r,`vessel`)),H(`click`,y,()=>I(r,`ais`)),H(`click`,x,()=>I(r,`routes`)),H(`click`,C,()=>I(r,`about`)),W(e,t)};Yr(_,e=>{V(n)&&e(v)}),H(`click`,g,u),W(e,h),Ge()}Ar([`click`,`change`,`input`]);var QR=U(`<li class="chart-row svelte-1mbfew2"><input type="checkbox" class="svelte-1mbfew2"/> <label class="chart-name svelte-1mbfew2"> </label></li>`),$R=U(`<li class="chart-row hint-row svelte-1mbfew2">Loading charts…</li>`),ez=U(`<li class="chart-row hint-row error svelte-1mbfew2"> </li>`),tz=U(`<span class="badge svelte-1mbfew2">WMS</span>`),nz=U(`<span class="badge svelte-1mbfew2">WMTS</span>`),rz=U(`<span class="chart-desc svelte-1mbfew2"> </span>`),iz=U(`<span class="wmts-warning svelte-1mbfew2">⚠ Cannot auto-discover tile URL (CORS). Enter template manually:</span> <div class="wmts-manual svelte-1mbfew2"><input type="text" class="wmts-input svelte-1mbfew2"/> <button class="wmts-apply svelte-1mbfew2">Apply</button></div>`,1),az=U(`<span class="wmts-ok svelte-1mbfew2">✓ Custom URL active</span> <button class="wmts-clear svelte-1mbfew2">Clear</button>`,1),oz=U(`<option> </option>`),sz=U(`<label class="wmts-showall-label svelte-1mbfew2" title="Show all layers from capabilities"><input type="checkbox" class="svelte-1mbfew2"/> All</label>`),cz=U(`<div class="wmts-layer-row svelte-1mbfew2"><label class="wmts-layer-label svelte-1mbfew2">Layer</label> <select class="wmts-layer-select svelte-1mbfew2"></select> <!></div>`),lz=U(`<span class="wmts-ok svelte-1mbfew2"> </span>`),uz=U(`<li class="chart-row svelte-1mbfew2"><input type="checkbox" class="svelte-1mbfew2"/> <div class="chart-info svelte-1mbfew2"><label class="chart-name svelte-1mbfew2"> <!> <!></label> <!> <span class="chart-meta svelte-1mbfew2"> </span> <!></div></li>`),dz=U(`<div class="backdrop svelte-1mbfew2"></div> <div class="panel svelte-1mbfew2"><div class="panel-header svelte-1mbfew2"><span class="panel-title svelte-1mbfew2">Layers</span> <button class="close-btn svelte-1mbfew2" title="Close">✕</button></div> <ul class="chart-list svelte-1mbfew2"><!> <!></ul></div>`,1),fz=U(`<button title="Charts"><!></button> <!>`,1);function pz(e,t){We(t,!0);let n=F(!1),r=cn({});function i(){I(n,!V(n))}function a(){I(n,!1)}function o(e){Y.setOverride(e,r[e]??``)}var s=fz(),c=yn(s);let l;Jl(L(c),{get icon(){return nu}}),M(c);var u=R(c,2),d=e=>{var t=dz(),n=yn(t),i=R(n,2),s=L(i),c=R(L(s),2);M(s);var l=R(s,2),u=L(l);$r(u,17,()=>Wu,e=>e.id,(e,t)=>{var n=QR(),r=L(n);Si(r);var i=R(r,2),a=L(i,!0);M(i),M(n),zn(e=>{Ti(r,`id`,`base-${V(t).id??``}`),wi(r,e),Ti(i,`for`,`base-${V(t).id??``}`),Br(a,V(t).name)},[()=>Ju.enabled.has(V(t).id)]),H(`change`,r,()=>{Ju.toggle(V(t).id)}),W(e,n)});var d=R(u,2),f=e=>{W(e,$R())},p=e=>{var t=ez(),n=L(t);M(t),zn(()=>Br(n,`⚠ ${Y.error??``}`)),W(e,t)},m=e=>{var t=Lr();$r(yn(t),17,()=>Object.entries(Y.available),([e,t])=>e,(e,t)=>{var n=Wt(()=>S(V(t),2));let i=()=>V(n)[0],a=()=>V(n)[1];var s=uz(),c=L(s);Si(c);var l=R(c,2),u=L(l),d=L(u),f=R(d),p=e=>{W(e,tz())};Yr(f,e=>{a().type===`WMS`&&e(p)});var m=R(f,2),h=e=>{W(e,nz())};Yr(m,e=>{a().type===`WMTS`&&e(h)}),M(u);var g=R(u,2),_=e=>{var t=rz(),n=L(t,!0);M(t),zn(()=>Br(n,a().description)),W(e,t)};Yr(g,e=>{a().description&&e(_)});var v=R(g,2),y=L(v);M(v);var b=R(v,2),x=e=>{var t=iz(),n=R(yn(t),2),a=L(n);Si(a),Ti(a,`placeholder`,`https://…/{z}/{x}/{y}.png`);var s=R(a,2);M(n),zn(e=>Ci(a,e),[()=>r[i()]??Y.getOverride(i())]),H(`input`,a,e=>{r[i()]=e.target.value}),H(`keydown`,a,e=>{e.key===`Enter`&&o(i())}),H(`click`,s,()=>o(i())),W(e,t)},C=Wt(()=>Y.needsManualUrl(i())),w=e=>{var t=az();H(`click`,R(yn(t),2),()=>{Y.setOverride(i(),``),r[i()]=``}),W(e,t)},T=Wt(()=>a().type===`WMTS`&&Y.getOverride(i())),E=e=>{var t=Lr(),n=yn(t),r=e=>{var t=cz(),n=L(t),r=R(n,2);$r(r,21,()=>Y.visibleLayers(i()),e=>e.id,(e,t)=>{var n=oz(),r=L(n,!0);M(n);var i={};zn(()=>{Br(r,V(t).title),i!==(i=V(t).id)&&(n.value=(n.__value=V(t).id)??``)}),W(e,n)}),M(r);var a;hi(r);var o=R(r,2),s=e=>{var t=sz(),n=L(t);Si(n),Fe(),M(t),zn(e=>wi(n,e),[()=>Y.isShowingAll(i())]),H(`change`,n,()=>Y.toggleShowAll(i())),W(e,t)},c=Wt(()=>Y.hasFilter(i()));Yr(o,e=>{V(c)&&e(s)}),M(t),zn(e=>{Ti(n,`for`,`wmts-layer-${i()??``}`),Ti(r,`id`,`wmts-layer-${i()??``}`),a!==(a=e)&&(r.value=(r.__value=e)??``,mi(r,e))},[()=>Y.getLayerSel(i())]),H(`change`,r,e=>{Y.selectLayer(i(),e.target.value)}),W(e,t)},a=Wt(()=>Y.visibleLayers(i()).length>1),o=e=>{var t=lz(),n=L(t);M(t),zn(e=>Br(n,`Layer: ${e??``}`),[()=>Y.visibleLayers(i())[0]?.title]),W(e,t)},s=Wt(()=>Y.visibleLayers(i()).length===1);Yr(n,e=>{V(a)?e(r):V(s)&&e(o,1)}),W(e,t)};Yr(b,e=>{V(C)?e(x):V(T)?e(w,1):a().type===`WMTS`&&e(E,2)}),M(l),M(s),zn((e,t,n,r)=>{Ti(c,`id`,`cp-chart-${i()??``}`),wi(c,e),c.disabled=t,Ti(u,`for`,`cp-chart-${i()??``}`),Br(d,`${a().name??``} `),Br(y,`${n??``}${r??``}`)},[()=>Y.selected.has(i()),()=>Y.needsManualUrl(i()),()=>a().format.toUpperCase(),()=>a().scale?` · 1:${a().scale.toLocaleString()}`:``]),H(`change`,c,()=>{Y.toggle(i())}),W(e,s)}),W(e,t)};Yr(d,e=>{Y.loading?e(f):Y.error?e(p,1):e(m,-1)}),M(l),M(i),H(`click`,n,a),H(`keydown`,n,a),H(`click`,c,a),W(e,t)};Yr(u,e=>{V(n)&&e(d)}),zn(()=>l=di(c,1,`charts-btn svelte-1mbfew2`,null,l,{active:V(n)})),H(`click`,c,i),W(e,s),Ge()}Ar([`click`,`keydown`,`change`,`input`]);var mz=U(`<span style="color: #f87171"> </span>`),hz=U(`<div style="position: relative; width: 100%; height: 100%;"><!> <!> <!> <div style="
|
|
3911
|
+
</div>`,i=new uu.default.Popup({closeButton:!0,maxWidth:`220px`}).setLngLat(e).setHTML(r).addTo(c);i.getElement().addEventListener(`click`,t=>{let n=t.target.closest(`[data-idx]`);if(!n)return;let r=Number(n.dataset.idx),a=rd.getTarget(r);a?.position&&(i.remove(),Ne(e,a))})}Ln(()=>{if(!c||!V(p))return;let e=c,t=Y.selected,n=Y.available,r=Object.values(n).find(e=>t.has(e.identifier)&&!!e.style),i=r?Y.styleUrl(r):null;if(i!==ae){I(p,!1),ie.clear(),ae=i,i?IL(i).then(t=>e.setStyle(t,{diff:!1})).catch(e=>{console.error(`[map] Failed to load style`,i,e),ae=null,I(p,!0)}):e.setStyle(o,{diff:!1});return}for(let r of Object.keys(n)){if(t.has(r)&&!n[r].style)continue;let i=`chart-layer-${r}`,a=`chart-${r}`;e.getLayer(i)&&e.removeLayer(i),e.getSource(a)&&e.removeSource(a),ie.delete(r)}for(let[r,i]of Object.entries(n)){if(!t.has(r)||i.style)continue;let n=Y.tileUrl(i);if(!n)continue;let a=`chart-${r}`,o=`chart-layer-${r}`;if(ie.get(r)!==n&&(e.getLayer(o)&&e.removeLayer(o),e.getSource(a)&&e.removeSource(a),ie.set(r,n)),!e.getSource(a)){let t=n.includes(`{-y}`),r=t?n.replace(`{-y}`,`{y}`):n;i.format===`pbf`?e.addSource(a,{type:`vector`,tiles:[r]}):e.addSource(a,{type:`raster`,tiles:[r],tileSize:256,scheme:t?`tms`:`xyz`,minzoom:i.minzoom??0,maxzoom:i.maxzoom??22})}if(!e.getLayer(o))if(i.format===`pbf`){let t=i.layers?.[0]??r;e.addLayer({id:o,type:`fill`,source:a,"source-layer":t},`vessel-gc-line`)}else e.addLayer({id:o,type:`raster`,source:a},`vessel-gc-line`)}}),Ln(()=>{if(!c||!V(p))return;let e=td.enabled;for(let t of Zu)c.getLayer(t.id)&&c.setLayoutProperty(t.id,`visibility`,e.has(t.id)?`visible`:`none`)}),Ln(()=>{if(!c||!V(p))return;let e=GR(64,J.appearance.vesselColor);c.updateImage(`vessel-icon`,{width:64,height:64,data:e.data})}),Ln(()=>{!c||!V(p)||c.setPaintProperty(`ais-label`,`text-color`,J.appearance.ais.vesselColor)}),Ln(()=>{if(!c||!V(p))return;let e=c.getSource(D);if(!(e instanceof uu.default.GeoJSONSource))return;let t=rd.hotData,n=rd.ids,r=rd.coldMap;rd.coldVersion;let i=[];if(t&&n.length>0)for(let e=0;e<n.length;e++)i.push({type:`Feature`,geometry:{type:`Point`,coordinates:[t[e*7+0],t[e*7+1]]},properties:{label:r.get(n[e])?.name??``}});let a=()=>{S=Date.now(),e.setData({type:`FeatureCollection`,features:i}),window.__mapDiag&&window.__mapDiag.aisLabels++};w=a;let o=1e3-(Date.now()-S);o<=0?(C!==null&&(clearTimeout(C),C=null),a(),w=null):C===null&&(C=setTimeout(()=>{C=null,w?.(),w=null},o))}),Ln(()=>{let e=rd.hotData,t=rd.ids,n=rd.coldMap;rd.coldVersion;let r=J.appearance.ais,i=r.vesselSize/64,a=Date.now(),o=r.cog.color,s=r.cog.width,c=r.cog.style,l=r.cog.lengthMinutes;if(!e||t.length===0){Te=[],De(),Se=null,Ce=[],we=0;return}let u=t.length,d=[],f=[],p=[],m=[],h=[],g=[],_=[],v=[],y=[],b=[],x=[],S=[],C=[],w=[],T=[],E=[],ee=[],te=[],ne=[];for(let r=0;r<u;r++){let i=n.get(t[r]),a=i?.navState?.toLowerCase()??``;if(a.includes(`sart`)||a.includes(`transponder`)){S.push(r);continue}d.push(r);let o=e[r*7+3],s=e[r*7+2];!isNaN(s)&&!isNaN(o)&&o>.1&&(f.push(r),p.push(r));let c=e[r*7+4],l=!isNaN(c)&&(i?.lengthM??0)>0&&(i?.beamM??0)>0;l&&m.push(r),a.includes(`aground`)?(g.push(r),l&&w.push(r)):a.includes(`anchor`)?(h.push(r),l&&C.push(r)):a.includes(`moor`)?(_.push(r),l&&T.push(r)):a.includes(`fishing`)?(v.push(r),l&&E.push(r)):a.includes(`command`)?(y.push(r),l&&ee.push(r)):a.includes(`restrict`)?(b.push(r),l&&te.push(r)):a.includes(`draught`)&&(x.push(r),l&&ne.push(r))}Se=e,Ce=t,we=a;let D=ue(r.vesselColor,220),O=ue(r.vesselColor,130),[k,re,ie]=D,ae=(k*.299+re*.587+ie*.114)/255,oe=(e,t,n)=>Math.round(e+(t-e)*n),se=ae<.5?255:0,ce=oe(k,se,.5),le=oe(re,se,.5),fe=oe(ie,se,.5),pe=[ce,le,fe,220],me=[ce,le,fe,160],A=t=>[e[t*7+0],e[t*7+1],0],he=t=>{let n=e[t*7+3];return isNaN(n)?0:n},ge=t=>{let n=e[t*7+2];return isNaN(n)?0:n},_e=t=>{let n=e[t*7+4];if(!isNaN(n))return n;let r=e[t*7+2];return isNaN(r)?0:r},ve=t=>{let n=e[t*7+4];return isNaN(n)?0:n},ye=t=>{let n=e[t*7+5];return isNaN(n)?0:n},be=t=>e[t*7+6],xe=(e,r)=>n.get(t[e])?.lengthM??r,Ee=(e,r)=>n.get(t[e])?.beamM??r,Oe=new Set(m),ke=e=>Oe.has(e)?xe(e,0):0,Ae=f.length>0?new VR({id:`ais-ghost-icon`,data:f,getPosition:A,getSog:he,getCog:ge,getHeading:_e,getRot:ye,getAgeAtUpload:be,getLength:ke,getColor:O,uploadTimestamp:a,selfAnimate:!0,settingsIconSize:i,pickable:!0}):null,je=new VR({id:`ais-confirmed-icon`,data:d,getPosition:A,getSog:()=>0,getCog:()=>0,getHeading:_e,getRot:()=>0,getAgeAtUpload:()=>0,getLength:ke,getColor:D,uploadTimestamp:a,selfAnimate:!1,settingsIconSize:i,pickable:!0}),Me=h.length>0?new VR({id:`ais-anchored-icon`,data:h,getPosition:A,getSog:()=>0,getCog:()=>0,getHeading:_e,getRot:()=>0,getAgeAtUpload:()=>0,getLength:ke,getColor:D,uploadTimestamp:a,selfAnimate:!1,settingsIconSize:i,iconGeometry:MR,pickable:!1}):null,j=_.length>0?new VR({id:`ais-moored-icon`,data:_,getPosition:A,getSog:()=>0,getCog:()=>0,getHeading:_e,getRot:()=>0,getAgeAtUpload:()=>0,getLength:ke,getColor:D,uploadTimestamp:a,selfAnimate:!1,settingsIconSize:i,iconGeometry:PR,pickable:!1}):null,Ne=g.length>0?new VR({id:`ais-aground-icon`,data:g,getPosition:A,getSog:()=>0,getCog:()=>0,getHeading:_e,getRot:()=>0,getAgeAtUpload:()=>0,getLength:ke,getColor:D,uploadTimestamp:a,selfAnimate:!1,settingsIconSize:i,iconGeometry:NR,pickable:!1}):null,M=v.length>0?new VR({id:`ais-fishing-icon`,data:v,getPosition:A,getSog:()=>0,getCog:()=>0,getHeading:_e,getRot:()=>0,getAgeAtUpload:()=>0,getLength:ke,getColor:D,uploadTimestamp:a,selfAnimate:!1,settingsIconSize:i,iconGeometry:FR,pickable:!1}):null,Pe=y.length>0?new VR({id:`ais-nuc-icon`,data:y,getPosition:A,getSog:()=>0,getCog:()=>0,getHeading:_e,getRot:()=>0,getAgeAtUpload:()=>0,getLength:ke,getColor:D,uploadTimestamp:a,selfAnimate:!1,settingsIconSize:i,iconGeometry:IR,pickable:!1}):null,Fe=b.length>0?new VR({id:`ais-restricted-icon`,data:b,getPosition:A,getSog:()=>0,getCog:()=>0,getHeading:_e,getRot:()=>0,getAgeAtUpload:()=>0,getLength:ke,getColor:D,uploadTimestamp:a,selfAnimate:!1,settingsIconSize:i,iconGeometry:LR,pickable:!1}):null,N=x.length>0?new VR({id:`ais-draught-icon`,data:x,getPosition:A,getSog:()=>0,getCog:()=>0,getHeading:_e,getRot:()=>0,getAgeAtUpload:()=>0,getLength:ke,getColor:D,uploadTimestamp:a,selfAnimate:!1,settingsIconSize:i,iconGeometry:RR,pickable:!1}):null,Ie=S.length>0?new VR({id:`ais-mob-icon`,data:S,getPosition:A,getSog:()=>0,getCog:()=>0,getHeading:()=>0,getRot:()=>0,getAgeAtUpload:()=>0,getLength:()=>0,getColor:()=>[255,40,40,220],uploadTimestamp:a,selfAnimate:!1,settingsIconSize:i,iconGeometry:zR,pickable:!0}):null,Le=m.length>0?new JL({id:`ais-hull-ghost`,data:m,getPosition:A,getSog:he,getCog:ge,getHeading:ve,getRot:ye,getAgeAtUpload:be,getLength:e=>xe(e,50),getBeam:e=>Ee(e,10),getColor:D,uploadTimestamp:a,selfAnimate:!0,settingsIconSize:i,opacity:.75,pickable:!0}):null,Re=m.length>0?new JL({id:`ais-hull-confirmed`,data:m,getPosition:A,getSog:()=>0,getCog:()=>0,getHeading:ve,getRot:()=>0,getAgeAtUpload:()=>0,getLength:e=>xe(e,50),getBeam:e=>Ee(e,10),getColor:D,uploadTimestamp:a,selfAnimate:!1,settingsIconSize:i,opacity:1,pickable:!0}):null,ze=(e,t,n,r)=>t.length>0?new mR({id:e,data:t,getPosition:A,getSog:r?he:()=>0,getCog:r?ge:()=>0,getHeading:ve,getRot:r?ye:()=>0,getAgeAtUpload:r?be:()=>0,getLength:e=>xe(e,50),getBeam:e=>Ee(e,10),uploadTimestamp:a,selfAnimate:r,settingsIconSize:i,decoration:n}):null,Be=(e,t,n,r)=>m.length>0?new vR({id:e,data:m,getPosition:A,getSog:t?he:()=>0,getCog:t?ge:()=>0,getHeading:ve,getRot:t?ye:()=>0,getAgeAtUpload:t?be:()=>0,getLength:e=>xe(e,50),getBeam:e=>Ee(e,10),getBorderColor:()=>n,uploadTimestamp:a,selfAnimate:t,settingsIconSize:i,opacity:r}):null,Ve=Be(`ais-hull-border-confirmed`,!1,pe,1),He=Be(`ais-hull-border-ghost`,!0,me,.75),Ue=ze(`ais-anchored-hull`,C,oR,!1),We=ze(`ais-moored-hull`,T,sR,!1),Ge=ze(`ais-aground-hull`,w,cR,!1),Ke=ze(`ais-fishing-hull`,E,lR,!1),qe=ze(`ais-nuc-hull`,ee,uR,!1),Je=ze(`ais-restricted-hull`,te,dR,!1),Ye=ze(`ais-draught-hull`,ne,fR,!1),Xe=ze(`ais-anchored-hull-ghost`,C,oR,!0),Ze=ze(`ais-moored-hull-ghost`,T,sR,!0),Qe=ze(`ais-aground-hull-ghost`,w,cR,!0),$e=ze(`ais-fishing-hull-ghost`,E,lR,!0),et=ze(`ais-nuc-hull-ghost`,ee,uR,!0),tt=ze(`ais-restricted-hull-ghost`,te,dR,!0),nt=ze(`ais-draught-hull-ghost`,ne,fR,!0);Te=[...Re?[Re]:[],...Ve?[Ve]:[],...Ue?[Ue]:[],...We?[We]:[],...Ge?[Ge]:[],...Ke?[Ke]:[],...qe?[qe]:[],...Je?[Je]:[],...Ye?[Ye]:[],...Le?[Le]:[],...He?[He]:[],...Xe?[Xe]:[],...Ze?[Ze]:[],...Qe?[Qe]:[],...$e?[$e]:[],...et?[et]:[],...tt?[tt]:[],...nt?[nt]:[],new uI({id:`ais-cog`,data:p,getPath:t=>{let n=e[t*7+0],r=e[t*7+1],i=e[t*7+2],a=e[t*7+3],o=e[t*7+5],s=l*60,c=isNaN(o)?0:o;if(Math.abs(c)<1e-4){let[e,t]=HR(n,r,i,isNaN(a)?0:a,0,0,s*1e3);return[[n,r],[e,t]]}let u=2*Math.PI/Math.abs(c),d=Math.min(s,u);return Array.from({length:25},(e,t)=>{let[o,s]=HR(n,r,i,isNaN(a)?0:a,c,0,d*t/24*1e3);return[o,s]})},getColor:()=>ue(o,200),getWidth:s,getDashArray:de(c,s),widthUnits:`pixels`,widthMinPixels:1,pickable:!1,extensions:[new pL({dash:!0})],updateTriggers:{getPath:[l],getColor:[o],getWidth:[s],getDashArray:[c,s]}}),...Ae?[Ae]:[],je,...Me?[Me]:[],...Ne?[Ne]:[],...j?[j]:[],...M?[M]:[],...Pe?[Pe]:[],...Fe?[Fe]:[],...N?[N]:[],...Ie?[Ie]:[]],De()}),Ln(()=>{let e=J.appearance;!c||!V(p)||(c.setPaintProperty(`vessel-gc-line`,`line-color`,e.gc.color),c.setPaintProperty(`vessel-gc-line`,`line-width`,e.gc.width),c.setPaintProperty(`vessel-gc-line`,`line-dasharray`,oe(e.gc.style,e.gc.width)??void 0),c.setPaintProperty(`vessel-cog-line`,`line-color`,e.cog.color),c.setPaintProperty(`vessel-cog-line`,`line-width`,e.cog.width),c.setPaintProperty(`vessel-cog-line`,`line-dasharray`,oe(e.cog.style,e.cog.width)??void 0),c.setPaintProperty(`vessel-hdg-line`,`line-color`,e.heading.color),c.setPaintProperty(`vessel-hdg-line`,`line-width`,e.heading.width),c.setPaintProperty(`vessel-hdg-line`,`line-dasharray`,oe(e.heading.style,e.heading.width)??void 0),c.setLayoutProperty(`vessel-icon`,`icon-size`,e.vesselSize/64))}),Ln(()=>{let e=J.appearance,t=n(),r=V(m);if(!c||!V(p)||!t.position)return;let{longitude:i,latitude:a}=t.position;function o(e,t){if(e.lengthUnit===`nm`)return e.lengthValue*1852;if(e.lengthUnit===`min`)return t===null?0:e.lengthValue*60*t;let n=Math.cos(a*Math.PI/180)*40075016.686/(512*2**r);return e.lengthValue*n}let s=t.heading??t.cog??null,l=s===null?0:s*180/Math.PI,u={type:`FeatureCollection`,features:[{type:`Feature`,geometry:{type:`Point`,coordinates:[i,a]},properties:{bearing_deg:l}}]},d=t.cog===null?re:{type:`FeatureCollection`,features:[{type:`Feature`,geometry:{type:`LineString`,coordinates:ce(i,a,t.cog,o(e.cog,t.sog))},properties:{}}]},f=t.cog===null?re:{type:`FeatureCollection`,features:[{type:`Feature`,geometry:{type:`LineString`,coordinates:le(i,a,t.cog,o(e.gc,t.sog))},properties:{}}]},h=t.heading===null?re:{type:`FeatureCollection`,features:[{type:`Feature`,geometry:{type:`LineString`,coordinates:(V(g)===`globe`?le:ce)(i,a,t.heading,o(e.heading,t.sog))},properties:{}}]},_=c;x=()=>{let e=_.getSource(E),t=_.getSource(ee),n=_.getSource(ne),r=_.getSource(te);e instanceof uu.default.GeoJSONSource&&t instanceof uu.default.GeoJSONSource&&n instanceof uu.default.GeoJSONSource&&r instanceof uu.default.GeoJSONSource&&(e.setData(u),t.setData(d),n.setData(f),r.setData(h),window.__mapDiag&&window.__mapDiag.ownVessel++)},b===null&&(b=requestAnimationFrame(()=>{b=null,x?.(),x=null}))}),Ln(()=>{let e=NL.geometry,t=NL.nextPoint,r=NL.previousPoint,i=n().position,a=J.appearance.route;if(!c||!V(p))return;let o=c.getSource(O),s=c.getSource(k);if(!(o instanceof uu.default.GeoJSONSource)||!(s instanceof uu.default.GeoJSONSource))return;c.setPaintProperty(`route-full`,`line-color`,a.remaining.color),c.setPaintProperty(`route-full`,`line-width`,a.remaining.width),c.setPaintProperty(`route-full`,`line-dasharray`,oe(a.remaining.style,a.remaining.width)??void 0),c.setPaintProperty(`route-leg`,`line-color`,a.segment.color),c.setPaintProperty(`route-leg`,`line-width`,a.segment.width),c.setPaintProperty(`route-leg`,`line-dasharray`,oe(a.segment.style,a.segment.width)??void 0),c.setPaintProperty(`route-bearing`,`line-color`,a.bearing.color),c.setPaintProperty(`route-bearing`,`line-width`,a.bearing.width),c.setPaintProperty(`route-bearing`,`line-dasharray`,oe(a.bearing.style,a.bearing.width)??void 0);let l=[];e&&l.push({type:`Feature`,geometry:e.geometry,properties:{kind:`full`}}),t&&r&&l.push({type:`Feature`,geometry:{type:`LineString`,coordinates:[[r.longitude,r.latitude],[t.longitude,t.latitude]]},properties:{kind:`leg`}}),t&&i&&l.push({type:`Feature`,geometry:{type:`LineString`,coordinates:[[i.longitude,i.latitude],[t.longitude,t.latitude]]},properties:{kind:`bearing`}}),o.setData({type:`FeatureCollection`,features:l});let u=[];t&&u.push({type:`Feature`,geometry:{type:`Point`,coordinates:[t.longitude,t.latitude]},properties:{wtype:`next`}}),r&&u.push({type:`Feature`,geometry:{type:`Point`,coordinates:[r.longitude,r.latitude]},properties:{wtype:`prev`}}),s.setData({type:`FeatureCollection`,features:u})}),Ln(()=>{if(!c)return;let e=n(),t=e.position,r=Tu.mode,i;if(r===`north`?i=0:r===`cog`&&e.cog!==null?i=e.cog*180/Math.PI:r===`heading`&&e.heading!==null&&(i=e.heading*180/Math.PI),t&&xu.following){let e=c.getCenter(),n=Math.hypot(e.lng-t.longitude,e.lat-t.latitude),r=i===void 0?{}:{bearing:i};n>1?c.flyTo({center:[t.longitude,t.latitude],speed:1.5,...r}):c.easeTo({center:[t.longitude,t.latitude],duration:1e3,...r})}else i!==void 0&&!y&&c.easeTo({bearing:i,duration:300})});var Pe={flyToVessel:f,addRuler:fe},Fe=qR(),Ie=Cn(Fe);zi(Ie,e=>s=e,()=>s);var Le=R(Ie,2),Re=L(Le);let ze;var Be=L(Re,!0);N(Re);var Ve=R(Re,2),He=L(Ve);{let e=Jt(()=>V(g)===`mercator`?ou:ru);tu(He,{get icon(){return V(e)}})}N(Ve);var Ue=R(Ve,2),We=L(Ue);{let e=Jt(()=>V(l)?su:nu);tu(We,{get icon(){return V(e)}})}N(Ue),N(Le);var Ge=R(Le,2);let Je;var Ye=L(Ge),Xe=R(L(Ye)),Ze=R(Xe);N(Ye),N(Ge);var Qe=R(Ge,2),$e=e=>{var t=KR(),n=L(t);N(t),Un(()=>yi(t,`left: ${V(A).x??``}px; top: ${V(A).y??``}px;`)),H(`pointerdown`,t,e=>e.stopPropagation()),H(`click`,n,()=>{V(A)&&(xL.remove(V(A).rulerId),I(A,null))}),W(e,t)};ti(Qe,e=>{V(A)&&e($e)}),Un((e,t)=>{ze=_i(Re,1,`proj-btn svelte-c20cna`,null,ze,{"proj-btn--manual":Tu.mode===`manual`}),ji(Re,`title`,`Rotation mode: ${Tu.label??``}`),Kr(Be,Tu.label),ji(Ve,`title`,`Switch to ${V(g)===`mercator`?`Globe`:`Mercator`}`),ji(Ue,`title`,V(l)?`Exit fullscreen`:`Enter fullscreen`),Je=_i(Ge,1,`north-indicator svelte-c20cna`,null,Je,e),ji(Ge,`title`,`Tap to reset to North-Up (bearing ${t??``}°)`),ji(Xe,`transform`,`rotate(${-V(h)}, 22, 22)`),ji(Ze,`transform`,`rotate(${-V(h)}, 22, 22)`)},[()=>({"north-indicator--visible":Math.abs(V(h))>.5}),()=>V(h).toFixed(1)]),H(`click`,Re,()=>Tu.toggle(n().heading!==null,!1)),H(`click`,Ve,()=>{T(V(g)===`mercator`?`globe`:`mercator`)}),H(`click`,Ue,d),H(`click`,Ge,()=>c?.easeTo({bearing:0,duration:300})),W(e,Fe);var et=qe(Pe);return i(),et}Ir([`click`,`pointerdown`]);var YR=U(`<div class="color-input svelte-weju5m"><input type="color" class="swatch svelte-weju5m"/> <input type="text" class="hex-field svelte-weju5m" autocomplete="off"/></div>`);function XR(e,t){Ke(t,!0);let n=Bi(t,`value`,15),r=F(fn(n()));Ln(()=>{I(r,n(),!0)});function i(e){n(e.target.value),I(r,n(),!0),t.oninput?.()}function a(e){I(r,e.target.value,!0);let i=V(r).startsWith(`#`)?V(r):`#${V(r)}`;/^#[0-9a-fA-F]{6}$/.test(i)&&(n(i),t.oninput?.())}function o(){I(r,n(),!0)}var s=YR(),c=L(s);Oi(c);var l=R(c,2);Oi(l),ji(l,`maxlength`,7),ji(l,`spellcheck`,!1),N(s),Un(()=>{ki(c,n()),ki(l,V(r))}),H(`input`,c,i),H(`input`,l,a),Fr(`blur`,l,o),W(e,s),qe()}Ir([`input`]);var ZR=U(`<p class="geo-error-note svelte-1u3w06f"> </p>`),QR=U(`<p class="section-title svelte-1u3w06f">Signal K server</p> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Protocol</label> <div class="field svelte-1u3w06f"><select class="svelte-1u3w06f"><option>ws://</option><option>wss://</option></select></div></div> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Host</label> <div class="field svelte-1u3w06f"><input type="text" placeholder="192.168.1.1" style="flex:1; font-family: monospace;" class="svelte-1u3w06f"/></div></div> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Port</label> <div class="field svelte-1u3w06f"><input type="number" min="1" max="65535" class="svelte-1u3w06f"/></div></div> <p class="hint svelte-1u3w06f"> </p> <p class="section-title svelte-1u3w06f">Position source</p> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Browser GPS</label> <div class="field svelte-1u3w06f"><label class="toggle svelte-1u3w06f"><input type="checkbox" class="svelte-1u3w06f"/> <span class="toggle-track svelte-1u3w06f"><span class="toggle-thumb svelte-1u3w06f"></span></span></label> <span class="toggle-label svelte-1u3w06f">Use device GPS instead of Signal K position</span></div></div> <!>`,1),$R=U(`<p class="section-title svelte-1u3w06f"> </p>`),ez=U(`<div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Color</label> <div class="field svelte-1u3w06f"><!></div></div> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Width</label> <div class="field svelte-1u3w06f"><input type="number" min="1" max="8" step="0.5" class="svelte-1u3w06f"/> <span class="unit svelte-1u3w06f">px</span></div></div> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Style</label> <div class="field svelte-1u3w06f"><select class="svelte-1u3w06f"><option>Solid</option><option>Dashed</option><option>Dotted</option><option>Dash-dot</option></select></div></div> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Length</label> <div class="field svelte-1u3w06f"><input type="number" min="0" step="0.1" style="width:72px" class="svelte-1u3w06f"/> <select class="svelte-1u3w06f"><option>nm</option><option>min at SOG</option><option>px</option></select></div></div> <!>`,1),tz=U(`<p class="section-title svelte-1u3w06f">Icon</p> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Color</label> <div class="field svelte-1u3w06f"><!></div></div> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Size</label> <div class="field svelte-1u3w06f"><input type="number" min="8" max="64" step="2" class="svelte-1u3w06f"/> <span class="unit svelte-1u3w06f">px</span></div></div> <p class="section-title svelte-1u3w06f">Heading predictor</p> <!>`,1),nz=U(`<p class="section-title svelte-1u3w06f">Icon</p> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Color</label> <div class="field svelte-1u3w06f"><!></div></div> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Size</label> <div class="field svelte-1u3w06f"><input type="number" min="8" max="48" step="2" class="svelte-1u3w06f"/> <span class="unit svelte-1u3w06f">px</span></div></div> <p class="section-title svelte-1u3w06f">COG line</p> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Color</label> <div class="field svelte-1u3w06f"><!></div></div> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Width</label> <div class="field svelte-1u3w06f"><input type="number" min="1" max="8" step="0.5" class="svelte-1u3w06f"/> <span class="unit svelte-1u3w06f">px</span></div></div> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Style</label> <div class="field svelte-1u3w06f"><select class="svelte-1u3w06f"><option>Solid</option><option>Dashed</option><option>Dotted</option><option>Dash-dot</option></select></div></div> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Length</label> <div class="field svelte-1u3w06f"><input type="number" min="1" max="60" step="1" class="svelte-1u3w06f"/> <span class="unit svelte-1u3w06f">min</span></div></div> <p class="section-title svelte-1u3w06f">Performance</p> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Frame rate</label> <div class="fps-field svelte-1u3w06f"><input type="range" class="fps-slider svelte-1u3w06f" min="0" max="1000"/> <span class="fps-target svelte-1u3w06f"> </span> <span class="fps-actual svelte-1u3w06f"> </span></div></div>`,1),rz=U(`<p class="section-title svelte-1u3w06f"> </p>`),iz=U(`<div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Color</label> <div class="field svelte-1u3w06f"><!></div></div> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Width</label> <div class="field svelte-1u3w06f"><input type="number" min="1" max="8" step="0.5" class="svelte-1u3w06f"/> <span class="unit svelte-1u3w06f">px</span></div></div> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Style</label> <div class="field svelte-1u3w06f"><select class="svelte-1u3w06f"><option>Solid</option><option>Dashed</option><option>Dotted</option><option>Dash-dot</option></select></div></div> <!>`,1),az=U(`<p class="section-title svelte-1u3w06f">Bearing to waypoint</p> <!> <p class="section-title svelte-1u3w06f">Ruler</p> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Color</label> <div class="field svelte-1u3w06f"><!></div></div> <div class="row svelte-1u3w06f"><label class="svelte-1u3w06f">Width</label> <div class="field svelte-1u3w06f"><input type="number" min="1" max="8" step="0.5" class="svelte-1u3w06f"/> <span class="unit svelte-1u3w06f">px</span></div></div>`,1),oz=U(`<div class="about svelte-1u3w06f"><img src="./icon-192.png" alt="Winga logo" class="about-logo svelte-1u3w06f"/> <p class="about-name svelte-1u3w06f">Winga Chart Plotter</p> <p class="about-version svelte-1u3w06f"> <span class="about-commit svelte-1u3w06f"></span></p> <p class="about-desc svelte-1u3w06f">A sea chart plotting application for Signal K.</p> <div class="about-links svelte-1u3w06f"><a href="https://github.com/daniel-freiermuth/winga-chart-plotter" target="_blank" rel="noopener" class="svelte-1u3w06f">GitHub</a></div></div>`),sz=U(`<button class="btn btn-cancel svelte-1u3w06f">Cancel</button> <button class="btn btn-save svelte-1u3w06f">Save & reconnect</button>`,1),cz=U(`<button class="btn btn-save svelte-1u3w06f">Close</button>`),lz=U(`<button class="btn btn-cancel svelte-1u3w06f">Cancel</button> <button class="btn btn-save svelte-1u3w06f">Close</button>`,1),uz=U(`<div class="backdrop svelte-1u3w06f"></div> <div class="modal svelte-1u3w06f"><h2 class="svelte-1u3w06f">Settings</h2> <div class="tabs svelte-1u3w06f"><button>Connection</button> <button>Own vessel</button> <button>AIS</button> <button>Routes</button> <button>About</button></div> <!> <!> <!> <!> <!> <div class="actions svelte-1u3w06f"><!></div></div>`,1),dz=U(`<button title="Settings" class="gear-btn svelte-1u3w06f"><!></button> <!>`,1);function fz(e,t){Ke(t,!0);let n=F(!1),r=F(`connection`),i=F(fn({protocol:J.protocol,host:J.host,port:J.port})),a=``;function o(e){return Math.round((Math.log10(e)+1)/(Math.log10(60)+1)*1e3)}function s(e){let t=10**(-1+e/1e3*(Math.log10(60)+1));return t>=10?Math.round(t):Math.round(t*10)/10}function c(e){return e>=10?`${Math.round(e)} fps`:e>=1?`${e.toFixed(1)} fps`:`every ${Math.round(1/e)}s`}function l(e){return e<=0?``:e>=10?`${Math.round(e)} fps`:`${e.toFixed(1)} fps`}function u(){I(i,{protocol:J.protocol,host:J.host,port:J.port},!0),a=JSON.stringify({appearance:J.appearance,targetFps:J.targetFps}),I(r,`connection`),I(n,!0)}function d(e){I(i,{protocol:J.protocol,host:J.host,port:J.port},!0),a=JSON.stringify({appearance:J.appearance,targetFps:J.targetFps}),I(r,e,!0),I(n,!0)}function f(){J.apply({signalkProtocol:V(i).protocol,signalkHost:V(i).host,signalkPort:V(i).port,useGeoLocation:J.useGeoLocation,appearance:J.appearance,targetFps:J.targetFps}),I(n,!1)}function p(){let e=JSON.parse(a);J.apply({signalkProtocol:J.protocol,signalkHost:J.host,signalkPort:J.port,useGeoLocation:J.useGeoLocation,appearance:e.appearance,targetFps:e.targetFps}),I(n,!1)}function m(){I(n,!1)}function h(){J.apply({signalkProtocol:J.protocol,signalkHost:J.host,signalkPort:J.port,useGeoLocation:J.useGeoLocation,appearance:J.appearance,targetFps:J.targetFps})}var g={openTo:d},_=dz(),v=Cn(_);tu(L(v),{get icon(){return iu}}),N(v);var y=R(v,2),b=e=>{var t=uz(),n=Cn(t),a=R(n,2),u=R(L(a),2),d=L(u);let g;var _=R(d,2);let v;var y=R(_,2);let b;var x=R(y,2);let S;var C=R(x,2);let w;N(u);var T=R(u,2),E=e=>{var t=QR(),n=R(Cn(t),2),r=R(L(n),2),a=L(r),o=L(a);o.value=o.__value=`ws`;var s=R(o);s.value=s.__value=`wss`,N(a),N(r),N(n);var c=R(n,2),l=R(L(c),2),u=L(l);Oi(u),N(l),N(c);var d=R(c,2),f=R(L(d),2),p=L(f);Oi(p),N(f),N(d);var m=R(d,2),h=L(m);N(m);var g=R(m,4),_=R(L(g),2),v=L(_),y=L(v);Oi(y),Ie(2),N(v),Ie(2),N(_),N(g);var b=R(g,2),x=e=>{var t=ZR(),n=L(t);N(t),Un(()=>Kr(n,`⚠ ${J.geoError??``}`)),W(e,t)};ti(b,e=>{J.geoError&&!J.useGeoLocation&&e(x)}),Un(()=>{Kr(h,`→ ${V(i).protocol??``}://${V(i).host??``}:${V(i).port??``}/signalk/v1/stream?subscribe=self`),Ai(y,J.useGeoLocation)}),Si(a,()=>V(i).protocol,e=>V(i).protocol=e),Fi(u,()=>V(i).host,e=>V(i).host=e),Fi(p,()=>V(i).port,e=>V(i).port=e),H(`change`,y,e=>{let t=e.target.checked;t&&`geolocation`in navigator&&navigator.geolocation.getCurrentPosition(()=>{},()=>{}),t&&typeof window.DeviceOrientationEvent.requestPermission==`function`&&window.DeviceOrientationEvent.requestPermission().then(e=>{e!==`granted`&&J.setGeoError(`Compass access denied — heading unavailable`)}).catch(()=>{}),J.apply({useGeoLocation:t})}),W(e,t)};ti(T,e=>{V(r)===`connection`&&e(E)});var ee=R(T,2),te=e=>{var t=tz(),n=R(Cn(t),2),r=R(L(n),2);XR(L(r),{oninput:h,get value(){return J.appearance.vesselColor},set value(e){J.appearance.vesselColor=e}}),N(r),N(n);var i=R(n,2),a=R(L(i),2),o=L(a);Oi(o),Ie(2),N(a),N(i),ai(R(i,4),16,()=>[{key:`heading`,nextTitle:`Rhumb line (COG) predictor`},{key:`cog`,nextTitle:`Great circle (GC) predictor`},{key:`gc`,nextTitle:null}],({key:e,nextTitle:t})=>e,(e,t)=>{let n=()=>t.key,r=()=>t.nextTitle,i=Jt(()=>n()===`heading`?J.appearance.heading:n()===`cog`?J.appearance.cog:J.appearance.gc);var a=ez(),o=Cn(a),s=R(L(o),2);XR(L(s),{oninput:h,get value(){return V(i).color},set value(e){V(i).color=e}}),N(s),N(o);var c=R(o,2),l=R(L(c),2),u=L(l);Oi(u),Ie(2),N(l),N(c);var d=R(c,2),f=R(L(d),2),p=L(f),m=L(p);m.value=m.__value=`solid`;var g=R(m);g.value=g.__value=`dashed`;var _=R(g);_.value=_.__value=`dotted`;var v=R(_);v.value=v.__value=`dash-dot`,N(p),N(f),N(d);var y=R(d,2),b=R(L(y),2),x=L(b);Oi(x);var S=R(x,2),C=L(S);C.value=C.__value=`nm`;var w=R(C);w.value=w.__value=`min`;var T=R(w);T.value=T.__value=`px`,N(S),N(b),N(y);var E=R(y,2),ee=e=>{var t=$R(),n=L(t,!0);N(t),Un(()=>Kr(n,r())),W(e,t)};ti(E,e=>{r()&&e(ee)}),H(`input`,u,h),Fi(u,()=>V(i).width,e=>V(i).width=e),H(`change`,p,h),Si(p,()=>V(i).style,e=>V(i).style=e),H(`input`,x,h),Fi(x,()=>V(i).lengthValue,e=>V(i).lengthValue=e),H(`change`,S,h),Si(S,()=>V(i).lengthUnit,e=>V(i).lengthUnit=e),W(e,a)}),H(`input`,o,h),Fi(o,()=>J.appearance.vesselSize,e=>J.appearance.vesselSize=e),W(e,t)};ti(ee,e=>{V(r)===`vessel`&&e(te)});var ne=R(ee,2),D=e=>{var t=nz(),n=R(Cn(t),2),r=R(L(n),2);XR(L(r),{oninput:h,get value(){return J.appearance.ais.vesselColor},set value(e){J.appearance.ais.vesselColor=e}}),N(r),N(n);var i=R(n,2),a=R(L(i),2),u=L(a);Oi(u),Ie(2),N(a),N(i);var d=R(i,4),f=R(L(d),2);XR(L(f),{oninput:h,get value(){return J.appearance.ais.cog.color},set value(e){J.appearance.ais.cog.color=e}}),N(f),N(d);var p=R(d,2),m=R(L(p),2),g=L(m);Oi(g),Ie(2),N(m),N(p);var _=R(p,2),v=R(L(_),2),y=L(v),b=L(y);b.value=b.__value=`solid`;var x=R(b);x.value=x.__value=`dashed`;var S=R(x);S.value=S.__value=`dotted`;var C=R(S);C.value=C.__value=`dash-dot`,N(y),N(v),N(_);var w=R(_,2),T=R(L(w),2),E=L(T);Oi(E),Ie(2),N(T),N(w);var ee=R(w,4),te=R(L(ee),2),ne=L(te);Oi(ne);var D=R(ne,2),O=L(D,!0);N(D);var k=R(D,2),re=L(k,!0);N(k),N(te),N(ee),Un((e,t,n)=>{ki(ne,e),Kr(O,t),Kr(re,n)},[()=>o(J.targetFps),()=>c(J.targetFps),()=>l(yu.value)]),H(`input`,u,h),Fi(u,()=>J.appearance.ais.vesselSize,e=>J.appearance.ais.vesselSize=e),H(`input`,g,h),Fi(g,()=>J.appearance.ais.cog.width,e=>J.appearance.ais.cog.width=e),H(`change`,y,h),Si(y,()=>J.appearance.ais.cog.style,e=>J.appearance.ais.cog.style=e),H(`input`,E,h),Fi(E,()=>J.appearance.ais.cog.lengthMinutes,e=>J.appearance.ais.cog.lengthMinutes=e),H(`input`,ne,e=>J.setTargetFps(s(+e.target.value))),W(e,t)};ti(ne,e=>{V(r)===`ais`&&e(D)});var O=R(ne,2),k=e=>{var t=az(),n=R(Cn(t),2);ai(n,16,()=>[{key:`bearing`,nextTitle:`Active segment`},{key:`segment`,nextTitle:`Remaining route`},{key:`remaining`,nextTitle:null}],({key:e,nextTitle:t})=>e,(e,t)=>{let n=()=>t.key,r=()=>t.nextTitle,i=Jt(()=>n()===`bearing`?J.appearance.route.bearing:n()===`segment`?J.appearance.route.segment:J.appearance.route.remaining);var a=iz(),o=Cn(a),s=R(L(o),2);XR(L(s),{oninput:h,get value(){return V(i).color},set value(e){V(i).color=e}}),N(s),N(o);var c=R(o,2),l=R(L(c),2),u=L(l);Oi(u),Ie(2),N(l),N(c);var d=R(c,2),f=R(L(d),2),p=L(f),m=L(p);m.value=m.__value=`solid`;var g=R(m);g.value=g.__value=`dashed`;var _=R(g);_.value=_.__value=`dotted`;var v=R(_);v.value=v.__value=`dash-dot`,N(p),N(f),N(d);var y=R(d,2),b=e=>{var t=rz(),n=L(t,!0);N(t),Un(()=>Kr(n,r())),W(e,t)};ti(y,e=>{r()&&e(b)}),H(`input`,u,h),Fi(u,()=>V(i).width,e=>V(i).width=e),H(`change`,p,h),Si(p,()=>V(i).style,e=>V(i).style=e),W(e,a)});var r=R(n,4),i=R(L(r),2);XR(L(i),{oninput:h,get value(){return J.appearance.ruler.color},set value(e){J.appearance.ruler.color=e}}),N(i),N(r);var a=R(r,2),o=R(L(a),2),s=L(o);Oi(s),Ie(2),N(o),N(a),H(`input`,s,h),Fi(s,()=>J.appearance.ruler.width,e=>J.appearance.ruler.width=e),W(e,t)};ti(O,e=>{V(r)===`routes`&&e(k)});var re=R(O,2),ie=e=>{var t=oz(),n=R(L(t),4),r=L(n);r.nodeValue=`v0.9.0 `;var i=R(r);i.textContent=`#4077c14`,N(n),Ie(4),N(t),W(e,t)};ti(re,e=>{V(r)===`about`&&e(ie)});var ae=R(re,2),oe=L(ae),se=e=>{var t=sz(),n=Cn(t),r=R(n,2);H(`click`,n,p),H(`click`,r,f),W(e,t)},ce=e=>{var t=cz();H(`click`,t,m),W(e,t)},le=e=>{var t=lz(),n=Cn(t),r=R(n,2);H(`click`,n,p),H(`click`,r,m),W(e,t)};ti(oe,e=>{V(r)===`connection`?e(se):V(r)===`about`?e(ce,1):e(le,-1)}),N(ae),N(a),Un(()=>{g=_i(d,1,`tab svelte-1u3w06f`,null,g,{active:V(r)===`connection`}),v=_i(_,1,`tab svelte-1u3w06f`,null,v,{active:V(r)===`vessel`}),b=_i(y,1,`tab svelte-1u3w06f`,null,b,{active:V(r)===`ais`}),S=_i(x,1,`tab svelte-1u3w06f`,null,S,{active:V(r)===`routes`}),w=_i(C,1,`tab svelte-1u3w06f`,null,w,{active:V(r)===`about`})}),H(`click`,n,m),H(`click`,d,()=>I(r,`connection`)),H(`click`,_,()=>I(r,`vessel`)),H(`click`,y,()=>I(r,`ais`)),H(`click`,x,()=>I(r,`routes`)),H(`click`,C,()=>I(r,`about`)),W(e,t)};return ti(y,e=>{V(n)&&e(b)}),H(`click`,v,u),W(e,_),qe(g)}Ir([`click`,`change`,`input`]);var pz=U(`<li class="chart-row svelte-1mbfew2"><input type="checkbox" class="svelte-1mbfew2"/> <label class="chart-name svelte-1mbfew2"> </label></li>`),mz=U(`<li class="chart-row hint-row svelte-1mbfew2">Loading charts…</li>`),hz=U(`<li class="chart-row hint-row error svelte-1mbfew2"> </li>`),gz=U(`<span class="badge svelte-1mbfew2">WMS</span>`),_z=U(`<span class="badge svelte-1mbfew2">WMTS</span>`),vz=U(`<span class="chart-desc svelte-1mbfew2"> </span>`),yz=U(`<span class="wmts-warning svelte-1mbfew2">⚠ Cannot auto-discover tile URL (CORS). Enter template manually:</span> <div class="wmts-manual svelte-1mbfew2"><input type="text" class="wmts-input svelte-1mbfew2"/> <button class="wmts-apply svelte-1mbfew2">Apply</button></div>`,1),bz=U(`<span class="wmts-ok svelte-1mbfew2">✓ Custom URL active</span> <button class="wmts-clear svelte-1mbfew2">Clear</button>`,1),xz=U(`<option> </option>`),Sz=U(`<label class="wmts-showall-label svelte-1mbfew2" title="Show all layers from capabilities"><input type="checkbox" class="svelte-1mbfew2"/> All</label>`),Cz=U(`<div class="wmts-layer-row svelte-1mbfew2"><label class="wmts-layer-label svelte-1mbfew2">Layer</label> <select class="wmts-layer-select svelte-1mbfew2"></select> <!></div>`),wz=U(`<span class="wmts-ok svelte-1mbfew2"> </span>`),Tz=U(`<li class="chart-row svelte-1mbfew2"><input type="checkbox" class="svelte-1mbfew2"/> <div class="chart-info svelte-1mbfew2"><label class="chart-name svelte-1mbfew2"> <!> <!></label> <!> <span class="chart-meta svelte-1mbfew2"> </span> <!></div></li>`),Ez=U(`<div class="backdrop svelte-1mbfew2"></div> <div class="panel svelte-1mbfew2"><div class="panel-header svelte-1mbfew2"><span class="panel-title svelte-1mbfew2">Layers</span> <button class="close-btn svelte-1mbfew2" title="Close">✕</button></div> <ul class="chart-list svelte-1mbfew2"><!> <!></ul></div>`,1),Dz=U(`<button title="Charts"><!></button> <!>`,1);function Oz(e,t){Ke(t,!0);let n=F(!1),r=fn({});function i(){I(n,!V(n))}function a(){I(n,!1)}function o(e){Y.setOverride(e,r[e]??``)}var s=Dz(),c=Cn(s);let l;tu(L(c),{get icon(){return lu}}),N(c);var u=R(c,2),d=e=>{var t=Ez(),n=Cn(t),i=R(n,2),s=L(i),c=R(L(s),2);N(s);var l=R(s,2),u=L(l);ai(u,17,()=>Zu,e=>e.id,(e,t)=>{var n=pz(),r=L(n);Oi(r);var i=R(r,2),a=L(i,!0);N(i),N(n),Un(e=>{ji(r,`id`,`base-${V(t).id??``}`),Ai(r,e),ji(i,`for`,`base-${V(t).id??``}`),Kr(a,V(t).name)},[()=>td.enabled.has(V(t).id)]),H(`change`,r,()=>{td.toggle(V(t).id)}),W(e,n)});var d=R(u,2),f=e=>{W(e,mz())},p=e=>{var t=hz(),n=L(t);N(t),Un(()=>Kr(n,`⚠ ${Y.error??``}`)),W(e,t)},m=e=>{var t=Ur();ai(Cn(t),17,()=>Object.entries(Y.available),([e,t])=>e,(e,t)=>{var n=Jt(()=>S(V(t),2));let i=()=>V(n)[0],a=()=>V(n)[1];var s=Tz(),c=L(s);Oi(c);var l=R(c,2),u=L(l),d=L(u),f=R(d),p=e=>{W(e,gz())};ti(f,e=>{a().type===`WMS`&&e(p)});var m=R(f,2),h=e=>{W(e,_z())};ti(m,e=>{a().type===`WMTS`&&e(h)}),N(u);var g=R(u,2),_=e=>{var t=vz(),n=L(t,!0);N(t),Un(()=>Kr(n,a().description)),W(e,t)};ti(g,e=>{a().description&&e(_)});var v=R(g,2),y=L(v);N(v);var b=R(v,2),x=e=>{var t=yz(),n=R(Cn(t),2),a=L(n);Oi(a),ji(a,`placeholder`,`https://…/{z}/{x}/{y}.png`);var s=R(a,2);N(n),Un(e=>ki(a,e),[()=>r[i()]??Y.getOverride(i())]),H(`input`,a,e=>{r[i()]=e.target.value}),H(`keydown`,a,e=>{e.key===`Enter`&&o(i())}),H(`click`,s,()=>o(i())),W(e,t)},C=Jt(()=>Y.needsManualUrl(i())),w=e=>{var t=bz();H(`click`,R(Cn(t),2),()=>{Y.setOverride(i(),``),r[i()]=``}),W(e,t)},T=Jt(()=>a().type===`WMTS`&&Y.getOverride(i())),E=e=>{var t=Ur(),n=Cn(t),r=e=>{var t=Cz(),n=L(t),r=R(n,2);ai(r,21,()=>Y.visibleLayers(i()),e=>e.id,(e,t)=>{var n=xz(),r=L(n,!0);N(n);var i={};Un(()=>{Kr(r,V(t).title),i!==(i=V(t).id)&&(n.value=(n.__value=V(t).id)??``)}),W(e,n)}),N(r);var a;xi(r);var o=R(r,2),s=e=>{var t=Sz(),n=L(t);Oi(n),Ie(),N(t),Un(e=>Ai(n,e),[()=>Y.isShowingAll(i())]),H(`change`,n,()=>Y.toggleShowAll(i())),W(e,t)},c=Jt(()=>Y.hasFilter(i()));ti(o,e=>{V(c)&&e(s)}),N(t),Un(e=>{ji(n,`for`,`wmts-layer-${i()??``}`),ji(r,`id`,`wmts-layer-${i()??``}`),a!==(a=e)&&(r.value=(r.__value=e)??``,bi(r,e))},[()=>Y.getLayerSel(i())]),H(`change`,r,e=>{Y.selectLayer(i(),e.target.value)}),W(e,t)},a=Jt(()=>Y.visibleLayers(i()).length>1),o=e=>{var t=wz(),n=L(t);N(t),Un(e=>Kr(n,`Layer: ${e??``}`),[()=>Y.visibleLayers(i())[0]?.title]),W(e,t)},s=Jt(()=>Y.visibleLayers(i()).length===1);ti(n,e=>{V(a)?e(r):V(s)&&e(o,1)}),W(e,t)};ti(b,e=>{V(C)?e(x):V(T)?e(w,1):a().type===`WMTS`&&e(E,2)}),N(l),N(s),Un((e,t,n,r)=>{ji(c,`id`,`cp-chart-${i()??``}`),Ai(c,e),c.disabled=t,ji(u,`for`,`cp-chart-${i()??``}`),Kr(d,`${a().name??``} `),Kr(y,`${n??``}${r??``}`)},[()=>Y.selected.has(i()),()=>Y.needsManualUrl(i()),()=>a().format.toUpperCase(),()=>a().scale?` · 1:${a().scale.toLocaleString()}`:``]),H(`change`,c,()=>{Y.toggle(i())}),W(e,s)}),W(e,t)};ti(d,e=>{Y.loading?e(f):Y.error?e(p,1):e(m,-1)}),N(l),N(i),H(`click`,n,a),H(`keydown`,n,a),H(`click`,c,a),W(e,t)};ti(u,e=>{V(n)&&e(d)}),Un(()=>l=_i(c,1,`charts-btn svelte-1mbfew2`,null,l,{active:V(n)})),H(`click`,c,i),W(e,s),qe()}Ir([`click`,`keydown`,`change`,`input`]);var kz=U(`<span style="color: #f87171"> </span>`),Az=U(`<div style="position: relative; width: 100%; height: 100%;"><!> <!> <!> <div style="
|
|
3829
3912
|
position: absolute; top: 10px; left: 10px; z-index: 10;
|
|
3830
3913
|
background: rgba(0,0,0,0.7); color: white;
|
|
3831
3914
|
padding: 6px 12px; border-radius: 6px; font: 12px monospace;
|
|
@@ -3835,12 +3918,12 @@ void main(void) {
|
|
|
3835
3918
|
background: rgba(0,0,0,0.7); border: 1px solid transparent; color: white;
|
|
3836
3919
|
padding: 6px 10px; border-radius: 6px; cursor: pointer;
|
|
3837
3920
|
font-size: 16px;
|
|
3838
|
-
"><!></button></div>`);function
|
|
3921
|
+
"><!></button></div>`);function jz(e,t){Ke(t,!0);let n=()=>pt(du,`$vesselState`,r),[r,i]=mt(),a=F(null),o=F(null),s=F(!1),c=F(null),l=null,u=null,d=2e3,f=null;Ln(()=>{if(!J.useGeoLocation||!(`geolocation`in navigator))return;let e=navigator.geolocation.watchPosition(e=>{let{longitude:t,latitude:n,speed:r,heading:i}=e.coords;du.set({position:{longitude:t,latitude:n},cog:i!==null&&isFinite(i)?Math.PI/180*i:null,sog:r!==null&&isFinite(r)?r:null,heading:f})},e=>{console.warn(`[geolocation] error`,e.code,e.message),e.code===GeolocationPositionError.PERMISSION_DENIED?(J.setGeoError(`Location access denied — check browser/OS permissions`),J.apply({useGeoLocation:!1})):e.code===GeolocationPositionError.POSITION_UNAVAILABLE?J.setGeoError(`Location unavailable — GPS signal lost`):J.setGeoError(`Location error: ${e.message}`)},{enableHighAccuracy:!0,maximumAge:2e3,timeout:15e3});return()=>{navigator.geolocation.clearWatch(e),f=null}}),Ln(()=>{if(!J.useGeoLocation||!(`DeviceOrientationEvent`in window))return;let e=!1,t=!1;function n(e){return(360-e)%360*(Math.PI/180)}function r(){t||(t=!0,requestAnimationFrame(()=>{t=!1,du.update(e=>({...e,heading:f}))}))}function i(t){t.alpha!==null&&(e=!0,f=n(t.alpha),r())}function a(t){if(e)return;let i=t.webkitCompassHeading;if(typeof i==`number`&&isFinite(i))f=Math.PI/180*i;else if(t.absolute&&t.alpha!==null)f=n(t.alpha);else return;r()}return window.addEventListener(`deviceorientationabsolute`,i),window.addEventListener(`deviceorientation`,a),()=>{window.removeEventListener(`deviceorientationabsolute`,i),window.removeEventListener(`deviceorientation`,a),f=null,du.update(e=>({...e,heading:null}))}});function p(){u===null&&(u=setTimeout(()=>{u=null;let e=J.signalkUrl;e&&l?.postMessage({type:`connect`,url:e})},d),d=Math.min(d*2,3e4))}Qr(()=>{l=new Worker(new URL(``+new URL(`signalk.worker-BA8YHNLb.js`,import.meta.url).href,``+import.meta.url),{type:`module`}),l.onmessage=e=>{let t=e.data;if(t.type===`state`){let e=t.state.position;J.useGeoLocation||e&&du.set({position:{longitude:e.longitude,latitude:e.latitude},cog:t.state.cog??null,sog:t.state.sog??null,heading:t.state.heading??null,course:t.state.course}),NL.update(J.signalkHttpUrl,t.state.course)}else t.type===`status`?(I(s,t.status===1),t.status===1?(d=2e3,(Y.error||Object.keys(Y.available).length===0)&&Y.load(J.signalkHttpUrl)):(t.status===2||t.status===3)&&(t.status===3&&I(c,`Connection error`),p()),t.status===2&&I(c,null)):t.type===`ais`?rd.updateBinary(t.hot,t.ids,t.cold):(I(c,`Signal K client failed: ${t.message}`),console.error(`[signalk] worker error`,t.message))};let e=()=>{if(document.visibilityState===`visible`&&!V(s)){u!==null&&(clearTimeout(u),u=null);let e=J.signalkUrl;e&&l?.postMessage({type:`connect`,url:e})}};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e),u!==null&&clearTimeout(u),l?.postMessage({type:`disconnect`}),l?.terminate()}});let m=``,h=null;Ln(()=>{let e=J.signalkHttpUrl;if(e===m)return;m=e,Y.load(e),h!==null&&clearInterval(h);let t=()=>void Pu(e).then(e=>rd.setInfoCache(e));return t(),h=setInterval(t,18e4),()=>{h!==null&&clearInterval(h)}});let g=``;Ln(()=>{let e=J.signalkUrl;e!==g&&(g=e,I(s,!1),I(c,null),d=2e3,u!==null&&(clearTimeout(u),u=null),l?.postMessage({type:`connect`,url:e}))});var _=Az(),v=L(_);zi(JR(v,{openSettings:e=>V(o)?.openTo(e)}),e=>I(a,e,!0),()=>V(a));var y=R(v,2);zi(fz(y,{}),e=>I(o,e,!0),()=>V(o));var b=R(y,2);Oz(b,{});var x=R(b,2),S=L(x),C=R(S,2),w=e=>{var t=kz(),n=L(t);N(t),Un(()=>Kr(n,`⚠ ${V(c)??``}`)),W(e,t)};ti(C,e=>{V(c)&&e(w)}),N(x);var T=R(x,2);tu(L(T),{get icon(){return cu}}),N(T);var E=R(T,2);tu(L(E),{get icon(){return au}}),N(E),N(_),Un(()=>{yi(S,`color: ${V(s)?`#4ade80`:`#f87171`}`),ji(T,`title`,xu.following?`Stop following vessel`:`Follow vessel`),T.disabled=!n().position,yi(T,`
|
|
3839
3922
|
position: absolute; top: 120px; left: 10px; z-index: 10;
|
|
3840
|
-
background: ${
|
|
3923
|
+
background: ${xu.following?`rgba(255,255,255,0.9)`:`rgba(0,0,0,0.7)`};
|
|
3841
3924
|
border: none;
|
|
3842
|
-
color: ${
|
|
3925
|
+
color: ${xu.following?`#111827`:`white`};
|
|
3843
3926
|
padding: 6px 10px; border-radius: 6px; cursor: pointer;
|
|
3844
3927
|
font-size: 16px; transition: background 0.15s, color 0.15s;
|
|
3845
3928
|
opacity: ${n().position?1:.35};
|
|
3846
|
-
`)}),H(`click`,
|
|
3929
|
+
`)}),H(`click`,T,()=>V(a)?.flyToVessel()),H(`click`,E,()=>V(a)?.addRuler()),W(e,_),qe(),i()}Ir([`click`]);var Mz=document.getElementById(`app`);if(!Mz)throw Error(`No #app element found`);qr(jz,{target:Mz});
|